From 0fbc3c0c84982bfa851e80cde02fa037c0f5eaa0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 12 Aug 2017 14:18:51 -0500 Subject: [PATCH 001/244] Fix build error with g++ 6.3 (Debian Stretch) On this platform, TEST_NULLPTR fails, even though nullptr and nullptr_t are supported: /home/jepler/src/stepcode/build/CMakeFiles/CMakeTmp/src.cxx:4:23: error: converting to 'bool' from 'std::nullptr_t' requires direct-initialization [-fpermissive] int main() {return !!f();} ~^~ Subsequent to this failure, the workaround definitions in sc_nullptr.h prevent standard C++ headers (which must refer to real nullptr) to fail. The failure occurs because the C++ standard apparently does not state that operator! may be used on nullptr. Despite this, some compilers have historically allowed it. g++ 6.3's behavior appears to be aligned with the standard. As requested by @brlcad, ensure that the function 'f' is used from main, to avoid a clever (but not nullptr-supporting) compiler from somehow skipping 'f' altogether, creating a false positive for nullptr support. --- cmake/SC_Config_Headers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 2ed3ba6e5..f272c94d3 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -80,7 +80,7 @@ std::cout << \"1s is \"<< std::chrono::duration_cast( set( TEST_NULLPTR " #include std::nullptr_t f() {return nullptr;} -int main() {return !!f();} +int main() {return !(f() == f());} " ) cmake_push_check_state() if( UNIX ) From 3fd71cf4573a3c39952a84ac96c92de9c8c76e46 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 15 Aug 2017 20:38:47 -0500 Subject: [PATCH 002/244] appveyor build: don't use ctest parallelism On Windows, concurrent access to files is severely restricted compared to standard operating systems. When ctest is invoking cmake, this causes it to write simultaneously to the same files in each concurrent cmake invocation, leading to spurious test failures like error MSB3491: Could not write lines to file "...". The process cannot access the file '...' because it is being used by another process. Explicitly ask for no parallelism with "-j1", even though it is probably the default. --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index a7c68957a..77c1c5f01 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -58,7 +58,7 @@ test_script: - cmd: echo Running CTest... - cmd: cd c:\projects\STEPcode\build - cmd: echo excluding test_inverse_attr3, which hangs - - cmd: ctest -j2 . -C Debug -E test_inverse_attr3 --output-on-failure + - cmd: ctest -j1 . -C Debug -E test_inverse_attr3 --output-on-failure # - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log From 0b6cd90dd962fd617bf7995e971c1b8a125637b9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 16 Aug 2017 07:32:37 -0500 Subject: [PATCH 003/244] Fix test_inverse_attr3 failure This fixes the failure in test_inverse_attr3 seen on travis ci's osx build. Actually, only the change to sectionReader::getRealInstance is needed to fix the test, but as the reason that 'unget' can fail is unclear, I changed all instances of 'unget' to use the 'seekg' + arithmetic method instead. I failed to find a reason why 'unget' could fail in this way, or reports of macos-specific failures in 'unget', but I was not enlightened. I do not know whether test_inverse_attr3 would *consistently* hang on Appveyor, but after this change (and modifying .appveyor.yml to not skip test_inverse_attr3) it did succeed on the first try. --- src/cllazyfile/sectionReader.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index bd3d9c23a..15220078a 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -47,7 +47,7 @@ std::streampos sectionReader::findNormalString( const std::string & str, bool se } if( c == '\'' ) { //push past string - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); } if( ( c == '/' ) && ( _file.peek() == '*' ) ) { @@ -129,7 +129,7 @@ std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { } break; case '\'': - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); break; case '=': @@ -155,7 +155,7 @@ std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { if( _file.get() == ';' ) { return _file.tellg(); } else { - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); } } default: @@ -186,7 +186,7 @@ instanceID sectionReader::readInstanceNumber() { if( ( c == '/' ) && ( _file.peek() == '*' ) ) { findNormalString( "*/" ); } else { - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); } skipWS(); c = _file.get(); @@ -210,7 +210,7 @@ instanceID sectionReader::readInstanceNumber() { digits++; } else { - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); break; } @@ -309,7 +309,7 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg assert( inst->getEDesc() ); _file.seekg( begin ); findNormalString( "(" ); - _file.unget(); + _file.seekg( _file.tellg() - std::streampos(1) ); sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false ); //TODO do something with 'sev' inst->InitIAttrs(); From e422262877abce2c8db2e4974141d29450d03c44 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 15 Aug 2017 19:47:26 -0500 Subject: [PATCH 004/244] sc_version_string: omit the date and time when testing As analyzed in #359, if the header contains the current time, it will be updated while running the testsuite; this, in turn, causes multiple cmake processes to attempt to update targets like lib/libexpress.so.2.0.0 at the same time, causing test failures. --- cmake/sc_version_string.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake index 3c7f89927..2acf43d9d 100644 --- a/cmake/sc_version_string.cmake +++ b/cmake/sc_version_string.cmake @@ -8,6 +8,7 @@ # http://www.cmake.org/pipermail/cmake/2009-February/027014.html set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") +set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@") set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h") @@ -47,7 +48,9 @@ string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) #once cmake_minimum_required is >= 2.8.11, we can use TIMESTAMP: #string(TIMESTAMP date_time_string) -if(UNIX) +if(SC_ENABLE_TESTING) + set (date_time_string "NA - disabled for testing") +elseif(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) From d39fbaf4d7f68d4b246d2ee27481b25a824a2b85 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 15 Aug 2017 19:54:05 -0500 Subject: [PATCH 005/244] sc_version_string: Use temporary names resilient against parallel builds In #359 I identify a race condition between multiple parallel invocations of cmake, which can arise naturally during ctests. Now that the file contents will not change without an intervening git commit, it is sufficient to ensure that the parallel invocations use distinct temporary file names with high probability. --- cmake/sc_version_string.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake index 2acf43d9d..e6e2501c3 100644 --- a/cmake/sc_version_string.cmake +++ b/cmake/sc_version_string.cmake @@ -78,9 +78,10 @@ set(header_string "/* sc_version_string.h - written by cmake. Changes will be lo ) #don't update the file unless somethig changed -file(WRITE ${SC_VERSION_HEADER}.tmp ${header_string}) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.tmp ${SC_VERSION_HEADER}) -execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.tmp) +string(RANDOM tmpsuffix) +file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) +execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix}) if(NOT SC_IS_SUBBUILD) message("-- sc_version_string.h is up-to-date.") From 0d2e791e823ec2462234c0787989f8b1ae26388f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 15 Aug 2017 07:25:10 -0500 Subject: [PATCH 006/244] express/error.c: Ensure the error buffer does not overflow On Debian Stretch, when configuring stepcode like so: ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CXXFLAGS="-fsanitize=address" cmake .. a fatal error would be detected: ==29661==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62100001dca0 at pc 0x0000004435e3 bp 0x7ffed6d9cae0 sp 0x7ffed6d9c290 READ of size 4001 at 0x62100001dca0 thread T0 #0 0x4435e2 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4435e2) #1 0x501d7b in ERRORreport_with_symbol /home/jepler/src/stepcode/src/express/error.c:413 0x62100001dca0 is located 0 bytes to the right of 4000-byte region [0x62100001cd00,0x62100001dca0) allocated by thread T0 here: #0 0x4c3ae8 in __interceptor_malloc (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4c3ae8) #1 0x5011fc in ERRORinitialize /home/jepler/src/stepcode/src/express/error.c:129 Operations on ERROR_string were unsafe, because they did not guard against accesses beyond the end of the allocatd region. This patch ensures that all accesses via *printf functions do respect the end of the buffer; and encapsulates the routine for pointing ERROR_string at the space for the next error text to start, if space is available. Finally, because it was found with search and replace, a stray manipulation of ERROR_string within the print-to-file branch of the code is removed. This stray line would have had the effect of moving ERROR_string one byte further along at every warning-to-file, which could also have been a cause of the problem here. --- src/express/error.c | 52 +++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/express/error.c b/src/express/error.c index abcb8a2b0..996aae1df 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -67,6 +67,9 @@ #include "express/info.h" #include "express/linklist.h" +#if defined( _WIN32 ) || defined ( __WIN32__ ) +# define snprintf _snprintf +#endif bool __ERROR_buffer_errors = false; const char * current_filename = "stdin"; @@ -112,6 +115,7 @@ static struct heap_element { static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */ static char * ERROR_string; static char * ERROR_string_base; +static char * ERROR_string_end; static bool ERROR_unsafe = false; static jmp_buf ERROR_safe_env; @@ -119,6 +123,34 @@ static jmp_buf ERROR_safe_env; #define error_file stderr /**< message buffer file */ +static int ERROR_vprintf( const char *format, va_list ap ) { + int result = snprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); + if(result < 0) { + ERROR_string = ERROR_string_end; + } else if(result > (ERROR_string_end - ERROR_string)) { + ERROR_string = ERROR_string_end; + } else { + ERROR_string = ERROR_string + result; + } + return result; +} + +static int ERROR_printf( const char *format, ... ) { + int result; + va_list ap; + va_start( ap, format ); + result = ERROR_vprintf( format, ap ); + va_end( ap ); + return result; +} + +static void ERROR_nexterror() { + if( ERROR_string == ERROR_string_end ) { + return; + } + ERROR_string++; +} + /** Initialize the Error module */ void ERRORinitialize( void ) { ERROR_subordinate_failed = @@ -127,6 +159,7 @@ void ERRORinitialize( void ) { ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT ); ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); + ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); @@ -377,20 +410,14 @@ va_dcl { heap[child].msg = ERROR_string; if( what->severity >= SEVERITY_ERROR ) { - sprintf( ERROR_string, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial ); - ERROR_string += strlen( ERROR_string ); - vsprintf( ERROR_string, what->message, args ); - ERROR_string += strlen( ERROR_string ); - *ERROR_string++ = '\n'; - *ERROR_string++ = '\0'; + ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial ); + ERROR_vprintf( what->message, args ); + ERROR_nexterror(); ERRORoccurred = true; } else { - sprintf( ERROR_string, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial ); - ERROR_string += strlen( ERROR_string ); - vsprintf( ERROR_string, what->message, args ); - ERROR_string += strlen( ERROR_string ); - *ERROR_string++ = '\n'; - *ERROR_string++ = '\0'; + ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial ); + ERROR_vprintf( what->message, args ); + ERROR_nexterror(); } if( what->severity >= SEVERITY_EXIT || ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE || @@ -410,7 +437,6 @@ va_dcl { ERRORoccurred = true; } else { fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial ); - ERROR_string += strlen( ERROR_string ) + 1; vfprintf( error_file, what->message, args ); fprintf( error_file, "\n" ); } From 1d01b831aa3094de66a4337f27c3b08c90bfbace Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 15 Aug 2017 07:35:58 -0500 Subject: [PATCH 007/244] errordesc.cc: Correctly append a single character to a std::string The idiom char c = ...; _userMsg.append( &c ); is not correct C++, because it treats the address of 'c' as a NUL- terminated C string. However, this is not guaranteed. When building and testing on Debian Stretch with AddressSanitizer: ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CC=clang CXXFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" cmake .. -DSC_ENABLE_TESTING=ON -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209" ASAN_OPTIONS="detect_leaks=false" make ASAN_OPTIONS="detect_leaks=false" ctest . --output-on-failure an error like the following is encountered: ==15739==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffeb2ca7621 at pc 0x00000043c943 bp 0x7ffeb2ca75d0 sp 0x7ffeb2ca6d80 READ of size 33 at 0x7ffeb2ca7621 thread T0 #0 0x43c942 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/lazy_sdai_ap214e3+0x43c942) #1 0x7fb9056e6143 in std::__cxx11::basic_string, std::allocator >::append(char const*) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x11f143) #2 0x7fb905b677c3 in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:150:5 Address 0x7ffeb2ca7621 is located in stack of thread T0 at offset 33 in frame #0 0x7fb905b676af in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:149 This frame has 1 object(s): [32, 33) '' <== Memory access at offset 33 overflows this variable A similar problem with AppendToUserMsg is found by inspection. After this change, all 200 tests pass under the AddressSanitizer configuration --- src/clutils/errordesc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index 061b9a4e9..c5a998c8c 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -131,7 +131,7 @@ void ErrorDescriptor::PrependToUserMsg( const char * msg ) { } void ErrorDescriptor::AppendToUserMsg( const char c ) { - _userMsg.append( &c ); + _userMsg.push_back( c ); } void ErrorDescriptor::AppendToUserMsg( const char * msg ) { @@ -147,7 +147,7 @@ void ErrorDescriptor::PrependToDetailMsg( const char * msg ) { } void ErrorDescriptor::AppendToDetailMsg( const char c ) { - _detailMsg.append( &c ); + _detailMsg.push_back( c ); } void ErrorDescriptor::AppendToDetailMsg( const char * msg ) { From 84472921c138183ce3f2ec29c2a22a52e4578249 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 16 Aug 2017 17:41:39 -0500 Subject: [PATCH 008/244] Don't open part 21 files as text files On Windows, when a file is opened in "text" mode, but it actually contains Unix-style line endings, the behavior of tellg() is unexpected. Consider this program which puts the (binary) contents "a\nb\n" in a file, then opens it in text mode for reading. It prints each character read, along with the value returned by tellg(): #include #include int main() { { std::ofstream f("myfile.txt", std::ios::binary); f << "a\nb\n"; } std::ifstream f("myfile.txt"); for (char c=0; f.get(c);) std::cout << f.tellg() << ' ' << int(c) << '\n'; } On a UNIX platform which does not have a distinction between "text" and "binary" files, the output will read 1 97 2 10 3 98 4 10 because the file position simply advances one position after each byte is read. On Windows with the Visual Studio C and C++ runtime, the result is instead -1 97 1 10 2 98 4 10 While it is impossible to say exactly what the Windows runtime is doing here, it appears that it is trying to adjust for the mismatch between "number of bytes read in byte oriented mode and "number of bytes read in text mode". Since "part21" files don't necessarily contain CRLF line endings when viewed in binary mode, open the file in binary mode. This fixes the test failure seen on appveyor ci running the "test_inverse_attr3" test. --- src/cllazyfile/lazyFileReader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index b31a6dfd3..9cc294df0 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -50,7 +50,7 @@ instancesLoaded_t * lazyFileReader::getHeaderInstances() { } lazyFileReader::lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ): _fileName( fname ), _parent( i ), _fileID( fid ) { - _file.open( _fileName.c_str() ); + _file.open( _fileName.c_str(), std::ios::binary ); _file.imbue( std::locale::classic() ); _file.unsetf( std::ios_base::skipws ); assert( _file.is_open() && _file.good() ); From 6fe864865751d0bdb37bdee801ab726b89310417 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 22 Aug 2017 20:32:00 -0500 Subject: [PATCH 009/244] travis: no longer allow osx failures .. the known failure was fixed at 0b6cd90d --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d186c6b2..269a382ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,3 @@ notifications: os: - linux - osx -matrix: - allow_failures: - - os: osx From e5a534d5e5081a120c7f20c1cef520921def89ba Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 28 Aug 2017 07:51:42 -0500 Subject: [PATCH 010/244] appveyor: don't skip test on Windows The test failure has been fixed since 84472921 --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 77c1c5f01..b7f2d5c36 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -58,7 +58,7 @@ test_script: - cmd: echo Running CTest... - cmd: cd c:\projects\STEPcode\build - cmd: echo excluding test_inverse_attr3, which hangs - - cmd: ctest -j1 . -C Debug -E test_inverse_attr3 --output-on-failure + - cmd: ctest -j1 . -C Debug --output-on-failure # - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log From 0eb7aabbb3b765af39289ae44e27df4ae2d08178 Mon Sep 17 00:00:00 2001 From: luzpaz Date: Fri, 15 Sep 2017 11:48:28 -0400 Subject: [PATCH 011/244] Misc. typos A few user-facing and the rest just code comments --- COPYING | 2 +- NEWS | 4 +-- doc/doxyassist.xml | 2 +- doc/man/man1/exp2cxx.1 | 2 +- include/express/schema.h | 2 +- include/express/stmt.h | 2 +- misc/flawfinder | 2 +- src/cleditor/SdaiHeaderSchema.cc | 34 +++++++++---------- src/clstepcore/STEPaggregate.cc | 2 +- src/clstepcore/complexlist.cc | 2 +- src/clstepcore/dict-pic.txt | 2 +- src/clstepcore/sdai.h | 2 +- src/exp2cxx/classes.h | 2 +- src/exp2cxx/classes_entity.c | 2 +- src/exp2cxx/classes_type.c | 2 +- src/exp2cxx/complexlist.cc | 2 +- src/exp2cxx/selects.c | 2 +- src/exp2python/DESIGN.txt | 2 +- .../python/SCL/ConstructedDataTypes.py | 2 +- src/exp2python/src/classes.h | 2 +- src/exp2python/src/classes_python.c | 2 +- src/express/README | 2 +- src/express/ordered_attrs.cc | 2 +- src/express/stmt.c | 2 +- src/test/scl2html/scl2html.cc | 6 ++-- 25 files changed, 44 insertions(+), 44 deletions(-) diff --git a/COPYING b/COPYING index 27cd65330..45c5ac40b 100644 --- a/COPYING +++ b/COPYING @@ -4,7 +4,7 @@ on the date those changes were committed to whichever repository they were committed to first (i.e. BRL-CAD on SourceForge.net, mpictor/StepClassLibrary or stepcode/stepcode on github). -Modifications which were first commited to the repository on github +Modifications which were first committed to the repository on github are licensed under the 3-clause BSD license below. Changes committed to BRL-CAD either contain license information mentioning BRL-CAD near the top of the file, or are licensed under the same terms that diff --git a/NEWS b/NEWS index bdf02e439..25f05d0d1 100644 --- a/NEWS +++ b/NEWS @@ -176,7 +176,7 @@ There were also some issues with the configure script and some makefiles which are addressed, as well as a new macro that is at least required for gcc. -Remaing problem: The p21 file scanner of SCL currently +Remaining problem: The p21 file scanner of SCL currently does not allow for comments within the parameter list of data records. Only comments outside of data records are accepted. @@ -987,7 +987,7 @@ the attribute value field in the entity editor. If there wasn't a value in the attribute previously, then the field will contain just the type specifier, e.g., Str1() if Str1 is the type selected. -If a value exists in the field, it is modified to accomodate the new +If a value exists in the field, it is modified to accommodate the new specifier. This means the following: o If the value in the field starts with a single-quote ('), it is assumed to be a string literal, and is completely wrapped in the new diff --git a/doc/doxyassist.xml b/doc/doxyassist.xml index 27db20f0c..3eb5f8ac3 100644 --- a/doc/doxyassist.xml +++ b/doc/doxyassist.xml @@ -36,7 +36,7 @@ English - diff --git a/doc/man/man1/exp2cxx.1 b/doc/man/man1/exp2cxx.1 index 8cb0514d7..7ff17dd3a 100644 --- a/doc/man/man1/exp2cxx.1 +++ b/doc/man/man1/exp2cxx.1 @@ -5,7 +5,7 @@ .\" $Id: exp2cxx.1,v 2.1.0.2 1998/02/27 23:54:30 sauderd Exp $ .TH FEDEX_PLUS 1 "19 November 1997" .SH NAME -exp2cxx - EXPRESS compiler and translater +exp2cxx - EXPRESS compiler and translator .SH SYNOPSIS exp2cxx [ options ] [ express-file ] .nf diff --git a/include/express/schema.h b/include/express/schema.h index 309d75f6e..3640646cd 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -88,7 +88,7 @@ struct Schema_ { Linked_List reflist; Linked_List uselist; /** \var refdict, usedict - * dictionarys into which are entered renames for each specific + * dictionaries into which are entered renames for each specific * object specified in a rename clause (even if it uses the same * name */ Dictionary refdict; diff --git a/include/express/stmt.h b/include/express/stmt.h index 2a2acd10e..f32eaa7fd 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -27,7 +27,7 @@ * CADDETC certified * * Revision 1.5 1993/02/16 03:27:02 libes - * removed artifical begin/end nesting for improved reconstruction (printing) + * removed artificial begin/end nesting for improved reconstruction (printing) * of original Express file * * Revision 1.4 1992/08/18 17:12:41 libes diff --git a/misc/flawfinder b/misc/flawfinder index 680e65dc5..c0b12a99d 100755 --- a/misc/flawfinder +++ b/misc/flawfinder @@ -703,7 +703,7 @@ c_ruleset = { "lstrcpyn|wcsncpy|_tcsncpy|_mbsnbcpy" : (c_buffer, 1, # Low risk level, because this is often used correctly when FIXING security - # problems, and raising it to a higher risk levle would cause many false positives. + # problems, and raising it to a higher risk level would cause many false positives. "Easily used incorrectly; doesn't always \\0-terminate or " + "check for invalid pointers", "", diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index 6c96a2d2c..cea95b42f 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -62,7 +62,7 @@ SdaiSection_language::SdaiSection_language( SDAI_Application_instance * se, int /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -72,7 +72,7 @@ SdaiSection_language::SdaiSection_language( SDAI_Application_instance * se, int /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -144,7 +144,7 @@ SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -154,7 +154,7 @@ SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -164,7 +164,7 @@ SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -264,7 +264,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -274,7 +274,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -284,7 +284,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -294,7 +294,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -304,7 +304,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -314,7 +314,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -324,7 +324,7 @@ SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -452,7 +452,7 @@ SdaiSection_context::SdaiSection_context( SDAI_Application_instance * se, int * /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -462,7 +462,7 @@ SdaiSection_context::SdaiSection_context( SDAI_Application_instance * se, int * /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -530,7 +530,7 @@ SdaiFile_description::SdaiFile_description( SDAI_Application_instance * se, int /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -540,7 +540,7 @@ SdaiFile_description::SdaiFile_description( SDAI_Application_instance * se, int /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } @@ -604,7 +604,7 @@ SdaiFile_schema::SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs /*access functions still work. */ attributes.push( a ); /* Put attribute on the attributes list for the */ - /* main inheritance heirarchy. */ + /* main inheritance hierarchy. */ if( !addAttrs || addAttrs[0] ) { se->attributes.push( a ); } diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 65af0927a..db3bbf819 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -355,7 +355,7 @@ const char * STEPnode::asStr( std::string & s ) { * cause e.g. type X may be defined in schema A, and may be USEd in schema * B and renamed to Y (i.e., "USE from A (X as Y)"). Thus, if currSch = B, * Y will have to be written out rather than X. Actually, this concern - * only applies for SelectNode. To accomodate those cases, all the signa- + * only applies for SelectNode. To accommodate those cases, all the signa- * tures of STEPwrite(std::string) contain currSch. (As an additional note, * 2D aggregates should make use of currSch in case they are 2D aggrs of * selects. But since currently (3/27/97) the SCL handles 2D+ aggrs using diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index 52eb0a372..2fc289381 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -144,7 +144,7 @@ bool ComplexList::contains( EntNode * ents ) { ours = ours->next; } if( ours == NULL || *ours > *theirs ) { - // If either of these occured, we couldn't find one of ours which + // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return false; } diff --git a/src/clstepcore/dict-pic.txt b/src/clstepcore/dict-pic.txt index aea7a746e..79f3399ad 100644 --- a/src/clstepcore/dict-pic.txt +++ b/src/clstepcore/dict-pic.txt @@ -9,7 +9,7 @@ Jeff, This is the layout of the dictionary classes in our toolkit (when the new changes get integrated). This matches Part 23. -// The classes in the heirarchy are the new names for our classes. +// The classes in the hierarchy are the new names for our classes. // DictionaryInstance // | diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index 7c7985a3e..5751996a0 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -246,7 +246,7 @@ ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, /****************************************************************************** AGGREGATE TYPES - Aggregate types are accessed generically. (There are not seperate + Aggregate types are accessed generically. (There are not separate classes for the different types of aggregates.) Aggregates are implemented through the STEPaggregate class. diff --git a/src/exp2cxx/classes.h b/src/exp2cxx/classes.h index e6dd63c01..462e22687 100644 --- a/src/exp2cxx/classes.h +++ b/src/exp2cxx/classes.h @@ -76,7 +76,7 @@ typedef struct file_holder { } File_holder, FILES; /** these fields are used so that ENTITY types are processed in order - * when appearing in differnt schemas + * when appearing in different schemas */ typedef struct EntityTag_ * EntityTag; struct EntityTag_ { diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 9af9c3ec4..5d168625a 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -599,7 +599,7 @@ void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * fil fprintf( file, " /* Put attribute on this class' attributes list so the access functions still work. */\n" ); fprintf( file, " attributes.push( a );\n" ); - fprintf( file, " /* Put attribute on the attributes list for the main inheritance heirarchy. **\n" ); + fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n" ); fprintf( file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); fprintf( file, " if( addAttrs ) {\n" ); fprintf( file, " se->attributes.push( a );\n }\n" ); diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 20a850935..2f59dd8fa 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -94,7 +94,7 @@ void strcat_bounds( TypeBody b, char * buf ) { ** Description: prints code to represent an enumerated type in c++ ** Side Effects: prints to header file ** Status: ok 1/15/91 - ** Changes: Modified to check for appropiate key words as described + ** Changes: Modified to check for appropriate key words as described ** in "SDAI C++ Binding for PDES, Inc. Prototyping" by ** Stephen Clark. ** - Changed to match CD2 Part 23, 1/14/97 DAS diff --git a/src/exp2cxx/complexlist.cc b/src/exp2cxx/complexlist.cc index 84acd5a20..2a42c6d96 100644 --- a/src/exp2cxx/complexlist.cc +++ b/src/exp2cxx/complexlist.cc @@ -151,7 +151,7 @@ int ComplexList::contains( EntNode * ents ) ours = ours->next; } if( ours == NULL || *ours > *theirs ) { - // If either of these occured, we couldn't find one of ours which + // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return FALSE; } diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 23b89cbc5..9e4aae118 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -983,7 +983,7 @@ void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, co /* if the underlying type is that item's type, call the underlying_item's * member function if it is the same attribute */ if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { - /* update attribute_func_name because is has been overriden */ + /* update attribute_func_name because is has been overridden */ generate_attribute_func_name( uattr, funcnm ); } else { generate_attribute_func_name( a, funcnm ); diff --git a/src/exp2python/DESIGN.txt b/src/exp2python/DESIGN.txt index 7d70c6635..0481bef18 100644 --- a/src/exp2python/DESIGN.txt +++ b/src/exp2python/DESIGN.txt @@ -60,7 +60,7 @@ class AP203Parser(SCL.Part21.Parser): def __init__(self, ...): SCL.Part21.Parser.__init__(self) - # schema entities would be passed to the underlying lexer to faciliate exact rule matches + # schema entities would be passed to the underlying lexer to facilitate exact rule matches self.lexer.register_entities(self.entities) # validating form diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/SCL/ConstructedDataTypes.py index 4959704fc..afb3bd871 100644 --- a/src/exp2python/python/SCL/ConstructedDataTypes.py +++ b/src/exp2python/python/SCL/ConstructedDataTypes.py @@ -84,7 +84,7 @@ def get_allowed_types(self): def get_allowed_basic_types(self): ''' if a select contains some subselect, goes down through the different - sublayers untill there is no more ''' + sublayers until there is no more ''' b = [] _auth_types = self.get_allowed_types() for _auth_type in _auth_types: diff --git a/src/exp2python/src/classes.h b/src/exp2python/src/classes.h index c8642f217..a76cb6afa 100644 --- a/src/exp2python/src/classes.h +++ b/src/exp2python/src/classes.h @@ -70,7 +70,7 @@ typedef struct file_holder { } File_holder, FILES; /** these fields are used so that ENTITY types are processed in order - * when appearing in differnt schemas + * when appearing in different schemas */ typedef struct EntityTag_ * EntityTag; struct EntityTag_ { diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 4f1876201..f6b6b8554 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -767,7 +767,7 @@ LIBdescribe_entity( Entity entity, FILE * file ) { /* if the argument is not optional */ if( !VARget_optional( v ) ) { fprintf( file, "\t\t# Mandatory argument\n" ); - fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mantatory and cannot be set to None'\n" ); + fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); fprintf( file, "\t\tif not check_type(value," ); if( TYPEis_aggregate( t ) ) { process_aggregate( file, t ); diff --git a/src/express/README b/src/express/README index 34c0b9921..30774388e 100644 --- a/src/express/README +++ b/src/express/README @@ -41,7 +41,7 @@ them. I expect this should run on any UNIX, POSIX, or other system using a compatibility package. For instance, you can build this on a PC -runing DOS using djgpp (GNU C on DOS). (Ask your local archie server +running DOS using djgpp (GNU C on DOS). (Ask your local archie server where to get djgpp.) -------------------- diff --git a/src/express/ordered_attrs.cc b/src/express/ordered_attrs.cc index 7ee41e635..1286dd1bf 100644 --- a/src/express/ordered_attrs.cc +++ b/src/express/ordered_attrs.cc @@ -48,7 +48,7 @@ void populateAttrList( oaList & list, Entity ent ) { } LISTod } -///compare attr name and creator, remove all but first occurence +///compare attr name and creator, remove all but first occurrence ///this is necessary for diamond inheritance void dedupList( oaList & list ) { oaList::iterator it, jt; diff --git a/src/express/stmt.c b/src/express/stmt.c index 1ac62deac..d125cd12f 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -26,7 +26,7 @@ * CADDETC certified * * Revision 1.6 1993/02/16 03:27:02 libes - * removed artifical begin/end nesting for improved reconstruction (printing) + * removed artificial begin/end nesting for improved reconstruction (printing) * of original Express file * * Revision 1.5 1992/08/18 17:13:43 libes diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index b981fedae..6ed56c4c3 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -35,7 +35,7 @@ #include "../SEarritr.h" // PrintAttrTypeWithAnchor() -// Given an atribute, print out its immediate type (not fundamental). +// Given an attribute, print out its immediate type (not fundamental). // Ah, but if life were so simple. If this attribute is _not_ of a // fundamental type, put in an anchor to somewhere with info on the type. // This could be either the index page Type list, or an entity's page if @@ -162,9 +162,9 @@ void PrintParentAttrsHTML( const EntityDescriptor * ent, grandpaNode = ( EntityDescLinkNode * )grandpaNode->NextNode(); } - // Now print the parent's atributes. This calls PrintAttrsHTML() to + // Now print the parent's attributes. This calls PrintAttrsHTML() to // actually print any existing attributes, but to see if there are - // any, we'll check to see if the head of the atribute descriptor list + // any, we'll check to see if the head of the attribute descriptor list // exists. Conversely, once grabbing the head we could print out // the attributes by following the list (attrNode->NextNode()). const AttrDescriptorList * attrList = &( parent->ExplicitAttr() ); From 575a2f93b3ea5ec30fea1009b3db08c164c3cf94 Mon Sep 17 00:00:00 2001 From: luzpaz Date: Tue, 3 Oct 2017 08:47:55 -0400 Subject: [PATCH 012/244] More typos --- misc/flawfinder | 2 +- .../unitary_schemas/index_attribute.py | 6 +++--- .../examples/unitary_schemas/multiple_rep.py | 18 ++++++++--------- .../examples/unitary_schemas/test_array.py | 2 +- .../test_array_of_array_of_simple_types.py | 2 +- .../test_array_of_simple_types.py | 6 +++--- .../unitary_schemas/test_derived_attribute.py | 6 +++--- .../unitary_schemas/test_entity_where_rule.py | 6 +++--- .../test_multiple_inheritance.py | 12 +++++------ .../unitary_schemas/test_named_type.py | 6 +++--- .../unitary_schemas/test_select_data_type.py | 20 +++++++++---------- .../test_single_inheritance.py | 8 ++++---- .../test_single_inheritance_multi_level.py | 8 ++++---- src/exp2python/python/SCL/TypeChecker.py | 2 +- src/exp2python/src/classes_python.c | 2 +- src/express/resolve.c | 2 +- 16 files changed, 54 insertions(+), 54 deletions(-) diff --git a/misc/flawfinder b/misc/flawfinder index c0b12a99d..0c08fa353 100755 --- a/misc/flawfinder +++ b/misc/flawfinder @@ -102,7 +102,7 @@ blank_line = re.compile( r'(?m)^\s+$' ) # --- OLDFILENAME OLDTIMESTAMP # +++ NEWFILENAME NEWTIMESTAMP # @@ -OLDSTART,OLDLENGTH +NEWSTART,NEWLENGTH @@ -# ... Changes where preceeding "+" is add, "-" is remove, " " is unchanged. +# ... Changes where preceding "+" is add, "-" is remove, " " is unchanged. # # ",OLDLENGTH" and ",NEWLENGTH" are optional (they default to 1). # GNU unified diff format doesn't normally output "Index:"; you use diff --git a/src/exp2python/examples/unitary_schemas/index_attribute.py b/src/exp2python/examples/unitary_schemas/index_attribute.py index 4824586a3..32fffaeab 100644 --- a/src/exp2python/examples/unitary_schemas/index_attribute.py +++ b/src/exp2python/examples/unitary_schemas/index_attribute.py @@ -50,7 +50,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument name is mantatory and can not be set to None') + raise AssertionError('Argument name is mandatory and can not be set to None') if not check_type(value,label): self._name = label(value) else: @@ -64,7 +64,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument of_shape is mantatory and can not be set to None') + raise AssertionError('Argument of_shape is mandatory and can not be set to None') if not check_type(value,product_definition_shape): self._of_shape = product_definition_shape(value) else: @@ -98,7 +98,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument base is mantatory and can not be set to None') + raise AssertionError('Argument base is mandatory and can not be set to None') if not check_type(value,datum_or_common_datum): self._base = datum_or_common_datum(value) else: diff --git a/src/exp2python/examples/unitary_schemas/multiple_rep.py b/src/exp2python/examples/unitary_schemas/multiple_rep.py index 6dfcc4a0b..3805349fc 100644 --- a/src/exp2python/examples/unitary_schemas/multiple_rep.py +++ b/src/exp2python/examples/unitary_schemas/multiple_rep.py @@ -94,7 +94,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument name is mantatory and can not be set to None') + raise AssertionError('Argument name is mandatory and can not be set to None') if not check_type(value,label): self._name = label(value) else: @@ -108,7 +108,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument rep_1 is mantatory and can not be set to None') + raise AssertionError('Argument rep_1 is mandatory and can not be set to None') if not check_type(value,representation): self._rep_1 = representation(value) else: @@ -122,7 +122,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument rep_2 is mantatory and can not be set to None') + raise AssertionError('Argument rep_2 is mandatory and can not be set to None') if not check_type(value,representation): self._rep_2 = representation(value) else: @@ -172,7 +172,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument name is mantatory and can not be set to None') + raise AssertionError('Argument name is mandatory and can not be set to None') if not check_type(value,label): self._name = label(value) else: @@ -186,7 +186,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument items is mantatory and can not be set to None') + raise AssertionError('Argument items is mandatory and can not be set to None') if not check_type(value,SET(1,None,'STRING', scope = schema_scope)): self._items = SET(value) else: @@ -200,7 +200,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument context_of_items is mantatory and can not be set to None') + raise AssertionError('Argument context_of_items is mandatory and can not be set to None') if not check_type(value,representation_context): self._context_of_items = representation_context(value) else: @@ -244,7 +244,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument name is mantatory and can not be set to None') + raise AssertionError('Argument name is mandatory and can not be set to None') if not check_type(value,label): self._name = label(value) else: @@ -258,7 +258,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument definition is mantatory and can not be set to None') + raise AssertionError('Argument definition is mandatory and can not be set to None') if not check_type(value,characterized_definition): self._definition = characterized_definition(value) else: @@ -291,7 +291,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument representation_relation is mantatory and can not be set to None') + raise AssertionError('Argument representation_relation is mandatory and can not be set to None') if not check_type(value,shape_representation_relationship): self._representation_relation = shape_representation_relationship(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_array.py b/src/exp2python/examples/unitary_schemas/test_array.py index d7f77e69e..7f4fb6259 100644 --- a/src/exp2python/examples/unitary_schemas/test_array.py +++ b/src/exp2python/examples/unitary_schemas/test_array.py @@ -35,7 +35,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument coords is mantatory and can not be set to None') + raise AssertionError('Argument coords is mandatory and can not be set to None') if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)): self._coords = ARRAY(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py b/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py index 32e8c5456..3ea8a8c15 100644 --- a/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py +++ b/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py @@ -35,7 +35,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument rotation is mantatory and can not be set to None') + raise AssertionError('Argument rotation is mandatory and can not be set to None') if not check_type(value,ARRAY(1,3,ARRAY(1,3,'REAL', scope = schema_scope))): self._rotation = ARRAY(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py b/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py index 09a6ca5e5..4c3d6f5df 100644 --- a/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py +++ b/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py @@ -43,7 +43,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument arr_real is mantatory and can not be set to None') + raise AssertionError('Argument arr_real is mandatory and can not be set to None') if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)): self._arr_real = ARRAY(value) else: @@ -57,7 +57,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument arr_string is mantatory and can not be set to None') + raise AssertionError('Argument arr_string is mandatory and can not be set to None') if not check_type(value,ARRAY(1,3,'STRING', scope = schema_scope)): self._arr_string = ARRAY(value) else: @@ -71,7 +71,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument arr_integer is mantatory and can not be set to None') + raise AssertionError('Argument arr_integer is mandatory and can not be set to None') if not check_type(value,ARRAY(1,None,'INTEGER', scope = schema_scope)): self._arr_integer = ARRAY(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_derived_attribute.py b/src/exp2python/examples/unitary_schemas/test_derived_attribute.py index 61da680f6..bdd4b82ee 100644 --- a/src/exp2python/examples/unitary_schemas/test_derived_attribute.py +++ b/src/exp2python/examples/unitary_schemas/test_derived_attribute.py @@ -58,7 +58,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument centre is mantatory and can not be set to None') + raise AssertionError('Argument centre is mandatory and can not be set to None') if not check_type(value,point): self._centre = point(value) else: @@ -72,7 +72,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument radius is mantatory and can not be set to None') + raise AssertionError('Argument radius is mandatory and can not be set to None') if not check_type(value,REAL): self._radius = REAL(value) else: @@ -86,7 +86,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument axis is mantatory and can not be set to None') + raise AssertionError('Argument axis is mandatory and can not be set to None') if not check_type(value,vector): self._axis = vector(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py b/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py index 89f305645..84c56c78b 100644 --- a/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py +++ b/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py @@ -48,7 +48,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument a is mantatory and can not be set to None') + raise AssertionError('Argument a is mandatory and can not be set to None') if not check_type(value,REAL): self._a = REAL(value) else: @@ -62,7 +62,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument b is mantatory and can not be set to None') + raise AssertionError('Argument b is mandatory and can not be set to None') if not check_type(value,REAL): self._b = REAL(value) else: @@ -76,7 +76,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument c is mantatory and can not be set to None') + raise AssertionError('Argument c is mandatory and can not be set to None') if not check_type(value,REAL): self._c = REAL(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py b/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py index 1598e2e7f..ce4e42d52 100644 --- a/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py +++ b/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py @@ -284,7 +284,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument people is mantatory and can not be set to None') + raise AssertionError('Argument people is mandatory and can not be set to None') if not check_type(value,SET(1,None,'person', scope = schema_scope)): self._people = SET(value) else: @@ -329,7 +329,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument organizations is mantatory and can not be set to None') + raise AssertionError('Argument organizations is mandatory and can not be set to None') if not check_type(value,SET(1,None,'organization', scope = schema_scope)): self._organizations = SET(value) else: @@ -389,7 +389,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument id is mantatory and can not be set to None') + raise AssertionError('Argument id is mandatory and can not be set to None') if not check_type(value,identifier): self._id = identifier(value) else: @@ -514,7 +514,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument name is mantatory and can not be set to None') + raise AssertionError('Argument name is mandatory and can not be set to None') if not check_type(value,label): self._name = label(value) else: @@ -560,7 +560,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument organizational_address_organizations is mantatory and can not be set to None') + raise AssertionError('Argument organizational_address_organizations is mandatory and can not be set to None') if not check_type(value,SET(1,1,'organization', scope = schema_scope)): self._organizational_address_organizations = SET(value) else: @@ -574,7 +574,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument personal_address_people is mantatory and can not be set to None') + raise AssertionError('Argument personal_address_people is mandatory and can not be set to None') if not check_type(value,SET(1,1,'person', scope = schema_scope)): self._personal_address_people = SET(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_named_type.py b/src/exp2python/examples/unitary_schemas/test_named_type.py index beed4e578..8ba93647f 100644 --- a/src/exp2python/examples/unitary_schemas/test_named_type.py +++ b/src/exp2python/examples/unitary_schemas/test_named_type.py @@ -58,7 +58,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument line_length is mantatory and can not be set to None') + raise AssertionError('Argument line_length is mandatory and can not be set to None') if not check_type(value,measure): self._line_length = measure(value) else: @@ -72,7 +72,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument other_param is mantatory and can not be set to None') + raise AssertionError('Argument other_param is mandatory and can not be set to None') if not check_type(value,type3): self._other_param = type3(value) else: @@ -86,7 +86,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument and_another is mantatory and can not be set to None') + raise AssertionError('Argument and_another is mandatory and can not be set to None') if not check_type(value,REAL): self._and_another = REAL(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_select_data_type.py b/src/exp2python/examples/unitary_schemas/test_select_data_type.py index b30f5cd8b..d4c3b53c3 100644 --- a/src/exp2python/examples/unitary_schemas/test_select_data_type.py +++ b/src/exp2python/examples/unitary_schemas/test_select_data_type.py @@ -50,7 +50,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument composition is mantatory and can not be set to None') + raise AssertionError('Argument composition is mandatory and can not be set to None') if not check_type(value,STRING): self._composition = STRING(value) else: @@ -80,7 +80,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument composition is mantatory and can not be set to None') + raise AssertionError('Argument composition is mandatory and can not be set to None') if not check_type(value,STRING): self._composition = STRING(value) else: @@ -94,7 +94,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument solvent is mantatory and can not be set to None') + raise AssertionError('Argument solvent is mandatory and can not be set to None') if not check_type(value,STRING): self._solvent = STRING(value) else: @@ -128,7 +128,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument mounting is mantatory and can not be set to None') + raise AssertionError('Argument mounting is mandatory and can not be set to None') if not check_type(value,STRING): self._mounting = STRING(value) else: @@ -142,7 +142,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument on is mantatory and can not be set to None') + raise AssertionError('Argument on is mandatory and can not be set to None') if not check_type(value,STRING): self._on = STRING(value) else: @@ -156,7 +156,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument using is mantatory and can not be set to None') + raise AssertionError('Argument using is mandatory and can not be set to None') if not check_type(value,attachment_method): self._using = attachment_method(value) else: @@ -186,7 +186,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument body_length is mantatory and can not be set to None') + raise AssertionError('Argument body_length is mandatory and can not be set to None') if not check_type(value,REAL): self._body_length = REAL(value) else: @@ -200,7 +200,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument pitch is mantatory and can not be set to None') + raise AssertionError('Argument pitch is mandatory and can not be set to None') if not check_type(value,REAL): self._pitch = REAL(value) else: @@ -230,7 +230,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument body_length is mantatory and can not be set to None') + raise AssertionError('Argument body_length is mandatory and can not be set to None') if not check_type(value,REAL): self._body_length = REAL(value) else: @@ -244,7 +244,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument head_area is mantatory and can not be set to None') + raise AssertionError('Argument head_area is mandatory and can not be set to None') if not check_type(value,REAL): self._head_area = REAL(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_single_inheritance.py b/src/exp2python/examples/unitary_schemas/test_single_inheritance.py index e317b26df..bd67d1a8b 100644 --- a/src/exp2python/examples/unitary_schemas/test_single_inheritance.py +++ b/src/exp2python/examples/unitary_schemas/test_single_inheritance.py @@ -54,7 +54,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument item_name is mantatory and can not be set to None') + raise AssertionError('Argument item_name is mandatory and can not be set to None') if not check_type(value,label): self._item_name = label(value) else: @@ -68,7 +68,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument number_of_sides is mantatory and can not be set to None') + raise AssertionError('Argument number_of_sides is mandatory and can not be set to None') if not check_type(value,INTEGER): self._number_of_sides = INTEGER(value) else: @@ -99,7 +99,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument height is mantatory and can not be set to None') + raise AssertionError('Argument height is mandatory and can not be set to None') if not check_type(value,length_measure): self._height = length_measure(value) else: @@ -113,7 +113,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument width is mantatory and can not be set to None') + raise AssertionError('Argument width is mandatory and can not be set to None') if not check_type(value,length_measure): self._width = length_measure(value) else: diff --git a/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py b/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py index d552f6add..b15846391 100644 --- a/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py +++ b/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py @@ -54,7 +54,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument item_name is mantatory and can not be set to None') + raise AssertionError('Argument item_name is mandatory and can not be set to None') if not check_type(value,label): self._item_name = label(value) else: @@ -68,7 +68,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument number_of_sides is mantatory and can not be set to None') + raise AssertionError('Argument number_of_sides is mandatory and can not be set to None') if not check_type(value,INTEGER): self._number_of_sides = INTEGER(value) else: @@ -108,7 +108,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument height is mantatory and can not be set to None') + raise AssertionError('Argument height is mandatory and can not be set to None') if not check_type(value,length_measure): self._height = length_measure(value) else: @@ -122,7 +122,7 @@ def fget( self ): def fset( self, value ): # Mandatory argument if value==None: - raise AssertionError('Argument width is mantatory and can not be set to None') + raise AssertionError('Argument width is mandatory and can not be set to None') if not check_type(value,length_measure): self._width = length_measure(value) else: diff --git a/src/exp2python/python/SCL/TypeChecker.py b/src/exp2python/python/SCL/TypeChecker.py index 2c04faed5..979e99ed2 100644 --- a/src/exp2python/python/SCL/TypeChecker.py +++ b/src/exp2python/python/SCL/TypeChecker.py @@ -46,7 +46,7 @@ def cast_python_object_to_aggregate(obj, aggregate): return aggregate def check_type(instance, expected_type): - """ This function checks wether an object is an instance of a given class + """ This function checks whether an object is an instance of a given class returns False or True """ type_match = False #by default, will be set to True if any match diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index f6b6b8554..01e70ec5b 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -789,7 +789,7 @@ LIBdescribe_entity( Entity entity, FILE * file ) { fprintf( file, "%s):\n\t", attr_type ); } } - /* check wether attr_type is aggr or explicit */ + /* check whether attr_type is aggr or explicit */ if( TYPEis_aggregate( t ) ) { fprintf( file, "\t\t\tself._%s = ", attrnm ); print_aggregate_type( file, t ); diff --git a/src/express/resolve.c b/src/express/resolve.c index e9d01436c..658c2be39 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -361,7 +361,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { expr->return_type = f->u.func->return_type; /* do argument typechecking here if requested */ - /* currently, we just check arg count; necesary */ + /* currently, we just check arg count; necessary */ /* to NVL code later which assumes args are present */ if( LISTget_length( expr->u.funcall.list ) != f->u.func->pcount ) { From f3b6498da2cdafda4ba332c4d9b1069fffe0bda9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 9 Oct 2017 07:40:52 -0400 Subject: [PATCH 013/244] data/ap238/ap238-aim-long.exp comment typo --- data/ap238/ap238-aim-long.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/ap238/ap238-aim-long.exp b/data/ap238/ap238-aim-long.exp index 2cc3248b2..3ed2f2d1a 100644 --- a/data/ap238/ap238-aim-long.exp +++ b/data/ap238/ap238-aim-long.exp @@ -3891,11 +3891,11 @@ ENTITY grooving_turning_operation WR3: (verify_optional_action_property (SELF, 'allowance')) AND (verify_length_measure_action_property (SELF, 'allowance')); - -- allowance propery required for roughing + -- allowance property required for roughing WR4: NOT (SELF.description = 'roughing') OR (verify_required_action_property (SELF, 'allowance')); - -- allowance propery forbidden for cutting in + -- allowance property forbidden for cutting in WR5: NOT (SELF.description = 'cutting in') OR (0 = SIZEOF (get_action_property (SELF, 'allowance'))); END_ENTITY; -- 10303-238: integrated_cnc_schema From 11942a3c069af6f3f901a579feb84bb2a0b57eaf Mon Sep 17 00:00:00 2001 From: luzpaz Date: Mon, 27 Nov 2017 16:27:48 -0500 Subject: [PATCH 014/244] Misc. typos --- misc/flawfinder | 2 +- src/cleditor/README | 2 +- src/cleditor/STEPfile.cc | 2 +- src/clstepcore/sdaiSelect.cc | 2 +- src/exp2cxx/selects.c | 2 +- src/exp2python/python/SCL/SimpleDataTypes.py | 2 +- src/exp2python/src/multpass_python.c | 2 +- src/exp2python/test/test_base.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/misc/flawfinder b/misc/flawfinder index 0c08fa353..151a48fb8 100755 --- a/misc/flawfinder +++ b/misc/flawfinder @@ -451,7 +451,7 @@ def extract_c_parameters(text, pos=0): # so will get confused by patterns like gettext("hi") + function("bye") # In practice, this doesn't seem to be a problem; gettext() is usually # wrapped around the entire parameter. -# The ?s makes it posible to match multi-line strings. +# The ?s makes it possible to match multi-line strings. gettext_pattern = re.compile(r'(?s)^\s*' + 'gettext' + r'\s*\((.*)\)\s*$') undersc_pattern = re.compile(r'(?s)^\s*' + '_(T(EXT)?)?' + r'\s*\((.*)\)\s*$') diff --git a/src/cleditor/README b/src/cleditor/README index 98b2011bc..8cacccd43 100644 --- a/src/cleditor/README +++ b/src/cleditor/README @@ -1,6 +1,6 @@ This directory contains source code defining a collection of application independent classes supporting the editing of STEP -instance data. This library includes functions for editing +instance data. This library includes functions for editing individual instances and for manipulating groups of instances. The editor library acts as an intermediary between the core library and a graphical user interface library. diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index f7f4b2818..4f31e273f 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -101,7 +101,7 @@ float STEPfile::GetWriteProgress() const { * returns an error descriptor. * It expects to find the "HEADER;" symbol at the beginning of the istream. * - * side effects: The function gobbles all characters up to and including the + * side effects: The function gobbles all characters up to and including the * next "ENDSEC;" from in. * The STEPfile::_headerInstances may change. */ diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 9837540c9..cd1512179 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -242,7 +242,7 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, /** ** This section of code is used to read a value belonging to a select ** contained in another select. If you have read the text part of the - ** TYPED_PARAMETER and it needs to fall down thru some levels of contained + ** TYPED_PARAMETER and it needs to fall down through some levels of contained ** select types, then the text is passed down to each select in the utype ** parameter as STEPread is called on each contained select type.DAS 2/4/97 */ diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 9e4aae118..6539f14d2 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -1940,5 +1940,5 @@ void TYPEselect_print( Type t, FILES * files, Schema schema ) { /************************************************************************** -******** END of SELECT TYPE +******** END of SELECT TYPE **************************************************************************/ diff --git a/src/exp2python/python/SCL/SimpleDataTypes.py b/src/exp2python/python/SCL/SimpleDataTypes.py index e7075aa41..a46f8cb78 100644 --- a/src/exp2python/python/SCL/SimpleDataTypes.py +++ b/src/exp2python/python/SCL/SimpleDataTypes.py @@ -185,7 +185,7 @@ def __init__(self, value, width=-1, fixed=False): self._fixed = fixed # Check implicit width if (width!=-1) and not fixed: - raise ValueError("The 'width' parameter is passed but 'fixed' is still false. Please explicitely set 'fixed' to True to avoid implicit declaration") + raise ValueError("The 'width' parameter is passed but 'fixed' is still false. Please explicitly set 'fixed' to True to avoid implicit declaration") # First check the string length if 'fixed' is set to True if fixed: if len(value) != width: diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index 9cc6553d3..595ab6a94 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -498,7 +498,7 @@ static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to - // check. But checkTypes should keep looping thru the re- + // check. But checkTypes should keep looping through the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ ( *unknowncnt )++; diff --git a/src/exp2python/test/test_base.py b/src/exp2python/test/test_base.py index 00205d997..270fa324e 100644 --- a/src/exp2python/test/test_base.py +++ b/src/exp2python/test/test_base.py @@ -217,7 +217,7 @@ def test_array_unique(self): self.fail('ExpectedException not thrown') def test_array_optional(self): - # if OPTIONAL is not set explicitely to True + # if OPTIONAL is not set explicitly to True # then each value must be set a = ARRAY(1,3,REAL) try: From 41105500c9ab64b00c2c530d0d9d6257ebf9397f Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 23 Dec 2017 08:30:03 -0500 Subject: [PATCH 015/244] More Misc. typos --- NEWS | 4 ++-- src/cleditor/STEPfile.cc | 2 +- src/cllazyfile/lazyRefs.h | 2 +- src/cllazyfile/sectionReader.cc | 2 +- src/clstepcore/STEPaggrEntity.h | 2 +- src/clstepcore/STEPaggrSelect.h | 2 +- src/clstepcore/collect.cc | 6 +++--- src/clstepcore/multlist.cc | 2 +- src/clstepcore/typeDescriptor.h | 4 ++-- src/clutils/Str.cc | 2 +- src/exp2cxx/classes_entity.c | 2 +- src/exp2cxx/collect.cc | 6 +++--- src/exp2cxx/multlist.cc | 2 +- src/exp2cxx/multpass.c | 2 +- src/exp2cxx/selects.c | 2 +- src/exp2cxx/write.cc | 2 +- src/exp2python/src/classes_misc_python.c | 2 +- src/exp2python/src/multpass_python.c | 2 +- src/exppp/test/inverse_qualifiers.cmake | 2 +- src/exppp/test/unique_qualifiers.cmake | 2 +- src/express/Changes | 4 ++-- src/test/scl2html/scl2html.cc | 4 ++-- src/test/tstatic/tstatic.cc | 2 +- 23 files changed, 31 insertions(+), 31 deletions(-) diff --git a/NEWS b/NEWS index 25f05d0d1..35bcba3e6 100644 --- a/NEWS +++ b/NEWS @@ -252,7 +252,7 @@ the TD for label. - Fixed the casting operator for the class representing EXPRESS enumeration types. It was returning the last element of the enum type -as the the default when the enum was unset. This choice predated enums +as the default when the enum was unset. This choice predated enums having an unset enum value. It now returns _unset as the default when the enum is unset. @@ -794,7 +794,7 @@ When this case of multiple inheritance is encountered attributes are duplicated. This case of multiple inheritance may possibly be avoided by modifying the EXPRESS schema by breaking some links in the inheritance hierarchy. This will not have an adverse affect on the -implemementation. The user may choose to use the current or previous +implementation. The user may choose to use the current or previous method of handling multiple inheritance. The current method is the default behavior. The previous method is obtained by supplying the -s (or -S) option with the exp2cxx code generator or the mkProbe diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 4f31e273f..cb1fe5bca 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -341,7 +341,7 @@ SDAI_Application_instance * STEPfile::HeaderDefaultFileSchema() { * If the _headerInstances contain no instances, then copy the instances * from im onto the _headerInstances. * This only works for an instance manager which contains the following - * header section entites. The file id numbers are important. + * header section entities. The file id numbers are important. * * #1 = FILE_DESCRIPTION * #2 = FILE_NAME diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index f94f41e7a..02889bcd1 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -48,7 +48,7 @@ class SDAI_Application_instance; * 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 +//TODO screen out instances 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? diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 15220078a..7a6053a46 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -206,7 +206,7 @@ instanceID sectionReader::readInstanceNumber() { do { c = _file.get(); if( isdigit( c ) ) { - buffer[ digits ] = c; //copy the charcter into the buffer + buffer[ digits ] = c; //copy the character into the buffer digits++; } else { diff --git a/src/clstepcore/STEPaggrEntity.h b/src/clstepcore/STEPaggrEntity.h index 76a0ec95c..f18bc3d0f 100644 --- a/src/clstepcore/STEPaggrEntity.h +++ b/src/clstepcore/STEPaggrEntity.h @@ -57,7 +57,7 @@ class SC_CORE_EXPORT EntityNode : public STEPnode { virtual SingleLinkNode * NewNode(); - // Calling these funtions is an error. + // Calling these functions is an error. Severity StrToVal( const char * s, ErrorDescriptor * err ) { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; diff --git a/src/clstepcore/STEPaggrSelect.h b/src/clstepcore/STEPaggrSelect.h index 581862802..b62a9c3fe 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/src/clstepcore/STEPaggrSelect.h @@ -68,7 +68,7 @@ class SC_CORE_EXPORT SelectNode : public STEPnode { virtual SingleLinkNode * NewNode(); - // Calling these funtions is an error. + // Calling these functions is an error. Severity StrToVal( const char * s, ErrorDescriptor * err ) { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index 08f2131bb..b6abef73c 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -1,7 +1,7 @@ /*************************************************************************//** * collect.cc \class ComplexCollect * * * - * Description: ComplexCollect is the container structure for all ofthe com- * + * Description: ComplexCollect is the container structure for all of the com-* * plex entity information in a schema. It contains a list of * * ComplexList structures each of which corresponds to one set * * of subtype/supertype information about the schema. This file * @@ -85,8 +85,8 @@ ComplexList * ComplexCollect::find( char * name ) { /** * Determines if the parent schema supports the instantiation of a complex - * type consisting of the the entities named in ents. Does so by attempt- - * ing to match ents against the ComplexLists in clists. If one of the + * type consisting of the entities named in ents. Does so by attempting + * to match ents against the ComplexLists in clists. If one of the * nodes of ents has multSupers set to true (it has >1 supertype), it * should be included in >1 CList. A more complicated algorithm is applied * to match it, as described in the commenting. diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index aa0f5e42c..959720ed0 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -218,7 +218,7 @@ bool JoinList::acceptChoice( EntNode * ents ) { if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who - // can mark but whose vaiable val = SATISFIED. This will be the + // can mark but whose variable val = SATISFIED. This will be the // case if there's another EntList with higher priority which can // also mark this node. (For example, if an AND has an OR and a // SIMPLE child, the SIMPLE wins so that we'll have fewer OR diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 24ef471c5..915c1831d 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -53,7 +53,7 @@ * part_label and label would be the value of the respective * _name member variables for the 2 TypeDescriptors. * \var _referentType - * will point at another TypeDescriptor furthur specifying + * will point at another TypeDescriptor further specifying * the type in all cases except when the type is directly * an enum or select. i.e. in the following... _referentType for * the 1st type does not point at anything and for the 2nd it does: @@ -74,7 +74,7 @@ ** var _referentType * For the TypeDescriptors describing the EXPRESS base types this will * be a null pointer. For all other TypeDescriptors this will point - * to another TypeDescriptor which furthur describes the type. e.g. + * to another TypeDescriptor which further describes the type. e.g. * TYPE part_label = label END_TYPE; TYPE label = STRING END_TYPE; * part_label's _referentType will point to the TypeDescriptor for * label. label's _referentType will point to the TypeDescriptor diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index ba36cd610..a14f0dc08 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -228,7 +228,7 @@ char * PrettyNewName( const char * oldname ) { *** the value. *** If the input stream can be readable again then -*** - any error states set for the the stream are cleared. +*** - any error states set for the stream are cleared. *** - white space skipped in the input stream *** - if EOF is encountered it returns *** otherwise it peeks at the next character diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 5d168625a..f33b2c13d 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -1065,7 +1065,7 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) /* create list of attr that have to be inherited in EXPRESS */ collectAttributes( required, entity, ALL_BUT_FIRST ); - /* build list of unique attr that are required but havn't been */ + /* build list of unique attr that are required but haven't been */ /* inherited */ LISTdo( required, attr, Variable ) { if( !listContainsVar( existing, attr ) && diff --git a/src/exp2cxx/collect.cc b/src/exp2cxx/collect.cc index 2d3c352f3..d12db7346 100644 --- a/src/exp2cxx/collect.cc +++ b/src/exp2cxx/collect.cc @@ -1,7 +1,7 @@ /***************************************************************************** * collect.cc * * * - * Description: ComplexCollect is the container structure for all ofthe com- * + * Description: ComplexCollect is the container structure for all of the com-* * plex entity information in a schema. It contains a list of * * ComplexList structures each of which corresponds to one set * * of subtype/supertype information about the schema. This file * @@ -89,8 +89,8 @@ ComplexList * ComplexCollect::find( char * name ) int ComplexCollect::supports( EntNode * ents ) /* * Determines if the parent schema supports the instantiation of a complex - * type consisting of the the entities named in ents. Does so by attempt- - * ing to match ents against the ComplexLists in clists. If one of the + * type consisting of the entities named in ents. Does so by attempting + * to match ents against the ComplexLists in clists. If one of the * nodes of ents has multSupers set to TRUE (it has >1 supertype), it * should be included in >1 CList. A more complicated algorithm is applied * to match it, as described in the commenting. diff --git a/src/exp2cxx/multlist.cc b/src/exp2cxx/multlist.cc index a92a86874..fb74cf5d1 100644 --- a/src/exp2cxx/multlist.cc +++ b/src/exp2cxx/multlist.cc @@ -336,7 +336,7 @@ int JoinList::acceptChoice( EntNode * ents ) if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who - // can mark but whose vaiable val = SATISFIED. This will be the + // can mark but whose variable val = SATISFIED. This will be the // case if there's another EntList with higher priority which can // also mark this node. (For example, if an AND has an OR and a // SIMPLE child, the SIMPLE wins so that we'll have fewer OR diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 10294b35a..51a210ecb 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -56,7 +56,7 @@ static void addUseRefNames( Schema, FILE * ); /** * Generates the C++ files corresponding to a list of schemas. Does so in * multiple passes through the schemas. In each pass it checks for enti- - * ties which are subtypes of entites in other schemas which have not yet + * ties which are subtypes of entities in other schemas which have not yet * been processed. Such entities cannot be processed in that pass until * their supertypes have been defined. It also checks for entities which * have enum or select attributes which have not been processed, and for diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 6539f14d2..37ee99e73 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -376,7 +376,7 @@ void non_unique_types_vector( const Type type, int * tvec ) { tvec[tnumber]++; break; default: - fprintf( stderr, "non_unique_types_vector: can't handle unknow type %d\n", + fprintf( stderr, "non_unique_types_vector: can't handle unknown type %d\n", TYPEget_body( t )->type ); abort(); } diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 39f32367c..964aca652 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -132,7 +132,7 @@ static void writeheader( ostream & os, int noLists ) os << "#include \"complexSupport.h\"\n#include \"sc_memmgr.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << " /*" << endl - << " * This function contains instantiation statments for all the\n" + << " * This function contains instantiation statements for all the\n" << " * ComplexLists and EntLists in a ComplexCollect. The instan-\n" << " * stiation statements were generated in order of lower to\n" << " * higher, and last to first to simplify creating some of the\n" diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 5462eddaa..3fdf76218 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -22,7 +22,7 @@ extern int multiple_inheritance; /****************************************************************** ** The following functions will be used *** -*** through out the the program exp2python ***/ +*** throughout the program exp2python ***/ /****************************************************************** diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index 595ab6a94..ece7e6617 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -56,7 +56,7 @@ void print_schemas_separate( Express express, FILES * files ) /* * Generates the C++ files corresponding to a list of schemas. Does so in * multiple passes through the schemas. In each pass it checks for enti- - * ties which are subtypes of entites in other schemas which have not yet + * ties which are subtypes of entities in other schemas which have not yet * been processed. Such entities cannot be processed in that pass until * their supertypes have been defined. It also checks for entities which * have enum or select attributes which have not been processed, and for diff --git a/src/exppp/test/inverse_qualifiers.cmake b/src/exppp/test/inverse_qualifiers.cmake index c27b473a7..ab64af9c0 100644 --- a/src/exppp/test/inverse_qualifiers.cmake +++ b/src/exppp/test/inverse_qualifiers.cmake @@ -13,7 +13,7 @@ endif( NOT ${CMD_RESULT} EQUAL 0 ) file( READ ${ofile} pretty_out LIMIT 1024 ) # SELF\product_occurrence.occurrence_contexts : SET [1 : ?] OF assembly_component_relationship FOR related_view; -# one backslash baloons into 4 x( +# one backslash balloons into 4 x( string( REGEX MATCH " *SELF *\\\\ *product_occurrence *\\. *occurrence_contexts *: *SET *\\[ *1 *:" match_result ${pretty_out} ) if( match_result STREQUAL "" ) diff --git a/src/exppp/test/unique_qualifiers.cmake b/src/exppp/test/unique_qualifiers.cmake index 8bf492d2f..b2c787862 100644 --- a/src/exppp/test/unique_qualifiers.cmake +++ b/src/exppp/test/unique_qualifiers.cmake @@ -13,7 +13,7 @@ endif( NOT ${CMD_RESULT} EQUAL 0 ) file( READ ${ofile} pretty_out LIMIT 1024 ) # ur1 : SELF\shape_aspect_relationship.name; -# one backslash baloons into 4, and I can't figure out how to escape the semicolon x( +# one backslash balloons into 4, and I can't figure out how to escape the semicolon x( string( REGEX MATCH "[uU][rR]1 *: *SELF *\\\\ *shape_aspect_relationship *\\. *name" match_result ${pretty_out} ) if( match_result STREQUAL "" ) diff --git a/src/express/Changes b/src/express/Changes index e7d4c5488..be48e6205 100644 --- a/src/express/Changes +++ b/src/express/Changes @@ -158,7 +158,7 @@ Class x; -> Class_of_what x; i.e., Class_of_Type x; -Similary, OBJget_class is now specific to whatever class you are using. +Similarly, OBJget_class is now specific to whatever class you are using. I.e., @@ -496,7 +496,7 @@ foreach schema Original code did not check for redefining keywords. Fixed. ====================================================================== USE and REFERENCE are handled by having separate lists and -dictionaries to remember schemas and invididual objects that are USEd +dictionaries to remember schemas and individual objects that are USEd and REFd. 'rename' structures are used to point to the remote object. (This avoids the need for copying dictionaries, which enabled large time/space savings.) diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index 6ed56c4c3..f597b36e4 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -135,7 +135,7 @@ int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { // PrintParentAttrsHTML() // This function, given an entity and its parent, recursively travels up // the inheritance tree of the entity, printing to the HTML file a -// description-list structre showing all ancestors. For each ancestor, +// description-list structure showing all ancestors. For each ancestor, // the attributes are printed using the PrintAttrsHTML() function above. void PrintParentAttrsHTML( const EntityDescriptor * ent, const EntityDescriptor * parent, ofstream & outhtml ) { @@ -245,7 +245,7 @@ main() { // These are all pointers we need to wander around the registry // information. We'll want to not only look at the current entity - // and its attributes, but also which entites are super- and subclasses + // and its attributes, but also which entities are super- and subclasses // of the current entity. Here, supers isn't really used beyond checking // for ancestors, but we'll use subs to list subclasses and make links // to them. diff --git a/src/test/tstatic/tstatic.cc b/src/test/tstatic/tstatic.cc index 3d84f5581..eb6d6f2c5 100644 --- a/src/test/tstatic/tstatic.cc +++ b/src/test/tstatic/tstatic.cc @@ -25,7 +25,7 @@ int main() { // This test creates a bunch of different entities, puts values in them, // prints the values out, links them to an array of entities, and then - // outputs all the enitities in STEP exchange format. + // outputs all the entities in STEP exchange format. // For specifics on the structure of the entity classes, see // the SdaiEXAMPLE_SCHEMA.h header file. From e20def2ee120121018fa5950d612abd3ab7b1256 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Thu, 4 Jan 2018 11:44:03 -0500 Subject: [PATCH 016/244] Misc. typo --- src/exp2python/python/SCL/Builtin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2python/python/SCL/Builtin.py b/src/exp2python/python/SCL/Builtin.py index e0a20e0b8..67f590007 100644 --- a/src/exp2python/python/SCL/Builtin.py +++ b/src/exp2python/python/SCL/Builtin.py @@ -580,7 +580,7 @@ def SQRT(V): # =================== #15.24 Tan - arithmetic function #FUNCTION TAN ( V:NUMBER ) : REAL; -#The tan function returns the tangent of of an angle. +#The tan function returns the tangent of an angle. #Parameters : V is a number representing an angle expressed in radians. #Result : The tangent of the angle. If the angle is npi/2, where n is an odd integer, indeterminate #(?) is returned. From f93abd29916c7e86750c855ca507b2fcffee1ed1 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Fri, 13 Jul 2018 19:12:09 -0400 Subject: [PATCH 017/244] Misc. typos Found via `codespell` --- cmake/sc_version_string.cmake | 3 +-- src/cldai/sdaiDaObject.h | 2 +- src/clstepcore/sdaiSelect.cc | 2 +- src/exp2python/python/SCL/essa_par.py | 9 +++------ src/exp2python/src/classes_wrapper_python.cc | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake index e6e2501c3..c6669c8d7 100644 --- a/cmake/sc_version_string.cmake +++ b/cmake/sc_version_string.cmake @@ -77,7 +77,7 @@ set(header_string "/* sc_version_string.h - written by cmake. Changes will be lo "#endif\n" ) -#don't update the file unless somethig changed +#don't update the file unless something changed string(RANDOM tmpsuffix) file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) @@ -93,4 +93,3 @@ endif(NOT SC_IS_SUBBUILD) # indent-tabs-mode: t # End: # ex: shiftwidth=2 tabstop=8 - diff --git a/src/cldai/sdaiDaObject.h b/src/cldai/sdaiDaObject.h index 29ddc4e5d..168c7bfbc 100644 --- a/src/cldai/sdaiDaObject.h +++ b/src/cldai/sdaiDaObject.h @@ -65,7 +65,7 @@ typedef SDAI_PID_ptr SDAI_PID_var; // The Direct Access Protocol supports direct access to persistent data // through typed attributes organized in data objects that are defined // in a Data Definition Language (DDL). An object using this protocol -// whould represent its persistent data as one or more interconnected +// would represent its persistent data as one or more interconnected // data objects, For uniformity, the persistent data of an object is // described as a single data object; however, that data object might be // the root of a graph of data objects interconnected by stored data diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index cd1512179..08e789a6d 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -514,7 +514,7 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, STEPread_content( in, instances, 0, addFileId ); } - else { // ERROR -- the type wasn\'t one of the choices + else { // ERROR -- the type wasn't one of the choices err->AppendToDetailMsg( "The type of the SELECT type is not valid.\n" ); err->GreaterSeverity( SEVERITY_WARNING ); diff --git a/src/exp2python/python/SCL/essa_par.py b/src/exp2python/python/SCL/essa_par.py index 00f75957f..2bfbdb253 100644 --- a/src/exp2python/python/SCL/essa_par.py +++ b/src/exp2python/python/SCL/essa_par.py @@ -46,7 +46,7 @@ def process_nested_parent_str2(attr_str,idx=0): current_param = '' k += progress+1 elif ch==')': - #print "Down one level parenthesis: %i caracters parsed"%k + #print "Down one level parenthesis: %i characters parsed"%k params.append(current_param) #print "Current params:",params#k -= acc-2 return params,k @@ -54,10 +54,10 @@ def process_nested_parent_str2(attr_str,idx=0): current_param += ch #print "Ch:",ch #print "k:",k - + #raw_input("") #idx += 1 - + params.append(current_param) return params,k #print process_nested_parent_str2('1,2,3,4,5,6') @@ -69,6 +69,3 @@ def process_nested_parent_str2(attr_str,idx=0): print process_nested_parent_str2("Thomas, Paviot, ouais")[0] print process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0] print process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0] - - - diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index d8a134779..21c16d1c4 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -41,7 +41,7 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { SCOPEod /* Defined Types with defined ancestor head - * TODO: recusive approach + * TODO: recursive approach */ SCOPEdo_types( scope, t, de ) if ( ( t->search_id == CANPROCESS ) From 284b1893def66a4112499b2370bf73f2262c0ab4 Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 4 Jan 2019 16:20:29 +0100 Subject: [PATCH 018/244] Use print() function in both Python 2 and Python 3 Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3. --- misc/wiki-scripts/update-matrix.py | 19 ++++++----- .../python/SCL/AggregationDataTypes.py | 34 +++++++++---------- src/exp2python/python/SCL/BaseType.py | 7 ++-- .../python/SCL/ConstructedDataTypes.py | 2 +- src/exp2python/python/SCL/Model.py | 3 +- src/exp2python/python/SCL/SimpleDataTypes.py | 17 +++++----- src/exp2python/python/SCL/TypeChecker.py | 15 ++++---- src/exp2python/python/SCL/Utils.py | 9 ++--- src/exp2python/python/SCL/essa_par.py | 13 +++---- src/exp2python/test/test_base.py | 10 +++--- 10 files changed, 68 insertions(+), 61 deletions(-) diff --git a/misc/wiki-scripts/update-matrix.py b/misc/wiki-scripts/update-matrix.py index 9893cf38e..65894726e 100644 --- a/misc/wiki-scripts/update-matrix.py +++ b/misc/wiki-scripts/update-matrix.py @@ -5,6 +5,7 @@ #must be ran from scl/build_matrix +from __future__ import print_function from xml.etree import ElementTree as ET import os from datetime import date @@ -49,7 +50,7 @@ def find_xml(): if str(date.today().year) in dirname: i += 1 if i > 1: - print "Too many directories, exiting" + print("Too many directories, exiting") exit(1) xml = os.path.join("Testing", dirname, "Test.xml") return xml @@ -58,31 +59,31 @@ def find_wiki(): #find wiki and matrix file, issue 'git pull' wikipath = os.path.abspath("../../wiki-scl") if not os.path.isdir(os.path.join(wikipath,".git")): - print "Can't find wiki or not a git repo" + print("Can't find wiki or not a git repo") exit(1) p = subprocess.call(["git", "pull", "origin"], cwd=wikipath) if not p == 0: - print "'git pull' exited with error" + print("'git pull' exited with error") exit(1) matrix = os.path.join(wikipath, "Schema-build-matrix.md") if not os.path.isfile(matrix): - print "Matrix file doesn't exist or isn't a file" + print("Matrix file doesn't exist or isn't a file") exit(1) return wikipath,matrix def git_push(path,f): p = subprocess.call(["git", "add", f], cwd=path) if not p == 0: - print "'git add' exited with error" + print("'git add' exited with error") exit(1) msg = date.today().__str__() + " - schema matrix updated by update-matrix.py" p = subprocess.call(["git", "commit", "-m", msg ], cwd=path) if not p == 0: - print "'git commit' exited with error" + print("'git commit' exited with error") exit(1) p = subprocess.call(["git", "push", "origin"], cwd=path) if not p == 0: - print "'git push' exited with error" + print("'git push' exited with error") exit(1) @@ -98,8 +99,8 @@ def read_tests(xml): # read all s in xml, create mixed html/markdown try: tree = ET.parse(xml) - except Exception, inst: - print "Unexpected error opening %s: %s" % (xml, inst) + except Exception as inst: + print("Unexpected error opening %s: %s" % (xml, inst)) return root = tree.getroot() diff --git a/src/exp2python/python/SCL/AggregationDataTypes.py b/src/exp2python/python/SCL/AggregationDataTypes.py index 9bb4709e8..c40758e66 100644 --- a/src/exp2python/python/SCL/AggregationDataTypes.py +++ b/src/exp2python/python/SCL/AggregationDataTypes.py @@ -126,9 +126,9 @@ class ARRAY(BaseType.Type, BaseType.Aggregate): """ def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, OPTIONAL=False, scope = None): BaseType.Type.__init__(self, base_type, scope) - if not type(bound_1)==int: + if not isinstance(bound_1, int): raise TypeError("ARRAY lower bound must be an integer") - if not type(bound_2)==int: + if not isinstance(bound_2, int): raise TypeError("ARRAY upper bound must be an integer") if not (bound_1 <= bound_2): raise AssertionError("ARRAY lower bound must be less than or equal to upper bound") @@ -235,17 +235,17 @@ class LIST(BaseType.Type, BaseType.Aggregate): """ def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, scope = None): BaseType.Type.__init__(self, base_type, scope) - if not type(bound_1)==int: + if not isinstance(bound_1, int): raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False if bound_2 == None: self._unbounded = True - elif not type(bound_2)==int: + elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") if not bound_1>=0: raise AssertionError("LIST lower bound must be greater of equal to 0") - if (type(bound_2)==int and not (bound_1 <= bound_2)): + if (isinstance(bound_2, int) and not (bound_1 <= bound_2)): raise AssertionError("ARRAY lower bound must be less than or equal to upper bound") # set up class attributes self._bound_1 = bound_1 @@ -282,14 +282,14 @@ def get_loindex(self): def get_hibound(self): hibound = self._bound_2 - if type(hibound)==int: + if isinstance(hibound, int): return INTEGER(hibound) else: return hibound def get_lobound(self): lobound = self._bound_1 - if type(lobound)==int: + if isinstance(lobound, int): return INTEGER(lobound) else: return lobound @@ -409,17 +409,17 @@ class BAG(BaseType.Type, BaseType.Aggregate): """ def __init__( self , bound_1 , bound_2 , base_type , scope = None): BaseType.Type.__init__(self, base_type, scope) - if not type(bound_1)==int: + if not isinstance(bound_1, int): raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False if bound_2 == None: self._unbounded = True - elif not type(bound_2)==int: + elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") if not bound_1>=0: raise AssertionError("LIST lower bound must be greater of equal to 0") - if (type(bound_2)==int and not (bound_1 <= bound_2)): + if (isinstance(bound_2, int) and not (bound_1 <= bound_2)): raise AssertionError("ARRAY lower bound must be less than or equal to upper bound") # set up class attributes self._bound_1 = bound_1 @@ -462,14 +462,14 @@ def get_loindex(self): def get_hibound(self): hibound = self._bound_2 - if type(hibound)==int: + if isinstance(hibound, int): return INTEGER(hibound) else: return hibound def get_lobound(self): lobound = self._bound_1 - if type(lobound)==int: + if isinstance(lobound, int): return INTEGER(lobound) else: return lobound @@ -527,17 +527,17 @@ class SET(BaseType.Type, BaseType.Aggregate): """ def __init__( self , bound_1 , bound_2 , base_type , scope = None): BaseType.Type.__init__(self, base_type, scope) - if not type(bound_1)==int: + if not isinstance(bound_1, int): raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False if bound_2 == None: self._unbounded = True - elif not type(bound_2)==int: + elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") if not bound_1>=0: raise AssertionError("LIST lower bound must be greater of equal to 0") - if (type(bound_2)==int and not (bound_1 <= bound_2)): + if (isinstance(bound_2, int) and not (bound_1 <= bound_2)): raise AssertionError("ARRAY lower bound must be less than or equal to upper bound") # set up class attributes self._bound_1 = bound_1 @@ -581,14 +581,14 @@ def get_loindex(self): def get_hibound(self): hibound = self._bound_2 - if type(hibound)==int: + if isinstance(hibound, int): return INTEGER(hibound) else: return hibound def get_lobound(self): lobound = self._bound_1 - if type(lobound)==int: + if isinstance(lobound, int): return INTEGER(lobound) else: return lobound diff --git a/src/exp2python/python/SCL/BaseType.py b/src/exp2python/python/SCL/BaseType.py index 0698ba89b..a6e2ab4a7 100644 --- a/src/exp2python/python/SCL/BaseType.py +++ b/src/exp2python/python/SCL/BaseType.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. @@ -43,10 +44,10 @@ def get_scope(self): return self._scope def get_type(self): - if type(self._typedef) == str: + if isinstance(self._typedef, str): if self._scope == None: raise AssertionError('No scope defined for this type') - elif vars(self._scope).has_key(self._typedef): + elif self._typedef in vars(self._scope): return vars(self._scope)[self._typedef] else: raise TypeError("Type '%s' is not defined in given scope"%self._typedef) @@ -65,5 +66,5 @@ class Aggregate: class line: pass new_type = Type('lie',scp) - print new_type.get_type() + print(new_type.get_type()) \ No newline at end of file diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/SCL/ConstructedDataTypes.py index afb3bd871..f272994ef 100644 --- a/src/exp2python/python/SCL/ConstructedDataTypes.py +++ b/src/exp2python/python/SCL/ConstructedDataTypes.py @@ -66,7 +66,7 @@ class SELECT(object): """ def __init__(self,*kargs,**args): # first defining the scope - if args.has_key('scope'): + if 'scope' in args: self._scope = args['scope'] else: self._scope = None diff --git a/src/exp2python/python/SCL/Model.py b/src/exp2python/python/SCL/Model.py index 9a3f0e87b..a204972fa 100644 --- a/src/exp2python/python/SCL/Model.py +++ b/src/exp2python/python/SCL/Model.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. @@ -33,7 +34,7 @@ class Model(objet): """ The container for entity instances """ def __init_(self): - print "Model initialized" + print("Model initialized") self._instances = [] def add_instance(self, entity_instance): diff --git a/src/exp2python/python/SCL/SimpleDataTypes.py b/src/exp2python/python/SCL/SimpleDataTypes.py index a46f8cb78..594df650f 100644 --- a/src/exp2python/python/SCL/SimpleDataTypes.py +++ b/src/exp2python/python/SCL/SimpleDataTypes.py @@ -32,6 +32,7 @@ """ Docstrings are courtesy of ISO 10303-11:1994(E) """ +from __future__ import print_function class NUMBER: """ @@ -198,19 +199,19 @@ def __init__(self, value, width=-1, fixed=False): if __name__=="__main__": - print "Creating REAL from float value" + print("Creating REAL from float value") a = REAL(1.5) - print a*2 - print "Creating REAL from string value" + print(a*2) + print("Creating REAL from string value") a = REAL("1.2") - print a*3 - print "Creating INTEGER from int value" + print(a*3) + print("Creating INTEGER from int value") b = INTEGER(2) c = INTEGER(3) - print b+c - print "Creating INTEGER from string value" + print(b+c) + print("Creating INTEGER from string value") e = INTEGER("5") f = INTEGER("8") - print e*f + print(e*f) \ No newline at end of file diff --git a/src/exp2python/python/SCL/TypeChecker.py b/src/exp2python/python/SCL/TypeChecker.py index 979e99ed2..d46b00aad 100644 --- a/src/exp2python/python/SCL/TypeChecker.py +++ b/src/exp2python/python/SCL/TypeChecker.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. @@ -40,7 +41,7 @@ def cast_python_object_to_aggregate(obj, aggregate): [1.,2.,3.]-> ARRAY(1,3,REAL)""" aggregate_lower_bound = aggregate.bound_1() aggregate_upper_bound = aggregate.bound_2() - if type(obj)==list: + if isinstance(obj, list): for idx in range(aggregate_lower_bound,aggregate_upper_bound+1): aggregate[idx] = obj[idx-aggregate_lower_bound] return aggregate @@ -51,9 +52,9 @@ def check_type(instance, expected_type): """ type_match = False #by default, will be set to True if any match if DEBUG: - print "===" - print "Instance passed: ",instance - print "Expected type: ", expected_type + print("===") + print("Instance passed: ",instance) + print("Expected type: ", expected_type) # in the case of an enumeration, we have to check if the instance is in the list if (isinstance(expected_type,ENUMERATION)): allowed_ids = expected_type.get_enum_ids() @@ -71,11 +72,11 @@ def check_type(instance, expected_type): if RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH: raise TypeError('Argument type must be %s (you passed %s)'%(allowed_types,type(instance))) else: - print "WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(allowed_types, type(instance)) + print("WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(allowed_types, type(instance))) return False elif (isinstance(expected_type, BaseType.Aggregate)): # first check that they are instance of the same class - if not (type(instance) == type(expected_type)): + if not (isinstance(instance, type(expected_type))): raise TypeError('Expected %s but passed %s'%(type(expected_type),type(instance))) # then check that the base type is the same elif not (instance.get_type() == expected_type.get_type()): @@ -96,6 +97,6 @@ def check_type(instance, expected_type): if RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH: raise TypeError('Argument type must be %s (you passed %s)'%(expected_type,type(instance))) else: - print "WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(expected_type, type(instance)) + print("WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(expected_type, type(instance))) return False return True diff --git a/src/exp2python/python/SCL/Utils.py b/src/exp2python/python/SCL/Utils.py index 7cce22494..4ba119349 100644 --- a/src/exp2python/python/SCL/Utils.py +++ b/src/exp2python/python/SCL/Utils.py @@ -30,6 +30,7 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''' This module provide string utils''' +from __future__ import print_function def process_nested_parent_str(attr_str,idx=0): ''' @@ -61,10 +62,10 @@ def process_nested_parent_str(attr_str,idx=0): return params,k if __name__=="__main__": - print process_nested_parent_str2("'A'")[0] - print process_nested_parent_str2("30.0,0.0,5.0")[0] - print process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0] - print process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0] + print(process_nested_parent_str2("'A'")[0]) + print(process_nested_parent_str2("30.0,0.0,5.0")[0]) + print(process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0]) + print(process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0]) diff --git a/src/exp2python/python/SCL/essa_par.py b/src/exp2python/python/SCL/essa_par.py index 2bfbdb253..9c21ee4bd 100644 --- a/src/exp2python/python/SCL/essa_par.py +++ b/src/exp2python/python/SCL/essa_par.py @@ -1,3 +1,4 @@ +from __future__ import print_function def process_nested_parent_str(attr_str): ''' The first letter should be a parenthesis @@ -63,9 +64,9 @@ def process_nested_parent_str2(attr_str,idx=0): #print process_nested_parent_str2('1,2,3,4,5,6') #idx=0 #print process_nested_parent_str2("'A','B','C'") -print process_nested_parent_str2("'A'")[0] -print process_nested_parent_str2("30.0,0.0,5.0")[0] -print process_nested_parent_str2("(Thomas)")[0] -print process_nested_parent_str2("Thomas, Paviot, ouais")[0] -print process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0] -print process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0] +print(process_nested_parent_str2("'A'")[0]) +print(process_nested_parent_str2("30.0,0.0,5.0")[0]) +print(process_nested_parent_str2("(Thomas)")[0]) +print(process_nested_parent_str2("Thomas, Paviot, ouais")[0]) +print(process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0]) +print(process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0]) diff --git a/src/exp2python/test/test_base.py b/src/exp2python/test/test_base.py index 270fa324e..413d6fdf6 100644 --- a/src/exp2python/test/test_base.py +++ b/src/exp2python/test/test_base.py @@ -58,7 +58,7 @@ def test_create_from_string(self): def test_type(self): a = INTEGER(5) - self.assertTrue(type(a) == INTEGER) + self.assertTrue(isinstance(a, INTEGER)) def test_inherit_from_NUMBER(self): a = INTEGER(6) @@ -70,7 +70,7 @@ def test_INTEGER_ops(self): b = INTEGER(3) c = a*b self.assertEqual(c,6) - self.assertTrue(type(c) == int) + self.assertTrue(isinstance(c, int)) def test_create_from_string_exception(self): ''' @@ -103,7 +103,7 @@ def test_create_from_string(self): def test_type(self): a = REAL(5) - self.assertTrue(type(a) == REAL) + self.assertTrue(isinstance(a, REAL)) def test_inherit_from_NUMBER(self): a = REAL(4.5) @@ -115,13 +115,13 @@ def test_REAL_ops(self): b = REAL(2) c = a*b self.assertEqual(c,3) - self.assertTrue(type(c) == float) + self.assertTrue(isinstance(c, float)) def test_REAL_INTEGER_ops(self): a = REAL(5.5) b = INTEGER(3) self.assertEqual(a+b,8.5) - self.assertTrue(type(a+b) == float) + self.assertTrue(isinstance(a+b, float)) def test_create_from_string_exception(self): ''' From 7e46389420c359babdcf4043332bfe494c4d08b6 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 12:48:10 +0100 Subject: [PATCH 019/244] MSVC doesn't correctly implement snprintf or vsnprintf until VS2015 --- src/base/sc_stdio.h | 39 +++++++++++++++++++++++++++++ src/exp2cxx/classes_attribute.c | 5 ++-- src/exp2cxx/genCxxFilenames.c | 5 ++-- src/exp2python/src/classes_python.c | 5 ++-- src/exppp/exppp.c | 5 ++-- src/express/error.c | 8 +++--- 6 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 src/base/sc_stdio.h diff --git a/src/base/sc_stdio.h b/src/base/sc_stdio.h new file mode 100644 index 000000000..78fefc53b --- /dev/null +++ b/src/base/sc_stdio.h @@ -0,0 +1,39 @@ +#ifndef __SC_STDIO_H +#define __SC_STDIO_H + +/* + * https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 + * (NOTE: MSVC defines va_list as a char*, so this should be safe) + */ +#if defined(_MSC_VER) && _MSC_VER < 1900 + +#include + +static __inline int +c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) { + int count = -1; + + if (sz != 0) + count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +static __inline int +c99_snprintf(char *buffer, size_t sz, const char *format, ...) { + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(buffer, sz, format, ap); + va_end(ap); + + return count; +} + +#endif + +#endif /* __SC_STDIO_H */ + diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index faf12e480..f304ba176 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -22,8 +22,9 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #include -#if defined( _WIN32 ) || defined ( __WIN32__ ) -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# include "sc_stdio.h" +# define snprintf c99_snprintf #endif extern int old_accessors; diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index f6e87d11a..47004e43d 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -1,8 +1,9 @@ #include "genCxxFilenames.h" #include "class_strings.h" -#if defined( _WIN32 ) || defined ( __WIN32__ ) -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# include "sc_stdio.h" +# define snprintf c99_snprintf #endif /** \file genCxxFilenames.c diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 01e70ec5b..e53dadbe8 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -50,8 +50,9 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define PAD 1 #define NOPAD 0 -#if defined( _WIN32 ) || defined ( __WIN32__ ) -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# include "sc_stdio.h" +# define snprintf c99_snprintf #endif int isAggregateType( const Type t ); diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index 39a213048..a7395d095 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -14,8 +14,9 @@ #include "exppp.h" -#if defined( _WIN32 ) || defined ( __WIN32__ ) -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# include "sc_stdio.h" +# define snprintf c99_snprintf #endif /* PP_SMALL_BUF_SZ is a macro used in a few places where const int causes diff --git a/src/express/error.c b/src/express/error.c index 996aae1df..878590fb5 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -67,8 +67,9 @@ #include "express/info.h" #include "express/linklist.h" -#if defined( _WIN32 ) || defined ( __WIN32__ ) -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# include "sc_stdio.h" +# define vsnprintf c99_vsnprintf #endif bool __ERROR_buffer_errors = false; @@ -124,7 +125,8 @@ static jmp_buf ERROR_safe_env; #define error_file stderr /**< message buffer file */ static int ERROR_vprintf( const char *format, va_list ap ) { - int result = snprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); + int result = vsnprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); + if(result < 0) { ERROR_string = ERROR_string_end; } else if(result > (ERROR_string_end - ERROR_string)) { From 1732897cbc6f3811acdd659b2bce8055ff4085d9 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 12:55:57 +0100 Subject: [PATCH 020/244] simplify DLL exports / imports --- include/sc_export.h | 138 +++++++++++++++------------------ src/base/judy/src/judy.h | 13 +--- src/exp2cxx/classes_wrapper.cc | 14 ++-- 3 files changed, 68 insertions(+), 97 deletions(-) diff --git a/include/sc_export.h b/include/sc_export.h index e128c4906..2f51c9ff5 100644 --- a/include/sc_export.h +++ b/include/sc_export.h @@ -2,107 +2,91 @@ #define SC_EXPORT_H /* Import/Export flags for base. */ -#ifndef SC_BASE_EXPORT -# if defined(SC_BASE_DLL_EXPORTS) && defined(SC_BASE_DLL_IMPORTS) -# error "Only SC_BASE_DLL_EXPORTS or SC_BASE_DLL_IMPORTS can be defined, not both." -# elif defined(SC_BASE_DLL_EXPORTS) +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_BASE_DLL_EXPORTS) # define SC_BASE_EXPORT __declspec(dllexport) -# elif defined(SC_BASE_DLL_IMPORTS) -# define SC_BASE_EXPORT __declspec(dllimport) # else -# define SC_BASE_EXPORT +# define SC_BASE_EXPORT __declspec(dllimport) # endif +#else +# define SC_BASE_EXPORT #endif /* Import/Export flags for express. */ -#ifndef SC_EXPRESS_EXPORT -# if defined(SC_EXPRESS_DLL_EXPORTS) && defined(SC_EXPRESS_DLL_IMPORTS) -# error "Only SC_EXPRESS_DLL_EXPORTS or SC_EXPRESS_DLL_IMPORTS can be defined, not both." -# elif defined(SC_EXPRESS_DLL_EXPORTS) -# define SC_EXPRESS_EXPORT __declspec(dllexport) -# elif defined(SC_EXPRESS_DLL_IMPORTS) -# define SC_EXPRESS_EXPORT __declspec(dllimport) -# else -# define SC_EXPRESS_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_EXPRESS_DLL_EXPORTS) +# define SC_EXPRESS_EXPORT __declspec(dllexport) +# else +# define SC_EXPRESS_EXPORT __declspec(dllimport) +# endif +#else +# define SC_EXPRESS_EXPORT #endif /* Import/Export flags for exppp. */ -#ifndef SC_EXPPP_EXPORT -# if defined(SC_EXPPP_DLL_EXPORTS) && defined(SC_EXPPP_DLL_IMPORTS) -# error "Only SC_EXPPP_DLL_EXPORTS or SC_EXPPP_DLL_IMPORTS can be defined, not both." -# elif defined(SC_EXPPP_DLL_EXPORTS) -# define SC_EXPPP_EXPORT __declspec(dllexport) -# elif defined(SC_EXPPP_DLL_IMPORTS) -# define SC_EXPPP_EXPORT __declspec(dllimport) -# else -# define SC_EXPPP_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_EXPPP_DLL_EXPORTS) +# define SC_EXPPP_EXPORT __declspec(dllexport) +# else +# define SC_EXPPP_EXPORT __declspec(dllimport) +# endif +#else +# define SC_EXPPP_EXPORT #endif /* Import/Export flags for utils. */ -#ifndef SC_UTILS_EXPORT -# if defined(SC_UTILS_DLL_EXPORTS) && defined(SC_UTILS_DLL_IMPORTS) -# error "Only SC_UTILS_DLL_EXPORTS or SC_UTILS_DLL_IMPORTS can be defined, not both." -# elif defined(SC_UTILS_DLL_EXPORTS) -# define SC_UTILS_EXPORT __declspec(dllexport) -# elif defined(SC_UTILS_DLL_IMPORTS) -# define SC_UTILS_EXPORT __declspec(dllimport) -# else -# define SC_UTILS_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_UTILS_DLL_EXPORTS) +# define SC_UTILS_EXPORT __declspec(dllexport) +# else +# define SC_UTILS_EXPORT __declspec(dllimport) +# endif +#else +# define SC_UTILS_EXPORT #endif /* Import/Export flags for dai. */ -#ifndef SC_DAI_EXPORT -# if defined(SC_DAI_DLL_EXPORTS) && defined(SC_DAI_DLL_IMPORTS) -# error "Only SC_DAI_DLL_EXPORTS or SC_DAI_DLL_IMPORTS can be defined, not both." -# elif defined(SC_DAI_DLL_EXPORTS) -# define SC_DAI_EXPORT __declspec(dllexport) -# elif defined(SC_DAI_DLL_IMPORTS) -# define SC_DAI_EXPORT __declspec(dllimport) -# else -# define SC_DAI_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_DAI_DLL_EXPORTS) +# define SC_DAI_EXPORT __declspec(dllexport) +# else +# define SC_DAI_EXPORT __declspec(dllimport) +# endif +#else +# define SC_DAI_EXPORT #endif /* Import/Export flags for core. */ -#ifndef SC_CORE_EXPORT -# if defined(SC_CORE_DLL_EXPORTS) && defined(SC_CORE_DLL_IMPORTS) -# error "Only SC_CORE_DLL_EXPORTS or SC_CORE_DLL_IMPORTS can be defined, not both." -# elif defined(SC_CORE_DLL_EXPORTS) -# define SC_CORE_EXPORT __declspec(dllexport) -# elif defined(SC_CORE_DLL_IMPORTS) -# define SC_CORE_EXPORT __declspec(dllimport) -# else -# define SC_CORE_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_CORE_DLL_EXPORTS) +# define SC_CORE_EXPORT __declspec(dllexport) +# else +# define SC_CORE_EXPORT __declspec(dllimport) +# endif +#else +# define SC_CORE_EXPORT #endif /* Import/Export flags for editor. */ -#ifndef SC_EDITOR_EXPORT -# if defined(SC_EDITOR_DLL_EXPORTS) && defined(SC_EDITOR_DLL_IMPORTS) -# error "Only SC_EDITOR_DLL_EXPORTS or SC_EDITOR_DLL_IMPORTS can be defined, not both." -# elif defined(SC_EDITOR_DLL_EXPORTS) -# define SC_EDITOR_EXPORT __declspec(dllexport) -# elif defined(SC_EDITOR_DLL_IMPORTS) -# define SC_EDITOR_EXPORT __declspec(dllimport) -# else -# define SC_EDITOR_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_EDITOR_DLL_EXPORTS) +# define SC_EDITOR_EXPORT __declspec(dllexport) +# else +# define SC_EDITOR_EXPORT __declspec(dllimport) +# endif +#else +# define SC_EDITOR_EXPORT #endif /* Import/Export flags for lazyfile. */ -#ifndef SC_LAZYFILE_EXPORT -# if defined(SC_LAZYFILE_DLL_EXPORTS) && defined(SC_LAZYFILE_DLL_IMPORTS) -# error "Only SC_LAZYFILE_DLL_EXPORTS or SC_LAZYFILE_DLL_IMPORTS can be defined, not both." -# elif defined(SC_LAZYFILE_DLL_EXPORTS) -# define SC_LAZYFILE_EXPORT __declspec(dllexport) -# elif defined(SC_LAZYFILE_DLL_IMPORTS) -# define SC_LAZYFILE_EXPORT __declspec(dllimport) -# else -# define SC_LAZYFILE_EXPORT -# endif +#if !defined(SC_STATIC) && defined(_WIN32) +# if defined(SC_LAZYFILE_DLL_EXPORTS) +# define SC_LAZYFILE_EXPORT __declspec(dllexport) +# else +# define SC_LAZYFILE_EXPORT __declspec(dllimport) +# endif +#else +# define SC_LAZYFILE_EXPORT #endif #endif /* SC_EXPORT_H */ diff --git a/src/base/judy/src/judy.h b/src/base/judy/src/judy.h index 8721fc293..dfd193cf3 100644 --- a/src/base/judy/src/judy.h +++ b/src/base/judy/src/judy.h @@ -32,18 +32,7 @@ // judy_prv: retrieve the cell pointer for the prev string in the array. // judy_del: delete the key and cell for the current stack entry. -/* Import/Export flags for base. */ -#ifndef SC_BASE_EXPORT -# if defined(SC_BASE_DLL_EXPORTS) && defined(SC_BASE_DLL_IMPORTS) -# error "Only SC_BASE_DLL_EXPORTS or SC_BASE_DLL_IMPORTS can be defined, not both." -# elif defined(SC_BASE_DLL_EXPORTS) -# define SC_BASE_EXPORT __declspec(dllexport) -# elif defined(SC_BASE_DLL_IMPORTS) -# define SC_BASE_EXPORT __declspec(dllimport) -# else -# define SC_BASE_EXPORT -# endif -#endif +#include "sc_export.h" #if defined(__LP64__) || \ defined(__x86_64__) || \ diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 1c7e39b5e..c8732c53c 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -62,16 +62,14 @@ void print_file_header( FILES * files ) { files -> incall = FILEcreate( "schema.h" ); fprintf( files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n" ); - fprintf( files->incall, "\n#ifndef SC_%s_EXPORT\n", "SCHEMA" ); - fprintf( files->incall, "# if defined(SC_%s_DLL_EXPORTS) && defined(SC_%s_DLL_IMPORTS)\n", "SCHEMA", "SCHEMA" ); - fprintf( files->incall, "# error \"SC_%s_DLL_EXPORTS or SC_%s_DLL_IMPORTS can be defined, not both.\"\n", "SCHEMA", "SCHEMA" ); - fprintf( files->incall, "# elif defined(SC_%s_DLL_EXPORTS)\n", "SCHEMA" ); - fprintf( files->incall, "# define SC_%s_EXPORT __declspec(dllexport)\n", "SCHEMA" ); - fprintf( files->incall, "# elif defined(SC_%s_DLL_IMPORTS)\n", "SCHEMA" ); - fprintf( files->incall, "# define SC_%s_EXPORT __declspec(dllimport)\n", "SCHEMA" ); + fprintf( files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n" ); + fprintf( files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n" ); fprintf( files->incall, "# else\n" ); - fprintf( files->incall, "# define SC_%s_EXPORT\n", "SCHEMA" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n" ); fprintf( files->incall, "# endif\n" ); + fprintf( files->incall, "#else\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT\n" ); fprintf( files->incall, "#endif\n\n" ); fprintf( files->incall, "#ifdef SC_LOGGING\n" ); From fd7790253907a7a81a093ac9fa0cc503d2034064 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 15:14:01 +0100 Subject: [PATCH 021/244] drop macro streq --- include/express/basic.h | 3 --- src/exp2cxx/classes_entity.c | 2 +- src/exppp/pretty_schema.c | 2 +- src/express/entity.c | 10 +++++----- src/express/error.c | 8 ++++---- src/express/express.c | 6 +++--- src/express/resolve.c | 4 ++-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/express/basic.h b/include/express/basic.h index 349e653b8..f87f3dadb 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -95,9 +95,6 @@ typedef void * Generic; typedef char * Generic; #endif /* */ -/* other handy macros */ -#define streq(x,y) (!strcmp((x),(y))) - /**************************/ /* function pointer types */ diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index f33b2c13d..d9d4aaf36 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -1014,7 +1014,7 @@ static void collectAttributes( Linked_List curList, const Entity curEntity, enum static bool listContainsVar( Linked_List l, Variable v ) { const char * vName = VARget_simple_name( v ); LISTdo( l, curr, Variable ) { - if( streq( vName, VARget_simple_name( curr ) ) ) { + if( !strcmp( vName, VARget_simple_name( curr ) ) ) { return true; } } diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index ba43f821a..67b6362d5 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -77,7 +77,7 @@ char * SCHEMAout( Schema s ) { if( 0 != ( p = strchr( buf, '\n' ) ) ) { *p = '\0'; } - if( ( !result ) || ( streq( buf, expheader[0] ) ) ) { + if( ( !result ) || ( !strcmp( buf, expheader[0] ) ) ) { unlink( exppp_filename_buffer ); } else { fprintf( stderr, "%s: %s already exists and appears to be hand-written\n", diff --git a/src/express/entity.c b/src/express/entity.c index 77dd5ca8c..e298cfe8d 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -146,7 +146,7 @@ static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down entity->search_id = __SCOPE_search_id; LISTdo( entity->u.entity->supertypes, super, Entity ) - if( streq( super->symbol.name, name ) ) { + if( !strcmp( super->symbol.name, name ) ) { return super; } LISTod @@ -160,7 +160,7 @@ static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down if( down ) { LISTdo( entity->u.entity->subtypes, sub, Entity ) - if( streq( sub->symbol.name, name ) ) { + if( !strcmp( sub->symbol.name, name ) ) { return sub; } LISTod; @@ -177,7 +177,7 @@ static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down } struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { - if( streq( name, entity->symbol.name ) ) { + if( !strcmp( name, entity->symbol.name ) ) { return( entity ); } @@ -437,7 +437,7 @@ Variable ENTITYget_named_attribute( Entity entity, char * name ) { Variable attribute; LISTdo( entity->u.entity->attributes, attr, Variable ) - if( streq( VARget_simple_name( attr ), name ) ) { + if( !strcmp( VARget_simple_name( attr ), name ) ) { return attr; } LISTod; @@ -495,7 +495,7 @@ int ENTITYget_named_attribute_offset( Entity entity, char * name ) { int value; LISTdo( entity->u.entity->attributes, attr, Variable ) - if( streq( VARget_simple_name( attr ), name ) ) + if( !strcmp( VARget_simple_name( attr ), name ) ) return entity->u.entity->inheritance + VARget_offset( ENTITY_find_inherited_attribute( entity, name, 0, 0 ) ); LISTod; diff --git a/src/express/error.c b/src/express/error.c index 878590fb5..ee78137ca 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -199,7 +199,7 @@ void ERRORcreate_warning( char * name, Error error ) { /* first check if we know about this type of error */ LISTdo( ERRORwarnings, opt, Error_Warning ) { - if( streq( name, opt->name ) ) { + if( !strcmp( name, opt->name ) ) { LISTadd_last( opt->errors, ( Generic )error ); return; } @@ -215,14 +215,14 @@ void ERRORcreate_warning( char * name, Error error ) { void ERRORset_warning( char * name, int set ) { - if( streq( name, "all" ) ) { + if( !strcmp( name, "all" ) ) { ERRORset_all_warnings( set ); - } else if( streq( name, "none" ) ) { + } else if( !strcmp( name, "none" ) ) { ERRORset_all_warnings( !set ); } else { bool found = false; LISTdo( ERRORwarnings, opt, Error_Warning ) { - if( streq( opt->name, name ) ) { + if( !strcmp( opt->name, name ) ) { found = true; LISTdo_n( opt->errors, err, Error, b ) { err->enabled = set; diff --git a/src/express/express.c b/src/express/express.c index 4ae48e86d..e01f19860 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -222,7 +222,7 @@ static void EXPRESS_PATHinit() { /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ - if( streq( ".", start ) ) { + if( !strcmp( ".", start ) ) { dir->leaf = dir->full; LISTadd_last( EXPRESS_path, ( Generic )dir ); *( p - 1 ) = save; /* put char back where */ @@ -446,7 +446,7 @@ void EXPRESSparse( Express model, FILE * fp, char * filename ) { int length = strlen( start ); /* drop .exp suffix if present */ - if( dot && streq( dot, ".exp" ) ) { + if( dot && !strcmp( dot, ".exp" ) ) { length -= 4; } @@ -552,7 +552,7 @@ static Generic SCOPEfind_for_rename( Scope schema, char * name ) { } LISTdo( schema->u.schema->uselist, r, Rename * ) - if( streq( ( r->nnew ? r->nnew : r->old )->name, name ) ) { + if( !strcmp( ( r->nnew ? r->nnew : r->old )->name, name ) ) { RENAMEresolve( r, schema ); DICT_type = r->type; return( r->object ); diff --git a/src/express/resolve.c b/src/express/resolve.c index 658c2be39..fcb8012b7 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -957,7 +957,7 @@ void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { static Variable ENTITY_get_local_attribute( Entity e, char * name ) { LISTdo( e->u.entity->attributes, a, Variable ) - if( streq( VARget_simple_name( a ), name ) ) { + if( !strcmp( VARget_simple_name( a ), name ) ) { return a; } LISTod; @@ -982,7 +982,7 @@ void ENTITYresolve_expressions( Entity e ) { if( attr->name->type->u.type->body->type == op_ ) { /* attribute redeclaration */ sname = attr->name->e.op1->e.op2->symbol.name; - if( streq( sname, e->symbol.name ) || + if( !strcmp( sname, e->symbol.name ) || !( sup = ENTITYfind_inherited_entity( e, sname, 0 ) ) ) { ERRORreport_with_symbol( ERROR_redecl_no_such_supertype, &attr->name->e.op1->e.op2->symbol, From f773771f2773250c5e1879ff30d9a4d3ff82f1a1 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:03:36 +0100 Subject: [PATCH 022/244] drop PROTO macro --- include/express/alg.h | 6 +++--- include/express/basic.h | 14 -------------- include/express/caseitem.h | 4 ++-- include/express/dict.h | 18 +++++++++--------- include/express/entity.h | 28 ++++++++++++++-------------- include/express/error.h | 38 +++++++++++++++++++------------------- include/express/expr.h | 24 ++++++++++++------------ include/express/express.h | 26 +++++++++++++------------- include/express/hash.h | 16 ++++++++-------- include/express/lexact.h | 32 ++++++++++++++++---------------- include/express/linklist.h | 32 ++++++++++++++++---------------- include/express/memory.h | 8 ++++---- include/express/object.h | 8 ++++---- include/express/resolve.h | 18 +++++++++--------- include/express/schema.h | 28 ++++++++++++++-------------- include/express/scope.h | 18 +++++++++--------- include/express/stmt.h | 24 ++++++++++++------------ include/express/symbol.h | 2 +- include/express/type.h | 24 ++++++++++++------------ include/express/variable.h | 6 +++--- src/express/expr.c | 2 +- src/express/express.c | 16 ++++++++-------- src/express/resolve.c | 12 ++++++------ 23 files changed, 195 insertions(+), 209 deletions(-) diff --git a/include/express/alg.h b/include/express/alg.h index 8f457638a..b000b98c8 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -161,8 +161,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Scope ALGcreate PROTO( ( char ) ); -extern SC_EXPRESS_EXPORT void ALGinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ALGput_full_text PROTO( ( Scope, int, int ) ); +extern SC_EXPRESS_EXPORT Scope ALGcreate( char ); +extern SC_EXPRESS_EXPORT void ALGinitialize( void ); +extern SC_EXPRESS_EXPORT void ALGput_full_text( Scope, int, int ); #endif /* ALGORITHM_H */ diff --git a/include/express/basic.h b/include/express/basic.h index f87f3dadb..5ff00892d 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -128,20 +128,6 @@ typedef int ( *intFuncptr )(); # endif #endif -#ifndef PROTO -# ifdef __STDC__ -# define PROTO(x) x -# else - -# if defined(__CLCC__) || defined(__MSVC__) || defined(__BORLAND__) -# define PROTO(x) x -#else -# define PROTO(x) () -# endif - -# endif -#endif - #endif /* */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index d3b8fb464..3f36699ed 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -86,7 +86,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; #define CASE_IT_new() (struct Case_Item_ *)MEM_new(&CASE_IT_fl) #define CASE_IT_destroy(x) MEM_destroy(&CASE_IT_fl,(Freelist *)(Generic)x) -extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate PROTO( ( Linked_List, struct Statement_ * ) ); -extern SC_EXPRESS_EXPORT void CASE_ITinitialize PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); +extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); #endif /*CASE_ITEM_H*/ diff --git a/include/express/dict.h b/include/express/dict.h index b46709456..1a32c4608 100644 --- a/include/express/dict.h +++ b/include/express/dict.h @@ -97,14 +97,14 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void DICTinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void DICTcleanup PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT int DICTdefine PROTO( ( Dictionary, char *, Generic, Symbol *, char ) ); -extern SC_EXPRESS_EXPORT int DICT_define PROTO( ( Dictionary, char *, Generic, Symbol *, char ) ); -extern SC_EXPRESS_EXPORT void DICTundefine PROTO( ( Dictionary, char * ) ); -extern SC_EXPRESS_EXPORT Generic DICTlookup PROTO( ( Dictionary, char * ) ); -extern SC_EXPRESS_EXPORT Generic DICTlookup_symbol PROTO( ( Dictionary, char *, Symbol ** ) ); -extern SC_EXPRESS_EXPORT Generic DICTdo PROTO( ( DictionaryEntry * ) ); -extern SC_EXPRESS_EXPORT void DICTprint PROTO( ( Dictionary ) ); +extern SC_EXPRESS_EXPORT void DICTinitialize( void ); +extern SC_EXPRESS_EXPORT void DICTcleanup( void ); +extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, Generic, Symbol *, char ); +extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, Generic, Symbol *, char ); +extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * ); +extern SC_EXPRESS_EXPORT Generic DICTlookup( Dictionary, char * ); +extern SC_EXPRESS_EXPORT Generic DICTlookup_symbol( Dictionary, char *, Symbol ** ); +extern SC_EXPRESS_EXPORT Generic DICTdo( DictionaryEntry * ); +extern SC_EXPRESS_EXPORT void DICTprint( Dictionary ); #endif /*DICTIONARY_H*/ diff --git a/include/express/entity.h b/include/express/entity.h index 8a0ab891b..4cca681a1 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -140,19 +140,19 @@ extern SC_EXPRESS_EXPORT int ENTITY_MARK; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate PROTO( ( struct Symbol_ * ) ); -extern SC_EXPRESS_EXPORT void ENTITYinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ENTITYadd_attribute PROTO( ( struct Scope_ *, struct Variable_ * ) ); -extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy PROTO( ( struct Scope_ * ) ); -extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity PROTO( ( struct Scope_ *, char *, int ) ); -extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute PROTO( ( struct Scope_ *, char *, struct Symbol_ ** ) ); -extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref PROTO( ( Entity, Symbol *, Symbol * ) ); -extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype PROTO( ( Entity, Entity ) ); -extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute PROTO( ( Entity, char * ) ); -extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes PROTO( ( Entity ) ); -extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype PROTO( ( Entity, Entity ) ); -extern SC_EXPRESS_EXPORT void ENTITYadd_instance PROTO( ( Entity, Generic ) ); -extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset PROTO( ( Entity ) ); -extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable PROTO( ( Entity, struct Variable_ * ) ); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT void ENTITYinitialize( void ); +extern SC_EXPRESS_EXPORT void ENTITYadd_attribute( struct Scope_ *, struct Variable_ * ); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy( struct Scope_ * ); +extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, char *, int ); +extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute( struct Scope_ *, char *, struct Symbol_ ** ); +extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref( Entity, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * ); +extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, Generic ); +extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset( Entity ); +extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable( Entity, struct Variable_ * ); #endif /* ENTITY_H */ diff --git a/include/express/error.h b/include/express/error.h index 5e62656d6..d4e10d67e 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -118,8 +118,8 @@ extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /***********************/ #if defined(__MSVC__) || defined(__BORLAND__) -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); +extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); #endif /********************/ @@ -171,28 +171,28 @@ static_inline void ERRORflush_messages( void ) { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERRORinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERRORinitialize_after_LIST PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERRORcleanup PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERRORnospace PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERRORabort PROTO( ( int ) ); -extern SC_EXPRESS_EXPORT Error ERRORcreate PROTO( ( char *, Severity ) ); -extern SC_EXPRESS_EXPORT void ERRORreport PROTO( ( Error, ... ) ); -extern SC_EXPRESS_EXPORT void ERRORdestroy PROTO( ( Error ) ); +extern SC_EXPRESS_EXPORT void ERRORinitialize( void ); +extern SC_EXPRESS_EXPORT void ERRORinitialize_after_LIST( void ); +extern SC_EXPRESS_EXPORT void ERRORcleanup( void ); +extern SC_EXPRESS_EXPORT void ERRORnospace( void ); +extern SC_EXPRESS_EXPORT void ERRORabort( int ); +extern SC_EXPRESS_EXPORT Error ERRORcreate( char *, Severity ); +extern SC_EXPRESS_EXPORT void ERRORreport( Error, ... ); +extern SC_EXPRESS_EXPORT void ERRORdestroy( Error ); struct Symbol_; /* mention Symbol to avoid warning on following line */ -extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol PROTO( ( Error, struct Symbol_ *, ... ) ); -extern SC_EXPRESS_EXPORT void ERRORreport_with_line PROTO( ( Error, int, ... ) ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( Error, struct Symbol_ *, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_line( Error, int, ... ); #if !defined(__MSVC__) && !defined(__BORLAND__) -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); +extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); #endif -extern SC_EXPRESS_EXPORT void ERRORcreate_warning PROTO( ( char *, Error ) ); -extern SC_EXPRESS_EXPORT void ERRORset_warning PROTO( ( char *, int ) ); -extern SC_EXPRESS_EXPORT void ERRORset_all_warnings PROTO( ( int ) ); -extern SC_EXPRESS_EXPORT void ERRORsafe PROTO( ( jmp_buf env ) ); -extern SC_EXPRESS_EXPORT void ERRORunsafe PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT void ERRORcreate_warning( char *, Error ); +extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, int ); +extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( int ); +extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); +extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); #endif /* ERROR_H */ diff --git a/include/express/expr.h b/include/express/expr.h index 56cb8e186..41fcce495 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -178,7 +178,7 @@ struct Expression_ { /** indexed by the op enumeration values */ struct EXPop_entry { char * token; /**< literal token, e.g., "<>" */ - Type( *resolve ) PROTO( ( Expression, struct Scope_ * ) ); + Type( *resolve )( Expression, struct Scope_ * ); }; /********************/ @@ -254,16 +254,16 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Expression EXPcreate PROTO( ( Type ) ); -extern SC_EXPRESS_EXPORT Expression EXPcreate_simple PROTO( ( Type ) ); -extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol PROTO( ( Type, Symbol * ) ); -extern SC_EXPRESS_EXPORT Expression UN_EXPcreate PROTO( ( Op_Code, Expression ) ); -extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate PROTO( ( Op_Code, Expression, Expression ) ); -extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate PROTO( ( Op_Code, Expression, Expression, Expression ) ); -extern SC_EXPRESS_EXPORT Expression QUERYcreate PROTO( ( Symbol *, Expression ) ); -extern SC_EXPRESS_EXPORT void EXPinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void EXPcleanup PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT Type EXPtype PROTO( ( Expression, struct Scope_ * ) ); -extern SC_EXPRESS_EXPORT int EXPget_integer_value PROTO( ( Expression ) ); +extern SC_EXPRESS_EXPORT Expression EXPcreate( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_simple( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol( Type, Symbol * ); +extern SC_EXPRESS_EXPORT Expression UN_EXPcreate( Op_Code, Expression ); +extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate( Op_Code, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate( Op_Code, Expression, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression QUERYcreate( Symbol *, Expression ); +extern SC_EXPRESS_EXPORT void EXPinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPcleanup( void ); +extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); +extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); #endif /*EXPRESSION_H*/ diff --git a/include/express/express.h b/include/express/express.h index f04beb1d3..43377845e 100644 --- a/include/express/express.h +++ b/include/express/express.h @@ -92,14 +92,14 @@ extern SC_EXPRESS_EXPORT char * input_filename; extern SC_EXPRESS_EXPORT Linked_List EXPRESS_path; extern SC_EXPRESS_EXPORT int EXPRESSpass; -extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_args ) PROTO( ( int, char ** ) ); -extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_parse ) PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT int ( *EXPRESSfail ) PROTO( ( Express ) ); -extern SC_EXPRESS_EXPORT int ( *EXPRESSsucceed ) PROTO( ( Express ) ); -extern SC_EXPRESS_EXPORT void ( *EXPRESSbackend ) PROTO( ( Express ) ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_args )( int, char ** ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_parse )( void ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSfail )( Express ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSsucceed )( Express ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSbackend )( Express ); extern SC_EXPRESS_EXPORT char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt ) PROTO( ( int, char * ) ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt )( int, char * ); extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas; extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */ @@ -128,15 +128,15 @@ extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Express EXPRESScreate PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void EXPRESSdestroy PROTO( ( Express ) ); -extern SC_EXPRESS_EXPORT void EXPRESSparse PROTO( ( Express, FILE *, char * ) ); -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 Express EXPRESScreate( void ); +extern SC_EXPRESS_EXPORT void EXPRESSdestroy( Express ); +extern SC_EXPRESS_EXPORT void EXPRESSparse( Express, FILE *, char * ); +extern SC_EXPRESS_EXPORT void EXPRESSinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPRESScleanup( void ); +extern SC_EXPRESS_EXPORT void EXPRESSresolve( 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 void EXPRESSinit_init( void ); extern SC_EXPRESS_EXPORT void build_complex( Express ); #endif /*EXPRESS_H*/ diff --git a/include/express/hash.h b/include/express/hash.h index c9e7782c1..a64a98c9c 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -193,13 +193,13 @@ This change only seems to have affected hash.h and hash.c /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void HASHinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT Hash_Table HASHcreate PROTO( ( unsigned ) ); -extern SC_EXPRESS_EXPORT Hash_Table HASHcopy PROTO( ( Hash_Table ) ); -extern SC_EXPRESS_EXPORT void HASHdestroy PROTO( ( Hash_Table ) ); -extern SC_EXPRESS_EXPORT Element HASHsearch PROTO( ( Hash_Table, Element, Action ) ); -extern SC_EXPRESS_EXPORT void HASHlistinit PROTO( ( Hash_Table, HashEntry * ) ); -extern SC_EXPRESS_EXPORT void HASHlistinit_by_type PROTO( ( Hash_Table, HashEntry *, char ) ); -extern SC_EXPRESS_EXPORT Element HASHlist PROTO( ( HashEntry * ) ); +extern SC_EXPRESS_EXPORT void HASHinitialize( void ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( unsigned ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table ); +extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table ); +extern SC_EXPRESS_EXPORT Element HASHsearch( Hash_Table, Element, Action ); +extern SC_EXPRESS_EXPORT void HASHlistinit( Hash_Table, HashEntry * ); +extern SC_EXPRESS_EXPORT void HASHlistinit_by_type( Hash_Table, HashEntry *, char ); +extern SC_EXPRESS_EXPORT Element HASHlist( HashEntry * ); #endif /*HASH_H*/ diff --git a/include/express/lexact.h b/include/express/lexact.h index 40bc47539..aa71342fa 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -99,22 +99,22 @@ extern SC_EXPRESS_EXPORT Error ERROR_nonascii_char; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SCANinitialize PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT void SCANinitialize( void ); extern SC_EXPRESS_EXPORT void SCANcleanup( void ); -extern SC_EXPRESS_EXPORT int SCANprocess_real_literal PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal PROTO( ( char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_string PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT int SCANprocess_semicolon PROTO( ( const char *, int ) ); -extern SC_EXPRESS_EXPORT void SCANsave_comment PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT bool SCANread PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void SCANinclude_file PROTO( ( char * ) ); - SC_EXPRESS_EXPORT void SCANlowerize PROTO( ( char * ) ); - SC_EXPRESS_EXPORT void SCANupperize PROTO( ( char * ) ); -extern SC_EXPRESS_EXPORT char * SCANstrdup PROTO( ( const char * ) ); -extern SC_EXPRESS_EXPORT long SCANtell PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT int SCANprocess_real_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal( char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_semicolon( const char *, int ); +extern SC_EXPRESS_EXPORT void SCANsave_comment( const char * ); +extern SC_EXPRESS_EXPORT bool SCANread( void ); +extern SC_EXPRESS_EXPORT void SCANinclude_file( char * ); + SC_EXPRESS_EXPORT void SCANlowerize( char * ); + SC_EXPRESS_EXPORT void SCANupperize( char * ); +extern SC_EXPRESS_EXPORT char * SCANstrdup( const char * ); +extern SC_EXPRESS_EXPORT long SCANtell( void ); #endif /* LEX_ACTIONS_H */ diff --git a/include/express/linklist.h b/include/express/linklist.h index 01581eb14..860307907 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -125,22 +125,22 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /* function prototypes */ /***********************/ -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 ) ); -extern SC_EXPRESS_EXPORT Generic LISTadd_before PROTO( ( Linked_List, Link, Generic ) ); -extern SC_EXPRESS_EXPORT Generic LISTremove_first PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT Generic LISTget_first PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT Generic LISTget_second PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT Generic LISTget_nth PROTO( ( Linked_List, int ) ); -extern SC_EXPRESS_EXPORT void LISTfree PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT int LISTget_length PROTO( ( Linked_List ) ); +extern SC_EXPRESS_EXPORT void LISTinitialize( void ); +extern SC_EXPRESS_EXPORT void LISTcleanup( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcreate( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcopy( Linked_List ); +extern SC_EXPRESS_EXPORT void LISTsort( Linked_List, int (*comp)(void*, void*) ); +extern SC_EXPRESS_EXPORT void LISTswap( Link, Link ); +extern SC_EXPRESS_EXPORT Generic LISTadd_first( Linked_List, Generic ); +extern SC_EXPRESS_EXPORT Generic LISTadd_last( Linked_List, Generic ); +extern SC_EXPRESS_EXPORT Generic LISTadd_after( Linked_List, Link, Generic ); +extern SC_EXPRESS_EXPORT Generic LISTadd_before( Linked_List, Link, Generic ); +extern SC_EXPRESS_EXPORT Generic LISTremove_first( Linked_List ); +extern SC_EXPRESS_EXPORT Generic LISTget_first( Linked_List ); +extern SC_EXPRESS_EXPORT Generic LISTget_second( Linked_List ); +extern SC_EXPRESS_EXPORT Generic LISTget_nth( Linked_List, int ); +extern SC_EXPRESS_EXPORT void LISTfree( Linked_List ); +extern SC_EXPRESS_EXPORT int LISTget_length( Linked_List ); extern SC_EXPRESS_EXPORT bool LISTempty( Linked_List list ); #endif /*LINKED_LIST_H*/ diff --git a/include/express/memory.h b/include/express/memory.h index 305664739..69b93fa8f 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -75,10 +75,10 @@ extern SC_EXPRESS_EXPORT int yylineno; fprintf(stderr,"fedex: out of space");\ } else {} -SC_EXPRESS_EXPORT void _MEMinitialize PROTO( ( void ) ); -SC_EXPRESS_EXPORT void MEMinitialize PROTO( ( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) ); -SC_EXPRESS_EXPORT void MEM_destroy PROTO( ( struct freelist_head *, Freelist * ) ); -SC_EXPRESS_EXPORT Generic MEM_new PROTO( ( struct freelist_head * ) ); +SC_EXPRESS_EXPORT void _MEMinitialize( void ); +SC_EXPRESS_EXPORT void MEMinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); +SC_EXPRESS_EXPORT void MEM_destroy( struct freelist_head *, Freelist * ); +SC_EXPRESS_EXPORT void * MEM_new( struct freelist_head * ); #endif /* MEMORY_H */ diff --git a/include/express/object.h b/include/express/object.h index d0f5052bf..bd026bce4 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -97,9 +97,9 @@ extern SC_EXPRESS_EXPORT struct Object * OBJ; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void OBJinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void OBJcleanup PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void OBJcreate PROTO( ( char, struct Symbol_ * ( * )( Generic ), char *, int ) ); -extern SC_EXPRESS_EXPORT Symbol * UNK_get_symbol PROTO( ( Generic x ) ); +extern SC_EXPRESS_EXPORT void OBJinitialize( void ); +extern SC_EXPRESS_EXPORT void OBJcleanup( void ); +extern SC_EXPRESS_EXPORT void OBJcreate( char, struct Symbol_ * (*) (void *), char *, int); +extern SC_EXPRESS_EXPORT Symbol * UNK_get_symbol( void *x ); #endif /*OBJECT_H*/ diff --git a/include/express/resolve.h b/include/express/resolve.h index c9169d55c..4be46373f 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -73,14 +73,14 @@ extern SC_EXPRESS_EXPORT Error WARNING_fn_skip_branch; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void RESOLVEinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void RESOLVEcleanup PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_types PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT void TYPE_resolve PROTO( ( Type * ) ); -extern SC_EXPRESS_EXPORT void EXP_resolve PROTO( ( Expression, Scope, Type ) ); -extern SC_EXPRESS_EXPORT void ALGresolve PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT void SCHEMAresolve PROTO( ( Scope ) ); +extern SC_EXPRESS_EXPORT void RESOLVEinitialize( void ); +extern SC_EXPRESS_EXPORT void RESOLVEcleanup( void ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_types( Scope ); +extern SC_EXPRESS_EXPORT void TYPE_resolve( Type * ); +extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); +extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); +extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); #endif /*RESOLVE_H*/ diff --git a/include/express/schema.h b/include/express/schema.h index 3640646cd..6e26b51d1 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -133,20 +133,20 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARfind PROTO( ( Scope, char *, int ) ); -extern SC_EXPRESS_EXPORT Schema SCHEMAcreate PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void SCHEMAinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void SCHEMAadd_use PROTO( ( Schema, Symbol *, Symbol *, Symbol * ) ); -extern SC_EXPRESS_EXPORT void SCHEMAadd_reference PROTO( ( Schema, Symbol *, Symbol *, Symbol * ) ); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_use PROTO( ( Schema, Rename * ) ); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference PROTO( ( Schema, Rename * ) ); -extern SC_EXPRESS_EXPORT Generic SCHEMAfind PROTO( ( Schema, char * name, int search_refs ) ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate PROTO( ( char ) ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny PROTO( ( char ) ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab PROTO( ( char ) ); -extern SC_EXPRESS_EXPORT void SCOPEdestroy PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref PROTO( ( Scope ) ); +extern SC_EXPRESS_EXPORT Variable VARfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT Schema SCHEMAcreate( void ); +extern SC_EXPRESS_EXPORT void SCHEMAinitialize( void ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_use( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_reference( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_use( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void * SCHEMAfind( Schema, char * name, int search_refs ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab( char ); +extern SC_EXPRESS_EXPORT void SCOPEdestroy( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref( Scope ); #endif /* SCHEMA_H */ diff --git a/include/express/scope.h b/include/express/scope.h index c087fc035..90ba99563 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -134,14 +134,14 @@ struct Scope_ { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol PROTO( ( Generic ) ); -extern SC_EXPRESS_EXPORT void SCOPE_get_entities PROTO( ( Scope, Linked_List ) ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT Generic SCOPEfind PROTO( ( Scope, char *, int ) ); -extern SC_EXPRESS_EXPORT void SCOPE_get_functions PROTO( ( Scope, Linked_List ) ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions PROTO( ( Scope ) ); -extern SC_EXPRESS_EXPORT void SCOPE_get_rules PROTO( ( Scope, Linked_List ) ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules PROTO( ( Scope ) ); +extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( Generic ); +extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope ); +extern SC_EXPRESS_EXPORT Generic SCOPEfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); +extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); #endif /* SCOPE_H */ diff --git a/include/express/stmt.h b/include/express/stmt.h index f32eaa7fd..4aa909b9e 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -225,17 +225,17 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Statement STMTcreate PROTO( ( int ) ); -extern SC_EXPRESS_EXPORT Statement ALIAScreate PROTO( ( struct Scope_ *, Variable, Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement CASEcreate PROTO( ( Expression , Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement ASSIGNcreate PROTO( ( Expression , Expression ) ); -extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement CONDcreate PROTO( ( Expression, Linked_List, Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement LOOPcreate PROTO( ( struct Scope_ *, Expression, Expression, Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement PCALLcreate PROTO( ( Linked_List ) ); -extern SC_EXPRESS_EXPORT Statement RETcreate PROTO( ( Expression ) ); -extern SC_EXPRESS_EXPORT void STMTinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate PROTO( ( Symbol *, Expression start, - Expression end, Expression increment ) ); +extern SC_EXPRESS_EXPORT Statement STMTcreate( int ); +extern SC_EXPRESS_EXPORT Statement ALIAScreate( struct Scope_ *, Variable, Linked_List ); +extern SC_EXPRESS_EXPORT Statement CASEcreate( Expression , Linked_List ); +extern SC_EXPRESS_EXPORT Statement ASSIGNcreate( Expression , Expression ); +extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement CONDcreate( Expression, Linked_List, Linked_List ); +extern SC_EXPRESS_EXPORT Statement LOOPcreate( struct Scope_ *, Expression, Expression, Linked_List ); +extern SC_EXPRESS_EXPORT Statement PCALLcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement RETcreate( Expression ); +extern SC_EXPRESS_EXPORT void STMTinitialize( void ); +extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate( Symbol *, Expression start, + Expression end, Expression increment ); #endif /*STATEMENT_H*/ diff --git a/include/express/symbol.h b/include/express/symbol.h index 5e2acc4a4..e61e38ac0 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -88,7 +88,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SYMBOLinitialize PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT void SYMBOLinitialize( void ); SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename ); #endif /* SYMBOL_H */ diff --git a/include/express/type.h b/include/express/type.h index 3cd5ff1a6..2ffc1652b 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -293,20 +293,20 @@ extern SC_EXPRESS_EXPORT Error ERROR_corrupted_type; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Type TYPEcreate_partial PROTO( ( struct Symbol_ *, Scope ) ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_partial( struct Symbol_ *, Scope ); -extern SC_EXPRESS_EXPORT Type TYPEcreate PROTO( ( enum type_enum ) ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously PROTO( ( TypeBody ) ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_name PROTO( ( struct Symbol_ * ) ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab PROTO( ( struct Symbol_ *, Scope, char ) ); -extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate PROTO( ( enum type_enum ) ); -extern SC_EXPRESS_EXPORT void TYPEinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT void TYPEcleanup PROTO( ( void ) ); +extern SC_EXPRESS_EXPORT Type TYPEcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously( TypeBody ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_name( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab( struct Symbol_ *, Scope, char ); +extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT void TYPEinitialize( void ); +extern SC_EXPRESS_EXPORT void TYPEcleanup( void ); -extern SC_EXPRESS_EXPORT bool TYPEinherits_from PROTO( ( Type, enum type_enum ) ); -extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type PROTO( ( Type ) ); +extern SC_EXPRESS_EXPORT bool TYPEinherits_from( Type, enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type( Type ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type PROTO( ( Type, Scope, struct Symbol_ * ) ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag PROTO( ( Type, Scope, struct Symbol_ * ) ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type( Type, Scope, struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag( Type, Scope, struct Symbol_ * ); #endif /* TYPE_H */ diff --git a/include/express/variable.h b/include/express/variable.h index 0b6a781e7..f49693222 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -125,8 +125,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARcreate PROTO( ( Expression, Type ) ); -extern SC_EXPRESS_EXPORT void VARinitialize PROTO( ( void ) ); -extern SC_EXPRESS_EXPORT char * VARget_simple_name PROTO( ( Variable ) ); +extern SC_EXPRESS_EXPORT Variable VARcreate( Expression, Type ); +extern SC_EXPRESS_EXPORT void VARinitialize( void ); +extern SC_EXPRESS_EXPORT char * VARget_simple_name( Variable ); #endif /* VARIABLE_H */ diff --git a/src/express/expr.c b/src/express/expr.c index 72a69586b..aaf972f13 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -733,7 +733,7 @@ Type EXPresolve_op_unknown( Expression e, Scope s ) { return Type_Bad; } -typedef Type Resolve_expr_func PROTO( ( Expression , Scope ) ); +typedef Type (Resolve_expr_func) ( Expression , Scope ); Type EXPresolve_op_logical( Expression e, Scope s ) { EXPresolve_op_default( e, s ); diff --git a/src/express/express.c b/src/express/express.c index e01f19860..47c07e4e8 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -94,14 +94,14 @@ void ParseTrace(FILE *TraceFILE, char *zTracePrompt); Linked_List EXPRESS_path; int EXPRESSpass; -void ( *EXPRESSinit_args ) PROTO( ( int, char ** ) ) = 0; -void ( *EXPRESSinit_parse ) PROTO( ( void ) ) = 0; -int ( *EXPRESSfail ) PROTO( ( Express ) ) = 0; -int ( *EXPRESSsucceed ) PROTO( ( Express ) ) = 0; -void ( *EXPRESSbackend ) PROTO( ( Express ) ) = 0; +void ( *EXPRESSinit_args )( int, char ** ) = NULL; +void ( *EXPRESSinit_parse )( void ) = NULL; +int ( *EXPRESSfail )( Express ) = NULL; +int ( *EXPRESSsucceed )( Express ) = NULL; +void ( *EXPRESSbackend )( Express ) = NULL; char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -int ( *EXPRESSgetopt ) PROTO( ( int, char * ) ) = 0; +int ( *EXPRESSgetopt )( int, char * ) = NULL; bool EXPRESSignore_duplicate_schemas = false; Dictionary EXPRESSbuiltins; /* procedures/functions */ @@ -125,7 +125,7 @@ static Error ERROR_schema_not_in_own_schema_file; extern Linked_List PARSEnew_schemas; void SCOPEinitialize( void ); -static Express PARSERrun PROTO( ( char *, FILE * ) ); +static Express PARSERrun( char *, FILE * ); /** name specified on command line */ char * input_filename = 0; @@ -469,7 +469,7 @@ void parserInitState(); /** start parsing a new schema file */ static Express PARSERrun( char * filename, FILE * fp ) { - extern void SCAN_lex_init PROTO( ( char *, FILE * ) ); + extern void SCAN_lex_init( char *, FILE * ); extern YYSTYPE yylval; extern int yyerrstatus; int tokenID; diff --git a/src/express/resolve.c b/src/express/resolve.c index fcb8012b7..d5fcf9784 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -78,9 +78,9 @@ Error WARNING_fn_skip_branch = ERROR_none; Error WARNING_case_skip_label = ERROR_none; -static void ENTITYresolve_subtypes PROTO( ( Schema ) ); -static void ENTITYresolve_supertypes PROTO( ( Entity ) ); -static void TYPEresolve_expressions PROTO( ( Type, Scope ) ); +static void ENTITYresolve_subtypes( Schema ); +static void ENTITYresolve_supertypes( Entity ); +static void TYPEresolve_expressions( Type, Scope ); static Error ERROR_wrong_arg_count; static Error ERROR_supertype_resolve; @@ -115,9 +115,9 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -static int WHEREresolve PROTO( ( Linked_List, Scope, int ) ); -extern void VAR_resolve_expressions PROTO( ( Variable, Entity ) ); -extern void VAR_resolve_types PROTO( ( Variable v ) ); +static int WHEREresolve( Linked_List, Scope, int ); +extern void VAR_resolve_expressions( Variable, Entity ); +extern void VAR_resolve_types( Variable v ); /** Initialize the Fed-X second pass. */ void RESOLVEinitialize( void ) { From e934fa246c3d0f8bf6d57c38655f8fb36d971995 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:21:04 +0100 Subject: [PATCH 023/244] drop the Generic typedef --- cmake/schema_scanner/schemaScanner.cc | 2 +- include/express/alg.h | 10 ++++----- include/express/basic.h | 10 --------- include/express/caseitem.h | 2 +- include/express/dict.h | 10 ++++----- include/express/entity.h | 2 +- include/express/error.h | 2 +- include/express/expbasic.h | 4 ---- include/express/expr.h | 8 ++++---- include/express/hash.h | 2 +- include/express/linklist.h | 22 ++++++++++---------- include/express/memory.h | 2 +- include/express/schema.h | 8 ++++---- include/express/scope.h | 4 ++-- include/express/stmt.h | 18 ++++++++-------- include/express/symbol.h | 2 +- include/express/type.h | 4 ++-- include/express/variable.h | 2 +- src/exp2cxx/classes.c | 5 ++--- src/exp2cxx/classes_entity.c | 4 ++-- src/exp2cxx/classes_misc.c | 2 +- src/exp2cxx/classes_wrapper.cc | 2 +- src/exp2cxx/selects.c | 16 +++++++-------- src/exp2python/src/classes_misc_python.c | 2 +- src/exp2python/src/selects_python.c | 4 ++-- src/exppp/pretty_ref.c | 5 ++--- src/exppp/pretty_scope.c | 10 ++++----- src/express/alg.c | 2 +- src/express/dict.c | 10 ++++----- src/express/entity.c | 10 ++++----- src/express/error.c | 6 +++--- src/express/expr.c | 10 ++++----- src/express/express.c | 22 ++++++++++---------- src/express/lexact.c | 2 +- src/express/linklist.c | 26 ++++++++++++------------ src/express/memory.c | 4 ++-- src/express/object.c | 4 ++-- src/express/parse_data.h | 4 ++++ src/express/resolve.c | 18 ++++++++-------- src/express/schema.c | 12 +++++------ src/express/scope.c | 20 +++++++++--------- src/express/stmt.c | 2 +- src/express/type.c | 6 +++--- src/express/variable.c | 2 +- 44 files changed, 156 insertions(+), 168 deletions(-) diff --git a/cmake/schema_scanner/schemaScanner.cc b/cmake/schema_scanner/schemaScanner.cc index 9460733de..8b3647f60 100644 --- a/cmake/schema_scanner/schemaScanner.cc +++ b/cmake/schema_scanner/schemaScanner.cc @@ -244,7 +244,7 @@ void printSchemaFilenames( Schema sch ){ int ecount = 0, tcount = 0; DictionaryEntry de; - Generic x; + void *x; filenames_t fn; DICTdo_init( sch->symbol_table, &de ); while( 0 != ( x = DICTdo( &de ) ) ) { diff --git a/include/express/alg.h b/include/express/alg.h index b000b98c8..e37ab1671 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -120,15 +120,15 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /******************************/ #define ALG_new() (struct Algorithm *)MEM_new(&ALG_fl); -#define ALG_destroy(x) MEM_destroy(&ALG_fl,(Freelist *)(Generic)x) +#define ALG_destroy(x) MEM_destroy(&ALG_fl,(Freelist *)x) #define FUNC_new() (struct Function_ *)MEM_new(&FUNC_fl) -#define FUNC_destroy(x) MEM_destroy(&FUNC_fl,(Freelist *)(Generic)x) +#define FUNC_destroy(x) MEM_destroy(&FUNC_fl,(Freelist *)x) #define RULE_new() (struct Rule_ *)MEM_new(&RULE_fl) -#define RULE_destroy(x) MEM_destroy(&RULE_fl,(Freelist *)(Generic)x) +#define RULE_destroy(x) MEM_destroy(&RULE_fl,(Freelist *)x) #define PROC_new() (struct Procedure_ *)MEM_new(&PROC_fl) -#define PROC_destroy(x) MEM_destroy(&PROC_fl,(Freelist *)(Generic)x) +#define PROC_destroy(x) MEM_destroy(&PROC_fl,(Freelist *)x) #define WHERE_new() (struct Where_ *)MEM_new(&WHERE_fl) -#define WHERE_destroy(x) MEM_destroy(&WHERE_fl,(Freelist *)(Generic)x) +#define WHERE_destroy(x) MEM_destroy(&WHERE_fl,(Freelist *)x) #define ALGput_name(algorithm, name) SCOPEput_name(algorithm,name) #define ALGget_name(algorithm) SCOPEget_name(algorithm) diff --git a/include/express/basic.h b/include/express/basic.h index 5ff00892d..353117a1e 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -85,16 +85,6 @@ # include #endif -/************************/ -/* Generic pointer type */ -/************************/ - -#ifdef __STDC__ -typedef void * Generic; -#else -typedef char * Generic; -#endif /* */ - /**************************/ /* function pointer types */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index 3f36699ed..d5bd4fa4d 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -84,7 +84,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; /***********************/ #define CASE_IT_new() (struct Case_Item_ *)MEM_new(&CASE_IT_fl) -#define CASE_IT_destroy(x) MEM_destroy(&CASE_IT_fl,(Freelist *)(Generic)x) +#define CASE_IT_destroy(x) MEM_destroy(&CASE_IT_fl,(Freelist *)x) extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); diff --git a/include/express/dict.h b/include/express/dict.h index 1a32c4608..f289ecca3 100644 --- a/include/express/dict.h +++ b/include/express/dict.h @@ -99,12 +99,12 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look extern SC_EXPRESS_EXPORT void DICTinitialize( void ); extern SC_EXPRESS_EXPORT void DICTcleanup( void ); -extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, Generic, Symbol *, char ); -extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, Generic, Symbol *, char ); +extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, void *, Symbol *, char ); +extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, void *, Symbol *, char ); extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * ); -extern SC_EXPRESS_EXPORT Generic DICTlookup( Dictionary, char * ); -extern SC_EXPRESS_EXPORT Generic DICTlookup_symbol( Dictionary, char *, Symbol ** ); -extern SC_EXPRESS_EXPORT Generic DICTdo( DictionaryEntry * ); +extern SC_EXPRESS_EXPORT void * DICTlookup( Dictionary, char * ); +extern SC_EXPRESS_EXPORT void * DICTlookup_symbol( Dictionary, char *, Symbol ** ); +extern SC_EXPRESS_EXPORT void * DICTdo( DictionaryEntry * ); extern SC_EXPRESS_EXPORT void DICTprint( Dictionary ); #endif /*DICTIONARY_H*/ diff --git a/include/express/entity.h b/include/express/entity.h index 4cca681a1..8bdc97a78 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -151,7 +151,7 @@ extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * ); extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity ); extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity ); -extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, Generic ); +extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, void *); extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset( Entity ); extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable( Entity, struct Variable_ * ); diff --git a/include/express/error.h b/include/express/error.h index d4e10d67e..f49ec9708 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -111,7 +111,7 @@ extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /******************************/ #define ERROR_OPT_new() (struct Error_Warning_ *)MEM_new(&ERROR_OPT_fl) -#define ERROR_OPT_destroy(x) MEM_destroy(&ERROR_OPT_fl,(Freelist *)(Generic)x) +#define ERROR_OPT_destroy(x) MEM_destroy(&ERROR_OPT_fl,(Freelist *)x) /***********************/ /* function prototypes */ diff --git a/include/express/expbasic.h b/include/express/expbasic.h index 15006e379..509701e16 100644 --- a/include/express/expbasic.h +++ b/include/express/expbasic.h @@ -46,11 +46,7 @@ typedef enum { Lfalse, Lunknown, Ltrue } Logical; /* typedef ... Binary; done below because String not defined yet */ #ifndef _CLIENTDATA -# ifdef __STDC__ typedef void * ClientData; -# else -typedef int * ClientData; -# endif /* __STDC__ */ #define _CLIENTDATA #endif diff --git a/include/express/expr.h b/include/express/expr.h index 41fcce495..8d13814b2 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -208,13 +208,13 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /******************************/ #define EXP_new() (struct Expression_ *)MEM_new(&EXP_fl) -#define EXP_destroy(x) MEM_destroy(&EXP_fl,(Freelist *)(Generic)x) +#define EXP_destroy(x) MEM_destroy(&EXP_fl,(Freelist *)x) #define OP_new() (struct Op_Subexpression *)MEM_new(&OP_fl) -#define OP_destroy(x) MEM_destroy(&OP_fl,(Freelist *)(Generic)x) +#define OP_destroy(x) MEM_destroy(&OP_fl,(Freelist *)x) #define QUERY_new() (struct Query_ *)MEM_new(&QUERY_fl) -#define QUERY_destroy(x) MEM_destroy(&QUERY_fl,(Freelist *)(Generic)x) +#define QUERY_destroy(x) MEM_destroy(&QUERY_fl,(Freelist *)x) #define QUAL_ATTR_new() (struct Qualified_Attr *)MEM_new(&QUAL_ATTR_fl) -#define QUAL_ATTR_destroy(x) MEM_destroy(&QUAL_ATTR_fl,(Freelist *)(Generic)x) +#define QUAL_ATTR_destroy(x) MEM_destroy(&QUAL_ATTR_fl,(Freelist *)x) #define EXPget_name(e) ((e)->symbol.name) #define ENUMget_name(e) ((e)->symbol.name) diff --git a/include/express/hash.h b/include/express/hash.h index a64a98c9c..b75c3d1d9 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -184,7 +184,7 @@ This change only seems to have affected hash.h and hash.c #define MOD(x,y) ((x) & ((y)-1)) #define HASH_Table_new() (struct Hash_Table_ *)MEM_new(&HASH_Table_fl) -#define HASH_Table_destroy(x) MEM_destroy(&HASH_Table_fl,(Freelist *)(Generic)x) +#define HASH_Table_destroy(x) MEM_destroy(&HASH_Table_fl,(Freelist *)x) #define HASH_Element_new() (struct Element_ *)MEM_new(&HASH_Element_fl) #define HASH_Element_destroy(x) MEM_destroy(&HASH_Element_fl,(Freelist *)(char *)x) diff --git a/include/express/linklist.h b/include/express/linklist.h index 860307907..b820aa06c 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -59,7 +59,7 @@ typedef struct Linked_List_ * Linked_List; typedef struct Link_ { struct Link_ * next; struct Link_ * prev; - Generic data; + void *data; } * Link; struct Linked_List_ { @@ -79,9 +79,9 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /******************************/ #define LINK_new() (struct Link_ *)MEM_new(&LINK_fl) -#define LINK_destroy(x) MEM_destroy(&LINK_fl,(Freelist *)(Generic)x) +#define LINK_destroy(x) MEM_destroy(&LINK_fl,(Freelist *)x) #define LIST_new() (struct Linked_List_ *)MEM_new(&LIST_fl) -#define LIST_destroy(x) MEM_destroy(&LIST_fl,(Freelist *)(Generic)x) +#define LIST_destroy(x) MEM_destroy(&LIST_fl,(Freelist *)x) /** accessing links */ #define LINKdata(link) (link)->data @@ -131,14 +131,14 @@ extern SC_EXPRESS_EXPORT Linked_List LISTcreate( void ); extern SC_EXPRESS_EXPORT Linked_List LISTcopy( Linked_List ); extern SC_EXPRESS_EXPORT void LISTsort( Linked_List, int (*comp)(void*, void*) ); extern SC_EXPRESS_EXPORT void LISTswap( Link, Link ); -extern SC_EXPRESS_EXPORT Generic LISTadd_first( Linked_List, Generic ); -extern SC_EXPRESS_EXPORT Generic LISTadd_last( Linked_List, Generic ); -extern SC_EXPRESS_EXPORT Generic LISTadd_after( Linked_List, Link, Generic ); -extern SC_EXPRESS_EXPORT Generic LISTadd_before( Linked_List, Link, Generic ); -extern SC_EXPRESS_EXPORT Generic LISTremove_first( Linked_List ); -extern SC_EXPRESS_EXPORT Generic LISTget_first( Linked_List ); -extern SC_EXPRESS_EXPORT Generic LISTget_second( Linked_List ); -extern SC_EXPRESS_EXPORT Generic LISTget_nth( Linked_List, int ); +extern SC_EXPRESS_EXPORT void * LISTadd_first( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_last( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_after( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_before( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTremove_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_second( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_nth( Linked_List, int ); extern SC_EXPRESS_EXPORT void LISTfree( Linked_List ); extern SC_EXPRESS_EXPORT int LISTget_length( Linked_List ); extern SC_EXPRESS_EXPORT bool LISTempty( Linked_List list ); diff --git a/include/express/memory.h b/include/express/memory.h index 69b93fa8f..0c05a8325 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -48,7 +48,7 @@ struct freelist_head { int alloc; /**< # of allocations */ int dealloc; int create; /**< number of calls to create a new freelist */ - Generic max; /**< end of freelist */ + void *max; /**< end of freelist */ #endif int size; /**< size of a single elt incl. next ptr */ int bytes; /**< if we run out, allocate memory by this many bytes */ diff --git a/include/express/schema.h b/include/express/schema.h index 6e26b51d1..c44946b70 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -76,7 +76,7 @@ typedef struct Rename { Schema schema; struct Symbol_ * old; struct Symbol_ * nnew; - Generic object; /**< once object has been looked up */ + void *object; /**< once object has been looked up */ char type; /**< drat, need to remember this once renames have been * resolved to avoid looking them up in the dictionary again */ enum rename_type rename_type; @@ -118,11 +118,11 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; #define SCHEMAget_symbol(schema) SCOPEget_symbol(schema) #define REN_new() (struct Rename *)MEM_new(&REN_fl) -#define REN_destroy(x) MEM_destroy(&REN_fl,(Freelist *)(Generic)x) +#define REN_destroy(x) MEM_destroy(&REN_fl,(Freelist *)x) #define SCOPE_new() (struct Scope_ *)MEM_new(&SCOPE_fl) -#define SCOPE_destroy(x) MEM_destroy(&SCOPE_fl,(Freelist *)(Generic)x) +#define SCOPE_destroy(x) MEM_destroy(&SCOPE_fl,(Freelist *)x) #define SCHEMA_new() (struct Schema_ *)MEM_new(&SCHEMA_fl) -#define SCHEMA_destroy(x) MEM_destroy(&SCHEMA_fl,(Freelist *)(Generic)x) +#define SCHEMA_destroy(x) MEM_destroy(&SCHEMA_fl,(Freelist *)x) /* the following is simply to make the resulting code easier to read */ /* otherwise, you'd see "entity->superscope" even when you KNOW */ diff --git a/include/express/scope.h b/include/express/scope.h index 90ba99563..8ad45b21b 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -134,11 +134,11 @@ struct Scope_ { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( Generic ); +extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( void * ); extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List ); extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope ); extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope ); -extern SC_EXPRESS_EXPORT Generic SCOPEfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT void * SCOPEfind( Scope, char *, int ); extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List ); extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); diff --git a/include/express/stmt.h b/include/express/stmt.h index 4aa909b9e..7382b2ce0 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -184,24 +184,24 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /******************************/ #define STMT_new() (struct Statement_ *)MEM_new(&STMT_fl) -#define STMT_destroy(x) MEM_destroy(&STMT_fl,(Freelist *)(Generic)x) +#define STMT_destroy(x) MEM_destroy(&STMT_fl,(Freelist *)x) #define ALIAS_new() (struct Alias_ *)MEM_new(&ALIAS_fl) -#define ALIAS_destroy(x) MEM_destroy(&ALIAS_fl,(Freelist *)(Generic)x) +#define ALIAS_destroy(x) MEM_destroy(&ALIAS_fl,(Freelist *)x) #define ASSIGN_new() (struct Assignment_ *)MEM_new(&ASSIGN_fl) -#define ASSIGN_destroy(x) MEM_destroy(&ASSIGN_fl,(Freelist *)(Generic)x) +#define ASSIGN_destroy(x) MEM_destroy(&ASSIGN_fl,(Freelist *)x) #define CASE_new() (struct Case_Statement_ *)MEM_new(&CASE_fl) -#define CASE_destroy(x) MEM_destroy(&CASE_fl,(Freelist *)(Generic)x) +#define CASE_destroy(x) MEM_destroy(&CASE_fl,(Freelist *)x) #define COMP_STMT_new() (struct Compound_Statement_ *)MEM_new(&COMP_STMT_fl) -#define COMP_STMT_destroy(x) MEM_destroy(&COMP_STMT_fl,(Freelist *)(Generic)x) +#define COMP_STMT_destroy(x) MEM_destroy(&COMP_STMT_fl,(Freelist *)x) #define COND_new() (struct Conditional_ *)MEM_new(&COND_fl) -#define COND_destroy(x) MEM_destroy(&COND_fl,(Freelist *)(Generic)x) +#define COND_destroy(x) MEM_destroy(&COND_fl,(Freelist *)x) #define LOOP_new() (struct Loop_ *)MEM_new(&LOOP_fl) -#define LOOP_destroy(x) MEM_destroy(&LOOP_fl,(Freelist *)(Generic)x) +#define LOOP_destroy(x) MEM_destroy(&LOOP_fl,(Freelist *)x) #define PCALL_new() (struct Procedure_Call_ *)MEM_new(&PCALL_fl) -#define PCALL_destroy(x) MEM_destroy(&PCALL_fl,(Freelist *)(Generic)x) +#define PCALL_destroy(x) MEM_destroy(&PCALL_fl,(Freelist *)x) #define RET_new() (struct Return_Statement_ *)MEM_new(&RET_fl) -#define RET_destroy(x) MEM_destroy(&RET_fl,(Freelist *)(Generic)x) +#define RET_destroy(x) MEM_destroy(&RET_fl,(Freelist *)x) #define INCR_new() (struct Increment_ *)MEM_new(&INCR_fl) #define INCR_destroy(x) MEM_destroy(&INCR_fl,(Freelist *)(char *)x) diff --git a/include/express/symbol.h b/include/express/symbol.h index e61e38ac0..eb4a0235d 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -79,7 +79,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /******************************/ #define SYMBOL_new() (struct Symbol_ *)MEM_new(&SYMBOL_fl) -#define SYMBOL_destroy(x) MEM_destroy(&SYMBOL_fl,(Freelist *)(Generic)x) +#define SYMBOL_destroy(x) MEM_destroy(&SYMBOL_fl,(Freelist *)x) #define SYMBOLset(obj) obj->symbol.line = yylineno; \ obj->symbol.filename = current_filename diff --git a/include/express/type.h b/include/express/type.h index 2ffc1652b..4ac2f4089 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -224,9 +224,9 @@ extern SC_EXPRESS_EXPORT Error ERROR_corrupted_type; /******************************/ #define TYPEHEAD_new() (struct TypeHead_ *)MEM_new(&TYPEHEAD_fl) -#define TYPEHEAD_destroy(x) MEM_destroy(&TYPEHEAD_fl,(Freelist *)(Generic)x) +#define TYPEHEAD_destroy(x) MEM_destroy(&TYPEHEAD_fl,(Freelist *)x) #define TYPEBODY_new() (struct TypeBody_ *)MEM_new(&TYPEBODY_fl) -#define TYPEBODY_destroy(x) MEM_destroy(&TYPEBODY_fl,(Freelist *)(Generic)x) +#define TYPEBODY_destroy(x) MEM_destroy(&TYPEBODY_fl,(Freelist *)x) #define TYPEis(t) ((t)->u.type->body->type) #define TYPEis_identifier(t) ((t)->u.type->body->type == identifier_) diff --git a/include/express/variable.h b/include/express/variable.h index f49693222..aa31eda2d 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -106,7 +106,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /******************************/ #define VAR_new() (struct Variable_ *)MEM_new(&VAR_fl) -#define VAR_destroy(x) MEM_destroy(&VAR_fl,(Freelist *)(Generic)x) +#define VAR_destroy(x) MEM_destroy(&VAR_fl,(Freelist *)x) #define VARget_name(v) ((v)->name) #define VARput_name(v,n) ((v)->name = (n)) diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 4f5a8561e..0f1494ded 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -135,10 +135,9 @@ void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * t wlist = ( Linked_List )DICTlookup( dict, r->schema->symbol.name ); if( !wlist ) { wlist = LISTcreate(); - DICTdefine( dict, r->schema->symbol.name, ( Generic ) wlist, - ( Symbol * )0, OBJ_UNKNOWN ); + DICTdefine( dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN ); } - LISTadd_last( wlist, ( Generic ) r ); + LISTadd_last( wlist, r ); } /* step 2: for each list, print out the renames */ diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index d9d4aaf36..10a6af92c 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -1007,7 +1007,7 @@ static void collectAttributes( Linked_List curList, const Entity curEntity, enum } /* prepend this entity's attributes to the result list */ LISTdo( ENTITYget_attributes( curEntity ), attr, Variable ) { - LISTadd_first( curList, ( Generic ) attr ); + LISTadd_first( curList, attr ); } LISTod; } @@ -1070,7 +1070,7 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) LISTdo( required, attr, Variable ) { if( !listContainsVar( existing, attr ) && !listContainsVar( remaining, attr ) ) { - LISTadd_first( remaining, ( Generic ) attr ); + LISTadd_first( remaining, attr ); } } LISTod; diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index c30b37583..4e24a8d24 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -340,7 +340,7 @@ Entity ENTITYget_superclass( Entity entity ) { void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo( ENTITYget_attributes( entity ), attr, Generic ) + LISTdo( ENTITYget_attributes( entity ), attr, void * ) LISTadd_last( result, attr ); LISTod; supers = ENTITYget_supertypes( entity ); diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index c8732c53c..517fa8a89 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -722,7 +722,7 @@ void print_file( Express express ) { print_file_header( &files ); if( separate_schemas ) { - print_schemas_separate( express, ( void * )&col, &files ); + print_schemas_separate( express, &col, &files ); } else { print_schemas_combined( express, col, &files ); } diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 37ee99e73..b4fd3e60d 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -67,7 +67,7 @@ const char * TYPEget_utype( Type t ) { /** determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. */ -Generic LISTmember( const Linked_List list, Generic e ) { +void *LISTmember( const Linked_List list, void *e ) { Link node; for( node = list->mark->next; node != list->mark; node = node->next ) if( e == node -> data ) { @@ -156,7 +156,7 @@ Linked_List SELgetnew_dmlist( const Type type ) { /* if t\'s underlying type is not already in newlist, */ if( ! utype_member( newlist, t, 0 ) ) { - LISTadd_last( newlist, ( Generic ) t ); + LISTadd_last( newlist, t ); } LISTod; @@ -304,9 +304,9 @@ int find_duplicate_list( const Type type, Linked_List * duplicate_list ) { if( !utype_member( *duplicate_list, u, 1 ) ) { /** if not already a duplicate **/ if( utype_member( temp, u, 1 ) ) { - LISTadd_first( *duplicate_list, ( Generic ) u ); + LISTadd_first( *duplicate_list, u ); } else { - LISTadd_first( temp, ( Generic ) u ); + LISTadd_first( temp, u ); } } LISTod; @@ -480,7 +480,7 @@ Linked_List SEL_TYPEgetnew_attribute_list( const Type type ) { attrs = ENTITYget_all_attributes( cur ); LISTdo_n( attrs, a, Variable, b ) { if( ! ATTR_LISTmember( newlist, a ) ) { - LISTadd_first( newlist, ( Generic ) a ); + LISTadd_first( newlist, a ); } } LISTod } @@ -889,8 +889,8 @@ Linked_List ENTITYget_expanded_entities( Entity e, Linked_List l ) { Linked_List supers; Entity super; - if( ! LISTmember( l, ( Generic ) e ) ) { - LISTadd_first( l, ( Generic ) e ); + if( ! LISTmember( l, e ) ) { + LISTadd_first( l, e ); } if( multiple_inheritance ) { @@ -939,7 +939,7 @@ static int memberOfEntPrimary( Entity ent, Variable uattr ) { int result; ENTITYget_first_attribs( ent, attrlist ); - result = ( LISTmember( attrlist, ( Generic ) uattr ) != 0 ); + result = ( LISTmember( attrlist, uattr ) != 0 ); LIST_destroy( attrlist ); return result; } diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 3fdf76218..a425f0d88 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -466,7 +466,7 @@ Entity ENTITYget_superclass( Entity entity ) { void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo( ENTITYget_attributes( entity ), attr, Generic ) + LISTdo( ENTITYget_attributes( entity ), attr, void * ) LISTadd_last( result, attr ); LISTod; supers = ENTITYget_supertypes( entity ); diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index 3579849e5..b44abab95 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -81,8 +81,8 @@ LISTmember determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. *******************/ -Generic -LISTmember( const Linked_List list, Generic e ) { +void * +LISTmember( const Linked_List list, void *e ) { Link node; for( node = list->mark->next; node != list->mark; node = node->next ) if( e == node -> data ) { diff --git a/src/exppp/pretty_ref.c b/src/exppp/pretty_ref.c index cbb65c3ff..3d73efd77 100644 --- a/src/exppp/pretty_ref.c +++ b/src/exppp/pretty_ref.c @@ -33,10 +33,9 @@ void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ) { nameList = ( Linked_List )DICTlookup( dict, ren->schema->symbol.name ); if( !nameList ) { nameList = LISTcreate(); - DICTdefine( dict, ren->schema->symbol.name, ( Generic ) nameList, - ( Symbol * )0, OBJ_UNKNOWN ); + DICTdefine( dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN ); } - LISTadd_last( nameList, ( Generic ) ren ); + LISTadd_last( nameList, ren ); } /* step 2: for each list, print out the renames */ diff --git a/src/exppp/pretty_scope.c b/src/exppp/pretty_scope.c index 1fccdc73f..85fe041d1 100644 --- a/src/exppp/pretty_scope.c +++ b/src/exppp/pretty_scope.c @@ -24,7 +24,7 @@ void SCOPEadd_inorder( Linked_List list, Scope s ) { break; } LISTod - LISTadd_before( list, k, ( Generic )s ); + LISTadd_before( list, k, s ); } /** like SCOPEadd_inorder, but for Variables */ @@ -37,7 +37,7 @@ void SCOPEaddvars_inorder( Linked_List list, Variable v ) { break; } LISTod - LISTadd_before( list, k, ( Generic )v ); + LISTadd_before( list, k, v ); } @@ -244,11 +244,11 @@ void SCOPEconsts_out( Scope s, int level ) { void SCOPElocals_order( Linked_List list, Variable v ) { LISTdo_links( list, link ) { if( v->offset < ( (Variable) link->data )->offset ) { - LISTadd_before( list, link, (Generic) v ); + LISTadd_before( list, link, v ); return; } } LISTod - LISTadd_last( list, (Generic) v ); + LISTadd_last( list, v ); } void SCOPElocals_out( Scope s, int level ) { @@ -290,7 +290,7 @@ void SCOPElocals_out( Scope s, int level ) { } if( !orderedLocals ) { orderedLocals = LISTcreate(); - LISTadd_first( orderedLocals, (Generic) v ); + LISTadd_first( orderedLocals, v ); } else { /* sort by v->offset */ SCOPElocals_order( orderedLocals, v ); diff --git a/src/express/alg.c b/src/express/alg.c index 4d010f509..671c6dce4 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -73,7 +73,7 @@ Scope ALGcreate( char type ) { ** Description: Initialize the Algorithm module. */ -Symbol * WHERE_get_symbol( Generic w ) { +Symbol * WHERE_get_symbol( void *w ) { return( ( ( Where )w )->label ); } diff --git a/src/express/dict.c b/src/express/dict.c index 320a03cf4..fea38d463 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -75,7 +75,7 @@ void DICTcleanup( void ) { * error directly if there is a duplicate value. * \return 0 on success, 1 on failure */ -int DICTdefine( Dictionary dict, char * name, Generic obj, Symbol * sym, char type ) { +int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ new, *old; new.key = name; @@ -123,7 +123,7 @@ int DICTdefine( Dictionary dict, char * name, Generic obj, Symbol * sym, char ty * their unusual behavior with respect to scoping and visibility rules * \sa DICTdefine() */ -int DICT_define( Dictionary dict, char * name, Generic obj, Symbol * sym, char type ) { +int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ e, *e2; e.key = name; @@ -163,7 +163,7 @@ void DICTundefine( Dictionary dict, char * name ) { ** \param name name to look up ** \return the value found, NULL if not found */ -Generic DICTlookup( Dictionary dictionary, char * name ) { +void *DICTlookup( Dictionary dictionary, char * name ) { struct Element_ e, *ep; if( !dictionary ) { @@ -182,7 +182,7 @@ Generic DICTlookup( Dictionary dictionary, char * name ) { /** like DICTlookup but returns symbol, too * \sa DICTlookup() */ -Generic DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { +void *DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { struct Element_ e, *ep; if( !dictionary ) { @@ -199,7 +199,7 @@ Generic DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { return( NULL ); } -Generic DICTdo( DictionaryEntry * dict_entry ) { +void *DICTdo( DictionaryEntry * dict_entry ) { if( 0 == HASHlist( dict_entry ) ) { return 0; } diff --git a/src/express/entity.c b/src/express/entity.c index e298cfe8d..efde2a182 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -336,14 +336,14 @@ void ENTITYadd_attribute( Entity entity, Variable attr ) { if( attr->name->type->u.type->body->type != op_ ) { /* simple id */ rc = DICTdefine( entity->symbol_table, attr->name->symbol.name, - ( Generic )attr, &attr->name->symbol, OBJ_VARIABLE ); + attr, &attr->name->symbol, OBJ_VARIABLE ); } else { /* SELF\ENTITY.SIMPLE_ID */ rc = DICTdefine( entity->symbol_table, attr->name->e.op2->symbol.name, - ( Generic )attr, &attr->name->symbol, OBJ_VARIABLE ); + attr, &attr->name->symbol, OBJ_VARIABLE ); } if( rc == 0 ) { - LISTadd_last( entity->u.entity->attributes, ( Generic )attr ); + LISTadd_last( entity->u.entity->attributes, attr ); VARput_offset( attr, entity->u.entity->attribute_count ); entity->u.entity->attribute_count++; } @@ -354,7 +354,7 @@ void ENTITYadd_attribute( Entity entity, Variable attr ) { ** \param instance new instance ** Add an item to the instance list of an entity. */ -void ENTITYadd_instance( Entity entity, Generic instance ) { +void ENTITYadd_instance( Entity entity, void *instance ) { if( entity->u.entity->instances == LIST_NULL ) { entity->u.entity->instances = LISTcreate(); } @@ -401,7 +401,7 @@ static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) { ENTITY_get_all_attributes( super, result ); LISTod; /* Gee, aren't they resolved by this time? */ - LISTdo( entity->u.entity->attributes, attr, Generic ) + LISTdo( entity->u.entity->attributes, attr, void * ) LISTadd_last( result, attr ); LISTod; } diff --git a/src/express/error.c b/src/express/error.c index ee78137ca..ebc171f62 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -200,7 +200,7 @@ void ERRORcreate_warning( char * name, Error error ) { /* first check if we know about this type of error */ LISTdo( ERRORwarnings, opt, Error_Warning ) { if( !strcmp( name, opt->name ) ) { - LISTadd_last( opt->errors, ( Generic )error ); + LISTadd_last( opt->errors, error ); return; } } LISTod @@ -209,8 +209,8 @@ void ERRORcreate_warning( char * name, Error error ) { o = ERROR_OPT_new(); o->name = name; o->errors = LISTcreate(); - LISTadd_last( o->errors, ( Generic )error ); - LISTadd_last( ERRORwarnings, ( Generic )o ); + LISTadd_last( o->errors, error ); + LISTadd_last( ERRORwarnings, o ); } void ERRORset_warning( char * name, int set ) { diff --git a/src/express/expr.c b/src/express/expr.c index aaf972f13..738da37ed 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -146,7 +146,7 @@ Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { return e; } -Symbol * EXP_get_symbol( Generic e ) { +Symbol * EXP_get_symbol( void *e ) { return( &( ( Expression )e )->symbol ); } @@ -297,9 +297,9 @@ static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e * sure of the circumstances in which this is beneficial. */ *where = w; - LISTadd_last( subt, (Generic) w ); + LISTadd_last( subt, w ); } else { - LISTadd_last( supert, (Generic) t ); + LISTadd_last( supert, t ); } options += nr; } @@ -316,7 +316,7 @@ static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e } } LISTod if( !found ) { - LISTadd_last( uniqSubs, (Generic) s ); + LISTadd_last( uniqSubs, s ); } } LISTod if( ( LISTget_length( uniqSubs ) == 0 ) && ( LISTget_length( supert ) == 1 ) && ( options > 1 ) ) { @@ -961,7 +961,7 @@ Expression QUERYcreate( Symbol * local, Expression aggregate ) { Variable v = VARcreate( e2, Type_Attribute ); - DICTdefine( s->symbol_table, local->name, ( Generic )v, &e2->symbol, OBJ_VARIABLE ); + DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); e->u.query = QUERY_new(); e->u.query->scope = s; e->u.query->local = v; diff --git a/src/express/express.c b/src/express/express.c index 47c07e4e8..b895770fe 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -150,7 +150,7 @@ int EXPRESS_succeed( Express model ) { return 0; } -Symbol * EXPRESS_get_symbol( Generic e ) { +Symbol * EXPRESS_get_symbol( void *e ) { return( &( ( Express )e )->symbol ); } @@ -187,7 +187,7 @@ static void EXPRESS_PATHinit() { /* if no EXPRESS_PATH, search current directory anyway */ dir = ( Dir * )sc_malloc( sizeof( Dir ) ); dir->leaf = dir->full; - LISTadd_last( EXPRESS_path, ( Generic )dir ); + LISTadd_last( EXPRESS_path, dir ); } else { int done = 0; while( !done ) { @@ -224,7 +224,7 @@ static void EXPRESS_PATHinit() { /* just "" to make error messages cleaner */ if( !strcmp( ".", start ) ) { dir->leaf = dir->full; - LISTadd_last( EXPRESS_path, ( Generic )dir ); + LISTadd_last( EXPRESS_path, dir ); *( p - 1 ) = save; /* put char back where */ /* temp null was */ continue; @@ -241,7 +241,7 @@ static void EXPRESS_PATHinit() { sprintf( dir->full, "%s/", start ); dir->leaf = dir->full + length + 1; } - LISTadd_last( EXPRESS_path, ( Generic )dir ); + LISTadd_last( EXPRESS_path, dir ); *( p - 1 ) = save; /* put char back where temp null was */ } @@ -312,13 +312,13 @@ void EXPRESSinitialize( void ) { x->u.func->return_type = r; \ x->u.func->builtin = true; \ resolved_all(x); \ - DICTdefine(EXPRESSbuiltins,y,(Generic)x,0,OBJ_FUNCTION); + DICTdefine(EXPRESSbuiltins,y,x,NULL,OBJ_FUNCTION); #define procdef(x,y,c) x = ALGcreate(OBJ_PROCEDURE);\ x->symbol.name = y;\ x->u.proc->pcount = c; \ x->u.proc->builtin = true; \ resolved_all(x); \ - DICTdefine(EXPRESSbuiltins,y,(Generic)x,0,OBJ_PROCEDURE); + DICTdefine(EXPRESSbuiltins,y,x,NULL,OBJ_PROCEDURE); /* third arg is # of parameters */ /* eventually everything should be data-driven, but for now */ @@ -522,8 +522,8 @@ static void RENAMEresolve( Rename * r, Schema s ); * * Sept 2013 - remove unused param enum rename_type type (TODO should this be used)? */ -static Generic SCOPEfind_for_rename( Scope schema, char * name ) { - Generic result; +static void * SCOPEfind_for_rename( Scope schema, char * name ) { + void *result; Rename * rename; /* object can only appear in top level symbol table */ @@ -567,7 +567,7 @@ static Generic SCOPEfind_for_rename( Scope schema, char * name ) { } static void RENAMEresolve( Rename * r, Schema s ) { - Generic remote; + void *remote; /* if (is_resolved_rename_raw(r->old)) return;*/ if( r->object ) { @@ -716,9 +716,9 @@ static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_Li if( !ref_schema ) { ERRORreport_with_symbol( ERROR_undefined_schema, sym, sym->name ); resolve_failed( schema ); - list->data = 0; + list->data = NULL; } else { - list->data = ( Generic )ref_schema; + list->data = ref_schema; } LISTod } diff --git a/src/express/lexact.c b/src/express/lexact.c index 0be65803b..8fcb803e9 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -246,7 +246,7 @@ void SCANinitialize( void ) { keyword_dictionary = HASHcreate( 100 ); /* not exact */ for( k = keywords; k->key; k++ ) { - DICTdefine( keyword_dictionary, k->key, ( Generic )k, 0, OBJ_UNKNOWN ); + DICTdefine( keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN ); /* not "unknown", but certainly won't be looked up by type! */ } diff --git a/src/express/linklist.c b/src/express/linklist.c index 083b9d060..53fa4ff94 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -47,7 +47,7 @@ Linked_List LISTcreate() { Linked_List LISTcopy( Linked_List src ) { Linked_List dst = LISTcreate(); - LISTdo( src, x, Generic ) + LISTdo( src, x, void * ) LISTadd_last( dst, x ); LISTod return dst; @@ -88,7 +88,7 @@ void LISTsort( Linked_List list, int (*comp)(void*, void*)) { } void LISTswap( Link p, Link q ) { - Generic tmp; + void *tmp; if( p == LINK_NULL || q == LINK_NULL || p == q ) return; @@ -99,7 +99,7 @@ void LISTswap( Link p, Link q ) { } -Generic LISTadd_first( Linked_List list, Generic item ) { +void *LISTadd_first( Linked_List list, void *item ) { Link node; node = LINK_new(); @@ -109,7 +109,7 @@ Generic LISTadd_first( Linked_List list, Generic item ) { return item; } -Generic LISTadd_last( Linked_List list, Generic item ) { +void *LISTadd_last( Linked_List list, void *item ) { Link node; node = LINK_new(); @@ -119,7 +119,7 @@ Generic LISTadd_last( Linked_List list, Generic item ) { return item; } -Generic LISTadd_after( Linked_List list, Link link, Generic item ) { +void *LISTadd_after( Linked_List list, Link link, void *item ) { Link node; if( link == LINK_NULL ) { @@ -133,7 +133,7 @@ Generic LISTadd_after( Linked_List list, Link link, Generic item ) { return item; } -Generic LISTadd_before( Linked_List list, Link link, Generic item ) { +void *LISTadd_before( Linked_List list, Link link, void *item ) { Link node; if( link == LINK_NULL ) { @@ -151,9 +151,9 @@ Generic LISTadd_before( Linked_List list, Link link, Generic item ) { } -Generic LISTremove_first( Linked_List list ) { +void *LISTremove_first( Linked_List list ) { Link node; - Generic item; + void *item; node = list->mark->next; if( node == list->mark ) { @@ -166,9 +166,9 @@ Generic LISTremove_first( Linked_List list ) { return item; } -Generic LISTget_first( Linked_List list ) { +void *LISTget_first( Linked_List list ) { Link node; - Generic item; + void *item; node = list->mark->next; if( node == list->mark ) { @@ -178,9 +178,9 @@ Generic LISTget_first( Linked_List list ) { return item; } -Generic LISTget_second( Linked_List list ) { +void *LISTget_second( Linked_List list ) { Link node; - Generic item; + void *item; node = list->mark->next; if( node == list->mark ) { @@ -195,7 +195,7 @@ Generic LISTget_second( Linked_List list ) { } /** first is 1, not 0 */ -Generic LISTget_nth( Linked_List list, int n ) { +void *LISTget_nth( Linked_List list, int n ) { int count = 1; Link node; diff --git a/src/express/memory.c b/src/express/memory.c index 8b91d63ad..83edb15cb 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -116,8 +116,8 @@ void MEMinitialize( struct freelist_head * flh, unsigned int size, int alloc1, i #endif } -Generic MEM_new( struct freelist_head * flh ) { - Generic obj; +void * MEM_new( struct freelist_head * flh ) { + void *obj; #ifndef NOSTAT flh->alloc++; diff --git a/src/express/object.c b/src/express/object.c index f3782a5c3..6d4852046 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -27,7 +27,7 @@ struct Object * OBJ; -Symbol * UNK_get_symbol( Generic x ) { +Symbol * UNK_get_symbol( void *x ) { (void) x; /* quell unused param warning; it appears that the prototype must match other functions */ fprintf( stderr, "OBJget_symbol called on object of unknown type\n" ); ERRORabort( 0 ); @@ -51,7 +51,7 @@ void OBJcleanup() { sc_free( OBJ ); } -void OBJcreate( char type, struct Symbol_ * ( *get_symbol )( Generic ), char * printable_type, int bits ) { +void OBJcreate( char type, struct Symbol_ * ( *get_symbol ) ( void * ), char * printable_type, int bits ) { int index = ( int )type; OBJ[index].get_symbol = get_symbol; OBJ[index].type = printable_type; diff --git a/src/express/parse_data.h b/src/express/parse_data.h index 9ff1f96f4..fc7d41e0b 100644 --- a/src/express/parse_data.h +++ b/src/express/parse_data.h @@ -1,6 +1,10 @@ #ifndef PARSE_DATA #define PARSE_DATA #include "expscan.h" + +/* TODO: factor out when regenerating the parser */ +#define Generic void * + typedef struct parse_data { perplex_t scanner; } parse_data_t; diff --git a/src/express/resolve.c b/src/express/resolve.c index d5fcf9784..2d7a95ca4 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -316,7 +316,7 @@ Type TYPE_retrieve_aggregate( Type t_select, Type t_agg ) { void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { Function f = 0; Symbol * sym; - Generic x; + void *x; Entity e; Type t; bool func_args_checked = false; @@ -426,7 +426,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { /* assume it's a variable/attribute */ if( !x ) { - x = ( Generic )VARfind( scope, expr->symbol.name, 0 ); + x = VARfind( scope, expr->symbol.name, 0 ); } /* if not found as a variable, try as function, etc ... */ if( !x ) { @@ -632,7 +632,7 @@ int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, LISTod if( !found ) { - LISTadd_last( *flat, ( Generic )ent_ref ); + LISTadd_last( *flat, ent_ref ); } /* link in to expression */ @@ -653,7 +653,7 @@ int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, if( !ent_ref->u.entity->supertypes ) { ent_ref->u.entity->supertypes = LISTcreate(); } - LISTadd_last( ent_ref->u.entity->supertypes, ( Generic )ent ); + LISTadd_last( ent_ref->u.entity->supertypes, ent ); } #endif } @@ -1136,7 +1136,7 @@ void ENTITYresolve_types( Entity e ); void SCOPEresolve_types( Scope s ) { Variable var; DictionaryEntry de; - Generic x; + void *x; if( print_objects_while_running & OBJ_SCOPE_BITS & OBJget_bits( s->type ) ) { @@ -1200,7 +1200,7 @@ void SCOPEresolve_types( Scope s ) { void SCOPEresolve_subsupers( Scope scope ) { DictionaryEntry de; - Generic x; + void *x; char type; Symbol * sym; Type t; @@ -1270,7 +1270,7 @@ static void ENTITYresolve_supertypes( Entity e ) { } else { bool found = false; - LISTadd_last( e->u.entity->supertypes, ( Generic )ref_entity ); + LISTadd_last( e->u.entity->supertypes, ref_entity ); if( is_resolve_failed( ref_entity ) ) { resolve_failed( e ); } @@ -1290,7 +1290,7 @@ static void ENTITYresolve_supertypes( Entity e ) { if( !ref_entity->u.entity->subtypes ) { ref_entity->u.entity->subtypes = LISTcreate(); } - LISTadd_last( ref_entity->u.entity->subtypes, ( Generic )e ); + LISTadd_last( ref_entity->u.entity->subtypes, e ); } } } LISTod; @@ -1429,7 +1429,7 @@ static void TYPEresolve_expressions( Type t, Scope s ) { void SCOPEresolve_expressions_statements( Scope s ) { DictionaryEntry de; - Generic x; + void *x; Variable v; if( print_objects_while_running & OBJ_SCOPE_BITS & diff --git a/src/express/schema.c b/src/express/schema.c index 4207d262c..6f6a0d521 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -57,8 +57,8 @@ struct freelist_head SCHEMA_fl; int __SCOPE_search_id = 0; -Symbol * RENAME_get_symbol( Generic r ) { - return( ( ( Rename * )r )->old ); +Symbol * RENAME_get_symbol( void *r ) { + return ( ( Rename * )r )->old; } /** Initialize the Schema module. */ @@ -143,7 +143,7 @@ void SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, if( !cur_schema->u.schema->reflist ) { cur_schema->u.schema->reflist = LISTcreate(); } - LISTadd_last( cur_schema->u.schema->reflist, ( Generic )r ); + LISTadd_last( cur_schema->u.schema->reflist, r ); } void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { @@ -156,7 +156,7 @@ void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol if( !cur_schema->u.schema->uselist ) { cur_schema->u.schema->uselist = LISTcreate(); } - LISTadd_last( cur_schema->u.schema->uselist, ( Generic )r ); + LISTadd_last( cur_schema->u.schema->uselist, r ); } void SCHEMAdefine_reference( Schema schema, Rename * r ) { @@ -170,7 +170,7 @@ void SCHEMAdefine_reference( Schema schema, Rename * r ) { } if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { DICTdefine( schema->u.schema->refdict, name, - ( Generic )r, r->old, OBJ_RENAME ); + r, r->old, OBJ_RENAME ); } } @@ -185,7 +185,7 @@ void SCHEMAdefine_use( Schema schema, Rename * r ) { } if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { DICTdefine( schema->u.schema->usedict, name, - ( Generic )r, r->old, OBJ_RENAME ); + r, r->old, OBJ_RENAME ); } } diff --git a/src/express/scope.c b/src/express/scope.c index 52f5d7822..9fb53d0c9 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -44,7 +44,7 @@ #include "express/scope.h" #include "express/resolve.h" -Symbol * SCOPE_get_symbol( Generic s ) { +Symbol * SCOPE_get_symbol( void *s ) { return( &( ( Scope )s )->symbol ); } @@ -58,7 +58,7 @@ void SCOPEinitialize( void ) { */ void SCOPE_get_entities( Scope scope, Linked_List result ) { DictionaryEntry de; - Generic x; + void *x; DICTdo_type_init( scope->symbol_table, &de, OBJ_ENTITY ); while( 0 != ( x = DICTdo( &de ) ) ) { @@ -71,7 +71,7 @@ void SCOPE_get_entities( Scope scope, Linked_List result ) { */ void SCOPE_get_functions( Scope scope, Linked_List result ) { DictionaryEntry de; - Generic x; + void *x; DICTdo_type_init( scope->symbol_table, &de, OBJ_FUNCTION ); while( 0 != ( x = DICTdo( &de ) ) ) { @@ -92,7 +92,7 @@ Linked_List SCOPEget_functions( Scope scope ) { */ void SCOPE_get_rules( Scope scope, Linked_List result ) { DictionaryEntry de; - Generic x; + void *x; DICTdo_type_init( scope->symbol_table, &de, OBJ_RULE ); while( 0 != ( x = DICTdo( &de ) ) ) { @@ -140,7 +140,7 @@ void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { SCOPE_dfs( symbols, ent, result ); } LISTod - LISTadd_last( result, ( Generic )root ); + LISTadd_last( result, root ); } } @@ -170,10 +170,10 @@ Linked_List SCOPEget_entities_superclass_order( Scope scope ) { * note that object found is not actually checked, only because * caller is in a better position to describe the error with context */ -Generic SCOPEfind( Scope scope, char * name, int type ) { - extern Generic SCOPE_find( Scope , char *, int ); +void *SCOPEfind( Scope scope, char * name, int type ) { + extern void *SCOPE_find( Scope , char *, int ); extern Dictionary EXPRESSbuiltins; /* procedures/functions */ - Generic x; + void *x; __SCOPE_search_id++; @@ -194,8 +194,8 @@ Generic SCOPEfind( Scope scope, char * name, int type ) { * the supertype/subtype hierarchy * EH??? -> lookup an object when the current scope is not a schema */ -Generic SCOPE_find( Scope scope, char * name, int type ) { - Generic result; +void *SCOPE_find( Scope scope, char * name, int type ) { + void *result; Rename * rename; if( scope->search_id == __SCOPE_search_id ) { diff --git a/src/express/stmt.c b/src/express/stmt.c index d125cd12f..77e7ef2d7 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -205,7 +205,7 @@ Scope INCR_CTLcreate( Symbol * control, Expression start, Expression e = EXPcreate_from_symbol( Type_Attribute, control ); Variable v = VARcreate( e, Type_Number ); DICTdefine( s->symbol_table, control->name, - ( Generic )v, control, OBJ_VARIABLE ); + v, control, OBJ_VARIABLE ); s->u.incr = INCR_new(); s->u.incr->init = start; s->u.incr->end = end; diff --git a/src/express/type.c b/src/express/type.c index b7a7de599..235bead9b 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -174,7 +174,7 @@ Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { t->u.type = th; t->symbol = *symbol; - DICTdefine( scope->symbol_table, symbol->name, ( Generic )t, &t->symbol, objtype ); + DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); return t; } @@ -309,8 +309,8 @@ return( false ); } #endif -Symbol * TYPE_get_symbol( Generic t ) { - return( &( ( Type )t )->symbol ); +Symbol * TYPE_get_symbol( void *t ) { + return &( ( Type )t )->symbol; } diff --git a/src/express/variable.c b/src/express/variable.c index c6f982509..bb1c7fec3 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -91,7 +91,7 @@ char * opcode_print( Op_Code o ); struct freelist_head VAR_fl; -Symbol * VAR_get_symbol( Generic v ) { +Symbol * VAR_get_symbol( void *v ) { return( &( ( Variable )v )->name->symbol ); } From e9c28ff7cbadc537d5bafe569b715959370f3147 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:32:10 +0100 Subject: [PATCH 024/244] drop static_inline macro --- include/express/basic.h | 17 +++-------------- include/express/error.h | 11 ++++++----- include/express/lexact.h | 4 ++++ src/express/expr.c | 2 +- src/express/hash.c | 4 ++-- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/express/basic.h b/include/express/basic.h index 353117a1e..0e47d37b0 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -85,6 +85,9 @@ # include #endif +#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__cplusplus) +#define inline __inline +#endif /**************************/ /* function pointer types */ @@ -93,20 +96,6 @@ typedef void ( *voidFuncptr )(); typedef int ( *intFuncptr )(); -/******************************/ -/* deal with inline functions */ -/******************************/ - -#if !defined(static_inline) -#if (!defined(__GNUC__) && !defined(__MSVC__)) || defined(__STRICT_ANSI) -#define static_inline -#undef supports_inline_functions -#else -#define static_inline static __inline -#define supports_inline_functions 1L -#endif /* */ -#endif /* !defined(static_inline) */ - /* allow same declarations to suffice for both Standard and Classic C */ /* ... at least in header files ... */ diff --git a/include/express/error.h b/include/express/error.h index f49ec9708..689840b18 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -126,23 +126,23 @@ extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); /* Inline functions */ /********************/ -static_inline void ERRORdisable( Error error ) { +static inline void ERRORdisable( Error error ) { if( error != ERROR_none ) { error->enabled = false; } } -static_inline void ERRORenable( Error error ) { +static inline void ERRORenable( Error error ) { if( error != ERROR_none ) { error->enabled = true; } } -static_inline bool ERRORis_enabled( Error error ) { +static inline bool ERRORis_enabled( Error error ) { return error->enabled; } -static_inline void ERRORbuffer_messages( bool flag ) { +static inline void ERRORbuffer_messages( bool flag ) { #if !defined(__MSVC__) && !defined(__BORLAND__) extern void ERROR_start_message_buffer( void ), ERROR_flush_message_buffer( void ); @@ -155,7 +155,7 @@ static_inline void ERRORbuffer_messages( bool flag ) { } } -static_inline void ERRORflush_messages( void ) { +static inline void ERRORflush_messages( void ) { #if !defined(__MSVC__) && !defined(__BORLAND__) extern void ERROR_start_message_buffer( void ), ERROR_flush_message_buffer( void ); @@ -167,6 +167,7 @@ static_inline void ERRORflush_messages( void ) { } } + /***********************/ /* function prototypes */ /***********************/ diff --git a/include/express/lexact.h b/include/express/lexact.h index aa71342fa..1b443f62c 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -95,6 +95,10 @@ extern SC_EXPRESS_EXPORT Error ERROR_nonascii_char; # define SCANtext_ready (*SCANcurrent != '\0') #endif +#ifndef static_inline +# define static_inline static inline +#endif + /***********************/ /* function prototypes */ /***********************/ diff --git a/src/express/expr.c b/src/express/expr.c index 738da37ed..58fe1b157 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -106,7 +106,7 @@ static Error ERROR_enum_no_such_item; static Error ERROR_group_ref_no_such_entity; static Error ERROR_group_ref_unexpected_type; -static_inline int OPget_number_of_operands( Op_Code op ) { +static inline int OPget_number_of_operands( Op_Code op ) { if( ( op == OP_NEGATE ) || ( op == OP_NOT ) ) { return 1; } else if( op == OP_SUBCOMPONENT ) { diff --git a/src/express/hash.c b/src/express/hash.c index 48c968a7d..fc3e4d9bf 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -118,7 +118,7 @@ struct freelist_head HASH_Element_fl; ** Internal routines */ -static_inline Address HASHhash( char *, Hash_Table ); +static inline Address HASHhash( char *, Hash_Table ); static void HASHexpand_table( Hash_Table ); /* @@ -409,7 +409,7 @@ HASHsearch( Hash_Table table, Element item, Action action ) { ** Internal routines */ -static_inline Address HASHhash( char * Key, Hash_Table table ) { +static inline Address HASHhash( char * Key, Hash_Table table ) { Address h, address; register unsigned char * k = ( unsigned char * )Key; From e1162b63c4297d8243569b35ae005f4c9c46a5ee Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:37:40 +0100 Subject: [PATCH 025/244] drop (unused) CONST macro --- include/express/basic.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/include/express/basic.h b/include/express/basic.h index 0e47d37b0..2dffecf3c 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -96,17 +96,5 @@ typedef void ( *voidFuncptr )(); typedef int ( *intFuncptr )(); -/* allow same declarations to suffice for both Standard and Classic C */ -/* ... at least in header files ... */ - -#ifndef CONST -# ifdef __STDC__ -# define CONST const -# else -# define CONST -# endif -#endif - -#endif /* */ - +#endif /* BASIC_H */ From bab3886f5441d72881837d7597eac3b9e46730d4 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:39:13 +0100 Subject: [PATCH 026/244] drop THROW_ macros --- src/base/sc_memmgr.h | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/base/sc_memmgr.h b/src/base/sc_memmgr.h index e9ecddcb2..9517a20bc 100644 --- a/src/base/sc_memmgr.h +++ b/src/base/sc_memmgr.h @@ -6,17 +6,6 @@ #if defined(SC_MEMMGR_ENABLE_CHECKS) -/** - Platform specific defines -*/ -#if defined(__MSVC__) || defined(__BORLAND__) -#define THROW_STD_BAD_ALLOC -#define THROW_EMPTY -#else -#define THROW_STD_BAD_ALLOC throw (std::bad_alloc) -#define THROW_EMPTY throw () -#endif - #ifdef __cplusplus #include extern "C" { @@ -50,27 +39,27 @@ SC_BASE_EXPORT void sc_operator_delete( void * addr ); #include -inline void * operator new( size_t size, const char * file, const int line ) THROW_STD_BAD_ALLOC { +inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) { return sc_operator_new( size, file, line ); } -inline void * operator new[]( size_t size, const char * file, const int line ) THROW_STD_BAD_ALLOC { +inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) { return sc_operator_new( size, file, line ); } -inline void operator delete( void * addr, const char * file, const int line ) THROW_STD_BAD_ALLOC { +inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) { sc_operator_delete( addr, file, line ); } -inline void operator delete[]( void * addr, const char * file, const int line ) THROW_STD_BAD_ALLOC { +inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) { sc_operator_delete( addr, file, line ); } -inline void operator delete( void * addr ) THROW_EMPTY { +inline void operator delete( void * addr ) throw () { sc_operator_delete( addr ); } -inline void operator delete[]( void * addr ) THROW_EMPTY { +inline void operator delete[]( void * addr ) throw () { sc_operator_delete( addr ); } From ce88e635f0b36e7f12d93a5a455753bb5a3f5f11 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:45:56 +0100 Subject: [PATCH 027/244] cleanup error.h, migrate error.c to use stdarg.h --- include/express/error.h | 16 --------- src/exp2python/src/classes_python.c | 6 ---- src/express/error.c | 50 +++-------------------------- 3 files changed, 4 insertions(+), 68 deletions(-) diff --git a/include/express/error.h b/include/express/error.h index 689840b18..bf4effc3e 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -117,10 +117,8 @@ extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /* function prototypes */ /***********************/ -#if defined(__MSVC__) || defined(__BORLAND__) extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); -#endif /********************/ /* Inline functions */ @@ -143,10 +141,6 @@ static inline bool ERRORis_enabled( Error error ) { } static inline void ERRORbuffer_messages( bool flag ) { -#if !defined(__MSVC__) && !defined(__BORLAND__) - extern void ERROR_start_message_buffer( void ), - ERROR_flush_message_buffer( void ); -#endif __ERROR_buffer_errors = flag; if( __ERROR_buffer_errors ) { ERROR_start_message_buffer(); @@ -156,11 +150,6 @@ static inline void ERRORbuffer_messages( bool flag ) { } static inline void ERRORflush_messages( void ) { -#if !defined(__MSVC__) && !defined(__BORLAND__) - extern void ERROR_start_message_buffer( void ), - ERROR_flush_message_buffer( void ); -#endif - if( __ERROR_buffer_errors ) { ERROR_flush_message_buffer(); ERROR_start_message_buffer(); @@ -185,11 +174,6 @@ struct Symbol_; /* mention Symbol to avoid warning on following line */ extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( Error, struct Symbol_ *, ... ); extern SC_EXPRESS_EXPORT void ERRORreport_with_line( Error, int, ... ); -#if !defined(__MSVC__) && !defined(__BORLAND__) -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); -#endif - extern SC_EXPRESS_EXPORT void ERRORcreate_warning( char *, Error ); extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, int ); extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( int ); diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index e53dadbe8..8c672868a 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -27,12 +27,6 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #include #include -#ifdef __STDC__ -#include -#else -#include -#endif - #include "sc_memmgr.h" #include "classes.h" #include "expr.h" diff --git a/src/express/error.c b/src/express/error.c index ebc171f62..2ad356f8e 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -51,18 +51,16 @@ * prettied up interface to print_objects_when_running */ -#include +#include "sc_cf.h" + +#include #include #include #include #include - -#ifdef __STDC__ #include -#else -#include -#endif +#include "sc_memmgr.h" #include "express/error.h" #include "express/info.h" #include "express/linklist.h" @@ -278,22 +276,10 @@ void ERRORset_all_warnings( int set ) { } void -#ifdef __STDC__ ERRORreport( Error what, ... ) { -#else -ERRORreport( va_alist ) -va_dcl { - Error what; -#endif /* extern void abort(void);*/ va_list args; - -#ifdef __STDC__ va_start( args, what ); -#else - va_start( args ); - what = va_arg( args, Error ); -#endif if( ( what != ERROR_none ) && ( what != ERROR_subordinate_failed ) && @@ -331,27 +317,13 @@ va_dcl { ** format fields of the message generated by 'what.' */ void -#ifdef __STDC__ ERRORreport_with_line( Error what, int line, ... ) { -#else -ERRORreport_with_line( va_alist ) -va_dcl { - Error what; - int line; -#endif - char buf[BUFSIZ]; char * savemsg; /* save what->message here while we fool */ /* ERRORreport_with_line */ Symbol sym; va_list args; -#ifdef __STDC__ va_start( args, line ); -#else - va_start( args ); - what = va_arg( args, Error ); - line = va_arg( args, int ); -#endif sym.filename = current_filename; sym.line = line; @@ -367,24 +339,10 @@ va_dcl { } void -#ifdef __STDC__ ERRORreport_with_symbol( Error what, Symbol * sym, ... ) { -#else -ERRORreport_with_symbol( va_alist ) -va_dcl { - Error what; - Symbol * sym; -#endif /* extern void abort(void);*/ va_list args; - -#ifdef __STDC__ va_start( args, sym ); -#else - va_start( args ); - what = va_arg( args, Error ); - sym = va_arg( args, Symbol * ); -#endif if( ( what != ERROR_none ) && ( what != ERROR_subordinate_failed ) && what->enabled ) { if( __ERROR_buffer_errors ) { From ac9fc039865498b0e40c852ba578911d536a2187 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 16:50:54 +0100 Subject: [PATCH 028/244] drop support for BORLAND compiler --- include/sc_stdbool.h | 10 ---------- src/cllazyfile/current_function.hpp | 4 ---- src/exp2cxx/classes_type.c | 2 -- 3 files changed, 16 deletions(-) diff --git a/include/sc_stdbool.h b/include/sc_stdbool.h index 5d126dffc..0591fa536 100644 --- a/include/sc_stdbool.h +++ b/include/sc_stdbool.h @@ -14,21 +14,11 @@ * for various compiler versions and defines things that are missing in * those versions. * - * The GNU and Watcom compilers include a stdbool.h, but the Borland - * C/C++ 5.5.1 compiler and the Microsoft compilers do not. - * * See http://predef.sourceforge.net/precomp.html for compile macros. */ #ifndef __cplusplus -/** - * Borland C++ 5.5.1 does not define _Bool. - */ -#if defined(__BORLANDC__) && __BORLANDC__ < 0x630 -typedef int _Bool; -#endif - /** * Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005, * and version 15.00.30729.01, which comes with Visual C++ 2008, do not diff --git a/src/cllazyfile/current_function.hpp b/src/cllazyfile/current_function.hpp index 691cf6964..2a0244d2f 100644 --- a/src/cllazyfile/current_function.hpp +++ b/src/cllazyfile/current_function.hpp @@ -36,10 +36,6 @@ # define SC_CURRENT_FUNCTION __FUNCTION__ -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) - -# define SC_CURRENT_FUNCTION __FUNC__ - #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) # define SC_CURRENT_FUNCTION __func__ diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 2f59dd8fa..62d737aba 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -492,10 +492,8 @@ void TYPEprint_typedefs( Type t, FILE * classes ) { } /* Print the extern statement: */ -#if !defined(__BORLAND__) strncpy( nm, TYPEtd_name( t ), BUFSIZ ); fprintf( classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName( t ), nm ); -#endif } /** ** From 85b76db65af9436085653ee95593ccedb005e4ab Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 17:23:23 +0100 Subject: [PATCH 029/244] use _WIN32 for Windows and _MSC_VER for compiler checks --- cmake/schema_scanner/schemaScanner.cc | 2 +- include/sc_cf_cmake.h.in | 3 ++- src/base/path2str.h | 4 ++-- src/base/sc_benchmark.cc | 4 ++-- src/cleditor/STEPfile.inline.cc | 2 +- src/cllazyfile/current_function.hpp | 10 +++------- src/cllazyfile/lazyTypes.h | 10 ++++++++++ src/clutils/dirobj.cc | 15 ++++++++------- src/exppp/pretty_schema.c | 2 +- test/cpp/schema_specific/stepfile_rw_progress.cc | 2 +- 10 files changed, 31 insertions(+), 23 deletions(-) diff --git a/cmake/schema_scanner/schemaScanner.cc b/cmake/schema_scanner/schemaScanner.cc index 8b3647f60..88bd110ae 100644 --- a/cmake/schema_scanner/schemaScanner.cc +++ b/cmake/schema_scanner/schemaScanner.cc @@ -22,7 +22,7 @@ extern "C" { # include -# if defined( _WIN32 ) || defined ( __WIN32__ ) +# ifdef _WIN32 # include # define getcwd _getcwd # else diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf_cmake.h.in index 3d744d15d..6caec92aa 100644 --- a/include/sc_cf_cmake.h.in +++ b/include/sc_cf_cmake.h.in @@ -3,7 +3,7 @@ /**** Define statements for CMake ****/ #cmakedefine HAVE_NDIR_H 1 -#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_SYS_STAT_H 1 #cmakedefine HAVE_SYS_PARAM_H 1 #cmakedefine HAVE_SYSENT_H 1 @@ -20,6 +20,7 @@ #cmakedefine HAVE_MEMCPY 1 #cmakedefine HAVE_MEMMOVE 1 #cmakedefine HAVE_GETOPT 1 +#cmakedefine HAVE_VSNPRINTF 1 #cmakedefine HAVE_SSIZE_T 1 diff --git a/src/base/path2str.h b/src/base/path2str.h index 05c2f7b91..84155cd9f 100644 --- a/src/base/path2str.h +++ b/src/base/path2str.h @@ -11,10 +11,10 @@ */ SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro ); -#if defined( _WIN32 ) || defined ( __WIN32__ ) +#ifdef _WIN32 # define path2str(path) path2str_fn(path) #else # define path2str(path) path -#endif /* defined( _WIN32 ) || defined ( __WIN32__ ) */ +#endif #endif /* PATH2STR_H */ diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index cbf8ce98b..44f085f2f 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -3,7 +3,7 @@ #include "sc_benchmark.h" #include "sc_memmgr.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include #include #else @@ -49,7 +49,7 @@ benchVals getMemAndTime( ) { vals.sysMilliseconds = ( stime * 1000 ) / sysconf( _SC_CLK_TCK ); #elif defined(__APPLE__) // http://stackoverflow.com/a/1911863/382458 -#elif defined(__WIN32__) +#elif defined(_WIN32) // http://stackoverflow.com/a/282220/382458 and http://stackoverflow.com/a/64166/382458 PROCESS_MEMORY_COUNTERS MemoryCntrs; FILETIME CreationTime, ExitTime, KernelTime, UserTime; diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 2d4e6d9dd..0c5b937e0 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -85,7 +85,7 @@ int STEPfile::SetFileType( FileTypeCode ft ) { ** from filename */ std::string STEPfile::TruncFileName( const std::string filename ) const { -#if defined(__WIN32__) && !defined(__mingw32__) +#if defined(_WIN32) && !defined(__mingw32__) char slash = '\\'; #else char slash = '/'; diff --git a/src/cllazyfile/current_function.hpp b/src/cllazyfile/current_function.hpp index 2a0244d2f..9e783f003 100644 --- a/src/cllazyfile/current_function.hpp +++ b/src/cllazyfile/current_function.hpp @@ -28,22 +28,18 @@ # define SC_CURRENT_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__FUNCSIG__) +#elif defined(_MSC_VER) && _MSC_VER < 1900 -# define SC_CURRENT_FUNCTION __FUNCSIG__ +# define SC_CURRENT_FUNCTION __FUNCTION__ #elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) # define SC_CURRENT_FUNCTION __FUNCTION__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) +#else // STDC # define SC_CURRENT_FUNCTION __func__ -#else - -# define SC_CURRENT_FUNCTION "(unknown)" - #endif #endif // #ifndef CURRENT_FUNCTION_HPP_INCLUDED diff --git a/src/cllazyfile/lazyTypes.h b/src/cllazyfile/lazyTypes.h index 28b7ac60c..0ba2aa671 100644 --- a/src/cllazyfile/lazyTypes.h +++ b/src/cllazyfile/lazyTypes.h @@ -1,10 +1,20 @@ #ifndef LAZYTYPES_H #define LAZYTYPES_H +#include "sc_cf.h" + #include #include #include + +#ifdef HAVE_STDINT_H #include +#else +#if defined(_MSC_VER) && _MSC_VER < 1600 +typedef unsigned __int64 uint64_t; +typedef unsigned __int16 uint16_t; +#endif +#endif #include "judyLArray.h" #include "judySArray.h" diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 162beada8..337774342 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -52,8 +52,9 @@ #include #include +#include -#if defined(__WIN32__) +#ifdef _WIN32 #include #endif @@ -145,7 +146,7 @@ int DirObj::Index( const char * name ) { bool DirObj::Reset( const std::string & path ) { bool successful = IsADirectory( path.c_str() ); if( successful ) { -#ifdef __WIN32__ +#ifdef _WIN32 WIN32_FIND_DATA FindFileData; HANDLE hFind; @@ -182,7 +183,7 @@ bool DirObj::Reset( const std::string & path ) { /////////////////////////////////////////////////////////////////////////////// bool DirObj::IsADirectory( const char * path ) { -#if defined(__WIN32__) +#ifdef _WIN32 if( PathIsDirectory( path ) ) { return true; } @@ -217,7 +218,7 @@ bool DirObj::IsADirectory( const char * path ) { std::string DirObj::Normalize( const std::string & path ) { std::string buf; const char * slash; -#if defined(__WIN32__) +#ifdef _WIN32 char b[MAX_PATH]; PathCanonicalize( b, path.c_str() ); slash = "\\"; @@ -231,7 +232,7 @@ std::string DirObj::Normalize( const std::string & path ) { } else { buf.assign( b ); -#if !defined(__WIN32__) +#if !defined(_WIN32) free(b); #endif } @@ -254,7 +255,7 @@ std::string DirObj::Normalize( const std::string & path ) { /////////////////////////////////////////////////////////////////////////////// const char * DirObj::ValidDirectories( const char * path ) { -#ifdef __WIN32__ +#ifdef _WIN32 static char buf[MAX_PATH + 1]; #else static char buf[MAXPATHLEN + 1]; @@ -308,7 +309,7 @@ void DirObj::InsertFile( const char * f, int index ) { CheckIndex( index ); spot = &fileList[index]; } -#ifdef __MSVC__ +#ifdef _MSC_VER char * string = _strdup( f ); #else char * string = strdup( f ); diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 67b6362d5..8dfaeb6f8 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -14,7 +14,7 @@ #include "pretty_scope.h" #include "pretty_schema.h" -#if defined( _WIN32 ) || defined ( __WIN32__ ) +#ifdef _WIN32 # define unlink _unlink #else # include /* for unlink */ diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 3b0aece60..3b9e17d04 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -31,7 +31,7 @@ #ifdef HAVE_STD_CHRONO # define DELAY(t) std::this_thread::sleep_for(std::chrono::milliseconds(t)); #else -# ifndef __WIN32__ +# ifndef _WIN32 # define DELAY(t) usleep( t * 100 ) # else # include From 254024b954ee24c492f6d2884eb6e93175771fcc Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 17:28:28 +0100 Subject: [PATCH 030/244] silence MSVC warning 4251 - should be revisited later (if std:: interface layer needs to be limited) --- src/base/sc_benchmark.h | 7 +++++++ src/cldai/sdaiBinary.h | 8 ++++++++ src/cldai/sdaiString.h | 8 ++++++++ src/cleditor/STEPfile.h | 14 ++++++++++++++ src/cllazyfile/lazyDataSectionReader.h | 7 +++++++ src/cllazyfile/lazyFileReader.h | 7 +++++++ src/cllazyfile/lazyInstMgr.h | 8 ++++++++ src/cllazyfile/lazyRefs.h | 7 +++++++ src/cllazyfile/sectionReader.h | 7 +++++++ src/clstepcore/STEPcomplex.h | 7 +++++++ src/clstepcore/STEPundefined.h | 7 +++++++ src/clstepcore/aggrTypeDescriptor.h | 7 +++++++ src/clstepcore/dictSchema.h | 7 +++++++ src/clstepcore/entityDescriptor.h | 9 ++++++++- src/clstepcore/explicitItemId.h | 7 +++++++ src/clstepcore/globalRule.h | 10 +++++++++- src/clstepcore/interfaceSpec.h | 16 ++++++++++++---- src/clstepcore/interfacedItem.h | 7 +++++++ src/clstepcore/sdaiApplication_instance.h | 14 ++++++++++++++ src/clstepcore/uniquenessRule.h | 10 +++++++++- src/clstepcore/whereRule.h | 9 ++++++++- src/clutils/errordesc.h | 7 +++++++ 22 files changed, 182 insertions(+), 8 deletions(-) diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index 4721b2ae7..8512bd892 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -42,8 +42,15 @@ extern "C" { class SC_BASE_EXPORT benchmark { protected: benchVals initialVals, laterVals; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::ostream & ostr; std::string descr; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif bool debug, stopped; public: benchmark( std::string description = "", bool debugMessages = true, std::ostream & o_stream = std::cout ); diff --git a/src/cldai/sdaiBinary.h b/src/cldai/sdaiBinary.h index 151863ea0..76bb56d18 100644 --- a/src/cldai/sdaiBinary.h +++ b/src/cldai/sdaiBinary.h @@ -15,7 +15,15 @@ class SC_DAI_EXPORT SDAI_Binary { private: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string content; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + public: //constructor(s) & destructor diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index e365e575d..083da80ea 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -17,7 +17,15 @@ class SC_DAI_EXPORT SDAI_String { private: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string content; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + public: //constructor(s) & destructor diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index 124795539..37c7d20bc 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -58,11 +58,18 @@ class SC_EDITOR_EXPORT STEPfile { //file information DirObj * _currentDir; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _fileName; //the following are used to compute read/write progress std::ifstream::pos_type _iFileSize; ///< input file size std::ifstream::pos_type _iFileCurrentPosition; ///< input file position (from ifstream::tellg()) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif bool _iFileStage1Done; ///< set immediately before ReadData1() returns int _oFileInstsWritten; ///< number of instances that have been written @@ -92,8 +99,15 @@ class SC_EDITOR_EXPORT STEPfile { //file type information FileTypeCode _fileType; char ENTITY_NAME_DELIM; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string FILE_DELIM; std::string END_FILE_DELIM; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif //public member functions public: diff --git a/src/cllazyfile/lazyDataSectionReader.h b/src/cllazyfile/lazyDataSectionReader.h index 8cd4b0468..f2dc9dee4 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/src/cllazyfile/lazyDataSectionReader.h @@ -16,7 +16,14 @@ class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader { protected: bool _error, _completelyLoaded; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _sectionIdentifier; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif /// only makes sense to call the ctor from derived class ctors lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); diff --git a/src/cllazyfile/lazyFileReader.h b/src/cllazyfile/lazyFileReader.h index 44def9fb4..49eea5b50 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/src/cllazyfile/lazyFileReader.h @@ -26,10 +26,17 @@ class headerSectionReader; ///for use only from within lazyInstMgr class SC_LAZYFILE_EXPORT lazyFileReader { protected: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _fileName; lazyInstMgr * _parent; headerSectionReader * _header; std::ifstream _file; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif fileTypeEnum _fileType; fileID _fileID; diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 3a7e682ce..78444a756 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -26,6 +26,10 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { /** multimap from instance number to instances that it refers to * \sa instanceRefs_pair */ +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif instanceRefs_t _fwdInstanceRefs; /** multimap from instance number to instances that refer to it - the majority of these will not be inverse references! * \sa instanceRefs_pair @@ -67,6 +71,10 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { instMgrAdapter * _ima; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + public: lazyInstMgr(); ~lazyInstMgr(); diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 02889bcd1..6d2e093e4 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -60,12 +60,19 @@ class SC_LAZYFILE_EXPORT lazyRefs { typedef std::set< const Inverse_attribute * > iaList_t; typedef judyLArray< instanceID, std::string * > refMap_t; typedef std::set< const EntityDescriptor * > edList_t; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif iaList_t _iaList; lazyInstMgr * _lim; instanceID _id; refMap_t _refMap; referentInstances_t _referentInstances; SDAI_Application_instance * _inst; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif void checkAnInvAttr( const Inverse_attribute * ia ) { const EntityDescriptor * ed; diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index 8af3efd6b..c6a64b55a 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -18,10 +18,17 @@ class SC_LAZYFILE_EXPORT sectionReader { protected: //protected data members lazyFileReader * _lazyFile; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::ifstream & _file; std::streampos _sectionStart, ///< the start of this section as reported by tellg() _sectionEnd; ///< the end of this section as reported by tellg() +#ifdef _MSC_VER +#pragma warning( pop ) +#endif unsigned long _totalInstances; ErrorDescriptor * _error; diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index 9de151d43..caf7ea255 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -42,7 +42,14 @@ class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance { STEPcomplex * head; Registry * _registry; int visited; ///< used when reading (or as you wish?) +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif STEPcomplex_attr_data_list _attr_data_list; ///< attrs are created with a pointer to data; this stores them for deletion +#ifdef _MSC_VER +#pragma warning( pop ) +#endif public: STEPcomplex( Registry * registry, int fileid ); STEPcomplex( Registry * registry, const std::string ** names, int fileid, diff --git a/src/clstepcore/STEPundefined.h b/src/clstepcore/STEPundefined.h index 88abe110f..306eb0ef2 100644 --- a/src/clstepcore/STEPundefined.h +++ b/src/clstepcore/STEPundefined.h @@ -19,7 +19,14 @@ class SC_CORE_EXPORT SCLundefined { protected: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string val; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif public: // INPUT diff --git a/src/clstepcore/aggrTypeDescriptor.h b/src/clstepcore/aggrTypeDescriptor.h index 9126b8116..850a6b2e7 100644 --- a/src/clstepcore/aggrTypeDescriptor.h +++ b/src/clstepcore/aggrTypeDescriptor.h @@ -35,7 +35,14 @@ class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor { AggrBoundTypeEnum _bound1_type, _bound2_type; boundCallbackFn _bound1_callback, _bound2_callback; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _bound1_str, _bound2_str; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif public: diff --git a/src/clstepcore/dictSchema.h b/src/clstepcore/dictSchema.h index 8cfce8a0a..96977f98e 100644 --- a/src/clstepcore/dictSchema.h +++ b/src/clstepcore/dictSchema.h @@ -27,8 +27,15 @@ class SC_CORE_EXPORT Schema : public Dictionary_instance { // non-SDAI lists Interface_spec__set_var _use_interface_list; // list of USE interfaces Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::vector< std::string > _function_list; // of EXPRESS functions std::vector< std::string > _procedure_list; // of EXPRESS procedures +#ifdef _MSC_VER +#pragma warning( pop ) +#endif Global_rule__set_var _global_rules; diff --git a/src/clstepcore/entityDescriptor.h b/src/clstepcore/entityDescriptor.h index dfc9ac230..e0bd25ec8 100644 --- a/src/clstepcore/entityDescriptor.h +++ b/src/clstepcore/entityDescriptor.h @@ -33,8 +33,15 @@ class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor { EntityDescriptorList _supertypes; // OPTIONAL AttrDescriptorList _explicitAttr; // OPTIONAL Inverse_attributeList _inverseAttr; // OPTIONAL +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _supertype_stmt; - public: +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + public: Uniqueness_rule__set_var _uniqueness_rules; // initially a null pointer // pointer to a function that will create a new instance of a SDAI_Application_instance diff --git a/src/clstepcore/explicitItemId.h b/src/clstepcore/explicitItemId.h index 31319fd08..8a4d22ca0 100644 --- a/src/clstepcore/explicitItemId.h +++ b/src/clstepcore/explicitItemId.h @@ -21,10 +21,17 @@ class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item { // this ptr will be null. const TypeDescriptor * _local_definition; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif // name in originating schema - only exists if it has been renamed. Express_id _original_id; Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif const TypeDescriptor * local_definition_() const { return _local_definition; diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index 1b18590c5..c5614fdbf 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -9,11 +9,19 @@ class SC_CORE_EXPORT Global_rule : public Dictionary_instance { public: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif Express_id _name; + std::string _rule_text; // non-SDAI +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + Entity__set_var _entities; // not implemented Where_rule__list_var _where_rules; Schema_ptr _parent_schema; - std::string _rule_text; // non-SDAI Global_rule(); Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ); diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index b06a5bb78..8469a555d 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -9,15 +9,23 @@ class SC_CORE_EXPORT Interface_spec : public Dictionary_instance { public: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif Express_id _current_schema_id; // schema containing the USE/REF stmt - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema - + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to // be a list). // schema that defined the USE/REFd objects Express_id _foreign_schema_id; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema // non-SDAI, not useful for SDAI use of Interface_spec (it would need to // be a list of ints). diff --git a/src/clstepcore/interfacedItem.h b/src/clstepcore/interfacedItem.h index 54871d2af..00401b68b 100644 --- a/src/clstepcore/interfacedItem.h +++ b/src/clstepcore/interfacedItem.h @@ -14,7 +14,14 @@ class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance { Interfaced_item( const char * foreign_schema ); virtual ~Interfaced_item(); public: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif Express_id _foreign_schema; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif const Express_id foreign_schema_(); // private: diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index bcf5ef43d..70b7b3308 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -38,7 +38,14 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t; protected: const EntityDescriptor * eDesc; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif iAMap_t iAMap; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif bool _complex; public: //TODO make these private? @@ -51,7 +58,14 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { int STEPfile_id; ErrorDescriptor _error; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string p21Comment; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif /** ** head entity for multiple inheritance. If it is null then this diff --git a/src/clstepcore/uniquenessRule.h b/src/clstepcore/uniquenessRule.h index 8ed5fc624..4751ce97b 100644 --- a/src/clstepcore/uniquenessRule.h +++ b/src/clstepcore/uniquenessRule.h @@ -11,13 +11,21 @@ class EntityDescriptor; class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance { public: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif Express_id _label; - const EntityDescriptor * _parent_entity; // non-SDAI std::string _comment; /** Comment contained in the EXPRESS. * Should be properly formatted to include (* *) * Will be written to EXPRESS as-is (w/out formatting) */ +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + + const EntityDescriptor * _parent_entity; Uniqueness_rule(); Uniqueness_rule( const Uniqueness_rule & ); diff --git a/src/clstepcore/whereRule.h b/src/clstepcore/whereRule.h index 2f4487bfd..ef9043a4b 100644 --- a/src/clstepcore/whereRule.h +++ b/src/clstepcore/whereRule.h @@ -10,13 +10,20 @@ class SC_CORE_EXPORT Where_rule : public Dictionary_instance { public: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif Express_id _label; - Type_or_rule_var _type_or_rule; // non-SDAI std::string _comment; // Comment contained in the EXPRESS. // Should be properly formatted to include (* *) // Will be written to EXPRESS as-is (w/out formatting) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + Type_or_rule_var _type_or_rule; Where_rule(); Where_rule( const Where_rule & ); diff --git a/src/clutils/errordesc.h b/src/clutils/errordesc.h index 7b5c9db31..4ab284b2d 100644 --- a/src/clutils/errordesc.h +++ b/src/clutils/errordesc.h @@ -55,7 +55,14 @@ typedef int DebugLevel; class SC_UTILS_EXPORT ErrorDescriptor { private: +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif std::string _userMsg, _detailMsg; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif protected: Severity _severity; From dc38153539dd7bedfb4b4568ff692c2a24dcdf47 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 7 Aug 2019 17:33:56 +0100 Subject: [PATCH 031/244] duplicate declaration of SchemaInit() - it's already in the schema's generated header --- test/cpp/schema_specific/attribute.cc | 1 - test/cpp/schema_specific/inverse_attr1.cc | 1 - test/cpp/schema_specific/inverse_attr2.cc | 1 - test/cpp/schema_specific/inverse_attr3.cc | 1 - 4 files changed, 4 deletions(-) diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index cb21f19f6..bc624143a 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,7 +3,6 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include -extern void SchemaInit( class Registry & ); #include "sc_version_string.h" #include #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 7054464e4..3fd51454c 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,7 +4,6 @@ ** */ #include -extern void SchemaInit( class Registry & ); #include "sc_version_string.h" #include "SubSuperIterators.h" #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index c538129b0..d30eabe7b 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,7 +4,6 @@ ** */ #include -extern void SchemaInit( class Registry & ); #include "sc_version_string.h" #include #include diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index b35f5280d..866801dbf 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -5,7 +5,6 @@ * This test originally used STEPfile, which didn't work. Fixing STEPfile would have been very difficult, it uses lazyInstMgr now. */ #include -extern void SchemaInit( class Registry & ); #include #include #include From 5ab50bb68fd499560f9c5446a2ed23e3f7db6185 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 4 Aug 2019 18:54:28 +0100 Subject: [PATCH 032/244] begin to modernise / simplify CMake code --- CMakeLists.txt | 12 +- cmake/SC_CXX_schema_macros.cmake | 28 ++- cmake/SC_Config_Headers.cmake | 14 +- cmake/SC_Targets.cmake | 200 ++++++------------ cmake/sc_version_string.cmake | 13 +- cmake/schema_scanner/CMakeLists.txt | 15 +- cmake/schema_scanner/schemaScanner.cmake | 10 +- example/ap203min/CMakeLists.txt | 2 +- .../ExternalProjectBuild/CMakeLists.txt | 4 +- run_ctest.cmake | 4 +- src/base/CMakeLists.txt | 21 +- src/base/judy/CMakeLists.txt | 2 +- src/cldai/CMakeLists.txt | 13 +- src/cleditor/CMakeLists.txt | 11 +- src/cllazyfile/CMakeLists.txt | 21 +- src/clstepcore/CMakeLists.txt | 13 +- src/clstepcore/test/CMakeLists.txt | 2 +- src/clutils/CMakeLists.txt | 15 +- src/exp2cxx/CMakeLists.txt | 2 +- src/exp2cxx/test/inverse_qualifiers.cmake | 2 +- src/exp2cxx/test/unique_qualifiers.cmake | 2 +- src/exp2python/CMakeLists.txt | 2 +- src/exppp/CMakeLists.txt | 16 +- src/exppp/test/CMakeLists.txt | 4 +- src/exppp/test/exppp_div_slash.cmake | 2 +- src/exppp/test/exppp_lost_var.cmake | 2 +- src/exppp/test/inverse_qualifiers.cmake | 2 +- src/exppp/test/unique_qualifiers.cmake | 2 +- src/express/CMakeLists.txt | 59 ++++-- src/express/test/CMakeLists.txt | 4 +- test/cpp/schema_specific/CMakeLists.txt | 5 +- 31 files changed, 260 insertions(+), 244 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7708df8e8..af0b6fcc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,8 @@ 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) +cmake_minimum_required(VERSION 3.6.3) +# TODO: rework to remove these if(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) if ("${CMAKE_VERSION}" VERSION_GREATER 2.99) @@ -109,11 +110,8 @@ include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) ################ 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) if(HAVE_NULLPTR) @@ -145,7 +143,11 @@ add_subdirectory(doc) # 'make core' builds everything that isn't generated. for devs. add_custom_target(core) -add_dependencies(core stepdai check-express stepeditor exp2cxx) +if($CACHE{SC_BUILD_SHARED_LIBS}) + add_dependencies(core stepdai stepeditor exp2cxx check-express) +else() + add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) +endif() # 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. diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index ddb267053..388d820a5 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -27,10 +27,10 @@ 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") + SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${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") + SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) @@ -38,7 +38,7 @@ macro(SCHEMA_EXES) 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") + SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${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}) @@ -96,8 +96,26 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ${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}) + if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) + add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) + if(WIN32) + target_compile_definitions("${PROJECT_NAME}" PRIVATE SC_SCHEMA_DLL_EXPORTS) + if(MSVC) + target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj") + endif() + endif() + endif() + + if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static base-static TESTABLE) + add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME}) + target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC) + if(MSVC) + target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj") + endif() + endif() + SCHEMA_EXES() SCHEMA_TESTS() diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index f272c94d3..17d0c2774 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -21,9 +21,10 @@ CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}") include(CheckLibraryExists) include(CheckIncludeFile) -include(CheckFunctionExists) +include(CheckSymbolExists) include(CheckTypeSize) include(CMakePushCheckState) +include(CheckCSourceCompiles) include(CheckCXXSourceRuns) CHECK_INCLUDE_FILE(ndir.h HAVE_NDIR_H) @@ -37,10 +38,13 @@ 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) +# ensure macro functions are captured +CHECK_SYMBOL_EXISTS(abs "stdlib.h" HAVE_ABS) +CHECK_SYMBOL_EXISTS(memcpy "string.h" HAVE_MEMCPY) +CHECK_SYMBOL_EXISTS(memmove "string.h" HAVE_MEMMOVE) +CHECK_SYMBOL_EXISTS(getopt "getopt.h" HAVE_GETOPT) +CHECK_SYMBOL_EXISTS(snprintf "stdio.h" HAVE_SNPRINTF) +CHECK_SYMBOL_EXISTS(vsnprintf "stdio.h" HAVE_VSNPRINTF) CHECK_TYPE_SIZE("ssize_t" SSIZE_T) diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index d451658d2..09204146c 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -1,150 +1,82 @@ +macro(SC_ADDEXEC execname) + set(_addexec_opts NO_INSTALL TESTABLE) + set(_addexec_multikw SOURCES LINK_LIBRARIES) + string(TOUPPER "SC_ADDEXEC_${execname}_ARG" _arg_prefix) + cmake_parse_arguments(${_arg_prefix} "${_addexec_opts}" "" "${_addexec_multikw}" ${ARGN}) -# 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() - set_property(TARGET ${libname} APPEND PROPERTY COMPILE_DEFINITIONS "${export}") - endif(MSVC OR BORLAND) -endmacro(DEFINE_DLL_EXPORTS libname) + if(NOT DEFINED "${_arg_prefix}_SOURCES") + message(SEND_ERROR "SC_ADDEXEC usage error!") + endif() -# set compile definitions for dll imports on windows -macro(DEFINE_DLL_IMPORTS tgt libs) - if(MSVC OR BORLAND) - set(imports "") - foreach(lib ${libs}) - string(REGEX REPLACE "lib" "" shortname "${lib}") - string(REGEX REPLACE "step" "" LOWERCORE "${shortname}") - string(TOUPPER ${LOWERCORE} UPPER_CORE) - list(APPEND imports "SC_${UPPER_CORE}_DLL_IMPORTS") - endforeach(lib ${libs}) - set_property(TARGET ${tgt} APPEND PROPERTY COMPILE_DEFINITIONS "${imports}") - endif(MSVC OR BORLAND) -endmacro(DEFINE_DLL_IMPORTS tgt libs) + add_executable(${execname} ${${_arg_prefix}_SOURCES}) -#SC_ADDEXEC(execname "source files" "linked libs" ["TESTABLE"] ["NO_INSTALL"]) -macro(SC_ADDEXEC execname srcslist libslist) + if(DEFINED "${_arg_prefix}_LINK_LIBRARIES") + foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES}) + if($CACHE{SC_STATIC_UTILS}) + if(NOT $ STREQUAL "STATIC_LIBRARY") + message(SEND_ERROR "SC_ADDEXEC usage error - expected STATIC LINK_LIBRARIES targets (${_lib})") + endif() + endif() + target_link_libraries(${execname} ${_lib}) + endforeach() + endif() - string(TOUPPER "${execname}" EXECNAME_UPPER) - if(${ARGC} GREATER 3) - CMAKE_PARSE_ARGUMENTS(${EXECNAME_UPPER} "NO_INSTALL;TESTABLE" "" "" ${ARGN}) - endif(${ARGC} GREATER 3) - - 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 - if(NOT ${EXECNAME_UPPER}_NO_INSTALL AND NOT ${EXECNAME_UPPER}_TESTABLE) + if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE) install(TARGETS ${execname} RUNTIME DESTINATION ${BIN_DIR} LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR} - ) - endif(NOT ${EXECNAME_UPPER}_NO_INSTALL AND NOT ${EXECNAME_UPPER}_TESTABLE) - if(NOT SC_ENABLE_TESTING AND ${EXECNAME_UPPER}_TESTABLE) - set_target_properties( ${execname} PROPERTIES EXCLUDE_FROM_ALL ON ) - endif(NOT SC_ENABLE_TESTING AND ${EXECNAME_UPPER}_TESTABLE) - - # 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) + ARCHIVE DESTINATION ${LIB_DIR} + ) + endif() -endmacro(SC_ADDEXEC execname srcslist libslist) + if(NOT SC_ENABLE_TESTING AND ${_arg_prefix}_TESTABLE) + set_target_properties(${execname} PROPERTIES EXCLUDE_FROM_ALL ON) + endif() +endmacro() -#SC_ADDLIB(libname "source files" "linked libs" ["TESTABLE"] ["NO_INSTALL"] ["SO_SRCS ..."] ["STATIC_SRCS ..."]) -macro(SC_ADDLIB libname srcslist libslist) +macro(SC_ADDLIB _addlib_target) + set(_addlib_opts SHARED STATIC NO_INSTALL TESTABLE) + set(_addlib_multikw SOURCES LINK_LIBRARIES) + string(TOUPPER "SC_ADDLIB_${libname}_ARG" _arg_prefix) + cmake_parse_arguments(${_arg_prefix} "${_addlib_opts}" "" "${_addlib_multikw}" ${ARGN}) - string(TOUPPER "${libname}" LIBNAME_UPPER) - if(${ARGC} GREATER 3) - CMAKE_PARSE_ARGUMENTS(${LIBNAME_UPPER} "NO_INSTALL;TESTABLE" "" "SO_SRCS;STATIC_SRCS" ${ARGN}) - endif(${ARGC} GREATER 3) + if(NOT DEFINED ${_arg_prefix}_SOURCES) + message(SEND_ERROR "SC_ADDLIB usage error!") + endif() - string(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}") - if(SC_BUILD_SHARED_LIBS) - add_library(${libname} SHARED ${srcslist} ${${LIBNAME_UPPER}_SO_SRCS}) - 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}) - if(NOT ${LIBNAME_UPPER}_NO_INSTALL AND NOT ${LIBNAME_UPPER}_TESTABLE) - install(TARGETS ${libname} - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR} - ) - endif(NOT ${LIBNAME_UPPER}_NO_INSTALL AND NOT ${LIBNAME_UPPER}_TESTABLE) - if(NOT SC_ENABLE_TESTING AND ${LIBNAME_UPPER}_TESTABLE) - set_target_properties( ${libname} PROPERTIES EXCLUDE_FROM_ALL ON ) - endif(NOT SC_ENABLE_TESTING AND ${LIBNAME_UPPER}_TESTABLE) - 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} ${${LIBNAME_UPPER}_STATIC_SRCS}) - 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) - if(NOT ${LIBNAME_UPPER}_NO_INSTALL AND NOT ${LIBNAME_UPPER}_TESTABLE) - install(TARGETS ${libname}-static - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR} - ) - endif(NOT ${LIBNAME_UPPER}_NO_INSTALL AND NOT ${LIBNAME_UPPER}_TESTABLE) - if(NOT SC_ENABLE_TESTING AND ${LIBNAME_UPPER}_TESTABLE) - set_target_properties( ${libname}-static PROPERTIES EXCLUDE_FROM_ALL ON ) - endif(NOT SC_ENABLE_TESTING AND ${LIBNAME_UPPER}_TESTABLE) + if(${_arg_prefix}_SHARED) + add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES}) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION}) if(APPLE) - set_target_properties(${staticlibname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") + set_target_properties(${_addlib_target} 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) + elseif(${_arg_prefix}_STATIC) + add_library(${_addlib_target} STATIC ${${_arg_prefix}_SOURCES}) + target_compile_definitions(${_addlib_target} PRIVATE SC_STATIC) + else() + message(SEND_ERROR "SC_ADDLIB usage error!") + endif() + + if(DEFINED ${_arg_prefix}_LINK_LIBRARIES) + foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES}) + if(${_arg_prefix}_STATIC AND TARGET ${_lib}) + get_property(_libtype TARGET ${_lib} PROPERTY TYPE) + if(NOT ${_libtype} STREQUAL "STATIC_LIBRARY") + message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})") + endif() + endif() + target_link_libraries(${_addlib_target} ${_lib}) + endforeach() + endif() + + if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE) + install(TARGETS ${_addlib_target} + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR} + ) + endif() +endmacro() # Local Variables: # tab-width: 8 diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake index c6669c8d7..ed53ac27e 100644 --- a/cmake/sc_version_string.cmake +++ b/cmake/sc_version_string.cmake @@ -45,22 +45,11 @@ endif() 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) if(SC_ENABLE_TESTING) set (date_time_string "NA - disabled for testing") -elseif(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) + string(TIMESTAMP date_time_string UTC) endif() set(header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n" diff --git a/cmake/schema_scanner/CMakeLists.txt b/cmake/schema_scanner/CMakeLists.txt index 13bbb24dd..6575eb3fa 100644 --- a/cmake/schema_scanner/CMakeLists.txt +++ b/cmake/schema_scanner/CMakeLists.txt @@ -1,5 +1,5 @@ project(SC_SUBPROJECT_SCHEMA_SCANNER) -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 3.6.3) if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR)) message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}") @@ -54,19 +54,16 @@ include_directories( ${SC_BUILDDIR}/include ) +add_executable(schema_scanner ${schema_scanner_src}) + 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__) + target_compile_definitions(schema_scanner PUBLIC _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS) else() - add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) + target_compile_options(schema_scanner PUBLIC -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) endif() -add_definitions(-DSCHEMA_SCANNER) - -add_executable(schema_scanner ${schema_scanner_src}) +target_compile_definitions(schema_scanner PUBLIC SC_STATIC SCHEMA_SCANNER) # Local Variables: # tab-width: 8 diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index 6b066339b..0c345d931 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -11,13 +11,8 @@ # 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( STATUS "Will not do unity build for this compiler. (SC_UNITY_BUILD=FALSE)") - set(SC_UNITY_BUILD FALSE) - else() - message( STATUS "Assuming compiler is capable of unity build. (SC_UNITY_BUILD=TRUE)") - set(SC_UNITY_BUILD TRUE) - endif(BORLAND) + message( STATUS "Assuming compiler is capable of unity build. (SC_UNITY_BUILD=TRUE)") + set(SC_UNITY_BUILD TRUE) message( STATUS "Override by setting SC_UNITY_BUILD; TRUE will result in faster build times but *huge* translation units and higher memory use in compilation.") else(NOT DEFINED SC_UNITY_BUILD) message( STATUS "Respecting user-defined SC_UNITY_BUILD value of ${SC_UNITY_BUILD}.") @@ -106,5 +101,6 @@ macro(SCHEMA_CMLIST SCHEMA_FILE) 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. + # 2e6ee669 removed _schema, does this still work? configure_file(${SCHEMA_FILE} ${SCANNER_BUILD_DIR}/${_schema}) endmacro(SCHEMA_CMLIST SCHEMA_FILE) diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index 3765fa48a..624ca44a4 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -6,7 +6,7 @@ # for the use of this file. # project(AP203Minimum) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.6.3) # Set STEPCODE_ROOT_DIR to point to the root of the STEPcode source tree. if(NOT DEFINED STEPCODE_ROOT_DIR) diff --git a/example/ap203min/ExternalProjectBuild/CMakeLists.txt b/example/ap203min/ExternalProjectBuild/CMakeLists.txt index c73d648a2..7e964684c 100644 --- a/example/ap203min/ExternalProjectBuild/CMakeLists.txt +++ b/example/ap203min/ExternalProjectBuild/CMakeLists.txt @@ -6,7 +6,7 @@ # for the use of this file. # project(AP203Minimum) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.6.3) INCLUDE( ExternalProject ) @@ -77,4 +77,4 @@ target_link_libraries( ${PROJECT_NAME} # mode: cmake # indent-tabs-mode: t # End: -# ex: shiftwidth=2 tabstop=8 \ No newline at end of file +# ex: shiftwidth=2 tabstop=8 diff --git a/run_ctest.cmake b/run_ctest.cmake index 096cfb1c5..7533d7c17 100644 --- a/run_ctest.cmake +++ b/run_ctest.cmake @@ -3,8 +3,8 @@ 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_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") +#set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind) set(CTEST_INITIAL_CACHE " SITE:STRING=${CTEST_SITE} BUILDNAME:STRING=${CTEST_BUILD_NAME} diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 6f391e7c2..cd41f97b6 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -29,18 +29,23 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/judy/src ) -if(MINGW OR MSVC OR BORLAND) - add_definitions(-DSC_BASE_DLL_EXPORTS) -endif() - -if (${SC_MEMMGR_ENABLE_CHECKS}) +if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) endif() -SC_ADDLIB(base "${SC_BASE_SOURCES}" "") +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) + if(WIN32) + target_link_libraries(base psapi) + target_compile_definitions(base PRIVATE SC_BASE_DLL_EXPORTS) + endif() +endif() -if(MINGW OR MSVC OR BORLAND) - target_link_libraries(base psapi.lib) +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) + if(WIN32) + target_link_libraries(base-static psapi) + endif() endif() if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") diff --git a/src/base/judy/CMakeLists.txt b/src/base/judy/CMakeLists.txt index 4ba30087c..807fcd0af 100644 --- a/src/base/judy/CMakeLists.txt +++ b/src/base/judy/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.6.3) project( JudyTemplates ) if( NOT DEFINED CMAKE_BUILD_TYPE ) diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 4630296a3..2978f8c7a 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -34,7 +34,18 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -SC_ADDLIB(stepdai "${LIBSTEPDAI_SRCS}" "steputils;base") +set(_libdeps steputils base) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) + if(WIN32) + target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) +endif() install(FILES ${SC_CLDAI_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai) diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index dafbfd6af..4c40f73fc 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -27,7 +27,16 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -SC_ADDLIB(stepeditor "${LIBSTEPEDITOR_SRCS}" "stepcore;stepdai;steputils;base") +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) + if(WIN32) + target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) +endif() install(FILES ${SC_CLEDITOR_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor) diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index 1ff85d6e8..d737a9c89 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -30,12 +30,21 @@ include_directories( ${SC_SOURCE_DIR}/src/base/judy/src ) -SC_ADDLIB(steplazyfile "${clLazyFile_SRCS};${clLazyFile_HDRS}" "stepcore;stepdai;steputils;base;stepeditor") -SC_ADDEXEC(lazy_test "lazy_test.cc" "steplazyfile;stepeditor" NO_INSTALL) -set_property(TARGET lazy_test APPEND PROPERTY COMPILE_DEFINITIONS "NO_REGISTRY") -if(TARGET lazy_test-static) - set_property(TARGET lazy_test-static APPEND PROPERTY COMPILE_DEFINITIONS "NO_REGISTRY") -endif(TARGET lazy_test-static) +set(_libdeps stepcore stepdai steputils base stepeditor) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) + if(WIN32) + target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) +endif() + +SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) +target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile) diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index c18257986..937985fff 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -131,7 +131,18 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -SC_ADDLIB(stepcore "${LIBSTEPCORE_SRCS}" "steputils;stepdai;base") +set(_libdeps steputils stepdai base) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) + if(WIN32) + target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) +endif() install(FILES ${SC_CLSTEPCORE_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore) diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index 3ed91a9f2..1de017638 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories( ) function(add_stepcore_test name libs) - SC_ADDEXEC(tst_${name} test_${name}.cc "${libs}" "TESTABLE") + SC_ADDEXEC(tst_${name} SOURCES test_${name}.cc LINK_LIBRARIES ${libs} TESTABLE) add_test(NAME build_cpp_${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 22506bf00..2553f4fa5 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -25,10 +25,19 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -SC_ADDLIB(steputils "${LIBSTEPUTILS_SRCS}" "base") +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) + if(WIN32) + target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) + target_link_libraries(steputils shlwapi) + endif() +endif() -if(MINGW OR MSVC OR BORLAND) - target_link_libraries(steputils shlwapi.lib) +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) + if(WIN32) + target_link_libraries(steputils-static shlwapi) + endif() endif() install(FILES ${SC_CLUTILS_HDRS} diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index c50e66734..fe438ad28 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -37,7 +37,7 @@ include_directories( ${SC_SOURCE_DIR}/src/base ) -SC_ADDEXEC(exp2cxx "${exp2cxx_SOURCES}" "libexppp;express;base") +SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) add_dependencies(exp2cxx version_string) diff --git a/src/exp2cxx/test/inverse_qualifiers.cmake b/src/exp2cxx/test/inverse_qualifiers.cmake index dec2fe81f..e222c0b57 100644 --- a/src/exp2cxx/test/inverse_qualifiers.cmake +++ b/src/exp2cxx/test/inverse_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXE}, input file is ${INFILE} diff --git a/src/exp2cxx/test/unique_qualifiers.cmake b/src/exp2cxx/test/unique_qualifiers.cmake index b4b41f5df..3b3b1d7b5 100644 --- a/src/exp2cxx/test/unique_qualifiers.cmake +++ b/src/exp2cxx/test/unique_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXE}, input file is ${INFILE} diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index ae4ac9686..0cbf338aa 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -29,7 +29,7 @@ if(SC_PYTHON_GENERATOR) ../exp2cxx/write.cc ../exp2cxx/print.cc ) - SC_ADDEXEC(exp2python "${exp2python_SOURCES}" "express;base") + SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) add_dependencies(exp2python version_string) diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index b52821325..5d6b7a6f3 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -30,14 +30,20 @@ include_directories( ${SC_SOURCE_DIR}/src/express ) -if(BORLAND) - add_definitions(-D__STDC__) +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) + set_target_properties(libexppp PROPERTIES PREFIX "") + if(WIN32) + target_compile_definitions(libexppp PRIVATE SC_EXPPP_DLL_EXPORTS) + endif() endif() -SC_ADDLIB(libexppp "${LIBEXPPP_SOURCES}" "express;base") -set_target_properties(libexppp PROPERTIES PREFIX "") +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) + set_target_properties(libexppp-static PROPERTIES PREFIX "") +endif() -SC_ADDEXEC(exppp "${EXPPP_SOURCES}" "libexppp;express;base") +SC_ADDEXEC(exppp SOURCES ${EXPPP_SOURCES} LINK_LIBRARIES libexppp express base) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/exppp/test/CMakeLists.txt b/src/exppp/test/CMakeLists.txt index f99c932af..3b620a4b8 100644 --- a/src/exppp/test/CMakeLists.txt +++ b/src/exppp/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.6.3) project(test_exppp) set(breakLongStr_SRCS @@ -14,7 +14,7 @@ add_test(NAME build_exppp ) # this executable doesn't really check the results, just ensures no segfaults. ought to improve it... -SC_ADDEXEC(tst_breakLongStr "${breakLongStr_SRCS}" "express;base" "TESTABLE") +SC_ADDEXEC(tst_breakLongStr SOURCES ${breakLongStr_SRCS} LINK_LIBRARIES express base TESTABLE) add_test(NAME build_tst_breakLongStr WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . diff --git a/src/exppp/test/exppp_div_slash.cmake b/src/exppp/test/exppp_div_slash.cmake index 3c81b6860..b72b8582d 100644 --- a/src/exppp/test/exppp_div_slash.cmake +++ b/src/exppp/test/exppp_div_slash.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/exppp_lost_var.cmake b/src/exppp/test/exppp_lost_var.cmake index d564d7f1b..02809d6fd 100644 --- a/src/exppp/test/exppp_lost_var.cmake +++ b/src/exppp/test/exppp_lost_var.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/inverse_qualifiers.cmake b/src/exppp/test/inverse_qualifiers.cmake index ab64af9c0..233cb5399 100644 --- a/src/exppp/test/inverse_qualifiers.cmake +++ b/src/exppp/test/inverse_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/unique_qualifiers.cmake b/src/exppp/test/unique_qualifiers.cmake index b2c787862..5c26f8b11 100644 --- a/src/exppp/test/unique_qualifiers.cmake +++ b/src/exppp/test/unique_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.8 ) +cmake_minimum_required( VERSION 3.6.3 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index a63f2aa93..dfcf5e917 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -1,5 +1,5 @@ include_directories( - ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} ${SC_SOURCE_DIR}/src/base ) @@ -109,28 +109,49 @@ SET(EXPRESS_PRIVATE_HDRS stack.h ) -SC_ADDLIB(express "${EXPRESS_SOURCES}" "base" SO_SRCS "${SCL_SO_SRCS}" STATIC_SRCS "${SCL_STATIC_SRCS}") -if(SC_GENERATE_LP_SOURCES) - set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") - set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") - if (TARGET express-static) +variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) +variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(express SHARED SOURCES ${EXPRESS_SOURCES} ${SCL_SO_SRCS} LINK_LIBRARIES base) + if(WIN32) + target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) + endif() + + if(SC_GENERATE_LP_SOURCES) + set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") + set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + add_custom_command(TARGET express POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + ) + else() + add_dependencies(express express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express version_string) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(express-static STATIC SOURCES ${EXPRESS_SOURCES} ${SCL_STATIC_SRCS} LINK_LIBRARIES base-static) + + if(SC_GENERATE_LP_SOURCES) set_property(TARGET express-static APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_static_INCLUDE_DIR}") set_property(TARGET express-static APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_static_INCLUDE_DIR}") - endif (TARGET express-static) -endif(SC_GENERATE_LP_SOURCES) - -if(SC_GENERATE_LP_SOURCES) - add_custom_command(TARGET express POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + add_custom_command(TARGET express-static POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake ) -else(SC_GENERATE_LP_SOURCES) - add_dependencies(express express_verify) -endif(SC_GENERATE_LP_SOURCES) + else() + add_dependencies(express-static express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express-static version_string) + endif() +endif() -if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(express version_string) -endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) -SC_ADDEXEC("check-express" "${CHECK_EXPRESS_SOURCES}" "express;base" ${SC_EXEC_NOINSTALL}) +SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 2c932d3cf..dd8ddab5b 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -15,8 +15,8 @@ add_test(NAME test_plib_parse_err set_tests_properties( test_plib_parse_err PROPERTIES DEPENDS "build_check_express;$" ) set_tests_properties( test_plib_parse_err build_check_express PROPERTIES LABELS parser ) -sc_addexec(print_schemas "../fedex.c;print_schemas.c" "express;base") -sc_addexec(print_attrs "../fedex.c;print_attrs.c" "express;base") +sc_addexec(print_schemas SOURCES ../fedex.c print_schemas.c LINK_LIBRARIES express base) +sc_addexec(print_attrs SOURCES ../fedex.c print_attrs.c LINK_LIBRARIES express base) # Local Variables: # tab-width: 8 diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index 51d9c3172..39ce6541a 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.6.3) #c++ tests that depend on a particular schema include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/clutils @@ -52,9 +52,6 @@ function(add_schema_dependent_test name sdai_lib exe_args ) if(NOT ${ARGV4} STREQUAL "") set_property(TARGET tst_${name} APPEND_STRING PROPERTY COMPILE_FLAGS ${ARGV4} ) endif(NOT ${ARGV4} STREQUAL "") - if(NOT "${ARGV5}" MATCHES "NONE") - DEFINE_DLL_IMPORTS("tst_${name}" "${ARGV5}") - endif(NOT "${ARGV5}" MATCHES "NONE") target_link_libraries(tst_${name} sdai_${sdai_lib} ${ARGV5}) add_test(NAME build_cpp_${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} From 4afeea4d399efe54bea6989265a196143ce8dfd4 Mon Sep 17 00:00:00 2001 From: Sean Morrison Date: Sat, 23 Nov 2019 04:02:13 -0500 Subject: [PATCH 033/244] clean up the copying file to clarify the licensing status. add a detailed INTENT.md file to explain the government and brl-cad origins of the project. --- COPYING | 137 +++++++++++++++--------------------------------------- INTENT.md | 102 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 100 deletions(-) create mode 100644 INTENT.md diff --git a/COPYING b/COPYING index 45c5ac40b..58b5900c7 100644 --- a/COPYING +++ b/COPYING @@ -1,108 +1,45 @@ -Modifications to the original NIST code are (C)opyright by their -respective authors. Unless otherwise specified, they are copyright -on the date those changes were committed to whichever repository -they were committed to first (i.e. BRL-CAD on SourceForge.net, -mpictor/StepClassLibrary or stepcode/stepcode on github). +STEPcode is provided as a unified work under the 3-clause BSD license. +As some portions are not subject to copyright in some jurisdictions, +see INTENT.md for additional details regarding intent and history. -Modifications which were first committed to the repository on github -are licensed under the 3-clause BSD license below. Changes committed -to BRL-CAD either contain license information mentioning BRL-CAD -near the top of the file, or are licensed under the same terms that -NIST used. +In jurisdictions where code generated by STEPcode is subject to this +license, a special exception is provided that gives you permission to +non-exclusively license generated code under any license. -******************************************************************** -3-clause BSD license: - -Copyright (c) , -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. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -******************************************************************** +STEPcode acknowledgement and/or attribution is appreciated regardless +of license or copyright status. ******************************************************************** - ORIGINAL NIST TEXT FOLLOWS + 3-Clause BSD License ******************************************************************** -This software was produced by the National Institute of Standards and -Technology (NIST), an agency of the U.S. government, and by statute is -not subject to copyright in the United States. Recipients of this -software assume all responsibility associated with its operation, -modification, maintenance, and subsequent redistribution. - -Acknowledgements: -The STEP Class Library (SCL) was developed by the Manufacturing -Systems Integration Division at NIST to support testing of the -Standard for the Exchange of Product Model Data (a.k.a STEP) and -validation of STEP's emerging implementation specifications. Funding -for the project has come from the Department of Commerce and the -Department of Defense agencies including the Office of the Defense -CALS (Continuous Acquisition and Life-Cycle Support) Executive and -the Defense Advanced Research Projects Agency (DARPA). Recent -enhancements were sponsored by the National Information Infrastructure -Protocols Consortium and NIST's Systems Integration for Manufacturing -Applications (SIMA) program. - - -/* ******************************************************************** - * D I S C L A I M E R - * (February 6, 1992) - * - * There is no warranty for the NIST PDES Toolkit. - * If the NIST PDES Toolkit - * is modified by someone else and passed on, NIST wants - * the Toolkit's recipients to know that what they have is not what NIST - * distributed. - * - * Policies - * - * 1. Anyone may copy and distribute verbatim copies of the NIST PDES Toolkit - * source code as received in any medium. - * - * 2. Anyone may modify your copy or copies of the NIST PDES Toolkit source - * code or any portion of it, and copy and distribute such modifications - * provided that all modifications are clearly associated with the entity - * that performs the modifications. - * - * NO WARRANTY - * =========== - * - * NIST PROVIDES ABSOLUTELY NO WARRANTY. THE NIST PDES TOOLKIT - * IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS - * WITH YOU. SHOULD ANY PORTION OF THE NIST PDES TOOLKIT PROVE DEFECTIVE, - * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - * - * IN NO EVENT WILL NIST BE LIABLE FOR DAMAGES, - * INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, - * INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR - * INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA - * BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A - * FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY - * NIST) THE PROGRAMS, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. - */ - +Copyright (c) 2009-2019 STEPcode AUTHORS +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. 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. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/INTENT.md b/INTENT.md new file mode 100644 index 000000000..06d306e6a --- /dev/null +++ b/INTENT.md @@ -0,0 +1,102 @@ +## Licensing Intent + +The intent is that this software and documentation ("Project") should +be treated as if it is licensed under the license(s) associated with +the Project ("License") in the `COPYING` file. However, because some +contributors work for the United States (U.S.) Federal Government, it +is not that simple. + +The portions of this Project written by United States (U.S.) federal +government employees within the scope of their federal employment are +ineligible for copyright protection in the U.S.; this is generally +understood to mean that these portions of the Project are placed in +the public domain. + +In countries where copyright protection is available (which does not +include the U.S.), contributions made by U.S. Federal government +employees are released under the License. Merged contributions from +private contributors are released under the License. + +## Background History + +STEPcode was originally developed as the STEP Class Libraries (SCL) by +the U.S. National Institute of Standards and Technology (NIST). Prior +to 2009, the U.S. Army Research Laboratory and members of the BRL-CAD +open source community researched freely available open source options +for ISO 10303 STEP support. Development had ceased, no open source +community existed, the code was out of date in many regards, and +additional work was needed to become production-ready, but SCL was +found to be a usable reference implementation. + +Consulting with NIST and others circa 2009, the BRL-CAD community +began efforts to take over SCL development, modernization, and code +enhancements. The BRL-CAD community purchased licenses for the ISO +10303 standard and began working to bring SCL up-to-date with the +latest specification. By 2011, significant progress had been made, +the project had garnered attention from others, and STEPcode was +establishd as an independent project. + +## Original NIST License Text + +This software was [originally] produced by the National Institute of +Standards and Technology (NIST), an agency of the U.S. government, and +by statute is not subject to copyright in the United +States. Recipients of this software assume all responsibility +associated with its operation, modification, maintenance, and +subsequent redistribution. + +Acknowledgements: +The STEP Class Library (SCL) was developed by the Manufacturing +Systems Integration Division at NIST to support testing of the +Standard for the Exchange of Product Model Data (a.k.a STEP) and +validation of STEP's emerging implementation specifications. Funding +for the project has come from the Department of Commerce and the +Department of Defense agencies including the Office of the Defense +CALS (Continuous Acquisition and Life-Cycle Support) Executive and +the Defense Advanced Research Projects Agency (DARPA). Recent +enhancements [circa 1992] were sponsored by the National Information Infrastructure +Protocols Consortium and NIST's Systems Integration for Manufacturing +Applications (SIMA) program. + +~~~~ +/* ******************************************************************** + * D I S C L A I M E R + * (February 6, 1992) + * + * There is no warranty for the NIST PDES Toolkit. + * If the NIST PDES Toolkit + * is modified by someone else and passed on, NIST wants + * the Toolkit's recipients to know that what they have is not what NIST + * distributed. + * + * Policies + * + * 1. Anyone may copy and distribute verbatim copies of the NIST PDES Toolkit + * source code as received in any medium. + * + * 2. Anyone may modify your copy or copies of the NIST PDES Toolkit source + * code or any portion of it, and copy and distribute such modifications + * provided that all modifications are clearly associated with the entity + * that performs the modifications. + * + * NO WARRANTY + * =========== + * + * NIST PROVIDES ABSOLUTELY NO WARRANTY. THE NIST PDES TOOLKIT + * IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS + * WITH YOU. SHOULD ANY PORTION OF THE NIST PDES TOOLKIT PROVE DEFECTIVE, + * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + * + * IN NO EVENT WILL NIST BE LIABLE FOR DAMAGES, + * INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, + * INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR + * INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA + * BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A + * FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY + * NIST) THE PROGRAMS, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. + */ + ~~~~ \ No newline at end of file From b5c6bd327ad522ccbbe18326e8b3a31f11a45324 Mon Sep 17 00:00:00 2001 From: Sean Morrison Date: Sat, 23 Nov 2019 04:50:21 -0500 Subject: [PATCH 034/244] clarify AUTHORS and meant collective --- COPYING | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/COPYING b/COPYING index 58b5900c7..880953453 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,8 @@ -STEPcode is provided as a unified work under the 3-clause BSD license. -As some portions are not subject to copyright in some jurisdictions, -see INTENT.md for additional details regarding intent and history. +STEPcode is provided as a collective work under the 3-clause BSD +license. As some portions are not subject to copyright in some +jurisdictions, see INTENT.md for additional details regarding intent +and history. See the AUTHORS file for a list of contributors and +copyright holders. In jurisdictions where code generated by STEPcode is subject to this license, a special exception is provided that gives you permission to From c9031fb76ac65db891be55eeab749af5ffbc947d Mon Sep 17 00:00:00 2001 From: Sean Morrison Date: Sat, 23 Nov 2019 04:54:38 -0500 Subject: [PATCH 035/244] leave the exception clause out for now, at least until there's an expressed concern/need. --- COPYING | 4 ---- 1 file changed, 4 deletions(-) diff --git a/COPYING b/COPYING index 880953453..8bac185a8 100644 --- a/COPYING +++ b/COPYING @@ -4,10 +4,6 @@ jurisdictions, see INTENT.md for additional details regarding intent and history. See the AUTHORS file for a list of contributors and copyright holders. -In jurisdictions where code generated by STEPcode is subject to this -license, a special exception is provided that gives you permission to -non-exclusively license generated code under any license. - STEPcode acknowledgement and/or attribution is appreciated regardless of license or copyright status. From 8bf6f74bb87c11d8a14008052585cb7994b312d7 Mon Sep 17 00:00:00 2001 From: Sean Morrison Date: Sat, 23 Nov 2019 06:07:05 -0500 Subject: [PATCH 036/244] make what should be the obvious statement regarding generated code --- COPYING | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/COPYING b/COPYING index 8bac185a8..48d3fd176 100644 --- a/COPYING +++ b/COPYING @@ -4,6 +4,10 @@ jurisdictions, see INTENT.md for additional details regarding intent and history. See the AUTHORS file for a list of contributors and copyright holders. +Code generated by STEPcode containing substantial parts of STEPcode +complex enough to have copyright protection are subject to the terms +of this license. + STEPcode acknowledgement and/or attribution is appreciated regardless of license or copyright status. From ead76640708ddea4b79888050d802d26cc3bb8f8 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 15 Jul 2018 13:59:28 +0100 Subject: [PATCH 037/244] remove (now) redundant cmake_policy conditional checks require C11 / C++11 --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af0b6fcc6..aa6f1e667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,13 +52,9 @@ set(SC_ABI_VERSION ${SC_ABI_SOVERSION}.0.0) # Minimum required version of CMake cmake_minimum_required(VERSION 3.6.3) -# TODO: rework to remove these -if(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) - if ("${CMAKE_VERSION}" VERSION_GREATER 2.99) - CMAKE_POLICY(SET CMP0026 OLD) - endif ("${CMAKE_VERSION}" VERSION_GREATER 2.99) -endif(COMMAND CMAKE_POLICY) +cmake_policy(SET CMP0003 NEW) +cmake_policy(SET CMP0026 NEW) +cmake_policy(SET CMP0057 NEW) # CMake derives much of its functionality from modules, typically # stored in one directory - let CMake know where to find them. @@ -109,6 +105,9 @@ include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) ################ +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 11) + if(MSVC) # 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) From c0b61b40cb09fa2e48146ef30599cec2f4866786 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 16 Jul 2018 13:08:07 +0100 Subject: [PATCH 038/244] intermediate CMake object libraries for libexpress to support tests generated subdir CMakeLists.txt begin to remove Perplex --- src/express/CMakeLists.txt | 40 ++++++++++++++++++---------- src/express/generated/CMakeLists.txt | 8 ++++++ 2 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 src/express/generated/CMakeLists.txt diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index dfcf5e917..c546b9b7c 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -56,13 +56,8 @@ if(SC_GENERATE_LP_SOURCES) ${PERPLEX_ExpScanner_static_SRC} ) else(SC_GENERATE_LP_SOURCES) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/generated) - set(EXPRESS_GENERATED_SRCS - generated/expparse.c - generated/expscan.c - ) - set(SCL_SO_SRCS ${EXPRESS_GENERATED_SRCS}) - set(SCL_STATIC_SRCS ${EXPRESS_GENERATED_SRCS}) + add_subdirectory(generated) + include_directories(generated) endif(SC_GENERATE_LP_SOURCES) set(EXPRESS_SOURCES @@ -79,7 +74,7 @@ set(EXPRESS_SOURCES resolve.c lexact.c linklist.c - error.c +# error.c dict.c hash.c memory.c @@ -90,6 +85,19 @@ set(EXPRESS_SOURCES exp_kw.c ) +set(EXPRESS_OBJS) +foreach(_src ${EXPRESS_SOURCES}) + string(REPLACE "." "_" _suffix ${_src}) + set(_objlib "objlib_${_suffix}") + add_library(${_objlib} OBJECT ${_src}) + # TODO: probably PIC should be used everywhere... + set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) + list(APPEND EXPRESS_OBJS $) +endforeach() + +list(APPEND EXPRESS_OBJS $) +list(APPEND EXPRESS_OBJS $) + # TODO # Currently, fedex.c provides the main() for multiple programs. These programs # provide custom behavior by defining EXPRESSinit_init (called by fedex.c's @@ -113,14 +121,16 @@ variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) if($CACHE{SC_BUILD_SHARED_LIBS}) - SC_ADDLIB(express SHARED SOURCES ${EXPRESS_SOURCES} ${SCL_SO_SRCS} LINK_LIBRARIES base) + SC_ADDLIB(express SHARED SOURCES "error.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) endif() if(SC_GENERATE_LP_SOURCES) - set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") - set_property(TARGET express APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + set_property(TARGET express + APPEND PROPERTY INCLUDE_DIRECTORIES "${RE2C_ExpScanner_INCLUDE_DIR}") + set_property(TARGET express + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") add_custom_command(TARGET express POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake ) @@ -134,11 +144,13 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(express-static STATIC SOURCES ${EXPRESS_SOURCES} ${SCL_STATIC_SRCS} LINK_LIBRARIES base-static) + SC_ADDLIB(express-static STATIC SOURCES "error.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) if(SC_GENERATE_LP_SOURCES) - set_property(TARGET express-static APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_static_INCLUDE_DIR}") - set_property(TARGET express-static APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_static_INCLUDE_DIR}") + set_property(TARGET express-static + APPEND PROPERTY INCLUDE_DIRECTORIES "${RE2C_ExpScanner_INCLUDE_DIR}") + set_property(TARGET express-static + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") add_custom_command(TARGET express-static POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake ) diff --git a/src/express/generated/CMakeLists.txt b/src/express/generated/CMakeLists.txt new file mode 100644 index 000000000..53e9293be --- /dev/null +++ b/src/express/generated/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(.) + +add_library(objlib_expscan_c OBJECT expscan.c) +set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + +add_library(objlib_expparse_c OBJECT expparse.c) +set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + From 573c3ec1d53732981fd7d4750890d6736e6d8867 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 16 Jul 2018 13:17:40 +0100 Subject: [PATCH 039/244] add parentheses and scopes to remove noisy warnings issued by GCC --- src/base/judy/src/judy.c | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index fb5fb5fed..45e0cba44 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -193,7 +193,7 @@ void * judy_alloc( Judy * judy, unsigned int type ) { if( type >= JUDY_1 ) for( idx = type; idx++ < JUDY_max; ) - if( block = judy->reuse[idx] ) { + if( (block = judy->reuse[idx]) ) { judy->reuse[idx] = *block; while( idx-- > type ) { judy->reuse[idx] = block + JudySize[idx] / sizeof( void * ); @@ -366,7 +366,7 @@ unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { off = keysize; while( off-- && len < max ) - if( buff[len] = base[slot * keysize + off] ) { + if( (buff[len] = base[slot * keysize + off]) ) { len++; } else { break; @@ -495,7 +495,7 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max // is this a leaf? - if( !judy->depth && !( value & 0xFF ) || judy->depth && depth == judy->depth ) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { return &node[-slot - 1]; } @@ -509,7 +509,7 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max table = ( JudySlot * )( next & JUDY_mask ); // outer radix if( judy->depth ) { - slot = ( src[depth] >> ( ( JUDY_key_size - ++off & JUDY_key_mask ) * 8 ) ) & 0xff; + slot = ( src[depth] >> ( (( JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; } else if( off < max ) { slot = buff[off++]; } else { @@ -531,12 +531,13 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max depth++; } - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) // leaf? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? if( table[slot & 0x0F] ) { // occupied? return &table[slot & 0x0F]; } else { return NULL; } + } next = table[slot & 0x0F]; continue; @@ -650,7 +651,7 @@ void judy_radix( Judy * judy, JudySlot * radix, unsigned char * old, int start, // is this slot a leaf? - if( !judy->depth && ( !key || !keysize ) || judy->depth && !keysize && depth == judy->depth ) { + if( (!judy->depth && ( !key || !keysize )) || (judy->depth && !keysize && depth == judy->depth) ) { table[key & 0x0F] = oldnode[-start - 1]; return; } @@ -763,7 +764,7 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) { + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) { return &node[-slot - 1]; } #else @@ -787,7 +788,7 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { if( ( next = inner[slot & 0x0F] ) ) { judy->stack[judy->level].slot = slot; - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[slot & 0x0F]; } else { break; @@ -848,9 +849,9 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth ) #endif return &node[-slot - 1]; @@ -870,12 +871,13 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int for( slot = 256; slot--; ) { judy->stack[judy->level].slot = slot; if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { - if( ( next = inner[slot & 0x0F] ) ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { + if( ( next = inner[slot & 0x0F] ) ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { break; } + } } else { slot &= 0xF0; } @@ -942,11 +944,11 @@ JudySlot * judy_nxt( Judy * judy ) { cnt = size / ( sizeof( JudySlot ) + keysize ); node = ( JudySlot * )( ( next & JUDY_mask ) + size ); base = ( unsigned char * )( next & JUDY_mask ); - if( ++slot < cnt ) + if( ++slot < cnt ) { #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif { judy->stack[judy->level].slot = slot; @@ -955,6 +957,7 @@ JudySlot * judy_nxt( Judy * judy ) { judy->stack[judy->level].slot = slot; return judy_first( judy, node[-slot - 1], ( off | JUDY_key_mask ) + 1, depth ); } + } judy->level--; continue; @@ -1033,9 +1036,9 @@ JudySlot * judy_prv( Judy * judy ) { keysize = JUDY_key_size - ( off & JUDY_key_mask ); #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[( slot - 1 ) * keysize] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[( slot - 1 ) * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if( !judy->depth && !base[( slot - 1 ) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + if( (!judy->depth && !base[( slot - 1 ) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif return &node[-slot]; return judy_last( judy, node[-slot], ( off | JUDY_key_mask ) + 1, depth ); @@ -1051,12 +1054,13 @@ JudySlot * judy_prv( Judy * judy ) { while( slot-- ) { judy->stack[judy->level].slot--; if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) - if( inner[slot & 0x0F] ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { + if( inner[slot & 0x0F] ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { return judy_last( judy, inner[slot & 0x0F], off + 1, depth ); } + } } judy->level--; @@ -1291,7 +1295,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // is this a leaf? - if( !judy->depth && !( value & 0xFF ) || judy->depth && depth == judy->depth ) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS if( *next ) { Found++; @@ -1327,7 +1331,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max node[-slot - 1] = 0; // set new tree ptr/cell next = &node[-slot - 1]; - if( !judy->depth && !( value & 0xFF ) || judy->depth && depth == judy->depth ) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS if( *next ) { Found++; @@ -1344,7 +1348,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max if( size < JudySize[JUDY_max] ) { next = judy_promote( judy, next, slot + 1, value, keysize ); - if( !judy->depth && !( value & 0xFF ) || judy->depth && depth == judy->depth ) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS if( *next ) { Found++; @@ -1375,7 +1379,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max table = ( JudySlot * )( *next & JUDY_mask ); // outer radix if( judy->depth ) { - slot = ( src[depth] >> ( ( JUDY_key_size - ++off & JUDY_key_mask ) * 8 ) ) & 0xff; + slot = ( src[depth] >> ( ( (JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; } else if( off < max ) { slot = buff[off++]; } else { @@ -1399,7 +1403,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max #endif next = &table[slot & 0x0F]; - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { // leaf? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? #ifdef ASKITIS if( *next ) { Found++; From a4d1e03f0d2bda647d8e3b19d724575a9278ae99 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 16 Jul 2018 16:08:47 +0100 Subject: [PATCH 040/244] ensure when SC_BUILD_EXPRESS_ONLY is set that we do not build the schema scanner --- CMakeLists.txt | 2 +- cmake/SC_Build_opts.cmake | 6 ++++-- data/CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa6f1e667..d897264c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ project(SC) # SC version set(SC_VERSION_MAJOR 0) -set(SC_VERSION_MINOR 7-dev) +set(SC_VERSION_MINOR 8-dev) set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) # SC ABI version. SC_ABI_SOVERSION should be incremented diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index 5a3661e45..8ca942615 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -60,6 +60,9 @@ OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON) option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) mark_as_advanced(SC_BUILD_EXPRESS_ONLY) +option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) +mark_as_advanced(DEBUGGING_GENERATED_SOURCES) + #--------------------------------------------------------------------- # Coverage option OPTION_WITH_DEFAULT(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) @@ -79,11 +82,10 @@ 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) + if(NOT ${SC_BUILD_EXPRESS_ONLY} AND 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) #--------------------------------------------------------------------- diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 4e99f0b70..819403e6f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,7 +10,7 @@ # .exp file inside, which it uses. otherwise, ${path} is assumed to # be an express file. -if(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +if(NOT ${SC_BUILD_EXPRESS_ONLY} AND 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) @@ -25,7 +25,7 @@ if(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") LOCATE_SCHEMA(${FILE} abspath) SCHEMA_CMLIST(${abspath}) endforeach() -endif(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +endif() # Local Variables: # tab-width: 8 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05530cb5b..48d826458 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,8 +13,10 @@ foreach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) endif( UNITARY_SCHEMA MATCHES "fail_.*" ) endforeach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) -add_subdirectory(p21) -add_subdirectory(cpp) +if(NOT ${SC_BUILD_EXPRESS_ONLY}) + add_subdirectory(p21) + add_subdirectory(cpp) +endif() # Local Variables: # tab-width: 8 From 9b68d893e77270628e82753aacf15736d2f29bf5 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 18 Jul 2018 17:16:53 +0100 Subject: [PATCH 041/244] start to implement TDD to ensure no change of behaviour --- src/express/CMakeLists.txt | 6 +- src/express/dummy.c | 5 ++ src/express/test/CMakeLists.txt | 15 ++++ src/express/test/test_expr.c | 154 ++++++++++++++++++++++++++++++++ src/express/test/test_express.c | 11 +++ src/express/test/test_resolve.c | 23 +++++ src/express/test/test_schema.c | 14 +++ src/express/test/test_scope.c | 9 ++ src/express/test/test_type.c | 8 ++ 9 files changed, 242 insertions(+), 3 deletions(-) create mode 100644 src/express/dummy.c create mode 100644 src/express/test/test_expr.c create mode 100644 src/express/test/test_express.c create mode 100644 src/express/test/test_resolve.c create mode 100644 src/express/test/test_schema.c create mode 100644 src/express/test/test_scope.c create mode 100644 src/express/test/test_type.c diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index c546b9b7c..ece841bf2 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -74,7 +74,7 @@ set(EXPRESS_SOURCES resolve.c lexact.c linklist.c -# error.c + error.c dict.c hash.c memory.c @@ -121,7 +121,7 @@ variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) if($CACHE{SC_BUILD_SHARED_LIBS}) - SC_ADDLIB(express SHARED SOURCES "error.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) + SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) endif() @@ -144,7 +144,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(express-static STATIC SOURCES "error.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) + SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) if(SC_GENERATE_LP_SOURCES) set_property(TARGET express-static diff --git a/src/express/dummy.c b/src/express/dummy.c new file mode 100644 index 000000000..6956cac06 --- /dev/null +++ b/src/express/dummy.c @@ -0,0 +1,5 @@ +/* + * CMake dummy - unused + */ + +static int unused_1431423134; diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index dd8ddab5b..85d9a6b8f 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -1,5 +1,20 @@ include_directories(..) +set(EXPRESS_CORE_OBJ + $ + $ + $ + $ +# extra + $ + $ + $ +) + +add_executable(test_expr test_expr.c + $ + ${EXPRESS_CORE_OBJ}) + add_test(NAME build_check_express WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c new file mode 100644 index 000000000..24ef14c65 --- /dev/null +++ b/src/express/test/test_expr.c @@ -0,0 +1,154 @@ +#include "express/expr.h" + +/* core */ +#include "express/memory.h" +#include "express/error.h" +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ +#include "express/dict.h" +#include "express/object.h" +#include "express/info.h" + +/* + * missing header definition + */ +Type EXPresolve_op_dot( Expression expr, Scope scope ); + +/* + * TODO: keep interface, but refactor for test + */ +void EXPRESSinitialize( void ) {} + +/* + * TODO: move to error.c + */ +int EXPRESS_fail( Express model ) { return 1; } + +/* + * TODO: move to memory.c + */ +Type TYPEcreate( enum type_enum type ) { return NULL; } +Type TYPEcreate_name( Symbol * symbol ) { return NULL; } +TypeBody TYPEBODYcreate( enum type_enum type ) { return NULL; } + +Schema SCHEMAcreate( void ) { return NULL; } +Symbol *SYMBOLcreate( char * name, int line, const char * filename ) { return NULL; } + +/* + * mock globals + * TODO: what needs initialising? + */ +char * EXPRESSprogram_name; +int yylineno; +int __SCOPE_search_id; + +Type Type_Unknown; +Type Type_Identifier; +Type Type_Real; +Type Type_Integer; +Type Type_Dont_Care; +Type Type_Bad; +Type Type_Runtime; +Type Type_Logical; +Type Type_Generic; +Type Type_Binary; +Type Type_Entity; +Type Type_Aggregate; +Type Type_Expression; +Type Type_Query; +Type Type_Attribute; + +Error ERROR_warn_unsupported_lang_feat; +Error WARNING_case_skip_label; +Error ERROR_undefined_attribute; + +/* + * TODO: mock functions + */ +Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, struct Symbol_ ** down_sym ) { return NULL; } + +void EXP_resolve( Expression expr, Scope scope, Type typecheck ) {} + +Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { return NULL; } + +struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { return NULL; } + +Scope SCOPEcreate_tiny( char type ) { return NULL; } + +Variable VARcreate( Expression name, Type type ) { return NULL; } + + +int main(int argc, char *argv[]) { + Schema scope; + Symbol *e_type_id, *enum_id, *s_type_id; + Type enum_typ, select_typ; + TypeBody tb; + Expression expr, op1, op2, exp_enum_id; + + /* + * setup + */ + EXPRESSinitialize(); + Type_Identifier = TYPEcreate(identifier_); + + /* TODO: SCHEMAcreate should do this */ + scope = SCHEMAcreate(); + if (!scope->symbol_table) + scope->symbol_table = DICTcreate(50); + if (!scope->enum_table) + scope->enum_table = DICTcreate(50); + + /* + * initial code to faciliate code path under test (use of DICT_type) + */ + s_type_id = SYMBOLcreate("sel1", 1, "test1"); + e_type_id = SYMBOLcreate("enum1", 1, "test1"); + enum_id = SYMBOLcreate("val1", 1, "test1"); + + enum_typ = TYPEcreate_name(e_type_id); + + exp_enum_id = EXPcreate(enum_typ); + exp_enum_id->symbol = *enum_id; + exp_enum_id->u.integer = 1; + + tb = TYPEBODYcreate(enumeration_); + tb->list = LISTcreate(); + LISTadd_last(tb->list, enum_id); + enum_typ->u.type->body = tb; + + DICT_define(scope->symbol_table, e_type_id->name, enum_typ, &enum_typ->symbol, OBJ_TYPE); + + /* + * TODO: someone did half a job with OBJ_ENUM / OBJ_EXPRESSION + * now it's confusing when reading the source + */ + DICT_define(scope->enum_table, exp_enum_id->symbol.name, exp_enum_id, &exp_enum_id->symbol, OBJ_EXPRESSION); + + if (!enum_typ->symbol_table) + enum_typ->symbol_table = DICTcreate(50); + DICT_define(enum_typ->symbol_table, enum_id->name, exp_enum_id, enum_id, OBJ_EXPRESSION); + + select_typ = TYPEcreate_name(s_type_id); + tb = TYPEBODYcreate(select_); + tb->list = LISTcreate(); + LISTadd_last(tb->list, enum_typ); + select_typ->u.type->body = tb; + DICT_define(scope->symbol_table, s_type_id->name, select_typ, &select_typ->symbol, OBJ_TYPE); + + op1 = EXPcreate_from_symbol(Type_Identifier, s_type_id); + op2 = EXPcreate_from_symbol(Type_Identifier, enum_id); + expr = BIN_EXPcreate(OP_DOT, op1, op2); + + /* + * test: enum_ref '.' enum_id + */ + EXPresolve_op_dot(expr, scope); + + /* in case of error will exit via abort() */ + + return 0; +} + +/* TODO: additional test for entity_ attribute, variable */ diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c new file mode 100644 index 000000000..fd27e6e20 --- /dev/null +++ b/src/express/test/test_express.c @@ -0,0 +1,11 @@ +#include "express/express.h" + +int main(int argc, char *argv[]) { + + SCOPEfind_for_rename(); + + RENAMEresolve(); + + return 0; +} + diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c new file mode 100644 index 000000000..fc662bc3a --- /dev/null +++ b/src/express/test/test_resolve.c @@ -0,0 +1,23 @@ +#include "express/resolve.h" + +int main(int argc, char *argv[]) { + + EXP_resolve(); + + ENTITYresolve_subtype_expression(); + + TYPE_resolve(typ); + + STMTresolve(); + + SCOPEresolve_types(); + + SCOPEresolve_subsupers(); + + ENTITYresolve_supertypes(); + + SCOPEresolve_expressions_statements(); + + return 0; +} + diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c new file mode 100644 index 000000000..629f3fe81 --- /dev/null +++ b/src/express/test/test_schema.c @@ -0,0 +1,14 @@ +#include "express/schema.h" + +int main(int argc, char *argv[]) { + + SCHEMAdefine_reference(); + + SCHEMAdefine_use(); + + SCHEMA_get_entities_ref(); + + VARfind(); + + return 0; +} diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c new file mode 100644 index 000000000..22d62e40b --- /dev/null +++ b/src/express/test/test_scope.c @@ -0,0 +1,9 @@ +#include "express/scope.h" + +int main(int argc, char *argv[]) { + + SCOPE_find(); + + return 0; + +} diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c new file mode 100644 index 000000000..8890b7e0e --- /dev/null +++ b/src/express/test/test_type.c @@ -0,0 +1,8 @@ +#include "express/type.h" + +int main(int argc, char *argv[]) { + + TYPEcreate_user_defined_tag(); + + return 0; +} From 61e680ae7202fbadb38ba5275a217423bbf743c3 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Thu, 19 Jul 2018 09:45:34 +0100 Subject: [PATCH 042/244] add Fake Function Framework (FFF) for mocks --- src/express/test/fff.h | 6188 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 6188 insertions(+) create mode 100644 src/express/test/fff.h diff --git a/src/express/test/fff.h b/src/express/test/fff.h new file mode 100644 index 000000000..ecd19da4f --- /dev/null +++ b/src/express/test/fff.h @@ -0,0 +1,6188 @@ +/* +git origin: https://github.com/meekrosoft/fff.git +git SHA: 8b5e44b872f65874427be645dfacd01cde31f358 + +LICENSE + +The MIT License (MIT) + +Copyright (c) 2010 Michael Long + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +#ifndef FAKE_FUNCTIONS +#define FAKE_FUNCTIONS + +#include +#include /* For memset and memcpy */ + +#define FFF_MAX_ARGS (20u) +#ifndef FFF_ARG_HISTORY_LEN + #define FFF_ARG_HISTORY_LEN (50u) +#endif +#ifndef FFF_CALL_HISTORY_LEN + #define FFF_CALL_HISTORY_LEN (50u) +#endif +/* -- INTERNAL HELPER MACROS -- */ +#define SET_RETURN_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ + FUNCNAME##_fake.return_val_seq = ARRAY_POINTER; \ + FUNCNAME##_fake.return_val_seq_len = ARRAY_LEN; +#define SET_CUSTOM_FAKE_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ + FUNCNAME##_fake.custom_fake_seq = ARRAY_POINTER; \ + FUNCNAME##_fake.custom_fake_seq_len = ARRAY_LEN; + +/* Defining a function to reset a fake function */ +#define RESET_FAKE(FUNCNAME) { \ + FUNCNAME##_reset(); \ +} \ + + +#define DECLARE_ARG(type, n, FUNCNAME) \ + type arg##n##_val; \ + type arg##n##_history[FFF_ARG_HISTORY_LEN]; + +#define DECLARE_ALL_FUNC_COMMON \ + unsigned int call_count; \ + unsigned int arg_history_len; \ + unsigned int arg_histories_dropped; \ + +#define DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + RETURN_TYPE return_val_history[FFF_ARG_HISTORY_LEN]; + +#define SAVE_ARG(FUNCNAME, n) \ + memcpy((void*)&FUNCNAME##_fake.arg##n##_val, (void*)&arg##n, sizeof(arg##n)); + +#define ROOM_FOR_MORE_HISTORY(FUNCNAME) \ + FUNCNAME##_fake.call_count < FFF_ARG_HISTORY_LEN + +#define SAVE_RET_HISTORY(FUNCNAME, RETVAL) \ + if ((FUNCNAME##_fake.call_count - 1) < FFF_ARG_HISTORY_LEN) \ + memcpy((void *)&FUNCNAME##_fake.return_val_history[FUNCNAME##_fake.call_count - 1], (const void *) &RETVAL, sizeof(RETVAL)); \ + +#define SAVE_ARG_HISTORY(FUNCNAME, ARGN) \ + memcpy((void*)&FUNCNAME##_fake.arg##ARGN##_history[FUNCNAME##_fake.call_count], (void*)&arg##ARGN, sizeof(arg##ARGN)); + +#define HISTORY_DROPPED(FUNCNAME) \ + FUNCNAME##_fake.arg_histories_dropped++ + +#define DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + RETURN_TYPE return_val; \ + int return_val_seq_len; \ + int return_val_seq_idx; \ + RETURN_TYPE * return_val_seq; \ + +#define DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + int custom_fake_seq_len; \ + int custom_fake_seq_idx; \ + +#define INCREMENT_CALL_COUNT(FUNCNAME) \ + FUNCNAME##_fake.call_count++ + +#define RETURN_FAKE_RESULT(FUNCNAME) \ + if (FUNCNAME##_fake.return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_fake.return_val_seq_idx < FUNCNAME##_fake.return_val_seq_len) { \ + SAVE_RET_HISTORY(FUNCNAME, FUNCNAME##_fake.return_val_seq[FUNCNAME##_fake.return_val_seq_idx]) \ + return FUNCNAME##_fake.return_val_seq[FUNCNAME##_fake.return_val_seq_idx++]; \ + } \ + SAVE_RET_HISTORY(FUNCNAME, FUNCNAME##_fake.return_val_seq[FUNCNAME##_fake.return_val_seq_len-1]) \ + return FUNCNAME##_fake.return_val_seq[FUNCNAME##_fake.return_val_seq_len-1]; /* return last element */ \ + } \ + SAVE_RET_HISTORY(FUNCNAME, FUNCNAME##_fake.return_val) \ + return FUNCNAME##_fake.return_val; \ + +#ifdef __cplusplus + #define FFF_EXTERN_C extern "C"{ + #define FFF_END_EXTERN_C } +#else /* ansi c */ + #define FFF_EXTERN_C + #define FFF_END_EXTERN_C +#endif /* cpp/ansi c */ + +#define DEFINE_RESET_FUNCTION(FUNCNAME) \ + void FUNCNAME##_reset(void){ \ + memset(&FUNCNAME##_fake, 0, sizeof(FUNCNAME##_fake)); \ + FUNCNAME##_fake.arg_history_len = FFF_ARG_HISTORY_LEN; \ + } +/* -- END INTERNAL HELPER MACROS -- */ + +typedef void (*fff_function_t)(void); +typedef struct { + fff_function_t call_history[FFF_CALL_HISTORY_LEN]; + unsigned int call_history_idx; +} fff_globals_t; + +FFF_EXTERN_C \ +extern fff_globals_t fff; +FFF_END_EXTERN_C \ + +#define DEFINE_FFF_GLOBALS \ + FFF_EXTERN_C \ + fff_globals_t fff; \ + FFF_END_EXTERN_C + +#define FFF_RESET_HISTORY() fff.call_history_idx = 0; + +#define REGISTER_CALL(function) \ + if(fff.call_history_idx < FFF_CALL_HISTORY_LEN) \ + fff.call_history[fff.call_history_idx++] = (fff_function_t)function; + +#define DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(void); \ + void(**custom_fake_seq)(void); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(void); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC0(FUNCNAME) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(void){ \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC0(FUNCNAME) \ + DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ + DEFINE_FAKE_VOID_FUNC0(FUNCNAME) \ + + +#define DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0); \ + void(**custom_fake_seq)(ARG0_TYPE arg0); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0){ \ + SAVE_ARG(FUNCNAME, 0); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + DEFINE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + DEFINE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + DEFINE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + DEFINE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + DEFINE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + DEFINE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + DEFINE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + DEFINE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + DEFINE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + DEFINE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + DEFINE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + DEFINE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + DEFINE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + DEFINE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + DEFINE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + DEFINE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + DEFINE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + DEFINE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + DEFINE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ARG(ARG19_TYPE, 19, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + SAVE_ARG(FUNCNAME, 19); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + SAVE_ARG_HISTORY(FUNCNAME, 19); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + } \ + else{ \ + FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + DEFINE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(void); \ + RETURN_TYPE(**custom_fake_seq)(void); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(void); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(void){ \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + DEFINE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + + +#define DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0){ \ + SAVE_ARG(FUNCNAME, 0); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + DEFINE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + DEFINE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + DEFINE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + DEFINE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + DEFINE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + DEFINE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + DEFINE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + DEFINE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + DEFINE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + DEFINE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + DEFINE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + DEFINE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + DEFINE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + DEFINE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + DEFINE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + DEFINE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + DEFINE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + DEFINE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ + + +#define DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ARG(ARG19_TYPE, 19, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ARG19_TYPE arg19){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + SAVE_ARG(FUNCNAME, 19); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + SAVE_ARG_HISTORY(FUNCNAME, 19); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if (FUNCNAME##_fake.custom_fake_seq_len){ /* a sequence of custom fakes */ \ + if (FUNCNAME##_fake.custom_fake_seq_idx < FUNCNAME##_fake.custom_fake_seq_len){ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_idx++](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + else{ \ + RETURN_TYPE ret = FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + return FUNCNAME##_fake.custom_fake_seq[FUNCNAME##_fake.custom_fake_seq_len-1](arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + } \ + } \ + if (FUNCNAME##_fake.custom_fake) return FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + DEFINE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ + + +#define DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg0); \ + FUNCNAME##_fake.custom_fake(arg0, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg1); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg2); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg3); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg4); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg5); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg6); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg7); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg8); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg9); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg10); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg11); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg12); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg13); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg14); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg15); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg16); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg17); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + + +#define DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, va_list ap); \ + void(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + va_list ap; \ + va_start(ap, arg18); \ + FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, ap); \ + va_end(ap); \ + } \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + DEFINE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg0); \ + ret = FUNCNAME##_fake.custom_fake(arg0, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg1); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg2); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg3); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg4); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg5); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg6); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg7); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg8); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg9); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg10); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg11); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg12); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg13); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg14); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg15); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg16); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg17); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ + + +#define DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + FFF_EXTERN_C \ + typedef struct FUNCNAME##_Fake { \ + DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ + DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ + DECLARE_ARG(ARG2_TYPE, 2, FUNCNAME) \ + DECLARE_ARG(ARG3_TYPE, 3, FUNCNAME) \ + DECLARE_ARG(ARG4_TYPE, 4, FUNCNAME) \ + DECLARE_ARG(ARG5_TYPE, 5, FUNCNAME) \ + DECLARE_ARG(ARG6_TYPE, 6, FUNCNAME) \ + DECLARE_ARG(ARG7_TYPE, 7, FUNCNAME) \ + DECLARE_ARG(ARG8_TYPE, 8, FUNCNAME) \ + DECLARE_ARG(ARG9_TYPE, 9, FUNCNAME) \ + DECLARE_ARG(ARG10_TYPE, 10, FUNCNAME) \ + DECLARE_ARG(ARG11_TYPE, 11, FUNCNAME) \ + DECLARE_ARG(ARG12_TYPE, 12, FUNCNAME) \ + DECLARE_ARG(ARG13_TYPE, 13, FUNCNAME) \ + DECLARE_ARG(ARG14_TYPE, 14, FUNCNAME) \ + DECLARE_ARG(ARG15_TYPE, 15, FUNCNAME) \ + DECLARE_ARG(ARG16_TYPE, 16, FUNCNAME) \ + DECLARE_ARG(ARG17_TYPE, 17, FUNCNAME) \ + DECLARE_ARG(ARG18_TYPE, 18, FUNCNAME) \ + DECLARE_ALL_FUNC_COMMON \ + DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \ + DECLARE_RETURN_VALUE_HISTORY(RETURN_TYPE) \ + DECLARE_CUSTOM_FAKE_SEQ_VARIABLES \ + RETURN_TYPE(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, va_list ap); \ + RETURN_TYPE(**custom_fake_seq)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, va_list ap); \ + } FUNCNAME##_Fake; \ + extern FUNCNAME##_Fake FUNCNAME##_fake; \ + void FUNCNAME##_reset(void); \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ...); \ + FFF_END_EXTERN_C \ + +#define DEFINE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + FFF_EXTERN_C \ + FUNCNAME##_Fake FUNCNAME##_fake; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8, ARG9_TYPE arg9, ARG10_TYPE arg10, ARG11_TYPE arg11, ARG12_TYPE arg12, ARG13_TYPE arg13, ARG14_TYPE arg14, ARG15_TYPE arg15, ARG16_TYPE arg16, ARG17_TYPE arg17, ARG18_TYPE arg18, ...){ \ + SAVE_ARG(FUNCNAME, 0); \ + SAVE_ARG(FUNCNAME, 1); \ + SAVE_ARG(FUNCNAME, 2); \ + SAVE_ARG(FUNCNAME, 3); \ + SAVE_ARG(FUNCNAME, 4); \ + SAVE_ARG(FUNCNAME, 5); \ + SAVE_ARG(FUNCNAME, 6); \ + SAVE_ARG(FUNCNAME, 7); \ + SAVE_ARG(FUNCNAME, 8); \ + SAVE_ARG(FUNCNAME, 9); \ + SAVE_ARG(FUNCNAME, 10); \ + SAVE_ARG(FUNCNAME, 11); \ + SAVE_ARG(FUNCNAME, 12); \ + SAVE_ARG(FUNCNAME, 13); \ + SAVE_ARG(FUNCNAME, 14); \ + SAVE_ARG(FUNCNAME, 15); \ + SAVE_ARG(FUNCNAME, 16); \ + SAVE_ARG(FUNCNAME, 17); \ + SAVE_ARG(FUNCNAME, 18); \ + if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){ \ + SAVE_ARG_HISTORY(FUNCNAME, 0); \ + SAVE_ARG_HISTORY(FUNCNAME, 1); \ + SAVE_ARG_HISTORY(FUNCNAME, 2); \ + SAVE_ARG_HISTORY(FUNCNAME, 3); \ + SAVE_ARG_HISTORY(FUNCNAME, 4); \ + SAVE_ARG_HISTORY(FUNCNAME, 5); \ + SAVE_ARG_HISTORY(FUNCNAME, 6); \ + SAVE_ARG_HISTORY(FUNCNAME, 7); \ + SAVE_ARG_HISTORY(FUNCNAME, 8); \ + SAVE_ARG_HISTORY(FUNCNAME, 9); \ + SAVE_ARG_HISTORY(FUNCNAME, 10); \ + SAVE_ARG_HISTORY(FUNCNAME, 11); \ + SAVE_ARG_HISTORY(FUNCNAME, 12); \ + SAVE_ARG_HISTORY(FUNCNAME, 13); \ + SAVE_ARG_HISTORY(FUNCNAME, 14); \ + SAVE_ARG_HISTORY(FUNCNAME, 15); \ + SAVE_ARG_HISTORY(FUNCNAME, 16); \ + SAVE_ARG_HISTORY(FUNCNAME, 17); \ + SAVE_ARG_HISTORY(FUNCNAME, 18); \ + } \ + else{ \ + HISTORY_DROPPED(FUNCNAME); \ + } \ + INCREMENT_CALL_COUNT(FUNCNAME); \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_fake.custom_fake){ \ + RETURN_TYPE ret; \ + va_list ap; \ + va_start(ap, arg18); \ + ret = FUNCNAME##_fake.custom_fake(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, ap); \ + va_end(ap); \ + SAVE_RET_HISTORY(FUNCNAME, ret); \ + return ret; \ + } \ + RETURN_FAKE_RESULT(FUNCNAME) \ + } \ + DEFINE_RESET_FUNCTION(FUNCNAME) \ + FFF_END_EXTERN_C \ + +#define FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + DEFINE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ + +/* MSVC expand macro fix */ +#define EXPAND(x) x + +#define PP_NARG_MINUS2(...) EXPAND(PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2())) + +#define PP_NARG_MINUS2_(...) EXPAND(PP_ARG_MINUS2_N(__VA_ARGS__)) + +#define PP_ARG_MINUS2_N(returnVal, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N + +#define PP_RSEQ_N_MINUS2() 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 + + +#define PP_NARG_MINUS1(...) EXPAND(PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1())) + +#define PP_NARG_MINUS1_(...) EXPAND(PP_ARG_MINUS1_N(__VA_ARGS__)) + +#define PP_ARG_MINUS1_N(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N + +#define PP_RSEQ_N_MINUS1() 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 + + + +/* DECLARE AND DEFINE FAKE FUNCTIONS - PLACE IN TEST FILES */ + +#define FAKE_VALUE_FUNC(...) EXPAND(FUNC_VALUE_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define FUNC_VALUE_(N,...) EXPAND(FUNC_VALUE_N(N,__VA_ARGS__)) + +#define FUNC_VALUE_N(N,...) EXPAND(FAKE_VALUE_FUNC ## N(__VA_ARGS__)) + + +#define FAKE_VOID_FUNC(...) EXPAND(FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define FUNC_VOID_(N,...) EXPAND(FUNC_VOID_N(N,__VA_ARGS__)) + +#define FUNC_VOID_N(N,...) EXPAND(FAKE_VOID_FUNC ## N(__VA_ARGS__)) + + +#define FAKE_VALUE_FUNC_VARARG(...) EXPAND(FUNC_VALUE_VARARG_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define FUNC_VALUE_VARARG_(N,...) EXPAND(FUNC_VALUE_VARARG_N(N,__VA_ARGS__)) + +#define FUNC_VALUE_VARARG_N(N,...) EXPAND(FAKE_VALUE_FUNC ## N ## _VARARG(__VA_ARGS__)) + + +#define FAKE_VOID_FUNC_VARARG(...) EXPAND(FUNC_VOID_VARARG_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define FUNC_VOID_VARARG_(N,...) EXPAND(FUNC_VOID_VARARG_N(N,__VA_ARGS__)) + +#define FUNC_VOID_VARARG_N(N,...) EXPAND(FAKE_VOID_FUNC ## N ## _VARARG(__VA_ARGS__)) + + + +/* DECLARE FAKE FUNCTIONS - PLACE IN HEADER FILES */ + +#define DECLARE_FAKE_VALUE_FUNC(...) EXPAND(DECLARE_FUNC_VALUE_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define DECLARE_FUNC_VALUE_(N,...) EXPAND(DECLARE_FUNC_VALUE_N(N,__VA_ARGS__)) + +#define DECLARE_FUNC_VALUE_N(N,...) EXPAND(DECLARE_FAKE_VALUE_FUNC ## N(__VA_ARGS__)) + + +#define DECLARE_FAKE_VOID_FUNC(...) EXPAND(DECLARE_FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define DECLARE_FUNC_VOID_(N,...) EXPAND(DECLARE_FUNC_VOID_N(N,__VA_ARGS__)) + +#define DECLARE_FUNC_VOID_N(N,...) EXPAND(DECLARE_FAKE_VOID_FUNC ## N(__VA_ARGS__)) + + +#define DECLARE_FAKE_VALUE_FUNC_VARARG(...) EXPAND(DECLARE_FUNC_VALUE_VARARG_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define DECLARE_FUNC_VALUE_VARARG_(N,...) EXPAND(DECLARE_FUNC_VALUE_VARARG_N(N,__VA_ARGS__)) + +#define DECLARE_FUNC_VALUE_VARARG_N(N,...) EXPAND(DECLARE_FAKE_VALUE_FUNC ## N ## _VARARG(__VA_ARGS__)) + + +#define DECLARE_FAKE_VOID_FUNC_VARARG(...) EXPAND(DECLARE_FUNC_VOID_VARARG_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define DECLARE_FUNC_VOID_VARARG_(N,...) EXPAND(DECLARE_FUNC_VOID_VARARG_N(N,__VA_ARGS__)) + +#define DECLARE_FUNC_VOID_VARARG_N(N,...) EXPAND(DECLARE_FAKE_VOID_FUNC ## N ## _VARARG(__VA_ARGS__)) + + + +/* DEFINE FAKE FUNCTIONS - PLACE IN SOURCE FILES */ + +#define DEFINE_FAKE_VALUE_FUNC(...) EXPAND(DEFINE_FUNC_VALUE_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define DEFINE_FUNC_VALUE_(N,...) EXPAND(DEFINE_FUNC_VALUE_N(N,__VA_ARGS__)) + +#define DEFINE_FUNC_VALUE_N(N,...) EXPAND(DEFINE_FAKE_VALUE_FUNC ## N(__VA_ARGS__)) + + +#define DEFINE_FAKE_VOID_FUNC(...) EXPAND(DEFINE_FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define DEFINE_FUNC_VOID_(N,...) EXPAND(DEFINE_FUNC_VOID_N(N,__VA_ARGS__)) + +#define DEFINE_FUNC_VOID_N(N,...) EXPAND(DEFINE_FAKE_VOID_FUNC ## N(__VA_ARGS__)) + + +#define DEFINE_FAKE_VALUE_FUNC_VARARG(...) EXPAND(DEFINE_FUNC_VALUE_VARARG_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__)) + +#define DEFINE_FUNC_VALUE_VARARG_(N,...) EXPAND(DEFINE_FUNC_VALUE_VARARG_N(N,__VA_ARGS__)) + +#define DEFINE_FUNC_VALUE_VARARG_N(N,...) EXPAND(DEFINE_FAKE_VALUE_FUNC ## N ## _VARARG(__VA_ARGS__)) + + +#define DEFINE_FAKE_VOID_FUNC_VARARG(...) EXPAND(DEFINE_FUNC_VOID_VARARG_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)) + +#define DEFINE_FUNC_VOID_VARARG_(N,...) EXPAND(DEFINE_FUNC_VOID_VARARG_N(N,__VA_ARGS__)) + +#define DEFINE_FUNC_VOID_VARARG_N(N,...) EXPAND(DEFINE_FAKE_VOID_FUNC ## N ## _VARARG(__VA_ARGS__)) + + + + +#endif /* FAKE_FUNCTIONS */ From 3ed4ffd302da6f8f9dec5db32406999da400d84f Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Thu, 19 Jul 2018 18:31:02 +0100 Subject: [PATCH 043/244] rename memory.[ch] --- include/express/{memory.h => alloc.h} | 0 src/express/{memory.c => alloc.c} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename include/express/{memory.h => alloc.h} (100%) rename src/express/{memory.c => alloc.c} (100%) diff --git a/include/express/memory.h b/include/express/alloc.h similarity index 100% rename from include/express/memory.h rename to include/express/alloc.h diff --git a/src/express/memory.c b/src/express/alloc.c similarity index 100% rename from src/express/memory.c rename to src/express/alloc.c From 7e192a40f32886ae0ca779f869855b4d439647bd Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Thu, 19 Jul 2018 19:19:11 +0100 Subject: [PATCH 044/244] rename everything with MEM prefix to ALLOC prefix and fix includes --- include/express/alg.h | 20 ++++++++--------- include/express/alloc.h | 16 +++++++------- include/express/caseitem.h | 4 ++-- include/express/entity.h | 4 ++-- include/express/error.h | 6 +++--- include/express/expbasic.h | 2 +- include/express/expr.h | 16 +++++++------- include/express/hash.h | 11 +++++----- include/express/linklist.h | 10 ++++----- include/express/schema.h | 12 +++++------ include/express/stmt.h | 44 +++++++++++++++++++------------------- include/express/symbol.h | 6 +++--- include/express/type.h | 8 +++---- include/express/variable.h | 4 ++-- src/express/CMakeLists.txt | 2 +- src/express/alg.c | 8 +++---- src/express/alloc.c | 14 ++++++------ src/express/caseitem.c | 2 +- src/express/entity.c | 2 +- src/express/error.c | 2 +- src/express/expr.c | 8 +++---- src/express/express.c | 2 +- src/express/hash.c | 4 ++-- src/express/lexact.c | 2 +- src/express/linklist.c | 4 ++-- src/express/schema.c | 4 ++-- src/express/scope.c | 2 +- src/express/stmt.c | 22 +++++++++---------- src/express/symbol.c | 2 +- src/express/type.c | 4 ++-- src/express/variable.c | 2 +- 31 files changed, 123 insertions(+), 126 deletions(-) diff --git a/include/express/alg.h b/include/express/alg.h index e37ab1671..bc76c5ddd 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -119,16 +119,16 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /* macro function definitions */ /******************************/ -#define ALG_new() (struct Algorithm *)MEM_new(&ALG_fl); -#define ALG_destroy(x) MEM_destroy(&ALG_fl,(Freelist *)x) -#define FUNC_new() (struct Function_ *)MEM_new(&FUNC_fl) -#define FUNC_destroy(x) MEM_destroy(&FUNC_fl,(Freelist *)x) -#define RULE_new() (struct Rule_ *)MEM_new(&RULE_fl) -#define RULE_destroy(x) MEM_destroy(&RULE_fl,(Freelist *)x) -#define PROC_new() (struct Procedure_ *)MEM_new(&PROC_fl) -#define PROC_destroy(x) MEM_destroy(&PROC_fl,(Freelist *)x) -#define WHERE_new() (struct Where_ *)MEM_new(&WHERE_fl) -#define WHERE_destroy(x) MEM_destroy(&WHERE_fl,(Freelist *)x) +#define ALG_new() (struct Algorithm *)ALLOC_new(&ALG_fl); +#define ALG_destroy(x) ALLOC_destroy(&ALG_fl,(Freelist *)x) +#define FUNC_new() (struct Function_ *)ALLOC_new(&FUNC_fl) +#define FUNC_destroy(x) ALLOC_destroy(&FUNC_fl,(Freelist *)x) +#define RULE_new() (struct Rule_ *)ALLOC_new(&RULE_fl) +#define RULE_destroy(x) ALLOC_destroy(&RULE_fl,(Freelist *)x) +#define PROC_new() (struct Procedure_ *)ALLOC_new(&PROC_fl) +#define PROC_destroy(x) ALLOC_destroy(&PROC_fl,(Freelist *)x) +#define WHERE_new() (struct Where_ *)ALLOC_new(&WHERE_fl) +#define WHERE_destroy(x) ALLOC_destroy(&WHERE_fl,(Freelist *)x) #define ALGput_name(algorithm, name) SCOPEput_name(algorithm,name) #define ALGget_name(algorithm) SCOPEget_name(algorithm) diff --git a/include/express/alloc.h b/include/express/alloc.h index 0c05a8325..79199773a 100644 --- a/include/express/alloc.h +++ b/include/express/alloc.h @@ -1,5 +1,5 @@ -#ifndef MEMORY_H -#define MEMORY_H +#ifndef ALLOC_H +#define ALLOC_H /* * This work was supported by the United States Government, and is @@ -30,7 +30,7 @@ #include -/** \file memory.h - defs for fixed size block memory allocator */ +/** \file alloc.h - defs for fixed size block memory allocator */ typedef long Align; @@ -75,11 +75,11 @@ extern SC_EXPRESS_EXPORT int yylineno; fprintf(stderr,"fedex: out of space");\ } else {} -SC_EXPRESS_EXPORT void _MEMinitialize( void ); -SC_EXPRESS_EXPORT void MEMinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); -SC_EXPRESS_EXPORT void MEM_destroy( struct freelist_head *, Freelist * ); -SC_EXPRESS_EXPORT void * MEM_new( struct freelist_head * ); +SC_EXPRESS_EXPORT void _ALLOCinitialize( void ); +SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); +SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * ); +SC_EXPRESS_EXPORT void * ALLOC_new( struct freelist_head * ); -#endif /* MEMORY_H */ +#endif /* ALLOC_H */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index d5bd4fa4d..1c75f55bd 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -83,8 +83,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; /* function prototypes */ /***********************/ -#define CASE_IT_new() (struct Case_Item_ *)MEM_new(&CASE_IT_fl) -#define CASE_IT_destroy(x) MEM_destroy(&CASE_IT_fl,(Freelist *)x) +#define CASE_IT_new() (struct Case_Item_ *)ALLOC_new(&CASE_IT_fl) +#define CASE_IT_destroy(x) ALLOC_destroy(&CASE_IT_fl,(Freelist *)x) extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); diff --git a/include/express/entity.h b/include/express/entity.h index 8bdc97a78..3440dc9bc 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -109,8 +109,8 @@ extern SC_EXPRESS_EXPORT int ENTITY_MARK; /* macro function definitions */ /******************************/ -#define ENTITY_new() (struct Entity_ *)MEM_new(&ENTITY_fl) -#define ENTITY_destroy(x) MEM_destroy(&ENTITY_fl,(Freelist *)(char *)x) +#define ENTITY_new() (struct Entity_ *)ALLOC_new(&ENTITY_fl) +#define ENTITY_destroy(x) ALLOC_destroy(&ENTITY_fl,(Freelist *)(char *)x) #define ENTITYget_symbol(e) SCOPEget_symbol(e) /* returns a function (i.e., which can be passed to other functions) */ diff --git a/include/express/error.h b/include/express/error.h index bf4effc3e..194885381 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -43,7 +43,7 @@ /* packages used */ /*****************/ -#include "memory.h" +#include "alloc.h" #include "symbol.h" /************/ @@ -110,8 +110,8 @@ extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /* macro function definitions */ /******************************/ -#define ERROR_OPT_new() (struct Error_Warning_ *)MEM_new(&ERROR_OPT_fl) -#define ERROR_OPT_destroy(x) MEM_destroy(&ERROR_OPT_fl,(Freelist *)x) +#define ERROR_OPT_new() (struct Error_Warning_ *)ALLOC_new(&ERROR_OPT_fl) +#define ERROR_OPT_destroy(x) ALLOC_destroy(&ERROR_OPT_fl,(Freelist *)x) /***********************/ /* function prototypes */ diff --git a/include/express/expbasic.h b/include/express/expbasic.h index 509701e16..63ab6e291 100644 --- a/include/express/expbasic.h +++ b/include/express/expbasic.h @@ -54,7 +54,7 @@ typedef void * ClientData; /* packages used throughout */ /****************************/ -#include "memory.h" +#include "alloc.h" typedef struct Scope_ * Type; typedef struct Scope_ * Scope; diff --git a/include/express/expr.h b/include/express/expr.h index 8d13814b2..0d0b2946d 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -207,14 +207,14 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /* macro function definitions */ /******************************/ -#define EXP_new() (struct Expression_ *)MEM_new(&EXP_fl) -#define EXP_destroy(x) MEM_destroy(&EXP_fl,(Freelist *)x) -#define OP_new() (struct Op_Subexpression *)MEM_new(&OP_fl) -#define OP_destroy(x) MEM_destroy(&OP_fl,(Freelist *)x) -#define QUERY_new() (struct Query_ *)MEM_new(&QUERY_fl) -#define QUERY_destroy(x) MEM_destroy(&QUERY_fl,(Freelist *)x) -#define QUAL_ATTR_new() (struct Qualified_Attr *)MEM_new(&QUAL_ATTR_fl) -#define QUAL_ATTR_destroy(x) MEM_destroy(&QUAL_ATTR_fl,(Freelist *)x) +#define EXP_new() (struct Expression_ *)ALLOC_new(&EXP_fl) +#define EXP_destroy(x) ALLOC_destroy(&EXP_fl,(Freelist *)x) +#define OP_new() (struct Op_Subexpression *)ALLOC_new(&OP_fl) +#define OP_destroy(x) ALLOC_destroy(&OP_fl,(Freelist *)x) +#define QUERY_new() (struct Query_ *)ALLOC_new(&QUERY_fl) +#define QUERY_destroy(x) ALLOC_destroy(&QUERY_fl,(Freelist *)x) +#define QUAL_ATTR_new() (struct Qualified_Attr *)ALLOC_new(&QUAL_ATTR_fl) +#define QUAL_ATTR_destroy(x) ALLOC_destroy(&QUAL_ATTR_fl,(Freelist *)x) #define EXPget_name(e) ((e)->symbol.name) #define ENUMget_name(e) ((e)->symbol.name) diff --git a/include/express/hash.h b/include/express/hash.h index b75c3d1d9..c5d1dfffe 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -101,7 +101,7 @@ /*****************/ #include -#include "memory.h" +#include "alloc.h" /************/ /* typedefs */ @@ -183,11 +183,10 @@ This change only seems to have affected hash.h and hash.c #define DIV(x,y) ((x) >> (y)) #define MOD(x,y) ((x) & ((y)-1)) -#define HASH_Table_new() (struct Hash_Table_ *)MEM_new(&HASH_Table_fl) -#define HASH_Table_destroy(x) MEM_destroy(&HASH_Table_fl,(Freelist *)x) -#define HASH_Element_new() (struct Element_ *)MEM_new(&HASH_Element_fl) -#define HASH_Element_destroy(x) MEM_destroy(&HASH_Element_fl,(Freelist *)(char *)x) - +#define HASH_Table_new() (struct Hash_Table_ *)ALLOC_new(&HASH_Table_fl) +#define HASH_Table_destroy(x) ALLOC_destroy(&HASH_Table_fl,(Freelist *)x) +#define HASH_Element_new() (struct Element_ *)ALLOC_new(&HASH_Element_fl) +#define HASH_Element_destroy(x) ALLOC_destroy(&HASH_Element_fl,(Freelist *)(char *)x) /***********************/ /* function prototypes */ diff --git a/include/express/linklist.h b/include/express/linklist.h index b820aa06c..a053e310c 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -38,7 +38,7 @@ #include #include "basic.h" -#include "memory.h" +#include "alloc.h" /************/ /* typedefs */ @@ -78,10 +78,10 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /* macro function definitions */ /******************************/ -#define LINK_new() (struct Link_ *)MEM_new(&LINK_fl) -#define LINK_destroy(x) MEM_destroy(&LINK_fl,(Freelist *)x) -#define LIST_new() (struct Linked_List_ *)MEM_new(&LIST_fl) -#define LIST_destroy(x) MEM_destroy(&LIST_fl,(Freelist *)x) +#define LINK_new() (struct Link_ *)ALLOC_new(&LINK_fl) +#define LINK_destroy(x) ALLOC_destroy(&LINK_fl,(Freelist *)x) +#define LIST_new() (struct Linked_List_ *)ALLOC_new(&LIST_fl) +#define LIST_destroy(x) ALLOC_destroy(&LIST_fl,(Freelist *)x) /** accessing links */ #define LINKdata(link) (link)->data diff --git a/include/express/schema.h b/include/express/schema.h index c44946b70..e7d5d46ec 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -117,12 +117,12 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; #define SCHEMAget_name(schema) SCOPEget_name(schema) #define SCHEMAget_symbol(schema) SCOPEget_symbol(schema) -#define REN_new() (struct Rename *)MEM_new(&REN_fl) -#define REN_destroy(x) MEM_destroy(&REN_fl,(Freelist *)x) -#define SCOPE_new() (struct Scope_ *)MEM_new(&SCOPE_fl) -#define SCOPE_destroy(x) MEM_destroy(&SCOPE_fl,(Freelist *)x) -#define SCHEMA_new() (struct Schema_ *)MEM_new(&SCHEMA_fl) -#define SCHEMA_destroy(x) MEM_destroy(&SCHEMA_fl,(Freelist *)x) +#define REN_new() (struct Rename *)ALLOC_new(&REN_fl) +#define REN_destroy(x) ALLOC_destroy(&REN_fl,(Freelist *)x) +#define SCOPE_new() (struct Scope_ *)ALLOC_new(&SCOPE_fl) +#define SCOPE_destroy(x) ALLOC_destroy(&SCOPE_fl,(Freelist *)x) +#define SCHEMA_new() (struct Schema_ *)ALLOC_new(&SCHEMA_fl) +#define SCHEMA_destroy(x) ALLOC_destroy(&SCHEMA_fl,(Freelist *)x) /* the following is simply to make the resulting code easier to read */ /* otherwise, you'd see "entity->superscope" even when you KNOW */ diff --git a/include/express/stmt.h b/include/express/stmt.h index 7382b2ce0..21f5e4645 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -183,28 +183,28 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /* macro function definitions */ /******************************/ -#define STMT_new() (struct Statement_ *)MEM_new(&STMT_fl) -#define STMT_destroy(x) MEM_destroy(&STMT_fl,(Freelist *)x) - -#define ALIAS_new() (struct Alias_ *)MEM_new(&ALIAS_fl) -#define ALIAS_destroy(x) MEM_destroy(&ALIAS_fl,(Freelist *)x) -#define ASSIGN_new() (struct Assignment_ *)MEM_new(&ASSIGN_fl) -#define ASSIGN_destroy(x) MEM_destroy(&ASSIGN_fl,(Freelist *)x) -#define CASE_new() (struct Case_Statement_ *)MEM_new(&CASE_fl) -#define CASE_destroy(x) MEM_destroy(&CASE_fl,(Freelist *)x) -#define COMP_STMT_new() (struct Compound_Statement_ *)MEM_new(&COMP_STMT_fl) -#define COMP_STMT_destroy(x) MEM_destroy(&COMP_STMT_fl,(Freelist *)x) -#define COND_new() (struct Conditional_ *)MEM_new(&COND_fl) -#define COND_destroy(x) MEM_destroy(&COND_fl,(Freelist *)x) -#define LOOP_new() (struct Loop_ *)MEM_new(&LOOP_fl) -#define LOOP_destroy(x) MEM_destroy(&LOOP_fl,(Freelist *)x) -#define PCALL_new() (struct Procedure_Call_ *)MEM_new(&PCALL_fl) -#define PCALL_destroy(x) MEM_destroy(&PCALL_fl,(Freelist *)x) -#define RET_new() (struct Return_Statement_ *)MEM_new(&RET_fl) -#define RET_destroy(x) MEM_destroy(&RET_fl,(Freelist *)x) - -#define INCR_new() (struct Increment_ *)MEM_new(&INCR_fl) -#define INCR_destroy(x) MEM_destroy(&INCR_fl,(Freelist *)(char *)x) +#define STMT_new() (struct Statement_ *)ALLOC_new(&STMT_fl) +#define STMT_destroy(x) ALLOC_destroy(&STMT_fl,(Freelist *)x) + +#define ALIAS_new() (struct Alias_ *)ALLOC_new(&ALIAS_fl) +#define ALIAS_destroy(x) ALLOC_destroy(&ALIAS_fl,(Freelist *)x) +#define ASSIGN_new() (struct Assignment_ *)ALLOC_new(&ASSIGN_fl) +#define ASSIGN_destroy(x) ALLOC_destroy(&ASSIGN_fl,(Freelist *)x) +#define CASE_new() (struct Case_Statement_ *)ALLOC_new(&CASE_fl) +#define CASE_destroy(x) ALLOC_destroy(&CASE_fl,(Freelist *)x) +#define COMP_STMT_new() (struct Compound_Statement_ *)ALLOC_new(&COMP_STMT_fl) +#define COMP_STMT_destroy(x) ALLOC_destroy(&COMP_STMT_fl,(Freelist *)x) +#define COND_new() (struct Conditional_ *)ALLOC_new(&COND_fl) +#define COND_destroy(x) ALLOC_destroy(&COND_fl,(Freelist *)x) +#define LOOP_new() (struct Loop_ *)ALLOC_new(&LOOP_fl) +#define LOOP_destroy(x) ALLOC_destroy(&LOOP_fl,(Freelist *)x) +#define PCALL_new() (struct Procedure_Call_ *)ALLOC_new(&PCALL_fl) +#define PCALL_destroy(x) ALLOC_destroy(&PCALL_fl,(Freelist *)x) +#define RET_new() (struct Return_Statement_ *)ALLOC_new(&RET_fl) +#define RET_destroy(x) ALLOC_destroy(&RET_fl,(Freelist *)x) + +#define INCR_new() (struct Increment_ *)ALLOC_new(&INCR_fl) +#define INCR_destroy(x) ALLOC_destroy(&INCR_fl,(Freelist *)(char *)x) #define ASSIGNget_lhs(s) ((s)->u.assign->lhs) #define ASSIGNget_rhs(s) ((s)->u.assign->rhs) diff --git a/include/express/symbol.h b/include/express/symbol.h index eb4a0235d..b589b01e2 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -45,7 +45,7 @@ #include #include "basic.h" /* get basic definitions */ -#include "memory.h" +#include "alloc.h" /************/ /* typedefs */ @@ -78,8 +78,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /* macro function definitions */ /******************************/ -#define SYMBOL_new() (struct Symbol_ *)MEM_new(&SYMBOL_fl) -#define SYMBOL_destroy(x) MEM_destroy(&SYMBOL_fl,(Freelist *)x) +#define SYMBOL_new() (struct Symbol_ *)ALLOC_new(&SYMBOL_fl) +#define SYMBOL_destroy(x) ALLOC_destroy(&SYMBOL_fl,(Freelist *)x) #define SYMBOLset(obj) obj->symbol.line = yylineno; \ obj->symbol.filename = current_filename diff --git a/include/express/type.h b/include/express/type.h index 4ac2f4089..46e9147b7 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -223,10 +223,10 @@ extern SC_EXPRESS_EXPORT Error ERROR_corrupted_type; /* macro function definitions */ /******************************/ -#define TYPEHEAD_new() (struct TypeHead_ *)MEM_new(&TYPEHEAD_fl) -#define TYPEHEAD_destroy(x) MEM_destroy(&TYPEHEAD_fl,(Freelist *)x) -#define TYPEBODY_new() (struct TypeBody_ *)MEM_new(&TYPEBODY_fl) -#define TYPEBODY_destroy(x) MEM_destroy(&TYPEBODY_fl,(Freelist *)x) +#define TYPEHEAD_new() (struct TypeHead_ *)ALLOC_new(&TYPEHEAD_fl) +#define TYPEHEAD_destroy(x) ALLOC_destroy(&TYPEHEAD_fl,(Freelist *)x) +#define TYPEBODY_new() (struct TypeBody_ *)ALLOC_new(&TYPEBODY_fl) +#define TYPEBODY_destroy(x) ALLOC_destroy(&TYPEBODY_fl,(Freelist *)x) #define TYPEis(t) ((t)->u.type->body->type) #define TYPEis_identifier(t) ((t)->u.type->body->type == identifier_) diff --git a/include/express/variable.h b/include/express/variable.h index aa31eda2d..308116459 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -105,8 +105,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /* macro function definitions */ /******************************/ -#define VAR_new() (struct Variable_ *)MEM_new(&VAR_fl) -#define VAR_destroy(x) MEM_destroy(&VAR_fl,(Freelist *)x) +#define VAR_new() (struct Variable_ *)ALLOC_new(&VAR_fl) +#define VAR_destroy(x) ALLOC_destroy(&VAR_fl,(Freelist *)x) #define VARget_name(v) ((v)->name) #define VARput_name(v,n) ((v)->name = (n)) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index ece841bf2..74395d6fa 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -77,7 +77,7 @@ set(EXPRESS_SOURCES error.c dict.c hash.c - memory.c + alloc.c object.c express.c ordered_attrs.cc diff --git a/src/express/alg.c b/src/express/alg.c index 671c6dce4..23ecc07bf 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -79,10 +79,10 @@ Symbol * WHERE_get_symbol( void *w ) { /** Initialize the Algorithm module. */ void ALGinitialize( void ) { - MEMinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); - MEMinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); - MEMinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); - MEMinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); + ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); + ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); + ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); + ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); OBJcreate( OBJ_RULE, SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS ); OBJcreate( OBJ_PROCEDURE, SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS ); OBJcreate( OBJ_FUNCTION, SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS ); diff --git a/src/express/alloc.c b/src/express/alloc.c index 83edb15cb..dfc3572f3 100644 --- a/src/express/alloc.c +++ b/src/express/alloc.c @@ -1,6 +1,4 @@ -#define MEMORY_C - -/* mem.c - memory allocator for fixed size blocks */ +/* alloc.c - memory allocator for fixed size blocks */ /* @@ -37,7 +35,7 @@ Now you can say things like: #include #include #include -#include "express/memory.h" +#include "express/alloc.h" #include "express/error.h" /* just in case we are compiling by hand */ @@ -77,7 +75,7 @@ Freelist * create_freelist( struct freelist_head * flh, int bytes ) { } void -_MEMinitialize() { +_ALLOCinitialize() { #ifdef DEBUG_MALLOC malloc_debug( 2 ); #endif @@ -89,7 +87,7 @@ _MEMinitialize() { * \param alloc1 number to allocate initially * \param alloc2 number to allocate if we run out */ -void MEMinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) { +void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) { flh->size_elt = size; /* kludge for calloc-like behavior */ #ifndef NOSTAT flh->alloc = flh->dealloc = flh->create = 0; @@ -116,7 +114,7 @@ void MEMinitialize( struct freelist_head * flh, unsigned int size, int alloc1, i #endif } -void * MEM_new( struct freelist_head * flh ) { +void * ALLOC_new( struct freelist_head * flh ) { void *obj; #ifndef NOSTAT @@ -151,7 +149,7 @@ void * MEM_new( struct freelist_head * flh ) { #endif } -void MEM_destroy( struct freelist_head * flh, Freelist * link ) { +void ALLOC_destroy( struct freelist_head * flh, Freelist * link ) { #ifndef NOSTAT flh->dealloc++; #endif diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 6082cc755..3fb72b23e 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -37,7 +37,7 @@ struct freelist_head CASE_IT_fl; /** Initialize the Case Item module. */ void CASE_ITinitialize( void ) { - MEMinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); + ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); } /** diff --git a/src/express/entity.c b/src/express/entity.c index efde2a182..df4f2a59f 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -320,7 +320,7 @@ Entity ENTITYcopy( Entity e ) { /** Initialize the Entity module. */ void ENTITYinitialize() { - MEMinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); + ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); OBJcreate( OBJ_ENTITY, SCOPE_get_symbol, "entity", OBJ_ENTITY_BITS ); } diff --git a/src/express/error.c b/src/express/error.c index 2ad356f8e..ebb33977d 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -189,7 +189,7 @@ void ERRORcleanup( void ) { void ERRORinitialize_after_LIST( void ) { ERRORwarnings = LISTcreate(); - MEMinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 ); + ALLOCinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 ); } void ERRORcreate_warning( char * name, Error error ) { diff --git a/src/express/expr.c b/src/express/expr.c index 58fe1b157..80bdd911d 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -152,10 +152,10 @@ Symbol * EXP_get_symbol( void *e ) { /** Description: Initialize the Expression module. */ void EXPinitialize( void ) { - MEMinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); - MEMinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); - MEMinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); - MEMinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); + ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); + ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); + ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); + ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); OBJcreate( OBJ_EXPRESSION, EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS ); OBJcreate( OBJ_AMBIG_ENUM, EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS ); diff --git a/src/express/express.c b/src/express/express.c index b895770fe..d848061d3 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -274,7 +274,7 @@ void EXPRESSinitialize( void ) { Procedure proc_insert, proc_remove; - _MEMinitialize(); + _ALLOCinitialize(); ERRORinitialize(); OBJinitialize(); diff --git a/src/express/hash.c b/src/express/hash.c index fc3e4d9bf..42223b117 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -136,10 +136,10 @@ static long HashAccesses, HashCollisions; void HASHinitialize() { if( HASH_Table_fl.size_elt == 0 ) { - MEMinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); + ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); } if( HASH_Element_fl.size_elt == 0 ) { - MEMinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); + ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); } } diff --git a/src/express/lexact.c b/src/express/lexact.c index 8fcb803e9..fc9c064cf 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -61,7 +61,7 @@ #include "express/hash.h" #include "express/express.h" #include "express/dict.h" -#include "express/memory.h" +#include "express/alloc.h" #include "token_type.h" #include "expparse.h" #include "expscan.h" diff --git a/src/express/linklist.c b/src/express/linklist.c index 53fa4ff94..37791f6c5 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -29,8 +29,8 @@ struct freelist_head LINK_fl; struct freelist_head LIST_fl; void LISTinitialize( void ) { - MEMinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); - MEMinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); + ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); + ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); ERROR_empty_list = ERRORcreate( "Empty list in %s.", SEVERITY_ERROR ); } diff --git a/src/express/schema.c b/src/express/schema.c index 6f6a0d521..abddda40d 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -64,8 +64,8 @@ Symbol * RENAME_get_symbol( void *r ) { /** Initialize the Schema module. */ void SCHEMAinitialize( void ) { OBJcreate( OBJ_RENAME, RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS ); - MEMinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); - MEMinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); + ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); + ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); } /** Create and return an empty scope inside a parent scope. */ diff --git a/src/express/scope.c b/src/express/scope.c index 9fb53d0c9..8fbf81039 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -50,7 +50,7 @@ Symbol * SCOPE_get_symbol( void *s ) { void SCOPEinitialize( void ) { OBJcreate( OBJ_SCHEMA, SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS ); - MEMinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); + ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); } /** diff --git a/src/express/stmt.c b/src/express/stmt.c index 77e7ef2d7..384f981b6 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -68,17 +68,17 @@ Statement STMTcreate( int type ) { /** Initialize the Statement module. */ void STMTinitialize( void ) { - MEMinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); - - MEMinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); - MEMinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); - MEMinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); - MEMinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); - MEMinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); - MEMinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); - MEMinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); - MEMinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); - MEMinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); + ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); + + ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); + ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); + ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); + ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); + ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); + ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); + ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); + ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); + ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); OBJcreate( OBJ_ALIAS, SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS ); OBJcreate( OBJ_INCREMENT, SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS ); diff --git a/src/express/symbol.c b/src/express/symbol.c index a70e38b5a..34dfa04c7 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -39,7 +39,7 @@ struct freelist_head SYMBOL_fl; /** Initialize the Symbol module */ void SYMBOLinitialize( void ) { - MEMinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); + ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); } Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { diff --git a/src/express/type.c b/src/express/type.c index 235bead9b..6ea04db27 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -316,8 +316,8 @@ Symbol * TYPE_get_symbol( void *t ) { /** Initialize the Type module */ void TYPEinitialize() { - MEMinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); - MEMinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); + ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); + ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); OBJcreate( OBJ_TYPE, TYPE_get_symbol, "type", OBJ_TYPE_BITS ); /* OBJcreate(OBJ_TYPE,TYPE_get_symbol,"(headless) type", OBJ_UNFINDABLE_BITS);*/ OBJcreate( OBJ_TAG, TYPE_get_symbol, "tag", OBJ_TYPE_BITS ); diff --git a/src/express/variable.c b/src/express/variable.c index bb1c7fec3..65b348255 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -97,7 +97,7 @@ Symbol * VAR_get_symbol( void *v ) { /** Initialize the Variable module. */ void VARinitialize() { - MEMinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); + ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); /* OBJcreate(OBJ_VARIABLE,VAR_get_symbol,"variable",OBJ_UNUSED_BITS);*/ OBJcreate( OBJ_VARIABLE, VAR_get_symbol, "variable", OBJ_VARIABLE_BITS ); } From 3c785b4451c9468e02efb99d1d1b4c7fc02c7634 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Fri, 20 Jul 2018 12:01:56 +0100 Subject: [PATCH 045/244] move all allocator setup to new memory.c (initially just for tests) --- include/express/memory.h | 6 +++ src/express/CMakeLists.txt | 1 + src/express/caseitem.c | 1 - src/express/entity.c | 1 - src/express/error.c | 1 - src/express/expr.c | 5 -- src/express/hash.c | 3 -- src/express/linklist.c | 2 - src/express/memory.c | 102 +++++++++++++++++++++++++++++++++++++ src/express/schema.c | 2 - src/express/symbol.c | 2 - src/express/type.c | 3 -- src/express/variable.c | 2 - 13 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 include/express/memory.h create mode 100644 src/express/memory.c diff --git a/include/express/memory.h b/include/express/memory.h new file mode 100644 index 000000000..bd91f2e41 --- /dev/null +++ b/include/express/memory.h @@ -0,0 +1,6 @@ +#ifndef __MEMORY_H +#define __MEMORY_H + +void MEMinit(); + +#endif // __MEMORY_H diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 74395d6fa..be8852228 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -78,6 +78,7 @@ set(EXPRESS_SOURCES dict.c hash.c alloc.c + memory.c object.c express.c ordered_attrs.cc diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 3fb72b23e..f0dbc5ef1 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -32,7 +32,6 @@ #include #include "express/caseitem.h" -struct freelist_head CASE_IT_fl; /** Initialize the Case Item module. */ void diff --git a/src/express/entity.c b/src/express/entity.c index df4f2a59f..7043c7e2c 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -118,7 +118,6 @@ #include "express/express.h" #include "express/object.h" -struct freelist_head ENTITY_fl; int ENTITY_MARK = 0; /** returns true if variable is declared (or redeclared) directly by entity */ diff --git a/src/express/error.c b/src/express/error.c index ebb33977d..29ae1dcc0 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -90,7 +90,6 @@ int malloc_debug_resolve = 0; int debug = 0; struct Linked_List_ * ERRORwarnings; -struct freelist_head ERROR_OPT_fl; void ( *ERRORusage_function )( void ); diff --git a/src/express/expr.c b/src/express/expr.c index 80bdd911d..e8c1eab28 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -90,11 +90,6 @@ Error ERROR_integer_expression_expected = ERROR_none; Error ERROR_implicit_downcast = ERROR_none; Error ERROR_ambig_implicit_downcast = ERROR_none; -struct freelist_head EXP_fl; -struct freelist_head OP_fl; -struct freelist_head QUERY_fl; -struct freelist_head QUAL_ATTR_fl; - void EXPop_init(); static Error ERROR_internal_unrecognized_op_in_EXPresolve; /* following two could probably be combined */ diff --git a/src/express/hash.c b/src/express/hash.c index 42223b117..4a83ca460 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -111,9 +111,6 @@ #include #include "express/hash.h" -struct freelist_head HASH_Table_fl; -struct freelist_head HASH_Element_fl; - /* ** Internal routines */ diff --git a/src/express/linklist.c b/src/express/linklist.c index 37791f6c5..ba52ea4b2 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -25,8 +25,6 @@ #include "express/linklist.h" Error ERROR_empty_list = ERROR_none; -struct freelist_head LINK_fl; -struct freelist_head LIST_fl; void LISTinitialize( void ) { ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); diff --git a/src/express/memory.c b/src/express/memory.c new file mode 100644 index 000000000..6b3d7e6a4 --- /dev/null +++ b/src/express/memory.c @@ -0,0 +1,102 @@ +#include "express/memory.h" + +#include "express/alloc.h" + +#include "express/hash.h" +#include "express/symbol.h" +#include "express/schema.h" +#include "express/type.h" + +struct freelist_head HASH_Table_fl; +struct freelist_head HASH_Element_fl; + +struct freelist_head LINK_fl; +struct freelist_head LIST_fl; + +struct freelist_head ERROR_OPT_fl; + +struct freelist_head SYMBOL_fl; + +struct freelist_head SCOPE_fl; +struct freelist_head SCHEMA_fl; + +struct freelist_head TYPEHEAD_fl; +struct freelist_head TYPEBODY_fl; + +struct freelist_head VAR_fl; + +struct freelist_head FUNC_fl; +struct freelist_head RULE_fl; +struct freelist_head PROC_fl; +struct freelist_head WHERE_fl; + +struct freelist_head ENTITY_fl; + +struct freelist_head CASE_IT_fl; + +struct freelist_head EXP_fl; +struct freelist_head OP_fl; +struct freelist_head QUERY_fl; +struct freelist_head QUAL_ATTR_fl; + +struct freelist_head STMT_fl; +struct freelist_head ALIAS_fl; +struct freelist_head ASSIGN_fl; +struct freelist_head CASE_fl; +struct freelist_head COMP_STMT_fl; +struct freelist_head COND_fl; +struct freelist_head LOOP_fl; +struct freelist_head PCALL_fl; +struct freelist_head RET_fl; +struct freelist_head INCR_fl; + +void MEMinit() { + _ALLOCinitialize(); + + ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); + ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); + + ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); + ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); + + ALLOCinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 ); + + ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); + + ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); + + ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); + ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); + + ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); + + ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); + ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); + ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); + ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); + + ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); + + ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); + + ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); + + ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); + ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); + ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); + ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); + + ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); + + ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); + ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); + ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); + ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); + ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); + ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); + ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); + ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); + ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); + +} + diff --git a/src/express/schema.c b/src/express/schema.c index abddda40d..3c43664dc 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -52,8 +52,6 @@ #include "express/resolve.h" struct freelist_head REN_fl; -struct freelist_head SCOPE_fl; -struct freelist_head SCHEMA_fl; int __SCOPE_search_id = 0; diff --git a/src/express/symbol.c b/src/express/symbol.c index 34dfa04c7..fa230677c 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -35,8 +35,6 @@ #include #include "express/symbol.h" -struct freelist_head SYMBOL_fl; - /** Initialize the Symbol module */ void SYMBOLinitialize( void ) { ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); diff --git a/src/express/type.c b/src/express/type.c index 6ea04db27..f75436009 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -159,9 +159,6 @@ Type Type_Set_Of_String; Type Type_Set_Of_Generic; Type Type_Bag_Of_Generic; -struct freelist_head TYPEHEAD_fl; -struct freelist_head TYPEBODY_fl; - Error ERROR_corrupted_type = ERROR_none; static Error ERROR_undefined_tag; diff --git a/src/express/variable.c b/src/express/variable.c index 65b348255..1de22797e 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -89,8 +89,6 @@ #include "express/object.h" char * opcode_print( Op_Code o ); -struct freelist_head VAR_fl; - Symbol * VAR_get_symbol( void *v ) { return( &( ( Variable )v )->name->symbol ); } From 4b58b2dc110ddeb72b908e5a1612c8e2850ae989 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Fri, 20 Jul 2018 12:05:24 +0100 Subject: [PATCH 046/244] start to move object creation routines to factory.c --- src/express/CMakeLists.txt | 1 + src/express/factory.c | 105 +++++++++++++++++++++++++++++++++++++ src/express/schema.c | 35 ------------- src/express/symbol.c | 13 ----- src/express/type.c | 50 ------------------ 5 files changed, 106 insertions(+), 98 deletions(-) create mode 100644 src/express/factory.c diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index be8852228..4b377d722 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -84,6 +84,7 @@ set(EXPRESS_SOURCES ordered_attrs.cc info.c exp_kw.c + factory.c ) set(EXPRESS_OBJS) diff --git a/src/express/factory.c b/src/express/factory.c new file mode 100644 index 000000000..388484a76 --- /dev/null +++ b/src/express/factory.c @@ -0,0 +1,105 @@ +#include "express/schema.h" +#include "express/type.h" + +#include "express/dict.h" + +/** Create and return an empty scope inside a parent scope. */ +Scope SCOPEcreate( char type ) { + Scope d = SCOPE_new(); + d->symbol_table = DICTcreate( 50 ); + d->type = type; + return d; +} + +Scope SCOPEcreate_tiny( char type ) { + Scope d = SCOPE_new(); + d->symbol_table = DICTcreate( 1 ); + d->type = type; + return d; +} + +void SCOPEdestroy( Scope scope ) { + SCOPE_destroy( scope ); +} + +/** + * create a scope without a symbol table + * used for simple types + */ +Scope SCOPEcreate_nostab( char type ) { + Scope d = SCOPE_new(); + d->type = type; + return d; +} + +/** Create and return a schema. */ +Schema SCHEMAcreate( void ) { + Scope s = SCOPEcreate( OBJ_SCHEMA ); + s->enum_table = DICTcreate(50); + s->u.schema = SCHEMA_new(); + return s; +} + +/** + * create a type with no symbol table + */ +Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); + TypeHead th = TYPEHEAD_new(); + + t->u.type = th; + t->symbol = *symbol; + DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); + + return t; +} + +/** + * create a type but this is just a shell, either to be completed later + * such as enumerations (which have a symbol table added later) + * or to be used as a type reference + */ +Type TYPEcreate_name( Symbol * symbol ) { + Scope s = SCOPEcreate_nostab( OBJ_TYPE ); + TypeHead t = TYPEHEAD_new(); + + s->u.type = t; + s->symbol = *symbol; + return s; +} + +Type TYPEcreate( enum type_enum type ) { + TypeBody tb = TYPEBODYcreate( type ); + Type t = TYPEcreate_from_body_anonymously( tb ); + return( t ); +} + +Type TYPEcreate_from_body_anonymously( TypeBody tb ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); + TypeHead th = TYPEHEAD_new(); + + t->u.type = th; + t->u.type->body = tb; + t->symbol.name = 0; + SYMBOLset( t ); + return t; +} + +TypeBody TYPEBODYcreate( enum type_enum type ) { + TypeBody tb = TYPEBODY_new(); + tb->type = type; + return tb; +} + +Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { + Symbol * sym = SYMBOL_new(); + sym->name = name; + sym->line = line; + sym->filename = filename; /* NOTE this used the global 'current_filename', + * instead of 'filename'. This func is only + * called in two places, and both calls use + * 'current_filename'. Changed this to avoid + * potential future headaches. (MAP, Jan 12) + */ + return sym; +} diff --git a/src/express/schema.c b/src/express/schema.c index 3c43664dc..aa6765be4 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -66,41 +66,6 @@ void SCHEMAinitialize( void ) { ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); } -/** Create and return an empty scope inside a parent scope. */ -Scope SCOPEcreate( char type ) { - Scope d = SCOPE_new(); - d->symbol_table = DICTcreate( 50 ); - d->type = type; - return d; -} - -Scope SCOPEcreate_tiny( char type ) { - Scope d = SCOPE_new(); - d->symbol_table = DICTcreate( 1 ); - d->type = type; - return d; -} - -void SCOPEdestroy( Scope scope ) { - SCOPE_destroy( scope ); -} - -/** - * create a scope without a symbol table - * used for simple types - */ -Scope SCOPEcreate_nostab( char type ) { - Scope d = SCOPE_new(); - d->type = type; - return d; -} - -/** Create and return a schema. */ -Schema SCHEMAcreate( void ) { - Scope s = SCOPEcreate( OBJ_SCHEMA ); - s->u.schema = SCHEMA_new(); - return s; -} /** SCHEMAget_name ** \param schema schema to examine diff --git a/src/express/symbol.c b/src/express/symbol.c index fa230677c..aa7d6fcf6 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -39,16 +39,3 @@ void SYMBOLinitialize( void ) { ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); } - -Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { - Symbol * sym = SYMBOL_new(); - sym->name = name; - sym->line = line; - sym->filename = filename; /* NOTE this used the global 'current_filename', - * instead of 'filename'. This func is only - * called in two places, and both calls use - * 'current_filename'. Changed this to avoid - * potential future headaches. (MAP, Jan 12) - */ - return sym; -} diff --git a/src/express/type.c b/src/express/type.c index f75436009..07e15695c 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -162,33 +162,6 @@ Type Type_Bag_Of_Generic; Error ERROR_corrupted_type = ERROR_none; static Error ERROR_undefined_tag; -/** - * create a type with no symbol table - */ -Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { - Type t = SCOPEcreate_nostab( OBJ_TYPE ); - TypeHead th = TYPEHEAD_new(); - - t->u.type = th; - t->symbol = *symbol; - DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); - - return t; -} - -/** - * create a type but this is just a shell, either to be completed later - * such as enumerations (which have a symbol table added later) - * or to be used as a type reference - */ -Type TYPEcreate_name( Symbol * symbol ) { - Scope s = SCOPEcreate_nostab( OBJ_TYPE ); - TypeHead t = TYPEHEAD_new(); - - s->u.type = t; - s->symbol = *symbol; - return s; -} Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) { Type t; @@ -229,29 +202,6 @@ Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol return( t ); } -Type TYPEcreate( enum type_enum type ) { - TypeBody tb = TYPEBODYcreate( type ); - Type t = TYPEcreate_from_body_anonymously( tb ); - return( t ); -} - -Type TYPEcreate_from_body_anonymously( TypeBody tb ) { - Type t = SCOPEcreate_nostab( OBJ_TYPE ); - TypeHead th = TYPEHEAD_new(); - - t->u.type = th; - t->u.type->body = tb; - t->symbol.name = 0; - SYMBOLset( t ); - return t; -} - -TypeBody TYPEBODYcreate( enum type_enum type ) { - TypeBody tb = TYPEBODY_new(); - tb->type = type; - return tb; -} - /** * return true if "type t" inherits from "enum type_enum" * may need to be implemented for more types From a25ee56f6ce9a3bb5deac97c5738ce4e5efbe72e Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Fri, 20 Jul 2018 12:14:18 +0100 Subject: [PATCH 047/244] add test for EXPresolve_op_dot --- src/express/test/CMakeLists.txt | 7 +- src/express/test/test_expr.c | 151 ++++++++++++++++++++------------ 2 files changed, 97 insertions(+), 61 deletions(-) diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 85d9a6b8f..3aeb9fb86 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -1,7 +1,9 @@ include_directories(..) set(EXPRESS_CORE_OBJ + $ $ + $ $ $ $ @@ -11,9 +13,8 @@ set(EXPRESS_CORE_OBJ $ ) -add_executable(test_expr test_expr.c - $ - ${EXPRESS_CORE_OBJ}) +add_executable(test_expr test_expr.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME expr_resolve_op_dot COMMAND test_expr resolve_op_dot) add_test(NAME build_check_express WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 24ef14c65..123ffbf7b 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -1,6 +1,11 @@ +#include +#include +#include + #include "express/expr.h" /* core */ +#include "express/alloc.h" #include "express/memory.h" #include "express/error.h" #include "express/hash.h" @@ -8,38 +13,20 @@ /* non-core */ #include "express/dict.h" -#include "express/object.h" -#include "express/info.h" - -/* - * missing header definition - */ -Type EXPresolve_op_dot( Expression expr, Scope scope ); -/* - * TODO: keep interface, but refactor for test - */ -void EXPRESSinitialize( void ) {} +#include "fff.h" -/* - * TODO: move to error.c - */ -int EXPRESS_fail( Express model ) { return 1; } +DEFINE_FFF_GLOBALS /* - * TODO: move to memory.c + * missing header definition */ -Type TYPEcreate( enum type_enum type ) { return NULL; } -Type TYPEcreate_name( Symbol * symbol ) { return NULL; } -TypeBody TYPEBODYcreate( enum type_enum type ) { return NULL; } - -Schema SCHEMAcreate( void ) { return NULL; } -Symbol *SYMBOLcreate( char * name, int line, const char * filename ) { return NULL; } +Type EXPresolve_op_dot( Expression expr, Scope scope ); /* * mock globals - * TODO: what needs initialising? */ + char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -65,49 +52,49 @@ Error WARNING_case_skip_label; Error ERROR_undefined_attribute; /* - * TODO: mock functions + * mock functions */ -Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, struct Symbol_ ** down_sym ) { return NULL; } - -void EXP_resolve( Expression expr, Scope scope, Type typecheck ) {} -Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { return NULL; } +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) +FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) +FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) +FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) +FAKE_VALUE_FUNC(Variable, VARcreate, Expression, Type) +FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) -struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { return NULL; } - -Scope SCOPEcreate_tiny( char type ) { return NULL; } - -Variable VARcreate( Expression name, Type type ) { return NULL; } +void setup() { + Type_Identifier = TYPEcreate(identifier_); +} +/* + * mock resolve operation + */ +void EXP_resolve_handler(Expression exp, Scope cxt, Type typ) { + (void) typ; + Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); + exp->type = res_typ; + exp->return_type = res_typ; + exp->symbol.resolved = RESOLVED; +} -int main(int argc, char *argv[]) { +int test_resolve_op_dot() { Schema scope; Symbol *e_type_id, *enum_id, *s_type_id; - Type enum_typ, select_typ; + Type enum_typ, select_typ, chk_typ; TypeBody tb; Expression expr, op1, op2, exp_enum_id; /* - * setup + * boilerplate: create objects, populate symbol tables */ - EXPRESSinitialize(); - Type_Identifier = TYPEcreate(identifier_); - - /* TODO: SCHEMAcreate should do this */ scope = SCHEMAcreate(); - if (!scope->symbol_table) - scope->symbol_table = DICTcreate(50); - if (!scope->enum_table) - scope->enum_table = DICTcreate(50); - - /* - * initial code to faciliate code path under test (use of DICT_type) - */ + s_type_id = SYMBOLcreate("sel1", 1, "test1"); e_type_id = SYMBOLcreate("enum1", 1, "test1"); enum_id = SYMBOLcreate("val1", 1, "test1"); enum_typ = TYPEcreate_name(e_type_id); + enum_typ->symbol_table = DICTcreate(50); exp_enum_id = EXPcreate(enum_typ); exp_enum_id->symbol = *enum_id; @@ -120,14 +107,8 @@ int main(int argc, char *argv[]) { DICT_define(scope->symbol_table, e_type_id->name, enum_typ, &enum_typ->symbol, OBJ_TYPE); - /* - * TODO: someone did half a job with OBJ_ENUM / OBJ_EXPRESSION - * now it's confusing when reading the source - */ + /* TODO: OBJ_ENUM / OBJ_EXPRESSION are used interchangeably, this is confusing. */ DICT_define(scope->enum_table, exp_enum_id->symbol.name, exp_enum_id, &exp_enum_id->symbol, OBJ_EXPRESSION); - - if (!enum_typ->symbol_table) - enum_typ->symbol_table = DICTcreate(50); DICT_define(enum_typ->symbol_table, enum_id->name, exp_enum_id, enum_id, OBJ_EXPRESSION); select_typ = TYPEcreate_name(s_type_id); @@ -142,13 +123,67 @@ int main(int argc, char *argv[]) { expr = BIN_EXPcreate(OP_DOT, op1, op2); /* - * test: enum_ref '.' enum_id + * test: sel_ref '.' enum_id + * expectation: enum_typ */ - EXPresolve_op_dot(expr, scope); + EXP_resolve_fake.custom_fake = EXP_resolve_handler; + + chk_typ = EXPresolve_op_dot(expr, scope); + + assert(EXP_resolve_fake.call_count == 1); + assert(expr->e.op1->type == select_typ); + assert(chk_typ == enum_typ); - /* in case of error will exit via abort() */ + /* in case of error SIGABRT will be raised (and non-zero returned) */ return 0; } +struct test_def { + const char *name; + int (*testfunc) (void); +}; + +int main(int argc, char *argv[]) { + int status; + + struct test_def tests[] = { + {"resolve_op_dot", test_resolve_op_dot} + }; + + /* enable libexpress allocator */ + MEMinit(); + + argc--; + status = 0; + if (argc) { + int test_counter = argc; + + /* selected tests */ + for (int i=1; i <= argc; i++) { + for (unsigned int j=0; j < (sizeof tests / sizeof tests[0]); j++) { + const char *test_name = tests[j].name; + int (*test_ptr) (void) = tests[j].testfunc; + + if (!strcmp(argv[i], test_name)) { + test_counter--; + setup(); + status |= test_ptr(); + } + } + } + + if (test_counter) + fprintf(stderr, "WARNING: some tests not found...\n"); + } else { + /* all tests */ + for (unsigned int j=0; j < (sizeof tests / sizeof tests[0]); j++) { + int (*test_ptr) (void) = tests[j].testfunc; + status |= test_ptr(); + } + } + + return status; +} + /* TODO: additional test for entity_ attribute, variable */ From 18f81e18983fa0d0f1258f7d06cf0e6df674a819 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 21 Jul 2018 13:51:59 +0100 Subject: [PATCH 048/244] move VARcreate and ENTITYcreate to factory.c --- src/express/entity.c | 21 --------------------- src/express/factory.c | 38 ++++++++++++++++++++++++++++++++++++++ src/express/variable.c | 17 ----------------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/express/entity.c b/src/express/entity.c index 7043c7e2c..b4ec31144 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -285,27 +285,6 @@ Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) return attr; } -/** -** low-level function for type Entity -** -** \note The attribute list of a new entity is defined as an -** empty list; all other aspects of the entity are initially -** undefined (i.e., have appropriate NULL values). -*/ -Entity ENTITYcreate( Symbol * sym ) { - Scope s = SCOPEcreate( OBJ_ENTITY ); - - s->u.entity = ENTITY_new(); - s->u.entity->attributes = LISTcreate(); - s->u.entity->inheritance = ENTITY_INHERITANCE_UNINITIALIZED; - - /* it's so useful to have a type hanging around for each entity */ - s->u.entity->type = TYPEcreate_name( sym ); - s->u.entity->type->u.type->body = TYPEBODYcreate( entity_ ); - s->u.entity->type->u.type->body->entity = s; - return( s ); -} - /** * currently, this is only used by USEresolve * low-level function for type Entity diff --git a/src/express/factory.c b/src/express/factory.c index 388484a76..cb2fb9f7a 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -103,3 +103,41 @@ Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { */ return sym; } + +/** +** low-level function for type Entity +** +** \note The attribute list of a new entity is defined as an +** empty list; all other aspects of the entity are initially +** undefined (i.e., have appropriate NULL values). +*/ +Entity ENTITYcreate( Symbol * sym ) { + Scope s = SCOPEcreate( OBJ_ENTITY ); + + s->u.entity = ENTITY_new(); + s->u.entity->attributes = LISTcreate(); + s->u.entity->inheritance = ENTITY_INHERITANCE_UNINITIALIZED; + + /* it's so useful to have a type hanging around for each entity */ + s->u.entity->type = TYPEcreate_name( sym ); + s->u.entity->type->u.type->body = TYPEBODYcreate( entity_ ); + s->u.entity->type->u.type->body->entity = s; + return( s ); +} + +/** VARcreate +** \param name name of variable to create +** \param type type of new variable +** \return the Variable created +** Create and return a new variable. +** +** \note The reference class of the variable is, by default, +** dynamic. Special flags associated with the variable +** (e.g., optional) are initially false. +*/ +Variable VARcreate( Expression name, Type type ) { + Variable v = VAR_new(); + v->name = name; + v->type = type; + return v; +} diff --git a/src/express/variable.c b/src/express/variable.c index 1de22797e..cb8261b3d 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -120,20 +120,3 @@ extern char * VARget_simple_name( Variable v ) { } return EXPget_name( e ); } - -/** VARcreate -** \param name name of variable to create -** \param type type of new variable -** \return the Variable created -** Create and return a new variable. -** -** \note The reference class of the variable is, by default, -** dynamic. Special flags associated with the variable -** (e.g., optional) are initially false. -*/ -Variable VARcreate( Expression name, Type type ) { - Variable v = VAR_new(); - v->name = name; - v->type = type; - return v; -} From f3b1065432420a2df54d637913bb38eadbc4004b Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 21 Jul 2018 13:57:39 +0100 Subject: [PATCH 049/244] additional tests / rename of tests for EXPresolve_op_dot --- src/express/test/CMakeLists.txt | 3 +- src/express/test/test_expr.c | 101 ++++++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 13 deletions(-) diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 3aeb9fb86..c516ad100 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -14,7 +14,8 @@ set(EXPRESS_CORE_OBJ ) add_executable(test_expr test_expr.c $ ${EXPRESS_CORE_OBJ}) -add_test(NAME expr_resolve_op_dot COMMAND test_expr resolve_op_dot) +add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) +add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) add_test(NAME build_check_express WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 123ffbf7b..a1f0e2e54 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -13,11 +13,10 @@ /* non-core */ #include "express/dict.h" +#include "express/variable.h" #include "fff.h" -DEFINE_FFF_GLOBALS - /* * missing header definition */ @@ -55,21 +54,27 @@ Error ERROR_undefined_attribute; * mock functions */ +DEFINE_FFF_GLOBALS + FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) -FAKE_VALUE_FUNC(Variable, VARcreate, Expression, Type) FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) void setup() { - Type_Identifier = TYPEcreate(identifier_); + Type_Identifier = TYPEcreate(identifier_); + Type_Attribute = TYPEcreate(attribute_); + + RESET_FAKE(EXPRESS_fail); + RESET_FAKE(ENTITYfind_inherited_attribute); + RESET_FAKE(ENTITYresolve_attr_ref); + RESET_FAKE(ENTITYfind_inherited_entity); + RESET_FAKE(EXP_resolve); } -/* - * mock resolve operation - */ -void EXP_resolve_handler(Expression exp, Scope cxt, Type typ) { +/* TODO: remove DICTlookup after eliminating DICT_type */ +void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) { (void) typ; Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); exp->type = res_typ; @@ -77,7 +82,7 @@ void EXP_resolve_handler(Expression exp, Scope cxt, Type typ) { exp->symbol.resolved = RESOLVED; } -int test_resolve_op_dot() { +int test_resolve_select_enum_member() { Schema scope; Symbol *e_type_id, *enum_id, *s_type_id; Type enum_typ, select_typ, chk_typ; @@ -126,7 +131,7 @@ int test_resolve_op_dot() { * test: sel_ref '.' enum_id * expectation: enum_typ */ - EXP_resolve_fake.custom_fake = EXP_resolve_handler; + EXP_resolve_fake.custom_fake = EXP_resolve_type_handler; chk_typ = EXPresolve_op_dot(expr, scope); @@ -139,6 +144,76 @@ int test_resolve_op_dot() { return 0; } +/* TODO: remove DICTlookup after eliminating DICT_type */ +void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) { + (void) unused; + Entity ent = DICTlookup(cxt->symbol_table, exp->symbol.name); + Type typ = ent->u.entity->type; + exp->type = typ; + exp->return_type = typ; + exp->symbol.resolved = RESOLVED; +} + +Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) { + (void) grp_ref; + Variable v = DICTlookup(ent->symbol_table, attr_ref->name); + return v; +} + +int test_resolve_entity_attribute() { + Schema scope; + Symbol *e_type_id, *attr_id; + Entity ent; + Type attr_typ, chk_typ; + TypeBody tb; + Expression exp_attr, expr, op1, op2; + Variable var_attr; + Linked_List explicit_attr_list; + + /* + * boilerplate: create objects, populate symbol tables + */ + scope = SCHEMAcreate(); + + e_type_id = SYMBOLcreate("entity1", 1, "test2"); + ent = ENTITYcreate(e_type_id); + DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); + + attr_id = SYMBOLcreate("attr1", 1, "test2"); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + tb = TYPEBODYcreate(number_); + attr_typ = TYPEcreate_from_body_anonymously(tb); + attr_typ->superscope = ent; + var_attr = VARcreate(exp_attr, attr_typ); + var_attr->flags.attribute = 1; + explicit_attr_list = LISTcreate(); + LISTadd_last(explicit_attr_list, var_attr); + + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); + DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); + + op1 = EXPcreate_from_symbol(Type_Identifier, e_type_id); + op2 = EXPcreate_from_symbol(Type_Attribute, attr_id); + expr = BIN_EXPcreate(OP_DOT, op1, op2); + + /* + * test: entity_ref '.' attribute_id + * expectation: attr_typ + */ + EXP_resolve_fake.custom_fake = EXP_resolve_entity_handler; + ENTITYresolve_attr_ref_fake.custom_fake = ENTITY_resolve_attr_handler; + + chk_typ = EXPresolve_op_dot(expr, scope); + + assert(EXP_resolve_fake.call_count == 1); + assert(expr->e.op1->type == ent->u.entity->type); + assert(chk_typ == attr_typ); + + /* in case of error SIGABRT will be raised (and non-zero returned) */ + + return 0; +} + struct test_def { const char *name; int (*testfunc) (void); @@ -148,7 +223,8 @@ int main(int argc, char *argv[]) { int status; struct test_def tests[] = { - {"resolve_op_dot", test_resolve_op_dot} + {"resolve_select_enum_member", test_resolve_select_enum_member}, + {"resolve_entity_attribute", test_resolve_entity_attribute} }; /* enable libexpress allocator */ @@ -179,6 +255,7 @@ int main(int argc, char *argv[]) { /* all tests */ for (unsigned int j=0; j < (sizeof tests / sizeof tests[0]); j++) { int (*test_ptr) (void) = tests[j].testfunc; + setup(); status |= test_ptr(); } } @@ -186,4 +263,4 @@ int main(int argc, char *argv[]) { return status; } -/* TODO: additional test for entity_ attribute, variable */ + From 99e57aed21749b3153f1ef03c6f8280c280ea70a Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 21 Jul 2018 14:01:32 +0100 Subject: [PATCH 050/244] grammar debugging aide for gdb --- src/express/generated/ybreaks.txt | 229 ++++++++++++++++++++++++++++++ src/express/ybreaks.py | 20 +++ 2 files changed, 249 insertions(+) create mode 100644 src/express/generated/ybreaks.txt create mode 100755 src/express/ybreaks.py diff --git a/src/express/generated/ybreaks.txt b/src/express/generated/ybreaks.txt new file mode 100644 index 000000000..cb7636ff3 --- /dev/null +++ b/src/express/generated/ybreaks.txt @@ -0,0 +1,229 @@ +expparse.y:2 +expparse.y:124 +expparse.y:2440 +expparse.y:297 +expparse.y:303 +expparse.y:320 +expparse.y:337 +expparse.y:341 +expparse.y:347 +expparse.y:353 +expparse.y:359 +expparse.y:364 +expparse.y:369 +expparse.y:379 +expparse.y:387 +expparse.y:397 +expparse.y:411 +expparse.y:423 +expparse.y:442 +expparse.y:456 +expparse.y:463 +expparse.y:475 +expparse.y:486 +expparse.y:491 +expparse.y:501 +expparse.y:506 +expparse.y:510 +expparse.y:516 +expparse.y:523 +expparse.y:529 +expparse.y:533 +expparse.y:538 +expparse.y:543 +expparse.y:547 +expparse.y:551 +expparse.y:557 +expparse.y:583 +expparse.y:593 +expparse.y:599 +expparse.y:609 +expparse.y:618 +expparse.y:628 +expparse.y:634 +expparse.y:642 +expparse.y:646 +expparse.y:653 +expparse.y:658 +expparse.y:663 +expparse.y:668 +expparse.y:675 +expparse.y:694 +expparse.y:726 +expparse.y:733 +expparse.y:738 +expparse.y:745 +expparse.y:760 +expparse.y:775 +expparse.y:786 +expparse.y:819 +expparse.y:834 +expparse.y:841 +expparse.y:855 +expparse.y:862 +expparse.y:868 +expparse.y:872 +expparse.y:878 +expparse.y:907 +expparse.y:913 +expparse.y:919 +expparse.y:925 +expparse.y:931 +expparse.y:937 +expparse.y:943 +expparse.y:949 +expparse.y:955 +expparse.y:961 +expparse.y:967 +expparse.y:973 +expparse.y:979 +expparse.y:985 +expparse.y:995 +expparse.y:1001 +expparse.y:1007 +expparse.y:1013 +expparse.y:1019 +expparse.y:1025 +expparse.y:1031 +expparse.y:1037 +expparse.y:1055 +expparse.y:1059 +expparse.y:1064 +expparse.y:1087 +expparse.y:1092 +expparse.y:1098 +expparse.y:1104 +expparse.y:1129 +expparse.y:1138 +expparse.y:1146 +expparse.y:1154 +expparse.y:1159 +expparse.y:1169 +expparse.y:1178 +expparse.y:1182 +expparse.y:1188 +expparse.y:1194 +expparse.y:1202 +expparse.y:1211 +expparse.y:1224 +expparse.y:1232 +expparse.y:1240 +expparse.y:1245 +expparse.y:1253 +expparse.y:1265 +expparse.y:1278 +expparse.y:1284 +expparse.y:1292 +expparse.y:1296 +expparse.y:1300 +expparse.y:1308 +expparse.y:1313 +expparse.y:1318 +expparse.y:1324 +expparse.y:1342 +expparse.y:1346 +expparse.y:1355 +expparse.y:1365 +expparse.y:1378 +expparse.y:1384 +expparse.y:1397 +expparse.y:1420 +expparse.y:1432 +expparse.y:1437 +expparse.y:1444 +expparse.y:1452 +expparse.y:1460 +expparse.y:1487 +expparse.y:1521 +expparse.y:1529 +expparse.y:1536 +expparse.y:1548 +expparse.y:1565 +expparse.y:1571 +expparse.y:1577 +expparse.y:1583 +expparse.y:1599 +expparse.y:1616 +expparse.y:1640 +expparse.y:1646 +expparse.y:1651 +expparse.y:1658 +expparse.y:1664 +expparse.y:1681 +expparse.y:1686 +expparse.y:1691 +expparse.y:1696 +expparse.y:1707 +expparse.y:1711 +expparse.y:1716 +expparse.y:1720 +expparse.y:1730 +expparse.y:1735 +expparse.y:1742 +expparse.y:1750 +expparse.y:1760 +expparse.y:1786 +expparse.y:1794 +expparse.y:1801 +expparse.y:1810 +expparse.y:1819 +expparse.y:1827 +expparse.y:1835 +expparse.y:1842 +expparse.y:1846 +expparse.y:1850 +expparse.y:1854 +expparse.y:1858 +expparse.y:1862 +expparse.y:1866 +expparse.y:1870 +expparse.y:1878 +expparse.y:1886 +expparse.y:1891 +expparse.y:1896 +expparse.y:1907 +expparse.y:1915 +expparse.y:1936 +expparse.y:1942 +expparse.y:1949 +expparse.y:1957 +expparse.y:1984 +expparse.y:1993 +expparse.y:2012 +expparse.y:2023 +expparse.y:2036 +expparse.y:2041 +expparse.y:2090 +expparse.y:2100 +expparse.y:2106 +expparse.y:2112 +expparse.y:2118 +expparse.y:2131 +expparse.y:2137 +expparse.y:2143 +expparse.y:2149 +expparse.y:2153 +expparse.y:2158 +expparse.y:2169 +expparse.y:2175 +expparse.y:2180 +expparse.y:2185 +expparse.y:2190 +expparse.y:2215 +expparse.y:2223 +expparse.y:2234 +expparse.y:2241 +expparse.y:2284 +expparse.y:2292 +expparse.y:2297 +expparse.y:2301 +expparse.y:2328 +expparse.y:2334 +expparse.y:2341 +expparse.y:2347 +expparse.y:2362 +expparse.y:2371 +expparse.y:2377 +expparse.y:2391 +expparse.y:2396 +expparse.y:2424 diff --git a/src/express/ybreaks.py b/src/express/ybreaks.py new file mode 100755 index 000000000..eaae0bc34 --- /dev/null +++ b/src/express/ybreaks.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# to use in your gdb session +# pi (enters the interactive python interpreter) +# import gdb +# f = open(r'../../ybreaks.txt') +# ybreaks = [gdb.Breakpoint(x.strip()) for x in f] +# +# note you'll also need to set the gdb source path to include the location of the grammar +# dir ../src/express +# dir ../src/express/generated +# + +import re + +y_line_re = re.compile(r'^#line\s(?P[0-9]+)\s"expparse.y"') + +with open(r'generated/expparse.c') as f, open(r'generated/ybreaks.txt', 'w+') as g: + ybreaks = ['expparse.y:%s' % y_line_re.match(l).group('lineno') for l in f if y_line_re.match(l)] + g.writelines(x + '\n' for x in ybreaks) From e5a55b4ab39dcd1d2bae5b9a8cc8db95323e2a35 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 22 Jul 2018 09:17:05 +0100 Subject: [PATCH 051/244] remove dependance upon exp_kw.c / unnecessary globals --- src/express/CMakeLists.txt | 1 - src/express/express.c | 128 ++++++++++++++++++------------------- 2 files changed, 62 insertions(+), 67 deletions(-) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 4b377d722..48498e6ba 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -83,7 +83,6 @@ set(EXPRESS_SOURCES express.c ordered_attrs.cc info.c - exp_kw.c factory.c ) diff --git a/src/express/express.c b/src/express/express.c index d848061d3..5a94fb2af 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -84,7 +84,6 @@ #include "expscan.h" #include "parse_data.h" #include "express/lexact.h" -#include "express/exp_kw.h" void * ParseAlloc( void * ( *mallocProc )( size_t ) ); void ParseFree( void * parser, void ( *freeProc )( void * ) ); @@ -104,6 +103,9 @@ extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ int ( *EXPRESSgetopt )( int, char * ) = NULL; bool EXPRESSignore_duplicate_schemas = false; +Function funcdef(char *name, int pcount, Type ret_typ); +void procdef(char *name, int pcount); +void BUILTINSinitialize(); Dictionary EXPRESSbuiltins; /* procedures/functions */ Error ERROR_bail_out = ERROR_none; @@ -262,18 +264,6 @@ void PASSinitialize() { /** Initialize the Express package. */ void EXPRESSinitialize( void ) { - Function - func_abs, func_acos, func_asin, func_atan, - func_blength, - func_cos, func_exists, func_exp, func_format, - func_hibound, func_hiindex, func_length, func_lobound, - func_log, func_log10, func_log2, func_loindex, - func_odd, func_rolesof, func_sin, func_sizeof, - func_sqrt, func_tan, func_typeof, - func_value, func_value_in, func_value_unique; - Procedure - proc_insert, proc_remove; - _ALLOCinitialize(); ERRORinitialize(); OBJinitialize(); @@ -303,59 +293,8 @@ void EXPRESSinitialize( void ) { STMTinitialize(); SCANinitialize(); - - EXPRESSbuiltins = DICTcreate( 35 ); -#define funcdef(x,y,c,r) \ - x = ALGcreate(OBJ_FUNCTION);\ - x->symbol.name = y;\ - x->u.func->pcount = c; \ - x->u.func->return_type = r; \ - x->u.func->builtin = true; \ - resolved_all(x); \ - DICTdefine(EXPRESSbuiltins,y,x,NULL,OBJ_FUNCTION); -#define procdef(x,y,c) x = ALGcreate(OBJ_PROCEDURE);\ - x->symbol.name = y;\ - x->u.proc->pcount = c; \ - x->u.proc->builtin = true; \ - resolved_all(x); \ - DICTdefine(EXPRESSbuiltins,y,x,NULL,OBJ_PROCEDURE); - /* third arg is # of parameters */ - - /* eventually everything should be data-driven, but for now */ - /* uppercase def's are global to allow passing necessary information */ - /* into resolver */ - procdef( proc_insert, KW_INSERT, 3 ); - procdef( proc_remove, KW_REMOVE, 2 ); - - funcdef( func_abs, KW_ABS, 1, Type_Number ); - funcdef( func_acos, KW_ACOS, 1, Type_Real ); - funcdef( func_asin, KW_ASIN, 1, Type_Real ); - funcdef( func_atan, KW_ATAN, 2, Type_Real ); - funcdef( func_blength, KW_BLENGTH, 1, Type_Integer ); - funcdef( func_cos, KW_COS, 1, Type_Real ); - funcdef( func_exists, KW_EXISTS, 1, Type_Boolean ); - funcdef( func_exp, KW_EXP, 1, Type_Real ); - funcdef( func_format, KW_FORMAT, 2, Type_String ); - funcdef( func_hibound, KW_HIBOUND, 1, Type_Integer ); - funcdef( func_hiindex, KW_HIINDEX, 1, Type_Integer ); - funcdef( func_length, KW_LENGTH, 1, Type_Integer ); - funcdef( func_lobound, KW_LOBOUND, 1, Type_Integer ); - funcdef( func_log, KW_LOG, 1, Type_Real ); - funcdef( func_log10, KW_LOG10, 1, Type_Real ); - funcdef( func_log2, KW_LOG2, 1, Type_Real ); - funcdef( func_loindex, KW_LOINDEX, 1, Type_Integer ); - funcdef( FUNC_NVL, KW_NVL, 2, Type_Generic ); - funcdef( func_odd, KW_ODD, 1, Type_Logical ); - funcdef( func_rolesof, KW_ROLESOF, 1, Type_Set_Of_String ); - funcdef( func_sin, KW_SIN, 1, Type_Real ); - funcdef( func_sizeof, KW_SIZEOF, 1, Type_Integer ); - funcdef( func_sqrt, KW_SQRT, 1, Type_Real ); - funcdef( func_tan, KW_TAN, 1, Type_Real ); - funcdef( func_typeof, KW_TYPEOF, 1, Type_Set_Of_String ); - funcdef( FUNC_USEDIN, KW_USEDIN, 2, Type_Bag_Of_Generic ); - funcdef( func_value, KW_VALUE, 1, Type_Number ); - funcdef( func_value_in, KW_VALUE_IN, 2, Type_Logical ); - funcdef( func_value_unique, KW_VALUE_UNIQUE, 1, Type_Logical ); + + BUILTINSinitialize(); ERROR_bail_out = ERRORcreate( "Aborting due to internal error(s)", SEVERITY_DUMP ); ERROR_syntax = ERRORcreate( "%s in %s %s", SEVERITY_EXIT ); @@ -891,3 +830,60 @@ void EXPRESSresolve( Express model ) { } } } + +Function funcdef(char *name, int pcount, Type ret_typ) { + Function f = ALGcreate(OBJ_FUNCTION); + f->symbol.name = name; + f->u.func->pcount = pcount; + f->u.func->return_type = ret_typ; + f->u.func->builtin = true; + resolved_all(f); + DICTdefine(EXPRESSbuiltins, name, f, 0, OBJ_FUNCTION); + return f; +} + +void procdef(char *name, int pcount) { + Procedure p = ALGcreate(OBJ_PROCEDURE); + p->symbol.name = name; + p->u.proc->pcount = pcount; + p->u.proc->builtin = true; + resolved_all(p); + DICTdefine(EXPRESSbuiltins, name, p, 0, OBJ_PROCEDURE); +} + +void BUILTINSinitialize() { + EXPRESSbuiltins = DICTcreate( 35 ); + procdef("INSERT", 3 ); + procdef("REMOVE", 2 ); + + funcdef("ABS", 1, Type_Number ); + funcdef("ACOS", 1, Type_Real ); + funcdef("ASIN", 1, Type_Real ); + funcdef("ATAN", 2, Type_Real ); + funcdef("BLENGTH", 1, Type_Integer ); + funcdef("COS", 1, Type_Real ); + funcdef("EXISTS", 1, Type_Boolean ); + funcdef("EXP", 1, Type_Real ); + funcdef("FORMAT", 2, Type_String ); + funcdef("HIBOUND", 1, Type_Integer ); + funcdef("HIINDEX", 1, Type_Integer ); + funcdef("LENGTH", 1, Type_Integer ); + funcdef("LOBOUND", 1, Type_Integer ); + funcdef("LOG", 1, Type_Real ); + funcdef("LOG10", 1, Type_Real ); + funcdef("LOG2", 1, Type_Real ); + funcdef("LOINDEX", 1, Type_Integer ); + funcdef("ODD", 1, Type_Logical ); + funcdef("ROLESOF", 1, Type_Set_Of_String ); + funcdef("SIN", 1, Type_Real ); + funcdef("SIZEOF", 1, Type_Integer ); + funcdef("SQRT", 1, Type_Real ); + funcdef("TAN", 1, Type_Real ); + funcdef("TYPEOF", 1, Type_Set_Of_String ); + funcdef("VALUE", 1, Type_Number ); + funcdef("VALUE_IN", 2, Type_Logical ); + funcdef("VALUE_UNIQUE", 1, Type_Logical ); + + FUNC_NVL = funcdef("NVL", 2, Type_Generic ); + FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic ); +} From 997618fe861ee3775b82e2f6a3cd35025e329d17 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 22 Jul 2018 18:40:41 +0100 Subject: [PATCH 052/244] initial test harness for express.c, resolve.c, schema.c, scope.c, type.c (currently no tests) --- src/express/test/CMakeLists.txt | 13 +++- src/express/test/driver.c | 47 ++++++++++++ src/express/test/driver.h | 11 +++ src/express/test/test_expr.c | 59 ++------------- src/express/test/test_express.c | 127 +++++++++++++++++++++++++++++++- src/express/test/test_resolve.c | 77 ++++++++++++++++++- src/express/test/test_schema.c | 49 +++++++++++- src/express/test/test_scope.c | 49 +++++++++++- src/express/test/test_type.c | 46 +++++++++++- 9 files changed, 403 insertions(+), 75 deletions(-) create mode 100644 src/express/test/driver.c create mode 100644 src/express/test/driver.h diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index c516ad100..1f0b874fa 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -13,10 +13,21 @@ set(EXPRESS_CORE_OBJ $ ) -add_executable(test_expr test_expr.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_expr driver.c test_expr.c $ ${EXPRESS_CORE_OBJ}) + add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) +add_executable(test_express driver.c test_express.c $ ${EXPRESS_CORE_OBJ}) + +add_executable(test_resolve driver.c test_resolve.c $ ${EXPRESS_CORE_OBJ}) + +add_executable(test_schema driver.c test_schema.c $ ${EXPRESS_CORE_OBJ}) + +add_executable(test_scope driver.c test_scope.c $ ${EXPRESS_CORE_OBJ}) + +add_executable(test_type driver.c test_type.c $ ${EXPRESS_CORE_OBJ}) + add_test(NAME build_check_express WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . diff --git a/src/express/test/driver.c b/src/express/test/driver.c new file mode 100644 index 000000000..2c329a0a2 --- /dev/null +++ b/src/express/test/driver.c @@ -0,0 +1,47 @@ +#include +#include + +#include "driver.h" + +#include "express/memory.h" + +extern struct test_def tests[]; + +int main(int argc, char *argv[]) { + int status; + + /* enable libexpress allocator */ + MEMinit(); + + argc--; + status = 0; + if (argc) { + int test_counter = argc; + + /* selected tests */ + for (int i=1; i <= argc; i++) { + for (unsigned int j=0; tests[j].name != NULL; j++) { + const char *test_name = tests[j].name; + int (*test_ptr) (void) = tests[j].testfunc; + + if (!strcmp(argv[i], test_name)) { + test_counter--; + setup(); + status |= test_ptr(); + } + } + } + + if (test_counter) + fprintf(stderr, "WARNING: some tests not found...\n"); + } else { + /* all tests */ + for (unsigned int j=0; tests[j].name != NULL; j++) { + int (*test_ptr) (void) = tests[j].testfunc; + setup(); + status |= test_ptr(); + } + } + + return status; +} diff --git a/src/express/test/driver.h b/src/express/test/driver.h new file mode 100644 index 000000000..0df5707cd --- /dev/null +++ b/src/express/test/driver.h @@ -0,0 +1,11 @@ +#ifndef __DRIVER_H_ +#define __DRIVER_H_ + +struct test_def { + const char *name; + int (*testfunc) (void); +}; + +void setup(); + +#endif /* __DRIVER_H_ */ diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index a1f0e2e54..f9c55838f 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -1,13 +1,8 @@ -#include -#include #include #include "express/expr.h" /* core */ -#include "express/alloc.h" -#include "express/memory.h" -#include "express/error.h" #include "express/hash.h" #include "express/linklist.h" @@ -15,6 +10,7 @@ #include "express/dict.h" #include "express/variable.h" +#include "driver.h" #include "fff.h" /* @@ -214,53 +210,8 @@ int test_resolve_entity_attribute() { return 0; } -struct test_def { - const char *name; - int (*testfunc) (void); +struct test_def tests[] = { + {"resolve_select_enum_member", test_resolve_select_enum_member}, + {"resolve_entity_attribute", test_resolve_entity_attribute}, + {NULL} }; - -int main(int argc, char *argv[]) { - int status; - - struct test_def tests[] = { - {"resolve_select_enum_member", test_resolve_select_enum_member}, - {"resolve_entity_attribute", test_resolve_entity_attribute} - }; - - /* enable libexpress allocator */ - MEMinit(); - - argc--; - status = 0; - if (argc) { - int test_counter = argc; - - /* selected tests */ - for (int i=1; i <= argc; i++) { - for (unsigned int j=0; j < (sizeof tests / sizeof tests[0]); j++) { - const char *test_name = tests[j].name; - int (*test_ptr) (void) = tests[j].testfunc; - - if (!strcmp(argv[i], test_name)) { - test_counter--; - setup(); - status |= test_ptr(); - } - } - } - - if (test_counter) - fprintf(stderr, "WARNING: some tests not found...\n"); - } else { - /* all tests */ - for (unsigned int j=0; j < (sizeof tests / sizeof tests[0]); j++) { - int (*test_ptr) (void) = tests[j].testfunc; - setup(); - status |= test_ptr(); - } - } - - return status; -} - - diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index fd27e6e20..ab03d15bd 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -1,11 +1,130 @@ +#include + #include "express/express.h" -int main(int argc, char *argv[]) { +/* core */ +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ +#include "../token_type.h" +#include "../parse_data.h" +#include "expscan.h" + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ + +Error ERROR_circular_reference; +Error ERROR_undefined_schema; + +Type Type_Number; +Type Type_Real; +Type Type_Integer; +Type Type_Boolean; +Type Type_String; +Type Type_Logical; +Type Type_Set_Of_String; +Type Type_Generic; +Type Type_Bag_Of_Generic; + +int yylineno; +Express yyexpresult; +Linked_List PARSEnew_schemas; +int print_objects_while_running; +YYSTYPE yylval; +int yyerrstatus; + +/* + * mock functions + */ +typedef void * (*malloc_func_t) (size_t); +typedef void (*free_func_t) (void *); + +DEFINE_FFF_GLOBALS + +FAKE_VOID_FUNC0(RESOLVEinitialize) +FAKE_VOID_FUNC0(SYMBOLinitialize) +FAKE_VOID_FUNC0(SCOPEinitialize) +FAKE_VOID_FUNC0(TYPEinitialize) +FAKE_VOID_FUNC0(VARinitialize) +FAKE_VOID_FUNC0(ALGinitialize) +FAKE_VOID_FUNC0(ENTITYinitialize) +FAKE_VOID_FUNC0(SCHEMAinitialize) +FAKE_VOID_FUNC0(CASE_ITinitialize) +FAKE_VOID_FUNC0(EXPinitialize) +FAKE_VOID_FUNC0(STMTinitialize) +FAKE_VOID_FUNC0(SCANinitialize) +FAKE_VOID_FUNC0(EXPKWinitialize) +FAKE_VOID_FUNC0(RESOLVEcleanup) +FAKE_VOID_FUNC0(TYPEcleanup) +FAKE_VOID_FUNC0(EXPcleanup) +FAKE_VOID_FUNC0(SCANcleanup) +FAKE_VOID_FUNC0(parserInitState) +FAKE_VOID_FUNC(SCAN_lex_init, char *, FILE *) +FAKE_VOID_FUNC(Parse, void *, int, YYSTYPE, parse_data_t) +FAKE_VOID_FUNC(perplexFree, perplex_t) +FAKE_VOID_FUNC(ParseFree, void *, free_func_t) +FAKE_VOID_FUNC(SCHEMAdefine_use, Schema, Rename *) +FAKE_VOID_FUNC(SCHEMAdefine_reference, Schema, Rename *) +FAKE_VOID_FUNC(SCOPEresolve_subsupers, Scope) +FAKE_VOID_FUNC(SCOPEresolve_types, Scope) +FAKE_VOID_FUNC(SCOPEresolve_expressions_statements, Scope) + +FAKE_VALUE_FUNC(void *, ParseAlloc, malloc_func_t) +FAKE_VALUE_FUNC(char *, SCANstrdup, const char *) +FAKE_VALUE_FUNC(perplex_t, perplexFileScanner, FILE *) +FAKE_VALUE_FUNC(int, yylex, perplex_t) +FAKE_VALUE_FUNC(Scope, ALGcreate, char) + +void setup() { + RESET_FAKE(RESOLVEinitialize); + RESET_FAKE(SYMBOLinitialize); + RESET_FAKE(SCOPEinitialize); + RESET_FAKE(TYPEinitialize); + RESET_FAKE(VARinitialize); + RESET_FAKE(ALGinitialize); + RESET_FAKE(ENTITYinitialize); + RESET_FAKE(SCHEMAinitialize); + RESET_FAKE(CASE_ITinitialize); + RESET_FAKE(EXPinitialize); + RESET_FAKE(STMTinitialize); + RESET_FAKE(SCANinitialize); + RESET_FAKE(EXPKWinitialize); + RESET_FAKE(RESOLVEcleanup); + RESET_FAKE(TYPEcleanup); + RESET_FAKE(EXPcleanup); + RESET_FAKE(SCANcleanup); + RESET_FAKE(parserInitState); + RESET_FAKE(SCAN_lex_init); + RESET_FAKE(Parse); + RESET_FAKE(perplexFree); + RESET_FAKE(ParseFree); + RESET_FAKE(SCHEMAdefine_use); + RESET_FAKE(SCHEMAdefine_reference); + RESET_FAKE(SCOPEresolve_subsupers); + RESET_FAKE(SCOPEresolve_types); + RESET_FAKE(SCOPEresolve_expressions_statements); + RESET_FAKE(ParseAlloc); + RESET_FAKE(SCANstrdup); + RESET_FAKE(perplexFileScanner); + RESET_FAKE(yylex); + RESET_FAKE(ALGcreate); +} - SCOPEfind_for_rename(); +int test_something() { + /*SCOPEfind_for_rename(); - RENAMEresolve(); + RENAMEresolve();*/ - return 0; + return 1; } +struct test_def tests[] = { + {"resolve_select_enum_member", test_something}, + {"resolve_entity_attribute", test_something}, + {NULL} +}; diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index fc662bc3a..801ed713b 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -1,7 +1,70 @@ +#include + #include "express/resolve.h" -int main(int argc, char *argv[]) { +/* core */ +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ +#include "express/type.h" + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ + +char * EXPRESSprogram_name; +int yylineno; +int __SCOPE_search_id; +int EXPRESSpass; +struct Scope_ * FUNC_NVL; +struct Scope_ * FUNC_USEDIN; + +Type Type_Unknown; +Type Type_Dont_Care; +Type Type_Bad; +Type Type_Runtime; +Type Type_Attribute; +Type Type_Self; +Type Type_Bag_Of_Generic; +Type Type_Funcall; + +struct EXPop_entry EXPop_table[OP_LAST]; + +int tag_count; +/* + * mock functions + */ + +DEFINE_FFF_GLOBALS + +FAKE_VALUE_FUNC(Generic, SCOPEfind, Scope, char *, int) +FAKE_VALUE_FUNC(Variable, VARfind, Scope, char *, int) +FAKE_VALUE_FUNC(char *, VARget_simple_name, Variable) +FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) +FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) +FAKE_VALUE_FUNC(Variable, ENTITYget_named_attribute, Entity, char *) +FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) + +void setup() { + RESET_FAKE(SCOPEfind); + RESET_FAKE(VARfind); + RESET_FAKE(VARget_simple_name); + RESET_FAKE(ENTITYfind_inherited_entity); + RESET_FAKE(ENTITYresolve_attr_ref); + RESET_FAKE(ENTITYget_named_attribute); + RESET_FAKE(ENTITYdeclares_variable); + RESET_FAKE(EXPRESS_fail); +} + +int test_something() { + +/* EXP_resolve(); ENTITYresolve_subtype_expression(); @@ -16,8 +79,14 @@ int main(int argc, char *argv[]) { ENTITYresolve_supertypes(); - SCOPEresolve_expressions_statements(); - - return 0; + SCOPEresolve_expressions_statements();*/ + + return 1; } +struct test_def tests[] = { + {"resolve_select_enum_member", test_something}, + {"resolve_entity_attribute", test_something}, + {NULL} +}; + diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c index 629f3fe81..c359a5d3d 100644 --- a/src/express/test/test_schema.c +++ b/src/express/test/test_schema.c @@ -1,14 +1,55 @@ +#include + #include "express/schema.h" -int main(int argc, char *argv[]) { +/* core */ +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ +char * EXPRESSprogram_name; +int yylineno; + +int ENTITY_MARK; + - SCHEMAdefine_reference(); +/* + * mock functions + */ + +DEFINE_FFF_GLOBALS + +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) +FAKE_VOID_FUNC(SCOPE_get_entities, Scope, Linked_List) +FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) + +void setup() { + RESET_FAKE(EXPRESS_fail) + RESET_FAKE(SCOPE_get_entities) + RESET_FAKE(ENTITYfind_inherited_attribute) +} + +int test_something() { + /* SCHEMAdefine_reference(); SCHEMAdefine_use(); SCHEMA_get_entities_ref(); - VARfind(); + VARfind();*/ - return 0; + return 1; } + +struct test_def tests[] = { + {"resolve_select_enum_member", test_something}, + {"resolve_entity_attribute", test_something}, + {NULL} +}; diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c index 22d62e40b..925788882 100644 --- a/src/express/test/test_scope.c +++ b/src/express/test/test_scope.c @@ -1,9 +1,50 @@ +#include + #include "express/scope.h" -int main(int argc, char *argv[]) { +/* core */ +#include "express/hash.h" +#include "express/linklist.h" - SCOPE_find(); - - return 0; +/* non-core */ + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ + +char * EXPRESSprogram_name; +int yylineno; +int __SCOPE_search_id; + +int ENTITY_MARK; + +Dictionary EXPRESSbuiltins; + + +/* + * mock functions + */ + +DEFINE_FFF_GLOBALS + +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) + + +void setup() { + RESET_FAKE(EXPRESS_fail); +} + +int test_something() { + /* SCOPE_find() */ + return 1; } + +struct test_def tests[] = { + {"resolve_select_enum_member", test_something}, + {"resolve_entity_attribute", test_something}, + {NULL} +}; diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c index 8890b7e0e..a9cdc1df9 100644 --- a/src/express/test/test_type.c +++ b/src/express/test/test_type.c @@ -1,8 +1,46 @@ +#include + #include "express/type.h" -int main(int argc, char *argv[]) { - - TYPEcreate_user_defined_tag(); +/* core */ +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ + +char * EXPRESSprogram_name; +int yylineno; + +int tag_count; + +/* + * mock functions + */ + +DEFINE_FFF_GLOBALS + +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) + + +void setup() { + RESET_FAKE(EXPRESS_fail) +} + +int test_something() { + /* TYPEcreate_user_defined_tag() */ - return 0; + return 1; } + +struct test_def tests[] = { + {"resolve_select_enum_member", test_something}, + {"resolve_entity_attribute", test_something}, + {NULL} +}; From f8bd03507d49ca06164de518747d45b8e5fac639 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 15 Sep 2018 13:52:48 +0100 Subject: [PATCH 053/244] legacy parser USE / REFERENCE bug fix --- src/express/expparse.y | 4 ++-- src/express/generated/expparse.c | 4 ++-- src/express/generated/verification_info.cmake | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/express/expparse.y b/src/express/expparse.y index 1817c2e7c..bf00d0948 100644 --- a/src/express/expparse.y +++ b/src/express/expparse.y @@ -1340,11 +1340,11 @@ initializer(A) ::= TOK_ASSIGNMENT expression(B). */ rename ::= TOK_IDENTIFIER(A). { - (*interface_func)(CURRENT_SCOPE, interface_schema, A, A); + (*interface_func)(CURRENT_SCOPE, interface_schema, A.symbol, A.symbol); } rename ::= TOK_IDENTIFIER(A) TOK_AS TOK_IDENTIFIER(B). { - (*interface_func)(CURRENT_SCOPE, interface_schema, A, B); + (*interface_func)(CURRENT_SCOPE, interface_schema, A.symbol, B.symbol); } rename_list(A) ::= rename(B). diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index f8f9b6a58..d689b22ae 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -3397,14 +3397,14 @@ static void yy_reduce( case 155: /* rename ::= TOK_IDENTIFIER */ #line 1342 "expparse.y" { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0, yymsp[0].minor.yy0); + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); } #line 3403 "expparse.c" break; case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ #line 1346 "expparse.y" { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); } #line 3410 "expparse.c" break; diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake index 078ca43d5..8e003cffe 100644 --- a/src/express/generated/verification_info.cmake +++ b/src/express/generated/verification_info.cmake @@ -1,7 +1,7 @@ # Autogenerated verification information set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) -set(baseline_expparse_y_md5 91c889ef1f177533bcc581a735273b5e) +set(baseline_expparse_y_md5 6e10d377f3d2abd9cce8cc439942dc2a) set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) -set(baseline_expparse_c_md5 f10b7efa5c5e35aa57b8a1050f22901a) +set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) set(baseline_expparse_h_md5 e4a5599839b2a9f7a6915a0dcc7747b0) From e76d92d082841c096dda43cb44fecd9ec9c07e16 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 29 Sep 2018 22:14:35 +0100 Subject: [PATCH 054/244] complete tests around DICT_type usage to faciliate refactoring --- src/express/test/CMakeLists.txt | 37 ++++- src/express/test/driver.c | 4 +- src/express/test/test_expr.c | 25 +-- src/express/test/test_express.c | 60 ++++--- src/express/test/test_resolve.c | 273 ++++++++++++++++++++++++++++--- src/express/test/test_resolve2.c | 122 ++++++++++++++ src/express/test/test_schema.c | 162 +++++++++++++++++- src/express/test/test_scope.c | 38 ++++- src/express/test/test_type.c | 29 +++- 9 files changed, 656 insertions(+), 94 deletions(-) create mode 100644 src/express/test/test_resolve2.c diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 1f0b874fa..33d789cfc 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -1,32 +1,59 @@ include_directories(..) set(EXPRESS_CORE_OBJ + # base $ $ - $ - $ $ $ -# extra - $ + + # global tables $ + $ + + # AST creation + $ + $ + $ + + # deprecated + $ $ ) add_executable(test_expr driver.c test_expr.c $ ${EXPRESS_CORE_OBJ}) - add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) add_executable(test_express driver.c test_express.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME express_rename_resolve COMMAND test_express express_rename_resolve) add_executable(test_resolve driver.c test_resolve.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME exp_resolve_bad_func_call COMMAND test_resolve exp_resolve_bad_func_call) +add_test(NAME exp_resolve_func_call COMMAND test_resolve exp_resolve_func_call) +add_test(NAME exp_resolve_local_identifier COMMAND test_resolve exp_resolve_local_identifier) +add_test(NAME entity_resolve_subtype_expr_entity COMMAND test_resolve entity_resolve_subtype_expr_entity) +add_test(NAME type_resolve_entity COMMAND test_resolve type_resolve_entity) +add_test(NAME stmt_resolve_pcall_proc COMMAND test_resolve stmt_resolve_pcall_proc) +add_test(NAME scope_resolve_named_types COMMAND test_resolve scope_resolve_named_types) +add_test(NAME entity_resolve_supertypes_entity COMMAND test_resolve entity_resolve_supertypes_entity) + +add_executable(test_resolve2 driver.c test_resolve2.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME scope_resolve_expr_stmt COMMAND test_resolve2 scope_resolve_expr_stmt) +add_test(NAME scope_resolve_subsupers COMMAND test_resolve2 scope_resolve_subsupers) + add_executable(test_schema driver.c test_schema.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME schema_define_ref COMMAND test_schema schema_define_ref) +add_test(NAME schema_define_use COMMAND test_schema schema_define_use) +add_test(NAME schema_get_entities_ref COMMAND test_schema schema_get_entities_ref) +add_test(NAME var_find COMMAND test_schema var_find) add_executable(test_scope driver.c test_scope.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME scope_find COMMAND test_scope scope_find) add_executable(test_type driver.c test_type.c $ ${EXPRESS_CORE_OBJ}) +add_test(NAME type_create_user_defined_tag COMMAND test_type type_create_user_defined_tag) add_test(NAME build_check_express WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/src/express/test/driver.c b/src/express/test/driver.c index 2c329a0a2..d3e5f4dc5 100644 --- a/src/express/test/driver.c +++ b/src/express/test/driver.c @@ -4,6 +4,7 @@ #include "driver.h" #include "express/memory.h" +#include "express/factory.h" extern struct test_def tests[]; @@ -11,7 +12,8 @@ int main(int argc, char *argv[]) { int status; /* enable libexpress allocator */ - MEMinit(); + MEMORYinitialize(); + FACTORYinitialize(); argc--; status = 0; diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index f9c55838f..554ef5f13 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -13,11 +13,6 @@ #include "driver.h" #include "fff.h" -/* - * missing header definition - */ -Type EXPresolve_op_dot( Expression expr, Scope scope ); - /* * mock globals */ @@ -26,22 +21,6 @@ char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; -Type Type_Unknown; -Type Type_Identifier; -Type Type_Real; -Type Type_Integer; -Type Type_Dont_Care; -Type Type_Bad; -Type Type_Runtime; -Type Type_Logical; -Type Type_Generic; -Type Type_Binary; -Type Type_Entity; -Type Type_Aggregate; -Type Type_Expression; -Type Type_Query; -Type Type_Attribute; - Error ERROR_warn_unsupported_lang_feat; Error WARNING_case_skip_label; Error ERROR_undefined_attribute; @@ -59,8 +38,8 @@ FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, c FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) void setup() { - Type_Identifier = TYPEcreate(identifier_); - Type_Attribute = TYPEcreate(attribute_); + ERRORwarnings = LISTcreate(); + EXPinitialize(); RESET_FAKE(EXPRESS_fail); RESET_FAKE(ENTITYfind_inherited_attribute); diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index ab03d15bd..932a029e4 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -7,6 +7,9 @@ #include "express/linklist.h" /* non-core */ +#include "express/resolve.h" +#include "express/schema.h" + #include "../token_type.h" #include "../parse_data.h" #include "expscan.h" @@ -21,16 +24,6 @@ Error ERROR_circular_reference; Error ERROR_undefined_schema; -Type Type_Number; -Type Type_Real; -Type Type_Integer; -Type Type_Boolean; -Type Type_String; -Type Type_Logical; -Type Type_Set_Of_String; -Type Type_Generic; -Type Type_Bag_Of_Generic; - int yylineno; Express yyexpresult; Linked_List PARSEnew_schemas; @@ -51,12 +44,10 @@ FAKE_VOID_FUNC0(SYMBOLinitialize) FAKE_VOID_FUNC0(SCOPEinitialize) FAKE_VOID_FUNC0(TYPEinitialize) FAKE_VOID_FUNC0(VARinitialize) -FAKE_VOID_FUNC0(ALGinitialize) FAKE_VOID_FUNC0(ENTITYinitialize) FAKE_VOID_FUNC0(SCHEMAinitialize) FAKE_VOID_FUNC0(CASE_ITinitialize) FAKE_VOID_FUNC0(EXPinitialize) -FAKE_VOID_FUNC0(STMTinitialize) FAKE_VOID_FUNC0(SCANinitialize) FAKE_VOID_FUNC0(EXPKWinitialize) FAKE_VOID_FUNC0(RESOLVEcleanup) @@ -65,6 +56,7 @@ FAKE_VOID_FUNC0(EXPcleanup) FAKE_VOID_FUNC0(SCANcleanup) FAKE_VOID_FUNC0(parserInitState) FAKE_VOID_FUNC(SCAN_lex_init, char *, FILE *) +FAKE_VOID_FUNC(ParseTrace, FILE *, char *) FAKE_VOID_FUNC(Parse, void *, int, YYSTYPE, parse_data_t) FAKE_VOID_FUNC(perplexFree, perplex_t) FAKE_VOID_FUNC(ParseFree, void *, free_func_t) @@ -78,7 +70,6 @@ FAKE_VALUE_FUNC(void *, ParseAlloc, malloc_func_t) FAKE_VALUE_FUNC(char *, SCANstrdup, const char *) FAKE_VALUE_FUNC(perplex_t, perplexFileScanner, FILE *) FAKE_VALUE_FUNC(int, yylex, perplex_t) -FAKE_VALUE_FUNC(Scope, ALGcreate, char) void setup() { RESET_FAKE(RESOLVEinitialize); @@ -86,12 +77,10 @@ void setup() { RESET_FAKE(SCOPEinitialize); RESET_FAKE(TYPEinitialize); RESET_FAKE(VARinitialize); - RESET_FAKE(ALGinitialize); RESET_FAKE(ENTITYinitialize); RESET_FAKE(SCHEMAinitialize); RESET_FAKE(CASE_ITinitialize); RESET_FAKE(EXPinitialize); - RESET_FAKE(STMTinitialize); RESET_FAKE(SCANinitialize); RESET_FAKE(EXPKWinitialize); RESET_FAKE(RESOLVEcleanup); @@ -100,6 +89,7 @@ void setup() { RESET_FAKE(SCANcleanup); RESET_FAKE(parserInitState); RESET_FAKE(SCAN_lex_init); + RESET_FAKE(ParseTrace); RESET_FAKE(Parse); RESET_FAKE(perplexFree); RESET_FAKE(ParseFree); @@ -112,19 +102,45 @@ void setup() { RESET_FAKE(SCANstrdup); RESET_FAKE(perplexFileScanner); RESET_FAKE(yylex); - RESET_FAKE(ALGcreate); } -int test_something() { - /*SCOPEfind_for_rename(); +int test_express_rename_resolve() { + Schema cur_schema, ref_schema; + Rename *use_ref; + Entity ent; + Symbol *cur_schema_id, *ent_id, *ent_ref, *ref_schema_id; + + cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); + ent_id = SYMBOLcreate("line", 1, "cur.exp"); + ent_ref = SYMBOLcreate("line", 1, "ref.exp"); + ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); + + cur_schema = SCHEMAcreate(); + cur_schema->symbol = *cur_schema_id; + cur_schema->u.schema->uselist = LISTcreate(); + + ref_schema = SCHEMAcreate(); + ref_schema->symbol = *ref_schema_id; + + ent = ENTITYcreate(ent_id); + DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + + /* TODO: create RENcreate(...), refactor SCHEMAadd_use() */ + use_ref = REN_new(); + use_ref->schema_sym = ref_schema_id; + use_ref->old = ent_ref; + use_ref->nnew = ent_ref; + use_ref->rename_type = use; + LISTadd_last(cur_schema->u.schema->uselist, (Generic) use_ref); + use_ref->schema = ref_schema; - RENAMEresolve();*/ + RENAMEresolve(use_ref, cur_schema); - return 1; + assert(use_ref->type == OBJ_ENTITY); + return 0; } struct test_def tests[] = { - {"resolve_select_enum_member", test_something}, - {"resolve_entity_attribute", test_something}, + {"express_rename_resolve", test_express_rename_resolve}, {NULL} }; diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index 801ed713b..8e600f7ed 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -7,6 +7,9 @@ #include "express/linklist.h" /* non-core */ +#include "express/symbol.h" +#include "express/schema.h" +#include "express/expr.h" #include "express/type.h" #include "driver.h" @@ -23,15 +26,6 @@ int EXPRESSpass; struct Scope_ * FUNC_NVL; struct Scope_ * FUNC_USEDIN; -Type Type_Unknown; -Type Type_Dont_Care; -Type Type_Bad; -Type Type_Runtime; -Type Type_Attribute; -Type Type_Self; -Type Type_Bag_Of_Generic; -Type Type_Funcall; - struct EXPop_entry EXPop_table[OP_LAST]; int tag_count; @@ -46,12 +40,15 @@ FAKE_VALUE_FUNC(Generic, SCOPEfind, Scope, char *, int) FAKE_VALUE_FUNC(Variable, VARfind, Scope, char *, int) FAKE_VALUE_FUNC(char *, VARget_simple_name, Variable) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) -FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(Variable, ENTITYget_named_attribute, Entity, char *) +FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) void setup() { + ERRORwarnings = LISTcreate(); + RESOLVEinitialize(); + RESET_FAKE(SCOPEfind); RESET_FAKE(VARfind); RESET_FAKE(VARget_simple_name); @@ -59,34 +56,260 @@ void setup() { RESET_FAKE(ENTITYresolve_attr_ref); RESET_FAKE(ENTITYget_named_attribute); RESET_FAKE(ENTITYdeclares_variable); - RESET_FAKE(EXPRESS_fail); + RESET_FAKE(EXPRESS_fail); } -int test_something() { +Generic SCOPEfind_handler(Scope scope, char * name, int type) { + (void) type; + return DICTlookup(scope->symbol_table, name); +} -/* - EXP_resolve(); +int test_exp_resolve_bad_func_call() { + Schema scope; + Symbol *func_id; + Expression func_call; + + scope = SCHEMAcreate(); + + func_id = SYMBOLcreate("func1", 1, "test1"); + func_call = EXPcreate_from_symbol(Type_Funcall, func_id); + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + EXP_resolve(func_call, scope, Type_Dont_Care); + + assert(func_call->symbol.resolved != RESOLVED); + + return 0; +} + +int test_exp_resolve_func_call() { + Schema scope; + Symbol *func_id; + Expression func_call; + Function func_def; + + scope = SCHEMAcreate(); + + func_id = SYMBOLcreate("func1", 1, "test1"); + func_call = EXPcreate_from_symbol(Type_Funcall, func_id); + + func_def = TYPEcreate_nostab(func_id, scope, OBJ_FUNCTION); + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + EXP_resolve(func_call, scope, Type_Dont_Care); - ENTITYresolve_subtype_expression(); + assert(func_call->symbol.resolved == RESOLVED); + assert(func_call->u.funcall.function == func_def); - TYPE_resolve(typ); + return 0; +} + +Variable VARfind_handler(Scope scope, char *name, int strict) { + (void) strict; + return DICTlookup(scope->symbol_table, name); +} + +int test_exp_resolve_local_identifier() { + Schema scope; + Entity ent; + Expression ent_attr, ent_attr_ref; + Symbol *attr_id, *attr_ref, *ent_id; + Variable v_attr; + Type attr_typ; + + scope = SCHEMAcreate(); + + ent_id = SYMBOLcreate("entity1", 1, "test_2"); + ent = ENTITYcreate(ent_id); + DICT_define(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + + attr_id = SYMBOLcreate("attr1", 1, "test_2"); + ent_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + attr_typ = TYPEcreate(real_); + v_attr = VARcreate(ent_attr, attr_typ); + v_attr->flags.attribute = true; + DICT_define(ent->symbol_table, attr_id->name, v_attr, attr_id, OBJ_VARIABLE); + + attr_ref = SYMBOLcreate("attr1", 1, "test_2"); + ent_attr_ref = EXPcreate_from_symbol(Type_Identifier, attr_ref); + + VARfind_fake.custom_fake = VARfind_handler; + + EXP_resolve(ent_attr_ref, ent, Type_Dont_Care); + + assert(ent_attr_ref->u.variable == v_attr); + assert(ent_attr_ref->symbol.resolved == RESOLVED); + + return 0; +} - STMTresolve(); +int test_entity_resolve_subtype_expr_entity() { + Schema scope; + Entity ent1, ent2; + Expression subtype_exp; + Symbol *ent1_id, *ent2_id, *ent2_ref; + int chk; - SCOPEresolve_types(); + scope = SCHEMAcreate(); + ent1_id = SYMBOLcreate("ent1", 1, "test_3"); + ent2_id = SYMBOLcreate("ent2", 1, "test_3"); + ent2_ref = SYMBOLcreate("ent2", 1, "test_3"); + ent1 = ENTITYcreate(ent1_id); + ent2 = ENTITYcreate(ent2_id); - SCOPEresolve_subsupers(); + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); + + subtype_exp = EXPcreate_from_symbol(Type_Identifier, ent2_ref); + ent1->superscope = scope; + ent1->u.entity->subtypes = LISTcreate(); + ent1->u.entity->subtype_expression = subtype_exp; - ENTITYresolve_supertypes(); + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + chk = ENTITYresolve_subtype_expression(subtype_exp, ent1, &ent1->u.entity->subtypes); + + assert(chk == RESOLVED); + + return 0; +} + +int test_type_resolve_entity() { + Schema scope; + Type sel, ent_base; + Entity ent; + Symbol *ent_id, *sel_id; + + scope = SCHEMAcreate(); + ent_id = SYMBOLcreate("ent", 1, "test_4"); + sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); + + ent_base = TYPEcreate_name(ent_id); + ent_base->superscope = scope; + ent = ENTITYcreate(ent_id); + ent->superscope = scope; + sel = TYPEcreate(select_); + sel->symbol = *sel_id; + sel->u.type->body->list = LISTcreate(); + sel->superscope = scope; + LISTadd_last(sel->u.type->body->list, ent_base); + + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + TYPE_resolve(&sel); + + assert(sel->symbol.resolved == RESOLVED); + + return 0; +} + +int test_stmt_resolve_pcall_proc() { + Schema scope; + Function f; + Procedure p; + Statement s; + Symbol *func_id, *proc_id, *proc_ref; + + scope = SCHEMAcreate(); + + func_id = SYMBOLcreate("func1", 1, "test_5"); + proc_id = SYMBOLcreate("proc1", 1, "test_5"); + proc_ref = SYMBOLcreate("proc1", 1, "test_5"); + + f = ALGcreate(OBJ_FUNCTION); + DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); + + p = ALGcreate(OBJ_PROCEDURE); + DICTdefine(f->symbol_table, proc_id->name, p, proc_id, OBJ_PROCEDURE); + + s = PCALLcreate(NULL); + s->symbol = *proc_ref; + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + STMTresolve(s, f); + + assert(s->u.proc->procedure == p); + + return 0; +} + +int test_scope_resolve_named_types() { + Schema scope; + Type sel, ent_base; + Entity ent; + Symbol *ent_id, *sel_id; + + scope = SCHEMAcreate(); + sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); + ent_id = SYMBOLcreate("ent", 1, "test_4"); + + ent_base = TYPEcreate(entity_); + ent_base->symbol = *ent_id; + ent_base->superscope = scope; + ent = ENTITYcreate(ent_id); + ent->superscope = scope; + sel = TYPEcreate(select_); + sel->symbol = *sel_id; + sel->u.type->body->list = LISTcreate(); + sel->superscope = scope; + LISTadd_last(sel->u.type->body->list, ent_base); + + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + SCOPEresolve_types(scope); + + assert(!(ent->symbol.resolved & RESOLVE_FAILED)); + assert(!(sel->symbol.resolved & RESOLVE_FAILED)); + assert(!(scope->symbol.resolved & RESOLVE_FAILED)); + + return 0; +} + +int test_entity_resolve_supertypes() { + Schema scope; + Entity ent1, ent2; + Symbol *ent1_id, *ent2_id, *ent1_ref; + + scope = SCHEMAcreate(); + ent1_id = SYMBOLcreate("ent1", 1, "test_3"); + ent2_id = SYMBOLcreate("ent2", 1, "test_3"); + ent1_ref = SYMBOLcreate("ent1", 1, "test_3"); + ent1 = ENTITYcreate(ent1_id); + ent2 = ENTITYcreate(ent2_id); + ent1->superscope = scope; + ent2->superscope = scope; + + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); + + ent2->u.entity->supertype_symbols = LISTcreate(); + LISTadd_last(ent2->u.entity->supertype_symbols, ent1_ref); + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + ENTITYresolve_supertypes(ent2); + + assert(!(ent2->symbol.resolved & RESOLVE_FAILED)); - SCOPEresolve_expressions_statements();*/ - - return 1; + return 0; } struct test_def tests[] = { - {"resolve_select_enum_member", test_something}, - {"resolve_entity_attribute", test_something}, + {"exp_resolve_bad_func_call", test_exp_resolve_bad_func_call}, + {"exp_resolve_func_call", test_exp_resolve_func_call}, + {"exp_resolve_local_identifier", test_exp_resolve_local_identifier}, + {"entity_resolve_subtype_expr_entity", test_entity_resolve_subtype_expr_entity}, + {"type_resolve_entity", test_type_resolve_entity}, + {"stmt_resolve_pcall_proc", test_stmt_resolve_pcall_proc}, + {"scope_resolve_named_types", test_scope_resolve_named_types}, + {"entity_resolve_supertypes_entity", test_entity_resolve_supertypes}, {NULL} }; diff --git a/src/express/test/test_resolve2.c b/src/express/test/test_resolve2.c new file mode 100644 index 000000000..a293dce69 --- /dev/null +++ b/src/express/test/test_resolve2.c @@ -0,0 +1,122 @@ + +#include + +#include "express/resolve.h" + +/* core */ +#include "express/hash.h" +#include "express/linklist.h" + +/* non-core */ +#include "express/type.h" + +#include "driver.h" +#include "fff.h" + +/* + * mock globals + */ + +char * EXPRESSprogram_name; +int EXPRESSpass; +int yylineno; +int print_objects_while_running; + +/* + * mock functions + */ + +DEFINE_FFF_GLOBALS + +FAKE_VOID_FUNC(ENTITYresolve_supertypes, Entity) +FAKE_VOID_FUNC(ENTITYresolve_subtypes, Schema) +FAKE_VOID_FUNC(TYPE_resolve, Type *) +FAKE_VOID_FUNC(TYPEresolve_expressions, Type, Scope) +FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) +FAKE_VOID_FUNC(STMTlist_resolve, Linked_List, Scope) +FAKE_VOID_FUNC(ENTITYresolve_expressions, Entity) + +FAKE_VALUE_FUNC(int, WHEREresolve, Linked_List, Scope, int) +FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) + +void setup() { + RESET_FAKE(ENTITYresolve_supertypes); + RESET_FAKE(ENTITYresolve_subtypes); + RESET_FAKE(TYPE_resolve); + RESET_FAKE(TYPEresolve_expressions); + RESET_FAKE(EXP_resolve); + RESET_FAKE(STMTlist_resolve); + RESET_FAKE(ENTITYresolve_expressions); + RESET_FAKE(WHEREresolve); + RESET_FAKE(EXPRESS_fail); +} + +int test_scope_resolve_expr_stmt() { + Schema scope; + Type sel, ent_base; + Entity ent; + Symbol *ent_id, *sel_id; + + scope = SCHEMAcreate(); + ent_id = SYMBOLcreate("ent", 1, "test_4"); + sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); + + ent_base = TYPEcreate_name(ent_id); + ent_base->superscope = scope; + ent = ENTITYcreate(ent_id); + ent->superscope = scope; + sel = TYPEcreate(select_); + sel->symbol = *sel_id; + sel->u.type->body->list = LISTcreate(); + sel->superscope = scope; + LISTadd_last(sel->u.type->body->list, ent_base); + + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); + + SCOPEresolve_expressions_statements(scope); + + assert(ENTITYresolve_expressions_fake.call_count == 1); + assert(TYPEresolve_expressions_fake.call_count == 1); + + return 0; +} + +int test_scope_resolve_subsupers() { + Schema scope; + Type sel, ent_base; + Entity ent; + Symbol *ent_id, *sel_id; + + scope = SCHEMAcreate(); + ent_id = SYMBOLcreate("ent", 1, "test_4"); + sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); + + ent_base = TYPEcreate_name(ent_id); + ent_base->superscope = scope; + ent = ENTITYcreate(ent_id); + ent->superscope = scope; + sel = TYPEcreate(select_); + sel->symbol = *sel_id; + sel->u.type->body->list = LISTcreate(); + sel->superscope = scope; + LISTadd_last(sel->u.type->body->list, ent_base); + + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); + + SCOPEresolve_subsupers(scope); + + assert(TYPE_resolve_fake.call_count == 1); + assert(ENTITYresolve_supertypes_fake.call_count == 1); + assert(ENTITYresolve_subtypes_fake.call_count == 1); + + return 0; +} + + +struct test_def tests[] = { + {"scope_resolve_expr_stmt", test_scope_resolve_expr_stmt}, + {"scope_resolve_subsupers", test_scope_resolve_subsupers}, + {NULL} +}; diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c index c359a5d3d..80fe0eadc 100644 --- a/src/express/test/test_schema.c +++ b/src/express/test/test_schema.c @@ -6,7 +6,10 @@ #include "express/hash.h" #include "express/linklist.h" + /* non-core */ +#include "express/variable.h" +#include "express/scope.h" #include "driver.h" #include "fff.h" @@ -36,20 +39,163 @@ void setup() { RESET_FAKE(ENTITYfind_inherited_attribute) } -int test_something() { - /* SCHEMAdefine_reference(); +int test_schema_define_ref() { + Schema cur_schema, ref_schema; + Rename *ref_rename; + Symbol *cur_schema_id, *ent_ref, *ref_schema_id; + + cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); + ent_ref = SYMBOLcreate("line", 1, "ref.exp"); + ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); + + cur_schema = SCHEMAcreate(); + cur_schema->symbol = *cur_schema_id; + cur_schema->u.schema->refdict = DICTcreate(20); + + ref_schema = SCHEMAcreate(); + ref_schema->symbol = *ref_schema_id; + + ref_rename = REN_new(); + ref_rename->schema_sym = ref_schema_id; + ref_rename->old = ent_ref; + ref_rename->nnew = ent_ref; + ref_rename->rename_type = ref; + ref_rename->schema = ref_schema; + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); + + SCHEMAdefine_reference(cur_schema, ref_rename); + + assert(cur_schema->u.schema->refdict->KeyCount == 1); + + return 0; +} + +int test_schema_define_use() { + Schema cur_schema, ref_schema; + Rename *use_rename; + Symbol *cur_schema_id, *ent_ref, *ref_schema_id; + + cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); + ent_ref = SYMBOLcreate("line", 1, "ref.exp"); + ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); + + cur_schema = SCHEMAcreate(); + cur_schema->symbol = *cur_schema_id; + cur_schema->u.schema->usedict = DICTcreate(20); + + ref_schema = SCHEMAcreate(); + ref_schema->symbol = *ref_schema_id; + + use_rename = REN_new(); + use_rename->schema_sym = ref_schema_id; + use_rename->old = ent_ref; + use_rename->nnew = ent_ref; + use_rename->rename_type = use; + use_rename->schema = ref_schema; + DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); + + SCHEMAdefine_use(cur_schema, use_rename); + + assert(cur_schema->u.schema->usedict->KeyCount == 1); + + return 0; +} + +/* TODO: + * currently this function expects OBJ_RENAME stored as OBJ_ENTITY + * (to indicate partial reference) + */ +int test_schema_get_entities_ref() { + Schema cur_schema, ref_schema; + Rename *ref_rename; + Entity ent; + Symbol *cur_schema_id, *ent_id, *ent_ref, *ref_schema_id; + Linked_List r; + + cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); + ent_id = SYMBOLcreate("line", 1, "cur.exp"); + ent_ref = SYMBOLcreate("line", 1, "ref.exp"); + ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); + + cur_schema = SCHEMAcreate(); + cur_schema->symbol = *cur_schema_id; + cur_schema->u.schema->refdict = DICTcreate(20); + + ref_schema = SCHEMAcreate(); + ref_schema->symbol = *ref_schema_id; - SCHEMAdefine_use(); + ent = ENTITYcreate(ent_id); + DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + + ref_rename = REN_new(); + ref_rename->schema_sym = ref_schema_id; + ref_rename->old = ent_ref; + ref_rename->nnew = ent_ref; + ref_rename->rename_type = ref; + ref_rename->schema = ref_schema; + ref_rename->object = ent; + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); + + r = LISTcreate(); + cur_schema->search_id = -1; + SCHEMA_get_entities_ref(cur_schema, r); + + assert(LISTget_length(r) == 1); + + return 0; +} - SCHEMA_get_entities_ref(); +Variable +ENTITY_find_attr_handler(struct Scope_ *entity, char * name, struct Symbol_** down_sym) +{ + Variable r; + (void) down_sym; + r = DICTlookup(entity->symbol_table, name); + return r; +} - VARfind();*/ +int test_var_find() { + Schema scope; + Symbol *e_type_id, *attr_id; + Entity ent; + Type attr_typ; + TypeBody tb; + Expression exp_attr; + Variable var_attr, var_ref; + Linked_List explicit_attr_list; + + scope = SCHEMAcreate(); + + e_type_id = SYMBOLcreate("entity1", 1, "test2"); + ent = ENTITYcreate(e_type_id); + DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); + + attr_id = SYMBOLcreate("attr1", 1, "test2"); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + tb = TYPEBODYcreate(number_); + attr_typ = TYPEcreate_from_body_anonymously(tb); + attr_typ->superscope = ent; + var_attr = VARcreate(exp_attr, attr_typ); + var_attr->flags.attribute = 1; + explicit_attr_list = LISTcreate(); + LISTadd_last(explicit_attr_list, var_attr); + + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); + DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); + + ENTITYfind_inherited_attribute_fake.custom_fake = ENTITY_find_attr_handler; + + var_ref = VARfind(ent, "attr1", 1); + + assert(var_ref != NULL); - return 1; + return 0; } struct test_def tests[] = { - {"resolve_select_enum_member", test_something}, - {"resolve_entity_attribute", test_something}, + {"schema_define_ref", test_schema_define_ref}, + {"schema_define_use", test_schema_define_use}, + {"schema_get_entities_ref", test_schema_get_entities_ref}, + {"var_find", test_var_find}, {NULL} }; diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c index 925788882..b59ef4acc 100644 --- a/src/express/test/test_scope.c +++ b/src/express/test/test_scope.c @@ -37,14 +37,42 @@ void setup() { RESET_FAKE(EXPRESS_fail); } -int test_something() { - /* SCOPE_find() */ +int test_scope_find() { + Schema scope; + Type sel, ent_base, chk_sel; + Entity ent, chk_ent; + Symbol *ent_id, *sel_id; - return 1; + scope = SCHEMAcreate(); + ent_id = SYMBOLcreate("ent", 1, "test_4"); + sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); + + ent_base = TYPEcreate_name(ent_id); + ent_base->superscope = scope; + ent = ENTITYcreate(ent_id); + ent->superscope = scope; + sel = TYPEcreate(select_); + sel->symbol = *sel_id; + sel->u.type->body->list = LISTcreate(); + sel->superscope = scope; + LISTadd_last(sel->u.type->body->list, ent_base); + + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); + DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); + + scope->search_id = -1; + chk_sel = SCOPE_find(scope, "sel_typ", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); + + scope->search_id = -1; + chk_ent = SCOPE_find(scope, "ent", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); + + assert(chk_sel == sel); + assert(chk_ent == ent); + + return 0; } struct test_def tests[] = { - {"resolve_select_enum_member", test_something}, - {"resolve_entity_attribute", test_something}, + {"scope_find", test_scope_find}, {NULL} }; diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c index a9cdc1df9..94b1f8b5a 100644 --- a/src/express/test/test_type.c +++ b/src/express/test/test_type.c @@ -31,16 +31,35 @@ FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) void setup() { RESET_FAKE(EXPRESS_fail) + TYPEinitialize(); } -int test_something() { - /* TYPEcreate_user_defined_tag() */ +int test_type_create_user_defined_tag() { + Schema scope; + Function f; + Type t, g, chk; + Symbol *func_id, *tag_id; - return 1; + scope = SCHEMAcreate(); + + func_id = SYMBOLcreate("func1", 1, "test_5"); + tag_id = SYMBOLcreate("item1", 1, "test_5"); + + f = ALGcreate(OBJ_FUNCTION); + f->symbol = *func_id; + DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); + + g = TYPEcreate(generic_); + t = TYPEcreate_nostab(tag_id, f, OBJ_TAG); + + chk = TYPEcreate_user_defined_tag(g, f, tag_id); + + assert(chk == t); + + return 0; } struct test_def tests[] = { - {"resolve_select_enum_member", test_something}, - {"resolve_entity_attribute", test_something}, + {"type_create_user_defined_tag", test_type_create_user_defined_tag}, {NULL} }; From db4f1a68d5237d9209be15f6f0bc6bd80d0da42c Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 29 Sep 2018 22:21:22 +0100 Subject: [PATCH 055/244] simplify OBJ lookup, compile time initialisation --- include/express/object.h | 7 +--- src/express/alg.c | 8 ---- src/express/entity.c | 2 - src/express/expr.c | 6 --- src/express/express.c | 9 ----- src/express/object.c | 86 ++++++++++++++++++++++++++++++---------- src/express/schema.c | 5 --- src/express/scope.c | 5 --- src/express/stmt.c | 3 -- src/express/type.c | 9 ----- src/express/variable.c | 6 --- 11 files changed, 67 insertions(+), 79 deletions(-) diff --git a/include/express/object.h b/include/express/object.h index bd026bce4..e5736f45b 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -81,7 +81,7 @@ struct Object { /* global variables */ /********************/ -extern SC_EXPRESS_EXPORT struct Object * OBJ; +extern SC_EXPRESS_EXPORT struct Object OBJ[]; /******************************/ /* macro function definitions */ @@ -97,9 +97,4 @@ extern SC_EXPRESS_EXPORT struct Object * OBJ; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void OBJinitialize( void ); -extern SC_EXPRESS_EXPORT void OBJcleanup( void ); -extern SC_EXPRESS_EXPORT void OBJcreate( char, struct Symbol_ * (*) (void *), char *, int); -extern SC_EXPRESS_EXPORT Symbol * UNK_get_symbol( void *x ); - #endif /*OBJECT_H*/ diff --git a/src/express/alg.c b/src/express/alg.c index 23ecc07bf..6729ece84 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -73,20 +73,12 @@ Scope ALGcreate( char type ) { ** Description: Initialize the Algorithm module. */ -Symbol * WHERE_get_symbol( void *w ) { - return( ( ( Where )w )->label ); -} - /** Initialize the Algorithm module. */ void ALGinitialize( void ) { ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); - OBJcreate( OBJ_RULE, SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS ); - OBJcreate( OBJ_PROCEDURE, SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS ); - OBJcreate( OBJ_FUNCTION, SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS ); - OBJcreate( OBJ_WHERE, WHERE_get_symbol, "where", OBJ_WHERE_BITS ); } void ALGput_full_text( Scope s, int start, int end ) { diff --git a/src/express/entity.c b/src/express/entity.c index b4ec31144..35cd9b062 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -299,8 +299,6 @@ Entity ENTITYcopy( Entity e ) { /** Initialize the Entity module. */ void ENTITYinitialize() { ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); - OBJcreate( OBJ_ENTITY, SCOPE_get_symbol, "entity", - OBJ_ENTITY_BITS ); } /** diff --git a/src/express/expr.c b/src/express/expr.c index e8c1eab28..97abe349e 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -141,18 +141,12 @@ Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { return e; } -Symbol * EXP_get_symbol( void *e ) { - return( &( ( Expression )e )->symbol ); -} - /** Description: Initialize the Expression module. */ void EXPinitialize( void ) { ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); - OBJcreate( OBJ_EXPRESSION, EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS ); - OBJcreate( OBJ_AMBIG_ENUM, EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS ); #ifdef does_not_appear_to_be_necessary_or_even_make_sense LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); diff --git a/src/express/express.c b/src/express/express.c index 5a94fb2af..65b53bb2f 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -152,10 +152,6 @@ int EXPRESS_succeed( Express model ) { return 0; } -Symbol * EXPRESS_get_symbol( void *e ) { - return( &( ( Express )e )->symbol ); -} - Express EXPRESScreate() { Express model = SCOPEcreate( OBJ_EXPRESS ); model->u.express = ( struct Express_ * )sc_calloc( 1, sizeof( struct Express_ ) ); @@ -259,14 +255,12 @@ static void EXPRESS_PATHfree( void ) { /** inform object system about bit representation for handling pass diagnostics */ void PASSinitialize() { - OBJcreate( OBJ_PASS, UNK_get_symbol, "pass", OBJ_PASS_BITS ); } /** Initialize the Express package. */ void EXPRESSinitialize( void ) { _ALLOCinitialize(); ERRORinitialize(); - OBJinitialize(); HASHinitialize(); /* comes first - used by just about everything else! */ DICTinitialize(); @@ -312,8 +306,6 @@ void EXPRESSinitialize( void ) { ERROR_warn_small_real = ERRORcreate( "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", SEVERITY_WARNING ); - OBJcreate( OBJ_EXPRESS, EXPRESS_get_symbol, "express file", OBJ_UNUSED_BITS ); - /* I don't think this should be a mere warning; exppp crashes if this warning is suppressed. * ERRORcreate_warning( "unknown_subtype", ERROR_unknown_subtype ); */ @@ -339,7 +331,6 @@ void EXPRESScleanup( void ) { ERRORdestroy( ERROR_warn_small_real ); DICTcleanup(); - OBJcleanup(); ERRORcleanup(); RESOLVEcleanup(); TYPEcleanup(); diff --git a/src/express/object.c b/src/express/object.c index 6d4852046..f75e64274 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -21,11 +21,53 @@ * prettied up interface to print_objects_when_running */ -#include -#include #include "express/object.h" -struct Object * OBJ; +#include "express/scope.h" +#include "express/variable.h" +#include "express/alg.h" +#include "express/schema.h" +#include "express/type.h" +#include "express/expr.h" + +Symbol * SCOPE_get_symbol( void *s ); +Symbol * EXPRESS_get_symbol( void *e ); +Symbol * RENAME_get_symbol( void *r ); +Symbol * TYPE_get_symbol( void *t ); +Symbol * EXP_get_symbol( void *e ); +Symbol * WHERE_get_symbol( void *w ); +Symbol * VAR_get_symbol( void *v ); +Symbol * UNK_get_symbol( void *x ); + +/* global Object type array */ +struct Object OBJ[] = { + [0] = {UNK_get_symbol, "of unknown type", 0}, + + [OBJ_VARIABLE] = {VAR_get_symbol, "variable", OBJ_VARIABLE_BITS}, + [OBJ_ENTITY] = {SCOPE_get_symbol, "entity", OBJ_ENTITY_BITS}, + + [OBJ_EXPRESSION] = {EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS}, + [OBJ_AMBIG_ENUM] = {EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS}, + + [OBJ_RULE] = {SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS}, + [OBJ_PROCEDURE] = {SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS}, + [OBJ_FUNCTION] = {SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS}, + [OBJ_WHERE] = {WHERE_get_symbol, "where", OBJ_WHERE_BITS}, + + [OBJ_SCHEMA] = {SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS}, + /* TODO: PASS should also have a symbol */ + [OBJ_PASS] = {UNK_get_symbol, "pass", OBJ_PASS_BITS}, + [OBJ_EXPRESS] = {EXPRESS_get_symbol, "express file", OBJ_UNUSED_BITS}, + [OBJ_RENAME] = {RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS}, + + [OBJ_TYPE] = {TYPE_get_symbol, "type", OBJ_TYPE_BITS}, + [OBJ_TAG] = {TYPE_get_symbol, "tag", OBJ_TYPE_BITS}, + + [OBJ_ALIAS] = {SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS }, + [OBJ_INCREMENT] = {SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS }, + + {0} +}; Symbol * UNK_get_symbol( void *x ) { (void) x; /* quell unused param warning; it appears that the prototype must match other functions */ @@ -34,26 +76,30 @@ Symbol * UNK_get_symbol( void *x ) { return 0; } -/** Initialize the Object module */ -void OBJinitialize() { - int i; +Symbol * VAR_get_symbol( void *v ) { + return &( ( Variable )v )->name->symbol; +} + +Symbol * SCOPE_get_symbol( void *s ) { + return &( ( Scope )s )->symbol; +} + +Symbol * EXP_get_symbol( void *e ) { + return &( ( Expression )e )->symbol; +} + +Symbol * WHERE_get_symbol( void *w ) { + return ( ( Where )w )->label; +} - OBJ = ( struct Object * )sc_malloc( MAX_OBJECT_TYPES * sizeof( struct Object ) ); - for( i = 0; i < MAX_OBJECT_TYPES; i++ ) { - OBJ[i].get_symbol = UNK_get_symbol; - OBJ[i].type = "of unknown_type"; - OBJ[i].bits = 0; - } +Symbol * EXPRESS_get_symbol( void *e ) { + return &( ( Express )e )->symbol; } -/** Clean up the Object module */ -void OBJcleanup() { - sc_free( OBJ ); +Symbol * RENAME_get_symbol( void *r ) { + return ( ( Rename * )r )->old; } -void OBJcreate( char type, struct Symbol_ * ( *get_symbol ) ( void * ), char * printable_type, int bits ) { - int index = ( int )type; - OBJ[index].get_symbol = get_symbol; - OBJ[index].type = printable_type; - OBJ[index].bits = bits; +Symbol * TYPE_get_symbol( void *t ) { + return &( ( Type )t )->symbol; } diff --git a/src/express/schema.c b/src/express/schema.c index aa6765be4..17317fc7c 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -55,13 +55,8 @@ struct freelist_head REN_fl; int __SCOPE_search_id = 0; -Symbol * RENAME_get_symbol( void *r ) { - return ( ( Rename * )r )->old; -} - /** Initialize the Schema module. */ void SCHEMAinitialize( void ) { - OBJcreate( OBJ_RENAME, RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS ); ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); } diff --git a/src/express/scope.c b/src/express/scope.c index 8fbf81039..0e07354ab 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -44,12 +44,7 @@ #include "express/scope.h" #include "express/resolve.h" -Symbol * SCOPE_get_symbol( void *s ) { - return( &( ( Scope )s )->symbol ); -} - void SCOPEinitialize( void ) { - OBJcreate( OBJ_SCHEMA, SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS ); ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); } diff --git a/src/express/stmt.c b/src/express/stmt.c index 384f981b6..d5359daaf 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -80,9 +80,6 @@ void STMTinitialize( void ) { ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); - OBJcreate( OBJ_ALIAS, SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS ); - OBJcreate( OBJ_INCREMENT, SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS ); - STATEMENT_SKIP = STMTcreate( STMT_SKIP ); STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE ); } diff --git a/src/express/type.c b/src/express/type.c index 07e15695c..ba356dcd5 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -256,19 +256,10 @@ return( false ); } #endif -Symbol * TYPE_get_symbol( void *t ) { - return &( ( Type )t )->symbol; -} - - /** Initialize the Type module */ void TYPEinitialize() { ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); - OBJcreate( OBJ_TYPE, TYPE_get_symbol, "type", OBJ_TYPE_BITS ); - /* OBJcreate(OBJ_TYPE,TYPE_get_symbol,"(headless) type", OBJ_UNFINDABLE_BITS);*/ - OBJcreate( OBJ_TAG, TYPE_get_symbol, "tag", OBJ_TYPE_BITS ); - /* Very commonly-used read-only types */ Type_Unknown = TYPEcreate( unknown_ ); Type_Dont_Care = TYPEcreate( special_ ); diff --git a/src/express/variable.c b/src/express/variable.c index cb8261b3d..231c1f83d 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -89,15 +89,9 @@ #include "express/object.h" char * opcode_print( Op_Code o ); -Symbol * VAR_get_symbol( void *v ) { - return( &( ( Variable )v )->name->symbol ); -} - /** Initialize the Variable module. */ void VARinitialize() { ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); - /* OBJcreate(OBJ_VARIABLE,VAR_get_symbol,"variable",OBJ_UNUSED_BITS);*/ - OBJcreate( OBJ_VARIABLE, VAR_get_symbol, "variable", OBJ_VARIABLE_BITS ); } /** VARget_simple_name From 4a71f48bc8270acd15c31975a4e4910b459fbcf3 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 29 Sep 2018 23:13:19 +0100 Subject: [PATCH 056/244] move allocator functionality to one module to enable easier testing --- include/express/memory.h | 2 +- src/express/alg.c | 4 ---- src/express/caseitem.c | 1 - src/express/entity.c | 1 - src/express/error.c | 2 -- src/express/expr.c | 4 ---- src/express/express.c | 3 ++- src/express/hash.c | 6 ------ src/express/linklist.c | 2 -- src/express/memory.c | 4 +++- src/express/schema.c | 4 ---- src/express/scope.c | 1 - src/express/stmt.c | 24 ------------------------ src/express/symbol.c | 1 - src/express/type.c | 2 -- src/express/variable.c | 1 - 16 files changed, 6 insertions(+), 56 deletions(-) diff --git a/include/express/memory.h b/include/express/memory.h index bd91f2e41..77357cf7e 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -1,6 +1,6 @@ #ifndef __MEMORY_H #define __MEMORY_H -void MEMinit(); +void MEMORYinitialize(); #endif // __MEMORY_H diff --git a/src/express/alg.c b/src/express/alg.c index 6729ece84..e0dfdb4e9 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -75,10 +75,6 @@ Scope ALGcreate( char type ) { /** Initialize the Algorithm module. */ void ALGinitialize( void ) { - ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); - ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); - ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); - ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); } void ALGput_full_text( Scope s, int start, int end ) { diff --git a/src/express/caseitem.c b/src/express/caseitem.c index f0dbc5ef1..5e5660378 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -36,7 +36,6 @@ /** Initialize the Case Item module. */ void CASE_ITinitialize( void ) { - ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); } /** diff --git a/src/express/entity.c b/src/express/entity.c index 35cd9b062..669064867 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -298,7 +298,6 @@ Entity ENTITYcopy( Entity e ) { /** Initialize the Entity module. */ void ENTITYinitialize() { - ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); } /** diff --git a/src/express/error.c b/src/express/error.c index 29ae1dcc0..98ba386a2 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -187,8 +187,6 @@ void ERRORcleanup( void ) { /** Need the LIST routines to complete ERROR initialization */ void ERRORinitialize_after_LIST( void ) { ERRORwarnings = LISTcreate(); - - ALLOCinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 ); } void ERRORcreate_warning( char * name, Error error ) { diff --git a/src/express/expr.c b/src/express/expr.c index 97abe349e..9179f072e 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -143,10 +143,6 @@ Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { /** Description: Initialize the Expression module. */ void EXPinitialize( void ) { - ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); - ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); - ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); - ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); #ifdef does_not_appear_to_be_necessary_or_even_make_sense LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); diff --git a/src/express/express.c b/src/express/express.c index 65b53bb2f..326775efc 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -74,6 +74,7 @@ #include #include +#include "express/memory.h" #include "express/basic.h" #include "express/express.h" #include "express/resolve.h" @@ -259,7 +260,7 @@ void PASSinitialize() { /** Initialize the Express package. */ void EXPRESSinitialize( void ) { - _ALLOCinitialize(); + MEMORYinitialize(); ERRORinitialize(); HASHinitialize(); /* comes first - used by just about everything else! */ diff --git a/src/express/hash.c b/src/express/hash.c index 4a83ca460..dd6866213 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -132,12 +132,6 @@ static long HashAccesses, HashCollisions; void HASHinitialize() { - if( HASH_Table_fl.size_elt == 0 ) { - ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); - } - if( HASH_Element_fl.size_elt == 0 ) { - ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); - } } Hash_Table diff --git a/src/express/linklist.c b/src/express/linklist.c index ba52ea4b2..205487161 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -27,8 +27,6 @@ Error ERROR_empty_list = ERROR_none; void LISTinitialize( void ) { - ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); - ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); ERROR_empty_list = ERRORcreate( "Empty list in %s.", SEVERITY_ERROR ); } diff --git a/src/express/memory.c b/src/express/memory.c index 6b3d7e6a4..9a83b83db 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -19,6 +19,7 @@ struct freelist_head SYMBOL_fl; struct freelist_head SCOPE_fl; struct freelist_head SCHEMA_fl; +struct freelist_head REN_fl; struct freelist_head TYPEHEAD_fl; struct freelist_head TYPEBODY_fl; @@ -50,7 +51,7 @@ struct freelist_head PCALL_fl; struct freelist_head RET_fl; struct freelist_head INCR_fl; -void MEMinit() { +void MEMORYinitialize() { _ALLOCinitialize(); ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); @@ -78,6 +79,7 @@ void MEMinit() { ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); + ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); diff --git a/src/express/schema.c b/src/express/schema.c index 17317fc7c..8bf2ee828 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -51,14 +51,10 @@ #include "express/object.h" #include "express/resolve.h" -struct freelist_head REN_fl; - int __SCOPE_search_id = 0; /** Initialize the Schema module. */ void SCHEMAinitialize( void ) { - ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); - ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); } diff --git a/src/express/scope.c b/src/express/scope.c index 0e07354ab..5a812212f 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -45,7 +45,6 @@ #include "express/resolve.h" void SCOPEinitialize( void ) { - ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); } /** diff --git a/src/express/stmt.c b/src/express/stmt.c index d5359daaf..f15305559 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -43,18 +43,6 @@ #include #include "express/stmt.h" -struct freelist_head STMT_fl; - -struct freelist_head ALIAS_fl; -struct freelist_head ASSIGN_fl; -struct freelist_head CASE_fl; -struct freelist_head COMP_STMT_fl; -struct freelist_head COND_fl; -struct freelist_head LOOP_fl; -struct freelist_head PCALL_fl; -struct freelist_head RET_fl; -struct freelist_head INCR_fl; - Statement STATEMENT_ESCAPE = STATEMENT_NULL; Statement STATEMENT_SKIP = STATEMENT_NULL; @@ -68,18 +56,6 @@ Statement STMTcreate( int type ) { /** Initialize the Statement module. */ void STMTinitialize( void ) { - ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); - - ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); - ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); - ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); - ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); - ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); - ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); - ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); - ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); - ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); - STATEMENT_SKIP = STMTcreate( STMT_SKIP ); STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE ); } diff --git a/src/express/symbol.c b/src/express/symbol.c index aa7d6fcf6..3648635cf 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -37,5 +37,4 @@ /** Initialize the Symbol module */ void SYMBOLinitialize( void ) { - ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); } diff --git a/src/express/type.c b/src/express/type.c index ba356dcd5..673a6ea35 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -258,8 +258,6 @@ return( false ); /** Initialize the Type module */ void TYPEinitialize() { - ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); - ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); /* Very commonly-used read-only types */ Type_Unknown = TYPEcreate( unknown_ ); Type_Dont_Care = TYPEcreate( special_ ); diff --git a/src/express/variable.c b/src/express/variable.c index 231c1f83d..2e6c23ebd 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -91,7 +91,6 @@ char * opcode_print( Op_Code o ); /** Initialize the Variable module. */ void VARinitialize() { - ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); } /** VARget_simple_name From b58e30c57579e9817e2bfa9187753e69eab61d77 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 09:33:45 +0100 Subject: [PATCH 057/244] move object creation to factory.c to make testing possible --- include/express/factory.h | 6 + src/express/expr.c | 103 ----------------- src/express/express.c | 2 + src/express/factory.c | 232 ++++++++++++++++++++++++++++++++++++++ src/express/type.c | 130 --------------------- 5 files changed, 240 insertions(+), 233 deletions(-) create mode 100644 include/express/factory.h diff --git a/include/express/factory.h b/include/express/factory.h new file mode 100644 index 000000000..77075720d --- /dev/null +++ b/include/express/factory.h @@ -0,0 +1,6 @@ +#ifndef __FACTORY_H_ +#define __FACTORY_H_ + +void FACTORYinitialize(); + +#endif /* __FACTORY_H_ */ diff --git a/src/express/expr.c b/src/express/expr.c index 9179f072e..7a9b24756 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -111,39 +111,8 @@ static inline int OPget_number_of_operands( Op_Code op ) { } } -Expression EXPcreate( Type type ) { - Expression e; - e = EXP_new(); - SYMBOLset( e ); - e->type = type; - e->return_type = Type_Unknown; - return( e ); -} - -/** - * use this when the return_type is the same as the type - * For example, for constant integers - */ -Expression EXPcreate_simple( Type type ) { - Expression e; - e = EXP_new(); - SYMBOLset( e ); - e->type = e->return_type = type; - return( e ); -} - -Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { - Expression e; - e = EXP_new(); - e->type = type; - e->return_type = Type_Unknown; - e->symbol = *symbol; - return e; -} - /** Description: Initialize the Expression module. */ void EXPinitialize( void ) { - #ifdef does_not_appear_to_be_necessary_or_even_make_sense LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); LITERAL_EMPTY_SET->u.list = LISTcreate(); @@ -882,78 +851,6 @@ void EXPop_init() { EXPop_create( OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown ); } - -/** -** \param op operation -** \param operand1 - first operand -** \param operand2 - second operand -** \param operand3 - third operand -** \returns Ternary_Expression - the expression created -** Create a ternary operation Expression. -*/ -Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, Expression operand3 ) { - Expression e = EXPcreate( Type_Expression ); - - e->e.op_code = op; - e->e.op1 = operand1; - e->e.op2 = operand2; - e->e.op3 = operand3; - return e; -} - -/** -** \fn BIN_EXPcreate -** \param op operation -** \param operand1 - first operand -** \param operand2 - second operand -** \returns Binary_Expression - the expression created -** Create a binary operation Expression. -*/ -Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) { - Expression e = EXPcreate( Type_Expression ); - - e->e.op_code = op; - e->e.op1 = operand1; - e->e.op2 = operand2; - return e; -} - -/** -** \param op operation -** \param operand operand -** \returns the expression created -** Create a unary operation Expression. -*/ -Expression UN_EXPcreate( Op_Code op, Expression operand ) { - Expression e = EXPcreate( Type_Expression ); - - e->e.op_code = op; - e->e.op1 = operand; - return e; -} - -/** -** \param local local identifier for source elements -** \param aggregate source aggregate to query -** \returns the query expression created -** Create a query Expression. -** NOTE Dec 2011 - MP - function description did not match actual params. Had to guess. -*/ -Expression QUERYcreate( Symbol * local, Expression aggregate ) { - Expression e = EXPcreate_from_symbol( Type_Query, local ); - Scope s = SCOPEcreate_tiny( OBJ_QUERY ); - Expression e2 = EXPcreate_from_symbol( Type_Attribute, local ); - - Variable v = VARcreate( e2, Type_Attribute ); - - DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); - e->u.query = QUERY_new(); - e->u.query->scope = s; - e->u.query->local = v; - e->u.query->aggregate = aggregate; - return e; -} - /** ** \param expression expression to evaluate ** \param experrc buffer for error code diff --git a/src/express/express.c b/src/express/express.c index 326775efc..d78ed0dd5 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -78,6 +78,7 @@ #include "express/basic.h" #include "express/express.h" #include "express/resolve.h" +#include "express/factory.h" #include "stack.h" #include "express/scope.h" #include "token_type.h" @@ -275,6 +276,7 @@ void EXPRESSinitialize( void ) { SYMBOLinitialize(); SCOPEinitialize(); + FACTORYinitialize(); TYPEinitialize(); /* cannot come before SCOPEinitialize */ VARinitialize(); diff --git a/src/express/factory.c b/src/express/factory.c index cb2fb9f7a..00bc835af 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -1,8 +1,139 @@ #include "express/schema.h" #include "express/type.h" +#include "express/expr.h" #include "express/dict.h" +/* TODO: use enum? */ +Type Type_Bad; +Type Type_Unknown; +Type Type_Dont_Care; +Type Type_Runtime; +Type Type_Binary; +Type Type_Boolean; +Type Type_Enumeration; +Type Type_Expression; +Type Type_Aggregate; +Type Type_Repeat; +Type Type_Integer; +Type Type_Number; +Type Type_Real; +Type Type_String; +Type Type_String_Encoded; +Type Type_Logical; +Type Type_Set; +Type Type_Attribute; +Type Type_Entity; +Type Type_Funcall; +Type Type_Generic; +Type Type_Identifier; +Type Type_Oneof; +Type Type_Query; +Type Type_Self; +Type Type_Set_Of_String; +Type Type_Set_Of_Generic; +Type Type_Bag_Of_Generic; + +void FACTORYinitialize() { + /* Very commonly-used read-only types */ + Type_Unknown = TYPEcreate( unknown_ ); + Type_Dont_Care = TYPEcreate( special_ ); + Type_Bad = TYPEcreate( special_ ); + Type_Runtime = TYPEcreate( runtime_ ); + + Type_Enumeration = TYPEcreate( enumeration_ ); + Type_Enumeration->u.type->body->flags.shared = 1; + resolved_all( Type_Enumeration ); + + Type_Expression = TYPEcreate( op_ ); + Type_Expression->u.type->body->flags.shared = 1; + + Type_Aggregate = TYPEcreate( aggregate_ ); + Type_Aggregate->u.type->body->flags.shared = 1; + Type_Aggregate->u.type->body->base = Type_Runtime; + + Type_Integer = TYPEcreate( integer_ ); + Type_Integer->u.type->body->flags.shared = 1; + resolved_all( Type_Integer ); + + Type_Real = TYPEcreate( real_ ); + Type_Real->u.type->body->flags.shared = 1; + resolved_all( Type_Real ); + + Type_Number = TYPEcreate( number_ ); + Type_Number->u.type->body->flags.shared = 1; + resolved_all( Type_Number ); + + Type_String = TYPEcreate( string_ ); + Type_String->u.type->body->flags.shared = 1; + resolved_all( Type_String ); + + Type_String_Encoded = TYPEcreate( string_ ); + Type_String_Encoded->u.type->body->flags.shared = 1; + Type_String_Encoded->u.type->body->flags.encoded = 1; + resolved_all( Type_String ); + + Type_Logical = TYPEcreate( logical_ ); + Type_Logical->u.type->body->flags.shared = 1; + resolved_all( Type_Logical ); + + Type_Binary = TYPEcreate( binary_ ); + Type_Binary->u.type->body->flags.shared = 1; + resolved_all( Type_Binary ); + + Type_Number = TYPEcreate( number_ ); + Type_Number->u.type->body->flags.shared = 1; + resolved_all( Type_Number ); + + Type_Boolean = TYPEcreate( boolean_ ); + Type_Boolean->u.type->body->flags.shared = 1; + resolved_all( Type_Boolean ); + + Type_Generic = TYPEcreate( generic_ ); + Type_Generic->u.type->body->flags.shared = 1; + resolved_all( Type_Generic ); + + Type_Set_Of_String = TYPEcreate( set_ ); + Type_Set_Of_String->u.type->body->flags.shared = 1; + Type_Set_Of_String->u.type->body->base = Type_String; + + Type_Set_Of_Generic = TYPEcreate( set_ ); + Type_Set_Of_Generic->u.type->body->flags.shared = 1; + Type_Set_Of_Generic->u.type->body->base = Type_Generic; + + Type_Bag_Of_Generic = TYPEcreate( bag_ ); + Type_Bag_Of_Generic->u.type->body->flags.shared = 1; + Type_Bag_Of_Generic->u.type->body->base = Type_Generic; + + Type_Attribute = TYPEcreate( attribute_ ); + Type_Attribute->u.type->body->flags.shared = 1; + + Type_Entity = TYPEcreate( entity_ ); + Type_Entity->u.type->body->flags.shared = 1; + + Type_Funcall = TYPEcreate( funcall_ ); + Type_Funcall->u.type->body->flags.shared = 1; + + Type_Generic = TYPEcreate( generic_ ); + Type_Generic->u.type->body->flags.shared = 1; + + Type_Identifier = TYPEcreate( identifier_ ); + Type_Identifier->u.type->body->flags.shared = 1; + + Type_Repeat = TYPEcreate( integer_ ); + Type_Repeat->u.type->body->flags.shared = 1; + Type_Repeat->u.type->body->flags.repeat = 1; + + Type_Oneof = TYPEcreate( oneof_ ); + Type_Oneof->u.type->body->flags.shared = 1; + + Type_Query = TYPEcreate( query_ ); + Type_Query->u.type->body->flags.shared = 1; + + Type_Self = TYPEcreate( self_ ); + Type_Self->u.type->body->flags.shared = 1; +} + /** Create and return an empty scope inside a parent scope. */ Scope SCOPEcreate( char type ) { Scope d = SCOPE_new(); @@ -141,3 +272,104 @@ Variable VARcreate( Expression name, Type type ) { v->type = type; return v; } + +Expression EXPcreate( Type type ) { + Expression e; + e = EXP_new(); + SYMBOLset( e ); + e->type = type; + e->return_type = Type_Unknown; + return( e ); +} + +/** + * use this when the return_type is the same as the type + * For example, for constant integers + */ +Expression EXPcreate_simple( Type type ) { + Expression e; + e = EXP_new(); + SYMBOLset( e ); + e->type = e->return_type = type; + return( e ); +} + +Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { + Expression e; + e = EXP_new(); + e->type = type; + e->return_type = Type_Unknown; + e->symbol = *symbol; + return e; +} + +/** +** \param op operation +** \param operand1 - first operand +** \param operand2 - second operand +** \param operand3 - third operand +** \returns Ternary_Expression - the expression created +** Create a ternary operation Expression. +*/ +Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, Expression operand3 ) { + Expression e = EXPcreate( Type_Expression ); + + e->e.op_code = op; + e->e.op1 = operand1; + e->e.op2 = operand2; + e->e.op3 = operand3; + return e; +} + +/** +** \fn BIN_EXPcreate +** \param op operation +** \param operand1 - first operand +** \param operand2 - second operand +** \returns Binary_Expression - the expression created +** Create a binary operation Expression. +*/ +Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) { + Expression e = EXPcreate( Type_Expression ); + + e->e.op_code = op; + e->e.op1 = operand1; + e->e.op2 = operand2; + return e; +} + +/** +** \param op operation +** \param operand operand +** \returns the expression created +** Create a unary operation Expression. +*/ +Expression UN_EXPcreate( Op_Code op, Expression operand ) { + Expression e = EXPcreate( Type_Expression ); + + e->e.op_code = op; + e->e.op1 = operand; + return e; +} + +/** +** \param local local identifier for source elements +** \param aggregate source aggregate to query +** \returns the query expression created +** Create a query Expression. +** NOTE Dec 2011 - MP - function description did not match actual params. Had to guess. +*/ +Expression QUERYcreate( Symbol * local, Expression aggregate ) { + Expression e = EXPcreate_from_symbol( Type_Query, local ); + Scope s = SCOPEcreate_tiny( OBJ_QUERY ); + Expression e2 = EXPcreate_from_symbol( Type_Attribute, local ); + + Variable v = VARcreate( e2, Type_Attribute ); + + DICTdefine( s->symbol_table, local->name, ( Generic )v, &e2->symbol, OBJ_VARIABLE ); + e->u.query = QUERY_new(); + e->u.query->scope = s; + e->u.query->local = v; + e->u.query->aggregate = aggregate; + return e; +} diff --git a/src/express/type.c b/src/express/type.c index 673a6ea35..aae2ec323 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -126,38 +126,6 @@ This module implements the type abstraction. It is #include #include "express/type.h" -/* Very commonly-used read-only types */ -/* non-constant versions probably aren't necessary? */ -Type Type_Bad; -Type Type_Unknown; -Type Type_Dont_Care; -Type Type_Runtime; /* indicates that this object can't be */ -/* calculated now but must be deferred */ -/* til (the mythical) runtime */ -Type Type_Binary; -Type Type_Boolean; -Type Type_Enumeration; -Type Type_Expression; -Type Type_Aggregate; -Type Type_Repeat; -Type Type_Integer; -Type Type_Number; -Type Type_Real; -Type Type_String; -Type Type_String_Encoded; -Type Type_Logical; -Type Type_Set; -Type Type_Attribute; -Type Type_Entity; -Type Type_Funcall; -Type Type_Generic; -Type Type_Identifier; -Type Type_Oneof; -Type Type_Query; -Type Type_Self; -Type Type_Set_Of_String; -Type Type_Set_Of_Generic; -Type Type_Bag_Of_Generic; Error ERROR_corrupted_type = ERROR_none; @@ -258,104 +226,6 @@ return( false ); /** Initialize the Type module */ void TYPEinitialize() { - /* Very commonly-used read-only types */ - Type_Unknown = TYPEcreate( unknown_ ); - Type_Dont_Care = TYPEcreate( special_ ); - Type_Bad = TYPEcreate( special_ ); - Type_Runtime = TYPEcreate( runtime_ ); - - Type_Enumeration = TYPEcreate( enumeration_ ); - Type_Enumeration->u.type->body->flags.shared = 1; - resolved_all( Type_Enumeration ); - - Type_Expression = TYPEcreate( op_ ); - Type_Expression->u.type->body->flags.shared = 1; - - Type_Aggregate = TYPEcreate( aggregate_ ); - Type_Aggregate->u.type->body->flags.shared = 1; - Type_Aggregate->u.type->body->base = Type_Runtime; - - Type_Integer = TYPEcreate( integer_ ); - Type_Integer->u.type->body->flags.shared = 1; - resolved_all( Type_Integer ); - - Type_Real = TYPEcreate( real_ ); - Type_Real->u.type->body->flags.shared = 1; - resolved_all( Type_Real ); - - Type_Number = TYPEcreate( number_ ); - Type_Number->u.type->body->flags.shared = 1; - resolved_all( Type_Number ); - - Type_String = TYPEcreate( string_ ); - Type_String->u.type->body->flags.shared = 1; - resolved_all( Type_String ); - - Type_String_Encoded = TYPEcreate( string_ ); - Type_String_Encoded->u.type->body->flags.shared = 1; - Type_String_Encoded->u.type->body->flags.encoded = 1; - resolved_all( Type_String ); - - Type_Logical = TYPEcreate( logical_ ); - Type_Logical->u.type->body->flags.shared = 1; - resolved_all( Type_Logical ); - - Type_Binary = TYPEcreate( binary_ ); - Type_Binary->u.type->body->flags.shared = 1; - resolved_all( Type_Binary ); - - Type_Number = TYPEcreate( number_ ); - Type_Number->u.type->body->flags.shared = 1; - resolved_all( Type_Number ); - - Type_Boolean = TYPEcreate( boolean_ ); - Type_Boolean->u.type->body->flags.shared = 1; - resolved_all( Type_Boolean ); - - Type_Generic = TYPEcreate( generic_ ); - Type_Generic->u.type->body->flags.shared = 1; - resolved_all( Type_Generic ); - - Type_Set_Of_String = TYPEcreate( set_ ); - Type_Set_Of_String->u.type->body->flags.shared = 1; - Type_Set_Of_String->u.type->body->base = Type_String; - - Type_Set_Of_Generic = TYPEcreate( set_ ); - Type_Set_Of_Generic->u.type->body->flags.shared = 1; - Type_Set_Of_Generic->u.type->body->base = Type_Generic; - - Type_Bag_Of_Generic = TYPEcreate( bag_ ); - Type_Bag_Of_Generic->u.type->body->flags.shared = 1; - Type_Bag_Of_Generic->u.type->body->base = Type_Generic; - - Type_Attribute = TYPEcreate( attribute_ ); - Type_Attribute->u.type->body->flags.shared = 1; - - Type_Entity = TYPEcreate( entity_ ); - Type_Entity->u.type->body->flags.shared = 1; - - Type_Funcall = TYPEcreate( funcall_ ); - Type_Funcall->u.type->body->flags.shared = 1; - - Type_Generic = TYPEcreate( generic_ ); - Type_Generic->u.type->body->flags.shared = 1; - - Type_Identifier = TYPEcreate( identifier_ ); - Type_Identifier->u.type->body->flags.shared = 1; - - Type_Repeat = TYPEcreate( integer_ ); - Type_Repeat->u.type->body->flags.shared = 1; - Type_Repeat->u.type->body->flags.repeat = 1; - - Type_Oneof = TYPEcreate( oneof_ ); - Type_Oneof->u.type->body->flags.shared = 1; - - Type_Query = TYPEcreate( query_ ); - Type_Query->u.type->body->flags.shared = 1; - - Type_Self = TYPEcreate( self_ ); - Type_Self->u.type->body->flags.shared = 1; - ERROR_corrupted_type = ERRORcreate( "Corrupted type in %s", SEVERITY_DUMP ); From 663414f90d054965342046f7d8c5d3d1398e326c Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 09:58:24 +0100 Subject: [PATCH 058/244] split resolve.c, add a linker seam to facilitate tests --- include/express/resolve.h | 11 ++++ src/express/CMakeLists.txt | 1 + src/express/resolve.c | 124 ++----------------------------------- src/express/resolve2.c | 115 ++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 120 deletions(-) create mode 100644 src/express/resolve2.c diff --git a/include/express/resolve.h b/include/express/resolve.h index 4be46373f..9944e03f5 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -83,4 +83,15 @@ extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); +/* + * for unit tests, no extern / export + */ +void ENTITYresolve_subtypes( Schema ); +void ENTITYresolve_supertypes( Entity ); +void ENTITYresolve_expressions( Entity e ); +void ALGresolve_expressions_statements( Scope, Linked_List ); +int WHEREresolve( Linked_List, Scope, int ); +void TYPEresolve_expressions( Type, Scope ); +void STMTlist_resolve( Linked_List, Scope ); + #endif /*RESOLVE_H*/ diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 48498e6ba..d0e41e049 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -72,6 +72,7 @@ set(EXPRESS_SOURCES scope.c schema.c resolve.c + resolve2.c lexact.c linklist.c error.c diff --git a/src/express/resolve.c b/src/express/resolve.c index 2d7a95ca4..7e64f7fcb 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -77,11 +77,6 @@ Error ERROR_ambiguous_group = ERROR_none; Error WARNING_fn_skip_branch = ERROR_none; Error WARNING_case_skip_label = ERROR_none; - -static void ENTITYresolve_subtypes( Schema ); -static void ENTITYresolve_supertypes( Entity ); -static void TYPEresolve_expressions( Type, Scope ); - static Error ERROR_wrong_arg_count; static Error ERROR_supertype_resolve; static Error ERROR_subtype_resolve; @@ -115,7 +110,6 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -static int WHEREresolve( Linked_List, Scope, int ); extern void VAR_resolve_expressions( Variable, Entity ); extern void VAR_resolve_types( Variable v ); @@ -940,21 +934,6 @@ void STMTresolve( Statement statement, Scope scope ) { } } -void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { - int status = 0; - - if( print_objects_while_running & OBJ_ALGORITHM_BITS & - OBJget_bits( s->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type( s->type ) ); - } - - SCOPEresolve_expressions_statements( s ); - STMTlist_resolve( statements, s ); - - s->symbol.resolved = status; -} - static Variable ENTITY_get_local_attribute( Entity e, char * name ) { LISTdo( e->u.entity->attributes, a, Variable ) if( !strcmp( VARget_simple_name( a ), name ) ) { @@ -1194,52 +1173,8 @@ void SCOPEresolve_types( Scope s ) { } } - - -/********************************new****************************************/ - -void SCOPEresolve_subsupers( Scope scope ) { - DictionaryEntry de; - void *x; - char type; - Symbol * sym; - Type t; - - if( print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits( scope->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - scope->symbol.name, OBJget_type( scope->type ) ); - } - - DICTdo_init( scope->symbol_table, &de ); - while( 0 != ( x = DICTdo( &de ) ) ) { - switch( type = DICT_type ) { - case OBJ_ENTITY: - ENTITYresolve_supertypes( ( Entity )x ); - ENTITYresolve_subtypes( ( Entity )x ); - break; - case OBJ_FUNCTION: - case OBJ_PROCEDURE: - case OBJ_RULE: - SCOPEresolve_subsupers( ( Scope )x ); - break; - case OBJ_TYPE: - t = ( Type )x; - TYPEresolve( &t ); - break; - default: - /* ignored everything else */ - break; - } - sym = OBJget_symbol( x, type ); - if( is_resolve_failed_raw( sym ) ) { - resolve_failed( scope ); - } - } -} - /** for each supertype, find the entity it refs to */ -static void ENTITYresolve_supertypes( Entity e ) { +void ENTITYresolve_supertypes( Entity e ) { Entity ref_entity; if( print_objects_while_running & OBJ_ENTITY_BITS ) { @@ -1296,7 +1231,7 @@ static void ENTITYresolve_supertypes( Entity e ) { } LISTod; } -static void ENTITYresolve_subtypes( Entity e ) { +void ENTITYresolve_subtypes( Entity e ) { int i; if( print_objects_while_running & OBJ_ENTITY_BITS ) { @@ -1389,7 +1324,7 @@ void ENTITYresolve_types( Entity e ) { } /** resolve all expressions in type definitions */ -static void TYPEresolve_expressions( Type t, Scope s ) { +void TYPEresolve_expressions( Type t, Scope s ) { TypeBody body; /* meaning of self in a type declaration refers to the type itself, so */ @@ -1427,58 +1362,7 @@ static void TYPEresolve_expressions( Type t, Scope s ) { self = self_old; } -void SCOPEresolve_expressions_statements( Scope s ) { - DictionaryEntry de; - void *x; - Variable v; - - if( print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits( s->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type( s->type ) ); - } - - DICTdo_init( s->symbol_table, &de ); - while( 0 != ( x = DICTdo( &de ) ) ) { - switch( DICT_type ) { - case OBJ_SCHEMA: - if( is_not_resolvable( ( Schema )x ) ) { - break; - } - SCOPEresolve_expressions_statements( ( Scope )x ); - break; - case OBJ_ENTITY: - ENTITYresolve_expressions( ( Entity )x ); - break; - case OBJ_FUNCTION: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.func->body ); - break; - case OBJ_PROCEDURE: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.proc->body ); - break; - case OBJ_RULE: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.rule->body ); - - WHEREresolve( RULEget_where( ( Scope )x ), ( Scope )x, 0 ); - break; - case OBJ_VARIABLE: - v = ( Variable )x; - TYPEresolve_expressions( v->type, s ); - if( v->initializer ) { - EXPresolve( v->initializer, s, v->type ); - } - break; - case OBJ_TYPE: - TYPEresolve_expressions( ( Type )x, s ); - break; - default: - /* ignored everything else */ - break; - } - } -} - -static int WHEREresolve( Linked_List list, Scope scope, int need_self ) { +int WHEREresolve( Linked_List list, Scope scope, int need_self ) { int status = 0; LISTdo( list, w, Where ) diff --git a/src/express/resolve2.c b/src/express/resolve2.c new file mode 100644 index 000000000..bd5518595 --- /dev/null +++ b/src/express/resolve2.c @@ -0,0 +1,115 @@ +/* + * This software was developed by U.S. Government employees as part of + * their official duties and is not subject to copyright. + */ + +#include "express/express.h" +#include "express/schema.h" +#include "express/resolve.h" + +void SCOPEresolve_subsupers( Scope scope ) { + DictionaryEntry de; + void *x; + char type; + Symbol * sym; + Type t; + + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( scope->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + scope->symbol.name, OBJget_type( scope->type ) ); + } + + DICTdo_init( scope->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( type = DICT_type ) { + case OBJ_ENTITY: + ENTITYresolve_supertypes( ( Entity )x ); + ENTITYresolve_subtypes( ( Entity )x ); + break; + case OBJ_FUNCTION: + case OBJ_PROCEDURE: + case OBJ_RULE: + SCOPEresolve_subsupers( ( Scope )x ); + break; + case OBJ_TYPE: + t = ( Type )x; + TYPEresolve( &t ); + break; + default: + /* ignored everything else */ + break; + } + sym = OBJget_symbol( x, type ); + if( is_resolve_failed_raw( sym ) ) { + resolve_failed( scope ); + } + } +} + +void SCOPEresolve_expressions_statements( Scope s ) { + DictionaryEntry de; + void *x; + Variable v; + + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); + } + + DICTdo_init( s->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( DICT_type ) { + case OBJ_SCHEMA: + if( is_not_resolvable( ( Schema )x ) ) { + break; + } + SCOPEresolve_expressions_statements( ( Scope )x ); + break; + case OBJ_ENTITY: + ENTITYresolve_expressions( ( Entity )x ); + break; + case OBJ_FUNCTION: + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.func->body ); + break; + case OBJ_PROCEDURE: + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.proc->body ); + break; + case OBJ_RULE: + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.rule->body ); + + WHEREresolve( RULEget_where( ( Scope )x ), ( Scope )x, 0 ); + break; + case OBJ_VARIABLE: + v = ( Variable )x; + TYPEresolve_expressions( v->type, s ); + if( v->initializer ) { + EXPresolve( v->initializer, s, v->type ); + } + break; + case OBJ_TYPE: + TYPEresolve_expressions( ( Type )x, s ); + break; + default: + /* ignored everything else */ + break; + } + } +} + +void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { + int status = 0; + + if( print_objects_while_running & OBJ_ALGORITHM_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); + } + + SCOPEresolve_expressions_statements( s ); + STMTlist_resolve( statements, s ); + + s->symbol.resolved = status; +} + From 2cd591be99e58c67e2c430f66744c992b651f9f8 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 10:36:08 +0100 Subject: [PATCH 059/244] move declarations from resolve.c to resolve.h / add missing declaration --- include/express/resolve.h | 3 +++ src/express/resolve.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/express/resolve.h b/include/express/resolve.h index 9944e03f5..549aa8852 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -86,12 +86,15 @@ extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); /* * for unit tests, no extern / export */ +void VAR_resolve_expressions( Variable, Entity ); void ENTITYresolve_subtypes( Schema ); void ENTITYresolve_supertypes( Entity ); void ENTITYresolve_expressions( Entity e ); void ALGresolve_expressions_statements( Scope, Linked_List ); int WHEREresolve( Linked_List, Scope, int ); void TYPEresolve_expressions( Type, Scope ); +void STMTresolve( Statement, Scope ); void STMTlist_resolve( Linked_List, Scope ); +int ENTITYresolve_subtype_expression( Expression, Entity, Linked_List * ); #endif /*RESOLVE_H*/ diff --git a/src/express/resolve.c b/src/express/resolve.c index 7e64f7fcb..d6ebad2e4 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -110,7 +110,6 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -extern void VAR_resolve_expressions( Variable, Entity ); extern void VAR_resolve_types( Variable v ); /** Initialize the Fed-X second pass. */ @@ -818,7 +817,6 @@ void VAR_resolve_types( Variable v ) { ** ** Resolve all references in a statement. */ -void STMTresolve( Statement statement, Scope scope ); void STMTlist_resolve( Linked_List list, Scope scope ) { LISTdo( list, s, Statement ) From d9d6406b0bb3a5dfb45fc4443e118377fcdfc32a Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 10:42:25 +0100 Subject: [PATCH 060/244] remove static declaration from some functions to enable tests --- include/express/resolve.h | 1 + include/express/schema.h | 2 ++ src/express/express.c | 4 +--- src/express/schema.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/express/resolve.h b/include/express/resolve.h index 549aa8852..6e566597f 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -82,6 +82,7 @@ extern SC_EXPRESS_EXPORT void TYPE_resolve( Type * ); extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); +extern SC_EXPRESS_EXPORT void RENAMEresolve( Rename *, Schema ); /* * for unit tests, no extern / export diff --git a/include/express/schema.h b/include/express/schema.h index e7d5d46ec..1d2ce5c4b 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -148,5 +148,7 @@ extern SC_EXPRESS_EXPORT void SCOPEdestroy( Scope ); extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use( Scope ); extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref( Scope ); +void SCHEMA_get_entities_ref( Scope, Linked_List ); + #endif /* SCHEMA_H */ diff --git a/src/express/express.c b/src/express/express.c index d78ed0dd5..f3765743b 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -446,8 +446,6 @@ static Express PARSERrun( char * filename, FILE * fp ) { return yyexpresult; } -static void RENAMEresolve( Rename * r, Schema s ); - /** * find the final object to which a rename points * i.e., follow chain of USEs or REFs @@ -499,7 +497,7 @@ static void * SCOPEfind_for_rename( Scope schema, char * name ) { return 0; } -static void RENAMEresolve( Rename * r, Schema s ) { +void RENAMEresolve( Rename * r, Schema s ) { void *remote; /* if (is_resolved_rename_raw(r->old)) return;*/ diff --git a/src/express/schema.c b/src/express/schema.c index 8bf2ee828..13f82d0a1 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -179,7 +179,7 @@ Linked_List SCHEMAget_entities_use( Scope scope ) { } /** return ref'd entities */ -static void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { +void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { Rename * rename; DictionaryEntry de; From 5edde001e50cc31d9eb05ef2fdb99326b59c7439 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 10:52:39 +0100 Subject: [PATCH 061/244] add missing declarations required for tests --- include/express/expr.h | 2 ++ include/express/scope.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/express/expr.h b/include/express/expr.h index 0d0b2946d..55e7adad9 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -266,4 +266,6 @@ extern SC_EXPRESS_EXPORT void EXPcleanup( void ); extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); +Type EXPresolve_op_dot PROTO( ( Expression, Scope ) ); + #endif /*EXPRESSION_H*/ diff --git a/include/express/scope.h b/include/express/scope.h index 8ad45b21b..f06807788 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -144,4 +144,6 @@ extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); +Generic SCOPE_find PROTO( ( Scope, char *, int ) ); + #endif /* SCOPE_H */ From d6d7aeec9547b139699f8460f9957b01138a9049 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 30 Sep 2018 11:25:36 +0100 Subject: [PATCH 062/244] clean up includes, use <> for C standard library and "" for stepcode headers --- src/express/alg.c | 1 - src/express/alloc.c | 3 ++- src/express/caseitem.c | 1 - src/express/dict.c | 1 - src/express/entity.c | 1 - src/express/error.c | 2 -- src/express/expr.c | 6 +++--- src/express/express.c | 2 +- src/express/fedex.c | 9 +++++---- src/express/hash.c | 5 +++-- src/express/lexact.c | 5 +++-- src/express/linklist.c | 1 - src/express/ordered_attrs.cc | 6 ++++-- src/express/resolve.c | 3 +-- src/express/schema.c | 1 - src/express/scope.c | 1 - src/express/stmt.c | 1 - src/express/symbol.c | 1 - src/express/type.c | 3 +-- src/express/variable.c | 2 +- 20 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/express/alg.c b/src/express/alg.c index e0dfdb4e9..2211eff1a 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -38,7 +38,6 @@ * prettied up interface to print_objects_when_running */ -#include #include "express/alg.h" #include "express/object.h" #include "express/schema.h" diff --git a/src/express/alloc.c b/src/express/alloc.c index dfc3572f3..e20cfa943 100644 --- a/src/express/alloc.c +++ b/src/express/alloc.c @@ -32,9 +32,10 @@ Now you can say things like: foo_destroy(foo1); */ -#include + #include #include + #include "express/alloc.h" #include "express/error.h" diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 5e5660378..fe8aa460f 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -29,7 +29,6 @@ * prettied up interface to print_objects_when_running */ -#include #include "express/caseitem.h" diff --git a/src/express/dict.c b/src/express/dict.c index fea38d463..9988d0a5b 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -33,7 +33,6 @@ * Initial revision */ -#include #include "express/dict.h" #include "express/object.h" #include "express/expbasic.h" diff --git a/src/express/entity.c b/src/express/entity.c index 669064867..4f2585200 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -113,7 +113,6 @@ * */ -#include #include "express/entity.h" #include "express/express.h" #include "express/object.h" diff --git a/src/express/error.c b/src/express/error.c index 98ba386a2..63a2c2e0c 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -51,8 +51,6 @@ * prettied up interface to print_objects_when_running */ -#include "sc_cf.h" - #include #include #include diff --git a/src/express/expr.c b/src/express/expr.c index 7a9b24756..4b4fa81fc 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -70,12 +70,12 @@ * */ -#include +#include +#include + #include "express/expr.h" #include "express/resolve.h" -#include -#include struct EXPop_entry EXPop_table[OP_LAST]; diff --git a/src/express/express.c b/src/express/express.c index f3765743b..f8a517b33 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -68,12 +68,12 @@ * */ -#include "sc_memmgr.h" #include #include #include #include +#include "sc_memmgr.h" #include "express/memory.h" #include "express/basic.h" #include "express/express.h" diff --git a/src/express/fedex.c b/src/express/fedex.c index efad8e4d9..805f8aeed 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -71,12 +71,13 @@ * */ -#include -#include -#include -#include "sc_version_string.h" #include #include + +#include "sc_cf.h" +#include "sc_memmgr.h" +#include "sc_export.h" +#include "sc_version_string.h" #include "sc_getopt.h" #include "express/error.h" #include "express/express.h" diff --git a/src/express/hash.c b/src/express/hash.c index dd6866213..5556ade92 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -105,10 +105,11 @@ * */ -#include #include -#include #include +#include + +#include "sc_memmgr.h" #include "express/hash.h" /* diff --git a/src/express/lexact.c b/src/express/lexact.c index fc9c064cf..750ee51c8 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -51,11 +51,12 @@ * prettied up interface to print_objects_when_running */ -#include #include #include +#include + +#include "sc_memmgr.h" #include "express/lexact.h" -#include "string.h" #include "express/linklist.h" #include "stack.h" #include "express/hash.h" diff --git a/src/express/linklist.c b/src/express/linklist.c index 205487161..dbaf118db 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -21,7 +21,6 @@ * prettied up interface to print_objects_when_running */ -#include #include "express/linklist.h" Error ERROR_empty_list = ERROR_none; diff --git a/src/express/ordered_attrs.cc b/src/express/ordered_attrs.cc index 1286dd1bf..8081c16e3 100644 --- a/src/express/ordered_attrs.cc +++ b/src/express/ordered_attrs.cc @@ -1,8 +1,10 @@ /// \file ordered_attrs.cc - create a list of attributes in the proper order for part 21, taking into account derivation, diamond inheritance, and (TODO) redefinition -#include "ordered_attrs.h" #include -#include +#include +#include + +#include "ordered_attrs.h" #ifdef _WIN32 # define strcasecmp _stricmp diff --git a/src/express/resolve.c b/src/express/resolve.c index d6ebad2e4..114e25158 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -56,10 +56,9 @@ */ #include -#include #include + #include "express/resolve.h" -#include "stack.h" #include "express/schema.h" #include "express/express.h" diff --git a/src/express/schema.c b/src/express/schema.c index 13f82d0a1..5dd77873a 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -45,7 +45,6 @@ * prettied up interface to print_objects_when_running */ -#include #include "express/expbasic.h" #include "express/schema.h" #include "express/object.h" diff --git a/src/express/scope.c b/src/express/scope.c index 5a812212f..0e27db3b5 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -39,7 +39,6 @@ * prettied up interface to print_objects_when_running */ -#include #define SCOPE_C #include "express/scope.h" #include "express/resolve.h" diff --git a/src/express/stmt.c b/src/express/stmt.c index f15305559..7f1579f25 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -40,7 +40,6 @@ * */ -#include #include "express/stmt.h" Statement STATEMENT_ESCAPE = STATEMENT_NULL; diff --git a/src/express/symbol.c b/src/express/symbol.c index 3648635cf..ed71fb836 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -32,7 +32,6 @@ * Initial revision */ -#include #include "express/symbol.h" /** Initialize the Symbol module */ diff --git a/src/express/type.c b/src/express/type.c index aae2ec323..e78d7de6c 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -123,9 +123,8 @@ This module implements the type abstraction. It is */ #include -#include -#include "express/type.h" +#include "express/type.h" Error ERROR_corrupted_type = ERROR_none; diff --git a/src/express/variable.c b/src/express/variable.c index 2e6c23ebd..b3ec9f88a 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -83,8 +83,8 @@ * */ -#include #include + #include "express/variable.h" #include "express/object.h" char * opcode_print( Op_Code o ); From 88e82d8faf6b01e55f7b7d95265d29f4986b74e8 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 3 Oct 2018 06:36:14 +0100 Subject: [PATCH 063/244] reenable lemon / full build for integration test purposes --- cmake/schema_scanner/CMakeLists.txt | 3 ++ src/express/CMakeLists.txt | 35 +++++++++---------- src/express/expparse.y | 5 ++- src/express/generated/verification_info.cmake | 2 +- src/express/test/CMakeLists.txt | 4 +++ 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/cmake/schema_scanner/CMakeLists.txt b/cmake/schema_scanner/CMakeLists.txt index 6575eb3fa..34520e67c 100644 --- a/cmake/schema_scanner/CMakeLists.txt +++ b/cmake/schema_scanner/CMakeLists.txt @@ -22,6 +22,7 @@ set(schema_scanner_src ${SC_ROOT}/src/express/generated/expparse.c ${SC_ROOT}/src/express/generated/expscan.c ${SC_ROOT}/src/express/alg.c + ${SC_ROOT}/src/express/alloc.c ${SC_ROOT}/src/express/caseitem.c ${SC_ROOT}/src/express/dict.c ${SC_ROOT}/src/express/entity.c @@ -29,6 +30,7 @@ set(schema_scanner_src ${SC_ROOT}/src/express/exp_kw.c ${SC_ROOT}/src/express/expr.c ${SC_ROOT}/src/express/express.c + ${SC_ROOT}/src/express/factory.c ${SC_ROOT}/src/express/hash.c ${SC_ROOT}/src/express/lexact.c ${SC_ROOT}/src/express/linklist.c @@ -36,6 +38,7 @@ set(schema_scanner_src ${SC_ROOT}/src/express/object.c ${SC_ROOT}/src/express/info.c ${SC_ROOT}/src/express/resolve.c + ${SC_ROOT}/src/express/resolve2.c ${SC_ROOT}/src/express/schema.c ${SC_ROOT}/src/express/scope.c ${SC_ROOT}/src/express/stmt.c diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index d0e41e049..5ef962c83 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -43,18 +43,13 @@ if(SC_GENERATE_LP_SOURCES) LEMON_TARGET(ExpParser expparse.y) PERPLEX_TARGET(ExpScanner expscan.l) ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner ExpParser) - set(SCL_SO_SRCS - ${LEMON_ExpParser_SRC} - ${PERPLEX_ExpScanner_SRC} - ) - LEMON_TARGET(ExpParser_static expparse.y) - PERPLEX_TARGET(ExpScanner_static expscan.l) - ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner_static ExpParser_static) - set(SCL_STATIC_SRCS - ${LEMON_ExpParser_static_SRC} - ${PERPLEX_ExpScanner_static_SRC} - ) + add_library(objlib_expscan_c OBJECT ${PERPLEX_ExpScanner_SRC}) + set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + + add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_SRC}) + set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + else(SC_GENERATE_LP_SOURCES) add_subdirectory(generated) include_directories(generated) @@ -100,6 +95,16 @@ endforeach() list(APPEND EXPRESS_OBJS $) list(APPEND EXPRESS_OBJS $) + +if(SC_GENERATE_LP_SOURCES) + set_property(TARGET objlib_expparse_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") + set_property(TARGET objlib_expscan_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + # OBJECT libraries are not targets, and so an explicit dependency is required + set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") +endif() + # TODO # Currently, fedex.c provides the main() for multiple programs. These programs # provide custom behavior by defining EXPRESSinit_init (called by fedex.c's @@ -129,10 +134,6 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() if(SC_GENERATE_LP_SOURCES) - set_property(TARGET express - APPEND PROPERTY INCLUDE_DIRECTORIES "${RE2C_ExpScanner_INCLUDE_DIR}") - set_property(TARGET express - APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") add_custom_command(TARGET express POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake ) @@ -149,10 +150,6 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) if(SC_GENERATE_LP_SOURCES) - set_property(TARGET express-static - APPEND PROPERTY INCLUDE_DIRECTORIES "${RE2C_ExpScanner_INCLUDE_DIR}") - set_property(TARGET express-static - APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") add_custom_command(TARGET express-static POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake ) diff --git a/src/express/expparse.y b/src/express/expparse.y index bf00d0948..441c4efe6 100644 --- a/src/express/expparse.y +++ b/src/express/expparse.y @@ -2439,5 +2439,8 @@ while_control(A) ::= TOK_WHILE expression(B). %stack_overflow { fprintf(stderr, "Express parser experienced stack overflow.\n"); - fprintf(stderr, "Last token had value %x\n", yypMinor->yy0.val); + /* + * fprintf(stderr, "Last token had value %x\n", yypMinor->yy0.val); + * fprintf(stderr, "Last token had value %x\n", yypParser->yytos->minor.yy0.val); + */ } diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake index 8e003cffe..b3d7b3608 100644 --- a/src/express/generated/verification_info.cmake +++ b/src/express/generated/verification_info.cmake @@ -1,6 +1,6 @@ # Autogenerated verification information set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) -set(baseline_expparse_y_md5 6e10d377f3d2abd9cce8cc439942dc2a) +set(baseline_expparse_y_md5 3722242f16c679c40323317833757a6d) set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 33d789cfc..6d2615a9b 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -1,5 +1,9 @@ include_directories(..) +if(SC_GENERATE_LP_SOURCES) + include_directories("${PERPLEX_ExpScanner_INCLUDE_DIR}" "${LEMON_ExpParser_INCLUDE_DIR}") +endif(SC_GENERATE_LP_SOURCES) + set(EXPRESS_CORE_OBJ # base $ From 68d0e7bbb426813543d0a2decb2738e1b95975b5 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 14 Oct 2018 22:00:16 +0100 Subject: [PATCH 064/244] rework ERROR handling --- include/express/error.h | 184 ++++++++------ include/express/expr.h | 5 - include/express/express.h | 8 - include/express/lexact.h | 10 - include/express/linklist.h | 1 - include/express/resolve.h | 13 - include/express/type.h | 2 - src/exp2cxx/fedex_main.c | 5 +- src/exp2python/src/fedex_main_python.c | 5 +- src/exppp/exppp-main.c | 5 +- src/exppp/exppp.c | 3 - src/exppp/pretty_schema.c | 2 +- src/exppp/pretty_type.c | 2 +- src/express/dict.c | 21 +- src/express/entity.c | 12 +- src/express/error.c | 320 ++++++++++++++----------- src/express/expparse.y | 8 +- src/express/expr.c | 96 ++------ src/express/express.c | 58 +---- src/express/expscan.l | 12 +- src/express/generated/expparse.c | 8 +- src/express/generated/expscan.c | 12 +- src/express/info.c | 4 +- src/express/lexact.c | 48 +--- src/express/linklist.c | 6 +- src/express/memory.c | 2 - src/express/resolve.c | 250 +++---------------- src/express/test/test_expr.c | 1 - src/express/test/test_resolve.c | 1 - src/express/type.c | 13 +- 30 files changed, 394 insertions(+), 723 deletions(-) diff --git a/include/express/error.h b/include/express/error.h index 194885381..7eef340c4 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -28,16 +28,10 @@ * prettied up interface to print_objects_when_running */ -#include -#include "basic.h" /* get basic definitions */ #include -/*************/ -/* constants */ -/*************/ - -#define ERROR_none (Error)NULL -#define ERROR_MAX 100 +#include "sc_export.h" +#include "basic.h" /* get basic definitions */ /*****************/ /* packages used */ @@ -46,33 +40,122 @@ #include "alloc.h" #include "symbol.h" +enum ErrorCode { + /* dict.c */ + DUPLICATE_DECL = 1, + DUPLICATE_DECL_DIFF_FILE, + /* error.c */ + SUBORDINATE_FAILED, + SYNTAX_EXPECTING, + /* expr.c */ + INTEGER_EXPRESSION_EXPECTED, + INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE, + ATTRIBUTE_REF_ON_AGGREGATE, + ATTRIBUTE_REF_FROM_NON_ENTITY, + INDEXING_ILLEGAL, + WARN_INDEXING_MIXED, + ENUM_NO_SUCH_ITEM, + GROUP_REF_NO_SUCH_ENTITY, + GROUP_REF_UNEXPECTED_TYPE, + IMPLICIT_DOWNCAST, + AMBIG_IMPLICIT_DOWNCAST, + /* express.c */ + BAIL_OUT, + SYNTAX, + REF_NONEXISTENT, + TILDE_EXPANSION_FAILED, + SCHEMA_NOT_IN_OWN_SCHEMA_FILE, + UNLABELLED_PARAM_TYPE, + FILE_UNREADABLE, + FILE_UNWRITABLE, + WARN_UNSUPPORTED_LANG_FEAT, + WARN_SMALL_REAL, + /* lexact.c */ + INCLUDE_FILE, + UNMATCHED_CLOSE_COMMENT, + UNMATCHED_OPEN_COMMENT, + UNTERMINATED_STRING, + ENCODED_STRING_BAD_DIGIT, + ENCODED_STRING_BAD_COUNT, + BAD_IDENTIFIER, + UNEXPECTED_CHARACTER, + NONASCII_CHAR, + /* linklist.c */ + EMPTY_LIST, + /* resolve.c */ + UNDEFINED, + UNDEFINED_ATTR, + UNDEFINED_TYPE, + UNDEFINED_SCHEMA, + UNKNOWN_ATTR_IN_ENTITY, + UNKNOWN_SUBTYPE, + UNKNOWN_SUPERTYPE, + CIRCULAR_REFERENCE, + SUBSUPER_LOOP, + SUBSUPER_CONTINUATION, + SELECT_LOOP, + SELECT_CONTINUATION, + SUPERTYPE_RESOLVE, + SUBTYPE_RESOLVE, + NOT_A_TYPE, + FUNCALL_NOT_A_FUNCTION, + UNDEFINED_FUNC, + EXPECTED_PROC, + NO_SUCH_PROCEDURE, + WRONG_ARG_COUNT, + QUERY_REQUIRES_AGGREGATE, + SELF_IS_UNKNOWN, + INVERSE_BAD_ENTITY, + INVERSE_BAD_ATTR, + MISSING_SUPERTYPE, + TYPE_IS_ENTITY, + AMBIGUOUS_ATTR, + AMBIGUOUS_GROUP, + OVERLOADED_ATTR, + REDECL_NO_SUCH_ATTR, + REDECL_NO_SUCH_SUPERTYPE, + MISSING_SELF, + FN_SKIP_BRANCH, + CASE_SKIP_LABEL, + UNIQUE_QUAL_REDECL, + /* type.c */ + CORRUPTED_TYPE, + UNDEFINED_TAG, + /* exppp.c */ + SELECT_EMPTY, +}; + +/*************/ +/* constants */ +/*************/ + +#define ERROR_none (Error)NULL +#define ERROR_MAX 100 + /************/ /* typedefs */ /************/ -typedef enum { - SEVERITY_WARNING = 0, - SEVERITY_ERROR = 1, - SEVERITY_EXIT = 2, - SEVERITY_DUMP = 3, - SEVERITY_MAX = 4 -} Severity; +enum Severity { + SEVERITY_WARNING = 0, + SEVERITY_ERROR, + SEVERITY_EXIT, + SEVERITY_DUMP, + SEVERITY_MAX +}; /***************************/ /* hidden type definitions */ /***************************/ -typedef struct Error_ { - bool enabled; - Severity severity; - char * message; - int serial; /* used to give each type of error a unique identifier */ -} * Error; +struct Error_ { + enum Severity severity; + const char *message; + const char *name; + bool override; +}; -typedef struct Error_Warning_ { - char * name; - struct Linked_List_ * errors; -} * Error_Warning; +typedef struct Error_ *Error; /****************/ /* modules used */ @@ -89,10 +172,6 @@ extern SC_EXPRESS_EXPORT const char * current_filename; extern SC_EXPRESS_EXPORT bool ERRORoccurred; -extern SC_EXPRESS_EXPORT Error experrc; -extern SC_EXPRESS_EXPORT Error ERROR_subordinate_failed; -extern SC_EXPRESS_EXPORT Error ERROR_syntax_expecting; - /* all of these are 1 if true, 0 if false switches */ /* for debugging fedex */ extern SC_EXPRESS_EXPORT int ERRORdebugging; @@ -101,18 +180,8 @@ extern SC_EXPRESS_EXPORT int malloc_debug_resolve; /* for debugging yacc/lex */ extern SC_EXPRESS_EXPORT int debug; -extern SC_EXPRESS_EXPORT struct Linked_List_ * ERRORwarnings; -extern SC_EXPRESS_EXPORT struct freelist_head ERROR_OPT_fl; - extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); -/******************************/ -/* macro function definitions */ -/******************************/ - -#define ERROR_OPT_new() (struct Error_Warning_ *)ALLOC_new(&ERROR_OPT_fl) -#define ERROR_OPT_destroy(x) ALLOC_destroy(&ERROR_OPT_fl,(Freelist *)x) - /***********************/ /* function prototypes */ /***********************/ @@ -120,26 +189,6 @@ extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); -/********************/ -/* Inline functions */ -/********************/ - -static inline void ERRORdisable( Error error ) { - if( error != ERROR_none ) { - error->enabled = false; - } -} - -static inline void ERRORenable( Error error ) { - if( error != ERROR_none ) { - error->enabled = true; - } -} - -static inline bool ERRORis_enabled( Error error ) { - return error->enabled; -} - static inline void ERRORbuffer_messages( bool flag ) { __ERROR_buffer_errors = flag; if( __ERROR_buffer_errors ) { @@ -162,22 +211,21 @@ static inline void ERRORflush_messages( void ) { /***********************/ extern SC_EXPRESS_EXPORT void ERRORinitialize( void ); -extern SC_EXPRESS_EXPORT void ERRORinitialize_after_LIST( void ); extern SC_EXPRESS_EXPORT void ERRORcleanup( void ); extern SC_EXPRESS_EXPORT void ERRORnospace( void ); extern SC_EXPRESS_EXPORT void ERRORabort( int ); -extern SC_EXPRESS_EXPORT Error ERRORcreate( char *, Severity ); -extern SC_EXPRESS_EXPORT void ERRORreport( Error, ... ); -extern SC_EXPRESS_EXPORT void ERRORdestroy( Error ); +extern SC_EXPRESS_EXPORT void ERRORreport( enum ErrorCode, ... ); struct Symbol_; /* mention Symbol to avoid warning on following line */ -extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( Error, struct Symbol_ *, ... ); -extern SC_EXPRESS_EXPORT void ERRORreport_with_line( Error, int, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( enum ErrorCode, struct Symbol_ *, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_line( enum ErrorCode, int, ... ); -extern SC_EXPRESS_EXPORT void ERRORcreate_warning( char *, Error ); -extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, int ); -extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( int ); +extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, bool ); +extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); +extern char * ERRORget_warnings_help(const char* prefix, const char *eol); +extern bool ERRORis_enabled(enum ErrorCode errnum); + #endif /* ERROR_H */ diff --git a/include/express/expr.h b/include/express/expr.h index 55e7adad9..4abf2610d 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -193,11 +193,6 @@ extern SC_EXPRESS_EXPORT Expression LITERAL_PI; extern SC_EXPRESS_EXPORT Expression LITERAL_ZERO; extern SC_EXPRESS_EXPORT Expression LITERAL_ONE; -extern SC_EXPRESS_EXPORT Error ERROR_bad_qualification; -extern SC_EXPRESS_EXPORT Error ERROR_integer_expression_expected; -extern SC_EXPRESS_EXPORT Error ERROR_implicit_downcast; -extern SC_EXPRESS_EXPORT Error ERROR_ambig_implicit_downcast; - extern SC_EXPRESS_EXPORT struct freelist_head EXP_fl; extern SC_EXPRESS_EXPORT struct freelist_head OP_fl; extern SC_EXPRESS_EXPORT struct freelist_head QUERY_fl; diff --git a/include/express/express.h b/include/express/express.h index 43377845e..e849ae56a 100644 --- a/include/express/express.h +++ b/include/express/express.h @@ -104,14 +104,6 @@ extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas; extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */ -extern SC_EXPRESS_EXPORT Error ERROR_bail_out; -extern SC_EXPRESS_EXPORT Error ERROR_syntax; -extern SC_EXPRESS_EXPORT Error ERROR_unlabelled_param_type; -extern SC_EXPRESS_EXPORT Error ERROR_file_unreadable; -extern SC_EXPRESS_EXPORT Error ERROR_file_unwriteable; -extern SC_EXPRESS_EXPORT Error ERROR_warn_unsupported_lang_feat; -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; diff --git a/include/express/lexact.h b/include/express/lexact.h index 1b443f62c..9e9ac3559 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -72,16 +72,6 @@ extern SC_EXPRESS_EXPORT Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; extern SC_EXPRESS_EXPORT int SCAN_current_buffer; extern SC_EXPRESS_EXPORT char * SCANcurrent; -extern SC_EXPRESS_EXPORT Error ERROR_include_file; -extern SC_EXPRESS_EXPORT Error ERROR_unmatched_close_comment; -extern SC_EXPRESS_EXPORT Error ERROR_unmatched_open_comment; -extern SC_EXPRESS_EXPORT Error ERROR_unterminated_string; -extern SC_EXPRESS_EXPORT Error ERROR_encoded_string_bad_digit; -extern SC_EXPRESS_EXPORT Error ERROR_encoded_string_bad_count; -extern SC_EXPRESS_EXPORT Error ERROR_bad_identifier; -extern SC_EXPRESS_EXPORT Error ERROR_unexpected_character; -extern SC_EXPRESS_EXPORT Error ERROR_nonascii_char; - /******************************/ /* macro function definitions */ /******************************/ diff --git a/include/express/linklist.h b/include/express/linklist.h index a053e310c..76c31a461 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -70,7 +70,6 @@ struct Linked_List_ { /* global variables */ /********************/ -extern SC_EXPRESS_EXPORT Error ERROR_empty_list; extern SC_EXPRESS_EXPORT struct freelist_head LINK_fl; extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; diff --git a/include/express/resolve.h b/include/express/resolve.h index 6e566597f..7eca8aa07 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -47,19 +47,6 @@ extern SC_EXPRESS_EXPORT int print_objects_while_running; -extern SC_EXPRESS_EXPORT Error ERROR_undefined_attribute; -extern SC_EXPRESS_EXPORT Error ERROR_undefined_type; -extern SC_EXPRESS_EXPORT Error ERROR_undefined_schema; -extern SC_EXPRESS_EXPORT Error ERROR_unknown_attr_in_entity; -extern SC_EXPRESS_EXPORT Error ERROR_unknown_subtype; -extern SC_EXPRESS_EXPORT Error ERROR_unknown_supertype; -extern SC_EXPRESS_EXPORT Error ERROR_circular_reference; -extern SC_EXPRESS_EXPORT Error ERROR_ambiguous_attribute; -extern SC_EXPRESS_EXPORT Error ERROR_ambiguous_group; - -extern SC_EXPRESS_EXPORT Error WARNING_case_skip_label; -extern SC_EXPRESS_EXPORT Error WARNING_fn_skip_branch; - /* macros */ /* cheaper doing the check here, then inside the function call. Return */ diff --git a/include/express/type.h b/include/express/type.h index 46e9147b7..321fe716e 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -217,8 +217,6 @@ extern SC_EXPRESS_EXPORT Type Type_Bag_Of_Generic; extern SC_EXPRESS_EXPORT struct freelist_head TYPEHEAD_fl; extern SC_EXPRESS_EXPORT struct freelist_head TYPEBODY_fl; -extern SC_EXPRESS_EXPORT Error ERROR_corrupted_type; - /******************************/ /* macro function definitions */ /******************************/ diff --git a/src/exp2cxx/fedex_main.c b/src/exp2cxx/fedex_main.c index 9803db703..81c6f1515 100644 --- a/src/exp2cxx/fedex_main.c +++ b/src/exp2cxx/fedex_main.c @@ -83,6 +83,7 @@ extern void print_fedex_version( void ); static void exp2cxx_usage( void ) { + char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); fprintf( stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); fprintf( stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n" ); fprintf( stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n" ); @@ -95,9 +96,7 @@ static void exp2cxx_usage( void ) { fprintf( stderr, "\t-i warning ignore\n" ); fprintf( stderr, "and is one of:\n" ); fprintf( stderr, "\tnone\n\tall\n" ); - LISTdo( ERRORwarnings, opt, Error_Warning ) - fprintf( stderr, "\t%s\n", opt->name ); - LISTod + fprintf( stderr, "%s", warnings_help_msg); fprintf( stderr, "and is one or more of:\n" ); fprintf( stderr, " e entity\n" ); fprintf( stderr, " p procedure\n" ); diff --git a/src/exp2python/src/fedex_main_python.c b/src/exp2python/src/fedex_main_python.c index 9f3a39183..be7bdd242 100644 --- a/src/exp2python/src/fedex_main_python.c +++ b/src/exp2python/src/fedex_main_python.c @@ -14,6 +14,7 @@ extern void print_fedex_version( void ); static void exp2python_usage( void ) { + char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); fprintf( stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); fprintf( stderr, "\t-v produces the version description below\n" ); fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); @@ -21,9 +22,7 @@ static void exp2python_usage( void ) { fprintf( stderr, "\t-i warning ignore\n" ); fprintf( stderr, "and is one of:\n" ); fprintf( stderr, "\tnone\n\tall\n" ); - LISTdo( ERRORwarnings, opt, Error_Warning ) - fprintf( stderr, "\t%s\n", opt->name ); - LISTod + fprintf( stderr, "%s", warnings_help_msg); fprintf( stderr, "and is one or more of:\n" ); fprintf( stderr, " e entity\n" ); fprintf( stderr, " p procedure\n" ); diff --git a/src/exppp/exppp-main.c b/src/exppp/exppp-main.c index 079f0885d..670dd7a88 100644 --- a/src/exppp/exppp-main.c +++ b/src/exppp/exppp-main.c @@ -4,6 +4,7 @@ #include "exppp.h" static void exppp_usage( void ) { + char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name ); fprintf( stderr, "\t-v produces a version description\n" ); fprintf( stderr, "\t-l specifies line length hint for output\n" ); @@ -16,9 +17,7 @@ static void exppp_usage( void ) { fprintf( stderr, "\t-i warning ignore\n" ); fprintf( stderr, "and is one of:\n" ); fprintf( stderr, "\tnone\n\tall\n" ); - LISTdo( ERRORwarnings, opt, Error_Warning ) - fprintf( stderr, "\t%s\n", opt->name ); - LISTod + fprintf( stderr, "%s", warnings_help_msg); fprintf( stderr, "and is one or more of:\n" ); fprintf( stderr, " e entity\n" ); fprintf( stderr, " p procedure\n" ); diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index a7395d095..e40ffaee9 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -215,9 +215,6 @@ void exppp_init() { return; } first_time = false; - - ERROR_select_empty = ERRORcreate( - "select type %s has no members", SEVERITY_ERROR ); } diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 8dfaeb6f8..6b555f379 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -99,7 +99,7 @@ char * SCHEMAout( Schema s ) { fprintf( stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer ); } if( !( exppp_fp = f = fopen( exppp_filename_buffer, "w" ) ) ) { - ERRORreport( ERROR_file_unwriteable, exppp_filename_buffer, strerror( errno ) ); + ERRORreport( FILE_UNWRITABLE, exppp_filename_buffer, strerror( errno ) ); return 0; } } diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index d4cf62fb7..d18402ddc 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -198,7 +198,7 @@ void TYPE_body_out( Type t, int level ) { /* if empty, force a left paren */ if( first_time ) { - ERRORreport_with_symbol( ERROR_select_empty, &error_sym, t->symbol.name ); + ERRORreport_with_symbol( SELECT_EMPTY, &error_sym, t->symbol.name ); raw( "%*s( ", level, "" ); } raw( " )" ); diff --git a/src/express/dict.c b/src/express/dict.c index 9988d0a5b..69d8d1dd8 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -39,9 +39,6 @@ char DICT_type; /**< set to type of object found, as a side-effect of DICT lookup routines */ -static Error ERROR_duplicate_decl; -static Error ERROR_duplicate_decl_diff_file; - void DICTprint( Dictionary dict ) { Element e; DictionaryEntry de; @@ -57,16 +54,10 @@ void DICTprint( Dictionary dict ) { /** Initialize the Dictionary module */ void DICTinitialize( void ) { - ERROR_duplicate_decl = ERRORcreate( - "Redeclaration of %s. Previous declaration was on line %d.", SEVERITY_ERROR ); - ERROR_duplicate_decl_diff_file = ERRORcreate( - "Redeclaration of %s. Previous declaration was on line %d in file %s.", SEVERITY_ERROR ); } /** Clean up the Dictionary module */ void DICTcleanup( void ) { - ERRORdestroy( ERROR_duplicate_decl ); - ERRORdestroy( ERROR_duplicate_decl_diff_file ); } /** @@ -104,11 +95,11 @@ int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type /* if we're adding a non-enum, and we've * * already added a non-enum, complain */ if( sym->filename == old->symbol->filename ) { - ERRORreport_with_symbol( ERROR_duplicate_decl, sym, name, old->symbol->line ); + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, old->symbol->line ); } else { - ERRORreport_with_symbol( ERROR_duplicate_decl_diff_file, sym, name, old->symbol->line, old->symbol->filename ); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename ); } - experrc = ERROR_subordinate_failed; + ERRORreport(SUBORDINATE_FAILED); return( 1 ); } return 0; @@ -135,11 +126,11 @@ int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char typ } if( sym->filename == e2->symbol->filename ) { - ERRORreport_with_symbol( ERROR_duplicate_decl, sym, name, e2->symbol->line ); + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, e2->symbol->line ); } else { - ERRORreport_with_symbol( ERROR_duplicate_decl_diff_file, sym, name, e2->symbol->line, e2->symbol->filename ); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename ); } - experrc = ERROR_subordinate_failed; + ERRORreport(SUBORDINATE_FAILED); return( 1 ); } diff --git a/src/express/entity.c b/src/express/entity.c index 4f2585200..507b2c23f 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -246,8 +246,6 @@ Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, * report errors as appropriate */ Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { - extern Error ERROR_unknown_supertype; - extern Error ERROR_unknown_attr_in_entity; Entity ref_entity; Variable attr; struct Symbol_ *where; @@ -256,15 +254,13 @@ Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) /* use entity provided in group reference */ ref_entity = ENTITYfind_inherited_entity( e, grp_ref->name, 0 ); if( !ref_entity ) { - ERRORreport_with_symbol( ERROR_unknown_supertype, grp_ref, - grp_ref->name, e->symbol.name ); + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name ); return 0; } attr = ( Variable )DICTlookup( ref_entity->symbol_table, attr_ref->name ); if( !attr ) { - ERRORreport_with_symbol( ERROR_unknown_attr_in_entity, - attr_ref, attr_ref->name, + ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, attr_ref, attr_ref->name, ref_entity->symbol.name ); /* resolve_failed(e);*/ } @@ -273,11 +269,11 @@ Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) where = NULL; attr = ENTITYfind_inherited_attribute( e, attr_ref->name, &where ); if( !attr /* was ref_entity? */ ) { - ERRORreport_with_symbol( ERROR_unknown_attr_in_entity, + ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, attr_ref, attr_ref->name, e->symbol.name ); } else if( where != NULL ) { - ERRORreport_with_symbol( ERROR_implicit_downcast, attr_ref, + ERRORreport_with_symbol(IMPLICIT_DOWNCAST, attr_ref, where->name ); } } diff --git a/src/express/error.c b/src/express/error.c index 63a2c2e0c..04bcc4154 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -59,6 +59,7 @@ #include #include "sc_memmgr.h" +#include "express/express.h" #include "express/error.h" #include "express/info.h" #include "express/linklist.h" @@ -68,13 +69,99 @@ # define vsnprintf c99_vsnprintf #endif +static struct Error_ LibErrors[] = { + /* dict.c */ + [DUPLICATE_DECL] = {SEVERITY_ERROR, "Redeclaration of %s. Previous declaration was on line %d.", NULL, false}, + [DUPLICATE_DECL_DIFF_FILE] = {SEVERITY_ERROR, "Redeclaration of %s. Previous declaration was on line %d in file %s.", NULL, false}, + /* error.c */ + [SUBORDINATE_FAILED] = {SEVERITY_ERROR, "A subordinate failed.", NULL, false}, + [SYNTAX_EXPECTING] = {SEVERITY_EXIT, "%s, expecting %s in %s %s", NULL, false}, + /* expr.c */ + [INTEGER_EXPRESSION_EXPECTED] = {SEVERITY_WARNING, "Integer expression expected", NULL, false}, + [INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE] = {SEVERITY_ERROR, "Opcode unrecognized while trying to resolve expression", NULL, false}, + [ATTRIBUTE_REF_ON_AGGREGATE] = {SEVERITY_ERROR, "Attribute %s cannot be referenced from an aggregate", NULL, false}, + [ATTRIBUTE_REF_FROM_NON_ENTITY] = {SEVERITY_ERROR, "Attribute %s cannot be referenced from a non-entity", NULL, false}, + [INDEXING_ILLEGAL] = {SEVERITY_ERROR, "Indexing is only permitted on aggregates", NULL, false}, + [WARN_INDEXING_MIXED] = {SEVERITY_WARNING, "non-aggregates) and/or different aggregation types.", "indexing", false}, + [ENUM_NO_SUCH_ITEM] = {SEVERITY_ERROR, "Enumeration type %s does not contain item %s", NULL, false}, + [GROUP_REF_NO_SUCH_ENTITY] = {SEVERITY_ERROR, "Group reference failed to find entity %s", NULL, false}, + [GROUP_REF_UNEXPECTED_TYPE] = {SEVERITY_ERROR, "Group reference of unusual expression %s", NULL, false}, + [IMPLICIT_DOWNCAST] = {SEVERITY_WARNING, "Implicit downcast to %s.", "downcast", false}, + [AMBIG_IMPLICIT_DOWNCAST] = {SEVERITY_WARNING, "Possibly ambiguous implicit downcast (%s?).", "downcast", false}, + /* express.c */ + [BAIL_OUT] = {SEVERITY_DUMP, "Aborting due to internal error(s)", NULL, false}, + [SYNTAX] = {SEVERITY_EXIT, "%s in %s %s", NULL, false}, + [REF_NONEXISTENT] = {SEVERITY_ERROR, "USE/REF of non-existent object (%s in schema %s)", NULL, false}, + [TILDE_EXPANSION_FAILED] = {SEVERITY_ERROR, "Tilde expansion for %s failed in EXPRESS_PATH environment variable", NULL, false}, + [SCHEMA_NOT_IN_OWN_SCHEMA_FILE] = {SEVERITY_ERROR, "Schema %s was not found in its own schema file (%s)", NULL, false}, + [UNLABELLED_PARAM_TYPE] = {SEVERITY_ERROR, "Return type or local variable requires type label in `%s'", NULL, false}, + [FILE_UNREADABLE] = {SEVERITY_ERROR, "Could not read file %s: %s", NULL, false}, + [FILE_UNWRITABLE] = {SEVERITY_ERROR, "Could not write file %s: %s", NULL, false}, + [WARN_UNSUPPORTED_LANG_FEAT] = {SEVERITY_WARNING, "Unsupported language feature (%s) at %s:%d", "unsupported", false}, + [WARN_SMALL_REAL] = {SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " + "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false}, + /* lexact.c */ + [INCLUDE_FILE] = {SEVERITY_ERROR, "Could not open include file `%s'.", NULL, false}, + [UNMATCHED_CLOSE_COMMENT] = {SEVERITY_ERROR, "unmatched close comment", NULL, false}, + [UNMATCHED_OPEN_COMMENT] = {SEVERITY_ERROR, "unmatched open comment", NULL, false}, + [UNTERMINATED_STRING] = {SEVERITY_ERROR, "unterminated string literal", NULL, false}, + [ENCODED_STRING_BAD_DIGIT] = {SEVERITY_ERROR, "non-hex digit (%c) in encoded string literal", NULL, false}, + [ENCODED_STRING_BAD_COUNT] = {SEVERITY_ERROR, "number of digits (%d) in encoded string literal is not divisible by 8", NULL, false}, + [BAD_IDENTIFIER] = {SEVERITY_ERROR, "identifier (%s) cannot start with underscore", NULL, false}, + [UNEXPECTED_CHARACTER] = {SEVERITY_ERROR, "character (%c) is not a valid lexical element by itself", NULL, false}, + [NONASCII_CHAR] = {SEVERITY_ERROR, "character (0x%x) is not in the EXPRESS character set", NULL, false}, + /* linklist.c */ + [EMPTY_LIST] = {SEVERITY_ERROR, "Empty list in %s.", NULL, false}, + /* resolve.c */ + [UNDEFINED] = {SEVERITY_ERROR, "Reference to undefined object %s.", NULL, false}, + [UNDEFINED_ATTR] = {SEVERITY_ERROR, "Reference to undefined attribute %s.", NULL, false}, + [UNDEFINED_TYPE] = {SEVERITY_ERROR, "Reference to undefined type %s.", NULL, false}, + [UNDEFINED_SCHEMA] = {SEVERITY_ERROR, "Reference to undefined schema %s.", NULL, false}, + [UNKNOWN_ATTR_IN_ENTITY] = {SEVERITY_ERROR, "Unknown attribute %s in entity %s.", NULL, false}, + [UNKNOWN_SUBTYPE] = {SEVERITY_EXIT, "Unknown subtype %s for entity %s.", "unknown_subtype", false}, + [UNKNOWN_SUPERTYPE] = {SEVERITY_ERROR, "Unknown supertype %s for entity %s.", NULL, false}, + [CIRCULAR_REFERENCE] = {SEVERITY_ERROR, "Circularity: definition of %s references itself.", NULL, false}, + [SUBSUPER_LOOP] = {SEVERITY_ERROR, "Entity %s is a subtype of itself", "circular_subtype", false}, + [SUBSUPER_CONTINUATION] = {SEVERITY_ERROR, " (via supertype entity %s)", NULL, false}, + [SELECT_LOOP] = {SEVERITY_ERROR, "Select type %s selects itself", "circular_select", false}, + [SELECT_CONTINUATION] = {SEVERITY_ERROR, " (via select type %s)", NULL, false}, + [SUPERTYPE_RESOLVE] = {SEVERITY_ERROR, "Supertype %s is not an entity (line %d).", NULL, false}, + [SUBTYPE_RESOLVE] = {SEVERITY_ERROR, "Subtype %s resolves to non-entity %s on line %d.", NULL, false}, + [NOT_A_TYPE] = {SEVERITY_ERROR, "Expected a type (or entity) but %s is %s.", NULL, false}, + [FUNCALL_NOT_A_FUNCTION] = {SEVERITY_ERROR, "Function call of %s which is not a function.", NULL, false}, + [UNDEFINED_FUNC] = {SEVERITY_ERROR, "Function %s undefined.", NULL, false}, + [EXPECTED_PROC] = {SEVERITY_ERROR, "%s is used as a procedure call but is not defined as one (line %d).", NULL, false}, + [NO_SUCH_PROCEDURE] = {SEVERITY_ERROR, "No such procedure as %s.", NULL, false}, + [WRONG_ARG_COUNT] = {SEVERITY_WARNING, "Call to %s uses %d arguments, but expected %d.", NULL, false}, + [QUERY_REQUIRES_AGGREGATE] = {SEVERITY_ERROR, "Query expression source must be an aggregate.", NULL, false}, + [SELF_IS_UNKNOWN] = {SEVERITY_ERROR, "SELF is not within an entity declaration.", NULL, false}, + [INVERSE_BAD_ENTITY] = {SEVERITY_ERROR, "Attribute %s is referenced from non-entity-inheriting type.", NULL, false}, + [INVERSE_BAD_ATTR] = {SEVERITY_ERROR, "Unknown attribute %s in entity %s in inverse.", NULL, false}, + [MISSING_SUPERTYPE] = {SEVERITY_ERROR, "Entity %s missing from supertype list for subtype %s.", NULL, false}, + [TYPE_IS_ENTITY] = {SEVERITY_ERROR, "An entity (%s) is not acceptable as an underlying type.", "entity_as_type", false}, + [AMBIGUOUS_ATTR] = {SEVERITY_WARNING, "Ambiguous attribute reference %s.", NULL, false}, + [AMBIGUOUS_GROUP] = {SEVERITY_WARNING, "Ambiguous group reference %s.", NULL, false}, + [OVERLOADED_ATTR] = {SEVERITY_ERROR, "Attribute %s already inherited via supertype %s.", NULL, false}, + [REDECL_NO_SUCH_ATTR] = {SEVERITY_ERROR, "Redeclared attribute %s not declared in supertype %s.", NULL, false}, + [REDECL_NO_SUCH_SUPERTYPE] = {SEVERITY_ERROR, "No such supertype %s for redeclaration of attribute %s.", NULL, false}, + [MISSING_SELF] = {SEVERITY_ERROR, "Domain rule %s must refer to SELF or attribute.", NULL, false}, + [FN_SKIP_BRANCH] = {SEVERITY_WARNING, "IF statement condition is always %s. Ignoring branch that is never taken.", "invariant_condition", false}, + [CASE_SKIP_LABEL] = {SEVERITY_WARNING, "CASE label %s cannot be matched. Ignoring its statements.", "invalid_case", false}, + [UNIQUE_QUAL_REDECL] = {SEVERITY_WARNING, "Possibly unnecessary qualifiers on redeclared attr '%s' in a uniqueness rule of entity '%s'.", "unnecessary_qualifiers", false}, + /* type.c */ + [CORRUPTED_TYPE] = {SEVERITY_DUMP, "Corrupted type in %s", NULL, false}, + [UNDEFINED_TAG] = {SEVERITY_ERROR, "Undefined type tag %s", NULL, false}, + /* exppp.c */ + [SELECT_EMPTY] = {SEVERITY_ERROR, "select type %s has no members", NULL, false}, +}; + + bool __ERROR_buffer_errors = false; const char * current_filename = "stdin"; /* flag to remember whether non-warning errors have occurred */ bool ERRORoccurred = false; - Error experrc = ERROR_none; Error ERROR_subordinate_failed = ERROR_none; Error ERROR_syntax_expecting = ERROR_none; @@ -87,12 +174,8 @@ int malloc_debug_resolve = 0; /* for debugging yacc/lex */ int debug = 0; -struct Linked_List_ * ERRORwarnings; - void ( *ERRORusage_function )( void ); -#include "express/express.h" - #define ERROR_MAX_ERRORS 100 /**< max line-numbered errors */ #define ERROR_MAX_SPACE 4000 /**< max space for line-numbered errors */ #define ERROR_MAX_STRLEN 200 /**< assuming all error messages are less than this, @@ -150,16 +233,10 @@ static void ERROR_nexterror() { /** Initialize the Error module */ void ERRORinitialize( void ) { - ERROR_subordinate_failed = - ERRORcreate( "A subordinate failed.", SEVERITY_ERROR ); - ERROR_syntax_expecting = - ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT ); - ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); - #ifdef SIGQUIT signal( SIGQUIT, ERRORabort ); #endif @@ -176,56 +253,22 @@ void ERRORinitialize( void ) { /** Clean up the Error module */ void ERRORcleanup( void ) { - ERRORdestroy( ERROR_subordinate_failed ); - ERRORdestroy( ERROR_syntax_expecting ); - sc_free( ERROR_string_base ); } -/** Need the LIST routines to complete ERROR initialization */ -void ERRORinitialize_after_LIST( void ) { - ERRORwarnings = LISTcreate(); -} - -void ERRORcreate_warning( char * name, Error error ) { - struct Error_Warning_ *o; - - /* first check if we know about this type of error */ - LISTdo( ERRORwarnings, opt, Error_Warning ) { - if( !strcmp( name, opt->name ) ) { - LISTadd_last( opt->errors, error ); - return; +void ERRORset_warning(char * name, bool warn_only) { + Error err; + bool found = false; + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + err = &LibErrors[errnum]; + if (err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { + found = true; + err->override = warn_only; } - } LISTod - - /* new error */ - o = ERROR_OPT_new(); - o->name = name; - o->errors = LISTcreate(); - LISTadd_last( o->errors, error ); - LISTadd_last( ERRORwarnings, o ); -} - -void ERRORset_warning( char * name, int set ) { - - if( !strcmp( name, "all" ) ) { - ERRORset_all_warnings( set ); - } else if( !strcmp( name, "none" ) ) { - ERRORset_all_warnings( !set ); - } else { - bool found = false; - LISTdo( ERRORwarnings, opt, Error_Warning ) { - if( !strcmp( opt->name, name ) ) { - found = true; - LISTdo_n( opt->errors, err, Error, b ) { - err->enabled = set; - } LISTod - } - } LISTod - if( found ) { - return; - } - + } + + if (!found) { fprintf( stderr, "unknown warning: %s\n", name ); if( ERRORusage_function ) { ( *ERRORusage_function )(); @@ -235,24 +278,56 @@ void ERRORset_warning( char * name, int set ) { } } -/** \fn ERRORdisable -** \param error error to disable -** Disable an error (ERRORreport*() will ignore it) -** \note this function is inlined in error.h -*/ +void ERRORset_all_warnings( bool warn_only ) { + Error err; + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + err = &LibErrors[errnum]; + if (err->severity <= SEVERITY_WARNING) { + err->override = warn_only; + } + } +} -/** \fn ERRORenable -** \param error error to enable -** Enable an error (ERRORreport*() will report it) -** \note this function is inlined in error.h -*/ +char * ERRORget_warnings_help(const char* prefix, const char *eol) { + unsigned int sz = 2048, len, clen; + char *buf, *nbuf; + Error err; + + clen = strlen(prefix) + strlen(eol) + 1; + + buf = sc_malloc(sz); + if (!buf) { + fprintf(error_file, "failed to allocate memory for warnings help!\n"); + } + buf[0] = '\0'; + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + err = &LibErrors[errnum]; + if (err->name) { + len = strlen(buf) + strlen(err->name) + clen; + if (len > sz) { + sz *= 2; + nbuf = sc_realloc(buf, sz); + if (!nbuf) { + fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); + } + buf = nbuf; + } + strcat(buf, prefix); + strcat(buf, err->name); + strcat(buf, eol); + } + } + + return buf; +} -/** \fn ERRORis_enabled -** \param error error to test -** \return is reporting of the error enabled? -** Check whether an error is enabled -** \note this function is inlined in error.h -*/ +bool +ERRORis_enabled(enum ErrorCode errnum) { + Error err = &LibErrors[errnum]; + return !err->override; +} /** \fn ERRORreport ** \param what error to report @@ -262,30 +337,21 @@ void ERRORset_warning( char * name, int set ) { ** Notes: The second and subsequent arguments should match the ** format fields of the message generated by 'what.' */ -void ERRORset_all_warnings( int set ) { - LISTdo( ERRORwarnings, opts, Error_Warning ) { - LISTdo_n( opts->errors, err, Error, b ) { - err->enabled = set; - } LISTod - } LISTod -} - void -ERRORreport( Error what, ... ) { - /* extern void abort(void);*/ +ERRORreport( enum ErrorCode errnum, ... ) { va_list args; - va_start( args, what ); - if( ( what != ERROR_none ) && - ( what != ERROR_subordinate_failed ) && - what->enabled ) { + va_start( args, errnum ); + Error what = &LibErrors[errnum]; + + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum) ) { if( what->severity >= SEVERITY_ERROR ) { - fprintf( error_file, "ERROR PE%03d: ", what->serial ); + fprintf( error_file, "ERROR PE%03d: ", errnum ); vfprintf( error_file, what->message, args ); fputc( '\n', error_file ); ERRORoccurred = true; } else { - fprintf( error_file, "WARNING PW%03d: %d", what->serial, what->severity ); + fprintf( error_file, "WARNING PW%03d: %d", errnum, what->severity ); vfprintf( error_file, what->message, args ); fputc( '\n', error_file ); } @@ -298,7 +364,6 @@ ERRORreport( Error what, ... ) { } } } - experrc = ERROR_none; va_end( args ); } @@ -312,34 +377,23 @@ ERRORreport( Error what, ... ) { ** format fields of the message generated by 'what.' */ void -ERRORreport_with_line( Error what, int line, ... ) { - char buf[BUFSIZ]; - char * savemsg; /* save what->message here while we fool */ - /* ERRORreport_with_line */ +ERRORreport_with_line( enum ErrorCode errnum, int line, ... ) { Symbol sym; va_list args; va_start( args, line ); sym.filename = current_filename; sym.line = line; - - vsprintf( buf, what->message, args ); - - /* gross, but there isn't any way to do this more directly */ - /* without writing yet another variant of ERRORreport_with_line */ - savemsg = what->message; - what->message = "%s"; - ERRORreport_with_symbol( what, &sym, buf ); - what->message = savemsg; + ERRORreport_with_symbol(errnum, &sym, args); } void -ERRORreport_with_symbol( Error what, Symbol * sym, ... ) { - /* extern void abort(void);*/ +ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { va_list args; va_start( args, sym ); + Error what = &LibErrors[errnum]; - if( ( what != ERROR_none ) && ( what != ERROR_subordinate_failed ) && what->enabled ) { + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { if( __ERROR_buffer_errors ) { int child, parent; @@ -365,12 +419,12 @@ ERRORreport_with_symbol( Error what, Symbol * sym, ... ) { heap[child].msg = ERROR_string; if( what->severity >= SEVERITY_ERROR ) { - ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial ); + ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); ERROR_vprintf( what->message, args ); ERROR_nexterror(); ERRORoccurred = true; } else { - ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial ); + ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); ERROR_vprintf( what->message, args ); ERROR_nexterror(); } @@ -386,12 +440,12 @@ ERRORreport_with_symbol( Error what, Symbol * sym, ... ) { } } else { if( what->severity >= SEVERITY_ERROR ) { - fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial ); + fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); vfprintf( error_file, what->message, args ); fprintf( error_file, "\n" ); ERRORoccurred = true; } else { - fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial ); + fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); vfprintf( error_file, what->message, args ); fprintf( error_file, "\n" ); } @@ -404,7 +458,6 @@ ERRORreport_with_symbol( Error what, Symbol * sym, ... ) { } } } - experrc = ERROR_none; va_end( args ); } @@ -413,28 +466,6 @@ void ERRORnospace() { ERRORabort( 0 ); } -/** -** \param message error message -** \param severity severity of error -** \return newly created error -** Create a new error -*/ -Error ERRORcreate( char * message, Severity severity ) { - static int errnum = 0; /* give each error type a unique identifier */ - Error n; - - n = ( struct Error_ * )sc_malloc( sizeof( struct Error_ ) ); - n->message = message; - n->severity = severity; - n->enabled = true; - n->serial = errnum++; - return n; -} - -void ERRORdestroy( Error error ) { - sc_free( error ); -} - /** \fn ERRORbuffer_messages ** \param flag - to buffer or not to buffer ** Selects buffering of error messages @@ -454,7 +485,7 @@ void ERROR_start_message_buffer( void ) { } void ERROR_flush_message_buffer( void ) { - if( __ERROR_buffer_errors == false ) { + if(!__ERROR_buffer_errors) { return; } @@ -490,16 +521,21 @@ void ERROR_flush_message_buffer( void ) { void ERRORabort( int sig ) { (void) sig; /* quell unused param warning */ - ERRORflush_messages(); - if( !ERRORdebugging ) { - if( ERROR_unsafe ) { - longjmp( ERROR_safe_env, 1 ); - } + + /* TODO: rework - fprintf is not atomic + * so ERRORflush_messages() is unsafe if __ERROR_buffer_errors is set + */ + + /* NOTE: signals can be caught in gdb, + * no need for special treatment of debugging scenario */ + if( ERROR_unsafe ) { + longjmp( ERROR_safe_env, 1 ); + } #ifdef SIGABRT - signal( SIGABRT, SIG_DFL ); + signal( SIGABRT, SIG_DFL ); #endif - abort(); - } + /* TODO: library shouldn't abort an application? */ + abort(); } void ERRORsafe( jmp_buf env ) { diff --git a/src/express/expparse.y b/src/express/expparse.y index 441c4efe6..f6bc296c2 100644 --- a/src/express/expparse.y +++ b/src/express/expparse.y @@ -402,7 +402,7 @@ aggregate_type(A) ::= TOK_AGGREGATE TOK_OF parameter_type(B). Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_unlabelled_param_type, &sym, + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } @@ -1257,7 +1257,7 @@ generic_type(A) ::= TOK_GENERIC. Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_unlabelled_param_type, &sym, + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } @@ -1551,7 +1551,7 @@ literal(A) ::= TOK_REAL_LITERAL(B). Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_warn_small_real, &sym, B.rVal ); + ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, B.rVal ); } if( fabs( B.rVal ) < DBL_MIN ) { A = LITERAL_ZERO; @@ -2431,7 +2431,7 @@ while_control(A) ::= TOK_WHILE expression(B). sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_syntax, &sym, "Syntax error", + ERRORreport_with_symbol(SYNTAX, &sym, "Syntax error", CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); } diff --git a/src/express/expr.c b/src/express/expr.c index 4b4fa81fc..7f814cf89 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -85,21 +85,7 @@ Expression LITERAL_PI = EXPRESSION_NULL; Expression LITERAL_ZERO = EXPRESSION_NULL; Expression LITERAL_ONE; -Error ERROR_bad_qualification = ERROR_none; -Error ERROR_integer_expression_expected = ERROR_none; -Error ERROR_implicit_downcast = ERROR_none; -Error ERROR_ambig_implicit_downcast = ERROR_none; - void EXPop_init(); -static Error ERROR_internal_unrecognized_op_in_EXPresolve; -/* following two could probably be combined */ -static Error ERROR_attribute_reference_on_aggregate; -static Error ERROR_attribute_ref_from_nonentity; -static Error ERROR_indexing_illegal; -static Error ERROR_warn_indexing_mixed; -static Error ERROR_enum_no_such_item; -static Error ERROR_group_ref_no_such_entity; -static Error ERROR_group_ref_unexpected_type; static inline int OPget_number_of_operands( Op_Code op ) { if( ( op == OP_NEGATE ) || ( op == OP_NOT ) ) { @@ -147,58 +133,10 @@ void EXPinitialize( void ) { LITERAL_ONE->u.integer = 1; resolved_all( LITERAL_ONE ); - ERROR_integer_expression_expected = ERRORcreate( - "Integer expression expected", SEVERITY_WARNING ); - - ERROR_internal_unrecognized_op_in_EXPresolve = ERRORcreate( - "Opcode unrecognized while trying to resolve expression", SEVERITY_ERROR ); - - ERROR_attribute_reference_on_aggregate = ERRORcreate( - "Attribute %s cannot be referenced from an aggregate", SEVERITY_ERROR ); - - ERROR_attribute_ref_from_nonentity = ERRORcreate( - "Attribute %s cannot be referenced from a non-entity", SEVERITY_ERROR ); - - ERROR_indexing_illegal = ERRORcreate( - "Indexing is only permitted on aggregates", SEVERITY_ERROR ); - - ERROR_warn_indexing_mixed = ERRORcreate( "Indexing upon a select (%s), with mixed base types (aggregates and " - "non-aggregates) and/or different aggregation types.", SEVERITY_WARNING ); - - ERROR_enum_no_such_item = ERRORcreate( - "Enumeration type %s does not contain item %s", SEVERITY_ERROR ); - - ERROR_group_ref_no_such_entity = ERRORcreate( - "Group reference failed to find entity %s", SEVERITY_ERROR ); - - ERROR_group_ref_unexpected_type = ERRORcreate( - "Group reference of unusual expression %s", SEVERITY_ERROR ); - - ERROR_implicit_downcast = ERRORcreate( - "Implicit downcast to %s.", SEVERITY_WARNING ); - - ERROR_ambig_implicit_downcast = ERRORcreate( - "Possibly ambiguous implicit downcast (%s?).", SEVERITY_WARNING ); - - ERRORcreate_warning( "downcast", ERROR_implicit_downcast ); - ERRORcreate_warning( "downcast", ERROR_ambig_implicit_downcast ); - ERRORcreate_warning( "indexing", ERROR_warn_indexing_mixed ); - EXPop_init(); } void EXPcleanup( void ) { - ERRORdestroy( ERROR_integer_expression_expected ); - ERRORdestroy( ERROR_internal_unrecognized_op_in_EXPresolve ); - ERRORdestroy( ERROR_attribute_reference_on_aggregate ); - ERRORdestroy( ERROR_attribute_ref_from_nonentity ); - ERRORdestroy( ERROR_indexing_illegal ); - ERRORdestroy( ERROR_warn_indexing_mixed ); - ERRORdestroy( ERROR_enum_no_such_item ); - ERRORdestroy( ERROR_group_ref_no_such_entity ); - ERRORdestroy( ERROR_group_ref_unexpected_type ); - ERRORdestroy( ERROR_implicit_downcast ); - ERRORdestroy( ERROR_ambig_implicit_downcast ); } /** @@ -349,10 +287,10 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { LISTod; if( all_enums ) { - ERRORreport_with_symbol( WARNING_case_skip_label, &op2->symbol, op2->symbol.name ); + ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name ); } else { /* no possible resolutions */ - ERRORreport_with_symbol( ERROR_undefined_attribute, &op2->symbol, op2->symbol.name ); + ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name ); } resolve_failed( expr ); return( Type_Bad ); @@ -360,7 +298,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { /* only one possible resolution */ if( dt == OBJ_VARIABLE ) { if( where ) { - ERRORreport_with_symbol( ERROR_implicit_downcast, &op2->symbol, where->name ); + ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } if( v == VARIABLE_NULL ) { @@ -385,7 +323,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { /* compile-time ambiguous */ if( where ) { /* this is actually a warning, not an error */ - ERRORreport_with_symbol( ERROR_ambig_implicit_downcast, &op2->symbol, where->name ); + ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } return( Type_Runtime ); } @@ -433,7 +371,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { * which calls EXP_resolve_op_dot_fuzzy(). */ item = ( Expression )DICTlookup( TYPEget_enum_tags( op1type ), op2->symbol.name ); if( !item ) { - ERRORreport_with_symbol( ERROR_enum_no_such_item, &op2->symbol, + ERRORreport_with_symbol(ENUM_NO_SUCH_ITEM, &op2->symbol, op1type->symbol.name, op2->symbol.name ); resolve_failed( expr ); return( Type_Bad ); @@ -448,7 +386,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { case bag_: case list_: case set_: - ERRORreport_with_symbol( ERROR_attribute_reference_on_aggregate, + ERRORreport_with_symbol(ATTRIBUTE_REF_ON_AGGREGATE, &op2->symbol, op2->symbol.name ); /*FALLTHRU*/ case unknown_: /* unable to resolved operand */ @@ -456,7 +394,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { resolve_failed( expr ); return( Type_Bad ); default: - ERRORreport_with_symbol( ERROR_attribute_ref_from_nonentity, + ERRORreport_with_symbol(ATTRIBUTE_REF_FROM_NON_ENTITY, &op2->symbol, op2->symbol.name ); resolve_failed( expr ); return( Type_Bad ); @@ -553,7 +491,7 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) { ent_ref = ( Entity )ENTITYfind_inherited_entity( tmp, op2->symbol.name, 1 ); if( !ent_ref ) { - ERRORreport_with_symbol( ERROR_group_ref_no_such_entity, + ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, &op2->symbol, op2->symbol.name ); resolve_failed( expr ); return( Type_Bad ); @@ -581,7 +519,7 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) { switch( options ) { case 0: /* no possible resolutions */ - ERRORreport_with_symbol( ERROR_group_ref_no_such_entity, + ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, &op2->symbol, op2->symbol.name ); resolve_failed( expr ); return( Type_Bad ); @@ -611,7 +549,7 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) { case list_: case set_: default: - ERRORreport_with_symbol( ERROR_group_ref_unexpected_type, + ERRORreport_with_symbol(GROUP_REF_UNEXPECTED_TYPE, &op1->symbol ); return( Type_Bad ); } @@ -683,7 +621,7 @@ void EXPresolve_op_default( Expression e, Scope s ) { Type EXPresolve_op_unknown( Expression e, Scope s ) { (void) e; /* quell unused param warning */ (void) s; - ERRORreport( ERROR_internal_unrecognized_op_in_EXPresolve ); + ERRORreport( INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE ); return Type_Bad; } @@ -706,7 +644,7 @@ Type EXPresolve_op_array_like( Expression e, Scope s ) { } else if( op1type == Type_Runtime ) { return( Type_Runtime ); } else if( op1type->u.type->body->type == binary_ ) { - ERRORreport_with_symbol( ERROR_warn_unsupported_lang_feat, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__ ); + ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__ ); return( Type_Binary ); } else if( op1type->u.type->body->type == generic_ ) { return( Type_Generic ); @@ -748,15 +686,15 @@ Type EXPresolve_op_array_like( Expression e, Scope s ) { return( lasttype->u.type->body->base ); } else if( numNonAggr == 0 ) { /* All aggregates, but different types */ - ERRORreport_with_symbol( ERROR_warn_indexing_mixed, &e->symbol, op1type->symbol.name ); + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ } else if( numAggr != 0 ) { /* One or more aggregates, one or more nonaggregates */ - ERRORreport_with_symbol( ERROR_warn_indexing_mixed, &e->symbol, op1type->symbol.name ); + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ } /* Else, all are nonaggregates. This is an error. */ } - ERRORreport_with_symbol( ERROR_indexing_illegal, &e->symbol ); + ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol ); return( Type_Unknown ); } @@ -858,14 +796,14 @@ void EXPop_init() { ** Compute the value of an integer expression. */ int EXPget_integer_value( Expression expression ) { - experrc = ERROR_none; + /* TODO: why is this treated differently than a type error below? */ if( expression == EXPRESSION_NULL ) { return 0; } if( expression->return_type->u.type->body->type == integer_ ) { return INT_LITget_value( expression ); } else { - experrc = ERROR_integer_expression_expected; + ERRORreport(INTEGER_EXPRESSION_EXPECTED); return 0; } } diff --git a/src/express/express.c b/src/express/express.c index f8a517b33..82e7b7889 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -110,21 +110,11 @@ void procdef(char *name, int pcount); void BUILTINSinitialize(); Dictionary EXPRESSbuiltins; /* procedures/functions */ -Error ERROR_bail_out = ERROR_none; -Error ERROR_syntax = ERROR_none; -Error ERROR_unlabelled_param_type = ERROR_none; -Error ERROR_file_unreadable; -Error ERROR_file_unwriteable; -Error ERROR_warn_unsupported_lang_feat; -Error ERROR_warn_small_real; struct Scope_ * FUNC_NVL; struct Scope_ * FUNC_USEDIN; extern Express yyexpresult; -static Error ERROR_ref_nonexistent; -static Error ERROR_tilde_expansion_failed; -static Error ERROR_schema_not_in_own_schema_file; extern Linked_List PARSEnew_schemas; void SCOPEinitialize( void ); @@ -267,7 +257,6 @@ void EXPRESSinitialize( void ) { HASHinitialize(); /* comes first - used by just about everything else! */ DICTinitialize(); LISTinitialize(); /* ditto */ - ERRORinitialize_after_LIST(); STACKinitialize(); PASSinitialize(); @@ -293,28 +282,6 @@ void EXPRESSinitialize( void ) { BUILTINSinitialize(); - ERROR_bail_out = ERRORcreate( "Aborting due to internal error(s)", SEVERITY_DUMP ); - ERROR_syntax = ERRORcreate( "%s in %s %s", SEVERITY_EXIT ); - /* i.e., "syntax error in procedure foo" */ - ERROR_ref_nonexistent = ERRORcreate( "USE/REF of non-existent object (%s in schema %s)", SEVERITY_ERROR ); - ERROR_tilde_expansion_failed = ERRORcreate( - "Tilde expansion for %s failed in EXPRESS_PATH environment variable", SEVERITY_ERROR ); - ERROR_schema_not_in_own_schema_file = ERRORcreate( - "Schema %s was not found in its own schema file (%s)", SEVERITY_ERROR ); - ERROR_unlabelled_param_type = ERRORcreate( - "Return type or local variable requires type label in `%s'", SEVERITY_ERROR ); - ERROR_file_unreadable = ERRORcreate( "Could not read file %s: %s", SEVERITY_ERROR ); - ERROR_file_unwriteable = ERRORcreate( "Could not write file %s: %s", SEVERITY_ERROR ); - ERROR_warn_unsupported_lang_feat = ERRORcreate( "Unsupported language feature (%s) at %s:%d", SEVERITY_WARNING ); - ERROR_warn_small_real = ERRORcreate( "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " - "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", SEVERITY_WARNING ); - -/* I don't think this should be a mere warning; exppp crashes if this warning is suppressed. - * ERRORcreate_warning( "unknown_subtype", ERROR_unknown_subtype ); - */ - ERRORcreate_warning( "unsupported", ERROR_warn_unsupported_lang_feat ); - ERRORcreate_warning( "limits", ERROR_warn_small_real ); - EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */ } @@ -322,17 +289,6 @@ void EXPRESSinitialize( void ) { void EXPRESScleanup( void ) { EXPRESS_PATHfree(); - ERRORdestroy( ERROR_bail_out ); - ERRORdestroy( ERROR_syntax ); - ERRORdestroy( ERROR_ref_nonexistent ); - ERRORdestroy( ERROR_tilde_expansion_failed ); - ERRORdestroy( ERROR_schema_not_in_own_schema_file ); - ERRORdestroy( ERROR_unlabelled_param_type ); - ERRORdestroy( ERROR_file_unreadable ); - ERRORdestroy( ERROR_file_unwriteable ); - ERRORdestroy( ERROR_warn_unsupported_lang_feat ); - ERRORdestroy( ERROR_warn_small_real ); - DICTcleanup(); ERRORcleanup(); RESOLVEcleanup(); @@ -365,7 +321,7 @@ void EXPRESSparse( Express model, FILE * fp, char * filename ) { } if( !fp ) { - ERRORreport( ERROR_file_unreadable, filename, strerror( errno ) ); + ERRORreport( FILE_UNREADABLE, filename, strerror( errno ) ); return; } @@ -434,7 +390,7 @@ static Express PARSERrun( char * filename, FILE * fp ) { /* want 0 on success, 1 on invalid input, 2 on memory exhaustion */ if( yyerrstatus != 0 ) { fprintf( stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus ); - ERRORreport( ERROR_bail_out ); + ERRORreport( BAIL_OUT ); /* free model and model->u.express */ return 0; } @@ -510,7 +466,7 @@ void RENAMEresolve( Rename * r, Schema s ) { } if( is_resolve_in_progress_raw( r->old ) ) { - ERRORreport_with_symbol( ERROR_circular_reference, + ERRORreport_with_symbol( CIRCULAR_REFERENCE, r->old, r->old->name ); resolve_failed_raw( r->old ); return; @@ -519,7 +475,7 @@ void RENAMEresolve( Rename * r, Schema s ) { remote = SCOPEfind_for_rename( r->schema, r->old->name ); if( remote == 0 ) { - ERRORreport_with_symbol( ERROR_ref_nonexistent, r->old, + ERRORreport_with_symbol( REF_NONEXISTENT, r->old, r->old->name, r->schema->symbol.name ); resolve_failed_raw( r->old ); } else { @@ -596,7 +552,7 @@ Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) { if( s ) { return s; } - ERRORreport( ERROR_schema_not_in_own_schema_file, + ERRORreport( SCHEMA_NOT_IN_OWN_SCHEMA_FILE, name, dir->full ); return 0; } else { @@ -623,7 +579,7 @@ static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list r = ( Rename * )l->data; r->schema = EXPRESSfind_schema( modeldict, r->schema_sym->name ); if( !r->schema ) { - ERRORreport_with_symbol( ERROR_undefined_schema, + ERRORreport_with_symbol(UNDEFINED_SCHEMA, r->schema_sym, r->schema_sym->name ); resolve_failed_raw( r->old ); @@ -645,7 +601,7 @@ static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_Li sym = ( Symbol * )list->data; ref_schema = EXPRESSfind_schema( modeldict, sym->name ); if( !ref_schema ) { - ERRORreport_with_symbol( ERROR_undefined_schema, sym, sym->name ); + ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name ); resolve_failed( schema ); list->data = NULL; } else { diff --git a/src/express/expscan.l b/src/express/expscan.l index de23a7546..cbd56c535 100644 --- a/src/express/expscan.l +++ b/src/express/expscan.l @@ -142,7 +142,7 @@ SCANnextchar(char* buffer) #endif buffer[0] = *(SCANcurrent++); if (!isascii(buffer[0])) { - ERRORreport_with_line(ERROR_nonascii_char,yylineno, + ERRORreport_with_line(NONASCII_CHAR,yylineno, 0xff & buffer[0]); buffer[0] = ' '; /* substitute space */ } @@ -224,7 +224,7 @@ integer { /* bad identifier */ [_A-Za-z]id_char* { - ERRORreport_with_line(ERROR_bad_identifier, yylineno, yytext); + ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); return SCANprocess_identifier_or_keyword(yytext); } @@ -235,7 +235,7 @@ integer { } "'"([^'\n]|"''")*'\n' { - ERRORreport_with_line(ERROR_unterminated_string, LINENO_FUDGE); + ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); NEWLINE; return SCANprocess_string(yytext); } @@ -245,7 +245,7 @@ integer { } '"'[^\"\n]*'\n' { - ERRORreport_with_line(ERROR_unterminated_string, LINENO_FUDGE); + ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); NEWLINE; return SCANprocess_encoded_string(yytext); } @@ -299,7 +299,7 @@ integer { } "*)" { - ERRORreport_with_line(ERROR_unmatched_close_comment, yylineno); + ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); IGNORE_TOKEN; } @@ -316,7 +316,7 @@ integer { /* As per N15, 7.1.5.3, all other recognized chars are incorrect - DEL */ [$%&@\^{}~] { - ERRORreport_with_line(ERROR_unexpected_character,yylineno,yytext[0]); + ERRORreport_with_line(UNEXPECTED_CHARACTER,yylineno,yytext[0]); IGNORE_TOKEN; } diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index d689b22ae..217c349d6 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -2348,7 +2348,7 @@ static void yy_reduce( Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_unlabelled_param_type, &sym, + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } @@ -3298,7 +3298,7 @@ static void yy_reduce( Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_unlabelled_param_type, &sym, + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } @@ -3578,7 +3578,7 @@ static void yy_reduce( Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_warn_small_real, &sym, yymsp[0].minor.yy0.rVal ); + ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal ); } if( fabs( yymsp[0].minor.yy0.rVal ) < DBL_MIN ) { yygotominor.yy401 = LITERAL_ZERO; @@ -4464,7 +4464,7 @@ static void yy_syntax_error( sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(ERROR_syntax, &sym, "Syntax error", + ERRORreport_with_symbol(SYNTAX, &sym, "Syntax error", CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); #line 4470 "expparse.c" ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index d05ec736b..b78b863a5 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -135,7 +135,7 @@ SCANbuffer.numRead--; #endif buffer[0] = *(SCANcurrent++); if (!isascii(buffer[0])) { -ERRORreport_with_line(ERROR_nonascii_char,yylineno, +ERRORreport_with_line(NONASCII_CHAR,yylineno, 0xff & buffer[0]); buffer[0] = ' '; /* substitute space */ } @@ -933,7 +933,7 @@ IGNORE_TOKEN; ++scanner->cursor; yy13: { -ERRORreport_with_line(ERROR_unexpected_character,yylineno,yytext[0]); +ERRORreport_with_line(UNEXPECTED_CHARACTER,yylineno,yytext[0]); IGNORE_TOKEN; } yy14: @@ -1093,7 +1093,7 @@ return TOK_RIGHT_BRACKET; } goto yy65; yy55: { -ERRORreport_with_line(ERROR_bad_identifier, yylineno, yytext); +ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); return SCANprocess_identifier_or_keyword(yytext); } yy56: @@ -1453,7 +1453,7 @@ IGNORE_TOKEN; yy105: ++scanner->cursor; { -ERRORreport_with_line(ERROR_unmatched_close_comment, yylineno); +ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); IGNORE_TOKEN; } yy107: @@ -1497,7 +1497,7 @@ return SCANprocess_string(yytext); yy115: ++scanner->cursor; { -ERRORreport_with_line(ERROR_unterminated_string, LINENO_FUDGE); +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); NEWLINE; return SCANprocess_string(yytext); } @@ -1527,7 +1527,7 @@ return SCANprocess_binary_literal(yytext); yy122: ++scanner->cursor; { -ERRORreport_with_line(ERROR_unterminated_string, LINENO_FUDGE); +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); NEWLINE; return SCANprocess_encoded_string(yytext); } diff --git a/src/express/info.c b/src/express/info.c index 1669102a1..50af7ab11 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -26,9 +26,7 @@ void EXPRESSusage( int _exit ) { fprintf( stderr, "\t-i warning ignore\n" ); fprintf( stderr, "and is one of:\n" ); fprintf( stderr, "\tnone\n\tall\n" ); - LISTdo( ERRORwarnings, opt, Error_Warning ) - fprintf( stderr, "\t%s\n", opt->name ); - LISTod + fprintf( stderr, ERRORget_warnings_help("\t", "\n") ); fprintf( stderr, "and is one or more of:\n" ); fprintf( stderr, " e entity\n" ); fprintf( stderr, " p procedure\n" ); diff --git a/src/express/lexact.c b/src/express/lexact.c index 750ee51c8..abcde3176 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -73,17 +73,6 @@ Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; int SCAN_current_buffer = 0; char * SCANcurrent; -Error ERROR_include_file = ERROR_none; -Error ERROR_unmatched_close_comment = ERROR_none; -Error ERROR_unmatched_open_comment = ERROR_none; -Error ERROR_unterminated_string = ERROR_none; -Error ERROR_encoded_string_bad_digit = ERROR_none; -Error ERROR_encoded_string_bad_count = ERROR_none; -Error ERROR_bad_identifier = ERROR_none; -Error ERROR_unexpected_character = ERROR_none; -Error ERROR_nonascii_char; - - extern int yylineno; #define SCAN_COMMENT_LENGTH 256 @@ -250,41 +239,10 @@ void SCANinitialize( void ) { DICTdefine( keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN ); /* not "unknown", but certainly won't be looked up by type! */ } - - /* set up errors on first time through */ - if( ERROR_include_file == ERROR_none ) { - ERROR_include_file = - ERRORcreate( "Could not open include file `%s'.", SEVERITY_ERROR ); - ERROR_unmatched_close_comment = - ERRORcreate( "unmatched close comment", SEVERITY_ERROR ); - ERROR_unmatched_open_comment = - ERRORcreate( "unmatched open comment", SEVERITY_ERROR ); - ERROR_unterminated_string = - ERRORcreate( "unterminated string literal", SEVERITY_ERROR ); - ERROR_encoded_string_bad_digit = ERRORcreate( - "non-hex digit (%c) in encoded string literal", SEVERITY_ERROR ); - ERROR_encoded_string_bad_count = ERRORcreate( - "number of digits (%d) in encoded string literal is not divisible by 8", SEVERITY_ERROR ); - ERROR_bad_identifier = ERRORcreate( - "identifier (%s) cannot start with underscore", SEVERITY_ERROR ); - ERROR_unexpected_character = ERRORcreate( - "character (%c) is not a valid lexical element by itself", SEVERITY_ERROR ); - ERROR_nonascii_char = ERRORcreate( - "character (0x%x) is not in the EXPRESS character set", SEVERITY_ERROR ); - } } /** Clean up the Scan module */ void SCANcleanup( void ) { - ERRORdestroy( ERROR_include_file ); - ERRORdestroy( ERROR_unmatched_close_comment ); - ERRORdestroy( ERROR_unmatched_open_comment ); - ERRORdestroy( ERROR_unterminated_string ); - ERRORdestroy( ERROR_encoded_string_bad_digit ); - ERRORdestroy( ERROR_encoded_string_bad_count ); - ERRORdestroy( ERROR_bad_identifier ); - ERRORdestroy( ERROR_unexpected_character ); - ERRORdestroy( ERROR_nonascii_char ); } int SCANprocess_real_literal( const char * yytext ) { @@ -403,12 +361,12 @@ int SCANprocess_encoded_string( const char * yytext ) { count = 0; for( s = yylval.string; *s; s++, count++ ) { if( !isxdigit( *s ) ) { - ERRORreport_with_line( ERROR_encoded_string_bad_digit, yylineno, *s ); + ERRORreport_with_line( ENCODED_STRING_BAD_DIGIT, yylineno, *s ); } } if( 0 != ( count % 8 ) ) { - ERRORreport_with_line( ERROR_encoded_string_bad_count, yylineno, count ); + ERRORreport_with_line( ENCODED_STRING_BAD_COUNT, yylineno, count ); } return TOK_STRING_LITERAL_ENCODED; @@ -489,7 +447,7 @@ void SCANinclude_file( char * filename ) { FILE * fp; if( ( fp = fopen( filename, "r" ) ) == NULL ) { - ERRORreport_with_line( ERROR_include_file, yylineno ); + ERRORreport_with_line( INCLUDE_FILE, yylineno ); } else { if( print_objects_while_running & OBJ_SCHEMA_BITS ) { fprintf( stderr, "parse: including %s at line %d of %s\n", diff --git a/src/express/linklist.c b/src/express/linklist.c index dbaf118db..7089dd81d 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -23,14 +23,10 @@ #include "express/linklist.h" -Error ERROR_empty_list = ERROR_none; - void LISTinitialize( void ) { - ERROR_empty_list = ERRORcreate( "Empty list in %s.", SEVERITY_ERROR ); } void LISTcleanup( void ) { - ERRORdestroy( ERROR_empty_list ); } Linked_List LISTcreate() { @@ -152,7 +148,7 @@ void *LISTremove_first( Linked_List list ) { node = list->mark->next; if( node == list->mark ) { - ERRORreport( ERROR_empty_list, "LISTremove_first" ); + ERRORreport( EMPTY_LIST, "LISTremove_first" ); return NULL; } item = node->data; diff --git a/src/express/memory.c b/src/express/memory.c index 9a83b83db..f8b536e45 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -60,8 +60,6 @@ void MEMORYinitialize() { ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); - ALLOCinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 ); - ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); diff --git a/src/express/resolve.c b/src/express/resolve.c index 114e25158..fa5797917 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -64,43 +64,6 @@ int print_objects_while_running = 0; -Error ERROR_undefined_attribute = ERROR_none; -Error ERROR_undefined_type = ERROR_none; -Error ERROR_undefined_schema = ERROR_none; -Error ERROR_unknown_attr_in_entity = ERROR_none; -Error ERROR_unknown_subtype = ERROR_none; -Error ERROR_unknown_supertype = ERROR_none; -Error ERROR_circular_reference = ERROR_none; -Error ERROR_ambiguous_attribute = ERROR_none; -Error ERROR_ambiguous_group = ERROR_none; -Error WARNING_fn_skip_branch = ERROR_none; -Error WARNING_case_skip_label = ERROR_none; - -static Error ERROR_wrong_arg_count; -static Error ERROR_supertype_resolve; -static Error ERROR_subtype_resolve; -static Error ERROR_not_a_type; -static Error ERROR_funcall_not_a_function; -static Error ERROR_undefined_func; -static Error ERROR_undefined; -static Error ERROR_expected_proc; -static Error ERROR_no_such_procedure; -static Error ERROR_query_requires_aggregate; -static Error ERROR_self_is_unknown; -static Error ERROR_inverse_bad_attribute; -static Error ERROR_inverse_bad_entity; -static Error ERROR_missing_supertype; -static Error ERROR_subsuper_loop; -static Error ERROR_subsuper_continuation; -static Error ERROR_select_loop; -static Error ERROR_select_continuation; -static Error ERROR_type_is_entity; -static Error ERROR_overloaded_attribute; -static Error ERROR_redecl_no_such_attribute; -static Error ERROR_redecl_no_such_supertype; -static Error ERROR_missing_self; -static Error WARNING_unique_qual_redecl; - static Type self = 0; /**< always points to current value of SELF or 0 if none */ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clause */ @@ -113,154 +76,10 @@ extern void VAR_resolve_types( Variable v ); /** Initialize the Fed-X second pass. */ void RESOLVEinitialize( void ) { - ERROR_undefined = ERRORcreate( - "Reference to undefined object %s.", SEVERITY_ERROR ); - - ERROR_undefined_attribute = ERRORcreate( - "Reference to undefined attribute %s.", SEVERITY_ERROR ); - - ERROR_undefined_type = ERRORcreate( - "Reference to undefined type %s.", SEVERITY_ERROR ); - - ERROR_undefined_schema = ERRORcreate( - "Reference to undefined schema %s.", SEVERITY_ERROR ); - - ERROR_unknown_attr_in_entity = ERRORcreate( - "Unknown attribute %s in entity %s.", SEVERITY_ERROR ); - - ERROR_unknown_subtype = ERRORcreate( - "Unknown subtype %s for entity %s.", SEVERITY_EXIT ); - /*"Unknown subtype %s for entity %s.", SEVERITY_WARNING);*/ - - ERROR_unknown_supertype = ERRORcreate( - "Unknown supertype %s for entity %s.", SEVERITY_ERROR ); - - ERROR_circular_reference = ERRORcreate( - "Circularity: definition of %s references itself.", SEVERITY_ERROR ); - /*"Circular definition: schema %s referenced schema %s.",SEVERITY_ERROR);*/ - - ERROR_subsuper_loop = ERRORcreate( - "Entity %s is a subtype of itself", SEVERITY_ERROR ); - ERROR_subsuper_continuation = ERRORcreate( - " (via supertype entity %s)", SEVERITY_ERROR ); - - ERROR_select_loop = ERRORcreate( - "Select type %s selects itself", SEVERITY_ERROR ); - ERROR_select_continuation = ERRORcreate( - " (via select type %s)", SEVERITY_ERROR ); - - ERROR_supertype_resolve = ERRORcreate( - "Supertype %s is not an entity (line %d).", SEVERITY_ERROR ); - - ERROR_subtype_resolve = ERRORcreate( - "Subtype %s resolves to non-entity %s on line %d.", SEVERITY_ERROR ); - - ERROR_not_a_type = ERRORcreate( - "Expected a type (or entity) but %s is %s.", SEVERITY_ERROR ); - - ERROR_funcall_not_a_function = ERRORcreate( - "Function call of %s which is not a function.", SEVERITY_ERROR ); - - ERROR_undefined_func = ERRORcreate( - "Function %s undefined.", SEVERITY_ERROR ); - - ERROR_expected_proc = ERRORcreate( - "%s is used as a procedure call but is not defined as one (line %d).", SEVERITY_ERROR ); - - ERROR_no_such_procedure = ERRORcreate( - "No such procedure as %s.", SEVERITY_ERROR ); - - ERROR_wrong_arg_count = ERRORcreate( - "Call to %s uses %d arguments, but expected %d.", SEVERITY_WARNING ); - - ERROR_query_requires_aggregate = ERRORcreate( - "Query expression source must be an aggregate.", SEVERITY_ERROR ); - - ERROR_self_is_unknown = ERRORcreate( - "SELF is not within an entity declaration.", SEVERITY_ERROR ); - - ERROR_inverse_bad_entity = ERRORcreate( - "Attribute %s is referenced from non-entity-inheriting type.", SEVERITY_ERROR ); - - ERROR_inverse_bad_attribute = ERRORcreate( - "Unknown attribute %s in entity %s in inverse.", SEVERITY_ERROR ); - - ERROR_missing_supertype = ERRORcreate( - "Entity %s missing from supertype list for subtype %s.", SEVERITY_ERROR ); - - ERROR_type_is_entity = ERRORcreate( - "An entity (%s) is not acceptable as an underlying type.", SEVERITY_ERROR ); - - ERROR_ambiguous_attribute = ERRORcreate( - "Ambiguous attribute reference %s.", SEVERITY_WARNING ); - - ERROR_ambiguous_group = ERRORcreate( - "Ambiguous group reference %s.", SEVERITY_WARNING ); - - ERROR_overloaded_attribute = ERRORcreate( - "Attribute %s already inherited via supertype %s.", SEVERITY_ERROR ); - - ERROR_redecl_no_such_attribute = ERRORcreate( - "Redeclared attribute %s not declared in supertype %s.", SEVERITY_ERROR ); - - ERROR_redecl_no_such_supertype = ERRORcreate( - "No such supertype %s for redeclaration of attribute %s.", SEVERITY_ERROR ); - - ERROR_missing_self = ERRORcreate( - "Domain rule %s must refer to SELF or attribute.", SEVERITY_ERROR ); - - WARNING_fn_skip_branch = ERRORcreate( - "IF statement condition is always %s. Ignoring branch that is never taken.", SEVERITY_WARNING ); - - WARNING_case_skip_label = ERRORcreate( "CASE label %s cannot be matched. Ignoring its statements.", SEVERITY_WARNING ); - - WARNING_unique_qual_redecl = ERRORcreate( "Possibly unnecessary qualifiers on redeclared attr '%s' in a uniqueness rule of entity '%s'.", SEVERITY_WARNING ); - - ERRORcreate_warning( "circular_subtype", ERROR_subsuper_loop ); - ERRORcreate_warning( "circular_select", ERROR_select_loop ); - ERRORcreate_warning( "entity_as_type", ERROR_type_is_entity ); - ERRORcreate_warning( "invariant_condition", WARNING_fn_skip_branch ); - ERRORcreate_warning( "invalid_case", WARNING_case_skip_label ); - ERRORcreate_warning( "unnecessary_qualifiers", WARNING_unique_qual_redecl ); } /** Clean up the Fed-X second pass */ void RESOLVEcleanup( void ) { - ERRORdestroy( ERROR_undefined ); - ERRORdestroy( ERROR_undefined_attribute ); - ERRORdestroy( ERROR_undefined_type ); - ERRORdestroy( ERROR_undefined_schema ); - ERRORdestroy( ERROR_unknown_attr_in_entity ); - ERRORdestroy( ERROR_unknown_subtype ); - ERRORdestroy( ERROR_unknown_supertype ); - ERRORdestroy( ERROR_circular_reference ); - ERRORdestroy( ERROR_subsuper_loop ); - ERRORdestroy( ERROR_subsuper_continuation ); - ERRORdestroy( ERROR_select_loop ); - ERRORdestroy( ERROR_select_continuation ); - ERRORdestroy( ERROR_supertype_resolve ); - ERRORdestroy( ERROR_subtype_resolve ); - ERRORdestroy( ERROR_not_a_type ); - ERRORdestroy( ERROR_funcall_not_a_function ); - ERRORdestroy( ERROR_undefined_func ); - ERRORdestroy( ERROR_expected_proc ); - ERRORdestroy( ERROR_no_such_procedure ); - ERRORdestroy( ERROR_wrong_arg_count ); - ERRORdestroy( ERROR_query_requires_aggregate ); - ERRORdestroy( ERROR_self_is_unknown ); - ERRORdestroy( ERROR_inverse_bad_entity ); - ERRORdestroy( ERROR_inverse_bad_attribute ); - ERRORdestroy( ERROR_missing_supertype ); - ERRORdestroy( ERROR_type_is_entity ); - ERRORdestroy( ERROR_ambiguous_attribute ); - ERRORdestroy( ERROR_ambiguous_group ); - ERRORdestroy( ERROR_overloaded_attribute ); - ERRORdestroy( ERROR_redecl_no_such_attribute ); - ERRORdestroy( ERROR_redecl_no_such_supertype ); - ERRORdestroy( ERROR_missing_self ); - ERRORdestroy( WARNING_case_skip_label ); - ERRORdestroy( WARNING_fn_skip_branch ); - ERRORdestroy( WARNING_unique_qual_redecl ); } /** @@ -324,15 +143,13 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { x = SCOPEfind( scope, expr->symbol.name, SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY ); if( !x ) { - ERRORreport_with_symbol( ERROR_undefined_func, - &expr->symbol, expr->symbol.name ); + ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name ); resolve_failed( expr ); break; } if( ( DICT_type != OBJ_FUNCTION ) && ( DICT_type != OBJ_ENTITY ) ) { sym = OBJget_symbol( x, DICT_type ); - ERRORreport_with_symbol( ERROR_funcall_not_a_function, - &expr->symbol, sym->name ); + ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name ); resolve_failed( expr ); break; } @@ -357,8 +174,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { /* to NVL code later which assumes args are present */ if( LISTget_length( expr->u.funcall.list ) != f->u.func->pcount ) { - ERRORreport_with_symbol( ERROR_wrong_arg_count, - &expr->symbol, expr->symbol.name, + ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, LISTget_length( expr->u.funcall.list ), f->u.func->pcount ); } @@ -447,8 +263,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { if( typecheck == Type_Unknown ) { return; } else { - ERRORreport_with_symbol( ERROR_undefined, - &expr->symbol, expr->symbol.name ); + ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name ); resolve_failed( expr ); break; } @@ -494,8 +309,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { /* but I don't think that's a problem */ if( ( ( Function )x )->u.func->pcount != 0 ) { - ERRORreport_with_symbol( ERROR_wrong_arg_count, - &expr->symbol, expr->symbol.name, 0, + ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, 0, f->u.func->pcount ); resolve_failed( expr ); } else { @@ -527,7 +341,7 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { found_self = true; resolved_all( expr ); } else { - ERRORreport_with_symbol( ERROR_self_is_unknown, &scope->symbol ); + ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol ); resolve_failed( expr ); } break; @@ -546,14 +360,14 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { /* retrieve the common aggregate type */ t = TYPE_retrieve_aggregate( expr->return_type, 0 ); if( !t ) { - ERRORreport_with_symbol( ERROR_query_requires_aggregate, &expr->u.query->aggregate->symbol ); + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); resolve_failed( expr ); break; } } else if( TYPEis_runtime( expr->return_type ) ) { t = Type_Runtime; } else { - ERRORreport_with_symbol( ERROR_query_requires_aggregate, &expr->u.query->aggregate->symbol ); + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); resolve_failed( expr ); break; } @@ -598,14 +412,14 @@ int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, /* must be a simple entity reference */ ent_ref = ( Entity )SCOPEfind( ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY ); if( !ent_ref ) { - ERRORreport_with_symbol( ERROR_unknown_subtype, &ent->symbol, + ERRORreport_with_symbol(UNKNOWN_SUBTYPE, &ent->symbol, expr->symbol.name, ent->symbol.name ); i = RESOLVE_FAILED; } else if( DICT_type != OBJ_ENTITY ) { Symbol * sym = OBJget_symbol( ent_ref, DICT_type ); /* line number should really be on supertype name, */ /* but all we have easily is the entity line number */ - ERRORreport_with_symbol( ERROR_subtype_resolve, &ent->symbol, + ERRORreport_with_symbol(SUBTYPE_RESOLVE, &ent->symbol, expr->symbol.name, sym->line ); i = RESOLVE_FAILED; } else { @@ -691,9 +505,9 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { TYPEresolve( &type->u.type->head ); if( !is_resolve_failed( type->u.type->head ) ) { - if( ERRORis_enabled( ERROR_type_is_entity ) ) { + if( ERRORis_enabled( TYPE_IS_ENTITY ) ) { if( TYPEis_entity( type->u.type->head ) ) { - ERRORreport_with_symbol( ERROR_type_is_entity, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name ); + ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name ); resolve_failed( type ); } } @@ -711,7 +525,7 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE ); /* SCOPE_FIND_TYPE | SCOPE_FIND_ENTITY);*/ if( !ref_type ) { - ERRORreport_with_symbol( ERROR_undefined_type, &type->symbol, type->symbol.name ); + ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name ); *typeaddr = Type_Bad; /* just in case */ resolve_failed( type ); } else if( DICT_type == OBJ_TYPE ) { @@ -729,7 +543,7 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { type = *typeaddr = ( ( Entity )ref_type )->u.entity->type; } else { - ERRORreport_with_symbol( ERROR_not_a_type, &type->symbol, type->symbol.name, + ERRORreport_with_symbol(NOT_A_TYPE, &type->symbol, type->symbol.name, OBJget_type( DICT_type ) ); resolve_failed( type ); } @@ -781,7 +595,7 @@ void VAR_resolve_types( Variable v ) { type = type->u.type->body->base; } if( type->u.type->body->type != entity_ ) { - ERRORreport_with_symbol( ERROR_inverse_bad_entity, + ERRORreport_with_symbol(INVERSE_BAD_ENTITY, &v->name->symbol, v->inverse_symbol->name ); } else { attr = VARfind( type->u.type->body->entity, v->inverse_symbol->name, 1 ); @@ -789,7 +603,7 @@ void VAR_resolve_types( Variable v ) { v->inverse_attribute = attr; failed |= is_resolve_failed( attr->name ); } else { - ERRORreport_with_symbol( ERROR_inverse_bad_attribute, + ERRORreport_with_symbol(INVERSE_BAD_ATTR, v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name ); } } @@ -889,12 +703,12 @@ void STMTresolve( Statement statement, Scope scope ) { if( proc ) { if( DICT_type != OBJ_PROCEDURE ) { Symbol * newsym = OBJget_symbol( proc, DICT_type ); - ERRORreport_with_symbol( ERROR_expected_proc, &statement->symbol, proc_name, newsym->line ); + ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line ); } else { statement->u.proc->procedure = proc; } } else { - ERRORreport_with_symbol( ERROR_no_such_procedure, &statement->symbol, proc_name ); + ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name ); } LISTdo( statement->u.proc->parameters, e, Expression ) EXPresolve( e, scope, Type_Dont_Care ); @@ -960,7 +774,7 @@ void ENTITYresolve_expressions( Entity e ) { sname = attr->name->e.op1->e.op2->symbol.name; if( !strcmp( sname, e->symbol.name ) || !( sup = ENTITYfind_inherited_entity( e, sname, 0 ) ) ) { - ERRORreport_with_symbol( ERROR_redecl_no_such_supertype, + ERRORreport_with_symbol(REDECL_NO_SUCH_SUPERTYPE, &attr->name->e.op1->e.op2->symbol, attr->name->e.op1->e.op2->symbol.name, VARget_simple_name( attr ) ); @@ -968,7 +782,7 @@ void ENTITYresolve_expressions( Entity e ) { } else { sname = VARget_simple_name( attr ); if( !ENTITY_get_local_attribute( sup, sname ) ) { - ERRORreport_with_symbol( ERROR_redecl_no_such_attribute, + ERRORreport_with_symbol(REDECL_NO_SUCH_ATTR, &attr->name->e.op2->symbol, sname, sup->symbol.name ); @@ -982,7 +796,7 @@ void ENTITYresolve_expressions( Entity e ) { LISTdo_n( e->u.entity->supertypes, supr, Entity, b ) { if( ENTITYget_named_attribute( supr, attr->name->symbol.name ) ) { - ERRORreport_with_symbol( ERROR_overloaded_attribute, + ERRORreport_with_symbol(OVERLOADED_ATTR, &attr->name->symbol, attr->name->symbol.name, supr->symbol.name ); @@ -1031,7 +845,7 @@ void ENTITYcheck_missing_supertypes( Entity ent ) { } } LISTod; if( !found ) { - ERRORreport_with_symbol( ERROR_missing_supertype, &sub->symbol, ent->symbol.name, sub->symbol.name ); + ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name ); resolve_failed( sub ); } } LISTod; @@ -1056,7 +870,7 @@ int ENTITY_check_subsuper_cyclicity( Entity e, Entity enew ) { /* as well */ LISTdo( enew->u.entity->subtypes, sub, Entity ) if( e == sub ) { - ERRORreport_with_symbol( ERROR_subsuper_loop, &sub->symbol, e->symbol.name ); + ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name ); return 1; } if( sub->search_id == __SCOPE_search_id ) { @@ -1064,7 +878,7 @@ int ENTITY_check_subsuper_cyclicity( Entity e, Entity enew ) { } sub->search_id = __SCOPE_search_id; if( ENTITY_check_subsuper_cyclicity( e, sub ) ) { - ERRORreport_with_symbol( ERROR_subsuper_continuation, &sub->symbol, sub->symbol.name ); + ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name ); return 1; } LISTod; @@ -1081,7 +895,7 @@ int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { LISTdo( tnew->u.type->body->list, item, Type ) if( item->u.type->body->type == select_ ) { if( tb == item->u.type->body ) { - ERRORreport_with_symbol( ERROR_select_loop, + ERRORreport_with_symbol(SELECT_LOOP, &item->symbol, item->symbol.name ); return 1; } @@ -1090,7 +904,7 @@ int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { } item->search_id = __SCOPE_search_id; if( TYPE_check_select_cyclicity( tb, item ) ) { - ERRORreport_with_symbol( ERROR_select_continuation, + ERRORreport_with_symbol(SELECT_CONTINUATION, &item->symbol, item->symbol.name ); return 1; } @@ -1124,7 +938,7 @@ void SCOPEresolve_types( Scope s ) { while( 0 != ( x = DICTdo( &de ) ) ) { switch( DICT_type ) { case OBJ_TYPE: - if( ERRORis_enabled( ERROR_select_loop ) ) { + if( ERRORis_enabled( SELECT_LOOP ) ) { TYPEcheck_select_cyclicity( ( Type )x ); } break; @@ -1141,7 +955,7 @@ void SCOPEresolve_types( Scope s ) { ENTITYcheck_missing_supertypes( ( Entity )x ); ENTITYresolve_types( ( Entity )x ); ENTITYcalculate_inheritance( ( Entity )x ); - if( ERRORis_enabled( ERROR_subsuper_loop ) ) { + if( ERRORis_enabled( SUBSUPER_LOOP ) ) { ENTITYcheck_subsuper_cyclicity( ( Entity )x ); } if( is_resolve_failed( ( Entity )x ) ) { @@ -1191,12 +1005,12 @@ void ENTITYresolve_supertypes( Entity e ) { LISTdo( e->u.entity->supertype_symbols, sym, Symbol * ) { ref_entity = ( Entity )SCOPEfind( e->superscope, sym->name, SCOPE_FIND_ENTITY ); if( !ref_entity ) { - ERRORreport_with_symbol( ERROR_unknown_supertype, sym, sym->name, e->symbol.name ); + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name ); /* ENTITY_resolve_failed = 1;*/ resolve_failed( e ); } else if( DICT_type != OBJ_ENTITY ) { Symbol * newsym = OBJget_symbol( ref_entity, DICT_type ); - ERRORreport_with_symbol( ERROR_supertype_resolve, sym, sym->name, newsym->line ); + ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line ); /* ENTITY_resolve_failed = 1;*/ resolve_failed( e ); } else { @@ -1280,7 +1094,7 @@ void ENTITYresolve_uniques( Entity e ) { if( ( attr2 ) && ( attr != attr2 ) && ( ENTITYdeclares_variable( e, attr2 ) ) ) { /* attr exists in type + supertype - it's a redeclaration. * in this case, qualifiers are unnecessary; print a warning */ - ERRORreport_with_symbol( WARNING_unique_qual_redecl, &( expr->e.op2->symbol ), expr->e.op2->symbol.name, e->symbol.name ); + ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &( expr->e.op2->symbol ), expr->e.op2->symbol.name, e->symbol.name ); } if( !attr ) { /* ERRORreport_with_symbol(ERROR_unknown_attr_in_entity,*/ @@ -1373,7 +1187,7 @@ int WHEREresolve( Linked_List list, Scope scope, int need_self ) { found_self = false; EXPresolve( w->expr, scope, Type_Dont_Care ); if( need_self && ! found_self ) { - ERRORreport_with_symbol( ERROR_missing_self, + ERRORreport_with_symbol(MISSING_SELF, w->label, w->label->name ); w->label->resolved = RESOLVE_FAILED; diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 554ef5f13..72c4d3e14 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -38,7 +38,6 @@ FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, c FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) void setup() { - ERRORwarnings = LISTcreate(); EXPinitialize(); RESET_FAKE(EXPRESS_fail); diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index 8e600f7ed..f4d0937e6 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -46,7 +46,6 @@ FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) void setup() { - ERRORwarnings = LISTcreate(); RESOLVEinitialize(); RESET_FAKE(SCOPEfind); diff --git a/src/express/type.c b/src/express/type.c index e78d7de6c..ffcba5915 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -126,10 +126,6 @@ This module implements the type abstraction. It is #include "express/type.h" -Error ERROR_corrupted_type = ERROR_none; - -static Error ERROR_undefined_tag; - Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) { Type t; extern int tag_count; @@ -152,7 +148,7 @@ Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol * then we can only refer to existing tags, so produce an error */ if( tag_count < 0 ) { - ERRORreport_with_symbol( ERROR_undefined_tag, symbol, + ERRORreport_with_symbol( UNDEFINED_TAG, symbol, symbol->name ); return( 0 ); } @@ -225,17 +221,10 @@ return( false ); /** Initialize the Type module */ void TYPEinitialize() { - ERROR_corrupted_type = - ERRORcreate( "Corrupted type in %s", SEVERITY_DUMP ); - - ERROR_undefined_tag = - ERRORcreate( "Undefined type tag %s", SEVERITY_ERROR ); } /** Clean up the Type module */ void TYPEcleanup( void ) { - ERRORdestroy( ERROR_corrupted_type ); - ERRORdestroy( ERROR_undefined_tag ); } /** From 61eec0dcc54137879bc6ec6a1e3812262f758be3 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 22 Jul 2020 22:56:30 +0100 Subject: [PATCH 065/244] drop the Generic typedef (fixup) --- src/express/factory.c | 2 +- src/express/test/test_express.c | 2 +- src/express/test/test_resolve.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/express/factory.c b/src/express/factory.c index 00bc835af..daf6ee7d3 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -366,7 +366,7 @@ Expression QUERYcreate( Symbol * local, Expression aggregate ) { Variable v = VARcreate( e2, Type_Attribute ); - DICTdefine( s->symbol_table, local->name, ( Generic )v, &e2->symbol, OBJ_VARIABLE ); + DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); e->u.query = QUERY_new(); e->u.query->scope = s; e->u.query->local = v; diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index 932a029e4..8ce3eb5e1 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -131,7 +131,7 @@ int test_express_rename_resolve() { use_ref->old = ent_ref; use_ref->nnew = ent_ref; use_ref->rename_type = use; - LISTadd_last(cur_schema->u.schema->uselist, (Generic) use_ref); + LISTadd_last(cur_schema->u.schema->uselist, use_ref); use_ref->schema = ref_schema; RENAMEresolve(use_ref, cur_schema); diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index f4d0937e6..2fc30ac68 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -36,7 +36,7 @@ int tag_count; DEFINE_FFF_GLOBALS -FAKE_VALUE_FUNC(Generic, SCOPEfind, Scope, char *, int) +FAKE_VALUE_FUNC(void *, SCOPEfind, Scope, char *, int) FAKE_VALUE_FUNC(Variable, VARfind, Scope, char *, int) FAKE_VALUE_FUNC(char *, VARget_simple_name, Variable) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) @@ -58,7 +58,7 @@ void setup() { RESET_FAKE(EXPRESS_fail); } -Generic SCOPEfind_handler(Scope scope, char * name, int type) { +void * SCOPEfind_handler(Scope scope, char * name, int type) { (void) type; return DICTlookup(scope->symbol_table, name); } From 5e28f4417a3c4ac4db8133848636fc140569eed2 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 22 Jul 2020 23:02:37 +0100 Subject: [PATCH 066/244] drop PROTO macro (fixup) --- include/express/expr.h | 2 +- include/express/scope.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/express/expr.h b/include/express/expr.h index 4abf2610d..57191d5b6 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -261,6 +261,6 @@ extern SC_EXPRESS_EXPORT void EXPcleanup( void ); extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); -Type EXPresolve_op_dot PROTO( ( Expression, Scope ) ); +Type EXPresolve_op_dot( Expression, Scope ); #endif /*EXPRESSION_H*/ diff --git a/include/express/scope.h b/include/express/scope.h index f06807788..8f16fafbf 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -144,6 +144,6 @@ extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); -Generic SCOPE_find PROTO( ( Scope, char *, int ) ); +void * SCOPE_find( Scope, char *, int ); #endif /* SCOPE_H */ From 69db0c0192dbe031202efc48ccddf54155dbebf1 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 22 Jul 2020 23:13:02 +0100 Subject: [PATCH 067/244] remove inline extern declarations --- src/express/scope.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/express/scope.c b/src/express/scope.c index 0e27db3b5..3d93509d7 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -164,7 +164,6 @@ Linked_List SCOPEget_entities_superclass_order( Scope scope ) { * caller is in a better position to describe the error with context */ void *SCOPEfind( Scope scope, char * name, int type ) { - extern void *SCOPE_find( Scope , char *, int ); extern Dictionary EXPRESSbuiltins; /* procedures/functions */ void *x; From f2ebe246fa4b1537bda96642996bbc30f3baf2a5 Mon Sep 17 00:00:00 2001 From: luz paz Date: Thu, 8 Oct 2020 16:12:36 -0400 Subject: [PATCH 068/244] Rename NotImplemented() to NotImplementedError() Fixes #395 --- src/exp2python/python/SCL/Builtin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exp2python/python/SCL/Builtin.py b/src/exp2python/python/SCL/Builtin.py index 67f590007..2b8e22939 100644 --- a/src/exp2python/python/SCL/Builtin.py +++ b/src/exp2python/python/SCL/Builtin.py @@ -536,7 +536,7 @@ def ODD(V): # Python note: # @TODO: implement the ROLESOF function def ROLESOF(V): - raise NotImplemented("Function ROLESOF not implemented") + raise NotImplementedError("Function ROLESOF not implemented") # EXPRESS definition: # =================== @@ -639,7 +639,7 @@ def TYPEOF(V): #The usedin function returns each entity instance that uses a specified entity instance in a #specified role. def USEDIN(T,R): - raise NotImplemented("USEDIN function not yet implemented.") + raise NotImplementedError("USEDIN function not yet implemented.") # EXPRESS definition: # =================== @@ -691,7 +691,7 @@ def VALUE(V): def VALUE_IN(C,V): if not isinstance(C,Aggregate): raise TypeError("VALUE_IN method takes an aggregate as first parameter") - raise NotImplemented("VALUE_IN function not yet implemented") + raise NotImplementedError("VALUE_IN function not yet implemented") # EXPRESS definition: # =================== From 227dbb84ab6da4be28d8ca510e5e9911aa7f012d Mon Sep 17 00:00:00 2001 From: luz paz Date: Thu, 8 Oct 2020 16:19:24 -0400 Subject: [PATCH 069/244] Fix all 'Testing equality to None' issues Testing whether an object is `None` using the `==` operator is inefficient and potentially incorrect. This PR has substituted all instances (that are not subject to be regenerated by exp2python) with`is None` --- src/exp2python/python/SCL/AggregationDataTypes.py | 12 ++++++------ src/exp2python/python/SCL/BaseType.py | 2 +- src/exp2python/python/SCL/Builtin.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/exp2python/python/SCL/AggregationDataTypes.py b/src/exp2python/python/SCL/AggregationDataTypes.py index c40758e66..09c4892b1 100644 --- a/src/exp2python/python/SCL/AggregationDataTypes.py +++ b/src/exp2python/python/SCL/AggregationDataTypes.py @@ -179,7 +179,7 @@ def __getitem__(self, index): raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index)) else: value = self._container[index-self._bound_1] - if not self._optional and value==None: + if not self._optional and value is None: raise AssertionError("Not OPTIONAL prevent the value with index %i from being None (default). Please set the value first."%index) return value @@ -239,7 +239,7 @@ def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, scope = No raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False - if bound_2 == None: + if bound_2 is None: self._unbounded = True elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") @@ -313,7 +313,7 @@ def __getitem__(self, index): raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index)) else: value = self._container[index-self._bound_1] - if value == None: + if value is None: raise AssertionError("Value with index %i not defined. Please set the value first."%index) return value #case unbounded @@ -322,7 +322,7 @@ def __getitem__(self, index): raise AssertionError("Value with index %i not defined. Please set the value first."%index) else: value = self._container[index-self._bound_1] - if value == None: + if value is None: raise AssertionError("Value with index %i not defined. Please set the value first."%index) return value @@ -413,7 +413,7 @@ def __init__( self , bound_1 , bound_2 , base_type , scope = None): raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False - if bound_2 == None: + if bound_2 is None: self._unbounded = True elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") @@ -531,7 +531,7 @@ def __init__( self , bound_1 , bound_2 , base_type , scope = None): raise TypeError("LIST lower bound must be an integer") # bound_2 can be set to None self._unbounded = False - if bound_2 == None: + if bound_2 is None: self._unbounded = True elif not isinstance(bound_2, int): raise TypeError("LIST upper bound must be an integer") diff --git a/src/exp2python/python/SCL/BaseType.py b/src/exp2python/python/SCL/BaseType.py index a6e2ab4a7..a92fc39fa 100644 --- a/src/exp2python/python/SCL/BaseType.py +++ b/src/exp2python/python/SCL/BaseType.py @@ -45,7 +45,7 @@ def get_scope(self): def get_type(self): if isinstance(self._typedef, str): - if self._scope == None: + if self._scope is None: raise AssertionError('No scope defined for this type') elif self._typedef in vars(self._scope): return vars(self._scope)[self._typedef] diff --git a/src/exp2python/python/SCL/Builtin.py b/src/exp2python/python/SCL/Builtin.py index 67f590007..de390e9e0 100644 --- a/src/exp2python/python/SCL/Builtin.py +++ b/src/exp2python/python/SCL/Builtin.py @@ -220,7 +220,7 @@ def SIN(V): #Result : true or false depending on whether V has an actual or indeterminate (?) value. #EXAMPLE 131 { IF EXISTS ( a ) THEN ... def EXISTS(V): - if V==None: + if V is None: return False else: return True From 928509020816016a54b49cfe69f4e779160c6e2c Mon Sep 17 00:00:00 2001 From: luz paz Date: Thu, 8 Oct 2020 16:26:11 -0400 Subject: [PATCH 070/244] Fix typos Found via `codespell` --- src/exp2python/python/SCL/Model.py | 2 +- src/exp2python/python/SCL/SimpleDataTypes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2python/python/SCL/Model.py b/src/exp2python/python/SCL/Model.py index a204972fa..c697dfa66 100644 --- a/src/exp2python/python/SCL/Model.py +++ b/src/exp2python/python/SCL/Model.py @@ -30,7 +30,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -class Model(objet): +class Model(object): """ The container for entity instances """ def __init_(self): diff --git a/src/exp2python/python/SCL/SimpleDataTypes.py b/src/exp2python/python/SCL/SimpleDataTypes.py index 594df650f..d1a99f259 100644 --- a/src/exp2python/python/SCL/SimpleDataTypes.py +++ b/src/exp2python/python/SCL/SimpleDataTypes.py @@ -117,7 +117,7 @@ class STRING(str): 318 width_spec = '(' width ')' [ FIXED ] . 317 width = numeric_expression . A string data type may be defined as either fixed or varying width (number of characters). If - it is not specfically defined as fixed width (by using the fixed reserved word in the dfinition) + it is not specifically defined as fixed width (by using the fixed reserved word in the definition) the string has varying width. The domain of a fixed width string data type is the set of all character sequences of exactly From 3f8bde4319f70ea0aa12a5aa67c9c1163f351971 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 30 Nov 2020 21:15:25 -0500 Subject: [PATCH 071/244] Update Find* modules to the latest from BRL-CAD --- cmake/FindLEMON.cmake | 40 ++++++++++++++++++++++++++++++++++----- cmake/FindPERPLEX.cmake | 42 +++++++++++++++++++++++++++++++++++------ cmake/FindRE2C.cmake | 26 +++++++++++++++++++++++-- 3 files changed, 95 insertions(+), 13 deletions(-) diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index 19aa0d500..ebd7af001 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2016 United States Government as represented by +# Copyright (c) 2010-2020 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,9 +44,35 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -find_program(LEMON_EXECUTABLE lemon DOC "path to the lemon executable") +set(_LEMON_SEARCHES) + +# Search LEMON_ROOT first if it is set. +if(LEMON_ROOT) + set(_LEMON_SEARCH_ROOT PATHS ${LEMON_ROOT} NO_DEFAULT_PATH) + list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_ROOT) +endif() + +# Normal search. +set(_LEMON_x86 "(x86)") +set(_LEMON_SEARCH_NORMAL + PATHS "$ENV{ProgramFiles}/lemon" + "$ENV{ProgramFiles${_LEMON_x86}}/lemon") +unset(_LEMON_x86) +list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_NORMAL) + +set(LEMON_NAMES lemon) + +# Try each search configuration. +foreach(search ${_LEMON_SEARCHES}) + find_program(LEMON_EXECUTABLE lemon ${${search}} PATH_SUFFIXES bin) +endforeach() mark_as_advanced(LEMON_EXECUTABLE) +foreach(search ${_LEMON_SEARCHES}) + find_file(LEMON_TEMPLATE lempar.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/lemon) +endforeach() +mark_as_advanced(LEMON_TEMPLATE) + if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) # look for the template in share if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") @@ -113,6 +139,10 @@ if(NOT COMMAND LEMON_TARGET) CMAKE_PARSE_ARGUMENTS(${LVAR_PREFIX} "" "OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR;EXTRA_ARGS" "" ${ARGN}) endif(${ARGC} GREATER 3) + if (TARGET perplex_stage) + set(DEPS_TARGET perplex_stage) + endif (TARGET perplex_stage) + # Need a working directory if("${${LVAR_PREFIX}_WORKING_DIR}" STREQUAL "") set(${LVAR_PREFIX}_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LVAR_PREFIX}") @@ -161,7 +191,7 @@ if(NOT COMMAND LEMON_TARGET) OUTPUT ${LEMON_GEN_OUT} ${LEMON_GEN_SOURCE} ${LEMON_GEN_HEADER} COMMAND ${CMAKE_COMMAND} -E copy ${lemon_in_file} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} ${${LVAR_PREFIX}__EXTRA_ARGS} - DEPENDS ${Input} ${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_TARGET} + DEPENDS ${Input} ${LEMON_EXECUTABLE_TARGET} ${DEPS_TARGET} WORKING_DIRECTORY ${${LVAR_PREFIX}_WORKING_DIR} COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" ) @@ -171,7 +201,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${${LVAR_PREFIX}_OUT_SRC_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ${DEPS_TARGET} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_SRC_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "${LEMON_GEN_SOURCE}") @@ -179,7 +209,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_HDR_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${${LVAR_PREFIX}_OUT_HDR_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ${DEPS_TARGET} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_HDR_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "${LEMON_GEN_HEADER}") diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index 22d632032..d1482d67c 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2016 United States Government as represented by +# Copyright (c) 2010-2020 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,9 +44,35 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -find_program(PERPLEX_EXECUTABLE perplex DOC "path to the perplex executable") +set(_PERPLEX_SEARCHES) + +# Search PERPLEX_ROOT first if it is set. +if(PERPLEX_ROOT) + set(_PERPLEX_SEARCH_ROOT PATHS ${PERPLEX_ROOT} NO_DEFAULT_PATH) + list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_ROOT) +endif() + +# Normal search. +set(_PERPLEX_x86 "(x86)") +set(_PERPLEX_SEARCH_NORMAL + PATHS "$ENV{ProgramFiles}/perplex" + "$ENV{ProgramFiles${_PERPLEX_x86}}/perplex") +unset(_PERPLEX_x86) +list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_NORMAL) + +set(PERPLEX_NAMES perplex) + +# Try each search configuration. +foreach(search ${_PERPLEX_SEARCHES}) + find_program(PERPLEX_EXECUTABLE perplex ${${search}} PATH_SUFFIXES bin) +endforeach() mark_as_advanced(PERPLEX_EXECUTABLE) +foreach(search ${_PERPLEX_SEARCHES}) + find_file(PERPLEX_TEMPLATE perplex_template.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/perplex) +endforeach() +mark_as_advanced(PERPLEX_TEMPLATE) + if(PERPLEX_EXECUTABLE AND NOT PERPLEX_TEMPLATE) get_filename_component(perplex_path ${PERPLEX_EXECUTABLE} PATH) if(perplex_path) @@ -96,7 +122,7 @@ mark_as_advanced(PERPLEX_TEMPLATE) # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2016 United States Government as represented by +# Copyright (c) 2010-2020 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -141,6 +167,10 @@ if(NOT COMMAND PERPLEX_TARGET) get_filename_component(IN_FILE_WE ${Input} NAME_WE) set(PVAR_PREFIX ${Name}_${IN_FILE_WE}) + if (TARGET perplex_stage) + set(DEP_TARGET perplex_stage) + endif (TARGET perplex_stage) + if(${ARGC} GREATER 3) CMAKE_PARSE_ARGUMENTS(${PVAR_PREFIX} "" "TEMPLATE;OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR" "" ${ARGN}) endif(${ARGC} GREATER 3) @@ -200,7 +230,7 @@ if(NOT COMMAND PERPLEX_TARGET) OUTPUT ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${perplex_in_file} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${PERPLEX_EXECUTABLE} -c -o ${re2c_src} -i ${${PVAR_PREFIX}_OUT_HDR_FILE} -t ${${PVAR_PREFIX}_TEMPLATE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} - DEPENDS ${Input} ${${PVAR_PREFIX}_TEMPLATE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} + DEPENDS ${Input} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[PERPLEX][${Name}] Generating re2c input with ${PERPLEX_EXECUTABLE}" ) @@ -209,7 +239,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-debug-info --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) @@ -217,7 +247,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) diff --git a/cmake/FindRE2C.cmake b/cmake/FindRE2C.cmake index 5450c34a9..2b3a9492b 100644 --- a/cmake/FindRE2C.cmake +++ b/cmake/FindRE2C.cmake @@ -3,7 +3,29 @@ # #============================================================================= -find_program(RE2C_EXECUTABLE re2c DOC "path to the re2c executable") +set(_RE2C_SEARCHES) + +# Search RE2C_ROOT first if it is set. +if(RE2C_ROOT) + set(_RE2C_SEARCH_ROOT PATHS ${RE2C_ROOT} NO_DEFAULT_PATH) + list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_ROOT) +endif() + +# Normal search. +set(_RE2C_x86 "(x86)") +set(_RE2C_SEARCH_NORMAL + PATHS "$ENV{ProgramFiles}/re2c" + "$ENV{ProgramFiles${_RE2C_x86}}/re2c") +unset(_RE2C_x86) +list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_NORMAL) + +set(RE2C_NAMES re2c) + +# Try each search configuration. +foreach(search ${_RE2C_SEARCHES}) + find_program(RE2C_EXECUTABLE re2c ${${search}} PATH_SUFFIXES bin) +endforeach() + mark_as_advanced(RE2C_EXECUTABLE) include(FindPackageHandleStandardArgs) @@ -42,7 +64,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(RE2C DEFAULT_MSG RE2C_EXECUTABLE) # ==================================================================== # #============================================================================= -# Copyright (c) 2010-2016 United States Government as represented by +# Copyright (c) 2010-2020 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel From 414b8705a2d93f091d738a060f3f5c0315976939 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 30 Nov 2020 21:36:27 -0500 Subject: [PATCH 072/244] Remove md5 verification of generated sources. This has proven to be more trouble than it is worth - changes to the lexer and parser inputs are relatively rare at this point, and different versions of re2c/lemon can break the checks. --- cmake/md5_gen.cmake.in | 35 ------------- cmake/md5_verify.cmake.in | 30 ------------ src/express/CMakeLists.txt | 49 ------------------- src/express/generated/CMakeLists.txt | 2 +- src/express/generated/README | 11 +---- src/express/generated/verification_info.cmake | 7 --- 6 files changed, 2 insertions(+), 132 deletions(-) delete mode 100644 cmake/md5_gen.cmake.in delete mode 100644 cmake/md5_verify.cmake.in delete mode 100644 src/express/generated/verification_info.cmake diff --git a/cmake/md5_gen.cmake.in b/cmake/md5_gen.cmake.in deleted file mode 100644 index 9d664baa0..000000000 --- a/cmake/md5_gen.cmake.in +++ /dev/null @@ -1,35 +0,0 @@ -# Inherit the parent CMake setting -set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) -set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) - -# Define a variety of convenience routines -include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake) - -# The following steps are executed to sync generated sources: -# -# 1. Create a new verification_info.cmake file and populate -# it with the MD5 sums for current files. -# -# 2. Overwrite the original cached verification_info.cmake -# and generated files with the new ones. If LOCKED_SOURCE_DIR -# is ON, this step will not be carried out - instead, an -# informational message with manual updating instructions -# will be printed. - -set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake") - - -file(WRITE ${new_info_file} "# Autogenerated verification information\n") - -# Handle input files -set(input_files "@MD5_FILELIST@") -WRITE_MD5_SUMS("${input_files}" "${new_info_file}") - -message("New verification file created: ${new_info_file}") - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/md5_verify.cmake.in b/cmake/md5_verify.cmake.in deleted file mode 100644 index 5eb105337..000000000 --- a/cmake/md5_verify.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# Inherit the parent CMake setting -set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@) -set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") - -# Include the file the provides the baseline against which -# current files will be compared - - include("@BASELINE_INFORMATION_FILE@") - - # Define a variety of convenience routines - include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake") - - # Individually verify all of the files in question. - set(filelist "@MD5_FILELIST@") - VERIFY_FILES("${filelist}" 1 srcs_pass) - if(NOT srcs_pass) - if(NOT DEBUGGING_GENERATED_SOURCES) - message(FATAL_ERROR "Sources have been modified and md5 sums have not been updated. This generally indicates either\n a) an input file has been modified but generated files have not been updated, or\n b) genenerated files have been edited directly.\nTo clear the error:\n a) Copy the new generated sources from the build directory to the generated/ sources directory, use the _md5gen build target to create a new verifictation_info.cmake file, and copy verfication_info.cmake to generated/ as well.\n b) install Perplex/Re2C/LEMON and make the changes to the input file rather than the generated file.\nNote:\n If this is a debugging situation where multiple sequential tests must be conducted, temporarily set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure to disable this check.\nThis measure is necessary to ensure that compilations using either Perplex/Re2C/LEMON generation or the cached outputs of those tools produce consistent results.") - else(NOT DEBUGGING_GENERATED_SOURCES) - message(WARNING "Note: Sources have been modified and md5 sums have not been updated - build failure condition temporarily overridden by DEBUGGING_GENERATED_SOURCES setting.") - endif(NOT DEBUGGING_GENERATED_SOURCES) - endif(NOT srcs_pass) - - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 5ef962c83..88c6e970e 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -4,39 +4,6 @@ include_directories( ${SC_SOURCE_DIR}/src/base ) -# Set up the information we need to feed the generated source management -# scripts -set(BASELINE_INFORMATION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/generated/verification_info.cmake") -set(PROJECT_CMAKE_DIR "${SC_SOURCE_DIR}/cmake") -set(MD5_FILELIST - "${CMAKE_CURRENT_SOURCE_DIR}/expscan.l" - "${CMAKE_CURRENT_SOURCE_DIR}/expparse.y" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h" - ) -configure_file(${SC_SOURCE_DIR}/cmake/md5_gen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake @ONLY) -configure_file(${SC_SOURCE_DIR}/cmake/md5_verify.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake @ONLY) - -# Convenience target to generate an updated verification_info.cmake file -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel - ) -add_custom_target(express_md5gen DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel) - -# Target for actually checking cached MD5 sums against files -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel - DEPENDS ${MD5_FILELIST} - ) -add_custom_target(express_verify DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel) - - # Depending on whether we're using pre-generated sources or building them on # the fly, set up targets and source lists. if(SC_GENERATE_LP_SOURCES) @@ -133,14 +100,6 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) endif() - if(SC_GENERATE_LP_SOURCES) - add_custom_command(TARGET express POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - ) - else() - add_dependencies(express express_verify) - endif() - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) add_dependencies(express version_string) endif() @@ -148,14 +107,6 @@ endif() if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) - - if(SC_GENERATE_LP_SOURCES) - add_custom_command(TARGET express-static POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - ) - else() - add_dependencies(express-static express_verify) - endif() if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) add_dependencies(express-static version_string) diff --git a/src/express/generated/CMakeLists.txt b/src/express/generated/CMakeLists.txt index 53e9293be..8aada6d0f 100644 --- a/src/express/generated/CMakeLists.txt +++ b/src/express/generated/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(.) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_library(objlib_expscan_c OBJECT expscan.c) set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/express/generated/README b/src/express/generated/README index 7ca0ac13a..ccee594dd 100644 --- a/src/express/generated/README +++ b/src/express/generated/README @@ -5,8 +5,7 @@ lexing and parsing logic. DO NOT EDIT THESE FILES. They are machine generated and should not be modified directly - bugs in these files need to be fixed in either the -Perplex/RE2C/Lemon input files or the tools themselves. Directly changing -these files will result in a build failure. +Perplex/RE2C/Lemon input files or the tools themselves. If changes need to be made, the correct approach is: @@ -14,12 +13,4 @@ If changes need to be made, the correct approach is: 2. make any necessary fixes to the input files and/or the generator tools. 3. run the build, and copy the new generated expscan and expparse c and h files to this directory. -4. run the build target "express_md5gen" to generate a new verification_info.cmake - file, and copy that file into this directory as well. -The verification_info.cmake file in this directory is used by CMake to protect -the integrity of the generated files. - -If iterative debugging is necessary, set the cmake configure variable -DEBUGGING_GENERATED_SOURCES to avoid having to update generated sources and md5 -sums each time an input file is changed. diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake deleted file mode 100644 index b3d7b3608..000000000 --- a/src/express/generated/verification_info.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Autogenerated verification information -set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) -set(baseline_expparse_y_md5 3722242f16c679c40323317833757a6d) -set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) -set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) -set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) -set(baseline_expparse_h_md5 e4a5599839b2a9f7a6915a0dcc7747b0) From 9e31f561c69155f5a6065b3f79a1b3aec881c323 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 30 Nov 2020 21:52:36 -0500 Subject: [PATCH 073/244] Remove unneeded indentation in generated output. Newer GCC doesn't like the indenting of this line, since in some situations it looks as if it is being guarded by an if clause when it is not. --- src/exp2cxx/selects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index b4fd3e60d..d72163667 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -34,7 +34,7 @@ extern int multiple_inheritance; ((t)->u.type->body->type == integer_) || \ ((t)->u.type->body->type == number_) ) #define PRINT_BUG_REPORT \ - fprintf( f, " std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ + fprintf( f, "std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ " in schema library: \\n\" \n << _POC_ << \"\\n\\n\";\n"); #define PRINT_SELECTBUG_WARNING(f) \ From b9189212bd7d519f2a4054707ff109aad5be4ec0 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 1 Dec 2020 09:23:09 -0500 Subject: [PATCH 074/244] Define a default copy constructor. Werror=deprecated-copy with GCC was triggered by code generated from this exp2cxx output. Go ahead and define the copy constructor to avoid the deprecated behavior. --- src/exp2cxx/classes_type.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 62d737aba..fcf8c109d 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -183,11 +183,11 @@ void TYPEenum_inc_print( const Type type, FILE * inc ) { /* constructors */ strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); tdnm[BUFSIZ-1] = '\0'; - fprintf( inc, " public:\n %s (const char * n =0, Enum" - "TypeDescriptor *et =%s);\n", n, tdnm ); + fprintf( inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm ); fprintf( inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" " : type(et) { set_value (e); }\n", n, EnumName( TYPEget_name( type ) ), tdnm ); + fprintf( inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype( type )); /* destructor */ fprintf( inc, " ~%s () { }\n", n ); From 90de683f5a3e91cc53d0be74d220e78121512abe Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 1 Dec 2020 12:07:13 -0500 Subject: [PATCH 075/244] Adjust versioning of shared libraries. Simplify - just use the library versions for the shared library links. Also, accommodate OpenBSD's particular convention for such libraries. --- CMakeLists.txt | 16 +++++++++------- cmake/SC_Targets.cmake | 6 +++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d897264c0..900905014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,13 +42,9 @@ project(SC) # SC version set(SC_VERSION_MAJOR 0) -set(SC_VERSION_MINOR 8-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_VERSION_MINOR 9) +set(SC_VERSION_PATCH 1) +set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) # Minimum required version of CMake cmake_minimum_required(VERSION 3.6.3) @@ -65,6 +61,12 @@ else(NOT SC_IS_SUBBUILD) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}") endif(NOT SC_IS_SUBBUILD) +# OpenBSD has its own naming conventions. Set a platform variable based on +# the OS name so we can test for it succinctly. +if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") + set(OPENBSD ON) +endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") + # testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index 09204146c..cb2d11dd6 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -46,7 +46,11 @@ macro(SC_ADDLIB _addlib_target) if(${_arg_prefix}_SHARED) add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES}) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION}) + if(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) + else(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) + endif(OPENBSD) if(APPLE) set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") endif(APPLE) From 029eac6065d2fef4c48097049463985dc5092010 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:36:00 -0500 Subject: [PATCH 076/244] Bump minimum CMake to 3.12 --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 900905014..91dad1189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ # This file contains the top level CMakeLists.txt logic for the # STEPcode software package. + project(SC) # SC version @@ -47,10 +48,8 @@ set(SC_VERSION_PATCH 1) set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) # Minimum required version of CMake -cmake_minimum_required(VERSION 3.6.3) -cmake_policy(SET CMP0003 NEW) -cmake_policy(SET CMP0026 NEW) -cmake_policy(SET CMP0057 NEW) +cmake_minimum_required(VERSION 3.12) +cmake_policy(SET CMP0077 OLD) # CMake derives much of its functionality from modules, typically # stored in one directory - let CMake know where to find them. From 63fe2f69ee9a92a252177518d87ce3a51dd14fed Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:36:42 -0500 Subject: [PATCH 077/244] Export ERRORget_warnings_help for MSVC --- include/express/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/express/error.h b/include/express/error.h index 7eef340c4..9a9334f88 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -225,7 +225,7 @@ extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); -extern char * ERRORget_warnings_help(const char* prefix, const char *eol); +extern SC_EXPRESS_EXPORT char * ERRORget_warnings_help(const char* prefix, const char *eol); extern bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ From 371d498c0aa0b642f5268cf057f35ba660927e99 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:37:46 -0500 Subject: [PATCH 078/244] Don't set RPATH settings if they've already been defined. --- cmake/SC_Build_opts.cmake | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index 8ca942615..9b14c5125 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -103,23 +103,33 @@ endif(SC_SKIP_EXEC_INSTALL) # 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) +if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) + set(CMAKE_SKIP_BUILD_RPATH FALSE) +endif() # when building, don't use the install RPATH already # (but later on when installing) -set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +endif() # the RPATH/INSTALL_NAME_DIR to be used when installing if (NOT APPLE) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") + if(NOT DEFINED CMAKE_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") + endif() 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") +if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +endif() # 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) +if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() # When this is a subbuild, assume that the parent project controls all of the following #====================================================================================== From 142edd569847b8114b9febdc1d903ba46e8ea1e4 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 20:38:55 -0500 Subject: [PATCH 079/244] Go with the simpler version string. The relatively complicated logic trying to pull in the git sha1 id for each build is proving fragile in some scenarios. Just go with a simpler encoding of the defined library version. --- cmake/SC_Config_Headers.cmake | 33 ++++---------- cmake/sc_version_string.cmake | 84 ----------------------------------- 2 files changed, 9 insertions(+), 108 deletions(-) delete mode 100644 cmake/sc_version_string.cmake diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 17d0c2774..64f9bdef1 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -101,32 +101,17 @@ 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. -if(SC_GIT_VERSION) - 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 - 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 -else(SC_GIT_VERSION) - set(VER_HDR " - #ifndef SC_VERSION_STRING - #define SC_VERSION_STRING - static char sc_version[512] = {\"${SC_VERSION}\"}; - #endif" - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") -endif(SC_GIT_VERSION) +set(VER_HDR " +#ifndef SC_VERSION_STRING +#define SC_VERSION_STRING +static char sc_version[512] = {\"${SC_VERSION}\"}; +#endif" +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h PROPERTIES GENERATED TRUE - HEADER_FILE_ONLY TRUE ) + HEADER_FILE_ONLY TRUE + ) # Local Variables: # tab-width: 8 diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake deleted file mode 100644 index ed53ac27e..000000000 --- a/cmake/sc_version_string.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# creates sc_version_string.h, which defines sc_version() -# sc_version() returns a pretty commit description and a build timestamp. - -# only update the file if the git commit has changed, because whenever the file is updated files including the header must rebuild -# parallel rebuilds can result in race conditions and failures, particularly when running ctest in parallel - -# http://stackoverflow.com/questions/3780667 -# http://www.cmake.org/pipermail/cmake/2009-February/027014.html - -set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") -set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@") - -set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h") - -#---------- find commit id ------------------ -#use git for a pretty commit id -#uses 'git describe --tags', so tags are required in the repo -#create a tag with 'git tag ' 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) - if(NOT SC_IS_SUBBUILD) - message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.") - endif(NOT SC_IS_SUBBUILD) - 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) -endif() -string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) - -#-------------- date and time --------------- - -if(SC_ENABLE_TESTING) - set (date_time_string "NA - disabled for testing") -else() - string(TIMESTAMP date_time_string UTC) -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" - ) - -#don't update the file unless something changed -string(RANDOM tmpsuffix) -file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) -execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix}) - -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 From 18b4d8282abce631b6e0acbd088c272e1bdacc04 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 21:07:02 -0500 Subject: [PATCH 080/244] Remove a couple uses of version_string target --- src/exp2cxx/CMakeLists.txt | 4 ---- src/exp2python/CMakeLists.txt | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index fe438ad28..93cf8c911 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -39,10 +39,6 @@ include_directories( SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) -if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(exp2cxx version_string) -endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - if(SC_ENABLE_TESTING) add_subdirectory(test) endif(SC_ENABLE_TESTING) diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index 0cbf338aa..a9feb39d2 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -31,9 +31,6 @@ if(SC_PYTHON_GENERATOR) ) SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(exp2python version_string) - endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) endif(SC_PYTHON_GENERATOR) # Local Variables: From 30d570a3a0ce79f9fd3c6407189e2e280d67a144 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 2 Dec 2020 23:02:20 -0500 Subject: [PATCH 081/244] Simplify the libexpress build logic. This approach seems to be more reliable when it comes to generating expscan.h in the proper sequence for building. --- src/express/CMakeLists.txt | 111 ++++++++++++--------------- src/express/generated/CMakeLists.txt | 8 -- 2 files changed, 50 insertions(+), 69 deletions(-) delete mode 100644 src/express/generated/CMakeLists.txt diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 88c6e970e..f1a78b646 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -10,19 +10,23 @@ if(SC_GENERATE_LP_SOURCES) LEMON_TARGET(ExpParser expparse.y) PERPLEX_TARGET(ExpScanner expscan.l) ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner ExpParser) - - add_library(objlib_expscan_c OBJECT ${PERPLEX_ExpScanner_SRC}) - set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) - - add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_SRC}) - set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) - + include_directories( + ${LEMON_ExpParser_INCLUDE_DIR} + ${PERPLEX_ExpScanner_INCLUDE_DIR} + ) else(SC_GENERATE_LP_SOURCES) - add_subdirectory(generated) - include_directories(generated) + set(LEMON_ExpParser_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c) + set(LEMON_ExpParser_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h) + set(PERPLEX_ExpScanner_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c) + set(PERPLEX_ExpScanner_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/generated) endif(SC_GENERATE_LP_SOURCES) set(EXPRESS_SOURCES + ${LEMON_ExpParser_HDR} + ${LEMON_ExpParser_SRC} + ${PERPLEX_ExpScanner_HDR} + ${PERPLEX_ExpScanner_SRC} symbol.c type.c variable.c @@ -47,30 +51,42 @@ set(EXPRESS_SOURCES ordered_attrs.cc info.c factory.c - ) - -set(EXPRESS_OBJS) -foreach(_src ${EXPRESS_SOURCES}) - string(REPLACE "." "_" _suffix ${_src}) - set(_objlib "objlib_${_suffix}") - add_library(${_objlib} OBJECT ${_src}) - # TODO: probably PIC should be used everywhere... - set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) - list(APPEND EXPRESS_OBJS $) -endforeach() - -list(APPEND EXPRESS_OBJS $) -list(APPEND EXPRESS_OBJS $) - + ) -if(SC_GENERATE_LP_SOURCES) - set_property(TARGET objlib_expparse_c objlib_express_c objlib_lexact_c - APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") - set_property(TARGET objlib_expscan_c objlib_express_c objlib_lexact_c - APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") - # OBJECT libraries are not targets, and so an explicit dependency is required - set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") -endif() +add_library(express-obj OBJECT ${EXPRESS_SOURCES}) +add_dependencies(express-obj base) +if(MSVC) + set_property(TARGET express-obj APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") +endif(MSVC) + + +add_library(express SHARED ${EXPRESS_SOURCES}) +target_link_libraries(express base) +if(OPENBSD) + set_target_properties(express PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) +else(OPENBSD) + set_target_properties(express PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) +endif(OPENBSD) +if(APPLE) + set_property(TARGET express APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress") +endif(APPLE) +install(TARGETS express + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) + +if(MSVC) + set_property(TARGET express APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") + set_property(TARGET express APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") +endif(MSVC) + +if (BUILD_STATIC_LIBS) + add_library(express-static STATIC ${EXPRESS_SOURCES}) + install(TARGETS express-static + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) +endif (BUILD_STATIC_LIBS) # TODO # Currently, fedex.c provides the main() for multiple programs. These programs @@ -85,35 +101,8 @@ set(CHECK_EXPRESS_SOURCES fedex.c inithook.c ) - -SET(EXPRESS_PRIVATE_HDRS - exptoks.h - stack.h - ) - -variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) -variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) - -if($CACHE{SC_BUILD_SHARED_LIBS}) - SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) - if(WIN32) - target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) - endif() - - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(express version_string) - endif() -endif() - -if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) - - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(express-static version_string) - endif() -endif() - -SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) +add_executable(check-express ${CHECK_EXPRESS_SOURCES}) +target_link_libraries(check-express express base) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/express/generated/CMakeLists.txt b/src/express/generated/CMakeLists.txt deleted file mode 100644 index 8aada6d0f..000000000 --- a/src/express/generated/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -add_library(objlib_expscan_c OBJECT expscan.c) -set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) - -add_library(objlib_expparse_c OBJECT expparse.c) -set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) - From 0b69a9a5e56cf135ba15d42ba7eede6e88eb9b90 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 3 Dec 2020 08:54:29 -0500 Subject: [PATCH 082/244] Install check-express --- src/express/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index f1a78b646..409d974ee 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -103,6 +103,11 @@ set(CHECK_EXPRESS_SOURCES ) add_executable(check-express ${CHECK_EXPRESS_SOURCES}) target_link_libraries(check-express express base) +install(TARGETS check-express + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) + if(SC_ENABLE_TESTING) add_subdirectory(test) From 1f4f78f9057dd14edd6a54bf7ac3e9565dcdffb4 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:03:12 -0500 Subject: [PATCH 083/244] Remove Raw() and getEDesc(), restore C asStr() This commit removes the Raw and getEDesc methods in favor of the simplicity of just making ptr and eDesc public. Also, add back in previous version of asStr() that returns a C string. (These changes are motivated by BRL-CAD's step code.) --- src/cllazyfile/lazyRefs.h | 8 +- src/cllazyfile/lazy_test.cc | 4 +- src/cllazyfile/sectionReader.cc | 2 +- src/clstepcore/Registry.cc | 2 +- src/clstepcore/STEPattribute.cc | 94 ++++++++++++++++++++++ src/clstepcore/STEPattribute.h | 25 +++--- src/clstepcore/sdaiApplication_instance.cc | 8 +- src/clstepcore/sdaiApplication_instance.h | 6 +- src/exp2cxx/selects.c | 4 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- 10 files changed, 120 insertions(+), 35 deletions(-) diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 6d2e093e4..cde0bc62b 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -116,8 +116,8 @@ class SC_LAZYFILE_EXPORT lazyRefs { ias.i = rinst; _inst->setInvAttr( ia, ias ); } else if( ai->GetFileId() != (int)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 << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->eDesc->Name(); + std::cerr << " and " << ai << ", #" << ai->GetFileId() <<"=" << ai->eDesc->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 ); } @@ -184,7 +184,7 @@ class SC_LAZYFILE_EXPORT lazyRefs { } ++iai; } - std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->getEDesc()->Name() << std::endl; + std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->eDesc->Name() << std::endl; abort(); iAstruct nil = {nullptr}; return nil; @@ -279,7 +279,7 @@ class SC_LAZYFILE_EXPORT lazyRefs { // 1. find inverse attrs with recursion - getInverseAttrs( ai->getEDesc(), _iaList ); + getInverseAttrs( ai->eDesc, _iaList ); //2. find reverse refs, map id to type (stop if there are no inverse attrs or no refs) if( _iaList.size() == 0 || !mapRefsToTypes() ) { diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 87838e467..71786bb59 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -111,14 +111,14 @@ void dumpComplexInst( STEPcomplex * c ) { 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 component " << complex->eDesc->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; + std::cout << "non-complex component at depth " << depth << ", " << ai->eDesc->Name() << std::endl; } else { std::cout << "unknown component at depth " << depth << ": " << complex << std::endl; } diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 7a6053a46..0384efd4c 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -306,7 +306,7 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg if( !comment.empty() ) { inst->AddP21Comment( comment ); } - assert( inst->getEDesc() ); + assert( inst->eDesc ); _file.seekg( begin ); findNormalString( "(" ); _file.seekg( _file.tellg() - std::streampos(1) ); diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 6bbd3eaff..2e5eb490f 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -260,7 +260,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->setEDesc( entd ); + se->eDesc = entd; return se; } else { return ENTITY_NULL; diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 251beb445..866248fe4 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -382,6 +382,100 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add } } +/*****************************************************************//** + ** \fn asStr + ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). + ** \returns the value of the attribute + ** Status: complete 3/91 + *********************************************************************/ +const char * STEPattribute::asStr( std::string & str, const char * currSch ) const { + ostringstream ss; + + str.clear(); + + // The attribute has been derived by a subtype's attribute + if( IsDerived() ) { + str = "*"; + return const_cast( str.c_str() ); + } + + // The attribute has been redefined by the attribute pointed + // to by _redefAttr so write the redefined value. + if( _redefAttr ) { + return _redefAttr->asStr( str, currSch ); + } + + if( is_null() ) { + str = ""; + return const_cast( str.c_str() ); + } + + switch( NonRefType() ) { + case INTEGER_TYPE: + ss << *( ptr.i ); + str += ss.str(); + break; + + case NUMBER_TYPE: + case REAL_TYPE: + + ss.precision( ( int ) Real_Num_Precision ); + ss << *( ptr.r ); + str += ss.str(); + break; + + case ENTITY_TYPE: + // print instance id only if not empty pointer + // and has value assigned + if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { + break; + } else { + ( *( ptr.c ) )->STEPwrite_reference( str ); + } + break; + + case BINARY_TYPE: + if( !( ( ptr.b )->empty() ) ) { + ( ptr.b ) -> STEPwrite( str ); + } + break; + + case STRING_TYPE: + if( !( ( ptr.S )->empty() ) ) { + return ( ptr.S ) -> asStr( str ); + } + break; + + case AGGREGATE_TYPE: + case ARRAY_TYPE: // DAS + case BAG_TYPE: // DAS + case SET_TYPE: // DAS + case LIST_TYPE: // DAS + return ptr.a->asStr( str ) ; + + case ENUM_TYPE: + case BOOLEAN_TYPE: + case LOGICAL_TYPE: + return ptr.e -> asStr( str ); + + case SELECT_TYPE: + ptr.sh -> STEPwrite( str, currSch ); + return const_cast( str.c_str() ); + + case REFERENCE_TYPE: + case GENERIC_TYPE: + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return 0; + + case UNKNOWN_TYPE: + default: + return ( ptr.u -> asStr( str ) ); + } + return const_cast( str.c_str() ); +} + + /*****************************************************************//** ** \fn asStr ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index e3b43e0b4..0884a1bd8 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -75,15 +75,9 @@ extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, Erro class SC_CORE_EXPORT STEPattribute { friend ostream & operator<< ( ostream &, STEPattribute & ); friend class SDAI_Application_instance; - protected: - bool _derive; - bool _mustDeletePtr; ///if a member uses new to create an object in ptr - ErrorDescriptor _error; - STEPattribute * _redefAttr; - const AttrDescriptor * aDesc; - int refCount; - /** \union ptr + public: + /** \union ptr ** You know which of these to use based on the return value of ** NonRefType() - see below. BASE_TYPE is defined in baseType.h ** This variable points to an appropriate member variable in the entity @@ -103,6 +97,15 @@ class SC_CORE_EXPORT STEPattribute { void * p; } ptr; + + protected: + bool _derive; + bool _mustDeletePtr; ///if a member uses new to create an object in ptr + ErrorDescriptor _error; + STEPattribute * _redefAttr; + const AttrDescriptor * aDesc; + int refCount; + char SkipBadAttr( istream & in, char * StopChars ); void AddErrorInfo(); void STEPwriteError( ostream& out, unsigned int line, const char* desc ); @@ -137,6 +140,7 @@ class SC_CORE_EXPORT STEPattribute { /// return the attr value as a string string asStr( const char * currSch = 0 ) const; + const char * asStr( std::string &, const char * = 0 ) const; /// put the attr value in ostream void STEPwrite( ostream & out = cout, const char * currSch = 0 ); @@ -167,11 +171,6 @@ class SC_CORE_EXPORT STEPattribute { SCLundefined * Undefined(); ///@} - /// allows direct access to the union containing attr data (dangerous!) - attrUnion * Raw() { - return & ptr; - } - /** * These functions allow setting the attribute value. * Attr type is verified using an assertion. diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 2bbf6b31c..ad143cae5 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -172,10 +172,6 @@ void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * } } -const EntityDescriptor* SDAI_Application_instance::getEDesc() const { - return eDesc; -} - // BUG implement this -- FIXME function is never used SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entName ) { std::string s1, s2; @@ -790,9 +786,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->getEDesc() ) { + else if( se->eDesc ) { // is se a descendant of ed? - if( se->getEDesc()->IsA( ed ) ) { + if( se->eDesc->IsA( ed ) ) { return SEVERITY_NULL; } else { if( se->IsComplex() ) { diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index 70b7b3308..405964c24 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -36,8 +36,8 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { public: typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t; - protected: const EntityDescriptor * eDesc; + protected: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -89,10 +89,6 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { /// initialize inverse attribute list void InitIAttrs(); - void setEDesc( const EntityDescriptor * const ed ) { - eDesc = ed; - } - const EntityDescriptor * getEDesc() const; void StepFileId( int fid ) { STEPfile_id = fid; } diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index d72163667..afd490832 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -1493,7 +1493,7 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm ); fprintf( f, " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " - " ( CurrentUnderlyingType()->CanBe( _%s->getEDesc() ) ) ) {\n" + " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" " return severity();\n", dm, dm, dm ); fprintf( f, " } else {\n " @@ -1680,7 +1680,7 @@ void SELlib_print_protected( const Type type, FILE * f ) { if( TYPEis_select( t ) ) { fprintf( f, " // %s\n" /* item name */ - " if( %s->CanBe( se->getEDesc() ) ) {\n" + " if( %s->CanBe( se->eDesc ) ) {\n" " _%s.AssignEntity (se);\n" /* underlying data member */ " return SetUnderlyingType (%s);\n" /* td */ " }\n", diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 3fd51454c..2ff14bc3f 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -44,7 +44,7 @@ bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { EntityNode * en = ( EntityNode * ) relObj->GetHead(); SdaiObject * obj = ( SdaiObject * ) en->node; cout << "file id " << obj->StepFileId() << "; name " - << instList.GetApplication_instance( obj->StepFileId() - 1 )->getEDesc()->Name() << endl; + << instList.GetApplication_instance( obj->StepFileId() - 1 )->eDesc->Name() << endl; } ent_id = i; } From 2f378267dc8b87b22c063e0532291938a5aca70e Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:19:45 -0500 Subject: [PATCH 084/244] BRL-CAD also uses aDesc directly --- src/clstepcore/STEPattribute.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 0884a1bd8..dc5ff9ae1 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -97,13 +97,13 @@ class SC_CORE_EXPORT STEPattribute { void * p; } ptr; + const AttrDescriptor * aDesc; protected: bool _derive; bool _mustDeletePtr; ///if a member uses new to create an object in ptr ErrorDescriptor _error; STEPattribute * _redefAttr; - const AttrDescriptor * aDesc; int refCount; char SkipBadAttr( istream & in, char * StopChars ); From 9eb23dc2a9d94d0847c8746ca1db930c3e7d3d18 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:44:28 -0500 Subject: [PATCH 085/244] Make sure we have the policy before we try to set it. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91dad1189..0f99de18f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,9 @@ set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) # Minimum required version of CMake cmake_minimum_required(VERSION 3.12) -cmake_policy(SET CMP0077 OLD) +if (POLICY CMP0077) + cmake_policy(SET CMP0077 OLD) +endif (POLICY CMP0077) # CMake derives much of its functionality from modules, typically # stored in one directory - let CMake know where to find them. From 74d9062ff120c3131748b5a05db0d34cb7a25762 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:57:58 -0500 Subject: [PATCH 086/244] Start making some fixes to tests --- src/clstepcore/test/CMakeLists.txt | 2 +- src/express/test/CMakeLists.txt | 42 +++++++++---------------- test/cpp/CMakeLists.txt | 2 +- test/cpp/schema_specific/CMakeLists.txt | 4 +++ test/p21/CMakeLists.txt | 2 +- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index 1de017638..f9f353e26 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #c++ tests for clstepcore include_directories( diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 6d2615a9b..1c4fd7e90 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -4,35 +4,17 @@ if(SC_GENERATE_LP_SOURCES) include_directories("${PERPLEX_ExpScanner_INCLUDE_DIR}" "${LEMON_ExpParser_INCLUDE_DIR}") endif(SC_GENERATE_LP_SOURCES) -set(EXPRESS_CORE_OBJ - # base - $ - $ - $ - $ - - # global tables - $ - $ - - # AST creation - $ - $ - $ - - # deprecated - $ - $ -) - -add_executable(test_expr driver.c test_expr.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_expr driver.c test_expr.c) +target_link_libraries(test_expr express) add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) -add_executable(test_express driver.c test_express.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_express driver.c test_express.c) +target_link_libraries(test_express express) add_test(NAME express_rename_resolve COMMAND test_express express_rename_resolve) -add_executable(test_resolve driver.c test_resolve.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_resolve driver.c test_resolve.c) +target_link_libraries(test_resolve express) add_test(NAME exp_resolve_bad_func_call COMMAND test_resolve exp_resolve_bad_func_call) add_test(NAME exp_resolve_func_call COMMAND test_resolve exp_resolve_func_call) @@ -43,20 +25,24 @@ add_test(NAME stmt_resolve_pcall_proc COMMAND test_resolve stmt_resolve_pcall_pr add_test(NAME scope_resolve_named_types COMMAND test_resolve scope_resolve_named_types) add_test(NAME entity_resolve_supertypes_entity COMMAND test_resolve entity_resolve_supertypes_entity) -add_executable(test_resolve2 driver.c test_resolve2.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_resolve2 driver.c test_resolve2.c) +target_link_libraries(test_resolve2 express) add_test(NAME scope_resolve_expr_stmt COMMAND test_resolve2 scope_resolve_expr_stmt) add_test(NAME scope_resolve_subsupers COMMAND test_resolve2 scope_resolve_subsupers) -add_executable(test_schema driver.c test_schema.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_schema driver.c test_schema.c) +target_link_libraries(test_schema express) add_test(NAME schema_define_ref COMMAND test_schema schema_define_ref) add_test(NAME schema_define_use COMMAND test_schema schema_define_use) add_test(NAME schema_get_entities_ref COMMAND test_schema schema_get_entities_ref) add_test(NAME var_find COMMAND test_schema var_find) -add_executable(test_scope driver.c test_scope.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_scope driver.c test_scope.c) +target_link_libraries(test_scope express) add_test(NAME scope_find COMMAND test_scope scope_find) -add_executable(test_type driver.c test_type.c $ ${EXPRESS_CORE_OBJ}) +add_executable(test_type driver.c test_type.c) +target_link_libraries(test_type express) add_test(NAME type_create_user_defined_tag COMMAND test_type type_create_user_defined_tag) add_test(NAME build_check_express diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index cccf68811..7af916d2c 100644 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #c++ tests diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index 39ce6541a..c96ea08f3 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -9,6 +9,10 @@ include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${ # added as a workaround for changed behavior in newer cmake # versions (changes somewhere between 2.8 and 3.1) function(get_sdai_incl_dir out_path_var sdai_lib) + if (NOT TARGET sdai_${sdai_lib}) + message("sdai_${sdai_lib} is not a target") + return() + endif (NOT TARGET sdai_${sdai_lib}) if(NOT "${sdai_${sdai_lib}_SOURCE_DIR}" STREQUAL "") set(${out_path_var} "${sdai_${sdai_lib}_SOURCE_DIR}" PARENT_SCOPE) return() diff --git a/test/p21/CMakeLists.txt b/test/p21/CMakeLists.txt index b16bdd7b3..7d533f9ca 100644 --- a/test/p21/CMakeLists.txt +++ b/test/p21/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #test part 21 files #necessary macros won't already be defined if SC_BUILD_SCHEMAS is set to "" From 93cb422595d319d945272d2cfc1be2ae4e60c9fc Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 9 Dec 2020 09:26:27 -0500 Subject: [PATCH 087/244] Update formatting with astyle - use K&R --- README.md | 18 +- include/exppp/exppp.h | 84 +- include/express/alg.h | 20 +- include/express/alloc.h | 14 +- include/express/basic.h | 4 +- include/express/caseitem.h | 8 +- include/express/dict.h | 20 +- include/express/entity.h | 30 +- include/express/error.h | 42 +- include/express/exp_kw.h | 240 +- include/express/expbasic.h | 10 +- include/express/expr.h | 52 +- include/express/express.h | 48 +- include/express/hash.h | 30 +- include/express/info.h | 4 +- include/express/lexact.h | 42 +- include/express/linklist.h | 42 +- include/express/object.h | 4 +- include/express/resolve.h | 40 +- include/express/schema.h | 38 +- include/express/scope.h | 40 +- include/express/stmt.h | 70 +- include/express/symbol.h | 8 +- include/express/type.h | 34 +- include/express/variable.h | 10 +- include/ordered_attrs.h | 4 +- misc/astyle.cfg | 5 +- src/base/judy/misc/judy64n.c | 2200 ++--- src/base/judy/src/judy.c | 863 +- src/base/judy/src/judy.h | 54 +- src/base/judy/src/judyL2Array.h | 127 +- src/base/judy/src/judyLArray.h | 114 +- src/base/judy/src/judyS2Array.h | 163 +- src/base/judy/src/judySArray.h | 138 +- src/base/judy/test/hexSort.c | 83 +- src/base/judy/test/judyL2test.cc | 48 +- src/base/judy/test/judyLtest.cc | 31 +- src/base/judy/test/judyS2test.cc | 52 +- src/base/judy/test/judyStest.cc | 33 +- src/base/judy/test/pennySort.c | 163 +- src/base/judy/test/sort.c | 194 +- src/base/judy/test/sort.h | 4 +- src/base/path2str.c | 23 +- src/base/path2str.h | 2 +- src/base/sc_benchmark.cc | 80 +- src/base/sc_benchmark.h | 43 +- src/base/sc_getopt.cc | 31 +- src/base/sc_getopt.h | 6 +- src/base/sc_memmgr.cc | 223 +- src/base/sc_memmgr.h | 44 +- src/base/sc_mkdir.c | 24 +- src/base/sc_mkdir.h | 4 +- src/base/sc_stdio.h | 12 +- src/base/sc_trace_fprintf.c | 13 +- src/base/sc_trace_fprintf.h | 8 +- src/cldai/sdaiApplication_instance_set.cc | 85 +- src/cldai/sdaiApplication_instance_set.h | 23 +- src/cldai/sdaiBinary.cc | 177 +- src/cldai/sdaiBinary.h | 46 +- src/cldai/sdaiDaObject.cc | 114 +- src/cldai/sdaiDaObject.h | 115 +- src/cldai/sdaiEntity_extent.cc | 39 +- src/cldai/sdaiEntity_extent.h | 26 +- src/cldai/sdaiEntity_extent_set.cc | 158 +- src/cldai/sdaiEntity_extent_set.h | 23 +- src/cldai/sdaiEnum.cc | 503 +- src/cldai/sdaiEnum.h | 122 +- src/cldai/sdaiModel_contents.cc | 67 +- src/cldai/sdaiModel_contents.h | 32 +- src/cldai/sdaiModel_contents_list.cc | 84 +- src/cldai/sdaiModel_contents_list.h | 21 +- src/cldai/sdaiObject.cc | 6 +- src/cldai/sdaiObject.h | 5 +- src/cldai/sdaiSession_instance.cc | 6 +- src/cldai/sdaiSession_instance.h | 5 +- src/cldai/sdaiString.cc | 78 +- src/cldai/sdaiString.h | 34 +- src/cleditor/STEPfile.cc | 1230 +-- src/cleditor/STEPfile.h | 168 +- src/cleditor/STEPfile.inline.cc | 235 +- src/cleditor/SdaiHeaderSchema.cc | 537 +- src/cleditor/SdaiHeaderSchema.h | 163 +- src/cleditor/SdaiHeaderSchemaAll.cc | 65 +- src/cleditor/SdaiHeaderSchemaClasses.h | 74 +- src/cleditor/SdaiHeaderSchemaInit.cc | 273 +- src/cleditor/SdaiSchemaInit.cc | 9 +- src/cleditor/SdaiSchemaInit.h | 6 +- src/cleditor/cmdmgr.cc | 108 +- src/cleditor/cmdmgr.h | 124 +- src/cleditor/seeinfodefault.h | 19 +- src/cllazyfile/headerSectionReader.h | 16 +- src/cllazyfile/instMgrHelper.h | 26 +- src/cllazyfile/lazyDataSectionReader.cc | 7 +- src/cllazyfile/lazyDataSectionReader.h | 8 +- src/cllazyfile/lazyFileReader.cc | 55 +- src/cllazyfile/lazyFileReader.h | 25 +- src/cllazyfile/lazyInstMgr.cc | 122 +- src/cllazyfile/lazyInstMgr.h | 130 +- src/cllazyfile/lazyP21DataSectionReader.cc | 50 +- src/cllazyfile/lazyP21DataSectionReader.h | 10 +- src/cllazyfile/lazyRefs.h | 213 +- src/cllazyfile/lazyTypes.h | 4 +- src/cllazyfile/lazy_test.cc | 135 +- src/cllazyfile/p21HeaderSectionReader.cc | 43 +- src/cllazyfile/p21HeaderSectionReader.h | 5 +- src/cllazyfile/sectionReader.cc | 224 +- src/cllazyfile/sectionReader.h | 61 +- src/clstepcore/Registry.cc | 267 +- src/clstepcore/Registry.h | 68 +- src/clstepcore/STEPaggrBinary.cc | 80 +- src/clstepcore/STEPaggrBinary.h | 66 +- src/clstepcore/STEPaggrEntity.cc | 196 +- src/clstepcore/STEPaggrEntity.h | 126 +- src/clstepcore/STEPaggrEnum.cc | 117 +- src/clstepcore/STEPaggrEnum.h | 100 +- src/clstepcore/STEPaggrGeneric.cc | 78 +- src/clstepcore/STEPaggrGeneric.h | 66 +- src/clstepcore/STEPaggrInt.cc | 79 +- src/clstepcore/STEPaggrInt.h | 54 +- src/clstepcore/STEPaggrReal.cc | 77 +- src/clstepcore/STEPaggrReal.h | 54 +- src/clstepcore/STEPaggrSelect.cc | 182 +- src/clstepcore/STEPaggrSelect.h | 130 +- src/clstepcore/STEPaggrString.cc | 82 +- src/clstepcore/STEPaggrString.h | 66 +- src/clstepcore/STEPaggregate.cc | 250 +- src/clstepcore/STEPaggregate.h | 111 +- src/clstepcore/STEPattribute.cc | 900 +- src/clstepcore/STEPattribute.h | 218 +- src/clstepcore/STEPattributeList.cc | 47 +- src/clstepcore/STEPattributeList.h | 14 +- src/clstepcore/STEPcomplex.cc | 524 +- src/clstepcore/STEPcomplex.h | 85 +- src/clstepcore/STEPinvAttrList.cc | 52 +- src/clstepcore/STEPinvAttrList.h | 61 +- src/clstepcore/STEPundefined.cc | 91 +- src/clstepcore/STEPundefined.h | 21 +- src/clstepcore/SingleLinkList.cc | 79 +- src/clstepcore/SingleLinkList.h | 33 +- src/clstepcore/SubSuperIterators.h | 181 +- src/clstepcore/aggrTypeDescriptor.cc | 27 +- src/clstepcore/aggrTypeDescriptor.h | 371 +- src/clstepcore/attrDescriptor.cc | 109 +- src/clstepcore/attrDescriptor.h | 140 +- src/clstepcore/attrDescriptorList.cc | 40 +- src/clstepcore/attrDescriptorList.h | 35 +- src/clstepcore/collect.cc | 66 +- src/clstepcore/complexSupport.h | 337 +- src/clstepcore/complexlist.cc | 114 +- src/clstepcore/create_Aggr.cc | 24 +- src/clstepcore/create_Aggr.h | 36 +- src/clstepcore/derivedAttribute.cc | 35 +- src/clstepcore/derivedAttribute.h | 19 +- src/clstepcore/dictSchema.cc | 156 +- src/clstepcore/dictSchema.h | 260 +- src/clstepcore/dictdefs.h | 30 +- src/clstepcore/dictionaryInstance.h | 11 +- src/clstepcore/dispnode.cc | 20 +- src/clstepcore/dispnode.h | 37 +- src/clstepcore/dispnodelist.cc | 28 +- src/clstepcore/dispnodelist.h | 23 +- src/clstepcore/entityDescriptor.cc | 249 +- src/clstepcore/entityDescriptor.h | 125 +- src/clstepcore/entityDescriptorList.cc | 29 +- src/clstepcore/entityDescriptorList.h | 47 +- src/clstepcore/entlist.cc | 63 +- src/clstepcore/entnode.cc | 85 +- src/clstepcore/enumTypeDescriptor.cc | 70 +- src/clstepcore/enumTypeDescriptor.h | 30 +- src/clstepcore/explicitItemId.cc | 85 +- src/clstepcore/explicitItemId.h | 204 +- src/clstepcore/globalRule.cc | 106 +- src/clstepcore/globalRule.h | 122 +- src/clstepcore/implicitItemId.cc | 85 +- src/clstepcore/implicitItemId.h | 82 +- src/clstepcore/instmgr.cc | 240 +- src/clstepcore/instmgr.h | 82 +- src/clstepcore/interfaceSpec.cc | 102 +- src/clstepcore/interfaceSpec.h | 160 +- src/clstepcore/interfacedItem.cc | 20 +- src/clstepcore/interfacedItem.h | 23 +- src/clstepcore/inverseAttribute.cc | 21 +- src/clstepcore/inverseAttribute.h | 45 +- src/clstepcore/inverseAttributeList.cc | 48 +- src/clstepcore/inverseAttributeList.h | 37 +- src/clstepcore/match-ors.cc | 61 +- src/clstepcore/mgrnode.cc | 114 +- src/clstepcore/mgrnode.h | 70 +- src/clstepcore/mgrnodearray.cc | 132 +- src/clstepcore/mgrnodearray.h | 48 +- src/clstepcore/mgrnodelist.cc | 46 +- src/clstepcore/mgrnodelist.h | 15 +- src/clstepcore/multlist.cc | 118 +- src/clstepcore/needFunc.cc | 3 +- src/clstepcore/needFunc.h | 5 +- src/clstepcore/non-ors.cc | 49 +- src/clstepcore/orlist.cc | 35 +- src/clstepcore/print.cc | 53 +- src/clstepcore/read_func.cc | 562 +- src/clstepcore/read_func.h | 72 +- src/clstepcore/realTypeDescriptor.h | 32 +- src/clstepcore/schRename.cc | 20 +- src/clstepcore/schRename.h | 51 +- src/clstepcore/sdai.cc | 2 +- src/clstepcore/sdai.h | 28 +- src/clstepcore/sdaiApplication_instance.cc | 774 +- src/clstepcore/sdaiApplication_instance.h | 147 +- src/clstepcore/sdaiSelect.cc | 345 +- src/clstepcore/sdaiSelect.h | 75 +- src/clstepcore/selectTypeDescriptor.cc | 51 +- src/clstepcore/selectTypeDescriptor.h | 92 +- src/clstepcore/stringTypeDescriptor.h | 65 +- src/clstepcore/superInvAttrIter.h | 107 +- .../test/test_SupertypesIterator.cc | 83 +- src/clstepcore/test/test_null_attr.cc | 13 +- .../test/test_operators_SDAI_Select.cc | 79 +- .../test/test_operators_STEPattribute.cc | 57 +- src/clstepcore/trynext.cc | 72 +- src/clstepcore/typeDescriptor.cc | 323 +- src/clstepcore/typeDescriptor.h | 114 +- src/clstepcore/typeDescriptorList.cc | 29 +- src/clstepcore/typeDescriptorList.h | 42 +- src/clstepcore/typeOrRuleVar.cc | 11 +- src/clstepcore/typeOrRuleVar.h | 13 +- src/clstepcore/uniquenessRule.cc | 85 +- src/clstepcore/uniquenessRule.h | 116 +- src/clstepcore/whereRule.cc | 85 +- src/clstepcore/whereRule.h | 108 +- src/clutils/Str.cc | 177 +- src/clutils/Str.h | 36 +- src/clutils/dirobj.cc | 156 +- src/clutils/dirobj.h | 56 +- src/clutils/errordesc.cc | 105 +- src/clutils/errordesc.h | 93 +- src/clutils/gennode.cc | 5 +- src/clutils/gennode.h | 22 +- src/clutils/gennodearray.cc | 91 +- src/clutils/gennodearray.h | 31 +- src/clutils/gennodelist.cc | 38 +- src/clutils/gennodelist.h | 24 +- src/clutils/sc_hash.cc | 233 +- src/clutils/sc_hash.h | 34 +- src/exp2cxx/class_strings.c | 213 +- src/exp2cxx/class_strings.h | 20 +- src/exp2cxx/classes.c | 219 +- src/exp2cxx/classes.h | 88 +- src/exp2cxx/classes_attribute.c | 668 +- src/exp2cxx/classes_attribute.h | 18 +- src/exp2cxx/classes_entity.c | 1087 +-- src/exp2cxx/classes_entity.h | 16 +- src/exp2cxx/classes_misc.c | 284 +- src/exp2cxx/classes_type.c | 1116 +-- src/exp2cxx/classes_type.h | 40 +- src/exp2cxx/classes_wrapper.cc | 720 +- src/exp2cxx/collect.cc | 62 +- src/exp2cxx/complexSupport.h | 368 +- src/exp2cxx/complexlist.cc | 110 +- src/exp2cxx/entlist.cc | 58 +- src/exp2cxx/entnode.cc | 48 +- src/exp2cxx/expressbuild.cc | 182 +- src/exp2cxx/fedex_main.c | 72 +- src/exp2cxx/genCxxFilenames.c | 18 +- src/exp2cxx/genCxxFilenames.h | 8 +- src/exp2cxx/match-ors.cc | 58 +- src/exp2cxx/multlist.cc | 135 +- src/exp2cxx/multpass.c | 445 +- src/exp2cxx/non-ors.cc | 46 +- src/exp2cxx/orlist.cc | 32 +- src/exp2cxx/print.cc | 48 +- src/exp2cxx/rules.c | 69 +- src/exp2cxx/rules.h | 4 +- src/exp2cxx/selects.c | 1811 ++-- src/exp2cxx/trynext.cc | 68 +- src/exp2cxx/write.cc | 56 +- src/exp2python/src/classes.h | 118 +- src/exp2python/src/classes_misc_python.c | 361 +- src/exp2python/src/classes_python.c | 1717 ++-- src/exp2python/src/classes_wrapper_python.cc | 220 +- src/exp2python/src/complexSupport.h | 368 +- src/exp2python/src/fedex_main_python.c | 62 +- src/exp2python/src/multpass_python.c | 319 +- src/exp2python/src/selects_python.c | 293 +- src/exppp/exppp-main.c | 73 +- src/exppp/exppp.c | 308 +- src/exppp/pp.h | 24 +- src/exppp/pretty_alg.c | 49 +- src/exppp/pretty_alg.h | 4 +- src/exppp/pretty_case.c | 61 +- src/exppp/pretty_case.h | 2 +- src/exppp/pretty_entity.c | 234 +- src/exppp/pretty_entity.h | 14 +- src/exppp/pretty_expr.c | 361 +- src/exppp/pretty_expr.h | 14 +- src/exppp/pretty_express.c | 9 +- src/exppp/pretty_express.h | 2 +- src/exppp/pretty_func.c | 58 +- src/exppp/pretty_func.h | 8 +- src/exppp/pretty_loop.c | 41 +- src/exppp/pretty_loop.h | 2 +- src/exppp/pretty_proc.c | 44 +- src/exppp/pretty_proc.h | 8 +- src/exppp/pretty_ref.c | 56 +- src/exppp/pretty_ref.h | 2 +- src/exppp/pretty_rule.c | 52 +- src/exppp/pretty_rule.h | 8 +- src/exppp/pretty_schema.c | 142 +- src/exppp/pretty_schema.h | 8 +- src/exppp/pretty_scope.c | 322 +- src/exppp/pretty_scope.h | 18 +- src/exppp/pretty_stmt.c | 115 +- src/exppp/pretty_stmt.h | 10 +- src/exppp/pretty_subtype.c | 18 +- src/exppp/pretty_subtype.h | 4 +- src/exppp/pretty_type.c | 255 +- src/exppp/pretty_type.h | 26 +- src/exppp/pretty_where.c | 60 +- src/exppp/pretty_where.h | 8 +- src/exppp/test/test_breakLongStr.c | 33 +- src/express/alg.c | 15 +- src/express/alloc.c | 84 +- src/express/caseitem.c | 8 +- src/express/dict.c | 89 +- src/express/entity.c | 218 +- src/express/error.c | 250 +- src/express/exp_kw.c | 240 +- src/express/expr.c | 617 +- src/express/express.c | 613 +- src/express/factory.c | 201 +- src/express/fedex.c | 114 +- src/express/generated/expparse.c | 7334 +++++++++-------- src/express/generated/expscan.c | 2150 ++--- src/express/generated/expscan.h | 10 +- src/express/hash.c | 259 +- src/express/info.c | 56 +- src/express/inithook.c | 3 +- src/express/lexact.c | 211 +- src/express/linklist.c | 134 +- src/express/memory.c | 91 +- src/express/object.c | 70 +- src/express/ordered_attrs.cc | 67 +- src/express/resolve.c | 862 +- src/express/resolve2.c | 91 +- src/express/schema.c | 150 +- src/express/scope.c | 131 +- src/express/stmt.c | 75 +- src/express/symbol.c | 3 +- src/express/test/driver.c | 30 +- src/express/test/driver.h | 2 +- src/express/test/fff.h | 174 +- src/express/test/print_attrs.c | 82 +- src/express/test/print_schemas.c | 18 +- src/express/test/test_expr.c | 60 +- src/express/test/test_express.c | 22 +- src/express/test/test_resolve.c | 143 +- src/express/test/test_resolve2.c | 31 +- src/express/test/test_schema.c | 79 +- src/express/test/test_scope.c | 22 +- src/express/test/test_type.c | 20 +- src/express/token_type.h | 6 +- src/express/type.c | 77 +- src/express/variable.c | 18 +- src/test/SEarritr.h | 24 +- src/test/generate_express/generate_express.cc | 35 +- src/test/needFunc.cc | 3 +- src/test/needFunc.h | 5 +- src/test/p21read/p21read.cc | 117 +- src/test/scl2html/scl2html.cc | 120 +- src/test/tests.h | 2 +- src/test/tio/tio.cc | 41 +- src/test/treg/treg.cc | 64 +- src/test/tstatic/tstatic.cc | 51 +- .../aggregate_bound_runtime.cc | 91 +- test/cpp/schema_specific/attribute.cc | 39 +- test/cpp/schema_specific/inverse_attr1.cc | 66 +- test/cpp/schema_specific/inverse_attr2.cc | 74 +- test/cpp/schema_specific/inverse_attr3.cc | 43 +- .../schema_specific/stepfile_rw_progress.cc | 59 +- 377 files changed, 29482 insertions(+), 26171 deletions(-) diff --git a/README.md b/README.md index 4df78fd0d..e34c4c2ef 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Linux, OSX (LLVM) | Windows (MSVC) [![Build Status](https://travis-ci.org/stepcode/stepcode.svg?branch=master)](https://travis-ci.org/stepcode/stepcode) | [![Build status](https://ci.appveyor.com/api/projects/status/3fbr9t9gfa812oqu?svg=true)](https://ci.appveyor.com/project/mpictor/stepcode) *********************************************************************** -STEPcode v0.8 -- stepcode.org, github.com/stepcode/stepcode +STEPcode v0.9 -- 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 @@ -36,14 +36,16 @@ CODING STANDARDS SC's source has been reformatted with astyle. When making changes, try to match the current formatting. The main points are: - - compact (java-style) brackets: + - K&R (Kernighan & Ritchie) brackets: ```C - if( a == 3 ) { - c = 5; - function( a, b ); - } else { - somefunc( ); - } + int Foo(bool isBar) + { + if (isBar) { + bar(); + return 1; + } else + return 0; + } ``` - indents are 4 spaces - no tab characters diff --git a/include/exppp/exppp.h b/include/exppp/exppp.h index f6159cbf5..1e7e78cc7 100644 --- a/include/exppp/exppp.h +++ b/include/exppp/exppp.h @@ -15,56 +15,56 @@ extern SC_EXPPP_EXPORT int exppp_linelength; /**< leave some slop extern SC_EXPPP_EXPORT bool exppp_alphabetize; /**< if true, alphabetize */ extern SC_EXPPP_EXPORT bool exppp_terse; /**< don't describe action to stdout */ extern SC_EXPPP_EXPORT bool exppp_reference_info; /**< if true, add commentary about where things came from */ -extern SC_EXPPP_EXPORT char * exppp_output_filename; /**< force output filename */ +extern SC_EXPPP_EXPORT char *exppp_output_filename; /**< force output filename */ extern SC_EXPPP_EXPORT bool exppp_output_filename_reset; /**< if true, force output filename */ extern SC_EXPPP_EXPORT bool exppp_print_to_stdout; /**< if true, print to stdout */ extern SC_EXPPP_EXPORT bool exppp_aggressively_wrap_consts; /**< for constants, print one item per line */ extern SC_EXPPP_EXPORT bool exppp_tail_comment; /**< print tail comment, such as END_ENTITY; --entity_name */ -SC_EXPPP_EXPORT void EXPRESSout( Express e ); +SC_EXPPP_EXPORT void EXPRESSout(Express e); -SC_EXPPP_EXPORT void ENTITYout( Entity e ); -SC_EXPPP_EXPORT void EXPRout( Expression expr ); -SC_EXPPP_EXPORT void FUNCout( Function f ); -SC_EXPPP_EXPORT void PROCout( Procedure p ); -SC_EXPPP_EXPORT void RULEout( Rule r ); -SC_EXPPP_EXPORT char * SCHEMAout( Schema s ); -SC_EXPPP_EXPORT void SCHEMAref_out( Schema s ); -SC_EXPPP_EXPORT void STMTout( Statement s ); -SC_EXPPP_EXPORT void TYPEout( Type t ); -SC_EXPPP_EXPORT void TYPEhead_out( Type t ); -SC_EXPPP_EXPORT void TYPEbody_out( Type t ); -SC_EXPPP_EXPORT void WHEREout( Linked_List w ); +SC_EXPPP_EXPORT void ENTITYout(Entity e); +SC_EXPPP_EXPORT void EXPRout(Expression expr); +SC_EXPPP_EXPORT void FUNCout(Function f); +SC_EXPPP_EXPORT void PROCout(Procedure p); +SC_EXPPP_EXPORT void RULEout(Rule r); +SC_EXPPP_EXPORT char *SCHEMAout(Schema s); +SC_EXPPP_EXPORT void SCHEMAref_out(Schema s); +SC_EXPPP_EXPORT void STMTout(Statement s); +SC_EXPPP_EXPORT void TYPEout(Type t); +SC_EXPPP_EXPORT void TYPEhead_out(Type t); +SC_EXPPP_EXPORT void TYPEbody_out(Type t); +SC_EXPPP_EXPORT void WHEREout(Linked_List w); -SC_EXPPP_EXPORT char * REFto_string( Dictionary refdict, Linked_List reflist, char * type, int level ); -SC_EXPPP_EXPORT char * ENTITYto_string( Entity e ); -SC_EXPPP_EXPORT char * SUBTYPEto_string( Expression e ); -SC_EXPPP_EXPORT char * EXPRto_string( Expression expr ); -SC_EXPPP_EXPORT char * FUNCto_string( Function f ); -SC_EXPPP_EXPORT char * PROCto_string( Procedure p ); -SC_EXPPP_EXPORT char * RULEto_string( Rule r ); -SC_EXPPP_EXPORT char * SCHEMAref_to_string( Schema s ); -SC_EXPPP_EXPORT char * STMTto_string( Statement s ); -SC_EXPPP_EXPORT char * TYPEto_string( Type t ); -SC_EXPPP_EXPORT char * TYPEhead_to_string( Type t ); -SC_EXPPP_EXPORT char * TYPEbody_to_string( Type t ); -SC_EXPPP_EXPORT char * WHEREto_string( Linked_List w ); +SC_EXPPP_EXPORT char *REFto_string(Dictionary refdict, Linked_List reflist, char *type, int level); +SC_EXPPP_EXPORT char *ENTITYto_string(Entity e); +SC_EXPPP_EXPORT char *SUBTYPEto_string(Expression e); +SC_EXPPP_EXPORT char *EXPRto_string(Expression expr); +SC_EXPPP_EXPORT char *FUNCto_string(Function f); +SC_EXPPP_EXPORT char *PROCto_string(Procedure p); +SC_EXPPP_EXPORT char *RULEto_string(Rule r); +SC_EXPPP_EXPORT char *SCHEMAref_to_string(Schema s); +SC_EXPPP_EXPORT char *STMTto_string(Statement s); +SC_EXPPP_EXPORT char *TYPEto_string(Type t); +SC_EXPPP_EXPORT char *TYPEhead_to_string(Type t); +SC_EXPPP_EXPORT char *TYPEbody_to_string(Type t); +SC_EXPPP_EXPORT char *WHEREto_string(Linked_List w); -SC_EXPPP_EXPORT int REFto_buffer( Dictionary refdict, Linked_List reflist, char * type, int level, char * buffer, int length ); -SC_EXPPP_EXPORT int ENTITYto_buffer( Entity e, char * buffer, int length ); -SC_EXPPP_EXPORT int EXPRto_buffer( Expression e, char * buffer, int length ); -SC_EXPPP_EXPORT int FUNCto_buffer( Function e, char * buffer, int length ); -SC_EXPPP_EXPORT int PROCto_buffer( Procedure e, char * buffer, int length ); -SC_EXPPP_EXPORT int RULEto_buffer( Rule e, char * buffer, int length ); -SC_EXPPP_EXPORT int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); -SC_EXPPP_EXPORT int STMTto_buffer( Statement s, char * buffer, int length ); -SC_EXPPP_EXPORT int TYPEto_buffer( Type t, char * buffer, int length ); -SC_EXPPP_EXPORT int TYPEhead_to_buffer( Type t, char * buffer, int length ); -SC_EXPPP_EXPORT int TYPEbody_to_buffer( Type t, char * buffer, int length ); -SC_EXPPP_EXPORT int WHEREto_buffer( Linked_List w, char * buffer, int length ); +SC_EXPPP_EXPORT int REFto_buffer(Dictionary refdict, Linked_List reflist, char *type, int level, char *buffer, int length); +SC_EXPPP_EXPORT int ENTITYto_buffer(Entity e, char *buffer, int length); +SC_EXPPP_EXPORT int EXPRto_buffer(Expression e, char *buffer, int length); +SC_EXPPP_EXPORT int FUNCto_buffer(Function e, char *buffer, int length); +SC_EXPPP_EXPORT int PROCto_buffer(Procedure e, char *buffer, int length); +SC_EXPPP_EXPORT int RULEto_buffer(Rule e, char *buffer, int length); +SC_EXPPP_EXPORT int SCHEMAref_to_buffer(Schema s, char *buffer, int length); +SC_EXPPP_EXPORT int STMTto_buffer(Statement s, char *buffer, int length); +SC_EXPPP_EXPORT int TYPEto_buffer(Type t, char *buffer, int length); +SC_EXPPP_EXPORT int TYPEhead_to_buffer(Type t, char *buffer, int length); +SC_EXPPP_EXPORT int TYPEbody_to_buffer(Type t, char *buffer, int length); +SC_EXPPP_EXPORT int WHEREto_buffer(Linked_List w, char *buffer, int length); -SC_EXPPP_EXPORT int EXPRlength( Expression e ); -extern SC_EXPPP_EXPORT void tail_comment( const char * name ); -extern SC_EXPPP_EXPORT int count_newlines( char * s ); +SC_EXPPP_EXPORT int EXPRlength(Expression e); +extern SC_EXPPP_EXPORT void tail_comment(const char *name); +extern SC_EXPPP_EXPORT int count_newlines(char *s); #endif diff --git a/include/express/alg.h b/include/express/alg.h index bc76c5ddd..20b2891a7 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -50,10 +50,10 @@ /* typedefs */ /************/ -typedef struct Scope_ * Procedure; -typedef struct Scope_ * Function; -typedef struct Scope_ * Rule; -typedef struct Where_ * Where; +typedef struct Scope_ *Procedure; +typedef struct Scope_ *Function; +typedef struct Scope_ *Rule; +typedef struct Where_ *Where; /***************************/ /* hidden type definitions */ @@ -63,13 +63,13 @@ typedef struct Where_ * Where; * As each (real) call is resolved, the tag->type is temporarily borrowed */ struct tag { - char * name; + char *name; Type type; }; /** location of fulltext of algorithm in source file */ struct FullText { - const char * filename; + const char *filename; unsigned int start, end; }; @@ -101,7 +101,7 @@ struct Rule_ { /** define a where clause */ struct Where_ { - Symbol * label; + Symbol *label; Expression expr; }; @@ -161,8 +161,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Scope ALGcreate( char ); -extern SC_EXPRESS_EXPORT void ALGinitialize( void ); -extern SC_EXPRESS_EXPORT void ALGput_full_text( Scope, int, int ); +extern SC_EXPRESS_EXPORT Scope ALGcreate(char); +extern SC_EXPRESS_EXPORT void ALGinitialize(void); +extern SC_EXPRESS_EXPORT void ALGput_full_text(Scope, int, int); #endif /* ALGORITHM_H */ diff --git a/include/express/alloc.h b/include/express/alloc.h index 79199773a..11a476878 100644 --- a/include/express/alloc.h +++ b/include/express/alloc.h @@ -35,7 +35,7 @@ typedef long Align; union freelist { - union freelist * next; /**< next block on freelist */ + union freelist *next; /**< next block on freelist */ char memory; /**< user data */ Align aligner; /**< force alignment of blocks */ }; @@ -52,13 +52,13 @@ struct freelist_head { #endif int size; /**< size of a single elt incl. next ptr */ int bytes; /**< if we run out, allocate memory by this many bytes */ - Freelist * freelist; + Freelist *freelist; #ifdef SPACE_PROFILE int count; #endif }; -char * nnew(); +char *nnew(); #include "error.h" @@ -75,10 +75,10 @@ extern SC_EXPRESS_EXPORT int yylineno; fprintf(stderr,"fedex: out of space");\ } else {} -SC_EXPRESS_EXPORT void _ALLOCinitialize( void ); -SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); -SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * ); -SC_EXPRESS_EXPORT void * ALLOC_new( struct freelist_head * ); +SC_EXPRESS_EXPORT void _ALLOCinitialize(void); +SC_EXPRESS_EXPORT void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2); +SC_EXPRESS_EXPORT void ALLOC_destroy(struct freelist_head *, Freelist *); +SC_EXPRESS_EXPORT void *ALLOC_new(struct freelist_head *); #endif /* ALLOC_H */ diff --git a/include/express/basic.h b/include/express/basic.h index 2dffecf3c..6e348c586 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -93,8 +93,8 @@ /* function pointer types */ /**************************/ -typedef void ( *voidFuncptr )(); -typedef int ( *intFuncptr )(); +typedef void (*voidFuncptr)(); +typedef int (*intFuncptr)(); #endif /* BASIC_H */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index 1c75f55bd..ff422ad78 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -48,7 +48,7 @@ /* typedefs */ /************/ -typedef struct Case_Item_ * Case_Item; +typedef struct Case_Item_ *Case_Item; /****************/ /* modules used */ @@ -63,7 +63,7 @@ typedef struct Case_Item_ * Case_Item; struct Case_Item_ { Symbol symbol; Linked_List labels; - struct Statement_ * action; + struct Statement_ *action; }; /********************/ @@ -86,7 +86,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; #define CASE_IT_new() (struct Case_Item_ *)ALLOC_new(&CASE_IT_fl) #define CASE_IT_destroy(x) ALLOC_destroy(&CASE_IT_fl,(Freelist *)x) -extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); -extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); +extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate(Linked_List, struct Statement_ *); +extern SC_EXPRESS_EXPORT void CASE_ITinitialize(void); #endif /*CASE_ITEM_H*/ diff --git a/include/express/dict.h b/include/express/dict.h index f289ecca3..d22f4c33c 100644 --- a/include/express/dict.h +++ b/include/express/dict.h @@ -55,7 +55,7 @@ /* typedefs */ /************/ -typedef struct Hash_Table_ * Dictionary; +typedef struct Hash_Table_ *Dictionary; typedef HashEntry DictionaryEntry; /****************/ @@ -97,14 +97,14 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void DICTinitialize( void ); -extern SC_EXPRESS_EXPORT void DICTcleanup( void ); -extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, void *, Symbol *, char ); -extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, void *, Symbol *, char ); -extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * ); -extern SC_EXPRESS_EXPORT void * DICTlookup( Dictionary, char * ); -extern SC_EXPRESS_EXPORT void * DICTlookup_symbol( Dictionary, char *, Symbol ** ); -extern SC_EXPRESS_EXPORT void * DICTdo( DictionaryEntry * ); -extern SC_EXPRESS_EXPORT void DICTprint( Dictionary ); +extern SC_EXPRESS_EXPORT void DICTinitialize(void); +extern SC_EXPRESS_EXPORT void DICTcleanup(void); +extern SC_EXPRESS_EXPORT int DICTdefine(Dictionary, char *, void *, Symbol *, char); +extern SC_EXPRESS_EXPORT int DICT_define(Dictionary, char *, void *, Symbol *, char); +extern SC_EXPRESS_EXPORT void DICTundefine(Dictionary, char *); +extern SC_EXPRESS_EXPORT void *DICTlookup(Dictionary, char *); +extern SC_EXPRESS_EXPORT void *DICTlookup_symbol(Dictionary, char *, Symbol **); +extern SC_EXPRESS_EXPORT void *DICTdo(DictionaryEntry *); +extern SC_EXPRESS_EXPORT void DICTprint(Dictionary); #endif /*DICTIONARY_H*/ diff --git a/include/express/entity.h b/include/express/entity.h index 3440dc9bc..4c26c1c88 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -69,7 +69,7 @@ /* typedefs */ /************/ -typedef struct Scope_ * Entity; +typedef struct Scope_ *Entity; /****************/ /* modules used */ @@ -140,19 +140,19 @@ extern SC_EXPRESS_EXPORT int ENTITY_MARK; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate( struct Symbol_ * ); -extern SC_EXPRESS_EXPORT void ENTITYinitialize( void ); -extern SC_EXPRESS_EXPORT void ENTITYadd_attribute( struct Scope_ *, struct Variable_ * ); -extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy( struct Scope_ * ); -extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, char *, int ); -extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute( struct Scope_ *, char *, struct Symbol_ ** ); -extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref( Entity, Symbol *, Symbol * ); -extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity ); -extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * ); -extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity ); -extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity ); -extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, void *); -extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset( Entity ); -extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable( Entity, struct Variable_ * ); +extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcreate(struct Symbol_ *); +extern SC_EXPRESS_EXPORT void ENTITYinitialize(void); +extern SC_EXPRESS_EXPORT void ENTITYadd_attribute(struct Scope_ *, struct Variable_ *); +extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcopy(struct Scope_ *); +extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity(struct Scope_ *, char *, int); +extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute(struct Scope_ *, char *, struct Symbol_ **); +extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref(Entity, Symbol *, Symbol *); +extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype(Entity, Entity); +extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute(Entity, char *); +extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes(Entity); +extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype(Entity, Entity); +extern SC_EXPRESS_EXPORT void ENTITYadd_instance(Entity, void *); +extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset(Entity); +extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable(Entity, struct Variable_ *); #endif /* ENTITY_H */ diff --git a/include/express/error.h b/include/express/error.h index 9a9334f88..65e32387c 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -166,7 +166,7 @@ typedef struct Error_ *Error; /********************/ extern SC_EXPRESS_EXPORT bool __ERROR_buffer_errors; -extern SC_EXPRESS_EXPORT const 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; @@ -180,26 +180,28 @@ extern SC_EXPRESS_EXPORT int malloc_debug_resolve; /* for debugging yacc/lex */ extern SC_EXPRESS_EXPORT int debug; -extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); +extern SC_EXPRESS_EXPORT void (*ERRORusage_function)(void); /***********************/ /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); +extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer(void); +extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer(void); -static inline void ERRORbuffer_messages( bool flag ) { +static inline void ERRORbuffer_messages(bool flag) +{ __ERROR_buffer_errors = flag; - if( __ERROR_buffer_errors ) { + if(__ERROR_buffer_errors) { ERROR_start_message_buffer(); } else { ERROR_flush_message_buffer(); } } -static inline void ERRORflush_messages( void ) { - if( __ERROR_buffer_errors ) { +static inline void ERRORflush_messages(void) +{ + if(__ERROR_buffer_errors) { ERROR_flush_message_buffer(); ERROR_start_message_buffer(); } @@ -210,22 +212,22 @@ static inline void ERRORflush_messages( void ) { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERRORinitialize( void ); -extern SC_EXPRESS_EXPORT void ERRORcleanup( void ); -extern SC_EXPRESS_EXPORT void ERRORnospace( void ); -extern SC_EXPRESS_EXPORT void ERRORabort( int ); -extern SC_EXPRESS_EXPORT void ERRORreport( enum ErrorCode, ... ); +extern SC_EXPRESS_EXPORT void ERRORinitialize(void); +extern SC_EXPRESS_EXPORT void ERRORcleanup(void); +extern SC_EXPRESS_EXPORT void ERRORnospace(void); +extern SC_EXPRESS_EXPORT void ERRORabort(int); +extern SC_EXPRESS_EXPORT void ERRORreport(enum ErrorCode, ...); struct Symbol_; /* mention Symbol to avoid warning on following line */ -extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( enum ErrorCode, struct Symbol_ *, ... ); -extern SC_EXPRESS_EXPORT void ERRORreport_with_line( enum ErrorCode, int, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol(enum ErrorCode, struct Symbol_ *, ...); +extern SC_EXPRESS_EXPORT void ERRORreport_with_line(enum ErrorCode, int, ...); -extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, bool ); -extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); -extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); -extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); +extern SC_EXPRESS_EXPORT void ERRORset_warning(char *, bool); +extern SC_EXPRESS_EXPORT void ERRORset_all_warnings(bool); +extern SC_EXPRESS_EXPORT void ERRORsafe(jmp_buf env); +extern SC_EXPRESS_EXPORT void ERRORunsafe(void); -extern SC_EXPRESS_EXPORT char * ERRORget_warnings_help(const char* prefix, const char *eol); +extern SC_EXPRESS_EXPORT char *ERRORget_warnings_help(const char *prefix, const char *eol); extern bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ diff --git a/include/express/exp_kw.h b/include/express/exp_kw.h index d8f1f6ec2..71974db6c 100644 --- a/include/express/exp_kw.h +++ b/include/express/exp_kw.h @@ -3,125 +3,125 @@ #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; +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 */ diff --git a/include/express/expbasic.h b/include/express/expbasic.h index 63ab6e291..2db340b5a 100644 --- a/include/express/expbasic.h +++ b/include/express/expbasic.h @@ -46,7 +46,7 @@ typedef enum { Lfalse, Lunknown, Ltrue } Logical; /* typedef ... Binary; done below because String not defined yet */ #ifndef _CLIENTDATA -typedef void * ClientData; +typedef void *ClientData; #define _CLIENTDATA #endif @@ -56,11 +56,11 @@ typedef void * ClientData; #include "alloc.h" -typedef struct Scope_ * Type; -typedef struct Scope_ * Scope; -typedef struct Scope_ * Schema; +typedef struct Scope_ *Type; +typedef struct Scope_ *Scope; +typedef struct Scope_ *Schema; -typedef char * Binary; +typedef char *Binary; #include "linklist.h" #define UNRESOLVED 0x0 diff --git a/include/express/expr.h b/include/express/expr.h index 57191d5b6..73f2a1b1c 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -88,10 +88,10 @@ typedef enum { } Op_Code; typedef struct Qualified_Attr Qualified_Attr; -typedef struct Expression_ * Expression; +typedef struct Expression_ *Expression; typedef Expression Ary_Expression, One_Of_Expression, Identifier, Literal; -typedef struct Query_ * Query; +typedef struct Query_ *Query; typedef One_Of_Expression Function_Call; typedef Ary_Expression Ternary_Expression, Binary_Expression, Unary_Expression; @@ -116,9 +116,9 @@ typedef Literal Aggregate_Literal, Integer_Literal, /* expression types */ struct Qualified_Attr { - struct Expression_ * complex; /**< complex entity instance */ - Symbol * entity; - Symbol * attribute; + struct Expression_ *complex; /**< complex entity instance */ + Symbol *entity; + Symbol *attribute; }; struct Op_Subexpression { @@ -132,22 +132,22 @@ struct Query_ { Variable local; Expression aggregate; /**< set from which to test */ Expression expression; /**< logical expression */ - struct Scope_ * scope; + struct Scope_ *scope; }; struct Funcall { - struct Scope_ * function; /**< can also be an entity because entities can be called as functions */ + struct Scope_ *function; /**< can also be an entity because entities can be called as functions */ Linked_List list; }; union expr_union { int integer; double real; - char * attribute; /**< inverse .... for 'attr' */ - char * binary; + char *attribute; /**< inverse .... for 'attr' */ + char *binary; int logical; bool boolean; - struct Query_ * query; + struct Query_ *query; struct Funcall funcall; /* if etype == aggregate, list of expressions */ @@ -158,7 +158,7 @@ union expr_union { * initializer in local vars, or * enumeration tags * or oneof value */ - struct Scope_ * entity; /**< used by subtype exp, group expr + struct Scope_ *entity; /**< used by subtype exp, group expr * and self expr, some funcall's and any * expr that results in an entity */ Variable variable; /**< attribute reference */ @@ -177,8 +177,8 @@ struct Expression_ { /** indexed by the op enumeration values */ struct EXPop_entry { - char * token; /**< literal token, e.g., "<>" */ - Type( *resolve )( Expression, struct Scope_ * ); + char *token; /**< literal token, e.g., "<>" */ + Type(*resolve)(Expression, struct Scope_ *); }; /********************/ @@ -249,18 +249,18 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Expression EXPcreate( Type ); -extern SC_EXPRESS_EXPORT Expression EXPcreate_simple( Type ); -extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol( Type, Symbol * ); -extern SC_EXPRESS_EXPORT Expression UN_EXPcreate( Op_Code, Expression ); -extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate( Op_Code, Expression, Expression ); -extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate( Op_Code, Expression, Expression, Expression ); -extern SC_EXPRESS_EXPORT Expression QUERYcreate( Symbol *, Expression ); -extern SC_EXPRESS_EXPORT void EXPinitialize( void ); -extern SC_EXPRESS_EXPORT void EXPcleanup( void ); -extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); -extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); - -Type EXPresolve_op_dot( Expression, Scope ); +extern SC_EXPRESS_EXPORT Expression EXPcreate(Type); +extern SC_EXPRESS_EXPORT Expression EXPcreate_simple(Type); +extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol(Type, Symbol *); +extern SC_EXPRESS_EXPORT Expression UN_EXPcreate(Op_Code, Expression); +extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate(Op_Code, Expression, Expression); +extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate(Op_Code, Expression, Expression, Expression); +extern SC_EXPRESS_EXPORT Expression QUERYcreate(Symbol *, Expression); +extern SC_EXPRESS_EXPORT void EXPinitialize(void); +extern SC_EXPRESS_EXPORT void EXPcleanup(void); +extern SC_EXPRESS_EXPORT Type EXPtype(Expression, struct Scope_ *); +extern SC_EXPRESS_EXPORT int EXPget_integer_value(Expression); + +Type EXPresolve_op_dot(Expression, Scope); #endif /*EXPRESSION_H*/ diff --git a/include/express/express.h b/include/express/express.h index e849ae56a..a89c67391 100644 --- a/include/express/express.h +++ b/include/express/express.h @@ -68,7 +68,7 @@ /* typedefs */ /************/ -typedef struct Scope_ * Express; +typedef struct Scope_ *Express; /****************/ /* modules used */ @@ -79,33 +79,33 @@ typedef struct Scope_ * Express; /***************************/ struct Express_ { - FILE * file; - char * filename; - char * basename; /**< name of file but without directory or .exp suffix */ + FILE *file; + char *filename; + char *basename; /**< name of file but without directory or .exp suffix */ }; /********************/ /* global variables */ /********************/ -extern SC_EXPRESS_EXPORT char * input_filename; +extern SC_EXPRESS_EXPORT char *input_filename; extern SC_EXPRESS_EXPORT Linked_List EXPRESS_path; extern SC_EXPRESS_EXPORT int EXPRESSpass; -extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_args )( int, char ** ); -extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_parse )( void ); -extern SC_EXPRESS_EXPORT int ( *EXPRESSfail )( Express ); -extern SC_EXPRESS_EXPORT int ( *EXPRESSsucceed )( Express ); -extern SC_EXPRESS_EXPORT void ( *EXPRESSbackend )( Express ); -extern SC_EXPRESS_EXPORT char * EXPRESSprogram_name; +extern SC_EXPRESS_EXPORT void (*EXPRESSinit_args)(int, char **); +extern SC_EXPRESS_EXPORT void (*EXPRESSinit_parse)(void); +extern SC_EXPRESS_EXPORT int (*EXPRESSfail)(Express); +extern SC_EXPRESS_EXPORT int (*EXPRESSsucceed)(Express); +extern SC_EXPRESS_EXPORT void (*EXPRESSbackend)(Express); +extern SC_EXPRESS_EXPORT char *EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt )( int, char * ); +extern SC_EXPRESS_EXPORT int (*EXPRESSgetopt)(int, char *); extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas; extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */ -extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_NVL; -extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN; +extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_NVL; +extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_USEDIN; /******************************/ /* macro function definitions */ @@ -120,15 +120,15 @@ extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Express EXPRESScreate( void ); -extern SC_EXPRESS_EXPORT void EXPRESSdestroy( Express ); -extern SC_EXPRESS_EXPORT void EXPRESSparse( Express, FILE *, char * ); -extern SC_EXPRESS_EXPORT void EXPRESSinitialize( void ); -extern SC_EXPRESS_EXPORT void EXPRESScleanup( void ); -extern SC_EXPRESS_EXPORT void EXPRESSresolve( Express ); -extern SC_EXPRESS_EXPORT int EXPRESS_fail( Express model ); -extern SC_EXPRESS_EXPORT int EXPRESS_succeed( Express model ); -extern void EXPRESSinit_init( void ); -extern SC_EXPRESS_EXPORT void build_complex( Express ); +extern SC_EXPRESS_EXPORT Express EXPRESScreate(void); +extern SC_EXPRESS_EXPORT void EXPRESSdestroy(Express); +extern SC_EXPRESS_EXPORT void EXPRESSparse(Express, FILE *, char *); +extern SC_EXPRESS_EXPORT void EXPRESSinitialize(void); +extern SC_EXPRESS_EXPORT void EXPRESScleanup(void); +extern SC_EXPRESS_EXPORT void EXPRESSresolve(Express); +extern SC_EXPRESS_EXPORT int EXPRESS_fail(Express model); +extern SC_EXPRESS_EXPORT int EXPRESS_succeed(Express model); +extern void EXPRESSinit_init(void); +extern SC_EXPRESS_EXPORT void build_complex(Express); #endif /*EXPRESS_H*/ diff --git a/include/express/hash.h b/include/express/hash.h index c5d1dfffe..5b3e9b150 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -116,14 +116,14 @@ typedef unsigned long Address; /****************/ typedef struct Element_ { - char * key; - char * data; - struct Element_ * next; - Symbol * symbol; /**< for debugging hash conflicts */ + char *key; + char *data; + struct Element_ *next; + Symbol *symbol; /**< for debugging hash conflicts */ char type; /**< user-supplied type */ -} * Element; +} *Element; -typedef Element * Segment; +typedef Element *Segment; typedef struct Hash_Table_ { #if 0 @@ -136,7 +136,7 @@ typedef struct Hash_Table_ { unsigned int MinLoadFactor; unsigned int MaxLoadFactor; Segment Directory[DIRECTORY_SIZE]; -} * Hash_Table; +} *Hash_Table; typedef struct { unsigned int i; /**< segment index (i think) */ @@ -192,13 +192,13 @@ This change only seems to have affected hash.h and hash.c /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void HASHinitialize( void ); -extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( unsigned ); -extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table ); -extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table ); -extern SC_EXPRESS_EXPORT Element HASHsearch( Hash_Table, Element, Action ); -extern SC_EXPRESS_EXPORT void HASHlistinit( Hash_Table, HashEntry * ); -extern SC_EXPRESS_EXPORT void HASHlistinit_by_type( Hash_Table, HashEntry *, char ); -extern SC_EXPRESS_EXPORT Element HASHlist( HashEntry * ); +extern SC_EXPRESS_EXPORT void HASHinitialize(void); +extern SC_EXPRESS_EXPORT Hash_Table HASHcreate(unsigned); +extern SC_EXPRESS_EXPORT Hash_Table HASHcopy(Hash_Table); +extern SC_EXPRESS_EXPORT void HASHdestroy(Hash_Table); +extern SC_EXPRESS_EXPORT Element HASHsearch(Hash_Table, Element, Action); +extern SC_EXPRESS_EXPORT void HASHlistinit(Hash_Table, HashEntry *); +extern SC_EXPRESS_EXPORT void HASHlistinit_by_type(Hash_Table, HashEntry *, char); +extern SC_EXPRESS_EXPORT Element HASHlist(HashEntry *); #endif /*HASH_H*/ diff --git a/include/express/info.h b/include/express/info.h index 1a96cf679..2a8c40d63 100644 --- a/include/express/info.h +++ b/include/express/info.h @@ -6,9 +6,9 @@ * informative functions that were in express.c/express.h */ -extern SC_EXPRESS_EXPORT char * EXPRESSversion( void ); +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 ); +extern SC_EXPRESS_EXPORT void EXPRESSusage(int _exit); #endif /* INFO_H */ diff --git a/include/express/lexact.h b/include/express/lexact.h index 9e9ac3559..5fb2212f2 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -56,9 +56,9 @@ typedef struct Scan_Buffer { #ifdef keep_nul int numRead; #endif - char * savedPos; - FILE * file; - const char * filename; + char *savedPos; + FILE *file; + const char *filename; bool readEof; int lineno; int bol; @@ -70,7 +70,7 @@ typedef struct Scan_Buffer { extern SC_EXPRESS_EXPORT Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; extern SC_EXPRESS_EXPORT int SCAN_current_buffer; -extern SC_EXPRESS_EXPORT char * SCANcurrent; +extern SC_EXPRESS_EXPORT char *SCANcurrent; /******************************/ /* macro function definitions */ @@ -93,22 +93,22 @@ extern SC_EXPRESS_EXPORT char * SCANcurrent; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SCANinitialize( void ); -extern SC_EXPRESS_EXPORT void SCANcleanup( void ); -extern SC_EXPRESS_EXPORT int SCANprocess_real_literal( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal( char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_string( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string( const char * ); -extern SC_EXPRESS_EXPORT int SCANprocess_semicolon( const char *, int ); -extern SC_EXPRESS_EXPORT void SCANsave_comment( const char * ); -extern SC_EXPRESS_EXPORT bool SCANread( void ); -extern SC_EXPRESS_EXPORT void SCANinclude_file( char * ); - SC_EXPRESS_EXPORT void SCANlowerize( char * ); - SC_EXPRESS_EXPORT void SCANupperize( char * ); -extern SC_EXPRESS_EXPORT char * SCANstrdup( const char * ); -extern SC_EXPRESS_EXPORT long SCANtell( void ); +extern SC_EXPRESS_EXPORT void SCANinitialize(void); +extern SC_EXPRESS_EXPORT void SCANcleanup(void); +extern SC_EXPRESS_EXPORT int SCANprocess_real_literal(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal(char *); +extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_string(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string(const char *); +extern SC_EXPRESS_EXPORT int SCANprocess_semicolon(const char *, int); +extern SC_EXPRESS_EXPORT void SCANsave_comment(const char *); +extern SC_EXPRESS_EXPORT bool SCANread(void); +extern SC_EXPRESS_EXPORT void SCANinclude_file(char *); +SC_EXPRESS_EXPORT void SCANlowerize(char *); +SC_EXPRESS_EXPORT void SCANupperize(char *); +extern SC_EXPRESS_EXPORT char *SCANstrdup(const char *); +extern SC_EXPRESS_EXPORT long SCANtell(void); #endif /* LEX_ACTIONS_H */ diff --git a/include/express/linklist.h b/include/express/linklist.h index 76c31a461..794ee9bcc 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -44,7 +44,7 @@ /* typedefs */ /************/ -typedef struct Linked_List_ * Linked_List; +typedef struct Linked_List_ *Linked_List; /****************/ /* modules used */ @@ -57,10 +57,10 @@ typedef struct Linked_List_ * Linked_List; /***************************/ typedef struct Link_ { - struct Link_ * next; - struct Link_ * prev; + struct Link_ *next; + struct Link_ *prev; void *data; -} * Link; +} *Link; struct Linked_List_ { Link mark; @@ -124,22 +124,22 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void LISTinitialize( void ); -extern SC_EXPRESS_EXPORT void LISTcleanup( void ); -extern SC_EXPRESS_EXPORT Linked_List LISTcreate( void ); -extern SC_EXPRESS_EXPORT Linked_List LISTcopy( Linked_List ); -extern SC_EXPRESS_EXPORT void LISTsort( Linked_List, int (*comp)(void*, void*) ); -extern SC_EXPRESS_EXPORT void LISTswap( Link, Link ); -extern SC_EXPRESS_EXPORT void * LISTadd_first( Linked_List, void * ); -extern SC_EXPRESS_EXPORT void * LISTadd_last( Linked_List, void * ); -extern SC_EXPRESS_EXPORT void * LISTadd_after( Linked_List, Link, void * ); -extern SC_EXPRESS_EXPORT void * LISTadd_before( Linked_List, Link, void * ); -extern SC_EXPRESS_EXPORT void * LISTremove_first( Linked_List ); -extern SC_EXPRESS_EXPORT void * LISTget_first( Linked_List ); -extern SC_EXPRESS_EXPORT void * LISTget_second( Linked_List ); -extern SC_EXPRESS_EXPORT void * LISTget_nth( Linked_List, int ); -extern SC_EXPRESS_EXPORT void LISTfree( Linked_List ); -extern SC_EXPRESS_EXPORT int LISTget_length( Linked_List ); -extern SC_EXPRESS_EXPORT bool LISTempty( Linked_List list ); +extern SC_EXPRESS_EXPORT void LISTinitialize(void); +extern SC_EXPRESS_EXPORT void LISTcleanup(void); +extern SC_EXPRESS_EXPORT Linked_List LISTcreate(void); +extern SC_EXPRESS_EXPORT Linked_List LISTcopy(Linked_List); +extern SC_EXPRESS_EXPORT void LISTsort(Linked_List, int (*comp)(void *, void *)); +extern SC_EXPRESS_EXPORT void LISTswap(Link, Link); +extern SC_EXPRESS_EXPORT void *LISTadd_first(Linked_List, void *); +extern SC_EXPRESS_EXPORT void *LISTadd_last(Linked_List, void *); +extern SC_EXPRESS_EXPORT void *LISTadd_after(Linked_List, Link, void *); +extern SC_EXPRESS_EXPORT void *LISTadd_before(Linked_List, Link, void *); +extern SC_EXPRESS_EXPORT void *LISTremove_first(Linked_List); +extern SC_EXPRESS_EXPORT void *LISTget_first(Linked_List); +extern SC_EXPRESS_EXPORT void *LISTget_second(Linked_List); +extern SC_EXPRESS_EXPORT void *LISTget_nth(Linked_List, int); +extern SC_EXPRESS_EXPORT void LISTfree(Linked_List); +extern SC_EXPRESS_EXPORT int LISTget_length(Linked_List); +extern SC_EXPRESS_EXPORT bool LISTempty(Linked_List list); #endif /*LINKED_LIST_H*/ diff --git a/include/express/object.h b/include/express/object.h index e5736f45b..524451081 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -68,8 +68,8 @@ /***************************/ struct Object { - struct Symbol_ * ( *get_symbol )(); - char * type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ + struct Symbol_ *(*get_symbol)(); + char *type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ int bits; /**< a bitwise selector of a type, i.e. OBJ_XX_BITS */ }; diff --git a/include/express/resolve.h b/include/express/resolve.h index 7eca8aa07..497c1a023 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -60,29 +60,29 @@ extern SC_EXPRESS_EXPORT int print_objects_while_running; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void RESOLVEinitialize( void ); -extern SC_EXPRESS_EXPORT void RESOLVEcleanup( void ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements( Scope ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers( Scope ); -extern SC_EXPRESS_EXPORT void SCOPEresolve_types( Scope ); -extern SC_EXPRESS_EXPORT void TYPE_resolve( Type * ); -extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); -extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); -extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); -extern SC_EXPRESS_EXPORT void RENAMEresolve( Rename *, Schema ); +extern SC_EXPRESS_EXPORT void RESOLVEinitialize(void); +extern SC_EXPRESS_EXPORT void RESOLVEcleanup(void); +extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements(Scope); +extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers(Scope); +extern SC_EXPRESS_EXPORT void SCOPEresolve_types(Scope); +extern SC_EXPRESS_EXPORT void TYPE_resolve(Type *); +extern SC_EXPRESS_EXPORT void EXP_resolve(Expression, Scope, Type); +extern SC_EXPRESS_EXPORT void ALGresolve(Scope); +extern SC_EXPRESS_EXPORT void SCHEMAresolve(Scope); +extern SC_EXPRESS_EXPORT void RENAMEresolve(Rename *, Schema); /* * for unit tests, no extern / export */ -void VAR_resolve_expressions( Variable, Entity ); -void ENTITYresolve_subtypes( Schema ); -void ENTITYresolve_supertypes( Entity ); -void ENTITYresolve_expressions( Entity e ); -void ALGresolve_expressions_statements( Scope, Linked_List ); -int WHEREresolve( Linked_List, Scope, int ); -void TYPEresolve_expressions( Type, Scope ); -void STMTresolve( Statement, Scope ); -void STMTlist_resolve( Linked_List, Scope ); -int ENTITYresolve_subtype_expression( Expression, Entity, Linked_List * ); +void VAR_resolve_expressions(Variable, Entity); +void ENTITYresolve_subtypes(Schema); +void ENTITYresolve_supertypes(Entity); +void ENTITYresolve_expressions(Entity e); +void ALGresolve_expressions_statements(Scope, Linked_List); +int WHEREresolve(Linked_List, Scope, int); +void TYPEresolve_expressions(Type, Scope); +void STMTresolve(Statement, Scope); +void STMTlist_resolve(Linked_List, Scope); +int ENTITYresolve_subtype_expression(Expression, Entity, Linked_List *); #endif /*RESOLVE_H*/ diff --git a/include/express/schema.h b/include/express/schema.h index 1d2ce5c4b..c2d1c6ca0 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -72,10 +72,10 @@ enum rename_type { use, ref }; typedef struct Rename { - struct Symbol_ * schema_sym; + struct Symbol_ *schema_sym; Schema schema; - struct Symbol_ * old; - struct Symbol_ * nnew; + struct Symbol_ *old; + struct Symbol_ *nnew; void *object; /**< once object has been looked up */ char type; /**< drat, need to remember this once renames have been * resolved to avoid looking them up in the dictionary again */ @@ -133,22 +133,22 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARfind( Scope, char *, int ); -extern SC_EXPRESS_EXPORT Schema SCHEMAcreate( void ); -extern SC_EXPRESS_EXPORT void SCHEMAinitialize( void ); -extern SC_EXPRESS_EXPORT void SCHEMAadd_use( Schema, Symbol *, Symbol *, Symbol * ); -extern SC_EXPRESS_EXPORT void SCHEMAadd_reference( Schema, Symbol *, Symbol *, Symbol * ); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_use( Schema, Rename * ); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference( Schema, Rename * ); -extern SC_EXPRESS_EXPORT void * SCHEMAfind( Schema, char * name, int search_refs ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate( char ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny( char ); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab( char ); -extern SC_EXPRESS_EXPORT void SCOPEdestroy( Scope ); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use( Scope ); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref( Scope ); - -void SCHEMA_get_entities_ref( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Variable VARfind(Scope, char *, int); +extern SC_EXPRESS_EXPORT Schema SCHEMAcreate(void); +extern SC_EXPRESS_EXPORT void SCHEMAinitialize(void); +extern SC_EXPRESS_EXPORT void SCHEMAadd_use(Schema, Symbol *, Symbol *, Symbol *); +extern SC_EXPRESS_EXPORT void SCHEMAadd_reference(Schema, Symbol *, Symbol *, Symbol *); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_use(Schema, Rename *); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference(Schema, Rename *); +extern SC_EXPRESS_EXPORT void *SCHEMAfind(Schema, char *name, int search_refs); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate(char); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny(char); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab(char); +extern SC_EXPRESS_EXPORT void SCOPEdestroy(Scope); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use(Scope); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref(Scope); + +void SCHEMA_get_entities_ref(Scope, Linked_List); #endif /* SCHEMA_H */ diff --git a/include/express/scope.h b/include/express/scope.h index 8f16fafbf..26e4a7f3f 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -83,16 +83,16 @@ struct Scope_ { ClientData clientData; /**< user may use this for any purpose */ int search_id; /**< key to avoid searching this scope twice */ Dictionary symbol_table, enum_table; - struct Scope_ * superscope; + struct Scope_ *superscope; union { - struct Procedure_ * proc; - struct Function_ * func; - struct Rule_ * rule; - struct Entity_ * entity; - struct Schema_ * schema; - struct Express_ * express; - struct Increment_ * incr; - struct TypeHead_ * type; + struct Procedure_ *proc; + struct Function_ *func; + struct Rule_ *rule; + struct Entity_ *entity; + struct Schema_ *schema; + struct Express_ *express; + struct Increment_ *incr; + struct TypeHead_ *type; /* no, query owns a scope rather than scope owning a query * struct Query *query; */ } u; @@ -134,16 +134,16 @@ struct Scope_ { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( void * ); -extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope ); -extern SC_EXPRESS_EXPORT void * SCOPEfind( Scope, char *, int ); -extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); -extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); - -void * SCOPE_find( Scope, char *, int ); +extern SC_EXPRESS_EXPORT struct Symbol_ *SCOPE_get_symbol(void *); +extern SC_EXPRESS_EXPORT void SCOPE_get_entities(Scope, Linked_List); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities(Scope); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order(Scope); +extern SC_EXPRESS_EXPORT void *SCOPEfind(Scope, char *, int); +extern SC_EXPRESS_EXPORT void SCOPE_get_functions(Scope, Linked_List); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions(Scope); +extern SC_EXPRESS_EXPORT void SCOPE_get_rules(Scope, Linked_List); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules(Scope); + +void *SCOPE_find(Scope, char *, int); #endif /* SCOPE_H */ diff --git a/include/express/stmt.h b/include/express/stmt.h index 21f5e4645..b0d49f3ff 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -56,17 +56,17 @@ /* typedefs */ /************/ -typedef struct Statement_ * Statement, - *Alias, - *Assignment, - *Case_Statement, - *Compound_Statement, - *Conditional, - *Loop, - *Procedure_Call, - *Return_Statement; - -typedef struct Scope_ * Increment; +typedef struct Statement_ *Statement, + *Alias, + *Assignment, + *Case_Statement, + *Compound_Statement, + *Conditional, + *Loop, + *Procedure_Call, + *Return_Statement; + +typedef struct Scope_ *Increment; /****************/ /* modules used */ @@ -97,21 +97,21 @@ struct Statement_ { int type; /**< one of STMT_XXX above */ /* hey, is there nothing in common beside symbol and private data?? */ union u_statement { - struct Alias_ * alias; - struct Assignment_ * assign; - struct Case_Statement_ * Case; - struct Compound_Statement_ * compound; - struct Conditional_ * cond; - struct Loop_ * loop; - struct Procedure_Call_ * proc; - struct Return_Statement_ * ret; + struct Alias_ *alias; + struct Assignment_ *assign; + struct Case_Statement_ *Case; + struct Compound_Statement_ *compound; + struct Conditional_ *cond; + struct Loop_ *loop; + struct Procedure_Call_ *proc; + struct Return_Statement_ *ret; /* skip & escape have no data */ } u; }; struct Alias_ { - struct Scope_ * scope; - struct Variable_ * variable; + struct Scope_ *scope; + struct Variable_ *variable; Linked_List statements; /**< list of statements */ }; @@ -136,7 +136,7 @@ struct Conditional_ { }; struct Loop_ { - struct Scope_ * scope; /**< scope for increment control */ + struct Scope_ *scope; /**< scope for increment control */ Expression while_expr; Expression until_expr; Linked_List statements; /**< list of statements */ @@ -150,7 +150,7 @@ struct Increment_ { }; struct Procedure_Call_ { - struct Scope_ * procedure; + struct Scope_ *procedure; Linked_List parameters; /**< list of expressions */ }; @@ -225,17 +225,17 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Statement STMTcreate( int ); -extern SC_EXPRESS_EXPORT Statement ALIAScreate( struct Scope_ *, Variable, Linked_List ); -extern SC_EXPRESS_EXPORT Statement CASEcreate( Expression , Linked_List ); -extern SC_EXPRESS_EXPORT Statement ASSIGNcreate( Expression , Expression ); -extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate( Linked_List ); -extern SC_EXPRESS_EXPORT Statement CONDcreate( Expression, Linked_List, Linked_List ); -extern SC_EXPRESS_EXPORT Statement LOOPcreate( struct Scope_ *, Expression, Expression, Linked_List ); -extern SC_EXPRESS_EXPORT Statement PCALLcreate( Linked_List ); -extern SC_EXPRESS_EXPORT Statement RETcreate( Expression ); -extern SC_EXPRESS_EXPORT void STMTinitialize( void ); -extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate( Symbol *, Expression start, - Expression end, Expression increment ); +extern SC_EXPRESS_EXPORT Statement STMTcreate(int); +extern SC_EXPRESS_EXPORT Statement ALIAScreate(struct Scope_ *, Variable, Linked_List); +extern SC_EXPRESS_EXPORT Statement CASEcreate(Expression, Linked_List); +extern SC_EXPRESS_EXPORT Statement ASSIGNcreate(Expression, Expression); +extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate(Linked_List); +extern SC_EXPRESS_EXPORT Statement CONDcreate(Expression, Linked_List, Linked_List); +extern SC_EXPRESS_EXPORT Statement LOOPcreate(struct Scope_ *, Expression, Expression, Linked_List); +extern SC_EXPRESS_EXPORT Statement PCALLcreate(Linked_List); +extern SC_EXPRESS_EXPORT Statement RETcreate(Expression); +extern SC_EXPRESS_EXPORT void STMTinitialize(void); +extern SC_EXPRESS_EXPORT struct Scope_ *INCR_CTLcreate(Symbol *, Expression start, + Expression end, Expression increment); #endif /*STATEMENT_H*/ diff --git a/include/express/symbol.h b/include/express/symbol.h index b589b01e2..8da717b51 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -58,8 +58,8 @@ typedef struct Symbol_ Symbol; /***************************/ struct Symbol_ { - char * name; - const char * filename; + char *name; + const char *filename; int line; char resolved; }; @@ -88,7 +88,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SYMBOLinitialize( void ); -SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename ); +extern SC_EXPRESS_EXPORT void SYMBOLinitialize(void); +SC_EXPRESS_EXPORT Symbol *SYMBOLcreate(char *name, int line, const char *filename); #endif /* SYMBOL_H */ diff --git a/include/express/type.h b/include/express/type.h index 321fe716e..c0680aea5 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -115,8 +115,8 @@ enum type_enum { /* typedefs */ /************/ -typedef struct TypeHead_ * TypeHead; -typedef struct TypeBody_ * TypeBody; +typedef struct TypeHead_ *TypeHead; +typedef struct TypeBody_ *TypeBody; typedef enum type_enum TypeType; /* provide a replacement for Class */ @@ -140,7 +140,7 @@ typedef enum type_enum Class; struct TypeHead_ { Type head; /**< if we are a defined type this is who we point to */ - struct TypeBody_ * body; /**< true type, ignoring defined types */ + struct TypeBody_ *body; /**< true type, ignoring defined types */ #if 0 /* if we are concerned about memory (over time) uncomment this and */ /* other references to refcount in parser and TYPEresolve. It is */ @@ -151,7 +151,7 @@ struct TypeHead_ { struct TypeBody_ { #if 1 - struct TypeHead_ * head; /**< for debugging only */ + struct TypeHead_ *head; /**< for debugging only */ #endif enum type_enum type; /**< bits describing this type, int, real, etc */ struct { @@ -174,7 +174,7 @@ struct TypeBody_ { Linked_List list; /**< used by select_types and composed types, such as for a list of entities in an instance */ Expression upper; Expression lower; - struct Scope_ * entity; /**< only used by entity types */ + struct Scope_ *entity; /**< only used by entity types */ }; /********************/ @@ -291,20 +291,20 @@ extern SC_EXPRESS_EXPORT struct freelist_head TYPEBODY_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Type TYPEcreate_partial( struct Symbol_ *, Scope ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_partial(struct Symbol_ *, Scope); -extern SC_EXPRESS_EXPORT Type TYPEcreate( enum type_enum ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously( TypeBody ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_name( struct Symbol_ * ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab( struct Symbol_ *, Scope, char ); -extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate( enum type_enum ); -extern SC_EXPRESS_EXPORT void TYPEinitialize( void ); -extern SC_EXPRESS_EXPORT void TYPEcleanup( void ); +extern SC_EXPRESS_EXPORT Type TYPEcreate(enum type_enum); +extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously(TypeBody); +extern SC_EXPRESS_EXPORT Type TYPEcreate_name(struct Symbol_ *); +extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab(struct Symbol_ *, Scope, char); +extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate(enum type_enum); +extern SC_EXPRESS_EXPORT void TYPEinitialize(void); +extern SC_EXPRESS_EXPORT void TYPEcleanup(void); -extern SC_EXPRESS_EXPORT bool TYPEinherits_from( Type, enum type_enum ); -extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type( Type ); +extern SC_EXPRESS_EXPORT bool TYPEinherits_from(Type, enum type_enum); +extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type(Type); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type( Type, Scope, struct Symbol_ * ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag( Type, Scope, struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type(Type, Scope, struct Symbol_ *); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag(Type, Scope, struct Symbol_ *); #endif /* TYPE_H */ diff --git a/include/express/variable.h b/include/express/variable.h index 308116459..b9d09a57d 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -62,7 +62,7 @@ /* typedefs */ /************/ -typedef struct Variable_ * Variable; +typedef struct Variable_ *Variable; /****************/ /* modules used */ @@ -91,7 +91,7 @@ struct Variable_ { unsigned int attribute : 1; /**< is an attribute (rule parameters are marked this way, too) */ } flags; - Symbol * inverse_symbol; /**< entity symbol */ + Symbol *inverse_symbol; /**< entity symbol */ Variable inverse_attribute; /**< attribute related by inverse relationship */ }; @@ -125,8 +125,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARcreate( Expression, Type ); -extern SC_EXPRESS_EXPORT void VARinitialize( void ); -extern SC_EXPRESS_EXPORT char * VARget_simple_name( Variable ); +extern SC_EXPRESS_EXPORT Variable VARcreate(Expression, Type); +extern SC_EXPRESS_EXPORT void VARinitialize(void); +extern SC_EXPRESS_EXPORT char *VARget_simple_name(Variable); #endif /* VARIABLE_H */ diff --git a/include/ordered_attrs.h b/include/ordered_attrs.h index 56a3b410f..dded023f6 100644 --- a/include/ordered_attrs.h +++ b/include/ordered_attrs.h @@ -16,13 +16,13 @@ typedef struct { } orderedAttr; /**set the entity we're working on, init working variables */ -extern SC_EXPRESS_EXPORT void orderedAttrsInit( Entity e ); +extern SC_EXPRESS_EXPORT void orderedAttrsInit(Entity e); /**free memory */ extern SC_EXPRESS_EXPORT void orderedAttrsCleanup(); /**get next attr; not thread safe (as if the rest of libexpress is) */ -extern SC_EXPRESS_EXPORT const orderedAttr * nextAttr(); +extern SC_EXPRESS_EXPORT const orderedAttr *nextAttr(); #ifdef __cplusplus } diff --git a/misc/astyle.cfg b/misc/astyle.cfg index 40268faed..da64a0c92 100644 --- a/misc/astyle.cfg +++ b/misc/astyle.cfg @@ -11,7 +11,7 @@ suffix=none #don't create backup files -style=java #compact bracket style +style=kr #Kernighan & Ritchie style indent=spaces=4 @@ -19,11 +19,10 @@ indent-classes indent-switches indent-namespaces pad-oper #pad (space) around operators -pad-paren-in #pad inside parenthesis unpad-paren #remove parenthesis padding other than requested above add-brackets #add brackets on one-line conditionals convert-tabs #convert all tabs to spaces -align-pointer=middle #char * foo +align-pointer=name #char *foo lineend=linux #lines end with LF (linux), not CRLF (windows) diff --git a/src/base/judy/misc/judy64n.c b/src/base/judy/misc/judy64n.c index 8dc8f909a..5e9d61d02 100644 --- a/src/base/judy/misc/judy64n.c +++ b/src/base/judy/misc/judy64n.c @@ -40,24 +40,24 @@ #include #ifdef linux - #define _FILE_OFFSET_BITS 64 - #define _LARGEFILE_SOURCE - #define __USE_FILE_OFFSET64 +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE +#define __USE_FILE_OFFSET64 - #include +#include #else - #ifdef __BIG_ENDIAN__ - #ifndef BYTE_ORDER - #define BYTE_ORDER 4321 - #endif - #else - #ifndef BYTE_ORDER - #define BYTE_ORDER 1234 - #endif - #endif - #ifndef BIG_ENDIAN - #define BIG_ENDIAN 4321 - #endif +#ifdef __BIG_ENDIAN__ +#ifndef BYTE_ORDER +#define BYTE_ORDER 4321 +#endif +#else +#ifndef BYTE_ORDER +#define BYTE_ORDER 1234 +#endif +#endif +#ifndef BIG_ENDIAN +#define BIG_ENDIAN 4321 +#endif #endif @@ -72,32 +72,32 @@ defined(__arch64__) || \ defined(__powerpc64__) || \ defined (__s390x__) - // defines for 64 bit +// defines for 64 bit - typedef unsigned long long judyvalue; - typedef unsigned long long JudySlot; - #define JUDY_key_mask (0x07) - #define JUDY_key_size 8 - #define JUDY_slot_size 8 - #define JUDY_span_bytes (3 * JUDY_key_size) - #define JUDY_span_equiv JUDY_2 - #define JUDY_radix_equiv JUDY_8 +typedef unsigned long long judyvalue; +typedef unsigned long long JudySlot; +#define JUDY_key_mask (0x07) +#define JUDY_key_size 8 +#define JUDY_slot_size 8 +#define JUDY_span_bytes (3 * JUDY_key_size) +#define JUDY_span_equiv JUDY_2 +#define JUDY_radix_equiv JUDY_8 - #define PRIjudyvalue "llu" +#define PRIjudyvalue "llu" #else - // defines for 32 bit +// defines for 32 bit - typedef unsigned int judyvalue; - typedef unsigned int JudySlot; - #define JUDY_key_mask (0x03) - #define JUDY_key_size 4 - #define JUDY_slot_size 4 - #define JUDY_span_bytes (7 * JUDY_key_size) - #define JUDY_span_equiv JUDY_4 - #define JUDY_radix_equiv JUDY_8 +typedef unsigned int judyvalue; +typedef unsigned int JudySlot; +#define JUDY_key_mask (0x03) +#define JUDY_key_size 4 +#define JUDY_slot_size 4 +#define JUDY_span_bytes (7 * JUDY_key_size) +#define JUDY_span_equiv JUDY_4 +#define JUDY_radix_equiv JUDY_8 - #define PRIjudyvalue "u" +#define PRIjudyvalue "u" #endif @@ -115,7 +115,7 @@ unsigned int MaxMem = 0; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort (char *msg) +void judy_abort(char *msg) { fprintf(stderr, "%s\n", msg); exit(1); @@ -155,9 +155,9 @@ int JudySize[] = { }; judyvalue JudyMask[9] = { -0, 0xff, 0xffff, 0xffffff, 0xffffffff, + 0, 0xff, 0xffff, 0xffffff, 0xffffffff, #if JUDY_key_size > 4 -0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL + 0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL #endif }; @@ -200,20 +200,20 @@ int Found = 0; // call with max key size // and Integer tree depth. -void *judy_open (unsigned int max, unsigned int depth) +void *judy_open(unsigned int max, unsigned int depth) { -JudySeg *seg; -Judy *judy; -unsigned int amt; + JudySeg *seg; + Judy *judy; + unsigned int amt; max++; // allow for zero terminator on keys - if( (seg = malloc(JUDY_seg)) ) { + if((seg = malloc(JUDY_seg))) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort ("No virtual memory"); + judy_abort("No virtual memory"); #else return NULL; #endif @@ -221,8 +221,9 @@ unsigned int amt; amt = sizeof(Judy) + max * sizeof(JudyStack); - if( amt & (JUDY_cache_line - 1) ) + if(amt & (JUDY_cache_line - 1)) { amt |= JUDY_cache_line - 1, amt++; + } #if defined(STANDALONE) || defined(ASKITIS) MaxMem += JUDY_seg; @@ -234,75 +235,79 @@ unsigned int amt; judy = (Judy *)((unsigned char *)seg + seg->next); memset(judy, 0, amt); judy->depth = depth; - judy->seg = seg; + judy->seg = seg; judy->max = max; return judy; } -void judy_close (Judy *judy) +void judy_close(Judy *judy) { -JudySeg *seg, *nxt = judy->seg; + JudySeg *seg, *nxt = judy->seg; - while( (seg = nxt) ) - nxt = seg->seg, free (seg); + while((seg = nxt)) { + nxt = seg->seg, free(seg); + } } // allocate judy node -void *judy_alloc (Judy *judy, unsigned int type) +void *judy_alloc(Judy *judy, unsigned int type) { -unsigned int amt, idx, min; -JudySeg *seg; -void **block; -void **rtn; + unsigned int amt, idx, min; + JudySeg *seg; + void **block; + void **rtn; - if( !judy->seg ) + if(!judy->seg) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if( type == JUDY_radix ) + if(type == JUDY_radix) { type = JUDY_radix_equiv; + } #ifndef ASKITIS - if( type == JUDY_span ) + if(type == JUDY_span) { type = JUDY_span_equiv; + } #endif amt = JudySize[type]; - if( amt & 0x07 ) + if(amt & 0x07) { amt |= 0x07, amt += 1; + } // see if free block is already available - if( (block = judy->reuse[type]) ) { + if((block = judy->reuse[type])) { judy->reuse[type] = *block; - memset (block, 0, amt); + memset(block, 0, amt); return (void *)block; } // break down available larger block // for reuse into smaller blocks - if( type >= JUDY_1 ) - for( idx = type; idx++ < JUDY_max; ) - if( block = judy->reuse[idx] ) { - judy->reuse[idx] = *block; - while( idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; - } - memset (block, 0, amt); - return (void *)block; - } + if(type >= JUDY_1) + for(idx = type; idx++ < JUDY_max;) + if(block = judy->reuse[idx]) { + judy->reuse[idx] = *block; + while(idx-- > type) { + judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); + block[JudySize[idx] / sizeof(void *)] = 0; + } + memset(block, 0, amt); + return (void *)block; + } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if( judy->seg->next < min + sizeof(*seg) ) { - if( (seg = malloc (JUDY_seg)) ) { + if(judy->seg->next < min + sizeof(*seg)) { + if((seg = malloc(JUDY_seg))) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -325,35 +330,36 @@ void **rtn; rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); - for( idx = type; amt & (JUDY_cache_line - 1); amt <<= 1 ) { + for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset (rtn, 0, JudySize[type]); + memset(rtn, 0, JudySize[type]); return (void *)rtn; } -void *judy_data (Judy *judy, unsigned int amt) +void *judy_data(Judy *judy, unsigned int amt) { -JudySeg *seg; -void *block; + JudySeg *seg; + void *block; - if( !judy->seg ) + if(!judy->seg) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if( amt & (JUDY_cache_line - 1)) + if(amt & (JUDY_cache_line - 1)) { amt |= (JUDY_cache_line - 1), amt += 1; + } - if( judy->seg->next < amt + sizeof(*seg) ) { - if( (seg = malloc (JUDY_seg)) ) { + if(judy->seg->next < amt + sizeof(*seg)) { + if((seg = malloc(JUDY_seg))) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -374,30 +380,32 @@ void *block; judy->seg->next -= amt; block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset (block, 0, amt); + memset(block, 0, amt); return block; } -void *judy_clone (Judy *judy) +void *judy_clone(Judy *judy) { -Judy *clone; -unsigned int amt; + Judy *clone; + unsigned int amt; amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data (judy, amt); - memcpy (clone, judy, amt); + clone = judy_data(judy, amt); + memcpy(clone, judy, amt); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free (Judy *judy, void *block, int type) +void judy_free(Judy *judy, void *block, int type) { - if( type == JUDY_radix ) + if(type == JUDY_radix) { type = JUDY_radix_equiv; + } #ifndef ASKITIS - if( type == JUDY_span ) + if(type == JUDY_span) { type = JUDY_span_equiv; + } #endif *((void **)(block)) = judy->reuse[type]; @@ -407,95 +415,104 @@ void judy_free (Judy *judy, void *block, int type) // assemble key from current path -unsigned int judy_key (Judy *judy, unsigned char *buff, unsigned int max) +unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) { -judyvalue *dest = (judyvalue *)buff; -unsigned int len = 0, idx = 0, depth; -int slot, off, type; -judyvalue value; -unsigned char *base; -int keysize; - - if( judy->depth ) + judyvalue *dest = (judyvalue *)buff; + unsigned int len = 0, idx = 0, depth; + int slot, off, type; + judyvalue value; + unsigned char *base; + int keysize; + + if(judy->depth) { max = judy->depth * JUDY_key_size; - else - max--; // leave room for zero terminator + } else { + max--; // leave room for zero terminator + } - while( len < max && ++idx <= judy->level ) { + while(len < max && ++idx <= judy->level) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if( judy->depth ) - if( !(len & JUDY_key_mask) ) - dest[depth] = 0; - - switch( type ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + if(judy->depth) + if(!(len & JUDY_key_mask)) { + dest[depth] = 0; + } + + switch(type) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - if( judy->depth ) { - value = *(judyvalue *)(base + slot * keysize); - value &= JudyMask[keysize]; - dest[depth++] |= value; - len += keysize; + if(judy->depth) { + value = *(judyvalue *)(base + slot * keysize); + value &= JudyMask[keysize]; + dest[depth++] |= value; + len += keysize; - if( depth < judy->depth ) - continue; + if(depth < judy->depth) { + continue; + } - return len; - } + return len; + } #if BYTE_ORDER != BIG_ENDIAN - off = keysize; - - while( off-- && len < max ) - if( buff[len] = base[slot * keysize + off] ) - len++; - else - break; + off = keysize; + + while(off-- && len < max) + if(buff[len] = base[slot * keysize + off]) { + len++; + } else { + break; + } #else - for( off = 0; off < keysize && len < max; off++ ) - if( buff[len] = base[slot * keysize + off] ) - len++; - else - break; + for(off = 0; off < keysize && len < max; off++) + if(buff[len] = base[slot * keysize + off]) { + len++; + } else { + break; + } #endif - continue; - - case JUDY_radix: - if( judy->depth ) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if( !(len & JUDY_key_mask) ) - depth++; - if( depth < judy->depth ) - continue; + continue; - return len; - } + case JUDY_radix: + if(judy->depth) { + dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; + if(!(len & JUDY_key_mask)) { + depth++; + } + if(depth < judy->depth) { + continue; + } + + return len; + } - if( !slot ) - break; - buff[len++] = (unsigned char)slot; - continue; + if(!slot) { + break; + } + buff[len++] = (unsigned char)slot; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + case JUDY_span: + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) - if( len < max ) - buff[len++] = base[slot]; - continue; + for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) + if(len < max) { + buff[len++] = base[slot]; + } + continue; #endif } } @@ -505,139 +522,149 @@ int keysize; // find slot & setup cursor -JudySlot *judy_slot (Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_slot(Judy *judy, unsigned char *buff, unsigned int max) { -judyvalue *src = (judyvalue *)buff; -int slot, size, keysize, tst, cnt; -JudySlot next = *judy->root; -judyvalue value, test = 0; -JudySlot *table; -JudySlot *node; -unsigned int depth = 0; -unsigned int off = 0; -unsigned char *base; + judyvalue *src = (judyvalue *)buff; + int slot, size, keysize, tst, cnt; + JudySlot next = *judy->root; + judyvalue value, test = 0; + JudySlot *table; + JudySlot *node; + unsigned int depth = 0; + unsigned int off = 0; + unsigned char *base; #ifndef ASKITIS judy->level = 0; #endif - while( next ) { + while(next) { #ifndef ASKITIS - if( judy->level < judy->max ) + if(judy->level < judy->max) { judy->level++; + } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; #endif size = JudySize[next & 0x07]; - switch( next & 0x07 ) { + switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: -#endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - slot = cnt; - value = 0; - - if( judy->depth ) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if( off < max ) - value |= buff[off]; - } while( ++off & JUDY_key_mask ); - - // find slot > key - - while( slot-- ) { - test = *(judyvalue *)(base + slot * keysize); + case JUDY_64: +#endif + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + slot = cnt; + value = 0; + + if(judy->depth) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if(off < max) { + value |= buff[off]; + } + } while(++off & JUDY_key_mask); + + // find slot > key + + while(slot--) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if( test <= value ) - break; - } + if(test <= value) { + break; + } + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if( test == value ) { + if(test == value) { - // is this a leaf? + // is this a leaf? - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) - return &node[-slot-1]; + if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + return &node[-slot - 1]; + } - next = node[-slot-1]; - continue; - } + next = node[-slot - 1]; + continue; + } - return NULL; + return NULL; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); // outer radix - if( judy->depth ) - slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; - else if( off < max ) - slot = buff[off++]; - else - slot = 0; + if(judy->depth) { + slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; + } else if(off < max) { + slot = buff[off++]; + } else { + slot = 0; + } #ifndef ASKITIS - // put radix slot on judy stack + // put radix slot on judy stack - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if( (next = table[slot >> 4]) ) - table = (JudySlot *)(next & JUDY_mask); // inner radix - else - return NULL; + if((next = table[slot >> 4])) { + table = (JudySlot *)(next & JUDY_mask); // inner radix + } else { + return NULL; + } - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; + if(judy->depth) + if(!(off & JUDY_key_mask)) { + depth++; + } - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) // leaf? - if( table[slot & 0x0F] ) // occupied? - return &table[slot & 0x0F]; - else - return NULL; + if(!judy->depth && !slot || judy->depth && depth == judy->depth) // leaf? + if(table[slot & 0x0F]) { // occupied? + return &table[slot & 0x0F]; + } else { + return NULL; + } - next = table[slot & 0x0F]; - continue; + next = table[slot & 0x0F]; + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = tst = JUDY_span_bytes; - if( tst > (int)(max - off) ) - tst = max - off; - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if( !value && tst < cnt && !base[tst] ) // leaf? - return &node[-1]; + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = tst = JUDY_span_bytes; + if(tst > (int)(max - off)) { + tst = max - off; + } + value = strncmp((const char *)base, (const char *)(buff + off), tst); + if(!value && tst < cnt && !base[tst]) { // leaf? + return &node[-1]; + } - if( !value && tst == cnt ) { - next = node[-1]; - off += cnt; - continue; - } - return NULL; + if(!value && tst == cnt) { + next = node[-1]; + off += cnt; + continue; + } + return NULL; #endif } } @@ -647,26 +674,26 @@ unsigned char *base; // promote full nodes to next larger size -JudySlot *judy_promote (Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) +JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) { -unsigned char *base = (unsigned char *)(*next & JUDY_mask); -int oldcnt, newcnt, slot; + unsigned char *base = (unsigned char *)(*next & JUDY_mask); + int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif -JudySlot *newnode, *node; -JudySlot *result; -unsigned char *newbase; -unsigned int type; + JudySlot *newnode, *node; + JudySlot *result; + unsigned char *newbase; + unsigned int type; type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type-1]); - oldcnt = JudySize[type-1] / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); + oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); // promote node to next larger size - newbase = judy_alloc (judy, type); + newbase = judy_alloc(judy, type); newnode = (JudySlot *)(newbase + JudySize[type]); *next = (JudySlot)newbase | type; @@ -674,8 +701,9 @@ unsigned int type; memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys - for( slot = 0; slot < idx; slot++ ) + for(slot = 0; slot < idx; slot++) { newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr + } // fill in new node @@ -684,8 +712,9 @@ unsigned int type; #else i = keysize; - while( i-- ) - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; + while(i--) { + newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; + } #endif result = &newnode[-(idx + newcnt - oldcnt)]; @@ -693,14 +722,15 @@ unsigned int type; memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys - for( ; slot < oldcnt; slot++ ) + for(; slot < oldcnt; slot++) { newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr + } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free (judy, (void **)base, type - 1); + judy_free(judy, (void **)base, type - 1); return result; } @@ -708,18 +738,18 @@ unsigned int type; // make node with slot - start entries // moving key over one offset -void judy_radix (Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) +void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) { -int size, idx, cnt = slot - start, newcnt; -JudySlot *node, *oldnode; -unsigned int type = JUDY_1 - 1; -JudySlot *table; -unsigned char *base; + int size, idx, cnt = slot - start, newcnt; + JudySlot *node, *oldnode; + unsigned int type = JUDY_1 - 1; + JudySlot *table; + unsigned char *base; // if necessary, setup inner radix node - if( !(table = (JudySlot *)(radix[key >> 4] & JUDY_mask)) ) { - table = judy_alloc (judy, JUDY_radix); + if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { + table = judy_alloc(judy, JUDY_radix); radix[key >> 4] = (JudySlot)table | JUDY_radix; } @@ -727,8 +757,8 @@ unsigned char *base; // is this slot a leaf? - if( !judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { - table[key & 0x0F] = oldnode[-start-1]; + if(!judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { + table[key & 0x0F] = oldnode[-start - 1]; return; } @@ -738,22 +768,22 @@ unsigned char *base; type++; size = JudySize[type]; newcnt = size / (sizeof(JudySlot) + keysize); - } while( cnt > newcnt && type < JUDY_max ); + } while(cnt > newcnt && type < JUDY_max); // store new node pointer in inner table - base = judy_alloc (judy, type); + base = judy_alloc(judy, type); node = (JudySlot *)(base + size); table[key & 0x0F] = (JudySlot)base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for( idx = 0; idx < cnt; idx++ ) { + for(idx = 0; idx < cnt; idx++) { #if BYTE_ORDER != BIG_ENDIAN - memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); + memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); #else - memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); + memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); #endif node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; } @@ -761,122 +791,132 @@ unsigned char *base; // decompose full node to radix nodes -void judy_splitnode (Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) +void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) { -int cnt, slot, start = 0; -unsigned int key = 0x0100, nxt; -JudySlot *newradix; -unsigned char *base; + int cnt, slot, start = 0; + unsigned int key = 0x0100, nxt; + JudySlot *newradix; + unsigned char *base; - base = (unsigned char *)(*next & JUDY_mask); + base = (unsigned char *)(*next & JUDY_mask); cnt = size / (sizeof(JudySlot) + keysize); // allocate outer judy_radix node - newradix = judy_alloc (judy, JUDY_radix); + newradix = judy_alloc(judy, JUDY_radix); *next = (JudySlot)newradix | JUDY_radix; - for( slot = 0; slot < cnt; slot++ ) { + for(slot = 0; slot < cnt; slot++) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if( key > 0xFF ) + if(key > 0xFF) { key = nxt; - if( nxt == key ) + } + if(nxt == key) { continue; + } // decompose portion of old node into radix nodes - judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); start = slot; key = nxt; } - judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free (judy, (void **)base, JUDY_max); + judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_free(judy, (void **)base, JUDY_max); } // return first leaf -JudySlot *judy_first (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { -JudySlot *table, *inner; -unsigned int keysize, size; -JudySlot *node; -int slot, cnt; -unsigned char *base; - - while( next ) { - if( judy->level < judy->max ) + JudySlot *table, *inner; + unsigned int keysize, size; + JudySlot *node; + int slot, cnt; + unsigned char *base; + + while(next) { + if(judy->level < judy->max) { judy->level++; + } judy->stack[judy->level].off = off; judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch(next & 0x07) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + cnt = size / (sizeof(JudySlot) + keysize); - for( slot = 0; slot < cnt; slot++ ) - if( node[-slot-1] ) - break; + for(slot = 0; slot < cnt; slot++) + if(node[-slot - 1]) { + break; + } - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) - return &node[-slot-1]; + if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) { + return &node[-slot - 1]; + } #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) - return &node[-slot-1]; + if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { + return &node[-slot - 1]; + } #endif - next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; - continue; - case JUDY_radix: - off++; + next = node[-slot - 1]; + off = (off | JUDY_key_mask) + 1; + continue; + case JUDY_radix: + off++; - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - table = (JudySlot *)(next & JUDY_mask); - for( slot = 0; slot < 256; slot++ ) - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( (next = inner[slot & 0x0F]) ) { - judy->stack[judy->level].slot = slot; - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[slot & 0x0F]; - else - break; - } - } else - slot |= 0x0F; - continue; + if(judy->depth) + if(!(off & JUDY_key_mask)) { + depth++; + } + + table = (JudySlot *)(next & JUDY_mask); + for(slot = 0; slot < 256; slot++) + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if((next = inner[slot & 0x0F])) { + judy->stack[judy->level].slot = slot; + if(!judy->depth && !slot || judy->depth && depth == judy->depth) { + return &inner[slot & 0x0F]; + } else { + break; + } + } + } else { + slot |= 0x0F; + } + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) // leaf node? - return &node[-1]; - next = node[-1]; - off += cnt; - continue; + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if(!base[cnt - 1]) { // leaf node? + return &node[-1]; + } + next = node[-1]; + off += cnt; + continue; #endif } } @@ -885,79 +925,84 @@ unsigned char *base; // return last leaf cell pointer -JudySlot *judy_last (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { -JudySlot *table, *inner; -unsigned int keysize, size; -JudySlot *node; -int slot, cnt; -unsigned char *base; - - while( next ) { - if( judy->level < judy->max ) + JudySlot *table, *inner; + unsigned int keysize, size; + JudySlot *node; + int slot, cnt; + unsigned char *base; + + while(next) { + if(judy->level < judy->max) { judy->level++; + } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch(next & 0x07) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - judy->stack[judy->level].slot = --slot; + keysize = JUDY_key_size - (off & JUDY_key_mask); + slot = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) #endif - return &node[-slot-1]; + return &node[-slot - 1]; - next = node[-slot-1]; - off += keysize; - continue; + next = node[-slot - 1]; + off += keysize; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - off++; + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + off++; - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - for( slot = 256; slot--; ) { - judy->stack[judy->level].slot = slot; - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( (next = inner[slot & 0x0F]) ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[0]; - else - break; - } else - slot &= 0xF0; - } - continue; + if(judy->depth) + if(!(off & JUDY_key_mask)) { + depth++; + } + + for(slot = 256; slot--;) { + judy->stack[judy->level].slot = slot; + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if((next = inner[slot & 0x0F])) + if(!judy->depth && !slot || judy->depth && depth == judy->depth) { + return &inner[0]; + } else { + break; + } + } else { + slot &= 0xF0; + } + } + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) // leaf node? - return &node[-1]; - next = node[-1]; - off += cnt; - continue; + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if(!base[cnt - 1]) { // leaf node? + return &node[-1]; + } + next = node[-1]; + off += cnt; + continue; #endif } } @@ -966,27 +1011,28 @@ unsigned char *base; // judy_end: return last entry -JudySlot *judy_end (Judy *judy) +JudySlot *judy_end(Judy *judy) { judy->level = 0; - return judy_last (judy, *judy->root, 0, 0); + return judy_last(judy, *judy->root, 0, 0); } // judy_nxt: return next entry -JudySlot *judy_nxt (Judy *judy) +JudySlot *judy_nxt(Judy *judy) { -JudySlot *table, *inner; -int slot, size, cnt; -JudySlot *node; -JudySlot next; -unsigned int keysize; -unsigned char *base; -unsigned int depth; -unsigned int off; - - if( !judy->level ) - return judy_first (judy, *judy->root, 0, 0); - - while( judy->level ) { + JudySlot *table, *inner; + int slot, size, cnt; + JudySlot *node; + JudySlot next; + unsigned int keysize; + unsigned char *base; + unsigned int depth; + unsigned int off; + + if(!judy->level) { + return judy_first(judy, *judy->root, 0, 0); + } + + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; @@ -994,59 +1040,62 @@ unsigned int off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch(next & 0x07) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if( ++slot < cnt ) + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + if(++slot < cnt) #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) -#endif - { - judy->stack[judy->level].slot = slot; - return &node[-slot - 1]; - } else { - judy->stack[judy->level].slot = slot; - return judy_first (judy, node[-slot-1], (off | JUDY_key_mask) + 1, depth); - } - judy->level--; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if( judy->depth ) - if( !((off+1) & JUDY_key_mask) ) - depth++; + if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) +#endif + { + judy->stack[judy->level].slot = slot; + return &node[-slot - 1]; + } else { + judy->stack[judy->level].slot = slot; + return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); + } + judy->level--; + continue; - while( ++slot < 256 ) - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( inner[slot & 0x0F] ) { - judy->stack[judy->level].slot = slot; - if( !judy->depth || depth < judy->depth ) - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); - return &inner[slot & 0x0F]; - } - } else - slot |= 0x0F; + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + + if(judy->depth) + if(!((off + 1) & JUDY_key_mask)) { + depth++; + } + + while(++slot < 256) + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if(inner[slot & 0x0F]) { + judy->stack[judy->level].slot = slot; + if(!judy->depth || depth < judy->depth) { + return judy_first(judy, inner[slot & 0x0F], off + 1, depth); + } + return &inner[slot & 0x0F]; + } + } else { + slot |= 0x0F; + } - judy->level--; - continue; + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1055,77 +1104,80 @@ unsigned int off; // judy_prv: return ptr to previous entry -JudySlot *judy_prv (Judy *judy) +JudySlot *judy_prv(Judy *judy) { -int slot, size, keysize; -JudySlot *table, *inner; -JudySlot *node, next; -unsigned char *base; -unsigned int depth; -unsigned int off; - - if( !judy->level ) - return judy_last (judy, *judy->root, 0, 0); + int slot, size, keysize; + JudySlot *table, *inner; + JudySlot *node, next; + unsigned char *base; + unsigned int depth; + unsigned int off; + + if(!judy->level) { + return judy_last(judy, *judy->root, 0, 0); + } - while( judy->level ) { + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch(next & 0x07) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - node = (JudySlot *)((next & JUDY_mask) + size); - if( !slot || !node[-slot] ) { - judy->level--; - continue; - } + node = (JudySlot *)((next & JUDY_mask) + size); + if(!slot || !node[-slot]) { + judy->level--; + continue; + } - base = (unsigned char *)(next & JUDY_mask); - judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); + base = (unsigned char *)(next & JUDY_mask); + judy->stack[judy->level].slot--; + keysize = JUDY_key_size - (off & JUDY_key_mask); #if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth ) + if(!judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth) #else - if( !judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) -#endif - return &node[-slot]; - return judy_last (judy, node[-slot], (off | JUDY_key_mask) + 1, depth); - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if( judy->depth ) - if( !((off + 1) & JUDY_key_mask) ) - depth++; - - while( slot-- ) { - judy->stack[judy->level].slot--; - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) - if( inner[slot & 0x0F] ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[0]; - else - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); - } + if(!judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) +#endif + return &node[-slot]; + return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); + + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + + if(judy->depth) + if(!((off + 1) & JUDY_key_mask)) { + depth++; + } + + while(slot--) { + judy->stack[judy->level].slot--; + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) + if(inner[slot & 0x0F]) + if(!judy->depth && !slot || judy->depth && depth == judy->depth) { + return &inner[0]; + } else { + return judy_last(judy, inner[slot & 0x0F], off + 1, depth); + } + } - judy->level--; - continue; + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1135,84 +1187,86 @@ unsigned int off; // judy_del: delete string from judy array // returning previous entry. -JudySlot *judy_del (Judy *judy) +JudySlot *judy_del(Judy *judy) { -int slot, off, size, type, high; -JudySlot *table, *inner; -JudySlot next, *node; -int keysize, cnt; -unsigned char *base; + int slot, off, size, type, high; + JudySlot *table, *inner; + JudySlot next, *node; + int keysize, cnt; + unsigned char *base; - while( judy->level ) { + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch( type = next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch(type = next & 0x07) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); - // move deleted slot to first slot + // move deleted slot to first slot - while( slot ) { - node[-slot-1] = node[-slot]; - memcpy (base + slot * keysize, base + (slot - 1) * keysize, keysize); - slot--; - } + while(slot) { + node[-slot - 1] = node[-slot]; + memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); + slot--; + } - // zero out first slot + // zero out first slot - node[-1] = 0; - memset (base, 0, keysize); + node[-1] = 0; + memset(base, 0, keysize); - if( node[-cnt] ) { // does node have any slots left? - judy->stack[judy->level].slot++; - return judy_prv (judy); - } + if(node[-cnt]) { // does node have any slots left? + judy->stack[judy->level].slot++; + return judy_prv(judy); + } - judy_free (judy, base, type); - judy->level--; - continue; + judy_free(judy, base, type); + judy->level--; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); - inner[slot & 0x0F] = 0; - high = slot & 0xF0; + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); + inner[slot & 0x0F] = 0; + high = slot & 0xF0; - for( cnt = 16; cnt--; ) - if( inner[cnt] ) - return judy_prv (judy); + for(cnt = 16; cnt--;) + if(inner[cnt]) { + return judy_prv(judy); + } - judy_free (judy, inner, JUDY_radix); - table[slot >> 4] = 0; + judy_free(judy, inner, JUDY_radix); + table[slot >> 4] = 0; - for( cnt = 16; cnt--; ) - if( table[cnt] ) - return judy_prv (judy); + for(cnt = 16; cnt--;) + if(table[cnt]) { + return judy_prv(judy); + } - judy_free (judy, table, JUDY_radix); - judy->level--; - continue; + judy_free(judy, table, JUDY_radix); + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free (judy, base, type); - judy->level--; - continue; + case JUDY_span: + base = (unsigned char *)(next & JUDY_mask); + judy_free(judy, base, type); + judy->level--; + continue; #endif } } @@ -1225,266 +1279,284 @@ unsigned char *base; // return cell for first key greater than or equal to given key -JudySlot *judy_strt (Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_strt(Judy *judy, unsigned char *buff, unsigned int max) { -JudySlot *cell; + JudySlot *cell; judy->level = 0; - if( !max ) - return judy_first (judy, *judy->root, 0, 0); + if(!max) { + return judy_first(judy, *judy->root, 0, 0); + } - if( (cell = judy_slot (judy, buff, max)) ) + if((cell = judy_slot(judy, buff, max))) { return cell; + } - return judy_nxt (judy); + return judy_nxt(judy); } // split open span node #ifndef ASKITIS -void judy_splitspan (Judy *judy, JudySlot *next, unsigned char *base) +void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) { -JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); -unsigned int cnt = JUDY_span_bytes; -unsigned char *newbase; -unsigned int off = 0; + JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); + unsigned int cnt = JUDY_span_bytes; + unsigned char *newbase; + unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN -int i; + int i; #endif do { - newbase = judy_alloc (judy, JUDY_1); + newbase = judy_alloc(judy, JUDY_1); *next = (JudySlot)newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while( i-- ) + while(i--) { *newbase++ = base[off + i]; + } #else - memcpy (newbase, base + off, JUDY_key_size); + memcpy(newbase, base + off, JUDY_key_size); newbase += JUDY_key_size; #endif next = (JudySlot *)newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while( cnt && base[off - 1] ); + } while(cnt && base[off - 1]); *next = node[-1]; - judy_free (judy, base, JUDY_span); + judy_free(judy, base, JUDY_span); } #endif // judy_cell: add string to judy array -JudySlot *judy_cell (Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_cell(Judy *judy, unsigned char *buff, unsigned int max) { -judyvalue *src = (judyvalue *)buff; -int size, idx, slot, cnt, tst; -JudySlot *next = judy->root; -judyvalue test, value; -unsigned int off = 0, start; -JudySlot *table; -JudySlot *node; -unsigned int depth = 0; -unsigned int keysize; -unsigned char *base; + judyvalue *src = (judyvalue *)buff; + int size, idx, slot, cnt, tst; + JudySlot *next = judy->root; + judyvalue test, value; + unsigned int off = 0, start; + JudySlot *table; + JudySlot *node; + unsigned int depth = 0; + unsigned int keysize; + unsigned char *base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while( *next ) { + while(*next) { #ifndef ASKITIS - if( judy->level < judy->max ) + if(judy->level < judy->max) { judy->level++; + } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch( *next & 0x07 ) { - default: - size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); - start = off; - slot = cnt; - value = 0; - - if( judy->depth ) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if( off < max ) - value |= buff[off]; - } while( ++off & JUDY_key_mask ); - - // find slot > key - - while( slot-- ) { - test = *(judyvalue *)(base + slot * keysize); + switch(*next & 0x07) { + default: + size = JudySize[*next & 0x07]; + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + size); + start = off; + slot = cnt; + value = 0; + + if(judy->depth) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if(off < max) { + value |= buff[off]; + } + } while(++off & JUDY_key_mask); + + // find slot > key + + while(slot--) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if( test <= value ) - break; - } + if(test <= value) { + break; + } + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if( test == value ) { // new key is equal to slot key - next = &node[-slot-1]; + if(test == value) { // new key is equal to slot key + next = &node[-slot - 1]; - // is this a leaf? + // is this a leaf? - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { + if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { #ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; + if(*next) { + Found++; + } else { + Inserts++; + } #endif - return next; - } + return next; + } - continue; - } + continue; + } - // if this node is not full - // open up cell after slot + // if this node is not full + // open up cell after slot - if( !node[-1] ) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot + if(!node[-1]) { + memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot + memcpy(base + slot * keysize, &value, keysize); // copy new key into slot #else - test = value; - idx = keysize; + test = value; + idx = keysize; - while( idx-- ) - base[slot * keysize + idx] = test, test >>= 8; + while(idx--) { + base[slot * keysize + idx] = test, test >>= 8; + } #endif - for( idx = 0; idx < slot; idx++ ) - node[-idx-1] = node[-idx-2];// copy tree ptrs/cells down one slot + for(idx = 0; idx < slot; idx++) { + node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot + } - node[-slot-1] = 0; // set new tree ptr/cell - next = &node[-slot-1]; + node[-slot - 1] = 0; // set new tree ptr/cell + next = &node[-slot - 1]; - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { + if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { #ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; + if(*next) { + Found++; + } else { + Inserts++; + } #endif - return next; - } + return next; + } - continue; - } + continue; + } - if( size < JudySize[JUDY_max] ) { - next = judy_promote (judy, next, slot+1, value, keysize); + if(size < JudySize[JUDY_max]) { + next = judy_promote(judy, next, slot + 1, value, keysize); - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { + if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { #ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; + if(*next) { + Found++; + } else { + Inserts++; + } #endif - return next; - } + return next; + } - continue; - } + continue; + } - // split full maximal node into JUDY_radix nodes - // loop to reprocess new insert + // split full maximal node into JUDY_radix nodes + // loop to reprocess new insert - judy_splitnode (judy, next, size, keysize, depth); + judy_splitnode(judy, next, size, keysize, depth); #ifndef ASKITIS - judy->level--; + judy->level--; #endif - off = start; - if( judy->depth ) - depth--; - continue; + off = start; + if(judy->depth) { + depth--; + } + continue; - case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(*next & JUDY_mask); // outer radix - if( judy->depth ) - slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; - else if( off < max ) - slot = buff[off++]; - else - slot = 0, off++; + if(judy->depth) { + slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; + } else if(off < max) { + slot = buff[off++]; + } else { + slot = 0, off++; + } - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; + if(judy->depth) + if(!(off & JUDY_key_mask)) { + depth++; + } - // allocate inner radix if empty + // allocate inner radix if empty - if( !table[slot >> 4] ) - table[slot >> 4] = (JudySlot)judy_alloc (judy, JUDY_radix) | JUDY_radix; + if(!table[slot >> 4]) { + table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; + } - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = (JudySlot *)(table[slot >> 4] & JUDY_mask); #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - next = &table[slot & 0x0F]; + next = &table[slot & 0x0F]; - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { // leaf? + if(!judy->depth && !slot || judy->depth && depth == judy->depth) { // leaf? #ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; + if(*next) { + Found++; + } else { + Inserts++; + } #endif - return next; - } + return next; + } - continue; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); - cnt = JUDY_span_bytes; - tst = cnt; - - if( tst > (int)(max - off) ) - tst = max - off; + case JUDY_span: + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); + cnt = JUDY_span_bytes; + tst = cnt; + + if(tst > (int)(max - off)) { + tst = max - off; + } - value = strncmp((const char *)base, (const char *)(buff + off), tst); + value = strncmp((const char *)base, (const char *)(buff + off), tst); - if( !value && tst < cnt && !base[tst] ) // leaf? - return &node[-1]; + if(!value && tst < cnt && !base[tst]) { // leaf? + return &node[-1]; + } - if( !value && tst == cnt ) { - next = &node[-1]; - off += cnt; - continue; - } + if(!value && tst == cnt) { + next = &node[-1]; + off += cnt; + continue; + } - // bust up JUDY_span node and produce JUDY_1 nodes - // then loop to reprocess insert + // bust up JUDY_span node and produce JUDY_1 nodes + // then loop to reprocess insert - judy_splitspan (judy, next, base); - judy->level--; - continue; + judy_splitspan(judy, next, base); + judy->level--; + continue; #endif } } @@ -1492,102 +1564,109 @@ unsigned char *base; // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if( off & JUDY_key_mask ) - if( judy->depth || off <= max ) { + if(off & JUDY_key_mask) + if(judy->depth || off <= max) { #else - while( off <= max ) { + while(off <= max) { #endif - base = judy_alloc (judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + base = judy_alloc(judy, JUDY_1); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - if( judy->depth ) { - value = src[depth]; + if(judy->depth) { + value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot + memcpy(base, &value, keysize); // copy new key into slot #else - while( keysize-- ) - base[keysize] = value, value >>= 8; + while(keysize--) { + base[keysize] = value, value >>= 8; + } #endif - } else { + } else { #if BYTE_ORDER != BIG_ENDIAN - while( keysize ) - if( off + keysize <= max ) - *base++ = buff[off + --keysize]; - else - base++, --keysize; + while(keysize) + if(off + keysize <= max) { + *base++ = buff[off + --keysize]; + } else { + base++, --keysize; + } #else - tst = keysize; + tst = keysize; - if( tst > (int)(max - off) ) - tst = max - off; + if(tst > (int)(max - off)) { + tst = max - off; + } - memcpy (base, buff + off, tst); + memcpy(base, buff + off, tst); #endif - } + } #ifndef ASKITIS - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; + if(judy->level < judy->max) { + judy->level++; + } + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; #endif - next = &node[-1]; + next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + off |= JUDY_key_mask; + depth++; + off++; + } // produce span nodes to consume rest of key // or judy_1 nodes if not string tree #ifndef ASKITIS - if( !judy->depth ) - while( off <= max ) { - base = judy_alloc (judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); - cnt = tst = JUDY_span_bytes; - if( tst > (int)(max - off) ) - tst = max - off; - memcpy (base, buff + off, tst); - - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off += tst; - depth++; + if(!judy->depth) + while(off <= max) { + base = judy_alloc(judy, JUDY_span); + *next = (JudySlot)base | JUDY_span; + node = (JudySlot *)(base + JudySize[JUDY_span]); + cnt = tst = JUDY_span_bytes; + if(tst > (int)(max - off)) { + tst = max - off; + } + memcpy(base, buff + off, tst); - if( !base[cnt-1] ) // done on leaf - break; - } - else - while( depth < judy->depth ) { - base = judy_alloc (judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + if(judy->level < judy->max) { + judy->level++; + } + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off += tst; + depth++; + + if(!base[cnt - 1]) { // done on leaf + break; + } + } else + while(depth < judy->depth) { + base = judy_alloc(judy, JUDY_1); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - *(judyvalue *)base = src[depth]; + *(judyvalue *)base = src[depth]; - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + if(judy->level < judy->max) { + judy->level++; + } + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off |= JUDY_key_mask; + depth++; + off++; + } #endif #ifdef ASKITIS @@ -1630,195 +1709,203 @@ typedef struct { void *next; // duplicate chain } PennySort; -void sort (FILE *infile, char *outname) +void sort(FILE *infile, char *outname) { -unsigned long long size, off, offset, part; -int ifd = fileno (infile); -char filename[512]; -PennySort *line; -JudySlot *cell; -unsigned char *inbuff; -void *judy; -FILE *out; + unsigned long long size, off, offset, part; + int ifd = fileno(infile); + char filename[512]; + PennySort *line; + JudySlot *cell; + unsigned char *inbuff; + void *judy; + FILE *out; #if defined(_WIN32) -HANDLE hndl, fm; -DWORD hiword; -FILETIME dummy[1]; -FILETIME user[1]; + HANDLE hndl, fm; + DWORD hiword; + FILETIME dummy[1]; + FILETIME user[1]; #else -struct tms buff[1]; + struct tms buff[1]; #endif -time_t start = time(NULL); + time_t start = time(NULL); - if( PennyOff + PennyKey > PennyLine ) - fprintf (stderr, "Key Offset + Key Length > Record Length\n"), exit(1); + if(PennyOff + PennyKey > PennyLine) { + fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); + } - offset = 0; - PennyPasses = 0; + offset = 0; + PennyPasses = 0; #if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize (hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if( !fm ) - fprintf (stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); - size |= (unsigned long long)hiword << 32; + hndl = (HANDLE)_get_osfhandle(ifd); + size = GetFileSize(hndl, &hiword); + fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); + if(!fm) { + fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); + } + size |= (unsigned long long)hiword << 32; #else - size = lseek (ifd, 0L, 2); + size = lseek(ifd, 0L, 2); #endif - while( offset < size ) { + while(offset < size) { #if defined(_WIN32) - part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part); - if( !inbuff ) - fprintf (stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); + part = offset + PennyMerge > size ? size - offset : PennyMerge; + inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); + if(!inbuff) { + fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); + } #else - inbuff = mmap (NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); + inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); - if( inbuff == MAP_FAILED ) - fprintf (stderr, "mmap error %d\n", errno), exit(1); + if(inbuff == MAP_FAILED) { + fprintf(stderr, "mmap error %d\n", errno), exit(1); + } - if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0 ) - fprintf (stderr, "madvise error %d\n", errno); + if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { + fprintf(stderr, "madvise error %d\n", errno); + } #endif - judy = judy_open (PennyKey, 0); + judy = judy_open(PennyKey, 0); - off = 0; + off = 0; - // build judy array from mapped input chunk + // build judy array from mapped input chunk - while( offset + off < size && off < PennyMerge ) { - line = judy_data (judy, sizeof(PennySort)); - cell = judy_cell (judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; - line->buff = inbuff + off; + while(offset + off < size && off < PennyMerge) { + line = judy_data(judy, sizeof(PennySort)); + cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); + line->next = *(void **)cell; + line->buff = inbuff + off; - *(PennySort **)cell = line; - off += PennyLine; - } + *(PennySort **)cell = line; + off += PennyLine; + } - sprintf (filename, "%s.%d", outname, PennyPasses); - out = fopen (filename, "wb"); - setvbuf (out, NULL, _IOFBF, 4096 * 1024); + sprintf(filename, "%s.%d", outname, PennyPasses); + out = fopen(filename, "wb"); + setvbuf(out, NULL, _IOFBF, 4096 * 1024); #ifndef _WIN32 - if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0 ) - fprintf (stderr, "madvise error %d\n", errno); + if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { + fprintf(stderr, "madvise error %d\n", errno); + } #endif - // write judy array in sorted order to temporary file + // write judy array in sorted order to temporary file - cell = judy_strt (judy, NULL, 0); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { - line = *(PennySort **)cell; - do fwrite (line->buff, PennyLine, 1, out); - while( line = line->next ); - } while( cell = judy_nxt (judy) ); + if(cell) do { + line = *(PennySort **)cell; + do { + fwrite(line->buff, PennyLine, 1, out); + } while(line = line->next); + } while(cell = judy_nxt(judy)); #if defined(_WIN32) - UnmapViewOfFile (inbuff); + UnmapViewOfFile(inbuff); #else - munmap (inbuff, PennyMerge); -#endif - judy_close (judy); - offset += off; - fflush (out); - fclose (out); - PennyPasses++; - } - fprintf (stderr, "End Sort %d secs", time(NULL) - start); + munmap(inbuff, PennyMerge); +#endif + judy_close(judy); + offset += off; + fflush(out); + fclose(out); + PennyPasses++; + } + fprintf(stderr, "End Sort %d secs", time(NULL) - start); #if defined(_WIN32) - CloseHandle (fm); - GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long*)user / 10000000; + CloseHandle(fm); + GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); + PennySortTime = *(unsigned long long *)user / 10000000; #else - times (buff); - PennySortTime = buff->tms_utime/100; + times(buff); + PennySortTime = buff->tms_utime / 100; #endif - fprintf (stderr, " Cpu %d\n", PennySortTime); + fprintf(stderr, " Cpu %d\n", PennySortTime); } -int merge (FILE *out, char *outname) +int merge(FILE *out, char *outname) { -time_t start = time(NULL); -char filename[512]; -JudySlot *cell; -unsigned int nxt, idx; -unsigned char **line; -unsigned int *next; -void *judy; -FILE **in; + time_t start = time(NULL); + char filename[512]; + JudySlot *cell; + unsigned int nxt, idx; + unsigned char **line; + unsigned int *next; + void *judy; + FILE **in; - next = calloc (PennyPasses + 1, sizeof(unsigned int)); - line = calloc (PennyPasses, sizeof(void *)); - in = calloc (PennyPasses, sizeof(void *)); + next = calloc(PennyPasses + 1, sizeof(unsigned int)); + line = calloc(PennyPasses, sizeof(void *)); + in = calloc(PennyPasses, sizeof(void *)); - judy = judy_open (PennyKey, 0); + judy = judy_open(PennyKey, 0); // initialize merge with one record from each temp file - for( idx = 0; idx < PennyPasses; idx++ ) { - sprintf (filename, "%s.%d", outname, idx); - in[idx] = fopen (filename, "rb"); - line[idx] = malloc (PennyLine); - setvbuf (in[idx], NULL, _IOFBF, 4096 * 1024); - fread (line[idx], PennyLine, 1, in[idx]); - cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); + for(idx = 0; idx < PennyPasses; idx++) { + sprintf(filename, "%s.%d", outname, idx); + in[idx] = fopen(filename, "rb"); + line[idx] = malloc(PennyLine); + setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); + fread(line[idx], PennyLine, 1, in[idx]); + cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; } // output records, replacing smallest each time - while( cell = judy_strt (judy, NULL, 0) ) { + while(cell = judy_strt(judy, NULL, 0)) { nxt = *(unsigned int *)cell; - judy_del (judy); + judy_del(judy); // process duplicates - while( idx = nxt ) { + while(idx = nxt) { nxt = next[idx--]; - fwrite (line[idx], PennyLine, 1, out); + fwrite(line[idx], PennyLine, 1, out); - if( fread (line[idx], PennyLine, 1, in[idx]) ) { - cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); + if(fread(line[idx], PennyLine, 1, in[idx])) { + cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; - } else + } else { next[idx + 1] = 0; + } } } - for( idx = 0; idx < PennyPasses; idx++ ) { - fclose (in[idx]); - free (line[idx]); + for(idx = 0; idx < PennyPasses; idx++) { + fclose(in[idx]); + free(line[idx]); } - free (line); - free (next); - free (in); + free(line); + free(next); + free(in); - fprintf (stderr, "End Merge %d secs", time(NULL) - start); + fprintf(stderr, "End Merge %d secs", time(NULL) - start); #ifdef _WIN32 { - FILETIME dummy[1]; - FILETIME user[1]; - GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long*)user / 10000000; + FILETIME dummy[1]; + FILETIME user[1]; + GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); + PennyMergeTime = *(unsigned long long *)user / 10000000; } #else { - struct tms buff[1]; - times (buff); - PennyMergeTime = buff->tms_utime/100; + struct tms buff[1]; + times(buff); + PennyMergeTime = buff->tms_utime / 100; } #endif - fprintf (stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close (judy); - fflush (out); - fclose (out); + fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); + judy_close(judy); + fflush(out); + fclose(out); return 0; } @@ -1851,71 +1938,78 @@ typedef struct timeval timer; // Also, the file to search judy is hardcoded to skew1_1. -int main (int argc, char **argv) +int main(int argc, char **argv) { -unsigned char buff[1024]; -JudySlot max = 0; -JudySlot *cell; -FILE *in, *out; -void *judy; -unsigned int len; -unsigned int idx; + unsigned char buff[1024]; + JudySlot max = 0; + JudySlot *cell; + FILE *in, *out; + void *judy; + unsigned int len; + unsigned int idx; #ifdef ASKITIS -char *askitis; -int prev, off; -float insert_real_time=0.0; -float search_real_time=0.0; -int size; + char *askitis; + int prev, off; + float insert_real_time = 0.0; + float search_real_time = 0.0; + int size; #if !defined(_WIN32) -timer start, stop; + timer start, stop; #else -time_t start[1], stop[1]; + time_t start[1], stop[1]; #endif #endif - if( argc > 1 ) - in = fopen (argv[1], "rb"); - else + if(argc > 1) { + in = fopen(argv[1], "rb"); + } else { in = stdin; + } - if( argc > 2 ) - out = fopen (argv[2], "wb"); - else + if(argc > 2) { + out = fopen(argv[2], "wb"); + } else { out = stdout; + } - setvbuf (out, NULL, _IOFBF, 4096 * 1024); + setvbuf(out, NULL, _IOFBF, 4096 * 1024); - if( !in ) - fprintf (stderr, "unable to open input file\n"); + if(!in) { + fprintf(stderr, "unable to open input file\n"); + } - if( !out ) - fprintf (stderr, "unable to open output file\n"); + if(!out) { + fprintf(stderr, "unable to open output file\n"); + } - if( argc > 6 ) + if(argc > 6) { PennyRecs = atoi(argv[6]); + } - if( argc > 5 ) + if(argc > 5) { PennyOff = atoi(argv[5]); + } - if( argc > 4 ) + if(argc > 4) { PennyLine = atoi(argv[4]); + } PennyMerge = (unsigned long long)PennyLine * PennyRecs; - if( argc > 3 ) { + if(argc > 3) { PennyKey = atoi(argv[3]); - sort (in, argv[2]); - return merge (out, argv[2]); + sort(in, argv[2]); + return merge(out, argv[2]); } #ifdef ASKITIS - judy = judy_open (1024, 0); + judy = judy_open(1024, 0); // build judy array - size = lseek (fileno(in), 0L, 2); + size = lseek(fileno(in), 0L, 2); askitis = malloc(size); - lseek (fileno(in), 0L, 0); - read (fileno(in), askitis,size); + lseek(fileno(in), 0L, 0); + read(fileno(in), askitis, size); prev = 0; // naskitis.com: // Start the timer. @@ -1926,29 +2020,29 @@ time_t start[1], stop[1]; time(start); #endif - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *(judy_cell (judy, askitis+prev, off - prev)) += 1; // count instances of string - prev = off + 1; - } + for(off = 0; off < size; off++) + if(askitis[off] == '\n') { + *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * (stop.tv_usec - start.tv_usec ); - insert_real_time = insert_real_time/1000.0; + insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); + insert_real_time = insert_real_time / 1000.0; #else - time (stop); + time(stop); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free (askitis); + free(askitis); fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem/1000000., "Time to insert:", insert_real_time); + "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); @@ -1958,13 +2052,14 @@ time_t start[1], stop[1]; Found = 0; // search judy array - if( in = freopen ("skew1_1", "rb", in) ) - size = lseek (fileno(in), 0L, 2); - else + if(in = freopen("skew1_1", "rb", in)) { + size = lseek(fileno(in), 0L, 2); + } else { exit(0); + } askitis = malloc(size); - lseek (fileno(in), 0L, 0); - read (fileno(in), askitis,size); + lseek(fileno(in), 0L, 0); + read(fileno(in), askitis, size); prev = 0; #if !defined(_WIN32) @@ -1973,19 +2068,19 @@ time_t start[1], stop[1]; time(start); #endif - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *judy_cell (judy, askitis+prev, off - prev) += 1; - prev = off + 1; - } + for(off = 0; off < size; off++) + if(askitis[off] == '\n') { + *judy_cell(judy, askitis + prev, off - prev) += 1; + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 - * (stop.tv_usec - start.tv_usec ); - search_real_time = search_real_time/1000.0; + search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 + * (stop.tv_usec - start.tv_usec); + search_real_time = search_real_time / 1000.0; #else time(stop); search_real_time = *stop - *start; @@ -1994,88 +2089,91 @@ time_t start[1], stop[1]; // naskitis.com: // To do: report a count on the number of strings found. - fprintf(stderr,"\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem/1000000., "Time to search:", search_real_time); + fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); exit(0); #endif #ifdef HEXKEYS - judy = judy_open (1024, 16/JUDY_key_size); + judy = judy_open(1024, 16 / JUDY_key_size); - while( fgets((char *)buff, sizeof(buff), in) ) { - judyvalue key[16/JUDY_key_size]; - if( len = strlen((const char *)buff) ) - buff[--len] = 0; // remove LF + while(fgets((char *)buff, sizeof(buff), in)) { + judyvalue key[16 / JUDY_key_size]; + if(len = strlen((const char *)buff)) { + buff[--len] = 0; // remove LF + } #if JUDY_key_size == 4 - key[3] = strtoul (buff + 24, NULL, 16); + key[3] = strtoul(buff + 24, NULL, 16); buff[24] = 0; - key[2] = strtoul (buff + 16, NULL, 16); + key[2] = strtoul(buff + 16, NULL, 16); buff[16] = 0; - key[1] = strtoul (buff + 8, NULL, 16); + key[1] = strtoul(buff + 8, NULL, 16); buff[8] = 0; - key[0] = strtoul (buff, NULL, 16); + key[0] = strtoul(buff, NULL, 16); #else - key[1] = strtoull (buff + 16, NULL, 16); + key[1] = strtoull(buff + 16, NULL, 16); buff[16] = 0; - key[0] = strtoull (buff, NULL, 16); + key[0] = strtoull(buff, NULL, 16); #endif - *(judy_cell (judy, (void *)key, 0)) += 1; // count instances of string + *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt (judy, NULL, 0); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { - judyvalue key[16/JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates + if(cell) do { + judyvalue key[16 / JUDY_key_size]; + len = judy_key(judy, (void *)key, 0); + for(idx = 0; idx < *cell; idx++) { // spit out duplicates #if JUDY_key_size == 4 - fprintf (out, "%.8X", key[0]); - fprintf (out, "%.8X", key[1]); - fprintf (out, "%.8X", key[2]); - fprintf (out, "%.8X", key[3]); + fprintf(out, "%.8X", key[0]); + fprintf(out, "%.8X", key[1]); + fprintf(out, "%.8X", key[2]); + fprintf(out, "%.8X", key[3]); #else - fprintf (out, "%.16llX", key[0]); - fprintf (out, "%.16llX", key[1]); + fprintf(out, "%.16llX", key[0]); + fprintf(out, "%.16llX", key[1]); #endif - fputc('\n', out); - } - } while( cell = judy_nxt (judy) ); + fputc('\n', out); + } + } while(cell = judy_nxt(judy)); #else - judy = judy_open (1024, 0); + judy = judy_open(1024, 0); - while( fgets((char *)buff, sizeof(buff), in) ) { - if( len = strlen((const char *)buff) ) - buff[--len] = 0; // remove LF - *(judy_cell (judy, buff, len)) += 1; // count instances of string + while(fgets((char *)buff, sizeof(buff), in)) { + if(len = strlen((const char *)buff)) { + buff[--len] = 0; // remove LF + } + *(judy_cell(judy, buff, len)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt (judy, NULL, 0); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { - len = judy_key(judy, buff, sizeof(buff)); - for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); - } - } while( cell = judy_nxt (judy) ); + if(cell) do { + len = judy_key(judy, buff, sizeof(buff)); + for(idx = 0; idx < *cell; idx++) { // spit out duplicates + fwrite(buff, len, 1, out); + fputc('\n', out); + } + } while(cell = judy_nxt(judy)); #endif #if 0 // test deletion all the way to an empty tree - if( cell = judy_prv (judy) ) - do max -= *cell; - while( cell = judy_del (judy) ); + if(cell = judy_prv(judy)) + do { + max -= *cell; + } while(cell = judy_del(judy)); - assert (max == 0); + assert(max == 0); #endif judy_close(judy); return 0; diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index 45e0cba44..b9f314a0a 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -70,24 +70,25 @@ extern unsigned int MaxMem; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort( char * msg ) { - fprintf( stderr, "%s\n", msg ); - exit( 1 ); +void judy_abort(char *msg) +{ + fprintf(stderr, "%s\n", msg); + exit(1); } #endif int JudySize[] = { - ( JUDY_slot_size * 16 ), // JUDY_radix node size - ( JUDY_slot_size + JUDY_key_size ), // JUDY_1 node size - ( 2 * JUDY_slot_size + 2 * JUDY_key_size ), - ( 4 * JUDY_slot_size + 4 * JUDY_key_size ), - ( 8 * JUDY_slot_size + 8 * JUDY_key_size ), - ( 16 * JUDY_slot_size + 16 * JUDY_key_size ), - ( 32 * JUDY_slot_size + 32 * JUDY_key_size ), + (JUDY_slot_size * 16), // JUDY_radix node size + (JUDY_slot_size + JUDY_key_size), // JUDY_1 node size + (2 * JUDY_slot_size + 2 * JUDY_key_size), + (4 * JUDY_slot_size + 4 * JUDY_key_size), + (8 * JUDY_slot_size + 8 * JUDY_key_size), + (16 * JUDY_slot_size + 16 * JUDY_key_size), + (32 * JUDY_slot_size + 32 * JUDY_key_size), #ifndef ASKITIS - ( JUDY_span_bytes + JUDY_slot_size ) + (JUDY_span_bytes + JUDY_slot_size) #else - ( 64 * JUDY_slot_size + 64 * JUDY_key_size ) + (64 * JUDY_slot_size + 64 * JUDY_key_size) #endif }; @@ -102,27 +103,28 @@ judyvalue JudyMask[9] = { // call with max key size // and Integer tree depth. -Judy * judy_open( unsigned int max, unsigned int depth ) { - JudySeg * seg; - Judy * judy; +Judy *judy_open(unsigned int max, unsigned int depth) +{ + JudySeg *seg; + Judy *judy; unsigned int amt; max++; // allow for zero terminator on keys - if( ( seg = malloc( JUDY_seg ) ) ) { + if((seg = malloc(JUDY_seg))) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort( "No virtual memory" ); + judy_abort("No virtual memory"); #else return NULL; #endif } - amt = sizeof( Judy ) + max * sizeof( JudyStack ); + amt = sizeof(Judy) + max * sizeof(JudyStack); - if( amt & ( JUDY_cache_line - 1 ) ) { + if(amt & (JUDY_cache_line - 1)) { amt |= JUDY_cache_line - 1, amt++; } @@ -130,90 +132,92 @@ Judy * judy_open( unsigned int max, unsigned int depth ) { MaxMem += JUDY_seg; #endif - seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); + seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); seg->next -= amt; - judy = ( Judy * )( ( unsigned char * )seg + seg->next ); - memset( judy, 0, amt ); + judy = (Judy *)((unsigned char *)seg + seg->next); + memset(judy, 0, amt); judy->depth = depth; judy->seg = seg; judy->max = max; return judy; } -void judy_close( Judy * judy ) { - JudySeg * seg, *nxt = judy->seg; +void judy_close(Judy *judy) +{ + JudySeg *seg, *nxt = judy->seg; - while( ( seg = nxt ) ) { - nxt = seg->seg, free( seg ); + while((seg = nxt)) { + nxt = seg->seg, free(seg); } } // allocate judy node -void * judy_alloc( Judy * judy, unsigned int type ) { +void *judy_alloc(Judy *judy, unsigned int type) +{ unsigned int amt, idx, min; - JudySeg * seg; - void ** block; - void ** rtn; + JudySeg *seg; + void **block; + void **rtn; - if( !judy->seg ) + if(!judy->seg) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort( "illegal allocation from judy clone" ); + judy_abort("illegal allocation from judy clone"); #else return NULL; #endif - if( type == JUDY_radix ) { + if(type == JUDY_radix) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if( type == JUDY_span ) { + if(type == JUDY_span) { type = JUDY_span_equiv; } #endif amt = JudySize[type]; - if( amt & 0x07 ) { + if(amt & 0x07) { amt |= 0x07, amt += 1; } // see if free block is already available - if( ( block = judy->reuse[type] ) ) { + if((block = judy->reuse[type])) { judy->reuse[type] = *block; - memset( block, 0, amt ); - return ( void * )block; + memset(block, 0, amt); + return (void *)block; } // break down available larger block // for reuse into smaller blocks - if( type >= JUDY_1 ) - for( idx = type; idx++ < JUDY_max; ) - if( (block = judy->reuse[idx]) ) { + if(type >= JUDY_1) + for(idx = type; idx++ < JUDY_max;) + if((block = judy->reuse[idx])) { judy->reuse[idx] = *block; - while( idx-- > type ) { - judy->reuse[idx] = block + JudySize[idx] / sizeof( void * ); - block[JudySize[idx] / sizeof( void * )] = 0; + while(idx-- > type) { + judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); + block[JudySize[idx] / sizeof(void *)] = 0; } - memset( block, 0, amt ); - return ( void * )block; + memset(block, 0, amt); + return (void *)block; } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if( judy->seg->next < min + sizeof( *seg ) ) { - if( ( seg = malloc( JUDY_seg ) ) ) { + if(judy->seg->next < min + sizeof(*seg)) { + if((seg = malloc(JUDY_seg))) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); + seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort( "Out of virtual memory" ); + judy_abort("Out of virtual memory"); #else return NULL; #endif @@ -227,45 +231,45 @@ void * judy_alloc( Judy * judy, unsigned int type ) { // generate additional free blocks // to fill up to cache line size - rtn = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - amt ); + rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); - for( idx = type; amt & ( JUDY_cache_line - 1 ); amt <<= 1 ) { - block = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - 2 * amt ); + for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { + block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset( rtn, 0, JudySize[type] ); - return ( void * )rtn; + memset(rtn, 0, JudySize[type]); + return (void *)rtn; } -void * judy_data( Judy * judy, unsigned int amt ) +void *judy_data(Judy *judy, unsigned int amt) { - JudySeg * seg; - void * block; + JudySeg *seg; + void *block; - if( !judy->seg ) + if(!judy->seg) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort( "illegal allocation from judy clone" ); + judy_abort("illegal allocation from judy clone"); #else return NULL; #endif - if( amt & ( JUDY_cache_line - 1 ) ) { - amt |= ( JUDY_cache_line - 1 ), amt += 1; + if(amt & (JUDY_cache_line - 1)) { + amt |= (JUDY_cache_line - 1), amt += 1; } - if( judy->seg->next < amt + sizeof( *seg ) ) { - if( ( seg = malloc( JUDY_seg ) ) ) { + if(judy->seg->next < amt + sizeof(*seg)) { + if((seg = malloc(JUDY_seg))) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); + seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort( "Out of virtual memory" ); + judy_abort("Out of virtual memory"); #else return NULL; #endif @@ -278,65 +282,68 @@ void * judy_data( Judy * judy, unsigned int amt ) judy->seg->next -= amt; - block = ( void * )( ( unsigned char * )judy->seg + judy->seg->next ); - memset( block, 0, amt ); + block = (void *)((unsigned char *)judy->seg + judy->seg->next); + memset(block, 0, amt); return block; } -Judy * judy_clone( Judy * judy ) { - Judy * clone; +Judy *judy_clone(Judy *judy) +{ + Judy *clone; unsigned int amt; - amt = sizeof( Judy ) + judy->max * sizeof( JudyStack ); - clone = judy_data( judy, amt ); - memcpy( clone, judy, amt ); + amt = sizeof(Judy) + judy->max * sizeof(JudyStack); + clone = judy_data(judy, amt); + memcpy(clone, judy, amt); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free( Judy * judy, void * block, int type ) { - if( type == JUDY_radix ) { +void judy_free(Judy *judy, void *block, int type) +{ + if(type == JUDY_radix) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if( type == JUDY_span ) { + if(type == JUDY_span) { type = JUDY_span_equiv; } #endif - *( ( void ** )( block ) ) = judy->reuse[type]; - judy->reuse[type] = ( void ** )block; + *((void **)(block)) = judy->reuse[type]; + judy->reuse[type] = (void **)block; return; } // assemble key from current path -unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { - judyvalue * dest = ( judyvalue * )buff; +unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) +{ + judyvalue *dest = (judyvalue *)buff; unsigned int len = 0, idx = 0, depth; int slot, off, type; judyvalue value; - unsigned char * base; + unsigned char *base; int keysize; - if( judy->depth ) { + if(judy->depth) { max = judy->depth * JUDY_key_size; } else { max--; // leave room for zero terminator } - while( len < max && ++idx <= judy->level ) { + while(len < max && ++idx <= judy->level) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if( judy->depth ) - if( !( len & JUDY_key_mask ) ) { + if(judy->depth) + if(!(len & JUDY_key_mask)) { dest[depth] = 0; } - switch( type ) { + switch(type) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -346,16 +353,16 @@ unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - ( judy->stack[idx].off & JUDY_key_mask ); - base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); + keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - if( judy->depth ) { - value = *( judyvalue * )( base + slot * keysize ); + if(judy->depth) { + value = *(judyvalue *)(base + slot * keysize); value &= JudyMask[keysize]; dest[depth++] |= value; len += keysize; - if( depth < judy->depth ) { + if(depth < judy->depth) { continue; } @@ -365,15 +372,15 @@ unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { #if BYTE_ORDER != BIG_ENDIAN off = keysize; - while( off-- && len < max ) - if( (buff[len] = base[slot * keysize + off]) ) { + while(off-- && len < max) + if((buff[len] = base[slot * keysize + off])) { len++; } else { break; } #else - for( off = 0; off < keysize && len < max; off++ ) - if( buff[len] = base[slot * keysize + off] ) { + for(off = 0; off < keysize && len < max; off++) + if(buff[len] = base[slot * keysize + off]) { len++; } else { break; @@ -382,30 +389,30 @@ unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { continue; case JUDY_radix: - if( judy->depth ) { - dest[depth] |= ( judyvalue )slot << ( JUDY_key_size - ( ++len & JUDY_key_mask ) ) * 8; - if( !( len & JUDY_key_mask ) ) { + if(judy->depth) { + dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; + if(!(len & JUDY_key_mask)) { depth++; } - if( depth < judy->depth ) { + if(depth < judy->depth) { continue; } return len; } - if( !slot ) { + if(!slot) { break; } - buff[len++] = ( unsigned char )slot; + buff[len++] = (unsigned char)slot; continue; #ifndef ASKITIS case JUDY_span: - base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) - if( len < max ) { + for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) + if(len < max) { buff[len++] = base[slot]; } continue; @@ -418,24 +425,25 @@ unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { // find slot & setup cursor -JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ) { - judyvalue * src = ( judyvalue * )buff; +JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) +{ + judyvalue *src = (judyvalue *)buff; int slot, size, keysize, tst, cnt; JudySlot next = *judy->root; judyvalue value, test = 0; - JudySlot * table; - JudySlot * node; + JudySlot *table; + JudySlot *node; unsigned int depth = 0; unsigned int off = 0; - unsigned char * base; + unsigned char *base; #ifndef ASKITIS judy->level = 0; #endif - while( next ) { + while(next) { #ifndef ASKITIS - if( judy->level < judy->max ) { + if(judy->level < judy->max) { judy->level++; } @@ -444,7 +452,7 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max #endif size = JudySize[next & 0x07]; - switch( next & 0x07 ) { + switch(next & 0x07) { case JUDY_1: case JUDY_2: @@ -455,14 +463,14 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max #ifdef ASKITIS case JUDY_64: #endif - base = ( unsigned char * )( next & JUDY_mask ); - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - cnt = size / ( sizeof( JudySlot ) + keysize ); + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); slot = cnt; value = 0; - if( judy->depth ) { + if(judy->depth) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -470,32 +478,32 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max } else do { value <<= 8; - if( off < max ) { + if(off < max) { value |= buff[off]; } - } while( ++off & JUDY_key_mask ); + } while(++off & JUDY_key_mask); // find slot > key - while( slot-- ) { - test = *( judyvalue * )( base + slot * keysize ); + while(slot--) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * ( JUDY_key_size - keysize ); + test >>= 8 * (JUDY_key_size - keysize); #else test &= JudyMask[keysize]; #endif - if( test <= value ) { + if(test <= value) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if( test == value ) { + if(test == value) { // is this a leaf? - if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { + if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { return &node[-slot - 1]; } @@ -506,11 +514,11 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max return NULL; case JUDY_radix: - table = ( JudySlot * )( next & JUDY_mask ); // outer radix + table = (JudySlot *)(next & JUDY_mask); // outer radix - if( judy->depth ) { - slot = ( src[depth] >> ( (( JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; - } else if( off < max ) { + if(judy->depth) { + slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; + } else if(off < max) { slot = buff[off++]; } else { slot = 0; @@ -520,19 +528,19 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max judy->stack[judy->level].slot = slot; #endif - if( ( next = table[slot >> 4] ) ) { - table = ( JudySlot * )( next & JUDY_mask ); // inner radix + if((next = table[slot >> 4])) { + table = (JudySlot *)(next & JUDY_mask); // inner radix } else { return NULL; } - if( judy->depth ) - if( !( off & JUDY_key_mask ) ) { + if(judy->depth) + if(!(off & JUDY_key_mask)) { depth++; } - if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? - if( table[slot & 0x0F] ) { // occupied? + if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? + if(table[slot & 0x0F]) { // occupied? return &table[slot & 0x0F]; } else { return NULL; @@ -544,18 +552,18 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max #ifndef ASKITIS case JUDY_span: - node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); - base = ( unsigned char * )( next & JUDY_mask ); + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); cnt = tst = JUDY_span_bytes; - if( tst > ( int )( max - off ) ) { + if(tst > (int)(max - off)) { tst = max - off; } - value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); - if( !value && tst < cnt && !base[tst] ) { // leaf? + value = strncmp((const char *)base, (const char *)(buff + off), tst); + if(!value && tst < cnt && !base[tst]) { // leaf? return &node[-1]; } - if( !value && tst == cnt ) { + if(!value && tst == cnt) { next = node[-1]; off += cnt; continue; @@ -570,62 +578,63 @@ JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max // promote full nodes to next larger size -JudySlot * judy_promote( Judy * judy, JudySlot * next, int idx, judyvalue value, int keysize ) { - unsigned char * base = ( unsigned char * )( *next & JUDY_mask ); +JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) +{ + unsigned char *base = (unsigned char *)(*next & JUDY_mask); int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif - JudySlot * newnode, *node; - JudySlot * result; - unsigned char * newbase; + JudySlot *newnode, *node; + JudySlot *result; + unsigned char *newbase; unsigned int type; - type = ( *next & 0x07 ) + 1; - node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[type - 1] ); - oldcnt = JudySize[type - 1] / ( sizeof( JudySlot ) + keysize ); - newcnt = JudySize[type] / ( sizeof( JudySlot ) + keysize ); + type = (*next & 0x07) + 1; + node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); + oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); + newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); // promote node to next larger size - newbase = judy_alloc( judy, type ); - newnode = ( JudySlot * )( newbase + JudySize[type] ); - *next = ( JudySlot )newbase | type; + newbase = judy_alloc(judy, type); + newnode = (JudySlot *)(newbase + JudySize[type]); + *next = (JudySlot)newbase | type; // open up slot at idx - memcpy( newbase + ( newcnt - oldcnt - 1 ) * keysize, base, idx * keysize ); // copy keys + memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys - for( slot = 0; slot < idx; slot++ ) { - newnode[-( slot + newcnt - oldcnt )] = node[-( slot + 1 )]; // copy ptr + for(slot = 0; slot < idx; slot++) { + newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr } // fill in new node #if BYTE_ORDER != BIG_ENDIAN - memcpy( newbase + ( idx + newcnt - oldcnt - 1 ) * keysize, &value, keysize ); // copy key + memcpy(newbase + (idx + newcnt - oldcnt - 1) * keysize, &value, keysize); // copy key #else i = keysize; - while( i-- ) { - newbase[( idx + newcnt - oldcnt - 1 ) * keysize + i] = value, value >>= 8; + while(i--) { + newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; } #endif - result = &newnode[-( idx + newcnt - oldcnt )]; + result = &newnode[-(idx + newcnt - oldcnt)]; // copy rest of old node - memcpy( newbase + ( idx + newcnt - oldcnt ) * keysize, base + ( idx * keysize ), ( oldcnt - slot ) * keysize ); // copy keys + memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys - for( ; slot < oldcnt; slot++ ) { - newnode[-( slot + newcnt - oldcnt + 1 )] = node[-( slot + 1 )]; // copy ptr + for(; slot < oldcnt; slot++) { + newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free( judy, ( void ** )base, type - 1 ); + judy_free(judy, (void **)base, type - 1); return result; } @@ -633,25 +642,26 @@ JudySlot * judy_promote( Judy * judy, JudySlot * next, int idx, judyvalue value, // make node with slot - start entries // moving key over one offset -void judy_radix( Judy * judy, JudySlot * radix, unsigned char * old, int start, int slot, int keysize, unsigned char key, unsigned int depth ) { +void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) +{ int size, idx, cnt = slot - start, newcnt; - JudySlot * node, *oldnode; + JudySlot *node, *oldnode; unsigned int type = JUDY_1 - 1; - JudySlot * table; - unsigned char * base; + JudySlot *table; + unsigned char *base; // if necessary, setup inner radix node - if( !( table = ( JudySlot * )( radix[key >> 4] & JUDY_mask ) ) ) { - table = judy_alloc( judy, JUDY_radix ); - radix[key >> 4] = ( JudySlot )table | JUDY_radix; + if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { + table = judy_alloc(judy, JUDY_radix); + radix[key >> 4] = (JudySlot)table | JUDY_radix; } - oldnode = ( JudySlot * )( old + JudySize[JUDY_max] ); + oldnode = (JudySlot *)(old + JudySize[JUDY_max]); // is this slot a leaf? - if( (!judy->depth && ( !key || !keysize )) || (judy->depth && !keysize && depth == judy->depth) ) { + if((!judy->depth && (!key || !keysize)) || (judy->depth && !keysize && depth == judy->depth)) { table[key & 0x0F] = oldnode[-start - 1]; return; } @@ -661,80 +671,82 @@ void judy_radix( Judy * judy, JudySlot * radix, unsigned char * old, int start, do { type++; size = JudySize[type]; - newcnt = size / ( sizeof( JudySlot ) + keysize ); - } while( cnt > newcnt && type < JUDY_max ); + newcnt = size / (sizeof(JudySlot) + keysize); + } while(cnt > newcnt && type < JUDY_max); // store new node pointer in inner table - base = judy_alloc( judy, type ); - node = ( JudySlot * )( base + size ); - table[key & 0x0F] = ( JudySlot )base | type; + base = judy_alloc(judy, type); + node = (JudySlot *)(base + size); + table[key & 0x0F] = (JudySlot)base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for( idx = 0; idx < cnt; idx++ ) { + for(idx = 0; idx < cnt; idx++) { #if BYTE_ORDER != BIG_ENDIAN - memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ), keysize ); + memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); #else - memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ) + 1, keysize ); + memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); #endif - node[-( newcnt - idx )] = oldnode[-( start + cnt - idx )]; + node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; } } // decompose full node to radix nodes -void judy_splitnode( Judy * judy, JudySlot * next, unsigned int size, unsigned int keysize, unsigned int depth ) { +void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) +{ int cnt, slot, start = 0; unsigned int key = 0x0100, nxt; - JudySlot * newradix; - unsigned char * base; + JudySlot *newradix; + unsigned char *base; - base = ( unsigned char * )( *next & JUDY_mask ); - cnt = size / ( sizeof( JudySlot ) + keysize ); + base = (unsigned char *)(*next & JUDY_mask); + cnt = size / (sizeof(JudySlot) + keysize); // allocate outer judy_radix node - newradix = judy_alloc( judy, JUDY_radix ); - *next = ( JudySlot )newradix | JUDY_radix; + newradix = judy_alloc(judy, JUDY_radix); + *next = (JudySlot)newradix | JUDY_radix; - for( slot = 0; slot < cnt; slot++ ) { + for(slot = 0; slot < cnt; slot++) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if( key > 0xFF ) { + if(key > 0xFF) { key = nxt; } - if( nxt == key ) { + if(nxt == key) { continue; } // decompose portion of old node into radix nodes - judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); + judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); start = slot; key = nxt; } - judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); - judy_free( judy, ( void ** )base, JUDY_max ); + judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_free(judy, (void **)base, JUDY_max); } // return first leaf -JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { - JudySlot * table, *inner; +JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +{ + JudySlot *table, *inner; unsigned int keysize, size; - JudySlot * node; + JudySlot *node; int slot, cnt; - unsigned char * base; + unsigned char *base; - while( next ) { - if( judy->level < judy->max ) { + while(next) { + if(judy->level < judy->max) { judy->level++; } @@ -742,7 +754,7 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch( next & 0x07 ) { + switch(next & 0x07) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -752,43 +764,43 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); - base = ( unsigned char * )( next & JUDY_mask ); - cnt = size / ( sizeof( JudySlot ) + keysize ); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + cnt = size / (sizeof(JudySlot) + keysize); - for( slot = 0; slot < cnt; slot++ ) - if( node[-slot - 1] ) { + for(slot = 0; slot < cnt; slot++) + if(node[-slot - 1]) { break; } judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) { + if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) { return &node[-slot - 1]; } #else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) { + if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { return &node[-slot - 1]; } #endif next = node[-slot - 1]; - off = ( off | JUDY_key_mask ) + 1; + off = (off | JUDY_key_mask) + 1; continue; case JUDY_radix: off++; - if( judy->depth ) - if( !( off & JUDY_key_mask ) ) { + if(judy->depth) + if(!(off & JUDY_key_mask)) { depth++; } - table = ( JudySlot * )( next & JUDY_mask ); - for( slot = 0; slot < 256; slot++ ) - if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { - if( ( next = inner[slot & 0x0F] ) ) { + table = (JudySlot *)(next & JUDY_mask); + for(slot = 0; slot < 256; slot++) + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if((next = inner[slot & 0x0F])) { judy->stack[judy->level].slot = slot; - if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { + if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { return &inner[slot & 0x0F]; } else { break; @@ -800,10 +812,10 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in continue; #ifndef ASKITIS case JUDY_span: - node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); - base = ( unsigned char * )( next & JUDY_mask ); + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) { // leaf node? + if(!base[cnt - 1]) { // leaf node? return &node[-1]; } next = node[-1]; @@ -817,22 +829,23 @@ JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned in // return last leaf cell pointer -JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { - JudySlot * table, *inner; +JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +{ + JudySlot *table, *inner; unsigned int keysize, size; - JudySlot * node; + JudySlot *node; int slot, cnt; - unsigned char * base; + unsigned char *base; - while( next ) { - if( judy->level < judy->max ) { + while(next) { + if(judy->level < judy->max) { judy->level++; } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch( next & 0x07 ) { + switch(next & 0x07) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -842,16 +855,16 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - slot = size / ( sizeof( JudySlot ) + keysize ); - base = ( unsigned char * )( next & JUDY_mask ); - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + keysize = JUDY_key_size - (off & JUDY_key_mask); + slot = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) + if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) #else - if( (!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth ) + if((!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth) #endif return &node[-slot - 1]; @@ -860,19 +873,19 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int continue; case JUDY_radix: - table = ( JudySlot * )( next & JUDY_mask ); + table = (JudySlot *)(next & JUDY_mask); off++; - if( judy->depth ) - if( !( off & JUDY_key_mask ) ) { + if(judy->depth) + if(!(off & JUDY_key_mask)) { depth++; } - for( slot = 256; slot--; ) { + for(slot = 256; slot--;) { judy->stack[judy->level].slot = slot; - if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { - if( ( next = inner[slot & 0x0F] ) ) { - if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if((next = inner[slot & 0x0F])) { + if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { return &inner[0]; } else { break; @@ -886,10 +899,10 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int #ifndef ASKITIS case JUDY_span: - node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); - base = ( unsigned char * )( next & JUDY_mask ); + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) { // leaf node? + if(!base[cnt - 1]) { // leaf node? return &node[-1]; } next = node[-1]; @@ -903,35 +916,37 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int // judy_end: return last entry -JudySlot * judy_end( Judy * judy ) { +JudySlot *judy_end(Judy *judy) +{ judy->level = 0; - return judy_last( judy, *judy->root, 0, 0 ); + return judy_last(judy, *judy->root, 0, 0); } // judy_nxt: return next entry -JudySlot * judy_nxt( Judy * judy ) { - JudySlot * table, *inner; +JudySlot *judy_nxt(Judy *judy) +{ + JudySlot *table, *inner; int slot, size, cnt; - JudySlot * node; + JudySlot *node; JudySlot next; unsigned int keysize; - unsigned char * base; + unsigned char *base; unsigned int depth; unsigned int off; - if( !judy->level ) { - return judy_first( judy, *judy->root, 0, 0 ); + if(!judy->level) { + return judy_first(judy, *judy->root, 0, 0); } - while( judy->level ) { + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; - keysize = JUDY_key_size - ( off & JUDY_key_mask ); + keysize = JUDY_key_size - (off & JUDY_key_mask); size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch( next & 0x07 ) { + switch(next & 0x07) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -941,40 +956,40 @@ JudySlot * judy_nxt( Judy * judy ) { #ifdef ASKITIS case JUDY_64: #endif - cnt = size / ( sizeof( JudySlot ) + keysize ); - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); - base = ( unsigned char * )( next & JUDY_mask ); - if( ++slot < cnt ) { + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + if(++slot < cnt) { #if BYTE_ORDER != BIG_ENDIAN - if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) + if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) #else - if( (!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) + if((!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) #endif { judy->stack[judy->level].slot = slot; return &node[-slot - 1]; } else { judy->stack[judy->level].slot = slot; - return judy_first( judy, node[-slot - 1], ( off | JUDY_key_mask ) + 1, depth ); + return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); } } judy->level--; continue; case JUDY_radix: - table = ( JudySlot * )( next & JUDY_mask ); + table = (JudySlot *)(next & JUDY_mask); - if( judy->depth ) - if( !( ( off + 1 ) & JUDY_key_mask ) ) { + if(judy->depth) + if(!((off + 1) & JUDY_key_mask)) { depth++; } - while( ++slot < 256 ) - if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { - if( inner[slot & 0x0F] ) { + while(++slot < 256) + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { + if(inner[slot & 0x0F]) { judy->stack[judy->level].slot = slot; - if( !judy->depth || depth < judy->depth ) { - return judy_first( judy, inner[slot & 0x0F], off + 1, depth ); + if(!judy->depth || depth < judy->depth) { + return judy_first(judy, inner[slot & 0x0F], off + 1, depth); } return &inner[slot & 0x0F]; } @@ -996,26 +1011,27 @@ JudySlot * judy_nxt( Judy * judy ) { // judy_prv: return ptr to previous entry -JudySlot * judy_prv( Judy * judy ) { +JudySlot *judy_prv(Judy *judy) +{ int slot, size, keysize; - JudySlot * table, *inner; - JudySlot * node, next; - unsigned char * base; + JudySlot *table, *inner; + JudySlot *node, next; + unsigned char *base; unsigned int depth; unsigned int off; - if( !judy->level ) { - return judy_last( judy, *judy->root, 0, 0 ); + if(!judy->level) { + return judy_last(judy, *judy->root, 0, 0); } - while( judy->level ) { + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch( next & 0x07 ) { + switch(next & 0x07) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1025,40 +1041,40 @@ JudySlot * judy_prv( Judy * judy ) { #ifdef ASKITIS case JUDY_64: #endif - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); - if( !slot || !node[-slot] ) { + node = (JudySlot *)((next & JUDY_mask) + size); + if(!slot || !node[-slot]) { judy->level--; continue; } - base = ( unsigned char * )( next & JUDY_mask ); + base = (unsigned char *)(next & JUDY_mask); judy->stack[judy->level].slot--; - keysize = JUDY_key_size - ( off & JUDY_key_mask ); + keysize = JUDY_key_size - (off & JUDY_key_mask); #if BYTE_ORDER != BIG_ENDIAN - if( (!judy->depth && !base[( slot - 1 ) * keysize]) || (judy->depth && ++depth == judy->depth) ) + if((!judy->depth && !base[(slot - 1) * keysize]) || (judy->depth && ++depth == judy->depth)) #else - if( (!judy->depth && !base[( slot - 1 ) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) + if((!judy->depth && !base[(slot - 1) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) #endif return &node[-slot]; - return judy_last( judy, node[-slot], ( off | JUDY_key_mask ) + 1, depth ); + return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); case JUDY_radix: - table = ( JudySlot * )( next & JUDY_mask ); + table = (JudySlot *)(next & JUDY_mask); - if( judy->depth ) - if( !( ( off + 1 ) & JUDY_key_mask ) ) { + if(judy->depth) + if(!((off + 1) & JUDY_key_mask)) { depth++; } - while( slot-- ) { + while(slot--) { judy->stack[judy->level].slot--; - if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) - if( inner[slot & 0x0F] ) { - if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { + if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) + if(inner[slot & 0x0F]) { + if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { return &inner[0]; } else { - return judy_last( judy, inner[slot & 0x0F], off + 1, depth ); + return judy_last(judy, inner[slot & 0x0F], off + 1, depth); } } } @@ -1079,20 +1095,21 @@ JudySlot * judy_prv( Judy * judy ) { // judy_del: delete string from judy array // returning previous entry. -JudySlot * judy_del( Judy * judy ) { +JudySlot *judy_del(Judy *judy) +{ int slot, off, size, type, high; - JudySlot * table, *inner; + JudySlot *table, *inner; JudySlot next, *node; int keysize, cnt; - unsigned char * base; + unsigned char *base; - while( judy->level ) { + while(judy->level) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch( type = next & 0x07 ) { + switch(type = next & 0x07) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1102,60 +1119,60 @@ JudySlot * judy_del( Judy * judy ) { #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - cnt = size / ( sizeof( JudySlot ) + keysize ); - node = ( JudySlot * )( ( next & JUDY_mask ) + size ); - base = ( unsigned char * )( next & JUDY_mask ); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); // move deleted slot to first slot - while( slot ) { + while(slot) { node[-slot - 1] = node[-slot]; - memcpy( base + slot * keysize, base + ( slot - 1 ) * keysize, keysize ); + memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); slot--; } // zero out first slot node[-1] = 0; - memset( base, 0, keysize ); + memset(base, 0, keysize); - if( node[-cnt] ) { // does node have any slots left? + if(node[-cnt]) { // does node have any slots left? judy->stack[judy->level].slot++; - return judy_prv( judy ); + return judy_prv(judy); } - judy_free( judy, base, type ); + judy_free(judy, base, type); judy->level--; continue; case JUDY_radix: - table = ( JudySlot * )( next & JUDY_mask ); - inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); + table = (JudySlot *)(next & JUDY_mask); + inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); inner[slot & 0x0F] = 0; high = slot & 0xF0; - for( cnt = 16; cnt--; ) - if( inner[cnt] ) { - return judy_prv( judy ); + for(cnt = 16; cnt--;) + if(inner[cnt]) { + return judy_prv(judy); } - judy_free( judy, inner, JUDY_radix ); + judy_free(judy, inner, JUDY_radix); table[slot >> 4] = 0; - for( cnt = 16; cnt--; ) - if( table[cnt] ) { - return judy_prv( judy ); + for(cnt = 16; cnt--;) + if(table[cnt]) { + return judy_prv(judy); } - judy_free( judy, table, JUDY_radix ); + judy_free(judy, table, JUDY_radix); judy->level--; continue; #ifndef ASKITIS case JUDY_span: - base = ( unsigned char * )( next & JUDY_mask ); - judy_free( judy, base, type ); + base = (unsigned char *)(next & JUDY_mask); + judy_free(judy, base, type); judy->level--; continue; #endif @@ -1170,98 +1187,101 @@ JudySlot * judy_del( Judy * judy ) { // return cell for first key greater than or equal to given key -JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ) { - JudySlot * cell; +JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max) +{ + JudySlot *cell; judy->level = 0; - if( !max ) { - return judy_first( judy, *judy->root, 0, 0 ); + if(!max) { + return judy_first(judy, *judy->root, 0, 0); } - if( ( cell = judy_slot( judy, buff, max ) ) ) { + if((cell = judy_slot(judy, buff, max))) { return cell; } - return judy_nxt( judy ); + return judy_nxt(judy); } // split open span node #ifndef ASKITIS -void judy_splitspan( Judy * judy, JudySlot * next, unsigned char * base ) { - JudySlot * node = ( JudySlot * )( base + JudySize[JUDY_span] ); +void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) +{ + JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); unsigned int cnt = JUDY_span_bytes; - unsigned char * newbase; + unsigned char *newbase; unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN int i; #endif do { - newbase = judy_alloc( judy, JUDY_1 ); - *next = ( JudySlot )newbase | JUDY_1; + newbase = judy_alloc(judy, JUDY_1); + *next = (JudySlot)newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while( i-- ) { + while(i--) { *newbase++ = base[off + i]; } #else - memcpy( newbase, base + off, JUDY_key_size ); + memcpy(newbase, base + off, JUDY_key_size); newbase += JUDY_key_size; #endif - next = ( JudySlot * )newbase; + next = (JudySlot *)newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while( cnt && base[off - 1] ); + } while(cnt && base[off - 1]); *next = node[-1]; - judy_free( judy, base, JUDY_span ); + judy_free(judy, base, JUDY_span); } #endif // judy_cell: add string to judy array -JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ) { - judyvalue * src = ( judyvalue * )buff; +JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) +{ + judyvalue *src = (judyvalue *)buff; int size, idx, slot, cnt, tst; - JudySlot * next = judy->root; + JudySlot *next = judy->root; judyvalue test, value; unsigned int off = 0, start; - JudySlot * table; - JudySlot * node; + JudySlot *table; + JudySlot *node; unsigned int depth = 0; unsigned int keysize; - unsigned char * base; + unsigned char *base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while( *next ) { + while(*next) { #ifndef ASKITIS - if( judy->level < judy->max ) { + if(judy->level < judy->max) { judy->level++; } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch( *next & 0x07 ) { + switch(*next & 0x07) { default: size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - cnt = size / ( sizeof( JudySlot ) + keysize ); - base = ( unsigned char * )( *next & JUDY_mask ); - node = ( JudySlot * )( ( *next & JUDY_mask ) + size ); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + size); start = off; slot = cnt; value = 0; - if( judy->depth ) { + if(judy->depth) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -1269,35 +1289,35 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max } else do { value <<= 8; - if( off < max ) { + if(off < max) { value |= buff[off]; } - } while( ++off & JUDY_key_mask ); + } while(++off & JUDY_key_mask); // find slot > key - while( slot-- ) { - test = *( judyvalue * )( base + slot * keysize ); + while(slot--) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * ( JUDY_key_size - keysize ); + test >>= 8 * (JUDY_key_size - keysize); #else test &= JudyMask[keysize]; #endif - if( test <= value ) { + if(test <= value) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if( test == value ) { // new key is equal to slot key + if(test == value) { // new key is equal to slot key next = &node[-slot - 1]; // is this a leaf? - if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { + if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { #ifdef ASKITIS - if( *next ) { + if(*next) { Found++; } else { Inserts++; @@ -1312,28 +1332,28 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // if this node is not full // open up cell after slot - if( !node[-1] ) { - memmove( base, base + keysize, slot * keysize ); // move keys less than new key down one slot + if(!node[-1]) { + memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy( base + slot * keysize, &value, keysize ); // copy new key into slot + memcpy(base + slot * keysize, &value, keysize); // copy new key into slot #else test = value; idx = keysize; - while( idx-- ) { + while(idx--) { base[slot * keysize + idx] = test, test >>= 8; } #endif - for( idx = 0; idx < slot; idx++ ) { + for(idx = 0; idx < slot; idx++) { node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot } node[-slot - 1] = 0; // set new tree ptr/cell next = &node[-slot - 1]; - if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { + if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { #ifdef ASKITIS - if( *next ) { + if(*next) { Found++; } else { Inserts++; @@ -1345,12 +1365,12 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max continue; } - if( size < JudySize[JUDY_max] ) { - next = judy_promote( judy, next, slot + 1, value, keysize ); + if(size < JudySize[JUDY_max]) { + next = judy_promote(judy, next, slot + 1, value, keysize); - if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { + if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { #ifdef ASKITIS - if( *next ) { + if(*next) { Found++; } else { Inserts++; @@ -1365,47 +1385,47 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // split full maximal node into JUDY_radix nodes // loop to reprocess new insert - judy_splitnode( judy, next, size, keysize, depth ); + judy_splitnode(judy, next, size, keysize, depth); #ifndef ASKITIS judy->level--; #endif off = start; - if( judy->depth ) { + if(judy->depth) { depth--; } continue; case JUDY_radix: - table = ( JudySlot * )( *next & JUDY_mask ); // outer radix + table = (JudySlot *)(*next & JUDY_mask); // outer radix - if( judy->depth ) { - slot = ( src[depth] >> ( ( (JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; - } else if( off < max ) { + if(judy->depth) { + slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; + } else if(off < max) { slot = buff[off++]; } else { slot = 0, off++; } - if( judy->depth ) - if( !( off & JUDY_key_mask ) ) { + if(judy->depth) + if(!(off & JUDY_key_mask)) { depth++; } // allocate inner radix if empty - if( !table[slot >> 4] ) { - table[slot >> 4] = ( JudySlot )judy_alloc( judy, JUDY_radix ) | JUDY_radix; + if(!table[slot >> 4]) { + table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; } - table = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); + table = (JudySlot *)(table[slot >> 4] & JUDY_mask); #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif next = &table[slot & 0x0F]; - if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? + if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? #ifdef ASKITIS - if( *next ) { + if(*next) { Found++; } else { Inserts++; @@ -1418,22 +1438,22 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max #ifndef ASKITIS case JUDY_span: - base = ( unsigned char * )( *next & JUDY_mask ); - node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[JUDY_span] ); + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); cnt = JUDY_span_bytes; tst = cnt; - if( tst > ( int )( max - off ) ) { + if(tst > (int)(max - off)) { tst = max - off; } - value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); + value = strncmp((const char *)base, (const char *)(buff + off), tst); - if( !value && tst < cnt && !base[tst] ) { // leaf? + if(!value && tst < cnt && !base[tst]) { // leaf? return &node[-1]; } - if( !value && tst == cnt ) { + if(!value && tst == cnt) { next = &node[-1]; off += cnt; continue; @@ -1442,7 +1462,7 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // bust up JUDY_span node and produce JUDY_1 nodes // then loop to reprocess insert - judy_splitspan( judy, next, base ); + judy_splitspan(judy, next, base); judy->level--; continue; #endif @@ -1452,31 +1472,31 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if( off & JUDY_key_mask ) - if( judy->depth || off <= max ) { + if(off & JUDY_key_mask) + if(judy->depth || off <= max) { #else - while( off <= max ) { + while(off <= max) { #endif - base = judy_alloc( judy, JUDY_1 ); - keysize = JUDY_key_size - ( off & JUDY_key_mask ); - node = ( JudySlot * )( base + JudySize[JUDY_1] ); - *next = ( JudySlot )base | JUDY_1; + base = judy_alloc(judy, JUDY_1); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; // fill in slot 0 with bytes of key - if( judy->depth ) { + if(judy->depth) { value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy( base, &value, keysize ); // copy new key into slot + memcpy(base, &value, keysize); // copy new key into slot #else - while( keysize-- ) { + while(keysize--) { base[keysize] = value, value >>= 8; } #endif } else { #if BYTE_ORDER != BIG_ENDIAN - while( keysize ) - if( off + keysize <= max ) { + while(keysize) + if(off + keysize <= max) { *base++ = buff[off + --keysize]; } else { base++, --keysize; @@ -1484,15 +1504,15 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max #else tst = keysize; - if( tst > ( int )( max - off ) ) { + if(tst > (int)(max - off)) { tst = max - off; } - memcpy( base, buff + off, tst ); + memcpy(base, buff + off, tst); #endif } #ifndef ASKITIS - if( judy->level < judy->max ) { + if(judy->level < judy->max) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1510,18 +1530,18 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max // or judy_1 nodes if not string tree #ifndef ASKITIS - if( !judy->depth ) - while( off <= max ) { - base = judy_alloc( judy, JUDY_span ); - *next = ( JudySlot )base | JUDY_span; - node = ( JudySlot * )( base + JudySize[JUDY_span] ); + if(!judy->depth) + while(off <= max) { + base = judy_alloc(judy, JUDY_span); + *next = (JudySlot)base | JUDY_span; + node = (JudySlot *)(base + JudySize[JUDY_span]); cnt = tst = JUDY_span_bytes; - if( tst > ( int )( max - off ) ) { + if(tst > (int)(max - off)) { tst = max - off; } - memcpy( base, buff + off, tst ); + memcpy(base, buff + off, tst); - if( judy->level < judy->max ) { + if(judy->level < judy->max) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1531,21 +1551,20 @@ JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max off += tst; depth++; - if( !base[cnt - 1] ) { // done on leaf + if(!base[cnt - 1]) { // done on leaf break; } - } - else - while( depth < judy->depth ) { - base = judy_alloc( judy, JUDY_1 ); - node = ( JudySlot * )( base + JudySize[JUDY_1] ); - *next = ( JudySlot )base | JUDY_1; + } else + while(depth < judy->depth) { + base = judy_alloc(judy, JUDY_1); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; // fill in slot 0 with bytes of key - *( judyvalue * )base = src[depth]; + *(judyvalue *)base = src[depth]; - if( judy->level < judy->max ) { + if(judy->level < judy->max) { judy->level++; } judy->stack[judy->level].next = *next; diff --git a/src/base/judy/src/judy.h b/src/base/judy/src/judy.h index dfd193cf3..5ef2497ea 100644 --- a/src/base/judy/src/judy.h +++ b/src/base/judy/src/judy.h @@ -96,7 +96,7 @@ enum JUDY_types { }; typedef struct { - void * seg; // next used allocator + void *seg; // next used allocator unsigned int next; // next available offset } JudySeg; @@ -108,8 +108,8 @@ typedef struct { typedef struct { JudySlot root[1]; // root of judy array - void ** reuse[8]; // reuse judy blocks - JudySeg * seg; // current judy allocator + void **reuse[8]; // reuse judy blocks + JudySeg *seg; // current judy allocator unsigned int level; // current height of stack unsigned int max; // max height of stack unsigned int depth; // number of Integers in a key, or zero for string keys @@ -133,41 +133,41 @@ int Found = 0; extern "C" { #endif - /// open a new judy array returning a judy object. - SC_BASE_EXPORT Judy * judy_open( unsigned int max, unsigned int depth ); +/// open a new judy array returning a judy object. +SC_BASE_EXPORT Judy *judy_open(unsigned int max, unsigned int depth); - /// close an open judy array, freeing all memory. - SC_BASE_EXPORT void judy_close( Judy * judy ); +/// close an open judy array, freeing all memory. +SC_BASE_EXPORT void judy_close(Judy *judy); - /// clone an open judy array, duplicating the stack. - SC_BASE_EXPORT Judy * judy_clone( Judy * judy ); +/// clone an open judy array, duplicating the stack. +SC_BASE_EXPORT Judy *judy_clone(Judy *judy); - /// allocate data memory within judy array for external use. - SC_BASE_EXPORT void * judy_data( Judy * judy, unsigned int amt ); +/// allocate data memory within judy array for external use. +SC_BASE_EXPORT void *judy_data(Judy *judy, unsigned int amt); - /// insert a key into the judy array, return cell pointer. - SC_BASE_EXPORT JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ); +/// insert a key into the judy array, return cell pointer. +SC_BASE_EXPORT JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max); - /// retrieve the cell pointer greater than or equal to given key - SC_BASE_EXPORT JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ); +/// retrieve the cell pointer greater than or equal to given key +SC_BASE_EXPORT JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max); - /// retrieve the cell pointer, or return NULL for a given key. - SC_BASE_EXPORT JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ); +/// retrieve the cell pointer, or return NULL for a given key. +SC_BASE_EXPORT JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max); - /// retrieve the string value for the most recent judy query. - SC_BASE_EXPORT unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ); +/// retrieve the string value for the most recent judy query. +SC_BASE_EXPORT unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max); - /// retrieve the cell pointer for the last string in the array. - SC_BASE_EXPORT JudySlot * judy_end( Judy * judy ); +/// retrieve the cell pointer for the last string in the array. +SC_BASE_EXPORT JudySlot *judy_end(Judy *judy); - /// retrieve the cell pointer for the next string in the array. - SC_BASE_EXPORT JudySlot * judy_nxt( Judy * judy ); +/// retrieve the cell pointer for the next string in the array. +SC_BASE_EXPORT JudySlot *judy_nxt(Judy *judy); - /// retrieve the cell pointer for the prev string in the array. - SC_BASE_EXPORT JudySlot * judy_prv( Judy * judy ); +/// retrieve the cell pointer for the prev string in the array. +SC_BASE_EXPORT JudySlot *judy_prv(Judy *judy); - /// delete the key and cell for the current stack entry. - SC_BASE_EXPORT JudySlot * judy_del( Judy * judy ); +/// delete the key and cell for the current stack entry. +SC_BASE_EXPORT JudySlot *judy_del(Judy *judy); #ifdef __cplusplus } diff --git a/src/base/judy/src/judyL2Array.h b/src/base/judy/src/judyL2Array.h index 02b416827..e5b58bcfd 100644 --- a/src/base/judy/src/judyL2Array.h +++ b/src/base/judy/src/judyL2Array.h @@ -29,60 +29,68 @@ struct judyl2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. With judyL2Array, the size of this value can vary. */ template< typename JudyKey, typename JudyValue > -class judyL2Array { +class judyL2Array +{ public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judyl2KVpair< JudyKey, vector * > pair; typedef judyl2KVpair< JudyKey, cvector * > cpair; protected: - Judy * _judyarray; + Judy *_judyarray; unsigned int _maxLevels, _depth; - vector ** _lastSlot; + vector **_lastSlot; JudyKey _buff[1]; bool _success; cpair kv; public: - judyL2Array(): _maxLevels( sizeof( JudyKey ) ), _depth( 1 ), _lastSlot( 0 ), _success( true ) { - assert( sizeof( JudyKey ) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!" ); - _judyarray = judy_open( _maxLevels, _depth ); + judyL2Array(): _maxLevels(sizeof(JudyKey)), _depth(1), _lastSlot(0), _success(true) + { + assert(sizeof(JudyKey) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!"); + _judyarray = judy_open(_maxLevels, _depth); _buff[0] = 0; } - explicit judyL2Array( const judyL2Array< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), - _depth( other._depth ), _success( other._success ) { - _judyarray = judy_clone( other._judyarray ); + explicit judyL2Array(const judyL2Array< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), + _depth(other._depth), _success(other._success) + { + _judyarray = judy_clone(other._judyarray); _buff[0] = other._buff[0]; - find( *_buff ); //set _lastSlot + find(*_buff); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyL2Array() { + ~judyL2Array() + { clear(); - judy_close( _judyarray ); + judy_close(_judyarray); } /// delete all vectors and empty the array - void clear() { + void clear() + { JudyKey key = 0; - while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { + while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { //( * _lastSlot )->~vector(); //TODO: placement new - delete( * _lastSlot ); - judy_del( _judyarray ); + delete(* _lastSlot); + judy_del(_judyarray); } } - vector * getLastValue() { - assert( _lastSlot ); + vector *getLastValue() + { + assert(_lastSlot); return &_lastSlot; } - void setLastValue( vector * value ) { - assert( _lastSlot ); + void setLastValue(vector *value) + { + assert(_lastSlot); &_lastSlot = value; } - bool success() { + bool success() + { return _success; } @@ -96,10 +104,11 @@ class judyL2Array { // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert( JudyKey key, JudyValue value ) { - _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); - if( _lastSlot ) { - if( !( * _lastSlot ) ) { + bool insert(JudyKey key, JudyValue value) + { + _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + if(_lastSlot) { + if(!(* _lastSlot)) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -109,7 +118,7 @@ class judyL2Array { * also use placement new in the other insert function, below */ } - ( * _lastSlot )->push_back( value ); + (* _lastSlot)->push_back(value); _success = true; } else { _success = false; @@ -121,18 +130,19 @@ class judyL2Array { * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert( JudyKey key, const vector & values, bool overwrite = false ) { - _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); - if( _lastSlot ) { - if( !( * _lastSlot ) ) { + bool insert(JudyKey key, const vector &values, bool overwrite = false) + { + _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + if(_lastSlot) { + if(!(* _lastSlot)) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if( overwrite ) { - ( * _lastSlot )->clear(); + } else if(overwrite) { + (* _lastSlot)->clear(); } - std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); + std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); _success = true; } else { _success = false; @@ -142,15 +152,17 @@ class judyL2Array { /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter( JudyKey key ) { - _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + const cpair atOrAfter(JudyKey key) + { + _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector * find( JudyKey key ) { - _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); - if( ( _lastSlot ) && ( * _lastSlot ) ) { + cvector *find(JudyKey key) + { + _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + if((_lastSlot) && (* _lastSlot)) { _success = true; return * _lastSlot; } else { @@ -160,9 +172,10 @@ class judyL2Array { } /// retrieve the key-value pair for the most recent judy query. - inline const cpair & mostRecentPair() { - judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); - if( _lastSlot ) { + inline const cpair &mostRecentPair() + { + judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); + if(_lastSlot) { kv.value = *_lastSlot; _success = true; } else { @@ -174,27 +187,31 @@ class judyL2Array { } /// retrieve the first key-value pair in the array - const cpair & begin() { + const cpair &begin() + { JudyKey key = 0; - _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); + _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair & end() { - _lastSlot = ( vector ** ) judy_end( _judyarray ); + const cpair &end() + { + _lastSlot = (vector **) judy_end(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the next string in the array. - const cpair & next() { - _lastSlot = ( vector ** ) judy_nxt( _judyarray ); + const cpair &next() + { + _lastSlot = (vector **) judy_nxt(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the prev string in the array. - const cpair & previous() { - _lastSlot = ( vector ** ) judy_prv( _judyarray ); + const cpair &previous() + { + _lastSlot = (vector **) judy_prv(_judyarray); return mostRecentPair(); } @@ -202,11 +219,12 @@ class judyL2Array { * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry( JudyKey key ) { - if( 0 != ( _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ) { + bool removeEntry(JudyKey key) + { + if(0 != (_lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size))) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = ( vector ** ) judy_del( _judyarray ); + _lastSlot = (vector **) judy_del(_judyarray); return true; } else { return false; @@ -214,9 +232,10 @@ class judyL2Array { } /// true if the array is empty - bool isEmpty() { + bool isEmpty() + { JudyKey key = 0; - return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); + return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); } }; #endif //JUDYL2ARRAY_H diff --git a/src/base/judy/src/judyLArray.h b/src/base/judy/src/judyLArray.h index b78dc0bb9..a70e787c7 100644 --- a/src/base/judy/src/judyLArray.h +++ b/src/base/judy/src/judyLArray.h @@ -28,56 +28,64 @@ struct judylKVpair { * \param JudyValue the type of the value */ template< typename JudyKey, typename JudyValue > -class judyLArray { +class judyLArray +{ public: typedef judylKVpair< JudyKey, JudyValue > pair; protected: - Judy * _judyarray; + Judy *_judyarray; unsigned int _maxLevels, _depth; - JudyValue * _lastSlot; + JudyValue *_lastSlot; JudyKey _buff[1]; bool _success; pair _kv; public: - 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!" ); - _judyarray = judy_open( _maxLevels, _depth ); + 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!"); + _judyarray = judy_open(_maxLevels, _depth); _buff[0] = 0; } - explicit judyLArray( const judyLArray< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), - _depth( other._depth ), _success( other._success ) { - _judyarray = judy_clone( other._judyarray ); + explicit judyLArray(const judyLArray< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), + _depth(other._depth), _success(other._success) + { + _judyarray = judy_clone(other._judyarray); _buff[0] = other._buff[0]; - find( *_buff ); //set _lastSlot + find(*_buff); //set _lastSlot } - ~judyLArray() { - judy_close( _judyarray ); + ~judyLArray() + { + judy_close(_judyarray); } - void clear( bool deleteContents = false ) { + void clear(bool deleteContents = false) + { JudyKey key = 0; - while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { - if( deleteContents ) { + while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { + if(deleteContents) { delete *_lastSlot; } - judy_del( _judyarray ); + judy_del(_judyarray); } } - JudyValue getLastValue() { - assert( _lastSlot ); + JudyValue getLastValue() + { + assert(_lastSlot); return &_lastSlot; } - void setLastValue( JudyValue value ) { - assert( _lastSlot ); + void setLastValue(JudyValue value) + { + assert(_lastSlot); &_lastSlot = value; } - bool success() { + bool success() + { return _success; } //TODO @@ -85,10 +93,11 @@ class judyLArray { // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert( JudyKey key, JudyValue value ) { - assert( value != 0 ); - _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); - if( _lastSlot ) { + bool insert(JudyKey key, JudyValue value) + { + assert(value != 0); + _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + if(_lastSlot) { *_lastSlot = value; _success = true; } else { @@ -99,15 +108,17 @@ class judyLArray { /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter( JudyKey key ) { - _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + const pair atOrAfter(JudyKey key) + { + _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find( JudyKey key ) { - _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); - if( _lastSlot ) { + JudyValue find(JudyKey key) + { + _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + if(_lastSlot) { _success = true; return *_lastSlot; } else { @@ -117,13 +128,14 @@ class judyLArray { } /// retrieve the key-value pair for the most recent judy query. - inline const pair & mostRecentPair() { - judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); - if( _lastSlot ) { + inline const pair &mostRecentPair() + { + judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); + if(_lastSlot) { _kv.value = *_lastSlot; _success = true; } else { - _kv.value = ( JudyValue ) 0; + _kv.value = (JudyValue) 0; _success = false; } _kv.key = _buff[0]; @@ -131,27 +143,31 @@ class judyLArray { } /// retrieve the first key-value pair in the array - const pair & begin() { + const pair &begin() + { JudyKey key = 0; - _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); + _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair & end() { - _lastSlot = ( JudyValue * ) judy_end( _judyarray ); + const pair &end() + { + _lastSlot = (JudyValue *) judy_end(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair & next() { - _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); + const pair &next() + { + _lastSlot = (JudyValue *) judy_nxt(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair & previous() { - _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); + const pair &previous() + { + _lastSlot = (JudyValue *) judy_prv(_judyarray); return mostRecentPair(); } @@ -159,9 +175,10 @@ class judyLArray { * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry( JudyKey * key ) { - if( judy_slot( _judyarray, key, _depth * JUDY_key_size ) ) { - _lastSlot = ( JudyValue * ) judy_del( _judyarray ); + bool removeEntry(JudyKey *key) + { + if(judy_slot(_judyarray, key, _depth * JUDY_key_size)) { + _lastSlot = (JudyValue *) judy_del(_judyarray); return true; } else { return false; @@ -169,9 +186,10 @@ class judyLArray { } /// true if the array is empty - bool isEmpty() { + bool isEmpty() + { JudyKey key = 0; - return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); + return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); } }; #endif //JUDYLARRAY_H diff --git a/src/base/judy/src/judyS2Array.h b/src/base/judy/src/judyS2Array.h index 726a6449a..421c310f0 100644 --- a/src/base/judy/src/judyS2Array.h +++ b/src/base/judy/src/judyS2Array.h @@ -19,7 +19,7 @@ template< typename JudyValue > struct judys2KVpair { - unsigned char * key; + unsigned char *key; JudyValue value; }; @@ -28,62 +28,70 @@ struct judys2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. */ template< typename JudyValue > -class judyS2Array { +class judyS2Array +{ public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judys2KVpair< vector * > pair; typedef judys2KVpair< cvector * > cpair; protected: - Judy * _judyarray; + Judy *_judyarray; unsigned int _maxKeyLen; - vector ** _lastSlot; - unsigned char * _buff; + vector **_lastSlot; + unsigned char *_buff; bool _success; cpair kv; public: - judyS2Array( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _lastSlot( 0 ), _success( true ) { - _judyarray = judy_open( _maxKeyLen, 0 ); + judyS2Array(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _lastSlot(0), _success(true) + { + _judyarray = judy_open(_maxKeyLen, 0); _buff = new unsigned char[_maxKeyLen]; - assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); + assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); } - explicit judyS2Array( const judyS2Array< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { - _judyarray = judy_clone( other._judyarray ); + explicit judyS2Array(const judyS2Array< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) + { + _judyarray = judy_clone(other._judyarray); _buff = new unsigned char[_maxKeyLen]; - strncpy( _buff, other._buff, _maxKeyLen ); + strncpy(_buff, other._buff, _maxKeyLen); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find( _buff ); //set _lastSlot + find(_buff); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyS2Array() { + ~judyS2Array() + { clear(); - judy_close( _judyarray ); + judy_close(_judyarray); delete[] _buff; } /// delete all vectors and empty the array - void clear() { + void clear() + { _buff[0] = '\0'; - while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { + while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { //( * _lastSlot )->~vector(); //TODO: placement new - delete( * _lastSlot ); - judy_del( _judyarray ); + delete(* _lastSlot); + judy_del(_judyarray); } } - vector * getLastValue() { - assert( _lastSlot ); + vector *getLastValue() + { + assert(_lastSlot); return &_lastSlot; } - void setLastValue( vector * value ) { - assert( _lastSlot ); + void setLastValue(vector *value) + { + assert(_lastSlot); &_lastSlot = value; } - bool success() { + bool success() + { return _success; } @@ -97,16 +105,17 @@ class judyS2Array { // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); - if( _lastSlot ) { - if( !( * _lastSlot ) ) { + assert(keyLen <= _maxKeyLen); + _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); + if(_lastSlot) { + if(!(* _lastSlot)) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -116,7 +125,7 @@ class judyS2Array { * also use placement new in the other insert function, below */ } - ( * _lastSlot )->push_back( value ); + (* _lastSlot)->push_back(value); _success = true; } else { _success = false; @@ -128,24 +137,25 @@ class judyS2Array { * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert( const char * key, const vector & values, unsigned int keyLen = 0, bool overwrite = false ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + bool insert(const char *key, const vector &values, unsigned int keyLen = 0, bool overwrite = false) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); - if( _lastSlot ) { - if( !( * _lastSlot ) ) { + assert(keyLen <= _maxKeyLen); + _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); + if(_lastSlot) { + if(!(* _lastSlot)) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if( overwrite ) { - ( * _lastSlot )->clear(); + } else if(overwrite) { + (* _lastSlot)->clear(); } - std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); + std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); _success = true; } else { _success = false; @@ -155,27 +165,29 @@ class judyS2Array { /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter( const char * key, unsigned int keyLen = 0 ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + const cpair atOrAfter(const char *key, unsigned int keyLen = 0) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); + assert(keyLen <= _maxKeyLen); + _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *)key, keyLen); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector * find( const char * key, unsigned int keyLen = 0 ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + cvector *find(const char *key, unsigned int keyLen = 0) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); - if( ( _lastSlot ) && ( * _lastSlot ) ) { + assert(keyLen <= _maxKeyLen); + _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) key, keyLen); + if((_lastSlot) && (* _lastSlot)) { _success = true; return * _lastSlot; } else { @@ -185,9 +197,10 @@ class judyS2Array { } /// retrieve the key-value pair for the most recent judy query. - inline const cpair & mostRecentPair() { - judy_key( _judyarray, _buff, _maxKeyLen ); - if( _lastSlot ) { + inline const cpair &mostRecentPair() + { + judy_key(_judyarray, _buff, _maxKeyLen); + if(_lastSlot) { kv.value = *_lastSlot; _success = true; } else { @@ -199,27 +212,31 @@ class judyS2Array { } /// retrieve the first key-value pair in the array - const cpair & begin() { + const cpair &begin() + { _buff[0] = '\0'; - _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); + _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair & end() { - _lastSlot = ( vector ** ) judy_end( _judyarray ); + const cpair &end() + { + _lastSlot = (vector **) judy_end(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const cpair & next() { - _lastSlot = ( vector ** ) judy_nxt( _judyarray ); + const cpair &next() + { + _lastSlot = (vector **) judy_nxt(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const cpair & previous() { - _lastSlot = ( vector ** ) judy_prv( _judyarray ); + const cpair &previous() + { + _lastSlot = (vector **) judy_prv(_judyarray); return mostRecentPair(); } @@ -227,11 +244,12 @@ class judyS2Array { * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry( const char * key ) { - if( 0 != ( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) ) { + bool removeEntry(const char *key) + { + if(0 != (judy_slot(_judyarray, (const unsigned char *)key, strlen(key)))) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = ( vector ** ) judy_del( _judyarray ); + _lastSlot = (vector **) judy_del(_judyarray); return true; } else { return false; @@ -239,9 +257,10 @@ class judyS2Array { } ///return true if the array is empty - bool isEmpty() { + bool isEmpty() + { _buff[0] = 0; - return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); + return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); } }; #endif //JUDYS2ARRAY_H diff --git a/src/base/judy/src/judySArray.h b/src/base/judy/src/judySArray.h index db75ec91c..2a6079a2c 100644 --- a/src/base/judy/src/judySArray.h +++ b/src/base/judy/src/judySArray.h @@ -17,56 +17,64 @@ template< typename JudyValue > struct judysKVpair { - unsigned char * key; + unsigned char *key; JudyValue value; }; template< typename JudyValue > -class judySArray { +class judySArray +{ protected: - Judy * _judyarray; + Judy *_judyarray; unsigned int _maxKeyLen; - JudyValue * _lastSlot; - unsigned char * _buff; + JudyValue *_lastSlot; + unsigned char *_buff; bool _success; public: typedef judysKVpair< JudyValue > pair; - judySArray( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _success( true ) { - _judyarray = judy_open( _maxKeyLen, 0 ); + judySArray(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _success(true) + { + _judyarray = judy_open(_maxKeyLen, 0); _buff = new unsigned char[_maxKeyLen]; - assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); + assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); } - explicit judySArray( const judySArray< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { - _judyarray = judy_clone( other._judyarray ); + explicit judySArray(const judySArray< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) + { + _judyarray = judy_clone(other._judyarray); _buff = new unsigned char[_maxKeyLen]; - strncpy( _buff, other._buff, _maxKeyLen ); + strncpy(_buff, other._buff, _maxKeyLen); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find( _buff ); //set _lastSlot + find(_buff); //set _lastSlot } - ~judySArray() { - judy_close( _judyarray ); + ~judySArray() + { + judy_close(_judyarray); delete[] _buff; } - void clear() { + void clear() + { _buff[0] = '\0'; - while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { - judy_del( _judyarray ); + while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { + judy_del(_judyarray); } } - JudyValue getLastValue() { - assert( _lastSlot ); + JudyValue getLastValue() + { + assert(_lastSlot); return &_lastSlot; } - void setLastValue( JudyValue value ) { - assert( _lastSlot ); + void setLastValue(JudyValue value) + { + assert(_lastSlot); &_lastSlot = value; } - bool success() { + bool success() + { return _success; } //TODO @@ -74,16 +82,17 @@ class judySArray { // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { - assert( value != 0 ); - if( keyLen == 0 ) { - keyLen = strlen( key ); + bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) + { + assert(value != 0); + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); - if( _lastSlot ) { + assert(keyLen <= _maxKeyLen); + _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *)key, keyLen); + if(_lastSlot) { *_lastSlot = value; _success = true; } else { @@ -94,27 +103,29 @@ class judySArray { /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter( const char * key, unsigned int keyLen = 0 ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + const pair atOrAfter(const char *key, unsigned int keyLen = 0) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); + assert(keyLen <= _maxKeyLen); + _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *)key, keyLen); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find( const char * key, unsigned int keyLen = 0 ) { - if( keyLen == 0 ) { - keyLen = strlen( key ); + JudyValue find(const char *key, unsigned int keyLen = 0) + { + if(keyLen == 0) { + keyLen = strlen(key); } else { - assert( keyLen == strlen( key ) ); + assert(keyLen == strlen(key)); } - assert( keyLen <= _maxKeyLen ); - _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); - if( _lastSlot ) { + assert(keyLen <= _maxKeyLen); + _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) key, keyLen); + if(_lastSlot) { _success = true; return *_lastSlot; } else { @@ -124,14 +135,15 @@ class judySArray { } /// retrieve the key-value pair for the most recent judy query. - inline const pair mostRecentPair() { + inline const pair mostRecentPair() + { pair kv; - judy_key( _judyarray, _buff, _maxKeyLen ); - if( _lastSlot ) { + judy_key(_judyarray, _buff, _maxKeyLen); + if(_lastSlot) { kv.value = *_lastSlot; _success = true; } else { - kv.value = ( JudyValue ) 0; + kv.value = (JudyValue) 0; _success = false; } kv.key = _buff; @@ -139,27 +151,31 @@ class judySArray { } /// retrieve the first key-value pair in the array - const pair & begin() { + const pair &begin() + { _buff[0] = '\0'; - _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); + _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair & end() { - _lastSlot = ( JudyValue * ) judy_end( _judyarray ); + const pair &end() + { + _lastSlot = (JudyValue *) judy_end(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair & next() { - _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); + const pair &next() + { + _lastSlot = (JudyValue *) judy_nxt(_judyarray); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair & previous() { - _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); + const pair &previous() + { + _lastSlot = (JudyValue *) judy_prv(_judyarray); return mostRecentPair(); } @@ -167,9 +183,10 @@ class judySArray { * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry( const char * key ) { - if( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) { - _lastSlot = ( JudyValue * ) judy_del( _judyarray ); + bool removeEntry(const char *key) + { + if(judy_slot(_judyarray, (const unsigned char *)key, strlen(key))) { + _lastSlot = (JudyValue *) judy_del(_judyarray); return true; } else { return false; @@ -177,9 +194,10 @@ class judySArray { } ///return true if the array is empty - bool isEmpty() { + bool isEmpty() + { _buff[0] = 0; - return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); + return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); } }; #endif //JUDYSARRAY_H diff --git a/src/base/judy/test/hexSort.c b/src/base/judy/test/hexSort.c index 0d770d752..9d9523af8 100644 --- a/src/base/judy/test/hexSort.c +++ b/src/base/judy/test/hexSort.c @@ -30,95 +30,96 @@ unsigned int MaxMem = 0; On linux, a 1M-line file can be created with the following: hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >in-file */ -int main( int argc, char ** argv ) { +int main(int argc, char **argv) +{ unsigned char buff[1024]; JudySlot max = 0; - JudySlot * cell; - FILE * in, *out; - void * judy; + JudySlot *cell; + FILE *in, *out; + void *judy; unsigned int len; unsigned int idx; - if( argc > 1 ) { - in = fopen( argv[1], "rb" ); + if(argc > 1) { + in = fopen(argv[1], "rb"); } else { in = stdin; } - if( argc > 2 ) { - out = fopen( argv[2], "wb" ); + if(argc > 2) { + out = fopen(argv[2], "wb"); } else { out = stdout; } - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); + setvbuf(out, NULL, _IOFBF, 4096 * 1024); - if( !in ) { - fprintf( stderr, "unable to open input file\n" ); + if(!in) { + fprintf(stderr, "unable to open input file\n"); } - if( !out ) { - fprintf( stderr, "unable to open output file\n" ); + if(!out) { + fprintf(stderr, "unable to open output file\n"); } - PennyMerge = ( unsigned long long )PennyLine * PennyRecs; + PennyMerge = (unsigned long long)PennyLine * PennyRecs; - judy = judy_open( 1024, 16 / JUDY_key_size ); + judy = judy_open(1024, 16 / JUDY_key_size); - while( fgets( ( char * )buff, sizeof( buff ), in ) ) { + while(fgets((char *)buff, sizeof(buff), in)) { judyvalue key[16 / JUDY_key_size]; - if( len = strlen( ( const char * )buff ) ) { + if(len = strlen((const char *)buff)) { buff[--len] = 0; // remove LF } #if JUDY_key_size == 4 - key[3] = strtoul( buff + 24, NULL, 16 ); + key[3] = strtoul(buff + 24, NULL, 16); buff[24] = 0; - key[2] = strtoul( buff + 16, NULL, 16 ); + key[2] = strtoul(buff + 16, NULL, 16); buff[16] = 0; - key[1] = strtoul( buff + 8, NULL, 16 ); + key[1] = strtoul(buff + 8, NULL, 16); buff[8] = 0; - key[0] = strtoul( buff, NULL, 16 ); + key[0] = strtoul(buff, NULL, 16); #else - key[1] = strtoull( buff + 16, NULL, 16 ); + key[1] = strtoull(buff + 16, NULL, 16); buff[16] = 0; - key[0] = strtoull( buff, NULL, 16 ); + key[0] = strtoull(buff, NULL, 16); #endif - *( judy_cell( judy, ( void * )key, 0 ) ) += 1; // count instances of string + *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string max++; } - fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); + fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt( judy, NULL, 0 ); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { + if(cell) do { judyvalue key[16 / JUDY_key_size]; - len = judy_key( judy, ( void * )key, 0 ); - for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates + len = judy_key(judy, (void *)key, 0); + for(idx = 0; idx < *cell; idx++) { // spit out duplicates #if JUDY_key_size == 4 - fprintf( out, "%.8X", key[0] ); - fprintf( out, "%.8X", key[1] ); - fprintf( out, "%.8X", key[2] ); - fprintf( out, "%.8X", key[3] ); + fprintf(out, "%.8X", key[0]); + fprintf(out, "%.8X", key[1]); + fprintf(out, "%.8X", key[2]); + fprintf(out, "%.8X", key[3]); #else - fprintf( out, "%.16llX", key[0] ); - fprintf( out, "%.16llX", key[1] ); + fprintf(out, "%.16llX", key[0]); + fprintf(out, "%.16llX", key[1]); #endif - fputc( '\n', out ); + fputc('\n', out); } - } while( cell = judy_nxt( judy ) ); + } while(cell = judy_nxt(judy)); #if 0 // test deletion all the way to an empty tree - if( cell = judy_prv( judy ) ) + if(cell = judy_prv(judy)) do { max -= *cell; - } while( cell = judy_del( judy ) ); + } while(cell = judy_del(judy)); - assert( max == 0 ); + assert(max == 0); #endif - judy_close( judy ); + judy_close(judy); return 0; } diff --git a/src/base/judy/test/judyL2test.cc b/src/base/judy/test/judyL2test.cc index 20ef559a9..fdf16e58e 100644 --- a/src/base/judy/test/judyL2test.cc +++ b/src/base/judy/test/judyL2test.cc @@ -5,13 +5,14 @@ #include "judyL2Array.h" typedef judyL2Array< uint64_t, uint64_t > jl2a; -bool testFind( jl2a & j, uint64_t key, unsigned int count ) { - jl2a::cvector * v = j.find( key ); +bool testFind(jl2a &j, uint64_t key, unsigned int count) +{ + jl2a::cvector *v = j.find(key); std::cout << "find: key " << key << " ..." << std::endl; - if( count > 0 ) { - if( !v || !j.success() || ( v->size() != count ) ) { + if(count > 0) { + if(!v || !j.success() || (v->size() != count)) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if( v ) { + if(v) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -20,13 +21,13 @@ bool testFind( jl2a & j, uint64_t key, unsigned int count ) { // note - this doesn't verify that the right keys are returned, just the right number! jl2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for( ; it != v->end(); it++ ) { + for(; it != v->end(); it++) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if( v || j.success() ) { + if(v || j.success()) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -36,37 +37,38 @@ bool testFind( jl2a & j, uint64_t key, unsigned int count ) { return true; } -int main() { +int main() +{ bool pass = true; jl2a jl; - std::cout.setf( std::ios::boolalpha ); + std::cout.setf(std::ios::boolalpha); // std::cout << "size of judyL2Array: " << sizeof( jl ) << std::endl; - jl.insert( 5, 12 ); - jl.insert( 6, 2 ); - jl.insert( 7, 312 ); - jl.insert( 11, 412 ); - jl.insert( 7, 313 ); - jl2a::cpair kv = jl.atOrAfter( 4 ); + jl.insert(5, 12); + jl.insert(6, 2); + jl.insert(7, 312); + jl.insert(11, 412); + jl.insert(7, 313); + jl2a::cpair kv = jl.atOrAfter(4); std::cout << "atOrAfter test ..." << std::endl; - if( kv.value != 0 && jl.success() ) { - std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; + if(kv.value != 0 && jl.success()) { + std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind( jl, 8, 0 ); - pass &= testFind( jl, 11, 1 ); - pass &= testFind( jl, 7, 2 ); + pass &= testFind(jl, 8, 0); + pass &= testFind(jl, 11, 1); + pass &= testFind(jl, 7, 2); jl.clear(); //TODO test all of judyL2Array - if( pass ) { + if(pass) { std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } else { std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } } \ No newline at end of file diff --git a/src/base/judy/test/judyLtest.cc b/src/base/judy/test/judyLtest.cc index 01ae3d5d7..81815d4d5 100644 --- a/src/base/judy/test/judyLtest.cc +++ b/src/base/judy/test/judyLtest.cc @@ -4,30 +4,31 @@ #include "judyLArray.h" -int main() { - std::cout.setf( std::ios::boolalpha ); +int main() +{ + std::cout.setf(std::ios::boolalpha); judyLArray< uint64_t, uint64_t > jl; - std::cout << "size of judyLArray: " << sizeof( jl ) << std::endl; - jl.insert( 5, 12 ); - jl.insert( 6, 2 ); - jl.insert( 7, 312 ); - jl.insert( 8, 412 ); - judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter( 4 ); + std::cout << "size of judyLArray: " << sizeof(jl) << std::endl; + jl.insert(5, 12); + jl.insert(6, 2); + jl.insert(7, 312); + jl.insert(8, 412); + judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter(4); std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = jl.find( 11 ); - if( v != 0 || jl.success() ) { + long v = jl.find(11); + if(v != 0 || jl.success()) { std::cout << "find: false positive - v: " << v << " success: " << jl.success() << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - v = jl.find( 7 ); - if( v != 312 || !jl.success() ) { + v = jl.find(7); + if(v != 312 || !jl.success()) { std::cout << "find: false negative - v: " << v << " success: " << jl.success() << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } jl.clear(); //TODO test all of judyLArray - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } \ No newline at end of file diff --git a/src/base/judy/test/judyS2test.cc b/src/base/judy/test/judyS2test.cc index ec25f960b..4e0678cd7 100644 --- a/src/base/judy/test/judyS2test.cc +++ b/src/base/judy/test/judyS2test.cc @@ -6,13 +6,14 @@ typedef judyS2Array< uint64_t > js2a; -bool testFind( js2a & j, const char * key, unsigned int count ) { - js2a::cvector * v = j.find( key ); +bool testFind(js2a &j, const char *key, unsigned int count) +{ + js2a::cvector *v = j.find(key); std::cout << "find: key " << key << " ..." << std::endl; - if( count > 0 ) { - if( !v || !j.success() || ( v->size() != count ) ) { + if(count > 0) { + if(!v || !j.success() || (v->size() != count)) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if( v ) { + if(v) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -21,13 +22,13 @@ bool testFind( js2a & j, const char * key, unsigned int count ) { // note - this doesn't verify that the right keys are returned, just the right number! js2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for( ; it != v->end(); it++ ) { + for(; it != v->end(); it++) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if( v || j.success() ) { + if(v || j.success()) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -37,39 +38,40 @@ bool testFind( js2a & j, const char * key, unsigned int count ) { return true; } -int main() { +int main() +{ bool pass = true; - std::cout.setf( std::ios::boolalpha ); + std::cout.setf(std::ios::boolalpha); - js2a js( 255 ); - js.insert( "blah", 1234 ); - js.insert( "bah", 124 ); - js.insert( "blh", 123 ); - js.insert( "blh", 4123 ); - js.insert( "bla", 134 ); - js.insert( "bh", 234 ); + js2a js(255); + js.insert("blah", 1234); + js.insert("bah", 124); + js.insert("blh", 123); + js.insert("blh", 4123); + js.insert("bla", 134); + js.insert("bh", 234); - js2a::cpair kv = js.atOrAfter( "ab" ); + js2a::cpair kv = js.atOrAfter("ab"); std::cout << "atOrAfter test ..." << std::endl; - if( kv.value != 0 && js.success() ) { - std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; + if(kv.value != 0 && js.success()) { + std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind( js, "sdafsd", 0 ); - pass &= testFind( js, "bah", 1 ); - pass &= testFind( js, "blh", 2 ); + pass &= testFind(js, "sdafsd", 0); + pass &= testFind(js, "bah", 1); + pass &= testFind(js, "blh", 2); js.clear(); //TODO test all of judyS2Array - if( pass ) { + if(pass) { std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } else { std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } } \ No newline at end of file diff --git a/src/base/judy/test/judyStest.cc b/src/base/judy/test/judyStest.cc index 3d620b015..f6fc74ffa 100644 --- a/src/base/judy/test/judyStest.cc +++ b/src/base/judy/test/judyStest.cc @@ -4,40 +4,41 @@ #include "judySArray.h" -int main() { +int main() +{ bool pass = true; - std::cout.setf( std::ios::boolalpha ); + std::cout.setf(std::ios::boolalpha); - judySArray< uint64_t > js( 255 ); - js.insert( "blah", 1234 ); - js.insert( "bah", 124 ); - js.insert( "blh", 123 ); - js.insert( "bla", 134 ); - js.insert( "bh", 234 ); + judySArray< uint64_t > js(255); + js.insert("blah", 1234); + js.insert("bah", 124); + js.insert("blh", 123); + js.insert("bla", 134); + js.insert("bh", 234); - judySArray< uint64_t >::pair kv = js.atOrAfter( "ab" ); + judySArray< uint64_t >::pair kv = js.atOrAfter("ab"); //TODO if()... std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = js.find( "sdafsd" ); - if( v != 0 || js.success() ) { + long v = js.find("sdafsd"); + if(v != 0 || js.success()) { std::cout << "find: false positive - v: " << v << " success: " << js.success() << std::endl; pass = false; } - v = js.find( "bah" ); - if( v != 124 || !js.success() ) { + v = js.find("bah"); + if(v != 124 || !js.success()) { std::cout << "find: false negative - v: " << v << " success: " << js.success() << std::endl; pass = false; } //TODO test all of judySArray - if( pass ) { + if(pass) { std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } else { std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } } \ No newline at end of file diff --git a/src/base/judy/test/pennySort.c b/src/base/judy/test/pennySort.c index a279b1a70..0bc3a4f42 100644 --- a/src/base/judy/test/pennySort.c +++ b/src/base/judy/test/pennySort.c @@ -40,16 +40,17 @@ unsigned int MaxMem = 0; // Also, the file to search judy is hardcoded to skew1_1. -int main( int argc, char ** argv ) { +int main(int argc, char **argv) +{ unsigned char buff[1024]; JudySlot max = 0; - JudySlot * cell; - FILE * in, *out; - void * judy; + JudySlot *cell; + FILE *in, *out; + void *judy; unsigned int len; unsigned int idx; #ifdef ASKITIS - char * askitis; + char *askitis; int prev, off; float insert_real_time = 0.0; float search_real_time = 0.0; @@ -61,176 +62,176 @@ int main( int argc, char ** argv ) { #endif #endif - if( argc > 1 ) { - in = fopen( argv[1], "rb" ); + if(argc > 1) { + in = fopen(argv[1], "rb"); } else { in = stdin; } - if( argc > 2 ) { - out = fopen( argv[2], "wb" ); + if(argc > 2) { + out = fopen(argv[2], "wb"); } else { out = stdout; } - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); + setvbuf(out, NULL, _IOFBF, 4096 * 1024); - if( !in ) { - fprintf( stderr, "unable to open input file\n" ); + if(!in) { + fprintf(stderr, "unable to open input file\n"); } - if( !out ) { - fprintf( stderr, "unable to open output file\n" ); + if(!out) { + fprintf(stderr, "unable to open output file\n"); } - if( argc > 6 ) { - PennyRecs = atoi( argv[6] ); + if(argc > 6) { + PennyRecs = atoi(argv[6]); } - if( argc > 5 ) { - PennyOff = atoi( argv[5] ); + if(argc > 5) { + PennyOff = atoi(argv[5]); } - if( argc > 4 ) { - PennyLine = atoi( argv[4] ); + if(argc > 4) { + PennyLine = atoi(argv[4]); } - PennyMerge = ( unsigned long long )PennyLine * PennyRecs; + PennyMerge = (unsigned long long)PennyLine * PennyRecs; - if( argc > 3 ) { - PennyKey = atoi( argv[3] ); - sort( in, argv[2] ); - return merge( out, argv[2] ); + if(argc > 3) { + PennyKey = atoi(argv[3]); + sort(in, argv[2]); + return merge(out, argv[2]); } #ifdef ASKITIS - judy = judy_open( 1024, 0 ); + judy = judy_open(1024, 0); // build judy array - size = lseek( fileno( in ), 0L, 2 ); - askitis = malloc( size ); - lseek( fileno( in ), 0L, 0 ); - read( fileno( in ), askitis, size ); + size = lseek(fileno(in), 0L, 2); + askitis = malloc(size); + lseek(fileno(in), 0L, 0); + read(fileno(in), askitis, size); prev = 0; // naskitis.com: // Start the timer. #if !defined(_WIN32) - gettimeofday( &start, NULL ); + gettimeofday(&start, NULL); #else - time( start ); + time(start); #endif - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *( judy_cell( judy, askitis + prev, off - prev ) ) += 1; // count instances of string + for(off = 0; off < size; off++) + if(askitis[off] == '\n') { + *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) - gettimeofday( &stop, NULL ); + gettimeofday(&stop, NULL); - insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * ( stop.tv_usec - start.tv_usec ); + insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); insert_real_time = insert_real_time / 1000.0; #else - time( stop ); + time(stop); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free( askitis ); - fprintf( stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time ); - fprintf( stderr, "%-20s %d\n", "Words:", Words ); - fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); - fprintf( stderr, "%-20s %d\n", "Found:", Found ); + free(askitis); + fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); + fprintf(stderr, "%-20s %d\n", "Words:", Words); + fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); + fprintf(stderr, "%-20s %d\n", "Found:", Found); Words = 0; Inserts = 0; Found = 0; // search judy array - if( in = freopen( "skew1_1", "rb", in ) ) { - size = lseek( fileno( in ), 0L, 2 ); + if(in = freopen("skew1_1", "rb", in)) { + size = lseek(fileno(in), 0L, 2); } else { - exit( 0 ); + exit(0); } - askitis = malloc( size ); - lseek( fileno( in ), 0L, 0 ); - read( fileno( in ), askitis, size ); + askitis = malloc(size); + lseek(fileno(in), 0L, 0); + read(fileno(in), askitis, size); prev = 0; #if !defined(_WIN32) - gettimeofday( &start, NULL ); + gettimeofday(&start, NULL); #else - time( start ); + time(start); #endif - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *judy_cell( judy, askitis + prev, off - prev ) += 1; + for(off = 0; off < size; off++) + if(askitis[off] == '\n') { + *judy_cell(judy, askitis + prev, off - prev) += 1; prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) - gettimeofday( &stop, NULL ); - search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 - * ( stop.tv_usec - start.tv_usec ); + gettimeofday(&stop, NULL); + search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 + * (stop.tv_usec - start.tv_usec); search_real_time = search_real_time / 1000.0; #else - time( stop ); + time(stop); search_real_time = *stop - *start; #endif // naskitis.com: // To do: report a count on the number of strings found. - fprintf( stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time ); - fprintf( stderr, "%-20s %d\n", "Words:", Words ); - fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); - fprintf( stderr, "%-20s %d\n", "Found:", Found ); - exit( 0 ); + fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); + fprintf(stderr, "%-20s %d\n", "Words:", Words); + fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); + fprintf(stderr, "%-20s %d\n", "Found:", Found); + exit(0); #endif - judy = judy_open( 1024, 0 ); + judy = judy_open(1024, 0); - while( fgets( ( char * )buff, sizeof( buff ), in ) ) { - if( len = strlen( ( const char * )buff ) ) { + while(fgets((char *)buff, sizeof(buff), in)) { + if(len = strlen((const char *)buff)) { buff[--len] = 0; // remove LF } - *( judy_cell( judy, buff, len ) ) += 1; // count instances of string + *(judy_cell(judy, buff, len)) += 1; // count instances of string max++; } - fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); + fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt( judy, NULL, 0 ); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { - len = judy_key( judy, buff, sizeof( buff ) ); - for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates - fwrite( buff, len, 1, out ); - fputc( '\n', out ); + if(cell) do { + len = judy_key(judy, buff, sizeof(buff)); + for(idx = 0; idx < *cell; idx++) { // spit out duplicates + fwrite(buff, len, 1, out); + fputc('\n', out); } - } while( cell = judy_nxt( judy ) ); + } while(cell = judy_nxt(judy)); #if 0 // test deletion all the way to an empty tree - if( cell = judy_prv( judy ) ) + if(cell = judy_prv(judy)) do { max -= *cell; - } while( cell = judy_del( judy ) ); + } while(cell = judy_del(judy)); - assert( max == 0 ); + assert(max == 0); #endif - judy_close( judy ); + judy_close(judy); return 0; } diff --git a/src/base/judy/test/sort.c b/src/base/judy/test/sort.c index e483b92e0..53a460312 100644 --- a/src/base/judy/test/sort.c +++ b/src/base/judy/test/sort.c @@ -24,7 +24,7 @@ // memory map input file and sort // define pennysort parameters -unsigned int PennyRecs = ( 4096 * 400 ); // records to sort to temp files +unsigned int PennyRecs = (4096 * 400); // records to sort to temp files unsigned int PennyLine = 100; // length of input record unsigned int PennyKey = 10; // length of input key unsigned int PennyOff = 0; // key offset in input record @@ -34,15 +34,16 @@ unsigned int PennyPasses; // number of intermediate files created unsigned int PennySortTime; // cpu time to run sort unsigned int PennyMergeTime; // cpu time to run merge -void sort( FILE * infile, char * outname ) { +void sort(FILE *infile, char *outname) +{ unsigned long long size, off, offset, part; - int ifd = fileno( infile ); + int ifd = fileno(infile); char filename[512]; - PennySort * line; - JudySlot * cell; - unsigned char * inbuff; - void * judy; - FILE * out; + PennySort *line; + JudySlot *cell; + unsigned char *inbuff; + void *judy; + FILE *out; #if defined(_WIN32) HANDLE hndl, fm; DWORD hiword; @@ -51,149 +52,150 @@ void sort( FILE * infile, char * outname ) { #else struct tms buff[1]; #endif - time_t start = time( NULL ); + time_t start = time(NULL); - if( PennyOff + PennyKey > PennyLine ) { - fprintf( stderr, "Key Offset + Key Length > Record Length\n" ), exit( 1 ); + if(PennyOff + PennyKey > PennyLine) { + fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); } offset = 0; PennyPasses = 0; #if defined(_WIN32) - hndl = ( HANDLE )_get_osfhandle( ifd ); - size = GetFileSize( hndl, &hiword ); - fm = CreateFileMapping( hndl, NULL, PAGE_READONLY, hiword, ( DWORD )size, NULL ); - if( !fm ) { - fprintf( stderr, "CreateFileMapping error %d\n", GetLastError() ), exit( 1 ); + hndl = (HANDLE)_get_osfhandle(ifd); + size = GetFileSize(hndl, &hiword); + fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); + if(!fm) { + fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); } - size |= ( unsigned long long )hiword << 32; + size |= (unsigned long long)hiword << 32; #else - size = lseek( ifd, 0L, 2 ); + size = lseek(ifd, 0L, 2); #endif - while( offset < size ) { + while(offset < size) { #if defined(_WIN32) part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part ); - if( !inbuff ) { - fprintf( stderr, "MapViewOfFile error %d\n", GetLastError() ), exit( 1 ); + inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); + if(!inbuff) { + fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); } #else - inbuff = mmap( NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset ); + inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); - if( inbuff == MAP_FAILED ) { - fprintf( stderr, "mmap error %d\n", errno ), exit( 1 ); + if(inbuff == MAP_FAILED) { + fprintf(stderr, "mmap error %d\n", errno), exit(1); } - if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL ) < 0 ) { - fprintf( stderr, "madvise error %d\n", errno ); + if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { + fprintf(stderr, "madvise error %d\n", errno); } #endif - judy = judy_open( PennyKey, 0 ); + judy = judy_open(PennyKey, 0); off = 0; // build judy array from mapped input chunk - while( offset + off < size && off < PennyMerge ) { - line = judy_data( judy, sizeof( PennySort ) ); - cell = judy_cell( judy, inbuff + off + PennyOff, PennyKey ); - line->next = *( void ** )cell; + while(offset + off < size && off < PennyMerge) { + line = judy_data(judy, sizeof(PennySort)); + cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); + line->next = *(void **)cell; line->buff = inbuff + off; - *( PennySort ** )cell = line; + *(PennySort **)cell = line; off += PennyLine; } - sprintf( filename, "%s.%d", outname, PennyPasses ); - out = fopen( filename, "wb" ); - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); + sprintf(filename, "%s.%d", outname, PennyPasses); + out = fopen(filename, "wb"); + setvbuf(out, NULL, _IOFBF, 4096 * 1024); #ifndef _WIN32 - if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM ) < 0 ) { - fprintf( stderr, "madvise error %d\n", errno ); + if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { + fprintf(stderr, "madvise error %d\n", errno); } #endif // write judy array in sorted order to temporary file - cell = judy_strt( judy, NULL, 0 ); + cell = judy_strt(judy, NULL, 0); - if( cell ) do { - line = *( PennySort ** )cell; + if(cell) do { + line = *(PennySort **)cell; do { - fwrite( line->buff, PennyLine, 1, out ); - } while( line = line->next ); - } while( cell = judy_nxt( judy ) ); + fwrite(line->buff, PennyLine, 1, out); + } while(line = line->next); + } while(cell = judy_nxt(judy)); #if defined(_WIN32) - UnmapViewOfFile( inbuff ); + UnmapViewOfFile(inbuff); #else - munmap( inbuff, PennyMerge ); + munmap(inbuff, PennyMerge); #endif - judy_close( judy ); + judy_close(judy); offset += off; - fflush( out ); - fclose( out ); + fflush(out); + fclose(out); PennyPasses++; } - fprintf( stderr, "End Sort %llu secs", ( unsigned long long ) time( NULL ) - start ); + fprintf(stderr, "End Sort %llu secs", (unsigned long long) time(NULL) - start); #if defined(_WIN32) - CloseHandle( fm ); - GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); - PennySortTime = *( unsigned long long * )user / 10000000; + CloseHandle(fm); + GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); + PennySortTime = *(unsigned long long *)user / 10000000; #else - times( buff ); + times(buff); PennySortTime = buff->tms_utime / 100; #endif - fprintf( stderr, " Cpu %d\n", PennySortTime ); + fprintf(stderr, " Cpu %d\n", PennySortTime); } -int merge( FILE * out, char * outname ) { - time_t start = time( NULL ); +int merge(FILE *out, char *outname) +{ + time_t start = time(NULL); char filename[512]; - JudySlot * cell; + JudySlot *cell; unsigned int nxt, idx; - unsigned char ** line; - unsigned int * next; - void * judy; - FILE ** in; + unsigned char **line; + unsigned int *next; + void *judy; + FILE **in; - next = calloc( PennyPasses + 1, sizeof( unsigned int ) ); - line = calloc( PennyPasses, sizeof( void * ) ); - in = calloc( PennyPasses, sizeof( void * ) ); + next = calloc(PennyPasses + 1, sizeof(unsigned int)); + line = calloc(PennyPasses, sizeof(void *)); + in = calloc(PennyPasses, sizeof(void *)); - judy = judy_open( PennyKey, 0 ); + judy = judy_open(PennyKey, 0); // initialize merge with one record from each temp file - for( idx = 0; idx < PennyPasses; idx++ ) { - sprintf( filename, "%s.%d", outname, idx ); - in[idx] = fopen( filename, "rb" ); - line[idx] = malloc( PennyLine ); - setvbuf( in[idx], NULL, _IOFBF, 4096 * 1024 ); - fread( line[idx], PennyLine, 1, in[idx] ); - cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); - next[idx + 1] = *( unsigned int * )cell; + for(idx = 0; idx < PennyPasses; idx++) { + sprintf(filename, "%s.%d", outname, idx); + in[idx] = fopen(filename, "rb"); + line[idx] = malloc(PennyLine); + setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); + fread(line[idx], PennyLine, 1, in[idx]); + cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; } // output records, replacing smallest each time - while( cell = judy_strt( judy, NULL, 0 ) ) { - nxt = *( unsigned int * )cell; - judy_del( judy ); + while(cell = judy_strt(judy, NULL, 0)) { + nxt = *(unsigned int *)cell; + judy_del(judy); // process duplicates - while( idx = nxt ) { + while(idx = nxt) { nxt = next[idx--]; - fwrite( line[idx], PennyLine, 1, out ); + fwrite(line[idx], PennyLine, 1, out); - if( fread( line[idx], PennyLine, 1, in[idx] ) ) { - cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); - next[idx + 1] = *( unsigned int * )cell; + if(fread(line[idx], PennyLine, 1, in[idx])) { + cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; } else { next[idx + 1] = 0; @@ -201,33 +203,33 @@ int merge( FILE * out, char * outname ) { } } - for( idx = 0; idx < PennyPasses; idx++ ) { - fclose( in[idx] ); - free( line[idx] ); + for(idx = 0; idx < PennyPasses; idx++) { + fclose(in[idx]); + free(line[idx]); } - free( line ); - free( next ); - free( in ); + free(line); + free(next); + free(in); - fprintf( stderr, "End Merge %llu secs", ( unsigned long long ) time( NULL ) - start ); + fprintf(stderr, "End Merge %llu secs", (unsigned long long) time(NULL) - start); #ifdef _WIN32 { FILETIME dummy[1]; FILETIME user[1]; - GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); - PennyMergeTime = *( unsigned long long * )user / 10000000; + GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); + PennyMergeTime = *(unsigned long long *)user / 10000000; } #else { struct tms buff[1]; - times( buff ); + times(buff); PennyMergeTime = buff->tms_utime / 100; } #endif - fprintf( stderr, " Cpu %d\n", PennyMergeTime - PennySortTime ); - judy_close( judy ); - fflush( out ); - fclose( out ); + fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); + judy_close(judy); + fflush(out); + fclose(out); return 0; } diff --git a/src/base/judy/test/sort.h b/src/base/judy/test/sort.h index 785e58d69..f3f497e72 100644 --- a/src/base/judy/test/sort.h +++ b/src/base/judy/test/sort.h @@ -51,8 +51,8 @@ extern unsigned int PennyOff; extern unsigned long long PennyMerge; typedef struct { - void * buff; // record pointer in input file map - void * next; // duplicate chain + void *buff; // record pointer in input file map + void *next; // duplicate chain } PennySort; #endif //SORT_H \ No newline at end of file diff --git a/src/base/path2str.c b/src/base/path2str.c index 6f5aedd7c..a4f88ee3a 100644 --- a/src/base/path2str.c +++ b/src/base/path2str.c @@ -6,21 +6,22 @@ /* for windows, rewrite backslashes in paths * that will be written to generated code */ -const char * path2str_fn( const char * fileMacro ) { - static char * result = 0; +const char *path2str_fn(const char *fileMacro) +{ + static char *result = 0; static size_t rlen = 0; - char * p; - if( rlen < strlen( fileMacro ) ) { - if( result ) { - sc_free( result ); + char *p; + if(rlen < strlen(fileMacro)) { + if(result) { + sc_free(result); } - rlen = strlen( fileMacro ); - result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 ); + rlen = strlen(fileMacro); + result = (char *)sc_malloc(rlen * sizeof(char) + 1); } - strcpy( result, fileMacro ); + strcpy(result, fileMacro); p = result; - while( *p ) { - if( *p == '\\' ) { + while(*p) { + if(*p == '\\') { *p = '/'; } p++; diff --git a/src/base/path2str.h b/src/base/path2str.h index 84155cd9f..57f735142 100644 --- a/src/base/path2str.h +++ b/src/base/path2str.h @@ -9,7 +9,7 @@ * silence "unknown escape sequence" warning when contents of __FILE__ * are fprintf'd into string in generated code */ -SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro ); +SC_BASE_EXPORT const char *path2str_fn(const char *fileMacro); #ifdef _WIN32 # define path2str(path) path2str_fn(path) diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index 44f085f2f..a4dbab273 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -21,11 +21,12 @@ #include /// mem values in kb, times in ms (granularity may be higher than 1ms) -benchVals getMemAndTime( ) { +benchVals getMemAndTime() +{ benchVals vals; #ifdef __linux__ // adapted from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c - std::ifstream stat_stream( "/proc/self/stat", std::ios_base::in ); + std::ifstream stat_stream("/proc/self/stat", std::ios_base::in); // dummy vars for leading entries in stat that we don't care about std::string pid, comm, state, ppid, pgrp, session, tty_nr; @@ -42,11 +43,11 @@ benchVals getMemAndTime( ) { >> utime >> stime >> cutime >> cstime >> priority >> nice >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest - long page_size_kb = sysconf( _SC_PAGE_SIZE ) / 1024; // in case x86-64 is configured to use 2MB pages + long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages vals.physMemKB = rss * page_size_kb; - vals.virtMemKB = ( vsize / 1024 ) - vals.physMemKB; - vals.userMilliseconds = ( utime * 1000 ) / sysconf( _SC_CLK_TCK ); - vals.sysMilliseconds = ( stime * 1000 ) / sysconf( _SC_CLK_TCK ); + vals.virtMemKB = (vsize / 1024) - vals.physMemKB; + vals.userMilliseconds = (utime * 1000) / sysconf(_SC_CLK_TCK); + vals.sysMilliseconds = (stime * 1000) / sysconf(_SC_CLK_TCK); #elif defined(__APPLE__) // http://stackoverflow.com/a/1911863/382458 #elif defined(_WIN32) @@ -56,7 +57,7 @@ benchVals getMemAndTime( ) { long page_size_kb = 1024; ULARGE_INTEGER kTime, uTime; - if( GetProcessMemoryInfo( GetCurrentProcess(), &MemoryCntrs, sizeof( MemoryCntrs ) ) ) { + if(GetProcessMemoryInfo(GetCurrentProcess(), &MemoryCntrs, sizeof(MemoryCntrs))) { vals.physMemKB = MemoryCntrs.PeakWorkingSetSize / page_size_kb; vals.virtMemKB = MemoryCntrs.PeakPagefileUsage / page_size_kb; } else { @@ -64,12 +65,12 @@ benchVals getMemAndTime( ) { vals.virtMemKB = 0; } - if( GetProcessTimes( GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime ) ) { - assert( sizeof( FILETIME ) == sizeof( ULARGE_INTEGER ) ); - memcpy( &kTime, &KernelTime, sizeof( FILETIME ) ); - memcpy( &uTime, &UserTime, sizeof( FILETIME ) ); - vals.userMilliseconds = ( long )( uTime.QuadPart / 100000L ); - vals.sysMilliseconds = ( long )( kTime.QuadPart / 100000L ); + if(GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime)) { + assert(sizeof(FILETIME) == sizeof(ULARGE_INTEGER)); + memcpy(&kTime, &KernelTime, sizeof(FILETIME)); + memcpy(&uTime, &UserTime, sizeof(FILETIME)); + vals.userMilliseconds = (long)(uTime.QuadPart / 100000L); + vals.sysMilliseconds = (long)(kTime.QuadPart / 100000L); } else { vals.userMilliseconds = 0; vals.sysMilliseconds = 0; @@ -82,33 +83,37 @@ benchVals getMemAndTime( ) { // --------------------- benchmark class --------------------- -benchmark::benchmark( std::string description, bool debugMessages, std::ostream & o_stream ): ostr( o_stream ), - descr( description ), debug( debugMessages ), stopped( false ) { - initialVals = getMemAndTime( ); +benchmark::benchmark(std::string description, bool debugMessages, std::ostream &o_stream): ostr(o_stream), + descr(description), debug(debugMessages), stopped(false) +{ + initialVals = getMemAndTime(); } -benchmark::~benchmark() { - if( !stopped ) { - stop( ); - if( debug ) { +benchmark::~benchmark() +{ + if(!stopped) { + stop(); + if(debug) { ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; } - out( ); + out(); } } -void benchmark::stop( ) { - if( stopped ) { +void benchmark::stop() +{ + if(stopped) { std::cerr << "benchmark::stop(): tried to stop a benchmark that was already stopped!" << std::endl; } else { - laterVals = getMemAndTime( ); + laterVals = getMemAndTime(); stopped = true; } } -benchVals benchmark::get( ) { - if( !stopped ) { - laterVals = getMemAndTime( ); +benchVals benchmark::get() +{ + if(!stopped) { + laterVals = getMemAndTime(); } benchVals delta; delta.physMemKB = laterVals.physMemKB - initialVals.physMemKB; @@ -117,31 +122,36 @@ benchVals benchmark::get( ) { delta.userMilliseconds = laterVals.userMilliseconds - initialVals.userMilliseconds; //If vm is negative, the memory had been requested before initialVals was set. Don't count it - if( delta.virtMemKB < 0 ) { + if(delta.virtMemKB < 0) { delta.physMemKB -= delta.virtMemKB; delta.virtMemKB = 0; } return delta; } -void benchmark::reset( std::string description ) { +void benchmark::reset(std::string description) +{ descr = description; reset(); } -void benchmark::reset( ) { +void benchmark::reset() +{ stopped = false; initialVals = getMemAndTime(); } -std::string benchmark::str( ) { - return str( get( ) ); +std::string benchmark::str() +{ + return str(get()); } -void benchmark::out() { - ostr << str( ) << std::endl; +void benchmark::out() +{ + ostr << str() << std::endl; } -std::string benchmark::str( const benchVals & bv ) { +std::string benchmark::str(const benchVals &bv) +{ std::stringstream ss; ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index 8512bd892..70b5876f5 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -13,17 +13,17 @@ extern "C" { #endif - typedef struct { - long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; - } benchVals; +typedef struct { + long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; +} benchVals; - /** return a benchVals struct with four current statistics for this process: - * virtual and physical memory use in kb, - * user and system cpu time in ms - * - * not yet implemented for OSX or Windows. - */ - SC_BASE_EXPORT benchVals getMemAndTime( ); +/** return a benchVals struct with four current statistics for this process: + * virtual and physical memory use in kb, + * user and system cpu time in ms + * + * not yet implemented for OSX or Windows. + */ +SC_BASE_EXPORT benchVals getMemAndTime(); #ifdef __cplusplus } @@ -39,37 +39,38 @@ extern "C" { * depends on getMemAndTime() above - may not work on all platforms. */ -class SC_BASE_EXPORT benchmark { +class SC_BASE_EXPORT benchmark +{ protected: benchVals initialVals, laterVals; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::ostream & ostr; + std::ostream &ostr; std::string descr; #ifdef _MSC_VER #pragma warning( pop ) #endif bool debug, stopped; public: - benchmark( std::string description = "", bool debugMessages = true, std::ostream & o_stream = std::cout ); + benchmark(std::string description = "", bool debugMessages = true, std::ostream &o_stream = std::cout); /// if 'stopped' is false, uses str(true) to print to ostream - ~benchmark( ); - void reset( ); - void reset( std::string description ); - benchVals get( ); - void stop( ); + ~benchmark(); + void reset(); + void reset(std::string description); + benchVals get(); + void stop(); /// converts data member 'laterVals' into a string and returns it - std::string str( ); + std::string str(); /// outputs result of str() on ostream 'ostr' - void out( ); + void out(); /// converts 'bv' into a string, prefixed by data member 'descr' - std::string str( const benchVals & bv ); + std::string str(const benchVals &bv); }; diff --git a/src/base/sc_getopt.cc b/src/base/sc_getopt.cc index 01e925b56..e135f1f31 100644 --- a/src/base/sc_getopt.cc +++ b/src/base/sc_getopt.cc @@ -152,34 +152,35 @@ // /////////////////////////////////////////////////////////////////////////////// -char * sc_optarg; // global argument pointer +char *sc_optarg; // global argument pointer int sc_optind = 0; // global argv index -int sc_getopt( int argc, char * argv[], char * optstring ) { - static char * next = NULL; - if( sc_optind == 0 ) { +int sc_getopt(int argc, char *argv[], char *optstring) +{ + static char *next = NULL; + if(sc_optind == 0) { next = NULL; } sc_optarg = NULL; - if( next == NULL || *next == '\0' ) { - if( sc_optind == 0 ) { + if(next == NULL || *next == '\0') { + if(sc_optind == 0) { sc_optind++; } - if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + if(sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0') { sc_optarg = NULL; - if( sc_optind < argc ) { + if(sc_optind < argc) { sc_optarg = argv[sc_optind]; } return EOF; } - if( strcmp( argv[sc_optind], "--" ) == 0 ) { + if(strcmp(argv[sc_optind], "--") == 0) { sc_optind++; sc_optarg = NULL; - if( sc_optind < argc ) { + if(sc_optind < argc) { sc_optarg = argv[sc_optind]; } return EOF; @@ -191,18 +192,18 @@ int sc_getopt( int argc, char * argv[], char * optstring ) { } char c = *next++; - char * cp = strchr( optstring, c ); + char *cp = strchr(optstring, c); - if( cp == NULL || c == ':' ) { + if(cp == NULL || c == ':') { return '?'; } cp++; - if( *cp == ':' ) { - if( *next != '\0' ) { + if(*cp == ':') { + if(*next != '\0') { sc_optarg = next; next = NULL; - } else if( sc_optind < argc ) { + } else if(sc_optind < argc) { sc_optarg = argv[sc_optind]; sc_optind++; } else { diff --git a/src/base/sc_getopt.h b/src/base/sc_getopt.h index e1421a7bf..2eedcdf3b 100644 --- a/src/base/sc_getopt.h +++ b/src/base/sc_getopt.h @@ -20,10 +20,10 @@ extern "C" { #endif - extern SC_BASE_EXPORT int sc_optind, sc_opterr; - extern SC_BASE_EXPORT char * sc_optarg; +extern SC_BASE_EXPORT int sc_optind, sc_opterr; +extern SC_BASE_EXPORT char *sc_optarg; - int SC_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring ); +int SC_BASE_EXPORT sc_getopt(int argc, char *argv[], char *optstring); #ifdef __cplusplus } diff --git a/src/base/sc_memmgr.cc b/src/base/sc_memmgr.cc index 262d26e28..223bac4db 100644 --- a/src/base/sc_memmgr.cc +++ b/src/base/sc_memmgr.cc @@ -15,21 +15,22 @@ /** sc_memmgr_error definition */ -class sc_memmgr_error { +class sc_memmgr_error +{ private: std::string _srcfile; unsigned int _srcline; unsigned int _occurences; public: - sc_memmgr_error( const std::string & file, const unsigned int line ); - sc_memmgr_error( const sc_memmgr_error & rhs ); - ~sc_memmgr_error( void ); + sc_memmgr_error(const std::string &file, const unsigned int line); + sc_memmgr_error(const sc_memmgr_error &rhs); + ~sc_memmgr_error(void); - bool operator<( const sc_memmgr_error & rhs ) const; + bool operator<(const sc_memmgr_error &rhs) const; - std::string getsrcfile( void ) const; - unsigned int getsrcline( void ) const; - unsigned int getoccurences( void ) const; + std::string getsrcfile(void) const; + unsigned int getsrcline(void) const; + unsigned int getoccurences(void) const; }; typedef std::set sc_memmgr_errors; @@ -38,24 +39,25 @@ typedef std::set::iterator sc_memmgr_error_iterator; /** sc_memmgr_record definition */ -class sc_memmgr_record { +class sc_memmgr_record +{ private: - void * _addr; + void *_addr; size_t _size; std::string _srcfile; unsigned int _srcline; public: - sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ); - sc_memmgr_record( void * addr ); - sc_memmgr_record( const sc_memmgr_record & rhs ); - ~sc_memmgr_record( void ); + sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line); + sc_memmgr_record(void *addr); + sc_memmgr_record(const sc_memmgr_record &rhs); + ~sc_memmgr_record(void); - bool operator<( const sc_memmgr_record & rhs ) const; + bool operator<(const sc_memmgr_record &rhs) const; - void * getaddr( void ) const; - size_t getsize( void ) const; - std::string getsrcfile( void ) const; - unsigned int getsrcline( void ) const; + void *getaddr(void) const; + size_t getsize(void) const; + std::string getsrcfile(void) const; + unsigned int getsrcline(void) const; }; typedef std::set sc_memmgr_records; @@ -66,7 +68,8 @@ typedef std::set::iterator sc_memmgr_record_iterator; /** sc_memmgr definition */ -class sc_memmgr { +class sc_memmgr +{ private: #ifdef SC_MEMMGR_ENABLE_CHECKS bool _record_insert_busy, _record_erase_busy; @@ -81,12 +84,12 @@ class sc_memmgr { #endif /* SC_MEMMGR_ENABLE_CHECKS */ protected: public: - sc_memmgr( void ); - ~sc_memmgr( void ); + sc_memmgr(void); + ~sc_memmgr(void); - void * allocate( size_t size, const char * file, const int line ); - void * reallocate( void * addr, size_t size, const char * file, const int line ); - void deallocate( void * addr, const char * file, const int line ); + void *allocate(size_t size, const char *file, const int line); + void *reallocate(void *addr, size_t size, const char *file, const int line); + void deallocate(void *addr, const char *file, const int line); }; /** @@ -102,20 +105,24 @@ sc_memmgr memmgr; */ extern "C" { - void * sc_malloc_fn( unsigned int size, const char * file, const int line ) { - return memmgr.allocate( size, file, line ); + void *sc_malloc_fn(unsigned int size, const char *file, const int line) + { + return memmgr.allocate(size, file, line); } - void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) { - return memmgr.allocate( count * size, file, line ); + void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line) + { + return memmgr.allocate(count * size, file, line); } - void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) { - return memmgr.reallocate( addr, size, file, line ); + void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line) + { + return memmgr.reallocate(addr, size, file, line); } - void sc_free_fn( void * addr ) { - memmgr.deallocate( addr, "", 0 ); + void sc_free_fn(void *addr) + { + memmgr.deallocate(addr, "", 0); } } @@ -123,22 +130,26 @@ extern "C" { /** c++ memory operators implementation */ -void * sc_operator_new( size_t size, const char * file, const int line ) { - return memmgr.allocate( size, file, line ); +void *sc_operator_new(size_t size, const char *file, const int line) +{ + return memmgr.allocate(size, file, line); } -void sc_operator_delete( void * addr, const char * file, const int line ) { - memmgr.deallocate( addr, file, line ); +void sc_operator_delete(void *addr, const char *file, const int line) +{ + memmgr.deallocate(addr, file, line); } -void sc_operator_delete( void * addr ) { - memmgr.deallocate( addr, "", 0 ); +void sc_operator_delete(void *addr) +{ + memmgr.deallocate(addr, "", 0); } /** sc_memmgr implementation */ -sc_memmgr::sc_memmgr( void ) { +sc_memmgr::sc_memmgr(void) +{ #ifdef SC_MEMMGR_ENABLE_CHECKS _record_insert_busy = false; _record_erase_busy = false; @@ -159,28 +170,29 @@ sc_memmgr::sc_memmgr( void ) { All records still present when sc_memmgr instance is destroyed can be considered as memory leaks. */ -sc_memmgr::~sc_memmgr( void ) { +sc_memmgr::~sc_memmgr(void) +{ #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator irecord; sc_memmgr_errors errors; sc_memmgr_error_iterator ierror; // Check if total allocated equals total deallocated - if( _allocated_total != _deallocated_total ) { + if(_allocated_total != _deallocated_total) { // todo: generate warning for possible memory leaks, enable full memory leak checking - fprintf( stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total ); + fprintf(stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total); } // Compact leaks into an error list to prevent same leak being reported multiple times. _record_insert_busy = true; _record_erase_busy = true; - for( irecord = _records.begin(); + for(irecord = _records.begin(); irecord != _records.end(); - irecord ++ ) { - sc_memmgr_error error( irecord->getsrcfile(), irecord->getsrcline() ); - ierror = errors.find( error ); - if( ierror == errors.end() ) { - errors.insert( error ); + irecord ++) { + sc_memmgr_error error(irecord->getsrcfile(), irecord->getsrcline()); + ierror = errors.find(error); + if(ierror == errors.end()) { + errors.insert(error); } //else // ierror->occurences ++; @@ -189,11 +201,11 @@ sc_memmgr::~sc_memmgr( void ) { _record_erase_busy = false; // Loop through memory leaks to generate/buffer errors - for( ierror = errors.begin(); + for(ierror = errors.begin(); ierror != errors.end(); - ierror ++ ) { + ierror ++) { // todo: generate error for memory leak - fprintf( stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline() ); + fprintf(stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline()); } // Clear remaining records @@ -204,14 +216,15 @@ sc_memmgr::~sc_memmgr( void ) { #endif /* SC_MEMMGR_ENABLE_CHECKS */ } -void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { - void * addr; +void *sc_memmgr::allocate(size_t size, const char *file, const int line) +{ + void *addr; // Allocate - addr = malloc( size ); - if( addr == NULL ) { + addr = malloc(size); + if(addr == NULL) { // todo: error allocation failed - fprintf( stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line ); + fprintf(stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line); } // Some stl implementations (for example debian gcc) use the new operator to construct @@ -219,15 +232,15 @@ void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { // for this operation, this would result in an infinite loop. This is fixed by the // _record_insert_busy flag. #ifdef SC_MEMMGR_ENABLE_CHECKS - if( !_record_insert_busy ) { + if(!_record_insert_busy) { // Store record for this allocation _record_insert_busy = true; - _records.insert( sc_memmgr_record( addr, size, file, line ) ); + _records.insert(sc_memmgr_record(addr, size, file, line)); _record_insert_busy = false; // Update stats _allocated += size; - if( _allocated > _maximum_allocated ) { + if(_allocated > _maximum_allocated) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -237,16 +250,17 @@ void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { return addr; } -void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const int line ) { +void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int line) +{ #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if( !_record_insert_busy ) { + if(!_record_insert_busy) { // Find record of previous allocation/reallocation - record = _records.find( sc_memmgr_record( addr ) ); - if( record == _records.end() ) { + record = _records.find(sc_memmgr_record(addr)); + if(record == _records.end()) { // todo: error reallocating memory not allocated? - fprintf( stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line ); + fprintf(stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line); } else { // Update stats _allocated -= record->getsize(); @@ -254,29 +268,29 @@ void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const // Erase previous allocation/reallocation _record_erase_busy = true; - _records.erase( record ); + _records.erase(record); _record_erase_busy = false; } } #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Reallocate - addr = realloc( addr, size ); - if( addr == NULL ) { + addr = realloc(addr, size); + if(addr == NULL) { // todo: error reallocation failed - fprintf( stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line ); + fprintf(stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line); } #ifdef SC_MEMMGR_ENABLE_CHECKS - if( !_record_insert_busy ) { + if(!_record_insert_busy) { // Store record for this reallocation _record_insert_busy = true; - _records.insert( sc_memmgr_record( addr, size, file, line ) ); + _records.insert(sc_memmgr_record(addr, size, file, line)); _record_insert_busy = false; // Update stats _allocated += size; - if( _allocated > _maximum_allocated ) { + if(_allocated > _maximum_allocated) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -287,16 +301,17 @@ void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const return addr; } -void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { +void sc_memmgr::deallocate(void *addr, const char *file, const int line) +{ #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if( !_record_erase_busy ) { + if(!_record_erase_busy) { // Find record of previous allocation/reallocation - record = _records.find( sc_memmgr_record( addr ) ); - if( record == _records.end() ) { + record = _records.find(sc_memmgr_record(addr)); + if(record == _records.end()) { // todo: error free called for not allocated memory? - fprintf( stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line ); + fprintf(stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line); } else { // Update stats _allocated -= record->getsize(); @@ -304,7 +319,7 @@ void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { // Erase record _record_erase_busy = true; - _records.erase( record ); + _records.erase(record); _record_erase_busy = false; } } @@ -314,91 +329,107 @@ void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Deallocate - free( addr ); + free(addr); } #ifdef SC_MEMMGR_ENABLE_CHECKS /** sc_memmgr_error implementation */ -sc_memmgr_error::sc_memmgr_error( const std::string & file, const unsigned int line ) { +sc_memmgr_error::sc_memmgr_error(const std::string &file, const unsigned int line) +{ _srcfile = file; _srcline = line; _occurences = 1; } -sc_memmgr_error::sc_memmgr_error( const sc_memmgr_error & rhs ) { +sc_memmgr_error::sc_memmgr_error(const sc_memmgr_error &rhs) +{ _srcfile = rhs._srcfile; _srcline = rhs._srcline; _occurences = rhs._occurences; } -sc_memmgr_error::~sc_memmgr_error( void ) { +sc_memmgr_error::~sc_memmgr_error(void) +{ } -bool sc_memmgr_error::operator<( const sc_memmgr_error & rhs ) const { - if( _srcfile == rhs._srcfile ) { +bool sc_memmgr_error::operator<(const sc_memmgr_error &rhs) const +{ + if(_srcfile == rhs._srcfile) { return _srcline < rhs._srcline; } return _srcfile < rhs._srcfile; } -std::string sc_memmgr_error::getsrcfile( void ) const { +std::string sc_memmgr_error::getsrcfile(void) const +{ return _srcfile; } -unsigned int sc_memmgr_error::getsrcline( void ) const { +unsigned int sc_memmgr_error::getsrcline(void) const +{ return _srcline; } -unsigned int sc_memmgr_error::getoccurences( void ) const { +unsigned int sc_memmgr_error::getoccurences(void) const +{ return _occurences; } /** sc_memmgr_record implementation */ -sc_memmgr_record::sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ) { +sc_memmgr_record::sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line) +{ _addr = addr; _size = size; _srcfile = file; _srcline = line; } -sc_memmgr_record::sc_memmgr_record( void * addr ) { +sc_memmgr_record::sc_memmgr_record(void *addr) +{ _addr = addr; _size = 0; _srcfile = ""; _srcline = -1; } -sc_memmgr_record::sc_memmgr_record( const sc_memmgr_record & rhs ) { +sc_memmgr_record::sc_memmgr_record(const sc_memmgr_record &rhs) +{ _addr = rhs._addr; _size = rhs._size; _srcfile = rhs._srcfile; _srcline = rhs._srcline; } -sc_memmgr_record::~sc_memmgr_record( void ) { +sc_memmgr_record::~sc_memmgr_record(void) +{ } -bool sc_memmgr_record::operator<( const sc_memmgr_record & rhs ) const { +bool sc_memmgr_record::operator<(const sc_memmgr_record &rhs) const +{ return _addr < rhs._addr; } -void * sc_memmgr_record::getaddr( void ) const { +void *sc_memmgr_record::getaddr(void) const +{ return _addr; } -size_t sc_memmgr_record::getsize( void ) const { +size_t sc_memmgr_record::getsize(void) const +{ return _size; } -std::string sc_memmgr_record::getsrcfile( void ) const { +std::string sc_memmgr_record::getsrcfile(void) const +{ return _srcfile; } -unsigned int sc_memmgr_record::getsrcline( void ) const { +unsigned int sc_memmgr_record::getsrcline(void) const +{ return _srcline; } diff --git a/src/base/sc_memmgr.h b/src/base/sc_memmgr.h index 9517a20bc..b1b05d2d4 100644 --- a/src/base/sc_memmgr.h +++ b/src/base/sc_memmgr.h @@ -11,10 +11,10 @@ extern "C" { #endif /* __cplusplus */ - SC_BASE_EXPORT void * sc_malloc_fn( unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void sc_free_fn( void * addr ); +SC_BASE_EXPORT void *sc_malloc_fn(unsigned int size, const char *file, const int line); +SC_BASE_EXPORT void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line); +SC_BASE_EXPORT void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line); +SC_BASE_EXPORT void sc_free_fn(void *addr); #ifdef __cplusplus } @@ -22,9 +22,9 @@ extern "C" { #ifdef __cplusplus -SC_BASE_EXPORT void * sc_operator_new( size_t size, const char * file, const int line ); -SC_BASE_EXPORT void sc_operator_delete( void * addr, const char * file, const int line ); -SC_BASE_EXPORT void sc_operator_delete( void * addr ); +SC_BASE_EXPORT void *sc_operator_new(size_t size, const char *file, const int line); +SC_BASE_EXPORT void sc_operator_delete(void *addr, const char *file, const int line); +SC_BASE_EXPORT void sc_operator_delete(void *addr); #endif /* __cplusplus */ @@ -39,28 +39,34 @@ SC_BASE_EXPORT void sc_operator_delete( void * addr ); #include -inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) { - return sc_operator_new( size, file, line ); +inline void *operator new(size_t size, const char *file, const int line) throw(std::bad_alloc) +{ + return sc_operator_new(size, file, line); } -inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) { - return sc_operator_new( size, file, line ); +inline void *operator new[](size_t size, const char *file, const int line) throw(std::bad_alloc) +{ + return sc_operator_new(size, file, line); } -inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) { - sc_operator_delete( addr, file, line ); +inline void operator delete(void *addr, const char *file, const int line) throw(std::bad_alloc) +{ + sc_operator_delete(addr, file, line); } -inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) { - sc_operator_delete( addr, file, line ); +inline void operator delete[](void *addr, const char *file, const int line) throw(std::bad_alloc) +{ + sc_operator_delete(addr, file, line); } -inline void operator delete( void * addr ) throw () { - sc_operator_delete( addr ); +inline void operator delete(void *addr) throw() +{ + sc_operator_delete(addr); } -inline void operator delete[]( void * addr ) throw () { - sc_operator_delete( addr ); +inline void operator delete[](void *addr) throw() +{ + sc_operator_delete(addr); } #define new new(__FILE__, __LINE__) diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c index 1a908155c..f48829973 100644 --- a/src/base/sc_mkdir.c +++ b/src/base/sc_mkdir.c @@ -9,22 +9,24 @@ #endif /* _WIN32 */ /* cross-platform mkdir */ -int sc_mkdir( const char * path ) { - #ifdef _WIN32 - return mkdir( path ); - #else - return mkdir( path, 0777 ); - #endif /* _WIN32 */ +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 ) { +int mkDirIfNone(const char *path) +{ struct stat s; - if( stat( path, &s ) != 0 ) { - if( errno == ENOENT ) { - return sc_mkdir( path ); + if(stat(path, &s) != 0) { + if(errno == ENOENT) { + return sc_mkdir(path); } - } else if( s.st_mode & S_IFDIR ) { + } 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 */ diff --git a/src/base/sc_mkdir.h b/src/base/sc_mkdir.h index 21c8d9c5c..34bea074c 100644 --- a/src/base/sc_mkdir.h +++ b/src/base/sc_mkdir.h @@ -4,12 +4,12 @@ #include /** cross-platform mkdir() */ -SC_BASE_EXPORT int sc_mkdir( const char * path ); +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 ); +SC_BASE_EXPORT int mkDirIfNone(const char *path); #endif /* SC_MKDIR */ diff --git a/src/base/sc_stdio.h b/src/base/sc_stdio.h index 78fefc53b..717be249c 100644 --- a/src/base/sc_stdio.h +++ b/src/base/sc_stdio.h @@ -10,19 +10,23 @@ #include static __inline int -c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) { +c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) +{ int count = -1; - if (sz != 0) + if(sz != 0) { count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap); - if (count == -1) + } + if(count == -1) { count = _vscprintf(format, ap); + } return count; } static __inline int -c99_snprintf(char *buffer, size_t sz, const char *format, ...) { +c99_snprintf(char *buffer, size_t sz, const char *format, ...) +{ int count; va_list ap; diff --git a/src/base/sc_trace_fprintf.c b/src/base/sc_trace_fprintf.c index 95ca6b9c6..4ec3fde56 100644 --- a/src/base/sc_trace_fprintf.c +++ b/src/base/sc_trace_fprintf.c @@ -4,13 +4,14 @@ #include "sc_trace_fprintf.h" -void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) { +void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...) +{ va_list args; - if( ( file != stdout ) && ( file != stderr ) ) { - fprintf( file, "/* source: %s:%d */", sourcefile, line ); + if((file != stdout) && (file != stderr)) { + fprintf(file, "/* source: %s:%d */", sourcefile, line); } - va_start( args, format ); - vfprintf( file, format, args ); - va_end( args ); + va_start(args, format); + vfprintf(file, format, args); + va_end(args); } diff --git a/src/base/sc_trace_fprintf.h b/src/base/sc_trace_fprintf.h index b7aa05fa2..c09803ef0 100644 --- a/src/base/sc_trace_fprintf.h +++ b/src/base/sc_trace_fprintf.h @@ -17,10 +17,10 @@ #ifdef __cplusplus extern "C" { #endif - /** Used to find where generated c++ originates from in exp2cxx. - * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' - */ - SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ); +/** Used to find where generated c++ originates from in exp2cxx. + * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' + */ +SC_BASE_EXPORT void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...); #ifdef __cplusplus } #endif diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index 30a9103f4..768cdded9 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -37,105 +37,116 @@ #ifndef HAVE_MEMMOVE extern "C" { - void * memmove( void * __s1, const void * __s2, size_t __n ); + void *memmove(void *__s1, const void *__s2, size_t __n); } #endif /*****************************************************************************/ -SDAI_Application_instance__set::SDAI_Application_instance__set( int defaultSize ) { +SDAI_Application_instance__set::SDAI_Application_instance__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new SDAI_Application_instance_ptr[_bufsize]; _count = 0; } -SDAI_Application_instance__set::~SDAI_Application_instance__set() { +SDAI_Application_instance__set::~SDAI_Application_instance__set() +{ delete _buf; } -void SDAI_Application_instance__set::Check( int index ) { - SDAI_Application_instance_ptr * newbuf; +void SDAI_Application_instance__set::Check(int index) +{ + SDAI_Application_instance_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new SDAI_Application_instance_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( SDAI_Application_instance_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(SDAI_Application_instance_ptr)); delete _buf; _buf = newbuf; } } -void SDAI_Application_instance__set::Insert( SDAI_Application_instance_ptr v, int index ) { - SDAI_Application_instance_ptr * spot; - index = ( index < 0 ) ? _count : index; +void SDAI_Application_instance__set::Insert(SDAI_Application_instance_ptr v, int index) +{ + SDAI_Application_instance_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Append( SDAI_Application_instance_ptr v ) { +void SDAI_Application_instance__set::Append(SDAI_Application_instance_ptr v) +{ int index = _count; - SDAI_Application_instance_ptr * spot; + SDAI_Application_instance_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void SDAI_Application_instance__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - SDAI_Application_instance_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); + SDAI_Application_instance_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Application_instance_ptr)); } } -void SDAI_Application_instance__set::Remove( SDAI_Application_instance_ptr a ) { - int index = Index( a ); - if( !( index < 0 ) ) { - Remove( index ); +void SDAI_Application_instance__set::Remove(SDAI_Application_instance_ptr a) +{ + int index = Index(a); + if(!(index < 0)) { + Remove(index); } } -int SDAI_Application_instance__set::Index( SDAI_Application_instance_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int SDAI_Application_instance__set::Index(SDAI_Application_instance_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -SDAI_Application_instance_ptr & SDAI_Application_instance__set::operator[]( int index ) { - Check( index ); +SDAI_Application_instance_ptr &SDAI_Application_instance__set::operator[](int index) +{ + Check(index); // _count = max(_count, index+1); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } int -SDAI_Application_instance__set::Count() { +SDAI_Application_instance__set::Count() +{ return _count; } void -SDAI_Application_instance__set::Clear() { +SDAI_Application_instance__set::Clear() +{ _count = 0; } diff --git a/src/cldai/sdaiApplication_instance_set.h b/src/cldai/sdaiApplication_instance_set.h index 378e65443..ebe1dbfbe 100644 --- a/src/cldai/sdaiApplication_instance_set.h +++ b/src/cldai/sdaiApplication_instance_set.h @@ -34,27 +34,28 @@ class SDAI_Application_instance; class SDAI_Application_instance__set; -typedef SDAI_Application_instance__set * SDAI_Application_instance__set_ptr; +typedef SDAI_Application_instance__set *SDAI_Application_instance__set_ptr; typedef SDAI_Application_instance__set_ptr SDAI_Application_instance__set_var; -class SC_DAI_EXPORT SDAI_Application_instance__set { +class SC_DAI_EXPORT SDAI_Application_instance__set +{ public: - SDAI_Application_instance__set( int = 16 ); + SDAI_Application_instance__set(int = 16); ~SDAI_Application_instance__set(); - SDAI_Application_instance *& operator[]( int index ); - void Insert( SDAI_Application_instance *, int index ); - void Append( SDAI_Application_instance * ); - void Remove( int index ); - void Remove( SDAI_Application_instance * ); - int Index( SDAI_Application_instance * ); + SDAI_Application_instance *&operator[](int index); + void Insert(SDAI_Application_instance *, int index); + void Append(SDAI_Application_instance *); + void Remove(int index); + void Remove(SDAI_Application_instance *); + int Index(SDAI_Application_instance *); int Count(); void Clear(); private: - void Check( int index ); + void Check(int index); private: - SDAI_Application_instance ** _buf; + SDAI_Application_instance **_buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index 678add01c..3763f9490 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -13,42 +13,50 @@ #include #include "sc_memmgr.h" -SDAI_Binary::SDAI_Binary( const char * str, int max ) { - content = std::string( str, max ); +SDAI_Binary::SDAI_Binary(const char *str, int max) +{ + content = std::string(str, max); } -SDAI_Binary::SDAI_Binary( const std::string & s ) { - content = std::string( s ); +SDAI_Binary::SDAI_Binary(const std::string &s) +{ + content = std::string(s); } -SDAI_Binary::~SDAI_Binary( void ) { +SDAI_Binary::~SDAI_Binary(void) +{ } -SDAI_Binary & SDAI_Binary::operator= ( const char * s ) { - content = std::string( s ); +SDAI_Binary &SDAI_Binary::operator= (const char *s) +{ + content = std::string(s); return *this; } -void SDAI_Binary::clear( void ) { +void SDAI_Binary::clear(void) +{ content.clear(); } -bool SDAI_Binary::empty( void ) const { +bool SDAI_Binary::empty(void) const +{ return content.empty(); } -const char * SDAI_Binary::c_str( void ) const { +const char *SDAI_Binary::c_str(void) const +{ return content.c_str(); } -void SDAI_Binary::STEPwrite( ostream & out ) const { - const char * str = 0; - if( empty() ) { +void SDAI_Binary::STEPwrite(ostream &out) const +{ + const char *str = 0; + if(empty()) { out << "$"; } else { out << '\"'; str = c_str(); - while( *str ) { + while(*str) { out << *str; str++; } @@ -56,25 +64,27 @@ void SDAI_Binary::STEPwrite( ostream & out ) const { } } -const char * SDAI_Binary::STEPwrite( std::string & s ) const { - const char * str = 0; - if( empty() ) { +const char *SDAI_Binary::STEPwrite(std::string &s) const +{ + const char *str = 0; + if(empty()) { s = "$"; } else { s = "\""; str = c_str(); - while( *str ) { + while(*str) { s += *str; str++; } s += BINARY_DELIM; } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -Severity SDAI_Binary::ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal, - int needDelims ) { - if( AssignVal ) { +Severity SDAI_Binary::ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal, + int needDelims) +{ + if(AssignVal) { clear(); } @@ -84,79 +94,82 @@ Severity SDAI_Binary::ReadBinary( istream & in, ErrorDescriptor * err, int Assig in >> ws; // skip white space - if( in.good() ) { + if(in.good()) { char c; - in.get( c ); - if( ( c == '\"' ) || isxdigit( c ) ) { + in.get(c); + if((c == '\"') || isxdigit(c)) { int validDelimiters = 1; - if( c == '\"' ) { - in.get( c ); // push past the delimiter + if(c == '\"') { + in.get(c); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } - while( in.good() && isxdigit( c ) ) { + while(in.good() && isxdigit(c)) { str += c; - in.get( c ); + in.get(c); } - if( in.good() && ( c != '\"' ) ) { - in.putback( c ); + if(in.good() && (c != '\"')) { + in.putback(c); } - if( AssignVal && ( str.length() > 0 ) ) { - operator= ( str.c_str() ); + if(AssignVal && (str.length() > 0)) { + operator= (str.c_str()); } - if( c == '\"' ) { // if found ending delimiter + if(c == '\"') { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if( !validDelimiters ) { + if(!validDelimiters) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if( needDelims ) { + else if(needDelims) { validDelimiters = 0; } - if( !validDelimiters ) { - err->GreaterSeverity( SEVERITY_WARNING ); - if( needDelims ) - sprintf( messageBuf, - "Binary value missing double quote delimiters.\n" ); + if(!validDelimiters) { + err->GreaterSeverity(SEVERITY_WARNING); + if(needDelims) + sprintf(messageBuf, + "Binary value missing double quote delimiters.\n"); else - sprintf( messageBuf, - "Mismatched double quote delimiters for binary.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + sprintf(messageBuf, + "Mismatched double quote delimiters for binary.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } } else { - err->GreaterSeverity( SEVERITY_WARNING ); - sprintf( messageBuf, "Invalid binary value.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + err->GreaterSeverity(SEVERITY_WARNING); + sprintf(messageBuf, "Invalid binary value.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } } else { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } return err->severity(); } -Severity SDAI_Binary::StrToVal( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); // sz defaults to length of s - return ReadBinary( in, err, 1, 0 ); +Severity SDAI_Binary::StrToVal(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); // sz defaults to length of s + return ReadBinary(in, err, 1, 0); } ///////////////////////////////////////////////// /// reads a binary in exchange file format delimited by double quotes -Severity SDAI_Binary::STEPread( istream & in, ErrorDescriptor * err ) { - return ReadBinary( in, err, 1, 1 ); +Severity SDAI_Binary::STEPread(istream &in, ErrorDescriptor *err) +{ + return ReadBinary(in, err, 1, 1); } -Severity SDAI_Binary::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); - return STEPread( in, err ); +Severity SDAI_Binary::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); + return STEPread(in, err); } /***************************************************************************//** @@ -178,45 +191,47 @@ Severity SDAI_Binary::STEPread( const char * s, ErrorDescriptor * err ) { ** null then attrValue must only contain a valid value and nothing else ** following. ******************************************************************************/ -Severity SDAI_Binary::BinaryValidLevel( istream & in, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims, int clearError ) { - if( clearError ) { +Severity SDAI_Binary::BinaryValidLevel(istream &in, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims, int clearError) +{ + if(clearError) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = in.peek(); - if( c == '$' || in.eof() ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(c == '$' || in.eof()) { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - if( in ) { + if(in) { in >> c; } - CheckRemainingInput( in, err, "binary", tokenList ); + CheckRemainingInput(in, err, "binary", tokenList); return err->severity(); } else { ErrorDescriptor error; - ReadBinary( in, &error, 0, needDelims ); - CheckRemainingInput( in, &error, "binary", tokenList ); + ReadBinary(in, &error, 0, needDelims); + CheckRemainingInput(in, &error, "binary", tokenList); Severity sev = error.severity(); - if( sev < SEVERITY_INCOMPLETE ) { - err->AppendToDetailMsg( error.DetailMsg() ); - err->AppendToUserMsg( error.UserMsg() ); - err->GreaterSeverity( error.severity() ); - } else if( sev == SEVERITY_INCOMPLETE && !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(sev < SEVERITY_INCOMPLETE) { + err->AppendToDetailMsg(error.DetailMsg()); + err->AppendToUserMsg(error.UserMsg()); + err->GreaterSeverity(error.severity()); + } else if(sev == SEVERITY_INCOMPLETE && !optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } } return err->severity(); } -Severity SDAI_Binary::BinaryValidLevel( const char * value, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims, int clearError ) { - istringstream in( ( char * )value ); - return BinaryValidLevel( in, err, optional, tokenList, - needDelims, clearError ); +Severity SDAI_Binary::BinaryValidLevel(const char *value, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims, int clearError) +{ + istringstream in((char *)value); + return BinaryValidLevel(in, err, optional, tokenList, + needDelims, clearError); } diff --git a/src/cldai/sdaiBinary.h b/src/cldai/sdaiBinary.h index 76bb56d18..c07350fda 100644 --- a/src/cldai/sdaiBinary.h +++ b/src/cldai/sdaiBinary.h @@ -13,7 +13,8 @@ * and is not subject to copyright. */ -class SC_DAI_EXPORT SDAI_Binary { +class SC_DAI_EXPORT SDAI_Binary +{ private: #ifdef _MSC_VER #pragma warning( push ) @@ -27,37 +28,38 @@ class SC_DAI_EXPORT SDAI_Binary { public: //constructor(s) & destructor - SDAI_Binary( const char * str = 0, int max = 0 ); - SDAI_Binary( const std::string & s ); - ~SDAI_Binary( void ); + SDAI_Binary(const char *str = 0, int max = 0); + SDAI_Binary(const std::string &s); + ~SDAI_Binary(void); // operators - SDAI_Binary & operator= ( const char * s ); + SDAI_Binary &operator= (const char *s); - void clear( void ); - bool empty( void ) const; - const char * c_str( void ) const; + void clear(void); + bool empty(void) const; + const char *c_str(void) const; // format for STEP - const char * asStr() const { + const char *asStr() const + { return c_str(); } - void STEPwrite( ostream & out = cout ) const; - const char * STEPwrite( std::string & s ) const; + void STEPwrite(ostream &out = cout) const; + const char *STEPwrite(std::string &s) const; - Severity StrToVal( const char * s, ErrorDescriptor * err ); - Severity STEPread( istream & in, ErrorDescriptor * err ); - Severity STEPread( const char * s, ErrorDescriptor * err ); + Severity StrToVal(const char *s, ErrorDescriptor *err); + Severity STEPread(istream &in, ErrorDescriptor *err); + Severity STEPread(const char *s, ErrorDescriptor *err); - Severity BinaryValidLevel( const char * value, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims = 0, int clearError = 1 ); - Severity BinaryValidLevel( istream & in, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims = 0, int clearError = 1 ); + Severity BinaryValidLevel(const char *value, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims = 0, int clearError = 1); + Severity BinaryValidLevel(istream &in, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims = 0, int clearError = 1); protected: - Severity ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal = 1, - int needDelims = 1 ); + Severity ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal = 1, + int needDelims = 1); }; #endif diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index 2f43ab284..5c35e4e7e 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -9,36 +9,45 @@ #ifndef HAVE_MEMMOVE extern "C" { - void * memmove( void * __s1, const void * __s2, size_t __n ); + void *memmove(void *__s1, const void *__s2, size_t __n); } #endif -SDAI_PID::SDAI_PID() { +SDAI_PID::SDAI_PID() +{ } -SDAI_PID::~SDAI_PID() { +SDAI_PID::~SDAI_PID() +{ } -SDAI_PID_DA::SDAI_PID_DA() { +SDAI_PID_DA::SDAI_PID_DA() +{ } -SDAI_PID_DA::~SDAI_PID_DA() { +SDAI_PID_DA::~SDAI_PID_DA() +{ } -SDAI_PID_SDAI::SDAI_PID_SDAI() { +SDAI_PID_SDAI::SDAI_PID_SDAI() +{ } -SDAI_PID_SDAI::~SDAI_PID_SDAI() { +SDAI_PID_SDAI::~SDAI_PID_SDAI() +{ } -SDAI_DAObject::SDAI_DAObject() { +SDAI_DAObject::SDAI_DAObject() +{ } -SDAI_DAObject::~SDAI_DAObject() { +SDAI_DAObject::~SDAI_DAObject() +{ } -SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() { +SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() +{ } /* @@ -47,7 +56,8 @@ SDAI_DAObject_SDAI::SDAI_DAObject_SDAI(const DAObject_SDAI&) } */ -SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() { +SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() +{ } /* @@ -78,79 +88,86 @@ SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() { /*****************************************************************************/ -SDAI_DAObject__set::SDAI_DAObject__set( int defaultSize ) { +SDAI_DAObject__set::SDAI_DAObject__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new SDAI_DAObject_ptr[_bufsize]; _count = 0; } -SDAI_DAObject__set::~SDAI_DAObject__set() { +SDAI_DAObject__set::~SDAI_DAObject__set() +{ delete _buf; } -void SDAI_DAObject__set::Check( int index ) { +void SDAI_DAObject__set::Check(int index) +{ - SDAI_DAObject_ptr * newbuf; + SDAI_DAObject_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new SDAI_DAObject_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( SDAI_DAObject_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(SDAI_DAObject_ptr)); delete _buf; _buf = newbuf; } } void -SDAI_DAObject__set::Insert( SDAI_DAObject_ptr v, int index ) { +SDAI_DAObject__set::Insert(SDAI_DAObject_ptr v, int index) +{ - SDAI_DAObject_ptr * spot; - index = ( index < 0 ) ? _count : index; + SDAI_DAObject_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Append( SDAI_DAObject_ptr v ) { +void SDAI_DAObject__set::Append(SDAI_DAObject_ptr v) +{ int index = _count; - SDAI_DAObject_ptr * spot; + SDAI_DAObject_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Remove( int index ) { +void SDAI_DAObject__set::Remove(int index) +{ - if( 0 <= index && index < _count ) { + if(0 <= index && index < _count) { --_count; - SDAI_DAObject_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); + SDAI_DAObject_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_DAObject_ptr)); } } -int SDAI_DAObject__set::Index( SDAI_DAObject_ptr v ) { +int SDAI_DAObject__set::Index(SDAI_DAObject_ptr v) +{ - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } @@ -158,29 +175,34 @@ int SDAI_DAObject__set::Index( SDAI_DAObject_ptr v ) { } SDAI_DAObject_ptr -SDAI_DAObject__set::retrieve( int index ) { - return operator[]( index ); +SDAI_DAObject__set::retrieve(int index) +{ + return operator[](index); } -SDAI_DAObject_ptr & SDAI_DAObject__set::operator[]( int index ) { +SDAI_DAObject_ptr &SDAI_DAObject__set::operator[](int index) +{ - Check( index ); + Check(index); // _count = max(_count, index+1); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } int -SDAI_DAObject__set::Count() { +SDAI_DAObject__set::Count() +{ return _count; } int -SDAI_DAObject__set::is_empty() { +SDAI_DAObject__set::is_empty() +{ return _count; } void -SDAI_DAObject__set::Clear() { +SDAI_DAObject__set::Clear() +{ _count = 0; } diff --git a/src/cldai/sdaiDaObject.h b/src/cldai/sdaiDaObject.h index 168c7bfbc..97af663be 100644 --- a/src/cldai/sdaiDaObject.h +++ b/src/cldai/sdaiDaObject.h @@ -7,7 +7,7 @@ #include -typedef char * SDAI_DAObjectID; +typedef char *SDAI_DAObjectID; // // The PID class maintains the persistent object identifier for every @@ -24,7 +24,8 @@ typedef char * SDAI_DAObjectID; SDAI_DAObjectID as follows: */ /// interface PID (ISO/DIS 10303-23:1996(E) 5.3.10.1) -class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject { +class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject +{ public: // These are in the IDL generated code for Part 26. I will have to think about @@ -44,20 +45,22 @@ class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject { The Datestore_type attribute shall identify the type of the underlying datastore. */ - char * Datastore_type() const { - return const_cast( _datastore_type.c_str() ); + char *Datastore_type() const + { + return const_cast(_datastore_type.c_str()); } - void Datastore_type( char * x ) { + void Datastore_type(char *x) + { _datastore_type = x; } /* This function shall return a string version of the receiver. */ - char * get_PIDString(); + char *get_PIDString(); }; -typedef SDAI_PID * SDAI_PID_ptr; +typedef SDAI_PID *SDAI_PID_ptr; typedef SDAI_PID_ptr SDAI_PID_var; @@ -81,7 +84,8 @@ typedef SDAI_PID_ptr SDAI_PID_var; // interface. // /// interface PID_DA (ISO/DIS 10303-23:1996(E) 5.3.10.3) -class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID { +class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID +{ public: SDAI_String _oid; @@ -101,15 +105,17 @@ class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID { SDAI_PID_DA(); virtual ~SDAI_PID_DA(); - virtual void oid( const SDAI_DAObjectID x ) { + virtual void oid(const SDAI_DAObjectID x) + { _oid = x; } - virtual SDAI_DAObjectID oid() const { - return const_cast( _oid.c_str() ); + virtual SDAI_DAObjectID oid() const + { + return const_cast(_oid.c_str()); } }; -typedef SDAI_PID_DA * SDAI_PID_DA_ptr; +typedef SDAI_PID_DA *SDAI_PID_DA_ptr; typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // @@ -117,7 +123,8 @@ typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // a Model_contents object. // /// interface PID_SDAI (ISO/DIS 10303-23:1996(E) 5.3.10.2) -class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID { +class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID +{ public: SDAI_String _modelid; @@ -131,15 +138,17 @@ class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID { // the persistent identifier of the cluster of data for the // Model_contents referred to by this PID. // - virtual void Modelid( const char * x ) { + virtual void Modelid(const char *x) + { _modelid = x; } - virtual char * Modelid() const { - return const_cast( _modelid.c_str() ); + virtual char *Modelid() const + { + return const_cast(_modelid.c_str()); } }; -typedef SDAI_PID_SDAI * SDAI_PID_SDAI_ptr; +typedef SDAI_PID_SDAI *SDAI_PID_SDAI_ptr; typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // @@ -153,11 +162,12 @@ typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // predefine these _ptr since they are used inside this class class SDAI_DAObject; -typedef SDAI_DAObject * SDAI_DAObject_ptr; +typedef SDAI_DAObject *SDAI_DAObject_ptr; typedef SDAI_DAObject_ptr SDAI_DAObject_var; /// interface DAObject (ISO/DIS 10303-23:1996(E) 5.3.10.5) -class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { +class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject +{ public: SDAI_String _dado_oid; @@ -176,8 +186,11 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { SDAI_DAObject(); virtual ~SDAI_DAObject(); - Logical dado_same( SDAI_DAObject_ptr obj ) { - if (obj == this) return LTrue; + Logical dado_same(SDAI_DAObject_ptr obj) + { + if(obj == this) { + return LTrue; + } return LUnknown; } @@ -210,8 +223,9 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { note that the return value as described in the text above should be a string type. */ - SDAI_DAObjectID dado_oid() { - return const_cast( _dado_oid.c_str() ); + SDAI_DAObjectID dado_oid() + { + return const_cast(_dado_oid.c_str()); } // dado_pid @@ -223,7 +237,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { part of interface DAObject in the specification of the Persistent Object Service. */ - SDAI_PID_DA_ptr dado_pid() { + SDAI_PID_DA_ptr dado_pid() + { return 0; } @@ -257,7 +272,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { 5.3.10.1 DAObject_SDAI */ -class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { +class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject +{ public: SDAI_DAObject_SDAI(); @@ -304,7 +320,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { 5.3.10.1.3 Is same */ - Logical IsSame( const SDAI_sdaiObject_ptr & otherEntity ) const; + Logical IsSame(const SDAI_sdaiObject_ptr &otherEntity) const; /* Function: @@ -329,8 +345,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { */ #ifdef SDAI_CPP_LATE_BINDING - Any_var GetAttr( const Attribute_ptr & attDef ); - Any_var GetAttr( const char * attName ); + Any_var GetAttr(const Attribute_ptr &attDef); + Any_var GetAttr(const char *attName); #endif /* @@ -369,9 +385,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { 5.3.10.1.6 Is instance of */ - ::Boolean IsInstanceOf( const char * typeName ) const; + ::Boolean IsInstanceOf(const char *typeName) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsInstanceOf( const Entity_ptr & otherEntity ) const; + ::Boolean IsInstanceOf(const Entity_ptr &otherEntity) const; #endif /* @@ -391,9 +407,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { 5.3.10.1.7 Is kind of */ - ::Boolean IsKindOf( const char * typeName ) const; + ::Boolean IsKindOf(const char *typeName) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsKindOf( const Entity_ptr & theType ) const; + ::Boolean IsKindOf(const Entity_ptr &theType) const; #endif /* @@ -411,10 +427,10 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { 5.3.10.1.8 Is SDAI kind of */ - ::Boolean IsSDAIKindOf( const char * typeName ) const; + ::Boolean IsSDAIKindOf(const char *typeName) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsSDAIKindOf( const Entity_ptr & theType ) const; + ::Boolean IsSDAIKindOf(const Entity_ptr &theType) const; #endif /* @@ -434,8 +450,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { */ #ifdef SDAI_CPP_LATE_BINDING - ::Boolean TestAttr( const Attribute_ptr & attDef ); - ::Boolean TestAttr( const char * attName ) const; + ::Boolean TestAttr(const Attribute_ptr &attDef); + ::Boolean TestAttr(const char *attName) const; #endif /* @@ -455,7 +471,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { */ #ifndef SDAI_CPP_LATE_BINDING - char * GetInstanceTypeName() const; + char *GetInstanceTypeName() const; #endif /* Function: @@ -477,32 +493,33 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { }; -typedef SDAI_DAObject_SDAI * SDAI_DAObject_SDAI_ptr; +typedef SDAI_DAObject_SDAI *SDAI_DAObject_SDAI_ptr; typedef SDAI_DAObject_SDAI_ptr SDAI_DAObject_SDAI_var; -class SC_DAI_EXPORT SDAI_DAObject__set { +class SC_DAI_EXPORT SDAI_DAObject__set +{ public: - SDAI_DAObject__set( int = 16 ); + SDAI_DAObject__set(int = 16); ~SDAI_DAObject__set(); - SDAI_DAObject_ptr retrieve( int index ); + SDAI_DAObject_ptr retrieve(int index); int is_empty(); - SDAI_DAObject_ptr & operator[]( int index ); + SDAI_DAObject_ptr &operator[](int index); - void Insert( SDAI_DAObject_ptr, int index ); - void Append( SDAI_DAObject_ptr ); - void Remove( int index ); + void Insert(SDAI_DAObject_ptr, int index); + void Append(SDAI_DAObject_ptr); + void Remove(int index); - int Index( SDAI_DAObject_ptr ); + int Index(SDAI_DAObject_ptr); void Clear(); int Count(); private: - void Check( int index ); + void Check(int index); private: - SDAI_DAObject_ptr * _buf; + SDAI_DAObject_ptr *_buf; int _bufsize; int _count; @@ -510,7 +527,7 @@ class SC_DAI_EXPORT SDAI_DAObject__set { }; -typedef SDAI_DAObject__set * SDAI_DAObject__set_ptr; +typedef SDAI_DAObject__set *SDAI_DAObject__set_ptr; typedef SDAI_DAObject__set_ptr SDAI_DAObject__set_var; #endif diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index f98d5d279..68fcb0af8 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -5,8 +5,9 @@ #include #include "sc_memmgr.h" -SDAI_Entity_extent::SDAI_Entity_extent( ) - : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { +SDAI_Entity_extent::SDAI_Entity_extent() + : _definition(0), _definition_name(0), _owned_by(0) +{ /* _definition = 0; _definition_name = 0; @@ -23,12 +24,14 @@ SDAI_Entity_extent::SDAI_Entity_extent(const SDAI_Entity_extent& ee) } */ -SDAI_Entity_extent::~SDAI_Entity_extent() { +SDAI_Entity_extent::~SDAI_Entity_extent() +{ delete _definition_name; } Entity_ptr -SDAI_Entity_extent ::definition_() const { +SDAI_Entity_extent ::definition_() const +{ return _definition; } @@ -41,22 +44,26 @@ SDAI_Entity_extent::definition_name_() const */ void -SDAI_Entity_extent::definition_( const Entity_ptr & ep ) { +SDAI_Entity_extent::definition_(const Entity_ptr &ep) +{ _definition = ep; } void -SDAI_Entity_extent::definition_name_( const SDAI_Entity_name & en ) { - _definition_name = new char[strlen( en ) + 1]; - strncpy( _definition_name, en, strlen( en ) + 1 ); +SDAI_Entity_extent::definition_name_(const SDAI_Entity_name &en) +{ + _definition_name = new char[strlen(en) + 1]; + strncpy(_definition_name, en, strlen(en) + 1); } -void SDAI_Entity_extent::owned_by_( SDAI_Model_contents__list_var& mclv ) { +void SDAI_Entity_extent::owned_by_(SDAI_Model_contents__list_var &mclv) +{ _owned_by = *mclv; } -SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const { - return ( const SDAI_Model_contents__list_var ) &_owned_by; +SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const +{ + return (const SDAI_Model_contents__list_var) &_owned_by; } /* @@ -91,8 +98,9 @@ SDAI_DAObject__set_var instances_() const */ void -SDAI_Entity_extent::AddInstance( const SDAI_DAObject_ptr & appInst ) { - _instances.Append( appInst ); +SDAI_Entity_extent::AddInstance(const SDAI_DAObject_ptr &appInst) +{ + _instances.Append(appInst); } /* @@ -113,8 +121,9 @@ SDAI_Entity_extent::AddInstance( const SDAI_DAObject_ptr & appInst ) { void -SDAI_Entity_extent::RemoveInstance( const SDAI_DAObject_ptr & appInst ) { - _instances.Remove( _instances.Index( appInst ) ); +SDAI_Entity_extent::RemoveInstance(const SDAI_DAObject_ptr &appInst) +{ + _instances.Remove(_instances.Index(appInst)); } ///////// END_ENTITY SDAI_Entity_extent diff --git a/src/cldai/sdaiEntity_extent.h b/src/cldai/sdaiEntity_extent.h index 0dcca471f..b2471839e 100644 --- a/src/cldai/sdaiEntity_extent.h +++ b/src/cldai/sdaiEntity_extent.h @@ -15,10 +15,11 @@ */ class SDAI_Entity_extent; -typedef SDAI_Entity_extent * SDAI_Entity_extent_ptr; +typedef SDAI_Entity_extent *SDAI_Entity_extent_ptr; typedef SDAI_Entity_extent_ptr SDAI_Entity_extent_var; -class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { +class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance +{ friend class SDAI_Model_contents; /* @@ -43,7 +44,8 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { public: - SDAI_Entity_name definition_name_() const { + SDAI_Entity_name definition_name_() const + { return _definition_name; } @@ -52,11 +54,13 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { // const Entity_ptr definition_() const; #endif - SDAI_DAObject__set_var instances_() { + SDAI_DAObject__set_var instances_() + { return &_instances; } - SDAI_DAObject__set_var instances_() const { - return ( const SDAI_DAObject__set_var )&_instances; + SDAI_DAObject__set_var instances_() const + { + return (const SDAI_DAObject__set_var)&_instances; } // need to implement Model_contents__list @@ -68,12 +72,12 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { // static SDAI_Entity_extent_ptr _nil(); // private: - void definition_( const Entity_ptr & ep ); + void definition_(const Entity_ptr &ep); #ifdef SDAI_CPP_LATE_BINDING // void definition_(const Entity_ptr& ep); #endif - void definition_name_( const SDAI_Entity_name & ep ); - void owned_by_( SDAI_Model_contents__list_var & mclv ); + void definition_name_(const SDAI_Entity_name &ep); + void owned_by_(SDAI_Model_contents__list_var &mclv); /* 7.3.3.1 SDAI operation declarations @@ -82,7 +86,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { */ // this is no longer in Part 23 - void AddInstance( const SDAI_DAObject_ptr & appInst ); + void AddInstance(const SDAI_DAObject_ptr &appInst); /* Function: @@ -101,7 +105,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { */ // this is no longer in Part 23 - void RemoveInstance( const SDAI_DAObject_ptr & appInst ); + void RemoveInstance(const SDAI_DAObject_ptr &appInst); /* 7.3.3.1.2 RemoveInstance diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index af3658222..d96ccc057 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -38,85 +38,92 @@ #ifndef HAVE_MEMMOVE extern "C" { - void * memmove( void * __s1, const void * __s2, size_t __n ); + void *memmove(void *__s1, const void *__s2, size_t __n); } #endif /*****************************************************************************/ -SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) { +SDAI_Entity_extent__set::SDAI_Entity_extent__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new SDAI_Entity_extent_ptr[_bufsize]; _count = 0; } -SDAI_Entity_extent__set::~SDAI_Entity_extent__set() { +SDAI_Entity_extent__set::~SDAI_Entity_extent__set() +{ delete _buf; } -void SDAI_Entity_extent__set::Check( int index ) { +void SDAI_Entity_extent__set::Check(int index) +{ - SDAI_Entity_extent_ptr * newbuf; + SDAI_Entity_extent_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new SDAI_Entity_extent_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(SDAI_Entity_extent_ptr)); delete _buf; _buf = newbuf; } } void -SDAI_Entity_extent__set::Insert( SDAI_Entity_extent_ptr v, int index ) { +SDAI_Entity_extent__set::Insert(SDAI_Entity_extent_ptr v, int index) +{ - SDAI_Entity_extent_ptr * spot; - index = ( index < 0 ) ? _count : index; + SDAI_Entity_extent_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Append( SDAI_Entity_extent_ptr v ) { +void SDAI_Entity_extent__set::Append(SDAI_Entity_extent_ptr v) +{ int index = _count; - SDAI_Entity_extent_ptr * spot; + SDAI_Entity_extent_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Remove( int index ) { +void SDAI_Entity_extent__set::Remove(int index) +{ - if( 0 <= index && index < _count ) { + if(0 <= index && index < _count) { --_count; - SDAI_Entity_extent_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); + SDAI_Entity_extent_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); } } -int SDAI_Entity_extent__set::Index( SDAI_Entity_extent_ptr v ) { +int SDAI_Entity_extent__set::Index(SDAI_Entity_extent_ptr v) +{ - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } @@ -124,29 +131,34 @@ int SDAI_Entity_extent__set::Index( SDAI_Entity_extent_ptr v ) { } SDAI_Entity_extent_ptr -SDAI_Entity_extent__set::retrieve( int index ) { - return operator[]( index ); +SDAI_Entity_extent__set::retrieve(int index) +{ + return operator[](index); } -SDAI_Entity_extent_ptr & SDAI_Entity_extent__set::operator[]( int index ) { - Check( index ); +SDAI_Entity_extent_ptr &SDAI_Entity_extent__set::operator[](int index) +{ + Check(index); // _count = max(_count, index+1); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } int -SDAI_Entity_extent__set::Count() { +SDAI_Entity_extent__set::Count() +{ return _count; } int -SDAI_Entity_extent__set::is_empty() { +SDAI_Entity_extent__set::is_empty() +{ return _count; } void -SDAI_Entity_extent__set::Clear() { +SDAI_Entity_extent__set::Clear() +{ _count = 0; } @@ -154,93 +166,103 @@ SDAI_Entity_extent__set::Clear() { #if 0 -Entity_extent__set::Entity_extent__set( int defaultSize ) { +Entity_extent__set::Entity_extent__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Entity_extent_ptr[_bufsize]; _count = 0; } -Entity_extent__set::~Entity_extent__set() { +Entity_extent__set::~Entity_extent__set() +{ delete _buf; } -void Entity_extent__set::Check( int index ) { - Entity_extent_ptr * newbuf; +void Entity_extent__set::Check(int index) +{ + Entity_extent_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Entity_extent_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Entity_extent_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Entity_extent_ptr)); delete _buf; _buf = newbuf; } } -void Entity_extent__set::Insert( Entity_extent_ptr v, int index ) { - Entity_extent_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Entity_extent__set::Insert(Entity_extent_ptr v, int index) +{ + Entity_extent_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Append( Entity_extent_ptr v ) { +void Entity_extent__set::Append(Entity_extent_ptr v) +{ int index = _count; - Entity_extent_ptr * spot; + Entity_extent_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Entity_extent__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Entity_extent_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Entity_extent_ptr ) ); + Entity_extent_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Entity_extent_ptr)); } } -int Entity_extent__set::Index( Entity_extent_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Entity_extent__set::Index(Entity_extent_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Entity_extent_ptr & Entity_extent__set::operator[]( int index ) { - Check( index ); +Entity_extent_ptr &Entity_extent__set::operator[](int index) +{ + Check(index); // _count = max(_count, index+1); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } int -Entity_extent__set::Count() { +Entity_extent__set::Count() +{ return _count; } void -Entity_extent__set::Clear() { +Entity_extent__set::Clear() +{ _count = 0; } diff --git a/src/cldai/sdaiEntity_extent_set.h b/src/cldai/sdaiEntity_extent_set.h index b6b893078..a7541cd83 100644 --- a/src/cldai/sdaiEntity_extent_set.h +++ b/src/cldai/sdaiEntity_extent_set.h @@ -37,35 +37,36 @@ //#include */ -class SC_DAI_EXPORT SDAI_Entity_extent__set { +class SC_DAI_EXPORT SDAI_Entity_extent__set +{ public: - SDAI_Entity_extent__set( int = 16 ); + SDAI_Entity_extent__set(int = 16); ~SDAI_Entity_extent__set(); - SDAI_Entity_extent_ptr retrieve( int index ); + SDAI_Entity_extent_ptr retrieve(int index); int is_empty(); - SDAI_Entity_extent_ptr & operator[]( int index ); + SDAI_Entity_extent_ptr &operator[](int index); - void Insert( SDAI_Entity_extent_ptr, int index ); - void Append( SDAI_Entity_extent_ptr ); - void Remove( int index ); - int Index( SDAI_Entity_extent_ptr ); + void Insert(SDAI_Entity_extent_ptr, int index); + void Append(SDAI_Entity_extent_ptr); + void Remove(int index); + int Index(SDAI_Entity_extent_ptr); void Clear(); int Count(); private: - void Check( int index ); + void Check(int index); private: - SDAI_Entity_extent_ptr * _buf; + SDAI_Entity_extent_ptr *_buf; int _bufsize; int _count; }; -typedef SDAI_Entity_extent__set * SDAI_Entity_extent__set_ptr; +typedef SDAI_Entity_extent__set *SDAI_Entity_extent__set_ptr; typedef SDAI_Entity_extent__set_ptr SDAI_Entity_extent__set_var; /* diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index a8e37d407..c303df7e3 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -19,39 +19,47 @@ // class Logical /////////////////////////////////////////////////////////////////////////////// -SDAI_LOGICAL::SDAI_LOGICAL( const char * val ) { - set_value( val ); +SDAI_LOGICAL::SDAI_LOGICAL(const char *val) +{ + set_value(val); } -SDAI_LOGICAL::SDAI_LOGICAL( Logical state ) { - set_value( state ); +SDAI_LOGICAL::SDAI_LOGICAL(Logical state) +{ + set_value(state); } -SDAI_LOGICAL::SDAI_LOGICAL( const SDAI_LOGICAL & source ) { - set_value( source.asInt() ); +SDAI_LOGICAL::SDAI_LOGICAL(const SDAI_LOGICAL &source) +{ + set_value(source.asInt()); } -SDAI_LOGICAL::SDAI_LOGICAL( int i ) { - if( i == 0 ) { +SDAI_LOGICAL::SDAI_LOGICAL(int i) +{ + if(i == 0) { v = LFalse ; } else { v = LTrue ; } } -SDAI_LOGICAL::~SDAI_LOGICAL() { +SDAI_LOGICAL::~SDAI_LOGICAL() +{ } -const char * SDAI_LOGICAL::Name() const { +const char *SDAI_LOGICAL::Name() const +{ return "Logical"; } -int SDAI_LOGICAL::no_elements() const { +int SDAI_LOGICAL::no_elements() const +{ return 3; } -const char * SDAI_LOGICAL::element_at( int n ) const { - switch( n ) { +const char *SDAI_LOGICAL::element_at(int n) const +{ + switch(n) { case LUnknown : return "U"; case LFalse : @@ -63,16 +71,19 @@ const char * SDAI_LOGICAL::element_at( int n ) const { } } -int SDAI_LOGICAL::exists() const { // return 0 if unset otherwise return 1 - return !( v == 2 ); +int SDAI_LOGICAL::exists() const // return 0 if unset otherwise return 1 +{ + return !(v == 2); } -void SDAI_LOGICAL::nullify() { // change the receiver to an unset status +void SDAI_LOGICAL::nullify() // change the receiver to an unset status +{ v = 2; } -SDAI_LOGICAL::operator Logical() const { - switch( v ) { +SDAI_LOGICAL::operator Logical() const +{ + switch(v) { case LFalse : return LFalse ; case LTrue : @@ -85,26 +96,29 @@ SDAI_LOGICAL::operator Logical() const { } } -SDAI_LOGICAL & SDAI_LOGICAL::operator= ( const SDAI_LOGICAL & t ) { - set_value( t.asInt() ); +SDAI_LOGICAL &SDAI_LOGICAL::operator= (const SDAI_LOGICAL &t) +{ + set_value(t.asInt()); return *this; } -SDAI_LOGICAL SDAI_LOGICAL::operator ==( const SDAI_LOGICAL & t ) const { - if( v == t.asInt() ) { +SDAI_LOGICAL SDAI_LOGICAL::operator ==(const SDAI_LOGICAL &t) const +{ + if(v == t.asInt()) { return LTrue ; } return LFalse ; } -int SDAI_LOGICAL::set_value( const int i ) { - if( i > no_elements() + 1 ) { +int SDAI_LOGICAL::set_value(const int i) +{ + if(i > no_elements() + 1) { v = 2; return v; } - const char * tmp = element_at( i ); - if( tmp[0] != '\0' ) { - return ( v = i ); + const char *tmp = element_at(i); + if(tmp[0] != '\0') { + return (v = i); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -113,20 +127,21 @@ int SDAI_LOGICAL::set_value( const int i ) { return no_elements() + 1 ; } -int SDAI_LOGICAL::set_value( const char * n ) { +int SDAI_LOGICAL::set_value(const char *n) +{ // assigns the appropriate value based on n - if( !n || ( !strcmp( n, "" ) ) ) { + if(!n || (!strcmp(n, ""))) { nullify(); return asInt(); } int i = 0; std::string tmp; - while( ( i < ( no_elements() + 1 ) ) && - ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { + while((i < (no_elements() + 1)) && + (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { ++i; } - if( ( no_elements() + 1 ) == i ) { // exhausted all the possible values + if((no_elements() + 1) == i) { // exhausted all the possible values nullify(); return v; } @@ -134,9 +149,10 @@ int SDAI_LOGICAL::set_value( const char * n ) { return v; } -Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, - int needDelims ) { - if( AssignVal ) { +Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, + int needDelims) +{ + if(AssignVal) { set_null(); } @@ -146,85 +162,85 @@ Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int Assign in >> ws; // skip white space - if( in.good() ) { + if(in.good()) { char c; - in.get( c ); - if( c == '.' || isalpha( c ) ) { + in.get(c); + if(c == '.' || isalpha(c)) { int validDelimiters = 1; - if( c == '.' ) { - in.get( c ); // push past the delimiter + if(c == '.') { + in.get(c); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if( in.good() && ( isalpha( c ) || c == '_' ) ) { + if(in.good() && (isalpha(c) || c == '_')) { str += c; - in.get( c ); + in.get(c); } // look for UPPER or DIGIT - while( in.good() && ( isalnum( c ) || c == '_' ) ) { + while(in.good() && (isalnum(c) || c == '_')) { str += c; - in.get( c ); + in.get(c); } // if character is not the delimiter unread it - if( in.good() && ( c != '.' ) ) { - in.putback( c ); + if(in.good() && (c != '.')) { + in.putback(c); } // a value was read - if( str.length() > 0 ) { + if(str.length() > 0) { int i = 0; - const char * strval = str.c_str(); + const char *strval = str.c_str(); std::string tmp; - while( ( i < ( no_elements() + 1 ) ) && - ( strcmp( ( char * )StrToUpper( strval, tmp ), - element_at( i ) ) != 0 ) ) { + while((i < (no_elements() + 1)) && + (strcmp((char *)StrToUpper(strval, tmp), + element_at(i)) != 0)) { ++i; } - if( ( no_elements() + 1 ) == i ) { + if((no_elements() + 1) == i) { // exhausted all the possible values - err->GreaterSeverity( SEVERITY_WARNING ); - err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); - err->AppendToUserMsg( "Invalid Enumeration value.\n" ); + err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg("Invalid Enumeration value.\n"); + err->AppendToUserMsg("Invalid Enumeration value.\n"); } else { - if( AssignVal ) { + if(AssignVal) { v = i; } } // now also check the delimiter situation - if( c == '.' ) { // if found ending delimiter + if(c == '.') { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if( !validDelimiters ) { + if(!validDelimiters) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if( needDelims ) { + else if(needDelims) { validDelimiters = 0; } - if( !validDelimiters ) { - err->GreaterSeverity( SEVERITY_WARNING ); - if( needDelims ) - sprintf( messageBuf, - "Enumerated value has invalid period delimiters.\n" ); + if(!validDelimiters) { + err->GreaterSeverity(SEVERITY_WARNING); + if(needDelims) + sprintf(messageBuf, + "Enumerated value has invalid period delimiters.\n"); else - sprintf( messageBuf, - "Mismatched period delimiters for enumeration.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + sprintf(messageBuf, + "Mismatched period delimiters for enumeration.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if( ( c == '.' ) || !validDelimiters ) { - err->GreaterSeverity( SEVERITY_WARNING ); + else if((c == '.') || !validDelimiters) { + err->GreaterSeverity(SEVERITY_WARNING); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -233,21 +249,21 @@ Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int Assign ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - } else if( ( c == ',' ) || ( c == ')' ) ) { - in.putback( c ); - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + } else if((c == ',') || (c == ')')) { + in.putback(c); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } else { - in.putback( c ); - err->GreaterSeverity( SEVERITY_WARNING ); - sprintf( messageBuf, "Invalid enumeration value.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + in.putback(c); + err->GreaterSeverity(SEVERITY_WARNING); + sprintf(messageBuf, "Invalid enumeration value.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } return err->severity(); } @@ -256,48 +272,57 @@ Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int Assign // class BOOLEAN Jan 97 /////////////////////////////////////////////////////////////////////////////// -const char * SDAI_BOOLEAN::Name() const { +const char *SDAI_BOOLEAN::Name() const +{ return "Bool"; } -SDAI_BOOLEAN::SDAI_BOOLEAN( char * val ) { - set_value( val ); +SDAI_BOOLEAN::SDAI_BOOLEAN(char *val) +{ + set_value(val); } -SDAI_BOOLEAN::SDAI_BOOLEAN( Boolean state ) { - set_value( state ); +SDAI_BOOLEAN::SDAI_BOOLEAN(Boolean state) +{ + set_value(state); } -SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_BOOLEAN & source ) { - set_value( source.asInt() ); +SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_BOOLEAN &source) +{ + set_value(source.asInt()); } -SDAI_BOOLEAN::~SDAI_BOOLEAN() { +SDAI_BOOLEAN::~SDAI_BOOLEAN() +{ } -int SDAI_BOOLEAN::no_elements() const { +int SDAI_BOOLEAN::no_elements() const +{ return 2; } -SDAI_BOOLEAN::SDAI_BOOLEAN( int i ) { - if( i == 0 ) { +SDAI_BOOLEAN::SDAI_BOOLEAN(int i) +{ + if(i == 0) { v = BFalse ; } else { v = BTrue ; } } -SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_LOGICAL & val ) { - if( val.asInt() == LUnknown ) { +SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_LOGICAL &val) +{ + if(val.asInt() == LUnknown) { // this should set error code sdaiVT_NVLD i.e. Invalid value type. v = BUnset; return; } - set_value( val ); + set_value(val); } -SDAI_BOOLEAN::operator Boolean() const { - switch( v ) { +SDAI_BOOLEAN::operator Boolean() const +{ + switch(v) { case BFalse : return BFalse ; case BTrue : @@ -308,18 +333,21 @@ SDAI_BOOLEAN::operator Boolean() const { } } -SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_LOGICAL & t ) { - set_value( t.asInt() ); +SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_LOGICAL &t) +{ + set_value(t.asInt()); return *this; } -SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const Boolean t ) { +SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const Boolean t) +{ v = t; return *this; } -const char * SDAI_BOOLEAN::element_at( int n ) const { - switch( n ) { +const char *SDAI_BOOLEAN::element_at(int n) const +{ + switch(n) { case BFalse : return "F"; case BTrue : @@ -329,8 +357,9 @@ const char * SDAI_BOOLEAN::element_at( int n ) const { } } -SDAI_LOGICAL SDAI_BOOLEAN::operator ==( const SDAI_LOGICAL & t ) const { - if( v == t.asInt() ) { +SDAI_LOGICAL SDAI_BOOLEAN::operator ==(const SDAI_LOGICAL &t) const +{ + if(v == t.asInt()) { return LTrue ; } return LFalse ; @@ -338,35 +367,40 @@ SDAI_LOGICAL SDAI_BOOLEAN::operator ==( const SDAI_LOGICAL & t ) const { /////////////////////////////////////////////////////////////////////////////// -SDAI_Enum::SDAI_Enum() { +SDAI_Enum::SDAI_Enum() +{ v = 0; } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put( int val ) { - return set_value( val ); +int SDAI_Enum::put(int val) +{ + return set_value(val); } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put( const char * n ) { - return set_value( n ); +int SDAI_Enum::put(const char *n) +{ + return set_value(n); } /// return 0 if unset otherwise return 1 /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? -int SDAI_Enum::exists() const { - return !( v > no_elements() ); +int SDAI_Enum::exists() const +{ + return !(v > no_elements()); } /** * change the receiver to an unset status * unset is generated to be 1 greater than last element */ -void SDAI_Enum::nullify() { - set_value( no_elements() + 1 ); +void SDAI_Enum::nullify() +{ + set_value(no_elements() + 1); } /**************************************************************//** @@ -374,19 +408,20 @@ void SDAI_Enum::nullify() { ** debugging purposes ** Status: ok 2/1/91 ******************************************************************/ -void SDAI_Enum::DebugDisplay( ostream & out ) const { +void SDAI_Enum::DebugDisplay(ostream &out) const +{ std::string tmp; out << "Current " << Name() << " value: " << endl << " cardinal: " << v << endl - << " string: " << asStr( tmp ) << endl + << " string: " << asStr(tmp) << endl << " Part 21 file format: "; - STEPwrite( out ); + STEPwrite(out); out << endl; out << "Valid values are: " << endl; int i = 0; - while( i < ( no_elements() + 1 ) ) { - out << i << " " << element_at( i ) << endl; + while(i < (no_elements() + 1)) { + out << i << " " << element_at(i) << endl; i++; } out << "\n"; @@ -407,9 +442,10 @@ void SDAI_Enum::DebugDisplay( ostream & out ) const { ** true => delimiters must be valid; ** true or false => non-matching delimiters are flagged as an error */ -Severity SDAI_Enum::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, - int needDelims ) { - if( AssignVal ) { +Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, + int needDelims) +{ + if(AssignVal) { set_null(); } @@ -419,85 +455,85 @@ Severity SDAI_Enum::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal in >> ws; // skip white space - if( in.good() ) { + if(in.good()) { char c; - in.get( c ); - if( c == '.' || isalpha( c ) ) { + in.get(c); + if(c == '.' || isalpha(c)) { int validDelimiters = 1; - if( c == '.' ) { - in.get( c ); // push past the delimiter + if(c == '.') { + in.get(c); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if( in.good() && ( isalpha( c ) || c == '_' ) ) { + if(in.good() && (isalpha(c) || c == '_')) { str += c; - in.get( c ); + in.get(c); } // look for UPPER or DIGIT - while( in.good() && ( isalnum( c ) || c == '_' ) ) { + while(in.good() && (isalnum(c) || c == '_')) { str += c; - in.get( c ); + in.get(c); } // if character is not the delimiter unread it - if( in.good() && ( c != '.' ) ) { - in.putback( c ); + if(in.good() && (c != '.')) { + in.putback(c); } // a value was read - if( str.length() > 0 ) { + if(str.length() > 0) { int i = 0; - const char * strval = str.c_str(); + const char *strval = str.c_str(); std::string tmp; - while( ( i < no_elements() ) && - ( strcmp( ( char * )StrToUpper( strval, tmp ), - element_at( i ) ) != 0 ) ) { + while((i < no_elements()) && + (strcmp((char *)StrToUpper(strval, tmp), + element_at(i)) != 0)) { ++i; } - if( no_elements() == i ) { + if(no_elements() == i) { // exhausted all the possible values - err->GreaterSeverity( SEVERITY_WARNING ); - err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); - err->AppendToUserMsg( "Invalid Enumeration value.\n" ); + err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg("Invalid Enumeration value.\n"); + err->AppendToUserMsg("Invalid Enumeration value.\n"); } else { - if( AssignVal ) { + if(AssignVal) { v = i; } } // now also check the delimiter situation - if( c == '.' ) { // if found ending delimiter + if(c == '.') { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if( !validDelimiters ) { + if(!validDelimiters) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if( needDelims ) { + else if(needDelims) { validDelimiters = 0; } - if( !validDelimiters ) { - err->GreaterSeverity( SEVERITY_WARNING ); - if( needDelims ) - sprintf( messageBuf, - "Enumerated value has invalid period delimiters.\n" ); + if(!validDelimiters) { + err->GreaterSeverity(SEVERITY_WARNING); + if(needDelims) + sprintf(messageBuf, + "Enumerated value has invalid period delimiters.\n"); else - sprintf( messageBuf, - "Mismatched period delimiters for enumeration.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + sprintf(messageBuf, + "Mismatched period delimiters for enumeration.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if( ( c == '.' ) || !validDelimiters ) { - err->GreaterSeverity( SEVERITY_WARNING ); + else if((c == '.') || !validDelimiters) { + err->GreaterSeverity(SEVERITY_WARNING); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -506,55 +542,59 @@ Severity SDAI_Enum::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - } else if( ( c == ',' ) || ( c == ')' ) ) { - in.putback( c ); - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + } else if((c == ',') || (c == ')')) { + in.putback(c); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } else { - in.putback( c ); - err->GreaterSeverity( SEVERITY_WARNING ); - sprintf( messageBuf, "Invalid enumeration value.\n" ); - err->AppendToDetailMsg( messageBuf ); - err->AppendToUserMsg( messageBuf ); + in.putback(c); + err->GreaterSeverity(SEVERITY_WARNING); + sprintf(messageBuf, "Invalid enumeration value.\n"); + err->AppendToDetailMsg(messageBuf); + err->AppendToUserMsg(messageBuf); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); } return err->severity(); } -Severity SDAI_Enum::StrToVal( const char * s, ErrorDescriptor * err, int optional ) { - istringstream in( ( char * )s ); // sz defaults to length of s +Severity SDAI_Enum::StrToVal(const char *s, ErrorDescriptor *err, int optional) +{ + istringstream in((char *)s); // sz defaults to length of s - ReadEnum( in, err, 1, 0 ); - if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { - err->severity( SEVERITY_NULL ); + ReadEnum(in, err, 1, 0); + if((err->severity() == SEVERITY_INCOMPLETE) && optional) { + err->severity(SEVERITY_NULL); } return err->severity(); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread( const char * s, ErrorDescriptor * err, int optional ) { - istringstream in( ( char * )s ); - return STEPread( in, err, optional ); +Severity SDAI_Enum::STEPread(const char *s, ErrorDescriptor *err, int optional) +{ + istringstream in((char *)s); + return STEPread(in, err, optional); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread( istream & in, ErrorDescriptor * err, int optional ) { - ReadEnum( in, err, 1, 1 ); - if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { - err->severity( SEVERITY_NULL ); +Severity SDAI_Enum::STEPread(istream &in, ErrorDescriptor *err, int optional) +{ + ReadEnum(in, err, 1, 1); + if((err->severity() == SEVERITY_INCOMPLETE) && optional) { + err->severity(SEVERITY_NULL); } return err->severity(); } -const char * SDAI_Enum::asStr( std::string & s ) const { - if( exists() ) { - s = element_at( v ); +const char *SDAI_Enum::asStr(std::string &s) const +{ + if(exists()) { + s = element_at(v); return s.c_str(); } else { s.clear(); @@ -562,70 +602,74 @@ const char * SDAI_Enum::asStr( std::string & s ) const { } } -void SDAI_Enum::STEPwrite( ostream & out ) const { - if( is_null() ) { +void SDAI_Enum::STEPwrite(ostream &out) const +{ + if(is_null()) { out << '$'; } else { std::string tmp; - out << "." << asStr( tmp ) << "."; + out << "." << asStr(tmp) << "."; } } -const char * SDAI_Enum::STEPwrite( std::string & s ) const { - if( is_null() ) { +const char *SDAI_Enum::STEPwrite(std::string &s) const +{ + if(is_null()) { s.clear(); } else { std::string tmp; s = "."; - s.append( asStr( tmp ) ); - s.append( "." ); + s.append(asStr(tmp)); + s.append("."); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -Severity SDAI_Enum::EnumValidLevel( istream & in, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims, int clearError ) { - if( clearError ) { +Severity SDAI_Enum::EnumValidLevel(istream &in, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims, int clearError) +{ + if(clearError) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = ' '; c = in.peek(); - if( c == '$' || in.eof() ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(c == '$' || in.eof()) { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - if( in ) { + if(in) { in >> c; } - CheckRemainingInput( in, err, "enumeration", tokenList ); + CheckRemainingInput(in, err, "enumeration", tokenList); return err->severity(); } else { ErrorDescriptor error; - ReadEnum( in, &error, 0, needDelims ); - CheckRemainingInput( in, &error, "enumeration", tokenList ); + ReadEnum(in, &error, 0, needDelims); + CheckRemainingInput(in, &error, "enumeration", tokenList); Severity sev = error.severity(); - if( sev < SEVERITY_INCOMPLETE ) { - err->AppendToDetailMsg( error.DetailMsg() ); - err->AppendToUserMsg( error.UserMsg() ); - err->GreaterSeverity( error.severity() ); - } else if( sev == SEVERITY_INCOMPLETE && !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(sev < SEVERITY_INCOMPLETE) { + err->AppendToDetailMsg(error.DetailMsg()); + err->AppendToUserMsg(error.UserMsg()); + err->GreaterSeverity(error.severity()); + } else if(sev == SEVERITY_INCOMPLETE && !optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } } return err->severity(); } -Severity SDAI_Enum::EnumValidLevel( const char * value, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims, int clearError ) { - istringstream in( ( char * )value ); - return EnumValidLevel( in, err, optional, tokenList, needDelims, - clearError ); +Severity SDAI_Enum::EnumValidLevel(const char *value, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims, int clearError) +{ + istringstream in((char *)value); + return EnumValidLevel(in, err, optional, tokenList, needDelims, + clearError); } /**************************************************************//** @@ -639,19 +683,20 @@ Severity SDAI_Enum::EnumValidLevel( const char * value, ErrorDescriptor * err, ** Status: ok 2.91 ** \returns: value set ******************************************************************/ -int SDAI_Enum::set_value( const char * n ) { - if( !n || ( !strcmp( n, "" ) ) ) { +int SDAI_Enum::set_value(const char *n) +{ + if(!n || (!strcmp(n, ""))) { nullify(); return asInt(); } int i = 0; std::string tmp; - while( ( i < no_elements() ) && - ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { + while((i < no_elements()) && + (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { ++i; } - if( no_elements() == i ) { // exhausted all the possible values + if(no_elements() == i) { // exhausted all the possible values return v = no_elements() + 1; // defined as UNSET } v = i; @@ -662,14 +707,15 @@ int SDAI_Enum::set_value( const char * n ) { /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::set_value( const int i ) { - if( i > no_elements() ) { +int SDAI_Enum::set_value(const int i) +{ + if(i > no_elements()) { v = no_elements() + 1; return v; } - const char * tmp = element_at( i ); - if( tmp[0] != '\0' ) { - return ( v = i ); + const char *tmp = element_at(i); + if(tmp[0] != '\0') { + return (v = i); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -678,19 +724,22 @@ int SDAI_Enum::set_value( const int i ) { return no_elements() + 1 ; } -SDAI_Enum & SDAI_Enum::operator= ( const int i ) { - put( i ); +SDAI_Enum &SDAI_Enum::operator= (const int i) +{ + put(i); return *this; } -SDAI_Enum & SDAI_Enum::operator= ( const SDAI_Enum & Senum ) { - put( Senum.asInt() ); +SDAI_Enum &SDAI_Enum::operator= (const SDAI_Enum &Senum) +{ + put(Senum.asInt()); return *this; } -ostream & operator<< ( ostream & out, const SDAI_Enum & a ) { +ostream &operator<< (ostream &out, const SDAI_Enum &a) +{ std::string tmp; - out << a.asStr( tmp ); + out << a.asStr(tmp); return out; } diff --git a/src/cldai/sdaiEnum.h b/src/cldai/sdaiEnum.h index c883f2be6..ed1579f07 100644 --- a/src/cldai/sdaiEnum.h +++ b/src/cldai/sdaiEnum.h @@ -15,70 +15,76 @@ #include #include -class SC_DAI_EXPORT SDAI_Enum { - friend ostream & operator<< ( ostream &, const SDAI_Enum & ); +class SC_DAI_EXPORT SDAI_Enum +{ + friend ostream &operator<< (ostream &, const SDAI_Enum &); protected: int v; // integer value of enumeration instance // mapped to a symbolic value in the elements - virtual int set_value( const char * n ); - virtual int set_value( const int n ); + virtual int set_value(const char *n); + virtual int set_value(const int n); SDAI_Enum(); public: virtual ~SDAI_Enum() {}; - void PrintContents( ostream & out = std::cout ) const { - DebugDisplay( out ); + void PrintContents(ostream &out = std::cout) const + { + DebugDisplay(out); } virtual int no_elements() const = 0; - virtual const char * Name() const = 0; - const char * get_value_at( int n ) const { - return element_at( n ); + virtual const char *Name() const = 0; + const char *get_value_at(int n) const + { + return element_at(n); } - virtual const char * element_at( int n ) const = 0; + virtual const char *element_at(int n) const = 0; - Severity EnumValidLevel( const char * value, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims = 0, int clearError = 1 ); + Severity EnumValidLevel(const char *value, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims = 0, int clearError = 1); - Severity EnumValidLevel( istream & in, ErrorDescriptor * err, - int optional, char * tokenList, - int needDelims = 0, int clearError = 1 ); + Severity EnumValidLevel(istream &in, ErrorDescriptor *err, + int optional, char *tokenList, + int needDelims = 0, int clearError = 1); - int asInt() const { + int asInt() const + { return v; } - const char * asStr( std::string & s ) const; - void STEPwrite( ostream & out = std::cout ) const; - const char * STEPwrite( std::string & s ) const; + const char *asStr(std::string &s) const; + void STEPwrite(ostream &out = std::cout) const; + const char *STEPwrite(std::string &s) const; - Severity StrToVal( const char * s, ErrorDescriptor * err, int optional = 1 ); - Severity STEPread( istream & in, ErrorDescriptor * err, int optional = 1 ); - Severity STEPread( const char * s, ErrorDescriptor * err, int optional = 1 ); + Severity StrToVal(const char *s, ErrorDescriptor *err, int optional = 1); + Severity STEPread(istream &in, ErrorDescriptor *err, int optional = 1); + Severity STEPread(const char *s, ErrorDescriptor *err, int optional = 1); - virtual int put( int val ); - virtual int put( const char * n ); - bool is_null() const { - return ( exists() == 0 ); + virtual int put(int val); + virtual int put(const char *n); + bool is_null() const + { + return (exists() == 0); } - void set_null() { + void set_null() + { nullify(); } - SDAI_Enum & operator= ( const int ); - SDAI_Enum & operator= ( const SDAI_Enum & ); + SDAI_Enum &operator= (const int); + SDAI_Enum &operator= (const SDAI_Enum &); /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? ///FIXME need to rewrite this function, but strange implementation... virtual int exists() const; virtual void nullify(); - void DebugDisplay( ostream & out = std::cout ) const; + void DebugDisplay(ostream &out = std::cout) const; protected: - virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, - int AssignVal = 1, int needDelims = 1 ); + virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, + int AssignVal = 1, int needDelims = 1); }; @@ -90,57 +96,59 @@ enum Boolean { BFalse, BTrue, BUnset }; enum Logical { LFalse, LTrue, LUnset, LUnknown }; class SC_DAI_EXPORT SDAI_LOGICAL : - public SDAI_Enum { + public SDAI_Enum +{ public: - const char * Name() const; + const char *Name() const; - SDAI_LOGICAL( const char * val = 0 ); - SDAI_LOGICAL( Logical state ); - SDAI_LOGICAL( const SDAI_LOGICAL & source ); - SDAI_LOGICAL( int i ); + SDAI_LOGICAL(const char *val = 0); + SDAI_LOGICAL(Logical state); + SDAI_LOGICAL(const SDAI_LOGICAL &source); + SDAI_LOGICAL(int i); virtual ~SDAI_LOGICAL(); virtual int no_elements() const; - virtual const char * element_at( int n ) const; + virtual const char *element_at(int n) const; operator Logical() const; - SDAI_LOGICAL & operator=( const SDAI_LOGICAL & t ); + SDAI_LOGICAL &operator=(const SDAI_LOGICAL &t); - SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; + SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; // these 2 are redefined because LUnknown has cardinal value > LUnset int exists() const; // return 0 if unset otherwise return 1 void nullify(); // change the receiver to an unset status protected: - virtual int set_value( const int n ); - virtual int set_value( const char * n ); - virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, - int AssignVal = 1, int needDelims = 1 ); + virtual int set_value(const int n); + virtual int set_value(const char *n); + virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, + int AssignVal = 1, int needDelims = 1); }; class SC_DAI_EXPORT SDAI_BOOLEAN : - public SDAI_Enum { + public SDAI_Enum +{ public: - const char * Name() const; + const char *Name() const; - SDAI_BOOLEAN( char * val = 0 ); - SDAI_BOOLEAN( ::Boolean state ); - SDAI_BOOLEAN( const SDAI_BOOLEAN & source ); - SDAI_BOOLEAN( int i ); - SDAI_BOOLEAN( const SDAI_LOGICAL & val ); + SDAI_BOOLEAN(char *val = 0); + SDAI_BOOLEAN(::Boolean state); + SDAI_BOOLEAN(const SDAI_BOOLEAN &source); + SDAI_BOOLEAN(int i); + SDAI_BOOLEAN(const SDAI_LOGICAL &val); virtual ~SDAI_BOOLEAN(); virtual int no_elements() const; - virtual const char * element_at( int n ) const; + virtual const char *element_at(int n) const; operator ::Boolean() const; - SDAI_BOOLEAN & operator=( const SDAI_LOGICAL & t ); + SDAI_BOOLEAN &operator=(const SDAI_LOGICAL &t); - SDAI_BOOLEAN & operator=( const ::Boolean t ); - SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; + SDAI_BOOLEAN &operator=(const ::Boolean t); + SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; }; diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index 67140916a..84d2389f9 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -4,76 +4,91 @@ ///////// SDAI_Model_contents_instances -SDAI_Model_contents_instances::SDAI_Model_contents_instances( ) { +SDAI_Model_contents_instances::SDAI_Model_contents_instances() +{ } -SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() { +SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() +{ } ///////// SDAI_Model_contents -SDAI_Model_contents::SDAI_Model_contents( ) { +SDAI_Model_contents::SDAI_Model_contents() +{ } -SDAI_Model_contents ::~SDAI_Model_contents() { +SDAI_Model_contents ::~SDAI_Model_contents() +{ } // const Entity_instance__set_var instances() const; //const SDAIAGGRH(Set, EntityInstanceH) Instances() const; SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() { +SDAI_Model_contents::instances_() +{ return &_instances; } SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() const { - return ( const SDAI_Model_contents_instances_ptr ) &_instances; +SDAI_Model_contents::instances_() const +{ + return (const SDAI_Model_contents_instances_ptr) &_instances; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() { +SDAI_Model_contents::folders_() +{ return &_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() const { - return ( const SDAI_Entity_extent__set_var )&_folders; +SDAI_Model_contents::folders_() const +{ + return (const SDAI_Entity_extent__set_var)&_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() { +SDAI_Model_contents::populated_folders_() +{ return &_populated_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() const { - return ( const SDAI_Entity_extent__set_var )&_populated_folders; +SDAI_Model_contents::populated_folders_() const +{ + return (const SDAI_Entity_extent__set_var)&_populated_folders; } -SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid( const SDAI_DAObject_ptr & d ) const { +SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid(const SDAI_DAObject_ptr &d) const +{ std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::get_object_pid() unimplemented!" << std::endl; (void) d; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::lookup( const SDAI_PID_DA_ptr & p ) const { +SDAI_DAObject_ptr SDAI_Model_contents::lookup(const SDAI_PID_DA_ptr &p) const +{ std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::lookup() unimplemented!" << std::endl; (void) p; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance( const char * Type ) { +SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance(const char *Type) +{ std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::CreateEntityInstance() unimplemented!" << std::endl; (void) Type; //unused return 0; } -void SDAI_Model_contents::AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ) { - _instances.contents_()->Append( appInst ); +void SDAI_Model_contents::AddInstance(const SDAI_DAObject_SDAI_ptr &appInst) +{ + _instances.contents_()->Append(appInst); } -void SDAI_Model_contents::RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ) { - _instances.contents_()->Remove( _instances.contents_()->Index( appInst ) ); +void SDAI_Model_contents::RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst) +{ + _instances.contents_()->Remove(_instances.contents_()->Index(appInst)); } @@ -81,19 +96,23 @@ void SDAI_Model_contents::RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ) { #if 0 // for now Any_var -SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) { +SDAI_Model_contents::GetEntity_extent(const std::string &entityName) +{ } const Any_var -SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) const { +SDAI_Model_contents::GetEntity_extent(const std::string &entityName) const +{ } Any_var -SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) { +SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) +{ } const Any_var -SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) const { +SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) const +{ } #endif diff --git a/src/cldai/sdaiModel_contents.h b/src/cldai/sdaiModel_contents.h index 5795232dc..060b20f06 100644 --- a/src/cldai/sdaiModel_contents.h +++ b/src/cldai/sdaiModel_contents.h @@ -26,7 +26,8 @@ // The class SDAI_Model_contents_instances shall implement convenience functions by // SDAI_Model_contents in this part of ISO 10303 -class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject { +class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject +{ public: SDAI_DAObject__set _instances; @@ -36,11 +37,13 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject { // This function shall return the set of DAObjects contained in // the receiver. - SDAI_DAObject__set_var contents_() { + SDAI_DAObject__set_var contents_() + { return &_instances; } - SDAI_DAObject__set_var contents_() const { - return ( const SDAI_DAObject__set_var ) &_instances; + SDAI_DAObject__set_var contents_() const + { + return (const SDAI_DAObject__set_var) &_instances; } }; @@ -52,7 +55,8 @@ SDAI_Model_contents_instances_var; // Model_contents_ptr def pushed ahead of #include for Entity_extent -class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { +class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance +{ //friend class SDAI_Model; @@ -89,9 +93,9 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { SDAI_Entity_extent__set_var populated_folders_(); SDAI_PID_DA_ptr - get_object_pid( const SDAI_DAObject_ptr & d ) const; + get_object_pid(const SDAI_DAObject_ptr &d) const; - SDAI_DAObject_ptr lookup( const SDAI_PID_DA_ptr & p ) const; + SDAI_DAObject_ptr lookup(const SDAI_PID_DA_ptr &p) const; /* SDAI operation declarations @@ -103,10 +107,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { // private: public: // for now at least SDAI_DAObject_ptr - CreateEntityInstance( const char * Type ); + CreateEntityInstance(const char *Type); // until we find out what this should really be in the spec - void AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ); + void AddInstance(const SDAI_DAObject_SDAI_ptr &appInst); // void AddInstance(const Entity_instance_ptr& entityHandle); //void AddInstance(EntityInstanceH& entityHandle); /* Function: @@ -131,7 +135,7 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { */ // until we find out what this should really be in the spec - void RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ); + void RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst); // void RemoveInstance(Entity_instance_ptr& entityHandle); //void RemoveInstance(EntityInstanceH& entityHandle); /* Function @@ -162,10 +166,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { */ #ifdef SDAI_CPP_LATE_BINDING #if 0 // for now - Any_var GetEntity_extent( const std::string & entityName ); - const Any_var GetEntity_extent( const std::string & entityName ) const; - Any_var GetEntity_extent( const Entity_ptr & ep ); - const Any_var GetEntity_extent( const Entity_ptr & ep ) const; + Any_var GetEntity_extent(const std::string &entityName); + const Any_var GetEntity_extent(const std::string &entityName) const; + Any_var GetEntity_extent(const Entity_ptr &ep); + const Any_var GetEntity_extent(const Entity_ptr &ep) const; #endif /* Function: The GetEntity_extent function shall retrieve an entity folder from diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index 8f6440e8e..9d0f24a56 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -30,85 +30,92 @@ #ifndef HAVE_MEMMOVE extern "C" { - void * memmove( void * __s1, const void * __s2, size_t __n ); + void *memmove(void *__s1, const void *__s2, size_t __n); } #endif /*****************************************************************************/ -SDAI_Model_contents__list::SDAI_Model_contents__list( int defaultSize ) { +SDAI_Model_contents__list::SDAI_Model_contents__list(int defaultSize) +{ _bufsize = defaultSize; _buf = new SDAI_Model_contents_ptr[_bufsize]; _count = 0; } -SDAI_Model_contents__list::~SDAI_Model_contents__list() { +SDAI_Model_contents__list::~SDAI_Model_contents__list() +{ delete _buf; } -void SDAI_Model_contents__list::Check( int index ) { +void SDAI_Model_contents__list::Check(int index) +{ - SDAI_Model_contents_ptr * newbuf; + SDAI_Model_contents_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new SDAI_Model_contents_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( SDAI_Model_contents_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(SDAI_Model_contents_ptr)); delete _buf; _buf = newbuf; } } void -SDAI_Model_contents__list::Insert( SDAI_Model_contents_ptr v, int index ) { +SDAI_Model_contents__list::Insert(SDAI_Model_contents_ptr v, int index) +{ - SDAI_Model_contents_ptr * spot; - index = ( index < 0 ) ? _count : index; + SDAI_Model_contents_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Append( SDAI_Model_contents_ptr v ) { +void SDAI_Model_contents__list::Append(SDAI_Model_contents_ptr v) +{ int index = _count; - SDAI_Model_contents_ptr * spot; + SDAI_Model_contents_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Remove( int index ) { +void SDAI_Model_contents__list::Remove(int index) +{ - if( 0 <= index && index < _count ) { + if(0 <= index && index < _count) { --_count; - SDAI_Model_contents_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); + SDAI_Model_contents_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Model_contents_ptr)); } } -int SDAI_Model_contents__list::Index( SDAI_Model_contents_ptr v ) { +int SDAI_Model_contents__list::Index(SDAI_Model_contents_ptr v) +{ - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } @@ -116,31 +123,36 @@ int SDAI_Model_contents__list::Index( SDAI_Model_contents_ptr v ) { } SDAI_Model_contents_ptr -SDAI_Model_contents__list::retrieve( int index ) { - return operator[]( index ); +SDAI_Model_contents__list::retrieve(int index) +{ + return operator[](index); } SDAI_Model_contents_ptr & -SDAI_Model_contents__list::operator[]( int index ) { +SDAI_Model_contents__list::operator[](int index) +{ - Check( index ); + Check(index); // _count = max(_count, index+1); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } int -SDAI_Model_contents__list::Count() { +SDAI_Model_contents__list::Count() +{ return _count; } int -SDAI_Model_contents__list::is_empty() { +SDAI_Model_contents__list::is_empty() +{ return _count; } void -SDAI_Model_contents__list::Clear() { +SDAI_Model_contents__list::Clear() +{ _count = 0; } diff --git a/src/cldai/sdaiModel_contents_list.h b/src/cldai/sdaiModel_contents_list.h index 47e98a072..58bd13eb6 100644 --- a/src/cldai/sdaiModel_contents_list.h +++ b/src/cldai/sdaiModel_contents_list.h @@ -3,28 +3,29 @@ #include -class SC_DAI_EXPORT SDAI_Model_contents__list { +class SC_DAI_EXPORT SDAI_Model_contents__list +{ public: - SDAI_Model_contents__list( int = 16 ); + SDAI_Model_contents__list(int = 16); ~SDAI_Model_contents__list(); - SDAI_Model_contents_ptr retrieve( int index ); + SDAI_Model_contents_ptr retrieve(int index); int is_empty(); - SDAI_Model_contents_ptr & operator[]( int index ); + SDAI_Model_contents_ptr &operator[](int index); - void Insert( SDAI_Model_contents_ptr, int index ); - void Append( SDAI_Model_contents_ptr ); - void Remove( int index ); - int Index( SDAI_Model_contents_ptr ); + void Insert(SDAI_Model_contents_ptr, int index); + void Append(SDAI_Model_contents_ptr); + void Remove(int index); + int Index(SDAI_Model_contents_ptr); void Clear(); int Count(); private: - void Check( int index ); + void Check(int index); private: - SDAI_Model_contents_ptr * _buf; + SDAI_Model_contents_ptr *_buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index 14cf6c26a..f68838b29 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,8 +1,10 @@ #include #include "sc_memmgr.h" -SDAI_sdaiObject::SDAI_sdaiObject() { +SDAI_sdaiObject::SDAI_sdaiObject() +{ } -SDAI_sdaiObject::~SDAI_sdaiObject() { +SDAI_sdaiObject::~SDAI_sdaiObject() +{ } diff --git a/src/cldai/sdaiObject.h b/src/cldai/sdaiObject.h index 99936f17c..1479af3f1 100644 --- a/src/cldai/sdaiObject.h +++ b/src/cldai/sdaiObject.h @@ -13,7 +13,8 @@ The class Entity_instance shall be a subtype of the C++ class Object: */ -class SC_DAI_EXPORT SDAI_sdaiObject { +class SC_DAI_EXPORT SDAI_sdaiObject +{ public: SDAI_sdaiObject(); virtual ~SDAI_sdaiObject(); @@ -22,7 +23,7 @@ class SC_DAI_EXPORT SDAI_sdaiObject { }; -typedef SDAI_sdaiObject * SDAI_sdaiObject_ptr; +typedef SDAI_sdaiObject *SDAI_sdaiObject_ptr; typedef SDAI_sdaiObject_ptr SDAI_sdaiObject_var; /* diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 6f48be442..7c79543e4 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,8 +1,10 @@ #include #include "sc_memmgr.h" -SDAI_Session_instance::SDAI_Session_instance() { +SDAI_Session_instance::SDAI_Session_instance() +{ } -SDAI_Session_instance::~SDAI_Session_instance() { +SDAI_Session_instance::~SDAI_Session_instance() +{ } diff --git a/src/cldai/sdaiSession_instance.h b/src/cldai/sdaiSession_instance.h index fcc8fad15..02c8e7acd 100644 --- a/src/cldai/sdaiSession_instance.h +++ b/src/cldai/sdaiSession_instance.h @@ -5,7 +5,8 @@ #include //#include -class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { +class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject +{ public: int x; @@ -14,7 +15,7 @@ class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { virtual ~SDAI_Session_instance(); }; -typedef SDAI_Session_instance * SDAI_Session_instance_ptr; +typedef SDAI_Session_instance *SDAI_Session_instance_ptr; typedef SDAI_Session_instance_ptr SDAI_Session_instance_var; // the old names diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 664a39358..9d12b8bbc 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -13,62 +13,74 @@ #include #include "sc_memmgr.h" -SDAI_String::SDAI_String( const char * str, size_t max ) { - if( !str ) { +SDAI_String::SDAI_String(const char *str, size_t max) +{ + if(!str) { str = ""; } - if( max == std::string::npos ) { - content = std::string( str ); + if(max == std::string::npos) { + content = std::string(str); } else { - content = std::string( str, max ); + content = std::string(str, max); } } -SDAI_String::SDAI_String( const std::string & s ) - : content( std::string( s ) ) { +SDAI_String::SDAI_String(const std::string &s) + : content(std::string(s)) +{ } -SDAI_String::SDAI_String( const SDAI_String & s ) - : content( std::string( s.c_str() ) ) { +SDAI_String::SDAI_String(const SDAI_String &s) + : content(std::string(s.c_str())) +{ } -SDAI_String::~SDAI_String( void ) { +SDAI_String::~SDAI_String(void) +{ } -SDAI_String & SDAI_String::operator= ( const char * s ) { - content = std::string( s ); +SDAI_String &SDAI_String::operator= (const char *s) +{ + content = std::string(s); return *this; } -bool SDAI_String::operator== ( const char * s ) const { - return ( content == s ); +bool SDAI_String::operator== (const char *s) const +{ + return (content == s); } -void SDAI_String::clear( void ) { +void SDAI_String::clear(void) +{ content.clear(); } -bool SDAI_String::empty( void ) const { +bool SDAI_String::empty(void) const +{ return content.empty(); } -const char * SDAI_String::c_str( void ) const { +const char *SDAI_String::c_str(void) const +{ return content.c_str(); } -void SDAI_String::STEPwrite( ostream & out ) const { +void SDAI_String::STEPwrite(ostream &out) const +{ out << c_str(); } -void SDAI_String::STEPwrite( std::string & s ) const { +void SDAI_String::STEPwrite(std::string &s) const +{ s += c_str(); } -Severity SDAI_String::StrToVal( const char * s ) { - operator= ( s ); - if( ! strcmp( c_str(), s ) ) { +Severity SDAI_String::StrToVal(const char *s) +{ + operator= (s); + if(! strcmp(c_str(), s)) { return SEVERITY_NULL ; } else { return SEVERITY_INPUT_ERROR; @@ -79,25 +91,26 @@ Severity SDAI_String::StrToVal( const char * s ) { * STEPread reads a string in exchange file format * starting with a single quote */ -Severity SDAI_String::STEPread( istream & in, ErrorDescriptor * err ) { +Severity SDAI_String::STEPread(istream &in, ErrorDescriptor *err) +{ clear(); // clear the old string // remember the current format state to restore the previous settings ios_base::fmtflags flags = in.flags(); - in.unsetf( ios::skipws ); + in.unsetf(ios::skipws); // extract the string from the inputstream - std::string s = GetLiteralStr( in, err ); + std::string s = GetLiteralStr(in, err); content += s; // retrieve current severity Severity sev = err -> severity(); - if( s.empty() ) { + if(s.empty()) { // no string was read - in.flags( flags ); // set the format state back to previous settings - err -> GreaterSeverity( SEVERITY_INCOMPLETE ); + in.flags(flags); // set the format state back to previous settings + err -> GreaterSeverity(SEVERITY_INCOMPLETE); sev = SEVERITY_INCOMPLETE; - } else if( sev != SEVERITY_INPUT_ERROR ) { + } else if(sev != SEVERITY_INPUT_ERROR) { // read valid string sev = SEVERITY_NULL; } @@ -107,7 +120,8 @@ Severity SDAI_String::STEPread( istream & in, ErrorDescriptor * err ) { /** * \copydoc STEPread( istream & in, ErrorDescriptor * err ) */ -Severity SDAI_String::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); - return STEPread( in, err ); +Severity SDAI_String::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); + return STEPread(in, err); } diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index 083da80ea..7021d5e70 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -15,7 +15,8 @@ #include -class SC_DAI_EXPORT SDAI_String { +class SC_DAI_EXPORT SDAI_String +{ private: #ifdef _MSC_VER #pragma warning( push ) @@ -29,29 +30,30 @@ class SC_DAI_EXPORT SDAI_String { public: //constructor(s) & destructor - SDAI_String( const char * str = "", size_t max = std::string::npos ); - SDAI_String( const std::string & s ); - SDAI_String( const SDAI_String & s ); - ~SDAI_String( void ); + SDAI_String(const char *str = "", size_t max = std::string::npos); + SDAI_String(const std::string &s); + SDAI_String(const SDAI_String &s); + ~SDAI_String(void); // operators - SDAI_String & operator= ( const char * s ); - bool operator== ( const char * s ) const; + SDAI_String &operator= (const char *s); + bool operator== (const char *s) const; - void clear( void ); - bool empty( void ) const; - const char * c_str( void ) const; + void clear(void); + bool empty(void) const; + const char *c_str(void) const; // format for STEP - const char * asStr( std::string & s ) const { + const char *asStr(std::string &s) const + { s = c_str(); return s.c_str(); } - void STEPwrite( ostream & out = cout ) const; - void STEPwrite( std::string & s ) const; + void STEPwrite(ostream &out = cout) const; + void STEPwrite(std::string &s) const; - Severity StrToVal( const char * s ); - Severity STEPread( istream & in, ErrorDescriptor * err ); - Severity STEPread( const char * s, ErrorDescriptor * err ); + Severity StrToVal(const char *s); + Severity STEPread(istream &in, ErrorDescriptor *err); + Severity STEPread(const char *s, ErrorDescriptor *err); }; diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index cb1fe5bca..7b414aa45 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -46,13 +46,14 @@ * * side effects: STEPfile::_fileName value may change. */ -std::string STEPfile::SetFileName( const std::string newName ) { +std::string STEPfile::SetFileName(const std::string newName) +{ // if a newName is not given or is the same as the old, use the old name - if( ( newName.empty() ) || ( newName == _fileName ) ) { + if((newName.empty()) || (newName == _fileName)) { return FileName(); } - _fileName = DirObj::Normalize( newName ); + _fileName = DirObj::Normalize(newName); return _fileName; } @@ -63,13 +64,14 @@ std::string STEPfile::SetFileName( const std::string newName ) { * * This function is useless unless it is called from another thread. */ -float STEPfile::GetReadProgress() const { - if( _iFileSize < 1 ) { +float STEPfile::GetReadProgress() const +{ + if(_iFileSize < 1) { return -1; } //the file is read once by ReadData1(), and again by ReadData2. Each gets 50%. - float percent = ( static_cast( _iFileCurrentPosition ) / _iFileSize ) * 50.0; - if( _iFileStage1Done ) { + float percent = (static_cast(_iFileCurrentPosition) / _iFileSize) * 50.0; + if(_iFileStage1Done) { percent += 50; } return percent; @@ -84,10 +86,11 @@ float STEPfile::GetReadProgress() const { * * This function is useless unless it is called from another thread. */ -float STEPfile::GetWriteProgress() const { +float STEPfile::GetWriteProgress() const +{ int total = _instances.InstanceCount(); - if( total > 0 ) { - return ( static_cast( _oFileInstsWritten ) / total ) * 100.0; + if(total > 0) { + return (static_cast(_oFileInstsWritten) / total) * 100.0; } else { return -1; } @@ -105,11 +108,12 @@ float STEPfile::GetWriteProgress() const { * next "ENDSEC;" from in. * The STEPfile::_headerInstances may change. */ -Severity STEPfile::ReadHeader( istream & in ) { +Severity STEPfile::ReadHeader(istream &in) +{ std::string cmtStr; - InstMgr * im = new InstMgr; - SDAI_Application_instance * obj; + InstMgr *im = new InstMgr; + SDAI_Application_instance *obj; Severity objsev = SEVERITY_NULL; int endsec = 0; @@ -121,41 +125,41 @@ Severity STEPfile::ReadHeader( istream & in ) { std::string strbuf; - ReadTokenSeparator( in ); + ReadTokenSeparator(in); // Read and gobble all 'junk' up to "HEADER;" - if( !FindHeaderSection( in ) ) { + if(!FindHeaderSection(in)) { delete im; return SEVERITY_INPUT_ERROR; } //read the header instances - while( !endsec ) { - ReadTokenSeparator( in, &cmtStr ); - if( in.eof() ) { - _error.AppendToDetailMsg( "End of file reached in reading header section.\n" ); - _error.GreaterSeverity( SEVERITY_EXIT ); + while(!endsec) { + ReadTokenSeparator(in, &cmtStr); + if(in.eof()) { + _error.AppendToDetailMsg("End of file reached in reading header section.\n"); + _error.GreaterSeverity(SEVERITY_EXIT); delete im; return SEVERITY_EXIT; } //check for user defined instances //if it is userDefined, the '!' does not get put back on the istream - in.get( c ); - if( c == '!' ) { + in.get(c); + if(c == '!') { userDefined = 1; } else { - in.putback( c ); + in.putback(c); } //get the entity keyword - keywd = GetKeyword( in, ";( /\\", _error ); - ReadTokenSeparator( in, &cmtStr ); + keywd = GetKeyword(in, ";( /\\", _error); + ReadTokenSeparator(in, &cmtStr); //check for "ENDSEC" - if( !strncmp( const_cast( keywd.c_str() ), "ENDSEC", 7 ) ) { + if(!strncmp(const_cast(keywd.c_str()), "ENDSEC", 7)) { //get the token delimiter - in.get( c ); //should be ';' + in.get(c); //should be ';' endsec = 1; break; //from while-loop } else { @@ -164,69 +168,69 @@ Severity STEPfile::ReadHeader( istream & in ) { //create header instance buf[0] = '\0'; - if( _fileType == VERSION_OLD ) { - _error.AppendToDetailMsg( "N279 header detected. Files this old are no longer supported.\n" ); - _error.GreaterSeverity( SEVERITY_EXIT ); + if(_fileType == VERSION_OLD) { + _error.AppendToDetailMsg("N279 header detected. Files this old are no longer supported.\n"); + _error.GreaterSeverity(SEVERITY_EXIT); delete im; return SEVERITY_EXIT; } else { - strncpy( buf, const_cast( keywd.c_str() ), BUFSIZ ); + strncpy(buf, const_cast(keywd.c_str()), BUFSIZ); } - if( userDefined ) { + if(userDefined) { //create user defined header instance // BUG: user defined entities are ignored //obj = _headerUserDefined->ObjCreate (buf); //objsev = AppendEntityErrorMsg( &(obj->Error()) ); - SkipInstance( in, strbuf ); + SkipInstance(in, strbuf); cerr << "User defined entity in header section " << "is ignored.\n\tdata lost: !" << buf << strbuf << "\n"; - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.GreaterSeverity(SEVERITY_WARNING); break; //from while loop } else { //not userDefined - obj = _headerRegistry->ObjCreate( buf ); + obj = _headerRegistry->ObjCreate(buf); } //read header instance - if( !obj || ( obj == ENTITY_NULL ) ) { + if(!obj || (obj == ENTITY_NULL)) { ++_errorCount; - SkipInstance( in, strbuf ); + SkipInstance(in, strbuf); cerr << "Unable to create header section entity: \'" << keywd << "\'.\n\tdata lost: " << strbuf << "\n"; - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.GreaterSeverity(SEVERITY_WARNING); } else { //not ENTITY_NULL //read the header instance - AppendEntityErrorMsg( &( obj->Error() ) ); + AppendEntityErrorMsg(&(obj->Error())); //set file_id to reflect the appropriate Header Section Entity - fileid = HeaderId( const_cast( keywd.c_str() ) ); + fileid = HeaderId(const_cast(keywd.c_str())); //read the values from the istream - objsev = obj->STEPread( fileid, 0, ( InstMgr * )0, in, NULL, true, _strict ); - _error.GreaterSeverity( objsev ); - if( !cmtStr.empty() ) { - obj->PrependP21Comment( cmtStr ); + objsev = obj->STEPread(fileid, 0, (InstMgr *)0, in, NULL, true, _strict); + _error.GreaterSeverity(objsev); + if(!cmtStr.empty()) { + obj->PrependP21Comment(cmtStr); } in >> ws; c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if( c != 'E' ) { + if(c != 'E') { in >> c; // read the semicolon } //check to see if object was successfully read - AppendEntityErrorMsg( &( obj->Error() ) ); + AppendEntityErrorMsg(&(obj->Error())); //append to header instance manager - im->Append( obj, completeSE ); + im->Append(obj, completeSE); } } cmtStr.clear(); } - HeaderVerifyInstances( im ); - HeaderMergeInstances( im ); // handles delete for im + HeaderVerifyInstances(im); + HeaderMergeInstances(im); // handles delete for im return _error.severity(); } @@ -240,88 +244,92 @@ Severity STEPfile::ReadHeader( istream & in ) { * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -Severity STEPfile::HeaderVerifyInstances( InstMgr * im ) { +Severity STEPfile::HeaderVerifyInstances(InstMgr *im) +{ int err = 0; int fileid; - SDAI_Application_instance * obj; + SDAI_Application_instance *obj; //check File_Name - fileid = HeaderId( "File_Name" ); - if( !( im->FindFileId( fileid ) ) ) { + fileid = HeaderId("File_Name"); + if(!(im->FindFileId(fileid))) { ++err; cerr << "FILE_NAME instance not found in header section\n"; // create a File_Name entity and assign default values obj = HeaderDefaultFileName(); - im->Append( obj, completeSE ); + im->Append(obj, completeSE); } //check File_Description - fileid = HeaderId( "File_Description" ); - if( !( im->FindFileId( fileid ) ) ) { + fileid = HeaderId("File_Description"); + if(!(im->FindFileId(fileid))) { ++err; cerr << "FILE_DESCRIPTION instance not found in header section\n"; // create a File_Description entity and assign default values obj = HeaderDefaultFileDescription(); - im->Append( obj, completeSE ); + im->Append(obj, completeSE); } //check File_Schema - fileid = HeaderId( "File_Schema" ); - if( !( im->FindFileId( fileid ) ) ) { + fileid = HeaderId("File_Schema"); + if(!(im->FindFileId(fileid))) { ++err; cerr << "FILE_SCHEMA instance not found in header section\n"; // create a File_Schema entity and read in default values obj = HeaderDefaultFileSchema(); - im->Append( obj, completeSE ); + im->Append(obj, completeSE); } - if( !err ) { + if(!err) { return SEVERITY_NULL; } - _error.AppendToUserMsg( "Missing required entity in header section.\n" ); - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.AppendToUserMsg("Missing required entity in header section.\n"); + _error.GreaterSeverity(SEVERITY_WARNING); return SEVERITY_WARNING; } -SDAI_Application_instance * STEPfile::HeaderDefaultFileName() { - SdaiFile_name * fn = new SdaiFile_name; +SDAI_Application_instance *STEPfile::HeaderDefaultFileName() +{ + SdaiFile_name *fn = new SdaiFile_name; StringAggregate_ptr tmp = new StringAggregate; - fn->name_( "" ); - fn->time_stamp_( "" ); - tmp->StrToVal( "", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances ); - fn->author_( tmp ); + fn->name_(""); + fn->time_stamp_(""); + tmp->StrToVal("", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances); + fn->author_(tmp); - tmp->StrToVal( "", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances ); - fn->organization_( tmp ); + tmp->StrToVal("", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances); + fn->organization_(tmp); - fn->preprocessor_version_( "" ); - fn->originating_system_( "" ); - fn->authorization_( "" ); + fn->preprocessor_version_(""); + fn->originating_system_(""); + fn->authorization_(""); - fn->STEPfile_id = HeaderId( "File_Name" ); + fn->STEPfile_id = HeaderId("File_Name"); return fn; } -SDAI_Application_instance * STEPfile::HeaderDefaultFileDescription() { - SdaiFile_description * fd = new SdaiFile_description; +SDAI_Application_instance *STEPfile::HeaderDefaultFileDescription() +{ + SdaiFile_description *fd = new SdaiFile_description; - fd->implementation_level_( "" ); + fd->implementation_level_(""); - fd->STEPfile_id = HeaderId( "File_Description" ); + fd->STEPfile_id = HeaderId("File_Description"); return fd; } -SDAI_Application_instance * STEPfile::HeaderDefaultFileSchema() { - SdaiFile_schema * fs = new SdaiFile_schema; +SDAI_Application_instance *STEPfile::HeaderDefaultFileSchema() +{ + SdaiFile_schema *fs = new SdaiFile_schema; StringAggregate_ptr tmp = new StringAggregate; - tmp->StrToVal( "", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances ); - fs->schema_identifiers_( tmp ); + tmp->StrToVal("", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances); + fs->schema_identifiers_(tmp); - fs->STEPfile_id = HeaderId( "File_Schema" ); + fs->STEPfile_id = HeaderId("File_Schema"); return fs; } @@ -347,29 +355,30 @@ SDAI_Application_instance * STEPfile::HeaderDefaultFileSchema() { * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -void STEPfile::HeaderMergeInstances( InstMgr * im ) { - SDAI_Application_instance * se = 0; - SDAI_Application_instance * from = 0; +void STEPfile::HeaderMergeInstances(InstMgr *im) +{ + SDAI_Application_instance *se = 0; + SDAI_Application_instance *from = 0; int idnum; //check for _headerInstances - if( !_headerInstances ) { + if(!_headerInstances) { _headerInstances = im; return; } - if( _headerInstances->InstanceCount() < 4 ) { + if(_headerInstances->InstanceCount() < 4) { delete _headerInstances; _headerInstances = im; return; } //checking for _headerInstances::FILE_NAME - idnum = HeaderId( "File_Name" ); - se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); - if( se ) { - from = im->GetApplication_instance( im->FindFileId( idnum ) ); + idnum = HeaderId("File_Name"); + se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); + if(se) { + from = im->GetApplication_instance(im->FindFileId(idnum)); // name: // time_stamp: keep the newer time_stamp @@ -379,34 +388,34 @@ void STEPfile::HeaderMergeInstances( InstMgr * im ) { // originating_system: // authorization: } else { // No current File_Name instance - from = im->GetApplication_instance( im->FindFileId( idnum ) ); - _headerInstances->Append( from, completeSE ); + from = im->GetApplication_instance(im->FindFileId(idnum)); + _headerInstances->Append(from, completeSE); } //checking for _headerInstances::FILE_DESCRIPTION - idnum = HeaderId( "File_Description" ); - se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); - if( se ) { - from = im->GetApplication_instance( im->FindFileId( idnum ) ); + idnum = HeaderId("File_Description"); + se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); + if(se) { + from = im->GetApplication_instance(im->FindFileId(idnum)); //description //implementation_level } else { - from = im->GetApplication_instance( im->FindFileId( idnum ) ); - _headerInstances->Append( from, completeSE ); + from = im->GetApplication_instance(im->FindFileId(idnum)); + _headerInstances->Append(from, completeSE); } //checking for _headerInstances::FILE_SCHEMA - idnum = HeaderId( "File_Schema" ); - se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); - if( se ) { - from = im->GetApplication_instance( im->FindFileId( idnum ) ); + idnum = HeaderId("File_Schema"); + se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); + if(se) { + from = im->GetApplication_instance(im->FindFileId(idnum)); //description //implementation_level } else { - from = im->GetApplication_instance( im->FindFileId( idnum ) ); - _headerInstances->Append( from, completeSE ); + from = im->GetApplication_instance(im->FindFileId(idnum)); + _headerInstances->Append(from, completeSE); } delete im; @@ -414,8 +423,9 @@ void STEPfile::HeaderMergeInstances( InstMgr * im ) { } -stateEnum STEPfile::EntityWfState( char c ) { - switch( c ) { +stateEnum STEPfile::EntityWfState(char c) +{ + switch(c) { case wsSaveComplete: return completeSE; case wsSaveIncomplete: @@ -433,7 +443,8 @@ stateEnum STEPfile::EntityWfState( char c ) { * PASS 1: create instances * starts at the data section */ -int STEPfile::ReadData1( istream & in ) { +int STEPfile::ReadData1(istream &in) +{ int endsec = 0; _entsNotCreated = 0; @@ -446,66 +457,66 @@ int STEPfile::ReadData1( istream & in ) { buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance * obj = ENTITY_NULL; + SDAI_Application_instance *obj = ENTITY_NULL; stateEnum inst_state = noStateSE; // used if reading working file ErrorDescriptor e; // PASS 1: create instances - endsec = FoundEndSecKywd( in ); - while( in.good() && !endsec ) { + endsec = FoundEndSecKywd(in); + while(in.good() && !endsec) { e.ClearErrorMsg(); - ReadTokenSeparator( in ); // also skips white space + ReadTokenSeparator(in); // also skips white space in >> c; - if( _fileType == WORKING_SESSION ) { - if( strchr( "CIND", c ) ) { // if there is a valid char - inst_state = EntityWfState( c ); - ReadTokenSeparator( in ); + if(_fileType == WORKING_SESSION) { + if(strchr("CIND", c)) { // if there is a valid char + inst_state = EntityWfState(c); + ReadTokenSeparator(in); in >> c; // read the ENTITY_NAME_DELIM } else { - e.AppendToDetailMsg( "Invalid editing state character: " ); - e.AppendToDetailMsg( c ); - e.AppendToDetailMsg( "\nAssigning editing state to be INCOMPLETE\n" ); - e.GreaterSeverity( SEVERITY_WARNING ); + e.AppendToDetailMsg("Invalid editing state character: "); + e.AppendToDetailMsg(c); + e.AppendToDetailMsg("\nAssigning editing state to be INCOMPLETE\n"); + e.GreaterSeverity(SEVERITY_WARNING); inst_state = incompleteSE; } } - if( c != ENTITY_NAME_DELIM ) { - in.putback( c ); - while( c != ENTITY_NAME_DELIM && in.good() && - !( endsec = FoundEndSecKywd( in ) ) ) { + if(c != ENTITY_NAME_DELIM) { + in.putback(c); + while(c != ENTITY_NAME_DELIM && in.good() && + !(endsec = FoundEndSecKywd(in))) { tmpbuf.clear(); - FindStartOfInstance( in, tmpbuf ); + FindStartOfInstance(in, tmpbuf); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator( in ); + ReadTokenSeparator(in); } } - if( !endsec ) { + if(!endsec) { obj = ENTITY_NULL; - if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { - SkipInstance( in, tmpbuf ); + if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { + SkipInstance(in, tmpbuf); } else { - obj = CreateInstance( in, cout ); + obj = CreateInstance(in, cout); _iFileCurrentPosition = in.tellg(); } - if( obj != ENTITY_NULL ) { - if( obj->Error().severity() < SEVERITY_WARNING ) { + if(obj != ENTITY_NULL) { + if(obj->Error().severity() < SEVERITY_WARNING) { ++_errorCount; - } else if( obj->Error().severity() < SEVERITY_NULL ) { + } else if(obj->Error().severity() < SEVERITY_NULL) { ++_warningCount; } obj->Error().ClearErrorMsg(); - if( _fileType == WORKING_SESSION ) { - instances().Append( obj, inst_state ); + if(_fileType == WORKING_SESSION) { + instances().Append(obj, inst_state); } else { - instances().Append( obj, newSE ); + instances().Append(obj, newSE); } ++instance_count; @@ -515,44 +526,46 @@ int STEPfile::ReadData1( istream & in ) { ++_errorCount; } - if( _entsNotCreated > _maxErrorCount ) { - _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); + if(_entsNotCreated > _maxErrorCount) { + _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity( SEVERITY_EXIT ); + Error().severity(SEVERITY_EXIT); return instance_count; } - endsec = FoundEndSecKywd( in ); + endsec = FoundEndSecKywd(in); } } // end while loop - if( _entsNotCreated ) { - sprintf( buf, - "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", - _entsNotCreated ); - _error.AppendToUserMsg( buf ); - _error.GreaterSeverity( SEVERITY_WARNING ); + if(_entsNotCreated) { + sprintf(buf, + "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", + _entsNotCreated); + _error.AppendToUserMsg(buf); + _error.GreaterSeverity(SEVERITY_WARNING); } - if( !in.good() ) { - _error.AppendToUserMsg( "Error in input file.\n" ); + if(!in.good()) { + _error.AppendToUserMsg("Error in input file.\n"); } _iFileStage1Done = true; return instance_count; } -int STEPfile::ReadWorkingData1( istream & in ) { - return ReadData1( in ); +int STEPfile::ReadWorkingData1(istream &in) +{ + return ReadData1(in); } /** * \returns number of valid instances read * reads in the data portion of the instances in an exchange file */ -int STEPfile::ReadData2( istream & in, bool useTechCor ) { +int STEPfile::ReadData2(istream &in, bool useTechCor) +{ _entsInvalid = 0; _entsIncomplete = 0; _entsWarning = 0; @@ -569,58 +582,58 @@ int STEPfile::ReadData2( istream & in, bool useTechCor ) { buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance * obj = ENTITY_NULL; + SDAI_Application_instance *obj = ENTITY_NULL; std::string cmtStr; - int endsec = FoundEndSecKywd( in ); + int endsec = FoundEndSecKywd(in); // PASS 2: read instances - while( in.good() && !endsec ) { - ReadTokenSeparator( in, &cmtStr ); + while(in.good() && !endsec) { + ReadTokenSeparator(in, &cmtStr); in >> c; - if( _fileType == WORKING_SESSION ) { - if( strchr( "CIND", c ) ) { // if there is a valid char - inst_state = EntityWfState( c ); - ReadTokenSeparator( in, &cmtStr ); + if(_fileType == WORKING_SESSION) { + if(strchr("CIND", c)) { // if there is a valid char + inst_state = EntityWfState(c); + ReadTokenSeparator(in, &cmtStr); in >> c; // read the ENTITY_NAME_DELIM } } - if( c != ENTITY_NAME_DELIM ) { - in.putback( c ); - while( c != ENTITY_NAME_DELIM && in.good() && - !( endsec = FoundEndSecKywd( in ) ) ) { + if(c != ENTITY_NAME_DELIM) { + in.putback(c); + while(c != ENTITY_NAME_DELIM && in.good() && + !(endsec = FoundEndSecKywd(in))) { tmpbuf.clear(); - FindStartOfInstance( in, tmpbuf ); + FindStartOfInstance(in, tmpbuf); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); } } - if( !endsec ) { + if(!endsec) { obj = ENTITY_NULL; - if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { - SkipInstance( in, tmpbuf ); + if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { + SkipInstance(in, tmpbuf); } else { - obj = ReadInstance( in, cout, cmtStr, useTechCor ); + obj = ReadInstance(in, cout, cmtStr, useTechCor); _iFileCurrentPosition = in.tellg(); } cmtStr.clear(); - if( obj != ENTITY_NULL ) { - if( obj->Error().severity() < SEVERITY_INCOMPLETE ) { + if(obj != ENTITY_NULL) { + if(obj->Error().severity() < SEVERITY_INCOMPLETE) { ++_entsInvalid; // old ++_errorCount; - } else if( obj->Error().severity() == SEVERITY_INCOMPLETE ) { + } else if(obj->Error().severity() == SEVERITY_INCOMPLETE) { ++_entsIncomplete; ++_entsInvalid; - } else if( obj->Error().severity() == SEVERITY_USERMSG ) { + } else if(obj->Error().severity() == SEVERITY_USERMSG) { ++_entsWarning; } else { // i.e. if severity == SEVERITY_NULL ++valid_insts; @@ -635,73 +648,75 @@ int STEPfile::ReadData2( istream & in, bool useTechCor ) { ++_errorCount; } - if( _entsInvalid > _maxErrorCount ) { - _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); + if(_entsInvalid > _maxErrorCount) { + _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity( SEVERITY_EXIT ); + Error().severity(SEVERITY_EXIT); return valid_insts; } - endsec = FoundEndSecKywd( in ); + endsec = FoundEndSecKywd(in); } } // end while loop - if( _entsInvalid ) { - sprintf( buf, - "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", - "Second pass complete - instance summary:", total_instances, - _entsInvalid, _entsIncomplete, "Warnings", - _entsWarning ); + if(_entsInvalid) { + sprintf(buf, + "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", + "Second pass complete - instance summary:", total_instances, + _entsInvalid, _entsIncomplete, "Warnings", + _entsWarning); cout << buf << endl; - _error.AppendToUserMsg( buf ); - _error.AppendToDetailMsg( buf ); - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.AppendToUserMsg(buf); + _error.AppendToDetailMsg(buf); + _error.GreaterSeverity(SEVERITY_WARNING); } - if( !in.good() ) { - _error.AppendToUserMsg( "Error in input file.\n" ); + if(!in.good()) { + _error.AppendToUserMsg("Error in input file.\n"); } return valid_insts; } -int STEPfile::ReadWorkingData2( istream & in, bool useTechCor ) { - return ReadData2( in, useTechCor ); +int STEPfile::ReadWorkingData2(istream &in, bool useTechCor) +{ + return ReadData2(in, useTechCor); } /** Looks for the word DATA followed by optional whitespace * followed by a semicolon. When it is looking for the word * DATA it skips over strings and comments. */ -int STEPfile::FindDataSection( istream & in ) { +int STEPfile::FindDataSection(istream &in) +{ ErrorDescriptor errs; SDAI_String tmp; std::string s; // used if need to read a comment char c; - while( in.good() ) { + while(in.good()) { in >> c; - if( in.eof() ) { - _error.AppendToUserMsg( "Can't find \"DATA;\" section." ); + if(in.eof()) { + _error.AppendToUserMsg("Can't find \"DATA;\" section."); return 0; //ERROR_WARNING } - switch( c ) { + switch(c) { case 'D': // look for string "DATA;" with optional whitespace after "DATA" c = in.peek(); // look at next char (for 'A') // only peek since it may be 'D' again a we need to start over - if( c == 'A' ) { - in.get( c ); // read char 'A' + if(c == 'A') { + in.get(c); // read char 'A' c = in.peek(); // look for 'T' - if( c == 'T' ) { - in.get( c ); // read 'T' + if(c == 'T') { + in.get(c); // read 'T' c = in.peek(); // look for 'A' - if( c == 'A' ) { - in.get( c ); // read 'A' + if(c == 'A') { + in.get(c); // read 'A' in >> ws; // may want to skip comments or print control directives? c = in.peek(); // look for semicolon - if( c == ';' ) { - in.get( c ); // read the semicolon + if(c == ';') { + in.get(c); // read the semicolon return 1; // success } } @@ -710,13 +725,13 @@ int STEPfile::FindDataSection( istream & in ) { break; case '\'': // get past the string - in.putback( c ); - tmp.STEPread( in, &errs ); + in.putback(c); + tmp.STEPread(in, &errs); break; case '/': // read p21 file comment - in.putback( c ); // looks like a comment - ReadComment( in, s ); + in.putback(c); // looks like a comment + ReadComment(in, s); break; case '\0': // problem in input ? @@ -729,22 +744,23 @@ int STEPfile::FindDataSection( istream & in ) { return 0; } -int STEPfile::FindHeaderSection( istream & in ) { +int STEPfile::FindHeaderSection(istream &in) +{ char buf[BUFSIZ]; - char * b = buf; + char *b = buf; *b = '\0'; - ReadTokenSeparator( in ); + ReadTokenSeparator(in); // find the header section - while( !( b = strstr( buf, "HEADER" ) ) ) { - if( in.eof() ) { + while(!(b = strstr(buf, "HEADER"))) { + if(in.eof()) { _error.AppendToUserMsg( - "Error: Unable to find HEADER section. File not read.\n" ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + "Error: Unable to find HEADER section. File not read.\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); return 0; } - in.getline( buf, BUFSIZ, ';' ); // reads but does not store the ; + in.getline(buf, BUFSIZ, ';'); // reads but does not store the ; } return 1; } @@ -769,7 +785,8 @@ an ENTITY_INSTANCE consists of: '#'(int)'=' [SCOPE] SUBSUPER_RECORD ';' The '#' is read from the istream before CreateInstance is called. */ -SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & out ) { +SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) +{ std::string tmpbuf; std::string objnm; @@ -777,53 +794,53 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou std::string schnm; int fileid = -1; - SDAI_Application_instance_ptr * scopelist = 0; + SDAI_Application_instance_ptr *scopelist = 0; - SDAI_Application_instance * obj; + SDAI_Application_instance *obj; ErrorDescriptor result; // Sent down to CreateSubSuperInstance() to receive error info - ReadTokenSeparator( in ); + ReadTokenSeparator(in); in >> fileid; // read instance id - fileid = IncrementFileId( fileid ); - if( instances().FindFileId( fileid ) ) { - SkipInstance( in, tmpbuf ); + fileid = IncrementFileId(fileid); + if(instances().FindFileId(fileid)) { + SkipInstance(in, tmpbuf); out << "ERROR: instance #" << fileid << " already exists.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator( in ); - in.get( c ); // read equal sign - if( c != '=' ) { + ReadTokenSeparator(in); + in.get(c); // read equal sign + if(c != '=') { // ERROR: '=' expected - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); c = in.peek(); // peek at the next character on the istream //check for optional "&SCOPE" construct - if( c == '&' ) { // TODO check this out - Severity s = CreateScopeInstances( in, &scopelist ); - if( s < SEVERITY_WARNING ) { + if(c == '&') { // TODO check this out + Severity s = CreateScopeInstances(in, &scopelist); + if(s < SEVERITY_WARNING) { return ENTITY_NULL; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); c = in.peek(); // peek at next char on istream again } //check for subtype/supertype record - if( c == '(' ) { + if(c == '(') { // TODO: implement complex inheritance - obj = CreateSubSuperInstance( in, fileid, result ); - if( obj == ENTITY_NULL ) { - SkipInstance( in, tmpbuf ); + obj = CreateSubSuperInstance(in, fileid, result); + if(obj == ENTITY_NULL) { + SkipInstance(in, tmpbuf); out << "ERROR: instance #" << fileid << " Illegal complex entity.\n" << result.UserMsg() << ".\n\n"; @@ -832,21 +849,21 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou } else { // not a complex entity // check for User Defined Entity int userDefined = 0; - if( c == '!' ) { + if(c == '!') { userDefined = 1; - in.get( c ); + in.get(c); } - ReadStdKeyword( in, objnm, 1 ); // read the type name - if( !in.good() ) { + ReadStdKeyword(in, objnm, 1); // read the type name + if(!in.good()) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::CreateInstance.\n"; } //create the instance using the Registry object - if( userDefined ) { - SkipInstance( in, tmpbuf ); + if(userDefined) { + SkipInstance(in, tmpbuf); out << "WARNING: instance #" << fileid << " User Defined Entity in DATA section ignored.\n" << "\tData lost: \'!" << objnm << "\': " << tmpbuf @@ -854,18 +871,18 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou return ENTITY_NULL; } else { schnm = schemaName(); - obj = reg().ObjCreate( objnm.c_str(), schnm.c_str() ); - if( obj == ENTITY_NULL ) { + obj = reg().ObjCreate(objnm.c_str(), schnm.c_str()); + if(obj == ENTITY_NULL) { // This will be the case if objnm does not exist in the reg. - result.UserMsg( "Unknown ENTITY type" ); - } else if( obj->Error().severity() <= SEVERITY_WARNING ) { + result.UserMsg("Unknown ENTITY type"); + } else if(obj->Error().severity() <= SEVERITY_WARNING) { // Common causes of error is that obj is an abstract supertype // or that it can only be instantiated using external mapping. // If neither are the case, create a generic message. - if( !obj->Error().UserMsg().empty() ) { - result.UserMsg( obj->Error().UserMsg() ); + if(!obj->Error().UserMsg().empty()) { + result.UserMsg(obj->Error().UserMsg()); } else { - result.UserMsg( "Could not create ENTITY" ); + result.UserMsg("Could not create ENTITY"); } // Delete obj so that below we'll know that an error occur: delete obj; @@ -874,8 +891,8 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou } } - if( obj == ENTITY_NULL ) { - SkipInstance( in, tmpbuf ); + if(obj == ENTITY_NULL) { + SkipInstance(in, tmpbuf); out << "ERROR: instance #" << fileid << " \'" << objnm << "\': " << result.UserMsg() << ".\n\tData lost: " << tmpbuf << "\n\n"; @@ -884,9 +901,9 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou obj -> STEPfile_id = fileid; // scan values - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); - ReadTokenSeparator( in ); + ReadTokenSeparator(in); return obj; } @@ -905,60 +922,61 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou < SEVERITY_WARNING: the istream was read up to and including the next ";" < SEVERITY_BUG: fatal */ -Severity STEPfile::CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ) { +Severity STEPfile::CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist) +{ Severity rval = SEVERITY_NULL; - SDAI_Application_instance * se; + SDAI_Application_instance *se; std::string tmpbuf; char c; std::vector< SDAI_Application_instance_ptr > inscope; std::string keywd; - keywd = GetKeyword( in, " \n\t/\\#;", _error ); - if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { + keywd = GetKeyword(in, " \n\t/\\#;", _error); + if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { //ERROR: "&SCOPE" expected //TODO: should attempt to recover by reading through ENDSCOPE //currently recovery is attempted by reading through next ";" - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << "ERROR: " << "\'&SCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; return SEVERITY_INPUT_ERROR; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); - in.get( c ); - while( c == '#' ) { - se = CreateInstance( in, cout ); - if( se != ENTITY_NULL ) { + in.get(c); + while(c == '#') { + se = CreateInstance(in, cout); + if(se != ENTITY_NULL) { //TODO: apply scope information to se // Add se to scopelist - inscope.push_back( se ); + inscope.push_back(se); //append the se to the instance manager - instances().Append( se, newSE ); + instances().Append(se, newSE); } else { //ERROR: instance in SCOPE not created rval = SEVERITY_WARNING; - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << "instance in SCOPE not created.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; } - ReadTokenSeparator( in ); - in.get( c ); + ReadTokenSeparator(in); + in.get(c); } - in.putback( c ); + in.putback(c); *scopelist = new SDAI_Application_instance_ptr [inscope.size()]; - for( size_t i = 0; i < inscope.size(); ++i ) { + for(size_t i = 0; i < inscope.size(); ++i) { *scopelist[i] = inscope[i]; } //check for "ENDSCOPE" - keywd = GetKeyword( in, " \t\n/\\#;", _error ); - if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { + keywd = GetKeyword(in, " \t\n/\\#;", _error); + if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { //ERROR: "ENDSCOPE" expected - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << "ERROR: " << "\'ENDSCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; @@ -966,37 +984,38 @@ Severity STEPfile::CreateScopeInstances( istream & in, SDAI_Application_instance } //check for export list - ReadTokenSeparator( in ); - in.get( c ); - in.putback( c ); - if( c == '/' ) { + ReadTokenSeparator(in); + in.get(c); + in.putback(c); + if(c == '/') { //read export list - in.get( c ); + in.get(c); c = ','; - while( c == ',' ) { + while(c == ',') { int exportid; - ReadTokenSeparator( in ); - in.get( c ); - if( c != '#' ) { } //ERROR + ReadTokenSeparator(in); + in.get(c); + if(c != '#') { } //ERROR in >> exportid; //TODO: nothing is done with the idnums on the export list - ReadTokenSeparator( in ); - in.get( c ); + ReadTokenSeparator(in); + in.get(c); } - if( c != '/' ) { + if(c != '/') { //ERROR: '/' expected while reading export list - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << "ERROR: \'/\' expected in export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_INPUT_ERROR; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); } return rval; } -SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int fileid, ErrorDescriptor & e ) { - SDAI_Application_instance * obj = ENTITY_NULL; +SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fileid, ErrorDescriptor &e) +{ + SDAI_Application_instance *obj = ENTITY_NULL; char c; std::string schnm; @@ -1005,20 +1024,20 @@ SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int ErrorDescriptor err; // used to catch error msgs const int enaSize = 64; - std::string * entNmArr[enaSize]; // array of entity type names + std::string *entNmArr[enaSize]; // array of entity type names int enaIndex = 0; in >> ws; - in.get( c ); // read the open paren + in.get(c); // read the open paren c = in.peek(); // see if you have closed paren (ending the record) - while( in.good() && ( c != ')' ) && ( enaIndex < enaSize ) ) { - entNmArr[enaIndex] = new std::string( "" ); - ReadStdKeyword( in, *( entNmArr[enaIndex] ), 1 ); // read the type name - if( entNmArr[enaIndex]->empty() ) { + while(in.good() && (c != ')') && (enaIndex < enaSize)) { + entNmArr[enaIndex] = new std::string(""); + ReadStdKeyword(in, *(entNmArr[enaIndex]), 1); // read the type name + if(entNmArr[enaIndex]->empty()) { delete entNmArr[enaIndex]; entNmArr[enaIndex] = 0; } else { - SkipSimpleRecord( in, buf, &err ); + SkipSimpleRecord(in, buf, &err); buf.clear(); enaIndex++; } @@ -1028,7 +1047,7 @@ SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int // garbage or a comment) this will keep the read function from // infinite looping. If the entity name starts with a digit it is // incorrect and will be invalid. - while( in.good() && ( c != ')' ) && !isalpha( c ) ) { + while(in.good() && (c != ')') && !isalpha(c)) { in >> c; // skip the invalid char c = in.peek(); // see if you have closed paren (ending the record) } @@ -1036,18 +1055,18 @@ SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int entNmArr[enaIndex] = 0; schnm = schemaName(); - obj = new STEPcomplex( &_reg, ( const std::string ** )entNmArr, fileid, schnm.c_str() ); + obj = new STEPcomplex(&_reg, (const std::string **)entNmArr, fileid, schnm.c_str()); - if( obj->Error().severity() <= SEVERITY_WARNING ) { + if(obj->Error().severity() <= SEVERITY_WARNING) { // If obj is not legal, record its error info and delete it: - e.severity( obj->Error().severity() ); - e.UserMsg( obj->Error().UserMsg() ); + e.severity(obj->Error().severity()); + e.UserMsg(obj->Error().UserMsg()); delete obj; obj = ENTITY_NULL; } enaIndex = 0; - while( entNmArr[enaIndex] != 0 ) { + while(entNmArr[enaIndex] != 0) { delete entNmArr[enaIndex]; enaIndex ++; } @@ -1063,29 +1082,30 @@ SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int It first searches for "&SCOPE" and reads all characters from the istream up to and including "ENDSCOPE" */ -Severity STEPfile::ReadScopeInstances( istream & in ) { +Severity STEPfile::ReadScopeInstances(istream &in) +{ Severity rval = SEVERITY_NULL; - SDAI_Application_instance * se; + SDAI_Application_instance *se; std::string tmpbuf; char c; std::string keywd; std::string cmtStr; - keywd = GetKeyword( in, " \n\t/\\#;", _error ); - if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { + keywd = GetKeyword(in, " \n\t/\\#;", _error); + if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { //ERROR: "&SCOPE" expected - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << "\'&SCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); - in.get( c ); - while( c == '#' ) { - se = ReadInstance( in, cout, cmtStr ); - if( se != ENTITY_NULL ) { + in.get(c); + while(c == '#') { + se = ReadInstance(in, cout, cmtStr); + if(se != ENTITY_NULL) { //apply scope information to se //TODO: not yet implemented } else { @@ -1093,46 +1113,46 @@ Severity STEPfile::ReadScopeInstances( istream & in ) { rval = SEVERITY_WARNING; } - ReadTokenSeparator( in ); - in.get( c ); + ReadTokenSeparator(in); + in.get(c); } - in.putback( c ); + in.putback(c); //check for "ENDSCOPE" - keywd = GetKeyword( in, " \t\n/\\#;", _error ); - if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { + keywd = GetKeyword(in, " \t\n/\\#;", _error); + if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { //ERROR: "ENDSCOPE" expected - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << " \'ENDSCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } //check for export list - ReadTokenSeparator( in ); - in.get( c ); - in.putback( c ); - if( c == '/' ) { + ReadTokenSeparator(in); + in.get(c); + in.putback(c); + if(c == '/') { //read through export list - in.get( c ); + in.get(c); c = ','; - while( c == ',' ) { + while(c == ',') { int exportid; - ReadTokenSeparator( in ); - in.get( c ); + ReadTokenSeparator(in); + in.get(c); in >> exportid; - ReadTokenSeparator( in ); - in.get( c ); + ReadTokenSeparator(in); + in.get(c); } - if( c != '/' ) { + if(c != '/') { //ERROR: '/' expected while reading export list - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); cerr << " \'/\' expected while reading export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_WARNING; } - ReadTokenSeparator( in ); + ReadTokenSeparator(in); } return rval; } @@ -1145,8 +1165,9 @@ Severity STEPfile::ReadScopeInstances( istream & in ) { reading the SDAI_Application_instance. It passes SDAI_Application_instance error information onto the STEPfile ErrorDescriptor. */ -SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr, - bool useTechCor ) { +SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std::string &cmtStr, + bool useTechCor) +{ Severity sev = SEVERITY_NULL; std::string tmpbuf; @@ -1157,33 +1178,33 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, char c; int fileid; - SDAI_Application_instance * obj = ENTITY_NULL; + SDAI_Application_instance *obj = ENTITY_NULL; int idIncrNum = FileIdIncr(); - ReadComment( in, cmtStr ); + ReadComment(in, cmtStr); in >> fileid; - fileid = IncrementFileId( fileid ); + fileid = IncrementFileId(fileid); // check to see that instance was created on PASS 1 - MgrNode * node = instances().FindFileId( fileid ); - if( ( !node ) || ( ( obj = node -> GetApplication_instance() ) == ENTITY_NULL ) ) { - SkipInstance( in, tmpbuf ); + MgrNode *node = instances().FindFileId(fileid); + if((!node) || ((obj = node -> GetApplication_instance()) == ENTITY_NULL)) { + SkipInstance(in, tmpbuf); // Changed the 2nd pass error message to report Part 21 User // Defined Entities. STEPfile still includes them in the error count // which is not valid. // Check to see if an User Defined Entity has been found. - const char * ude = tmpbuf.c_str(); - while( *ude && ( *ude != '=' ) ) { + const char *ude = tmpbuf.c_str(); + while(*ude && (*ude != '=')) { ude++; } - if( *ude == '=' ) { + if(*ude == '=') { ude++; } - while( *ude && isspace( *ude ) ) { + while(*ude && isspace(*ude)) { ude++; } - if( *ude == '!' ) { + if(*ude == '!') { out << "\nWARNING: #" << fileid << " - Ignoring User Defined Entity.\n\tData lost: " << tmpbuf << endl; @@ -1191,80 +1212,80 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, out << "\nERROR: in 2nd pass, instance #" << fileid << " not found.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; - } else if( ( _fileType != WORKING_SESSION ) && ( node->CurrState() != newSE ) ) { - SkipInstance( in, tmpbuf ); + } else if((_fileType != WORKING_SESSION) && (node->CurrState() != newSE)) { + SkipInstance(in, tmpbuf); out << "\nERROR: in 2nd pass, instance #" << fileid << " already exists - ignoring duplicate.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); - in.get( c ); - if( c != '=' ) { + in.get(c); + if(c != '=') { //ERROR: '=' expected - SkipInstance( in, tmpbuf ); + SkipInstance(in, tmpbuf); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); //peek at the next character on the istream c = in.peek(); //check for optional "&SCOPE" construct - if( c == '&' ) { - ReadScopeInstances( in ); - ReadTokenSeparator( in, &cmtStr ); - in.get( c ); - in.putback( c ); + if(c == '&') { + ReadScopeInstances(in); + ReadTokenSeparator(in, &cmtStr); + in.get(c); + in.putback(c); } currSch = schemaName(); //check for subtype/supertype record - if( c == '(' ) { + if(c == '(') { // TODO - sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict ); + sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict); - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); - if( !cmtStr.empty() ) { - obj->AddP21Comment( cmtStr ); + if(!cmtStr.empty()) { + obj->AddP21Comment(cmtStr); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if( c != 'E' ) { + if(c != 'E') { in >> c; // read the semicolon } } else { - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); c = in.peek(); // check for User Defined Entity // DAS - I checked this out. It doesn't get into this code for user // defined entities because a ude isn't created. int userDefined = 0; - if( c == '!' ) { + if(c == '!') { userDefined = 1; - in.get( c ); + in.get(c); } - ReadStdKeyword( in, objnm, 1 ); // read the type name - if( !in.good() ) { + ReadStdKeyword(in, objnm, 1); // read the type name + if(!in.good()) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::ReadInstance." << endl; } - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); // read values - if( userDefined ) { - SkipInstance( in, tmpbuf ); + if(userDefined) { + SkipInstance(in, tmpbuf); out << "WARNING: #" << fileid << ". Ignoring User defined entity." << endl << " data lost: !" << objnm << tmpbuf << endl; @@ -1275,30 +1296,30 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, // NOTE: this function is called for all FileTypes // (WORKING_SESSION included) - sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict ); + sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict); - ReadTokenSeparator( in, &cmtStr ); + ReadTokenSeparator(in, &cmtStr); - if( !cmtStr.empty() ) { - obj->AddP21Comment( cmtStr ); + if(!cmtStr.empty()) { + obj->AddP21Comment(cmtStr); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if( c != 'E' ) { + if(c != 'E') { in >> c; // read the semicolon } - AppendEntityErrorMsg( &( obj->Error() ) ); + AppendEntityErrorMsg(&(obj->Error())); } //set the node's state, //and set the STEPfile:_error (based on the type of file being read) - switch( sev ) { + switch(sev) { case SEVERITY_NULL: case SEVERITY_USERMSG: - if( _fileType != WORKING_SESSION ) { - node->ChangeState( completeSE ); + if(_fileType != WORKING_SESSION) { + node->ChangeState(completeSE); } break; @@ -1307,18 +1328,18 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, case SEVERITY_BUG: case SEVERITY_INCOMPLETE: - if( _fileType == VERSION_CURRENT ) { + if(_fileType == VERSION_CURRENT) { cerr << "ERROR in EXCHANGE FILE: incomplete instance #" << obj -> STEPfile_id << ".\n"; - if( _fileType != WORKING_SESSION ) { - node->ChangeState( incompleteSE ); + if(_fileType != WORKING_SESSION) { + node->ChangeState(incompleteSE); } } else { - if( node->CurrState() == completeSE ) { - sprintf( errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid ); - _error.AppendToUserMsg( errbuf ); - if( _fileType != WORKING_SESSION ) { - node->ChangeState( incompleteSE ); + if(node->CurrState() == completeSE) { + sprintf(errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid); + _error.AppendToUserMsg(errbuf); + if(_fileType != WORKING_SESSION) { + node->ChangeState(incompleteSE); } } } @@ -1327,8 +1348,8 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, case SEVERITY_EXIT: case SEVERITY_DUMP: case SEVERITY_MAX: - if( _fileType != WORKING_SESSION ) { - node->ChangeState( noStateSE ); + if(_fileType != WORKING_SESSION) { + node->ChangeState(noStateSE); } break; @@ -1359,96 +1380,100 @@ BUG: doesn't check to see if the backup command works. the results of the system call are not used by the by this function */ -void STEPfile::MakeBackupFile() { +void STEPfile::MakeBackupFile() +{ std::string bckup = FileName(); - bckup.append( ".bak" ); + bckup.append(".bak"); - std::fstream f( FileName().c_str(), std::fstream::in | std::fstream::binary ); + std::fstream f(FileName().c_str(), std::fstream::in | std::fstream::binary); f << std::noskipws; - std::istream_iterator begin( f ); + std::istream_iterator begin(f); std::istream_iterator end; - std::fstream f2( bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary ); - std::ostream_iterator begin2( f2 ); + std::fstream f2(bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary); + std::ostream_iterator begin2(f2); - copy( begin, end, begin2 ); + copy(begin, end, begin2); - _error.AppendToDetailMsg( "Making backup file: " ); - _error.AppendToDetailMsg( bckup.c_str() ); - _error.AppendToDetailMsg( "\n" ); + _error.AppendToDetailMsg("Making backup file: "); + _error.AppendToDetailMsg(bckup.c_str()); + _error.AppendToDetailMsg("\n"); } -Severity STEPfile::WriteExchangeFile( ostream & out, int validate, int clearError, - int writeComments ) { +Severity STEPfile::WriteExchangeFile(ostream &out, int validate, int clearError, + int writeComments) +{ Severity rval = SEVERITY_NULL; - SetFileType( VERSION_CURRENT ); - if( clearError ) { + SetFileType(VERSION_CURRENT); + if(clearError) { _error.ClearErrorMsg(); } - if( validate ) { - rval = instances().VerifyInstances( _error ); - _error.GreaterSeverity( rval ); - if( rval < SEVERITY_USERMSG ) { - _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); - _error.GreaterSeverity( SEVERITY_INCOMPLETE ); + if(validate) { + rval = instances().VerifyInstances(_error); + _error.GreaterSeverity(rval); + if(rval < SEVERITY_USERMSG) { + _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); + _error.GreaterSeverity(SEVERITY_INCOMPLETE); return rval; } } out << FILE_DELIM << "\n"; - WriteHeader( out ); - WriteData( out, writeComments ); + WriteHeader(out); + WriteData(out, writeComments); out << END_FILE_DELIM << "\n"; return rval; } -Severity STEPfile::WriteExchangeFile( const std::string filename, int validate, int clearError, - int writeComments ) { +Severity STEPfile::WriteExchangeFile(const std::string filename, int validate, int clearError, + int writeComments) +{ Severity rval = SEVERITY_NULL; - if( clearError ) { + if(clearError) { _error.ClearErrorMsg(); } - if( validate ) { - rval = instances().VerifyInstances( _error ); - _error.GreaterSeverity( rval ); - if( rval < SEVERITY_USERMSG ) { - _error.AppendToUserMsg( "Unable to verify instances. File wasn't opened. Try saving as working session file.\n" ); - _error.GreaterSeverity( SEVERITY_INCOMPLETE ); + if(validate) { + rval = instances().VerifyInstances(_error); + _error.GreaterSeverity(rval); + if(rval < SEVERITY_USERMSG) { + _error.AppendToUserMsg("Unable to verify instances. File wasn't opened. Try saving as working session file.\n"); + _error.GreaterSeverity(SEVERITY_INCOMPLETE); return rval; } } - ostream * out = OpenOutputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { + ostream *out = OpenOutputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { return _error.severity(); } - rval = WriteExchangeFile( *out, 0, 0, writeComments ); - CloseOutputFile( out ); + rval = WriteExchangeFile(*out, 0, 0, writeComments); + CloseOutputFile(out); return rval; } -Severity STEPfile::WriteValuePairsFile( ostream & out, int validate, int clearError, - int writeComments, int mixedCase ) { +Severity STEPfile::WriteValuePairsFile(ostream &out, int validate, int clearError, + int writeComments, int mixedCase) +{ Severity rval = SEVERITY_NULL; - SetFileType( VERSION_CURRENT ); - if( clearError ) { + SetFileType(VERSION_CURRENT); + if(clearError) { _error.ClearErrorMsg(); } - if( validate ) { - rval = instances().VerifyInstances( _error ); - _error.GreaterSeverity( rval ); - if( rval < SEVERITY_USERMSG ) { - _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); - _error.GreaterSeverity( SEVERITY_INCOMPLETE ); + if(validate) { + rval = instances().VerifyInstances(_error); + _error.GreaterSeverity(rval); + if(rval < SEVERITY_USERMSG) { + _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); + _error.GreaterSeverity(SEVERITY_INCOMPLETE); return rval; } } - WriteValuePairsData( out, writeComments, mixedCase ); + WriteValuePairsData(out, writeComments, mixedCase); return rval; } @@ -1466,18 +1491,19 @@ The header section entities must be numbered in the following manner: #2=FILE_NAME #3=FILE_SCHEMA */ -int STEPfile::HeaderId( const char * name ) { +int STEPfile::HeaderId(const char *name) +{ std::string tmp = name; - std::transform( tmp.begin(), tmp.end(), tmp.begin(), ::toupper ); + std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::toupper); - if( tmp == "FILE_DESCRIPTION" ) { + if(tmp == "FILE_DESCRIPTION") { return 1; } - if( tmp == "FILE_NAME" ) { + if(tmp == "FILE_NAME") { return 2; } - if( tmp == "FILE_SCHEMA" ) { + if(tmp == "FILE_SCHEMA") { return 3; } return ++_headerId; @@ -1485,41 +1511,43 @@ int STEPfile::HeaderId( const char * name ) { /*************************** ***************************/ -void STEPfile::WriteHeader( ostream & out ) { +void STEPfile::WriteHeader(ostream &out) +{ out << "HEADER;\n"; - WriteHeaderInstanceFileDescription( out ); - WriteHeaderInstanceFileName( out ); - WriteHeaderInstanceFileSchema( out ); + WriteHeaderInstanceFileDescription(out); + WriteHeaderInstanceFileName(out); + WriteHeaderInstanceFileSchema(out); // Write the rest of the header instances - SDAI_Application_instance * se; + SDAI_Application_instance *se; int n = _headerInstances->InstanceCount(); - for( int i = 0; i < n; ++i ) { - se = _headerInstances->GetMgrNode( i ) ->GetApplication_instance(); - if( !( - ( se->StepFileId() == HeaderId( "File_Name" ) ) || - ( se->StepFileId() == HeaderId( "File_Description" ) ) || - ( se->StepFileId() == HeaderId( "File_Schema" ) ) - ) ) + for(int i = 0; i < n; ++i) { + se = _headerInstances->GetMgrNode(i) ->GetApplication_instance(); + if(!( + (se->StepFileId() == HeaderId("File_Name")) || + (se->StepFileId() == HeaderId("File_Description")) || + (se->StepFileId() == HeaderId("File_Schema")) + )) WriteHeaderInstance( - _headerInstances->GetMgrNode( i )->GetApplication_instance(), out ); + _headerInstances->GetMgrNode(i)->GetApplication_instance(), out); } out << "ENDSEC;\n"; } /*************************** ***************************/ -void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ) { +void STEPfile::WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out) +{ std::string tmp; - if( !obj->P21Comment().empty() ) { + if(!obj->P21Comment().empty()) { out << obj->P21Comment(); } - out << StrToUpper( obj->EntityName(), tmp ) << "("; + out << StrToUpper(obj->EntityName(), tmp) << "("; int n = obj->attributes.list_length(); - for( int i = 0; i < n; ++i ) { - ( obj->attributes[i] ).STEPwrite( out ); - if( i < n - 1 ) { + for(int i = 0; i < n; ++i) { + (obj->attributes[i]).STEPwrite(out); + if(i < n - 1) { out << ","; } } @@ -1528,16 +1556,17 @@ void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & o /*************************** ***************************/ -void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { +void STEPfile::WriteHeaderInstanceFileName(ostream &out) +{ // Get the FileName instance from _headerInstances - SDAI_Application_instance * se = 0; - se = _headerInstances->GetApplication_instance( "File_Name" ); - if( se == ENTITY_NULL ) { - se = ( SDAI_Application_instance * )HeaderDefaultFileName(); + SDAI_Application_instance *se = 0; + se = _headerInstances->GetApplication_instance("File_Name"); + if(se == ENTITY_NULL) { + se = (SDAI_Application_instance *)HeaderDefaultFileName(); } //set some of the attribute values at time of output - SdaiFile_name * fn = ( SdaiFile_name * )se; + SdaiFile_name *fn = (SdaiFile_name *)se; /* I'm not sure this is a good idea that Peter did but I'll leave around - DAS // write time_stamp (as specified in ISO Standard 8601) @@ -1545,130 +1574,135 @@ void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { // example: '1994-04-12T15:27:46' // for Calendar Date, 12 April 1994, 27 minute 46 seconds past 15 hours */ - time_t t = time( NULL ); - struct tm * timeptr = localtime( &t ); + time_t t = time(NULL); + struct tm *timeptr = localtime(&t); char time_buf[26]; - strftime( time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr ); - fn->time_stamp_( time_buf ); + strftime(time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr); + fn->time_stamp_(time_buf); //output the values to the file - WriteHeaderInstance( se, out ); + WriteHeaderInstance(se, out); } -void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) { +void STEPfile::WriteHeaderInstanceFileDescription(ostream &out) +{ // Get the FileDescription instance from _headerInstances - SDAI_Application_instance * se = 0; - se = _headerInstances->GetApplication_instance( "File_Description" ); - if( se == ENTITY_NULL ) { + SDAI_Application_instance *se = 0; + se = _headerInstances->GetApplication_instance("File_Description"); + if(se == ENTITY_NULL) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = ( SDAI_Application_instance * )HeaderDefaultFileDescription(); + se = (SDAI_Application_instance *)HeaderDefaultFileDescription(); } - WriteHeaderInstance( se, out ); + WriteHeaderInstance(se, out); } -void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) { +void STEPfile::WriteHeaderInstanceFileSchema(ostream &out) +{ // Get the FileName instance from _headerInstances - SDAI_Application_instance * se = 0; - se = _headerInstances->GetApplication_instance( "File_Schema" ); - if( se == ENTITY_NULL ) { + SDAI_Application_instance *se = 0; + se = _headerInstances->GetApplication_instance("File_Schema"); + if(se == ENTITY_NULL) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = ( SDAI_Application_instance * ) HeaderDefaultFileSchema(); + se = (SDAI_Application_instance *) HeaderDefaultFileSchema(); } - WriteHeaderInstance( se, out ); + WriteHeaderInstance(se, out); } -void STEPfile::WriteData( ostream & out, int writeComments ) { +void STEPfile::WriteData(ostream &out, int writeComments) +{ _oFileInstsWritten = 0; std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for( int i = 0; i < n; ++i ) { - instances().GetMgrNode( i )->GetApplication_instance()->STEPwrite( out, currSch.c_str(), writeComments ); + for(int i = 0; i < n; ++i) { + instances().GetMgrNode(i)->GetApplication_instance()->STEPwrite(out, currSch.c_str(), writeComments); _oFileInstsWritten++; } out << "ENDSEC;\n"; } -void STEPfile::WriteValuePairsData( ostream & out, int writeComments, int mixedCase ) { +void STEPfile::WriteValuePairsData(ostream &out, int writeComments, int mixedCase) +{ std::string currSch = schemaName(); int n = instances().InstanceCount(); - for( int i = 0; i < n; ++i ) { - instances().GetMgrNode( i )->GetApplication_instance()->WriteValuePairs( out, currSch.c_str(), writeComments, mixedCase ); + for(int i = 0; i < n; ++i) { + instances().GetMgrNode(i)->GetApplication_instance()->WriteValuePairs(out, currSch.c_str(), writeComments, mixedCase); } } -Severity STEPfile::AppendFile( istream * in, bool useTechCor ) { +Severity STEPfile::AppendFile(istream *in, bool useTechCor) +{ Severity rval = SEVERITY_NULL; char errbuf[BUFSIZ]; SetFileIdIncrement(); int total_insts = 0, valid_insts = 0; - ReadTokenSeparator( *in ); - std::string keywd = GetKeyword( *in, "; #", _error ); + ReadTokenSeparator(*in); + std::string keywd = GetKeyword(*in, "; #", _error); // get the delimiter off the istream char c; - in->get( c ); - - if( !strncmp( const_cast( keywd.c_str() ), "ISO-10303-21", - strlen( const_cast( keywd.c_str() ) ) ) ) { - SetFileType( VERSION_CURRENT ); - } else if( !strncmp( const_cast( keywd.c_str() ), "STEP_WORKING_SESSION", - strlen( const_cast( keywd.c_str() ) ) ) ) { - if( _fileType != WORKING_SESSION ) { + in->get(c); + + if(!strncmp(const_cast(keywd.c_str()), "ISO-10303-21", + strlen(const_cast(keywd.c_str())))) { + SetFileType(VERSION_CURRENT); + } else if(!strncmp(const_cast(keywd.c_str()), "STEP_WORKING_SESSION", + strlen(const_cast(keywd.c_str())))) { + if(_fileType != WORKING_SESSION) { _error.AppendToUserMsg( - "Warning: Reading in file as Working Session file.\n" ); - _error.GreaterSeverity( SEVERITY_WARNING ); + "Warning: Reading in file as Working Session file.\n"); + _error.GreaterSeverity(SEVERITY_WARNING); } - SetFileType( WORKING_SESSION ); + SetFileType(WORKING_SESSION); } else { - sprintf( errbuf, - "Faulty input at beginning of file. \"ISO-10303-21;\" or" - " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", - ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); - _error.AppendToUserMsg( errbuf ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf(errbuf, + "Faulty input at beginning of file. \"ISO-10303-21;\" or" + " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", + ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); + _error.AppendToUserMsg(errbuf); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; } - cout << "Reading Data from " << ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) << "...\n"; + cout << "Reading Data from " << ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str()) << "...\n"; // Read header - rval = ReadHeader( *in ); + rval = ReadHeader(*in); cout << "\nHEADER read:"; - if( rval < SEVERITY_WARNING ) { - sprintf( errbuf, - "Error: non-recoverable error in reading header section. " - "There were %d errors encountered. Rest of file is ignored.\n", - _errorCount ); - _error.AppendToUserMsg( errbuf ); + if(rval < SEVERITY_WARNING) { + sprintf(errbuf, + "Error: non-recoverable error in reading header section. " + "There were %d errors encountered. Rest of file is ignored.\n", + _errorCount); + _error.AppendToUserMsg(errbuf); return rval; - } else if( rval != SEVERITY_NULL ) { - sprintf( errbuf, " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount ); + } else if(rval != SEVERITY_NULL) { + sprintf(errbuf, " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount); cout << errbuf; } else { cout << endl; } - if( !FindDataSection( *in ) ) { - _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n" ); + if(!FindDataSection(*in)) { + _error.AppendToUserMsg("Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n"); return SEVERITY_INPUT_ERROR; } // PASS 1 _errorCount = 0; - total_insts = ReadData1( *in ); + total_insts = ReadData1(*in); cout << "\nFIRST PASS complete: " << total_insts << " instances created.\n"; - sprintf( errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount ); + sprintf(errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount); cout << errbuf; // PASS 2 @@ -1682,140 +1716,143 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) { // reset the error count so you're not counting things twice: _errorCount = 0; - istream * in2; - if( !( ( in2 = OpenInputFile() ) && ( in2 -> good() ) ) ) { + istream *in2; + if(!((in2 = OpenInputFile()) && (in2 -> good()))) { // if the stream is not readable, there's an error - _error.AppendToUserMsg( "Cannot open file for 2nd pass -- No data read.\n" ); - CloseInputFile( in2 ); + _error.AppendToUserMsg("Cannot open file for 2nd pass -- No data read.\n"); + CloseInputFile(in2); return SEVERITY_INPUT_ERROR; } - if( !FindDataSection( *in2 ) ) { - _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n" ); - CloseInputFile( in2 ); + if(!FindDataSection(*in2)) { + _error.AppendToUserMsg("Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n"); + CloseInputFile(in2); return SEVERITY_INPUT_ERROR; } - switch( _fileType ) { + switch(_fileType) { case VERSION_CURRENT: case VERSION_UNKNOWN: case WORKING_SESSION: - valid_insts = ReadData2( *in2, useTechCor ); + valid_insts = ReadData2(*in2, useTechCor); break; default: - _error.AppendToUserMsg( "STEPfile::AppendFile: STEP file version set to unrecognized value.\n" ); - CloseInputFile( in2 ); + _error.AppendToUserMsg("STEPfile::AppendFile: STEP file version set to unrecognized value.\n"); + CloseInputFile(in2); return SEVERITY_BUG; } //check for "ENDSEC;" - ReadTokenSeparator( *in2 ); - if( total_insts != valid_insts ) { - sprintf( errbuf, "%d invalid instances in file: %s\n", - total_insts - valid_insts, ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); - _error.AppendToUserMsg( errbuf ); - CloseInputFile( in2 ); - return _error.GreaterSeverity( SEVERITY_WARNING ); + ReadTokenSeparator(*in2); + if(total_insts != valid_insts) { + sprintf(errbuf, "%d invalid instances in file: %s\n", + total_insts - valid_insts, ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); + _error.AppendToUserMsg(errbuf); + CloseInputFile(in2); + return _error.GreaterSeverity(SEVERITY_WARNING); } cout << "\nSECOND PASS complete: " << valid_insts << " instances valid.\n"; - sprintf( errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount ); - _error.AppendToUserMsg( errbuf ); + sprintf(errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount); + _error.AppendToUserMsg(errbuf); cout << errbuf; //check for "ENDSTEP;" || "END-ISO-10303-21;" - if( in2 -> good() ) { - ReadTokenSeparator( *in2 ); - keywd = GetKeyword( *in2, ";", _error ); + if(in2 -> good()) { + ReadTokenSeparator(*in2); + keywd = GetKeyword(*in2, ";", _error); //yank the ";" from the istream //if (';' == in2->peek()) in2->get(); char ch; - in2->get( ch ); - if( ch != ';' ) { + in2->get(ch); + if(ch != ';') { std::cerr << __FILE__ << ":" << __LINE__ << " - Expected ';' at Part 21 EOF, found '" << c << "'." << std::endl; } } - if( ( !keywd.compare( 0, keywd.size(), END_FILE_DELIM ) ) || !( in2 -> good() ) ) { - _error.AppendToUserMsg( END_FILE_DELIM ); - _error.AppendToUserMsg( " missing at end of file.\n" ); - CloseInputFile( in2 ); - return _error.GreaterSeverity( SEVERITY_WARNING ); + if((!keywd.compare(0, keywd.size(), END_FILE_DELIM)) || !(in2 -> good())) { + _error.AppendToUserMsg(END_FILE_DELIM); + _error.AppendToUserMsg(" missing at end of file.\n"); + CloseInputFile(in2); + return _error.GreaterSeverity(SEVERITY_WARNING); } - CloseInputFile( in2 ); + CloseInputFile(in2); cout << "Finished reading file.\n\n"; return SEVERITY_NULL; } -Severity STEPfile::WriteWorkingFile( ostream & out, int clearError, int writeComments ) { - SetFileType( WORKING_SESSION ); - if( clearError ) { +Severity STEPfile::WriteWorkingFile(ostream &out, int clearError, int writeComments) +{ + SetFileType(WORKING_SESSION); + if(clearError) { _error.ClearErrorMsg(); } - if( instances().VerifyInstances( _error ) < SEVERITY_INCOMPLETE ) { - _error.AppendToUserMsg( "WARNING: some invalid instances written to working session file. Data may have been lost." ); - _error.GreaterSeverity( SEVERITY_INCOMPLETE ); + if(instances().VerifyInstances(_error) < SEVERITY_INCOMPLETE) { + _error.AppendToUserMsg("WARNING: some invalid instances written to working session file. Data may have been lost."); + _error.GreaterSeverity(SEVERITY_INCOMPLETE); } out << FILE_DELIM << "\n"; - WriteHeader( out ); + WriteHeader(out); - WriteWorkingData( out, writeComments ); + WriteWorkingData(out, writeComments); out << END_FILE_DELIM << "\n"; SetFileType(); return _error.severity(); } -Severity STEPfile::WriteWorkingFile( const std::string filename, int clearError, - int writeComments ) { - if( clearError ) { +Severity STEPfile::WriteWorkingFile(const std::string filename, int clearError, + int writeComments) +{ + if(clearError) { _error.ClearErrorMsg(); } - ostream * out = OpenOutputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { + ostream *out = OpenOutputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { return _error.severity(); } - Severity rval = WriteWorkingFile( *out, 0, writeComments ); - CloseOutputFile( out ); + Severity rval = WriteWorkingFile(*out, 0, writeComments); + CloseOutputFile(out); return rval; } -void STEPfile::WriteWorkingData( ostream & out, int writeComments ) { +void STEPfile::WriteWorkingData(ostream &out, int writeComments) +{ std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for( int i = 0; i < n; ++i ) { - switch( instances().GetMgrNode( i )->CurrState() ) { + for(int i = 0; i < n; ++i) { + switch(instances().GetMgrNode(i)->CurrState()) { case deleteSE: out << wsDelete; - instances().GetMgrNode( i )->GetApplication_instance()-> - STEPwrite( out, currSch.c_str(), writeComments ); + instances().GetMgrNode(i)->GetApplication_instance()-> + STEPwrite(out, currSch.c_str(), writeComments); break; case completeSE: out << wsSaveComplete; - instances().GetMgrNode( i )->GetApplication_instance()-> - STEPwrite( out, currSch.c_str(), writeComments ); + instances().GetMgrNode(i)->GetApplication_instance()-> + STEPwrite(out, currSch.c_str(), writeComments); break; case incompleteSE: out << wsSaveIncomplete; - instances().GetMgrNode( i )->GetApplication_instance()-> - STEPwrite( out, currSch.c_str(), writeComments ); + instances().GetMgrNode(i)->GetApplication_instance()-> + STEPwrite(out, currSch.c_str(), writeComments); break; case newSE: out << wsNew; - instances().GetMgrNode( i )->GetApplication_instance()-> - STEPwrite( out, currSch.c_str(), writeComments ); + instances().GetMgrNode(i)->GetApplication_instance()-> + STEPwrite(out, currSch.c_str(), writeComments); break; case noStateSE: - _error.AppendToUserMsg( "no state information for this node\n" ); + _error.AppendToUserMsg("no state information for this node\n"); break; } } @@ -1833,18 +1870,19 @@ void STEPfile::WriteWorkingData( ostream & out, int writeComments ) { The STEPfile's error descriptor is set no lower than SEVERITY_WARNING. */ -Severity STEPfile::AppendEntityErrorMsg( ErrorDescriptor * e ) { - ErrorDescriptor * ed = e; +Severity STEPfile::AppendEntityErrorMsg(ErrorDescriptor *e) +{ + ErrorDescriptor *ed = e; Severity sev = ed->severity(); - if( ( sev < SEVERITY_MAX ) || ( sev > SEVERITY_NULL ) ) { + if((sev < SEVERITY_MAX) || (sev > SEVERITY_NULL)) { //ERROR: something wrong with ErrorDescriptor - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.GreaterSeverity(SEVERITY_WARNING); return SEVERITY_BUG; } - switch( sev ) { + switch(sev) { case SEVERITY_NULL: return SEVERITY_NULL; @@ -1852,14 +1890,14 @@ Severity STEPfile::AppendEntityErrorMsg( ErrorDescriptor * e ) { cerr << e->DetailMsg(); e->ClearErrorMsg(); - if( sev < SEVERITY_USERMSG ) { + if(sev < SEVERITY_USERMSG) { ++_errorCount; } - if( sev < SEVERITY_WARNING ) { + if(sev < SEVERITY_WARNING) { sev = SEVERITY_WARNING; } - _error.GreaterSeverity( sev ); + _error.GreaterSeverity(sev); return sev; } } diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index 37c7d20bc..dc41050dc 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -35,29 +35,32 @@ enum FileTypeCode { WORKING_SESSION = 2 }; -class SC_EDITOR_EXPORT STEPfile { +class SC_EDITOR_EXPORT STEPfile +{ protected: //data members - InstMgr & _instances; - Registry & _reg; + InstMgr &_instances; + Registry &_reg; - InstMgr & instances() { + InstMgr &instances() + { return _instances; } - Registry & reg() { + Registry ®() + { return _reg; } int _fileIdIncr; ///< Increment value to be added to FileId Numbers on input //header information - InstMgr * _headerInstances; - Registry * _headerRegistry; + InstMgr *_headerInstances; + Registry *_headerRegistry; int _headerId; ///< STEPfile_id given to SDAI_Application_instance from header section //file information - DirObj * _currentDir; + DirObj *_currentDir; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -114,138 +117,147 @@ class SC_EDITOR_EXPORT STEPfile { //public access to member variables //header information - InstMgr * HeaderInstances() { + InstMgr *HeaderInstances() + { return _headerInstances; } - const Registry * HeaderRegistry() { + const Registry *HeaderRegistry() + { return _headerRegistry; } // to create header instances - SDAI_Application_instance * HeaderDefaultFileName(); - SDAI_Application_instance * HeaderDefaultFileDescription(); - SDAI_Application_instance * HeaderDefaultFileSchema(); + SDAI_Application_instance *HeaderDefaultFileName(); + SDAI_Application_instance *HeaderDefaultFileDescription(); + SDAI_Application_instance *HeaderDefaultFileSchema(); //file information - std::string FileName() const { + std::string FileName() const + { return _fileName; } - std::string SetFileName( const std::string name = "" ); - std::string TruncFileName( const std::string name ) const; + std::string SetFileName(const std::string name = ""); + std::string TruncFileName(const std::string name) const; float GetReadProgress() const; float GetWriteProgress() const; //error information - ErrorDescriptor & Error() { /* const */ + ErrorDescriptor &Error() /* const */ + { return _error; } - int ErrorCount() const { + int ErrorCount() const + { return _errorCount; } - int WarningCount() const { + int WarningCount() const + { return _warningCount; } - Severity AppendEntityErrorMsg( ErrorDescriptor * e ); + Severity AppendEntityErrorMsg(ErrorDescriptor *e); //version information - FileTypeCode FileType() const { + FileTypeCode FileType() const + { return _fileType; } - void FileType( FileTypeCode ft ) { + void FileType(FileTypeCode ft) + { _fileType = ft; } - int SetFileType( FileTypeCode ft = VERSION_CURRENT ); + int SetFileType(FileTypeCode ft = VERSION_CURRENT); //Reading and Writing - Severity ReadExchangeFile( const std::string filename = "", bool useTechCor = 1 ); - Severity AppendExchangeFile( const std::string filename = "", bool useTechCor = 1 ); + Severity ReadExchangeFile(const std::string filename = "", bool useTechCor = 1); + Severity AppendExchangeFile(const std::string filename = "", bool useTechCor = 1); - Severity ReadWorkingFile( const std::string filename = "", bool useTechCor = 1 ); - Severity AppendWorkingFile( const std::string filename = "", bool useTechCor = 1 ); + Severity ReadWorkingFile(const std::string filename = "", bool useTechCor = 1); + Severity AppendWorkingFile(const std::string filename = "", bool useTechCor = 1); - Severity AppendFile( istream * in, bool useTechCor = 1 ) ; + Severity AppendFile(istream *in, bool useTechCor = 1) ; - Severity WriteExchangeFile( ostream & out, int validate = 1, - int clearError = 1, int writeComments = 1 ); - Severity WriteExchangeFile( const std::string filename = "", int validate = 1, - int clearError = 1, int writeComments = 1 ); - Severity WriteValuePairsFile( ostream & out, int validate = 1, - int clearError = 1, - int writeComments = 1, int mixedCase = 1 ); + Severity WriteExchangeFile(ostream &out, int validate = 1, + int clearError = 1, int writeComments = 1); + Severity WriteExchangeFile(const std::string filename = "", int validate = 1, + int clearError = 1, int writeComments = 1); + Severity WriteValuePairsFile(ostream &out, int validate = 1, + int clearError = 1, + int writeComments = 1, int mixedCase = 1); - Severity WriteWorkingFile( ostream & out, int clearError = 1, - int writeComments = 1 ); - Severity WriteWorkingFile( const std::string filename = "", int clearError = 1, - int writeComments = 1 ); + Severity WriteWorkingFile(ostream &out, int clearError = 1, + int writeComments = 1); + Severity WriteWorkingFile(const std::string filename = "", int clearError = 1, + int writeComments = 1); - stateEnum EntityWfState( char c ); + stateEnum EntityWfState(char c); void Renumber(); //constructors - STEPfile( Registry & r, InstMgr & i, const std::string filename = "", bool strict = true ); + STEPfile(Registry &r, InstMgr &i, const std::string filename = "", bool strict = true); virtual ~STEPfile(); protected: //member functions std::string schemaName(); /**< Returns and copies out schema name from header instances. Called by ReadExchangeFile */ - istream * OpenInputFile( const std::string filename = "" ); - void CloseInputFile( istream * in ); + istream *OpenInputFile(const std::string filename = ""); + void CloseInputFile(istream *in); - Severity ReadHeader( istream & in ); + Severity ReadHeader(istream &in); - Severity HeaderVerifyInstances( InstMgr * im ); - void HeaderMergeInstances( InstMgr * im ); + Severity HeaderVerifyInstances(InstMgr *im); + void HeaderMergeInstances(InstMgr *im); - int HeaderId( int increment = 1 ); - int HeaderId( const char * nm = "\0" ); + int HeaderId(int increment = 1); + int HeaderId(const char *nm = "\0"); - int ReadData1( istream & in ); /**< First pass, to create instances */ - int ReadData2( istream & in, bool useTechCor = true ); /**< Second pass, to read instances */ + int ReadData1(istream &in); /**< First pass, to create instances */ + int ReadData2(istream &in, bool useTechCor = true); /**< Second pass, to read instances */ // obsolete - int ReadWorkingData1( istream & in ); - int ReadWorkingData2( istream & in, bool useTechCor = true ); + int ReadWorkingData1(istream &in); + int ReadWorkingData2(istream &in, bool useTechCor = true); - void ReadRestOfFile( istream & in ); + void ReadRestOfFile(istream &in); /// create instance - used by ReadData1() - SDAI_Application_instance * CreateInstance( istream & in, ostream & out ); + SDAI_Application_instance *CreateInstance(istream &in, ostream &out); /// create complex instance - used by CreateInstance() - SDAI_Application_instance * CreateSubSuperInstance( istream & in, int fileid, - ErrorDescriptor & ); + SDAI_Application_instance *CreateSubSuperInstance(istream &in, int fileid, + ErrorDescriptor &); // read the instance - used by ReadData2() - SDAI_Application_instance * ReadInstance( istream & in, ostream & out, - std::string & cmtStr, bool useTechCor = true ); + SDAI_Application_instance *ReadInstance(istream &in, ostream &out, + std::string &cmtStr, bool useTechCor = true); /// reading scopes are still incomplete, CreateScopeInstances and ReadScopeInstances are stubs - Severity CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ); - Severity ReadScopeInstances( istream & in ); + Severity CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist); + Severity ReadScopeInstances(istream &in); // Severity ReadSubSuperInstance(istream& in); - int FindDataSection( istream & in ); - int FindHeaderSection( istream & in ); + int FindDataSection(istream &in); + int FindHeaderSection(istream &in); // writing working session files - void WriteWorkingData( ostream & out, int writeComments = 1 ); + void WriteWorkingData(ostream &out, int writeComments = 1); //called by WriteExchangeFile - ofstream * OpenOutputFile( const std::string filename = "" ); - void CloseOutputFile( ostream * out ); - - void WriteHeader( ostream & out ); - void WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ); - void WriteHeaderInstanceFileName( ostream & out ); - void WriteHeaderInstanceFileDescription( ostream & out ); - void WriteHeaderInstanceFileSchema( ostream & out ); - - void WriteData( ostream & out, int writeComments = 1 ); - void WriteValuePairsData( ostream & out, int writeComments = 1, - int mixedCase = 1 ); - - int IncrementFileId( int fileid ); - int FileIdIncr() { + ofstream *OpenOutputFile(const std::string filename = ""); + void CloseOutputFile(ostream *out); + + void WriteHeader(ostream &out); + void WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out); + void WriteHeaderInstanceFileName(ostream &out); + void WriteHeaderInstanceFileDescription(ostream &out); + void WriteHeaderInstanceFileSchema(ostream &out); + + void WriteData(ostream &out, int writeComments = 1); + void WriteValuePairsData(ostream &out, int writeComments = 1, + int mixedCase = 1); + + int IncrementFileId(int fileid); + int FileIdIncr() + { return _fileIdIncr; } void SetFileIdIncrement(); diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 0c5b937e0..60d7c540e 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -19,28 +19,30 @@ #include #include "sc_memmgr.h" -extern void HeaderSchemaInit( Registry & reg ); +extern void HeaderSchemaInit(Registry ®); //To Be inline functions //constructor & destructor -STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict ) : - _instances( i ), _reg( r ), _fileIdIncr( 0 ), _headerId( 0 ), _iFileSize( 0 ), - _iFileCurrentPosition( 0 ), _iFileStage1Done( false ), _oFileInstsWritten( 0 ), - _entsNotCreated( 0 ), _entsInvalid( 0 ), _entsIncomplete( 0 ), _entsWarning( 0 ), - _errorCount( 0 ), _warningCount( 0 ), _maxErrorCount( 100000 ), _strict( strict ) { - SetFileType( VERSION_CURRENT ); +STEPfile::STEPfile(Registry &r, InstMgr &i, const std::string filename, bool strict) : + _instances(i), _reg(r), _fileIdIncr(0), _headerId(0), _iFileSize(0), + _iFileCurrentPosition(0), _iFileStage1Done(false), _oFileInstsWritten(0), + _entsNotCreated(0), _entsInvalid(0), _entsIncomplete(0), _entsWarning(0), + _errorCount(0), _warningCount(0), _maxErrorCount(100000), _strict(strict) +{ + SetFileType(VERSION_CURRENT); SetFileIdIncrement(); - _currentDir = new DirObj( "" ); - _headerRegistry = new Registry( HeaderSchemaInit ); + _currentDir = new DirObj(""); + _headerRegistry = new Registry(HeaderSchemaInit); _headerInstances = new InstMgr; - if( !filename.empty() ) { - ReadExchangeFile( filename ); + if(!filename.empty()) { + ReadExchangeFile(filename); } } -STEPfile::~STEPfile() { +STEPfile::~STEPfile() +{ delete _currentDir; delete _headerRegistry; @@ -49,22 +51,23 @@ STEPfile::~STEPfile() { delete _headerInstances; } -int STEPfile::SetFileType( FileTypeCode ft ) { - FileType( ft ); +int STEPfile::SetFileType(FileTypeCode ft) +{ + FileType(ft); - switch( _fileType ) { - case( VERSION_OLD ): + switch(_fileType) { + case(VERSION_OLD): ENTITY_NAME_DELIM = '@'; FILE_DELIM = "STEP;"; END_FILE_DELIM = "ENDSTEP;"; break; - case( VERSION_UNKNOWN ): - case( VERSION_CURRENT ): + case(VERSION_UNKNOWN): + case(VERSION_CURRENT): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "ISO-10303-21;"; END_FILE_DELIM = "END-ISO-10303-21;"; break; - case( WORKING_SESSION ): + case(WORKING_SESSION): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "STEP_WORKING_SESSION;"; END_FILE_DELIM = "END-STEP_WORKING_SESSION;"; @@ -84,135 +87,142 @@ int STEPfile::SetFileType( FileTypeCode ft ) { ** remove any slashes, and anything before the slash, ** from filename */ -std::string STEPfile::TruncFileName( const std::string filename ) const { +std::string STEPfile::TruncFileName(const std::string filename) const +{ #if defined(_WIN32) && !defined(__mingw32__) char slash = '\\'; #else char slash = '/'; #endif - size_t l = filename.find_last_of( slash ); - if( l == std::string::npos ) { + size_t l = filename.find_last_of(slash); + if(l == std::string::npos) { return filename; } else { - return filename.substr( l ); + return filename.substr(l); } } /******************************************************/ -Severity STEPfile::ReadExchangeFile( const std::string filename, bool useTechCor ) { +Severity STEPfile::ReadExchangeFile(const std::string filename, bool useTechCor) +{ _error.ClearErrorMsg(); _errorCount = 0; - istream * in = OpenInputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { - CloseInputFile( in ); + istream *in = OpenInputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { + CloseInputFile(in); return _error.severity(); } instances().ClearInstances(); - if( _headerInstances ) { + if(_headerInstances) { _headerInstances->ClearInstances(); } _headerId = 5; - Severity rval = AppendFile( in, useTechCor ); - CloseInputFile( in ); + Severity rval = AppendFile(in, useTechCor); + CloseInputFile(in); return rval; } -Severity STEPfile::AppendExchangeFile( const std::string filename, bool useTechCor ) { +Severity STEPfile::AppendExchangeFile(const std::string filename, bool useTechCor) +{ _error.ClearErrorMsg(); _errorCount = 0; - istream * in = OpenInputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { - CloseInputFile( in ); + istream *in = OpenInputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { + CloseInputFile(in); return _error.severity(); } - Severity rval = AppendFile( in, useTechCor ); - CloseInputFile( in ); + Severity rval = AppendFile(in, useTechCor); + CloseInputFile(in); return rval; } /******************************************************/ -Severity STEPfile::ReadWorkingFile( const std::string filename, bool useTechCor ) { +Severity STEPfile::ReadWorkingFile(const std::string filename, bool useTechCor) +{ _error.ClearErrorMsg(); _errorCount = 0; - istream * in = OpenInputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { - CloseInputFile( in ); + istream *in = OpenInputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { + CloseInputFile(in); return _error.severity(); } instances().ClearInstances(); _headerInstances->ClearInstances(); - SetFileType( WORKING_SESSION ); + SetFileType(WORKING_SESSION); - Severity rval = AppendFile( in, useTechCor ); + Severity rval = AppendFile(in, useTechCor); SetFileType(); - CloseInputFile( in ); + CloseInputFile(in); return rval; } -Severity STEPfile::AppendWorkingFile( const std::string filename, bool useTechCor ) { +Severity STEPfile::AppendWorkingFile(const std::string filename, bool useTechCor) +{ _error.ClearErrorMsg(); _errorCount = 0; - istream * in = OpenInputFile( filename ); - if( _error.severity() < SEVERITY_WARNING ) { - CloseInputFile( in ); + istream *in = OpenInputFile(filename); + if(_error.severity() < SEVERITY_WARNING) { + CloseInputFile(in); return _error.severity(); } - SetFileType( WORKING_SESSION ); - Severity rval = AppendFile( in, useTechCor ); + SetFileType(WORKING_SESSION); + Severity rval = AppendFile(in, useTechCor); SetFileType(); - CloseInputFile( in ); + CloseInputFile(in); return rval; } /******************************************************/ -istream * STEPfile::OpenInputFile( const std::string filename ) { +istream *STEPfile::OpenInputFile(const std::string filename) +{ _iFileCurrentPosition = 0; // if there's no filename to use, fail - if( filename.empty() && FileName().empty() ) { - _error.AppendToUserMsg( "Unable to open file for input. No current file name.\n" ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); - return( 0 ); + if(filename.empty() && FileName().empty()) { + _error.AppendToUserMsg("Unable to open file for input. No current file name.\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + return(0); } else { - if( SetFileName( filename ).empty() && ( filename.compare( "-" ) != 0 ) ) { + if(SetFileName(filename).empty() && (filename.compare("-") != 0)) { char msg[BUFSIZ]; - sprintf( msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str() ); - _error.AppendToUserMsg( msg ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); - return( 0 ); + sprintf(msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str()); + _error.AppendToUserMsg(msg); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + return(0); } } - std::istream * in; + std::istream *in; - if( filename.compare( "-" ) == 0 ) { + if(filename.compare("-") == 0) { in = &std::cin; } else { - in = new ifstream( FileName().c_str() ); + in = new ifstream(FileName().c_str()); } - if( !in || !( in -> good() ) ) { + if(!in || !(in -> good())) { char msg[BUFSIZ]; - sprintf( msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str() ); - _error.AppendToUserMsg( msg ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); - return ( 0 ); + sprintf(msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str()); + _error.AppendToUserMsg(msg); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + return (0); } //check size of file - in->seekg( 0, std::ifstream::end ); + in->seekg(0, std::ifstream::end); _iFileSize = in->tellg(); - in->seekg( 0, std::ifstream::beg ); + in->seekg(0, std::ifstream::beg); return in; } /******************************************************/ -void STEPfile::CloseInputFile( istream * in ) { - if (in != &std::cin) { +void STEPfile::CloseInputFile(istream *in) +{ + if(in != &std::cin) { delete in; } @@ -223,49 +233,53 @@ void STEPfile::CloseInputFile( istream * in ) { /******************************************************/ -ofstream * STEPfile::OpenOutputFile( std::string filename ) { - if( filename.empty() ) { - if( FileName().empty() ) { - _error.AppendToUserMsg( "No current file name.\n" ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); +ofstream *STEPfile::OpenOutputFile(std::string filename) +{ + if(filename.empty()) { + if(FileName().empty()) { + _error.AppendToUserMsg("No current file name.\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); } } else { - if( SetFileName( filename ).empty() ) { + if(SetFileName(filename).empty()) { char msg[BUFSIZ]; - sprintf( msg, "can't find file: %s\nFile not written.\n", filename.c_str() ); - _error.AppendToUserMsg( msg ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf(msg, "can't find file: %s\nFile not written.\n", filename.c_str()); + _error.AppendToUserMsg(msg); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); } } - if( _currentDir->FileExists( TruncFileName( filename ) ) ) { + if(_currentDir->FileExists(TruncFileName(filename))) { MakeBackupFile(); } - ofstream * out = new ofstream( filename.c_str() ); - if( !out ) { - _error.AppendToUserMsg( "unable to open file for output\n" ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + ofstream *out = new ofstream(filename.c_str()); + if(!out) { + _error.AppendToUserMsg("unable to open file for output\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); } _oFileInstsWritten = 0; return out; } -void STEPfile::CloseOutputFile( ostream * out ) { +void STEPfile::CloseOutputFile(ostream *out) +{ _oFileInstsWritten = 0; delete out; } /******************************************************/ -int STEPfile::IncrementFileId( int fileid ) { - return ( fileid + FileIdIncr() ); +int STEPfile::IncrementFileId(int fileid) +{ + return (fileid + FileIdIncr()); } -void STEPfile::SetFileIdIncrement() { - if( instances().MaxFileId() < 0 ) { +void STEPfile::SetFileIdIncrement() +{ + if(instances().MaxFileId() < 0) { _fileIdIncr = 0; } else { - _fileIdIncr = ( int )( ( ceil( ( instances().MaxFileId() + 99.0 ) / 1000.0 ) + 1.0 ) * 1000.0 ); + _fileIdIncr = (int)((ceil((instances().MaxFileId() + 99.0) / 1000.0) + 1.0) * 1000.0); } } @@ -275,42 +289,43 @@ void STEPfile::SetFileIdIncrement() { * is no header section or no value for file schema, NULL is returned and * schName is unset. */ -std::string STEPfile::schemaName() { - SdaiFile_schema * fs; +std::string STEPfile::schemaName() +{ + SdaiFile_schema *fs; std::string schName; - STEPnode * n; + STEPnode *n; - if( _headerInstances == NULL ) { + if(_headerInstances == NULL) { return schName; } - fs = ( SdaiFile_schema * )_headerInstances->GetApplication_instance( "File_Schema" ); - if( fs == ENTITY_NULL ) { + fs = (SdaiFile_schema *)_headerInstances->GetApplication_instance("File_Schema"); + if(fs == ENTITY_NULL) { return schName; } - n = ( STEPnode * )fs->schema_identifiers_()->GetHead(); + n = (STEPnode *)fs->schema_identifiers_()->GetHead(); // (take the first one) - if( n == NULL ) { + if(n == NULL) { return schName; } - n->STEPwrite( schName ); - if( schName.empty() || schName[0] == '$' ) { + n->STEPwrite(schName); + if(schName.empty() || schName[0] == '$') { schName.clear(); return schName; - } else if( schName[0] == '\0' ) { + } else if(schName[0] == '\0') { //probably never - it seems that putting null in std::string takes effort - _error.AppendToUserMsg( "In STEPfile::schemaName: schName contains \\0 - it should be empty." ); - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.AppendToUserMsg("In STEPfile::schemaName: schName contains \\0 - it should be empty."); + _error.GreaterSeverity(SEVERITY_WARNING); schName.clear(); return schName; } - if( schName[ schName.length() - 1 ] == '\'' ) { - schName = schName.substr( 1, schName.length() - 2 ); + if(schName[ schName.length() - 1 ] == '\'') { + schName = schName.substr(1, schName.length() - 2); } else { - _error.AppendToUserMsg( "In STEPfile::schemaName: schName was truncated." ); - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.AppendToUserMsg("In STEPfile::schemaName: schName was truncated."); + _error.GreaterSeverity(SEVERITY_WARNING); - schName = schName.substr( 1, schName.length() - 1 ); + schName = schName.substr(1, schName.length() - 1); } return schName; } diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index cea95b42f..7b642a25c 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -6,7 +6,7 @@ #ifdef SC_LOGGING #include -extern ofstream * logStream; +extern ofstream *logStream; #define SCLLOGFILE "scl.log" #endif @@ -15,88 +15,93 @@ extern ofstream * logStream; #include #include "sc_memmgr.h" -Schema * s_header_section_schema = 0; +Schema *s_header_section_schema = 0; /* ************** TYPES */ -TypeDescriptor * header_section_schemat_time_stamp_text; -TypeDescriptor * header_section_schemat_section_name; -TypeDescriptor * header_section_schemat_context_name; -TypeDescriptor * header_section_schemat_schema_name; -TypeDescriptor * header_section_schemat_language_name; -TypeDescriptor * header_section_schemat_exchange_structure_identifier; +TypeDescriptor *header_section_schemat_time_stamp_text; +TypeDescriptor *header_section_schemat_section_name; +TypeDescriptor *header_section_schemat_context_name; +TypeDescriptor *header_section_schemat_schema_name; +TypeDescriptor *header_section_schemat_language_name; +TypeDescriptor *header_section_schemat_exchange_structure_identifier; /* ************** ENTITIES */ ///////// ENTITY section_language -EntityDescriptor * header_section_schemae_section_language = 0; -AttrDescriptor * a_0section = 0; -AttrDescriptor * a_1default_language = 0; -SdaiSection_language::SdaiSection_language( ) { +EntityDescriptor *header_section_schemae_section_language = 0; +AttrDescriptor *a_0section = 0; +AttrDescriptor *a_1default_language = 0; +SdaiSection_language::SdaiSection_language() +{ /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute * a = new STEPattribute( *a_0section, &_section ); + STEPattribute *a = new STEPattribute(*a_0section, &_section); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_1default_language, &_default_language ); + attributes.push(a); + a = new STEPattribute(*a_1default_language, &_default_language); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiSection_language::SdaiSection_language( SdaiSection_language & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiSection_language::SdaiSection_language(SdaiSection_language &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiSection_language::~SdaiSection_language() { } -SdaiSection_language::SdaiSection_language( SDAI_Application_instance * se, int * addAttrs ) { +SdaiSection_language::SdaiSection_language(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute * a = new STEPattribute( *a_0section, &_section ); + STEPattribute *a = new STEPattribute(*a_0section, &_section); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_1default_language, &_default_language ); + a = new STEPattribute(*a_1default_language, &_default_language); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } const SdaiSection_name -SdaiSection_language::section_() const { - return ( const SdaiSection_name ) _section; +SdaiSection_language::section_() const +{ + return (const SdaiSection_name) _section; } void -SdaiSection_language::section_( const SdaiSection_name x ) +SdaiSection_language::section_(const SdaiSection_name x) { _section = x; } const SdaiLanguage_name -SdaiSection_language::default_language_() const { - return ( const SdaiLanguage_name ) _default_language; +SdaiSection_language::default_language_() const +{ + return (const SdaiLanguage_name) _default_language; } void -SdaiSection_language::default_language_( const SdaiLanguage_name x ) +SdaiSection_language::default_language_(const SdaiLanguage_name x) { _default_language = x; @@ -107,103 +112,109 @@ SdaiSection_language::default_language_( const SdaiLanguage_name x ) ///////// ENTITY file_population -EntityDescriptor * header_section_schemae_file_population = 0; -AttrDescriptor * a_2governing_schema = 0; -AttrDescriptor * a_3determination_method = 0; -AttrDescriptor * a_4governed_sections = 0; -SdaiFile_population::SdaiFile_population( ) { +EntityDescriptor *header_section_schemae_file_population = 0; +AttrDescriptor *a_2governing_schema = 0; +AttrDescriptor *a_3determination_method = 0; +AttrDescriptor *a_4governed_sections = 0; +SdaiFile_population::SdaiFile_population() +{ /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); + STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_3determination_method, &_determination_method ); + attributes.push(a); + a = new STEPattribute(*a_3determination_method, &_determination_method); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_4governed_sections, &_governed_sections ); + attributes.push(a); + a = new STEPattribute(*a_4governed_sections, &_governed_sections); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiFile_population::SdaiFile_population( SdaiFile_population & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiFile_population::SdaiFile_population(SdaiFile_population &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiFile_population::~SdaiFile_population() { } -SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * addAttrs ) { +SdaiFile_population::SdaiFile_population(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); + STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_3determination_method, &_determination_method ); + a = new STEPattribute(*a_3determination_method, &_determination_method); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_4governed_sections, &_governed_sections ); + a = new STEPattribute(*a_4governed_sections, &_governed_sections); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } const SdaiSchema_name -SdaiFile_population::governing_schema_() const { - return ( const SdaiSchema_name ) _governing_schema; +SdaiFile_population::governing_schema_() const +{ + return (const SdaiSchema_name) _governing_schema; } void -SdaiFile_population::governing_schema_( const SdaiSchema_name x ) +SdaiFile_population::governing_schema_(const SdaiSchema_name x) { _governing_schema = x; } const SdaiExchange_structure_identifier -SdaiFile_population::determination_method_() const { - return ( const SdaiExchange_structure_identifier ) _determination_method; +SdaiFile_population::determination_method_() const +{ + return (const SdaiExchange_structure_identifier) _determination_method; } void -SdaiFile_population::determination_method_( const SdaiExchange_structure_identifier x ) +SdaiFile_population::determination_method_(const SdaiExchange_structure_identifier x) { _determination_method = x; } StringAggregate_ptr -SdaiFile_population::governed_sections_() const { - return ( StringAggregate_ptr ) &_governed_sections; +SdaiFile_population::governed_sections_() const +{ + return (StringAggregate_ptr) &_governed_sections; } void -SdaiFile_population::governed_sections_( const StringAggregate_ptr x ) +SdaiFile_population::governed_sections_(const StringAggregate_ptr x) { - _governed_sections.ShallowCopy( *x ); + _governed_sections.ShallowCopy(*x); } ///////// END_ENTITY file_population @@ -211,204 +222,214 @@ SdaiFile_population::governed_sections_( const StringAggregate_ptr x ) ///////// ENTITY file_name -EntityDescriptor * header_section_schemae_file_name = 0; -AttrDescriptor * a_5name = 0; -AttrDescriptor * a_6time_stamp = 0; -AttrDescriptor * a_7author = 0; -AttrDescriptor * a_8organization = 0; -AttrDescriptor * a_9preprocessor_version = 0; -AttrDescriptor * a_10originating_system = 0; -AttrDescriptor * a_11authorization = 0; -SdaiFile_name::SdaiFile_name( ) { +EntityDescriptor *header_section_schemae_file_name = 0; +AttrDescriptor *a_5name = 0; +AttrDescriptor *a_6time_stamp = 0; +AttrDescriptor *a_7author = 0; +AttrDescriptor *a_8organization = 0; +AttrDescriptor *a_9preprocessor_version = 0; +AttrDescriptor *a_10originating_system = 0; +AttrDescriptor *a_11authorization = 0; +SdaiFile_name::SdaiFile_name() +{ /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute * a = new STEPattribute( *a_5name, &_name ); + STEPattribute *a = new STEPattribute(*a_5name, &_name); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_6time_stamp, &_time_stamp ); + attributes.push(a); + a = new STEPattribute(*a_6time_stamp, &_time_stamp); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_7author, &_author ); + attributes.push(a); + a = new STEPattribute(*a_7author, &_author); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_8organization, &_organization ); + attributes.push(a); + a = new STEPattribute(*a_8organization, &_organization); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); + attributes.push(a); + a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_10originating_system, &_originating_system ); + attributes.push(a); + a = new STEPattribute(*a_10originating_system, &_originating_system); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_11authorization, &_authorization ); + attributes.push(a); + a = new STEPattribute(*a_11authorization, &_authorization); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiFile_name::SdaiFile_name( SdaiFile_name & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiFile_name::SdaiFile_name(SdaiFile_name &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiFile_name::~SdaiFile_name() { } -SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { +SdaiFile_name::SdaiFile_name(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute * a = new STEPattribute( *a_5name, &_name ); + STEPattribute *a = new STEPattribute(*a_5name, &_name); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_6time_stamp, &_time_stamp ); + a = new STEPattribute(*a_6time_stamp, &_time_stamp); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_7author, &_author ); + a = new STEPattribute(*a_7author, &_author); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_8organization, &_organization ); + a = new STEPattribute(*a_8organization, &_organization); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); + a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_10originating_system, &_originating_system ); + a = new STEPattribute(*a_10originating_system, &_originating_system); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_11authorization, &_authorization ); + a = new STEPattribute(*a_11authorization, &_authorization); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } const SDAI_String -SdaiFile_name::name_() const { - return ( const SDAI_String ) _name; +SdaiFile_name::name_() const +{ + return (const SDAI_String) _name; } void -SdaiFile_name::name_( const SDAI_String x ) +SdaiFile_name::name_(const SDAI_String x) { _name = x; } const SdaiTime_stamp_text -SdaiFile_name::time_stamp_() const { - return ( const SdaiTime_stamp_text ) _time_stamp; +SdaiFile_name::time_stamp_() const +{ + return (const SdaiTime_stamp_text) _time_stamp; } void -SdaiFile_name::time_stamp_( const SdaiTime_stamp_text x ) +SdaiFile_name::time_stamp_(const SdaiTime_stamp_text x) { _time_stamp = x; } StringAggregate_ptr -SdaiFile_name::author_() const { - return ( StringAggregate_ptr ) &_author; +SdaiFile_name::author_() const +{ + return (StringAggregate_ptr) &_author; } void -SdaiFile_name::author_( const StringAggregate_ptr x ) +SdaiFile_name::author_(const StringAggregate_ptr x) { - _author.ShallowCopy( *x ); + _author.ShallowCopy(*x); } StringAggregate_ptr -SdaiFile_name::organization_() const { - return ( StringAggregate_ptr ) &_organization; +SdaiFile_name::organization_() const +{ + return (StringAggregate_ptr) &_organization; } void -SdaiFile_name::organization_( const StringAggregate_ptr x ) +SdaiFile_name::organization_(const StringAggregate_ptr x) { - _organization.ShallowCopy( *x ); + _organization.ShallowCopy(*x); } const SDAI_String -SdaiFile_name::preprocessor_version_() const { - return ( const SDAI_String ) _preprocessor_version; +SdaiFile_name::preprocessor_version_() const +{ + return (const SDAI_String) _preprocessor_version; } void -SdaiFile_name::preprocessor_version_( const SDAI_String x ) +SdaiFile_name::preprocessor_version_(const SDAI_String x) { _preprocessor_version = x; } const SDAI_String -SdaiFile_name::originating_system_() const { - return ( const SDAI_String ) _originating_system; +SdaiFile_name::originating_system_() const +{ + return (const SDAI_String) _originating_system; } void -SdaiFile_name::originating_system_( const SDAI_String x ) +SdaiFile_name::originating_system_(const SDAI_String x) { _originating_system = x; } const SDAI_String -SdaiFile_name::authorization_() const { - return ( const SDAI_String ) _authorization; +SdaiFile_name::authorization_() const +{ + return (const SDAI_String) _authorization; } void -SdaiFile_name::authorization_( const SDAI_String x ) +SdaiFile_name::authorization_(const SDAI_String x) { _authorization = x; @@ -419,77 +440,82 @@ SdaiFile_name::authorization_( const SDAI_String x ) ///////// ENTITY section_context -EntityDescriptor * header_section_schemae_section_context = 0; -AttrDescriptor * a_12section = 0; -AttrDescriptor * a_13context_identifiers = 0; -SdaiSection_context::SdaiSection_context( ) { +EntityDescriptor *header_section_schemae_section_context = 0; +AttrDescriptor *a_12section = 0; +AttrDescriptor *a_13context_identifiers = 0; +SdaiSection_context::SdaiSection_context() +{ /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute * a = new STEPattribute( *a_12section, &_section ); + STEPattribute *a = new STEPattribute(*a_12section, &_section); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); + attributes.push(a); + a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiSection_context::SdaiSection_context( SdaiSection_context & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiSection_context::SdaiSection_context(SdaiSection_context &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiSection_context::~SdaiSection_context() { } -SdaiSection_context::SdaiSection_context( SDAI_Application_instance * se, int * addAttrs ) { +SdaiSection_context::SdaiSection_context(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute * a = new STEPattribute( *a_12section, &_section ); + STEPattribute *a = new STEPattribute(*a_12section, &_section); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); + a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } const SdaiSection_name -SdaiSection_context::section_() const { - return ( const SdaiSection_name ) _section; +SdaiSection_context::section_() const +{ + return (const SdaiSection_name) _section; } void -SdaiSection_context::section_( const SdaiSection_name x ) +SdaiSection_context::section_(const SdaiSection_name x) { _section = x; } StringAggregate_ptr -SdaiSection_context::context_identifiers_() const { - return ( StringAggregate_ptr ) &_context_identifiers; +SdaiSection_context::context_identifiers_() const +{ + return (StringAggregate_ptr) &_context_identifiers; } void -SdaiSection_context::context_identifiers_( const StringAggregate_ptr x ) +SdaiSection_context::context_identifiers_(const StringAggregate_ptr x) { - _context_identifiers.ShallowCopy( *x ); + _context_identifiers.ShallowCopy(*x); } ///////// END_ENTITY section_context @@ -497,74 +523,79 @@ SdaiSection_context::context_identifiers_( const StringAggregate_ptr x ) ///////// ENTITY file_description -EntityDescriptor * header_section_schemae_file_description = 0; -AttrDescriptor * a_14description = 0; -AttrDescriptor * a_15implementation_level = 0; -SdaiFile_description::SdaiFile_description( ) { +EntityDescriptor *header_section_schemae_file_description = 0; +AttrDescriptor *a_14description = 0; +AttrDescriptor *a_15implementation_level = 0; +SdaiFile_description::SdaiFile_description() +{ /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute * a = new STEPattribute( *a_14description, &_description ); + STEPattribute *a = new STEPattribute(*a_14description, &_description); a -> set_null(); - attributes.push( a ); - a = new STEPattribute( *a_15implementation_level, &_implementation_level ); + attributes.push(a); + a = new STEPattribute(*a_15implementation_level, &_implementation_level); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiFile_description::SdaiFile_description( SdaiFile_description & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiFile_description::SdaiFile_description(SdaiFile_description &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiFile_description::~SdaiFile_description() {} -SdaiFile_description::SdaiFile_description( SDAI_Application_instance * se, int * addAttrs ) { +SdaiFile_description::SdaiFile_description(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute * a = new STEPattribute( *a_14description, &_description ); + STEPattribute *a = new STEPattribute(*a_14description, &_description); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } - a = new STEPattribute( *a_15implementation_level, &_implementation_level ); + a = new STEPattribute(*a_15implementation_level, &_implementation_level); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } StringAggregate_ptr -SdaiFile_description::description_() const { - return ( StringAggregate_ptr ) &_description; +SdaiFile_description::description_() const +{ + return (StringAggregate_ptr) &_description; } void -SdaiFile_description::description_( const StringAggregate_ptr x ) +SdaiFile_description::description_(const StringAggregate_ptr x) { - _description.ShallowCopy( *x ); + _description.ShallowCopy(*x); } const SDAI_String -SdaiFile_description::implementation_level_() const { - return ( const SDAI_String ) _implementation_level; +SdaiFile_description::implementation_level_() const +{ + return (const SDAI_String) _implementation_level; } void -SdaiFile_description::implementation_level_( const SDAI_String x ) +SdaiFile_description::implementation_level_(const SDAI_String x) { _implementation_level = x; @@ -575,110 +606,122 @@ SdaiFile_description::implementation_level_( const SDAI_String x ) ///////// ENTITY file_schema -EntityDescriptor * header_section_schemae_file_schema = 0; -AttrDescriptor * a_16schema_identifiers = 0; -SdaiFile_schema::SdaiFile_schema( ) { +EntityDescriptor *header_section_schemae_file_schema = 0; +AttrDescriptor *a_16schema_identifiers = 0; +SdaiFile_schema::SdaiFile_schema() +{ /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); + STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); a -> set_null(); - attributes.push( a ); + attributes.push(a); } -SdaiFile_schema::SdaiFile_schema( SdaiFile_schema & e ): SDAI_Application_instance() { - CopyAs( ( SDAI_Application_instance_ptr ) &e ); +SdaiFile_schema::SdaiFile_schema(SdaiFile_schema &e): SDAI_Application_instance() +{ + CopyAs((SDAI_Application_instance_ptr) &e); } SdaiFile_schema::~SdaiFile_schema() { } -SdaiFile_schema::SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs ) { +SdaiFile_schema::SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs) +{ /* Set this to point to the head entity. */ - HeadEntity( se ); + HeadEntity(se); /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); + STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push( a ); + attributes.push(a); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if( !addAttrs || addAttrs[0] ) { - se->attributes.push( a ); + if(!addAttrs || addAttrs[0]) { + se->attributes.push(a); } } StringAggregate_ptr -SdaiFile_schema::schema_identifiers_() const { - return ( StringAggregate_ptr ) &_schema_identifiers; +SdaiFile_schema::schema_identifiers_() const +{ + return (StringAggregate_ptr) &_schema_identifiers; } void -SdaiFile_schema::schema_identifiers_( const StringAggregate_ptr x ) +SdaiFile_schema::schema_identifiers_(const StringAggregate_ptr x) { - _schema_identifiers.ShallowCopy( *x ); + _schema_identifiers.ShallowCopy(*x); } ///////// END_ENTITY file_schema -SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() { +SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() +{ return new SdaiModel_contents_header_section_schema ; } -SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() { - SDAI_Entity_extent_ptr eep = ( SDAI_Entity_extent_ptr )0; +SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() +{ + SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0; eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_section_language ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_section_language); + _folders.Append(eep); eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_file_population ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_file_population); + _folders.Append(eep); eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_file_name ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_file_name); + _folders.Append(eep); eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_section_context ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_section_context); + _folders.Append(eep); eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_file_description ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_file_description); + _folders.Append(eep); eep = new SDAI_Entity_extent; - eep->definition_( header_section_schemae_file_schema ); - _folders.Append( eep ); + eep->definition_(header_section_schemae_file_schema); + _folders.Append(eep); } -SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() { - return ( SdaiSection_language__set_var )( ( _folders.retrieve( 0 ) )->instances_() ); +SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() +{ + return (SdaiSection_language__set_var)((_folders.retrieve(0))->instances_()); } -SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() { - return ( SdaiFile_population__set_var )( ( _folders.retrieve( 1 ) )->instances_() ); +SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() +{ + return (SdaiFile_population__set_var)((_folders.retrieve(1))->instances_()); } -SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() { - return ( SdaiFile_name__set_var )( ( _folders.retrieve( 2 ) )->instances_() ); +SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() +{ + return (SdaiFile_name__set_var)((_folders.retrieve(2))->instances_()); } -SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() { - return ( SdaiSection_context__set_var )( ( _folders.retrieve( 3 ) )->instances_() ); +SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() +{ + return (SdaiSection_context__set_var)((_folders.retrieve(3))->instances_()); } -SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() { - return ( SdaiFile_description__set_var )( ( _folders.retrieve( 4 ) )->instances_() ); +SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() +{ + return (SdaiFile_description__set_var)((_folders.retrieve(4))->instances_()); } -SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() { - return ( SdaiFile_schema__set_var )( ( _folders.retrieve( 5 ) )->instances_() ); +SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() +{ + return (SdaiFile_schema__set_var)((_folders.retrieve(5))->instances_()); } #endif diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index 7cd45d848..30e5b9f20 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -13,33 +13,36 @@ ///////// ENTITY section_language -extern SC_EDITOR_EXPORT AttrDescriptor * a_0section; -extern SC_EDITOR_EXPORT AttrDescriptor * a_1default_language; +extern SC_EDITOR_EXPORT AttrDescriptor *a_0section; +extern SC_EDITOR_EXPORT AttrDescriptor *a_1default_language; -class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance +{ protected: SDAI_String _section ; // OPTIONAL SDAI_String _default_language ; public: - SdaiSection_language( ); - SdaiSection_language( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiSection_language( SdaiSection_language & e ); + SdaiSection_language(); + SdaiSection_language(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiSection_language(SdaiSection_language &e); ~SdaiSection_language(); - int opcode() { + int opcode() + { return 0 ; } const SdaiSection_name section_() const; - void section_( const SdaiSection_name x ); + void section_(const SdaiSection_name x); const SdaiLanguage_name default_language_() const; - void default_language_( const SdaiLanguage_name x ); + void default_language_(const SdaiLanguage_name x); }; inline SdaiSection_language * -create_SdaiSection_language() { +create_SdaiSection_language() +{ return new SdaiSection_language ; } @@ -48,11 +51,12 @@ create_SdaiSection_language() { ///////// ENTITY file_population -extern SC_EDITOR_EXPORT AttrDescriptor * a_2governing_schema; -extern SC_EDITOR_EXPORT AttrDescriptor * a_3determination_method; -extern SC_EDITOR_EXPORT AttrDescriptor * a_4governed_sections; +extern SC_EDITOR_EXPORT AttrDescriptor *a_2governing_schema; +extern SC_EDITOR_EXPORT AttrDescriptor *a_3determination_method; +extern SC_EDITOR_EXPORT AttrDescriptor *a_4governed_sections; -class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance +{ protected: SDAI_String _governing_schema ; SDAI_String _determination_method ; @@ -60,27 +64,29 @@ class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instanc public: - SdaiFile_population( ); - SdaiFile_population( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiFile_population( SdaiFile_population & e ); + SdaiFile_population(); + SdaiFile_population(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiFile_population(SdaiFile_population &e); ~SdaiFile_population(); - int opcode() { + int opcode() + { return 1 ; } const SdaiSchema_name governing_schema_() const; - void governing_schema_( const SdaiSchema_name x ); + void governing_schema_(const SdaiSchema_name x); const SdaiExchange_structure_identifier determination_method_() const; - void determination_method_( const SdaiExchange_structure_identifier x ); + void determination_method_(const SdaiExchange_structure_identifier x); StringAggregate_ptr governed_sections_() const; - void governed_sections_( const StringAggregate_ptr x ); + void governed_sections_(const StringAggregate_ptr x); }; inline SdaiFile_population * -create_SdaiFile_population() { +create_SdaiFile_population() +{ return new SdaiFile_population ; } @@ -89,15 +95,16 @@ create_SdaiFile_population() { ///////// ENTITY file_name -extern AttrDescriptor * a_5name; -extern AttrDescriptor * a_6time_stamp; -extern AttrDescriptor * a_7author; -extern AttrDescriptor * a_8organization; -extern AttrDescriptor * a_9preprocessor_version; -extern AttrDescriptor * a_10originating_system; -extern AttrDescriptor * a_11authorization; +extern AttrDescriptor *a_5name; +extern AttrDescriptor *a_6time_stamp; +extern AttrDescriptor *a_7author; +extern AttrDescriptor *a_8organization; +extern AttrDescriptor *a_9preprocessor_version; +extern AttrDescriptor *a_10originating_system; +extern AttrDescriptor *a_11authorization; -class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance +{ protected: SDAI_String _name ; SDAI_String _time_stamp ; @@ -108,39 +115,41 @@ class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance { SDAI_String _authorization ; public: - SdaiFile_name( ); - SdaiFile_name( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiFile_name( SdaiFile_name & e ); + SdaiFile_name(); + SdaiFile_name(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiFile_name(SdaiFile_name &e); ~SdaiFile_name(); - int opcode() { + int opcode() + { return 2 ; } const SDAI_String name_() const; - void name_( const SDAI_String x ); + void name_(const SDAI_String x); const SdaiTime_stamp_text time_stamp_() const; - void time_stamp_( const SdaiTime_stamp_text x ); + void time_stamp_(const SdaiTime_stamp_text x); StringAggregate_ptr author_() const; - void author_( const StringAggregate_ptr x ); + void author_(const StringAggregate_ptr x); StringAggregate_ptr organization_() const; - void organization_( const StringAggregate_ptr x ); + void organization_(const StringAggregate_ptr x); const SDAI_String preprocessor_version_() const; - void preprocessor_version_( const SDAI_String x ); + void preprocessor_version_(const SDAI_String x); const SDAI_String originating_system_() const; - void originating_system_( const SDAI_String x ); + void originating_system_(const SDAI_String x); const SDAI_String authorization_() const; - void authorization_( const SDAI_String x ); + void authorization_(const SDAI_String x); }; inline SdaiFile_name * -create_SdaiFile_name() { +create_SdaiFile_name() +{ return new SdaiFile_name ; } @@ -149,34 +158,37 @@ create_SdaiFile_name() { ///////// ENTITY section_context -extern SC_EDITOR_EXPORT AttrDescriptor * a_12section; -extern SC_EDITOR_EXPORT AttrDescriptor * a_13context_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor *a_12section; +extern SC_EDITOR_EXPORT AttrDescriptor *a_13context_identifiers; -class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance +{ protected: SDAI_String _section ; // OPTIONAL StringAggregate _context_identifiers ; // of context_name public: - SdaiSection_context( ); - SdaiSection_context( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiSection_context( SdaiSection_context & e ); + SdaiSection_context(); + SdaiSection_context(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiSection_context(SdaiSection_context &e); ~SdaiSection_context(); - int opcode() { + int opcode() + { return 3 ; } const SdaiSection_name section_() const; - void section_( const SdaiSection_name x ); + void section_(const SdaiSection_name x); StringAggregate_ptr context_identifiers_() const; - void context_identifiers_( const StringAggregate_ptr x ); + void context_identifiers_(const StringAggregate_ptr x); }; inline SdaiSection_context * -create_SdaiSection_context() { +create_SdaiSection_context() +{ return new SdaiSection_context ; } @@ -185,33 +197,36 @@ create_SdaiSection_context() { ///////// ENTITY file_description -extern SC_EDITOR_EXPORT AttrDescriptor * a_14description; -extern SC_EDITOR_EXPORT AttrDescriptor * a_15implementation_level; +extern SC_EDITOR_EXPORT AttrDescriptor *a_14description; +extern SC_EDITOR_EXPORT AttrDescriptor *a_15implementation_level; -class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance +{ protected: StringAggregate _description ; SDAI_String _implementation_level ; public: - SdaiFile_description( ); - SdaiFile_description( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiFile_description( SdaiFile_description & e ); + SdaiFile_description(); + SdaiFile_description(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiFile_description(SdaiFile_description &e); ~SdaiFile_description(); - int opcode() { + int opcode() + { return 4 ; } StringAggregate_ptr description_() const; - void description_( const StringAggregate_ptr x ); + void description_(const StringAggregate_ptr x); const SDAI_String implementation_level_() const; - void implementation_level_( const SDAI_String x ); + void implementation_level_(const SDAI_String x); }; inline SdaiFile_description * -create_SdaiFile_description() { +create_SdaiFile_description() +{ return new SdaiFile_description ; } @@ -220,29 +235,32 @@ create_SdaiFile_description() { ///////// ENTITY file_schema -extern SC_EDITOR_EXPORT AttrDescriptor * a_16schema_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor *a_16schema_identifiers; -class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance { +class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance +{ protected: StringAggregate _schema_identifiers ; // of schema_name public: - SdaiFile_schema( ); - SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs = 0 ); - SdaiFile_schema( SdaiFile_schema & e ); + SdaiFile_schema(); + SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs = 0); + SdaiFile_schema(SdaiFile_schema &e); ~SdaiFile_schema(); - int opcode() { + int opcode() + { return 5 ; } StringAggregate_ptr schema_identifiers_() const; - void schema_identifiers_( const StringAggregate_ptr x ); + void schema_identifiers_(const StringAggregate_ptr x); }; inline SdaiFile_schema * -create_SdaiFile_schema() { +create_SdaiFile_schema() +{ return new SdaiFile_schema ; } @@ -251,7 +269,8 @@ create_SdaiFile_schema() { // ***** generate Model related pieces -class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents { +class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents +{ public: SdaiModel_contents_header_section_schema(); @@ -271,7 +290,7 @@ class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Mo }; -typedef SdaiModel_contents_header_section_schema * SdaiModel_contents_header_section_schema_ptr; +typedef SdaiModel_contents_header_section_schema *SdaiModel_contents_header_section_schema_ptr; typedef SdaiModel_contents_header_section_schema_ptr SdaiModel_contents_header_section_schema_var; SC_EDITOR_EXPORT SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema(); #endif diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index 3a469c7d3..d4431ebf5 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -7,83 +7,84 @@ #include #include "sc_memmgr.h" -void HeaderInitSchemasAndEnts( Registry & reg ) { +void HeaderInitSchemasAndEnts(Registry ®) +{ Uniqueness_rule_ptr ur; // Schema: SdaiHEADER_SECTION_SCHEMA - s_header_section_schema = new Schema( "Header_Section_Schema" ); + s_header_section_schema = new Schema("Header_Section_Schema"); s_header_section_schema->AssignModelContentsCreator( - ( ModelContentsCreator ) create_SdaiModel_contents_header_section_schema ); - reg.AddSchema( *s_header_section_schema ); + (ModelContentsCreator) create_SdaiModel_contents_header_section_schema); + reg.AddSchema(*s_header_section_schema); // ***** Initialize the Types header_section_schemat_time_stamp_text = new TypeDescriptor( "Time_Stamp_Text", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (256)" ); // Description - s_header_section_schema->AddType( header_section_schemat_time_stamp_text ); + "STRING (256)"); // Description + s_header_section_schema->AddType(header_section_schemat_time_stamp_text); header_section_schemat_section_name = new TypeDescriptor( "Section_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier" ); // Description - s_header_section_schema->AddType( header_section_schemat_section_name ); + "exchange_structure_identifier"); // Description + s_header_section_schema->AddType(header_section_schemat_section_name); header_section_schemat_context_name = new TypeDescriptor( "Context_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING" ); // Description - s_header_section_schema->AddType( header_section_schemat_context_name ); + "STRING"); // Description + s_header_section_schema->AddType(header_section_schemat_context_name); header_section_schemat_schema_name = new TypeDescriptor( "Schema_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (1024)" ); // Description - s_header_section_schema->AddType( header_section_schemat_schema_name ); + "STRING (1024)"); // Description + s_header_section_schema->AddType(header_section_schemat_schema_name); header_section_schemat_language_name = new TypeDescriptor( "Language_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier" ); // Description - s_header_section_schema->AddType( header_section_schemat_language_name ); + "exchange_structure_identifier"); // Description + s_header_section_schema->AddType(header_section_schemat_language_name); header_section_schemat_exchange_structure_identifier = new TypeDescriptor( "Exchange_Structure_Identifier", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING" ); // Description - s_header_section_schema->AddType( header_section_schemat_exchange_structure_identifier ); + "STRING"); // Description + s_header_section_schema->AddType(header_section_schemat_exchange_structure_identifier); // ***** Initialize the Entities header_section_schemae_section_language = new EntityDescriptor( "Section_Language", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiSection_language ); - s_header_section_schema->AddEntity( header_section_schemae_section_language ); + (Creator) create_SdaiSection_language); + s_header_section_schema->AddEntity(header_section_schemae_section_language); header_section_schemae_section_language->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule( "UR1 : section;\n" ); - header_section_schemae_section_language->_uniqueness_rules->Append( ur ); + ur = new Uniqueness_rule("UR1 : section;\n"); + header_section_schemae_section_language->_uniqueness_rules->Append(ur); header_section_schemae_file_population = new EntityDescriptor( "File_Population", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiFile_population ); - s_header_section_schema->AddEntity( header_section_schemae_file_population ); + (Creator) create_SdaiFile_population); + s_header_section_schema->AddEntity(header_section_schemae_file_population); header_section_schemae_file_name = new EntityDescriptor( "File_Name", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiFile_name ); - s_header_section_schema->AddEntity( header_section_schemae_file_name ); + (Creator) create_SdaiFile_name); + s_header_section_schema->AddEntity(header_section_schemae_file_name); header_section_schemae_section_context = new EntityDescriptor( "Section_Context", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiSection_context ); - s_header_section_schema->AddEntity( header_section_schemae_section_context ); + (Creator) create_SdaiSection_context); + s_header_section_schema->AddEntity(header_section_schemae_section_context); header_section_schemae_section_context->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule( "UR1 : section;\n" ); - header_section_schemae_section_context->_uniqueness_rules->Append( ur ); + ur = new Uniqueness_rule("UR1 : section;\n"); + header_section_schemae_section_context->_uniqueness_rules->Append(ur); header_section_schemae_file_description = new EntityDescriptor( "File_Description", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiFile_description ); - s_header_section_schema->AddEntity( header_section_schemae_file_description ); + (Creator) create_SdaiFile_description); + s_header_section_schema->AddEntity(header_section_schemae_file_description); header_section_schemae_file_schema = new EntityDescriptor( "File_Schema", s_header_section_schema, LFalse, LFalse, - ( Creator ) create_SdaiFile_schema ); - s_header_section_schema->AddEntity( header_section_schemae_file_schema ); + (Creator) create_SdaiFile_schema); + s_header_section_schema->AddEntity(header_section_schemae_file_schema); //////////////// USE statements //////////////// REFERENCE statements diff --git a/src/cleditor/SdaiHeaderSchemaClasses.h b/src/cleditor/SdaiHeaderSchemaClasses.h index 5427bd7b5..307af452b 100644 --- a/src/cleditor/SdaiHeaderSchemaClasses.h +++ b/src/cleditor/SdaiHeaderSchemaClasses.h @@ -7,81 +7,81 @@ #include // Schema: SdaiHEADER_SECTION_SCHEMA -extern Schema * s_header_section_schema; +extern Schema *s_header_section_schema; // Types: typedef SDAI_String SdaiTime_stamp_text; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_time_stamp_text; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_time_stamp_text; typedef SDAI_String SdaiSection_name; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_section_name; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_section_name; typedef SDAI_String SdaiContext_name; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_context_name; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_context_name; typedef SDAI_String SdaiSchema_name; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_schema_name; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_schema_name; typedef SDAI_String SdaiLanguage_name; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_language_name; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_language_name; typedef SDAI_String SdaiExchange_structure_identifier; -extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_exchange_structure_identifier; +extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_exchange_structure_identifier; // Entities: class SdaiSection_language; -typedef SdaiSection_language * SdaiSection_languageH; -typedef SdaiSection_language * SdaiSection_language_ptr; +typedef SdaiSection_language *SdaiSection_languageH; +typedef SdaiSection_language *SdaiSection_language_ptr; typedef SdaiSection_language_ptr SdaiSection_language_var; -typedef const SdaiSection_language * const_SdaiSection_languageH; -typedef const SdaiSection_language * const_SdaiSection_language_ptr; +typedef const SdaiSection_language *const_SdaiSection_languageH; +typedef const SdaiSection_language *const_SdaiSection_language_ptr; #define SdaiSection_language__set SDAI_DAObject__set #define SdaiSection_language__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_language; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_language; class SdaiFile_population; -typedef SdaiFile_population * SdaiFile_populationH; -typedef SdaiFile_population * SdaiFile_population_ptr; +typedef SdaiFile_population *SdaiFile_populationH; +typedef SdaiFile_population *SdaiFile_population_ptr; typedef SdaiFile_population_ptr SdaiFile_population_var; -typedef const SdaiFile_population * const_SdaiFile_populationH; -typedef const SdaiFile_population * const_SdaiFile_population_ptr; +typedef const SdaiFile_population *const_SdaiFile_populationH; +typedef const SdaiFile_population *const_SdaiFile_population_ptr; #define SdaiFile_population__set SDAI_DAObject__set #define SdaiFile_population__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_population; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_population; class SdaiFile_name; -typedef SdaiFile_name * SdaiFile_nameH; -typedef SdaiFile_name * SdaiFile_name_ptr; +typedef SdaiFile_name *SdaiFile_nameH; +typedef SdaiFile_name *SdaiFile_name_ptr; typedef SdaiFile_name_ptr SdaiFile_name_var; -typedef const SdaiFile_name * const_SdaiFile_nameH; -typedef const SdaiFile_name * const_SdaiFile_name_ptr; +typedef const SdaiFile_name *const_SdaiFile_nameH; +typedef const SdaiFile_name *const_SdaiFile_name_ptr; #define SdaiFile_name__set SDAI_DAObject__set #define SdaiFile_name__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_name; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_name; class SdaiSection_context; -typedef SdaiSection_context * SdaiSection_contextH; -typedef SdaiSection_context * SdaiSection_context_ptr; +typedef SdaiSection_context *SdaiSection_contextH; +typedef SdaiSection_context *SdaiSection_context_ptr; typedef SdaiSection_context_ptr SdaiSection_context_var; -typedef const SdaiSection_context * const_SdaiSection_contextH; -typedef const SdaiSection_context * const_SdaiSection_context_ptr; +typedef const SdaiSection_context *const_SdaiSection_contextH; +typedef const SdaiSection_context *const_SdaiSection_context_ptr; #define SdaiSection_context__set SDAI_DAObject__set #define SdaiSection_context__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_context; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_context; class SdaiFile_description; -typedef SdaiFile_description * SdaiFile_descriptionH; -typedef SdaiFile_description * SdaiFile_description_ptr; +typedef SdaiFile_description *SdaiFile_descriptionH; +typedef SdaiFile_description *SdaiFile_description_ptr; typedef SdaiFile_description_ptr SdaiFile_description_var; -typedef const SdaiFile_description * const_SdaiFile_descriptionH; -typedef const SdaiFile_description * const_SdaiFile_description_ptr; +typedef const SdaiFile_description *const_SdaiFile_descriptionH; +typedef const SdaiFile_description *const_SdaiFile_description_ptr; #define SdaiFile_description__set SDAI_DAObject__set #define SdaiFile_description__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_description; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_description; class SdaiFile_schema; -typedef SdaiFile_schema * SdaiFile_schemaH; -typedef SdaiFile_schema * SdaiFile_schema_ptr; +typedef SdaiFile_schema *SdaiFile_schemaH; +typedef SdaiFile_schema *SdaiFile_schema_ptr; typedef SdaiFile_schema_ptr SdaiFile_schema_var; -typedef const SdaiFile_schema * const_SdaiFile_schemaH; -typedef const SdaiFile_schema * const_SdaiFile_schema_ptr; +typedef const SdaiFile_schema *const_SdaiFile_schemaH; +typedef const SdaiFile_schema *const_SdaiFile_schema_ptr; #define SdaiFile_schema__set SDAI_DAObject__set #define SdaiFile_schema__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_schema; +extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_schema; #endif diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 35099d805..97661537a 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -10,182 +10,183 @@ #include #include "sc_memmgr.h" -void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { - header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); - reg.AddType( *header_section_schemat_time_stamp_text ); - header_section_schemat_section_name->ReferentType( header_section_schemat_exchange_structure_identifier ); - reg.AddType( *header_section_schemat_section_name ); - header_section_schemat_context_name->ReferentType( t_sdaiSTRING ); - reg.AddType( *header_section_schemat_context_name ); - header_section_schemat_schema_name->ReferentType( t_sdaiSTRING ); - reg.AddType( *header_section_schemat_schema_name ); - header_section_schemat_language_name->ReferentType( header_section_schemat_exchange_structure_identifier ); - reg.AddType( *header_section_schemat_language_name ); - header_section_schemat_exchange_structure_identifier->ReferentType( t_sdaiSTRING ); - reg.AddType( *header_section_schemat_exchange_structure_identifier ); +void SdaiHEADER_SECTION_SCHEMAInit(Registry ®) +{ + header_section_schemat_time_stamp_text->ReferentType(t_sdaiSTRING); + reg.AddType(*header_section_schemat_time_stamp_text); + header_section_schemat_section_name->ReferentType(header_section_schemat_exchange_structure_identifier); + reg.AddType(*header_section_schemat_section_name); + header_section_schemat_context_name->ReferentType(t_sdaiSTRING); + reg.AddType(*header_section_schemat_context_name); + header_section_schemat_schema_name->ReferentType(t_sdaiSTRING); + reg.AddType(*header_section_schemat_schema_name); + header_section_schemat_language_name->ReferentType(header_section_schemat_exchange_structure_identifier); + reg.AddType(*header_section_schemat_language_name); + header_section_schemat_exchange_structure_identifier->ReferentType(t_sdaiSTRING); + reg.AddType(*header_section_schemat_exchange_structure_identifier); ///////// ENTITY section_language a_0section = - new AttrDescriptor( "section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_language ); - header_section_schemae_section_language->AddExplicitAttr( a_0section ); + new AttrDescriptor("section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_language); + header_section_schemae_section_language->AddExplicitAttr(a_0section); a_1default_language = - new AttrDescriptor( "default_language", header_section_schemat_language_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_language ); - header_section_schemae_section_language->AddExplicitAttr( a_1default_language ); - reg.AddEntity( *header_section_schemae_section_language ); + new AttrDescriptor("default_language", header_section_schemat_language_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_language); + header_section_schemae_section_language->AddExplicitAttr(a_1default_language); + reg.AddEntity(*header_section_schemae_section_language); ///////// END_ENTITY section_language ///////// ENTITY file_population a_2governing_schema = - new AttrDescriptor( "governing_schema", header_section_schemat_schema_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population ); - header_section_schemae_file_population->AddExplicitAttr( a_2governing_schema ); + new AttrDescriptor("governing_schema", header_section_schemat_schema_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population); + header_section_schemae_file_population->AddExplicitAttr(a_2governing_schema); a_3determination_method = - new AttrDescriptor( "determination_method", header_section_schemat_exchange_structure_identifier, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population ); - header_section_schemae_file_population->AddExplicitAttr( a_3determination_method ); - SetTypeDescriptor * t_0 = new SetTypeDescriptor; - t_0->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_0->SetBound1( 1 ); - t_0->SetBound2( 2147483647 ); - t_0->FundamentalType( SET_TYPE ); - t_0->Description( "SET [1:?] OF section_name" ); - t_0->OriginatingSchema( s_header_section_schema ); - t_0->ReferentType( header_section_schemat_section_name ); - s_header_section_schema->AddUnnamedType( t_0 ); + new AttrDescriptor("determination_method", header_section_schemat_exchange_structure_identifier, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population); + header_section_schemae_file_population->AddExplicitAttr(a_3determination_method); + SetTypeDescriptor *t_0 = new SetTypeDescriptor; + t_0->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_0->SetBound1(1); + t_0->SetBound2(2147483647); + t_0->FundamentalType(SET_TYPE); + t_0->Description("SET [1:?] OF section_name"); + t_0->OriginatingSchema(s_header_section_schema); + t_0->ReferentType(header_section_schemat_section_name); + s_header_section_schema->AddUnnamedType(t_0); a_4governed_sections = - new AttrDescriptor( "governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, - *header_section_schemae_file_population ); - header_section_schemae_file_population->AddExplicitAttr( a_4governed_sections ); - reg.AddEntity( *header_section_schemae_file_population ); + new AttrDescriptor("governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, + *header_section_schemae_file_population); + header_section_schemae_file_population->AddExplicitAttr(a_4governed_sections); + reg.AddEntity(*header_section_schemae_file_population); ///////// END_ENTITY file_population ///////// ENTITY file_name a_5name = - new AttrDescriptor( "name", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_5name ); + new AttrDescriptor("name", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_5name); a_6time_stamp = - new AttrDescriptor( "time_stamp", header_section_schemat_time_stamp_text, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_6time_stamp ); - ListTypeDescriptor * t_1 = new ListTypeDescriptor; - t_1->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_1->SetBound1( 1 ); - t_1->SetBound2( 2147483647 ); - t_1->FundamentalType( LIST_TYPE ); - t_1->Description( "LIST [1:?] OF STRING (256)" ); - t_1->OriginatingSchema( s_header_section_schema ); - t_1->ReferentType( t_sdaiSTRING ); - s_header_section_schema->AddUnnamedType( t_1 ); + new AttrDescriptor("time_stamp", header_section_schemat_time_stamp_text, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_6time_stamp); + ListTypeDescriptor *t_1 = new ListTypeDescriptor; + t_1->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_1->SetBound1(1); + t_1->SetBound2(2147483647); + t_1->FundamentalType(LIST_TYPE); + t_1->Description("LIST [1:?] OF STRING (256)"); + t_1->OriginatingSchema(s_header_section_schema); + t_1->ReferentType(t_sdaiSTRING); + s_header_section_schema->AddUnnamedType(t_1); a_7author = - new AttrDescriptor( "author", t_1, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_7author ); - ListTypeDescriptor * t_2 = new ListTypeDescriptor; - t_2->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_2->SetBound1( 1 ); - t_2->SetBound2( 2147483647 ); - t_2->FundamentalType( LIST_TYPE ); - t_2->Description( "LIST [1:?] OF STRING (256)" ); - t_2->OriginatingSchema( s_header_section_schema ); - t_2->ReferentType( t_sdaiSTRING ); - s_header_section_schema->AddUnnamedType( t_2 ); + new AttrDescriptor("author", t_1, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_7author); + ListTypeDescriptor *t_2 = new ListTypeDescriptor; + t_2->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_2->SetBound1(1); + t_2->SetBound2(2147483647); + t_2->FundamentalType(LIST_TYPE); + t_2->Description("LIST [1:?] OF STRING (256)"); + t_2->OriginatingSchema(s_header_section_schema); + t_2->ReferentType(t_sdaiSTRING); + s_header_section_schema->AddUnnamedType(t_2); a_8organization = - new AttrDescriptor( "organization", t_2, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_8organization ); + new AttrDescriptor("organization", t_2, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_8organization); a_9preprocessor_version = - new AttrDescriptor( "preprocessor_version", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_9preprocessor_version ); + new AttrDescriptor("preprocessor_version", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_9preprocessor_version); a_10originating_system = - new AttrDescriptor( "originating_system", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_10originating_system ); + new AttrDescriptor("originating_system", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_10originating_system); a_11authorization = - new AttrDescriptor( "authorization", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name ); - header_section_schemae_file_name->AddExplicitAttr( a_11authorization ); - reg.AddEntity( *header_section_schemae_file_name ); + new AttrDescriptor("authorization", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name); + header_section_schemae_file_name->AddExplicitAttr(a_11authorization); + reg.AddEntity(*header_section_schemae_file_name); ///////// END_ENTITY file_name ///////// ENTITY section_context a_12section = - new AttrDescriptor( "section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_context ); - header_section_schemae_section_context->AddExplicitAttr( a_12section ); - ListTypeDescriptor * t_3 = new ListTypeDescriptor; - t_3->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_3->SetBound1( 1 ); - t_3->SetBound2( 2147483647 ); - t_3->FundamentalType( LIST_TYPE ); - t_3->Description( "LIST [1:?] OF context_name" ); - t_3->OriginatingSchema( s_header_section_schema ); - t_3->ReferentType( header_section_schemat_context_name ); - s_header_section_schema->AddUnnamedType( t_3 ); + new AttrDescriptor("section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_context); + header_section_schemae_section_context->AddExplicitAttr(a_12section); + ListTypeDescriptor *t_3 = new ListTypeDescriptor; + t_3->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_3->SetBound1(1); + t_3->SetBound2(2147483647); + t_3->FundamentalType(LIST_TYPE); + t_3->Description("LIST [1:?] OF context_name"); + t_3->OriginatingSchema(s_header_section_schema); + t_3->ReferentType(header_section_schemat_context_name); + s_header_section_schema->AddUnnamedType(t_3); a_13context_identifiers = - new AttrDescriptor( "context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_context ); - header_section_schemae_section_context->AddExplicitAttr( a_13context_identifiers ); - reg.AddEntity( *header_section_schemae_section_context ); + new AttrDescriptor("context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_context); + header_section_schemae_section_context->AddExplicitAttr(a_13context_identifiers); + reg.AddEntity(*header_section_schemae_section_context); ///////// END_ENTITY section_context ///////// ENTITY file_description - ListTypeDescriptor * t_4 = new ListTypeDescriptor; - t_4->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_4->SetBound1( 1 ); - t_4->SetBound2( 2147483647 ); - t_4->FundamentalType( LIST_TYPE ); - t_4->Description( "LIST [1:?] OF STRING (256)" ); - t_4->OriginatingSchema( s_header_section_schema ); - t_4->ReferentType( t_sdaiSTRING ); - s_header_section_schema->AddUnnamedType( t_4 ); + ListTypeDescriptor *t_4 = new ListTypeDescriptor; + t_4->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_4->SetBound1(1); + t_4->SetBound2(2147483647); + t_4->FundamentalType(LIST_TYPE); + t_4->Description("LIST [1:?] OF STRING (256)"); + t_4->OriginatingSchema(s_header_section_schema); + t_4->ReferentType(t_sdaiSTRING); + s_header_section_schema->AddUnnamedType(t_4); a_14description = - new AttrDescriptor( "description", t_4, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description ); - header_section_schemae_file_description->AddExplicitAttr( a_14description ); + new AttrDescriptor("description", t_4, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description); + header_section_schemae_file_description->AddExplicitAttr(a_14description); a_15implementation_level = - new AttrDescriptor( "implementation_level", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description ); - header_section_schemae_file_description->AddExplicitAttr( a_15implementation_level ); - reg.AddEntity( *header_section_schemae_file_description ); + new AttrDescriptor("implementation_level", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description); + header_section_schemae_file_description->AddExplicitAttr(a_15implementation_level); + reg.AddEntity(*header_section_schemae_file_description); ///////// END_ENTITY file_description ///////// ENTITY file_schema - ListTypeDescriptor * t_5 = new ListTypeDescriptor; - t_5->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function - t_5->SetBound1( 1 ); - t_5->SetBound2( 2147483647 ); - t_5->UniqueElements( LTrue ); - t_5->FundamentalType( LIST_TYPE ); - t_5->Description( "LIST [1:?] OF UNIQUE schema_name" ); - t_5->OriginatingSchema( s_header_section_schema ); - t_5->ReferentType( header_section_schemat_schema_name ); - s_header_section_schema->AddUnnamedType( t_5 ); + ListTypeDescriptor *t_5 = new ListTypeDescriptor; + t_5->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function + t_5->SetBound1(1); + t_5->SetBound2(2147483647); + t_5->UniqueElements(LTrue); + t_5->FundamentalType(LIST_TYPE); + t_5->Description("LIST [1:?] OF UNIQUE schema_name"); + t_5->OriginatingSchema(s_header_section_schema); + t_5->ReferentType(header_section_schemat_schema_name); + s_header_section_schema->AddUnnamedType(t_5); a_16schema_identifiers = - new AttrDescriptor( "schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_schema ); - header_section_schemae_file_schema->AddExplicitAttr( a_16schema_identifiers ); - reg.AddEntity( *header_section_schemae_file_schema ); + new AttrDescriptor("schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_schema); + header_section_schemae_file_schema->AddExplicitAttr(a_16schema_identifiers); + reg.AddEntity(*header_section_schemae_file_schema); ///////// END_ENTITY file_schema } diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index 05790a09c..a5c2a45b3 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -7,10 +7,11 @@ #include #include "sc_memmgr.h" -void HeaderSchemaInit( Registry & reg ) { - HeaderInitSchemasAndEnts( reg ); - SdaiHEADER_SECTION_SCHEMAInit( reg ); - reg.SetCompCollect( 0 ); +void HeaderSchemaInit(Registry ®) +{ + HeaderInitSchemasAndEnts(reg); + SdaiHEADER_SECTION_SCHEMAInit(reg); + reg.SetCompCollect(0); } #endif diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index a0868fbc6..2a9589ff7 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -20,8 +20,8 @@ #include #include -SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & ); -SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & ); -SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit( Registry & r ); +SC_EDITOR_EXPORT void HeaderSchemaInit(Registry &); +SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts(Registry &); +SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit(Registry &r); #endif diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index 7c015ce47..ed90f8887 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -13,72 +13,79 @@ #include #include "sc_memmgr.h" -ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { - ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); +ReplicateLinkNode *ReplicateList::FindNode(MgrNode *mn) +{ + ReplicateLinkNode *rln = (ReplicateLinkNode *)GetHead(); int numEntries = EntryCount(); - while( numEntries-- ) { - if( rln->ReplicateNode() == mn ) { + while(numEntries--) { + if(rln->ReplicateNode() == mn) { return rln; } - rln = ( ReplicateLinkNode * )rln->NextNode(); + rln = (ReplicateLinkNode *)rln->NextNode(); } return 0; } -bool ReplicateList::IsOnList( MgrNode * mn ) { - return ( FindNode( mn ) != 0 ); +bool ReplicateList::IsOnList(MgrNode *mn) +{ + return (FindNode(mn) != 0); } /////////////////////////////////////////////////////////////////////////////// // returns true if it could delete the node /////////////////////////////////////////////////////////////////////////////// -bool ReplicateList::Remove( ReplicateLinkNode * rln ) { - ReplicateLinkNode * rnFollow = ( ReplicateLinkNode * )GetHead(); - if( !rnFollow || !rln ) { +bool ReplicateList::Remove(ReplicateLinkNode *rln) +{ + ReplicateLinkNode *rnFollow = (ReplicateLinkNode *)GetHead(); + if(!rnFollow || !rln) { return false; } else { - if( rnFollow == rln ) { + if(rnFollow == rln) { head = rln->NextNode(); delete rln; return true; } else { - ReplicateLinkNode * rn = ( ReplicateLinkNode * )rnFollow->NextNode(); - while( rn ) { - if( rn == rln ) { - rnFollow->next = ( SingleLinkNode * )rln->NextNode(); + ReplicateLinkNode *rn = (ReplicateLinkNode *)rnFollow->NextNode(); + while(rn) { + if(rn == rln) { + rnFollow->next = (SingleLinkNode *)rln->NextNode(); delete rln; return true; } rnFollow = rn; - rn = ( ReplicateLinkNode * )rn->NextNode(); + rn = (ReplicateLinkNode *)rn->NextNode(); } // end while(rn) } // end else } // end else return false; } -bool ReplicateList::Remove( MgrNode * rn ) { - return Remove( FindNode( rn ) ); +bool ReplicateList::Remove(MgrNode *rn) +{ + return Remove(FindNode(rn)); } -CmdMgr::CmdMgr() { - completeList = new MgrNodeList( completeSE ); - incompleteList = new MgrNodeList( incompleteSE ); - deleteList = new MgrNodeList( deleteSE ); +CmdMgr::CmdMgr() +{ + completeList = new MgrNodeList(completeSE); + incompleteList = new MgrNodeList(incompleteSE); + deleteList = new MgrNodeList(deleteSE); - mappedWriteList = new DisplayNodeList( mappedWrite ); - mappedViewList = new DisplayNodeList( mappedView ); - closeList = new DisplayNodeList( notMapped ); + mappedWriteList = new DisplayNodeList(mappedWrite); + mappedViewList = new DisplayNodeList(mappedView); + closeList = new DisplayNodeList(notMapped); replicateList = new ReplicateList(); } -void CmdMgr::ReplicateCmdList( MgrNode * mn ) { - if( !( replicateList->IsOnList( mn ) ) ) { - replicateList->AddNode( mn ); +void CmdMgr::ReplicateCmdList(MgrNode *mn) +{ + if(!(replicateList->IsOnList(mn))) { + replicateList->AddNode(mn); } } -void CmdMgr::ClearInstances() { +void CmdMgr::ClearInstances() +{ completeList->ClearEntries(); incompleteList->ClearEntries(); cancelList->ClearEntries(); @@ -87,14 +94,15 @@ void CmdMgr::ClearInstances() { } /// searches current list for fileId -MgrNode * CmdMgr::StateFindFileId( stateEnum s, int fileId ) { - switch( s ) { +MgrNode *CmdMgr::StateFindFileId(stateEnum s, int fileId) +{ + switch(s) { case completeSE: - return completeList->FindFileId( fileId ); + return completeList->FindFileId(fileId); case incompleteSE: - return incompleteList->FindFileId( fileId ); + return incompleteList->FindFileId(fileId); case deleteSE: - return deleteList->FindFileId( fileId ); + return deleteList->FindFileId(fileId); case newSE: // there is no new list case noStateSE: default: @@ -104,29 +112,31 @@ MgrNode * CmdMgr::StateFindFileId( stateEnum s, int fileId ) { } } -MgrNode * CmdMgr::GetHead( stateEnum listType ) { - switch( listType ) { +MgrNode *CmdMgr::GetHead(stateEnum listType) +{ + switch(listType) { case completeSE: // saved complete list - return ( MgrNode * )completeList->GetHead(); + return (MgrNode *)completeList->GetHead(); case incompleteSE: // saved incomplete list - return ( MgrNode * )incompleteList->GetHead(); + return (MgrNode *)incompleteList->GetHead(); case deleteSE: // delete list - return ( MgrNode * )deleteList->GetHead(); + return (MgrNode *)deleteList->GetHead(); default: return 0; } } -DisplayNode * CmdMgr::GetHead( displayStateEnum listType ) { - switch( listType ) { +DisplayNode *CmdMgr::GetHead(displayStateEnum listType) +{ + switch(listType) { case mappedWrite: - return ( DisplayNode * )mappedWriteList->GetHead(); + return (DisplayNode *)mappedWriteList->GetHead(); case mappedView: - return ( DisplayNode * )mappedViewList->GetHead(); + return (DisplayNode *)mappedViewList->GetHead(); case notMapped: - return ( DisplayNode * )closeList->GetHead(); + return (DisplayNode *)closeList->GetHead(); case noMapState: default: @@ -134,8 +144,9 @@ DisplayNode * CmdMgr::GetHead( displayStateEnum listType ) { } } -void CmdMgr::ClearEntries( stateEnum listType ) { - switch( listType ) { +void CmdMgr::ClearEntries(stateEnum listType) +{ + switch(listType) { case completeSE: // saved complete list completeList->ClearEntries(); break; @@ -150,8 +161,9 @@ void CmdMgr::ClearEntries( stateEnum listType ) { } } -void CmdMgr::ClearEntries( displayStateEnum listType ) { - switch( listType ) { +void CmdMgr::ClearEntries(displayStateEnum listType) +{ + switch(listType) { case mappedWrite: mappedWriteList->ClearEntries(); break; diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 7ef2f00b5..0f985cb24 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -77,121 +77,141 @@ /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode { +class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode +{ private: protected: - MgrNode * _repNode; + MgrNode *_repNode; public: - ReplicateLinkNode() { + ReplicateLinkNode() + { _repNode = 0; } ~ReplicateLinkNode() { } - const char * ClassName() { + const char *ClassName() + { return "ReplicateLinkNode"; } - MgrNode * ReplicateNode() { + MgrNode *ReplicateNode() + { return _repNode; } - void ReplicateNode( MgrNode * rn ) { + void ReplicateNode(MgrNode *rn) + { _repNode = rn; } }; -class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList { +class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList +{ private: protected: public: ReplicateList() { } ~ReplicateList() { } - virtual SingleLinkNode * NewNode() { + virtual SingleLinkNode *NewNode() + { return new ReplicateLinkNode; } - bool IsOnList( MgrNode * mn ); - ReplicateLinkNode * FindNode( MgrNode * mn ); + bool IsOnList(MgrNode *mn); + ReplicateLinkNode *FindNode(MgrNode *mn); - ReplicateLinkNode * AddNode( MgrNode * rn ) { - ReplicateLinkNode * node = ( ReplicateLinkNode * ) NewNode(); - node->ReplicateNode( rn ); - SingleLinkList::AppendNode( node ); + ReplicateLinkNode *AddNode(MgrNode *rn) + { + ReplicateLinkNode *node = (ReplicateLinkNode *) NewNode(); + node->ReplicateNode(rn); + SingleLinkList::AppendNode(node); return node; } - bool Remove( ReplicateLinkNode * rln ); - bool Remove( MgrNode * rn ); + bool Remove(ReplicateLinkNode *rln); + bool Remove(MgrNode *rn); - const char * ClassName() { + const char *ClassName() + { return "ReplicateList"; } }; /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT CmdMgr { +class SC_EDITOR_EXPORT CmdMgr +{ protected: - MgrNodeList * completeList; - MgrNodeList * incompleteList; - MgrNodeList * cancelList; - MgrNodeList * deleteList; + MgrNodeList *completeList; + MgrNodeList *incompleteList; + MgrNodeList *cancelList; + MgrNodeList *deleteList; - DisplayNodeList * mappedWriteList; - DisplayNodeList * mappedViewList; - DisplayNodeList * closeList; + DisplayNodeList *mappedWriteList; + DisplayNodeList *mappedViewList; + DisplayNodeList *closeList; - ReplicateList * replicateList; + ReplicateList *replicateList; public: CmdMgr(); // STATE LIST OPERATIONS - MgrNode * GetHead( stateEnum listType ); - DisplayNode * GetHead( displayStateEnum listType ); - ReplicateLinkNode * GetReplicateHead() { - return ( ReplicateLinkNode * )( replicateList->GetHead() ); + MgrNode *GetHead(stateEnum listType); + DisplayNode *GetHead(displayStateEnum listType); + ReplicateLinkNode *GetReplicateHead() + { + return (ReplicateLinkNode *)(replicateList->GetHead()); } - void ClearEntries( stateEnum listType ); - void ClearEntries( displayStateEnum listType ); - void ClearReplicateEntries() { + void ClearEntries(stateEnum listType); + void ClearEntries(displayStateEnum listType); + void ClearReplicateEntries() + { replicateList->Empty(); } - ReplicateList * RepList() { + ReplicateList *RepList() + { return replicateList; } // searches current list for fileId - MgrNode * StateFindFileId( stateEnum s, int fileId ); + MgrNode *StateFindFileId(stateEnum s, int fileId); // returns stateNext or statePrev member variables // i.e. next or previous node on curr state list - int SaveCompleteCmdList( MgrNode * mn ) { - return mn->ChangeList( completeList ); + int SaveCompleteCmdList(MgrNode *mn) + { + return mn->ChangeList(completeList); } - int SaveIncompleteCmdList( MgrNode * mn ) { - return mn->ChangeList( incompleteList ); + int SaveIncompleteCmdList(MgrNode *mn) + { + return mn->ChangeList(incompleteList); } - int CancelCmdList( MgrNode * mn ) { - return mn->ChangeList( cancelList ); + int CancelCmdList(MgrNode *mn) + { + return mn->ChangeList(cancelList); } - int DeleteCmdList( MgrNode * mn ) { - return mn->ChangeList( deleteList ); + int DeleteCmdList(MgrNode *mn) + { + return mn->ChangeList(deleteList); } - int ModifyCmdList( MgrNode * mn ) { - return mn->ChangeList( mappedWriteList ); + int ModifyCmdList(MgrNode *mn) + { + return mn->ChangeList(mappedWriteList); } - int ViewCmdList( MgrNode * mn ) { - return mn->ChangeList( mappedViewList ); + int ViewCmdList(MgrNode *mn) + { + return mn->ChangeList(mappedViewList); } - int CloseCmdList( MgrNode * mn ) { - return ( ( mn->DisplayState() == mappedWrite ) || - ( mn->DisplayState() == mappedView ) ) ? - mn->ChangeList( closeList ) : 0; + int CloseCmdList(MgrNode *mn) + { + return ((mn->DisplayState() == mappedWrite) || + (mn->DisplayState() == mappedView)) ? + mn->ChangeList(closeList) : 0; } - void ReplicateCmdList( MgrNode * mn ); + void ReplicateCmdList(MgrNode *mn); void ClearInstances(); protected: diff --git a/src/cleditor/seeinfodefault.h b/src/cleditor/seeinfodefault.h index 51198eac8..5c24ba863 100644 --- a/src/cleditor/seeinfodefault.h +++ b/src/cleditor/seeinfodefault.h @@ -25,23 +25,26 @@ class DisplayNodelist; #include -class SC_EDITOR_EXPORT seeInfo : public DisplayNode { +class SC_EDITOR_EXPORT seeInfo : public DisplayNode +{ public: - seeInfo( MgrNode * node, - SDAI_Application_instance * se, - DisplayNodeList * dnl, displayStateEnum displaySt = mappedWrite ); + seeInfo(MgrNode *node, + SDAI_Application_instance *se, + DisplayNodeList *dnl, displayStateEnum displaySt = mappedWrite); - void * GetSEE() { + void *GetSEE() + { return see; } }; -inline seeInfo::seeInfo( MgrNode * node, SDAI_Application_instance * se, - DisplayNodeList * dnl, displayStateEnum displaySt ) { +inline seeInfo::seeInfo(MgrNode *node, SDAI_Application_instance *se, + DisplayNodeList *dnl, displayStateEnum displaySt) +{ mn = node; see = 0; displayState = displaySt; - dnl->Append( this ); + dnl->Append(this); } #endif diff --git a/src/cllazyfile/headerSectionReader.h b/src/cllazyfile/headerSectionReader.h index 8a51f5721..6c5bf721d 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/src/cllazyfile/headerSectionReader.h @@ -13,21 +13,25 @@ #include "sc_export.h" ///differs from the lazyDataSectionReader in that all instances are always loaded -class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader { +class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader +{ protected: - instancesLoaded_t * _headerInstances; + instancesLoaded_t *_headerInstances; /// must derive from this class - headerSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): - sectionReader( parent, file, start, sid ) { + headerSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid): + sectionReader(parent, file, start, sid) + { _headerInstances = new instancesLoaded_t; } public: - instancesLoaded_t * getInstances() const { + instancesLoaded_t *getInstances() const + { return _headerInstances; } - virtual ~headerSectionReader() { + virtual ~headerSectionReader() + { //FIXME delete each instance?! maybe add to clear, since it iterates over everything already //enum clearHow { rawData, deletePointers } _headerInstances->clear(); diff --git a/src/cllazyfile/instMgrHelper.h b/src/cllazyfile/instMgrHelper.h index 659f1ec8e..0d9321766 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/src/cllazyfile/instMgrHelper.h @@ -17,21 +17,25 @@ * 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 SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase { +class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase +{ protected: - lazyInstMgr * _lim; + lazyInstMgr *_lim; instanceID _id; public: - mgrNodeHelper( lazyInstMgr * lim ) { + mgrNodeHelper(lazyInstMgr *lim) + { _lim = lim; _id = 0; prev = next = 0; } - inline void setInstance( instanceID id ) { + inline void setInstance(instanceID id) + { _id = id; } - inline SDAI_Application_instance * GetSTEPentity() { - return _lim->loadInstance( _id, true ); + inline SDAI_Application_instance *GetSTEPentity() + { + return _lim->loadInstance(_id, true); } }; @@ -43,15 +47,17 @@ class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase { * when an instance is looked up, this uses lazyInstMgr to load it, and then returns a pointer to it. */ -class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase { +class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase +{ protected: mgrNodeHelper _mn; public: - instMgrAdapter( lazyInstMgr * lim ): InstMgrBase(), _mn( lim ) {} + instMgrAdapter(lazyInstMgr *lim): InstMgrBase(), _mn(lim) {} - inline mgrNodeHelper * FindFileId( int fileId ) { + inline mgrNodeHelper *FindFileId(int fileId) + { //TODO check if fileId exists. if not, return null - _mn.setInstance( fileId ); + _mn.setInstance(fileId); return &_mn; } }; diff --git a/src/cllazyfile/lazyDataSectionReader.cc b/src/cllazyfile/lazyDataSectionReader.cc index 4b1bc1785..5d7941bd3 100644 --- a/src/cllazyfile/lazyDataSectionReader.cc +++ b/src/cllazyfile/lazyDataSectionReader.cc @@ -3,9 +3,10 @@ #include "lazyInstMgr.h" #include -lazyDataSectionReader::lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, - std::streampos start, sectionID sid ): - sectionReader( parent, file, start, sid ) { +lazyDataSectionReader::lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, + std::streampos start, sectionID sid): + sectionReader(parent, file, start, sid) +{ _sectionIdentifier = ""; //FIXME set _sectionIdentifier from the data section identifier (2002 rev of Part 21), if present _error = false; } diff --git a/src/cllazyfile/lazyDataSectionReader.h b/src/cllazyfile/lazyDataSectionReader.h index f2dc9dee4..9f4d9763c 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/src/cllazyfile/lazyDataSectionReader.h @@ -13,7 +13,8 @@ * \sa lazyP21DataSectionReader * \sa lazyP28DataSectionReader */ -class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader { +class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader +{ protected: bool _error, _completelyLoaded; #ifdef _MSC_VER @@ -26,10 +27,11 @@ class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader { #endif /// only makes sense to call the ctor from derived class ctors - lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); + lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); public: virtual ~lazyDataSectionReader() {} - bool success() { + bool success() + { return !_error; } }; diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index 9cc294df0..baba1f137 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -6,37 +6,39 @@ #include "headerSectionReader.h" #include "lazyInstMgr.h" -void lazyFileReader::initP21() { - _header = new p21HeaderSectionReader( this, _file, 0, -1 ); +void lazyFileReader::initP21() +{ + _header = new p21HeaderSectionReader(this, _file, 0, -1); - for( ;; ) { - lazyDataSectionReader * r; - r = new lazyP21DataSectionReader( this, _file, _file.tellg(), _parent->countDataSections() ); - if( !r->success() ) { + for(;;) { + lazyDataSectionReader *r; + r = new lazyP21DataSectionReader(this, _file, _file.tellg(), _parent->countDataSections()); + if(!r->success()) { delete r; //last read attempt failed std::cerr << "Corrupted data section" << std::endl; break; } - _parent->registerDataSection( r ); + _parent->registerDataSection(r); //check for new data section (DATA) or end of file (END-ISO-10303-21;) - while( isspace( _file.peek() ) && _file.good() ) { - _file.ignore( 1 ); + while(isspace(_file.peek()) && _file.good()) { + _file.ignore(1); } - if( needKW( "END-ISO-10303-21;" ) ) { + if(needKW("END-ISO-10303-21;")) { break; - } else if( !needKW( "DATA" ) ) { + } else if(!needKW("DATA")) { std::cerr << "Corrupted file - did not find new data section (\"DATA\") or end of file (\"END-ISO-10303-21;\") at offset " << _file.tellg() << std::endl; break; } } } -bool lazyFileReader::needKW( const char * kw ) { - const char * c = kw; +bool lazyFileReader::needKW(const char *kw) +{ + const char *c = kw; bool found = true; - while( *c ) { - if( *c != _file.get() ) { + while(*c) { + if(*c != _file.get()) { found = false; break; } @@ -45,31 +47,34 @@ bool lazyFileReader::needKW( const char * kw ) { return found; } -instancesLoaded_t * lazyFileReader::getHeaderInstances() { +instancesLoaded_t *lazyFileReader::getHeaderInstances() +{ return _header->getInstances(); } -lazyFileReader::lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ): _fileName( fname ), _parent( i ), _fileID( fid ) { - _file.open( _fileName.c_str(), std::ios::binary ); - _file.imbue( std::locale::classic() ); - _file.unsetf( std::ios_base::skipws ); - assert( _file.is_open() && _file.good() ); +lazyFileReader::lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid): _fileName(fname), _parent(i), _fileID(fid) +{ + _file.open(_fileName.c_str(), std::ios::binary); + _file.imbue(std::locale::classic()); + _file.unsetf(std::ios_base::skipws); + assert(_file.is_open() && _file.good()); detectType(); - switch( _fileType ) { + switch(_fileType) { case Part21: initP21(); break; case Part28: - //initP28(); - //break; + //initP28(); + //break; default: std::cerr << "Reached default case, " << __FILE__ << ":" << __LINE__ << std::endl; abort(); } } -lazyFileReader::~lazyFileReader() { +lazyFileReader::~lazyFileReader() +{ delete _header; } diff --git a/src/cllazyfile/lazyFileReader.h b/src/cllazyfile/lazyFileReader.h index 49eea5b50..10a9baabd 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/src/cllazyfile/lazyFileReader.h @@ -24,15 +24,16 @@ class headerSectionReader; ///read an exchange file of any supported type (currently only p21) ///for use only from within lazyInstMgr -class SC_LAZYFILE_EXPORT lazyFileReader { +class SC_LAZYFILE_EXPORT lazyFileReader +{ protected: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif std::string _fileName; - lazyInstMgr * _parent; - headerSectionReader * _header; + lazyInstMgr *_parent; + headerSectionReader *_header; std::ifstream _file; #ifdef _MSC_VER #pragma warning( pop ) @@ -43,26 +44,30 @@ class SC_LAZYFILE_EXPORT lazyFileReader { void initP21(); ///TODO detect file type; for now, assume all are Part 21 - void detectType() { + void detectType() + { _fileType = Part21; } public: - fileID ID() const { + fileID ID() const + { return _fileID; } - instancesLoaded_t * getHeaderInstances(); + instancesLoaded_t *getHeaderInstances(); - lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ); + lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid); ~lazyFileReader(); - fileTypeEnum type() const { + fileTypeEnum type() const + { return _fileType; } - lazyInstMgr * getInstMgr() const { + lazyInstMgr *getInstMgr() const + { return _parent; } - bool needKW( const char * kw ); + bool needKW(const char *kw); }; #endif //LAZYFILEREADER_H diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 7ce253ee9..7d30d3c71 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -8,48 +8,52 @@ #include "sdaiApplication_instance.h" -lazyInstMgr::lazyInstMgr() { - _headerRegistry = new Registry( HeaderSchemaInit ); - _instanceTypes = new instanceTypes_t( 255 ); //NOTE arbitrary max of 255 chars for a type name +lazyInstMgr::lazyInstMgr() +{ + _headerRegistry = new Registry(HeaderSchemaInit); + _instanceTypes = new instanceTypes_t(255); //NOTE arbitrary max of 255 chars for a type name _lazyInstanceCount = 0; _loadedInstanceCount = 0; _longestTypeNameLen = 0; _mainRegistry = 0; _errors = new ErrorDescriptor(); - _ima = new instMgrAdapter( this ); + _ima = new instMgrAdapter(this); } -lazyInstMgr::~lazyInstMgr() { +lazyInstMgr::~lazyInstMgr() +{ delete _headerRegistry; delete _errors; delete _ima; //loop over files, sections, instances; delete header instances lazyFileReaderVec_t::iterator fit = _files.begin(); - for( ; fit != _files.end(); ++fit ) { + for(; fit != _files.end(); ++fit) { delete *fit; } dataSectionReaderVec_t::iterator sit = _dataSections.begin(); - for( ; sit != _dataSections.end(); ++sit ) { + for(; sit != _dataSections.end(); ++sit) { delete *sit; } _instancesLoaded.clear(); _instanceStreamPos.clear(); } -sectionID lazyInstMgr::registerDataSection( lazyDataSectionReader * sreader ) { - _dataSections.push_back( sreader ); +sectionID lazyInstMgr::registerDataSection(lazyDataSectionReader *sreader) +{ + _dataSections.push_back(sreader); return _dataSections.size() - 1; } -void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) { +void lazyInstMgr::addLazyInstance(namedLazyInstance inst) +{ _lazyInstanceCount++; - assert( inst.loc.begin > 0 && inst.loc.instance > 0 ); - int len = strlen( inst.name ); - if( len > _longestTypeNameLen ) { + assert(inst.loc.begin > 0 && inst.loc.instance > 0); + int len = strlen(inst.name); + if(len > _longestTypeNameLen) { _longestTypeNameLen = len; _longestTypeName = inst.name; } - _instanceTypes->insert( inst.name, inst.loc.instance ); + _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? @@ -60,17 +64,17 @@ void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) { */ positionAndSection ps = inst.loc.section; ps <<= 48; - ps |= ( inst.loc.begin & 0xFFFFFFFFFFFFULL ); - _instanceStreamPos.insert( inst.loc.instance, ps ); + ps |= (inst.loc.begin & 0xFFFFFFFFFFFFULL); + _instanceStreamPos.insert(inst.loc.instance, ps); - if( inst.refs ) { - if( inst.refs->size() > 0 ) { + if(inst.refs) { + if(inst.refs->size() > 0) { //forward refs - _fwdInstanceRefs.insert( inst.loc.instance, *inst.refs ); + _fwdInstanceRefs.insert(inst.loc.instance, *inst.refs); instanceRefs::iterator it = inst.refs->begin(); - for( ; it != inst.refs->end(); ++it ) { + for(; it != inst.refs->end(); ++it) { //reverse refs - _revInstanceRefs.insert( *it, inst.loc.instance ); + _revInstanceRefs.insert(*it, inst.loc.instance); } } else { delete inst.refs; @@ -78,14 +82,15 @@ void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) { } } -unsigned long lazyInstMgr::getNumTypes() const { +unsigned long lazyInstMgr::getNumTypes() const +{ unsigned long n = 0 ; instanceTypes_t::cpair curr, end; end = _instanceTypes->end(); curr = _instanceTypes->begin(); - if( curr.value != 0 ) { + if(curr.value != 0) { n = 1; - while( curr.value != end.value ) { + while(curr.value != end.value) { n++; curr = _instanceTypes->next(); } @@ -93,56 +98,58 @@ unsigned long lazyInstMgr::getNumTypes() const { return n ; } -void lazyInstMgr::openFile( std::string fname ) { +void lazyInstMgr::openFile(std::string fname) +{ //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 ); + _files.push_back((lazyFileReader *) 0); ///FIXME end atomic op - lazyFileReader * lfr = new lazyFileReader( fname, this, i ); + 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, bool reSeek ) { - assert( _mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()." ); +SDAI_Application_instance *lazyInstMgr::loadInstance(instanceID id, bool reSeek) +{ + assert(_mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()."); std::streampos oldPos; positionAndSection ps; sectionID sid; - SDAI_Application_instance * inst = _instancesLoaded.find( id ); - if( inst ) { + SDAI_Application_instance *inst = _instancesLoaded.find(id); + if(inst) { return inst; } - instanceStreamPos_t::cvector * cv; - if( 0 != ( cv = _instanceStreamPos.find( id ) ) ) { - switch( cv->size() ) { + instanceStreamPos_t::cvector *cv; + if(0 != (cv = _instanceStreamPos.find(id))) { + switch(cv->size()) { case 0: std::cerr << "Instance #" << id << " not found in any section." << std::endl; break; case 1: long int off; - ps = cv->at( 0 ); + ps = cv->at(0); off = ps & 0xFFFFFFFFFFFFULL; sid = ps >> 48; - assert( _dataSections.size() > sid ); - if( reSeek ) { + assert(_dataSections.size() > sid); + if(reSeek) { oldPos = _dataSections[sid]->tellg(); } - inst = _dataSections[sid]->getRealInstance( _mainRegistry, off, id ); - if( reSeek ) { - _dataSections[sid]->seekg( oldPos ); + 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; break; } - if( !isNilSTEPentity( inst ) ) { - _instancesLoaded.insert( id, inst ); + if(!isNilSTEPentity(inst)) { + _instancesLoaded.insert(id, inst); _loadedInstanceCount++; - lazyRefs lr( this, inst ); + lazyRefs lr(this, inst); lazyRefs::referentInstances_t insts = lr.result(); } else { std::cerr << "Error loading instance #" << id << "." << std::endl; @@ -154,26 +161,27 @@ SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id, bool reSee } -instanceSet * lazyInstMgr::instanceDependencies( instanceID id ) { - instanceSet * checkedDependencies = new instanceSet(); +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 ); + 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() ); + 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() ); + 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()); } } diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 78444a756..63d12464e 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -21,7 +21,8 @@ class Registry; class instMgrAdapter; -class SC_LAZYFILE_EXPORT lazyInstMgr { +class SC_LAZYFILE_EXPORT lazyInstMgr +{ protected: /** multimap from instance number to instances that it refers to * \sa instanceRefs_pair @@ -40,7 +41,7 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { * \sa instanceType_pair * \sa instanceType_range */ - instanceTypes_t * _instanceTypes; + instanceTypes_t *_instanceTypes; /** map from instance number to instance pointer (loaded instances only) * \sa instancesLoaded_pair @@ -62,14 +63,14 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { lazyFileReaderVec_t _files; - Registry * _headerRegistry, * _mainRegistry; - ErrorDescriptor * _errors; + Registry *_headerRegistry, * _mainRegistry; + ErrorDescriptor *_errors; unsigned long _lazyInstanceCount, _loadedInstanceCount; int _longestTypeNameLen; std::string _longestTypeName; - instMgrAdapter * _ima; + instMgrAdapter *_ima; #ifdef _MSC_VER #pragma warning( pop ) @@ -78,88 +79,103 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { public: lazyInstMgr(); ~lazyInstMgr(); - void openFile( std::string fname ); + void openFile(std::string fname); - void addLazyInstance( namedLazyInstance inst ); - InstMgrBase * getAdapter() { - return ( InstMgrBase * ) _ima; + void addLazyInstance(namedLazyInstance inst); + InstMgrBase *getAdapter() + { + return (InstMgrBase *) _ima; } - instanceRefs_t * getFwdRefs() { + instanceRefs_t *getFwdRefs() + { return & _fwdInstanceRefs; } - instanceRefs_t * getRevRefs() { + instanceRefs_t *getRevRefs() + { return & _revInstanceRefs; } /// returns a vector containing the instances that match `type` - instanceTypes_t::cvector * getInstances( std::string type, bool caseSensitive = false ) { /*const*/ - if( !caseSensitive ) { + 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 ); + for(; it != type.end(); ++it) { + *it = toupper(*it); } } - return _instanceTypes->find( type.c_str() ); + return _instanceTypes->find(type.c_str()); } /// get the number of instances of a certain type - unsigned int countInstances( std::string type ) { - instanceTypes_t::cvector * v = _instanceTypes->find( type.c_str() ); - if( !v ) { + unsigned int countInstances(std::string type) + { + instanceTypes_t::cvector *v = _instanceTypes->find(type.c_str()); + if(!v) { return 0; } return v->size(); } - instancesLoaded_t * getHeaderInstances( fileID file ) { + instancesLoaded_t *getHeaderInstances(fileID file) + { return _files[file]->getHeaderInstances(); } /// get the number of instances that have been found in the open files. - unsigned long totalInstanceCount() const { + unsigned long totalInstanceCount() const + { return _lazyInstanceCount; } /// get the number of instances that are loaded. - unsigned long loadedInstanceCount() const { + unsigned long loadedInstanceCount() const + { return _loadedInstanceCount; } /// get the number of data sections that have been identified - unsigned int countDataSections() { + unsigned int countDataSections() + { return _dataSections.size(); } ///builds the registry using the given initFunct - const Registry * initRegistry( CF_init initFunct ) { - setRegistry( new Registry( initFunct ) ); + const Registry *initRegistry(CF_init initFunct) + { + setRegistry(new Registry(initFunct)); return _mainRegistry; } /// set the registry to one already initialized - void setRegistry( Registry * reg ) { - assert( _mainRegistry == 0 ); + void setRegistry(Registry *reg) + { + assert(_mainRegistry == 0); _mainRegistry = reg; } - const Registry * getHeaderRegistry() const { + const Registry *getHeaderRegistry() const + { return _headerRegistry; } - const Registry * getMainRegistry() const { + const Registry *getMainRegistry() const + { return _mainRegistry; } /// get the longest type name - const std::string & getLongestTypeName() const { + const std::string &getLongestTypeName() const + { return _longestTypeName; } /// get the number of types of instances. unsigned long getNumTypes() const; - sectionID registerDataSection( lazyDataSectionReader * sreader ); + sectionID registerDataSection(lazyDataSectionReader *sreader); - ErrorDescriptor * getErrorDesc() { + ErrorDescriptor *getErrorDesc() + { return _errors; } @@ -167,28 +183,30 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { * \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 ); + 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 ); + 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 ) { + 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 ); + positionAndSection ps = cv->at(0); //extract p, s, call long int off = ps & 0xFFFFFFFFFFFFULL; sectionID sid = ps >> 48; - return _dataSections[sid]->getType( off ); + return _dataSections[sid]->getType(off); } std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " not found." << std::endl; return 0; @@ -196,24 +214,24 @@ class SC_LAZYFILE_EXPORT lazyInstMgr { // TODO implement these - // add another schema to registry - //void addSchema( void ( *initFn )() ); + // add another schema to registry + //void addSchema( void ( *initFn )() ); - //list all instances that one instance depends on (recursive) - //std::vector instanceDependencies( instanceID id ); //set is faster? + //list all instances that one instance depends on (recursive) + //std::vector 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 notDependencies(...) + /* * the opposite of instanceDependencies() - all instances that are *not* dependencies of one particular instance + same as above, but with list of instances */ + //std::vector notDependencies(...) - //renumber instances so that they are numbered 1..N where N is the total number of instances - //void normalizeInstanceIds(); + //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(); + //find data that is repeated and eliminate, if possible + //void eliminateDuplicates(); - //tell instMgr to use instances from this section - //void useDataSection( sectionID id ); + //tell instMgr to use instances from this section + //void useDataSection( sectionID id ); // TODO support references from one file to another }; diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index 9e9df2070..d3f873c82 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -3,39 +3,40 @@ #include "lazyP21DataSectionReader.h" #include "lazyInstMgr.h" -lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, - std::streampos start, sectionID sid ): - lazyDataSectionReader( parent, file, start, sid ) { +lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, + std::streampos start, sectionID sid): + lazyDataSectionReader(parent, file, start, sid) +{ findSectionStart(); namedLazyInstance nl; - while( nl = nextInstance(), ( ( nl.loc.begin > 0 ) && ( nl.name != 0 ) ) ) { - parent->getInstMgr()->addLazyInstance( nl ); + 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 ) { + if(sectionReader::_error->severity() <= SEVERITY_WARNING) { + sectionReader::_error->PrintContents(std::cerr); + if(sectionReader::_error->severity() <= SEVERITY_INPUT_ERROR) { _error = true; - return; + return; } } - - if( !_file.good() ) { + + if(!_file.good()) { _error = true; return; } - if( nl.loc.instance == 0 ) { + if(nl.loc.instance == 0) { //check for ENDSEC; skipWS(); std::streampos pos = _file.tellg(); - if( _file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' + if(_file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' && _file.get() == 'S' && _file.get() == 'E' && _file.get() == 'C' - && ( skipWS(), _file.get() == ';' ) ) { + && (skipWS(), _file.get() == ';')) { _sectionEnd = _file.tellg(); } else { - _file.seekg( pos ); + _file.seekg(pos); char found[26] = { '\0' }; - _file.read( found, 25 ); + _file.read(found, 25); std::cerr << "expected 'ENDSEC;', found " << found << std::endl; _error = true; } @@ -44,26 +45,27 @@ lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std // part of readdata1 //if this changes, probably need to change sectionReader::getType() -const namedLazyInstance lazyP21DataSectionReader::nextInstance() { +const namedLazyInstance lazyP21DataSectionReader::nextInstance() +{ std::streampos end = -1; namedLazyInstance i; i.refs = 0; i.loc.begin = _file.tellg(); i.loc.instance = readInstanceNumber(); - if( ( _file.good() ) && ( i.loc.instance > 0 ) ) { + if((_file.good()) && (i.loc.instance > 0)) { skipWS(); i.loc.section = _sectionID; - i.name = getDelimitedKeyword( ";( /\\" ); - if( _file.good() ) { - end = seekInstanceEnd( & i.refs ); + i.name = getDelimitedKeyword(";( /\\"); + if(_file.good()) { + end = seekInstanceEnd(& i.refs); } } - if( ( i.loc.instance == 0 ) || ( !_file.good() ) || ( end == ( std::streampos ) - 1 ) ) { + if((i.loc.instance == 0) || (!_file.good()) || (end == (std::streampos) - 1)) { //invalid instance, so clear everything - _file.seekg( i.loc.begin ); + _file.seekg(i.loc.begin); i.loc.begin = -1; - if( i.refs ) { + if(i.refs) { delete i.refs; } i.name = 0; diff --git a/src/cllazyfile/lazyP21DataSectionReader.h b/src/cllazyfile/lazyP21DataSectionReader.h index 423679142..a666fdeb2 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.h +++ b/src/cllazyfile/lazyP21DataSectionReader.h @@ -6,13 +6,15 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { +class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader +{ protected: public: - lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); + lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); - void findSectionStart() { - _sectionStart = findNormalString( "DATA", true ); + void findSectionStart() + { + _sectionStart = findNormalString("DATA", true); } /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index cde0bc62b..b38f626a7 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -40,20 +40,21 @@ class SDAI_Application_instance; * 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) - */ +/* **** +* 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 instances 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 SC_LAZYFILE_EXPORT lazyRefs { +class SC_LAZYFILE_EXPORT lazyRefs +{ public: typedef std::set< instanceID > referentInstances_t; protected: @@ -65,121 +66,126 @@ class SC_LAZYFILE_EXPORT lazyRefs { #pragma warning( disable: 4251 ) #endif iaList_t _iaList; - lazyInstMgr * _lim; + lazyInstMgr *_lim; instanceID _id; refMap_t _refMap; referentInstances_t _referentInstances; - SDAI_Application_instance * _inst; + SDAI_Application_instance *_inst; #ifdef _MSC_VER #pragma warning( pop ) #endif - void checkAnInvAttr( const Inverse_attribute * ia ) { - const EntityDescriptor * ed; - const Registry * reg = _lim->getMainRegistry(); - ed = reg->FindEntity( ia->_inverted_entity_id ); - subtypesIterator subtypeIter( ed ); + 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 ); + edL.insert(ed); // 3b - use subtypeIter to add to edL - for( ; !subtypeIter.empty(); ++subtypeIter ) { - edL.insert( *subtypeIter ); + for(; !subtypeIter.empty(); ++subtypeIter) { + edL.insert(*subtypeIter); } //3c - for each item in both _refMap and edL, add it to _referentInstances - potentialReferentInsts( edL ); + potentialReferentInsts(edL); //3d - load each inst - iAstruct ias = invAttr( _inst, ia ); + iAstruct ias = invAttr(_inst, ia); referentInstances_t::iterator insts = _referentInstances.begin(); - for( ; insts != _referentInstances.end(); ++insts ) { - loadInstIFFreferent( *insts, ias, ia ); + 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 ) { + 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 ); + _inst->setInvAttr(ia, ias); + assert(invAttr(_inst, ia).a == ias.a); } - EntityAggregate * ea = ias.a; + EntityAggregate *ea = ias.a; //TODO check if duplicate - ea->AddNode( new EntityNode( rinst ) ); + ea->AddNode(new EntityNode(rinst)); } else { - SDAI_Application_instance * ai = ias.i; - if( !ai ) { + SDAI_Application_instance *ai = ias.i; + if(!ai) { ias.i = rinst; - _inst->setInvAttr( ia, ias ); - } else if( ai->GetFileId() != (int)inst ) { + _inst->setInvAttr(ia, ias); + } else if(ai->GetFileId() != (int)inst) { std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->eDesc->Name(); - std::cerr << " and " << ai << ", #" << ai->GetFileId() <<"=" << ai->eDesc->Name() << ") refer to inst "; + std::cerr << " and " << ai << ", #" << ai->GetFileId() << "=" << ai->eDesc->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 ) { + 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 ) { + 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 ); + int rindex = attrIndex(referrer, ia->_inverted_attr_id, ia->_inverted_entity_id); STEPattribute sa = referrer->attributes[ rindex ]; - assert( sa.getADesc()->BaseType() == ENTITY_TYPE ); + assert(sa.getADesc()->BaseType() == ENTITY_TYPE); bool found = false; - if( sa.getADesc()->IsAggrType() ) { + 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 ) { + 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(); + en = (EntityNode *) en->NextNode(); } } else { //single instance - assert( sa.getADesc()->NonRefType() == ENTITY_TYPE ); - if( sa.Entity() == _inst ) { + assert(sa.getADesc()->NonRefType() == ENTITY_TYPE); + if(sa.Entity() == _inst) { found = true; } } - if( !found ) { + if(!found) { std::cerr << "inst #" << _inst->FileId() << " not found in #" << referrer->FileId(); std::cerr << ", attr #" << rindex << " [contents: "; - referrer->STEPwrite( std::cerr ); + 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++ ) { + 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 ) ) { + 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 */ ) { + 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 ) { + while(iai != map.end()) { + if(iai->first == ia) { return iai->second; } ++iai; @@ -193,13 +199,14 @@ class SC_LAZYFILE_EXPORT lazyRefs { /** 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 ) { + void potentialReferentInsts(edList_t &edL) + { refMap_t::pair kv = _refMap.begin(); - while( kv.value != 0 ) { + 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 ); + for(; edi != edL.end(); ++edi) { + if(0 == strcasecmp(kv.value->c_str(), (*edi)->Name())) { + _referentInstances.insert(kv.key); break; } } @@ -209,91 +216,99 @@ class SC_LAZYFILE_EXPORT lazyRefs { ///find any inverse attributes, put in `iaList` /// attrs not necessarily in order! - void getInverseAttrs( const EntityDescriptor * ed, iaList_t & iaList ) { + void getInverseAttrs(const EntityDescriptor *ed, iaList_t &iaList) + { iaList.clear(); - supertypesIterator supersIter( ed ); - const Inverse_attribute * iAttr; - for( ; !supersIter.empty(); ++supersIter ) { + 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 ); + 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 ); + 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() ) { + 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 ) ); + 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 ) { + lazyRefs(lazyInstMgr *lmgr): _lim(lmgr), _id(0) + { _iaList.clear(); } - lazyRefs( lazyInstMgr * lmgr, SDAI_Application_instance * ai ): _lim( lmgr ), _id( 0 ) { + lazyRefs(lazyInstMgr *lmgr, SDAI_Application_instance *ai): _lim(lmgr), _id(0) + { _iaList.clear(); - init( 0, ai ); + init(0, ai); } - lazyRefs( lazyInstMgr * lmgr, instanceID iid ): _lim( lmgr ) { + lazyRefs(lazyInstMgr *lmgr, instanceID iid): _lim(lmgr) + { _iaList.clear(); - init( iid, 0 ); + init(iid, 0); } - ~lazyRefs() { + ~lazyRefs() + { // delete strings in refMap - _refMap.clear( true ); + _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 ) { + 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 ); + if(!ai) { + _inst = _lim->loadInstance(iid); _id = iid; } else { _inst = ai; _id = _inst->GetFileId(); } - _refMap.clear( true ); + _refMap.clear(true); // 1. find inverse attrs with recursion - getInverseAttrs( ai->eDesc, _iaList ); + getInverseAttrs(ai->eDesc, _iaList); //2. find reverse refs, map id to type (stop if there are no inverse attrs or no refs) - if( _iaList.size() == 0 || !mapRefsToTypes() ) { + if(_iaList.size() == 0 || !mapRefsToTypes()) { return; } iaList_t::iterator iai = _iaList.begin(); - for( ; iai != _iaList.end(); ++iai ) { + for(; iai != _iaList.end(); ++iai) { // 3. for each IA, ... - checkAnInvAttr( *iai ); + checkAnInvAttr(*iai); } } - referentInstances_t result() { + referentInstances_t result() + { return _referentInstances; } diff --git a/src/cllazyfile/lazyTypes.h b/src/cllazyfile/lazyTypes.h index 0ba2aa671..35bcc1ba2 100644 --- a/src/cllazyfile/lazyTypes.h +++ b/src/cllazyfile/lazyTypes.h @@ -65,8 +65,8 @@ typedef struct { /// used when populating the instance type map \sa lazyInstMgr::_instanceTypeMMap typedef struct { lazyInstanceLoc loc; - const char * name; - instanceRefs * refs; + const char *name; + instanceRefs *refs; } namedLazyInstance; // instanceRefs - map between an instanceID and instances that refer to it diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 71786bb59..b01a13fa2 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -9,31 +9,33 @@ #endif //NO_REGISTRY -void fileInfo( lazyInstMgr & mgr, fileID id ) { - instancesLoaded_t * headerInsts = mgr.getHeaderInstances( id ); - SDAI_Application_instance * hdrInst; - hdrInst = headerInsts->find( 3 ); - if( ( hdrInst != 0 ) && ( hdrInst->STEPfile_id == 3 ) ) { - SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( hdrInst ); - if( fs ) { +void fileInfo(lazyInstMgr &mgr, fileID id) +{ + instancesLoaded_t *headerInsts = mgr.getHeaderInstances(id); + SDAI_Application_instance *hdrInst; + hdrInst = headerInsts->find(3); + if((hdrInst != 0) && (hdrInst->STEPfile_id == 3)) { + SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(hdrInst); + if(fs) { StringAggregate_ptr p = fs->schema_identifiers_(); - StringNode * sn = ( StringNode * ) p->GetHead(); + StringNode *sn = (StringNode *) p->GetHead(); std::cout << "Schema(s): "; - while( sn ) { + while(sn) { std::cout << sn->value.c_str() << " "; - sn = ( StringNode * ) sn->NextNode(); + sn = (StringNode *) sn->NextNode(); } std::cout << std::endl; } } } -void countTypeInstances( lazyInstMgr & mgr, std::string type ) { - int count = mgr.countInstances( type ); +void countTypeInstances(lazyInstMgr &mgr, std::string type) +{ + int count = mgr.countInstances(type); std::cout << type << " instances: " << count; - if( count ) { + if(count) { instanceID ex; - ex = ( * mgr.getInstances( type ) )[ 0 ]; + ex = (* mgr.getInstances(type))[ 0 ]; std::cout << " -- example: #" << ex; } std::cout << std::endl; @@ -41,18 +43,19 @@ void countTypeInstances( lazyInstMgr & mgr, std::string type ) { } /// Called twice by printRefs. Returns the instanceID of one instance that has a reference. -instanceID printRefs1( instanceRefs_t * refs, bool forward ) { - const char * d1 = forward ? "forward" : "reverse"; - const char * d2 = forward ? " refers to " : " is referred to by "; +instanceID printRefs1(instanceRefs_t *refs, bool forward) +{ + const char *d1 = forward ? "forward" : "reverse"; + const char *d2 = forward ? " refers to " : " is referred to by "; instanceID id = 0; instanceRefs_t::cpair p = refs->begin(); - instanceRefs_t::cvector * v = p.value; - if( !v ) { + instanceRefs_t::cvector *v = p.value; + if(!v) { std::cout << "No " << d1 << " references" << std::endl; } else { - instanceRefs_t::cvector::const_iterator it( v->begin() ), end( v->end() ); + instanceRefs_t::cvector::const_iterator it(v->begin()), end(v->end()); std::cout << "Example of " << d1 << " references - Instance #" << p.key << d2 << v->size() << " other instances: "; - for( ; it != end; it++ ) { + for(; it != end; it++) { std::cout << *it << " "; } std::cout << std::endl; @@ -62,34 +65,36 @@ instanceID printRefs1( instanceRefs_t * refs, bool forward ) { } ///prints references; returns the instanceID for one instance that has a forward reference -instanceID printRefs( lazyInstMgr & mgr ) { +instanceID printRefs(lazyInstMgr &mgr) +{ instanceID id; std::cout << "\nReferences\n==============\n"; - id = printRefs1( mgr.getFwdRefs(), true ); - printRefs1( mgr.getRevRefs(), false ); + id = printRefs1(mgr.getFwdRefs(), true); + printRefs1(mgr.getRevRefs(), false); std::cout << std::endl; return id; } /// prints dependencies of an instance -void printDeps( lazyInstMgr & mgr ) { +void printDeps(lazyInstMgr &mgr) +{ const int displayInstances = 10; - instanceRefs_t * refs = mgr.getFwdRefs(); + 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() ); + 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++ ) { + for(i = 0; it != end && i < displayInstances; it++, i++) { std::cout << *it << " "; } - if( dependencies->size() > displayInstances ) { + if(dependencies->size() > displayInstances) { std::cout << ".... (Displaying only " << displayInstances << " instances) "; } @@ -100,24 +105,25 @@ void printDeps( lazyInstMgr & mgr ) { } ///prints info about a complex instance -void dumpComplexInst( STEPcomplex * c ) { +void dumpComplexInst(STEPcomplex *c) +{ int depth = 0; - if( c ) { + 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! // SDAI_Application_instance * attr = ( SDAI_Application_instance * ) *it; - STEPcomplex * complex = c->head; - while( complex ) { - if( complex->IsComplex() ) { + STEPcomplex *complex = c->head; + while(complex) { + if(complex->IsComplex()) { std::cout << "Complex component " << complex->eDesc->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 ) { + SDAI_Application_instance *ai = dynamic_cast< SDAI_Application_instance * >(complex); + if(ai) { std::cout << "non-complex component at depth " << depth << ", " << ai->eDesc->Name() << std::endl; } else { std::cout << "unknown component at depth " << depth << ": " << complex << std::endl; @@ -129,60 +135,61 @@ void dumpComplexInst( STEPcomplex * c ) { } } -int main( int argc, char ** argv ) { - if( argc != 2 ) { +int main(int argc, char **argv) +{ + if(argc != 2) { std::cerr << "Expected one argument, given " << argc - 1 << ". Exiting." << std::endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - lazyInstMgr * mgr = new lazyInstMgr; + lazyInstMgr *mgr = new lazyInstMgr; #ifndef NO_REGISTRY //init schema - mgr->initRegistry( SchemaInit ); + mgr->initRegistry(SchemaInit); #endif //NO_REGISTRY instanceID instWithRef; - benchmark stats( "================ p21 lazy load: scanning the file ================\n" ); - mgr->openFile( argv[1] ); + benchmark stats("================ p21 lazy load: scanning the file ================\n"); + mgr->openFile(argv[1]); stats.stop(); benchVals scanStats = stats.get(); stats.out(); - stats.reset( "================ p21 lazy load: gathering statistics ================\n" ); + stats.reset("================ p21 lazy load: gathering statistics ================\n"); int instances = mgr->totalInstanceCount(); - std::cout << "Total instances: " << instances << " (" << ( float )( scanStats.userMilliseconds * 1000 ) / instances << "us per instance, "; - std::cout << ( float )( scanStats.physMemKB * 1000 ) / instances << " bytes per instance)" << std::endl << std::endl; + std::cout << "Total instances: " << instances << " (" << (float)(scanStats.userMilliseconds * 1000) / instances << "us per instance, "; + std::cout << (float)(scanStats.physMemKB * 1000) / instances << " bytes per instance)" << std::endl << std::endl; - fileInfo( *mgr, 0 ); + fileInfo(*mgr, 0); //these are just common types - countTypeInstances( *mgr, "CARTESIAN_POINT" ); - countTypeInstances( *mgr, "POSITIVE_LENGTH_MEASURE" ); - countTypeInstances( *mgr, "VERTEX_POINT" ); + countTypeInstances(*mgr, "CARTESIAN_POINT"); + countTypeInstances(*mgr, "POSITIVE_LENGTH_MEASURE"); + countTypeInstances(*mgr, "VERTEX_POINT"); //complex instances std::cout << "Complex"; - countTypeInstances( *mgr, "" ); + countTypeInstances(*mgr, ""); std::cout << "Longest type name: " << mgr->getLongestTypeName() << std::endl; // std::cout << "Total types: " << mgr->getNumTypes() << std::endl; - instWithRef = printRefs( *mgr ); - printDeps( *mgr ); + instWithRef = printRefs(*mgr); + printDeps(*mgr); #ifndef NO_REGISTRY - if( instWithRef ) { + if(instWithRef) { std::cout << "Number of data section instances fully loaded: " << mgr->loadedInstanceCount() << std::endl; std::cout << "Loading #" << instWithRef; - SDAI_Application_instance * inst = mgr->loadInstance( instWithRef ); + SDAI_Application_instance *inst = mgr->loadInstance(instWithRef); std::cout << " which is of type " << inst->EntityName() << std::endl; std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } - instanceTypes_t::cvector * complexInsts = mgr->getInstances( "" ); - if( complexInsts && complexInsts->size() > 0 ) { - std::cout << "loading complex instance #" << complexInsts->at( 0 ) << "." << std::endl; - STEPcomplex * c = dynamic_cast( mgr->loadInstance( complexInsts->at( 0 ) ) ); - dumpComplexInst( c ); + instanceTypes_t::cvector *complexInsts = mgr->getInstances(""); + if(complexInsts && complexInsts->size() > 0) { + std::cout << "loading complex instance #" << complexInsts->at(0) << "." << std::endl; + STEPcomplex *c = dynamic_cast(mgr->loadInstance(complexInsts->at(0))); + dumpComplexInst(c); std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } #else @@ -190,7 +197,7 @@ int main( int argc, char ** argv ) { #endif //NO_REGISTRY stats.out(); - stats.reset( "================ p21 lazy load: freeing memory ================\n" ); + stats.reset("================ p21 lazy load: freeing memory ================\n"); delete mgr; //stats will print from its destructor } diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index bcb78ac83..e1f3f7fff 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -8,53 +8,56 @@ #include "judyL2Array.h" -void p21HeaderSectionReader::findSectionStart() { - _sectionStart = findNormalString( "HEADER", true ); - assert( _file.is_open() && _file.good() ); +void p21HeaderSectionReader::findSectionStart() +{ + _sectionStart = findNormalString("HEADER", true); + assert(_file.is_open() && _file.good()); } -p21HeaderSectionReader::p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, - std::streampos start, sectionID sid ): - headerSectionReader( parent, file, start, sid ) { +p21HeaderSectionReader::p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, + std::streampos start, sectionID sid): + headerSectionReader(parent, file, start, sid) +{ findSectionStart(); findSectionEnd(); - _file.seekg( _sectionStart ); + _file.seekg(_sectionStart); namedLazyInstance nl; - while( nl = nextInstance(), ( nl.loc.begin > 0 ) ) { + while(nl = nextInstance(), (nl.loc.begin > 0)) { std::streampos pos = _file.tellg(); - _headerInstances->insert( nl.loc.instance, getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true ) ); - _file.seekg( pos ); //reset stream position for next call to nextInstance() + _headerInstances->insert(nl.loc.instance, getRealInstance(_lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true)); + _file.seekg(pos); //reset stream position for next call to nextInstance() } - _file.seekg( _sectionEnd ); + _file.seekg(_sectionEnd); } // part of readdata1 -const namedLazyInstance p21HeaderSectionReader::nextInstance() { +const namedLazyInstance p21HeaderSectionReader::nextInstance() +{ namedLazyInstance i; static instanceID nextFreeInstance = 4; // 1-3 are reserved per 10303-21 i.loc.begin = _file.tellg(); i.loc.section = _sectionID; skipWS(); - if( i.loc.begin <= 0 ) { + if(i.loc.begin <= 0) { i.name = 0; } else { - i.name = getDelimitedKeyword( ";( /\\" ); + i.name = getDelimitedKeyword(";( /\\"); - if( 0 == strcmp( "FILE_DESCRIPTION", i.name ) ) { + if(0 == strcmp("FILE_DESCRIPTION", i.name)) { i.loc.instance = 1; - } else if( 0 == strcmp( "FILE_NAME", i.name ) ) { + } else if(0 == strcmp("FILE_NAME", i.name)) { i.loc.instance = 2; - } else if( 0 == strcmp( "FILE_SCHEMA", i.name ) ) { + } else if(0 == strcmp("FILE_SCHEMA", i.name)) { i.loc.instance = 3; } else { i.loc.instance = nextFreeInstance++; } - assert( strlen( i.name ) > 0 ); + assert(strlen(i.name) > 0); - std::streampos end = seekInstanceEnd( 0 ); //no references in file header - if( ( (signed long int)end == -1 ) || ( end >= _sectionEnd ) ) { + std::streampos end = seekInstanceEnd(0); //no references in file header + if(((signed long int)end == -1) || (end >= _sectionEnd)) { //invalid instance, so clear everything i.loc.begin = -1; i.name = 0; diff --git a/src/cllazyfile/p21HeaderSectionReader.h b/src/cllazyfile/p21HeaderSectionReader.h index b5ce04948..5a4aea3ca 100644 --- a/src/cllazyfile/p21HeaderSectionReader.h +++ b/src/cllazyfile/p21HeaderSectionReader.h @@ -5,9 +5,10 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { +class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader +{ public: - p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); + p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); void findSectionStart(); /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 0384efd4c..cf38bb3c5 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -20,59 +20,61 @@ #include "current_function.hpp" -sectionReader::sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): - _lazyFile( parent ), _file( file ), _sectionStart( start ), _sectionID( sid ) { +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(); } -std::streampos sectionReader::findNormalString( const std::string & str, bool semicolon ) { +std::streampos sectionReader::findNormalString(const std::string &str, bool semicolon) +{ std::streampos found = -1, startPos = _file.tellg(), nextTry = startPos; int i = 0, l = str.length(); char c; //i is reset every time a character doesn't match; if i == l, this means that we've found the entire string - while( i < l || semicolon ) { + while(i < l || semicolon) { skipWS(); c = _file.get(); - if( ( i == l ) && ( semicolon ) ) { - if( c == ';' ) { + if((i == l) && (semicolon)) { + if(c == ';') { break; } else { i = 0; - _file.seekg( nextTry ); + _file.seekg(nextTry); continue; } } - if( c == '\'' ) { + if(c == '\'') { //push past string - _file.seekg( _file.tellg() - std::streampos(1) ); - GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); + _file.seekg(_file.tellg() - std::streampos(1)); + GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); } - if( ( c == '/' ) && ( _file.peek() == '*' ) ) { + if((c == '/') && (_file.peek() == '*')) { //push past comment - findNormalString( "*/" ); + findNormalString("*/"); } - if( str[i] == c ) { + if(str[i] == c) { i++; - if( i == 1 ) { + if(i == 1) { nextTry = _file.tellg(); } } else { - if( !_file.good() ) { + if(!_file.good()) { break; } - if( i >= 1 ) { - _file.seekg( nextTry ); + if(i >= 1) { + _file.seekg(nextTry); } i = 0; } } - if( i == l ) { + if(i == l) { found = _file.tellg(); } - if( _file.is_open() && _file.good() ) { + if(_file.is_open() && _file.good()) { return found; } else { return -1; @@ -82,28 +84,29 @@ 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 ) { +const char *sectionReader::getDelimitedKeyword(const char *delimiters) +{ static std::string str; char c; str.clear(); - str.reserve( 100 ); + str.reserve(100); skipWS(); - while( c = _file.get(), _file.good() ) { - if( c == '-' || c == '_' || isupper( c ) || isdigit( c ) || - ( c == '!' && str.length() == 0 ) ) { - str.append( 1, c ); - } else if( ( c == '/' ) && ( _file.peek() == '*' ) && ( str.length() == 0 ) ) { + while(c = _file.get(), _file.good()) { + if(c == '-' || c == '_' || isupper(c) || isdigit(c) || + (c == '!' && str.length() == 0)) { + str.append(1, c); + } else if((c == '/') && (_file.peek() == '*') && (str.length() == 0)) { //push past comment - findNormalString( "*/" ); + findNormalString("*/"); skipWS(); continue; } else { - _file.putback( c ); + _file.putback(c); break; } } c = _file.peek(); - if( !strchr( delimiters, c ) ) { + if(!strchr(delimiters, c)) { std::cerr << SC_CURRENT_FUNCTION << ": missing delimiter. Found " << c << ", expected one of " << delimiters << " at end of keyword " << str << ". File offset: " << _file.tellg() << std::endl; abort(); } @@ -113,49 +116,50 @@ const char * sectionReader::getDelimitedKeyword( const char * delimiters ) { /// search forward in the file for the end of the instance. Start position should /// be the opening parenthesis; otherwise, it is likely to fail. ///NOTE *must* check return value! -std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { +std::streampos sectionReader::seekInstanceEnd(instanceRefs **refs) +{ char c; int parenDepth = 0; - while( c = _file.get(), _file.good() ) { - switch( c ) { + while(c = _file.get(), _file.good()) { + switch(c) { case '(': parenDepth++; break; case '/': - if( _file.peek() == '*' ) { - findNormalString( "*/" ); + if(_file.peek() == '*') { + findNormalString("*/"); } else { return -1; } break; case '\'': - _file.seekg( _file.tellg() - std::streampos(1) ); - GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); + _file.seekg(_file.tellg() - std::streampos(1)); + GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); break; case '=': return -1; case '#': skipWS(); - if( isdigit( _file.peek() ) ) { - if( refs != 0 ) { - if( ! * refs ) { + if(isdigit(_file.peek())) { + if(refs != 0) { + if(! * refs) { *refs = new std::vector< instanceID >; } instanceID n; _file >> n; - ( * refs )->push_back( n ); + (* refs)->push_back(n); } } else { return -1; } break; case ')': - if( --parenDepth == 0 ) { + if(--parenDepth == 0) { skipWS(); - if( _file.get() == ';' ) { + if(_file.get() == ';') { return _file.tellg(); } else { - _file.seekg( _file.tellg() - std::streampos(1) ); + _file.seekg(_file.tellg() - std::streampos(1)); } } default: @@ -168,14 +172,16 @@ std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { // new memory: 673340kb; User CPU time: 29890ms; System CPU time: 11650ms } -void sectionReader::locateAllInstances() { +void sectionReader::locateAllInstances() +{ namedLazyInstance inst; - while( inst = nextInstance(), ( _file.good() ) && ( inst.loc.begin > 0 ) ) { - _lazyFile->getInstMgr()->addLazyInstance( inst ); + while(inst = nextInstance(), (_file.good()) && (inst.loc.begin > 0)) { + _lazyFile->getInstMgr()->addLazyInstance(inst); } } -instanceID sectionReader::readInstanceNumber() { +instanceID sectionReader::readInstanceNumber() +{ char c; size_t digits = 0; instanceID id = 0; @@ -183,64 +189,64 @@ instanceID sectionReader::readInstanceNumber() { //find instance number ("# nnnn ="), where ' ' is any whitespace found by isspace() skipWS(); c = _file.get(); - if( ( c == '/' ) && ( _file.peek() == '*' ) ) { - findNormalString( "*/" ); + if((c == '/') && (_file.peek() == '*')) { + findNormalString("*/"); } else { - _file.seekg( _file.tellg() - std::streampos(1) ); + _file.seekg(_file.tellg() - std::streampos(1)); } skipWS(); c = _file.get(); - if( c != '#' ) { + if(c != '#') { return 0; } skipWS(); // The largest instance ID yet supported is the maximum value of unsigned long long int - assert( std::numeric_limits::max() <= std::numeric_limits::max() ); + assert(std::numeric_limits::max() <= std::numeric_limits::max()); size_t instanceIDLength = std::numeric_limits::digits10 + 1; - char * buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character - + char *buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character + std::stringstream errorMsg; do { c = _file.get(); - if( isdigit( c ) ) { + if(isdigit(c)) { buffer[ digits ] = c; //copy the character into the buffer digits++; } else { - _file.seekg( _file.tellg() - std::streampos(1) ); + _file.seekg(_file.tellg() - std::streampos(1)); break; } - if( digits > instanceIDLength ) { + 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() ); + _error->GreaterSeverity(SEVERITY_INPUT_ERROR); + _error->UserMsg("A very large instance ID encountered"); + _error->DetailMsg(errorMsg.str()); delete buffer; - return 0; + return 0; } - } while( _file.good() ); + } while(_file.good()); buffer[ digits ] = '\0'; //Append the terminating character skipWS(); - if( _file.good() && ( digits > 0 ) && ( _file.get() == '=' ) ) { - id = strtoull( buffer, NULL, 10); - if( id == std::numeric_limits::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. + if(_file.good() && (digits > 0) && (_file.get() == '=')) { + id = strtoull(buffer, NULL, 10); + if(id == std::numeric_limits::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() ); + _error->GreaterSeverity(SEVERITY_INPUT_ERROR); + _error->UserMsg("A very large instance ID encountered"); + _error->DetailMsg(errorMsg.str()); } - assert( id > 0 ); + assert(id > 0); } delete [] buffer; return id; @@ -249,24 +255,25 @@ instanceID sectionReader::readInstanceNumber() { /** 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 ) { +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 + const char *tName = 0, * sName = 0; //these are necessary since typeName and schName are const std::string comment; Severity sev = SEVERITY_NULL; - SDAI_Application_instance * inst = 0; + SDAI_Application_instance *inst = 0; tName = typeName.c_str(); - if( schName.size() > 0 ) { + if(schName.size() > 0) { sName = schName.c_str(); - } else if( !header ) { - SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( _lazyFile->getHeaderInstances()->find( 3 ) ); - if( fs ) { - StringNode * sn = ( StringNode * ) fs->schema_identifiers_()->GetHead(); - if( sn ) { + } else if(!header) { + SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(_lazyFile->getHeaderInstances()->find(3)); + if(fs) { + StringNode *sn = (StringNode *) fs->schema_identifiers_()->GetHead(); + if(sn) { sName = sn->value.c_str(); - if( sn->NextNode() ) { + if(sn->NextNode()) { std::cerr << "Warning - multiple schema names found. Only searching with first one." << std::endl; } } @@ -275,78 +282,79 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg } } - _file.seekg( begin ); + _file.seekg(begin); skipWS(); - ReadTokenSeparator( _file, &comment ); - if( !header ) { - findNormalString( "=" ); + ReadTokenSeparator(_file, &comment); + if(!header) { + findNormalString("="); } skipWS(); - ReadTokenSeparator( _file, &comment ); + ReadTokenSeparator(_file, &comment); c = _file.peek(); - switch( c ) { + switch(c) { case '&': std::cerr << "Can't handle scope instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; // sev = CreateScopeInstances( in, &scopelist ); break; case '(': - inst = CreateSubSuperInstance( reg, instance, sev ); + inst = CreateSubSuperInstance(reg, instance, sev); break; case '!': std::cerr << "Can't handle user-defined instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; break; default: - if( ( !header ) && ( typeName.size() == 0 ) ) { - tName = getDelimitedKeyword( ";( /\\" ); + if((!header) && (typeName.size() == 0)) { + tName = getDelimitedKeyword(";( /\\"); } - inst = reg->ObjCreate( tName, sName ); + inst = reg->ObjCreate(tName, sName); break; } - if( !isNilSTEPentity( inst ) ) { - if( !comment.empty() ) { - inst->AddP21Comment( comment ); + if(!isNilSTEPentity(inst)) { + if(!comment.empty()) { + inst->AddP21Comment(comment); } - assert( inst->eDesc ); - _file.seekg( begin ); - findNormalString( "(" ); - _file.seekg( _file.tellg() - std::streampos(1) ); - sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false ); + assert(inst->eDesc); + _file.seekg(begin); + findNormalString("("); + _file.seekg(_file.tellg() - std::streampos(1)); + sev = inst->STEPread(instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false); //TODO do something with 'sev' inst->InitIAttrs(); } return inst; } -STEPcomplex * sectionReader::CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & ) { +STEPcomplex *sectionReader::CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &) +{ std::string buf; ErrorDescriptor err; std::vector typeNames; _file.get(); //move past the first '(' skipWS(); - while( _file.good() && ( _file.peek() != ')' ) ) { - typeNames.push_back( new std::string( getDelimitedKeyword( ";( /\\\n" ) ) ); - if( typeNames.back()->empty() ) { + while(_file.good() && (_file.peek() != ')')) { + typeNames.push_back(new std::string(getDelimitedKeyword(";( /\\\n"))); + if(typeNames.back()->empty()) { delete typeNames.back(); typeNames.pop_back(); } else { - SkipSimpleRecord( _file, buf, &err ); //exactly what does this do? if it doesn't count parenthesis, it probably should + SkipSimpleRecord(_file, buf, &err); //exactly what does this do? if it doesn't count parenthesis, it probably should buf.clear(); } skipWS(); - if( _file.peek() != ')' ) { + if(_file.peek() != ')') { // do something } } // STEPComplex needs an array of strings or of char*. construct the latter using c_str() on all strings in the vector //FIXME: STEPComplex ctor should accept std::vector ? const int s = typeNames.size(); - const char ** names = new const char * [ s + 1 ]; + const char **names = new const char *[ s + 1 ]; names[ s ] = 0; - for( int i = 0; i < s; i++ ) { + for(int i = 0; i < s; i++) { names[ i ] = typeNames[i]->c_str(); } //TODO still need the schema name - STEPcomplex * sc = new STEPcomplex( ( const_cast( reg ) ), names, ( int ) fileid /*, schnm*/ ); + STEPcomplex *sc = new STEPcomplex((const_cast(reg)), names, (int) fileid /*, schnm*/); delete[] names; //TODO also delete contents of typeNames! return sc; diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index c6a64b55a..c6508669d 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -14,15 +14,16 @@ class lazyFileReader; class ErrorDescriptor; class Registry; -class SC_LAZYFILE_EXPORT sectionReader { +class SC_LAZYFILE_EXPORT sectionReader +{ protected: //protected data members - lazyFileReader * _lazyFile; + lazyFileReader *_lazyFile; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::ifstream & _file; + std::ifstream &_file; std::streampos _sectionStart, ///< the start of this section as reported by tellg() _sectionEnd; ///< the end of this section as reported by tellg() @@ -31,56 +32,61 @@ class SC_LAZYFILE_EXPORT sectionReader { #endif unsigned long _totalInstances; - ErrorDescriptor * _error; + ErrorDescriptor *_error; sectionID _sectionID; fileID _fileID; // protected member functions - sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); + sectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); /** Find a string, ignoring occurrences in comments or Part 21 strings (i.e. 'string with \S\' control directive' ) * \param str string to find * \param semicolon if true, 'str' must be followed by a semicolon, possibly preceded by whitespace. * \returns the position of the end of the found string */ - std::streampos findNormalString( const std::string & str, bool semicolon = false ); + std::streampos findNormalString(const std::string &str, bool semicolon = false); /** Get a keyword ending with one of delimiters. */ - const char * getDelimitedKeyword( const char * delimiters ); + const char *getDelimitedKeyword(const char *delimiters); /** Seek to the end of the current instance */ - std::streampos seekInstanceEnd( instanceRefs ** refs ); + std::streampos seekInstanceEnd(instanceRefs **refs); /// operator>> is very slow?! - inline void skipWS() { - while( isspace( _file.peek() ) && _file.good() ) { - _file.ignore( 1 ); + inline void skipWS() + { + while(isspace(_file.peek()) && _file.good()) { + _file.ignore(1); } } - STEPcomplex * CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & sev ); + STEPcomplex *CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &sev); public: - SDAI_Application_instance * getRealInstance( const Registry * reg, long int begin, instanceID instance, - const std::string & typeName = "", const std::string & schName = "", bool header = false ); + SDAI_Application_instance *getRealInstance(const Registry *reg, long int begin, instanceID instance, + const std::string &typeName = "", const std::string &schName = "", bool header = false); - sectionID ID() const { + sectionID ID() const + { return _sectionID; } virtual void findSectionStart() = 0; - void findSectionEnd() { - _sectionEnd = findNormalString( "ENDSEC", true ); + void findSectionEnd() + { + _sectionEnd = findNormalString("ENDSEC", true); } - std::streampos sectionStart() const { + std::streampos sectionStart() const + { return _sectionStart; } - std::streampos sectionEnd() const { + std::streampos sectionEnd() const + { return _sectionEnd; } @@ -91,22 +97,25 @@ class SC_LAZYFILE_EXPORT sectionReader { /** 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 ) { + const char *getType(long int offset) + { + if(offset <= 0) { return 0; } - _file.seekg( offset ); + _file.seekg(offset); readInstanceNumber(); skipWS(); - return getDelimitedKeyword( ";( /\\" ); + return getDelimitedKeyword(";( /\\"); } instanceID readInstanceNumber(); - void seekg( std::streampos pos ) { - _file.seekg( pos ); + void seekg(std::streampos pos) + { + _file.seekg(pos); } - std::streampos tellg() { + std::streampos tellg() + { return _file.tellg(); } }; diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 2e5eb490f..11ddde52a 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -15,55 +15,58 @@ /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ -const TypeDescriptor * const t_sdaiINTEGER = new TypeDescriptor( "INTEGER", sdaiINTEGER, 0, "INTEGER" ); -const TypeDescriptor * const t_sdaiREAL = new TypeDescriptor( "REAL", sdaiREAL, 0, "Real" ); -const TypeDescriptor * const t_sdaiNUMBER = new TypeDescriptor( "NUMBER", sdaiNUMBER, 0, "Number" ); -const TypeDescriptor * const t_sdaiSTRING = new TypeDescriptor( "STRING", sdaiSTRING, 0, "String" ); -const TypeDescriptor * const t_sdaiBINARY = new TypeDescriptor( "BINARY", sdaiBINARY, 0, "Binary" ); -const TypeDescriptor * const t_sdaiBOOLEAN = new TypeDescriptor( "BOOLEAN", sdaiBOOLEAN, 0, "Boolean" ); -const TypeDescriptor * const t_sdaiLOGICAL = new TypeDescriptor( "LOGICAL", sdaiLOGICAL, 0, "Logical" ); - -static int uniqueNames( const char *, const SchRename * ); - -Registry::Registry( CF_init initFunct ) - : col( 0 ), entity_cnt( 0 ), all_ents_cnt( 0 ) { - - primordialSwamp = SC_HASHcreate( 1000 ); - active_schemas = SC_HASHcreate( 10 ); - active_types = SC_HASHcreate( 100 ); - - initFunct( *this ); - SC_HASHlistinit( active_types, &cur_type ); - SC_HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur's - SC_HASHlistinit( active_schemas, &cur_schema ); +const TypeDescriptor *const t_sdaiINTEGER = new TypeDescriptor("INTEGER", sdaiINTEGER, 0, "INTEGER"); +const TypeDescriptor *const t_sdaiREAL = new TypeDescriptor("REAL", sdaiREAL, 0, "Real"); +const TypeDescriptor *const t_sdaiNUMBER = new TypeDescriptor("NUMBER", sdaiNUMBER, 0, "Number"); +const TypeDescriptor *const t_sdaiSTRING = new TypeDescriptor("STRING", sdaiSTRING, 0, "String"); +const TypeDescriptor *const t_sdaiBINARY = new TypeDescriptor("BINARY", sdaiBINARY, 0, "Binary"); +const TypeDescriptor *const t_sdaiBOOLEAN = new TypeDescriptor("BOOLEAN", sdaiBOOLEAN, 0, "Boolean"); +const TypeDescriptor *const t_sdaiLOGICAL = new TypeDescriptor("LOGICAL", sdaiLOGICAL, 0, "Logical"); + +static int uniqueNames(const char *, const SchRename *); + +Registry::Registry(CF_init initFunct) + : col(0), entity_cnt(0), all_ents_cnt(0) +{ + + primordialSwamp = SC_HASHcreate(1000); + active_schemas = SC_HASHcreate(10); + active_types = SC_HASHcreate(100); + + initFunct(*this); + SC_HASHlistinit(active_types, &cur_type); + SC_HASHlistinit(primordialSwamp, &cur_entity); // initialize cur's + SC_HASHlistinit(active_schemas, &cur_schema); } -Registry::~Registry() { +Registry::~Registry() +{ DeleteContents(); - SC_HASHdestroy( primordialSwamp ); - SC_HASHdestroy( active_schemas ); - SC_HASHdestroy( active_types ); + SC_HASHdestroy(primordialSwamp); + SC_HASHdestroy(active_schemas); + SC_HASHdestroy(active_types); delete col; } -void Registry::DeleteContents() { +void Registry::DeleteContents() +{ // entities first - SC_HASHlistinit( primordialSwamp, &cur_entity ); - while( SC_HASHlist( &cur_entity ) ) { - delete( EntityDescriptor * ) cur_entity.e->data; + SC_HASHlistinit(primordialSwamp, &cur_entity); + while(SC_HASHlist(&cur_entity)) { + delete(EntityDescriptor *) cur_entity.e->data; } // schemas - SC_HASHlistinit( active_schemas, &cur_schema ); - while( SC_HASHlist( &cur_schema ) ) { - delete( Schema * ) cur_schema.e->data; + SC_HASHlistinit(active_schemas, &cur_schema); + while(SC_HASHlist(&cur_schema)) { + delete(Schema *) cur_schema.e->data; } // types - SC_HASHlistinit( active_types, &cur_type ); - while( SC_HASHlist( &cur_type ) ) { - delete( TypeDescriptor * ) cur_type.e->data; + SC_HASHlistinit(active_types, &cur_type); + while(SC_HASHlist(&cur_type)) { + delete(TypeDescriptor *) cur_type.e->data; } } @@ -76,33 +79,34 @@ void Registry::DeleteContents() { * entity A from schema Y and renames it to B, X should only refer to A as * B. Thus, if schNm here = "X", only e="B" would be valid but not e="A". */ -const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const { - const EntityDescriptor * entd; - const SchRename * altlist; +const EntityDescriptor *Registry::FindEntity(const char *e, const char *schNm, int check_case) const +{ + const EntityDescriptor *entd; + const SchRename *altlist; char schformat[BUFSIZ], altName[BUFSIZ]; - if( check_case ) { - entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, ( char * )e ); + if(check_case) { + entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, (char *)e); } else { - entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, - ( char * )PrettyTmpName( e ) ); + entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, + (char *)PrettyTmpName(e)); } - if( entd && schNm ) { + if(entd && schNm) { // We've now found an entity. If schNm has a value, we must ensure we // have a valid name. - strcpy( schformat, PrettyTmpName( schNm ) ); - if( ( ( altlist = entd->AltNameList() ) != 0 ) - && ( altlist->rename( schformat, altName ) ) ) { + strcpy(schformat, PrettyTmpName(schNm)); + if(((altlist = entd->AltNameList()) != 0) + && (altlist->rename(schformat, altName))) { // If entd has other name choices, and entd is referred to with a // new name by schema schNm, then e had better = the new name. - if( !StrCmpIns( e, altName ) ) { + if(!StrCmpIns(e, altName)) { return entd; } return NULL; - } else if( FindSchema( schformat, 1 ) ) { + } else if(FindSchema(schformat, 1)) { // If schema schNm exists but we had no conditions above to use an // altName, we must use the original name: - if( !StrCmpIns( e, entd->Name() ) ) { + if(!StrCmpIns(e, entd->Name())) { return entd; } return NULL; @@ -116,48 +120,55 @@ const EntityDescriptor * Registry::FindEntity( const char * e, const char * schN return entd; } -const Schema * Registry::FindSchema( const char * n, int check_case ) const { - if( check_case ) { - return ( const Schema * ) SC_HASHfind( active_schemas, ( char * ) n ); +const Schema *Registry::FindSchema(const char *n, int check_case) const +{ + if(check_case) { + return (const Schema *) SC_HASHfind(active_schemas, (char *) n); } - return ( const Schema * ) SC_HASHfind( active_schemas, - ( char * )PrettyTmpName( n ) ); + return (const Schema *) SC_HASHfind(active_schemas, + (char *)PrettyTmpName(n)); } -const TypeDescriptor * Registry::FindType( const char * n, int check_case ) const { - if( check_case ) { - return ( const TypeDescriptor * ) SC_HASHfind( active_types, ( char * ) n ); +const TypeDescriptor *Registry::FindType(const char *n, int check_case) const +{ + if(check_case) { + return (const TypeDescriptor *) SC_HASHfind(active_types, (char *) n); } - return ( const TypeDescriptor * ) SC_HASHfind( active_types, - ( char * )PrettyTmpName( n ) ); + return (const TypeDescriptor *) SC_HASHfind(active_types, + (char *)PrettyTmpName(n)); } -void Registry::ResetTypes() { - SC_HASHlistinit( active_types, &cur_type ); +void Registry::ResetTypes() +{ + SC_HASHlistinit(active_types, &cur_type); } -const TypeDescriptor * Registry::NextType() { - if( 0 == SC_HASHlist( &cur_type ) ) { +const TypeDescriptor *Registry::NextType() +{ + if(0 == SC_HASHlist(&cur_type)) { return 0; } - return ( const TypeDescriptor * ) cur_type.e->data; + return (const TypeDescriptor *) cur_type.e->data; } -void Registry::AddEntity( const EntityDescriptor & e ) { - SC_HASHinsert( primordialSwamp, ( char * ) e.Name(), ( EntityDescriptor * ) &e ); +void Registry::AddEntity(const EntityDescriptor &e) +{ + SC_HASHinsert(primordialSwamp, (char *) e.Name(), (EntityDescriptor *) &e); ++entity_cnt; ++all_ents_cnt; - AddClones( e ); + AddClones(e); } -void Registry::AddSchema( const Schema & d ) { - SC_HASHinsert( active_schemas, ( char * ) d.Name(), ( Schema * ) &d ); +void Registry::AddSchema(const Schema &d) +{ + SC_HASHinsert(active_schemas, (char *) d.Name(), (Schema *) &d); } -void Registry::AddType( const TypeDescriptor & d ) { - SC_HASHinsert( active_types, ( char * ) d.Name(), ( TypeDescriptor * ) &d ); +void Registry::AddType(const TypeDescriptor &d) +{ + SC_HASHinsert(active_types, (char *) d.Name(), (TypeDescriptor *) &d); } /** @@ -167,15 +178,16 @@ void Registry::AddType( const TypeDescriptor & d ) { * so that if we comes across one of them in a Part 21 file, we'll recog- * nize it. */ -void Registry::AddClones( const EntityDescriptor & e ) { - const SchRename * alts = e.AltNameList(); +void Registry::AddClones(const EntityDescriptor &e) +{ + const SchRename *alts = e.AltNameList(); - while( alts ) { - SC_HASHinsert( primordialSwamp, ( char * )alts->objName(), - ( EntityDescriptor * )&e ); + while(alts) { + SC_HASHinsert(primordialSwamp, (char *)alts->objName(), + (EntityDescriptor *)&e); alts = alts->next; } - all_ents_cnt += uniqueNames( e.Name(), e.AltNameList() ); + all_ents_cnt += uniqueNames(e.Name(), e.AltNameList()); } /** @@ -184,13 +196,14 @@ void Registry::AddClones( const EntityDescriptor & e ) { * does the same (or if C simply uses yy from B), altlist will contain 2 * entries with the same alt name. */ -static int uniqueNames( const char * entnm, const SchRename * altlist ) { +static int uniqueNames(const char *entnm, const SchRename *altlist) +{ int cnt = 0; - const SchRename * alt = altlist; + const SchRename *alt = altlist; - while( alt ) { - if( !( ( alt->next && alt->next->choice( alt->objName() ) ) - || !StrCmpIns( alt->objName(), entnm ) ) ) { + while(alt) { + if(!((alt->next && alt->next->choice(alt->objName())) + || !StrCmpIns(alt->objName(), entnm))) { // alt has a unique alternate name if it's not reused by a later // alt. alt->next->choice() returns 1 if one of the later alts // also has alt's name as its value. The final condition checks @@ -206,59 +219,64 @@ static int uniqueNames( const char * entnm, const SchRename * altlist ) { return cnt; } -void Registry::RemoveEntity( const char * n ) { - const EntityDescriptor * e = FindEntity( n ); +void Registry::RemoveEntity(const char *n) +{ + const EntityDescriptor *e = FindEntity(n); struct Element tmp; - if( e ) { - RemoveClones( *e ); + if(e) { + RemoveClones(*e); } - tmp.key = ( char * ) n; - SC_HASHsearch( primordialSwamp, &tmp, HASH_DELETE ) ? --entity_cnt : 0; + tmp.key = (char *) n; + SC_HASHsearch(primordialSwamp, &tmp, HASH_DELETE) ? --entity_cnt : 0; } -void Registry::RemoveSchema( const char * n ) { +void Registry::RemoveSchema(const char *n) +{ struct Element tmp; - tmp.key = ( char * ) n; - SC_HASHsearch( active_schemas, &tmp, HASH_DELETE ); + tmp.key = (char *) n; + SC_HASHsearch(active_schemas, &tmp, HASH_DELETE); } -void Registry::RemoveType( const char * n ) { +void Registry::RemoveType(const char *n) +{ struct Element tmp; - tmp.key = ( char * ) n; - SC_HASHsearch( active_types, &tmp, HASH_DELETE ); + tmp.key = (char *) n; + SC_HASHsearch(active_types, &tmp, HASH_DELETE); } /** * Remove all the "clones", or rename values of e. */ -void Registry::RemoveClones( const EntityDescriptor & e ) { - const SchRename * alts = e.AltNameList(); - struct Element * tmp; +void Registry::RemoveClones(const EntityDescriptor &e) +{ + const SchRename *alts = e.AltNameList(); + struct Element *tmp; - while( alts ) { + while(alts) { tmp = new Element; - tmp->key = ( char * ) alts->objName(); - SC_HASHsearch( primordialSwamp, tmp, HASH_DELETE ); + tmp->key = (char *) alts->objName(); + SC_HASHsearch(primordialSwamp, tmp, HASH_DELETE); alts = alts->next; } } -SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * schnm, int check_case ) const { - const EntityDescriptor * entd = FindEntity( nm, schnm, check_case ); - if( entd ) { - SDAI_Application_instance * se = - ( ( EntityDescriptor * )entd ) -> NewSTEPentity(); +SDAI_Application_instance *Registry::ObjCreate(const char *nm, const char *schnm, int check_case) const +{ + const EntityDescriptor *entd = FindEntity(nm, schnm, check_case); + if(entd) { + SDAI_Application_instance *se = + ((EntityDescriptor *)entd) -> NewSTEPentity(); // See comment in previous function. - if( entd->AbstractEntity().asInt() == 1 ) { - se->Error().severity( SEVERITY_WARNING ); - se->Error().UserMsg( "ENTITY is abstract supertype" ); - } else if( entd->ExtMapping().asInt() == 1 ) { - se->Error().severity( SEVERITY_WARNING ); - se->Error().UserMsg( "ENTITY requires external mapping" ); + if(entd->AbstractEntity().asInt() == 1) { + se->Error().severity(SEVERITY_WARNING); + se->Error().UserMsg("ENTITY is abstract supertype"); + } else if(entd->ExtMapping().asInt() == 1) { + se->Error().severity(SEVERITY_WARNING); + se->Error().UserMsg("ENTITY requires external mapping"); } se->eDesc = entd; return se; @@ -268,29 +286,34 @@ SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * s } -int Registry::GetEntityCnt() { +int Registry::GetEntityCnt() +{ return entity_cnt; } -void Registry::ResetEntities() { - SC_HASHlistinit( primordialSwamp, &cur_entity ); +void Registry::ResetEntities() +{ + SC_HASHlistinit(primordialSwamp, &cur_entity); } -const EntityDescriptor * Registry::NextEntity() { - if( 0 == SC_HASHlist( &cur_entity ) ) { +const EntityDescriptor *Registry::NextEntity() +{ + if(0 == SC_HASHlist(&cur_entity)) { return 0; } - return ( const EntityDescriptor * ) cur_entity.e->data; + return (const EntityDescriptor *) cur_entity.e->data; } -void Registry::ResetSchemas() { - SC_HASHlistinit( active_schemas, &cur_schema ); +void Registry::ResetSchemas() +{ + SC_HASHlistinit(active_schemas, &cur_schema); } -const Schema * Registry::NextSchema() { - if( 0 == SC_HASHlist( &cur_schema ) ) { +const Schema *Registry::NextSchema() +{ + if(0 == SC_HASHlist(&cur_schema)) { return 0; } - return ( const Schema * ) cur_schema.e->data; + return (const Schema *) cur_schema.e->data; } diff --git a/src/clstepcore/Registry.h b/src/clstepcore/Registry.h index d4d4d4db0..d81d7d8c2 100644 --- a/src/clstepcore/Registry.h +++ b/src/clstepcore/Registry.h @@ -21,25 +21,26 @@ // defined and created in Registry.cc -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiINTEGER; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiREAL; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiNUMBER; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiSTRING; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBINARY; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBOOLEAN; -extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiLOGICAL; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiINTEGER; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiREAL; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiNUMBER; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiSTRING; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBINARY; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBOOLEAN; +extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiLOGICAL; -typedef struct Hash_Table * HashTable; +typedef struct Hash_Table *HashTable; class Registry; -typedef void ( * CF_init )( Registry & ); // pointer to creation initialization +typedef void (* CF_init)(Registry &); // pointer to creation initialization -class SC_CORE_EXPORT Registry { +class SC_CORE_EXPORT Registry +{ protected: HashTable primordialSwamp; // dictionary of EntityDescriptors HashTable active_schemas; // dictionary of Schemas HashTable active_types; // dictionary of TypeDescriptors - ComplexCollect * col; // struct containing all complex entity info + ComplexCollect *col; // struct containing all complex entity info int entity_cnt, all_ents_cnt; @@ -50,50 +51,53 @@ class SC_CORE_EXPORT Registry { // used by AddEntity() and RemoveEntity() to deal with renamings of an // entity done in a USE or REFERENCE clause - see header comments in // file Registry.inline.cc - void AddClones( const EntityDescriptor & ); - void RemoveClones( const EntityDescriptor & ); + void AddClones(const EntityDescriptor &); + void RemoveClones(const EntityDescriptor &); public: - Registry( CF_init initFunct ); + Registry(CF_init initFunct); ~Registry(); void DeleteContents(); // CAUTION: calls delete on all the descriptors - const EntityDescriptor * FindEntity( const char *, const char * = 0, - int check_case = 0 ) const; - const Schema * FindSchema( const char *, int check_case = 0 ) const; - const TypeDescriptor * FindType( const char *, int check_case = 0 ) const; + const EntityDescriptor *FindEntity(const char *, const char * = 0, + int check_case = 0) const; + const Schema *FindSchema(const char *, int check_case = 0) const; + const TypeDescriptor *FindType(const char *, int check_case = 0) const; - void AddEntity( const EntityDescriptor & ); - void AddSchema( const Schema & ); - void AddType( const TypeDescriptor & ); + void AddEntity(const EntityDescriptor &); + void AddSchema(const Schema &); + void AddType(const TypeDescriptor &); - void RemoveEntity( const char * ); - void RemoveSchema( const char * ); - void RemoveType( const char * ); + void RemoveEntity(const char *); + void RemoveSchema(const char *); + void RemoveType(const char *); int GetEntityCnt(); - int GetFullEntCnt() { + int GetFullEntCnt() + { return all_ents_cnt; } void ResetEntities(); - const EntityDescriptor * NextEntity(); + const EntityDescriptor *NextEntity(); void ResetSchemas(); - const Schema * NextSchema(); + const Schema *NextSchema(); void ResetTypes(); - const TypeDescriptor * NextType(); + const TypeDescriptor *NextType(); - const ComplexCollect * CompCol() { + const ComplexCollect *CompCol() + { return col; } - void SetCompCollect( ComplexCollect * c ) { + void SetCompCollect(ComplexCollect *c) + { col = c; } - SDAI_Application_instance * ObjCreate( const char * nm, const char * = 0, - int check_case = 0 ) const; + SDAI_Application_instance *ObjCreate(const char *nm, const char * = 0, + int check_case = 0) const; }; #endif /* _REGISTRY_H */ diff --git a/src/clstepcore/STEPaggrBinary.cc b/src/clstepcore/STEPaggrBinary.cc index fd7302748..4b1df27d1 100644 --- a/src/clstepcore/STEPaggrBinary.cc +++ b/src/clstepcore/STEPaggrBinary.cc @@ -6,24 +6,27 @@ */ -BinaryAggregate::BinaryAggregate() { +BinaryAggregate::BinaryAggregate() +{ } -BinaryAggregate::~BinaryAggregate() { +BinaryAggregate::~BinaryAggregate() +{ } -STEPaggregate & BinaryAggregate::ShallowCopy( const STEPaggregate & a ) { +STEPaggregate &BinaryAggregate::ShallowCopy(const STEPaggregate &a) +{ Empty(); - SingleLinkNode * next = a.GetHead(); - SingleLinkNode * copy; + SingleLinkNode *next = a.GetHead(); + SingleLinkNode *copy; - while( next ) { - copy = new BinaryNode( *( BinaryNode * )next ); - AddNode( copy ); + while(next) { + copy = new BinaryNode(*(BinaryNode *)next); + AddNode(copy); next = next->NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -32,29 +35,35 @@ STEPaggregate & BinaryAggregate::ShallowCopy( const STEPaggregate & a ) { } -SingleLinkNode * BinaryAggregate::NewNode() { +SingleLinkNode *BinaryAggregate::NewNode() +{ return new BinaryNode(); } -BinaryNode::BinaryNode() { +BinaryNode::BinaryNode() +{ value = 0; } -BinaryNode::~BinaryNode() { +BinaryNode::~BinaryNode() +{ } -BinaryNode::BinaryNode( BinaryNode & bn ) { +BinaryNode::BinaryNode(BinaryNode &bn) +{ value = bn.value.c_str(); } -BinaryNode::BinaryNode( const char * sStr ) { +BinaryNode::BinaryNode(const char *sStr) +{ // value is an SDAI_Binary (the memory is copied) value = sStr; } SingleLinkNode * -BinaryNode::NewNode() { +BinaryNode::NewNode() +{ return new BinaryNode(); } @@ -62,48 +71,55 @@ BinaryNode::NewNode() { * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::StrToVal( const char * s, ErrorDescriptor * err ) { - return STEPread( s, err ); +Severity BinaryNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + return STEPread(s, err); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::StrToVal( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity BinaryNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); +Severity BinaryNode::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); - value.STEPread( in, err ); - CheckRemainingInput( in, err, "binary", ",)" ); + value.STEPread(in, err); + CheckRemainingInput(in, err, "binary", ",)"); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::STEPread( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity BinaryNode::STEPread(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } -const char * BinaryNode::asStr( std::string & s ) { +const char *BinaryNode::asStr(std::string &s) +{ s = value.c_str(); - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const char * BinaryNode::STEPwrite( std::string & s, const char * ) { - value.STEPwrite( s ); - return const_cast( s.c_str() ); +const char *BinaryNode::STEPwrite(std::string &s, const char *) +{ + value.STEPwrite(s); + return const_cast(s.c_str()); } -void BinaryNode::STEPwrite( ostream & out ) { - value.STEPwrite( out ); +void BinaryNode::STEPwrite(ostream &out) +{ + value.STEPwrite(out); } diff --git a/src/clstepcore/STEPaggrBinary.h b/src/clstepcore/STEPaggrBinary.h index cd4991bbb..7d627efa5 100644 --- a/src/clstepcore/STEPaggrBinary.h +++ b/src/clstepcore/STEPaggrBinary.h @@ -12,45 +12,47 @@ * * \class BinaryAggregate ** This class supports LIST OF BINARY type */ -class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate { -public: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - - BinaryAggregate(); - virtual ~BinaryAggregate(); +class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate +{ + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + + BinaryAggregate(); + virtual ~BinaryAggregate(); }; -typedef BinaryAggregate * BinaryAggregateH; -typedef BinaryAggregate * BinaryAggregate_ptr; -typedef const BinaryAggregate * BinaryAggregate_ptr_c; +typedef BinaryAggregate *BinaryAggregateH; +typedef BinaryAggregate *BinaryAggregate_ptr; +typedef const BinaryAggregate *BinaryAggregate_ptr_c; typedef BinaryAggregate_ptr BinaryAggregate_var; /** * * \class BinaryNode ** This class is for the Nodes of BinaryAggregates */ -class SC_CORE_EXPORT BinaryNode : public STEPnode { -public: - SDAI_Binary value; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); - - // CONSTRUCTORS - BinaryNode( BinaryNode & bn ); - BinaryNode( const char * sStr ); - BinaryNode(); - ~BinaryNode(); - - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT BinaryNode : public STEPnode +{ + public: + SDAI_Binary value; + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); + + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); + + // CONSTRUCTORS + BinaryNode(BinaryNode &bn); + BinaryNode(const char *sStr); + BinaryNode(); + ~BinaryNode(); + + virtual SingleLinkNode *NewNode(); }; diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index bda8f6db5..480eb97dd 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -8,24 +8,27 @@ */ -EntityAggregate::EntityAggregate() { +EntityAggregate::EntityAggregate() +{ } -EntityAggregate::~EntityAggregate() { +EntityAggregate::~EntityAggregate() +{ } /// if exchangeFileFormat == 1 then delims are required. -Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char * ) { +Severity EntityAggregate::ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char *) +{ ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if( assignVal ) { + if(assignVal) { Empty(); // read new values and discard existing ones } @@ -35,98 +38,99 @@ Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, c = in.peek(); // does not advance input - if( in.eof() || ( c == '$' ) ) { + if(in.eof() || (c == '$')) { _null = 1; - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - if( c == '(' ) { - in.get( c ); - } else if( exchangeFileFormat ) { + if(c == '(') { + in.get(c); + } else if(exchangeFileFormat) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; - } else if( !in.good() ) { + } else if(!in.good()) { // this should actually have been caught by skipping white space above - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - EntityNode * item = 0; + EntityNode *item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if( c == ')' ) { - in.get( c ); + if(c == ')') { + in.get(c); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if( !assignVal ) { + else if(!assignVal) { item = new EntityNode(); } - while( in.good() && ( c != ')' ) ) { + while(in.good() && (c != ')')) { value_cnt++; - if( assignVal ) { // create a new node each time through the loop + if(assignVal) { // create a new node each time through the loop item = new EntityNode(); } errdesc.ClearErrorMsg(); - if( exchangeFileFormat ) { - item->STEPread( in, &errdesc, elem_type, insts, addFileId ); + if(exchangeFileFormat) { + item->STEPread(in, &errdesc, elem_type, insts, addFileId); } else { - item->StrToVal( in, &errdesc, elem_type, insts, addFileId ); + item->StrToVal(in, &errdesc, elem_type, insts, addFileId); } - elem_type->AttrTypeName( buf ); + elem_type->AttrTypeName(buf); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput( in, &errdesc, buf, ",)" ); + CheckRemainingInput(in, &errdesc, buf, ",)"); - if( errdesc.severity() < SEVERITY_INCOMPLETE ) { - sprintf( errmsg, " index: %d\n", value_cnt ); - errdesc.PrependToDetailMsg( errmsg ); - err->AppendFromErrorArg( &errdesc ); + if(errdesc.severity() < SEVERITY_INCOMPLETE) { + sprintf(errmsg, " index: %d\n", value_cnt); + errdesc.PrependToDetailMsg(errmsg); + err->AppendFromErrorArg(&errdesc); } - if( assignVal ) { - AddNode( item ); + if(assignVal) { + AddNode(item); } in >> ws; // skip white space (although should already be skipped) - in.get( c ); // read delim + in.get(c); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if( ( c != ',' ) && ( c != ')' ) ) { + if((c != ',') && (c != ')')) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; } } - if( c == ')' ) { + if(c == ')') { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - err->AppendToUserMsg( "Missing close paren for aggregate value" ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->AppendToUserMsg("Missing close paren for aggregate value"); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate & EntityAggregate::ShallowCopy( const STEPaggregate & a ) { - const EntityNode * tmp = ( const EntityNode * ) a.GetHead(); - while( tmp ) { - AddNode( new EntityNode( tmp -> node ) ); - tmp = ( const EntityNode * ) tmp -> NextNode(); +STEPaggregate &EntityAggregate::ShallowCopy(const STEPaggregate &a) +{ + const EntityNode *tmp = (const EntityNode *) a.GetHead(); + while(tmp) { + AddNode(new EntityNode(tmp -> node)); + tmp = (const EntityNode *) tmp -> NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -136,38 +140,44 @@ STEPaggregate & EntityAggregate::ShallowCopy( const STEPaggregate & a ) { } -SingleLinkNode * EntityAggregate::NewNode() { +SingleLinkNode *EntityAggregate::NewNode() +{ return new EntityNode(); } -EntityNode::EntityNode() { +EntityNode::EntityNode() +{ } -EntityNode::~EntityNode() { +EntityNode::~EntityNode() +{ } -EntityNode::EntityNode( SDAI_Application_instance * e ) : node( e ) { +EntityNode::EntityNode(SDAI_Application_instance *e) : node(e) +{ } -SingleLinkNode * EntityNode::NewNode() { +SingleLinkNode *EntityNode::NewNode() +{ return new EntityNode(); } /////////////////////////////////////////////////////////////////////////////// -Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId ) { - SDAI_Application_instance * se = ReadEntityRef( s, err, ",)", insts, - addFileId ); - if( se != S_ENTITY_NULL ) { +Severity EntityNode::StrToVal(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId) +{ + SDAI_Application_instance *se = ReadEntityRef(s, err, ",)", insts, + addFileId); + if(se != S_ENTITY_NULL) { ErrorDescriptor error; - if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { + if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg( error.DetailMsg() ); - err->AppendToUserMsg( error.UserMsg() ); - err->GreaterSeverity( error.severity() ); + err->AppendToDetailMsg(error.DetailMsg()); + err->AppendToUserMsg(error.UserMsg()); + err->GreaterSeverity(error.severity()); } } else { node = S_ENTITY_NULL; @@ -175,33 +185,36 @@ Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err, return err->severity(); } -Severity EntityNode::StrToVal( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId ) { - return STEPread( in, err, elem_type, insts, addFileId ); +Severity EntityNode::StrToVal(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId) +{ + return STEPread(in, err, elem_type, insts, addFileId); } -Severity EntityNode::STEPread( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId ) { - istringstream in( ( char * )s ); - return STEPread( in, err, elem_type, insts, addFileId ); +Severity EntityNode::STEPread(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + 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, - InstMgrBase * insts, int addFileId ) { - SDAI_Application_instance * se = ReadEntityRef( in, err, ",)", insts, - addFileId ); - if( se != S_ENTITY_NULL ) { +Severity EntityNode::STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId) +{ + SDAI_Application_instance *se = ReadEntityRef(in, err, ",)", insts, + addFileId); + if(se != S_ENTITY_NULL) { ErrorDescriptor error; - if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { + if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg( error.DetailMsg() ); - err->AppendToUserMsg( error.UserMsg() ); - err->GreaterSeverity( error.severity() ); + err->AppendToDetailMsg(error.DetailMsg()); + err->AppendToUserMsg(error.UserMsg()); + err->GreaterSeverity(error.severity()); } } else { node = S_ENTITY_NULL; @@ -209,33 +222,36 @@ Severity EntityNode::STEPread( istream & in, ErrorDescriptor * err, return err->severity(); } -const char * EntityNode::asStr( std::string & s ) { +const char *EntityNode::asStr(std::string &s) +{ s.clear(); - if( !node || ( node == S_ENTITY_NULL ) ) { // nothing + if(!node || (node == S_ENTITY_NULL)) { // nothing return ""; } else { // otherwise return entity id char tmp [64]; - sprintf( tmp, "#%d", node->STEPfile_id ); + sprintf(tmp, "#%d", node->STEPfile_id); s = tmp; } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const char * EntityNode::STEPwrite( std::string & s, const char * ) { - if( !node || ( node == S_ENTITY_NULL ) ) { // nothing +const char *EntityNode::STEPwrite(std::string &s, const char *) +{ + if(!node || (node == S_ENTITY_NULL)) { // nothing s = "$"; - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } - asStr( s ); - return const_cast( s.c_str() ); + asStr(s); + return const_cast(s.c_str()); } -void EntityNode::STEPwrite( ostream & out ) { - if( !node || ( node == S_ENTITY_NULL ) ) { // nothing +void EntityNode::STEPwrite(ostream &out) +{ + if(!node || (node == S_ENTITY_NULL)) { // nothing out << "$"; } std::string s; - out << asStr( s ); + out << asStr(s); } diff --git a/src/clstepcore/STEPaggrEntity.h b/src/clstepcore/STEPaggrEntity.h index f18bc3d0f..a89a3e55f 100644 --- a/src/clstepcore/STEPaggrEntity.h +++ b/src/clstepcore/STEPaggrEntity.h @@ -8,77 +8,83 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT EntityAggregate : public STEPaggregate { -public: - virtual Severity ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char * currSch = 0 ); +class SC_CORE_EXPORT EntityAggregate : public STEPaggregate +{ + public: + virtual Severity ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char *currSch = 0); - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - EntityAggregate(); - virtual ~EntityAggregate(); + EntityAggregate(); + virtual ~EntityAggregate(); }; -typedef EntityAggregate * EntityAggregateH; -typedef EntityAggregate * EntityAggregate_ptr; -typedef const EntityAggregate * EntityAggregate_ptr_c; +typedef EntityAggregate *EntityAggregateH; +typedef EntityAggregate *EntityAggregate_ptr; +typedef const EntityAggregate *EntityAggregate_ptr_c; typedef EntityAggregate_ptr EntityAggregate_var; -class SC_CORE_EXPORT EntityNode : public STEPnode { -public: - SDAI_Application_instance * node; +class SC_CORE_EXPORT EntityNode : public STEPnode +{ + public: + SDAI_Application_instance *node; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); - virtual Severity STEPread( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); + virtual Severity STEPread(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); + virtual Severity STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); - // CONSTRUCTORS - EntityNode( SDAI_Application_instance * e ); - EntityNode(); - ~EntityNode(); + // CONSTRUCTORS + EntityNode(SDAI_Application_instance *e); + EntityNode(); + ~EntityNode(); - virtual SingleLinkNode * NewNode(); + virtual SingleLinkNode *NewNode(); - // Calling these functions is an error. - Severity StrToVal( const char * s, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal( s, err, 0, 0, 0 ); - } - Severity StrToVal( istream & in, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal( in, err, 0, 0, 0 ); - } + // Calling these functions is an error. + Severity StrToVal(const char *s, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal(s, err, 0, 0, 0); + } + Severity StrToVal(istream &in, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal(in, err, 0, 0, 0); + } - Severity STEPread( const char * s, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread( s, err, 0, 0, 0 ); - } - Severity STEPread( istream & in, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread( in, err, 0, 0, 0 ); - } + Severity STEPread(const char *s, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread(s, err, 0, 0, 0); + } + Severity STEPread(istream &in, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread(in, err, 0, 0, 0); + } }; #endif //STEPAGGRENTITY_H diff --git a/src/clstepcore/STEPaggrEnum.cc b/src/clstepcore/STEPaggrEnum.cc index 41b77aa21..ded295cf4 100644 --- a/src/clstepcore/STEPaggrEnum.cc +++ b/src/clstepcore/STEPaggrEnum.cc @@ -7,17 +7,18 @@ /// COPY -STEPaggregate & EnumAggregate::ShallowCopy( const STEPaggregate & a ) { - const EnumNode * tmp = ( const EnumNode * ) a.GetHead(); - EnumNode * to; - - while( tmp ) { - to = ( EnumNode * ) NewNode(); - to -> node -> put( tmp -> node ->asInt() ); - AddNode( to ); - tmp = ( const EnumNode * ) tmp -> NextNode(); +STEPaggregate &EnumAggregate::ShallowCopy(const STEPaggregate &a) +{ + const EnumNode *tmp = (const EnumNode *) a.GetHead(); + EnumNode *to; + + while(tmp) { + to = (EnumNode *) NewNode(); + to -> node -> put(tmp -> node ->asInt()); + AddNode(to); + tmp = (const EnumNode *) tmp -> NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -26,11 +27,13 @@ STEPaggregate & EnumAggregate::ShallowCopy( const STEPaggregate & a ) { return *this; } -EnumAggregate::EnumAggregate() { +EnumAggregate::EnumAggregate() +{ } -EnumAggregate::~EnumAggregate() { +EnumAggregate::~EnumAggregate() +{ } @@ -41,56 +44,69 @@ EnumAggregate::~EnumAggregate() { ** created ** Status: ok 2/91 ******************************************************************/ -SingleLinkNode * EnumAggregate::NewNode() { +SingleLinkNode *EnumAggregate::NewNode() +{ // defined in subclass cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumAggregate::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } -LOGICALS::LOGICALS() { +LOGICALS::LOGICALS() +{ } -LOGICALS::~LOGICALS() { +LOGICALS::~LOGICALS() +{ } -SingleLinkNode * LOGICALS::NewNode() { - return new EnumNode( new SDAI_LOGICAL ); +SingleLinkNode *LOGICALS::NewNode() +{ + return new EnumNode(new SDAI_LOGICAL); } -LOGICALS * create_LOGICALS() { +LOGICALS *create_LOGICALS() +{ return new LOGICALS; } -BOOLEANS::BOOLEANS() { +BOOLEANS::BOOLEANS() +{ } -BOOLEANS::~BOOLEANS() { +BOOLEANS::~BOOLEANS() +{ } -SingleLinkNode * BOOLEANS::NewNode() { - return new EnumNode( new SDAI_BOOLEAN ); +SingleLinkNode *BOOLEANS::NewNode() +{ + return new EnumNode(new SDAI_BOOLEAN); } -BOOLEANS * create_BOOLEANS() { +BOOLEANS *create_BOOLEANS() +{ return new BOOLEANS ; } -EnumNode::EnumNode( SDAI_Enum * e ) : node( e ) { +EnumNode::EnumNode(SDAI_Enum *e) : node(e) +{ } -EnumNode::EnumNode() { +EnumNode::EnumNode() +{ } -EnumNode::~EnumNode() { +EnumNode::~EnumNode() +{ } /// defined in subclass -SingleLinkNode * EnumNode::NewNode() { +SingleLinkNode *EnumNode::NewNode() +{ cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumNode::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } @@ -98,48 +114,55 @@ SingleLinkNode * EnumNode::NewNode() { * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::StrToVal( const char * s, ErrorDescriptor * err ) { - return STEPread( s, err ); +Severity EnumNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + return STEPread(s, err); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::StrToVal( istream & in, ErrorDescriptor * err ) { - return node->STEPread( in, err ); +Severity EnumNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + return node->STEPread(in, err); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); // sz defaults to length of s +Severity EnumNode::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); // sz defaults to length of s int nullable = 0; - node->STEPread( in, err, nullable ); - CheckRemainingInput( in, err, "enumeration", ",)" ); + node->STEPread(in, err, nullable); + CheckRemainingInput(in, err, "enumeration", ",)"); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::STEPread( istream & in, ErrorDescriptor * err ) { +Severity EnumNode::STEPread(istream &in, ErrorDescriptor *err) +{ int nullable = 0; - node->STEPread( in, err, nullable ); + node->STEPread(in, err, nullable); return err->severity(); } -const char * EnumNode::asStr( std::string & s ) { - node -> asStr( s ); - return const_cast( s.c_str() ); +const char *EnumNode::asStr(std::string &s) +{ + node -> asStr(s); + return const_cast(s.c_str()); } -const char * EnumNode::STEPwrite( std::string & s, const char * ) { - node->STEPwrite( s ); - return const_cast( s.c_str() ); +const char *EnumNode::STEPwrite(std::string &s, const char *) +{ + node->STEPwrite(s); + return const_cast(s.c_str()); } -void EnumNode::STEPwrite( ostream & out ) { - node->STEPwrite( out ); +void EnumNode::STEPwrite(ostream &out) +{ + node->STEPwrite(out); } diff --git a/src/clstepcore/STEPaggrEnum.h b/src/clstepcore/STEPaggrEnum.h index 161706a48..a1cf5d9dd 100644 --- a/src/clstepcore/STEPaggrEnum.h +++ b/src/clstepcore/STEPaggrEnum.h @@ -11,73 +11,77 @@ * \class EnumAggregate * This is a minimal representions for a collection of SDAI_Enum */ -class SC_CORE_EXPORT EnumAggregate : public STEPaggregate { -public: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - - EnumAggregate(); - virtual ~EnumAggregate(); +class SC_CORE_EXPORT EnumAggregate : public STEPaggregate +{ + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + + EnumAggregate(); + virtual ~EnumAggregate(); }; -typedef EnumAggregate * EnumAggregateH; -typedef EnumAggregate * EnumAggregate_ptr; -typedef const EnumAggregate * EnumAggregate_ptr_c; +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: - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT LOGICALS : public EnumAggregate +{ + public: + virtual SingleLinkNode *NewNode(); - LOGICALS(); - virtual ~LOGICALS(); + LOGICALS(); + virtual ~LOGICALS(); }; -typedef LOGICALS * LogicalsH; -typedef LOGICALS * LOGICALS_ptr; -typedef const LOGICALS * LOGICALS_ptr_c; +typedef LOGICALS *LogicalsH; +typedef LOGICALS *LOGICALS_ptr; +typedef const LOGICALS *LOGICALS_ptr_c; typedef LOGICALS_ptr LOGICALS_var; -SC_CORE_EXPORT LOGICALS * create_LOGICALS(); +SC_CORE_EXPORT LOGICALS *create_LOGICALS(); -class SC_CORE_EXPORT BOOLEANS : public EnumAggregate { -public: - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT BOOLEANS : public EnumAggregate +{ + public: + virtual SingleLinkNode *NewNode(); - BOOLEANS(); - virtual ~BOOLEANS(); + BOOLEANS(); + virtual ~BOOLEANS(); }; -typedef BOOLEANS * BOOLEANS_ptr; -typedef const BOOLEANS * BOOLEANS_ptr_c; +typedef BOOLEANS *BOOLEANS_ptr; +typedef const BOOLEANS *BOOLEANS_ptr_c; typedef BOOLEANS_ptr BOOLEANS_var; -SC_CORE_EXPORT BOOLEANS * create_BOOLEANS(); +SC_CORE_EXPORT BOOLEANS *create_BOOLEANS(); /** * * \class EnumNode ** This is a minimal representions for node in lists of SDAI_Enum */ -class SC_CORE_EXPORT EnumNode : public STEPnode { -public: - SDAI_Enum * node; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); - - // CONSTRUCTORS - EnumNode( SDAI_Enum * e ); - EnumNode(); - ~EnumNode(); - - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT EnumNode : public STEPnode +{ + public: + SDAI_Enum *node; + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); + + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); + + // CONSTRUCTORS + EnumNode(SDAI_Enum *e); + EnumNode(); + ~EnumNode(); + + virtual SingleLinkNode *NewNode(); }; diff --git a/src/clstepcore/STEPaggrGeneric.cc b/src/clstepcore/STEPaggrGeneric.cc index 899d6c656..fb94bfd83 100644 --- a/src/clstepcore/STEPaggrGeneric.cc +++ b/src/clstepcore/STEPaggrGeneric.cc @@ -5,28 +5,32 @@ * implement classes GenericAggregate, GenericAggrNode */ -GenericAggregate::GenericAggregate() { +GenericAggregate::GenericAggregate() +{ } -GenericAggregate::~GenericAggregate() { +GenericAggregate::~GenericAggregate() +{ } -SingleLinkNode * GenericAggregate::NewNode() { +SingleLinkNode *GenericAggregate::NewNode() +{ return new GenericAggrNode(); } -STEPaggregate & GenericAggregate::ShallowCopy( const STEPaggregate & a ) { +STEPaggregate &GenericAggregate::ShallowCopy(const STEPaggregate &a) +{ Empty(); - SingleLinkNode * next = a.GetHead(); - SingleLinkNode * copy; + SingleLinkNode *next = a.GetHead(); + SingleLinkNode *copy; - while( next ) { - copy = new GenericAggrNode( *( GenericAggrNode * )next ); - AddNode( copy ); + while(next) { + copy = new GenericAggrNode(*(GenericAggrNode *)next); + AddNode(copy); next = next->NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -35,53 +39,65 @@ STEPaggregate & GenericAggregate::ShallowCopy( const STEPaggregate & a ) { } -GenericAggrNode::GenericAggrNode( const char * str ) { +GenericAggrNode::GenericAggrNode(const char *str) +{ value = str; } -GenericAggrNode::GenericAggrNode( GenericAggrNode & gan ) { +GenericAggrNode::GenericAggrNode(GenericAggrNode &gan) +{ value = gan.value; } -GenericAggrNode::GenericAggrNode() { +GenericAggrNode::GenericAggrNode() +{ } -GenericAggrNode::~GenericAggrNode() { +GenericAggrNode::~GenericAggrNode() +{ } -SingleLinkNode * GenericAggrNode::NewNode() { +SingleLinkNode *GenericAggrNode::NewNode() +{ return new GenericAggrNode(); } -Severity GenericAggrNode::StrToVal( const char * s, ErrorDescriptor * err ) { - return value.STEPread( s, err ); +Severity GenericAggrNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + return value.STEPread(s, err); } //TODO -Severity GenericAggrNode::StrToVal( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity GenericAggrNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } -Severity GenericAggrNode::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * ) s ); - return value.STEPread( in, err ); +Severity GenericAggrNode::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *) s); + return value.STEPread(in, err); } -Severity GenericAggrNode::STEPread( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity GenericAggrNode::STEPread(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } -const char * GenericAggrNode::asStr( std::string & s ) { +const char *GenericAggrNode::asStr(std::string &s) +{ s.clear(); - value.asStr( s ); - return const_cast( s.c_str() ); + value.asStr(s); + return const_cast(s.c_str()); } -const char * GenericAggrNode::STEPwrite( std::string & s, const char * currSch ) { +const char *GenericAggrNode::STEPwrite(std::string &s, const char *currSch) +{ (void) currSch; //unused - return value.STEPwrite( s ); + return value.STEPwrite(s); } -void GenericAggrNode::STEPwrite( ostream & out ) { - value.STEPwrite( out ); +void GenericAggrNode::STEPwrite(ostream &out) +{ + value.STEPwrite(out); } diff --git a/src/clstepcore/STEPaggrGeneric.h b/src/clstepcore/STEPaggrGeneric.h index 76190406e..037572180 100644 --- a/src/clstepcore/STEPaggrGeneric.h +++ b/src/clstepcore/STEPaggrGeneric.h @@ -13,44 +13,46 @@ * 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: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - - GenericAggregate(); - virtual ~GenericAggregate(); +class SC_CORE_EXPORT GenericAggregate : public STEPaggregate +{ + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + + GenericAggregate(); + virtual ~GenericAggregate(); }; -typedef GenericAggregate * GenericAggregateH; -typedef GenericAggregate * GenericAggregate_ptr; -typedef const GenericAggregate * GenericAggregate_ptr_c; +typedef GenericAggregate *GenericAggregateH; +typedef GenericAggregate *GenericAggregate_ptr; +typedef const GenericAggregate *GenericAggregate_ptr_c; typedef GenericAggregate_ptr GenericAggregate_var; /** * This class is for the Nodes of GenericAggregates */ -class SC_CORE_EXPORT GenericAggrNode : public STEPnode { -public: - SCLundefined value; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); - - // CONSTRUCTORS - GenericAggrNode( const char * str ); - GenericAggrNode( GenericAggrNode & gan ); - GenericAggrNode(); - ~GenericAggrNode(); - - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT GenericAggrNode : public STEPnode +{ + public: + SCLundefined value; + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); + + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); + + // CONSTRUCTORS + GenericAggrNode(const char *str); + GenericAggrNode(GenericAggrNode &gan); + GenericAggrNode(); + ~GenericAggrNode(); + + virtual SingleLinkNode *NewNode(); }; diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index 2e61a1504..cc729a455 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -1,28 +1,32 @@ #include "STEPaggrInt.h" -IntAggregate::IntAggregate() { +IntAggregate::IntAggregate() +{ } -IntAggregate::~IntAggregate() { +IntAggregate::~IntAggregate() +{ } -SingleLinkNode * IntAggregate::NewNode() { +SingleLinkNode *IntAggregate::NewNode() +{ return new IntNode(); } /// COPY -STEPaggregate & IntAggregate::ShallowCopy( const STEPaggregate & a ) { - const IntNode * tmp = ( const IntNode * ) a.GetHead(); - IntNode * to; +STEPaggregate &IntAggregate::ShallowCopy(const STEPaggregate &a) +{ + const IntNode *tmp = (const IntNode *) a.GetHead(); + IntNode *to; - while( tmp ) { - to = ( IntNode * ) NewNode(); + while(tmp) { + to = (IntNode *) NewNode(); to -> value = tmp -> value; - AddNode( to ); - tmp = ( const IntNode * ) tmp -> NextNode(); + AddNode(to); + tmp = (const IntNode *) tmp -> NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -33,23 +37,28 @@ STEPaggregate & IntAggregate::ShallowCopy( const STEPaggregate & a ) { -IntNode::IntNode() { +IntNode::IntNode() +{ value = S_INT_NULL; } -IntNode::IntNode( SDAI_Integer v ) { +IntNode::IntNode(SDAI_Integer v) +{ value = v; } -IntNode::~IntNode() { +IntNode::~IntNode() +{ } -SingleLinkNode * IntNode::NewNode() { +SingleLinkNode *IntNode::NewNode() +{ return new IntNode(); } -Severity IntNode::StrToVal( const char * s, ErrorDescriptor * err ) { - if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned +Severity IntNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -58,8 +67,9 @@ Severity IntNode::StrToVal( const char * s, ErrorDescriptor * err ) { return err->severity(); } -Severity IntNode::StrToVal( istream & in, ErrorDescriptor * err ) { - if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned +Severity IntNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -68,8 +78,9 @@ Severity IntNode::StrToVal( istream & in, ErrorDescriptor * err ) { return err->severity(); } -Severity IntNode::STEPread( const char * s, ErrorDescriptor * err ) { - if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned +Severity IntNode::STEPread(const char *s, ErrorDescriptor *err) +{ + if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -78,8 +89,9 @@ Severity IntNode::STEPread( const char * s, ErrorDescriptor * err ) { return err->severity(); } -Severity IntNode::STEPread( istream & in, ErrorDescriptor * err ) { - if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned +Severity IntNode::STEPread(istream &in, ErrorDescriptor *err) +{ + if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -88,23 +100,26 @@ Severity IntNode::STEPread( istream & in, ErrorDescriptor * err ) { return err->severity(); } -const char * IntNode::asStr( std::string & s ) { - STEPwrite( s ); - return const_cast( s.c_str() ); +const char *IntNode::asStr(std::string &s) +{ + STEPwrite(s); + return const_cast(s.c_str()); } -const char * IntNode::STEPwrite( std::string & s, const char * ) { +const char *IntNode::STEPwrite(std::string &s, const char *) +{ char tmp[BUFSIZ]; - if( value != S_INT_NULL ) { - sprintf( tmp, "%ld", value ); + if(value != S_INT_NULL) { + sprintf(tmp, "%ld", value); s = tmp; } else { s.clear(); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -void IntNode::STEPwrite( ostream & out ) { +void IntNode::STEPwrite(ostream &out) +{ std::string s; - out << STEPwrite( s ); + out << STEPwrite(s); } diff --git a/src/clstepcore/STEPaggrInt.h b/src/clstepcore/STEPaggrInt.h index 726d07c0e..bf10ca8b0 100644 --- a/src/clstepcore/STEPaggrInt.h +++ b/src/clstepcore/STEPaggrInt.h @@ -4,42 +4,44 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT IntAggregate : public STEPaggregate { +class SC_CORE_EXPORT IntAggregate : public STEPaggregate +{ -public: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - IntAggregate(); - virtual ~IntAggregate(); + IntAggregate(); + virtual ~IntAggregate(); }; -typedef IntAggregate * IntAggregateH; -typedef IntAggregate * IntAggregate_ptr; -typedef const IntAggregate * IntAggregate_ptr_c; +typedef IntAggregate *IntAggregateH; +typedef IntAggregate *IntAggregate_ptr; +typedef const IntAggregate *IntAggregate_ptr_c; typedef IntAggregate_ptr IntAggregate_var; -class SC_CORE_EXPORT IntNode : public STEPnode { -public: - SDAI_Integer value; // long int - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); +class SC_CORE_EXPORT IntNode : public STEPnode +{ + public: + SDAI_Integer value; // long int + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); - // CONSTRUCTORS - IntNode( SDAI_Integer v ); - IntNode(); - ~IntNode(); + // CONSTRUCTORS + IntNode(SDAI_Integer v); + IntNode(); + ~IntNode(); - virtual SingleLinkNode * NewNode(); + virtual SingleLinkNode *NewNode(); }; diff --git a/src/clstepcore/STEPaggrReal.cc b/src/clstepcore/STEPaggrReal.cc index 7d05c1333..d517d90ef 100644 --- a/src/clstepcore/STEPaggrReal.cc +++ b/src/clstepcore/STEPaggrReal.cc @@ -4,28 +4,32 @@ * implementation of classes RealAggregate and RealNode */ -RealAggregate::RealAggregate() { +RealAggregate::RealAggregate() +{ } -RealAggregate::~RealAggregate() { +RealAggregate::~RealAggregate() +{ } -SingleLinkNode * RealAggregate::NewNode() { +SingleLinkNode *RealAggregate::NewNode() +{ return new RealNode(); } // COPY -STEPaggregate & RealAggregate::ShallowCopy( const STEPaggregate & a ) { - const RealNode * tmp = ( const RealNode * ) a.GetHead(); - RealNode * to; +STEPaggregate &RealAggregate::ShallowCopy(const STEPaggregate &a) +{ + const RealNode *tmp = (const RealNode *) a.GetHead(); + RealNode *to; - while( tmp ) { - to = ( RealNode * ) NewNode(); + while(tmp) { + to = (RealNode *) NewNode(); to -> value = tmp -> value; - AddNode( to ); - tmp = ( const RealNode * ) tmp -> NextNode(); + AddNode(to); + tmp = (const RealNode *) tmp -> NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -34,23 +38,28 @@ STEPaggregate & RealAggregate::ShallowCopy( const STEPaggregate & a ) { } -RealNode::RealNode() { +RealNode::RealNode() +{ value = S_REAL_NULL; } -RealNode::RealNode( SDAI_Real v) { +RealNode::RealNode(SDAI_Real v) +{ value = v; } -RealNode::~RealNode() { +RealNode::~RealNode() +{ } -SingleLinkNode * RealNode::NewNode() { +SingleLinkNode *RealNode::NewNode() +{ return new RealNode(); } -Severity RealNode::StrToVal( const char * s, ErrorDescriptor * err ) { - if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned +Severity RealNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -59,8 +68,9 @@ Severity RealNode::StrToVal( const char * s, ErrorDescriptor * err ) { return err->severity(); } -Severity RealNode::StrToVal( istream & in, ErrorDescriptor * err ) { - if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned +Severity RealNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -69,8 +79,9 @@ Severity RealNode::StrToVal( istream & in, ErrorDescriptor * err ) { return err->severity(); } -Severity RealNode::STEPread( const char * s, ErrorDescriptor * err ) { - if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned +Severity RealNode::STEPread(const char *s, ErrorDescriptor *err) +{ + if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -79,8 +90,9 @@ Severity RealNode::STEPread( const char * s, ErrorDescriptor * err ) { return err->severity(); } -Severity RealNode::STEPread( istream & in, ErrorDescriptor * err ) { - if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned +Severity RealNode::STEPread(istream &in, ErrorDescriptor *err) +{ + if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -89,23 +101,26 @@ Severity RealNode::STEPread( istream & in, ErrorDescriptor * err ) { return err->severity(); } -const char * RealNode::asStr( std::string & s ) { - STEPwrite( s ); - return const_cast( s.c_str() ); +const char *RealNode::asStr(std::string &s) +{ + STEPwrite(s); + return const_cast(s.c_str()); } -const char * RealNode::STEPwrite( std::string & s, const char * ) { +const char *RealNode::STEPwrite(std::string &s, const char *) +{ //use memcmp to work around -Wfloat-equal warning SDAI_Real z = S_REAL_NULL; - if( 0 != memcmp( &value, &z, sizeof z ) ) { - s = WriteReal( value ); + if(0 != memcmp(&value, &z, sizeof z)) { + s = WriteReal(value); } else { s.clear(); } return s.c_str(); } -void RealNode::STEPwrite( ostream & out ) { +void RealNode::STEPwrite(ostream &out) +{ std::string s; - out << STEPwrite( s ); + out << STEPwrite(s); } diff --git a/src/clstepcore/STEPaggrReal.h b/src/clstepcore/STEPaggrReal.h index 48cd90e51..f3b6602d8 100644 --- a/src/clstepcore/STEPaggrReal.h +++ b/src/clstepcore/STEPaggrReal.h @@ -4,41 +4,43 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT RealAggregate : public STEPaggregate { +class SC_CORE_EXPORT RealAggregate : public STEPaggregate +{ -public: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - RealAggregate(); - virtual ~RealAggregate(); + RealAggregate(); + virtual ~RealAggregate(); }; -typedef RealAggregate * RealAggregateH; -typedef RealAggregate * RealAggregate_ptr; -typedef const RealAggregate * RealAggregate_ptr_c; +typedef RealAggregate *RealAggregateH; +typedef RealAggregate *RealAggregate_ptr; +typedef const RealAggregate *RealAggregate_ptr_c; typedef RealAggregate_ptr RealAggregate_var; -class SC_CORE_EXPORT RealNode : public STEPnode { -public: - SDAI_Real value; // double - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); +class SC_CORE_EXPORT RealNode : public STEPnode +{ + public: + SDAI_Real value; // double + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); - // CONSTRUCTORS - RealNode( SDAI_Real v ); - RealNode(); - ~RealNode(); + // CONSTRUCTORS + RealNode(SDAI_Real v); + RealNode(); + ~RealNode(); - virtual SingleLinkNode * NewNode(); + virtual SingleLinkNode *NewNode(); }; diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index 02970479c..f74fcf955 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -6,24 +6,27 @@ * implement classes SelectAggregate, SelectNode */ -SelectAggregate::SelectAggregate() { +SelectAggregate::SelectAggregate() +{ } -SelectAggregate::~SelectAggregate() { +SelectAggregate::~SelectAggregate() +{ } /// if exchangeFileFormat == 1 then delims are required. -Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char * currSch ) { +Severity SelectAggregate::ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char *currSch) +{ ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if( assignVal ) { + if(assignVal) { Empty(); // read new values and discard existing ones } @@ -33,99 +36,100 @@ Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err, c = in.peek(); // does not advance input - if( in.eof() || ( c == '$' ) ) { + if(in.eof() || (c == '$')) { _null = 1; - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - if( c == '(' ) { - in.get( c ); - } else if( exchangeFileFormat ) { + if(c == '(') { + in.get(c); + } else if(exchangeFileFormat) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; - } else if( !in.good() ) { + } else if(!in.good()) { // this should actually have been caught by skipping white space above - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - SelectNode * item = 0; + SelectNode *item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if( c == ')' ) { - in.get( c ); + if(c == ')') { + in.get(c); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if( !assignVal ) { - item = ( SelectNode * ) NewNode(); + else if(!assignVal) { + item = (SelectNode *) NewNode(); } - while( in.good() && ( c != ')' ) ) { + while(in.good() && (c != ')')) { value_cnt++; - if( assignVal ) { // create a new node each time through the loop - item = ( SelectNode * ) NewNode(); + if(assignVal) { // create a new node each time through the loop + item = (SelectNode *) NewNode(); } errdesc.ClearErrorMsg(); - if( exchangeFileFormat ) { - item->STEPread( in, &errdesc, elem_type, insts, addFileId, currSch ); + if(exchangeFileFormat) { + item->STEPread(in, &errdesc, elem_type, insts, addFileId, currSch); } else { - item->StrToVal( in, &errdesc, elem_type, insts, addFileId, currSch ); + item->StrToVal(in, &errdesc, elem_type, insts, addFileId, currSch); } - elem_type->AttrTypeName( buf ); + elem_type->AttrTypeName(buf); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput( in, &errdesc, buf, ",)" ); + CheckRemainingInput(in, &errdesc, buf, ",)"); - if( errdesc.severity() < SEVERITY_INCOMPLETE ) { - sprintf( errmsg, " index: %d\n", value_cnt ); - errdesc.PrependToDetailMsg( errmsg ); - err->AppendFromErrorArg( &errdesc ); + if(errdesc.severity() < SEVERITY_INCOMPLETE) { + sprintf(errmsg, " index: %d\n", value_cnt); + errdesc.PrependToDetailMsg(errmsg); + err->AppendFromErrorArg(&errdesc); } - if( assignVal ) { - AddNode( item ); + if(assignVal) { + AddNode(item); } in >> ws; // skip white space (although should already be skipped) - in.get( c ); // read delim + in.get(c); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if( ( c != ',' ) && ( c != ')' ) ) { + if((c != ',') && (c != ')')) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; } } - if( c == ')' ) { + if(c == ')') { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - err->AppendToUserMsg( "Missing close paren for aggregate value" ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->AppendToUserMsg("Missing close paren for aggregate value"); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate & SelectAggregate::ShallowCopy( const STEPaggregate & a ) { - const SelectNode * tmp = ( const SelectNode * ) a.GetHead(); - while( tmp ) { - AddNode( new SelectNode( tmp -> node ) ); +STEPaggregate &SelectAggregate::ShallowCopy(const STEPaggregate &a) +{ + const SelectNode *tmp = (const SelectNode *) a.GetHead(); + while(tmp) { + AddNode(new SelectNode(tmp -> node)); - tmp = ( const SelectNode * ) tmp -> NextNode(); + tmp = (const SelectNode *) tmp -> NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -135,90 +139,102 @@ STEPaggregate & SelectAggregate::ShallowCopy( const STEPaggregate & a ) { } -SingleLinkNode * SelectAggregate::NewNode() { +SingleLinkNode *SelectAggregate::NewNode() +{ return new SelectNode(); } -SelectNode::SelectNode( SDAI_Select * s ) : node( s ) { +SelectNode::SelectNode(SDAI_Select *s) : node(s) +{ } -SelectNode::SelectNode() { +SelectNode::SelectNode() +{ } -SelectNode::~SelectNode() { +SelectNode::~SelectNode() +{ delete node; } -SingleLinkNode * SelectNode::NewNode() { +SingleLinkNode *SelectNode::NewNode() +{ return new SelectNode(); } -Severity SelectNode::StrToVal( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId ) { +Severity SelectNode::StrToVal(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId) +{ (void) elem_type; //unused (void) addFileId; //unused - istringstream in( ( char * )s ); - if( err->severity( node->STEPread( in, err, insts ) ) != SEVERITY_NULL ) { - err->AppendToDetailMsg( node ->Error() ); + istringstream in((char *)s); + if(err->severity(node->STEPread(in, err, insts)) != SEVERITY_NULL) { + err->AppendToDetailMsg(node ->Error()); } return err->severity(); } -Severity SelectNode::StrToVal( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId, const char * currSch ) { - return STEPread( in, err, elem_type, insts, addFileId, currSch ); +Severity SelectNode::StrToVal(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + 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, - InstMgrBase * insts, int addFileId ) { - istringstream in( ( char * )s ); - return STEPread( in, err, elem_type, insts, addFileId ); +Severity SelectNode::STEPread(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + 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, - InstMgrBase * insts, int addFileId, const char * currSch ) { +Severity SelectNode::STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId, const char *currSch) +{ (void) elem_type; //unused - if( !node ) { + if(!node) { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; cerr << "function: SelectNode::STEPread \n" << "\n"; return SEVERITY_BUG; } - err->severity( node->STEPread( in, err, insts, 0, addFileId, currSch ) ); - CheckRemainingInput( in, err, "select", ",)" ); + err->severity(node->STEPread(in, err, insts, 0, addFileId, currSch)); + CheckRemainingInput(in, err, "select", ",)"); return err->severity(); } -const char * SelectNode::asStr( std::string & s ) { +const char *SelectNode::asStr(std::string &s) +{ s.clear(); - if( !node || ( node->is_null() ) ) { // nothing + if(!node || (node->is_null())) { // nothing return ""; } else { // otherwise return entity id - node -> STEPwrite( s ); - return const_cast( s.c_str() ); + node -> STEPwrite(s); + return const_cast(s.c_str()); } } -const char * SelectNode::STEPwrite( std::string & s, const char * currSch ) { +const char *SelectNode::STEPwrite(std::string &s, const char *currSch) +{ s.clear(); - if( !node || ( node->is_null() ) ) { // nothing + if(!node || (node->is_null())) { // nothing s = "$"; return "$"; } - node -> STEPwrite( s, currSch ); - return const_cast( s.c_str() ); + node -> STEPwrite(s, currSch); + return const_cast(s.c_str()); } -void SelectNode::STEPwrite( ostream & out ) { - if( !node || ( node->is_null() ) ) { // nothing +void SelectNode::STEPwrite(ostream &out) +{ + if(!node || (node->is_null())) { // nothing out << "$"; } std::string s; - out << asStr( s ); + out << asStr(s); } diff --git a/src/clstepcore/STEPaggrSelect.h b/src/clstepcore/STEPaggrSelect.h index b62a9c3fe..1db7ba252 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/src/clstepcore/STEPaggrSelect.h @@ -13,23 +13,24 @@ * * \class SelectAggregate ** This is a minimal represention for a collection of SDAI_Select */ -class SC_CORE_EXPORT SelectAggregate : public STEPaggregate { -public: - virtual Severity ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char * currSch = 0 ); +class SC_CORE_EXPORT SelectAggregate : public STEPaggregate +{ + public: + virtual Severity ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char *currSch = 0); - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - SelectAggregate(); - virtual ~SelectAggregate(); + SelectAggregate(); + virtual ~SelectAggregate(); }; -typedef SelectAggregate * SelectAggregateH; -typedef SelectAggregate * SelectAggregate_ptr; -typedef const SelectAggregate * SelectAggregate_ptr_c; +typedef SelectAggregate *SelectAggregateH; +typedef SelectAggregate *SelectAggregate_ptr; +typedef const SelectAggregate *SelectAggregate_ptr_c; typedef SelectAggregate_ptr SelectAggregate_var; @@ -37,59 +38,64 @@ typedef SelectAggregate_ptr SelectAggregate_var; * * \class SelectNode ** This is a minimal representions for node in lists of SDAI_Select */ -class SC_CORE_EXPORT SelectNode : public STEPnode { -public: - SDAI_Select * node; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0, - const char * currSch = 0 ); +class SC_CORE_EXPORT SelectNode : public STEPnode +{ + public: + SDAI_Select *node; + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0, + const char *currSch = 0); - virtual Severity STEPread( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0 ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0, - const char * currSch = 0 ); - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); + virtual Severity STEPread(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0); + virtual Severity STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0, + const char *currSch = 0); + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); - // CONSTRUCTORS - SelectNode( SDAI_Select * s ); - SelectNode(); - ~SelectNode(); + // CONSTRUCTORS + SelectNode(SDAI_Select *s); + SelectNode(); + ~SelectNode(); - virtual SingleLinkNode * NewNode(); + virtual SingleLinkNode *NewNode(); - // Calling these functions is an error. - Severity StrToVal( const char * s, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal( s, err, 0, 0, 0 ); - } - Severity StrToVal( istream & in, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal( in, err, 0, 0, 0 ); - } + // Calling these functions is an error. + Severity StrToVal(const char *s, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal(s, err, 0, 0, 0); + } + Severity StrToVal(istream &in, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal(in, err, 0, 0, 0); + } - Severity STEPread( const char * s, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread( s, err, 0, 0, 0 ); - } - Severity STEPread( istream & in, ErrorDescriptor * err ) { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread( in, err, 0, 0, 0 ); - } + Severity STEPread(const char *s, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread(s, err, 0, 0, 0); + } + Severity STEPread(istream &in, ErrorDescriptor *err) + { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread(in, err, 0, 0, 0); + } }; diff --git a/src/clstepcore/STEPaggrString.cc b/src/clstepcore/STEPaggrString.cc index fd9285ad3..08179bb3d 100644 --- a/src/clstepcore/STEPaggrString.cc +++ b/src/clstepcore/STEPaggrString.cc @@ -6,24 +6,27 @@ */ -StringAggregate::StringAggregate() { +StringAggregate::StringAggregate() +{ } -StringAggregate::~StringAggregate() { +StringAggregate::~StringAggregate() +{ } -STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) { +STEPaggregate &StringAggregate::ShallowCopy(const STEPaggregate &a) +{ Empty(); - SingleLinkNode * next = a.GetHead(); - SingleLinkNode * copy; + SingleLinkNode *next = a.GetHead(); + SingleLinkNode *copy; - while( next ) { - copy = new StringNode( *( StringNode * )next ); - AddNode( copy ); + while(next) { + copy = new StringNode(*(StringNode *)next); + AddNode(copy); next = next->NextNode(); } - if( head ) { + if(head) { _null = 0; } else { _null = 1; @@ -32,28 +35,34 @@ STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) { } -SingleLinkNode * StringAggregate::NewNode() { +SingleLinkNode *StringAggregate::NewNode() +{ return new StringNode(); } -StringNode::StringNode() { +StringNode::StringNode() +{ value = ""; } -StringNode::~StringNode() { +StringNode::~StringNode() +{ } -StringNode::StringNode( StringNode & sn ) { +StringNode::StringNode(StringNode &sn) +{ value = sn.value.c_str(); } -StringNode::StringNode( const char * sStr ) { +StringNode::StringNode(const char *sStr) +{ // value is an SDAI_String (the memory is copied) value = sStr; } -SingleLinkNode * StringNode::NewNode() { +SingleLinkNode *StringNode::NewNode() +{ return new StringNode(); } @@ -61,47 +70,54 @@ SingleLinkNode * StringNode::NewNode() { * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) { - return STEPread( s, err ); +Severity StringNode::StrToVal(const char *s, ErrorDescriptor *err) +{ + return STEPread(s, err); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity StringNode::StrToVal(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * )s ); +Severity StringNode::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *)s); - value.STEPread( in, err ); - CheckRemainingInput( in, err, "string", ",)" ); + value.STEPread(in, err); + CheckRemainingInput(in, err, "string", ",)"); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) { - return value.STEPread( in, err ); +Severity StringNode::STEPread(istream &in, ErrorDescriptor *err) +{ + return value.STEPread(in, err); } -const char * StringNode::asStr( std::string & s ) { - value.asStr( s ); - return const_cast( s.c_str() ); +const char *StringNode::asStr(std::string &s) +{ + value.asStr(s); + return const_cast(s.c_str()); } -const char * StringNode::STEPwrite( std::string & s, const char * ) { - value.STEPwrite( s ); - return const_cast( s.c_str() ); +const char *StringNode::STEPwrite(std::string &s, const char *) +{ + value.STEPwrite(s); + return const_cast(s.c_str()); } -void StringNode::STEPwrite( ostream & out ) { - value.STEPwrite( out ); +void StringNode::STEPwrite(ostream &out) +{ + value.STEPwrite(out); } diff --git a/src/clstepcore/STEPaggrString.h b/src/clstepcore/STEPaggrString.h index 6f5cc8331..5446a989a 100644 --- a/src/clstepcore/STEPaggrString.h +++ b/src/clstepcore/STEPaggrString.h @@ -12,45 +12,47 @@ * * \class StringAggregate ** This class supports LIST OF STRING type */ -class SC_CORE_EXPORT StringAggregate : public STEPaggregate { -public: - virtual SingleLinkNode * NewNode(); - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - - StringAggregate(); - virtual ~StringAggregate(); +class SC_CORE_EXPORT StringAggregate : public STEPaggregate +{ + public: + virtual SingleLinkNode *NewNode(); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + + StringAggregate(); + virtual ~StringAggregate(); }; -typedef StringAggregate * StringAggregateH; -typedef StringAggregate * StringAggregate_ptr; -typedef const StringAggregate * StringAggregate_ptr_c; +typedef StringAggregate *StringAggregateH; +typedef StringAggregate *StringAggregate_ptr; +typedef const StringAggregate *StringAggregate_ptr_c; typedef StringAggregate_ptr StringAggregate_var; /** * * \class StringNode ** This class is for the Nodes of StringAggregates */ -class SC_CORE_EXPORT StringNode : public STEPnode { -public: - SDAI_String value; - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); - - // CONSTRUCTORS - StringNode( StringNode & sn ); - StringNode( const char * sStr ); - StringNode(); - ~StringNode(); - - virtual SingleLinkNode * NewNode(); +class SC_CORE_EXPORT StringNode : public STEPnode +{ + public: + SDAI_String value; + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); + + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); + + // CONSTRUCTORS + StringNode(StringNode &sn); + StringNode(const char *sStr); + StringNode(); + ~StringNode(); + + virtual SingleLinkNode *NewNode(); }; #endif //STEPAGGRSTRING_H diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index db3bbf819..7bf6933e6 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -34,22 +34,25 @@ STEPaggregate NilSTEPaggregate; -STEPaggregate::STEPaggregate() { +STEPaggregate::STEPaggregate() +{ _null = true; } -STEPaggregate::~STEPaggregate() { - STEPnode * node; +STEPaggregate::~STEPaggregate() +{ + STEPnode *node; - node = ( STEPnode * ) head; - while( node ) { + node = (STEPnode *) head; + while(node) { head = node->NextNode(); delete node; - node = ( STEPnode * ) head; + node = (STEPnode *) head; } } -STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) { +STEPaggregate &STEPaggregate::ShallowCopy(const STEPaggregate &a) +{ (void) a; // unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; @@ -58,50 +61,53 @@ STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) { } /// do not require exchange file format -Severity STEPaggregate::AggrValidLevel( const char * value, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int optional, char * tokenList, int addFileId, - int clearError ) { +Severity STEPaggregate::AggrValidLevel(const char *value, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int optional, char *tokenList, int addFileId, + int clearError) +{ std::string buf; - if( clearError ) { + if(clearError) { err->ClearErrorMsg(); } - istringstream in( ( char * )value ); // sz defaults to length of s + istringstream in((char *)value); // sz defaults to length of s - ReadValue( in, err, elem_type, insts, addFileId, 0, 0 ); - elem_type->AttrTypeName( buf ); - CheckRemainingInput( in, err, buf, tokenList ); - if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { - err->severity( SEVERITY_NULL ); + ReadValue(in, err, elem_type, insts, addFileId, 0, 0); + elem_type->AttrTypeName(buf); + CheckRemainingInput(in, err, buf, tokenList); + if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { + err->severity(SEVERITY_NULL); } return err->severity(); } /// require exchange file format -Severity STEPaggregate::AggrValidLevel( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int optional, char * tokenList, int addFileId, - int clearError ) { +Severity STEPaggregate::AggrValidLevel(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int optional, char *tokenList, int addFileId, + int clearError) +{ std::string buf; - if( clearError ) { + if(clearError) { err->ClearErrorMsg(); } - ReadValue( in, err, elem_type, insts, addFileId, 0, 1 ); - elem_type->AttrTypeName( buf ); - CheckRemainingInput( in, err, buf, tokenList ); - if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { - err->severity( SEVERITY_NULL ); + ReadValue(in, err, elem_type, insts, addFileId, 0, 1); + elem_type->AttrTypeName(buf); + CheckRemainingInput(in, err, buf, tokenList); + if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { + err->severity(SEVERITY_NULL); } return err->severity(); } /// if exchangeFileFormat == 1 then paren delims are required. -Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int addFileId, int assignVal, int exchangeFileFormat, - const char * ) { +Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int addFileId, int assignVal, int exchangeFileFormat, + const char *) +{ (void) insts; //not used in ReadValue() for this class (void) addFileId; //not used in ReadValue() for this class @@ -110,7 +116,7 @@ Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, int value_cnt = 0; std::string buf; - if( assignVal ) { + if(assignVal) { Empty(); // read new values and discard existing ones } @@ -120,134 +126,138 @@ Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, c = in.peek(); // does not advance input - if( in.eof() || c == '$' ) { + if(in.eof() || c == '$') { _null = true; - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - if( c == '(' ) { - in.get( c ); - } else if( exchangeFileFormat ) { + if(c == '(') { + in.get(c); + } else if(exchangeFileFormat) { // error did not find opening delim // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; - } else if( !in.good() ) { + } else if(!in.good()) { // this should actually have been caught by skipping white space above - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } - STEPnode * item = 0; + STEPnode *item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if( c == ')' ) { - in.get( c ); + if(c == ')') { + in.get(c); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if( !assignVal ) { - item = ( STEPnode * )NewNode(); + else if(!assignVal) { + item = (STEPnode *)NewNode(); } // ')' is the end of the aggregate - while( in.good() && ( c != ')' ) ) { + while(in.good() && (c != ')')) { value_cnt++; - if( assignVal ) { // create a new node each time through the loop - item = ( STEPnode * )NewNode(); + if(assignVal) { // create a new node each time through the loop + item = (STEPnode *)NewNode(); } errdesc.ClearErrorMsg(); - if( exchangeFileFormat ) { - item->STEPread( in, &errdesc ); + if(exchangeFileFormat) { + item->STEPread(in, &errdesc); } else { - item->StrToVal( in, &errdesc ); + item->StrToVal(in, &errdesc); } // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - elem_type->AttrTypeName( buf ); - CheckRemainingInput( in, &errdesc, buf, ",)" ); + elem_type->AttrTypeName(buf); + CheckRemainingInput(in, &errdesc, buf, ",)"); - if( errdesc.severity() < SEVERITY_INCOMPLETE ) { - sprintf( errmsg, " index: %d\n", value_cnt ); - errdesc.PrependToDetailMsg( errmsg ); - err->AppendFromErrorArg( &errdesc ); + if(errdesc.severity() < SEVERITY_INCOMPLETE) { + sprintf(errmsg, " index: %d\n", value_cnt); + errdesc.PrependToDetailMsg(errmsg); + err->AppendFromErrorArg(&errdesc); } - if( assignVal ) { // pass the node to STEPaggregate - AddNode( item ); + if(assignVal) { // pass the node to STEPaggregate + AddNode(item); } in >> ws; // skip white space (although should already be skipped) - in.get( c ); // read delim + in.get(c); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if( ( c != ',' ) && ( c != ')' ) ) { + if((c != ',') && (c != ')')) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); return SEVERITY_INPUT_ERROR; } } - if( c == ')' ) { + if(c == ')') { _null = false; } else { // expectation for end paren delim has not been met - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - err->AppendToUserMsg( "Missing close paren for aggregate value" ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->AppendToUserMsg("Missing close paren for aggregate value"); return SEVERITY_INPUT_ERROR; } return err->severity(); } -Severity STEPaggregate::StrToVal( const char * s, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int addFileId ) { - istringstream in( ( char * )s ); - return ReadValue( in, err, elem_type, insts, addFileId, 1, 0 ); +Severity STEPaggregate::StrToVal(const char *s, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int addFileId) +{ + istringstream in((char *)s); + return ReadValue(in, err, elem_type, insts, addFileId, 1, 0); } /////////////////////////////////////////////////////////////////////////////// -Severity STEPaggregate::STEPread( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int addFileId, const char * currSch ) { - return ReadValue( in, err, elem_type, insts, addFileId, 1, 1, currSch ); +Severity STEPaggregate::STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, InstMgrBase *insts, + int addFileId, const char *currSch) +{ + return ReadValue(in, err, elem_type, insts, addFileId, 1, 1, currSch); } -const char * STEPaggregate::asStr( std::string & s ) const { +const char *STEPaggregate::asStr(std::string &s) const +{ s.clear(); - if( !_null ) { + if(!_null) { s = "("; - STEPnode * n = ( STEPnode * ) head; + STEPnode *n = (STEPnode *) head; std::string tmp; - while( n ) { - s.append( n->STEPwrite( tmp ) ); - n = ( STEPnode * ) n -> NextNode(); - if( n ) { - s.append( "," ); + while(n) { + s.append(n->STEPwrite(tmp)); + n = (STEPnode *) n -> NextNode(); + if(n) { + s.append(","); } } - s.append( ")" ); + s.append(")"); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -void STEPaggregate::STEPwrite( ostream & out, const char * currSch ) const { - if( !_null ) { +void STEPaggregate::STEPwrite(ostream &out, const char *currSch) const +{ + if(!_null) { out << '('; - STEPnode * n = ( STEPnode * )head; + STEPnode *n = (STEPnode *)head; std::string s; - while( n ) { - out << n->STEPwrite( s, currSch ); - n = ( STEPnode * ) n -> NextNode(); - if( n ) { + while(n) { + out << n->STEPwrite(s, currSch); + n = (STEPnode *) n -> NextNode(); + if(n) { out << ','; } } @@ -257,18 +267,21 @@ void STEPaggregate::STEPwrite( ostream & out, const char * currSch ) const { } } -SingleLinkNode * STEPaggregate::NewNode() { +SingleLinkNode *STEPaggregate::NewNode() +{ cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPaggregate::NewNode \n" << _POC_ << "\n"; return 0; } -void STEPaggregate::AddNode( SingleLinkNode * n ) { - SingleLinkList::AppendNode( n ); +void STEPaggregate::AddNode(SingleLinkNode *n) +{ + SingleLinkList::AppendNode(n); _null = false; } -void STEPaggregate::Empty() { +void STEPaggregate::Empty() +{ SingleLinkList::Empty(); _null = true; } @@ -278,35 +291,38 @@ void STEPaggregate::Empty() { // STEPnode /////////////////////////////////////////////////////////////////////////////// -Severity STEPnode::StrToVal( const char * s, ErrorDescriptor * err ) { +Severity STEPnode::StrToVal(const char *s, ErrorDescriptor *err) +{ // defined in subtypes (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg( "Aggr. attr value: '\n" ); - err->AppendToDetailMsg( "not assigned.\n" ); - err->AppendToDetailMsg( _POC_ ); - err->GreaterSeverity( SEVERITY_BUG ); + err->AppendToDetailMsg("Aggr. attr value: '\n"); + err->AppendToDetailMsg("not assigned.\n"); + err->AppendToDetailMsg(_POC_); + err->GreaterSeverity(SEVERITY_BUG); return SEVERITY_BUG; } -Severity STEPnode::StrToVal( istream & in, ErrorDescriptor * err ) { +Severity STEPnode::StrToVal(istream &in, ErrorDescriptor *err) +{ // defined in subtypes (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg( "Aggr. attr value: '\n" ); - err->AppendToDetailMsg( "not assigned.\n" ); - err->AppendToDetailMsg( _POC_ ); - err->GreaterSeverity( SEVERITY_BUG ); + err->AppendToDetailMsg("Aggr. attr value: '\n"); + err->AppendToDetailMsg("not assigned.\n"); + err->AppendToDetailMsg(_POC_); + err->GreaterSeverity(SEVERITY_BUG); return SEVERITY_BUG; } -Severity STEPnode::STEPread( const char * s, ErrorDescriptor * err ) { +Severity STEPnode::STEPread(const char *s, ErrorDescriptor *err) +{ // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -316,13 +332,14 @@ Severity STEPnode::STEPread( const char * s, ErrorDescriptor * err ) { err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg( _POC_ ); - err->GreaterSeverity( SEVERITY_BUG ); + err->AppendToDetailMsg(_POC_); + err->GreaterSeverity(SEVERITY_BUG); return SEVERITY_BUG; } -Severity STEPnode::STEPread( istream & in, ErrorDescriptor * err ) { +Severity STEPnode::STEPread(istream &in, ErrorDescriptor *err) +{ (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPread called instead of virtual function.\n" @@ -331,12 +348,13 @@ Severity STEPnode::STEPread( istream & in, ErrorDescriptor * err ) { err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg( _POC_ ); - err->GreaterSeverity( SEVERITY_BUG ); + err->AppendToDetailMsg(_POC_); + err->GreaterSeverity(SEVERITY_BUG); return SEVERITY_BUG; } -const char * STEPnode::asStr( std::string & s ) { +const char *STEPnode::asStr(std::string &s) +{ // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -361,7 +379,8 @@ const char * STEPnode::asStr( std::string & s ) { * selects. But since currently (3/27/97) the SCL handles 2D+ aggrs using * SCLundefined's, this is not implemented.) */ -const char * STEPnode::STEPwrite( std::string & s, const char * currSch ) { +const char *STEPnode::STEPwrite(std::string &s, const char *currSch) +{ (void) s; //unused (void) currSch; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -370,7 +389,8 @@ const char * STEPnode::STEPwrite( std::string & s, const char * currSch ) { return ""; } -void STEPnode::STEPwrite( ostream & out ) { +void STEPnode::STEPwrite(ostream &out) +{ (void) out; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPwrite called instead of virtual function.\n" diff --git a/src/clstepcore/STEPaggregate.h b/src/clstepcore/STEPaggregate.h index df2178ee9..c3882064c 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/src/clstepcore/STEPaggregate.h @@ -30,85 +30,90 @@ extern STEPaggregate NilSTEPaggregate; class SingleLinkNode; -typedef STEPaggregate * STEPaggregateH; -typedef STEPaggregate * STEPaggregate_ptr; +typedef STEPaggregate *STEPaggregateH; +typedef STEPaggregate *STEPaggregate_ptr; typedef STEPaggregate_ptr STEPaggregate_var; -class SC_CORE_EXPORT STEPaggregate : public SingleLinkList { +class SC_CORE_EXPORT STEPaggregate : public SingleLinkList +{ protected: bool _null; protected: - virtual Severity ReadValue( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type, - InstMgrBase * insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char * currSch = 0 ); + virtual Severity ReadValue(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type, + InstMgrBase *insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char *currSch = 0); public: - bool is_null() { + bool is_null() + { return _null; } - virtual Severity AggrValidLevel( const char * value, ErrorDescriptor * err, - const TypeDescriptor * elem_type, InstMgrBase * insts, - int optional, char * tokenList, int addFileId = 0, - int clearError = 0 ); + virtual Severity AggrValidLevel(const char *value, ErrorDescriptor *err, + 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, InstMgrBase * insts, - int optional, char * tokenList, int addFileId = 0, - int clearError = 0 ); + virtual Severity AggrValidLevel(istream &in, ErrorDescriptor *err, + 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, - InstMgrBase * insts = 0, int addFileId = 0 ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err, - const TypeDescriptor * elem_type = 0, - InstMgrBase * insts = 0, int addFileId = 0, - const char * currSch = 0 ); + virtual Severity StrToVal(const char *s, ErrorDescriptor *err = 0, + const TypeDescriptor *elem_type = 0, + InstMgrBase *insts = 0, int addFileId = 0); + virtual Severity STEPread(istream &in, ErrorDescriptor *err, + const TypeDescriptor *elem_type = 0, + InstMgrBase *insts = 0, int addFileId = 0, + const char *currSch = 0); // OUTPUT - virtual const char * asStr( std::string & s ) const; - virtual void STEPwrite( ostream & out = cout, const char * = 0 ) const; + virtual const char *asStr(std::string &s) const; + virtual void STEPwrite(ostream &out = cout, const char * = 0) const; - virtual SingleLinkNode * NewNode(); - void AddNode( SingleLinkNode * ); + virtual SingleLinkNode *NewNode(); + void AddNode(SingleLinkNode *); void Empty(); STEPaggregate(); virtual ~STEPaggregate(); // COPY - defined in subtypes - virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + virtual STEPaggregate &ShallowCopy(const STEPaggregate &); }; -class SC_CORE_EXPORT STEPnode : public SingleLinkNode { -protected: - int _null; - -public: - int is_null() { - return _null; - } - void set_null() { - _null = 1; - } - - // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - - // OUTPUT - virtual const char * asStr( std::string & s ); - virtual const char * STEPwrite( std::string & s, const char * = 0 ); - virtual void STEPwrite( ostream & out = cout ); +class SC_CORE_EXPORT STEPnode : public SingleLinkNode +{ + protected: + int _null; + + public: + int is_null() + { + return _null; + } + void set_null() + { + _null = 1; + } + + // INPUT + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); + + // OUTPUT + virtual const char *asStr(std::string &s); + virtual const char *STEPwrite(std::string &s, const char * = 0); + virtual void STEPwrite(ostream &out = cout); }; -typedef STEPnode * STEPnodeH; +typedef STEPnode *STEPnodeH; #include "STEPaggrGeneric.h" #include "STEPaggrEntity.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 866248fe4..f67b2fee5 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -39,9 +39,10 @@ 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, InstMgrBase * instances, int addFileId ) { - if( _redefAttr ) { - return _redefAttr->StrToVal( s, instances, addFileId ); +Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addFileId) +{ + if(_redefAttr) { + return _redefAttr->StrToVal(s, instances, addFileId); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -49,97 +50,97 @@ Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int a // set the value to be null (reinitialize the attribute value) set_null(); - int nullable = ( aDesc->Optional().asInt() == BTrue ); + int nullable = (aDesc->Optional().asInt() == BTrue); // an empty str gets assigned NULL - if( !s ) { - if( nullable || IsDerived() ) { // if it is derived it doesn't + if(!s) { + if(nullable || IsDerived()) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity( SEVERITY_INCOMPLETE ); + _error.severity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } } - if( s[0] == '\0' ) { - if( NonRefType() == STRING_TYPE ) { + if(s[0] == '\0') { + if(NonRefType() == STRING_TYPE) { // this is interpreted as a string with no value i.e. "". - *( ptr.S ) = s; // using string class - don't need to declare space + *(ptr.S) = s; // using string class - don't need to declare space return SEVERITY_NULL; } - if( nullable || IsDerived() ) { // if it is derived it doesn't + if(nullable || IsDerived()) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity( SEVERITY_INCOMPLETE ); + _error.severity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if( IsDerived() ) { // check to see if value contains: optional space, + if(IsDerived()) { // check to see if value contains: optional space, // followed by *, followed by optional space - const char * tmpSptr = s; - while( isspace( *tmpSptr ) ) { + const char *tmpSptr = s; + while(isspace(*tmpSptr)) { tmpSptr++; } - if( *tmpSptr == '*' ) { + if(*tmpSptr == '*') { tmpSptr++; char tmpC; - int charsFound = sscanf( tmpSptr, "%c", &tmpC ); - if( charsFound == EOF ) { // no non-white chars followed the * + int charsFound = sscanf(tmpSptr, "%c", &tmpC); + if(charsFound == EOF) { // no non-white chars followed the * return SEVERITY_NULL; } } _error.AppendToDetailMsg( - "Derived attribute must have \'*\' for its value.\n" ); - return _error.severity( SEVERITY_INPUT_ERROR ); + "Derived attribute must have \'*\' for its value.\n"); + return _error.severity(SEVERITY_INPUT_ERROR); } - istringstream in( ( char * )s ); // sz defaults to length of s + istringstream in((char *)s); // sz defaults to length of s // read in value for attribute - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: { - ReadInteger( *( ptr.i ), s, &_error, 0 ); + ReadInteger(*(ptr.i), s, &_error, 0); break; } case REAL_TYPE: { - ReadReal( *( ptr.r ), s, &_error, 0 ); + ReadReal(*(ptr.r), s, &_error, 0); break; } case NUMBER_TYPE: { - ReadNumber( *( ptr.r ), s, &_error, 0 ); + ReadNumber(*(ptr.r), s, &_error, 0); break; } case ENTITY_TYPE: { - STEPentity * se = ReadEntityRef( s, &_error, 0, instances, addFileId ); - if( se != S_ENTITY_NULL ) { - if( EntityValidLevel( se, aDesc->NonRefTypeDescriptor(), - &_error ) - == SEVERITY_NULL ) { - *( ptr.c ) = se; + STEPentity *se = ReadEntityRef(s, &_error, 0, instances, addFileId); + if(se != S_ENTITY_NULL) { + if(EntityValidLevel(se, aDesc->NonRefTypeDescriptor(), + &_error) + == SEVERITY_NULL) { + *(ptr.c) = se; } else { - *( ptr.c ) = S_ENTITY_NULL; + *(ptr.c) = S_ENTITY_NULL; } } else { - *( ptr.c ) = S_ENTITY_NULL; + *(ptr.c) = S_ENTITY_NULL; } break; } case BINARY_TYPE: { - ptr.b->StrToVal( s, &_error ); // call class SDAI_Binary::StrToVal() + ptr.b->StrToVal(s, &_error); // call class SDAI_Binary::StrToVal() break; } case STRING_TYPE: { - *( ptr.S ) = s; // using string class - don't need to declare space + *(ptr.S) = s; // using string class - don't need to declare space break; } case BOOLEAN_TYPE: case LOGICAL_TYPE: case ENUM_TYPE: { - ptr.e->StrToVal( s, &_error, nullable ); + ptr.e->StrToVal(s, &_error, nullable); break; } @@ -148,15 +149,15 @@ Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int a case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> StrToVal( s, &_error, - aDesc -> AggrElemTypeDescriptor(), - instances, addFileId ); + ptr.a -> StrToVal(s, &_error, + aDesc -> AggrElemTypeDescriptor(), + instances, addFileId); break; case SELECT_TYPE: - if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0 ) ) - != SEVERITY_NULL ) { - _error.AppendToDetailMsg( ptr.sh ->Error() ); + if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0)) + != SEVERITY_NULL) { + _error.AppendToDetailMsg(ptr.sh ->Error()); } break; @@ -164,7 +165,7 @@ Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int a case GENERIC_TYPE: default: // other cases are the same for StrToVal and file - return STEPread( in, instances, addFileId ); + return STEPread(in, instances, addFileId); } return _error.severity(); } @@ -187,13 +188,14 @@ Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int a ** value >= SEVERITY_WARNING means program can continue parsing input, ** value <= SEVERITY_INPUT_ERROR is fatal read error ******************************************************************/ -Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int addFileId, - const char * currSch, bool strict ) { +Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFileId, + const char *currSch, bool strict) +{ // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - return _redefAttr->STEPread( in, instances, addFileId, currSch ); + if(_redefAttr) { + return _redefAttr->STEPread(in, instances, addFileId, currSch); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -204,119 +206,119 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add in >> ws; // skip whitespace char c = in.peek(); - if( IsDerived() ) { - if( c == '*' ) { - in.get( c ); // take * off the istream - _error.severity( SEVERITY_NULL ); + if(IsDerived()) { + if(c == '*') { + in.get(c); // take * off the istream + _error.severity(SEVERITY_NULL); } else { - _error.severity( SEVERITY_WARNING ); - _error.AppendToDetailMsg( " WARNING: attribute '" ); - _error.AppendToDetailMsg( aDesc->Name() ); - _error.AppendToDetailMsg( "' of type '" ); - _error.AppendToDetailMsg( aDesc->TypeName() ); - _error.AppendToDetailMsg( "' - missing asterisk for derived attribute.\n" ); + _error.severity(SEVERITY_WARNING); + _error.AppendToDetailMsg(" WARNING: attribute '"); + _error.AppendToDetailMsg(aDesc->Name()); + _error.AppendToDetailMsg("' of type '"); + _error.AppendToDetailMsg(aDesc->TypeName()); + _error.AppendToDetailMsg("' - missing asterisk for derived attribute.\n"); } - CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); + CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); return _error.severity(); } PrimitiveType attrBaseType = NonRefType(); // check for NULL or derived attribute value, return if either - switch( c ) { + switch(c) { case '$': case ',': case ')': - if( c == '$' ) { + if(c == '$') { in.ignore(); - CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); + CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); } - if( Nullable() ) { - _error.severity( SEVERITY_NULL ); - } else if( !strict ) { + if(Nullable()) { + _error.severity(SEVERITY_NULL); + } else if(!strict) { std::string fillerValue; // we aren't in strict mode, so find out the type of the missing attribute and insert a suitable value. ErrorDescriptor err; //this will be discarded - switch( attrBaseType ) { + switch(attrBaseType) { case INTEGER_TYPE: { fillerValue = "'0',"; - ReadInteger( *( ptr.i ), fillerValue.c_str(), &err, ",)" ); + ReadInteger(*(ptr.i), fillerValue.c_str(), &err, ",)"); break; } case REAL_TYPE: { fillerValue = "'0.0',"; - ReadReal( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); + ReadReal(*(ptr.r), fillerValue.c_str(), &err, ",)"); break; } case NUMBER_TYPE: { fillerValue = "'0',"; - ReadNumber( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); + ReadNumber(*(ptr.r), fillerValue.c_str(), &err, ",)"); break; } case STRING_TYPE: { fillerValue = "'',"; - *( ptr.S ) = "''"; + *(ptr.S) = "''"; break; } default: { //do not know what a good value would be for other types - _error.severity( SEVERITY_INCOMPLETE ); - _error.AppendToDetailMsg( " missing and required\n" ); + _error.severity(SEVERITY_INCOMPLETE); + _error.AppendToDetailMsg(" missing and required\n"); return _error.severity(); } } - if( err.severity() <= SEVERITY_INCOMPLETE ) { - _error.severity( SEVERITY_BUG ); - _error.AppendToDetailMsg( " Error in STEPattribute::STEPread()\n" ); + if(err.severity() <= SEVERITY_INCOMPLETE) { + _error.severity(SEVERITY_BUG); + _error.AppendToDetailMsg(" Error in STEPattribute::STEPread()\n"); return _error.severity(); } //create a warning. SEVERITY_WARNING makes more sense to me, but is considered more severe than SEVERITY_INCOMPLETE - _error.severity( SEVERITY_USERMSG ); - _error.AppendToDetailMsg( " missing and required. For compatibility, replacing with " ); - _error.AppendToDetailMsg( fillerValue.substr( 0, fillerValue.length() - 1 ) ); - _error.AppendToDetailMsg( ".\n" ); + _error.severity(SEVERITY_USERMSG); + _error.AppendToDetailMsg(" missing and required. For compatibility, replacing with "); + _error.AppendToDetailMsg(fillerValue.substr(0, fillerValue.length() - 1)); + _error.AppendToDetailMsg(".\n"); } else { - _error.severity( SEVERITY_INCOMPLETE ); - _error.AppendToDetailMsg( " missing and required\n" ); + _error.severity(SEVERITY_INCOMPLETE); + _error.AppendToDetailMsg(" missing and required\n"); } return _error.severity(); } - switch( attrBaseType ) { + switch(attrBaseType) { case INTEGER_TYPE: { - ReadInteger( *( ptr.i ), in, &_error, ",)" ); + ReadInteger(*(ptr.i), in, &_error, ",)"); return _error.severity(); } case REAL_TYPE: { - ReadReal( *( ptr.r ), in, &_error, ",)" ); + ReadReal(*(ptr.r), in, &_error, ",)"); return _error.severity(); } case NUMBER_TYPE: { - ReadNumber( *( ptr.r ), in, &_error, ",)" ); + ReadNumber(*(ptr.r), in, &_error, ",)"); return _error.severity(); } case STRING_TYPE: { - ptr.S->STEPread( in, &_error ); - CheckRemainingInput( in, &_error, "string", ",)" ); + ptr.S->STEPread(in, &_error); + CheckRemainingInput(in, &_error, "string", ",)"); return _error.severity(); } case BINARY_TYPE: { // call class SDAI_Binary::STEPread() - ptr.b->STEPread( in, &_error ); - CheckRemainingInput( in, &_error, "binary", ",)" ); + ptr.b->STEPread(in, &_error); + CheckRemainingInput(in, &_error, "binary", ",)"); return _error.severity(); } case BOOLEAN_TYPE: { - ptr.e->STEPread( in, &_error, Nullable() ); - CheckRemainingInput( in, &_error, "boolean", ",)" ); + ptr.e->STEPread(in, &_error, Nullable()); + CheckRemainingInput(in, &_error, "boolean", ",)"); return _error.severity(); } case LOGICAL_TYPE: { - ptr.e->STEPread( in, &_error, Nullable() ); - CheckRemainingInput( in, &_error, "logical", ",)" ); + ptr.e->STEPread(in, &_error, Nullable()); + CheckRemainingInput(in, &_error, "logical", ",)"); return _error.severity(); } case ENUM_TYPE: { - ptr.e->STEPread( in, &_error, Nullable() ); - CheckRemainingInput( in, &_error, "enumeration", ",)" ); + ptr.e->STEPread(in, &_error, Nullable()); + CheckRemainingInput(in, &_error, "enumeration", ",)"); return _error.severity(); } case AGGREGATE_TYPE: @@ -324,49 +326,49 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - ptr.a->STEPread( in, &_error, - aDesc->AggrElemTypeDescriptor(), - instances, addFileId, currSch ); + ptr.a->STEPread(in, &_error, + aDesc->AggrElemTypeDescriptor(), + instances, addFileId, currSch); // cannot recover so give up and let STEPentity recover - if( _error.severity() < SEVERITY_WARNING ) { + if(_error.severity() < SEVERITY_WARNING) { return _error.severity(); } // check for garbage following the aggregate - CheckRemainingInput( in, &_error, "aggregate", ",)" ); + CheckRemainingInput(in, &_error, "aggregate", ",)"); return _error.severity(); } case ENTITY_TYPE: { - STEPentity * se = ReadEntityRef( in, &_error, ",)", instances, - addFileId ); - if( se != S_ENTITY_NULL ) { - if( EntityValidLevel( se, - aDesc->NonRefTypeDescriptor(), - &_error ) == SEVERITY_NULL ) { - *( ptr.c ) = se; + STEPentity *se = ReadEntityRef(in, &_error, ",)", instances, + addFileId); + if(se != S_ENTITY_NULL) { + if(EntityValidLevel(se, + aDesc->NonRefTypeDescriptor(), + &_error) == SEVERITY_NULL) { + *(ptr.c) = se; } else { - *( ptr.c ) = S_ENTITY_NULL; + *(ptr.c) = S_ENTITY_NULL; } } else { - *( ptr.c ) = S_ENTITY_NULL; + *(ptr.c) = S_ENTITY_NULL; } return _error.severity(); } case SELECT_TYPE: - if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0, - addFileId, currSch ) ) - != SEVERITY_NULL ) { - _error.AppendToDetailMsg( ptr.sh ->Error() ); + if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0, + addFileId, currSch)) + != SEVERITY_NULL) { + _error.AppendToDetailMsg(ptr.sh ->Error()); } - CheckRemainingInput( in, &_error, "select", ",)" ); + CheckRemainingInput(in, &_error, "select", ",)"); return _error.severity(); case GENERIC_TYPE: { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity( SEVERITY_BUG ); + _error.GreaterSeverity(SEVERITY_BUG); return _error.severity(); } @@ -376,7 +378,7 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add // bug cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity( SEVERITY_BUG ); + _error.GreaterSeverity(SEVERITY_BUG); return _error.severity(); } } @@ -388,61 +390,62 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add ** \returns the value of the attribute ** Status: complete 3/91 *********************************************************************/ -const char * STEPattribute::asStr( std::string & str, const char * currSch ) const { +const char *STEPattribute::asStr(std::string &str, const char *currSch) const +{ ostringstream ss; str.clear(); // The attribute has been derived by a subtype's attribute - if( IsDerived() ) { + if(IsDerived()) { str = "*"; - return const_cast( str.c_str() ); + return const_cast(str.c_str()); } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - return _redefAttr->asStr( str, currSch ); + if(_redefAttr) { + return _redefAttr->asStr(str, currSch); } - if( is_null() ) { + if(is_null()) { str = ""; - return const_cast( str.c_str() ); + return const_cast(str.c_str()); } - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - ss << *( ptr.i ); + ss << *(ptr.i); str += ss.str(); break; case NUMBER_TYPE: case REAL_TYPE: - ss.precision( ( int ) Real_Num_Precision ); - ss << *( ptr.r ); + ss.precision((int) Real_Num_Precision); + ss << *(ptr.r); str += ss.str(); break; case ENTITY_TYPE: // print instance id only if not empty pointer // and has value assigned - if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { + if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { break; } else { - ( *( ptr.c ) )->STEPwrite_reference( str ); + (*(ptr.c))->STEPwrite_reference(str); } break; case BINARY_TYPE: - if( !( ( ptr.b )->empty() ) ) { - ( ptr.b ) -> STEPwrite( str ); + if(!((ptr.b)->empty())) { + (ptr.b) -> STEPwrite(str); } break; case STRING_TYPE: - if( !( ( ptr.S )->empty() ) ) { - return ( ptr.S ) -> asStr( str ); + if(!((ptr.S)->empty())) { + return (ptr.S) -> asStr(str); } break; @@ -451,16 +454,16 @@ const char * STEPattribute::asStr( std::string & str, const char * currSch ) con case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - return ptr.a->asStr( str ) ; + return ptr.a->asStr(str) ; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return ptr.e -> asStr( str ); + return ptr.e -> asStr(str); case SELECT_TYPE: - ptr.sh -> STEPwrite( str, currSch ); - return const_cast( str.c_str() ); + ptr.sh -> STEPwrite(str, currSch); + return const_cast(str.c_str()); case REFERENCE_TYPE: case GENERIC_TYPE: @@ -470,9 +473,9 @@ const char * STEPattribute::asStr( std::string & str, const char * currSch ) con case UNKNOWN_TYPE: default: - return ( ptr.u -> asStr( str ) ); + return (ptr.u -> asStr(str)); } - return const_cast( str.c_str() ); + return const_cast(str.c_str()); } @@ -482,59 +485,60 @@ const char * STEPattribute::asStr( std::string & str, const char * currSch ) con ** \returns the value of the attribute ** Status: complete 3/91 *********************************************************************/ -std::string STEPattribute::asStr( const char * currSch ) const { +std::string STEPattribute::asStr(const char *currSch) const +{ ostringstream ss; std::string str; // The attribute has been derived by a subtype's attribute - if( IsDerived() ) { + if(IsDerived()) { str = "*"; return str; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - return _redefAttr->asStr( currSch ); + if(_redefAttr) { + return _redefAttr->asStr(currSch); } - if( is_null() ) { + if(is_null()) { return str; } - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - ss << *( ptr.i ); + ss << *(ptr.i); str += ss.str(); break; case NUMBER_TYPE: case REAL_TYPE: - ss.precision( ( int ) Real_Num_Precision ); - ss << *( ptr.r ); + ss.precision((int) Real_Num_Precision); + ss << *(ptr.r); str += ss.str(); break; case ENTITY_TYPE: // print instance id only if not empty pointer // and has value assigned - if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { + if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { break; } else { - ( *( ptr.c ) )->STEPwrite_reference( str ); + (*(ptr.c))->STEPwrite_reference(str); } break; case BINARY_TYPE: - if( !( ptr.b->empty() ) ) { - ptr.b->STEPwrite( str ); + if(!(ptr.b->empty())) { + ptr.b->STEPwrite(str); } break; case STRING_TYPE: - if( !( ( ptr.S )->empty() ) ) { - ptr.S->asStr( str ); + if(!((ptr.S)->empty())) { + ptr.S->asStr(str); } break; @@ -543,17 +547,17 @@ std::string STEPattribute::asStr( const char * currSch ) const { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a->asStr( str ); + ptr.a->asStr(str); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - ptr.e->asStr( str ); + ptr.e->asStr(str); break; case SELECT_TYPE: - ptr.sh->STEPwrite( str, currSch ); + ptr.sh->STEPwrite(str, currSch); break; case REFERENCE_TYPE: @@ -565,21 +569,22 @@ std::string STEPattribute::asStr( const char * currSch ) const { case UNKNOWN_TYPE: default: - ptr.u->asStr( str ); + ptr.u->asStr(str); } return str; } /// write '$' to out, put message in error, write brief error to stderr -void STEPattribute::STEPwriteError( ostream & out, unsigned int line, const char* desc ) { +void STEPattribute::STEPwriteError(ostream &out, unsigned int line, const char *desc) +{ out << "$"; cerr << "Internal error: " << __FILE__ << ":" << line << "\n" << _POC_ "\n"; - _error.GreaterSeverity( SEVERITY_BUG ); + _error.GreaterSeverity(SEVERITY_BUG); std::stringstream ss; ss << " Warning: attribute '" << Name() << " : " << TypeName() << "' " << desc << std::endl; - _error.AppendToUserMsg( ss.str() ); - _error.AppendToDetailMsg( ss.str() ); + _error.AppendToUserMsg(ss.str()); + _error.AppendToDetailMsg(ss.str()); } /** @@ -587,61 +592,62 @@ void STEPattribute::STEPwriteError( ostream & out, unsigned int line, const char * The output is in physical file format. * */ -void STEPattribute::STEPwrite( ostream & out, const char * currSch ) { +void STEPattribute::STEPwrite(ostream &out, const char *currSch) +{ // The attribute has been derived by a subtype's attribute - if( IsDerived() ) { + if(IsDerived()) { out << "*"; return; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - _redefAttr->STEPwrite( out ); + if(_redefAttr) { + _redefAttr->STEPwrite(out); return; } - if( is_null() ) { + if(is_null()) { out << "$"; return; } - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - out << *( ptr.i ); + out << *(ptr.i); break; case NUMBER_TYPE: case REAL_TYPE: { - WriteReal( *( ptr.r ), out ); + WriteReal(*(ptr.r), out); break; } case ENTITY_TYPE: // print instance id only if not empty pointer - if( ( ptr.c == 0 ) || ( *( ptr.c ) == 0 ) || + if((ptr.c == 0) || (*(ptr.c) == 0) || // no value was assigned <-- this would be a BUG - ( *( ptr.c ) == S_ENTITY_NULL ) ) { - STEPwriteError( out, __LINE__, "is null and shouldn't be." ); + (*(ptr.c) == S_ENTITY_NULL)) { + STEPwriteError(out, __LINE__, "is null and shouldn't be."); } else { - ( *( ptr.c ) ) -> STEPwrite_reference( out ); + (*(ptr.c)) -> STEPwrite_reference(out); } break; case STRING_TYPE: // if null pointer or pointer to a string of length zero - if( ptr.S ) { - ( ptr.S ) -> STEPwrite( out ); + if(ptr.S) { + (ptr.S) -> STEPwrite(out); } else { - STEPwriteError( out, __LINE__, "should be pointing at an SDAI_String." ); + STEPwriteError(out, __LINE__, "should be pointing at an SDAI_String."); } break; case BINARY_TYPE: // if null pointer or pointer to a string of length zero - if( ptr.b ) { - ( ptr.b ) -> STEPwrite( out ); + if(ptr.b) { + (ptr.b) -> STEPwrite(out); } else { - STEPwriteError( out, __LINE__, "should be pointing at an SDAI_Binary." ); + STEPwriteError(out, __LINE__, "should be pointing at an SDAI_Binary."); } break; @@ -650,53 +656,54 @@ void STEPattribute::STEPwrite( ostream & out, const char * currSch ) { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> STEPwrite( out, currSch ); + ptr.a -> STEPwrite(out, currSch); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - if( ptr.e ) { - ptr.e -> STEPwrite( out ); + if(ptr.e) { + ptr.e -> STEPwrite(out); } else { - STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Enum class." ); + STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Enum class."); } break; case SELECT_TYPE: - if( ptr.sh ) { - ptr.sh -> STEPwrite( out, currSch ); + if(ptr.sh) { + ptr.sh -> STEPwrite(out, currSch); } else { - STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Select class." ); + STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Select class."); } break; case REFERENCE_TYPE: case GENERIC_TYPE: cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity( SEVERITY_BUG ); + _error.GreaterSeverity(SEVERITY_BUG); return; case UNKNOWN_TYPE: default: - ptr.u -> STEPwrite( out ); + ptr.u -> STEPwrite(out); break; } } -void STEPattribute::ShallowCopy( const STEPattribute * sa ) { +void STEPattribute::ShallowCopy(const STEPattribute *sa) +{ _mustDeletePtr = false; aDesc = sa->aDesc; refCount = 0; _derive = sa->_derive; _redefAttr = sa->_redefAttr; - if( _redefAttr ) { - _redefAttr->ShallowCopy( sa ); + if(_redefAttr) { + _redefAttr->ShallowCopy(sa); } //Should we just use memcpy()? That would be a true shallowCopy - switch( sa->NonRefType() ) { + switch(sa->NonRefType()) { case INTEGER_TYPE: ptr.i = sa->ptr.i; break; @@ -717,7 +724,7 @@ void STEPattribute::ShallowCopy( const STEPattribute * sa ) { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - switch( sa->BaseType() ) { + switch(sa->BaseType()) { case sdaiAGGR: ptr.a = new GenericAggregate; break; @@ -751,11 +758,11 @@ void STEPattribute::ShallowCopy( const STEPattribute * sa ) { break; default: std::cerr << "WARNING: Reached default case for BaseType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; + << "ShallowCopy(). New attribute may be invalid." << std::endl; ptr.a = new STEPaggregate; break; } - ptr.a->ShallowCopy( *( sa->ptr.a ) ); + ptr.a->ShallowCopy(*(sa->ptr.a)); _mustDeletePtr = true; break; case SELECT_TYPE: @@ -763,12 +770,12 @@ void STEPattribute::ShallowCopy( const STEPattribute * sa ) { break; case BOOLEAN_TYPE: ptr.e = new SDAI_BOOLEAN; - ptr.e->put( sa->ptr.e->asInt() ); + ptr.e->put(sa->ptr.e->asInt()); _mustDeletePtr = true; break; case LOGICAL_TYPE: ptr.e = new SDAI_LOGICAL; - ptr.e->put( sa->ptr.e->asInt() ); + ptr.e->put(sa->ptr.e->asInt()); _mustDeletePtr = true; break; @@ -776,8 +783,8 @@ void STEPattribute::ShallowCopy( const STEPattribute * sa ) { case ENUM_TYPE: default: std::cerr << "WARNING: Reached default case for NonRefType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; - memcpy( & ptr, & ( sa->ptr ), sizeof( sa->ptr ) ); + << "ShallowCopy(). New attribute may be invalid." << std::endl; + memcpy(& ptr, & (sa->ptr), sizeof(sa->ptr)); break; } } @@ -787,25 +794,26 @@ void STEPattribute::ShallowCopy( const STEPattribute * sa ) { * will exist in member variable ptr but SDAI_string will be told to report * as not containing a value (even a value of no chars). */ -Severity STEPattribute::set_null() { - if( _redefAttr ) { +Severity STEPattribute::set_null() +{ + if(_redefAttr) { return _redefAttr->set_null(); } - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - *( ptr.i ) = S_INT_NULL; + *(ptr.i) = S_INT_NULL; break; case NUMBER_TYPE: - *( ptr.r ) = S_NUMBER_NULL; + *(ptr.r) = S_NUMBER_NULL; break; case REAL_TYPE: - *( ptr.r ) = S_REAL_NULL; + *(ptr.r) = S_REAL_NULL; break; case ENTITY_TYPE: - *( ptr.c ) = S_ENTITY_NULL; + *(ptr.c) = S_ENTITY_NULL; break; case STRING_TYPE: @@ -846,11 +854,11 @@ Severity STEPattribute::set_null() { 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 ); + _error.AppendToDetailMsg(err.str()); + _error.GreaterSeverity(SEVERITY_WARNING); return SEVERITY_WARNING; } - if( Nullable() ) { + if(Nullable()) { return SEVERITY_NULL; } else { return SEVERITY_INCOMPLETE; @@ -861,31 +869,32 @@ Severity STEPattribute::set_null() { * For a string value this reports whether the string exists (as reported by * SDAI_String ) not whether SDAI_String contains a null string. */ -bool STEPattribute::is_null() const { - if( _redefAttr ) { +bool STEPattribute::is_null() const +{ + if(_redefAttr) { return _redefAttr->is_null(); } /* for NUMBER_TYPE and REAL_TYPE, we want an exact comparison. however, doing so causes a compiler warning. * workaround is to use memcmp. need a variable, but can't declare it within the switch without errors. */ SDAI_Real z; - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - return ( *( ptr.i ) == S_INT_NULL ); + return (*(ptr.i) == S_INT_NULL); case NUMBER_TYPE: z = S_NUMBER_NULL; - return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); + return (0 == memcmp(ptr.r, &z, sizeof z)); case REAL_TYPE: z = S_REAL_NULL; - return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); + return (0 == memcmp(ptr.r, &z, sizeof z)); case ENTITY_TYPE: - return ( *( ptr.c ) == S_ENTITY_NULL ); + return (*(ptr.c) == S_ENTITY_NULL); case STRING_TYPE: - return ( *( ptr.S ) == S_STRING_NULL ); + return (*(ptr.S) == S_STRING_NULL); case BINARY_TYPE: return ptr.b->empty(); @@ -895,16 +904,16 @@ bool STEPattribute::is_null() const { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return ( ptr.a -> is_null() ); + return (ptr.a -> is_null()); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return ( ptr.e -> is_null() ); + return (ptr.e -> is_null()); case SELECT_TYPE: - return( ptr.sh->is_null() ); + return(ptr.sh->is_null()); case REFERENCE_TYPE: case GENERIC_TYPE: @@ -912,92 +921,104 @@ bool STEPattribute::is_null() const { return true; case UNKNOWN_TYPE: default: - return ( ptr.u -> is_null() ); + return (ptr.u -> is_null()); } } // these get the attr value -SDAI_Integer * STEPattribute::Integer(){ - if( NonRefType() == INTEGER_TYPE ) { +SDAI_Integer *STEPattribute::Integer() +{ + if(NonRefType() == INTEGER_TYPE) { return ptr.i; } return 0; } -SDAI_Real * STEPattribute::Number() { - if( NonRefType() == NUMBER_TYPE ) { +SDAI_Real *STEPattribute::Number() +{ + if(NonRefType() == NUMBER_TYPE) { return ptr.r; } return 0; } -SDAI_Real * STEPattribute::Real() { - if( NonRefType() == REAL_TYPE ) { +SDAI_Real *STEPattribute::Real() +{ + if(NonRefType() == REAL_TYPE) { return ptr.r; } return 0; } -SDAI_Application_instance * STEPattribute::Entity() { - if( NonRefType() == ENTITY_TYPE ) { - return *( ptr.c ); +SDAI_Application_instance *STEPattribute::Entity() +{ + if(NonRefType() == ENTITY_TYPE) { + return *(ptr.c); } return 0; } -SDAI_String * STEPattribute::String() { - if( NonRefType() == STRING_TYPE ) { +SDAI_String *STEPattribute::String() +{ + if(NonRefType() == STRING_TYPE) { return ptr.S; } return 0; } -SDAI_Binary * STEPattribute::Binary() { - if( NonRefType() == BINARY_TYPE ) { +SDAI_Binary *STEPattribute::Binary() +{ + if(NonRefType() == BINARY_TYPE) { return ptr.b; } return 0; } -STEPaggregate * STEPattribute::Aggregate() { - if( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) - || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ) { +STEPaggregate *STEPattribute::Aggregate() +{ + if((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) + || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)) { return ptr.a; } return 0; } -SDAI_BOOLEAN * STEPattribute::Boolean() { - if( NonRefType() == BOOLEAN_TYPE ) { - return ( SDAI_BOOLEAN * ) ptr.e; +SDAI_BOOLEAN *STEPattribute::Boolean() +{ + if(NonRefType() == BOOLEAN_TYPE) { + return (SDAI_BOOLEAN *) ptr.e; } return 0; } -SDAI_LOGICAL * STEPattribute::Logical() { - if( NonRefType() == LOGICAL_TYPE ) { - return ( SDAI_LOGICAL * ) ptr.e; +SDAI_LOGICAL *STEPattribute::Logical() +{ + if(NonRefType() == LOGICAL_TYPE) { + return (SDAI_LOGICAL *) ptr.e; } return 0; } -SDAI_Enum * STEPattribute::Enum() { - if( NonRefType() == ENUM_TYPE ) { +SDAI_Enum *STEPattribute::Enum() +{ + if(NonRefType() == ENUM_TYPE) { return ptr.e; } return 0; } -SDAI_Select * STEPattribute::Select() { - if( NonRefType() == SELECT_TYPE ) { +SDAI_Select *STEPattribute::Select() +{ + if(NonRefType() == SELECT_TYPE) { return ptr.sh; } return 0; } -SCLundefined * STEPattribute::Undefined() { - if( ( NonRefType() != REFERENCE_TYPE ) && ( NonRefType() != GENERIC_TYPE ) ) { +SCLundefined *STEPattribute::Undefined() +{ + if((NonRefType() != REFERENCE_TYPE) && (NonRefType() != GENERIC_TYPE)) { return ptr.u; } return 0; @@ -1005,115 +1026,127 @@ SCLundefined * STEPattribute::Undefined() { // these set the attr value -void STEPattribute::Integer( SDAI_Integer * n ) { - assert( NonRefType() == INTEGER_TYPE ); - if( ptr.i ) { - *( ptr.i ) = * n; +void STEPattribute::Integer(SDAI_Integer *n) +{ + assert(NonRefType() == INTEGER_TYPE); + if(ptr.i) { + *(ptr.i) = * n; } else { ptr.i = n; } } -void STEPattribute::Real( SDAI_Real * n ) { - assert( NonRefType() == REAL_TYPE ); - if( ptr.r ) { - *( ptr.r ) = * n; +void STEPattribute::Real(SDAI_Real *n) +{ + assert(NonRefType() == REAL_TYPE); + if(ptr.r) { + *(ptr.r) = * n; } else { ptr.r = n; } } -void STEPattribute::Number( SDAI_Real * n ) { - assert( NonRefType() == NUMBER_TYPE ); - if( ptr.r ) { - *( ptr.r ) = * n; +void STEPattribute::Number(SDAI_Real *n) +{ + assert(NonRefType() == NUMBER_TYPE); + if(ptr.r) { + *(ptr.r) = * n; } else { ptr.r = n; } } -void STEPattribute::String( SDAI_String * str ) { - assert( NonRefType() == STRING_TYPE ); - if( ptr.S ) { - *( ptr.S ) = * str; +void STEPattribute::String(SDAI_String *str) +{ + assert(NonRefType() == STRING_TYPE); + if(ptr.S) { + *(ptr.S) = * str; } else { ptr.S = str; } } -void STEPattribute::Binary( SDAI_Binary * bin ) { - assert( NonRefType() == BINARY_TYPE ); - if( ptr.b ) { - *( ptr.b ) = * bin; +void STEPattribute::Binary(SDAI_Binary *bin) +{ + assert(NonRefType() == BINARY_TYPE); + if(ptr.b) { + *(ptr.b) = * bin; } else { ptr.b = bin; } } -void STEPattribute::Entity( SDAI_Application_instance * ent ) { - assert( NonRefType() == ENTITY_TYPE ); - if( ptr.c ) { +void STEPattribute::Entity(SDAI_Application_instance *ent) +{ + assert(NonRefType() == ENTITY_TYPE); + if(ptr.c) { delete ptr.c; } - ptr.c = new (SDAI_Application_instance * ); - *( ptr.c ) = ent; + ptr.c = new(SDAI_Application_instance *); + *(ptr.c) = ent; } -void STEPattribute::Aggregate( STEPaggregate * aggr ) { - assert( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) - || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ); - if( ptr.a ) { - *( ptr.a ) = * aggr; +void STEPattribute::Aggregate(STEPaggregate *aggr) +{ + assert((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) + || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)); + if(ptr.a) { + *(ptr.a) = * aggr; } else { ptr.a = aggr; } } -void STEPattribute::Enum( SDAI_Enum * enu ) { - assert( NonRefType() == ENUM_TYPE ); - if( ptr.e ) { +void STEPattribute::Enum(SDAI_Enum *enu) +{ + assert(NonRefType() == ENUM_TYPE); + if(ptr.e) { ptr.e->set_null(); - *( ptr.e ) = * enu; + *(ptr.e) = * enu; } else { ptr.e = enu; } } -void STEPattribute::Logical( SDAI_LOGICAL * log ) { - assert( NonRefType() == LOGICAL_TYPE ); - if( ptr.e ) { +void STEPattribute::Logical(SDAI_LOGICAL *log) +{ + assert(NonRefType() == LOGICAL_TYPE); + if(ptr.e) { ptr.e->set_null(); - *( ptr.e ) = * log; + *(ptr.e) = * log; } else { ptr.e = log; } } -void STEPattribute::Boolean( SDAI_BOOLEAN * boo ) { - assert( NonRefType() == BOOLEAN_TYPE ); - if( ptr.e ) { +void STEPattribute::Boolean(SDAI_BOOLEAN *boo) +{ + assert(NonRefType() == BOOLEAN_TYPE); + if(ptr.e) { ptr.e->set_null(); - *( ptr.e ) = *boo; + *(ptr.e) = *boo; } else { ptr.e = boo; } } -void STEPattribute::Select( SDAI_Select * sel ) { - assert( NonRefType() == SELECT_TYPE ); - if( ptr.sh ) { +void STEPattribute::Select(SDAI_Select *sel) +{ + assert(NonRefType() == SELECT_TYPE); + if(ptr.sh) { ptr.sh->set_null(); - *( ptr.sh ) = * sel; + *(ptr.sh) = * sel; } else { ptr.sh = sel; } } -void STEPattribute::Undefined( SCLundefined * undef ) { +void STEPattribute::Undefined(SCLundefined *undef) +{ //FIXME is this right, or is the Undefined() above right? - assert( NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE ); - if( ptr.u ) { - *( ptr.u ) = * undef; + assert(NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE); + if(ptr.u) { + *(ptr.u) = * undef; } else { ptr.u = undef; } @@ -1124,12 +1157,13 @@ void STEPattribute::Undefined( SCLundefined * undef ) { * ignores _error and refCount, since those are ancillary * \return true if equal */ -bool operator == ( const STEPattribute & a1, const STEPattribute & a2 ) { - if( & a1 == & a2 ) { +bool operator == (const STEPattribute &a1, const STEPattribute &a2) +{ + if(& a1 == & a2) { return true; } - if( a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr ){ - if( 0 == memcmp( & a1.ptr, & a2.ptr, sizeof( a1.ptr ) ) ) { + if(a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr) { + if(0 == memcmp(& a1.ptr, & a2.ptr, sizeof(a1.ptr))) { return true; } else { //ptr differs between a1 and a2, but contents aren't necessarily different @@ -1143,12 +1177,14 @@ bool operator == ( const STEPattribute & a1, const STEPattribute & a2 ) { * ignores _error and refCount, since those are ancillary * \return true if not equal */ -bool operator != ( const STEPattribute & a1, const STEPattribute & a2 ) { - return !( a1 == a2 ); +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 ) { +bool sameADesc(const STEPattribute &a1, const STEPattribute &a2) +{ return a1.aDesc == a2.aDesc; } @@ -1160,84 +1196,85 @@ 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, InstMgrBase * im, bool clearError ) { - if( clearError ) { +Severity STEPattribute::ValidLevel(const char *attrValue, ErrorDescriptor *error, InstMgrBase *im, bool clearError) +{ + if(clearError) { ClearErrorMsg(); } - if( _redefAttr ) { - return _redefAttr->ValidLevel( attrValue, error, im, clearError ); + if(_redefAttr) { + return _redefAttr->ValidLevel(attrValue, error, im, clearError); } bool optional = Nullable(); - if( !attrValue ) { - if( optional ) { + if(!attrValue) { + if(optional) { return error->severity(); } else { - error->GreaterSeverity( SEVERITY_INCOMPLETE ); + error->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } } - if( attrValue[0] == '\0' ) { - if( NonRefType() == STRING_TYPE ) { + if(attrValue[0] == '\0') { + if(NonRefType() == STRING_TYPE) { // this is interpreted as a string with no value i.e. "". // Thus if it exists it has to be valid. return SEVERITY_NULL; } - if( optional ) { + if(optional) { return error->severity(); } else { - error->GreaterSeverity( SEVERITY_INCOMPLETE ); + error->GreaterSeverity(SEVERITY_INCOMPLETE); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if( IsDerived() ) { - if( !strcmp( attrValue, "*" ) ) { + if(IsDerived()) { + if(!strcmp(attrValue, "*")) { return SEVERITY_NULL; } else { - _error.AppendToDetailMsg( "attr is derived - value not permitted\n" ); - return _error.severity( SEVERITY_INPUT_ERROR ); + _error.AppendToDetailMsg("attr is derived - value not permitted\n"); + return _error.severity(SEVERITY_INPUT_ERROR); } } - switch( NonRefType() ) { + switch(NonRefType()) { case INTEGER_TYPE: - return IntValidLevel( attrValue, error, clearError, optional, 0 ); + return IntValidLevel(attrValue, error, clearError, optional, 0); case STRING_TYPE: // if a value exists (checked above) then that is the string value return SEVERITY_NULL; case REAL_TYPE: - return RealValidLevel( attrValue, error, clearError, optional, 0 ); + return RealValidLevel(attrValue, error, clearError, optional, 0); case NUMBER_TYPE: - return NumberValidLevel( attrValue, error, clearError, optional, 0 ); + return NumberValidLevel(attrValue, error, clearError, optional, 0); case ENTITY_TYPE: - return EntityValidLevel( attrValue, - aDesc->NonRefTypeDescriptor(), - error, im, 0 ); + return EntityValidLevel(attrValue, + aDesc->NonRefTypeDescriptor(), + error, im, 0); case BINARY_TYPE: - return ptr.b->BinaryValidLevel( attrValue, &_error, optional, 0 ); + return ptr.b->BinaryValidLevel(attrValue, &_error, optional, 0); case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return ptr.a->AggrValidLevel( attrValue, error, - aDesc->AggrElemTypeDescriptor(), im, - optional, 0, 0, 0 ); + return ptr.a->AggrValidLevel(attrValue, error, + aDesc->AggrElemTypeDescriptor(), im, + optional, 0, 0, 0); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return ptr.e->EnumValidLevel( attrValue, error, optional, 0, 0, 1 ); + return ptr.e->EnumValidLevel(attrValue, error, optional, 0, 0, 1); case SELECT_TYPE: - return ptr.sh->SelectValidLevel( attrValue, error, im ); + return ptr.sh->SelectValidLevel(attrValue, error, im); default: cerr << "Internal error: " << __FILE__ << __LINE__ @@ -1251,8 +1288,9 @@ Severity STEPattribute::ValidLevel( const char * attrValue, ErrorDescriptor * er ** \param a -- attribute to output ** Description: overloads the output operator to print an attribute ******************************************************************/ -ostream & operator<< ( ostream & out, STEPattribute & a ) { - a.STEPwrite( out ); +ostream &operator<< (ostream &out, STEPattribute &a) +{ + a.STEPwrite(out); return out; } @@ -1262,22 +1300,23 @@ ostream & operator<< ( ostream & out, STEPattribute & a ) { * Aggregates, and SDAI_Strings which don't know they are a STEPattribute * value. ******************************************************************/ -void STEPattribute::AddErrorInfo() { +void STEPattribute::AddErrorInfo() +{ char errStr[BUFSIZ]; errStr[0] = '\0'; - if( SEVERITY_INPUT_ERROR < _error.severity() && - _error.severity() < SEVERITY_NULL ) { - sprintf( errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); - _error.PrependToDetailMsg( errStr ); - } else if( _error.severity() == SEVERITY_INPUT_ERROR ) { - sprintf( errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); - _error.PrependToDetailMsg( errStr ); - } else if( _error.severity() <= SEVERITY_BUG ) { - sprintf( errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); - _error.PrependToDetailMsg( errStr ); + if(SEVERITY_INPUT_ERROR < _error.severity() && + _error.severity() < SEVERITY_NULL) { + sprintf(errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type()); + _error.PrependToDetailMsg(errStr); + } else if(_error.severity() == SEVERITY_INPUT_ERROR) { + sprintf(errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type()); + _error.PrependToDetailMsg(errStr); + } else if(_error.severity() <= SEVERITY_BUG) { + sprintf(errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type()); + _error.PrependToDetailMsg(errStr); } } @@ -1286,34 +1325,35 @@ void STEPattribute::AddErrorInfo() { * if it hits one of StopChars it puts it back. * RETURNS: the last char it read. ******************************************************************/ -char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { +char STEPattribute::SkipBadAttr(istream &in, char *StopChars) +{ ios_base::fmtflags flbuf = in.flags(); - in.unsetf( ios::skipws ); // turn skipping whitespace off + in.unsetf(ios::skipws); // turn skipping whitespace off // read bad data until end of this attribute or entity. - char * foundCh = 0; + char *foundCh = 0; char c = '\0'; char errStr[BUFSIZ]; errStr[0] = '\0'; - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.GreaterSeverity(SEVERITY_WARNING); in >> c; - while( !in.eof() && !( foundCh = strchr( StopChars, c ) ) ) { + while(!in.eof() && !(foundCh = strchr(StopChars, c))) { in >> c; } - if( in.eof() ) { - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); - sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), - "Unexpected EOF when skipping bad attr value" ); - _error.AppendToDetailMsg( errStr ); + if(in.eof()) { + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), + "Unexpected EOF when skipping bad attr value"); + _error.AppendToDetailMsg(errStr); } else { - sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), "Invalid value" ); - _error.AppendToDetailMsg( errStr ); + sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), "Invalid value"); + _error.AppendToDetailMsg(errStr); } - in.putback( c ); - in.flags( flbuf ); // set skip whitespace to its original state + in.putback(c); + in.flags(flbuf); // set skip whitespace to its original state return c; } @@ -1334,9 +1374,10 @@ char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { /// This is needed so that STEPattribute's can be passed as references to inline functions /// NOTE this code only does shallow copies. It may be necessary to do more, in which case /// the destructor and assignment operator will also need examined. -STEPattribute::STEPattribute( const STEPattribute & a ) : _derive( a._derive ), _mustDeletePtr( false ), -_redefAttr( a._redefAttr ), aDesc( a.aDesc ), refCount( a.refCount ) { - ShallowCopy( & a ); +STEPattribute::STEPattribute(const STEPattribute &a) : _derive(a._derive), _mustDeletePtr(false), + _redefAttr(a._redefAttr), aDesc(a.aDesc), refCount(a.refCount) +{ + ShallowCopy(& a); //NOTE may need to do a deep copy for the following types since they are classes /* @@ -1361,95 +1402,105 @@ _redefAttr( a._redefAttr ), aDesc( a.aDesc ), refCount( a.refCount ) { * * default: * break; -} -*/ + } + */ } /// INTEGER -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.i = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// BINARY -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.b = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// STRING -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_String * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_String *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.S = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// REAL & NUMBER -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Real *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.r = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// ENTITY -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance * *p ): -_derive( false ), _mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p): + _derive(false), _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.c = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// AGGREGATE -STEPattribute::STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, STEPaggregate *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.a = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// ENUMERATION and Logical -STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.e = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// SELECT -STEPattribute::STEPattribute( const class AttrDescriptor & d, class SDAI_Select * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, class SDAI_Select *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.sh = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// UNDEFINED -STEPattribute::STEPattribute( const class AttrDescriptor & d, SCLundefined * p ): _derive( false ), -_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { +STEPattribute::STEPattribute(const class AttrDescriptor &d, SCLundefined *p): _derive(false), + _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) +{ ptr.u = p; - assert( &d ); //ensure that the AttrDescriptor is not a null pointer + assert(&d); //ensure that the AttrDescriptor is not a null pointer } /// the destructor conditionally deletes the object in ptr -STEPattribute::~STEPattribute() { - if( _mustDeletePtr ) { - switch( NonRefType() ) { +STEPattribute::~STEPattribute() +{ + if(_mustDeletePtr) { + switch(NonRefType()) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if( ptr.a ) { + if(ptr.a) { delete ptr.a; ptr.a = 0; } break; case BOOLEAN_TYPE: - if( ptr.e ) { - delete ( SDAI_BOOLEAN * ) ptr.e; + if(ptr.e) { + delete(SDAI_BOOLEAN *) ptr.e; ptr.e = 0; } case LOGICAL_TYPE: - if( ptr.e ) { - delete ( SDAI_LOGICAL * ) ptr.e; + if(ptr.e) { + delete(SDAI_LOGICAL *) ptr.e; ptr.e = 0; } break; @@ -1460,50 +1511,57 @@ STEPattribute::~STEPattribute() { } /// name is the same even if redefined -const char * STEPattribute::Name() const { +const char *STEPattribute::Name() const +{ return aDesc->Name(); } -const char * STEPattribute::TypeName() const { - if( _redefAttr ) { +const char *STEPattribute::TypeName() const +{ + if(_redefAttr) { return _redefAttr->TypeName(); } return aDesc->TypeName().c_str(); } -BASE_TYPE STEPattribute::Type() const { - if( _redefAttr ) { +BASE_TYPE STEPattribute::Type() const +{ + if(_redefAttr) { return _redefAttr->Type(); } return aDesc->Type(); } -BASE_TYPE STEPattribute::NonRefType() const { - if( _redefAttr ) { +BASE_TYPE STEPattribute::NonRefType() const +{ + if(_redefAttr) { return _redefAttr->NonRefType(); - } else if( aDesc ) { + } else if(aDesc) { return aDesc->NonRefType(); } return UNKNOWN_TYPE; } -BASE_TYPE STEPattribute::BaseType() const { - if( _redefAttr ) { +BASE_TYPE STEPattribute::BaseType() const +{ + if(_redefAttr) { return _redefAttr->BaseType(); } return aDesc->BaseType(); } -const TypeDescriptor * STEPattribute::ReferentType() const { - if( _redefAttr ) { +const TypeDescriptor *STEPattribute::ReferentType() const +{ + if(_redefAttr) { return _redefAttr->ReferentType(); } return aDesc->ReferentType(); } -bool STEPattribute::Nullable() const { - if( _redefAttr ) { +bool STEPattribute::Nullable() const +{ + if(_redefAttr) { return _redefAttr->Nullable(); } - return ( aDesc->Optionality().asInt() == LTrue ); + return (aDesc->Optionality().asInt() == LTrue); } diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index dc5ff9ae1..63d2abecf 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -37,114 +37,121 @@ class EntityDescriptor; #include -extern SC_CORE_EXPORT int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ); +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, - InstMgrBase * instances, int addFileId ); +extern SC_CORE_EXPORT SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, + InstMgrBase *instances, int addFileId); -extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList, - InstMgrBase * instances, int addFileId ); +extern SC_CORE_EXPORT SDAI_Application_instance *ReadEntityRef(const char *s, ErrorDescriptor *err, const char *tokenList, + 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) - ErrorDescriptor * err ); +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) + ErrorDescriptor *err); -extern SC_CORE_EXPORT Severity EntityValidLevel( const char * attrValue, ///< string containing entity ref - const TypeDescriptor * ed, /**< entity type that entity in attrValue (if it exists) needs +extern SC_CORE_EXPORT Severity EntityValidLevel(const char *attrValue, ///< string containing entity ref + const TypeDescriptor *ed, /**< entity type that entity in attrValue (if it exists) needs * to match. (this must be an EntityDescriptor) */ - ErrorDescriptor * err, InstMgrBase * im, int clearError ); + ErrorDescriptor *err, InstMgrBase *im, int clearError); //////////////////// //////////////////// -extern SC_CORE_EXPORT SDAI_Application_instance * STEPread_reference( const char * s, ErrorDescriptor * err, - InstMgrBase * instances, int addFileId ); +extern SC_CORE_EXPORT SDAI_Application_instance *STEPread_reference(const char *s, ErrorDescriptor *err, + InstMgrBase *instances, int addFileId); //////////////////// -extern SC_CORE_EXPORT int QuoteInString( istream & in ); +extern SC_CORE_EXPORT int QuoteInString(istream &in); -extern SC_CORE_EXPORT void AppendChar( char c, int & index, char *& s, int & sSize ); +extern SC_CORE_EXPORT void AppendChar(char c, int &index, char *&s, int &sSize); -extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); -extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); -extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); -class SC_CORE_EXPORT STEPattribute { - friend ostream & operator<< ( ostream &, STEPattribute & ); +class SC_CORE_EXPORT STEPattribute +{ + friend ostream &operator<< (ostream &, STEPattribute &); friend class SDAI_Application_instance; public: - /** \union ptr - ** You know which of these to use based on the return value of - ** NonRefType() - see below. BASE_TYPE is defined in baseType.h - ** This variable points to an appropriate member variable in the entity - ** class in the generated schema class library (the entity class is - ** inherited from SDAI_Application_instance) - */ + /** \union ptr + ** You know which of these to use based on the return value of + ** NonRefType() - see below. BASE_TYPE is defined in baseType.h + ** This variable points to an appropriate member variable in the entity + ** class in the generated schema class library (the entity class is + ** inherited from SDAI_Application_instance) + */ union attrUnion { - SDAI_String * S; // STRING_TYPE - SDAI_Integer * i; // INTEGER_TYPE (Integer is a long int) - SDAI_Binary * b; // BINARY_TYPE - SDAI_Real * r; // REAL_TYPE and NUMBER_TYPE (Real is a double) - SDAI_Application_instance * * c; // ENTITY_TYPE - STEPaggregate * a; // AGGREGATE_TYPE - SDAI_Enum * e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE - SDAI_Select * sh; // SELECT_TYPE - SCLundefined * u; // UNKNOWN_TYPE - void * p; + SDAI_String *S; // STRING_TYPE + SDAI_Integer *i; // INTEGER_TYPE (Integer is a long int) + SDAI_Binary *b; // BINARY_TYPE + SDAI_Real *r; // REAL_TYPE and NUMBER_TYPE (Real is a double) + SDAI_Application_instance * *c; // ENTITY_TYPE + STEPaggregate *a; // AGGREGATE_TYPE + SDAI_Enum *e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE + SDAI_Select *sh; // SELECT_TYPE + SCLundefined *u; // UNKNOWN_TYPE + void *p; } ptr; - const AttrDescriptor * aDesc; + const AttrDescriptor *aDesc; protected: bool _derive; bool _mustDeletePtr; ///if a member uses new to create an object in ptr ErrorDescriptor _error; - STEPattribute * _redefAttr; + STEPattribute *_redefAttr; int refCount; - char SkipBadAttr( istream & in, char * StopChars ); + char SkipBadAttr(istream &in, char *StopChars); void AddErrorInfo(); - void STEPwriteError( ostream& out, unsigned int line, const char* desc ); + void STEPwriteError(ostream &out, unsigned int line, const char *desc); public: - void incrRefCount() { + void incrRefCount() + { ++ refCount; } - void decrRefCount() { + void decrRefCount() + { -- refCount; } - int getRefCount() { + int getRefCount() + { return refCount; } - const AttrDescriptor * getADesc() { + const AttrDescriptor *getADesc() + { return aDesc; } - void Derive( bool n = true ) { + void Derive(bool n = true) + { _derive = n; } - void RedefiningAttr( STEPattribute * a ) { + void RedefiningAttr(STEPattribute *a) + { _redefAttr = a; } ///////////// Read, Write, Assign attr value - Severity StrToVal( const char * s, InstMgrBase * instances = 0, - int addFileId = 0 ); - Severity STEPread( istream & in = cin, InstMgrBase * instances = 0, - int addFileId = 0, const char * currSch = NULL, bool strict = true ); + Severity StrToVal(const char *s, InstMgrBase *instances = 0, + int addFileId = 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 - string asStr( const char * currSch = 0 ) const; - const char * asStr( std::string &, const char * = 0 ) const; + string asStr(const char *currSch = 0) const; + const char *asStr(std::string &, const char * = 0) const; /// put the attr value in ostream - void STEPwrite( ostream & out = cout, const char * currSch = 0 ); - void ShallowCopy( const STEPattribute * sa ); + void STEPwrite(ostream &out = cout, const char *currSch = 0); + void ShallowCopy(const STEPattribute *sa); Severity set_null(); @@ -157,18 +164,18 @@ class SC_CORE_EXPORT STEPattribute { * \sa is_null() */ ///@{ - SDAI_Integer * Integer(); - SDAI_Real * Real(); - SDAI_Real * Number(); - SDAI_String * String(); - SDAI_Binary * Binary(); - SDAI_Application_instance * Entity(); - STEPaggregate * Aggregate(); - SDAI_Enum * Enum(); - SDAI_LOGICAL * Logical(); - SDAI_BOOLEAN * Boolean(); - SDAI_Select * Select(); - SCLundefined * Undefined(); + SDAI_Integer *Integer(); + SDAI_Real *Real(); + SDAI_Real *Number(); + SDAI_String *String(); + SDAI_Binary *Binary(); + SDAI_Application_instance *Entity(); + STEPaggregate *Aggregate(); + SDAI_Enum *Enum(); + SDAI_LOGICAL *Logical(); + SDAI_BOOLEAN *Boolean(); + SDAI_Select *Select(); + SCLundefined *Undefined(); ///@} /** @@ -179,81 +186,86 @@ class SC_CORE_EXPORT STEPattribute { * what about ptr.c, which is ( SDAI_Application_instance ** ) ? */ ///@{ - void Integer( SDAI_Integer * n ); - void Real( SDAI_Real * n ); - void Number( SDAI_Real * n ); - void String( SDAI_String * str ); - void Binary( SDAI_Binary * bin ); - void Entity( SDAI_Application_instance * ent ); - void Aggregate( STEPaggregate * aggr ); - void Enum( SDAI_Enum * enu ); - void Logical( SDAI_LOGICAL * log ); - void Boolean( SDAI_BOOLEAN * boo ); - void Select( SDAI_Select * sel ); - void Undefined( SCLundefined * undef ); + void Integer(SDAI_Integer *n); + void Real(SDAI_Real *n); + void Number(SDAI_Real *n); + void String(SDAI_String *str); + void Binary(SDAI_Binary *bin); + void Entity(SDAI_Application_instance *ent); + void Aggregate(STEPaggregate *aggr); + void Enum(SDAI_Enum *enu); + void Logical(SDAI_LOGICAL *log); + void Boolean(SDAI_BOOLEAN *boo); + void Select(SDAI_Select *sel); + void Undefined(SCLundefined *undef); ///@} ////////////// Return info on attr bool Nullable() const; ///< may this attribute be null? bool is_null() const; ///< is this attribute null? - bool IsDerived() const { + bool IsDerived() const + { return _derive; } - STEPattribute * RedefiningAttr() { + STEPattribute *RedefiningAttr() + { return _redefAttr; } - const char * Name() const; - const char * TypeName() const; + const char *Name() const; + const char *TypeName() const; BASE_TYPE Type() const; BASE_TYPE NonRefType() const; BASE_TYPE BaseType() const; - const TypeDescriptor * ReferentType() const; + const TypeDescriptor *ReferentType() const; - ErrorDescriptor & Error() { + ErrorDescriptor &Error() + { return _error; } - void ClearErrorMsg() { + void ClearErrorMsg() + { _error.ClearErrorMsg(); } - Severity ValidLevel( const char* attrValue, ErrorDescriptor* error, InstMgrBase * im, bool clearError = true ); + Severity ValidLevel(const char *attrValue, ErrorDescriptor *error, InstMgrBase *im, bool clearError = true); ////////////////// Constructors - STEPattribute( const STEPattribute & a ); - STEPattribute(): _derive( false ), _mustDeletePtr( false ), - _redefAttr( 0 ), aDesc( 0 ), refCount( 0 ) { - memset( & ptr, 0, sizeof( ptr ) ); + STEPattribute(const STEPattribute &a); + STEPattribute(): _derive(false), _mustDeletePtr(false), + _redefAttr(0), aDesc(0), refCount(0) + { + memset(& ptr, 0, sizeof(ptr)); } ~STEPattribute(); // INTEGER - STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p); // BINARY - STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p); // STRING - STEPattribute( const class AttrDescriptor & d, SDAI_String * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_String *p); // REAL & NUMBER - STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Real *p); // ENTITY - STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance* *p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p); // AGGREGATE - STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ); + STEPattribute(const class AttrDescriptor &d, STEPaggregate *p); // ENUMERATION and Logical - STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p); // SELECT - STEPattribute( const class AttrDescriptor & d, SDAI_Select * p ); + STEPattribute(const class AttrDescriptor &d, SDAI_Select *p); // UNDEFINED - STEPattribute( const class AttrDescriptor & d, SCLundefined * p ); + STEPattribute(const class AttrDescriptor &d, SCLundefined *p); /// return true if attr types and values match - SC_CORE_EXPORT friend bool operator == ( const STEPattribute & a1, const STEPattribute & 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); + SC_CORE_EXPORT friend bool operator != (const STEPattribute &a1, const STEPattribute &a2); /// return true if aDesc's match (behavior of old operator==) - SC_CORE_EXPORT friend bool sameADesc ( const STEPattribute & a1, const STEPattribute & a2 ); + SC_CORE_EXPORT friend bool sameADesc(const STEPattribute &a1, const STEPattribute &a2); }; #endif diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 7774321b2..3ada09ea4 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -14,55 +14,62 @@ #include #include "sc_memmgr.h" -AttrListNode::AttrListNode( STEPattribute * a ) { +AttrListNode::AttrListNode(STEPattribute *a) +{ attr = a; } -AttrListNode::~AttrListNode() { +AttrListNode::~AttrListNode() +{ } -STEPattributeList::STEPattributeList() { +STEPattributeList::STEPattributeList() +{ } -STEPattributeList::~STEPattributeList() { +STEPattributeList::~STEPattributeList() +{ } -STEPattribute & STEPattributeList::operator []( int n ) { +STEPattribute &STEPattributeList::operator [](int n) +{ int x = 0; - AttrListNode * a = ( AttrListNode * )head; + AttrListNode *a = (AttrListNode *)head; int cnt = EntryCount(); - if( n < cnt ) { - while( a && ( x < n ) ) { - a = ( AttrListNode * )( a->next ); + if(n < cnt) { + while(a && (x < n)) { + a = (AttrListNode *)(a->next); x++; } } - if( a ) { - return *( a->attr ); + if(a) { + return *(a->attr); } // else cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ << "\n\n"; - return *( STEPattribute * ) 0; + return *(STEPattribute *) 0; } -int STEPattributeList::list_length() { +int STEPattributeList::list_length() +{ return EntryCount(); } -void STEPattributeList::push( STEPattribute * a ) { - AttrListNode * a2 = ( AttrListNode * )head; +void STEPattributeList::push(STEPattribute *a) +{ + AttrListNode *a2 = (AttrListNode *)head; // if the attribute already exists in the list, don't push it - while( a2 ) { - if( *a == *( a2 -> attr ) ) { + while(a2) { + if(*a == *(a2 -> attr)) { return; } - a2 = ( AttrListNode * )( a2->next ); + a2 = (AttrListNode *)(a2->next); } a->incrRefCount(); - AttrListNode * saln = new AttrListNode( a ); - AppendNode( saln ); + AttrListNode *saln = new AttrListNode(a); + AppendNode(saln); } diff --git a/src/clstepcore/STEPattributeList.h b/src/clstepcore/STEPattributeList.h index 9159f4664..b8d00c6c3 100644 --- a/src/clstepcore/STEPattributeList.h +++ b/src/clstepcore/STEPattributeList.h @@ -20,26 +20,28 @@ class STEPattribute; class STEPattributeList; -class SC_CORE_EXPORT AttrListNode : public SingleLinkNode { +class SC_CORE_EXPORT AttrListNode : public SingleLinkNode +{ friend class STEPattributeList; protected: - STEPattribute * attr; + STEPattribute *attr; public: - AttrListNode( STEPattribute * a ); + AttrListNode(STEPattribute *a); virtual ~AttrListNode(); }; -class SC_CORE_EXPORT STEPattributeList : public SingleLinkList { +class SC_CORE_EXPORT STEPattributeList : public SingleLinkList +{ public: STEPattributeList(); virtual ~STEPattributeList(); - STEPattribute & operator []( int n ); + STEPattribute &operator [](int n); int list_length(); - void push( STEPattribute * a ); + void push(STEPattribute *a); }; /***************************************************************** diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 5daf31ab7..082079646 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -9,40 +9,43 @@ #include "sc_memmgr.h" extern const char * -ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ); +ReadStdKeyword(istream &in, std::string &buf, int skipInitWS); -STEPcomplex::STEPcomplex( Registry * registry, int fileid ) - : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { +STEPcomplex::STEPcomplex(Registry *registry, int fileid) + : 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, true ), sc( 0 ), _registry( registry ), visited( 0 ) { - char * nms[BUFSIZ]; +STEPcomplex::STEPcomplex(Registry *registry, const std::string **names, + int fileid, const char *schnm) + : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) +{ + char *nms[BUFSIZ]; int j, k; head = this; // Create a char ** list of names and call Initialize to build all: - for( j = 0; names[j]; j++ ) { - nms[j] = new char[( names[j] )->length() + 1 ]; - strcpy( nms[j], names[j]->c_str() ); + for(j = 0; names[j]; j++) { + nms[j] = new char[(names[j])->length() + 1 ]; + strcpy(nms[j], names[j]->c_str()); } nms[j] = NULL; - Initialize( ( const char ** )nms, schnm ); - for( k = 0; k < j; k++ ) { + Initialize((const char **)nms, schnm); + for(k = 0; k < j; k++) { delete [] nms[k]; } } -STEPcomplex::STEPcomplex( Registry * registry, const char ** names, int fileid, - const char * schnm ) - : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { +STEPcomplex::STEPcomplex(Registry *registry, const char **names, int fileid, + const char *schnm) + : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) +{ head = this; - Initialize( names, schnm ); + Initialize(names, schnm); } /** @@ -56,23 +59,24 @@ STEPcomplex::STEPcomplex( Registry * registry, const char ** names, int fileid, * A and renames it to Y.) Registry::FindEntity() below knows how to * search using the current name of each entity based on schnm. */ -void STEPcomplex::Initialize( const char ** names, const char * schnm ) { +void STEPcomplex::Initialize(const char **names, const char *schnm) +{ // Create an EntNode list consisting of all the names in the complex ent: - EntNode * ents = new EntNode( names ), + EntNode *ents = new EntNode(names), *eptr = ents, *prev = NULL, *enext; - const EntityDescriptor * enDesc; + const EntityDescriptor *enDesc; char nm[BUFSIZ]; bool invalid = false, outOfOrder = false; // Splice out the invalid names from our list: - while( eptr ) { + while(eptr) { enext = eptr->next; - enDesc = _registry->FindEntity( *eptr, schnm ); - if( enDesc ) { - if( enDesc->Supertypes().EntryCount() > 1 ) { - eptr->multSuprs( true ); + enDesc = _registry->FindEntity(*eptr, schnm); + if(enDesc) { + if(enDesc->Supertypes().EntryCount() > 1) { + eptr->multSuprs(true); } - if( StrCmpIns( *eptr, enDesc->Name() ) ) { + if(StrCmpIns(*eptr, enDesc->Name())) { // If this entity was referred by another name rather than the // original. May be the case if FindEntity() determined that // eptr's name was a legal renaming of enDesc's. (Entities and @@ -80,7 +84,7 @@ void STEPcomplex::Initialize( const char ** names, const char * schnm ) { // comments.) If so, change eptr's name (since the complex // support structs only deal with the original names) and have // ents re-ort eptr properly in the list: - eptr->Name( StrToLower( enDesc->Name(), nm ) ); + eptr->Name(StrToLower(enDesc->Name(), nm)); outOfOrder = true; } prev = eptr; @@ -88,7 +92,7 @@ void STEPcomplex::Initialize( const char ** names, const char * schnm ) { invalid = true; cerr << "ERROR: Invalid entity \"" << eptr->Name() << "\" found in complex entity.\n"; - if( !prev ) { + if(!prev) { // if we need to delete the first node, ents = eptr->next; } else { @@ -102,36 +106,36 @@ void STEPcomplex::Initialize( const char ** names, const char * schnm ) { } // If we changed the name of any of the entities, resort: - if( outOfOrder ) { - ents->sort( &ents ); + if(outOfOrder) { + ents->sort(&ents); // This fn may change the value of ents if the list should have a new // first EndNode. } // Set error message according to results of above: - if( invalid ) { - if( !ents ) { + if(invalid) { + if(!ents) { // not a single legal name - _error.severity( SEVERITY_WARNING ); + _error.severity(SEVERITY_WARNING); // SEV_WARNING - we have to skip this entity altogether, but will // continue with the next entity. - _error.UserMsg( "No legal entity names found in instance" ); + _error.UserMsg("No legal entity names found in instance"); return; } - _error.severity( SEVERITY_INCOMPLETE ); - _error.UserMsg( "Some illegal entity names found in instance" ); + _error.severity(SEVERITY_INCOMPLETE); + _error.UserMsg("Some illegal entity names found in instance"); // some illegal entity names, but some legal } // Check if a complex entity can be formed from the resulting combination: - if( !_registry->CompCol()->supports( ents ) ) { - _error.severity( SEVERITY_WARNING ); + if(!_registry->CompCol()->supports(ents)) { + _error.severity(SEVERITY_WARNING); _error.UserMsg( - "Entity combination does not represent a legal complex entity" ); + "Entity combination does not represent a legal complex entity"); cerr << "ERROR: Could not create instance of the following complex" << " entity:" << endl; eptr = ents; - while( eptr ) { + while(eptr) { cerr << *eptr << endl; eptr = eptr->next; } @@ -140,23 +144,24 @@ void STEPcomplex::Initialize( const char ** names, const char * schnm ) { } // Finally, build what we can: - BuildAttrs( *ents ); - for( eptr = ents->next; eptr; eptr = eptr->next ) { - AddEntityPart( *eptr ); + BuildAttrs(*ents); + for(eptr = ents->next; eptr; eptr = eptr->next) { + AddEntityPart(*eptr); } AssignDerives(); delete ents; } -STEPcomplex::~STEPcomplex() { +STEPcomplex::~STEPcomplex() +{ STEPcomplex_attr_data_iter attr_data; - if( sc ) { + if(sc) { delete sc; } - for( attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++ ) { + for(attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++) { attrData_t attrData = *attr_data; - switch( attrData.type ) { + switch(attrData.type) { case INTEGER_TYPE: delete attrData.i; break; @@ -180,12 +185,12 @@ STEPcomplex::~STEPcomplex() { delete attrData.ai; break; case ENUM_TYPE: - if( attrData.e ) { + if(attrData.e) { delete attrData.e; } break; case SELECT_TYPE: - if( attrData.s ) { + if(attrData.s) { delete attrData.s; } break; @@ -194,7 +199,7 @@ STEPcomplex::~STEPcomplex() { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if( attrData.a ) { + if(attrData.a) { delete attrData.a; } break; @@ -208,59 +213,61 @@ STEPcomplex::~STEPcomplex() { _attr_data_list.clear(); } -void STEPcomplex::AssignDerives() { - STEPattribute * a = 0; - STEPcomplex * scomp1 = head; - STEPcomplex * scomp2; +void STEPcomplex::AssignDerives() +{ + STEPattribute *a = 0; + STEPcomplex *scomp1 = head; + STEPcomplex *scomp2; - const AttrDescriptorList * attrList; - AttrDescLinkNode * attrPtr; - const AttrDescriptor * ad; + const AttrDescriptorList *attrList; + AttrDescLinkNode *attrPtr; + const AttrDescriptor *ad; - while( scomp1 && scomp1->eDesc ) { + while(scomp1 && scomp1->eDesc) { a = 0; - attrList = &( scomp1->eDesc->ExplicitAttr() ); - attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); + attrList = &(scomp1->eDesc->ExplicitAttr()); + attrPtr = (AttrDescLinkNode *)attrList->GetHead(); // assign nm to be derived attr // while( more derived attr for entity part ) - while( attrPtr != 0 ) { + while(attrPtr != 0) { ad = attrPtr->AttrDesc(); - if( ( ad->Derived() ) == LTrue ) { - const char * nm = ad->Name(); - const char * attrNm = 0; - if( strrchr( nm, '.' ) ) { - attrNm = strrchr( nm, '.' ); + if((ad->Derived()) == LTrue) { + const char *nm = ad->Name(); + const char *attrNm = 0; + if(strrchr(nm, '.')) { + attrNm = strrchr(nm, '.'); attrNm++; } else { attrNm = nm; } scomp2 = head; - while( scomp2 && !a ) { - if( scomp1 != scomp2 ) { - scomp2->MakeDerived( attrNm ); - a = scomp2->GetSTEPattribute( attrNm ); + while(scomp2 && !a) { + if(scomp1 != scomp2) { + scomp2->MakeDerived(attrNm); + a = scomp2->GetSTEPattribute(attrNm); } scomp2 = scomp2->sc; } } // increment attr - attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); + attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); } scomp1 = scomp1->sc; } } /** 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 ) { +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 ); + AppendEntity(scomplex); } else { cout << scomplex->_error.DetailMsg() << endl; delete scomplex; @@ -268,11 +275,12 @@ void STEPcomplex::AddEntityPart( const char * name ) { } } -STEPcomplex * STEPcomplex::EntityPart( const char * name, const char * currSch ) { - STEPcomplex * scomp = head; - while( scomp ) { - if( scomp->eDesc ) { - if( scomp->eDesc->CurrName( name, currSch ) ) { +STEPcomplex *STEPcomplex::EntityPart(const char *name, const char *currSch) +{ + STEPcomplex *scomp = head; + while(scomp) { + if(scomp->eDesc) { + if(scomp->eDesc->CurrName(name, currSch)) { return scomp; } } else { @@ -284,8 +292,9 @@ STEPcomplex * STEPcomplex::EntityPart( const char * name, const char * currSch ) return 0; } -int STEPcomplex::EntityExists( const char * name, const char * currSch ) { - return ( EntityPart( name, currSch ) ? 1 : 0 ); +int STEPcomplex::EntityExists(const char *name, const char *currSch) +{ + return (EntityPart(name, currSch) ? 1 : 0); } /** @@ -293,18 +302,20 @@ int STEPcomplex::EntityExists( const char * name, const char * currSch ) { ** For a complex entity, we'll check the EntityDescriptor of each entity ** in the complex 'chain' */ -const EntityDescriptor * STEPcomplex::IsA( const EntityDescriptor * ed ) const { - const EntityDescriptor * return_ed = eDesc->IsA( ed ); +const EntityDescriptor *STEPcomplex::IsA(const EntityDescriptor *ed) const +{ + const EntityDescriptor *return_ed = eDesc->IsA(ed); - if( !return_ed && sc ) { - return sc->IsA( ed ); + if(!return_ed && sc) { + return sc->IsA(ed); } else { return return_ed; } } -Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, - int clearError ) { +Severity STEPcomplex::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, + int clearError) +{ (void) error; //unused (void) im; (void) clearError; @@ -312,73 +323,75 @@ Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, return SEVERITY_NULL; } -void STEPcomplex::AppendEntity( STEPcomplex * stepc ) { - if( sc ) { - sc->AppendEntity( stepc ); +void STEPcomplex::AppendEntity(STEPcomplex *stepc) +{ + if(sc) { + sc->AppendEntity(stepc); } else { sc = stepc; } } // READ -Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set, - istream & in, const char * currSch, bool /*useTechCor*/, bool /*strict*/ ) { +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; - STEPcomplex * stepc = 0; + STEPcomplex *stepc = 0; - ClearError( 1 ); + ClearError(1); STEPfile_id = id; stepc = head; - while( stepc ) { + while(stepc) { stepc->visited = 0; stepc = stepc->sc; } in >> ws; - in.get( c ); - if( c == '(' ) { // opening paren for subsuperRecord + in.get(c); + if(c == '(') { // opening paren for subsuperRecord in >> ws; c = in.peek(); - while( c != ')' ) { + while(c != ')') { typeNm.clear(); in >> ws; - ReadStdKeyword( in, typeNm, 1 ); // read the type name + ReadStdKeyword(in, typeNm, 1); // read the type name in >> ws; c = in.peek(); - if( c != '(' ) { - _error.AppendToDetailMsg( "Missing open paren before entity attr values.\n" ); + if(c != '(') { + _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 ); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + STEPread_error(c, 0, in, currSch); return _error.severity(); } - stepc = EntityPart( typeNm.c_str(), currSch ); - if( stepc ) { + stepc = EntityPart(typeNm.c_str(), currSch); + 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 ); + 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 ); + _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(); } in >> ws; c = in.peek(); } - if( c != ')' ) { + if(c != ')') { cout << "ERROR: missing ending paren for complex entity instance." << endl; } else { - in.get( c ); // read the closing paren + 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 ); + _error.AppendToDetailMsg("Complex instances must begin with '('. Found '"); + _error.AppendToDetailMsg(c); + _error.AppendToDetailMsg("' instead.\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); } return _error.severity(); } @@ -386,82 +399,83 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * insta //FIXME delete this? #ifdef buildwhileread // READ -Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set, - istream & in, const char * currSch ) { - ClearError( 1 ); +Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instance_set, + istream &in, const char *currSch) +{ + ClearError(1); STEPfile_id = id; STEPcomplex stepc = head; - while( stepc ) { + while(stepc) { stepc->visited = 0; stepc = stepc->sc; } char c; in >> ws; - in.get( c ); - if( c == '(' ) { + in.get(c); + if(c == '(') { std::string s; in >> ws; - in.get( c ); - while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name - s.Append( c ); - in.get( c ); + in.get(c); + while(in && (c != '(') && !isspace(c)) { // get the entity name + s.Append(c); + in.get(c); } - if( isspace( c ) ) { + if(isspace(c)) { in >> ws; - in.get( c ); + in.get(c); } - if( c != '(' ) { + if(c != '(') { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n" ); + "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 ); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + STEPread_error(c, 0, in, currSch); return _error.severity(); } else { // c == '(' - in.putback( c ); + in.putback(c); } cout << s << endl; - BuildAttrs( s.c_str() ); - SDAI_Application_instance::STEPread( id, addFileId, instance_set, - in, currSch ); + BuildAttrs(s.c_str()); + SDAI_Application_instance::STEPread(id, addFileId, instance_set, + in, currSch); in >> ws; - in.get( c ); - while( c != ')' ) { + in.get(c); + while(c != ')') { s.set_null(); - while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name - s.Append( c ); - in.get( c ); + while(in && (c != '(') && !isspace(c)) { // get the entity name + s.Append(c); + in.get(c); } - if( isspace( c ) ) { + if(isspace(c)) { in >> ws; - in.get( c ); + in.get(c); } - if( c != '(' ) { + if(c != '(') { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n" ); + "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 ); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + STEPread_error(c, 0, in, currSch); return _error.severity(); } else { // c == '(' - in.putback( c ); + in.putback(c); } cout << s << endl; // diagnostics DAS - STEPcomplex * stepc = new STEPcomplex( _registry ); - AppendEntity( stepc ); - stepc->BuildAttrs( s.c_str() ); - stepc->SDAI_Application_instance::STEPread( id, addFileId, + STEPcomplex *stepc = new STEPcomplex(_registry); + AppendEntity(stepc); + stepc->BuildAttrs(s.c_str()); + stepc->SDAI_Application_instance::STEPread(id, addFileId, instance_set, in, - currSch ); + currSch); in >> ws; - in.get( c ); + in.get(c); } } return _error.severity(); @@ -469,75 +483,76 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * insta #endif -void STEPcomplex::BuildAttrs( const char * s ) { +void STEPcomplex::BuildAttrs(const char *s) +{ // assign inherited member variable - eDesc = ( class EntityDescriptor * )_registry->FindEntity( s ); + eDesc = (class EntityDescriptor *)_registry->FindEntity(s); - if( eDesc ) { - const AttrDescriptorList * attrList = &( eDesc->ExplicitAttr() ); + if(eDesc) { + const AttrDescriptorList *attrList = &(eDesc->ExplicitAttr()); ////////////////////////////////////////////// // find out how many attrs there are ////////////////////////////////////////////// - STEPattribute * a = 0; + STEPattribute *a = 0; //_attr_data_list used to store everything as void *, but we couldn't correctly delete the contents in the dtor. - AttrDescLinkNode * attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); - while( attrPtr != 0 ) { - const AttrDescriptor * ad = attrPtr->AttrDesc(); + AttrDescLinkNode *attrPtr = (AttrDescLinkNode *)attrList->GetHead(); + while(attrPtr != 0) { + const AttrDescriptor *ad = attrPtr->AttrDesc(); - if( ( ad->Derived() ) != LTrue ) { + if((ad->Derived()) != LTrue) { attrData_t attrData; attrData.type = ad->NonRefType(); - switch( attrData.type ) { + switch(attrData.type) { case INTEGER_TYPE: attrData.i = new SDAI_Integer; - a = new STEPattribute( *ad, attrData.i ); + a = new STEPattribute(*ad, attrData.i); break; case STRING_TYPE: attrData.str = new SDAI_String; - a = new STEPattribute( *ad, attrData.str ); + a = new STEPattribute(*ad, attrData.str); break; case BINARY_TYPE: attrData.bin = new SDAI_Binary; - a = new STEPattribute( *ad, attrData.bin ); + a = new STEPattribute(*ad, attrData.bin); break; case REAL_TYPE: case NUMBER_TYPE: attrData.r = new SDAI_Real; - a = new STEPattribute( *ad, attrData.r ); + a = new STEPattribute(*ad, attrData.r); break; case BOOLEAN_TYPE: attrData.b = new SDAI_BOOLEAN; - a = new STEPattribute( *ad, attrData.b ); + a = new STEPattribute(*ad, attrData.b); break; case LOGICAL_TYPE: attrData.l = new SDAI_LOGICAL; - a = new STEPattribute( *ad, attrData.l ); + a = new STEPattribute(*ad, attrData.l); break; case ENTITY_TYPE: - attrData.ai = new( SDAI_Application_instance * ); - a = new STEPattribute( *ad, attrData.ai ); + attrData.ai = new(SDAI_Application_instance *); + a = new STEPattribute(*ad, attrData.ai); break; case ENUM_TYPE: { - EnumTypeDescriptor * enumD = ( EnumTypeDescriptor * )ad->ReferentType(); + EnumTypeDescriptor *enumD = (EnumTypeDescriptor *)ad->ReferentType(); attrData.e = enumD->CreateEnum(); - a = new STEPattribute( *ad, attrData.e ); + a = new STEPattribute(*ad, attrData.e); break; } case SELECT_TYPE: { - SelectTypeDescriptor * selectD = ( SelectTypeDescriptor * )ad->ReferentType(); + SelectTypeDescriptor *selectD = (SelectTypeDescriptor *)ad->ReferentType(); attrData.s = selectD->CreateSelect(); - a = new STEPattribute( *ad, attrData.s ); + a = new STEPattribute(*ad, attrData.s); break; } case AGGREGATE_TYPE: @@ -545,41 +560,42 @@ void STEPcomplex::BuildAttrs( const char * s ) { case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - AggrTypeDescriptor * aggrD = ( AggrTypeDescriptor * )ad->ReferentType(); + AggrTypeDescriptor *aggrD = (AggrTypeDescriptor *)ad->ReferentType(); attrData.a = aggrD->CreateAggregate(); - a = new STEPattribute( *ad, attrData.a ); + a = new STEPattribute(*ad, attrData.a); break; } default: - _error.AppendToDetailMsg( "STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n" ); - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.AppendToDetailMsg("STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n"); + _error.GreaterSeverity(SEVERITY_WARNING); a = new STEPattribute(); attrData.type = UNKNOWN_TYPE; //don't add to attr list } - if( attrData.type != UNKNOWN_TYPE ) { - _attr_data_list.push_back( attrData ); + if(attrData.type != UNKNOWN_TYPE) { + _attr_data_list.push_back(attrData); } a -> set_null(); - attributes.push( a ); + attributes.push(a); } - attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); + attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); } } else { - _error.AppendToDetailMsg( "Entity does not exist.\n" ); - _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error.AppendToDetailMsg("Entity does not exist.\n"); + _error.GreaterSeverity(SEVERITY_INPUT_ERROR); } } -void STEPcomplex::STEPread_error( char c, int index, istream & in, const char * schnm ) { +void STEPcomplex::STEPread_error(char c, int index, istream &in, const char *schnm) +{ (void) schnm; //unused cout << "STEPcomplex::STEPread_error(), index=" << index << ", entity #" << STEPfile_id << "." << endl; streampos p = in.tellg(); std::string q, r; - getline( in, q ); - getline( in, r ); + getline(in, q); + getline(in, r); cout << "Remainder of this line:" << endl << c << q << endl << "Next line:" << endl << r << endl; - in.seekg( p ); + in.seekg(p); } /** @@ -590,132 +606,138 @@ void STEPcomplex::STEPread_error( char c, int index, istream & in, const char * ** alphabetical order. The nodes are sorted alphabetically according to their ** original names but not according to their renamed names (DAR 6/5/97). */ -void STEPcomplex::STEPwrite( ostream & out, const char * currSch, int writeComment ) { - if( writeComment && !p21Comment.empty() ) { +void STEPcomplex::STEPwrite(ostream &out, const char *currSch, int writeComment) +{ + if(writeComment && !p21Comment.empty()) { out << p21Comment; } out << "#" << STEPfile_id << "=(\n"; - WriteExtMapEntities( out, currSch ); + WriteExtMapEntities(out, currSch); out << ");\n"; } -const char * STEPcomplex::STEPwrite( std::string & buf, const char * currSch ) { +const char *STEPcomplex::STEPwrite(std::string &buf, const char *currSch) +{ buf.clear(); stringstream ss; ss << "#" << STEPfile_id << "=("; - WriteExtMapEntities( ss, currSch ); + WriteExtMapEntities(ss, currSch); ss << ");"; ss << ends; - buf.append( ss.str() ); + buf.append(ss.str()); - return const_cast( buf.c_str() ); + return const_cast(buf.c_str()); } /** \copydoc STEPcomplex::STEPwrite */ -void STEPcomplex::WriteExtMapEntities( ostream & out, const char * currSch ) { +void STEPcomplex::WriteExtMapEntities(ostream &out, const char *currSch) +{ std::string tmp; - out << StrToUpper( EntityName( currSch ), tmp ); + out << StrToUpper(EntityName(currSch), tmp); out << "("; int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - ( attributes[i] ).STEPwrite( out, currSch ); - if( i < n - 1 ) { + for(int i = 0 ; i < n; i++) { + (attributes[i]).STEPwrite(out, currSch); + if(i < n - 1) { out << ","; } } out << ")\n"; - if( sc ) { - sc->WriteExtMapEntities( out, currSch ); + if(sc) { + sc->WriteExtMapEntities(out, currSch); } } /** \copydoc STEPcomplex::STEPwrite */ -const char * STEPcomplex::WriteExtMapEntities( std::string & buf, const char * currSch ) { +const char *STEPcomplex::WriteExtMapEntities(std::string &buf, const char *currSch) +{ std::string tmp; - StrToUpper( EntityName( currSch ), tmp ); - buf.append( tmp ); - buf.append( "i" ); + StrToUpper(EntityName(currSch), tmp); + buf.append(tmp); + buf.append("i"); int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - buf.append( attributes[i].asStr( currSch ) ); - if( i < n - 1 ) { - buf.append( "," ); + for(int i = 0 ; i < n; i++) { + buf.append(attributes[i].asStr(currSch)); + if(i < n - 1) { + buf.append(","); } } - buf.append( ")\n" ); + buf.append(")\n"); - if( sc ) { - sc->WriteExtMapEntities( buf, currSch ); + if(sc) { + sc->WriteExtMapEntities(buf, currSch); } return buf.c_str(); } -void STEPcomplex::CopyAs( SDAI_Application_instance * se ) { - if( !se->IsComplex() ) { +void STEPcomplex::CopyAs(SDAI_Application_instance *se) +{ + if(!se->IsComplex()) { char errStr[BUFSIZ]; cerr << "STEPcomplex::CopyAs() called with non-complex entity: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf( errStr, - "STEPcomplex::CopyAs(): %s - entity #%d.\n", - "Programming ERROR - called with non-complex entity", - STEPfile_id ); - _error.AppendToDetailMsg( errStr ); - _error.AppendToUserMsg( errStr ); - _error.GreaterSeverity( SEVERITY_BUG ); + sprintf(errStr, + "STEPcomplex::CopyAs(): %s - entity #%d.\n", + "Programming ERROR - called with non-complex entity", + STEPfile_id); + _error.AppendToDetailMsg(errStr); + _error.AppendToUserMsg(errStr); + _error.GreaterSeverity(SEVERITY_BUG); return; } else { - STEPcomplex * scpartCpyTo = head; - STEPcomplex * scpartCpyFrom = ( ( STEPcomplex * )se )->head; - while( scpartCpyTo && scpartCpyFrom ) { - scpartCpyTo->SDAI_Application_instance::CopyAs( scpartCpyFrom ); + STEPcomplex *scpartCpyTo = head; + STEPcomplex *scpartCpyFrom = ((STEPcomplex *)se)->head; + while(scpartCpyTo && scpartCpyFrom) { + scpartCpyTo->SDAI_Application_instance::CopyAs(scpartCpyFrom); scpartCpyTo = scpartCpyTo->sc; scpartCpyFrom = scpartCpyFrom->sc; } } } -SDAI_Application_instance * STEPcomplex::Replicate() { - if( !IsComplex() ) { +SDAI_Application_instance *STEPcomplex::Replicate() +{ + if(!IsComplex()) { return SDAI_Application_instance::Replicate(); - } else if( !_registry ) { + } else if(!_registry) { return S_ENTITY_NULL; } else { int nameCount = 64; - std::string ** nameList = new std::string *[nameCount]; - STEPcomplex * scomp = this->head; + std::string **nameList = new std::string *[nameCount]; + STEPcomplex *scomp = this->head; int i = 0; - while( scomp && ( i < 63 ) ) { - nameList[i] = new std::string( "" ); - nameList[i]->append( scomp->eDesc->Name() ); + while(scomp && (i < 63)) { + nameList[i] = new std::string(""); + nameList[i]->append(scomp->eDesc->Name()); i++; scomp = scomp->sc; } - nameList[i] = ( std::string * )0; - if( i == 63 ) { + nameList[i] = (std::string *)0; + if(i == 63) { char errStr[BUFSIZ]; cerr << "STEPcomplex::Replicate() name buffer too small: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf( errStr, - "STEPcomplex::Replicate(): %s - entity #%d.\n", - "Programming ERROR - name buffer too small", - STEPfile_id ); - _error.AppendToDetailMsg( errStr ); - _error.AppendToUserMsg( errStr ); - _error.GreaterSeverity( SEVERITY_BUG ); + sprintf(errStr, + "STEPcomplex::Replicate(): %s - entity #%d.\n", + "Programming ERROR - name buffer too small", + STEPfile_id); + _error.AppendToDetailMsg(errStr); + _error.AppendToUserMsg(errStr); + _error.GreaterSeverity(SEVERITY_BUG); } - STEPcomplex * seNew = new STEPcomplex( _registry, - ( const std::string ** )nameList, - 1111 ); - seNew -> CopyAs( this ); + STEPcomplex *seNew = new STEPcomplex(_registry, + (const std::string **)nameList, + 1111); + seNew -> CopyAs(this); return seNew; // TODO need to: diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index caf7ea255..10239ec01 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -18,16 +18,16 @@ typedef struct { PrimitiveType type; union { - SDAI_Integer * i; - SDAI_String * str; - SDAI_Binary * bin; - SDAI_Real * r; - SDAI_BOOLEAN * b; - SDAI_LOGICAL * l; - SDAI_Application_instance ** ai; - SDAI_Enum * e; - SDAI_Select * s; - STEPaggregate * a; + SDAI_Integer *i; + SDAI_String *str; + SDAI_Binary *bin; + SDAI_Real *r; + SDAI_BOOLEAN *b; + SDAI_LOGICAL *l; + SDAI_Application_instance **ai; + SDAI_Enum *e; + SDAI_Select *s; + STEPaggregate *a; }; } attrData_t; typedef std::list< attrData_t > STEPcomplex_attr_data_list; @@ -36,11 +36,12 @@ typedef STEPcomplex_attr_data_list::iterator STEPcomplex_attr_data_iter; /** FIXME are inverse attr's initialized for STEPcomplex? */ -class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance { +class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance +{ public: //TODO should this _really_ be public?! - STEPcomplex * sc; - STEPcomplex * head; - Registry * _registry; + STEPcomplex *sc; + STEPcomplex *head; + Registry *_registry; int visited; ///< used when reading (or as you wish?) #ifdef _MSC_VER #pragma warning( push ) @@ -51,48 +52,48 @@ class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance { #pragma warning( pop ) #endif public: - STEPcomplex( Registry * registry, int fileid ); - STEPcomplex( Registry * registry, const std::string ** names, int fileid, - const char * schnm = 0 ); - STEPcomplex( Registry * registry, const char ** names, int fileid, - const char * schnm = 0 ); + STEPcomplex(Registry *registry, int fileid); + STEPcomplex(Registry *registry, const std::string **names, int fileid, + const char *schnm = 0); + STEPcomplex(Registry *registry, const char **names, int fileid, + const char *schnm = 0); virtual ~STEPcomplex(); - int EntityExists( const char * name, const char * currSch = 0 ); - STEPcomplex * EntityPart( const char * name, const char * currSch = 0 ); + int EntityExists(const char *name, const char *currSch = 0); + STEPcomplex *EntityPart(const char *name, const char *currSch = 0); - virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; + virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; - virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, - int clearError = 1 ); + virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, + int clearError = 1); // READ - virtual Severity STEPread( int id, int addFileId, - class InstMgrBase * instance_set, - istream & in = cin, const char * currSch = NULL, - bool useTechCor = true, bool strict = true ); + virtual Severity STEPread(int id, int addFileId, + class InstMgrBase *instance_set, + istream &in = cin, const char *currSch = NULL, + bool useTechCor = true, bool strict = true); - virtual void STEPread_error( char c, int index, istream& in, const char * schnm ); + virtual void STEPread_error(char c, int index, istream &in, const char *schnm); // WRITE - virtual void STEPwrite( ostream & out = cout, const char * currSch = NULL, - int writeComment = 1 ); - virtual const char * STEPwrite( std::string & buf, const char * currSch = NULL ); + virtual void STEPwrite(ostream &out = cout, const char *currSch = NULL, + int writeComment = 1); + virtual const char *STEPwrite(std::string &buf, const char *currSch = NULL); - SDAI_Application_instance * Replicate(); + SDAI_Application_instance *Replicate(); - virtual void WriteExtMapEntities( ostream & out = cout, - const char * currSch = NULL ); - virtual const char * WriteExtMapEntities( std::string & buf, - const char * currSch = NULL ); - virtual void AppendEntity( STEPcomplex * stepc ); + virtual void WriteExtMapEntities(ostream &out = cout, + const char *currSch = NULL); + virtual const char *WriteExtMapEntities(std::string &buf, + const char *currSch = NULL); + virtual void AppendEntity(STEPcomplex *stepc); protected: - virtual void CopyAs( SDAI_Application_instance * se ); - void BuildAttrs( const char * s ); - void AddEntityPart( const char * name ); + virtual void CopyAs(SDAI_Application_instance *se); + void BuildAttrs(const char *s); + void AddEntityPart(const char *name); void AssignDerives(); - void Initialize( const char ** names, const char * schnm ); + void Initialize(const char **names, const char *schnm); }; #endif diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index 52bdf1ee5..cd083a67a 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -7,8 +7,8 @@ #include #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(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() {} @@ -16,51 +16,55 @@ invAttrListNodeA::~invAttrListNodeA() {} STEPinvAttrList::STEPinvAttrList() {} STEPinvAttrList::~STEPinvAttrList() {} -invAttrListNode * STEPinvAttrList::operator []( int n ) { +invAttrListNode *STEPinvAttrList::operator [](int n) +{ int x = 0; - invAttrListNode * a = ( invAttrListNode * )head; + invAttrListNode *a = (invAttrListNode *)head; int cnt = EntryCount(); - if( n < cnt ) { - while( a && ( x < n ) ) { - a = ( invAttrListNode * )( a->next ); + if(n < cnt) { + while(a && (x < n)) { + a = (invAttrListNode *)(a->next); x++; } } - if( !a ) { + if(!a) { cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" - << __LINE__ << "\n" << _POC_ << "\n\n"; + << __LINE__ << "\n" << _POC_ << "\n\n"; } return a; } -int STEPinvAttrList::list_length() { +int STEPinvAttrList::list_length() +{ return EntryCount(); } -void STEPinvAttrList::push( Inverse_attribute * a, setterA_t s, getterA_t g ) { - invAttrListNode * an = ( invAttrListNode * )head; +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 ) ) { + while(an) { + if(a == (an -> attr)) { return; } - an = ( invAttrListNode * )( an->next ); + an = (invAttrListNode *)(an->next); } - invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeA( a, s, g ); - AppendNode( ialn ); + 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; +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 ) ) { + while(an) { + if(a == (an -> attr)) { return; } - an = ( invAttrListNode * )( an->next ); + an = (invAttrListNode *)(an->next); } - invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeI( a, s, g ); - AppendNode( ialn ); + invAttrListNode *ialn = (invAttrListNode *) new invAttrListNodeI(a, s, g); + AppendNode(ialn); } diff --git a/src/clstepcore/STEPinvAttrList.h b/src/clstepcore/STEPinvAttrList.h index 342720065..6754fc99e 100644 --- a/src/clstepcore/STEPinvAttrList.h +++ b/src/clstepcore/STEPinvAttrList.h @@ -25,75 +25,86 @@ class SDAI_Application_instance; * 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 * ); +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; +class SC_CORE_EXPORT invAttrListNode : public SingleLinkNode +{ + friend class STEPinvAttrList; protected: - invAttrListNode( Inverse_attribute * a ) : attr( a ) {}; - Inverse_attribute * attr; + invAttrListNode(Inverse_attribute *a) : attr(a) {}; + Inverse_attribute *attr; public: - Inverse_attribute * inverseADesc() { + Inverse_attribute *inverseADesc() + { return attr; } virtual bool isAggregate() = 0; }; -class SC_CORE_EXPORT invAttrListNodeI : public invAttrListNode { - friend class STEPinvAttrList; +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 ); + invAttrListNodeI(Inverse_attribute *a, setterI_t s, getterI_t g); virtual ~invAttrListNodeI(); - setterI_t setter() { + setterI_t setter() + { return set; } - getterI_t getter() { + getterI_t getter() + { return get; } - virtual bool isAggregate() { + virtual bool isAggregate() + { return false; } }; -class SC_CORE_EXPORT invAttrListNodeA : public invAttrListNode { - friend class STEPinvAttrList; +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 ); + invAttrListNodeA(Inverse_attribute *a, setterA_t s, getterA_t g); virtual ~invAttrListNodeA(); - setterA_t setter() { + setterA_t setter() + { return set; } - getterA_t getter() { + getterA_t getter() + { return get; } - virtual bool isAggregate() { + 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 { +class SC_CORE_EXPORT STEPinvAttrList : public SingleLinkList +{ public: STEPinvAttrList(); virtual ~STEPinvAttrList(); - invAttrListNode * operator []( int n ); + 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 ); + void push(Inverse_attribute *a, setterA_t s, getterA_t g); + void push(Inverse_attribute *a, setterI_t s, getterI_t g); }; diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index 6ca378099..71ad08705 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -19,22 +19,26 @@ ** helper functions for reading unknown types */ -Severity SCLundefined::StrToVal( const char * s, ErrorDescriptor * err ) { +Severity SCLundefined::StrToVal(const char *s, ErrorDescriptor *err) +{ (void) err; //unused val = s; return SEVERITY_NULL; } -Severity SCLundefined::StrToVal( istream & in, ErrorDescriptor * err ) { - return STEPread( in, err ); +Severity SCLundefined::StrToVal(istream &in, ErrorDescriptor *err) +{ + return STEPread(in, err); } -Severity SCLundefined::STEPread( const char * s, ErrorDescriptor * err ) { - istringstream in( ( char * ) s ); - return STEPread( in, err ); +Severity SCLundefined::STEPread(const char *s, ErrorDescriptor *err) +{ + istringstream in((char *) s); + return STEPread(in, err); } -Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) { +Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) +{ char c = '\0'; ostringstream ss; std::string str; @@ -43,38 +47,38 @@ Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) { in >> ws; // skip white space in >> c; - if( c == '$' ) { + if(c == '$') { val = ""; - CheckRemainingInput( in, err, "aggregate item", ",)" ); + CheckRemainingInput(in, err, "aggregate item", ",)"); } else { - in.putback( c ); + in.putback(c); } - while( !terminal ) { - in.get( c ); - switch( c ) { + while(!terminal) { + in.get(c); + switch(c) { case '(': - in.putback( c ); + in.putback(c); - PushPastImbedAggr( in, str, err ); + PushPastImbedAggr(in, str, err); ss << str; break; case '\'': - in.putback( c ); + in.putback(c); - PushPastString( in, str, err ); + PushPastString(in, str, err); ss << str; break; case ',': terminal = 1; // it's a STEPattribute separator - in.putback( c ); + in.putback(c); c = '\0'; break; case ')': - in.putback( c ); + in.putback(c); terminal = 1; // found a valid delimiter break; @@ -84,53 +88,58 @@ Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) { break; default: - ss.put( c ); + ss.put(c); break; } - if( !in.good() ) { + if(!in.good()) { terminal = 1; c = '\0'; } } ss << ends; - val = &( ss.str()[0] ); + val = &(ss.str()[0]); - err->GreaterSeverity( SEVERITY_NULL ); + err->GreaterSeverity(SEVERITY_NULL); return SEVERITY_NULL; } -const char * SCLundefined::asStr( std::string & s ) const { +const char *SCLundefined::asStr(std::string &s) const +{ s = val.c_str(); - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const char * SCLundefined::STEPwrite( std::string & s ) { - if( val.empty() ) { +const char *SCLundefined::STEPwrite(std::string &s) +{ + if(val.empty()) { s = "$"; } else { s = val.c_str(); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -void SCLundefined:: STEPwrite( ostream & out ) { - if( val.empty() ) { +void SCLundefined:: STEPwrite(ostream &out) +{ + if(val.empty()) { out << "$"; } else { out << val; } } -SCLundefined & SCLundefined::operator= ( const SCLundefined & x ) { +SCLundefined &SCLundefined::operator= (const SCLundefined &x) +{ std::string tmp; - val = x.asStr( tmp ); + val = x.asStr(tmp); return *this; } -SCLundefined & SCLundefined::operator= ( const char * str ) { - if( !str ) { +SCLundefined &SCLundefined::operator= (const char *str) +{ + if(!str) { val.clear(); } else { val = str; @@ -138,18 +147,22 @@ SCLundefined & SCLundefined::operator= ( const char * str ) { return *this; } -SCLundefined::SCLundefined() { +SCLundefined::SCLundefined() +{ } -SCLundefined::~SCLundefined() { +SCLundefined::~SCLundefined() +{ } -int SCLundefined::set_null() { +int SCLundefined::set_null() +{ val = ""; return 1; } -bool SCLundefined::is_null() { - return ( val.empty() ); +bool SCLundefined::is_null() +{ + return (val.empty()); } diff --git a/src/clstepcore/STEPundefined.h b/src/clstepcore/STEPundefined.h index 306eb0ef2..e83685f17 100644 --- a/src/clstepcore/STEPundefined.h +++ b/src/clstepcore/STEPundefined.h @@ -17,7 +17,8 @@ #include #include -class SC_CORE_EXPORT SCLundefined { +class SC_CORE_EXPORT SCLundefined +{ protected: #ifdef _MSC_VER #pragma warning( push ) @@ -30,21 +31,21 @@ class SC_CORE_EXPORT SCLundefined { public: // INPUT - virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); - virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + virtual Severity StrToVal(const char *s, ErrorDescriptor *err); + virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - virtual Severity STEPread( const char * s, ErrorDescriptor * err ); - virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + virtual Severity STEPread(const char *s, ErrorDescriptor *err); + virtual Severity STEPread(istream &in, ErrorDescriptor *err); // OUTPUT - virtual const char * asStr( std::string & s ) const; - virtual const char * STEPwrite( std::string & s ); - virtual void STEPwrite( ostream & out = cout ); + virtual const char *asStr(std::string &s) const; + virtual const char *STEPwrite(std::string &s); + virtual void STEPwrite(ostream &out = cout); int set_null(); bool is_null(); - SCLundefined & operator= ( const SCLundefined & ); - SCLundefined & operator= ( const char * str ); + SCLundefined &operator= (const SCLundefined &); + SCLundefined &operator= (const char *str); SCLundefined(); virtual ~SCLundefined(); }; diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index b13e2061d..1552b2707 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -15,65 +15,72 @@ #include -SingleLinkList::SingleLinkList() : head( 0 ), tail( 0 ) { +SingleLinkList::SingleLinkList() : head(0), tail(0) +{ } -SingleLinkList::~SingleLinkList() { +SingleLinkList::~SingleLinkList() +{ Empty(); } -void SingleLinkList::Empty() { - SingleLinkNode * tmp = head; - while( tmp ) { +void SingleLinkList::Empty() +{ + SingleLinkNode *tmp = head; + while(tmp) { tmp = head -> NextNode(); delete head; head = tmp; } } -SingleLinkNode * SingleLinkList::NewNode() { +SingleLinkNode *SingleLinkList::NewNode() +{ // defined in subtypes std::cerr << "\n\n******BUG****** a virtually defined function should \n" - << "be called for SingleLinkList::NewNode()\n\n"; + << "be called for SingleLinkList::NewNode()\n\n"; return new SingleLinkNode(); } -SingleLinkNode * SingleLinkList::GetHead() const { - return ( head ); +SingleLinkNode *SingleLinkList::GetHead() const +{ + return (head); } -int SingleLinkList::EntryCount() const { +int SingleLinkList::EntryCount() const +{ int entryCount = 0; - SingleLinkNode * entryPtr = head; + SingleLinkNode *entryPtr = head; - while( entryPtr != 0 ) { + while(entryPtr != 0) { entryPtr = entryPtr->NextNode(); entryCount++; } return entryCount; } -void SingleLinkList::DeleteFollowingNodes( SingleLinkNode * item ) { - if( head ) { - SingleLinkNode * trailer = 0; - SingleLinkNode * leader = head; - while( leader ) { - if( leader == item ) { - while( leader ) { - if( trailer ) { +void SingleLinkList::DeleteFollowingNodes(SingleLinkNode *item) +{ + if(head) { + SingleLinkNode *trailer = 0; + SingleLinkNode *leader = head; + while(leader) { + if(leader == item) { + while(leader) { + if(trailer) { trailer->next = leader->next; - } else if( leader == head ) { + } else if(leader == head) { head = leader->next; trailer = head; } - if( leader == tail ) { + if(leader == tail) { tail = trailer; } delete leader; leader = trailer->next; } } else { - if( trailer ) { + if(trailer) { trailer = trailer->NextNode(); } else { trailer = leader; @@ -84,8 +91,9 @@ void SingleLinkList::DeleteFollowingNodes( SingleLinkNode * item ) { } } -void SingleLinkList::AppendNode( SingleLinkNode * item ) { - if( head ) { +void SingleLinkList::AppendNode(SingleLinkNode *item) +{ + if(head) { tail -> next = item; tail = item; } else { @@ -94,25 +102,26 @@ void SingleLinkList::AppendNode( SingleLinkNode * item ) { item->owner = this; } -void SingleLinkList::DeleteNode( SingleLinkNode * item ) { - if( head ) { - SingleLinkNode * trailer = 0; - SingleLinkNode * leader = head; - while( leader ) { - if( leader == item ) { - if( trailer ) { +void SingleLinkList::DeleteNode(SingleLinkNode *item) +{ + if(head) { + SingleLinkNode *trailer = 0; + SingleLinkNode *leader = head; + while(leader) { + if(leader == item) { + if(trailer) { trailer->next = leader->next; } leader = leader->next; - if( item == head ) { + if(item == head) { head = item->next; } - if( item == tail ) { + if(item == tail) { tail = trailer; } delete item; } else { - if( trailer ) { + if(trailer) { trailer = trailer->NextNode(); } else { trailer = leader; diff --git a/src/clstepcore/SingleLinkList.h b/src/clstepcore/SingleLinkList.h index 24726f194..a6fddd928 100644 --- a/src/clstepcore/SingleLinkList.h +++ b/src/clstepcore/SingleLinkList.h @@ -20,18 +20,19 @@ * node which represents the value is contained in the subclass * since it may have different types for different lists */ -class SC_CORE_EXPORT SingleLinkList { +class SC_CORE_EXPORT SingleLinkList +{ protected: - class SingleLinkNode * head; - SingleLinkNode * tail; + class SingleLinkNode *head; + SingleLinkNode *tail; public: - virtual SingleLinkNode * NewNode(); - virtual void AppendNode( SingleLinkNode * ); - virtual void DeleteNode( SingleLinkNode * ); + virtual SingleLinkNode *NewNode(); + virtual void AppendNode(SingleLinkNode *); + virtual void DeleteNode(SingleLinkNode *); virtual void Empty(); - virtual void DeleteFollowingNodes( SingleLinkNode * ); - virtual SingleLinkNode * GetHead() const; + virtual void DeleteFollowingNodes(SingleLinkNode *); + virtual SingleLinkNode *GetHead() const; int EntryCount() const; @@ -42,20 +43,24 @@ class SC_CORE_EXPORT SingleLinkList { /** Base class for nodes of a single-linked list. * \sa SingleLinkList */ -class SC_CORE_EXPORT SingleLinkNode { +class SC_CORE_EXPORT SingleLinkNode +{ friend class SingleLinkList; public: - SingleLinkList * owner; - SingleLinkNode * next; + SingleLinkList *owner; + SingleLinkNode *next; - virtual SingleLinkNode * NextNode() const { + virtual SingleLinkNode *NextNode() const + { return next; } - SingleLinkNode() : owner( 0 ), next( 0 ) { + SingleLinkNode() : owner(0), next(0) + { } - virtual ~SingleLinkNode() { + virtual ~SingleLinkNode() + { } }; diff --git a/src/clstepcore/SubSuperIterators.h b/src/clstepcore/SubSuperIterators.h index 9ca78765b..029d0999e 100644 --- a/src/clstepcore/SubSuperIterators.h +++ b/src/clstepcore/SubSuperIterators.h @@ -9,11 +9,12 @@ /** abstract base class for recursive breadth-first input iterators of EntityDescriptor/EntityDescLinkNode * NOTE: due to pure virtual functions being necessary for initialization, derived class constructor must call reset(t) */ -class recursiveEntDescripIterator { +class recursiveEntDescripIterator +{ protected: - const EntityDescriptor * startEntity; + const EntityDescriptor *startEntity; typedef struct { - const EntityDescriptor * ed; + const EntityDescriptor *ed; unsigned int depth; ///< for debugging; records how many lists had to be traversed to find the current node } queue_pair; @@ -21,146 +22,166 @@ class recursiveEntDescripIterator { unsigned int position; ///< primarily used in comparisons between iterators ///add contents of a linked list to q - void addLinkedList( const queue_pair qp ) { - EntityDescLinkNode * a = listHead( qp.ed ); + void addLinkedList(const queue_pair qp) + { + EntityDescLinkNode *a = listHead(qp.ed); queue_pair tmp; tmp.depth = qp.depth + 1; - while( a != 0 ) { - tmp.ed = nodeContent( a ); - q.push_back( tmp ); - a = ( EntityDescLinkNode * ) a->NextNode( ); + while(a != 0) { + tmp.ed = nodeContent(a); + q.push_back(tmp); + a = (EntityDescLinkNode *) a->NextNode(); } } - virtual EntityDescLinkNode * listHead( const EntityDescriptor * t ) const = 0; ///< returns the head of something inheriting SingleLinkList - virtual EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const = 0; ///< returns the content of a SingleLinkNode + virtual EntityDescLinkNode *listHead(const EntityDescriptor *t) const = 0; ///< returns the head of something inheriting SingleLinkList + virtual EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const = 0; ///< returns the content of a SingleLinkNode public: - recursiveEntDescripIterator( const EntityDescriptor * t = 0 ): startEntity( t ), position( 0 ) { + recursiveEntDescripIterator(const EntityDescriptor *t = 0): startEntity(t), position(0) + { //NOTE due to pure virtual functions, derived class constructor *must* call reset(t) } - ~recursiveEntDescripIterator( ) { + ~recursiveEntDescripIterator() + { } - void reset( const EntityDescriptor * t = 0 ) { + void reset(const EntityDescriptor *t = 0) + { position = 0; - q.clear( ); - if( t ) { + q.clear(); + if(t) { startEntity = t; } - if( startEntity ) { + if(startEntity) { queue_pair p; p.depth = 0; p.ed = startEntity; - addLinkedList( p ); + addLinkedList(p); } } - const EntityDescriptor * next( ) { - if( q.empty( ) ) { - return ( EntityDescriptor * ) 0; + const EntityDescriptor *next() + { + if(q.empty()) { + return (EntityDescriptor *) 0; } else { position++; - queue_pair qp = q.front( ); - q.pop_front( ); - addLinkedList( qp ); + queue_pair qp = q.front(); + q.pop_front(); + addLinkedList(qp); return qp.ed; } } - const EntityDescriptor * current( ) const { - if( q.empty( ) ) { - return ( EntityDescriptor * ) 0; + const EntityDescriptor *current() const + { + if(q.empty()) { + return (EntityDescriptor *) 0; } - return( q.front( ).ed ); + return(q.front().ed); } - bool hasNext( ) const { - return( ( ( q.size( ) > 1 ) && ( q[1].ed != 0 ) ) //there is another EntityDescriptor in q - || ( nodeContent( listHead( q[0].ed ) ) != 0 ) ); //or, the only one in the queue has a non-empty list + bool hasNext() const + { + return(((q.size() > 1) && (q[1].ed != 0)) //there is another EntityDescriptor in q + || (nodeContent(listHead(q[0].ed)) != 0)); //or, the only one in the queue has a non-empty list } - bool empty( ) const { - return q.empty( ); + bool empty() const + { + return q.empty(); } - unsigned int pos( ) const { + unsigned int pos() const + { return position; } - unsigned int depth( ) const { + unsigned int depth() const + { return q[0].depth; } - const EntityDescriptor * operator *( ) const { - return current( ); + const EntityDescriptor *operator *() const + { + return current(); } - const EntityDescriptor * operator ->( ) const { - return current( ); + const EntityDescriptor *operator ->() const + { + return current(); } /// two iterators are not considered equal unless the startEntity pointers match and the positions match - bool operator ==( const recursiveEntDescripIterator & b ) const { - return( ( startEntity == b.startEntity ) && ( position == b.position ) ); + bool operator ==(const recursiveEntDescripIterator &b) const + { + return((startEntity == b.startEntity) && (position == b.position)); } - bool operator !=( const recursiveEntDescripIterator & b ) const { - return( ( startEntity != b.startEntity ) || ( position != b.position ) ); + bool operator !=(const recursiveEntDescripIterator &b) const + { + return((startEntity != b.startEntity) || (position != b.position)); } /// for inequality operators, return a Logical; LUnknown means that the startEntity pointers do not match - Logical operator >( const recursiveEntDescripIterator & b ) const { - if( startEntity != b.startEntity ) { + Logical operator >(const recursiveEntDescripIterator &b) const + { + if(startEntity != b.startEntity) { return LUnknown; } - if( position > b.position ) { + if(position > b.position) { return LTrue; } else { return LFalse; } } - Logical operator <( const recursiveEntDescripIterator & b ) const { - if( startEntity != b.startEntity ) { + Logical operator <(const recursiveEntDescripIterator &b) const + { + if(startEntity != b.startEntity) { return LUnknown; } - if( position < b.position ) { + if(position < b.position) { return LTrue; } else { return LFalse; } } - Logical operator >=( const recursiveEntDescripIterator & b ) const { - if( startEntity != b.startEntity ) { + Logical operator >=(const recursiveEntDescripIterator &b) const + { + if(startEntity != b.startEntity) { return LUnknown; } - if( position >= b.position ) { + if(position >= b.position) { return LTrue; } else { return LFalse; } } - Logical operator <=( const recursiveEntDescripIterator & b ) const { - if( startEntity != b.startEntity ) { + Logical operator <=(const recursiveEntDescripIterator &b) const + { + if(startEntity != b.startEntity) { return LUnknown; } - if( position <= b.position ) { + if(position <= b.position) { return LTrue; } else { return LFalse; } } - const EntityDescriptor * operator ++( ) { - return next( ); + const EntityDescriptor *operator ++() + { + return next(); } - const EntityDescriptor * operator ++( int ) { - const EntityDescriptor * c = current( ); - next( ); + const EntityDescriptor *operator ++(int) + { + const EntityDescriptor *c = current(); + next(); return c; } }; @@ -168,46 +189,54 @@ class recursiveEntDescripIterator { /** Recursive breadth-first input iterator for supertypes * \sa subtypesIterator */ -class supertypesIterator : public recursiveEntDescripIterator { +class supertypesIterator : public recursiveEntDescripIterator +{ protected: - EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList - if( !t ) { + EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList + { + if(!t) { return 0; } - return ( EntityDescLinkNode * ) t->Supertypes().GetHead(); + return (EntityDescLinkNode *) t->Supertypes().GetHead(); } - EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode - if( !n ) { + EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode + { + if(!n) { return 0; } return n->EntityDesc(); } public: - supertypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { - reset( t ); + supertypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) + { + reset(t); } }; /** Recursive breadth-first input iterator for subtypes * \sa supertypesIterator */ -class subtypesIterator: public recursiveEntDescripIterator { +class subtypesIterator: public recursiveEntDescripIterator +{ protected: - EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList - if( !t ) { + EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList + { + if(!t) { return 0; } - return ( EntityDescLinkNode * ) t->Subtypes().GetHead(); + return (EntityDescLinkNode *) t->Subtypes().GetHead(); } - EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode - if( !n ) { + EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode + { + if(!n) { return 0; } return n->EntityDesc(); } public: - subtypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { - reset( t ); + subtypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) + { + reset(t); } }; diff --git a/src/clstepcore/aggrTypeDescriptor.cc b/src/clstepcore/aggrTypeDescriptor.cc index 91bed40be..6b6a5857e 100644 --- a/src/clstepcore/aggrTypeDescriptor.cc +++ b/src/clstepcore/aggrTypeDescriptor.cc @@ -1,31 +1,36 @@ #include "aggrTypeDescriptor.h" -STEPaggregate * AggrTypeDescriptor::CreateAggregate() { - if( CreateNewAggr ) { +STEPaggregate *AggrTypeDescriptor::CreateAggregate() +{ + if(CreateNewAggr) { return CreateNewAggr(); } else { return 0; } } -void AggrTypeDescriptor::AssignAggrCreator( AggregateCreator f ) { +void AggrTypeDescriptor::AssignAggrCreator(AggregateCreator f) +{ CreateNewAggr = f; } -AggrTypeDescriptor::AggrTypeDescriptor( ) : -_uniqueElements( "UNKNOWN_TYPE" ) { +AggrTypeDescriptor::AggrTypeDescriptor() : + _uniqueElements("UNKNOWN_TYPE") +{ _bound1 = -1; _bound2 = -1; _aggrDomainType = 0; } -AggrTypeDescriptor::AggrTypeDescriptor( SDAI_Integer b1, - SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor * aggrDomType ) -: _bound1( b1 ), _bound2( b2 ), _uniqueElements( uniqElem ) { +AggrTypeDescriptor::AggrTypeDescriptor(SDAI_Integer b1, + SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor *aggrDomType) + : _bound1(b1), _bound2(b2), _uniqueElements(uniqElem) +{ _aggrDomainType = aggrDomType; } -AggrTypeDescriptor::~AggrTypeDescriptor() { +AggrTypeDescriptor::~AggrTypeDescriptor() +{ } diff --git a/src/clstepcore/aggrTypeDescriptor.h b/src/clstepcore/aggrTypeDescriptor.h index 850a6b2e7..98da5579d 100644 --- a/src/clstepcore/aggrTypeDescriptor.h +++ b/src/clstepcore/aggrTypeDescriptor.h @@ -24,203 +24,232 @@ enum AggrBoundTypeEnum { * together by the _aggrDomainType variables. If you can make this * work then go for it. */ -class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor { +class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor +{ -protected: + protected: - SDAI_Integer _bound1, _bound2; - SDAI_LOGICAL _uniqueElements; - TypeDescriptor * _aggrDomainType; - AggregateCreator CreateNewAggr; + SDAI_Integer _bound1, _bound2; + SDAI_LOGICAL _uniqueElements; + TypeDescriptor *_aggrDomainType; + AggregateCreator CreateNewAggr; - AggrBoundTypeEnum _bound1_type, _bound2_type; - boundCallbackFn _bound1_callback, _bound2_callback; + AggrBoundTypeEnum _bound1_type, _bound2_type; + boundCallbackFn _bound1_callback, _bound2_callback; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::string _bound1_str, _bound2_str; + std::string _bound1_str, _bound2_str; #ifdef _MSC_VER #pragma warning( pop ) #endif -public: - - void AssignAggrCreator( AggregateCreator f = 0 ); - - STEPaggregate * CreateAggregate(); - - AggrTypeDescriptor( ); - AggrTypeDescriptor( SDAI_Integer b1, SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor * aggrDomType ); - AggrTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - AggregateCreator f = 0 ) - : TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ) { } - virtual ~AggrTypeDescriptor(); - - - /// find bound type - AggrBoundTypeEnum Bound1Type() const { - return _bound1_type; - } - /// get a constant bound - SDAI_Integer Bound1( ) const { - assert( _bound1_type == bound_constant ); - return _bound1; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound1Runtime( SDAI_Application_instance * this_ptr ) const { - assert( this_ptr && ( _bound1_type == bound_runtime ) ); - return _bound1_callback( this_ptr ) ; - } - /// get a bound's EXPRESS function call string - std::string Bound1Funcall() const { - return _bound1_str; - } - /// set bound to a constant - void SetBound1( SDAI_Integer b1 ) { - _bound1 = b1; - _bound1_type = bound_constant; - } - ///set bound's callback fn. only for bounds dependent on an attribute - void SetBound1FromMemberAccessor( boundCallbackFn callback ) { - _bound1_callback = callback; - _bound1_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound1FromExpressFuncall( std::string s ) { - _bound1_str = s; - _bound1_type = bound_funcall; - } - - /// find bound type - AggrBoundTypeEnum Bound2Type() const { - return _bound2_type; - } - /// get a constant bound - SDAI_Integer Bound2( ) const { - assert( _bound2_type == bound_constant ); - return _bound2; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound2Runtime( SDAI_Application_instance * this_ptr ) const { - assert( this_ptr && ( _bound2_type == bound_runtime ) ); - return _bound2_callback( this_ptr ) ; - } - /// get a bound's EXPRESS function call string - std::string Bound2Funcall() const { - return _bound2_str; - } - /// set bound to a constant - void SetBound2( SDAI_Integer b2 ) { - _bound2 = b2; - _bound2_type = bound_constant; - } - ///set bound's callback fn - void SetBound2FromMemberAccessor( boundCallbackFn callback ) { - _bound2_callback = callback; - _bound2_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound2FromExpressFuncall( std::string s ) { - _bound2_str = s; - _bound2_type = bound_funcall; - } - - SDAI_LOGICAL & UniqueElements() { - return _uniqueElements; - } - void UniqueElements( SDAI_LOGICAL & ue ) { - _uniqueElements.put( ue.asInt() ); - } - void UniqueElements( Logical ue ) { - _uniqueElements.put( ue ); - } - void UniqueElements( const char * ue ) { - _uniqueElements.put( ue ); - } - - class TypeDescriptor * AggrDomainType() { - return _aggrDomainType; - } - void AggrDomainType( TypeDescriptor * adt ) { - _aggrDomainType = adt; - } + public: + + void AssignAggrCreator(AggregateCreator f = 0); + + STEPaggregate *CreateAggregate(); + + AggrTypeDescriptor(); + AggrTypeDescriptor(SDAI_Integer b1, SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor *aggrDomType); + AggrTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + AggregateCreator f = 0) + : TypeDescriptor(nm, ft, origSchema, d), _bound1(0), _bound2(0), _uniqueElements(0), _aggrDomainType(NULL), CreateNewAggr(f) { } + virtual ~AggrTypeDescriptor(); + + + /// find bound type + AggrBoundTypeEnum Bound1Type() const + { + return _bound1_type; + } + /// get a constant bound + SDAI_Integer Bound1() const + { + assert(_bound1_type == bound_constant); + return _bound1; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound1Runtime(SDAI_Application_instance *this_ptr) const + { + assert(this_ptr && (_bound1_type == bound_runtime)); + return _bound1_callback(this_ptr) ; + } + /// get a bound's EXPRESS function call string + std::string Bound1Funcall() const + { + return _bound1_str; + } + /// set bound to a constant + void SetBound1(SDAI_Integer b1) + { + _bound1 = b1; + _bound1_type = bound_constant; + } + ///set bound's callback fn. only for bounds dependent on an attribute + void SetBound1FromMemberAccessor(boundCallbackFn callback) + { + _bound1_callback = callback; + _bound1_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound1FromExpressFuncall(std::string s) + { + _bound1_str = s; + _bound1_type = bound_funcall; + } + + /// find bound type + AggrBoundTypeEnum Bound2Type() const + { + return _bound2_type; + } + /// get a constant bound + SDAI_Integer Bound2() const + { + assert(_bound2_type == bound_constant); + return _bound2; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound2Runtime(SDAI_Application_instance *this_ptr) const + { + assert(this_ptr && (_bound2_type == bound_runtime)); + return _bound2_callback(this_ptr) ; + } + /// get a bound's EXPRESS function call string + std::string Bound2Funcall() const + { + return _bound2_str; + } + /// set bound to a constant + void SetBound2(SDAI_Integer b2) + { + _bound2 = b2; + _bound2_type = bound_constant; + } + ///set bound's callback fn + void SetBound2FromMemberAccessor(boundCallbackFn callback) + { + _bound2_callback = callback; + _bound2_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound2FromExpressFuncall(std::string s) + { + _bound2_str = s; + _bound2_type = bound_funcall; + } + + SDAI_LOGICAL &UniqueElements() + { + return _uniqueElements; + } + void UniqueElements(SDAI_LOGICAL &ue) + { + _uniqueElements.put(ue.asInt()); + } + void UniqueElements(Logical ue) + { + _uniqueElements.put(ue); + } + void UniqueElements(const char *ue) + { + _uniqueElements.put(ue); + } + + class TypeDescriptor *AggrDomainType() + { + return _aggrDomainType; + } + void AggrDomainType(TypeDescriptor *adt) + { + _aggrDomainType = adt; + } }; -class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor { - -protected: - SDAI_LOGICAL _optionalElements; -public: - - ArrayTypeDescriptor( ) : _optionalElements( "UNKNOWN_TYPE" ) { } - ArrayTypeDescriptor( Logical optElem ) : _optionalElements( optElem ) - { } - ArrayTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - AggregateCreator f = 0 ) - : AggrTypeDescriptor( nm, ft, origSchema, d, f ), - _optionalElements( "UNKNOWN_TYPE" ) - { } - - virtual ~ArrayTypeDescriptor() {} - - - SDAI_LOGICAL & OptionalElements() { - return _optionalElements; - } - void OptionalElements( SDAI_LOGICAL & oe ) { - _optionalElements.put( oe.asInt() ); - } - void OptionalElements( Logical oe ) { - _optionalElements.put( oe ); - } - void OptionalElements( const char * oe ) { - _optionalElements.put( oe ); - } +class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor +{ + + protected: + SDAI_LOGICAL _optionalElements; + public: + + ArrayTypeDescriptor() : _optionalElements("UNKNOWN_TYPE") { } + ArrayTypeDescriptor(Logical optElem) : _optionalElements(optElem) + { } + ArrayTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + AggregateCreator f = 0) + : AggrTypeDescriptor(nm, ft, origSchema, d, f), + _optionalElements("UNKNOWN_TYPE") + { } + + virtual ~ArrayTypeDescriptor() {} + + + SDAI_LOGICAL &OptionalElements() + { + return _optionalElements; + } + void OptionalElements(SDAI_LOGICAL &oe) + { + _optionalElements.put(oe.asInt()); + } + void OptionalElements(Logical oe) + { + _optionalElements.put(oe); + } + void OptionalElements(const char *oe) + { + _optionalElements.put(oe); + } }; -class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor { +class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor +{ -protected: -public: - ListTypeDescriptor( ) { } - ListTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - AggregateCreator f = 0 ) - : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } - virtual ~ListTypeDescriptor() { } + protected: + public: + ListTypeDescriptor() { } + ListTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + AggregateCreator f = 0) + : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } + virtual ~ListTypeDescriptor() { } }; -class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor { +class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor +{ -protected: -public: + protected: + public: - SetTypeDescriptor( ) { } - SetTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - AggregateCreator f = 0 ) - : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } - virtual ~SetTypeDescriptor() { } + SetTypeDescriptor() { } + SetTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + AggregateCreator f = 0) + : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } + virtual ~SetTypeDescriptor() { } }; -class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor { +class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor +{ -protected: -public: + protected: + public: - BagTypeDescriptor( ) { } - BagTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - AggregateCreator f = 0 ) - : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } - virtual ~BagTypeDescriptor() { } + BagTypeDescriptor() { } + BagTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + AggregateCreator f = 0) + : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } + virtual ~BagTypeDescriptor() { } }; diff --git a/src/clstepcore/attrDescriptor.cc b/src/clstepcore/attrDescriptor.cc index 329d90393..f95b8dfaa 100644 --- a/src/clstepcore/attrDescriptor.cc +++ b/src/clstepcore/attrDescriptor.cc @@ -1,101 +1,115 @@ #include "attrDescriptor.h" -AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType, - Logical optional, Logical unique, AttrType_Enum at, - const EntityDescriptor & owner ) - : _name( name ), _domainType( domainType ), _optional( optional ), - _unique( unique ), _attrType( at ), _owner( ( EntityDescriptor & )owner ) { +AttrDescriptor::AttrDescriptor(const char *name, const TypeDescriptor *domainType, + Logical optional, Logical unique, AttrType_Enum at, + const EntityDescriptor &owner) + : _name(name), _domainType(domainType), _optional(optional), + _unique(unique), _attrType(at), _owner((EntityDescriptor &)owner) +{ } -AttrDescriptor::~AttrDescriptor() { +AttrDescriptor::~AttrDescriptor() +{ } -Logical AttrDescriptor::Explicit() const { - if( _attrType == AttrType_Explicit ) { +Logical AttrDescriptor::Explicit() const +{ + if(_attrType == AttrType_Explicit) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Inverse() const { - if( _attrType == AttrType_Inverse ) { +Logical AttrDescriptor::Inverse() const +{ + if(_attrType == AttrType_Inverse) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Redefining() const { - if( _attrType == AttrType_Redefining ) { +Logical AttrDescriptor::Redefining() const +{ + if(_attrType == AttrType_Redefining) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Deriving() const { - if( _attrType == AttrType_Deriving ) { +Logical AttrDescriptor::Deriving() const +{ + if(_attrType == AttrType_Deriving) { return LTrue; } return LFalse; } -const char * AttrDescriptor::AttrExprDefStr( std::string & s ) const { +const char *AttrDescriptor::AttrExprDefStr(std::string &s) const +{ std::string buf; s = Name(); - s.append( " : " ); - if( _optional.asInt() == LTrue ) { - s.append( "OPTIONAL " ); + s.append(" : "); + if(_optional.asInt() == LTrue) { + s.append("OPTIONAL "); } - if( DomainType() ) { - DomainType()->AttrTypeName( buf ); - s.append( buf ); + if(DomainType()) { + DomainType()->AttrTypeName(buf); + s.append(buf); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -PrimitiveType AttrDescriptor::BaseType() const { - if( _domainType ) { +PrimitiveType AttrDescriptor::BaseType() const +{ + if(_domainType) { return _domainType->BaseType(); } return UNKNOWN_TYPE; } -int AttrDescriptor::IsAggrType() const { +int AttrDescriptor::IsAggrType() const +{ return ReferentType()->IsAggrType(); } -PrimitiveType AttrDescriptor::AggrElemType() const { - if( IsAggrType() ) { +PrimitiveType AttrDescriptor::AggrElemType() const +{ + if(IsAggrType()) { return ReferentType()->AggrElemType(); } return UNKNOWN_TYPE; } -const TypeDescriptor * AttrDescriptor::AggrElemTypeDescriptor() const { - if( IsAggrType() ) { +const TypeDescriptor *AttrDescriptor::AggrElemTypeDescriptor() const +{ + if(IsAggrType()) { return ReferentType()->AggrElemTypeDescriptor(); } return 0; } -const TypeDescriptor * AttrDescriptor::NonRefTypeDescriptor() const { - if( _domainType ) { +const TypeDescriptor *AttrDescriptor::NonRefTypeDescriptor() const +{ + if(_domainType) { return _domainType->NonRefTypeDescriptor(); } return 0; } PrimitiveType -AttrDescriptor::NonRefType() const { - if( _domainType ) { +AttrDescriptor::NonRefType() const +{ + if(_domainType) { return _domainType->NonRefType(); } return UNKNOWN_TYPE; } PrimitiveType -AttrDescriptor::Type() const { - if( _domainType ) { +AttrDescriptor::Type() const +{ + if(_domainType) { return _domainType->Type(); } return UNKNOWN_TYPE; @@ -105,34 +119,37 @@ AttrDescriptor::Type() const { * right side of attr def * NOTE this returns a \'const char * \' instead of an std::string */ -const std::string AttrDescriptor::TypeName() const { +const std::string AttrDescriptor::TypeName() const +{ std::string buf; - if( _domainType ) { - _domainType->AttrTypeName( buf ); + if(_domainType) { + _domainType->AttrTypeName(buf); } return buf; } /// an expanded right side of attr def const char * -AttrDescriptor::ExpandedTypeName( std::string & s ) const { +AttrDescriptor::ExpandedTypeName(std::string &s) const +{ s.clear(); - if( Derived() == LTrue ) { + if(Derived() == LTrue) { s = "DERIVE "; } - if( _domainType ) { + if(_domainType) { std::string tmp; - return const_cast( ( s.append( _domainType->TypeString( tmp ) ).c_str() ) ); + return const_cast((s.append(_domainType->TypeString(tmp)).c_str())); } else { return 0; } } -const char * AttrDescriptor::GenerateExpress( std::string & buf ) const { +const char *AttrDescriptor::GenerateExpress(std::string &buf) const +{ std::string sstr; - buf = AttrExprDefStr( sstr ); - buf.append( ";\n" ); - return const_cast( buf.c_str() ); + buf = AttrExprDefStr(sstr); + buf.append(";\n"); + return const_cast(buf.c_str()); } diff --git a/src/clstepcore/attrDescriptor.h b/src/clstepcore/attrDescriptor.h index cee4d13bc..f681e111e 100644 --- a/src/clstepcore/attrDescriptor.h +++ b/src/clstepcore/attrDescriptor.h @@ -20,39 +20,42 @@ class EntityDescriptor; * An instance of this class will be generated for each attribute for * an Entity. They will be pointed to by the EntityTypeDescriptors. */ -class SC_CORE_EXPORT AttrDescriptor { +class SC_CORE_EXPORT AttrDescriptor +{ protected: - const char * _name; // the attributes name + const char *_name; // the attributes name // this defines the domain of the attribute - const TypeDescriptor * _domainType; + const TypeDescriptor *_domainType; SDAI_LOGICAL _optional; SDAI_LOGICAL _unique; AttrType_Enum _attrType; // former attribute _derived - const EntityDescriptor & _owner; // the owning entityDescriptor + const EntityDescriptor &_owner; // the owning entityDescriptor public: AttrDescriptor( - const char * name, // i.e. char * - const TypeDescriptor * domainType, + const char *name, // i.e. char * + const TypeDescriptor *domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor & owner + const EntityDescriptor &owner ); virtual ~AttrDescriptor(); - const char * GenerateExpress( std::string & buf ) const; + const char *GenerateExpress(std::string &buf) const; // the attribute Express def - virtual const char * AttrExprDefStr( std::string & s ) const; + virtual const char *AttrExprDefStr(std::string &s) const; // left side of attr def - const char * Name() const { + const char *Name() const + { return _name; } - void Name( const char * n ) { + void Name(const char *n) + { _name = n; } @@ -76,7 +79,7 @@ class SC_CORE_EXPORT AttrDescriptor { */ ///@{ PrimitiveType BaseType() const; - const TypeDescriptor * BaseTypeDescriptor() const; + const TypeDescriptor *BaseTypeDescriptor() const; ///@} /** @@ -92,12 +95,12 @@ class SC_CORE_EXPORT AttrDescriptor { */ ///@{ PrimitiveType NonRefType() const; - const TypeDescriptor * NonRefTypeDescriptor() const; + const TypeDescriptor *NonRefTypeDescriptor() const; ///@} int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor * AggrElemTypeDescriptor() const; + const TypeDescriptor *AggrElemTypeDescriptor() const; /// The type of the attributes TypeDescriptor PrimitiveType Type() const; @@ -106,56 +109,71 @@ class SC_CORE_EXPORT AttrDescriptor { const std::string TypeName() const; /// an expanded right side of attr def - const char * ExpandedTypeName( std::string & s ) const; + const char *ExpandedTypeName(std::string &s) const; - int RefersToType() const { - return !( _domainType == 0 ); + int RefersToType() const + { + return !(_domainType == 0); } - const TypeDescriptor * ReferentType() const { + const TypeDescriptor *ReferentType() const + { return _domainType; } - const TypeDescriptor * DomainType() const { + const TypeDescriptor *DomainType() const + { return _domainType; } - void DomainType( const TypeDescriptor * td ) { + void DomainType(const TypeDescriptor *td) + { _domainType = td; } - void ReferentType( const TypeDescriptor * td ) { + void ReferentType(const TypeDescriptor *td) + { _domainType = td; } - const SDAI_LOGICAL & Optional() const { + const SDAI_LOGICAL &Optional() const + { return _optional; } - void Optional( SDAI_LOGICAL & opt ) { - _optional.put( opt.asInt() ); + void Optional(SDAI_LOGICAL &opt) + { + _optional.put(opt.asInt()); } - void Optional( Logical opt ) { - _optional.put( opt ); + void Optional(Logical opt) + { + _optional.put(opt); } - void Optional( const char * opt ) { - _optional.put( opt ); + void Optional(const char *opt) + { + _optional.put(opt); } - const SDAI_LOGICAL & Unique() const { + const SDAI_LOGICAL &Unique() const + { return _unique; } - void Unique( SDAI_LOGICAL uniq ) { - _unique.put( uniq.asInt() ); + void Unique(SDAI_LOGICAL uniq) + { + _unique.put(uniq.asInt()); } - void Unique( Logical uniq ) { - _unique.put( uniq ); + void Unique(Logical uniq) + { + _unique.put(uniq); } - void Unique( const char * uniq ) { - _unique.put( uniq ); + void Unique(const char *uniq) + { + _unique.put(uniq); } - void AttrType( enum AttrType_Enum ate ) { + void AttrType(enum AttrType_Enum ate) + { _attrType = ate; } - enum AttrType_Enum AttrType() const { + enum AttrType_Enum AttrType() const + { return _attrType; } @@ -165,40 +183,50 @@ class SC_CORE_EXPORT AttrDescriptor { Logical Deriving() const; //outdated functions, use AttrType func above, new support of redefined - Logical Derived() const { + Logical Derived() const + { return Deriving(); } - void Derived( Logical x ); // outdated DAS - void Derived( SDAI_LOGICAL x ); // outdated DAS - void Derived( const char * x ); // outdated DAS + void Derived(Logical x); // outdated DAS + void Derived(SDAI_LOGICAL x); // outdated DAS + void Derived(const char *x); // outdated DAS - const SDAI_LOGICAL & Optionality() const { + const SDAI_LOGICAL &Optionality() const + { return _optional; } - void Optionality( SDAI_LOGICAL & opt ) { - _optional.put( opt.asInt() ); + void Optionality(SDAI_LOGICAL &opt) + { + _optional.put(opt.asInt()); } - void Optionality( Logical opt ) { - _optional.put( opt ); + void Optionality(Logical opt) + { + _optional.put(opt); } - void Optionality( const char * opt ) { - _optional.put( opt ); + void Optionality(const char *opt) + { + _optional.put(opt); } - const SDAI_LOGICAL & Uniqueness() const { + const SDAI_LOGICAL &Uniqueness() const + { return _unique; } - void Uniqueness( SDAI_LOGICAL uniq ) { - _unique.put( uniq.asInt() ); + void Uniqueness(SDAI_LOGICAL uniq) + { + _unique.put(uniq.asInt()); } - void Uniqueness( Logical uniq ) { - _unique.put( uniq ); + void Uniqueness(Logical uniq) + { + _unique.put(uniq); } - void Uniqueness( const char * uniq ) { - _unique.put( uniq ); + void Uniqueness(const char *uniq) + { + _unique.put(uniq); } - const EntityDescriptor & Owner() const { + const EntityDescriptor &Owner() const + { return _owner; } }; diff --git a/src/clstepcore/attrDescriptorList.cc b/src/clstepcore/attrDescriptorList.cc index c197ac5e2..e75f23c41 100644 --- a/src/clstepcore/attrDescriptorList.cc +++ b/src/clstepcore/attrDescriptorList.cc @@ -2,40 +2,48 @@ #include "attrDescriptor.h" -AttrDescriptorList::AttrDescriptorList() { +AttrDescriptorList::AttrDescriptorList() +{ } -AttrDescriptorList::~AttrDescriptorList() { +AttrDescriptorList::~AttrDescriptorList() +{ } -AttrDescLinkNode * AttrDescriptorList::AddNode( AttrDescriptor * ad ) { - AttrDescLinkNode * node = ( AttrDescLinkNode * ) NewNode(); - node->AttrDesc( ad ); - SingleLinkList::AppendNode( node ); +AttrDescLinkNode *AttrDescriptorList::AddNode(AttrDescriptor *ad) +{ + AttrDescLinkNode *node = (AttrDescLinkNode *) NewNode(); + node->AttrDesc(ad); + SingleLinkList::AppendNode(node); return node; } -AttrDescLinkNode::AttrDescLinkNode() { +AttrDescLinkNode::AttrDescLinkNode() +{ _attrDesc = 0; } -AttrDescLinkNode::~AttrDescLinkNode() { - if( _attrDesc ) { +AttrDescLinkNode::~AttrDescLinkNode() +{ + if(_attrDesc) { delete _attrDesc; } } -AttrDescItr::AttrDescItr( const AttrDescriptorList & adList ) : adl( adList ) { - cur = ( AttrDescLinkNode * )( adl.GetHead() ); +AttrDescItr::AttrDescItr(const AttrDescriptorList &adList) : adl(adList) +{ + cur = (AttrDescLinkNode *)(adl.GetHead()); } -AttrDescItr::~AttrDescItr() { +AttrDescItr::~AttrDescItr() +{ } -const AttrDescriptor * AttrDescItr::NextAttrDesc() { - if( cur ) { - const AttrDescriptor * ad = cur->AttrDesc(); - cur = ( AttrDescLinkNode * )( cur->NextNode() ); +const AttrDescriptor *AttrDescItr::NextAttrDesc() +{ + if(cur) { + const AttrDescriptor *ad = cur->AttrDesc(); + cur = (AttrDescLinkNode *)(cur->NextNode()); return ad; } return 0; diff --git a/src/clstepcore/attrDescriptorList.h b/src/clstepcore/attrDescriptorList.h index a1c844a8f..c6550ba82 100644 --- a/src/clstepcore/attrDescriptorList.h +++ b/src/clstepcore/attrDescriptorList.h @@ -9,50 +9,57 @@ class AttrDescriptor; -class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode { +class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode +{ private: protected: - AttrDescriptor * _attrDesc; + AttrDescriptor *_attrDesc; public: AttrDescLinkNode(); virtual ~AttrDescLinkNode(); - const AttrDescriptor * AttrDesc() const { + const AttrDescriptor *AttrDesc() const + { return _attrDesc; } - void AttrDesc( AttrDescriptor * ad ) { + void AttrDesc(AttrDescriptor *ad) + { _attrDesc = ad; } }; -class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList { +class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList +{ private: protected: public: AttrDescriptorList(); virtual ~AttrDescriptorList(); - virtual SingleLinkNode * NewNode() { + virtual SingleLinkNode *NewNode() + { return new AttrDescLinkNode; } - AttrDescLinkNode * AddNode( AttrDescriptor * ad ); + AttrDescLinkNode *AddNode(AttrDescriptor *ad); }; -class SC_CORE_EXPORT AttrDescItr { +class SC_CORE_EXPORT AttrDescItr +{ protected: - const AttrDescriptorList & adl; - const AttrDescLinkNode * cur; + const AttrDescriptorList &adl; + const AttrDescLinkNode *cur; public: - AttrDescItr( const AttrDescriptorList & adList ); + AttrDescItr(const AttrDescriptorList &adList); virtual ~AttrDescItr(); - void ResetItr() { - cur = ( AttrDescLinkNode * )( adl.GetHead() ); + void ResetItr() + { + cur = (AttrDescLinkNode *)(adl.GetHead()); } - const AttrDescriptor * NextAttrDesc(); + const AttrDescriptor *NextAttrDesc(); }; #endif //ATTRDESCRIPTORLIST_H diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index b6abef73c..92c95cc88 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -18,14 +18,15 @@ * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ -void ComplexCollect::insert( ComplexList * c ) { - ComplexList * prev = NULL, *cl = clists; +void ComplexCollect::insert(ComplexList *c) +{ + ComplexList *prev = NULL, *cl = clists; - while( cl && *cl < *c ) { + while(cl && *cl < *c) { prev = cl; cl = cl->next; } - if( prev == NULL ) { + if(prev == NULL) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -46,18 +47,19 @@ void ComplexCollect::insert( ComplexList * c ) { * be able to find it, and now that all its supers have accessed it, we * remove it from the Collect. */ -void ComplexCollect::remove( ComplexList * c ) { - ComplexList * cl = clists, *prev = NULL; +void ComplexCollect::remove(ComplexList *c) +{ + ComplexList *cl = clists, *prev = NULL; - while( cl && *cl < *c ) { + while(cl && *cl < *c) { prev = cl; cl = cl->next; } - if( cl == NULL || cl != c ) { + if(cl == NULL || cl != c) { // Just in case c isn't in the list. return; } - if( prev == NULL ) { + if(prev == NULL) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -71,13 +73,14 @@ void ComplexCollect::remove( ComplexList * c ) { /** * Searches for and returns the ComplexList whose supertype name = name. */ -ComplexList * ComplexCollect::find( char * name ) { - ComplexList * cl = clists; +ComplexList *ComplexCollect::find(char *name) +{ + ComplexList *cl = clists; - while( cl && *cl < name ) { + while(cl && *cl < name) { cl = cl->next; } - if( cl && *cl == name ) { + if(cl && *cl == name) { return cl; } return NULL; @@ -91,37 +94,38 @@ ComplexList * ComplexCollect::find( char * name ) { * should be included in >1 CList. A more complicated algorithm is applied * to match it, as described in the commenting. */ -bool ComplexCollect::supports( EntNode * ents ) const { - EntNode * node = ents, *nextnode; - AndList * alist = 0; - ComplexList * clist = clists, *cl = NULL, *current; +bool ComplexCollect::supports(EntNode *ents) const +{ + EntNode *node = ents, *nextnode; + AndList *alist = 0; + ComplexList *clist = clists, *cl = NULL, *current; bool retval; - EntList * elist, *next; + EntList *elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while( node ) { - if( node->multSuprs() ) { + while(node) { + if(node->multSuprs()) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if( !cl ) { + if(!cl) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList( alist ); + cl = new ComplexList(alist); } current = clists; - while( current ) { - if( current->contains( node ) ) { + while(current) { + if(current->contains(node)) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if( ! cl->toplevel( current->supertype() ) ) { + if(! cl->toplevel(current->supertype())) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList( current->head->childList ); + alist->appendList(current->head->childList); } } current = current->next; @@ -133,11 +137,11 @@ bool ComplexCollect::supports( EntNode * ents ) const { // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if( !cl ) { + if(!cl) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while( clist != NULL ) { - if( clist->matches( ents ) ) { + while(clist != NULL) { + if(clist->matches(ents)) { return true; } clist = clist->next; @@ -148,13 +152,13 @@ bool ComplexCollect::supports( EntNode * ents ) const { // Use cl to test that the conditions of all supertypes are met: cl->multSupers = true; cl->buildList(); - retval = cl->matches( ents ); + retval = cl->matches(ents); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while( elist ) { + while(elist) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index 46b673b46..00490df23 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -72,7 +72,8 @@ class OrList; class ComplexList; class ComplexCollect; -class SC_CORE_EXPORT EntNode { +class SC_CORE_EXPORT EntNode +{ friend class SimpleList; friend class AndOrList; friend class AndList; @@ -80,90 +81,108 @@ class SC_CORE_EXPORT EntNode { friend class ComplexList; public: - EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), multSupers( 0 ) { - StrToLower( nm, name ); - } - EntNode( const char ** ); ///< given a list, create a linked list of EntNodes - ~EntNode() { - if( next ) { + EntNode(const char *nm = "") : next(0), mark(NOMARK), multSupers(0) + { + StrToLower(nm, name); + } + EntNode(const char **); ///< given a list, create a linked list of EntNodes + ~EntNode() + { + if(next) { delete next; } } - operator const char * () { + operator const char *() + { return name; } - bool operator== ( EntNode & ent ) { - return ( strcmp( name, ent.name ) == 0 ); + bool operator== (EntNode &ent) + { + return (strcmp(name, ent.name) == 0); } - bool operator< ( EntNode & ent ) { - return ( strcmp( name, ent.name ) < 0 ); + bool operator< (EntNode &ent) + { + return (strcmp(name, ent.name) < 0); } - bool operator> ( EntNode & ent ) { - return ( strcmp( name, ent.name ) > 0 ); + bool operator> (EntNode &ent) + { + return (strcmp(name, ent.name) > 0); } - EntNode & operator= ( EntNode & ent ); - void Name( const char * nm ) { - strncpy( name, nm, BUFSIZ - 1 ); + EntNode &operator= (EntNode &ent); + void Name(const char *nm) + { + strncpy(name, nm, BUFSIZ - 1); } - const char * Name() { + const char *Name() + { return name; } - void setmark( MarkType stamp = MARK ) { + void setmark(MarkType stamp = MARK) + { mark = stamp; } - void markAll( MarkType = MARK ); - void unmarkAll() { - markAll( NOMARK ); + void markAll(MarkType = MARK); + void unmarkAll() + { + markAll(NOMARK); } - bool marked( MarkType base = ORMARK ) { - return ( mark >= base ); + bool marked(MarkType base = ORMARK) + { + return (mark >= base); } bool allMarked(); ///< returns true if all nodes in list are marked int unmarkedCount(); - bool multSuprs() { + bool multSuprs() + { return multSupers; } - void multSuprs( int j ) { + void multSuprs(int j) + { multSupers = j; } - void sort( EntNode ** ); + void sort(EntNode **); - EntNode * next; + EntNode *next; private: MarkType mark; char name[BUFSIZ]; bool multSupers; ///< do I correspond to an entity with >1 supertype? - EntNode * lastSmaller( EntNode * ); ///< used by ::sort() + EntNode *lastSmaller(EntNode *); ///< used by ::sort() }; -class SC_CORE_EXPORT EntList { +class SC_CORE_EXPORT EntList +{ friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, EntList & ); - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, EntList &); + friend ostream &operator<< (ostream &, MultList &); public: - EntList( JoinType j ) : join( j ), next( 0 ), prev( 0 ), viable( UNKNOWN ), - level( 0 ) {} + EntList(JoinType j) : join(j), next(0), prev(0), viable(UNKNOWN), + level(0) {} virtual ~EntList() {} - MatchType viableVal() { + MatchType viableVal() + { return viable; } - virtual void setLevel( int l ) { + virtual void setLevel(int l) + { level = l; } - virtual bool contains( char * ) = 0; - virtual bool hit( char * ) = 0; - virtual MatchType matchNonORs( EntNode * ) { + virtual bool contains(char *) = 0; + virtual bool hit(char *) = 0; + virtual MatchType matchNonORs(EntNode *) + { return UNKNOWN; } - virtual bool acceptChoice( EntNode * ) = 0; - virtual void unmarkAll( EntNode * ) = 0; - virtual void reset() { + virtual bool acceptChoice(EntNode *) = 0; + virtual void unmarkAll(EntNode *) = 0; + virtual void reset() + { viable = UNKNOWN; } int siblings(); @@ -171,28 +190,33 @@ class SC_CORE_EXPORT EntList { // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList * firstNot( JoinType ); - EntList * nextNot( JoinType j ) { - return next->firstNot( j ); + EntList *firstNot(JoinType); + EntList *nextNot(JoinType j) + { + return next->firstNot(j); } - EntList * firstWanted( MatchType ); - EntList * nextWanted( MatchType mat ) { - return next->firstWanted( mat ); + EntList *firstWanted(MatchType); + EntList *nextWanted(MatchType mat) + { + return next->firstWanted(mat); } - EntList * lastNot( JoinType ); - EntList * prevNot( JoinType j ) { - return prev->lastNot( j ); + EntList *lastNot(JoinType); + EntList *prevNot(JoinType j) + { + return prev->lastNot(j); } - EntList * lastWanted( MatchType ); - EntList * prevWanted( MatchType mat ) { - return prev->lastWanted( mat ); + EntList *lastWanted(MatchType); + EntList *prevWanted(MatchType mat) + { + return prev->lastWanted(mat); } JoinType join; - int multiple() { - return ( join != SIMPLE ); + int multiple() + { + return (join != SIMPLE); } - EntList * next, *prev; + EntList *next, *prev; protected: MatchType viable; @@ -206,32 +230,39 @@ class SC_CORE_EXPORT EntList { int level; ///< How many levels deep are we (main use for printing). }; -class SC_CORE_EXPORT SimpleList : public EntList { +class SC_CORE_EXPORT SimpleList : public EntList +{ friend class ComplexList; - friend ostream & operator<< ( ostream &, SimpleList & ); + friend ostream &operator<< (ostream &, SimpleList &); public: - SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { - strncpy( name, n, sizeof( name ) - 1 ); - name[sizeof( name ) - 1] = '\0'; /* sanity */ + SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) + { + strncpy(name, n, sizeof(name) - 1); + name[sizeof(name) - 1] = '\0'; /* sanity */ } ~SimpleList() {} - int operator== ( const char * nm ) { - return ( strcmp( name, nm ) == 0 ); + int operator== (const char *nm) + { + return (strcmp(name, nm) == 0); } - const char * Name() { + const char *Name() + { return name; } - bool contains( char * nm ) { + bool contains(char *nm) + { return *this == nm; } - bool hit( char * nm ) { + bool hit(char *nm) + { return *this == nm; } - MatchType matchNonORs( EntNode * ); - bool acceptChoice( EntNode * ); - void unmarkAll( EntNode * ); - void reset() { + MatchType matchNonORs(EntNode *); + bool acceptChoice(EntNode *); + void unmarkAll(EntNode *); + void reset() + { viable = UNKNOWN; I_marked = NOMARK; } @@ -245,40 +276,43 @@ class SC_CORE_EXPORT SimpleList : public EntList { * Supports concepts and functionality common to all the compound list * types, especially AND and ANDOR. */ -class SC_CORE_EXPORT MultList : public EntList { +class SC_CORE_EXPORT MultList : public EntList +{ friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, MultList &); public: - MultList( JoinType j ) : EntList( j ), supertype( 0 ), numchildren( 0 ), - childList( 0 ) {} + MultList(JoinType j) : EntList(j), supertype(0), numchildren(0), + childList(0) {} ~MultList(); - void setLevel( int ); - bool contains( char * ); - bool hit( char * ); - void appendList( EntList * ); - EntList * copyList( EntList * ); - virtual MatchType matchORs( EntNode * ) = 0; - virtual MatchType tryNext( EntNode * ); - - int childCount() { + void setLevel(int); + bool contains(char *); + bool hit(char *); + void appendList(EntList *); + EntList *copyList(EntList *); + virtual MatchType matchORs(EntNode *) = 0; + virtual MatchType tryNext(EntNode *); + + int childCount() + { return numchildren; } // EntList *operator[]( int ); - EntList * getChild( int ); - EntList * getLast() { - return ( getChild( numchildren - 1 ) ); + EntList *getChild(int); + EntList *getLast() + { + return (getChild(numchildren - 1)); } - void unmarkAll( EntNode * ); - bool prevKnown( EntList * ); + void unmarkAll(EntNode *); + bool prevKnown(EntList *); void reset(); protected: int supertype; ///< do I represent a supertype? int numchildren; - EntList * childList; + EntList *childList; /** \var childList * Points to a list of "children" of this EntList. E.g., if join = * AND, it would point to a list of the entity types we are AND'ing. @@ -291,49 +325,55 @@ class SC_CORE_EXPORT MultList : public EntList { * A specialized MultList, super for subtypes AndOrList and AndList, or * ones which join their multiple children. */ -class SC_CORE_EXPORT JoinList : public MultList { +class SC_CORE_EXPORT JoinList : public MultList +{ public: - JoinList( JoinType j ) : MultList( j ) {} + JoinList(JoinType j) : MultList(j) {} ~JoinList() {} - void setViableVal( EntNode * ); - bool acceptChoice( EntNode * ); + void setViableVal(EntNode *); + bool acceptChoice(EntNode *); }; -class SC_CORE_EXPORT AndOrList : public JoinList { +class SC_CORE_EXPORT AndOrList : public JoinList +{ friend class ComplexList; public: - AndOrList() : JoinList( ANDOR ) {} + AndOrList() : JoinList(ANDOR) {} ~AndOrList() {} - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); }; -class SC_CORE_EXPORT AndList : public JoinList { +class SC_CORE_EXPORT AndList : public JoinList +{ friend class ComplexList; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - AndList() : JoinList( AND ) {} + AndList() : JoinList(AND) {} ~AndList() {} - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); }; -class SC_CORE_EXPORT OrList : public MultList { +class SC_CORE_EXPORT OrList : public MultList +{ public: - OrList() : MultList( OR ), choice( -1 ), choice1( -1 ), choiceCount( 0 ) {} + OrList() : MultList(OR), choice(-1), choice1(-1), choiceCount(0) {} ~OrList() {} - bool hit( char * ); - MatchType matchORs( EntNode * ); - MatchType tryNext( EntNode * ); - void unmarkAll( EntNode * ); - bool acceptChoice( EntNode * ); - bool acceptNextChoice( EntNode * ents ) { + bool hit(char *); + MatchType matchORs(EntNode *); + MatchType tryNext(EntNode *); + void unmarkAll(EntNode *); + bool acceptChoice(EntNode *); + bool acceptNextChoice(EntNode *ents) + { choice++; - return ( acceptChoice( ents ) ); + return (acceptChoice(ents)); } - void reset() { + void reset() + { choice = -1; choice1 = -2; choiceCount = 0; @@ -350,71 +390,80 @@ class SC_CORE_EXPORT OrList : public MultList { * Contains the entire list of EntLists which describe the set of * instantiable complex entities defined by an EXPRESS expression. */ -class SC_CORE_EXPORT ComplexList { +class SC_CORE_EXPORT ComplexList +{ friend class ultList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), - abstract( 0 ), dependent( 0 ), - multSupers( 0 ) {} + ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), + abstract(0), dependent(0), + multSupers(0) {} ~ComplexList(); void buildList(); void remove(); - int operator< ( ComplexList & c ) { - return ( strcmp( supertype(), c.supertype() ) < 0 ); + int operator< (ComplexList &c) + { + return (strcmp(supertype(), c.supertype()) < 0); } - int operator< ( char * name ) { - return ( strcmp( supertype(), name ) < 0 ); + int operator< (char *name) + { + return (strcmp(supertype(), name) < 0); } - int operator== ( char * name ) { - return ( strcmp( supertype(), name ) == 0 ); + int operator== (char *name) + { + return (strcmp(supertype(), name) == 0); } - const char * supertype() { - return ( dynamic_cast< SimpleList * >(head->childList ))->name ; + const char *supertype() + { + return (dynamic_cast< SimpleList * >(head->childList))->name ; } /** \fn supertype * Based on knowledge that ComplexList always created by ANDing supertype * with subtypes. */ - bool toplevel( const char * ); - bool contains( EntNode * ); - bool matches( EntNode * ); + bool toplevel(const char *); + bool contains(EntNode *); + bool matches(EntNode *); - EntNode * list; /**< List of all entities contained in this complex type, + EntNode *list; /**< List of all entities contained in this complex type, * regardless of how. (Used as a quick way of determining * if this List *may* contain a certain complex type.) */ - AndList * head; - ComplexList * next; - int Dependent() { + AndList *head; + ComplexList *next; + int Dependent() + { return dependent; } private: - void addChildren( EntList * ); - bool hitMultNodes( EntNode * ); + void addChildren(EntList *); + bool hitMultNodes(EntNode *); int abstract; ///< is our supertype abstract? int dependent; ///< is our supertype also a subtype of other supertype(s)? bool multSupers; ///< am I a combo-CList created to test a subtype which has >1 supertypes? }; /// The collection of all the ComplexLists defined by the current schema. -class SC_CORE_EXPORT ComplexCollect { +class SC_CORE_EXPORT ComplexCollect +{ public: - ComplexCollect( ComplexList * c = NULL ) : clists( c ) { - count = ( c ? 1 : 0 ); + ComplexCollect(ComplexList *c = NULL) : clists(c) + { + count = (c ? 1 : 0); } - ~ComplexCollect() { + ~ComplexCollect() + { delete clists; } - void insert( ComplexList * ); - void remove( ComplexList * ); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. - ComplexList * find( char * ); - bool supports( EntNode * ) const; + void insert(ComplexList *); + void remove(ComplexList *); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. + ComplexList *find(char *); + bool supports(EntNode *) const; - ComplexList * clists; + ComplexList *clists; private: int count; ///< # of clist children diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index 2fc289381..e2cea3ee0 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -16,8 +16,9 @@ /** * Destructor for ComplexList. */ -ComplexList::~ComplexList() { - if( next ) { +ComplexList::~ComplexList() +{ + if(next) { delete next; } delete head; @@ -31,7 +32,8 @@ ComplexList::~ComplexList() { * the supertypes' ComplexLists, this temp one can be deleted. Its sub- * structure, however, cannot be deleted since it's still being used. */ -void ComplexList::remove() { +void ComplexList::remove() +{ head = NULL; // Only the overall AND will be deleted. delete this; @@ -43,15 +45,16 @@ void ComplexList::remove() { * is a highly specialized function which is used during the building of * a temporary CList to test entities which are subtypes of >1 supertype. */ -bool ComplexList::toplevel( const char * name ) { - EntList * slist = head->childList; +bool ComplexList::toplevel(const char *name) +{ + EntList *slist = head->childList; - while( slist ) { - if( * dynamic_cast< SimpleList * >(slist) == name ) { + while(slist) { + if(* dynamic_cast< SimpleList * >(slist) == name) { return true; } slist = slist->next; - if( slist ) { + if(slist) { slist = slist->next; } } @@ -66,20 +69,21 @@ bool ComplexList::toplevel( const char * name ) { * entity which contains an entity which is not contained in list, this * ComplexList certainly can't support it. */ -void ComplexList::buildList() { - EntList * sibling = head->childList->next; +void ComplexList::buildList() +{ + EntList *sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if( list ) { + if(list) { delete list; } // Add first node based on supertype: - list = new EntNode( ( dynamic_cast< SimpleList * >(head->childList ))->name ); + list = new EntNode((dynamic_cast< SimpleList * >(head->childList))->name); // Recursively add all descendents: - while( sibling ) { - addChildren( sibling ); + while(sibling) { + addChildren(sibling); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -92,32 +96,33 @@ void ComplexList::buildList() { * Recursive function to add all the SimpleList descendents of ent into * this's list. */ -void ComplexList::addChildren( EntList * ent ) { - EntList * child; - char * nm; - EntNode * prev = list, *prev2 = NULL, *newnode; +void ComplexList::addChildren(EntList *ent) +{ + EntList *child; + char *nm; + EntNode *prev = list, *prev2 = NULL, *newnode; int comp = 0; - if( ent->multiple() ) { - child = ( ( MultList * )ent )->childList; - while( child ) { - addChildren( child ); + if(ent->multiple()) { + child = ((MultList *)ent)->childList; + while(child) { + addChildren(child); child = child->next; } } else { - nm = ( dynamic_cast(ent) )->name; - while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { + nm = (dynamic_cast(ent))->name; + while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if( comp != 0 ) { + if(comp != 0) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode( nm ); + newnode = new EntNode(nm); newnode->next = prev; - if( prev2 == NULL ) { + if(prev2 == NULL) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -136,14 +141,15 @@ void ComplexList::addChildren( EntList * ent ) { * tion is simplified greatly because both EntNodes are ordered alphabeti- * cally. */ -bool ComplexList::contains( EntNode * ents ) { - EntNode * ours = list, *theirs = ents; +bool ComplexList::contains(EntNode *ents) +{ + EntNode *ours = list, *theirs = ents; - while( theirs != NULL ) { - while( ours != NULL && *ours < *theirs ) { + while(theirs != NULL) { + while(ours != NULL && *ours < *theirs) { ours = ours->next; } - if( ours == NULL || *ours > *theirs ) { + if(ours == NULL || *ours > *theirs) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return false; @@ -162,38 +168,39 @@ bool ComplexList::contains( EntNode * ents ) { * can be instantiated based on the list of EntLists which were generated * when the schema was read; false otherwise. */ -bool ComplexList::matches( EntNode * ents ) { +bool ComplexList::matches(EntNode *ents) +{ MatchType retval; int result = false; // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if( ! contains( ents ) ) { + if(! contains(ents)) { return false; } // Now start a thorough search through this ComplexList: - if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { + if((retval = head->matchNonORs(ents)) == MATCHALL) { result = true; - } else if( retval != UNKNOWN ) { + } else if(retval != UNKNOWN) { result = false; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && - ( hitMultNodes( ents ) ) ) { + if(((retval = head->matchORs(ents)) == MATCHALL) && + (hitMultNodes(ents))) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = true; - } else if( retval >= MATCHSOME ) { + } else if(retval >= MATCHSOME) { // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): MatchType otherChoices = NEWCHOICE; - while( otherChoices == NEWCHOICE ) { - otherChoices = head->tryNext( ents ); - if( otherChoices == MATCHALL ) { - if( hitMultNodes( ents ) ) { + while(otherChoices == NEWCHOICE) { + otherChoices = head->tryNext(ents); + if(otherChoices == MATCHALL) { + if(hitMultNodes(ents)) { result = true; } else { otherChoices = NEWCHOICE; @@ -222,35 +229,36 @@ bool ComplexList::matches( EntNode * ents ) { * valid. (This function is actually slightly more complicated because it * also deals with the possibility that >1 entities like C exist.) */ -bool ComplexList::hitMultNodes( EntNode * ents ) { - EntNode * node; - EntList * child; +bool ComplexList::hitMultNodes(EntNode *ents) +{ + EntNode *node; + EntList *child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if( !multSupers ) { + if(!multSupers) { return true; } - for( node = ents; node != NULL; node = node->next ) { - if( node->multSuprs() ) { + for(node = ents; node != NULL; node = node->next) { + if(node->multSuprs()) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while( child ) { + while(child) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if( child->contains( node->name ) ) { - if( ! child->hit( node->name ) ) { + if(child->contains(node->name)) { + if(! child->hit(node->name)) { return false; } } child = child->next; - if( child ) { + if(child) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 72f6adb53..154e1be60 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,34 +1,42 @@ #include "create_Aggr.h" #include -EnumAggregate * create_EnumAggregate() { +EnumAggregate *create_EnumAggregate() +{ return new EnumAggregate; } -GenericAggregate * create_GenericAggregate() { +GenericAggregate *create_GenericAggregate() +{ return new GenericAggregate; } -EntityAggregate * create_EntityAggregate() { +EntityAggregate *create_EntityAggregate() +{ return new EntityAggregate; } -SelectAggregate * create_SelectAggregate() { +SelectAggregate *create_SelectAggregate() +{ return new SelectAggregate; } -StringAggregate * create_StringAggregate() { +StringAggregate *create_StringAggregate() +{ return new StringAggregate; } -BinaryAggregate * create_BinaryAggregate() { +BinaryAggregate *create_BinaryAggregate() +{ return new BinaryAggregate; } -RealAggregate * create_RealAggregate() { +RealAggregate *create_RealAggregate() +{ return new RealAggregate; } -IntAggregate * create_IntAggregate() { +IntAggregate *create_IntAggregate() +{ return new IntAggregate; } diff --git a/src/clstepcore/create_Aggr.h b/src/clstepcore/create_Aggr.h index a0483fa66..61918e06a 100644 --- a/src/clstepcore/create_Aggr.h +++ b/src/clstepcore/create_Aggr.h @@ -17,32 +17,32 @@ class BinaryAggregate; class RealAggregate; class IntAggregate; -typedef STEPaggregate * ( * AggregateCreator )(); -typedef EnumAggregate * ( * EnumAggregateCreator )(); -typedef GenericAggregate * ( * GenericAggregateCreator )(); -typedef EntityAggregate * ( * EntityAggregateCreator )(); -typedef SelectAggregate * ( * SelectAggregateCreator )(); -typedef StringAggregate * ( * StringAggregateCreator )(); -typedef BinaryAggregate * ( * BinaryAggregateCreator )(); -typedef RealAggregate * ( * RealAggregateCreator )(); -typedef IntAggregate * ( * IntAggregateCreator )(); +typedef STEPaggregate *(* AggregateCreator)(); +typedef EnumAggregate *(* EnumAggregateCreator)(); +typedef GenericAggregate *(* GenericAggregateCreator)(); +typedef EntityAggregate *(* EntityAggregateCreator)(); +typedef SelectAggregate *(* SelectAggregateCreator)(); +typedef StringAggregate *(* StringAggregateCreator)(); +typedef BinaryAggregate *(* BinaryAggregateCreator)(); +typedef RealAggregate *(* RealAggregateCreator)(); +typedef IntAggregate *(* IntAggregateCreator)(); -SC_CORE_EXPORT EnumAggregate * create_EnumAggregate(); +SC_CORE_EXPORT EnumAggregate *create_EnumAggregate(); -SC_CORE_EXPORT GenericAggregate * create_GenericAggregate(); +SC_CORE_EXPORT GenericAggregate *create_GenericAggregate(); -SC_CORE_EXPORT EntityAggregate * create_EntityAggregate(); +SC_CORE_EXPORT EntityAggregate *create_EntityAggregate(); -SC_CORE_EXPORT SelectAggregate * create_SelectAggregate(); +SC_CORE_EXPORT SelectAggregate *create_SelectAggregate(); -SC_CORE_EXPORT StringAggregate * create_StringAggregate(); +SC_CORE_EXPORT StringAggregate *create_StringAggregate(); -SC_CORE_EXPORT BinaryAggregate * create_BinaryAggregate(); +SC_CORE_EXPORT BinaryAggregate *create_BinaryAggregate(); -SC_CORE_EXPORT RealAggregate * create_RealAggregate(); +SC_CORE_EXPORT RealAggregate *create_RealAggregate(); -SC_CORE_EXPORT IntAggregate * create_IntAggregate(); +SC_CORE_EXPORT IntAggregate *create_IntAggregate(); -typedef SDAI_Integer( *boundCallbackFn )( SDAI_Application_instance * ); +typedef SDAI_Integer(*boundCallbackFn)(SDAI_Application_instance *); #endif //AGGRCREATORTD_H diff --git a/src/clstepcore/derivedAttribute.cc b/src/clstepcore/derivedAttribute.cc index 7fca3b16f..194f95471 100644 --- a/src/clstepcore/derivedAttribute.cc +++ b/src/clstepcore/derivedAttribute.cc @@ -1,30 +1,33 @@ #include "derivedAttribute.h" -Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType, - Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner ) - : AttrDescriptor( name, domainType, optional, unique, at, owner ) { - _initializer = ( const char * )0; +Derived_attribute::Derived_attribute(const char *name, const TypeDescriptor *domainType, + Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor &owner) + : AttrDescriptor(name, domainType, optional, unique, at, owner) +{ + _initializer = (const char *)0; } -Derived_attribute::~Derived_attribute() { +Derived_attribute::~Derived_attribute() +{ } -const char * Derived_attribute::AttrExprDefStr( std::string & s ) const { +const char *Derived_attribute::AttrExprDefStr(std::string &s) const +{ std::string buf; s.clear(); - if( Name() && strchr( Name(), '.' ) ) { + if(Name() && strchr(Name(), '.')) { s = "SELF\\"; } - s.append( Name() ); - s.append( " : " ); - if( DomainType() ) { - DomainType()->AttrTypeName( buf ); - s.append( buf ); + s.append(Name()); + s.append(" : "); + if(DomainType()) { + DomainType()->AttrTypeName(buf); + s.append(buf); } - if( _initializer ) { // this is supposed to exist for a derived attribute. - s.append( " \n\t\t:= " ); - s.append( _initializer ); + if(_initializer) { // this is supposed to exist for a derived attribute. + s.append(" \n\t\t:= "); + s.append(_initializer); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } diff --git a/src/clstepcore/derivedAttribute.h b/src/clstepcore/derivedAttribute.h index 234521a07..d894e3ede 100644 --- a/src/clstepcore/derivedAttribute.h +++ b/src/clstepcore/derivedAttribute.h @@ -5,26 +5,29 @@ #include "sc_export.h" -class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor { +class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor +{ public: - const char * _initializer; + const char *_initializer; Derived_attribute( - const char * name, // i.e. char * - const TypeDescriptor * domainType, + const char *name, // i.e. char * + const TypeDescriptor *domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor & owner + const EntityDescriptor &owner ); virtual ~Derived_attribute(); - const char * AttrExprDefStr( std::string & s ) const; + const char *AttrExprDefStr(std::string &s) const; - const char * initializer_() { + const char *initializer_() + { return _initializer; } - void initializer_( const char * i ) { + void initializer_(const char *i) + { _initializer = i; } }; diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 11170d4df..2889e2117 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -3,47 +3,52 @@ #include "typeDescriptor.h" #include "entityDescriptor.h" -Schema::Schema( const char * schemaName ) -: _use_interface_list( new Interface_spec__set ), -_ref_interface_list( new Interface_spec__set ), -_function_list( 0 ), _procedure_list( 0 ), _global_rules( 0 ) { +Schema::Schema(const char *schemaName) + : _use_interface_list(new Interface_spec__set), + _ref_interface_list(new Interface_spec__set), + _function_list(0), _procedure_list(0), _global_rules(0) +{ _name = schemaName; } -Schema::~Schema() { - TypeDescLinkNode * node; +Schema::~Schema() +{ + TypeDescLinkNode *node; - if( _use_interface_list != 0 ) { + if(_use_interface_list != 0) { delete _use_interface_list; } - if( _ref_interface_list != 0 ) { + if(_ref_interface_list != 0) { delete _ref_interface_list; } - if( _global_rules != 0 ) { + if(_global_rules != 0) { delete _global_rules; } - node = ( TypeDescLinkNode * ) _unnamed_typeList.GetHead(); - while( node ) { + node = (TypeDescLinkNode *) _unnamed_typeList.GetHead(); + while(node) { delete node->TypeDesc(); - node = ( TypeDescLinkNode * ) node->NextNode(); + node = (TypeDescLinkNode *) node->NextNode(); } } -void Schema::AddFunction( const std::string & f ) { - _function_list.push_back( f ); +void Schema::AddFunction(const std::string &f) +{ + _function_list.push_back(f); } -void Schema::AddGlobal_rule( Global_rule_ptr gr ) { - if( _global_rules == 0 ) { +void Schema::AddGlobal_rule(Global_rule_ptr gr) +{ + if(_global_rules == 0) { _global_rules = new Global_rule__set; } - _global_rules->Append( gr ); + _global_rules->Append(gr); } /// hope I did this right (MP) - was "not implemented" -void Schema::global_rules_( Global_rule__set_var & grs ) { - if( _global_rules ) { - if( _global_rules->Count() > 0 ) { +void Schema::global_rules_(Global_rule__set_var &grs) +{ + if(_global_rules) { + if(_global_rules->Count() > 0) { std::cerr << "In " << __FILE__ << ", Schema::global_rules_(): overwriting non-empty global rule set!" << std::endl; } delete _global_rules; @@ -51,43 +56,45 @@ void Schema::global_rules_( Global_rule__set_var & grs ) { _global_rules = grs; } -void Schema::AddProcedure( const std::string & p ) { - _procedure_list.push_back( p ); +void Schema::AddProcedure(const std::string &p) +{ + _procedure_list.push_back(p); } /// the whole schema -void Schema::GenerateExpress( ostream & out ) const { +void Schema::GenerateExpress(ostream &out) const +{ std::string tmp; out << endl << "(* Generating: " << Name() << " *)" << endl; - out << endl << "SCHEMA " << StrToLower( Name(), tmp ) << ";" << endl; - GenerateUseRefExpress( out ); + out << endl << "SCHEMA " << StrToLower(Name(), tmp) << ";" << endl; + GenerateUseRefExpress(out); // print TYPE definitions out << endl << "(* ////////////// TYPE Definitions *)" << endl; - GenerateTypesExpress( out ); + GenerateTypesExpress(out); // print Entity definitions out << endl << "(* ////////////// ENTITY Definitions *)" << endl; - GenerateEntitiesExpress( out ); + GenerateEntitiesExpress(out); int count, i; - if( _global_rules != 0 ) { + if(_global_rules != 0) { out << endl << "(* *************RULES************* *)" << endl; count = _global_rules->Count(); - for( i = 0; i < count; i++ ) { - out << endl << ( *_global_rules )[i]->rule_text_() << endl; + for(i = 0; i < count; i++) { + out << endl << (*_global_rules)[i]->rule_text_() << endl; } } - if( !_function_list.empty() ) { + if(!_function_list.empty()) { out << "(* *************FUNCTIONS************* *)" << endl; count = _function_list.size(); - for( i = 0; i < count; i++ ) { + for(i = 0; i < count; i++) { out << endl << _function_list[i] << endl; } } - if( !_procedure_list.empty() ) { + if(!_procedure_list.empty()) { out << "(* *************PROCEDURES************* *)" << endl; count = _procedure_list.size(); - for( i = 0; i < count; i++ ) { + for(i = 0; i < count; i++) { out << endl << _procedure_list[i] << endl; } } @@ -95,7 +102,8 @@ void Schema::GenerateExpress( ostream & out ) const { } /// USE, REFERENCE definitions -void Schema::GenerateUseRefExpress( ostream & out ) const { +void Schema::GenerateUseRefExpress(ostream &out) const +{ int i, k; int intf_count; int count; @@ -106,38 +114,38 @@ void Schema::GenerateUseRefExpress( ostream & out ) const { /////////////////////// print USE statements intf_count = _use_interface_list->Count(); - if( intf_count ) { // there is at least 1 USE interface to a foreign schema - for( i = 0; i < intf_count; i++ ) { // print out each USE interface - is = ( *_use_interface_list )[i]; // the 1st USE interface + if(intf_count) { // there is at least 1 USE interface to a foreign schema + for(i = 0; i < intf_count; i++) { // print out each USE interface + is = (*_use_interface_list)[i]; // the 1st USE interface // count is # of USE items in interface count = is->explicit_items_()->Count(); - if( count > 0 ) { + if(count > 0) { out << endl << " USE FROM " - << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; + << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; out << " ("; first_time = 1; - for( k = 0; k < count; k++ ) { // print out each USE item - if( first_time ) { + for(k = 0; k < count; k++) { // print out each USE item + if(first_time) { first_time = 0; } else { out << "," << endl << "\t"; } - if( !( ( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { + if(!((*(is->explicit_items_()))[k]->original_id_().size())) { // not renamed - out << ( *( is->explicit_items_() ) )[k]->new_id_(); + out << (*(is->explicit_items_()))[k]->new_id_(); } else { // renamed - out << ( *( is->explicit_items_() ) )[k]->original_id_(); - out << " AS " << ( *( is->explicit_items_() ) )[k]->new_id_(); + out << (*(is->explicit_items_()))[k]->original_id_(); + out << " AS " << (*(is->explicit_items_()))[k]->new_id_(); } } out << ");" << endl; - } else if( is->all_objects_() ) { + } else if(is->all_objects_()) { out << endl << " USE FROM " - << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" - << endl; + << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" + << endl; } } } @@ -145,67 +153,69 @@ void Schema::GenerateUseRefExpress( ostream & out ) const { /////////////////////// print REFERENCE stmts intf_count = _ref_interface_list->Count(); - if( intf_count ) { //there is at least 1 REFERENCE interface to a foreign schema - for( i = 0; i < intf_count; i++ ) { // print out each REFERENCE interface - is = ( *_ref_interface_list )[i]; // the 1st REFERENCE interface + if(intf_count) { //there is at least 1 REFERENCE interface to a foreign schema + for(i = 0; i < intf_count; i++) { // print out each REFERENCE interface + is = (*_ref_interface_list)[i]; // the 1st REFERENCE interface // count is # of REFERENCE items in interface count = is->explicit_items_()->Count(); - if( count > 0 ) { + if(count > 0) { out << endl << " REFERENCE FROM " - << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; + << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; out << " ("; first_time = 1; - for( k = 0; k < count; k++ ) { // print out each REFERENCE item - if( first_time ) { + for(k = 0; k < count; k++) { // print out each REFERENCE item + if(first_time) { first_time = 0; } else { out << "," << endl << "\t"; } - if( ( !( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { + if((!(*(is->explicit_items_()))[k]->original_id_().size())) { // not renamed - out << ( *( is->explicit_items_() ) )[k]->new_id_(); + out << (*(is->explicit_items_()))[k]->new_id_(); } else { // renamed - out << ( *( is->explicit_items_() ) )[k]->original_id_(); + out << (*(is->explicit_items_()))[k]->original_id_(); out << " AS " - << ( *( is->explicit_items_() ) )[k]->new_id_(); + << (*(is->explicit_items_()))[k]->new_id_(); } } out << ");" << endl; - } else if( is->all_objects_() ) { + } else if(is->all_objects_()) { out << endl << " REFERENCE FROM " - << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" - << endl; + << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" + << endl; } } } } /// TYPE definitions -void Schema::GenerateTypesExpress( ostream & out ) const { - TypeDescItr tdi( _typeList ); +void Schema::GenerateTypesExpress(ostream &out) const +{ + TypeDescItr tdi(_typeList); tdi.ResetItr(); std::string tmp; - const TypeDescriptor * td = tdi.NextTypeDesc(); - while( td ) { - out << endl << td->GenerateExpress( tmp ); + const TypeDescriptor *td = tdi.NextTypeDesc(); + while(td) { + out << endl << td->GenerateExpress(tmp); td = tdi.NextTypeDesc(); } } /// Entity definitions -void Schema::GenerateEntitiesExpress( ostream & out ) const { - EntityDescItr edi( _entList ); +void Schema::GenerateEntitiesExpress(ostream &out) const +{ + EntityDescItr edi(_entList); edi.ResetItr(); std::string tmp; - const EntityDescriptor * ed = edi.NextEntityDesc(); - while( ed ) { - out << endl << ed->GenerateExpress( tmp ); + const EntityDescriptor *ed = edi.NextEntityDesc(); + while(ed) { + out << endl << ed->GenerateExpress(tmp); ed = edi.NextEntityDesc(); } } diff --git a/src/clstepcore/dictSchema.h b/src/clstepcore/dictSchema.h index 96977f98e..1617703e3 100644 --- a/src/clstepcore/dictSchema.h +++ b/src/clstepcore/dictSchema.h @@ -9,137 +9,159 @@ #include "dictionaryInstance.h" -typedef SDAI_Model_contents_ptr( * ModelContentsCreator )(); +typedef SDAI_Model_contents_ptr(* ModelContentsCreator)(); /** * \class Schema (was SchemaDescriptor) - a class of this type is generated and contains schema info. */ -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) - - // non-SDAI lists - Interface_spec__set_var _use_interface_list; // list of USE interfaces - Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces +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) + + // non-SDAI lists + Interface_spec__set_var _use_interface_list; // list of USE interfaces + Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::vector< std::string > _function_list; // of EXPRESS functions - std::vector< std::string > _procedure_list; // of EXPRESS procedures + std::vector< std::string > _function_list; // of EXPRESS functions + std::vector< std::string > _procedure_list; // of EXPRESS procedures #ifdef _MSC_VER #pragma warning( pop ) #endif - Global_rule__set_var _global_rules; - -public: - ModelContentsCreator CreateNewModelContents; - - Schema( const char * schemaName ); - virtual ~Schema(); - - void AssignModelContentsCreator( ModelContentsCreator f = 0 ) { - CreateNewModelContents = f; - } - - const char * Name() const { - return _name; - } - void Name( const char * n ) { - _name = n; - } - - Interface_spec & interface_() { - return _interface; - } - - Interface_spec__set_var use_interface_list_() { - return - _use_interface_list; - } - - Interface_spec__set_var ref_interface_list_() { - return _ref_interface_list; - } - - std::vector< std::string > function_list_() { - return _function_list; - } - - void AddFunction( const std::string & f ); - - Global_rule__set_var global_rules_() { // const - return _global_rules; - } - - void AddGlobal_rule( Global_rule_ptr gr ); - - void global_rules_( Global_rule__set_var & grs ); // not implemented - - std::vector< std::string > procedure_list_() { - return _procedure_list; - } - - void AddProcedure( const std::string & p ); - - 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; - - // USE, REFERENCE definitions - void GenerateUseRefExpress( ostream & out ) const; - - // TYPE definitions - void GenerateTypesExpress( ostream & out ) const; - - // Entity definitions - void GenerateEntitiesExpress( ostream & out ) const; + Global_rule__set_var _global_rules; + + public: + ModelContentsCreator CreateNewModelContents; + + Schema(const char *schemaName); + virtual ~Schema(); + + void AssignModelContentsCreator(ModelContentsCreator f = 0) + { + CreateNewModelContents = f; + } + + const char *Name() const + { + return _name; + } + void Name(const char *n) + { + _name = n; + } + + Interface_spec &interface_() + { + return _interface; + } + + Interface_spec__set_var use_interface_list_() + { + return + _use_interface_list; + } + + Interface_spec__set_var ref_interface_list_() + { + return _ref_interface_list; + } + + std::vector< std::string > function_list_() + { + return _function_list; + } + + void AddFunction(const std::string &f); + + Global_rule__set_var global_rules_() // const + { + return _global_rules; + } + + void AddGlobal_rule(Global_rule_ptr gr); + + void global_rules_(Global_rule__set_var &grs); // not implemented + + std::vector< std::string > procedure_list_() + { + return _procedure_list; + } + + void AddProcedure(const std::string &p); + + 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; + + // USE, REFERENCE definitions + void GenerateUseRefExpress(ostream &out) const; + + // TYPE definitions + void GenerateTypesExpress(ostream &out) const; + + // Entity definitions + void GenerateEntitiesExpress(ostream &out) const; }; typedef Schema SchemaDescriptor; diff --git a/src/clstepcore/dictdefs.h b/src/clstepcore/dictdefs.h index 1dbb7cdf9..0a6c8f241 100644 --- a/src/clstepcore/dictdefs.h +++ b/src/clstepcore/dictdefs.h @@ -29,37 +29,37 @@ class TypeDescriptorList; // currently commented out. FIXME The underlying class names should be updated // when the new dictionary is integrated. DAS -typedef class Schema * Schema_ptr; +typedef class Schema *Schema_ptr; typedef Schema_ptr Schema_var; -typedef class EntityDescriptor * Entity_ptr; +typedef class EntityDescriptor *Entity_ptr; typedef Entity_ptr Entity_var; -typedef class AttrDescriptor * Attribute_ptr; +typedef class AttrDescriptor *Attribute_ptr; typedef Attribute_ptr Attribute_var; -typedef class Derived_attribute * Derived_attribute_ptr; +typedef class Derived_attribute *Derived_attribute_ptr; typedef Derived_attribute_ptr Derived_attribute_var; -typedef class AttrDescriptor * Explicit_attribute_ptr; +typedef class AttrDescriptor *Explicit_attribute_ptr; typedef Explicit_attribute_ptr Explicit_attribute_var; -typedef Inverse_attribute * Inverse_attribute_ptr; +typedef Inverse_attribute *Inverse_attribute_ptr; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute InverseAttrDescriptor; -typedef class EnumTypeDescriptor * Enumeration_type_ptr; +typedef class EnumTypeDescriptor *Enumeration_type_ptr; typedef Enumeration_type_ptr Enumeration_type_var; -typedef class SelectTypeDescriptor * Select_type_ptr; +typedef class SelectTypeDescriptor *Select_type_ptr; typedef Select_type_ptr Select_type_var; -typedef class RealTypeDescriptor * Real_type_ptr; +typedef class RealTypeDescriptor *Real_type_ptr; typedef Real_type_ptr Real_type_var; -typedef class StringTypeDescriptor * String_type_ptr; +typedef class StringTypeDescriptor *String_type_ptr; typedef String_type_ptr String_type_var; -typedef class AggrTypeDescriptor * Aggr_type_ptr; +typedef class AggrTypeDescriptor *Aggr_type_ptr; typedef Aggr_type_ptr Aggr_type_var; -typedef class SetTypeDescriptor * Set_type_ptr; +typedef class SetTypeDescriptor *Set_type_ptr; typedef Set_type_ptr Set_type_var; -typedef class BagTypeDescriptor * Bag_type_ptr; +typedef class BagTypeDescriptor *Bag_type_ptr; typedef Bag_type_ptr Bag_type_var; -typedef class ListTypeDescriptor * List_type_ptr; +typedef class ListTypeDescriptor *List_type_ptr; typedef List_type_ptr List_type_var; -typedef class ArrayTypeDescriptor * Array_type_ptr; +typedef class ArrayTypeDescriptor *Array_type_ptr; typedef Array_type_ptr Array_type_var; // the following exist until everything is updated diff --git a/src/clstepcore/dictionaryInstance.h b/src/clstepcore/dictionaryInstance.h index ac8734c68..34fceee89 100644 --- a/src/clstepcore/dictionaryInstance.h +++ b/src/clstepcore/dictionaryInstance.h @@ -3,13 +3,14 @@ #include "sc_export.h" -class SC_CORE_EXPORT Dictionary_instance { +class SC_CORE_EXPORT Dictionary_instance +{ -protected: - Dictionary_instance() {} - Dictionary_instance( const Dictionary_instance & ) {} + protected: + Dictionary_instance() {} + Dictionary_instance(const Dictionary_instance &) {} - virtual ~Dictionary_instance() {}; + virtual ~Dictionary_instance() {}; }; diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 2590e034c..903ba086d 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -29,28 +29,32 @@ class StepEntityEditor; // 2) delete the StepEntityEditor window // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). -extern void DeleteSEE( StepEntityEditor * se ); +extern void DeleteSEE(StepEntityEditor *se); -DisplayNode::~DisplayNode() { +DisplayNode::~DisplayNode() +{ Remove(); - if( see ) { - DeleteSEE( ( StepEntityEditor * )see ); + if(see) { + DeleteSEE((StepEntityEditor *)see); //DAS PORT need the cast from void* DeleteSEE(see); } } -void DisplayNode::Remove() { +void DisplayNode::Remove() +{ GenericNode::Remove(); // DON'T DO THIS!! displayState = noMapState; } -int DisplayNode::ChangeState( displayStateEnum s ) { +int DisplayNode::ChangeState(displayStateEnum s) +{ displayState = s; return 1; } -int DisplayNode::ChangeList( DisplayNodeList * cmdList ) { +int DisplayNode::ChangeList(DisplayNodeList *cmdList) +{ Remove(); - cmdList->Append( this ); + cmdList->Append(this); return 1; } diff --git a/src/clstepcore/dispnode.h b/src/clstepcore/dispnode.h index 1209b9c3e..9e2ca5b7f 100644 --- a/src/clstepcore/dispnode.h +++ b/src/clstepcore/dispnode.h @@ -32,49 +32,58 @@ class MgrNode; // class DisplayNode ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNode : public GenericNode { +class SC_CORE_EXPORT DisplayNode : public GenericNode +{ protected: friend class GenNodeList; friend class DisplayNodeList; - MgrNode * mn; - void * see; + MgrNode *mn; + void *see; displayStateEnum displayState; // = { mappedWrite, mappedView, notMapped } public: // this should probably only be used to create head nodes for dispnodelists - DisplayNode() { + DisplayNode() + { displayState = noMapState; } - DisplayNode( MgrNode * node ) { + DisplayNode(MgrNode *node) + { mn = node; displayState = noMapState; } ~DisplayNode(); - void SEE( void * s ) { + void SEE(void *s) + { see = s; } - virtual void * SEE() { + virtual void *SEE() + { return see; } - void mgrNode( MgrNode * node ) { + void mgrNode(MgrNode *node) + { mn = node; } - class MgrNode * mgrNode() { + class MgrNode *mgrNode() + { return mn; } - displayStateEnum DisplayState() { + displayStateEnum DisplayState() + { return displayState; } - int DisplayListMember( displayStateEnum ds ) { - return ( displayState == ds ); + int DisplayListMember(displayStateEnum ds) + { + return (displayState == ds); } - int ChangeState( displayStateEnum s ); - int ChangeList( DisplayNodeList * cmdList ); + int ChangeState(displayStateEnum s); + int ChangeList(DisplayNodeList *cmdList); void Remove(); diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index f4d00a6aa..0aad7885c 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -21,36 +21,40 @@ #include #include "sc_memmgr.h" -void DisplayNodeList::Remove( GenericNode * node ) { - GenNodeList::Remove( node ); +void DisplayNodeList::Remove(GenericNode *node) +{ + GenNodeList::Remove(node); // DON'T DO THIS ((DisplayNode *)node)->displayState = noMapState; } // deletes node from its previous list & appends // actually it puts it at the front of the list. -void DisplayNodeList::Append( GenericNode * node ) { - InsertBefore( node, head ); +void DisplayNodeList::Append(GenericNode *node) +{ + InsertBefore(node, head); } // deletes newNode from its previous list & inserts after // existNode -void DisplayNodeList::InsertAfter( GenericNode * newNode, - GenericNode * existNode ) { - if( newNode->next != 0 ) { // remove the node from its previous +void DisplayNodeList::InsertAfter(GenericNode *newNode, + GenericNode *existNode) +{ + if(newNode->next != 0) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertAfter( newNode, existNode ); + GenNodeList::InsertAfter(newNode, existNode); // DON'T DO THIS ((DisplayNode *)newNode)->displayState = listType; } // deletes newNode from its previous list & inserts before // existNode -void DisplayNodeList::InsertBefore( GenericNode * newNode, - GenericNode * existNode ) { - if( newNode->next != 0 ) { // remove the node from its previous +void DisplayNodeList::InsertBefore(GenericNode *newNode, + GenericNode *existNode) +{ + if(newNode->next != 0) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertBefore( newNode, existNode ); + GenNodeList::InsertBefore(newNode, existNode); // DON'T DO THIS!!! ((DisplayNode *)newNode)->displayState = listType; } diff --git a/src/clstepcore/dispnodelist.h b/src/clstepcore/dispnodelist.h index c4fe4dde3..a621e657e 100644 --- a/src/clstepcore/dispnodelist.h +++ b/src/clstepcore/dispnodelist.h @@ -29,24 +29,26 @@ // This will be used to represent the display state lists. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNodeList : public GenNodeList { +class SC_CORE_EXPORT DisplayNodeList : public GenNodeList +{ public: - DisplayNodeList( displayStateEnum type ); + DisplayNodeList(displayStateEnum type); ~DisplayNodeList() { } // ADDED functions - displayStateEnum GetState() { + displayStateEnum GetState() + { return listType; } // REDEFINED functions // deletes node from its previous list & appends - virtual void Append( GenericNode * node ); + virtual void Append(GenericNode *node); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); - virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); - virtual void Remove( GenericNode * node ); + virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); + virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); + virtual void Remove(GenericNode *node); protected: private: @@ -59,10 +61,11 @@ class SC_CORE_EXPORT DisplayNodeList : public GenNodeList { // other classes) that aren't in this file except for Generic functions ////////////////////////////////////////////////////////////////////////////// -inline DisplayNodeList::DisplayNodeList( displayStateEnum type ) - : GenNodeList( new DisplayNode() ) { +inline DisplayNodeList::DisplayNodeList(displayStateEnum type) + : GenNodeList(new DisplayNode()) +{ listType = type; - ( ( DisplayNode * )head )->displayState = type; + ((DisplayNode *)head)->displayState = type; } #endif diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 0e58c4db6..2711c05f6 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -6,45 +6,49 @@ #include "inverseAttribute.h" #include "SubSuperIterators.h" -EntityDescriptor::EntityDescriptor( ) - : _abstractEntity( LUnknown ), _extMapping( LUnknown ), - _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( 0 ) { +EntityDescriptor::EntityDescriptor() + : _abstractEntity(LUnknown), _extMapping(LUnknown), + _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(0) +{ } -EntityDescriptor::EntityDescriptor( const char * name, // i.e. char * - Schema * origSchema, - Logical abstractEntity, // F U or T - Logical extMapping, - Creator f +EntityDescriptor::EntityDescriptor(const char *name, // i.e. char * + Schema *origSchema, + Logical abstractEntity, // F U or T + Logical extMapping, + Creator f ) - : TypeDescriptor( name, ENTITY_TYPE, origSchema, name ), - _abstractEntity( abstractEntity ), _extMapping( extMapping ), - _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( f ) { + : TypeDescriptor(name, ENTITY_TYPE, origSchema, name), + _abstractEntity(abstractEntity), _extMapping(extMapping), + _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(f) +{ } -EntityDescriptor::~EntityDescriptor() { +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 ); +void initIAttr(Inverse_attribute *ia, Registry ®, 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 ); + 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; } } @@ -59,60 +63,62 @@ void initIAttr( Inverse_attribute * ia, Registry & reg, const char * schNm, cons * 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 ); +void EntityDescriptor::InitIAttrs(Registry ®, 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 { +const char *EntityDescriptor::GenerateExpress(std::string &buf) const +{ std::string sstr; int count; int i; int all_comments = 1; buf = "ENTITY "; - buf.append( StrToLower( Name(), sstr ) ); + buf.append(StrToLower(Name(), sstr)); - if( strlen( _supertype_stmt.c_str() ) > 0 ) { - buf.append( "\n " ); + if(strlen(_supertype_stmt.c_str()) > 0) { + buf.append("\n "); } - buf.append( _supertype_stmt ); + buf.append(_supertype_stmt); - const EntityDescriptor * ed = 0; + const EntityDescriptor *ed = 0; - EntityDescItr edi_super( _supertypes ); + EntityDescItr edi_super(_supertypes); edi_super.ResetItr(); ed = edi_super.NextEntityDesc(); int supertypes = 0; - if( ed ) { - buf.append( "\n SUBTYPE OF (" ); - buf.append( StrToLower( ed->Name(), sstr ) ); + if(ed) { + buf.append("\n SUBTYPE OF ("); + buf.append(StrToLower(ed->Name(), sstr)); supertypes = 1; } ed = edi_super.NextEntityDesc(); - while( ed ) { - buf.append( ",\n\t\t" ); - buf.append( StrToLower( ed->Name(), sstr ) ); + while(ed) { + buf.append(",\n\t\t"); + buf.append(StrToLower(ed->Name(), sstr)); ed = edi_super.NextEntityDesc(); } - if( supertypes ) { - buf.append( ")" ); + if(supertypes) { + buf.append(")"); } - buf.append( ";\n" ); + buf.append(";\n"); - AttrDescItr adi( _explicitAttr ); + AttrDescItr adi(_explicitAttr); adi.ResetItr(); - const AttrDescriptor * ad = adi.NextAttrDesc(); + const AttrDescriptor *ad = adi.NextAttrDesc(); - while( ad ) { - if( ad->AttrType() == AttrType_Explicit ) { - buf.append( " " ); - buf.append( ad->GenerateExpress( sstr ) ); + while(ad) { + if(ad->AttrType() == AttrType_Explicit) { + buf.append(" "); + buf.append(ad->GenerateExpress(sstr)); } ad = adi.NextAttrDesc(); } @@ -121,136 +127,139 @@ const char * EntityDescriptor::GenerateExpress( std::string & buf ) const { ad = adi.NextAttrDesc(); count = 1; - while( ad ) { - if( ad->AttrType() == AttrType_Deriving ) { - if( count == 1 ) { - buf.append( " DERIVE\n" ); + while(ad) { + if(ad->AttrType() == AttrType_Deriving) { + if(count == 1) { + buf.append(" DERIVE\n"); } - buf.append( " " ); - buf.append( ad->GenerateExpress( sstr ) ); + buf.append(" "); + buf.append(ad->GenerateExpress(sstr)); count++; } ad = adi.NextAttrDesc(); } ///////// - InverseAItr iai( &_inverseAttr ); + InverseAItr iai(&_inverseAttr); iai.ResetItr(); - const Inverse_attribute * ia = iai.NextInverse_attribute(); + const Inverse_attribute *ia = iai.NextInverse_attribute(); - if( ia ) { - buf.append( " INVERSE\n" ); + if(ia) { + buf.append(" INVERSE\n"); } - while( ia ) { - buf.append( " " ); - buf.append( ia->GenerateExpress( sstr ) ); + while(ia) { + buf.append(" "); + buf.append(ia->GenerateExpress(sstr)); ia = iai.NextInverse_attribute(); } /////////////// // count is # of UNIQUE rules - if( _uniqueness_rules != 0 ) { + if(_uniqueness_rules != 0) { count = _uniqueness_rules->Count(); - for( i = 0; i < count; i++ ) { // print out each UNIQUE rule - if( !( *( _uniqueness_rules ) )[i]->_label.size() ) { + for(i = 0; i < count; i++) { // print out each UNIQUE rule + if(!(*(_uniqueness_rules))[i]->_label.size()) { all_comments = 0; } } - if( all_comments ) { - buf.append( " (* UNIQUE *)\n" ); + if(all_comments) { + buf.append(" (* UNIQUE *)\n"); } else { - buf.append( " UNIQUE\n" ); + buf.append(" UNIQUE\n"); } - for( i = 0; i < count; i++ ) { // print out each UNIQUE rule - if( !( *( _uniqueness_rules ) )[i]->_comment.empty() ) { - buf.append( " " ); - buf.append( ( *( _uniqueness_rules ) )[i]->comment_() ); - buf.append( "\n" ); + for(i = 0; i < count; i++) { // print out each UNIQUE rule + if(!(*(_uniqueness_rules))[i]->_comment.empty()) { + buf.append(" "); + buf.append((*(_uniqueness_rules))[i]->comment_()); + buf.append("\n"); } - if( ( *( _uniqueness_rules ) )[i]->_label.size() ) { - buf.append( " " ); - buf.append( ( *( _uniqueness_rules ) )[i]->label_() ); - buf.append( "\n" ); + if((*(_uniqueness_rules))[i]->_label.size()) { + buf.append(" "); + buf.append((*(_uniqueness_rules))[i]->label_()); + buf.append("\n"); } } } /////////////// // count is # of WHERE rules - if( _where_rules != 0 ) { + if(_where_rules != 0) { all_comments = 1; count = _where_rules->Count(); - for( i = 0; i < count; i++ ) { // print out each UNIQUE rule - if( !( *( _where_rules ) )[i]->_label.size() ) { + for(i = 0; i < count; i++) { // print out each UNIQUE rule + if(!(*(_where_rules))[i]->_label.size()) { all_comments = 0; } } - if( !all_comments ) { - buf.append( " WHERE\n" ); + if(!all_comments) { + buf.append(" WHERE\n"); } else { - buf.append( " (* WHERE *)\n" ); + buf.append(" (* WHERE *)\n"); } - for( i = 0; i < count; i++ ) { // print out each WHERE rule - if( !( *( _where_rules ) )[i]->_comment.empty() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->comment_() ); - buf.append( "\n" ); + for(i = 0; i < count; i++) { // print out each WHERE rule + if(!(*(_where_rules))[i]->_comment.empty()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->comment_()); + buf.append("\n"); } - if( ( *( _where_rules ) )[i]->_label.size() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->label_() ); - buf.append( "\n" ); + if((*(_where_rules))[i]->_label.size()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->label_()); + buf.append("\n"); } } } - buf.append( "END_ENTITY;\n" ); + buf.append("END_ENTITY;\n"); - return const_cast( buf.c_str() ); + return const_cast(buf.c_str()); } -const char * EntityDescriptor::QualifiedName( std::string & s ) const { +const char *EntityDescriptor::QualifiedName(std::string &s) const +{ s.clear(); - EntityDescItr edi( _supertypes ); + EntityDescItr edi(_supertypes); int count = 1; - const EntityDescriptor * ed = edi.NextEntityDesc(); - while( ed ) { - if( count > 1 ) { - s.append( "&" ); + const EntityDescriptor *ed = edi.NextEntityDesc(); + while(ed) { + if(count > 1) { + s.append("&"); } - s.append( ed->Name() ); + s.append(ed->Name()); count++; ed = edi.NextEntityDesc(); } - if( count > 1 ) { - s.append( "&" ); + if(count > 1) { + s.append("&"); } - s.append( Name() ); - return const_cast( s.c_str() ); + s.append(Name()); + return const_cast(s.c_str()); } -const TypeDescriptor * EntityDescriptor::IsA( const TypeDescriptor * td ) const { - if( td -> NonRefType() == ENTITY_TYPE ) { - return IsA( ( EntityDescriptor * ) td ); +const TypeDescriptor *EntityDescriptor::IsA(const TypeDescriptor *td) const +{ + if(td -> NonRefType() == ENTITY_TYPE) { + return IsA((EntityDescriptor *) td); } else { return 0; } } -const EntityDescriptor * EntityDescriptor::IsA( const EntityDescriptor * other ) const { - const EntityDescriptor * found = 0; - const EntityDescLinkNode * link = ( const EntityDescLinkNode * )( GetSupertypes().GetHead() ); +const EntityDescriptor *EntityDescriptor::IsA(const EntityDescriptor *other) const +{ + const EntityDescriptor *found = 0; + const EntityDescLinkNode *link = (const EntityDescLinkNode *)(GetSupertypes().GetHead()); - if( this == other ) { + if(this == other) { return other; } else { - while( link && ! found ) { - found = link -> EntityDesc() -> IsA( other ); - link = ( EntityDescLinkNode * ) link -> NextNode(); + while(link && ! found) { + found = link -> EntityDesc() -> IsA(other); + link = (EntityDescLinkNode *) link -> NextNode(); } } return found; diff --git a/src/clstepcore/entityDescriptor.h b/src/clstepcore/entityDescriptor.h index e0bd25ec8..1510fe6a8 100644 --- a/src/clstepcore/entityDescriptor.h +++ b/src/clstepcore/entityDescriptor.h @@ -9,7 +9,7 @@ #include "sc_export.h" -typedef SDAI_Application_instance * ( * Creator )(); +typedef SDAI_Application_instance *(* Creator)(); class Registry; @@ -22,7 +22,8 @@ class Registry; * will be building the same thing but using the new schema info. * nodes (i.e. EntityDesc nodes) for each entity. */ -class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor { +class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor +{ protected: @@ -41,113 +42,137 @@ class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor { #ifdef _MSC_VER #pragma warning( pop ) #endif - public: + public: Uniqueness_rule__set_var _uniqueness_rules; // initially a null pointer // pointer to a function that will create a new instance of a SDAI_Application_instance Creator NewSTEPentity; - EntityDescriptor( ); - EntityDescriptor( const char * name, // i.e. char * - Schema * origSchema, - Logical abstractEntity, // i.e. F U or T - Logical extMapping, - Creator f = 0 + EntityDescriptor(); + EntityDescriptor(const char *name, // i.e. char * + Schema *origSchema, + Logical abstractEntity, // i.e. F U or T + Logical extMapping, + Creator f = 0 ); virtual ~EntityDescriptor(); - void InitIAttrs( Registry & reg, const char * schNm ); + void InitIAttrs(Registry ®, const char *schNm); - const char * GenerateExpress( std::string & buf ) const; + const char *GenerateExpress(std::string &buf) const; - const char * QualifiedName( std::string & s ) const; + const char *QualifiedName(std::string &s) const; - const SDAI_LOGICAL & AbstractEntity() const { + const SDAI_LOGICAL &AbstractEntity() const + { return _abstractEntity; } - const SDAI_LOGICAL & ExtMapping() const { + const SDAI_LOGICAL &ExtMapping() const + { return _extMapping; } - void AbstractEntity( SDAI_LOGICAL & ae ) { - _abstractEntity.put( ae.asInt() ); + void AbstractEntity(SDAI_LOGICAL &ae) + { + _abstractEntity.put(ae.asInt()); } - void ExtMapping( SDAI_LOGICAL & em ) { - _extMapping.put( em.asInt() ); + void ExtMapping(SDAI_LOGICAL &em) + { + _extMapping.put(em.asInt()); } - void AbstractEntity( Logical ae ) { - _abstractEntity.put( ae ); + void AbstractEntity(Logical ae) + { + _abstractEntity.put(ae); } - void ExtMapping( Logical em ) { - _extMapping.put( em ); + void ExtMapping(Logical em) + { + _extMapping.put(em); } - void ExtMapping( const char * em ) { - _extMapping.put( em ); + void ExtMapping(const char *em) + { + _extMapping.put(em); } - const EntityDescriptorList & Subtypes() const { + const EntityDescriptorList &Subtypes() const + { return _subtypes; } - const EntityDescriptorList & Supertypes() const { + const EntityDescriptorList &Supertypes() const + { return _supertypes; } - const EntityDescriptorList & GetSupertypes() const { + const EntityDescriptorList &GetSupertypes() const + { return _supertypes; } - const AttrDescriptorList & ExplicitAttr() const { + const AttrDescriptorList &ExplicitAttr() const + { return _explicitAttr; } - const Inverse_attributeList & InverseAttr() const { + const Inverse_attributeList &InverseAttr() const + { return _inverseAttr; } - virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; - virtual const TypeDescriptor * IsA( const TypeDescriptor * td ) const; - virtual const TypeDescriptor * IsA( const char * n ) const { - return TypeDescriptor::IsA( n ); + virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; + virtual const TypeDescriptor *IsA(const TypeDescriptor *td) const; + virtual const TypeDescriptor *IsA(const char *n) const + { + return TypeDescriptor::IsA(n); } - virtual const TypeDescriptor * CanBe( const TypeDescriptor * o ) const { - return o -> IsA( this ); + virtual const TypeDescriptor *CanBe(const TypeDescriptor *o) const + { + return o -> IsA(this); } - virtual const TypeDescriptor * CanBe( const char * n ) const { - return TypeDescriptor::CanBe( n ); + virtual const TypeDescriptor *CanBe(const char *n) const + { + return TypeDescriptor::CanBe(n); } // The following will be used by schema initialization functions - void AddSubtype( EntityDescriptor * ed ) { - _subtypes.AddNode( ed ); + void AddSubtype(EntityDescriptor *ed) + { + _subtypes.AddNode(ed); } - void AddSupertype_Stmt( const std::string & s ) { + void AddSupertype_Stmt(const std::string &s) + { _supertype_stmt = s; } - const char * Supertype_Stmt() { + const char *Supertype_Stmt() + { return _supertype_stmt.c_str(); } - std::string & supertype_stmt_() { + std::string &supertype_stmt_() + { return _supertype_stmt; } - void AddSupertype( EntityDescriptor * ed ) { - _supertypes.AddNode( ed ); + void AddSupertype(EntityDescriptor *ed) + { + _supertypes.AddNode(ed); } - void AddExplicitAttr( AttrDescriptor * ad ) { - _explicitAttr.AddNode( ad ); + void AddExplicitAttr(AttrDescriptor *ad) + { + _explicitAttr.AddNode(ad); } - void AddInverseAttr( Inverse_attribute * ia ) { - _inverseAttr.AddNode( ia ); + void AddInverseAttr(Inverse_attribute *ia) + { + _inverseAttr.AddNode(ia); } - void uniqueness_rules_( Uniqueness_rule__set * urs ) { + void uniqueness_rules_(Uniqueness_rule__set *urs) + { _uniqueness_rules = urs; } - Uniqueness_rule__set_var & uniqueness_rules_() { + Uniqueness_rule__set_var &uniqueness_rules_() + { return _uniqueness_rules; } diff --git a/src/clstepcore/entityDescriptorList.cc b/src/clstepcore/entityDescriptorList.cc index 86d937c76..92b3001e1 100644 --- a/src/clstepcore/entityDescriptorList.cc +++ b/src/clstepcore/entityDescriptorList.cc @@ -1,29 +1,36 @@ #include "entityDescriptorList.h" -EntityDescLinkNode::EntityDescLinkNode() { +EntityDescLinkNode::EntityDescLinkNode() +{ _entityDesc = 0; } -EntityDescLinkNode::~EntityDescLinkNode() { +EntityDescLinkNode::~EntityDescLinkNode() +{ } -EntityDescriptorList::EntityDescriptorList() { +EntityDescriptorList::EntityDescriptorList() +{ } -EntityDescriptorList::~EntityDescriptorList() { +EntityDescriptorList::~EntityDescriptorList() +{ } -EntityDescItr::EntityDescItr( const EntityDescriptorList & edList ) : edl( edList ) { - cur = ( EntityDescLinkNode * )( edl.GetHead() ); +EntityDescItr::EntityDescItr(const EntityDescriptorList &edList) : edl(edList) +{ + cur = (EntityDescLinkNode *)(edl.GetHead()); } -EntityDescItr::~EntityDescItr() { +EntityDescItr::~EntityDescItr() +{ } -EntityDescriptor * EntityDescItr::NextEntityDesc_nc() { - if( cur ) { - EntityDescriptor * ed = cur->EntityDesc(); - cur = ( EntityDescLinkNode * )( cur->NextNode() ); +EntityDescriptor *EntityDescItr::NextEntityDesc_nc() +{ + if(cur) { + EntityDescriptor *ed = cur->EntityDesc(); + cur = (EntityDescLinkNode *)(cur->NextNode()); return ed; } return 0; diff --git a/src/clstepcore/entityDescriptorList.h b/src/clstepcore/entityDescriptorList.h index e34da432a..5d8059b62 100644 --- a/src/clstepcore/entityDescriptorList.h +++ b/src/clstepcore/entityDescriptorList.h @@ -9,25 +9,29 @@ class EntityDescriptor; -class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode { +class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode +{ private: protected: - EntityDescriptor * _entityDesc; + EntityDescriptor *_entityDesc; public: EntityDescLinkNode(); virtual ~EntityDescLinkNode(); - EntityDescriptor * EntityDesc() const { + EntityDescriptor *EntityDesc() const + { return _entityDesc; } - void EntityDesc( EntityDescriptor * ed ) { + void EntityDesc(EntityDescriptor *ed) + { _entityDesc = ed; } }; -class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList { +class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList +{ private: protected: @@ -35,39 +39,44 @@ class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList { EntityDescriptorList(); virtual ~EntityDescriptorList(); - virtual SingleLinkNode * NewNode() { + virtual SingleLinkNode *NewNode() + { return new EntityDescLinkNode; } - EntityDescLinkNode * AddNode( EntityDescriptor * ed ) { - EntityDescLinkNode * node = ( EntityDescLinkNode * ) NewNode(); - node->EntityDesc( ed ); - SingleLinkList::AppendNode( node ); + EntityDescLinkNode *AddNode(EntityDescriptor *ed) + { + EntityDescLinkNode *node = (EntityDescLinkNode *) NewNode(); + node->EntityDesc(ed); + SingleLinkList::AppendNode(node); return node; } }; -typedef EntityDescriptorList * Entity__set_ptr; +typedef EntityDescriptorList *Entity__set_ptr; typedef Entity__set_ptr Entity__set_var; -class SC_CORE_EXPORT EntityDescItr { +class SC_CORE_EXPORT EntityDescItr +{ protected: - const EntityDescriptorList & edl; - const EntityDescLinkNode * cur; + const EntityDescriptorList &edl; + const EntityDescLinkNode *cur; public: - EntityDescItr( const EntityDescriptorList & edList ); + EntityDescItr(const EntityDescriptorList &edList); virtual ~EntityDescItr(); - void ResetItr() { - cur = ( EntityDescLinkNode * )( edl.GetHead() ); + void ResetItr() + { + cur = (EntityDescLinkNode *)(edl.GetHead()); } - inline const EntityDescriptor * NextEntityDesc() { + inline const EntityDescriptor *NextEntityDesc() + { return NextEntityDesc_nc(); } - EntityDescriptor * NextEntityDesc_nc(); + EntityDescriptor *NextEntityDesc_nc(); }; #endif //ENTITYDESCRIPTORLIST_H diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index 0dd35803a..d74a68621 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -20,11 +20,12 @@ * Returns the number of EntLists in this's list (EntList->next, next->next * etc.) including this. */ -int EntList::siblings() { +int EntList::siblings() +{ int count; - EntList * el; + EntList *el; - for( count = 1, el = next; el; count++, el = el->next ) { + for(count = 1, el = next; el; count++, el = el->next) { ; } return count; @@ -33,10 +34,11 @@ int EntList::siblings() { /** * Returns the first EntList not of type join, starting from this. */ -EntList * EntList::firstNot( JoinType j ) { - EntList * sibling = this; +EntList *EntList::firstNot(JoinType j) +{ + EntList *sibling = this; - while( sibling != NULL && sibling->join == j ) { + while(sibling != NULL && sibling->join == j) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -45,10 +47,11 @@ EntList * EntList::firstNot( JoinType j ) { /** * Returns the first EntList where viable = match, starting from this. */ -EntList * EntList::firstWanted( MatchType match ) { - EntList * sibling = this; +EntList *EntList::firstWanted(MatchType match) +{ + EntList *sibling = this; - while( sibling != NULL && sibling->viable != match ) { + while(sibling != NULL && sibling->viable != match) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -58,10 +61,11 @@ EntList * EntList::firstWanted( MatchType match ) { * Returns the last EntList not of type join, searching backwards from * this. */ -EntList * EntList::lastNot( JoinType j ) { - EntList * sibling = this; +EntList *EntList::lastNot(JoinType j) +{ + EntList *sibling = this; - while( sibling != NULL && sibling->join == j ) { + while(sibling != NULL && sibling->join == j) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -71,10 +75,11 @@ EntList * EntList::lastNot( JoinType j ) { * Returns the last EntList where viable = match, searching backwards from * this. */ -EntList * EntList::lastWanted( MatchType match ) { - EntList * sibling = this; +EntList *EntList::lastWanted(MatchType match) +{ + EntList *sibling = this; - while( sibling != NULL && sibling->viable != match ) { + while(sibling != NULL && sibling->viable != match) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -85,21 +90,22 @@ EntList * EntList::lastWanted( MatchType match ) { * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ -void SimpleList::unmarkAll( EntNode * ents ) { - EntNode * eptr = ents; +void SimpleList::unmarkAll(EntNode *ents) +{ + EntNode *eptr = ents; int comp = -1; - if( viable < MATCHSOME ) { + if(viable < MATCHSOME) { return; } - while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { + while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if( eptr->mark <= I_marked ) { + if(eptr->mark <= I_marked) { // Only unmark if we gave it the strongest mark: - eptr->setmark( NOMARK ); + eptr->setmark(NOMARK); } // Either way (whether or not another List's mark remains), we no longer // marked: @@ -112,14 +118,15 @@ void SimpleList::unmarkAll( EntNode * ents ) { * viable val of MATCHSOME. Return true if we mark a previously unmarked * node; otherwise false. */ -bool SimpleList::acceptChoice( EntNode * ents ) { - EntNode * eptr = ents; +bool SimpleList::acceptChoice(EntNode *ents) +{ + EntNode *eptr = ents; int comp; - while( eptr != NULL ) { - if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { - if( ! eptr->marked() ) { - eptr->setmark( ORMARK ); + while(eptr != NULL) { + if((comp = strcmp(name, eptr->name)) == 0) { + if(! eptr->marked()) { + eptr->setmark(ORMARK); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -127,7 +134,7 @@ bool SimpleList::acceptChoice( EntNode * ents ) { } return false; // we didn't mark } - if( comp < 0 ) { + if(comp < 0) { // We're beyond name in the ents list. No more checking to do. return false; } diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 792489e4b..5fe71a6a5 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -21,30 +21,31 @@ * list, then sets this to the first element, and then deletes the first * element. This ensures that `this' points to the start of the list. */ -EntNode::EntNode( const char ** names ) { +EntNode::EntNode(const char **names) +{ int j = 1, comp; - EntNode * prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - const char * nm; + EntNode *prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + const char *nm; // Create a first EntNode: - firstnode = prev = new EntNode( names[0] ); + firstnode = prev = new EntNode(names[0]); - while( names[j] && *names[j] != '*' ) { + while(names[j] && *names[j] != '*') { nm = names[j]; - while( prev != NULL && ( comp = StrCmpIns( prev->name, nm ) ) < 0 ) { + while(prev != NULL && (comp = StrCmpIns(prev->name, nm)) < 0) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if( comp != 0 ) { + if(comp != 0) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode( nm ); + newnode = new EntNode(nm); newnode->next = prev; - if( prev2 == NULL ) { + if(prev2 == NULL) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -70,10 +71,11 @@ EntNode::EntNode( const char ** names ) { /** * Copies all of ent's values here. */ -EntNode & EntNode::operator= ( EntNode & ent ) { - Name( ent.name ); - setmark( ent.mark ); - multSuprs( ent.multSupers ); +EntNode &EntNode::operator= (EntNode &ent) +{ + Name(ent.name); + setmark(ent.mark); + multSuprs(ent.multSupers); next = ent.next; return *this; } @@ -81,10 +83,11 @@ EntNode & EntNode::operator= ( EntNode & ent ) { /** * Marks/unmarks all the nodes in this's list (default is to mark). */ -void EntNode::markAll( MarkType stamp ) { - EntNode * node = this; +void EntNode::markAll(MarkType stamp) +{ + EntNode *node = this; - while( node != NULL ) { + while(node != NULL) { node->mark = stamp; node = node->next; } @@ -93,11 +96,12 @@ void EntNode::markAll( MarkType stamp ) { /** * Returns true if this and all nodes following it are marked. */ -bool EntNode::allMarked() { - EntNode * node = this; +bool EntNode::allMarked() +{ + EntNode *node = this; - while( node != NULL ) { - if( node->mark == NOMARK ) { + while(node != NULL) { + if(node->mark == NOMARK) { return false; } node = node->next; @@ -108,12 +112,13 @@ bool EntNode::allMarked() { /** * Returns the number of unmarked nodes in this's list. */ -int EntNode::unmarkedCount() { +int EntNode::unmarkedCount() +{ int count = 0; - EntNode * node = this; + EntNode *node = this; - while( node != NULL ) { - if( node->mark == NOMARK ) { + while(node != NULL) { + if(node->mark == NOMARK) { count++; } node = node->next; @@ -125,13 +130,14 @@ int EntNode::unmarkedCount() { * Starting from `this', search for the last node (along our next's) which * alphabetically precedes ent. */ -EntNode * EntNode::lastSmaller( EntNode * ent ) { - EntNode * eptr = next, *prev = this; +EntNode *EntNode::lastSmaller(EntNode *ent) +{ + EntNode *eptr = next, *prev = this; - if( *this > *ent ) { + if(*this > *ent) { return NULL; } - while( eptr && *eptr > *prev && *eptr < *ent ) { + while(eptr && *eptr > *prev && *eptr < *ent) { prev = eptr; eptr = eptr->next; } @@ -147,10 +153,11 @@ EntNode * EntNode::lastSmaller( EntNode * ent ) { * few of the nodes. The nodes at first were in order; only the renamed * ones may be out of place.) */ -void EntNode::sort( EntNode ** first ) { - EntNode * eptr1, *eptr2, *temp1, *temp2; +void EntNode::sort(EntNode **first) +{ + EntNode *eptr1, *eptr2, *temp1, *temp2; - while( next && *this > *next ) { + while(next && *this > *next) { // Find the earliest node greater than next. (I.e., is not only this > // next but also some of this's preceding nodes. Since the nodes @@ -158,20 +165,20 @@ void EntNode::sort( EntNode ** first ) { // ordered chunk of nodes which next should precede.) (eptr1 is // actually set to the one before, so that we'll know that eptr1->next // should now be set to next.) - eptr1 = ( *first )->lastSmaller( next ); + eptr1 = (*first)->lastSmaller(next); // Take the latest node eptr1 is greater than. (I.e., beyond next are // there more nodes which should be immediately after eptr1.) (The // succeeding nodes are not necessarily in order, so lastSmaller() also // checks that nodes later than next are also > their prev's.) - if( eptr1 ) { - eptr2 = next->lastSmaller( eptr1->next ); + if(eptr1) { + eptr2 = next->lastSmaller(eptr1->next); } else { - eptr2 = next->lastSmaller( *first ); + eptr2 = next->lastSmaller(*first); } // Switch the two lists: - if( eptr1 ) { + if(eptr1) { temp1 = eptr1->next; eptr1->next = next; temp2 = eptr2->next; @@ -186,7 +193,7 @@ void EntNode::sort( EntNode ** first ) { } } - if( next ) { - next->sort( first ); + if(next) { + next->sort(first); } } diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 9200b196f..16a34ae7f 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -5,73 +5,77 @@ * this was in ExpDict.cc before splitting it up */ #ifdef NOT_YET -EnumerationTypeDescriptor::EnumerationTypeDescriptor( ) { +EnumerationTypeDescriptor::EnumerationTypeDescriptor() +{ _elements = new StringAggregate; } #endif -EnumTypeDescriptor::EnumTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, - const char * d, EnumCreator f ) - : TypeDescriptor( nm, ft, origSchema, d ), CreateNewEnum( f ) { +EnumTypeDescriptor::EnumTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, + const char *d, EnumCreator f) + : TypeDescriptor(nm, ft, origSchema, d), CreateNewEnum(f) +{ } -SDAI_Enum * EnumTypeDescriptor::CreateEnum() { - if( CreateNewEnum ) { +SDAI_Enum *EnumTypeDescriptor::CreateEnum() +{ + if(CreateNewEnum) { return CreateNewEnum(); } else { return 0; } } -const char * EnumTypeDescriptor::GenerateExpress( std::string & buf ) const { +const char *EnumTypeDescriptor::GenerateExpress(std::string &buf) const +{ char tmp[BUFSIZ]; buf = "TYPE "; - buf.append( StrToLower( Name(), tmp ) ); - buf.append( " = ENUMERATION OF \n (" ); - const char * desc = Description(); - const char * ptr = &( desc[16] ); + buf.append(StrToLower(Name(), tmp)); + buf.append(" = ENUMERATION OF \n ("); + const char *desc = Description(); + const char *ptr = &(desc[16]); - while( *ptr != '\0' ) { - if( *ptr == ',' ) { - buf.append( ",\n " ); - } else if( isupper( *ptr ) ) { - buf += ( char )tolower( *ptr ); + while(*ptr != '\0') { + if(*ptr == ',') { + buf.append(",\n "); + } else if(isupper(*ptr)) { + buf += (char)tolower(*ptr); } else { buf += *ptr; } ptr++; } - buf.append( ";\n" ); + buf.append(";\n"); /////////////// // count is # of WHERE rules - if( _where_rules != 0 ) { + if(_where_rules != 0) { int all_comments = 1; int count = _where_rules->Count(); - for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule - if( !( *( _where_rules ) )[i]->_label.size() ) { + for(int i = 0; i < count; i++) { // print out each UNIQUE rule + if(!(*(_where_rules))[i]->_label.size()) { all_comments = 0; } } - if( all_comments ) { - buf.append( " (* WHERE *)\n" ); + if(all_comments) { + buf.append(" (* WHERE *)\n"); } else { - buf.append( " WHERE\n" ); + buf.append(" WHERE\n"); } - for( int i = 0; i < count; i++ ) { // print out each WHERE rule - if( !( *( _where_rules ) )[i]->_comment.empty() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->comment_() ); + for(int i = 0; i < count; i++) { // print out each WHERE rule + if(!(*(_where_rules))[i]->_comment.empty()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->comment_()); } - if( ( *( _where_rules ) )[i]->_label.size() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->label_() ); + if((*(_where_rules))[i]->_label.size()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->label_()); } } } - buf.append( "END_TYPE;\n" ); - return const_cast( buf.c_str() ); + buf.append("END_TYPE;\n"); + return const_cast(buf.c_str()); } diff --git a/src/clstepcore/enumTypeDescriptor.h b/src/clstepcore/enumTypeDescriptor.h index de3a2c620..1d4d3d226 100644 --- a/src/clstepcore/enumTypeDescriptor.h +++ b/src/clstepcore/enumTypeDescriptor.h @@ -3,24 +3,26 @@ #include "typeDescriptor.h" -typedef SDAI_Enum * ( * EnumCreator )(); +typedef SDAI_Enum *(* EnumCreator)(); -class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor { +class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor +{ public: EnumCreator CreateNewEnum; - const char * GenerateExpress( std::string & buf ) const; + const char *GenerateExpress(std::string &buf) const; - void AssignEnumCreator( EnumCreator f = 0 ) { + void AssignEnumCreator(EnumCreator f = 0) + { CreateNewEnum = f; } - SDAI_Enum * CreateEnum(); + SDAI_Enum *CreateEnum(); - EnumTypeDescriptor( ) { } - EnumTypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d, - EnumCreator f = 0 ); + EnumTypeDescriptor() { } + EnumTypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d, + EnumCreator f = 0); virtual ~EnumTypeDescriptor() { } }; @@ -32,17 +34,19 @@ class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor { * why have EnumTypeDescriptor + EnumerationTypeDescriptor ??? */ #ifdef NOT_YET -class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor { +class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor +{ protected: - StringAggregate * _elements; // of (null) + StringAggregate *_elements; // of (null) public: - EnumerationTypeDescriptor( ); + EnumerationTypeDescriptor(); virtual ~EnumerationTypeDescriptor() { } - StringAggregate & Elements() { + StringAggregate &Elements() + { return *_elements; } // void Elements (StringAggregate e); diff --git a/src/clstepcore/explicitItemId.cc b/src/clstepcore/explicitItemId.cc index c229f6369..e34a583e7 100644 --- a/src/clstepcore/explicitItemId.cc +++ b/src/clstepcore/explicitItemId.cc @@ -1,103 +1,116 @@ #include "explicitItemId.h" -Explicit_item_id::Explicit_item_id() { +Explicit_item_id::Explicit_item_id() +{ _local_definition = 0; } -Explicit_item_id::Explicit_item_id( const Explicit_item_id & eii ) -: Interfaced_item( eii ) { +Explicit_item_id::Explicit_item_id(const Explicit_item_id &eii) + : Interfaced_item(eii) +{ _local_definition = eii._local_definition; _original_id = eii._original_id; _new_id = eii._new_id; } -Explicit_item_id::~Explicit_item_id() { +Explicit_item_id::~Explicit_item_id() +{ _local_definition = 0; } -Explicit_item_id__set::Explicit_item_id__set( int defaultSize ) { +Explicit_item_id__set::Explicit_item_id__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Explicit_item_id_ptr[_bufsize]; _count = 0; } -Explicit_item_id__set::~Explicit_item_id__set() { +Explicit_item_id__set::~Explicit_item_id__set() +{ delete[] _buf; } -void Explicit_item_id__set::Check( int index ) { - Explicit_item_id_ptr * newbuf; +void Explicit_item_id__set::Check(int index) +{ + Explicit_item_id_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Explicit_item_id_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Explicit_item_id_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Explicit_item_id_ptr)); delete[] _buf; _buf = newbuf; } } -void Explicit_item_id__set::Insert( Explicit_item_id_ptr v, int index ) { - Explicit_item_id_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Explicit_item_id__set::Insert(Explicit_item_id_ptr v, int index) +{ + Explicit_item_id_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Append( Explicit_item_id_ptr v ) { +void Explicit_item_id__set::Append(Explicit_item_id_ptr v) +{ int index = _count; - Explicit_item_id_ptr * spot; + Explicit_item_id_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Explicit_item_id__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Explicit_item_id_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); + Explicit_item_id_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Explicit_item_id_ptr)); } } -int Explicit_item_id__set::Index( Explicit_item_id_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Explicit_item_id__set::Index(Explicit_item_id_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Explicit_item_id_ptr & Explicit_item_id__set::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Explicit_item_id_ptr &Explicit_item_id__set::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Explicit_item_id__set::Count() { +int Explicit_item_id__set::Count() +{ return _count; } -void Explicit_item_id__set::Clear() { +void Explicit_item_id__set::Clear() +{ _count = 0; } diff --git a/src/clstepcore/explicitItemId.h b/src/clstepcore/explicitItemId.h index 8a4d22ca0..d16f05b21 100644 --- a/src/clstepcore/explicitItemId.h +++ b/src/clstepcore/explicitItemId.h @@ -3,122 +3,134 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item { -protected: - Explicit_item_id(); - Explicit_item_id( const Explicit_item_id & ); - Explicit_item_id( const char * foreign_schema, TypeDescriptor * ld, - const char * oi, const char * ni ) - : Interfaced_item( foreign_schema ), _local_definition( ld ), _original_id( oi ), _new_id( ni ) {} - virtual ~Explicit_item_id(); -public: - // definition in the local schema. The TypeDescriptor (or subtype) is not - // implemented quite right - the name in it is the original (foreign - // schema) name. The USE or REFERENCED renames are listed in - // TypeDescriptor's altNames member variable. - // Warning: This is currently a null ptr for objects other than - // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE - // this ptr will be null. - const TypeDescriptor * _local_definition; +class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item +{ + protected: + Explicit_item_id(); + Explicit_item_id(const Explicit_item_id &); + Explicit_item_id(const char *foreign_schema, TypeDescriptor *ld, + const char *oi, const char *ni) + : Interfaced_item(foreign_schema), _local_definition(ld), _original_id(oi), _new_id(ni) {} + virtual ~Explicit_item_id(); + public: + // definition in the local schema. The TypeDescriptor (or subtype) is not + // implemented quite right - the name in it is the original (foreign + // schema) name. The USE or REFERENCED renames are listed in + // TypeDescriptor's altNames member variable. + // Warning: This is currently a null ptr for objects other than + // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE + // this ptr will be null. + const TypeDescriptor *_local_definition; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - // name in originating schema - only exists if it has been renamed. - Express_id _original_id; + // name in originating schema - only exists if it has been renamed. + Express_id _original_id; - Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) + Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) #ifdef _MSC_VER #pragma warning( pop ) #endif - const TypeDescriptor * local_definition_() const { - return _local_definition; - } - - const Express_id original_id_() const { - return _original_id; - } - - // non-sdai, renamed name - const Express_id new_id_() const { - return _new_id; - } - - // return string "USE" or "REFERENCE" - virtual const char * EXPRESS_type() = 0; - - // private: - void local_definition_( const TypeDescriptor * td ) { - _local_definition = td; - } - void original_id_( const Express_id & ei ) { - _original_id = ei; - } - - // non-sdai - void new_id_( const Express_id & ni ) { - _new_id = ni; - } + const TypeDescriptor *local_definition_() const + { + return _local_definition; + } + + const Express_id original_id_() const + { + return _original_id; + } + + // non-sdai, renamed name + const Express_id new_id_() const + { + return _new_id; + } + + // return string "USE" or "REFERENCE" + virtual const char *EXPRESS_type() = 0; + + // private: + void local_definition_(const TypeDescriptor *td) + { + _local_definition = td; + } + void original_id_(const Express_id &ei) + { + _original_id = ei; + } + + // non-sdai + void new_id_(const Express_id &ni) + { + _new_id = ni; + } }; -typedef Explicit_item_id * Explicit_item_id_ptr; - - -class SC_CORE_EXPORT Explicit_item_id__set { -public: - Explicit_item_id__set( int = 16 ); - ~Explicit_item_id__set(); - - Explicit_item_id_ptr & operator[]( int index ); - void Insert( Explicit_item_id_ptr, int index ); - void Append( Explicit_item_id_ptr ); - void Remove( int index ); - int Index( Explicit_item_id_ptr ); - - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Explicit_item_id_ptr * _buf; - int _bufsize; - int _count; +typedef Explicit_item_id *Explicit_item_id_ptr; + + +class SC_CORE_EXPORT Explicit_item_id__set +{ + public: + Explicit_item_id__set(int = 16); + ~Explicit_item_id__set(); + + Explicit_item_id_ptr &operator[](int index); + void Insert(Explicit_item_id_ptr, int index); + void Append(Explicit_item_id_ptr); + void Remove(int index); + int Index(Explicit_item_id_ptr); + + int Count(); + void Clear(); + private: + void Check(int index); + private: + Explicit_item_id_ptr *_buf; + int _bufsize; + int _count; }; -typedef Explicit_item_id__set * Explicit_item_id__set_ptr; +typedef Explicit_item_id__set *Explicit_item_id__set_ptr; typedef Explicit_item_id__set_ptr Explicit_item_id__set_var; -class SC_CORE_EXPORT Used_item : public Explicit_item_id { -public: - Used_item() {} - Used_item( const char * foreign_schema, TypeDescriptor * ld, - const char * oi, const char * ni ) - : Explicit_item_id( foreign_schema, ld, oi, ni ) {} - virtual ~Used_item() {} - - const char * EXPRESS_type() { - return "USE"; - } +class SC_CORE_EXPORT Used_item : public Explicit_item_id +{ + public: + Used_item() {} + Used_item(const char *foreign_schema, TypeDescriptor *ld, + const char *oi, const char *ni) + : Explicit_item_id(foreign_schema, ld, oi, ni) {} + virtual ~Used_item() {} + + const char *EXPRESS_type() + { + return "USE"; + } }; -typedef Used_item * Used_item_ptr; - -class SC_CORE_EXPORT Referenced_item : public Explicit_item_id { -public: - Referenced_item() {} - Referenced_item( const char * foreign_schema, TypeDescriptor * ld, - const char * oi, const char * ni ) - : Explicit_item_id( foreign_schema, ld, oi, ni ) {} - virtual ~Referenced_item() {} - - const char * EXPRESS_type() { - return "REFERENCE"; - } +typedef Used_item *Used_item_ptr; + +class SC_CORE_EXPORT Referenced_item : public Explicit_item_id +{ + public: + Referenced_item() {} + Referenced_item(const char *foreign_schema, TypeDescriptor *ld, + const char *oi, const char *ni) + : Explicit_item_id(foreign_schema, ld, oi, ni) {} + virtual ~Referenced_item() {} + + const char *EXPRESS_type() + { + return "REFERENCE"; + } }; -typedef Referenced_item * Referenced_item_ptr; +typedef Referenced_item *Referenced_item_ptr; #endif //EXPLICITITEMID_H diff --git a/src/clstepcore/globalRule.cc b/src/clstepcore/globalRule.cc index b6fdeb19a..126fbda1d 100644 --- a/src/clstepcore/globalRule.cc +++ b/src/clstepcore/globalRule.cc @@ -1,28 +1,33 @@ #include "globalRule.h" Global_rule::Global_rule() -: _entities( 0 ), _where_rules( 0 ), _parent_schema( 0 ) { + : _entities(0), _where_rules(0), _parent_schema(0) +{ } -Global_rule::Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ) -: _name( n ), _entities( 0 ), _where_rules( 0 ), _parent_schema( parent_sch ), -_rule_text( rt ) { +Global_rule::Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt) + : _name(n), _entities(0), _where_rules(0), _parent_schema(parent_sch), + _rule_text(rt) +{ } /// not fully implemented -Global_rule::Global_rule( Global_rule & gr ): Dictionary_instance() { +Global_rule::Global_rule(Global_rule &gr): Dictionary_instance() +{ _name = gr._name; _parent_schema = gr._parent_schema; } -Global_rule::~Global_rule() { +Global_rule::~Global_rule() +{ delete _entities; delete _where_rules; } -void Global_rule::entities_( const Entity__set_var & e ) { - if( _entities ) { - if( _entities->EntryCount() > 0 ) { +void Global_rule::entities_(const Entity__set_var &e) +{ + if(_entities) { + if(_entities->EntryCount() > 0) { std::cerr << "In " << __FILE__ << ", Global_rule::entities_(): overwriting non-empty entity set!" << std::endl; } delete _entities; @@ -30,9 +35,10 @@ void Global_rule::entities_( const Entity__set_var & e ) { _entities = e; } -void Global_rule::where_rules_( const Where_rule__list_var & wrl ) { - if( _where_rules ) { - if( _where_rules->Count() > 0 ) { +void Global_rule::where_rules_(const Where_rule__list_var &wrl) +{ + if(_where_rules) { + if(_where_rules->Count() > 0) { std::cerr << "In " << __FILE__ << ", Global_rule::where_rules_(): overwriting non-empty rule set!" << std::endl; } delete _where_rules; @@ -42,92 +48,102 @@ void Global_rule::where_rules_( const Where_rule__list_var & wrl ) { /////////////////////////////////////////////////////////////////////////////// -Global_rule__set::Global_rule__set( int defaultSize ) { +Global_rule__set::Global_rule__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Global_rule_ptr[_bufsize]; _count = 0; } -Global_rule__set::~Global_rule__set() { +Global_rule__set::~Global_rule__set() +{ Clear(); delete[] _buf; } -void Global_rule__set::Check( int index ) { - Global_rule_ptr * newbuf; +void Global_rule__set::Check(int index) +{ + Global_rule_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Global_rule_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Global_rule_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Global_rule_ptr)); delete[] _buf; _buf = newbuf; } } -void Global_rule__set::Insert( Global_rule_ptr v, int index ) { - Global_rule_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Global_rule__set::Insert(Global_rule_ptr v, int index) +{ + Global_rule_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Append( Global_rule_ptr v ) { +void Global_rule__set::Append(Global_rule_ptr v) +{ int index = _count; - Global_rule_ptr * spot; + Global_rule_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Global_rule__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Global_rule_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Global_rule_ptr ) ); + Global_rule_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Global_rule_ptr)); } } -int Global_rule__set::Index( Global_rule_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Global_rule__set::Index(Global_rule_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Global_rule_ptr & Global_rule__set::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Global_rule_ptr &Global_rule__set::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Global_rule__set::Count() { +int Global_rule__set::Count() +{ return _count; } -void Global_rule__set::Clear() { - for( int i = 0; i < _count; i ++ ) { +void Global_rule__set::Clear() +{ + for(int i = 0; i < _count; i ++) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index c5614fdbf..1c47bdbbe 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -7,81 +7,91 @@ #include "sc_export.h" -class SC_CORE_EXPORT Global_rule : public Dictionary_instance { -public: +class SC_CORE_EXPORT Global_rule : public Dictionary_instance +{ + public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _name; - std::string _rule_text; // non-SDAI + Express_id _name; + std::string _rule_text; // non-SDAI #ifdef _MSC_VER #pragma warning( pop ) #endif - Entity__set_var _entities; // not implemented - Where_rule__list_var _where_rules; - Schema_ptr _parent_schema; + Entity__set_var _entities; // not implemented + Where_rule__list_var _where_rules; + Schema_ptr _parent_schema; - Global_rule(); - Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ); - Global_rule( Global_rule & ); // not fully implemented - virtual ~Global_rule(); + Global_rule(); + Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt); + Global_rule(Global_rule &); // not fully implemented + virtual ~Global_rule(); - Express_id name_() const { - return _name; - } - Entity__set_var entities_() const { - return _entities; - } - Where_rule__list_var where_rules_() const { - return _where_rules; - } - Schema_ptr parent_schema_() const { - return _parent_schema; - } - const char * rule_text_() { - return _rule_text.c_str(); - } + Express_id name_() const + { + return _name; + } + Entity__set_var entities_() const + { + return _entities; + } + Where_rule__list_var where_rules_() const + { + return _where_rules; + } + Schema_ptr parent_schema_() const + { + return _parent_schema; + } + const char *rule_text_() + { + return _rule_text.c_str(); + } - void name_( Express_id & n ) { - _name = n; - } - void entities_( const Entity__set_var & e ); // not implemented - void where_rules_( const Where_rule__list_var & wrl ); // not implemented - void parent_schema_( const Schema_ptr & s ) { - _parent_schema = s; - } - void rule_text_( const char * rt ) { - _rule_text = rt; - } + void name_(Express_id &n) + { + _name = n; + } + void entities_(const Entity__set_var &e); // not implemented + void where_rules_(const Where_rule__list_var &wrl); // not implemented + void parent_schema_(const Schema_ptr &s) + { + _parent_schema = s; + } + void rule_text_(const char *rt) + { + _rule_text = rt; + } }; -typedef Global_rule * Global_rule_ptr; +typedef Global_rule *Global_rule_ptr; -class SC_CORE_EXPORT Global_rule__set { -public: - Global_rule__set( int = 16 ); - ~Global_rule__set(); +class SC_CORE_EXPORT Global_rule__set +{ + public: + Global_rule__set(int = 16); + ~Global_rule__set(); - Global_rule_ptr & operator[]( int index ); - void Insert( Global_rule_ptr, int index ); - void Append( Global_rule_ptr ); - void Remove( int index ); - int Index( Global_rule_ptr ); + Global_rule_ptr &operator[](int index); + void Insert(Global_rule_ptr, int index); + void Append(Global_rule_ptr); + void Remove(int index); + int Index(Global_rule_ptr); - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Global_rule_ptr * _buf; - int _bufsize; - int _count; + int Count(); + void Clear(); + private: + void Check(int index); + private: + Global_rule_ptr *_buf; + int _bufsize; + int _count; }; -typedef Global_rule__set * Global_rule__set_ptr; +typedef Global_rule__set *Global_rule__set_ptr; typedef Global_rule__set_ptr Global_rule__set_var; diff --git a/src/clstepcore/implicitItemId.cc b/src/clstepcore/implicitItemId.cc index 1961727af..fa6443494 100644 --- a/src/clstepcore/implicitItemId.cc +++ b/src/clstepcore/implicitItemId.cc @@ -1,101 +1,114 @@ #include "implicitItemId.h" -Implicit_item_id::Implicit_item_id() { +Implicit_item_id::Implicit_item_id() +{ _local_definition = 0; } -Implicit_item_id::Implicit_item_id( Implicit_item_id & iii ) -: Interfaced_item( iii ) { +Implicit_item_id::Implicit_item_id(Implicit_item_id &iii) + : Interfaced_item(iii) +{ _local_definition = iii._local_definition; } -Implicit_item_id::~Implicit_item_id() { +Implicit_item_id::~Implicit_item_id() +{ _local_definition = 0; } -Implicit_item_id__set::Implicit_item_id__set( int defaultSize ) { +Implicit_item_id__set::Implicit_item_id__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Implicit_item_id_ptr[_bufsize]; _count = 0; } -Implicit_item_id__set::~Implicit_item_id__set() { +Implicit_item_id__set::~Implicit_item_id__set() +{ delete[] _buf; } -void Implicit_item_id__set::Check( int index ) { - Implicit_item_id_ptr * newbuf; +void Implicit_item_id__set::Check(int index) +{ + Implicit_item_id_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Implicit_item_id_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Implicit_item_id_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Implicit_item_id_ptr)); delete[]_buf; _buf = newbuf; } } -void Implicit_item_id__set::Insert( Implicit_item_id_ptr v, int index ) { - Implicit_item_id_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Implicit_item_id__set::Insert(Implicit_item_id_ptr v, int index) +{ + Implicit_item_id_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Append( Implicit_item_id_ptr v ) { +void Implicit_item_id__set::Append(Implicit_item_id_ptr v) +{ int index = _count; - Implicit_item_id_ptr * spot; + Implicit_item_id_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Implicit_item_id__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Implicit_item_id_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); + Implicit_item_id_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Implicit_item_id_ptr)); } } -int Implicit_item_id__set::Index( Implicit_item_id_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Implicit_item_id__set::Index(Implicit_item_id_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Implicit_item_id_ptr & Implicit_item_id__set::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Implicit_item_id_ptr &Implicit_item_id__set::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Implicit_item_id__set::Count() { +int Implicit_item_id__set::Count() +{ return _count; } -void Implicit_item_id__set::Clear() { +void Implicit_item_id__set::Clear() +{ _count = 0; } diff --git a/src/clstepcore/implicitItemId.h b/src/clstepcore/implicitItemId.h index c8526324e..cea215d63 100644 --- a/src/clstepcore/implicitItemId.h +++ b/src/clstepcore/implicitItemId.h @@ -3,49 +3,53 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item { -protected: - Implicit_item_id(); - Implicit_item_id( Implicit_item_id & ); - virtual ~Implicit_item_id(); -public: - const TypeDescriptor * _local_definition; - - const TypeDescriptor * local_definition_() const { - return _local_definition; - } - - // private: - void local_definition_( const TypeDescriptor * td ) { - _local_definition = td; - } +class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item +{ + protected: + Implicit_item_id(); + Implicit_item_id(Implicit_item_id &); + virtual ~Implicit_item_id(); + public: + const TypeDescriptor *_local_definition; + + const TypeDescriptor *local_definition_() const + { + return _local_definition; + } + + // private: + void local_definition_(const TypeDescriptor *td) + { + _local_definition = td; + } }; -typedef Implicit_item_id * Implicit_item_id_ptr; - - -class SC_CORE_EXPORT Implicit_item_id__set { -public: - Implicit_item_id__set( int = 16 ); - ~Implicit_item_id__set(); - - Implicit_item_id_ptr & operator[]( int index ); - void Insert( Implicit_item_id_ptr, int index ); - void Append( Implicit_item_id_ptr ); - void Remove( int index ); - int Index( Implicit_item_id_ptr ); - - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Implicit_item_id_ptr * _buf; - int _bufsize; - int _count; +typedef Implicit_item_id *Implicit_item_id_ptr; + + +class SC_CORE_EXPORT Implicit_item_id__set +{ + public: + Implicit_item_id__set(int = 16); + ~Implicit_item_id__set(); + + Implicit_item_id_ptr &operator[](int index); + void Insert(Implicit_item_id_ptr, int index); + void Append(Implicit_item_id_ptr); + void Remove(int index); + int Index(Implicit_item_id_ptr); + + int Count(); + void Clear(); + private: + void Check(int index); + private: + Implicit_item_id_ptr *_buf; + int _bufsize; + int _count; }; -typedef Implicit_item_id__set * Implicit_item_id__set_ptr; +typedef Implicit_item_id__set *Implicit_item_id__set_ptr; typedef Implicit_item_id__set_ptr Implicit_item_id__set_var; #endif //IMPLICITITEMID_H diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 702ea0869..6fa085168 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -36,24 +36,27 @@ static int debug_level = 3; /////////////////////////////////////////////////////////////////////////////// void -InstMgr::PrintSortedFileIds() { - MgrNode * mn = 0; +InstMgr::PrintSortedFileIds() +{ + MgrNode *mn = 0; int count = InstanceCount(); int i = 0; - for( i = 0; i < count; i++ ) { - mn = ( MgrNode * )( ( *sortedMaster )[i] ); + for(i = 0; i < count; i++) { + mn = (MgrNode *)((*sortedMaster)[i]); cout << i << " " << mn->GetFileId() << endl; } } -InstMgr::InstMgr( int ownsInstances ) - : maxFileId( -1 ), _ownsInstances( ownsInstances ) { +InstMgr::InstMgr(int ownsInstances) + : maxFileId(-1), _ownsInstances(ownsInstances) +{ master = new MgrNodeArray(); sortedMaster = new std::map; } -InstMgr::~InstMgr() { - if( _ownsInstances ) { +InstMgr::~InstMgr() +{ + if(_ownsInstances) { master->DeleteEntries(); } else { master->ClearEntries(); @@ -67,13 +70,15 @@ InstMgr::~InstMgr() { /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ClearInstances() { +void InstMgr::ClearInstances() +{ master->ClearEntries(); sortedMaster->clear(); maxFileId = -1; } -void InstMgr::DeleteInstances() { +void InstMgr::DeleteInstances() +{ master->DeleteEntries(); sortedMaster->clear(); maxFileId = -1; @@ -92,13 +97,13 @@ void InstMgr::DeleteInstances() { **************************************************/ enum Severity -InstMgr::VerifyInstances( ErrorDescriptor & err ) { +InstMgr::VerifyInstances(ErrorDescriptor &err) { int errorCount = 0; char errbuf[BUFSIZ]; int n = InstanceCount(); - MgrNode * mn; - SDAI_Application_instance * se; + MgrNode *mn; + SDAI_Application_instance *se; enum Severity rval = SEVERITY_NULL; //for each instance on the list, @@ -111,52 +116,54 @@ InstMgr::VerifyInstances( ErrorDescriptor & err ) { // if it is not valid, then increment the error count // and set the rval to - for( int i = 0; i < n; ++i ) { - mn = GetMgrNode( i ); - if( !mn ) { + for(int i = 0; i < n; ++i) + { + mn = GetMgrNode(i); + if(!mn) { ++errorCount; - if( errorCount == 1 ) - sprintf( errbuf, - "VerifyInstances: Unable to verify the following instances: node %d", - i ); + if(errorCount == 1) + sprintf(errbuf, + "VerifyInstances: Unable to verify the following instances: node %d", + i); else { - sprintf( errbuf, ", node %d", i ); + sprintf(errbuf, ", node %d", i); } - err.AppendToDetailMsg( errbuf ); + err.AppendToDetailMsg(errbuf); rval = SEVERITY_INPUT_ERROR; - err.GreaterSeverity( SEVERITY_INPUT_ERROR ); + err.GreaterSeverity(SEVERITY_INPUT_ERROR); continue; } - if( debug_level > 3 ) + if(debug_level > 3) cerr << "In VerifyInstances: " << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if( !mn->MgrNodeListMember( completeSE ) ) { + if(!mn->MgrNodeListMember(completeSE)) { se = mn->GetApplication_instance(); - if( se->ValidLevel( &err, this, 0 ) < SEVERITY_USERMSG ) { - if( rval > SEVERITY_INCOMPLETE ) { + if(se->ValidLevel(&err, this, 0) < SEVERITY_USERMSG) { + if(rval > SEVERITY_INCOMPLETE) { rval = SEVERITY_INCOMPLETE; } ++errorCount; - if( errorCount == 1 ) - sprintf( errbuf, - "VerifyInstances: Unable to verify the following instances: #%d", - se->StepFileId() ); + if(errorCount == 1) + sprintf(errbuf, + "VerifyInstances: Unable to verify the following instances: #%d", + se->StepFileId()); else { - sprintf( errbuf, ", #%d", se->StepFileId() ); + sprintf(errbuf, ", #%d", se->StepFileId()); } - err.AppendToDetailMsg( errbuf ); + err.AppendToDetailMsg(errbuf); } } } - if( errorCount ) { - sprintf( errbuf, - "VerifyInstances: %d invalid instances in list.\n", - errorCount ); - err.AppendToUserMsg( errbuf ); - err.AppendToDetailMsg( ".\n" ); - err.GreaterSeverity( SEVERITY_INCOMPLETE ); + if(errorCount) + { + sprintf(errbuf, + "VerifyInstances: %d invalid instances in list.\n", + errorCount); + err.AppendToUserMsg(errbuf); + err.AppendToDetailMsg(".\n"); + err.GreaterSeverity(SEVERITY_INCOMPLETE); } return rval; @@ -164,27 +171,32 @@ InstMgr::VerifyInstances( ErrorDescriptor & err ) { /////////////////////////////////////////////////////////////////////////////// -MgrNode * InstMgr::FindFileId( int fileId ) { - std::map::iterator it; - it=sortedMaster->find(fileId); - if (it == sortedMaster->end()) return ( MgrNode * )0; - return it->second; +MgrNode *InstMgr::FindFileId(int fileId) +{ + std::map::iterator it; + it = sortedMaster->find(fileId); + if(it == sortedMaster->end()) { + return (MgrNode *)0; + } + return it->second; } /////////////////////////////////////////////////////////////////////////////// // get the index into display list given a SDAI_Application_instance // called by see initiated functions -int InstMgr::GetIndex( MgrNode * mn ) { +int InstMgr::GetIndex(MgrNode *mn) +{ return mn->ArrayIndex(); } /////////////////////////////////////////////////////////////////////////////// -int InstMgr::VerifyEntity( int fileId, const char * expectedType ) { - MgrNode * mn = FindFileId( fileId ); - if( mn ) { - if( !strcmp( expectedType, mn->GetApplication_instance()->EntityName() ) ) { +int InstMgr::VerifyEntity(int fileId, const char *expectedType) +{ + MgrNode *mn = FindFileId(fileId); + if(mn) { + if(!strcmp(expectedType, mn->GetApplication_instance()->EntityName())) { return 2; // types match } else { return 1; // possible mismatch depending on descendants @@ -198,39 +210,40 @@ int InstMgr::VerifyEntity( int fileId, const char * expectedType ) { // Append instance to the list of instances. Checks the file id and // sets it if 1) it is not set already or 2) it already exists in the list. -MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState ) { - if( debug_level > 3 ) { +MgrNode *InstMgr::Append(SDAI_Application_instance *se, stateEnum listState) +{ + if(debug_level > 3) { cout << "#" << se->StepFileId() << " append node to InstMgr" << endl; } - MgrNode * mn = 0; + MgrNode *mn = 0; - if( se->StepFileId() == 0 ) { // no id assigned - se->StepFileId( NextFileId() ); // assign a file id + if(se->StepFileId() == 0) { // no id assigned + se->StepFileId(NextFileId()); // assign a file id } - mn = FindFileId( se->StepFileId() ); - if( mn ) { // if id already in list + mn = FindFileId(se->StepFileId()); + if(mn) { // if id already in list // and it's because instance is already in list - if( GetApplication_instance( mn ) == se ) { + if(GetApplication_instance(mn) == se) { return 0; // return 0 or mn? } else { - se->StepFileId( NextFileId() ); // otherwise assign a new file id + se->StepFileId(NextFileId()); // otherwise assign a new file id } } // update the maxFileId if needed - if( se->StepFileId() > MaxFileId() ) { + if(se->StepFileId() > MaxFileId()) { maxFileId = se->StepFileId(); } - mn = new MgrNode( se, listState ); + mn = new MgrNode(se, listState); - if( debug_level > 3 ) + if(debug_level > 3) cerr << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if( listState == noStateSE ) + if(listState == noStateSE) cout << "append to InstMgr **ERROR ** node #" << se->StepFileId() << " doesn't have state information" << endl; - master->Append( mn ); + master->Append(mn); (*sortedMaster)[mn->GetFileId()] = mn; //PrintSortedFileIds(); return mn; @@ -238,53 +251,56 @@ MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState ) /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete( MgrNode * node ) { +void InstMgr::Delete(MgrNode *node) +{ // delete the node from its current state list node->Remove(); // remove the node from the sorted master array - sortedMaster->erase( node->GetFileId() ); + sortedMaster->erase(node->GetFileId()); // get the index into the master array by ptr arithmetic int index = node->ArrayIndex(); - master->Remove( index ); + master->Remove(index); delete node; } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete( SDAI_Application_instance * se ) { - Delete( FindFileId( se->StepFileId() ) ); +void InstMgr::Delete(SDAI_Application_instance *se) +{ + Delete(FindFileId(se->StepFileId())); } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ChangeState( MgrNode * node, stateEnum listState ) { - switch( listState ) { +void InstMgr::ChangeState(MgrNode *node, stateEnum listState) +{ + switch(listState) { case completeSE: - if( debug_level > 3 ) + if(debug_level > 3) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's complete list\n"; - node->ChangeState( listState ); + node->ChangeState(listState); break; case incompleteSE: - if( debug_level > 3 ) + if(debug_level > 3) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's incomplete list\n"; - node->ChangeState( listState ); + node->ChangeState(listState); break; case newSE: - if( debug_level > 3 ) + if(debug_level > 3) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's new list\n"; - node->ChangeState( listState ); + node->ChangeState(listState); break; case deleteSE: - if( debug_level > 3 ) + if(debug_level > 3) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's delete list\n"; - node->ChangeState( listState ); + node->ChangeState(listState); break; case noStateSE: cout << "#" << node->GetApplication_instance()->StepFileId() << @@ -303,16 +319,17 @@ void InstMgr::ChangeState( MgrNode * node, stateEnum listState ) { on the instance manager. **************************************************/ int -InstMgr::EntityKeywordCount( const char * name ) { +InstMgr::EntityKeywordCount(const char *name) +{ int count = 0; - MgrNode * node; - SDAI_Application_instance * se; + MgrNode *node; + SDAI_Application_instance *se; int n = InstanceCount(); - const char *pretty_name = PrettyTmpName( name ); - for( int j = 0; j < n; ++j ) { - node = GetMgrNode( j ); + const char *pretty_name = PrettyTmpName(name); + for(int j = 0; j < n; ++j) { + node = GetMgrNode(j); se = node->GetApplication_instance(); - if( !strcmp( se->EntityName(), pretty_name ) ) { + if(!strcmp(se->EntityName(), pretty_name)) { ++count; } } @@ -322,9 +339,10 @@ InstMgr::EntityKeywordCount( const char * name ) { /////////////////////////////////////////////////////////////////////////////// SDAI_Application_instance * -InstMgr::GetApplication_instance( int index ) { - MgrNode * mn = ( MgrNode * )( *master )[index]; - if( mn ) { +InstMgr::GetApplication_instance(int index) +{ + MgrNode *mn = (MgrNode *)(*master)[index]; + if(mn) { return mn->GetApplication_instance(); } else { return 0; @@ -332,9 +350,10 @@ InstMgr::GetApplication_instance( int index ) { } SDAI_Application_instance * -InstMgr::GetSTEPentity( int index ) { - MgrNode * mn = ( MgrNode * )( *master )[index]; - if( mn ) { +InstMgr::GetSTEPentity(int index) +{ + MgrNode *mn = (MgrNode *)(*master)[index]; + if(mn) { return mn->GetApplication_instance(); } else { return 0; @@ -354,16 +373,17 @@ InstMgr::GetSTEPentity( int index ) { starting_index. **************************************************/ SDAI_Application_instance * -InstMgr::GetApplication_instance( const char * entityKeyword, int starting_index ) { - MgrNode * node; - SDAI_Application_instance * se; - const char *pretty_name = PrettyTmpName( entityKeyword ); +InstMgr::GetApplication_instance(const char *entityKeyword, int starting_index) +{ + MgrNode *node; + SDAI_Application_instance *se; + const char *pretty_name = PrettyTmpName(entityKeyword); int count = InstanceCount(); - for( int j = starting_index; j < count; ++j ) { - node = GetMgrNode( j ); + for(int j = starting_index; j < count; ++j) { + node = GetMgrNode(j); se = node->GetApplication_instance(); - if( !strcmp( se->EntityName(), pretty_name ) ) { + if(!strcmp(se->EntityName(), pretty_name)) { return se; } } @@ -371,16 +391,17 @@ InstMgr::GetApplication_instance( const char * entityKeyword, int starting_index } SDAI_Application_instance * -InstMgr::GetSTEPentity( const char * entityKeyword, int starting_index ) { - MgrNode * node; - SDAI_Application_instance * se; - const char *pretty_name = PrettyTmpName( entityKeyword ); +InstMgr::GetSTEPentity(const char *entityKeyword, int starting_index) +{ + MgrNode *node; + SDAI_Application_instance *se; + const char *pretty_name = PrettyTmpName(entityKeyword); int count = InstanceCount(); - for( int j = starting_index; j < count; ++j ) { - node = GetMgrNode( j ); + for(int j = starting_index; j < count; ++j) { + node = GetMgrNode(j); se = node->GetApplication_instance(); - if( !strcmp( se->EntityName(), pretty_name ) ) { + if(!strcmp(se->EntityName(), pretty_name)) { return se; } } @@ -390,9 +411,10 @@ InstMgr::GetSTEPentity( const char * entityKeyword, int starting_index ) { /////////////////////////////////////////////////////////////////////////////// void * -InstMgr::GetSEE( int index ) { - MgrNode * mn = ( MgrNode * )( *master )[index]; - if( mn ) { +InstMgr::GetSEE(int index) +{ + MgrNode *mn = (MgrNode *)(*master)[index]; + if(mn) { return mn->SEE(); } else { return 0; diff --git a/src/clstepcore/instmgr.h b/src/clstepcore/instmgr.h index 3f185b3fb..0b8a8fa49 100644 --- a/src/clstepcore/instmgr.h +++ b/src/clstepcore/instmgr.h @@ -39,95 +39,107 @@ #include -class SC_CORE_EXPORT InstMgrBase { +class SC_CORE_EXPORT InstMgrBase +{ public: - virtual MgrNodeBase * FindFileId( int fileId ) = 0; + virtual MgrNodeBase *FindFileId(int fileId) = 0; virtual ~InstMgrBase() {}; }; -class SC_CORE_EXPORT InstMgr : public InstMgrBase { +class SC_CORE_EXPORT InstMgr : public InstMgrBase +{ protected: int maxFileId; int _ownsInstances; // if true will delete instances inside destructor - MgrNodeArray * master; // master array of all MgrNodes made up of + 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 - std::map *sortedMaster; // master array sorted by fileId + std::map *sortedMaster; // master array sorted by fileId // StateList *master; // this will be an sorted array of ptrs to MgrNodes public: - InstMgr( int ownsInstances = 0 ); + InstMgr(int ownsInstances = 0); virtual ~InstMgr(); // MASTER LIST OPERATIONS - int InstanceCount() const { + int InstanceCount() const + { return master->Count(); } - int OwnsInstances() const { + int OwnsInstances() const + { return _ownsInstances; } - void OwnsInstances( int ownsInstances ) { + void OwnsInstances(int ownsInstances) + { _ownsInstances = ownsInstances; } void ClearInstances(); //clears instance lists but doesn't delete instances void DeleteInstances(); // deletes the instances (ignores _ownsInstances) - Severity VerifyInstances( ErrorDescriptor & e ); + Severity VerifyInstances(ErrorDescriptor &e); // DAS PORT possible BUG two funct's below may create a temp for the cast - MgrNode * GetMgrNode( int index ) { - return ( MgrNode * ) * GetGenNode( index ); + MgrNode *GetMgrNode(int index) + { + return (MgrNode *) * GetGenNode(index); } - GenericNode ** GetGenNode( int index ) { - return &( *master ) [index]; + GenericNode **GetGenNode(int index) + { + return &(*master) [index]; } - MgrNode * FindFileId( int fileId ); + MgrNode *FindFileId(int fileId); // get the index into display list given a SDAI_Application_instance // called by see initiated functions - int GetIndex( SDAI_Application_instance * se ); - int GetIndex( MgrNode * mn ); - int VerifyEntity( int fileId, const char * expectedType ); + int GetIndex(SDAI_Application_instance *se); + int GetIndex(MgrNode *mn); + int VerifyEntity(int fileId, const char *expectedType); // void Append(MgrNode *node); - MgrNode * Append( SDAI_Application_instance * se, stateEnum listState ); + MgrNode *Append(SDAI_Application_instance *se, stateEnum listState); // deletes node from master list structure - void Delete( MgrNode * node ); - void Delete( SDAI_Application_instance * se ); + void Delete(MgrNode *node); + void Delete(SDAI_Application_instance *se); - void ChangeState( MgrNode * node, stateEnum listState ); + void ChangeState(MgrNode *node, stateEnum listState); - int MaxFileId() { + int MaxFileId() + { return maxFileId; } - int NextFileId() { + int NextFileId() + { return maxFileId = maxFileId + 1; } - int EntityKeywordCount( const char * name ); + int EntityKeywordCount(const char *name); - SDAI_Application_instance * GetApplication_instance( int index ); + SDAI_Application_instance *GetApplication_instance(int index); SDAI_Application_instance * - GetApplication_instance( const char * entityKeyword, - int starting_index = 0 ); - SDAI_Application_instance * GetApplication_instance( MgrNode * node ) { + GetApplication_instance(const char *entityKeyword, + int starting_index = 0); + SDAI_Application_instance *GetApplication_instance(MgrNode *node) + { return node->GetApplication_instance(); } - void * GetSEE( int index ); - void * GetSEE( MgrNode * node ) { + void *GetSEE(int index); + void *GetSEE(MgrNode *node) + { return node->SEE(); } void PrintSortedFileIds(); // OBSOLETE - SDAI_Application_instance * GetSTEPentity( int index ); - SDAI_Application_instance * GetSTEPentity( const char * entityKeyword, - int starting_index = 0 ); - SDAI_Application_instance * GetSTEPentity( MgrNode * node ) { + SDAI_Application_instance *GetSTEPentity(int index); + SDAI_Application_instance *GetSTEPentity(const char *entityKeyword, + int starting_index = 0); + SDAI_Application_instance *GetSTEPentity(MgrNode *node) + { return node->GetApplication_instance(); } diff --git a/src/clstepcore/interfaceSpec.cc b/src/clstepcore/interfaceSpec.cc index eb0fecf3a..a8bf4ae2c 100644 --- a/src/clstepcore/interfaceSpec.cc +++ b/src/clstepcore/interfaceSpec.cc @@ -1,107 +1,119 @@ #include "interfaceSpec.h" -Interface_spec__set::Interface_spec__set( int defaultSize ) { +Interface_spec__set::Interface_spec__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Interface_spec_ptr[_bufsize]; _count = 0; } -Interface_spec__set::~Interface_spec__set() { +Interface_spec__set::~Interface_spec__set() +{ delete[] _buf; } -void Interface_spec__set::Check( int index ) { - Interface_spec_ptr * newbuf; +void Interface_spec__set::Check(int index) +{ + Interface_spec_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Interface_spec_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Interface_spec_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Interface_spec_ptr)); delete[] _buf; _buf = newbuf; } } -void Interface_spec__set::Insert( Interface_spec_ptr v, int index ) { - Interface_spec_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Interface_spec__set::Insert(Interface_spec_ptr v, int index) +{ + Interface_spec_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Append( Interface_spec_ptr v ) { +void Interface_spec__set::Append(Interface_spec_ptr v) +{ int index = _count; - Interface_spec_ptr * spot; + Interface_spec_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Interface_spec__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Interface_spec_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Interface_spec_ptr ) ); + Interface_spec_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Interface_spec_ptr)); } } -int Interface_spec__set::Index( Interface_spec_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Interface_spec__set::Index(Interface_spec_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Interface_spec_ptr & Interface_spec__set::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Interface_spec_ptr &Interface_spec__set::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Interface_spec__set::Count() { +int Interface_spec__set::Count() +{ return _count; } -void Interface_spec__set::Clear() { +void Interface_spec__set::Clear() +{ _count = 0; } /////////////////////////////////////////////////////////////////////////////// Interface_spec::Interface_spec() -: _explicit_items( new Explicit_item_id__set ), -_implicit_items( 0 ), _all_objects( 0 ) { + : _explicit_items(new Explicit_item_id__set), + _implicit_items(0), _all_objects(0) +{ } /// not tested -Interface_spec::Interface_spec( Interface_spec & is ): Dictionary_instance() { +Interface_spec::Interface_spec(Interface_spec &is): Dictionary_instance() +{ _explicit_items = new Explicit_item_id__set; int count = is._explicit_items->Count(); int i; - for( i = 0; i < count; i++ ) { - ( *_explicit_items )[i] = - ( *( is._explicit_items ) )[i]; + for(i = 0; i < count; i++) { + (*_explicit_items)[i] = + (*(is._explicit_items))[i]; } _current_schema_id = is._current_schema_id; _foreign_schema_id = is._foreign_schema_id; @@ -109,14 +121,16 @@ Interface_spec::Interface_spec( Interface_spec & is ): Dictionary_instance() { _implicit_items = 0; } -Interface_spec::Interface_spec( const char * cur_sch_id, - const char * foreign_sch_id, int all_objects ) -: _current_schema_id( cur_sch_id ), _explicit_items( new Explicit_item_id__set ), -_implicit_items( 0 ), _foreign_schema_id( foreign_sch_id ), -_all_objects( all_objects ) { +Interface_spec::Interface_spec(const char *cur_sch_id, + const char *foreign_sch_id, int all_objects) + : _current_schema_id(cur_sch_id), _explicit_items(new Explicit_item_id__set), + _implicit_items(0), _foreign_schema_id(foreign_sch_id), + _all_objects(all_objects) +{ } -Interface_spec::~Interface_spec() { +Interface_spec::~Interface_spec() +{ delete _explicit_items; delete _implicit_items; } diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index 8469a555d..8ae4b4b27 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -7,93 +7,103 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interface_spec : public Dictionary_instance { -public: +class SC_CORE_EXPORT Interface_spec : public Dictionary_instance +{ + public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _current_schema_id; // schema containing the USE/REF stmt - - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list). - // schema that defined the USE/REFd objects - Express_id _foreign_schema_id; + Express_id _current_schema_id; // schema containing the USE/REF stmt + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list). + // schema that defined the USE/REFd objects + Express_id _foreign_schema_id; #ifdef _MSC_VER #pragma warning( pop ) #endif - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema - - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list of ints). - // schema USEs or REFERENCEs all objects from foreign schema - int _all_objects; - - Interface_spec(); - Interface_spec( Interface_spec & ); // not tested - Interface_spec( const char * cur_sch_id, const char * foreign_sch_id, - int all_objects = 0 ); - virtual ~Interface_spec(); - - Express_id current_schema_id_() { - return _current_schema_id; - } - Express_id foreign_schema_id_() { - return _foreign_schema_id; - } - - Explicit_item_id__set_var explicit_items_() { - return _explicit_items; - } - - // this is not yet initialized for the schema - Implicit_item_id__set_var implicit_items_() { - return _implicit_items; - } - - // private: - void current_schema_id_( const Express_id & ei ) { - _current_schema_id = ei; - } - void foreign_schema_id_( const Express_id & fi ) { - _foreign_schema_id = fi; - } - - int all_objects_() { - return _all_objects; - } - void all_objects_( int ao ) { - _all_objects = ao; - } + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list of ints). + // schema USEs or REFERENCEs all objects from foreign schema + int _all_objects; + + Interface_spec(); + Interface_spec(Interface_spec &); // not tested + Interface_spec(const char *cur_sch_id, const char *foreign_sch_id, + int all_objects = 0); + virtual ~Interface_spec(); + + Express_id current_schema_id_() + { + return _current_schema_id; + } + Express_id foreign_schema_id_() + { + return _foreign_schema_id; + } + + Explicit_item_id__set_var explicit_items_() + { + return _explicit_items; + } + + // this is not yet initialized for the schema + Implicit_item_id__set_var implicit_items_() + { + return _implicit_items; + } + + // private: + void current_schema_id_(const Express_id &ei) + { + _current_schema_id = ei; + } + void foreign_schema_id_(const Express_id &fi) + { + _foreign_schema_id = fi; + } + + int all_objects_() + { + return _all_objects; + } + void all_objects_(int ao) + { + _all_objects = ao; + } }; -typedef Interface_spec * Interface_spec_ptr; - -class SC_CORE_EXPORT Interface_spec__set { -public: - Interface_spec__set( int = 16 ); - ~Interface_spec__set(); - - Interface_spec_ptr & operator[]( int index ); - void Insert( Interface_spec_ptr, int index ); - void Append( Interface_spec_ptr ); - void Remove( int index ); - int Index( Interface_spec_ptr ); - - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Interface_spec_ptr * _buf; - int _bufsize; - int _count; +typedef Interface_spec *Interface_spec_ptr; + +class SC_CORE_EXPORT Interface_spec__set +{ + public: + Interface_spec__set(int = 16); + ~Interface_spec__set(); + + Interface_spec_ptr &operator[](int index); + void Insert(Interface_spec_ptr, int index); + void Append(Interface_spec_ptr); + void Remove(int index); + int Index(Interface_spec_ptr); + + int Count(); + void Clear(); + private: + void Check(int index); + private: + Interface_spec_ptr *_buf; + int _bufsize; + int _count; }; -typedef Interface_spec__set * Interface_spec__set_ptr; +typedef Interface_spec__set *Interface_spec__set_ptr; typedef Interface_spec__set_ptr Interface_spec__set_var; diff --git a/src/clstepcore/interfacedItem.cc b/src/clstepcore/interfacedItem.cc index 749a5922e..fe3a67fdf 100644 --- a/src/clstepcore/interfacedItem.cc +++ b/src/clstepcore/interfacedItem.cc @@ -1,24 +1,30 @@ #include "interfacedItem.h" -Interfaced_item::Interfaced_item() { +Interfaced_item::Interfaced_item() +{ } -Interfaced_item::Interfaced_item( const Interfaced_item & ii ): Dictionary_instance() { +Interfaced_item::Interfaced_item(const Interfaced_item &ii): Dictionary_instance() +{ _foreign_schema = ii._foreign_schema; } -Interfaced_item::Interfaced_item( const char * foreign_schema ) -: _foreign_schema( foreign_schema ) { +Interfaced_item::Interfaced_item(const char *foreign_schema) + : _foreign_schema(foreign_schema) +{ } -Interfaced_item::~Interfaced_item() { +Interfaced_item::~Interfaced_item() +{ } -const Express_id Interfaced_item::foreign_schema_() { +const Express_id Interfaced_item::foreign_schema_() +{ return _foreign_schema; } -void Interfaced_item::foreign_schema_( const Express_id & fs ) { +void Interfaced_item::foreign_schema_(const Express_id &fs) +{ _foreign_schema = fs; } diff --git a/src/clstepcore/interfacedItem.h b/src/clstepcore/interfacedItem.h index 00401b68b..78b74c1fa 100644 --- a/src/clstepcore/interfacedItem.h +++ b/src/clstepcore/interfacedItem.h @@ -7,25 +7,26 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance { -protected: - Interfaced_item(); - Interfaced_item( const Interfaced_item & ); - Interfaced_item( const char * foreign_schema ); - virtual ~Interfaced_item(); -public: +class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance +{ + protected: + Interfaced_item(); + Interfaced_item(const Interfaced_item &); + Interfaced_item(const char *foreign_schema); + virtual ~Interfaced_item(); + public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _foreign_schema; + Express_id _foreign_schema; #ifdef _MSC_VER #pragma warning( pop ) #endif - const Express_id foreign_schema_(); - // private: - void foreign_schema_( const Express_id & ); + const Express_id foreign_schema_(); + // private: + void foreign_schema_(const Express_id &); }; #endif //INTERFACEDITEM_H diff --git a/src/clstepcore/inverseAttribute.cc b/src/clstepcore/inverseAttribute.cc index eeccec90a..13ae8721a 100644 --- a/src/clstepcore/inverseAttribute.cc +++ b/src/clstepcore/inverseAttribute.cc @@ -1,19 +1,20 @@ #include "inverseAttribute.h" #include -const char * Inverse_attribute::AttrExprDefStr( std::string & s ) const { +const char *Inverse_attribute::AttrExprDefStr(std::string &s) const +{ std::string buf; s = Name(); - s.append( " : " ); - if( _optional.asInt() == LTrue ) { - s.append( "OPTIONAL " ); + s.append(" : "); + if(_optional.asInt() == LTrue) { + s.append("OPTIONAL "); } - if( DomainType() ) { - DomainType()->AttrTypeName( buf ); - s.append( buf ); + if(DomainType()) { + DomainType()->AttrTypeName(buf); + s.append(buf); } - s.append( " FOR " ); - s.append( _inverted_attr_id ); - return const_cast( s.c_str() ); + s.append(" FOR "); + s.append(_inverted_attr_id); + return const_cast(s.c_str()); } diff --git a/src/clstepcore/inverseAttribute.h b/src/clstepcore/inverseAttribute.h index 0d02b793d..3032cac15 100644 --- a/src/clstepcore/inverseAttribute.h +++ b/src/clstepcore/inverseAttribute.h @@ -3,54 +3,61 @@ #include "attrDescriptor.h" -class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor { +class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor +{ public: - const char * _inverted_attr_id; - const char * _inverted_entity_id; + const char *_inverted_attr_id; + const char *_inverted_entity_id; protected: - const AttrDescriptor * _inverted_attr; // not implemented (?!) (perhaps this means "not used"?) + const AttrDescriptor *_inverted_attr; // not implemented (?!) (perhaps this means "not used"?) public: Inverse_attribute( - const char * name, // i.e. char * - TypeDescriptor * domainType, + const char *name, // i.e. char * + TypeDescriptor *domainType, Logical optional, // i.e. F U or T*/ Logical unique, // i.e. F U or T - const EntityDescriptor & owner, - const char * inverted_attr_id = 0 - ) : AttrDescriptor( name, domainType, optional, unique, - AttrType_Inverse, owner ), - _inverted_attr_id( inverted_attr_id ), - _inverted_entity_id( 0 ), _inverted_attr( 0 ) + const EntityDescriptor &owner, + const char *inverted_attr_id = 0 + ) : AttrDescriptor(name, domainType, optional, unique, + AttrType_Inverse, owner), + _inverted_attr_id(inverted_attr_id), + _inverted_entity_id(0), _inverted_attr(0) { } virtual ~Inverse_attribute() { } - const char * AttrExprDefStr( std::string & s ) const; + const char *AttrExprDefStr(std::string &s) const; - const char * inverted_attr_id_() const { + const char *inverted_attr_id_() const + { return _inverted_attr_id; } - void inverted_attr_id_( const char * iai ) { + void inverted_attr_id_(const char *iai) + { _inverted_attr_id = iai; } - const char * inverted_entity_id_() const { + const char *inverted_entity_id_() const + { return _inverted_entity_id; } - void inverted_entity_id_( const char * iei ) { + void inverted_entity_id_(const char *iei) + { _inverted_entity_id = iei; } /// 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 { + const class AttrDescriptor *inverted_attr_() const + { return _inverted_attr; } - void inverted_attr_( const AttrDescriptor * ia ) { + void inverted_attr_(const AttrDescriptor *ia) + { _inverted_attr = ia; } diff --git a/src/clstepcore/inverseAttributeList.cc b/src/clstepcore/inverseAttributeList.cc index 22591d41c..96207adf2 100644 --- a/src/clstepcore/inverseAttributeList.cc +++ b/src/clstepcore/inverseAttributeList.cc @@ -1,45 +1,53 @@ #include "inverseAttributeList.h" #include "inverseAttribute.h" -Inverse_attributeLinkNode::Inverse_attributeLinkNode() { +Inverse_attributeLinkNode::Inverse_attributeLinkNode() +{ _invAttr = 0; } -Inverse_attributeLinkNode::~Inverse_attributeLinkNode() { +Inverse_attributeLinkNode::~Inverse_attributeLinkNode() +{ } -Inverse_attributeList::Inverse_attributeList() { +Inverse_attributeList::Inverse_attributeList() +{ } -Inverse_attributeList::~Inverse_attributeList() { - Inverse_attributeLinkNode * node; +Inverse_attributeList::~Inverse_attributeList() +{ + Inverse_attributeLinkNode *node; - node = ( Inverse_attributeLinkNode * ) head; - while( node ) { + node = (Inverse_attributeLinkNode *) head; + while(node) { delete node->Inverse_attr(); - node = ( Inverse_attributeLinkNode * ) node->NextNode(); + node = (Inverse_attributeLinkNode *) node->NextNode(); } } -Inverse_attributeLinkNode * Inverse_attributeList::AddNode( Inverse_attribute * ad ) { - Inverse_attributeLinkNode * node = ( Inverse_attributeLinkNode * ) NewNode(); - node->Inverse_attr( ad ); - SingleLinkList::AppendNode( node ); +Inverse_attributeLinkNode *Inverse_attributeList::AddNode(Inverse_attribute *ad) +{ + Inverse_attributeLinkNode *node = (Inverse_attributeLinkNode *) NewNode(); + node->Inverse_attr(ad); + SingleLinkList::AppendNode(node); return node; } -InverseAItr::InverseAItr( const Inverse_attributeList * iaList ) - : ial( iaList ) { - cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); +InverseAItr::InverseAItr(const Inverse_attributeList *iaList) + : ial(iaList) +{ + cur = (Inverse_attributeLinkNode *)(ial->GetHead()); } -InverseAItr::~InverseAItr() { +InverseAItr::~InverseAItr() +{ } -Inverse_attribute * InverseAItr::NextInverse_attribute() { - if( cur ) { - Inverse_attribute * ia = cur->Inverse_attr(); - cur = ( Inverse_attributeLinkNode * )( cur->NextNode() ); +Inverse_attribute *InverseAItr::NextInverse_attribute() +{ + if(cur) { + Inverse_attribute *ia = cur->Inverse_attr(); + cur = (Inverse_attributeLinkNode *)(cur->NextNode()); return ia; } return 0; diff --git a/src/clstepcore/inverseAttributeList.h b/src/clstepcore/inverseAttributeList.h index e7dc8a7d6..1bacf6f95 100644 --- a/src/clstepcore/inverseAttributeList.h +++ b/src/clstepcore/inverseAttributeList.h @@ -6,51 +6,58 @@ #include "SingleLinkList.h" class Inverse_attribute; -class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode { +class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode +{ private: protected: - Inverse_attribute * _invAttr; + Inverse_attribute *_invAttr; public: Inverse_attributeLinkNode(); virtual ~Inverse_attributeLinkNode(); - Inverse_attribute * Inverse_attr() const { + Inverse_attribute *Inverse_attr() const + { return _invAttr; } - void Inverse_attr( Inverse_attribute * ia ) { + void Inverse_attr(Inverse_attribute *ia) + { _invAttr = ia; } }; -class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList { +class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList +{ private: protected: - virtual SingleLinkNode * NewNode() { + virtual SingleLinkNode *NewNode() + { return new Inverse_attributeLinkNode; } public: Inverse_attributeList(); virtual ~Inverse_attributeList(); - Inverse_attributeLinkNode * AddNode( Inverse_attribute * ia ); + Inverse_attributeLinkNode *AddNode(Inverse_attribute *ia); }; -class SC_CORE_EXPORT InverseAItr { +class SC_CORE_EXPORT InverseAItr +{ protected: - const Inverse_attributeList * ial; - const Inverse_attributeLinkNode * cur; + const Inverse_attributeList *ial; + const Inverse_attributeLinkNode *cur; public: - InverseAItr( const Inverse_attributeList * iaList ); + InverseAItr(const Inverse_attributeList *iaList); virtual ~InverseAItr(); - void ResetItr( const Inverse_attributeList * iaList = 0 ) { - if( iaList ) { + void ResetItr(const Inverse_attributeList *iaList = 0) + { + if(iaList) { ial = iaList; } - cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); + cur = (Inverse_attributeLinkNode *)(ial->GetHead()); } - Inverse_attribute * NextInverse_attribute(); + Inverse_attribute *NextInverse_attribute(); }; #endif //INVERSEATTRIBUTELIST_H diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index 5f17f7d93..ec33b65db 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -25,24 +25,25 @@ * OR descendants we didn't test. Thus, UNKNOWN tells us that this child * is an OR, or has an OR somewhere beneath it which we must process now. */ -MatchType AndOrList::matchORs( EntNode * ents ) { - EntList * child = childList->firstWanted( UNKNOWN ); +MatchType AndOrList::matchORs(EntNode *ents) +{ + EntList *child = childList->firstWanted(UNKNOWN); - while( child != NULL ) { - if( ( dynamic_cast< MultList * >(child))->matchORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll( ents ); + child->unmarkAll(ents); } - child = child->nextWanted( UNKNOWN ); + child = child->nextWanted(UNKNOWN); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal( ents ); + setViableVal(ents); return viable; } @@ -52,23 +53,24 @@ MatchType AndOrList::matchORs( EntNode * ents ) { * descendants match the nodes of ents. We only take UNKNOWN's because * they will lead us to OR's, as explained in AndOrList::matchORs(). */ -MatchType AndList::matchORs( EntNode * ents ) { - EntList * child = childList->firstWanted( UNKNOWN ); +MatchType AndList::matchORs(EntNode *ents) +{ + EntList *child = childList->firstWanted(UNKNOWN); - while( child != NULL ) { - if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted( UNKNOWN ); + child = child->nextWanted(UNKNOWN); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal( ents ); + setViableVal(ents); return viable; } @@ -80,43 +82,44 @@ MatchType AndList::matchORs( EntNode * ents ) { * retain the info that these were only conditionally marked. Also, if a * MATCHALL solution was found, that is returned immediately. */ -MatchType OrList::matchORs( EntNode * ents ) { +MatchType OrList::matchORs(EntNode *ents) +{ int count; - EntList * child = childList; + EntList *child = childList; MatchType retval = UNKNOWN; - for( count = 0; count < numchildren; count++, child = child->next ) { + for(count = 0; count < numchildren; count++, child = child->next) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if( child->join != OR ) { - retval = child->matchNonORs( ents ); + if(child->join != OR) { + retval = child->matchNonORs(ents); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if( child->viable == UNKNOWN ) { + if(child->viable == UNKNOWN) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); + retval = (dynamic_cast< MultList * >(child))->matchORs(ents); } // Now register the result: - if( retval >= MATCHSOME ) { + if(retval >= MATCHSOME) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if( choice == -1 ) { + if(choice == -1) { choice1 = choice = count; } choiceCount++; - if( viable < retval ) { + if(viable < retval) { viable = retval; } } else { @@ -128,17 +131,17 @@ MatchType OrList::matchORs( EntNode * ents ) { // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if( viable < retval ) { + if(viable < retval) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll( ents ); + child->unmarkAll(ents); } // Accept the first viable solution, if there is one: - if( viable >= MATCHSOME ) { + if(viable >= MATCHSOME) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -147,10 +150,10 @@ MatchType OrList::matchORs( EntNode * ents ) { // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice( ents ); + acceptChoice(ents); } - if( viable == MATCHALL ) { - return getChild( choice1 )->viable; + if(viable == MATCHALL) { + return getChild(choice1)->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 8e44443ee..9abde8d0b 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -24,15 +24,18 @@ #include #include "sc_memmgr.h" -void * MgrNode::SEE() { - return ( di ? di->SEE() : 0 ); +void *MgrNode::SEE() +{ + return (di ? di->SEE() : 0); } -int MgrNode::GetFileId() { - return ( se ? se->GetFileId() : -1 ); +int MgrNode::GetFileId() +{ + return (se ? se->GetFileId() : -1); } -void MgrNode::Remove() { +void MgrNode::Remove() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Remove()\n"; // if(debug_level >= PrintValues) @@ -42,34 +45,36 @@ void MgrNode::Remove() { } // searches current list for fileId -MgrNode * MgrNode::StateFindFileId( int fileId ) { +MgrNode *MgrNode::StateFindFileId(int fileId) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::StateFindFileId()\n"; - MgrNode * startNode = this; - if( startNode->GetFileId() == fileId ) { + MgrNode *startNode = this; + if(startNode->GetFileId() == fileId) { return this; } else { // mn is really a MgrNode - MgrNode * mn = ( MgrNode * )( startNode->Next() ); - while( mn != startNode ) { - if( mn->GetFileId() == fileId ) { - return ( MgrNode * )mn; + MgrNode *mn = (MgrNode *)(startNode->Next()); + while(mn != startNode) { + if(mn->GetFileId() == fileId) { + return (MgrNode *)mn; } - mn = ( ( MgrNode * )mn->Next() ); + mn = ((MgrNode *)mn->Next()); } - return ( MgrNode * )0; + return (MgrNode *)0; } } -MgrNode::~MgrNode() { +MgrNode::~MgrNode() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::~MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - if( se ) { + if(se) { delete se; } - if( di ) { + if(di) { delete di; } // GenericNode::Remove(); // this is called by default. @@ -77,23 +82,26 @@ MgrNode::~MgrNode() { ///////////////////// class MgrNode Display Functions ///////////////////////// -displayStateEnum MgrNode::DisplayState() { +displayStateEnum MgrNode::DisplayState() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::DisplayState()\n"; - return ( di ? di->DisplayState() : noMapState ); + return (di ? di->DisplayState() : noMapState); } -int MgrNode::IsDisplayState( displayStateEnum ds ) { +int MgrNode::IsDisplayState(displayStateEnum ds) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::IsDisplayState()\n"; - return ( di ? di->DisplayListMember( ds ) : 0 ); + return (di ? di->DisplayListMember(ds) : 0); } -GenericNode * MgrNode::NextDisplay() { +GenericNode *MgrNode::NextDisplay() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::NextDisplay()\n"; // return (di ? ((DisplayNode *)di->Next()) : (DisplayNode *)0); - if( di ) { + if(di) { // GenericNode *dn = di->Next(); // return (DisplayNode *)dn; // return (DisplayNode *)(di->Next()); @@ -103,11 +111,12 @@ GenericNode * MgrNode::NextDisplay() { } } -GenericNode * MgrNode::PrevDisplay() { +GenericNode *MgrNode::PrevDisplay() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::PrevDisplay()\n"; // return (di ? ((DisplayNode *)di->Prev()) : 0); - if( di ) { + if(di) { return di->Prev(); } else { return 0; @@ -117,30 +126,34 @@ GenericNode * MgrNode::PrevDisplay() { // STATE LIST OPERATIONS // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList( DisplayNodeList * cmdList ) { - if( !di ) { - di = new class DisplayNode( this ); +int MgrNode::ChangeList(DisplayNodeList *cmdList) +{ + if(!di) { + di = new class DisplayNode(this); } - return di->ChangeList( cmdList ); + return di->ChangeList(cmdList); } // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList( MgrNodeList * cmdList ) { +int MgrNode::ChangeList(MgrNodeList *cmdList) +{ Remove(); - cmdList->Append( this ); + cmdList->Append(this); return 1; } -int MgrNode::ChangeState( displayStateEnum s ) { +int MgrNode::ChangeState(displayStateEnum s) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; - if( di ) { - return di->ChangeState( s ); + if(di) { + return di->ChangeState(s); } return 0; } -int MgrNode::ChangeState( stateEnum s ) { +int MgrNode::ChangeState(stateEnum s) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; currState = s; @@ -148,57 +161,62 @@ int MgrNode::ChangeState( stateEnum s ) { return 1; } -void MgrNode::Init( SDAI_Application_instance * s, - stateEnum listState, - MgrNodeList * list ) { +void MgrNode::Init(SDAI_Application_instance *s, + stateEnum listState, + MgrNodeList *list) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Init()\n"; se = s; arrayIndex = -1; di = 0; currState = listState; - if( list ) { - list->Append( this ); + if(list) { + list->Append(this); } } // used for sentinel node on lists of MgrNodes -MgrNode::MgrNode() { +MgrNode::MgrNode() +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init( 0, noStateSE, 0 ); + Init(0, noStateSE, 0); } -MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr ) { +MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init( StepEntPtr, noStateSE, 0 ); + Init(StepEntPtr, noStateSE, 0); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState ) { +MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init( StepEntPtr, listState, 0 ); + Init(StepEntPtr, listState, 0); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState, MgrNodeList * list ) { +MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState, MgrNodeList *list) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init( StepEntPtr, listState, list ); + Init(StepEntPtr, listState, list); } diff --git a/src/clstepcore/mgrnode.h b/src/clstepcore/mgrnode.h index 435b6aa70..f230877ed 100644 --- a/src/clstepcore/mgrnode.h +++ b/src/clstepcore/mgrnode.h @@ -29,13 +29,15 @@ class DisplayNode; class InstMgr; -class SC_CORE_EXPORT MgrNodeBase : public GenericNode { +class SC_CORE_EXPORT MgrNodeBase : public GenericNode +{ public: - virtual inline SDAI_Application_instance * GetSTEPentity() { + virtual inline SDAI_Application_instance *GetSTEPentity() + { abort(); return nullptr; }; - virtual ~MgrNodeBase() {}; + virtual ~MgrNodeBase() {}; }; ////////////////////////////////////////////////////////////////////////////// @@ -44,7 +46,8 @@ class SC_CORE_EXPORT MgrNodeBase : public GenericNode { // the DisplayNode, and removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNode : public MgrNodeBase { +class SC_CORE_EXPORT MgrNode : public MgrNodeBase +{ friend class GenNodeList; friend class MgrNodeList; friend class InstMgr; @@ -57,93 +60,100 @@ class SC_CORE_EXPORT MgrNode : public MgrNodeBase { stateEnum currState; // SDAI_Application_instance this node is representing info for - SDAI_Application_instance * se; + SDAI_Application_instance *se; // this is the index (in the InstMgr master array) of the ptr to // this node. int arrayIndex; // display info (SEE, etc) for this node - DisplayNode * di; + DisplayNode *di; public: // used for sentinel node on lists of MgrNodes MgrNode(); - MgrNode( SDAI_Application_instance * se ); + MgrNode(SDAI_Application_instance *se); // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) - MgrNode( SDAI_Application_instance * se, stateEnum listState ); - MgrNode( SDAI_Application_instance * se, stateEnum listState, MgrNodeList * list ); + MgrNode(SDAI_Application_instance *se, stateEnum listState); + MgrNode(SDAI_Application_instance *se, stateEnum listState, MgrNodeList *list); virtual ~MgrNode(); // STATE LIST OPERATIONS - int MgrNodeListMember( stateEnum s ) { - return ( currState == s ); + int MgrNodeListMember(stateEnum s) + { + return (currState == s); } - stateEnum CurrState() { + stateEnum CurrState() + { return currState; } // returns next or prev member variables // i.e. next or previous node on curr state list // searches current list for fileId - MgrNode * StateFindFileId( int fileId ); + MgrNode *StateFindFileId(int fileId); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList( MgrNodeList * cmdList ); - int ChangeState( stateEnum s ); + int ChangeList(MgrNodeList *cmdList); + int ChangeState(stateEnum s); // Removes from current list. // Called before adding to diff list or when destructor is called. void Remove(); // DISPLAY LIST OPERATIONS - void * SEE(); + void *SEE(); displayStateEnum DisplayState(); - int IsDisplayState( displayStateEnum ds ); + int IsDisplayState(displayStateEnum ds); // returns next or prev member variables // i.e. next or previous node on display state list - GenericNode * NextDisplay(); - GenericNode * PrevDisplay(); + GenericNode *NextDisplay(); + GenericNode *PrevDisplay(); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList( DisplayNodeList * cmdList ); + int ChangeList(DisplayNodeList *cmdList); // deletes from previous display list, assigns ds to // displayState & puts on list dsList - int ChangeState( displayStateEnum ds ); + int ChangeState(displayStateEnum ds); // might not want these three? since it won't actually map them? - void MapModifiable( DisplayNodeList * dnList ); - void MapViewable( DisplayNodeList * dnList ); - void UnMap( DisplayNodeList * dnList ); + void MapModifiable(DisplayNodeList *dnList); + void MapViewable(DisplayNodeList *dnList); + void UnMap(DisplayNodeList *dnList); // ACCESS FUNCTIONS int GetFileId(); - SDAI_Application_instance * GetApplication_instance() { + SDAI_Application_instance *GetApplication_instance() + { return se; } - DisplayNode *& displayNode() { + DisplayNode *&displayNode() + { return di; } - int ArrayIndex() { + int ArrayIndex() + { return arrayIndex; } - void ArrayIndex( int index ) { + void ArrayIndex(int index) + { arrayIndex = index; } // OBSOLETE - SDAI_Application_instance * GetSTEPentity() { + SDAI_Application_instance *GetSTEPentity() + { return se; } protected: private: - void Init( SDAI_Application_instance * s, stateEnum listState, MgrNodeList * list ); + void Init(SDAI_Application_instance *s, stateEnum listState, MgrNodeList *list); }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 23069f02b..87ef68c1b 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -43,18 +43,21 @@ static int PrintFunctionTrace = 2; // class MgrNodeArray member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArray::MgrNodeArray( int defaultSize ) - : GenNodeArray( defaultSize ) { +MgrNodeArray::MgrNodeArray(int defaultSize) + : GenNodeArray(defaultSize) +{ } -void MgrNodeArray::AssignIndexAddress( int index ) { +void MgrNodeArray::AssignIndexAddress(int index) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArray::AssignIndexAddress()\n"; - ( ( MgrNode * )_buf[index] )->ArrayIndex( index ); + ((MgrNode *)_buf[index])->ArrayIndex(index); } -MgrNodeArray::~MgrNodeArray() { - if( debug_level >= PrintFunctionTrace ) { +MgrNodeArray::~MgrNodeArray() +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::~MgrNodeArray()\n"; } DeleteEntries(); @@ -62,12 +65,13 @@ MgrNodeArray::~MgrNodeArray() { /*****************************************************************************/ -void MgrNodeArray::ClearEntries() { - if( debug_level >= PrintFunctionTrace ) { +void MgrNodeArray::ClearEntries() +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::ClearEntries()\n"; } int i; - for( i = 0 ; i < _count; i++ ) { + for(i = 0 ; i < _count; i++) { _buf[i] = 0; } _count = 0; @@ -75,55 +79,59 @@ void MgrNodeArray::ClearEntries() { /*****************************************************************************/ -void MgrNodeArray::DeleteEntries() { - if( debug_level >= PrintFunctionTrace ) { +void MgrNodeArray::DeleteEntries() +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::DeleteEntries()\n"; } int i; - for( i = 0 ; i < _count; i++ ) { - delete( ( MgrNode * )_buf[i] ); + for(i = 0 ; i < _count; i++) { + delete((MgrNode *)_buf[i]); } _count = 0; } /*****************************************************************************/ -int MgrNodeArray::Insert( GenericNode * gn, int index ) { - if( debug_level >= PrintFunctionTrace ) { +int MgrNodeArray::Insert(GenericNode *gn, int index) +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::Insert()\n"; } - int AssignedIndex = GenNodeArray::Insert( gn, index ); + int AssignedIndex = GenNodeArray::Insert(gn, index); int i; - for( i = AssignedIndex ; i < _count; i++ ) { - ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); + for(i = AssignedIndex ; i < _count; i++) { + ((MgrNode *)_buf[i])->ArrayIndex(i); } return AssignedIndex; } /*****************************************************************************/ -void MgrNodeArray::Remove( int index ) { - if( debug_level >= PrintFunctionTrace ) { +void MgrNodeArray::Remove(int index) +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::Remove()\n"; } - if( 0 <= index && index < _count ) { - GenNodeArray::Remove( index ); + if(0 <= index && index < _count) { + GenNodeArray::Remove(index); int i; - for( i = index; i < _count; i++ ) { - ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); + for(i = index; i < _count; i++) { + ((MgrNode *)_buf[i])->ArrayIndex(i); } } } /*****************************************************************************/ -int MgrNodeArray::MgrNodeIndex( int fileId ) { - if( debug_level >= PrintFunctionTrace ) { +int MgrNodeArray::MgrNodeIndex(int fileId) +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArray::MgrNodeIndex()\n"; } int i; - for( i = 0; i < _count; ++i ) { - if( ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId() == fileId ) { + for(i = 0; i < _count; ++i) { + if(((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId() == fileId) { return i; } } @@ -134,42 +142,47 @@ int MgrNodeArray::MgrNodeIndex( int fileId ) { // class MgrNodeArraySorted member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArraySorted::MgrNodeArraySorted( int defaultSize ) - : GenNodeArray( defaultSize ) { +MgrNodeArraySorted::MgrNodeArraySorted(int defaultSize) + : GenNodeArray(defaultSize) +{ } -int MgrNodeArraySorted::Insert( GenericNode * gn ) { +int MgrNodeArraySorted::Insert(GenericNode *gn) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Insert()\n"; // since gn is really a MgrNode - int fileId = ( ( MgrNode * )gn )->GetApplication_instance()->GetFileId(); + int fileId = ((MgrNode *)gn)->GetApplication_instance()->GetFileId(); - int index = FindInsertPosition( fileId ); + int index = FindInsertPosition(fileId); - return GenNodeArray::Insert( gn, index ); + return GenNodeArray::Insert(gn, index); } -int MgrNodeArraySorted::Index( GenericNode * gn ) { +int MgrNodeArraySorted::Index(GenericNode *gn) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex( ( ( MgrNode * )gn )->GetFileId() ); + return MgrNodeIndex(((MgrNode *)gn)->GetFileId()); } -int MgrNodeArraySorted::Index( GenericNode ** gn ) { +int MgrNodeArraySorted::Index(GenericNode **gn) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex( ( ( MgrNode * )( *gn ) )->GetFileId() ); + return MgrNodeIndex(((MgrNode *)(*gn))->GetFileId()); } -void MgrNodeArraySorted::ClearEntries() { - if( debug_level >= PrintFunctionTrace ) { +void MgrNodeArraySorted::ClearEntries() +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArraySorted::ClearEntries()\n"; } int i; - for( i = 0 ; i < _count; i++ ) { + for(i = 0 ; i < _count; i++) { _buf[i] = 0; } _count = 0; @@ -177,13 +190,14 @@ void MgrNodeArraySorted::ClearEntries() { /*****************************************************************************/ -void MgrNodeArraySorted::DeleteEntries() { - if( debug_level >= PrintFunctionTrace ) { +void MgrNodeArraySorted::DeleteEntries() +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArraySorted::DeleteEntries()\n"; } int i; - for( i = 0 ; i < _count; i++ ) { - delete( ( MgrNode * )_buf[i] ); + for(i = 0 ; i < _count; i++) { + delete((MgrNode *)_buf[i]); } _count = 0; } @@ -193,16 +207,17 @@ void MgrNodeArraySorted::DeleteEntries() { // the reason this is written this way is because most of the // time the file id will be higher than any seen so far and // thus the insert position will be at the end -int MgrNodeArraySorted::FindInsertPosition( const int fileId ) { - if( debug_level >= PrintFunctionTrace ) { +int MgrNodeArraySorted::FindInsertPosition(const int fileId) +{ + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArraySorted::FindInsertPosition()\n"; } int i; int curFileId; - for( i = _count - 1; i >= 0; --i ) { - curFileId = ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId(); - if( curFileId < fileId /*|| curFileId == fileId*/ ) { + for(i = _count - 1; i >= 0; --i) { + curFileId = ((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId(); + if(curFileId < fileId /*|| curFileId == fileId*/) { return i + 1; } } @@ -211,11 +226,12 @@ int MgrNodeArraySorted::FindInsertPosition( const int fileId ) { /*****************************************************************************/ -int MgrNodeArraySorted::MgrNodeIndex( int fileId ) { +int MgrNodeArraySorted::MgrNodeIndex(int fileId) +{ // this function assumes that _buf[0] to _buf[_count] ALL point to MgrNodes // that are sorted by fileId - if( debug_level >= PrintFunctionTrace ) { + if(debug_level >= PrintFunctionTrace) { cout << "MgrNodeArraySorted::MgrNodeIndex()\n"; } int low = 0; @@ -224,18 +240,18 @@ int MgrNodeArraySorted::MgrNodeIndex( int fileId ) { int found = 0; int curFileId; - while( !found && ( low <= high ) ) { - mid = ( low + high ) / 2; - curFileId = ( ( MgrNode * )_buf[mid] )->GetApplication_instance()->GetFileId(); - if( curFileId == fileId ) { + while(!found && (low <= high)) { + mid = (low + high) / 2; + curFileId = ((MgrNode *)_buf[mid])->GetApplication_instance()->GetFileId(); + if(curFileId == fileId) { found = 1; - } else if( curFileId < fileId ) { + } else if(curFileId < fileId) { low = mid + 1; } else { high = mid - 1; } } - if( found ) { + if(found) { return mid; } return -1; diff --git a/src/clstepcore/mgrnodearray.h b/src/clstepcore/mgrnodearray.h index 22019d071..43e422f99 100644 --- a/src/clstepcore/mgrnodearray.h +++ b/src/clstepcore/mgrnodearray.h @@ -38,28 +38,31 @@ // If you delete this object it deletes all of the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray { +class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray +{ public: - MgrNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); + MgrNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); ~MgrNodeArray(); // REDEFINED functions // need to redefine Append() & Insert(GenericNode *) so they call // MgrNodeArray::Insert(GenericNode *, int index); - virtual int Insert( GenericNode * gn, int index ); - virtual void Append( GenericNode * gn ) { - Insert( gn, _count ); + virtual int Insert(GenericNode *gn, int index); + virtual void Append(GenericNode *gn) + { + Insert(gn, _count); } - virtual int Insert( GenericNode * gn ) { - return Insert( gn, _count ); + virtual int Insert(GenericNode *gn) + { + return Insert(gn, _count); } - virtual void Remove( int index ); + virtual void Remove(int index); virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex( int fileId ); - void AssignIndexAddress( int index ); + virtual int MgrNodeIndex(int fileId); + void AssignIndexAddress(int index); }; ////////////////////////////////////////////////////////////////////////////// @@ -70,31 +73,34 @@ class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray { // If you delete this object it won't delete the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray { +class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray +{ public: - MgrNodeArraySorted( int defaultSize = ARRAY_DEFAULT_SIZE ); + MgrNodeArraySorted(int defaultSize = ARRAY_DEFAULT_SIZE); ~MgrNodeArraySorted() { } // REDEFINED functions - virtual int Index( GenericNode * gn ); - virtual int Index( GenericNode ** gn ); + virtual int Index(GenericNode *gn); + virtual int Index(GenericNode **gn); - virtual int Insert( GenericNode * gn ); - virtual int Insert( GenericNode * gn, int index ) { + virtual int Insert(GenericNode *gn); + virtual int Insert(GenericNode *gn, int index) + { cerr << "Call MgrNodeArraySorted::Insert() without index argument instead.\n" << "index argument: " << index << " being ignored.\n"; - return Insert( gn ); + return Insert(gn); } - virtual void Append( GenericNode * gn ) { - Insert( gn ); + virtual void Append(GenericNode *gn) + { + Insert(gn); } virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex( int fileId ); - int FindInsertPosition( const int fileId ); + virtual int MgrNodeIndex(int fileId); + int FindInsertPosition(const int fileId); }; diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index 9bff8e254..641deada5 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -18,56 +18,62 @@ #include #include "sc_memmgr.h" -MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { +MgrNodeList::MgrNodeList(stateEnum type) : GenNodeList(new MgrNode()) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::MgrNodeList()\n"; listType = type; - ( ( MgrNode * )head )->currState = type; + ((MgrNode *)head)->currState = type; } -void MgrNodeList::Remove( GenericNode * node ) { +void MgrNodeList::Remove(GenericNode *node) +{ // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::Remove()\n"; - GenNodeList::Remove( node ); + GenNodeList::Remove(node); // DON'T DO THIS ((MgrNode *)node)->currState = noStateSE; } // deletes node from its previous list & appends... // actually it puts it at the front of the list. -void MgrNodeList::Append( GenericNode * node ) { - InsertBefore( node, head ); +void MgrNodeList::Append(GenericNode *node) +{ + InsertBefore(node, head); } // deletes newNode from its previous list & inserts after // existNode -void MgrNodeList::InsertAfter( GenericNode * newNode, - GenericNode * existNode ) { - if( newNode->next != 0 ) { // remove the node from its previous list +void MgrNodeList::InsertAfter(GenericNode *newNode, + GenericNode *existNode) +{ + if(newNode->next != 0) { // remove the node from its previous list newNode->Remove(); } - GenNodeList::InsertAfter( newNode, existNode ); + GenNodeList::InsertAfter(newNode, existNode); // DON'T DO THIS ((MgrNode *)newNode)->currState = listType; } // deletes newNode from its previous list & inserts before // existNode -void MgrNodeList::InsertBefore( GenericNode * newNode, - GenericNode * existNode ) { - if( newNode->next != 0 ) { // remove the node from its previous +void MgrNodeList::InsertBefore(GenericNode *newNode, + GenericNode *existNode) +{ + if(newNode->next != 0) { // remove the node from its previous newNode->Remove(); // state list } - GenNodeList::InsertBefore( newNode, existNode ); + GenNodeList::InsertBefore(newNode, existNode); // DON'T DO THIS!! ((MgrNode *)newNode)->currState = listType; } -MgrNode * MgrNodeList::FindFileId( int fileId ) { - MgrNode * mn = ( MgrNode * )head->next; - while( mn != head ) { - if( mn->GetFileId() == fileId ) { +MgrNode *MgrNodeList::FindFileId(int fileId) +{ + MgrNode *mn = (MgrNode *)head->next; + while(mn != head) { + if(mn->GetFileId() == fileId) { return mn; } - mn = ( MgrNode * )mn->next; + mn = (MgrNode *)mn->next; } - return ( MgrNode * )0; + return (MgrNode *)0; } diff --git a/src/clstepcore/mgrnodelist.h b/src/clstepcore/mgrnodelist.h index be822c798..c477d9601 100644 --- a/src/clstepcore/mgrnodelist.h +++ b/src/clstepcore/mgrnodelist.h @@ -29,22 +29,23 @@ class MgrNode; -class SC_CORE_EXPORT MgrNodeList : public GenNodeList { +class SC_CORE_EXPORT MgrNodeList : public GenNodeList +{ public: - MgrNodeList( stateEnum type ); + MgrNodeList(stateEnum type); virtual ~MgrNodeList() { } // ADDED functions - virtual MgrNode * FindFileId( int fileId ); + virtual MgrNode *FindFileId(int fileId); // REDEFINED functions // deletes node from its previous list & appends - virtual void Append( GenericNode * node ); + virtual void Append(GenericNode *node); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); - virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); - virtual void Remove( GenericNode * node ); + virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); + virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); + virtual void Remove(GenericNode *node); protected: stateEnum listType; diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index 959720ed0..79455607e 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -19,10 +19,11 @@ /** * Deletes the childList of this, before this is deleted. */ -MultList::~MultList() { - EntList * child = childList, *cnext; +MultList::~MultList() +{ + EntList *child = childList, *cnext; - while( child ) { + while(child) { cnext = child->next; delete child; child = cnext; @@ -33,23 +34,25 @@ MultList::~MultList() { * Sets this's level, and tells all its children to set their level to our * level +1. */ -void MultList::setLevel( int l ) { - EntList * child = childList; +void MultList::setLevel(int l) +{ + EntList *child = childList; level = l; - for( ; child != NULL; child = child->next ) { - child->setLevel( l + 1 ); + for(; child != NULL; child = child->next) { + child->setLevel(l + 1); } } /** * Check if one of this's descendants matches nm. */ -bool MultList::contains( char * nm ) { - EntList * child = childList; +bool MultList::contains(char *nm) +{ + EntList *child = childList; - while( child ) { - if( child->contains( nm ) ) { + while(child) { + if(child->contains(nm)) { return true; } child = child->next; @@ -60,10 +63,11 @@ bool MultList::contains( char * nm ) { /** * Check if one of our descendants matches nm. */ -bool MultList::hit( char * nm ) { - EntList * child = childList; - while( child ) { - if( child->viable > UNSATISFIED && child->hit( nm ) ) { +bool MultList::hit(char *nm) +{ + EntList *child = childList; + while(child) { + if(child->viable > UNSATISFIED && child->hit(nm)) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -79,15 +83,16 @@ bool MultList::hit( char * nm ) { /** * Returns a pointer to the num'th child of MultList. */ -EntList * MultList::getChild( int num ) { - EntList * child = childList; +EntList *MultList::getChild(int num) +{ + EntList *child = childList; int j; - if( num < 0 || num >= numchildren ) { + if(num < 0 || num >= numchildren) { // Check for error situations (shouldn't normally occur): return NULL; } - for( j = 0; j < num; j++, child = child->next ) { + for(j = 0; j < num; j++, child = child->next) { ; } return child; @@ -97,10 +102,11 @@ EntList * MultList::getChild( int num ) { * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ -void MultList::appendList( EntList * ent ) { - EntList * eprev; +void MultList::appendList(EntList *ent) +{ + EntList *eprev; - if( numchildren == 0 ) { + if(numchildren == 0) { childList = ent; } else { eprev = getLast(); @@ -114,12 +120,13 @@ void MultList::appendList( EntList * ent ) { * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ -EntList * MultList::copyList( EntList * ent ) { - EntList * newlist = 0, *child; +EntList *MultList::copyList(EntList *ent) +{ + EntList *newlist = 0, *child; - switch( ent->join ) { + switch(ent->join) { case SIMPLE: - newlist = new SimpleList( ( dynamic_cast(ent) )->Name() ); + newlist = new SimpleList((dynamic_cast(ent))->Name()); break; case AND: newlist = new AndList; @@ -131,12 +138,12 @@ EntList * MultList::copyList( EntList * ent ) { newlist = new AndOrList; break; }; - appendList( newlist ); - if( ent->multiple() ) { + appendList(newlist); + if(ent->multiple()) { // For the multlists, we must recurse for all their children: - child = ( dynamic_cast< MultList * >(ent) )->childList; - while( child ) { - ( dynamic_cast< MultList * >(newlist) )->copyList( child ); + child = (dynamic_cast< MultList * >(ent))->childList; + while(child) { + (dynamic_cast< MultList * >(newlist))->copyList(child); child = child->next; } } @@ -148,11 +155,12 @@ EntList * MultList::copyList( EntList * ent ) { * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ -void MultList::unmarkAll( EntNode * ents ) { - EntList * child = childList; +void MultList::unmarkAll(EntNode *ents) +{ + EntList *child = childList; - while( child != NULL ) { - child->unmarkAll( ents ); + while(child != NULL) { + child->unmarkAll(ents); child = child->next; } } @@ -161,11 +169,12 @@ void MultList::unmarkAll( EntNode * ents ) { * Resets this to default values. Iterates through child list, calling * each child's reset function. */ -void MultList::reset() { - EntList * child; +void MultList::reset() +{ + EntList *child; viable = UNKNOWN; - for( child = childList; child; child = child->next ) { + for(child = childList; child; child = child->next) { child->reset(); } } @@ -180,23 +189,24 @@ void MultList::reset() { * children which are UNSATISFIED and return UNSAT if found, we don't * worry about coming across them down here. */ -void JoinList::setViableVal( EntNode * ents ) { - EntList * child = childList; +void JoinList::setViableVal(EntNode *ents) +{ + EntList *child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while( child != NULL ) { - if( child->viable == UNKNOWN ) { + while(child != NULL) { + if(child->viable == UNKNOWN) { viable = UNKNOWN; return; } - if( child->viable > viable ) { + if(child->viable > viable) { viable = child->viable; } child = child->next; } - if( viable == MATCHALL && !ents->allMarked() ) { + if(viable == MATCHALL && !ents->allMarked()) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -210,12 +220,13 @@ void JoinList::setViableVal( EntNode * ents ) { * value will = mark (either MARK or ORMARK). Return true if we mark any- * thing; false otherwise. */ -bool JoinList::acceptChoice( EntNode * ents ) { - EntList * child; +bool JoinList::acceptChoice(EntNode *ents) +{ + EntList *child; int result = false; - for( child = childList; child != NULL; child = child->next ) { - if( child->viable >= MATCHSOME ) { + for(child = childList; child != NULL; child = child->next) { + if(child->viable >= MATCHSOME) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -226,7 +237,7 @@ bool JoinList::acceptChoice( EntNode * ents ) { // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice( ents ) || result; + result = child->acceptChoice(ents) || result; // (NOTE - must run acceptChoice() first in above line. If result // were true and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -240,11 +251,12 @@ bool JoinList::acceptChoice( EntNode * ents ) { * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ -bool MultList::prevKnown( EntList * desc ) { - EntList * child = childList; +bool MultList::prevKnown(EntList *desc) +{ + EntList *child = childList; - while( child != NULL && child != desc ) { - if( child->viable == UNKNOWN ) { + while(child != NULL && child != desc) { + if(child->viable == UNKNOWN) { return false; } child = child->next; diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index eea46ddb5..046a0e6ba 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -15,6 +15,7 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE( StepEntityEditor * se ) { +void DeleteSEE(StepEntityEditor *se) +{ delete se; } diff --git a/src/clstepcore/needFunc.h b/src/clstepcore/needFunc.h index 74148bcc6..91170be39 100644 --- a/src/clstepcore/needFunc.h +++ b/src/clstepcore/needFunc.h @@ -3,10 +3,11 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class SC_CORE_EXPORT StepEntityEditor { +class SC_CORE_EXPORT StepEntityEditor +{ public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE( StepEntityEditor * se ); +extern void DeleteSEE(StepEntityEditor *se); diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index 14607f606..5d83d8776 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -19,13 +19,14 @@ * other return values. (See descript of MatchType values in complex- * Support.h.) */ -MatchType SimpleList::matchNonORs( EntNode * ents ) { - EntNode * eptr = ents; +MatchType SimpleList::matchNonORs(EntNode *ents) +{ + EntNode *eptr = ents; int comp; - while( eptr != NULL ) { - if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { - if( ! eptr->marked( MARK ) ) { + while(eptr != NULL) { + if((comp = strcmp(name, eptr->name)) == 0) { + if(! eptr->marked(MARK)) { // NOTE - this cond also returns true if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -34,13 +35,13 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) { // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if( eptr->mark == NOMARK ) { + if(eptr->mark == NOMARK) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if( ents->allMarked() ) { + if(ents->allMarked()) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -54,7 +55,7 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) { // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if( comp < 0 ) { + if(comp < 0) { // We're beyond name in the ents list. No more checking to do. break; } @@ -74,13 +75,14 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) { * processing them we'll be able to tell which OR choices are viable, and * which are unnec. */ -MatchType AndOrList::matchNonORs( EntNode * ents ) { - EntList * child = childList->firstNot( OR ); +MatchType AndOrList::matchNonORs(EntNode *ents) +{ + EntList *child = childList->firstNot(OR); MatchType retval; - while( child != NULL ) { - if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { - if( prevKnown( child ) ) { + while(child != NULL) { + if((retval = child->matchNonORs(ents)) == MATCHALL) { + if(prevKnown(child)) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -107,15 +109,15 @@ MatchType AndOrList::matchNonORs( EntNode * ents ) { // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if( retval == UNSATISFIED ) { + } else if(retval == UNSATISFIED) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll( ents ); + child->unmarkAll(ents); } - child = child->nextNot( OR ); + child = child->nextNot(OR); } - setViableVal( ents ); + setViableVal(ents); return viable; } @@ -123,22 +125,23 @@ MatchType AndOrList::matchNonORs( EntNode * ents ) { * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ -MatchType AndList::matchNonORs( EntNode * ents ) { - EntList * child = childList->firstNot( OR ); +MatchType AndList::matchNonORs(EntNode *ents) +{ + EntList *child = childList->firstNot(OR); - while( child != NULL ) { - if( child->matchNonORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if(child->matchNonORs(ents) == UNSATISFIED) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot( OR ); + child = child->nextNot(OR); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal( ents ); + setViableVal(ents); return viable; } diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index b820bea53..ddcc260c2 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -25,16 +25,17 @@ * context of a sub w/ >1 super, in which case we build a combo-CList and * may need to check if all sub-CLists matched the multi-sub, C.) */ -bool OrList::hit( char * nm ) { - EntList * child = getChild( choice ); +bool OrList::hit(char *nm) +{ + EntList *child = getChild(choice); - if( child ) { + if(child) { // I.e., if we have a choice selected, check it only. - return ( child->hit( nm ) ); + return (child->hit(nm)); } else { child = childList; - while( child ) { - if( child->viable > UNSATISFIED && child->hit( nm ) ) { + while(child) { + if(child->viable > UNSATISFIED && child->hit(nm)) { // See MultList::hit() on why we must skip UNSATs. return true; } @@ -47,12 +48,13 @@ bool OrList::hit( char * nm ) { /** * Unmarks all the nodes of ents marked by the descendants of this. */ -void OrList::unmarkAll( EntNode * ents ) { - EntList * child; +void OrList::unmarkAll(EntNode *ents) +{ + EntList *child; - if( ( child = getChild( choice ) ) != NULL ) { + if((child = getChild(choice)) != NULL) { // choice = the last selected path which we'll now undo. - child->unmarkAll( ents ); + child->unmarkAll(ents); } } @@ -62,15 +64,16 @@ void OrList::unmarkAll( EntNode * ents ) { * LISTEND. If choice was set to LISTEND before calling aC(), we reset * choice to choice1, and search again. */ -bool OrList::acceptChoice( EntNode * ents ) { - EntList * child; +bool OrList::acceptChoice(EntNode *ents) +{ + EntList *child; - if( choice == LISTEND ) { + if(choice == LISTEND) { choice = choice1; } - child = getChild( choice ); - while( child ) { - if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { + child = getChild(choice); + while(child) { + if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { // acceptChoice() returns true if we marked something. return true; } diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index 2139d1f61..c4ecf9778 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -11,13 +11,14 @@ #include "sc_memmgr.h" // Local function prototypes: -static char * joinText( JoinType, char * ); +static char *joinText(JoinType, char *); /** * Prints out a ComplexList, by iterating through its children. */ -ostream & operator << ( ostream & os, ComplexList & clist ) { - os << "ComplexList - \"" << *( SimpleList * )clist.head->childList +ostream &operator << (ostream &os, ComplexList &clist) +{ + os << "ComplexList - \"" << *(SimpleList *)clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -28,11 +29,12 @@ ostream & operator << ( ostream & os, ComplexList & clist ) { /** * Prints out an EntList. Calls appropriate function based on JoinType. */ -ostream & operator << ( ostream & os, EntList & list ) { - if( list.join == SIMPLE ) { - os << *( SimpleList * )&list; +ostream &operator << (ostream &os, EntList &list) +{ + if(list.join == SIMPLE) { + os << *(SimpleList *)&list; } else { - os << *( MultList * )&list; + os << *(MultList *)&list; } return os; } @@ -40,7 +42,8 @@ ostream & operator << ( ostream & os, EntList & list ) { /** * Prints out a SimpleList. */ -ostream & operator << ( ostream & os, SimpleList & slist ) { +ostream &operator << (ostream &os, SimpleList &slist) +{ os << slist.name; return os; } @@ -48,26 +51,27 @@ ostream & operator << ( ostream & os, SimpleList & slist ) { /** * Prints out a MultList. */ -ostream & operator << ( ostream & os, MultList & mlist ) { +ostream &operator << (ostream &os, MultList &mlist) +{ char jointype[7]; int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList * child = mlist.childList; + EntList *child = mlist.childList; - os << joinText( mlist.join, jointype ) << endl; - for( k = 0; k <= mlist.level; k++ ) { + os << joinText(mlist.join, jointype) << endl; + for(k = 0; k <= mlist.level; k++) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while( child != NULL ) { + while(child != NULL) { os << *child; - if( child->next == NULL ) { - lastSimple = ( child->join == SIMPLE ); + if(child->next == NULL) { + lastSimple = (child->join == SIMPLE); break; // We don't want to do the conditions below if we're done. } - if( child->join == SIMPLE ) { + if(child->join == SIMPLE) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -75,13 +79,13 @@ ostream & operator << ( ostream & os, MultList & mlist ) { // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for( k = 0; k <= mlist.level; k++ ) { + for(k = 0; k <= mlist.level; k++) { os << " "; } } child = child->next; } - if( lastSimple ) { + if(lastSimple) { os << endl; } return os; @@ -90,19 +94,20 @@ ostream & operator << ( ostream & os, MultList & mlist ) { /** * Copies and returns the string equivalent of a JoinType. */ -static char * joinText( JoinType j, char * buf ) { - switch( j ) { +static char *joinText(JoinType j, char *buf) +{ + switch(j) { case SIMPLE: - strcpy( buf, "SIMPLE" ); + strcpy(buf, "SIMPLE"); return buf; case AND: - strcpy( buf, "AND" ); + strcpy(buf, "AND"); return buf; case OR: - strcpy( buf, "OR" ); + strcpy(buf, "OR"); return buf; case ANDOR: - strcpy( buf, "ANDOR" ); + strcpy(buf, "ANDOR"); return buf; }; return NULL; diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index 395e52cfd..cfc83f548 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -11,9 +11,10 @@ const int RealNumPrecision = REAL_NUM_PRECISION; // print Error information for debugging purposes void -PrintErrorState( ErrorDescriptor & err ) { +PrintErrorState(ErrorDescriptor &err) +{ cout << "** severity: "; - switch( err.severity() ) { + switch(err.severity()) { case SEVERITY_NULL : cout << "\n Null\n"; break; @@ -37,14 +38,15 @@ PrintErrorState( ErrorDescriptor & err ) { } // print istream error information for debugging purposes -void IStreamState( istream & in ) { - if( in.good() ) { +void IStreamState(istream &in) +{ + if(in.good()) { cerr << "istream GOOD\n" << flush; } - if( in.fail() ) { + if(in.fail()) { cerr << "istream FAIL\n" << flush; } - if( in.eof() ) { + if(in.eof()) { cerr << "istream EOF\n" << flush; } } @@ -69,27 +71,29 @@ void IStreamState( istream & in ) { // by any characters other than white space (i.e. EOF must happen) // /////////////////////////////////////////////////////////////////////////////// -int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, - const char * tokenList ) { +int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, + const char *tokenList) +{ SDAI_Integer i = 0; in >> ws; in >> i; int valAssigned = 0; - if( !in.fail() ) { + if(!in.fail()) { valAssigned = 1; val = i; } - CheckRemainingInput( in, err, "Integer", tokenList ); + CheckRemainingInput(in, err, "Integer", tokenList); return valAssigned; } /// same as above but reads from a const char * -int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, - const char * tokenList ) { - istringstream in( ( char * )s ); - return ReadInteger( val, in, err, tokenList ); +int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, + const char *tokenList) +{ + istringstream in((char *)s); + return ReadInteger(val, in, err, tokenList); } /////////////////////////////////////////////////////////////////////////////// @@ -111,37 +115,39 @@ int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ) { - if( clearError ) { +Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList) +{ + if(clearError) { err->ClearErrorMsg(); } - istringstream in( ( char * )attrValue ); + istringstream in((char *)attrValue); in >> ws; // skip white space char c = in.peek(); - if( in.eof() ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(in.eof()) { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - } else if( c == '$' ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + } else if(c == '$') { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } in >> c; - CheckRemainingInput( in, err, "integer", tokenList ); + CheckRemainingInput(in, err, "integer", tokenList); return err->severity(); } else { SDAI_Integer val = 0; - int valAssigned = ReadInteger( val, in, err, tokenList ); - if( !valAssigned && !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + int valAssigned = ReadInteger(val, in, err, tokenList); + if(!valAssigned && !optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } } return err->severity(); } -std::string WriteReal( SDAI_Real val ) { +std::string WriteReal(SDAI_Real val) +{ char rbuf[64]; std::string s; @@ -154,22 +160,22 @@ std::string WriteReal( SDAI_Real val ) { // Also use G instead of g since G writes uppercase E (E instead of e // is also required by Part 21) when scientific notation is used - DAS - sprintf( rbuf, "%.*G", ( int ) RealNumPrecision, val ); - if( !strchr( rbuf, '.' ) ) { - if( strchr( rbuf, 'E' ) || strchr( rbuf, 'e' ) ) { - char * expon = strchr( rbuf, 'E' ); + sprintf(rbuf, "%.*G", (int) RealNumPrecision, val); + if(!strchr(rbuf, '.')) { + if(strchr(rbuf, 'E') || strchr(rbuf, 'e')) { + char *expon = strchr(rbuf, 'E'); - if( !expon ) { - expon = strchr( rbuf, 'e' ); + if(!expon) { + expon = strchr(rbuf, 'e'); } *expon = '\0'; s = rbuf; - s.append( "." ); - s.append( "E" ); + s.append("."); + s.append("E"); expon++; s += expon; } else { - int rindex = strlen( rbuf ); + int rindex = strlen(rbuf); rbuf[rindex] = '.'; rbuf[rindex + 1] = '\0'; s = rbuf; @@ -180,8 +186,9 @@ std::string WriteReal( SDAI_Real val ) { return s; } -void WriteReal( SDAI_Real val, ostream & out ) { - out << WriteReal( val ); +void WriteReal(SDAI_Real val, ostream &out) +{ + out << WriteReal(val); } /////////////////////////////////////////////////////////////////////////////// @@ -209,8 +216,9 @@ void WriteReal( SDAI_Real val, ostream & out ) { // an error), optional sign, at least one decimal digit if there is an E. // /////////////////////////////////////////////////////////////////////////////// -int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, - const char * tokenList ) { +int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, + const char *tokenList) +{ SDAI_Real d = 0; // Read the real's value into a string so we can make sure it is properly @@ -225,71 +233,71 @@ int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, // read optional sign c = in.peek(); - if( c == '+' || c == '-' ) { - in.get( buf[i++] ); + if(c == '+' || c == '-') { + in.get(buf[i++]); c = in.peek(); } // check for required initial decimal digit - if( !isdigit( c ) ) { - e.severity( SEVERITY_WARNING ); - e.DetailMsg( "Real must have an initial digit.\n" ); + if(!isdigit(c)) { + e.severity(SEVERITY_WARNING); + e.DetailMsg("Real must have an initial digit.\n"); } // read one or more decimal digits - while( isdigit( c ) ) { - in.get( buf[i++] ); + while(isdigit(c)) { + in.get(buf[i++]); c = in.peek(); } // read Part 21 required decimal point - if( c == '.' ) { - in.get( buf[i++] ); + if(c == '.') { + in.get(buf[i++]); c = in.peek(); } else { // It may be the number they wanted but it is incompletely specified // without a decimal and thus it is an error - e.GreaterSeverity( SEVERITY_WARNING ); - e.AppendToDetailMsg( "Reals are required to have a decimal point.\n" ); + e.GreaterSeverity(SEVERITY_WARNING); + e.AppendToDetailMsg("Reals are required to have a decimal point.\n"); } // read optional decimal digits - while( isdigit( c ) ) { - in.get( buf[i++] ); + while(isdigit(c)) { + in.get(buf[i++]); c = in.peek(); } // try to read an optional E for scientific notation - if( ( c == 'e' ) || ( c == 'E' ) ) { - if( c == 'e' ) { + if((c == 'e') || (c == 'E')) { + if(c == 'e') { // this is incorrectly specified and thus is an error - e.GreaterSeverity( SEVERITY_WARNING ); + e.GreaterSeverity(SEVERITY_WARNING); e.AppendToDetailMsg( - "Reals using scientific notation must use upper case E.\n" ); + "Reals using scientific notation must use upper case E.\n"); } - in.get( buf[i++] ); // read the E + in.get(buf[i++]); // read the E c = in.peek(); // read optional sign - if( c == '+' || c == '-' ) { - in.get( buf[i++] ); + if(c == '+' || c == '-') { + in.get(buf[i++]); c = in.peek(); } // read required decimal digit (since it has an E) - if( !isdigit( c ) ) { - e.GreaterSeverity( SEVERITY_WARNING ); + if(!isdigit(c)) { + e.GreaterSeverity(SEVERITY_WARNING); e.AppendToDetailMsg( - "Real must have at least one digit following E for scientific notation.\n" ); + "Real must have at least one digit following E for scientific notation.\n"); } // read one or more decimal digits - while( isdigit( c ) ) { - in.get( buf[i++] ); + while(isdigit(c)) { + in.get(buf[i++]); c = in.peek(); } } buf[i] = '\0'; - istringstream in2( ( char * )buf ); + istringstream in2((char *)buf); // now that we have the real the stream will be able to salvage reading // whatever kind of format was used to represent the real. @@ -297,24 +305,25 @@ int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, int valAssigned = 0; - if( !in2.fail() ) { + if(!in2.fail()) { valAssigned = 1; val = d; - err->GreaterSeverity( e.severity() ); - err->AppendToDetailMsg( e.DetailMsg() ); + err->GreaterSeverity(e.severity()); + err->AppendToDetailMsg(e.DetailMsg()); } else { val = S_REAL_NULL; } - CheckRemainingInput( in, err, "Real", tokenList ); + CheckRemainingInput(in, err, "Real", tokenList); return valAssigned; } /// same as above but reads from a const char * -int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, - const char * tokenList ) { - istringstream in( ( char * )s ); - return ReadReal( val, in, err, tokenList ); +int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, + const char *tokenList) +{ + istringstream in((char *)s); + return ReadReal(val, in, err, tokenList); } /////////////////////////////////////////////////////////////////////////////// @@ -336,31 +345,32 @@ int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ) { - if( clearError ) { +Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList) +{ + if(clearError) { err->ClearErrorMsg(); } - istringstream in( ( char * )attrValue ); + istringstream in((char *)attrValue); in >> ws; // skip white space char c = in.peek(); - if( in.eof() ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(in.eof()) { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - } else if( c == '$' ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + } else if(c == '$') { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } in >> c; - CheckRemainingInput( in, err, "real", tokenList ); + CheckRemainingInput(in, err, "real", tokenList); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadReal( val, in, err, tokenList ); - if( !valAssigned && !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + int valAssigned = ReadReal(val, in, err, tokenList); + if(!valAssigned && !optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } } return err->severity(); @@ -385,26 +395,28 @@ Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, * to be invalid. If tokenList is null then the value must not be followed * by any characters other than white space (i.e. EOF must happen) */ -int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, - const char * tokenList ) { +int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, + const char *tokenList) +{ SDAI_Real d = 0; in >> ws; in >> d; int valAssigned = 0; - if( !in.fail() ) { + if(!in.fail()) { valAssigned = 1; val = d; } - CheckRemainingInput( in, err, "Number", tokenList ); + CheckRemainingInput(in, err, "Number", tokenList); return valAssigned; } /// same as above but reads from a const char * -int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, - const char * tokenList ) { - istringstream in( ( char * )s ); - return ReadNumber( val, in, err, tokenList ); +int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, + const char *tokenList) +{ + istringstream in((char *)s); + return ReadNumber(val, in, err, tokenList); } @@ -427,73 +439,76 @@ int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ) { - if( clearError ) { +Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList) +{ + if(clearError) { err->ClearErrorMsg(); } - istringstream in( ( char * )attrValue ); + istringstream in((char *)attrValue); in >> ws; // skip white space char c = in.peek(); - if( in.eof() ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(in.eof()) { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } - } else if( c == '$' ) { - if( !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + } else if(c == '$') { + if(!optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } in >> c; - CheckRemainingInput( in, err, "number", tokenList ); + CheckRemainingInput(in, err, "number", tokenList); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadNumber( val, in, err, tokenList ); - if( !valAssigned && !optional ) { - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + int valAssigned = ReadNumber(val, in, err, tokenList); + if(!valAssigned && !optional) { + err->GreaterSeverity(SEVERITY_INCOMPLETE); } } return err->severity(); } /// assign 's' so that it contains an exchange file format string read from 'in'. -void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ) { - s += GetLiteralStr( in, err ); +void PushPastString(istream &in, std::string &s, ErrorDescriptor *err) +{ + s += GetLiteralStr(in, err); } /** * assign 's' so that it contains an exchange file format aggregate read from 'in'. * This is used to read aggregates that are part of multidimensional aggregates. */ -void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { +void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err) +{ char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get( c ); + in.get(c); - if( c == '(' ) { + if(c == '(') { s += c; - in.get( c ); - while( in.good() && ( c != ')' ) ) { - if( c == '(' ) { - in.putback( c ); - PushPastImbedAggr( in, s, err ); - } else if( c == STRING_DELIM ) { - in.putback( c ); - PushPastString( in, s, err ); + in.get(c); + while(in.good() && (c != ')')) { + if(c == '(') { + in.putback(c); + PushPastImbedAggr(in, s, err); + } else if(c == STRING_DELIM) { + in.putback(c); + PushPastString(in, s, err); } else { s += c; } - in.get( c ); + in.get(c); } - if( c != ')' ) { - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - sprintf( messageBuf, "Invalid aggregate value.\n" ); - err->AppendToDetailMsg( messageBuf ); - s.append( ")" ); + if(c != ')') { + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf(messageBuf, "Invalid aggregate value.\n"); + err->AppendToDetailMsg(messageBuf); + s.append(")"); } else { s += c; } @@ -505,37 +520,38 @@ void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { * This is used to read a single dimensional aggregate (i.e. it is not allowed * to contain an aggregate as an element. */ -void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ) { +void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err) +{ char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get( c ); + in.get(c); - if( c == '(' ) { + if(c == '(') { s += c; - in.get( c ); - while( in.good() && ( c != ')' ) ) { - if( c == '(' ) { - err->GreaterSeverity( SEVERITY_WARNING ); - sprintf( messageBuf, "Invalid aggregate value.\n" ); - err->AppendToDetailMsg( messageBuf ); + in.get(c); + while(in.good() && (c != ')')) { + if(c == '(') { + err->GreaterSeverity(SEVERITY_WARNING); + sprintf(messageBuf, "Invalid aggregate value.\n"); + err->AppendToDetailMsg(messageBuf); } - if( c == STRING_DELIM ) { - in.putback( c ); - PushPastString( in, s, err ); + if(c == STRING_DELIM) { + in.putback(c); + PushPastString(in, s, err); } else { s += c; } - in.get( c ); + in.get(c); } - if( c != ')' ) { - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - sprintf( messageBuf, "Invalid aggregate value.\n" ); - err->AppendToDetailMsg( messageBuf ); - s.append( ")" ); + if(c != ')') { + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf(messageBuf, "Invalid aggregate value.\n"); + err->AppendToDetailMsg(messageBuf); + s.append(")"); } else { s += c; } @@ -547,22 +563,23 @@ void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ) { * it copies what is read to the std::string inst. It leaves the # on the * istream. */ -Severity FindStartOfInstance( istream & in, std::string & inst ) { +Severity FindStartOfInstance(istream &in, std::string &inst) +{ char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while( in.good() ) { + while(in.good()) { in >> c; - switch( c ) { + switch(c) { case '#': // found char looking for. - in.putback( c ); + in.putback(c); return SEVERITY_NULL; case '\'': // get past the string - in.putback( c ); - tmp.STEPread( in, &errs ); - inst.append( tmp.c_str() ); + in.putback(c); + tmp.STEPread(in, &errs); + inst.append(tmp.c_str()); break; case '\0': // problem in input ? @@ -579,21 +596,22 @@ Severity FindStartOfInstance( istream & in, std::string & inst ) { * SkipInstance reads in an instance terminated with ;. it copies * what is read to the std::string inst. */ -Severity SkipInstance( istream & in, std::string & inst ) { +Severity SkipInstance(istream &in, std::string &inst) +{ char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while( in.good() ) { + while(in.good()) { in >> c; - switch( c ) { + switch(c) { case ';': // end of instance reached return SEVERITY_NULL; case '\'': // get past the string - in.putback( c ); - tmp.STEPread( in, &errs ); - inst.append( tmp.c_str() ); + in.putback(c); + tmp.STEPread(in, &errs); + inst.append(tmp.c_str()); break; case '\0': // problem in input ? @@ -614,38 +632,39 @@ Severity SkipInstance( istream & in, std::string & inst ) { // external mapping don't have them. If you are reading a simple record in the // form of an internal mapping you will have to read the semicolon. */ -const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ) { +const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err) +{ char c; std::string s; in >> ws; - in.get( c ); - if( c == '(' ) { // beginning of record + in.get(c); + if(c == '(') { // beginning of record buf += c; - while( in.get( c ) && ( c != ')' ) && ( err->severity() > SEVERITY_INPUT_ERROR ) ) { - if( c == '\'' ) { - in.putback( c ); + while(in.get(c) && (c != ')') && (err->severity() > SEVERITY_INPUT_ERROR)) { + if(c == '\'') { + in.putback(c); s.clear(); - PushPastString( in, s, err ); - buf.append( s.c_str() ); - } else if( c == '(' ) { - in.putback( c ); + PushPastString(in, s, err); + buf.append(s.c_str()); + } else if(c == '(') { + in.putback(c); s.clear(); - PushPastImbedAggr( in, s, err ); - buf.append( s.c_str() ); + PushPastImbedAggr(in, s, err); + buf.append(s.c_str()); } else { buf += c; } } - if( !in.good() ) { - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); - err->DetailMsg( "File problems reading simple record.\n" ); + if(!in.good()) { + err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->DetailMsg("File problems reading simple record.\n"); } - buf.append( ")" ); + buf.append(")"); } else { - in.putback( c ); // put back open paren + in.putback(c); // put back open paren } - return const_cast( buf.c_str() ); + return const_cast(buf.c_str()); } /** @@ -653,21 +672,22 @@ const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor // entity types. To read a user-defined keyword: read the '!' then call // this function with skipInitWS turned off. **/ -const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ) { +const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS) +{ char c; - if( skipInitWS ) { + if(skipInitWS) { in >> ws; } - while( in.get( c ) && !isspace( c ) && ( isalnum( c ) || ( c == '_' ) ) ) { + while(in.get(c) && !isspace(c) && (isalnum(c) || (c == '_'))) { buf += c; } - if( in.eof() || in.good() ) { - in.putback( c ); + if(in.eof() || in.good()) { + in.putback(c); } - return const_cast( buf.c_str() ); + return const_cast(buf.c_str()); } /*************************** @@ -684,35 +704,36 @@ of an entity of a specific type. They shall consist of uppercase letters, digits, underscore characters, and possibly an exclamation mark. The "!" shall appear only once, and only as the first character. ***************************/ -const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) { +const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err) +{ char c; int sz = 1; static std::string str; str = ""; - in.get( c ); - while( !( ( isspace( c ) ) || ( strchr( delims, c ) ) ) ) { + in.get(c); + while(!((isspace(c)) || (strchr(delims, c)))) { //check to see if the char is valid - if( !( ( isupper( c ) ) || - ( isdigit( c ) ) || - ( c == '_' ) || - ( c == '-' ) || //for reading 'ISO-10303-21' - ( ( c == '!' ) && ( sz == 1 ) ) ) ) { + if(!((isupper(c)) || + (isdigit(c)) || + (c == '_') || + (c == '-') || //for reading 'ISO-10303-21' + ((c == '!') && (sz == 1)))) { cerr << "Error: Invalid character \'" << c << "\' in GetKeyword.\nkeyword was: " << str << "\n"; - err.GreaterSeverity( SEVERITY_WARNING ); - in.putback( c ); - return const_cast( str.c_str() ); + err.GreaterSeverity(SEVERITY_WARNING); + in.putback(c); + return const_cast(str.c_str()); } - if( !in.good() ) { + if(!in.good()) { break; //BUG: should do something on eof() } str += c; ++sz; - in.get( c ); + in.get(c); } - in.putback( c ); - return const_cast( str.c_str() ); + in.putback(c); + return const_cast(str.c_str()); } /** @@ -727,46 +748,47 @@ const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & er * next chars are DATA; for the beginning of the data section). * FIXME putback() doesn't work well on all platforms */ -int FoundEndSecKywd( istream & in ) { +int FoundEndSecKywd(istream &in) +{ char c; in >> ws; - in.get( c ); - - if( c == 'E' ) { - in.get( c ); - if( c == 'N' ) { - in.get( c ); - if( c == 'D' ) { - in.get( c ); - if( c == 'S' ) { - in.get( c ); - if( c == 'E' ) { - in.get( c ); - if( c == 'C' ) { + in.get(c); + + if(c == 'E') { + in.get(c); + if(c == 'N') { + in.get(c); + if(c == 'D') { + in.get(c); + if(c == 'S') { + in.get(c); + if(c == 'E') { + in.get(c); + if(c == 'C') { in >> ws; - in.get( c ); - if( c == ';' ) { + in.get(c); + if(c == ';') { return 1; } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } } else { - in.putback( c ); + in.putback(c); } // error return 0; @@ -779,27 +801,28 @@ int FoundEndSecKywd( istream & in ) { // returned. If one is found ss is appended with it and a pointer just // past the comment in s is returned. Note* a carraige return ('\n') is added // after the comment that is appended. -const char * ReadComment( std::string & ss, const char * s ) { +const char *ReadComment(std::string &ss, const char *s) +{ std::string ssTmp; - if( s ) { + if(s) { int endComment = 0; - while( *s && *s != '/' ) { + while(*s && *s != '/') { s++; // skip leading everything } - if( *s == '/' ) { + if(*s == '/') { s++; - if( *s == '*' ) { // found a comment - ssTmp.append( "/*" ); + if(*s == '*') { // found a comment + ssTmp.append("/*"); s++; - while( *s && !endComment ) { - if( *s == '*' ) { + while(*s && !endComment) { + if(*s == '*') { ssTmp += *s; s++; - if( *s == '/' ) { + if(*s == '/') { endComment = 1; ssTmp += *s; - ssTmp.append( "\n" ); + ssTmp.append("\n"); } else { s--; } @@ -810,8 +833,8 @@ const char * ReadComment( std::string & ss, const char * s ) { } } } - if( endComment ) { - ss.append( ssTmp.c_str() ); + if(endComment) { + ss.append(ssTmp.c_str()); } } return s; @@ -829,29 +852,30 @@ const char * ReadComment( std::string & ss, const char * s ) { * only the slash will be read from 'in'. * FIXME putback() doesn't work well on all platforms ***************************/ -const char * ReadComment( istream & in, std::string & s ) { +const char *ReadComment(istream &in, std::string &s) +{ char c = '\0'; in >> ws; in >> c; // it looks like a comment so far - if( c == '/' ) { // leave slash read from stream - in.get( c ); // won't skip space - if( c == '*' ) { // it is a comment + if(c == '/') { // leave slash read from stream + in.get(c); // won't skip space + if(c == '*') { // it is a comment in >> ws; // skip leading comment space int commentLength = 0; // only to keep it from completely gobbling up input - while( commentLength <= MAX_COMMENT_LENGTH ) { - in.get( c ); - if( c == '*' ) { // looks like start of end comment - in.get( c ); - if( c == '/' ) { // it is end of comment + while(commentLength <= MAX_COMMENT_LENGTH) { + in.get(c); + if(c == '*') { // looks like start of end comment + in.get(c); + if(c == '/') { // it is end of comment return s.c_str(); // return comment as a string } else { // it is not end of comment // so store the * and put back the other char - s.append( "*" ); - in.putback( c ); + s.append("*"); + in.putback(c); commentLength++; } } else { @@ -863,17 +887,17 @@ const char * ReadComment( istream & in, std::string & s ) { << MAX_COMMENT_LENGTH << "\n" << "Will try to recover...\n"; std::string tmp; - SkipInstance( in, tmp ); + SkipInstance(in, tmp); return s.c_str(); } // leave slash read from stream... assume caller already knew there was // a slash, leave it off stream so they don't think this funct needs // to be called again else { // not a comment - in.putback( c ); // put non asterisk char back on input stream + in.putback(c); // put non asterisk char back on input stream } } else { // first non-white char is not a slash - in.putback( c ); // put non slash char back on input stream + in.putback(c); // put non slash char back on input stream } return 0; // no comment string to return @@ -884,15 +908,16 @@ const char * ReadComment( istream & in, std::string & s ) { ** "\F\" == formfeed ** "\N\" == newline ***************************/ -Severity ReadPcd( istream & in ) { +Severity ReadPcd(istream &in) +{ char c; - in.get( c ); - if( c == '\\' ) { - in.get( c ); - if( c == 'F' || c == 'N' ) { - in.get( c ); - if( c == '\\' ) { - in.get( c ); + in.get(c); + if(c == '\\') { + in.get(c); + if(c == 'F' || c == 'N') { + in.get(c); + if(c == '\\') { + in.get(c); return SEVERITY_NULL; } } @@ -911,32 +936,33 @@ and comments. Part 21 considers the blank to be the space character, but this function considers blanks to be the return value of isspace(c) ******************************/ -void ReadTokenSeparator( istream & in, std::string * comments ) { +void ReadTokenSeparator(istream &in, std::string *comments) +{ char c; std::string s; // used if need to read a comment - if( in.eof() ) { + if(in.eof()) { //BUG: no error message is reported return; } - while( in ) { + while(in) { in >> ws; // skip white space. c = in.peek(); // look at next char on input stream - switch( c ) { + switch(c) { case '/': // read p21 file comment s.clear(); - ReadComment( in, s ); - if( !s.empty() && comments ) { - comments->append( "/*" ); - comments->append( s.c_str() ); - comments->append( "*/\n" ); + ReadComment(in, s); + if(!s.empty() && comments) { + comments->append("/*"); + comments->append(s.c_str()); + comments->append("*/\n"); } break; case '\\': // try to read a print control directive - ReadPcd( in ); + ReadPcd(in); break; case '\n': in.ignore(); diff --git a/src/clstepcore/read_func.h b/src/clstepcore/read_func.h index 92cff5705..1b5d0c101 100644 --- a/src/clstepcore/read_func.h +++ b/src/clstepcore/read_func.h @@ -8,75 +8,75 @@ #define MAX_COMMENT_LENGTH 8192 // print Error information for debugging purposes -extern SC_CORE_EXPORT void PrintErrorState( ErrorDescriptor & err ); +extern SC_CORE_EXPORT void PrintErrorState(ErrorDescriptor &err); // print istream error information for debugging purposes -extern SC_CORE_EXPORT void IStreamState( istream & in ); +extern SC_CORE_EXPORT void IStreamState(istream &in); -extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ); +extern SC_CORE_EXPORT Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList); -extern SC_CORE_EXPORT std::string WriteReal( SDAI_Real val ); +extern SC_CORE_EXPORT std::string WriteReal(SDAI_Real val); -extern SC_CORE_EXPORT void WriteReal( SDAI_Real val, ostream & out ); +extern SC_CORE_EXPORT void WriteReal(SDAI_Real val, ostream &out); -extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ); +extern SC_CORE_EXPORT Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList); -extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, - const char * tokenList ); +extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, + const char *tokenList); -extern SC_CORE_EXPORT Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, - int clearError, int optional, const char * tokenList ); +extern SC_CORE_EXPORT Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, + int clearError, int optional, const char *tokenList); //////////////////// -extern SC_CORE_EXPORT int QuoteInString( istream & in ); +extern SC_CORE_EXPORT int QuoteInString(istream &in); -extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); -extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); -extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); +extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); //////////////////// -extern SC_CORE_EXPORT Severity FindStartOfInstance( istream & in, std::string & inst ); +extern SC_CORE_EXPORT Severity FindStartOfInstance(istream &in, std::string &inst); /// used for instances that aren\'t valid - reads to next \';\' -extern SC_CORE_EXPORT Severity SkipInstance( istream & in, std::string & inst ); +extern SC_CORE_EXPORT Severity SkipInstance(istream &in, std::string &inst); -extern SC_CORE_EXPORT const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ); +extern SC_CORE_EXPORT const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err); /// this includes entity names -extern SC_CORE_EXPORT const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS = 1 ); +extern SC_CORE_EXPORT const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS = 1); -extern SC_CORE_EXPORT const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ); +extern SC_CORE_EXPORT const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err); -extern SC_CORE_EXPORT int FoundEndSecKywd( istream& in ); +extern SC_CORE_EXPORT int FoundEndSecKywd(istream &in); -extern SC_CORE_EXPORT const char * ReadComment( std::string & ss, const char * s ); +extern SC_CORE_EXPORT const char *ReadComment(std::string &ss, const char *s); -extern SC_CORE_EXPORT const char * ReadComment( istream & in, std::string & s ); +extern SC_CORE_EXPORT const char *ReadComment(istream &in, std::string &s); -extern SC_CORE_EXPORT Severity ReadPcd( istream & in ); //print control directive +extern SC_CORE_EXPORT Severity ReadPcd(istream &in); //print control directive -extern SC_CORE_EXPORT void ReadTokenSeparator( istream & in, std::string * comments = 0 ); +extern SC_CORE_EXPORT void ReadTokenSeparator(istream &in, std::string *comments = 0); #endif diff --git a/src/clstepcore/realTypeDescriptor.h b/src/clstepcore/realTypeDescriptor.h index 8f1519540..155598bd3 100644 --- a/src/clstepcore/realTypeDescriptor.h +++ b/src/clstepcore/realTypeDescriptor.h @@ -3,23 +3,27 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor { +class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor +{ -protected: - SDAI_Integer _precisionSpec; // OPTIONAL -public: + protected: + SDAI_Integer _precisionSpec; // OPTIONAL + public: - RealTypeDescriptor( ) { - _precisionSpec = 0; - } - virtual ~RealTypeDescriptor() { } + RealTypeDescriptor() + { + _precisionSpec = 0; + } + virtual ~RealTypeDescriptor() { } - SDAI_Integer PrecisionSpec() { - return _precisionSpec; - } - void PrecisionSpec( SDAI_Integer ps ) { - _precisionSpec = ps; - } + SDAI_Integer PrecisionSpec() + { + return _precisionSpec; + } + void PrecisionSpec(SDAI_Integer ps) + { + _precisionSpec = ps; + } }; #endif //REALTYPEDESCRIPTOR_H diff --git a/src/clstepcore/schRename.cc b/src/clstepcore/schRename.cc index b7159a6e0..32e1fe8c0 100644 --- a/src/clstepcore/schRename.cc +++ b/src/clstepcore/schRename.cc @@ -5,12 +5,13 @@ * See if nm = one of our choices (either ours or that of a SchRename * later in the list. */ -bool SchRename::choice( const char * nm ) const { - if( !StrCmpIns( nm, newName ) ) { +bool SchRename::choice(const char *nm) const +{ + if(!StrCmpIns(nm, newName)) { return true; } - if( next ) { - return ( next->choice( nm ) ); + if(next) { + return (next->choice(nm)); } return false; } @@ -22,13 +23,14 @@ bool SchRename::choice( const char * nm ) const { * on next. Thus, this function will tell us if this or any later SchRe- * name in this list provide a new name for TypeDesc for schema schnm. */ -char * SchRename::rename( const char * schnm, char * newnm ) const { - if( !StrCmpIns( schnm, schName ) ) { - strcpy( newnm, newName ); +char *SchRename::rename(const char *schnm, char *newnm) const +{ + if(!StrCmpIns(schnm, schName)) { + strcpy(newnm, newName); return newnm; } - if( next ) { - return ( next->rename( schnm, newnm ) ); + if(next) { + return (next->rename(schnm, newnm)); } return NULL; } diff --git a/src/clstepcore/schRename.h b/src/clstepcore/schRename.h index a0403a5d8..d9ada7db8 100644 --- a/src/clstepcore/schRename.h +++ b/src/clstepcore/schRename.h @@ -19,30 +19,35 @@ * schema is determined by the file schema section of the header section of a * part21 file (the _headerInstances of STEPfile). */ -class SC_CORE_EXPORT SchRename { -public: - SchRename( const char * sch = "\0", const char * newnm = "\0" ) : next( 0 ) { - strcpy( schName, sch ); - strcpy( newName, newnm ); - } - ~SchRename() { - delete next; - } - const char * objName() const { - return newName; - } - int operator< ( SchRename & schrnm ) { - return ( strcmp( schName, schrnm.schName ) < 0 ); - } - bool choice( const char * nm ) const; - // is nm one of our possible choices? - char * rename( const char * schm, char * newnm ) const; - // given a schema name, returns new object name if exists - SchRename * next; +class SC_CORE_EXPORT SchRename +{ + public: + SchRename(const char *sch = "\0", const char *newnm = "\0") : next(0) + { + strcpy(schName, sch); + strcpy(newName, newnm); + } + ~SchRename() + { + delete next; + } + const char *objName() const + { + return newName; + } + int operator< (SchRename &schrnm) + { + return (strcmp(schName, schrnm.schName) < 0); + } + bool choice(const char *nm) const; + // is nm one of our possible choices? + char *rename(const char *schm, char *newnm) const; + // given a schema name, returns new object name if exists + SchRename *next; -private: - char schName[BUFSIZ]; - char newName[BUFSIZ]; + private: + char schName[BUFSIZ]; + char newName[BUFSIZ]; }; diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index 731a381f5..6ebf71f71 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -4,7 +4,7 @@ #include #include "sc_memmgr.h" -const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; +const char *SCLversion = "STEPcode, github.com/stepcode/stepcode"; const SDAI_Integer SDAI_INT_NULL = LONG_MAX; const SDAI_Real SDAI_REAL_NULL = FLT_MIN; diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index 5751996a0..d066720b3 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -21,7 +21,7 @@ #include "sc_cf.h" #include -extern const char * SCLversion; +extern const char *SCLversion; #include #include @@ -151,9 +151,9 @@ enum SDAI_Error_id { SDAI_sdaiSY_ERR = 1000 // Underlying system error }; -typedef char * SDAI_Time_stamp; -typedef char * SDAI_Entity_name; -typedef char * SDAI_Schema_name; +typedef char *SDAI_Time_stamp; +typedef char *SDAI_Entity_name; +typedef char *SDAI_Schema_name; #include @@ -201,7 +201,7 @@ SELECT #include class SDAI_Model_contents; -typedef SDAI_Model_contents * SDAI_Model_contents_ptr; +typedef SDAI_Model_contents *SDAI_Model_contents_ptr; typedef SDAI_Model_contents_ptr SDAI_Model_contents_var; #include @@ -221,15 +221,15 @@ extern SC_CORE_EXPORT SDAI_Application_instance NilSTEPentity; typedef SDAI_Application_instance STEPentity; -typedef SDAI_Application_instance * STEPentity_ptr; +typedef SDAI_Application_instance *STEPentity_ptr; typedef STEPentity_ptr STEPentity_var; -typedef SDAI_Application_instance * STEPentityPtr; -typedef SDAI_Application_instance * STEPentityH; +typedef SDAI_Application_instance *STEPentityPtr; +typedef SDAI_Application_instance *STEPentityH; extern SC_CORE_EXPORT SDAI_Application_instance * -ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, - InstMgrBase * instances, int addFileId ); +ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, + InstMgrBase *instances, int addFileId); #define SdaiInteger SDAI_Integer #define SdaiReal SDAI_Real @@ -252,15 +252,17 @@ AGGREGATE TYPES ******************************************************************************/ -inline SDAI_BOOLEAN * create_BOOLEAN() { +inline SDAI_BOOLEAN *create_BOOLEAN() +{ return new SDAI_BOOLEAN ; } -inline SDAI_LOGICAL * create_LOGICAL() { +inline SDAI_LOGICAL *create_LOGICAL() +{ return new SDAI_LOGICAL ; } // below is outdated -typedef SDAI_Select * SdaiSelectH; +typedef SDAI_Select *SdaiSelectH; #endif diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index ad143cae5..c770a8f9c 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -24,8 +24,9 @@ SDAI_Application_instance NilSTEPentity; -bool isNilSTEPentity( const SDAI_Application_instance * ai ) { - if( ai && ai == &NilSTEPentity ) { +bool isNilSTEPentity(const SDAI_Application_instance *ai) +{ + if(ai && ai == &NilSTEPentity) { return true; } return false; @@ -43,41 +44,44 @@ bool isNilSTEPentity( const SDAI_Application_instance * ai ) { */ SDAI_Application_instance::SDAI_Application_instance() - : _cur( 0 ), - eDesc( NULL ), - _complex( false ), - STEPfile_id( 0 ), - p21Comment( std::string( "" ) ), - headMiEntity( 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( "" ) ), - headMiEntity( 0 ), - nextMiEntity( 0 ) { -} - -SDAI_Application_instance::~SDAI_Application_instance() { - STEPattribute * attr; + : _cur(0), + eDesc(NULL), + _complex(false), + STEPfile_id(0), + p21Comment(std::string("")), + headMiEntity(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("")), + headMiEntity(0), + nextMiEntity(0) +{ +} + +SDAI_Application_instance::~SDAI_Application_instance() +{ + STEPattribute *attr; ResetAttributes(); do { attr = NextAttribute(); - if( attr ) { + if(attr) { attr->refCount --; - if( attr->refCount <= 0 ) { + if(attr->refCount <= 0) { delete attr; } } - } while( attr ); + } while(attr); - if( MultipleInheritance() ) { + if(MultipleInheritance()) { delete nextMiEntity; } } @@ -86,85 +90,93 @@ 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; +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 ) ); + 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() ) { + superInvAttrIter siai(eDesc); + while(!siai.empty()) { ia = siai.next(); - assert( ia && "Null inverse attr!" ); - iAMap.insert( iAMap_t::value_type( ia, s ) ); + assert(ia && "Null inverse attr!"); + iAMap.insert(iAMap_t::value_type(ia, s)); } } -SDAI_Application_instance * SDAI_Application_instance::Replicate() { +SDAI_Application_instance *SDAI_Application_instance::Replicate() +{ char errStr[BUFSIZ]; - if( IsComplex() ) { + if(IsComplex()) { cerr << "STEPcomplex::Replicate() should be called: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf( errStr, - "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", - "Programming ERROR - STEPcomplex::Replicate() should be called", - STEPfile_id ); - _error.AppendToDetailMsg( errStr ); - _error.AppendToUserMsg( errStr ); - _error.GreaterSeverity( SEVERITY_BUG ); + sprintf(errStr, + "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", + "Programming ERROR - STEPcomplex::Replicate() should be called", + STEPfile_id); + _error.AppendToDetailMsg(errStr); + _error.AppendToUserMsg(errStr); + _error.GreaterSeverity(SEVERITY_BUG); return S_ENTITY_NULL; } else { - if( !eDesc ) { + if(!eDesc) { return S_ENTITY_NULL; } - SDAI_Application_instance * seNew = eDesc->NewSTEPentity(); - seNew -> CopyAs( this ); + SDAI_Application_instance *seNew = eDesc->NewSTEPentity(); + seNew -> CopyAs(this); return seNew; } } -void SDAI_Application_instance::AddP21Comment( const char * s, bool replace ) { - if( replace ) { +void SDAI_Application_instance::AddP21Comment(const char *s, bool replace) +{ + if(replace) { p21Comment.clear(); } - if( s ) { + if(s) { p21Comment += s; } } -void SDAI_Application_instance::AddP21Comment( const std::string & s, bool replace ) { - if( replace ) { +void SDAI_Application_instance::AddP21Comment(const std::string &s, bool replace) +{ + if(replace) { p21Comment.clear(); } p21Comment += s; } -void SDAI_Application_instance::PrependP21Comment( const std::string & s ) { - p21Comment.insert( 0, s ); +void SDAI_Application_instance::PrependP21Comment(const std::string &s) +{ + p21Comment.insert(0, s); } -void SDAI_Application_instance::STEPwrite_reference( ostream & out ) { +void SDAI_Application_instance::STEPwrite_reference(ostream &out) +{ out << "#" << STEPfile_id; } -const char * SDAI_Application_instance::STEPwrite_reference( std::string & buf ) { +const char *SDAI_Application_instance::STEPwrite_reference(std::string &buf) +{ char tmp[64]; - sprintf( tmp, "#%d", STEPfile_id ); + sprintf(tmp, "#%d", STEPfile_id); buf = tmp; - return const_cast( buf.c_str() ); + return const_cast(buf.c_str()); } -void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * se ) { - if( nextMiEntity == 0 ) { +void SDAI_Application_instance::AppendMultInstance(SDAI_Application_instance *se) +{ + if(nextMiEntity == 0) { nextMiEntity = se; } else { - SDAI_Application_instance * link = nextMiEntity; - SDAI_Application_instance * linkTrailing = 0; - while( link ) { + SDAI_Application_instance *link = nextMiEntity; + SDAI_Application_instance *linkTrailing = 0; + while(link) { linkTrailing = link; link = link->nextMiEntity; } @@ -173,27 +185,28 @@ void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * } // BUG implement this -- FIXME function is never used -SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entName ) { +SDAI_Application_instance *SDAI_Application_instance::GetMiEntity(char *entName) +{ std::string s1, s2; - const EntityDescLinkNode * edln = 0; - const EntityDescriptor * ed = eDesc; + const EntityDescLinkNode *edln = 0; + const EntityDescriptor *ed = eDesc; // compare up the *leftmost* parent path - while( ed ) { - if( !strcmp( StrToLower( ed->Name(), s1 ), StrToLower( entName, s2 ) ) ) { + while(ed) { + if(!strcmp(StrToLower(ed->Name(), s1), StrToLower(entName, s2))) { return this; // return this parent path } - edln = ( EntityDescLinkNode * )( ed->Supertypes().GetHead() ); - if( edln ) { + edln = (EntityDescLinkNode *)(ed->Supertypes().GetHead()); + if(edln) { ed = edln->EntityDesc(); } else { ed = 0; } } // search alternate parent path since didn't find it in this one. - if( nextMiEntity ) { - return nextMiEntity->GetMiEntity( entName ); + if(nextMiEntity) { + return nextMiEntity->GetMiEntity(entName); } return 0; } @@ -204,18 +217,19 @@ SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entNa * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When MakeDerived is called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute * SDAI_Application_instance::GetSTEPattribute( const char * nm, const char * entity ) { - if( !nm ) { +STEPattribute *SDAI_Application_instance::GetSTEPattribute(const char *nm, const char *entity) +{ + if(!nm) { return 0; } - STEPattribute * a = 0; + STEPattribute *a = 0; ResetAttributes(); // keep going until no more attributes, or attribute is found - while( ( a = NextAttribute() ) ) { - if( 0 == strcmp( nm, a ->Name() ) && - //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? - ( entity ? ( 0 != a->aDesc->Owner().IsA( entity ) ) : true ) ) { + while((a = NextAttribute())) { + if(0 == strcmp(nm, a ->Name()) && + //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? + (entity ? (0 != a->aDesc->Owner().IsA(entity)) : true)) { break; } } @@ -223,13 +237,14 @@ STEPattribute * SDAI_Application_instance::GetSTEPattribute( const char * nm, co return a; } -STEPattribute * SDAI_Application_instance::MakeRedefined( STEPattribute * redefiningAttr, const char * nm ) { +STEPattribute *SDAI_Application_instance::MakeRedefined(STEPattribute *redefiningAttr, const char *nm) +{ // find the attribute being redefined - STEPattribute * a = GetSTEPattribute( nm ); + STEPattribute *a = GetSTEPattribute(nm); // assign its pointer to the redefining attribute - if( a ) { - a->RedefiningAttr( redefiningAttr ); + if(a) { + a->RedefiningAttr(redefiningAttr); } return a; } @@ -239,61 +254,66 @@ STEPattribute * SDAI_Application_instance::MakeRedefined( STEPattribute * redefi * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute * SDAI_Application_instance::MakeDerived( const char * nm, const char * entity ) { - STEPattribute * a = GetSTEPattribute( nm, entity ); - if( a ) { +STEPattribute *SDAI_Application_instance::MakeDerived(const char *nm, const char *entity) +{ + STEPattribute *a = GetSTEPattribute(nm, entity); + if(a) { a ->Derive(); } return a; } -void SDAI_Application_instance::CopyAs( SDAI_Application_instance * other ) { +void SDAI_Application_instance::CopyAs(SDAI_Application_instance *other) +{ int numAttrs = AttributeCount(); ResetAttributes(); other -> ResetAttributes(); - STEPattribute * this_attr = 0; - STEPattribute * other_attr = 0; - while( ( this_attr = NextAttribute() ) && numAttrs ) { + STEPattribute *this_attr = 0; + STEPattribute *other_attr = 0; + while((this_attr = NextAttribute()) && numAttrs) { other_attr = other -> NextAttribute(); - this_attr -> ShallowCopy( other_attr ); + this_attr -> ShallowCopy(other_attr); numAttrs--; } } -const char * SDAI_Application_instance::EntityName( const char * schnm ) const { - if( !eDesc ) { +const char *SDAI_Application_instance::EntityName(const char *schnm) const +{ + if(!eDesc) { return NULL; } - return eDesc->Name( schnm ); + return eDesc->Name(schnm); } /** * Checks if a given SDAI_Application_instance is the same * type as this one */ -const EntityDescriptor * SDAI_Application_instance::IsA( const EntityDescriptor * ed ) const { - if( !eDesc ) { +const EntityDescriptor *SDAI_Application_instance::IsA(const EntityDescriptor *ed) const +{ + if(!eDesc) { return NULL; } - return ( eDesc->IsA( ed ) ); + return (eDesc->IsA(ed)); } /** * Checks the validity of the current attribute values for the entity */ -Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, - int clearError ) { +Severity SDAI_Application_instance::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, + int clearError) +{ ErrorDescriptor err; - if( clearError ) { + if(clearError) { ClearError(); } int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) - error->GreaterSeverity( attributes[i].ValidLevel( - attributes[i].asStr().c_str(), &err, im, 0 ) ); + for(int i = 0 ; i < n; i++) { + if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) + error->GreaterSeverity(attributes[i].ValidLevel( + attributes[i].asStr().c_str(), &err, im, 0)); } return error->severity(); } @@ -301,9 +321,10 @@ Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgr /** * clears all attr's errors */ -void SDAI_Application_instance::ClearAttrError() { +void SDAI_Application_instance::ClearAttrError() +{ int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { + for(int i = 0 ; i < n; i++) { attributes[i].Error().ClearErrorMsg(); } } @@ -311,9 +332,10 @@ void SDAI_Application_instance::ClearAttrError() { /** * clears entity's error and optionally all attr's errors */ -void SDAI_Application_instance::ClearError( int clearAttrs ) { +void SDAI_Application_instance::ClearError(int clearAttrs) +{ _error.ClearErrorMsg(); - if( clearAttrs ) { + if(clearAttrs) { ClearAttrError(); } } @@ -324,15 +346,16 @@ void SDAI_Application_instance::ClearError( int clearAttrs ) { ** Side Effects: writes out the SCOPE section for an entity ** Status: stub FIXME *******************************************************************/ -void SDAI_Application_instance::beginSTEPwrite( ostream & out ) { +void SDAI_Application_instance::beginSTEPwrite(ostream &out) +{ out << "begin STEPwrite ... \n" ; out.flush(); int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - if( attributes[i].Type() == ENTITY_TYPE - && *( attributes[i].ptr.c ) != S_ENTITY_NULL ) { - ( *( attributes[i].ptr.c ) ) -> STEPwrite(); + for(int i = 0 ; i < n; i++) { + if(attributes[i].Type() == ENTITY_TYPE + && *(attributes[i].ptr.c) != S_ENTITY_NULL) { + (*(attributes[i].ptr.c)) -> STEPwrite(); } } } @@ -345,65 +368,68 @@ void SDAI_Application_instance::beginSTEPwrite( ostream & out ) { ** Problems: does not print out the SCOPE section of an entity ** *******************************************************************/ -void SDAI_Application_instance::STEPwrite( ostream & out, const char * currSch, - int writeComments ) { +void SDAI_Application_instance::STEPwrite(ostream &out, const char *currSch, + int writeComments) +{ std::string tmp; - if( writeComments && !p21Comment.empty() ) { + if(writeComments && !p21Comment.empty()) { out << p21Comment; } - out << "#" << STEPfile_id << "=" << StrToUpper( EntityName( currSch ), tmp ) + out << "#" << STEPfile_id << "=" << StrToUpper(EntityName(currSch), tmp) << "("; int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { - if( i > 0 ) { + for(int i = 0 ; i < n; i++) { + if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { + if(i > 0) { out << ","; } - ( attributes[i] ).STEPwrite( out, currSch ); + (attributes[i]).STEPwrite(out, currSch); } } out << ");\n"; } -void SDAI_Application_instance::endSTEPwrite( ostream & out ) { +void SDAI_Application_instance::endSTEPwrite(ostream &out) +{ out << "end STEPwrite ... \n" ; out.flush(); } -void SDAI_Application_instance::WriteValuePairs( ostream & out, - const char * currSch, - int writeComments, int mixedCase ) { +void SDAI_Application_instance::WriteValuePairs(ostream &out, + const char *currSch, + int writeComments, int mixedCase) +{ std::string s, tmp, tmp2; - if( writeComments && !p21Comment.empty() ) { + if(writeComments && !p21Comment.empty()) { out << p21Comment; } - if( eDesc ) { - if( mixedCase ) { + if(eDesc) { + if(mixedCase) { out << "#" << STEPfile_id << " " - << eDesc->QualifiedName( s ) << endl; + << eDesc->QualifiedName(s) << endl; } else { out << "#" << STEPfile_id << " " - << StrToUpper( eDesc->QualifiedName( s ), tmp ) << endl; + << StrToUpper(eDesc->QualifiedName(s), tmp) << endl; } } int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { - if( mixedCase ) { + for(int i = 0 ; i < n; i++) { + if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { + if(mixedCase) { out << "\t" - << attributes[i].aDesc->Owner().Name( s.c_str() ) + << attributes[i].aDesc->Owner().Name(s.c_str()) << "." << attributes[i].aDesc->Name() << " "; } else { out << "\t" - << StrToUpper( attributes[i].aDesc->Owner().Name( s.c_str() ), tmp ) - << "." << StrToUpper( attributes[i].aDesc->Name(), tmp2 ) << " "; + << StrToUpper(attributes[i].aDesc->Owner().Name(s.c_str()), tmp) + << "." << StrToUpper(attributes[i].aDesc->Name(), tmp2) << " "; } - ( attributes[i] ).STEPwrite( out, currSch ); + (attributes[i]).STEPwrite(out, currSch); out << endl; } } @@ -415,39 +441,41 @@ void SDAI_Application_instance::WriteValuePairs( ostream & out, ** Procedure: STEPwrite ** Problems: does not print out the SCOPE section of an entity ******************************************************************/ -const char * SDAI_Application_instance::STEPwrite( std::string & buf, const char * currSch ) { +const char *SDAI_Application_instance::STEPwrite(std::string &buf, const char *currSch) +{ buf.clear(); char instanceInfo[BUFSIZ]; std::string tmp; - sprintf( instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper( EntityName( currSch ), tmp ) ); - buf.append( instanceInfo ); + sprintf(instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper(EntityName(currSch), tmp)); + buf.append(instanceInfo); int n = attributes.list_length(); - for( int i = 0 ; i < n; i++ ) { - if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { - if( i > 0 ) { - buf.append( "," ); + for(int i = 0 ; i < n; i++) { + if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { + if(i > 0) { + buf.append(","); } - tmp = attributes[i].asStr( currSch ) ; - buf.append( tmp ); + tmp = attributes[i].asStr(currSch) ; + buf.append(tmp); } } - buf.append( ");" ); - return const_cast( buf.c_str() ); + buf.append(");"); + return const_cast(buf.c_str()); } -void SDAI_Application_instance::PrependEntityErrMsg() { +void SDAI_Application_instance::PrependEntityErrMsg() +{ char errStr[BUFSIZ]; errStr[0] = '\0'; - if( _error.severity() == SEVERITY_NULL ) { + if(_error.severity() == SEVERITY_NULL) { // if there is not an error already - sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName() ); - _error.PrependToDetailMsg( errStr ); + sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName()); + _error.PrependToDetailMsg(errStr); } } @@ -459,38 +487,39 @@ void SDAI_Application_instance::PrependEntityErrMsg() { ** instance. i.e. a close quote followed by a semicolon optionally ** having whitespace between them. ******************************************************************/ -void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, const char * schnm ) { +void SDAI_Application_instance::STEPread_error(char c, int i, istream &in, const char *schnm) +{ (void) in; char errStr[BUFSIZ]; errStr[0] = '\0'; - if( _error.severity() == SEVERITY_NULL ) { + if(_error.severity() == SEVERITY_NULL) { // if there is not an error already - sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName() ); - _error.PrependToDetailMsg( errStr ); + sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName()); + _error.PrependToDetailMsg(errStr); } - if( ( i >= 0 ) && ( i < attributes.list_length() ) ) { // i is an attribute - Error().GreaterSeverity( SEVERITY_WARNING ); - sprintf( errStr, " invalid data before type \'%s\'\n", - attributes[i].TypeName() ); - _error.AppendToDetailMsg( errStr ); + if((i >= 0) && (i < attributes.list_length())) { // i is an attribute + Error().GreaterSeverity(SEVERITY_WARNING); + sprintf(errStr, " invalid data before type \'%s\'\n", + attributes[i].TypeName()); + _error.AppendToDetailMsg(errStr); } else { - Error().GreaterSeverity( SEVERITY_INPUT_ERROR ); - _error.AppendToDetailMsg( " No more attributes were expected.\n" ); + Error().GreaterSeverity(SEVERITY_INPUT_ERROR); + _error.AppendToDetailMsg(" No more attributes were expected.\n"); } std::string tmp; - STEPwrite( tmp, schnm ); // STEPwrite writes to a static buffer inside function - _error.AppendToDetailMsg( " The invalid instance to this point looks like :\n" ); - _error.AppendToDetailMsg( tmp ); - _error.AppendToDetailMsg( "\nUnexpected character: " ); - _error.AppendToDetailMsg( c ); - _error.AppendToDetailMsg( '\n' ); - - sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); - _error.AppendToDetailMsg( errStr ); + STEPwrite(tmp, schnm); // STEPwrite writes to a static buffer inside function + _error.AppendToDetailMsg(" The invalid instance to this point looks like :\n"); + _error.AppendToDetailMsg(tmp); + _error.AppendToDetailMsg("\nUnexpected character: "); + _error.AppendToDetailMsg(c); + _error.AppendToDetailMsg('\n'); + + sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); + _error.AppendToDetailMsg(errStr); return; } @@ -508,9 +537,10 @@ void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, con ** Side Effects: gobbles up input stream ** Status: ******************************************************************/ -Severity SDAI_Application_instance::STEPread( int id, int idIncr, - InstMgrBase * instance_set, istream & in, - const char * currSch, bool useTechCor, bool strict ) { +Severity SDAI_Application_instance::STEPread(int id, int idIncr, + InstMgrBase *instance_set, istream &in, + const char *currSch, bool useTechCor, bool strict) +{ STEPfile_id = id; char c = '\0'; char errStr[BUFSIZ]; @@ -518,53 +548,53 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, Severity severe; int i = 0; - ClearError( 1 ); + ClearError(1); in >> ws; in >> c; // read the open paren - if( c != '(' ) { + if(c != '(') { PrependEntityErrMsg(); _error.AppendToDetailMsg( - " Missing initial open paren... Trying to recover.\n" ); - in.putback( c ); // assume you can recover by reading 1st attr value + " Missing initial open paren... Trying to recover.\n"); + in.putback(c); // assume you can recover by reading 1st attr value } - ReadTokenSeparator( in, &p21Comment ); + ReadTokenSeparator(in, &p21Comment); int n = attributes.list_length(); - if( n == 0 ) { // no attributes + if(n == 0) { // no attributes in >> c; // look for the close paren - if( c == ')' ) { + if(c == ')') { return _error.severity(); } } - for( i = 0 ; i < n; i++ ) { - ReadTokenSeparator( in, &p21Comment ); - if( attributes[i].aDesc->AttrType() == AttrType_Redefining ) { + for(i = 0 ; i < n; i++) { + ReadTokenSeparator(in, &p21Comment); + if(attributes[i].aDesc->AttrType() == AttrType_Redefining) { in >> ws; c = in.peek(); - if( !useTechCor ) { // i.e. use pre-technical corrigendum encoding + if(!useTechCor) { // i.e. use pre-technical corrigendum encoding in >> c; // read what should be the '*' in >> ws; - if( c == '*' ) { + if(c == '*') { in >> c; // read the delimiter i.e. ',' or ')' } else { severe = SEVERITY_INCOMPLETE; PrependEntityErrMsg(); // adds entity info if necessary // set the severity for this entity - _error.GreaterSeverity( severe ); - sprintf( errStr, " %s : ", attributes[i].Name() ); - _error.AppendToDetailMsg( errStr ); // add attr name + _error.GreaterSeverity(severe); + sprintf(errStr, " %s : ", attributes[i].Name()); + _error.AppendToDetailMsg(errStr); // add attr name _error.AppendToDetailMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n" ); + "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n"); _error.AppendToUserMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr. " ); + "Since using pre-technical corrigendum... missing asterisk for redefined attr. "); } } else { // using technical corrigendum // should be nothing to do except loop again unless... // if at end need to have read the closing paren. - if( c == ')' ) { // assume you are at the end so read last char + if(c == ')') { // assume you are at the end so read last char in >> c; } cout << "Entity #" << STEPfile_id @@ -574,54 +604,54 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, // increment counter to read following attr since these attrs // aren't written or read => there won't be a delimiter either } else { - attributes[i].STEPread( in, instance_set, idIncr, currSch, strict ); + attributes[i].STEPread(in, instance_set, idIncr, currSch, strict); in >> c; // read the , or ) following the attr read severe = attributes[i].Error().severity(); - if( severe <= SEVERITY_USERMSG ) { + if(severe <= SEVERITY_USERMSG) { // if there is some type of error PrependEntityErrMsg(); // set the severity for this entity - _error.GreaterSeverity( severe ); - sprintf( errStr, " %s : ", attributes[i].Name() ); - _error.AppendToDetailMsg( errStr ); // add attr name - _error.AppendToDetailMsg( attributes[i].Error().DetailMsg() ); // add attr error - _error.AppendToUserMsg( attributes[i].Error().UserMsg() ); + _error.GreaterSeverity(severe); + sprintf(errStr, " %s : ", attributes[i].Name()); + _error.AppendToDetailMsg(errStr); // add attr name + _error.AppendToDetailMsg(attributes[i].Error().DetailMsg()); // add attr error + _error.AppendToUserMsg(attributes[i].Error().UserMsg()); } } // if technical corrigendum redefined, input is at next attribute value // if pre-technical corrigendum redefined, don't process - if( ( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) || - !useTechCor ) && - !( ( c == ',' ) || ( c == ')' ) ) ) { // input is not a delimiter + if((!(attributes[i].aDesc->AttrType() == AttrType_Redefining) || + !useTechCor) && + !((c == ',') || (c == ')'))) { // input is not a delimiter PrependEntityErrMsg(); _error.AppendToDetailMsg( - "Delimiter expected after attribute value.\n" ); - if( !useTechCor ) { + "Delimiter expected after attribute value.\n"); + if(!useTechCor) { _error.AppendToDetailMsg( - "I.e. since using pre-technical corrigendum, redefined " ); + "I.e. since using pre-technical corrigendum, redefined "); _error.AppendToDetailMsg( - "attribute is mapped as an asterisk so needs delimiter.\n" ); + "attribute is mapped as an asterisk so needs delimiter.\n"); } - CheckRemainingInput( in, &_error, "ENTITY", ",)" ); - if( !in.good() ) { + CheckRemainingInput(in, &_error, "ENTITY", ",)"); + if(!in.good()) { return _error.severity(); } - if( _error.severity() <= SEVERITY_INPUT_ERROR ) { + if(_error.severity() <= SEVERITY_INPUT_ERROR) { return _error.severity(); } - } else if( c == ')' ) { - while( i < n - 1 ) { + } else if(c == ')') { + while(i < n - 1) { i++; // check if following attributes are redefined - if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { PrependEntityErrMsg(); - _error.AppendToDetailMsg( "Missing attribute value[s].\n" ); + _error.AppendToDetailMsg("Missing attribute value[s].\n"); // recoverable error - _error.GreaterSeverity( SEVERITY_WARNING ); + _error.GreaterSeverity(SEVERITY_WARNING); return _error.severity(); } i++; @@ -629,7 +659,7 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, return _error.severity(); } } - STEPread_error( c, i, in, currSch ); + STEPread_error(c, i, in, currSch); // code fragment imported from STEPread_error // for some currently unknown reason it was commented out of STEPread_error errStr[0] = '\0'; @@ -640,144 +670,147 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, // Search until a close paren is found followed by (skipping optional // whitespace) a semicolon - while( in.good() && !foundEnd ) { - while( in.good() && ( c != ')' ) ) { - in.get( c ); + while(in.good() && !foundEnd) { + while(in.good() && (c != ')')) { + in.get(c); tmp += c; } - if( in.good() && ( c == ')' ) ) { + if(in.good() && (c == ')')) { in >> ws; // skip whitespace - in.get( c ); + in.get(c); tmp += c; - if( c == ';' ) { + if(c == ';') { foundEnd = 1; } } } - _error.AppendToDetailMsg( tmp.c_str() ); - sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); - _error.AppendToDetailMsg( errStr ); + _error.AppendToDetailMsg(tmp.c_str()); + sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); + _error.AppendToDetailMsg(errStr); // end of imported code return _error.severity(); } /// read an entity reference and return a pointer to the SDAI_Application_instance -SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, - InstMgrBase * instances, int addFileId ) { +SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, + InstMgrBase *instances, int addFileId) +{ char c; char errStr[BUFSIZ]; errStr[0] = '\0'; in >> ws; in >> c; - switch( c ) { + switch(c) { case '@': - err->AppendToDetailMsg( "Use of @ instead of # to identify entity.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); - // no break statement here on purpose + err->AppendToDetailMsg("Use of @ instead of # to identify entity.\n"); + err->GreaterSeverity(SEVERITY_WARNING); + // no break statement here on purpose case '#': { int id = -1; in >> id; - if( in.fail() ) { // there's been an error in input - sprintf( errStr, "Invalid entity reference value.\n" ); - err->AppendToDetailMsg( errStr ); - err->AppendToUserMsg( errStr ); - err->GreaterSeverity( SEVERITY_WARNING ); - CheckRemainingInput( in, err, "Entity Reference", tokenList ); + if(in.fail()) { // there's been an error in input + sprintf(errStr, "Invalid entity reference value.\n"); + err->AppendToDetailMsg(errStr); + err->AppendToUserMsg(errStr); + err->GreaterSeverity(SEVERITY_WARNING); + CheckRemainingInput(in, err, "Entity Reference", tokenList); return S_ENTITY_NULL; } else { // found an entity id // check to make sure garbage does not follow the id - CheckRemainingInput( in, err, "Entity Reference", tokenList ); + CheckRemainingInput(in, err, "Entity Reference", tokenList); id += addFileId; - if( !instances ) { + if(!instances) { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf( errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - cannot read reference without the InstMgr", - id, "is unknown" ); - err->AppendToDetailMsg( errStr ); - err->AppendToUserMsg( errStr ); - err->GreaterSeverity( SEVERITY_BUG ); + sprintf(errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - cannot read reference without the InstMgr", + id, "is unknown"); + err->AppendToDetailMsg(errStr); + err->AppendToUserMsg(errStr); + err->GreaterSeverity(SEVERITY_BUG); return S_ENTITY_NULL; } // lookup which object has id as its instance id - SDAI_Application_instance * inst; + SDAI_Application_instance *inst; /* If there is a ManagerNode it should have a SDAI_Application_instance */ - MgrNodeBase * mn = 0; - mn = instances->FindFileId( id ); - if( mn ) { + MgrNodeBase *mn = 0; + mn = instances->FindFileId(id); + if(mn) { inst = mn->GetSTEPentity() ; - if( inst ) { - return ( inst ); + if(inst) { + return (inst); } else { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf( errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - MgrNode::GetSTEPentity returned NULL pointer", - id, "is unknown" ); - err->AppendToDetailMsg( errStr ); - err->AppendToUserMsg( errStr ); - err->GreaterSeverity( SEVERITY_BUG ); + sprintf(errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - MgrNode::GetSTEPentity returned NULL pointer", + id, "is unknown"); + err->AppendToDetailMsg(errStr); + err->AppendToUserMsg(errStr); + err->GreaterSeverity(SEVERITY_BUG); return S_ENTITY_NULL; } } else { - sprintf( errStr, "Reference to non-existent ENTITY #%d.\n", - id ); - err->AppendToDetailMsg( errStr ); - err->AppendToUserMsg( errStr ); - err->GreaterSeverity( SEVERITY_WARNING ); + sprintf(errStr, "Reference to non-existent ENTITY #%d.\n", + id); + err->AppendToDetailMsg(errStr); + err->AppendToUserMsg(errStr); + err->GreaterSeverity(SEVERITY_WARNING); return S_ENTITY_NULL; } } } default: { - in.putback( c ); + in.putback(c); // read past garbage up to delim in tokenList // if tokenList is null it will not read anything - CheckRemainingInput( in, err, "Entity Reference", tokenList ); + CheckRemainingInput(in, err, "Entity Reference", tokenList); return S_ENTITY_NULL; } } } /// 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, - InstMgrBase * instances, int addFileId ) { - istringstream in( ( char * )s ); - return ReadEntityRef( in, err, tokenList, instances, addFileId ); +SDAI_Application_instance *ReadEntityRef(const char *s, ErrorDescriptor *err, const char *tokenList, + InstMgrBase *instances, int addFileId) +{ + istringstream in((char *)s); + return ReadEntityRef(in, err, tokenList, instances, addFileId); } /// return SEVERITY_NULL if se's entity type matches the supplied entity type -Severity EntityValidLevel( SDAI_Application_instance * se, - const TypeDescriptor * ed, // entity type that entity se needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor * err ) { +Severity EntityValidLevel(SDAI_Application_instance *se, + const TypeDescriptor *ed, // entity type that entity se needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor *err) +{ char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; - if( !ed || ( ed->NonRefType() != ENTITY_TYPE ) ) { - err->GreaterSeverity( SEVERITY_BUG ); - sprintf( messageBuf, - " BUG: EntityValidLevel() called with %s", - "missing or invalid EntityDescriptor\n" ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); + if(!ed || (ed->NonRefType() != ENTITY_TYPE)) { + err->GreaterSeverity(SEVERITY_BUG); + sprintf(messageBuf, + " BUG: EntityValidLevel() called with %s", + "missing or invalid EntityDescriptor\n"); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; } - if( !se || ( se == S_ENTITY_NULL ) ) { - err->GreaterSeverity( SEVERITY_BUG ); - sprintf( messageBuf, - " BUG: EntityValidLevel() called with null pointer %s\n", - "for SDAI_Application_instance argument." ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); + if(!se || (se == S_ENTITY_NULL)) { + err->GreaterSeverity(SEVERITY_BUG); + sprintf(messageBuf, + " BUG: EntityValidLevel() called with null pointer %s\n", + "for SDAI_Application_instance argument."); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -786,35 +819,35 @@ 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->eDesc) { // is se a descendant of ed? - if( se->eDesc->IsA( ed ) ) { + if(se->eDesc->IsA(ed)) { return SEVERITY_NULL; } else { - if( se->IsComplex() ) { + if(se->IsComplex()) { // This way assumes that the complex has all it's parts i.e. the // complete hierarchy so it should be able to find ed's part if // it is an ed. - STEPcomplex * sc = ( ( STEPcomplex * )se )->sc; - if( sc->EntityExists( ed->Name() ) ) { + STEPcomplex *sc = ((STEPcomplex *)se)->sc; + if(sc->EntityExists(ed->Name())) { return SEVERITY_NULL; } } - err->GreaterSeverity( SEVERITY_WARNING ); - sprintf( messageBuf, - " Entity #%d exists but is not a %s or descendant.\n", - se->STEPfile_id, ed->Name() ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity(SEVERITY_WARNING); + sprintf(messageBuf, + " Entity #%d exists but is not a %s or descendant.\n", + se->STEPfile_id, ed->Name()); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); return SEVERITY_WARNING; } } else { - err->GreaterSeverity( SEVERITY_BUG ); - sprintf( messageBuf, - " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", - se->STEPfile_id, "missing or invalid EntityDescriptor\n" ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity(SEVERITY_BUG); + sprintf(messageBuf, + " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", + se->STEPfile_id, "missing or invalid EntityDescriptor\n"); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -825,18 +858,19 @@ Severity EntityValidLevel( SDAI_Application_instance * se, * return 1 if attrValue has the equivalent of a null value. * DAVE: Is this needed will sscanf return 1 if assignment suppression is used? */ -int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ) { +int SetErrOnNull(const char *attrValue, ErrorDescriptor *error) +{ char scanBuf[BUFSIZ]; scanBuf[0] = '\0'; std::stringstream fmtstr; - fmtstr << " %" << BUFSIZ -1 << "s "; + fmtstr << " %" << BUFSIZ - 1 << "s "; //fmtstr contains " %ns " where n is BUFSIZ -1 - int numFound = sscanf( ( char * )attrValue , fmtstr.str().c_str() , scanBuf ); + int numFound = sscanf((char *)attrValue, fmtstr.str().c_str(), scanBuf); - if( numFound == EOF ) { - error->GreaterSeverity( SEVERITY_INCOMPLETE ); + if(numFound == EOF) { + error->GreaterSeverity(SEVERITY_INCOMPLETE); return 1; } return 0; @@ -848,69 +882,70 @@ int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ) { ** without the # sign: e.g. either #23 or 23 will be read. ** If non-whitespace characters follow the entity reference an error is set. */ -Severity EntityValidLevel( const char * attrValue, // string contain entity ref - const TypeDescriptor * ed, // entity type that entity in - // attrValue (if it exists) needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor * err, InstMgrBase * im, int clearError ) { +Severity EntityValidLevel(const char *attrValue, // string contain entity ref + const TypeDescriptor *ed, // entity type that entity in + // attrValue (if it exists) needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor *err, InstMgrBase *im, int clearError) +{ char tmp [BUFSIZ]; tmp[0] = '\0'; char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; std::stringstream fmtstr1, fmtstr2; - if( clearError ) { + if(clearError) { err->ClearErrorMsg(); } int fileId; - MgrNodeBase * mn = 0; + MgrNodeBase *mn = 0; // fmtstr1 contains "#%d %ns" where n is BUFSIZ-1 fmtstr1 << " #%d %" << BUFSIZ - 1 << "s "; // fmtstr2 contains "%d %ns" where n is BUFSIZ-1 fmtstr2 << " %d %" << BUFSIZ - 1 << "s "; - + // check for both forms: #id or id - int found1 = sscanf( ( char * )attrValue, fmtstr1.str().c_str() , &fileId, tmp ); - int found2 = sscanf( ( char * )attrValue, fmtstr2.str().c_str() , &fileId, tmp ); - - if( ( found1 > 0 ) || ( found2 > 0 ) ) { - if( ( found1 == 2 ) || ( found2 == 2 ) ) { - sprintf( messageBuf, - " Attribute's Entity Reference %s is %s data \'%s\'.\n", - attrValue, "followed by invalid", tmp ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); - err->GreaterSeverity( SEVERITY_WARNING ); + int found1 = sscanf((char *)attrValue, fmtstr1.str().c_str(), &fileId, tmp); + int found2 = sscanf((char *)attrValue, fmtstr2.str().c_str(), &fileId, tmp); + + if((found1 > 0) || (found2 > 0)) { + if((found1 == 2) || (found2 == 2)) { + sprintf(messageBuf, + " Attribute's Entity Reference %s is %s data \'%s\'.\n", + attrValue, "followed by invalid", tmp); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity(SEVERITY_WARNING); } - mn = im->FindFileId( fileId ); - if( mn ) { - SDAI_Application_instance * se = mn->GetSTEPentity(); - return EntityValidLevel( se, ed, err ); + mn = im->FindFileId(fileId); + if(mn) { + SDAI_Application_instance *se = mn->GetSTEPentity(); + return EntityValidLevel(se, ed, err); } else { - sprintf( messageBuf, - " Attribute's Entity Reference %s does not exist.\n", - attrValue ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); - err->GreaterSeverity( SEVERITY_WARNING ); + sprintf(messageBuf, + " Attribute's Entity Reference %s does not exist.\n", + attrValue); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity(SEVERITY_WARNING); return SEVERITY_WARNING; } } // if the attrValue contains no value return - if( SetErrOnNull( attrValue, err ) ) { + if(SetErrOnNull(attrValue, err)) { return err->severity(); } - sprintf( messageBuf, "Invalid attribute entity reference value: '%s'.\n", - attrValue ); - err->AppendToUserMsg( messageBuf ); - err->AppendToDetailMsg( messageBuf ); - err->GreaterSeverity( SEVERITY_WARNING ); + sprintf(messageBuf, "Invalid attribute entity reference value: '%s'.\n", + attrValue); + err->AppendToUserMsg(messageBuf); + err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity(SEVERITY_WARNING); return SEVERITY_WARNING; } @@ -920,47 +955,52 @@ Severity EntityValidLevel( const char * attrValue, // string contain entity ref ** Status: untested 7/31/90 ** \Returns reference to an attribute pointer ******************************************************************/ -STEPattribute * SDAI_Application_instance::NextAttribute() { +STEPattribute *SDAI_Application_instance::NextAttribute() +{ int i = AttributeCount(); ++_cur; - if( i < _cur ) { + if(i < _cur) { return 0; } return &attributes [_cur - 1]; } -int SDAI_Application_instance::AttributeCount() { +int SDAI_Application_instance::AttributeCount() +{ return attributes.list_length(); } -const iAstruct SDAI_Application_instance::getInvAttr( const Inverse_attribute * const ia ) const { +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() ) { + 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 { +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) ) { + 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( (Inverse_attribute *) nullptr, z ); + memset(&z, 0, sizeof z); + iAMap_t::value_type nil((Inverse_attribute *) nullptr, z); return nil; } -void SDAI_Application_instance::setInvAttr( const Inverse_attribute * const ia, const iAstruct ias ) { +void SDAI_Application_instance::setInvAttr(const Inverse_attribute *const ia, const iAstruct ias) +{ iAMap_t::iterator it = iAMap.find(ia); - if( it != iAMap.end() ) { + if(it != iAMap.end()) { it->second = ias; } else { - iAMap.insert( iAMap_t::value_type( ia, ias ) ); + iAMap.insert(iAMap_t::value_type(ia, ias)); } } diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index 405964c24..991e06fa8 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -22,21 +22,22 @@ class EntityAggregate; class Inverse_attribute; typedef struct { union { - EntityAggregate * a; - SDAI_Application_instance * i; + EntityAggregate *a; + SDAI_Application_instance *i; }; } iAstruct; /** @class * this used to be STEPentity */ -class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { +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; - const EntityDescriptor * eDesc; + typedef std::map< const Inverse_attribute *const, iAstruct> iAMap_t; + const EntityDescriptor *eDesc; protected: #ifdef _MSC_VER #pragma warning( push ) @@ -51,10 +52,10 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { public: //TODO make these private? STEPattributeList attributes; - /* see mgrnode.cc where -1 is returned when there is no sdai - * instance. might be possible to treat 0 for this purpose - * instead of negative so the ID's can become unsigned. - */ + /* see mgrnode.cc where -1 is returned when there is no sdai + * instance. might be possible to treat 0 for this purpose + * instead of negative so the ID's can become unsigned. + */ int STEPfile_id; ErrorDescriptor _error; @@ -74,136 +75,152 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { ** and head points at the root SDAI_Application_instance of the primary inheritance ** path (the one that is the root of the leaf entity). */ - SDAI_Application_instance * headMiEntity; + SDAI_Application_instance *headMiEntity; /// these form a chain of other entity parents for multiple inheritance - SDAI_Application_instance * nextMiEntity; + SDAI_Application_instance *nextMiEntity; public: SDAI_Application_instance(); - SDAI_Application_instance( int fileid, int complex = 0 ); + SDAI_Application_instance(int fileid, int complex = 0); virtual ~SDAI_Application_instance(); - bool IsComplex() const { + bool IsComplex() const + { return _complex; } /// initialize inverse attribute list void InitIAttrs(); - void StepFileId( int fid ) { + void StepFileId(int fid) + { STEPfile_id = fid; } - int StepFileId() const { + int StepFileId() const + { return STEPfile_id; } - void AddP21Comment( const std::string & s, bool replace = true ); - void AddP21Comment( const char * s, bool replace = true ); - void PrependP21Comment( const std::string & s ); - void DeleteP21Comment() { + void AddP21Comment(const std::string &s, bool replace = true); + void AddP21Comment(const char *s, bool replace = true); + void PrependP21Comment(const std::string &s); + void DeleteP21Comment() + { p21Comment = ""; } - std::string P21Comment() const { + std::string P21Comment() const + { return p21Comment; } - const char * EntityName( const char * schnm = NULL ) const; + const char *EntityName(const char *schnm = NULL) const; - virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; + virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; - virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, - int clearError = 1 ); - ErrorDescriptor & Error() { + virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, + int clearError = 1); + ErrorDescriptor &Error() + { return _error; } // clears entity's error and optionally all attr's errors - void ClearError( int clearAttrs = 1 ); + void ClearError(int clearAttrs = 1); // clears all attr's errors void ClearAttrError(); - virtual SDAI_Application_instance * Replicate(); + virtual SDAI_Application_instance *Replicate(); // ACCESS attributes in order. int AttributeCount(); - STEPattribute * NextAttribute(); - void ResetAttributes() { + STEPattribute *NextAttribute(); + 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 { + 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 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 ); + virtual Severity STEPread(int id, int addFileId, + 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( std::ostream & out = std::cout, const char * currSch = NULL, - int writeComments = 1 ); - virtual const char * STEPwrite( std::string & buf, 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( std::ostream & out, const char * currSch = NULL, - int writeComments = 1, int mixedCase = 1 ); + void WriteValuePairs(std::ostream &out, const char *currSch = NULL, + int writeComments = 1, int mixedCase = 1); - void STEPwrite_reference( std::ostream & out = std::cout ); - const char * STEPwrite_reference( std::string & buf ); + void STEPwrite_reference(std::ostream &out = std::cout); + const char *STEPwrite_reference(std::string &buf); - void beginSTEPwrite( std::ostream & out = std::cout ); ///< writes out the SCOPE section - void endSTEPwrite( std::ostream & out = std::cout ); + void beginSTEPwrite(std::ostream &out = std::cout); ///< writes out the SCOPE section + void endSTEPwrite(std::ostream &out = std::cout); // MULTIPLE INHERITANCE - int MultipleInheritance() { - return !( headMiEntity == 0 ); + int MultipleInheritance() + { + return !(headMiEntity == 0); } - void HeadEntity( SDAI_Application_instance * se ) { + void HeadEntity(SDAI_Application_instance *se) + { headMiEntity = se; } - SDAI_Application_instance * HeadEntity() { + SDAI_Application_instance *HeadEntity() + { return headMiEntity; } - SDAI_Application_instance * GetNextMiEntity() { + SDAI_Application_instance *GetNextMiEntity() + { return nextMiEntity; } - SDAI_Application_instance * GetMiEntity( char * entName ); - void AppendMultInstance( SDAI_Application_instance * se ); + SDAI_Application_instance *GetMiEntity(char *entName); + void AppendMultInstance(SDAI_Application_instance *se); protected: - STEPattribute * GetSTEPattribute( const char * nm, const char * entity = NULL ); - STEPattribute * MakeDerived( const char * nm, const char * entity = NULL ); - STEPattribute * MakeRedefined( STEPattribute * redefiningAttr, - const char * nm ); + STEPattribute *GetSTEPattribute(const char *nm, const char *entity = NULL); + STEPattribute *MakeDerived(const char *nm, const char *entity = NULL); + STEPattribute *MakeRedefined(STEPattribute *redefiningAttr, + const char *nm); - virtual void CopyAs( SDAI_Application_instance * ); + virtual void CopyAs(SDAI_Application_instance *); void PrependEntityErrMsg(); public: // these functions are going to go away in the future. - int SetFileId( int fid ) { + int SetFileId(int fid) + { return STEPfile_id = fid; } - int GetFileId() const { + int GetFileId() const + { return STEPfile_id; } - int FileId( int fid ) { + int FileId(int fid) + { return STEPfile_id = fid; } - int FileId() const { + int FileId() const + { return STEPfile_id; } }; // current style of CORBA handles for Part 23 - NOTE - used for more than CORBA -typedef SDAI_Application_instance * SDAI_Application_instance_ptr; +typedef SDAI_Application_instance *SDAI_Application_instance_ptr; typedef SDAI_Application_instance_ptr SDAI_Application_instance_var; -SC_CORE_EXPORT bool isNilSTEPentity( const SDAI_Application_instance * ai ); +SC_CORE_EXPORT bool isNilSTEPentity(const SDAI_Application_instance *ai); #endif //STEPENTITY_H diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 08e789a6d..1d1d741ce 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -19,21 +19,23 @@ #ifdef SC_LOGGING #include -extern ofstream * logStream; +extern ofstream *logStream; #endif /********** (member) functions for the select class SDAI_Select **********/ -SDAI_Select::SDAI_Select( const SelectTypeDescriptor * s, - const TypeDescriptor * td ) - : _type( s ), underlying_type( td ) { +SDAI_Select::SDAI_Select(const SelectTypeDescriptor *s, + const TypeDescriptor *td) + : _type(s), underlying_type(td) +{ #ifdef SC_LOGGING *logStream << "Exiting SDAI_Select constructor." << endl; #endif } -SDAI_Select::SDAI_Select( const SDAI_Select & other ) { +SDAI_Select::SDAI_Select(const SDAI_Select &other) +{ underlying_type = other.underlying_type; base_type = other.base_type; _type = other._type; @@ -42,11 +44,13 @@ SDAI_Select::SDAI_Select( const SDAI_Select & other ) { #endif } -SDAI_Select::~SDAI_Select() { +SDAI_Select::~SDAI_Select() +{ } -SDAI_Select & SDAI_Select::operator=( const SDAI_Select & other ) { - if( &other != this ) { +SDAI_Select &SDAI_Select::operator=(const SDAI_Select &other) +{ + if(&other != this) { _error = other._error; _type = other._type; base_type = other.base_type; @@ -56,88 +60,101 @@ SDAI_Select & SDAI_Select::operator=( const SDAI_Select & other ) { return *this; } -Severity SDAI_Select::severity() const { +Severity SDAI_Select::severity() const +{ return _error.severity(); } -Severity SDAI_Select::severity( Severity s ) { - return _error.severity( s ); +Severity SDAI_Select::severity(Severity s) +{ + return _error.severity(s); } -std::string SDAI_Select::Error() { +std::string SDAI_Select::Error() +{ return _error.DetailMsg(); } -void SDAI_Select::Error( const char * e ) { - _error.DetailMsg( e ); +void SDAI_Select::Error(const char *e) +{ + _error.DetailMsg(e); } -void SDAI_Select::ClearError() { +void SDAI_Select::ClearError() +{ _error.ClearErrorMsg(); } const TypeDescriptor * -SDAI_Select::CanBe( const char * n ) const { - return _type -> CanBe( n ); +SDAI_Select::CanBe(const char *n) const +{ + return _type -> CanBe(n); } const TypeDescriptor * -SDAI_Select::CanBe( BASE_TYPE bt ) const { - const TypeDescLinkNode * tdn = - ( const TypeDescLinkNode * ) _type -> GetElements().GetHead(); - const TypeDescriptor * td = tdn -> TypeDesc(); +SDAI_Select::CanBe(BASE_TYPE bt) const +{ + const TypeDescLinkNode *tdn = + (const TypeDescLinkNode *) _type -> GetElements().GetHead(); + const TypeDescriptor *td = tdn -> TypeDesc(); BASE_TYPE bt_thisnode; - while( tdn ) { + while(tdn) { td = tdn -> TypeDesc(); - if( ( ( bt_thisnode = td -> NonRefType() ) == bt ) || - ( bt == AGGREGATE_TYPE && ( ( bt_thisnode == ARRAY_TYPE ) || - ( bt_thisnode == LIST_TYPE ) || - ( bt_thisnode == SET_TYPE ) || - ( bt_thisnode == BAG_TYPE ) ) ) ) { + if(((bt_thisnode = td -> NonRefType()) == bt) || + (bt == AGGREGATE_TYPE && ((bt_thisnode == ARRAY_TYPE) || + (bt_thisnode == LIST_TYPE) || + (bt_thisnode == SET_TYPE) || + (bt_thisnode == BAG_TYPE)))) { return td; // they are the same } - tdn = ( TypeDescLinkNode * )( tdn -> NextNode() ); + tdn = (TypeDescLinkNode *)(tdn -> NextNode()); } return 0; } const TypeDescriptor * -SDAI_Select::CanBe( const TypeDescriptor * td ) const { - return _type -> CanBe( td ); +SDAI_Select::CanBe(const TypeDescriptor *td) const +{ + return _type -> CanBe(td); } const TypeDescriptor * -SDAI_Select::CanBeSet( const char * n, const char * schnm ) const { - return _type -> CanBeSet( n, schnm ); +SDAI_Select::CanBeSet(const char *n, const char *schnm) const +{ + return _type -> CanBeSet(n, schnm); } int -SDAI_Select::IsUnique( const BASE_TYPE bt ) const { - if( bt == ARRAY_TYPE || +SDAI_Select::IsUnique(const BASE_TYPE bt) const +{ + if(bt == ARRAY_TYPE || bt == LIST_TYPE || bt == BAG_TYPE || - bt == SET_TYPE ) { - return ( ( _type->UniqueElements() ) & AGGREGATE_TYPE ); + bt == SET_TYPE) { + return ((_type->UniqueElements()) & AGGREGATE_TYPE); } else { - return ( ( _type->UniqueElements() ) & bt ); + return ((_type->UniqueElements()) & bt); } } -SDAI_String SDAI_Select::UnderlyingTypeName() const { +SDAI_String SDAI_Select::UnderlyingTypeName() const +{ return underlying_type -> Name(); } -const TypeDescriptor * SDAI_Select::CurrentUnderlyingType() const { +const TypeDescriptor *SDAI_Select::CurrentUnderlyingType() const +{ return underlying_type; } const TypeDescriptor * -SDAI_Select::SetUnderlyingType( const TypeDescriptor * td ) { +SDAI_Select::SetUnderlyingType(const TypeDescriptor *td) +{ // don\'t do anything if the descriptor is bad - if( !td || !( _type -> CanBe( td ) ) ) { + if(!td || !(_type -> CanBe(td))) { return 0; } @@ -146,45 +163,49 @@ SDAI_Select::SetUnderlyingType( const TypeDescriptor * td ) { return underlying_type = td; } -bool SDAI_Select::exists() const { +bool SDAI_Select::exists() const +{ return underlying_type != NULL; } -void SDAI_Select::nullify() { +void SDAI_Select::nullify() +{ underlying_type = 0; } -Severity SDAI_Select::SelectValidLevel( const char * attrValue, ErrorDescriptor * err, - InstMgrBase * im ) { - SDAI_Select * tmp = NewSelect(); +Severity SDAI_Select::SelectValidLevel(const char *attrValue, ErrorDescriptor *err, + InstMgrBase *im) +{ + SDAI_Select *tmp = NewSelect(); Severity s = SEVERITY_NULL; - istringstream strtmp( attrValue ); - s = tmp -> STEPread( strtmp, err, im ); + istringstream strtmp(attrValue); + s = tmp -> STEPread(strtmp, err, im); delete tmp; return s; } -Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, - ErrorDescriptor * err, InstMgrBase * instances ) { - severity( SEVERITY_NULL ); - if( SetUnderlyingType( CanBe( selectType ) ) ) +Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, + ErrorDescriptor *err, InstMgrBase *instances) +{ + severity(SEVERITY_NULL); + if(SetUnderlyingType(CanBe(selectType))) // the underlying type is set to a valid type // call read on underlying type in subclass - switch( base_type ) { + switch(base_type) { case ENTITY_TYPE: { - STEPentity * tmp = - ReadEntityRef( Val, err, ",)", instances, 0 ); - if( tmp && ( tmp != ENTITY_NULL ) ) { - AssignEntity( tmp ); + STEPentity *tmp = + ReadEntityRef(Val, err, ",)", instances, 0); + if(tmp && (tmp != ENTITY_NULL)) { + AssignEntity(tmp); return severity(); } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n" ); + "Reference to entity that is not a valid type for SELECT.\n"); nullify(); - err->GreaterSeverity( SEVERITY_WARNING ); + err->GreaterSeverity(SEVERITY_WARNING); return SEVERITY_WARNING; } } @@ -200,9 +221,9 @@ Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, case SELECT_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: { - err->GreaterSeverity( StrToVal_content( Val, instances ) ); - if( _error.severity() != SEVERITY_NULL ) { - err->AppendFromErrorArg( &_error ); + err->GreaterSeverity(StrToVal_content(Val, instances)); + if(_error.severity() != SEVERITY_NULL) { + err->AppendFromErrorArg(&_error); } return err->severity(); } @@ -213,10 +234,10 @@ Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, case REAL_TYPE: case INTEGER_TYPE: default: { - istringstream strtmp( Val ); - err->GreaterSeverity( STEPread_content( strtmp ) ); - if( _error.severity() != SEVERITY_NULL ) { - err->AppendFromErrorArg( &_error ); + istringstream strtmp(Val); + err->GreaterSeverity(STEPread_content(strtmp)); + if(_error.severity() != SEVERITY_NULL) { + err->AppendFromErrorArg(&_error); } return err->severity(); } @@ -227,9 +248,10 @@ Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, /** updated to Technical Corrigendum. DAS 2/4/97 * This function does the following: */ -Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, - InstMgrBase * instances, const char * utype, - int addFileId, const char * currSch ) { +Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, + InstMgrBase *instances, const char *utype, + int addFileId, const char *currSch) +{ char c = '\0'; std::string tmp; @@ -246,19 +268,19 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, ** select types, then the text is passed down to each select in the utype ** parameter as STEPread is called on each contained select type.DAS 2/4/97 */ - if( utype ) { - if( SetUnderlyingType( CanBeSet( utype, currSch ) ) ) { + if(utype) { + if(SetUnderlyingType(CanBeSet(utype, currSch))) { // assign the value to the underlying type in >> ws; // skip white space - if( ( underlying_type->Type() == REFERENCE_TYPE ) && - ( underlying_type->NonRefType() == sdaiSELECT ) ) { + if((underlying_type->Type() == REFERENCE_TYPE) && + (underlying_type->NonRefType() == sdaiSELECT)) { // See comments below for a similar code segment. - STEPread_content( in, instances, 0, addFileId, currSch ); + STEPread_content(in, instances, 0, addFileId, currSch); } else { - STEPread_content( in, instances, utype, addFileId, currSch ); + STEPread_content(in, instances, utype, addFileId, currSch); } - err->AppendToDetailMsg( Error() ); - err->GreaterSeverity( severity() ); + err->AppendToDetailMsg(Error()); + err->GreaterSeverity(severity()); } return err->severity(); } @@ -283,11 +305,11 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, ** will cause the contained Select STEPread function to read it. DAS 2/4/97 */ - if( isalpha( c ) ) { // case B + if(isalpha(c)) { // case B int eot = 0; // end of token flag // token is a type name - get the type - while( ( c != '(' ) && in.good() ) { - if( !eot && !( eot = isspace( c ) ) ) + while((c != '(') && in.good()) { + if(!eot && !(eot = isspace(c))) // as long as eot hasn\'t been reached keep appending { tmp += c; @@ -296,7 +318,7 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, } // check for valid type and set the underlying type - if( SetUnderlyingType( CanBeSet( tmp.c_str(), currSch ) ) ) { + if(SetUnderlyingType(CanBeSet(tmp.c_str(), currSch))) { /** ** Assign the value to the underlying type. CanBeSet() is a ** slightly modified CanBe(). It ensures that a renamed select @@ -307,8 +329,8 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, ** case if "selX" appears first and is what we just read. */ in >> ws; // skip white space - if( ( underlying_type->Type() == REFERENCE_TYPE ) && - ( underlying_type->NonRefType() == sdaiSELECT ) ) { + if((underlying_type->Type() == REFERENCE_TYPE) && + (underlying_type->NonRefType() == sdaiSELECT)) { /** * This means (1) that the underlying type is itself a select ** (cond 2), and (2) it's not defined in the EXPRESS as a @@ -323,7 +345,7 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, ** would appear (according to TC) and we already read the value ** of sel1. If so, we pass the already-read value down. */ - STEPread_content( in, instances, 0, addFileId, currSch ); + STEPread_content(in, instances, 0, addFileId, currSch); } else { /** ** In most cases (see above note), we've already read the value @@ -331,19 +353,19 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, ** This also handles all other cases? other than the if part ** above and elements of type entity ref? */ - STEPread_content( in, instances, tmp.c_str(), addFileId, - currSch ); + STEPread_content(in, instances, tmp.c_str(), addFileId, + currSch); // STEPread_content uses the ErrorDesc data member from the // SDAI_Select class } - err->AppendToDetailMsg( Error() ); - err->GreaterSeverity( severity() ); + err->AppendToDetailMsg(Error()); + err->GreaterSeverity(severity()); in >> ws >> c; - if( c != ')' ) { + if(c != ')') { err->AppendToDetailMsg( - "Bad data or missing closing ')' for SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); - in.putback( c ); + "Bad data or missing closing ')' for SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); + in.putback(c); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -354,16 +376,16 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, #endif return err->severity(); } else { // ERROR -- the type wasn't one of the choices - if( !in.good() ) { - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + if(!in.good()) { + err->GreaterSeverity(SEVERITY_INPUT_ERROR); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_INPUT_ERROR; } else { err->AppendToDetailMsg( - "The type name for the SELECT type is not valid.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + "The type name for the SELECT type is not valid.\n"); + err->GreaterSeverity(SEVERITY_WARNING); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -380,10 +402,10 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, */ else { /// case A - switch( c ) { + switch(c) { case '$': nullify(); - err->GreaterSeverity( SEVERITY_INCOMPLETE ); + err->GreaterSeverity(SEVERITY_INCOMPLETE); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -392,9 +414,9 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, case ',': case '\0': // ERROR IN INPUT - in.putback( c ); - err->AppendToDetailMsg( "No value found for SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + in.putback(c); + err->AppendToDetailMsg("No value found for SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -402,44 +424,44 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, case '.': // assign enum base_type = ENUM_TYPE; - err->AppendToDetailMsg( "Invalid Enumeration, Logical, or Boolean value in SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg("Invalid Enumeration, Logical, or Boolean value in SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); break; - // set the underlying type - // call STEPread - // return + // set the underlying type + // call STEPread + // return case '\'': // assign string base_type = STRING_TYPE; - err->AppendToDetailMsg( "Invalid String value in SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg("Invalid String value in SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); break; case '"': // assign string base_type = BINARY_TYPE; - err->AppendToDetailMsg( "Invalid Binary value in SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg("Invalid Binary value in SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); break; case '#': base_type = ENTITY_TYPE; break; - // call STEPread_reference - // set the underlying type + // call STEPread_reference + // set the underlying type - // assign entity - // read the reference - // match type to underlying type - // assign the value - // set the underlying type + // assign entity + // read the reference + // match type to underlying type + // assign the value + // set the underlying type case '(': { - err->AppendToDetailMsg( "Invalid aggregate value in SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg("Invalid aggregate value in SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); char n; in >> n; - in.putback( n ); - if( isalpha( n ) ) { + in.putback(n); + if(isalpha(n)) { base_type = SELECT_TYPE; } else { base_type = AGGREGATE_TYPE; @@ -458,9 +480,9 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, case '8': case '9': case '-': - err->AppendToDetailMsg( "Invalid Integer or Real value in SELECT type.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); - if( CanBe( REAL_TYPE ) ) { + err->AppendToDetailMsg("Invalid Integer or Real value in SELECT type.\n"); + err->GreaterSeverity(SEVERITY_WARNING); + if(CanBe(REAL_TYPE)) { base_type = REAL_TYPE; } else { base_type = INTEGER_TYPE; @@ -470,54 +492,54 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, default: // ambiguous - ERROR: underlying type should have been set err->AppendToDetailMsg( - "type for SELECT could not be determined from value.\n" ); + "type for SELECT could not be determined from value.\n"); nullify(); - in.putback( c ); - err->GreaterSeverity( SEVERITY_WARNING ); + in.putback(c); + err->GreaterSeverity(SEVERITY_WARNING); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - in.putback( c ); + in.putback(c); // now the type descriptor should be derivable from the base_type // if it's not issue a warning - if( _type && !( IsUnique( base_type ) ) ) { - err->AppendToDetailMsg( "Value for SELECT will be assigned to first possible choice.\n" ); - err->GreaterSeverity( SEVERITY_USERMSG ); + if(_type && !(IsUnique(base_type))) { + err->AppendToDetailMsg("Value for SELECT will be assigned to first possible choice.\n"); + err->GreaterSeverity(SEVERITY_USERMSG); } - if( base_type == ENTITY_TYPE ) { + if(base_type == ENTITY_TYPE) { // you don't know if this is an ENTITY or a SELECT // have to do this here - not in STEPread_content - STEPentity * temp = - ReadEntityRef( in, err, ",)", instances, addFileId ); - if( temp && ( temp != ENTITY_NULL ) && AssignEntity( temp ) ) { + STEPentity *temp = + ReadEntityRef(in, err, ",)", instances, addFileId); + if(temp && (temp != ENTITY_NULL) && AssignEntity(temp)) { #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_NULL; } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n" ); + "Reference to entity that is not a valid type for SELECT.\n"); nullify(); - err->GreaterSeverity( SEVERITY_WARNING ); + err->GreaterSeverity(SEVERITY_WARNING); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - } else if( SetUnderlyingType( CanBe( base_type ) ) ) { - STEPread_content( in, instances, 0, addFileId ); + } else if(SetUnderlyingType(CanBe(base_type))) { + STEPread_content(in, instances, 0, addFileId); } else { // ERROR -- the type wasn't one of the choices err->AppendToDetailMsg( - "The type of the SELECT type is not valid.\n" ); - err->GreaterSeverity( SEVERITY_WARNING ); + "The type of the SELECT type is not valid.\n"); + err->GreaterSeverity(SEVERITY_WARNING); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -533,24 +555,25 @@ Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, /// updated to Technical Corrigendum DAS Feb 4, 1997 -void SDAI_Select::STEPwrite( ostream & out, const char * currSch ) const { - if( !exists() ) { +void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const +{ + if(!exists()) { out << "$"; return; } - switch( underlying_type->NonRefType() ) { + switch(underlying_type->NonRefType()) { case sdaiINSTANCE: { - STEPwrite_content( out ); + STEPwrite_content(out); break; } case sdaiSELECT: { // The name of a select is never written DAS 1/31/97 - if( underlying_type->Type() == REFERENCE_TYPE ) { + if(underlying_type->Type() == REFERENCE_TYPE) { std::string s; - out << StrToUpper( underlying_type->Name( currSch ), s ) << "("; - STEPwrite_content( out, currSch ); + out << StrToUpper(underlying_type->Name(currSch), s) << "("; + STEPwrite_content(out, currSch); out << ")"; } else { - STEPwrite_content( out, currSch ); + STEPwrite_content(out, currSch); } break; } @@ -567,7 +590,7 @@ void SDAI_Select::STEPwrite( ostream & out, const char * currSch ) const { case BAG_TYPE: case SET_TYPE: case LIST_TYPE: { - STEPwrite_verbose( out, currSch ); + STEPwrite_verbose(out, currSch); break; } case REFERENCE_TYPE: // this should never happen? DAS @@ -577,26 +600,30 @@ void SDAI_Select::STEPwrite( ostream & out, const char * currSch ) const { } } -void SDAI_Select::STEPwrite_verbose( ostream & out, const char * currSch ) const { +void SDAI_Select::STEPwrite_verbose(ostream &out, const char *currSch) const +{ std::string tmp; - out << StrToUpper( CurrentUnderlyingType()->Name( currSch ), tmp ) << "("; - STEPwrite_content( out ); + out << StrToUpper(CurrentUnderlyingType()->Name(currSch), tmp) << "("; + STEPwrite_content(out); out << ")"; } -const char * SDAI_Select::STEPwrite( std::string & s, const char * currSch ) const { +const char *SDAI_Select::STEPwrite(std::string &s, const char *currSch) const +{ ostringstream buf; - STEPwrite( buf, currSch ); + STEPwrite(buf, currSch); buf << ends; // add the terminating \0 char s = buf.str(); - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -bool SDAI_Select::set_null() { +bool SDAI_Select::set_null() +{ nullify(); return true; } -bool SDAI_Select::is_null() { - return ( !exists() ); +bool SDAI_Select::is_null() +{ + return (!exists()); } diff --git a/src/clstepcore/sdaiSelect.h b/src/clstepcore/sdaiSelect.h index 04307b1f4..c0c50ed42 100644 --- a/src/clstepcore/sdaiSelect.h +++ b/src/clstepcore/sdaiSelect.h @@ -17,32 +17,33 @@ /** ** \file sdaiSelect.h class definition for the select superclass SDAI_Select. **/ -class SC_CORE_EXPORT SDAI_Select { +class SC_CORE_EXPORT SDAI_Select +{ protected: - const SelectTypeDescriptor * _type; - const TypeDescriptor * underlying_type; + const SelectTypeDescriptor *_type; + const TypeDescriptor *underlying_type; BASE_TYPE base_type; // used by the subtypes // it looks like this member, val, is not used anywhere 9/27/96 - DAS SDAI_String val; ErrorDescriptor _error; - const TypeDescriptor * SetUnderlyingType( const TypeDescriptor * ); + const TypeDescriptor *SetUnderlyingType(const TypeDescriptor *); - const TypeDescriptor * CanBe( const char * ) const; - const TypeDescriptor * CanBe( BASE_TYPE ) const; - const TypeDescriptor * CanBe( const TypeDescriptor * td ) const; - const TypeDescriptor * CanBeSet( const char *, const char * ) const; + const TypeDescriptor *CanBe(const char *) const; + const TypeDescriptor *CanBe(BASE_TYPE) const; + const TypeDescriptor *CanBe(const TypeDescriptor *td) const; + const TypeDescriptor *CanBeSet(const char *, const char *) const; - int IsUnique( const BASE_TYPE bt ) const; + int IsUnique(const BASE_TYPE bt) const; - virtual const TypeDescriptor * AssignEntity( SDAI_Application_instance * se ) = 0; - virtual SDAI_Select * NewSelect() = 0; + virtual const TypeDescriptor *AssignEntity(SDAI_Application_instance *se) = 0; + virtual SDAI_Select *NewSelect() = 0; public: Severity severity() const; - Severity severity( Severity ); + Severity severity(Severity); std::string Error(); - void Error( const char * ); + void Error(const char *); // clears select's error void ClearError(); // clears error @@ -50,50 +51,50 @@ class SC_CORE_EXPORT SDAI_Select { virtual BASE_TYPE ValueType() const = 0; // constructors - SDAI_Select( const SelectTypeDescriptor * s = 0, - const TypeDescriptor * td = 0 ); - SDAI_Select( const SDAI_Select & other ); + SDAI_Select(const SelectTypeDescriptor *s = 0, + const TypeDescriptor *td = 0); + SDAI_Select(const SDAI_Select &other); virtual ~SDAI_Select(); // from SDAI binding SDAI_String UnderlyingTypeName() const; - const TypeDescriptor * CurrentUnderlyingType() const; + const TypeDescriptor *CurrentUnderlyingType() const; bool exists() const; void nullify(); - Severity SelectValidLevel( const char * attrValue, ErrorDescriptor * err, - InstMgrBase * im ); + Severity SelectValidLevel(const char *attrValue, ErrorDescriptor *err, + InstMgrBase *im); // reading and writing - const char * STEPwrite( std::string & s, const char * currSch = 0 ) const; - void STEPwrite( ostream & out = cout, const char * currSch = 0 ) const; + const char *STEPwrite(std::string &s, const char *currSch = 0) const; + void STEPwrite(ostream &out = cout, const char *currSch = 0) const; // IMS 8/2/95: added as part of new select implementation - virtual void STEPwrite_verbose( ostream & out = cout, const char * = 0 ) + virtual void STEPwrite_verbose(ostream &out = cout, const char * = 0) const; - virtual void STEPwrite_content( ostream & out, const char * = 0 ) const = 0; + virtual void STEPwrite_content(ostream &out, const char * = 0) const = 0; - Severity StrToVal( const char * val, const char * selectType, - ErrorDescriptor * err, InstMgrBase * instances = 0 ); - virtual Severity StrToVal_content( const char *, - InstMgrBase * instances = 0 ) = 0; + Severity StrToVal(const char *val, const char *selectType, + ErrorDescriptor *err, InstMgrBase *instances = 0); + virtual Severity StrToVal_content(const char *, + InstMgrBase *instances = 0) = 0; - Severity STEPread( istream & in, ErrorDescriptor * err, - InstMgrBase * instances = 0, const char * utype = 0, - int addFileId = 0, const char * = NULL ); + Severity STEPread(istream &in, ErrorDescriptor *err, + InstMgrBase *instances = 0, const char *utype = 0, + int addFileId = 0, const char * = NULL); // abstract function - virtual Severity STEPread_content( istream & in = cin, - InstMgrBase * instances = 0, - const char * utype = 0, - int addFileId = 0, - const char * currSch = 0 ) = 0; + virtual Severity STEPread_content(istream &in = cin, + InstMgrBase *instances = 0, + const char *utype = 0, + int addFileId = 0, + const char *currSch = 0) = 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 ); + virtual SDAI_Select &operator =(const SDAI_Select &other); //FIXME set_null always returns true. why not void?! bool set_null(); @@ -101,7 +102,7 @@ class SC_CORE_EXPORT SDAI_Select { }; /** end class **/ -typedef SDAI_Select * SDAI_Select_ptr; +typedef SDAI_Select *SDAI_Select_ptr; typedef SDAI_Select_ptr SDAI_Select_var; #endif diff --git a/src/clstepcore/selectTypeDescriptor.cc b/src/clstepcore/selectTypeDescriptor.cc index a7c0ad032..f4c9d1f6d 100644 --- a/src/clstepcore/selectTypeDescriptor.cc +++ b/src/clstepcore/selectTypeDescriptor.cc @@ -4,16 +4,18 @@ // SelectTypeDescriptor functions /////////////////////////////////////////////////////////////////////////////// -SDAI_Select * SelectTypeDescriptor::CreateSelect() { - if( CreateNewSelect ) { +SDAI_Select *SelectTypeDescriptor::CreateSelect() +{ + if(CreateNewSelect) { return CreateNewSelect(); } else { return 0; } } -const TypeDescriptor * SelectTypeDescriptor::IsA( const TypeDescriptor * other ) const { - return TypeDescriptor::IsA( other ); +const TypeDescriptor *SelectTypeDescriptor::IsA(const TypeDescriptor *other) const +{ + return TypeDescriptor::IsA(other); } /** @@ -21,15 +23,16 @@ const TypeDescriptor * SelectTypeDescriptor::IsA( const TypeDescriptor * other ) * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor * SelectTypeDescriptor::CanBe( const TypeDescriptor * other ) const { - if( this == other ) { +const TypeDescriptor *SelectTypeDescriptor::CanBe(const TypeDescriptor *other) const +{ + if(this == other) { return other; } - TypeDescItr elements( GetElements() ) ; - const TypeDescriptor * td = elements.NextTypeDesc(); - while( td ) { - if( td -> CanBe( other ) ) { + TypeDescItr elements(GetElements()) ; + const TypeDescriptor *td = elements.NextTypeDesc(); + while(td) { + if(td -> CanBe(other)) { return td; } td = elements.NextTypeDesc(); @@ -42,18 +45,19 @@ const TypeDescriptor * SelectTypeDescriptor::CanBe( const TypeDescriptor * other * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor * SelectTypeDescriptor::CanBe( const char * other ) const { - TypeDescItr elements( GetElements() ) ; - const TypeDescriptor * td = 0; +const TypeDescriptor *SelectTypeDescriptor::CanBe(const char *other) const +{ + TypeDescItr elements(GetElements()) ; + const TypeDescriptor *td = 0; // see if other is the select - if( !StrCmpIns( _name, other ) ) { + if(!StrCmpIns(_name, other)) { return this; } // see if other is one of the elements - while( ( td = elements.NextTypeDesc() ) ) { - if( td -> CanBe( other ) ) { + while((td = elements.NextTypeDesc())) { + if(td -> CanBe(other)) { return td; } } @@ -79,17 +83,18 @@ const TypeDescriptor * SelectTypeDescriptor::CanBe( const char * other ) const { * if schNm = a schema which USEs or REFERENCEs this and renames it (e.g., "USE * from XX (A as B)"). */ -const TypeDescriptor * SelectTypeDescriptor::CanBeSet( const char * other, const char * schNm ) const { - TypeDescItr elements( GetElements() ) ; - const TypeDescriptor * td = elements.NextTypeDesc(); +const TypeDescriptor *SelectTypeDescriptor::CanBeSet(const char *other, const char *schNm) const +{ + TypeDescItr elements(GetElements()) ; + const TypeDescriptor *td = elements.NextTypeDesc(); - while( td ) { - if( td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT ) { + while(td) { + if(td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT) { // Just look at this level, don't look at my items (see intro). - if( td->CurrName( other, schNm ) ) { + if(td->CurrName(other, schNm)) { return td; } - } else if( td->CanBeSet( other, schNm ) ) { + } else if(td->CanBeSet(other, schNm)) { return td; } td = elements.NextTypeDesc(); diff --git a/src/clstepcore/selectTypeDescriptor.h b/src/clstepcore/selectTypeDescriptor.h index 8dbfd1b19..bb491ca6d 100644 --- a/src/clstepcore/selectTypeDescriptor.h +++ b/src/clstepcore/selectTypeDescriptor.h @@ -3,49 +3,55 @@ #include "typeDescriptor.h" -typedef SDAI_Select * ( * SelectCreator )(); - -class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor { - -protected: - TypeDescriptorList _elements; // of TYPE_DESCRIPTOR - int _unique_elements; - -public: - - SelectCreator CreateNewSelect; - - void AssignSelectCreator( SelectCreator f = 0 ) { - CreateNewSelect = f; - } - - SDAI_Select * CreateSelect(); - - SelectTypeDescriptor( int b, const char * nm, PrimitiveType ft, - Schema * origSchema, - const char * d, SelectCreator f = 0 ) - : TypeDescriptor( nm, ft, origSchema, d ), - _unique_elements( b ), CreateNewSelect( f ) - { } - virtual ~SelectTypeDescriptor() { } - - TypeDescriptorList & Elements() { - return _elements; - } - const TypeDescriptorList & GetElements() const { - return _elements; - } - int UniqueElements() const { - return _unique_elements; - } - virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; - virtual const TypeDescriptor * IsA( const char * n ) const { - return TypeDescriptor::IsA( n ); - } - virtual const TypeDescriptor * CanBe( const TypeDescriptor * ) const; - virtual const TypeDescriptor * CanBe( const char * n ) const; - virtual const TypeDescriptor * CanBeSet( const char *, const char * ) - const; +typedef SDAI_Select *(* SelectCreator)(); + +class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor +{ + + protected: + TypeDescriptorList _elements; // of TYPE_DESCRIPTOR + int _unique_elements; + + public: + + SelectCreator CreateNewSelect; + + void AssignSelectCreator(SelectCreator f = 0) + { + CreateNewSelect = f; + } + + SDAI_Select *CreateSelect(); + + SelectTypeDescriptor(int b, const char *nm, PrimitiveType ft, + Schema *origSchema, + const char *d, SelectCreator f = 0) + : TypeDescriptor(nm, ft, origSchema, d), + _unique_elements(b), CreateNewSelect(f) + { } + virtual ~SelectTypeDescriptor() { } + + TypeDescriptorList &Elements() + { + return _elements; + } + const TypeDescriptorList &GetElements() const + { + return _elements; + } + int UniqueElements() const + { + return _unique_elements; + } + virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; + virtual const TypeDescriptor *IsA(const char *n) const + { + return TypeDescriptor::IsA(n); + } + virtual const TypeDescriptor *CanBe(const TypeDescriptor *) const; + virtual const TypeDescriptor *CanBe(const char *n) const; + virtual const TypeDescriptor *CanBeSet(const char *, const char *) + const; }; #endif //SELECTTYPEDESCRIPTOR_H diff --git a/src/clstepcore/stringTypeDescriptor.h b/src/clstepcore/stringTypeDescriptor.h index b328dafaa..aff628617 100644 --- a/src/clstepcore/stringTypeDescriptor.h +++ b/src/clstepcore/stringTypeDescriptor.h @@ -3,35 +3,42 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor { - -protected: - SDAI_Integer _width; // OPTIONAL - SDAI_LOGICAL _fixedSize; -public: - - StringTypeDescriptor( ) : _fixedSize( "UNKNOWN_TYPE" ) { - _width = 0; - } - virtual ~StringTypeDescriptor() { } - - - SDAI_Integer Width() { - return _width; - } - void Width( SDAI_Integer w ) { - _width = w; - } - - SDAI_LOGICAL & FixedSize() { - return _fixedSize; - } - void FixedSize( SDAI_LOGICAL fs ) { - _fixedSize.put( fs.asInt() ); - } - void FixedSize( Logical fs ) { - _fixedSize.put( fs ); - } +class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor +{ + + protected: + SDAI_Integer _width; // OPTIONAL + SDAI_LOGICAL _fixedSize; + public: + + StringTypeDescriptor() : _fixedSize("UNKNOWN_TYPE") + { + _width = 0; + } + virtual ~StringTypeDescriptor() { } + + + SDAI_Integer Width() + { + return _width; + } + void Width(SDAI_Integer w) + { + _width = w; + } + + SDAI_LOGICAL &FixedSize() + { + return _fixedSize; + } + void FixedSize(SDAI_LOGICAL fs) + { + _fixedSize.put(fs.asInt()); + } + void FixedSize(Logical fs) + { + _fixedSize.put(fs); + } }; #endif //STRINGTYPEDESCRIPTOR_H diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index bfe73dc17..9270ad3a0 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -10,63 +10,70 @@ * * 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; +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(); } - if( sit.empty() ) { - isempty = true; - } else { - invIter = new InverseAItr( &( sit.current()->InverseAttr() ) ); - nextInv = invIter->NextInverse_attribute(); - if( !nextInv ) { - next(); + 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; + ~superInvAttrIter() + { + if(invIter) { + delete invIter; + invIter = 0; + } } - return sit.current(); - } - bool empty() { - if( isempty ) { - return true; + const EntityDescriptor *currentEDesc() + { + if(isempty) { + return NULL; + } + return sit.current(); } - return ( !sit.hasNext() && !nextInv ); - } - const Inverse_attribute * next() { - if( isempty ) { - return NULL; + bool empty() + { + if(isempty) { + return true; + } + return (!sit.hasNext() && !nextInv); } - 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() ) ); + 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; } - return ia; - } }; #endif //SUPERINVATTRITER_H diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index f557d7c72..f06028309 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -8,76 +8,77 @@ #include "ExpDict.h" #include -int main( int /*argc*/, char ** /*argv*/ ) { - Schema * a = 0; - Logical b( LFalse ); +int main(int /*argc*/, char ** /*argv*/) +{ + Schema *a = 0; + Logical b(LFalse); char buf[20][2] = { { '\0' } }; int i, d; - EntityDescriptor * descriptors[20], ed( "ed", a, b, b ); + EntityDescriptor *descriptors[20], ed("ed", a, b, b); bool failed = false; //create 20 more ed's - for( i = 0; i < 20; i++ ) { + for(i = 0; i < 20; i++) { buf[i][0] = 'a' + i; //ed names are 1st 20 lowercase chars - descriptors[i] = new EntityDescriptor( buf[i], a, b, b ); + descriptors[i] = new EntityDescriptor(buf[i], a, b, b); } //link the ed's together - ed.AddSupertype( descriptors[0] ); - for( i = 0; i < 10; i++ ) { - descriptors[i]->AddSupertype( descriptors[i + 1] ); + ed.AddSupertype(descriptors[0]); + for(i = 0; i < 10; i++) { + descriptors[i]->AddSupertype(descriptors[i + 1]); } - for( i = 11; i < 20; i++ ) { - descriptors[5]->AddSupertype( descriptors[i] ); + for(i = 11; i < 20; i++) { + descriptors[5]->AddSupertype(descriptors[i]); } //print the ed's i = 0; d = 0; std::cout << "head, name " << ed.Name() << std::endl; - supertypesIterator iter( &ed ); - for( ; !iter.empty(); iter++ ) { - if( !iter.hasNext() ) { //hasNext should be false once and once only + supertypesIterator iter(&ed); + for(; !iter.empty(); iter++) { + if(!iter.hasNext()) { //hasNext should be false once and once only i++; } - if( iter.depth() > d ) { + if(iter.depth() > d) { d = iter.depth(); } - std::cout << "position " << std::setw( 3 ) << iter.pos() << ", name " << std::setw( iter.depth() ) << iter->Name() << std::endl; + std::cout << "position " << std::setw(3) << iter.pos() << ", name " << std::setw(iter.depth()) << iter->Name() << std::endl; } - if( iter.pos() == 20 ) { + if(iter.pos() == 20) { std::cout << "success" << std::endl; } else { std::cout << "expected 20, got " << iter.pos() << std::endl; failed = true; } - if( i != 1 ) { + if(i != 1) { std::cout << "problem with hasNext(): expected 1, got " << i << std::endl; failed = true; } - if( d != 11 ) { + if(d != 11) { std::cout << "problem with depth(): expected 11, got " << d << std::endl; failed = true; } - supertypesIterator it2( &ed ), it3, uninitializedIter; + supertypesIterator it2(&ed), it3, uninitializedIter; it3 = it2; //test operator==, operator!= - if( ( it2 == iter ) || ( it2 == uninitializedIter ) ) { + if((it2 == iter) || (it2 == uninitializedIter)) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 1st" << std::endl; } - if( !( it2 == it3 ) ) { + if(!(it2 == it3)) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 2nd" << std::endl; } - if( !( it2 != iter ) ) { + if(!(it2 != iter)) { std::cout << "problem with operator!=" << std::endl; failed = true; } else { @@ -88,19 +89,19 @@ int main( int /*argc*/, char ** /*argv*/ ) { ++it3; // operator> - if( ( it3 > it2 ) != LTrue ) { + if((it3 > it2) != LTrue) { std::cout << "problem with operator>, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator> passed LTrue" << std::endl; } - if( ( uninitializedIter > it2 ) != LUnknown ) { + if((uninitializedIter > it2) != LUnknown) { std::cout << "problem with operator>, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator> passed LUnknown" << std::endl; } - if( ( it2 > it2 ) != LFalse ) { + if((it2 > it2) != LFalse) { std::cout << "problem with operator>, expected LFalse" << std::endl; failed = true; } else { @@ -108,19 +109,19 @@ int main( int /*argc*/, char ** /*argv*/ ) { } // operator< - if( ( it2 < it3 ) != LTrue ) { + if((it2 < it3) != LTrue) { std::cout << "problem with operator<, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator< passed LTrue" << std::endl; } - if( ( it2 < uninitializedIter ) != LUnknown ) { + if((it2 < uninitializedIter) != LUnknown) { std::cout << "problem with operator<, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator< passed LUnknown" << std::endl; } - if( ( it2 < it2 ) != LFalse ) { + if((it2 < it2) != LFalse) { std::cout << "problem with operator<, expected LFalse" << std::endl; failed = true; } else { @@ -128,19 +129,19 @@ int main( int /*argc*/, char ** /*argv*/ ) { } // operator<= - if( ( it2 <= it2 ) != LTrue ) { + if((it2 <= it2) != LTrue) { std::cout << "problem with operator<=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator<= passed LTrue" << std::endl; } - if( ( it2 <= uninitializedIter ) != LUnknown ) { + if((it2 <= uninitializedIter) != LUnknown) { std::cout << "problem with operator<=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator<= passed LUnknown" << std::endl; } - if( ( it3 <= it2 ) != LFalse ) { + if((it3 <= it2) != LFalse) { std::cout << "problem with operator<=, expected LFalse" << std::endl; failed = true; } else { @@ -148,19 +149,19 @@ int main( int /*argc*/, char ** /*argv*/ ) { } // operator>= - if( ( it2 >= it2 ) != LTrue ) { + if((it2 >= it2) != LTrue) { std::cout << "problem with operator>=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator>= passed LTrue" << std::endl; } - if( ( it2 >= uninitializedIter ) != LUnknown ) { + if((it2 >= uninitializedIter) != LUnknown) { std::cout << "problem with operator>=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator>= passed LUnknown" << std::endl; } - if( ( it2 >= it3 ) != LFalse ) { + if((it2 >= it3) != LFalse) { std::cout << "problem with operator>=, expected LFalse" << std::endl; failed = true; } else { @@ -169,19 +170,19 @@ int main( int /*argc*/, char ** /*argv*/ ) { /// still need operator* >= it3.reset(); - const EntityDescriptor * e = *it3; - const char * n = "a"; - if( strcmp( e->Name(), n ) ) { + const EntityDescriptor *e = *it3; + const char *n = "a"; + if(strcmp(e->Name(), n)) { std::cout << "problem with operator*" << std::endl; failed = true; } else { std::cout << "operator* passed " << std::endl; } - if( failed ) { - exit( EXIT_FAILURE ); + if(failed) { + exit(EXIT_FAILURE); } else { - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } } /* output: diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index 0c96c5798..0cd86b654 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -7,13 +7,14 @@ EntityDescriptor *ed = 0; TypeDescriptor *td; Schema *sch = 0; -int main () { +int main() +{ SDAI_String _description; - sch = new Schema( "Ifc2x3" ); - td = new TypeDescriptor( "Ifctext", sdaiSTRING, sch, "STRING" ); - ed = new EntityDescriptor( "Ifcroot", sch, LTrue, LFalse ); - ad = new AttrDescriptor( "description", td, LTrue, LFalse, AttrType_Explicit, *ed ); - ed->AddExplicitAttr( ad ); + sch = new Schema("Ifc2x3"); + td = new TypeDescriptor("Ifctext", sdaiSTRING, sch, "STRING"); + ed = new EntityDescriptor("Ifcroot", sch, LTrue, LFalse); + ad = new AttrDescriptor("description", td, LTrue, LFalse, AttrType_Explicit, *ed); + ed->AddExplicitAttr(ad); STEPattribute *a = new STEPattribute(*ad, &_description); a -> set_null(); delete a; diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index fcb6cde4d..e65969097 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -12,58 +12,82 @@ using namespace std; -class TestSdaiSelect: public SDAI_Select { +class TestSdaiSelect: public SDAI_Select +{ public: - TestSdaiSelect( SelectTypeDescriptor * s, TypeDescriptor * t, BASE_TYPE b, SDAI_String v, ErrorDescriptor e ): - SDAI_Select( s, t ) { + 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 ); + TestSdaiSelect &operator=(const TestSdaiSelect &other) + { + SDAI_Select::operator=(other); return *this; } - SDAI_Select& operator=( const SDAI_Select& other ) { - SDAI_Select::operator=( other ); + 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 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() ); + 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; + 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" ); +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 ); + 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 ) ) { + if(s2.compare(&s, &t, b, &v, &e)) { return true; } else { cerr << __FILE__ << ":" << __LINE__ << " - error: test for SDAI_Select::operator= failed" << endl; @@ -71,14 +95,15 @@ bool testOperatorEq() { } } -int main( int /*argc*/, char ** /*argv*/ ) { +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 ); + if(pass) { + exit(EXIT_SUCCESS); } else { - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } } diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index abd396816..8d2fba7ab 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -6,24 +6,25 @@ /// test copying a STEPattribute; returns true on success -bool testCopy( STEPattribute & attr, const char * desc ) { +bool testCopy(STEPattribute &attr, const char *desc) +{ bool pass = true; STEPattribute b = attr; STEPattribute c; - if( !( attr == attr ) ) { + if(!(attr == attr)) { std::cerr << "test class initialization failed " << desc << std::endl; pass = false; } - if( !( attr == b ) ) { + if(!(attr == b)) { std::cerr << "assignment operator failed " << desc << std::endl; pass = false; } - c.ShallowCopy( & attr ); - if( !( attr == c ) ) { + c.ShallowCopy(& attr); + if(!(attr == c)) { std::cerr << "ShallowCopy() failed " << desc << std::endl; pass = false; } @@ -31,43 +32,45 @@ bool testCopy( STEPattribute & attr, const char * desc ) { return pass; } -bool testEqu( const STEPattribute & a1, const STEPattribute & a2, bool invert, const char * desc ) { - bool pass = ( invert ? ( !( a1 == a2 ) ) : ( a1 == a2 ) ); - if( !pass ) { +bool testEqu(const STEPattribute &a1, const STEPattribute &a2, bool invert, const char *desc) +{ + bool pass = (invert ? (!(a1 == a2)) : (a1 == a2)); + if(!pass) { std::cerr << "Comparison test " << desc << " failed." << std::endl; } return pass; } -int main( int /*argc*/, char ** /*argv*/ ) { +int main(int /*argc*/, char ** /*argv*/) +{ bool pass = true; - EntityDescriptor ed( "ename", 0, LFalse, LFalse ); + EntityDescriptor ed("ename", 0, LFalse, LFalse); // used to test copying without operator new - TypeDescriptor tdi( "tint", sdaiINTEGER, 0, "int" ); - AttrDescriptor adi( "aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed ); + TypeDescriptor tdi("tint", sdaiINTEGER, 0, "int"); + AttrDescriptor adi("aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed); SDAI_Integer sint = 1234L, s2int = 123L; - STEPattribute ai( adi, & sint ); + STEPattribute ai(adi, & sint); //test copying with operator new (SDAI_Logical requires new) - TypeDescriptor tdl( "tlog", sdaiLOGICAL, 0, "str" ); - AttrDescriptor adl( "alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed ); - SDAI_LOGICAL slog( LTrue ); - STEPattribute al( adl, & slog ); + TypeDescriptor tdl("tlog", sdaiLOGICAL, 0, "str"); + AttrDescriptor adl("alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed); + SDAI_LOGICAL slog(LTrue); + STEPattribute al(adl, & slog); - pass &= testCopy( ai, "without operator new" ); - pass &= testCopy( al, "with operator new" ); + pass &= testCopy(ai, "without operator new"); + pass &= testCopy(al, "with operator new"); - pass &= testEqu( al, al, false, "LOGICAL ==" ); - pass &= testEqu( ai, ai, false, "int ==" ); - pass &= testEqu( ai, al, true, "int != LOGICAL" ); + pass &= testEqu(al, al, false, "LOGICAL =="); + pass &= testEqu(ai, ai, false, "int =="); + pass &= testEqu(ai, al, true, "int != LOGICAL"); - STEPattribute aii( adi, & s2int ); - pass &= testEqu( ai, aii, true, "ints !=" ); + STEPattribute aii(adi, & s2int); + pass &= testEqu(ai, aii, true, "ints !="); - if( pass ) { - exit( EXIT_SUCCESS ); + if(pass) { + exit(EXIT_SUCCESS); } - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 145af7699..24a5a3516 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -15,8 +15,8 @@ #include "sc_memmgr.h" // Local function prototypes: -static EntList * firstCandidate( EntList * ); -static EntList * nextCandidate( EntList * ); +static EntList *firstCandidate(EntList *); +static EntList *nextCandidate(EntList *); /** * Loops backwards through the children of this, recursively searching for @@ -28,17 +28,18 @@ static EntList * nextCandidate( EntList * ); * (reasons discussed in notes, 10/17). This function is the tryNext() * for AND and ANDOR; the OR version is redefined. */ -MatchType MultList::tryNext( EntNode * ents ) { +MatchType MultList::tryNext(EntNode *ents) +{ MatchType retval; - EntList * child = getLast(); + EntList *child = getLast(); - child = firstCandidate( child ); - while( child != NULL ) { - if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { + child = firstCandidate(child); + while(child != NULL) { + if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { // We're done - a good solution was found. return MATCHALL; } - if( retval == NEWCHOICE ) { + if(retval == NEWCHOICE) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -46,14 +47,14 @@ MatchType MultList::tryNext( EntNode * ents ) { // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while( ( child = nextCandidate( child ) ) != NULL ) { - if( child->acceptChoice( ents ) && ents->allMarked() ) { + while((child = nextCandidate(child)) != NULL) { + if(child->acceptChoice(ents) && ents->allMarked()) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate( child->prev ); + child = firstCandidate(child->prev); } // If we got here, we didn't find any new OR choices: return NOMORE; @@ -64,17 +65,18 @@ MatchType MultList::tryNext( EntNode * ents ) { * choices below it. The acceptable choices are described in commenting * below. */ -static EntList * firstCandidate( EntList * child ) { - EntList * ent = child->lastNot( SIMPLE ); +static EntList *firstCandidate(EntList *child) +{ + EntList *ent = child->lastNot(SIMPLE); - while( ent != NULL ) { - if( ent->viableVal() >= MATCHSOME ) { + while(ent != NULL) { + if(ent->viableVal() >= MATCHSOME) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot( SIMPLE ); + ent = ent->prevNot(SIMPLE); } return ent; } @@ -82,14 +84,15 @@ static EntList * firstCandidate( EntList * child ) { /** * Same as prev function, searches forwards from ent after child. */ -static EntList * nextCandidate( EntList * child ) { - EntList * ent = child->nextNot( SIMPLE ); +static EntList *nextCandidate(EntList *child) +{ + EntList *ent = child->nextNot(SIMPLE); - while( ent != NULL ) { - if( ent->viableVal() >= MATCHSOME ) { + while(ent != NULL) { + if(ent->viableVal() >= MATCHSOME) { return ent; } - ent = ent->nextNot( SIMPLE ); + ent = ent->nextNot(SIMPLE); } return ent; } @@ -99,27 +102,28 @@ static EntList * nextCandidate( EntList * child ) { * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ -MatchType OrList::tryNext( EntNode * ents ) { - EntList * child; +MatchType OrList::tryNext(EntNode *ents) +{ + EntList *child; - if( choice == LISTEND ) { + if(choice == LISTEND) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild( choice ); - if( child->multiple() ) { + child = getChild(choice); + if(child->multiple()) { // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - MatchType retval; - retval = ( ( MultList * )child )->tryNext( ents ); - if( retval == MATCHALL ) { + MatchType retval; + retval = ((MultList *)child)->tryNext(ents); + if(retval == MATCHALL) { return MATCHALL; } - if( retval == NEWCHOICE ) { + if(retval == NEWCHOICE) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -130,8 +134,8 @@ MatchType OrList::tryNext( EntNode * ents ) { // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll( ents ); - if( choiceCount == 1 ) { + child->unmarkAll(ents); + if(choiceCount == 1) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -140,8 +144,8 @@ MatchType OrList::tryNext( EntNode * ents ) { } // Otherwise, try our next: - if( acceptNextChoice( ents ) ) { - if( ents->allMarked() ) { + if(acceptNextChoice(ents)) { + if(ents->allMarked()) { return MATCHALL; } return NEWCHOICE; diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index e37d931bb..7b207ea89 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -1,20 +1,23 @@ #include "typeDescriptor.h" -TypeDescriptor::TypeDescriptor( ) - : _name( 0 ), altNames( 0 ), _fundamentalType( UNKNOWN_TYPE ), - _originatingSchema( 0 ), _referentType( 0 ), _description( 0 ), _where_rules( 0 ) { +TypeDescriptor::TypeDescriptor() + : _name(0), altNames(0), _fundamentalType(UNKNOWN_TYPE), + _originatingSchema(0), _referentType(0), _description(0), _where_rules(0) +{ } TypeDescriptor::TypeDescriptor -( const char * nm, PrimitiveType ft, Schema * origSchema, - const char * d ) - : _name( nm ), altNames( 0 ), _fundamentalType( ft ), - _originatingSchema( origSchema ), _referentType( 0 ), _description( d ), - _where_rules( 0 ) { +(const char *nm, PrimitiveType ft, Schema *origSchema, + const char *d) + : _name(nm), altNames(0), _fundamentalType(ft), + _originatingSchema(origSchema), _referentType(0), _description(d), + _where_rules(0) +{ } -TypeDescriptor::~TypeDescriptor() { - if( _where_rules ) { +TypeDescriptor::~TypeDescriptor() +{ + if(_where_rules) { delete _where_rules; } } @@ -29,11 +32,12 @@ TypeDescriptor::~TypeDescriptor() { * and returns the new name if found. (See header comments to function * SchRename::rename().) */ -const char * TypeDescriptor::Name( const char * schnm ) const { - if( schnm == NULL ) { +const char *TypeDescriptor::Name(const char *schnm) const +{ + if(schnm == NULL) { return _name; } - if( altNames && altNames->rename( schnm, ( char * )_altname ) ) { + if(altNames && altNames->rename(schnm, (char *)_altname)) { // If our altNames list has an alternate for schnm, copy it into // _altname, and return it: return _altname; @@ -41,18 +45,20 @@ const char * TypeDescriptor::Name( const char * schnm ) const { return _name; } -const char * TypeDescriptor::BaseTypeName() const { +const char *TypeDescriptor::BaseTypeName() const +{ return BaseTypeDescriptor() ? BaseTypeDescriptor() -> Name() : 0; } -const TypeDescriptor * TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const { - switch( NonRefType() ) { +const TypeDescriptor *TypeDescriptor::BaseTypeIsA(const TypeDescriptor *td) const +{ + switch(NonRefType()) { case AGGREGATE_TYPE: - return AggrElemTypeDescriptor() -> IsA( td ); + return AggrElemTypeDescriptor() -> IsA(td); case ENTITY_TYPE: case SELECT_TYPE: default: - return IsA( td ); + return IsA(td); } } @@ -64,37 +70,41 @@ const TypeDescriptor * TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) * case if schNm USEs or REFERENCEs type and renames it in the process * (e.g., "USE (X as Y)". */ -bool TypeDescriptor::CurrName( const char * other, const char * schNm ) const { - if( !schNm || *schNm == '\0' ) { +bool TypeDescriptor::CurrName(const char *other, const char *schNm) const +{ + if(!schNm || *schNm == '\0') { // If there's no current schema, accept any possible name of this. // (I.e., accept its actual name or any substitute): - return ( PossName( other ) ); + return (PossName(other)); } - if( altNames && altNames->rename( schNm, ( char * )_altname ) ) { + if(altNames && altNames->rename(schNm, (char *)_altname)) { // If we have a different name when the current schema = schNm, then // other better = the alt name. - return ( !StrCmpIns( _altname, other ) ); + return (!StrCmpIns(_altname, other)); } else { // If we have no desginated alternate name when the current schema = // schNm, other must = our _name. - return ( OurName( other ) ); + return (OurName(other)); } } /** * return true if nm is either our name or one of the possible alternates. */ -bool TypeDescriptor::PossName( const char * nm ) const { - return ( OurName( nm ) || AltName( nm ) ); +bool TypeDescriptor::PossName(const char *nm) const +{ + return (OurName(nm) || AltName(nm)); } -bool TypeDescriptor::OurName( const char * nm ) const { - return !StrCmpIns( nm, _name ); +bool TypeDescriptor::OurName(const char *nm) const +{ + return !StrCmpIns(nm, _name); } -bool TypeDescriptor::AltName( const char * nm ) const { - if( altNames ) { - return ( altNames->choice( nm ) ); +bool TypeDescriptor::AltName(const char *nm) const +{ + if(altNames) { + return (altNames->choice(nm)); } return false; } @@ -103,16 +113,17 @@ bool TypeDescriptor::AltName( const char * nm ) const { * Creates a SchRename consisting of schnm & newnm. Places it in alphabe- * tical order in this's altNames list. */ -void TypeDescriptor::addAltName( const char * schnm, const char * newnm ) { - SchRename * newpair = new SchRename( schnm, newnm ), - *node = ( SchRename * )altNames, *prev = NULL; +void TypeDescriptor::addAltName(const char *schnm, const char *newnm) +{ + SchRename *newpair = new SchRename(schnm, newnm), + *node = (SchRename *)altNames, *prev = NULL; - while( node && *node < *newpair ) { + while(node && *node < *newpair) { prev = node; node = node->next; } newpair->next = node; // node may = NULL - if( prev ) { + if(prev) { // Will be the case if new node should not be first (and above while // loop was entered). prev->next = newpair; @@ -122,67 +133,69 @@ void TypeDescriptor::addAltName( const char * schnm, const char * newnm ) { } } -void TypeDescriptor::AttrTypeName( std::string & buf, const char * schnm ) const { - const char * sn = Name( schnm ); - if( sn ) { - StrToLower( sn , buf ); +void TypeDescriptor::AttrTypeName(std::string &buf, const char *schnm) const +{ + const char *sn = Name(schnm); + if(sn) { + StrToLower(sn, buf); } else { buf = _description; } } -const char * TypeDescriptor::GenerateExpress( std::string & buf ) const { +const char *TypeDescriptor::GenerateExpress(std::string &buf) const +{ char tmp[BUFSIZ]; buf = "TYPE "; - buf.append( StrToLower( Name(), tmp ) ); - buf.append( " = " ); - const char * desc = Description(); - const char * ptr = desc; - - while( *ptr != '\0' ) { - if( *ptr == ',' ) { - buf.append( ",\n " ); - } else if( *ptr == '(' ) { - buf.append( "\n (" ); - } else if( isupper( *ptr ) ) { - buf += ( char )tolower( *ptr ); + buf.append(StrToLower(Name(), tmp)); + buf.append(" = "); + const char *desc = Description(); + const char *ptr = desc; + + while(*ptr != '\0') { + if(*ptr == ',') { + buf.append(",\n "); + } else if(*ptr == '(') { + buf.append("\n ("); + } else if(isupper(*ptr)) { + buf += (char)tolower(*ptr); } else { buf += *ptr; } ptr++; } - buf.append( ";\n" ); + buf.append(";\n"); /////////////// // count is # of WHERE rules - if( _where_rules != 0 ) { + if(_where_rules != 0) { int all_comments = 1; int count = _where_rules->Count(); - for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule - if( !( *( _where_rules ) )[i]->_label.size() ) { + for(int i = 0; i < count; i++) { // print out each UNIQUE rule + if(!(*(_where_rules))[i]->_label.size()) { all_comments = 0; } } - if( all_comments ) { - buf.append( " (* WHERE *)\n" ); + if(all_comments) { + buf.append(" (* WHERE *)\n"); } else { - buf.append( " WHERE\n" ); + buf.append(" WHERE\n"); } - for( int i = 0; i < count; i++ ) { // print out each WHERE rule - if( !( *( _where_rules ) )[i]->_comment.empty() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->comment_() ); + for(int i = 0; i < count; i++) { // print out each WHERE rule + if(!(*(_where_rules))[i]->_comment.empty()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->comment_()); } - if( ( *( _where_rules ) )[i]->_label.size() ) { - buf.append( " " ); - buf.append( ( *( _where_rules ) )[i]->label_() ); + if((*(_where_rules))[i]->_label.size()) { + buf.append(" "); + buf.append((*(_where_rules))[i]->label_()); } } } - buf.append( "END_TYPE;\n" ); - return const_cast( buf.c_str() ); + buf.append("END_TYPE;\n"); + return const_cast(buf.c_str()); } /** @@ -192,106 +205,107 @@ const char * TypeDescriptor::GenerateExpress( std::string & buf ) const { * e.g. if the description contains a TYPE name it will also * be explained. */ -const char * TypeDescriptor::TypeString( std::string & s ) const { - switch( Type() ) { +const char *TypeDescriptor::TypeString(std::string &s) const +{ + switch(Type()) { case REFERENCE_TYPE: - if( Name() ) { - s.append( "TYPE " ); - s.append( Name() ); - s.append( " = " ); + if(Name()) { + s.append("TYPE "); + s.append(Name()); + s.append(" = "); } - if( Description() ) { - s.append( Description() ); + if(Description()) { + s.append(Description()); } - if( ReferentType() ) { - s.append( " -- " ); + if(ReferentType()) { + s.append(" -- "); std::string tmp; - s.append( ReferentType()->TypeString( tmp ) ); + s.append(ReferentType()->TypeString(tmp)); } - return const_cast( s.c_str() ); + return const_cast(s.c_str()); case INTEGER_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Integer" ); + s.append("Integer"); break; case STRING_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "String" ); + s.append("String"); break; case REAL_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Real" ); + s.append("Real"); break; case ENUM_TYPE: s = "Enumeration: "; - if( Name() ) { - s.append( "TYPE " ); - s.append( Name() ); - s.append( " = " ); + if(Name()) { + s.append("TYPE "); + s.append(Name()); + s.append(" = "); } - if( Description() ) { - s.append( Description() ); + if(Description()) { + s.append(Description()); } break; case BOOLEAN_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Boolean: F, T" ); + s.append("Boolean: F, T"); break; case LOGICAL_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Logical: F, T, U" ); + s.append("Logical: F, T, U"); break; case NUMBER_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Number" ); + s.append("Number"); break; case BINARY_TYPE: s.clear(); - if( _referentType != 0 ) { + if(_referentType != 0) { s = "TYPE "; - s.append( Name() ); - s.append( " = " ); + s.append(Name()); + s.append(" = "); } - s.append( "Binary" ); + s.append("Binary"); break; case ENTITY_TYPE: s = "Entity: "; - if( Name() ) { - s.append( Name() ); + if(Name()) { + s.append(Name()); } break; case AGGREGATE_TYPE: @@ -300,39 +314,41 @@ const char * TypeDescriptor::TypeString( std::string & s ) const { case SET_TYPE: // DAS case LIST_TYPE: // DAS s = Description(); - if( ReferentType() ) { - s.append( " -- " ); + if(ReferentType()) { + s.append(" -- "); std::string tmp; - s.append( ReferentType()->TypeString( tmp ) ); + s.append(ReferentType()->TypeString(tmp)); } break; case SELECT_TYPE: - s.append( Description() ); + s.append(Description()); break; case GENERIC_TYPE: case UNKNOWN_TYPE: s = "Unknown"; break; } // end switch - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const TypeDescriptor * TypeDescriptor::IsA( const TypeDescriptor * other ) const { - if( this == other ) { +const TypeDescriptor *TypeDescriptor::IsA(const TypeDescriptor *other) const +{ + if(this == other) { return other; } return 0; } -const TypeDescriptor * TypeDescriptor::IsA( const char * other ) const { - if( !Name() ) { +const TypeDescriptor *TypeDescriptor::IsA(const char *other) const +{ + if(!Name()) { return 0; } - if( !StrCmpIns( _name, other ) ) { // this is the type + if(!StrCmpIns(_name, other)) { // this is the type return this; } - return ( ReferentType() ? ReferentType() -> IsA( other ) : 0 ); + return (ReferentType() ? ReferentType() -> IsA(other) : 0); } /** @@ -344,20 +360,22 @@ const TypeDescriptor * TypeDescriptor::IsA( const char * other ) const { * an element by calling AggrElemType(). Select types * would work the same? */ -PrimitiveType TypeDescriptor::NonRefType() const { - const TypeDescriptor * td = NonRefTypeDescriptor(); - if( td ) { +PrimitiveType TypeDescriptor::NonRefType() const +{ + const TypeDescriptor *td = NonRefTypeDescriptor(); + if(td) { return td->FundamentalType(); } return UNKNOWN_TYPE; } -const TypeDescriptor * TypeDescriptor::NonRefTypeDescriptor() const { - const TypeDescriptor * td = this; +const TypeDescriptor *TypeDescriptor::NonRefTypeDescriptor() const +{ + const TypeDescriptor *td = this; - while( td->ReferentType() ) { - if( td->Type() != REFERENCE_TYPE ) { + while(td->ReferentType()) { + if(td->Type() != REFERENCE_TYPE) { return td; } td = td->ReferentType(); @@ -367,8 +385,9 @@ const TypeDescriptor * TypeDescriptor::NonRefTypeDescriptor() const { } /// This returns the PrimitiveType of the first non-aggregate element of an aggregate -int TypeDescriptor::IsAggrType() const { - switch( NonRefType() ) { +int TypeDescriptor::IsAggrType() const +{ + switch(NonRefType()) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS @@ -381,18 +400,20 @@ int TypeDescriptor::IsAggrType() const { } } -PrimitiveType TypeDescriptor::AggrElemType() const { - const TypeDescriptor * aggrElemTD = AggrElemTypeDescriptor(); - if( aggrElemTD ) { +PrimitiveType TypeDescriptor::AggrElemType() const +{ + const TypeDescriptor *aggrElemTD = AggrElemTypeDescriptor(); + if(aggrElemTD) { return aggrElemTD->Type(); } return UNKNOWN_TYPE; } -const TypeDescriptor * TypeDescriptor::AggrElemTypeDescriptor() const { - const TypeDescriptor * aggrTD = NonRefTypeDescriptor(); - const TypeDescriptor * aggrElemTD = aggrTD->ReferentType(); - if( aggrElemTD ) { +const TypeDescriptor *TypeDescriptor::AggrElemTypeDescriptor() const +{ + const TypeDescriptor *aggrTD = NonRefTypeDescriptor(); + const TypeDescriptor *aggrElemTD = aggrTD->ReferentType(); + if(aggrElemTD) { aggrElemTD = aggrElemTD->NonRefTypeDescriptor(); } return aggrElemTD; @@ -408,19 +429,21 @@ const TypeDescriptor * TypeDescriptor::AggrElemTypeDescriptor() const { * TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor * for Integer */ -PrimitiveType TypeDescriptor::BaseType() const { - const TypeDescriptor * td = BaseTypeDescriptor(); - if( td ) { +PrimitiveType TypeDescriptor::BaseType() const +{ + const TypeDescriptor *td = BaseTypeDescriptor(); + if(td) { return td->FundamentalType(); } else { return ENTITY_TYPE; } } -const TypeDescriptor * TypeDescriptor::BaseTypeDescriptor() const { - const TypeDescriptor * td = this; +const TypeDescriptor *TypeDescriptor::BaseTypeDescriptor() const +{ + const TypeDescriptor *td = this; - while( td -> ReferentType() ) { + while(td -> ReferentType()) { td = td->ReferentType(); } return td; diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 915c1831d..3790707e2 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -93,7 +93,8 @@ * It is the same as _name for EXPRESS base types TypeDescriptors (with * the possible exception of upper or lower case differences). */ -class SC_CORE_EXPORT TypeDescriptor { +class SC_CORE_EXPORT TypeDescriptor +{ protected: @@ -105,7 +106,7 @@ class SC_CORE_EXPORT TypeDescriptor { /// generated code, for example, places a literal string in its /// TypeDesc constructor calls. This creates a location in me- /// mory static throughout the lifetime of the calling program. - const char * _name ; + const char *_name ; /// an alternate name of type - such as one given by a different /// schema which USEs/ REFERENCEs this. (A complete list of @@ -115,56 +116,58 @@ class SC_CORE_EXPORT TypeDescriptor { /// contains list of renamings of type - used by other schemas /// which USE/ REFERENCE this - const SchRename * altNames; + const SchRename *altNames; /// the type of the type (see above). /// it is an enum see file clstepcore/baseType.h PrimitiveType _fundamentalType; - const Schema * _originatingSchema; + const Schema *_originatingSchema; /// further describes the type (see above) /// most often (or always) points at a subtype. - const TypeDescriptor * _referentType; + const TypeDescriptor *_referentType; /// Express file description (see above) /// e.g. the right side of an Express TYPE stmt /// (See note above by _name regarding memory allocation.) - const char * _description; + const char *_description; public: /// a Where_rule may contain only a comment Where_rule__list_var _where_rules; // initially a null pointer - Where_rule__list_var & where_rules_() { + Where_rule__list_var &where_rules_() + { return _where_rules; } - void where_rules_( Where_rule__list * wrl ) { + void where_rules_(Where_rule__list *wrl) + { _where_rules = wrl; } protected: /// Functions used to check the current name of the type (may /// != _name if altNames has diff name for current schema). - bool PossName( const char * ) const; - bool OurName( const char * ) const; - bool AltName( const char * ) const; + bool PossName(const char *) const; + bool OurName(const char *) const; + bool AltName(const char *) const; public: - TypeDescriptor( const char * nm, PrimitiveType ft, const char * d ); - TypeDescriptor( const char * nm, PrimitiveType ft, - Schema * origSchema, const char * d ); - TypeDescriptor( ); + TypeDescriptor(const char *nm, PrimitiveType ft, const char *d); + TypeDescriptor(const char *nm, PrimitiveType ft, + Schema *origSchema, const char *d); + TypeDescriptor(); virtual ~TypeDescriptor(); - virtual const char * GenerateExpress( std::string & buf ) const; + virtual const char *GenerateExpress(std::string &buf) const; /// The name of this type. If schnm != NULL, the name we're /// referred to by schema schnm (may be diff name in our alt- /// names list (based on schnm's USE/REF list)). - const char * Name( const char * schnm = NULL ) const; + const char *Name(const char *schnm = NULL) const; /// The name that would be found on the right side of an /// attribute definition. In the case of a type defined like @@ -174,10 +177,11 @@ class SC_CORE_EXPORT TypeDescriptor { /// defined in an attribute it will be the _description /// member variable since _name will be null. e.g. attr. def. /// project_names : ARRAY [1..10] name; - void AttrTypeName( std::string & buf, const char * schnm = NULL ) const; + void AttrTypeName(std::string &buf, const char *schnm = NULL) const; /// Linked link of alternate names for the type: - const SchRename * AltNameList() const { + const SchRename *AltNameList() const + { return altNames; } @@ -186,13 +190,15 @@ class SC_CORE_EXPORT TypeDescriptor { /// except it is more thorough of a description where possible /// e.g. if the description contains a TYPE name it will also /// be explained. - const char * TypeString( std::string & s ) const; + const char *TypeString(std::string &s) const; /// This TypeDescriptor's type - PrimitiveType Type() const { + PrimitiveType Type() const + { return _fundamentalType; } - void Type( const PrimitiveType type ) { + void Type(const PrimitiveType type) + { _fundamentalType = type; } @@ -207,8 +213,8 @@ class SC_CORE_EXPORT TypeDescriptor { /// TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor /// for Integer. PrimitiveType BaseType() const; - const TypeDescriptor * BaseTypeDescriptor() const; - const char * BaseTypeName() const; + const TypeDescriptor *BaseTypeDescriptor() const; + const char *BaseTypeName() const; /// the first PrimitiveType that is not REFERENCE_TYPE (the first /// TypeDescriptor *_referentType that does not have REFERENCE_TYPE @@ -219,36 +225,43 @@ class SC_CORE_EXPORT TypeDescriptor { /// would work the same? PrimitiveType NonRefType() const; - const TypeDescriptor * NonRefTypeDescriptor() const; + const TypeDescriptor *NonRefTypeDescriptor() const; int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor * AggrElemTypeDescriptor() const; + const TypeDescriptor *AggrElemTypeDescriptor() const; - PrimitiveType FundamentalType() const { + PrimitiveType FundamentalType() const + { return _fundamentalType; } - void FundamentalType( PrimitiveType ftype ) { + void FundamentalType(PrimitiveType ftype) + { _fundamentalType = ftype; } /// The TypeDescriptor for the type this type is based on - const TypeDescriptor * ReferentType() const { + const TypeDescriptor *ReferentType() const + { return _referentType; } - void ReferentType( const TypeDescriptor * rtype ) { + void ReferentType(const TypeDescriptor *rtype) + { _referentType = rtype; } - const Schema * OriginatingSchema() const { + const Schema *OriginatingSchema() const + { return _originatingSchema; } - void OriginatingSchema( const Schema * os ) { + void OriginatingSchema(const Schema *os) + { _originatingSchema = os; } - const char * schemaName() const { - if( _originatingSchema ) { + const char *schemaName() const + { + if(_originatingSchema) { return _originatingSchema->Name(); } else { return ""; @@ -258,30 +271,35 @@ class SC_CORE_EXPORT TypeDescriptor { /// A description of this type's type. Basically you /// get the right side of a TYPE statement minus END_TYPE. /// For base type TypeDescriptors it is the same as _name. - const char * Description() const { + const char *Description() const + { return _description; } - void Description( const char * desc ) { + void Description(const char *desc) + { _description = desc; } - virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; - virtual const TypeDescriptor * BaseTypeIsA( const TypeDescriptor * ) + virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; + virtual const TypeDescriptor *BaseTypeIsA(const TypeDescriptor *) const; - virtual const TypeDescriptor * IsA( const char * ) const; - virtual const TypeDescriptor * CanBe( const TypeDescriptor * n ) const { - return IsA( n ); + virtual const TypeDescriptor *IsA(const char *) const; + virtual const TypeDescriptor *CanBe(const TypeDescriptor *n) const + { + return IsA(n); } - virtual const TypeDescriptor * CanBe( const char * n ) const { - return IsA( n ); + virtual const TypeDescriptor *CanBe(const char *n) const + { + return IsA(n); } - virtual const TypeDescriptor * CanBeSet( const char * n, - const char * schNm = 0 ) const { - return ( CurrName( n, schNm ) ? this : 0 ); + virtual const TypeDescriptor *CanBeSet(const char *n, + const char *schNm = 0) const + { + return (CurrName(n, schNm) ? this : 0); } - bool CurrName( const char *, const char * = 0 ) const; + bool CurrName(const char *, const char * = 0) const; /// Adds an additional name, newnm, to be use when schema schnm is USE/REFERENCE'ing us (added to altNames). - void addAltName( const char * schnm, const char * newnm ); + void addAltName(const char *schnm, const char *newnm); }; #endif //TYPEDESCRIPTOR_H diff --git a/src/clstepcore/typeDescriptorList.cc b/src/clstepcore/typeDescriptorList.cc index f47e8f502..606e667f8 100644 --- a/src/clstepcore/typeDescriptorList.cc +++ b/src/clstepcore/typeDescriptorList.cc @@ -1,29 +1,36 @@ #include "typeDescriptorList.h" -TypeDescLinkNode::TypeDescLinkNode() { +TypeDescLinkNode::TypeDescLinkNode() +{ _typeDesc = 0; } -TypeDescLinkNode::~TypeDescLinkNode() { +TypeDescLinkNode::~TypeDescLinkNode() +{ } -TypeDescriptorList::TypeDescriptorList() { +TypeDescriptorList::TypeDescriptorList() +{ } -TypeDescriptorList::~TypeDescriptorList() { +TypeDescriptorList::~TypeDescriptorList() +{ } -TypeDescItr::TypeDescItr( const TypeDescriptorList & tdList ) : tdl( tdList ) { - cur = ( TypeDescLinkNode * )( tdl.GetHead() ); +TypeDescItr::TypeDescItr(const TypeDescriptorList &tdList) : tdl(tdList) +{ + cur = (TypeDescLinkNode *)(tdl.GetHead()); } -TypeDescItr::~TypeDescItr() { +TypeDescItr::~TypeDescItr() +{ } -const TypeDescriptor * TypeDescItr::NextTypeDesc() { - if( cur ) { - const TypeDescriptor * td = cur->TypeDesc(); - cur = ( TypeDescLinkNode * )( cur->NextNode() ); +const TypeDescriptor *TypeDescItr::NextTypeDesc() +{ + if(cur) { + const TypeDescriptor *td = cur->TypeDesc(); + cur = (TypeDescLinkNode *)(cur->NextNode()); return td; } return 0; diff --git a/src/clstepcore/typeDescriptorList.h b/src/clstepcore/typeDescriptorList.h index b8bbc614c..faff6712a 100644 --- a/src/clstepcore/typeDescriptorList.h +++ b/src/clstepcore/typeDescriptorList.h @@ -9,55 +9,63 @@ class TypeDescriptor; -class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode { +class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode +{ private: protected: - TypeDescriptor * _typeDesc; + TypeDescriptor *_typeDesc; public: TypeDescLinkNode(); virtual ~TypeDescLinkNode(); - const TypeDescriptor * TypeDesc() const { + const TypeDescriptor *TypeDesc() const + { return _typeDesc; } - void TypeDesc( TypeDescriptor * td ) { + void TypeDesc(TypeDescriptor *td) + { _typeDesc = td; } }; -class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList { +class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList +{ private: protected: public: TypeDescriptorList(); virtual ~TypeDescriptorList(); - virtual SingleLinkNode * NewNode() { + virtual SingleLinkNode *NewNode() + { return new TypeDescLinkNode; } - TypeDescLinkNode * AddNode( TypeDescriptor * td ) { - TypeDescLinkNode * node = ( TypeDescLinkNode * ) NewNode(); - node->TypeDesc( td ); - SingleLinkList::AppendNode( node ); + TypeDescLinkNode *AddNode(TypeDescriptor *td) + { + TypeDescLinkNode *node = (TypeDescLinkNode *) NewNode(); + node->TypeDesc(td); + SingleLinkList::AppendNode(node); return node; } }; -class SC_CORE_EXPORT TypeDescItr { +class SC_CORE_EXPORT TypeDescItr +{ protected: - const TypeDescriptorList & tdl; - const TypeDescLinkNode * cur; + const TypeDescriptorList &tdl; + const TypeDescLinkNode *cur; public: - TypeDescItr( const TypeDescriptorList & tdList ); + TypeDescItr(const TypeDescriptorList &tdList); virtual ~TypeDescItr(); - void ResetItr() { - cur = ( TypeDescLinkNode * )( tdl.GetHead() ); + void ResetItr() + { + cur = (TypeDescLinkNode *)(tdl.GetHead()); } - const TypeDescriptor * NextTypeDesc(); + const TypeDescriptor *NextTypeDesc(); }; #endif //TYPEDESCRIPTORLIST_H diff --git a/src/clstepcore/typeOrRuleVar.cc b/src/clstepcore/typeOrRuleVar.cc index 0b06f1949..ced514c00 100644 --- a/src/clstepcore/typeOrRuleVar.cc +++ b/src/clstepcore/typeOrRuleVar.cc @@ -2,13 +2,16 @@ #include -Type_or_rule::Type_or_rule() { +Type_or_rule::Type_or_rule() +{ std::cerr << "WARNING - Type_or_rule class doesn't seem to be complete - it has no members!" << std::endl; } -Type_or_rule::Type_or_rule( const Type_or_rule & tor ): Dictionary_instance() { - ( void ) tor; //TODO once this class has some members, we'll actually have something to copy +Type_or_rule::Type_or_rule(const Type_or_rule &tor): Dictionary_instance() +{ + (void) tor; //TODO once this class has some members, we'll actually have something to copy } -Type_or_rule::~Type_or_rule() { +Type_or_rule::~Type_or_rule() +{ } diff --git a/src/clstepcore/typeOrRuleVar.h b/src/clstepcore/typeOrRuleVar.h index 09f78da59..a8c7cc959 100644 --- a/src/clstepcore/typeOrRuleVar.h +++ b/src/clstepcore/typeOrRuleVar.h @@ -5,14 +5,15 @@ #include "sc_export.h" -class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance { -public: - Type_or_rule(); - Type_or_rule( const Type_or_rule & ); - virtual ~Type_or_rule(); +class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance +{ + public: + Type_or_rule(); + Type_or_rule(const Type_or_rule &); + virtual ~Type_or_rule(); }; -typedef Type_or_rule * Type_or_rule_ptr; +typedef Type_or_rule *Type_or_rule_ptr; typedef Type_or_rule_ptr Type_or_rule_var; diff --git a/src/clstepcore/uniquenessRule.cc b/src/clstepcore/uniquenessRule.cc index 038f1a68f..501ac9e4b 100644 --- a/src/clstepcore/uniquenessRule.cc +++ b/src/clstepcore/uniquenessRule.cc @@ -3,105 +3,118 @@ #include Uniqueness_rule::Uniqueness_rule() -: _parent_entity( 0 ) { + : _parent_entity(0) +{ } -Uniqueness_rule::Uniqueness_rule( const Uniqueness_rule & ur ): Dictionary_instance() { +Uniqueness_rule::Uniqueness_rule(const Uniqueness_rule &ur): Dictionary_instance() +{ _label = ur._label; _parent_entity = ur._parent_entity; } -Uniqueness_rule::~Uniqueness_rule() { +Uniqueness_rule::~Uniqueness_rule() +{ // don't delete _parent_entity } -Uniqueness_rule__set::Uniqueness_rule__set( int defaultSize ) { +Uniqueness_rule__set::Uniqueness_rule__set(int defaultSize) +{ _bufsize = defaultSize; _buf = new Uniqueness_rule_ptr[_bufsize]; _count = 0; } -Uniqueness_rule__set::~Uniqueness_rule__set() { +Uniqueness_rule__set::~Uniqueness_rule__set() +{ Clear(); delete[] _buf; } -void Uniqueness_rule__set::Check( int index ) { - Uniqueness_rule_ptr * newbuf; +void Uniqueness_rule__set::Check(int index) +{ + Uniqueness_rule_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Uniqueness_rule_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Uniqueness_rule_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Uniqueness_rule_ptr)); delete[] _buf; _buf = newbuf; } } -void Uniqueness_rule__set::Insert( Uniqueness_rule_ptr v, int index ) { - Uniqueness_rule_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Uniqueness_rule__set::Insert(Uniqueness_rule_ptr v, int index) +{ + Uniqueness_rule_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Append( Uniqueness_rule_ptr v ) { +void Uniqueness_rule__set::Append(Uniqueness_rule_ptr v) +{ int index = _count; - Uniqueness_rule_ptr * spot; + Uniqueness_rule_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Uniqueness_rule__set::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Uniqueness_rule_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); + Uniqueness_rule_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Uniqueness_rule_ptr)); } } -int Uniqueness_rule__set::Index( Uniqueness_rule_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Uniqueness_rule__set::Index(Uniqueness_rule_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Uniqueness_rule_ptr & Uniqueness_rule__set::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Uniqueness_rule_ptr &Uniqueness_rule__set::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Uniqueness_rule__set::Count() { +int Uniqueness_rule__set::Count() +{ return _count; } -void Uniqueness_rule__set::Clear() { - for( int i = 0; i < _count; i ++ ) { +void Uniqueness_rule__set::Clear() +{ + for(int i = 0; i < _count; i ++) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/uniquenessRule.h b/src/clstepcore/uniquenessRule.h index 4751ce97b..ccac487c9 100644 --- a/src/clstepcore/uniquenessRule.h +++ b/src/clstepcore/uniquenessRule.h @@ -9,77 +9,85 @@ class EntityDescriptor; -class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance { -public: +class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance +{ + public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; /** Comment contained in the EXPRESS. + // non-SDAI + std::string _comment; /** Comment contained in the EXPRESS. * Should be properly formatted to include (* *) * Will be written to EXPRESS as-is (w/out formatting) */ #ifdef _MSC_VER #pragma warning( pop ) #endif - const EntityDescriptor * _parent_entity; - - Uniqueness_rule(); - Uniqueness_rule( const Uniqueness_rule & ); - Uniqueness_rule( const char * label, EntityDescriptor * pe = 0 ) - : _label( label ), _parent_entity( pe ) { } - virtual ~Uniqueness_rule(); - - Express_id label_() const { - return _label; - } - const EntityDescriptor * parent_() const { - return _parent_entity; - } - std::string & comment_() { - return _comment; - } - - void label_( const Express_id & ei ) { - _label = ei; - } - void parent_( const EntityDescriptor * pe ) { - _parent_entity = pe; - } - void comment_( const char * c ) { - _comment = c; - } + const EntityDescriptor *_parent_entity; + + Uniqueness_rule(); + Uniqueness_rule(const Uniqueness_rule &); + Uniqueness_rule(const char *label, EntityDescriptor *pe = 0) + : _label(label), _parent_entity(pe) { } + virtual ~Uniqueness_rule(); + + Express_id label_() const + { + return _label; + } + const EntityDescriptor *parent_() const + { + return _parent_entity; + } + std::string &comment_() + { + return _comment; + } + + void label_(const Express_id &ei) + { + _label = ei; + } + void parent_(const EntityDescriptor *pe) + { + _parent_entity = pe; + } + void comment_(const char *c) + { + _comment = c; + } }; -typedef Uniqueness_rule * Uniqueness_rule_ptr; - -class SC_CORE_EXPORT Uniqueness_rule__set { -public: - Uniqueness_rule__set( int = 16 ); - ~Uniqueness_rule__set(); - - Uniqueness_rule_ptr & operator[]( int index ); - void Insert( Uniqueness_rule_ptr, int index ); - void Append( Uniqueness_rule_ptr ); - void Remove( int index ); - int Index( Uniqueness_rule_ptr ); - - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Uniqueness_rule_ptr * _buf; - int _bufsize; - int _count; +typedef Uniqueness_rule *Uniqueness_rule_ptr; + +class SC_CORE_EXPORT Uniqueness_rule__set +{ + public: + Uniqueness_rule__set(int = 16); + ~Uniqueness_rule__set(); + + Uniqueness_rule_ptr &operator[](int index); + void Insert(Uniqueness_rule_ptr, int index); + void Append(Uniqueness_rule_ptr); + void Remove(int index); + int Index(Uniqueness_rule_ptr); + + int Count(); + void Clear(); + private: + void Check(int index); + private: + Uniqueness_rule_ptr *_buf; + int _bufsize; + int _count; }; -typedef Uniqueness_rule__set * Uniqueness_rule__set_ptr; +typedef Uniqueness_rule__set *Uniqueness_rule__set_ptr; typedef Uniqueness_rule__set_ptr Uniqueness_rule__set_var; #endif //UNIQUENESSRULE_H diff --git a/src/clstepcore/whereRule.cc b/src/clstepcore/whereRule.cc index e60c64940..43db2f1e5 100644 --- a/src/clstepcore/whereRule.cc +++ b/src/clstepcore/whereRule.cc @@ -1,106 +1,119 @@ #include "whereRule.h" -Where_rule::Where_rule() { +Where_rule::Where_rule() +{ _type_or_rule = 0; } -Where_rule::Where_rule( const Where_rule & wr ): Dictionary_instance() { +Where_rule::Where_rule(const Where_rule &wr): Dictionary_instance() +{ _label = wr._label; _type_or_rule = wr._type_or_rule; } -Where_rule::~Where_rule() { +Where_rule::~Where_rule() +{ } /////////////////////////////////////////////////////////////////////////////// -Where_rule__list::Where_rule__list( int defaultSize ) { +Where_rule__list::Where_rule__list(int defaultSize) +{ _bufsize = defaultSize; _buf = new Where_rule_ptr[_bufsize]; _count = 0; } -Where_rule__list::~Where_rule__list() { +Where_rule__list::~Where_rule__list() +{ Clear(); delete[] _buf; } -void Where_rule__list::Check( int index ) { - Where_rule_ptr * newbuf; +void Where_rule__list::Check(int index) +{ + Where_rule_ptr *newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new Where_rule_ptr[_bufsize]; - memmove( newbuf, _buf, _count * sizeof( Where_rule_ptr ) ); + memmove(newbuf, _buf, _count * sizeof(Where_rule_ptr)); delete[] _buf; _buf = newbuf; } } -void Where_rule__list::Insert( Where_rule_ptr v, int index ) { - Where_rule_ptr * spot; - index = ( index < 0 ) ? _count : index; +void Where_rule__list::Insert(Where_rule_ptr v, int index) +{ + Where_rule_ptr *spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Append( Where_rule_ptr v ) { +void Where_rule__list::Append(Where_rule_ptr v) +{ int index = _count; - Where_rule_ptr * spot; + Where_rule_ptr *spot; - if( index < _count ) { - Check( _count + 1 ); + if(index < _count) { + Check(_count + 1); spot = &_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); + memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); } else { - Check( index ); + Check(index); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Remove( int index ) { - if( 0 <= index && index < _count ) { +void Where_rule__list::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - Where_rule_ptr * spot = &_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( Where_rule_ptr ) ); + Where_rule_ptr *spot = &_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(Where_rule_ptr)); } } -int Where_rule__list::Index( Where_rule_ptr v ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == v ) { +int Where_rule__list::Index(Where_rule_ptr v) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == v) { return i; } } return -1; } -Where_rule_ptr & Where_rule__list::operator[]( int index ) { - Check( index ); - _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); +Where_rule_ptr &Where_rule__list::operator[](int index) +{ + Check(index); + _count = ((_count > index + 1) ? _count : (index + 1)); return _buf[index]; } -int Where_rule__list::Count() { +int Where_rule__list::Count() +{ return _count; } -void Where_rule__list::Clear() { - for( int i = 0; i < _count ; i ++ ) { +void Where_rule__list::Clear() +{ + for(int i = 0; i < _count ; i ++) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/whereRule.h b/src/clstepcore/whereRule.h index ef9043a4b..7ed9954a2 100644 --- a/src/clstepcore/whereRule.h +++ b/src/clstepcore/whereRule.h @@ -8,74 +8,82 @@ #include "sc_export.h" -class SC_CORE_EXPORT Where_rule : public Dictionary_instance { -public: +class SC_CORE_EXPORT Where_rule : public Dictionary_instance +{ + public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; // Comment contained in the EXPRESS. - // Should be properly formatted to include (* *) - // Will be written to EXPRESS as-is (w/out formatting) + // non-SDAI + std::string _comment; // Comment contained in the EXPRESS. + // Should be properly formatted to include (* *) + // Will be written to EXPRESS as-is (w/out formatting) #ifdef _MSC_VER #pragma warning( pop ) #endif - Type_or_rule_var _type_or_rule; + Type_or_rule_var _type_or_rule; - Where_rule(); - Where_rule( const Where_rule & ); - Where_rule( const char * label, Type_or_rule_var tor = 0 ) - : _label( label ), _type_or_rule( tor ) { } - virtual ~Where_rule(); + Where_rule(); + Where_rule(const Where_rule &); + Where_rule(const char *label, Type_or_rule_var tor = 0) + : _label(label), _type_or_rule(tor) { } + virtual ~Where_rule(); - Express_id label_() const { - return _label; - } - Type_or_rule_var parent_item() const { - return _type_or_rule; - } - std::string comment_() const { - return _comment; - } + Express_id label_() const + { + return _label; + } + Type_or_rule_var parent_item() const + { + return _type_or_rule; + } + std::string comment_() const + { + return _comment; + } - void label_( const Express_id & ei ) { - _label = ei; - } - void parent_item( const Type_or_rule_var & tor ) { - _type_or_rule = tor; - } - void comment_( const char * c ) { - _comment = c; - } + void label_(const Express_id &ei) + { + _label = ei; + } + void parent_item(const Type_or_rule_var &tor) + { + _type_or_rule = tor; + } + void comment_(const char *c) + { + _comment = c; + } }; -typedef Where_rule * Where_rule_ptr; +typedef Where_rule *Where_rule_ptr; -class SC_CORE_EXPORT Where_rule__list { -public: - Where_rule__list( int = 16 ); - ~Where_rule__list(); +class SC_CORE_EXPORT Where_rule__list +{ + public: + Where_rule__list(int = 16); + ~Where_rule__list(); - Where_rule_ptr & operator[]( int index ); - void Insert( Where_rule_ptr, int index ); - void Append( Where_rule_ptr ); - void Remove( int index ); - int Index( Where_rule_ptr ); + Where_rule_ptr &operator[](int index); + void Insert(Where_rule_ptr, int index); + void Append(Where_rule_ptr); + void Remove(int index); + int Index(Where_rule_ptr); - int Count(); - void Clear(); -private: - void Check( int index ); -private: - Where_rule_ptr * _buf; - int _bufsize; - int _count; + int Count(); + void Clear(); + private: + void Check(int index); + private: + Where_rule_ptr *_buf; + int _bufsize; + int _count; }; -typedef Where_rule__list * Where_rule__list_ptr; +typedef Where_rule__list *Where_rule__list_ptr; typedef Where_rule__list_ptr Where_rule__list_var; #endif //WHERERULE_H diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index a14f0dc08..e97083dc0 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -23,76 +23,82 @@ ** Status: complete ******************************************************************/ -char ToLower( const char c ) { - if( isupper( c ) ) { - return ( tolower( c ) ); +char ToLower(const char c) +{ + if(isupper(c)) { + return (tolower(c)); } else { - return ( c ); + return (c); } } -char ToUpper( const char c ) { - if( islower( c ) ) { - return ( toupper( c ) ); +char ToUpper(const char c) +{ + if(islower(c)) { + return (toupper(c)); } else { - return ( c ); + return (c); } } // Place in strNew a lowercase version of strOld. -char * StrToLower( const char * strOld, char * strNew ) { +char *StrToLower(const char *strOld, char *strNew) +{ int i = 0; - while( strOld[i] != '\0' ) { - strNew[i] = ToLower( strOld[i] ); + while(strOld[i] != '\0') { + strNew[i] = ToLower(strOld[i]); i++; } strNew[i] = '\0'; return strNew; } -const char * StrToLower( const char * word, std::string & s ) { +const char *StrToLower(const char *word, std::string &s) +{ char newword [BUFSIZ]; int i = 0; - while( word [i] != '\0' ) { - newword [i] = ToLower( word [i] ); + while(word [i] != '\0') { + newword [i] = ToLower(word [i]); ++i; } newword [i] = '\0'; s = newword; - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const char * StrToUpper( const char * word, std::string & s ) { +const char *StrToUpper(const char *word, std::string &s) +{ char newword [BUFSIZ]; int i = 0; - while( word [i] != '\0' ) { - newword [i] = ToUpper( word [i] ); + while(word [i] != '\0') { + newword [i] = ToUpper(word [i]); ++i; } newword [i] = '\0'; s = newword; - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } -const char * StrToConstant( const char * word, std::string & s ) { +const char *StrToConstant(const char *word, std::string &s) +{ char newword [BUFSIZ]; int i = 0; - while( word [i] != '\0' ) { - if( word [i] == '/' || word [i] == '.' ) { + while(word [i] != '\0') { + if(word [i] == '/' || word [i] == '.') { newword [i] = '_'; } else { - newword [i] = ToUpper( word [i] ); + newword [i] = ToUpper(word [i]); } ++i; } newword [i] = '\0'; s = newword; - return const_cast( s.c_str() ); + return const_cast(s.c_str()); } /**************************************************************//** @@ -103,9 +109,10 @@ const char * StrToConstant( const char * word, std::string & s ) { ** == 0 when str1 equals str2 ** > 0 when str1 greater then str2 ******************************************************************/ -int StrCmpIns( const char * str1, const char * str2 ) { +int StrCmpIns(const char *str1, const char *str2) +{ char c1, c2; - while( ( c1 = tolower( *str1 ) ) == ( c2 = tolower( *str2 ) ) && c1 != '\0' ) { + while((c1 = tolower(*str1)) == (c2 = tolower(*str2)) && c1 != '\0') { str1++; str2++; } @@ -115,17 +122,18 @@ int StrCmpIns( const char * str1, const char * str2 ) { /** * Test if a string ends with the given suffix. */ -bool StrEndsWith( const std::string & s, const char * suf ) { - if( suf == NULL ) { +bool StrEndsWith(const std::string &s, const char *suf) +{ + if(suf == NULL) { return false; } std::string suffix = suf; size_t sLen = s.length(); size_t suffixLen = suffix.length(); - if( sLen < suffixLen ) { + if(sLen < suffixLen) { return false; } - if( s.substr( sLen - suffixLen ).compare( suffix ) == 0 ) { + if(s.substr(sLen - suffixLen).compare(suffix) == 0) { return true; } return false; @@ -134,38 +142,39 @@ bool StrEndsWith( const std::string & s, const char * suf ) { /** * Extract the next delimited string from the istream. */ -std::string GetLiteralStr( istream & in, ErrorDescriptor * err ) { +std::string GetLiteralStr(istream &in, ErrorDescriptor *err) +{ std::string s; in >> std::ws; // skip whitespace - if( in.good() && in.peek() == STRING_DELIM ) { + if(in.good() && in.peek() == STRING_DELIM) { s += in.get(); bool allDelimsEscaped = true; - while( in.good() ) { - if( in.peek() == STRING_DELIM ) { + while(in.good()) { + if(in.peek() == STRING_DELIM) { // A delimiter closes the string unless it's followed by another // delimiter, in which case it's escaped. \S\ starts an ISO // 8859 character escape sequence, so we ignore delimiters // prefixed with \S\. - if( !StrEndsWith( s, "\\S\\" ) ) { + if(!StrEndsWith(s, "\\S\\")) { allDelimsEscaped = !allDelimsEscaped; } - } else if( !allDelimsEscaped ) { + } else if(!allDelimsEscaped) { // Found normal char after unescaped delim, so last delim // that was appended terminated the string. break; } - if( !in.eof() ) { + if(!in.eof()) { s += in.get(); } } - if( allDelimsEscaped ) { + if(allDelimsEscaped) { // Any delimiters found after the opening delimiter were escaped, // so the string is unclosed. // non-recoverable error - err->AppendToDetailMsg( "Missing closing quote on string value.\n" ); - err->AppendToUserMsg( "Missing closing quote on string value.\n" ); - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToDetailMsg("Missing closing quote on string value.\n"); + err->AppendToUserMsg("Missing closing quote on string value.\n"); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); } } return s; @@ -177,21 +186,22 @@ std::string GetLiteralStr( istream & in, ErrorDescriptor * err ) { ** Capitalizes first char of word, rest is lowercase. Removes '_'. ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -const char * PrettyTmpName( const char * oldname ) { +const char *PrettyTmpName(const char *oldname) +{ int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { - newname [i] = ToLower( oldname [i] ); - if( oldname [i] == '_' ) { /* character is '_' */ + while((oldname [i] != '\0') && (i < BUFSIZ)) { + newname [i] = ToLower(oldname [i]); + if(oldname [i] == '_') { /* character is '_' */ ++i; - newname [i] = ToUpper( oldname [i] ); + newname [i] = ToUpper(oldname [i]); } - if( oldname [i] != '\0' ) { + if(oldname [i] != '\0') { ++i; } } - newname [0] = ToUpper( oldname [0] ); + newname [0] = ToUpper(oldname [0]); newname [i] = '\0'; return newname; } @@ -203,9 +213,10 @@ const char * PrettyTmpName( const char * oldname ) { ** Side Effects: allocates memory for the new name ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -char * PrettyNewName( const char * oldname ) { - char * name = new char [strlen( oldname ) + 1]; - strcpy( name, PrettyTmpName( oldname ) ); +char *PrettyNewName(const char *oldname) +{ + char *name = new char [strlen(oldname) + 1]; + strcpy(name, PrettyTmpName(oldname)); return name; } @@ -245,80 +256,82 @@ char * PrettyNewName( const char * oldname ) { *** not then it is an error but the bad chars are not read since you have *** no way to know when to stop. **/ -Severity CheckRemainingInput( istream & in, ErrorDescriptor * err, - const char * typeName, // used in error message - const char * delimiterList ) { // e.g. ",)" +Severity CheckRemainingInput(istream &in, ErrorDescriptor *err, + const char *typeName, // used in error message + const char *delimiterList) // e.g. ",)" +{ string skipBuf; ostringstream errMsg; - if( in.eof() ) { + if(in.eof()) { // no error return err->severity(); - } else if( in.bad() ) { + } else if(in.bad()) { // Bad bit must have been set during read. Recovery is impossible. - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg( errMsg.str().c_str() ); - err->AppendToDetailMsg( errMsg.str().c_str() ); + err->AppendToUserMsg(errMsg.str().c_str()); + err->AppendToDetailMsg(errMsg.str().c_str()); } else { // At most the fail bit is set, so stream can still be read. // Clear errors and skip whitespace. in.clear(); in >> ws; - if( in.eof() ) { + if(in.eof()) { // no error return err->severity(); } - if( delimiterList != NULL ) { + if(delimiterList != NULL) { // If the next char is a delimiter then there's no error. char c = in.peek(); - if( strchr( delimiterList, c ) == NULL ) { + if(strchr(delimiterList, c) == NULL) { // Error. Extra input is more than just a delimiter and is // now considered invalid. We'll try to recover by skipping // to the next delimiter. - for( in.get( c ); in && !strchr( delimiterList, c ); in.get( c ) ) { + for(in.get(c); in && !strchr(delimiterList, c); in.get(c)) { skipBuf += c; } - if( strchr( delimiterList, c ) != NULL ) { + if(strchr(delimiterList, c) != NULL) { // Delimiter found. Recovery succeeded. - in.putback( c ); + in.putback(c); errMsg << "\tFound invalid " << typeName << " value...\n"; - err->AppendToUserMsg( errMsg.str().c_str() ); - err->AppendToDetailMsg( errMsg.str().c_str() ); - err->AppendToDetailMsg( "\tdata lost looking for end of " - "attribute: " ); - err->AppendToDetailMsg( skipBuf.c_str() ); - err->AppendToDetailMsg( "\n" ); - - err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToUserMsg(errMsg.str().c_str()); + err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToDetailMsg("\tdata lost looking for end of " + "attribute: "); + err->AppendToDetailMsg(skipBuf.c_str()); + err->AppendToDetailMsg("\n"); + + err->GreaterSeverity(SEVERITY_WARNING); } else { // No delimiter found. Recovery failed. errMsg << "Unable to recover from input error while " << "reading " << typeName << " value.\n"; - err->AppendToUserMsg( errMsg.str().c_str() ); - err->AppendToDetailMsg( errMsg.str().c_str() ); + err->AppendToUserMsg(errMsg.str().c_str()); + err->AppendToDetailMsg(errMsg.str().c_str()); - err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->GreaterSeverity(SEVERITY_INPUT_ERROR); } } - } else if( in.good() ) { + } else if(in.good()) { // Error. Have more input, but lack of delimiter list means we // don't know where we can safely resume. Recovery is impossible. - err->GreaterSeverity( SEVERITY_WARNING ); + err->GreaterSeverity(SEVERITY_WARNING); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg( errMsg.str().c_str() ); - err->AppendToDetailMsg( errMsg.str().c_str() ); + err->AppendToUserMsg(errMsg.str().c_str()); + err->AppendToDetailMsg(errMsg.str().c_str()); } } return err->severity(); } -Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ) { - return CheckRemainingInput( in, err, typeName.c_str(), tokenList ); +Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList) +{ + return CheckRemainingInput(in, err, typeName.c_str(), tokenList); } diff --git a/src/clutils/Str.h b/src/clutils/Str.h index f605bfdda..fb1859c4e 100644 --- a/src/clutils/Str.h +++ b/src/clutils/Str.h @@ -25,23 +25,23 @@ #define STRING_DELIM '\'' #endif -SC_UTILS_EXPORT char ToLower( const char c ); -SC_UTILS_EXPORT char ToUpper( const char c ); -SC_UTILS_EXPORT char * StrToLower( const char *, char * ); -SC_UTILS_EXPORT const char * StrToLower( const char * word, std::string & s ); -SC_UTILS_EXPORT const char * StrToUpper( const char * word, std::string & s ); -SC_UTILS_EXPORT const char * StrToConstant( const char * word, std::string & s ); -SC_UTILS_EXPORT int StrCmpIns( const char * str1, const char * str2 ); -SC_UTILS_EXPORT const char * PrettyTmpName( const char * oldname ); -SC_UTILS_EXPORT char * PrettyNewName( const char * oldname ); -SC_UTILS_EXPORT char * EntityClassName( char * oldname ); - -SC_UTILS_EXPORT bool StrEndsWith( const std::string & s, const char * suffix ); -SC_UTILS_EXPORT std::string GetLiteralStr( istream & in, ErrorDescriptor * err ); - -extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, - const char * typeName, // used in error message - const char * tokenList ); // e.g. ",)" -extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ); +SC_UTILS_EXPORT char ToLower(const char c); +SC_UTILS_EXPORT char ToUpper(const char c); +SC_UTILS_EXPORT char *StrToLower(const char *, char *); +SC_UTILS_EXPORT const char *StrToLower(const char *word, std::string &s); +SC_UTILS_EXPORT const char *StrToUpper(const char *word, std::string &s); +SC_UTILS_EXPORT const char *StrToConstant(const char *word, std::string &s); +SC_UTILS_EXPORT int StrCmpIns(const char *str1, const char *str2); +SC_UTILS_EXPORT const char *PrettyTmpName(const char *oldname); +SC_UTILS_EXPORT char *PrettyNewName(const char *oldname); +SC_UTILS_EXPORT char *EntityClassName(char *oldname); + +SC_UTILS_EXPORT bool StrEndsWith(const std::string &s, const char *suffix); +SC_UTILS_EXPORT std::string GetLiteralStr(istream &in, ErrorDescriptor *err); + +extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, + const char *typeName, // used in error message + const char *tokenList); // e.g. ",)" +extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList); #endif diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 337774342..a55786762 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -66,13 +66,14 @@ // /////////////////////////////////////////////////////////////////////////////// -DirObj::DirObj( const char * dirName ) { +DirObj::DirObj(const char *dirName) +{ const int defaultSize = 256; fileListSize = defaultSize; - fileList = new char*[fileListSize]; + fileList = new char *[fileListSize]; fileCount = 0; - LoadDirectory( dirName ); + LoadDirectory(dirName); } /////////////////////////////////////////////////////////////////////////////// @@ -81,7 +82,8 @@ DirObj::DirObj( const char * dirName ) { // /////////////////////////////////////////////////////////////////////////////// -DirObj::~DirObj() { +DirObj::~DirObj() +{ ClearFileList(); delete [] fileList; } @@ -94,10 +96,11 @@ DirObj::~DirObj() { // /////////////////////////////////////////////////////////////////////////////// -const char * DirObj::RealPath( const char * path ) { - const char * realpath; +const char *DirObj::RealPath(const char *path) +{ + const char *realpath; - if( path == 0 || *path == '\0' ) { + if(path == 0 || *path == '\0') { realpath = "./"; } else { realpath = path; @@ -111,11 +114,12 @@ const char * DirObj::RealPath( const char * path ) { // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::LoadDirectory( const std::string & name ) { - if( name.empty() ) { - return Reset( "./" ); +bool DirObj::LoadDirectory(const std::string &name) +{ + if(name.empty()) { + return Reset("./"); } else { - return Reset( name ); + return Reset(name); } } @@ -126,9 +130,10 @@ bool DirObj::LoadDirectory( const std::string & name ) { // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Index( const char * name ) { - for( int i = 0; i < fileCount; ++i ) { - if( strcmp( fileList[i], name ) == 0 ) { +int DirObj::Index(const char *name) +{ + for(int i = 0; i < fileCount; ++i) { + if(strcmp(fileList[i], name) == 0) { return i; } } @@ -143,30 +148,31 @@ int DirObj::Index( const char * name ) { // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::Reset( const std::string & path ) { - bool successful = IsADirectory( path.c_str() ); - if( successful ) { +bool DirObj::Reset(const std::string &path) +{ + bool successful = IsADirectory(path.c_str()); + if(successful) { #ifdef _WIN32 WIN32_FIND_DATA FindFileData; HANDLE hFind; ClearFileList(); - hFind = FindFirstFile( path.c_str(), &FindFileData ); - if( hFind != INVALID_HANDLE_VALUE ) { + hFind = FindFirstFile(path.c_str(), &FindFileData); + if(hFind != INVALID_HANDLE_VALUE) { int i = 0; do { - InsertFile( FindFileData.cFileName, i++ ); - } while( FindNextFile( hFind, &FindFileData ) ); - FindClose( hFind ); + InsertFile(FindFileData.cFileName, i++); + } while(FindNextFile(hFind, &FindFileData)); + FindClose(hFind); } #else - DIR * dir = opendir( path.c_str() ); + DIR *dir = opendir(path.c_str()); ClearFileList(); - for( struct dirent * d = readdir( dir ); d != NULL; d = readdir( dir ) ) { - InsertFile( d->d_name, Position( d->d_name ) ); + for(struct dirent *d = readdir(dir); d != NULL; d = readdir(dir)) { + InsertFile(d->d_name, Position(d->d_name)); } - closedir( dir ); + closedir(dir); #endif } else { std::cout << "not a directory: " << path << "!" << std::endl; @@ -182,15 +188,16 @@ bool DirObj::Reset( const std::string & path ) { // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::IsADirectory( const char * path ) { +bool DirObj::IsADirectory(const char *path) +{ #ifdef _WIN32 - if( PathIsDirectory( path ) ) { + if(PathIsDirectory(path)) { return true; } return false; #else struct stat st; - return stat( path, &st ) == 0 && ( st.st_mode & S_IFMT ) == S_IFDIR; + return stat(path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR; #endif } @@ -215,35 +222,36 @@ bool DirObj::IsADirectory( const char * path ) { // /////////////////////////////////////////////////////////////////////////////// -std::string DirObj::Normalize( const std::string & path ) { +std::string DirObj::Normalize(const std::string &path) +{ std::string buf; - const char * slash; + const char *slash; #ifdef _WIN32 char b[MAX_PATH]; - PathCanonicalize( b, path.c_str() ); + PathCanonicalize(b, path.c_str()); slash = "\\"; #else - char * b; - b = realpath( path.c_str(), 0 ); + char *b; + b = realpath(path.c_str(), 0); slash = "/"; #endif - if( b == 0 ) { + if(b == 0) { buf.clear(); } else { - buf.assign( b ); + buf.assign(b); #if !defined(_WIN32) - free(b); + free(b); #endif } - if( buf.empty() ) { + if(buf.empty()) { buf = "."; - buf.append( slash ); + buf.append(slash); // if buf is a path to a directory and doesn't end with '/' - } else if( IsADirectory( buf.c_str() ) && buf[buf.size()] != slash[0] ) { - buf.append( slash ); + } else if(IsADirectory(buf.c_str()) && buf[buf.size()] != slash[0]) { + buf.append(slash); } return buf; } @@ -254,17 +262,18 @@ std::string DirObj::Normalize( const std::string & path ) { // /////////////////////////////////////////////////////////////////////////////// -const char * DirObj::ValidDirectories( const char * path ) { +const char *DirObj::ValidDirectories(const char *path) +{ #ifdef _WIN32 static char buf[MAX_PATH + 1]; #else static char buf[MAXPATHLEN + 1]; #endif - strcpy( buf, path ); - int i = strlen( path ); + strcpy(buf, path); + int i = strlen(path); - while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) { - for( --i; buf[i] != '/' && i >= 0; --i ) { + while(!IsADirectory(RealPath(buf)) && i >= 0) { + for(--i; buf[i] != '/' && i >= 0; --i) { ; } buf[i + 1] = '\0'; @@ -279,13 +288,14 @@ const char * DirObj::ValidDirectories( const char * path ) { // /////////////////////////////////////////////////////////////////////////////// -void DirObj::CheckIndex( int index ) { - char ** newstrbuf; +void DirObj::CheckIndex(int index) +{ + char **newstrbuf; - if( index >= fileListSize ) { - fileListSize = ( index + 1 ) * 2; - newstrbuf = new char*[fileListSize]; - memmove( newstrbuf, fileList, fileCount * sizeof( char * ) ); + if(index >= fileListSize) { + fileListSize = (index + 1) * 2; + newstrbuf = new char *[fileListSize]; + memmove(newstrbuf, fileList, fileCount * sizeof(char *)); delete [] fileList; fileList = newstrbuf; } @@ -297,22 +307,23 @@ void DirObj::CheckIndex( int index ) { // /////////////////////////////////////////////////////////////////////////////// -void DirObj::InsertFile( const char * f, int index ) { - char ** spot; - index = ( index < 0 ) ? fileCount : index; +void DirObj::InsertFile(const char *f, int index) +{ + char **spot; + index = (index < 0) ? fileCount : index; - if( index < fileCount ) { - CheckIndex( fileCount + 1 ); + if(index < fileCount) { + CheckIndex(fileCount + 1); spot = &fileList[index]; - memmove( spot + 1, spot, ( fileCount - index )*sizeof( char * ) ); + memmove(spot + 1, spot, (fileCount - index)*sizeof(char *)); } else { - CheckIndex( index ); + CheckIndex(index); spot = &fileList[index]; } #ifdef _MSC_VER - char * string = _strdup( f ); + char *string = _strdup(f); #else - char * string = strdup( f ); + char *string = strdup(f); #endif *spot = string; ++fileCount; @@ -324,11 +335,12 @@ void DirObj::InsertFile( const char * f, int index ) { // /////////////////////////////////////////////////////////////////////////////// -void DirObj::RemoveFile( int index ) { - if( index < --fileCount ) { - const char ** spot = ( const char ** )&fileList[index]; +void DirObj::RemoveFile(int index) +{ + if(index < --fileCount) { + const char **spot = (const char **)&fileList[index]; delete spot; - memmove( spot, spot + 1, ( fileCount - index )*sizeof( char * ) ); + memmove(spot, spot + 1, (fileCount - index)*sizeof(char *)); } } @@ -338,9 +350,10 @@ void DirObj::RemoveFile( int index ) { // /////////////////////////////////////////////////////////////////////////////// -void DirObj::ClearFileList() { - for( int i = 0; i < fileCount; ++i ) { - free( fileList[i] ); +void DirObj::ClearFileList() +{ + for(int i = 0; i < fileCount; ++i) { + free(fileList[i]); } fileCount = 0; } @@ -352,11 +365,12 @@ void DirObj::ClearFileList() { // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Position( const char * f ) { +int DirObj::Position(const char *f) +{ int i; - for( i = 0; i < fileCount; ++i ) { - if( strcmp( f, fileList[i] ) < 0 ) { + for(i = 0; i < fileCount; ++i) { + if(strcmp(f, fileList[i]) < 0) { return i; } } diff --git a/src/clutils/dirobj.h b/src/clutils/dirobj.h index a89e28dad..534d9bc97 100644 --- a/src/clutils/dirobj.h +++ b/src/clutils/dirobj.h @@ -47,57 +47,63 @@ /*****************************************************************************/ -class SC_UTILS_EXPORT DirObj { +class SC_UTILS_EXPORT DirObj +{ public: - DirObj( const char * dirName ); + DirObj(const char *dirName); virtual ~DirObj(); - bool LoadDirectory( const std::string & name ); - static std::string Normalize( const std::string & s ); + bool LoadDirectory(const std::string &name); + static std::string Normalize(const std::string &s); - const char * ValidDirectories( const char * ); + const char *ValidDirectories(const char *); - int Index( const char * ); - const char * File( int index ); + int Index(const char *); + const char *File(int index); // check for file in the currently loaded directory - bool FileExists( const char * file ) { - return Index( file ) ? 1 : 0; + bool FileExists(const char *file) + { + return Index(file) ? 1 : 0; } - bool FileExists( const std::string & file ) { - return Index( file.c_str() ) ? true : false; + bool FileExists(const std::string &file) + { + return Index(file.c_str()) ? true : false; } int Count(); - static bool IsADirectory( const char * ); + static bool IsADirectory(const char *); private: - const char * RealPath( const char * ); + const char *RealPath(const char *); - bool Reset( const std::string & path ); + bool Reset(const std::string &path); void ClearFileList(); - void CheckIndex( int index ); - void InsertFile( const char *, int index ); - void AppendFile( const char * ); - void RemoveFile( int index ); - virtual int Position( const char * ); + void CheckIndex(int index); + void InsertFile(const char *, int index); + void AppendFile(const char *); + void RemoveFile(int index); + virtual int Position(const char *); private: - char ** fileList; + char **fileList; int fileCount; int fileListSize; }; // Return the number of files in the loaded directory. -inline int DirObj::Count() { +inline int DirObj::Count() +{ return fileCount; } // Insert a new file into the fileList. -inline void DirObj::AppendFile( const char * s ) { - InsertFile( s, fileCount ); +inline void DirObj::AppendFile(const char *s) +{ + InsertFile(s, fileCount); } // Return the file at the given index (starting at 0) in the fileList -inline const char * DirObj::File( int index ) { - return ( 0 <= index && index < fileCount ) ? fileList[index] : 0; +inline const char *DirObj::File(int index) +{ + return (0 <= index && index < fileCount) ? fileList[index] : 0; } #endif diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index c5a998c8c..9d76c6e22 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -15,58 +15,60 @@ #include DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; -ostream * ErrorDescriptor::_out = 0; +ostream *ErrorDescriptor::_out = 0; void -ErrorDescriptor::PrintContents( ostream & out ) const { +ErrorDescriptor::PrintContents(ostream &out) const +{ out << "Severity: " << severityString() << endl; - if( !_userMsg.empty() ) { + if(!_userMsg.empty()) { out << "User message in parens:" << endl << "("; out << UserMsg() << ")" << endl; } - if( !_detailMsg.empty() ) { + if(!_detailMsg.empty()) { out << "Detailed message in parens:" << endl << "("; out << DetailMsg() << ")" << endl; } } -std::string ErrorDescriptor::severityString() const { +std::string ErrorDescriptor::severityString() const +{ std::string s; - switch( severity() ) { + switch(severity()) { case SEVERITY_NULL : { - s.assign( "SEVERITY_NULL" ); + s.assign("SEVERITY_NULL"); break; } case SEVERITY_USERMSG : { - s.assign( "SEVERITY_USERMSG" ); + s.assign("SEVERITY_USERMSG"); break; } case SEVERITY_INCOMPLETE : { - s.assign( "SEVERITY_INCOMPLETE" ); + s.assign("SEVERITY_INCOMPLETE"); break; } case SEVERITY_WARNING : { - s.assign( "SEVERITY_WARNING" ); + s.assign("SEVERITY_WARNING"); break; } case SEVERITY_INPUT_ERROR : { - s.assign( "SEVERITY_INPUT_ERROR" ); + s.assign("SEVERITY_INPUT_ERROR"); break; } case SEVERITY_BUG : { - s.assign( "SEVERITY_BUG" ); + s.assign("SEVERITY_BUG"); break; } case SEVERITY_EXIT : { - s.assign( "SEVERITY_EXIT" ); + s.assign("SEVERITY_EXIT"); break; } case SEVERITY_DUMP : { - s.assign( "SEVERITY_DUMP" ); + s.assign("SEVERITY_DUMP"); break; } case SEVERITY_MAX : { - s.assign( "SEVERITY_MAX" ); + s.assign("SEVERITY_MAX"); break; } } @@ -75,35 +77,36 @@ std::string ErrorDescriptor::severityString() const { Severity -ErrorDescriptor::GetCorrSeverity( const char * s ) { - if( s && s[0] != 0 ) { +ErrorDescriptor::GetCorrSeverity(const char *s) +{ + if(s && s[0] != 0) { std::string s2; - StrToUpper( s, s2 ); - if( !s2.compare( "SEVERITY_NULL" ) ) { + StrToUpper(s, s2); + if(!s2.compare("SEVERITY_NULL")) { return SEVERITY_NULL; } - if( !s2.compare( "SEVERITY_USERMSG" ) ) { + if(!s2.compare("SEVERITY_USERMSG")) { return SEVERITY_USERMSG; } - if( !s2.compare( "SEVERITY_INCOMPLETE" ) ) { + if(!s2.compare("SEVERITY_INCOMPLETE")) { return SEVERITY_INCOMPLETE; } - if( !s2.compare( "SEVERITY_WARNING" ) ) { + if(!s2.compare("SEVERITY_WARNING")) { return SEVERITY_WARNING; } - if( !s2.compare( "SEVERITY_INPUT_ERROR" ) ) { + if(!s2.compare("SEVERITY_INPUT_ERROR")) { return SEVERITY_INPUT_ERROR; } - if( !s2.compare( "SEVERITY_BUG" ) ) { + if(!s2.compare("SEVERITY_BUG")) { return SEVERITY_BUG; } - if( !s2.compare( "SEVERITY_EXIT" ) ) { + if(!s2.compare("SEVERITY_EXIT")) { return SEVERITY_EXIT; } - if( !s2.compare( "SEVERITY_DUMP" ) ) { + if(!s2.compare("SEVERITY_DUMP")) { return SEVERITY_DUMP; } - if( !s2.compare( "SEVERITY_MAX" ) ) { + if(!s2.compare("SEVERITY_MAX")) { return SEVERITY_MAX; } } @@ -113,43 +116,53 @@ ErrorDescriptor::GetCorrSeverity( const char * s ) { return SEVERITY_BUG; } -ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) { - if( d != DEBUG_OFF ) { +ErrorDescriptor::ErrorDescriptor(Severity s, DebugLevel d) : _severity(s) +{ + if(d != DEBUG_OFF) { _debug_level = d; } } -ErrorDescriptor::~ErrorDescriptor( void ) { +ErrorDescriptor::~ErrorDescriptor(void) +{ } -void ErrorDescriptor::UserMsg( const char * msg ) { - _userMsg.assign( msg ); +void ErrorDescriptor::UserMsg(const char *msg) +{ + _userMsg.assign(msg); } -void ErrorDescriptor::PrependToUserMsg( const char * msg ) { - _userMsg.insert( 0, msg ); +void ErrorDescriptor::PrependToUserMsg(const char *msg) +{ + _userMsg.insert(0, msg); } -void ErrorDescriptor::AppendToUserMsg( const char c ) { - _userMsg.push_back( c ); +void ErrorDescriptor::AppendToUserMsg(const char c) +{ + _userMsg.push_back(c); } -void ErrorDescriptor::AppendToUserMsg( const char * msg ) { - _userMsg.append( msg ); +void ErrorDescriptor::AppendToUserMsg(const char *msg) +{ + _userMsg.append(msg); } -void ErrorDescriptor::DetailMsg( const char * msg ) { - _detailMsg.assign( msg ); +void ErrorDescriptor::DetailMsg(const char *msg) +{ + _detailMsg.assign(msg); } -void ErrorDescriptor::PrependToDetailMsg( const char * msg ) { - _detailMsg.insert( 0, msg ); +void ErrorDescriptor::PrependToDetailMsg(const char *msg) +{ + _detailMsg.insert(0, msg); } -void ErrorDescriptor::AppendToDetailMsg( const char c ) { - _detailMsg.push_back( c ); +void ErrorDescriptor::AppendToDetailMsg(const char c) +{ + _detailMsg.push_back(c); } -void ErrorDescriptor::AppendToDetailMsg( const char * msg ) { - _detailMsg.append( msg ); +void ErrorDescriptor::AppendToDetailMsg(const char *msg) +{ + _detailMsg.append(msg); } diff --git a/src/clutils/errordesc.h b/src/clutils/errordesc.h index 4ab284b2d..c2c3671e4 100644 --- a/src/clutils/errordesc.h +++ b/src/clutils/errordesc.h @@ -53,7 +53,8 @@ typedef int DebugLevel; ** Status: ******************************************************************/ -class SC_UTILS_EXPORT ErrorDescriptor { +class SC_UTILS_EXPORT ErrorDescriptor +{ private: #ifdef _MSC_VER #pragma warning( push ) @@ -67,76 +68,90 @@ class SC_UTILS_EXPORT ErrorDescriptor { Severity _severity; static DebugLevel _debug_level; - static ostream * _out; // note this will not be persistent + static ostream *_out; // note this will not be persistent public: - ErrorDescriptor( Severity s = SEVERITY_NULL, - DebugLevel d = DEBUG_OFF ); - ~ErrorDescriptor( void ); + ErrorDescriptor(Severity s = SEVERITY_NULL, + DebugLevel d = DEBUG_OFF); + ~ErrorDescriptor(void); - void PrintContents( ostream & out = cout ) const; + void PrintContents(ostream &out = cout) const; - void ClearErrorMsg() { + void ClearErrorMsg() + { _severity = SEVERITY_NULL; _userMsg.clear(); _detailMsg.clear(); } // return the enum value of _severity - Severity severity() const { + Severity severity() const + { return _severity; } - Severity severity( Severity s ) { - return ( _severity = s ); + Severity severity(Severity s) + { + return (_severity = s); } std::string severityString() const; - Severity GetCorrSeverity( const char * s ); - Severity GreaterSeverity( Severity s ) { - return ( ( s < _severity ) ? _severity = s : _severity ); + Severity GetCorrSeverity(const char *s); + Severity GreaterSeverity(Severity s) + { + return ((s < _severity) ? _severity = s : _severity); } - std::string UserMsg() const { + std::string UserMsg() const + { return _userMsg; } - void UserMsg( const char * msg ); - void UserMsg( const std::string msg ) { - _userMsg.assign( msg ); + void UserMsg(const char *msg); + void UserMsg(const std::string msg) + { + _userMsg.assign(msg); } - void AppendToUserMsg( const char * msg ); - void AppendToUserMsg( const char c ); - void AppendToUserMsg( const std::string & msg ) { - _userMsg.append( msg ); + void AppendToUserMsg(const char *msg); + void AppendToUserMsg(const char c); + void AppendToUserMsg(const std::string &msg) + { + _userMsg.append(msg); } - void PrependToUserMsg( const char * msg ); + void PrependToUserMsg(const char *msg); - std::string DetailMsg() const { + std::string DetailMsg() const + { return _detailMsg; } - void DetailMsg( const std::string msg ) { - _detailMsg.assign( msg ); + void DetailMsg(const std::string msg) + { + _detailMsg.assign(msg); } - void DetailMsg( const char * msg ); - void AppendToDetailMsg( const char * msg ); - void AppendToDetailMsg( const std::string & msg ) { - _detailMsg.append( msg ); + void DetailMsg(const char *msg); + void AppendToDetailMsg(const char *msg); + void AppendToDetailMsg(const std::string &msg) + { + _detailMsg.append(msg); } - void PrependToDetailMsg( const char * msg ); - void AppendToDetailMsg( const char c ); - - Severity AppendFromErrorArg( ErrorDescriptor * err ) { - GreaterSeverity( err->severity() ); - AppendToDetailMsg( err->DetailMsg() ); - AppendToUserMsg( err->UserMsg() ); + void PrependToDetailMsg(const char *msg); + void AppendToDetailMsg(const char c); + + Severity AppendFromErrorArg(ErrorDescriptor *err) + { + GreaterSeverity(err->severity()); + AppendToDetailMsg(err->DetailMsg()); + AppendToUserMsg(err->UserMsg()); return severity(); } - DebugLevel debug_level() const { + DebugLevel debug_level() const + { return _debug_level; } - void debug_level( DebugLevel d ) { + void debug_level(DebugLevel d) + { _debug_level = d; } - void SetOutput( ostream * o ) { + void SetOutput(ostream *o) + { _out = o; } } ; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index 3036ab19d..b29c021a2 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -24,11 +24,12 @@ // void GenNodeList::Append(GenericNode *node) from the gennodelist.h ////////////////////////////////////////////////////////////////////////////// -void GenericNode::Append( GenNodeList * list ) { +void GenericNode::Append(GenNodeList *list) +{ // if(debug_level >= PrintFunctionTrace) // cout << "GenericNode::Append()\n"; // if(debug_level >= PrintValues) // cout << "GenericNode::this : '" << this << "'\n"; - list->Append( this ); + list->Append(this); } diff --git a/src/clutils/gennode.h b/src/clutils/gennode.h index c4c630244..f8285a827 100644 --- a/src/clutils/gennode.h +++ b/src/clutils/gennode.h @@ -27,28 +27,32 @@ class DisplayNodeList; // If you delete this object it first removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenericNode { +class SC_UTILS_EXPORT GenericNode +{ friend class GenNodeList; friend class MgrNodeList; friend class DisplayNodeList; protected: - GenericNode * next; - GenericNode * prev; + GenericNode *next; + GenericNode *prev; public: GenericNode(); virtual ~GenericNode(); - GenericNode * Next() { + GenericNode *Next() + { return next; } - GenericNode * Prev() { + GenericNode *Prev() + { return prev; } - virtual void Append( GenNodeList * list ); - virtual void Remove() { - ( next ) ? ( next->prev = prev ) : 0; - ( prev ) ? ( prev->next = next ) : 0; + virtual void Append(GenNodeList *list); + virtual void Remove() + { + (next) ? (next->prev = prev) : 0; + (prev) ? (prev->next = next) : 0; /* // if(next) // next->prev = prev; diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index f78acbd14..16e3a3b7b 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -20,70 +20,79 @@ #ifndef HAVE_MEMMOVE extern "C" { - extern void * memmove( void *, const void *, size_t ); + extern void *memmove(void *, const void *, size_t); } #endif -GenericNode::GenericNode() { +GenericNode::GenericNode() +{ next = 0; prev = 0; } -GenericNode::~GenericNode() { +GenericNode::~GenericNode() +{ Remove(); } -GenNodeArray::GenNodeArray( int defaultSize ) { +GenNodeArray::GenNodeArray(int defaultSize) +{ _bufsize = defaultSize; _buf = new GenericNode*[_bufsize]; - memset( _buf, 0, _bufsize * sizeof( GenericNode * ) ); + memset(_buf, 0, _bufsize * sizeof(GenericNode *)); _count = 0; } -GenNodeArray::~GenNodeArray() { +GenNodeArray::~GenNodeArray() +{ delete [] _buf; } -int GenNodeArray::Index( GenericNode ** gn ) { - return ( ( gn - _buf ) / sizeof( GenericNode * ) ); +int GenNodeArray::Index(GenericNode **gn) +{ + return ((gn - _buf) / sizeof(GenericNode *)); } -void GenNodeArray::Append( GenericNode * gn ) { - Insert( gn, _count ); +void GenNodeArray::Append(GenericNode *gn) +{ + Insert(gn, _count); } -int GenNodeArray::Insert( GenericNode * gn ) { - return Insert( gn, _count ); +int GenNodeArray::Insert(GenericNode *gn) +{ + return Insert(gn, _count); } void -GenNodeArray::Check( int index ) { - GenericNode ** newbuf; +GenNodeArray::Check(int index) +{ + GenericNode **newbuf; - if( index >= _bufsize ) { - _bufsize = ( index + 1 ) * 2; + if(index >= _bufsize) { + _bufsize = (index + 1) * 2; newbuf = new GenericNode*[_bufsize]; - memset( newbuf, 0, _bufsize * sizeof( GenericNode * ) ); - memmove( newbuf, _buf, _count * sizeof( GenericNode * ) ); + memset(newbuf, 0, _bufsize * sizeof(GenericNode *)); + memmove(newbuf, _buf, _count * sizeof(GenericNode *)); delete [] _buf; _buf = newbuf; } } int -GenNodeArray::Insert( GenericNode * gn, int index ) { - const GenericNode ** spot; - index = ( index < 0 ) ? _count : index; +GenNodeArray::Insert(GenericNode *gn, int index) +{ + const GenericNode **spot; + index = (index < 0) ? _count : index; - if( index < _count ) { - Check( _count + 1 ); - spot = ( const GenericNode ** )&_buf[index]; - memmove( spot + 1, spot, ( _count - index )*sizeof( GenericNode * ) ); + if(index < _count) { + Check(_count + 1); + spot = (const GenericNode **)&_buf[index]; + memmove(spot + 1, spot, (_count - index)*sizeof(GenericNode *)); } else { - Check( index ); - spot = ( const GenericNode ** )&_buf[index]; + Check(index); + spot = (const GenericNode **)&_buf[index]; } *spot = gn; ++_count; @@ -91,35 +100,39 @@ GenNodeArray::Insert( GenericNode * gn, int index ) { } void -GenNodeArray::Remove( int index ) { - if( 0 <= index && index < _count ) { +GenNodeArray::Remove(int index) +{ + if(0 <= index && index < _count) { --_count; - const GenericNode ** spot = ( const GenericNode ** )&_buf[index]; - memmove( spot, spot + 1, ( _count - index )*sizeof( GenericNode * ) ); + const GenericNode **spot = (const GenericNode **)&_buf[index]; + memmove(spot, spot + 1, (_count - index)*sizeof(GenericNode *)); _buf[_count] = 0; } } -void GenNodeArray::ClearEntries() { +void GenNodeArray::ClearEntries() +{ int i; - for( i = 0 ; i < _count; i++ ) { + for(i = 0 ; i < _count; i++) { _buf[i] = 0; } _count = 0; } -void GenNodeArray::DeleteEntries() { +void GenNodeArray::DeleteEntries() +{ int i; - for( i = 0 ; i < _count; i++ ) { - delete( _buf[i] ); + for(i = 0 ; i < _count; i++) { + delete(_buf[i]); } _count = 0; } -int GenNodeArray::Index( GenericNode * gn ) { - for( int i = 0; i < _count; ++i ) { - if( _buf[i] == gn ) { +int GenNodeArray::Index(GenericNode *gn) +{ + for(int i = 0; i < _count; ++i) { + if(_buf[i] == gn) { return i; } } diff --git a/src/clutils/gennodearray.h b/src/clutils/gennodearray.h index 4c0ee075a..19de427c1 100644 --- a/src/clutils/gennodearray.h +++ b/src/clutils/gennodearray.h @@ -38,29 +38,30 @@ // DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeArray { +class SC_UTILS_EXPORT GenNodeArray +{ public: - GenNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); + GenNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); virtual ~GenNodeArray(); - GenericNode *& operator[]( int index ); - virtual int Index( GenericNode * gn ); - virtual int Index( GenericNode ** gn ); + GenericNode *&operator[](int index); + virtual int Index(GenericNode *gn); + virtual int Index(GenericNode **gn); int Count() const; - virtual void Append( GenericNode * gn ); - virtual int Insert( GenericNode * gn ); - virtual int Insert( GenericNode * gn, int index ); - virtual void Remove( int index ); + virtual void Append(GenericNode *gn); + virtual int Insert(GenericNode *gn); + virtual int Insert(GenericNode *gn, int index); + virtual void Remove(int index); virtual void ClearEntries(); virtual void DeleteEntries(); protected: - virtual void Check( int index ); + virtual void Check(int index); - GenericNode ** _buf; // the array + GenericNode **_buf; // the array int _bufsize; // the possible number of entries in the array int _count; // the number of entries in the array }; @@ -69,12 +70,14 @@ class SC_UTILS_EXPORT GenNodeArray { // class GenNodeArray inline public functions ////////////////////////////////////////////////////////////////////////////// -inline GenericNode *& GenNodeArray::operator[]( int index ) { - Check( index ); +inline GenericNode *&GenNodeArray::operator[](int index) +{ + Check(index); return _buf[index]; } -inline int GenNodeArray::Count() const { +inline int GenNodeArray::Count() const +{ return _count; } diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index 9560a72b1..478601172 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -19,8 +19,9 @@ #include // inserts after existNode -void GenNodeList::InsertAfter( GenericNode * newNode, - GenericNode * existNode ) { +void GenNodeList::InsertAfter(GenericNode *newNode, + GenericNode *existNode) +{ newNode->next = existNode->next; newNode->next->prev = newNode; @@ -29,8 +30,9 @@ void GenNodeList::InsertAfter( GenericNode * newNode, } // inserts before existNode -void GenNodeList::InsertBefore( GenericNode * newNode, - GenericNode * existNode ) { +void GenNodeList::InsertBefore(GenericNode *newNode, + GenericNode *existNode) +{ existNode->prev->next = newNode; newNode->prev = existNode->prev; @@ -39,26 +41,29 @@ void GenNodeList::InsertBefore( GenericNode * newNode, } // inserts before the head node -void GenNodeList::Append( GenericNode * node ) { - InsertBefore( node, head ); +void GenNodeList::Append(GenericNode *node) +{ + InsertBefore(node, head); } void -GenNodeList::Remove( GenericNode * node ) { - if( node != head ) { +GenNodeList::Remove(GenericNode *node) +{ + if(node != head) { node->next->prev = node->prev; node->prev->next = node->next; node->next = 0; node->prev = 0; } } -void GenNodeList::ClearEntries() { +void GenNodeList::ClearEntries() +{ // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::ClearEntries()\n"; - GenericNode * gnPrev = head->Next(); - GenericNode * gn = gnPrev->Next(); + GenericNode *gnPrev = head->Next(); + GenericNode *gn = gnPrev->Next(); - while( gnPrev != head ) { + while(gnPrev != head) { gnPrev->prev = 0; gnPrev->next = 0; gnPrev = gn; @@ -68,14 +73,15 @@ void GenNodeList::ClearEntries() { head->prev = head; } -void GenNodeList::DeleteEntries() { +void GenNodeList::DeleteEntries() +{ // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::DeleteEntries()\n"; - GenericNode * gnPrev = head->Next(); - GenericNode * gn; + GenericNode *gnPrev = head->Next(); + GenericNode *gn; head->next = 0; - while( gnPrev != head ) { + while(gnPrev != head) { gn = gnPrev->Next(); delete gnPrev; gnPrev = gn; diff --git a/src/clutils/gennodelist.h b/src/clutils/gennodelist.h index 4751f6044..3ba1f50c2 100644 --- a/src/clutils/gennodelist.h +++ b/src/clutils/gennodelist.h @@ -26,30 +26,33 @@ // as its head, you need to call DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeList { +class SC_UTILS_EXPORT GenNodeList +{ public: - GenNodeList( GenericNode * headNode ); - virtual ~GenNodeList() { + GenNodeList(GenericNode *headNode); + virtual ~GenNodeList() + { delete head; } - GenericNode * GetHead() { + GenericNode *GetHead() + { return head; } virtual void ClearEntries(); virtual void DeleteEntries(); // deletes node from its previous list & appends - virtual void Append( GenericNode * node ); + virtual void Append(GenericNode *node); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); - virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); + virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); - virtual void Remove( GenericNode * node ); + virtual void Remove(GenericNode *node); protected: - GenericNode * head; + GenericNode *head; }; ////////////////////////////////////////////////////////////////////////////// @@ -58,7 +61,8 @@ class SC_UTILS_EXPORT GenNodeList { // other classes) that aren't in this file ////////////////////////////////////////////////////////////////////////////// -inline GenNodeList::GenNodeList( GenericNode * headNode ) { +inline GenNodeList::GenNodeList(GenericNode *headNode) +{ head = headNode; head->next = head; head->prev = head; diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index 706780411..654e110a3 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -32,43 +32,46 @@ /* typedefs */ typedef unsigned long Address; -typedef struct Element * ElementP; -typedef struct Hash_Table * Hash_TableP; +typedef struct Element *ElementP; +typedef struct Hash_Table *Hash_TableP; /* Internal routines */ -Address SC_HASHhash( char *, Hash_TableP ); -static void SC_HASHexpand_table( Hash_TableP ); +Address SC_HASHhash(char *, Hash_TableP); +static void SC_HASHexpand_table(Hash_TableP); # ifdef HASH_STATISTICS static long HashAccesses, HashCollisions; # endif /// find entry in given hash table -void * SC_HASHfind( Hash_TableP t, char * s ) { +void *SC_HASHfind(Hash_TableP t, char *s) +{ struct Element e; - struct Element * ep; + struct Element *ep; e.key = s; e.symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ - ep = SC_HASHsearch( t, &e, HASH_FIND ); - return( ep ? ep->data : 0 ); + ep = SC_HASHsearch(t, &e, HASH_FIND); + return(ep ? ep->data : 0); } /// insert entry into given hash table -void SC_HASHinsert( Hash_TableP t, char * s, void * data ) { +void SC_HASHinsert(Hash_TableP t, char *s, void *data) +{ struct Element e, *e2; e.key = s; e.data = data; e.symbol = 0; - e2 = SC_HASHsearch( t, &e, HASH_INSERT ); - if( e2 ) { - fprintf( stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s ); + e2 = SC_HASHsearch(t, &e, HASH_INSERT); + if(e2) { + fprintf(stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s); } } /// create a hash table -Hash_TableP SC_HASHcreate( unsigned count ) { +Hash_TableP SC_HASHcreate(unsigned count) +{ unsigned int i; Hash_TableP table; @@ -77,51 +80,52 @@ Hash_TableP SC_HASHcreate( unsigned count ) { ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while( i < count ) { + while(i < count) { i <<= 1; } - count = DIV( i, SEGMENT_SIZE ); + count = DIV(i, SEGMENT_SIZE); - table = ( Hash_TableP ) SC_HASH_Table_new(); + table = (Hash_TableP) SC_HASH_Table_new(); table->SegmentCount = table->p = table->KeyCount = 0; /* ** First initialize directory to 0\'s ** DIRECTORY_SIZE must be same as in header */ - for( i = 0; i < DIRECTORY_SIZE; i++ ) { + for(i = 0; i < DIRECTORY_SIZE; i++) { table->Directory[i] = 0; } /* ** Allocate initial 'i' segments of buckets */ - for( i = 0; i < count; i++ ) { + for(i = 0; i < count; i++) { table->Directory[i] = new struct Element * [SEGMENT_SIZE]; - for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL + for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL table->Directory[i][h] = 0; } } table->SegmentCount = count; - table->maxp = MUL( count, SEGMENT_SIZE ); + table->maxp = MUL(count, SEGMENT_SIZE); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef DEBUG - fprintf( stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount ); + fprintf(stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return( table ); + return(table); } /** initialize pointer to beginning of hash table so we can * step through it on repeated calls to HASHlist - DEL */ -void SC_HASHlistinit( Hash_TableP table, HashEntry * he ) { +void SC_HASHlistinit(Hash_TableP table, HashEntry *he) +{ he->i = he->j = 0; he->p = 0; he->table = table; @@ -129,7 +133,8 @@ void SC_HASHlistinit( Hash_TableP table, HashEntry * he ) { he->e = 0; } -void SC_HASHlistinit_by_type( Hash_TableP table, HashEntry * he, char type ) { +void SC_HASHlistinit_by_type(Hash_TableP table, HashEntry *he, char type) +{ he->i = he->j = 0; he->p = 0; he->table = table; @@ -138,18 +143,19 @@ void SC_HASHlistinit_by_type( Hash_TableP table, HashEntry * he, char type ) { } /** provide a way to step through the hash */ -struct Element * SC_HASHlist( HashEntry * he ) { +struct Element *SC_HASHlist(HashEntry *he) +{ int i2 = he->i; int j2 = he->j; - struct Element ** s; + struct Element **s; he->e = 0; - for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { + for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { /* test probably unnecessary */ - if( ( s = he->table->Directory[he->i] ) != NULL ) { - for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { - if( !he->p ) { + if((s = he->table->Directory[he->i]) != NULL) { + for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { + if(!he->p) { he->p = s[he->j]; } @@ -157,44 +163,45 @@ struct Element * SC_HASHlist( HashEntry * he ) { setting it to he->e) and begin looking for a new value for he->p */ - while( he->p && he->type != '*' && he->type != he->p->type ) { + while(he->p && he->type != '*' && he->type != he->p->type) { he->p = he->p->next; } - if( he->p ) { - if( he->e ) { - return( he->e ); + if(he->p) { + if(he->e) { + return(he->e); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if( he->p ) { - return( he->e ); + if(he->p) { + return(he->e); } } j2 = 0; } } /* if he->e was set then it is last one */ - return( he->e ); + return(he->e); } /// destroy all elements in given table, then the table itself -void SC_HASHdestroy( Hash_TableP table ) { - struct Element ** s; - struct Element * p, *q; +void SC_HASHdestroy(Hash_TableP table) +{ + struct Element **s; + struct Element *p, *q; - if( table != HASH_NULL ) { + if(table != HASH_NULL) { unsigned int i, j; - for( i = 0; i < table->SegmentCount; i++ ) { + for(i = 0; i < table->SegmentCount; i++) { /* test probably unnecessary */ - if( ( s = table->Directory[i] ) != NULL ) { - for( j = 0; j < SEGMENT_SIZE; j++ ) { + if((s = table->Directory[i]) != NULL) { + for(j = 0; j < SEGMENT_SIZE; j++) { p = s[j]; - while( p != NULL ) { + while(p != NULL) { q = p->next; - SC_HASH_Element_destroy( p ); + SC_HASH_Element_destroy(p); p = q; } } @@ -202,29 +209,30 @@ void SC_HASHdestroy( Hash_TableP table ) { delete [] table->Directory[i]; } } - SC_HASH_Table_destroy( table ); + SC_HASH_Table_destroy(table); # if defined(HASH_STATISTICS) && defined(DEBUG) - fprintf( stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions ); + fprintf(stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions); # endif } } /// search table for 'item', perform 'action' (find/insert/delete) -struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, Action action ) { +struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Action action) +{ Address h; - struct Element ** CurrentSegment; + struct Element **CurrentSegment; int SegmentIndex; int SegmentDir; - struct Element ** p; - struct Element * q; - struct Element * deleteme; + struct Element **p; + struct Element *q; + struct Element *deleteme; # ifdef HASH_STATISTICS HashAccesses++; # endif - h = SC_HASHhash( item->key, table ); - SegmentDir = ( int ) DIV( h, SEGMENT_SIZE ); - SegmentIndex = ( int ) MOD( h, SEGMENT_SIZE ); + h = SC_HASHhash(item->key, table); + SegmentDir = (int) DIV(h, SEGMENT_SIZE); + SegmentIndex = (int) MOD(h, SEGMENT_SIZE); /* ** valid segment ensured by HASHhash() */ @@ -237,7 +245,7 @@ struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, ** p = &element, and ** q = element */ - while( q != NULL && strcmp( q->key, item->key ) ) { + while(q != NULL && strcmp(q->key, item->key)) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -245,28 +253,28 @@ struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, # endif } /* at this point, we have either found the element or it doesn't exist */ - switch( action ) { + switch(action) { case HASH_FIND: - return( ( struct Element * )q ); + return((struct Element *)q); case HASH_DELETE: - if( !q ) { - return( 0 ); + if(!q) { + return(0); } /* at this point, element exists and action == DELETE */ deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - SC_HASH_Element_destroy( deleteme ); + SC_HASH_Element_destroy(deleteme); --table->KeyCount; - return( deleteme ); /* of course, user shouldn't deref this! */ + return(deleteme); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if( q != NULL ) { - return( q ); /* was return(0);!!!!!?!?! */ + if(q != NULL) { + return(q); /* was return(0);!!!!!?!?! */ } /* at this point, element does not exist and action == INSERT */ - q = ( ElementP ) SC_HASH_Element_new(); + q = (ElementP) SC_HASH_Element_new(); *p = q; /* link into chain */ /* ** Initialize new element @@ -281,59 +289,61 @@ struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, /* ** table over-full? */ - if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE ) > table->MaxLoadFactor ) { - SC_HASHexpand_table( table ); /* doesn't affect q */ + if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE) > table->MaxLoadFactor) { + SC_HASHexpand_table(table); /* doesn't affect q */ } } - return( ( struct Element * )0 ); /* was return (Element)q */ + return((struct Element *)0); /* was return (Element)q */ } /* ** Internal routines */ -Address SC_HASHhash( char * Key, Hash_TableP table ) { +Address SC_HASHhash(char *Key, Hash_TableP table) +{ Address h, address; - unsigned char * k = ( unsigned char * )Key; + unsigned char *k = (unsigned char *)Key; h = 0; /* ** Convert string to integer */ - while( *k ) { - h = h * PRIME1 ^ ( *k++ - ' ' ); + while(*k) { + h = h * PRIME1 ^ (*k++ - ' '); } h %= PRIME2; - address = MOD( h, table->maxp ); - if( address < table->p ) { - address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ + address = MOD(h, table->maxp); + if(address < table->p) { + address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ } - return( address ); + return(address); } -static void SC_HASHexpand_table( Hash_TableP table ) { - struct Element ** OldSegment, **NewSegment; - struct Element * Current, **Previous, **LastOfNew; +static void SC_HASHexpand_table(Hash_TableP table) +{ + struct Element **OldSegment, **NewSegment; + struct Element *Current, **Previous, **LastOfNew; - if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE ) ) { + if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE)) { /* ** Locate the bucket to be split */ Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; - OldSegmentDir = DIV( table->p, SEGMENT_SIZE ); + OldSegmentDir = DIV(table->p, SEGMENT_SIZE); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); + OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = ( int ) DIV( NewAddress, SEGMENT_SIZE ); - NewSegmentIndex = ( int ) MOD( NewAddress, SEGMENT_SIZE ); - if( NewSegmentIndex == 0 ) { + NewSegmentDir = (int) DIV(NewAddress, SEGMENT_SIZE); + NewSegmentIndex = (int) MOD(NewAddress, SEGMENT_SIZE); + if(NewSegmentIndex == 0) { table->Directory[NewSegmentDir] = new struct Element * [SEGMENT_SIZE]; - for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL + for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL table->Directory[NewSegmentDir][h] = 0; } } @@ -343,7 +353,7 @@ static void SC_HASHexpand_table( Hash_TableP table ) { ** Adjust state variables */ table->p++; - if( table->p == table->maxp ) { + if(table->p == table->maxp) { table->maxp <<= 1; table->p = 0; } @@ -355,8 +365,8 @@ static void SC_HASHexpand_table( Hash_TableP table ) { Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while( Current != NULL ) { - if( SC_HASHhash( Current->key, table ) == NewAddress ) { + while(Current != NULL) { + if(SC_HASHhash(Current->key, table) == NewAddress) { /* ** Attach it to the end of the new chain */ @@ -382,28 +392,29 @@ static void SC_HASHexpand_table( Hash_TableP table ) { /* for testing sc_hash */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table * t; +struct Hash_Table *t; HashEntry he; -main() { +main() +{ e1.key = "foo"; - e1.data = ( char * )1; + e1.data = (char *)1; e2.key = "bar"; - e2.data = ( char * )2; + e2.data = (char *)2; e3.key = "herschel"; - e3.data = ( char * )3; - - t = SC_HASHcreate( 100 ); - e = SC_HASHsearch( t, &e1, HASH_INSERT ); - e = SC_HASHsearch( t, &e2, HASH_INSERT ); - e = SC_HASHsearch( t, &e3, HASH_INSERT ); - SC_HASHlistinit( t, &he ); - for( ;; ) { - e = SC_HASHlist( &he ); - if( !e ) { - exit( 0 ); + e3.data = (char *)3; + + t = SC_HASHcreate(100); + e = SC_HASHsearch(t, &e1, HASH_INSERT); + e = SC_HASHsearch(t, &e2, HASH_INSERT); + e = SC_HASHsearch(t, &e3, HASH_INSERT); + SC_HASHlistinit(t, &he); + for(;;) { + e = SC_HASHlist(&he); + if(!e) { + exit(0); } - printf( "found key %s, data %d\n", e->key, ( int )e->data ); + printf("found key %s, data %d\n", e->key, (int)e->data); } } #endif diff --git a/src/clutils/sc_hash.h b/src/clutils/sc_hash.h index f6a230ba9..dde8245f3 100644 --- a/src/clutils/sc_hash.h +++ b/src/clutils/sc_hash.h @@ -96,10 +96,10 @@ typedef enum { HASH_FIND, HASH_INSERT, HASH_DELETE } Action; struct Element { - char * key; - void * data; - struct Element * next; - struct Symbol * symbol; //for debugging hash conflicts + char *key; + void *data; + struct Element *next; + struct Symbol *symbol; //for debugging hash conflicts char type; //user-supplied type }; @@ -112,16 +112,16 @@ struct Hash_Table { unsigned int MaxLoadFactor; #define DIRECTORY_SIZE 256 #define DIRECTORY_SIZE_SHIFT 8 // log2(DIRECTORY_SIZE) - struct Element ** Directory[DIRECTORY_SIZE]; + struct Element **Directory[DIRECTORY_SIZE]; }; typedef struct { unsigned int i; // segment index (i think) unsigned int j; // key index in segment (ditto) - struct Element * p; // usually the next element to be returned - struct Hash_Table * table; + struct Element *p; // usually the next element to be returned + struct Hash_Table *table; char type; - struct Element * e; /* originally thought of as a place for */ + struct Element *e; /* originally thought of as a place for */ /* the caller of HASHlist to temporarily stash the return value */ /* to allow the caller (i.e., DICTdo) to be macroized, but now */ /* conveniently used by HASHlist, which both stores the ultimate */ @@ -132,15 +132,15 @@ typedef struct { extern "C" { #endif - SC_UTILS_EXPORT struct Hash_Table * SC_HASHcreate( unsigned ); - SC_UTILS_EXPORT void SC_HASHinitialize( void ); - SC_UTILS_EXPORT void * SC_HASHfind( struct Hash_Table *, char * ); - SC_UTILS_EXPORT void SC_HASHinsert( struct Hash_Table *, char *, void * ); - SC_UTILS_EXPORT void SC_HASHdestroy( struct Hash_Table * ); - SC_UTILS_EXPORT struct Element * SC_HASHsearch( struct Hash_Table *, const struct Element *, Action ); - SC_UTILS_EXPORT void SC_HASHlistinit( struct Hash_Table *, HashEntry * ); - SC_UTILS_EXPORT void SC_HASHlistinit_by_type( struct Hash_Table *, HashEntry *, char ); - SC_UTILS_EXPORT struct Element * SC_HASHlist( HashEntry * ); +SC_UTILS_EXPORT struct Hash_Table *SC_HASHcreate(unsigned); +SC_UTILS_EXPORT void SC_HASHinitialize(void); +SC_UTILS_EXPORT void *SC_HASHfind(struct Hash_Table *, char *); +SC_UTILS_EXPORT void SC_HASHinsert(struct Hash_Table *, char *, void *); +SC_UTILS_EXPORT void SC_HASHdestroy(struct Hash_Table *); +SC_UTILS_EXPORT struct Element *SC_HASHsearch(struct Hash_Table *, const struct Element *, Action); +SC_UTILS_EXPORT void SC_HASHlistinit(struct Hash_Table *, HashEntry *); +SC_UTILS_EXPORT void SC_HASHlistinit_by_type(struct Hash_Table *, HashEntry *, char); +SC_UTILS_EXPORT struct Element *SC_HASHlist(HashEntry *); #ifdef __cplusplus } diff --git a/src/exp2cxx/class_strings.c b/src/exp2cxx/class_strings.c index d1736a644..69fe2b4b8 100644 --- a/src/exp2cxx/class_strings.c +++ b/src/exp2cxx/class_strings.c @@ -4,19 +4,20 @@ #include "class_strings.h" #include "express/type.h" -const char * ClassName( const char * oldname ) { +const char *ClassName(const char *oldname) +{ int i = 0, j = 0; static char newname [BUFSIZ]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, ENTITYCLASS_PREFIX ) ; - j = strlen( ENTITYCLASS_PREFIX ) ; - newname [j] = ToUpper( oldname [i] ); + strcpy(newname, ENTITYCLASS_PREFIX) ; + j = strlen(ENTITYCLASS_PREFIX) ; + newname [j] = ToUpper(oldname [i]); ++i; ++j; - while( oldname [i] != '\0' ) { - newname [j] = ToLower( oldname [i] ); + while(oldname [i] != '\0') { + newname [j] = ToLower(oldname [i]); /* if (oldname [i] == '_') */ /* character is '_' */ /* newname [++j] = ToUpper (oldname [++i]);*/ @@ -24,108 +25,110 @@ const char * ClassName( const char * oldname ) { ++j; } newname [j] = '\0'; - return ( newname ); + return (newname); } -const char * ENTITYget_classname( Entity ent ) { - const char * oldname = ENTITYget_name( ent ); - return ( ClassName( oldname ) ); +const char *ENTITYget_classname(Entity ent) +{ + const char *oldname = ENTITYget_name(ent); + return (ClassName(oldname)); } /** like TYPEget_ctype, but caller must alloc a buffer of at least buf_siz * in many circumstances, this func will return a short string rather than using that buffer * buf_siz is ignored in those cases since it is meaningless */ -const char * TYPE_get_ctype( const Type t, char * retval, size_t buf_siz ) { - const char * ptr = "_ptr", * var = "_var", * agg = "_agg"; - const char * overflowMsg = "buffer overflow detected at %s:%d!"; +const char *TYPE_get_ctype(const Type t, char *retval, size_t buf_siz) +{ + const char *ptr = "_ptr", * var = "_var", * agg = "_agg"; + const char *overflowMsg = "buffer overflow detected at %s:%d!"; Class_Of_Type ctype; Type bt; - if( TYPEinherits_from( t, aggregate_ ) ) { - bt = TYPEget_body( t )->base; - if( TYPEinherits_from( bt, aggregate_ ) ) { - return( "GenericAggregate" ); + if(TYPEinherits_from(t, aggregate_)) { + bt = TYPEget_body(t)->base; + if(TYPEinherits_from(bt, aggregate_)) { + return("GenericAggregate"); } - ctype = TYPEget_type( bt ); - if( ctype == integer_ ) { - return ( "IntAggregate" ); + ctype = TYPEget_type(bt); + if(ctype == integer_) { + return ("IntAggregate"); } - if( ( ctype == number_ ) || ( ctype == real_ ) ) { - return ( "RealAggregate" ); + if((ctype == number_) || (ctype == real_)) { + return ("RealAggregate"); } - if( ctype == entity_ ) { - return( "EntityAggregate" ); + if(ctype == entity_) { + return("EntityAggregate"); } - if( ( ctype == enumeration_ ) || ( ctype == select_ ) ) { - const char * tmp = TYPE_get_ctype( bt, retval, buf_siz - strlen( retval ) - 1 ); - if( tmp != retval ) { - strncpy( retval, tmp, buf_siz - strlen( retval ) - 1 ); + if((ctype == enumeration_) || (ctype == select_)) { + const char *tmp = TYPE_get_ctype(bt, retval, buf_siz - strlen(retval) - 1); + if(tmp != retval) { + strncpy(retval, tmp, buf_siz - strlen(retval) - 1); } - if( strlen( retval ) + strlen( agg ) < buf_siz ) { - strcat( retval, agg ); + if(strlen(retval) + strlen(agg) < buf_siz) { + strcat(retval, agg); } else { - fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); + fprintf(stderr, overflowMsg, __FILE__, __LINE__); abort(); } - return ( retval ); + return (retval); } - if( ctype == logical_ ) { - return ( "LOGICALS" ); + if(ctype == logical_) { + return ("LOGICALS"); } - if( ctype == boolean_ ) { - return ( "BOOLEANS" ); + if(ctype == boolean_) { + return ("BOOLEANS"); } - if( ctype == string_ ) { - return( "StringAggregate" ); + if(ctype == string_) { + return("StringAggregate"); } - if( ctype == binary_ ) { - return( "BinaryAggregate" ); + if(ctype == binary_) { + return("BinaryAggregate"); } } /* the rest is for things that are not aggregates */ - ctype = TYPEget_type( t ); + ctype = TYPEget_type(t); /* case TYPE_LOGICAL: */ - if( ctype == logical_ ) { - return ( "SDAI_LOGICAL" ); + if(ctype == logical_) { + return ("SDAI_LOGICAL"); } /* case TYPE_BOOLEAN: */ - if( ctype == boolean_ ) { - return ( "SDAI_BOOLEAN" ); + if(ctype == boolean_) { + return ("SDAI_BOOLEAN"); } /* case TYPE_INTEGER: */ - if( ctype == integer_ ) { - return ( "SDAI_Integer" ); + if(ctype == integer_) { + return ("SDAI_Integer"); } /* case TYPE_REAL: * case TYPE_NUMBER: */ - if( ( ctype == number_ ) || ( ctype == real_ ) ) { - return ( "SDAI_Real" ); + if((ctype == number_) || (ctype == real_)) { + return ("SDAI_Real"); } /* case TYPE_STRING: */ - if( ctype == string_ ) { - return ( "SDAI_String" ); + if(ctype == string_) { + return ("SDAI_String"); } /* case TYPE_BINARY: */ - if( ctype == binary_ ) { - return ( "SDAI_Binary" ); + if(ctype == binary_) { + return ("SDAI_Binary"); } /* case TYPE_ENTITY: */ - if( ctype == entity_ ) { - strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); - if( strlen( retval ) + strlen( ptr ) < buf_siz ) { - strcat( retval, ptr ); + if(ctype == entity_) { + strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); + if(strlen(retval) + strlen(ptr) < buf_siz) { + strcat(retval, ptr); } else { - fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); + fprintf(stderr, overflowMsg, __FILE__, __LINE__); abort(); } return retval; @@ -133,105 +136,113 @@ const char * TYPE_get_ctype( const Type t, char * retval, size_t buf_siz ) { } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if( ctype == enumeration_ ) { - strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); - if( strlen( retval ) + strlen( var ) < buf_siz ) { - strcat( retval, var ); + if(ctype == enumeration_) { + strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); + if(strlen(retval) + strlen(var) < buf_siz) { + strcat(retval, var); } else { - fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); + fprintf(stderr, overflowMsg, __FILE__, __LINE__); abort(); } return retval; } - if( ctype == select_ ) { - return ( TypeName( t ) ); + if(ctype == select_) { + return (TypeName(t)); } /* default returns undefined */ - return ( "SCLundefined" ); + return ("SCLundefined"); } -const char * TYPEget_ctype( const Type t ) { +const char *TYPEget_ctype(const Type t) +{ static char retval [BUFSIZ] = {0}; - return TYPE_get_ctype( t, retval, BUFSIZ ); + return TYPE_get_ctype(t, retval, BUFSIZ); } -const char * TypeName( Type t ) { +const char *TypeName(Type t) +{ static char name [BUFSIZ]; - strcpy( name, TYPE_PREFIX ); - if( TYPEget_name( t ) ) { - strncat( name, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - strlen( TYPE_PREFIX ) - 1 ); + strcpy(name, TYPE_PREFIX); + if(TYPEget_name(t)) { + strncat(name, FirstToUpper(TYPEget_name(t)), BUFSIZ - strlen(TYPE_PREFIX) - 1); } else { - return TYPEget_ctype( t ); + return TYPEget_ctype(t); } return name; } -char ToLower( char c ) { - if( isupper( c ) ) { - return ( tolower( c ) ); +char ToLower(char c) +{ + if(isupper(c)) { + return (tolower(c)); } else { - return ( c ); + return (c); } } -char ToUpper( char c ) { - if( islower( c ) ) { - return ( toupper( c ) ); +char ToUpper(char c) +{ + if(islower(c)) { + return (toupper(c)); } else { - return ( c ); + return (c); } } -const char * StrToLower( const char * word ) { +const char *StrToLower(const char *word) +{ static char newword [MAX_LEN]; int i = 0; - if( !word ) { + if(!word) { return 0; } - while( word [i] != '\0' ) { - newword [i] = ToLower( word [i] ); + while(word [i] != '\0') { + newword [i] = ToLower(word [i]); ++i; } newword [i] = '\0'; - return ( newword ) ; + return (newword) ; } -const char * StrToUpper( const char * word ) { +const char *StrToUpper(const char *word) +{ static char newword [MAX_LEN]; int i = 0; - while( word [i] != '\0' ) { - newword [i] = ToUpper( word [i] ); + while(word [i] != '\0') { + newword [i] = ToUpper(word [i]); ++i; } newword [i] = '\0'; - return ( newword ); + return (newword); } -const char * StrToConstant( const char * word ) { +const char *StrToConstant(const char *word) +{ static char newword[MAX_LEN]; int i = 0; - while( word [i] != '\0' ) { - if( word [i] == '/' || word [i] == '.' ) { + while(word [i] != '\0') { + if(word [i] == '/' || word [i] == '.') { newword [i] = '_'; } else { - newword [i] = ToUpper( word [i] ); + newword [i] = ToUpper(word [i]); } ++i; } newword [i] = '\0'; - return ( newword ); + return (newword); } -const char * FirstToUpper( const char * word ) { +const char *FirstToUpper(const char *word) +{ static char newword [MAX_LEN]; - strncpy( newword, word, MAX_LEN ); - newword[0] = ToUpper( newword[0] ); - return ( newword ); + strncpy(newword, word, MAX_LEN); + newword[0] = ToUpper(newword[0]); + return (newword); } diff --git a/src/exp2cxx/class_strings.h b/src/exp2cxx/class_strings.h index 147c970fb..bae97af28 100644 --- a/src/exp2cxx/class_strings.h +++ b/src/exp2cxx/class_strings.h @@ -20,18 +20,18 @@ /** \returns: temporary copy of name suitable for use as a class name * Side Effects: erases the name created by a previous call to this function */ -const char * ClassName( const char * oldname ); +const char *ClassName(const char *oldname); /** \returns the name of the c++ class representing the entity */ -const char * ENTITYget_classname( Entity ent ); +const char *ENTITYget_classname(Entity ent); /** supplies the type of a data member for the c++ class * \returns: a string which is the type of the data member in the c++ class */ -const char * TYPEget_ctype( const Type t ); +const char *TYPEget_ctype(const Type t); /** name of type as defined in SDAI C++ binding 4-Nov-1993 */ -const char * TypeName( Type t ); +const char *TypeName(Type t); /** These functions take a character or a string and return ** a temporary copy of the string with the function applied to it. @@ -42,11 +42,11 @@ const char * TypeName( Type t ); ** \returns a temporary copy of characters ** @{ */ -char ToLower( char c ); -char ToUpper( char c ); -const char * StrToLower( const char * word ); -const char * StrToUpper( const char * word ); -const char * StrToConstant( const char * word ); -const char * FirstToUpper( const char * word ); +char ToLower(char c); +char ToUpper(char c); +const char *StrToLower(const char *word); +const char *StrToUpper(const char *word); +const char *StrToConstant(const char *word); +const char *FirstToUpper(const char *word); /* @} */ #endif /* CLASS_STRINGS_H */ diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 0f1494ded..42f7eefa0 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -46,15 +46,16 @@ int old_accessors = 0; * Mostly replaced by format_for_std_stringout, below. This function is * still used in one place in ENTITYincode_print(). */ -char * format_for_stringout( char * orig_buf, char * return_buf ) { - char * optr = orig_buf; - char * rptr = return_buf; - while( *optr ) { - if( *optr == '\n' ) { +char *format_for_stringout(char *orig_buf, char *return_buf) +{ + char *optr = orig_buf; + char *rptr = return_buf; + while(*optr) { + if(*optr == '\n') { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if( *optr == '\\' ) { + } else if(*optr == '\\') { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -75,175 +76,183 @@ char * format_for_stringout( char * orig_buf, char * return_buf ) { * * This version takes a file pointer and eliminates use of the temp buffer. */ -void format_for_std_stringout( FILE * f, char * orig_buf ) { - const char * optr = orig_buf; - char * s_end = "\\n\" );\n"; - char * s_begin = " str.append( \""; - fprintf( f, "%s", s_begin ); - while( *optr ) { - if( *optr == '\n' ) { - if( * ( optr + 1 ) == '\n' ) { /* skip blank lines */ +void format_for_std_stringout(FILE *f, char *orig_buf) +{ + const char *optr = orig_buf; + char *s_end = "\\n\" );\n"; + char *s_begin = " str.append( \""; + fprintf(f, "%s", s_begin); + while(*optr) { + if(*optr == '\n') { + if(* (optr + 1) == '\n') { /* skip blank lines */ optr++; continue; } - fprintf( f, "%s", s_end ); - fprintf( f, "%s", s_begin ); - } else if( *optr == '\\' ) { - fprintf( f, "\\\\" ); + fprintf(f, "%s", s_end); + fprintf(f, "%s", s_begin); + } else if(*optr == '\\') { + fprintf(f, "\\\\"); } else { - fprintf( f, "%c", *optr ); + fprintf(f, "%c", *optr); } optr++; } - fprintf( f, "%s", s_end ); - sc_free( orig_buf ); + fprintf(f, "%s", s_end); + sc_free(orig_buf); } -void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ) { +void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file) +{ Dictionary dict; DictionaryEntry de; - struct Rename * r; + struct Rename *r; Linked_List list; char td_name[BUFSIZ]; char sch_name[BUFSIZ]; - strncpy( sch_name, PrettyTmpName( SCHEMAget_name( schema ) ), BUFSIZ ); + strncpy(sch_name, PrettyTmpName(SCHEMAget_name(schema)), BUFSIZ); - LISTdo( reflist, s, Schema ) { - fprintf( file, " // %s FROM %s; (all objects)\n", type, s->symbol.name ); - fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( s->symbol.name ) ); - fprintf( file, " is->all_objects_(1);\n" ); - if( !strcmp( type, "USE" ) ) { - fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); + LISTdo(reflist, s, Schema) { + fprintf(file, " // %s FROM %s; (all objects)\n", type, s->symbol.name); + fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(s->symbol.name)); + fprintf(file, " is->all_objects_(1);\n"); + if(!strcmp(type, "USE")) { + fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); } else { - fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); + fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); } - } LISTod + } + LISTod - if( !refdict ) { + if(!refdict) { return; } - dict = DICTcreate( 10 ); + dict = DICTcreate(10); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init( refdict, &de ); - while( 0 != ( r = ( struct Rename * )DICTdo( &de ) ) ) { + DICTdo_init(refdict, &de); + while(0 != (r = (struct Rename *)DICTdo(&de))) { Linked_List wlist; - wlist = ( Linked_List )DICTlookup( dict, r->schema->symbol.name ); - if( !wlist ) { + wlist = (Linked_List)DICTlookup(dict, r->schema->symbol.name); + if(!wlist) { wlist = LISTcreate(); - DICTdefine( dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN ); + DICTdefine(dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN); } - LISTadd_last( wlist, r ); + LISTadd_last(wlist, r); } /* step 2: for each list, print out the renames */ - DICTdo_init( dict, &de ); - while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { + DICTdo_init(dict, &de); + while(0 != (list = (Linked_List)DICTdo(&de))) { bool first_time = true; - LISTdo( list, re, struct Rename * ) { + LISTdo(list, re, struct Rename *) { /* note: SCHEMAget_name(r->schema) equals r->schema->symbol.name) */ - if( first_time ) { - fprintf( file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name ); - fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( re->schema->symbol.name ) ); - if( !strcmp( type, "USE" ) ) { - fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); + if(first_time) { + fprintf(file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name); + fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(re->schema->symbol.name)); + if(!strcmp(type, "USE")) { + fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); } else { - fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); + fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); } } - if( first_time ) { + if(first_time) { first_time = false; } - if( re->type == OBJ_TYPE ) { - sprintf( td_name, "%s", TYPEtd_name( ( Type )re->object ) ); - } else if( re->type == OBJ_FUNCTION ) { - sprintf( td_name, "/* Function not implemented */ 0" ); - } else if( re->type == OBJ_PROCEDURE ) { - sprintf( td_name, "/* Procedure not implemented */ 0" ); - } else if( re->type == OBJ_RULE ) { - sprintf( td_name, "/* Rule not implemented */ 0" ); - } else if( re->type == OBJ_ENTITY ) { - sprintf( td_name, "%s%s%s", - SCOPEget_name( ( ( Entity )re->object )->superscope ), - ENT_PREFIX, ENTITYget_name( ( Entity )re->object ) ); + if(re->type == OBJ_TYPE) { + sprintf(td_name, "%s", TYPEtd_name((Type)re->object)); + } else if(re->type == OBJ_FUNCTION) { + sprintf(td_name, "/* Function not implemented */ 0"); + } else if(re->type == OBJ_PROCEDURE) { + sprintf(td_name, "/* Procedure not implemented */ 0"); + } else if(re->type == OBJ_RULE) { + sprintf(td_name, "/* Rule not implemented */ 0"); + } else if(re->type == OBJ_ENTITY) { + sprintf(td_name, "%s%s%s", + SCOPEget_name(((Entity)re->object)->superscope), + ENT_PREFIX, ENTITYget_name((Entity)re->object)); } else { - sprintf( td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type ); + sprintf(td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type); } - if( re->old != re->nnew ) { - fprintf( file, " // object %s AS %s\n", re->old->name, - re->nnew->name ); - if( !strcmp( type, "USE" ) ) { - fprintf( file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); - fprintf( file, " is->explicit_items_()->Append(ui);\n" ); - fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); + if(re->old != re->nnew) { + fprintf(file, " // object %s AS %s\n", re->old->name, + re->nnew->name); + if(!strcmp(type, "USE")) { + fprintf(file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); + fprintf(file, " is->explicit_items_()->Append(ui);\n"); + fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); } else { - fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); - fprintf( file, " is->explicit_items_()->Append(ri);\n" ); - fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); + fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); + fprintf(file, " is->explicit_items_()->Append(ri);\n"); + fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); } } else { - fprintf( file, " // object %s\n", re->old->name ); - if( !strcmp( type, "USE" ) ) { - fprintf( file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); - fprintf( file, " is->explicit_items_()->Append(ui);\n" ); - fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); + fprintf(file, " // object %s\n", re->old->name); + if(!strcmp(type, "USE")) { + fprintf(file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); + fprintf(file, " is->explicit_items_()->Append(ui);\n"); + fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); } else { - fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); - fprintf( file, " is->explicit_items_()->Append(ri);\n" ); - fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); + fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); + fprintf(file, " is->explicit_items_()->Append(ri);\n"); + fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); } } - } LISTod + } + LISTod } - HASHdestroy( dict ); + HASHdestroy(dict); } -int Handle_FedPlus_Args( int i, char * arg ) { +int Handle_FedPlus_Args(int i, char *arg) +{ (void) arg; /* unused */ - if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { + if(((char)i == 's') || ((char)i == 'S')) { multiple_inheritance = 0; } - if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { + if(((char)i == 'a') || ((char)i == 'A')) { old_accessors = 1; } - if( ( ( char )i == 'l' ) || ( ( char )i == 'L' ) ) { + if(((char)i == 'l') || ((char)i == 'L')) { print_logging = 1; } return 0; } -void MODELPrintConstructorBody( Entity entity, FILES * files, Schema schema ) { - const char * n; - DEBUG( "Entering MODELPrintConstructorBody for %s\n", n ); +void MODELPrintConstructorBody(Entity entity, FILES *files, Schema schema) +{ + const char *n; + DEBUG("Entering MODELPrintConstructorBody for %s\n", n); - n = ENTITYget_classname( entity ); + n = ENTITYget_classname(entity); - fprintf( files->lib, " eep = new SDAI_Entity_extent;\n" ); + fprintf(files->lib, " eep = new SDAI_Entity_extent;\n"); - fprintf( files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - fprintf( files->lib, " _folders.Append(eep);\n\n" ); + fprintf(files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf(files->lib, " _folders.Append(eep);\n\n"); } -void MODELPrint( Entity entity, FILES * files, Schema schema, int index ) { +void MODELPrint(Entity entity, FILES *files, Schema schema, int index) +{ - const char * n; - DEBUG( "Entering MODELPrint for %s\n", n ); + const char *n; + DEBUG("Entering MODELPrint for %s\n", n); - n = ENTITYget_classname( entity ); - fprintf( files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name( schema ), n ); - fprintf( files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index ); - DEBUG( "DONE MODELPrint\n" ) ; + n = ENTITYget_classname(entity); + fprintf(files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name(schema), n); + fprintf(files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index); + DEBUG("DONE MODELPrint\n") ; } -void MODELprint_new( Entity entity, FILES * files ) { - const char * n; +void MODELprint_new(Entity entity, FILES *files) +{ + const char *n; - n = ENTITYget_classname( entity ); - fprintf( files->inc, "\n %s__set_var %s_get_extents();\n", n, n ); + n = ENTITYget_classname(entity); + fprintf(files->inc, "\n %s__set_var %s_get_extents();\n", n, n); } diff --git a/src/exp2cxx/classes.h b/src/exp2cxx/classes.h index 462e22687..eac80fbf5 100644 --- a/src/exp2cxx/classes.h +++ b/src/exp2cxx/classes.h @@ -48,29 +48,29 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define move(b) (b = (b + strlen(b))) #define TYPEtd_name(t) TypeDescriptorName (t) -Variable VARis_type_shifter( Variable a ); -int isAggregateType( const Type t ); -int isAggregate( Variable a ); +Variable VARis_type_shifter(Variable a); +int isAggregateType(const Type t); +int isAggregate(Variable a); typedef struct file_holder { - FILE * inc; /**< include file */ - FILE * lib; /**< library file */ - FILE * incall; /**< include file for collecting all include files */ - FILE * initall; /**< for registering all entities from all schemas */ - FILE * init; /**< contains function to initialize program to use schema's entities */ - FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE *inc; /**< include file */ + FILE *lib; /**< library file */ + FILE *incall; /**< include file for collecting all include files */ + FILE *initall; /**< for registering all entities from all schemas */ + FILE *init; /**< contains function to initialize program to use schema's entities */ + FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ struct { struct { - FILE * impl; - FILE * hdr; + FILE *impl; + FILE *hdr; } entity, type; } unity; } File_holder, FILES; @@ -78,7 +78,7 @@ typedef struct file_holder { /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ * EntityTag; +typedef struct EntityTag_ *EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ @@ -86,36 +86,36 @@ struct EntityTag_ { }; /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ * SelectTag; +typedef struct SelectTag_ *SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char * GetTypeDescriptorName( Type t ); -char * format_for_stringout( char * orig_buf, char * return_buf ); -void format_for_std_stringout( FILE* f, char* orig_buf ); -const char * CheckWord( const char * ); -const char * StrToLower( const char * ); -const char * StrToUpper( const char * ); -const char * FirstToUpper( const char * ); -const char * SelectName( const char * ); -FILE * FILEcreate( const char * ); -void FILEclose( FILE * ); -const char * ClassName( const char * ); -void FUNCPrint( Function, FILES *, Schema ); -void RULEPrint( Rule, FILES *, Schema ); -const char * StrToConstant( const char * ); -void MODELPrint( Entity, FILES *, Schema, int ); -void MODELprint_new( Entity entity, FILES* files ); -void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); -const char * PrettyTmpName( const char * oldname ); -const char * EnumName( const char * oldname ); -void print_file( Express ); -void resolution_success( void ); -void SCHEMAprint( Schema schema, FILES* files, void* complexCol, int suffix ); -const char * FundamentalType( const Type t, int report_reftypes ); -void numberAttributes( Scope scope ); +const char *GetTypeDescriptorName(Type t); +char *format_for_stringout(char *orig_buf, char *return_buf); +void format_for_std_stringout(FILE *f, char *orig_buf); +const char *CheckWord(const char *); +const char *StrToLower(const char *); +const char *StrToUpper(const char *); +const char *FirstToUpper(const char *); +const char *SelectName(const char *); +FILE *FILEcreate(const char *); +void FILEclose(FILE *); +const char *ClassName(const char *); +void FUNCPrint(Function, FILES *, Schema); +void RULEPrint(Rule, FILES *, Schema); +const char *StrToConstant(const char *); +void MODELPrint(Entity, FILES *, Schema, int); +void MODELprint_new(Entity entity, FILES *files); +void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); +const char *PrettyTmpName(const char *oldname); +const char *EnumName(const char *oldname); +void print_file(Express); +void resolution_success(void); +void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix); +const char *FundamentalType(const Type t, int report_reftypes); +void numberAttributes(Scope scope); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -123,14 +123,14 @@ void numberAttributes( Scope scope ); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider( Entity e, Variable a ); +Variable VARis_overrider(Entity e, Variable a); /* Added for multiple schema support: */ -void print_schemas_separate( Express, void *, FILES * ); -void getMCPrint( Express, FILE *, FILE * ); -int sameSchema( Scope, Scope ); +void print_schemas_separate(Express, void *, FILES *); +void getMCPrint(Express, FILE *, FILE *); +int sameSchema(Scope, Scope); -void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ); +void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file); #include "classes_attribute.h" #include "classes_type.h" diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index f304ba176..6233b7e3d 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -38,23 +38,24 @@ extern int print_logging; ** Side Effects: ** Status: complete 8/5/93 ******************************************************************/ -char * generate_attribute_name( Variable a, char * out ) { - char * temp, *q; - const char * p; +char *generate_attribute_name(Variable a, char *out) +{ + char *temp, *q; + const char *p; int i; - temp = EXPRto_string( VARget_name( a ) ); - p = StrToLower( temp ); - if( ! strncmp( p, "self\\", 5 ) ) { + temp = EXPRto_string(VARget_name(a)); + p = StrToLower(temp); + if(! strncmp(p, "self\\", 5)) { p += 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for( i = 0, q = out; *p != '\0' && i < BUFSIZ; p++ ) { + for(i = 0, q = out; *p != '\0' && i < BUFSIZ; p++) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert * '.' to '_', and convert to lowercase. */ - if( ( *p != '\n' ) && ( *p != ' ' ) ) { - if( *p == '.' ) { + if((*p != '\n') && (*p != ' ')) { + if(*p == '.') { *q = '_'; } else { *q = *p; @@ -64,29 +65,31 @@ char * generate_attribute_name( Variable a, char * out ) { } } *q = '\0'; - sc_free( temp ); + sc_free(temp); return out; } -char * generate_attribute_func_name( Variable a, char * out ) { - generate_attribute_name( a, out ); - strncpy( out, StrToLower( out ), BUFSIZ ); - if( old_accessors ) { - out[0] = toupper( out[0] ); +char *generate_attribute_func_name(Variable a, char *out) +{ + generate_attribute_name(a, out); + strncpy(out, StrToLower(out), BUFSIZ); + if(old_accessors) { + out[0] = toupper(out[0]); } else { - out[strlen( out )] = '_'; + out[strlen(out)] = '_'; } return out; } /* return true if attr needs const and non-const getters */ -bool attrIsObj( Type t ) { +bool attrIsObj(Type t) +{ /* if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { / * const doesn't make sense for pointer types * / return false; } else */ - Class_Of_Type class = TYPEget_type( t ); - switch( class ) { + Class_Of_Type class = TYPEget_type(t); + switch(class) { case number_: case real_: case integer_: @@ -101,17 +104,19 @@ bool attrIsObj( Type t ) { /** print attr descriptors to the namespace * \p attr_count_tmp is a _copy_ of attr_count */ -void ATTRnames_print( Entity entity, FILE* file ) { +void ATTRnames_print(Entity entity, FILE *file) +{ char attrnm [BUFSIZ]; - LISTdo( ENTITYget_attributes( entity ), v, Variable ) { - generate_attribute_name( v, attrnm ); - fprintf( file, " extern %s *%s%d%s%s;\n", - ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm ); - } LISTod + LISTdo(ENTITYget_attributes(entity), v, Variable) { + generate_attribute_name(v, attrnm); + fprintf(file, " extern %s *%s%d%s%s;\n", + (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), + attrnm); + } + LISTod } /** prints out the current attribute for an entity's c++ class definition @@ -120,32 +125,33 @@ void ATTRnames_print( Entity entity, FILE* file ) { * \param a attribute being processed * \param file file being written to */ -void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { +void DataMemberPrintAttr(Entity entity, Variable a, FILE *file) +{ char attrnm [BUFSIZ]; - const char * ctype, * etype; - if( !VARget_inverse( a ) && ( VARget_initializer( a ) == EXPRESSION_NULL ) ) { - ctype = TYPEget_ctype( VARget_type( a ) ); - generate_attribute_name( a, attrnm ); - if( !strcmp( ctype, "SCLundefined" ) ) { - fprintf( stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name( entity ), attrnm ); + const char *ctype, * etype; + if(!VARget_inverse(a) && (VARget_initializer(a) == EXPRESSION_NULL)) { + ctype = TYPEget_ctype(VARget_type(a)); + generate_attribute_name(a, attrnm); + if(!strcmp(ctype, "SCLundefined")) { + fprintf(stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name(entity), attrnm); } - if( TYPEis_entity( VARget_type( a ) ) ) { - fprintf( file, " SDAI_Application_instance_ptr _%s;", attrnm ); - } else if( TYPEis_aggregate( VARget_type( a ) ) ) { - fprintf( file, " %s_ptr _%s;", ctype, attrnm ); + if(TYPEis_entity(VARget_type(a))) { + fprintf(file, " SDAI_Application_instance_ptr _%s;", attrnm); + } else if(TYPEis_aggregate(VARget_type(a))) { + fprintf(file, " %s_ptr _%s;", ctype, attrnm); } else { - fprintf( file, " %s _%s;", ctype, attrnm ); + fprintf(file, " %s _%s;", ctype, attrnm); } - if( VARget_optional( a ) ) { - fprintf( file, " // OPTIONAL" ); + if(VARget_optional(a)) { + fprintf(file, " // OPTIONAL"); } - if( isAggregate( a ) ) { + if(isAggregate(a)) { /* if it's a named type, comment the type */ - if( ( etype = TYPEget_name ( TYPEget_nonaggregate_base_type( VARget_type( a ) ) ) ) ) { - fprintf( file, " // of %s\n", etype ); + if((etype = TYPEget_name(TYPEget_nonaggregate_base_type(VARget_type(a))))) { + fprintf(file, " // of %s\n", etype); } } - fprintf( file, "\n" ); + fprintf(file, "\n"); } } @@ -162,31 +168,32 @@ void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { ** Side Effects: ** Status: complete 17-Feb-1992 ******************************************************************/ -void ATTRsign_access_methods( Variable a, FILE * file ) { +void ATTRsign_access_methods(Variable a, FILE *file) +{ - Type t = VARget_type( a ); + Type t = VARget_type(a); char ctype [BUFSIZ]; char attrnm [BUFSIZ]; - generate_attribute_func_name( a, attrnm ); + generate_attribute_func_name(a, attrnm); - strncpy( ctype, AccessType( t ), BUFSIZ ); - ctype[BUFSIZ-1] = '\0'; + strncpy(ctype, AccessType(t), BUFSIZ); + ctype[BUFSIZ - 1] = '\0'; - if( attrIsObj( t ) ) { + if(attrIsObj(t)) { /* object or pointer, so provide const and non-const methods */ - if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { /* it's a typedef, so prefacing with 'const' won't do what we desire */ - fprintf( file, " %s_c %s() const;\n", ctype, attrnm ); + fprintf(file, " %s_c %s() const;\n", ctype, attrnm); } else { - fprintf( file, " const %s %s() const;\n", ctype, attrnm ); + fprintf(file, " const %s %s() const;\n", ctype, attrnm); } - fprintf( file, " %s %s();\n", ctype, attrnm ); + fprintf(file, " %s %s();\n", ctype, attrnm); } else { - fprintf( file, " %s %s() const;\n", ctype, attrnm ); + fprintf(file, " %s %s() const;\n", ctype, attrnm); } - fprintf( file, " void %s( const %s x );\n", attrnm, ctype ); - fprintf( file, "\n" ); + fprintf(file, " void %s( const %s x );\n", attrnm, ctype); + fprintf(file, "\n"); return; } @@ -206,17 +213,18 @@ void ATTRsign_access_methods( Variable a, FILE * file ) { ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ) { - Type t = VARget_type( a ); +void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst) +{ + Type t = VARget_type(a); char ctype [BUFSIZ]; /* return type of the get function */ char funcnm [BUFSIZ]; /* name of member function */ - generate_attribute_func_name( a, funcnm ); - strncpy( ctype, AccessType( t ), BUFSIZ ); - ctype[BUFSIZ-1] = '\0'; - if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { - fprintf( file, "\n%s%s %s::%s() ", ctype, ( returnsConst ? "_c" : "" ), classnm, funcnm ); + generate_attribute_func_name(a, funcnm); + strncpy(ctype, AccessType(t), BUFSIZ); + ctype[BUFSIZ - 1] = '\0'; + if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { + fprintf(file, "\n%s%s %s::%s() ", ctype, (returnsConst ? "_c" : ""), classnm, funcnm); } else { - fprintf( file, "\n%s%s %s::%s() ", ( returnsConst ? "const " : "" ), ctype, classnm, funcnm ); + fprintf(file, "\n%s%s %s::%s() ", (returnsConst ? "const " : ""), ctype, classnm, funcnm); } return; } @@ -237,33 +245,35 @@ void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ) { +void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file) +{ - Type t = VARget_type( a ); + Type t = VARget_type(a); char ctype [BUFSIZ]; char funcnm [BUFSIZ]; - generate_attribute_func_name( a, funcnm ); + generate_attribute_func_name(a, funcnm); - strncpy( ctype, AccessType( t ), BUFSIZ ); - ctype[BUFSIZ-1] = '\0'; - fprintf( file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype ); + strncpy(ctype, AccessType(t), BUFSIZ); + ctype[BUFSIZ - 1] = '\0'; + fprintf(file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype); return; } /** print access methods for aggregate attribute */ -void AGGRprint_access_methods( const char * entnm, Variable a, FILE * file, - char * ctype, char * attrnm ) { - ATTRprint_access_methods_get_head( entnm, a, file, false ); - fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); - fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); - fprintf( file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ( ( a->type->u.type->body->base ) ? "->" : "." ) ); +void AGGRprint_access_methods(const char *entnm, Variable a, FILE *file, + char *ctype, char *attrnm) +{ + ATTRprint_access_methods_get_head(entnm, a, file, false); + fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); + fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); + fprintf(file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ((a->type->u.type->body->base) ? "->" : ".")); return; } @@ -271,212 +281,221 @@ void AGGRprint_access_methods( const char * entnm, Variable a, FILE * file, * \p var is the variable name, minus preceding underscore, or null if 'x' is to be used * \p dir is either "returned" or "assigned" */ -void ATTRprint_access_methods_entity_logging( const char * entnm, const char * funcnm, const char * nm, - const char * var, const char * dir, FILE * file ) { - if( print_logging ) { - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if( *logStream ) {\n" ); - fprintf( file, " logStream -> open( SCLLOGFILE, ios::app );\n" ); - fprintf( file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); - fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); - fprintf( file, " *logStream << \"reference to Sdai%s entity #\"", nm ); - fprintf( file, " << %s%s->STEPfile_id << std::endl;\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); - fprintf( file, " } else {\n" ); - fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); - fprintf( file, " *logStream << \"null entity\" << std::endl;\n }\n" ); - fprintf( file, " logStream->close();\n" ); - fprintf( file, " }\n" ); - fprintf( file, "#endif\n" ); +void ATTRprint_access_methods_entity_logging(const char *entnm, const char *funcnm, const char *nm, + const char *var, const char *dir, FILE *file) +{ + if(print_logging) { + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if( *logStream ) {\n"); + fprintf(file, " logStream -> open( SCLLOGFILE, ios::app );\n"); + fprintf(file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", (var ? "_" : ""), (var ? var : "x")); + fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); + fprintf(file, " *logStream << \"reference to Sdai%s entity #\"", nm); + fprintf(file, " << %s%s->STEPfile_id << std::endl;\n", (var ? "_" : ""), (var ? var : "x")); + fprintf(file, " } else {\n"); + fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); + fprintf(file, " *logStream << \"null entity\" << std::endl;\n }\n"); + fprintf(file, " logStream->close();\n"); + fprintf(file, " }\n"); + fprintf(file, "#endif\n"); } } /** print access methods for attrs that are entities * prints const and non-const getters and a setter */ -void ATTRprint_access_methods_entity( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, - const char * ctype, Variable a, FILE * file ) { - fprintf( file, "{\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); - fprintf( file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); - fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); - - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); - fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); - - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); - fprintf( file, " _%s = x;\n}\n", attrnm ); +void ATTRprint_access_methods_entity(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, + const char *ctype, Variable a, FILE *file) +{ + fprintf(file, "{\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); + fprintf(file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); + + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); + + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); + fprintf(file, " _%s = x;\n}\n", attrnm); return; } /** logging code for string and binary attribute access methods */ -void ATTRprint_access_methods_str_bin_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { - if( print_logging ) { - const char * direction = ( setter ? "assigned" : "returned" ); - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - if( setter ) { - fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); +void ATTRprint_access_methods_str_bin_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) +{ + if(print_logging) { + const char *direction = (setter ? "assigned" : "returned"); + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + if(setter) { + fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); } else { - fprintf( file, " if(x)\n {\n" ); + fprintf(file, " if(x)\n {\n"); } - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - if( setter ) { - fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + if(setter) { + fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); } else { - fprintf( file, " *logStream << x << std::endl;\n" ); + fprintf(file, " *logStream << x << std::endl;\n"); } - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); - fprintf( file, "#endif\n" ); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); + fprintf(file, "#endif\n"); } } /** print access methods for string or bin attribute */ -void ATTRprint_access_methods_str_bin( const char * entnm, const char * attrnm, const char * funcnm, - const char * ctype, Variable a, FILE * file ) { - fprintf( file, "{\n" ); - ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); - fprintf( file, " return _%s;\n}\n", attrnm ); - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); - fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, false ); - fprintf( file, " _%s = x;\n}\n", attrnm ); +void ATTRprint_access_methods_str_bin(const char *entnm, const char *attrnm, const char *funcnm, + const char *ctype, Variable a, FILE *file) +{ + fprintf(file, "{\n"); + ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); + fprintf(file, " return _%s;\n}\n", attrnm); + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); + fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, false); + fprintf(file, " _%s = x;\n}\n", attrnm); return; } /** print logging code for access methods for enumeration attribute */ -void ATTRprint_access_methods_enum_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { - if( print_logging ) { - const char * direction = ( setter ? "assigned" : "returned" ); - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - if( !setter ) { - fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); +void ATTRprint_access_methods_enum_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) +{ + if(print_logging) { + const char *direction = (setter ? "assigned" : "returned"); + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + if(!setter) { + fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); } - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - if( setter ) { - fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + if(setter) { + fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); } else { - fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); + fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); } - fprintf( file, " }\n#endif\n" ); + fprintf(file, " }\n#endif\n"); } } /** print access methods for enumeration attribute */ -void ATTRprint_access_methods_enum( const char * entnm, const char * attrnm, const char * funcnm, - Variable a, Type t, FILE * file ) { - fprintf( file, "{\n" ); - ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); - fprintf( file, " return (%s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); - - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); - fprintf( file, " return (const %s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); - - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, true ); - fprintf( file, " _%s.put( x );\n}\n", attrnm ); +void ATTRprint_access_methods_enum(const char *entnm, const char *attrnm, const char *funcnm, + Variable a, Type t, FILE *file) +{ + fprintf(file, "{\n"); + ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); + fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); + + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); + fprintf(file, " return (const %s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); + + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, true); + fprintf(file, " _%s.put( x );\n}\n", attrnm); return; } /** print logging code for access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { - if( print_logging ) { - const char * direction = ( setter ? "assigned" : "returned" ); - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - if( !setter ) { +void ATTRprint_access_methods_log_bool_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) +{ + if(print_logging) { + const char *direction = (setter ? "assigned" : "returned"); + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + if(!setter) { /* fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" ); */ - fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); + fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); } - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - if( setter ) { - fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + if(setter) { + fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); } else { - fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); + fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); /* fprintf( file, " logStream->close();\n" ); */ } - fprintf( file, " }\n" ); - fprintf( file, "#endif\n" ); + fprintf(file, " }\n"); + fprintf(file, "#endif\n"); } } /** print access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool( const char * entnm, const char * attrnm, const char * funcnm, - const char * ctype, Variable a, FILE * file ) { - fprintf( file, "const {\n" ); - ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); - fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); - -/* don't need a const method for logical or boolean - * ATTRprint_access_methods_get_head( entnm, a, file, true ); - * fprintf( file, "const {\n" ); - * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); - * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); -*/ - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, true ); - fprintf( file, " _%s.put (x);\n}\n", attrnm ); +void ATTRprint_access_methods_log_bool(const char *entnm, const char *attrnm, const char *funcnm, + const char *ctype, Variable a, FILE *file) +{ + fprintf(file, "const {\n"); + ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, false); + fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + + /* don't need a const method for logical or boolean + * ATTRprint_access_methods_get_head( entnm, a, file, true ); + * fprintf( file, "const {\n" ); + * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); + * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + */ + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, true); + fprintf(file, " _%s.put (x);\n}\n", attrnm); return; } /** print access methods for inverse attrs, using iAMap */ -void INVprint_access_methods( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, - const char * ctype, Variable a, FILE * file, Schema schema ) { +void INVprint_access_methods(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, + const char *ctype, Variable a, FILE *file, Schema schema) +{ char iaName[BUFSIZ] = {0}; - snprintf( iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, - /* can it ever be anything but "I"? */ - ( VARis_derived( a ) ? "D" : ( VARis_type_shifter( a ) ? "R" : ( VARget_inverse( a ) ? "I" : "" ) ) ), attrnm ); + snprintf(iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name(schema), ATTR_PREFIX, a->idx, + /* can it ever be anything but "I"? */ + (VARis_derived(a) ? "D" : (VARis_type_shifter(a) ? "R" : (VARget_inverse(a) ? "I" : ""))), attrnm); - if( isAggregate( a ) ) { + if(isAggregate(a)) { /* following started as AGGRprint_access_methods() */ - ATTRprint_access_methods_get_head( entnm, a, file, false ); - fprintf( file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName ); - fprintf( file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName ); - fprintf( file, " return ias.a;\n}\n" ); - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - fprintf( file, " return getInvAttr( %s ).a;\n}\n", iaName ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName ); + ATTRprint_access_methods_get_head(entnm, a, file, false); + fprintf(file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName); + fprintf(file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName); + fprintf(file, " return ias.a;\n}\n"); + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + fprintf(file, " return getInvAttr( %s ).a;\n}\n", iaName); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName); } else { - ATTRprint_access_methods_get_head( entnm, a, file, false ); + ATTRprint_access_methods_get_head(entnm, a, file, false); /* following started as ATTRprint_access_methods_entity() */ - fprintf( file, "{\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); - fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); - fprintf( file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); - fprintf( file, " return (%s) ias.i;\n}\n", ctype ); - - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); - fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); - fprintf( file, " return (%s) ias.i;\n}\n", ctype ); - - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); - fprintf( file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName ); + fprintf(file, "{\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); + fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); + fprintf(file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); + fprintf(file, " return (%s) ias.i;\n}\n", ctype); + + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); + fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); + fprintf(file, " return (%s) ias.i;\n}\n", ctype); + + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); + fprintf(file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName); } } @@ -487,8 +506,9 @@ void INVprint_access_methods( const char * entnm, const char * attrnm, const cha * \param a attribute to print methods for * \param file file being written to */ -void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ) { - Type t = VARget_type( a ); +void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema) +{ + Type t = VARget_type(a); Class_Of_Type classType; char ctype [BUFSIZ]; /* type of data member */ char attrnm [BUFSIZ]; @@ -497,46 +517,46 @@ void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Sche char nm [BUFSIZ]; /* I believe nm has the name of the underlying type without Sdai in front of it */ - if( TYPEget_name( t ) ) { - strncpy( nm, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - 1 ); + if(TYPEget_name(t)) { + strncpy(nm, FirstToUpper(TYPEget_name(t)), BUFSIZ - 1); } - generate_attribute_func_name( a, funcnm ); - generate_attribute_name( a, attrnm ); - strcpy( membernm, attrnm ); - membernm[0] = toupper( membernm[0] ); - classType = TYPEget_type( t ); - strncpy( ctype, AccessType( t ), BUFSIZ ); - if( VARget_inverse( a ) ) { - INVprint_access_methods( entnm, attrnm, funcnm, nm, ctype, a, file, schema ); + generate_attribute_func_name(a, funcnm); + generate_attribute_name(a, attrnm); + strcpy(membernm, attrnm); + membernm[0] = toupper(membernm[0]); + classType = TYPEget_type(t); + strncpy(ctype, AccessType(t), BUFSIZ); + if(VARget_inverse(a)) { + INVprint_access_methods(entnm, attrnm, funcnm, nm, ctype, a, file, schema); return; } - if( isAggregate( a ) ) { - AGGRprint_access_methods( entnm, a, file, ctype, attrnm ); + if(isAggregate(a)) { + AGGRprint_access_methods(entnm, a, file, ctype, attrnm); return; } - ATTRprint_access_methods_get_head( entnm, a, file, false ); + ATTRprint_access_methods_get_head(entnm, a, file, false); /* case TYPE_ENTITY: */ - if( classType == entity_ ) { - ATTRprint_access_methods_entity( entnm, attrnm, funcnm, nm, ctype, a, file ); + if(classType == entity_) { + ATTRprint_access_methods_entity(entnm, attrnm, funcnm, nm, ctype, a, file); return; } /* case TYPE_LOGICAL: */ - if( ( classType == boolean_ ) || ( classType == logical_ ) ) { - ATTRprint_access_methods_log_bool( entnm, attrnm, funcnm, ctype, a, file ); + if((classType == boolean_) || (classType == logical_)) { + ATTRprint_access_methods_log_bool(entnm, attrnm, funcnm, ctype, a, file); } /* case TYPE_ENUM: */ - if( classType == enumeration_ ) { - ATTRprint_access_methods_enum( entnm, attrnm, funcnm, a, t, file ); + if(classType == enumeration_) { + ATTRprint_access_methods_enum(entnm, attrnm, funcnm, a, t, file); } /* case TYPE_SELECT: */ - if( classType == select_ ) { - fprintf( file, " {\n return &_%s;\n}\n", attrnm ); - ATTRprint_access_methods_get_head( entnm, a, file, true ); - fprintf( file, "const {\n return (const %s) &_%s;\n}\n", ctype, attrnm ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, " {\n _%s = x;\n}\n", attrnm ); + if(classType == select_) { + fprintf(file, " {\n return &_%s;\n}\n", attrnm); + ATTRprint_access_methods_get_head(entnm, a, file, true); + fprintf(file, "const {\n return (const %s) &_%s;\n}\n", ctype, attrnm); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, " {\n _%s = x;\n}\n", attrnm); return; } /* case TYPE_AGGRETATES: */ @@ -545,77 +565,77 @@ void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Sche /* case STRING:*/ /* case TYPE_BINARY: */ - if( ( classType == string_ ) || ( classType == binary_ ) ) { - ATTRprint_access_methods_str_bin( entnm, attrnm, funcnm, ctype, a, file ); + if((classType == string_) || (classType == binary_)) { + ATTRprint_access_methods_str_bin(entnm, attrnm, funcnm, ctype, a, file); } /* case TYPE_INTEGER: */ - if( classType == integer_ ) { - fprintf( file, "const {\n" ); - if( print_logging ) { - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - fprintf( file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm ); - fprintf( file, - " *logStream << _%s << std::endl;\n", attrnm ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm ); - fprintf( file, - " *logStream << \"unset\" << std::endl;\n }\n }\n" ); - fprintf( file, "#endif\n" ); + if(classType == integer_) { + fprintf(file, "const {\n"); + if(print_logging) { + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + fprintf(file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm); + fprintf(file, + " *logStream << _%s << std::endl;\n", attrnm); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm); + fprintf(file, + " *logStream << \"unset\" << std::endl;\n }\n }\n"); + fprintf(file, "#endif\n"); } /* default: INTEGER */ /* is the same type as the data member */ - fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - if( print_logging ) { - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - fprintf( file, " if(!(x == S_INT_NULL) )\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << x << std::endl;\n" ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); - fprintf( file, "#endif\n" ); + fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + if(print_logging) { + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + fprintf(file, " if(!(x == S_INT_NULL) )\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << x << std::endl;\n"); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); + fprintf(file, "#endif\n"); /* default: INTEGER */ /* is the same type as the data member */ } - fprintf( file, " _%s = x;\n}\n", attrnm ); + fprintf(file, " _%s = x;\n}\n", attrnm); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if( ( classType == number_ ) || ( classType == real_ ) ) { - fprintf( file, "const {\n" ); - if( print_logging ) { - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); - fprintf( file, "#endif\n" ); + if((classType == number_) || (classType == real_)) { + fprintf(file, "const {\n"); + if(print_logging) { + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); + fprintf(file, "#endif\n"); } - fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); - ATTRprint_access_methods_put_head( entnm, a, file ); - fprintf( file, "{\n" ); - if( print_logging ) { - fprintf( file, "#ifdef SC_LOGGING\n" ); - fprintf( file, " if(*logStream)\n {\n" ); - fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); - fprintf( file, " }\n else\n {\n" ); - fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); - fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); - fprintf( file, "#endif\n" ); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); + ATTRprint_access_methods_put_head(entnm, a, file); + fprintf(file, "{\n"); + if(print_logging) { + fprintf(file, "#ifdef SC_LOGGING\n"); + fprintf(file, " if(*logStream)\n {\n"); + fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); + fprintf(file, " }\n else\n {\n"); + fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); + fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); + fprintf(file, "#endif\n"); } - fprintf( file, " _%s = x;\n}\n", attrnm ); + fprintf(file, " _%s = x;\n}\n", attrnm); } } diff --git a/src/exp2cxx/classes_attribute.h b/src/exp2cxx/classes_attribute.h index 5a32b3074..f06273a77 100644 --- a/src/exp2cxx/classes_attribute.h +++ b/src/exp2cxx/classes_attribute.h @@ -1,17 +1,17 @@ #ifndef CLASSES_ATTRIBUTE_H #define CLASSES_ATTRIBUTE_H -char * generate_attribute_name( Variable a, char * out ); -char * generate_attribute_func_name( Variable a, char * out ); +char *generate_attribute_name(Variable a, char *out); +char *generate_attribute_func_name(Variable a, char *out); -void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ); -void ATTRnames_print( Entity entity, FILE * file ); -void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ); -void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); -void ATTRsign_access_methods( Variable a, FILE* file ); -void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ); +void DataMemberPrintAttr(Entity entity, Variable a, FILE *file); +void ATTRnames_print(Entity entity, FILE *file); +void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst); +void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); +void ATTRsign_access_methods(Variable a, FILE *file); +void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema); /** return true if attr needs const and non-const getters */ -bool attrIsObj( Type t ); +bool attrIsObj(Type t); #endif diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 10a6af92c..13bbc5ecd 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -45,8 +45,9 @@ extern int old_accessors; * Nov 2011 - MAP - This function was split out of ENTITYhead_print to enable * use of a separate header with a namespace. */ -void ENTITYnames_print( Entity entity, FILE * file ) { - fprintf( file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name( entity ) ); +void ENTITYnames_print(Entity entity, FILE *file) +{ + fprintf(file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name(entity)); } /** declares the global pointer to the EntityDescriptor representing a particular entity @@ -58,18 +59,20 @@ void ENTITYnames_print( Entity entity, FILE * file ) { * \param file file being written to * \param schema schema being processed */ -void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { +void LIBdescribe_entity(Entity entity, FILE *file, Schema schema) +{ char attrnm [BUFSIZ]; - fprintf( file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - LISTdo( ENTITYget_attributes( entity ), v, Variable ) { - generate_attribute_name( v, attrnm ); - fprintf( file, "%s * %s::%s%d%s%s = 0;\n", - ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm ); - } LISTod - fprintf( file, "\n"); + fprintf(file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + LISTdo(ENTITYget_attributes(entity), v, Variable) { + generate_attribute_name(v, attrnm); + fprintf(file, "%s * %s::%s%d%s%s = 0;\n", + (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), attrnm); + } + LISTod + fprintf(file, "\n"); } /** prints the member functions for the class representing an entity. These go in the .cc file @@ -78,67 +81,73 @@ void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { * \param file file being written to * \param schema needed for name of namespace */ -void LIBmemberFunctionPrint( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { +void LIBmemberFunctionPrint(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) +{ Linked_List attr_list; char entnm [BUFSIZ]; - strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ + strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ /* 1. put in member functions which belong to all entities */ /* the common function are still in the class definition 17-Feb-1992 */ /* 2. print access functions for attributes */ - attr_list = ENTITYget_attributes( entity ); - LISTdo( attr_list, a, Variable ) { + attr_list = ENTITYget_attributes(entity); + LISTdo(attr_list, a, Variable) { /* do for EXPLICIT, REDEFINED, and INVERSE attributes - but not DERIVED */ - if( ! VARis_derived( a ) ) { + if(! VARis_derived(a)) { /* retrieval and assignment */ - ATTRprint_access_methods( entnm, a, file, schema ); + ATTRprint_access_methods(entnm, a, file, schema); } - } LISTod + } + LISTod /* //////////////// */ - if( multiple_inheritance ) { - LISTdo( neededAttr, attr, Variable ) { - if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { - ATTRprint_access_methods( entnm, attr, file, schema ); + if(multiple_inheritance) { + LISTdo(neededAttr, attr, Variable) { + if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { + ATTRprint_access_methods(entnm, attr, file, schema); } - } LISTod + } + LISTod } /* //////////////// */ - - fprintf( file, "\n" ); + + fprintf(file, "\n"); } -int get_attribute_number( Entity entity ) { +int get_attribute_number(Entity entity) +{ int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes( entity ); - local = ENTITYget_attributes( entity ); + complete = ENTITYget_all_attributes(entity); + local = ENTITYget_attributes(entity); - LISTdo( local, a, Variable ) { + LISTdo(local, a, Variable) { /* go to the child's first explicit attribute */ - if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { - LISTdo_n( complete, p, Variable, b ) { + if((! VARget_inverse(a)) && (! VARis_derived(a))) { + LISTdo_n(complete, p, Variable, b) { /* cycle through all the explicit attributes until the child's attribute is found */ - if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { - if( p != a ) { + if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { + if(p != a) { ++i; } else { found = 1; } } - } LISTod - if( found ) { + } + LISTod + if(found) { return i; } else { - fprintf( stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name( VARget_name( a ) ) ); + fprintf(stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name(VARget_name(a))); } } - } LISTod + } + LISTod return -1; } @@ -148,66 +157,71 @@ int get_attribute_number( Entity entity ) { * \p entity entity to print * \p file file being written to */ -void ENTITYhead_print( Entity entity, FILE * file ) { +void ENTITYhead_print(Entity entity, FILE *file) +{ char entnm [BUFSIZ]; Linked_List list; Entity super = 0; - strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); - entnm[BUFSIZ-1] = '\0'; + strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); + entnm[BUFSIZ - 1] = '\0'; /* inherit from either supertype entity class or root class of all - i.e. SDAI_Application_instance */ - if( multiple_inheritance ) { - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { - super = ( Entity )LISTpeek_first( list ); + if(multiple_inheritance) { + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { + super = (Entity)LISTpeek_first(list); } } else { /* the old way */ - super = ENTITYput_superclass( entity ); + super = ENTITYput_superclass(entity); } - fprintf( file, "class SC_SCHEMA_EXPORT %s : ", entnm ); - if( super ) { - fprintf( file, "public %s {\n ", ENTITYget_classname( super ) ); + fprintf(file, "class SC_SCHEMA_EXPORT %s : ", entnm); + if(super) { + fprintf(file, "public %s {\n ", ENTITYget_classname(super)); } else { - fprintf( file, "public SDAI_Application_instance {\n" ); + fprintf(file, "public SDAI_Application_instance {\n"); } } /** print an attr initializer * skip inverse attrs */ -void DataMemberInit( bool * first, Variable a, FILE * lib ) { +void DataMemberInit(bool *first, Variable a, FILE *lib) +{ char attrnm [BUFSIZ]; - if( VARis_derived( a ) || VARget_inverse( a ) ) { + if(VARis_derived(a) || VARget_inverse(a)) { return; } - if( TYPEis_entity( VARget_type( a ) ) || TYPEis_aggregate( VARget_type( a ) ) ) { - if( *first ) { + if(TYPEis_entity(VARget_type(a)) || TYPEis_aggregate(VARget_type(a))) { + if(*first) { *first = false; - fprintf( lib, " :" ); + fprintf(lib, " :"); } else { - fprintf( lib, "," ); + fprintf(lib, ","); } - generate_attribute_name( a, attrnm ); - fprintf( lib, " _%s( 0 )", attrnm ); + generate_attribute_name(a, attrnm); + fprintf(lib, " _%s( 0 )", attrnm); } } /** print attribute initializers; call before printing constructor body * \param first true if this is the first initializer */ -void DataMemberInitializers( Entity entity, bool * first, Linked_List neededAttr, FILE * lib ) { - Linked_List attr_list = ENTITYget_attributes( entity ); - LISTdo( attr_list, attr, Variable ) { - DataMemberInit( first, attr, lib ); - } LISTod; - if( multiple_inheritance ) { - LISTdo( neededAttr, attr, Variable ) { - DataMemberInit( first, attr, lib ); - } LISTod +void DataMemberInitializers(Entity entity, bool *first, Linked_List neededAttr, FILE *lib) +{ + Linked_List attr_list = ENTITYget_attributes(entity); + LISTdo(attr_list, attr, Variable) { + DataMemberInit(first, attr, lib); + } + LISTod; + if(multiple_inheritance) { + LISTdo(neededAttr, attr, Variable) { + DataMemberInit(first, attr, lib); + } + LISTod } } @@ -215,22 +229,23 @@ void DataMemberInitializers( Entity entity, bool * first, Linked_List neededAttr * \param entity entity being processed * \param file file being written to */ -void DataMemberPrint( Entity entity, Linked_List neededAttr, FILE * file ) { +void DataMemberPrint(Entity entity, Linked_List neededAttr, FILE *file) +{ Linked_List attr_list; /* print list of attributes in the protected access area */ - fprintf( file, " protected:\n" ); + fprintf(file, " protected:\n"); - attr_list = ENTITYget_attributes( entity ); - LISTdo( attr_list, attr, Variable ) { - DataMemberPrintAttr( entity, attr, file ); + attr_list = ENTITYget_attributes(entity); + LISTdo(attr_list, attr, Variable) { + DataMemberPrintAttr(entity, attr, file); } LISTod; /* add attributes for parent attributes not inherited through C++ inheritance. */ - if( multiple_inheritance ) { - LISTdo( neededAttr, attr, Variable ) { - DataMemberPrintAttr( entity, attr, file ); + if(multiple_inheritance) { + LISTdo(neededAttr, attr, Variable) { + DataMemberPrintAttr(entity, attr, file); } LISTod; } @@ -240,52 +255,55 @@ void DataMemberPrint( Entity entity, Linked_List neededAttr, FILE * file ) { * \param entity entity being processed * \param file file being written to */ -void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) { +void MemberFunctionSign(Entity entity, Linked_List neededAttr, FILE *file) +{ Linked_List attr_list; static int entcode = 0; char entnm [BUFSIZ]; - strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ - entnm[BUFSIZ-1] = '\0'; + strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ + entnm[BUFSIZ - 1] = '\0'; - fprintf( file, " public: \n" ); + fprintf(file, " public: \n"); /* put in member functions which belong to all entities */ /* constructors: */ - fprintf( file, " %s();\n", entnm ); - fprintf( file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm ); + fprintf(file, " %s();\n", entnm); + fprintf(file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm); /* copy constructor */ - fprintf( file, " %s( %s & e );\n", entnm, entnm ); + fprintf(file, " %s( %s & e );\n", entnm, entnm); /* destructor: */ - fprintf( file, " ~%s();\n", entnm ); + fprintf(file, " ~%s();\n", entnm); - fprintf( file, " int opcode() {\n return %d;\n }\n", entcode++ ); + fprintf(file, " int opcode() {\n return %d;\n }\n", entcode++); /* print signature of access functions for attributes */ - attr_list = ENTITYget_attributes( entity ); - LISTdo( attr_list, a, Variable ) { - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + attr_list = ENTITYget_attributes(entity); + LISTdo(attr_list, a, Variable) { + if(VARget_initializer(a) == EXPRESSION_NULL) { /* retrieval and assignment */ - ATTRsign_access_methods( a, file ); + ATTRsign_access_methods(a, file); } - } LISTod + } + LISTod /* //////////////// */ - if( multiple_inheritance ) { + if(multiple_inheritance) { /* add the EXPRESS inherited attributes which are non */ /* inherited in C++ */ - LISTdo( neededAttr, attr, Variable ) { - if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { - ATTRsign_access_methods( attr, file ); + LISTdo(neededAttr, attr, Variable) { + if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { + ATTRsign_access_methods(attr, file); } - } LISTod + } + LISTod } /* //////////////// */ - fprintf( file, "};\n\n" ); + fprintf(file, "};\n\n"); /* print creation function for class */ - fprintf( file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm ); + fprintf(file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm); } /** drives the generation of the c++ class definition code @@ -295,19 +313,21 @@ void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) { * \param entity entity being processed * \param file file being written to */ -void ENTITYinc_print( Entity entity, Linked_List neededAttr, FILE * file ) { - ENTITYhead_print( entity, file ); - DataMemberPrint( entity, neededAttr, file ); - MemberFunctionSign( entity, neededAttr, file ); +void ENTITYinc_print(Entity entity, Linked_List neededAttr, FILE *file) +{ + ENTITYhead_print(entity, file); + DataMemberPrint(entity, neededAttr, file); + MemberFunctionSign(entity, neededAttr, file); } /** initialize attributes in the constructor; used for two different constructors */ -void initializeAttrs( Entity e, FILE* file ) { - const orderedAttr * oa; - orderedAttrsInit( e ); - while( 0 != ( oa = nextAttr() ) ) { - if( oa->deriver ) { - fprintf( file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name ); +void initializeAttrs(Entity e, FILE *file) +{ + const orderedAttr *oa; + orderedAttrsInit(e); + while(0 != (oa = nextAttr())) { + if(oa->deriver) { + fprintf(file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name); } } orderedAttrsCleanup(); @@ -325,7 +345,8 @@ void initializeAttrs( Entity e, FILE* file ) { * \param entity entity being processed * \param file file being written to */ -void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { +void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) +{ Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -333,152 +354,154 @@ void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Sche Linked_List list; Entity principalSuper = 0; - const char * entnm = ENTITYget_classname( entity ); + const char *entnm = ENTITYget_classname(entity); bool first = true; /* constructor definition */ /* parent class initializer (if any) and '{' printed below */ - fprintf( file, "%s::%s()", entnm, entnm ); + fprintf(file, "%s::%s()", entnm, entnm); /* ////MULTIPLE INHERITANCE//////// */ - if( multiple_inheritance ) { + if(multiple_inheritance) { int super_cnt = 0; - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { - LISTdo( list, e, Entity ) { + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { + LISTdo(list, e, Entity) { /* if there's no super class yet, or the super class doesn't have any attributes */ super_cnt++; - if( super_cnt == 1 ) { + if(super_cnt == 1) { bool firstInitializer = false; /* ignore the 1st parent */ - const char * parent = ENTITYget_classname( e ); + const char *parent = ENTITYget_classname(e); /* parent class initializer */ - fprintf( file, ": %s()", parent ); - DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); - fprintf( file, " {\n" ); - fprintf( file, " /* parent: %s */\n%s\n%s\n", parent, + fprintf(file, ": %s()", parent); + DataMemberInitializers(entity, &firstInitializer, neededAttr, file); + fprintf(file, " {\n"); + fprintf(file, " /* parent: %s */\n%s\n%s\n", parent, " /* Ignore the first parent since it is */", - " /* part of the main inheritance hierarchy */" ); + " /* part of the main inheritance hierarchy */"); principalSuper = e; /* principal SUPERTYPE */ } else { - fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); - fprintf( file, " HeadEntity(this);\n" ); - fprintf( file, " AppendMultInstance(new %s(this));\n", - ENTITYget_classname( e ) ); - - if( super_cnt == 2 ) { - printf( "\nMULTIPLE INHERITANCE for entity: %s\n", - ENTITYget_name( entity ) ); - printf( " SUPERTYPE 1: %s (principal supertype)\n", - ENTITYget_name( principalSuper ) ); + fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); + fprintf(file, " HeadEntity(this);\n"); + fprintf(file, " AppendMultInstance(new %s(this));\n", + ENTITYget_classname(e)); + + if(super_cnt == 2) { + printf("\nMULTIPLE INHERITANCE for entity: %s\n", + ENTITYget_name(entity)); + printf(" SUPERTYPE 1: %s (principal supertype)\n", + ENTITYget_name(principalSuper)); } - printf( " SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name( e ) ); + printf(" SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name(e)); } - } LISTod; + } + LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ /* no parent class constructor has been printed, so still need an opening brace */ bool firstInitializer = true; - DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); - fprintf( file, " {\n" ); - fprintf( file, " /* no SuperTypes */\n" ); + DataMemberInitializers(entity, &firstInitializer, neededAttr, file); + fprintf(file, " {\n"); + fprintf(file, " /* no SuperTypes */\n"); } } /* what if entity comes from other schema? * It appears that entity.superscope.symbol.name is the schema name (but only if entity.superscope.type == 's'?) --MAP 27Nov11 */ - fprintf( file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf(file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - attr_list = ENTITYget_attributes( entity ); + attr_list = ENTITYget_attributes(entity); - LISTdo( attr_list, a, Variable ) { - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + LISTdo(attr_list, a, Variable) { + if(VARget_initializer(a) == EXPRESSION_NULL) { /* include attribute if it is not derived */ - generate_attribute_name( a, attrnm ); - t = VARget_type( a ); + generate_attribute_name(a, attrnm); + t = VARget_type(a); - if( !VARget_inverse( a ) && !VARis_derived( a ) ) { + if(!VARget_inverse(a) && !VARis_derived(a)) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if( TYPEis_aggregate( t ) ) { - fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); + if(TYPEis_aggregate(t)) { + fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); } - fprintf( file, " %sa = new STEPattribute( * %s::", - ( first ? "STEPattribute * " : "" ), /* first time through, declare 'a' */ - SCHEMAget_name( schema ) ); - fprintf( file, "%s%d%s%s", ATTR_PREFIX, a->idx, ( VARis_type_shifter( a ) ? "R" : "" ), attrnm ); - fprintf( file, ", %s%s_%s );\n", - ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * ) " : "" ), - ( TYPEis_aggregate( t ) ? "" : "& " ), attrnm ); - if( first ) { + fprintf(file, " %sa = new STEPattribute( * %s::", + (first ? "STEPattribute * " : ""), /* first time through, declare 'a' */ + SCHEMAget_name(schema)); + fprintf(file, "%s%d%s%s", ATTR_PREFIX, a->idx, (VARis_type_shifter(a) ? "R" : ""), attrnm); + fprintf(file, ", %s%s_%s );\n", + (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * ) " : ""), + (TYPEis_aggregate(t) ? "" : "& "), attrnm); + if(first) { first = false; } /* 2. initialize everything to NULL (even if not optional) */ - fprintf( file, " a->set_null();\n" ); + fprintf(file, " a->set_null();\n"); /* 3. put attribute on attributes list */ - fprintf( file, " attributes.push( a );\n" ); + fprintf(file, " attributes.push( a );\n"); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if( VARis_type_shifter( a ) ) { - fprintf( file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name( a ) ); + if(VARis_type_shifter(a)) { + fprintf(file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name(a)); } } } - } LISTod; + } + LISTod; - initializeAttrs( entity, file ); + initializeAttrs(entity, file); - fprintf( file, "}\n\n" ); + fprintf(file, "}\n\n"); /* copy constructor */ - entnm = ENTITYget_classname( entity ); - fprintf( file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm ); + entnm = ENTITYget_classname(entity); + fprintf(file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm); /* include explicit initialization of base class */ - if( principalSuper ) { - fprintf( file, "%s()", ENTITYget_classname( principalSuper ) ); + if(principalSuper) { + fprintf(file, "%s()", ENTITYget_classname(principalSuper)); } else { - fprintf( file, "SDAI_Application_instance()" ); + fprintf(file, "SDAI_Application_instance()"); } - fprintf( file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n" ); + fprintf(file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n"); /* print destructor */ /* currently empty, but should check to see if any attributes need to be deleted -- attributes will need reference count */ - entnm = ENTITYget_classname( entity ); - fprintf( file, "%s::~%s() {\n", entnm, entnm ); + entnm = ENTITYget_classname(entity); + fprintf(file, "%s::~%s() {\n", entnm, entnm); - attr_list = ENTITYget_attributes( entity ); + attr_list = ENTITYget_attributes(entity); - LISTdo( attr_list, a, Variable ) - if( VARget_initializer( a ) == EXPRESSION_NULL ) { - generate_attribute_name( a, attrnm ); - t = VARget_type( a ); + LISTdo(attr_list, a, Variable) + if(VARget_initializer(a) == EXPRESSION_NULL) { + generate_attribute_name(a, attrnm); + t = VARget_type(a); - if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { - if( TYPEis_aggregate( t ) ) { - fprintf( file, " delete _%s;\n", attrnm ); + if((! VARget_inverse(a)) && (! VARis_derived(a))) { + if(TYPEis_aggregate(t)) { + fprintf(file, " delete _%s;\n", attrnm); } } } LISTod; - fprintf( file, "}\n\n" ); + fprintf(file, "}\n\n"); } /********************/ @@ -486,7 +509,8 @@ void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Sche when building multiply inherited entities. \sa LIBstructor_print() */ -void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { +void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) +{ Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -496,19 +520,19 @@ void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * fil /* added for calling parents constructor if there is one */ char parentnm [BUFSIZ]; - char * parent = 0; + char *parent = 0; - const char * entnm; + const char *entnm; bool first = true; - if( multiple_inheritance ) { + if(multiple_inheritance) { bool firstInitializer = true; Entity parentEntity = 0; - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { - parentEntity = ( Entity )LISTpeek_first( list ); - if( parentEntity ) { - strcpy( parentnm, ENTITYget_classname( parentEntity ) ); + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { + parentEntity = (Entity)LISTpeek_first(list); + if(parentEntity) { + strcpy(parentnm, ENTITYget_classname(parentEntity)); parent = parentnm; } else { parent = 0; /* no parent */ @@ -520,109 +544,111 @@ void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * fil /* ENTITYget_classname returns a static buffer so don't call it twice before it gets used - (I didn't write it) - I had to move it below the above use. DAS */ - entnm = ENTITYget_classname( entity ); + entnm = ENTITYget_classname(entity); /* constructor definition */ - if( parent ) { + if(parent) { firstInitializer = false; - fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm ); + fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm); } else { - fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm ); + fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm); } - DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); - fprintf( file, " {\n" ); + DataMemberInitializers(entity, &firstInitializer, neededAttr, file); + fprintf(file, " {\n"); - fprintf( file, " /* Set this to point to the head entity. */\n" ); - fprintf( file, " HeadEntity(se);\n" ); - if( !parent ) { - fprintf( file, " ( void ) addAttrs; /* quell potentially unused var */\n\n" ); + fprintf(file, " /* Set this to point to the head entity. */\n"); + fprintf(file, " HeadEntity(se);\n"); + if(!parent) { + fprintf(file, " ( void ) addAttrs; /* quell potentially unused var */\n\n"); } - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { - LISTdo( list, e, Entity ) + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { + LISTdo(list, e, Entity) /* if there's no super class yet, or the super class doesn't have any attributes */ - fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); + fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); super_cnt++; - if( super_cnt == 1 ) { + if(super_cnt == 1) { /* ignore the 1st parent */ - fprintf( file, - " /* Ignore the first parent since it is part *\n%s\n", - " ** of the main inheritance hierarchy */" ); + fprintf(file, + " /* Ignore the first parent since it is part *\n%s\n", + " ** of the main inheritance hierarchy */"); } else { - fprintf( file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", - ENTITYget_classname( e ) ); + fprintf(file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", + ENTITYget_classname(e)); } LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ - fprintf( file, " /* no SuperTypes */\n" ); + fprintf(file, " /* no SuperTypes */\n"); } /* what if entity comes from other schema? */ - fprintf( file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf(file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - attr_list = ENTITYget_attributes( entity ); + attr_list = ENTITYget_attributes(entity); - LISTdo( attr_list, a, Variable ) { - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + LISTdo(attr_list, a, Variable) { + if(VARget_initializer(a) == EXPRESSION_NULL) { /* include attribute if it is not derived */ - generate_attribute_name( a, attrnm ); - t = VARget_type( a ); - if( !VARget_inverse( a ) && !VARis_derived( a ) ) { + generate_attribute_name(a, attrnm); + t = VARget_type(a); + if(!VARget_inverse(a) && !VARis_derived(a)) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if( TYPEis_aggregate( t ) ) { - fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); + if(TYPEis_aggregate(t)) { + fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); } - fprintf( file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", - ( first ? "STEPattribute * " : "" ), /* first time through, declare a */ - SCHEMAget_name( schema ), + fprintf(file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", + (first ? "STEPattribute * " : ""), /* first time through, declare a */ + SCHEMAget_name(schema), ATTR_PREFIX, a->idx, - ( VARis_type_shifter( a ) ? "R" : "" ), + (VARis_type_shifter(a) ? "R" : ""), attrnm, - ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * )" : "" ), - ( TYPEis_aggregate( t ) ? "" : "&" ), - attrnm ); + (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * )" : ""), + (TYPEis_aggregate(t) ? "" : "&"), + attrnm); - if( first ) { + if(first) { first = false; } - fprintf( file, " /* initialize to NULL (even if not optional) */\n" ); - fprintf( file, " a ->set_null();\n" ); + fprintf(file, " /* initialize to NULL (even if not optional) */\n"); + fprintf(file, " a ->set_null();\n"); - fprintf( file, " /* Put attribute on this class' attributes list so the access functions still work. */\n" ); - fprintf( file, " attributes.push( a );\n" ); + fprintf(file, " /* Put attribute on this class' attributes list so the access functions still work. */\n"); + fprintf(file, " attributes.push( a );\n"); - fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n" ); - fprintf( file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); - fprintf( file, " if( addAttrs ) {\n" ); - fprintf( file, " se->attributes.push( a );\n }\n" ); + fprintf(file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n"); + fprintf(file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n"); + fprintf(file, " if( addAttrs ) {\n"); + fprintf(file, " se->attributes.push( a );\n }\n"); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if( VARis_type_shifter( a ) ) { - fprintf( file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name( a ) ); + if(VARis_type_shifter(a)) { + fprintf(file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name(a)); } } } - } LISTod + } + LISTod - initializeAttrs( entity, file ); + initializeAttrs(entity, file); - fprintf( file, "}\n\n" ); + fprintf(file, "}\n\n"); } /* end if(multiple_inheritance) */ } /** return 1 if types are predefined by us */ -bool TYPEis_builtin( const Type t ) { - switch( TYPEget_body( t )->type ) { /* dunno if correct*/ +bool TYPEis_builtin(const Type t) +{ + switch(TYPEget_body(t)->type) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -654,29 +680,30 @@ bool TYPEis_builtin( const Type t ) { * \param a, an Express attribute * \param out, the C++ name */ -char * generate_dict_attr_name( Variable a, char * out ) { - char * temp, *p, *q; +char *generate_dict_attr_name(Variable a, char *out) +{ + char *temp, *p, *q; int j; - temp = EXPRto_string( VARget_name( a ) ); + temp = EXPRto_string(VARget_name(a)); p = temp; - if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { + if(! strncmp(StrToLower(p), "self\\", 5)) { p = p + 5; } /* copy p to out */ - strncpy( out, StrToLower( p ), BUFSIZ ); + strncpy(out, StrToLower(p), BUFSIZ); /* DAR - fixed so that '\n's removed */ - for( j = 0, q = out; *p != '\0' && j < BUFSIZ; p++ ) { + for(j = 0, q = out; *p != '\0' && j < BUFSIZ; p++) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if( *p != '\n' ) { - *q = tolower( *p ); + if(*p != '\n') { + *q = tolower(*p); j++; q++; } } *q = '\0'; - sc_free( temp ); + sc_free(temp); return out; } @@ -687,237 +714,238 @@ char * generate_dict_attr_name( Variable a, char * out ) { * \param impl implementation file being written to * \param schema schema the entity is in */ -void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schema ) { +void ENTITYincode_print(Entity entity, FILE *header, FILE *impl, Schema schema) +{ #define entity_name ENTITYget_name(entity) #define schema_name SCHEMAget_name(schema) char attrnm [BUFSIZ]; char dict_attrnm [BUFSIZ]; - const char * super_schema; - char * tmp, *tmp2; + const char *super_schema; + char *tmp, *tmp2; bool hasInverse = false; #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the entity into the schema descriptor */ - fprintf( impl, - " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", - schema_name, schema_name, ENT_PREFIX, entity_name ); + fprintf(impl, + " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", + schema_name, schema_name, ENT_PREFIX, entity_name); #endif - if( ENTITYget_abstract( entity ) ) { - if( entity->u.entity->subtype_expression ) { + if(ENTITYget_abstract(entity)) { + if(entity->u.entity->subtype_expression) { - fprintf( impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n" ); + fprintf(impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n"); - format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); - fprintf( impl, " str.append( \")\" );\n" ); - fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); + format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); + fprintf(impl, " str.append( \")\" );\n"); + fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); } else { - fprintf( impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", - schema_name, ENT_PREFIX, entity_name ); + fprintf(impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", + schema_name, ENT_PREFIX, entity_name); } } else { - if( entity->u.entity->subtype_expression ) { - fprintf( impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n" ); - format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); - fprintf( impl, " str.append( \")\" );\n" ); - fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); + if(entity->u.entity->subtype_expression) { + fprintf(impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n"); + format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); + fprintf(impl, " str.append( \")\" );\n"); + fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); } } - LISTdo( ENTITYget_supertypes( entity ), sup, Entity ) + LISTdo(ENTITYget_supertypes(entity), sup, Entity) /* set the owning schema of the supertype */ - super_schema = SCHEMAget_name( ENTITYget_schema( sup ) ); + super_schema = SCHEMAget_name(ENTITYget_schema(sup)); /* print the supertype list for this entity */ - fprintf( impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", - schema_name, ENT_PREFIX, entity_name, - super_schema, - ENT_PREFIX, ENTITYget_name( sup ) ); + fprintf(impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", + schema_name, ENT_PREFIX, entity_name, + super_schema, + ENT_PREFIX, ENTITYget_name(sup)); /* add this entity to the subtype list of it's supertype */ - fprintf( impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", - super_schema, - ENT_PREFIX, ENTITYget_name( sup ), - schema_name, ENT_PREFIX, entity_name ); + fprintf(impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", + super_schema, + ENT_PREFIX, ENTITYget_name(sup), + schema_name, ENT_PREFIX, entity_name); LISTod - LISTdo( ENTITYget_attributes( entity ), v, Variable ) - if( VARget_inverse( v ) ) { + LISTdo(ENTITYget_attributes(entity), v, Variable) + if(VARget_inverse(v)) { hasInverse = true; } - generate_attribute_name( v, attrnm ); + generate_attribute_name(v, attrnm); /* do EXPLICIT and DERIVED attributes first */ /* if ( ! VARget_inverse (v)) {*/ /* first make sure that type descriptor exists */ - if( TYPEget_name( v->type ) ) { - if( ( !TYPEget_head( v->type ) ) && - ( TYPEget_body( v->type )->type == entity_ ) ) { - fprintf( impl, " %s::%s%d%s%s =", SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm ); - fprintf( impl, "\n new %s( \"%s\",", - ( VARget_inverse( v ) ? "Inverse_attribute" : - ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - /* attribute name param */ - generate_dict_attr_name( v, dict_attrnm ) ); - - /* following assumes we are not in a nested */ - /* entity otherwise we should search upward */ - /* for schema */ - /* attribute's type */ - fprintf( impl, " %s::%s%s, %s,\n", TYPEget_name( TYPEget_body( v->type )->entity->superscope ), - ENT_PREFIX, TYPEget_name( v->type ), ( VARget_optional( v ) ? "LTrue" : "LFalse" ) ); - fprintf( impl, " %s%s, *%s::%s%s);\n", ( VARget_unique( v ) ? "LTrue" : "LFalse" ), - /* Support REDEFINED */ - ( VARget_inverse( v ) ? "" : ( VARis_derived( v ) ? ", AttrType_Deriving" : - ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), - schema_name, ENT_PREFIX, TYPEget_name( entity ) ); + if(TYPEget_name(v->type)) { + if((!TYPEget_head(v->type)) && + (TYPEget_body(v->type)->type == entity_)) { + fprintf(impl, " %s::%s%d%s%s =", SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), + attrnm); + fprintf(impl, "\n new %s( \"%s\",", + (VARget_inverse(v) ? "Inverse_attribute" : + (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + /* attribute name param */ + generate_dict_attr_name(v, dict_attrnm)); + + /* following assumes we are not in a nested */ + /* entity otherwise we should search upward */ + /* for schema */ + /* attribute's type */ + fprintf(impl, " %s::%s%s, %s,\n", TYPEget_name(TYPEget_body(v->type)->entity->superscope), + ENT_PREFIX, TYPEget_name(v->type), (VARget_optional(v) ? "LTrue" : "LFalse")); + fprintf(impl, " %s%s, *%s::%s%s);\n", (VARget_unique(v) ? "LTrue" : "LFalse"), + /* Support REDEFINED */ + (VARget_inverse(v) ? "" : (VARis_derived(v) ? ", AttrType_Deriving" : + (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), + schema_name, ENT_PREFIX, TYPEget_name(entity)); } else { /* type reference */ - fprintf( impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm, + fprintf(impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm, - ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name( v, dict_attrnm ), + /* attribute name param */ + generate_dict_attr_name(v, dict_attrnm), - SCHEMAget_name( v->type->superscope ), - TD_PREFIX, TYPEget_name( v->type ), + SCHEMAget_name(v->type->superscope), + TD_PREFIX, TYPEget_name(v->type), - ( VARget_optional( v ) ? "LTrue" : "LFalse" ), + (VARget_optional(v) ? "LTrue" : "LFalse"), - ( VARget_unique( v ) ? "LTrue" : "LFalse" ), + (VARget_unique(v) ? "LTrue" : "LFalse"), - ( VARget_inverse( v ) ? "" : - ( VARis_derived( v ) ? ", AttrType_Deriving" : - ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), + (VARget_inverse(v) ? "" : + (VARis_derived(v) ? ", AttrType_Deriving" : + (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name( entity ) + schema_name, ENT_PREFIX, TYPEget_name(entity) ); } - } else if( TYPEis_builtin( v->type ) ) { + } else if(TYPEis_builtin(v->type)) { /* the type wasn't named -- it must be built in or aggregate */ - fprintf( impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm, - ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - /* attribute name param */ - generate_dict_attr_name( v, dict_attrnm ), - /* not sure about 0 here */ TD_PREFIX, FundamentalType( v->type, 0 ), - ( VARget_optional( v ) ? "LTrue" : - "LFalse" ), - ( VARget_unique( v ) ? "LTrue" : - "LFalse" ), - ( VARget_inverse( v ) ? "" : - ( VARis_derived( v ) ? ", AttrType_Deriving" : - ( VARis_type_shifter( v ) ? - ", AttrType_Redefining" : - ", AttrType_Explicit" ) ) ), - schema_name, ENT_PREFIX, TYPEget_name( entity ) + fprintf(impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm, + (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + /* attribute name param */ + generate_dict_attr_name(v, dict_attrnm), + /* not sure about 0 here */ TD_PREFIX, FundamentalType(v->type, 0), + (VARget_optional(v) ? "LTrue" : + "LFalse"), + (VARget_unique(v) ? "LTrue" : + "LFalse"), + (VARget_inverse(v) ? "" : + (VARis_derived(v) ? ", AttrType_Deriving" : + (VARis_type_shifter(v) ? + ", AttrType_Redefining" : + ", AttrType_Explicit"))), + schema_name, ENT_PREFIX, TYPEget_name(entity) ); } else { /* manufacture new one(s) on the spot */ char typename_buf[MAX_LEN]; - print_typechain( header, impl, v->type, typename_buf, schema, v->name->symbol.name ); - fprintf( impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm, - ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - /* attribute name param */ - generate_dict_attr_name( v, dict_attrnm ), - typename_buf, - ( VARget_optional( v ) ? "LTrue" : - "LFalse" ), - ( VARget_unique( v ) ? "LTrue" : - "LFalse" ), - ( VARget_inverse( v ) ? "" : - ( VARis_derived( v ) ? ", AttrType_Deriving" : - ( VARis_type_shifter( v ) ? - ", AttrType_Redefining" : - ", AttrType_Explicit" ) ) ), - schema_name, ENT_PREFIX, TYPEget_name( entity ) + print_typechain(header, impl, v->type, typename_buf, schema, v->name->symbol.name); + fprintf(impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm, + (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + /* attribute name param */ + generate_dict_attr_name(v, dict_attrnm), + typename_buf, + (VARget_optional(v) ? "LTrue" : + "LFalse"), + (VARget_unique(v) ? "LTrue" : + "LFalse"), + (VARget_inverse(v) ? "" : + (VARis_derived(v) ? ", AttrType_Deriving" : + (VARis_type_shifter(v) ? + ", AttrType_Redefining" : + ", AttrType_Explicit"))), + schema_name, ENT_PREFIX, TYPEget_name(entity) ); } - fprintf( impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", - schema_name, ENT_PREFIX, TYPEget_name( entity ), - ( VARget_inverse( v ) ? "Inverse" : "Explicit" ), - SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm ); - - if( VARis_derived( v ) && v->initializer ) { - tmp = EXPRto_string( v->initializer ); - tmp2 = ( char * )sc_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); - fprintf( impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm, format_for_stringout( tmp, tmp2 ) ); - sc_free( tmp ); - sc_free( tmp2 ); + fprintf(impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", + schema_name, ENT_PREFIX, TYPEget_name(entity), + (VARget_inverse(v) ? "Inverse" : "Explicit"), + SCHEMAget_name(schema), ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm); + + if(VARis_derived(v) && v->initializer) { + tmp = EXPRto_string(v->initializer); + tmp2 = (char *)sc_malloc(sizeof(char) * (strlen(tmp) + BUFSIZ)); + fprintf(impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm, format_for_stringout(tmp, tmp2)); + sc_free(tmp); + sc_free(tmp2); } - if( VARget_inverse( v ) ) { - fprintf( impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), - attrnm, v->inverse_attribute->name->symbol.name ); - if( v->type->symbol.name ) { - fprintf( impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, - v->type->symbol.name ); - fprintf( impl, "// inverse entity 1 %s\n", v->type->symbol.name ); + if(VARget_inverse(v)) { + fprintf(impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), + attrnm, v->inverse_attribute->name->symbol.name); + if(v->type->symbol.name) { + fprintf(impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), attrnm, + v->type->symbol.name); + fprintf(impl, "// inverse entity 1 %s\n", v->type->symbol.name); } else { - switch( TYPEget_body( v->type )->type ) { + switch(TYPEget_body(v->type)->type) { case entity_: - fprintf( impl, - " %s%d%s%s->inverted_entity_id_(\"%s\");\n", - ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, - TYPEget_body( v->type )->entity->symbol.name ); - fprintf( impl, "// inverse entity 2 %s\n", TYPEget_body( v->type )->entity->symbol.name ); + fprintf(impl, + " %s%d%s%s->inverted_entity_id_(\"%s\");\n", + ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), attrnm, + TYPEget_body(v->type)->entity->symbol.name); + fprintf(impl, "// inverse entity 2 %s\n", TYPEget_body(v->type)->entity->symbol.name); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf( impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - ( VARis_derived( v ) ? "D" : - ( VARis_type_shifter( v ) ? "R" : - ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, - TYPEget_body( v->type )->base->symbol.name ); - fprintf( impl, "// inverse entity 3 %s\n", TYPEget_body( v->type )->base->symbol.name ); + fprintf(impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + (VARis_derived(v) ? "D" : + (VARis_type_shifter(v) ? "R" : + (VARget_inverse(v) ? "I" : ""))), attrnm, + TYPEget_body(v->type)->base->symbol.name); + fprintf(impl, "// inverse entity 3 %s\n", TYPEget_body(v->type)->base->symbol.name); break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); abort(); } } @@ -925,55 +953,57 @@ void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schem LISTod - fprintf( impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name ); - if( hasInverse ) { - fprintf( impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name ); + fprintf(impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name); + if(hasInverse) { + fprintf(impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name); } #undef schema_name } -void ENTITYPrint_h( const Entity entity, FILE * header, Linked_List neededAttr, Schema schema ) { - const char *name = ENTITYget_classname( entity ); - DEBUG( "Entering ENTITYPrint_h for %s\n", name ); +void ENTITYPrint_h(const Entity entity, FILE *header, Linked_List neededAttr, Schema schema) +{ + const char *name = ENTITYget_classname(entity); + DEBUG("Entering ENTITYPrint_h for %s\n", name); - ENTITYhead_print( entity, header ); - DataMemberPrint( entity, neededAttr, header ); - MemberFunctionSign( entity, neededAttr, header ); - - fprintf( header, "void init_%s(Registry& reg);\n\n", name ); + ENTITYhead_print(entity, header); + DataMemberPrint(entity, neededAttr, header); + MemberFunctionSign(entity, neededAttr, header); - fprintf( header, "namespace %s {\n", SCHEMAget_name( schema ) ); - ENTITYnames_print( entity, header ); - ATTRnames_print( entity, header ); - fprintf( header, "}\n\n" ); + fprintf(header, "void init_%s(Registry& reg);\n\n", name); - DEBUG( "DONE ENTITYPrint_h\n" ); + fprintf(header, "namespace %s {\n", SCHEMAget_name(schema)); + ENTITYnames_print(entity, header); + ATTRnames_print(entity, header); + fprintf(header, "}\n\n"); + + DEBUG("DONE ENTITYPrint_h\n"); } -void ENTITYPrint_cc( const Entity entity, FILE * createall, FILE * header, FILE * impl, Linked_List neededAttr, Schema schema, bool externMap ) { - const char * name = ENTITYget_classname( entity ); - - DEBUG( "Entering ENTITYPrint_cc for %s\n", name ); +void ENTITYPrint_cc(const Entity entity, FILE *createall, FILE *header, FILE *impl, Linked_List neededAttr, Schema schema, bool externMap) +{ + const char *name = ENTITYget_classname(entity); + + DEBUG("Entering ENTITYPrint_cc for %s\n", name); - fprintf( impl, "#include \"schema.h\"\n" ); - fprintf( impl, "#include \"sc_memmgr.h\"\n" ); - fprintf( impl, "#include \"entity/%s.h\"\n\n", name ); + fprintf(impl, "#include \"schema.h\"\n"); + fprintf(impl, "#include \"sc_memmgr.h\"\n"); + fprintf(impl, "#include \"entity/%s.h\"\n\n", name); - LIBdescribe_entity( entity, impl, schema ); - LIBstructor_print( entity, neededAttr, impl, schema ); - if( multiple_inheritance ) { - LIBstructor_print_w_args( entity, neededAttr, impl, schema ); + LIBdescribe_entity(entity, impl, schema); + LIBstructor_print(entity, neededAttr, impl, schema); + if(multiple_inheritance) { + LIBstructor_print_w_args(entity, neededAttr, impl, schema); } - LIBmemberFunctionPrint( entity, neededAttr, impl, schema ); - - fprintf( impl, "void init_%s( Registry& reg ) {\n", name ); - fprintf( impl, " std::string str;\n\n" ); - ENTITYprint_descriptors( entity, createall, impl, schema, externMap ); - ENTITYincode_print( entity, header, impl, schema ); - fprintf( impl, "}\n\n" ); - - DEBUG( "DONE ENTITYPrint_cc\n" ); + LIBmemberFunctionPrint(entity, neededAttr, impl, schema); + + fprintf(impl, "void init_%s( Registry& reg ) {\n", name); + fprintf(impl, " std::string str;\n\n"); + ENTITYprint_descriptors(entity, createall, impl, schema, externMap); + ENTITYincode_print(entity, header, impl, schema); + fprintf(impl, "}\n\n"); + + DEBUG("DONE ENTITYPrint_cc\n"); } /** \sa collectAttributes */ @@ -984,37 +1014,40 @@ enum CollectType { ALL, ALL_BUT_FIRST, FIRST_ONLY }; * \param curEntity current Entity being processed * \param collect selects attrs to be collected */ -static void collectAttributes( Linked_List curList, const Entity curEntity, enum CollectType collect ) { - Linked_List parent_list = ENTITYget_supertypes( curEntity ); +static void collectAttributes(Linked_List curList, const Entity curEntity, enum CollectType collect) +{ + Linked_List parent_list = ENTITYget_supertypes(curEntity); - if( ! LISTempty( parent_list ) ) { - if( collect != FIRST_ONLY ) { + if(! LISTempty(parent_list)) { + if(collect != FIRST_ONLY) { /* collect attributes from parents and their supertypes */ - LISTdo( parent_list, e, Entity ) { - if( collect == ALL_BUT_FIRST ) { + LISTdo(parent_list, e, Entity) { + if(collect == ALL_BUT_FIRST) { /* skip first and collect from the rest */ collect = ALL; } else { /* collect attributes of this parent and its supertypes */ - collectAttributes( curList, e, ALL ); + collectAttributes(curList, e, ALL); } } LISTod; } else { /* collect attributes of only first parent and its supertypes */ - collectAttributes( curList, ( Entity ) LISTpeek_first( parent_list ), ALL ); + collectAttributes(curList, (Entity) LISTpeek_first(parent_list), ALL); } } /* prepend this entity's attributes to the result list */ - LISTdo( ENTITYget_attributes( curEntity ), attr, Variable ) { - LISTadd_first( curList, attr ); - } LISTod; + LISTdo(ENTITYget_attributes(curEntity), attr, Variable) { + LISTadd_first(curList, attr); + } + LISTod; } -static bool listContainsVar( Linked_List l, Variable v ) { - const char * vName = VARget_simple_name( v ); - LISTdo( l, curr, Variable ) { - if( !strcmp( vName, VARget_simple_name( curr ) ) ) { +static bool listContainsVar(Linked_List l, Variable v) +{ + const char *vName = VARget_simple_name(v); + LISTdo(l, curr, Variable) { + if(!strcmp(vName, VARget_simple_name(curr))) { return true; } } @@ -1031,13 +1064,14 @@ static bool listContainsVar( Linked_List l, Variable v ) { * \param entity entity being processed * \param file file being written to */ -void ENTITYlib_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { - LIBdescribe_entity( entity, file, schema ); - LIBstructor_print( entity, neededAttr, file, schema ); - if( multiple_inheritance ) { - LIBstructor_print_w_args( entity, neededAttr, file, schema ); +void ENTITYlib_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) +{ + LIBdescribe_entity(entity, file, schema); + LIBstructor_print(entity, neededAttr, file, schema); + if(multiple_inheritance) { + LIBstructor_print_w_args(entity, neededAttr, file, schema); } - LIBmemberFunctionPrint( entity, neededAttr, file, schema ); + LIBmemberFunctionPrint(entity, neededAttr, file, schema); } /** drives the functions for printing out code in lib, @@ -1047,58 +1081,59 @@ void ENTITYlib_print( Entity entity, Linked_List neededAttr, FILE * file, Schema * \p schema name of the schema * \p col the ComplexCollect */ -void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) { - FILE * hdr, * impl; - char * n = ENTITYget_name( entity ); +void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap) +{ + FILE *hdr, * impl; + char *n = ENTITYget_name(entity); Linked_List remaining = LISTcreate(); - filenames_t names = getEntityFilenames( entity ); + filenames_t names = getEntityFilenames(entity); - DEBUG( "Entering ENTITYPrint for %s\n", n ); + DEBUG("Entering ENTITYPrint for %s\n", n); - if( multiple_inheritance ) { + if(multiple_inheritance) { Linked_List existing = LISTcreate(); Linked_List required = LISTcreate(); /* create list of attr inherited from the parents in C++ */ - collectAttributes( existing, entity, FIRST_ONLY ); + collectAttributes(existing, entity, FIRST_ONLY); /* create list of attr that have to be inherited in EXPRESS */ - collectAttributes( required, entity, ALL_BUT_FIRST ); + collectAttributes(required, entity, ALL_BUT_FIRST); /* build list of unique attr that are required but haven't been */ /* inherited */ - LISTdo( required, attr, Variable ) { - if( !listContainsVar( existing, attr ) && - !listContainsVar( remaining, attr ) ) { - LISTadd_first( remaining, attr ); + LISTdo(required, attr, Variable) { + if(!listContainsVar(existing, attr) && + !listContainsVar(remaining, attr)) { + LISTadd_first(remaining, attr); } } LISTod; - LIST_destroy( existing ); - LIST_destroy( required ); + LIST_destroy(existing); + LIST_destroy(required); } - if( mkDirIfNone( "entity" ) == -1 ) { - fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror( 0 ); + if(mkDirIfNone("entity") == -1) { + fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror(0); abort(); } - hdr = FILEcreate( names.header ); - impl = FILEcreate( names.impl ); - assert( hdr && impl && "error creating files" ); - fprintf( files->unity.entity.hdr, "#include \"%s\"\n", names.header ); /* TODO this is not necessary? */ - fprintf( files->unity.entity.impl, "#include \"%s\"\n", names.impl ); + hdr = FILEcreate(names.header); + impl = FILEcreate(names.impl); + assert(hdr && impl && "error creating files"); + fprintf(files->unity.entity.hdr, "#include \"%s\"\n", names.header); /* TODO this is not necessary? */ + fprintf(files->unity.entity.impl, "#include \"%s\"\n", names.impl); - ENTITYPrint_h( entity, hdr, remaining, schema ); - ENTITYPrint_cc( entity, files->create, hdr, impl, remaining, schema, externMap ); - FILEclose( hdr ); - FILEclose( impl ); + ENTITYPrint_h(entity, hdr, remaining, schema); + ENTITYPrint_cc(entity, files->create, hdr, impl, remaining, schema, externMap); + FILEclose(hdr); + FILEclose(impl); - fprintf( files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname( entity ) ); - fprintf( files->init, " init_%s( reg );\n", ENTITYget_classname( entity ) ); + fprintf(files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname(entity)); + fprintf(files->init, " init_%s( reg );\n", ENTITYget_classname(entity)); - DEBUG( "DONE ENTITYPrint\n" ); - LIST_destroy( remaining ); + DEBUG("DONE ENTITYPrint\n"); + LIST_destroy(remaining); } /** create entity descriptors @@ -1114,27 +1149,29 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) * eDesc is printed into createall because it must be initialized before other entity init fn's are called * alternative is two init fn's per ent. call init1 for each ent, then repeat with init2 */ -void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ) { - fprintf( createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - fprintf( createall, "\"%s\", %s::schema, %s, ", PrettyTmpName( ENTITYget_name( entity ) ), SCHEMAget_name( schema ), ( ENTITYget_abstract( entity ) ? "LTrue" : "LFalse" ) ); - fprintf( createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname( entity ) ); +void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap) +{ + fprintf(createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf(createall, "\"%s\", %s::schema, %s, ", PrettyTmpName(ENTITYget_name(entity)), SCHEMAget_name(schema), (ENTITYget_abstract(entity) ? "LTrue" : "LFalse")); + fprintf(createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname(entity)); /* add the entity to the Schema dictionary entry */ - fprintf( createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf(createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name(schema), SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - WHEREprint( ENTITYget_name( entity ), TYPEget_where( entity ), impl, schema, true ); - UNIQUEprint( entity, impl, schema ); + WHEREprint(ENTITYget_name(entity), TYPEget_where(entity), impl, schema, true); + UNIQUEprint(entity, impl, schema); } /** print in classes file: class forward prototype, class typedefs * split out of ENTITYprint_new, which is now ENTITYprint_descriptors */ -void ENTITYprint_classes( Entity entity, FILE * classes ) { - const char * n = ENTITYget_classname( entity ); - fprintf( classes, "\nclass %s;\n", n ); - fprintf( classes, "typedef %s * %sH;\n", n, n ); - fprintf( classes, "typedef %s * %s_ptr;\n", n, n ); - fprintf( classes, "typedef const %s * %s_ptr_c;\n", n, n ); - fprintf( classes, "typedef %s_ptr %s_var;\n", n, n ); - fprintf( classes, "#define %s__set SDAI_DAObject__set\n", n ); - fprintf( classes, "#define %s__set_var SDAI_DAObject__set_var\n", n ); +void ENTITYprint_classes(Entity entity, FILE *classes) +{ + const char *n = ENTITYget_classname(entity); + fprintf(classes, "\nclass %s;\n", n); + fprintf(classes, "typedef %s * %sH;\n", n, n); + fprintf(classes, "typedef %s * %s_ptr;\n", n, n); + fprintf(classes, "typedef const %s * %s_ptr_c;\n", n, n); + fprintf(classes, "typedef %s_ptr %s_var;\n", n, n); + fprintf(classes, "#define %s__set SDAI_DAObject__set\n", n); + fprintf(classes, "#define %s__set_var SDAI_DAObject__set_var\n", n); } diff --git a/src/exp2cxx/classes_entity.h b/src/exp2cxx/classes_entity.h index 8e1c6e0be..32f184bc3 100644 --- a/src/exp2cxx/classes_entity.h +++ b/src/exp2cxx/classes_entity.h @@ -1,12 +1,12 @@ #ifndef CLASSES_ENTITY_H #define CLASSES_ENTITY_H -const char * ENTITYget_classname( Entity ); -Entity ENTITYget_superclass( Entity entity ); -Entity ENTITYput_superclass( Entity entity ); -int ENTITYhas_explicit_attributes( Entity e ); -void ENTITYget_first_attribs( Entity entity, Linked_List result ); -void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ); -void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ); -void ENTITYprint_classes( Entity entity, FILE * classes ); +const char *ENTITYget_classname(Entity); +Entity ENTITYget_superclass(Entity entity); +Entity ENTITYput_superclass(Entity entity); +int ENTITYhas_explicit_attributes(Entity e); +void ENTITYget_first_attribs(Entity entity, Linked_List result); +void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap); +void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap); +void ENTITYprint_classes(Entity entity, FILE *classes); #endif diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 4e24a8d24..559a45552 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -31,68 +31,73 @@ extern int multiple_inheritance; * Returns: FILE* pointer to file created or NULL * Status: complete */ -FILE * FILEcreate( const char * filename ) { - FILE * file; - const char * fn; - - if( ( file = fopen( filename, "w" ) ) == NULL ) { - fprintf( stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename ); - return ( NULL ); +FILE *FILEcreate(const char *filename) +{ + FILE *file; + const char *fn; + + if((file = fopen(filename, "w")) == NULL) { + fprintf(stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename); + return (NULL); } - fn = StrToConstant ( filename ); - fprintf( file, "#ifndef %s\n", fn ); - fprintf( file, "#define %s\n\n", fn ); + fn = StrToConstant(filename); + fprintf(file, "#ifndef %s\n", fn); + fprintf(file, "#define %s\n\n", fn); - fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version ); - fprintf( file, "// You probably don't want to edit it since your modifications\n" ); - fprintf( file, "// will be lost if exp2cxx is used to regenerate it.\n\n" ); - return ( file ); + fprintf(file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version); + fprintf(file, "// You probably don't want to edit it since your modifications\n"); + fprintf(file, "// will be lost if exp2cxx is used to regenerate it.\n\n"); + return (file); } /** closes a file opened with FILEcreate */ -void FILEclose( FILE * file ) { - fprintf( file, "#endif\n" ); - fclose( file ); +void FILEclose(FILE *file) +{ + fprintf(file, "#endif\n"); + fclose(file); } /** indicates whether the attribute is an aggregate */ -int isAggregate( Variable a ) { - return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); +int isAggregate(Variable a) +{ + return(TYPEinherits_from(VARget_type(a), aggregate_)); } /** indicates whether the attribute is an aggregate */ -int isAggregateType( const Type t ) { - return( TYPEinherits_from( t, aggregate_ ) ); +int isAggregateType(const Type t) +{ + return(TYPEinherits_from(t, aggregate_)); } /** \returns a pointer to a static buffer, containing a string which is the type used by the c++ data member access functions */ -const char * AccessType( Type t ) { +const char *AccessType(Type t) +{ Class_Of_Type class; static char nm [BUFSIZ]; - strncpy( nm, TypeName( t ), BUFSIZ - 4 ); - if( TYPEis_entity( t ) ) { - strcat( nm, "_ptr" ); + strncpy(nm, TypeName(t), BUFSIZ - 4); + if(TYPEis_entity(t)) { + strcat(nm, "_ptr"); return nm; - } else if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { - strcat( nm, "_ptr" ); + } else if(TYPEis_select(t) || TYPEis_aggregate(t)) { + strcat(nm, "_ptr"); return nm; } - class = TYPEget_type( t ); - if( class == enumeration_ ) { - strncpy( nm, TypeName( t ), BUFSIZ - 2 ); - strcat( nm, "_var" ); + class = TYPEget_type(t); + if(class == enumeration_) { + strncpy(nm, TypeName(t), BUFSIZ - 2); + strcat(nm, "_var"); return nm; } - if( class == logical_ ) { - strncpy( nm, "Logical", BUFSIZ - 2 ); + if(class == logical_) { + strncpy(nm, "Logical", BUFSIZ - 2); } /* case TYPE_BOOLEAN: */ - if( class == boolean_ ) { - strncpy( nm, "Boolean", BUFSIZ - 2 ); + if(class == boolean_) { + strncpy(nm, "Boolean", BUFSIZ - 2); } return nm; } @@ -101,133 +106,139 @@ const char * AccessType( Type t ) { * * creates a new name with first character's in caps */ -const char * PrettyTmpName( const char * oldname ) { +const char *PrettyTmpName(const char *oldname) +{ int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { - newname [i] = ToLower( oldname [i] ); - if( oldname [i] == '_' ) { /* character is '_' */ + while((oldname [i] != '\0') && (i < BUFSIZ)) { + newname [i] = ToLower(oldname [i]); + if(oldname [i] == '_') { /* character is '_' */ ++i; - newname [i] = ToUpper( oldname [i] ); + newname [i] = ToUpper(oldname [i]); } - if( oldname [i] != '\0' ) { + if(oldname [i] != '\0') { ++i; } } - newname [0] = ToUpper( oldname [0] ); + newname [0] = ToUpper(oldname [0]); newname [i] = '\0'; return newname; } /* This function is out of date DAS */ -const char * EnumName( const char * oldname ) { +const char *EnumName(const char *oldname) +{ int j = 0; static char newname [MAX_LEN]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, ENUM_PREFIX ); - j = strlen( ENUM_PREFIX ); - newname [j] = ToUpper( oldname [0] ); - strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); - j = strlen( newname ); + strcpy(newname, ENUM_PREFIX); + j = strlen(ENUM_PREFIX); + newname [j] = ToUpper(oldname [0]); + strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); + j = strlen(newname); newname [j] = '\0'; - return ( newname ); + return (newname); } -const char * SelectName( const char * oldname ) { +const char *SelectName(const char *oldname) +{ int j = 0; static char newname [MAX_LEN]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, TYPE_PREFIX ); - newname [0] = ToUpper( newname [0] ); - j = strlen( TYPE_PREFIX ); - newname [j] = ToUpper( oldname [0] ); - strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); - j = strlen( newname ); + strcpy(newname, TYPE_PREFIX); + newname [0] = ToUpper(newname [0]); + j = strlen(TYPE_PREFIX); + newname [j] = ToUpper(oldname [0]); + strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); + j = strlen(newname); newname [j] = '\0'; - return ( newname ); + return (newname); } /** \return fundamental type but as the string which corresponds to the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char * FundamentalType( const Type t, int report_reftypes ) { - if( report_reftypes && TYPEget_head( t ) ) { - return( "REFERENCE_TYPE" ); +const char *FundamentalType(const Type t, int report_reftypes) +{ + if(report_reftypes && TYPEget_head(t)) { + return("REFERENCE_TYPE"); } - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case integer_: - return( "sdaiINTEGER" ); + return("sdaiINTEGER"); case real_: - return( "sdaiREAL" ); + return("sdaiREAL"); case string_: - return( "sdaiSTRING" ); + return("sdaiSTRING"); case binary_: - return( "sdaiBINARY" ); + return("sdaiBINARY"); case boolean_: - return( "sdaiBOOLEAN" ); + return("sdaiBOOLEAN"); case logical_: - return( "sdaiLOGICAL" ); + return("sdaiLOGICAL"); case number_: - return( "sdaiNUMBER" ); + return("sdaiNUMBER"); case generic_: - return( "GENERIC_TYPE" ); + return("GENERIC_TYPE"); case aggregate_: - return( "AGGREGATE_TYPE" ); + return("AGGREGATE_TYPE"); case array_: - return( "ARRAY_TYPE" ); + return("ARRAY_TYPE"); case bag_: - return( "BAG_TYPE" ); + return("BAG_TYPE"); case set_: - return( "SET_TYPE" ); + return("SET_TYPE"); case list_: - return( "LIST_TYPE" ); + return("LIST_TYPE"); case entity_: - return( "sdaiINSTANCE" ); + return("sdaiINSTANCE"); case enumeration_: - return( "sdaiENUMERATION" ); + return("sdaiENUMERATION"); case select_: - return ( "sdaiSELECT" ); + return ("sdaiSELECT"); default: - return( "UNKNOWN_TYPE" ); + return("UNKNOWN_TYPE"); } } /** this actually gets you the name of the variable that will be generated to be a * TypeDescriptor or subtype of TypeDescriptor to represent Type t in the dictionary. */ -const char * TypeDescriptorName( Type t ) { +const char *TypeDescriptorName(Type t) +{ static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if( !parent ) { - parent = TYPEget_body( t )->entity->superscope; + if(!parent) { + parent = TYPEget_body(t)->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf( b, "%s::%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), - TYPEget_name( t ) ); + sprintf(b, "%s::%s%s", SCHEMAget_name(parent), TYPEprefix(t), + TYPEget_name(t)); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char * GetTypeDescriptorName( Type t ) { - switch( TYPEget_body( t )->type ) { +const char *GetTypeDescriptorName(Type t) +{ + switch(TYPEget_body(t)->type) { case aggregate_: return "AggrTypeDescriptor"; @@ -262,18 +273,19 @@ const char * GetTypeDescriptorName( Type t ) { case generic_: return "TypeDescriptor"; default: - fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); + fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); abort(); } /* NOTREACHED */ return ""; } -int ENTITYhas_explicit_attributes( Entity e ) { - Linked_List l = ENTITYget_attributes( e ); +int ENTITYhas_explicit_attributes(Entity e) +{ + Linked_List l = ENTITYget_attributes(e); int cnt = 0; - LISTdo( l, a, Variable ) - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + LISTdo(l, a, Variable) + if(VARget_initializer(a) == EXPRESSION_NULL) { ++cnt; } LISTod; @@ -281,21 +293,22 @@ int ENTITYhas_explicit_attributes( Entity e ) { } -Entity ENTITYput_superclass( Entity entity ) { +Entity ENTITYput_superclass(Entity entity) +{ #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes( entity ); + Linked_List l = ENTITYget_supertypes(entity); EntityTag tag; - if( ! LISTempty( l ) ) { + if(! LISTempty(l)) { Entity super = 0; - if( multiple_inheritance ) { + if(multiple_inheritance) { Linked_List list = 0; - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { /* assign superclass to be the first one on the list of parents */ - super = ( Entity )LISTpeek_first( list ); + super = (Entity)LISTpeek_first(list); } } else { Entity ignore = 0; @@ -303,49 +316,51 @@ Entity ENTITYput_superclass( Entity entity ) { /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo( l, e, Entity ) + LISTdo(l, e, Entity) /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { + if((! super) || (! ENTITYhas_explicit_attributes(super))) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if( ignore ) { - fprintf( stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name( entity ), ENTITYget_name( e ) ); + if(ignore) { + fprintf(stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name(entity), ENTITYget_name(e)); } LISTod; } - tag = ( EntityTag ) sc_malloc( sizeof( struct EntityTag_ ) ); + tag = (EntityTag) sc_malloc(sizeof(struct EntityTag_)); tag -> superclass = super; - TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); + TYPEput_clientData(ENTITYget_type(entity), (ClientData) tag); return super; } return 0; } -Entity ENTITYget_superclass( Entity entity ) { +Entity ENTITYget_superclass(Entity entity) +{ EntityTag tag; - tag = ( EntityTag ) TYPEget_clientData( ENTITYget_type( entity ) ); - return ( tag ? tag -> superclass : 0 ); + tag = (EntityTag) TYPEget_clientData(ENTITYget_type(entity)); + return (tag ? tag -> superclass : 0); } -void ENTITYget_first_attribs( Entity entity, Linked_List result ) { +void ENTITYget_first_attribs(Entity entity, Linked_List result) +{ Linked_List supers; - LISTdo( ENTITYget_attributes( entity ), attr, void * ) - LISTadd_last( result, attr ); + LISTdo(ENTITYget_attributes(entity), attr, void *) + LISTadd_last(result, attr); LISTod; - supers = ENTITYget_supertypes( entity ); - if( supers ) { - ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); + supers = ENTITYget_supertypes(entity); + if(supers) { + ENTITYget_first_attribs((Entity)LISTget_first(supers), result); } } @@ -379,28 +394,30 @@ void ENTITYget_first_attribs( Entity entity, Linked_List result ) { ** if STEPattribute found with same name ** tell it to be * for reading and writing **/ -Variable VARis_type_shifter( Variable a ) { - char * temp; - if( VARis_derived( a ) || VARget_inverse( a ) ) { +Variable VARis_type_shifter(Variable a) +{ + char *temp; + if(VARis_derived(a) || VARget_inverse(a)) { return 0; } - temp = EXPRto_string( VARget_name( a ) ); - if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { + temp = EXPRto_string(VARget_name(a)); + if(! strncmp(StrToLower(temp), "self\\", 5)) { /* a is a type shifter */ - sc_free( temp ); + sc_free(temp); return a; } - sc_free( temp ); + sc_free(temp); return 0; } -Variable VARis_overrider( Entity e, Variable a ) { +Variable VARis_overrider(Entity e, Variable a) +{ Variable other; - char * tmp; - tmp = VARget_simple_name( a ); - LISTdo( ENTITYget_supertypes( e ), s, Entity ) - if( ( other = ENTITYget_named_attribute( s, tmp ) ) - && other != a ) { + char *tmp; + tmp = VARget_simple_name(a); + LISTdo(ENTITYget_supertypes(e), s, Entity) + if((other = ENTITYget_named_attribute(s, tmp)) + && other != a) { return other; } LISTod; @@ -410,15 +427,16 @@ Variable VARis_overrider( Entity e, Variable a ) { /** For a renamed type, returns the original (ancestor) type * from which t descends. Return NULL if t is top level. */ -Type TYPEget_ancestor( Type t ) { +Type TYPEget_ancestor(Type t) +{ Type i = t; - if( !TYPEget_head( i ) ) { + if(!TYPEget_head(i)) { return NULL; } - while( TYPEget_head( i ) ) { - i = TYPEget_head( i ); + while(TYPEget_head(i)) { + i = TYPEget_head(i); } return i; diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index fcf8c109d..c37221554 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -29,43 +29,44 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. static int type_count; /**< number each temporary type for same reason as \sa attr_count */ -extern char * non_unique_types_string( const Type type ); +extern char *non_unique_types_string(const Type type); -static void printEnumCreateHdr( FILE *, const Type ); -static void printEnumCreateBody( FILE *, const Type ); -static void printEnumAggrCrHdr( FILE *, const Type ); -static void printEnumAggrCrBody( FILE *, const Type ); +static void printEnumCreateHdr(FILE *, const Type); +static void printEnumCreateBody(FILE *, const Type); +static void printEnumAggrCrHdr(FILE *, const Type); +static void printEnumAggrCrBody(FILE *, const Type); -int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); +int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); -int isMultiDimAggregateType( const Type t ); +int isMultiDimAggregateType(const Type t); -void Type_Description( const Type, char * ); -void TypeBody_Description( TypeBody body, char * buf ); +void Type_Description(const Type, char *); +void TypeBody_Description(TypeBody body, char *buf); /** write representation of expression to end of buf * * TODO: add buflen arg and check for overflow */ -void strcat_expr( Expression e, char * buf ) { - if( e == LITERAL_INFINITY ) { - strcat( buf, "?" ); - } else if( e == LITERAL_PI ) { - strcat( buf, "PI" ); - } else if( e == LITERAL_E ) { - strcat( buf, "E" ); - } else if( e == LITERAL_ZERO ) { - strcat( buf, "0" ); - } else if( e == LITERAL_ONE ) { - strcat( buf, "1" ); - } else if( TYPEget_name( e ) ) { - strcat( buf, TYPEget_name( e ) ); - } else if( TYPEget_body( e->type )->type == integer_ ) { +void strcat_expr(Expression e, char *buf) +{ + if(e == LITERAL_INFINITY) { + strcat(buf, "?"); + } else if(e == LITERAL_PI) { + strcat(buf, "PI"); + } else if(e == LITERAL_E) { + strcat(buf, "E"); + } else if(e == LITERAL_ZERO) { + strcat(buf, "0"); + } else if(e == LITERAL_ONE) { + strcat(buf, "1"); + } else if(TYPEget_name(e)) { + strcat(buf, TYPEget_name(e)); + } else if(TYPEget_body(e->type)->type == integer_) { char tmpbuf[30]; - sprintf( tmpbuf, "%d", e->u.integer ); - strcat( buf, tmpbuf ); + sprintf(tmpbuf, "%d", e->u.integer); + strcat(buf, tmpbuf); } else { - strcat( buf, "??" ); + strcat(buf, "??"); } } @@ -73,16 +74,17 @@ void strcat_expr( Expression e, char * buf ) { * * TODO: add buflen arg and check for overflow */ -void strcat_bounds( TypeBody b, char * buf ) { - if( !b->upper ) { +void strcat_bounds(TypeBody b, char *buf) +{ + if(!b->upper) { return; } - strcat( buf, " [" ); - strcat_expr( b->lower, buf ); - strcat( buf, ":" ); - strcat_expr( b->upper, buf ); - strcat( buf, "]" ); + strcat(buf, " ["); + strcat_expr(b->lower, buf); + strcat(buf, ":"); + strcat_expr(b->upper, buf); + strcat(buf, "]"); } /****************************************************************** @@ -100,28 +102,30 @@ void strcat_bounds( TypeBody b, char * buf ) { ** - Changed to match CD2 Part 23, 1/14/97 DAS ** Change Date: 5/22/91 CD ******************************************************************/ -const char * EnumCElementName( Type type, Expression expr ) { +const char *EnumCElementName(Type type, Expression expr) +{ static char buf [BUFSIZ]; - sprintf( buf, "%s__", - EnumName( TYPEget_name( type ) ) ); - strcat( buf, StrToLower( EXPget_name( expr ) ) ); + sprintf(buf, "%s__", + EnumName(TYPEget_name(type))); + strcat(buf, StrToLower(EXPget_name(expr))); return buf; } -char * CheckEnumSymbol( char * s ) { +char *CheckEnumSymbol(char *s) +{ static char b [BUFSIZ]; - if( strcmp( s, "sdaiTRUE" ) - && strcmp( s, "sdaiFALSE" ) - && strcmp( s, "sdaiUNKNOWN" ) ) { + if(strcmp(s, "sdaiTRUE") + && strcmp(s, "sdaiFALSE") + && strcmp(s, "sdaiUNKNOWN")) { /* if the symbol is not a reserved one */ - return ( s ); + return (s); } else { - strcpy( b, s ); - strcat( b, "_" ); - fprintf( stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b ); - return ( b ); + strcpy(b, s); + strcat(b, "_"); + fprintf(stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b); + return (b); } } @@ -129,15 +133,16 @@ char * CheckEnumSymbol( char * s ) { * return printable version of entire type definition * return it in static buffer */ -char * TypeDescription( const Type t ) { +char *TypeDescription(const Type t) +{ static char buf[6000]; buf[0] = '\0'; - if( TYPEget_head( t ) ) { - Type_Description( TYPEget_head( t ), buf ); + if(TYPEget_head(t)) { + Type_Description(TYPEget_head(t), buf); } else { - TypeBody_Description( TYPEget_body( t ), buf ); + TypeBody_Description(TYPEget_body(t), buf); } /* should also print out where clause here */ @@ -150,217 +155,222 @@ char * TypeDescription( const Type t ) { ** Description: Writes enum type descriptors and classes. ** Change Date: ********************************************************************/ -void TYPEenum_inc_print( const Type type, FILE * inc ) { +void TYPEenum_inc_print(const Type type, FILE *inc) +{ Expression expr; char tdnm[BUFSIZ], enumAggrNm[BUFSIZ]; - const char * n; /* pointer to class name */ + const char *n; /* pointer to class name */ int cnt = 0; /* print c++ enumerated values for class */ - fprintf( inc, "enum %s {\n", EnumName( TYPEget_name( type ) ) ); + fprintf(inc, "enum %s {\n", EnumName(TYPEget_name(type))); - LISTdo_links( TYPEget_body( type )->list, link ) + LISTdo_links(TYPEget_body(type)->list, link) /* print the elements of the c++ enum type */ - expr = ( Expression )link->data; - if( cnt != 0 ) { - fprintf( inc, ",\n" ); + expr = (Expression)link->data; + if(cnt != 0) { + fprintf(inc, ",\n"); } ++cnt; - fprintf( inc, " %s", EnumCElementName( type, expr ) ); + fprintf(inc, " %s", EnumCElementName(type, expr)); LISTod - fprintf( inc, ",\n %s_unset\n};\n", EnumName( TYPEget_name( type ) ) ); + fprintf(inc, ",\n %s_unset\n};\n", EnumName(TYPEget_name(type))); /* print class for enumeration */ - n = TYPEget_ctype( type ); - fprintf( inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n ); + n = TYPEget_ctype(type); + fprintf(inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n); - fprintf( inc, " protected:\n EnumTypeDescriptor *type;\n\n" ); + fprintf(inc, " protected:\n EnumTypeDescriptor *type;\n\n"); /* constructors */ - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; - fprintf( inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm ); - fprintf( inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" - " : type(et) { set_value (e); }\n", - n, EnumName( TYPEget_name( type ) ), tdnm ); - fprintf( inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype( type )); + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; + fprintf(inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm); + fprintf(inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" + " : type(et) { set_value (e); }\n", + n, EnumName(TYPEget_name(type)), tdnm); + fprintf(inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype(type)); /* destructor */ - fprintf( inc, " ~%s () { }\n", n ); + fprintf(inc, " ~%s () { }\n", n); /* operator = */ - fprintf( inc, " %s& operator= (const %s& e)\n", - n, TYPEget_ctype( type ) ); - fprintf( inc, " { set_value (e); return *this; }\n" ); + fprintf(inc, " %s& operator= (const %s& e)\n", + n, TYPEget_ctype(type)); + fprintf(inc, " { set_value (e); return *this; }\n"); /* operator to cast to an enumerated type */ - fprintf( inc, " operator %s () const;\n", - EnumName( TYPEget_name( type ) ) ); + fprintf(inc, " operator %s () const;\n", + EnumName(TYPEget_name(type))); /* others */ - fprintf( inc, "\n inline virtual const char * Name () const\n" ); - fprintf( inc, " { return type->Name(); }\n" ); - fprintf( inc, " inline virtual int no_elements () const" - " { return %d; }\n", cnt ); - fprintf( inc, " virtual const char * element_at (int n) const;\n" ); + fprintf(inc, "\n inline virtual const char * Name () const\n"); + fprintf(inc, " { return type->Name(); }\n"); + fprintf(inc, " inline virtual int no_elements () const" + " { return %d; }\n", cnt); + fprintf(inc, " virtual const char * element_at (int n) const;\n"); /* end class definition */ - fprintf( inc, "};\n" ); + fprintf(inc, "};\n"); - fprintf( inc, "\ntypedef %s * %s_ptr;\n", n, n ); - fprintf( inc, "\ntypedef const %s * %s_ptr_c;\n", n, n ); + fprintf(inc, "\ntypedef %s * %s_ptr;\n", n, n); + fprintf(inc, "\ntypedef const %s * %s_ptr_c;\n", n, n); /* Print ObjectStore Access Hook function */ - printEnumCreateHdr( inc, type ); + printEnumCreateHdr(inc, type); /* DAS brandnew above */ /* print things for aggregate class */ - sprintf( enumAggrNm, "%s_agg", n ); + sprintf(enumAggrNm, "%s_agg", n); - fprintf( inc, "\nclass %s_agg : public EnumAggregate {\n", n ); + fprintf(inc, "\nclass %s_agg : public EnumAggregate {\n", n); - fprintf( inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n" ); - fprintf( inc, " public:\n" ); - fprintf( inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm ); - fprintf( inc, " virtual ~%s_agg();\n", n ); - fprintf( inc, " virtual SingleLinkNode * NewNode()\n" ); - fprintf( inc, " { return new EnumNode (new %s( \"\", enum_type )); }" - "\n", n ); + fprintf(inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n"); + fprintf(inc, " public:\n"); + fprintf(inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm); + fprintf(inc, " virtual ~%s_agg();\n", n); + fprintf(inc, " virtual SingleLinkNode * NewNode()\n"); + fprintf(inc, " { return new EnumNode (new %s( \"\", enum_type )); }" + "\n", n); - fprintf( inc, "};\n" ); + fprintf(inc, "};\n"); - fprintf( inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n ); - fprintf( inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n ); + fprintf(inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n); + fprintf(inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n); /* DAS brandnew below */ /* DAS creation function for enum aggregate class */ - printEnumAggrCrHdr( inc, type ); + printEnumAggrCrHdr(inc, type); /* DAS brandnew above */ } -void TYPEenum_lib_print( const Type type, FILE * f ) { +void TYPEenum_lib_print(const Type type, FILE *f) +{ DictionaryEntry de; Expression expr; - const char * n; /* pointer to class name */ + const char *n; /* pointer to class name */ char c_enum_ele [BUFSIZ]; - n = TYPEget_ctype( type ); + n = TYPEget_ctype(type); /* set up the dictionary info */ - fprintf( f, "const char *\n%s::element_at (int n) const {\n", n ); - fprintf( f, " switch (n) {\n" ); - DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); - while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { - strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); - c_enum_ele[BUFSIZ-1] = '\0'; - fprintf( f, " case %s: return \"%s\";\n", - c_enum_ele, - StrToUpper( EXPget_name( expr ) ) ); + fprintf(f, "const char *\n%s::element_at (int n) const {\n", n); + fprintf(f, " switch (n) {\n"); + DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); + while(0 != (expr = (Expression)DICTdo(&de))) { + strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); + c_enum_ele[BUFSIZ - 1] = '\0'; + fprintf(f, " case %s: return \"%s\";\n", + c_enum_ele, + StrToUpper(EXPget_name(expr))); } - fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); - fprintf( f, " default : return \"UNSET\";\n }\n}\n" ); + fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); + fprintf(f, " default : return \"UNSET\";\n }\n}\n"); /* constructors */ /* construct with character string */ - fprintf( f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" - " : type(et)\n{\n", n, n ); - fprintf( f, " set_value (n);\n}\n" ); + fprintf(f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" + " : type(et)\n{\n", n, n); + fprintf(f, " set_value (n);\n}\n"); /* cast operator to an enumerated type */ - fprintf( f, "\n%s::operator %s () const {\n", n, - EnumName( TYPEget_name( type ) ) ); - fprintf( f, " switch (v) {\n" ); - DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); - while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { - strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); - fprintf( f, " case %s : ", c_enum_ele ); - fprintf( f, "return %s;\n", c_enum_ele ); + fprintf(f, "\n%s::operator %s () const {\n", n, + EnumName(TYPEget_name(type))); + fprintf(f, " switch (v) {\n"); + DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); + while(0 != (expr = (Expression)DICTdo(&de))) { + strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); + fprintf(f, " case %s : ", c_enum_ele); + fprintf(f, "return %s;\n", c_enum_ele); } /* print the last case with the default so sun c++ doesn't complain */ - fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); - fprintf( f, " default : return %s_unset;\n }\n}\n", EnumName( TYPEget_name( type ) ) ); + fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); + fprintf(f, " default : return %s_unset;\n }\n}\n", EnumName(TYPEget_name(type))); - printEnumCreateBody( f, type ); + printEnumCreateBody(f, type); /* print the enum aggregate functions */ - fprintf( f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n ); - fprintf( f, " : enum_type(et)\n{\n}\n\n" ); - fprintf( f, "%s_agg::~%s_agg()\n{\n}\n", n, n ); + fprintf(f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n); + fprintf(f, " : enum_type(et)\n{\n}\n\n"); + fprintf(f, "%s_agg::~%s_agg()\n{\n}\n", n, n); - printEnumAggrCrBody( f, type ); + printEnumAggrCrBody(f, type); } -void TYPEPrint_h( const Type type, FILE * file ) { - DEBUG( "Entering TYPEPrint_h for %s\n", TYPEget_ctype( type ) ); +void TYPEPrint_h(const Type type, FILE *file) +{ + DEBUG("Entering TYPEPrint_h for %s\n", TYPEget_ctype(type)); - if ( TYPEis_enumeration( type ) ) { - TYPEenum_inc_print( type, file ); - } else if ( TYPEis_select( type ) ) { - TYPEselect_inc_print( type, file ); + if(TYPEis_enumeration(type)) { + TYPEenum_inc_print(type, file); + } else if(TYPEis_select(type)) { + TYPEselect_inc_print(type, file); } - fprintf( file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype( type ) ); + fprintf(file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype(type)); - DEBUG( "DONE TYPEPrint_h\n" ); + DEBUG("DONE TYPEPrint_h\n"); } -void TYPEPrint_cc( const Type type, const filenames_t * names, FILE * hdr, FILE * impl, Schema schema ) { - DEBUG( "Entering TYPEPrint_cc for %s\n", names->impl ); +void TYPEPrint_cc(const Type type, const filenames_t *names, FILE *hdr, FILE *impl, Schema schema) +{ + DEBUG("Entering TYPEPrint_cc for %s\n", names->impl); - fprintf( impl, "#include \"schema.h\"\n" ); - fprintf( impl, "#include \"sc_memmgr.h\"\n" ); - fprintf( impl, "#include \"%s\"\n\n", names->header ); + fprintf(impl, "#include \"schema.h\"\n"); + fprintf(impl, "#include \"sc_memmgr.h\"\n"); + fprintf(impl, "#include \"%s\"\n\n", names->header); - if ( TYPEis_enumeration( type ) ) { - TYPEenum_lib_print( type, impl ); - } else if ( TYPEis_select( type ) ) { - TYPEselect_lib_print( type, impl ); + if(TYPEis_enumeration(type)) { + TYPEenum_lib_print(type, impl); + } else if(TYPEis_select(type)) { + TYPEselect_lib_print(type, impl); } - fprintf( impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype( type ) ); - fprintf( impl, " std::string str;\n" ); + fprintf(impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype(type)); + fprintf(impl, " std::string str;\n"); /* moved from SCOPEPrint in classes_wrapper */ - TYPEprint_new( type, impl, schema, true ); - TYPEprint_init( type, hdr, impl, schema ); - fprintf( impl, "}\n\n" ); + TYPEprint_new(type, impl, schema, true); + TYPEprint_init(type, hdr, impl, schema); + fprintf(impl, "}\n\n"); - DEBUG( "DONE TYPEPrint_cc\n" ); + DEBUG("DONE TYPEPrint_cc\n"); } -void TYPEPrint( const Type type, FILES *files, Schema schema ) { - FILE * hdr, * impl; - filenames_t names = getTypeFilenames( type ); +void TYPEPrint(const Type type, FILES *files, Schema schema) +{ + FILE *hdr, * impl; + filenames_t names = getTypeFilenames(type); - fprintf( files->inc, "#include \"%s\"\n", names.header ); + fprintf(files->inc, "#include \"%s\"\n", names.header); - fprintf( files->init, " init_%s( reg );\n", TYPEget_ctype( type ) ); + fprintf(files->init, " init_%s( reg );\n", TYPEget_ctype(type)); - if( mkDirIfNone( "type" ) == -1 ) { - fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror( 0 ); + if(mkDirIfNone("type") == -1) { + fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror(0); abort(); } - hdr = FILEcreate( names.header ); - impl = FILEcreate( names.impl ); - assert( hdr && impl && "error creating files" ); - fprintf( files->unity.type.hdr, "#include \"%s\"\n", names.header ); - fprintf( files->unity.type.impl, "#include \"%s\"\n", names.impl ); + hdr = FILEcreate(names.header); + impl = FILEcreate(names.impl); + assert(hdr && impl && "error creating files"); + fprintf(files->unity.type.hdr, "#include \"%s\"\n", names.header); + fprintf(files->unity.type.impl, "#include \"%s\"\n", names.impl); - TYPEPrint_h( type, hdr ); - TYPEPrint_cc( type, &names, hdr, impl, schema ); + TYPEPrint_h(type, hdr); + TYPEPrint_cc(type, &names, hdr, impl, schema); - FILEclose( hdr ); - FILEclose( impl ); + FILEclose(hdr); + FILEclose(impl); } /** @@ -371,41 +381,45 @@ void TYPEPrint( const Type type, FILES *files, Schema schema ) { * NOTE - "Print ObjectStore Access Hook function" comment seen at one of * the calls seems to imply it's ObjectStore specific... */ -static void printEnumCreateHdr( FILE * inc, const Type type ) { - const char * nm = TYPEget_ctype( type ); +static void printEnumCreateHdr(FILE *inc, const Type type) +{ + const char *nm = TYPEget_ctype(type); - fprintf( inc, " SDAI_Enum * create_%s();\n", nm ); + fprintf(inc, " SDAI_Enum * create_%s();\n", nm); } /** See header comment above by printEnumCreateHdr. */ -static void printEnumCreateBody( FILE * lib, const Type type ) { - const char * nm = TYPEget_ctype( type ); +static void printEnumCreateBody(FILE *lib, const Type type) +{ + const char *nm = TYPEget_ctype(type); char tdnm[BUFSIZ]; - tdnm[BUFSIZ-1] = '\0'; + tdnm[BUFSIZ - 1] = '\0'; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; - fprintf( lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm ); - fprintf( lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm ); + fprintf(lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm); + fprintf(lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm); } /** Similar to printEnumCreateHdr above for the enum aggregate. */ -static void printEnumAggrCrHdr( FILE * inc, const Type type ) { - const char * n = TYPEget_ctype( type ); +static void printEnumAggrCrHdr(FILE *inc, const Type type) +{ + const char *n = TYPEget_ctype(type); /* const char *n = ClassName( TYPEget_name(type) ));*/ - fprintf( inc, " STEPaggregate * create_%s_agg ();\n", n ); + fprintf(inc, " STEPaggregate * create_%s_agg ();\n", n); } -static void printEnumAggrCrBody( FILE * lib, const Type type ) { - const char * n = TYPEget_ctype( type ); +static void printEnumAggrCrBody(FILE *lib, const Type type) +{ + const char *n = TYPEget_ctype(type); char tdnm[BUFSIZ]; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; - fprintf( lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n ); - fprintf( lib, " return new %s_agg( %s );\n}\n", n, tdnm ); + fprintf(lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n); + fprintf(lib, " return new %s_agg( %s );\n}\n", n, tdnm); } /** ************************************************************************ @@ -423,13 +437,14 @@ static void printEnumAggrCrBody( FILE * lib, const Type type ) { ** Status: 16-Mar-1993 kcm; updated 04-Feb-1997 dar ** Dec 2011 - MAP - remove goto **************************************************************************/ -void TYPEprint_typedefs( Type t, FILE * classes ) { +void TYPEprint_typedefs(Type t, FILE *classes) +{ char nm [BUFSIZ]; Type i; bool aggrNot1d = true; /* added so I can get rid of a goto */ /* Print the typedef statement (poss also a forward class def: */ - if( TYPEis_enumeration( t ) ) { + if(TYPEis_enumeration(t)) { /* For enums and sels (else clause below), we need forward decl's so that if we later come across a type which is an aggregate of one of them, we'll be able to process it. For selects, we also need a decl @@ -438,32 +453,32 @@ void TYPEprint_typedefs( Type t, FILE * classes ) { same is basically true for the select, but a sel containing an ent containing a sel needs the forward decl (trust me ;-) ). */ - if( !TYPEget_head( t ) ) { + if(!TYPEget_head(t)) { /* Only print this enum if it is an actual type and not a redefi- nition of another enum. (Those are printed at the end of the classes file - after all the actual enum's. They must be printed last since they depend on the others.) */ - strncpy( nm, TYPEget_ctype( t ), BUFSIZ ); - nm[BUFSIZ-1] = '\0'; - fprintf( classes, "class %s_agg;\n", nm ); + strncpy(nm, TYPEget_ctype(t), BUFSIZ); + nm[BUFSIZ - 1] = '\0'; + fprintf(classes, "class %s_agg;\n", nm); } - } else if( TYPEis_select( t ) ) { - if( !TYPEget_head( t ) ) { + } else if(TYPEis_select(t)) { + if(!TYPEget_head(t)) { /* Same comment as above. */ - strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); - nm[BUFSIZ-1] = '\0'; - fprintf( classes, "class %s;\n", nm ); - fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); - fprintf( classes, "class %s_agg;\n", nm ); - fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); + strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); + nm[BUFSIZ - 1] = '\0'; + fprintf(classes, "class %s;\n", nm); + fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); + fprintf(classes, "class %s_agg;\n", nm); + fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); } } else { - if( TYPEis_aggregate( t ) ) { - i = TYPEget_base_type( t ); - if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { + if(TYPEis_aggregate(t)) { + i = TYPEget_base_type(t); + if(TYPEis_enumeration(i) || TYPEis_select(i)) { /* One exceptional case - a 1d aggregate of an enum or select. We must wait till the enum/sel itself has been processed. To ensure this, we process all such 1d aggrs in a special @@ -474,26 +489,26 @@ void TYPEprint_typedefs( Type t, FILE * classes ) { aggrNot1d = false; } } - if( aggrNot1d ) { + if(aggrNot1d) { /* At this point, we'll print typedefs for types which are redefined fundamental types and their aggregates, and for 2D aggregates(aggre- gates of aggregates) of enum's and selects. */ - strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); - nm[BUFSIZ-1] = '\0'; - fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); - if( TYPEis_aggregate( t ) ) { - fprintf( classes, "typedef %s * %sH;\n", nm, nm ); - fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); - fprintf( classes, "typedef %s_ptr %s_var;\n", nm, nm ); + strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); + nm[BUFSIZ - 1] = '\0'; + fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); + if(TYPEis_aggregate(t)) { + fprintf(classes, "typedef %s * %sH;\n", nm, nm); + fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); + fprintf(classes, "typedef %s_ptr %s_var;\n", nm, nm); } } } /* Print the extern statement: */ - strncpy( nm, TYPEtd_name( t ), BUFSIZ ); - fprintf( classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName( t ), nm ); + strncpy(nm, TYPEtd_name(t), BUFSIZ); + fprintf(classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName(t), nm); } /** ** @@ -505,90 +520,92 @@ void TYPEprint_typedefs( Type t, FILE * classes ) { initialize it in the .init.cc file (DAR - all initialization done in fn TYPEprint_init() (below) which is done in exp2cxx's 1st pass only.) *****/ -void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { +void TYPEprint_descriptions(const Type type, FILES *files, Schema schema) +{ char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], nm [BUFSIZ]; Type i; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; /* define type descriptor pointer */ /* in source - declare the real definition of the pointer */ /* i.e. in the .cc file */ - fprintf( files -> lib, "%s *%s;\n", GetTypeDescriptorName( type ), tdnm ); + fprintf(files -> lib, "%s *%s;\n", GetTypeDescriptorName(type), tdnm); - if( isAggregateType( type ) ) { - const char * ctype = TYPEget_ctype( type ); + if(isAggregateType(type)) { + const char *ctype = TYPEget_ctype(type); - fprintf( files->inc, "STEPaggregate * create_%s ();\n\n", - ClassName( TYPEget_name( type ) ) ); + fprintf(files->inc, "STEPaggregate * create_%s ();\n\n", + ClassName(TYPEget_name(type))); - fprintf( files->lib, - "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", - ClassName( TYPEget_name( type ) ), ctype ); + fprintf(files->lib, + "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", + ClassName(TYPEget_name(type)), ctype); /* this function is assigned to the aggrCreator var in TYPEprint_new */ } - if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { + if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { /* If we're a renamed enum type, just print a few typedef's to the * original and some specialized create functions: */ - strncpy( base, EnumName( TYPEget_name( i ) ), BUFSIZ ); - strncpy( nm, EnumName( TYPEget_name( type ) ), BUFSIZ ); - fprintf( files->inc, "typedef %s %s;\n", base, nm ); - strncpy( base, TYPEget_ctype( i ), BUFSIZ ); - strncpy( nm, TYPEget_ctype( type ), BUFSIZ ); - fprintf( files->inc, "typedef %s %s;\n", base, nm ); - printEnumCreateHdr( files->inc, type ); - printEnumCreateBody( files->lib, type ); - fprintf( files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); - fprintf( files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); - printEnumAggrCrHdr( files->inc, type ); - printEnumAggrCrBody( files->lib, type ); + strncpy(base, EnumName(TYPEget_name(i)), BUFSIZ); + strncpy(nm, EnumName(TYPEget_name(type)), BUFSIZ); + fprintf(files->inc, "typedef %s %s;\n", base, nm); + strncpy(base, TYPEget_ctype(i), BUFSIZ); + strncpy(nm, TYPEget_ctype(type), BUFSIZ); + fprintf(files->inc, "typedef %s %s;\n", base, nm); + printEnumCreateHdr(files->inc, type); + printEnumCreateBody(files->lib, type); + fprintf(files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); + fprintf(files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); + printEnumAggrCrHdr(files->inc, type); + printEnumAggrCrBody(files->lib, type); return; } - if( !TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { - if( TYPEis_enumeration( type ) ) { - TYPEPrint( type, files, schema ); + if(!TYPEget_RefTypeVarNm(type, typename_buf, schema)) { + if(TYPEis_enumeration(type)) { + TYPEPrint(type, files, schema); } /* so we don't do anything for non-enums??? */ } else { - TYPEprint_new( type, files->create, schema, false ); - TYPEprint_init( type, files->inc, files->init, schema ); + TYPEprint_new(type, files->create, schema, false); + TYPEprint_init(type, files->inc, files->init, schema); } } -void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ) { +void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema) +{ char tdnm [BUFSIZ]; char typename_buf[MAX_LEN]; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - if( isAggregateType( type ) ) { - AGGRprint_init( header, impl, type, tdnm, type->symbol.name ); + if(isAggregateType(type)) { + AGGRprint_init(header, impl, type, tdnm, type->symbol.name); } /* fill in the TD's values in the SchemaInit function (it is already declared with basic values) */ - if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { - fprintf( impl, " %s->ReferentType(%s);\n", tdnm, typename_buf ); + if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { + fprintf(impl, " %s->ReferentType(%s);\n", tdnm, typename_buf); } else { - switch( TYPEget_body( type )->type ) { + switch(TYPEget_body(type)->type) { case aggregate_: /* aggregate_ should not happen? DAS */ case array_: case bag_: case set_: case list_: { - if( isMultiDimAggregateType( type ) ) { - print_typechain( header, impl, TYPEget_body( type )->base, - typename_buf, schema, type->symbol.name ); - fprintf( impl, " %s->ReferentType(%s);\n", tdnm, - typename_buf ); + if(isMultiDimAggregateType(type)) { + print_typechain(header, impl, TYPEget_body(type)->base, + typename_buf, schema, type->symbol.name); + fprintf(impl, " %s->ReferentType(%s);\n", tdnm, + typename_buf); } break; } @@ -599,71 +616,73 @@ void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema /* DAR - moved fn call below from TYPEselect_print to here to put all init ** info together. */ - if( TYPEis_select( type ) ) { - TYPEselect_init_print( type, impl ); + if(TYPEis_select(type)) { + TYPEselect_init_print(type, impl); } #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the type into the schema descriptor */ - fprintf( impl, - " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", - SCHEMAget_name( schema ), tdnm ); + fprintf(impl, + " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", + SCHEMAget_name(schema), tdnm); #endif /* insert into type dictionary */ - fprintf( impl, " reg.AddType (*%s);\n", tdnm ); + fprintf(impl, " reg.AddType (*%s);\n", tdnm); } /** print name, fundamental type, and description initialization function calls */ -void TYPEprint_nm_ft_desc( Schema schema, const Type type, FILE * f, char * endChars ) { - fprintf( f, " \"%s\", // Name\n", PrettyTmpName( TYPEget_name( type ) ) ); - fprintf( f, " %s, // FundamentalType\n", FundamentalType( type, 1 ) ); - fprintf( f, " %s::schema, // Originating Schema\n", SCHEMAget_name( schema ) ); - fprintf( f, " \"%s\"%s // Description\n", TypeDescription( type ), endChars ); +void TYPEprint_nm_ft_desc(Schema schema, const Type type, FILE *f, char *endChars) +{ + fprintf(f, " \"%s\", // Name\n", PrettyTmpName(TYPEget_name(type))); + fprintf(f, " %s, // FundamentalType\n", FundamentalType(type, 1)); + fprintf(f, " %s::schema, // Originating Schema\n", SCHEMAget_name(schema)); + fprintf(f, " \"%s\"%s // Description\n", TypeDescription(type), endChars); } /** new space for a variable of type TypeDescriptor (or subtype). This * function is called for Types that have an Express name. */ -void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) { - Type tmpType = TYPEget_head( type ); +void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) +{ + Type tmpType = TYPEget_head(type); Type bodyType = tmpType; /* define type definition */ /* in source - the real definition of the TypeDescriptor */ - if( TYPEis_select( type ) ) { - char * temp; - temp = non_unique_types_string( type ); - fprintf( create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name( type ), temp ); - sc_free( temp ); - TYPEprint_nm_ft_desc( schema, type, create, "," ); - fprintf( create, " (SelectCreator) create_%s); // Creator function\n", SelectName( TYPEget_name( type ) ) ); + if(TYPEis_select(type)) { + char *temp; + temp = non_unique_types_string(type); + fprintf(create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name(type), temp); + sc_free(temp); + TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf(create, " (SelectCreator) create_%s); // Creator function\n", SelectName(TYPEget_name(type))); } else { - switch( TYPEget_body( type )->type ) { + switch(TYPEget_body(type)->type) { case boolean_: - fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); - TYPEprint_nm_ft_desc( schema, type, create, "," ); - fprintf( create, " (EnumCreator) create_BOOLEAN); // Creator function\n" ); + fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); + TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf(create, " (EnumCreator) create_BOOLEAN); // Creator function\n"); break; case logical_: - fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); - TYPEprint_nm_ft_desc( schema, type, create, "," ); - fprintf( create, " (EnumCreator) create_LOGICAL); // Creator function\n" ); + fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); + TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf(create, " (EnumCreator) create_LOGICAL); // Creator function\n"); break; case enumeration_: - fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); - TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); + TYPEprint_nm_ft_desc(schema, type, create, ","); /* get the type name of the underlying type - it is the type that needs to get created */ - tmpType = TYPEget_head( type ); - if( tmpType ) { + tmpType = TYPEget_head(type); + if(tmpType) { bodyType = tmpType; - while( tmpType ) { + while(tmpType) { bodyType = tmpType; - tmpType = TYPEget_head( tmpType ); + tmpType = TYPEget_head(tmpType); } - fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( bodyType ) ); + fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(bodyType)); } else { - fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( type ) ); + fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(type)); } break; case aggregate_: @@ -671,20 +690,20 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) case bag_: case set_: case list_: - fprintf( create, "\n %s = new %s (\n", TYPEtd_name( type ), GetTypeDescriptorName( type ) ); - TYPEprint_nm_ft_desc( schema, type, create, "," ); - fprintf( create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName( TYPEget_name( type ) ) ); + fprintf(create, "\n %s = new %s (\n", TYPEtd_name(type), GetTypeDescriptorName(type)); + TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf(create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName(TYPEget_name(type))); break; default: - fprintf( create, " %s = new TypeDescriptor (\n", TYPEtd_name( type ) ); - TYPEprint_nm_ft_desc( schema, type, create, ");" ); + fprintf(create, " %s = new TypeDescriptor (\n", TYPEtd_name(type)); + TYPEprint_nm_ft_desc(schema, type, create, ");"); break; } } /* add the type to the Schema dictionary entry */ - fprintf( create, " %s::schema->AddType(%s);\n", SCHEMAget_name( schema ), TYPEtd_name( type ) ); + fprintf(create, " %s::schema->AddType(%s);\n", SCHEMAget_name(schema), TYPEtd_name(type)); - WHEREprint( TYPEtd_name( type ), type->where, create, 0, needWR ); + WHEREprint(TYPEtd_name(type), type->where, create, 0, needWR); } /** Get the TypeDescriptor variable name that t's TypeDescriptor references (if @@ -706,22 +725,23 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) Nov 2011 - MAP - modified to insert scope operator into variable name. Reason: use of namespace for global variables */ -int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { +int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) +{ /* It looks like TYPEget_head(t) is true when processing a type that refers to another type. e.g. when processing "name" in: TYPE name = label; ENDTYPE; TYPE label = STRING; ENDTYPE; DAS */ - if( TYPEget_head( t ) ) { + if(TYPEget_head(t)) { /* this means that it is defined in an Express TYPE stmt and it refers to another Express TYPE stmt */ /* it would be a reference_ type */ /* a TypeDescriptor of the form t_ */ - sprintf( buf, "%s::%s%s", - SCHEMAget_name( TYPEget_head( t )->superscope ), - TYPEprefix( t ), TYPEget_name( TYPEget_head( t ) ) ); + sprintf(buf, "%s::%s%s", + SCHEMAget_name(TYPEget_head(t)->superscope), + TYPEprefix(t), TYPEget_name(TYPEget_head(t))); return 1; } else { - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case integer_: case real_: case boolean_: @@ -731,7 +751,7 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { case number_: /* one of the SCL builtin TypeDescriptors of the form t_STRING_TYPE, or t_REAL_TYPE */ - sprintf( buf, "%s%s", TD_PREFIX, FundamentalType( t, 0 ) ); + sprintf(buf, "%s%s", TD_PREFIX, FundamentalType(t, 0)); return 1; break; @@ -742,7 +762,7 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { break; case entity_: - sprintf( buf, "%s", TYPEtd_name( t ) ); + sprintf(buf, "%s", TYPEtd_name(t)); /* following assumes we are not in a nested entity */ /* otherwise we should search upward for schema */ return 1; @@ -756,11 +776,11 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { /* referent TypeDescriptor will be the one for the element unless it is a multidimensional aggregate then return 0 */ - if( isMultiDimAggregateType( t ) ) { - if( TYPEget_name( TYPEget_body( t )->base ) ) { - sprintf( buf, "%s::%s%s", - SCHEMAget_name( TYPEget_body( t )->base->superscope ), - TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); + if(isMultiDimAggregateType(t)) { + if(TYPEget_name(TYPEget_body(t)->base)) { + sprintf(buf, "%s::%s%s", + SCHEMAget_name(TYPEget_body(t)->base->superscope), + TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); return 1; } @@ -772,22 +792,22 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { for element */ /* being an aggregate implies that base below is not 0 */ - if( TYPEget_body( TYPEget_body( t )->base )->type == enumeration_ || - TYPEget_body( TYPEget_body( t )->base )->type == select_ ) { + if(TYPEget_body(TYPEget_body(t)->base)->type == enumeration_ || + TYPEget_body(TYPEget_body(t)->base)->type == select_) { - sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); + sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); return 1; - } else if( TYPEget_name( TYPEget_body( t )->base ) ) { - if( TYPEget_body( TYPEget_body( t )->base )->type == entity_ ) { - sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); + } else if(TYPEget_name(TYPEget_body(t)->base)) { + if(TYPEget_body(TYPEget_body(t)->base)->type == entity_) { + sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); return 1; } - sprintf( buf, "%s::%s%s", - SCHEMAget_name( TYPEget_body( t )->base->superscope ), - TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); + sprintf(buf, "%s::%s%s", + SCHEMAget_name(TYPEget_body(t)->base->superscope), + TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); return 1; } - return TYPEget_RefTypeVarNm( TYPEget_body( t )->base, buf, schema ); + return TYPEget_RefTypeVarNm(TYPEget_body(t)->base, buf, schema); } break; default: @@ -825,277 +845,284 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { that can be referenced to refer to the type that was created for Type t. */ -void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ) { +void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name) +{ /* if we've been called, current type has no name */ /* nor is it a built-in type */ /* the type_count variable is there for debugging purposes */ - const char * ctype = TYPEget_ctype( t ); + const char *ctype = TYPEget_ctype(t); int count = type_count++; char name_buf[MAX_LEN]; int s; - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case aggregate_: case array_: case bag_: case set_: case list_: /* create a new TypeDescriptor variable, e.g. t1, and new space for it */ - fprintf( impl, " %s * %s%d = new %s;\n", - GetTypeDescriptorName( t ), TD_PREFIX, count, - GetTypeDescriptorName( t ) ); + fprintf(impl, " %s * %s%d = new %s;\n", + GetTypeDescriptorName(t), TD_PREFIX, count, + GetTypeDescriptorName(t)); - fprintf( impl, - " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", - TD_PREFIX, count, ctype, " // Creator function\n" ); + fprintf(impl, + " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", + TD_PREFIX, count, ctype, " // Creator function\n"); - s = sprintf( name_buf, "%s%d", TD_PREFIX, count ); - assert( ( s > 0 ) && ( s < MAX_LEN ) ); - AGGRprint_init( header, impl, t, name_buf, type_name ); + s = sprintf(name_buf, "%s%d", TD_PREFIX, count); + assert((s > 0) && (s < MAX_LEN)); + AGGRprint_init(header, impl, t, name_buf, type_name); break; default: /* this should not happen since only aggregates are allowed to not have a name. This funct should only be called for aggrs without names. */ - fprintf( impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", - TD_PREFIX, count ); + fprintf(impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", + TD_PREFIX, count); } /* there is no name so name doesn't need to be initialized */ - fprintf( impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, - FundamentalType( t, 1 ) ); - fprintf( impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, - TypeDescription( t ) ); + fprintf(impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, + FundamentalType(t, 1)); + fprintf(impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, + TypeDescription(t)); /* DAS ORIG SCHEMA FIX */ - fprintf( impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name( schema ) ); + fprintf(impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name(schema)); - if( TYPEget_RefTypeVarNm( t, name_buf, schema ) ) { - fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf ); + if(TYPEget_RefTypeVarNm(t, name_buf, schema)) { + fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf); } else { Type base = 0; /* no name, recurse */ char callee_buffer[MAX_LEN]; - if( TYPEget_body( t ) ) { - base = TYPEget_body( t )->base; + if(TYPEget_body(t)) { + base = TYPEget_body(t)->base; } - print_typechain( header, impl, base, callee_buffer, schema, type_name ); - fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer ); + print_typechain(header, impl, base, callee_buffer, schema, type_name); + fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer); } - sprintf( buf, "%s%d", TD_PREFIX, count ); + sprintf(buf, "%s%d", TD_PREFIX, count); /* Types */ - fprintf( impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name( schema ), TD_PREFIX, count ); + fprintf(impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name(schema), TD_PREFIX, count); } /** return 1 if it is a multidimensional aggregate at the level passed in otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ -int isMultiDimAggregateType( const Type t ) { - if( TYPEget_body( t )->base ) - if( isAggregateType( TYPEget_body( t )->base ) ) { +int isMultiDimAggregateType(const Type t) +{ + if(TYPEget_body(t)->base) + if(isAggregateType(TYPEget_body(t)->base)) { return 1; } return 0; } -void Type_Description( const Type t, char * buf ) { - if( TYPEget_name( t ) ) { - strcat( buf, " " ); - strcat( buf, TYPEget_name( t ) ); +void Type_Description(const Type t, char *buf) +{ + if(TYPEget_name(t)) { + strcat(buf, " "); + strcat(buf, TYPEget_name(t)); } else { - TypeBody_Description( TYPEget_body( t ), buf ); + TypeBody_Description(TYPEget_body(t), buf); } } -void TypeBody_Description( TypeBody body, char * buf ) { - char * s; +void TypeBody_Description(TypeBody body, char *buf) +{ + char *s; - switch( body->type ) { + switch(body->type) { case integer_: - strcat( buf, " INTEGER" ); + strcat(buf, " INTEGER"); break; case real_: - strcat( buf, " REAL" ); + strcat(buf, " REAL"); break; case string_: - strcat( buf, " STRING" ); + strcat(buf, " STRING"); break; case binary_: - strcat( buf, " BINARY" ); + strcat(buf, " BINARY"); break; case boolean_: - strcat( buf, " BOOLEAN" ); + strcat(buf, " BOOLEAN"); break; case logical_: - strcat( buf, " LOGICAL" ); + strcat(buf, " LOGICAL"); break; case number_: - strcat( buf, " NUMBER" ); + strcat(buf, " NUMBER"); break; case entity_: - strcat( buf, " " ); - strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); + strcat(buf, " "); + strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch( body->type ) { - /* ignore the aggregate bounds for now */ + switch(body->type) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat( buf, " AGGREGATE OF" ); + strcat(buf, " AGGREGATE OF"); break; case array_: - strcat( buf, " ARRAY" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); - if( body->flags.optional ) { - strcat( buf, " OPTIONAL" ); + strcat(buf, " ARRAY"); + strcat_bounds(body, buf); + strcat(buf, " OF"); + if(body->flags.optional) { + strcat(buf, " OPTIONAL"); } - if( body->flags.unique ) { - strcat( buf, " UNIQUE" ); + if(body->flags.unique) { + strcat(buf, " UNIQUE"); } break; case bag_: - strcat( buf, " BAG" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); + strcat(buf, " BAG"); + strcat_bounds(body, buf); + strcat(buf, " OF"); break; case set_: - strcat( buf, " SET" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); + strcat(buf, " SET"); + strcat_bounds(body, buf); + strcat(buf, " OF"); break; case list_: - strcat( buf, " LIST" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); - if( body->flags.unique ) { - strcat( buf, " UNIQUE" ); + strcat(buf, " LIST"); + strcat_bounds(body, buf); + strcat(buf, " OF"); + if(body->flags.unique) { + strcat(buf, " UNIQUE"); } break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); abort(); } - Type_Description( body->base, buf ); + Type_Description(body->base, buf); break; case enumeration_: - strcat( buf, " ENUMERATION of (" ); - LISTdo( body->list, e, Expression ) - strcat( buf, ENUMget_name( e ) ); - strcat( buf, ", " ); + strcat(buf, " ENUMERATION of ("); + LISTdo(body->list, e, Expression) + strcat(buf, ENUMget_name(e)); + strcat(buf, ", "); LISTod /* find last comma and replace with ')' */ - s = strrchr( buf, ',' ); - if( s ) { - strcpy( s, ")" ); + s = strrchr(buf, ','); + if(s) { + strcpy(s, ")"); } break; case select_: - strcat( buf, " SELECT (" ); - LISTdo( body->list, t, Type ) - strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); - strcat( buf, ", " ); + strcat(buf, " SELECT ("); + LISTdo(body->list, t, Type) + strcat(buf, PrettyTmpName(TYPEget_name(t))); + strcat(buf, ", "); LISTod /* find last comma and replace with ')' */ - s = strrchr( buf, ',' ); - if( s ) { - strcpy( s, ")" ); + s = strrchr(buf, ','); + if(s) { + strcpy(s, ")"); } break; default: - strcat( buf, " UNKNOWN" ); + strcat(buf, " UNKNOWN"); } - if( body->precision ) { - strcat( buf, " (" ); - strcat_expr( body->precision, buf ); - strcat( buf, ")" ); + if(body->precision) { + strcat(buf, " ("); + strcat_expr(body->precision, buf); + strcat(buf, ")"); } - if( body->flags.fixed ) { - strcat( buf, " FIXED" ); + if(body->flags.fixed) { + strcat(buf, " FIXED"); } } -const char * IdlEntityTypeName( Type t ) { +const char *IdlEntityTypeName(Type t) +{ static char name [BUFSIZ]; - strcpy( name, TYPE_PREFIX ); - if( TYPEget_name( t ) ) { - strcpy( name, FirstToUpper( TYPEget_name( t ) ) ); + strcpy(name, TYPE_PREFIX); + if(TYPEget_name(t)) { + strcpy(name, FirstToUpper(TYPEget_name(t))); } else { - return TYPEget_ctype( t ); + return TYPEget_ctype(t); } return name; } -const char * GetAggrElemType( const Type type ) { +const char *GetAggrElemType(const Type type) +{ Class_Of_Type class; Type bt; static char retval [BUFSIZ]; - if( isAggregateType( type ) ) { - bt = TYPEget_nonaggregate_base_type( type ); - if( isAggregateType( bt ) ) { - strcpy( retval, "ERROR_aggr_of_aggr" ); + if(isAggregateType(type)) { + bt = TYPEget_nonaggregate_base_type(type); + if(isAggregateType(bt)) { + strcpy(retval, "ERROR_aggr_of_aggr"); } - class = TYPEget_type( bt ); + class = TYPEget_type(bt); /* case TYPE_INTEGER: */ - if( class == integer_ ) { - strcpy( retval, "long" ); + if(class == integer_) { + strcpy(retval, "long"); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if( ( class == number_ ) || ( class == real_ ) ) { - strcpy( retval, "double" ); + if((class == number_) || (class == real_)) { + strcpy(retval, "double"); } /* case TYPE_ENTITY: */ - if( class == entity_ ) { - strcpy( retval, IdlEntityTypeName( bt ) ); + if(class == entity_) { + strcpy(retval, IdlEntityTypeName(bt)); } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if( ( class == enumeration_ ) - || ( class == select_ ) ) { - strcpy( retval, TYPEget_ctype( bt ) ); + if((class == enumeration_) + || (class == select_)) { + strcpy(retval, TYPEget_ctype(bt)); } /* case TYPE_LOGICAL: */ - if( class == logical_ ) { - strcpy( retval, "Logical" ); + if(class == logical_) { + strcpy(retval, "Logical"); } /* case TYPE_BOOLEAN: */ - if( class == boolean_ ) { - strcpy( retval, "Bool" ); + if(class == boolean_) { + strcpy(retval, "Bool"); } /* case TYPE_STRING: */ - if( class == string_ ) { - strcpy( retval, "string" ); + if(class == string_) { + strcpy(retval, "string"); } /* case TYPE_BINARY: */ - if( class == binary_ ) { - strcpy( retval, "binary" ); + if(class == binary_) { + strcpy(retval, "binary"); } } return retval; } -const char * TYPEget_idl_type( const Type t ) { +const char *TYPEget_idl_type(const Type t) +{ Class_Of_Type class; static char retval [BUFSIZ]; @@ -1106,86 +1133,86 @@ const char * TYPEget_idl_type( const Type t ) { case TYPE_SET: */ - if( isAggregateType( t ) ) { - strcpy( retval, GetAggrElemType( t ) ); + if(isAggregateType(t)) { + strcpy(retval, GetAggrElemType(t)); /* case TYPE_ARRAY: */ - if( TYPEget_type( t ) == array_ ) { - strcat( retval, "__array" ); + if(TYPEget_type(t) == array_) { + strcat(retval, "__array"); } /* case TYPE_LIST: */ - if( TYPEget_type( t ) == list_ ) { - strcat( retval, "__list" ); + if(TYPEget_type(t) == list_) { + strcat(retval, "__list"); } /* case TYPE_SET: */ - if( TYPEget_type( t ) == set_ ) { - strcat( retval, "__set" ); + if(TYPEget_type(t) == set_) { + strcat(retval, "__set"); } /* case TYPE_BAG: */ - if( TYPEget_type( t ) == bag_ ) { - strcat( retval, "__bag" ); + if(TYPEget_type(t) == bag_) { + strcat(retval, "__bag"); } return retval; } /* the rest is for things that are not aggregates */ - class = TYPEget_type( t ); + class = TYPEget_type(t); /* case TYPE_LOGICAL: */ - if( class == logical_ ) { - return ( "Logical" ); + if(class == logical_) { + return ("Logical"); } /* case TYPE_BOOLEAN: */ - if( class == boolean_ ) { - return ( "Boolean" ); + if(class == boolean_) { + return ("Boolean"); } /* case TYPE_INTEGER: */ - if( class == integer_ ) { - return ( "SDAI_Integer" ); + if(class == integer_) { + return ("SDAI_Integer"); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if( ( class == number_ ) || ( class == real_ ) ) { - return ( "SDAI_Real" ); + if((class == number_) || (class == real_)) { + return ("SDAI_Real"); } /* case TYPE_STRING: */ - if( class == string_ ) { - return ( "char *" ); + if(class == string_) { + return ("char *"); } /* case TYPE_BINARY: */ - if( class == binary_ ) { - return ( AccessType( t ) ); + if(class == binary_) { + return (AccessType(t)); } /* case TYPE_ENTITY: */ - if( class == entity_ ) { + if(class == entity_) { /* better do this because the return type might go away */ - strcpy( retval, IdlEntityTypeName( t ) ); - strcat( retval, "_ptr" ); + strcpy(retval, IdlEntityTypeName(t)); + strcat(retval, "_ptr"); return retval; } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if( class == enumeration_ ) { - strncpy( retval, EnumName( TYPEget_name( t ) ), BUFSIZ - 2 ); + if(class == enumeration_) { + strncpy(retval, EnumName(TYPEget_name(t)), BUFSIZ - 2); - strcat( retval, " /*" ); - strcat( retval, IdlEntityTypeName( t ) ); - strcat( retval, "*/ " ); + strcat(retval, " /*"); + strcat(retval, IdlEntityTypeName(t)); + strcat(retval, "*/ "); return retval; } - if( class == select_ ) { - return ( IdlEntityTypeName( t ) ); + if(class == select_) { + return (IdlEntityTypeName(t)); } /* default returns undefined */ - return ( "SCLundefined" ); + return ("SCLundefined"); } /**************************************************************//** @@ -1199,11 +1226,12 @@ const char * TYPEget_idl_type( const Type t ) { ** Side Effects: ** Status: new 1/24/91 ******************************************************************/ -char * TYPEget_express_type( const Type t ) { +char *TYPEget_express_type(const Type t) +{ Class_Of_Type class; Type bt; char retval [BUFSIZ]; - char * n, * permval, * aggr_type; + char *n, * permval, * aggr_type; /* 1. "DEFINED" types */ @@ -1211,38 +1239,38 @@ char * TYPEget_express_type( const Type t ) { /* case TYPE_ENTITY: */ /* case TYPE_SELECT: */ - n = TYPEget_name( t ); - if( n ) { - PrettyTmpName( n ); + n = TYPEget_name(t); + if(n) { + PrettyTmpName(n); } /* 2. "BASE" types */ - class = TYPEget_type( t ); + class = TYPEget_type(t); /* case TYPE_LOGICAL: */ - if( ( class == boolean_ ) || ( class == logical_ ) ) { - return ( "Logical" ); + if((class == boolean_) || (class == logical_)) { + return ("Logical"); } /* case TYPE_INTEGER: */ - if( class == integer_ ) { - return ( "Integer " ); + if(class == integer_) { + return ("Integer "); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if( ( class == number_ ) || ( class == real_ ) ) { - return ( "Real " ); + if((class == number_) || (class == real_)) { + return ("Real "); } /* case TYPE_STRING: */ - if( class == string_ ) { - return ( "String " ) ; + if(class == string_) { + return ("String ") ; } /* case TYPE_BINARY: */ - if( class == binary_ ) { - return ( "Binary " ) ; + if(class == binary_) { + return ("Binary ") ; } /* AGGREGATES @@ -1251,70 +1279,71 @@ char * TYPEget_express_type( const Type t ) { case TYPE_LIST: case TYPE_SET: */ - if( isAggregateType( t ) ) { - bt = TYPEget_nonaggregate_base_type( t ); - class = TYPEget_type( bt ); + if(isAggregateType(t)) { + bt = TYPEget_nonaggregate_base_type(t); + class = TYPEget_type(bt); /* case TYPE_ARRAY: */ - if( TYPEget_type( t ) == array_ ) { + if(TYPEget_type(t) == array_) { aggr_type = "Array"; } /* case TYPE_LIST: */ - if( TYPEget_type( t ) == list_ ) { + if(TYPEget_type(t) == list_) { aggr_type = "List"; } /* case TYPE_SET: */ - if( TYPEget_type( t ) == set_ ) { + if(TYPEget_type(t) == set_) { aggr_type = "Set"; } /* case TYPE_BAG: */ - if( TYPEget_type( t ) == bag_ ) { + if(TYPEget_type(t) == bag_) { aggr_type = "Bag"; } - sprintf( retval, "%s of %s", - aggr_type, TYPEget_express_type( bt ) ); + sprintf(retval, "%s of %s", + aggr_type, TYPEget_express_type(bt)); /* this will declare extra memory when aggregate is > 1D */ - permval = ( char * )sc_malloc( strlen( retval ) * sizeof( char ) + 1 ); - strcpy( permval, retval ); + permval = (char *)sc_malloc(strlen(retval) * sizeof(char) + 1); + strcpy(permval, retval); return permval; } /* default returns undefined */ - fprintf( stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name( t ) ); - return ( "SCLundefined" ); + fprintf(stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name(t)); + return ("SCLundefined"); } /** Initialize an upper or lower bound for an aggregate. \sa AGGRprint_init */ -void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const char * aggr_name, const char * cname, Expression bound, int boundNr ) { - if( bound->symbol.resolved ) { - if( bound->type == Type_Funcall ) { - fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string( bound ) ); +void AGGRprint_bound(FILE *header, FILE *impl, const char *var_name, const char *aggr_name, const char *cname, Expression bound, int boundNr) +{ + if(bound->symbol.resolved) { + if(bound->type == Type_Funcall) { + fprintf(impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string(bound)); } else { - fprintf( impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer ); + fprintf(impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer); } } else { /* resolved == 0 seems to mean that this is Type_Runtime */ - assert( cname && ( bound->e.op2 ) && ( bound->e.op2->symbol.name ) ); - fprintf( impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name ); - fprintf( header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name ); - fprintf( header, " %s * ths = (%s *) this_ptr;\n", cname, cname ); - fprintf( header, " ths->ResetAttributes();\n" ); - fprintf( header, " STEPattribute * a = ths->NextAttribute();\n" ); - fprintf( header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name ); - fprintf( header, " a = ths->NextAttribute();\n" ); - fprintf( header, " if( !a ) {\n" ); - fprintf( header, " break;\n" ); - fprintf( header, " }\n" ); - fprintf( header, " }\n" ); - fprintf( header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str( __FILE__ ), - __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com." ); - fprintf( header, " return *( a->Integer() );\n" ); /* always an integer? if not, would need to translate somehow due to return type... */ - fprintf( header, "}\n" ); + assert(cname && (bound->e.op2) && (bound->e.op2->symbol.name)); + fprintf(impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name); + fprintf(header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name); + fprintf(header, " %s * ths = (%s *) this_ptr;\n", cname, cname); + fprintf(header, " ths->ResetAttributes();\n"); + fprintf(header, " STEPattribute * a = ths->NextAttribute();\n"); + fprintf(header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name); + fprintf(header, " a = ths->NextAttribute();\n"); + fprintf(header, " if( !a ) {\n"); + fprintf(header, " break;\n"); + fprintf(header, " }\n"); + fprintf(header, " }\n"); + fprintf(header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str(__FILE__), + __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com."); + fprintf(header, " return *( a->Integer() );\n"); /* always an integer? if not, would need to translate somehow due to return type... */ + fprintf(header, "}\n"); } } @@ -1329,28 +1358,29 @@ void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const c * \param t the Type * \param var_name the name of the C++ variable, such as t_1 or schema::t_name */ -void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ) { - if( !header ) { - fprintf( stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name ); +void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name) +{ + if(!header) { + fprintf(stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name); abort(); } - if( !TYPEget_head( t ) ) { - const char * cname = 0; - if( ( t->superscope ) && ( t->superscope->symbol.name ) ) { - cname = ClassName( t->superscope->symbol.name ); + if(!TYPEget_head(t)) { + const char *cname = 0; + if((t->superscope) && (t->superscope->symbol.name)) { + cname = ClassName(t->superscope->symbol.name); } - if( TYPEget_body( t )->lower ) { - AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->lower, 1 ); + if(TYPEget_body(t)->lower) { + AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->lower, 1); } - if( TYPEget_body( t )->upper ) { - AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->upper, 2 ); + if(TYPEget_body(t)->upper) { + AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->upper, 2); } - if( TYPEget_body( t )->flags.unique ) { - fprintf( impl, " %s->UniqueElements(LTrue);\n", var_name ); + if(TYPEget_body(t)->flags.unique) { + fprintf(impl, " %s->UniqueElements(LTrue);\n", var_name); } - if( TYPEget_body( t )->flags.optional ) { - fprintf( impl, " %s->OptionalElements(LTrue);\n", var_name ); + if(TYPEget_body(t)->flags.optional) { + fprintf(impl, " %s->OptionalElements(LTrue);\n", var_name); } } } diff --git a/src/exp2cxx/classes_type.h b/src/exp2cxx/classes_type.h index a15815b07..ce178adc3 100644 --- a/src/exp2cxx/classes_type.h +++ b/src/exp2cxx/classes_type.h @@ -1,31 +1,31 @@ #ifndef CLASSES_TYPE_H #define CLASSES_TYPE_H -Type TYPEget_ancestor( Type ); +Type TYPEget_ancestor(Type); -const char * TypeName( Type t ); -const char * TypeDescriptorName( Type ); -char * TypeDescription( const Type t ); -const char * AccessType( Type t ); -const char * TYPEget_ctype( const Type t ); +const char *TypeName(Type t); +const char *TypeDescriptorName(Type); +char *TypeDescription(const Type t); +const char *AccessType(Type t); +const char *TYPEget_ctype(const Type t); -void TYPEPrint( const Type type, FILES *files, Schema schema ); -void TYPEprint_descriptions( const Type, FILES *, Schema ); -void TYPEprint_definition( Type, FILES *, Schema ); -void TYPEprint_typedefs( Type, FILE * ); -void TYPEprint_new( const Type type, FILE* create, Schema schema, bool needWR ); -void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ); +void TYPEPrint(const Type type, FILES *files, Schema schema); +void TYPEprint_descriptions(const Type, FILES *, Schema); +void TYPEprint_definition(Type, FILES *, Schema); +void TYPEprint_typedefs(Type, FILE *); +void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR); +void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema); -void TYPEenum_inc_print( const Type type, FILE * inc ); -void TYPEenum_lib_print( const Type type, FILE * f ); +void TYPEenum_inc_print(const Type type, FILE *inc); +void TYPEenum_lib_print(const Type type, FILE *f); -void TYPEselect_print( Type, FILES *, Schema ); -void TYPEselect_init_print( const Type type, FILE* f ); -void TYPEselect_inc_print( const Type type, FILE * f ); -void TYPEselect_lib_print( const Type type, FILE * f ); +void TYPEselect_print(Type, FILES *, Schema); +void TYPEselect_init_print(const Type type, FILE *f); +void TYPEselect_inc_print(const Type type, FILE *f); +void TYPEselect_lib_print(const Type type, FILE *f); -void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ); +void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name); -void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ); +void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name); #endif diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 517fa8a89..4d1381d9a 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -31,18 +31,20 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. ** **/ -void use_ref( Schema, Express, FILES * ); +void use_ref(Schema, Express, FILES *); -void create_builtin_type_decl( FILES * files, char * name ) { - fprintf( files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", - "SCHEMA", TD_PREFIX, name ); +void create_builtin_type_decl(FILES *files, char *name) +{ + fprintf(files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", + "SCHEMA", TD_PREFIX, name); } -void create_builtin_type_defn( FILES * files, char * name ) { - fprintf( files->initall, " %s%s_TYPE = new TypeDescriptor (", - TD_PREFIX, name ); - fprintf( files->initall, "\"%s\", %s_TYPE, \"%s\");\n", - PrettyTmpName( name ), StrToUpper( name ), StrToLower( name ) ); +void create_builtin_type_defn(FILES *files, char *name) +{ + fprintf(files->initall, " %s%s_TYPE = new TypeDescriptor (", + TD_PREFIX, name); + fprintf(files->initall, "\"%s\", %s_TYPE, \"%s\");\n", + PrettyTmpName(name), StrToUpper(name), StrToLower(name)); } /** **************************************************************** @@ -55,65 +57,66 @@ void create_builtin_type_defn( FILES * files, char * name ) { ** In this case the file schema.h is initiated ** Status: ok 1/15/91 ******************************************************************/ -void print_file_header( FILES * files ) { +void print_file_header(FILES *files) +{ /* open file which unifies all schema specific header files of input Express source */ - files -> incall = FILEcreate( "schema.h" ); - fprintf( files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n" ); - - fprintf( files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n" ); - fprintf( files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n" ); - fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n" ); - fprintf( files->incall, "# else\n" ); - fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n" ); - fprintf( files->incall, "# endif\n" ); - fprintf( files->incall, "#else\n" ); - fprintf( files->incall, "# define SC_SCHEMA_EXPORT\n" ); - fprintf( files->incall, "#endif\n\n" ); - - fprintf( files->incall, "#ifdef SC_LOGGING\n" ); - fprintf( files->incall, "#include \n" ); - fprintf( files->incall, "#endif\n" ); - - fprintf( files->incall, "#include \n\n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); - - fprintf( files->incall, "\n#include \n" ); - - fprintf( files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA" ); - fprintf( files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA" ); - - files -> initall = FILEcreate( "schema.cc" ); - fprintf( files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n" ); - fprintf( files->initall, "#include \"schema.h\"\n" ); - fprintf( files->initall, "#include \"sc_memmgr.h\"\n" ); - fprintf( files->initall, "class Registry;\n" ); - - fprintf( files->initall, "\nvoid SchemaInit (Registry & reg) {\n" ); - fprintf( files->initall, " extern void InitSchemasAndEnts " ); - fprintf( files->initall, "(Registry & r);\n" ); - fprintf( files->initall, " InitSchemasAndEnts (reg);\n" ); + files -> incall = FILEcreate("schema.h"); + fprintf(files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n"); + + fprintf(files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n"); + fprintf(files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n"); + fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n"); + fprintf(files->incall, "# else\n"); + fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n"); + fprintf(files->incall, "# endif\n"); + fprintf(files->incall, "#else\n"); + fprintf(files->incall, "# define SC_SCHEMA_EXPORT\n"); + fprintf(files->incall, "#endif\n\n"); + + fprintf(files->incall, "#ifdef SC_LOGGING\n"); + fprintf(files->incall, "#include \n"); + fprintf(files->incall, "#endif\n"); + + fprintf(files->incall, "#include \n\n"); + fprintf(files->incall, "\n#include \n"); + fprintf(files->incall, "\n#include \n"); + fprintf(files->incall, "\n#include \n"); + fprintf(files->incall, "\n#include \n"); + fprintf(files->incall, "\n#include \n"); + + fprintf(files->incall, "\n#include \n"); + + fprintf(files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA"); + fprintf(files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA"); + + files -> initall = FILEcreate("schema.cc"); + fprintf(files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n"); + fprintf(files->initall, "#include \"schema.h\"\n"); + fprintf(files->initall, "#include \"sc_memmgr.h\"\n"); + fprintf(files->initall, "class Registry;\n"); + + fprintf(files->initall, "\nvoid SchemaInit (Registry & reg) {\n"); + fprintf(files->initall, " extern void InitSchemasAndEnts "); + fprintf(files->initall, "(Registry & r);\n"); + fprintf(files->initall, " InitSchemasAndEnts (reg);\n"); // This file will contain instantiation statements for all the schemas and // entities in the express file. (They must all be in separate function // called first by SchemaInit() so that all entities will exist - files -> create = FILEcreate( "SdaiAll.cc" ); - fprintf( files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n" ); - fprintf( files->create, "#include \"schema.h\"\n" ); - fprintf( files->create, "#include \"sc_memmgr.h\"\n" ); - fprintf( files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n" ); + files -> create = FILEcreate("SdaiAll.cc"); + fprintf(files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n"); + fprintf(files->create, "#include \"schema.h\"\n"); + fprintf(files->create, "#include \"sc_memmgr.h\"\n"); + fprintf(files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n"); // This file declares all entity classes as incomplete types. This will // allow all the .h files to reference all .h's. We can then have e.g., // entX from schemaA have attribute attr1 = entY from schemaB. - files -> classes = FILEcreate( "Sdaiclasses.h" ); - fprintf( files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n" ); - fprintf( files->classes, "#include \"schema.h\"\n" ); + files -> classes = FILEcreate("Sdaiclasses.h"); + fprintf(files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n"); + fprintf(files->classes, "#include \"schema.h\"\n"); } /** **************************************************************** @@ -124,28 +127,32 @@ void print_file_header( FILES * files ) { ** Description: handles cleaning up things at end of processing ** Status: ok 1/15/91 ******************************************************************/ -void print_file_trailer( FILES * files ) { - FILEclose( files->incall ); - FILEclose( files->initall ); - fprintf( files->create, "}\n\n" ); - FILEclose( files->create ); - fprintf( files->classes, "\n" ); - FILEclose( files->classes ); - fprintf( files->names, "\n}\n" ); - FILEclose( files->names ); +void print_file_trailer(FILES *files) +{ + FILEclose(files->incall); + FILEclose(files->initall); + fprintf(files->create, "}\n\n"); + FILEclose(files->create); + fprintf(files->classes, "\n"); + FILEclose(files->classes); + fprintf(files->names, "\n}\n"); + FILEclose(files->names); } /* set attribute index to simplify attrdescriptor name calculation * and reduce/eliminate use of global attr_count */ -void numberAttributes( Scope scope ) { +void numberAttributes(Scope scope) +{ int count = 0; - Linked_List list = SCOPEget_entities_superclass_order( scope ); - LISTdo( list, e, Entity ) { - LISTdo_n( ENTITYget_attributes( e ), v, Variable, b ) { + Linked_List list = SCOPEget_entities_superclass_order(scope); + LISTdo(list, e, Entity) { + LISTdo_n(ENTITYget_attributes(e), v, Variable, b) { v->idx = count++; - } LISTod - } LISTod + } + LISTod + } + LISTod } /****************************************************************** @@ -163,13 +170,14 @@ void numberAttributes( Scope scope ) { ** and what the relationship is between this organization and the ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint( Scope scope, FILES * files, Schema schema, ComplexCollect * col, int cnt ) { - Linked_List list = SCOPEget_entities_superclass_order( scope ); +void SCOPEPrint(Scope scope, FILES *files, Schema schema, ComplexCollect *col, int cnt) +{ + Linked_List list = SCOPEget_entities_superclass_order(scope); DictionaryEntry de; Type i; int redefs = 0; - if( cnt <= 1 ) { + if(cnt <= 1) { /* This will be the case if this is the first time we are generating a ** file for this schema. (cnt = the file suffix. If it = 1, it's the ** first of multiple; if it = 0, it's the only one.) Basically, this @@ -177,198 +185,209 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema, ComplexCollect * col ** during multiple passes. This includes Sdaiclasses.h, SdaiAll.cc, ** and the Sdaixxx.init.cc files. */ - fprintf( files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name( schema ) ); + fprintf(files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name(schema)); /* Do \'new\'s for types descriptors (in SdaiAll.cc (files->create)), and the externs typedefs, and incomplete descriptors (in Sdai- classes.h (files->classes)). */ - fprintf( files->create, "\n // ***** Initialize the Types\n" ); - fprintf( files->classes, "\n// Types:\n" ); - SCOPEdo_types( scope, t, de ) { + fprintf(files->create, "\n // ***** Initialize the Types\n"); + fprintf(files->classes, "\n// Types:\n"); + SCOPEdo_types(scope, t, de) { //TYPEprint_new moved to TYPEPrint_cc and TYPEprint_descriptions in classes_type.c - TYPEprint_typedefs( t, files->classes ); + TYPEprint_typedefs(t, files->classes); //print in namespace. Some logic copied from TypeDescriptorName() - fprintf( files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName( t ), TYPEprefix( t ), TYPEget_name( t ) ); - } SCOPEod + fprintf(files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName(t), TYPEprefix(t), TYPEget_name(t)); + } + SCOPEod - fprintf( files->classes, "\n// Entity class typedefs:" ); - LISTdo( list, e, Entity ) { - ENTITYprint_classes( e, files->classes ); - } LISTod + fprintf(files->classes, "\n// Entity class typedefs:"); + LISTdo(list, e, Entity) { + ENTITYprint_classes(e, files->classes); + } + LISTod } /* fill in the values for the type descriptors and print the enumerations */ - fprintf( files -> inc, "\n/* ************** TYPES */\n" ); - fprintf( files -> lib, "\n/* ************** TYPES */\n" ); + fprintf(files -> inc, "\n/* ************** TYPES */\n"); + fprintf(files -> lib, "\n/* ************** TYPES */\n"); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - if( scope->enum_table ) { - HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); + if(scope->enum_table) { + HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); Type t; - while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { + while(0 != (t = (Type) DICTdo(&de))) { // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if( ( t->search_id == CANPROCESS ) - && ( TYPEis_enumeration( t ) ) - && ( ( i = TYPEget_ancestor( t ) ) != NULL ) - && ( i->search_id >= CANPROCESS ) ) { + if((t->search_id == CANPROCESS) + && (TYPEis_enumeration(t)) + && ((i = TYPEget_ancestor(t)) != NULL) + && (i->search_id >= CANPROCESS)) { redefs = 1; } } } - SCOPEdo_types( scope, t, de ) { + SCOPEdo_types(scope, t, de) { /* NOTE the following comment seems to contradict the logic below it (... && !( TYPEis_enumeration( t ) && ...) // Do the non-redefined enumerations:*/ - if( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { - TYPEprint_descriptions( t, files, schema ); - if( !TYPEis_select( t ) ) { + if((t->search_id == CANPROCESS) + && !(TYPEis_enumeration(t) && TYPEget_head(t))) { + TYPEprint_descriptions(t, files, schema); + if(!TYPEis_select(t)) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } } - } SCOPEod + } + SCOPEod - if( redefs ) { + if(redefs) { // Here we process redefined enumerations. See note, 2 loops ago. - fprintf( files->inc, "// ***** Redefined Enumerations:\n" ); + fprintf(files->inc, "// ***** Redefined Enumerations:\n"); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); + HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); Type t; - while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { - if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { - TYPEprint_descriptions( t, files, schema ); + while(0 != (t = (Type) DICTdo(&de))) { + if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { + TYPEprint_descriptions(t, files, schema); t->search_id = PROCESSED; } } } /* do the select definitions next, since they depend on the others */ - fprintf( files->inc, "\n// ***** Build the SELECT Types \n" ); + fprintf(files->inc, "\n// ***** Build the SELECT Types \n"); // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types( scope, t, de ) { - if( t->search_id == CANPROCESS ) { + SCOPEdo_types(scope, t, de) { + if(t->search_id == CANPROCESS) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. - if( TYPEis_select( t ) ) { - TYPEselect_print( t, files, schema ); + if(TYPEis_select(t)) { + TYPEselect_print(t, files, schema); } - if( TYPEis_enumeration( t ) ) { - TYPEprint_descriptions( t, files, schema ); + if(TYPEis_enumeration(t)) { + TYPEprint_descriptions(t, files, schema); } t->search_id = PROCESSED; } - } SCOPEod + } + SCOPEod - fprintf( files -> inc, "\n/* ************** ENTITIES */\n" ); - fprintf( files -> lib, "\n/* ************** ENTITIES */\n" ); + fprintf(files -> inc, "\n/* ************** ENTITIES */\n"); + fprintf(files -> lib, "\n/* ************** ENTITIES */\n"); - fprintf( files->inc, "\n// ***** Print Entity Classes \n" ); - LISTdo( list, e, Entity ) { - if( e->search_id == CANPROCESS ) { - ENTITYPrint( e, files, schema, col->externMapping( ENTITYget_name( e ) ) ); + fprintf(files->inc, "\n// ***** Print Entity Classes \n"); + LISTdo(list, e, Entity) { + if(e->search_id == CANPROCESS) { + ENTITYPrint(e, files, schema, col->externMapping(ENTITYget_name(e))); e->search_id = PROCESSED; } - } LISTod + } + LISTod - if( cnt <= 1 ) { + if(cnt <= 1) { int index = 0; // Do the model stuff: - fprintf( files->inc, "\n// ***** generate Model related pieces\n" ); - fprintf( files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name( schema ) ); - fprintf( files -> inc, "\n public:\n" ); - fprintf( files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); - LISTdo( list, e, Entity ) { - MODELprint_new( e, files ); - } LISTod - - fprintf( files->inc, "\n};\n\n" ); - - fprintf( files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf( files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf( files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf( files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); - - fprintf( files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ) ); - fprintf( files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name( schema ) ); - - fprintf( files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf( files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n" ); - LISTdo( list, e, Entity ) { - MODELPrintConstructorBody( e, files, schema ); - } LISTod - fprintf( files -> lib, "}\n" ); + fprintf(files->inc, "\n// ***** generate Model related pieces\n"); + fprintf(files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name(schema)); + fprintf(files -> inc, "\n public:\n"); + fprintf(files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); + LISTdo(list, e, Entity) { + MODELprint_new(e, files); + } + LISTod + + fprintf(files->inc, "\n};\n\n"); + + fprintf(files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf(files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf(files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf(files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); + + fprintf(files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name(schema)); + fprintf(files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name(schema)); + + fprintf(files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf(files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n"); + LISTdo(list, e, Entity) { + MODELPrintConstructorBody(e, files, schema); + } + LISTod + fprintf(files -> lib, "}\n"); index = 0; - LISTdo( list, e, Entity ) { - MODELPrint( e, files, schema, index ); + LISTdo(list, e, Entity) { + MODELPrint(e, files, schema, index); index++; - } LISTod + } + LISTod } - LISTfree( list ); + LISTfree(list); } /** open/init unity files which allow faster compilation with fewer translation units */ -void initUnityFiles( const char * schName, FILES * files ) { - const char * unity = "\n/** this file is for unity builds, which allow faster compilation\n" - " * with fewer translation units. not compatible with all compilers!\n */\n\n" - "#include \"schema.h\"\n"; +void initUnityFiles(const char *schName, FILES *files) +{ + const char *unity = "\n/** this file is for unity builds, which allow faster compilation\n" + " * with fewer translation units. not compatible with all compilers!\n */\n\n" + "#include \"schema.h\"\n"; std::string name = schName; - name.append( "_unity_" ); + name.append("_unity_"); size_t prefixLen = name.length(); - name.append( "entities.cc" ); - files->unity.entity.impl = FILEcreate( name.c_str() ); + name.append("entities.cc"); + files->unity.entity.impl = FILEcreate(name.c_str()); - name.resize( name.length() - 2 ); - name.append( "h" ); - fprintf( files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str() ); + name.resize(name.length() - 2); + name.append("h"); + fprintf(files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str()); - files->unity.entity.hdr = FILEcreate( name.c_str() ); - fprintf( files->unity.entity.hdr, "%s\n", unity ); + files->unity.entity.hdr = FILEcreate(name.c_str()); + fprintf(files->unity.entity.hdr, "%s\n", unity); - name.resize( prefixLen ); - name.append( "types.cc" ); - files->unity.type.impl = FILEcreate( name.c_str() ); + name.resize(prefixLen); + name.append("types.cc"); + files->unity.type.impl = FILEcreate(name.c_str()); - name.resize( name.length() - 2 ); - name.append( "h" ); - fprintf( files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str() ); + name.resize(name.length() - 2); + name.append("h"); + fprintf(files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str()); - files->unity.type.hdr = FILEcreate( name.c_str() ); - fprintf( files->unity.type.hdr, "%s\n", unity ); + files->unity.type.hdr = FILEcreate(name.c_str()); + fprintf(files->unity.type.hdr, "%s\n", unity); } /** close unity files * \sa initUnityFiles() */ -void closeUnityFiles( FILES * files ) { - FILEclose( files->unity.type.hdr ); - FILEclose( files->unity.type.impl ); - FILEclose( files->unity.entity.hdr ); - FILEclose( files->unity.entity.impl ); +void closeUnityFiles(FILES *files) +{ + FILEclose(files->unity.type.hdr); + FILEclose(files->unity.type.impl); + FILEclose(files->unity.entity.hdr); + FILEclose(files->unity.entity.impl); } ///write tail of initfile, close it -void INITFileFinish( FILE * initfile, Schema schema ) { - fprintf( initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); - fprintf( initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name( schema ) ); - fprintf( initfile, " EntityDescriptor * ed;\n"); - fprintf( initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name( schema ) ); - fprintf( initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); - fprintf( initfile, " ed->InitIAttrs( reg, nm );\n"); - fprintf( initfile, " }\n}\n" ); - FILEclose( initfile ); +void INITFileFinish(FILE *initfile, Schema schema) +{ + fprintf(initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); + fprintf(initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name(schema)); + fprintf(initfile, " EntityDescriptor * ed;\n"); + fprintf(initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name(schema)); + fprintf(initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); + fprintf(initfile, " ed->InitIAttrs( reg, nm );\n"); + fprintf(initfile, " }\n}\n"); + FILEclose(initfile); } /** **************************************************************** @@ -384,15 +403,16 @@ void INITFileFinish( FILE * initfile, Schema schema ) { ** Side Effects: ** Status: ******************************************************************/ -void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) { +void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) +{ char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE * libfile, + FILE *libfile, * incfile, * schemafile = files->incall, - * schemainit = files->initall, - * initfile, - * createall = files->create; + * schemainit = files->initall, + * initfile, + * createall = files->create; Rule r; Function f; Procedure p; @@ -400,160 +420,160 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf( schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper( SCHEMAget_name( schema ) ) ); //TODO change file names to CamelCase? - if( suffix == 0 ) { - sprintf( sufnm, "%s", schnm ); + sprintf(schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper(SCHEMAget_name(schema))); //TODO change file names to CamelCase? + if(suffix == 0) { + sprintf(sufnm, "%s", schnm); } else { - sprintf( sufnm, "%s_%d", schnm, suffix ); + sprintf(sufnm, "%s_%d", schnm, suffix); } - sprintf( fnm, "%s.h", sufnm ); + sprintf(fnm, "%s.h", sufnm); - if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { + if(!(incfile = (files -> inc) = FILEcreate(fnm))) { return; } - fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); + fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); - fprintf( incfile, "#include \"schema.h\"\n" ); - fprintf( incfile, "#include \"sc_memmgr.h\"\n" ); + fprintf(incfile, "#include \"schema.h\"\n"); + fprintf(incfile, "#include \"sc_memmgr.h\"\n"); - np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ + np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ /* 1.9 open/init unity files which allow faster compilation with fewer translation units */ - initUnityFiles( sufnm, files ); + initUnityFiles(sufnm, files); /* 2. class source file */ - sprintf( np, "cc" ); - if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { + sprintf(np, "cc"); + if(!(libfile = (files -> lib) = FILEcreate(fnm))) { return; } - fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); + fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); //TODO: Looks like this switches between 'schema.h' and a non-generic name. What is that name, //and how do we fully enable this feature (i.e. how to write the file with different name)? #ifdef SCHEMA_HANDLING - sprintf( np, "h" ); - fprintf( libfile, "#include <%s.h> \n", sufnm ); + sprintf(np, "h"); + fprintf(libfile, "#include <%s.h> \n", sufnm); #else - fprintf( libfile, "#include \"schema.h\"\n" ); + fprintf(libfile, "#include \"schema.h\"\n"); #endif - fprintf( libfile, "#include \"sc_memmgr.h\"\n" ); + fprintf(libfile, "#include \"sc_memmgr.h\"\n"); - fprintf( libfile, - "\n#ifdef SC_LOGGING \n" - "#include \n" - " extern ofstream *logStream;\n" - "#define SCLLOGFILE \"scl.log\"\n" - "#endif \n" ); + fprintf(libfile, + "\n#ifdef SC_LOGGING \n" + "#include \n" + " extern ofstream *logStream;\n" + "#define SCLLOGFILE \"scl.log\"\n" + "#endif \n"); - fprintf( libfile, "\n#include \"%s.h\"\n", schnm ); + fprintf(libfile, "\n#include \"%s.h\"\n", schnm); // 3. header for namespace to contain all formerly-global variables - sprintf( fnm, "%sNames.h", schnm ); - if( !( files->names = FILEcreate( fnm ) ) ) { + sprintf(fnm, "%sNames.h", schnm); + if(!(files->names = FILEcreate(fnm))) { return; } - fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); - fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); - fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); - fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); - fprintf( files->names, " extern Schema * schema;\n\n" ); + fprintf(libfile, "#include \"%sNames.h\"\n", schnm); + fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); + fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); + fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); + fprintf(files->names, " extern Schema * schema;\n\n"); /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - if( suffix <= 1 ) { + if(suffix <= 1) { /* I.e., if this is our first pass with schema */ - sprintf( fnm, "%s.init.cc", schnm ); + sprintf(fnm, "%s.init.cc", schnm); /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ - if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { + if(!(initfile = (files -> init) = FILEcreate(fnm))) { return; } - fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); + fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); #ifdef SCHEMA_HANDLING - if( suffix == 0 ) { - fprintf( initfile, "#include <%s.h>\n", schnm ); + if(suffix == 0) { + fprintf(initfile, "#include <%s.h>\n", schnm); } else { - fprintf( initfile, "#include <%s_%d.h>\n", schnm, suffix ); + fprintf(initfile, "#include <%s_%d.h>\n", schnm, suffix); } #else - fprintf( initfile, - "#ifndef SCHEMA_H\n" - "#include \"schema.h\"\n" - "#endif\n" ); + fprintf(initfile, + "#ifndef SCHEMA_H\n" + "#include \"schema.h\"\n" + "#endif\n"); #endif - fprintf( initfile, "#include \n#include \n" ); - fprintf( initfile, "#include \n" ); + fprintf(initfile, "#include \n#include \n"); + fprintf(initfile, "#include \n"); - fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); + fprintf(initfile, "\nvoid %sInit (Registry& reg) {\n", schnm); - fprintf( createall, "// Schema: %s\n", schnm ); - fprintf( createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name( schema ), PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf(createall, "// Schema: %s\n", schnm); + fprintf(createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name(schema), PrettyTmpName(SCHEMAget_name(schema))); /* Add the SdaiModel_contents_ class constructor to the schema descriptor create function for it */ - fprintf( createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", - SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf(createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", + SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf( createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name( schema ) ); + fprintf(createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name(schema)); /**************/ /* add global RULEs to Schema dictionary entry */ - DICTdo_type_init( schema->symbol_table, &de, OBJ_RULE ); - while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { - fprintf( createall, " str.clear();\n" ); - format_for_std_stringout( createall, RULEto_string( r ) ); - fprintf( createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name( schema ) ); - fprintf( createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name( schema ) ); + DICTdo_type_init(schema->symbol_table, &de, OBJ_RULE); + while(0 != (r = (Rule)DICTdo(&de))) { + fprintf(createall, " str.clear();\n"); + format_for_std_stringout(createall, RULEto_string(r)); + fprintf(createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name(schema)); + fprintf(createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name(schema)); } /**************/ /* add FUNCTIONs to Schema dictionary entry */ - DICTdo_type_init( schema->symbol_table, &de, OBJ_FUNCTION ); - while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { - fprintf( createall, " str.clear();\n" ); - format_for_std_stringout( createall, FUNCto_string( f ) ); - fprintf( createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name( schema ) ); + DICTdo_type_init(schema->symbol_table, &de, OBJ_FUNCTION); + while(0 != (f = (Function)DICTdo(&de))) { + fprintf(createall, " str.clear();\n"); + format_for_std_stringout(createall, FUNCto_string(f)); + fprintf(createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name(schema)); } /* add PROCEDUREs to Schema dictionary entry */ - DICTdo_type_init( schema->symbol_table, &de, OBJ_PROCEDURE ); - while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { - fprintf( createall, " str.clear();\n" ); - format_for_std_stringout( createall, PROCto_string( p ) ); - fprintf( createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name( schema ) ); + DICTdo_type_init(schema->symbol_table, &de, OBJ_PROCEDURE); + while(0 != (p = (Procedure)DICTdo(&de))) { + fprintf(createall, " str.clear();\n"); + format_for_std_stringout(createall, PROCto_string(p)); + fprintf(createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name(schema)); } - fprintf( files->classes, "\n// Schema: %s", schnm ); - fprintf( files->classes, "\n#include \"%sNames.h\"\n", schnm ); + fprintf(files->classes, "\n// Schema: %s", schnm); + fprintf(files->classes, "\n#include \"%sNames.h\"\n", schnm); } else { /* Just reopen the .init.cc (in append mode): */ - sprintf( fnm, "%s.init.cc", schnm ); - initfile = files->init = fopen( fnm, "a" ); + sprintf(fnm, "%s.init.cc", schnm); + initfile = files->init = fopen(fnm, "a"); } /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); - fprintf( schemafile, "#include \"%s.h\" \n", sufnm ); - if( schema->search_id == PROCESSED ) { - fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); - fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); - fprintf( schemainit, " %sInit (reg); \n", schnm ); + fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); + fprintf(schemafile, "#include \"%s.h\" \n", sufnm); + if(schema->search_id == PROCESSED) { + fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); + fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); + fprintf(schemainit, " %sInit (reg); \n", schnm); } /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint( schema, files, schema, ( ComplexCollect * )complexCol, suffix ); + SCOPEPrint(schema, files, schema, (ComplexCollect *)complexCol, suffix); /********** close the files ***********/ - closeUnityFiles( files ); - FILEclose( libfile ); - FILEclose( incfile ); - if( schema->search_id == PROCESSED ) { - INITFileFinish( initfile, schema ); + closeUnityFiles(files); + FILEclose(libfile); + FILEclose(incfile); + if(schema->search_id == PROCESSED) { + INITFileFinish(initfile, schema); } else { - fclose( initfile ); + fclose(initfile); } } @@ -570,27 +590,28 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { +void getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) +{ DictionaryEntry de; Schema schema; - fprintf( schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n" ); - fprintf( schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__ ); - fprintf( schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n" ); - fprintf( schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n" ); - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - schema = ( Scope )DICTdo( &de ); - fprintf( schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); - fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - fprintf( schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); - fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); + fprintf(schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n"); + fprintf(schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__); + fprintf(schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n"); + fprintf(schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n"); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + schema = (Scope)DICTdo(&de); + fprintf(schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); + fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); + while((schema = (Scope)DICTdo(&de)) != 0) { + fprintf(schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); + fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); } - fprintf( schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n" ); + fprintf(schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n"); } /****************************************************************** @@ -605,14 +626,15 @@ void getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { +void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) +{ char fnm [MAX_LEN], *np; - const char * schnm; /* schnm is really "express name" */ - FILE * libfile; - FILE * incfile; - FILE * schemafile = files -> incall; - FILE * schemainit = files -> initall; - FILE * initfile; + const char *schnm; /* schnm is really "express name" */ + FILE *libfile; + FILE *incfile; + FILE *schemafile = files -> incall; + FILE *schemainit = files -> initall; + FILE *initfile; /* new */ Schema schema; DictionaryEntry de; @@ -621,81 +643,81 @@ void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); - if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { + sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); + if(!(incfile = (files -> inc) = FILEcreate(fnm))) { return; } - fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); + fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); - fprintf( incfile, "#include \n" ); + fprintf(incfile, "#include \n"); - np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ + np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ /* 1.9 init unity files (large translation units, faster compilation) */ - initUnityFiles( schnm, files ); + initUnityFiles(schnm, files); /* 2. class source file */ - sprintf( np, "cc" ); - if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { + sprintf(np, "cc"); + if(!(libfile = (files -> lib) = FILEcreate(fnm))) { return; } - fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); + fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); - fprintf( libfile, "#include \"%s.h\" n", schnm ); + fprintf(libfile, "#include \"%s.h\" n", schnm); // 3. header for namespace to contain all formerly-global variables - sprintf( fnm, "%sNames.h", schnm ); - if( !( files->names = FILEcreate( fnm ) ) ) { + sprintf(fnm, "%sNames.h", schnm); + if(!(files->names = FILEcreate(fnm))) { return; } - fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); - fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); - fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); + fprintf(libfile, "#include \"%sNames.h\"\n", schnm); + fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); + fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); //the next line in this file depends on the schema name, so printing continues in the while loop ~25 lines below /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - sprintf( np, "init.cc" ); - if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { + sprintf(np, "init.cc"); + if(!(initfile = (files -> init) = FILEcreate(fnm))) { return; } - fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); + fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); - fprintf( initfile, "#include \"%s.h\"\n\n", schnm ); - fprintf( initfile, "void \n%sInit (Registry& reg)\n{\n", schnm ); + fprintf(initfile, "#include \"%s.h\"\n\n", schnm); + fprintf(initfile, "void \n%sInit (Registry& reg)\n{\n", schnm); /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); - fprintf( schemafile, "#include \"%s.h\"\n\n", schnm ); - fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); - fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); - fprintf( schemainit, " %sInit (reg);\n", schnm ); + fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); + fprintf(schemafile, "#include \"%s.h\"\n\n", schnm); + fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); + fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); + fprintf(schemainit, " %sInit (reg);\n", schnm); /********** do all schemas ***********/ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - numberAttributes( schema ); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + numberAttributes(schema); } - DICTdo_init( express->symbol_table, &de ); + DICTdo_init(express->symbol_table, &de); bool first = true; - while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { - if( !first ) { - fprintf( files->names, "} //namespace %s\n", SCHEMAget_name( schema ) ); + while(0 != (schema = (Scope)DICTdo(&de))) { + if(!first) { + fprintf(files->names, "} //namespace %s\n", SCHEMAget_name(schema)); } first = false; - fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); - fprintf( files->names, " extern Schema * schema;\n\n" ); + fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); + fprintf(files->names, " extern Schema * schema;\n\n"); - SCOPEPrint( schema, files, schema, &col, 0 ); + SCOPEPrint(schema, files, schema, &col, 0); } /********** close the files ***********/ - closeUnityFiles( files ); - FILEclose( libfile ); - FILEclose( incfile ); - INITFileFinish( initfile, schema ); + closeUnityFiles(files); + FILEclose(libfile); + FILEclose(incfile); + INITFileFinish(initfile, schema); } /** @@ -704,28 +726,30 @@ void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { * Side Effects: generates code * Status: 24-Feb-1992 new -kcm */ -void print_schemas_combined( Express express, ComplexCollect & col, FILES * files ) { - EXPRESSPrint( express, col, files ); +void print_schemas_combined(Express express, ComplexCollect &col, FILES *files) +{ + EXPRESSPrint(express, col, files); } /** this function calls one of two different functions * depending on whether the output should be combined into a single * set of files or a separate set for each schema */ -void print_file( Express express ) { - extern void RESOLUTIONsucceed( void ); +void print_file(Express express) +{ + extern void RESOLUTIONsucceed(void); int separate_schemas = 1; - ComplexCollect col( express ); + ComplexCollect col(express); File_holder files; resolution_success(); - print_file_header( &files ); - if( separate_schemas ) { - print_schemas_separate( express, &col, &files ); + print_file_header(&files); + if(separate_schemas) { + print_schemas_separate(express, &col, &files); } else { - print_schemas_combined( express, col, &files ); + print_schemas_combined(express, col, &files); } - print_file_trailer( &files ); - print_complex( col, "compstructs.cc" ); + print_file_trailer(&files); + print_complex(col, "compstructs.cc"); } diff --git a/src/exp2cxx/collect.cc b/src/exp2cxx/collect.cc index d12db7346..62a271498 100644 --- a/src/exp2cxx/collect.cc +++ b/src/exp2cxx/collect.cc @@ -14,19 +14,19 @@ #include "complexSupport.h" #include -void ComplexCollect::insert( ComplexList * c ) +void ComplexCollect::insert(ComplexList *c) /* * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ { - ComplexList * prev = NULL, *cl = clists; + ComplexList *prev = NULL, *cl = clists; - while( cl && *cl < *c ) { + while(cl && *cl < *c) { prev = cl; cl = cl->next; } - if( prev == NULL ) { + if(prev == NULL) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -39,7 +39,7 @@ void ComplexCollect::insert( ComplexList * c ) count++; } -void ComplexCollect::remove( ComplexList * c ) +void ComplexCollect::remove(ComplexList *c) /* * Removes the ComplexList whose supertype name = supername. "Removing" * deletes the list and removes it from this, but does not delete its @@ -49,17 +49,17 @@ void ComplexCollect::remove( ComplexList * c ) * remove it from the Collect. */ { - ComplexList * cl = clists, *prev = NULL; + ComplexList *cl = clists, *prev = NULL; - while( cl && *cl < *c ) { + while(cl && *cl < *c) { prev = cl; cl = cl->next; } - if( cl == NULL || cl != c ) { + if(cl == NULL || cl != c) { // Just in case c isn't in the list. return; } - if( prev == NULL ) { + if(prev == NULL) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -70,23 +70,23 @@ void ComplexCollect::remove( ComplexList * c ) count--; } -ComplexList * ComplexCollect::find( char * name ) +ComplexList *ComplexCollect::find(char *name) /* * Searches for and returns the ComplexList whose supertype name = name. */ { - ComplexList * cl = clists; + ComplexList *cl = clists; - while( cl && *cl < name ) { + while(cl && *cl < name) { cl = cl->next; } - if( cl && *cl == name ) { + if(cl && *cl == name) { return cl; } return NULL; } -int ComplexCollect::supports( EntNode * ents ) +int ComplexCollect::supports(EntNode *ents) /* * Determines if the parent schema supports the instantiation of a complex * type consisting of the entities named in ents. Does so by attempting @@ -96,36 +96,36 @@ int ComplexCollect::supports( EntNode * ents ) * to match it, as described in the commenting. */ { - EntNode * node = ents, *nextnode; - AndList * alist = 0; - ComplexList * clist = clists, *cl = NULL, *current; + EntNode *node = ents, *nextnode; + AndList *alist = 0; + ComplexList *clist = clists, *cl = NULL, *current; int retval; - EntList * elist, *next; + EntList *elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while( node ) { - if( node->multSuprs() ) { + while(node) { + if(node->multSuprs()) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if( !cl ) { + if(!cl) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList( alist ); + cl = new ComplexList(alist); } current = clists; - while( current ) { - if( current->contains( node ) ) { + while(current) { + if(current->contains(node)) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if( ! cl->toplevel( current->supertype() ) ) { + if(! cl->toplevel(current->supertype())) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList( current->head->childList ); + alist->appendList(current->head->childList); } } current = current->next; @@ -137,11 +137,11 @@ int ComplexCollect::supports( EntNode * ents ) // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if( !cl ) { + if(!cl) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while( clist != NULL ) { - if( clist->matches( ents ) ) { + while(clist != NULL) { + if(clist->matches(ents)) { return TRUE; } clist = clist->next; @@ -152,13 +152,13 @@ int ComplexCollect::supports( EntNode * ents ) // Use cl to test that the conditions of all supertypes are met: cl->multSupers = TRUE; cl->buildList(); - retval = cl->matches( ents ); + retval = cl->matches(ents); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while( elist ) { + while(elist) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/exp2cxx/complexSupport.h b/src/exp2cxx/complexSupport.h index 8277a03fa..9055d92f8 100644 --- a/src/exp2cxx/complexSupport.h +++ b/src/exp2cxx/complexSupport.h @@ -63,7 +63,8 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode { +class EntNode +{ friend class SimpleList; friend class AndOrList; friend class AndList; @@ -71,48 +72,59 @@ class EntNode { friend class ComplexList; public: - EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), - multSupers( 0 ) { - strcpy( name, nm ); - } - EntNode( char *[] ); // given a list, create a linked list of EntNodes - ~EntNode() { - if( next ) { + EntNode(const char *nm = "") : next(0), mark(NOMARK), + multSupers(0) + { + strcpy(name, nm); + } + EntNode(char *[]); // given a list, create a linked list of EntNodes + ~EntNode() + { + if(next) { delete next; } } - operator const char * () { + operator const char *() + { return name; } - int operator== ( EntNode & ent ) { - return ( strcmp( name, ent.name ) == 0 ); + int operator== (EntNode &ent) + { + return (strcmp(name, ent.name) == 0); } - int operator< ( EntNode & ent ) { - return ( strcmp( name, ent.name ) < 0 ); + int operator< (EntNode &ent) + { + return (strcmp(name, ent.name) < 0); } - int operator> ( EntNode & ent ) { - return ( strcmp( name, ent.name ) > 0 ); + int operator> (EntNode &ent) + { + return (strcmp(name, ent.name) > 0); } - void setmark( MarkType stamp = MARK ) { + void setmark(MarkType stamp = MARK) + { mark = stamp; } - void markAll( MarkType = MARK ); - void unmarkAll() { - markAll( NOMARK ); + void markAll(MarkType = MARK); + void unmarkAll() + { + markAll(NOMARK); } - int marked( MarkType base = ORMARK ) { - return ( mark >= base ); + int marked(MarkType base = ORMARK) + { + return (mark >= base); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() { + int multSuprs() + { return multSupers; } - void multSuprs( int j ) { + void multSuprs(int j) + { multSupers = j; } - EntNode * next; + EntNode *next; private: MarkType mark; @@ -120,68 +132,79 @@ class EntNode { int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList { +class EntList +{ friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, EntList & ); - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, EntList &); + friend ostream &operator<< (ostream &, MultList &); public: - EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), - level( 0 ) {} + EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), + level(0) {} virtual ~EntList() {} - MatchType viableVal() { + MatchType viableVal() + { return viable; } - virtual void setLevel( int l ) { + virtual void setLevel(int l) + { level = l; } - virtual int getMaxLevel() { + virtual int getMaxLevel() + { return level; } - virtual int contains( const char * ) = 0; - virtual int hit( const char * ) = 0; - virtual int isDependent( const char * ) = 0; - virtual MatchType matchNonORs( EntNode * ) { + virtual int contains(const char *) = 0; + virtual int hit(const char *) = 0; + virtual int isDependent(const char *) = 0; + virtual MatchType matchNonORs(EntNode *) + { return UNKNOWN; } - virtual int acceptChoice( EntNode * ) = 0; - virtual void unmarkAll( EntNode * ) = 0; - virtual void reset() { + virtual int acceptChoice(EntNode *) = 0; + virtual void unmarkAll(EntNode *) = 0; + virtual void reset() + { viable = UNKNOWN; } int siblings(); - virtual void write( ostream & ) = 0; + virtual void write(ostream &) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList * firstNot( JoinType ); - EntList * nextNot( JoinType j ) { - return next->firstNot( j ); + EntList *firstNot(JoinType); + EntList *nextNot(JoinType j) + { + return next->firstNot(j); } - EntList * firstWanted( MatchType ); - EntList * nextWanted( MatchType mat ) { - return next->firstWanted( mat ); + EntList *firstWanted(MatchType); + EntList *nextWanted(MatchType mat) + { + return next->firstWanted(mat); } - EntList * lastNot( JoinType ); - EntList * prevNot( JoinType j ) { - return prev->lastNot( j ); + EntList *lastNot(JoinType); + EntList *prevNot(JoinType j) + { + return prev->lastNot(j); } - EntList * lastWanted( MatchType ); - EntList * prevWanted( MatchType mat ) { - return prev->lastWanted( mat ); + EntList *lastWanted(MatchType); + EntList *prevWanted(MatchType mat) + { + return prev->lastWanted(mat); } JoinType join; - int multiple() { - return ( join != SIMPLE ); + int multiple() + { + return (join != SIMPLE); } - EntList * prev, * next; + EntList *prev, * next; protected: MatchType viable; @@ -193,137 +216,153 @@ class EntList { int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList { +class SimpleList : public EntList +{ friend class ComplexList; - friend ostream & operator<< ( ostream &, SimpleList & ); + friend ostream &operator<< (ostream &, SimpleList &); public: - SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { - strcpy( name, n ); + SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) + { + strcpy(name, n); } ~SimpleList() {} - int operator== ( const char * nm ) { - return ( strcmp( name, nm ) == 0 ); + int operator== (const char *nm) + { + return (strcmp(name, nm) == 0); } - const char * Name() { + const char *Name() + { return name; } - int contains( const char * nm ) { + int contains(const char *nm) + { return *this == nm; } - int hit( const char * nm ) { + int hit(const char *nm) + { return *this == nm; } - int isDependent( const char * ); - MatchType matchNonORs( EntNode * ); - int acceptChoice( EntNode * ); - void unmarkAll( EntNode * ); - void reset() { + int isDependent(const char *); + MatchType matchNonORs(EntNode *); + int acceptChoice(EntNode *); + void unmarkAll(EntNode *); + void reset() + { viable = UNKNOWN; I_marked = NOMARK; } - void write( ostream & ); + void write(ostream &); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList { +class MultList : public EntList +{ // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, MultList &); public: - MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} + MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} ~MultList(); - void setLevel( int ); + void setLevel(int); int getMaxLevel(); - int contains( const char * ); - int hit( const char * ); - int isDependent( const char * ); - void appendList( EntList * ); - EntList * copyList( EntList * ); - void processSubExp( Expression, Entity, ComplexCollect * ); - void addSimpleAndSubs( Entity, ComplexCollect * ); - virtual MatchType matchORs( EntNode * ) = 0; - virtual MatchType tryNext( EntNode * ); - - int childCount() { + int contains(const char *); + int hit(const char *); + int isDependent(const char *); + void appendList(EntList *); + EntList *copyList(EntList *); + void processSubExp(Expression, Entity, ComplexCollect *); + void addSimpleAndSubs(Entity, ComplexCollect *); + virtual MatchType matchORs(EntNode *) = 0; + virtual MatchType tryNext(EntNode *); + + int childCount() + { return numchildren; } // EntList *operator[]( int ); - EntList * getChild( int ); - EntList * getLast() { - return ( getChild( numchildren - 1 ) ); + EntList *getChild(int); + EntList *getLast() + { + return (getChild(numchildren - 1)); } - void unmarkAll( EntNode * ); - int prevKnown( EntList * ); + void unmarkAll(EntNode *); + int prevKnown(EntList *); void reset(); - void write( ostream & ); + void write(ostream &); protected: int numchildren; - EntList * childList; + EntList *childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList { +class JoinList : public MultList +{ // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList( JoinType j ) : MultList( j ) {} + JoinList(JoinType j) : MultList(j) {} ~JoinList() {} - void setViableVal( EntNode * ); - int acceptChoice( EntNode * ); + void setViableVal(EntNode *); + int acceptChoice(EntNode *); }; -class AndOrList : public JoinList { +class AndOrList : public JoinList +{ friend class ComplexList; public: - AndOrList() : JoinList( ANDOR ) {} + AndOrList() : JoinList(ANDOR) {} ~AndOrList() {} - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); }; -class AndList : public JoinList { +class AndList : public JoinList +{ friend class MultList; friend class ComplexList; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - AndList() : JoinList( AND ), supertype( 0 ) {} + AndList() : JoinList(AND), supertype(0) {} ~AndList() {} - int isDependent( const char * ); - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + int isDependent(const char *); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList { +class OrList : public MultList +{ public: - OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} + OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} ~OrList() {} - int hit( const char * ); - MatchType matchORs( EntNode * ); - MatchType tryNext( EntNode * ); - void unmarkAll( EntNode * ); - int acceptChoice( EntNode * ); - int acceptNextChoice( EntNode * ents ) { + int hit(const char *); + MatchType matchORs(EntNode *); + MatchType tryNext(EntNode *); + void unmarkAll(EntNode *); + int acceptChoice(EntNode *); + int acceptNextChoice(EntNode *ents) + { choice++; - return ( acceptChoice( ents ) ); + return (acceptChoice(ents)); } - void reset() { + void reset() + { choice = -1; choice1 = -2; choiceCount = 0; @@ -336,90 +375,101 @@ class OrList : public MultList { // the first viable choice; and how many choices are there entirely. }; -class ComplexList { +class ComplexList +{ // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), - abstract( 0 ), dependent( 0 ), - multSupers( 0 ) {} - ComplexList( Entity, ComplexCollect * ); + ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), + abstract(0), dependent(0), + multSupers(0) {} + ComplexList(Entity, ComplexCollect *); ~ComplexList(); void buildList(); void remove(); - int operator< ( ComplexList & c ) { - return ( strcmp( supertype(), c.supertype() ) < 0 ); + int operator< (ComplexList &c) + { + return (strcmp(supertype(), c.supertype()) < 0); } - int operator< ( char * name ) { - return ( strcmp( supertype(), name ) < 0 ); + int operator< (char *name) + { + return (strcmp(supertype(), name) < 0); } - int operator== ( char * name ) { - return ( strcmp( supertype(), name ) == 0 ); + int operator== (char *name) + { + return (strcmp(supertype(), name) == 0); } - const char * supertype() { - return ( ( SimpleList * )head->childList )->name; + const char *supertype() + { + return ((SimpleList *)head->childList)->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel( const char * ); - int contains( EntNode * ); - int matches( EntNode * ); - int isDependent( const char * ); + int toplevel(const char *); + int contains(EntNode *); + int matches(EntNode *); + int isDependent(const char *); - EntNode * list; // List of all entities contained in this complex type, + EntNode *list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList * head; - ComplexList * next; - int Dependent() { + AndList *head; + ComplexList *next; + int Dependent() + { return dependent; } - void write( ostream & ); - int getEntListMaxLevel() { + void write(ostream &); + int getEntListMaxLevel() + { return head->getMaxLevel(); } private: - void addSuper( Entity ); - void addSubExp( Expression ); - void addImplicitSubs( Linked_List, ComplexCollect * ); - void addChildren( EntList * ); - int hitMultNodes( EntNode * ); + void addSuper(Entity); + void addSubExp(Expression); + void addImplicitSubs(Linked_List, ComplexCollect *); + void addChildren(EntList *); + int hitMultNodes(EntNode *); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect { +class ComplexCollect +{ // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect( ComplexList * c = NULL ) : clists( c ) { - count = ( c ? 1 : 0 ); + ComplexCollect(ComplexList *c = NULL) : clists(c) + { + count = (c ? 1 : 0); } - ComplexCollect( Express ); - ~ComplexCollect() { + ComplexCollect(Express); + ~ComplexCollect() + { delete clists; } - void insert( ComplexList * ); - void remove( ComplexList * ); + void insert(ComplexList *); + void remove(ComplexList *); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList * find( char * ); - int supports( EntNode * ); - bool externMapping( const char * ent ) { - return ( clists ? clists->isDependent( ent ) : 0 ); + ComplexList *find(char *); + int supports(EntNode *); + bool externMapping(const char *ent) + { + return (clists ? clists->isDependent(ent) : 0); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write( const char * ); + void write(const char *); - ComplexList * clists; + ComplexList *clists; private: int count; // # of clist children @@ -427,6 +477,6 @@ class ComplexCollect { // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex( ComplexCollect &, const char * ); +void print_complex(ComplexCollect &, const char *); #endif diff --git a/src/exp2cxx/complexlist.cc b/src/exp2cxx/complexlist.cc index 2a42c6d96..672f2e9f0 100644 --- a/src/exp2cxx/complexlist.cc +++ b/src/exp2cxx/complexlist.cc @@ -18,7 +18,7 @@ ComplexList::~ComplexList() * Destructor for ComplexList. */ { - if( next ) { + if(next) { delete next; } delete head; @@ -39,7 +39,7 @@ void ComplexList::remove() delete this; } -int ComplexList::toplevel( const char * name ) +int ComplexList::toplevel(const char *name) /* * Returns TRUE if name is already contained at the top level of our * EntList hierarchy. By top level, we mean the level under head. This @@ -47,14 +47,14 @@ int ComplexList::toplevel( const char * name ) * a temporary CList to test entities which are subtypes of >1 supertype. */ { - EntList * slist = head->childList; + EntList *slist = head->childList; - while( slist ) { - if( *( SimpleList * )slist == name ) { + while(slist) { + if(*(SimpleList *)slist == name) { return TRUE; } slist = slist->next; - if( slist ) { + if(slist) { slist = slist->next; } } @@ -71,20 +71,20 @@ void ComplexList::buildList() * ComplexList certainly can't support it. */ { - EntList * sibling = head->childList->next; + EntList *sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if( list ) { + if(list) { delete list; } // Add first node based on supertype: - list = new EntNode( ( ( SimpleList * )head->childList )->name ); + list = new EntNode(((SimpleList *)head->childList)->name); // Recursively add all descendents: - while( sibling ) { - addChildren( sibling ); + while(sibling) { + addChildren(sibling); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -93,37 +93,37 @@ void ComplexList::buildList() } -void ComplexList::addChildren( EntList * ent ) +void ComplexList::addChildren(EntList *ent) /* * Recursive function to add all the SimpleList descendents of ent into * this's list. */ { - EntList * child; - char * nm; - EntNode * prev = list, *prev2 = NULL, *newnode; + EntList *child; + char *nm; + EntNode *prev = list, *prev2 = NULL, *newnode; int comp = 0; - if( ent->multiple() ) { - child = ( ( MultList * )ent )->childList; - while( child ) { - addChildren( child ); + if(ent->multiple()) { + child = ((MultList *)ent)->childList; + while(child) { + addChildren(child); child = child->next; } } else { - nm = ( dynamic_cast< SimpleList * >(ent) )->name; - while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { + nm = (dynamic_cast< SimpleList * >(ent))->name; + while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if( comp != 0 ) { + if(comp != 0) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode( nm ); + newnode = new EntNode(nm); newnode->next = prev; - if( prev2 == NULL ) { + if(prev2 == NULL) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -135,7 +135,7 @@ void ComplexList::addChildren( EntList * ent ) } } -int ComplexList::contains( EntNode * ents ) +int ComplexList::contains(EntNode *ents) /* * Does a simple search to determine if this contains all the nodes of an * EntNode list. If not, there's no way this will match ents. If so, @@ -144,13 +144,13 @@ int ComplexList::contains( EntNode * ents ) * cally. */ { - EntNode * ours = list, *theirs = ents; + EntNode *ours = list, *theirs = ents; - while( theirs != NULL ) { - while( ours != NULL && *ours < *theirs ) { + while(theirs != NULL) { + while(ours != NULL && *ours < *theirs) { ours = ours->next; } - if( ours == NULL || *ours > *theirs ) { + if(ours == NULL || *ours > *theirs) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return FALSE; @@ -163,7 +163,7 @@ int ComplexList::contains( EntNode * ents ) return TRUE; } -int ComplexList::matches( EntNode * ents ) +int ComplexList::matches(EntNode *ents) /* * Receives as input an EntNode list, corresponding to a user request to * instantiate the corresponding complex type. Returns TRUE if such a list @@ -176,32 +176,32 @@ int ComplexList::matches( EntNode * ents ) // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if( ! contains( ents ) ) { + if(! contains(ents)) { return FALSE; } // Now start a thorough search through this ComplexList: - if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { + if((retval = head->matchNonORs(ents)) == MATCHALL) { result = TRUE; - } else if( retval != UNKNOWN ) { + } else if(retval != UNKNOWN) { result = FALSE; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && - ( hitMultNodes( ents ) ) ) { + if(((retval = head->matchORs(ents)) == MATCHALL) && + (hitMultNodes(ents))) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = TRUE; - } else if( retval >= MATCHSOME ) { + } else if(retval >= MATCHSOME) { MatchType otherChoices = NEWCHOICE; // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): - while( otherChoices == NEWCHOICE ) { - otherChoices = head->tryNext( ents ); - if( otherChoices == MATCHALL ) { - if( hitMultNodes( ents ) ) { + while(otherChoices == NEWCHOICE) { + otherChoices = head->tryNext(ents); + if(otherChoices == MATCHALL) { + if(hitMultNodes(ents)) { result = TRUE; } else { otherChoices = NEWCHOICE; @@ -217,7 +217,7 @@ int ComplexList::matches( EntNode * ents ) return result; } -int ComplexList::isDependent( const char * ent ) +int ComplexList::isDependent(const char *ent) /* * Do any of our members tell us that ent cannot be instantiated indepen- * dently. This is the case if ent = one of the subtypes beneath and the @@ -229,22 +229,22 @@ int ComplexList::isDependent( const char * ent ) * it could (must?) be created with internal mapping. */ { - EntList * elist = head->childList->next; + EntList *elist = head->childList->next; // We start searching from the first sibling after head->childList. head-> // childList represents the supertype (`A' in header comments) which though // it of course is AND'ed with all its subtypes, it doesn't make its sub's // non-independent. - if( elist->isDependent( ent ) == TRUE ) { + if(elist->isDependent(ent) == TRUE) { return TRUE; } - if( next ) { - return ( next->isDependent( ent ) ); + if(next) { + return (next->isDependent(ent)); } return FALSE; } -int ComplexList::hitMultNodes( EntNode * ents ) +int ComplexList::hitMultNodes(EntNode *ents) /* * This function has a specialized application. If the user wants to * instantiate a complex type containing an entity with >1 supertype (call @@ -259,34 +259,34 @@ int ComplexList::hitMultNodes( EntNode * ents ) * also deals with the possibility that >1 entities like C exist.) */ { - EntNode * node; - EntList * child; + EntNode *node; + EntList *child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if( !multSupers ) { + if(!multSupers) { return TRUE; } - for( node = ents; node != NULL; node = node->next ) { - if( node->multSuprs() ) { + for(node = ents; node != NULL; node = node->next) { + if(node->multSuprs()) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while( child ) { + while(child) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if( child->contains( node->name ) ) { - if( ! child->hit( node->name ) ) { + if(child->contains(node->name)) { + if(! child->hit(node->name)) { return FALSE; } } child = child->next; - if( child ) { + if(child) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/exp2cxx/entlist.cc b/src/exp2cxx/entlist.cc index e27114294..8c9c47aef 100644 --- a/src/exp2cxx/entlist.cc +++ b/src/exp2cxx/entlist.cc @@ -23,108 +23,108 @@ int EntList::siblings() */ { int count; - EntList * el; + EntList *el; - for( count = 1, el = next; el; count++, el = el->next ) { + for(count = 1, el = next; el; count++, el = el->next) { ; } return count; } -EntList * EntList::firstNot( JoinType j ) +EntList *EntList::firstNot(JoinType j) /* * Returns the first EntList not of type join, starting from this. */ { - EntList * sibling = this; + EntList *sibling = this; - while( sibling != NULL && sibling->join == j ) { + while(sibling != NULL && sibling->join == j) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList * EntList::firstWanted( MatchType match ) +EntList *EntList::firstWanted(MatchType match) /* * Returns the first EntList where viable = match, starting from this. */ { - EntList * sibling = this; + EntList *sibling = this; - while( sibling != NULL && sibling->viable != match ) { + while(sibling != NULL && sibling->viable != match) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList * EntList::lastNot( JoinType j ) +EntList *EntList::lastNot(JoinType j) /* * Returns the last EntList not of type join, searching backwards from * this. */ { - EntList * sibling = this; + EntList *sibling = this; - while( sibling != NULL && sibling->join == j ) { + while(sibling != NULL && sibling->join == j) { sibling = sibling->prev; } return sibling; // (may = NULL) } -EntList * EntList::lastWanted( MatchType match ) +EntList *EntList::lastWanted(MatchType match) /* * Returns the last EntList where viable = match, searching backwards from * this. */ { - EntList * sibling = this; + EntList *sibling = this; - while( sibling != NULL && sibling->viable != match ) { + while(sibling != NULL && sibling->viable != match) { sibling = sibling->prev; } return sibling; // (may = NULL) } -int SimpleList::isDependent( const char * ent ) +int SimpleList::isDependent(const char *ent) /* * Can we determine that ent can be instantiated independently (a Simple- * List could never tell us that an entity is dependent - only a AndList * could determine that.) */ { - if( !strcmp( name, ent ) ) { + if(!strcmp(name, ent)) { return FALSE; } return DONT_KNOW; } -void SimpleList::unmarkAll( EntNode * ents ) +void SimpleList::unmarkAll(EntNode *ents) /* * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ { - EntNode * eptr = ents; + EntNode *eptr = ents; int comp = -1; - if( viable < MATCHSOME ) { + if(viable < MATCHSOME) { return; } - while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { + while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if( eptr->mark <= I_marked ) { + if(eptr->mark <= I_marked) { // Only unmark if we gave it the strongest mark: - eptr->setmark( NOMARK ); + eptr->setmark(NOMARK); } // Either way (whether or not another List's mark remains), we no longer // marked: I_marked = NOMARK; } -int SimpleList::acceptChoice( EntNode * ents ) +int SimpleList::acceptChoice(EntNode *ents) /* * Marks whichever node we can mark. We assume there is a match because * this function is only called by a parent MultList if its child had a @@ -132,13 +132,13 @@ int SimpleList::acceptChoice( EntNode * ents ) * node; otherwise FALSE. */ { - EntNode * eptr = ents; + EntNode *eptr = ents; int comp; - while( eptr != NULL ) { - if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { - if( ! eptr->marked() ) { - eptr->setmark( ORMARK ); + while(eptr != NULL) { + if((comp = strcmp(name, eptr->name)) == 0) { + if(! eptr->marked()) { + eptr->setmark(ORMARK); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -146,7 +146,7 @@ int SimpleList::acceptChoice( EntNode * ents ) } return FALSE; // we didn't mark } - if( comp < 0 ) { + if(comp < 0) { // We're beyond name in the ents list. No more checking to do. return FALSE; } diff --git a/src/exp2cxx/entnode.cc b/src/exp2cxx/entnode.cc index 50f3a8659..c042660fa 100644 --- a/src/exp2cxx/entnode.cc +++ b/src/exp2cxx/entnode.cc @@ -14,7 +14,7 @@ #include "complexSupport.h" #include -EntNode::EntNode( char * namelist[] ) +EntNode::EntNode(char *namelist[]) /* * Given a list of entity names, creates a sorted linked list of EntNodes * corresponding to the list. Final name must be "*" (otherwise we won't @@ -24,41 +24,41 @@ EntNode::EntNode( char * namelist[] ) */ { int j = 1, comp = 0; - EntNode * prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - char * nm; + EntNode *prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + char *nm; // Create a first EntNode: - firstnode = prev = new EntNode( namelist[0] ); + firstnode = prev = new EntNode(namelist[0]); // The following 3 lines are a ridiculous kludge to simplify testing. // We make the assumption that ents whose name start with C or M have // >1 supertype. (We make sure this is the case in the test file.) // When this code becomes a part of the SCL, it'll be easy to get this // info right from the entity structs anyway, so I'm not bothering // writing anything more sophisticated. - if( *namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j' ) { - firstnode->multSuprs( TRUE ); + if(*namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j') { + firstnode->multSuprs(TRUE); } - while( *namelist[j] != '*' ) { + while(*namelist[j] != '*') { nm = namelist[j]; - while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { + while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if( comp != 0 ) { + if(comp != 0) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode( nm ); + newnode = new EntNode(nm); // Same kludge: - if( *nm == 'c' || *nm == 'm' || *nm == 'j' ) { - newnode->multSuprs( TRUE ); + if(*nm == 'c' || *nm == 'm' || *nm == 'j') { + newnode->multSuprs(TRUE); } newnode->next = prev; - if( prev2 == NULL ) { + if(prev2 == NULL) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -75,7 +75,7 @@ EntNode::EntNode( char * namelist[] ) // Finally, place the contents of firstnode in 'this', and delete first- // node. This ensures that 'this' is first. - strcpy( name, firstnode->name ); + strcpy(name, firstnode->name); next = firstnode->next; multSupers = firstnode->multSupers; firstnode->next = NULL; @@ -83,14 +83,14 @@ EntNode::EntNode( char * namelist[] ) delete firstnode; } -void EntNode::markAll( MarkType stamp ) +void EntNode::markAll(MarkType stamp) /* * Marks/unmarks all the nodes in this's list (default is to mark). */ { - EntNode * node = this; + EntNode *node = this; - while( node != NULL ) { + while(node != NULL) { node->mark = stamp; node = node->next; } @@ -101,10 +101,10 @@ int EntNode::allMarked() * Returns TRUE if this and all nodes following it are marked. */ { - EntNode * node = this; + EntNode *node = this; - while( node != NULL ) { - if( node->mark == NOMARK ) { + while(node != NULL) { + if(node->mark == NOMARK) { return FALSE; } node = node->next; @@ -118,10 +118,10 @@ int EntNode::unmarkedCount() */ { int count = 0; - EntNode * node = this; + EntNode *node = this; - while( node != NULL ) { - if( node->mark == NOMARK ) { + while(node != NULL) { + if(node->mark == NOMARK) { count++; } node = node->next; diff --git a/src/exp2cxx/expressbuild.cc b/src/exp2cxx/expressbuild.cc index a1c665656..932978839 100644 --- a/src/exp2cxx/expressbuild.cc +++ b/src/exp2cxx/expressbuild.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static void initEnts( Express ); -static Entity findEnt( Entity, char * ); +static void initEnts(Express); +static Entity findEnt(Entity, char *); -ComplexCollect::ComplexCollect( Express express ) +ComplexCollect::ComplexCollect(Express express) /* * Builds a ComplexCollect, a collection of ComplexLists, based on the * entities contained in EXPRESS file express. @@ -26,7 +26,7 @@ ComplexCollect::ComplexCollect( Express express ) { DictionaryEntry de_sch, de_ent; Schema schema; - ComplexList * cl, *prev = NULL; + ComplexList *cl, *prev = NULL; // Some initializing: clists = NULL; @@ -35,26 +35,26 @@ ComplexCollect::ComplexCollect( Express express ) // Set all ent->search_id's to 0. Since entities - even ones in different // schemas - may be strongly connected, we must be sure not to process each // one more than once. - initEnts( express ); + initEnts(express); // Next loop through all the entities, building ComplexLists: - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { - SCOPEdo_entities( schema, ent, de_ent ) - if( ent->search_id == TRUE ) { + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de_sch)) != 0) { + SCOPEdo_entities(schema, ent, de_ent) + if(ent->search_id == TRUE) { // we've hit this entity already continue; } #ifdef COMPLEX_INFO - cout << "Processing entity " << ENTITYget_name( ent ) << endl; + cout << "Processing entity " << ENTITYget_name(ent) << endl; #endif - if( ent->u.entity->subtypes != NULL ) { - cl = new ComplexList( ent, this ); + if(ent->u.entity->subtypes != NULL) { + cl = new ComplexList(ent, this); // This constructor will not only create a ComplexList for // the ent subtypes, but it will recurse for all of their // subtypes. The entire hierarchy will become a single // ComplexList and is now appended to the Collect ("this"). - insert( cl ); + insert(cl); } SCOPEod } @@ -64,13 +64,13 @@ ComplexCollect::ComplexCollect( Express express ) // supercede them. (They were added in the first place to be available // so that any supertype which accessed it would find it.) cl = clists; - while( cl ) { - if( cl->Dependent() ) { + while(cl) { + if(cl->Dependent()) { #ifdef COMPLEX_INFO cout << "\nRemoving dependent entity " << cl->supertype() << endl; #endif - remove( cl ); - if( prev ) { + remove(cl); + if(prev) { cl = prev->next; // prev->next was automatically set to cl->next in remove() // when cl was removed. @@ -86,7 +86,7 @@ ComplexCollect::ComplexCollect( Express express ) } } -static void initEnts( Express express ) +static void initEnts(Express express) /* * Sets all the search_id's of all the entities to FALSE. The search_id's * will be used to keep track of which entities we've build ComplexLists @@ -96,15 +96,15 @@ static void initEnts( Express express ) DictionaryEntry de_sch, de_ent; Schema schema; - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { - SCOPEdo_entities( schema, ent, de_ent ) + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de_sch)) != 0) { + SCOPEdo_entities(schema, ent, de_ent) ent->search_id = FALSE; SCOPEod } } -ComplexList::ComplexList( Entity ent, ComplexCollect * col ) +ComplexList::ComplexList(Entity ent, ComplexCollect *col) /* * Builds a complex list from an entity which contains subtypes. (All our * members are set here or in called functions except next which is set @@ -118,39 +118,39 @@ ComplexList::ComplexList( Entity ent, ComplexCollect * col ) next = NULL; maxlevel = 0; - addSuper( ent ); - if( ( exp = ent->u.entity->subtype_expression ) != NULL ) { + addSuper(ent); + if((exp = ent->u.entity->subtype_expression) != NULL) { #ifdef COMPLEX_INFO cout << " Has a sub expression\n"; #endif - head->processSubExp( exp, ent, col ); + head->processSubExp(exp, ent, col); buildList(); } // Check for any subtypes which were not a part of subtype_expr. Any // subtype which was not in sub_exp but is included in subtypes is ANDORed // with the rest of the List. - addImplicitSubs( ENTITYget_subtypes( ent ), col ); + addImplicitSubs(ENTITYget_subtypes(ent), col); - if( ENTITYget_supertypes( ent ) == NULL ) { + if(ENTITYget_supertypes(ent) == NULL) { dependent = FALSE; // Rebuild list in case implicit subs were added (we had to build the // first time also so addImplicitSubs() would work). buildList(); //maxlevel = head->setLevel( 0 ); - head->setLevel( 0 ); + head->setLevel(0); } else { // If this List has supertypes, we don't really need it as a List - // it will ultimately be a part of its super(s)' List(s). We need it // now so its supers will be able to find it. But mark that this // does not stand on its own: #ifdef COMPLEX_INFO - cout << " " << ENTITYget_name( ent ) << " is dependent\n"; + cout << " " << ENTITYget_name(ent) << " is dependent\n"; #endif dependent = TRUE; } } -void ComplexList::addSuper( Entity ent ) +void ComplexList::addSuper(Entity ent) /* * Sets our supertype. Assumes supertype was previously unset. */ @@ -160,12 +160,12 @@ void ComplexList::addSuper( Entity ent ) // (Although this supertype may itself be a subtype of other supertypes, // we call this a supertype. We only need this info during the list- // creation stage (see MultList::processSubExp()).) - head->childList = new SimpleList( ENTITYget_name( ent ) ); + head->childList = new SimpleList(ENTITYget_name(ent)); head->numchildren = 1; } -void MultList::processSubExp( Expression exp, Entity super, - ComplexCollect * col ) +void MultList::processSubExp(Expression exp, Entity super, + ComplexCollect *col) /* * Recursive function which builds an EntList hierarchy from an entity's * subtype expression. First called with this = the ComplexList->head and @@ -173,26 +173,26 @@ void MultList::processSubExp( Expression exp, Entity super, * process the subexpressions. */ { - struct Op_Subexpression * oe = &exp->e; + struct Op_Subexpression *oe = &exp->e; Entity ent; - MultList * mult; + MultList *mult; int supertype = 0; - switch( TYPEis( exp->type ) ) { + switch(TYPEis(exp->type)) { case entity_: - ent = findEnt( super, exp->type->symbol.name ); + ent = findEnt(super, exp->type->symbol.name); #ifdef COMPLEX_INFO - cout << " Adding subtype " << ENTITYget_name( ent ) << endl; + cout << " Adding subtype " << ENTITYget_name(ent) << endl; #endif - addSimpleAndSubs( ent, col ); + addSimpleAndSubs(ent, col); break; case op_: - if( join == AND ) { - supertype = ( dynamic_cast< AndList * >(this) )->supertype; + if(join == AND) { + supertype = (dynamic_cast< AndList * >(this))->supertype; } - if( ! supertype && - ( ( oe->op_code == OP_AND && join == AND ) - || ( oe->op_code == OP_ANDOR && join == ANDOR ) ) ) { + if(! supertype && + ((oe->op_code == OP_AND && join == AND) + || (oe->op_code == OP_ANDOR && join == ANDOR))) { // If the subexp is of the same type as we, process its op's at // the same level (add them on to our childList). 1st cond says // we don't do this if this is the supertype. In that case, the @@ -200,10 +200,10 @@ void MultList::processSubExp( Expression exp, Entity super, // a lower level. One reason for this is in case we find implicit // subtypes, we'll want to ANDOR them with the rest of the subs. // So we'll want the subs at a distinct lower level. - processSubExp( oe->op1, super, col ); - processSubExp( oe->op2, super, col ); + processSubExp(oe->op1, super, col); + processSubExp(oe->op2, super, col); } else { - if( oe->op_code == OP_AND ) { + if(oe->op_code == OP_AND) { #ifdef COMPLEX_INFO cout << " Processing AND\n"; #endif @@ -214,9 +214,9 @@ void MultList::processSubExp( Expression exp, Entity super, #endif mult = new AndOrList; } - appendList( mult ); - mult->processSubExp( oe->op1, super, col ); - mult->processSubExp( oe->op2, super, col ); + appendList(mult); + mult->processSubExp(oe->op1, super, col); + mult->processSubExp(oe->op2, super, col); } break; case oneof_: @@ -224,9 +224,9 @@ void MultList::processSubExp( Expression exp, Entity super, cout << " Processing ONEOF\n"; #endif mult = new OrList; - appendList( mult ); - LISTdo( exp->u.list, arg, Expression ) - mult->processSubExp( arg, super, col ); + appendList(mult); + LISTdo(exp->u.list, arg, Expression) + mult->processSubExp(arg, super, col); LISTod break; default: @@ -235,20 +235,20 @@ void MultList::processSubExp( Expression exp, Entity super, } } -static Entity findEnt( Entity ent0, char * name ) +static Entity findEnt(Entity ent0, char *name) /* * Returns an entity named name. The desired entity is likely to be in the * same schema as ent0. findEnt first searches the schema which contains * ent, and then searches the other schemas in the express file. */ { - Schema schema = ENTITYget_schema( ent0 ), sch; + Schema schema = ENTITYget_schema(ent0), sch; DictionaryEntry de_ent, de_sch; Express express; // First look through the entities in the same schema as ent0: - SCOPEdo_entities( schema, ent, de_ent ) - if( !strcmp( ENTITYget_name( ent ), name ) ) { + SCOPEdo_entities(schema, ent, de_ent) + if(!strcmp(ENTITYget_name(ent), name)) { return ent; } SCOPEod @@ -256,14 +256,14 @@ static Entity findEnt( Entity ent0, char * name ) // If we still haven't found it, look through all the entities in the // express file: express = schema->superscope; - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( sch = ( Scope )DICTdo( &de_sch ) ) != 0 ) { - if( sch == schema ) { + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((sch = (Scope)DICTdo(&de_sch)) != 0) { + if(sch == schema) { // Don't redo the schema which contains ent0 - we did it already. continue; } - SCOPEdo_entities( sch, ent, de_ent ) - if( !strcmp( ENTITYget_name( ent ), name ) ) { + SCOPEdo_entities(sch, ent, de_ent) + if(!strcmp(ENTITYget_name(ent), name)) { return ent; } SCOPEod @@ -273,34 +273,34 @@ static Entity findEnt( Entity ent0, char * name ) // complained already. } -void ComplexList::addImplicitSubs( Linked_List subs, ComplexCollect * col ) +void ComplexList::addImplicitSubs(Linked_List subs, ComplexCollect *col) /* * Checks if there are any subtypes of entity this->supertype() which were * not in the entity's subtype_expression. (subs is the entity's subtypes * list.) If any are found they are ANDORed with the other subtypes. */ { - EntNode node( ( char * )"" ); + EntNode node((char *)""); // Temp var - used to check if this already contains certain values. int none_yet = TRUE; - AndOrList * ao = 0; + AndOrList *ao = 0; - LISTdo( subs, subEnt, Entity ) - strcpy( node.name, ENTITYget_name( subEnt ) ); - if( !contains( &node ) ) { + LISTdo(subs, subEnt, Entity) + strcpy(node.name, ENTITYget_name(subEnt)); + if(!contains(&node)) { // We've found an implicit subtype. #ifdef COMPLEX_INFO - cout << " Adding implicit subtype " << ENTITYget_name( subEnt ) + cout << " Adding implicit subtype " << ENTITYget_name(subEnt) << endl; #endif - if( none_yet ) { + if(none_yet) { // If this is the first one, replace the previous subtype list // with an ANDOR. none_yet = FALSE; ao = new AndOrList; // Make the previous sub exp a child of ao: ao->childList = head->childList->next; - if( ao->childList ) { + if(ao->childList) { ao->childList->prev = NULL; ao->numchildren = 1; } else { @@ -312,12 +312,12 @@ void ComplexList::addImplicitSubs( Linked_List subs, ComplexCollect * col ) } // Add the new entity to the end of ao. In case it has its own // subtype list, call addSimpleAndSubs(). - ao->addSimpleAndSubs( subEnt, col ); + ao->addSimpleAndSubs(subEnt, col); } LISTod } -void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) +void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) /* * Called whenever we have a SimpleList (to be built from newEnt) to add * to our ComplexList. The purpose of this function is to check if the @@ -326,17 +326,17 @@ void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) * SimpleList corresponding to newEnt. */ { - ComplexList * sublist; - SimpleList * simple; - EntList * newlist; - OrList * olist; + ComplexList *sublist; + SimpleList *simple; + EntList *newlist; + OrList *olist; // First get the easy case out of the way. If newEnt has no subtypes // just create a corresponding SimpleList: - if( ENTITYget_subtypes( newEnt ) == NULL ) { + if(ENTITYget_subtypes(newEnt) == NULL) { newEnt->search_id = TRUE; - simple = new SimpleList( ENTITYget_name( newEnt ) ); - appendList( simple ); + simple = new SimpleList(ENTITYget_name(newEnt)); + appendList(simple); return; } @@ -344,14 +344,14 @@ void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) #ifdef COMPLEX_INFO cout << " Subtype is a supertype ...\n"; #endif - if( newEnt->search_id == TRUE ) { + if(newEnt->search_id == TRUE) { // We've processed child already, find its ComplexList in col: #ifdef COMPLEX_INFO cout << " was built already ... finding it\n"; #endif - sublist = col->find( ENTITYget_name( newEnt ) ); + sublist = col->find(ENTITYget_name(newEnt)); // Make a copy and append to this: - newlist = copyList( sublist->head ); + newlist = copyList(sublist->head); } else { // If this subtype has never been visited, we build a ComplexList out // of it and add it to our ComplexCollect. Even though it only exists @@ -363,32 +363,32 @@ void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) #ifdef COMPLEX_INFO cout << " never built before ... building it now\n"; #endif - sublist = new ComplexList( newEnt, col ); - col->insert( sublist ); + sublist = new ComplexList(newEnt, col); + col->insert(sublist); // Since this is the first time we're creating this list, we don't need // to copy it and append to this, as above. We'll use the same Lists // again and also point to them from this. - appendList( sublist->head ); + appendList(sublist->head); newlist = sublist->head; } // If the sub-list is not abstract, one more task: - if( ! newEnt->u.entity->abstract ) { + if(! newEnt->u.entity->abstract) { // Since the subtype is not abstract, it can be instantiated without // its subtypes. Create an OrList OR'ing the supertype alone and its // entire List: olist = new OrList; - simple = new SimpleList( ( char * )sublist->supertype() ); - olist->appendList( simple ); + simple = new SimpleList((char *)sublist->supertype()); + olist->appendList(simple); // We just added "newlist" to the end of this. We now replace it with // our new or, and place it underneath the or. This OR's the new // subtype alone with the subtype + its own subtypes - just what we // want for a non-abstract subtype. - olist->appendList( newlist ); + olist->appendList(newlist); numchildren--; // (Slightly ugly: Since we just grabbed newlist from this to or, we // had the side effect of making this's numcount incorrect. I could // have done this more elegantly, but was lazy.) - appendList( olist ); + appendList(olist); } } diff --git a/src/exp2cxx/fedex_main.c b/src/exp2cxx/fedex_main.c index 81c6f1515..ded6b6aea 100644 --- a/src/exp2cxx/fedex_main.c +++ b/src/exp2cxx/fedex_main.c @@ -80,57 +80,61 @@ #include -extern void print_fedex_version( void ); +extern void print_fedex_version(void); -static void exp2cxx_usage( void ) { +static void exp2cxx_usage(void) +{ char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf( stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); - fprintf( stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n" ); - fprintf( stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n" ); - fprintf( stderr, "\t-L prints logging code in the generated C++ classes\n" ); - fprintf( stderr, "\t-v produces the version description below\n" ); - fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); - fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); - fprintf( stderr, "\t-n do not pause for internal errors (useful with delta script)\n" ); - fprintf( stderr, "\t-w warning enable\n" ); - fprintf( stderr, "\t-i warning ignore\n" ); - fprintf( stderr, "and is one of:\n" ); - fprintf( stderr, "\tnone\n\tall\n" ); - fprintf( stderr, "%s", warnings_help_msg); - fprintf( stderr, "and is one or more of:\n" ); - fprintf( stderr, " e entity\n" ); - fprintf( stderr, " p procedure\n" ); - fprintf( stderr, " r rule\n" ); - fprintf( stderr, " f function\n" ); - fprintf( stderr, " t type\n" ); - fprintf( stderr, " s schema or file\n" ); - fprintf( stderr, " # pass #\n" ); - fprintf( stderr, " E everything (all of the above)\n" ); + fprintf(stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); + fprintf(stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n"); + fprintf(stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n"); + fprintf(stderr, "\t-L prints logging code in the generated C++ classes\n"); + fprintf(stderr, "\t-v produces the version description below\n"); + fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); + fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); + fprintf(stderr, "\t-n do not pause for internal errors (useful with delta script)\n"); + fprintf(stderr, "\t-w warning enable\n"); + fprintf(stderr, "\t-i warning ignore\n"); + fprintf(stderr, "and is one of:\n"); + fprintf(stderr, "\tnone\n\tall\n"); + fprintf(stderr, "%s", warnings_help_msg); + fprintf(stderr, "and is one or more of:\n"); + fprintf(stderr, " e entity\n"); + fprintf(stderr, " p procedure\n"); + fprintf(stderr, " r rule\n"); + fprintf(stderr, " f function\n"); + fprintf(stderr, " t type\n"); + fprintf(stderr, " s schema or file\n"); + fprintf(stderr, " # pass #\n"); + fprintf(stderr, " E everything (all of the above)\n"); print_fedex_version(); - exit( 2 ); + exit(2); } -int Handle_FedPlus_Args( int, char * ); -void print_file( Express ); +int Handle_FedPlus_Args(int, char *); +void print_file(Express); -void resolution_success( void ) { - printf( "Resolution successful. Writing C++ output...\n" ); +void resolution_success(void) +{ + printf("Resolution successful. Writing C++ output...\n"); } -int success( Express model ) { +int success(Express model) +{ (void) model; /* unused */ - printf( "Finished writing files.\n" ); - return( 0 ); + printf("Finished writing files.\n"); + return(0); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init( void ) { +void EXPRESSinit_init(void) +{ EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat( EXPRESSgetopt_options, "sSlLaA" ); + strcat(EXPRESSgetopt_options, "sSlLaA"); ERRORusage_function = exp2cxx_usage; } diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index 47004e43d..2d21580b4 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -24,16 +24,18 @@ char header[ BUFSIZ ] = {0}; filenames_t fnames = { impl, header }; -filenames_t getEntityFilenames( Entity e ) { - const char * name = ENTITYget_classname( e ); - snprintf( header, BUFSIZ-1, "entity/%s.h", name ); - snprintf( impl, BUFSIZ-1, "entity/%s.cc", name ); +filenames_t getEntityFilenames(Entity e) +{ + const char *name = ENTITYget_classname(e); + snprintf(header, BUFSIZ - 1, "entity/%s.h", name); + snprintf(impl, BUFSIZ - 1, "entity/%s.cc", name); return fnames; } -filenames_t getTypeFilenames( Type t ) { - const char * name = TYPEget_ctype( t ); - snprintf( header, BUFSIZ-1, "type/%s.h", name ); - snprintf( impl, BUFSIZ-1, "type/%s.cc", name ); +filenames_t getTypeFilenames(Type t) +{ + const char *name = TYPEget_ctype(t); + snprintf(header, BUFSIZ - 1, "type/%s.h", name); + snprintf(impl, BUFSIZ - 1, "type/%s.cc", name); return fnames; } diff --git a/src/exp2cxx/genCxxFilenames.h b/src/exp2cxx/genCxxFilenames.h index f79d33cd6..1bdc65561 100644 --- a/src/exp2cxx/genCxxFilenames.h +++ b/src/exp2cxx/genCxxFilenames.h @@ -13,8 +13,8 @@ typedef struct { /* will we ever need more file names? */ - const char * impl; - const char * header; + const char *impl; + const char *header; } filenames_t; /** write entity filenames to a pair of shared static buffers. @@ -22,13 +22,13 @@ typedef struct { * * \sa getTypeFilenames() */ -filenames_t getEntityFilenames( Entity e ); +filenames_t getEntityFilenames(Entity e); /** write type filenames to a pair of shared static buffers. * names will be overwritten by next call to a function using those buffers! * * \sa getEntityFilenames() */ -filenames_t getTypeFilenames( Type t ); +filenames_t getTypeFilenames(Type t); #endif /* GENCXXFILENAMES_H */ diff --git a/src/exp2cxx/match-ors.cc b/src/exp2cxx/match-ors.cc index 1b86622e4..ee2bd7f48 100644 --- a/src/exp2cxx/match-ors.cc +++ b/src/exp2cxx/match-ors.cc @@ -16,7 +16,7 @@ #include "complexSupport.h" #include -MatchType AndOrList::matchORs( EntNode * ents ) +MatchType AndOrList::matchORs(EntNode *ents) /* * Loops through descendants of this, invoking their matchOR functions. * Returns the status of how well this's OR descendants match the nodes of @@ -27,27 +27,27 @@ MatchType AndOrList::matchORs( EntNode * ents ) * is an OR, or has an OR somewhere beneath it which we must process now. */ { - EntList * child = childList->firstWanted( UNKNOWN ); + EntList *child = childList->firstWanted(UNKNOWN); - while( child != NULL ) { - if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll( ents ); + child->unmarkAll(ents); } - child = child->nextWanted( UNKNOWN ); + child = child->nextWanted(UNKNOWN); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal( ents ); + setViableVal(ents); return viable; } -MatchType AndList::matchORs( EntNode * ents ) +MatchType AndList::matchORs(EntNode *ents) /* * Loops through the descendants of this with viable val = UNKNOWN, invo- * king their matchOR functions. Returns the status of how well this's OR @@ -55,26 +55,26 @@ MatchType AndList::matchORs( EntNode * ents ) * they will lead us to OR's, as explained in AndOrList::matchORs(). */ { - EntList * child = childList->firstWanted( UNKNOWN ); + EntList *child = childList->firstWanted(UNKNOWN); - while( child != NULL ) { - if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted( UNKNOWN ); + child = child->nextWanted(UNKNOWN); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal( ents ); + setViableVal(ents); return viable; } -MatchType OrList::matchORs( EntNode * ents ) +MatchType OrList::matchORs(EntNode *ents) /* * Checks the branches of an OrList to search for a match to the nodes of * ents. This function searches this's children and marks all the viable @@ -85,41 +85,41 @@ MatchType OrList::matchORs( EntNode * ents ) */ { int count; - EntList * child = childList; + EntList *child = childList; MatchType retval = UNKNOWN; - for( count = 0; count < numchildren; count++, child = child->next ) { + for(count = 0; count < numchildren; count++, child = child->next) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if( child->join != OR ) { - retval = child->matchNonORs( ents ); + if(child->join != OR) { + retval = child->matchNonORs(ents); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if( child->viable == UNKNOWN ) { + if(child->viable == UNKNOWN) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); + retval = (dynamic_cast< MultList * >(child))->matchORs(ents); } // Now register the result: - if( retval >= MATCHSOME ) { + if(retval >= MATCHSOME) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if( choice == -1 ) { + if(choice == -1) { choice1 = choice = count; } choiceCount++; - if( viable < retval ) { + if(viable < retval) { viable = retval; } } else { @@ -131,17 +131,17 @@ MatchType OrList::matchORs( EntNode * ents ) // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if( viable < retval ) { + if(viable < retval) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll( ents ); + child->unmarkAll(ents); } // Accept the first viable solution, if there is one: - if( viable >= MATCHSOME ) { + if(viable >= MATCHSOME) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -150,10 +150,10 @@ MatchType OrList::matchORs( EntNode * ents ) // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice( ents ); + acceptChoice(ents); } - if( viable == MATCHALL ) { - return getChild( choice1 )->viable; + if(viable == MATCHALL) { + return getChild(choice1)->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/exp2cxx/multlist.cc b/src/exp2cxx/multlist.cc index fb74cf5d1..f19b02827 100644 --- a/src/exp2cxx/multlist.cc +++ b/src/exp2cxx/multlist.cc @@ -20,37 +20,38 @@ MultList::~MultList() * Deletes the childList of this, before this is deleted. */ { - EntList * child = childList, *nxt; + EntList *child = childList, *nxt; - while( child ) { + while(child) { nxt = child->next; delete child; child = nxt; } } -void MultList::setLevel( int l ) +void MultList::setLevel(int l) /* * Sets this's level, and tells all its children to set their level to our * level +1. */ { - EntList * child = childList; + EntList *child = childList; level = l; - for( ; child != NULL; child = child->next ) { - child->setLevel( l + 1 ); + for(; child != NULL; child = child->next) { + child->setLevel(l + 1); } } -int MultList::getMaxLevel() { - EntList * child = childList; +int MultList::getMaxLevel() +{ + EntList *child = childList; int maxLevel, childLevel; maxLevel = level; - while( child ) { + while(child) { childLevel = child->getMaxLevel(); - if( childLevel > maxLevel ) { + if(childLevel > maxLevel) { maxLevel = childLevel; } child = child->next; @@ -59,15 +60,15 @@ int MultList::getMaxLevel() { return maxLevel; } -int MultList::contains( const char * nm ) +int MultList::contains(const char *nm) /* * Check if one of this's descendants matches nm. */ { - EntList * child = childList; + EntList *child = childList; - while( child ) { - if( child->contains( nm ) ) { + while(child) { + if(child->contains(nm)) { return TRUE; } child = child->next; @@ -75,15 +76,15 @@ int MultList::contains( const char * nm ) return FALSE; } -int MultList::hit( const char * nm ) +int MultList::hit(const char *nm) /* * Check if one of our descendants matches nm. */ { - EntList * child = childList; + EntList *child = childList; - while( child ) { - if( child->viable > UNSATISFIED && child->hit( nm ) ) { + while(child) { + if(child->viable > UNSATISFIED && child->hit(nm)) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -96,7 +97,7 @@ int MultList::hit( const char * nm ) return FALSE; } -int MultList::isDependent( const char * ent ) +int MultList::isDependent(const char *ent) /* * Can one of our descendants tell us that entity ent can or cannot be * instantiated independently (i.e., not as a complex entity with external @@ -107,14 +108,14 @@ int MultList::isDependent( const char * ent ) * Dependent(). */ { - EntList * child = childList; + EntList *child = childList; int result = DONT_KNOW, retval; - while( child ) { - if( ( retval = child->isDependent( ent ) ) == FALSE ) { + while(child) { + if((retval = child->isDependent(ent)) == FALSE) { return FALSE; } - if( retval == TRUE ) { + if(retval == TRUE) { // If child tells us that ent must be created together with another // leaf node (e.g., child is an AndList AND'ing ent + ent_b), save // the result. Don't return TRUE yet because a later child may @@ -129,7 +130,7 @@ int MultList::isDependent( const char * ent ) // either DONT_KNOW or TRUE if we got here } -int AndList::isDependent( const char * ent ) +int AndList::isDependent(const char *ent) /* * Tells us if entity ent cannot be instantiated independently. Say ent * A is a supertype of ( B AND C ). Neither B nor C can be instantiated @@ -140,7 +141,7 @@ int AndList::isDependent( const char * ent ) * if nothing can be determined, it returns DONT_KNOW. */ { - if( supertype ) { + if(supertype) { // If we're a supertype, we have to make one exception. Normally if // we're an AND of A & B and ent = A, we'd be able to conclude that A // requires ext mapping. But here, the first child of the AND is a @@ -149,7 +150,7 @@ int AndList::isDependent( const char * ent ) // we skip the first child. We then continue to check if among the // subtypes of A there are children requiring ext mapping (such as B // AND C). - return ( childList->next->isDependent( ent ) ); + return (childList->next->isDependent(ent)); // NOTE - actually the algorithm for a supertype is more complex. We // did not address here the possibility that ent = the super (A). In // such a case, if A is non-abstract, then by def it can be instanti- @@ -173,8 +174,8 @@ int AndList::isDependent( const char * ent ) // Next possibility: We don't represent a supertype. Thus, if we have >1 // child and ent is one of them, it can only be created by being AND'ed // with at least 1 other child. - if( numchildren > 1 ) { - if( contains( ent ) ) { + if(numchildren > 1) { + if(contains(ent)) { return TRUE; } return DONT_KNOW; @@ -183,36 +184,36 @@ int AndList::isDependent( const char * ent ) // If we have 1 child only, just move on. At this point, the fact that // we're an AND didn't go very far in telling us that our children are // dependent on one another since we only *have* one child. - return ( childList->isDependent( ent ) ); + return (childList->isDependent(ent)); } -EntList * MultList::getChild( int num ) +EntList *MultList::getChild(int num) /* * Returns a pointer to the num'th child of MultList. */ { - EntList * child = childList; + EntList *child = childList; int j; - if( num < 0 || num >= numchildren ) { + if(num < 0 || num >= numchildren) { // Check for error situations (shouldn't normally occur): return NULL; } - for( j = 0; j < num; j++, child = child->next ) { + for(j = 0; j < num; j++, child = child->next) { ; } return child; } -void MultList::appendList( EntList * ent ) +void MultList::appendList(EntList *ent) /* * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ { - EntList * prv; + EntList *prv; - if( numchildren == 0 ) { + if(numchildren == 0) { childList = ent; } else { prv = getLast(); @@ -222,21 +223,21 @@ void MultList::appendList( EntList * ent ) numchildren += ent->siblings(); } -EntList * MultList::copyList( EntList * ent ) +EntList *MultList::copyList(EntList *ent) /* * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ { - EntList * newlist = 0, *child; + EntList *newlist = 0, *child; - switch( ent->join ) { + switch(ent->join) { case SIMPLE: - newlist = new SimpleList( ( dynamic_cast< SimpleList * >(ent) )->Name() ); + newlist = new SimpleList((dynamic_cast< SimpleList * >(ent))->Name()); break; case AND: newlist = new AndList; - ( ( AndList * )newlist )->supertype = ( dynamic_cast< AndList * >(ent) )->supertype; + ((AndList *)newlist)->supertype = (dynamic_cast< AndList * >(ent))->supertype; break; case OR: newlist = new OrList; @@ -245,29 +246,29 @@ EntList * MultList::copyList( EntList * ent ) newlist = new AndOrList; break; }; - appendList( newlist ); - if( ent->multiple() ) { + appendList(newlist); + if(ent->multiple()) { // For the multlists, we must recurse for all their children: - child = ( dynamic_cast< MultList * >(ent) )->childList; - while( child ) { - ( dynamic_cast< MultList * >(newlist) )->copyList( child ); + child = (dynamic_cast< MultList * >(ent))->childList; + while(child) { + (dynamic_cast< MultList * >(newlist))->copyList(child); child = child->next; } } return newlist; } -void MultList::unmarkAll( EntNode * ents ) +void MultList::unmarkAll(EntNode *ents) /* * Unmarks all nodes of ents marked by any of the descendants of this. * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ { - EntList * child = childList; + EntList *child = childList; - while( child != NULL ) { - child->unmarkAll( ents ); + while(child != NULL) { + child->unmarkAll(ents); child = child->next; } } @@ -278,15 +279,15 @@ void MultList::reset() * each child's reset function. */ { - EntList * child; + EntList *child; viable = UNKNOWN; - for( child = childList; child; child = child->next ) { + for(child = childList; child; child = child->next) { child->reset(); } } -void JoinList::setViableVal( EntNode * ents ) +void JoinList::setViableVal(EntNode *ents) /* * Sets this's viable value based on the value of its children. This is * called at the end of matchNonOR() and matchOR() to determine the result @@ -298,22 +299,22 @@ void JoinList::setViableVal( EntNode * ents ) * worry about coming across them down here. */ { - EntList * child = childList; + EntList *child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while( child != NULL ) { - if( child->viable == UNKNOWN ) { + while(child != NULL) { + if(child->viable == UNKNOWN) { viable = UNKNOWN; return; } - if( child->viable > viable ) { + if(child->viable > viable) { viable = child->viable; } child = child->next; } - if( viable == MATCHALL && !ents->allMarked() ) { + if(viable == MATCHALL && !ents->allMarked()) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -322,18 +323,18 @@ void JoinList::setViableVal( EntNode * ents ) } } -int JoinList::acceptChoice( EntNode * ents ) +int JoinList::acceptChoice(EntNode *ents) /* * Accept the path we're a part of: Mark all nodes of ents we can. Mark * value will = mark (either MARK or ORMARK). Return TRUE if we mark any- * thing; FALSE otherwise. */ { - EntList * child; + EntList *child; int result = FALSE; - for( child = childList; child != NULL; child = child->next ) { - if( child->viable >= MATCHSOME ) { + for(child = childList; child != NULL; child = child->next) { + if(child->viable >= MATCHSOME) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -344,7 +345,7 @@ int JoinList::acceptChoice( EntNode * ents ) // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice( ents ) || result; + result = child->acceptChoice(ents) || result; // (NOTE - must run acceptChoice() first in above line. If result // were TRUE and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -353,17 +354,17 @@ int JoinList::acceptChoice( EntNode * ents ) return result; } -int MultList::prevKnown( EntList * desc ) +int MultList::prevKnown(EntList *desc) /* * Specialized function to test that none of the children prior to desc * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ { - EntList * child = childList; + EntList *child = childList; - while( child != NULL && child != desc ) { - if( child->viable == UNKNOWN ) { + while(child != NULL && child != desc) { + if(child->viable == UNKNOWN) { return FALSE; } child = child->next; diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 51a210ecb..0af0731e9 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -37,21 +37,21 @@ #include -int isAggregateType( const Type t ); +int isAggregateType(const Type t); /* Local function prototypes: */ -static void initializeMarks( Express ); -static void cleanupMarks( Express ); -static void unsetObjs( Schema ); -static bool checkTypes( Schema ); -static bool checkEnts( Schema ); -static void markDescs( Entity ); -static bool checkItem( Type, Scope, Schema, int *, int ); -static int ENUMcanBeProcessed( Type, Schema ); -static int inSchema( Scope, Scope ); -static void addRenameTypedefs( Schema, FILE * ); -static void addAggrTypedefs( Schema , FILE * ); -static void addUseRefNames( Schema, FILE * ); +static void initializeMarks(Express); +static void cleanupMarks(Express); +static void unsetObjs(Schema); +static bool checkTypes(Schema); +static bool checkEnts(Schema); +static void markDescs(Entity); +static bool checkItem(Type, Scope, Schema, int *, int); +static int ENUMcanBeProcessed(Type, Schema); +static int inSchema(Scope, Scope); +static void addRenameTypedefs(Schema, FILE *); +static void addAggrTypedefs(Schema, FILE *); +static void addUseRefNames(Schema, FILE *); /** * Generates the C++ files corresponding to a list of schemas. Does so in @@ -63,44 +63,45 @@ static void addUseRefNames( Schema, FILE * ); * select types which have enum or select items (or entities containing * enums) which have not been processed. */ -void print_schemas_separate( Express express, void * complexCol, FILES * files ) { +void print_schemas_separate(Express express, void *complexCol, FILES *files) +{ bool complete = false; int val1, val2, suffix; DictionaryEntry de; Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks( express ); + initializeMarks(express); /* TODO only print gr, wr, str as needed, from SCHEMAprint in classes_wrapper.cc? */ - fprintf( files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n" ); + fprintf(files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n"); - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - numberAttributes( schema ); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + numberAttributes(schema); } - while( !complete ) { + while(!complete) { complete = true; - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - if( schema->search_id == UNPROCESSED ) { + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + if(schema->search_id == UNPROCESSED) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs( schema ); + unsetObjs(schema); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes( schema ); - val2 = checkEnts( schema ); + val1 = checkTypes(schema); + val2 = checkEnts(schema); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if( val1 || val2 ) { - if( schema->search_id == UNPROCESSED || - *( int * )schema->clientData > 0 ) { + if(val1 || val2) { + if(schema->search_id == UNPROCESSED || + *(int *)schema->clientData > 0) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -110,13 +111,13 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files ) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*( int * )schema->clientData; - SCHEMAprint( schema, files, complexCol, suffix ); + suffix = ++*(int *)schema->clientData; + SCHEMAprint(schema, files, complexCol, suffix); } else { - SCHEMAprint( schema, files, complexCol, 0 ); + SCHEMAprint(schema, files, complexCol, 0); } } - complete = complete && ( schema->search_id == PROCESSED ); + complete = complete && (schema->search_id == PROCESSED); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -126,53 +127,53 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files ) /******************* *******************/ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - fprintf( files->create, - "//////////////// USE statements\n" ); - USEREFout( schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create ); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + fprintf(files->create, + "//////////////// USE statements\n"); + USEREFout(schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create); - fprintf( files->create, - "//////////////// REFERENCE statements\n" ); - USEREFout( schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create ); + fprintf(files->create, + "//////////////// REFERENCE statements\n"); + USEREFout(schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create); } /***************** *****************/ /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addRenameTypedefs( schema, files->classes ); - addUseRefNames( schema, files->create ); + addRenameTypedefs(schema, files->classes); + addUseRefNames(schema, files->create); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - addAggrTypedefs( schema, files->classes ); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + addAggrTypedefs(schema, files->classes); } /* On our way out, print the necessary statements to add support for // complex entities. (The 1st line below is a part of SchemaInit(), // which hasn't been closed yet. (That's done on 2nd line below.)) */ - fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); - fprintf( files->initall, "}\n\n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); + fprintf(files->initall, " reg.SetCompCollect( gencomplex() );\n"); + fprintf(files->initall, "}\n\n"); + fprintf(files->incall, "\n#include \n"); + fprintf(files->incall, "ComplexCollect *gencomplex();\n"); /* Function GetModelContents() is printed at the end of the schema.xx // files. This is done in a separate loop through the schemas, in function // below. */ - getMCPrint( express, files->incall, files->initall ); + getMCPrint(express, files->incall, files->initall); /* Finally clean up memory allocated by initializeMarks. */ - cleanupMarks( express ); + cleanupMarks(express); } -static void initializeMarks( Express express ) +static void initializeMarks(Express express) /* * Set all schema->search_id's to UNPROCESSED, meaning we haven't processed * all the ents and types in it yet. Also, put an int=0 in each schema's @@ -186,34 +187,35 @@ static void initializeMarks( Express express ) DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de_sch)) != 0) { schema->search_id = UNPROCESSED; - schema->clientData = ( int * )sc_malloc( sizeof( int ) ); - *( int * )schema->clientData = 0; - SCOPEdo_entities( schema, ent, de_ent ) + schema->clientData = (int *)sc_malloc(sizeof(int)); + *(int *)schema->clientData = 0; + SCOPEdo_entities(schema, ent, de_ent) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types( schema, t, de_type ) + SCOPEdo_types(schema, t, de_type) t->search_id = NOTKNOWN; SCOPEod } } -static void cleanupMarks( Express express ) { +static void cleanupMarks(Express express) +{ DictionaryEntry de_sch; Schema schema; - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { - if( schema->clientData ) { - sc_free( schema->clientData ); + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de_sch)) != 0) { + if(schema->clientData) { + sc_free(schema->clientData); schema->clientData = NULL; } } } -static void unsetObjs( Schema schema ) +static void unsetObjs(Schema schema) /* * Resets all the ents & types of schema which had been set to CANTPROCRSS * to NOTKNOWN. This function is called every time print_schemas_separate @@ -226,13 +228,13 @@ static void unsetObjs( Schema schema ) { DictionaryEntry de; - SCOPEdo_types( schema, t, de ) - if( t->search_id == CANTPROCESS ) { + SCOPEdo_types(schema, t, de) + if(t->search_id == CANTPROCESS) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities( schema, ent, de ) - if( ent->search_id == CANTPROCESS ) { + SCOPEdo_entities(schema, ent, de) + if(ent->search_id == CANTPROCESS) { ent->search_id = NOTKNOWN; } SCOPEod @@ -250,7 +252,8 @@ static void unsetObjs( Schema schema ) * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static bool checkTypes( Schema schema ) { +static bool checkTypes(Schema schema) +{ DictionaryEntry de; bool retval = false; int unknowncnt; @@ -260,8 +263,8 @@ static bool checkTypes( Schema schema ) { do { unknowncnt = 0; - SCOPEdo_types( schema, type, de ) { - if( type->search_id != NOTKNOWN ) { + SCOPEdo_types(schema, type, de) { + if(type->search_id != NOTKNOWN) { continue; } /* We're only interested in the ones which haven't been processed @@ -270,9 +273,9 @@ static bool checkTypes( Schema schema ) { type->search_id = CANPROCESS; /* Assume this until disproven. */ - if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { - i = TYPEget_ancestor( type ); - if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { + if(TYPEis_enumeration(type) && TYPEget_head(type)) { + i = TYPEget_ancestor(type); + if(!sameSchema(i, type) && i->search_id != PROCESSED) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -281,10 +284,10 @@ static bool checkTypes( Schema schema ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if( TYPEis_select( type ) ) { - LISTdo( SEL_TYPEget_items( type ), ii, Type ) { - if( !TYPEis_entity( ii ) ) { - if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { + } else if(TYPEis_select(type)) { + LISTdo(SEL_TYPEget_items(type), ii, Type) { + if(!TYPEis_entity(ii)) { + if(checkItem(ii, type, schema, &unknowncnt, 0)) { break; } /* checkItem does most of the work of determining if @@ -298,8 +301,8 @@ static bool checkTypes( Schema schema ) { } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity( ii ); - if( ent->search_id == PROCESSED ) { + ent = ENT_TYPEget_entity(ii); + if(ent->search_id == PROCESSED) { continue; } /* If entity has been processed already, things must be @@ -309,31 +312,33 @@ static bool checkTypes( Schema schema ) { // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes( ent ); - LISTdo_n( attribs, attr, Variable, z ) { - if( checkItem( attr->type, type, schema, - &unknowncnt, 1 ) ) { + attribs = ENTITYget_all_attributes(ent); + LISTdo_n(attribs, attr, Variable, z) { + if(checkItem(attr->type, type, schema, + &unknowncnt, 1)) { break; } - } LISTod - LISTfree( attribs ); + } + LISTod + LISTfree(attribs); } - } LISTod + } + LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if( ( type->search_id == CANPROCESS ) - && ( ( i = TYPEget_ancestor( type ) ) != NULL ) - && ( !sameSchema( i, type ) ) - && ( i->search_id != PROCESSED ) ) { + if((type->search_id == CANPROCESS) + && ((i = TYPEget_ancestor(type)) != NULL) + && (!sameSchema(i, type)) + && (i->search_id != PROCESSED)) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if( type->search_id == CANPROCESS ) { + if(type->search_id == CANPROCESS) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -341,8 +346,9 @@ static bool checkTypes( Schema schema ) { // go on. */ retval = true; } - } SCOPEod - } while( unknowncnt > 0 ); + } + SCOPEod + } while(unknowncnt > 0); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -376,14 +382,15 @@ static bool checkTypes( Schema schema ) { * of the inline commenting of checkTypes() is applicable here and is not * repeated.) */ -static bool checkEnts( Schema schema ) { +static bool checkEnts(Schema schema) +{ DictionaryEntry de; bool retval = false; int ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities( schema, ent, de ) - if( ent->search_id != NOTKNOWN ) { + SCOPEdo_entities(schema, ent, de) + if(ent->search_id != NOTKNOWN) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -395,10 +402,10 @@ static bool checkEnts( Schema schema ) { /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo( ENTITYget_supertypes( ent ), super, Entity ) - if( ( !sameSchema( ent, super ) ) - && ( super->search_id != PROCESSED ) ) { - markDescs( ent ); + LISTdo(ENTITYget_supertypes(ent), super, Entity) + if((!sameSchema(ent, super)) + && (super->search_id != PROCESSED)) { + markDescs(ent); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -408,17 +415,17 @@ static bool checkEnts( Schema schema ) { /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if( ent->search_id == CANPROCESS ) { + if(ent->search_id == CANPROCESS) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo( ENTITYget_attributes( ent ), attr, Variable ) - if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { - markDescs( ent ); + LISTdo(ENTITYget_attributes(ent), attr, Variable) + if(checkItem(attr->type, ent, schema, &ignore, 0)) { + markDescs(ent); break; } LISTod } - if( ent->search_id == CANPROCESS ) { + if(ent->search_id == CANPROCESS) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -439,11 +446,13 @@ static bool checkEnts( Schema schema ) { * function is called if we've determined that ent is a subtype of an * entity defined in a different schema which has not yet been processed. */ -static void markDescs( Entity ent ) { +static void markDescs(Entity ent) +{ ent->search_id = CANTPROCESS; - LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) { - markDescs( sub ); - } LISTod + LISTdo(ENTITYget_subtypes(ent), sub, Entity) { + markDescs(sub); + } + LISTod } /** @@ -468,11 +477,12 @@ static void markDescs( Entity ent ) { * noSel is set to 1 to tell it to worry about t if it's an enum but not * if it's a select. */ -static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, int noSel ) { +static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int noSel) +{ Type i = t; - if( isAggregateType( t ) ) { - i = TYPEget_base_type( t ); + if(isAggregateType(t)) { + i = TYPEget_base_type(t); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -481,26 +491,26 @@ static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, in // Sdaiclasses.h. */ } - if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { + if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if( parent->search_id == NOTKNOWN ) { + if(parent->search_id == NOTKNOWN) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - ( *unknowncnt )--; + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if( TYPEis_select( i ) && !noSel ) { - if( !sameSchema( i, parent ) ) { - if( i->search_id != PROCESSED ) { - if( parent->search_id == NOTKNOWN ) { - ( *unknowncnt )--; + } else if(TYPEis_select(i) && !noSel) { + if(!sameSchema(i, parent)) { + if(i->search_id != PROCESSED) { + if(parent->search_id == NOTKNOWN) { + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -510,24 +520,24 @@ static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, in /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if( i->search_id == CANTPROCESS ) { + if(i->search_id == CANTPROCESS) { /* We *have* checked i already and it can't be processed. */ - if( parent->search_id == NOTKNOWN ) { - ( *unknowncnt )--; + if(parent->search_id == NOTKNOWN) { + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if( i->search_id == NOTKNOWN ) { + } else if(i->search_id == NOTKNOWN) { /* We haven't processed i this pass. */ - if( parent->search_id != NOTKNOWN ) { + if(parent->search_id != NOTKNOWN) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping thru the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - ( *unknowncnt )++; + (*unknowncnt)++; } } } @@ -535,7 +545,7 @@ static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, in return false; } -static int ENUMcanBeProcessed( Type e, Schema s ) +static int ENUMcanBeProcessed(Type e, Schema s) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -547,31 +557,31 @@ static int ENUMcanBeProcessed( Type e, Schema s ) { Type a; - if( !inSchema( e, s ) ) { + if(!inSchema(e, s)) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return ( e->search_id == PROCESSED ); + return (e->search_id == PROCESSED); } - if( e->search_id != NOTKNOWN ) { + if(e->search_id != NOTKNOWN) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return ( e->search_id >= CANPROCESS ); + return (e->search_id >= CANPROCESS); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if( ( a = TYPEget_ancestor( e ) ) == NULL ) { + if((a = TYPEget_ancestor(e)) == NULL) { /* If e is not a rename of anything, it should be processed now. */ return true; } - if( inSchema( a, s ) || a->search_id == PROCESSED ) { + if(inSchema(a, s) || a->search_id == PROCESSED) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return true; @@ -579,23 +589,23 @@ static int ENUMcanBeProcessed( Type e, Schema s ) return false; } -int sameSchema( Scope sc1, Scope sc2 ) +int sameSchema(Scope sc1, Scope sc2) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return ( !strcmp( SCOPEget_name( sc1->superscope ), - SCOPEget_name( sc2->superscope ) ) ); + return (!strcmp(SCOPEget_name(sc1->superscope), + SCOPEget_name(sc2->superscope))); } -static int inSchema( Scope scope, Scope super ) +static int inSchema(Scope scope, Scope super) /* * Checks if scope is contained in super's scope. */ { - return ( !strcmp( SCOPEget_name( scope->superscope ), - SCOPEget_name( super ) ) ); + return (!strcmp(SCOPEget_name(scope->superscope), + SCOPEget_name(super))); } /** @@ -605,42 +615,44 @@ static int inSchema( Scope scope, Scope super ) * (Actually, for the enum only the aggregate class name is written in * Sdaiclasses.h (needs to have forward declarations here).) */ -static void addRenameTypedefs( Schema schema, FILE * classes ) { +static void addRenameTypedefs(Schema schema, FILE *classes) +{ DictionaryEntry de; Type i; char nm[BUFSIZ], basenm[BUFSIZ]; static bool firsttime = true; - SCOPEdo_types( schema, t, de ) { - if( ( TYPEis_enumeration( t ) || TYPEis_select( t ) ) - && ( ( i = TYPEget_ancestor( t ) ) != NULL ) ) { + SCOPEdo_types(schema, t, de) { + if((TYPEis_enumeration(t) || TYPEis_select(t)) + && ((i = TYPEget_ancestor(t)) != NULL)) { /* I.e., t is a renamed enum/sel type. i is set to the orig enum/ // sel t is based on (in case it's a rename of a rename etc). */ - if( firsttime ) { - fprintf( classes, "\n// Renamed enum and select" ); - fprintf( classes, " types (from all schemas):\n" ); + if(firsttime) { + fprintf(classes, "\n// Renamed enum and select"); + fprintf(classes, " types (from all schemas):\n"); firsttime = false; } - if( TYPEis_enumeration( t ) ) { - strncpy( nm, TYPEget_ctype( t ), BUFSIZ - 1 ); - nm[BUFSIZ-1] = '\0'; - strncpy( basenm, TYPEget_ctype( i ), BUFSIZ - 1 ); - basenm[BUFSIZ-1] = '\0'; - fprintf( classes, "typedef %s_agg %s_agg;\n", basenm, nm ); + if(TYPEis_enumeration(t)) { + strncpy(nm, TYPEget_ctype(t), BUFSIZ - 1); + nm[BUFSIZ - 1] = '\0'; + strncpy(basenm, TYPEget_ctype(i), BUFSIZ - 1); + basenm[BUFSIZ - 1] = '\0'; + fprintf(classes, "typedef %s_agg %s_agg;\n", basenm, nm); } else { - strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ - 1 ); - nm[BUFSIZ-1] = '\0'; - strncpy( basenm, SelectName( TYPEget_name( i ) ), BUFSIZ - 1 ); - basenm[BUFSIZ-1] = '\0'; - fprintf( classes, "typedef %s %s;\n", basenm, nm ); - fprintf( classes, "typedef %s_agg %s_agg;\n\n", basenm, nm ); - fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); - fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); + strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ - 1); + nm[BUFSIZ - 1] = '\0'; + strncpy(basenm, SelectName(TYPEget_name(i)), BUFSIZ - 1); + basenm[BUFSIZ - 1] = '\0'; + fprintf(classes, "typedef %s %s;\n", basenm, nm); + fprintf(classes, "typedef %s_agg %s_agg;\n\n", basenm, nm); + fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); + fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); } } - } SCOPEod + } + SCOPEod } /** @@ -650,33 +662,35 @@ static void addRenameTypedefs( Schema schema, FILE * classes ) { * called after addRenameTypedefs() since an aggregate may also be based on * one of the renamed enum/sel's defined there. */ -static void addAggrTypedefs( Schema schema, FILE * classes ) { +static void addAggrTypedefs(Schema schema, FILE *classes) +{ DictionaryEntry de; Type i; static bool firsttime = true; char nm[BUFSIZ]; - SCOPEdo_types( schema, t, de ) { - if( TYPEis_aggregate( t ) ) { - i = TYPEget_base_type( t ); - if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { + SCOPEdo_types(schema, t, de) { + if(TYPEis_aggregate(t)) { + i = TYPEget_base_type(t); + if(TYPEis_enumeration(i) || TYPEis_select(i)) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - if( firsttime ) { - fprintf( classes, "\n// Aggregate types (from all schemas) which depend on other types:\n" ); + if(firsttime) { + fprintf(classes, "\n// Aggregate types (from all schemas) which depend on other types:\n"); firsttime = false; } - strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); - nm[BUFSIZ-1] = '\0'; - fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); - fprintf( classes, "typedef %s * %sH;\n", nm, nm ); - fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); - fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); + nm[BUFSIZ - 1] = '\0'; + fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); + fprintf(classes, "typedef %s * %sH;\n", nm, nm); + fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); + fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); } } - } SCOPEod + } + SCOPEod } /** @@ -687,62 +701,63 @@ static void addAggrTypedefs( Schema schema, FILE * classes ) { * list will be used in the SCL to use the correct name of this type or * entity when reading and writing files. */ -static void addUseRefNames( Schema schema, FILE * create ) { +static void addUseRefNames(Schema schema, FILE *create) +{ Dictionary useRefDict; DictionaryEntry de; - Rename * rnm; - char * oldnm, schNm[BUFSIZ]; + Rename *rnm; + char *oldnm, schNm[BUFSIZ]; static bool firsttime = true; - if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { - DICTdo_init( useRefDict, &de ); - while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { - oldnm = ( ( Scope )rnm->object )->symbol.name; - if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if((useRefDict = schema->u.schema->usedict) != NULL) { + DICTdo_init(useRefDict, &de); + while((rnm = (Rename *)DICTdo(&de)) != 0) { + oldnm = ((Scope)rnm->object)->symbol.name; + if((strcmp(oldnm, rnm->nnew->name))) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if( firsttime ) { - fprintf( create, " // Alternate names for types and entities when used in other schemas:\n" ); + if(firsttime) { + fprintf(create, " // Alternate names for types and entities when used in other schemas:\n"); firsttime = false; } - if( rnm->type == OBJ_TYPE ) { - fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); + if(rnm->type == OBJ_TYPE) { + fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); } else { /* must be an entity */ - fprintf( create, " %s%s%s", - SCOPEget_name( ( ( Entity )rnm->object )->superscope ), - ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); + fprintf(create, " %s%s%s", + SCOPEget_name(((Entity)rnm->object)->superscope), + ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); } - strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); - fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName( rnm->nnew->name ) ); + strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); + fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName(rnm->nnew->name)); } } } - if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { - DICTdo_init( useRefDict, &de ); - while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { - oldnm = ( ( Scope )rnm->object )->symbol.name; - if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { - if( firsttime ) { - fprintf( create, " // Alternate names for types and " ); - fprintf( create, "entities when used in other schemas:\n" ); + if((useRefDict = schema->u.schema->refdict) != NULL) { + DICTdo_init(useRefDict, &de); + while((rnm = (Rename *)DICTdo(&de)) != 0) { + oldnm = ((Scope)rnm->object)->symbol.name; + if((strcmp(oldnm, rnm->nnew->name))) { + if(firsttime) { + fprintf(create, " // Alternate names for types and "); + fprintf(create, "entities when used in other schemas:\n"); firsttime = false; } - if( rnm->type == OBJ_TYPE ) { - fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); + if(rnm->type == OBJ_TYPE) { + fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); } else { - fprintf( create, " %s%s%s", - SCOPEget_name( ( ( Entity )rnm->object )->superscope ), - ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); + fprintf(create, " %s%s%s", + SCOPEget_name(((Entity)rnm->object)->superscope), + ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); } - strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); - fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName( rnm->nnew->name ) ); + strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); + fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName(rnm->nnew->name)); } } } diff --git a/src/exp2cxx/non-ors.cc b/src/exp2cxx/non-ors.cc index 2ef5dd803..8a4b24acf 100644 --- a/src/exp2cxx/non-ors.cc +++ b/src/exp2cxx/non-ors.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -MatchType SimpleList::matchNonORs( EntNode * ents ) +MatchType SimpleList::matchNonORs(EntNode *ents) /* * Checks if we match the nodes of ents. If only one unmarked is left * and we match it, return MATCHALL. More likely, we'll return one of the @@ -21,12 +21,12 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) * Support.h.) */ { - EntNode * eptr = ents; + EntNode *eptr = ents; int comp; - while( eptr != NULL ) { - if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { - if( ! eptr->marked( MARK ) ) { + while(eptr != NULL) { + if((comp = strcmp(name, eptr->name)) == 0) { + if(! eptr->marked(MARK)) { // NOTE - this cond also returns TRUE if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -35,13 +35,13 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if( eptr->mark == NOMARK ) { + if(eptr->mark == NOMARK) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if( ents->allMarked() ) { + if(ents->allMarked()) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -55,7 +55,7 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if( comp < 0 ) { + if(comp < 0) { // We're beyond name in the ents list. No more checking to do. break; } @@ -68,7 +68,7 @@ MatchType SimpleList::matchNonORs( EntNode * ents ) return UNSATISFIED; } -MatchType AndOrList::matchNonORs( EntNode * ents ) +MatchType AndOrList::matchNonORs(EntNode *ents) /* * Loop through the children of this matching as many of the nodes of ents * as we can. We skip all OrList descendants. Those are processed later @@ -77,12 +77,12 @@ MatchType AndOrList::matchNonORs( EntNode * ents ) * which are unnec. */ { - EntList * child = childList->firstNot( OR ); + EntList *child = childList->firstNot(OR); MatchType retval; - while( child != NULL ) { - if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { - if( prevKnown( child ) ) { + while(child != NULL) { + if((retval = child->matchNonORs(ents)) == MATCHALL) { + if(prevKnown(child)) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -109,39 +109,39 @@ MatchType AndOrList::matchNonORs( EntNode * ents ) // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if( retval == UNSATISFIED ) { + } else if(retval == UNSATISFIED) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll( ents ); + child->unmarkAll(ents); } - child = child->nextNot( OR ); + child = child->nextNot(OR); } - setViableVal( ents ); + setViableVal(ents); return viable; } -MatchType AndList::matchNonORs( EntNode * ents ) +MatchType AndList::matchNonORs(EntNode *ents) /* * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ { - EntList * child = childList->firstNot( OR ); + EntList *child = childList->firstNot(OR); - while( child != NULL ) { - if( child->matchNonORs( ents ) == UNSATISFIED ) { + while(child != NULL) { + if(child->matchNonORs(ents) == UNSATISFIED) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot( OR ); + child = child->nextNot(OR); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal( ents ); + setViableVal(ents); return viable; } diff --git a/src/exp2cxx/orlist.cc b/src/exp2cxx/orlist.cc index dd0c9db88..4b90b01cf 100644 --- a/src/exp2cxx/orlist.cc +++ b/src/exp2cxx/orlist.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -int OrList::hit( const char * nm ) +int OrList::hit(const char *nm) /* * Check if we matched nm. We have two possibilities here: If we have a * choice selected, we only check the selected choice. Say we're an OR @@ -27,15 +27,15 @@ int OrList::hit( const char * nm ) * may need to check if all sub-CLists matched the multi-sub, C.) */ { - EntList * child = getChild( choice ); + EntList *child = getChild(choice); - if( child ) { + if(child) { // I.e., if we have a choice selected, check it only. - return ( child->hit( nm ) ); + return (child->hit(nm)); } else { child = childList; - while( child ) { - if( child->viable > UNSATISFIED && child->hit( nm ) ) { + while(child) { + if(child->viable > UNSATISFIED && child->hit(nm)) { // See MultList::hit() on why we must skip UNSATs. return TRUE; } @@ -45,20 +45,20 @@ int OrList::hit( const char * nm ) return FALSE; } -void OrList::unmarkAll( EntNode * ents ) +void OrList::unmarkAll(EntNode *ents) /* * Unmarks all the nodes of ents marked by the descendants of this. */ { - EntList * child; + EntList *child; - if( ( child = getChild( choice ) ) != NULL ) { + if((child = getChild(choice)) != NULL) { // choice = the last selected path which we'll now undo. - child->unmarkAll( ents ); + child->unmarkAll(ents); } } -int OrList::acceptChoice( EntNode * ents ) +int OrList::acceptChoice(EntNode *ents) /* * Accepts the first choice of our childList which marks any unmarked * nodes. If none of our current choices mark anything, choice is set to @@ -66,14 +66,14 @@ int OrList::acceptChoice( EntNode * ents ) * choice to choice1, and search again. */ { - EntList * child; + EntList *child; - if( choice == LISTEND ) { + if(choice == LISTEND) { choice = choice1; } - child = getChild( choice ); - while( child ) { - if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { + child = getChild(choice); + while(child) { + if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { // acceptChoice() returns TRUE if we marked something. return TRUE; } diff --git a/src/exp2cxx/print.cc b/src/exp2cxx/print.cc index 0b1398a6d..837592405 100644 --- a/src/exp2cxx/print.cc +++ b/src/exp2cxx/print.cc @@ -11,14 +11,14 @@ #include // Local function prototypes: -static char * joinText( JoinType, char * ); +static char *joinText(JoinType, char *); -ostream & operator << ( ostream & os, ComplexList & clist ) +ostream &operator << (ostream &os, ComplexList &clist) /* * Prints out a ComplexList, by iterating through its children. */ { - os << "ComplexList - \"" << *( SimpleList * )clist.head->childList + os << "ComplexList - \"" << *(SimpleList *)clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -26,20 +26,20 @@ ostream & operator << ( ostream & os, ComplexList & clist ) return os; } -ostream & operator << ( ostream & os, EntList & list ) +ostream &operator << (ostream &os, EntList &list) /* * Prints out an EntList. Calls appropriate function based on JoinType. */ { - if( list.join == SIMPLE ) { - os << *( SimpleList * )&list; + if(list.join == SIMPLE) { + os << *(SimpleList *)&list; } else { - os << *( MultList * )&list; + os << *(MultList *)&list; } return os; } -ostream & operator << ( ostream & os, SimpleList & slist ) +ostream &operator << (ostream &os, SimpleList &slist) /* * Prints out a SimpleList. */ @@ -48,7 +48,7 @@ ostream & operator << ( ostream & os, SimpleList & slist ) return os; } -ostream & operator << ( ostream & os, MultList & mlist ) +ostream &operator << (ostream &os, MultList &mlist) /* * Prints out a MultList. */ @@ -57,21 +57,21 @@ ostream & operator << ( ostream & os, MultList & mlist ) int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList * child = mlist.childList; + EntList *child = mlist.childList; - os << joinText( mlist.join, jointype ) << endl; - for( k = 0; k <= mlist.level; k++ ) { + os << joinText(mlist.join, jointype) << endl; + for(k = 0; k <= mlist.level; k++) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while( child != NULL ) { + while(child != NULL) { os << *child; - if( child->next == NULL ) { - lastSimple = ( child->join == SIMPLE ); + if(child->next == NULL) { + lastSimple = (child->join == SIMPLE); break; // We don't want to do the conditions below if we're done. } - if( child->join == SIMPLE ) { + if(child->join == SIMPLE) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -79,35 +79,35 @@ ostream & operator << ( ostream & os, MultList & mlist ) // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for( k = 0; k <= mlist.level; k++ ) { + for(k = 0; k <= mlist.level; k++) { os << " "; } } child = child->next; } - if( lastSimple ) { + if(lastSimple) { os << endl; } return os; } -static char * joinText( JoinType j, char * buf ) +static char *joinText(JoinType j, char *buf) /* * Copies and returns the string equivalent of a JoinType. */ { - switch( j ) { + switch(j) { case SIMPLE: - strcpy( buf, "SIMPLE" ); + strcpy(buf, "SIMPLE"); return buf; case AND: - strcpy( buf, "AND" ); + strcpy(buf, "AND"); return buf; case OR: - strcpy( buf, "OR" ); + strcpy(buf, "OR"); return buf; case ANDOR: - strcpy( buf, "ANDOR" ); + strcpy(buf, "ANDOR"); return buf; }; return NULL; diff --git a/src/exp2cxx/rules.c b/src/exp2cxx/rules.c index 6dfe7aa96..3d39a3080 100644 --- a/src/exp2cxx/rules.c +++ b/src/exp2cxx/rules.c @@ -5,57 +5,62 @@ #include /* print Where_rule's. for types, schema should be null - tename will include schema name */ -void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ) { - if( wheres ) { - fprintf( impl, " %s%s%s->_where_rules = new Where_rule__list;\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); - if( needWR ) { - fprintf( impl, " Where_rule * wr;\n" ); +void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR) +{ + if(wheres) { + fprintf(impl, " %s%s%s->_where_rules = new Where_rule__list;\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); + if(needWR) { + fprintf(impl, " Where_rule * wr;\n"); } - LISTdo( wheres, w, Where ) { - fprintf( impl, " str.clear();\n"); - if( w->label ) { - fprintf( impl, " str.append( \"%s: (\" );\n", w->label->name ); + LISTdo(wheres, w, Where) { + fprintf(impl, " str.clear();\n"); + if(w->label) { + fprintf(impl, " str.append( \"%s: (\" );\n", w->label->name); } else { /* no label */ - fprintf( impl, " str.append( \"(\" );\n"); + fprintf(impl, " str.append( \"(\" );\n"); } - format_for_std_stringout( impl, EXPRto_string( w->expr ) ); + format_for_std_stringout(impl, EXPRto_string(w->expr)); - fprintf( impl, " str.append( \");\\n\" );\n"); + fprintf(impl, " str.append( \");\\n\" );\n"); - fprintf( impl, " wr = new Where_rule( str.c_str() );\n" ); - fprintf( impl, " %s%s%s->_where_rules->Append( wr );\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); + fprintf(impl, " wr = new Where_rule( str.c_str() );\n"); + fprintf(impl, " %s%s%s->_where_rules->Append( wr );\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); - } LISTod + } + LISTod } } /* print Uniqueness_rule's */ -void UNIQUEprint( Entity entity, FILE * impl, Schema schema ) { +void UNIQUEprint(Entity entity, FILE *impl, Schema schema) +{ Linked_List uniqs = entity->u.entity->unique; - if( uniqs ) { - fprintf( impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - fprintf( impl, " Uniqueness_rule * ur;\n" ); - LISTdo( uniqs, list, Linked_List ) { + if(uniqs) { + fprintf(impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf(impl, " Uniqueness_rule * ur;\n"); + LISTdo(uniqs, list, Linked_List) { int i = 0; - fprintf( impl, " str.clear();\n"); - LISTdo_n( list, e, Expression, b ) { + fprintf(impl, " str.clear();\n"); + LISTdo_n(list, e, Expression, b) { i++; - if( i == 1 ) { + if(i == 1) { /* print label if present */ - if( e ) { - fprintf( impl, " str.append( \"%s : \" );\n", StrToUpper( ( ( Symbol * )e )->name ) ); + if(e) { + fprintf(impl, " str.append( \"%s : \" );\n", StrToUpper(((Symbol *)e)->name)); } } else { - if( i > 2 ) { - fprintf( impl, " str.append( \", \" );\n"); + if(i > 2) { + fprintf(impl, " str.append( \", \" );\n"); } - format_for_std_stringout( impl, EXPRto_string( e ) ); + format_for_std_stringout(impl, EXPRto_string(e)); } - } LISTod - fprintf( impl, " ur = new Uniqueness_rule( str.c_str() );\n" ); - fprintf( impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - } LISTod + } + LISTod + fprintf(impl, " ur = new Uniqueness_rule( str.c_str() );\n"); + fprintf(impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + } + LISTod } } diff --git a/src/exp2cxx/rules.h b/src/exp2cxx/rules.h index 6f6e77cfb..3ad7d8d32 100644 --- a/src/exp2cxx/rules.h +++ b/src/exp2cxx/rules.h @@ -4,10 +4,10 @@ #include /** print Where_rule's. for types, schema should be null - tename will include schema name + type prefix */ -void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ); +void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR); /** print Uniqueness_rule's. only Entity type has them? */ -void UNIQUEprint( Entity entity, FILE * impl, Schema schema ); +void UNIQUEprint(Entity entity, FILE *impl, Schema schema); #endif /* RULES_H */ diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index afd490832..8bb9bb520 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -52,28 +52,31 @@ extern int multiple_inheritance; #define TRUE 1 #define FALSE 0 -static void initSelItems( const Type, FILE * ); +static void initSelItems(const Type, FILE *); -const char * SEL_ITEMget_enumtype( Type t ) { - return StrToUpper( TYPEget_name( t ) ); +const char *SEL_ITEMget_enumtype(Type t) +{ + return StrToUpper(TYPEget_name(t)); } /** \returns type used to represent the underlying type in a select class */ -const char * TYPEget_utype( Type t ) { - return ( TYPEis_entity( t ) ? "SDAI_Application_instance_ptr" : TYPEget_ctype( t ) ); +const char *TYPEget_utype(Type t) +{ + return (TYPEis_entity(t) ? "SDAI_Application_instance_ptr" : TYPEget_ctype(t)); } /** determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. */ -void *LISTmember( const Linked_List list, void *e ) { +void *LISTmember(const Linked_List list, void *e) +{ Link node; - for( node = list->mark->next; node != list->mark; node = node->next ) - if( e == node -> data ) { + for(node = list->mark->next; node != list->mark; node = node->next) + if(e == node -> data) { return e; } - return ( 0 ); + return (0); } /** Specialized function to catch if two enumerations, two selects, or two aggrs @@ -84,18 +87,19 @@ void *LISTmember( const Linked_List list, void *e ) { equivalent. This function is called in instances when they should be consi- dered equivalent. One such case is the generation of duplicate lists. */ -static int compareOrigTypes( Type a, Type b ) { +static int compareOrigTypes(Type a, Type b) +{ Type t, u; - if( ( TYPEis_select( a ) && TYPEis_select( b ) ) - || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { + if((TYPEis_select(a) && TYPEis_select(b)) + || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { t = a; u = b; - } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { - t = TYPEget_base_type( a ); - u = TYPEget_base_type( b ); - if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) - || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { + } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { + t = TYPEget_base_type(a); + u = TYPEget_base_type(b); + if(!((TYPEis_select(t) && TYPEis_select(u)) + || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that for 2D aggrs and higher we do not continue. These are all recog- @@ -106,13 +110,13 @@ static int compareOrigTypes( Type a, Type b ) { return FALSE; } - if( TYPEget_head( t ) ) { - t = TYPEget_ancestor( t ); + if(TYPEget_head(t)) { + t = TYPEget_ancestor(t); } - if( TYPEget_head( u ) ) { - u = TYPEget_ancestor( u ); + if(TYPEget_head(u)) { + u = TYPEget_ancestor(u); } - return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); + return (!strcmp(TYPEget_name(t), TYPEget_name(u))); } /** determines if the given "link's" underlying type is a member of the list. @@ -122,19 +126,20 @@ static int compareOrigTypes( Type a, Type b ) { list already has an item that check is a renaming of (see header comments to compareOrigTypes() above). */ -const char * utype_member( const Linked_List list, const Type check, int rename ) { +const char *utype_member(const Linked_List list, const Type check, int rename) +{ static char r [BUFSIZ]; - bool checkIsEntity = TYPEis_entity( check ); + bool checkIsEntity = TYPEis_entity(check); - LISTdo( list, t, Type ) { - if( TYPEis_entity( t ) && checkIsEntity ) { + LISTdo(list, t, Type) { + if(TYPEis_entity(t) && checkIsEntity) { return "SDAI_Application_instance_ptr"; } /* string returned by TYPEget_utype isn't necessarily static so we * need to copy between calls * */ - strncpy( r, TYPEget_ctype( t ), BUFSIZ ); - if( strcmp( r, TYPEget_ctype( check ) ) == 0 || ( rename && compareOrigTypes( check, t ) ) ) { + strncpy(r, TYPEget_ctype(t), BUFSIZ); + if(strcmp(r, TYPEget_ctype(check)) == 0 || (rename && compareOrigTypes(check, t))) { return r; } } @@ -148,15 +153,16 @@ const char * utype_member( const Linked_List list, const Type check, int rename * * The list that is returned needs to be freed by the caller. */ -Linked_List SELgetnew_dmlist( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +Linked_List SELgetnew_dmlist(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); - LISTdo( complete, t, Type ) + LISTdo(complete, t, Type) /* if t\'s underlying type is not already in newlist, */ - if( ! utype_member( newlist, t, 0 ) ) { - LISTadd_last( newlist, t ); + if(! utype_member(newlist, t, 0)) { + LISTadd_last(newlist, t); } LISTod; @@ -165,9 +171,10 @@ Linked_List SELgetnew_dmlist( const Type type ) { } -const char * SEL_ITEMget_dmtype( Type t, const Linked_List l ) { - const char * r = utype_member( l, t, 0 ); - return StrToLower( r ? r : TYPEget_utype( t ) ); +const char *SEL_ITEMget_dmtype(Type t, const Linked_List l) +{ + const char *r = utype_member(l, t, 0); + return StrToLower(r ? r : TYPEget_utype(t)); } @@ -176,48 +183,50 @@ const char * SEL_ITEMget_dmtype( Type t, const Linked_List l ) { * Logical and boolean are handled as exceptions because TYPEget_utype() * returns "PSDAI::..." for them which is not a legal variable name. */ -const char * SEL_ITEMget_dmname( Type t ) { - Class_Of_Type class = TYPEget_type( t ); +const char *SEL_ITEMget_dmname(Type t) +{ + Class_Of_Type class = TYPEget_type(t); - if( class == integer_ ) { + if(class == integer_) { return "integer"; } - if( class == real_ ) { + if(class == real_) { return "real"; } - if( class == number_ ) { + if(class == number_) { return "real"; } - if( class == string_ ) { + if(class == string_) { return "string"; } - if( class == binary_ ) { + if(class == binary_) { return "binary"; } - if( class == logical_ ) { + if(class == logical_) { return "logical"; } - if( class == boolean_ ) { + if(class == boolean_) { return "boolean"; } - if( class == entity_ ) { + if(class == entity_) { return "app_inst"; } - return ( StrToLower( TYPEget_utype( t ) ) ); + return (StrToLower(TYPEget_utype(t))); } /** determines if the given "link's" underlying type is a multiple member of the list. RETURNS 1 if true, else 0. */ -int duplicate_in_express_list( const Linked_List list, const Type check ) { - if( TYPEis_entity( check ) ) { +int duplicate_in_express_list(const Linked_List list, const Type check) +{ + if(TYPEis_entity(check)) { return FALSE; } /* entities are never the same */ - LISTdo( list, t, Type ) - if( t == check ) { + LISTdo(list, t, Type) + if(t == check) { ; /* don't compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -230,9 +239,10 @@ int duplicate_in_express_list( const Linked_List list, const Type check ) { underlying Express type. RETURNS 1 if true, else 0. */ -int unique_types( const Linked_List list ) { - LISTdo( list, t, Type ) - if( duplicate_in_express_list( list, t ) ) { +int unique_types(const Linked_List list) +{ + LISTdo(list, t, Type) + if(duplicate_in_express_list(list, t)) { return FALSE; } LISTod; @@ -243,29 +253,30 @@ int unique_types( const Linked_List list ) { /** determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. */ -int duplicate_utype_member( const Linked_List list, const Type check ) { +int duplicate_utype_member(const Linked_List list, const Type check) +{ char b [BUFSIZ]; - if( TYPEis_entity( check ) ) { + if(TYPEis_entity(check)) { return FALSE; } /* entities are never the same */ - LISTdo( list, t, Type ) - if( t == check ) { + LISTdo(list, t, Type) + if(t == check) { ; } /* don't compare check to itself */ else { /* continue looking */ - strncpy( b, TYPEget_utype( t ), BUFSIZ ); - if( ( !strcmp( b, TYPEget_utype( check ) ) ) - || ( compareOrigTypes( t, check ) ) ) + strncpy(b, TYPEget_utype(t), BUFSIZ); + if((!strcmp(b, TYPEget_utype(check))) + || (compareOrigTypes(t, check))) /* if the underlying types are the same */ { return TRUE; } - if( ! strcmp( b, "SDAI_Integer" ) && - ( ! strcmp( TYPEget_utype( check ), "SDAI_Real" ) ) ) + if(! strcmp(b, "SDAI_Integer") && + (! strcmp(TYPEget_utype(check), "SDAI_Real"))) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -279,9 +290,10 @@ int duplicate_utype_member( const Linked_List list, const Type check ) { C++ representation for the underlying Express type. RETURNS 1 if true, else 0. */ -int any_duplicates_in_select( const Linked_List list ) { - LISTdo( list, t, Type ) - if( duplicate_utype_member( list, t ) ) { +int any_duplicates_in_select(const Linked_List list) +{ + LISTdo(list, t, Type) + if(duplicate_utype_member(list, t)) { return TRUE; } LISTod; @@ -293,24 +305,25 @@ This list is returned as dup_list. If a duplicate exists, the function returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. */ -int find_duplicate_list( const Type type, Linked_List * duplicate_list ) { +int find_duplicate_list(const Type type, Linked_List *duplicate_list) +{ Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { + if(any_duplicates_in_select(SEL_TYPEget_items(type))) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo( SEL_TYPEget_items( type ), u, Type ) - if( !utype_member( *duplicate_list, u, 1 ) ) { + LISTdo(SEL_TYPEget_items(type), u, Type) + if(!utype_member(*duplicate_list, u, 1)) { /** if not already a duplicate **/ - if( utype_member( temp, u, 1 ) ) { - LISTadd_first( *duplicate_list, u ); + if(utype_member(temp, u, 1)) { + LISTadd_first(*duplicate_list, u); } else { - LISTadd_first( temp, u ); + LISTadd_first(temp, u); } } LISTod; - LISTfree( temp ); + LISTfree(temp); return TRUE; } return FALSE; @@ -338,9 +351,10 @@ enum __types { leaves. It passes around the vector described above, to track paths to the leaf nodes. */ -void non_unique_types_vector( const Type type, int * tvec ) { - LISTdo( SEL_TYPEget_items( type ), t, Type ) - switch( TYPEget_body( t )->type ) { +void non_unique_types_vector(const Type type, int *tvec) +{ + LISTdo(SEL_TYPEget_items(type), t, Type) + switch(TYPEget_body(t)->type) { case integer_: tvec[tint]++; break; @@ -360,7 +374,7 @@ void non_unique_types_vector( const Type type, int * tvec ) { break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector( t, tvec ); + non_unique_types_vector(t, tvec); break; case entity_: tvec[tentity]++; @@ -376,8 +390,8 @@ void non_unique_types_vector( const Type type, int * tvec ) { tvec[tnumber]++; break; default: - fprintf( stderr, "non_unique_types_vector: can't handle unknown type %d\n", - TYPEget_body( t )->type ); + fprintf(stderr, "non_unique_types_vector: can't handle unknown type %d\n", + TYPEget_body(t)->type); abort(); } LISTod; @@ -388,59 +402,60 @@ void non_unique_types_vector( const Type type, int * tvec ) { (FOO_TYPE | BAR_TYPE | BAZ_TYPE), where FOO, BAR, and BAZ are EXPRESS types. If all types are unique, the string (0) is generated. */ -char * non_unique_types_string( const Type type ) { +char *non_unique_types_string(const Type type) +{ int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char * typestr; + char *typestr; int first = 1; int i; - non_unique_types_vector( type, tvec ); + non_unique_types_vector(type, tvec); /* build type string from vector */ - typestr = ( char * )sc_malloc( BUFSIZ ); + typestr = (char *)sc_malloc(BUFSIZ); typestr[0] = '\0'; - strcat( typestr, ( char * )"(" ); - for( i = 0; i <= tnumber; i++ ) { - if( tvec[i] < 2 ) { + strcat(typestr, (char *)"("); + for(i = 0; i <= tnumber; i++) { + if(tvec[i] < 2) { continue; /* skip, this one is unique */ } - if( !first ) { - strcat( typestr, ( char * )" | " ); + if(!first) { + strcat(typestr, (char *)" | "); } else { first = 0; } - switch( i ) { + switch(i) { case tint : - strcat( typestr, ( char * )"sdaiINTEGER" ); + strcat(typestr, (char *)"sdaiINTEGER"); break; case treal : - strcat( typestr, ( char * )"sdaiREAL" ); + strcat(typestr, (char *)"sdaiREAL"); break; case tstring: - strcat( typestr, ( char * )"sdaiSTRING" ); + strcat(typestr, (char *)"sdaiSTRING"); break; case tbinary: - strcat( typestr, ( char * )"sdaiBINARY" ); + strcat(typestr, (char *)"sdaiBINARY"); break; case tenum : - strcat( typestr, ( char * )"sdaiENUMERATION" ); + strcat(typestr, (char *)"sdaiENUMERATION"); break; case tentity: - strcat( typestr, ( char * )"sdaiINSTANCE" ); + strcat(typestr, (char *)"sdaiINSTANCE"); break; case taggr : - strcat( typestr, ( char * )"sdaiAGGR" ); + strcat(typestr, (char *)"sdaiAGGR"); break; case tnumber: - strcat( typestr, ( char * )"sdaiNUMBER" ); + strcat(typestr, (char *)"sdaiNUMBER"); break; } } - if( first ) { - strcat( typestr, ( char * )"0" ); + if(first) { + strcat(typestr, (char *)"0"); } - strcat( typestr, ( char * )")" ); + strcat(typestr, (char *)")"); return typestr; } @@ -449,18 +464,20 @@ char * non_unique_types_string( const Type type ) { /** checks to see if an attribute is a member of the list * \returns the attribute 'check' if an attribute with the same name is on the list, 0 otherwise */ -Variable ATTR_LISTmember( Linked_List l, Variable check ) { +Variable ATTR_LISTmember(Linked_List l, Variable check) +{ char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name( check, nm ); - LISTdo( l, a, Variable ) { - generate_attribute_name( a, cur ); - if( ! strcmp( nm, cur ) ) { + generate_attribute_name(check, nm); + LISTdo(l, a, Variable) { + generate_attribute_name(a, cur); + if(! strcmp(nm, cur)) { return check; } - } LISTod; - return ( 0 ); + } + LISTod; + return (0); } @@ -468,236 +485,241 @@ Variable ATTR_LISTmember( Linked_List l, Variable check ) { * Side Effects: * The list that is returned needs to be freed by the caller. */ -Linked_List SEL_TYPEgetnew_attribute_list( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +Linked_List SEL_TYPEgetnew_attribute_list(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo( complete, t, Type ) { - if( TYPEis_entity( t ) ) { - cur = ENT_TYPEget_entity( t ); - attrs = ENTITYget_all_attributes( cur ); - LISTdo_n( attrs, a, Variable, b ) { - if( ! ATTR_LISTmember( newlist, a ) ) { - LISTadd_first( newlist, a ); + LISTdo(complete, t, Type) { + if(TYPEis_entity(t)) { + cur = ENT_TYPEget_entity(t); + attrs = ENTITYget_all_attributes(cur); + LISTdo_n(attrs, a, Variable, b) { + if(! ATTR_LISTmember(newlist, a)) { + LISTadd_first(newlist, a); } - } LISTod + } + LISTod } - } LISTod + } + LISTod return newlist; } /** prints the class 'definition', that is, the objects * and the constructor(s)/destructor for a select class. */ -void TYPEselect_inc_print_vars( const Type type, FILE * f, Linked_List dups ) { +void TYPEselect_inc_print_vars(const Type type, FILE *f, Linked_List dups) +{ int size, j; - Linked_List data_members = SELgetnew_dmlist( type ); + Linked_List data_members = SELgetnew_dmlist(type); char dmname [BUFSIZ], classnm [BUFSIZ], tdnm [BUFSIZ]; - strncpy( classnm, SelectName( TYPEget_name( type ) ), BUFSIZ ); - classnm[BUFSIZ-1] = '\0'; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; - size = strlen( classnm ) + 2; /* for formatting output */ - - fprintf( f, "\n////////// SELECT TYPE %s\n", SelectName( TYPEget_name( type ) ) ); - fprintf( f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm ); - fprintf( f, " protected:\n" ); - fprintf( f, " // types in SELECT \n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - fprintf( f, " // %s -- %s\n", SEL_ITEMget_enumtype( t ), FundamentalType( t, 0 ) ); + strncpy(classnm, SelectName(TYPEget_name(type)), BUFSIZ); + classnm[BUFSIZ - 1] = '\0'; + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; + size = strlen(classnm) + 2; /* for formatting output */ + + fprintf(f, "\n////////// SELECT TYPE %s\n", SelectName(TYPEget_name(type))); + fprintf(f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm); + fprintf(f, " protected:\n"); + fprintf(f, " // types in SELECT \n"); + LISTdo(SEL_TYPEget_items(type), t, Type) { + fprintf(f, " // %s -- %s\n", SEL_ITEMget_enumtype(t), FundamentalType(t, 0)); } LISTod; - LISTdo( data_members, t, Type ) { - strncpy( dmname, SEL_ITEMget_dmname( t ), BUFSIZ ); - fprintf( f, " %s%s _%s;\n", TYPEget_utype( t ), TYPEis_aggregate( t ) ? "_ptr" : "", dmname ); + LISTdo(data_members, t, Type) { + strncpy(dmname, SEL_ITEMget_dmname(t), BUFSIZ); + fprintf(f, " %s%s _%s;\n", TYPEget_utype(t), TYPEis_aggregate(t) ? "_ptr" : "", dmname); } LISTod; - fprintf( f, "\n public:\n" ); - fprintf( f, - " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" - " virtual SDAI_Select * NewSelect ();\n" + fprintf(f, "\n public:\n"); + fprintf(f, + " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" + " virtual SDAI_Select * NewSelect ();\n" ); - fprintf( f, "\n virtual BASE_TYPE ValueType() const;\n" ); + fprintf(f, "\n virtual BASE_TYPE ValueType() const;\n"); - fprintf( f, "\n\n// STEP Part 21\n" ); - fprintf( f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n" ); - fprintf( f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n" ); - fprintf( f, " virtual Severity STEPread_content (istream& in =cin,\n" - " InstMgrBase * instances =0, const char *utype =0,\n" - " int addFileId =0, const char *currSch =0);\n" ); + fprintf(f, "\n\n// STEP Part 21\n"); + fprintf(f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n"); + fprintf(f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n"); + fprintf(f, " virtual Severity STEPread_content (istream& in =cin,\n" + " InstMgrBase * instances =0, const char *utype =0,\n" + " int addFileId =0, const char *currSch =0);\n"); /* read StrToVal_content */ - fprintf( f, " virtual Severity StrToVal_content " - "(const char *,\n InstMgrBase * instances =0);\n" ); + fprintf(f, " virtual Severity StrToVal_content " + "(const char *,\n InstMgrBase * instances =0);\n"); /* constructor(s) */ - fprintf( f, "\n// STEP Part 22: SDAI\n" ); - fprintf( f, "\n// constructors\n" ); - fprintf( f, " %s( const SelectTypeDescriptor * =%s );\n", - classnm, tdnm ); + fprintf(f, "\n// STEP Part 22: SDAI\n"); + fprintf(f, "\n// constructors\n"); + fprintf(f, " %s( const SelectTypeDescriptor * =%s );\n", + classnm, tdnm); - fprintf( f, " // part 1\n" ); + fprintf(f, " // part 1\n"); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( ( TYPEis_entity( t ) ) - || ( !utype_member( dups, t, 1 ) ) ) { + LISTdo(SEL_TYPEget_items(type), t, Type) + if((TYPEis_entity(t)) + || (!utype_member(dups, t, 1))) { /** if an entity or not in the dup list **/ - fprintf( f, " %s( const %s&,\n ", - SelectName( TYPEget_name( type ) ), AccessType( t ) ); - for( j = 0; j < size; j++ ) { - fprintf( f, " " ); + fprintf(f, " %s( const %s&,\n ", + SelectName(TYPEget_name(type)), AccessType(t)); + for(j = 0; j < size; j++) { + fprintf(f, " "); } - fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); + fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); } LISTod; - LISTdo( dups, t, Type ) - if( ! TYPEis_entity( t ) ) { /* entities were done already */ - fprintf( f, " %s( const %s&,\n ", - SelectName( TYPEget_name( type ) ), - isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); - for( j = 0; j < size; j++ ) { - fprintf( f, " " ); + LISTdo(dups, t, Type) + if(! TYPEis_entity(t)) { /* entities were done already */ + fprintf(f, " %s( const %s&,\n ", + SelectName(TYPEget_name(type)), + isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); + for(j = 0; j < size; j++) { + fprintf(f, " "); } - fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); + fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); } LISTod; /* destructor */ - fprintf( f, " virtual ~%s();\n", classnm ); - LISTfree( data_members ); + fprintf(f, " virtual ~%s();\n", classnm); + LISTfree(data_members); } /** * TYPEselect_inc_print prints the class member function declarations of a select * class. */ -void TYPEselect_inc_print( const Type type, FILE * f ) { +void TYPEselect_inc_print(const Type type, FILE *f) +{ char n[BUFSIZ]; /* class name */ char tdnm [BUFSIZ]; /* TypeDescriptor name */ Linked_List dups; int dup_result; Linked_List attrs; - dup_result = find_duplicate_list( type, &dups ); - strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - TYPEselect_inc_print_vars( type, f, dups ); + dup_result = find_duplicate_list(type, &dups); + strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + TYPEselect_inc_print_vars(type, f, dups); - fprintf( f, "\n // part 2\n" ); + fprintf(f, "\n // part 2\n"); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( ( TYPEis_entity( t ) ) - || ( !utype_member( dups, t, 1 ) ) ) { + LISTdo(SEL_TYPEget_items(type), t, Type) + if((TYPEis_entity(t)) + || (!utype_member(dups, t, 1))) { /** if an entity or not in the dup list **/ - fprintf( f, " operator %s();\n", AccessType( t ) ); + fprintf(f, " operator %s();\n", AccessType(t)); } LISTod; - LISTdo( dups, t, Type ) + LISTdo(dups, t, Type) /* do the dups once only */ - if( ! TYPEis_entity( t ) ) /* entities were done already */ - fprintf( f, " operator %s ();\n", - ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? - AccessType( t ) : TYPEget_utype( t ) ); + if(! TYPEis_entity(t)) /* entities were done already */ + fprintf(f, " operator %s ();\n", + (TYPEis_aggregate(t) || TYPEis_select(t)) ? + AccessType(t) : TYPEget_utype(t)); LISTod; - fprintf( f, "\n // part 3\n" ); - attrs = SEL_TYPEgetnew_attribute_list( type ); + fprintf(f, "\n // part 3\n"); + attrs = SEL_TYPEgetnew_attribute_list(type); /* get the list of unique attributes from the entity items */ - LISTdo( attrs, a, Variable ) - if( VARget_initializer( a ) == EXPRESSION_NULL ) { - ATTRsign_access_methods( a, f ); + LISTdo(attrs, a, Variable) + if(VARget_initializer(a) == EXPRESSION_NULL) { + ATTRsign_access_methods(a, f); } LISTod; - LISTfree( attrs ); + LISTfree(attrs); - fprintf( f, "\n // part 4\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( ( TYPEis_entity( t ) ) - || ( !utype_member( dups, t, 1 ) ) ) { + fprintf(f, "\n // part 4\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) + if((TYPEis_entity(t)) + || (!utype_member(dups, t, 1))) { /** if an entity or not in the dup list **/ - fprintf( f, " %s& operator =( const %s& );\n", - SelectName( TYPEget_name( type ) ), AccessType( t ) ); + fprintf(f, " %s& operator =( const %s& );\n", + SelectName(TYPEget_name(type)), AccessType(t)); } LISTod; - LISTdo( dups, t, Type ) - if( ! TYPEis_entity( t ) ) { /* entities were done already */ - fprintf( f, " %s& operator =( const %s& );\n", - SelectName( TYPEget_name( type ) ), - isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); + LISTdo(dups, t, Type) + if(! TYPEis_entity(t)) { /* entities were done already */ + fprintf(f, " %s& operator =( const %s& );\n", + SelectName(TYPEget_name(type)), + isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); } LISTod; - fprintf( f, " // not in SDAI\n" - " %s& ShallowCopy ( const %s& );\n", - n, n ); + fprintf(f, " // not in SDAI\n" + " %s& ShallowCopy ( const %s& );\n", + n, n); - fprintf( f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n" ); - fprintf( f, " %s& operator =( %s * const & );\n", n, n ); - fprintf( f, " SDAI_Select& operator =( const SDAI_Select& );\n" ); - fprintf( f, "#endif\n" ); + fprintf(f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n"); + fprintf(f, " %s& operator =( %s * const & );\n", n, n); + fprintf(f, " SDAI_Select& operator =( const SDAI_Select& );\n"); + fprintf(f, "#endif\n"); - fprintf( f, "\n // part 5\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - fprintf( f, " Logical Is%s() const;\n", - FirstToUpper( TYPEget_name( t ) ) ); + fprintf(f, "\n // part 5\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) + fprintf(f, " Logical Is%s() const;\n", + FirstToUpper(TYPEget_name(t))); LISTod; - fprintf( f, "\n // part 6 ... UnderlyingTypeName () implemented in" - " SDAI_Select class ...\n" ); + fprintf(f, "\n // part 6 ... UnderlyingTypeName () implemented in" + " SDAI_Select class ...\n"); - if( dup_result ) { + if(dup_result) { /** if there are duplicate underlying types **/ - fprintf( f, "\n // part 7\n" ); - fprintf( f, " const TypeDescriptor *" - "SetUnderlyingType ( const TypeDescriptor * td );\n" ); + fprintf(f, "\n // part 7\n"); + fprintf(f, " const TypeDescriptor *" + "SetUnderlyingType ( const TypeDescriptor * td );\n"); } else { - fprintf( f, "\n // part 7 ... NONE only for complex selects...\n" ); + fprintf(f, "\n // part 7 ... NONE only for complex selects...\n"); } #ifdef PART8 - fprintf( f, "\n // part 8\n" ); - fprintf( f, " %s* operator->();\n", n ); + fprintf(f, "\n // part 8\n"); + fprintf(f, " %s* operator->();\n", n); #endif - fprintf( f, "};\n" ); + fprintf(f, "};\n"); - fprintf( f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n ); + fprintf(f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n); /* DAR - moved from SCOPEPrint() */ - fprintf( f, "typedef %s * %sH;\n", n, n ); - fprintf( f, "typedef %s_ptr %s_var;\n\n", n, n ); + fprintf(f, "typedef %s * %sH;\n", n, n); + fprintf(f, "typedef %s_ptr %s_var;\n\n", n, n); /* print things for aggregate class */ - fprintf( f, "\nclass %s_agg : public SelectAggregate {\n", n ); - fprintf( f, " protected:\n" ); - fprintf( f, " SelectTypeDescriptor *sel_type;\n\n" ); - fprintf( f, " public:\n" ); - fprintf( f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm ); - fprintf( f, " ~%s_agg();\n", n ); - fprintf( f, " virtual SingleLinkNode * NewNode()\n" ); - fprintf( f, " { return new SelectNode (new %s( sel_type )); }\n", n ); - fprintf( f, "};\n" ); + fprintf(f, "\nclass %s_agg : public SelectAggregate {\n", n); + fprintf(f, " protected:\n"); + fprintf(f, " SelectTypeDescriptor *sel_type;\n\n"); + fprintf(f, " public:\n"); + fprintf(f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm); + fprintf(f, " ~%s_agg();\n", n); + fprintf(f, " virtual SingleLinkNode * NewNode()\n"); + fprintf(f, " { return new SelectNode (new %s( sel_type )); }\n", n); + fprintf(f, "};\n"); /* DAS creation function for select aggregate class */ - fprintf( f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", - n, n ); + fprintf(f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", + n, n); - fprintf( f, "typedef %s_agg_ptr %s_agg_var;\n", n, n ); + fprintf(f, "typedef %s_agg_ptr %s_agg_var;\n", n, n); - fprintf( f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name( type ) ); + fprintf(f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name(type)); - LISTfree( dups ); + LISTfree(dups); } @@ -705,166 +727,172 @@ void TYPEselect_inc_print( const Type type, FILE * f ) { * TYPEselect_lib_print_part_one prints constructor(s)/destructor of a select * class. */ -void TYPEselect_lib_print_part_one( const Type type, FILE * f, - Linked_List dups, char * n ) { +void TYPEselect_lib_print_part_one(const Type type, FILE *f, + Linked_List dups, char *n) +{ #define schema_name SCHEMAget_name(schema) char tdnm[BUFSIZ], nm[BUFSIZ]; - int size = strlen( n ) * 2 + 4, j; /* size - for formatting output */ + int size = strlen(n) * 2 + 4, j; /* size - for formatting output */ - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - strncpy( nm, SelectName( TYPEget_name( type ) ), BUFSIZ ); + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + strncpy(nm, SelectName(TYPEget_name(type)), BUFSIZ); /* constructor(s) */ /* null constructor */ - fprintf( f, "\n// STEP Part 22: SDAI\n" ); - fprintf( f, "\n // part 0\n" ); - fprintf( f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n ); - fprintf( f, " : " BASE_SELECT " (typedescript)" ); + fprintf(f, "\n// STEP Part 22: SDAI\n"); + fprintf(f, "\n // part 0\n"); + fprintf(f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n); + fprintf(f, " : " BASE_SELECT " (typedescript)"); /* Initialize the select members with their correct typedescriptors: */ - initSelItems( type, f ); - fprintf( f, "\n{\n" ); - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); - fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n ); - fprintf( f, " }\n#endif\n" ); + initSelItems(type, f); + fprintf(f, "\n{\n"); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); + fprintf(f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n); + fprintf(f, " }\n#endif\n"); /* create objects for data member pointers. also in two more ctors below, and deleted in dtor which is printed at end of this function. */ - LISTdo( dups, t, Type ) { - if( isAggregateType( t ) && t->u.type->body->base ) { - fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); + LISTdo(dups, t, Type) { + if(isAggregateType(t) && t->u.type->body->base) { + fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); } - } LISTod + } + LISTod /* above misses some attr's that are initialized in part 1 ctor below. * hopefully this won't add duplicates... */ - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { - if( isAggregateType( t ) && ( t->u.type->body->base ) ) { - fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); + LISTdo(SEL_TYPEget_items(type), t, Type) { + if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { + if(isAggregateType(t) && (t->u.type->body->base)) { + fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); } } - } LISTod - fprintf( f, " nullify();\n" ); - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); - fprintf( f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n ); - fprintf( f, " }\n#endif\n" ); - fprintf( f, "}\n" ); + } + LISTod + fprintf(f, " nullify();\n"); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); + fprintf(f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n); + fprintf(f, " }\n#endif\n"); + fprintf(f, "}\n"); /* constructors with underlying types */ - fprintf( f, "\n // part 1\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { + fprintf(f, "\n // part 1\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) { + if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { /* if there is not more than one underlying type that maps to the same * base type print out the constructor using the type from the TYPE * statement as the underlying type. Also skip enums/sels which are * renames of other items. That would create redundant constructors * since renames are typedef'ed to the original type. */ - fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); - for( j = 0; j < size; j++ ) { - fprintf( f, " " ); + fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); + for(j = 0; j < size; j++) { + fprintf(f, " "); } /* Did this for the heck of it, and to show how easy it would have been to make it all pretty - DAR. ;-) */ - fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); - - fprintf( f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name( t ) ); - initSelItems( type, f ); - fprintf( f, "\n{\n" ); - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); - fprintf( f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n ); - fprintf( f, "#endif\n" ); - - if( isAggregateType( t ) ) { - if( t->u.type->body->base ) { - fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); + fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); + + fprintf(f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name(t)); + initSelItems(type, f); + fprintf(f, "\n{\n"); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); + fprintf(f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n); + fprintf(f, "#endif\n"); + + if(isAggregateType(t)) { + if(t->u.type->body->base) { + fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); } - fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), - ( ( t->u.type->body->base ) ? "->" : "." ) ); + fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), + ((t->u.type->body->base) ? "->" : ".")); } else { - fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); + fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); } - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); - fprintf( f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n ); - fprintf( f, "#endif\n" ); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); + fprintf(f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n); + fprintf(f, "#endif\n"); - fprintf( f, "}\n\n" ); + fprintf(f, "}\n\n"); } - } LISTod - LISTdo( dups, t, Type ) { + } + LISTod + LISTdo(dups, t, Type) { /* if there is more than one underlying type that maps to the * same base type, print a constructor using the base type. */ - if( ! TYPEis_entity( t ) ) { /* entities were done already */ - if( isAggregateType( t ) ) { - fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); - for( j = 0; j < size; j++ ) { - fprintf( f, " " ); + if(! TYPEis_entity(t)) { /* entities were done already */ + if(isAggregateType(t)) { + fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); + for(j = 0; j < size; j++) { + fprintf(f, " "); } - fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); - fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name( t ) ); - initSelItems( type, f ); - fprintf( f, "\n{\n" ); - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); - fprintf( f, + fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); + fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name(t)); + initSelItems(type, f); + fprintf(f, "\n{\n"); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); + fprintf(f, " *logStream << \"DAVE ERR entering %s constructor.\"" - " << std::endl;\n", n ); - fprintf( f, " }\n#endif\n" ); - if( t->u.type->body->base ) { - fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); + " << std::endl;\n", n); + fprintf(f, " }\n#endif\n"); + if(t->u.type->body->base) { + fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); } - fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); + fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); } else { - fprintf( f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype( t ) ); - for( j = 0; j < size; j++ ) { - fprintf( f, " " ); + fprintf(f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype(t)); + for(j = 0; j < size; j++) { + fprintf(f, " "); } - fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); - fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name( t ) ); - initSelItems( type, f ); - fprintf( f, "\n{\n" ); - fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); + fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); + fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name(t)); + initSelItems(type, f); + fprintf(f, "\n{\n"); + fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); } - fprintf( f, + fprintf(f, "// NOTE: Underlying type defaults to %s instead of NULL\n", - TYPEtd_name( t ) ); - fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); - fprintf( f, + TYPEtd_name(t)); + fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); + fprintf(f, "// *logStream << \"DAVE ERR exiting %s constructor.\"" - " << std::endl;\n", n ); - fprintf( f, " }\n#endif\n" ); - fprintf( f, "}\n\n" ); + " << std::endl;\n", n); + fprintf(f, " }\n#endif\n"); + fprintf(f, "}\n\n"); } - } LISTod + } + LISTod /* dtor */ - fprintf( f, "%s::~%s() {\n", n, n ); + fprintf(f, "%s::~%s() {\n", n, n); /* delete objects that data members point to */ - LISTdo( dups, t, Type ) { - if( isAggregateType( t ) && t->u.type->body->base ) { - fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); - fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); - fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); + LISTdo(dups, t, Type) { + if(isAggregateType(t) && t->u.type->body->base) { + fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); + fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); + fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); } } LISTod; - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { - if( isAggregateType( t ) && ( t->u.type->body->base ) ) { - fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); - fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); - fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); + LISTdo(SEL_TYPEget_items(type), t, Type) { + if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { + if(isAggregateType(t) && (t->u.type->body->base)) { + fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); + fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); + fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); } } - } LISTod + } + LISTod - fprintf( f, "}\n\n" ); + fprintf(f, "}\n\n"); - fprintf( f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" - " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n ); - fprintf( f, "%s_agg::~%s_agg() { }\n\n", n, n ); + fprintf(f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" + " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n); + fprintf(f, "%s_agg::~%s_agg() { }\n\n", n, n); #undef schema_name } @@ -874,54 +902,57 @@ void TYPEselect_lib_print_part_one( const Type type, FILE * f, * renaming of another select ("TYPE selB = selA") its td would default to * selA's, so it must be set specifically. */ -static void initSelItems( const Type type, FILE * f ) { - Linked_List data_members = SELgetnew_dmlist( type ); - - LISTdo( data_members, t, Type ) - if( TYPEis_select( t ) ) { - fprintf( f, ",\n _%s (%s)", SEL_ITEMget_dmname( t ), - TYPEtd_name( t ) ); +static void initSelItems(const Type type, FILE *f) +{ + Linked_List data_members = SELgetnew_dmlist(type); + + LISTdo(data_members, t, Type) + if(TYPEis_select(t)) { + fprintf(f, ",\n _%s (%s)", SEL_ITEMget_dmname(t), + TYPEtd_name(t)); } LISTod; } -Linked_List ENTITYget_expanded_entities( Entity e, Linked_List l ) { +Linked_List ENTITYget_expanded_entities(Entity e, Linked_List l) +{ Linked_List supers; Entity super; - if( ! LISTmember( l, e ) ) { - LISTadd_first( l, e ); + if(! LISTmember(l, e)) { + LISTadd_first(l, e); } - if( multiple_inheritance ) { + if(multiple_inheritance) { int super_cnt = 0; - supers = ENTITYget_supertypes( e ); - LISTdo( supers, s, Entity ) + supers = ENTITYget_supertypes(e); + LISTdo(supers, s, Entity) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if( super_cnt == 0 ) { - ENTITYget_expanded_entities( s, l ); + if(super_cnt == 0) { + ENTITYget_expanded_entities(s, l); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass( e ); - ENTITYget_expanded_entities( super, l ); + super = ENTITYget_superclass(e); + ENTITYget_expanded_entities(super, l); } return l; } -Linked_List SELget_entity_itemlist( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +Linked_List SELget_entity_itemlist(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo( complete, t, Type ) - if( TYPEis_entity( t ) ) { - cur = ENT_TYPEget_entity( t ); - ENTITYget_expanded_entities( cur, newlist ); + LISTdo(complete, t, Type) + if(TYPEis_entity(t)) { + cur = ENT_TYPEget_entity(t); + ENTITYget_expanded_entities(cur, newlist); } LISTod; return newlist; @@ -934,35 +965,37 @@ Linked_List SELget_entity_itemlist( const Type type ) { * to its primary path (is its own attr, that of its first super, that of * its first super's first super etc), and does necessary housekeeping. */ -static int memberOfEntPrimary( Entity ent, Variable uattr ) { +static int memberOfEntPrimary(Entity ent, Variable uattr) +{ Linked_List attrlist = LISTcreate(); int result; - ENTITYget_first_attribs( ent, attrlist ); - result = ( LISTmember( attrlist, uattr ) != 0 ); - LIST_destroy( attrlist ); + ENTITYget_first_attribs(ent, attrlist); + result = (LISTmember(attrlist, uattr) != 0); + LIST_destroy(attrlist); return result; } -void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, const char * attrnm, const char * utype, char * uent, char * funcnm, - Linked_List items, Variable a, Variable uattr, Entity ent, FILE * f, bool returnConst ) { +void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, const char *attrnm, const char *utype, char *uent, char *funcnm, + Linked_List items, Variable a, Variable uattr, Entity ent, FILE *f, bool returnConst) +{ /* return a const value? */ - const char * constStr = "const "; - const char * constReturn = ( returnConst ? constStr : "" ); + const char *constStr = "const "; + const char *constReturn = (returnConst ? constStr : ""); /* method can be const or non-const? */ - bool notAlwaysConst = attrIsObj( VARget_type( a ) ); + bool notAlwaysConst = attrIsObj(VARget_type(a)); - ATTRprint_access_methods_get_head( classnm, a, f, returnConst ); + ATTRprint_access_methods_get_head(classnm, a, f, returnConst); /* if there will not be const and non-const getters, then this method should be const */ - fprintf( f, "%s{\n", ( notAlwaysConst ? constReturn : constStr ) ); + fprintf(f, "%s{\n", (notAlwaysConst ? constReturn : constStr)); - LISTdo( items, t, Type ) { - if( TYPEis_entity( t ) && ( uattr = ENTITYget_named_attribute( - ( ent = ENT_TYPEget_entity( t ) ), ( char * ) StrToLower( attrnm ) ) ) ) { + LISTdo(items, t, Type) { + if(TYPEis_entity(t) && (uattr = ENTITYget_named_attribute( + (ent = ENT_TYPEget_entity(t)), (char *) StrToLower(attrnm)))) { /* for the select items which have the current attribute */ - if( !multiple_inheritance ) { - if( !memberOfEntPrimary( ent, uattr ) ) { + if(!multiple_inheritance) { + if(!memberOfEntPrimary(ent, uattr)) { /* If multiple inheritance is not supported, we must additionally check * that uattr is a member of the entity's primary inheritance path * (i.e., the entity, its first supertype, the super's first super, @@ -972,42 +1005,43 @@ void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, co continue; } } - if( ! VARis_derived( uattr ) ) { + if(! VARis_derived(uattr)) { - if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { + if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { /* check to make sure the underlying attribute\'s type is * the same as the current attribute. */ - strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); + strncpy(uent, TYPEget_ctype(t), BUFSIZ); /* if the underlying type is that item's type, call the underlying_item's * member function if it is the same attribute */ - if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { + if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { /* update attribute_func_name because is has been overridden */ - generate_attribute_func_name( uattr, funcnm ); + generate_attribute_func_name(uattr, funcnm); } else { - generate_attribute_func_name( a, funcnm ); + generate_attribute_func_name(a, funcnm); } - fprintf( f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); - fprintf( f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname( t ), funcnm ); + fprintf(f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", + TYPEtd_name(t), StrToUpper(TYPEget_name(t))); + fprintf(f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname(t), funcnm); } else { /* types are not the same issue a warning */ - fprintf( stderr, - "WARNING: in SELECT TYPE %s: ambiguous " - "attribute \"%s\" from underlying type \"%s\".\n\n", - TYPEget_name( type ), attrnm, TYPEget_name( t ) ); - fprintf( f, " // %s\n // attribute access function" - " has a different return type\n", - StrToUpper( TYPEget_name( t ) ) ); + fprintf(stderr, + "WARNING: in SELECT TYPE %s: ambiguous " + "attribute \"%s\" from underlying type \"%s\".\n\n", + TYPEget_name(type), attrnm, TYPEget_name(t)); + fprintf(f, " // %s\n // attribute access function" + " has a different return type\n", + StrToUpper(TYPEget_name(t))); } } else /* derived attributes */ - fprintf( f, " // for %s attribute is derived\n", - StrToUpper( TYPEget_name( t ) ) ); - } - } LISTod; + fprintf(f, " // for %s attribute is derived\n", + StrToUpper(TYPEget_name(t))); + } + } + LISTod; PRINT_BUG_REPORT /* If the return type is an enumeration class then you can\'t @@ -1026,18 +1060,18 @@ void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, co */ /* EnumName (TYPEget_name (VARget_type (a)))*/ - switch( TYPEget_body( VARget_type( a ) ) -> type ) { + switch(TYPEget_body(VARget_type(a)) -> type) { case enumeration_: - fprintf( f, " return (%s) 0;\n}\n\n", EnumName( TYPEget_name( VARget_type( a ) ) ) ); + fprintf(f, " return (%s) 0;\n}\n\n", EnumName(TYPEget_name(VARget_type(a)))); break; case boolean_: - fprintf( f, " return (Boolean) 0;\n}\n\n" ); + fprintf(f, " return (Boolean) 0;\n}\n\n"); break; case logical_: - fprintf( f, " return (Logical) 0;\n}\n\n" ); + fprintf(f, " return (Logical) 0;\n}\n\n"); break; default: - fprintf( f, " return 0;\n}\n\n" ); + fprintf(f, " return 0;\n}\n\n"); } } @@ -1046,63 +1080,64 @@ void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, co * a select class -- access functions for the data members of underlying entity * types. */ -void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm ) { +void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) +{ #define ENTITYget_type(e) ((e)->u.entity->type) char uent[BUFSIZ], /* name of underlying entity type */ utype[BUFSIZ], /* underlying type name */ attrnm [BUFSIZ], /* attribute name -> data member = _attrnm */ funcnm[BUFSIZ]; /* access function name = Attrnm */ - Linked_List items = SEL_TYPEget_items( type ); + Linked_List items = SEL_TYPEget_items(type); /* all the items in the select type */ - Linked_List attrs = SEL_TYPEgetnew_attribute_list( type ); + Linked_List attrs = SEL_TYPEgetnew_attribute_list(type); /* list of attributes with unique names */ Entity ent = NULL; Variable uattr = NULL; /* attribute in underlying type */ - fprintf( f, "\n // part 3\n" ); + fprintf(f, "\n // part 3\n"); /* go through all the unique attributes */ - LISTdo_n( attrs, a, Variable, b ) { + LISTdo_n(attrs, a, Variable, b) { bool putVarIsUsed = false; /* used to suppress unused var warning */ - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + if(VARget_initializer(a) == EXPRESSION_NULL) { /* only do for explicit attributes */ - generate_attribute_func_name( a, funcnm ); - generate_attribute_name( a, attrnm ); + generate_attribute_func_name(a, funcnm); + generate_attribute_name(a, attrnm); /* strncpy (funcnm, attrnm, BUFSIZ); funcnm [0] = toupper (funcnm[0]); */ /* use the ctype since utype will be the same for all entities */ - strncpy( utype, TYPEget_ctype( VARget_type( a ) ), BUFSIZ ); + strncpy(utype, TYPEget_ctype(VARget_type(a)), BUFSIZ); /* get methods */ - TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false ); - if( attrIsObj( VARget_type( a ) ) ) { - TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true ); + TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false); + if(attrIsObj(VARget_type(a))) { + TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true); } /* put method */ - ATTRprint_access_methods_put_head( classnm, a, f ); - fprintf( f, "{\n" ); - LISTdo( items, t, Type ) { - if( TYPEis_entity( t ) && - ( uattr = ENTITYget_named_attribute( - ( ent = ENT_TYPEget_entity( t ) ), - ( char * ) StrToLower( attrnm ) ) ) ) + ATTRprint_access_methods_put_head(classnm, a, f); + fprintf(f, "{\n"); + LISTdo(items, t, Type) { + if(TYPEis_entity(t) && + (uattr = ENTITYget_named_attribute( + (ent = ENT_TYPEget_entity(t)), + (char *) StrToLower(attrnm)))) { /* for the select items which have the current attribute */ - if( !multiple_inheritance ) { - if( !memberOfEntPrimary( ent, uattr ) ) { + if(!multiple_inheritance) { + if(!memberOfEntPrimary(ent, uattr)) { /* See note for similar code segment in 1st part of fn. */ continue; } } - if( ! VARis_derived( uattr ) ) { + if(! VARis_derived(uattr)) { - if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { + if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { /* check to make sure the underlying attribute\'s type is the same as the current attribute. */ @@ -1110,209 +1145,218 @@ void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm /* if the underlying type is that item\'s type call the underlying_item\'s member function */ /* if it is the same attribute */ - if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { + if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { /* update attribute_func_name because is has been overrid */ - generate_attribute_func_name( uattr, funcnm ); + generate_attribute_func_name(uattr, funcnm); } else { - generate_attribute_func_name( a, funcnm ); + generate_attribute_func_name(a, funcnm); } - strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); - fprintf( f, + strncpy(uent, TYPEget_ctype(t), BUFSIZ); + fprintf(f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); - fprintf( f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", - uent, SEL_ITEMget_dmname( t ), funcnm ); + TYPEtd_name(t), StrToUpper(TYPEget_name(t))); + fprintf(f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", + uent, SEL_ITEMget_dmname(t), funcnm); putVarIsUsed = true; } else { /* warning printed above */ - fprintf( f, " // for %s attribute access function" + fprintf(f, " // for %s attribute access function" " has a different argument type\n", - SEL_ITEMget_enumtype( t ) ); + SEL_ITEMget_enumtype(t)); } } else { /* derived attributes */ - fprintf( f, " // for %s attribute is derived\n", - SEL_ITEMget_enumtype( t ) ); + fprintf(f, " // for %s attribute is derived\n", + SEL_ITEMget_enumtype(t)); } } - } LISTod; - if( !putVarIsUsed ) { + } + LISTod; + if(!putVarIsUsed) { fprintf(f, " (void) x; //suppress unused var warning\n"); } - PRINT_SELECTBUG_WARNING( f ); - fprintf( f, "}\n" ); + PRINT_SELECTBUG_WARNING(f); + fprintf(f, "}\n"); } - } LISTod; - LISTfree( attrs ); + } + LISTod; + LISTfree(attrs); } /** * TYPEselect_lib_print_part_four prints part 4 of the SDAI document of a select class. */ -void TYPEselect_lib_print_part_four( const Type type, FILE * f, Linked_List dups, char * n ) { +void TYPEselect_lib_print_part_four(const Type type, FILE *f, Linked_List dups, char *n) +{ char x[BUFSIZ]; - fprintf( f, "\n // part 4\n" ); + fprintf(f, "\n // part 4\n"); - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - if( ( TYPEis_entity( t ) ) - || ( !utype_member( dups, t, 1 ) ) ) { - fprintf( f, "%s& %s::operator =( const %s& o )\n{\n" + LISTdo(SEL_TYPEget_items(type), t, Type) { + if((TYPEis_entity(t)) + || (!utype_member(dups, t, 1))) { + fprintf(f, "%s& %s::operator =( const %s& o )\n{\n" " nullify ();\n", - n, n, AccessType( t ) ); + n, n, AccessType(t)); - if( isAggregateType( t ) ) { - fprintf( f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname( t ), - ( ( t->u.type->body->base ) ? "->" : "." ) ); + if(isAggregateType(t)) { + fprintf(f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname(t), + ((t->u.type->body->base) ? "->" : ".")); } else { - fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); + fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); } - fprintf( f, " SetUnderlyingType( %s );\n", TYPEtd_name( t ) ); - fprintf( f, " return *this;\n}\n\n" ); + fprintf(f, " SetUnderlyingType( %s );\n", TYPEtd_name(t)); + fprintf(f, " return *this;\n}\n\n"); } - } LISTod - LISTdo( dups, t, Type ) { - if( ! TYPEis_entity( t ) ) { /* entities were done already */ - if( isAggregateType( t ) ) { - fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, AccessType( t ) ); - fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); + } + LISTod + LISTdo(dups, t, Type) { + if(! TYPEis_entity(t)) { /* entities were done already */ + if(isAggregateType(t)) { + fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, AccessType(t)); + fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); } else { - fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, TYPEget_utype( t ) ); - fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); + fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, TYPEget_utype(t)); + fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); } - fprintf( f, " underlying_type = 0; // MUST BE SET BY USER\n" ); - fprintf( f, " // discriminator = UNSET\n" ); - fprintf( f, " return *this;\n}\n" ); + fprintf(f, " underlying_type = 0; // MUST BE SET BY USER\n"); + fprintf(f, " // discriminator = UNSET\n"); + fprintf(f, " return *this;\n}\n"); } - } LISTod - - fprintf( f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n" ); - fprintf( f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n ); - fprintf( f, " SDAI_Select::operator=( *o );\n"); - - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - strncpy( x, TYPEget_name( t ), BUFSIZ ); - fprintf( f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name( t ) ); - if( TYPEis_select( t ) ) { - if( utype_member( dups, t, 1 ) ) + } + LISTod + + fprintf(f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n"); + fprintf(f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n); + fprintf(f, " SDAI_Select::operator=( *o );\n"); + + LISTdo(SEL_TYPEget_items(type), t, Type) { + strncpy(x, TYPEget_name(t), BUFSIZ); + fprintf(f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name(t)); + if(TYPEis_select(t)) { + if(utype_member(dups, t, 1)) /** if in the dup list **/ - fprintf( f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname( t ), - StrToLower( TYPEget_utype( t ) ) ); + fprintf(f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname(t), + StrToLower(TYPEget_utype(t))); else - fprintf( f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname( t ), - SEL_ITEMget_dmname( t ) ); + fprintf(f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname(t), + SEL_ITEMget_dmname(t)); } else { - if( utype_member( dups, t, 1 ) ) { + if(utype_member(dups, t, 1)) { /** if in the dup list **/ - fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); - /* I changed this although I'm not sure how the if and else differ */ - /* StrToLower(TYPEget_utype(t)) ); */ + fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); + /* I changed this although I'm not sure how the if and else differ */ + /* StrToLower(TYPEget_utype(t)) ); */ } else { - fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); + fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); } } - fprintf( f, " return *this;\n" ); - fprintf( f, " }\n" ); - } LISTod; - fprintf( f, " return *this;\n}\n\n" ); - - fprintf( f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n ); - fprintf( f, " SDAI_Select::operator=( o );\n"); - - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - strncpy( x, TYPEget_name( t ), BUFSIZ ); - x[BUFSIZ-1] = '\0'; - fprintf( f, " if ( o.CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name( t ) ); - if( TYPEis_select( t ) ) { - if( utype_member( dups, t, 1 ) ) + fprintf(f, " return *this;\n"); + fprintf(f, " }\n"); + } + LISTod; + fprintf(f, " return *this;\n}\n\n"); + + fprintf(f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n); + fprintf(f, " SDAI_Select::operator=( o );\n"); + + LISTdo(SEL_TYPEget_items(type), t, Type) { + strncpy(x, TYPEget_name(t), BUFSIZ); + x[BUFSIZ - 1] = '\0'; + fprintf(f, " if ( o.CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name(t)); + if(TYPEis_select(t)) { + if(utype_member(dups, t, 1)) /** if in the dup list **/ - fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname( t ), + fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname(t), n, - SEL_ITEMget_dmname( t ) ); + SEL_ITEMget_dmname(t)); else - fprintf( f, " _%s = &( ( ( %s& ) o )._%s );\n", - SEL_ITEMget_dmname( t ), + fprintf(f, " _%s = &( ( ( %s& ) o )._%s );\n", + SEL_ITEMget_dmname(t), n, - SEL_ITEMget_dmname( t ) ); + SEL_ITEMget_dmname(t)); } else { - if( utype_member( dups, t, 1 ) ) + if(utype_member(dups, t, 1)) /** if in the dup list **/ - fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname( t ), + fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname(t), n, - SEL_ITEMget_dmname( t ) ); + SEL_ITEMget_dmname(t)); else - fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname( t ), + fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname(t), n, - SEL_ITEMget_dmname( t ) ); + SEL_ITEMget_dmname(t)); } - fprintf( f, " return *this;\n" ); - fprintf( f, " }\n" ); - } LISTod - fprintf( f, " return *this;\n}\n\n" ); - fprintf( f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n" ); + fprintf(f, " return *this;\n"); + fprintf(f, " }\n"); + } + LISTod + fprintf(f, " return *this;\n}\n\n"); + fprintf(f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n"); } /** * TYPEselect_init_print prints the types that belong to the select type */ -void TYPEselect_init_print( const Type type, FILE * f ) { - LISTdo( SEL_TYPEget_items( type ), t, Type ) - - fprintf( f, " %s -> Elements ().AddNode", - TYPEtd_name( type ) ); - fprintf( f, " (%s);\n", - TYPEtd_name( t ) ); +void TYPEselect_init_print(const Type type, FILE *f) +{ + LISTdo(SEL_TYPEget_items(type), t, Type) + + fprintf(f, " %s -> Elements ().AddNode", + TYPEtd_name(type)); + fprintf(f, " (%s);\n", + TYPEtd_name(t)); LISTod; } -void TYPEselect_lib_part21( const Type type, FILE * f ) { +void TYPEselect_lib_part21(const Type type, FILE *f) +{ char n[BUFSIZ]; /* pointers to class name(s) */ - const char * dm; /* data member name */ - Linked_List data_members = SELgetnew_dmlist( type ); + const char *dm; /* data member name */ + Linked_List data_members = SELgetnew_dmlist(type); - strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); - n[BUFSIZ-1] = '\0'; + strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); + n[BUFSIZ - 1] = '\0'; - fprintf( f, "\n\n// STEP Part 21\n" ); + fprintf(f, "\n\n// STEP Part 21\n"); /* write part 21 */ - fprintf( f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" - " currSch) const {\n (void)currSch;\n ", n ); + fprintf(f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" + " currSch) const {\n (void)currSch;\n ", n); /* go through the items */ - LISTdo( SEL_TYPEget_items( type ), t, Type ) - dm = SEL_ITEMget_dmname( t ); + LISTdo(SEL_TYPEget_items(type), t, Type) + dm = SEL_ITEMget_dmname(t); - fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name( t ) ); + fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name(t)); - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { - /* if it\'s a number, just print it */ + /* if it\'s a number, just print it */ case integer_: - fprintf( f, " out << _%s;\n", dm ); + fprintf(f, " out << _%s;\n", dm); break; case number_: case real_: - fprintf( f, " WriteReal(_%s,out);\n", dm ); + fprintf(f, " WriteReal(_%s,out);\n", dm); break; case entity_: - fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); + fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); break; case string_: @@ -1321,11 +1365,11 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { case boolean_: case binary_: /* for string's, enum's, select's, and binary's it'll be embedded */ - fprintf( f, " _%s.STEPwrite (out);\n", dm ); + fprintf(f, " _%s.STEPwrite (out);\n", dm); break; case select_: - fprintf( f, " _%s.STEPwrite (out, currSch);\n", dm ); + fprintf(f, " _%s.STEPwrite (out, currSch);\n", dm); /* Select type needs currSch passed too. A Select writes the name of its current choice when it writes itself out (e.g. "DATA(33.5)"). Since the current choice name may depend on our current schema (it may be a @@ -1333,7 +1377,7 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { */ break; - /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ + /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ case aggregate_: case array_: case bag_: @@ -1341,88 +1385,88 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { case list_: default: /* otherwise it\'s a pointer */ - fprintf( f, " _%s -> STEPwrite (out);\n", dm ); + fprintf(f, " _%s -> STEPwrite (out);\n", dm); break; } - fprintf( f, " return;\n" ); - fprintf( f, " }\n" ); + fprintf(f, " return;\n"); + fprintf(f, " }\n"); LISTod; PRINT_BUG_REPORT - fprintf( f, "}\n" ); + fprintf(f, "}\n"); /* ValueType() -- get type of value stored in select */ - fprintf( f, "\nBASE_TYPE\n%s::ValueType() const {\n", n ); + fprintf(f, "\nBASE_TYPE\n%s::ValueType() const {\n", n); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - dm = SEL_ITEMget_dmname( t ); - fprintf( f, " if (CurrentUnderlyingType() == %s)\n", - TYPEtd_name( t ) ); + LISTdo(SEL_TYPEget_items(type), t, Type) + dm = SEL_ITEMget_dmname(t); + fprintf(f, " if (CurrentUnderlyingType() == %s)\n", + TYPEtd_name(t)); - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case select_: - fprintf( f, " return _%s.ValueType();\n", dm ); + fprintf(f, " return _%s.ValueType();\n", dm); break; default: - fprintf( f, " return %s;\n", FundamentalType( t, 0 ) ); + fprintf(f, " return %s;\n", FundamentalType(t, 0)); } LISTod; PRINT_BUG_REPORT - fprintf( f, " return (BASE_TYPE)0;\n}\n" ); + fprintf(f, " return (BASE_TYPE)0;\n}\n"); /* STEPwrite_verbose() -- print value with specified type */ - fprintf( f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," - " const char *currSch) const\n{\n", n ); + fprintf(f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," + " const char *currSch) const\n{\n", n); /* Get name of typedescriptor, according to value of currSch: */ - fprintf( f, " const TypeDescriptor *td = CurrentUnderlyingType();\n" ); - fprintf( f, " std::string tmp;\n\n" ); - fprintf( f, " if ( td ) {\n" ); - fprintf( f, " // If we have a legal underlying type, get its name acc\n" ); - fprintf( f, " // to the current schema.\n" ); - fprintf( f, " StrToUpper( td->Name(currSch), tmp );\n" ); - fprintf( f, " }\n" ); + fprintf(f, " const TypeDescriptor *td = CurrentUnderlyingType();\n"); + fprintf(f, " std::string tmp;\n\n"); + fprintf(f, " if ( td ) {\n"); + fprintf(f, " // If we have a legal underlying type, get its name acc\n"); + fprintf(f, " // to the current schema.\n"); + fprintf(f, " StrToUpper( td->Name(currSch), tmp );\n"); + fprintf(f, " }\n"); /* Next loop through the possible items: */ - LISTdo( SEL_TYPEget_items( type ), t, Type ) - dm = SEL_ITEMget_dmname( t ); - fprintf( f, " if (td == %s) {\n", - TYPEtd_name( t ) ); + LISTdo(SEL_TYPEget_items(type), t, Type) + dm = SEL_ITEMget_dmname(t); + fprintf(f, " if (td == %s) {\n", + TYPEtd_name(t)); - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case integer_: /* fprintf(f, " out << \"%s(\" << _%s << \")\";\n else ", StrToUpper(TYPEget_name(t)), dm);*/ - fprintf( f, " out << tmp << \"(\" << _%s << \")\";\n", - dm ); + fprintf(f, " out << tmp << \"(\" << _%s << \")\";\n", + dm); break; case real_: case number_: - fprintf( f, " out << tmp << \"(\";\n" ); - fprintf( f, " WriteReal(_%s,out);\n", dm ); - fprintf( f, " out << \")\";\n" ); + fprintf(f, " out << tmp << \"(\";\n"); + fprintf(f, " WriteReal(_%s,out);\n", dm); + fprintf(f, " out << \")\";\n"); break; case entity_: - fprintf( f, " out << tmp << \"(\";\n" ); - fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); - fprintf( f, " out << \")\";\n" ); + fprintf(f, " out << tmp << \"(\";\n"); + fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); + fprintf(f, " out << \")\";\n"); break; case string_: case enumeration_: case logical_: case boolean_: case binary_: - fprintf( f, " out << tmp << \"(\";\n" ); - fprintf( f, " _%s.STEPwrite (out);\n", dm ); - fprintf( f, " out << \")\";\n" ); + fprintf(f, " out << tmp << \"(\";\n"); + fprintf(f, " _%s.STEPwrite (out);\n", dm); + fprintf(f, " out << \")\";\n"); break; case aggregate_: case array_: @@ -1430,78 +1474,78 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { case set_: case list_: /* Aggregates need currSch passed since they may be aggrs of sels. */ - fprintf( f, " out << tmp << \"(\";\n" ); - fprintf( f, " _%s%sSTEPwrite (out, currSch);\n", dm, - ( ( t->u.type->body->base ) ? "->" : "." ) ); - fprintf( f, " out << \")\";\n" ); + fprintf(f, " out << tmp << \"(\";\n"); + fprintf(f, " _%s%sSTEPwrite (out, currSch);\n", dm, + ((t->u.type->body->base) ? "->" : ".")); + fprintf(f, " out << \")\";\n"); break; case select_: - fprintf( f, " out << tmp << \"(\";\n" ); - fprintf( f, " _%s.STEPwrite_verbose (out, currSch);\n", dm ); - fprintf( f, " out << \")\";\n" ); + fprintf(f, " out << tmp << \"(\";\n"); + fprintf(f, " _%s.STEPwrite_verbose (out, currSch);\n", dm); + fprintf(f, " out << \")\";\n"); break; default: - fprintf( f, " _%s -> STEPwrite (out); \n", dm ); + fprintf(f, " _%s -> STEPwrite (out); \n", dm); break; } - fprintf( f, " return;\n" ); - fprintf( f, " }\n" ); + fprintf(f, " return;\n"); + fprintf(f, " }\n"); LISTod; PRINT_BUG_REPORT - fprintf( f, " return;\n}\n" ); + fprintf(f, " return;\n}\n"); /* Read part 21 */ - fprintf( f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" - " const char *utype, int addFileId, const char *currSch)\n{\n" - " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n ); + fprintf(f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" + " const char *utype, int addFileId, const char *currSch)\n{\n" + " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n); /* go through the items */ - LISTdo( SEL_TYPEget_items( type ), t, Type ) + LISTdo(SEL_TYPEget_items(type), t, Type) - fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name( t ) ); + fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name(t)); - dm = SEL_ITEMget_dmname( t ); + dm = SEL_ITEMget_dmname(t); - switch( TYPEget_body( t )->type ) { - /* if it's a number, just read it */ + switch(TYPEget_body(t)->type) { + /* if it's a number, just read it */ case real_: case number_: /* since REAL and NUMBER are handled the same they both need to be included in the case stmt */ - fprintf( f, - " ReadReal (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm ); + fprintf(f, + " ReadReal (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm); break; case integer_: - fprintf( f, - " ReadInteger (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm ); + fprintf(f, + " ReadInteger (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm); break; case entity_: /* if it's an entity, use Assign - done in Select class */ - fprintf( f, - " // set Underlying Type in Select class\n" - " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm ); - fprintf( f, - " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " - " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" - " return severity();\n", dm, dm, dm ); - fprintf( f, - " } else {\n " - " Error (\"Reference to instance that is not indicated type\\n\");\n" - " _%s = 0;\n" - " nullify ();\n" - " return severity (SEVERITY_USERMSG);\n" - " }\n", dm ); + fprintf(f, + " // set Underlying Type in Select class\n" + " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm); + fprintf(f, + " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " + " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" + " return severity();\n", dm, dm, dm); + fprintf(f, + " } else {\n " + " Error (\"Reference to instance that is not indicated type\\n\");\n" + " _%s = 0;\n" + " nullify ();\n" + " return severity (SEVERITY_USERMSG);\n" + " }\n", dm); break; case string_: @@ -1509,68 +1553,69 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { case logical_: case boolean_: case binary_: - fprintf( f, - " _%s.STEPread (in, &_error);\n" - " return severity ();\n", - dm ); + fprintf(f, + " _%s.STEPread (in, &_error);\n" + " return severity ();\n", + dm); break; case select_: - fprintf( f, - " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" - " return severity ();\n", - dm ); + fprintf(f, + " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" + " return severity ();\n", + dm); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf( f, - " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" - " instances, addFileId, currSch);\n", - dm, ( ( t->u.type->body->base ) ? "->" : "." ), - TYPEtd_name( t ) ); - fprintf( f, - " return severity ();\n" ); + fprintf(f, + " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" + " instances, addFileId, currSch);\n", + dm, ((t->u.type->body->base) ? "->" : "."), + TYPEtd_name(t)); + fprintf(f, + " return severity ();\n"); break; default: - fprintf( f, - " _%s -> STEPread (in, &_error, instances, addFileId);\n" - " return severity ();\n", - dm ); + fprintf(f, + " _%s -> STEPread (in, &_error, instances, addFileId);\n" + " return severity ();\n", + dm); break; } - fprintf( f, " }\n" ); + fprintf(f, " }\n"); LISTod; - PRINT_SELECTBUG_WARNING( f ) ; + PRINT_SELECTBUG_WARNING(f) ; - LISTfree( data_members ); - fprintf( f, " return severity ();\n}\n" ); + LISTfree(data_members); + fprintf(f, " return severity ();\n}\n"); } -void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { +void TYPEselect_lib_StrToVal(const Type type, FILE *f) +{ char n[BUFSIZ]; /* pointers to class name */ - Linked_List data_members = SELgetnew_dmlist( type ); + Linked_List data_members = SELgetnew_dmlist(type); int enum_cnt = 0; - strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); - n[BUFSIZ-1] = '\0'; + strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); + n[BUFSIZ - 1] = '\0'; /* read StrToVal_content */ - fprintf( f, "\nSeverity\n%s::StrToVal_content " - "(const char * str, InstMgrBase * instances)" - "\n{\n (void)str;\n (void)instances;\n", n ); + fprintf(f, "\nSeverity\n%s::StrToVal_content " + "(const char * str, InstMgrBase * instances)" + "\n{\n (void)str;\n (void)instances;\n", n); - fprintf( f, " switch (base_type) {\n" ); - LISTdo( data_members, t, Type ) + fprintf(f, " switch (base_type) {\n"); + LISTdo(data_members, t, Type) /* fprintf (f, " case %s : \n", FundamentalType (t, 0));*/ - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case real_: case integer_: @@ -1590,23 +1635,23 @@ void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { case logical_: case boolean_: case enumeration_: - if( !enum_cnt ) { + if(!enum_cnt) { /* if there\'s more than one enumeration they are done in Select class */ - fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); - fprintf( f, - " return _%s.StrToVal (str, &_error);\n", - SEL_ITEMget_dmname( t ) ); + fprintf(f, " case %s : \n", FundamentalType(t, 0)); + fprintf(f, + " return _%s.StrToVal (str, &_error);\n", + SEL_ITEMget_dmname(t)); } else { - fprintf( f, " // case %s : done in Select class\n", FundamentalType( t, 0 ) ); + fprintf(f, " // case %s : done in Select class\n", FundamentalType(t, 0)); } ++enum_cnt; break; case string_: - fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); - fprintf( f, - " return _%s.StrToVal (str);\n", - SEL_ITEMget_dmname( t ) ); + fprintf(f, " case %s : \n", FundamentalType(t, 0)); + fprintf(f, + " return _%s.StrToVal (str);\n", + SEL_ITEMget_dmname(t)); break; case aggregate_: @@ -1614,258 +1659,265 @@ void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { case bag_: case set_: case list_: - fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); - fprintf( f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname( t ), - ( ( t->u.type->body->base ) ? "->" : "." ), - TYPEtd_name( t ) ); + fprintf(f, " case %s : \n", FundamentalType(t, 0)); + fprintf(f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname(t), + ((t->u.type->body->base) ? "->" : "."), + TYPEtd_name(t)); break; default: /* otherwise use StrToVal on the contents to check the format */ - fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); - fprintf( f, - " return _%s -> StrToVal (str, instances);\n", - SEL_ITEMget_dmname( t ) ); + fprintf(f, " case %s : \n", FundamentalType(t, 0)); + fprintf(f, + " return _%s -> StrToVal (str, instances);\n", + SEL_ITEMget_dmname(t)); } LISTod; - fprintf( f, " default: // should never be here - done in Select class\n" ); - PRINT_SELECTBUG_WARNING( f ) ; - fprintf( f, "#ifdef __SUNCPLUSPLUS__\n" - "std::cerr << str << \" \" << instances << std::endl;\n" - "#endif\n" ); - fprintf( f, " return SEVERITY_WARNING;\n }\n" ); - - LISTfree( data_members ); - fprintf( f, - "#ifdef __GNUG__\n" - "\n return SEVERITY_NULL;\n" - "#endif" - "\n}\n" ); + fprintf(f, " default: // should never be here - done in Select class\n"); + PRINT_SELECTBUG_WARNING(f) ; + fprintf(f, "#ifdef __SUNCPLUSPLUS__\n" + "std::cerr << str << \" \" << instances << std::endl;\n" + "#endif\n"); + fprintf(f, " return SEVERITY_WARNING;\n }\n"); + + LISTfree(data_members); + fprintf(f, + "#ifdef __GNUG__\n" + "\n return SEVERITY_NULL;\n" + "#endif" + "\n}\n"); } -void TYPEselect_lib_virtual( const Type type, FILE * f ) { - TYPEselect_lib_part21( type, f ); - TYPEselect_lib_StrToVal( type, f ); +void TYPEselect_lib_virtual(const Type type, FILE *f) +{ + TYPEselect_lib_part21(type, f); + TYPEselect_lib_StrToVal(type, f); } -void SELlib_print_protected( const Type type, FILE * f ) { - const char * snm; +void SELlib_print_protected(const Type type, FILE *f) +{ + const char *snm; /* SELECT::AssignEntity */ - fprintf( f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" - "{\n (void)se;\n", - SelectName( TYPEget_name( type ) ) + fprintf(f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" + "{\n (void)se;\n", + SelectName(TYPEget_name(type)) ); /* loop through the items in the SELECT */ - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( TYPEis_entity( t ) ) { - fprintf( f, - " // %s\n" /* item name */ - " if (se -> IsA (%s))\n" /* td */ - " { \n" - " _%s = (%s_ptr) se;\n" /* underlying data member */ - /* underlying data member type */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper( TYPEget_name( t ) ), - TYPEtd_name( t ), - SEL_ITEMget_dmname( t ), - ClassName( TYPEget_name( t ) ), - TYPEtd_name( t ) + LISTdo(SEL_TYPEget_items(type), t, Type) + if(TYPEis_entity(t)) { + fprintf(f, + " // %s\n" /* item name */ + " if (se -> IsA (%s))\n" /* td */ + " { \n" + " _%s = (%s_ptr) se;\n" /* underlying data member */ + /* underlying data member type */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper(TYPEget_name(t)), + TYPEtd_name(t), + SEL_ITEMget_dmname(t), + ClassName(TYPEget_name(t)), + TYPEtd_name(t) ); } - if( TYPEis_select( t ) ) { - fprintf( f, - " // %s\n" /* item name */ - " if( %s->CanBe( se->eDesc ) ) {\n" - " _%s.AssignEntity (se);\n" /* underlying data member */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper( TYPEget_name( t ) ), - TYPEtd_name( t ), - SEL_ITEMget_dmname( t ), - TYPEtd_name( t ) + if(TYPEis_select(t)) { + fprintf(f, + " // %s\n" /* item name */ + " if( %s->CanBe( se->eDesc ) ) {\n" + " _%s.AssignEntity (se);\n" /* underlying data member */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper(TYPEget_name(t)), + TYPEtd_name(t), + SEL_ITEMget_dmname(t), + TYPEtd_name(t) ); } LISTod; - fprintf( f, " // should never be here - done in Select class\n" ); - PRINT_SELECTBUG_WARNING( f ) ; - fprintf( f, - "#ifdef __SUNCPLUSPLUS__\n" - " std::cerr << se -> EntityName () << std::endl;\n" - "#endif\n" - " return 0;\n}\n" ); + fprintf(f, " // should never be here - done in Select class\n"); + PRINT_SELECTBUG_WARNING(f) ; + fprintf(f, + "#ifdef __SUNCPLUSPLUS__\n" + " std::cerr << se -> EntityName () << std::endl;\n" + "#endif\n" + " return 0;\n}\n"); /* SELECT::NewSelect */ - snm = SelectName( TYPEget_name( type ) ); - fprintf( f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm ); + snm = SelectName(TYPEget_name(type)); + fprintf(f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm); - fprintf( f, " %s * tmp = new %s();\n", snm, snm ); - fprintf( f, " return tmp;\n}\n" ); + fprintf(f, " %s * tmp = new %s();\n", snm, snm); + fprintf(f, " return tmp;\n}\n"); } /** * TYPEselect_lib_print prints the member functions (definitions) of a select class. */ -void TYPEselect_lib_print( const Type type, FILE * f ) { +void TYPEselect_lib_print(const Type type, FILE *f) +{ char n[BUFSIZ], m[BUFSIZ]; - const char * z; /* pointers to class name(s) */ + const char *z; /* pointers to class name(s) */ Linked_List dups; int dup_result; - dup_result = find_duplicate_list( type, &dups ); - strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); - fprintf( f, "\n////////// SELECT TYPE %s\n", TYPEget_name( type ) ); + dup_result = find_duplicate_list(type, &dups); + strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); + fprintf(f, "\n////////// SELECT TYPE %s\n", TYPEget_name(type)); - SELlib_print_protected( type, f ) ; - TYPEselect_lib_virtual( type, f ); - TYPEselect_lib_print_part_one( type, f, dups, n ); + SELlib_print_protected(type, f) ; + TYPEselect_lib_virtual(type, f); + TYPEselect_lib_print_part_one(type, f, dups, n); - fprintf( f, "\n // part 2\n" ); + fprintf(f, "\n // part 2\n"); - LISTdo( SEL_TYPEget_items( type ), t, Type ) { - if( TYPEis_entity( t ) ) { + LISTdo(SEL_TYPEget_items(type), t, Type) { + if(TYPEis_entity(t)) { /* if an entity */ - fprintf( f, "%s::operator %s_ptr()\n{\n", n, ClassName( TYPEget_name( t ) ) ); - fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); - fprintf( f, " return ((%s_ptr) _%s);\n", ClassName( TYPEget_name( t ) ), SEL_ITEMget_dmname( t ) ); - PRINT_SELECTBUG_WARNING( f ); - fprintf( f, " return NULL;\n}\n\n" ); - } else if( !utype_member( dups, t, 1 ) ) { + fprintf(f, "%s::operator %s_ptr()\n{\n", n, ClassName(TYPEget_name(t))); + fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); + fprintf(f, " return ((%s_ptr) _%s);\n", ClassName(TYPEget_name(t)), SEL_ITEMget_dmname(t)); + PRINT_SELECTBUG_WARNING(f); + fprintf(f, " return NULL;\n}\n\n"); + } else if(!utype_member(dups, t, 1)) { /** if not in the dup list **/ - fprintf( f, "%s::operator %s()\n{\n", n, AccessType( t ) ); - fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); - fprintf( f, " return %s _%s;\n", ( ( TYPEis_select( t ) ) ? "&" : "" ), SEL_ITEMget_dmname( t ) ); - fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); - fprintf( f, " Error( \"Underlying type is not %s\" );\n", AccessType( t ) ); - PRINT_SELECTBUG_WARNING( f ) ; - if( TYPEis_boolean( t ) || TYPEis_logical( t ) ) { - fprintf( f, " return (%s)0;\n}\n\n", TYPEget_utype( t ) ); + fprintf(f, "%s::operator %s()\n{\n", n, AccessType(t)); + fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); + fprintf(f, " return %s _%s;\n", ((TYPEis_select(t)) ? "&" : ""), SEL_ITEMget_dmname(t)); + fprintf(f, "\n severity( SEVERITY_WARNING );\n"); + fprintf(f, " Error( \"Underlying type is not %s\" );\n", AccessType(t)); + PRINT_SELECTBUG_WARNING(f) ; + if(TYPEis_boolean(t) || TYPEis_logical(t)) { + fprintf(f, " return (%s)0;\n}\n\n", TYPEget_utype(t)); } else { - fprintf( f, " return 0;\n}\n\n" ); + fprintf(f, " return 0;\n}\n\n"); } } - } LISTod - LISTdo( dups, t, Type ) { - if( ! TYPEis_entity( t ) ) { /* entities were done already */ - fprintf( f, "%s::operator %s()\n{\n", n, - ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? - AccessType( t ) : TYPEget_utype( t ) ); - strncpy( m, TYPEget_utype( t ), BUFSIZ ); + } + LISTod + LISTdo(dups, t, Type) { + if(! TYPEis_entity(t)) { /* entities were done already */ + fprintf(f, "%s::operator %s()\n{\n", n, + (TYPEis_aggregate(t) || TYPEis_select(t)) ? + AccessType(t) : TYPEget_utype(t)); + strncpy(m, TYPEget_utype(t), BUFSIZ); /**** MUST CHANGE FOR multiple big types ****/ - LISTdo_n( SEL_TYPEget_items( type ), x, Type, b ) { - if( ( strcmp( m, TYPEget_utype( x ) ) == 0 ) - || ( compareOrigTypes( t, x ) ) ) { + LISTdo_n(SEL_TYPEget_items(type), x, Type, b) { + if((strcmp(m, TYPEget_utype(x)) == 0) + || (compareOrigTypes(t, x))) { /* If this is one of the dups. compareOrigTypes checks if x\'s type is a rename of t\'s (see comments there). */ - fprintf( f, " if( CurrentUnderlyingType () == %s )\n", - TYPEtd_name( x ) ); - fprintf( f, " return %s _%s;\n", - ( ( TYPEis_select( x ) ) ? "&" : "" ), - SEL_ITEMget_dmname( x ) ); + fprintf(f, " if( CurrentUnderlyingType () == %s )\n", + TYPEtd_name(x)); + fprintf(f, " return %s _%s;\n", + ((TYPEis_select(x)) ? "&" : ""), + SEL_ITEMget_dmname(x)); } - } LISTod - fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); - fprintf( f, " Error( \"Underlying type is not %s\" );\n", - TYPEis_aggregate( t ) ? - AccessType( t ) : TYPEget_utype( t ) ); - PRINT_SELECTBUG_WARNING( f ) ; - fprintf( f, " return (%s)0;\n}\n\n", - TYPEis_aggregate( t ) ? - AccessType( t ) : TYPEget_utype( t ) ); + } + LISTod + fprintf(f, "\n severity( SEVERITY_WARNING );\n"); + fprintf(f, " Error( \"Underlying type is not %s\" );\n", + TYPEis_aggregate(t) ? + AccessType(t) : TYPEget_utype(t)); + PRINT_SELECTBUG_WARNING(f) ; + fprintf(f, " return (%s)0;\n}\n\n", + TYPEis_aggregate(t) ? + AccessType(t) : TYPEget_utype(t)); /* fprintf( f, " return NULL;\n}\n\n" ); */ } - } LISTod - - TYPEselect_lib_print_part_three( type, f, n ); - TYPEselect_lib_print_part_four( type, f, dups, n ); - - fprintf( f, "\n // part 5\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - z = FirstToUpper( TYPEget_name( t ) ); - fprintf( f, "Logical %s::Is%s() const\n{\n", n, z ); - fprintf( f, " if( !exists() )\n" ); - fprintf( f, " return LUnknown;\n" ); - fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); - fprintf( f, " return LTrue;\n" ); - fprintf( f, " return LFalse;\n}\n\n" ); + } + LISTod + + TYPEselect_lib_print_part_three(type, f, n); + TYPEselect_lib_print_part_four(type, f, dups, n); + + fprintf(f, "\n // part 5\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) + z = FirstToUpper(TYPEget_name(t)); + fprintf(f, "Logical %s::Is%s() const\n{\n", n, z); + fprintf(f, " if( !exists() )\n"); + fprintf(f, " return LUnknown;\n"); + fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); + fprintf(f, " return LTrue;\n"); + fprintf(f, " return LFalse;\n}\n\n"); LISTod; #ifdef UNDERLYINGTYPE - fprintf( f, "\n // part 6\n" ); - fprintf( f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n ); - fprintf( f, " if( exists() )\n" ); - fprintf( f, " {\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); - if( TYPEis_entity( t ) ) - fprintf( f, " return( _%s->Name() );\n" - StrToLower( TYPEget_name( t ) ) ); + fprintf(f, "\n // part 6\n"); + fprintf(f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n); + fprintf(f, " if( exists() )\n"); + fprintf(f, " {\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) + fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); + if(TYPEis_entity(t)) + fprintf(f, " return( _%s->Name() );\n" + StrToLower(TYPEget_name(t))); else { - fprintf( f, " return( \"%s\" );\n", TYPEget_utype( t ) ); + fprintf(f, " return( \"%s\" );\n", TYPEget_utype(t)); } LISTod; - fprintf( f, " }\n return NULL;\n}\n\n" ); - - fprintf( f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n ); - fprintf( f, " if( exists() )\n" ); - fprintf( f, " {\n" ); - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( TYPEis_entity( t ) ) { - fprintf( f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype( t ) ); - fprintf( f, " return( _%s->eDesc );\n", - SEL_ITEMget_dmname( t ) ); + fprintf(f, " }\n return NULL;\n}\n\n"); + + fprintf(f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n); + fprintf(f, " if( exists() )\n"); + fprintf(f, " {\n"); + LISTdo(SEL_TYPEget_items(type), t, Type) + if(TYPEis_entity(t)) { + fprintf(f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype(t)); + fprintf(f, " return( _%s->eDesc );\n", + SEL_ITEMget_dmname(t)); } LISTod; - fprintf( f, " }\n return NULL;\n}\n\n" ); + fprintf(f, " }\n return NULL;\n}\n\n"); #endif - if( dup_result ) { - fprintf( f, "\n // part 7\n" ); - fprintf( f, - "const TypeDescriptor * \n" - "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" - " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", - n ); + if(dup_result) { + fprintf(f, "\n // part 7\n"); + fprintf(f, + "const TypeDescriptor * \n" + "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" + " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", + n); } #ifdef PART8 - fprintf( f, "\n // part 8\n" ); - fprintf( f, "%s* %s::operator->()\n", n, n ); - fprintf( f, "{\n return this;\n}\n" ); + fprintf(f, "\n // part 8\n"); + fprintf(f, "%s* %s::operator->()\n", n, n); + fprintf(f, "{\n return this;\n}\n"); #endif - LISTfree( dups ); + LISTfree(dups); - fprintf( f, "////////// END SELECT TYPE %s\n\n", n ); + fprintf(f, "////////// END SELECT TYPE %s\n\n", n); } -void TYPEselect_print( Type t, FILES * files, Schema schema ) { +void TYPEselect_print(Type t, FILES *files, Schema schema) +{ SelectTag tag, tmp; Type i, bt; /* type of elements in an aggregate */ char nm[BUFSIZ], tdnm[BUFSIZ]; - FILE * inc = files->inc; + FILE *inc = files->inc; /* if type is already marked, return */ - if( ( tmp = ( SelectTag ) TYPEget_clientData( t ) ) ) { - if( ( tmp ->started ) && ( ! tmp ->complete ) ) - fprintf( stderr, "WARNING: SELECT type %s causes circular references\n", - TYPEget_name( t ) ); + if((tmp = (SelectTag) TYPEget_clientData(t))) { + if((tmp ->started) && (! tmp ->complete)) + fprintf(stderr, "WARNING: SELECT type %s causes circular references\n", + TYPEget_name(t)); return; } /* mark the type as being processed */ - tag = ( SelectTag ) sc_malloc( sizeof( struct SelectTag_ ) ); + tag = (SelectTag) sc_malloc(sizeof(struct SelectTag_)); tag -> started = 1; tag -> complete = 0; - TYPEput_clientData( t, ( ClientData ) tag ); + TYPEput_clientData(t, (ClientData) tag); /* Check if we're a renamed type, e.g., TYPE B (sel) = A. If so, if A has @@ -1873,48 +1925,48 @@ void TYPEselect_print( Type t, FILES * files, Schema schema ) { some are printed in files->classes rather than here). If A has not been defined, we must recurse. */ - if( ( i = TYPEget_ancestor( t ) ) != NULL ) { - if( !TYPEget_clientData( i ) ) { - TYPEselect_print( i, files, schema ); + if((i = TYPEget_ancestor(t)) != NULL) { + if(!TYPEget_clientData(i)) { + TYPEselect_print(i, files, schema); } - strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); - strncpy( tdnm, TYPEtd_name( t ), BUFSIZ ); - fprintf( inc, "typedef %s * %sH;\n", nm, nm ); - fprintf( inc, "typedef %s_ptr * %s_var;\n", nm, nm ); + strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); + strncpy(tdnm, TYPEtd_name(t), BUFSIZ); + fprintf(inc, "typedef %s * %sH;\n", nm, nm); + fprintf(inc, "typedef %s_ptr * %s_var;\n", nm, nm); /* Below are specialized create functions for the renamed sel type (both single and aggregate). The functions call the original sel's con- structor, passing the new sel's typedescriptor to create a hybrid entity - the original select pointing to a new typedesc. These fns give the user an easy way to create the renamed type properly. */ - fprintf( inc, "inline SDAI_Select *\ncreate_%s ()", nm ); - fprintf( inc, " { return new %s( %s ); }\n\n", nm, tdnm ); - fprintf( inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm ); - fprintf( inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm ); + fprintf(inc, "inline SDAI_Select *\ncreate_%s ()", nm); + fprintf(inc, " { return new %s( %s ); }\n\n", nm, tdnm); + fprintf(inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm); + fprintf(inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm); return; } - LISTdo( SEL_TYPEget_items( t ), ii, Type ) { + LISTdo(SEL_TYPEget_items(t), ii, Type) { /* check the items for select types */ /* and do the referenced select types first */ /* check aggregates too */ /* set ii to the bt and catch in next ifs */ - if( isAggregateType( ii ) ) { - bt = TYPEget_base_type( ii ); + if(isAggregateType(ii)) { + bt = TYPEget_base_type(ii); /* DAR - corrected - prev'ly above line retrieved non-aggr base type. But unnec - we only need the item defined if it's a select or a 1D aggregate. If bt is also an aggr, we go on. */ - if( TYPEis_select( bt ) ) { + if(TYPEis_select(bt)) { ii = bt; - } else if( TYPEis_entity( bt ) ) { + } else if(TYPEis_entity(bt)) { ii = bt; } } - if( TYPEis_select( ii ) && !TYPEget_clientData( ii ) ) { - TYPEselect_print( ii, files, schema ); + if(TYPEis_select(ii) && !TYPEget_clientData(ii)) { + TYPEselect_print(ii, files, schema); } /* NOTE - there was a bug here because above if did not take into account that ii came from a different schema (and above loop would have printed @@ -1925,16 +1977,17 @@ void TYPEselect_print( Type t, FILES * files, Schema schema ) { schema. So the above if will only reorder the printing of the sel's in this schema, which is the intent. DAR */ - } LISTod + } + LISTod - TYPEPrint(t, files, schema ); + TYPEPrint(t, files, schema); /* TYPEselect_inc_print( t, files -> inc ); */ /* TYPEselect_lib_print( t, files -> lib ); */ /* TYPEselect_init_print (t, files -> init, schema); DAR - moved to TYPEprint_init() - to keep init info together. */ tag -> complete = 1; - sc_free( tag ); + sc_free(tag); } #undef BASE_SELECT diff --git a/src/exp2cxx/trynext.cc b/src/exp2cxx/trynext.cc index 97cacc8a3..cb50d2eed 100644 --- a/src/exp2cxx/trynext.cc +++ b/src/exp2cxx/trynext.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static EntList * firstCandidate( EntList * ); -static EntList * nextCandidate( EntList * ); +static EntList *firstCandidate(EntList *); +static EntList *nextCandidate(EntList *); -MatchType MultList::tryNext( EntNode * ents ) +MatchType MultList::tryNext(EntNode *ents) /* * Loops backwards through the children of this, recursively searching for * alternate solutions (i.e., OR's which have alternate paths we haven't @@ -31,15 +31,15 @@ MatchType MultList::tryNext( EntNode * ents ) */ { MatchType retval; - EntList * child = getLast(); + EntList *child = getLast(); - child = firstCandidate( child ); - while( child != NULL ) { - if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { + child = firstCandidate(child); + while(child != NULL) { + if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { // We're done - a good solution was found. return MATCHALL; } - if( retval == NEWCHOICE ) { + if(retval == NEWCHOICE) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -47,83 +47,83 @@ MatchType MultList::tryNext( EntNode * ents ) // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while( ( child = nextCandidate( child ) ) != NULL ) { - if( child->acceptChoice( ents ) && ents->allMarked() ) { + while((child = nextCandidate(child)) != NULL) { + if(child->acceptChoice(ents) && ents->allMarked()) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate( child->prev ); + child = firstCandidate(child->prev); } // If we got here, we didn't find any new OR choices: return NOMORE; } -static EntList * firstCandidate( EntList * child ) +static EntList *firstCandidate(EntList *child) /* * Finds an EntList from child's list which may have an OR with more * choices below it. The acceptable choices are described in commenting * below. */ { - EntList * ent = child->lastNot( SIMPLE ); + EntList *ent = child->lastNot(SIMPLE); - while( ent != NULL ) { - if( ent->viableVal() >= MATCHSOME ) { + while(ent != NULL) { + if(ent->viableVal() >= MATCHSOME) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot( SIMPLE ); + ent = ent->prevNot(SIMPLE); } return ent; } -static EntList * nextCandidate( EntList * child ) +static EntList *nextCandidate(EntList *child) /* * Same as prev function, searches forwards from ent after child. */ { - EntList * ent = child->nextNot( SIMPLE ); + EntList *ent = child->nextNot(SIMPLE); - while( ent != NULL ) { - if( ent->viableVal() >= MATCHSOME ) { + while(ent != NULL) { + if(ent->viableVal() >= MATCHSOME) { return ent; } - ent = ent->nextNot( SIMPLE ); + ent = ent->nextNot(SIMPLE); } return ent; } -MatchType OrList::tryNext( EntNode * ents ) +MatchType OrList::tryNext(EntNode *ents) /* * Tries out the next choice of this. Basic algorithm is to first recurse * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ { - EntList * child; + EntList *child; - if( choice == LISTEND ) { + if(choice == LISTEND) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild( choice ); - if( child->multiple() ) { - MatchType retval; + child = getChild(choice); + if(child->multiple()) { + MatchType retval; // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ); - if( retval == MATCHALL ) { + retval = (dynamic_cast< MultList * >(child))->tryNext(ents); + if(retval == MATCHALL) { return MATCHALL; } - if( retval == NEWCHOICE ) { + if(retval == NEWCHOICE) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -134,8 +134,8 @@ MatchType OrList::tryNext( EntNode * ents ) // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll( ents ); - if( choiceCount == 1 ) { + child->unmarkAll(ents); + if(choiceCount == 1) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -144,8 +144,8 @@ MatchType OrList::tryNext( EntNode * ents ) } // Otherwise, try our next: - if( acceptNextChoice( ents ) ) { - if( ents->allMarked() ) { + if(acceptNextChoice(ents)) { + if(ents->allMarked()) { return MATCHALL; } return NEWCHOICE; diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 964aca652..1318ec1ed 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -14,9 +14,9 @@ #include // Local function prototypes: -static void writeheader( ostream &, int ); +static void writeheader(ostream &, int); -void print_complex( ComplexCollect & collect, const char * filename ) +void print_complex(ComplexCollect &collect, const char *filename) /* * Standalone function called from exp2cxx. Takes a ComplexCollect * and writes its contents to a file (filename) which can be used to @@ -24,19 +24,19 @@ void print_complex( ComplexCollect & collect, const char * filename ) */ { #ifdef COMPLEX_INFO - ComplexList * cl; - if( collect.clists ) { + ComplexList *cl; + if(collect.clists) { // If there's something in this collect, print it out: cout << "\nHere's everything:\n"; - for( cl = collect.clists; cl != NULL; cl = cl->next ) { + for(cl = collect.clists; cl != NULL; cl = cl->next) { cout << *cl << endl; } } #endif - collect.write( filename ); + collect.write(filename); } -void ComplexCollect::write( const char * fname ) +void ComplexCollect::write(const char *fname) /* * Generates C++ code in os which may be compiled and run to create a * ComplexCollect structure. Functions are called to write out the @@ -44,22 +44,22 @@ void ComplexCollect::write( const char * fname ) */ { ofstream complex; - ComplexList * clist; + ComplexList *clist; int maxlevel, listmax; // Open the stream: - complex.open( fname ); - if( !complex ) { + complex.open(fname); + if(!complex) { cerr << "ERROR: Could not create output file " << fname << endl; // yikes this is pretty drastic, Sun C++ doesn't like this anyway DAS // exit(-1); return; } - writeheader( complex, clists == NULL ); + writeheader(complex, clists == NULL); // If there's nothing in this, make function a stub (very little was // printed in writeheader() also): - if( clists == NULL ) { + if(clists == NULL) { complex << " return 0;" << endl; complex << "}" << endl; complex.close(); @@ -75,9 +75,9 @@ void ComplexCollect::write( const char * fname ) // of an array to create. maxlevel = 0; clist = clists; - while( clist ) { + while(clist) { listmax = clist->getEntListMaxLevel(); - if( listmax > maxlevel ) { + if(listmax > maxlevel) { maxlevel = listmax; } clist = clist->next; @@ -88,11 +88,11 @@ void ComplexCollect::write( const char * fname ) // Next create the CCollect and CLists: complex << " cc = new ComplexCollect;\n"; clist = clists; - while( clist ) { + while(clist) { complex << endl; complex << " // ComplexList with supertype \"" << clist->supertype() << "\":\n"; - clist->write( complex ); + clist->write(complex); complex << " cc->insert( cl );\n"; clist = clist->next; } @@ -103,14 +103,14 @@ void ComplexCollect::write( const char * fname ) complex.close(); } -static void writeheader( ostream & os, int noLists ) +static void writeheader(ostream &os, int noLists) /* * Writes the header for the complex file. */ { // If there are no ComplexLists in the ComplexCollect, make this function // a stub: - if( noLists ) { + if(noLists) { os << "/*" << endl << " * This file normally contains instantiation statements to\n" << " * create complex support structures. For the current EXPRESS\n" @@ -142,39 +142,39 @@ static void writeheader( ostream & os, int noLists ) os << "{" << endl; } -void ComplexList::write( ostream & os ) +void ComplexList::write(ostream &os) /* * Generates C++ code in os which will create an instantiation of a CList * which will recreate this. */ { - head->write( os ); + head->write(os); os << " cl = new ComplexList((AndList *)node);\n"; os << " cl->buildList();\n"; os << " cl->head->setLevel( 0 );\n"; } -void MultList::write( ostream & os ) +void MultList::write(ostream &os) /* * Writes to os code to instantiate a replica of this. Does so by first * recursing to replicate this's children, and then instantiating this. * When write() is finished, the "node" variable in os will point to this. */ { - EntList * child = getLast(); + EntList *child = getLast(); // First write our children, from last to first. (We go in backwards order // so that "node" (a variable name in the os) will = our first child when // this loop is done. See below.) - child->write( os ); - while( child->prev ) { + child->write(os); + while(child->prev) { // Whenever an EntList::write() function is called, it writes to os // an instantiation statement basically of the form "node = new XXX- // List;". So we know that in the output file (os) the newly-created // EntList is pointed to by variable node. os << " next[" << level + 1 << "] = node;\n"; child = child->prev; - child->write( os ); + child->write(os); os << " next[" << level + 1 << "]->prev = node;\n"; os << " node->next = next[" << level + 1 << "];\n"; } @@ -186,9 +186,9 @@ void MultList::write( ostream & os ) // node. We do this so that node will = this when we're done and return // to the calling function (so the calling fn can make the same assumption // we just did). - if( join == AND ) { + if(join == AND) { os << " node = new AndList;\n"; - } else if( join == ANDOR ) { + } else if(join == ANDOR) { os << " node = new AndOrList;\n"; } else { os << " node = new OrList;\n"; @@ -197,7 +197,7 @@ void MultList::write( ostream & os ) // The above line will set node's childList and numchidren count. } -void SimpleList::write( ostream & os ) +void SimpleList::write(ostream &os) /* * Writes to os a statement to instantiate this. */ diff --git a/src/exp2python/src/classes.h b/src/exp2python/src/classes.h index a76cb6afa..715a7e550 100644 --- a/src/exp2python/src/classes.h +++ b/src/exp2python/src/classes.h @@ -51,86 +51,86 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define TYPEtd_name(t) TypeDescriptorName (t) typedef struct file_holder { - FILE * inc; /**< include file */ - FILE * lib; /**< library file */ - FILE * incall; /**< include file for collecting all include files */ - FILE * initall; /**< for registering all entities from all schemas */ - FILE * init; /**< contains function to initialize program to use schema's entities */ - FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE *inc; /**< include file */ + FILE *lib; /**< library file */ + FILE *incall; /**< include file for collecting all include files */ + FILE *initall; /**< for registering all entities from all schemas */ + FILE *init; /**< contains function to initialize program to use schema's entities */ + FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ - FILE * helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for + FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE *helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for helper functions to find runtime aggregate bounds */ } File_holder, FILES; /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ * EntityTag; +typedef struct EntityTag_ *EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ Entity superclass; /**< the entity being used as the supertype - with multiple inheritance only chose one */ }; -Entity ENTITYget_superclass( Entity entity ); -Entity ENTITYput_superclass( Entity entity ); -int ENTITYhas_explicit_attributes( Entity e ); -void ENTITYget_first_attribs( Entity entity, Linked_List result ); +Entity ENTITYget_superclass(Entity entity); +Entity ENTITYput_superclass(Entity entity); +int ENTITYhas_explicit_attributes(Entity e); +void ENTITYget_first_attribs(Entity entity, Linked_List result); /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ * SelectTag; +typedef struct SelectTag_ *SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char * GetTypeDescriptorName( Type t ); -char * format_for_stringout( char * orig_buf, char * return_buf ); -void format_for_std_stringout( FILE* f, char* orig_buf ); -const char * CheckWord( const char * ); -const char * StrToLower( const char * ); -const char * StrToUpper( const char * ); -const char * FirstToUpper( const char * ); -const char * SelectName( const char * ); -FILE * FILEcreate( const char * ); -void FILEclose( FILE * ); -const char * ClassName( const char * ); -const char * ENTITYget_classname( Entity ); -void FUNCPrint( Function function, FILES* files ); -void RULEPrint( Rule rule, FILES* files ); -void ENTITYPrint( Entity, FILES * ); -const char * StrToConstant( const char * ); -void TYPEselect_print( Type, FILES *, Schema ); -void ENTITYprint_new( Entity, FILES *, Schema, int ); -void TYPEprint_definition( Type, FILES *, Schema ); -void TYPEprint_new( const Type, FILE *, Schema ); -void TYPEprint_typedefs( Type, FILE * ); -void TYPEprint_descriptions( const Type, FILES *, Schema ); -void TYPEprint_init( const Type type, FILES * files, Schema schema ); -void AGGRprint_init( FILES * files, const Type t, - const char * var_name, const char * aggr_name ); -void TYPEselect_init_print( const Type type, FILE* f ); -void MODELPrint( Entity, FILES *, Schema, int ); -void MODELprint_new( Entity entity, FILES* files ); -void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); -const char * PrettyTmpName( const char * oldname ); -const char * EnumName( const char * oldname ); -const char * TypeDescriptorName( Type ); -char * TypeDescription( const Type t ); -const char * AccessType( Type t ); -const char * TYPEget_ctype( const Type t ); -void print_file( Express ); -void resolution_success( void ); -void SCHEMAprint( Schema schema, FILES* files, int suffix ); -Type TYPEget_ancestor( Type t ); -const char * FundamentalType( const Type t, int report_reftypes ); +const char *GetTypeDescriptorName(Type t); +char *format_for_stringout(char *orig_buf, char *return_buf); +void format_for_std_stringout(FILE *f, char *orig_buf); +const char *CheckWord(const char *); +const char *StrToLower(const char *); +const char *StrToUpper(const char *); +const char *FirstToUpper(const char *); +const char *SelectName(const char *); +FILE *FILEcreate(const char *); +void FILEclose(FILE *); +const char *ClassName(const char *); +const char *ENTITYget_classname(Entity); +void FUNCPrint(Function function, FILES *files); +void RULEPrint(Rule rule, FILES *files); +void ENTITYPrint(Entity, FILES *); +const char *StrToConstant(const char *); +void TYPEselect_print(Type, FILES *, Schema); +void ENTITYprint_new(Entity, FILES *, Schema, int); +void TYPEprint_definition(Type, FILES *, Schema); +void TYPEprint_new(const Type, FILE *, Schema); +void TYPEprint_typedefs(Type, FILE *); +void TYPEprint_descriptions(const Type, FILES *, Schema); +void TYPEprint_init(const Type type, FILES *files, Schema schema); +void AGGRprint_init(FILES *files, const Type t, + const char *var_name, const char *aggr_name); +void TYPEselect_init_print(const Type type, FILE *f); +void MODELPrint(Entity, FILES *, Schema, int); +void MODELprint_new(Entity entity, FILES *files); +void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); +const char *PrettyTmpName(const char *oldname); +const char *EnumName(const char *oldname); +const char *TypeDescriptorName(Type); +char *TypeDescription(const Type t); +const char *AccessType(Type t); +const char *TYPEget_ctype(const Type t); +void print_file(Express); +void resolution_success(void); +void SCHEMAprint(Schema schema, FILES *files, int suffix); +Type TYPEget_ancestor(Type t); +const char *FundamentalType(const Type t, int report_reftypes); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -138,12 +138,12 @@ const char * FundamentalType( const Type t, int report_reftypes ); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider( Entity e, Variable a ); +Variable VARis_overrider(Entity e, Variable a); /* Added for multiple schema support: */ -void print_schemas_separate( Express, FILES * ); -void getMCPrint( Express, FILE *, FILE * ); -int sameSchema( Scope, Scope ); +void print_schemas_separate(Express, FILES *); +void getMCPrint(Express, FILE *, FILE *); +int sameSchema(Scope, Scope); #endif diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index a425f0d88..9e32f6189 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -34,11 +34,12 @@ extern int multiple_inheritance; ** Status: started 12/1 ******************************************************************/ const char * -CheckWord( const char * word ) { +CheckWord(const char *word) +{ #ifdef NOT_USING_SDAI_BINDING /* obsolete with proposed c++ binding */ - static char * reserved_words [] = { + static char *reserved_words [] = { "application_marker", "asm", "attributes", "auto", "break", "case", "char", "class", "const", "continue", "default", "delete", "do", "double", @@ -52,30 +53,30 @@ CheckWord( const char * word ) { "union", "unsigned", "val", "virtual", "void", "volatile" }; - int nwords = ( sizeof reserved_words / sizeof reserved_words[0] ); + int nwords = (sizeof reserved_words / sizeof reserved_words[0]); int cond, i, low = 0, high = nwords - 1; /* word is obviously not in list, if it is longer than any of the words in the list */ - if( strlen( word ) > 18 ) { - return ( word ); + if(strlen(word) > 18) { + return (word); } - while( low <= high ) { - i = ( low + high ) / 2; - if( ( cond = strcmp( word, reserved_words [i] ) ) < 0 ) { + while(low <= high) { + i = (low + high) / 2; + if((cond = strcmp(word, reserved_words [i])) < 0) { high = i - 1; - } else if( cond > 0 ) { + } else if(cond > 0) { low = i + 1; } else { /* word is a reserved word, capitalize it */ - fprintf( stderr, "Warning: reserved word %s capitalized\n", word ); - *word = toupper( *word ); + fprintf(stderr, "Warning: reserved word %s capitalized\n", word); + *word = toupper(*word); } } #endif - return ( word ); + return (word); } @@ -91,239 +92,255 @@ CheckWord( const char * word ) { ******************************************************************/ char -ToLower( char c ) { - if( isupper( c ) ) { - return ( tolower( c ) ); +ToLower(char c) +{ + if(isupper(c)) { + return (tolower(c)); } else { - return ( c ); + return (c); } } char -ToUpper( char c ) { - if( islower( c ) ) { - return ( toupper( c ) ); +ToUpper(char c) +{ + if(islower(c)) { + return (toupper(c)); } else { - return ( c ); + return (c); } } const char * -StrToLower( const char * word ) { +StrToLower(const char *word) +{ static char newword [MAX_LEN]; int i = 0; - if( !word ) { + if(!word) { return 0; } - while( word [i] != '\0' ) { - newword [i] = ToLower( word [i] ); + while(word [i] != '\0') { + newword [i] = ToLower(word [i]); ++i; } newword [i] = '\0'; - return ( newword ) ; + return (newword) ; } -const char * StrToUpper( const char * word ) { +const char *StrToUpper(const char *word) +{ static char newword [MAX_LEN]; int i = 0; - char ToUpper( char c ); + char ToUpper(char c); - while( word [i] != '\0' ) { - newword [i] = ToUpper( word [i] ); + while(word [i] != '\0') { + newword [i] = ToUpper(word [i]); ++i; } newword [i] = '\0'; - return ( newword ); + return (newword); } -const char * StrToConstant( const char * word ) { +const char *StrToConstant(const char *word) +{ static char newword [MAX_LEN]; int i = 0; - while( word [i] != '\0' ) { - if( word [i] == '/' || word [i] == '.' ) { + while(word [i] != '\0') { + if(word [i] == '/' || word [i] == '.') { newword [i] = '_'; } else { - newword [i] = ToUpper( word [i] ); + newword [i] = ToUpper(word [i]); } ++i; } newword [i] = '\0'; - return ( newword ); + return (newword); } /** creates a file for python */ -FILE * FILEcreate( const char * filename ) { - FILE * file; +FILE *FILEcreate(const char *filename) +{ + FILE *file; - if( ( file = fopen( filename, "w" ) ) == NULL ) { - fprintf( stderr, "Error in SCHEMAprint: unable to create file %s\n", filename ); - return ( NULL ); + if((file = fopen(filename, "w")) == NULL) { + fprintf(stderr, "Error in SCHEMAprint: unable to create file %s\n", filename); + return (NULL); } - fprintf( file, "# This file was generated by exp2python. You probably don't want to edit\n" ); - fprintf( file, "# it since your modifications will be lost if exp2python is used to\n" ); - fprintf( file, "# regenerate it.\n" ); - return ( file ); + fprintf(file, "# This file was generated by exp2python. You probably don't want to edit\n"); + fprintf(file, "# it since your modifications will be lost if exp2python is used to\n"); + fprintf(file, "# regenerate it.\n"); + return (file); } /** closes a file opened with FILEcreate */ -void FILEclose( FILE * file ) { - fclose( file ); +void FILEclose(FILE *file) +{ + fclose(file); } /** indicates whether the attribute is an aggregate */ -int isAggregate( Variable a ) { - return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); +int isAggregate(Variable a) +{ + return(TYPEinherits_from(VARget_type(a), aggregate_)); } /** indicates whether the type is an aggregate type */ -int isAggregateType( const Type t ) { - return( TYPEinherits_from( t, aggregate_ ) ); +int isAggregateType(const Type t) +{ + return(TYPEinherits_from(t, aggregate_)); } /** returns temporary copy of name suitable for use as a class name * * each call erases the name created by a previous call to this function */ -const char * ClassName( const char * oldname ) { +const char *ClassName(const char *oldname) +{ int i = 0, j = 0; static char newname [BUFSIZ]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, ENTITYCLASS_PREFIX ) ; - j = strlen( ENTITYCLASS_PREFIX ) ; - newname [j] = ToUpper( oldname [i] ); + strcpy(newname, ENTITYCLASS_PREFIX) ; + j = strlen(ENTITYCLASS_PREFIX) ; + newname [j] = ToUpper(oldname [i]); ++i; ++j; - while( oldname [i] != '\0' ) { - newname [j] = ToLower( oldname [i] ); + while(oldname [i] != '\0') { + newname [j] = ToLower(oldname [i]); ++i; ++j; } newname [j] = '\0'; - return ( newname ); + return (newname); } /** returns the name of the c++ class representing the entity */ -const char * ENTITYget_classname( Entity ent ) { - const char * oldname = ENTITYget_name( ent ); - return ( ClassName( oldname ) ); +const char *ENTITYget_classname(Entity ent) +{ + const char *oldname = ENTITYget_name(ent); + return (ClassName(oldname)); } /** returns a new capitalized name, in internal static buffer */ -const char * PrettyTmpName( const char * oldname ) { +const char *PrettyTmpName(const char *oldname) +{ int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { - newname [i] = ToLower( oldname [i] ); - if( oldname [i] == '_' ) { /* character is '_' */ + while((oldname [i] != '\0') && (i < BUFSIZ)) { + newname [i] = ToLower(oldname [i]); + if(oldname [i] == '_') { /* character is '_' */ ++i; - newname [i] = ToUpper( oldname [i] ); + newname [i] = ToUpper(oldname [i]); } - if( oldname [i] != '\0' ) { + if(oldname [i] != '\0') { ++i; } } - newname [0] = ToUpper( oldname [0] ); + newname [0] = ToUpper(oldname [0]); newname [i] = '\0'; return newname; } /** This function is out of date DAS */ -const char * EnumName( const char * oldname ) { +const char *EnumName(const char *oldname) +{ int j = 0; static char newname [MAX_LEN]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, ENUM_PREFIX ) ; - j = strlen( ENUM_PREFIX ) ; - newname [j] = ToUpper( oldname [0] ); - strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); - j = strlen( newname ); + strcpy(newname, ENUM_PREFIX) ; + j = strlen(ENUM_PREFIX) ; + newname [j] = ToUpper(oldname [0]); + strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); + j = strlen(newname); newname [j] = '\0'; - return ( newname ); + return (newname); } -const char * SelectName( const char * oldname ) { +const char *SelectName(const char *oldname) +{ int j = 0; static char newname [MAX_LEN]; - if( !oldname ) { - return ( "" ); + if(!oldname) { + return (""); } - strcpy( newname, TYPE_PREFIX ); - newname [0] = ToUpper( newname [0] ); - j = strlen( TYPE_PREFIX ); - newname [j] = ToUpper( oldname [0] ); - strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); - j = strlen( newname ); + strcpy(newname, TYPE_PREFIX); + newname [0] = ToUpper(newname [0]); + j = strlen(TYPE_PREFIX); + newname [j] = ToUpper(oldname [0]); + strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); + j = strlen(newname); newname [j] = '\0'; - return ( newname ); + return (newname); } -const char * FirstToUpper( const char * word ) { +const char *FirstToUpper(const char *word) +{ static char newword [MAX_LEN]; - strncpy( newword, word, MAX_LEN ); - newword[0] = ToUpper( newword[0] ); - return ( newword ); + strncpy(newword, word, MAX_LEN); + newword[0] = ToUpper(newword[0]); + return (newword); } /** return fundamental type but as the string which corresponds to * the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char * FundamentalType( const Type t, int report_reftypes ) { - if( report_reftypes && TYPEget_head( t ) ) { - return( "REFERENCE_TYPE" ); +const char *FundamentalType(const Type t, int report_reftypes) +{ + if(report_reftypes && TYPEget_head(t)) { + return("REFERENCE_TYPE"); } - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case integer_: - return( "INTEGER" ); + return("INTEGER"); case real_: - return( "REAL" ); + return("REAL"); case string_: - return( "STRING" ); + return("STRING"); case binary_: - return( "BINARY" ); + return("BINARY"); case boolean_: - return( "BOOLEAN" ); + return("BOOLEAN"); case logical_: - return( "LOGICAL" ); + return("LOGICAL"); case number_: - return( "NUMBER" ); + return("NUMBER"); case generic_: - return( "GENERIC_TYPE" ); + return("GENERIC_TYPE"); case aggregate_: - return( "AGGREGATE_" ); + return("AGGREGATE_"); case array_: - return( "ARRAY_TYPE" ); + return("ARRAY_TYPE"); case bag_: - return( "BAG_TYPE" ); + return("BAG_TYPE"); case set_: - return( "'SET_TYPE not implemented'" ); + return("'SET_TYPE not implemented'"); case list_: - return( "'LIST TYPE Not implemented'" ); + return("'LIST TYPE Not implemented'"); case entity_: - return( "INSTANCE" ); + return("INSTANCE"); case enumeration_: - return( "ENUMERATION" ); + return("ENUMERATION"); case select_: - return ( "SELECT" ); + return ("SELECT"); default: - return( "UNKNOWN_TYPE" ); + return("UNKNOWN_TYPE"); } } @@ -331,30 +348,32 @@ const char * FundamentalType( const Type t, int report_reftypes ) { * be a TypeDescriptor or subtype of TypeDescriptor to represent Type t in * the dictionary. */ -const char * TypeDescriptorName( Type t ) { +const char *TypeDescriptorName(Type t) +{ static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if( !parent ) { - parent = TYPEget_body( t )->entity->superscope; + if(!parent) { + parent = TYPEget_body(t)->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf( b, "%s%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), - TYPEget_name( t ) ); + sprintf(b, "%s%s%s", SCHEMAget_name(parent), TYPEprefix(t), + TYPEget_name(t)); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char * GetTypeDescriptorName( Type t ) { - switch( TYPEget_body( t )->type ) { +const char *GetTypeDescriptorName(Type t) +{ + switch(TYPEget_body(t)->type) { case aggregate_: return "AggrTypeDescriptor"; @@ -389,16 +408,17 @@ const char * GetTypeDescriptorName( Type t ) { case generic_: return "TypeDescriptor"; default: - fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); + fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); abort(); } } -int ENTITYhas_explicit_attributes( Entity e ) { - Linked_List l = ENTITYget_attributes( e ); +int ENTITYhas_explicit_attributes(Entity e) +{ + Linked_List l = ENTITYget_attributes(e); int cnt = 0; - LISTdo( l, a, Variable ) - if( VARget_initializer( a ) == EXPRESSION_NULL ) { + LISTdo(l, a, Variable) + if(VARget_initializer(a) == EXPRESSION_NULL) { ++cnt; } LISTod; @@ -406,21 +426,22 @@ int ENTITYhas_explicit_attributes( Entity e ) { } -Entity ENTITYput_superclass( Entity entity ) { +Entity ENTITYput_superclass(Entity entity) +{ #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes( entity ); + Linked_List l = ENTITYget_supertypes(entity); EntityTag tag; - if( ! LISTempty( l ) ) { + if(! LISTempty(l)) { Entity super = 0; - if( multiple_inheritance ) { + if(multiple_inheritance) { Linked_List list = 0; - list = ENTITYget_supertypes( entity ); - if( ! LISTempty( list ) ) { + list = ENTITYget_supertypes(entity); + if(! LISTempty(list)) { /* assign superclass to be the first one on the list of parents */ - super = ( Entity )LISTpeek_first( list ); + super = (Entity)LISTpeek_first(list); } } else { Entity ignore = 0; @@ -428,50 +449,53 @@ Entity ENTITYput_superclass( Entity entity ) { /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo( l, e, Entity ) { + LISTdo(l, e, Entity) { /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { + if((! super) || (! ENTITYhas_explicit_attributes(super))) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if( ignore ) { - printf( "WARNING: multiple inheritance not implemented.\n" ); - printf( "\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", - ENTITYget_name( entity ), ENTITYget_name( e ) ); + if(ignore) { + printf("WARNING: multiple inheritance not implemented.\n"); + printf("\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", + ENTITYget_name(entity), ENTITYget_name(e)); } - } LISTod + } + LISTod } - tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) ); + tag = (EntityTag) malloc(sizeof(struct EntityTag_)); tag -> superclass = super; - TYPEput_clientData( ENTITYget_type( entity ), tag ); + TYPEput_clientData(ENTITYget_type(entity), tag); return super; } return 0; } -Entity ENTITYget_superclass( Entity entity ) { +Entity ENTITYget_superclass(Entity entity) +{ EntityTag tag; - tag = TYPEget_clientData( ENTITYget_type( entity ) ); - return ( tag ? tag -> superclass : 0 ); + tag = TYPEget_clientData(ENTITYget_type(entity)); + return (tag ? tag -> superclass : 0); } -void ENTITYget_first_attribs( Entity entity, Linked_List result ) { +void ENTITYget_first_attribs(Entity entity, Linked_List result) +{ Linked_List supers; - LISTdo( ENTITYget_attributes( entity ), attr, void * ) - LISTadd_last( result, attr ); + LISTdo(ENTITYget_attributes(entity), attr, void *) + LISTadd_last(result, attr); LISTod; - supers = ENTITYget_supertypes( entity ); - if( supers ) { - ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); + supers = ENTITYget_supertypes(entity); + if(supers) { + ENTITYget_first_attribs((Entity)LISTget_first(supers), result); } } @@ -505,33 +529,35 @@ void ENTITYget_first_attribs( Entity entity, Linked_List result ) { ** // tell it to be * for reading and writing **/ -Variable VARis_type_shifter( Variable a ) { - char * temp; +Variable VARis_type_shifter(Variable a) +{ + char *temp; - if( VARis_derived( a ) || VARget_inverse( a ) ) { + if(VARis_derived(a) || VARget_inverse(a)) { return 0; } - temp = strdup( VARget_name( a )->symbol.name ); - if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { + temp = strdup(VARget_name(a)->symbol.name); + if(! strncmp(StrToLower(temp), "self\\", 5)) { /* a is a type shifter */ - free( temp ); + free(temp); return a; } - free( temp ); + free(temp); return 0; } -Variable VARis_overrider( Entity e, Variable a ) { +Variable VARis_overrider(Entity e, Variable a) +{ Variable other; - char * tmp; + char *tmp; - tmp = VARget_simple_name( a ); + tmp = VARget_simple_name(a); - LISTdo( ENTITYget_supertypes( e ), s, Entity ) - if( ( other = ENTITYget_named_attribute( s, tmp ) ) - && other != a ) { + LISTdo(ENTITYget_supertypes(e), s, Entity) + if((other = ENTITYget_named_attribute(s, tmp)) + && other != a) { return other; } LISTod; @@ -542,15 +568,16 @@ Variable VARis_overrider( Entity e, Variable a ) { * For a renamed type, returns the original (ancestor) type from which t * descends. Return NULL if t is top level. */ -Type TYPEget_ancestor( Type t ) { +Type TYPEget_ancestor(Type t) +{ Type i = t; - if( !TYPEget_head( i ) ) { + if(!TYPEget_head(i)) { return NULL; } - while( TYPEget_head( i ) ) { - i = TYPEget_head( i ); + while(TYPEget_head(i)) { + i = TYPEget_head(i); } return i; diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 8c672868a..087388402 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -49,11 +49,11 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. # define snprintf c99_snprintf #endif -int isAggregateType( const Type t ); -int isAggregate( Variable a ); -Variable VARis_type_shifter( Variable a ); -const char * GetTypeDescriptorName( Type t ); -void TYPEselect_lib_print( const Type type, FILE * f ); +int isAggregateType(const Type t); +int isAggregate(Variable a); +Variable VARis_type_shifter(Variable a); +const char *GetTypeDescriptorName(Type t); +void TYPEselect_lib_print(const Type type, FILE *f); int multiple_inheritance = 1; int print_logging = 0; @@ -74,37 +74,37 @@ int old_accessors = 0; static int attr_count; /* number each attr to avoid inter-entity clashes */ /* static int type_count; NOTE unused / * number each temporary type for same reason above */ -extern int any_duplicates_in_select( const Linked_List list ); -extern int unique_types( const Linked_List list ); -extern char * non_unique_types_string( const Type type ); +extern int any_duplicates_in_select(const Linked_List list); +extern int unique_types(const Linked_List list); +extern char *non_unique_types_string(const Type type); /* static void printEnumCreateHdr( FILE *, const Type ); //NOTE - unused * static void printEnumCreateBody( FILE *, const Type ); * static void printEnumAggrCrHdr( FILE *, const Type ); * static void printEnumAggrCrBody( FILE *, const Type ); */ -void printAccessHookFriend( FILE *, const char * ); -void printAccessHookHdr( FILE *, const char * ); -int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); -void TypeBody_Description( TypeBody body, char * buf ); - -void STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ); -void STATEMENTPrint( Statement s, int indent_level, FILE * file ); -void STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ); -void EXPRESSION__out( Expression e, int paren, Op_Code previous_op , FILE * file ); -void EXPRESSIONop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); -void EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); -void EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); -void ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ); -void ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); -void ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); -void ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); -void CASEout( struct Case_Statement_ *c, int level, FILE * file ); -void LOOPpyout( struct Loop_ *loop, int level, FILE * file ); -void WHEREPrint( Linked_List wheres, int level , FILE * file ); - -void Type_Description( const Type, char * ); - -char * EXPRto_python( Expression e ); +void printAccessHookFriend(FILE *, const char *); +void printAccessHookHdr(FILE *, const char *); +int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); +void TypeBody_Description(TypeBody body, char *buf); + +void STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file); +void STATEMENTPrint(Statement s, int indent_level, FILE *file); +void STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file); +void EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file); +void EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); +void EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); +void EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); +void ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file); +void ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); +void ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); +void ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); +void CASEout(struct Case_Statement_ *c, int level, FILE *file); +void LOOPpyout(struct Loop_ *loop, int level, FILE *file); +void WHEREPrint(Linked_List wheres, int level, FILE *file); + +void Type_Description(const Type, char *); + +char *EXPRto_python(Expression e); /* Turn the string into a new string that will be printed the same as the @@ -112,15 +112,16 @@ original string. That is, turn backslash into a quoted backslash and turn \n into "\n" (i.e. 2 chars). */ -char * format_for_stringout( char * orig_buf, char * return_buf ) { - char * optr = orig_buf; - char * rptr = return_buf; - while( *optr ) { - if( *optr == '\n' ) { +char *format_for_stringout(char *orig_buf, char *return_buf) +{ + char *optr = orig_buf; + char *rptr = return_buf; + while(*optr) { + if(*optr == '\n') { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if( *optr == '\\' ) { + } else if(*optr == '\\') { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -134,52 +135,61 @@ char * format_for_stringout( char * orig_buf, char * return_buf ) { return return_buf; } -char * strliteral_py_dup( char * orig_buf ) { - char * new_buf = strdup(orig_buf); - char * tmp = new_buf; +char *strliteral_py_dup(char *orig_buf) +{ + char *new_buf = strdup(orig_buf); + char *tmp = new_buf; - while ((tmp = strstr(tmp, "\\x9"))) { - tmp++ ; *tmp = 't'; tmp++; - memmove(tmp, tmp+1, strlen(tmp)); + while((tmp = strstr(tmp, "\\x9"))) { + tmp++ ; + *tmp = 't'; + tmp++; + memmove(tmp, tmp + 1, strlen(tmp)); } tmp = new_buf; - while ((tmp = strstr(tmp, "\\xA"))) { - tmp++ ; *tmp = 'n'; tmp++; - memmove(tmp, tmp+1, strlen(tmp)); + while((tmp = strstr(tmp, "\\xA"))) { + tmp++ ; + *tmp = 'n'; + tmp++; + memmove(tmp, tmp + 1, strlen(tmp)); } tmp = new_buf; - while ((tmp = strstr(tmp, "\\xD"))) { - tmp++ ; *tmp = 'r'; tmp++; - memmove(tmp, tmp+1, strlen(tmp)); + while((tmp = strstr(tmp, "\\xD"))) { + tmp++ ; + *tmp = 'r'; + tmp++; + memmove(tmp, tmp + 1, strlen(tmp)); } - + return new_buf; } -int Handle_FedPlus_Args( int i, char * arg ) { +int Handle_FedPlus_Args(int i, char *arg) +{ (void) arg; /* unused param */ - if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { + if(((char)i == 's') || ((char)i == 'S')) { multiple_inheritance = 0; } - if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { + if(((char)i == 'a') || ((char)i == 'A')) { old_accessors = 1; } - if( ( char )i == 'L' ) { + if((char)i == 'L') { print_logging = 1; } return 0; } -bool is_python_keyword( char * word ) { +bool is_python_keyword(char *word) +{ int i; - const char* keyword_list[] = {"class", "pass", NULL}; + const char *keyword_list[] = {"class", "pass", NULL}; bool python_keyword = false; - for( i = 0; keyword_list[i] != NULL; i++ ) { - if( strcmp( word, keyword_list[i] ) == 0 ) { + for(i = 0; keyword_list[i] != NULL; i++) { + if(strcmp(word, keyword_list[i]) == 0) { python_keyword = true; } } @@ -195,46 +205,48 @@ bool is_python_keyword( char * word ) { ** Status: complete 8/5/93 ******************************************************************/ char * -generate_attribute_name( Variable a, char * out ) { - char * temp, *p, *q; +generate_attribute_name(Variable a, char *out) +{ + char *temp, *p, *q; int j; - Expression name = VARget_name( a ); - temp = strdup( EXPget_name( name ) ); + Expression name = VARget_name(a); + temp = strdup(EXPget_name(name)); p = temp; - if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { + if(! strncmp(StrToLower(p), "self\\", 5)) { p = p + 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for( j = 0, q = out; j < BUFSIZ; p++ ) { + for(j = 0, q = out; j < BUFSIZ; p++) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert */ /* '.' to '_', and convert to lowercase. */ - if( ( *p != '\n' ) && ( *p != ' ' ) ) { - if( *p == '.' ) { + if((*p != '\n') && (*p != ' ')) { + if(*p == '.') { *q = '_'; } else { - *q = tolower( *p ); + *q = tolower(*p); } j++; q++; } } - free( temp ); + free(temp); /* python generator : we should prevend an attr name to be a python reserved keyword */ - if( is_python_keyword( out ) ) { - strcat( out, "_" ); + if(is_python_keyword(out)) { + strcat(out, "_"); } return out; } char * -generate_attribute_func_name( Variable a, char * out ) { - generate_attribute_name( a, out ); - strncpy( out, CheckWord( StrToLower( out ) ), BUFSIZ ); - if( old_accessors ) { - out[0] = toupper( out[0] ); +generate_attribute_func_name(Variable a, char *out) +{ + generate_attribute_name(a, out); + strncpy(out, CheckWord(StrToLower(out)), BUFSIZ); + if(old_accessors) { + out[0] = toupper(out[0]); } else { - out[strlen( out )] = '_'; + out[strlen(out)] = '_'; } return out; } @@ -260,28 +272,29 @@ generate_attribute_func_name( Variable a, char * out ) { ** Status: complete 8/5/93 ******************************************************************/ char * -generate_dict_attr_name( Variable a, char * out ) { - char * temp, *p, *q; +generate_dict_attr_name(Variable a, char *out) +{ + char *temp, *p, *q; int j; - Expression name = VARget_name( a ); - temp = strdup( EXPget_name( name ) ); + Expression name = VARget_name(a); + temp = strdup(EXPget_name(name)); p = temp; - if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { + if(! strncmp(StrToLower(p), "self\\", 5)) { p = p + 5; } /* copy p to out */ - strncpy( out, StrToLower( p ), BUFSIZ ); + strncpy(out, StrToLower(p), BUFSIZ); /* DAR - fixed so that '\n's removed */ - for( j = 0, q = out; j < BUFSIZ; p++ ) { + for(j = 0, q = out; j < BUFSIZ; p++) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if( *p != '\n' ) { - *q = tolower( *p ); + if(*p != '\n') { + *q = tolower(*p); j++; q++; } } - free( temp ); + free(temp); return out; } @@ -316,20 +329,21 @@ generate_dict_attr_name( Variable a, char * out ) { ** Status: ok 12-Apr-1993 ******************************************************************/ char * -GetAttrTypeName( Type t ) { - char * attr_type; - if( TYPEis_string( t ) ) { +GetAttrTypeName(Type t) +{ + char *attr_type; + if(TYPEis_string(t)) { attr_type = "STRING"; - } else if( TYPEis_logical( t ) ) { + } else if(TYPEis_logical(t)) { attr_type = "LOGICAL"; - } else if( TYPEis_boolean( t ) ) { + } else if(TYPEis_boolean(t)) { attr_type = "BOOLEAN"; - } else if( TYPEis_real( t ) ) { + } else if(TYPEis_real(t)) { attr_type = "REAL"; - } else if( TYPEis_integer( t ) ) { + } else if(TYPEis_integer(t)) { attr_type = "INTEGER"; } else { - attr_type = TYPEget_name( t ); + attr_type = TYPEget_name(t); } return attr_type; } @@ -341,19 +355,20 @@ GetAttrTypeName( Type t ) { */ void -print_aggregate_type( FILE * file, Type t ) { - switch( TYPEget_body( t )->type ) { +print_aggregate_type(FILE *file, Type t) +{ + switch(TYPEget_body(t)->type) { case array_: - fprintf( file, "ARRAY" ); + fprintf(file, "ARRAY"); break; case bag_: - fprintf( file, "BAG" ); + fprintf(file, "BAG"); break; case set_: - fprintf( file, "SET" ); + fprintf(file, "SET"); break; case list_: - fprintf( file, "LIST" ); + fprintf(file, "LIST"); break; default: break; @@ -363,111 +378,112 @@ print_aggregate_type( FILE * file, Type t ) { #define BIGBUFSIZ 100000 -char* EXPRto_python( Expression e ) { - char * buf; - char * temp; +char *EXPRto_python(Expression e) +{ + char *buf; + char *temp; unsigned int bufsize = BIGBUFSIZ; - buf = ( char * )sc_malloc( bufsize ); - if( !buf ) { - fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno) ); + buf = (char *)sc_malloc(bufsize); + if(!buf) { + fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno)); abort(); } - switch( TYPEis( e->type ) ) { + switch(TYPEis(e->type)) { case integer_: - snprintf( buf, bufsize, "%d", e->u.integer ); + snprintf(buf, bufsize, "%d", e->u.integer); break; case real_: - if( e == LITERAL_PI ) { - strcpy( buf, "math.pi" ); - } else if( e == LITERAL_E ) { - strcpy( buf, "math.e" ); + if(e == LITERAL_PI) { + strcpy(buf, "math.pi"); + } else if(e == LITERAL_E) { + strcpy(buf, "math.e"); } else { - snprintf( buf, bufsize, "%e", e->u.real ); + snprintf(buf, bufsize, "%e", e->u.real); } break; case binary_: - snprintf( buf, bufsize, "%s", e->u.binary ); + snprintf(buf, bufsize, "%s", e->u.binary); break; case logical_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - strcpy( buf, "True" ); + strcpy(buf, "True"); break; case Lfalse: - strcpy( buf, "False" ); + strcpy(buf, "False"); break; default: - strcpy( buf, "None" ); + strcpy(buf, "None"); break; } - break; + break; case boolean_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - strcpy( buf, "True" ); + strcpy(buf, "True"); break; case Lfalse: - strcpy( buf, "False" ); + strcpy(buf, "False"); break; } - break; + break; case string_: - if( TYPEis_encoded( e->type ) ) { - snprintf( buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name ); + if(TYPEis_encoded(e->type)) { + snprintf(buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name); } else { - temp = strliteral_py_dup( e->symbol.name ); - strncpy( buf, temp, bufsize ); - free(temp); + temp = strliteral_py_dup(e->symbol.name); + strncpy(buf, temp, bufsize); + free(temp); } break; case entity_: case identifier_: case attribute_: case enumeration_: - snprintf( buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name ); + snprintf(buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name); break; case query_: - strcpy( buf, "# query_ NOT_IMPLEMENTED!" ); + strcpy(buf, "# query_ NOT_IMPLEMENTED!"); break; case self_: - strcpy( buf, "self" ); + strcpy(buf, "self"); + break; + case funcall_: { + int i = 0; + snprintf(buf, bufsize, "%s(", e->symbol.name); + LISTdo(e->u.funcall.list, arg, Expression) { + i++; + if(i != 1) { + strcat(buf, ", "); + } + temp = EXPRto_python(arg); + strcat(buf, temp); + free(temp); + } + LISTod + strcat(buf, ")"); break; - case funcall_: - { - int i = 0; - snprintf( buf, bufsize, "%s(", e->symbol.name ); - LISTdo( e->u.funcall.list, arg, Expression ) { - i++; - if( i != 1 ) { - strcat( buf, ", " ); - } - temp = EXPRto_python( arg ); - strcat( buf, temp ); - free( temp ); - } LISTod - strcat( buf, ")" ); - break; } case op_: - strcpy( buf, "# op_ NOT_IMPLEMENTED!" ); + strcpy(buf, "# op_ NOT_IMPLEMENTED!"); break; case aggregate_: - strcpy( buf, "# aggregate_ NOT_IMPLEMENTED!" ); + strcpy(buf, "# aggregate_ NOT_IMPLEMENTED!"); break; case oneof_: { - strcpy( buf, "# oneof_ NOT_IMPLEMENTED!" ); + strcpy(buf, "# oneof_ NOT_IMPLEMENTED!"); break; } default: - fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); + fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); abort(); } - temp = ( char * )sc_realloc( buf, 1 + strlen(buf) ); - if( temp == 0 ) { - fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno) ); + temp = (char *)sc_realloc(buf, 1 + strlen(buf)); + if(temp == 0) { + fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno)); abort(); } @@ -480,73 +496,77 @@ char* EXPRto_python( Expression e ) { * */ void -process_aggregate( FILE * file, Type t ) { - Expression lower = AGGR_TYPEget_lower_limit( t ); - char * lower_str = EXPRto_python( lower ); - Expression upper = AGGR_TYPEget_upper_limit( t ); - char * upper_str = NULL; +process_aggregate(FILE *file, Type t) +{ + Expression lower = AGGR_TYPEget_lower_limit(t); + char *lower_str = EXPRto_python(lower); + Expression upper = AGGR_TYPEget_upper_limit(t); + char *upper_str = NULL; Type base_type; - if( upper == LITERAL_INFINITY ) { + if(upper == LITERAL_INFINITY) { upper_str = "None"; } else { - upper_str = EXPRto_python( upper ); + upper_str = EXPRto_python(upper); } - switch( TYPEget_body( t )->type ) { + switch(TYPEget_body(t)->type) { case array_: - fprintf( file, "ARRAY" ); + fprintf(file, "ARRAY"); break; case bag_: - fprintf( file, "BAG" ); + fprintf(file, "BAG"); break; case set_: - fprintf( file, "SET" ); + fprintf(file, "SET"); break; case list_: - fprintf( file, "LIST" ); + fprintf(file, "LIST"); break; default: break; } - fprintf( file, "(%s,%s,", lower_str, upper_str ); + fprintf(file, "(%s,%s,", lower_str, upper_str); /*write base type */ - base_type = TYPEget_base_type( t ); - if( TYPEis_aggregate( base_type ) ) { - process_aggregate( file, base_type ); - fprintf( file, ")" ); /*close parenthesis */ + base_type = TYPEget_base_type(t); + if(TYPEis_aggregate(base_type)) { + process_aggregate(file, base_type); + fprintf(file, ")"); /*close parenthesis */ } else { - char * array_base_type = GetAttrTypeName( TYPEget_base_type( t ) ); - fprintf( file, "'%s', scope = schema_scope)", array_base_type ); + char *array_base_type = GetAttrTypeName(TYPEget_base_type(t)); + fprintf(file, "'%s', scope = schema_scope)", array_base_type); } } -int count_supertypes(Entity f) { +int count_supertypes(Entity f) +{ int top_count; int child_count; Linked_List list; list = ENTITYget_supertypes(f); top_count = 0; - LISTdo( list, e, Entity ) - child_count = 1; - child_count += count_supertypes(e); - if (child_count > top_count) - top_count = child_count; + LISTdo(list, e, Entity) + child_count = 1; + child_count += count_supertypes(e); + if(child_count > top_count) { + top_count = child_count; + } LISTod; return top_count; } -int cmp_python_mro( void * e1, void * e2 ) { +int cmp_python_mro(void *e1, void *e2) +{ int e1_chain_len, e2_chain_len; /* TODO: This should do something more intelligent */ - e1_chain_len = count_supertypes( ( Entity ) e1); - e2_chain_len = count_supertypes( ( Entity ) e2); + e1_chain_len = count_supertypes((Entity) e1); + e2_chain_len = count_supertypes((Entity) e2); - if (e1_chain_len == e2_chain_len) { + if(e1_chain_len == e2_chain_len) { return 0; - } else if (e1_chain_len > e2_chain_len) { + } else if(e1_chain_len > e2_chain_len) { return 1; } else { return -1; @@ -554,10 +574,11 @@ int cmp_python_mro( void * e1, void * e2 ) { } void -LIBdescribe_entity( Entity entity, FILE * file ) { +LIBdescribe_entity(Entity entity, FILE *file) +{ int attr_count_tmp = attr_count; char attrnm [BUFSIZ], parent_attrnm[BUFSIZ]; - char * attr_type; + char *attr_type; bool generate_constructor = true; /*by default, generates a python constructor */ bool single_inheritance = false; bool ent_multiple_inheritance = false; @@ -571,34 +592,34 @@ LIBdescribe_entity( Entity entity, FILE * file ) { /* class name need to use new-style classes for properties to work correctly so class must inherit from object */ - if( is_python_keyword( ENTITYget_name( entity ) ) ) { - fprintf( file, "class %s_(", ENTITYget_name( entity ) ); + if(is_python_keyword(ENTITYget_name(entity))) { + fprintf(file, "class %s_(", ENTITYget_name(entity)); } else { - fprintf( file, "class %s(", ENTITYget_name( entity ) ); + fprintf(file, "class %s(", ENTITYget_name(entity)); } /* * Look for inheritance and super classes */ - list = ENTITYget_supertypes( entity ); + list = ENTITYget_supertypes(entity); LISTsort(list, cmp_python_mro); num_parent = 0; - if( ! LISTempty( list ) ) { - LISTdo( list, e, Entity ) + if(! LISTempty(list)) { + LISTdo(list, e, Entity) /* if there\'s no super class yet, or the super class doesn\'t have any attributes */ - if( num_parent > 0 ) { - fprintf( file, "," ); /*separator for parent classes names */ + if(num_parent > 0) { + fprintf(file, ","); /*separator for parent classes names */ } - if( is_python_keyword( ENTITYget_name( e ) ) ) { - fprintf( file, "%s_", ENTITYget_name( e ) ); + if(is_python_keyword(ENTITYget_name(e))) { + fprintf(file, "%s_", ENTITYget_name(e)); } else { - fprintf( file, "%s", ENTITYget_name( e ) ); + fprintf(file, "%s", ENTITYget_name(e)); } num_parent++; LISTod; - if( num_parent == 1 ) { + if(num_parent == 1) { single_inheritance = true; ent_multiple_inheritance = false; } else { @@ -608,261 +629,270 @@ LIBdescribe_entity( Entity entity, FILE * file ) { } else { /*inherit from BaseEntityClass by default, in order to enable decorators */ /* as well as advanced __repr__ feature */ - fprintf( file, "BaseEntityClass" ); + fprintf(file, "BaseEntityClass"); } - fprintf( file, "):\n" ); + fprintf(file, "):\n"); /* * Write docstrings in a Sphinx compliant manner */ - fprintf( file, "\t'''Entity %s definition.\n", ENTITYget_name( entity ) ); - LISTdo( ENTITYget_attributes( entity ), v, Variable ) - generate_attribute_name( v, attrnm ); - t = VARget_type( v ); - fprintf( file, "\n\t:param %s\n", attrnm ); - fprintf( file, "\t:type %s:", attrnm ); - if( TYPEis_aggregate( t ) ) { - process_aggregate( file, t ); - fprintf( file, "\n" ); + fprintf(file, "\t'''Entity %s definition.\n", ENTITYget_name(entity)); + LISTdo(ENTITYget_attributes(entity), v, Variable) + generate_attribute_name(v, attrnm); + t = VARget_type(v); + fprintf(file, "\n\t:param %s\n", attrnm); + fprintf(file, "\t:type %s:", attrnm); + if(TYPEis_aggregate(t)) { + process_aggregate(file, t); + fprintf(file, "\n"); } else { - if( TYPEget_name( t ) == NULL ) { - attr_type = GetAttrTypeName( t ); + if(TYPEget_name(t) == NULL) { + attr_type = GetAttrTypeName(t); } else { - attr_type = TYPEget_name( t ); + attr_type = TYPEget_name(t); } - fprintf( file, "%s\n", attr_type ); + fprintf(file, "%s\n", attr_type); } attr_count_tmp++; LISTod - fprintf( file, "\t'''\n" ); + fprintf(file, "\t'''\n"); /* * Before writing constructor, check if this entity has any attribute * other wise just a 'pass' statement is enough */ attr_count_tmp = 0; num_derived_inverse_attr = 0; - LISTdo( ENTITYget_attributes( entity ), v, Variable ) - if( VARis_derived( v ) || VARget_inverse( v ) ) { + LISTdo(ENTITYget_attributes(entity), v, Variable) + if(VARis_derived(v) || VARget_inverse(v)) { num_derived_inverse_attr++; } else { attr_count_tmp++; } LISTod - if( ( attr_count_tmp == 0 ) && !single_inheritance && !ent_multiple_inheritance ) { - fprintf( file, "\t# This class does not define any attribute.\n" ); - fprintf( file, "\tpass\n" ); + if((attr_count_tmp == 0) && !single_inheritance && !ent_multiple_inheritance) { + fprintf(file, "\t# This class does not define any attribute.\n"); + fprintf(file, "\tpass\n"); generate_constructor = false; } - if( false ) {} + if(false) {} else { /* * write class constructor */ - if( generate_constructor ) { - fprintf( file, "\tdef __init__( self , " ); + if(generate_constructor) { + fprintf(file, "\tdef __init__( self , "); } /* if inheritance, first write the inherited parameters */ - list = ENTITYget_supertypes( entity ); + list = ENTITYget_supertypes(entity); num_parent = 0; index_attribute = 0; - if( ! LISTempty( list ) ) { - LISTdo( list, e, Entity ) { + if(! LISTempty(list)) { + LISTdo(list, e, Entity) { /* search attribute names for superclass */ - LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { - generate_attribute_name( v2, parent_attrnm ); - if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { - fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); + LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { + generate_attribute_name(v2, parent_attrnm); + if(!VARis_derived(v2) && !VARget_inverse(v2)) { + fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); index_attribute++; } - } LISTod + } + LISTod num_parent++; - } LISTod + } + LISTod } - LISTdo( ENTITYget_attributes( entity ), v, Variable ) { - generate_attribute_name( v, attrnm ); - if( !VARis_derived( v ) && !VARget_inverse( v ) ) { - fprintf( file, "%s,", attrnm ); + LISTdo(ENTITYget_attributes(entity), v, Variable) { + generate_attribute_name(v, attrnm); + if(!VARis_derived(v) && !VARget_inverse(v)) { + fprintf(file, "%s,", attrnm); } - } LISTod + } + LISTod /* close constructor method */ - if( generate_constructor ) { - fprintf( file, " ):\n" ); + if(generate_constructor) { + fprintf(file, " ):\n"); } /** if inheritance, first init base class **/ - list = ENTITYget_supertypes( entity ); + list = ENTITYget_supertypes(entity); index_attribute = 0; - if( ! LISTempty( list ) ) { - LISTdo( list, e, Entity ) { - if (is_python_keyword(ENTITYget_name( e ))) { - fprintf( file, "\t\t%s_.__init__(self , ", ENTITYget_name( e ) ); + if(! LISTempty(list)) { + LISTdo(list, e, Entity) { + if(is_python_keyword(ENTITYget_name(e))) { + fprintf(file, "\t\t%s_.__init__(self , ", ENTITYget_name(e)); } else { - fprintf( file, "\t\t%s.__init__(self , ", ENTITYget_name( e ) ); + fprintf(file, "\t\t%s.__init__(self , ", ENTITYget_name(e)); } /* search and write attribute names for superclass */ - LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { - generate_attribute_name( v2, parent_attrnm ); - if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { - fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); + LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { + generate_attribute_name(v2, parent_attrnm); + if(!VARis_derived(v2) && !VARget_inverse(v2)) { + fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); index_attribute++; } - } LISTod + } + LISTod num_parent++; - fprintf( file, ")\n" ); /*separator for parent classes names */ - } LISTod + fprintf(file, ")\n"); /*separator for parent classes names */ + } + LISTod } /* init variables in constructor */ - LISTdo( ENTITYget_attributes( entity ), v, Variable ) - generate_attribute_name( v, attrnm ); - if( !VARis_derived( v ) && !VARget_inverse( v ) ) { - fprintf( file, "\t\tself._%s = %s\n", attrnm, attrnm ); + LISTdo(ENTITYget_attributes(entity), v, Variable) + generate_attribute_name(v, attrnm); + if(!VARis_derived(v) && !VARget_inverse(v)) { + fprintf(file, "\t\tself._%s = %s\n", attrnm, attrnm); } /*attr_count_tmp++; */ LISTod /* * write attributes as python properties */ - LISTdo( ENTITYget_attributes( entity ), v, Variable ) - generate_attribute_name( v, attrnm ); - fprintf( file, "\n\t@property\n" ); - if ( !strcmp(attrnm, "property") ) { - fprintf( file, "\tdef __%s(self):\n", attrnm ); + LISTdo(ENTITYget_attributes(entity), v, Variable) + generate_attribute_name(v, attrnm); + fprintf(file, "\n\t@property\n"); + if(!strcmp(attrnm, "property")) { + fprintf(file, "\tdef __%s(self):\n", attrnm); rename_python_property = true; } else { - fprintf( file, "\tdef %s(self):\n", attrnm ); + fprintf(file, "\tdef %s(self):\n", attrnm); } /* fget */ - if( !VARis_derived( v ) ) { - fprintf( file, "\t\treturn self._%s\n", attrnm ); + if(!VARis_derived(v)) { + fprintf(file, "\t\treturn self._%s\n", attrnm); } else { /* evaluation of attribute */ - fprintf( file, "\t\tattribute_eval = " ); + fprintf(file, "\t\tattribute_eval = "); /* outputs expression initializer */ - ATTRIBUTE_INITIALIZER_out( v->initializer, 1, file ); + ATTRIBUTE_INITIALIZER_out(v->initializer, 1, file); /* then returns the value */ - fprintf( file, "\n\t\treturn attribute_eval\n" ); + fprintf(file, "\n\t\treturn attribute_eval\n"); } /* fset */ - if ( !strcmp(attrnm, "property") ) { - fprintf( file, "\t@__%s.setter\n", attrnm ); - fprintf( file, "\tdef __%s(self, value):\n", attrnm ); + if(!strcmp(attrnm, "property")) { + fprintf(file, "\t@__%s.setter\n", attrnm); + fprintf(file, "\tdef __%s(self, value):\n", attrnm); } else { - fprintf( file, "\t@%s.setter\n", attrnm ); - fprintf( file, "\tdef %s(self, value):\n", attrnm ); + fprintf(file, "\t@%s.setter\n", attrnm); + fprintf(file, "\tdef %s(self, value):\n", attrnm); } - t = VARget_type( v ); + t = VARget_type(v); /* find attr type name */ - if( TYPEget_name( t ) == NULL ) { - attr_type = GetAttrTypeName( t ); + if(TYPEget_name(t) == NULL) { + attr_type = GetAttrTypeName(t); } else { - attr_type = TYPEget_name( t ); + attr_type = TYPEget_name(t); } - if( !VARis_derived( v ) && !VARget_inverse( v ) ) { + if(!VARis_derived(v) && !VARget_inverse(v)) { /* if the argument is not optional */ - if( !VARget_optional( v ) ) { - fprintf( file, "\t\t# Mandatory argument\n" ); - fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); - fprintf( file, "\t\tif not check_type(value," ); - if( TYPEis_aggregate( t ) ) { - process_aggregate( file, t ); - fprintf( file, "):\n" ); - } else if (attr_type && is_python_keyword(attr_type)) { - fprintf( file, "%s_):\n", attr_type ); + if(!VARget_optional(v)) { + fprintf(file, "\t\t# Mandatory argument\n"); + fprintf(file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n"); + fprintf(file, "\t\tif not check_type(value,"); + if(TYPEis_aggregate(t)) { + process_aggregate(file, t); + fprintf(file, "):\n"); + } else if(attr_type && is_python_keyword(attr_type)) { + fprintf(file, "%s_):\n", attr_type); } else { - fprintf( file, "%s):\n", attr_type ); + fprintf(file, "%s):\n", attr_type); } } else { - fprintf( file, "\t\tif value != None: # OPTIONAL attribute\n\t" ); - fprintf( file, "\t\tif not check_type(value," ); - if( TYPEis_aggregate( t ) ) { - process_aggregate( file, t ); - fprintf( file, "):\n\t" ); - } else if (attr_type && is_python_keyword(attr_type)) { - fprintf( file, "%s_):\n\t", attr_type ); + fprintf(file, "\t\tif value != None: # OPTIONAL attribute\n\t"); + fprintf(file, "\t\tif not check_type(value,"); + if(TYPEis_aggregate(t)) { + process_aggregate(file, t); + fprintf(file, "):\n\t"); + } else if(attr_type && is_python_keyword(attr_type)) { + fprintf(file, "%s_):\n\t", attr_type); } else { - fprintf( file, "%s):\n\t", attr_type ); + fprintf(file, "%s):\n\t", attr_type); } } /* check whether attr_type is aggr or explicit */ - if( TYPEis_aggregate( t ) ) { - fprintf( file, "\t\t\tself._%s = ", attrnm ); - print_aggregate_type( file, t ); - fprintf( file, "(value)\n" ); - } else if (attr_type && is_python_keyword(attr_type)) { - fprintf( file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type ); + if(TYPEis_aggregate(t)) { + fprintf(file, "\t\t\tself._%s = ", attrnm); + print_aggregate_type(file, t); + fprintf(file, "(value)\n"); + } else if(attr_type && is_python_keyword(attr_type)) { + fprintf(file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type); } else { - fprintf( file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type ); + fprintf(file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type); } - if( VARget_optional( v ) ) { - fprintf( file, "\t\t\telse:\n" ); - fprintf( file, "\t\t\t\tself._%s = value\n", attrnm ); + if(VARget_optional(v)) { + fprintf(file, "\t\t\telse:\n"); + fprintf(file, "\t\t\t\tself._%s = value\n", attrnm); } - fprintf( file, "\t\telse:\n\t" ); - fprintf( file, "\t\tself._%s = value\n", attrnm ); + fprintf(file, "\t\telse:\n\t"); + fprintf(file, "\t\tself._%s = value\n", attrnm); } /* if the attribute is derived, prevent fset to attribute to be set */ /* TODO: this can be done by NOT writing the setter method */ - else if( VARis_derived( v ) ) { - fprintf( file, "\t# DERIVED argument\n" ); - fprintf( file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm ); - } else if( VARget_inverse( v ) ) { - fprintf( file, "\t# INVERSE argument\n" ); - fprintf( file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm ); + else if(VARis_derived(v)) { + fprintf(file, "\t# DERIVED argument\n"); + fprintf(file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm); + } else if(VARget_inverse(v)) { + fprintf(file, "\t# INVERSE argument\n"); + fprintf(file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm); } LISTod } /* before exiting, process where rules */ - WHEREPrint( entity->where, 0, file ); + WHEREPrint(entity->where, 0, file); - if ( rename_python_property ) { - fprintf( file, "\tproperty = __property\n" ); + if(rename_python_property) { + fprintf(file, "\tproperty = __property\n"); } } int -get_local_attribute_number( Entity entity ) { +get_local_attribute_number(Entity entity) +{ int i = 0; - Linked_List local = ENTITYget_attributes( entity ); - LISTdo( local, a, Variable ) + Linked_List local = ENTITYget_attributes(entity); + LISTdo(local, a, Variable) /* go to the child's first explicit attribute */ - if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + if((! VARget_inverse(a)) && (! VARis_derived(a))) { ++i; } LISTod; return i; } -int get_attribute_number( Entity entity ) { +int get_attribute_number(Entity entity) +{ int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes( entity ); - local = ENTITYget_attributes( entity ); + complete = ENTITYget_all_attributes(entity); + local = ENTITYget_attributes(entity); - LISTdo( local, a, Variable ) { + LISTdo(local, a, Variable) { /* go to the child's first explicit attribute */ - if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { - LISTdo_n( complete, p, Variable, b ) { + if((! VARget_inverse(a)) && (! VARis_derived(a))) { + LISTdo_n(complete, p, Variable, b) { /* cycle through all the explicit attributes until the child's attribute is found */ - if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { - if( p != a ) { + if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { + if(p != a) { ++i; } else { found = 1; } } - } LISTod - if( found ) { + } + LISTod + if(found) { return i; } else { /* In this case, a is a Variable - so macro VARget_name (a) expands * * to an Expression. The first element of an Expression is a Symbol. * * The first element of a Symbol is char * name. */ - fprintf( stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name( a )->symbol.name ); + fprintf(stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name(a)->symbol.name); } } - } LISTod + } + LISTod return -1; } @@ -879,15 +909,17 @@ int get_attribute_number( Entity entity ) { ** Status: ok 1/15/91 ******************************************************************/ void -ENTITYlib_print( Entity entity, FILE * file ) { - LIBdescribe_entity( entity, file ); +ENTITYlib_print(Entity entity, FILE *file) +{ + LIBdescribe_entity(entity, file); } /*FIXME should return bool */ /* return 1 if types are predefined by us */ int -TYPEis_builtin( const Type t ) { - switch( TYPEget_body( t )->type ) { /* dunno if correct*/ +TYPEis_builtin(const Type t) +{ + switch(TYPEget_body(t)->type) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -915,11 +947,12 @@ TYPEis_builtin( const Type t ) { ** Status: started 2012/3/1 ******************************************************************/ void -RULEPrint( Rule rule, FILES * files ) { - char * n = RULEget_name( rule ); - fprintf( files->lib, "\n####################\n # RULE %s #\n####################\n", n ); +RULEPrint(Rule rule, FILES *files) +{ + char *n = RULEget_name(rule); + fprintf(files->lib, "\n####################\n # RULE %s #\n####################\n", n); /* write function definition */ - fprintf( files->lib, "%s = Rule()\n", n ); + fprintf(files->lib, "%s = Rule()\n", n); } @@ -933,216 +966,227 @@ RULEPrint( Rule rule, FILES * files ) { ** Status: started 2012/3/1 ******************************************************************/ void -FUNCPrint( Function function, FILES * files ) { - char * function_name = FUNCget_name( function ); - char * param_name; +FUNCPrint(Function function, FILES *files) +{ + char *function_name = FUNCget_name(function); + char *param_name; Expression expr_name = EXPRESSION_NULL; - fprintf( files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name ); + fprintf(files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name); /* write function definition */ - fprintf( files->lib, "def %s(", function_name ); + fprintf(files->lib, "def %s(", function_name); /* write parameter list */ - LISTdo( FUNCget_parameters( function ), v, Variable ) { - expr_name = VARget_name( v ); - param_name = strdup( EXPget_name( expr_name ) ); - fprintf( files->lib, "%s,", param_name ); - } LISTod - fprintf( files->lib, "):\n" ); + LISTdo(FUNCget_parameters(function), v, Variable) { + expr_name = VARget_name(v); + param_name = strdup(EXPget_name(expr_name)); + fprintf(files->lib, "%s,", param_name); + } + LISTod + fprintf(files->lib, "):\n"); /* print function docstring */ - fprintf( files->lib, "\t'''\n" ); - LISTdo( FUNCget_parameters( function ), v, Variable ) { - expr_name = VARget_name( v ); - param_name = strdup( EXPget_name( expr_name ) ); - fprintf( files->lib, "\t:param %s\n", param_name ); - fprintf( files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName( VARget_type( v ) ) ); - } LISTod - fprintf( files->lib, "\t'''\n" ); + fprintf(files->lib, "\t'''\n"); + LISTdo(FUNCget_parameters(function), v, Variable) { + expr_name = VARget_name(v); + param_name = strdup(EXPget_name(expr_name)); + fprintf(files->lib, "\t:param %s\n", param_name); + fprintf(files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName(VARget_type(v))); + } + LISTod + fprintf(files->lib, "\t'''\n"); /* process statements. The indent_level is set to 1 (the number of tabs \t) */ - STATEMENTSPrint( function->u.proc->body, 1, files->lib ); + STATEMENTSPrint(function->u.proc->body, 1, files->lib); } void -STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ) { - LISTdo( stmts, stmt, Statement ) - STATEMENTPrint( stmt, indent_level, file ); +STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file) +{ + LISTdo(stmts, stmt, Statement) + STATEMENTPrint(stmt, indent_level, file); LISTod } -void python_indent( FILE * file, int indent_level ) { +void python_indent(FILE *file, int indent_level) +{ int i; - for( i = 0; i < indent_level; i++ ) { - fprintf( file, "\t" ); + for(i = 0; i < indent_level; i++) { + fprintf(file, "\t"); } } void -STATEMENTPrint( Statement s, int indent_level, FILE * file ) { +STATEMENTPrint(Statement s, int indent_level, FILE *file) +{ bool first_time = true; - python_indent( file, indent_level ); - if( !s ) { /* null statement */ - fprintf( file, "pass" ); + python_indent(file, indent_level); + if(!s) { /* null statement */ + fprintf(file, "pass"); return; } - switch( s->type ) { + switch(s->type) { case STMT_ASSIGN: - EXPRESSION_out( s->u.assign->lhs, 0, file ); - fprintf( file, " = " ); - EXPRESSION_out( s->u.assign->rhs, 0, file ); - fprintf( file, "\n" ); + EXPRESSION_out(s->u.assign->lhs, 0, file); + fprintf(file, " = "); + EXPRESSION_out(s->u.assign->rhs, 0, file); + fprintf(file, "\n"); break; case STMT_CASE: - CASEout( s->u.Case, indent_level, file ); + CASEout(s->u.Case, indent_level, file); break; case STMT_RETURN: - fprintf( file, "return " ); - if( s->u.ret->value ) { - EXPRESSION_out( s->u.ret->value, 0, file ); + fprintf(file, "return "); + if(s->u.ret->value) { + EXPRESSION_out(s->u.ret->value, 0, file); } - fprintf( file, "\n" ); + fprintf(file, "\n"); break; case STMT_LOOP: - LOOPpyout( s->u.loop, indent_level , file ); + LOOPpyout(s->u.loop, indent_level, file); break; case STMT_ALIAS: - fprintf( file, "%s = %s\n", s->symbol.name, - s->u.alias->variable->name->symbol.name ); - STATEMENTlist_out( s->u.alias->statements, indent_level , file ); + fprintf(file, "%s = %s\n", s->symbol.name, + s->u.alias->variable->name->symbol.name); + STATEMENTlist_out(s->u.alias->statements, indent_level, file); break; case STMT_SKIP: - fprintf( file, "break\n" ); /* @TODO: is that correct? */ + fprintf(file, "break\n"); /* @TODO: is that correct? */ break; case STMT_ESCAPE: - fprintf( file, "break\n" ); + fprintf(file, "break\n"); break; case STMT_COMPOUND: /* following line is necessary other wise indentation */ /* errors in python */ - fprintf( file, "# begin/end block\n" ); - STATEMENTlist_out( s->u.compound->statements, indent_level, file ); + fprintf(file, "# begin/end block\n"); + STATEMENTlist_out(s->u.compound->statements, indent_level, file); break; case STMT_COND: - fprintf( file, "if (" ); - EXPRESSION_out( s->u.cond->test, 0 , file ); - fprintf( file, "):\n" ); - STATEMENTlist_out( s->u.cond->code, indent_level + 1, file ); - if( s->u.cond->otherwise ) { - python_indent( file, indent_level ); - fprintf( file, "else:\n" ); - STATEMENTlist_out( s->u.cond->otherwise, indent_level + 1, file ); + fprintf(file, "if ("); + EXPRESSION_out(s->u.cond->test, 0, file); + fprintf(file, "):\n"); + STATEMENTlist_out(s->u.cond->code, indent_level + 1, file); + if(s->u.cond->otherwise) { + python_indent(file, indent_level); + fprintf(file, "else:\n"); + STATEMENTlist_out(s->u.cond->otherwise, indent_level + 1, file); } break; case STMT_PCALL: - fprintf( file, "%s(", s->symbol.name ); - LISTdo( s->u.proc->parameters, p, Expression ) - if( first_time ) { + fprintf(file, "%s(", s->symbol.name); + LISTdo(s->u.proc->parameters, p, Expression) + if(first_time) { first_time = false; } else { - fprintf( file, "," ); + fprintf(file, ","); } - EXPRESSION_out( p, 0, file ); + EXPRESSION_out(p, 0, file); LISTod - fprintf( file, ")\n" ); + fprintf(file, ")\n"); } } void -CASEout( struct Case_Statement_ *c, int level, FILE * file ) { +CASEout(struct Case_Statement_ *c, int level, FILE *file) +{ int if_number = 0; - fprintf( file, "case_selector = " ); - EXPRESSION_out( c->selector, 0, file ); - fprintf( file, "\n" ); + fprintf(file, "case_selector = "); + EXPRESSION_out(c->selector, 0, file); + fprintf(file, "\n"); /* pass 2: print them */ - LISTdo( c->cases, ci, Case_Item ) { - if( ci->labels ) { - LISTdo_n( ci->labels, label, Expression, b ) { + LISTdo(c->cases, ci, Case_Item) { + if(ci->labels) { + LISTdo_n(ci->labels, label, Expression, b) { /* print label(s) */ - python_indent( file, level ); - if( if_number == 0 ) { - fprintf( file, "if " ); + python_indent(file, level); + if(if_number == 0) { + fprintf(file, "if "); } else { - fprintf( file, "elif" ); + fprintf(file, "elif"); } - fprintf( file, " case_selector == " ); - EXPRESSION_out( label, 0, file ); - fprintf( file, ":\n" ); + fprintf(file, " case_selector == "); + EXPRESSION_out(label, 0, file); + fprintf(file, ":\n"); /* print action */ - STATEMENTPrint( ci->action, level + 1, file ); + STATEMENTPrint(ci->action, level + 1, file); if_number++; - } LISTod + } + LISTod } else { /* print OTHERWISE */ - python_indent( file, level ); - fprintf( file, "else:\n" ); + python_indent(file, level); + fprintf(file, "else:\n"); /* print action */ - STATEMENTPrint( ci->action, level + 1, file ); + STATEMENTPrint(ci->action, level + 1, file); } - } LISTod + } + LISTod } void -LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { +LOOPpyout(struct Loop_ *loop, int level, FILE *file) +{ Variable v; - - if (loop->scope) { + + if(loop->scope) { DictionaryEntry de; /* TODO: if incr != 0 && ((incr > 0 && start < stop) || (incr < 0 && start > stop)): */ - DICTdo_init( loop->scope->symbol_table, &de ); - v = ( Variable )DICTdo( &de ); - fprintf( file, "for %s in range(", v->name->symbol.name ); - EXPRESSION_out( loop->scope->u.incr->init, 0 , file ); - fprintf( file, "," ); - EXPRESSION_out( loop->scope->u.incr->end, 0 , file ); - fprintf( file, "," ); /* parser always forces a "by" expr */ - EXPRESSION_out( loop->scope->u.incr->increment, 0 , file ); - fprintf( file, "):\n" ); - - if( loop->while_expr ) { - fprintf( file, "if " ); - EXPRESSION_out( loop->while_expr, 0 , file ); - fprintf( file, ":\n"); - STATEMENTlist_out( loop->statements, level + 2 , file ); + DICTdo_init(loop->scope->symbol_table, &de); + v = (Variable)DICTdo(&de); + fprintf(file, "for %s in range(", v->name->symbol.name); + EXPRESSION_out(loop->scope->u.incr->init, 0, file); + fprintf(file, ","); + EXPRESSION_out(loop->scope->u.incr->end, 0, file); + fprintf(file, ","); /* parser always forces a "by" expr */ + EXPRESSION_out(loop->scope->u.incr->increment, 0, file); + fprintf(file, "):\n"); + + if(loop->while_expr) { + fprintf(file, "if "); + EXPRESSION_out(loop->while_expr, 0, file); + fprintf(file, ":\n"); + STATEMENTlist_out(loop->statements, level + 2, file); } else { - STATEMENTlist_out( loop->statements, level + 1 , file ); + STATEMENTlist_out(loop->statements, level + 1, file); } - if( loop->until_expr ) { - fprintf( file, "if " ); - EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + if(loop->until_expr) { + fprintf(file, "if "); + EXPRESSION_out(loop->until_expr, 0, file); + fprintf(file, ":\n\tbreak\n"); } - } else if( loop->while_expr ) { - fprintf( file, "while " ); - EXPRESSION_out( loop->while_expr, 0 , file ); - fprintf( file, ":\n"); - STATEMENTlist_out( loop->statements, level + 1 , file ); - - if( loop->until_expr ) { - fprintf( file, "if " ); - EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + } else if(loop->while_expr) { + fprintf(file, "while "); + EXPRESSION_out(loop->while_expr, 0, file); + fprintf(file, ":\n"); + STATEMENTlist_out(loop->statements, level + 1, file); + + if(loop->until_expr) { + fprintf(file, "if "); + EXPRESSION_out(loop->until_expr, 0, file); + fprintf(file, ":\n\tbreak\n"); } } else { - fprintf( file, "while True:\n" ); - STATEMENTlist_out( loop->statements, level + 1 , file ); + fprintf(file, "while True:\n"); + STATEMENTlist_out(loop->statements, level + 1, file); - fprintf( file, "if " ); - EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + fprintf(file, "if "); + EXPRESSION_out(loop->until_expr, 0, file); + fprintf(file, ":\n\tbreak\n"); } } void -STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ) { - LISTdo( stmts, stmt, Statement ) - STATEMENTPrint( stmt, indent_level, file ); +STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file) +{ + LISTdo(stmts, stmt, Statement) + STATEMENTPrint(stmt, indent_level, file); LISTod } /***************************************************************** @@ -1152,112 +1196,113 @@ STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ) { ** ******************************************************************/ void -ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ) { +ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file) +{ int i; /* trusty temporary */ - switch( TYPEis( e->type ) ) { + switch(TYPEis(e->type)) { case integer_: - if( e == LITERAL_INFINITY ) { - fprintf( file, " None " ); + if(e == LITERAL_INFINITY) { + fprintf(file, " None "); } else { - fprintf( file, "%d", e->u.integer ); + fprintf(file, "%d", e->u.integer); } break; case real_: - if( e == LITERAL_PI ) { - fprintf( file, " PI " ); - } else if( e == LITERAL_E ) { - fprintf( file, " E " );; + if(e == LITERAL_PI) { + fprintf(file, " PI "); + } else if(e == LITERAL_E) { + fprintf(file, " E ");; } else { - fprintf( file, "%g", e->u.real ); + fprintf(file, "%g", e->u.real); } break; case binary_: - fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ + fprintf(file, "%%%s", e->u.binary); /* put "%" back */ break; case logical_: case boolean_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - fprintf( file, "TRUE" ); + fprintf(file, "TRUE"); break; case Lfalse: - fprintf( file, "FALSE" ); + fprintf(file, "FALSE"); break; default: - fprintf( file, "UNKNOWN" ); + fprintf(file, "UNKNOWN"); break; } break; case string_: - if( TYPEis_encoded( e->type ) ) { - fprintf( file, "\"%s\"", e->symbol.name ); + if(TYPEis_encoded(e->type)) { + fprintf(file, "\"%s\"", e->symbol.name); } else { - char* tmp = strliteral_py_dup(e->symbol.name); - fprintf( file, "'%s'", tmp ); + char *tmp = strliteral_py_dup(e->symbol.name); + fprintf(file, "'%s'", tmp); free(tmp); } break; case entity_: case identifier_: - fprintf( file, "self.%s", e->symbol.name ); + fprintf(file, "self.%s", e->symbol.name); break; case attribute_: - fprintf( file, "%s", e->symbol.name ); + fprintf(file, "%s", e->symbol.name); break; case enumeration_: - fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); + fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); break; case query_: /* so far we don't handle queries */ - fprintf( file, "None" ); + fprintf(file, "None"); break; case self_: - fprintf( file, "self" ); + fprintf(file, "self"); break; case funcall_: - fprintf( file, "%s(", e->symbol.name ); + fprintf(file, "%s(", e->symbol.name); i = 0; - LISTdo( e->u.funcall.list, arg, Expression ) + LISTdo(e->u.funcall.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); + ATTRIBUTE_INITIALIZER_out(arg, 0, file); LISTod - fprintf( file, ")" ); + fprintf(file, ")"); break; case op_: - ATTRIBUTE_INITIALIZERop__out( &e->e, paren, previous_op, file ); + ATTRIBUTE_INITIALIZERop__out(&e->e, paren, previous_op, file); break; case aggregate_: - fprintf( file, "[" ); + fprintf(file, "["); i = 0; - LISTdo( e->u.list, arg, Expression ) + LISTdo(e->u.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); + ATTRIBUTE_INITIALIZER_out(arg, 0, file); LISTod - fprintf( file, "]" ); + fprintf(file, "]"); break; case oneof_: - fprintf( file, "ONEOF (" ); + fprintf(file, "ONEOF ("); i = 0; - LISTdo( e->u.list, arg, Expression ) + LISTdo(e->u.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - ATTRIBUTE_INITIALIZER_out( arg, 0, file ); + ATTRIBUTE_INITIALIZER_out(arg, 0, file); LISTod - fprintf( file, ")" ); + fprintf(file, ")"); break; default: - fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); + fprintf(file, "unknown expression, type %d", TYPEis(e->type)); } } @@ -1267,409 +1312,417 @@ ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * fi ** include, and initialization files for a specific entity class ******************************************************************/ void -EXPRESSION__out( Expression e, int paren, Op_Code previous_op, FILE* file ) { +EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file) +{ int i; /* trusty temporary */ - switch( TYPEis( e->type ) ) { + switch(TYPEis(e->type)) { case integer_: - if( e == LITERAL_INFINITY ) { - fprintf( file, " None " ); + if(e == LITERAL_INFINITY) { + fprintf(file, " None "); } else { - fprintf( file, "%d", e->u.integer ); + fprintf(file, "%d", e->u.integer); } break; case real_: - if( e == LITERAL_PI ) { - fprintf( file, " PI " ); - } else if( e == LITERAL_E ) { - fprintf( file, " E " );; + if(e == LITERAL_PI) { + fprintf(file, " PI "); + } else if(e == LITERAL_E) { + fprintf(file, " E ");; } else { - fprintf( file, "%g", e->u.real ); + fprintf(file, "%g", e->u.real); } break; case binary_: - fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ + fprintf(file, "%%%s", e->u.binary); /* put "%" back */ break; case logical_: case boolean_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - fprintf( file, "TRUE" ); + fprintf(file, "TRUE"); break; case Lfalse: - fprintf( file, "FALSE" ); + fprintf(file, "FALSE"); break; default: - fprintf( file, "UNKNOWN" ); + fprintf(file, "UNKNOWN"); break; } break; case string_: - if( TYPEis_encoded( e->type ) ) { - fprintf( file, "\"%s\"", e->symbol.name ); + if(TYPEis_encoded(e->type)) { + fprintf(file, "\"%s\"", e->symbol.name); } else { - char* tmp = strliteral_py_dup(e->symbol.name); - fprintf( file, "'%s'", tmp ); + char *tmp = strliteral_py_dup(e->symbol.name); + fprintf(file, "'%s'", tmp); free(tmp); } break; case entity_: case identifier_: - if( is_python_keyword( e->symbol.name ) ) { - fprintf( file, "%s_", e->symbol.name ); + if(is_python_keyword(e->symbol.name)) { + fprintf(file, "%s_", e->symbol.name); } else { - fprintf( file, "%s", e->symbol.name ); + fprintf(file, "%s", e->symbol.name); } break; case attribute_: - fprintf( file, "%s", e->symbol.name ); + fprintf(file, "%s", e->symbol.name); break; case enumeration_: - fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); + fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); break; case query_: /* so far we don't handle queries */ - fprintf( file, "None" ); + fprintf(file, "None"); break; case self_: - fprintf( file, "self" ); + fprintf(file, "self"); break; case funcall_: - fprintf( file, "%s(", e->symbol.name ); + fprintf(file, "%s(", e->symbol.name); i = 0; - LISTdo( e->u.funcall.list, arg, Expression ) + LISTdo(e->u.funcall.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - EXPRESSION_out( arg, 0 , file ); + EXPRESSION_out(arg, 0, file); LISTod - fprintf( file, ")" ); + fprintf(file, ")"); break; case op_: - EXPRESSIONop__out( &e->e, paren, previous_op, file ); + EXPRESSIONop__out(&e->e, paren, previous_op, file); break; case aggregate_: - fprintf( file, "[" ); + fprintf(file, "["); i = 0; - LISTdo( e->u.list, arg, Expression ) + LISTdo(e->u.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - EXPRESSION_out( arg, 0 , file ); + EXPRESSION_out(arg, 0, file); LISTod - fprintf( file, "]" ); + fprintf(file, "]"); break; case oneof_: - fprintf( file, "ONEOF (" ); + fprintf(file, "ONEOF ("); i = 0; - LISTdo( e->u.list, arg, Expression ) + LISTdo(e->u.list, arg, Expression) i++; - if( i != 1 ) { - fprintf( file, "," ); + if(i != 1) { + fprintf(file, ","); } - EXPRESSION_out( arg, 0, file ); + EXPRESSION_out(arg, 0, file); LISTod - fprintf( file, ")" ); + fprintf(file, ")"); break; default: - fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); + fprintf(file, "unknown expression, type %d", TYPEis(e->type)); } } void -ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { +ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) +{ /* TODO: refactor, eliminate Op_Subexpression for enumerations */ - Type op1_type = EXPget_type( oe->op1 ); - if ( TYPEis_enumeration( op1_type ) ) { - fprintf( file, "%s.%s", TYPEget_name( op1_type ), EXPget_name( oe->op2 ) ); + Type op1_type = EXPget_type(oe->op1); + if(TYPEis_enumeration(op1_type)) { + fprintf(file, "%s.%s", TYPEget_name(op1_type), EXPget_name(oe->op2)); return; } - switch( oe->op_code ) { + switch(oe->op_code) { case OP_AND: - ATTRIBUTE_INITIALIZERop2_out( oe, " and ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " and ", paren, PAD, file); break; case OP_ANDOR: case OP_OR: - ATTRIBUTE_INITIALIZERop2_out( oe, " or ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " or ", paren, PAD, file); break; case OP_CONCAT: case OP_EQUAL: - ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); break; case OP_PLUS: - ATTRIBUTE_INITIALIZERop2_out( oe, " + ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " + ", paren, PAD, file); break; case OP_TIMES: - ATTRIBUTE_INITIALIZERop2_out( oe, " * ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " * ", paren, PAD, file); break; case OP_XOR: - ATTRIBUTE_INITIALIZERop2__out( oe, " != ", paren, PAD, previous_op, file ); + ATTRIBUTE_INITIALIZERop2__out(oe, " != ", paren, PAD, previous_op, file); break; case OP_EXP: - ATTRIBUTE_INITIALIZERop2_out( oe, " ** ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " ** ", paren, PAD, file); break; case OP_GREATER_EQUAL: - ATTRIBUTE_INITIALIZERop2_out( oe, " >= ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " >= ", paren, PAD, file); break; case OP_GREATER_THAN: - ATTRIBUTE_INITIALIZERop2_out( oe, " > ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " > ", paren, PAD, file); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); break; case OP_INST_NOT_EQUAL: - ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); break; case OP_LESS_EQUAL: - ATTRIBUTE_INITIALIZERop2_out( oe, " <= ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " <= ", paren, PAD, file); break; case OP_LESS_THAN: - ATTRIBUTE_INITIALIZERop2_out( oe, " < ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " < ", paren, PAD, file); break; case OP_LIKE: case OP_MOD: - ATTRIBUTE_INITIALIZERop2_out( oe, " % ", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " % ", paren, PAD, file); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD , file ); + ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); break; case OP_NOT: - ATTRIBUTE_INITIALIZERop1_out( oe, " not ", paren, file ); + ATTRIBUTE_INITIALIZERop1_out(oe, " not ", paren, file); break; case OP_REAL_DIV: case OP_DIV: - ATTRIBUTE_INITIALIZERop2_out( oe, "/", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, "/", paren, PAD, file); break; case OP_MINUS: - ATTRIBUTE_INITIALIZERop2_out( oe, "-", paren, PAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, "-", paren, PAD, file); break; case OP_DOT: - ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); break; case OP_GROUP: - ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); + ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); break; case OP_NEGATE: - ATTRIBUTE_INITIALIZERop1_out( oe, "-", paren, file ); + ATTRIBUTE_INITIALIZERop1_out(oe, "-", paren, file); break; case OP_ARRAY_ELEMENT: - ATTRIBUTE_INITIALIZER_out( oe->op1, 1, file ); - fprintf( file, "[" ); - ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); - fprintf( file, "]" ); + ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); + fprintf(file, "["); + ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); + fprintf(file, "]"); break; case OP_SUBCOMPONENT: - ATTRIBUTE_INITIALIZER_out( oe->op1, 1 , file ); - fprintf( file, "[" ); - ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); - fprintf( file, ":" ); - ATTRIBUTE_INITIALIZER_out( oe->op3, 0, file ); - fprintf( file, "]" ); + ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); + fprintf(file, "["); + ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); + fprintf(file, ":"); + ATTRIBUTE_INITIALIZER_out(oe->op3, 0, file); + fprintf(file, "]"); break; default: - fprintf( file, "(* unknown op-expression *)" ); + fprintf(file, "(* unknown op-expression *)"); } } /* print expression that has op and operands */ void -EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { - switch( oe->op_code ) { +EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) +{ + switch(oe->op_code) { case OP_AND: - EXPRESSIONop2_out( oe, " and ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " and ", paren, PAD, file); break; case OP_ANDOR: case OP_OR: - EXPRESSIONop2_out( oe, " or ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " or ", paren, PAD, file); break; case OP_CONCAT: case OP_EQUAL: - EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " == ", paren, PAD, file); break; case OP_PLUS: - EXPRESSIONop2_out( oe, " + ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " + ", paren, PAD, file); break; case OP_TIMES: - EXPRESSIONop2_out( oe, " * ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " * ", paren, PAD, file); break; case OP_XOR: - EXPRESSIONop2__out( oe, " != ", paren, PAD, previous_op, file ); + EXPRESSIONop2__out(oe, " != ", paren, PAD, previous_op, file); break; case OP_EXP: - EXPRESSIONop2_out( oe, " ** ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " ** ", paren, PAD, file); break; case OP_GREATER_EQUAL: - EXPRESSIONop2_out( oe, " >= ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " >= ", paren, PAD, file); break; case OP_GREATER_THAN: - EXPRESSIONop2_out( oe, " > ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " > ", paren, PAD, file); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " == ", paren, PAD, file); break; case OP_INST_NOT_EQUAL: - EXPRESSIONop2_out( oe, " != ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " != ", paren, PAD, file); break; case OP_LESS_EQUAL: - EXPRESSIONop2_out( oe, " <= ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " <= ", paren, PAD, file); break; case OP_LESS_THAN: - EXPRESSIONop2_out( oe, " < ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " < ", paren, PAD, file); break; case OP_LIKE: case OP_MOD: - EXPRESSIONop2_out( oe, " % ", paren, PAD, file ); + EXPRESSIONop2_out(oe, " % ", paren, PAD, file); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - EXPRESSIONop2_out( oe, " != ", paren, PAD , file ); + EXPRESSIONop2_out(oe, " != ", paren, PAD, file); break; case OP_NOT: - EXPRESSIONop1_out( oe, " not ", paren, file ); + EXPRESSIONop1_out(oe, " not ", paren, file); break; case OP_REAL_DIV: case OP_DIV: - EXPRESSIONop2_out( oe, "/", paren, PAD, file ); + EXPRESSIONop2_out(oe, "/", paren, PAD, file); break; case OP_MINUS: - EXPRESSIONop2_out( oe, "-", paren, PAD, file ); + EXPRESSIONop2_out(oe, "-", paren, PAD, file); break; case OP_DOT: - EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); + EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); break; case OP_GROUP: - EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); + EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); break; case OP_NEGATE: - EXPRESSIONop1_out( oe, "-", paren, file ); + EXPRESSIONop1_out(oe, "-", paren, file); break; case OP_ARRAY_ELEMENT: - EXPRESSION_out( oe->op1, 1, file ); - fprintf( file, "[" ); - EXPRESSION_out( oe->op2, 0, file ); - fprintf( file, "]" ); + EXPRESSION_out(oe->op1, 1, file); + fprintf(file, "["); + EXPRESSION_out(oe->op2, 0, file); + fprintf(file, "]"); break; case OP_SUBCOMPONENT: - EXPRESSION_out( oe->op1, 1 , file ); - fprintf( file, "[" ); - EXPRESSION_out( oe->op2, 0, file ); - fprintf( file, ":" ); - EXPRESSION_out( oe->op3, 0, file ); - fprintf( file, "]" ); + EXPRESSION_out(oe->op1, 1, file); + fprintf(file, "["); + EXPRESSION_out(oe->op2, 0, file); + fprintf(file, ":"); + EXPRESSION_out(oe->op3, 0, file); + fprintf(file, "]"); break; default: - fprintf( file, "(* unknown op-expression *)" ); + fprintf(file, "(* unknown op-expression *)"); } } void -EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { - if( pad && paren && ( eo->op_code != previous_op ) ) { - fprintf( file, "(" ); +EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) +{ + if(pad && paren && (eo->op_code != previous_op)) { + fprintf(file, "("); } - EXPRESSION__out( eo->op1, 1, eo->op_code , file ); - if( pad ) { - fprintf( file, " " ); + EXPRESSION__out(eo->op1, 1, eo->op_code, file); + if(pad) { + fprintf(file, " "); } - fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); - if( pad ) { - fprintf( file, " " ); + fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); + if(pad) { + fprintf(file, " "); } - EXPRESSION__out( eo->op2, 1, eo->op_code, file ); - if( pad && paren && ( eo->op_code != previous_op ) ) { - fprintf( file, ")" ); + EXPRESSION__out(eo->op2, 1, eo->op_code, file); + if(pad && paren && (eo->op_code != previous_op)) { + fprintf(file, ")"); } } void -ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { - if( pad && paren && ( eo->op_code != previous_op ) ) { - fprintf( file, "(" ); +ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) +{ + if(pad && paren && (eo->op_code != previous_op)) { + fprintf(file, "("); } - ATTRIBUTE_INITIALIZER__out( eo->op1, 1, eo->op_code , file ); - if( pad ) { - fprintf( file, " " ); + ATTRIBUTE_INITIALIZER__out(eo->op1, 1, eo->op_code, file); + if(pad) { + fprintf(file, " "); } - fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); - if( pad ) { - fprintf( file, " " ); + fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); + if(pad) { + fprintf(file, " "); } - ATTRIBUTE_INITIALIZER__out( eo->op2, 1, eo->op_code, file ); - if( pad && paren && ( eo->op_code != previous_op ) ) { - fprintf( file, ")" ); + ATTRIBUTE_INITIALIZER__out(eo->op2, 1, eo->op_code, file); + if(pad && paren && (eo->op_code != previous_op)) { + fprintf(file, ")"); } } /* Print out a one-operand operation. If there were more than two of these */ /* I'd generalize it to do padding, but it's not worth it. */ void -EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { - if( paren ) { - fprintf( file, "(" ); +EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) +{ + if(paren) { + fprintf(file, "("); } - fprintf( file, "%s", opcode ); - EXPRESSION_out( eo->op1, 1, file ); - if( paren ) { - fprintf( file, ")" ); + fprintf(file, "%s", opcode); + EXPRESSION_out(eo->op1, 1, file); + if(paren) { + fprintf(file, ")"); } } void -ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { - if( paren ) { - fprintf( file, "(" ); +ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) +{ + if(paren) { + fprintf(file, "("); } - fprintf( file, "%s", opcode ); - ATTRIBUTE_INITIALIZER_out( eo->op1, 1, file ); - if( paren ) { - fprintf( file, ")" ); + fprintf(file, "%s", opcode); + ATTRIBUTE_INITIALIZER_out(eo->op1, 1, file); + if(paren) { + fprintf(file, ")"); } } void -WHEREPrint( Linked_List wheres, int level , FILE * file ) { +WHEREPrint(Linked_List wheres, int level, FILE *file) +{ int where_rule_number = 0; - python_indent( file, level ); + python_indent(file, level); - if( !wheres ) { + if(!wheres) { return; } /* pass 2: now print labels and exprs */ - LISTdo( wheres, w, Where ) - if( strcmp( w->label->name, "" ) ) { + LISTdo(wheres, w, Where) + if(strcmp(w->label->name, "")) { /* define a function with the name 'label' */ - fprintf( file, "\tdef %s(self):\n", w->label->name ); - fprintf( file, "\t\teval_%s_wr = ", w->label->name ); + fprintf(file, "\tdef %s(self):\n", w->label->name); + fprintf(file, "\t\teval_%s_wr = ", w->label->name); } else { /* no label */ - fprintf( file, "\tdef unnamed_wr_%i(self):\n", where_rule_number ); - fprintf( file, "\t\teval_unnamed_wr_%i = ", where_rule_number ); + fprintf(file, "\tdef unnamed_wr_%i(self):\n", where_rule_number); + fprintf(file, "\t\teval_unnamed_wr_%i = ", where_rule_number); } /*EXPRESSION_out( w->expr, level+1 , file ); */ - ATTRIBUTE_INITIALIZER_out( w->expr, level + 1 , file ); + ATTRIBUTE_INITIALIZER_out(w->expr, level + 1, file); /* raise exception if rule violated */ - if( strcmp( w->label->name, "" ) ) { - fprintf( file, "\n\t\tif not eval_%s_wr:\n", w->label->name ); - fprintf( file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name ); - fprintf( file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name ); + if(strcmp(w->label->name, "")) { + fprintf(file, "\n\t\tif not eval_%s_wr:\n", w->label->name); + fprintf(file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name); + fprintf(file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name); } else { /* no label */ - fprintf( file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number ); - fprintf( file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number ); - fprintf( file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number ); + fprintf(file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number); + fprintf(file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number); + fprintf(file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number); where_rule_number++; } LISTod @@ -1688,12 +1741,13 @@ WHEREPrint( Linked_List wheres, int level , FILE * file ) { ******************************************************************/ void -ENTITYPrint( Entity entity, FILES * files ) { - char * n = ENTITYget_name( entity ); - DEBUG( "Entering ENTITYPrint for %s\n", n ); - fprintf( files->lib, "\n####################\n # ENTITY %s #\n####################\n", n ); - ENTITYlib_print( entity, files -> lib ); - DEBUG( "DONE ENTITYPrint\n" ) ; +ENTITYPrint(Entity entity, FILES *files) +{ + char *n = ENTITYget_name(entity); + DEBUG("Entering ENTITYPrint for %s\n", n); + fprintf(files->lib, "\n####################\n # ENTITY %s #\n####################\n", n); + ENTITYlib_print(entity, files -> lib); + DEBUG("DONE ENTITYPrint\n") ; } @@ -1705,200 +1759,206 @@ ENTITYPrint( Entity entity, FILES * files ) { * FIXME implement or remove */ const char * -EnumCElementName( Type type, Expression expr ) { +EnumCElementName(Type type, Expression expr) +{ (void) type; (void) expr; return NULL; } void -TYPEenum_lib_print( const Type type, FILE * f ) { +TYPEenum_lib_print(const Type type, FILE *f) +{ DictionaryEntry de; Expression expr; /* begin the new enum type */ - if( is_python_keyword( TYPEget_name( type ) ) ) { - fprintf( f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name( type ) ); + if(is_python_keyword(TYPEget_name(type))) { + fprintf(f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name(type)); } else { - fprintf( f, "\n# ENUMERATION TYPE %s\n", TYPEget_name( type ) ); + fprintf(f, "\n# ENUMERATION TYPE %s\n", TYPEget_name(type)); } /* then outputs the enum */ - if( is_python_keyword( TYPEget_name( type ) ) ) { - fprintf( f, "%s_ = ENUMERATION('%s_','", TYPEget_name( type ), TYPEget_name( type ) ); + if(is_python_keyword(TYPEget_name(type))) { + fprintf(f, "%s_ = ENUMERATION('%s_','", TYPEget_name(type), TYPEget_name(type)); } else { - fprintf( f, "%s = ENUMERATION('%s','", TYPEget_name( type ), TYPEget_name( type ) ); + fprintf(f, "%s = ENUMERATION('%s','", TYPEget_name(type), TYPEget_name(type)); } /* set up the dictionary info */ - DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); - while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { - if( is_python_keyword( EXPget_name( expr ) ) ) { - fprintf( f, "%s_ ", EXPget_name( expr ) ); + DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); + while(0 != (expr = (Expression)DICTdo(&de))) { + if(is_python_keyword(EXPget_name(expr))) { + fprintf(f, "%s_ ", EXPget_name(expr)); } else { - fprintf( f, "%s ", EXPget_name( expr ) ); + fprintf(f, "%s ", EXPget_name(expr)); } } - fprintf( f, "')\n" ); + fprintf(f, "')\n"); } -void strcat_expr( Expression e, char * buf ) { - if( e == LITERAL_INFINITY ) { - strcat( buf, "?" ); - } else if( e == LITERAL_PI ) { - strcat( buf, "PI" ); - } else if( e == LITERAL_E ) { - strcat( buf, "E" ); - } else if( e == LITERAL_ZERO ) { - strcat( buf, "0" ); - } else if( e == LITERAL_ONE ) { - strcat( buf, "1" ); - } else if( TYPEget_name( e ) ) { - strcat( buf, TYPEget_name( e ) ); - } else if( TYPEget_body( e->type )->type == integer_ ) { +void strcat_expr(Expression e, char *buf) +{ + if(e == LITERAL_INFINITY) { + strcat(buf, "?"); + } else if(e == LITERAL_PI) { + strcat(buf, "PI"); + } else if(e == LITERAL_E) { + strcat(buf, "E"); + } else if(e == LITERAL_ZERO) { + strcat(buf, "0"); + } else if(e == LITERAL_ONE) { + strcat(buf, "1"); + } else if(TYPEget_name(e)) { + strcat(buf, TYPEget_name(e)); + } else if(TYPEget_body(e->type)->type == integer_) { char tmpbuf[30]; - sprintf( tmpbuf, "%d", e->u.integer ); - strcat( buf, tmpbuf ); + sprintf(tmpbuf, "%d", e->u.integer); + strcat(buf, tmpbuf); } else { - strcat( buf, "??" ); + strcat(buf, "??"); } } /* print t's bounds to end of buf */ void -strcat_bounds( TypeBody b, char * buf ) { - if( !b->upper ) { +strcat_bounds(TypeBody b, char *buf) +{ + if(!b->upper) { return; } - strcat( buf, " [" ); - strcat_expr( b->lower, buf ); - strcat( buf, ":" ); - strcat_expr( b->upper, buf ); - strcat( buf, "]" ); + strcat(buf, " ["); + strcat_expr(b->lower, buf); + strcat(buf, ":"); + strcat_expr(b->upper, buf); + strcat(buf, "]"); } void -TypeBody_Description( TypeBody body, char * buf ) { - char * s; +TypeBody_Description(TypeBody body, char *buf) +{ + char *s; - switch( body->type ) { + switch(body->type) { case integer_: - strcat( buf, " INTEGER" ); + strcat(buf, " INTEGER"); break; case real_: - strcat( buf, " REAL" ); + strcat(buf, " REAL"); break; case string_: - strcat( buf, " STRING" ); + strcat(buf, " STRING"); break; case binary_: - strcat( buf, " BINARY" ); + strcat(buf, " BINARY"); break; case boolean_: - strcat( buf, " BOOLEAN" ); + strcat(buf, " BOOLEAN"); break; case logical_: - strcat( buf, " LOGICAL" ); + strcat(buf, " LOGICAL"); break; case number_: - strcat( buf, " NUMBER" ); + strcat(buf, " NUMBER"); break; case entity_: - strcat( buf, " " ); - strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); + strcat(buf, " "); + strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch( body->type ) { - /* ignore the aggregate bounds for now */ + switch(body->type) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat( buf, " AGGREGATE OF" ); + strcat(buf, " AGGREGATE OF"); break; case array_: - strcat( buf, " ARRAY" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); - if( body->flags.optional ) { - strcat( buf, " OPTIONAL" ); + strcat(buf, " ARRAY"); + strcat_bounds(body, buf); + strcat(buf, " OF"); + if(body->flags.optional) { + strcat(buf, " OPTIONAL"); } - if( body->flags.unique ) { - strcat( buf, " UNIQUE" ); + if(body->flags.unique) { + strcat(buf, " UNIQUE"); } break; case bag_: - strcat( buf, " BAG" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); + strcat(buf, " BAG"); + strcat_bounds(body, buf); + strcat(buf, " OF"); break; case set_: - strcat( buf, " SET" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); + strcat(buf, " SET"); + strcat_bounds(body, buf); + strcat(buf, " OF"); break; case list_: - strcat( buf, " LIST" ); - strcat_bounds( body, buf ); - strcat( buf, " OF" ); - if( body->flags.unique ) { - strcat( buf, " UNIQUE" ); + strcat(buf, " LIST"); + strcat_bounds(body, buf); + strcat(buf, " OF"); + if(body->flags.unique) { + strcat(buf, " UNIQUE"); } break; default: - fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type ); + fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type); abort(); } - Type_Description( body->base, buf ); + Type_Description(body->base, buf); break; case enumeration_: - strcat( buf, " ENUMERATION of (" ); - LISTdo( body->list, e, Expression ) - strcat( buf, ENUMget_name( e ) ); - strcat( buf, ", " ); + strcat(buf, " ENUMERATION of ("); + LISTdo(body->list, e, Expression) + strcat(buf, ENUMget_name(e)); + strcat(buf, ", "); LISTod /* find last comma and replace with ')' */ - s = strrchr( buf, ',' ); - if( s ) { - strcpy( s, ")" ); + s = strrchr(buf, ','); + if(s) { + strcpy(s, ")"); } break; case select_: - strcat( buf, " SELECT (" ); - LISTdo( body->list, t, Type ) - strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); - strcat( buf, ", " ); + strcat(buf, " SELECT ("); + LISTdo(body->list, t, Type) + strcat(buf, PrettyTmpName(TYPEget_name(t))); + strcat(buf, ", "); LISTod /* find last comma and replace with ')' */ - s = strrchr( buf, ',' ); - if( s ) { - strcpy( s, ")" ); + s = strrchr(buf, ','); + if(s) { + strcpy(s, ")"); } break; default: - strcat( buf, " UNKNOWN" ); + strcat(buf, " UNKNOWN"); } - if( body->precision ) { - strcat( buf, " (" ); - strcat_expr( body->precision, buf ); - strcat( buf, ")" ); + if(body->precision) { + strcat(buf, " ("); + strcat_expr(body->precision, buf); + strcat(buf, ")"); } - if( body->flags.fixed ) { - strcat( buf, " FIXED" ); + if(body->flags.fixed) { + strcat(buf, " FIXED"); } } void -Type_Description( const Type t, char * buf ) { - if( TYPEget_name( t ) ) { - strcat( buf, " " ); - strcat( buf, TYPEget_name( t ) ); +Type_Description(const Type t, char *buf) +{ + if(TYPEget_name(t)) { + strcat(buf, " "); + strcat(buf, TYPEget_name(t)); /* strcat(buf,PrettyTmpName (TYPEget_name(t)));*/ } else { - TypeBody_Description( TYPEget_body( t ), buf ); + TypeBody_Description(TYPEget_body(t), buf); } } @@ -1907,9 +1967,10 @@ Type_Description( const Type t, char * buf ) { otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ int -isMultiDimAggregateType( const Type t ) { - if( TYPEget_body( t )->base ) - if( isAggregateType( TYPEget_body( t )->base ) ) { +isMultiDimAggregateType(const Type t) +{ + if(TYPEget_body(t)->base) + if(isAggregateType(TYPEget_body(t)->base)) { return 1; } return 0; @@ -1931,7 +1992,8 @@ isMultiDimAggregateType( const Type t ) { return the name of the TD that arrlistSetAggr's ArrayTypeDescriptor should reference since it has an Express name associated with it. */ -int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { +int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) +{ (void) t; /* unused - FIXME implement or eliminate this function */ (void) buf; (void) schema; @@ -1950,7 +2012,8 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { *****/ void -TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { +TYPEprint_descriptions(const Type type, FILES *files, Schema schema) +{ char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], @@ -1958,62 +2021,62 @@ TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { Type i; int where_rule_number = 0; - strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; + strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + tdnm[BUFSIZ - 1] = '\0'; - if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { + if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { /* If we're a renamed enum type, just print a few typedef's to the original and some specialized create functions: */ - strncpy( base, StrToLower( EnumName( TYPEget_name( i ) ) ), BUFSIZ ); - base[BUFSIZ-1]='\0'; - strncpy( nm, StrToLower( EnumName( TYPEget_name( type ) ) ), BUFSIZ ); - nm[BUFSIZ-1]='\0'; - fprintf( files->lib, "%s = %s\n", nm, base ); + strncpy(base, StrToLower(EnumName(TYPEget_name(i))), BUFSIZ); + base[BUFSIZ - 1] = '\0'; + strncpy(nm, StrToLower(EnumName(TYPEget_name(type))), BUFSIZ); + nm[BUFSIZ - 1] = '\0'; + fprintf(files->lib, "%s = %s\n", nm, base); return; } - if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { - const char * output = FundamentalType( type, 0 ); - if( TYPEis_aggregate( type ) ) { - fprintf( files->lib, "%s = ", TYPEget_name( type ) ); - process_aggregate( files->lib, type ); - fprintf( files->lib, "\n" ); - } else if( TYPEis_boolean( type ) ) { - fprintf( files->lib, "%s = bool\n", TYPEget_name( type ) ); - } else if( TYPEis_select( type ) ) { - TYPEselect_lib_print( type, files -> lib ); - } else if( TYPEis_enumeration( type ) ) { - TYPEenum_lib_print( type, files -> lib ); - } else { + if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { + const char *output = FundamentalType(type, 0); + if(TYPEis_aggregate(type)) { + fprintf(files->lib, "%s = ", TYPEget_name(type)); + process_aggregate(files->lib, type); + fprintf(files->lib, "\n"); + } else if(TYPEis_boolean(type)) { + fprintf(files->lib, "%s = bool\n", TYPEget_name(type)); + } else if(TYPEis_select(type)) { + TYPEselect_lib_print(type, files -> lib); + } else if(TYPEis_enumeration(type)) { + TYPEenum_lib_print(type, files -> lib); + } else { /* the defined datatype inherits from the base type */ - fprintf( files->lib, "# Defined datatype %s\n", TYPEget_name( type ) ); - fprintf( files->lib, "class %s(", TYPEget_name( type ) ); - if( TYPEget_head( type ) != NULL ) { - fprintf( files->lib, "%s):\n", TYPEget_name( TYPEget_head( type ) ) ); + fprintf(files->lib, "# Defined datatype %s\n", TYPEget_name(type)); + fprintf(files->lib, "class %s(", TYPEget_name(type)); + if(TYPEget_head(type) != NULL) { + fprintf(files->lib, "%s):\n", TYPEget_name(TYPEget_head(type))); } else { - fprintf( files->lib, "%s):\n", output ); + fprintf(files->lib, "%s):\n", output); } - fprintf( files->lib, "\tdef __init__(self,*kargs):\n" ); - fprintf( files->lib, "\t\tpass\n" ); + fprintf(files->lib, "\tdef __init__(self,*kargs):\n"); + fprintf(files->lib, "\t\tpass\n"); /* call the where / rules */ - LISTdo( type->where, w, Where ) - if( strcmp( w->label->name, "" ) ) { + LISTdo(type->where, w, Where) + if(strcmp(w->label->name, "")) { /* define a function with the name 'label' */ - fprintf( files->lib, "\t\tself.%s()\n", w->label->name ); + fprintf(files->lib, "\t\tself.%s()\n", w->label->name); } else { /* no label */ - fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number ); + fprintf(files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number); where_rule_number ++; } LISTod - fprintf( files->lib, "\n" ); + fprintf(files->lib, "\n"); /* then we process the where rules */ - WHEREPrint( type->where, 0, files->lib ); + WHEREPrint(type->where, 0, files->lib); } } else { /* TODO: cleanup, currently this is deadcode */ - switch( TYPEget_body( type )->type ) { + switch(TYPEget_body(type)->type) { case enumeration_: - TYPEenum_lib_print( type, files -> lib ); + TYPEenum_lib_print(type, files -> lib); break; case select_: break; diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index 21c16d1c4..3fa6ed5ec 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -4,7 +4,7 @@ #include "complexSupport.h" -void use_ref( Schema, Express, FILES * ); +void use_ref(Schema, Express, FILES *); /****************************************************************** ** SCHEMA SECTION **/ @@ -22,20 +22,21 @@ void use_ref( Schema, Express, FILES * ); ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { - Linked_List list = SCOPEget_entities_superclass_order( scope ); - Linked_List function_list = SCOPEget_functions( scope ); - Linked_List rule_list = SCOPEget_rules( scope ); +void SCOPEPrint(Scope scope, FILES *files, Schema schema) +{ + Linked_List list = SCOPEget_entities_superclass_order(scope); + Linked_List function_list = SCOPEget_functions(scope); + Linked_List rule_list = SCOPEget_rules(scope); DictionaryEntry de; Type i; int redefs = 0;// index = 0; /* Defined Types based on SIMPLE types */ - SCOPEdo_types( scope, t, de ) - if ( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) - && ( TYPEget_ancestor( t ) == NULL) ) { - TYPEprint_descriptions( t, files, schema ); + SCOPEdo_types(scope, t, de) + if((t->search_id == CANPROCESS) + && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) + && (TYPEget_ancestor(t) == NULL)) { + TYPEprint_descriptions(t, files, schema); t->search_id = PROCESSED; } SCOPEod @@ -43,12 +44,12 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { /* Defined Types with defined ancestor head * TODO: recursive approach */ - SCOPEdo_types( scope, t, de ) - if ( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) - && ( ( i = TYPEget_head( t ) ) != NULL ) ) { - if (i->search_id == PROCESSED) { - TYPEprint_descriptions( t, files, schema ); + SCOPEdo_types(scope, t, de) + if((t->search_id == CANPROCESS) + && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) + && ((i = TYPEget_head(t)) != NULL)) { + if(i->search_id == PROCESSED) { + TYPEprint_descriptions(t, files, schema); t->search_id = PROCESSED; } } @@ -58,27 +59,27 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { /* and print the enumerations */ //fprintf( files -> inc, "\n/*\t************** TYPES \t*/\n" ); //fprintf( files -> lib, "\n/*\t************** TYPES \t*/\n" ); - SCOPEdo_types( scope, t, de ) + SCOPEdo_types(scope, t, de) // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if( ( t->search_id == CANPROCESS ) - && ( TYPEis_enumeration( t ) ) - && ( ( i = TYPEget_ancestor( t ) ) != NULL ) - && ( i->search_id >= CANPROCESS ) ) { + if((t->search_id == CANPROCESS) + && (TYPEis_enumeration(t)) + && ((i = TYPEget_ancestor(t)) != NULL) + && (i->search_id >= CANPROCESS)) { redefs = 1; } SCOPEod - SCOPEdo_types( scope, t, de ) + SCOPEdo_types(scope, t, de) // Do the non-redefined enumerations: - if( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { - TYPEprint_descriptions( t, files, schema ); - if( !TYPEis_select( t ) ) { + if((t->search_id == CANPROCESS) + && !(TYPEis_enumeration(t) && TYPEget_head(t))) { + TYPEprint_descriptions(t, files, schema); + if(!TYPEis_select(t)) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } @@ -86,10 +87,10 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { SCOPEod; // process redifined enumerations - if( redefs ) { - SCOPEdo_types( scope, t, de ) - if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { - TYPEprint_descriptions( t, files, schema ); + if(redefs) { + SCOPEdo_types(scope, t, de) + if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { + TYPEprint_descriptions(t, files, schema); t->search_id = PROCESSED; } SCOPEod; @@ -100,8 +101,8 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types( scope, t, de ) - if( t->search_id == CANPROCESS ) { + SCOPEdo_types(scope, t, de) + if(t->search_id == CANPROCESS) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. //FIXME this function is not implemented! @@ -111,25 +112,25 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { SCOPEod; // process each entity. This must be done *before* typedefs are defined - LISTdo( list, e, Entity ); - if( e->search_id == CANPROCESS ) { - ENTITYPrint( e, files ); + LISTdo(list, e, Entity); + if(e->search_id == CANPROCESS) { + ENTITYPrint(e, files); e->search_id = PROCESSED; } LISTod; - LISTfree( list ); + LISTfree(list); // process each function. This must be done *before* typedefs are defined - LISTdo( function_list, f, Function ); - FUNCPrint( f, files ); + LISTdo(function_list, f, Function); + FUNCPrint(f, files); LISTod; - LISTfree( function_list ); + LISTfree(function_list); // process each rule. This must be done *before* typedefs are defined - LISTdo( rule_list, r, Rule ); - RULEPrint( r, files ); + LISTdo(rule_list, r, Rule); + RULEPrint(r, files); LISTod; - LISTfree( rule_list ); + LISTfree(rule_list); } @@ -150,52 +151,53 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { ** Status: ******************************************************************/ -void SCHEMAprint( Schema schema, FILES * files, int suffix ) { +void SCHEMAprint(Schema schema, FILES *files, int suffix) +{ char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE * libfile; + FILE *libfile; /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf( schnm, "%s", SCHEMAget_name( schema ) ); - if( suffix == 0 ) { - sprintf( sufnm, "%s", schnm ); + sprintf(schnm, "%s", SCHEMAget_name(schema)); + if(suffix == 0) { + sprintf(sufnm, "%s", schnm); } else { - sprintf( sufnm, "%s_%d", schnm, suffix ); + sprintf(sufnm, "%s_%d", schnm, suffix); } - sprintf( fnm, "%s.h", sufnm ); + sprintf(fnm, "%s.h", sufnm); - np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ + np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ /* 2. class source file */ - sprintf( np, "py" ); - if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { + sprintf(np, "py"); + if(!(libfile = (files -> lib) = FILEcreate(fnm))) { return; } - fprintf( libfile, "import sys\n" ); - fprintf( libfile, "\n" ); - fprintf( libfile, "from SCL.SCLBase import *\n" ); - fprintf( libfile, "from SCL.SimpleDataTypes import *\n" ); - fprintf( libfile, "from SCL.ConstructedDataTypes import *\n" ); - fprintf( libfile, "from SCL.AggregationDataTypes import *\n" ); - fprintf( libfile, "from SCL.TypeChecker import check_type\n" ); - fprintf( libfile, "from SCL.Builtin import *\n" ); - fprintf( libfile, "from SCL.Rules import *\n" ); + fprintf(libfile, "import sys\n"); + fprintf(libfile, "\n"); + fprintf(libfile, "from SCL.SCLBase import *\n"); + fprintf(libfile, "from SCL.SimpleDataTypes import *\n"); + fprintf(libfile, "from SCL.ConstructedDataTypes import *\n"); + fprintf(libfile, "from SCL.AggregationDataTypes import *\n"); + fprintf(libfile, "from SCL.TypeChecker import check_type\n"); + fprintf(libfile, "from SCL.Builtin import *\n"); + fprintf(libfile, "from SCL.Rules import *\n"); /********* export schema name *******/ - fprintf( libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name( schema ) ); + fprintf(libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name(schema)); /******** export schema scope *******/ - fprintf( libfile, "schema_scope = sys.modules[__name__]\n\n" ); + fprintf(libfile, "schema_scope = sys.modules[__name__]\n\n"); /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint( schema, files, schema ); + SCOPEPrint(schema, files, schema); /********** close the files ***********/ - FILEclose( libfile ); + FILEclose(libfile); //FILEclose( incfile ); //if( schema->search_id == PROCESSED ) { // fprintf( initfile, "\n}\n" ); @@ -219,36 +221,37 @@ void SCHEMAprint( Schema schema, FILES * files, int suffix ) { ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { +getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) +{ DictionaryEntry de; Schema schema; - fprintf( schema_h, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n" ); - fprintf( schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n" ); - fprintf( schema_cc, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n" ); - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - schema = ( Scope )DICTdo( &de ); - fprintf( schema_cc, - " if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name( schema ) ); - fprintf( schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name( schema ) ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - fprintf( schema_cc, - " else if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name( schema ) ); - fprintf( schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name( schema ) ); + fprintf(schema_h, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n"); + fprintf(schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n"); + fprintf(schema_cc, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n"); + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + schema = (Scope)DICTdo(&de); + fprintf(schema_cc, + " if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name(schema)); + fprintf(schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name(schema)); + while((schema = (Scope)DICTdo(&de)) != 0) { + fprintf(schema_cc, + " else if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name(schema)); + fprintf(schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name(schema)); } - fprintf( schema_cc, "}\n" ); + fprintf(schema_cc, "}\n"); } /****************************************************************** @@ -264,10 +267,11 @@ getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -EXPRESSPrint( Express express, FILES * files ) { +EXPRESSPrint(Express express, FILES *files) +{ char fnm [MAX_LEN]; - const char * schnm; /* schnm is really "express name" */ - FILE * libfile; + const char *schnm; /* schnm is really "express name" */ + FILE *libfile; /* new */ Schema schema; DictionaryEntry de; @@ -276,23 +280,23 @@ EXPRESSPrint( Express express, FILES * files ) { /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); + sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); /* 2. class source file */ //sprintf( np, "cc" ); - if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { + if(!(libfile = (files -> lib) = FILEcreate(fnm))) { return; } /********** do all schemas ***********/ - DICTdo_init( express->symbol_table, &de ); - while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { - SCOPEPrint( schema, files, schema ); + DICTdo_init(express->symbol_table, &de); + while(0 != (schema = (Scope)DICTdo(&de))) { + SCOPEPrint(schema, files, schema); } /********** close the files ***********/ - FILEclose( libfile ); + FILEclose(libfile); //FILEclose( incfile ); //fprintf( initfile, "\n}\n" ); //FILEclose( initfile ); @@ -312,9 +316,10 @@ EXPRESSPrint( Express express, FILES * files ) { ******************************************************************/ void -print_schemas_combined( Express express, FILES * files ) { +print_schemas_combined(Express express, FILES *files) +{ - EXPRESSPrint( express, files ); + EXPRESSPrint(express, files); } /* @@ -329,17 +334,18 @@ print_schemas_combined( Express express, FILES * files ) { */ void -print_file( Express express ) { - extern void RESOLUTIONsucceed( void ); +print_file(Express express) +{ + extern void RESOLUTIONsucceed(void); int separate_schemas = 1; File_holder files; resolution_success(); - if( separate_schemas ) { - print_schemas_separate( express, &files ); + if(separate_schemas) { + print_schemas_separate(express, &files); } else { - print_schemas_combined( express, &files ); + print_schemas_combined(express, &files); } } diff --git a/src/exp2python/src/complexSupport.h b/src/exp2python/src/complexSupport.h index 7cd781a37..2f6731724 100644 --- a/src/exp2python/src/complexSupport.h +++ b/src/exp2python/src/complexSupport.h @@ -63,7 +63,8 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode { +class EntNode +{ friend class SimpleList; friend class AndOrList; friend class AndList; @@ -71,48 +72,59 @@ class EntNode { friend class ComplexList; public: - EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), - multSupers( 0 ) { - strcpy( name, nm ); - } - EntNode( char *[] ); // given a list, create a linked list of EntNodes - ~EntNode() { - if( next ) { + EntNode(const char *nm = "") : next(0), mark(NOMARK), + multSupers(0) + { + strcpy(name, nm); + } + EntNode(char *[]); // given a list, create a linked list of EntNodes + ~EntNode() + { + if(next) { delete next; } } - operator const char * () { + operator const char *() + { return name; } - int operator== ( EntNode & ent ) { - return ( strcmp( name, ent.name ) == 0 ); + int operator== (EntNode &ent) + { + return (strcmp(name, ent.name) == 0); } - int operator< ( EntNode & ent ) { - return ( strcmp( name, ent.name ) < 0 ); + int operator< (EntNode &ent) + { + return (strcmp(name, ent.name) < 0); } - int operator> ( EntNode & ent ) { - return ( strcmp( name, ent.name ) > 0 ); + int operator> (EntNode &ent) + { + return (strcmp(name, ent.name) > 0); } - void setmark( MarkType stamp = MARK ) { + void setmark(MarkType stamp = MARK) + { mark = stamp; } - void markAll( MarkType = MARK ); - void unmarkAll() { - markAll( NOMARK ); + void markAll(MarkType = MARK); + void unmarkAll() + { + markAll(NOMARK); } - int marked( MarkType base = ORMARK ) { - return ( mark >= base ); + int marked(MarkType base = ORMARK) + { + return (mark >= base); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() { + int multSuprs() + { return multSupers; } - void multSuprs( int j ) { + void multSuprs(int j) + { multSupers = j; } - EntNode * next; + EntNode *next; private: MarkType mark; @@ -120,68 +132,79 @@ class EntNode { int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList { +class EntList +{ friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, EntList & ); - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, EntList &); + friend ostream &operator<< (ostream &, MultList &); public: - EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), - level( 0 ) {} + EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), + level(0) {} virtual ~EntList() {} - MatchType viableVal() { + MatchType viableVal() + { return viable; } - virtual void setLevel( int l ) { + virtual void setLevel(int l) + { level = l; } - virtual int getMaxLevel() { + virtual int getMaxLevel() + { return level; } - virtual int contains( const char * ) = 0; - virtual int hit( const char * ) = 0; - virtual int isDependent( const char * ) = 0; - virtual MatchType matchNonORs( EntNode * ) { + virtual int contains(const char *) = 0; + virtual int hit(const char *) = 0; + virtual int isDependent(const char *) = 0; + virtual MatchType matchNonORs(EntNode *) + { return UNKNOWN; } - virtual int acceptChoice( EntNode * ) = 0; - virtual void unmarkAll( EntNode * ) = 0; - virtual void reset() { + virtual int acceptChoice(EntNode *) = 0; + virtual void unmarkAll(EntNode *) = 0; + virtual void reset() + { viable = UNKNOWN; } int siblings(); - virtual void write( ostream & ) = 0; + virtual void write(ostream &) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList * firstNot( JoinType ); - EntList * nextNot( JoinType j ) { - return next->firstNot( j ); + EntList *firstNot(JoinType); + EntList *nextNot(JoinType j) + { + return next->firstNot(j); } - EntList * firstWanted( MatchType ); - EntList * nextWanted( MatchType mat ) { - return next->firstWanted( mat ); + EntList *firstWanted(MatchType); + EntList *nextWanted(MatchType mat) + { + return next->firstWanted(mat); } - EntList * lastNot( JoinType ); - EntList * prevNot( JoinType j ) { - return prev->lastNot( j ); + EntList *lastNot(JoinType); + EntList *prevNot(JoinType j) + { + return prev->lastNot(j); } - EntList * lastWanted( MatchType ); - EntList * prevWanted( MatchType mat ) { - return prev->lastWanted( mat ); + EntList *lastWanted(MatchType); + EntList *prevWanted(MatchType mat) + { + return prev->lastWanted(mat); } JoinType join; - int multiple() { - return ( join != SIMPLE ); + int multiple() + { + return (join != SIMPLE); } - EntList * prev, * next; + EntList *prev, * next; protected: MatchType viable; @@ -193,137 +216,153 @@ class EntList { int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList { +class SimpleList : public EntList +{ friend class ComplexList; - friend ostream & operator<< ( ostream &, SimpleList & ); + friend ostream &operator<< (ostream &, SimpleList &); public: - SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { - strcpy( name, n ); + SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) + { + strcpy(name, n); } ~SimpleList() {} - int operator== ( const char * nm ) { - return ( strcmp( name, nm ) == 0 ); + int operator== (const char *nm) + { + return (strcmp(name, nm) == 0); } - const char * Name() { + const char *Name() + { return name; } - int contains( const char * nm ) { + int contains(const char *nm) + { return *this == nm; } - int hit( const char * nm ) { + int hit(const char *nm) + { return *this == nm; } - int isDependent( const char * ); - MatchType matchNonORs( EntNode * ); - int acceptChoice( EntNode * ); - void unmarkAll( EntNode * ); - void reset() { + int isDependent(const char *); + MatchType matchNonORs(EntNode *); + int acceptChoice(EntNode *); + void unmarkAll(EntNode *); + void reset() + { viable = UNKNOWN; I_marked = NOMARK; } - void write( ostream & ); + void write(ostream &); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList { +class MultList : public EntList +{ // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, MultList & ); + friend ostream &operator<< (ostream &, MultList &); public: - MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} + MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} ~MultList(); - void setLevel( int ); + void setLevel(int); int getMaxLevel(); - int contains( const char * ); - int hit( const char * ); - int isDependent( const char * ); - void appendList( EntList * ); - EntList * copyList( EntList * ); - void processSubExp( Expression, Entity, ComplexCollect * ); - void addSimpleAndSubs( Entity, ComplexCollect * ); - virtual MatchType matchORs( EntNode * ) = 0; - virtual MatchType tryNext( EntNode * ); - - int childCount() { + int contains(const char *); + int hit(const char *); + int isDependent(const char *); + void appendList(EntList *); + EntList *copyList(EntList *); + void processSubExp(Expression, Entity, ComplexCollect *); + void addSimpleAndSubs(Entity, ComplexCollect *); + virtual MatchType matchORs(EntNode *) = 0; + virtual MatchType tryNext(EntNode *); + + int childCount() + { return numchildren; } // EntList *operator[]( int ); - EntList * getChild( int ); - EntList * getLast() { - return ( getChild( numchildren - 1 ) ); + EntList *getChild(int); + EntList *getLast() + { + return (getChild(numchildren - 1)); } - void unmarkAll( EntNode * ); - int prevKnown( EntList * ); + void unmarkAll(EntNode *); + int prevKnown(EntList *); void reset(); - void write( ostream & ); + void write(ostream &); protected: int numchildren; - EntList * childList; + EntList *childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList { +class JoinList : public MultList +{ // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList( JoinType j ) : MultList( j ) {} + JoinList(JoinType j) : MultList(j) {} ~JoinList() {} - void setViableVal( EntNode * ); - int acceptChoice( EntNode * ); + void setViableVal(EntNode *); + int acceptChoice(EntNode *); }; -class AndOrList : public JoinList { +class AndOrList : public JoinList +{ friend class ComplexList; public: - AndOrList() : JoinList( ANDOR ) {} + AndOrList() : JoinList(ANDOR) {} ~AndOrList() {} - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); }; -class AndList : public JoinList { +class AndList : public JoinList +{ friend class MultList; friend class ComplexList; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - AndList() : JoinList( AND ), supertype( 0 ) {} + AndList() : JoinList(AND), supertype(0) {} ~AndList() {} - int isDependent( const char * ); - MatchType matchNonORs( EntNode * ); - MatchType matchORs( EntNode * ); + int isDependent(const char *); + MatchType matchNonORs(EntNode *); + MatchType matchORs(EntNode *); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList { +class OrList : public MultList +{ public: - OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} + OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} ~OrList() {} - int hit( const char * ); - MatchType matchORs( EntNode * ); - MatchType tryNext( EntNode * ); - void unmarkAll( EntNode * ); - int acceptChoice( EntNode * ); - int acceptNextChoice( EntNode * ents ) { + int hit(const char *); + MatchType matchORs(EntNode *); + MatchType tryNext(EntNode *); + void unmarkAll(EntNode *); + int acceptChoice(EntNode *); + int acceptNextChoice(EntNode *ents) + { choice++; - return ( acceptChoice( ents ) ); + return (acceptChoice(ents)); } - void reset() { + void reset() + { choice = -1; choice1 = -2; choiceCount = 0; @@ -336,90 +375,101 @@ class OrList : public MultList { // the first viable choice; and how many choices are there entirely. }; -class ComplexList { +class ComplexList +{ // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream & operator<< ( ostream &, ComplexList & ); + friend ostream &operator<< (ostream &, ComplexList &); public: - ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), - abstract( 0 ), dependent( 0 ), - multSupers( 0 ) {} - ComplexList( Entity, ComplexCollect * ); + ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), + abstract(0), dependent(0), + multSupers(0) {} + ComplexList(Entity, ComplexCollect *); ~ComplexList(); void buildList(); void remove(); - int operator< ( ComplexList & c ) { - return ( strcmp( supertype(), c.supertype() ) < 0 ); + int operator< (ComplexList &c) + { + return (strcmp(supertype(), c.supertype()) < 0); } - int operator< ( char * name ) { - return ( strcmp( supertype(), name ) < 0 ); + int operator< (char *name) + { + return (strcmp(supertype(), name) < 0); } - int operator== ( char * name ) { - return ( strcmp( supertype(), name ) == 0 ); + int operator== (char *name) + { + return (strcmp(supertype(), name) == 0); } - const char * supertype() { - return ( ( SimpleList * )head->childList )->name; + const char *supertype() + { + return ((SimpleList *)head->childList)->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel( const char * ); - int contains( EntNode * ); - int matches( EntNode * ); - int isDependent( const char * ); + int toplevel(const char *); + int contains(EntNode *); + int matches(EntNode *); + int isDependent(const char *); - EntNode * list; // List of all entities contained in this complex type, + EntNode *list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList * head; - ComplexList * next; - int Dependent() { + AndList *head; + ComplexList *next; + int Dependent() + { return dependent; } - void write( ostream & ); - int getEntListMaxLevel() { + void write(ostream &); + int getEntListMaxLevel() + { return head->getMaxLevel(); } private: - void addSuper( Entity ); - void addSubExp( Expression ); - void addImplicitSubs( Linked_List, ComplexCollect * ); - void addChildren( EntList * ); - int hitMultNodes( EntNode * ); + void addSuper(Entity); + void addSubExp(Expression); + void addImplicitSubs(Linked_List, ComplexCollect *); + void addChildren(EntList *); + int hitMultNodes(EntNode *); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect { +class ComplexCollect +{ // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect( ComplexList * c = NULL ) : clists( c ) { - count = ( c ? 1 : 0 ); + ComplexCollect(ComplexList *c = NULL) : clists(c) + { + count = (c ? 1 : 0); } - ComplexCollect( Express ); - ~ComplexCollect() { + ComplexCollect(Express); + ~ComplexCollect() + { delete clists; } - void insert( ComplexList * ); - void remove( ComplexList * ); + void insert(ComplexList *); + void remove(ComplexList *); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList * find( char * ); - int supports( EntNode * ); - int externMapping( const char * ent ) { - return ( clists ? clists->isDependent( ent ) : 0 ); + ComplexList *find(char *); + int supports(EntNode *); + int externMapping(const char *ent) + { + return (clists ? clists->isDependent(ent) : 0); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write( const char * ); + void write(const char *); - ComplexList * clists; + ComplexList *clists; private: int count; // # of clist children @@ -427,6 +477,6 @@ class ComplexCollect { // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex( ComplexCollect &, const char * ); +void print_complex(ComplexCollect &, const char *); #endif diff --git a/src/exp2python/src/fedex_main_python.c b/src/exp2python/src/fedex_main_python.c index be7bdd242..d8d379ce9 100644 --- a/src/exp2python/src/fedex_main_python.c +++ b/src/exp2python/src/fedex_main_python.c @@ -11,52 +11,56 @@ #include "../express/express.h" #include "../express/resolve.h" -extern void print_fedex_version( void ); +extern void print_fedex_version(void); -static void exp2python_usage( void ) { +static void exp2python_usage(void) +{ char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf( stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); - fprintf( stderr, "\t-v produces the version description below\n" ); - fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); - fprintf( stderr, "\t-w warning enable\n" ); - fprintf( stderr, "\t-i warning ignore\n" ); - fprintf( stderr, "and is one of:\n" ); - fprintf( stderr, "\tnone\n\tall\n" ); - fprintf( stderr, "%s", warnings_help_msg); - fprintf( stderr, "and is one or more of:\n" ); - fprintf( stderr, " e entity\n" ); - fprintf( stderr, " p procedure\n" ); - fprintf( stderr, " r rule\n" ); - fprintf( stderr, " f function\n" ); - fprintf( stderr, " t type\n" ); - fprintf( stderr, " s schema or file\n" ); - fprintf( stderr, " # pass #\n" ); - fprintf( stderr, " E everything (all of the above)\n" ); + fprintf(stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); + fprintf(stderr, "\t-v produces the version description below\n"); + fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); + fprintf(stderr, "\t-w warning enable\n"); + fprintf(stderr, "\t-i warning ignore\n"); + fprintf(stderr, "and is one of:\n"); + fprintf(stderr, "\tnone\n\tall\n"); + fprintf(stderr, "%s", warnings_help_msg); + fprintf(stderr, "and is one or more of:\n"); + fprintf(stderr, " e entity\n"); + fprintf(stderr, " p procedure\n"); + fprintf(stderr, " r rule\n"); + fprintf(stderr, " f function\n"); + fprintf(stderr, " t type\n"); + fprintf(stderr, " s schema or file\n"); + fprintf(stderr, " # pass #\n"); + fprintf(stderr, " E everything (all of the above)\n"); print_fedex_version(); - exit( 2 ); + exit(2); } -int Handle_FedPlus_Args( int, char * ); -void print_file( Express ); +int Handle_FedPlus_Args(int, char *); +void print_file(Express); -void resolution_success( void ) { - printf( "Resolution successful.\nWriting python module..." ); +void resolution_success(void) +{ + printf("Resolution successful.\nWriting python module..."); } -int success( Express model ) { +int success(Express model) +{ (void) model; /* unused */ - printf( "Done.\n" ); - return( 0 ); + printf("Done.\n"); + return(0); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init( void ) { +void EXPRESSinit_init(void) +{ EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat( EXPRESSgetopt_options, "sSLcCaA" ); + strcat(EXPRESSgetopt_options, "sSLcCaA"); ERRORusage_function = exp2python_usage; } diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index ece7e6617..efc46a7b1 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -37,22 +37,22 @@ #define FALSE 0 #define TRUE 1 -int isAggregateType( const Type t ); +int isAggregateType(const Type t); /* Local function prototypes: */ -static void initializeMarks( Express ); -static void unsetObjs( Schema ); -static int checkTypes( Schema ); -static int checkEnts( Schema ); -static void markDescs( Entity ); -static int checkItem( Type, Scope, Schema, int *, int ); -static int ENUMcanBeProcessed( Type, Schema ); -static int inSchema( Scope, Scope ); +static void initializeMarks(Express); +static void unsetObjs(Schema); +static int checkTypes(Schema); +static int checkEnts(Schema); +static void markDescs(Entity); +static int checkItem(Type, Scope, Schema, int *, int); +static int ENUMcanBeProcessed(Type, Schema); +static int inSchema(Scope, Scope); /* static void addRenameTypedefs( Schema, FILE * ); */ -static void addAggrTypedefs( Schema schema ); -static void addUseRefNames( Schema, FILE * ); +static void addAggrTypedefs(Schema schema); +static void addUseRefNames(Schema, FILE *); -void print_schemas_separate( Express express, FILES * files ) +void print_schemas_separate(Express express, FILES *files) /* * Generates the C++ files corresponding to a list of schemas. Does so in * multiple passes through the schemas. In each pass it checks for enti- @@ -69,31 +69,31 @@ void print_schemas_separate( Express express, FILES * files ) Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks( express ); + initializeMarks(express); /* FIXME SdaiAll.cc:12:24: warning: unused variable ‘is’ [-Wunused-variable] (also for ui & ri) */ /* fprintf( files->create, " Interface_spec_ptr is;\n Used_item_ptr ui;\n Referenced_item_ptr ri;\n Uniqueness_rule_ptr ur;\n Where_rule_ptr wr;\n Global_rule_ptr gr;\n" ); */ - while( !complete ) { + while(!complete) { complete = TRUE; - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { - if( schema->search_id == UNPROCESSED ) { + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { + if(schema->search_id == UNPROCESSED) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs( schema ); + unsetObjs(schema); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes( schema ); - val2 = checkEnts( schema ); + val1 = checkTypes(schema); + val2 = checkEnts(schema); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if( val1 || val2 ) { - if( schema->search_id == UNPROCESSED || - *( int * )schema->clientData > 0 ) { + if(val1 || val2) { + if(schema->search_id == UNPROCESSED || + *(int *)schema->clientData > 0) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -103,13 +103,13 @@ void print_schemas_separate( Express express, FILES * files ) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*( int * )schema->clientData; - SCHEMAprint( schema, files, suffix ); + suffix = ++*(int *)schema->clientData; + SCHEMAprint(schema, files, suffix); } else { - SCHEMAprint( schema, files, 0 ); + SCHEMAprint(schema, files, 0); } } - complete = complete && ( schema->search_id == PROCESSED ); + complete = complete && (schema->search_id == PROCESSED); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -131,18 +131,18 @@ void print_schemas_separate( Express express, FILES * files ) /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addUseRefNames( schema, files->create ); + addUseRefNames(schema, files->create); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de)) != 0) { /* addAggrTypedefs( schema, files->classes ); */ - addAggrTypedefs( schema ); + addAggrTypedefs(schema); } /* On our way out, print the necessary statements to add support for @@ -168,19 +168,20 @@ void print_schemas_separate( Express express, FILES * files ) * an attribute/item which comes from another schema. All other types can * be processed the first time, but that will be caught in checkTypes().) */ -static void initializeMarks( Express express ) { +static void initializeMarks(Express express) +{ DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); - while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); + while((schema = (Scope)DICTdo(&de_sch)) != 0) { schema->search_id = UNPROCESSED; - schema->clientData = ( int * )malloc( sizeof( int ) ); - *( int * )schema->clientData = 0; - SCOPEdo_entities( schema, ent, de_ent ) + schema->clientData = (int *)malloc(sizeof(int)); + *(int *)schema->clientData = 0; + SCOPEdo_entities(schema, ent, de_ent) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types( schema, t, de_type ) + SCOPEdo_types(schema, t, de_type) t->search_id = NOTKNOWN; SCOPEod } @@ -195,16 +196,17 @@ static void initializeMarks( Express express ) { * types which have already been marked PROCESSED will not have to be * revisited, and are not changed. */ -static void unsetObjs( Schema schema ) { +static void unsetObjs(Schema schema) +{ DictionaryEntry de; - SCOPEdo_types( schema, t, de ) - if( t->search_id == CANTPROCESS ) { + SCOPEdo_types(schema, t, de) + if(t->search_id == CANTPROCESS) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities( schema, ent, de ) - if( ent->search_id == CANTPROCESS ) { + SCOPEdo_entities(schema, ent, de) + if(ent->search_id == CANTPROCESS) { ent->search_id = NOTKNOWN; } SCOPEod @@ -222,7 +224,8 @@ static void unsetObjs( Schema schema ) { * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static int checkTypes( Schema schema ) { +static int checkTypes(Schema schema) +{ DictionaryEntry de; int retval = FALSE, unknowncnt; Type i; @@ -231,8 +234,8 @@ static int checkTypes( Schema schema ) { do { unknowncnt = 0; - SCOPEdo_types( schema, type, de ) - if( type->search_id != NOTKNOWN ) { + SCOPEdo_types(schema, type, de) + if(type->search_id != NOTKNOWN) { continue; } /* We're only interested in the ones which haven't been processed @@ -241,9 +244,9 @@ static int checkTypes( Schema schema ) { type->search_id = CANPROCESS; /* Assume this until disproven. */ - if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { - i = TYPEget_ancestor( type ); - if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { + if(TYPEis_enumeration(type) && TYPEget_head(type)) { + i = TYPEget_ancestor(type); + if(!sameSchema(i, type) && i->search_id != PROCESSED) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -252,10 +255,10 @@ static int checkTypes( Schema schema ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if( TYPEis_select( type ) ) { - LISTdo( SEL_TYPEget_items( type ), ii, Type ) { - if( !TYPEis_entity( ii ) ) { - if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { + } else if(TYPEis_select(type)) { + LISTdo(SEL_TYPEget_items(type), ii, Type) { + if(!TYPEis_entity(ii)) { + if(checkItem(ii, type, schema, &unknowncnt, 0)) { break; } /* checkItem does most of the work of determining if @@ -269,8 +272,8 @@ static int checkTypes( Schema schema ) { } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity( ii ); - if( ent->search_id == PROCESSED ) { + ent = ENT_TYPEget_entity(ii); + if(ent->search_id == PROCESSED) { continue; } /* If entity has been processed already, things must be @@ -280,31 +283,33 @@ static int checkTypes( Schema schema ) { // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes( ent ); - LISTdo_n( attribs, attr, Variable, b ) { - if( checkItem( attr->type, type, schema, - &unknowncnt, 1 ) ) { + attribs = ENTITYget_all_attributes(ent); + LISTdo_n(attribs, attr, Variable, b) { + if(checkItem(attr->type, type, schema, + &unknowncnt, 1)) { break; } - } LISTod - LISTfree( attribs ); + } + LISTod + LISTfree(attribs); } - } LISTod + } + LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if( ( type->search_id == CANPROCESS ) - && ( ( i = TYPEget_ancestor( type ) ) != NULL ) - && ( !sameSchema( i, type ) ) - && ( i->search_id != PROCESSED ) ) { + if((type->search_id == CANPROCESS) + && ((i = TYPEget_ancestor(type)) != NULL) + && (!sameSchema(i, type)) + && (i->search_id != PROCESSED)) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if( type->search_id == CANPROCESS ) { + if(type->search_id == CANPROCESS) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -313,7 +318,7 @@ static int checkTypes( Schema schema ) { retval = TRUE; } SCOPEod - } while( unknowncnt > 0 ); + } while(unknowncnt > 0); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -331,7 +336,7 @@ static int checkTypes( Schema schema ) { return retval; } -static int checkEnts( Schema schema ) +static int checkEnts(Schema schema) /* * Goes through the entities contained in this schema checking for ones * which can't be processed. It checks for two situations: (1) If we find @@ -353,8 +358,8 @@ static int checkEnts( Schema schema ) int retval = FALSE, ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities( schema, ent, de ) - if( ent->search_id != NOTKNOWN ) { + SCOPEdo_entities(schema, ent, de) + if(ent->search_id != NOTKNOWN) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -366,10 +371,10 @@ static int checkEnts( Schema schema ) /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo( ENTITYget_supertypes( ent ), super, Entity ) - if( ( !sameSchema( ent, super ) ) - && ( super->search_id != PROCESSED ) ) { - markDescs( ent ); + LISTdo(ENTITYget_supertypes(ent), super, Entity) + if((!sameSchema(ent, super)) + && (super->search_id != PROCESSED)) { + markDescs(ent); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -379,17 +384,17 @@ static int checkEnts( Schema schema ) /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if( ent->search_id == CANPROCESS ) { + if(ent->search_id == CANPROCESS) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo( ENTITYget_attributes( ent ), attr, Variable ) - if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { - markDescs( ent ); + LISTdo(ENTITYget_attributes(ent), attr, Variable) + if(checkItem(attr->type, ent, schema, &ignore, 0)) { + markDescs(ent); break; } LISTod } - if( ent->search_id == CANPROCESS ) { + if(ent->search_id == CANPROCESS) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -405,7 +410,7 @@ static int checkEnts( Schema schema ) return retval; } -static void markDescs( Entity ent ) +static void markDescs(Entity ent) /* * Sets the mark value of ent and all its subtypes to CANTPROCESS. This * function is called if we've determined that ent is a subtype of an @@ -413,13 +418,13 @@ static void markDescs( Entity ent ) */ { ent->search_id = CANTPROCESS; - LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) - markDescs( sub ); + LISTdo(ENTITYget_subtypes(ent), sub, Entity) + markDescs(sub); LISTod } -static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, - int noSel ) +static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, + int noSel) /* * Function with a lot of side effects: Checks if type t, a member of * `parent' makes parent unprocessable. parent may be an entity and t is @@ -445,8 +450,8 @@ static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, { Type i = t; - if( isAggregateType( t ) ) { - i = TYPEget_base_type( t ); + if(isAggregateType(t)) { + i = TYPEget_base_type(t); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -455,26 +460,26 @@ static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, // Sdaiclasses.h. */ } - if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { + if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if( parent->search_id == NOTKNOWN ) { + if(parent->search_id == NOTKNOWN) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - ( *unknowncnt )--; + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if( TYPEis_select( i ) && !noSel ) { - if( !sameSchema( i, parent ) ) { - if( i->search_id != PROCESSED ) { - if( parent->search_id == NOTKNOWN ) { - ( *unknowncnt )--; + } else if(TYPEis_select(i) && !noSel) { + if(!sameSchema(i, parent)) { + if(i->search_id != PROCESSED) { + if(parent->search_id == NOTKNOWN) { + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -484,24 +489,24 @@ static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if( i->search_id == CANTPROCESS ) { + if(i->search_id == CANTPROCESS) { /* We *have* checked i already and it can't be processed. */ - if( parent->search_id == NOTKNOWN ) { - ( *unknowncnt )--; + if(parent->search_id == NOTKNOWN) { + (*unknowncnt)--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if( i->search_id == NOTKNOWN ) { + } else if(i->search_id == NOTKNOWN) { /* We haven't processed i this pass. */ - if( parent->search_id != NOTKNOWN ) { + if(parent->search_id != NOTKNOWN) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping through the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - ( *unknowncnt )++; + (*unknowncnt)++; } } } @@ -509,7 +514,7 @@ static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, return FALSE; } -static int ENUMcanBeProcessed( Type e, Schema s ) +static int ENUMcanBeProcessed(Type e, Schema s) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -521,31 +526,31 @@ static int ENUMcanBeProcessed( Type e, Schema s ) { Type a; - if( !inSchema( e, s ) ) { + if(!inSchema(e, s)) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return ( e->search_id == PROCESSED ); + return (e->search_id == PROCESSED); } - if( e->search_id != NOTKNOWN ) { + if(e->search_id != NOTKNOWN) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return ( e->search_id >= CANPROCESS ); + return (e->search_id >= CANPROCESS); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if( ( a = TYPEget_ancestor( e ) ) == NULL ) { + if((a = TYPEget_ancestor(e)) == NULL) { /* If e is not a rename of anything, it should be processed now. */ return TRUE; } - if( inSchema( a, s ) || a->search_id == PROCESSED ) { + if(inSchema(a, s) || a->search_id == PROCESSED) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return TRUE; @@ -553,26 +558,26 @@ static int ENUMcanBeProcessed( Type e, Schema s ) return FALSE; } -int sameSchema( Scope sc1, Scope sc2 ) +int sameSchema(Scope sc1, Scope sc2) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return ( !strcmp( SCOPEget_name( sc1->superscope ), - SCOPEget_name( sc2->superscope ) ) ); + return (!strcmp(SCOPEget_name(sc1->superscope), + SCOPEget_name(sc2->superscope))); } -static int inSchema( Scope scope, Scope super ) +static int inSchema(Scope scope, Scope super) /* * Checks if scope is contained in super's scope. */ { - return ( !strcmp( SCOPEget_name( scope->superscope ), - SCOPEget_name( super ) ) ); + return (!strcmp(SCOPEget_name(scope->superscope), + SCOPEget_name(super))); } -static void addAggrTypedefs( Schema schema ) +static void addAggrTypedefs(Schema schema) /* * Print typedefs at the end of Sdiaclasses.h for aggregates of enum's and * selects. Since the underlying enum/sel may appear in any schema, this @@ -584,15 +589,15 @@ static void addAggrTypedefs( Schema schema ) DictionaryEntry de; Type i; - SCOPEdo_types( schema, t, de ) - if( TYPEis_aggregate( t ) ) { - i = TYPEget_base_type( t ); - if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { + SCOPEdo_types(schema, t, de) + if(TYPEis_aggregate(t)) { + i = TYPEget_base_type(t); + if(TYPEis_enumeration(i) || TYPEis_select(i)) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - printf( "in addAggrTypedefs. %s is enum or select.\n", TYPEget_name( t ) ); + printf("in addAggrTypedefs. %s is enum or select.\n", TYPEget_name(t)); /* strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); //printf("%s;%s",nm,TYPEget_ctype( t )); //if( firsttime ) { @@ -610,7 +615,7 @@ static void addAggrTypedefs( Schema schema ) SCOPEod } -static void addUseRefNames( Schema schema, FILE * create ) +static void addUseRefNames(Schema schema, FILE *create) /* * Checks the USE and REFERENCE dicts contained in schema. If either dict * contains items (types or entities) which are renamed in this schema, @@ -622,60 +627,60 @@ static void addUseRefNames( Schema schema, FILE * create ) { Dictionary useRefDict; DictionaryEntry de; - Rename * rnm; - char * oldnm, schNm[BUFSIZ]; + Rename *rnm; + char *oldnm, schNm[BUFSIZ]; static int firsttime = TRUE; - if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { - DICTdo_init( useRefDict, &de ); - while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { - oldnm = ( ( Scope )rnm->object )->symbol.name; - if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if((useRefDict = schema->u.schema->usedict) != NULL) { + DICTdo_init(useRefDict, &de); + while((rnm = (Rename *)DICTdo(&de)) != 0) { + oldnm = ((Scope)rnm->object)->symbol.name; + if((strcmp(oldnm, rnm->nnew->name))) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if( firsttime ) { - fprintf( create, "\t// Alternate names for types and " ); - fprintf( create, "entities when used in other schemas:\n" ); + if(firsttime) { + fprintf(create, "\t// Alternate names for types and "); + fprintf(create, "entities when used in other schemas:\n"); firsttime = FALSE; } - if( rnm->type == OBJ_TYPE ) { - fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); + if(rnm->type == OBJ_TYPE) { + fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); } else { /* must be an entity */ - fprintf( create, "\t%s%s%s", - SCOPEget_name( ( ( Entity )rnm->object )->superscope ), - ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); + fprintf(create, "\t%s%s%s", + SCOPEget_name(((Entity)rnm->object)->superscope), + ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); } - strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); - fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName( rnm->nnew->name ) ); + strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); + fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName(rnm->nnew->name)); } } } - if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { - DICTdo_init( useRefDict, &de ); - while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { - oldnm = ( ( Scope )rnm->object )->symbol.name; - if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { - if( firsttime ) { - fprintf( create, "\t// Alternate names for types and " ); - fprintf( create, "entities when used in other schemas:\n" ); + if((useRefDict = schema->u.schema->refdict) != NULL) { + DICTdo_init(useRefDict, &de); + while((rnm = (Rename *)DICTdo(&de)) != 0) { + oldnm = ((Scope)rnm->object)->symbol.name; + if((strcmp(oldnm, rnm->nnew->name))) { + if(firsttime) { + fprintf(create, "\t// Alternate names for types and "); + fprintf(create, "entities when used in other schemas:\n"); firsttime = FALSE; } - if( rnm->type == OBJ_TYPE ) { - fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); + if(rnm->type == OBJ_TYPE) { + fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); } else { - fprintf( create, "\t%s%s%s", - SCOPEget_name( ( ( Entity )rnm->object )->superscope ), - ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); + fprintf(create, "\t%s%s%s", + SCOPEget_name(((Entity)rnm->object)->superscope), + ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); } - strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); - fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName( rnm->nnew->name ) ); + strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); + fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName(rnm->nnew->name)); } } } diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index b44abab95..3a202d900 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -25,13 +25,13 @@ extern int multiple_inheritance; #include "classes.h" #include -bool is_python_keyword( char * word ); -int isAggregateType( const Type t ); -char * generate_attribute_name( Variable a, char * out ); -void ATTRsign_access_methods( Variable a, FILE * file ); -char * generate_attribute_func_name( Variable a, char * out ); -void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file ); -void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); +bool is_python_keyword(char *word); +int isAggregateType(const Type t); +char *generate_attribute_name(Variable a, char *out); +void ATTRsign_access_methods(Variable a, FILE *file); +char *generate_attribute_func_name(Variable a, char *out); +void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file); +void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); #define BASE_SELECT "SCLP23(Select)" @@ -62,15 +62,17 @@ void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * f #define FALSE 0 const char * -SEL_ITEMget_enumtype( Type t ) { - return StrToUpper( TYPEget_name( t ) ); +SEL_ITEMget_enumtype(Type t) +{ + return StrToUpper(TYPEget_name(t)); } /** FIXME implement for python or remove ** \returns type used to represent the underlying type in a select class */ -const char * TYPEget_utype( Type t ) { +const char *TYPEget_utype(Type t) +{ (void) t; /* unused */ return NULL; } @@ -82,13 +84,14 @@ determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. *******************/ void * -LISTmember( const Linked_List list, void *e ) { +LISTmember(const Linked_List list, void *e) +{ Link node; - for( node = list->mark->next; node != list->mark; node = node->next ) - if( e == node -> data ) { + for(node = list->mark->next; node != list->mark; node = node->next) + if(e == node -> data) { return e; } - return ( 0 ); + return (0); } /******************* @@ -103,18 +106,19 @@ LISTmember( const Linked_List list, void *e ) { dered equivalent. One such case is the generation of duplicate lists. *******************/ static int -compareOrigTypes( Type a, Type b ) { +compareOrigTypes(Type a, Type b) +{ Type t, u; - if( ( TYPEis_select( a ) && TYPEis_select( b ) ) - || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { + if((TYPEis_select(a) && TYPEis_select(b)) + || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { t = a; u = b; - } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { - t = TYPEget_base_type( a ); - u = TYPEget_base_type( b ); - if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) - || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { + } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { + t = TYPEget_base_type(a); + u = TYPEget_base_type(b); + if(!((TYPEis_select(t) && TYPEis_select(u)) + || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that // for 2D aggrs and higher we do not continue. These are all recog- @@ -125,13 +129,13 @@ compareOrigTypes( Type a, Type b ) { return FALSE; } - if( TYPEget_head( t ) ) { - t = TYPEget_ancestor( t ); + if(TYPEget_head(t)) { + t = TYPEget_ancestor(t); } - if( TYPEget_head( u ) ) { - u = TYPEget_ancestor( u ); + if(TYPEget_head(u)) { + u = TYPEget_ancestor(u); } - return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); + return (!strcmp(TYPEget_name(t), TYPEget_name(u))); } /******************* @@ -145,15 +149,16 @@ compareOrigTypes( Type a, Type b ) { compareOrigTypes() above). *******************/ const char * -utype_member( const Linked_List list, const Type check, int rename ) { +utype_member(const Linked_List list, const Type check, int rename) +{ static char r [BUFSIZ]; - LISTdo( list, t, Type ) - strncpy( r, TYPEget_utype( t ), BUFSIZ ); - if( strcmp( r, TYPEget_utype( check ) ) == 0 ) { + LISTdo(list, t, Type) + strncpy(r, TYPEget_utype(t), BUFSIZ); + if(strcmp(r, TYPEget_utype(check)) == 0) { return r; } - if( rename && compareOrigTypes( check, t ) ) { + if(rename && compareOrigTypes(check, t)) { return r; } LISTod; @@ -171,15 +176,16 @@ utype_member( const Linked_List list, const Type check, int rename ) { Linked_List -SELgetnew_dmlist( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +SELgetnew_dmlist(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); - LISTdo( complete, t, Type ) + LISTdo(complete, t, Type) /* if t\'s underlying type is not already in newlist, */ - if( ! utype_member( newlist, t, 0 ) ) { - LISTadd_last( newlist, t ); + if(! utype_member(newlist, t, 0)) { + LISTadd_last(newlist, t); } LISTod; @@ -189,9 +195,10 @@ SELgetnew_dmlist( const Type type ) { } const char * -SEL_ITEMget_dmtype( Type t, const Linked_List l ) { - const char * r = utype_member( l, t, 0 ); - return StrToLower( r ? r : TYPEget_utype( t ) ); +SEL_ITEMget_dmtype(Type t, const Linked_List l) +{ + const char *r = utype_member(l, t, 0); + return StrToLower(r ? r : TYPEget_utype(t)); } @@ -204,14 +211,15 @@ of the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_in_express_list( const Linked_List list, const Type check ) { - if( TYPEis_entity( check ) ) { +duplicate_in_express_list(const Linked_List list, const Type check) +{ + if(TYPEis_entity(check)) { return FALSE; } /* entities are never the same */ - LISTdo( list, t, Type ) - if( t == check ) { + LISTdo(list, t, Type) + if(t == check) { ; /* don\'t compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -228,9 +236,10 @@ underlying Express type. RETURNS 1 if true, else 0. *******************/ int -unique_types( const Linked_List list ) { - LISTdo( list, t, Type ) - if( duplicate_in_express_list( list, t ) ) { +unique_types(const Linked_List list) +{ + LISTdo(list, t, Type) + if(duplicate_in_express_list(list, t)) { return FALSE; } LISTod; @@ -245,29 +254,30 @@ determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_utype_member( const Linked_List list, const Type check ) { +duplicate_utype_member(const Linked_List list, const Type check) +{ char b [BUFSIZ]; - if( TYPEis_entity( check ) ) { + if(TYPEis_entity(check)) { return FALSE; } /* entities are never the same */ - LISTdo( list, t, Type ) - if( t == check ) { + LISTdo(list, t, Type) + if(t == check) { ; } /* don\'t compare check to itself */ else { /* continue looking */ - strncpy( b, TYPEget_utype( t ), BUFSIZ ); - if( ( !strcmp( b, TYPEget_utype( check ) ) ) - || ( compareOrigTypes( t, check ) ) ) + strncpy(b, TYPEget_utype(t), BUFSIZ); + if((!strcmp(b, TYPEget_utype(check))) + || (compareOrigTypes(t, check))) /* if the underlying types are the same */ { return TRUE; } - if( ! strcmp( b, "SCLP23(Integer)" ) && - ( ! strcmp( TYPEget_utype( check ), "SCLP23(Real)" ) ) ) + if(! strcmp(b, "SCLP23(Integer)") && + (! strcmp(TYPEget_utype(check), "SCLP23(Real)"))) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -285,9 +295,10 @@ C++ representation for the underlying Express type. RETURNS 1 if true, else 0. *******************/ int -any_duplicates_in_select( const Linked_List list ) { - LISTdo( list, t, Type ) - if( duplicate_utype_member( list, t ) ) { +any_duplicates_in_select(const Linked_List list) +{ + LISTdo(list, t, Type) + if(duplicate_utype_member(list, t)) { return TRUE; } LISTod; @@ -303,24 +314,25 @@ returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. *******************/ int -find_duplicate_list( const Type type, Linked_List * duplicate_list ) { +find_duplicate_list(const Type type, Linked_List *duplicate_list) +{ Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { + if(any_duplicates_in_select(SEL_TYPEget_items(type))) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo( SEL_TYPEget_items( type ), u, Type ) - if( !utype_member( *duplicate_list, u, 1 ) ) { + LISTdo(SEL_TYPEget_items(type), u, Type) + if(!utype_member(*duplicate_list, u, 1)) { /** if not already a duplicate **/ - if( utype_member( temp, u, 1 ) ) { - LISTadd_first( *duplicate_list, u ); + if(utype_member(temp, u, 1)) { + LISTadd_first(*duplicate_list, u); } else { - LISTadd_first( temp, u ); + LISTadd_first(temp, u); } } LISTod; - LISTfree( temp ); + LISTfree(temp); return TRUE; } return FALSE; @@ -355,9 +367,10 @@ enum __types { the leaf nodes. */ void -non_unique_types_vector( const Type type, int * tvec ) { - LISTdo( SEL_TYPEget_items( type ), t, Type ) - switch( TYPEget_body( t )->type ) { +non_unique_types_vector(const Type type, int *tvec) +{ + LISTdo(SEL_TYPEget_items(type), t, Type) + switch(TYPEget_body(t)->type) { case integer_: tvec[tint]++; break; @@ -377,7 +390,7 @@ non_unique_types_vector( const Type type, int * tvec ) { break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector( t, tvec ); + non_unique_types_vector(t, tvec); break; case entity_: tvec[tentity]++; @@ -393,7 +406,7 @@ non_unique_types_vector( const Type type, int * tvec ) { tvec[tnumber]++; break; default: - fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); + fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); abort(); } LISTod; @@ -405,59 +418,60 @@ non_unique_types_vector( const Type type, int * tvec ) { types. If all types are unique, the string (0) is generated. */ char * -non_unique_types_string( const Type type ) { +non_unique_types_string(const Type type) +{ int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char * typestr; + char *typestr; int first = 1; int i; - non_unique_types_vector( type, tvec ); + non_unique_types_vector(type, tvec); /* build type string from vector */ - typestr = ( char * )malloc( BUFSIZ ); + typestr = (char *)malloc(BUFSIZ); typestr[0] = '\0'; - strcat( typestr, ( char * )"(" ); - for( i = 0; i <= tnumber; i++ ) { - if( tvec[i] < 2 ) { + strcat(typestr, (char *)"("); + for(i = 0; i <= tnumber; i++) { + if(tvec[i] < 2) { continue; /* skip, this one is unique */ } - if( !first ) { - strcat( typestr, ( char * )" | " ); + if(!first) { + strcat(typestr, (char *)" | "); } else { first = 0; } - switch( i ) { + switch(i) { case tint : - strcat( typestr, ( char * )"sdaiINTEGER" ); + strcat(typestr, (char *)"sdaiINTEGER"); break; case treal : - strcat( typestr, ( char * )"sdaiREAL" ); + strcat(typestr, (char *)"sdaiREAL"); break; case tstring: - strcat( typestr, ( char * )"sdaiSTRING" ); + strcat(typestr, (char *)"sdaiSTRING"); break; case tbinary: - strcat( typestr, ( char * )"sdaiBINARY" ); + strcat(typestr, (char *)"sdaiBINARY"); break; case tenum : - strcat( typestr, ( char * )"sdaiENUMERATION" ); + strcat(typestr, (char *)"sdaiENUMERATION"); break; case tentity: - strcat( typestr, ( char * )"sdaiINSTANCE" ); + strcat(typestr, (char *)"sdaiINSTANCE"); break; case taggr : - strcat( typestr, ( char * )"sdaiAGGR" ); + strcat(typestr, (char *)"sdaiAGGR"); break; case tnumber: - strcat( typestr, ( char * )"sdaiNUMBER" ); + strcat(typestr, (char *)"sdaiNUMBER"); break; } } - if( first ) { - strcat( typestr, ( char * )"0" ); + if(first) { + strcat(typestr, (char *)"0"); } - strcat( typestr, ( char * )")" ); + strcat(typestr, (char *)")"); return typestr; } @@ -474,18 +488,19 @@ non_unique_types_string( const Type type ) { ******************************************************************/ Variable -ATTR_LISTmember( Linked_List l, Variable check ) { +ATTR_LISTmember(Linked_List l, Variable check) +{ char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name( check, nm ); - LISTdo( l, a, Variable ) - generate_attribute_name( a, cur ); - if( ! strcmp( nm, cur ) ) { + generate_attribute_name(check, nm); + LISTdo(l, a, Variable) + generate_attribute_name(a, cur); + if(! strcmp(nm, cur)) { return check; } LISTod; - return ( 0 ); + return (0); } @@ -501,19 +516,20 @@ ATTR_LISTmember( Linked_List l, Variable check ) { ******************************************************************/ Linked_List -SEL_TYPEgetnew_attribute_list( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +SEL_TYPEgetnew_attribute_list(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo( complete, t, Type ) - if( TYPEis_entity( t ) ) { - cur = ENT_TYPEget_entity( t ); - attrs = ENTITYget_all_attributes( cur ); - LISTdo_n( attrs, a, Variable, b ) - if( ! ATTR_LISTmember( newlist, a ) ) { - LISTadd_first( newlist, a ); + LISTdo(complete, t, Type) + if(TYPEis_entity(t)) { + cur = ENT_TYPEget_entity(t); + attrs = ENTITYget_all_attributes(cur); + LISTdo_n(attrs, a, Variable, b) + if(! ATTR_LISTmember(newlist, a)) { + LISTadd_first(newlist, a); } LISTod; } @@ -523,44 +539,46 @@ SEL_TYPEgetnew_attribute_list( const Type type ) { Linked_List -ENTITYget_expanded_entities( Entity e, Linked_List l ) { +ENTITYget_expanded_entities(Entity e, Linked_List l) +{ Linked_List supers; Entity super; - if( ! LISTmember( l, e ) ) { - LISTadd_first( l, e ); + if(! LISTmember(l, e)) { + LISTadd_first(l, e); } - if( multiple_inheritance ) { + if(multiple_inheritance) { int super_cnt = 0; - supers = ENTITYget_supertypes( e ); - LISTdo( supers, s, Entity ) + supers = ENTITYget_supertypes(e); + LISTdo(supers, s, Entity) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if( super_cnt == 0 ) { - ENTITYget_expanded_entities( s, l ); + if(super_cnt == 0) { + ENTITYget_expanded_entities(s, l); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass( e ); - ENTITYget_expanded_entities( super, l ); + super = ENTITYget_superclass(e); + ENTITYget_expanded_entities(super, l); } return l; } Linked_List -SELget_entity_itemlist( const Type type ) { - Linked_List complete = SEL_TYPEget_items( type ); +SELget_entity_itemlist(const Type type) +{ + Linked_List complete = SEL_TYPEget_items(type); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo( complete, t, Type ) - if( TYPEis_entity( t ) ) { - cur = ENT_TYPEget_entity( t ); - ENTITYget_expanded_entities( cur, newlist ); + LISTdo(complete, t, Type) + if(TYPEis_entity(t)) { + cur = ENT_TYPEget_entity(t); + ENTITYget_expanded_entities(cur, newlist); } LISTod; return newlist; @@ -573,38 +591,39 @@ TYPEselect_lib_print prints the member functions (definitions) of a select class. *******************/ void -TYPEselect_lib_print( const Type type, FILE * f ) { +TYPEselect_lib_print(const Type type, FILE *f) +{ int nbr_select = 0; int num = 0; - fprintf( f, "# SELECT TYPE %s\n", TYPEget_name( type ) ); + fprintf(f, "# SELECT TYPE %s\n", TYPEget_name(type)); /* create the SELECT */ - if( is_python_keyword( TYPEget_name( type ) ) ) { - fprintf( f, "%s_ = SELECT(", TYPEget_name( type ) ); + if(is_python_keyword(TYPEget_name(type))) { + fprintf(f, "%s_ = SELECT(", TYPEget_name(type)); } else { - fprintf( f, "%s = SELECT(", TYPEget_name( type ) ); + fprintf(f, "%s = SELECT(", TYPEget_name(type)); } /* first compute the number of types (necessary to insert commas) */ nbr_select = 0; - LISTdo( SEL_TYPEget_items( type ), t, Type ) + LISTdo(SEL_TYPEget_items(type), t, Type) (void) t; /* unused */ nbr_select++; LISTod; /* then write types */ num = 0; - LISTdo( SEL_TYPEget_items( type ), t, Type ) - if( is_python_keyword( TYPEget_name( t ) ) ) { - fprintf( f, "\n\t'%s_'", TYPEget_name( t ) ); + LISTdo(SEL_TYPEget_items(type), t, Type) + if(is_python_keyword(TYPEget_name(t))) { + fprintf(f, "\n\t'%s_'", TYPEget_name(t)); } else { - fprintf( f, "\n\t'%s'", TYPEget_name( t ) ); + fprintf(f, "\n\t'%s'", TYPEget_name(t)); } - if( num < nbr_select - 1 ) { - fprintf( f, "," ); + if(num < nbr_select - 1) { + fprintf(f, ","); } num++; LISTod; - fprintf( f, ",\n\tscope = schema_scope)\n" ); + fprintf(f, ",\n\tscope = schema_scope)\n"); } #undef BASE_SELECT diff --git a/src/exppp/exppp-main.c b/src/exppp/exppp-main.c index 670dd7a88..7ca23c034 100644 --- a/src/exppp/exppp-main.c +++ b/src/exppp/exppp-main.c @@ -3,63 +3,66 @@ #include "../express/express.h" #include "exppp.h" -static void exppp_usage( void ) { +static void exppp_usage(void) +{ char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name ); - fprintf( stderr, "\t-v produces a version description\n" ); - fprintf( stderr, "\t-l specifies line length hint for output\n" ); - fprintf( stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n" ); - fprintf( stderr, "\t-c for constants, print one item per line (YMMV!)\n" ); - fprintf( stderr, "\t-o specifies the name of the output file (-- for stdout)\n" ); - fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); - fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); - fprintf( stderr, "\t-w warning enable\n" ); - fprintf( stderr, "\t-i warning ignore\n" ); - fprintf( stderr, "and is one of:\n" ); - fprintf( stderr, "\tnone\n\tall\n" ); - fprintf( stderr, "%s", warnings_help_msg); - fprintf( stderr, "and is one or more of:\n" ); - fprintf( stderr, " e entity\n" ); - fprintf( stderr, " p procedure\n" ); - fprintf( stderr, " r rule\n" ); - fprintf( stderr, " f function\n" ); - fprintf( stderr, " t type\n" ); - fprintf( stderr, " s schema or file\n" ); - fprintf( stderr, " # pass #\n" ); - fprintf( stderr, " E everything (all of the above)\n" ); - exit( 2 ); + fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name); + fprintf(stderr, "\t-v produces a version description\n"); + fprintf(stderr, "\t-l specifies line length hint for output\n"); + fprintf(stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n"); + fprintf(stderr, "\t-c for constants, print one item per line (YMMV!)\n"); + fprintf(stderr, "\t-o specifies the name of the output file (-- for stdout)\n"); + fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); + fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); + fprintf(stderr, "\t-w warning enable\n"); + fprintf(stderr, "\t-i warning ignore\n"); + fprintf(stderr, "and is one of:\n"); + fprintf(stderr, "\tnone\n\tall\n"); + fprintf(stderr, "%s", warnings_help_msg); + fprintf(stderr, "and is one or more of:\n"); + fprintf(stderr, " e entity\n"); + fprintf(stderr, " p procedure\n"); + fprintf(stderr, " r rule\n"); + fprintf(stderr, " f function\n"); + fprintf(stderr, " t type\n"); + fprintf(stderr, " s schema or file\n"); + fprintf(stderr, " # pass #\n"); + fprintf(stderr, " E everything (all of the above)\n"); + exit(2); } -int Handle_Exppp_Args( int i, char * arg ) { - if( tolower( ( char )i ) == 'o' ) { - if( !strcmp( "--", arg ) ) { +int Handle_Exppp_Args(int i, char *arg) +{ + if(tolower((char)i) == 'o') { + if(!strcmp("--", arg)) { exppp_print_to_stdout = true; return 0; } exppp_output_filename_reset = false; exppp_output_filename = arg; return 0; - } else if( tolower( ( char )i ) == 'l' ) { - if( ( strlen( arg ) > 5 ) || ( strlen( arg ) < 2 ) ) { - fprintf( stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg ); + } else if(tolower((char)i) == 'l') { + if((strlen(arg) > 5) || (strlen(arg) < 2)) { + fprintf(stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg); return 1; } - exppp_linelength = atoi( arg ); + exppp_linelength = atoi(arg); return 0; - } else if( tolower( ( char )i ) == 'c' ) { + } else if(tolower((char)i) == 'c') { exppp_aggressively_wrap_consts = true; return 0; - } else if( tolower( ( char )i ) == 't' ) { + } else if(tolower((char)i) == 't') { exppp_tail_comment = true; return 0; } return 1; } -void EXPRESSinit_init( void ) { +void EXPRESSinit_init(void) +{ exppp_alphabetize = true; EXPRESSbackend = EXPRESSout; ERRORusage_function = exppp_usage; - strcat( EXPRESSgetopt_options, "o:l:ct" ); + strcat(EXPRESSgetopt_options, "o:l:ct"); EXPRESSgetopt = Handle_Exppp_Args; } diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index e40ffaee9..0aba5bbfc 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -30,26 +30,26 @@ # error "PP_SMALL_BUF_SZ already defined" #endif -void ALGscope_out( Scope s, int level ); -void ENTITYattrs_out( Linked_List attributes, int derived, int level ); -void ENTITY_out( Entity e, int level ); -void ENTITYinverse_out( Linked_List attrs, int level ); -void ENTITYunique_out( Linked_List u, int level ); -void FUNC_out( Function fn, int level ); -void PROC_out( Procedure p, int level ); -void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); -void RULE_out( Rule r, int level ); -void SCOPEalgs_out( Scope s, int level ); -void SCOPEconsts_out( Scope s, int level ); -void SCOPEentities_out( Scope s, int level ); -void SCOPElocals_out( Scope s, int level ); -void SCOPEtypes_out( Scope s, int level ); -void STMT_out( Statement s, int level ); -void STMTlist_out( Linked_List stmts, int level ); -void TYPE_out( Type t, int level ); -void TYPE_head_out( Type t, int level ); -void TYPE_body_out( Type t, int level ); -void WHERE_out( Linked_List wheres, int level ); +void ALGscope_out(Scope s, int level); +void ENTITYattrs_out(Linked_List attributes, int derived, int level); +void ENTITY_out(Entity e, int level); +void ENTITYinverse_out(Linked_List attrs, int level); +void ENTITYunique_out(Linked_List u, int level); +void FUNC_out(Function fn, int level); +void PROC_out(Procedure p, int level); +void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); +void RULE_out(Rule r, int level); +void SCOPEalgs_out(Scope s, int level); +void SCOPEconsts_out(Scope s, int level); +void SCOPEentities_out(Scope s, int level); +void SCOPElocals_out(Scope s, int level); +void SCOPEtypes_out(Scope s, int level); +void STMT_out(Statement s, int level); +void STMTlist_out(Linked_List stmts, int level); +void TYPE_out(Type t, int level); +void TYPE_head_out(Type t, int level); +void TYPE_body_out(Type t, int level); +void WHERE_out(Linked_List wheres, int level); Error ERROR_select_empty; @@ -73,11 +73,11 @@ bool exppp_terse = false; bool exppp_reference_info = false; /* if true, add commentary about where things came from */ bool exppp_tail_comment = false; -FILE * exppp_fp = NULL; /* output file */ -char * exppp_buf = 0; /* output buffer */ +FILE *exppp_fp = NULL; /* output file */ +char *exppp_buf = 0; /* output buffer */ int exppp_maxbuflen = 0; /* size of expppbuf */ unsigned int exppp_buflen = 0; /* remaining space in expppbuf */ -char * exppp_bufp = 0; /* pointer to write position in expppbuf, +char *exppp_bufp = 0; /* pointer to write position in expppbuf, * should usually be pointing to a "\0" */ /** used to print a comment containing the name of a structure at the @@ -85,18 +85,20 @@ char * exppp_bufp = 0; /* pointer to write position in expppbuf, * * prints a newline regardless */ -void tail_comment( const char * name ) { - if( exppp_tail_comment ) { - raw( " -- %s", name ); +void tail_comment(const char *name) +{ + if(exppp_tail_comment) { + raw(" -- %s", name); } - raw( "\n" ); + raw("\n"); } /** count newlines in a string */ -int count_newlines( char * s ) { +int count_newlines(char *s) +{ int count = 0; - for( ; *s; s++ ) { - if( *s == '\n' ) { + for(; *s; s++) { + if(*s == '\n') { count++; } } @@ -106,46 +108,48 @@ int count_newlines( char * s ) { /** true if last char through exp_output was a space */ static bool printedSpaceLast = false; -void exp_output( char * buf, unsigned int len ) { - FILE * fp = ( exppp_fp ? exppp_fp : stdout ); +void exp_output(char *buf, unsigned int len) +{ + FILE *fp = (exppp_fp ? exppp_fp : stdout); - error_sym.line += count_newlines( buf ); - printedSpaceLast = ( *( buf + len - 1) == ' ' ); - if( exppp_buf ) { + error_sym.line += count_newlines(buf); + printedSpaceLast = (*(buf + len - 1) == ' '); + if(exppp_buf) { /* output to string */ - if( len > exppp_buflen ) { + if(len > exppp_buflen) { /* should provide flag to enable complaint */ /* for now, just ignore */ return; } - memcpy( exppp_bufp, buf, len + 1 ); + memcpy(exppp_bufp, buf, len + 1); exppp_bufp += len; exppp_buflen -= len; } else { /* output to file */ - size_t out = fwrite( buf, 1, len, fp ); - if( out != len ) { - const char * err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; - fprintf( stderr, err, __FILE__, __LINE__, len, out ); + size_t out = fwrite(buf, 1, len, fp); + if(out != len) { + const char *err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; + fprintf(stderr, err, __FILE__, __LINE__, len, out); abort(); } } } -void wrap( const char * fmt, ... ) { +void wrap(const char *fmt, ...) +{ char buf[10000]; - char * p, * start = buf; + char *p, * start = buf; int len; va_list args; - va_start( args, fmt ); - vsprintf( buf, fmt, args ); - va_end( args ); + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); - len = strlen( buf ); + len = strlen(buf); /* eliminate leading whitespace */ - while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ + while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { start++; len--; } @@ -157,26 +161,26 @@ void wrap( const char * fmt, ... ) { * 3rd condition: if exppp_linelength == indent2 and curpos > indent2, always newline * to use #3: temporarily change exppp_linelength; it doesn't make sense to change indent2 */ - if( ( ( ( curpos + len ) > exppp_linelength ) && ( ( indent2 + len ) < exppp_linelength ) ) - || ( ( exppp_linelength == indent2 ) && ( curpos > indent2 ) ) ) { + if((((curpos + len) > exppp_linelength) && ((indent2 + len) < exppp_linelength)) + || ((exppp_linelength == indent2) && (curpos > indent2))) { /* move to new continuation line */ char line[1000]; - sprintf( line, "\n%*s", indent2, "" ); - exp_output( line, 1 + indent2 ); + sprintf(line, "\n%*s", indent2, ""); + exp_output(line, 1 + indent2); curpos = indent2; /* reset current position */ } /* eliminate leading whitespace - again */ - while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ + while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { start++; len--; } - exp_output( start, len ); + exp_output(start, len); - if( len ) { + if(len) { /* reset cur position based on last newline seen */ - if( 0 == ( p = strrchr( start, '\n' ) ) ) { + if(0 == (p = strrchr(start, '\n'))) { curpos += len; } else { curpos = len + start - p; @@ -184,23 +188,24 @@ void wrap( const char * fmt, ... ) { } } -void raw( const char * fmt, ... ) { - char * p; +void raw(const char *fmt, ...) +{ + char *p; char buf[10000]; int len; va_list args; - va_start( args, fmt ); - vsprintf( buf, fmt, args ); - va_end( args ); + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); - len = strlen( buf ); + len = strlen(buf); - exp_output( buf, len ); + exp_output(buf, len); - if( len ) { + if(len) { /* reset cur position based on last newline seen */ - if( 0 == ( p = strrchr( buf, '\n' ) ) ) { + if(0 == (p = strrchr(buf, '\n'))) { curpos += len; } else { curpos = len + buf - p; @@ -208,19 +213,21 @@ void raw( const char * fmt, ... ) { } } -void exppp_init() { +void exppp_init() +{ static bool first_time = true; - if( !first_time ) { + if(!first_time) { return; } first_time = false; } -void exppp_ref_info( Symbol * s ) { - if( exppp_reference_info ) { - raw( "--info %s %s %d\n", s->name, s->filename, s->line ); +void exppp_ref_info(Symbol *s) +{ + if(exppp_reference_info) { + raw("--info %s %s %d\n", s->name, s->filename, s->line); } } @@ -230,19 +237,21 @@ void exppp_ref_info( Symbol * s ) { */ bool first_line = true; /* if first line */ -void first_newline() { - if( first_line ) { +void first_newline() +{ + if(first_line) { first_line = false; } else { - raw( "\n" ); + raw("\n"); } } -int minimum( int a, int b, int c ) { - if( a < b ) { - return ( ( a < c ) ? a : c ); +int minimum(int a, int b, int c) +{ + if(a < b) { + return ((a < c) ? a : c); } else { - return ( ( b < c ) ? b : c ); + return ((b < c) ? b : c); } } @@ -252,10 +261,11 @@ int minimum( int a, int b, int c ) { * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char * real2exp( double r ) { - #define PP_SMALL_BUF_SZ 80 +const char *real2exp(double r) +{ +#define PP_SMALL_BUF_SZ 80 static char result[PP_SMALL_BUF_SZ] = { 0 }; - char * pos = result, * lcNumeric = setlocale( LC_NUMERIC, NULL ); + char *pos = result, * lcNumeric = setlocale(LC_NUMERIC, NULL); /* the following ensures that PP_SMALL_BUF_SZ is at least * as big as the largest possible string: @@ -270,89 +280,92 @@ const char * real2exp( double r ) { * non-exotic platforms. */ unsigned int exponentDigits = 2, expMax = DBL_MAX_10_EXP; - while( expMax >= 10 ) { + while(expMax >= 10) { exponentDigits++; expMax /= 10; } - if( !( ( DBL_DIG + exponentDigits + 3 ) < PP_SMALL_BUF_SZ ) ) { - fprintf( stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__ ); + if(!((DBL_DIG + exponentDigits + 3) < PP_SMALL_BUF_SZ)) { + fprintf(stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__); abort(); } - if( strcmp( "C", lcNumeric ) ) { - fprintf( stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, - "(are you calling exppp from Qt?). Incorrect formatting is possible.\n" ); - setlocale( LC_NUMERIC, "C" ); + if(strcmp("C", lcNumeric)) { + fprintf(stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, + "(are you calling exppp from Qt?). Incorrect formatting is possible.\n"); + setlocale(LC_NUMERIC, "C"); } - snprintf( result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r ); + snprintf(result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r); /* eliminate trailing zeros in the mantissa */ - assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); - while( ( *pos != '.' ) && ( *pos != '\0' ) ) { + assert(strlen(result) < PP_SMALL_BUF_SZ - 1); + while((*pos != '.') && (*pos != '\0')) { /* search for '.' */ pos++; } - if( *pos != '\0' ) { - char * firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ + if(*pos != '\0') { + char *firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ pos++; - while( isdigit( *pos ) ) { - if( ( *pos == '0' ) && ( firstUnnecessaryDigit == NULL ) ) { + while(isdigit(*pos)) { + if((*pos == '0') && (firstUnnecessaryDigit == NULL)) { firstUnnecessaryDigit = pos; - } else if( *pos != '0' ) { + } else if(*pos != '0') { firstUnnecessaryDigit = NULL; } pos++; } - if( ( firstUnnecessaryDigit != NULL ) && ( firstUnnecessaryDigit < pos ) ) { - if( ( *( firstUnnecessaryDigit - 1 ) == '.' ) && ( *pos == '\0' ) ) { + if((firstUnnecessaryDigit != NULL) && (firstUnnecessaryDigit < pos)) { + if((*(firstUnnecessaryDigit - 1) == '.') && (*pos == '\0')) { /* no exponent, nothing after decimal point - remove decimal point */ - *( firstUnnecessaryDigit - 1 ) = '\0'; + *(firstUnnecessaryDigit - 1) = '\0'; } else { /* copy exponent (or \0) immediately after the decimal point */ - memmove( firstUnnecessaryDigit, pos, strlen( pos ) + 1 ); + memmove(firstUnnecessaryDigit, pos, strlen(pos) + 1); } } } - assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); + assert(strlen(result) < PP_SMALL_BUF_SZ - 1); return result; - #undef PP_SMALL_BUF_SZ +#undef PP_SMALL_BUF_SZ } /** Find next '.' in null-terminated string, return number of chars * If no '.' found, returns length of string */ -int nextBreakpoint( const char * pos, const char * end ) { +int nextBreakpoint(const char *pos, const char *end) +{ int i = 0; - while( ( *pos != '.' ) && ( *pos != '\0' ) && ( pos < end ) ) { + while((*pos != '.') && (*pos != '\0') && (pos < end)) { i++; pos++; } - if( *pos == '.' ) { + if(*pos == '.') { i++; } return i; } /** true if it makes sense to break before printing next part of the string */ -bool shouldBreak( int len ) { - if( ( curpos > indent2 ) && - ( ( curpos + len ) > exppp_linelength ) ) { +bool shouldBreak(int len) +{ + if((curpos > indent2) && + ((curpos + len) > exppp_linelength)) { return true; } return false; } /** Insert newline if it makes sense. */ -void maybeBreak( int len, bool first ) { - if( shouldBreak( len ) ) { - if( first ) { - raw( "\n%*s'", indent2, "" ); +void maybeBreak(int len, bool first) +{ + if(shouldBreak(len)) { + if(first) { + raw("\n%*s'", indent2, ""); } else { - raw( "'\n%*s+ '", indent2, "" ); + raw("'\n%*s+ '", indent2, ""); } - } else if( first ) { + } else if(first) { /* staying on same line */ - raw( "%s", ( printedSpaceLast ? "'": " '" ) ); + raw("%s", (printedSpaceLast ? "'" : " '")); } } @@ -363,28 +376,29 @@ void maybeBreak( int len, bool first ) { * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr( const char * in ) { - const char * iptr = in, * end; - unsigned int inlen = strlen( in ); +void breakLongStr(const char *in) +{ + const char *iptr = in, * end; + unsigned int inlen = strlen(in); bool first = true; /* used to ensure that we don't overrun the input buffer */ end = in + inlen; - if( ( inlen == 0 ) || ( ( ( int ) inlen + curpos ) < exppp_linelength ) ) { + if((inlen == 0) || (((int) inlen + curpos) < exppp_linelength)) { /* short enough to fit on current line */ - raw( "%s'%s'", ( printedSpaceLast ? "": " " ), in ); + raw("%s'%s'", (printedSpaceLast ? "" : " "), in); return; } /* insert newlines at dots as necessary */ - while( ( iptr < end ) && ( *iptr ) ) { - int i = nextBreakpoint( iptr, end ); - maybeBreak( i, first ); + while((iptr < end) && (*iptr)) { + int i = nextBreakpoint(iptr, end); + maybeBreak(i, first); first = false; - raw( "%.*s", i, iptr ); + raw("%.*s", i, iptr); iptr += i; } - raw( "' "); + raw("' "); } /* Interfacing Definitions */ @@ -396,10 +410,11 @@ static bool string_func_in_use = false; static bool file_func_in_use = false; /** return 0 if successful */ -int prep_buffer( char * buf, int len ) { +int prep_buffer(char *buf, int len) +{ /* this should never happen */ - if( string_func_in_use ) { - fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); + if(string_func_in_use) { + fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); return 1; } string_func_in_use = true; @@ -418,7 +433,8 @@ int prep_buffer( char * buf, int len ) { } /** \return length of string */ -int finish_buffer() { +int finish_buffer() +{ exppp_buf = 0; curpos = old_curpos; error_sym.line = old_lineno; @@ -427,17 +443,18 @@ int finish_buffer() { } /** \return 0 if successful */ -int prep_string() { +int prep_string() +{ /* this should never happen */ - if( string_func_in_use ) { - fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); + if(string_func_in_use) { + fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); return 1; } string_func_in_use = true; - exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ ); - if( !exppp_buf ) { - fprintf( stderr, "failed to allocate exppp buffer\n" ); + exppp_buf = exppp_bufp = (char *)sc_malloc(BIGBUFSIZ); + if(!exppp_buf) { + fprintf(stderr, "failed to allocate exppp buffer\n"); return 1; } exppp_buflen = exppp_maxbuflen = BIGBUFSIZ; @@ -452,11 +469,12 @@ int prep_string() { return 0; } -char * finish_string() { - char * b = ( char * )sc_realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); +char *finish_string() +{ + char *b = (char *)sc_realloc(exppp_buf, 1 + exppp_maxbuflen - exppp_buflen); - if( b == 0 ) { - fprintf( stderr, "failed to reallocate exppp buffer\n" ); + if(b == 0) { + fprintf(stderr, "failed to reallocate exppp buffer\n"); return 0; } exppp_buf = 0; @@ -467,13 +485,14 @@ char * finish_string() { return b; } -static FILE * oldfp; +static FILE *oldfp; -void prep_file() { +void prep_file() +{ /* this can only happen if user calls output func while suspended */ /* inside another output func both called from debugger */ - if( file_func_in_use ) { - fprintf( stderr, "cannot print EXPRESS representations recursively!\n" ); + if(file_func_in_use) { + fprintf(stderr, "cannot print EXPRESS representations recursively!\n"); } file_func_in_use = true; @@ -484,12 +503,13 @@ void prep_file() { curpos = 1; } -void finish_file() { +void finish_file() +{ exppp_fp = oldfp; /* reset back to original file */ file_func_in_use = false; } -char * placeholder = "placeholder"; +char *placeholder = "placeholder"; diff --git a/src/exppp/pp.h b/src/exppp/pp.h index 89825de6a..e2bfad19b 100644 --- a/src/exppp/pp.h +++ b/src/exppp/pp.h @@ -13,19 +13,19 @@ extern const int NOLEVEL; /**< unused-level indicator */ extern Symbol error_sym; /**< only used when printing errors */ extern Error ERROR_select_empty; -extern FILE * exppp_fp; +extern FILE *exppp_fp; extern bool first_line; /** output a string, exactly as provided * \sa wrap() */ -void raw( const char * fmt, ... ); +void raw(const char *fmt, ...); /** output a string, insert newlines to keep line length down * TODO list globals this func uses * \sa raw() */ -void wrap( const char * fmt, ... ); +void wrap(const char *fmt, ...); /** convert a real into our preferred form compatible with 10303-11 * (i.e. decimal point is required; no trailing zeros) @@ -33,7 +33,7 @@ void wrap( const char * fmt, ... ); * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char * real2exp( double r ); +const char *real2exp(double r); /** Break a long un-encoded string up, enclose in '', output via raw() * if short, don't insert line breaks @@ -42,21 +42,21 @@ const char * real2exp( double r ); * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr( const char * in ); +void breakLongStr(const char *in); int finish_buffer(); -int minimum( int a, int b, int c ); -int prep_buffer( char * buf, int len ); +int minimum(int a, int b, int c); +int prep_buffer(char *buf, int len); int prep_string(); void finish_file(); void first_newline(); void prep_file(); -char * finish_string(); -const char * real2exp( double r ); -void exp_output( char * buf, unsigned int len ); +char *finish_string(); +const char *real2exp(double r); +void exp_output(char *buf, unsigned int len); void exppp_init(); -void exppp_ref_info( Symbol * s ); -extern char * placeholder; +void exppp_ref_info(Symbol *s); +extern char *placeholder; #endif /* PP_H */ diff --git a/src/exppp/pretty_alg.c b/src/exppp/pretty_alg.c index ba8a07aa5..3899b8492 100644 --- a/src/exppp/pretty_alg.c +++ b/src/exppp/pretty_alg.c @@ -13,17 +13,19 @@ #include "pretty_scope.h" #include "pretty_alg.h" -void ALGscope_out( Scope s, int level ) { - SCOPEtypes_out( s, level ); - SCOPEentities_out( s, level ); - SCOPEalgs_out( s, level ); - - SCOPEconsts_out( s, level ); - SCOPElocals_out( s, level ); +void ALGscope_out(Scope s, int level) +{ + SCOPEtypes_out(s, level); + SCOPEentities_out(s, level); + SCOPEalgs_out(s, level); + + SCOPEconsts_out(s, level); + SCOPElocals_out(s, level); } /** last arg is not terminated with ; or \n */ -void ALGargs_out( Linked_List args, int level ) { +void ALGargs_out(Linked_List args, int level) +{ Type previoustype = 0; bool previousVAR = false; indent2 = level + exppp_continuation_indent; @@ -35,26 +37,27 @@ void ALGargs_out( Linked_List args, int level ) { * flags.var is set in the formal_parameter production */ - LISTdo( args, v, Variable ) { - if( ( previoustype != v->type ) || ( previousVAR != v->flags.var ) ) { - if( previoustype ) { - wrap( " : " ); - TYPE_head_out( previoustype, NOLEVEL ); - raw( ";\n" ); + LISTdo(args, v, Variable) { + if((previoustype != v->type) || (previousVAR != v->flags.var)) { + if(previoustype) { + wrap(" : "); + TYPE_head_out(previoustype, NOLEVEL); + raw(";\n"); } - raw( "%*s", level, "" ); - if( v->flags.var ) { - raw( "VAR " ); + raw("%*s", level, ""); + if(v->flags.var) { + raw("VAR "); } - EXPR_out( VARget_name( v ), 0 ); + EXPR_out(VARget_name(v), 0); } else { - raw( ", " ); - EXPR_out( VARget_name( v ), 0 ); + raw(", "); + EXPR_out(VARget_name(v), 0); } previoustype = v->type; previousVAR = v->flags.var; - } LISTod + } + LISTod - wrap( " : " ); - TYPE_head_out( previoustype, NOLEVEL ); + wrap(" : "); + TYPE_head_out(previoustype, NOLEVEL); } diff --git a/src/exppp/pretty_alg.h b/src/exppp/pretty_alg.h index a365da9fc..ab0c5f566 100644 --- a/src/exppp/pretty_alg.h +++ b/src/exppp/pretty_alg.h @@ -4,7 +4,7 @@ #include #include -void ALGargs_out( Linked_List args, int level ); -void ALGscope_out( Scope s, int level ); +void ALGargs_out(Linked_List args, int level); +void ALGscope_out(Scope s, int level); #endif /* PRETTY_ALG_H */ diff --git a/src/exppp/pretty_case.c b/src/exppp/pretty_case.c index 82a9f2772..086ab53a9 100644 --- a/src/exppp/pretty_case.c +++ b/src/exppp/pretty_case.c @@ -10,61 +10,66 @@ #include "pretty_stmt.h" #include "pretty_case.h" -void CASEout( struct Case_Statement_ * c, int level ) { +void CASEout(struct Case_Statement_ * c, int level) +{ int len = 0, max_indent = 0, old_curpos = 0; - raw( "%*sCASE ", level, "" ); - EXPR_out( c->selector, 0 ); - wrap( " OF\n" ); + raw("%*sCASE ", level, ""); + EXPR_out(c->selector, 0); + wrap(" OF\n"); /* EXPRlength messes up curpos */ old_curpos = curpos; /* pass 1: calculate length of longest label */ - LISTdo( c->cases, ci, Case_Item ) { - if( ci->labels ) { - LISTdo_n( ci->labels, label, Expression, b ) { - len = EXPRlength( label ); - } LISTod + LISTdo(c->cases, ci, Case_Item) { + if(ci->labels) { + LISTdo_n(ci->labels, label, Expression, b) { + len = EXPRlength(label); + } + LISTod } else { - len = strlen( "OTHERWISE" ); + len = strlen("OTHERWISE"); } - if( len > max_indent ) { + if(len > max_indent) { max_indent = len; } - } LISTod + } + LISTod curpos = old_curpos; level += exppp_nesting_indent; - if( max_indent + level > exppp_linelength / 2 ) { - max_indent = ( exppp_linelength / 3 ) - level; + if(max_indent + level > exppp_linelength / 2) { + max_indent = (exppp_linelength / 3) - level; } /* pass 2: print them */ - LISTdo( c->cases, ci, Case_Item ) { - if( ci->labels ) { - LISTdo_n( ci->labels, label, Expression, b ) { + LISTdo(c->cases, ci, Case_Item) { + if(ci->labels) { + LISTdo_n(ci->labels, label, Expression, b) { int spaces; /* print label(s) */ indent2 = level + exppp_continuation_indent; - raw( "%*s", level, "" ); - EXPR_out( label, 0 ); + raw("%*s", level, ""); + EXPR_out(label, 0); spaces = level + max_indent - curpos; - raw( "%*s : ", ( ( spaces > 0 ) ? spaces : 0 ), "" ); + raw("%*s : ", ((spaces > 0) ? spaces : 0), ""); /* print action */ - STMT_out( ci->action, level + exppp_nesting_indent ); - } LISTod + STMT_out(ci->action, level + exppp_nesting_indent); + } + LISTod } else { /* print OTHERWISE */ indent2 = level + exppp_continuation_indent; - raw( "%*s", level, "" ); - raw( "OTHERWISE" ); - raw( "%*s : ", level + max_indent - curpos, "" ); + raw("%*s", level, ""); + raw("OTHERWISE"); + raw("%*s : ", level + max_indent - curpos, ""); /* print action */ - STMT_out( ci->action, level + exppp_nesting_indent ); + STMT_out(ci->action, level + exppp_nesting_indent); } - } LISTod + } + LISTod - raw( "%*sEND_CASE;\n", level, "" ); + raw("%*sEND_CASE;\n", level, ""); } diff --git a/src/exppp/pretty_case.h b/src/exppp/pretty_case.h index de46f417f..1028e0bf5 100644 --- a/src/exppp/pretty_case.h +++ b/src/exppp/pretty_case.h @@ -3,6 +3,6 @@ #include -void CASEout( struct Case_Statement_ * c, int level ); +void CASEout(struct Case_Statement_ * c, int level); #endif /* PRETTY_CASE_H */ diff --git a/src/exppp/pretty_entity.c b/src/exppp/pretty_entity.c index 73d167bba..248294bab 100644 --- a/src/exppp/pretty_entity.c +++ b/src/exppp/pretty_entity.c @@ -14,244 +14,258 @@ #include "pretty_type.h" #include "pretty_entity.h" -void ENTITY_out( Entity e, int level ) { +void ENTITY_out(Entity e, int level) +{ const unsigned int EXPLICIT = 0, DERIVED = 1; int linelen = exppp_linelength; bool first_time = true; first_newline(); - exppp_ref_info( &e->symbol ); + exppp_ref_info(&e->symbol); - raw( "%*sENTITY %s", level, "", e->symbol.name ); + raw("%*sENTITY %s", level, "", e->symbol.name); level += exppp_nesting_indent; indent2 = level + exppp_continuation_indent; exppp_linelength = indent2; /* force newlines */ - if( ENTITYget_abstract( e ) ) { - if( e->u.entity->subtype_expression ) { - raw( "\n%*sABSTRACT SUPERTYPE OF ", level, "" ); - SUBTYPEout( e->u.entity->subtype_expression ); + if(ENTITYget_abstract(e)) { + if(e->u.entity->subtype_expression) { + raw("\n%*sABSTRACT SUPERTYPE OF ", level, ""); + SUBTYPEout(e->u.entity->subtype_expression); } else { - raw( "\n%*sABSTRACT SUPERTYPE", level, "" ); + raw("\n%*sABSTRACT SUPERTYPE", level, ""); } } else { - if( e->u.entity->subtype_expression ) { - raw( "\n%*sSUPERTYPE OF ", level, "" ); - SUBTYPEout( e->u.entity->subtype_expression ); + if(e->u.entity->subtype_expression) { + raw("\n%*sSUPERTYPE OF ", level, ""); + SUBTYPEout(e->u.entity->subtype_expression); } } exppp_linelength = linelen; - if( e->u.entity->supertype_symbols ) { - raw( "\n%*sSUBTYPE OF ( ", level, "" ); + if(e->u.entity->supertype_symbols) { + raw("\n%*sSUBTYPE OF ( ", level, ""); - LISTdo( e->u.entity->supertype_symbols, s, Symbol * ) - if( first_time ) { + LISTdo(e->u.entity->supertype_symbols, s, Symbol *) + if(first_time) { first_time = false; } else { - raw( ", " ); + raw(", "); } - wrap( s->name ); + wrap(s->name); LISTod - raw( " )" ); + raw(" )"); } - raw( ";\n" ); + raw(";\n"); #if 0 /* add a little more space before entities if sub or super appears */ - if( e->u.entity->supertype_symbols || e->u.entity->subtype_expression ) { - raw( "\n" ); + if(e->u.entity->supertype_symbols || e->u.entity->subtype_expression) { + raw("\n"); } #endif - ENTITYattrs_out( e->u.entity->attributes, EXPLICIT, level ); - ENTITYattrs_out( e->u.entity->attributes, DERIVED, level ); - ENTITYinverse_out( e->u.entity->attributes, level ); - ENTITYunique_out( e->u.entity->unique, level ); - WHERE_out( TYPEget_where( e ), level ); + ENTITYattrs_out(e->u.entity->attributes, EXPLICIT, level); + ENTITYattrs_out(e->u.entity->attributes, DERIVED, level); + ENTITYinverse_out(e->u.entity->attributes, level); + ENTITYunique_out(e->u.entity->unique, level); + WHERE_out(TYPEget_where(e), level); level -= exppp_nesting_indent; - raw( "%*sEND_ENTITY;", level, "" ); - tail_comment( e->symbol.name ); + raw("%*sEND_ENTITY;", level, ""); + tail_comment(e->symbol.name); } -void ENTITYunique_out( Linked_List u, int level ) { +void ENTITYunique_out(Linked_List u, int level) +{ int i; int max_indent; - Symbol * sym; + Symbol *sym; - if( !u ) { + if(!u) { return; } - raw( "%*sUNIQUE\n", level, "" ); + raw("%*sUNIQUE\n", level, ""); /* pass 1 */ max_indent = 0; - LISTdo( u, list, Linked_List ) { - if( 0 != ( sym = ( Symbol * )LISTget_first( list ) ) ) { + LISTdo(u, list, Linked_List) { + if(0 != (sym = (Symbol *)LISTget_first(list))) { int length; - length = strlen( sym->name ); - if( length > max_indent ) { + length = strlen(sym->name); + if(length > max_indent) { max_indent = length; } } - } LISTod + } + LISTod level += exppp_nesting_indent; - indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; + indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; - LISTdo( u, list, Linked_List ) { + LISTdo(u, list, Linked_List) { i = 0; - LISTdo_n( list, e, Expression, b ) { + LISTdo_n(list, e, Expression, b) { i++; - if( i == 1 ) { + if(i == 1) { /* print label if present */ - if( e ) { - raw( "%*s%-*s : ", level, "", max_indent, ( ( Symbol * )e )->name ); + if(e) { + raw("%*s%-*s : ", level, "", max_indent, ((Symbol *)e)->name); } else { - raw( "%*s%-*s ", level, "", max_indent, "" ); + raw("%*s%-*s ", level, "", max_indent, ""); } } else { - if( i > 2 ) { - raw( ", " ); + if(i > 2) { + raw(", "); } - EXPR_out( e, 0 ); + EXPR_out(e, 0); } - } LISTod - raw( ";\n" ); - } LISTod + } + LISTod + raw(";\n"); + } + LISTod } -void ENTITYinverse_out( Linked_List attrs, int level ) { +void ENTITYinverse_out(Linked_List attrs, int level) +{ int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo( attrs, v, Variable ) { - if( v->inverse_symbol ) { + LISTdo(attrs, v, Variable) { + if(v->inverse_symbol) { int length; - length = strlen( v->name->symbol.name ); - if( length > max_indent ) { + length = strlen(v->name->symbol.name); + if(length > max_indent) { max_indent = length; } } - } LISTod + } + LISTod - if( max_indent == 0 ) { + if(max_indent == 0) { return; } - raw( "%*sINVERSE\n", level, "" ); + raw("%*sINVERSE\n", level, ""); level += exppp_nesting_indent; - indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; + indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; /* pass 2: print them */ - LISTdo( attrs, v, Variable ) { - if( v->inverse_symbol ) { + LISTdo(attrs, v, Variable) { + if(v->inverse_symbol) { /* print attribute name */ - raw( "%*s", level, "" ); - EXPR_out( v->name, 0 ); - raw( "%-*s :", ( ( ( max_indent - curpos ) > 0 ) ? max_indent - curpos : 0 ), "" ); + raw("%*s", level, ""); + EXPR_out(v->name, 0); + raw("%-*s :", (((max_indent - curpos) > 0) ? max_indent - curpos : 0), ""); /* print attribute type */ - if( VARget_optional( v ) ) { - wrap( " OPTIONAL" ); + if(VARget_optional(v)) { + wrap(" OPTIONAL"); } - TYPE_head_out( v->type, NOLEVEL ); + TYPE_head_out(v->type, NOLEVEL); - raw( " FOR " ); + raw(" FOR "); - wrap( v->inverse_attribute->name->symbol.name ); + wrap(v->inverse_attribute->name->symbol.name); - raw( ";\n" ); + raw(";\n"); } - } LISTod + } + LISTod } -void ENTITYattrs_out( Linked_List attrs, int derived, int level ) { +void ENTITYattrs_out(Linked_List attrs, int derived, int level) +{ int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo( attrs, v, Variable ) { - if( v->inverse_symbol ) { + LISTdo(attrs, v, Variable) { + if(v->inverse_symbol) { continue; } - if( ( derived && v->initializer ) || - ( !derived && !v->initializer ) ) { + if((derived && v->initializer) || + (!derived && !v->initializer)) { int length; - length = EXPRlength( v->name ); - if( length > max_indent ) { + length = EXPRlength(v->name); + if(length > max_indent) { max_indent = length; } } - } LISTod + } + LISTod - if( max_indent == 0 ) { + if(max_indent == 0) { return; } - if( derived ) { - raw( "%*sDERIVE\n", level, "" ); + if(derived) { + raw("%*sDERIVE\n", level, ""); } level += exppp_nesting_indent; - if( level + max_indent > exppp_linelength / 3 ) { - max_indent = ( exppp_linelength / 3 ) - level; + if(level + max_indent > exppp_linelength / 3) { + max_indent = (exppp_linelength / 3) - level; } - indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; + indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; /* pass 2: print them */ - LISTdo( attrs, v, Variable ) { - if( v->inverse_symbol ) { + LISTdo(attrs, v, Variable) { + if(v->inverse_symbol) { continue; } - if( ( derived && v->initializer ) || ( !derived && !v->initializer ) ) { + if((derived && v->initializer) || (!derived && !v->initializer)) { int spaces; /* print attribute name */ - raw( "%*s", level, "" ); - EXPR_out( v->name, 0 ); + raw("%*s", level, ""); + EXPR_out(v->name, 0); spaces = level + max_indent + 2 - curpos; - if( spaces < 0 ) { + if(spaces < 0) { spaces = 0; } - raw( "%*s :", spaces, "" ); + raw("%*s :", spaces, ""); /* print attribute type */ - if( VARget_optional( v ) ) { - wrap( " OPTIONAL" ); + if(VARget_optional(v)) { + wrap(" OPTIONAL"); } - TYPE_head_out( v->type, NOLEVEL ); + TYPE_head_out(v->type, NOLEVEL); - if( derived && v->initializer ) { - wrap( " := " ); - EXPR_out( v->initializer, 0 ); + if(derived && v->initializer) { + wrap(" := "); + EXPR_out(v->initializer, 0); } - raw( ";\n" ); + raw(";\n"); } - } LISTod + } + LISTod } -char * ENTITYto_string( Entity e ) { - if( prep_string() ) { +char *ENTITYto_string(Entity e) +{ + if(prep_string()) { return placeholder; } - ENTITY_out( e, 0 ); - return ( finish_string() ); + ENTITY_out(e, 0); + return (finish_string()); } /** return length of buffer used */ -int ENTITYto_buffer( Entity e, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int ENTITYto_buffer(Entity e, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - ENTITY_out( e, 0 ); - return( finish_buffer() ); + ENTITY_out(e, 0); + return(finish_buffer()); } -void ENTITYout( Entity e ) { +void ENTITYout(Entity e) +{ prep_file(); - ENTITY_out( e, 0 ); + ENTITY_out(e, 0); finish_file(); } diff --git a/src/exppp/pretty_entity.h b/src/exppp/pretty_entity.h index 7c54ae446..9b21e27c3 100644 --- a/src/exppp/pretty_entity.h +++ b/src/exppp/pretty_entity.h @@ -7,13 +7,13 @@ #include "pp.h" -char * ENTITYto_string( Entity e ); -void ENTITY_out( Entity e, int level ); -void ENTITYattrs_out( Linked_List attrs, int derived, int level ); -void ENTITYinverse_out( Linked_List attrs, int level ); -void ENTITYout( Entity e ); -int ENTITYto_buffer( Entity e, char * buffer, int length ); -void ENTITYunique_out( Linked_List u, int level ); +char *ENTITYto_string(Entity e); +void ENTITY_out(Entity e, int level); +void ENTITYattrs_out(Linked_List attrs, int derived, int level); +void ENTITYinverse_out(Linked_List attrs, int level); +void ENTITYout(Entity e); +int ENTITYto_buffer(Entity e, char *buffer, int length); +void ENTITYunique_out(Linked_List u, int level); #endif /* PRETTY_ENTITY_H */ diff --git a/src/exppp/pretty_expr.c b/src/exppp/pretty_expr.c index 60a1c2ded..2fb2f023a 100644 --- a/src/exppp/pretty_expr.c +++ b/src/exppp/pretty_expr.c @@ -14,16 +14,17 @@ /** print array bounds */ -void EXPRbounds_out( TypeBody tb ) { - if( !tb->upper ) { +void EXPRbounds_out(TypeBody tb) +{ + if(!tb->upper) { return; } - wrap( " [" ); - EXPR_out( tb->lower, 0 ); - wrap( " : " ); - EXPR_out( tb->upper, 0 ); - raw( "]" ); + wrap(" ["); + EXPR_out(tb->lower, 0); + wrap(" : "); + EXPR_out(tb->upper, 0); + raw("]"); } /** @@ -32,135 +33,138 @@ void EXPRbounds_out( TypeBody tb ) { * precedence/associativity is not a problem) parens may be omitted. * if paren == 0, then parens may be omitted without consequence */ -void EXPR__out( Expression e, int paren, unsigned int previous_op ) { +void EXPR__out(Expression e, int paren, unsigned int previous_op) +{ int i; /* trusty temporary */ - switch( TYPEis( e->type ) ) { + switch(TYPEis(e->type)) { case integer_: - if( e == LITERAL_INFINITY ) { - wrap( "?" ); + if(e == LITERAL_INFINITY) { + wrap("?"); } else { - wrap( "%d", e->u.integer ); + wrap("%d", e->u.integer); } break; case real_: - if( e == LITERAL_PI ) { - wrap( "PI" ); - } else if( e == LITERAL_E ) { - wrap( "E" ); + if(e == LITERAL_PI) { + wrap("PI"); + } else if(e == LITERAL_E) { + wrap("E"); } else { - wrap( real2exp( e->u.real ) ); + wrap(real2exp(e->u.real)); } break; case binary_: - wrap( "%%%s", e->u.binary ); /* put "%" back */ + wrap("%%%s", e->u.binary); /* put "%" back */ break; case logical_: case boolean_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - wrap( "TRUE" ); + wrap("TRUE"); break; case Lfalse: - wrap( "FALSE" ); + wrap("FALSE"); break; default: - wrap( "UNKNOWN" ); + wrap("UNKNOWN"); break; } break; case string_: - if( TYPEis_encoded( e->type ) ) { - wrap( "\"%s\"", e->symbol.name ); + if(TYPEis_encoded(e->type)) { + wrap("\"%s\"", e->symbol.name); } else { - breakLongStr( e->symbol.name ); + breakLongStr(e->symbol.name); } break; case entity_: case identifier_: case attribute_: case enumeration_: - wrap( "%s", e->symbol.name ); + wrap("%s", e->symbol.name); break; case query_: - wrap( "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); - EXPR_out( e->u.query->aggregate, 1 ); - wrap( " | " ); - EXPR_out( e->u.query->expression, 1 ); - raw( " )" ); + wrap("QUERY ( %s <* ", e->u.query->local->name->symbol.name); + EXPR_out(e->u.query->aggregate, 1); + wrap(" | "); + EXPR_out(e->u.query->expression, 1); + raw(" )"); break; case self_: - wrap( "SELF" ); + wrap("SELF"); break; case funcall_: - wrap( "%s( ", e->symbol.name ); + wrap("%s( ", e->symbol.name); i = 0; - LISTdo( e->u.funcall.list, arg, Expression ) + LISTdo(e->u.funcall.list, arg, Expression) i++; - if( i != 1 ) { - raw( ", " ); + if(i != 1) { + raw(", "); } - EXPR_out( arg, 0 ); + EXPR_out(arg, 0); LISTod - raw( " )" ); + raw(" )"); break; case op_: - EXPRop__out( &e->e, paren, previous_op ); + EXPRop__out(&e->e, paren, previous_op); break; case aggregate_: - wrap( "[" ); + wrap("["); i = 0; - LISTdo( e->u.list, arg, Expression ) { + LISTdo(e->u.list, arg, Expression) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if( i != 1 ) { - if( repeat ) { - raw( " : " ); + if(i != 1) { + if(repeat) { + raw(" : "); } else { - raw( ", " ); + raw(", "); } } - EXPR_out( arg, 0 ); - } LISTod - raw( "]" ); + EXPR_out(arg, 0); + } + LISTod + raw("]"); break; case oneof_: { int old_indent = indent2; - wrap( "ONEOF ( " ); + wrap("ONEOF ( "); - if( exppp_linelength == indent2 ) { + if(exppp_linelength == indent2) { exppp_linelength += exppp_continuation_indent; } indent2 += exppp_continuation_indent; i = 0; - LISTdo( e->u.list, arg, Expression ) + LISTdo(e->u.list, arg, Expression) i++; - if( i != 1 ) { - raw( ", " ); + if(i != 1) { + raw(", "); } - EXPR_out( arg, 1 ); + EXPR_out(arg, 1); LISTod - if( exppp_linelength == indent2 ) { + if(exppp_linelength == indent2) { exppp_linelength = old_indent; } indent2 = old_indent; - raw( " )" ); + raw(" )"); break; } default: - fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); + fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); abort(); } } /** print expression that has op and operands */ -void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ) { +void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op) +{ const unsigned int PAD = 1, NOPAD = 0; - switch( oe->op_code ) { + switch(oe->op_code) { case OP_AND: case OP_ANDOR: case OP_OR: @@ -169,7 +173,7 @@ void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous case OP_PLUS: case OP_TIMES: case OP_XOR: - EXPRop2__out( oe, ( char * )0, paren, PAD, previous_op ); + EXPRop2__out(oe, (char *)0, paren, PAD, previous_op); break; case OP_EXP: case OP_GREATER_EQUAL: @@ -182,88 +186,91 @@ void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous case OP_LIKE: case OP_MOD: case OP_NOT_EQUAL: - EXPRop2_out( oe, ( char * )0, paren, PAD ); + EXPRop2_out(oe, (char *)0, paren, PAD); break; case OP_NOT: - EXPRop1_out( oe, "NOT ", paren ); + EXPRop1_out(oe, "NOT ", paren); break; case OP_REAL_DIV: - EXPRop2_out( oe, "/", paren, PAD ); + EXPRop2_out(oe, "/", paren, PAD); break; case OP_DIV: - EXPRop2_out( oe, "DIV", paren, PAD ); + EXPRop2_out(oe, "DIV", paren, PAD); break; case OP_MINUS: - EXPRop2_out( oe, "-", paren, PAD ); + EXPRop2_out(oe, "-", paren, PAD); break; case OP_DOT: - EXPRop2_out( oe, ".", paren, NOPAD ); + EXPRop2_out(oe, ".", paren, NOPAD); break; case OP_GROUP: - EXPRop2_out( oe, "\\", paren, NOPAD ); + EXPRop2_out(oe, "\\", paren, NOPAD); break; case OP_NEGATE: - EXPRop1_out( oe, "-", paren ); + EXPRop1_out(oe, "-", paren); break; case OP_ARRAY_ELEMENT: - EXPR_out( oe->op1, 1 ); - wrap( "[" ); - EXPR_out( oe->op2, 0 ); - raw( "]" ); + EXPR_out(oe->op1, 1); + wrap("["); + EXPR_out(oe->op2, 0); + raw("]"); break; case OP_SUBCOMPONENT: - EXPR_out( oe->op1, 1 ); - wrap( "[" ); - EXPR_out( oe->op2, 0 ); - wrap( " : " ); - EXPR_out( oe->op3, 0 ); - raw( "]" ); + EXPR_out(oe->op1, 1); + wrap("["); + EXPR_out(oe->op2, 0); + wrap(" : "); + EXPR_out(oe->op3, 0); + raw("]"); break; default: - wrap( "(* unknown op-expression *)" ); + wrap("(* unknown op-expression *)"); } } -void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ) { - if( pad && paren && ( eo->op_code != previous_op ) ) { - wrap( "( " ); +void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op) +{ + if(pad && paren && (eo->op_code != previous_op)) { + wrap("( "); } - EXPR__out( eo->op1, 1, eo->op_code ); - if( pad ) { - raw( " " ); + EXPR__out(eo->op1, 1, eo->op_code); + if(pad) { + raw(" "); } - wrap( "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); - if( pad ) { - wrap( " " ); + wrap("%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); + if(pad) { + wrap(" "); } - EXPR__out( eo->op2, 1, eo->op_code ); - if( pad && paren && ( eo->op_code != previous_op ) ) { - raw( " )" ); + EXPR__out(eo->op2, 1, eo->op_code); + if(pad && paren && (eo->op_code != previous_op)) { + raw(" )"); } } /** Print out a one-operand operation. If there were more than two of these * I'd generalize it to do padding, but it's not worth it. */ -void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ) { - if( paren ) { - wrap( "( " ); +void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren) +{ + if(paren) { + wrap("( "); } - wrap( "%s", opcode ); - EXPR_out( eo->op1, 1 ); - if( paren ) { - raw( " )" ); + wrap("%s", opcode); + EXPR_out(eo->op1, 1); + if(paren) { + raw(" )"); } } -int EXPRop_length( struct Op_Subexpression * oe ) { - switch( oe->op_code ) { +int EXPRop_length(struct Op_Subexpression *oe) +{ + switch(oe->op_code) { case OP_DOT: case OP_GROUP: - return( 1 + EXPRlength( oe->op1 ) - + EXPRlength( oe->op2 ) ); + return(1 + EXPRlength(oe->op1) + + EXPRlength(oe->op2)); default: - fprintf( stdout, "EXPRop_length: unknown op-expression" ); + fprintf(stdout, "EXPRop_length: unknown op-expression"); } return 0; } @@ -273,165 +280,173 @@ int EXPRop_length( struct Op_Subexpression * oe ) { * any kind of expression * contains fragment of string, adds to it */ -void EXPRstring( char * buffer, Expression e ) { +void EXPRstring(char *buffer, Expression e) +{ int i; - switch( TYPEis( e->type ) ) { + switch(TYPEis(e->type)) { case integer_: - if( e == LITERAL_INFINITY ) { - strcpy( buffer, "?" ); + if(e == LITERAL_INFINITY) { + strcpy(buffer, "?"); } else { - sprintf( buffer, "%d", e->u.integer ); + sprintf(buffer, "%d", e->u.integer); } break; case real_: - if( e == LITERAL_PI ) { - strcpy( buffer, "PI" ); - } else if( e == LITERAL_E ) { - strcpy( buffer, "E" ); + if(e == LITERAL_PI) { + strcpy(buffer, "PI"); + } else if(e == LITERAL_E) { + strcpy(buffer, "E"); } else { - sprintf( buffer, "%s", real2exp( e->u.real ) ); + sprintf(buffer, "%s", real2exp(e->u.real)); } break; case binary_: - sprintf( buffer, "%%%s", e->u.binary ); /* put "%" back */ + sprintf(buffer, "%%%s", e->u.binary); /* put "%" back */ break; case logical_: case boolean_: - switch( e->u.logical ) { + switch(e->u.logical) { case Ltrue: - strcpy( buffer, "TRUE" ); + strcpy(buffer, "TRUE"); break; case Lfalse: - strcpy( buffer, "FALSE" ); + strcpy(buffer, "FALSE"); break; default: - strcpy( buffer, "UNKNOWN" ); + strcpy(buffer, "UNKNOWN"); break; } break; case string_: - if( TYPEis_encoded( e->type ) ) { - sprintf( buffer, "\"%s\"", e->symbol.name ); + if(TYPEis_encoded(e->type)) { + sprintf(buffer, "\"%s\"", e->symbol.name); } else { - sprintf( buffer, "%s", e->symbol.name ); + sprintf(buffer, "%s", e->symbol.name); } break; case entity_: case identifier_: case attribute_: case enumeration_: - strcpy( buffer, e->symbol.name ); + strcpy(buffer, e->symbol.name); break; case query_: - sprintf( buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); - EXPRstring( buffer + strlen( buffer ), e->u.query->aggregate ); - strcat( buffer, " | " ); - EXPRstring( buffer + strlen( buffer ), e->u.query->expression ); - strcat( buffer, " )" ); + sprintf(buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name); + EXPRstring(buffer + strlen(buffer), e->u.query->aggregate); + strcat(buffer, " | "); + EXPRstring(buffer + strlen(buffer), e->u.query->expression); + strcat(buffer, " )"); break; case self_: - strcpy( buffer, "SELF" ); + strcpy(buffer, "SELF"); break; case funcall_: - sprintf( buffer, "%s( ", e->symbol.name ); + sprintf(buffer, "%s( ", e->symbol.name); i = 0; - LISTdo( e->u.funcall.list, arg, Expression ) + LISTdo(e->u.funcall.list, arg, Expression) i++; - if( i != 1 ) { - strcat( buffer, ", " ); + if(i != 1) { + strcat(buffer, ", "); } - EXPRstring( buffer + strlen( buffer ), arg ); + EXPRstring(buffer + strlen(buffer), arg); LISTod - strcat( buffer, " )" ); + strcat(buffer, " )"); break; case op_: - EXPRop_string( buffer, &e->e ); + EXPRop_string(buffer, &e->e); break; case aggregate_: - strcpy( buffer, "[" ); + strcpy(buffer, "["); i = 0; - LISTdo( e->u.list, arg, Expression ) { + LISTdo(e->u.list, arg, Expression) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if( i != 1 ) { - if( repeat ) { - strcat( buffer, " : " ); + if(i != 1) { + if(repeat) { + strcat(buffer, " : "); } else { - strcat( buffer, ", " ); + strcat(buffer, ", "); } } - EXPRstring( buffer + strlen( buffer ), arg ); - } LISTod - strcat( buffer, "]" ); + EXPRstring(buffer + strlen(buffer), arg); + } + LISTod + strcat(buffer, "]"); break; case oneof_: - strcpy( buffer, "ONEOF ( " ); + strcpy(buffer, "ONEOF ( "); i = 0; - LISTdo( e->u.list, arg, Expression ) { + LISTdo(e->u.list, arg, Expression) { i++; - if( i != 1 ) { - strcat( buffer, ", " ); + if(i != 1) { + strcat(buffer, ", "); } - EXPRstring( buffer + strlen( buffer ), arg ); - } LISTod + EXPRstring(buffer + strlen(buffer), arg); + } + LISTod - strcat( buffer, " )" ); + strcat(buffer, " )"); break; default: - sprintf( buffer, "EXPRstring: unknown expression, type %d", TYPEis( e->type ) ); - fprintf( stderr, "%s", buffer ); + sprintf(buffer, "EXPRstring: unknown expression, type %d", TYPEis(e->type)); + fprintf(stderr, "%s", buffer); } } -void EXPRop_string( char * buffer, struct Op_Subexpression * oe ) { - EXPRstring( buffer, oe->op1 ); - switch( oe->op_code ) { +void EXPRop_string(char *buffer, struct Op_Subexpression *oe) +{ + EXPRstring(buffer, oe->op1); + switch(oe->op_code) { case OP_DOT: - strcat( buffer, "." ); + strcat(buffer, "."); break; case OP_GROUP: - strcat( buffer, "\\" ); + strcat(buffer, "\\"); break; default: - strcat( buffer, "(* unknown op-expression *)" ); + strcat(buffer, "(* unknown op-expression *)"); } - EXPRstring( buffer + strlen( buffer ), oe->op2 ); + EXPRstring(buffer + strlen(buffer), oe->op2); } /** returns length of printable representation of expression w.o. printing it * doesn't understand as many expressions as the printing functions (!) * WARNING this *does* change the global 'curpos'! */ -int EXPRlength( Expression e ) { +int EXPRlength(Expression e) +{ char buffer[10000]; *buffer = '\0'; - EXPRstring( buffer, e ); - return( strlen( buffer ) ); + EXPRstring(buffer, e); + return(strlen(buffer)); } -char * EXPRto_string( Expression e ) { - if( prep_string() ) { +char *EXPRto_string(Expression e) +{ + if(prep_string()) { return placeholder; } - EXPR_out( e, 0 ); - return ( finish_string() ); + EXPR_out(e, 0); + return (finish_string()); } /** \return length of buffer used */ -int EXPRto_buffer( Expression e, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int EXPRto_buffer(Expression e, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - EXPR_out( e, 0 ); - return( finish_buffer() ); + EXPR_out(e, 0); + return(finish_buffer()); } -void EXPRout( Expression e ) { +void EXPRout(Expression e) +{ prep_file(); - EXPR_out( e, 0 ); + EXPR_out(e, 0); finish_file(); } diff --git a/src/exppp/pretty_expr.h b/src/exppp/pretty_expr.h index 633bdf3f1..39f9ce989 100644 --- a/src/exppp/pretty_expr.h +++ b/src/exppp/pretty_expr.h @@ -10,13 +10,13 @@ EXPRop2__out(oe,string,paren,pad,OP_UNKNOWN) #define EXPRop_out(oe,paren) EXPRop__out(oe,paren,OP_UNKNOWN) -void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ); -void EXPRop_string( char * buffer, struct Op_Subexpression * oe ); -void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ); -void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ); -void EXPR__out( Expression e, int paren, unsigned int previous_op ); -void EXPRbounds_out( TypeBody tb ); -int EXPRlength( Expression e ); +void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op); +void EXPRop_string(char *buffer, struct Op_Subexpression *oe); +void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren); +void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op); +void EXPR__out(Expression e, int paren, unsigned int previous_op); +void EXPRbounds_out(TypeBody tb); +int EXPRlength(Expression e); #endif /* PRETTY_EXPR_H */ diff --git a/src/exppp/pretty_express.c b/src/exppp/pretty_express.c index 610d5e938..911567126 100644 --- a/src/exppp/pretty_express.c +++ b/src/exppp/pretty_express.c @@ -9,14 +9,15 @@ #include "pretty_schema.h" #include "pretty_express.h" -void EXPRESSout( Express e ) { +void EXPRESSout(Express e) +{ Schema s; DictionaryEntry de; exppp_init(); - DICTdo_init( e->symbol_table, &de ); - while( 0 != ( s = ( Schema )DICTdo( &de ) ) ) { - ( void ) SCHEMAout( s ); + DICTdo_init(e->symbol_table, &de); + while(0 != (s = (Schema)DICTdo(&de))) { + (void) SCHEMAout(s); } } diff --git a/src/exppp/pretty_express.h b/src/exppp/pretty_express.h index 18d7e1296..7ab337f4a 100644 --- a/src/exppp/pretty_express.h +++ b/src/exppp/pretty_express.h @@ -1,6 +1,6 @@ #ifndef PRETTY_EXPRESS_H #define PRETTY_EXPRESS_H -void EXPRESSout( Express e ); +void EXPRESSout(Express e); #endif /* PRETTY_EXPRESS_H */ diff --git a/src/exppp/pretty_func.c b/src/exppp/pretty_func.c index 4129d7855..f07f5291e 100644 --- a/src/exppp/pretty_func.c +++ b/src/exppp/pretty_func.c @@ -9,54 +9,58 @@ #include "pretty_stmt.h" #include "pretty_func.h" -void FUNC_out( Function fn, int level ) { - if( fn->u.func->builtin ) { +void FUNC_out(Function fn, int level) +{ + if(fn->u.func->builtin) { return; } first_newline(); - exppp_ref_info( &fn->symbol ); - - raw( "%*sFUNCTION %s", level, "", fn->symbol.name ); - if( fn->u.func->parameters ) { - unsigned int param_indent = level + strlen( "FUNCTION " ); - raw( "(\n" ); - ALGargs_out( fn->u.func->parameters, param_indent ); - raw( "\n%*s)", param_indent - exppp_continuation_indent, "" ); + exppp_ref_info(&fn->symbol); + + raw("%*sFUNCTION %s", level, "", fn->symbol.name); + if(fn->u.func->parameters) { + unsigned int param_indent = level + strlen("FUNCTION "); + raw("(\n"); + ALGargs_out(fn->u.func->parameters, param_indent); + raw("\n%*s)", param_indent - exppp_continuation_indent, ""); } - raw( " :" ); + raw(" :"); indent2 = curpos + exppp_continuation_indent; - TYPE_head_out( fn->u.func->return_type, NOLEVEL ); - raw( ";\n" ); + TYPE_head_out(fn->u.func->return_type, NOLEVEL); + raw(";\n"); - ALGscope_out( fn, level + exppp_nesting_indent ); - STMTlist_out( fn->u.proc->body, level + exppp_nesting_indent ); + ALGscope_out(fn, level + exppp_nesting_indent); + STMTlist_out(fn->u.proc->body, level + exppp_nesting_indent); - raw( "\n%*sEND_FUNCTION;", level, "" ); - tail_comment( fn->symbol.name ); + raw("\n%*sEND_FUNCTION;", level, ""); + tail_comment(fn->symbol.name); } -char * FUNCto_string( Function f ) { - if( prep_string() ) { +char *FUNCto_string(Function f) +{ + if(prep_string()) { return placeholder; } - FUNC_out( f, 0 ); - return ( finish_string() ); + FUNC_out(f, 0); + return (finish_string()); } /** return length of buffer used */ -int FUNCto_buffer( Function e, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int FUNCto_buffer(Function e, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - FUNC_out( e, 0 ); - return( finish_buffer() ); + FUNC_out(e, 0); + return(finish_buffer()); } -void FUNCout( Function f ) { +void FUNCout(Function f) +{ prep_file(); - FUNC_out( f, 0 ); + FUNC_out(f, 0); finish_file(); } diff --git a/src/exppp/pretty_func.h b/src/exppp/pretty_func.h index 70d4b850d..71d857c6a 100644 --- a/src/exppp/pretty_func.h +++ b/src/exppp/pretty_func.h @@ -3,10 +3,10 @@ #include -char * FUNCto_string( Function f ); -void FUNC_out( Function fn, int level ); -void FUNCout( Function f ); -int FUNCto_buffer( Function e, char * buffer, int length ); +char *FUNCto_string(Function f); +void FUNC_out(Function fn, int level); +void FUNCout(Function f); +int FUNCto_buffer(Function e, char *buffer, int length); #endif /* PRETTY_FUNC_H */ diff --git a/src/exppp/pretty_loop.c b/src/exppp/pretty_loop.c index 95a059f44..da29fd58e 100644 --- a/src/exppp/pretty_loop.c +++ b/src/exppp/pretty_loop.c @@ -11,41 +11,42 @@ #include "pretty_stmt.h" #include "pretty_loop.h" -void LOOPout( struct Loop_ *loop, int level ) { +void LOOPout(struct Loop_ *loop, int level) +{ Variable v; - raw( "%*sREPEAT", level, "" ); + raw("%*sREPEAT", level, ""); /* increment */ /* if (loop->scope->u.incr) {*/ - if( loop->scope ) { + if(loop->scope) { DictionaryEntry de; - DICTdo_init( loop->scope->symbol_table, &de ); - v = ( Variable )DICTdo( &de ); - wrap( " %s := ", v->name->symbol.name ); - EXPR_out( loop->scope->u.incr->init, 0 ); - wrap( " TO " ); - EXPR_out( loop->scope->u.incr->end, 0 ); - wrap( " BY " ); /* parser always forces a "by" expr */ - EXPR_out( loop->scope->u.incr->increment, 0 ); + DICTdo_init(loop->scope->symbol_table, &de); + v = (Variable)DICTdo(&de); + wrap(" %s := ", v->name->symbol.name); + EXPR_out(loop->scope->u.incr->init, 0); + wrap(" TO "); + EXPR_out(loop->scope->u.incr->end, 0); + wrap(" BY "); /* parser always forces a "by" expr */ + EXPR_out(loop->scope->u.incr->increment, 0); } /* while */ - if( loop->while_expr ) { - wrap( " WHILE " ); - EXPR_out( loop->while_expr, 0 ); + if(loop->while_expr) { + wrap(" WHILE "); + EXPR_out(loop->while_expr, 0); } /* until */ - if( loop->until_expr ) { - wrap( " UNTIL " ); - EXPR_out( loop->until_expr, 0 ); + if(loop->until_expr) { + wrap(" UNTIL "); + EXPR_out(loop->until_expr, 0); } - raw( ";\n" ); + raw(";\n"); - STMTlist_out( loop->statements, level + exppp_nesting_indent ); + STMTlist_out(loop->statements, level + exppp_nesting_indent); - raw( "%*sEND_REPEAT;\n", level, "" ); + raw("%*sEND_REPEAT;\n", level, ""); } diff --git a/src/exppp/pretty_loop.h b/src/exppp/pretty_loop.h index 7a048211d..804f4b450 100644 --- a/src/exppp/pretty_loop.h +++ b/src/exppp/pretty_loop.h @@ -3,6 +3,6 @@ #include -void LOOPout( struct Loop_ *loop, int level ); +void LOOPout(struct Loop_ *loop, int level); #endif /* PRETTY_LOOP_H */ diff --git a/src/exppp/pretty_proc.c b/src/exppp/pretty_proc.c index ee16d6853..cb297fbab 100644 --- a/src/exppp/pretty_proc.c +++ b/src/exppp/pretty_proc.c @@ -8,47 +8,51 @@ #include "pretty_stmt.h" #include "pretty_proc.h" -char * PROCto_string( Procedure p ) { - if( prep_string() ) { +char *PROCto_string(Procedure p) +{ + if(prep_string()) { return placeholder; } - PROC_out( p, 0 ); - return ( finish_string() ); + PROC_out(p, 0); + return (finish_string()); } /** return length of buffer used */ -int PROCto_buffer( Procedure e, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int PROCto_buffer(Procedure e, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - PROC_out( e, 0 ); - return( finish_buffer() ); + PROC_out(e, 0); + return(finish_buffer()); } -void PROCout( Procedure p ) { +void PROCout(Procedure p) +{ prep_file(); - PROC_out( p, 0 ); + PROC_out(p, 0); finish_file(); } -void PROC_out( Procedure p, int level ) { - if( p->u.proc->builtin ) { +void PROC_out(Procedure p, int level) +{ + if(p->u.proc->builtin) { return; } first_newline(); - exppp_ref_info( &p->symbol ); + exppp_ref_info(&p->symbol); - raw( "%*sPROCEDURE %s(\n", level, "", p->symbol.name ); + raw("%*sPROCEDURE %s(\n", level, "", p->symbol.name); - ALGargs_out( p->u.proc->parameters, level + strlen( "PROCEDURE " ) ); + ALGargs_out(p->u.proc->parameters, level + strlen("PROCEDURE ")); - raw( "%*s);\n", level + exppp_nesting_indent, "" ); + raw("%*s);\n", level + exppp_nesting_indent, ""); - ALGscope_out( p, level + exppp_nesting_indent ); - STMTlist_out( p->u.proc->body, level + exppp_nesting_indent ); + ALGscope_out(p, level + exppp_nesting_indent); + STMTlist_out(p->u.proc->body, level + exppp_nesting_indent); - raw( "\n%*sEND_PROCEDURE;", level, "" ); - tail_comment( p->symbol.name ); + raw("\n%*sEND_PROCEDURE;", level, ""); + tail_comment(p->symbol.name); } diff --git a/src/exppp/pretty_proc.h b/src/exppp/pretty_proc.h index 22099878e..46df8839e 100644 --- a/src/exppp/pretty_proc.h +++ b/src/exppp/pretty_proc.h @@ -3,9 +3,9 @@ #include -char * PROCto_string( Procedure p ); -void PROC_out( Procedure p, int level ); -void PROCout( Procedure p ); -int PROCto_buffer( Procedure e, char * buffer, int length ); +char *PROCto_string(Procedure p); +void PROC_out(Procedure p, int level); +void PROCout(Procedure p); +int PROCto_buffer(Procedure e, char *buffer, int length); #endif /* PRETTY_PROC_H */ diff --git a/src/exppp/pretty_ref.c b/src/exppp/pretty_ref.c index 3d73efd77..72cf13d1a 100644 --- a/src/exppp/pretty_ref.c +++ b/src/exppp/pretty_ref.c @@ -8,62 +8,64 @@ #include "pp.h" #include "pretty_ref.h" -void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ) { +void REFout(Dictionary refdict, Linked_List reflist, char *type, int level) +{ Dictionary dict; DictionaryEntry de; - struct Rename * ren; + struct Rename *ren; Linked_List list; - LISTdo( reflist, s, Schema ) - raw( "%s FROM %s;\n", type, s->symbol.name ); + LISTdo(reflist, s, Schema) + raw("%s FROM %s;\n", type, s->symbol.name); LISTod - if( !refdict ) { + if(!refdict) { return; } - dict = DICTcreate( 10 ); + dict = DICTcreate(10); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init( refdict, &de ); - while( 0 != ( ren = ( struct Rename * )DICTdo( &de ) ) ) { + DICTdo_init(refdict, &de); + while(0 != (ren = (struct Rename *)DICTdo(&de))) { Linked_List nameList; - nameList = ( Linked_List )DICTlookup( dict, ren->schema->symbol.name ); - if( !nameList ) { + nameList = (Linked_List)DICTlookup(dict, ren->schema->symbol.name); + if(!nameList) { nameList = LISTcreate(); - DICTdefine( dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN ); + DICTdefine(dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN); } - LISTadd_last( nameList, ren ); + LISTadd_last(nameList, ren); } /* step 2: for each list, print out the renames */ level = 6; /* no special reason, feels good */ indent2 = level + exppp_continuation_indent; - DICTdo_init( dict, &de ); - while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { + DICTdo_init(dict, &de); + while(0 != (list = (Linked_List)DICTdo(&de))) { bool first_time = true; - LISTdo( list, r, struct Rename * ) { - if( first_time ) { - raw( "%s FROM %s\n", type, r->schema->symbol.name ); + LISTdo(list, r, struct Rename *) { + if(first_time) { + raw("%s FROM %s\n", type, r->schema->symbol.name); } else { /* finish previous line */ - raw( ",\n" ); + raw(",\n"); } - if( first_time ) { - raw( "%*s( ", level, "" ); + if(first_time) { + raw("%*s( ", level, ""); first_time = false; } else { - raw( "%*s ", level, "" ); + raw("%*s ", level, ""); } - raw( r->old->name ); - if( r->old != r->nnew ) { - wrap( " AS %s", r->nnew->name ); + raw(r->old->name); + if(r->old != r->nnew) { + wrap(" AS %s", r->nnew->name); } - } LISTod - raw( " );\n" ); + } + LISTod + raw(" );\n"); } - HASHdestroy( dict ); + HASHdestroy(dict); } diff --git a/src/exppp/pretty_ref.h b/src/exppp/pretty_ref.h index 2b1c1cf84..7d1f22535 100644 --- a/src/exppp/pretty_ref.h +++ b/src/exppp/pretty_ref.h @@ -4,6 +4,6 @@ #include #include -void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); +void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); #endif /* PRETTY_REF_H */ diff --git a/src/exppp/pretty_rule.c b/src/exppp/pretty_rule.c index 49d4d0e15..9e18ef21e 100644 --- a/src/exppp/pretty_rule.c +++ b/src/exppp/pretty_rule.c @@ -9,50 +9,54 @@ #include "pretty_where.h" #include "pretty_rule.h" -char * RULEto_string( Rule r ) { - if( prep_string() ) { +char *RULEto_string(Rule r) +{ + if(prep_string()) { return placeholder; } - RULE_out( r, 0 ); - return ( finish_string() ); + RULE_out(r, 0); + return (finish_string()); } /** return length of buffer used */ -int RULEto_buffer( Rule e, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int RULEto_buffer(Rule e, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - RULE_out( e, 0 ); - return( finish_buffer() ); + RULE_out(e, 0); + return(finish_buffer()); } -void RULEout( Rule r ) { +void RULEout(Rule r) +{ prep_file(); - RULE_out( r, 0 ); + RULE_out(r, 0); finish_file(); } -void RULE_out( Rule r, int level ) { +void RULE_out(Rule r, int level) +{ int i = 0; first_newline(); - exppp_ref_info( &r->symbol ); + exppp_ref_info(&r->symbol); - raw( "%*sRULE %s FOR ( ", level, "", r->symbol.name ); + raw("%*sRULE %s FOR ( ", level, "", r->symbol.name); - LISTdo( r->u.rule->parameters, p, Variable ) + LISTdo(r->u.rule->parameters, p, Variable) i++; - if( i != 1 ) { - raw( ", " ); + if(i != 1) { + raw(", "); } - wrap( p->name->symbol.name ); + wrap(p->name->symbol.name); LISTod; - raw( " );\n" ); + raw(" );\n"); - ALGscope_out( r, level + exppp_nesting_indent ); - STMTlist_out( r->u.rule->body, level + exppp_nesting_indent ); - raw( "\n" ); - WHERE_out( RULEget_where( r ), level ); + ALGscope_out(r, level + exppp_nesting_indent); + STMTlist_out(r->u.rule->body, level + exppp_nesting_indent); + raw("\n"); + WHERE_out(RULEget_where(r), level); - raw( "\n%*sEND_RULE;", level, "" ); - tail_comment( r->symbol.name ); + raw("\n%*sEND_RULE;", level, ""); + tail_comment(r->symbol.name); } diff --git a/src/exppp/pretty_rule.h b/src/exppp/pretty_rule.h index 18d29e0c8..f507bde20 100644 --- a/src/exppp/pretty_rule.h +++ b/src/exppp/pretty_rule.h @@ -3,9 +3,9 @@ #include "../express/alg.h" -char * RULEto_string( Rule r ); -void RULE_out( Rule r, int level ); -void RULEout( Rule r ); -int RULEto_buffer( Rule e, char * buffer, int length ); +char *RULEto_string(Rule r); +void RULE_out(Rule r, int level); +void RULEout(Rule r); +int RULEto_buffer(Rule e, char *buffer, int length); #endif /* PRETTY_RULE_H */ diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 6b555f379..be6f4f7d2 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -20,47 +20,48 @@ # include /* for unlink */ #endif -char * exppp_output_filename = ( char * )0; /* if this is set, override default output filename */ +char *exppp_output_filename = (char *)0; /* if this is set, override default output filename */ char exppp_filename_buffer[1000]; /* output file name */ /* Only the first line is compared to an existing file, so putting a * version number in here won't cause problems. The actual version must * be inserted later - this can't be initialized with non-constant. */ -char * expheader[] = { - "(* This file was generated by the EXPRESS Pretty Printer exppp," , - "part of STEPcode (formerly NIST's SCL). exppp version:" , - "" /* if there are two consecutive blank lines, */ , - "" /* the version string will be printed on the first */ , - "WARNING: If you modify this file and want to save the changes," , - "delete this comment block or else the file will be rewritten" , - "the next time exppp processes this schema. *)" , +char *expheader[] = { + "(* This file was generated by the EXPRESS Pretty Printer exppp,", + "part of STEPcode (formerly NIST's SCL). exppp version:", + "" /* if there are two consecutive blank lines, */, + "" /* the version string will be printed on the first */, + "WARNING: If you modify this file and want to save the changes,", + "delete this comment block or else the file will be rewritten", + "the next time exppp processes this schema. *)", 0 }; /** returns name of file written to in static storage */ -char * SCHEMAout( Schema s ) { - #define PP_SMALL_BUF_SZ 80 +char *SCHEMAout(Schema s) +{ +#define PP_SMALL_BUF_SZ 80 char buf[PP_SMALL_BUF_SZ]; - char * p; + char *p; int level = 0; - char ** hp; + char **hp; bool described = false; - if( exppp_print_to_stdout ) { + if(exppp_print_to_stdout) { exppp_fp = stdout; } else { - FILE * f; - if( exppp_output_filename_reset ) { + FILE *f; + if(exppp_output_filename_reset) { exppp_output_filename = 0; } - if( exppp_output_filename ) { - if( !strcmp( input_filename, exppp_output_filename ) ) { - fprintf( stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename ); - exit( EXIT_FAILURE ); + if(exppp_output_filename) { + if(!strcmp(input_filename, exppp_output_filename)) { + fprintf(stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename); + exit(EXIT_FAILURE); } - strcpy( exppp_filename_buffer, exppp_output_filename ); + strcpy(exppp_filename_buffer, exppp_output_filename); } else { /* when there is only a single file, allow user to find */ /* out what it is */ @@ -70,47 +71,47 @@ char * SCHEMAout( Schema s ) { /* since we have to generate a filename, make sure we don't */ /* overwrite a valuable file */ - sprintf( exppp_filename_buffer, "%s.exp", s->symbol.name ); + sprintf(exppp_filename_buffer, "%s.exp", s->symbol.name); - if( 0 != ( f = fopen( exppp_filename_buffer, "r" ) ) ) { - char * result = fgets( buf, PP_SMALL_BUF_SZ, f ); - if( 0 != ( p = strchr( buf, '\n' ) ) ) { + if(0 != (f = fopen(exppp_filename_buffer, "r"))) { + char *result = fgets(buf, PP_SMALL_BUF_SZ, f); + if(0 != (p = strchr(buf, '\n'))) { *p = '\0'; } - if( ( !result ) || ( !strcmp( buf, expheader[0] ) ) ) { - unlink( exppp_filename_buffer ); + if((!result) || (!strcmp(buf, expheader[0]))) { + unlink(exppp_filename_buffer); } else { - fprintf( stderr, "%s: %s already exists and appears to be hand-written\n", - EXPRESSprogram_name, exppp_filename_buffer ); + fprintf(stderr, "%s: %s already exists and appears to be hand-written\n", + EXPRESSprogram_name, exppp_filename_buffer); /* strcat(bp,".pp");*/ - strcat( exppp_filename_buffer, ".pp" ); - fprintf( stderr, "%s: writing schema file %s instead\n", - EXPRESSprogram_name, exppp_filename_buffer ); + strcat(exppp_filename_buffer, ".pp"); + fprintf(stderr, "%s: writing schema file %s instead\n", + EXPRESSprogram_name, exppp_filename_buffer); described = true; } } - if( f ) { - fclose( f ); + if(f) { + fclose(f); } } error_sym.filename = exppp_filename_buffer; - if( !described && !exppp_terse ) { - fprintf( stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer ); + if(!described && !exppp_terse) { + fprintf(stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer); } - if( !( exppp_fp = f = fopen( exppp_filename_buffer, "w" ) ) ) { - ERRORreport( FILE_UNWRITABLE, exppp_filename_buffer, strerror( errno ) ); + if(!(exppp_fp = f = fopen(exppp_filename_buffer, "w"))) { + ERRORreport(FILE_UNWRITABLE, exppp_filename_buffer, strerror(errno)); return 0; } } error_sym.line = 1; /* print our header - generated by exppp, don't edit, etc */ - for( hp = expheader; *hp; hp++ ) { - if( ( **hp == '\0' ) && ( **( hp + 1 ) == '\0' ) ) { + for(hp = expheader; *hp; hp++) { + if((**hp == '\0') && (**(hp + 1) == '\0')) { /* if this and the next lines are blank, put version string on this line */ - raw( "%s\n", sc_version ); + raw("%s\n", sc_version); } else { - raw( "%s\n", *hp ); + raw("%s\n", *hp); } } @@ -118,15 +119,15 @@ char * SCHEMAout( Schema s ) { /* raw("SCHEMA %s;\n",s->symbol.name);*/ first_line = false; - raw( "\nSCHEMA %s;\n", s->symbol.name ); + raw("\nSCHEMA %s;\n", s->symbol.name); - if( s->u.schema->usedict || s->u.schema->use_schemas - || s->u.schema->refdict || s->u.schema->ref_schemas ) { - raw( "\n" ); + if(s->u.schema->usedict || s->u.schema->use_schemas + || s->u.schema->refdict || s->u.schema->ref_schemas) { + raw("\n"); } - REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent ); - REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent ); + REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent); + REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent); /* output order for DIS & IS schemas: * CONSTANT @@ -139,44 +140,47 @@ char * SCHEMAout( Schema s ) { * Within each of those groups, declarations must be sorted alphabetically. */ - SCOPEconsts_out( s, level + exppp_nesting_indent ); - SCOPEtypes_out( s, level + exppp_nesting_indent ); - SCOPEentities_out( s, level + exppp_nesting_indent ); - SCOPEalgs_out( s, level + exppp_nesting_indent ); + SCOPEconsts_out(s, level + exppp_nesting_indent); + SCOPEtypes_out(s, level + exppp_nesting_indent); + SCOPEentities_out(s, level + exppp_nesting_indent); + SCOPEalgs_out(s, level + exppp_nesting_indent); - raw( "\nEND_SCHEMA;"); - tail_comment( s->symbol.name ); + raw("\nEND_SCHEMA;"); + tail_comment(s->symbol.name); - fclose( exppp_fp ); + fclose(exppp_fp); return exppp_filename_buffer; - #undef PP_SMALL_BUF_SZ +#undef PP_SMALL_BUF_SZ } -char * SCHEMAref_to_string( Schema s ) { - if( prep_string() ) { +char *SCHEMAref_to_string(Schema s) +{ + if(prep_string()) { return placeholder; } - REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); - REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); - return ( finish_string() ); + REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); + REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); + return (finish_string()); } /** return length of buffer used */ -int SCHEMAref_to_buffer( Schema s, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int SCHEMAref_to_buffer(Schema s, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); - REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); - return( finish_buffer() ); + REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); + REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); + return(finish_buffer()); } -void SCHEMAref_out( Schema s ) { +void SCHEMAref_out(Schema s) +{ prep_file(); - REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); - REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); + REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); + REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); finish_file(); } diff --git a/src/exppp/pretty_schema.h b/src/exppp/pretty_schema.h index b9c649f99..7005bc363 100644 --- a/src/exppp/pretty_schema.h +++ b/src/exppp/pretty_schema.h @@ -3,9 +3,9 @@ #include -char * SCHEMAout( Schema s ); -char * SCHEMAref_to_string( Schema s ); -void SCHEMAref_out( Schema s ); -int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); +char *SCHEMAout(Schema s); +char *SCHEMAref_to_string(Schema s); +void SCHEMAref_out(Schema s); +int SCHEMAref_to_buffer(Schema s, char *buffer, int length); #endif /* PRETTY_SCHEMA_H */ diff --git a/src/exppp/pretty_scope.c b/src/exppp/pretty_scope.c index 85fe041d1..b3c92fc43 100644 --- a/src/exppp/pretty_scope.c +++ b/src/exppp/pretty_scope.c @@ -13,111 +13,121 @@ #include "pretty_scope.h" /** add items from s to list alphabetically */ -void SCOPEadd_inorder( Linked_List list, Scope s ) { +void SCOPEadd_inorder(Linked_List list, Scope s) +{ Link k = 0; - LISTdo_links( list, link ) - if( 0 > strcmp( - SCOPEget_name( s ), - SCOPEget_name( ( Type )( link->data ) ) ) ) { + LISTdo_links(list, link) + if(0 > strcmp( + SCOPEget_name(s), + SCOPEget_name((Type)(link->data)))) { k = link; break; - } LISTod + } + LISTod - LISTadd_before( list, k, s ); + LISTadd_before(list, k, s); } /** like SCOPEadd_inorder, but for Variables */ -void SCOPEaddvars_inorder( Linked_List list, Variable v ) { +void SCOPEaddvars_inorder(Linked_List list, Variable v) +{ Link k = 0; - LISTdo_links( list, link ) - if( 0 > strcmp( v->name->symbol.name, ( ( Variable ) link->data )->name->symbol.name ) ) { + LISTdo_links(list, link) + if(0 > strcmp(v->name->symbol.name, ((Variable) link->data)->name->symbol.name)) { k = link; break; - } LISTod + } + LISTod - LISTadd_before( list, k, v ); + LISTadd_before(list, k, v); } /** print the rules in a scope */ -void SCOPErules_out( Scope s, int level ) { +void SCOPErules_out(Scope s, int level) +{ Rule r; DictionaryEntry de; - if( exppp_alphabetize == false ) { - DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); - while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { - RULE_out( r, level ); + if(exppp_alphabetize == false) { + DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); + while(0 != (r = (Rule)DICTdo(&de))) { + RULE_out(r, level); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); - while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { - SCOPEadd_inorder( alpha, r ); + DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); + while(0 != (r = (Rule)DICTdo(&de))) { + SCOPEadd_inorder(alpha, r); } - LISTdo( alpha, ru, Rule ) { - RULE_out( ru, level ); - } LISTod + LISTdo(alpha, ru, Rule) { + RULE_out(ru, level); + } + LISTod - LISTfree( alpha ); + LISTfree(alpha); } } /** print the functions in a scope */ -void SCOPEfuncs_out( Scope s, int level ) { +void SCOPEfuncs_out(Scope s, int level) +{ Function f; DictionaryEntry de; - if( exppp_alphabetize == false ) { - DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); - while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { - FUNC_out( f, level ); + if(exppp_alphabetize == false) { + DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); + while(0 != (f = (Function)DICTdo(&de))) { + FUNC_out(f, level); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); - while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { - SCOPEadd_inorder( alpha, f ); + DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); + while(0 != (f = (Function)DICTdo(&de))) { + SCOPEadd_inorder(alpha, f); } - LISTdo( alpha, fun, Function ) { - FUNC_out( fun, level ); - } LISTod + LISTdo(alpha, fun, Function) { + FUNC_out(fun, level); + } + LISTod - LISTfree( alpha ); + LISTfree(alpha); } } /* print the procs in a scope */ -void SCOPEprocs_out( Scope s, int level ) { +void SCOPEprocs_out(Scope s, int level) +{ Procedure p; DictionaryEntry de; - if( exppp_alphabetize == false ) { - DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); - while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { - PROC_out( p, level ); + if(exppp_alphabetize == false) { + DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); + while(0 != (p = (Procedure)DICTdo(&de))) { + PROC_out(p, level); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); - while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { - SCOPEadd_inorder( alpha, p ); + DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); + while(0 != (p = (Procedure)DICTdo(&de))) { + SCOPEadd_inorder(alpha, p); } - LISTdo( alpha, pr, Procedure ) { - PROC_out( pr, level ); - } LISTod + LISTdo(alpha, pr, Procedure) { + PROC_out(pr, level); + } + LISTod - LISTfree( alpha ); + LISTfree(alpha); } } @@ -133,240 +143,252 @@ void SCOPEprocs_out( Scope s, int level ) { * Within each of those groups, declarations must be sorted alphabetically. */ /* print the algorithms in a scope */ -void SCOPEalgs_out( Scope s, int level ) { +void SCOPEalgs_out(Scope s, int level) +{ /* Supplementary Directivies 2.1.1 requires rules to be separated */ /* might as well separate funcs and procs, too */ - SCOPErules_out( s, level ); - SCOPEfuncs_out( s, level ); - SCOPEprocs_out( s, level ); + SCOPErules_out(s, level); + SCOPEfuncs_out(s, level); + SCOPEprocs_out(s, level); } /** output one const - used in SCOPEconsts_out, below */ -void SCOPEconst_out( Variable v, int level, size_t max_indent ) { +void SCOPEconst_out(Variable v, int level, size_t max_indent) +{ size_t old_indent2; /* print attribute name */ - raw( "%*s%-*s :", level + 2, "", - max_indent, v->name->symbol.name ); + raw("%*s%-*s :", level + 2, "", + max_indent, v->name->symbol.name); /* print attribute type */ - if( VARget_optional( v ) ) { - wrap( " OPTIONAL" ); + if(VARget_optional(v)) { + wrap(" OPTIONAL"); } /* let type definition stick out a bit to the left if it's on a new line */ old_indent2 = indent2; - if( indent2 > 4 ) { + if(indent2 > 4) { indent2 -= 4; } - TYPE_head_out( v->type, NOLEVEL ); + TYPE_head_out(v->type, NOLEVEL); indent2 = old_indent2; - if( v->initializer ) { + if(v->initializer) { int old_ll = exppp_linelength; /* so exppp_linelength can be restored */ - raw( " :=" ); + raw(" :="); /* let '[' on first line of initializer stick out so strings are aligned */ - raw( "\n%*s", indent2 - 2, "" ); + raw("\n%*s", indent2 - 2, ""); - if( exppp_aggressively_wrap_consts ) { + if(exppp_aggressively_wrap_consts) { /* causes wrap() to always begin new line */ exppp_linelength = indent2; } - EXPR_out( v->initializer, 0 ); + EXPR_out(v->initializer, 0); exppp_linelength = old_ll; } - raw( ";\n" ); + raw(";\n"); } /** output all consts in this scope */ -void SCOPEconsts_out( Scope s, int level ) { +void SCOPEconsts_out(Scope s, int level) +{ Variable v; DictionaryEntry de; size_t max_indent = 0; Dictionary d = s->symbol_table; /* checks length of constant names */ - DICTdo_type_init( d, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( !v->flags.constant ) { + DICTdo_type_init(d, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(!v->flags.constant) { continue; } - if( strlen( v->name->symbol.name ) > max_indent ) { - max_indent = strlen( v->name->symbol.name ); + if(strlen(v->name->symbol.name) > max_indent) { + max_indent = strlen(v->name->symbol.name); } } - if( !max_indent ) { + if(!max_indent) { return; } first_newline(); - raw( "%*sCONSTANT\n", level, "" ); + raw("%*sCONSTANT\n", level, ""); /* if max_indent is too big, wrap() won't insert any newlines * fiddled with this until it looked ok on 242 arm */ - if( ( max_indent + 20 ) > ( size_t ) exppp_linelength / 2 ) { - max_indent = ( size_t ) exppp_linelength / 3; + if((max_indent + 20) > (size_t) exppp_linelength / 2) { + max_indent = (size_t) exppp_linelength / 3; } - indent2 = level + max_indent + strlen( ": ab" ) + exppp_continuation_indent; + indent2 = level + max_indent + strlen(": ab") + exppp_continuation_indent; - if( !exppp_alphabetize ) { - DICTdo_type_init( d, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( !v->flags.constant ) { + if(!exppp_alphabetize) { + DICTdo_type_init(d, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(!v->flags.constant) { continue; } - SCOPEconst_out( v, level, max_indent ); + SCOPEconst_out(v, level, max_indent); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( d, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( !v->flags.constant ) { + DICTdo_type_init(d, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(!v->flags.constant) { continue; } - SCOPEaddvars_inorder( alpha, v ); + SCOPEaddvars_inorder(alpha, v); } - LISTdo( alpha, cnst, Variable ) { - SCOPEconst_out( cnst, level, max_indent ); - } LISTod - LISTfree( alpha ); + LISTdo(alpha, cnst, Variable) { + SCOPEconst_out(cnst, level, max_indent); + } + LISTod + LISTfree(alpha); } - raw( "%*sEND_CONSTANT;\n", level, "" ); + raw("%*sEND_CONSTANT;\n", level, ""); } /** insert variable v into list, keeping the list ordered by ascending v->offset */ -void SCOPElocals_order( Linked_List list, Variable v ) { - LISTdo_links( list, link ) { - if( v->offset < ( (Variable) link->data )->offset ) { - LISTadd_before( list, link, v ); +void SCOPElocals_order(Linked_List list, Variable v) +{ + LISTdo_links(list, link) { + if(v->offset < ((Variable) link->data)->offset) { + LISTadd_before(list, link, v); return; } - } LISTod - LISTadd_last( list, v ); + } + LISTod + LISTadd_last(list, v); } -void SCOPElocals_out( Scope s, int level ) { +void SCOPElocals_out(Scope s, int level) +{ Variable v; DictionaryEntry de; Linked_List orderedLocals = 0; /**< this list is used to order the vars the same way they were in the file */ size_t max_indent = 0; Dictionary d = s->symbol_table; - DICTdo_type_init( d, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( v->flags.constant ) { + DICTdo_type_init(d, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(v->flags.constant) { continue; } - if( v->flags.parameter ) { + if(v->flags.parameter) { continue; } - if( strlen( v->name->symbol.name ) > max_indent ) { - max_indent = strlen( v->name->symbol.name ); + if(strlen(v->name->symbol.name) > max_indent) { + max_indent = strlen(v->name->symbol.name); } } - if( !max_indent ) { + if(!max_indent) { return; } first_newline(); - raw( "%*sLOCAL\n", level, "" ); - indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; + raw("%*sLOCAL\n", level, ""); + indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; - DICTdo_type_init( d, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( v->flags.constant ) { + DICTdo_type_init(d, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(v->flags.constant) { continue; } - if( v->flags.parameter ) { + if(v->flags.parameter) { continue; } - if( !orderedLocals ) { + if(!orderedLocals) { orderedLocals = LISTcreate(); - LISTadd_first( orderedLocals, v ); + LISTadd_first(orderedLocals, v); } else { /* sort by v->offset */ - SCOPElocals_order( orderedLocals, v ); + SCOPElocals_order(orderedLocals, v); } } - LISTdo( orderedLocals, var, Variable ) { + LISTdo(orderedLocals, var, Variable) { /* print attribute name */ - raw( "%*s%-*s :", level + exppp_nesting_indent, "", - max_indent, var->name->symbol.name ); + raw("%*s%-*s :", level + exppp_nesting_indent, "", + max_indent, var->name->symbol.name); /* print attribute type */ - if( VARget_optional( var ) ) { - wrap( " OPTIONAL" ); + if(VARget_optional(var)) { + wrap(" OPTIONAL"); } - TYPE_head_out( var->type, NOLEVEL ); + TYPE_head_out(var->type, NOLEVEL); - if( var->initializer ) { - wrap( " := " ); - EXPR_out( var->initializer, 0 ); + if(var->initializer) { + wrap(" := "); + EXPR_out(var->initializer, 0); } - raw( ";\n" ); - } LISTod - LISTfree( orderedLocals ); + raw(";\n"); + } + LISTod + LISTfree(orderedLocals); - raw( "%*sEND_LOCAL;\n", level, "" ); + raw("%*sEND_LOCAL;\n", level, ""); } /** print all entities in a scope */ -void SCOPEentities_out( Scope s, int level ) { +void SCOPEentities_out(Scope s, int level) +{ Entity e; DictionaryEntry de; - if( exppp_alphabetize == false ) { - DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); - while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { - ENTITY_out( e, level ); + if(exppp_alphabetize == false) { + DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); + while(0 != (e = (Entity)DICTdo(&de))) { + ENTITY_out(e, level); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); - while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { - SCOPEadd_inorder( alpha, e ); + DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); + while(0 != (e = (Entity)DICTdo(&de))) { + SCOPEadd_inorder(alpha, e); } - LISTdo( alpha, en, Entity ) { - ENTITY_out( en, level ); - } LISTod + LISTdo(alpha, en, Entity) { + ENTITY_out(en, level); + } + LISTod - LISTfree( alpha ); + LISTfree(alpha); } } /** print all types in a scope */ -void SCOPEtypes_out( Scope s, int level ) { +void SCOPEtypes_out(Scope s, int level) +{ DictionaryEntry de; Type t; - if( exppp_alphabetize == false ) { - DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); - while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { - TYPE_out( t, level ); + if(exppp_alphabetize == false) { + DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); + while(0 != (t = (Type)DICTdo(&de))) { + TYPE_out(t, level); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); - while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { - SCOPEadd_inorder( alpha, t ); + DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); + while(0 != (t = (Type)DICTdo(&de))) { + SCOPEadd_inorder(alpha, t); } - LISTdo( alpha, ty, Type ) { - TYPE_out( ty, level ); - } LISTod + LISTdo(alpha, ty, Type) { + TYPE_out(ty, level); + } + LISTod - LISTfree( alpha ); + LISTfree(alpha); } } diff --git a/src/exppp/pretty_scope.h b/src/exppp/pretty_scope.h index 1e4e82e7d..82a64221d 100644 --- a/src/exppp/pretty_scope.h +++ b/src/exppp/pretty_scope.h @@ -6,15 +6,15 @@ #include "pp.h" -void SCOPEadd_inorder( Linked_List list, Scope s ); -void SCOPEalgs_out( Scope s, int level ); -void SCOPEconsts_out( Scope s, int level ); -void SCOPEentities_out( Scope s, int level ); -void SCOPEfuncs_out( Scope s, int level ); -void SCOPElocals_out( Scope s, int level ); -void SCOPEprocs_out( Scope s, int level ); -void SCOPErules_out( Scope s, int level ); -void SCOPEtypes_out( Scope s, int level ); +void SCOPEadd_inorder(Linked_List list, Scope s); +void SCOPEalgs_out(Scope s, int level); +void SCOPEconsts_out(Scope s, int level); +void SCOPEentities_out(Scope s, int level); +void SCOPEfuncs_out(Scope s, int level); +void SCOPElocals_out(Scope s, int level); +void SCOPEprocs_out(Scope s, int level); +void SCOPErules_out(Scope s, int level); +void SCOPEtypes_out(Scope s, int level); #endif /* PRETTY_SCOPE_H */ diff --git a/src/exppp/pretty_stmt.c b/src/exppp/pretty_stmt.c index 7694577ed..b99aaa2e5 100644 --- a/src/exppp/pretty_stmt.c +++ b/src/exppp/pretty_stmt.c @@ -9,110 +9,115 @@ #include "pretty_loop.h" #include "pretty_stmt.h" -void STMT_out( Statement s, int level ) { +void STMT_out(Statement s, int level) +{ bool first_time = true; - if( !s ) { /* null statement */ - raw( "%*s;\n", level, "" ); + if(!s) { /* null statement */ + raw("%*s;\n", level, ""); return; } indent2 = level + exppp_continuation_indent; - switch( s->type ) { + switch(s->type) { case STMT_ASSIGN: - raw( "%*s", level, "" ); - EXPR_out( s->u.assign->lhs, 0 ); - wrap( " := " ); - EXPR_out( s->u.assign->rhs, 0 ); - raw( ";\n", level, "" ); + raw("%*s", level, ""); + EXPR_out(s->u.assign->lhs, 0); + wrap(" := "); + EXPR_out(s->u.assign->rhs, 0); + raw(";\n", level, ""); break; case STMT_CASE: - CASEout( s->u.Case, level ); + CASEout(s->u.Case, level); break; case STMT_COMPOUND: - raw( "\n%*sBEGIN\n", level, "" ); - STMTlist_out( s->u.compound->statements, level + exppp_nesting_indent ); - raw( "%*sEND;\n", level, "" ); + raw("\n%*sBEGIN\n", level, ""); + STMTlist_out(s->u.compound->statements, level + exppp_nesting_indent); + raw("%*sEND;\n", level, ""); break; case STMT_COND: - raw( "%*sIF ", level, "" ); - EXPR_out( s->u.cond->test, 0 ); - wrap( " THEN\n" ); - STMTlist_out( s->u.cond->code, level + exppp_nesting_indent ); - if( s->u.cond->otherwise ) { - raw( "%*sELSE\n", level, "" ); - STMTlist_out( s->u.cond->otherwise, level + exppp_nesting_indent ); + raw("%*sIF ", level, ""); + EXPR_out(s->u.cond->test, 0); + wrap(" THEN\n"); + STMTlist_out(s->u.cond->code, level + exppp_nesting_indent); + if(s->u.cond->otherwise) { + raw("%*sELSE\n", level, ""); + STMTlist_out(s->u.cond->otherwise, level + exppp_nesting_indent); } - raw( "%*sEND_IF;\n", level, "" ); + raw("%*sEND_IF;\n", level, ""); break; case STMT_LOOP: - LOOPout( s->u.loop, level ); + LOOPout(s->u.loop, level); break; case STMT_PCALL: - raw( "%*s%s( ", level, "", s->symbol.name ); - LISTdo( s->u.proc->parameters, p, Expression ) - if( first_time ) { + raw("%*s%s( ", level, "", s->symbol.name); + LISTdo(s->u.proc->parameters, p, Expression) + if(first_time) { first_time = false; } else { - raw( ", " ); + raw(", "); } - EXPR_out( p, 0 ); + EXPR_out(p, 0); LISTod - raw( " );\n" ); + raw(" );\n"); break; case STMT_RETURN: - raw( "%*sRETURN", level, "" ); - if( s->u.ret->value ) { - wrap( "( " ); - EXPR_out( s->u.ret->value, 0 ); - raw( " )" ); + raw("%*sRETURN", level, ""); + if(s->u.ret->value) { + wrap("( "); + EXPR_out(s->u.ret->value, 0); + raw(" )"); } - raw( ";\n" ); + raw(";\n"); break; case STMT_ALIAS: - raw( "%*sALIAS %s for %s;\n", level, "", s->symbol.name, - /* should be generalized reference */ - s->u.alias->variable->name->symbol.name ); - STMTlist_out( s->u.alias->statements, level + exppp_nesting_indent ); - raw( "%*sEND_ALIAS;", level, "" ); - tail_comment( s->symbol.name ); + raw("%*sALIAS %s for %s;\n", level, "", s->symbol.name, + /* should be generalized reference */ + s->u.alias->variable->name->symbol.name); + STMTlist_out(s->u.alias->statements, level + exppp_nesting_indent); + raw("%*sEND_ALIAS;", level, ""); + tail_comment(s->symbol.name); break; case STMT_SKIP: - raw( "%*sSKIP;\n", level, "" ); + raw("%*sSKIP;\n", level, ""); break; case STMT_ESCAPE: - raw( "%*sESCAPE;\n", level, "" ); + raw("%*sESCAPE;\n", level, ""); break; } } -void STMTlist_out( Linked_List stmts, int level ) { - LISTdo( stmts, stmt, Statement ) - STMT_out( stmt, level ); +void STMTlist_out(Linked_List stmts, int level) +{ + LISTdo(stmts, stmt, Statement) + STMT_out(stmt, level); LISTod } -char * STMTto_string( Statement s ) { - if( prep_string() ) { +char *STMTto_string(Statement s) +{ + if(prep_string()) { return placeholder; } - STMT_out( s, 0 ); - return ( finish_string() ); + STMT_out(s, 0); + return (finish_string()); } /* return length of buffer used */ -int STMTto_buffer( Statement s, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int STMTto_buffer(Statement s, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - STMT_out( s, 0 ); - return( finish_buffer() ); + STMT_out(s, 0); + return(finish_buffer()); } -void STMTout( Statement s ) { +void STMTout(Statement s) +{ prep_file(); - STMT_out( s, 0 ); + STMT_out(s, 0); finish_file(); } diff --git a/src/exppp/pretty_stmt.h b/src/exppp/pretty_stmt.h index fe75ff372..f25d8bbde 100644 --- a/src/exppp/pretty_stmt.h +++ b/src/exppp/pretty_stmt.h @@ -4,11 +4,11 @@ #include #include -char * STMTto_string( Statement s ); -void STMT_out( Statement s, int level ); -void STMTlist_out( Linked_List stmts, int level ); -void STMTout( Statement s ); -int STMTto_buffer( Statement s, char * buffer, int length ); +char *STMTto_string(Statement s); +void STMT_out(Statement s, int level); +void STMTlist_out(Linked_List stmts, int level); +void STMTout(Statement s); +int STMTto_buffer(Statement s, char *buffer, int length); #endif /* PRETTY_STMT_H */ diff --git a/src/exppp/pretty_subtype.c b/src/exppp/pretty_subtype.c index d47298e49..1113d6ee1 100644 --- a/src/exppp/pretty_subtype.c +++ b/src/exppp/pretty_subtype.c @@ -10,25 +10,27 @@ #include "pretty_expr.h" #include "pretty_subtype.h" -void SUBTYPEout( Expression e ) { +void SUBTYPEout(Expression e) +{ /* language insists on having parens around entity names */ /* even if there is only one, but if the expression is */ /* complex, EXPRout will add on its own parens */ /* if (TYPEis_expression(e->type)) {*/ - raw( "( " ); + raw("( "); /* }*/ - EXPR_out( e, 0 ); + EXPR_out(e, 0); /* if (TYPEis_expression(e->type)) {*/ - raw( " )" ); + raw(" )"); /* }*/ } -char * SUBTYPEto_string( Expression e ) { - if( prep_string() ) { +char *SUBTYPEto_string(Expression e) +{ + if(prep_string()) { return placeholder; } - EXPR_out( e, 0 ); - return ( finish_string() ); + EXPR_out(e, 0); + return (finish_string()); } diff --git a/src/exppp/pretty_subtype.h b/src/exppp/pretty_subtype.h index 4ff6ef085..d938093b1 100644 --- a/src/exppp/pretty_subtype.h +++ b/src/exppp/pretty_subtype.h @@ -3,8 +3,8 @@ #include -char * SUBTYPEto_string( Expression e ); -void SUBTYPEout( Expression e ); +char *SUBTYPEto_string(Expression e); +void SUBTYPEout(Expression e); #endif /* PRETTY_SUBTYPE_H */ diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index d18402ddc..c6e7c580a 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -14,280 +14,293 @@ #include "pretty_type.h" /** print a type definition. I.e., a TYPE statement */ -void TYPE_out( Type t, int level ) { +void TYPE_out(Type t, int level) +{ first_newline(); - exppp_ref_info( &t->symbol ); + exppp_ref_info(&t->symbol); - raw( "%*sTYPE %s =", level, "", t->symbol.name ); - if( TYPEget_head( t ) ) { - wrap( " %s", TYPEget_name( TYPEget_head( t ) ) ); + raw("%*sTYPE %s =", level, "", t->symbol.name); + if(TYPEget_head(t)) { + wrap(" %s", TYPEget_name(TYPEget_head(t))); } else { - TYPE_body_out( t, level + exppp_nesting_indent ); + TYPE_body_out(t, level + exppp_nesting_indent); } - raw( ";\n" ); + raw(";\n"); - WHERE_out( t->where, level ); + WHERE_out(t->where, level); - raw( "%*sEND_TYPE;", level, "" ); - tail_comment( t->symbol.name ); + raw("%*sEND_TYPE;", level, ""); + tail_comment(t->symbol.name); } /** prints type description (preceded by a space). * I.e., the type of an attribute or other object */ -void TYPE_head_out( Type t, int level ) { - if( t->symbol.name ) { +void TYPE_head_out(Type t, int level) +{ + if(t->symbol.name) { int old_indent = indent2; - if( indent2 + ( int ) strlen( t->symbol.name ) > exppp_linelength ) { - indent2 = ( indent2 + level ) / 2; + if(indent2 + (int) strlen(t->symbol.name) > exppp_linelength) { + indent2 = (indent2 + level) / 2; } - wrap( " %s", t->symbol.name ); + wrap(" %s", t->symbol.name); indent2 = old_indent; } else { - TYPE_body_out( t, level ); + TYPE_body_out(t, level); } } -void TYPEunique_or_optional_out( TypeBody tb ) { - if( tb->flags.unique ) { - wrap( " UNIQUE" ); +void TYPEunique_or_optional_out(TypeBody tb) +{ + if(tb->flags.unique) { + wrap(" UNIQUE"); } - if( tb->flags.optional ) { - wrap( " OPTIONAL" ); + if(tb->flags.optional) { + wrap(" OPTIONAL"); } } -void TYPE_body_out( Type t, int level ) { +void TYPE_body_out(Type t, int level) +{ bool first_time = true; Expression expr; DictionaryEntry de; - TypeBody tb = TYPEget_body( t ); + TypeBody tb = TYPEget_body(t); - switch( tb->type ) { + switch(tb->type) { case integer_: - wrap( " INTEGER" ); + wrap(" INTEGER"); break; case real_: - wrap( " REAL" ); + wrap(" REAL"); break; case string_: - wrap( " STRING" ); + wrap(" STRING"); break; case binary_: - wrap( " BINARY" ); + wrap(" BINARY"); break; case boolean_: - wrap( " BOOLEAN" ); + wrap(" BOOLEAN"); break; case logical_: - wrap( " LOGICAL" ); + wrap(" LOGICAL"); break; case number_: - wrap( " NUMBER" ); + wrap(" NUMBER"); break; case entity_: - wrap( " %s", tb->entity->symbol.name ); + wrap(" %s", tb->entity->symbol.name); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch( tb->type ) { + switch(tb->type) { /* ignore the aggregate bounds for now */ case aggregate_: - wrap( " AGGREGATE" ); - if( tb->tag ) { - wrap( ":%s", tb->tag->symbol.name ); + wrap(" AGGREGATE"); + if(tb->tag) { + wrap(":%s", tb->tag->symbol.name); } - wrap( " OF" ); + wrap(" OF"); break; case array_: - wrap( " ARRAY" ); - EXPRbounds_out( tb ); - wrap( " OF" ); - TYPEunique_or_optional_out( tb ); + wrap(" ARRAY"); + EXPRbounds_out(tb); + wrap(" OF"); + TYPEunique_or_optional_out(tb); break; case bag_: - wrap( " BAG" ); - EXPRbounds_out( tb ); - wrap( " OF" ); + wrap(" BAG"); + EXPRbounds_out(tb); + wrap(" OF"); break; case set_: - wrap( " SET" ); - EXPRbounds_out( tb ); - wrap( " OF" ); + wrap(" SET"); + EXPRbounds_out(tb); + wrap(" OF"); break; case list_: - wrap( " LIST" ); - EXPRbounds_out( tb ); - wrap( " OF" ); - TYPEunique_or_optional_out( tb ); + wrap(" LIST"); + EXPRbounds_out(tb); + wrap(" OF"); + TYPEunique_or_optional_out(tb); break; default: - fprintf( stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__ ); + fprintf(stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__); abort(); } - TYPE_head_out( tb->base, level ); + TYPE_head_out(tb->base, level); break; case enumeration_: { int i, count = 0; - char ** names; + char **names; /* * write names out in original order by first bucket sorting * to a temporary array. This is trivial since all buckets * will get filled with one and only one object. */ - DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); - while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); + while(0 != (expr = (Expression)DICTdo(&de))) { count++; } - names = ( char ** )sc_malloc( count * sizeof( char * ) ); - DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); - while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + names = (char **)sc_malloc(count * sizeof(char *)); + DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); + while(0 != (expr = (Expression)DICTdo(&de))) { names[expr->u.integer - 1] = expr->symbol.name; } - wrap( " ENUMERATION OF\n" ); + wrap(" ENUMERATION OF\n"); - for( i = 0; i < count; i++ ) { + for(i = 0; i < count; i++) { /* finish line from previous enum item */ - if( !first_time ) { - raw( ",\n" ); + if(!first_time) { + raw(",\n"); } /* start new enum item */ - if( first_time ) { - raw( "%*s( ", level, "" ); + if(first_time) { + raw("%*s( ", level, ""); first_time = false; } else { - raw( "%*s ", level, "" ); + raw("%*s ", level, ""); } - raw( names[i] ); + raw(names[i]); } - raw( " )" ); - sc_free( ( char * )names ); + raw(" )"); + sc_free((char *)names); } break; case select_: - wrap( " SELECT\n" ); - LISTdo( tb->list, type, Type ) + wrap(" SELECT\n"); + LISTdo(tb->list, type, Type) /* finish line from previous entity */ - if( !first_time ) { - raw( ",\n" ); + if(!first_time) { + raw(",\n"); } /* start new entity */ - if( first_time ) { - raw( "%*s( ", level, "" ); + if(first_time) { + raw("%*s( ", level, ""); first_time = false; } else { - raw( "%*s ", level, "" ); + raw("%*s ", level, ""); } - raw( type->symbol.name ); + raw(type->symbol.name); LISTod /* if empty, force a left paren */ - if( first_time ) { - ERRORreport_with_symbol( SELECT_EMPTY, &error_sym, t->symbol.name ); - raw( "%*s( ", level, "" ); + if(first_time) { + ERRORreport_with_symbol(SELECT_EMPTY, &error_sym, t->symbol.name); + raw("%*s( ", level, ""); } - raw( " )" ); + raw(" )"); break; case generic_: - wrap( " GENERIC" ); - if( tb->tag ) { - wrap( ":%s", tb->tag->symbol.name ); + wrap(" GENERIC"); + if(tb->tag) { + wrap(":%s", tb->tag->symbol.name); } break; default: - wrap( " (* unknown type %d *)", tb->type ); + wrap(" (* unknown type %d *)", tb->type); } - if( tb->precision ) { - wrap( " ( " ); - EXPR_out( tb->precision, 0 ); - raw( " )" ); + if(tb->precision) { + wrap(" ( "); + EXPR_out(tb->precision, 0); + raw(" )"); } - if( tb->flags.fixed ) { - wrap( " FIXED" ); + if(tb->flags.fixed) { + wrap(" FIXED"); } } -char * TYPEto_string( Type t ) { - if( prep_string() ) { +char *TYPEto_string(Type t) +{ + if(prep_string()) { return placeholder; } - TYPE_out( t, 0 ); - return ( finish_string() ); + TYPE_out(t, 0); + return (finish_string()); } /** return length of buffer used */ -int TYPEto_buffer( Type t, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int TYPEto_buffer(Type t, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - TYPE_out( t, 0 ); - return( finish_buffer() ); + TYPE_out(t, 0); + return(finish_buffer()); } -void TYPEout( Type t ) { +void TYPEout(Type t) +{ prep_file(); - TYPE_out( t, 0 ); + TYPE_out(t, 0); finish_file(); } -char * TYPEhead_to_string( Type t ) { - if( prep_string() ) { +char *TYPEhead_to_string(Type t) +{ + if(prep_string()) { return placeholder; } - TYPE_head_out( t, 0 ); - return ( finish_string() ); + TYPE_head_out(t, 0); + return (finish_string()); } /** return length of buffer used */ -int TYPEhead_to_buffer( Type t, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int TYPEhead_to_buffer(Type t, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - TYPE_out( t, 0 ); - return( finish_buffer() ); + TYPE_out(t, 0); + return(finish_buffer()); } -void TYPEhead_out( Type t ) { +void TYPEhead_out(Type t) +{ prep_file(); - TYPE_head_out( t, 0 ); + TYPE_head_out(t, 0); finish_file(); } -char * TYPEbody_to_string( Type t ) { - if( prep_string() ) { +char *TYPEbody_to_string(Type t) +{ + if(prep_string()) { return placeholder; } - TYPE_body_out( t, 0 ); - return ( finish_string() ); + TYPE_body_out(t, 0); + return (finish_string()); } /** return length of buffer used */ -int TYPEbody_to_buffer( Type t, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int TYPEbody_to_buffer(Type t, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - TYPE_body_out( t, 0 ); - return( finish_buffer() ); + TYPE_body_out(t, 0); + return(finish_buffer()); } -void TYPEbody_out( Type t ) { +void TYPEbody_out(Type t) +{ prep_file(); - TYPE_body_out( t, 0 ); + TYPE_body_out(t, 0); finish_file(); } diff --git a/src/exppp/pretty_type.h b/src/exppp/pretty_type.h index 29101695b..91f788954 100644 --- a/src/exppp/pretty_type.h +++ b/src/exppp/pretty_type.h @@ -3,19 +3,19 @@ #include "../express/type.h" -char * TYPEbody_to_string( Type t ); -char * TYPEhead_to_string( Type t ); -char * TYPEto_string( Type t ); -void TYPE_body_out( Type t, int level ); -void TYPE_head_out( Type t, int level ); -void TYPE_out( Type t, int level ); -void TYPEbody_out( Type t ); -int TYPEbody_to_buffer( Type t, char * buffer, int length ); -void TYPEhead_out( Type t ); -int TYPEhead_to_buffer( Type t, char * buffer, int length ); -void TYPEout( Type t ); -int TYPEto_buffer( Type t, char * buffer, int length ); -void TYPEunique_or_optional_out( TypeBody tb ); +char *TYPEbody_to_string(Type t); +char *TYPEhead_to_string(Type t); +char *TYPEto_string(Type t); +void TYPE_body_out(Type t, int level); +void TYPE_head_out(Type t, int level); +void TYPE_out(Type t, int level); +void TYPEbody_out(Type t); +int TYPEbody_to_buffer(Type t, char *buffer, int length); +void TYPEhead_out(Type t); +int TYPEhead_to_buffer(Type t, char *buffer, int length); +void TYPEout(Type t); +int TYPEto_buffer(Type t, char *buffer, int length); +void TYPEunique_or_optional_out(TypeBody tb); #endif /* PRETTY_TYPE_H */ diff --git a/src/exppp/pretty_where.c b/src/exppp/pretty_where.c index b461baaa6..3aef4197c 100644 --- a/src/exppp/pretty_where.c +++ b/src/exppp/pretty_where.c @@ -10,65 +10,71 @@ #include "pretty_expr.h" #include "pretty_where.h" -char * WHEREto_string( Linked_List w ) { - if( prep_string() ) { +char *WHEREto_string(Linked_List w) +{ + if(prep_string()) { return placeholder; } - WHERE_out( w, 0 ); - return ( finish_string() ); + WHERE_out(w, 0); + return (finish_string()); } /** return length of buffer used */ -int WHEREto_buffer( Linked_List w, char * buffer, int length ) { - if( prep_buffer( buffer, length ) ) { +int WHEREto_buffer(Linked_List w, char *buffer, int length) +{ + if(prep_buffer(buffer, length)) { return -1; } - WHERE_out( w, 0 ); - return( finish_buffer() ); + WHERE_out(w, 0); + return(finish_buffer()); } -void WHEREout( Linked_List w ) { +void WHEREout(Linked_List w) +{ prep_file(); - WHERE_out( w, 0 ); + WHERE_out(w, 0); finish_file(); } -void WHERE_out( Linked_List wheres, int level ) { +void WHERE_out(Linked_List wheres, int level) +{ size_t max_indent; - if( !wheres ) { + if(!wheres) { return; } - raw( "%*s%s", level, "", "WHERE\n" ); + raw("%*s%s", level, "", "WHERE\n"); level += exppp_nesting_indent; /* pass 1: calculate length of longest label */ max_indent = 0; - LISTdo( wheres, w, Where ) { - if( w->label ) { - if( strlen( w->label->name ) > max_indent ) { - max_indent = strlen( w->label->name ); + LISTdo(wheres, w, Where) { + if(w->label) { + if(strlen(w->label->name) > max_indent) { + max_indent = strlen(w->label->name); } } - } LISTod + } + LISTod - if( max_indent > 10 ) { + if(max_indent > 10) { /* don't bother indenting completely for * labels that are ridiculously long */ max_indent = 4; } - indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; + indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; /* pass 2: now print labels and exprs */ - LISTdo( wheres, w, Where ) { - if( w->label ) { - raw( "%*s%-*s: ", level, "", max_indent, w->label->name ); + LISTdo(wheres, w, Where) { + if(w->label) { + raw("%*s%-*s: ", level, "", max_indent, w->label->name); } else { /* no label */ - raw( "%*s%-*s ", level, "", max_indent, "" ); + raw("%*s%-*s ", level, "", max_indent, ""); } - EXPR_out( w->expr, max_indent ); - raw( ";\n" ); - } LISTod + EXPR_out(w->expr, max_indent); + raw(";\n"); + } + LISTod } diff --git a/src/exppp/pretty_where.h b/src/exppp/pretty_where.h index 72d1a657a..68b5968ac 100644 --- a/src/exppp/pretty_where.h +++ b/src/exppp/pretty_where.h @@ -3,10 +3,10 @@ #include -void WHERE_out( Linked_List wheres, int level ); -void WHEREout( Linked_List w ); -int WHEREto_buffer( Linked_List w, char * buffer, int length ); -char * WHEREto_string( Linked_List w ); +void WHERE_out(Linked_List wheres, int level); +void WHEREout(Linked_List w); +int WHEREto_buffer(Linked_List w, char *buffer, int length); +char *WHEREto_string(Linked_List w); #endif /* PRETTY_WHERE_H */ diff --git a/src/exppp/test/test_breakLongStr.c b/src/exppp/test/test_breakLongStr.c index f93a5809d..0382b3667 100644 --- a/src/exppp/test/test_breakLongStr.c +++ b/src/exppp/test/test_breakLongStr.c @@ -2,8 +2,9 @@ #include "../pp.h" #include "exppp.h" -int main() { - char * testarr[] = { +int main() +{ + char *testarr[] = { "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION_RELATIONSHIP.RELATED_PRODUCT_DEFINITION", "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION" }; @@ -12,29 +13,29 @@ int main() { /* globals */ exppp_fp = stdout; exppp_linelength = 40; -/* - indent2 = 30; - curpos = 20; -*/ - for( i = 0; i < exppp_linelength + 10; i += 15 ) { - for( c = 2; c < exppp_linelength + 10; c += 13 ) { + /* + indent2 = 30; + curpos = 20; + */ + for(i = 0; i < exppp_linelength + 10; i += 15) { + for(c = 2; c < exppp_linelength + 10; c += 13) { curpos = c; indent2 = i; - raw( "indent2: %d, curpos: %d\n%*s||", i, c, c, "" ); - breakLongStr( testarr[0] ); + raw("indent2: %d, curpos: %d\n%*s||", i, c, c, ""); + breakLongStr(testarr[0]); curpos = c; indent2 = i; - raw( "\n%*s||", c, "" ); - breakLongStr( testarr[1] ); - raw( "\n" ); + raw("\n%*s||", c, ""); + breakLongStr(testarr[1]); + raw("\n"); } } curpos = 77; exppp_linelength = 130; indent2 = 17; - raw( "\n%*s||", 77, "" ); - breakLongStr( testarr[0] ); - raw( "\n" ); + raw("\n%*s||", 77, ""); + breakLongStr(testarr[0]); + raw("\n"); return EXIT_SUCCESS; } diff --git a/src/express/alg.c b/src/express/alg.c index 2211eff1a..f4966691e 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -48,10 +48,11 @@ struct freelist_head RULE_fl; struct freelist_head PROC_fl; struct freelist_head WHERE_fl; -Scope ALGcreate( char type ) { - Scope s = SCOPEcreate( type ); +Scope ALGcreate(char type) +{ + Scope s = SCOPEcreate(type); - switch( type ) { + switch(type) { case OBJ_PROCEDURE: s->u.proc = PROC_new(); break; @@ -73,11 +74,13 @@ Scope ALGcreate( char type ) { */ /** Initialize the Algorithm module. */ -void ALGinitialize( void ) { +void ALGinitialize(void) +{ } -void ALGput_full_text( Scope s, int start, int end ) { - switch( s->type ) { +void ALGput_full_text(Scope s, int start, int end) +{ + switch(s->type) { case OBJ_FUNCTION: s->u.func->text.filename = s->symbol.filename; s->u.func->text.start = start; diff --git a/src/express/alloc.c b/src/express/alloc.c index e20cfa943..4fae5d50e 100644 --- a/src/express/alloc.c +++ b/src/express/alloc.c @@ -49,10 +49,11 @@ Now you can say things like: * \param flh freelist head * \param bytes new memory size */ -Freelist * create_freelist( struct freelist_head * flh, int bytes ) { - Freelist * current = ( Freelist * )malloc( bytes ); - if( current == 0 ) { - return( 0 ); +Freelist *create_freelist(struct freelist_head *flh, int bytes) +{ + Freelist *current = (Freelist *)malloc(bytes); + if(current == 0) { + return(0); } flh->freelist = current; @@ -61,24 +62,25 @@ Freelist * create_freelist( struct freelist_head * flh, int bytes ) { flh->create++; /* set max to point to end of freelist */ - if( ( char * )flh->freelist + bytes > ( char * )flh->max ) { - flh->max = ( char * )flh->freelist + bytes; + if((char *)flh->freelist + bytes > (char *)flh->max) { + flh->max = (char *)flh->freelist + bytes; } #endif - while( ( char * )current + flh->size < - ( ( char * )flh->freelist + bytes ) ) { - current->next = ( Freelist * )( ¤t->memory + flh->size ); + while((char *)current + flh->size < + ((char *)flh->freelist + bytes)) { + current->next = (Freelist *)(¤t->memory + flh->size); current = current->next; } current->next = NULL; - return( current ); + return(current); } void -_ALLOCinitialize() { +_ALLOCinitialize() +{ #ifdef DEBUG_MALLOC - malloc_debug( 2 ); + malloc_debug(2); #endif } @@ -88,7 +90,8 @@ _ALLOCinitialize() { * \param alloc1 number to allocate initially * \param alloc2 number to allocate if we run out */ -void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) { +void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2) +{ flh->size_elt = size; /* kludge for calloc-like behavior */ #ifndef NOSTAT flh->alloc = flh->dealloc = flh->create = 0; @@ -96,7 +99,7 @@ void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, #endif /* make block large enough to hold the linked list pointer */ - flh->size = ( size > sizeof( Freelist * ) ? size : sizeof( Freelist * ) ); + flh->size = (size > sizeof(Freelist *) ? size : sizeof(Freelist *)); /* set up for future allocations */ flh->bytes = flh->size * alloc2; @@ -104,7 +107,7 @@ void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, return; /*NOTREACHED*/ #else - if( 0 == create_freelist( flh, flh->size * alloc1 ) ) { + if(0 == create_freelist(flh, flh->size * alloc1)) { ERRORnospace(); } @@ -115,7 +118,8 @@ void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, #endif } -void * ALLOC_new( struct freelist_head * flh ) { +void *ALLOC_new(struct freelist_head *flh) +{ void *obj; #ifndef NOSTAT @@ -123,10 +127,10 @@ void * ALLOC_new( struct freelist_head * flh ) { #endif #ifdef REAL_MALLOC - return( calloc( 1, flh->size_elt ) ); + return(calloc(1, flh->size_elt)); /*NOTREACHED*/ #else - if( flh->freelist == NULL && 0 == create_freelist( flh, flh->bytes ) ) { + if(flh->freelist == NULL && 0 == create_freelist(flh, flh->bytes)) { ERRORnospace(); } @@ -134,7 +138,7 @@ void * ALLOC_new( struct freelist_head * flh ) { flh->freelist = flh->freelist->next; #ifndef NOSTAT - if( obj > flh->max ) { + if(obj > flh->max) { abort(); } #endif @@ -144,19 +148,20 @@ void * ALLOC_new( struct freelist_head * flh ) { #endif /*SPACE_PROFILE*/ /* calloc-like */ - memset( obj, 0, flh->size_elt ); + memset(obj, 0, flh->size_elt); - return( obj ); + return(obj); #endif } -void ALLOC_destroy( struct freelist_head * flh, Freelist * link ) { +void ALLOC_destroy(struct freelist_head *flh, Freelist *link) +{ #ifndef NOSTAT flh->dealloc++; #endif #ifdef REAL_MALLOC - free( link ); + free(link); return; /*NOTREACHED*/ #else @@ -181,34 +186,35 @@ struct oct { char a[16]; }; -main() { - struct oct * o1, *o2, *o3, *o4, *o5, *o6; +main() +{ + struct oct *o1, *o2, *o3, *o4, *o5, *o6; - memory_init( &oct_freelist, sizeof( struct oct ), 5, 2 ); + memory_init(&oct_freelist, sizeof(struct oct), 5, 2); o1 = new_oct(); - fprintf( stderr, "o1 = %x\n", o1 ); + fprintf(stderr, "o1 = %x\n", o1); o2 = new_oct(); - fprintf( stderr, "o2 = %x\n", o2 ); + fprintf(stderr, "o2 = %x\n", o2); o3 = new_oct(); - fprintf( stderr, "o3 = %x\n", o3 ); + fprintf(stderr, "o3 = %x\n", o3); o4 = new_oct(); - fprintf( stderr, "o4 = %x\n", o4 ); + fprintf(stderr, "o4 = %x\n", o4); o5 = new_oct(); - fprintf( stderr, "o5 = %x\n", o5 ); + fprintf(stderr, "o5 = %x\n", o5); o6 = new_oct(); - fprintf( stderr, "o6 = %x\n", o6 ); - destroy_oct( o1 ); - destroy_oct( o2 ); + fprintf(stderr, "o6 = %x\n", o6); + destroy_oct(o1); + destroy_oct(o2); o1 = new_oct(); - fprintf( stderr, "o1 = %x\n", o1 ); + fprintf(stderr, "o1 = %x\n", o1); o2 = new_oct(); - fprintf( stderr, "o2 = %x\n", o2 ); + fprintf(stderr, "o2 = %x\n", o2); o3 = new_oct(); - fprintf( stderr, "o3 = %x\n", o3 ); + fprintf(stderr, "o3 = %x\n", o3); o4 = new_oct(); - fprintf( stderr, "o4 = %x\n", o4 ); + fprintf(stderr, "o4 = %x\n", o4); o5 = new_oct(); - fprintf( stderr, "o5 = %x\n", o5 ); + fprintf(stderr, "o5 = %x\n", o5); } #endif /*ALLOC_MAIN*/ diff --git a/src/express/caseitem.c b/src/express/caseitem.c index fe8aa460f..67a06d4e8 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -34,7 +34,8 @@ /** Initialize the Case Item module. */ void -CASE_ITinitialize( void ) { +CASE_ITinitialize(void) +{ } /** @@ -47,10 +48,11 @@ CASE_ITinitialize( void ) { ** \note If the 'labels' parameter is LIST_NULL, a case item ** matching in the default case is created. */ -Case_Item CASE_ITcreate( Linked_List labels, Statement statement ) { +Case_Item CASE_ITcreate(Linked_List labels, Statement statement) +{ struct Case_Item_ *s = CASE_IT_new(); s->labels = labels; s->action = statement; - return( s ); + return(s); } diff --git a/src/express/dict.c b/src/express/dict.c index 69d8d1dd8..506daf473 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -39,25 +39,28 @@ char DICT_type; /**< set to type of object found, as a side-effect of DICT lookup routines */ -void DICTprint( Dictionary dict ) { +void DICTprint(Dictionary dict) +{ Element e; DictionaryEntry de; - HASHlistinit( dict, &de ); + HASHlistinit(dict, &de); - while( 0 != ( e = ( HASHlist( &de ) ) ) ) { - fprintf( stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", + while(0 != (e = (HASHlist(&de)))) { + fprintf(stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", e->key, e->data, e->symbol->line, e->type, - OBJget_type( e->type ), e->symbol->filename ); + OBJget_type(e->type), e->symbol->filename); } } /** Initialize the Dictionary module */ -void DICTinitialize( void ) { +void DICTinitialize(void) +{ } /** Clean up the Dictionary module */ -void DICTcleanup( void ) { +void DICTcleanup(void) +{ } /** @@ -65,7 +68,8 @@ void DICTcleanup( void ) { * error directly if there is a duplicate value. * \return 0 on success, 1 on failure */ -int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { +int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) +{ struct Element_ new, *old; new.key = name; @@ -73,8 +77,8 @@ int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type new.symbol = sym; new.type = type; - if( 0 == ( old = HASHsearch( dict, &new, HASH_INSERT ) ) ) { - return( 0 ); + if(0 == (old = HASHsearch(dict, &new, HASH_INSERT))) { + return(0); } /* allow multiple definitions of an enumeration id in its @@ -87,20 +91,20 @@ int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type * to have the same name. To fix this, I replaced the * || with && in the else-if below. */ - if( ( type == OBJ_ENUM ) && ( old->type == OBJ_ENUM ) ) { + if((type == OBJ_ENUM) && (old->type == OBJ_ENUM)) { /* if we're adding an enum, but we've already seen one */ /* (and only one enum), mark it ambiguous */ - DICTchange_type( old, OBJ_AMBIG_ENUM ); - } else if( ( type != OBJ_ENUM ) && ( !IS_ENUM( old->type ) ) ) { + DICTchange_type(old, OBJ_AMBIG_ENUM); + } else if((type != OBJ_ENUM) && (!IS_ENUM(old->type))) { /* if we're adding a non-enum, and we've * * already added a non-enum, complain */ - if( sym->filename == old->symbol->filename ) { - ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, old->symbol->line ); + if(sym->filename == old->symbol->filename) { + ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, old->symbol->line); } else { - ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename ); + ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename); } ERRORreport(SUBORDINATE_FAILED); - return( 1 ); + return(1); } return 0; } @@ -113,7 +117,8 @@ int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type * their unusual behavior with respect to scoping and visibility rules * \sa DICTdefine() */ -int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { +int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) +{ struct Element_ e, *e2; e.key = name; @@ -121,17 +126,17 @@ int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char typ e.symbol = sym; e.type = type; - if( 0 == ( e2 = HASHsearch( dict, &e, HASH_INSERT ) ) ) { - return( 0 ); + if(0 == (e2 = HASHsearch(dict, &e, HASH_INSERT))) { + return(0); } - if( sym->filename == e2->symbol->filename ) { - ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, e2->symbol->line ); + if(sym->filename == e2->symbol->filename) { + ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, e2->symbol->line); } else { - ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename ); + ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename); } ERRORreport(SUBORDINATE_FAILED); - return( 1 ); + return(1); } /** @@ -141,11 +146,12 @@ int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char typ Changed to return void, since the hash code frees the element, there is no way to return (without godawful casting) the generic itself. */ -void DICTundefine( Dictionary dict, char * name ) { +void DICTundefine(Dictionary dict, char *name) +{ struct Element_ e; e.key = name; - HASHsearch( dict, &e, HASH_DELETE ); + HASHsearch(dict, &e, HASH_DELETE); } /** @@ -153,44 +159,47 @@ void DICTundefine( Dictionary dict, char * name ) { ** \param name name to look up ** \return the value found, NULL if not found */ -void *DICTlookup( Dictionary dictionary, char * name ) { +void *DICTlookup(Dictionary dictionary, char *name) +{ struct Element_ e, *ep; - if( !dictionary ) { + if(!dictionary) { return 0; } e.key = name; - ep = HASHsearch( dictionary, &e, HASH_FIND ); - if( ep ) { + ep = HASHsearch(dictionary, &e, HASH_FIND); + if(ep) { DICT_type = ep->type; - return( ep->data ); + return(ep->data); } - return( NULL ); + return(NULL); } /** like DICTlookup but returns symbol, too * \sa DICTlookup() */ -void *DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { +void *DICTlookup_symbol(Dictionary dictionary, char *name, Symbol **sym) +{ struct Element_ e, *ep; - if( !dictionary ) { + if(!dictionary) { return 0; } e.key = name; - ep = HASHsearch( dictionary, &e, HASH_FIND ); - if( ep ) { + ep = HASHsearch(dictionary, &e, HASH_FIND); + if(ep) { DICT_type = ep->type; *sym = ep->symbol; - return( ep->data ); + return(ep->data); } - return( NULL ); + return(NULL); } -void *DICTdo( DictionaryEntry * dict_entry ) { - if( 0 == HASHlist( dict_entry ) ) { +void *DICTdo(DictionaryEntry *dict_entry) +{ + if(0 == HASHlist(dict_entry)) { return 0; } diff --git a/src/express/entity.c b/src/express/entity.c index 507b2c23f..506f0450a 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -120,9 +120,10 @@ int ENTITY_MARK = 0; /** returns true if variable is declared (or redeclared) directly by entity */ -int ENTITYdeclares_variable( Entity e, Variable v ) { - LISTdo( e->u.entity->attributes, attr, Variable ) - if( attr == v ) { +int ENTITYdeclares_variable(Entity e, Variable v) +{ + LISTdo(e->u.entity->attributes, attr, Variable) + if(attr == v) { return true; } LISTod; @@ -130,7 +131,8 @@ int ENTITYdeclares_variable( Entity e, Variable v ) { return false; } -static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down ) { +static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) +{ Entity result; /* avoid searching scopes that we've already searched */ @@ -138,34 +140,34 @@ static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if( entity->search_id == __SCOPE_search_id ) { + if(entity->search_id == __SCOPE_search_id) { return NULL; } entity->search_id = __SCOPE_search_id; - LISTdo( entity->u.entity->supertypes, super, Entity ) - if( !strcmp( super->symbol.name, name ) ) { + LISTdo(entity->u.entity->supertypes, super, Entity) + if(!strcmp(super->symbol.name, name)) { return super; } LISTod - LISTdo( entity->u.entity->supertypes, super, Entity ) - result = ENTITY_find_inherited_entity( super, name, down ); - if( result ) { + LISTdo(entity->u.entity->supertypes, super, Entity) + result = ENTITY_find_inherited_entity(super, name, down); + if(result) { return result; } LISTod; - if( down ) { - LISTdo( entity->u.entity->subtypes, sub, Entity ) - if( !strcmp( sub->symbol.name, name ) ) { + if(down) { + LISTdo(entity->u.entity->subtypes, sub, Entity) + if(!strcmp(sub->symbol.name, name)) { return sub; } LISTod; - LISTdo( entity->u.entity->subtypes, sub, Entity ) - result = ENTITY_find_inherited_entity( sub, name, down ); - if( result ) { + LISTdo(entity->u.entity->subtypes, sub, Entity) + result = ENTITY_find_inherited_entity(sub, name, down); + if(result) { return result; } LISTod; @@ -174,17 +176,19 @@ static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down return 0; } -struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { - if( !strcmp( name, entity->symbol.name ) ) { - return( entity ); +struct Scope_ *ENTITYfind_inherited_entity(struct Scope_ *entity, char *name, int down) +{ + if(!strcmp(name, entity->symbol.name)) { + return(entity); } __SCOPE_search_id++; - return ENTITY_find_inherited_entity( entity, name, down ); + return ENTITY_find_inherited_entity(entity, name, down); } /** find a (possibly inherited) attribute */ -Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct Symbol_ ** where ) { +Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, struct Symbol_ **where) +{ Variable result; /* avoid searching scopes that we've already searched */ @@ -192,34 +196,34 @@ Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if( entity->search_id == __SCOPE_search_id ) { + if(entity->search_id == __SCOPE_search_id) { return NULL; } entity->search_id = __SCOPE_search_id; /* first look locally */ - result = ( Variable )DICTlookup( entity->symbol_table, name ); - if( result ) { - if( down && *down && where ) { + result = (Variable)DICTlookup(entity->symbol_table, name); + if(result) { + if(down && *down && where) { *where = &entity->symbol; } return result; } /* check supertypes */ - LISTdo( entity->u.entity->supertypes, super, Entity ) - result = ENTITY_find_inherited_attribute( super, name, down, where ); - if( result ) { + LISTdo(entity->u.entity->supertypes, super, Entity) + result = ENTITY_find_inherited_attribute(super, name, down, where); + if(result) { return result; } LISTod; /* check subtypes, if requested */ - if( down ) { + if(down) { ++*down; - LISTdo( entity->u.entity->subtypes, sub, Entity ) - result = ENTITY_find_inherited_attribute( sub, name, down, where ); - if( result ) { + LISTdo(entity->u.entity->subtypes, sub, Entity) + result = ENTITY_find_inherited_attribute(sub, name, down, where); + if(result) { return result; } LISTod; @@ -229,52 +233,54 @@ Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down return 0; } -Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, - struct Symbol_ ** down_sym ) { +Variable ENTITYfind_inherited_attribute(struct Scope_ *entity, char *name, + struct Symbol_ **down_sym) +{ extern int __SCOPE_search_id; int down_flag = 0; __SCOPE_search_id++; - if( down_sym ) { - return ENTITY_find_inherited_attribute( entity, name, &down_flag, down_sym ); + if(down_sym) { + return ENTITY_find_inherited_attribute(entity, name, &down_flag, down_sym); } else { - return ENTITY_find_inherited_attribute( entity, name, 0, 0 ); + return ENTITY_find_inherited_attribute(entity, name, 0, 0); } } /** resolve a (possibly group-qualified) attribute ref. * report errors as appropriate */ -Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { +Variable ENTITYresolve_attr_ref(Entity e, Symbol *grp_ref, Symbol *attr_ref) +{ Entity ref_entity; Variable attr; struct Symbol_ *where; - if( grp_ref ) { + if(grp_ref) { /* use entity provided in group reference */ - ref_entity = ENTITYfind_inherited_entity( e, grp_ref->name, 0 ); - if( !ref_entity ) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name ); + ref_entity = ENTITYfind_inherited_entity(e, grp_ref->name, 0); + if(!ref_entity) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name); return 0; } - attr = ( Variable )DICTlookup( ref_entity->symbol_table, - attr_ref->name ); - if( !attr ) { + attr = (Variable)DICTlookup(ref_entity->symbol_table, + attr_ref->name); + if(!attr) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, attr_ref, attr_ref->name, - ref_entity->symbol.name ); + ref_entity->symbol.name); /* resolve_failed(e);*/ } } else { /* no entity provided, look through supertype chain */ where = NULL; - attr = ENTITYfind_inherited_attribute( e, attr_ref->name, &where ); - if( !attr /* was ref_entity? */ ) { + attr = ENTITYfind_inherited_attribute(e, attr_ref->name, &where); + if(!attr /* was ref_entity? */) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, - attr_ref, attr_ref->name, - e->symbol.name ); - } else if( where != NULL ) { + attr_ref, attr_ref->name, + e->symbol.name); + } else if(where != NULL) { ERRORreport_with_symbol(IMPLICIT_DOWNCAST, attr_ref, - where->name ); + where->name); } } return attr; @@ -284,7 +290,8 @@ Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) * currently, this is only used by USEresolve * low-level function for type Entity */ -Entity ENTITYcopy( Entity e ) { +Entity ENTITYcopy(Entity e) +{ /* for now, do a totally shallow copy */ Entity e2 = SCOPE_new(); *e2 = *e; @@ -292,7 +299,8 @@ Entity ENTITYcopy( Entity e ) { } /** Initialize the Entity module. */ -void ENTITYinitialize() { +void ENTITYinitialize() +{ } /** @@ -300,21 +308,22 @@ void ENTITYinitialize() { ** \param attr attribute to add ** Add an attribute to an entity. */ -void ENTITYadd_attribute( Entity entity, Variable attr ) { +void ENTITYadd_attribute(Entity entity, Variable attr) +{ int rc; - if( attr->name->type->u.type->body->type != op_ ) { + if(attr->name->type->u.type->body->type != op_) { /* simple id */ - rc = DICTdefine( entity->symbol_table, attr->name->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE ); + rc = DICTdefine(entity->symbol_table, attr->name->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE); } else { /* SELF\ENTITY.SIMPLE_ID */ - rc = DICTdefine( entity->symbol_table, attr->name->e.op2->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE ); + rc = DICTdefine(entity->symbol_table, attr->name->e.op2->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE); } - if( rc == 0 ) { - LISTadd_last( entity->u.entity->attributes, attr ); - VARput_offset( attr, entity->u.entity->attribute_count ); + if(rc == 0) { + LISTadd_last(entity->u.entity->attributes, attr); + VARput_offset(attr, entity->u.entity->attribute_count); entity->u.entity->attribute_count++; } } @@ -324,11 +333,12 @@ void ENTITYadd_attribute( Entity entity, Variable attr ) { ** \param instance new instance ** Add an item to the instance list of an entity. */ -void ENTITYadd_instance( Entity entity, void *instance ) { - if( entity->u.entity->instances == LIST_NULL ) { +void ENTITYadd_instance(Entity entity, void *instance) +{ + if(entity->u.entity->instances == LIST_NULL) { entity->u.entity->instances = LISTcreate(); } - LISTadd_last( entity->u.entity->instances, instance ); + LISTadd_last(entity->u.entity->instances, instance); } /** @@ -337,12 +347,13 @@ void ENTITYadd_instance( Entity entity, void *instance ) { ** \return does child's superclass chain include parent? ** Look for a certain entity in the supertype graph of an entity. */ -bool ENTITYhas_supertype( Entity child, Entity parent ) { - LISTdo( child->u.entity->supertypes, entity, Entity ) - if( entity == parent ) { +bool ENTITYhas_supertype(Entity child, Entity parent) +{ + LISTdo(child->u.entity->supertypes, entity, Entity) + if(entity == parent) { return true; } - if( ENTITYhas_supertype( entity, parent ) ) { + if(ENTITYhas_supertype(entity, parent)) { return true; } LISTod; @@ -355,9 +366,10 @@ bool ENTITYhas_supertype( Entity child, Entity parent ) { ** \return is parent a direct supertype of child? ** Check whether an entity has a specific immediate superclass. */ -bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) { - LISTdo( child->u.entity->supertypes, entity, Entity ) - if( entity == parent ) { +bool ENTITYhas_immediate_supertype(Entity child, Entity parent) +{ + LISTdo(child->u.entity->supertypes, entity, Entity) + if(entity == parent) { return true; } LISTod; @@ -365,14 +377,15 @@ bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) { } /** called by ENTITYget_all_attributes(). \sa ENTITYget_all_attributes */ -static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) { - LISTdo( entity->u.entity->supertypes, super, Entity ) +static void ENTITY_get_all_attributes(Entity entity, Linked_List result) +{ + LISTdo(entity->u.entity->supertypes, super, Entity) /* if (OBJis_kind_of(super, Class_Entity))*/ - ENTITY_get_all_attributes( super, result ); + ENTITY_get_all_attributes(super, result); LISTod; /* Gee, aren't they resolved by this time? */ - LISTdo( entity->u.entity->attributes, attr, void * ) - LISTadd_last( result, attr ); + LISTdo(entity->u.entity->attributes, attr, void *) + LISTadd_last(result, attr); LISTod; } @@ -387,10 +400,11 @@ static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) { ** attributes, this call returns an empty list. Note ** that this is distinct from the constant LIST_NULL. */ -Linked_List ENTITYget_all_attributes( Entity entity ) { +Linked_List ENTITYget_all_attributes(Entity entity) +{ Linked_List result = LISTcreate(); - ENTITY_get_all_attributes( entity, result ); + ENTITY_get_all_attributes(entity, result); return result; } @@ -403,18 +417,19 @@ Linked_List ENTITYget_all_attributes( Entity entity ) { ** \note If the entity has no attribute with the given name, ** VARIABLE_NULL is returned. */ -Variable ENTITYget_named_attribute( Entity entity, char * name ) { +Variable ENTITYget_named_attribute(Entity entity, char *name) +{ Variable attribute; - LISTdo( entity->u.entity->attributes, attr, Variable ) - if( !strcmp( VARget_simple_name( attr ), name ) ) { + LISTdo(entity->u.entity->attributes, attr, Variable) + if(!strcmp(VARget_simple_name(attr), name)) { return attr; } LISTod; - LISTdo( entity->u.entity->supertypes, super, Entity ) + LISTdo(entity->u.entity->supertypes, super, Entity) /* if (OBJis_kind_of(super, Class_Entity) && */ - if( 0 != ( attribute = ENTITYget_named_attribute( super, name ) ) ) { + if(0 != (attribute = ENTITYget_named_attribute(super, name))) { return attribute; } LISTod; @@ -430,22 +445,23 @@ Variable ENTITYget_named_attribute( Entity entity, char * name ) { ** \note If the entity does not include the attribute, -1 ** is returned. */ -int ENTITYget_attribute_offset( Entity entity, Variable attribute ) { +int ENTITYget_attribute_offset(Entity entity, Variable attribute) +{ int offset; int value; - LISTdo( entity->u.entity->attributes, attr, Variable ) - if( attr == attribute ) { - return entity->u.entity->inheritance + VARget_offset( attribute ); + LISTdo(entity->u.entity->attributes, attr, Variable) + if(attr == attribute) { + return entity->u.entity->inheritance + VARget_offset(attribute); } LISTod; offset = 0; - LISTdo( entity->u.entity->supertypes, super, Entity ) + LISTdo(entity->u.entity->supertypes, super, Entity) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if( ( value = ENTITYget_attribute_offset( super, attribute ) ) != -1 ) { + if((value = ENTITYget_attribute_offset(super, attribute)) != -1) { return value + offset; } - offset += ENTITYget_initial_offset( super ); + offset += ENTITYget_initial_offset(super); /* }*/ LISTod; return -1; @@ -460,22 +476,23 @@ int ENTITYget_attribute_offset( Entity entity, Variable attribute ) { ** \note If the entity has no attribute with the given name, ** -1 is returned. */ -int ENTITYget_named_attribute_offset( Entity entity, char * name ) { +int ENTITYget_named_attribute_offset(Entity entity, char *name) +{ int offset; int value; - LISTdo( entity->u.entity->attributes, attr, Variable ) - if( !strcmp( VARget_simple_name( attr ), name ) ) + LISTdo(entity->u.entity->attributes, attr, Variable) + if(!strcmp(VARget_simple_name(attr), name)) return entity->u.entity->inheritance + - VARget_offset( ENTITY_find_inherited_attribute( entity, name, 0, 0 ) ); + VARget_offset(ENTITY_find_inherited_attribute(entity, name, 0, 0)); LISTod; offset = 0; - LISTdo( entity->u.entity->supertypes, super, Entity ) + LISTdo(entity->u.entity->supertypes, super, Entity) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if( ( value = ENTITYget_named_attribute_offset( super, name ) ) != -1 ) { + if((value = ENTITYget_named_attribute_offset(super, name)) != -1) { return value + offset; } - offset += ENTITYget_initial_offset( super ); + offset += ENTITYget_initial_offset(super); /* }*/ LISTod; return -1; @@ -486,6 +503,7 @@ int ENTITYget_named_attribute_offset( Entity entity, char * name ) { ** \return number of inherited attributes ** Retrieve the initial offset to an entity's local frame. */ -int ENTITYget_initial_offset( Entity entity ) { +int ENTITYget_initial_offset(Entity entity) +{ return entity->u.entity->inheritance; } diff --git a/src/express/error.c b/src/express/error.c index 04bcc4154..5d47a8e57 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -98,8 +98,10 @@ static struct Error_ LibErrors[] = { [FILE_UNREADABLE] = {SEVERITY_ERROR, "Could not read file %s: %s", NULL, false}, [FILE_UNWRITABLE] = {SEVERITY_ERROR, "Could not write file %s: %s", NULL, false}, [WARN_UNSUPPORTED_LANG_FEAT] = {SEVERITY_WARNING, "Unsupported language feature (%s) at %s:%d", "unsupported", false}, - [WARN_SMALL_REAL] = {SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " - "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false}, + [WARN_SMALL_REAL] = { + SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " + "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false + }, /* lexact.c */ [INCLUDE_FILE] = {SEVERITY_ERROR, "Could not open include file `%s'.", NULL, false}, [UNMATCHED_CLOSE_COMMENT] = {SEVERITY_ERROR, "unmatched close comment", NULL, false}, @@ -157,7 +159,7 @@ static struct Error_ LibErrors[] = { bool __ERROR_buffer_errors = false; -const char * current_filename = "stdin"; +const char *current_filename = "stdin"; /* flag to remember whether non-warning errors have occurred */ bool ERRORoccurred = false; @@ -174,7 +176,7 @@ int malloc_debug_resolve = 0; /* for debugging yacc/lex */ int debug = 0; -void ( *ERRORusage_function )( void ); +void (*ERRORusage_function)(void); #define ERROR_MAX_ERRORS 100 /**< max line-numbered errors */ #define ERROR_MAX_SPACE 4000 /**< max space for line-numbered errors */ @@ -185,16 +187,16 @@ void ( *ERRORusage_function )( void ); static struct heap_element { int line; - char * msg; + char *msg; } heap[ERROR_MAX_ERRORS + 1]; /**< NOTE! element 0 is purposely ignored, and * an additional element is at the end. This * allows the later heap calculations to be * much simpler */ static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */ -static char * ERROR_string; -static char * ERROR_string_base; -static char * ERROR_string_end; +static char *ERROR_string; +static char *ERROR_string_base; +static char *ERROR_string_end; static bool ERROR_unsafe = false; static jmp_buf ERROR_safe_env; @@ -202,8 +204,9 @@ static jmp_buf ERROR_safe_env; #define error_file stderr /**< message buffer file */ -static int ERROR_vprintf( const char *format, va_list ap ) { - int result = vsnprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); +static int ERROR_vprintf(const char *format, va_list ap) +{ + int result = vsnprintf(ERROR_string, ERROR_string_end - ERROR_string, format, ap); if(result < 0) { ERROR_string = ERROR_string_end; @@ -215,102 +218,109 @@ static int ERROR_vprintf( const char *format, va_list ap ) { return result; } -static int ERROR_printf( const char *format, ... ) { +static int ERROR_printf(const char *format, ...) +{ int result; va_list ap; - va_start( ap, format ); - result = ERROR_vprintf( format, ap ); - va_end( ap ); + va_start(ap, format); + result = ERROR_vprintf(format, ap); + va_end(ap); return result; } -static void ERROR_nexterror() { - if( ERROR_string == ERROR_string_end ) { +static void ERROR_nexterror() +{ + if(ERROR_string == ERROR_string_end) { return; } ERROR_string++; } /** Initialize the Error module */ -void ERRORinitialize( void ) { - ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); +void ERRORinitialize(void) +{ + ERROR_string_base = (char *)sc_malloc(ERROR_MAX_SPACE); ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); #ifdef SIGQUIT - signal( SIGQUIT, ERRORabort ); + signal(SIGQUIT, ERRORabort); #endif #ifdef SIGBUS - signal( SIGBUS, ERRORabort ); + signal(SIGBUS, ERRORabort); #endif #ifdef SIGSEGV - signal( SIGSEGV, ERRORabort ); + signal(SIGSEGV, ERRORabort); #endif #ifdef SIGABRT - signal( SIGABRT, ERRORabort ); + signal(SIGABRT, ERRORabort); #endif } /** Clean up the Error module */ -void ERRORcleanup( void ) { - sc_free( ERROR_string_base ); +void ERRORcleanup(void) +{ + sc_free(ERROR_string_base); } -void ERRORset_warning(char * name, bool warn_only) { +void ERRORset_warning(char *name, bool warn_only) +{ Error err; bool found = false; - - for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if (err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { + if(err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { found = true; err->override = warn_only; } - } - - if (!found) { - fprintf( stderr, "unknown warning: %s\n", name ); - if( ERRORusage_function ) { - ( *ERRORusage_function )(); + } + + if(!found) { + fprintf(stderr, "unknown warning: %s\n", name); + if(ERRORusage_function) { + (*ERRORusage_function)(); } else { EXPRESSusage(1); } } } -void ERRORset_all_warnings( bool warn_only ) { +void ERRORset_all_warnings(bool warn_only) +{ Error err; - - for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if (err->severity <= SEVERITY_WARNING) { + if(err->severity <= SEVERITY_WARNING) { err->override = warn_only; - } - } + } + } } -char * ERRORget_warnings_help(const char* prefix, const char *eol) { +char *ERRORget_warnings_help(const char *prefix, const char *eol) +{ unsigned int sz = 2048, len, clen; char *buf, *nbuf; Error err; - + clen = strlen(prefix) + strlen(eol) + 1; - + buf = sc_malloc(sz); - if (!buf) { + if(!buf) { fprintf(error_file, "failed to allocate memory for warnings help!\n"); } buf[0] = '\0'; - - for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if (err->name) { + if(err->name) { len = strlen(buf) + strlen(err->name) + clen; - if (len > sz) { + if(len > sz) { sz *= 2; nbuf = sc_realloc(buf, sz); - if (!nbuf) { - fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); + if(!nbuf) { + fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); } buf = nbuf; } @@ -319,12 +329,13 @@ char * ERRORget_warnings_help(const char* prefix, const char *eol) { strcat(buf, eol); } } - + return buf; } bool -ERRORis_enabled(enum ErrorCode errnum) { +ERRORis_enabled(enum ErrorCode errnum) +{ Error err = &LibErrors[errnum]; return !err->override; } @@ -338,33 +349,34 @@ ERRORis_enabled(enum ErrorCode errnum) { ** format fields of the message generated by 'what.' */ void -ERRORreport( enum ErrorCode errnum, ... ) { +ERRORreport(enum ErrorCode errnum, ...) +{ va_list args; - va_start( args, errnum ); + va_start(args, errnum); Error what = &LibErrors[errnum]; - if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum) ) { - if( what->severity >= SEVERITY_ERROR ) { - fprintf( error_file, "ERROR PE%03d: ", errnum ); - vfprintf( error_file, what->message, args ); - fputc( '\n', error_file ); + if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { + if(what->severity >= SEVERITY_ERROR) { + fprintf(error_file, "ERROR PE%03d: ", errnum); + vfprintf(error_file, what->message, args); + fputc('\n', error_file); ERRORoccurred = true; } else { - fprintf( error_file, "WARNING PW%03d: %d", errnum, what->severity ); - vfprintf( error_file, what->message, args ); - fputc( '\n', error_file ); + fprintf(error_file, "WARNING PW%03d: %d", errnum, what->severity); + vfprintf(error_file, what->message, args); + fputc('\n', error_file); } - if( what->severity >= SEVERITY_EXIT ) { + if(what->severity >= SEVERITY_EXIT) { ERROR_flush_message_buffer(); - if( what->severity >= SEVERITY_DUMP ) { + if(what->severity >= SEVERITY_DUMP) { abort(); } else { - exit( EXPRESS_fail( ( Express )0 ) ); + exit(EXPRESS_fail((Express)0)); } } } - va_end( args ); + va_end(args); } /** @@ -377,10 +389,11 @@ ERRORreport( enum ErrorCode errnum, ... ) { ** format fields of the message generated by 'what.' */ void -ERRORreport_with_line( enum ErrorCode errnum, int line, ... ) { +ERRORreport_with_line(enum ErrorCode errnum, int line, ...) +{ Symbol sym; va_list args; - va_start( args, line ); + va_start(args, line); sym.filename = current_filename; sym.line = line; @@ -388,13 +401,14 @@ ERRORreport_with_line( enum ErrorCode errnum, int line, ... ) { } void -ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { +ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) +{ va_list args; - va_start( args, sym ); + va_start(args, sym); Error what = &LibErrors[errnum]; - if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { - if( __ERROR_buffer_errors ) { + if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { + if(__ERROR_buffer_errors) { int child, parent; /* @@ -406,8 +420,8 @@ ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { child = ++ERROR_with_lines; parent = child / 2; - while( parent ) { - if( sym->line < heap[parent].line ) { + while(parent) { + if(sym->line < heap[parent].line) { heap[child] = heap[parent]; } else { break; @@ -418,52 +432,53 @@ ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { heap[child].line = sym->line; heap[child].msg = ERROR_string; - if( what->severity >= SEVERITY_ERROR ) { - ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); - ERROR_vprintf( what->message, args ); + if(what->severity >= SEVERITY_ERROR) { + ERROR_printf("%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); + ERROR_vprintf(what->message, args); ERROR_nexterror(); ERRORoccurred = true; } else { - ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); - ERROR_vprintf( what->message, args ); + ERROR_printf("%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); + ERROR_vprintf(what->message, args); ERROR_nexterror(); } - if( what->severity >= SEVERITY_EXIT || + if(what->severity >= SEVERITY_EXIT || ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE || - ERROR_with_lines == ERROR_MAX_ERRORS ) { + ERROR_with_lines == ERROR_MAX_ERRORS) { ERROR_flush_message_buffer(); - if( what->severity >= SEVERITY_DUMP ) { + if(what->severity >= SEVERITY_DUMP) { abort(); } else { - exit( EXPRESS_fail( ( Express )0 ) ); + exit(EXPRESS_fail((Express)0)); } } } else { - if( what->severity >= SEVERITY_ERROR ) { - fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); - vfprintf( error_file, what->message, args ); - fprintf( error_file, "\n" ); + if(what->severity >= SEVERITY_ERROR) { + fprintf(error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); + vfprintf(error_file, what->message, args); + fprintf(error_file, "\n"); ERRORoccurred = true; } else { - fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); - vfprintf( error_file, what->message, args ); - fprintf( error_file, "\n" ); + fprintf(error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); + vfprintf(error_file, what->message, args); + fprintf(error_file, "\n"); } - if( what->severity >= SEVERITY_EXIT ) { - if( what->severity >= SEVERITY_DUMP ) { + if(what->severity >= SEVERITY_EXIT) { + if(what->severity >= SEVERITY_DUMP) { abort(); } else { - exit( EXPRESS_fail( ( Express )0 ) ); + exit(EXPRESS_fail((Express)0)); } } } } - va_end( args ); + va_end(args); } -void ERRORnospace() { - fprintf( stderr, "%s: out of space\n", EXPRESSprogram_name ); - ERRORabort( 0 ); +void ERRORnospace() +{ + fprintf(stderr, "%s: out of space\n", EXPRESSprogram_name); + ERRORabort(0); } /** \fn ERRORbuffer_messages @@ -479,38 +494,40 @@ void ERRORnospace() { ** \note The error messages are sorted by line number (which appears in the third column). */ -void ERROR_start_message_buffer( void ) { +void ERROR_start_message_buffer(void) +{ ERROR_string = ERROR_string_base; ERROR_with_lines = 0; } -void ERROR_flush_message_buffer( void ) { +void ERROR_flush_message_buffer(void) +{ if(!__ERROR_buffer_errors) { return; } - while( ERROR_with_lines ) { - struct heap_element * replace; + while(ERROR_with_lines) { + struct heap_element *replace; int parent, child; /* pop off the top of the heap */ - fprintf( stderr, "%s", heap[1].msg ); + fprintf(stderr, "%s", heap[1].msg); replace = &heap[ERROR_with_lines--]; child = 1; - while( 1 ) { + while(1) { parent = child; child = 2 * parent; - if( child > ERROR_with_lines ) { + if(child > ERROR_with_lines) { break; } - if( child + 1 <= ERROR_with_lines ) { - if( heap[child].line > heap[child + 1].line ) { + if(child + 1 <= ERROR_with_lines) { + if(heap[child].line > heap[child + 1].line) { child++; } } - if( replace->line <= heap[child].line ) { + if(replace->line <= heap[child].line) { break; } heap[parent] = heap[child]; @@ -519,29 +536,32 @@ void ERROR_flush_message_buffer( void ) { } } -void ERRORabort( int sig ) { +void ERRORabort(int sig) +{ (void) sig; /* quell unused param warning */ /* TODO: rework - fprintf is not atomic * so ERRORflush_messages() is unsafe if __ERROR_buffer_errors is set */ - + /* NOTE: signals can be caught in gdb, * no need for special treatment of debugging scenario */ - if( ERROR_unsafe ) { - longjmp( ERROR_safe_env, 1 ); + if(ERROR_unsafe) { + longjmp(ERROR_safe_env, 1); } #ifdef SIGABRT - signal( SIGABRT, SIG_DFL ); + signal(SIGABRT, SIG_DFL); #endif /* TODO: library shouldn't abort an application? */ abort(); } -void ERRORsafe( jmp_buf env ) { - memcpy( ERROR_safe_env, env, sizeof( jmp_buf ) ); +void ERRORsafe(jmp_buf env) +{ + memcpy(ERROR_safe_env, env, sizeof(jmp_buf)); } -void ERRORunsafe() { +void ERRORunsafe() +{ ERROR_unsafe = true; } diff --git a/src/express/exp_kw.c b/src/express/exp_kw.c index 837e49393..e765fa510 100644 --- a/src/express/exp_kw.c +++ b/src/express/exp_kw.c @@ -1,122 +1,122 @@ #include "express/exp_kw.h" -char * KW_ABS = "ABS"; -char * KW_ABSTRACT = "ABSTRACT"; -char * KW_ACOS = "ACOS"; -char * KW_AGGREGATE = "AGGREGATE"; -char * KW_ALIAS = "ALIAS"; -char * KW_AND = "AND"; -char * KW_ANDOR = "ANDOR"; -char * KW_ARRAY = "ARRAY"; -char * KW_AS = "AS"; -char * KW_ASIN = "ASIN"; -char * KW_ATAN = "ATAN"; -char * KW_BAG = "BAG"; -char * KW_BEGIN = "BEGIN"; -char * KW_BINARY = "BINARY"; -char * KW_BLENGTH = "BLENGTH"; -char * KW_BOOLEAN = "BOOLEAN"; -char * KW_BY = "BY"; -char * KW_CASE = "CASE"; -char * KW_CONST_E = "CONST_E"; -char * KW_CONSTANT = "CONSTANT"; -char * KW_CONTEXT = "CONTEXT"; -char * KW_COS = "COS"; -char * KW_DERIVE = "DERIVE"; -char * KW_DIV = "DIV"; -char * KW_ELSE = "ELSE"; -char * KW_END = "END"; -char * KW_END_ALIAS = "END_ALIAS"; -char * KW_END_CASE = "END_CASE"; -char * KW_END_CONSTANT = "END_CONSTANT"; -char * KW_END_CONTEXT = "END_CONTEXT"; -char * KW_END_ENTITY = "END_ENTITY"; -char * KW_END_FUNCTION = "END_FUNCTION"; -char * KW_END_IF = "END_IF"; -char * KW_END_LOCAL = "END_LOCAL"; -char * KW_END_MODEL = "END_MODEL"; -char * KW_END_PROCEDURE = "END_PROCEDURE"; -char * KW_END_REPEAT = "END_REPEAT"; -char * KW_END_RULE = "END_RULE"; -char * KW_END_SCHEMA = "END_SCHEMA"; -char * KW_END_TYPE = "END_TYPE"; -char * KW_ENTITY = "ENTITY"; -char * KW_ENUMERATION = "ENUMERATION"; -char * KW_ESCAPE = "ESCAPE"; -char * KW_EXISTS = "EXISTS"; -char * KW_EXP = "EXP"; -char * KW_FALSE = "FALSE"; -char * KW_FIXED = "FIXED"; -char * KW_FOR = "FOR"; -char * KW_FORMAT = "FORMAT"; -char * KW_FROM = "FROM"; -char * KW_FUNCTION = "FUNCTION"; -char * KW_GENERIC = "GENERIC"; -char * KW_HIBOUND = "HIBOUND"; -char * KW_HIINDEX = "HIINDEX"; -char * KW_IF = "IF"; -char * KW_IN = "IN"; -char * KW_INCLUDE = "INCLUDE"; -char * KW_INSERT = "INSERT"; -char * KW_INTEGER = "INTEGER"; -char * KW_INVERSE = "INVERSE"; -char * KW_LENGTH = "LENGTH"; -char * KW_LIKE = "LIKE"; -char * KW_LIST = "LIST"; -char * KW_LOBOUND = "LOBOUND"; -char * KW_LOCAL = "LOCAL"; -char * KW_LOG = "LOG"; -char * KW_LOG10 = "LOG10"; -char * KW_LOG2 = "LOG2"; -char * KW_LOGICAL = "LOGICAL"; -char * KW_LOINDEX = "LOINDEX"; -char * KW_MOD = "MOD"; -char * KW_MODEL = "MODEL"; -char * KW_NOT = "NOT"; -char * KW_NUMBER = "NUMBER"; -char * KW_NVL = "NVL"; -char * KW_ODD = "ODD"; -char * KW_OF = "OF"; -char * KW_ONEOF = "ONEOF"; -char * KW_OPTIONAL = "OPTIONAL"; -char * KW_OR = "OR"; -char * KW_OTHERWISE = "OTHERWISE"; -char * KW_PI = "PI"; -char * KW_PROCEDURE = "PROCEDURE"; -char * KW_QUERY = "QUERY"; -char * KW_REAL = "REAL"; -char * KW_REFERENCE = "REFERENCE"; -char * KW_REMOVE = "REMOVE"; -char * KW_REPEAT = "REPEAT"; -char * KW_RETURN = "RETURN"; -char * KW_ROLESOF = "ROLESOF"; -char * KW_RULE = "RULE"; -char * KW_SCHEMA = "SCHEMA"; -char * KW_SELECT = "SELECT"; -char * KW_SELF = "SELF"; -char * KW_SET = "SET"; -char * KW_SIN = "SIN"; -char * KW_SIZEOF = "SIZEOF"; -char * KW_SKIP = "SKIP"; -char * KW_SQRT = "SQRT"; -char * KW_STRING = "STRING"; -char * KW_SUBTYPE = "SUBTYPE"; -char * KW_SUPERTYPE = "SUPERTYPE"; -char * KW_TAN = "TAN"; -char * KW_THEN = "THEN"; -char * KW_TO = "TO"; -char * KW_TRUE = "TRUE"; -char * KW_TYPE = "TYPE"; -char * KW_TYPEOF = "TYPEOF"; -char * KW_UNIQUE = "UNIQUE"; -char * KW_UNKNOWN = "UNKNOWN"; -char * KW_UNTIL = "UNTIL"; -char * KW_USE = "USE"; -char * KW_USEDIN = "USEDIN"; -char * KW_VALUE = "VALUE"; -char * KW_VALUE_IN = "VALUE_IN"; -char * KW_VALUE_UNIQUE = "VALUE_UNIQUE"; -char * KW_VAR = "VAR"; -char * KW_WHERE = "WHERE"; -char * KW_WHILE = "WHILE"; -char * KW_XOR = "XOR"; +char *KW_ABS = "ABS"; +char *KW_ABSTRACT = "ABSTRACT"; +char *KW_ACOS = "ACOS"; +char *KW_AGGREGATE = "AGGREGATE"; +char *KW_ALIAS = "ALIAS"; +char *KW_AND = "AND"; +char *KW_ANDOR = "ANDOR"; +char *KW_ARRAY = "ARRAY"; +char *KW_AS = "AS"; +char *KW_ASIN = "ASIN"; +char *KW_ATAN = "ATAN"; +char *KW_BAG = "BAG"; +char *KW_BEGIN = "BEGIN"; +char *KW_BINARY = "BINARY"; +char *KW_BLENGTH = "BLENGTH"; +char *KW_BOOLEAN = "BOOLEAN"; +char *KW_BY = "BY"; +char *KW_CASE = "CASE"; +char *KW_CONST_E = "CONST_E"; +char *KW_CONSTANT = "CONSTANT"; +char *KW_CONTEXT = "CONTEXT"; +char *KW_COS = "COS"; +char *KW_DERIVE = "DERIVE"; +char *KW_DIV = "DIV"; +char *KW_ELSE = "ELSE"; +char *KW_END = "END"; +char *KW_END_ALIAS = "END_ALIAS"; +char *KW_END_CASE = "END_CASE"; +char *KW_END_CONSTANT = "END_CONSTANT"; +char *KW_END_CONTEXT = "END_CONTEXT"; +char *KW_END_ENTITY = "END_ENTITY"; +char *KW_END_FUNCTION = "END_FUNCTION"; +char *KW_END_IF = "END_IF"; +char *KW_END_LOCAL = "END_LOCAL"; +char *KW_END_MODEL = "END_MODEL"; +char *KW_END_PROCEDURE = "END_PROCEDURE"; +char *KW_END_REPEAT = "END_REPEAT"; +char *KW_END_RULE = "END_RULE"; +char *KW_END_SCHEMA = "END_SCHEMA"; +char *KW_END_TYPE = "END_TYPE"; +char *KW_ENTITY = "ENTITY"; +char *KW_ENUMERATION = "ENUMERATION"; +char *KW_ESCAPE = "ESCAPE"; +char *KW_EXISTS = "EXISTS"; +char *KW_EXP = "EXP"; +char *KW_FALSE = "FALSE"; +char *KW_FIXED = "FIXED"; +char *KW_FOR = "FOR"; +char *KW_FORMAT = "FORMAT"; +char *KW_FROM = "FROM"; +char *KW_FUNCTION = "FUNCTION"; +char *KW_GENERIC = "GENERIC"; +char *KW_HIBOUND = "HIBOUND"; +char *KW_HIINDEX = "HIINDEX"; +char *KW_IF = "IF"; +char *KW_IN = "IN"; +char *KW_INCLUDE = "INCLUDE"; +char *KW_INSERT = "INSERT"; +char *KW_INTEGER = "INTEGER"; +char *KW_INVERSE = "INVERSE"; +char *KW_LENGTH = "LENGTH"; +char *KW_LIKE = "LIKE"; +char *KW_LIST = "LIST"; +char *KW_LOBOUND = "LOBOUND"; +char *KW_LOCAL = "LOCAL"; +char *KW_LOG = "LOG"; +char *KW_LOG10 = "LOG10"; +char *KW_LOG2 = "LOG2"; +char *KW_LOGICAL = "LOGICAL"; +char *KW_LOINDEX = "LOINDEX"; +char *KW_MOD = "MOD"; +char *KW_MODEL = "MODEL"; +char *KW_NOT = "NOT"; +char *KW_NUMBER = "NUMBER"; +char *KW_NVL = "NVL"; +char *KW_ODD = "ODD"; +char *KW_OF = "OF"; +char *KW_ONEOF = "ONEOF"; +char *KW_OPTIONAL = "OPTIONAL"; +char *KW_OR = "OR"; +char *KW_OTHERWISE = "OTHERWISE"; +char *KW_PI = "PI"; +char *KW_PROCEDURE = "PROCEDURE"; +char *KW_QUERY = "QUERY"; +char *KW_REAL = "REAL"; +char *KW_REFERENCE = "REFERENCE"; +char *KW_REMOVE = "REMOVE"; +char *KW_REPEAT = "REPEAT"; +char *KW_RETURN = "RETURN"; +char *KW_ROLESOF = "ROLESOF"; +char *KW_RULE = "RULE"; +char *KW_SCHEMA = "SCHEMA"; +char *KW_SELECT = "SELECT"; +char *KW_SELF = "SELF"; +char *KW_SET = "SET"; +char *KW_SIN = "SIN"; +char *KW_SIZEOF = "SIZEOF"; +char *KW_SKIP = "SKIP"; +char *KW_SQRT = "SQRT"; +char *KW_STRING = "STRING"; +char *KW_SUBTYPE = "SUBTYPE"; +char *KW_SUPERTYPE = "SUPERTYPE"; +char *KW_TAN = "TAN"; +char *KW_THEN = "THEN"; +char *KW_TO = "TO"; +char *KW_TRUE = "TRUE"; +char *KW_TYPE = "TYPE"; +char *KW_TYPEOF = "TYPEOF"; +char *KW_UNIQUE = "UNIQUE"; +char *KW_UNKNOWN = "UNKNOWN"; +char *KW_UNTIL = "UNTIL"; +char *KW_USE = "USE"; +char *KW_USEDIN = "USEDIN"; +char *KW_VALUE = "VALUE"; +char *KW_VALUE_IN = "VALUE_IN"; +char *KW_VALUE_UNIQUE = "VALUE_UNIQUE"; +char *KW_VAR = "VAR"; +char *KW_WHERE = "WHERE"; +char *KW_WHILE = "WHILE"; +char *KW_XOR = "XOR"; diff --git a/src/express/expr.c b/src/express/expr.c index 7f814cf89..2c2e279c6 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -87,10 +87,11 @@ Expression LITERAL_ONE; void EXPop_init(); -static inline int OPget_number_of_operands( Op_Code op ) { - if( ( op == OP_NEGATE ) || ( op == OP_NOT ) ) { +static inline int OPget_number_of_operands(Op_Code op) +{ + if((op == OP_NEGATE) || (op == OP_NOT)) { return 1; - } else if( op == OP_SUBCOMPONENT ) { + } else if(op == OP_SUBCOMPONENT) { return 3; } else { return 2; @@ -98,45 +99,47 @@ static inline int OPget_number_of_operands( Op_Code op ) { } /** Description: Initialize the Expression module. */ -void EXPinitialize( void ) { +void EXPinitialize(void) +{ #ifdef does_not_appear_to_be_necessary_or_even_make_sense - LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); + LITERAL_EMPTY_SET = EXPcreate_simple(Type_Set); LITERAL_EMPTY_SET->u.list = LISTcreate(); - resolved_all( LITERAL_EMPTY_SET ); + resolved_all(LITERAL_EMPTY_SET); #endif /* E and PI might come out of math.h */ - LITERAL_E = EXPcreate_simple( Type_Real ); + LITERAL_E = EXPcreate_simple(Type_Real); #ifndef M_E #define M_E 2.7182818284590452354 #endif LITERAL_E->u.real = M_E; - resolved_all( LITERAL_E ); + resolved_all(LITERAL_E); - LITERAL_PI = EXPcreate_simple( Type_Real ); + LITERAL_PI = EXPcreate_simple(Type_Real); #ifndef M_PI #define M_PI 3.14159265358979323846 #endif LITERAL_PI->u.real = M_PI; - resolved_all( LITERAL_PI ); + resolved_all(LITERAL_PI); - LITERAL_INFINITY = EXPcreate_simple( Type_Integer ); + LITERAL_INFINITY = EXPcreate_simple(Type_Integer); LITERAL_INFINITY->u.integer = INT_MAX; - resolved_all( LITERAL_INFINITY ); + resolved_all(LITERAL_INFINITY); - LITERAL_ZERO = EXPcreate_simple( Type_Integer ); + LITERAL_ZERO = EXPcreate_simple(Type_Integer); LITERAL_ZERO->u.integer = 0; - resolved_all( LITERAL_ZERO ); + resolved_all(LITERAL_ZERO); - LITERAL_ONE = EXPcreate_simple( Type_Integer ); + LITERAL_ONE = EXPcreate_simple(Type_Integer); LITERAL_ONE->u.integer = 1; - resolved_all( LITERAL_ONE ); + resolved_all(LITERAL_ONE); EXPop_init(); } -void EXPcleanup( void ) { +void EXPcleanup(void) +{ } /** @@ -150,23 +153,24 @@ void EXPcleanup( void ) { * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e, - Variable * v, char * dt, struct Symbol_ ** where, int s_id ) { +static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, + Variable *v, char *dt, struct Symbol_ **where, int s_id) +{ Expression item; Variable tmp; int options = 0; struct Symbol_ *w = NULL; - if( selection->search_id == s_id ) { + if(selection->search_id == s_id) { return 0; } - switch( selection->u.type->body->type ) { + switch(selection->u.type->body->type) { case entity_: /* goes through supertypes and their subtypes (!!) */ - tmp = ENTITYfind_inherited_attribute( selection->u.type->body->entity, sref.name, &w ); - if( tmp ) { - if( w != NULL ) { + tmp = ENTITYfind_inherited_attribute(selection->u.type->body->entity, sref.name, &w); + if(tmp) { + if(w != NULL) { *where = w; } *v = tmp; @@ -180,54 +184,57 @@ static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e Linked_List subt = LISTcreate(); Linked_List uniqSubs = LISTcreate(); selection->search_id = s_id; - LISTdo( selection->u.type->body->list, t, Type ) { - int nr = EXP_resolve_op_dot_fuzzy( t, sref, e, v, dt, &w, s_id ); - if( nr ) { - if( w != NULL ) { + LISTdo(selection->u.type->body->list, t, Type) { + int nr = EXP_resolve_op_dot_fuzzy(t, sref, e, v, dt, &w, s_id); + if(nr) { + if(w != NULL) { /* only ever set due to ENTITYfind_inherited_attribute in case entity_. * it is set to a subtype of one of the current type's supertypes. not * sure of the circumstances in which this is beneficial. */ *where = w; - LISTadd_last( subt, w ); + LISTadd_last(subt, w); } else { - LISTadd_last( supert, t ); + LISTadd_last(supert, t); } options += nr; } - } LISTod + } + LISTod /* go through supertypes and subtypes, comparing. for any subtypes in supertypes, remove item from subtypes * would be possible to delete items from subt while going through the list... worth the effort? */ - LISTdo( subt, s, Symbol* ) { + LISTdo(subt, s, Symbol *) { bool found = false; - LISTdo_n( supert, t, Type, b ) { - if( 0 == strcmp( s->name, t->symbol.name ) ) { + LISTdo_n(supert, t, Type, b) { + if(0 == strcmp(s->name, t->symbol.name)) { found = true; break; } - } LISTod - if( !found ) { - LISTadd_last( uniqSubs, s ); } - } LISTod - if( ( LISTget_length( uniqSubs ) == 0 ) && ( LISTget_length( supert ) == 1 ) && ( options > 1 ) ) { + LISTod + if(!found) { + LISTadd_last(uniqSubs, s); + } + } + LISTod + if((LISTget_length(uniqSubs) == 0) && (LISTget_length(supert) == 1) && (options > 1)) { options = 1; /* this ensures that v is set correctly and wasn't overwritten */ - EXP_resolve_op_dot_fuzzy( (Type) LISTget_first( supert ), sref, e, v, dt, &w, s_id ); + EXP_resolve_op_dot_fuzzy((Type) LISTget_first(supert), sref, e, v, dt, &w, s_id); } - if( options > 1 ) { + if(options > 1) { /* found more than one, so ambiguous */ *v = VARIABLE_NULL; } - LISTfree( supert ); - LISTfree( subt ); - LISTfree( uniqSubs ); + LISTfree(supert); + LISTfree(subt); + LISTfree(uniqSubs); return options; } case enumeration_: - item = ( Expression )DICTlookup( TYPEget_enum_tags( selection ), sref.name ); - if( item ) { + item = (Expression)DICTlookup(TYPEget_enum_tags(selection), sref.name); + if(item) { *e = item; *dt = DICT_type; return 1; @@ -237,7 +244,8 @@ static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e } } -Type EXPresolve_op_dot( Expression expr, Scope scope ) { +Type EXPresolve_op_dot(Expression expr, Scope scope) +{ Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Variable v = 0; @@ -253,151 +261,151 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { /* op1 is entity expression, op2 is attribute */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve( op1, scope, Type_Dont_Care ); - if( is_resolve_failed( op1 ) ) { - resolve_failed( expr ); - return( Type_Bad ); + EXPresolve(op1, scope, Type_Dont_Care); + if(is_resolve_failed(op1)) { + resolve_failed(expr); + return(Type_Bad); } op1type = op1->return_type; - switch( op1type->u.type->body->type ) { + switch(op1type->u.type->body->type) { case generic_: case runtime_: /* defer */ - return( Type_Runtime ); + return(Type_Runtime); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo( op1type->u.type->body->list, t, Type ) { + LISTdo(op1type->u.type->body->list, t, Type) { /* this used to increment options by 1 if EXP_resolve_op_dot_fuzzy found 1 or more possibilities. * thus the code for handling ambiguities was only used if the ambig was in the immediate type * and not a supertype. don't think that's right... */ - options += EXP_resolve_op_dot_fuzzy( t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id ); + options += EXP_resolve_op_dot_fuzzy(t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id); } LISTod; - switch( options ) { + switch(options) { case 0: - LISTdo( op1type->u.type->body->list, t, Type ) { - if( t->u.type->body->type != enumeration_ ) { + LISTdo(op1type->u.type->body->list, t, Type) { + if(t->u.type->body->type != enumeration_) { all_enums = false; } } LISTod; - if( all_enums ) { - ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name ); + if(all_enums) { + ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name); } else { /* no possible resolutions */ - ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name ); + ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name); } - resolve_failed( expr ); - return( Type_Bad ); + resolve_failed(expr); + return(Type_Bad); case 1: /* only one possible resolution */ - if( dt == OBJ_VARIABLE ) { - if( where ) { - ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name ); + if(dt == OBJ_VARIABLE) { + if(where) { + ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name); } - if( v == VARIABLE_NULL ) { - fprintf( stderr, "EXPresolve_op_dot: nonsense value for Variable\n" ); - ERRORabort( 0 ); + if(v == VARIABLE_NULL) { + fprintf(stderr, "EXPresolve_op_dot: nonsense value for Variable\n"); + ERRORabort(0); } op2->u.variable = v; op2->return_type = v->type; - resolved_all( expr ); - return( v->type ); - } else if( dt == OBJ_ENUM ) { + resolved_all(expr); + return(v->type); + } else if(dt == OBJ_ENUM) { op2->u.expression = item; op2->return_type = item->type; - resolved_all( expr ); - return( item->type ); + resolved_all(expr); + return(item->type); } else { - fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); - ERRORabort( 0 ); + fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); + ERRORabort(0); } default: /* compile-time ambiguous */ - if( where ) { + if(where) { /* this is actually a warning, not an error */ - ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name ); + ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name); } - return( Type_Runtime ); + return(Type_Runtime); } case attribute_: - v = ENTITYresolve_attr_ref( op1->u.variable->type->u.type->body->entity, ( struct Symbol_ * )0, &op2->symbol ); + v = ENTITYresolve_attr_ref(op1->u.variable->type->u.type->body->entity, (struct Symbol_ *)0, &op2->symbol); - if( !v ) { + if(!v) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed( expr ); - return( Type_Bad ); + resolve_failed(expr); + return(Type_Bad); } - if( DICT_type != OBJ_VARIABLE ) { - fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); - ERRORabort( 0 ); + if(DICT_type != OBJ_VARIABLE) { + fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); + ERRORabort(0); } op2->u.variable = v; op2->return_type = v->type; - resolved_all( expr ); - return( v->type ); + resolved_all(expr); + return(v->type); case entity_: case op_: /* (op1).op2 */ - v = ENTITYresolve_attr_ref( op1type->u.type->body->entity, - ( struct Symbol_ * )0, &op2->symbol ); - if( !v ) { + v = ENTITYresolve_attr_ref(op1type->u.type->body->entity, + (struct Symbol_ *)0, &op2->symbol); + if(!v) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed( expr ); - return( Type_Bad ); + resolve_failed(expr); + return(Type_Bad); } - if( DICT_type != OBJ_VARIABLE ) { - fprintf( stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n" ); + if(DICT_type != OBJ_VARIABLE) { + fprintf(stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n"); } op2->u.variable = v; /* changed to set return_type */ op2->return_type = op2->u.variable->type; - resolved_all( expr ); - return( op2->return_type ); + resolved_all(expr); + return(op2->return_type); case enumeration_: /* enumerations within a select will be handled by `case select_` above, * which calls EXP_resolve_op_dot_fuzzy(). */ - item = ( Expression )DICTlookup( TYPEget_enum_tags( op1type ), op2->symbol.name ); - if( !item ) { + item = (Expression)DICTlookup(TYPEget_enum_tags(op1type), op2->symbol.name); + if(!item) { ERRORreport_with_symbol(ENUM_NO_SUCH_ITEM, &op2->symbol, - op1type->symbol.name, op2->symbol.name ); - resolve_failed( expr ); - return( Type_Bad ); + op1type->symbol.name, op2->symbol.name); + resolve_failed(expr); + return(Type_Bad); } op2->u.expression = item; op2->return_type = item->type; - resolved_all( expr ); - return( item->type ); + resolved_all(expr); + return(item->type); case aggregate_: case array_: case bag_: case list_: case set_: ERRORreport_with_symbol(ATTRIBUTE_REF_ON_AGGREGATE, - &op2->symbol, op2->symbol.name ); - /*FALLTHRU*/ + &op2->symbol, op2->symbol.name); + /*FALLTHRU*/ case unknown_: /* unable to resolved operand */ /* presumably error has already been reported */ - resolve_failed( expr ); - return( Type_Bad ); + resolve_failed(expr); + return(Type_Bad); default: ERRORreport_with_symbol(ATTRIBUTE_REF_FROM_NON_ENTITY, - &op2->symbol, op2->symbol.name ); - resolve_failed( expr ); - return( Type_Bad ); + &op2->symbol, op2->symbol.name); + resolve_failed(expr); + return(Type_Bad); } } @@ -406,20 +414,21 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_group_fuzzy( Type selection, Symbol sref, Entity * e, - int s_id ) { +static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, + int s_id) +{ Entity tmp; int options = 0; - if( selection->search_id == s_id ) { + if(selection->search_id == s_id) { return 0; } - switch( selection->u.type->body->type ) { + switch(selection->u.type->body->type) { case entity_: - tmp = ( Entity )ENTITYfind_inherited_entity( - selection->u.type->body->entity, sref.name, 1 ); - if( tmp ) { + tmp = (Entity)ENTITYfind_inherited_entity( + selection->u.type->body->entity, sref.name, 1); + if(tmp) { *e = tmp; return 1; } @@ -428,16 +437,16 @@ static int EXP_resolve_op_group_fuzzy( Type selection, Symbol sref, Entity * e, case select_: tmp = *e; selection->search_id = s_id; - LISTdo( selection->u.type->body->list, t, Type ) - if( EXP_resolve_op_group_fuzzy( t, sref, e, s_id ) ) { - if( *e != tmp ) { + LISTdo(selection->u.type->body->list, t, Type) + if(EXP_resolve_op_group_fuzzy(t, sref, e, s_id)) { + if(*e != tmp) { tmp = *e; ++options; } } LISTod; - switch( options ) { + switch(options) { case 0: return 0; case 1: @@ -452,7 +461,8 @@ static int EXP_resolve_op_group_fuzzy( Type selection, Symbol sref, Entity * e, } } -Type EXPresolve_op_group( Expression expr, Scope scope ) { +Type EXPresolve_op_group(Expression expr, Scope scope) +{ Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Entity ent_ref = ENTITY_NULL; @@ -465,84 +475,84 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) { /* op1 is entity expression, op2 is entity */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve( op1, scope, Type_Dont_Care ); - if( is_resolve_failed( op1 ) ) { - resolve_failed( expr ); - return( Type_Bad ); + EXPresolve(op1, scope, Type_Dont_Care); + if(is_resolve_failed(op1)) { + resolve_failed(expr); + return(Type_Bad); } op1type = op1->return_type; - switch( op1type->u.type->body->type ) { + switch(op1type->u.type->body->type) { case generic_: case runtime_: case op_: /* All these cases are very painful to do right */ /* "Generic" and sometimes others require runtime evaluation */ op2->return_type = Type_Runtime; - return( Type_Runtime ); + return(Type_Runtime); case self_: case entity_: /* Get entity denoted by "X\" */ - tmp = ( ( op1type->u.type->body->type == self_ ) - ? scope - : op1type->u.type->body->entity ); + tmp = ((op1type->u.type->body->type == self_) + ? scope + : op1type->u.type->body->entity); /* Now get entity denoted by "X\Y" */ ent_ref = - ( Entity )ENTITYfind_inherited_entity( tmp, op2->symbol.name, 1 ); - if( !ent_ref ) { + (Entity)ENTITYfind_inherited_entity(tmp, op2->symbol.name, 1); + if(!ent_ref) { ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name ); - resolve_failed( expr ); - return( Type_Bad ); + &op2->symbol, op2->symbol.name); + resolve_failed(expr); + return(Type_Bad); } op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all( expr ); - return( op2->return_type ); + resolved_all(expr); + return(op2->return_type); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the */ /* first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo( op1type->u.type->body->list, t, Type ) - if( EXP_resolve_op_group_fuzzy( t, op2->symbol, &ent_ref, - __SCOPE_search_id ) ) { - if( ent_ref != tmp ) { + LISTdo(op1type->u.type->body->list, t, Type) + if(EXP_resolve_op_group_fuzzy(t, op2->symbol, &ent_ref, + __SCOPE_search_id)) { + if(ent_ref != tmp) { tmp = ent_ref; ++options; } } LISTod; - switch( options ) { + switch(options) { case 0: /* no possible resolutions */ ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name ); - resolve_failed( expr ); - return( Type_Bad ); + &op2->symbol, op2->symbol.name); + resolve_failed(expr); + return(Type_Bad); case 1: /* only one possible resolution */ op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all( expr ); - return( op2->return_type ); + resolved_all(expr); + return(op2->return_type); default: /* compile-time ambiguous */ /* ERRORreport_with_symbol(ERROR_ambiguous_group,*/ /* &op2->symbol, op2->symbol.name);*/ - return( Type_Runtime ); + return(Type_Runtime); } case array_: - if( op1->type->u.type->body->type == self_ ) { - return( Type_Runtime ); /* not sure if there are other cases where Type_Runtime should be returned, or not */ + if(op1->type->u.type->body->type == self_) { + return(Type_Runtime); /* not sure if there are other cases where Type_Runtime should be returned, or not */ } /* else fallthrough */ case unknown_: /* unable to resolve operand */ /* presumably error has already been reported */ - resolve_failed( expr ); - return( Type_Bad ); + resolve_failed(expr); + return(Type_Bad); case aggregate_: case bag_: @@ -550,112 +560,117 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) { case set_: default: ERRORreport_with_symbol(GROUP_REF_UNEXPECTED_TYPE, - &op1->symbol ); - return( Type_Bad ); + &op1->symbol); + return(Type_Bad); } } -Type EXPresolve_op_relational( Expression e, Scope s ) { +Type EXPresolve_op_relational(Expression e, Scope s) +{ Type t = 0; int failed = 0; Type op1type; /* Prevent op1 from complaining if it fails */ - EXPresolve( e->e.op1, s, Type_Unknown ); - failed = is_resolve_failed( e->e.op1 ); + EXPresolve(e->e.op1, s, Type_Unknown); + failed = is_resolve_failed(e->e.op1); op1type = e->e.op1->return_type; /* now, either op1 was resolved in which case, we use its return type */ /* for typechecking, OR, it wasn't resolved in which case we resolve */ /* op2 in such a way that it complains if it fails to resolved */ - if( op1type == Type_Unknown ) { + if(op1type == Type_Unknown) { t = Type_Dont_Care; } else { t = op1type; } - EXPresolve( e->e.op2, s, t ); - if( is_resolve_failed( e->e.op2 ) ) { + EXPresolve(e->e.op2, s, t); + if(is_resolve_failed(e->e.op2)) { failed = 1; } /* If op1 wasn't successfully resolved, retry it now with new information */ - if( ( failed == 0 ) && !is_resolved( e->e.op1 ) ) { - EXPresolve( e->e.op1, s, e->e.op2->return_type ); - if( is_resolve_failed( e->e.op1 ) ) { + if((failed == 0) && !is_resolved(e->e.op1)) { + EXPresolve(e->e.op1, s, e->e.op2->return_type); + if(is_resolve_failed(e->e.op1)) { failed = 1; } } - if( failed ) { - resolve_failed( e ); + if(failed) { + resolve_failed(e); } else { - resolved_all( e ); + resolved_all(e); } - return( Type_Logical ); + return(Type_Logical); } -void EXPresolve_op_default( Expression e, Scope s ) { +void EXPresolve_op_default(Expression e, Scope s) +{ int failed = 0; - switch( OPget_number_of_operands( e->e.op_code ) ) { + switch(OPget_number_of_operands(e->e.op_code)) { case 3: - EXPresolve( e->e.op3, s, Type_Dont_Care ); - failed = is_resolve_failed( e->e.op3 ); + EXPresolve(e->e.op3, s, Type_Dont_Care); + failed = is_resolve_failed(e->e.op3); case 2: - EXPresolve( e->e.op2, s, Type_Dont_Care ); - failed |= is_resolve_failed( e->e.op2 ); + EXPresolve(e->e.op2, s, Type_Dont_Care); + failed |= is_resolve_failed(e->e.op2); } - EXPresolve( e->e.op1, s, Type_Dont_Care ); - if( failed || is_resolve_failed( e->e.op1 ) ) { - resolve_failed( e ); + EXPresolve(e->e.op1, s, Type_Dont_Care); + if(failed || is_resolve_failed(e->e.op1)) { + resolve_failed(e); } else { - resolved_all( e ); + resolved_all(e); } } /* prototype for this func cannot change - it is passed as a fn pointer */ -Type EXPresolve_op_unknown( Expression e, Scope s ) { +Type EXPresolve_op_unknown(Expression e, Scope s) +{ (void) e; /* quell unused param warning */ (void) s; - ERRORreport( INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE ); + ERRORreport(INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE); return Type_Bad; } -typedef Type (Resolve_expr_func) ( Expression , Scope ); +typedef Type(Resolve_expr_func)(Expression, Scope); -Type EXPresolve_op_logical( Expression e, Scope s ) { - EXPresolve_op_default( e, s ); - return( Type_Logical ); +Type EXPresolve_op_logical(Expression e, Scope s) +{ + EXPresolve_op_default(e, s); + return(Type_Logical); } -Type EXPresolve_op_array_like( Expression e, Scope s ) { +Type EXPresolve_op_array_like(Expression e, Scope s) +{ Type op1type; - EXPresolve_op_default( e, s ); + EXPresolve_op_default(e, s); op1type = e->e.op1->return_type; - if( TYPEis_aggregate( op1type ) ) { - return( op1type->u.type->body->base ); - } else if( TYPEis_string( op1type ) ) { - return( op1type ); - } else if( op1type == Type_Runtime ) { - return( Type_Runtime ); - } else if( op1type->u.type->body->type == binary_ ) { - ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__ ); - return( Type_Binary ); - } else if( op1type->u.type->body->type == generic_ ) { - return( Type_Generic ); - } else if( TYPEis_select( op1type ) ) { + if(TYPEis_aggregate(op1type)) { + return(op1type->u.type->body->base); + } else if(TYPEis_string(op1type)) { + return(op1type); + } else if(op1type == Type_Runtime) { + return(Type_Runtime); + } else if(op1type->u.type->body->type == binary_) { + ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__); + return(Type_Binary); + } else if(op1type->u.type->body->type == generic_) { + return(Type_Generic); + } else if(TYPEis_select(op1type)) { int numAggr = 0, numNonAggr = 0; bool sameAggrType = true; Type lasttype = 0; /* FIXME Is it possible that the base type hasn't yet been resolved? * If it is possible, we should signal that we need to come back later... but how? */ - assert( op1type->symbol.resolved == 1 ); + assert(op1type->symbol.resolved == 1); /* FIXME We should check for a not...or excluding non-aggregate types in the select, such as * WR1: NOT('INDEX_ATTRIBUTE.COMMON_DATUM_LIST' IN TYPEOF(base)) OR (SELF\shape_aspect.of_shape = base[1]\shape_aspect.of_shape); @@ -663,13 +678,13 @@ Type EXPresolve_op_array_like( Expression e, Scope s ) { */ /* count aggregates and non-aggregates, check aggregate types */ - LISTdo( op1type->u.type->body->list, item, Type ) { - if( TYPEis_aggregate( item ) ) { + LISTdo(op1type->u.type->body->list, item, Type) { + if(TYPEis_aggregate(item)) { numAggr++; - if( lasttype == TYPE_NULL ) { + if(lasttype == TYPE_NULL) { lasttype = item; } else { - if( lasttype->u.type->body->type != item->u.type->body->type ) { + if(lasttype->u.type->body->type != item->u.type->body->type) { sameAggrType = false; } } @@ -681,40 +696,43 @@ Type EXPresolve_op_array_like( Expression e, Scope s ) { /* NOTE the following code returns the same data for every case that isn't an error. * It needs to be simplified or extended, depending on whether it works or not. */ - if( sameAggrType && ( numAggr != 0 ) && ( numNonAggr == 0 ) ) { + if(sameAggrType && (numAggr != 0) && (numNonAggr == 0)) { /* All are the same aggregation type */ - return( lasttype->u.type->body->base ); - } else if( numNonAggr == 0 ) { + return(lasttype->u.type->body->base); + } else if(numNonAggr == 0) { /* All aggregates, but different types */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); - return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ - } else if( numAggr != 0 ) { + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); + return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ + } else if(numAggr != 0) { /* One or more aggregates, one or more nonaggregates */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); - return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); + return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ } /* Else, all are nonaggregates. This is an error. */ } - ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol ); - return( Type_Unknown ); + ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol); + return(Type_Unknown); } -Type EXPresolve_op_entity_constructor( Expression e, Scope s ) { - EXPresolve_op_default( e, s ); +Type EXPresolve_op_entity_constructor(Expression e, Scope s) +{ + EXPresolve_op_default(e, s); /* perhaps should return Type_Runtime? */ return Type_Entity; } -Type EXPresolve_op_int_div_like( Expression e, Scope s ) { - EXPresolve_op_default( e, s ); +Type EXPresolve_op_int_div_like(Expression e, Scope s) +{ + EXPresolve_op_default(e, s); return Type_Integer; } -Type EXPresolve_op_plus_like( Expression e, Scope s ) { +Type EXPresolve_op_plus_like(Expression e, Scope s) +{ /* i.e., Integer or Real */ - EXPresolve_op_default( e, s ); - if( is_resolve_failed( e ) ) { - resolve_failed( e ); - return( Type_Unknown ); + EXPresolve_op_default(e, s); + if(is_resolve_failed(e)) { + resolve_failed(e); + return(Type_Unknown); } /* could produce better results with a lot of pain but the EXPRESS */ @@ -725,21 +743,22 @@ Type EXPresolve_op_plus_like( Expression e, Scope s ) { /* and list+set=? */ /* crude but sufficient */ - if( ( TYPEis_aggregate( e->e.op1->return_type ) ) || - ( TYPEis_aggregate( e->e.op2->return_type ) ) ) { + if((TYPEis_aggregate(e->e.op1->return_type)) || + (TYPEis_aggregate(e->e.op2->return_type))) { return Type_Aggregate; } /* crude but sufficient */ - if( ( e->e.op1->return_type->u.type->body->type == real_ ) || - ( e->e.op2->return_type->u.type->body->type == real_ ) ) { - return( Type_Real ); + if((e->e.op1->return_type->u.type->body->type == real_) || + (e->e.op2->return_type->u.type->body->type == real_)) { + return(Type_Real); } return Type_Integer; } -Type EXPresolve_op_unary_minus( Expression e, Scope s ) { - EXPresolve_op_default( e, s ); +Type EXPresolve_op_unary_minus(Expression e, Scope s) +{ + EXPresolve_op_default(e, s); return e->e.op1->return_type; } @@ -752,41 +771,43 @@ Type EXPresolve_op_unary_minus( Expression e, Scope s ) { * \param string human-readable description * \param resolve_func resolves an expression of this type */ -void EXPop_create( int token_number, char * string, Resolve_expr_func * resolve_func ) { +void EXPop_create(int token_number, char *string, Resolve_expr_func *resolve_func) +{ EXPop_table[token_number].token = string; EXPop_table[token_number].resolve = resolve_func; } -void EXPop_init() { - EXPop_create( OP_AND, "AND", EXPresolve_op_logical ); - EXPop_create( OP_ANDOR, "ANDOR", EXPresolve_op_logical ); - EXPop_create( OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like ); - EXPop_create( OP_CONCAT, "||", EXPresolve_op_entity_constructor ); - EXPop_create( OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like ); - EXPop_create( OP_DOT, ".", EXPresolve_op_dot ); - EXPop_create( OP_EQUAL, "=", EXPresolve_op_relational ); - EXPop_create( OP_EXP, "**", EXPresolve_op_plus_like ); - EXPop_create( OP_GREATER_EQUAL, ">=", EXPresolve_op_relational ); - EXPop_create( OP_GREATER_THAN, ">", EXPresolve_op_relational ); - EXPop_create( OP_GROUP, "\\", EXPresolve_op_group ); - EXPop_create( OP_IN, "IN", EXPresolve_op_relational ); - EXPop_create( OP_INST_EQUAL, ":=:", EXPresolve_op_relational ); - EXPop_create( OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational ); - EXPop_create( OP_LESS_EQUAL, "<=", EXPresolve_op_relational ); - EXPop_create( OP_LESS_THAN, "<", EXPresolve_op_relational ); - EXPop_create( OP_LIKE, "LIKE", EXPresolve_op_relational ); - EXPop_create( OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like ); - EXPop_create( OP_MOD, "MOD", EXPresolve_op_int_div_like ); - EXPop_create( OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus ); - EXPop_create( OP_NOT, "NOT", EXPresolve_op_logical ); - EXPop_create( OP_NOT_EQUAL, "<>", EXPresolve_op_relational ); - EXPop_create( OP_OR, "OR", EXPresolve_op_logical ); - EXPop_create( OP_PLUS, "+", EXPresolve_op_plus_like ); - EXPop_create( OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like ); - EXPop_create( OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like ); - EXPop_create( OP_TIMES, "*", EXPresolve_op_plus_like ); - EXPop_create( OP_XOR, "XOR", EXPresolve_op_logical ); - EXPop_create( OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown ); +void EXPop_init() +{ + EXPop_create(OP_AND, "AND", EXPresolve_op_logical); + EXPop_create(OP_ANDOR, "ANDOR", EXPresolve_op_logical); + EXPop_create(OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like); + EXPop_create(OP_CONCAT, "||", EXPresolve_op_entity_constructor); + EXPop_create(OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like); + EXPop_create(OP_DOT, ".", EXPresolve_op_dot); + EXPop_create(OP_EQUAL, "=", EXPresolve_op_relational); + EXPop_create(OP_EXP, "**", EXPresolve_op_plus_like); + EXPop_create(OP_GREATER_EQUAL, ">=", EXPresolve_op_relational); + EXPop_create(OP_GREATER_THAN, ">", EXPresolve_op_relational); + EXPop_create(OP_GROUP, "\\", EXPresolve_op_group); + EXPop_create(OP_IN, "IN", EXPresolve_op_relational); + EXPop_create(OP_INST_EQUAL, ":=:", EXPresolve_op_relational); + EXPop_create(OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational); + EXPop_create(OP_LESS_EQUAL, "<=", EXPresolve_op_relational); + EXPop_create(OP_LESS_THAN, "<", EXPresolve_op_relational); + EXPop_create(OP_LIKE, "LIKE", EXPresolve_op_relational); + EXPop_create(OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like); + EXPop_create(OP_MOD, "MOD", EXPresolve_op_int_div_like); + EXPop_create(OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus); + EXPop_create(OP_NOT, "NOT", EXPresolve_op_logical); + EXPop_create(OP_NOT_EQUAL, "<>", EXPresolve_op_relational); + EXPop_create(OP_OR, "OR", EXPresolve_op_logical); + EXPop_create(OP_PLUS, "+", EXPresolve_op_plus_like); + EXPop_create(OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like); + EXPop_create(OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like); + EXPop_create(OP_TIMES, "*", EXPresolve_op_plus_like); + EXPop_create(OP_XOR, "XOR", EXPresolve_op_logical); + EXPop_create(OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown); } /** @@ -795,80 +816,82 @@ void EXPop_init() { ** \returns value of expression ** Compute the value of an integer expression. */ -int EXPget_integer_value( Expression expression ) { +int EXPget_integer_value(Expression expression) +{ /* TODO: why is this treated differently than a type error below? */ - if( expression == EXPRESSION_NULL ) { + if(expression == EXPRESSION_NULL) { return 0; } - if( expression->return_type->u.type->body->type == integer_ ) { - return INT_LITget_value( expression ); + if(expression->return_type->u.type->body->type == integer_) { + return INT_LITget_value(expression); } else { ERRORreport(INTEGER_EXPRESSION_EXPECTED); return 0; } } -char * opcode_print( Op_Code o ) { - switch( o ) { +char *opcode_print(Op_Code o) +{ + switch(o) { case OP_AND: - return( "OP_AND" ); + return("OP_AND"); case OP_ANDOR: - return( "OP_ANDOR" ); + return("OP_ANDOR"); case OP_ARRAY_ELEMENT: - return( "OP_ARRAY_ELEMENT" ); + return("OP_ARRAY_ELEMENT"); case OP_CONCAT: - return( "OP_CONCAT" ); + return("OP_CONCAT"); case OP_DIV: - return( "OP_DIV" ); + return("OP_DIV"); case OP_DOT: - return( "OP_DOT" ); + return("OP_DOT"); case OP_EQUAL: - return( "OP_EQUAL" ); + return("OP_EQUAL"); case OP_EXP: - return( "OP_EXP" ); + return("OP_EXP"); case OP_GREATER_EQUAL: - return( "OP_GREATER_EQUAL" ); + return("OP_GREATER_EQUAL"); case OP_GREATER_THAN: - return( "OP_GREATER_THAN" ); + return("OP_GREATER_THAN"); case OP_GROUP: - return( "OP_GROUP" ); + return("OP_GROUP"); case OP_IN: - return( "OP_IN" ); + return("OP_IN"); case OP_INST_EQUAL: - return( "OP_INST_EQUAL" ); + return("OP_INST_EQUAL"); case OP_INST_NOT_EQUAL: - return( "OP_INST_NOT_EQUAL" ); + return("OP_INST_NOT_EQUAL"); case OP_LESS_EQUAL: - return( "OP_LESS_EQUAL" ); + return("OP_LESS_EQUAL"); case OP_LESS_THAN: - return( "OP_LESS_THAN" ); + return("OP_LESS_THAN"); case OP_LIKE: - return( "OP_LIKE" ); + return("OP_LIKE"); case OP_MINUS: - return( "OP_MINUS" ); + return("OP_MINUS"); case OP_MOD: - return( "OP_MOD" ); + return("OP_MOD"); case OP_NEGATE: - return( "OP_NEGATE" ); + return("OP_NEGATE"); case OP_NOT: - return( "OP_NOT" ); + return("OP_NOT"); case OP_NOT_EQUAL: - return( "OP_NOT_EQUAL" ); + return("OP_NOT_EQUAL"); case OP_OR: - return( "OP_OR" ); + return("OP_OR"); case OP_PLUS: - return( "OP_PLUS" ); + return("OP_PLUS"); case OP_REAL_DIV: - return( "OP_REAL_DIV" ); + return("OP_REAL_DIV"); case OP_SUBCOMPONENT: - return( "OP_SUBCOMPONENT" ); + return("OP_SUBCOMPONENT"); case OP_TIMES: - return( "OP_TIMES" ); + return("OP_TIMES"); case OP_XOR: - return( "OP_XOR" ); + return("OP_XOR"); case OP_UNKNOWN: - return( "OP_UNKNOWN" ); + return("OP_UNKNOWN"); default: - return( "no such op" ); + return("no such op"); } } diff --git a/src/express/express.c b/src/express/express.c index 82e7b7889..783b142e3 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -87,22 +87,22 @@ #include "parse_data.h" #include "express/lexact.h" -void * ParseAlloc( void * ( *mallocProc )( size_t ) ); -void ParseFree( void * parser, void ( *freeProc )( void * ) ); -void Parse( void * parser, int tokenID, YYSTYPE data, parse_data_t parseData ); +void *ParseAlloc(void *(*mallocProc)(size_t)); +void ParseFree(void *parser, void (*freeProc)(void *)); +void Parse(void *parser, int tokenID, YYSTYPE data, parse_data_t parseData); void ParseTrace(FILE *TraceFILE, char *zTracePrompt); Linked_List EXPRESS_path; int EXPRESSpass; -void ( *EXPRESSinit_args )( int, char ** ) = NULL; -void ( *EXPRESSinit_parse )( void ) = NULL; -int ( *EXPRESSfail )( Express ) = NULL; -int ( *EXPRESSsucceed )( Express ) = NULL; -void ( *EXPRESSbackend )( Express ) = NULL; -char * EXPRESSprogram_name; +void (*EXPRESSinit_args)(int, char **) = NULL; +void (*EXPRESSinit_parse)(void) = NULL; +int (*EXPRESSfail)(Express) = NULL; +int (*EXPRESSsucceed)(Express) = NULL; +void (*EXPRESSbackend)(Express) = NULL; +char *EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -int ( *EXPRESSgetopt )( int, char * ) = NULL; +int (*EXPRESSgetopt)(int, char *) = NULL; bool EXPRESSignore_duplicate_schemas = false; Function funcdef(char *name, int pcount, Type ret_typ); @@ -111,146 +111,154 @@ void BUILTINSinitialize(); Dictionary EXPRESSbuiltins; /* procedures/functions */ -struct Scope_ * FUNC_NVL; -struct Scope_ * FUNC_USEDIN; +struct Scope_ *FUNC_NVL; +struct Scope_ *FUNC_USEDIN; extern Express yyexpresult; extern Linked_List PARSEnew_schemas; -void SCOPEinitialize( void ); +void SCOPEinitialize(void); -static Express PARSERrun( char *, FILE * ); +static Express PARSERrun(char *, FILE *); /** name specified on command line */ -char * input_filename = 0; +char *input_filename = 0; -int EXPRESS_fail( Express model ) { +int EXPRESS_fail(Express model) +{ ERRORflush_messages(); - if( EXPRESSfail ) { - return( ( *EXPRESSfail )( model ) ); + if(EXPRESSfail) { + return((*EXPRESSfail)(model)); } - fprintf( stderr, "Errors in input\n" ); + fprintf(stderr, "Errors in input\n"); return 1; } -int EXPRESS_succeed( Express model ) { - if( EXPRESSsucceed ) { - return( ( *EXPRESSsucceed )( model ) ); +int EXPRESS_succeed(Express model) +{ + if(EXPRESSsucceed) { + return((*EXPRESSsucceed)(model)); } - fprintf( stderr, "No errors in input\n" ); + fprintf(stderr, "No errors in input\n"); return 0; } -Express EXPRESScreate() { - Express model = SCOPEcreate( OBJ_EXPRESS ); - model->u.express = ( struct Express_ * )sc_calloc( 1, sizeof( struct Express_ ) ); +Express EXPRESScreate() +{ + Express model = SCOPEcreate(OBJ_EXPRESS); + model->u.express = (struct Express_ *)sc_calloc(1, sizeof(struct Express_)); return model; } -void EXPRESSdestroy( Express model ) { - if( model->u.express->basename ) { - sc_free( model->u.express->basename ); +void EXPRESSdestroy(Express model) +{ + if(model->u.express->basename) { + sc_free(model->u.express->basename); } - if( model->u.express->filename ) { - sc_free( model->u.express->filename ); + if(model->u.express->filename) { + sc_free(model->u.express->filename); } - sc_free( model->u.express ); - SCOPEdestroy( model ); + sc_free(model->u.express); + SCOPEdestroy(model); } #define MAX_SCHEMA_FILENAME_SIZE 256 typedef struct Dir { char full[MAX_SCHEMA_FILENAME_SIZE]; - char * leaf; + char *leaf; } Dir; -static void EXPRESS_PATHinit() { - char * p; - Dir * dir; +static void EXPRESS_PATHinit() +{ + char *p; + Dir *dir; EXPRESS_path = LISTcreate(); - p = getenv( "EXPRESS_PATH" ); - if( !p ) { + p = getenv("EXPRESS_PATH"); + if(!p) { /* if no EXPRESS_PATH, search current directory anyway */ - dir = ( Dir * )sc_malloc( sizeof( Dir ) ); + dir = (Dir *)sc_malloc(sizeof(Dir)); dir->leaf = dir->full; - LISTadd_last( EXPRESS_path, dir ); + LISTadd_last(EXPRESS_path, dir); } else { int done = 0; - while( !done ) { - char * start; /* start of current dir */ + while(!done) { + char *start; /* start of current dir */ int length; /* length of dir */ - char * slash; /* last slash in dir */ + char *slash; /* last slash in dir */ char save; /* place to character from where we */ /* temporarily null terminate */ /* get next directory */ - while( isspace( *p ) ) { + while(isspace(*p)) { p++; } - if( *p == '\0' ) { + if(*p == '\0') { break; } start = p; /* find the end of the directory */ - while( *p != '\0' && !isspace( *p ) ) { + while(*p != '\0' && !isspace(*p)) { p++; } save = *p; - if( *p == 0 ) { + if(*p == 0) { done = 1; } else { *p = '\0'; } p++; /* leave p after terminating null */ - dir = ( Dir * )sc_malloc( sizeof( Dir ) ); + dir = (Dir *)sc_malloc(sizeof(Dir)); /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ - if( !strcmp( ".", start ) ) { + if(!strcmp(".", start)) { dir->leaf = dir->full; - LISTadd_last( EXPRESS_path, dir ); - *( p - 1 ) = save; /* put char back where */ + LISTadd_last(EXPRESS_path, dir); + *(p - 1) = save; /* put char back where */ /* temp null was */ continue; } - length = ( p - 1 ) - start; + length = (p - 1) - start; /* if slash present at end, don't add another */ - slash = strrchr( start, '/' ); - if( slash && ( slash[1] == '\0' ) ) { - strcpy( dir->full, start ); + slash = strrchr(start, '/'); + if(slash && (slash[1] == '\0')) { + strcpy(dir->full, start); dir->leaf = dir->full + length; } else { - sprintf( dir->full, "%s/", start ); + sprintf(dir->full, "%s/", start); dir->leaf = dir->full + length + 1; } - LISTadd_last( EXPRESS_path, dir ); + LISTadd_last(EXPRESS_path, dir); - *( p - 1 ) = save; /* put char back where temp null was */ + *(p - 1) = save; /* put char back where temp null was */ } } } -static void EXPRESS_PATHfree( void ) { - LISTdo( EXPRESS_path, dir, Dir * ) - sc_free( dir ); +static void EXPRESS_PATHfree(void) +{ + LISTdo(EXPRESS_path, dir, Dir *) + sc_free(dir); LISTod - LISTfree( EXPRESS_path ); + LISTfree(EXPRESS_path); } /** inform object system about bit representation for handling pass diagnostics */ -void PASSinitialize() { +void PASSinitialize() +{ } /** Initialize the Express package. */ -void EXPRESSinitialize( void ) { +void EXPRESSinitialize(void) +{ MEMORYinitialize(); ERRORinitialize(); @@ -279,14 +287,15 @@ void EXPRESSinitialize( void ) { STMTinitialize(); SCANinitialize(); - + BUILTINSinitialize(); EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */ } /** Clean up the EXPRESS package. */ -void EXPRESScleanup( void ) { +void EXPRESScleanup(void) +{ EXPRESS_PATHfree(); DICTcleanup(); @@ -303,101 +312,103 @@ void EXPRESScleanup( void ) { ** \return resulting Working Form model ** Parse an Express source file into the Working Form. */ -void EXPRESSparse( Express model, FILE * fp, char * filename ) { +void EXPRESSparse(Express model, FILE *fp, char *filename) +{ yyexpresult = model; - if( !fp ) { - fp = fopen( filename, "r" ); + if(!fp) { + fp = fopen(filename, "r"); } - if( !fp ) { + if(!fp) { /* go down path looking for file */ - LISTdo( EXPRESS_path, dir, Dir * ) - sprintf( dir->leaf, "%s", filename ); - if( 0 != ( fp = fopen( dir->full, "r" ) ) ) { + LISTdo(EXPRESS_path, dir, Dir *) + sprintf(dir->leaf, "%s", filename); + if(0 != (fp = fopen(dir->full, "r"))) { filename = dir->full; break; } LISTod } - if( !fp ) { - ERRORreport( FILE_UNREADABLE, filename, strerror( errno ) ); + if(!fp) { + ERRORreport(FILE_UNREADABLE, filename, strerror(errno)); return; } - if( filename ) { - char * dot = strrchr( filename, '.' ); - char * slash = strrchr( filename, '/' ); + if(filename) { + char *dot = strrchr(filename, '.'); + char *slash = strrchr(filename, '/'); /* get beginning of basename */ - char * start = slash ? ( slash + 1 ) : filename; + char *start = slash ? (slash + 1) : filename; - int length = strlen( start ); + int length = strlen(start); /* drop .exp suffix if present */ - if( dot && !strcmp( dot, ".exp" ) ) { + if(dot && !strcmp(dot, ".exp")) { length -= 4; } - model->u.express->basename = ( char * )sc_malloc( length + 1 ); - memcpy( model->u.express->basename, filename, length ); + model->u.express->basename = (char *)sc_malloc(length + 1); + memcpy(model->u.express->basename, filename, length); model->u.express->basename[length] = '\0'; /* get new copy of filename to avoid being smashed */ /* by subsequent lookups on EXPRESS_path */ - model->u.express->filename = SCANstrdup( filename ); + model->u.express->filename = SCANstrdup(filename); filename = model->u.express->filename; } PARSEnew_schemas = LISTcreate(); - PARSERrun( filename, model->u.express->file = fp ); + PARSERrun(filename, model->u.express->file = fp); } /* TODO LEMON ought to put this in expparse.h */ void parserInitState(); /** start parsing a new schema file */ -static Express PARSERrun( char * filename, FILE * fp ) { - extern void SCAN_lex_init( char *, FILE * ); +static Express PARSERrun(char *filename, FILE *fp) +{ + extern void SCAN_lex_init(char *, FILE *); extern YYSTYPE yylval; extern int yyerrstatus; int tokenID; parse_data_t parseData; - void * parser = ParseAlloc( malloc ); - perplex_t scanner = perplexFileScanner( fp ); + void *parser = ParseAlloc(malloc); + perplex_t scanner = perplexFileScanner(fp); parseData.scanner = scanner; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "parse (pass %d)\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "parse (pass %d)\n", EXPRESSpass); } - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "parse: %s (schema file)\n", filename ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "parse: %s (schema file)\n", filename); } - SCAN_lex_init( filename, fp ); + SCAN_lex_init(filename, fp); parserInitState(); yyerrstatus = 0; /* NOTE uncomment the next line to enable parser tracing */ /* ParseTrace( stderr, "- expparse - " ); */ - while( ( tokenID = yylex( scanner ) ) > 0 ) { - Parse( parser, tokenID, yylval, parseData ); + while((tokenID = yylex(scanner)) > 0) { + Parse(parser, tokenID, yylval, parseData); } - Parse( parser, 0, yylval, parseData ); + Parse(parser, 0, yylval, parseData); /* want 0 on success, 1 on invalid input, 2 on memory exhaustion */ - if( yyerrstatus != 0 ) { - fprintf( stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus ); - ERRORreport( BAIL_OUT ); + if(yyerrstatus != 0) { + fprintf(stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus); + ERRORreport(BAIL_OUT); /* free model and model->u.express */ return 0; } EXPRESSpass = 1; - perplexFree( scanner ); - ParseFree( parser, free ); + perplexFree(scanner); + ParseFree(parser, free); return yyexpresult; } @@ -409,40 +420,42 @@ static Express PARSERrun( char * filename, FILE * fp ) { * * Sept 2013 - remove unused param enum rename_type type (TODO should this be used)? */ -static void * SCOPEfind_for_rename( Scope schema, char * name ) { +static void *SCOPEfind_for_rename(Scope schema, char *name) +{ void *result; - Rename * rename; + Rename *rename; /* object can only appear in top level symbol table */ /* OR in another rename clause */ - result = DICTlookup( schema->symbol_table, name ); - if( result ) { + result = DICTlookup(schema->symbol_table, name); + if(result) { return result; } /* Occurs in a fully USE'd schema? */ - LISTdo( schema->u.schema->use_schemas, use_schema, Schema ) { + LISTdo(schema->u.schema->use_schemas, use_schema, Schema) { /* follow chain'd USEs */ - result = SCOPEfind_for_rename( use_schema, name ); - if( result ) { - return( result ); + result = SCOPEfind_for_rename(use_schema, name); + if(result) { + return(result); } - } LISTod; + } + LISTod; /* Occurs in a partially USE'd schema? */ - rename = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); - if( rename ) { - RENAMEresolve( rename, schema ); + rename = (Rename *)DICTlookup(schema->u.schema->usedict, name); + if(rename) { + RENAMEresolve(rename, schema); DICT_type = rename->type; - return( rename->object ); + return(rename->object); } - LISTdo( schema->u.schema->uselist, r, Rename * ) - if( !strcmp( ( r->nnew ? r->nnew : r->old )->name, name ) ) { - RENAMEresolve( r, schema ); + LISTdo(schema->u.schema->uselist, r, Rename *) + if(!strcmp((r->nnew ? r->nnew : r->old)->name, name)) { + RENAMEresolve(r, schema); DICT_type = r->type; - return( r->object ); + return(r->object); } LISTod; @@ -453,111 +466,114 @@ static void * SCOPEfind_for_rename( Scope schema, char * name ) { return 0; } -void RENAMEresolve( Rename * r, Schema s ) { +void RENAMEresolve(Rename *r, Schema s) +{ void *remote; /* if (is_resolved_rename_raw(r->old)) return;*/ - if( r->object ) { + if(r->object) { return; } - if( is_resolve_failed_raw( r->old ) ) { + if(is_resolve_failed_raw(r->old)) { return; } - if( is_resolve_in_progress_raw( r->old ) ) { - ERRORreport_with_symbol( CIRCULAR_REFERENCE, - r->old, r->old->name ); - resolve_failed_raw( r->old ); + if(is_resolve_in_progress_raw(r->old)) { + ERRORreport_with_symbol(CIRCULAR_REFERENCE, + r->old, r->old->name); + resolve_failed_raw(r->old); return; } - resolve_in_progress_raw( r->old ); + resolve_in_progress_raw(r->old); - remote = SCOPEfind_for_rename( r->schema, r->old->name ); - if( remote == 0 ) { - ERRORreport_with_symbol( REF_NONEXISTENT, r->old, - r->old->name, r->schema->symbol.name ); - resolve_failed_raw( r->old ); + remote = SCOPEfind_for_rename(r->schema, r->old->name); + if(remote == 0) { + ERRORreport_with_symbol(REF_NONEXISTENT, r->old, + r->old->name, r->schema->symbol.name); + resolve_failed_raw(r->old); } else { r->object = remote; r->type = DICT_type; - switch( r->rename_type ) { + switch(r->rename_type) { case use: - SCHEMAdefine_use( s, r ); + SCHEMAdefine_use(s, r); break; case ref: - SCHEMAdefine_reference( s, r ); + SCHEMAdefine_reference(s, r); break; } /* resolve_rename_raw(r->old);*/ } - resolve_not_in_progress_raw( r->old ); + resolve_not_in_progress_raw(r->old); } #ifdef using_enum_items_is_a_pain -static void RENAMEresolve_enum( Type t, Schema s ) { +static void RENAMEresolve_enum(Type t, Schema s) +{ DictionaryEntry de; Expression x; - DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); - while( 0 != ( x = ( Expression )DICTdo( &de ) ) ) { + DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); + while(0 != (x = (Expression)DICTdo(&de))) { /* SCHEMAadd_use(s, v*/ /* raw(x->symbol.name);*/ } } #endif -Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) { +Schema EXPRESSfind_schema(Dictionary modeldict, char *name) +{ Schema s; - FILE * fp; - char * src, *dest; + FILE *fp; + char *src, *dest; char lower[MAX_SCHEMA_FILENAME_SIZE]; /* avoid lowerizing original */ - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema reference)\n", - EXPRESSpass, name ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema reference)\n", + EXPRESSpass, name); } - s = ( Schema )DICTlookup( modeldict, name ); - if( s ) { + s = (Schema)DICTlookup(modeldict, name); + if(s) { return s; } dest = lower; - for( src = name; *src; src++ ) { - *dest++ = tolower( *src ); + for(src = name; *src; src++) { + *dest++ = tolower(*src); } *dest = '\0'; /* go down path looking for file */ - LISTdo( EXPRESS_path, dir, Dir * ) - sprintf( dir->leaf, "%s.exp", lower ); - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema file?)\n", - EXPRESSpass, dir->full ); - } - fp = fopen( dir->full, "r" ); - if( fp ) { + LISTdo(EXPRESS_path, dir, Dir *) + sprintf(dir->leaf, "%s.exp", lower); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema file?)\n", + EXPRESSpass, dir->full); + } + fp = fopen(dir->full, "r"); + if(fp) { Express express; - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema file found)\n", - EXPRESSpass, dir->full ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema file found)\n", + EXPRESSpass, dir->full); } - express = PARSERrun( SCANstrdup( dir->full ), fp ); - if( express ) { - s = ( Schema )DICTlookup( modeldict, name ); + express = PARSERrun(SCANstrdup(dir->full), fp); + if(express) { + s = (Schema)DICTlookup(modeldict, name); } - if( s ) { + if(s) { return s; } - ERRORreport( SCHEMA_NOT_IN_OWN_SCHEMA_FILE, - name, dir->full ); + ERRORreport(SCHEMA_NOT_IN_OWN_SCHEMA_FILE, + name, dir->full); return 0; } else { - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno); } } LISTod @@ -571,19 +587,20 @@ Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) { * because of partial schema references * \sa connect_schema_lists() */ -static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) { - Rename * r; +static void connect_lists(Dictionary modeldict, Schema schema, Linked_List list) +{ + Rename *r; /* translate symbols to schemas */ - LISTdo_links( list, l ) - r = ( Rename * )l->data; - r->schema = EXPRESSfind_schema( modeldict, r->schema_sym->name ); - if( !r->schema ) { + LISTdo_links(list, l) + r = (Rename *)l->data; + r->schema = EXPRESSfind_schema(modeldict, r->schema_sym->name); + if(!r->schema) { ERRORreport_with_symbol(UNDEFINED_SCHEMA, - r->schema_sym, - r->schema_sym->name ); - resolve_failed_raw( r->old ); - resolve_failed( schema ); + r->schema_sym, + r->schema_sym->name); + resolve_failed_raw(r->old); + resolve_failed(schema); } LISTod } @@ -592,17 +609,18 @@ static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list * same as `connect_lists` except for full schemas * \sa connect_lists() */ -static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_list ) { - Symbol * sym; +static void connect_schema_lists(Dictionary modeldict, Schema schema, Linked_List schema_list) +{ + Symbol *sym; Schema ref_schema; /* translate symbols to schemas */ - LISTdo_links( schema_list, list ) - sym = ( Symbol * )list->data; - ref_schema = EXPRESSfind_schema( modeldict, sym->name ); - if( !ref_schema ) { - ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name ); - resolve_failed( schema ); + LISTdo_links(schema_list, list) + sym = (Symbol *)list->data; + ref_schema = EXPRESSfind_schema(modeldict, sym->name); + if(!ref_schema) { + ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name); + resolve_failed(schema); list->data = NULL; } else { list->data = ref_schema; @@ -614,7 +632,8 @@ static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_Li ** \param model - Working Form model to resolve ** Perform symbol resolution on a loosely-coupled WF. */ -void EXPRESSresolve( Express model ) { +void EXPRESSresolve(Express model) +{ /* resolve multiple schemas. Schemas will be resolved here or when */ /* they are first encountered by a use/reference clause, whichever */ /* comes first - DEL */ @@ -623,14 +642,14 @@ void EXPRESSresolve( Express model ) { DictionaryEntry de; jmp_buf env; - if( setjmp( env ) ) { + if(setjmp(env)) { return; } - ERRORsafe( env ); + ERRORsafe(env); EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving schema references\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving schema references\n", EXPRESSpass); } /* connect the real schemas to all the rename clauses */ @@ -640,58 +659,59 @@ void EXPRESSresolve( Express model ) { /* add news schemas to end, drop old ones off the front as we */ /* process them. */ - LISTdo( PARSEnew_schemas, print_schema, Schema ) { - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema)\n", - EXPRESSpass, print_schema->symbol.name ); + LISTdo(PARSEnew_schemas, print_schema, Schema) { + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema)\n", + EXPRESSpass, print_schema->symbol.name); } - if( print_schema->u.schema->uselist ) - connect_lists( model->symbol_table, - print_schema, print_schema->u.schema->uselist ); - if( print_schema->u.schema->reflist ) - connect_lists( model->symbol_table, - print_schema, print_schema->u.schema->reflist ); + if(print_schema->u.schema->uselist) + connect_lists(model->symbol_table, + print_schema, print_schema->u.schema->uselist); + if(print_schema->u.schema->reflist) + connect_lists(model->symbol_table, + print_schema, print_schema->u.schema->reflist); - connect_schema_lists( model->symbol_table, - print_schema, print_schema->u.schema->use_schemas ); - connect_schema_lists( model->symbol_table, - print_schema, print_schema->u.schema->ref_schemas ); - } LISTod; + connect_schema_lists(model->symbol_table, + print_schema, print_schema->u.schema->use_schemas); + connect_schema_lists(model->symbol_table, + print_schema, print_schema->u.schema->ref_schemas); + } + LISTod; - LISTfree( PARSEnew_schemas ); + LISTfree(PARSEnew_schemas); PARSEnew_schemas = 0; /* just in case */ EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass); } /* connect the object in each rename clause to the real object */ - DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); - while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { - if( is_not_resolvable( schema ) ) { + DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); + while(0 != (schema = (Schema)DICTdo(&de))) { + if(is_not_resolvable(schema)) { continue; } - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name); } /* do USE's first because they take precedence */ - if( schema->u.schema->uselist ) { - LISTdo( schema->u.schema->uselist, r, Rename * ) - RENAMEresolve( r, schema ); + if(schema->u.schema->uselist) { + LISTdo(schema->u.schema->uselist, r, Rename *) + RENAMEresolve(r, schema); LISTod; - LISTfree( schema->u.schema->uselist ); + LISTfree(schema->u.schema->uselist); schema->u.schema->uselist = 0; } - if( schema->u.schema->reflist ) { - LISTdo( schema->u.schema->reflist, r, Rename * ) - RENAMEresolve( r, schema ); + if(schema->u.schema->reflist) { + LISTdo(schema->u.schema->reflist, r, Rename *) + RENAMEresolve(r, schema); LISTod; - LISTfree( schema->u.schema->reflist ); + LISTfree(schema->u.schema->reflist); schema->u.schema->reflist = 0; } } @@ -699,29 +719,29 @@ void EXPRESSresolve( Express model ) { /* resolve sub- and supertype references. also resolve all */ /* defined types */ EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass); } - DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); - while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { - if( is_not_resolvable( schema ) ) { + DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); + while(0 != (schema = (Schema)DICTdo(&de))) { + if(is_not_resolvable(schema)) { continue; } - SCOPEresolve_subsupers( schema ); + SCOPEresolve_subsupers(schema); } - if( ERRORoccurred ) { + if(ERRORoccurred) { ERRORunsafe(); } /* resolve types */ EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving types\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving types\n", EXPRESSpass); } - SCOPEresolve_types( model ); - if( ERRORoccurred ) { + SCOPEresolve_types(model); + if(ERRORoccurred) { ERRORunsafe(); } @@ -730,56 +750,57 @@ void EXPRESSresolve( Express model ) { /* doesn't really deserve its own pass, but needs to come after */ /* type resolution */ EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving implied USE's\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving implied USE's\n", EXPRESSpass); } - DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); - while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { - if( is_not_resolvable( schema ) ) { + DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); + while(0 != (schema = (Schema)DICTdo(&de))) { + if(is_not_resolvable(schema)) { continue; } - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name); } - if( schema->u.schema->usedict ) { - DICTdo_init( schema->u.schema->usedict, &fg ) - while( 0 != ( r = ( Rename )DICTdo( &fg ) ) ) { - if( ( r->type = OBJ_TYPE ) && ( ( Type )r->object )->body && - TYPEis_enumeration( ( Type )r->object ) ) { - RENAMEresolve_enum( ( Type )r->object, schema ); + if(schema->u.schema->usedict) { + DICTdo_init(schema->u.schema->usedict, &fg) + while(0 != (r = (Rename)DICTdo(&fg))) { + if((r->type = OBJ_TYPE) && ((Type)r->object)->body && + TYPEis_enumeration((Type)r->object)) { + RENAMEresolve_enum((Type)r->object, schema); } } } } - if( ERRORoccurred ) { + if(ERRORoccurred) { ERRORunsafe(); } #endif EXPRESSpass++; - if( print_objects_while_running & OBJ_PASS_BITS ) { - fprintf( stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass ); + if(print_objects_while_running & OBJ_PASS_BITS) { + fprintf(stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass); } - SCOPEresolve_expressions_statements( model ); - if( ERRORoccurred ) { + SCOPEresolve_expressions_statements(model); + if(ERRORoccurred) { ERRORunsafe(); } /* mark everything resolved if possible */ - DICTdo_init( model->symbol_table, &de ); - while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { - if( is_resolvable( schema ) ) { - resolved_all( schema ); + DICTdo_init(model->symbol_table, &de); + while(0 != (schema = (Schema)DICTdo(&de))) { + if(is_resolvable(schema)) { + resolved_all(schema); } } } -Function funcdef(char *name, int pcount, Type ret_typ) { +Function funcdef(char *name, int pcount, Type ret_typ) +{ Function f = ALGcreate(OBJ_FUNCTION); f->symbol.name = name; f->u.func->pcount = pcount; @@ -790,7 +811,8 @@ Function funcdef(char *name, int pcount, Type ret_typ) { return f; } -void procdef(char *name, int pcount) { +void procdef(char *name, int pcount) +{ Procedure p = ALGcreate(OBJ_PROCEDURE); p->symbol.name = name; p->u.proc->pcount = pcount; @@ -799,39 +821,40 @@ void procdef(char *name, int pcount) { DICTdefine(EXPRESSbuiltins, name, p, 0, OBJ_PROCEDURE); } -void BUILTINSinitialize() { - EXPRESSbuiltins = DICTcreate( 35 ); - procdef("INSERT", 3 ); - procdef("REMOVE", 2 ); - - funcdef("ABS", 1, Type_Number ); - funcdef("ACOS", 1, Type_Real ); - funcdef("ASIN", 1, Type_Real ); - funcdef("ATAN", 2, Type_Real ); - funcdef("BLENGTH", 1, Type_Integer ); - funcdef("COS", 1, Type_Real ); - funcdef("EXISTS", 1, Type_Boolean ); - funcdef("EXP", 1, Type_Real ); - funcdef("FORMAT", 2, Type_String ); - funcdef("HIBOUND", 1, Type_Integer ); - funcdef("HIINDEX", 1, Type_Integer ); - funcdef("LENGTH", 1, Type_Integer ); - funcdef("LOBOUND", 1, Type_Integer ); - funcdef("LOG", 1, Type_Real ); - funcdef("LOG10", 1, Type_Real ); - funcdef("LOG2", 1, Type_Real ); - funcdef("LOINDEX", 1, Type_Integer ); - funcdef("ODD", 1, Type_Logical ); - funcdef("ROLESOF", 1, Type_Set_Of_String ); - funcdef("SIN", 1, Type_Real ); - funcdef("SIZEOF", 1, Type_Integer ); - funcdef("SQRT", 1, Type_Real ); - funcdef("TAN", 1, Type_Real ); - funcdef("TYPEOF", 1, Type_Set_Of_String ); - funcdef("VALUE", 1, Type_Number ); - funcdef("VALUE_IN", 2, Type_Logical ); - funcdef("VALUE_UNIQUE", 1, Type_Logical ); - - FUNC_NVL = funcdef("NVL", 2, Type_Generic ); - FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic ); +void BUILTINSinitialize() +{ + EXPRESSbuiltins = DICTcreate(35); + procdef("INSERT", 3); + procdef("REMOVE", 2); + + funcdef("ABS", 1, Type_Number); + funcdef("ACOS", 1, Type_Real); + funcdef("ASIN", 1, Type_Real); + funcdef("ATAN", 2, Type_Real); + funcdef("BLENGTH", 1, Type_Integer); + funcdef("COS", 1, Type_Real); + funcdef("EXISTS", 1, Type_Boolean); + funcdef("EXP", 1, Type_Real); + funcdef("FORMAT", 2, Type_String); + funcdef("HIBOUND", 1, Type_Integer); + funcdef("HIINDEX", 1, Type_Integer); + funcdef("LENGTH", 1, Type_Integer); + funcdef("LOBOUND", 1, Type_Integer); + funcdef("LOG", 1, Type_Real); + funcdef("LOG10", 1, Type_Real); + funcdef("LOG2", 1, Type_Real); + funcdef("LOINDEX", 1, Type_Integer); + funcdef("ODD", 1, Type_Logical); + funcdef("ROLESOF", 1, Type_Set_Of_String); + funcdef("SIN", 1, Type_Real); + funcdef("SIZEOF", 1, Type_Integer); + funcdef("SQRT", 1, Type_Real); + funcdef("TAN", 1, Type_Real); + funcdef("TYPEOF", 1, Type_Set_Of_String); + funcdef("VALUE", 1, Type_Number); + funcdef("VALUE_IN", 2, Type_Logical); + funcdef("VALUE_UNIQUE", 1, Type_Logical); + + FUNC_NVL = funcdef("NVL", 2, Type_Generic); + FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic); } diff --git a/src/express/factory.c b/src/express/factory.c index daf6ee7d3..0e739518c 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -34,138 +34,144 @@ Type Type_Set_Of_String; Type Type_Set_Of_Generic; Type Type_Bag_Of_Generic; -void FACTORYinitialize() { +void FACTORYinitialize() +{ /* Very commonly-used read-only types */ - Type_Unknown = TYPEcreate( unknown_ ); - Type_Dont_Care = TYPEcreate( special_ ); - Type_Bad = TYPEcreate( special_ ); - Type_Runtime = TYPEcreate( runtime_ ); + Type_Unknown = TYPEcreate(unknown_); + Type_Dont_Care = TYPEcreate(special_); + Type_Bad = TYPEcreate(special_); + Type_Runtime = TYPEcreate(runtime_); - Type_Enumeration = TYPEcreate( enumeration_ ); + Type_Enumeration = TYPEcreate(enumeration_); Type_Enumeration->u.type->body->flags.shared = 1; - resolved_all( Type_Enumeration ); + resolved_all(Type_Enumeration); - Type_Expression = TYPEcreate( op_ ); + Type_Expression = TYPEcreate(op_); Type_Expression->u.type->body->flags.shared = 1; - Type_Aggregate = TYPEcreate( aggregate_ ); + Type_Aggregate = TYPEcreate(aggregate_); Type_Aggregate->u.type->body->flags.shared = 1; Type_Aggregate->u.type->body->base = Type_Runtime; - Type_Integer = TYPEcreate( integer_ ); + Type_Integer = TYPEcreate(integer_); Type_Integer->u.type->body->flags.shared = 1; - resolved_all( Type_Integer ); + resolved_all(Type_Integer); - Type_Real = TYPEcreate( real_ ); + Type_Real = TYPEcreate(real_); Type_Real->u.type->body->flags.shared = 1; - resolved_all( Type_Real ); + resolved_all(Type_Real); - Type_Number = TYPEcreate( number_ ); + Type_Number = TYPEcreate(number_); Type_Number->u.type->body->flags.shared = 1; - resolved_all( Type_Number ); + resolved_all(Type_Number); - Type_String = TYPEcreate( string_ ); + Type_String = TYPEcreate(string_); Type_String->u.type->body->flags.shared = 1; - resolved_all( Type_String ); + resolved_all(Type_String); - Type_String_Encoded = TYPEcreate( string_ ); + Type_String_Encoded = TYPEcreate(string_); Type_String_Encoded->u.type->body->flags.shared = 1; Type_String_Encoded->u.type->body->flags.encoded = 1; - resolved_all( Type_String ); + resolved_all(Type_String); - Type_Logical = TYPEcreate( logical_ ); + Type_Logical = TYPEcreate(logical_); Type_Logical->u.type->body->flags.shared = 1; - resolved_all( Type_Logical ); + resolved_all(Type_Logical); - Type_Binary = TYPEcreate( binary_ ); + Type_Binary = TYPEcreate(binary_); Type_Binary->u.type->body->flags.shared = 1; - resolved_all( Type_Binary ); + resolved_all(Type_Binary); - Type_Number = TYPEcreate( number_ ); + Type_Number = TYPEcreate(number_); Type_Number->u.type->body->flags.shared = 1; - resolved_all( Type_Number ); + resolved_all(Type_Number); - Type_Boolean = TYPEcreate( boolean_ ); + Type_Boolean = TYPEcreate(boolean_); Type_Boolean->u.type->body->flags.shared = 1; - resolved_all( Type_Boolean ); + resolved_all(Type_Boolean); - Type_Generic = TYPEcreate( generic_ ); + Type_Generic = TYPEcreate(generic_); Type_Generic->u.type->body->flags.shared = 1; - resolved_all( Type_Generic ); + resolved_all(Type_Generic); - Type_Set_Of_String = TYPEcreate( set_ ); + Type_Set_Of_String = TYPEcreate(set_); Type_Set_Of_String->u.type->body->flags.shared = 1; Type_Set_Of_String->u.type->body->base = Type_String; - Type_Set_Of_Generic = TYPEcreate( set_ ); + Type_Set_Of_Generic = TYPEcreate(set_); Type_Set_Of_Generic->u.type->body->flags.shared = 1; Type_Set_Of_Generic->u.type->body->base = Type_Generic; - Type_Bag_Of_Generic = TYPEcreate( bag_ ); + Type_Bag_Of_Generic = TYPEcreate(bag_); Type_Bag_Of_Generic->u.type->body->flags.shared = 1; Type_Bag_Of_Generic->u.type->body->base = Type_Generic; - Type_Attribute = TYPEcreate( attribute_ ); + Type_Attribute = TYPEcreate(attribute_); Type_Attribute->u.type->body->flags.shared = 1; - Type_Entity = TYPEcreate( entity_ ); + Type_Entity = TYPEcreate(entity_); Type_Entity->u.type->body->flags.shared = 1; - Type_Funcall = TYPEcreate( funcall_ ); + Type_Funcall = TYPEcreate(funcall_); Type_Funcall->u.type->body->flags.shared = 1; - Type_Generic = TYPEcreate( generic_ ); + Type_Generic = TYPEcreate(generic_); Type_Generic->u.type->body->flags.shared = 1; - Type_Identifier = TYPEcreate( identifier_ ); + Type_Identifier = TYPEcreate(identifier_); Type_Identifier->u.type->body->flags.shared = 1; - Type_Repeat = TYPEcreate( integer_ ); + Type_Repeat = TYPEcreate(integer_); Type_Repeat->u.type->body->flags.shared = 1; Type_Repeat->u.type->body->flags.repeat = 1; - Type_Oneof = TYPEcreate( oneof_ ); + Type_Oneof = TYPEcreate(oneof_); Type_Oneof->u.type->body->flags.shared = 1; - Type_Query = TYPEcreate( query_ ); + Type_Query = TYPEcreate(query_); Type_Query->u.type->body->flags.shared = 1; - Type_Self = TYPEcreate( self_ ); + Type_Self = TYPEcreate(self_); Type_Self->u.type->body->flags.shared = 1; } /** Create and return an empty scope inside a parent scope. */ -Scope SCOPEcreate( char type ) { +Scope SCOPEcreate(char type) +{ Scope d = SCOPE_new(); - d->symbol_table = DICTcreate( 50 ); + d->symbol_table = DICTcreate(50); d->type = type; return d; } -Scope SCOPEcreate_tiny( char type ) { +Scope SCOPEcreate_tiny(char type) +{ Scope d = SCOPE_new(); - d->symbol_table = DICTcreate( 1 ); + d->symbol_table = DICTcreate(1); d->type = type; return d; } -void SCOPEdestroy( Scope scope ) { - SCOPE_destroy( scope ); +void SCOPEdestroy(Scope scope) +{ + SCOPE_destroy(scope); } /** * create a scope without a symbol table * used for simple types */ -Scope SCOPEcreate_nostab( char type ) { +Scope SCOPEcreate_nostab(char type) +{ Scope d = SCOPE_new(); d->type = type; return d; } /** Create and return a schema. */ -Schema SCHEMAcreate( void ) { - Scope s = SCOPEcreate( OBJ_SCHEMA ); +Schema SCHEMAcreate(void) +{ + Scope s = SCOPEcreate(OBJ_SCHEMA); s->enum_table = DICTcreate(50); s->u.schema = SCHEMA_new(); return s; @@ -174,13 +180,14 @@ Schema SCHEMAcreate( void ) { /** * create a type with no symbol table */ -Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { - Type t = SCOPEcreate_nostab( OBJ_TYPE ); +Type TYPEcreate_nostab(struct Symbol_ *symbol, Scope scope, char objtype) +{ + Type t = SCOPEcreate_nostab(OBJ_TYPE); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->symbol = *symbol; - DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); + DICTdefine(scope->symbol_table, symbol->name, t, &t->symbol, objtype); return t; } @@ -190,8 +197,9 @@ Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { * such as enumerations (which have a symbol table added later) * or to be used as a type reference */ -Type TYPEcreate_name( Symbol * symbol ) { - Scope s = SCOPEcreate_nostab( OBJ_TYPE ); +Type TYPEcreate_name(Symbol *symbol) +{ + Scope s = SCOPEcreate_nostab(OBJ_TYPE); TypeHead t = TYPEHEAD_new(); s->u.type = t; @@ -199,31 +207,35 @@ Type TYPEcreate_name( Symbol * symbol ) { return s; } -Type TYPEcreate( enum type_enum type ) { - TypeBody tb = TYPEBODYcreate( type ); - Type t = TYPEcreate_from_body_anonymously( tb ); - return( t ); +Type TYPEcreate(enum type_enum type) +{ + TypeBody tb = TYPEBODYcreate(type); + Type t = TYPEcreate_from_body_anonymously(tb); + return(t); } -Type TYPEcreate_from_body_anonymously( TypeBody tb ) { - Type t = SCOPEcreate_nostab( OBJ_TYPE ); +Type TYPEcreate_from_body_anonymously(TypeBody tb) +{ + Type t = SCOPEcreate_nostab(OBJ_TYPE); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->u.type->body = tb; t->symbol.name = 0; - SYMBOLset( t ); + SYMBOLset(t); return t; } -TypeBody TYPEBODYcreate( enum type_enum type ) { +TypeBody TYPEBODYcreate(enum type_enum type) +{ TypeBody tb = TYPEBODY_new(); tb->type = type; return tb; } -Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { - Symbol * sym = SYMBOL_new(); +Symbol *SYMBOLcreate(char *name, int line, const char *filename) +{ + Symbol *sym = SYMBOL_new(); sym->name = name; sym->line = line; sym->filename = filename; /* NOTE this used the global 'current_filename', @@ -242,18 +254,19 @@ Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { ** empty list; all other aspects of the entity are initially ** undefined (i.e., have appropriate NULL values). */ -Entity ENTITYcreate( Symbol * sym ) { - Scope s = SCOPEcreate( OBJ_ENTITY ); +Entity ENTITYcreate(Symbol *sym) +{ + Scope s = SCOPEcreate(OBJ_ENTITY); s->u.entity = ENTITY_new(); s->u.entity->attributes = LISTcreate(); s->u.entity->inheritance = ENTITY_INHERITANCE_UNINITIALIZED; /* it's so useful to have a type hanging around for each entity */ - s->u.entity->type = TYPEcreate_name( sym ); - s->u.entity->type->u.type->body = TYPEBODYcreate( entity_ ); + s->u.entity->type = TYPEcreate_name(sym); + s->u.entity->type->u.type->body = TYPEBODYcreate(entity_); s->u.entity->type->u.type->body->entity = s; - return( s ); + return(s); } /** VARcreate @@ -266,35 +279,39 @@ Entity ENTITYcreate( Symbol * sym ) { ** dynamic. Special flags associated with the variable ** (e.g., optional) are initially false. */ -Variable VARcreate( Expression name, Type type ) { +Variable VARcreate(Expression name, Type type) +{ Variable v = VAR_new(); v->name = name; v->type = type; return v; } -Expression EXPcreate( Type type ) { +Expression EXPcreate(Type type) +{ Expression e; e = EXP_new(); - SYMBOLset( e ); + SYMBOLset(e); e->type = type; e->return_type = Type_Unknown; - return( e ); + return(e); } /** * use this when the return_type is the same as the type * For example, for constant integers */ -Expression EXPcreate_simple( Type type ) { +Expression EXPcreate_simple(Type type) +{ Expression e; e = EXP_new(); - SYMBOLset( e ); + SYMBOLset(e); e->type = e->return_type = type; - return( e ); + return(e); } -Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { +Expression EXPcreate_from_symbol(Type type, Symbol *symbol) +{ Expression e; e = EXP_new(); e->type = type; @@ -311,8 +328,9 @@ Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { ** \returns Ternary_Expression - the expression created ** Create a ternary operation Expression. */ -Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, Expression operand3 ) { - Expression e = EXPcreate( Type_Expression ); +Expression TERN_EXPcreate(Op_Code op, Expression operand1, Expression operand2, Expression operand3) +{ + Expression e = EXPcreate(Type_Expression); e->e.op_code = op; e->e.op1 = operand1; @@ -329,8 +347,9 @@ Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, ** \returns Binary_Expression - the expression created ** Create a binary operation Expression. */ -Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) { - Expression e = EXPcreate( Type_Expression ); +Expression BIN_EXPcreate(Op_Code op, Expression operand1, Expression operand2) +{ + Expression e = EXPcreate(Type_Expression); e->e.op_code = op; e->e.op1 = operand1; @@ -344,8 +363,9 @@ Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) ** \returns the expression created ** Create a unary operation Expression. */ -Expression UN_EXPcreate( Op_Code op, Expression operand ) { - Expression e = EXPcreate( Type_Expression ); +Expression UN_EXPcreate(Op_Code op, Expression operand) +{ + Expression e = EXPcreate(Type_Expression); e->e.op_code = op; e->e.op1 = operand; @@ -359,14 +379,15 @@ Expression UN_EXPcreate( Op_Code op, Expression operand ) { ** Create a query Expression. ** NOTE Dec 2011 - MP - function description did not match actual params. Had to guess. */ -Expression QUERYcreate( Symbol * local, Expression aggregate ) { - Expression e = EXPcreate_from_symbol( Type_Query, local ); - Scope s = SCOPEcreate_tiny( OBJ_QUERY ); - Expression e2 = EXPcreate_from_symbol( Type_Attribute, local ); +Expression QUERYcreate(Symbol *local, Expression aggregate) +{ + Expression e = EXPcreate_from_symbol(Type_Query, local); + Scope s = SCOPEcreate_tiny(OBJ_QUERY); + Expression e2 = EXPcreate_from_symbol(Type_Attribute, local); - Variable v = VARcreate( e2, Type_Attribute ); + Variable v = VARcreate(e2, Type_Attribute); - DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); + DICTdefine(s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE); e->u.query = QUERY_new(); e->u.query->scope = s; e->u.query->local = v; diff --git a/src/express/fedex.c b/src/express/fedex.c index 805f8aeed..4288a51b9 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -91,15 +91,17 @@ extern int exp_yydebug; char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string because exp2cxx, exppp, etc may append their own options */ static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */ -void print_fedex_version( void ) { - fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version ); +void print_fedex_version(void) +{ + fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version); no_need_to_work = 1; } -int main( int argc, char ** argv ) { +int main(int argc, char **argv) +{ int c; int rc; - char * cp; + char *cp; int no_warnings = 1; int resolve = 1; int result; @@ -114,27 +116,27 @@ int main( int argc, char ** argv ) { EXPRESSinitialize(); - if( EXPRESSinit_args ) { - ( *EXPRESSinit_args )( argc, argv ); + if(EXPRESSinit_args) { + (*EXPRESSinit_args)(argc, argv); } sc_optind = 1; - while( ( c = sc_getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 ) { - switch( c ) { + while((c = sc_getopt(argc, argv, EXPRESSgetopt_options)) != -1) { + switch(c) { case 'd': ERRORdebugging = 1; - switch( atoi( sc_optarg ) ) { + switch(atoi(sc_optarg)) { case 0: - fprintf( stderr, "\ndebug codes:\n" ); - fprintf( stderr, " 0 - this help\n" ); - fprintf( stderr, " 1 - basic debugging\n" ); + fprintf(stderr, "\ndebug codes:\n"); + fprintf(stderr, " 0 - this help\n"); + fprintf(stderr, " 1 - basic debugging\n"); #ifdef debugging - fprintf( stderr, " 4 - light malloc debugging\n" ); - fprintf( stderr, " 5 - heavy malloc debugging\n" ); - fprintf( stderr, " 6 - heavy malloc debugging while resolving\n" ); + fprintf(stderr, " 4 - light malloc debugging\n"); + fprintf(stderr, " 5 - heavy malloc debugging\n"); + fprintf(stderr, " 6 - heavy malloc debugging while resolving\n"); #endif /* debugging*/ #ifdef YYDEBUG - fprintf( stderr, " 8 - set YYDEBUG\n" ); + fprintf(stderr, " 8 - set YYDEBUG\n"); #endif /*YYDEBUG*/ break; case 1: @@ -142,10 +144,10 @@ int main( int argc, char ** argv ) { break; #ifdef debugging case 4: - malloc_debug( 1 ); + malloc_debug(1); break; case 5: - malloc_debug( 2 ); + malloc_debug(2); break; case 6: malloc_debug_resolve = 1; @@ -173,16 +175,16 @@ int main( int argc, char ** argv ) { case 'i': case 'w': no_warnings = 0; - ERRORset_warning( sc_optarg, c == 'w' ); + ERRORset_warning(sc_optarg, c == 'w'); break; case 'p': - for( cp = sc_optarg; *cp; cp++ ) { - if( *cp == '#' ) { + for(cp = sc_optarg; *cp; cp++) { + if(*cp == '#') { print_objects_while_running |= OBJ_PASS_BITS; - } else if( *cp == 'E' ) { + } else if(*cp == 'E') { print_objects_while_running = OBJ_ANYTHING_BITS; } else { - print_objects_while_running |= OBJget_bits( *cp ); + print_objects_while_running |= OBJget_bits(*cp); } } break; @@ -192,12 +194,12 @@ int main( int argc, char ** argv ) { break; default: rc = 1; - if( EXPRESSgetopt ) { - rc = ( *EXPRESSgetopt )( c, sc_optarg ); + if(EXPRESSgetopt) { + rc = (*EXPRESSgetopt)(c, sc_optarg); } - if( rc == 1 ) { - if( ERRORusage_function ) { - ( *ERRORusage_function )(); + if(rc == 1) { + if(ERRORusage_function) { + (*ERRORusage_function)(); } else { EXPRESSusage(1); } @@ -205,66 +207,66 @@ int main( int argc, char ** argv ) { break; } } - if( !input_filename ) { + if(!input_filename) { input_filename = argv[sc_optind]; - if( !input_filename ) { + if(!input_filename) { EXPRESScleanup(); - if( no_need_to_work ) { - return( 0 ); + if(no_need_to_work) { + return(0); } else { - ( *ERRORusage_function )(); + (*ERRORusage_function)(); } } } - if( no_warnings ) { - ERRORset_all_warnings( 1 ); + if(no_warnings) { + ERRORset_all_warnings(1); } - ERRORbuffer_messages( buffer_messages ); + ERRORbuffer_messages(buffer_messages); - if( EXPRESSinit_parse ) { - ( *EXPRESSinit_parse )(); + if(EXPRESSinit_parse) { + (*EXPRESSinit_parse)(); } model = EXPRESScreate(); - EXPRESSparse( model, ( FILE * )0, input_filename ); - if( ERRORoccurred ) { - result = EXPRESS_fail( model ); + EXPRESSparse(model, (FILE *)0, input_filename); + if(ERRORoccurred) { + result = EXPRESS_fail(model); EXPRESScleanup(); - EXPRESSdestroy( model ); + EXPRESSdestroy(model); return result; } #ifdef debugging - if( malloc_debug_resolve ) { + if(malloc_debug_resolve) { malloc_verify(); - malloc_debug( 2 ); + malloc_debug(2); } #endif /*debugging*/ - if( resolve ) { - EXPRESSresolve( model ); - if( ERRORoccurred ) { - result = EXPRESS_fail( model ); + if(resolve) { + EXPRESSresolve(model); + if(ERRORoccurred) { + result = EXPRESS_fail(model); EXPRESScleanup(); - EXPRESSdestroy( model ); + EXPRESSdestroy(model); return result; } } - if( EXPRESSbackend ) { - ( *EXPRESSbackend )( model ); + if(EXPRESSbackend) { + (*EXPRESSbackend)(model); } - if( ERRORoccurred ) { - result = EXPRESS_fail( model ); + if(ERRORoccurred) { + result = EXPRESS_fail(model); EXPRESScleanup(); - EXPRESSdestroy( model ); + EXPRESSdestroy(model); return result; } - result = EXPRESS_succeed( model ); + result = EXPRESS_succeed(model); EXPRESScleanup(); - EXPRESSdestroy( model ); + EXPRESSdestroy(model); return result; } diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index 217c349d6..bc97a5036 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -15,18 +15,18 @@ int yyerrstatus = 0; YYSTYPE yylval; - /* - * YACC grammar for Express parser. - * - * This software was developed by U.S. Government employees as part of - * their official duties and is not subject to copyright. - * - * $Log: expparse.y,v $ - * Revision 1.23 1997/11/14 17:09:04 libes - * allow multiple group references - * - * ** 22 older revision log records removed 3 January 2014 ** - */ +/* + * YACC grammar for Express parser. + * + * This software was developed by U.S. Government employees as part of + * their official duties and is not subject to copyright. + * + * $Log: expparse.y,v $ + * Revision 1.23 1997/11/14 17:09:04 libes + * allow multiple group references + * + * ** 22 older revision log records removed 3 January 2014 ** + */ #include "express/symbol.h" #include "express/linklist.h" @@ -38,9 +38,9 @@ YYSTYPE yylval; #include "expscan.h" #include - extern int print_objects_while_running; +extern int print_objects_while_running; - int tag_count; /**< use this to count tagged GENERIC types in the formal +int tag_count; /**< use this to count tagged GENERIC types in the formal * argument lists. Gross, but much easier to do it this * way then with the 'help' of yacc. Set it to -1 to * indicate that tags cannot be defined, only used @@ -50,46 +50,46 @@ YYSTYPE yylval; * - snc */ - int local_var_count; /**< used to keep LOCAL variables in order +int local_var_count; /**< used to keep LOCAL variables in order * used in combination with Variable.offset */ - Express yyexpresult; /* hook to everything built by parser */ +Express yyexpresult; /* hook to everything built by parser */ - Symbol *interface_schema; /* schema of interest in use/ref clauses */ - void (*interface_func)(); /* func to attach rename clauses */ +Symbol *interface_schema; /* schema of interest in use/ref clauses */ +void (*interface_func)(); /* func to attach rename clauses */ - /* record schemas found in a single parse here, allowing them to be */ - /* differentiated from other schemas parsed earlier */ - Linked_List PARSEnew_schemas; +/* record schemas found in a single parse here, allowing them to be */ +/* differentiated from other schemas parsed earlier */ +Linked_List PARSEnew_schemas; - void SCANskip_to_end_schema(perplex_t scanner); +void SCANskip_to_end_schema(perplex_t scanner); - int yylineno; +int yylineno; - bool yyeof = false; +bool yyeof = false; #define MAX_SCOPE_DEPTH 20 /* max number of scopes that can be nested */ - static struct scope { - struct Scope_ *this_; - char type; /* one of OBJ_XXX */ - struct scope *pscope; /* pointer back to most recent scope */ - /* that has a printable name - for better */ - /* error messages */ - } scopes[MAX_SCOPE_DEPTH], *scope; +static struct scope { + struct Scope_ *this_; + char type; /* one of OBJ_XXX */ + struct scope *pscope; /* pointer back to most recent scope */ + /* that has a printable name - for better */ + /* error messages */ +} scopes[MAX_SCOPE_DEPTH], *scope; #define CURRENT_SCOPE (scope->this_) #define PREVIOUS_SCOPE ((scope-1)->this_) #define CURRENT_SCHEMA (scope->this_->u.schema) #define CURRENT_SCOPE_NAME (OBJget_symbol(scope->pscope->this_,scope->pscope->type)->name) #define CURRENT_SCOPE_TYPE_PRINTABLE (OBJget_type(scope->pscope->type)) - /* ths = new scope to enter */ - /* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ - /* are not named, in which case sym should be 0 */ - /* This is useful for when a diagnostic is printed, an earlier named */ - /* scoped can be used */ - /* typ = type of scope */ +/* ths = new scope to enter */ +/* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ +/* are not named, in which case sym should be 0 */ +/* This is useful for when a diagnostic is printed, an earlier named */ +/* scoped can be used */ +/* typ = type of scope */ #define PUSH_SCOPE(ths,sym,typ) \ if (sym) DICTdefine(scope->this_->symbol_table,(sym)->name,(Generic)ths,sym,typ);\ ths->superscope = scope->this_; \ @@ -102,12 +102,12 @@ YYSTYPE yylval; } #define POP_SCOPE() scope-- - /* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ - /* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ +/* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ +/* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ #define PUSH_SCOPE_DUMMY() scope++ - /* normally the superscope is added by PUSH_SCOPE, but some things (types) */ - /* bother to get pushed so fix them this way */ +/* normally the superscope is added by PUSH_SCOPE, but some things (types) */ +/* bother to get pushed so fix them this way */ #define SCOPEadd_super(ths) ths->superscope = scope->this_; #define ERROR(code) ERRORreport(code, yylineno) @@ -127,10 +127,10 @@ void parserInitState() /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ -/* +/* ** These constants (all generated automatically by the parser generator) ** specify the various kinds of tokens (terminals) that the parser -** understands. +** understands. ** ** Each symbol here is a terminal symbol in the grammar. */ @@ -147,7 +147,7 @@ void parserInitState() ** and nonterminals. "int" is used otherwise. ** YYNOCODE is a number of type YYCODETYPE which corresponds ** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash +** number is used to fill in empty slots of the hash ** table. ** YYFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the @@ -156,7 +156,7 @@ void parserInitState() ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. -** ParseTOKENTYPE is the data type used for minor tokens given +** ParseTOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** YYMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of @@ -176,36 +176,36 @@ void parserInitState() #define YYCODETYPE unsigned short int #define YYNOCODE 280 #define YYACTIONTYPE unsigned short int -#define ParseTOKENTYPE YYSTYPE +#define ParseTOKENTYPE YYSTYPE typedef union { - int yyinit; - ParseTOKENTYPE yy0; - struct qualifier yy46; - Variable yy91; - Op_Code yy126; - struct entity_body yy176; - Where yy234; - struct subsuper_decl yy242; - struct type_flags yy252; - struct upper_lower yy253; - Symbol* yy275; - Type yy297; - Case_Item yy321; - Statement yy332; - Linked_List yy371; - struct type_either yy378; - struct subtypes yy385; - Expression yy401; - TypeBody yy477; - Integer yy507; + int yyinit; + ParseTOKENTYPE yy0; + struct qualifier yy46; + Variable yy91; + Op_Code yy126; + struct entity_body yy176; + Where yy234; + struct subsuper_decl yy242; + struct type_flags yy252; + struct upper_lower yy253; + Symbol *yy275; + Type yy297; + Case_Item yy321; + Statement yy332; + Linked_List yy371; + struct type_either yy378; + struct subtypes yy385; + Expression yy401; + TypeBody yy477; + Integer yy507; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 0 #endif #define ParseARG_SDECL parse_data_t parseData ; -#define ParseARG_PDECL , parse_data_t parseData -#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData -#define ParseARG_STORE yypParser->parseData = parseData +#define ParseARG_PDECL , parse_data_t parseData +#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData +#define ParseARG_STORE yypParser->parseData = parseData #define YYNSTATE 645 #define YYNRULE 332 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) @@ -232,7 +232,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; /* Next are the tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an -** action integer. +** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows @@ -257,7 +257,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; ** If the index value yy_shift_ofst[S]+X is out of range or if the value ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. +** and that yy_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after @@ -278,691 +278,691 @@ static const YYMINORTYPE yyzerominor = { 0 }; */ #define YY_ACTTAB_COUNT (2659) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, - /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, - /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, - /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, - /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, - /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, - /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, - /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, - /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, - /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, - /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, - /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, - /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, - /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, - /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, - /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, - /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, - /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, - /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, - /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, - /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, - /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, - /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, - /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, - /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, - /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, - /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, - /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, - /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, - /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, - /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, - /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, - /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, - /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, - /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, - /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, - /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, - /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, - /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, - /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, - /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, - /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, - /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, - /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, - /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, - /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, - /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, - /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, - /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, - /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, - /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, - /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, - /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, - /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, - /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, - /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, - /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, - /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, - /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, - /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, - /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, - /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, - /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, - /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, - /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, - /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, - /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, - /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, - /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, - /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, - /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, - /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, - /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, - /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, - /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, - /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, - /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, - /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, - /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, - /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, - /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, - /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, - /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, - /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, - /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, - /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, - /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, - /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, - /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, - /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, - /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, - /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, - /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, - /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, - /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, - /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, - /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, - /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, - /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, - /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, - /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, - /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, - /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, - /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, - /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, - /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, - /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, - /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, - /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, - /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, - /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, - /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, - /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, - /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, - /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, - /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, - /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, - /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, - /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, - /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, - /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, - /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, - /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, - /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, - /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, - /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, - /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, - /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, - /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, - /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, - /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, - /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, - /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, - /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, - /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, - /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, - /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, - /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, - /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, - /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, - /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, - /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, - /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, - /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, - /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, - /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, - /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, - /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, - /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, - /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, - /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, - /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, - /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, - /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, - /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, - /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, - /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, - /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, - /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, - /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, - /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, - /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, - /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, - /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, - /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, - /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, - /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, - /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, - /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, - /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, - /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, - /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, - /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, - /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, - /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, - /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, - /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, - /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, - /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, - /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, - /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, - /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, - /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, - /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, - /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, - /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, - /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, - /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, - /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, - /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, - /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, - /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, - /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, - /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, - /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, - /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, - /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, - /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, - /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, - /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, - /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, - /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, - /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, - /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, - /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, - /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, - /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, - /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, - /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, - /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, - /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, - /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, - /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, - /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, - /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, - /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, - /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, - /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, - /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, - /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, - /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, - /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, - /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, - /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, - /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, - /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, - /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, - /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, + /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, + /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, + /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, + /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, + /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, + /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, + /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, + /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, + /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, + /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, + /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, + /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, + /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, + /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, + /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, + /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, + /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, + /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, + /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, + /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, + /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, + /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, + /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, + /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, + /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, + /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, + /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, + /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, + /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, + /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, + /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, + /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, + /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, + /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, + /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, + /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, + /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, + /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, + /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, + /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, + /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, + /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, + /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, + /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, + /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, + /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, + /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, + /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, + /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, + /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, + /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, + /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, + /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, + /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, + /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, + /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, + /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, + /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, + /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, + /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, + /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, + /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, + /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, + /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, + /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, + /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, + /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, + /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, + /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, + /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, + /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, + /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, + /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, + /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, + /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, + /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, + /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, + /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, + /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, + /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, + /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, + /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, + /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, + /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, + /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, + /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, + /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, + /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, + /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, + /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, + /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, + /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, + /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, + /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, + /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, + /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, + /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, + /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, + /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, + /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, + /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, + /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, + /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, + /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, + /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, + /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, + /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, + /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, + /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, + /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, + /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, + /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, + /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, + /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, + /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, + /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, + /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, + /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, + /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, + /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, + /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, + /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, + /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, + /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, + /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, + /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, + /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, + /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, + /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, + /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, + /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, + /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, + /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, + /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, + /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, + /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, + /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, + /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, + /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, + /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, + /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, + /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, + /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, + /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, + /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, + /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, + /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, + /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, + /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, + /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, + /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, + /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, + /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, + /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, + /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, + /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, + /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, + /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, + /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, + /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, + /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, + /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, + /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, + /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, + /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, + /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, + /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, + /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, + /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, + /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, + /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, + /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, + /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, + /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, + /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, + /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, + /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, + /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, + /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, + /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, + /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, + /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, + /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, + /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, + /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, + /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, + /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, + /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, + /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, + /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, + /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, + /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, + /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, + /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, + /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, + /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, + /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, + /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, + /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, + /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, + /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, + /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, + /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, + /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, + /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, + /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, + /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, + /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, + /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, + /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, + /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, + /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, + /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, + /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, + /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, + /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, + /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, + /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, + /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, + /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, + /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, + /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, + /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, + /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, + /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, + /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, + /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, + /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, - /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, - /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, - /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, - /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, - /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, - /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, - /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, - /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, - /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, - /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, - /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, - /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, - /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, - /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, - /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, - /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, - /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, - /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, - /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, - /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, - /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, - /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, - /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, - /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, - /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, - /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, - /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, - /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, - /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, - /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, - /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, - /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, - /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, - /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, - /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, - /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, - /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, - /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, - /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, - /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, - /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, - /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, - /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, - /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, - /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, - /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, - /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, - /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, - /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, - /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, - /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, - /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, - /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, - /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, - /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, - /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, - /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, - /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, - /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, - /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, - /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, - /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, - /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, - /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, - /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, - /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, - /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, - /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, - /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, - /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, - /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, - /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, - /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, - /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, - /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, - /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, - /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, - /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, - /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, - /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, - /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, - /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, - /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, - /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, - /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, - /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, - /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, - /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, - /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, - /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, - /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, - /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, - /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, - /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, - /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, - /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, - /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, - /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, - /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, - /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, - /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, - /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, - /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, - /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, - /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, - /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, - /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, - /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, - /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, - /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, - /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, - /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, - /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, - /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, - /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, - /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, - /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, - /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, - /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, - /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, - /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, - /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, - /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, - /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, - /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, - /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, - /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, - /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, - /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, - /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, - /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, - /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, - /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, - /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, - /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, - /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, - /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, - /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, - /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, - /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, - /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, - /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, - /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, - /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, - /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, - /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, - /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, - /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, - /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, - /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, - /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, - /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, - /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, - /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, - /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, - /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, - /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, - /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, - /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, - /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, - /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, - /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, - /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, - /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, - /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, - /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, - /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, - /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, - /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, - /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, - /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, - /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, - /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, - /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, - /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, - /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, - /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, - /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, - /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, - /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, - /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, - /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, - /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, - /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, - /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, - /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, - /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, - /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, - /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, - /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, - /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, - /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, - /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, - /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, - /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, - /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, - /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, - /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, - /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, + /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, + /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, + /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, + /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, + /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, + /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, + /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, + /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, + /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, + /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, + /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, + /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, + /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, + /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, + /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, + /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, + /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, + /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, + /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, + /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, + /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, + /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, + /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, + /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, + /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, + /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, + /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, + /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, + /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, + /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, + /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, + /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, + /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, + /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, + /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, + /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, + /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, + /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, + /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, + /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, + /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, + /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, + /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, + /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, + /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, + /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, + /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, + /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, + /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, + /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, + /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, + /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, + /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, + /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, + /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, + /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, + /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, + /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, + /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, + /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, + /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, + /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, + /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, + /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, + /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, + /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, + /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, + /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, + /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, + /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, + /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, + /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, + /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, + /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, + /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, + /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, + /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, + /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, + /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, + /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, + /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, + /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, + /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, + /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, + /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, + /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, + /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, + /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, + /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, + /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, + /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, + /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, + /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, + /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, + /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, + /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, + /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, + /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, + /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, + /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, + /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, + /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, + /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, + /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, + /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, + /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, + /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, + /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, + /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, + /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, + /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, + /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, + /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, + /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, + /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, + /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, + /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, + /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, + /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, + /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, + /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, + /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, + /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, + /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, + /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, + /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, + /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, + /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, + /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, + /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, + /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, + /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, + /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, + /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, + /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, + /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, + /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, + /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, + /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, + /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, + /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, + /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, + /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, + /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, + /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, + /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, + /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, + /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, + /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, + /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, + /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, + /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, + /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, + /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, + /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, + /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, + /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, + /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, + /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, + /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, + /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, + /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, + /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, + /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, + /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, + /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, + /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, + /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, + /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, + /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, + /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, + /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, + /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, + /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, + /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, + /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, + /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, + /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, + /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, + /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, + /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, + /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, + /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, + /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, + /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, + /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, + /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, + /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, + /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, + /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, + /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, + /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, + /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, + /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, + /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, + /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, + /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, + /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, + /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, + /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, }; #define YY_SHIFT_USE_DFLT (-70) #define YY_SHIFT_COUNT (402) #define YY_SHIFT_MIN (-69) #define YY_SHIFT_MAX (2144) static const short yy_shift_ofst[] = { - /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, - /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, - /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, - /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, - /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, - /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, - /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, - /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, - /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, - /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, - /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, - /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, - /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, - /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, - /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, - /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, - /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, - /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, - /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, - /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, - /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, - /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, - /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, - /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, - /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, - /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, - /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, - /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, - /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, - /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, - /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, - /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, - /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, - /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, - /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, - /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, - /* 400 */ 34, 9, -69, + /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, + /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, + /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, + /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, + /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, + /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, + /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, + /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, + /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, + /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, + /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, + /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, + /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, + /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, + /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, + /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, + /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, + /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, + /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, + /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, + /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, + /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, + /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, + /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, + /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, + /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, + /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, + /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, + /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, + /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, + /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, + /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, + /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, + /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, + /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, + /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, + /* 400 */ 34, 9, -69, }; #define YY_REDUCE_USE_DFLT (-179) #define YY_REDUCE_COUNT (254) #define YY_REDUCE_MIN (-178) #define YY_REDUCE_MAX (2443) static const short yy_reduce_ofst[] = { - /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, - /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, - /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, - /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, - /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, - /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, - /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, - /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, - /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, - /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, - /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, - /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, - /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, - /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, - /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, - /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, - /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, - /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, - /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, - /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, - /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, - /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, - /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, - /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, - /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, - /* 250 */ 718, 700, 581, 569, 614, + /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, + /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, + /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, + /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, + /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, + /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, + /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, + /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, + /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, + /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, + /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, + /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, + /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, + /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, + /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, + /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, + /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, + /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, + /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, + /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, + /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, + /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, + /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, + /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, + /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, + /* 250 */ 718, 700, 581, 569, 614, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, - /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, - /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, - /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, - /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, - /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, - /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, - /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, - /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, - /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, - /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, - /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, - /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, - /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, - /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, - /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, - /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, - /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, - /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, - /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, - /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, - /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, - /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, - /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, - /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, - /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, - /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, - /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, - /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, - /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, - /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, - /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, - /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, - /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, - /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, - /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, - /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, - /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, - /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, - /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, - /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, - /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, - /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, - /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, - /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, - /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, - /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, - /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, - /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, - /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, - /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, - /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, - /* 640 */ 688, 687, 899, 797, 733, + /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, + /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, + /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, + /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, + /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, + /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, + /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, + /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, + /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, + /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, + /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, + /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, + /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, + /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, + /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, + /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, + /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, + /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, + /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, + /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, + /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, + /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, + /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, + /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, + /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, + /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, + /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, + /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, + /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, + /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, + /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, + /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, + /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, + /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, + /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, + /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, + /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, + /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, + /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, + /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, + /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, + /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, + /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, + /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, + /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, + /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, + /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, + /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, + /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, + /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, + /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, + /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, + /* 640 */ 688, 687, 899, 797, 733, }; /* The next table maps tokens into fallback tokens. If a construct ** like the following: -** +** ** %fallback ID X Y Z. ** ** appears in the grammar, then ID becomes a fallback token for X, Y, @@ -988,10 +988,10 @@ static const YYCODETYPE yyFallback[] = { ** It is sometimes called the "minor" token. */ struct yyStackEntry { - YYACTIONTYPE stateno; /* The state-number */ - YYCODETYPE major; /* The major token value. This is the code + YYACTIONTYPE stateno; /* The state-number */ + YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This + YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; @@ -999,17 +999,17 @@ typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { - int yyidx; /* Index of top element in stack */ + int yyidx; /* Index of top element in stack */ #ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ + int yyidxMax; /* Maximum value of yyidx */ #endif - int yyerrcnt; /* Shifts left before out of the error */ - ParseARG_SDECL /* A place to hold %extra_argument */ + int yyerrcnt; /* Shifts left before out of the error */ + ParseARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ + int yystksz; /* Current side of the stack */ + yyStackEntry *yystack; /* The parser's stack */ #else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ + yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ #endif }; typedef struct yyParser yyParser; @@ -1021,10 +1021,10 @@ static char *yyTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG -/* +/* ** Turn parser tracing on by giving a stream to which to write the trace ** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL +** by making either argument NULL ** ** Inputs: **
    @@ -1038,88 +1038,92 @@ static char *yyTracePrompt = 0; ** Outputs: ** None. */ -void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; +void ParseTrace(FILE *TraceFILE, char *zTracePrompt) +{ + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if(yyTraceFILE == 0) { + yyTracePrompt = 0; + } else if(yyTracePrompt == 0) { + yyTraceFILE = 0; + } } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", - "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", - "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", - "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", - "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", - "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", - "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", - "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", - "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", - "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", - "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", - "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", - "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", - "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", - "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", - "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", - "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", - "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", - "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", - "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", - "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", - "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", - "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", - "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", - "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", - "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", - "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", - "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", - "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", - "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", - "TOK_WHILE", "error", "statement_list", "case_action", - "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", - "assignable", "attribute_decl", "by_expression", "constant", - "expression", "function_call", "general_ref", "group_ref", - "identifier", "initializer", "interval", "literal", - "local_initializer", "precision_spec", "query_expression", "query_start", - "simple_expression", "unary_expression", "supertype_expression", "until_control", - "while_control", "function_header", "fh_lineno", "rule_header", - "rh_start", "rh_get_line", "procedure_header", "ph_get_line", - "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", - "case_action_list", "case_block", "case_labels", "where_clause_list", - "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", - "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", - "nested_id_list", "statement_rep", "subtype_decl", "where_rule", - "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", - "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", - "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", - "optional_or_unique", "optional_fixed", "optional", "var", - "unique", "qualified_attr", "qualifier", "alias_statement", - "assignment_statement", "case_statement", "compound_statement", "escape_statement", - "if_statement", "proc_call_statement", "repeat_statement", "return_statement", - "skip_statement", "statement", "subsuper_decl", "supertype_decl", - "supertype_factor", "function_id", "procedure_id", "attribute_type", - "defined_type", "parameter_type", "generic_type", "basic_type", - "select_type", "aggregate_type", "aggregation_type", "array_type", - "bag_type", "conformant_aggregation", "list_type", "set_type", - "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", - "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", - "action_body_item_rep", "action_body_item", "declaration", "constant_decl", - "local_decl", "semicolon", "alias_push_scope", "block_list", - "block_member", "include_directive", "rule_decl", "constant_body", - "constant_body_list", "entity_decl", "function_decl", "procedure_decl", - "type_decl", "entity_header", "enumeration_type", "express_file", - "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", - "increment_control", "rename", "rename_list", "parened_rename_list", - "reference_clause", "reference_head", "use_clause", "use_head", - "interface_specification", "interface_specification_list", "right_curl", "local_variable", - "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", - "ph_push_scope", "schema_body", "schema_header", "type_item_body", - "type_item", "ti_start", "td_start", +static const char *const yyTokenName[] = { + "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", + "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", + "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", + "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", + "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", + "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", + "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", + "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", + "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", + "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", + "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", + "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", + "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", + "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", + "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", + "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", + "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", + "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", + "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", + "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", + "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", + "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", + "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", + "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", + "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", + "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", + "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", + "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", + "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", + "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", + "TOK_WHILE", "error", "statement_list", "case_action", + "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", + "assignable", "attribute_decl", "by_expression", "constant", + "expression", "function_call", "general_ref", "group_ref", + "identifier", "initializer", "interval", "literal", + "local_initializer", "precision_spec", "query_expression", "query_start", + "simple_expression", "unary_expression", "supertype_expression", "until_control", + "while_control", "function_header", "fh_lineno", "rule_header", + "rh_start", "rh_get_line", "procedure_header", "ph_get_line", + "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", + "case_action_list", "case_block", "case_labels", "where_clause_list", + "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", + "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", + "nested_id_list", "statement_rep", "subtype_decl", "where_rule", + "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", + "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", + "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", + "optional_or_unique", "optional_fixed", "optional", "var", + "unique", "qualified_attr", "qualifier", "alias_statement", + "assignment_statement", "case_statement", "compound_statement", "escape_statement", + "if_statement", "proc_call_statement", "repeat_statement", "return_statement", + "skip_statement", "statement", "subsuper_decl", "supertype_decl", + "supertype_factor", "function_id", "procedure_id", "attribute_type", + "defined_type", "parameter_type", "generic_type", "basic_type", + "select_type", "aggregate_type", "aggregation_type", "array_type", + "bag_type", "conformant_aggregation", "list_type", "set_type", + "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", + "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", + "action_body_item_rep", "action_body_item", "declaration", "constant_decl", + "local_decl", "semicolon", "alias_push_scope", "block_list", + "block_member", "include_directive", "rule_decl", "constant_body", + "constant_body_list", "entity_decl", "function_decl", "procedure_decl", + "type_decl", "entity_header", "enumeration_type", "express_file", + "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", + "increment_control", "rename", "rename_list", "parened_rename_list", + "reference_clause", "reference_head", "use_clause", "use_head", + "interface_specification", "interface_specification_list", "right_curl", "local_variable", + "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", + "ph_push_scope", "schema_body", "schema_header", "type_item_body", + "type_item", "ti_start", "td_start", }; #endif /* NDEBUG */ @@ -1127,338 +1131,338 @@ static const char *const yyTokenName[] = { /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { - /* 0 */ "action_body ::= action_body_item_rep statement_rep", - /* 1 */ "action_body_item ::= declaration", - /* 2 */ "action_body_item ::= constant_decl", - /* 3 */ "action_body_item ::= local_decl", - /* 4 */ "action_body_item_rep ::=", - /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", - /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", - /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", - /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", - /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", - /* 10 */ "aggregate_init_element ::= expression", - /* 11 */ "aggregate_init_body ::= aggregate_init_element", - /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", - /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", - /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", - /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", - /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", - /* 17 */ "aggregation_type ::= array_type", - /* 18 */ "aggregation_type ::= bag_type", - /* 19 */ "aggregation_type ::= list_type", - /* 20 */ "aggregation_type ::= set_type", - /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", - /* 22 */ "alias_push_scope ::=", - /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", - /* 24 */ "assignable ::= assignable qualifier", - /* 25 */ "assignable ::= identifier", - /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", - /* 27 */ "attribute_type ::= aggregation_type", - /* 28 */ "attribute_type ::= basic_type", - /* 29 */ "attribute_type ::= defined_type", - /* 30 */ "explicit_attr_list ::=", - /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", - /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", - /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", - /* 34 */ "basic_type ::= TOK_BOOLEAN", - /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", - /* 36 */ "basic_type ::= TOK_REAL precision_spec", - /* 37 */ "basic_type ::= TOK_NUMBER", - /* 38 */ "basic_type ::= TOK_LOGICAL", - /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", - /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", - /* 41 */ "block_list ::=", - /* 42 */ "block_list ::= block_list block_member", - /* 43 */ "block_member ::= declaration", - /* 44 */ "block_member ::= include_directive", - /* 45 */ "block_member ::= rule_decl", - /* 46 */ "by_expression ::=", - /* 47 */ "by_expression ::= TOK_BY expression", - /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", - /* 49 */ "case_action ::= case_labels TOK_COLON statement", - /* 50 */ "case_action_list ::=", - /* 51 */ "case_action_list ::= case_action_list case_action", - /* 52 */ "case_block ::= case_action_list case_otherwise", - /* 53 */ "case_labels ::= expression", - /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", - /* 55 */ "case_otherwise ::=", - /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", - /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", - /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", - /* 59 */ "constant ::= TOK_PI", - /* 60 */ "constant ::= TOK_E", - /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", - /* 62 */ "constant_body_list ::=", - /* 63 */ "constant_body_list ::= constant_body constant_body_list", - /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", - /* 65 */ "declaration ::= entity_decl", - /* 66 */ "declaration ::= function_decl", - /* 67 */ "declaration ::= procedure_decl", - /* 68 */ "declaration ::= type_decl", - /* 69 */ "derive_decl ::=", - /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", - /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", - /* 72 */ "derived_attribute_rep ::= derived_attribute", - /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", - /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", - /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", - /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", - /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", - /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", - /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", - /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", - /* 81 */ "attribute_decl_list ::= attribute_decl", - /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", - /* 83 */ "optional ::=", - /* 84 */ "optional ::= TOK_OPTIONAL", - /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", - /* 86 */ "express_file ::= schema_decl_list", - /* 87 */ "schema_decl_list ::= schema_decl", - /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", - /* 89 */ "expression ::= simple_expression", - /* 90 */ "expression ::= expression TOK_AND expression", - /* 91 */ "expression ::= expression TOK_OR expression", - /* 92 */ "expression ::= expression TOK_XOR expression", - /* 93 */ "expression ::= expression TOK_LESS_THAN expression", - /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", - /* 95 */ "expression ::= expression TOK_EQUAL expression", - /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", - /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", - /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", - /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", - /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", - /* 101 */ "expression ::= expression TOK_IN expression", - /* 102 */ "expression ::= expression TOK_LIKE expression", - /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", - /* 104 */ "simple_expression ::= unary_expression", - /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", - /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", - /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", - /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", - /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", - /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", - /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", - /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", - /* 113 */ "expression_list ::= expression", - /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", - /* 115 */ "var ::=", - /* 116 */ "var ::= TOK_VAR", - /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", - /* 118 */ "formal_parameter_list ::=", - /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", - /* 120 */ "formal_parameter_rep ::= formal_parameter", - /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", - /* 122 */ "parameter_type ::= basic_type", - /* 123 */ "parameter_type ::= conformant_aggregation", - /* 124 */ "parameter_type ::= defined_type", - /* 125 */ "parameter_type ::= generic_type", - /* 126 */ "function_call ::= function_id actual_parameters", - /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", - /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", - /* 129 */ "fh_lineno ::= TOK_FUNCTION", - /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", - /* 131 */ "fh_plist ::= formal_parameter_list", - /* 132 */ "function_id ::= TOK_IDENTIFIER", - /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", - /* 134 */ "conformant_aggregation ::= aggregate_type", - /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", - /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", - /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", - /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", - /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", - /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", - /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", - /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", - /* 143 */ "generic_type ::= TOK_GENERIC", - /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", - /* 145 */ "id_list ::= TOK_IDENTIFIER", - /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", - /* 147 */ "identifier ::= TOK_SELF", - /* 148 */ "identifier ::= TOK_QUESTION_MARK", - /* 149 */ "identifier ::= TOK_IDENTIFIER", - /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", - /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", - /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", - /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", - /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", - /* 155 */ "rename ::= TOK_IDENTIFIER", - /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", - /* 157 */ "rename_list ::= rename", - /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", - /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", - /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", - /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", - /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", - /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", - /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", - /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", - /* 166 */ "interface_specification ::= use_clause", - /* 167 */ "interface_specification ::= reference_clause", - /* 168 */ "interface_specification_list ::=", - /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", - /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", - /* 171 */ "set_or_bag_of_entity ::= defined_type", - /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", - /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", - /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", - /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", - /* 176 */ "inverse_attr_list ::= inverse_attr", - /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", - /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", - /* 179 */ "inverse_clause ::=", - /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", - /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", - /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", - /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", - /* 184 */ "literal ::= TOK_INTEGER_LITERAL", - /* 185 */ "literal ::= TOK_REAL_LITERAL", - /* 186 */ "literal ::= TOK_STRING_LITERAL", - /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", - /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", - /* 189 */ "literal ::= TOK_BINARY_LITERAL", - /* 190 */ "literal ::= constant", - /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", - /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", - /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", - /* 194 */ "local_body ::=", - /* 195 */ "local_body ::= local_variable local_body", - /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", - /* 197 */ "local_decl_rules_on ::=", - /* 198 */ "local_decl_rules_off ::=", - /* 199 */ "defined_type ::= TOK_IDENTIFIER", - /* 200 */ "defined_type_list ::= defined_type", - /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", - /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", - /* 203 */ "oneof_op ::= TOK_ONEOF", - /* 204 */ "optional_or_unique ::=", - /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", - /* 206 */ "optional_or_unique ::= TOK_UNIQUE", - /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", - /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", - /* 209 */ "optional_fixed ::=", - /* 210 */ "optional_fixed ::= TOK_FIXED", - /* 211 */ "precision_spec ::=", - /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", - /* 214 */ "proc_call_statement ::= procedure_id semicolon", - /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", - /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", - /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", - /* 218 */ "ph_get_line ::=", - /* 219 */ "procedure_id ::= TOK_IDENTIFIER", - /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", - /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", - /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", - /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", - /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", - /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", - /* 228 */ "rel_op ::= TOK_LESS_THAN", - /* 229 */ "rel_op ::= TOK_GREATER_THAN", - /* 230 */ "rel_op ::= TOK_EQUAL", - /* 231 */ "rel_op ::= TOK_LESS_EQUAL", - /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", - /* 233 */ "rel_op ::= TOK_NOT_EQUAL", - /* 234 */ "rel_op ::= TOK_INST_EQUAL", - /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", - /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 238 */ "return_statement ::= TOK_RETURN semicolon", - /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", - /* 240 */ "right_curl ::= TOK_RIGHT_CURL", - /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", - /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", - /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", - /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", - /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", - /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", - /* 247 */ "rh_get_line ::=", - /* 248 */ "schema_body ::= interface_specification_list block_list", - /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", - /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", - /* 251 */ "schema_decl ::= include_directive", - /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", - /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 254 */ "semicolon ::= TOK_SEMICOLON", - /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", - /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", - /* 257 */ "skip_statement ::= TOK_SKIP semicolon", - /* 258 */ "statement ::= alias_statement", - /* 259 */ "statement ::= assignment_statement", - /* 260 */ "statement ::= case_statement", - /* 261 */ "statement ::= compound_statement", - /* 262 */ "statement ::= escape_statement", - /* 263 */ "statement ::= if_statement", - /* 264 */ "statement ::= proc_call_statement", - /* 265 */ "statement ::= repeat_statement", - /* 266 */ "statement ::= return_statement", - /* 267 */ "statement ::= skip_statement", - /* 268 */ "statement_rep ::=", - /* 269 */ "statement_rep ::= semicolon statement_rep", - /* 270 */ "statement_rep ::= statement statement_rep", - /* 271 */ "subsuper_decl ::=", - /* 272 */ "subsuper_decl ::= supertype_decl", - /* 273 */ "subsuper_decl ::= subtype_decl", - /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", - /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", - /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 279 */ "supertype_expression ::= supertype_factor", - /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", - /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", - /* 282 */ "supertype_expression_list ::= supertype_expression", - /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", - /* 284 */ "supertype_factor ::= identifier", - /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", - /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 287 */ "type ::= aggregation_type", - /* 288 */ "type ::= basic_type", - /* 289 */ "type ::= defined_type", - /* 290 */ "type ::= select_type", - /* 291 */ "type_item_body ::= enumeration_type", - /* 292 */ "type_item_body ::= type", - /* 293 */ "type_item ::= ti_start type_item_body semicolon", - /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", - /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", - /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", - /* 297 */ "general_ref ::= assignable group_ref", - /* 298 */ "general_ref ::= assignable", - /* 299 */ "unary_expression ::= aggregate_initializer", - /* 300 */ "unary_expression ::= unary_expression qualifier", - /* 301 */ "unary_expression ::= literal", - /* 302 */ "unary_expression ::= function_call", - /* 303 */ "unary_expression ::= identifier", - /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 305 */ "unary_expression ::= interval", - /* 306 */ "unary_expression ::= query_expression", - /* 307 */ "unary_expression ::= TOK_NOT unary_expression", - /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", - /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", - /* 310 */ "unique ::=", - /* 311 */ "unique ::= TOK_UNIQUE", - /* 312 */ "qualified_attr ::= attribute_decl", - /* 313 */ "qualified_attr_list ::= qualified_attr", - /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", - /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", - /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", - /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", - /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", - /* 319 */ "unique_clause ::=", - /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", - /* 321 */ "until_control ::=", - /* 322 */ "until_control ::= TOK_UNTIL expression", - /* 323 */ "where_clause ::= expression semicolon", - /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", - /* 325 */ "where_clause_list ::= where_clause", - /* 326 */ "where_clause_list ::= where_clause_list where_clause", - /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", - /* 328 */ "where_rule_OPT ::=", - /* 329 */ "where_rule_OPT ::= where_rule", - /* 330 */ "while_control ::=", - /* 331 */ "while_control ::= TOK_WHILE expression", + /* 0 */ "action_body ::= action_body_item_rep statement_rep", + /* 1 */ "action_body_item ::= declaration", + /* 2 */ "action_body_item ::= constant_decl", + /* 3 */ "action_body_item ::= local_decl", + /* 4 */ "action_body_item_rep ::=", + /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", + /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", + /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", + /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", + /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", + /* 10 */ "aggregate_init_element ::= expression", + /* 11 */ "aggregate_init_body ::= aggregate_init_element", + /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", + /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", + /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", + /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", + /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", + /* 17 */ "aggregation_type ::= array_type", + /* 18 */ "aggregation_type ::= bag_type", + /* 19 */ "aggregation_type ::= list_type", + /* 20 */ "aggregation_type ::= set_type", + /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", + /* 22 */ "alias_push_scope ::=", + /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", + /* 24 */ "assignable ::= assignable qualifier", + /* 25 */ "assignable ::= identifier", + /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", + /* 27 */ "attribute_type ::= aggregation_type", + /* 28 */ "attribute_type ::= basic_type", + /* 29 */ "attribute_type ::= defined_type", + /* 30 */ "explicit_attr_list ::=", + /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", + /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", + /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", + /* 34 */ "basic_type ::= TOK_BOOLEAN", + /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", + /* 36 */ "basic_type ::= TOK_REAL precision_spec", + /* 37 */ "basic_type ::= TOK_NUMBER", + /* 38 */ "basic_type ::= TOK_LOGICAL", + /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", + /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", + /* 41 */ "block_list ::=", + /* 42 */ "block_list ::= block_list block_member", + /* 43 */ "block_member ::= declaration", + /* 44 */ "block_member ::= include_directive", + /* 45 */ "block_member ::= rule_decl", + /* 46 */ "by_expression ::=", + /* 47 */ "by_expression ::= TOK_BY expression", + /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", + /* 49 */ "case_action ::= case_labels TOK_COLON statement", + /* 50 */ "case_action_list ::=", + /* 51 */ "case_action_list ::= case_action_list case_action", + /* 52 */ "case_block ::= case_action_list case_otherwise", + /* 53 */ "case_labels ::= expression", + /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", + /* 55 */ "case_otherwise ::=", + /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", + /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", + /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", + /* 59 */ "constant ::= TOK_PI", + /* 60 */ "constant ::= TOK_E", + /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", + /* 62 */ "constant_body_list ::=", + /* 63 */ "constant_body_list ::= constant_body constant_body_list", + /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", + /* 65 */ "declaration ::= entity_decl", + /* 66 */ "declaration ::= function_decl", + /* 67 */ "declaration ::= procedure_decl", + /* 68 */ "declaration ::= type_decl", + /* 69 */ "derive_decl ::=", + /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", + /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", + /* 72 */ "derived_attribute_rep ::= derived_attribute", + /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", + /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", + /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", + /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", + /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", + /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", + /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", + /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", + /* 81 */ "attribute_decl_list ::= attribute_decl", + /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", + /* 83 */ "optional ::=", + /* 84 */ "optional ::= TOK_OPTIONAL", + /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", + /* 86 */ "express_file ::= schema_decl_list", + /* 87 */ "schema_decl_list ::= schema_decl", + /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", + /* 89 */ "expression ::= simple_expression", + /* 90 */ "expression ::= expression TOK_AND expression", + /* 91 */ "expression ::= expression TOK_OR expression", + /* 92 */ "expression ::= expression TOK_XOR expression", + /* 93 */ "expression ::= expression TOK_LESS_THAN expression", + /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", + /* 95 */ "expression ::= expression TOK_EQUAL expression", + /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", + /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", + /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", + /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", + /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", + /* 101 */ "expression ::= expression TOK_IN expression", + /* 102 */ "expression ::= expression TOK_LIKE expression", + /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", + /* 104 */ "simple_expression ::= unary_expression", + /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", + /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", + /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", + /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", + /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", + /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", + /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", + /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", + /* 113 */ "expression_list ::= expression", + /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", + /* 115 */ "var ::=", + /* 116 */ "var ::= TOK_VAR", + /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", + /* 118 */ "formal_parameter_list ::=", + /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", + /* 120 */ "formal_parameter_rep ::= formal_parameter", + /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", + /* 122 */ "parameter_type ::= basic_type", + /* 123 */ "parameter_type ::= conformant_aggregation", + /* 124 */ "parameter_type ::= defined_type", + /* 125 */ "parameter_type ::= generic_type", + /* 126 */ "function_call ::= function_id actual_parameters", + /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", + /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", + /* 129 */ "fh_lineno ::= TOK_FUNCTION", + /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", + /* 131 */ "fh_plist ::= formal_parameter_list", + /* 132 */ "function_id ::= TOK_IDENTIFIER", + /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", + /* 134 */ "conformant_aggregation ::= aggregate_type", + /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", + /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", + /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", + /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", + /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", + /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", + /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", + /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", + /* 143 */ "generic_type ::= TOK_GENERIC", + /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", + /* 145 */ "id_list ::= TOK_IDENTIFIER", + /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", + /* 147 */ "identifier ::= TOK_SELF", + /* 148 */ "identifier ::= TOK_QUESTION_MARK", + /* 149 */ "identifier ::= TOK_IDENTIFIER", + /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", + /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", + /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", + /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", + /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", + /* 155 */ "rename ::= TOK_IDENTIFIER", + /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", + /* 157 */ "rename_list ::= rename", + /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", + /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", + /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", + /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", + /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", + /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", + /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", + /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", + /* 166 */ "interface_specification ::= use_clause", + /* 167 */ "interface_specification ::= reference_clause", + /* 168 */ "interface_specification_list ::=", + /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", + /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", + /* 171 */ "set_or_bag_of_entity ::= defined_type", + /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", + /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", + /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", + /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", + /* 176 */ "inverse_attr_list ::= inverse_attr", + /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", + /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", + /* 179 */ "inverse_clause ::=", + /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", + /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", + /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", + /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", + /* 184 */ "literal ::= TOK_INTEGER_LITERAL", + /* 185 */ "literal ::= TOK_REAL_LITERAL", + /* 186 */ "literal ::= TOK_STRING_LITERAL", + /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", + /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", + /* 189 */ "literal ::= TOK_BINARY_LITERAL", + /* 190 */ "literal ::= constant", + /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", + /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", + /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", + /* 194 */ "local_body ::=", + /* 195 */ "local_body ::= local_variable local_body", + /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", + /* 197 */ "local_decl_rules_on ::=", + /* 198 */ "local_decl_rules_off ::=", + /* 199 */ "defined_type ::= TOK_IDENTIFIER", + /* 200 */ "defined_type_list ::= defined_type", + /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", + /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", + /* 203 */ "oneof_op ::= TOK_ONEOF", + /* 204 */ "optional_or_unique ::=", + /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", + /* 206 */ "optional_or_unique ::= TOK_UNIQUE", + /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", + /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", + /* 209 */ "optional_fixed ::=", + /* 210 */ "optional_fixed ::= TOK_FIXED", + /* 211 */ "precision_spec ::=", + /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", + /* 214 */ "proc_call_statement ::= procedure_id semicolon", + /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", + /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", + /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", + /* 218 */ "ph_get_line ::=", + /* 219 */ "procedure_id ::= TOK_IDENTIFIER", + /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", + /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", + /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", + /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", + /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", + /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", + /* 228 */ "rel_op ::= TOK_LESS_THAN", + /* 229 */ "rel_op ::= TOK_GREATER_THAN", + /* 230 */ "rel_op ::= TOK_EQUAL", + /* 231 */ "rel_op ::= TOK_LESS_EQUAL", + /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", + /* 233 */ "rel_op ::= TOK_NOT_EQUAL", + /* 234 */ "rel_op ::= TOK_INST_EQUAL", + /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", + /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 238 */ "return_statement ::= TOK_RETURN semicolon", + /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", + /* 240 */ "right_curl ::= TOK_RIGHT_CURL", + /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", + /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", + /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", + /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", + /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", + /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", + /* 247 */ "rh_get_line ::=", + /* 248 */ "schema_body ::= interface_specification_list block_list", + /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", + /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", + /* 251 */ "schema_decl ::= include_directive", + /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", + /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 254 */ "semicolon ::= TOK_SEMICOLON", + /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", + /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", + /* 257 */ "skip_statement ::= TOK_SKIP semicolon", + /* 258 */ "statement ::= alias_statement", + /* 259 */ "statement ::= assignment_statement", + /* 260 */ "statement ::= case_statement", + /* 261 */ "statement ::= compound_statement", + /* 262 */ "statement ::= escape_statement", + /* 263 */ "statement ::= if_statement", + /* 264 */ "statement ::= proc_call_statement", + /* 265 */ "statement ::= repeat_statement", + /* 266 */ "statement ::= return_statement", + /* 267 */ "statement ::= skip_statement", + /* 268 */ "statement_rep ::=", + /* 269 */ "statement_rep ::= semicolon statement_rep", + /* 270 */ "statement_rep ::= statement statement_rep", + /* 271 */ "subsuper_decl ::=", + /* 272 */ "subsuper_decl ::= supertype_decl", + /* 273 */ "subsuper_decl ::= subtype_decl", + /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", + /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", + /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 279 */ "supertype_expression ::= supertype_factor", + /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", + /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", + /* 282 */ "supertype_expression_list ::= supertype_expression", + /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", + /* 284 */ "supertype_factor ::= identifier", + /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", + /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 287 */ "type ::= aggregation_type", + /* 288 */ "type ::= basic_type", + /* 289 */ "type ::= defined_type", + /* 290 */ "type ::= select_type", + /* 291 */ "type_item_body ::= enumeration_type", + /* 292 */ "type_item_body ::= type", + /* 293 */ "type_item ::= ti_start type_item_body semicolon", + /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", + /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", + /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", + /* 297 */ "general_ref ::= assignable group_ref", + /* 298 */ "general_ref ::= assignable", + /* 299 */ "unary_expression ::= aggregate_initializer", + /* 300 */ "unary_expression ::= unary_expression qualifier", + /* 301 */ "unary_expression ::= literal", + /* 302 */ "unary_expression ::= function_call", + /* 303 */ "unary_expression ::= identifier", + /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 305 */ "unary_expression ::= interval", + /* 306 */ "unary_expression ::= query_expression", + /* 307 */ "unary_expression ::= TOK_NOT unary_expression", + /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", + /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", + /* 310 */ "unique ::=", + /* 311 */ "unique ::= TOK_UNIQUE", + /* 312 */ "qualified_attr ::= attribute_decl", + /* 313 */ "qualified_attr_list ::= qualified_attr", + /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", + /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", + /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", + /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", + /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", + /* 319 */ "unique_clause ::=", + /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", + /* 321 */ "until_control ::=", + /* 322 */ "until_control ::= TOK_UNTIL expression", + /* 323 */ "where_clause ::= expression semicolon", + /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", + /* 325 */ "where_clause_list ::= where_clause", + /* 326 */ "where_clause_list ::= where_clause_list where_clause", + /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", + /* 328 */ "where_rule_OPT ::=", + /* 329 */ "where_rule_OPT ::= where_rule", + /* 330 */ "while_control ::=", + /* 331 */ "while_control ::= TOK_WHILE expression", }; #endif /* NDEBUG */ @@ -1467,26 +1471,27 @@ static const char *const yyRuleName[] = { /* ** Try to increase the size of the parser stack. */ -static void yyGrowStack(yyParser *p){ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz*2 + 256; - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); - if( pNew ){ - p->yystack = pNew; - p->yystksz = newSize; +static void yyGrowStack(yyParser *p) +{ + int newSize; + yyStackEntry *pNew; + + newSize = p->yystksz * 2 + 256; + pNew = realloc(p->yystack, newSize * sizeof(pNew[0])); + if(pNew) { + p->yystack = pNew; + p->yystksz = newSize; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sStack grows to %d entries!\n", + yyTracePrompt, p->yystksz); + } #endif - } + } } #endif -/* +/* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. @@ -1498,21 +1503,22 @@ static void yyGrowStack(yyParser *p){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); - if( pParser ){ - pParser->yyidx = -1; +void *ParseAlloc(void *(*mallocProc)(size_t)) +{ + yyParser *pParser; + pParser = (yyParser *)(*mallocProc)((size_t)sizeof(yyParser)); + if(pParser) { + pParser->yyidx = -1; #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; + pParser->yyidxMax = 0; #endif #if YYSTACKDEPTH<=0 - pParser->yystack = NULL; - pParser->yystksz = 0; - yyGrowStack(pParser); + pParser->yystack = NULL; + pParser->yystksz = 0; + yyGrowStack(pParser); #endif - } - return pParser; + } + return pParser; } /* The following function deletes the value associated with a @@ -1521,35 +1527,36 @@ void *ParseAlloc(void *(*mallocProc)(size_t)){ ** the value. */ static void yy_destructor( - yyParser *yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE *yypminor /* The object to be destroyed */ -){ - ParseARG_FETCH; - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 122: /* statement_list */ -{ + yyParser *yypParser, /* The parser */ + YYCODETYPE yymajor, /* Type code for object to destroy */ + YYMINORTYPE *yypminor /* The object to be destroyed */ +) +{ + ParseARG_FETCH; + switch(yymajor) { + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 122: { /* statement_list */ #line 124 "expparse.y" - if (parseData.scanner == NULL) { - (yypminor->yy0).string = (char*)NULL; - } + if(parseData.scanner == NULL) { + (yypminor->yy0).string = (char *)NULL; + } #line 1549 "expparse.c" -} - break; - default: break; /* If no destructor action specified: do nothing */ - } + } + break; + default: + break; /* If no destructor action specified: do nothing */ + } } /* @@ -1560,28 +1567,31 @@ static void yy_destructor( ** ** Return the major token number for the symbol popped. */ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos; +static int yy_pop_parser_stack(yyParser *pParser) +{ + YYCODETYPE yymajor; + yyStackEntry *yytos; - if( pParser->yyidx<0 ) return 0; + if(pParser->yyidx < 0) { + return 0; + } - yytos = &pParser->yystack[pParser->yyidx]; + yytos = &pParser->yystack[pParser->yyidx]; #ifndef NDEBUG - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } + if(yyTraceFILE && pParser->yyidx >= 0) { + fprintf(yyTraceFILE, "%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos->major]); + } #endif - yymajor = yytos->major; - yy_destructor(pParser, yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; + yymajor = yytos->major; + yy_destructor(pParser, yymajor, &yytos->minor); + pParser->yyidx--; + return yymajor; } -/* +/* ** Deallocate and destroy a parser. Destructors are all called for ** all stack elements before shutting the parser down. ** @@ -1594,25 +1604,31 @@ static int yy_pop_parser_stack(yyParser *pParser){ **
*/ void ParseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); + void *p, /* The parser to be deleted */ + void (*freeProc)(void *) /* Function used to reclaim memory */ +) +{ + yyParser *pParser = (yyParser *)p; + if(pParser == 0) { + return; + } + while(pParser->yyidx >= 0) { + yy_pop_parser_stack(pParser); + } #if YYSTACKDEPTH<=0 - free(pParser->yystack); + free(pParser->yystack); #endif - (*freeProc)((void*)pParser); + (*freeProc)((void *)pParser); } /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH -int ParseStackPeak(void *p){ - yyParser *pParser = (yyParser*)p; - return pParser->yyidxMax; +int ParseStackPeak(void *p) +{ + yyParser *pParser = (yyParser *)p; + return pParser->yyidxMax; } #endif @@ -1625,60 +1641,61 @@ int ParseStackPeak(void *p){ ** return YY_NO_ACTION. */ static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if( stateno>YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ +) +{ + int i; + int stateno = pParser->yystack[pParser->yyidx].stateno; + + if(stateno > YY_SHIFT_COUNT + || (i = yy_shift_ofst[stateno]) == YY_SHIFT_USE_DFLT) { + return yy_default[stateno]; + } + assert(iLookAhead != YYNOCODE); + i += iLookAhead; + if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { + if(iLookAhead > 0) { #ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + } #endif - return yy_find_shift_action(pParser, iFallback); - } + return yy_find_shift_action(pParser, iFallback); + } #endif #ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( + { + int j = i - iLookAhead + YYWILDCARD; + if( #if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && + j >= 0 && #endif #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } #endif /* NDEBUG */ - return yy_action[j]; - } - } + return yy_action[j]; + } + } #endif /* YYWILDCARD */ + } + return yy_default[stateno]; + } else { + return yy_action[i]; } - return yy_default[stateno]; - }else{ - return yy_action[i]; - } } /* @@ -1690,97 +1707,103 @@ static int yy_find_shift_action( ** return YY_NO_ACTION. */ static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ +) +{ + int i; #ifdef YYERRORSYMBOL - if( stateno>YY_REDUCE_COUNT ){ - return yy_default[stateno]; - } + if(stateno > YY_REDUCE_COUNT) { + return yy_default[stateno]; + } #else - assert( stateno<=YY_REDUCE_COUNT ); + assert(stateno <= YY_REDUCE_COUNT); #endif - i = yy_reduce_ofst[stateno]; - assert( i!=YY_REDUCE_USE_DFLT ); - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; + i = yy_reduce_ofst[stateno]; + assert(i != YY_REDUCE_USE_DFLT); + assert(iLookAhead != YYNOCODE); + i += iLookAhead; #ifdef YYERRORSYMBOL - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - } + if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { + return yy_default[stateno]; + } #else - assert( i>=0 && i= 0 && i < YY_ACTTAB_COUNT); + assert(yy_lookahead[i] == iLookAhead); #endif - return yy_action[i]; + return yy_action[i]; } /* ** The following routine is called if the stack overflows. */ -static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ - ParseARG_FETCH; - yypParser->yyidx--; +static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor) +{ + ParseARG_FETCH; + yypParser->yyidx--; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); + } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ + while(yypParser->yyidx >= 0) { + yy_pop_parser_stack(yypParser); + } + /* Here code is inserted which will execute if the parser + ** stack every overflows */ #line 2440 "expparse.y" fprintf(stderr, "Express parser experienced stack overflow.\n"); fprintf(stderr, "Last token had value %x\n", yypMinor->yy0.val); #line 1738 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ } /* ** Perform a shift action. */ static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; + yyParser *yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ +) +{ + yyStackEntry *yytos; + yypParser->yyidx++; #ifdef YYTRACKMAXSTACKDEPTH - if( yypParser->yyidx>yypParser->yyidxMax ){ - yypParser->yyidxMax = yypParser->yyidx; - } + if(yypParser->yyidx > yypParser->yyidxMax) { + yypParser->yyidxMax = yypParser->yyidx; + } #endif -#if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH ){ - yyStackOverflow(yypParser, yypMinor); - return; - } +#if YYSTACKDEPTH>0 + if(yypParser->yyidx >= YYSTACKDEPTH) { + yyStackOverflow(yypParser, yypMinor); + return; + } #else - if( yypParser->yyidx>=yypParser->yystksz ){ - yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz ){ - yyStackOverflow(yypParser, yypMinor); - return; + if(yypParser->yyidx >= yypParser->yystksz) { + yyGrowStack(yypParser); + if(yypParser->yyidx >= yypParser->yystksz) { + yyStackOverflow(yypParser, yypMinor); + return; + } } - } #endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; - yytos->minor = *yypMinor; + yytos = &yypParser->yystack[yypParser->yyidx]; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; + yytos->minor = *yypMinor; #ifndef NDEBUG - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } + if(yyTraceFILE && yypParser->yyidx > 0) { + int i; + fprintf(yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState); + fprintf(yyTraceFILE, "%sStack:", yyTracePrompt); + for(i = 1; i <= yypParser->yyidx; i++) { + fprintf(yyTraceFILE, " %s", yyTokenName[yypParser->yystack[i].major]); + } + fprintf(yyTraceFILE, "\n"); + } #endif } @@ -1788,2639 +1811,2744 @@ static void yy_shift( ** is used during the reduce. */ static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } yyRuleInfo[] = { - { 156, 2 }, - { 233, 1 }, - { 233, 1 }, - { 233, 1 }, - { 232, 0 }, - { 232, 2 }, - { 157, 3 }, - { 157, 2 }, - { 127, 2 }, - { 127, 3 }, - { 126, 1 }, - { 158, 1 }, - { 158, 3 }, - { 158, 3 }, - { 158, 5 }, - { 217, 3 }, - { 217, 5 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 195, 9 }, - { 238, 0 }, - { 219, 5 }, - { 128, 2 }, - { 128, 1 }, - { 196, 4 }, - { 211, 1 }, - { 211, 1 }, - { 211, 1 }, - { 159, 0 }, - { 159, 2 }, - { 220, 4 }, - { 220, 3 }, - { 215, 1 }, - { 215, 2 }, - { 215, 2 }, - { 215, 1 }, - { 215, 1 }, - { 215, 3 }, - { 215, 3 }, - { 239, 0 }, - { 239, 2 }, - { 240, 1 }, - { 240, 1 }, - { 240, 1 }, - { 130, 0 }, - { 130, 2 }, - { 226, 5 }, - { 123, 3 }, - { 160, 0 }, - { 160, 2 }, - { 161, 2 }, - { 162, 1 }, - { 162, 3 }, - { 124, 0 }, - { 124, 3 }, - { 197, 6 }, - { 198, 4 }, - { 131, 1 }, - { 131, 1 }, - { 243, 6 }, - { 244, 0 }, - { 244, 2 }, - { 235, 4 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 164, 0 }, - { 164, 2 }, - { 229, 5 }, - { 183, 1 }, - { 183, 2 }, - { 125, 5 }, - { 245, 6 }, - { 249, 2 }, - { 250, 3 }, - { 199, 2 }, - { 129, 1 }, - { 129, 5 }, - { 182, 1 }, - { 182, 3 }, - { 190, 0 }, - { 190, 1 }, - { 165, 5 }, - { 251, 1 }, - { 252, 1 }, - { 252, 2 }, - { 132, 1 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 144, 1 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 166, 1 }, - { 166, 3 }, - { 191, 0 }, - { 191, 1 }, - { 167, 4 }, - { 168, 0 }, - { 168, 3 }, - { 169, 1 }, - { 169, 3 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 133, 2 }, - { 246, 4 }, - { 149, 6 }, - { 150, 1 }, - { 254, 1 }, - { 255, 1 }, - { 209, 1 }, - { 209, 1 }, - { 221, 1 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 214, 1 }, - { 214, 3 }, - { 170, 1 }, - { 170, 3 }, - { 136, 1 }, - { 136, 1 }, - { 136, 1 }, - { 200, 6 }, - { 200, 8 }, - { 241, 3 }, - { 256, 6 }, - { 137, 2 }, - { 257, 1 }, - { 257, 3 }, - { 258, 1 }, - { 258, 3 }, - { 259, 3 }, - { 260, 4 }, - { 260, 3 }, - { 261, 3 }, - { 262, 4 }, - { 262, 3 }, - { 263, 3 }, - { 264, 1 }, - { 264, 1 }, - { 265, 0 }, - { 265, 2 }, - { 138, 7 }, - { 224, 1 }, - { 224, 3 }, - { 224, 4 }, - { 224, 4 }, - { 224, 3 }, - { 180, 1 }, - { 180, 2 }, - { 228, 6 }, - { 181, 0 }, - { 181, 2 }, - { 227, 5 }, - { 222, 5 }, - { 222, 4 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 140, 2 }, - { 267, 4 }, - { 267, 5 }, - { 268, 0 }, - { 268, 2 }, - { 236, 6 }, - { 269, 0 }, - { 270, 0 }, - { 212, 1 }, - { 171, 1 }, - { 171, 3 }, - { 172, 3 }, - { 271, 1 }, - { 188, 0 }, - { 188, 1 }, - { 188, 1 }, - { 188, 2 }, - { 188, 2 }, - { 189, 0 }, - { 189, 1 }, - { 141, 0 }, - { 141, 3 }, - { 201, 3 }, - { 201, 2 }, - { 247, 4 }, - { 154, 5 }, - { 272, 1 }, - { 155, 0 }, - { 210, 1 }, - { 210, 1 }, - { 135, 2 }, - { 194, 2 }, - { 194, 2 }, - { 194, 3 }, - { 194, 5 }, - { 142, 3 }, - { 143, 6 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 202, 8 }, - { 202, 7 }, - { 203, 2 }, - { 203, 5 }, - { 266, 1 }, - { 242, 5 }, - { 230, 1 }, - { 185, 1 }, - { 185, 3 }, - { 151, 4 }, - { 152, 5 }, - { 153, 0 }, - { 273, 2 }, - { 273, 3 }, - { 253, 4 }, - { 253, 1 }, - { 274, 3 }, - { 216, 4 }, - { 237, 1 }, - { 223, 4 }, - { 223, 3 }, - { 204, 2 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 173, 0 }, - { 173, 2 }, - { 173, 2 }, - { 206, 0 }, - { 206, 1 }, - { 206, 1 }, - { 206, 2 }, - { 174, 5 }, - { 207, 2 }, - { 207, 5 }, - { 207, 6 }, - { 146, 1 }, - { 146, 3 }, - { 146, 3 }, - { 177, 1 }, - { 177, 3 }, - { 208, 1 }, - { 208, 4 }, - { 208, 3 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 275, 1 }, - { 275, 1 }, - { 276, 3 }, - { 277, 2 }, - { 248, 3 }, - { 278, 3 }, - { 134, 2 }, - { 134, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 3 }, - { 145, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 2 }, - { 145, 2 }, - { 192, 0 }, - { 192, 1 }, - { 193, 1 }, - { 186, 1 }, - { 186, 3 }, - { 179, 2 }, - { 179, 4 }, - { 178, 1 }, - { 178, 2 }, - { 184, 0 }, - { 184, 2 }, - { 147, 0 }, - { 147, 2 }, - { 231, 2 }, - { 231, 4 }, - { 163, 1 }, - { 163, 2 }, - { 175, 2 }, - { 176, 0 }, - { 176, 1 }, - { 148, 0 }, - { 148, 2 }, + { 156, 2 }, + { 233, 1 }, + { 233, 1 }, + { 233, 1 }, + { 232, 0 }, + { 232, 2 }, + { 157, 3 }, + { 157, 2 }, + { 127, 2 }, + { 127, 3 }, + { 126, 1 }, + { 158, 1 }, + { 158, 3 }, + { 158, 3 }, + { 158, 5 }, + { 217, 3 }, + { 217, 5 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 195, 9 }, + { 238, 0 }, + { 219, 5 }, + { 128, 2 }, + { 128, 1 }, + { 196, 4 }, + { 211, 1 }, + { 211, 1 }, + { 211, 1 }, + { 159, 0 }, + { 159, 2 }, + { 220, 4 }, + { 220, 3 }, + { 215, 1 }, + { 215, 2 }, + { 215, 2 }, + { 215, 1 }, + { 215, 1 }, + { 215, 3 }, + { 215, 3 }, + { 239, 0 }, + { 239, 2 }, + { 240, 1 }, + { 240, 1 }, + { 240, 1 }, + { 130, 0 }, + { 130, 2 }, + { 226, 5 }, + { 123, 3 }, + { 160, 0 }, + { 160, 2 }, + { 161, 2 }, + { 162, 1 }, + { 162, 3 }, + { 124, 0 }, + { 124, 3 }, + { 197, 6 }, + { 198, 4 }, + { 131, 1 }, + { 131, 1 }, + { 243, 6 }, + { 244, 0 }, + { 244, 2 }, + { 235, 4 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 164, 0 }, + { 164, 2 }, + { 229, 5 }, + { 183, 1 }, + { 183, 2 }, + { 125, 5 }, + { 245, 6 }, + { 249, 2 }, + { 250, 3 }, + { 199, 2 }, + { 129, 1 }, + { 129, 5 }, + { 182, 1 }, + { 182, 3 }, + { 190, 0 }, + { 190, 1 }, + { 165, 5 }, + { 251, 1 }, + { 252, 1 }, + { 252, 2 }, + { 132, 1 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 144, 1 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 166, 1 }, + { 166, 3 }, + { 191, 0 }, + { 191, 1 }, + { 167, 4 }, + { 168, 0 }, + { 168, 3 }, + { 169, 1 }, + { 169, 3 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 133, 2 }, + { 246, 4 }, + { 149, 6 }, + { 150, 1 }, + { 254, 1 }, + { 255, 1 }, + { 209, 1 }, + { 209, 1 }, + { 221, 1 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 214, 1 }, + { 214, 3 }, + { 170, 1 }, + { 170, 3 }, + { 136, 1 }, + { 136, 1 }, + { 136, 1 }, + { 200, 6 }, + { 200, 8 }, + { 241, 3 }, + { 256, 6 }, + { 137, 2 }, + { 257, 1 }, + { 257, 3 }, + { 258, 1 }, + { 258, 3 }, + { 259, 3 }, + { 260, 4 }, + { 260, 3 }, + { 261, 3 }, + { 262, 4 }, + { 262, 3 }, + { 263, 3 }, + { 264, 1 }, + { 264, 1 }, + { 265, 0 }, + { 265, 2 }, + { 138, 7 }, + { 224, 1 }, + { 224, 3 }, + { 224, 4 }, + { 224, 4 }, + { 224, 3 }, + { 180, 1 }, + { 180, 2 }, + { 228, 6 }, + { 181, 0 }, + { 181, 2 }, + { 227, 5 }, + { 222, 5 }, + { 222, 4 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 140, 2 }, + { 267, 4 }, + { 267, 5 }, + { 268, 0 }, + { 268, 2 }, + { 236, 6 }, + { 269, 0 }, + { 270, 0 }, + { 212, 1 }, + { 171, 1 }, + { 171, 3 }, + { 172, 3 }, + { 271, 1 }, + { 188, 0 }, + { 188, 1 }, + { 188, 1 }, + { 188, 2 }, + { 188, 2 }, + { 189, 0 }, + { 189, 1 }, + { 141, 0 }, + { 141, 3 }, + { 201, 3 }, + { 201, 2 }, + { 247, 4 }, + { 154, 5 }, + { 272, 1 }, + { 155, 0 }, + { 210, 1 }, + { 210, 1 }, + { 135, 2 }, + { 194, 2 }, + { 194, 2 }, + { 194, 3 }, + { 194, 5 }, + { 142, 3 }, + { 143, 6 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 202, 8 }, + { 202, 7 }, + { 203, 2 }, + { 203, 5 }, + { 266, 1 }, + { 242, 5 }, + { 230, 1 }, + { 185, 1 }, + { 185, 3 }, + { 151, 4 }, + { 152, 5 }, + { 153, 0 }, + { 273, 2 }, + { 273, 3 }, + { 253, 4 }, + { 253, 1 }, + { 274, 3 }, + { 216, 4 }, + { 237, 1 }, + { 223, 4 }, + { 223, 3 }, + { 204, 2 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 173, 0 }, + { 173, 2 }, + { 173, 2 }, + { 206, 0 }, + { 206, 1 }, + { 206, 1 }, + { 206, 2 }, + { 174, 5 }, + { 207, 2 }, + { 207, 5 }, + { 207, 6 }, + { 146, 1 }, + { 146, 3 }, + { 146, 3 }, + { 177, 1 }, + { 177, 3 }, + { 208, 1 }, + { 208, 4 }, + { 208, 3 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 275, 1 }, + { 275, 1 }, + { 276, 3 }, + { 277, 2 }, + { 248, 3 }, + { 278, 3 }, + { 134, 2 }, + { 134, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 1 }, + { 145, 1 }, + { 145, 1 }, + { 145, 3 }, + { 145, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 2 }, + { 145, 2 }, + { 192, 0 }, + { 192, 1 }, + { 193, 1 }, + { 186, 1 }, + { 186, 3 }, + { 179, 2 }, + { 179, 4 }, + { 178, 1 }, + { 178, 2 }, + { 184, 0 }, + { 184, 2 }, + { 147, 0 }, + { 147, 2 }, + { 231, 2 }, + { 231, 4 }, + { 163, 1 }, + { 163, 2 }, + { 175, 2 }, + { 176, 0 }, + { 176, 1 }, + { 148, 0 }, + { 148, 2 }, }; -static void yy_accept(yyParser*); /* Forward Declaration */ +static void yy_accept(yyParser *); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - ParseARG_FETCH; - - yymsp = &yypParser->yystack[yypParser->yyidx]; - - if( yyruleno>=0 ) { + yyParser *yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ +) +{ + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yyStackEntry *yymsp; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + ParseARG_FETCH; + + yymsp = &yypParser->yystack[yypParser->yyidx]; + + if(yyruleno >= 0) { #ifndef NDEBUG - if ( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0]))) { - if (yyTraceFILE) { - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } - } + if(yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0]))) { + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno]); + } + } #endif /* NDEBUG */ - } else { - /* invalid rule number range */ - return; - } - - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - /*memset(&yygotominor, 0, sizeof(yygotominor));*/ - yygotominor = yyzerominor; - - - switch( yyruleno ){ - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line - ** { ... } // User supplied code - ** #line - ** break; - */ - case 0: /* action_body ::= action_body_item_rep statement_rep */ - case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ yytestcase(yyruleno==70); - case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ yytestcase(yyruleno==180); - case 269: /* statement_rep ::= semicolon statement_rep */ yytestcase(yyruleno==269); - case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ yytestcase(yyruleno==320); - case 327: /* where_rule ::= TOK_WHERE where_clause_list */ yytestcase(yyruleno==327); - case 329: /* where_rule_OPT ::= where_rule */ yytestcase(yyruleno==329); + } else { + /* invalid rule number range */ + return; + } + + + /* Silence complaints from purify about yygotominor being uninitialized + ** in some cases when it is copied into the stack after the following + ** switch. yygotominor is uninitialized when a rule reduces that does + ** not set the value of its left-hand side nonterminal. Leaving the + ** value of the nonterminal uninitialized is utterly harmless as long + ** as the value is never used. So really the only thing this code + ** accomplishes is to quieten purify. + ** + ** 2007-01-16: The wireshark project (www.wireshark.org) reports that + ** without this code, their parser segfaults. I'm not sure what there + ** parser is doing to make this happen. This is the second bug report + ** from wireshark this week. Clearly they are stressing Lemon in ways + ** that it has not been previously stressed... (SQLite ticket #2172) + */ + /*memset(&yygotominor, 0, sizeof(yygotominor));*/ + yygotominor = yyzerominor; + + + switch(yyruleno) { + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** #line + ** { ... } // User supplied code + ** #line + ** break; + */ + case 0: /* action_body ::= action_body_item_rep statement_rep */ + case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ + yytestcase(yyruleno == 70); + case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ + yytestcase(yyruleno == 180); + case 269: /* statement_rep ::= semicolon statement_rep */ + yytestcase(yyruleno == 269); + case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ + yytestcase(yyruleno == 320); + case 327: /* where_rule ::= TOK_WHERE where_clause_list */ + yytestcase(yyruleno == 327); + case 329: /* where_rule_OPT ::= where_rule */ + yytestcase(yyruleno == 329); #line 297 "expparse.y" -{ - yygotominor.yy371 = yymsp[0].minor.yy371; -} + { + yygotominor.yy371 = yymsp[0].minor.yy371; + } #line 2201 "expparse.c" - break; - case 1: /* action_body_item ::= declaration */ - case 2: /* action_body_item ::= constant_decl */ yytestcase(yyruleno==2); - case 3: /* action_body_item ::= local_decl */ yytestcase(yyruleno==3); - case 43: /* block_member ::= declaration */ yytestcase(yyruleno==43); - case 44: /* block_member ::= include_directive */ yytestcase(yyruleno==44); - case 45: /* block_member ::= rule_decl */ yytestcase(yyruleno==45); - case 65: /* declaration ::= entity_decl */ yytestcase(yyruleno==65); - case 66: /* declaration ::= function_decl */ yytestcase(yyruleno==66); - case 67: /* declaration ::= procedure_decl */ yytestcase(yyruleno==67); - case 68: /* declaration ::= type_decl */ yytestcase(yyruleno==68); - case 87: /* schema_decl_list ::= schema_decl */ yytestcase(yyruleno==87); - case 157: /* rename_list ::= rename */ yytestcase(yyruleno==157); - case 166: /* interface_specification ::= use_clause */ yytestcase(yyruleno==166); - case 167: /* interface_specification ::= reference_clause */ yytestcase(yyruleno==167); - case 203: /* oneof_op ::= TOK_ONEOF */ yytestcase(yyruleno==203); - case 251: /* schema_decl ::= include_directive */ yytestcase(yyruleno==251); - case 291: /* type_item_body ::= enumeration_type */ yytestcase(yyruleno==291); + break; + case 1: /* action_body_item ::= declaration */ + case 2: /* action_body_item ::= constant_decl */ + yytestcase(yyruleno == 2); + case 3: /* action_body_item ::= local_decl */ + yytestcase(yyruleno == 3); + case 43: /* block_member ::= declaration */ + yytestcase(yyruleno == 43); + case 44: /* block_member ::= include_directive */ + yytestcase(yyruleno == 44); + case 45: /* block_member ::= rule_decl */ + yytestcase(yyruleno == 45); + case 65: /* declaration ::= entity_decl */ + yytestcase(yyruleno == 65); + case 66: /* declaration ::= function_decl */ + yytestcase(yyruleno == 66); + case 67: /* declaration ::= procedure_decl */ + yytestcase(yyruleno == 67); + case 68: /* declaration ::= type_decl */ + yytestcase(yyruleno == 68); + case 87: /* schema_decl_list ::= schema_decl */ + yytestcase(yyruleno == 87); + case 157: /* rename_list ::= rename */ + yytestcase(yyruleno == 157); + case 166: /* interface_specification ::= use_clause */ + yytestcase(yyruleno == 166); + case 167: /* interface_specification ::= reference_clause */ + yytestcase(yyruleno == 167); + case 203: /* oneof_op ::= TOK_ONEOF */ + yytestcase(yyruleno == 203); + case 251: /* schema_decl ::= include_directive */ + yytestcase(yyruleno == 251); + case 291: /* type_item_body ::= enumeration_type */ + yytestcase(yyruleno == 291); #line 303 "expparse.y" -{ - yygotominor.yy0 = yymsp[0].minor.yy0; -} + { + yygotominor.yy0 = yymsp[0].minor.yy0; + } #line 2224 "expparse.c" - break; - case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ - case 42: /* block_list ::= block_list block_member */ yytestcase(yyruleno==42); - case 63: /* constant_body_list ::= constant_body constant_body_list */ yytestcase(yyruleno==63); - case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ yytestcase(yyruleno==88); - case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ yytestcase(yyruleno==169); - case 195: /* local_body ::= local_variable local_body */ yytestcase(yyruleno==195); - case 248: /* schema_body ::= interface_specification_list block_list */ yytestcase(yyruleno==248); + break; + case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ + case 42: /* block_list ::= block_list block_member */ + yytestcase(yyruleno == 42); + case 63: /* constant_body_list ::= constant_body constant_body_list */ + yytestcase(yyruleno == 63); + case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ + yytestcase(yyruleno == 88); + case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ + yytestcase(yyruleno == 169); + case 195: /* local_body ::= local_variable local_body */ + yytestcase(yyruleno == 195); + case 248: /* schema_body ::= interface_specification_list block_list */ + yytestcase(yyruleno == 248); #line 320 "expparse.y" -{ - yygotominor.yy0 = yymsp[-1].minor.yy0; -} + { + yygotominor.yy0 = yymsp[-1].minor.yy0; + } #line 2237 "expparse.c" - break; - case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ - case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==202); - case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==275); + break; + case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ + case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ + yytestcase(yyruleno == 202); + case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ + yytestcase(yyruleno == 275); #line 337 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; -} + { + yygotominor.yy371 = yymsp[-1].minor.yy371; + } #line 2246 "expparse.c" - break; - case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ - case 319: /* unique_clause ::= */ yytestcase(yyruleno==319); + break; + case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ + case 319: /* unique_clause ::= */ + yytestcase(yyruleno == 319); #line 341 "expparse.y" -{ - yygotominor.yy371 = 0; -} + { + yygotominor.yy371 = 0; + } #line 2254 "expparse.c" - break; - case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ + break; + case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ #line 347 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = LISTcreate(); -} + { + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = LISTcreate(); + } #line 2262 "expparse.c" - break; - case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ + break; + case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ #line 353 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = yymsp[-1].minor.yy371; -} + { + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = yymsp[-1].minor.yy371; + } #line 2270 "expparse.c" - break; - case 10: /* aggregate_init_element ::= expression */ - case 25: /* assignable ::= identifier */ yytestcase(yyruleno==25); - case 47: /* by_expression ::= TOK_BY expression */ yytestcase(yyruleno==47); - case 89: /* expression ::= simple_expression */ yytestcase(yyruleno==89); - case 104: /* simple_expression ::= unary_expression */ yytestcase(yyruleno==104); - case 154: /* initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==154); - case 190: /* literal ::= constant */ yytestcase(yyruleno==190); - case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==191); - case 298: /* general_ref ::= assignable */ yytestcase(yyruleno==298); - case 299: /* unary_expression ::= aggregate_initializer */ yytestcase(yyruleno==299); - case 301: /* unary_expression ::= literal */ yytestcase(yyruleno==301); - case 302: /* unary_expression ::= function_call */ yytestcase(yyruleno==302); - case 303: /* unary_expression ::= identifier */ yytestcase(yyruleno==303); - case 305: /* unary_expression ::= interval */ yytestcase(yyruleno==305); - case 306: /* unary_expression ::= query_expression */ yytestcase(yyruleno==306); - case 308: /* unary_expression ::= TOK_PLUS unary_expression */ yytestcase(yyruleno==308); - case 312: /* qualified_attr ::= attribute_decl */ yytestcase(yyruleno==312); - case 322: /* until_control ::= TOK_UNTIL expression */ yytestcase(yyruleno==322); - case 331: /* while_control ::= TOK_WHILE expression */ yytestcase(yyruleno==331); + break; + case 10: /* aggregate_init_element ::= expression */ + case 25: /* assignable ::= identifier */ + yytestcase(yyruleno == 25); + case 47: /* by_expression ::= TOK_BY expression */ + yytestcase(yyruleno == 47); + case 89: /* expression ::= simple_expression */ + yytestcase(yyruleno == 89); + case 104: /* simple_expression ::= unary_expression */ + yytestcase(yyruleno == 104); + case 154: /* initializer ::= TOK_ASSIGNMENT expression */ + yytestcase(yyruleno == 154); + case 190: /* literal ::= constant */ + yytestcase(yyruleno == 190); + case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ + yytestcase(yyruleno == 191); + case 298: /* general_ref ::= assignable */ + yytestcase(yyruleno == 298); + case 299: /* unary_expression ::= aggregate_initializer */ + yytestcase(yyruleno == 299); + case 301: /* unary_expression ::= literal */ + yytestcase(yyruleno == 301); + case 302: /* unary_expression ::= function_call */ + yytestcase(yyruleno == 302); + case 303: /* unary_expression ::= identifier */ + yytestcase(yyruleno == 303); + case 305: /* unary_expression ::= interval */ + yytestcase(yyruleno == 305); + case 306: /* unary_expression ::= query_expression */ + yytestcase(yyruleno == 306); + case 308: /* unary_expression ::= TOK_PLUS unary_expression */ + yytestcase(yyruleno == 308); + case 312: /* qualified_attr ::= attribute_decl */ + yytestcase(yyruleno == 312); + case 322: /* until_control ::= TOK_UNTIL expression */ + yytestcase(yyruleno == 322); + case 331: /* while_control ::= TOK_WHILE expression */ + yytestcase(yyruleno == 331); #line 359 "expparse.y" -{ - yygotominor.yy401 = yymsp[0].minor.yy401; -} + { + yygotominor.yy401 = yymsp[0].minor.yy401; + } #line 2295 "expparse.c" - break; - case 11: /* aggregate_init_body ::= aggregate_init_element */ - case 113: /* expression_list ::= expression */ yytestcase(yyruleno==113); - case 282: /* supertype_expression_list ::= supertype_expression */ yytestcase(yyruleno==282); - case 313: /* qualified_attr_list ::= qualified_attr */ yytestcase(yyruleno==313); + break; + case 11: /* aggregate_init_body ::= aggregate_init_element */ + case 113: /* expression_list ::= expression */ + yytestcase(yyruleno == 113); + case 282: /* supertype_expression_list ::= supertype_expression */ + yytestcase(yyruleno == 282); + case 313: /* qualified_attr_list ::= qualified_attr */ + yytestcase(yyruleno == 313); #line 364 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + } #line 2306 "expparse.c" - break; - case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ + break; + case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ #line 369 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; -} + yymsp[0].minor.yy401->type = Type_Repeat; + } #line 2318 "expparse.c" - break; - case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ + break; + case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ #line 379 "expparse.y" -{ - yygotominor.yy371 = yymsp[-2].minor.yy371; + { + yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + } #line 2328 "expparse.c" - break; - case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ + break; + case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ #line 387 "expparse.y" -{ - yygotominor.yy371 = yymsp[-4].minor.yy371; + { + yygotominor.yy371 = yymsp[-4].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; -} + yymsp[0].minor.yy401->type = Type_Repeat; + } #line 2340 "expparse.c" - break; - case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ + break; + case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ #line 397 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - - if (tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } -} + { + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + + if(tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } + } #line 2356 "expparse.c" - break; - case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ + break; + case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ #line 411 "expparse.y" -{ - Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); - - if (t) { - SCOPEadd_super(t); - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->tag = t; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } -} + { + Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); + + if(t) { + SCOPEadd_super(t); + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->tag = t; + yygotominor.yy477->base = yymsp[0].minor.yy297; + } + } #line 2370 "expparse.c" - break; - case 17: /* aggregation_type ::= array_type */ - case 18: /* aggregation_type ::= bag_type */ yytestcase(yyruleno==18); - case 19: /* aggregation_type ::= list_type */ yytestcase(yyruleno==19); - case 20: /* aggregation_type ::= set_type */ yytestcase(yyruleno==20); + break; + case 17: /* aggregation_type ::= array_type */ + case 18: /* aggregation_type ::= bag_type */ + yytestcase(yyruleno == 18); + case 19: /* aggregation_type ::= list_type */ + yytestcase(yyruleno == 19); + case 20: /* aggregation_type ::= set_type */ + yytestcase(yyruleno == 20); #line 423 "expparse.y" -{ - yygotominor.yy477 = yymsp[0].minor.yy477; -} + { + yygotominor.yy477 = yymsp[0].minor.yy477; + } #line 2380 "expparse.c" - break; - case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ + break; + case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ #line 442 "expparse.y" -{ - Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); - Variable v = VARcreate(e, Type_Unknown); + { + Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); + Variable v = VARcreate(e, Type_Unknown); - v->initializer = yymsp[-5].minor.yy401; + v->initializer = yymsp[-5].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, - yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); - yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, + yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); + yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); - POP_SCOPE(); -} + POP_SCOPE(); + } #line 2396 "expparse.c" - break; - case 22: /* alias_push_scope ::= */ + break; + case 22: /* alias_push_scope ::= */ #line 456 "expparse.y" -{ - struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); - PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); -} + { + struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); + PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); + } #line 2404 "expparse.c" - break; - case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ + break; + case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ #line 463 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(array_); - - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->base = yymsp[0].minor.yy297; -} + { + yygotominor.yy477 = TYPEBODYcreate(array_); + + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->base = yymsp[0].minor.yy297; + } #line 2417 "expparse.c" - break; - case 24: /* assignable ::= assignable qualifier */ - case 300: /* unary_expression ::= unary_expression qualifier */ yytestcase(yyruleno==300); + break; + case 24: /* assignable ::= assignable qualifier */ + case 300: /* unary_expression ::= unary_expression qualifier */ + yytestcase(yyruleno == 300); #line 475 "expparse.y" -{ - yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy46.expr; -} + { + yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy46.expr; + } #line 2426 "expparse.c" - break; - case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ + break; + case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ #line 486 "expparse.y" -{ - yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); -} + { + yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); + } #line 2433 "expparse.c" - break; - case 27: /* attribute_type ::= aggregation_type */ - case 28: /* attribute_type ::= basic_type */ yytestcase(yyruleno==28); - case 122: /* parameter_type ::= basic_type */ yytestcase(yyruleno==122); - case 123: /* parameter_type ::= conformant_aggregation */ yytestcase(yyruleno==123); + break; + case 27: /* attribute_type ::= aggregation_type */ + case 28: /* attribute_type ::= basic_type */ + yytestcase(yyruleno == 28); + case 122: /* parameter_type ::= basic_type */ + yytestcase(yyruleno == 122); + case 123: /* parameter_type ::= conformant_aggregation */ + yytestcase(yyruleno == 123); #line 491 "expparse.y" -{ - yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); - SCOPEadd_super(yygotominor.yy297); -} + { + yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); + SCOPEadd_super(yygotominor.yy297); + } #line 2444 "expparse.c" - break; - case 29: /* attribute_type ::= defined_type */ - case 124: /* parameter_type ::= defined_type */ yytestcase(yyruleno==124); - case 125: /* parameter_type ::= generic_type */ yytestcase(yyruleno==125); + break; + case 29: /* attribute_type ::= defined_type */ + case 124: /* parameter_type ::= defined_type */ + yytestcase(yyruleno == 124); + case 125: /* parameter_type ::= generic_type */ + yytestcase(yyruleno == 125); #line 501 "expparse.y" -{ - yygotominor.yy297 = yymsp[0].minor.yy297; -} + { + yygotominor.yy297 = yymsp[0].minor.yy297; + } #line 2453 "expparse.c" - break; - case 30: /* explicit_attr_list ::= */ - case 50: /* case_action_list ::= */ yytestcase(yyruleno==50); - case 69: /* derive_decl ::= */ yytestcase(yyruleno==69); - case 268: /* statement_rep ::= */ yytestcase(yyruleno==268); + break; + case 30: /* explicit_attr_list ::= */ + case 50: /* case_action_list ::= */ + yytestcase(yyruleno == 50); + case 69: /* derive_decl ::= */ + yytestcase(yyruleno == 69); + case 268: /* statement_rep ::= */ + yytestcase(yyruleno == 268); #line 506 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); -} + { + yygotominor.yy371 = LISTcreate(); + } #line 2463 "expparse.c" - break; - case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ + break; + case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ #line 510 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); -} + { + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); + } #line 2471 "expparse.c" - break; - case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ - case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ yytestcase(yyruleno==138); + break; + case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ + case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ + yytestcase(yyruleno == 138); #line 516 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; + } #line 2482 "expparse.c" - break; - case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ + break; + case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ #line 523 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; -} + { + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + } #line 2490 "expparse.c" - break; - case 34: /* basic_type ::= TOK_BOOLEAN */ + break; + case 34: /* basic_type ::= TOK_BOOLEAN */ #line 529 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(boolean_); -} + { + yygotominor.yy477 = TYPEBODYcreate(boolean_); + } #line 2497 "expparse.c" - break; - case 35: /* basic_type ::= TOK_INTEGER precision_spec */ + break; + case 35: /* basic_type ::= TOK_INTEGER precision_spec */ #line 533 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(integer_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; -} + { + yygotominor.yy477 = TYPEBODYcreate(integer_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; + } #line 2505 "expparse.c" - break; - case 36: /* basic_type ::= TOK_REAL precision_spec */ + break; + case 36: /* basic_type ::= TOK_REAL precision_spec */ #line 538 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(real_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; -} + { + yygotominor.yy477 = TYPEBODYcreate(real_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; + } #line 2513 "expparse.c" - break; - case 37: /* basic_type ::= TOK_NUMBER */ + break; + case 37: /* basic_type ::= TOK_NUMBER */ #line 543 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(number_); -} + { + yygotominor.yy477 = TYPEBODYcreate(number_); + } #line 2520 "expparse.c" - break; - case 38: /* basic_type ::= TOK_LOGICAL */ + break; + case 38: /* basic_type ::= TOK_LOGICAL */ #line 547 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(logical_); -} + { + yygotominor.yy477 = TYPEBODYcreate(logical_); + } #line 2527 "expparse.c" - break; - case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ + break; + case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ #line 551 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(binary_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; -} + { + yygotominor.yy477 = TYPEBODYcreate(binary_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; + } #line 2536 "expparse.c" - break; - case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ + break; + case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ #line 557 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(string_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; -} + { + yygotominor.yy477 = TYPEBODYcreate(string_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; + } #line 2545 "expparse.c" - break; - case 46: /* by_expression ::= */ + break; + case 46: /* by_expression ::= */ #line 583 "expparse.y" -{ - yygotominor.yy401 = LITERAL_ONE; -} + { + yygotominor.yy401 = LITERAL_ONE; + } #line 2552 "expparse.c" - break; - case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ - case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ yytestcase(yyruleno==181); + break; + case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ + case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ + yytestcase(yyruleno == 181); #line 593 "expparse.y" -{ - yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; - yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; -} + { + yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; + yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; + } #line 2561 "expparse.c" - break; - case 49: /* case_action ::= case_labels TOK_COLON statement */ + break; + case 49: /* case_action ::= case_labels TOK_COLON statement */ #line 599 "expparse.y" -{ - yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); -} + { + yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); + } #line 2569 "expparse.c" - break; - case 51: /* case_action_list ::= case_action_list case_action */ + break; + case 51: /* case_action_list ::= case_action_list case_action */ #line 609 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy371 = yymsp[-1].minor.yy371; + yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); -} + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); + } #line 2580 "expparse.c" - break; - case 52: /* case_block ::= case_action_list case_otherwise */ + break; + case 52: /* case_block ::= case_action_list case_otherwise */ #line 618 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; - - if (yymsp[0].minor.yy321) { - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy321); - } -} + { + yygotominor.yy371 = yymsp[-1].minor.yy371; + + if(yymsp[0].minor.yy321) { + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy321); + } + } #line 2592 "expparse.c" - break; - case 53: /* case_labels ::= expression */ + break; + case 53: /* case_labels ::= expression */ #line 628 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); + { + yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + } #line 2601 "expparse.c" - break; - case 54: /* case_labels ::= case_labels TOK_COMMA expression */ + break; + case 54: /* case_labels ::= case_labels TOK_COMMA expression */ #line 634 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + } #line 2611 "expparse.c" - break; - case 55: /* case_otherwise ::= */ + break; + case 55: /* case_otherwise ::= */ #line 642 "expparse.y" -{ - yygotominor.yy321 = (Case_Item)0; -} + { + yygotominor.yy321 = (Case_Item)0; + } #line 2618 "expparse.c" - break; - case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ + break; + case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ #line 646 "expparse.y" -{ - yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); -} + { + yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); + } #line 2626 "expparse.c" - break; - case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ + break; + case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ #line 653 "expparse.y" -{ - yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); -} + { + yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); + } #line 2633 "expparse.c" - break; - case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ + break; + case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ #line 658 "expparse.y" -{ - yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); -} + { + yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); + } #line 2640 "expparse.c" - break; - case 59: /* constant ::= TOK_PI */ + break; + case 59: /* constant ::= TOK_PI */ #line 663 "expparse.y" -{ - yygotominor.yy401 = LITERAL_PI; -} + { + yygotominor.yy401 = LITERAL_PI; + } #line 2647 "expparse.c" - break; - case 60: /* constant ::= TOK_E */ + break; + case 60: /* constant ::= TOK_E */ #line 668 "expparse.y" -{ - yygotominor.yy401 = LITERAL_E; -} + { + yygotominor.yy401 = LITERAL_E; + } #line 2654 "expparse.c" - break; - case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ + break; + case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ #line 675 "expparse.y" -{ - Variable v; - - yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; - v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); - v->initializer = yymsp[-1].minor.yy401; - v->flags.constant = 1; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, - &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); -} + { + Variable v; + + yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; + v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); + v->initializer = yymsp[-1].minor.yy401; + v->flags.constant = 1; + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, + &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); + } #line 2668 "expparse.c" - break; - case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ + break; + case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ #line 694 "expparse.y" -{ - yygotominor.yy0 = yymsp[-3].minor.yy0; -} + { + yygotominor.yy0 = yymsp[-3].minor.yy0; + } #line 2675 "expparse.c" - break; - case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ + break; + case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ #line 726 "expparse.y" -{ - yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); - yygotominor.yy91->initializer = yymsp[-1].minor.yy401; - yygotominor.yy91->flags.attribute = true; -} + { + yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); + yygotominor.yy91->initializer = yymsp[-1].minor.yy401; + yygotominor.yy91->flags.attribute = true; + } #line 2684 "expparse.c" - break; - case 72: /* derived_attribute_rep ::= derived_attribute */ - case 176: /* inverse_attr_list ::= inverse_attr */ yytestcase(yyruleno==176); + break; + case 72: /* derived_attribute_rep ::= derived_attribute */ + case 176: /* inverse_attr_list ::= inverse_attr */ + yytestcase(yyruleno == 176); #line 733 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); -} + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); + } #line 2693 "expparse.c" - break; - case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ - case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ yytestcase(yyruleno==177); + break; + case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ + case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ + yytestcase(yyruleno == 177); #line 738 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); -} + { + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); + } #line 2702 "expparse.c" - break; - case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ + break; + case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ #line 745 "expparse.y" -{ - yygotominor.yy176.attributes = yymsp[-4].minor.yy371; - /* this is flattened out in entity_decl - DEL */ - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); - - if (yymsp[-2].minor.yy371 != LIST_NULL) { - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); - } - - yygotominor.yy176.unique = yymsp[-1].minor.yy371; - yygotominor.yy176.where = yymsp[0].minor.yy371; -} + { + yygotominor.yy176.attributes = yymsp[-4].minor.yy371; + /* this is flattened out in entity_decl - DEL */ + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); + + if(yymsp[-2].minor.yy371 != LIST_NULL) { + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); + } + + yygotominor.yy176.unique = yymsp[-1].minor.yy371; + yygotominor.yy176.where = yymsp[0].minor.yy371; + } #line 2718 "expparse.c" - break; - case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ + break; + case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ #line 760 "expparse.y" -{ - CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; - CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; - LISTdo( yymsp[-2].minor.yy176.attributes, l, Linked_List ) { - LISTdo_n( l, a, Variable, b ) { - ENTITYadd_attribute(CURRENT_SCOPE, a); - } LISTod; - } LISTod; - CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; - CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; - CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; - POP_SCOPE(); -} + { + CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; + CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; + LISTdo(yymsp[-2].minor.yy176.attributes, l, Linked_List) { + LISTdo_n(l, a, Variable, b) { + ENTITYadd_attribute(CURRENT_SCOPE, a); + } + LISTod; + } + LISTod; + CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; + CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; + CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; + POP_SCOPE(); + } #line 2735 "expparse.c" - break; - case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ + break; + case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ #line 775 "expparse.y" -{ - Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); + { + Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); - if (print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf( stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); - } + if(print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf(stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); -} + PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); + } #line 2748 "expparse.c" - break; - case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ + break; + case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ #line 786 "expparse.y" -{ - int value = 0; - Expression x; - Symbol *tmp; - TypeBody tb; - tb = TYPEBODYcreate(enumeration_); - CURRENT_SCOPE->u.type->head = 0; - CURRENT_SCOPE->u.type->body = tb; - tb->list = yymsp[0].minor.yy371; - - if (!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - if (!PREVIOUS_SCOPE->enum_table) { - PREVIOUS_SCOPE->enum_table = DICTcreate(25); - } - LISTdo_links(yymsp[0].minor.yy371, id) { - tmp = (Symbol *)id->data; - id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); - x->symbol = *(tmp); - x->u.integer = ++value; - - /* define both in enum scope and scope of */ - /* 1st visibility */ - DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - SYMBOL_destroy(tmp); - } LISTod; -} + { + int value = 0; + Expression x; + Symbol *tmp; + TypeBody tb; + tb = TYPEBODYcreate(enumeration_); + CURRENT_SCOPE->u.type->head = 0; + CURRENT_SCOPE->u.type->body = tb; + tb->list = yymsp[0].minor.yy371; + + if(!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + if(!PREVIOUS_SCOPE->enum_table) { + PREVIOUS_SCOPE->enum_table = DICTcreate(25); + } + LISTdo_links(yymsp[0].minor.yy371, id) { + tmp = (Symbol *)id->data; + id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); + x->symbol = *(tmp); + x->u.integer = ++value; + + /* define both in enum scope and scope of */ + /* 1st visibility */ + DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + SYMBOL_destroy(tmp); + } + LISTod; + } #line 2783 "expparse.c" - break; - case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ + break; + case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ #line 819 "expparse.y" -{ - yygotominor.yy332 = STATEMENT_ESCAPE; -} + { + yygotominor.yy332 = STATEMENT_ESCAPE; + } #line 2790 "expparse.c" - break; - case 79: /* attribute_decl ::= TOK_IDENTIFIER */ + break; + case 79: /* attribute_decl ::= TOK_IDENTIFIER */ #line 834 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Attribute); - yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy401 = EXPcreate(Type_Attribute); + yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 2799 "expparse.c" - break; - case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ + break; + case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ #line 841 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1->e.op_code = OP_GROUP; - yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); - yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); - SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); - - yygotominor.yy401->e.op_code = OP_DOT; - yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy401 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1->e.op_code = OP_GROUP; + yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); + yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); + SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); + + yygotominor.yy401->e.op_code = OP_DOT; + yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 2815 "expparse.c" - break; - case 81: /* attribute_decl_list ::= attribute_decl */ + break; + case 81: /* attribute_decl_list ::= attribute_decl */ #line 855 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + } #line 2824 "expparse.c" - break; - case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ - case 114: /* expression_list ::= expression_list TOK_COMMA expression */ yytestcase(yyruleno==114); - case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ yytestcase(yyruleno==314); + break; + case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ + case 114: /* expression_list ::= expression_list TOK_COMMA expression */ + yytestcase(yyruleno == 114); + case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ + yytestcase(yyruleno == 314); #line 862 "expparse.y" -{ - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); -} + { + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + } #line 2834 "expparse.c" - break; - case 83: /* optional ::= */ + break; + case 83: /* optional ::= */ #line 868 "expparse.y" -{ - yygotominor.yy252.optional = 0; -} + { + yygotominor.yy252.optional = 0; + } #line 2841 "expparse.c" - break; - case 84: /* optional ::= TOK_OPTIONAL */ + break; + case 84: /* optional ::= TOK_OPTIONAL */ #line 872 "expparse.y" -{ - yygotominor.yy252.optional = 1; -} + { + yygotominor.yy252.optional = 1; + } #line 2848 "expparse.c" - break; - case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ + break; + case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ #line 878 "expparse.y" -{ - Variable v; - - LISTdo_links (yymsp[-4].minor.yy371, attr) - v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); - v->flags.optional = yymsp[-2].minor.yy252.optional; - v->flags.attribute = true; - attr->data = (Generic)v; - LISTod; - - yygotominor.yy371 = yymsp[-4].minor.yy371; -} + { + Variable v; + + LISTdo_links(yymsp[-4].minor.yy371, attr) + v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); + v->flags.optional = yymsp[-2].minor.yy252.optional; + v->flags.attribute = true; + attr->data = (Generic)v; + LISTod; + + yygotominor.yy371 = yymsp[-4].minor.yy371; + } #line 2864 "expparse.c" - break; - case 90: /* expression ::= expression TOK_AND expression */ + break; + case 90: /* expression ::= expression TOK_AND expression */ #line 907 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2873 "expparse.c" - break; - case 91: /* expression ::= expression TOK_OR expression */ + break; + case 91: /* expression ::= expression TOK_OR expression */ #line 913 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2882 "expparse.c" - break; - case 92: /* expression ::= expression TOK_XOR expression */ + break; + case 92: /* expression ::= expression TOK_XOR expression */ #line 919 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2891 "expparse.c" - break; - case 93: /* expression ::= expression TOK_LESS_THAN expression */ + break; + case 93: /* expression ::= expression TOK_LESS_THAN expression */ #line 925 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2900 "expparse.c" - break; - case 94: /* expression ::= expression TOK_GREATER_THAN expression */ + break; + case 94: /* expression ::= expression TOK_GREATER_THAN expression */ #line 931 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2909 "expparse.c" - break; - case 95: /* expression ::= expression TOK_EQUAL expression */ + break; + case 95: /* expression ::= expression TOK_EQUAL expression */ #line 937 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2918 "expparse.c" - break; - case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ + break; + case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ #line 943 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2927 "expparse.c" - break; - case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ + break; + case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ #line 949 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2936 "expparse.c" - break; - case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ + break; + case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ #line 955 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2945 "expparse.c" - break; - case 99: /* expression ::= expression TOK_INST_EQUAL expression */ + break; + case 99: /* expression ::= expression TOK_INST_EQUAL expression */ #line 961 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2954 "expparse.c" - break; - case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ + break; + case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ #line 967 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2963 "expparse.c" - break; - case 101: /* expression ::= expression TOK_IN expression */ + break; + case 101: /* expression ::= expression TOK_IN expression */ #line 973 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2972 "expparse.c" - break; - case 102: /* expression ::= expression TOK_LIKE expression */ + break; + case 102: /* expression ::= expression TOK_LIKE expression */ #line 979 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2981 "expparse.c" - break; - case 103: /* expression ::= simple_expression cardinality_op simple_expression */ - case 240: /* right_curl ::= TOK_RIGHT_CURL */ yytestcase(yyruleno==240); - case 254: /* semicolon ::= TOK_SEMICOLON */ yytestcase(yyruleno==254); + break; + case 103: /* expression ::= simple_expression cardinality_op simple_expression */ + case 240: /* right_curl ::= TOK_RIGHT_CURL */ + yytestcase(yyruleno == 240); + case 254: /* semicolon ::= TOK_SEMICOLON */ + yytestcase(yyruleno == 254); #line 985 "expparse.y" -{ - yyerrok; -} + { + yyerrok; + } #line 2990 "expparse.c" - break; - case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ + break; + case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ #line 995 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 2999 "expparse.c" - break; - case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ + break; + case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ #line 1001 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3008 "expparse.c" - break; - case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ + break; + case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ #line 1007 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3017 "expparse.c" - break; - case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ + break; + case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ #line 1013 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3026 "expparse.c" - break; - case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ + break; + case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ #line 1019 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3035 "expparse.c" - break; - case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ + break; + case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ #line 1025 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3044 "expparse.c" - break; - case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ + break; + case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ #line 1031 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3053 "expparse.c" - break; - case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ + break; + case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ #line 1037 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); -} + yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); + } #line 3062 "expparse.c" - break; - case 115: /* var ::= */ + break; + case 115: /* var ::= */ #line 1055 "expparse.y" -{ - yygotominor.yy252.var = 0; -} + { + yygotominor.yy252.var = 0; + } #line 3069 "expparse.c" - break; - case 116: /* var ::= TOK_VAR */ + break; + case 116: /* var ::= TOK_VAR */ #line 1059 "expparse.y" -{ - yygotominor.yy252.var = 1; -} + { + yygotominor.yy252.var = 1; + } #line 3076 "expparse.c" - break; - case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ + break; + case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ #line 1064 "expparse.y" -{ - Symbol *tmp; - Expression e; - Variable v; - - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTdo_links(yygotominor.yy371, param) - tmp = (Symbol*)param->data; - - e = EXPcreate_from_symbol(Type_Attribute, tmp); - v = VARcreate(e, yymsp[0].minor.yy297); - v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ - v->flags.parameter = true; - param->data = (Generic)v; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, - tmp->name, (Generic)v, tmp, OBJ_VARIABLE); - - LISTod; -} + { + Symbol *tmp; + Expression e; + Variable v; + + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTdo_links(yygotominor.yy371, param) + tmp = (Symbol *)param->data; + + e = EXPcreate_from_symbol(Type_Attribute, tmp); + v = VARcreate(e, yymsp[0].minor.yy297); + v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ + v->flags.parameter = true; + param->data = (Generic)v; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, + tmp->name, (Generic)v, tmp, OBJ_VARIABLE); + + LISTod; + } #line 3101 "expparse.c" - break; - case 118: /* formal_parameter_list ::= */ - case 179: /* inverse_clause ::= */ yytestcase(yyruleno==179); - case 328: /* where_rule_OPT ::= */ yytestcase(yyruleno==328); + break; + case 118: /* formal_parameter_list ::= */ + case 179: /* inverse_clause ::= */ + yytestcase(yyruleno == 179); + case 328: /* where_rule_OPT ::= */ + yytestcase(yyruleno == 328); #line 1087 "expparse.y" -{ - yygotominor.yy371 = LIST_NULL; -} + { + yygotominor.yy371 = LIST_NULL; + } #line 3110 "expparse.c" - break; - case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ + break; + case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ #line 1092 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; + { + yygotominor.yy371 = yymsp[-1].minor.yy371; -} + } #line 3118 "expparse.c" - break; - case 120: /* formal_parameter_rep ::= formal_parameter */ + break; + case 120: /* formal_parameter_rep ::= formal_parameter */ #line 1098 "expparse.y" -{ - yygotominor.yy371 = yymsp[0].minor.yy371; + { + yygotominor.yy371 = yymsp[0].minor.yy371; -} + } #line 3126 "expparse.c" - break; - case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ + break; + case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ #line 1104 "expparse.y" -{ - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); -} + { + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); + } #line 3134 "expparse.c" - break; - case 126: /* function_call ::= function_id actual_parameters */ + break; + case 126: /* function_call ::= function_id actual_parameters */ #line 1129 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Funcall); - yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; - SYMBOL_destroy(yymsp[-1].minor.yy275); - yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; -} + { + yygotominor.yy401 = EXPcreate(Type_Funcall); + yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; + SYMBOL_destroy(yymsp[-1].minor.yy275); + yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; + } #line 3144 "expparse.c" - break; - case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ + break; + case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ #line 1138 "expparse.y" -{ - FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); -} + { + FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); + } #line 3153 "expparse.c" - break; - case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ + break; + case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ #line 1146 "expparse.y" -{ - Function f = CURRENT_SCOPE; + { + Function f = CURRENT_SCOPE; - f->u.func->return_type = yymsp[-1].minor.yy297; - yygotominor.yy507 = yymsp[-5].minor.yy507; -} + f->u.func->return_type = yymsp[-1].minor.yy297; + yygotominor.yy507 = yymsp[-5].minor.yy507; + } #line 3163 "expparse.c" - break; - case 129: /* fh_lineno ::= TOK_FUNCTION */ - case 218: /* ph_get_line ::= */ yytestcase(yyruleno==218); - case 247: /* rh_get_line ::= */ yytestcase(yyruleno==247); + break; + case 129: /* fh_lineno ::= TOK_FUNCTION */ + case 218: /* ph_get_line ::= */ + yytestcase(yyruleno == 218); + case 247: /* rh_get_line ::= */ + yytestcase(yyruleno == 247); #line 1154 "expparse.y" -{ - yygotominor.yy507 = SCANtell(); -} + { + yygotominor.yy507 = SCANtell(); + } #line 3172 "expparse.c" - break; - case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ + break; + case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ #line 1159 "expparse.y" -{ - Function f = ALGcreate(OBJ_FUNCTION); - tag_count = 0; - if (print_objects_while_running & OBJ_FUNCTION_BITS) { - fprintf( stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); - } - PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); -} + { + Function f = ALGcreate(OBJ_FUNCTION); + tag_count = 0; + if(print_objects_while_running & OBJ_FUNCTION_BITS) { + fprintf(stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); + } + PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); + } #line 3184 "expparse.c" - break; - case 131: /* fh_plist ::= formal_parameter_list */ + break; + case 131: /* fh_plist ::= formal_parameter_list */ #line 1169 "expparse.y" -{ - Function f = CURRENT_SCOPE; - f->u.func->parameters = yymsp[0].minor.yy371; - f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); - f->u.func->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ -} + { + Function f = CURRENT_SCOPE; + f->u.func->parameters = yymsp[0].minor.yy371; + f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); + f->u.func->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ + } #line 3195 "expparse.c" - break; - case 132: /* function_id ::= TOK_IDENTIFIER */ - case 219: /* procedure_id ::= TOK_IDENTIFIER */ yytestcase(yyruleno==219); - case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ yytestcase(yyruleno==220); + break; + case 132: /* function_id ::= TOK_IDENTIFIER */ + case 219: /* procedure_id ::= TOK_IDENTIFIER */ + yytestcase(yyruleno == 219); + case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ + yytestcase(yyruleno == 220); #line 1178 "expparse.y" -{ - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; -} + { + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; + } #line 3204 "expparse.c" - break; - case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ + break; + case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ #line 1182 "expparse.y" -{ - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; + { + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; -} + } #line 3212 "expparse.c" - break; - case 134: /* conformant_aggregation ::= aggregate_type */ + break; + case 134: /* conformant_aggregation ::= aggregate_type */ #line 1188 "expparse.y" -{ - yygotominor.yy477 = yymsp[0].minor.yy477; + { + yygotominor.yy477 = yymsp[0].minor.yy477; -} + } #line 3220 "expparse.c" - break; - case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ + break; + case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ #line 1194 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; -} + { + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; + } #line 3230 "expparse.c" - break; - case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ + break; + case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ #line 1202 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + } #line 3242 "expparse.c" - break; - case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ + break; + case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ #line 1211 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; + { + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; -} + } #line 3251 "expparse.c" - break; - case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ + break; + case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ #line 1224 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; + { + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; -} + } #line 3261 "expparse.c" - break; - case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ + break; + case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ #line 1232 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + } #line 3272 "expparse.c" - break; - case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ - case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ yytestcase(yyruleno==256); + break; + case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ + case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ + yytestcase(yyruleno == 256); #line 1240 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; -} + { + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + } #line 3281 "expparse.c" - break; - case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ + break; + case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ #line 1245 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; + } #line 3291 "expparse.c" - break; - case 143: /* generic_type ::= TOK_GENERIC */ + break; + case 143: /* generic_type ::= TOK_GENERIC */ #line 1253 "expparse.y" -{ - yygotominor.yy297 = Type_Generic; - - if (tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } -} + { + yygotominor.yy297 = Type_Generic; + + if(tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } + } #line 3306 "expparse.c" - break; - case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ + break; + case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ #line 1265 "expparse.y" -{ - TypeBody g = TYPEBODYcreate(generic_); - yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); + { + TypeBody g = TYPEBODYcreate(generic_); + yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); - SCOPEadd_super(yygotominor.yy297); + SCOPEadd_super(yygotominor.yy297); - g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); - if (g->tag) { - SCOPEadd_super(g->tag); - } -} + g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); + if(g->tag) { + SCOPEadd_super(g->tag); + } + } #line 3321 "expparse.c" - break; - case 145: /* id_list ::= TOK_IDENTIFIER */ + break; + case 145: /* id_list ::= TOK_IDENTIFIER */ #line 1278 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); -} + } #line 3330 "expparse.c" - break; - case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ + break; + case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ #line 1284 "expparse.y" -{ - yyerrok; + { + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); -} + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); + } #line 3340 "expparse.c" - break; - case 147: /* identifier ::= TOK_SELF */ + break; + case 147: /* identifier ::= TOK_SELF */ #line 1292 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Self); -} + { + yygotominor.yy401 = EXPcreate(Type_Self); + } #line 3347 "expparse.c" - break; - case 148: /* identifier ::= TOK_QUESTION_MARK */ + break; + case 148: /* identifier ::= TOK_QUESTION_MARK */ #line 1296 "expparse.y" -{ - yygotominor.yy401 = LITERAL_INFINITY; -} + { + yygotominor.yy401 = LITERAL_INFINITY; + } #line 3354 "expparse.c" - break; - case 149: /* identifier ::= TOK_IDENTIFIER */ + break; + case 149: /* identifier ::= TOK_IDENTIFIER */ #line 1300 "expparse.y" -{ - yygotominor.yy401 = EXPcreate(Type_Identifier); - yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy401 = EXPcreate(Type_Identifier); + yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 3363 "expparse.c" - break; - case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ + break; + case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ #line 1308 "expparse.y" -{ - yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); -} + { + yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); + } #line 3370 "expparse.c" - break; - case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ + break; + case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ #line 1313 "expparse.y" -{ - yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); -} + { + yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); + } #line 3377 "expparse.c" - break; - case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ + break; + case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ #line 1318 "expparse.y" -{ - SCANinclude_file(yymsp[-1].minor.yy0.string); -} + { + SCANinclude_file(yymsp[-1].minor.yy0.string); + } #line 3384 "expparse.c" - break; - case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ + break; + case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ #line 1324 "expparse.y" -{ - Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); + { + Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); - /* scope doesn't really have/need a name, I suppose */ - /* naming it by the iterator variable is fine */ + /* scope doesn't really have/need a name, I suppose */ + /* naming it by the iterator variable is fine */ - PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); -} + PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); + } #line 3396 "expparse.c" - break; - case 155: /* rename ::= TOK_IDENTIFIER */ + break; + case 155: /* rename ::= TOK_IDENTIFIER */ #line 1342 "expparse.y" -{ - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); -} + { + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); + } #line 3403 "expparse.c" - break; - case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ + break; + case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ #line 1346 "expparse.y" -{ - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); -} + { + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); + } #line 3410 "expparse.c" - break; - case 158: /* rename_list ::= rename_list TOK_COMMA rename */ - case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ yytestcase(yyruleno==161); - case 164: /* use_clause ::= use_head parened_rename_list semicolon */ yytestcase(yyruleno==164); - case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ yytestcase(yyruleno==249); - case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ yytestcase(yyruleno==295); + break; + case 158: /* rename_list ::= rename_list TOK_COMMA rename */ + case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ + yytestcase(yyruleno == 161); + case 164: /* use_clause ::= use_head parened_rename_list semicolon */ + yytestcase(yyruleno == 164); + case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ + yytestcase(yyruleno == 249); + case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ + yytestcase(yyruleno == 295); #line 1355 "expparse.y" -{ - yygotominor.yy0 = yymsp[-2].minor.yy0; -} + { + yygotominor.yy0 = yymsp[-2].minor.yy0; + } #line 3421 "expparse.c" - break; - case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1365 "expparse.y" -{ - if (!CURRENT_SCHEMA->ref_schemas) { - CURRENT_SCHEMA->ref_schemas = LISTcreate(); - } + { + if(!CURRENT_SCHEMA->ref_schemas) { + CURRENT_SCHEMA->ref_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); -} + LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); + } #line 3432 "expparse.c" - break; - case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ + break; + case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ #line 1378 "expparse.y" -{ - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_reference; -} + { + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_reference; + } #line 3440 "expparse.c" - break; - case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1384 "expparse.y" -{ - if (!CURRENT_SCHEMA->use_schemas) { - CURRENT_SCHEMA->use_schemas = LISTcreate(); - } + { + if(!CURRENT_SCHEMA->use_schemas) { + CURRENT_SCHEMA->use_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); -} + LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); + } #line 3451 "expparse.c" - break; - case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ + break; + case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ #line 1397 "expparse.y" -{ - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_use; -} + { + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_use; + } #line 3459 "expparse.c" - break; - case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ + break; + case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ #line 1420 "expparse.y" -{ - Expression tmp1, tmp2; - - yygotominor.yy401 = (Expression)0; - tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); - tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); - yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); -} + { + Expression tmp1, tmp2; + + yygotominor.yy401 = (Expression)0; + tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); + tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); + yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); + } #line 3471 "expparse.c" - break; - case 171: /* set_or_bag_of_entity ::= defined_type */ - case 289: /* type ::= defined_type */ yytestcase(yyruleno==289); + break; + case 171: /* set_or_bag_of_entity ::= defined_type */ + case 289: /* type ::= defined_type */ + yytestcase(yyruleno == 289); #line 1432 "expparse.y" -{ - yygotominor.yy378.type = yymsp[0].minor.yy297; - yygotominor.yy378.body = 0; -} + { + yygotominor.yy378.type = yymsp[0].minor.yy297; + yygotominor.yy378.body = 0; + } #line 3480 "expparse.c" - break; - case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ + break; + case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ #line 1437 "expparse.y" -{ - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; + { + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; -} + } #line 3490 "expparse.c" - break; - case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ + break; + case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ #line 1444 "expparse.y" -{ - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; -} + { + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; + } #line 3501 "expparse.c" - break; - case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ + break; + case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ #line 1452 "expparse.y" -{ - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; -} + { + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; + } #line 3512 "expparse.c" - break; - case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ + break; + case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ #line 1460 "expparse.y" -{ - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; -} + { + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + } #line 3521 "expparse.c" - break; - case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ + break; + case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ #line 1487 "expparse.y" -{ - if (yymsp[-3].minor.yy378.type) { - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); - } else { - Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); - SCOPEadd_super(t); - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); - } - - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; -} + { + if(yymsp[-3].minor.yy378.type) { + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); + } else { + Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); + SCOPEadd_super(t); + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); + } + + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; + } #line 3537 "expparse.c" - break; - case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ + break; + case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ #line 1521 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + } #line 3548 "expparse.c" - break; - case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ + break; + case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ #line 1529 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; -} + { + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + } #line 3557 "expparse.c" - break; - case 184: /* literal ::= TOK_INTEGER_LITERAL */ + break; + case 184: /* literal ::= TOK_INTEGER_LITERAL */ #line 1536 "expparse.y" -{ - if (yymsp[0].minor.yy0.iVal == 0) { - yygotominor.yy401 = LITERAL_ZERO; - } else if (yymsp[0].minor.yy0.iVal == 1) { - yygotominor.yy401 = LITERAL_ONE; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Integer); - yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; - resolved_all(yygotominor.yy401); - } -} + { + if(yymsp[0].minor.yy0.iVal == 0) { + yygotominor.yy401 = LITERAL_ZERO; + } else if(yymsp[0].minor.yy0.iVal == 1) { + yygotominor.yy401 = LITERAL_ONE; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Integer); + yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; + resolved_all(yygotominor.yy401); + } + } #line 3572 "expparse.c" - break; - case 185: /* literal ::= TOK_REAL_LITERAL */ + break; + case 185: /* literal ::= TOK_REAL_LITERAL */ #line 1548 "expparse.y" -{ - /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ - if( ( fabs( yymsp[0].minor.yy0.rVal ) <= FLT_MIN ) && ( fabs( yymsp[0].minor.yy0.rVal ) > 0 ) ) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal ); - } - if( fabs( yymsp[0].minor.yy0.rVal ) < DBL_MIN ) { - yygotominor.yy401 = LITERAL_ZERO; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Real); - yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; - resolved_all(yygotominor.yy401); - } -} + { + /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ + if((fabs(yymsp[0].minor.yy0.rVal) <= FLT_MIN) && (fabs(yymsp[0].minor.yy0.rVal) > 0)) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal); + } + if(fabs(yymsp[0].minor.yy0.rVal) < DBL_MIN) { + yygotominor.yy401 = LITERAL_ZERO; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Real); + yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; + resolved_all(yygotominor.yy401); + } + } #line 3592 "expparse.c" - break; - case 186: /* literal ::= TOK_STRING_LITERAL */ + break; + case 186: /* literal ::= TOK_STRING_LITERAL */ #line 1565 "expparse.y" -{ - yygotominor.yy401 = EXPcreate_simple(Type_String); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); -} + { + yygotominor.yy401 = EXPcreate_simple(Type_String); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); + } #line 3601 "expparse.c" - break; - case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ + break; + case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ #line 1571 "expparse.y" -{ - yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); -} + { + yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); + } #line 3610 "expparse.c" - break; - case 188: /* literal ::= TOK_LOGICAL_LITERAL */ + break; + case 188: /* literal ::= TOK_LOGICAL_LITERAL */ #line 1577 "expparse.y" -{ - yygotominor.yy401 = EXPcreate_simple(Type_Logical); - yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; - resolved_all(yygotominor.yy401); -} + { + yygotominor.yy401 = EXPcreate_simple(Type_Logical); + yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; + resolved_all(yygotominor.yy401); + } #line 3619 "expparse.c" - break; - case 189: /* literal ::= TOK_BINARY_LITERAL */ + break; + case 189: /* literal ::= TOK_BINARY_LITERAL */ #line 1583 "expparse.y" -{ - yygotominor.yy401 = EXPcreate_simple(Type_Binary); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; - resolved_all(yygotominor.yy401); -} + { + yygotominor.yy401 = EXPcreate_simple(Type_Binary); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; + resolved_all(yygotominor.yy401); + } #line 3628 "expparse.c" - break; - case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ + break; + case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ #line 1599 "expparse.y" -{ - Expression e; - Variable v; - LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) - - /* convert symbol to name-expression */ - - e = EXPcreate(Type_Attribute); - e->symbol = *sym; SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-1].minor.yy297); - v->offset = local_var_count++; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-3].minor.yy371); -} + { + Expression e; + Variable v; + LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) + + /* convert symbol to name-expression */ + + e = EXPcreate(Type_Attribute); + e->symbol = *sym; + SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-1].minor.yy297); + v->offset = local_var_count++; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-3].minor.yy371); + } #line 3647 "expparse.c" - break; - case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ + break; + case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ #line 1616 "expparse.y" -{ - Expression e; - Variable v; - LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) - e = EXPcreate(Type_Attribute); - e->symbol = *sym; SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-2].minor.yy297); - v->offset = local_var_count++; - v->initializer = yymsp[-1].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, - &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-4].minor.yy371); -} + { + Expression e; + Variable v; + LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) + e = EXPcreate(Type_Attribute); + e->symbol = *sym; + SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-2].minor.yy297); + v->offset = local_var_count++; + v->initializer = yymsp[-1].minor.yy401; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, + &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-4].minor.yy371); + } #line 3665 "expparse.c" - break; - case 197: /* local_decl_rules_on ::= */ + break; + case 197: /* local_decl_rules_on ::= */ #line 1640 "expparse.y" -{ - tag_count = 0; /* don't signal an error if we find a generic_type */ - local_var_count = 0; /* used to keep local var decl's in the same order */ -} + { + tag_count = 0; /* don't signal an error if we find a generic_type */ + local_var_count = 0; /* used to keep local var decl's in the same order */ + } #line 3673 "expparse.c" - break; - case 198: /* local_decl_rules_off ::= */ + break; + case 198: /* local_decl_rules_off ::= */ #line 1646 "expparse.y" -{ - tag_count = -1; /* signal an error if we find a generic_type */ -} + { + tag_count = -1; /* signal an error if we find a generic_type */ + } #line 3680 "expparse.c" - break; - case 199: /* defined_type ::= TOK_IDENTIFIER */ + break; + case 199: /* defined_type ::= TOK_IDENTIFIER */ #line 1651 "expparse.y" -{ - yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(yygotominor.yy297); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(yygotominor.yy297); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 3689 "expparse.c" - break; - case 200: /* defined_type_list ::= defined_type */ + break; + case 200: /* defined_type_list ::= defined_type */ #line 1658 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); -} + } #line 3698 "expparse.c" - break; - case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ + break; + case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ #line 1664 "expparse.y" -{ - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy297); -} + { + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy297); + } #line 3707 "expparse.c" - break; - case 204: /* optional_or_unique ::= */ + break; + case 204: /* optional_or_unique ::= */ #line 1681 "expparse.y" -{ - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 0; -} + { + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 0; + } #line 3715 "expparse.c" - break; - case 205: /* optional_or_unique ::= TOK_OPTIONAL */ + break; + case 205: /* optional_or_unique ::= TOK_OPTIONAL */ #line 1686 "expparse.y" -{ - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 1; -} + { + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 1; + } #line 3723 "expparse.c" - break; - case 206: /* optional_or_unique ::= TOK_UNIQUE */ + break; + case 206: /* optional_or_unique ::= TOK_UNIQUE */ #line 1691 "expparse.y" -{ - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 0; -} + { + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 0; + } #line 3731 "expparse.c" - break; - case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ - case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ yytestcase(yyruleno==208); + break; + case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ + case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ + yytestcase(yyruleno == 208); #line 1696 "expparse.y" -{ - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 1; -} + { + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 1; + } #line 3740 "expparse.c" - break; - case 209: /* optional_fixed ::= */ + break; + case 209: /* optional_fixed ::= */ #line 1707 "expparse.y" -{ - yygotominor.yy252.fixed = 0; -} + { + yygotominor.yy252.fixed = 0; + } #line 3747 "expparse.c" - break; - case 210: /* optional_fixed ::= TOK_FIXED */ + break; + case 210: /* optional_fixed ::= TOK_FIXED */ #line 1711 "expparse.y" -{ - yygotominor.yy252.fixed = 1; -} + { + yygotominor.yy252.fixed = 1; + } #line 3754 "expparse.c" - break; - case 211: /* precision_spec ::= */ + break; + case 211: /* precision_spec ::= */ #line 1716 "expparse.y" -{ - yygotominor.yy401 = (Expression)0; -} + { + yygotominor.yy401 = (Expression)0; + } #line 3761 "expparse.c" - break; - case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ - case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ yytestcase(yyruleno==304); + break; + case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ + case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ + yytestcase(yyruleno == 304); #line 1720 "expparse.y" -{ - yygotominor.yy401 = yymsp[-1].minor.yy401; -} + { + yygotominor.yy401 = yymsp[-1].minor.yy401; + } #line 3769 "expparse.c" - break; - case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ + break; + case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ #line 1730 "expparse.y" -{ - yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); - yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); -} + { + yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); + yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); + } #line 3777 "expparse.c" - break; - case 214: /* proc_call_statement ::= procedure_id semicolon */ + break; + case 214: /* proc_call_statement ::= procedure_id semicolon */ #line 1735 "expparse.y" -{ - yygotominor.yy332 = PCALLcreate((Linked_List)0); - yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); -} + { + yygotominor.yy332 = PCALLcreate((Linked_List)0); + yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); + } #line 3785 "expparse.c" - break; - case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ + break; + case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ #line 1742 "expparse.y" -{ - PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); -} + { + PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); + } #line 3794 "expparse.c" - break; - case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ + break; + case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ #line 1750 "expparse.y" -{ - Procedure p = CURRENT_SCOPE; - p->u.proc->parameters = yymsp[-1].minor.yy371; - p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); - p->u.proc->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ - yygotominor.yy507 = yymsp[-3].minor.yy507; -} + { + Procedure p = CURRENT_SCOPE; + p->u.proc->parameters = yymsp[-1].minor.yy371; + p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); + p->u.proc->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ + yygotominor.yy507 = yymsp[-3].minor.yy507; + } #line 3806 "expparse.c" - break; - case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ + break; + case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ #line 1760 "expparse.y" -{ - Procedure p = ALGcreate(OBJ_PROCEDURE); - tag_count = 0; + { + Procedure p = ALGcreate(OBJ_PROCEDURE); + tag_count = 0; - if (print_objects_while_running & OBJ_PROCEDURE_BITS) { - fprintf( stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); - } + if(print_objects_while_running & OBJ_PROCEDURE_BITS) { + fprintf(stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); -} + PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); + } #line 3820 "expparse.c" - break; - case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1786 "expparse.y" -{ - yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 3830 "expparse.c" - break; - case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ + break; + case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ #line 1794 "expparse.y" -{ - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 3840 "expparse.c" - break; - case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1801 "expparse.y" -{ - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); -} + { + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); + } #line 3850 "expparse.c" - break; - case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ + break; + case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ #line 1810 "expparse.y" -{ - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, - (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; -} + { + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, + (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; + } #line 3859 "expparse.c" - break; - case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ + break; + case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ #line 1819 "expparse.y" -{ - yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, - (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; - yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; -} + { + yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, + (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; + yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; + } #line 3869 "expparse.c" - break; - case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ + break; + case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ #line 1827 "expparse.y" -{ - yygotominor.yy401 = yymsp[-2].minor.yy401; - yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; - POP_SCOPE(); -} + { + yygotominor.yy401 = yymsp[-2].minor.yy401; + yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; + POP_SCOPE(); + } #line 3878 "expparse.c" - break; - case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ + break; + case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ #line 1835 "expparse.y" -{ - yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); - SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); - PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); -} + { + yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); + SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); + PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); + } #line 3887 "expparse.c" - break; - case 228: /* rel_op ::= TOK_LESS_THAN */ + break; + case 228: /* rel_op ::= TOK_LESS_THAN */ #line 1842 "expparse.y" -{ - yygotominor.yy126 = OP_LESS_THAN; -} + { + yygotominor.yy126 = OP_LESS_THAN; + } #line 3894 "expparse.c" - break; - case 229: /* rel_op ::= TOK_GREATER_THAN */ + break; + case 229: /* rel_op ::= TOK_GREATER_THAN */ #line 1846 "expparse.y" -{ - yygotominor.yy126 = OP_GREATER_THAN; -} + { + yygotominor.yy126 = OP_GREATER_THAN; + } #line 3901 "expparse.c" - break; - case 230: /* rel_op ::= TOK_EQUAL */ + break; + case 230: /* rel_op ::= TOK_EQUAL */ #line 1850 "expparse.y" -{ - yygotominor.yy126 = OP_EQUAL; -} + { + yygotominor.yy126 = OP_EQUAL; + } #line 3908 "expparse.c" - break; - case 231: /* rel_op ::= TOK_LESS_EQUAL */ + break; + case 231: /* rel_op ::= TOK_LESS_EQUAL */ #line 1854 "expparse.y" -{ - yygotominor.yy126 = OP_LESS_EQUAL; -} + { + yygotominor.yy126 = OP_LESS_EQUAL; + } #line 3915 "expparse.c" - break; - case 232: /* rel_op ::= TOK_GREATER_EQUAL */ + break; + case 232: /* rel_op ::= TOK_GREATER_EQUAL */ #line 1858 "expparse.y" -{ - yygotominor.yy126 = OP_GREATER_EQUAL; -} + { + yygotominor.yy126 = OP_GREATER_EQUAL; + } #line 3922 "expparse.c" - break; - case 233: /* rel_op ::= TOK_NOT_EQUAL */ + break; + case 233: /* rel_op ::= TOK_NOT_EQUAL */ #line 1862 "expparse.y" -{ - yygotominor.yy126 = OP_NOT_EQUAL; -} + { + yygotominor.yy126 = OP_NOT_EQUAL; + } #line 3929 "expparse.c" - break; - case 234: /* rel_op ::= TOK_INST_EQUAL */ + break; + case 234: /* rel_op ::= TOK_INST_EQUAL */ #line 1866 "expparse.y" -{ - yygotominor.yy126 = OP_INST_EQUAL; -} + { + yygotominor.yy126 = OP_INST_EQUAL; + } #line 3936 "expparse.c" - break; - case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ + break; + case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ #line 1870 "expparse.y" -{ - yygotominor.yy126 = OP_INST_NOT_EQUAL; -} + { + yygotominor.yy126 = OP_INST_NOT_EQUAL; + } #line 3943 "expparse.c" - break; - case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1878 "expparse.y" -{ - yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); + { + yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - /* matching PUSH_SCOPE is in increment_control */ - POP_SCOPE(); -} + /* matching PUSH_SCOPE is in increment_control */ + POP_SCOPE(); + } #line 3953 "expparse.c" - break; - case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1886 "expparse.y" -{ - yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); -} + { + yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); + } #line 3960 "expparse.c" - break; - case 238: /* return_statement ::= TOK_RETURN semicolon */ + break; + case 238: /* return_statement ::= TOK_RETURN semicolon */ #line 1891 "expparse.y" -{ - yygotominor.yy332 = RETcreate((Expression)0); -} + { + yygotominor.yy332 = RETcreate((Expression)0); + } #line 3967 "expparse.c" - break; - case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ + break; + case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ #line 1896 "expparse.y" -{ - yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); -} + { + yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); + } #line 3974 "expparse.c" - break; - case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ + break; + case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ #line 1907 "expparse.y" -{ - RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); - RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); - POP_SCOPE(); -} + { + RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); + RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); + POP_SCOPE(); + } #line 3984 "expparse.c" - break; - case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ + break; + case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ #line 1915 "expparse.y" -{ - Expression e; - Type t; - - /* it's true that we know it will be an entity_ type later */ - TypeBody tb = TYPEBODYcreate(set_); - tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(tb->base); - t = TYPEcreate_from_body_anonymously(tb); - SCOPEadd_super(t); - e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); - yygotominor.yy91 = VARcreate(e, t); - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->flags.parameter = true; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, - yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); -} + { + Expression e; + Type t; + + /* it's true that we know it will be an entity_ type later */ + TypeBody tb = TYPEBODYcreate(set_); + tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(tb->base); + t = TYPEcreate_from_body_anonymously(tb); + SCOPEadd_super(t); + e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); + yygotominor.yy91 = VARcreate(e, t); + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->flags.parameter = true; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, + yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); + } #line 4007 "expparse.c" - break; - case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ + break; + case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ #line 1936 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); -} + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); + } #line 4015 "expparse.c" - break; - case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ + break; + case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ #line 1942 "expparse.y" -{ - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); -} + { + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); + } #line 4023 "expparse.c" - break; - case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ + break; + case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ #line 1949 "expparse.y" -{ - CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; + { + CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; - yygotominor.yy507 = yymsp[-3].minor.yy507; -} + yygotominor.yy507 = yymsp[-3].minor.yy507; + } #line 4032 "expparse.c" - break; - case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ + break; + case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ #line 1957 "expparse.y" -{ - Rule r = ALGcreate(OBJ_RULE); + { + Rule r = ALGcreate(OBJ_RULE); - if (print_objects_while_running & OBJ_RULE_BITS) { - fprintf( stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); - } + if(print_objects_while_running & OBJ_RULE_BITS) { + fprintf(stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); + } - PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); + PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); - yygotominor.yy507 = yymsp[-3].minor.yy507; -} + yygotominor.yy507 = yymsp[-3].minor.yy507; + } #line 4047 "expparse.c" - break; - case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ + break; + case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ #line 1984 "expparse.y" -{ - POP_SCOPE(); -} + { + POP_SCOPE(); + } #line 4054 "expparse.c" - break; - case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ + break; + case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ #line 1993 "expparse.y" -{ - Schema schema = ( Schema ) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); - - if (print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf( stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); - } - - if (EXPRESSignore_duplicate_schemas && schema) { - SCANskip_to_end_schema(parseData.scanner); - PUSH_SCOPE_DUMMY(); - } else { - schema = SCHEMAcreate(); - LISTadd_last(PARSEnew_schemas, (Generic)schema); - PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); - } -} + { + Schema schema = (Schema) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); + + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); + } + + if(EXPRESSignore_duplicate_schemas && schema) { + SCANskip_to_end_schema(parseData.scanner); + PUSH_SCOPE_DUMMY(); + } else { + schema = SCHEMAcreate(); + LISTadd_last(PARSEnew_schemas, (Generic)schema); + PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); + } + } #line 4074 "expparse.c" - break; - case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ + break; + case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ #line 2012 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(select_); - yygotominor.yy477->list = yymsp[-1].minor.yy371; -} + { + yygotominor.yy477 = TYPEBODYcreate(select_); + yygotominor.yy477->list = yymsp[-1].minor.yy371; + } #line 4082 "expparse.c" - break; - case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ + break; + case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ #line 2023 "expparse.y" -{ - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; -} + { + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + } #line 4092 "expparse.c" - break; - case 257: /* skip_statement ::= TOK_SKIP semicolon */ + break; + case 257: /* skip_statement ::= TOK_SKIP semicolon */ #line 2036 "expparse.y" -{ - yygotominor.yy332 = STATEMENT_SKIP; -} + { + yygotominor.yy332 = STATEMENT_SKIP; + } #line 4099 "expparse.c" - break; - case 258: /* statement ::= alias_statement */ - case 259: /* statement ::= assignment_statement */ yytestcase(yyruleno==259); - case 260: /* statement ::= case_statement */ yytestcase(yyruleno==260); - case 261: /* statement ::= compound_statement */ yytestcase(yyruleno==261); - case 262: /* statement ::= escape_statement */ yytestcase(yyruleno==262); - case 263: /* statement ::= if_statement */ yytestcase(yyruleno==263); - case 264: /* statement ::= proc_call_statement */ yytestcase(yyruleno==264); - case 265: /* statement ::= repeat_statement */ yytestcase(yyruleno==265); - case 266: /* statement ::= return_statement */ yytestcase(yyruleno==266); - case 267: /* statement ::= skip_statement */ yytestcase(yyruleno==267); + break; + case 258: /* statement ::= alias_statement */ + case 259: /* statement ::= assignment_statement */ + yytestcase(yyruleno == 259); + case 260: /* statement ::= case_statement */ + yytestcase(yyruleno == 260); + case 261: /* statement ::= compound_statement */ + yytestcase(yyruleno == 261); + case 262: /* statement ::= escape_statement */ + yytestcase(yyruleno == 262); + case 263: /* statement ::= if_statement */ + yytestcase(yyruleno == 263); + case 264: /* statement ::= proc_call_statement */ + yytestcase(yyruleno == 264); + case 265: /* statement ::= repeat_statement */ + yytestcase(yyruleno == 265); + case 266: /* statement ::= return_statement */ + yytestcase(yyruleno == 266); + case 267: /* statement ::= skip_statement */ + yytestcase(yyruleno == 267); #line 2041 "expparse.y" -{ - yygotominor.yy332 = yymsp[0].minor.yy332; -} + { + yygotominor.yy332 = yymsp[0].minor.yy332; + } #line 4115 "expparse.c" - break; - case 270: /* statement_rep ::= statement statement_rep */ + break; + case 270: /* statement_rep ::= statement statement_rep */ #line 2090 "expparse.y" -{ - yygotominor.yy371 = yymsp[0].minor.yy371; - LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); -} + { + yygotominor.yy371 = yymsp[0].minor.yy371; + LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); + } #line 4123 "expparse.c" - break; - case 271: /* subsuper_decl ::= */ + break; + case 271: /* subsuper_decl ::= */ #line 2100 "expparse.y" -{ - yygotominor.yy242.subtypes = EXPRESSION_NULL; - yygotominor.yy242.abstract = false; - yygotominor.yy242.supertypes = LIST_NULL; -} + { + yygotominor.yy242.subtypes = EXPRESSION_NULL; + yygotominor.yy242.abstract = false; + yygotominor.yy242.supertypes = LIST_NULL; + } #line 4132 "expparse.c" - break; - case 272: /* subsuper_decl ::= supertype_decl */ + break; + case 272: /* subsuper_decl ::= supertype_decl */ #line 2106 "expparse.y" -{ - yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; - yygotominor.yy242.supertypes = LIST_NULL; -} + { + yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; + yygotominor.yy242.supertypes = LIST_NULL; + } #line 4141 "expparse.c" - break; - case 273: /* subsuper_decl ::= subtype_decl */ + break; + case 273: /* subsuper_decl ::= subtype_decl */ #line 2112 "expparse.y" -{ - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; - yygotominor.yy242.abstract = false; - yygotominor.yy242.subtypes = EXPRESSION_NULL; -} + { + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; + yygotominor.yy242.abstract = false; + yygotominor.yy242.subtypes = EXPRESSION_NULL; + } #line 4150 "expparse.c" - break; - case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ + break; + case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ #line 2118 "expparse.y" -{ - yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; -} + { + yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; + } #line 4159 "expparse.c" - break; - case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ + break; + case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ #line 2131 "expparse.y" -{ - yygotominor.yy385.subtypes = (Expression)0; - yygotominor.yy385.abstract = true; -} + { + yygotominor.yy385.subtypes = (Expression)0; + yygotominor.yy385.abstract = true; + } #line 4167 "expparse.c" - break; - case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2137 "expparse.y" -{ - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = false; -} + { + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = false; + } #line 4175 "expparse.c" - break; - case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2143 "expparse.y" -{ - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = true; -} + { + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = true; + } #line 4183 "expparse.c" - break; - case 279: /* supertype_expression ::= supertype_factor */ + break; + case 279: /* supertype_expression ::= supertype_factor */ #line 2149 "expparse.y" -{ - yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; -} + { + yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; + } #line 4190 "expparse.c" - break; - case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ + break; + case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ #line 2153 "expparse.y" -{ - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); -} + { + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); + } #line 4197 "expparse.c" - break; - case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ + break; + case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ #line 2158 "expparse.y" -{ - yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); -} + { + yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); + } #line 4204 "expparse.c" - break; - case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ + break; + case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ #line 2169 "expparse.y" -{ - LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); - yygotominor.yy371 = yymsp[-2].minor.yy371; -} + { + LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); + yygotominor.yy371 = yymsp[-2].minor.yy371; + } #line 4212 "expparse.c" - break; - case 284: /* supertype_factor ::= identifier */ + break; + case 284: /* supertype_factor ::= identifier */ #line 2175 "expparse.y" -{ - yygotominor.yy385.subtypes = yymsp[0].minor.yy401; -} + { + yygotominor.yy385.subtypes = yymsp[0].minor.yy401; + } #line 4219 "expparse.c" - break; - case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ + break; + case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ #line 2180 "expparse.y" -{ - yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); - yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; -} + { + yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); + yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; + } #line 4227 "expparse.c" - break; - case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2185 "expparse.y" -{ - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; -} + { + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + } #line 4234 "expparse.c" - break; - case 287: /* type ::= aggregation_type */ - case 288: /* type ::= basic_type */ yytestcase(yyruleno==288); - case 290: /* type ::= select_type */ yytestcase(yyruleno==290); + break; + case 287: /* type ::= aggregation_type */ + case 288: /* type ::= basic_type */ + yytestcase(yyruleno == 288); + case 290: /* type ::= select_type */ + yytestcase(yyruleno == 290); #line 2190 "expparse.y" -{ - yygotominor.yy378.type = 0; - yygotominor.yy378.body = yymsp[0].minor.yy477; -} + { + yygotominor.yy378.type = 0; + yygotominor.yy378.body = yymsp[0].minor.yy477; + } #line 4244 "expparse.c" - break; - case 292: /* type_item_body ::= type */ + break; + case 292: /* type_item_body ::= type */ #line 2215 "expparse.y" -{ - CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; - CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; -} + { + CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; + CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; + } #line 4252 "expparse.c" - break; - case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ + break; + case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ #line 2223 "expparse.y" -{ - Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); - PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); -} + { + Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); + PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); + } #line 4260 "expparse.c" - break; - case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ + break; + case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ #line 2234 "expparse.y" -{ - CURRENT_SCOPE->where = yymsp[0].minor.yy371; - POP_SCOPE(); - yygotominor.yy0 = yymsp[-2].minor.yy0; -} + { + CURRENT_SCOPE->where = yymsp[0].minor.yy371; + POP_SCOPE(); + yygotominor.yy0 = yymsp[-2].minor.yy0; + } #line 4269 "expparse.c" - break; - case 297: /* general_ref ::= assignable group_ref */ + break; + case 297: /* general_ref ::= assignable group_ref */ #line 2241 "expparse.y" -{ - yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy401; -} + { + yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy401; + } #line 4277 "expparse.c" - break; - case 307: /* unary_expression ::= TOK_NOT unary_expression */ + break; + case 307: /* unary_expression ::= TOK_NOT unary_expression */ #line 2284 "expparse.y" -{ - yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); -} + { + yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); + } #line 4284 "expparse.c" - break; - case 309: /* unary_expression ::= TOK_MINUS unary_expression */ + break; + case 309: /* unary_expression ::= TOK_MINUS unary_expression */ #line 2292 "expparse.y" -{ - yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); -} + { + yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); + } #line 4291 "expparse.c" - break; - case 310: /* unique ::= */ + break; + case 310: /* unique ::= */ #line 2297 "expparse.y" -{ - yygotominor.yy252.unique = 0; -} + { + yygotominor.yy252.unique = 0; + } #line 4298 "expparse.c" - break; - case 311: /* unique ::= TOK_UNIQUE */ + break; + case 311: /* unique ::= TOK_UNIQUE */ #line 2301 "expparse.y" -{ - yygotominor.yy252.unique = 1; -} + { + yygotominor.yy252.unique = 1; + } #line 4305 "expparse.c" - break; - case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ + break; + case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ #line 2328 "expparse.y" -{ - LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); - yygotominor.yy371 = yymsp[-1].minor.yy371; -} + { + LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); + yygotominor.yy371 = yymsp[-1].minor.yy371; + } #line 4313 "expparse.c" - break; - case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ + break; + case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ #line 2334 "expparse.y" -{ - LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); - yygotominor.yy371 = yymsp[-1].minor.yy371; -} + { + LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); + yygotominor.yy371 = yymsp[-1].minor.yy371; + } #line 4321 "expparse.c" - break; - case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ + break; + case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ #line 2341 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); -} + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); + } #line 4329 "expparse.c" - break; - case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ + break; + case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ #line 2347 "expparse.y" -{ - LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); - yygotominor.yy371 = yymsp[-1].minor.yy371; -} + { + LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); + yygotominor.yy371 = yymsp[-1].minor.yy371; + } #line 4337 "expparse.c" - break; - case 321: /* until_control ::= */ - case 330: /* while_control ::= */ yytestcase(yyruleno==330); + break; + case 321: /* until_control ::= */ + case 330: /* while_control ::= */ + yytestcase(yyruleno == 330); #line 2362 "expparse.y" -{ - yygotominor.yy401 = 0; -} + { + yygotominor.yy401 = 0; + } #line 4345 "expparse.c" - break; - case 323: /* where_clause ::= expression semicolon */ + break; + case 323: /* where_clause ::= expression semicolon */ #line 2371 "expparse.y" -{ - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); - yygotominor.yy234->expr = yymsp[-1].minor.yy401; -} + { + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); + yygotominor.yy234->expr = yymsp[-1].minor.yy401; + } #line 4354 "expparse.c" - break; - case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ + break; + case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ #line 2377 "expparse.y" -{ - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; - yygotominor.yy234->expr = yymsp[-1].minor.yy401; - - if (!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, - yymsp[-3].minor.yy0.symbol, OBJ_WHERE); -} + { + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; + yygotominor.yy234->expr = yymsp[-1].minor.yy401; + + if(!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, + yymsp[-3].minor.yy0.symbol, OBJ_WHERE); + } #line 4370 "expparse.c" - break; - case 325: /* where_clause_list ::= where_clause */ + break; + case 325: /* where_clause_list ::= where_clause */ #line 2391 "expparse.y" -{ - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); -} + { + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); + } #line 4378 "expparse.c" - break; - case 326: /* where_clause_list ::= where_clause_list where_clause */ + break; + case 326: /* where_clause_list ::= where_clause_list where_clause */ #line 2396 "expparse.y" -{ - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); -} + { + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); + } #line 4386 "expparse.c" - break; - default: - /* (4) action_body_item_rep ::= */ yytestcase(yyruleno==4); - /* (41) block_list ::= */ yytestcase(yyruleno==41); - /* (62) constant_body_list ::= */ yytestcase(yyruleno==62); - /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno==86); - /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==159); - /* (168) interface_specification_list ::= */ yytestcase(yyruleno==168); - /* (194) local_body ::= */ yytestcase(yyruleno==194); - /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno==196); - /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno==293); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); - if( yyact < YYNSTATE ){ + break; + default: + /* (4) action_body_item_rep ::= */ + yytestcase(yyruleno == 4); + /* (41) block_list ::= */ yytestcase(yyruleno == 41); + /* (62) constant_body_list ::= */ yytestcase(yyruleno == 62); + /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno == 86); + /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno == 159); + /* (168) interface_specification_list ::= */ yytestcase(yyruleno == 168); + /* (194) local_body ::= */ yytestcase(yyruleno == 194); + /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno == 196); + /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno == 293); + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser->yyidx -= yysize; + yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto); + if(yyact < YYNSTATE) { #ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if( yysize ){ - yypParser->yyidx++; - yymsp -= yysize-1; - yymsp->stateno = (YYACTIONTYPE)yyact; - yymsp->major = (YYCODETYPE)yygoto; - yymsp->minor = yygotominor; - }else + /* If we are not debugging and the reduce action popped at least + ** one element off the stack, then we can push the new element back + ** onto the stack here, and skip the stack overflow test in yy_shift(). + ** That gives a significant speed improvement. */ + if(yysize) { + yypParser->yyidx++; + yymsp -= yysize - 1; + yymsp->stateno = (YYACTIONTYPE)yyact; + yymsp->major = (YYCODETYPE)yygoto; + yymsp->minor = yygotominor; + } else #endif - { - yy_shift(yypParser,yyact,yygoto,&yygotominor); + { + yy_shift(yypParser, yyact, yygoto, &yygotominor); + } + } else { + assert(yyact == YYNSTATE + YYNRULE + 1); + yy_accept(yypParser); } - }else{ - assert( yyact == YYNSTATE + YYNRULE + 1 ); - yy_accept(yypParser); - } } /* @@ -4428,18 +4556,21 @@ static void yy_reduce( */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +) +{ + ParseARG_FETCH; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); + } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while(yypParser->yyidx >= 0) { + yy_pop_parser_stack(yypParser); + } + /* Here code is inserted which will be executed whenever the + ** parser fails */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -4447,11 +4578,12 @@ static void yy_parse_failed( ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - ParseARG_FETCH; + yyParser *yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ +) +{ + ParseARG_FETCH; #define TOKEN (yyminor.yy0) #line 2424 "expparse.y" @@ -4465,27 +4597,30 @@ static void yy_syntax_error( sym.filename = current_filename; ERRORreport_with_symbol(SYNTAX, &sym, "Syntax error", - CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); + CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); #line 4470 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( - yyParser *yypParser /* The parser */ -){ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +) +{ + ParseARG_FETCH; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt); + } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while(yypParser->yyidx >= 0) { + yy_pop_parser_stack(yypParser); + } + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -4508,152 +4643,153 @@ static void yy_accept( ** None. */ void Parse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - ParseTOKENTYPE yyminor /* The value for the token */ - ParseARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ + void *yyp, /* The parser */ + int yymajor, /* The major token code number */ + ParseTOKENTYPE yyminor /* The value for the token */ + ParseARG_PDECL /* Optional %extra_argument parameter */ +) +{ + YYMINORTYPE yyminorunion; + int yyact; /* The parser action. */ + int yyendofinput; /* True if we are at the end of input */ #ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ + int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser; /* The parser */ + yyParser *yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ + /* (re)initialize the parser, if necessary */ + yypParser = (yyParser *)yyp; + if(yypParser->yyidx < 0) { #if YYSTACKDEPTH<=0 - if( yypParser->yystksz <=0 ){ - /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ - yyminorunion = yyzerominor; - yyStackOverflow(yypParser, &yyminorunion); - return; - } + if(yypParser->yystksz <= 0) { + /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ + yyminorunion = yyzerominor; + yyStackOverflow(yypParser, &yyminorunion); + return; + } #endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - ParseARG_STORE; + yypParser->yyidx = 0; + yypParser->yyerrcnt = -1; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor; + yyendofinput = (yymajor == 0); + ParseARG_STORE; #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor]); + } #endif - do{ - yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); - if( yyactyyerrcnt--; - yymajor = YYNOCODE; - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else{ - assert( yyact == YY_ERROR_ACTION ); + do { + yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor); + if(yyact < YYNSTATE) { + assert(!yyendofinput); /* Impossible to shift the $ token */ + yy_shift(yypParser, yyact, yymajor, &yyminorunion); + yypParser->yyerrcnt--; + yymajor = YYNOCODE; + } else if(yyact < YYNSTATE + YYNRULE) { + yy_reduce(yypParser, yyact - YYNSTATE); + } else { + assert(yyact == YY_ERROR_ACTION); #ifdef YYERRORSYMBOL - int yymx; + int yymx; #endif #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); + } #endif #ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if(yypParser->yyerrcnt < 0) { + yy_syntax_error(yypParser, yymajor, yyminorunion); + } + yymx = yypParser->yystack[yypParser->yyidx].major; + if(yymx == YYERRORSYMBOL || yyerrorhit) { #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } + if(yyTraceFILE) { + fprintf(yyTraceFILE, "%sDiscard input token %s\n", + yyTracePrompt, yyTokenName[yymajor]); + } #endif - yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; + yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); + yymajor = YYNOCODE; + } else { + while( + yypParser->yyidx >= 0 && + yymx != YYERRORSYMBOL && + (yyact = yy_find_reduce_action( + yypParser->yystack[yypParser->yyidx].stateno, + YYERRORSYMBOL)) >= YYNSTATE + ) { + yy_pop_parser_stack(yypParser); + } + if(yypParser->yyidx < 0 || yymajor == 0) { + yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); + yy_parse_failed(yypParser); + yymajor = YYNOCODE; + } else if(yymx != YYERRORSYMBOL) { + YYMINORTYPE u2; + u2.YYERRSYMDT = 0; + yy_shift(yypParser, yyact, YYERRORSYMBOL, &u2); + } + } + yypParser->yyerrcnt = 3; + yyerrorhit = 1; #elif defined(YYNOERRORRECOVERY) - /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to - ** do any kind of error recovery. Instead, simply invoke the syntax - ** error routine and continue going as if nothing had happened. - ** - ** Applications can set this macro (for example inside %include) if - ** they intend to abandon the parse upon the first syntax error seen. - */ - yy_syntax_error(yypParser,yymajor,yyminorunion); - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - + /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + yy_syntax_error(yypParser, yymajor, yyminorunion); + yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if(yypParser->yyerrcnt <= 0) { + yy_syntax_error(yypParser, yymajor, yyminorunion); + } + yypParser->yyerrcnt = 3; + yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); + if(yyendofinput) { + yy_parse_failed(yypParser); + } + yymajor = YYNOCODE; #endif - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; + } + } while(yymajor != YYNOCODE && yypParser->yyidx >= 0); + return; } diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index b78b863a5..0be5c8970 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -106,42 +106,43 @@ #include "expparse.h" #include "expscan.h" enum { INITIAL, code, comment, return_end_schema }; -extern int yylineno; -extern bool yyeof; -static int nesting_level = 0; +extern int yylineno; +extern bool yyeof; +static int nesting_level = 0; /* can't imagine this will ever be more than 2 or 3 - DEL */ #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; static_inline int -SCANnextchar(char* buffer) +SCANnextchar(char *buffer) { -extern bool SCANread(void); + extern bool SCANread(void); #ifdef keep_nul -static int escaped = 0; + static int escaped = 0; #endif -if (SCANtext_ready || SCANread()) { + if(SCANtext_ready || SCANread()) { #ifdef keep_nul -if (!*SCANcurrent) { -buffer[0] = SCAN_ESCAPE; -*SCANcurrent = '0'; -return 1; -} else if ((*SCANcurrent == SCAN_ESCAPE) && !escaped) { -escaped = 1; -buffer[0] = SCAN_ESCAPE; -return 1; -} -SCANbuffer.numRead--; + if(!*SCANcurrent) { + buffer[0] = SCAN_ESCAPE; + *SCANcurrent = '0'; + return 1; + } else if((*SCANcurrent == SCAN_ESCAPE) && !escaped) { + escaped = 1; + buffer[0] = SCAN_ESCAPE; + return 1; + } + SCANbuffer.numRead--; #endif -buffer[0] = *(SCANcurrent++); -if (!isascii(buffer[0])) { -ERRORreport_with_line(NONASCII_CHAR,yylineno, -0xff & buffer[0]); -buffer[0] = ' '; /* substitute space */ -} -return 1; -} else -return 0; + buffer[0] = *(SCANcurrent++); + if(!isascii(buffer[0])) { + ERRORreport_with_line(NONASCII_CHAR, yylineno, + 0xff & buffer[0]); + buffer[0] = ' '; /* substitute space */ + } + return 1; + } else { + return 0; + } } #define NEWLINE (yylineno++) /* when lex looks ahead over a newline, error messages get thrown off */ @@ -149,14 +150,15 @@ return 0; #define LINENO_FUDGE (yylineno - 1) /* added for re-initializing parser -snc 22-Apr-1992 */ void -SCAN_lex_init(char *filename, FILE *fp) { -/* return to initial scan buffer */ -SCAN_current_buffer = 0; -*(SCANcurrent = SCANbuffer.text) = '\0'; -SCANbuffer.readEof = false; -SCANbuffer.file = fp; -SCANbuffer.filename = (filename ? filename : ""); -current_filename = SCANbuffer.filename; +SCAN_lex_init(char *filename, FILE *fp) +{ + /* return to initial scan buffer */ + SCAN_current_buffer = 0; + *(SCANcurrent = SCANbuffer.text) = '\0'; + SCANbuffer.readEof = false; + SCANbuffer.file = fp; + SCANbuffer.filename = (filename ? filename : ""); + current_filename = SCANbuffer.filename; } #define PERPLEX_USING_CONDITIONS @@ -212,27 +214,27 @@ current_filename = SCANbuffer.filename; #include /* --- from flex's flexdef.h --- */ -void buf_init(struct Buf * buf, size_t elem_size); -void buf_destroy(struct Buf * buf); -struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem); -struct Buf *buf_concat(struct Buf* dest, const struct Buf* src); +void buf_init(struct Buf *buf, size_t elem_size); +void buf_destroy(struct Buf *buf); +struct Buf *buf_append(struct Buf *buf, const void *ptr, int n_elem); +struct Buf *buf_concat(struct Buf *dest, const struct Buf *src); struct Buf *buf_strappend(struct Buf *, const char *str); struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); -struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def); -struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); -struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val); -struct Buf *buf_m4_undefine(struct Buf *buf, const char* def); -struct Buf *buf_print_strings(struct Buf * buf, FILE* out); -struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno); +struct Buf *buf_strdefine(struct Buf *buf, const char *str, const char *def); +struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char *s); +struct Buf *buf_m4_define(struct Buf *buf, const char *def, const char *val); +struct Buf *buf_m4_undefine(struct Buf *buf, const char *def); +struct Buf *buf_print_strings(struct Buf *buf, FILE *out); +struct Buf *buf_linedir(struct Buf *buf, const char *filename, int lineno); /* --- from flex's misc.c --- */ -static void* +static void * allocate_array(int size, size_t element_size) { return malloc(element_size * size); } -static void* +static void * reallocate_array(void *array, int size, size_t element_size) { return realloc(array, element_size * size); @@ -242,17 +244,17 @@ reallocate_array(void *array, int size, size_t element_size) /* Take note: The buffer object is sometimes used as a String buffer (one * continuous string), and sometimes used as a list of strings, usually line by * line. - * + * * The type is specified in buf_init by the elt_size. If the elt_size is * sizeof(char), then the buffer should be treated as string buffer. If the * elt_size is sizeof(char*), then the buffer should be treated as a list of * strings. * - * Certain functions are only appropriate for one type or the other. + * Certain functions are only appropriate for one type or the other. */ -struct Buf* -buf_print_strings(struct Buf * buf, FILE* out) +struct Buf * +buf_print_strings(struct Buf *buf, FILE *out) { int i; @@ -260,22 +262,22 @@ buf_print_strings(struct Buf * buf, FILE* out) return buf; } - for (i = 0; i < buf->nelts; i++) { - const char *s = ((char**)buf->elts)[i]; + for(i = 0; i < buf->nelts; i++) { + const char *s = ((char **)buf->elts)[i]; if(s) { fprintf(out, "%s", s); - } + } } return buf; } /* Append a "%s" formatted string to a string buffer */ -struct Buf* +struct Buf * buf_prints(struct Buf *buf, const char *fmt, const char *s) { char *t; - t = (char*)malloc(strlen(fmt) + strlen(s) + 1); + t = (char *)malloc(strlen(fmt) + strlen(s) + 1); sprintf(t, fmt, s); buf = buf_strappend(buf, t); free(t); @@ -289,12 +291,12 @@ int numDigits(int n) /* take absolute value of n */ n = n >= 0 ? n : -n; - if (n == 0) { - return 1; + if(n == 0) { + return 1; } - for (digits = 0; n > 0; digits++) { - n /= 10; + for(digits = 0; n > 0; digits++) { + n /= 10; } return digits; @@ -306,13 +308,13 @@ int numDigits(int n) * @param lineno line number * @return buf */ -struct Buf* -buf_linedir(struct Buf *buf, const char* filename, int lineno) +struct Buf * +buf_linedir(struct Buf *buf, const char *filename, int lineno) { char *t; const char fmt[] = "#line %d \"%s\"\n"; - - t = (char*)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); + + t = (char *)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); sprintf(t, fmt, lineno, filename); buf = buf_strappend(buf, t); free(t); @@ -325,8 +327,8 @@ buf_linedir(struct Buf *buf, const char* filename, int lineno) * @param @a dest the source buffer * @return @a dest */ -struct Buf* -buf_concat(struct Buf* dest, const struct Buf* src) +struct Buf * +buf_concat(struct Buf *dest, const struct Buf *src) { buf_append(dest, src->elts, src->nelts); return dest; @@ -334,7 +336,7 @@ buf_concat(struct Buf* dest, const struct Buf* src) /* Appends n characters in str to buf. */ -struct Buf* +struct Buf * buf_strnappend(struct Buf *buf, const char *str, int n) { buf_append(buf, str, n + 1); @@ -346,14 +348,14 @@ buf_strnappend(struct Buf *buf, const char *str, int n) } /* Appends characters in str to buf. */ -struct Buf* +struct Buf * buf_strappend(struct Buf *buf, const char *str) { return buf_strnappend(buf, str, strlen(str)); } /* appends "#define str def\n" */ -struct Buf* +struct Buf * buf_strdefine(struct Buf *buf, const char *str, const char *def) { buf_strappend(buf, "#define "); @@ -371,14 +373,14 @@ buf_strdefine(struct Buf *buf, const char *str, const char *def) * @param val The definition; may be NULL. * @return buf */ -struct Buf* -buf_m4_define(struct Buf *buf, const char* def, const char* val) +struct Buf * +buf_m4_define(struct Buf *buf, const char *def, const char *val) { const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n"; char *str; val = val ? val : ""; - str = (char*)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); + str = (char *)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); sprintf(str, fmt, def, val); buf_append(buf, &str, 1); @@ -390,13 +392,13 @@ buf_m4_define(struct Buf *buf, const char* def, const char* val) * @param def The m4 symbol to undefine. * @return buf */ -struct Buf* -buf_m4_undefine(struct Buf *buf, const char* def) +struct Buf * +buf_m4_undefine(struct Buf *buf, const char *def) { const char *fmt = "m4_undefine( [[%s]])m4_dnl\n"; char *str; - str = (char*)malloc(strlen(fmt) + strlen(def) + 2); + str = (char *)malloc(strlen(fmt) + strlen(def) + 2); sprintf(str, fmt, def); buf_append(buf, &str, 1); @@ -407,7 +409,7 @@ buf_m4_undefine(struct Buf *buf, const char* def) void buf_init(struct Buf *buf, size_t elem_size) { - buf->elts = (void*)0; + buf->elts = (void *)0; buf->nelts = 0; buf->elt_size = elem_size; buf->nmax = 0; @@ -417,11 +419,12 @@ buf_init(struct Buf *buf, size_t elem_size) void buf_destroy(struct Buf *buf) { - if (buf && buf->elts) { - free(buf->elts); + if(buf && buf->elts) { + free(buf->elts); + } + if(buf) { + buf->elts = (void *)0; } - if (buf) - buf->elts = (void*)0; } /* appends ptr[] to buf, grow if necessary. @@ -429,33 +432,33 @@ buf_destroy(struct Buf *buf) * returns buf. * We grow by mod(512) boundaries. */ -struct Buf* +struct Buf * buf_append(struct Buf *buf, const void *ptr, int n_elem) { int n_alloc = 0; - if (!ptr || n_elem == 0) { - return buf; + if(!ptr || n_elem == 0) { + return buf; } /* May need to alloc more. */ - if (n_elem + buf->nelts > buf->nmax) { - /* exact amount needed... */ - n_alloc = (n_elem + buf->nelts) * buf->elt_size; - - /* ...plus some extra */ - if (((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { - n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; - } - if (!buf->elts) { - buf->elts = allocate_array(n_alloc, buf->elt_size); - } else { - buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); - } - buf->nmax = n_alloc; + if(n_elem + buf->nelts > buf->nmax) { + /* exact amount needed... */ + n_alloc = (n_elem + buf->nelts) * buf->elt_size; + + /* ...plus some extra */ + if(((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { + n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; + } + if(!buf->elts) { + buf->elts = allocate_array(n_alloc, buf->elt_size); + } else { + buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); + } + buf->nmax = n_alloc; } - memcpy((char*)buf->elts + buf->nelts * buf->elt_size, ptr, - n_elem * buf->elt_size); + memcpy((char *)buf->elts + buf->nelts * buf->elt_size, ptr, + n_elem * buf->elt_size); buf->nelts += n_elem; @@ -468,18 +471,18 @@ buf_append(struct Buf *buf, const void *ptr, int n_elem) */ /* get pointer to the start of the first element */ -static char* +static char * bufferFirstElt(struct Buf *buf) { - return (char*)buf->elts; + return (char *)buf->elts; } /* get pointer to the start of the last element */ -static char* +static char * bufferLastElt(struct Buf *buf) { - if (buf->nelts < 1) { - return NULL; + if(buf->nelts < 1) { + return NULL; } return bufferFirstElt(buf) + buf->nelts - 1; } @@ -508,7 +511,7 @@ bufferAppend(perplex_t scanner, size_t n) in = scanner->inFile; /* save marker offsets */ - bufStart = (char*)buf->elts; + bufStart = (char *)buf->elts; cursorOffset = (size_t)(scanner->cursor - bufStart); markerOffset = (size_t)(scanner->marker - bufStart); tokenStartOffset = (size_t)(scanner->tokenStart - bufStart); @@ -516,12 +519,12 @@ bufferAppend(perplex_t scanner, size_t n) /* remove last (null) element */ buf->nelts--; - for (i = 0; i < n; i++) { - if ((c = fgetc(in)) == EOF) { - scanner->atEOI = 1; - break; - } - bufferAppendChar(buf, c); + for(i = 0; i < n; i++) { + if((c = fgetc(in)) == EOF) { + scanner->atEOI = 1; + break; + } + bufferAppendChar(buf, c); } /* (scanner->null - eltSize) should be the last input element, @@ -531,7 +534,7 @@ bufferAppend(perplex_t scanner, size_t n) scanner->null = bufferLastElt(buf); /* update markers in case append caused buffer to be reallocated */ - bufStart = (char*)buf->elts; + bufStart = (char *)buf->elts; scanner->cursor = bufStart + cursorOffset; scanner->marker = bufStart + markerOffset; scanner->tokenStart = bufStart + tokenStartOffset; @@ -544,9 +547,9 @@ bufferFill(perplex_t scanner, size_t n) struct Buf *buf; size_t totalElts, usedElts, freeElts; - if (scanner->atEOI) { - /* nothing to add to buffer */ - return; + if(scanner->atEOI) { + /* nothing to add to buffer */ + return; } buf = scanner->buffer; @@ -556,53 +559,53 @@ bufferFill(perplex_t scanner, size_t n) freeElts = totalElts - usedElts; /* not enough room for append, shift buffer contents to avoid realloc */ - if (n > freeElts) { - void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; - size_t bytesInUse, shiftSize; + if(n > freeElts) { + void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; + size_t bytesInUse, shiftSize; - tokenStart = (void*)scanner->tokenStart; - marker = (void*)scanner->marker; - null = (void*)scanner->null; + tokenStart = (void *)scanner->tokenStart; + marker = (void *)scanner->marker; + null = (void *)scanner->null; - bufFirst = bufferFirstElt(buf); + bufFirst = bufferFirstElt(buf); - /* Find first buffer element still in use by scanner. Will be - * tokenStart unless backtracking marker is in use. - */ - scannerFirst = tokenStart; - if (marker >= bufFirst && marker < tokenStart) { - scannerFirst = marker; - } + /* Find first buffer element still in use by scanner. Will be + * tokenStart unless backtracking marker is in use. + */ + scannerFirst = tokenStart; + if(marker >= bufFirst && marker < tokenStart) { + scannerFirst = marker; + } - /* bytes of input being used by scanner */ - bytesInUse = (size_t)null - (size_t)scannerFirst + 1; + /* bytes of input being used by scanner */ + bytesInUse = (size_t)null - (size_t)scannerFirst + 1; - /* copy in-use elements to start of buffer */ - memmove(bufFirst, scannerFirst, bytesInUse); + /* copy in-use elements to start of buffer */ + memmove(bufFirst, scannerFirst, bytesInUse); - /* update number of elements */ + /* update number of elements */ buf->nelts = bytesInUse / buf->elt_size; - /* update markers */ - shiftSize = (size_t)scannerFirst - (size_t)bufFirst; - scanner->marker -= shiftSize; - scanner->cursor -= shiftSize; - scanner->null -= shiftSize; - scanner->tokenStart -= shiftSize; + /* update markers */ + shiftSize = (size_t)scannerFirst - (size_t)bufFirst; + scanner->marker -= shiftSize; + scanner->cursor -= shiftSize; + scanner->null -= shiftSize; + scanner->tokenStart -= shiftSize; } bufferAppend(scanner, n); } -static char* +static char * getTokenText(perplex_t scanner) { int tokenChars = scanner->cursor - scanner->tokenStart; - if (scanner->tokenText != NULL) { - free(scanner->tokenText); + if(scanner->tokenText != NULL) { + free(scanner->tokenText); } - scanner->tokenText = (char*)malloc(sizeof(char) * (tokenChars + 1)); + scanner->tokenText = (char *)malloc(sizeof(char) * (tokenChars + 1)); memcpy(scanner->tokenText, scanner->tokenStart, tokenChars); scanner->tokenText[tokenChars] = '\0'; @@ -628,7 +631,7 @@ newScanner() static void initBuffer(perplex_t scanner) { - scanner->buffer = (struct Buf*)malloc(sizeof(struct Buf)); + scanner->buffer = (struct Buf *)malloc(sizeof(struct Buf)); buf_init(scanner->buffer, sizeof(char)); } @@ -647,8 +650,8 @@ perplexStringScanner(char *firstChar, size_t numChars) buf = scanner->buffer; /* copy string to buffer */ - for (i = 0; i < numChars; i++) { - bufferAppendChar(buf, firstChar[i]); + for(i = 0; i < numChars; i++) { + bufferAppendChar(buf, firstChar[i]); } bufferAppendChar(buf, '\0'); @@ -679,9 +682,9 @@ perplexFileScanner(FILE *input) void perplexFree(perplex_t scanner) { - if (scanner->buffer != NULL) { - buf_destroy(scanner->buffer); - free(scanner->buffer); + if(scanner->buffer != NULL) { + buf_destroy(scanner->buffer); + free(scanner->buffer); } free(scanner); @@ -693,7 +696,7 @@ perplexSetExtra(perplex_t scanner, void *extra) scanner->extra = extra; } -void* +void * perplexGetExtra(perplex_t scanner) { return scanner->extra; @@ -731,8 +734,8 @@ perplexUnput(perplex_t scanner, char c) /* input from cursor to null is shifted to the right */ cursor = scanner->cursor; - for (curr = scanner->null; curr != cursor; curr--) { - curr[0] = curr[-1]; + for(curr = scanner->null; curr != cursor; curr--) { + curr[0] = curr[-1]; } /* insert c */ @@ -774,9 +777,10 @@ PERPLEX_PUBLIC_LEXER { ret = PERPLEX_LEXER_private(scanner); - if (scanner->tokenText != NULL) { - free(scanner->tokenText); - scanner->tokenText = NULL; + if(scanner->tokenText != NULL) + { + free(scanner->tokenText); + scanner->tokenText = NULL; } return ret; @@ -788,921 +792,1109 @@ PERPLEX_PRIVATE_LEXER { PERPLEX_ON_ENTER; - while (1) { - if (scanner->atEOI && scanner->cursor >= scanner->null) { - return YYEOF; - } - - { - unsigned int yyaccept = 0; - switch (YYGETCONDITION) { - case 0: goto yyc_0; - case code: goto yyc_code; - case comment: goto yyc_comment; - case return_end_schema: goto yyc_return_end_schema; - } -/* *********************************** */ + while(1) + { + if(scanner->atEOI && scanner->cursor >= scanner->null) { + return YYEOF; + } + + { + unsigned int yyaccept = 0; + switch(YYGETCONDITION) { + case 0: + goto yyc_0; + case code: + goto yyc_code; + case comment: + goto yyc_comment; + case return_end_schema: + goto yyc_return_end_schema; + } + /* *********************************** */ yyc_0: - YYSETCONDITION(code); - { -} -/* *********************************** */ + YYSETCONDITION(code); + { + } + /* *********************************** */ yyc_code: - if ((scanner->null - scanner->cursor) < 4) YYFILL(4); - yych = *scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy8; - case '\n': goto yy9; - case '"': goto yy11; - case '$': - case '&': - case '@': - case '^': - case '~': goto yy12; - case '%': goto yy14; - case '\'': goto yy15; - case '(': goto yy16; - case ')': goto yy18; - case '*': goto yy20; - case '+': goto yy22; - case ',': goto yy24; - case '-': goto yy26; - case '.': goto yy28; - case '/': goto yy30; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy32; - case ':': goto yy34; - case ';': goto yy36; - case '<': goto yy38; - case '=': goto yy40; - case '>': goto yy42; - case '?': goto yy44; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy46; - case '[': goto yy48; - case '\\': goto yy50; - case ']': goto yy52; - case '_': goto yy54; - case '{': goto yy56; - case '|': goto yy58; - case '}': goto yy60; - default: goto yy6; - } -yy5: - { -IGNORE_TOKEN; } + if((scanner->null - scanner->cursor) < 4) { + YYFILL(4); + } + yych = *scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy8; + case '\n': + goto yy9; + case '"': + goto yy11; + case '$': + case '&': + case '@': + case '^': + case '~': + goto yy12; + case '%': + goto yy14; + case '\'': + goto yy15; + case '(': + goto yy16; + case ')': + goto yy18; + case '*': + goto yy20; + case '+': + goto yy22; + case ',': + goto yy24; + case '-': + goto yy26; + case '.': + goto yy28; + case '/': + goto yy30; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy32; + case ':': + goto yy34; + case ';': + goto yy36; + case '<': + goto yy38; + case '=': + goto yy40; + case '>': + goto yy42; + case '?': + goto yy44; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + goto yy46; + case '[': + goto yy48; + case '\\': + goto yy50; + case ']': + goto yy52; + case '_': + goto yy54; + case '{': + goto yy56; + case '|': + goto yy58; + case '}': + goto yy60; + default: + goto yy6; + } +yy5: { + IGNORE_TOKEN; + } yy6: - ++scanner->cursor; -yy7: - { -IGNORE_TOKEN; } + ++scanner->cursor; +yy7: { + IGNORE_TOKEN; + } yy8: - yych = *++scanner->cursor; - goto yy127; + yych = *++scanner->cursor; + goto yy127; yy9: - ++scanner->cursor; - { -NEWLINE; -IGNORE_TOKEN; -} + ++scanner->cursor; + { + NEWLINE; + IGNORE_TOKEN; + } yy11: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy121; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy121; yy12: - ++scanner->cursor; -yy13: - { -ERRORreport_with_line(UNEXPECTED_CHARACTER,yylineno,yytext[0]); -IGNORE_TOKEN; -} + ++scanner->cursor; +yy13: { + ERRORreport_with_line(UNEXPECTED_CHARACTER, yylineno, yytext[0]); + IGNORE_TOKEN; + } yy14: - yych = *++scanner->cursor; - switch (yych) { - case '0': - case '1': goto yy117; - default: goto yy13; - } + yych = *++scanner->cursor; + switch(yych) { + case '0': + case '1': + goto yy117; + default: + goto yy13; + } yy15: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy112; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy112; yy16: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '*': goto yy109; - default: goto yy17; - } -yy17: - { -return TOK_LEFT_PAREN; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '*': + goto yy109; + default: + goto yy17; + } +yy17: { + return TOK_LEFT_PAREN; + } yy18: - ++scanner->cursor; - { -return TOK_RIGHT_PAREN; } + ++scanner->cursor; + { + return TOK_RIGHT_PAREN; + } yy20: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case ')': goto yy105; - case '*': goto yy107; - default: goto yy21; - } -yy21: - { -return TOK_TIMES; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case ')': + goto yy105; + case '*': + goto yy107; + default: + goto yy21; + } +yy21: { + return TOK_TIMES; + } yy22: - ++scanner->cursor; - { -return TOK_PLUS; } + ++scanner->cursor; + { + return TOK_PLUS; + } yy24: - ++scanner->cursor; - { -return TOK_COMMA; } + ++scanner->cursor; + { + return TOK_COMMA; + } yy26: - yyaccept = 1; - yych = *(scanner->marker = ++scanner->cursor); - switch (yych) { - case '-': goto yy101; - default: goto yy27; - } -yy27: - { -return TOK_MINUS; } + yyaccept = 1; + yych = *(scanner->marker = ++scanner->cursor); + switch(yych) { + case '-': + goto yy101; + default: + goto yy27; + } +yy27: { + return TOK_MINUS; + } yy28: - ++scanner->cursor; - { -return TOK_DOT; } + ++scanner->cursor; + { + return TOK_DOT; + } yy30: - ++scanner->cursor; - { -return TOK_REAL_DIV; } + ++scanner->cursor; + { + return TOK_REAL_DIV; + } yy32: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '.': goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy92; - default: goto yy33; - } -yy33: - { -return SCANprocess_integer_literal(yytext); -} + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '.': + goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy92; + default: + goto yy33; + } +yy33: { + return SCANprocess_integer_literal(yytext); + } yy34: - yyaccept = 2; - yych = *(scanner->marker = ++scanner->cursor); - switch (yych) { - case '<': goto yy84; - case '=': goto yy85; - default: goto yy35; - } -yy35: - { -return TOK_COLON; } + yyaccept = 2; + yych = *(scanner->marker = ++scanner->cursor); + switch(yych) { + case '<': + goto yy84; + case '=': + goto yy85; + default: + goto yy35; + } +yy35: { + return TOK_COLON; + } yy36: - yyaccept = 3; - yych = *(scanner->marker = ++scanner->cursor); - switch (yych) { - case '\t': - case ' ': goto yy76; - case '-': goto yy79; - default: goto yy37; - } -yy37: - { -return SCANprocess_semicolon(yytext, 0); } + yyaccept = 3; + yych = *(scanner->marker = ++scanner->cursor); + switch(yych) { + case '\t': + case ' ': + goto yy76; + case '-': + goto yy79; + default: + goto yy37; + } +yy37: { + return SCANprocess_semicolon(yytext, 0); + } yy38: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '*': goto yy74; - case '=': goto yy72; - case '>': goto yy70; - default: goto yy39; - } -yy39: - { -return TOK_LESS_THAN; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '*': + goto yy74; + case '=': + goto yy72; + case '>': + goto yy70; + default: + goto yy39; + } +yy39: { + return TOK_LESS_THAN; + } yy40: - ++scanner->cursor; - { -return TOK_EQUAL; } + ++scanner->cursor; + { + return TOK_EQUAL; + } yy42: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '=': goto yy68; - default: goto yy43; - } -yy43: - { -return TOK_GREATER_THAN; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '=': + goto yy68; + default: + goto yy43; + } +yy43: { + return TOK_GREATER_THAN; + } yy44: - ++scanner->cursor; - { -return TOK_QUESTION_MARK; } + ++scanner->cursor; + { + return TOK_QUESTION_MARK; + } yy46: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy67; -yy47: - { -return SCANprocess_identifier_or_keyword(yytext); -} + ++scanner->cursor; + yych = *scanner->cursor; + goto yy67; +yy47: { + return SCANprocess_identifier_or_keyword(yytext); + } yy48: - ++scanner->cursor; - { -return TOK_LEFT_BRACKET; } + ++scanner->cursor; + { + return TOK_LEFT_BRACKET; + } yy50: - ++scanner->cursor; - { -return TOK_BACKSLASH; } + ++scanner->cursor; + { + return TOK_BACKSLASH; + } yy52: - ++scanner->cursor; - { -return TOK_RIGHT_BRACKET; } + ++scanner->cursor; + { + return TOK_RIGHT_BRACKET; + } yy54: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy65; -yy55: - { -ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); -return SCANprocess_identifier_or_keyword(yytext); -} + ++scanner->cursor; + yych = *scanner->cursor; + goto yy65; +yy55: { + ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); + return SCANprocess_identifier_or_keyword(yytext); + } yy56: - ++scanner->cursor; - { -return TOK_LEFT_CURL; } + ++scanner->cursor; + { + return TOK_LEFT_CURL; + } yy58: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '|': goto yy62; - default: goto yy59; - } -yy59: - { -return TOK_SUCH_THAT; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '|': + goto yy62; + default: + goto yy59; + } +yy59: { + return TOK_SUCH_THAT; + } yy60: - ++scanner->cursor; - { -return TOK_RIGHT_CURL; } + ++scanner->cursor; + { + return TOK_RIGHT_CURL; + } yy62: - ++scanner->cursor; - { -return TOK_CONCAT_OP; } + ++scanner->cursor; + { + return TOK_CONCAT_OP; + } yy64: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy65: - switch (yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy64; - default: goto yy55; - } + switch(yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + goto yy64; + default: + goto yy55; + } yy66: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy67: - switch (yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy66; - default: goto yy47; - } + switch(yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + goto yy66; + default: + goto yy47; + } yy68: - ++scanner->cursor; - { -return TOK_GREATER_EQUAL; } + ++scanner->cursor; + { + return TOK_GREATER_EQUAL; + } yy70: - ++scanner->cursor; - { -return TOK_NOT_EQUAL; } + ++scanner->cursor; + { + return TOK_NOT_EQUAL; + } yy72: - ++scanner->cursor; - { -return TOK_LESS_EQUAL; } + ++scanner->cursor; + { + return TOK_LESS_EQUAL; + } yy74: - ++scanner->cursor; - { -return TOK_ALL_IN; } + ++scanner->cursor; + { + return TOK_ALL_IN; + } yy76: - ++scanner->cursor; - if ((scanner->null - scanner->cursor) < 2) YYFILL(2); - yych = *scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy76; - case '-': goto yy79; - default: goto yy78; - } + ++scanner->cursor; + if((scanner->null - scanner->cursor) < 2) { + YYFILL(2); + } + yych = *scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy76; + case '-': + goto yy79; + default: + goto yy78; + } yy78: - scanner->cursor = scanner->marker; - switch (yyaccept) { - case 0: goto yy7; - case 1: goto yy27; - case 2: goto yy35; - case 3: goto yy37; - case 4: goto yy96; - case 5: goto yy114; - } + scanner->cursor = scanner->marker; + switch(yyaccept) { + case 0: + goto yy7; + case 1: + goto yy27; + case 2: + goto yy35; + case 3: + goto yy37; + case 4: + goto yy96; + case 5: + goto yy114; + } yy79: - yych = *++scanner->cursor; - switch (yych) { - case '-': goto yy80; - default: goto yy78; - } + yych = *++scanner->cursor; + switch(yych) { + case '-': + goto yy80; + default: + goto yy78; + } yy80: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '\n': goto yy82; - default: goto yy80; - } + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '\n': + goto yy82; + default: + goto yy80; + } yy82: - ++scanner->cursor; - { -NEWLINE; -return SCANprocess_semicolon(yytext, 1); -} + ++scanner->cursor; + { + NEWLINE; + return SCANprocess_semicolon(yytext, 1); + } yy84: - yych = *++scanner->cursor; - switch (yych) { - case '>': goto yy89; - default: goto yy78; - } + yych = *++scanner->cursor; + switch(yych) { + case '>': + goto yy89; + default: + goto yy78; + } yy85: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case ':': goto yy87; - default: goto yy86; - } -yy86: - { -return TOK_ASSIGNMENT; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case ':': + goto yy87; + default: + goto yy86; + } +yy86: { + return TOK_ASSIGNMENT; + } yy87: - ++scanner->cursor; - { -return TOK_INST_EQUAL; } + ++scanner->cursor; + { + return TOK_INST_EQUAL; + } yy89: - yych = *++scanner->cursor; - switch (yych) { - case ':': goto yy90; - default: goto yy78; - } + yych = *++scanner->cursor; + switch(yych) { + case ':': + goto yy90; + default: + goto yy78; + } yy90: - ++scanner->cursor; - { -return TOK_INST_NOT_EQUAL; } + ++scanner->cursor; + { + return TOK_INST_NOT_EQUAL; + } yy92: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '.': goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy92; - default: goto yy33; - } + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '.': + goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy92; + default: + goto yy33; + } yy94: - yyaccept = 4; - scanner->marker = ++scanner->cursor; - if ((scanner->null - scanner->cursor) < 3) YYFILL(3); - yych = *scanner->cursor; - switch (yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy94; - case 'E': - case 'e': goto yy97; - default: goto yy96; - } -yy96: - { -return SCANprocess_real_literal(yytext); -} + yyaccept = 4; + scanner->marker = ++scanner->cursor; + if((scanner->null - scanner->cursor) < 3) { + YYFILL(3); + } + yych = *scanner->cursor; + switch(yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy94; + case 'E': + case 'e': + goto yy97; + default: + goto yy96; + } +yy96: { + return SCANprocess_real_literal(yytext); + } yy97: - yych = *++scanner->cursor; - switch (yych) { - case '+': - case '-': goto yy98; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy99; - default: goto yy78; - } + yych = *++scanner->cursor; + switch(yych) { + case '+': + case '-': + goto yy98; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy99; + default: + goto yy78; + } yy98: - yych = *++scanner->cursor; - switch (yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy99; - default: goto yy78; - } + yych = *++scanner->cursor; + switch(yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy99; + default: + goto yy78; + } yy99: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy99; - default: goto yy96; - } + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + goto yy99; + default: + goto yy96; + } yy101: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '\n': goto yy103; - default: goto yy101; - } + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '\n': + goto yy103; + default: + goto yy101; + } yy103: - ++scanner->cursor; - { -NEWLINE; -SCANsave_comment(yytext); -IGNORE_TOKEN; -} + ++scanner->cursor; + { + NEWLINE; + SCANsave_comment(yytext); + IGNORE_TOKEN; + } yy105: - ++scanner->cursor; - { -ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); -IGNORE_TOKEN; -} + ++scanner->cursor; + { + ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); + IGNORE_TOKEN; + } yy107: - ++scanner->cursor; - { -return TOK_EXP; } + ++scanner->cursor; + { + return TOK_EXP; + } yy109: - ++scanner->cursor; - YYSETCONDITION(comment); - { -if (nesting_level cursor; + YYSETCONDITION(comment); + { + if(nesting_level < MAX_NESTED_COMMENTS) { + open_comment[nesting_level].line = yylineno; + open_comment[nesting_level].filename = current_filename; + } + nesting_level++; + IGNORE_TOKEN; + } yy111: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy112: - switch (yych) { - case '\n': goto yy115; - case '\'': goto yy113; - default: goto yy111; - } + switch(yych) { + case '\n': + goto yy115; + case '\'': + goto yy113; + default: + goto yy111; + } yy113: - yyaccept = 5; - scanner->marker = ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '\'': goto yy111; - default: goto yy114; - } -yy114: - { -return SCANprocess_string(yytext); -} + yyaccept = 5; + scanner->marker = ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '\'': + goto yy111; + default: + goto yy114; + } +yy114: { + return SCANprocess_string(yytext); + } yy115: - ++scanner->cursor; - { -ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); -NEWLINE; -return SCANprocess_string(yytext); -} + ++scanner->cursor; + { + ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); + NEWLINE; + return SCANprocess_string(yytext); + } yy117: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '0': - case '1': goto yy117; - default: goto yy119; - } -yy119: - { -return SCANprocess_binary_literal(yytext); -} + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '0': + case '1': + goto yy117; + default: + goto yy119; + } +yy119: { + return SCANprocess_binary_literal(yytext); + } yy120: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy121: - switch (yych) { - case '\n': goto yy122; - case '"': goto yy124; - default: goto yy120; - } + switch(yych) { + case '\n': + goto yy122; + case '"': + goto yy124; + default: + goto yy120; + } yy122: - ++scanner->cursor; - { -ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); -NEWLINE; -return SCANprocess_encoded_string(yytext); -} + ++scanner->cursor; + { + ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); + NEWLINE; + return SCANprocess_encoded_string(yytext); + } yy124: - ++scanner->cursor; - { -return SCANprocess_encoded_string(yytext); -} + ++scanner->cursor; + { + return SCANprocess_encoded_string(yytext); + } yy126: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy127: - switch (yych) { - case '\t': - case ' ': goto yy126; - default: goto yy5; - } -/* *********************************** */ + switch(yych) { + case '\t': + case ' ': + goto yy126; + default: + goto yy5; + } + /* *********************************** */ yyc_comment: - if ((scanner->null - scanner->cursor) < 2) YYFILL(2); - yych = *scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy132; - case '\n': goto yy133; - case '(': goto yy135; - case ')': goto yy137; - case '*': goto yy138; - default: goto yy131; - } -yy130: - { -IGNORE_TOKEN; } + if((scanner->null - scanner->cursor) < 2) { + YYFILL(2); + } + yych = *scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy132; + case '\n': + goto yy133; + case '(': + goto yy135; + case ')': + goto yy137; + case '*': + goto yy138; + default: + goto yy131; + } +yy130: { + IGNORE_TOKEN; + } yy131: - yych = *++scanner->cursor; - goto yy144; + yych = *++scanner->cursor; + goto yy144; yy132: - yych = *++scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy145; - default: goto yy144; - } + yych = *++scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy145; + default: + goto yy144; + } yy133: - ++scanner->cursor; - { -NEWLINE; -IGNORE_TOKEN; -} + ++scanner->cursor; + { + NEWLINE; + IGNORE_TOKEN; + } yy135: - ++scanner->cursor; - switch ((yych = *scanner->cursor)) { - case '*': goto yy141; - default: goto yy136; - } -yy136: - { -IGNORE_TOKEN; } + ++scanner->cursor; + switch((yych = *scanner->cursor)) { + case '*': + goto yy141; + default: + goto yy136; + } +yy136: { + IGNORE_TOKEN; + } yy137: - yych = *++scanner->cursor; - goto yy136; + yych = *++scanner->cursor; + goto yy136; yy138: - yych = *++scanner->cursor; - switch (yych) { - case ')': goto yy139; - default: goto yy136; - } + yych = *++scanner->cursor; + switch(yych) { + case ')': + goto yy139; + default: + goto yy136; + } yy139: - ++scanner->cursor; - { -if (0 == --nesting_level) { -YYSETCONDITION(code); -} -IGNORE_TOKEN; -} + ++scanner->cursor; + { + if(0 == --nesting_level) { + YYSETCONDITION(code); + } + IGNORE_TOKEN; + } yy141: - ++scanner->cursor; - { -if (nesting_level cursor; + { + if(nesting_level < MAX_NESTED_COMMENTS) { + open_comment[nesting_level].line = yylineno; + open_comment[nesting_level].filename = current_filename; + } + nesting_level++; + IGNORE_TOKEN; + } yy143: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy144: - switch (yych) { - case '\n': - case '(': - case ')': - case '*': goto yy130; - default: goto yy143; - } + switch(yych) { + case '\n': + case '(': + case ')': + case '*': + goto yy130; + default: + goto yy143; + } yy145: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy145; - case '\n': - case '(': - case ')': - case '*': goto yy130; - default: goto yy143; - } -/* *********************************** */ + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy145; + case '\n': + case '(': + case ')': + case '*': + goto yy130; + default: + goto yy143; + } + /* *********************************** */ yyc_return_end_schema: - if ((scanner->null - scanner->cursor) < 2) YYFILL(2); - yych = *scanner->cursor; - switch (yych) { - case '\t': - case ' ': goto yy152; - case '\n': goto yy153; - case '(': goto yy155; - case 'X': - case 'x': goto yy156; - default: goto yy150; - } -yy149: - { -IGNORE_TOKEN; } + if((scanner->null - scanner->cursor) < 2) { + YYFILL(2); + } + yych = *scanner->cursor; + switch(yych) { + case '\t': + case ' ': + goto yy152; + case '\n': + goto yy153; + case '(': + goto yy155; + case 'X': + case 'x': + goto yy156; + default: + goto yy150; + } +yy149: { + IGNORE_TOKEN; + } yy150: - ++scanner->cursor; -yy151: - { -IGNORE_TOKEN; } + ++scanner->cursor; +yy151: { + IGNORE_TOKEN; + } yy152: - yych = *++scanner->cursor; - goto yy161; + yych = *++scanner->cursor; + goto yy161; yy153: - ++scanner->cursor; - { -NEWLINE; -IGNORE_TOKEN; -} + ++scanner->cursor; + { + NEWLINE; + IGNORE_TOKEN; + } yy155: - yych = *++scanner->cursor; - switch (yych) { - case '*': goto yy158; - default: goto yy151; - } + yych = *++scanner->cursor; + switch(yych) { + case '*': + goto yy158; + default: + goto yy151; + } yy156: - ++scanner->cursor; - YYSETCONDITION(code); - { -return TOK_END_SCHEMA; -} + ++scanner->cursor; + YYSETCONDITION(code); + { + return TOK_END_SCHEMA; + } yy158: - ++scanner->cursor; - YYSETCONDITION(comment); - { -if (nesting_level cursor; + YYSETCONDITION(comment); + { + if(nesting_level < MAX_NESTED_COMMENTS) { + open_comment[nesting_level].line = yylineno; + open_comment[nesting_level].filename = current_filename; + } + nesting_level++; + IGNORE_TOKEN; + } yy160: - ++scanner->cursor; - if (scanner->null <= scanner->cursor) YYFILL(1); - yych = *scanner->cursor; + ++scanner->cursor; + if(scanner->null <= scanner->cursor) { + YYFILL(1); + } + yych = *scanner->cursor; yy161: - switch (yych) { - case '\t': - case ' ': goto yy160; - default: goto yy149; - } - } + switch(yych) { + case '\t': + case ' ': + goto yy160; + default: + goto yy149; + } + } } } @@ -1711,7 +1903,7 @@ IGNORE_TOKEN; void SCANskip_to_end_schema(perplex_t scanner) { -while (yylex(scanner) != TOK_END_SCHEMA); -perplexUnput(scanner, 'X'); /* any old character */ -YYSETCONDITION(return_end_schema); + while(yylex(scanner) != TOK_END_SCHEMA); + perplexUnput(scanner, 'X'); /* any old character */ + YYSETCONDITION(return_end_schema); } diff --git a/src/express/generated/expscan.h b/src/express/generated/expscan.h index a9e6705cf..7b0ccb3a6 100644 --- a/src/express/generated/expscan.h +++ b/src/express/generated/expscan.h @@ -56,10 +56,10 @@ #define YYEOF -1 struct Buf { - void *elts; /* elements. */ - int nelts; /* number of elements. */ - size_t elt_size; /* in bytes. */ - int nmax; /* max capacity of elements. */ + void *elts; /* elements. */ + int nelts; /* number of elements. */ + size_t elt_size; /* in bytes. */ + int nmax; /* max capacity of elements. */ }; /* scanner data */ @@ -82,7 +82,7 @@ void perplexFree(perplex_t scanner); void perplexUnput(perplex_t scanner, char c); void perplexSetExtra(perplex_t scanner, void *extra); -void* perplexGetExtra(perplex_t scanner); +void *perplexGetExtra(perplex_t scanner); #ifndef PERPLEX_LEXER #define PERPLEX_LEXER yylex diff --git a/src/express/hash.c b/src/express/hash.c index 5556ade92..eeb073a8a 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -116,8 +116,8 @@ ** Internal routines */ -static inline Address HASHhash( char *, Hash_Table ); -static void HASHexpand_table( Hash_Table ); +static inline Address HASHhash(char *, Hash_Table); +static void HASHexpand_table(Hash_Table); /* ** Local data @@ -132,11 +132,13 @@ static long HashAccesses, HashCollisions; */ void -HASHinitialize() { +HASHinitialize() +{ } Hash_Table -HASHcreate( unsigned count ) { +HASHcreate(unsigned count) +{ unsigned i; Hash_Table table; @@ -145,10 +147,10 @@ HASHcreate( unsigned count ) { ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while( i < count ) { + while(i < count) { i <<= 1; } - count = DIV( i, SEGMENT_SIZE_SHIFT ); + count = DIV(i, SEGMENT_SIZE_SHIFT); table = HASH_Table_new(); #if 0 @@ -158,32 +160,33 @@ HASHcreate( unsigned count ) { /* ** Allocate initial 'i' segments of buckets */ - for( i = 0; i < count; i++ ) - CALLOC( table->Directory[i], SEGMENT_SIZE, Element ) + for(i = 0; i < count; i++) + CALLOC(table->Directory[i], SEGMENT_SIZE, Element) /*, "segment in HASHcreate");*/ table->SegmentCount = count; - table->maxp = MUL( count, SEGMENT_SIZE_SHIFT ); + table->maxp = MUL(count, SEGMENT_SIZE_SHIFT); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef HASH_DEBUG - fprintf( stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount ); + fprintf(stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return( table ); + return(table); } /* initialize pointer to beginning of hash table so we can step through it */ /* on repeated calls to HASHlist - DEL */ void -HASHlistinit( Hash_Table table, HashEntry * he ) { +HASHlistinit(Hash_Table table, HashEntry *he) +{ he->i = he->j = 0; he->p = 0; he->table = table; @@ -194,7 +197,8 @@ HASHlistinit( Hash_Table table, HashEntry * he ) { } void -HASHlistinit_by_type( Hash_Table table, HashEntry * he, char type ) { +HASHlistinit_by_type(Hash_Table table, HashEntry *he, char type) +{ he->i = he->j = 0; he->p = 0; he->table = table; @@ -207,25 +211,27 @@ HASHlistinit_by_type( Hash_Table table, HashEntry * he, char type ) { #if 0 /* if you don't step to the end, you can clear the flag this way */ void -HASHlistend( HashEntry * he ) { +HASHlistend(HashEntry *he) +{ he->table->in_use = 0; } #endif /* provide a way to step through the hash */ Element -HASHlist( HashEntry * he ) { +HASHlist(HashEntry *he) +{ int i2 = he->i; int j2 = he->j; Segment s; he->e = 0; - for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { + for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { /* test probably unnecessary */ - if( ( s = he->table->Directory[he->i] ) != NULL ) { - for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { - if( !he->p ) { + if((s = he->table->Directory[he->i]) != NULL) { + for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { + if(!he->p) { he->p = s[he->j]; } @@ -234,22 +240,22 @@ HASHlist( HashEntry * he ) { for he->p */ retry: - if( he->p ) { - if( ( he->type != '*' ) && - ( he->type != he->p->type ) ) { + if(he->p) { + if((he->type != '*') && + (he->type != he->p->type)) { he->p = he->p->next; goto retry; } - if( he->e ) { - return( he->e ); + if(he->e) { + return(he->e); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if( he->p ) { - return( he->e ); + if(he->p) { + return(he->e); } } j2 = 0; @@ -259,55 +265,58 @@ HASHlist( HashEntry * he ) { #if 0 he->table->in_use = 0; #endif - return( he->e ); + return(he->e); } #if 0 /* this verifies no one else is walking through the table that we might screw up */ /* it should be called before adding, deleting or destroying a table */ -HASH_in_use( Hash_Table table, char * action ) { - fprintf( stderr, "HASH: attempted to %s but hash table in use\n", action ); +HASH_in_use(Hash_Table table, char *action) +{ + fprintf(stderr, "HASH: attempted to %s but hash table in use\n", action); } #endif void -HASHdestroy( Hash_Table table ) { +HASHdestroy(Hash_Table table) +{ Segment s; Element p, q; - if( table != HASH_NULL ) { + if(table != HASH_NULL) { unsigned int i, j; #if 0 - if( table->in_use ) { - HASH_in_use( table, "destroy hash table" ); + if(table->in_use) { + HASH_in_use(table, "destroy hash table"); } #endif - for( i = 0; i < table->SegmentCount; i++ ) { + for(i = 0; i < table->SegmentCount; i++) { /* test probably unnecessary */ - if( ( s = table->Directory[i] ) != NULL ) { - for( j = 0; j < SEGMENT_SIZE; j++ ) { + if((s = table->Directory[i]) != NULL) { + for(j = 0; j < SEGMENT_SIZE; j++) { p = s[j]; - while( p != NULL ) { + while(p != NULL) { q = p->next; - HASH_Element_destroy( p ); + HASH_Element_destroy(p); p = q; } } - sc_free( table->Directory[i] ); + sc_free(table->Directory[i]); } } - HASH_Table_destroy( table ); + HASH_Table_destroy(table); # if defined(HASH_STATISTICS) && defined(HASH_DEBUG) - fprintf( stderr, - "[hdestroy] Accesses %ld Collisions %ld\n", - HashAccesses, - HashCollisions ); + fprintf(stderr, + "[hdestroy] Accesses %ld Collisions %ld\n", + HashAccesses, + HashCollisions); # endif } } Element -HASHsearch( Hash_Table table, Element item, Action action ) { +HASHsearch(Hash_Table table, Element item, Action action) +{ Address h; Segment CurrentSegment; int SegmentIndex; @@ -316,18 +325,18 @@ HASHsearch( Hash_Table table, Element item, Action action ) { Element q; Element deleteme; - assert( table != HASH_NULL ); /* Kinder really than return(NULL); */ + assert(table != HASH_NULL); /* Kinder really than return(NULL); */ # ifdef HASH_STATISTICS HashAccesses++; # endif - h = HASHhash( item->key, table ); - SegmentDir = DIV( h, SEGMENT_SIZE_SHIFT ); - SegmentIndex = MOD( h, SEGMENT_SIZE ); + h = HASHhash(item->key, table); + SegmentDir = DIV(h, SEGMENT_SIZE_SHIFT); + SegmentIndex = MOD(h, SEGMENT_SIZE); /* ** valid segment ensured by HASHhash() */ CurrentSegment = table->Directory[SegmentDir]; - assert( CurrentSegment != NULL ); /* bad failure if tripped */ + assert(CurrentSegment != NULL); /* bad failure if tripped */ p = CurrentSegment + SegmentIndex; q = *p; /* @@ -336,7 +345,7 @@ HASHsearch( Hash_Table table, Element item, Action action ) { ** p = &element, and ** q = element */ - while( q != NULL && strcmp( q->key, item->key ) ) { + while(q != NULL && strcmp(q->key, item->key)) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -344,34 +353,34 @@ HASHsearch( Hash_Table table, Element item, Action action ) { # endif } /* at this point, we have either found the element or it doesn't exist */ - switch( action ) { + switch(action) { case HASH_FIND: - return( ( Element )q ); + return((Element)q); case HASH_DELETE: - if( !q ) { - return( 0 ); + if(!q) { + return(0); } /* at this point, element exists and action == DELETE */ #if 0 - if( table->in_use ) { - HASH_in_use( table, "insert element" ); + if(table->in_use) { + HASH_in_use(table, "insert element"); } #endif deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - HASH_Element_destroy( deleteme ); + HASH_Element_destroy(deleteme); --table->KeyCount; - return( deleteme ); /* of course, user shouldn't deref this! */ + return(deleteme); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if( q != NULL ) { - return( q ); /* was return(0);!!!!!?!?! */ + if(q != NULL) { + return(q); /* was return(0);!!!!!?!?! */ } #if 0 - if( table->in_use ) { - HASH_in_use( table, "delete element" ); + if(table->in_use) { + HASH_in_use(table, "delete element"); } #endif /* at this point, element does not exist and action == INSERT */ @@ -390,61 +399,63 @@ HASHsearch( Hash_Table table, Element item, Action action ) { /* ** table over-full? */ - if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE_SHIFT ) > table->MaxLoadFactor ) { - HASHexpand_table( table ); /* doesn't affect q */ + if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE_SHIFT) > table->MaxLoadFactor) { + HASHexpand_table(table); /* doesn't affect q */ } } - return( ( Element )0 ); /* was return (Element)q */ + return((Element)0); /* was return (Element)q */ } /* ** Internal routines */ -static inline Address HASHhash( char * Key, Hash_Table table ) { +static inline Address HASHhash(char *Key, Hash_Table table) +{ Address h, address; - register unsigned char * k = ( unsigned char * )Key; + register unsigned char *k = (unsigned char *)Key; h = 0; /* ** Convert string to integer */ /*SUPPRESS 112*/ - assert( Key ); - while( *k ) + assert(Key); + while(*k) /*SUPPRESS 8*/ { /*SUPPRESS 112*/ - h = h * PRIME1 ^ ( *k++ - ' ' ); + h = h * PRIME1 ^ (*k++ - ' '); } h %= PRIME2; - address = MOD( h, table->maxp ); - if( address < table->p ) { - address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ + address = MOD(h, table->maxp); + if(address < table->p) { + address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ } - return( address ); + return(address); } -static void HASHexpand_table( Hash_Table table ) { +static void HASHexpand_table(Hash_Table table) +{ Segment OldSegment, NewSegment; Element Current, *Previous, *LastOfNew; - if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT ) ) { + if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT)) { Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; /* ** Locate the bucket to be split */ - OldSegmentDir = DIV( table->p, SEGMENT_SIZE_SHIFT ); + OldSegmentDir = DIV(table->p, SEGMENT_SIZE_SHIFT); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); + OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = DIV( NewAddress, SEGMENT_SIZE_SHIFT ); - NewSegmentIndex = MOD( NewAddress, SEGMENT_SIZE ); - if( NewSegmentIndex == 0 ) { - CALLOC( table->Directory[NewSegmentDir], SEGMENT_SIZE, Element ); + NewSegmentDir = DIV(NewAddress, SEGMENT_SIZE_SHIFT); + NewSegmentIndex = MOD(NewAddress, SEGMENT_SIZE); + if(NewSegmentIndex == 0) { + CALLOC(table->Directory[NewSegmentDir], SEGMENT_SIZE, Element); } /* "segment in HASHexpand_table");*/ NewSegment = table->Directory[NewSegmentDir]; @@ -452,7 +463,7 @@ static void HASHexpand_table( Hash_Table table ) { ** Adjust state variables */ table->p++; - if( table->p == table->maxp ) { + if(table->p == table->maxp) { table->maxp <<= 1; /* table->maxp *= 2 */ table->p = 0; } @@ -464,8 +475,8 @@ static void HASHexpand_table( Hash_Table table ) { Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while( Current != NULL ) { - if( HASHhash( Current->key, table ) == NewAddress ) { + while(Current != NULL) { + if(HASHhash(Current->key, table) == NewAddress) { /* ** Attach it to the end of the new chain */ @@ -493,16 +504,17 @@ static void HASHexpand_table( Hash_Table table ) { /* But then, it isn't called when objects are inserted/deleted so this seems */ /* reasonable - DEL */ Hash_Table -HASHcopy( Hash_Table oldtable ) { +HASHcopy(Hash_Table oldtable) +{ Hash_Table newtable; Segment s, s2; - Element * pp; /* old element */ - Element * qq; /* new element */ + Element *pp; /* old element */ + Element *qq; /* new element */ unsigned int i, j; newtable = HASH_Table_new(); - for( i = 0; i < oldtable->SegmentCount; i++ ) { - CALLOC( newtable->Directory[i], SEGMENT_SIZE, Element ); + for(i = 0; i < oldtable->SegmentCount; i++) { + CALLOC(newtable->Directory[i], SEGMENT_SIZE, Element); /* "segment in HASHcopy");*/ } @@ -513,54 +525,55 @@ HASHcopy( Hash_Table oldtable ) { newtable->MaxLoadFactor = oldtable->MaxLoadFactor; newtable->KeyCount = oldtable->KeyCount; - for( i = 0; i < oldtable->SegmentCount; i++ ) { + for(i = 0; i < oldtable->SegmentCount; i++) { /* test probably unnecessary */ - if( ( s = oldtable->Directory[i] ) != NULL ) { + if((s = oldtable->Directory[i]) != NULL) { s2 = newtable->Directory[i]; - for( j = 0; j < SEGMENT_SIZE; j++ ) { + for(j = 0; j < SEGMENT_SIZE; j++) { qq = &s2[j]; - for( pp = &s[j]; *pp; pp = &( *pp )->next ) { + for(pp = &s[j]; *pp; pp = &(*pp)->next) { *qq = HASH_Element_new(); /* (*qq)->key = STRINGcopy((*pp)->key);*/ /* I really doubt it is necessary to copy the key!!! */ - ( *qq )->key = ( *pp )->key; - ( *qq )->data = ( *pp )->data; - ( *qq )->symbol = ( *pp )->symbol; - ( *qq )->type = ( *pp )->type; - ( *qq )->next = NULL; - qq = &( ( *qq )->next ); + (*qq)->key = (*pp)->key; + (*qq)->data = (*pp)->data; + (*qq)->symbol = (*pp)->symbol; + (*qq)->type = (*pp)->type; + (*qq)->next = NULL; + qq = &((*qq)->next); } } } } - return( newtable ); + return(newtable); } /* following code is for testing hash package */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table * t; +struct Hash_Table *t; HashEntry he; -main() { +main() +{ e1.key = "foo"; - e1.data = ( char * )1; + e1.data = (char *)1; e2.key = "bar"; - e2.data = ( char * )2; + e2.data = (char *)2; e3.key = "herschel"; - e3.data = ( char * )3; - - t = HASHcreate( 100 ); - e = HASHsearch( t, &e1, HASH_INSERT ); - e = HASHsearch( t, &e2, HASH_INSERT ); - e = HASHsearch( t, &e3, HASH_INSERT ); - HASHlistinit( t, &he ); - for( ;; ) { - e = HASHlist( &he ); - if( !e ) { - exit( 0 ); + e3.data = (char *)3; + + t = HASHcreate(100); + e = HASHsearch(t, &e1, HASH_INSERT); + e = HASHsearch(t, &e2, HASH_INSERT); + e = HASHsearch(t, &e3, HASH_INSERT); + HASHlistinit(t, &he); + for(;;) { + e = HASHlist(&he); + if(!e) { + exit(0); } - fprintf( stderr, "found key %s, data %d\n", e->key, ( int )e->data ); + fprintf(stderr, "found key %s, data %d\n", e->key, (int)e->data); } } #endif diff --git a/src/express/info.c b/src/express/info.c index 50af7ab11..da8788ef7 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -7,37 +7,39 @@ #ifndef SCHEMA_SCANNER # include "sc_version_string.h" #else - /* dummy string to make the compiler happy when building the schema scanner, - * should never be seen by users */ - const char * sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; +/* dummy string to make the compiler happy when building the schema scanner, + * should never be seen by users */ +const char *sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; #endif -char * EXPRESSversion( void ) { - return( "Express Language, IS (N65), October 24, 1994" ); +char *EXPRESSversion(void) +{ + return("Express Language, IS (N65), October 24, 1994"); } -void EXPRESSusage( int _exit ) { - fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); - fprintf( stderr, "where\t-v produces the following version description:\n" ); - fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version ); - fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); - fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); - fprintf( stderr, "\t-w warning enable\n" ); - fprintf( stderr, "\t-i warning ignore\n" ); - fprintf( stderr, "and is one of:\n" ); - fprintf( stderr, "\tnone\n\tall\n" ); - fprintf( stderr, ERRORget_warnings_help("\t", "\n") ); - fprintf( stderr, "and is one or more of:\n" ); - fprintf( stderr, " e entity\n" ); - fprintf( stderr, " p procedure\n" ); - fprintf( stderr, " r rule\n" ); - fprintf( stderr, " f function\n" ); - fprintf( stderr, " t type\n" ); - fprintf( stderr, " s schema or file\n" ); - fprintf( stderr, " # pass #\n" ); - fprintf( stderr, " E everything (all of the above)\n" ); - if( _exit ) { - exit( 2 ); +void EXPRESSusage(int _exit) +{ + fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); + fprintf(stderr, "where\t-v produces the following version description:\n"); + fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version); + fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); + fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); + fprintf(stderr, "\t-w warning enable\n"); + fprintf(stderr, "\t-i warning ignore\n"); + fprintf(stderr, "and is one of:\n"); + fprintf(stderr, "\tnone\n\tall\n"); + fprintf(stderr, ERRORget_warnings_help("\t", "\n")); + fprintf(stderr, "and is one or more of:\n"); + fprintf(stderr, " e entity\n"); + fprintf(stderr, " p procedure\n"); + fprintf(stderr, " r rule\n"); + fprintf(stderr, " f function\n"); + fprintf(stderr, " t type\n"); + fprintf(stderr, " s schema or file\n"); + fprintf(stderr, " # pass #\n"); + fprintf(stderr, " E everything (all of the above)\n"); + if(_exit) { + exit(2); } } diff --git a/src/express/inithook.c b/src/express/inithook.c index a3d3eac5d..edf3fbcec 100644 --- a/src/express/inithook.c +++ b/src/express/inithook.c @@ -2,6 +2,7 @@ /* dummy function, user can supply one allowing them to setup a backend */ /* or customize other parts of fedex application */ -void EXPRESSinit_init( void ) { +void EXPRESSinit_init(void) +{ } diff --git a/src/express/lexact.c b/src/express/lexact.c index abcde3176..27db69163 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -71,20 +71,20 @@ extern YYSTYPE yylval; Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; int SCAN_current_buffer = 0; -char * SCANcurrent; +char *SCANcurrent; extern int yylineno; #define SCAN_COMMENT_LENGTH 256 static char last_comment_[256] = ""; -static char * last_comment = 0; +static char *last_comment = 0; /* keyword lookup table */ static Hash_Table keyword_dictionary; static struct keyword_entry { - char * key; + char *key; int token; } keywords[] = { { "ABS", TOK_BUILTIN_FUNCTION }, @@ -206,7 +206,8 @@ static struct keyword_entry { { 0, 0} }; -static void SCANpush_buffer( char * filename, FILE * fp ) { +static void SCANpush_buffer(char *filename, FILE *fp) +{ SCANbuffer.savedPos = SCANcurrent; SCANbuffer.lineno = yylineno; yylineno = 1; @@ -214,16 +215,17 @@ static void SCANpush_buffer( char * filename, FILE * fp ) { #ifdef keep_nul SCANbuffer.numRead = 0; #else - *( SCANcurrent = SCANbuffer.text ) = '\0'; + *(SCANcurrent = SCANbuffer.text) = '\0'; #endif SCANbuffer.readEof = false; SCANbuffer.file = fp; SCANbuffer.filename = current_filename = filename; } -static void SCANpop_buffer() { - if( SCANbuffer.file != NULL ) { - fclose( SCANbuffer.file ); +static void SCANpop_buffer() +{ + if(SCANbuffer.file != NULL) { + fclose(SCANbuffer.file); } --SCAN_current_buffer; SCANcurrent = SCANbuffer.savedPos; @@ -231,37 +233,43 @@ static void SCANpop_buffer() { current_filename = SCANbuffer.filename; } -void SCANinitialize( void ) { - struct keyword_entry * k; +void SCANinitialize(void) +{ + struct keyword_entry *k; - keyword_dictionary = HASHcreate( 100 ); /* not exact */ - for( k = keywords; k->key; k++ ) { - DICTdefine( keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN ); + keyword_dictionary = HASHcreate(100); /* not exact */ + for(k = keywords; k->key; k++) { + DICTdefine(keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN); /* not "unknown", but certainly won't be looked up by type! */ } } /** Clean up the Scan module */ -void SCANcleanup( void ) { +void SCANcleanup(void) +{ } -int SCANprocess_real_literal( const char * yytext ) { - sscanf( yytext, "%lf", &( yylval.rVal ) ); +int SCANprocess_real_literal(const char *yytext) +{ + sscanf(yytext, "%lf", &(yylval.rVal)); return TOK_REAL_LITERAL; } -int SCANprocess_integer_literal( const char * yytext ) { - sscanf( yytext, "%d", &( yylval.iVal ) ); +int SCANprocess_integer_literal(const char *yytext) +{ + sscanf(yytext, "%d", &(yylval.iVal)); return TOK_INTEGER_LITERAL; } -int SCANprocess_binary_literal( const char * yytext ) { - yylval.binary = SCANstrdup( yytext + 1 ); /* drop '%' prefix */ +int SCANprocess_binary_literal(const char *yytext) +{ + yylval.binary = SCANstrdup(yytext + 1); /* drop '%' prefix */ return TOK_BINARY_LITERAL; } -int SCANprocess_logical_literal( char * string ) { - switch( string[0] ) { +int SCANprocess_logical_literal(char *string) +{ + switch(string[0]) { case 'T': yylval.logical = Ltrue; break; @@ -273,65 +281,67 @@ int SCANprocess_logical_literal( char * string ) { break; /* default will actually be triggered by 'UNKNOWN' keyword */ } - sc_free( string ); + sc_free(string); return TOK_LOGICAL_LITERAL; } -int SCANprocess_identifier_or_keyword( const char * yytext ) { - char * test_string, * dest; - const char * src; - struct keyword_entry * k; +int SCANprocess_identifier_or_keyword(const char *yytext) +{ + char *test_string, * dest; + const char *src; + struct keyword_entry *k; int len; /* make uppercase copy */ - len = strlen( yytext ); - dest = test_string = ( char * )sc_malloc( len + 1 ); - for( src = yytext; *src; src++, dest++ ) { - *dest = ( islower( *src ) ? toupper( *src ) : *src ); + len = strlen(yytext); + dest = test_string = (char *)sc_malloc(len + 1); + for(src = yytext; *src; src++, dest++) { + *dest = (islower(*src) ? toupper(*src) : *src); } *dest = '\0'; /* check for language keywords */ - k = ( struct keyword_entry * )DICTlookup( keyword_dictionary, test_string ); - if( k ) { - switch( k->token ) { + k = (struct keyword_entry *)DICTlookup(keyword_dictionary, test_string); + if(k) { + switch(k->token) { case TOK_BUILTIN_FUNCTION: case TOK_BUILTIN_PROCEDURE: break; case TOK_LOGICAL_LITERAL: - return SCANprocess_logical_literal( test_string ); + return SCANprocess_logical_literal(test_string); default: - sc_free( test_string ); + sc_free(test_string); return k->token; } } /* now we have an identifier token */ - yylval.symbol = SYMBOLcreate( test_string, yylineno, current_filename ); - if( k ) { + yylval.symbol = SYMBOLcreate(test_string, yylineno, current_filename); + if(k) { /* built-in function/procedure */ - return( k->token ); + return(k->token); } else { /* plain identifier */ /* translate back to lower-case */ - SCANlowerize( test_string ); + SCANlowerize(test_string); return TOK_IDENTIFIER; } } -int SCANprocess_string( const char * yytext ) { - char * s, *d; /* source, destination */ +int SCANprocess_string(const char *yytext) +{ + char *s, *d; /* source, destination */ /* strip off quotes */ - yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st single quote */ + yylval.string = SCANstrdup(yytext + 1); /* remove 1st single quote */ /* change pairs of quotes to single quotes */ - for( s = d = yylval.string; *s; ) { - if( *s != '\'' ) { + for(s = d = yylval.string; *s;) { + if(*s != '\'') { *d++ = *s++; - } else if( 0 == strncmp( s, "''", 2 ) ) { + } else if(0 == strncmp(s, "''", 2)) { *d++ = '\''; s += 2; - } else if( *s == '\'' ) { + } else if(*s == '\'') { /* trailing quote */ *s = '\0'; /* if string was unterminated, there will be no */ @@ -344,64 +354,68 @@ int SCANprocess_string( const char * yytext ) { return TOK_STRING_LITERAL; } -int SCANprocess_encoded_string( const char * yytext ) { - char * s; /* source */ +int SCANprocess_encoded_string(const char *yytext) +{ + char *s; /* source */ int count; /* strip off quotes */ - yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st double quote */ + yylval.string = SCANstrdup(yytext + 1); /* remove 1st double quote */ - s = strrchr( yylval.string, '"' ); - if( s ) { + s = strrchr(yylval.string, '"'); + if(s) { *s = '\0'; /* remove last double quote */ } /* if string was unterminated, there will be no quote to remove */ /* in which case the scanner has already complained about it */ count = 0; - for( s = yylval.string; *s; s++, count++ ) { - if( !isxdigit( *s ) ) { - ERRORreport_with_line( ENCODED_STRING_BAD_DIGIT, yylineno, *s ); + for(s = yylval.string; *s; s++, count++) { + if(!isxdigit(*s)) { + ERRORreport_with_line(ENCODED_STRING_BAD_DIGIT, yylineno, *s); } } - if( 0 != ( count % 8 ) ) { - ERRORreport_with_line( ENCODED_STRING_BAD_COUNT, yylineno, count ); + if(0 != (count % 8)) { + ERRORreport_with_line(ENCODED_STRING_BAD_COUNT, yylineno, count); } return TOK_STRING_LITERAL_ENCODED; } -int SCANprocess_semicolon( const char * yytext, int commentp ) { +int SCANprocess_semicolon(const char *yytext, int commentp) +{ - if( commentp ) { - strcpy( last_comment_, strchr( yytext, '-' ) ); + if(commentp) { + strcpy(last_comment_, strchr(yytext, '-')); yylval.string = last_comment_; } else { yylval.string = last_comment; } - if( last_comment ) { + if(last_comment) { last_comment = 0; } return TOK_SEMICOLON; } -void SCANsave_comment( const char * yytext ) { - strncpy( last_comment_ , yytext, SCAN_COMMENT_LENGTH - 1 ); +void SCANsave_comment(const char *yytext) +{ + strncpy(last_comment_, yytext, SCAN_COMMENT_LENGTH - 1); last_comment = last_comment_; } -bool SCANread( void ) { +bool SCANread(void) +{ int numRead; bool done; do { /* this loop is guaranteed to terminate, since buffer[0] is on yyin */ - while( SCANbuffer.file == NULL ) { + while(SCANbuffer.file == NULL) { SCANpop_buffer(); - if( SCANtext_ready ) { + if(SCANtext_ready) { return true; } } @@ -409,15 +423,15 @@ bool SCANread( void ) { /* now we have a file buffer */ /* check for more stuff already buffered */ - if( SCANtext_ready ) { + if(SCANtext_ready) { return true; } /* check whether we've seen eof on this file */ - if( !SCANbuffer.readEof ) { - numRead = fread( SCANbuffer.text, sizeof( char ), - SCAN_BUFFER_SIZE, SCANbuffer.file ); - if( numRead < SCAN_BUFFER_SIZE ) { + if(!SCANbuffer.readEof) { + numRead = fread(SCANbuffer.text, sizeof(char), + SCAN_BUFFER_SIZE, SCANbuffer.file); + if(numRead < SCAN_BUFFER_SIZE) { SCANbuffer.readEof = true; } #ifdef keep_nul @@ -428,61 +442,66 @@ bool SCANread( void ) { SCANcurrent = SCANbuffer.text; } - if( !( done = SCANtext_ready ) ) { - if( SCAN_current_buffer == 0 ) { + if(!(done = SCANtext_ready)) { + if(SCAN_current_buffer == 0) { done = true; - fclose( SCANbuffer.file ); /* close yyin */ + fclose(SCANbuffer.file); /* close yyin */ SCANbuffer.file = NULL; } else { SCANpop_buffer(); } } - } while( !done ); + } while(!done); return SCANtext_ready; } -void SCANinclude_file( char * filename ) { +void SCANinclude_file(char *filename) +{ extern int print_objects_while_running; - FILE * fp; + FILE *fp; - if( ( fp = fopen( filename, "r" ) ) == NULL ) { - ERRORreport_with_line( INCLUDE_FILE, yylineno ); + if((fp = fopen(filename, "r")) == NULL) { + ERRORreport_with_line(INCLUDE_FILE, yylineno); } else { - if( print_objects_while_running & OBJ_SCHEMA_BITS ) { - fprintf( stderr, "parse: including %s at line %d of %s\n", - filename, yylineno, SCANbuffer.filename ); + if(print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf(stderr, "parse: including %s at line %d of %s\n", + filename, yylineno, SCANbuffer.filename); } - SCANpush_buffer( filename, fp ); + SCANpush_buffer(filename, fp); } } -void SCANlowerize( char * s ) { - for( ; *s; s++ ) { - if( isupper( *s ) ) { - *s = tolower( *s ); +void SCANlowerize(char *s) +{ + for(; *s; s++) { + if(isupper(*s)) { + *s = tolower(*s); } } } -void SCANupperize( char * s ) { - for( ; *s; s++ ) { - if( islower( *s ) ) { - *s = toupper( *s ); +void SCANupperize(char *s) +{ + for(; *s; s++) { + if(islower(*s)) { + *s = toupper(*s); } } } -char * SCANstrdup( const char * s ) { - char * s2 = ( char * )sc_malloc( strlen( s ) + 1 ); - if( !s2 ) { +char *SCANstrdup(const char *s) +{ + char *s2 = (char *)sc_malloc(strlen(s) + 1); + if(!s2) { return 0; } - strcpy( s2, s ); + strcpy(s2, s); return s2; } -long SCANtell() { +long SCANtell() +{ return yylineno; } diff --git a/src/express/linklist.c b/src/express/linklist.c index 7089dd81d..9a32e7bbe 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -23,66 +23,76 @@ #include "express/linklist.h" -void LISTinitialize( void ) { +void LISTinitialize(void) +{ } -void LISTcleanup( void ) { +void LISTcleanup(void) +{ } -Linked_List LISTcreate() { +Linked_List LISTcreate() +{ Linked_List list = LIST_new(); list->mark = LINK_new(); list->mark->next = list->mark->prev = list->mark; - return( list ); + return(list); } -Linked_List LISTcopy( Linked_List src ) { +Linked_List LISTcopy(Linked_List src) +{ Linked_List dst = LISTcreate(); - LISTdo( src, x, void * ) - LISTadd_last( dst, x ); + LISTdo(src, x, void *) + LISTadd_last(dst, x); LISTod return dst; } -void LISTfree( Linked_List list ) { +void LISTfree(Linked_List list) +{ Link p, q = list->mark->next; - for( p = q->next; p != list->mark; q = p, p = p->next ) { - LINK_destroy( q ); + for(p = q->next; p != list->mark; q = p, p = p->next) { + LINK_destroy(q); } - if( q != list->mark ) { - LINK_destroy( q ); + if(q != list->mark) { + LINK_destroy(q); } - LINK_destroy( list->mark ); - LIST_destroy( list ); + LINK_destroy(list->mark); + LIST_destroy(list); } -void LISTsort( Linked_List list, int (*comp)(void*, void*)) { +void LISTsort(Linked_List list, int (*comp)(void *, void *)) +{ unsigned int moved; Link node, prev; - if (LISTempty(list)) + if(LISTempty(list)) { return; + } - while (true) { - for ( node = list->mark->next, moved = 0; node != list->mark; node = node->next ) { + while(true) { + for(node = list->mark->next, moved = 0; node != list->mark; node = node->next) { prev = node->prev; - if (prev != list->mark && comp(prev->data, node->data) < 0) { + if(prev != list->mark && comp(prev->data, node->data) < 0) { LISTswap(prev, node); moved++; } } - if (moved == 0) + if(moved == 0) { break; + } } } -void LISTswap( Link p, Link q ) { +void LISTswap(Link p, Link q) +{ void *tmp; - if( p == LINK_NULL || q == LINK_NULL || p == q ) + if(p == LINK_NULL || q == LINK_NULL || p == q) { return; + } tmp = p->data; p->data = q->data; @@ -90,45 +100,49 @@ void LISTswap( Link p, Link q ) { } -void *LISTadd_first( Linked_List list, void *item ) { +void *LISTadd_first(Linked_List list, void *item) +{ Link node; node = LINK_new(); node->data = item; - ( node->next = list->mark->next )->prev = node; - ( list->mark->next = node )->prev = list->mark; + (node->next = list->mark->next)->prev = node; + (list->mark->next = node)->prev = list->mark; return item; } -void *LISTadd_last( Linked_List list, void *item ) { +void *LISTadd_last(Linked_List list, void *item) +{ Link node; node = LINK_new(); node->data = item; - ( node->prev = list->mark->prev )->next = node; - ( list->mark->prev = node )->next = list->mark; + (node->prev = list->mark->prev)->next = node; + (list->mark->prev = node)->next = list->mark; return item; } -void *LISTadd_after( Linked_List list, Link link, void *item ) { +void *LISTadd_after(Linked_List list, Link link, void *item) +{ Link node; - if( link == LINK_NULL ) { - LISTadd_first( list, item ); + if(link == LINK_NULL) { + LISTadd_first(list, item); } else { node = LINK_new(); node->data = item; - ( node->next = link->next )->prev = node; - ( link->next = node )->prev = link; + (node->next = link->next)->prev = node; + (link->next = node)->prev = link; } return item; } -void *LISTadd_before( Linked_List list, Link link, void *item ) { +void *LISTadd_before(Linked_List list, Link link, void *item) +{ Link node; - if( link == LINK_NULL ) { - LISTadd_last( list, item ); + if(link == LINK_NULL) { + LISTadd_last(list, item); } else { node = LINK_new(); node->data = item; @@ -142,43 +156,46 @@ void *LISTadd_before( Linked_List list, Link link, void *item ) { } -void *LISTremove_first( Linked_List list ) { +void *LISTremove_first(Linked_List list) +{ Link node; void *item; node = list->mark->next; - if( node == list->mark ) { - ERRORreport( EMPTY_LIST, "LISTremove_first" ); + if(node == list->mark) { + ERRORreport(EMPTY_LIST, "LISTremove_first"); return NULL; } item = node->data; - ( list->mark->next = node->next )->prev = list->mark; - LINK_destroy( node ); + (list->mark->next = node->next)->prev = list->mark; + LINK_destroy(node); return item; } -void *LISTget_first( Linked_List list ) { +void *LISTget_first(Linked_List list) +{ Link node; void *item; node = list->mark->next; - if( node == list->mark ) { + if(node == list->mark) { return NULL; } item = node->data; return item; } -void *LISTget_second( Linked_List list ) { +void *LISTget_second(Linked_List list) +{ Link node; void *item; node = list->mark->next; - if( node == list->mark ) { + if(node == list->mark) { return NULL; } node = node->next; - if( node == list->mark ) { + if(node == list->mark) { return NULL; } item = node->data; @@ -186,37 +203,40 @@ void *LISTget_second( Linked_List list ) { } /** first is 1, not 0 */ -void *LISTget_nth( Linked_List list, int n ) { +void *LISTget_nth(Linked_List list, int n) +{ int count = 1; Link node; - for( node = list->mark->next; node != list->mark; node = node->next ) { - if( n == count++ ) { - return( node->data ); + for(node = list->mark->next; node != list->mark; node = node->next) { + if(n == count++) { + return(node->data); } } - return( 0 ); + return(0); } -int LISTget_length( Linked_List list ) { +int LISTget_length(Linked_List list) +{ Link node; int count = 0; - if( !list ) { + if(!list) { return 0; } - for( node = list->mark->next; node != list->mark; node = node->next ) { + for(node = list->mark->next; node != list->mark; node = node->next) { count++; } return count; } -bool LISTempty( Linked_List list ) { - if( !list ) { +bool LISTempty(Linked_List list) +{ + if(!list) { return true; } - if( list->mark->next == list->mark ) { + if(list->mark->next == list->mark) { return true; } return false; diff --git a/src/express/memory.c b/src/express/memory.c index f8b536e45..a257582fb 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -51,52 +51,53 @@ struct freelist_head PCALL_fl; struct freelist_head RET_fl; struct freelist_head INCR_fl; -void MEMORYinitialize() { +void MEMORYinitialize() +{ _ALLOCinitialize(); - - ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); - ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); - - ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); - ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); - - ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); - - ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); - - ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); - ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); - - ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); - - ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); - ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); - ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); - ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); - - ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); - - ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); - ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); - - ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); - - ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); - ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); - ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); - ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); - - ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); - - ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); - ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); - ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); - ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); - ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); - ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); - ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); - ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); - ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); + + ALLOCinitialize(&HASH_Table_fl, sizeof(struct Hash_Table_), 50, 50); + ALLOCinitialize(&HASH_Element_fl, sizeof(struct Element_), 500, 100); + + ALLOCinitialize(&LINK_fl, sizeof(struct Link_), 500, 100); + ALLOCinitialize(&LIST_fl, sizeof(struct Linked_List_), 100, 50); + + ALLOCinitialize(&SYMBOL_fl, sizeof(struct Symbol_), 100, 100); + + ALLOCinitialize(&SCOPE_fl, sizeof(struct Scope_), 100, 50); + + ALLOCinitialize(&TYPEHEAD_fl, sizeof(struct TypeHead_), 500, 100); + ALLOCinitialize(&TYPEBODY_fl, sizeof(struct TypeBody_), 200, 100); + + ALLOCinitialize(&VAR_fl, sizeof(struct Variable_), 100, 50); + + ALLOCinitialize(&FUNC_fl, sizeof(struct Function_), 100, 50); + ALLOCinitialize(&RULE_fl, sizeof(struct Rule_), 100, 50); + ALLOCinitialize(&PROC_fl, sizeof(struct Procedure_), 100, 50); + ALLOCinitialize(&WHERE_fl, sizeof(struct Where_), 100, 50); + + ALLOCinitialize(&ENTITY_fl, sizeof(struct Entity_), 500, 100); + + ALLOCinitialize(&SCHEMA_fl, sizeof(struct Schema_), 40, 20); + ALLOCinitialize(&REN_fl, sizeof(struct Rename), 30, 30); + + ALLOCinitialize(&CASE_IT_fl, sizeof(struct Case_Item_), 500, 100); + + ALLOCinitialize(&EXP_fl, sizeof(struct Expression_), 500, 200); + ALLOCinitialize(&OP_fl, sizeof(struct Op_Subexpression), 500, 100); + ALLOCinitialize(&QUERY_fl, sizeof(struct Query_), 50, 10); + ALLOCinitialize(&QUAL_ATTR_fl, sizeof(struct Query_), 20, 10); + + ALLOCinitialize(&STMT_fl, sizeof(struct Statement_), 500, 100); + + ALLOCinitialize(&ALIAS_fl, sizeof(struct Alias_), 10, 10); + ALLOCinitialize(&ASSIGN_fl, sizeof(struct Assignment_), 100, 30); + ALLOCinitialize(&CASE_fl, sizeof(struct Case_Statement_), 100, 30); + ALLOCinitialize(&COMP_STMT_fl, sizeof(struct Compound_Statement_), 100, 30); + ALLOCinitialize(&COND_fl, sizeof(struct Conditional_), 100, 30); + ALLOCinitialize(&LOOP_fl, sizeof(struct Loop_), 100, 30); + ALLOCinitialize(&PCALL_fl, sizeof(struct Procedure_Call_), 100, 30); + ALLOCinitialize(&RET_fl, sizeof(struct Return_Statement_), 100, 30); + ALLOCinitialize(&INCR_fl, sizeof(struct Increment_), 100, 30); } diff --git a/src/express/object.c b/src/express/object.c index f75e64274..3aa76f2ec 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -30,76 +30,84 @@ #include "express/type.h" #include "express/expr.h" -Symbol * SCOPE_get_symbol( void *s ); -Symbol * EXPRESS_get_symbol( void *e ); -Symbol * RENAME_get_symbol( void *r ); -Symbol * TYPE_get_symbol( void *t ); -Symbol * EXP_get_symbol( void *e ); -Symbol * WHERE_get_symbol( void *w ); -Symbol * VAR_get_symbol( void *v ); -Symbol * UNK_get_symbol( void *x ); +Symbol *SCOPE_get_symbol(void *s); +Symbol *EXPRESS_get_symbol(void *e); +Symbol *RENAME_get_symbol(void *r); +Symbol *TYPE_get_symbol(void *t); +Symbol *EXP_get_symbol(void *e); +Symbol *WHERE_get_symbol(void *w); +Symbol *VAR_get_symbol(void *v); +Symbol *UNK_get_symbol(void *x); /* global Object type array */ struct Object OBJ[] = { [0] = {UNK_get_symbol, "of unknown type", 0}, - + [OBJ_VARIABLE] = {VAR_get_symbol, "variable", OBJ_VARIABLE_BITS}, [OBJ_ENTITY] = {SCOPE_get_symbol, "entity", OBJ_ENTITY_BITS}, - + [OBJ_EXPRESSION] = {EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS}, [OBJ_AMBIG_ENUM] = {EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS}, - + [OBJ_RULE] = {SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS}, [OBJ_PROCEDURE] = {SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS}, [OBJ_FUNCTION] = {SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS}, [OBJ_WHERE] = {WHERE_get_symbol, "where", OBJ_WHERE_BITS}, - + [OBJ_SCHEMA] = {SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS}, /* TODO: PASS should also have a symbol */ [OBJ_PASS] = {UNK_get_symbol, "pass", OBJ_PASS_BITS}, [OBJ_EXPRESS] = {EXPRESS_get_symbol, "express file", OBJ_UNUSED_BITS}, [OBJ_RENAME] = {RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS}, - + [OBJ_TYPE] = {TYPE_get_symbol, "type", OBJ_TYPE_BITS}, [OBJ_TAG] = {TYPE_get_symbol, "tag", OBJ_TYPE_BITS}, - + [OBJ_ALIAS] = {SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS }, [OBJ_INCREMENT] = {SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS }, {0} }; -Symbol * UNK_get_symbol( void *x ) { +Symbol *UNK_get_symbol(void *x) +{ (void) x; /* quell unused param warning; it appears that the prototype must match other functions */ - fprintf( stderr, "OBJget_symbol called on object of unknown type\n" ); - ERRORabort( 0 ); + fprintf(stderr, "OBJget_symbol called on object of unknown type\n"); + ERRORabort(0); return 0; } -Symbol * VAR_get_symbol( void *v ) { - return &( ( Variable )v )->name->symbol; +Symbol *VAR_get_symbol(void *v) +{ + return &((Variable)v)->name->symbol; } -Symbol * SCOPE_get_symbol( void *s ) { - return &( ( Scope )s )->symbol; +Symbol *SCOPE_get_symbol(void *s) +{ + return &((Scope)s)->symbol; } -Symbol * EXP_get_symbol( void *e ) { - return &( ( Expression )e )->symbol; +Symbol *EXP_get_symbol(void *e) +{ + return &((Expression)e)->symbol; } -Symbol * WHERE_get_symbol( void *w ) { - return ( ( Where )w )->label; +Symbol *WHERE_get_symbol(void *w) +{ + return ((Where)w)->label; } -Symbol * EXPRESS_get_symbol( void *e ) { - return &( ( Express )e )->symbol; +Symbol *EXPRESS_get_symbol(void *e) +{ + return &((Express)e)->symbol; } -Symbol * RENAME_get_symbol( void *r ) { - return ( ( Rename * )r )->old; +Symbol *RENAME_get_symbol(void *r) +{ + return ((Rename *)r)->old; } -Symbol * TYPE_get_symbol( void *t ) { - return &( ( Type )t )->symbol; +Symbol *TYPE_get_symbol(void *t) +{ + return &((Type)t)->symbol; } diff --git a/src/express/ordered_attrs.cc b/src/express/ordered_attrs.cc index 8081c16e3..ce3e2b08f 100644 --- a/src/express/ordered_attrs.cc +++ b/src/express/ordered_attrs.cc @@ -15,18 +15,20 @@ oaList attrs; unsigned int attrIndex = 0; /// uses depth-first recursion to add attrs in order; looks for derived attrs -void populateAttrList( oaList & list, Entity ent ) { +void populateAttrList(oaList &list, Entity ent) +{ unsigned int attrCount = list.size(); //use to figure out how many attrs on end of list need to be checked for duplicates //recurse through supertypes - LISTdo( ent->u.entity->supertypes, super, Entity ) { - populateAttrList( list, super ); - } LISTod + LISTdo(ent->u.entity->supertypes, super, Entity) { + populateAttrList(list, super); + } + LISTod //then look at ent's own attrs, checking against attrs with index >= attrCount //derivation check only - leave deduplication for later - LISTdo( ent->u.entity->attributes, attr, Variable ) { + LISTdo(ent->u.entity->attributes, attr, Variable) { bool unique = true; - for( unsigned int i = attrCount; i < list.size(); i++ ) { - if( 0 == strcasecmp( attr->name->symbol.name, list[i]->attr->name->symbol.name ) ) { + for(unsigned int i = attrCount; i < list.size(); i++) { + if(0 == strcasecmp(attr->name->symbol.name, list[i]->attr->name->symbol.name)) { // an attr by this name exists in a supertype // originally printed a warning here, but that was misleading - they have more uses than I thought unique = false; @@ -34,63 +36,68 @@ void populateAttrList( oaList & list, Entity ent ) { break; } } - if( unique ) { - orderedAttr * oa = new orderedAttr; - oa->attr=attr; - oa->creator=ent; - if( attr->initializer ) { + if(unique) { + orderedAttr *oa = new orderedAttr; + oa->attr = attr; + oa->creator = ent; + if(attr->initializer) { // attrs derived by their owner are omitted from part 21 - section 10.2.3 oa->deriver = ent; } else { oa->deriver = 0; } oa->redefiner = 0; - list.push_back( oa ); + list.push_back(oa); } - } LISTod + } + LISTod } ///compare attr name and creator, remove all but first occurrence ///this is necessary for diamond inheritance -void dedupList( oaList & list ) { +void dedupList(oaList &list) +{ oaList::iterator it, jt; - for( it = list.begin(); it != list.end(); it++ ) { - for( jt = it + 1; jt != list.end(); jt++ ) { - if( ( 0 == strcasecmp( ( * it )->attr->name->symbol.name, ( * jt )->attr->name->symbol.name ) ) && - ( 0 == strcasecmp( ( * it )->creator->symbol.name, ( * jt )->creator->symbol.name ) ) ) { + for(it = list.begin(); it != list.end(); it++) { + for(jt = it + 1; jt != list.end(); jt++) { + if((0 == strcasecmp((* it)->attr->name->symbol.name, (* jt)->attr->name->symbol.name)) && + (0 == strcasecmp((* it)->creator->symbol.name, (* jt)->creator->symbol.name))) { //fprintf( stderr, "erasing %s created by %s\n", ( * jt )->attr->name->symbol.name, ( * jt )->creator->symbol.name ); jt--; - list.erase( jt + 1 ); + list.erase(jt + 1); } } } } /// set up ordered attrs for new entity -void orderedAttrsInit( Entity e ) { +void orderedAttrsInit(Entity e) +{ orderedAttrsCleanup(); attrIndex = 0; currentEntity = e; - if( currentEntity ) { - populateAttrList( attrs, currentEntity ); - if( attrs.size() > 1 ) { - dedupList( attrs ); + if(currentEntity) { + populateAttrList(attrs, currentEntity); + if(attrs.size() > 1) { + dedupList(attrs); } } } -void orderedAttrsCleanup() { - for( unsigned int i = 0; i < attrs.size(); i++ ) { +void orderedAttrsCleanup() +{ + for(unsigned int i = 0; i < attrs.size(); i++) { delete attrs[i]; } attrs.clear(); } -const orderedAttr * nextAttr() { - if( attrIndex < attrs.size() ) { +const orderedAttr *nextAttr() +{ + if(attrIndex < attrs.size()) { unsigned int i = attrIndex; attrIndex++; - return attrs.at( i ); + return attrs.at(i); } else { return 0; } diff --git a/src/express/resolve.c b/src/express/resolve.c index fa5797917..f4f1a233f 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -72,14 +72,16 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -extern void VAR_resolve_types( Variable v ); +extern void VAR_resolve_types(Variable v); /** Initialize the Fed-X second pass. */ -void RESOLVEinitialize( void ) { +void RESOLVEinitialize(void) +{ } /** Clean up the Fed-X second pass */ -void RESOLVEcleanup( void ) { +void RESOLVEcleanup(void) +{ } /** @@ -88,17 +90,18 @@ void RESOLVEcleanup( void ) { ** \param t_agg the current aggregate type ** \return the aggregate type */ -Type TYPE_retrieve_aggregate( Type t_select, Type t_agg ) { - if( TYPEis_select( t_select ) ) { +Type TYPE_retrieve_aggregate(Type t_select, Type t_agg) +{ + if(TYPEis_select(t_select)) { /* parse the underlying types */ - LISTdo_links( t_select->u.type->body->list, link ) + LISTdo_links(t_select->u.type->body->list, link) /* the current underlying type */ - Type t = ( Type ) link->data; - if( TYPEis_select( t ) ) { - t_agg = TYPE_retrieve_aggregate( t, t_agg ); - } else if( TYPEis_aggregate( t ) ) { - if( t_agg ) { - if( t_agg != t->u.type->body->base ) { + Type t = (Type) link->data; + if(TYPEis_select(t)) { + t_agg = TYPE_retrieve_aggregate(t, t_agg); + } else if(TYPEis_aggregate(t)) { + if(t_agg) { + if(t_agg != t->u.type->body->base) { /* 2 underlying types do not have to the same base */ return 0; } @@ -124,9 +127,10 @@ Type TYPE_retrieve_aggregate( Type t_select, Type t_agg ) { ** Resolve all references in an expression. ** \note the macro 'EXPresolve' calls this function after checking if expr is already resolved */ -void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { +void EXP_resolve(Expression expr, Scope scope, Type typecheck) +{ Function f = 0; - Symbol * sym; + Symbol *sym; void *x; Entity e; Type t; @@ -135,73 +139,73 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { /* if (expr == EXPRESSION_NULL) return; */ - switch( expr->type->u.type->body->type ) { + switch(expr->type->u.type->body->type) { case funcall_: /* functions with no arguments get handled elsewhere */ /* because the parser sees them just like attributes */ - x = SCOPEfind( scope, expr->symbol.name, - SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY ); - if( !x ) { - ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name ); - resolve_failed( expr ); + x = SCOPEfind(scope, expr->symbol.name, + SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY); + if(!x) { + ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name); + resolve_failed(expr); break; } - if( ( DICT_type != OBJ_FUNCTION ) && ( DICT_type != OBJ_ENTITY ) ) { - sym = OBJget_symbol( x, DICT_type ); - ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name ); - resolve_failed( expr ); + if((DICT_type != OBJ_FUNCTION) && (DICT_type != OBJ_ENTITY)) { + sym = OBJget_symbol(x, DICT_type); + ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name); + resolve_failed(expr); break; } /* original code accepted rules, too? */ /* entities are treated like implicit constructor functions */ - if( DICT_type == OBJ_ENTITY ) { + if(DICT_type == OBJ_ENTITY) { Type self_old = self; /* save previous in the unlikely but possible case that * SELF is in a derived initialization of an entity */ - e = ( Entity )x; + e = (Entity)x; self = e->u.entity->type; /* skip parameter resolution for now */ /* ARGresolve();*/ expr->return_type = e->u.entity->type; self = self_old; /* restore old SELF */ } else { - f = ( Function )x; + f = (Function)x; expr->return_type = f->u.func->return_type; /* do argument typechecking here if requested */ /* currently, we just check arg count; necessary */ /* to NVL code later which assumes args are present */ - if( LISTget_length( expr->u.funcall.list ) != - f->u.func->pcount ) { + if(LISTget_length(expr->u.funcall.list) != + f->u.func->pcount) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, - LISTget_length( expr->u.funcall.list ), - f->u.func->pcount ); + LISTget_length(expr->u.funcall.list), + f->u.func->pcount); } #ifdef future_work - if( EXPRESS_lint ) { + if(EXPRESS_lint) { /* verify parameters match function call */ } #endif /* should make this data-driven! */ - if( f == FUNC_NVL ) { - EXPresolve( ( Expression )LISTget_first( expr->u.funcall.list ), scope, typecheck ); - EXPresolve( ( Expression )LISTget_second( expr->u.funcall.list ), scope, typecheck ); + if(f == FUNC_NVL) { + EXPresolve((Expression)LISTget_first(expr->u.funcall.list), scope, typecheck); + EXPresolve((Expression)LISTget_second(expr->u.funcall.list), scope, typecheck); func_args_checked = true; } /* why is this here? (snc) */ - if( f == FUNC_USEDIN ) { + if(f == FUNC_USEDIN) { expr->return_type = Type_Bag_Of_Generic; } } - if( !func_args_checked ) { - LISTdo( expr->u.funcall.list, param, Expression ) - EXPresolve( param, scope, Type_Dont_Care ); - if( is_resolve_failed( param ) ) { - resolve_failed( expr ); + if(!func_args_checked) { + LISTdo(expr->u.funcall.list, param, Expression) + EXPresolve(param, scope, Type_Dont_Care); + if(is_resolve_failed(param)) { + resolve_failed(expr); break; } LISTod; @@ -209,48 +213,48 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { #if 0 /* add function or entity as first element of list */ - LISTadd_first( expr->u.list, x ); + LISTadd_first(expr->u.list, x); #endif - expr->u.funcall.function = ( struct Scope_ * ) x; + expr->u.funcall.function = (struct Scope_ *) x; - resolved_all( expr ); + resolved_all(expr); break; case aggregate_: - LISTdo( expr->u.list, elt, Expression ) - EXPresolve( elt, scope, Type_Dont_Care ); - if( is_resolve_failed( elt ) ) { - resolve_failed( expr ); + LISTdo(expr->u.list, elt, Expression) + EXPresolve(elt, scope, Type_Dont_Care); + if(is_resolve_failed(elt)) { + resolve_failed(expr); break; } LISTod; /* may have to do more work here! */ expr->return_type = expr->type; - resolved_all( expr ); + resolved_all(expr); break; case identifier_: x = 0; /* assume it's a variable/attribute */ - if( !x ) { - x = VARfind( scope, expr->symbol.name, 0 ); + if(!x) { + x = VARfind(scope, expr->symbol.name, 0); } /* if not found as a variable, try as function, etc ... */ - if( !x ) { - x = SCOPEfind( scope, expr->symbol.name, - SCOPE_FIND_ANYTHING ); + if(!x) { + x = SCOPEfind(scope, expr->symbol.name, + SCOPE_FIND_ANYTHING); } /* Not all enums have `typecheck->u.type->body->type` == `enumeration_` - ?! */ - if( !x ) { + if(!x) { Scope enumscope = scope; - while( 1 ) { + while(1) { /* look up locally, then go through the superscopes */ - x = DICTlookup( enumscope->enum_table, expr->symbol.name ); - if( x ) { + x = DICTlookup(enumscope->enum_table, expr->symbol.name); + if(x) { break; } - if( enumscope->type == OBJ_SCHEMA ) { + if(enumscope->type == OBJ_SCHEMA) { /* if we get here, this means that we've looked through all scopes */ x = 0; break; @@ -259,121 +263,121 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { } } - if( !x ) { - if( typecheck == Type_Unknown ) { + if(!x) { + if(typecheck == Type_Unknown) { return; } else { - ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name ); - resolve_failed( expr ); + ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name); + resolve_failed(expr); break; } } - switch( DICT_type ) { + switch(DICT_type) { case OBJ_VARIABLE: - expr->u.variable = ( Variable )x; + expr->u.variable = (Variable)x; #if 0 /* gee, I don't see what variables have to go through this right here */ - VARresolve_expressions( expr->u.variable, scope ); - if( is_resolve_failed( expr->u.variable->name ) ) { - resolve_failed( expr ); + VARresolve_expressions(expr->u.variable, scope); + if(is_resolve_failed(expr->u.variable->name)) { + resolve_failed(expr); break; } #endif /* Geez, don't wipe out original type! */ expr->return_type = expr->u.variable->type; - if( expr->u.variable->flags.attribute ) { + if(expr->u.variable->flags.attribute) { found_self = true; } - resolved_all( expr ); + resolved_all(expr); break; case OBJ_ENTITY: - expr->return_type = expr->type = ( ( Entity )x )->u.entity->type; + expr->return_type = expr->type = ((Entity)x)->u.entity->type; /* entity may not actually be resolved by now */ /* but I don't think that's a problem */ - resolved_all( expr ); + resolved_all(expr); break; case OBJ_EXPRESSION: /* so far only enumerations get returned this way */ - expr->u.expression = ( Expression )x; - expr->type = expr->return_type = ( ( Expression )x )->type; - resolved_all( expr ); + expr->u.expression = (Expression)x; + expr->type = expr->return_type = ((Expression)x)->type; + resolved_all(expr); break; case OBJ_FUNCTION: /* functions with no args end up here because the */ /* parser doesn't know any better */ expr->u.list = LISTcreate(); - LISTadd_last( expr->u.list, x ); + LISTadd_last(expr->u.list, x); expr->type = Type_Funcall; - expr->return_type = ( ( Function )x )->u.func->return_type; + expr->return_type = ((Function)x)->u.func->return_type; /* function may not actually be resolved by now */ /* but I don't think that's a problem */ - if( ( ( Function )x )->u.func->pcount != 0 ) { + if(((Function)x)->u.func->pcount != 0) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, 0, - f->u.func->pcount ); - resolve_failed( expr ); + f->u.func->pcount); + resolve_failed(expr); } else { - resolved_all( expr ); + resolved_all(expr); } break; case OBJ_TYPE: /* enumerations can appear here, I don't know about others */ - expr->type = ( Type )x; - expr->return_type = ( Type )x; + expr->type = (Type)x; + expr->return_type = (Type)x; expr->symbol.resolved = expr->type->symbol.resolved; break; default: - fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); + fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); break; } break; case op_: - expr->return_type = ( *EXPop_table[expr->e.op_code].resolve )( expr, scope ); + expr->return_type = (*EXPop_table[expr->e.op_code].resolve)(expr, scope); break; case entity_: /* only 'self' is seen this way */ case self_: - if( self ) { + if(self) { expr->return_type = self; /* we can't really call ourselves resolved, but we */ /* will be by the time we return, and besides, */ /* there's no way this will be accessed if the true */ /* entity fails resolution */ found_self = true; - resolved_all( expr ); + resolved_all(expr); } else { - ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol ); - resolve_failed( expr ); + ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol); + resolve_failed(expr); } break; case query_: - EXPresolve( expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care ); + EXPresolve(expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care); expr->return_type = expr->u.query->aggregate->return_type; /* verify that it's an aggregate */ - if( is_resolve_failed( expr->u.query->aggregate ) ) { - resolve_failed( expr ); + if(is_resolve_failed(expr->u.query->aggregate)) { + resolve_failed(expr); break; } - if( TYPEis_aggregate( expr->return_type ) ) { + if(TYPEis_aggregate(expr->return_type)) { t = expr->u.query->aggregate->return_type->u.type->body->base; - } else if( TYPEis_select( expr->return_type ) ) { + } else if(TYPEis_select(expr->return_type)) { /* retrieve the common aggregate type */ - t = TYPE_retrieve_aggregate( expr->return_type, 0 ); - if( !t ) { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); - resolve_failed( expr ); + t = TYPE_retrieve_aggregate(expr->return_type, 0); + if(!t) { + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); + resolve_failed(expr); break; } - } else if( TYPEis_runtime( expr->return_type ) ) { + } else if(TYPEis_runtime(expr->return_type)) { t = Type_Runtime; } else { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); - resolve_failed( expr ); + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); + resolve_failed(expr); break; } expr->u.query->local->type = t; expr->u.query->local->name->return_type = t; - EXPresolve( expr->u.query->expression, expr->u.query->scope, Type_Dont_Care ); + EXPresolve(expr->u.query->expression, expr->u.query->scope, Type_Dont_Care); expr->symbol.resolved = expr->u.query->expression->symbol.resolved; break; case integer_: @@ -384,61 +388,62 @@ void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { case logical_: case number_: expr->return_type = expr->type; - resolved_all( expr ); + resolved_all(expr); break; case attribute_: expr->return_type = expr->type; - resolved_all( expr ); + resolved_all(expr); break; default: - fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); + fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); } } -int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, Linked_List * flat ) { +int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, Linked_List *flat) +{ Entity ent_ref; int i = UNRESOLVED; - if( !expr ) { - return ( RESOLVED ); - } else if( TYPEis_expression( expr->type ) ) { - i = ENTITYresolve_subtype_expression( expr->e.op1, ent, flat ); - i |= ENTITYresolve_subtype_expression( expr->e.op2, ent, flat ); - } else if( TYPEis_oneof( expr->type ) ) { - LISTdo( expr->u.list, sel, Expression ) - i |= ENTITYresolve_subtype_expression( sel, ent, flat ); + if(!expr) { + return (RESOLVED); + } else if(TYPEis_expression(expr->type)) { + i = ENTITYresolve_subtype_expression(expr->e.op1, ent, flat); + i |= ENTITYresolve_subtype_expression(expr->e.op2, ent, flat); + } else if(TYPEis_oneof(expr->type)) { + LISTdo(expr->u.list, sel, Expression) + i |= ENTITYresolve_subtype_expression(sel, ent, flat); LISTod; } else { /* must be a simple entity reference */ - ent_ref = ( Entity )SCOPEfind( ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY ); - if( !ent_ref ) { + ent_ref = (Entity)SCOPEfind(ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY); + if(!ent_ref) { ERRORreport_with_symbol(UNKNOWN_SUBTYPE, &ent->symbol, - expr->symbol.name, ent->symbol.name ); + expr->symbol.name, ent->symbol.name); i = RESOLVE_FAILED; - } else if( DICT_type != OBJ_ENTITY ) { - Symbol * sym = OBJget_symbol( ent_ref, DICT_type ); + } else if(DICT_type != OBJ_ENTITY) { + Symbol *sym = OBJget_symbol(ent_ref, DICT_type); /* line number should really be on supertype name, */ /* but all we have easily is the entity line number */ ERRORreport_with_symbol(SUBTYPE_RESOLVE, &ent->symbol, - expr->symbol.name, sym->line ); + expr->symbol.name, sym->line); i = RESOLVE_FAILED; } else { bool found = false; /* link in to flat list */ - if( !*flat ) { + if(!*flat) { *flat = LISTcreate(); } - LISTdo( *flat, sub, Entity ) - if( sub == ent_ref ) { + LISTdo(*flat, sub, Entity) + if(sub == ent_ref) { found = true; break; } LISTod - if( !found ) { - LISTadd_last( *flat, ent_ref ); + if(!found) { + LISTadd_last(*flat, ent_ref); } /* link in to expression */ @@ -449,22 +454,22 @@ int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, /* If the user said there was a subtype relationship but */ /* did not mention the reverse supertype relationship, */ /* complain (IS p. 44) */ - LISTdo( ent_ref->u.entity->supertypes, sup, Entity ) - if( sup == ent ) { + LISTdo(ent_ref->u.entity->supertypes, sup, Entity) + if(sup == ent) { found = true; break; } LISTod - if( !found ) { - if( !ent_ref->u.entity->supertypes ) { + if(!found) { + if(!ent_ref->u.entity->supertypes) { ent_ref->u.entity->supertypes = LISTcreate(); } - LISTadd_last( ent_ref->u.entity->supertypes, ent ); + LISTadd_last(ent_ref->u.entity->supertypes, ent); } #endif } } - return( i ); + return(i); } /** @@ -473,42 +478,43 @@ int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, ** ** Resolve all references in a type. */ -void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { +void TYPE_resolve(Type *typeaddr /*, Scope scope*/) +{ Type type = *typeaddr; Type ref_type; TypeBody body = type->u.type->body; Scope scope = type->superscope; - if( body ) { + if(body) { /* complex type definition such as aggregates, enums, ... */ - resolve_in_progress( type ); + resolve_in_progress(type); - if( TYPEis_aggregate( type ) ) { - TYPEresolve( &body->base ); + if(TYPEis_aggregate(type)) { + TYPEresolve(&body->base); /* only really critical failure point for future use */ /* of this type is the base type, ignore others (above) */ type->symbol.resolved = body->base->symbol.resolved; - } else if( TYPEis_select( type ) ) { - LISTdo_links( body->list, link ) - TYPEresolve( ( Type * )&link->data ); - if( is_resolve_failed( ( Type )link->data ) ) { - resolve_failed( type ); + } else if(TYPEis_select(type)) { + LISTdo_links(body->list, link) + TYPEresolve((Type *)&link->data); + if(is_resolve_failed((Type)link->data)) { + resolve_failed(type); break; } LISTod; } - } else if( type->u.type->head ) { + } else if(type->u.type->head) { /* simple type definition such as "TYPE T = U" */ - resolve_in_progress( type ); + resolve_in_progress(type); - TYPEresolve( &type->u.type->head ); + TYPEresolve(&type->u.type->head); - if( !is_resolve_failed( type->u.type->head ) ) { - if( ERRORis_enabled( TYPE_IS_ENTITY ) ) { - if( TYPEis_entity( type->u.type->head ) ) { - ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name ); - resolve_failed( type ); + if(!is_resolve_failed(type->u.type->head)) { + if(ERRORis_enabled(TYPE_IS_ENTITY)) { + if(TYPEis_entity(type->u.type->head)) { + ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name); + resolve_failed(type); } } /* allow type ref's to be bypassed by caching true type */ @@ -521,14 +527,14 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { /* an attribute or formal parameter whose name is the same */ /* as its type, i.e. "foo : foo". unfortunately, babys like */ /* local variables get thrown out with the bathwater. -snc */ - ref_type = ( Type )SCOPEfind( scope, type->symbol.name, - SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE ); + ref_type = (Type)SCOPEfind(scope, type->symbol.name, + SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE); /* SCOPE_FIND_TYPE | SCOPE_FIND_ENTITY);*/ - if( !ref_type ) { - ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name ); + if(!ref_type) { + ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name); *typeaddr = Type_Bad; /* just in case */ - resolve_failed( type ); - } else if( DICT_type == OBJ_TYPE ) { + resolve_failed(type); + } else if(DICT_type == OBJ_TYPE) { /* due to declarations of multiple attributes off of a */ /* single type ref, we have to use reference counts */ /* to safely deallocate the TypeHead. It's trivial to do */ @@ -536,21 +542,21 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { /* if (type->refcount--) TYPE_destroy(type); */ type = *typeaddr = ref_type; - TYPEresolve( typeaddr ); /* addr doesn't matter here */ + TYPEresolve(typeaddr); /* addr doesn't matter here */ /* it will not be written through */ - } else if( DICT_type == OBJ_ENTITY ) { + } else if(DICT_type == OBJ_ENTITY) { /* if (type->refcount--) TYPE_destroy(type); see above */ - type = *typeaddr = ( ( Entity )ref_type )->u.entity->type; + type = *typeaddr = ((Entity)ref_type)->u.entity->type; } else { ERRORreport_with_symbol(NOT_A_TYPE, &type->symbol, type->symbol.name, - OBJget_type( DICT_type ) ); - resolve_failed( type ); + OBJget_type(DICT_type)); + resolve_failed(type); } } - if( !is_resolve_failed( type ) ) { - resolved_all( type ); + if(!is_resolve_failed(type)) { + resolved_all(type); } return; } @@ -561,14 +567,15 @@ void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { ** ** Resolve all references in a variable definition. */ -void VAR_resolve_expressions( Variable v, Entity entity /* was scope */ ) { - EXPresolve( v->name, entity, Type_Dont_Care ); /* new!! */ +void VAR_resolve_expressions(Variable v, Entity entity /* was scope */) +{ + EXPresolve(v->name, entity, Type_Dont_Care); /* new!! */ - if( v->initializer ) { - EXPresolve( v->initializer, entity, v->type ); + if(v->initializer) { + EXPresolve(v->initializer, entity, v->type); - if( is_resolve_failed( v->initializer ) ) { - resolve_failed( v->name ); + if(is_resolve_failed(v->initializer)) { + resolve_failed(v->name); } } } @@ -578,48 +585,49 @@ void VAR_resolve_expressions( Variable v, Entity entity /* was scope */ ) { ** ** Resolve all references in a variable definition. */ -void VAR_resolve_types( Variable v ) { +void VAR_resolve_types(Variable v) +{ int failed = 0; - TYPEresolve( &v->type ); - failed = is_resolve_failed( v->type ); + TYPEresolve(&v->type); + failed = is_resolve_failed(v->type); - if( v->inverse_symbol && ( !v->inverse_attribute ) ) { + if(v->inverse_symbol && (!v->inverse_attribute)) { /* resolve inverse */ Variable attr; Type type = v->type; - if( TYPEis_aggregate( type ) ) { + if(TYPEis_aggregate(type)) { /* pull entity out of aggregate type defn for ... */ /* inverse var: set (or bag) of entity for ...; */ type = type->u.type->body->base; } - if( type->u.type->body->type != entity_ ) { + if(type->u.type->body->type != entity_) { ERRORreport_with_symbol(INVERSE_BAD_ENTITY, - &v->name->symbol, v->inverse_symbol->name ); + &v->name->symbol, v->inverse_symbol->name); } else { - attr = VARfind( type->u.type->body->entity, v->inverse_symbol->name, 1 ); - if( attr ) { + attr = VARfind(type->u.type->body->entity, v->inverse_symbol->name, 1); + if(attr) { v->inverse_attribute = attr; - failed |= is_resolve_failed( attr->name ); + failed |= is_resolve_failed(attr->name); } else { ERRORreport_with_symbol(INVERSE_BAD_ATTR, - v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name ); + v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name); } } /* symbol is no longer used here and could be gc'd */ /* but keep around anyway for ease in later reconstruction */ } - if( failed ) { - resolve_failed( v->name ); + if(failed) { + resolve_failed(v->name); } /* note: cannot set resolved bit since it has to be resolved again */ /* by VAR_resolve_expressions later on */ #if 0 else { - resolved_all( v->name ); + resolved_all(v->name); } #endif } @@ -631,9 +639,10 @@ void VAR_resolve_types( Variable v ) { ** Resolve all references in a statement. */ -void STMTlist_resolve( Linked_List list, Scope scope ) { - LISTdo( list, s, Statement ) - STMTresolve( s, scope ); +void STMTlist_resolve(Linked_List list, Scope scope) +{ + LISTdo(list, s, Statement) + STMTresolve(s, scope); LISTod; } @@ -644,98 +653,100 @@ void STMTlist_resolve( Linked_List list, Scope scope ) { * * Resolve all references in a case item */ -void CASE_ITresolve( Case_Item item, Scope scope, Statement statement ) { +void CASE_ITresolve(Case_Item item, Scope scope, Statement statement) +{ int validLabels = 0; - LISTdo( item->labels, e, Expression ) { - EXPresolve( e, scope, statement->u.Case->selector->return_type ); - if( e->return_type != Type_Bad ) { + LISTdo(item->labels, e, Expression) { + EXPresolve(e, scope, statement->u.Case->selector->return_type); + if(e->return_type != Type_Bad) { validLabels++; } } LISTod; - if( validLabels ) { - STMTresolve( item->action, scope ); + if(validLabels) { + STMTresolve(item->action, scope); } } -void STMTresolve( Statement statement, Scope scope ) { +void STMTresolve(Statement statement, Scope scope) +{ /* scope is always the function/procedure/rule from SCOPEresolve_expressions_statements(); */ Scope proc; - if( !statement ) { + if(!statement) { return; /* could be null statement */ } - switch( statement->type ) { + switch(statement->type) { case STMT_ALIAS: - EXPresolve( statement->u.alias->variable->initializer, scope, Type_Dont_Care ); + EXPresolve(statement->u.alias->variable->initializer, scope, Type_Dont_Care); statement->u.alias->variable->type = statement->u.alias->variable->initializer->type; - if( !is_resolve_failed( statement->u.alias->variable->initializer ) ) { - STMTlist_resolve( statement->u.alias->statements, statement->u.alias->scope ); + if(!is_resolve_failed(statement->u.alias->variable->initializer)) { + STMTlist_resolve(statement->u.alias->statements, statement->u.alias->scope); } break; case STMT_ASSIGN: - EXPresolve( statement->u.assign->lhs, scope, Type_Dont_Care ); - EXPresolve( statement->u.assign->rhs, scope, statement->u.assign->lhs->type ); + EXPresolve(statement->u.assign->lhs, scope, Type_Dont_Care); + EXPresolve(statement->u.assign->rhs, scope, statement->u.assign->lhs->type); break; case STMT_CASE: - EXPresolve( statement->u.Case->selector, scope, Type_Dont_Care ); - LISTdo( statement->u.Case->cases, c, Case_Item ) { - CASE_ITresolve( c, scope, statement ); + EXPresolve(statement->u.Case->selector, scope, Type_Dont_Care); + LISTdo(statement->u.Case->cases, c, Case_Item) { + CASE_ITresolve(c, scope, statement); } LISTod; break; case STMT_COMPOUND: - STMTlist_resolve( statement->u.compound->statements, scope ); + STMTlist_resolve(statement->u.compound->statements, scope); break; case STMT_COND: - EXPresolve( statement->u.cond->test, scope, Type_Dont_Care ); - STMTlist_resolve( statement->u.cond->code, scope ); - if( statement->u.cond->otherwise ) { - STMTlist_resolve( statement->u.cond->otherwise, scope ); + EXPresolve(statement->u.cond->test, scope, Type_Dont_Care); + STMTlist_resolve(statement->u.cond->code, scope); + if(statement->u.cond->otherwise) { + STMTlist_resolve(statement->u.cond->otherwise, scope); } break; case STMT_PCALL: #define proc_name statement->symbol.name - proc = ( Scope )SCOPEfind( scope, proc_name, - SCOPE_FIND_PROCEDURE ); - if( proc ) { - if( DICT_type != OBJ_PROCEDURE ) { - Symbol * newsym = OBJget_symbol( proc, DICT_type ); - ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line ); + proc = (Scope)SCOPEfind(scope, proc_name, + SCOPE_FIND_PROCEDURE); + if(proc) { + if(DICT_type != OBJ_PROCEDURE) { + Symbol *newsym = OBJget_symbol(proc, DICT_type); + ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line); } else { statement->u.proc->procedure = proc; } } else { - ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name ); + ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name); } - LISTdo( statement->u.proc->parameters, e, Expression ) - EXPresolve( e, scope, Type_Dont_Care ); + LISTdo(statement->u.proc->parameters, e, Expression) + EXPresolve(e, scope, Type_Dont_Care); LISTod; break; case STMT_LOOP: - if( statement->u.loop->scope ) { + if(statement->u.loop->scope) { /* resolve increment with old scope */ - EXPresolve( statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care ); - EXPresolve( statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care ); - EXPresolve( statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care ); + EXPresolve(statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care); + EXPresolve(statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care); + EXPresolve(statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care); /* resolve others with new scope! */ scope = statement->u.loop->scope; } - if( statement->u.loop->while_expr ) { - EXPresolve( statement->u.loop->while_expr, scope, Type_Dont_Care ); + if(statement->u.loop->while_expr) { + EXPresolve(statement->u.loop->while_expr, scope, Type_Dont_Care); } - if( statement->u.loop->until_expr ) { - EXPresolve( statement->u.loop->until_expr, scope, Type_Dont_Care ); + if(statement->u.loop->until_expr) { + EXPresolve(statement->u.loop->until_expr, scope, Type_Dont_Care); } - STMTlist_resolve( statement->u.loop->statements, scope ); + STMTlist_resolve(statement->u.loop->statements, scope); break; case STMT_RETURN: - if( statement->u.ret->value ) { - EXPresolve( statement->u.ret->value, scope, Type_Dont_Care ); + if(statement->u.ret->value) { + EXPresolve(statement->u.ret->value, scope, Type_Dont_Care); } break; case STMT_SKIP: @@ -745,83 +756,87 @@ void STMTresolve( Statement statement, Scope scope ) { } } -static Variable ENTITY_get_local_attribute( Entity e, char * name ) { - LISTdo( e->u.entity->attributes, a, Variable ) - if( !strcmp( VARget_simple_name( a ), name ) ) { +static Variable ENTITY_get_local_attribute(Entity e, char *name) +{ + LISTdo(e->u.entity->attributes, a, Variable) + if(!strcmp(VARget_simple_name(a), name)) { return a; } LISTod; return 0; } -void ENTITYresolve_expressions( Entity e ) { +void ENTITYresolve_expressions(Entity e) +{ Variable v; int status = 0; DictionaryEntry de; - char * sname; + char *sname; Entity sup; - if( print_objects_while_running & OBJ_ENTITY_BITS ) { - fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name ); + if(print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name); } self = e->u.entity->type; - LISTdo( e->u.entity->attributes, attr, Variable ) { - if( attr->name->type->u.type->body->type == op_ ) { + LISTdo(e->u.entity->attributes, attr, Variable) { + if(attr->name->type->u.type->body->type == op_) { /* attribute redeclaration */ sname = attr->name->e.op1->e.op2->symbol.name; - if( !strcmp( sname, e->symbol.name ) || - !( sup = ENTITYfind_inherited_entity( e, sname, 0 ) ) ) { + if(!strcmp(sname, e->symbol.name) || + !(sup = ENTITYfind_inherited_entity(e, sname, 0))) { ERRORreport_with_symbol(REDECL_NO_SUCH_SUPERTYPE, &attr->name->e.op1->e.op2->symbol, attr->name->e.op1->e.op2->symbol.name, - VARget_simple_name( attr ) ); - resolve_failed( attr->name ); + VARget_simple_name(attr)); + resolve_failed(attr->name); } else { - sname = VARget_simple_name( attr ); - if( !ENTITY_get_local_attribute( sup, sname ) ) { + sname = VARget_simple_name(attr); + if(!ENTITY_get_local_attribute(sup, sname)) { ERRORreport_with_symbol(REDECL_NO_SUCH_ATTR, &attr->name->e.op2->symbol, sname, - sup->symbol.name ); - resolve_failed( attr->name ); + sup->symbol.name); + resolve_failed(attr->name); } /* should be ok to share this ptr */ attr->name->symbol.name = sname; } } else { /* new attribute declaration */ - LISTdo_n( e->u.entity->supertypes, supr, Entity, b ) { - if( ENTITYget_named_attribute( supr, - attr->name->symbol.name ) ) { - ERRORreport_with_symbol(OVERLOADED_ATTR, - &attr->name->symbol, - attr->name->symbol.name, - supr->symbol.name ); - resolve_failed( attr->name ); - } - } LISTod; + LISTdo_n(e->u.entity->supertypes, supr, Entity, b) { + if(ENTITYget_named_attribute(supr, + attr->name->symbol.name)) { + ERRORreport_with_symbol(OVERLOADED_ATTR, + &attr->name->symbol, + attr->name->symbol.name, + supr->symbol.name); + resolve_failed(attr->name); + } + } + LISTod; } - VARresolve_expressions( attr, e ); - status |= is_resolve_failed( attr->name ); - } LISTod; - - DICTdo_type_init( e->symbol_table, &de, OBJ_VARIABLE ); - while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { - if( !is_resolve_failed( v->name ) ) { - TYPEresolve_expressions( v->type, e ); - if( v->initializer ) { - EXPresolve( v->initializer, e, v->type ); - status |= is_resolve_failed( v->initializer ); + VARresolve_expressions(attr, e); + status |= is_resolve_failed(attr->name); + } + LISTod; + + DICTdo_type_init(e->symbol_table, &de, OBJ_VARIABLE); + while(0 != (v = (Variable)DICTdo(&de))) { + if(!is_resolve_failed(v->name)) { + TYPEresolve_expressions(v->type, e); + if(v->initializer) { + EXPresolve(v->initializer, e, v->type); + status |= is_resolve_failed(v->initializer); } } else { status = RESOLVE_FAILED; } } - if( !WHEREresolve( e->where, e, 1 ) ) { + if(!WHEREresolve(e->where, e, 1)) { status = RESOLVE_FAILED; } @@ -832,80 +847,87 @@ void ENTITYresolve_expressions( Entity e ) { -void ENTITYcheck_missing_supertypes( Entity ent ) { +void ENTITYcheck_missing_supertypes(Entity ent) +{ int found; /* Make sure each of my subtypes lists me as a supertype */ - LISTdo( ent->u.entity->subtypes, sub, Entity ) { + LISTdo(ent->u.entity->subtypes, sub, Entity) { found = false; - LISTdo_n( sub->u.entity->supertypes, sup, Entity, b ) { - if( sup == ent ) { + LISTdo_n(sub->u.entity->supertypes, sup, Entity, b) { + if(sup == ent) { found = true; break; } - } LISTod; - if( !found ) { - ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name ); - resolve_failed( sub ); } - } LISTod; + LISTod; + if(!found) { + ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name); + resolve_failed(sub); + } + } + LISTod; } /** calculate number of attributes inheritance, following up superclass chain */ -void ENTITYcalculate_inheritance( Entity e ) { +void ENTITYcalculate_inheritance(Entity e) +{ e->u.entity->inheritance = 0; - LISTdo( e->u.entity->supertypes, super, Entity ) { - if( super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED ) { - ENTITYcalculate_inheritance( super ); + LISTdo(e->u.entity->supertypes, super, Entity) { + if(super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED) { + ENTITYcalculate_inheritance(super); } - e->u.entity->inheritance += ENTITYget_size( super ); + e->u.entity->inheritance += ENTITYget_size(super); } LISTod } /** returns 1 if entity is involved in circularity, else 0 */ -int ENTITY_check_subsuper_cyclicity( Entity e, Entity enew ) { +int ENTITY_check_subsuper_cyclicity(Entity e, Entity enew) +{ /* just check subtypes - this implicitly checks supertypes */ /* as well */ - LISTdo( enew->u.entity->subtypes, sub, Entity ) - if( e == sub ) { - ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name ); + LISTdo(enew->u.entity->subtypes, sub, Entity) + if(e == sub) { + ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name); return 1; } - if( sub->search_id == __SCOPE_search_id ) { + if(sub->search_id == __SCOPE_search_id) { return 0; } sub->search_id = __SCOPE_search_id; - if( ENTITY_check_subsuper_cyclicity( e, sub ) ) { - ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name ); + if(ENTITY_check_subsuper_cyclicity(e, sub)) { + ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name); return 1; } LISTod; return 0; } -void ENTITYcheck_subsuper_cyclicity( Entity e ) { +void ENTITYcheck_subsuper_cyclicity(Entity e) +{ __SCOPE_search_id++; - ( void ) ENTITY_check_subsuper_cyclicity( e, e ); + (void) ENTITY_check_subsuper_cyclicity(e, e); } /** returns 1 if select type is involved in circularity, else 0 */ -int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { - LISTdo( tnew->u.type->body->list, item, Type ) - if( item->u.type->body->type == select_ ) { - if( tb == item->u.type->body ) { +int TYPE_check_select_cyclicity(TypeBody tb, Type tnew) +{ + LISTdo(tnew->u.type->body->list, item, Type) + if(item->u.type->body->type == select_) { + if(tb == item->u.type->body) { ERRORreport_with_symbol(SELECT_LOOP, - &item->symbol, item->symbol.name ); + &item->symbol, item->symbol.name); return 1; } - if( item->search_id == __SCOPE_search_id ) { + if(item->search_id == __SCOPE_search_id) { return 0; } item->search_id = __SCOPE_search_id; - if( TYPE_check_select_cyclicity( tb, item ) ) { + if(TYPE_check_select_cyclicity(tb, item)) { ERRORreport_with_symbol(SELECT_CONTINUATION, - &item->symbol, item->symbol.name ); + &item->symbol, item->symbol.name); return 1; } } @@ -913,112 +935,115 @@ int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { return 0; } -void TYPEcheck_select_cyclicity( Type t ) { - if( t->u.type->body->type == select_ ) { +void TYPEcheck_select_cyclicity(Type t) +{ + if(t->u.type->body->type == select_) { __SCOPE_search_id++; - ( void ) TYPE_check_select_cyclicity( t->u.type->body, t ); + (void) TYPE_check_select_cyclicity(t->u.type->body, t); } } -void ENTITYresolve_types( Entity e ); +void ENTITYresolve_types(Entity e); /** also resolves inheritance counts and sub/super consistency */ -void SCOPEresolve_types( Scope s ) { +void SCOPEresolve_types(Scope s) +{ Variable var; DictionaryEntry de; void *x; - if( print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits( s->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type( s->type ) ); + if(print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits(s->type)) { + fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type(s->type)); } - DICTdo_init( s->symbol_table, &de ); - while( 0 != ( x = DICTdo( &de ) ) ) { - switch( DICT_type ) { + DICTdo_init(s->symbol_table, &de); + while(0 != (x = DICTdo(&de))) { + switch(DICT_type) { case OBJ_TYPE: - if( ERRORis_enabled( SELECT_LOOP ) ) { - TYPEcheck_select_cyclicity( ( Type )x ); + if(ERRORis_enabled(SELECT_LOOP)) { + TYPEcheck_select_cyclicity((Type)x); } break; case OBJ_VARIABLE: /* really constants */ - var = ( Variable )x; + var = (Variable)x; /* before OBJ_BITS hack, we looked in s->superscope */ - TYPEresolve( &var->type ); - if( is_resolve_failed( var->type ) ) { - resolve_failed( var->name ); - resolve_failed( s ); + TYPEresolve(&var->type); + if(is_resolve_failed(var->type)) { + resolve_failed(var->name); + resolve_failed(s); } break; case OBJ_ENTITY: - ENTITYcheck_missing_supertypes( ( Entity )x ); - ENTITYresolve_types( ( Entity )x ); - ENTITYcalculate_inheritance( ( Entity )x ); - if( ERRORis_enabled( SUBSUPER_LOOP ) ) { - ENTITYcheck_subsuper_cyclicity( ( Entity )x ); + ENTITYcheck_missing_supertypes((Entity)x); + ENTITYresolve_types((Entity)x); + ENTITYcalculate_inheritance((Entity)x); + if(ERRORis_enabled(SUBSUPER_LOOP)) { + ENTITYcheck_subsuper_cyclicity((Entity)x); } - if( is_resolve_failed( ( Entity )x ) ) { - resolve_failed( s ); + if(is_resolve_failed((Entity)x)) { + resolve_failed(s); } break; case OBJ_SCHEMA: - if( is_not_resolvable( ( Schema )x ) ) { + if(is_not_resolvable((Schema)x)) { break; } - /*FALLTHRU*/ + /*FALLTHRU*/ case OBJ_PROCEDURE: case OBJ_RULE: case OBJ_FUNCTION: - SCOPEresolve_types( ( Scope )x ); - if( is_resolve_failed( ( Scope )x ) ) { - resolve_failed( s ); + SCOPEresolve_types((Scope)x); + if(is_resolve_failed((Scope)x)) { + resolve_failed(s); } break; default: break; } } - if( s->type == OBJ_FUNCTION ) { - TYPEresolve( &s->u.func->return_type ); + if(s->type == OBJ_FUNCTION) { + TYPEresolve(&s->u.func->return_type); } } /** for each supertype, find the entity it refs to */ -void ENTITYresolve_supertypes( Entity e ) { +void ENTITYresolve_supertypes(Entity e) +{ Entity ref_entity; - if( print_objects_while_running & OBJ_ENTITY_BITS ) { - fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name ); + if(print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name); } - if( e->u.entity->supertype_symbols ) { + if(e->u.entity->supertype_symbols) { e->u.entity->supertypes = LISTcreate(); } #if 0 - if( e->u.entity->supertype_symbols && !e->u.entity->supertypes ) { + if(e->u.entity->supertype_symbols && !e->u.entity->supertypes) { e->u.entity->supertypes = LISTcreate(); } #endif - LISTdo( e->u.entity->supertype_symbols, sym, Symbol * ) { - ref_entity = ( Entity )SCOPEfind( e->superscope, sym->name, SCOPE_FIND_ENTITY ); - if( !ref_entity ) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name ); + LISTdo(e->u.entity->supertype_symbols, sym, Symbol *) { + ref_entity = (Entity)SCOPEfind(e->superscope, sym->name, SCOPE_FIND_ENTITY); + if(!ref_entity) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name); /* ENTITY_resolve_failed = 1;*/ - resolve_failed( e ); - } else if( DICT_type != OBJ_ENTITY ) { - Symbol * newsym = OBJget_symbol( ref_entity, DICT_type ); - ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line ); + resolve_failed(e); + } else if(DICT_type != OBJ_ENTITY) { + Symbol *newsym = OBJget_symbol(ref_entity, DICT_type); + ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line); /* ENTITY_resolve_failed = 1;*/ - resolve_failed( e ); + resolve_failed(e); } else { bool found = false; - LISTadd_last( e->u.entity->supertypes, ref_entity ); - if( is_resolve_failed( ref_entity ) ) { - resolve_failed( e ); + LISTadd_last(e->u.entity->supertypes, ref_entity); + if(is_resolve_failed(ref_entity)) { + resolve_failed(e); } /* If the user said there was a supertype relationship but */ @@ -1026,33 +1051,36 @@ void ENTITYresolve_supertypes( Entity e ) { /* force it to be explicitly known by listing this entity */ /* in the ref'd entity's subtype list */ - LISTdo_n( ref_entity->u.entity->subtypes, sub, Entity, b ) { - if( sub == e ) { + LISTdo_n(ref_entity->u.entity->subtypes, sub, Entity, b) { + if(sub == e) { found = true; break; } - } LISTod - if( !found ) { - if( !ref_entity->u.entity->subtypes ) { + } + LISTod + if(!found) { + if(!ref_entity->u.entity->subtypes) { ref_entity->u.entity->subtypes = LISTcreate(); } - LISTadd_last( ref_entity->u.entity->subtypes, e ); + LISTadd_last(ref_entity->u.entity->subtypes, e); } } - } LISTod; + } + LISTod; } -void ENTITYresolve_subtypes( Entity e ) { +void ENTITYresolve_subtypes(Entity e) +{ int i; - if( print_objects_while_running & OBJ_ENTITY_BITS ) { - fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name ); + if(print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name); } - i = ENTITYresolve_subtype_expression( e->u.entity->subtype_expression, e, &e->u.entity->subtypes ); - if( i & RESOLVE_FAILED ) { - resolve_failed( e ); + i = ENTITYresolve_subtype_expression(e->u.entity->subtype_expression, e, &e->u.entity->subtypes); + if(i & RESOLVE_FAILED) { + resolve_failed(e); } } @@ -1062,80 +1090,86 @@ void ENTITYresolve_subtypes( Entity e ) { * where ref'd_attrs are either simple ids or SELF\entity.attr * where "entity" represents a supertype (only, I believe) */ -void ENTITYresolve_uniques( Entity e ) { +void ENTITYresolve_uniques(Entity e) +{ Variable attr, attr2 = 0; int failed = 0; - LISTdo( e->u.entity->unique, unique, Linked_List ) { + LISTdo(e->u.entity->unique, unique, Linked_List) { int i = 0; - LISTdo_links( unique, reflink ) { + LISTdo_links(unique, reflink) { Type old_self = self; Expression expr; /* skip first which is always the label (or NULL if no label) */ i++; - if( i == 1 ) { + if(i == 1) { continue; } - expr = ( Expression ) reflink->data; - assert( expr ); + expr = (Expression) reflink->data; + assert(expr); self = e->u.entity->type; - EXPresolve( expr, e, Type_Dont_Care ); + EXPresolve(expr, e, Type_Dont_Care); self = old_self; /* SELF\entity.attr, or just an attr name? */ - if( ( expr->e.op_code == OP_DOT ) && - ( expr->e.op1->e.op_code == OP_GROUP ) && - ( expr->e.op1->e.op1->type == Type_Self ) ) { - attr = ENTITYresolve_attr_ref( e, &( expr->e.op1->e.op2->symbol ), &( expr->e.op2->symbol ) ); - attr2 = ENTITYresolve_attr_ref( e, 0, &( expr->e.op2->symbol ) ); + if((expr->e.op_code == OP_DOT) && + (expr->e.op1->e.op_code == OP_GROUP) && + (expr->e.op1->e.op1->type == Type_Self)) { + attr = ENTITYresolve_attr_ref(e, &(expr->e.op1->e.op2->symbol), &(expr->e.op2->symbol)); + attr2 = ENTITYresolve_attr_ref(e, 0, &(expr->e.op2->symbol)); } else { - attr = ENTITYresolve_attr_ref( e, 0, &( expr->symbol ) ); + attr = ENTITYresolve_attr_ref(e, 0, &(expr->symbol)); } - if( ( attr2 ) && ( attr != attr2 ) && ( ENTITYdeclares_variable( e, attr2 ) ) ) { + if((attr2) && (attr != attr2) && (ENTITYdeclares_variable(e, attr2))) { /* attr exists in type + supertype - it's a redeclaration. * in this case, qualifiers are unnecessary; print a warning */ - ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &( expr->e.op2->symbol ), expr->e.op2->symbol.name, e->symbol.name ); + ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &(expr->e.op2->symbol), expr->e.op2->symbol.name, e->symbol.name); } - if( !attr ) { + if(!attr) { /* ERRORreport_with_symbol(ERROR_unknown_attr_in_entity,*/ /* aref->attribute, aref->attribute->name,*/ /* e->symbol.name);*/ failed = RESOLVE_FAILED; continue; } - if( ENTITYdeclares_variable( e, attr ) ) { + if(ENTITYdeclares_variable(e, attr)) { attr->flags.unique = 1; } - } LISTod; - } LISTod; + } + LISTod; + } + LISTod; e->symbol.resolved |= failed; } -void ENTITYresolve_types( Entity e ) { +void ENTITYresolve_types(Entity e) +{ int failed = 0; - if( print_objects_while_running & OBJ_ENTITY_BITS ) { - fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name ); + if(print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name); } - LISTdo( e->u.entity->attributes, att, Variable ) { + LISTdo(e->u.entity->attributes, att, Variable) { /* resolve in context of superscope to allow "X : X;" */ - VARresolve_types( att ); - failed |= is_resolve_failed( att->name ); - } LISTod; + VARresolve_types(att); + failed |= is_resolve_failed(att->name); + } + LISTod; /* * resolve the 'unique' list */ - ENTITYresolve_uniques( e ); + ENTITYresolve_uniques(e); /* don't wipe out any previous failure stat */ e->symbol.resolved |= failed; } /** resolve all expressions in type definitions */ -void TYPEresolve_expressions( Type t, Scope s ) { +void TYPEresolve_expressions(Type t, Scope s) +{ TypeBody body; /* meaning of self in a type declaration refers to the type itself, so */ @@ -1144,67 +1178,69 @@ void TYPEresolve_expressions( Type t, Scope s ) { self = t; /* recurse through base types */ - for( ;; t = body->base ) { - if( t->where ) { - ( void )WHEREresolve( t->where, s, 1 ); + for(;; t = body->base) { + if(t->where) { + (void)WHEREresolve(t->where, s, 1); } /* reached an indirect type definition, resolved elsewhere */ - if( t->u.type->head ) { + if(t->u.type->head) { break; } - if( !TYPEis_aggregate( t ) ) { + if(!TYPEis_aggregate(t)) { break; } body = t->u.type->body; - if( body->upper ) { - EXPresolve( body->upper, s, Type_Dont_Care ); + if(body->upper) { + EXPresolve(body->upper, s, Type_Dont_Care); } - if( body->lower ) { - EXPresolve( body->lower, s, Type_Dont_Care ); + if(body->lower) { + EXPresolve(body->lower, s, Type_Dont_Care); } - if( body->precision ) { - EXPresolve( body->precision, s, Type_Dont_Care ); + if(body->precision) { + EXPresolve(body->precision, s, Type_Dont_Care); } } self = self_old; } -int WHEREresolve( Linked_List list, Scope scope, int need_self ) { +int WHEREresolve(Linked_List list, Scope scope, int need_self) +{ int status = 0; - LISTdo( list, w, Where ) + LISTdo(list, w, Where) /* check if we've been here before */ /* i'm not sure why, but it happens */ status |= w->label->resolved; - if( w->label->resolved & ( RESOLVED | RESOLVE_FAILED ) ) { + if(w->label->resolved & (RESOLVED | RESOLVE_FAILED)) { break; } found_self = false; - EXPresolve( w->expr, scope, Type_Dont_Care ); - if( need_self && ! found_self ) { + EXPresolve(w->expr, scope, Type_Dont_Care); + if(need_self && ! found_self) { ERRORreport_with_symbol(MISSING_SELF, - w->label, - w->label->name ); + w->label, + w->label->name); w->label->resolved = RESOLVE_FAILED; } else { w->label->resolved = RESOLVED; } status |= w->label->resolved; LISTod - if( status == RESOLVE_FAILED ) { + if(status == RESOLVE_FAILED) { return 0; } else { return 1; } } -struct tag * TAGcreate_tags() { +struct tag *TAGcreate_tags() +{ extern int tag_count; - return( ( struct tag * )calloc( tag_count, sizeof( struct tag ) ) ); + return((struct tag *)calloc(tag_count, sizeof(struct tag))); } diff --git a/src/express/resolve2.c b/src/express/resolve2.c index bd5518595..e00e50e3c 100644 --- a/src/express/resolve2.c +++ b/src/express/resolve2.c @@ -7,89 +7,91 @@ #include "express/schema.h" #include "express/resolve.h" -void SCOPEresolve_subsupers( Scope scope ) { +void SCOPEresolve_subsupers(Scope scope) +{ DictionaryEntry de; void *x; char type; - Symbol * sym; + Symbol *sym; Type t; - if( print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits( scope->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - scope->symbol.name, OBJget_type( scope->type ) ); + if(print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits(scope->type)) { + fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, + scope->symbol.name, OBJget_type(scope->type)); } - DICTdo_init( scope->symbol_table, &de ); - while( 0 != ( x = DICTdo( &de ) ) ) { - switch( type = DICT_type ) { + DICTdo_init(scope->symbol_table, &de); + while(0 != (x = DICTdo(&de))) { + switch(type = DICT_type) { case OBJ_ENTITY: - ENTITYresolve_supertypes( ( Entity )x ); - ENTITYresolve_subtypes( ( Entity )x ); + ENTITYresolve_supertypes((Entity)x); + ENTITYresolve_subtypes((Entity)x); break; case OBJ_FUNCTION: case OBJ_PROCEDURE: case OBJ_RULE: - SCOPEresolve_subsupers( ( Scope )x ); + SCOPEresolve_subsupers((Scope)x); break; case OBJ_TYPE: - t = ( Type )x; - TYPEresolve( &t ); + t = (Type)x; + TYPEresolve(&t); break; default: /* ignored everything else */ break; } - sym = OBJget_symbol( x, type ); - if( is_resolve_failed_raw( sym ) ) { - resolve_failed( scope ); + sym = OBJget_symbol(x, type); + if(is_resolve_failed_raw(sym)) { + resolve_failed(scope); } } } -void SCOPEresolve_expressions_statements( Scope s ) { +void SCOPEresolve_expressions_statements(Scope s) +{ DictionaryEntry de; void *x; Variable v; - if( print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits( s->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type( s->type ) ); + if(print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits(s->type)) { + fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type(s->type)); } - DICTdo_init( s->symbol_table, &de ); - while( 0 != ( x = DICTdo( &de ) ) ) { - switch( DICT_type ) { + DICTdo_init(s->symbol_table, &de); + while(0 != (x = DICTdo(&de))) { + switch(DICT_type) { case OBJ_SCHEMA: - if( is_not_resolvable( ( Schema )x ) ) { + if(is_not_resolvable((Schema)x)) { break; } - SCOPEresolve_expressions_statements( ( Scope )x ); + SCOPEresolve_expressions_statements((Scope)x); break; case OBJ_ENTITY: - ENTITYresolve_expressions( ( Entity )x ); + ENTITYresolve_expressions((Entity)x); break; case OBJ_FUNCTION: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.func->body ); + ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.func->body); break; case OBJ_PROCEDURE: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.proc->body ); + ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.proc->body); break; case OBJ_RULE: - ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.rule->body ); + ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.rule->body); - WHEREresolve( RULEget_where( ( Scope )x ), ( Scope )x, 0 ); + WHEREresolve(RULEget_where((Scope)x), (Scope)x, 0); break; case OBJ_VARIABLE: - v = ( Variable )x; - TYPEresolve_expressions( v->type, s ); - if( v->initializer ) { - EXPresolve( v->initializer, s, v->type ); + v = (Variable)x; + TYPEresolve_expressions(v->type, s); + if(v->initializer) { + EXPresolve(v->initializer, s, v->type); } break; case OBJ_TYPE: - TYPEresolve_expressions( ( Type )x, s ); + TYPEresolve_expressions((Type)x, s); break; default: /* ignored everything else */ @@ -98,17 +100,18 @@ void SCOPEresolve_expressions_statements( Scope s ) { } } -void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { +void ALGresolve_expressions_statements(Scope s, Linked_List statements) +{ int status = 0; - if( print_objects_while_running & OBJ_ALGORITHM_BITS & - OBJget_bits( s->type ) ) { - fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type( s->type ) ); + if(print_objects_while_running & OBJ_ALGORITHM_BITS & + OBJget_bits(s->type)) { + fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type(s->type)); } - SCOPEresolve_expressions_statements( s ); - STMTlist_resolve( statements, s ); + SCOPEresolve_expressions_statements(s); + STMTlist_resolve(statements, s); s->symbol.resolved = status; } diff --git a/src/express/schema.c b/src/express/schema.c index 5dd77873a..7fc3d6899 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -53,7 +53,8 @@ int __SCOPE_search_id = 0; /** Initialize the Schema module. */ -void SCHEMAinitialize( void ) { +void SCHEMAinitialize(void) +{ } @@ -73,116 +74,125 @@ void SCHEMAinitialize( void ) { */ void -SCHEMAdump( Schema schema, FILE * file ) { - fprintf( file, "SCHEMA %s:\n", SCHEMAget_name( schema ) ); - SCOPEdump( schema, file ); - fprintf( file, "END SCHEMA %s\n\n", SCHEMAget_name( schema ) ); +SCHEMAdump(Schema schema, FILE *file) +{ + fprintf(file, "SCHEMA %s:\n", SCHEMAget_name(schema)); + SCOPEdump(schema, file); + fprintf(file, "END SCHEMA %s\n\n", SCHEMAget_name(schema)); } #endif #if 0 -SYMBOLprint( Symbol * s ) { - fprintf( stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename ); +SYMBOLprint(Symbol *s) +{ + fprintf(stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename); } #endif -void SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { - Rename * r = REN_new(); +void SCHEMAadd_reference(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) +{ + Rename *r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = ref; - if( !cur_schema->u.schema->reflist ) { + if(!cur_schema->u.schema->reflist) { cur_schema->u.schema->reflist = LISTcreate(); } - LISTadd_last( cur_schema->u.schema->reflist, r ); + LISTadd_last(cur_schema->u.schema->reflist, r); } -void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { - Rename * r = REN_new(); +void SCHEMAadd_use(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) +{ + Rename *r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = use; - if( !cur_schema->u.schema->uselist ) { + if(!cur_schema->u.schema->uselist) { cur_schema->u.schema->uselist = LISTcreate(); } - LISTadd_last( cur_schema->u.schema->uselist, r ); + LISTadd_last(cur_schema->u.schema->uselist, r); } -void SCHEMAdefine_reference( Schema schema, Rename * r ) { - Rename * old = 0; - char * name = ( r->nnew ? r->nnew : r->old )->name; +void SCHEMAdefine_reference(Schema schema, Rename *r) +{ + Rename *old = 0; + char *name = (r->nnew ? r->nnew : r->old)->name; - if( !schema->u.schema->refdict ) { - schema->u.schema->refdict = DICTcreate( 20 ); + if(!schema->u.schema->refdict) { + schema->u.schema->refdict = DICTcreate(20); } else { - old = ( Rename * )DICTlookup( schema->u.schema->refdict, name ); + old = (Rename *)DICTlookup(schema->u.schema->refdict, name); } - if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { - DICTdefine( schema->u.schema->refdict, name, - r, r->old, OBJ_RENAME ); + if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { + DICTdefine(schema->u.schema->refdict, name, + r, r->old, OBJ_RENAME); } } -void SCHEMAdefine_use( Schema schema, Rename * r ) { - Rename * old = 0; - char * name = ( r->nnew ? r->nnew : r->old )->name; +void SCHEMAdefine_use(Schema schema, Rename *r) +{ + Rename *old = 0; + char *name = (r->nnew ? r->nnew : r->old)->name; - if( !schema->u.schema->usedict ) { - schema->u.schema->usedict = DICTcreate( 20 ); + if(!schema->u.schema->usedict) { + schema->u.schema->usedict = DICTcreate(20); } else { - old = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); + old = (Rename *)DICTlookup(schema->u.schema->usedict, name); } - if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { - DICTdefine( schema->u.schema->usedict, name, - r, r->old, OBJ_RENAME ); + if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { + DICTdefine(schema->u.schema->usedict, name, + r, r->old, OBJ_RENAME); } } -static void SCHEMA_get_entities_use( Scope scope, Linked_List result ) { +static void SCHEMA_get_entities_use(Scope scope, Linked_List result) +{ DictionaryEntry de; - Rename * rename; + Rename *rename; - if( scope->search_id == __SCOPE_search_id ) { + if(scope->search_id == __SCOPE_search_id) { return; } scope->search_id = __SCOPE_search_id; /* fully USE'd schema */ - LISTdo( scope->u.schema->use_schemas, schema, Schema ) - SCOPE_get_entities( schema, result ); - SCHEMA_get_entities_use( schema, result ); + LISTdo(scope->u.schema->use_schemas, schema, Schema) + SCOPE_get_entities(schema, result); + SCHEMA_get_entities_use(schema, result); LISTod /* partially USE'd schema */ - if( scope->u.schema->usedict ) { - DICTdo_init( scope->u.schema->usedict, &de ); - while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { - LISTadd_last( result, rename->object ); + if(scope->u.schema->usedict) { + DICTdo_init(scope->u.schema->usedict, &de); + while(0 != (rename = (Rename *)DICTdo(&de))) { + LISTadd_last(result, rename->object); } } } /** return use'd entities */ -Linked_List SCHEMAget_entities_use( Scope scope ) { +Linked_List SCHEMAget_entities_use(Scope scope) +{ Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_use( scope, result ); - return( result ); + SCHEMA_get_entities_use(scope, result); + return(result); } /** return ref'd entities */ -void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { - Rename * rename; +void SCHEMA_get_entities_ref(Scope scope, Linked_List result) +{ + Rename *rename; DictionaryEntry de; - if( scope->search_id == __SCOPE_search_id ) { + if(scope->search_id == __SCOPE_search_id) { return; } scope->search_id = __SCOPE_search_id; @@ -190,45 +200,47 @@ void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { ENTITY_MARK++; /* fully REF'd schema */ - LISTdo( scope->u.schema->ref_schemas, schema, Schema ) - SCOPE_get_entities( schema, result ); + LISTdo(scope->u.schema->ref_schemas, schema, Schema) + SCOPE_get_entities(schema, result); /* don't go down remote schema's ref_schemas */ LISTod /* partially REF'd schema */ - DICTdo_init( scope->u.schema->refdict, &de ); - while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { - if( DICT_type == OBJ_ENTITY ) { - LISTadd_last( result, rename->object ); + DICTdo_init(scope->u.schema->refdict, &de); + while(0 != (rename = (Rename *)DICTdo(&de))) { + if(DICT_type == OBJ_ENTITY) { + LISTadd_last(result, rename->object); } } } /** return ref'd entities */ -Linked_List SCHEMAget_entities_ref( Scope scope ) { +Linked_List SCHEMAget_entities_ref(Scope scope) +{ Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_ref( scope, result ); - return( result ); + SCHEMA_get_entities_ref(scope, result); + return(result); } /** * look up an attribute reference * if strict false, anything can be returned, not just attributes */ -Variable VARfind( Scope scope, char * name, int strict ) { +Variable VARfind(Scope scope, char *name, int strict) +{ Variable result; /* first look up locally */ - switch( scope->type ) { + switch(scope->type) { case OBJ_ENTITY: - result = ENTITYfind_inherited_attribute( scope, name, 0 ); - if( result ) { - if( strict && ( DICT_type != OBJ_VARIABLE ) ) { - fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); + result = ENTITYfind_inherited_attribute(scope, name, 0); + if(result) { + if(strict && (DICT_type != OBJ_VARIABLE)) { + fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); } return result; } @@ -236,14 +248,14 @@ Variable VARfind( Scope scope, char * name, int strict ) { case OBJ_INCREMENT: case OBJ_QUERY: case OBJ_ALIAS: - result = ( Variable )DICTlookup( scope->symbol_table, name ); - if( result ) { - if( strict && ( DICT_type != OBJ_VARIABLE ) ) { - fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); + result = (Variable)DICTlookup(scope->symbol_table, name); + if(result) { + if(strict && (DICT_type != OBJ_VARIABLE)) { + fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); } return result; } - return( VARfind( scope->superscope, name, strict ) ); + return(VARfind(scope->superscope, name, strict)); } return 0; } diff --git a/src/express/scope.c b/src/express/scope.c index 3d93509d7..f9193e6c5 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -43,62 +43,68 @@ #include "express/scope.h" #include "express/resolve.h" -void SCOPEinitialize( void ) { +void SCOPEinitialize(void) +{ } /** * \sa SCOPEget_entities() */ -void SCOPE_get_entities( Scope scope, Linked_List result ) { +void SCOPE_get_entities(Scope scope, Linked_List result) +{ DictionaryEntry de; void *x; - DICTdo_type_init( scope->symbol_table, &de, OBJ_ENTITY ); - while( 0 != ( x = DICTdo( &de ) ) ) { - LISTadd_last( result, x ); + DICTdo_type_init(scope->symbol_table, &de, OBJ_ENTITY); + while(0 != (x = DICTdo(&de))) { + LISTadd_last(result, x); } } /** * \sa SCOPEget_functions() */ -void SCOPE_get_functions( Scope scope, Linked_List result ) { +void SCOPE_get_functions(Scope scope, Linked_List result) +{ DictionaryEntry de; void *x; - DICTdo_type_init( scope->symbol_table, &de, OBJ_FUNCTION ); - while( 0 != ( x = DICTdo( &de ) ) ) { - LISTadd_last( result, x ); + DICTdo_type_init(scope->symbol_table, &de, OBJ_FUNCTION); + while(0 != (x = DICTdo(&de))) { + LISTadd_last(result, x); } } /** * \sa SCOPE_get_functions() */ -Linked_List SCOPEget_functions( Scope scope ) { +Linked_List SCOPEget_functions(Scope scope) +{ Linked_List result = LISTcreate(); - SCOPE_get_functions( scope, result ); - return( result ); + SCOPE_get_functions(scope, result); + return(result); } /** * \sa SCOPEget_rules() */ -void SCOPE_get_rules( Scope scope, Linked_List result ) { +void SCOPE_get_rules(Scope scope, Linked_List result) +{ DictionaryEntry de; void *x; - DICTdo_type_init( scope->symbol_table, &de, OBJ_RULE ); - while( 0 != ( x = DICTdo( &de ) ) ) { - LISTadd_last( result, x ); + DICTdo_type_init(scope->symbol_table, &de, OBJ_RULE); + while(0 != (x = DICTdo(&de))) { + LISTadd_last(result, x); } } /** * \sa SCOPE_get_rules() */ -Linked_List SCOPEget_rules( Scope scope ) { +Linked_List SCOPEget_rules(Scope scope) +{ Linked_List result = LISTcreate(); - SCOPE_get_rules( scope, result ); - return( result ); + SCOPE_get_rules(scope, result); + return(result); } @@ -112,28 +118,30 @@ Linked_List SCOPEget_rules( Scope scope ) { ** SCOPEget_entities_superclass_order(), and should be used whenever ** the order of the entities on the list is not important. */ -Linked_List SCOPEget_entities( Scope scope ) { +Linked_List SCOPEget_entities(Scope scope) +{ Linked_List result = LISTcreate(); - SCOPE_get_entities( scope, result ); - return( result ); + SCOPE_get_entities(scope, result); + return(result); } /** * \sa SCOPEget_entities_superclass_order() */ -void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { +void SCOPE_dfs(Dictionary symbols, Entity root, Linked_List result) +{ Entity ent; - if( ( ENTITYget_mark( root ) != ENTITY_MARK ) ) { - ENTITYput_mark( root, ENTITY_MARK ); - LISTdo( ENTITYget_supertypes( root ), super, Entity ) + if((ENTITYget_mark(root) != ENTITY_MARK)) { + ENTITYput_mark(root, ENTITY_MARK); + LISTdo(ENTITYget_supertypes(root), super, Entity) /* if super explicitly defined in scope, recurse. */ /* this chops out USEd and REFd entities */ - if( ( ent = ( Entity )DICTlookup( symbols, ENTITYget_name( super ) ) ) != ENTITY_NULL ) { - SCOPE_dfs( symbols, ent, result ); + if((ent = (Entity)DICTlookup(symbols, ENTITYget_name(super))) != ENTITY_NULL) { + SCOPE_dfs(symbols, ent, result); } LISTod - LISTadd_last( result, root ); + LISTadd_last(result, root); } } @@ -146,14 +154,15 @@ void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { ** \note The list returned is ordered such that an entity appears before all of its subtypes. ** \sa SCOPEget_entities() */ -Linked_List SCOPEget_entities_superclass_order( Scope scope ) { +Linked_List SCOPEget_entities_superclass_order(Scope scope) +{ Linked_List result; DictionaryEntry de; result = LISTcreate(); ++ENTITY_MARK; - SCOPEdo_entities( scope, e, de ) - SCOPE_dfs( scope->symbol_table, e, result ); + SCOPEdo_entities(scope, e, de) + SCOPE_dfs(scope->symbol_table, e, result); SCOPEod; return result; } @@ -163,19 +172,20 @@ Linked_List SCOPEget_entities_superclass_order( Scope scope ) { * note that object found is not actually checked, only because * caller is in a better position to describe the error with context */ -void *SCOPEfind( Scope scope, char * name, int type ) { +void *SCOPEfind(Scope scope, char *name, int type) +{ extern Dictionary EXPRESSbuiltins; /* procedures/functions */ void *x; __SCOPE_search_id++; - x = SCOPE_find( scope, name, type ); - if( x ) { + x = SCOPE_find(scope, name, type); + if(x) { return x; } - if( type & ( SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE ) ) { - x = DICTlookup( EXPRESSbuiltins, name ); + if(type & (SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE)) { + x = DICTlookup(EXPRESSbuiltins, name); } return x; } @@ -186,57 +196,58 @@ void *SCOPEfind( Scope scope, char * name, int type ) { * the supertype/subtype hierarchy * EH??? -> lookup an object when the current scope is not a schema */ -void *SCOPE_find( Scope scope, char * name, int type ) { +void *SCOPE_find(Scope scope, char *name, int type) +{ void *result; - Rename * rename; + Rename *rename; - if( scope->search_id == __SCOPE_search_id ) { + if(scope->search_id == __SCOPE_search_id) { return 0; } scope->search_id = __SCOPE_search_id; /* go up the superscopes, looking for object */ - while( 1 ) { + while(1) { /* first look up locally */ - result = DICTlookup( scope->symbol_table, name ); - if( result && OBJtype_is_oneof( DICT_type, type ) ) { + result = DICTlookup(scope->symbol_table, name); + if(result && OBJtype_is_oneof(DICT_type, type)) { return result; } - if( scope->type == OBJ_SCHEMA ) { + if(scope->type == OBJ_SCHEMA) { break; } scope = scope->superscope; } - if( type & ( SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE ) ) { + if(type & (SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE)) { /* Occurs in a fully USE'd schema? */ - LISTdo( scope->u.schema->use_schemas, schema, Schema ) + LISTdo(scope->u.schema->use_schemas, schema, Schema) /* follow chain'd USEs */ - if( schema == 0 ) { + if(schema == 0) { continue; } - result = SCOPE_find( schema, name, type ); - if( result ) { - return( result ); + result = SCOPE_find(schema, name, type); + if(result) { + return(result); } LISTod; /* Occurs in a partially USE'd schema? */ - rename = ( Rename * )DICTlookup( scope->u.schema->usedict, name ); - if( rename ) { + rename = (Rename *)DICTlookup(scope->u.schema->usedict, name); + if(rename) { DICT_type = rename->type; - return( rename->object ); + return(rename->object); } } /* Occurs in a fully REF'd schema? */ - LISTdo( scope->u.schema->ref_schemas, schema, Schema ) - if( schema == 0 ) { + LISTdo(scope->u.schema->ref_schemas, schema, Schema) + if(schema == 0) { continue; } - result = DICTlookup( schema->symbol_table, name ); - if( result ) { + result = DICTlookup(schema->symbol_table, name); + if(result) { return result; } else { continue; /* try another schema */ @@ -244,10 +255,10 @@ void *SCOPE_find( Scope scope, char * name, int type ) { LISTod; /* Occurs in a partially REF'd schema? */ - rename = ( Rename * )DICTlookup( scope->u.schema->refdict, name ); - if( rename ) { + rename = (Rename *)DICTlookup(scope->u.schema->refdict, name); + if(rename) { DICT_type = rename->type; - return( rename->object ); + return(rename->object); } return 0; diff --git a/src/express/stmt.c b/src/express/stmt.c index 7f1579f25..e5fd8ff5a 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -45,18 +45,20 @@ Statement STATEMENT_ESCAPE = STATEMENT_NULL; Statement STATEMENT_SKIP = STATEMENT_NULL; -Statement STMTcreate( int type ) { +Statement STMTcreate(int type) +{ Statement s; s = STMT_new(); - SYMBOLset( s ); + SYMBOLset(s); s->type = type; return s; } /** Initialize the Statement module. */ -void STMTinitialize( void ) { - STATEMENT_SKIP = STMTcreate( STMT_SKIP ); - STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE ); +void STMTinitialize(void) +{ + STATEMENT_SKIP = STMTcreate(STMT_SKIP); + STATEMENT_ESCAPE = STMTcreate(STMT_ESCAPE); } /** @@ -66,9 +68,10 @@ void STMTinitialize( void ) { ** ** Create and return an assignment statement. */ -Statement ASSIGNcreate( Expression lhs, Expression rhs ) { +Statement ASSIGNcreate(Expression lhs, Expression rhs) +{ Statement s; - s = STMTcreate( STMT_ASSIGN ); + s = STMTcreate(STMT_ASSIGN); s->u.assign = ASSIGN_new(); s->u.assign->lhs = lhs; s->u.assign->rhs = rhs; @@ -82,14 +85,15 @@ Statement ASSIGNcreate( Expression lhs, Expression rhs ) { ** ** Create and return a case statement. */ -Statement CASEcreate( Expression selector, Linked_List cases ) { +Statement CASEcreate(Expression selector, Linked_List cases) +{ Statement s; - s = STMTcreate( STMT_CASE ); + s = STMTcreate(STMT_CASE); s->u.Case = CASE_new(); s->u.Case->selector = selector; s->u.Case->cases = cases; - return( s ); + return(s); } /** @@ -98,9 +102,10 @@ Statement CASEcreate( Expression selector, Linked_List cases ) { ** ** Create and return a compound statement. */ -Statement COMP_STMTcreate( Linked_List statements ) { +Statement COMP_STMTcreate(Linked_List statements) +{ Statement s; - s = STMTcreate( STMT_COMPOUND ); + s = STMTcreate(STMT_COMPOUND); s->u.compound = COMP_STMT_new(); s->u.compound->statements = statements; return s; @@ -114,14 +119,15 @@ Statement COMP_STMTcreate( Linked_List statements ) { ** ** Create and return an if statement. */ -Statement CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) { +Statement CONDcreate(Expression test, Linked_List then, Linked_List otherwise) +{ Statement s; - s = STMTcreate( STMT_COND ); + s = STMTcreate(STMT_COND); s->u.cond = COND_new(); s->u.cond->test = test; s->u.cond->code = then; s->u.cond->otherwise = otherwise; - return( s ); + return(s); } /** @@ -130,9 +136,10 @@ Statement CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) ** ** Create and return a procedure call statement. */ -Statement PCALLcreate( Linked_List parameters ) { +Statement PCALLcreate(Linked_List parameters) +{ Statement s; - s = STMTcreate( STMT_PCALL ); + s = STMTcreate(STMT_PCALL); s->u.proc = PCALL_new(); s->u.proc->parameters = parameters; return s; @@ -143,23 +150,25 @@ Statement PCALLcreate( Linked_List parameters ) { ** ** Create and return a loop statement. */ -Statement LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_List statements ) { - Statement s = STMTcreate( STMT_LOOP ); +Statement LOOPcreate(Scope scope, Expression while_expr, Expression until_expr, Linked_List statements) +{ + Statement s = STMTcreate(STMT_LOOP); s->u.loop = LOOP_new(); s->u.loop->scope = scope; s->u.loop->while_expr = while_expr; s->u.loop->until_expr = until_expr; s->u.loop->statements = statements; - return( s ); + return(s); } -Statement ALIAScreate( Scope scope, Variable variable, Linked_List statements ) { - Statement s = STMTcreate( STMT_ALIAS ); +Statement ALIAScreate(Scope scope, Variable variable, Linked_List statements) +{ + Statement s = STMTcreate(STMT_ALIAS); s->u.alias = ALIAS_new(); s->u.alias->scope = scope; s->u.alias->variable = variable; s->u.alias->statements = statements; - return( s ); + return(s); } /** @@ -171,13 +180,14 @@ Statement ALIAScreate( Scope scope, Variable variable, Linked_List statements ) ** ** Create and return an increment control as specified. */ -Scope INCR_CTLcreate( Symbol * control, Expression start, - Expression end, Expression increment ) { - Scope s = SCOPEcreate_tiny( OBJ_INCREMENT ); - Expression e = EXPcreate_from_symbol( Type_Attribute, control ); - Variable v = VARcreate( e, Type_Number ); - DICTdefine( s->symbol_table, control->name, - v, control, OBJ_VARIABLE ); +Scope INCR_CTLcreate(Symbol *control, Expression start, + Expression end, Expression increment) +{ + Scope s = SCOPEcreate_tiny(OBJ_INCREMENT); + Expression e = EXPcreate_from_symbol(Type_Attribute, control); + Variable v = VARcreate(e, Type_Number); + DICTdefine(s->symbol_table, control->name, + v, control, OBJ_VARIABLE); s->u.incr = INCR_new(); s->u.incr->init = start; s->u.incr->end = end; @@ -190,8 +200,9 @@ Scope INCR_CTLcreate( Symbol * control, Expression start, ** \return the return statement created Create and return a return statement. */ -Statement RETcreate( Expression expression ) { - Statement s = STMTcreate( STMT_RETURN ); +Statement RETcreate(Expression expression) +{ + Statement s = STMTcreate(STMT_RETURN); s->u.ret = RET_new(); s->u.ret->value = expression; return s; diff --git a/src/express/symbol.c b/src/express/symbol.c index ed71fb836..2985cdcbe 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -35,5 +35,6 @@ #include "express/symbol.h" /** Initialize the Symbol module */ -void SYMBOLinitialize( void ) { +void SYMBOLinitialize(void) +{ } diff --git a/src/express/test/driver.c b/src/express/test/driver.c index d3e5f4dc5..f53dbaf5c 100644 --- a/src/express/test/driver.c +++ b/src/express/test/driver.c @@ -8,38 +8,40 @@ extern struct test_def tests[]; -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ int status; - + /* enable libexpress allocator */ MEMORYinitialize(); FACTORYinitialize(); - + argc--; status = 0; - if (argc) { + if(argc) { int test_counter = argc; - + /* selected tests */ - for (int i=1; i <= argc; i++) { - for (unsigned int j=0; tests[j].name != NULL; j++) { + for(int i = 1; i <= argc; i++) { + for(unsigned int j = 0; tests[j].name != NULL; j++) { const char *test_name = tests[j].name; - int (*test_ptr) (void) = tests[j].testfunc; - - if (!strcmp(argv[i], test_name)) { + int (*test_ptr)(void) = tests[j].testfunc; + + if(!strcmp(argv[i], test_name)) { test_counter--; setup(); status |= test_ptr(); } } } - - if (test_counter) + + if(test_counter) { fprintf(stderr, "WARNING: some tests not found...\n"); + } } else { /* all tests */ - for (unsigned int j=0; tests[j].name != NULL; j++) { - int (*test_ptr) (void) = tests[j].testfunc; + for(unsigned int j = 0; tests[j].name != NULL; j++) { + int (*test_ptr)(void) = tests[j].testfunc; setup(); status |= test_ptr(); } diff --git a/src/express/test/driver.h b/src/express/test/driver.h index 0df5707cd..ba9acde42 100644 --- a/src/express/test/driver.h +++ b/src/express/test/driver.h @@ -3,7 +3,7 @@ struct test_def { const char *name; - int (*testfunc) (void); + int (*testfunc)(void); }; void setup(); diff --git a/src/express/test/fff.h b/src/express/test/fff.h index ecd19da4f..4f7135976 100644 --- a/src/express/test/fff.h +++ b/src/express/test/fff.h @@ -34,10 +34,10 @@ SOFTWARE. #define FFF_MAX_ARGS (20u) #ifndef FFF_ARG_HISTORY_LEN - #define FFF_ARG_HISTORY_LEN (50u) +#define FFF_ARG_HISTORY_LEN (50u) #endif #ifndef FFF_CALL_HISTORY_LEN - #define FFF_CALL_HISTORY_LEN (50u) +#define FFF_CALL_HISTORY_LEN (50u) #endif /* -- INTERNAL HELPER MACROS -- */ #define SET_RETURN_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ @@ -107,11 +107,11 @@ SOFTWARE. return FUNCNAME##_fake.return_val; \ #ifdef __cplusplus - #define FFF_EXTERN_C extern "C"{ - #define FFF_END_EXTERN_C } +#define FFF_EXTERN_C extern "C"{ +#define FFF_END_EXTERN_C } #else /* ansi c */ - #define FFF_EXTERN_C - #define FFF_END_EXTERN_C +#define FFF_EXTERN_C +#define FFF_END_EXTERN_C #endif /* cpp/ansi c */ #define DEFINE_RESET_FUNCTION(FUNCNAME) \ @@ -122,7 +122,7 @@ SOFTWARE. /* -- END INTERNAL HELPER MACROS -- */ typedef void (*fff_function_t)(void); -typedef struct { +typedef struct { fff_function_t call_history[FFF_CALL_HISTORY_LEN]; unsigned int call_history_idx; } fff_globals_t; @@ -182,7 +182,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC0(FUNCNAME) \ DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ DEFINE_FAKE_VOID_FUNC0(FUNCNAME) \ - + #define DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -227,7 +227,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -275,7 +275,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -326,7 +326,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -380,7 +380,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -437,7 +437,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -497,7 +497,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -560,7 +560,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -626,7 +626,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -695,7 +695,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -767,7 +767,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -842,7 +842,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -920,7 +920,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -1001,7 +1001,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -1085,7 +1085,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -1172,7 +1172,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -1262,7 +1262,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -1355,7 +1355,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -1451,7 +1451,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -1550,7 +1550,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -1652,7 +1652,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ FFF_EXTERN_C \ @@ -1702,7 +1702,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DEFINE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ - + #define DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -1755,7 +1755,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -1811,7 +1811,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -1870,7 +1870,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -1932,7 +1932,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -1997,7 +1997,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -2065,7 +2065,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -2136,7 +2136,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -2210,7 +2210,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -2287,7 +2287,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -2367,7 +2367,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -2450,7 +2450,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -2536,7 +2536,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -2625,7 +2625,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -2717,7 +2717,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -2812,7 +2812,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -2910,7 +2910,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -3011,7 +3011,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -3115,7 +3115,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -3222,7 +3222,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -3332,7 +3332,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -3374,7 +3374,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -3419,7 +3419,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -3467,7 +3467,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -3518,7 +3518,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -3572,7 +3572,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -3629,7 +3629,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -3689,7 +3689,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -3752,7 +3752,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -3818,7 +3818,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -3887,7 +3887,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -3959,7 +3959,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -4034,7 +4034,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -4112,7 +4112,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -4193,7 +4193,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -4277,7 +4277,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -4364,7 +4364,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -4454,7 +4454,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -4547,7 +4547,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -4643,7 +4643,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -4691,7 +4691,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -4742,7 +4742,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -4796,7 +4796,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -4853,7 +4853,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -4913,7 +4913,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -4976,7 +4976,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -5042,7 +5042,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -5111,7 +5111,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -5183,7 +5183,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -5258,7 +5258,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -5336,7 +5336,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -5417,7 +5417,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -5501,7 +5501,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -5588,7 +5588,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -5678,7 +5678,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -5771,7 +5771,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -5867,7 +5867,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -5966,7 +5966,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -6068,7 +6068,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + /* MSVC expand macro fix */ #define EXPAND(x) x diff --git a/src/express/test/print_attrs.c b/src/express/test/print_attrs.c index 881ada059..99384de8e 100644 --- a/src/express/test/print_attrs.c +++ b/src/express/test/print_attrs.c @@ -23,29 +23,31 @@ #include "ordered_attrs.h" #include -char * entityName, _buf[512] = { 0 }; +char *entityName, _buf[512] = { 0 }; /** prints usage info specific to print_attrs */ -void my_usage(void) { - EXPRESSusage( 0 ); - printf( " ----\n\t-a : print attrs for \n" ); - exit( 2 ); +void my_usage(void) +{ + EXPRESSusage(0); + printf(" ----\n\t-a : print attrs for \n"); + exit(2); } /** prints info about one attr */ -void describeAttr( const orderedAttr * oa ) { - const char * visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; - const char * visibility, * descrip1="", * descrip2="", * descrip3=0; - if( oa->deriver ) { - assert( 0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute" ); +void describeAttr(const orderedAttr *oa) +{ + const char *visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; + const char *visibility, * descrip1 = "", * descrip2 = "", * descrip3 = 0; + if(oa->deriver) { + assert(0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute"); descrip1 = "derived in "; descrip2 = oa->deriver->symbol.name; - if( oa->deriver == oa->creator ) { + if(oa->deriver == oa->creator) { visibility = hidden_p21; } else { visibility = explicit_derived; } - } else if( oa->attr->inverse_attribute ) { + } else if(oa->attr->inverse_attribute) { visibility = hidden_p21; descrip1 = "inverse of "; descrip2 = oa->attr->inverse_attribute->name->symbol.name; @@ -54,53 +56,56 @@ void describeAttr( const orderedAttr * oa ) { visibility = visible_p21; } printf("%s|%22s |%22s | %s%s%s%s\n", visibility, oa->attr->name->symbol.name, - oa->creator->symbol.name, descrip1, descrip2, ( ( descrip3 ) ? " in " : "" ), ( ( descrip3 ) ? descrip3 : "" ) ); + oa->creator->symbol.name, descrip1, descrip2, ((descrip3) ? " in " : ""), ((descrip3) ? descrip3 : "")); } -void print_attrs( Entity ent ) { - const orderedAttr * oa; - const char * dashes="--------------------------------------------------------------------------"; - printf( "Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, - " In P21? | attr name | creator | detail", dashes ); - orderedAttrsInit( ent ); - while( 0 != ( oa = nextAttr() ) ) { - describeAttr( oa ); +void print_attrs(Entity ent) +{ + const orderedAttr *oa; + const char *dashes = "--------------------------------------------------------------------------"; + printf("Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, + " In P21? | attr name | creator | detail", dashes); + orderedAttrsInit(ent); + while(0 != (oa = nextAttr())) { + describeAttr(oa); } orderedAttrsCleanup(); } -void find_and_print( Express model ) { +void find_and_print(Express model) +{ DictionaryEntry de; Schema s; Entity e; - DICTdo_init( model->symbol_table, &de ); - while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { - printf( "Schema %s\n", s->symbol.name ); - e = (Entity) DICTlookup( s->symbol_table, entityName ); - if( e ) { - print_attrs( e ); + DICTdo_init(model->symbol_table, &de); + while(0 != (s = (Schema) DICTdo(&de))) { + printf("Schema %s\n", s->symbol.name); + e = (Entity) DICTlookup(s->symbol_table, entityName); + if(e) { + print_attrs(e); } } } /** reads arg setting entity name */ -int attr_arg( int i, char * arg ) { - const char * src = arg; +int attr_arg(int i, char *arg) +{ + const char *src = arg; int count = 0; - if( ( char )i == 'a' ) { + if((char)i == 'a') { entityName = _buf; - while( *src ) { - _buf[count] = tolower( *src ); + while(*src) { + _buf[count] = tolower(*src); src++; count++; - if( count == 511 ) { + if(count == 511) { break; } } - if( count == 0 ) { + if(count == 0) { entityName = 0; } - } else if( !entityName ) { + } else if(!entityName) { /* if libexpress comes across an unrecognized arg that isn't '-a', * and if the entityName isn't set, print usage and exit */ @@ -110,10 +115,11 @@ int attr_arg( int i, char * arg ) { } /** set the functions to be called by main() in libexpress */ -void EXPRESSinit_init() { +void EXPRESSinit_init() +{ entityName = 0; EXPRESSbackend = find_and_print; ERRORusage_function = my_usage; - strcat( EXPRESSgetopt_options, "a:" ); + strcat(EXPRESSgetopt_options, "a:"); EXPRESSgetopt = attr_arg; } diff --git a/src/express/test/print_schemas.c b/src/express/test/print_schemas.c index 40bb0a1e0..3d3db9c1b 100644 --- a/src/express/test/print_schemas.c +++ b/src/express/test/print_schemas.c @@ -15,21 +15,23 @@ #include "express/express.h" void -print_schemas( Express model ) { +print_schemas(Express model) +{ DictionaryEntry de; Schema s; - printf( "File: %s\n ", model->u.express->filename ); + printf("File: %s\n ", model->u.express->filename); - DICTdo_init( model->symbol_table, &de ); - while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { - printf( "%s", s->symbol.name ); + DICTdo_init(model->symbol_table, &de); + while(0 != (s = (Schema) DICTdo(&de))) { + printf("%s", s->symbol.name); } - printf( "\n" ); - exit( 0 ); + printf("\n"); + exit(0); } -void EXPRESSinit_init() { +void EXPRESSinit_init() +{ EXPRESSbackend = print_schemas; } diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 72c4d3e14..8de1be0ab 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -17,7 +17,7 @@ * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -37,9 +37,10 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) -void setup() { +void setup() +{ EXPinitialize(); - + RESET_FAKE(EXPRESS_fail); RESET_FAKE(ENTITYfind_inherited_attribute); RESET_FAKE(ENTITYresolve_attr_ref); @@ -48,15 +49,17 @@ void setup() { } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) { +void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) +{ (void) typ; - Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); + Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); exp->type = res_typ; exp->return_type = res_typ; exp->symbol.resolved = RESOLVED; } -int test_resolve_select_enum_member() { +int test_resolve_select_enum_member() +{ Schema scope; Symbol *e_type_id, *enum_id, *s_type_id; Type enum_typ, select_typ, chk_typ; @@ -71,55 +74,56 @@ int test_resolve_select_enum_member() { s_type_id = SYMBOLcreate("sel1", 1, "test1"); e_type_id = SYMBOLcreate("enum1", 1, "test1"); enum_id = SYMBOLcreate("val1", 1, "test1"); - + enum_typ = TYPEcreate_name(e_type_id); enum_typ->symbol_table = DICTcreate(50); - + exp_enum_id = EXPcreate(enum_typ); exp_enum_id->symbol = *enum_id; exp_enum_id->u.integer = 1; - + tb = TYPEBODYcreate(enumeration_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_id); enum_typ->u.type->body = tb; - + DICT_define(scope->symbol_table, e_type_id->name, enum_typ, &enum_typ->symbol, OBJ_TYPE); - + /* TODO: OBJ_ENUM / OBJ_EXPRESSION are used interchangeably, this is confusing. */ DICT_define(scope->enum_table, exp_enum_id->symbol.name, exp_enum_id, &exp_enum_id->symbol, OBJ_EXPRESSION); DICT_define(enum_typ->symbol_table, enum_id->name, exp_enum_id, enum_id, OBJ_EXPRESSION); - + select_typ = TYPEcreate_name(s_type_id); tb = TYPEBODYcreate(select_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_typ); select_typ->u.type->body = tb; DICT_define(scope->symbol_table, s_type_id->name, select_typ, &select_typ->symbol, OBJ_TYPE); - + op1 = EXPcreate_from_symbol(Type_Identifier, s_type_id); op2 = EXPcreate_from_symbol(Type_Identifier, enum_id); - expr = BIN_EXPcreate(OP_DOT, op1, op2); + expr = BIN_EXPcreate(OP_DOT, op1, op2); /* * test: sel_ref '.' enum_id * expectation: enum_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_type_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == select_typ); assert(chk_typ == enum_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) { +void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) +{ (void) unused; Entity ent = DICTlookup(cxt->symbol_table, exp->symbol.name); Type typ = ent->u.entity->type; @@ -128,13 +132,15 @@ void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) { exp->symbol.resolved = RESOLVED; } -Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) { +Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) +{ (void) grp_ref; Variable v = DICTlookup(ent->symbol_table, attr_ref->name); - return v; + return v; } -int test_resolve_entity_attribute() { +int test_resolve_entity_attribute() +{ Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -154,7 +160,7 @@ int test_resolve_entity_attribute() { DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -162,29 +168,29 @@ int test_resolve_entity_attribute() { var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); op1 = EXPcreate_from_symbol(Type_Identifier, e_type_id); op2 = EXPcreate_from_symbol(Type_Attribute, attr_id); expr = BIN_EXPcreate(OP_DOT, op1, op2); - + /* * test: entity_ref '.' attribute_id * expectation: attr_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_entity_handler; ENTITYresolve_attr_ref_fake.custom_fake = ENTITY_resolve_attr_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == ent->u.entity->type); assert(chk_typ == attr_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index 8ce3eb5e1..ff51ec334 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -34,8 +34,8 @@ int yyerrstatus; /* * mock functions */ -typedef void * (*malloc_func_t) (size_t); -typedef void (*free_func_t) (void *); +typedef void *(*malloc_func_t)(size_t); +typedef void (*free_func_t)(void *); DEFINE_FFF_GLOBALS @@ -71,7 +71,8 @@ FAKE_VALUE_FUNC(char *, SCANstrdup, const char *) FAKE_VALUE_FUNC(perplex_t, perplexFileScanner, FILE *) FAKE_VALUE_FUNC(int, yylex, perplex_t) -void setup() { +void setup() +{ RESET_FAKE(RESOLVEinitialize); RESET_FAKE(SYMBOLinitialize); RESET_FAKE(SCOPEinitialize); @@ -104,7 +105,8 @@ void setup() { RESET_FAKE(yylex); } -int test_express_rename_resolve() { +int test_express_rename_resolve() +{ Schema cur_schema, ref_schema; Rename *use_ref; Entity ent; @@ -114,17 +116,17 @@ int test_express_rename_resolve() { ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->uselist = LISTcreate(); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + /* TODO: create RENcreate(...), refactor SCHEMAadd_use() */ use_ref = REN_new(); use_ref->schema_sym = ref_schema_id; @@ -133,9 +135,9 @@ int test_express_rename_resolve() { use_ref->rename_type = use; LISTadd_last(cur_schema->u.schema->uselist, use_ref); use_ref->schema = ref_schema; - + RENAMEresolve(use_ref, cur_schema); - + assert(use_ref->type == OBJ_ENTITY); return 0; } diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index 2fc30ac68..9c974029c 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -19,12 +19,12 @@ * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; int EXPRESSpass; -struct Scope_ * FUNC_NVL; -struct Scope_ * FUNC_USEDIN; +struct Scope_ *FUNC_NVL; +struct Scope_ *FUNC_USEDIN; struct EXPop_entry EXPop_table[OP_LAST]; @@ -45,9 +45,10 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() { +void setup() +{ RESOLVEinitialize(); - + RESET_FAKE(SCOPEfind); RESET_FAKE(VARfind); RESET_FAKE(VARget_simple_name); @@ -58,69 +59,74 @@ void setup() { RESET_FAKE(EXPRESS_fail); } -void * SCOPEfind_handler(Scope scope, char * name, int type) { +void *SCOPEfind_handler(Scope scope, char *name, int type) +{ (void) type; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_bad_func_call() { +int test_exp_resolve_bad_func_call() +{ Schema scope; Symbol *func_id; Expression func_call; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - - SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved != RESOLVED); - + return 0; } -int test_exp_resolve_func_call() { +int test_exp_resolve_func_call() +{ Schema scope; Symbol *func_id; Expression func_call; Function func_def; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - + func_def = TYPEcreate_nostab(func_id, scope, OBJ_FUNCTION); - SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved == RESOLVED); assert(func_call->u.funcall.function == func_def); - + return 0; } -Variable VARfind_handler(Scope scope, char *name, int strict) { +Variable VARfind_handler(Scope scope, char *name, int strict) +{ (void) strict; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_local_identifier() { +int test_exp_resolve_local_identifier() +{ Schema scope; Entity ent; Expression ent_attr, ent_attr_ref; Symbol *attr_id, *attr_ref, *ent_id; Variable v_attr; Type attr_typ; - + scope = SCHEMAcreate(); - + ent_id = SYMBOLcreate("entity1", 1, "test_2"); - ent = ENTITYcreate(ent_id); + ent = ENTITYcreate(ent_id); DICT_define(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test_2"); @@ -129,34 +135,35 @@ int test_exp_resolve_local_identifier() { v_attr = VARcreate(ent_attr, attr_typ); v_attr->flags.attribute = true; DICT_define(ent->symbol_table, attr_id->name, v_attr, attr_id, OBJ_VARIABLE); - + attr_ref = SYMBOLcreate("attr1", 1, "test_2"); ent_attr_ref = EXPcreate_from_symbol(Type_Identifier, attr_ref); - + VARfind_fake.custom_fake = VARfind_handler; - + EXP_resolve(ent_attr_ref, ent, Type_Dont_Care); - + assert(ent_attr_ref->u.variable == v_attr); assert(ent_attr_ref->symbol.resolved == RESOLVED); - + return 0; } -int test_entity_resolve_subtype_expr_entity() { +int test_entity_resolve_subtype_expr_entity() +{ Schema scope; Entity ent1, ent2; Expression subtype_exp; Symbol *ent1_id, *ent2_id, *ent2_ref; int chk; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); ent2_ref = SYMBOLcreate("ent2", 1, "test_3"); ent1 = ENTITYcreate(ent1_id); ent2 = ENTITYcreate(ent2_id); - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); @@ -164,25 +171,26 @@ int test_entity_resolve_subtype_expr_entity() { ent1->superscope = scope; ent1->u.entity->subtypes = LISTcreate(); ent1->u.entity->subtype_expression = subtype_exp; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; chk = ENTITYresolve_subtype_expression(subtype_exp, ent1, &ent1->u.entity->subtypes); - + assert(chk == RESOLVED); - + return 0; } -int test_type_resolve_entity() { +int test_type_resolve_entity() +{ Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -192,60 +200,62 @@ int test_type_resolve_entity() { sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; TYPE_resolve(&sel); - + assert(sel->symbol.resolved == RESOLVED); - + return 0; } -int test_stmt_resolve_pcall_proc() { +int test_stmt_resolve_pcall_proc() +{ Schema scope; Function f; Procedure p; Statement s; Symbol *func_id, *proc_id, *proc_ref; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); proc_id = SYMBOLcreate("proc1", 1, "test_5"); proc_ref = SYMBOLcreate("proc1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + p = ALGcreate(OBJ_PROCEDURE); DICTdefine(f->symbol_table, proc_id->name, p, proc_id, OBJ_PROCEDURE); - + s = PCALLcreate(NULL); s->symbol = *proc_ref; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + STMTresolve(s, f); - + assert(s->u.proc->procedure == p); - + return 0; } -int test_scope_resolve_named_types() { +int test_scope_resolve_named_types() +{ Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); ent_id = SYMBOLcreate("ent", 1, "test_4"); - + ent_base = TYPEcreate(entity_); ent_base->symbol = *ent_id; ent_base->superscope = scope; @@ -256,26 +266,27 @@ int test_scope_resolve_named_types() { sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEresolve_types(scope); - + assert(!(ent->symbol.resolved & RESOLVE_FAILED)); assert(!(sel->symbol.resolved & RESOLVE_FAILED)); assert(!(scope->symbol.resolved & RESOLVE_FAILED)); - + return 0; } -int test_entity_resolve_supertypes() { +int test_entity_resolve_supertypes() +{ Schema scope; Entity ent1, ent2; Symbol *ent1_id, *ent2_id, *ent1_ref; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); @@ -284,19 +295,19 @@ int test_entity_resolve_supertypes() { ent2 = ENTITYcreate(ent2_id); ent1->superscope = scope; ent2->superscope = scope; - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); - + ent2->u.entity->supertype_symbols = LISTcreate(); LISTadd_last(ent2->u.entity->supertype_symbols, ent1_ref); - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + ENTITYresolve_supertypes(ent2); assert(!(ent2->symbol.resolved & RESOLVE_FAILED)); - + return 0; } diff --git a/src/express/test/test_resolve2.c b/src/express/test/test_resolve2.c index a293dce69..6fe469217 100644 --- a/src/express/test/test_resolve2.c +++ b/src/express/test/test_resolve2.c @@ -17,7 +17,7 @@ * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int EXPRESSpass; int yylineno; int print_objects_while_running; @@ -39,7 +39,8 @@ FAKE_VOID_FUNC(ENTITYresolve_expressions, Entity) FAKE_VALUE_FUNC(int, WHEREresolve, Linked_List, Scope, int) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() { +void setup() +{ RESET_FAKE(ENTITYresolve_supertypes); RESET_FAKE(ENTITYresolve_subtypes); RESET_FAKE(TYPE_resolve); @@ -51,16 +52,17 @@ void setup() { RESET_FAKE(EXPRESS_fail); } -int test_scope_resolve_expr_stmt() { +int test_scope_resolve_expr_stmt() +{ Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -70,28 +72,29 @@ int test_scope_resolve_expr_stmt() { sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_expressions_statements(scope); - + assert(ENTITYresolve_expressions_fake.call_count == 1); assert(TYPEresolve_expressions_fake.call_count == 1); - + return 0; } -int test_scope_resolve_subsupers() { +int test_scope_resolve_subsupers() +{ Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -101,16 +104,16 @@ int test_scope_resolve_subsupers() { sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_subsupers(scope); - + assert(TYPE_resolve_fake.call_count == 1); assert(ENTITYresolve_supertypes_fake.call_count == 1); assert(ENTITYresolve_subtypes_fake.call_count == 1); - + return 0; } diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c index 80fe0eadc..106e9cca5 100644 --- a/src/express/test/test_schema.c +++ b/src/express/test/test_schema.c @@ -17,7 +17,7 @@ /* * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int yylineno; int ENTITY_MARK; @@ -33,13 +33,15 @@ FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) FAKE_VOID_FUNC(SCOPE_get_entities, Scope, Linked_List) FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) -void setup() { +void setup() +{ RESET_FAKE(EXPRESS_fail) RESET_FAKE(SCOPE_get_entities) RESET_FAKE(ENTITYfind_inherited_attribute) } -int test_schema_define_ref() { +int test_schema_define_ref() +{ Schema cur_schema, ref_schema; Rename *ref_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -47,30 +49,31 @@ int test_schema_define_ref() { cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; ref_rename->nnew = ent_ref; ref_rename->rename_type = ref; ref_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_reference(cur_schema, ref_rename); - + assert(cur_schema->u.schema->refdict->KeyCount == 1); - + return 0; } -int test_schema_define_use() { +int test_schema_define_use() +{ Schema cur_schema, ref_schema; Rename *use_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -78,34 +81,35 @@ int test_schema_define_use() { cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->usedict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + use_rename = REN_new(); use_rename->schema_sym = ref_schema_id; use_rename->old = ent_ref; use_rename->nnew = ent_ref; use_rename->rename_type = use; use_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_use(cur_schema, use_rename); - + assert(cur_schema->u.schema->usedict->KeyCount == 1); - + return 0; } -/* TODO: +/* TODO: * currently this function expects OBJ_RENAME stored as OBJ_ENTITY * (to indicate partial reference) */ -int test_schema_get_entities_ref() { +int test_schema_get_entities_ref() +{ Schema cur_schema, ref_schema; Rename *ref_rename; Entity ent; @@ -116,17 +120,17 @@ int test_schema_get_entities_ref() { ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; @@ -134,19 +138,19 @@ int test_schema_get_entities_ref() { ref_rename->rename_type = ref; ref_rename->schema = ref_schema; ref_rename->object = ent; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); + r = LISTcreate(); cur_schema->search_id = -1; SCHEMA_get_entities_ref(cur_schema, r); - + assert(LISTget_length(r) == 1); - + return 0; } -Variable -ENTITY_find_attr_handler(struct Scope_ *entity, char * name, struct Symbol_** down_sym) +Variable +ENTITY_find_attr_handler(struct Scope_ *entity, char *name, struct Symbol_ **down_sym) { Variable r; (void) down_sym; @@ -154,7 +158,8 @@ ENTITY_find_attr_handler(struct Scope_ *entity, char * name, struct Symbol_** do return r; } -int test_var_find() { +int test_var_find() +{ Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -171,7 +176,7 @@ int test_var_find() { DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -179,16 +184,16 @@ int test_var_find() { var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); - DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); - + DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); + ENTITYfind_inherited_attribute_fake.custom_fake = ENTITY_find_attr_handler; - + var_ref = VARfind(ent, "attr1", 1); - + assert(var_ref != NULL); - + return 0; } diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c index b59ef4acc..17ac6bc81 100644 --- a/src/express/test/test_scope.c +++ b/src/express/test/test_scope.c @@ -15,7 +15,7 @@ * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -33,20 +33,22 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() { +void setup() +{ RESET_FAKE(EXPRESS_fail); } -int test_scope_find() { +int test_scope_find() +{ Schema scope; Type sel, ent_base, chk_sel; Entity ent, chk_ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -56,19 +58,19 @@ int test_scope_find() { sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); - + scope->search_id = -1; chk_sel = SCOPE_find(scope, "sel_typ", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + scope->search_id = -1; chk_ent = SCOPE_find(scope, "ent", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + assert(chk_sel == sel); assert(chk_ent == ent); - + return 0; } diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c index 94b1f8b5a..419d03a7e 100644 --- a/src/express/test/test_type.c +++ b/src/express/test/test_type.c @@ -15,7 +15,7 @@ * mock globals */ -char * EXPRESSprogram_name; +char *EXPRESSprogram_name; int yylineno; int tag_count; @@ -29,33 +29,35 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() { +void setup() +{ RESET_FAKE(EXPRESS_fail) TYPEinitialize(); } -int test_type_create_user_defined_tag() { +int test_type_create_user_defined_tag() +{ Schema scope; Function f; Type t, g, chk; Symbol *func_id, *tag_id; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); tag_id = SYMBOLcreate("item1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); f->symbol = *func_id; DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + g = TYPEcreate(generic_); t = TYPEcreate_nostab(tag_id, f, OBJ_TAG); - + chk = TYPEcreate_user_defined_tag(g, f, tag_id); - + assert(chk == t); - + return 0; } diff --git a/src/express/token_type.h b/src/express/token_type.h index 03cd99ab5..6c2bf2240 100644 --- a/src/express/token_type.h +++ b/src/express/token_type.h @@ -60,11 +60,11 @@ typedef union YYSTYPE { Linked_List list; Logical logical; Op_Code op_code; - Qualified_Attr * qualified_attr; + Qualified_Attr *qualified_attr; Real rVal; Statement statement; - Symbol * symbol; - char * string; + Symbol *symbol; + char *string; Type type; TypeBody typebody; Variable variable; diff --git a/src/express/type.c b/src/express/type.c index ffcba5915..838ce6a29 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -126,20 +126,21 @@ This module implements the type abstraction. It is #include "express/type.h" -Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) { +Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) +{ Type t; extern int tag_count; - t = ( Type )DICTlookup( scope->symbol_table, symbol->name ); - if( t ) { - if( DICT_type == OBJ_TAG ) { - return( t ); + t = (Type)DICTlookup(scope->symbol_table, symbol->name); + if(t) { + if(DICT_type == OBJ_TAG) { + return(t); } else { /* easiest to just generate the error this way! * following call WILL fail intentionally */ - DICTdefine( scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG ); - return( 0 ); + DICTdefine(scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG); + return(0); } } @@ -147,22 +148,22 @@ Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol * if we are outside a formal parameter list (hack, hack) * then we can only refer to existing tags, so produce an error */ - if( tag_count < 0 ) { - ERRORreport_with_symbol( UNDEFINED_TAG, symbol, - symbol->name ); - return( 0 ); + if(tag_count < 0) { + ERRORreport_with_symbol(UNDEFINED_TAG, symbol, + symbol->name); + return(0); } /* otherwise, we're in a formal parameter list, * so it's ok to define it */ - t = TYPEcreate_nostab( symbol, scope, OBJ_TAG ); + t = TYPEcreate_nostab(symbol, scope, OBJ_TAG); t->u.type->head = base; /* count unique type tags inside PROC and FUNC headers */ tag_count++; - return( t ); + return(t); } /** @@ -171,60 +172,63 @@ Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol */ #define TYPE_inherits_from(t,e) ((t) && TYPEinherits_from((t),(e))) -bool TYPEinherits_from( Type t, enum type_enum e ) { +bool TYPEinherits_from(Type t, enum type_enum e) +{ TypeBody tb = t->u.type->body; - assert( ( t->type == OBJ_TYPE ) && ( tb ) && "Not a Type!" ); - switch( e ) { + assert((t->type == OBJ_TYPE) && (tb) && "Not a Type!"); + switch(e) { case aggregate_: - if( tb->type == aggregate_ || + if(tb->type == aggregate_ || tb->type == array_ || tb->type == bag_ || tb->type == set_ || - tb->type == list_ ) { + tb->type == list_) { return true; } else { - return( TYPE_inherits_from( tb->base, e ) ); + return(TYPE_inherits_from(tb->base, e)); } case array_: - return( ( tb->type == array_ ) ? true : TYPE_inherits_from( tb->base, e ) ); + return((tb->type == array_) ? true : TYPE_inherits_from(tb->base, e)); case bag_: - return( ( tb->type == bag_ || - tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); + return((tb->type == bag_ || + tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); case set_: - return( ( tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); + return((tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); case list_: - return( ( tb->type == list_ ) ? true : TYPE_inherits_from( tb->base, e ) ); + return((tb->type == list_) ? true : TYPE_inherits_from(tb->base, e)); default: break; } - return ( tb->type == e ); + return (tb->type == e); } #if 0 case binary_: -return( ( t->type == binary_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == binary_) ? true : TYPEinherits_from(t->base, e)); case integer_: -return( ( t->type == integer_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == integer_) ? true : TYPEinherits_from(t->base, e)); case real_: -return( ( t->type == real_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == real_) ? true : TYPEinherits_from(t->base, e)); case string_: -return( ( t->type == string_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == string_) ? true : TYPEinherits_from(t->base, e)); case logical_: -return( ( t->type == logical_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == logical_) ? true : TYPEinherits_from(t->base, e)); case boolean_: -return( ( t->type == boolean_ ) ? true : TYPEinherits_from( t->base, e ) ); +return((t->type == boolean_) ? true : TYPEinherits_from(t->base, e)); default: -return( false ); +return(false); } } #endif /** Initialize the Type module */ -void TYPEinitialize() { +void TYPEinitialize() +{ } /** Clean up the Type module */ -void TYPEcleanup( void ) { +void TYPEcleanup(void) +{ } /** @@ -232,8 +236,9 @@ void TYPEcleanup( void ) { * \return the base type of the aggregate type * Retrieve the base type of an aggregate. */ -Type TYPEget_nonaggregate_base_type( Type t ) { - while( TYPEis_aggregate( t ) ) { +Type TYPEget_nonaggregate_base_type(Type t) +{ + while(TYPEis_aggregate(t)) { t = t->u.type->body->base; } return t; diff --git a/src/express/variable.c b/src/express/variable.c index b3ec9f88a..e99ca0b6f 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -87,29 +87,31 @@ #include "express/variable.h" #include "express/object.h" -char * opcode_print( Op_Code o ); +char *opcode_print(Op_Code o); /** Initialize the Variable module. */ -void VARinitialize() { +void VARinitialize() +{ } /** VARget_simple_name * returns simple name of variable * for example, if var is named SELF\xxx.yyy, return yyy */ -extern char * VARget_simple_name( Variable v ) { - Expression e = VARget_name( v ); +extern char *VARget_simple_name(Variable v) +{ + Expression e = VARget_name(v); - while( TYPEis_expression( EXPget_type( e ) ) ) { - switch( e->e.op_code ) { + while(TYPEis_expression(EXPget_type(e))) { + switch(e->e.op_code) { case OP_DOT: case OP_GROUP: e = e->e.op2; break; default: - fprintf( stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print( e->e.op_code ) ); + fprintf(stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print(e->e.op_code)); abort(); } } - return EXPget_name( e ); + return EXPget_name(e); } diff --git a/src/test/SEarritr.h b/src/test/SEarritr.h index f84b6fbb8..bf1214c20 100644 --- a/src/test/SEarritr.h +++ b/src/test/SEarritr.h @@ -17,36 +17,42 @@ // Best used in the form: for (SEitr=0; !SEitr; ++SEitr) { ... } // (this for loop walks the whole array) -class SEarrIterator { +class SEarrIterator +{ private: - const STEPentity ** SEarr; // Array of pointers to STEPentity's + const STEPentity **SEarr; // Array of pointers to STEPentity's int index; // current index int size; // size of array public: // Construct the iterator with a given array and its size - SEarrIterator( const STEPentity ** entarr, int sz ) { + SEarrIterator(const STEPentity **entarr, int sz) + { SEarr = entarr; index = 0; size = sz; } // set the value of the index: SEitr = 3 - void operator= ( int newindex ) { + void operator= (int newindex) + { index = newindex; } // check if we're out of range: if (!SEitr)... - int operator!() { - return ( index < size ); + int operator!() + { + return (index < size); } // return current element: SEptr = SEitr() - STEPentity * operator()() { - return ( STEPentity * )SEarr[index]; + STEPentity *operator()() + { + return (STEPentity *)SEarr[index]; } // PREFIX increment operator: ++SEitr - int operator++ () { + int operator++ () + { index++; return operator!(); } diff --git a/src/test/generate_express/generate_express.cc b/src/test/generate_express/generate_express.cc index a6cb1ef29..404929f4f 100644 --- a/src/test/generate_express/generate_express.cc +++ b/src/test/generate_express/generate_express.cc @@ -12,43 +12,44 @@ /******************** main() ****************************/ -main() { +main() +{ // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry * registry = new Registry( SchemaInit ); + Registry *registry = new Registry(SchemaInit); // "Reset" has tables for browsing registry->ResetSchemas(); - const SchemaDescriptor * schema = 0; + const SchemaDescriptor *schema = 0; - SchemaDescriptor * schema2 = 0; - schema = ( SchemaDescriptor * )registry->FindSchema( "Example_Schema" ); - EntityDescriptor * ed = ( EntityDescriptor * )registry->FindEntity( "Circle" ); + SchemaDescriptor *schema2 = 0; + schema = (SchemaDescriptor *)registry->FindSchema("Example_Schema"); + EntityDescriptor *ed = (EntityDescriptor *)registry->FindEntity("Circle"); Uniqueness_rule_ptr ur = new Uniqueness_rule; - ur->comment_( "(* Hi Dave *)\n" ); - if( ed->_uniqueness_rules ) { - ed->_uniqueness_rules->Append( ur ); + ur->comment_("(* Hi Dave *)\n"); + if(ed->_uniqueness_rules) { + ed->_uniqueness_rules->Append(ur); } else { - ed->uniqueness_rules_( new Uniqueness_rule__set ); - ed->_uniqueness_rules->Append( ur ); + ed->uniqueness_rules_(new Uniqueness_rule__set); + ed->_uniqueness_rules->Append(ur); } registry->ResetSchemas(); schema = registry->NextSchema(); - ofstream * efile; + ofstream *efile; std::string str, tmp; - while( schema != 0 ) { + while(schema != 0) { str = ""; - str.Append( StrToLower( schema->Name(), tmp ) ); - str.Append( ".exp" ); - efile = new ofstream( str.c_str() ); + str.Append(StrToLower(schema->Name(), tmp)); + str.Append(".exp"); + efile = new ofstream(str.c_str()); cout << "Generating: " << str << endl; - schema->GenerateExpress( *efile ); + schema->GenerateExpress(*efile); efile->close(); delete efile; diff --git a/src/test/needFunc.cc b/src/test/needFunc.cc index d71c8f28c..a8f507b04 100644 --- a/src/test/needFunc.cc +++ b/src/test/needFunc.cc @@ -14,6 +14,7 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE( StepEntityEditor * se ) { +void DeleteSEE(StepEntityEditor *se) +{ delete se; } diff --git a/src/test/needFunc.h b/src/test/needFunc.h index a473c332c..471c41a62 100644 --- a/src/test/needFunc.h +++ b/src/test/needFunc.h @@ -1,10 +1,11 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class StepEntityEditor { +class StepEntityEditor +{ public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE( StepEntityEditor * se ); +extern void DeleteSEE(StepEntityEditor *se); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index f3fc1a3c6..35e999396 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -12,7 +12,7 @@ ** provided the file written out is called file.out */ -extern void SchemaInit( class Registry & ); +extern void SchemaInit(class Registry &); #include "sc_version_string.h" #include #include @@ -35,22 +35,23 @@ extern void SchemaInit( class Registry & ); * before comparison. If they are not identical, attempt to strip any * ASN.1 identifiers and compare again. Returns true for a match. */ -bool compareOneSchName( std::string lib, std::string file ) { +bool compareOneSchName(std::string lib, std::string file) +{ size_t b, e, ls, fs; - b = lib.find_first_of( '\'' ) + 1; - e = lib.find_last_of( '\'' ); - lib = lib.substr( b, e - b ); - std::transform( lib.begin(), lib.end(), lib.begin(), ::toupper ); - std::transform( file.begin(), file.end(), file.begin(), ::toupper ); - if( lib == file ) { + b = lib.find_first_of('\'') + 1; + e = lib.find_last_of('\''); + lib = lib.substr(b, e - b); + std::transform(lib.begin(), lib.end(), lib.begin(), ::toupper); + std::transform(file.begin(), file.end(), file.begin(), ::toupper); + if(lib == file) { return true; } //There are no spaces, unless there is an ASN.1 identifier. If //the strings don't already match, try to remove this identifier. - ls = lib.find_first_of( ' ' ); - fs = file.find_first_of( ' ' ); - if( lib.substr( 0, ls ) == file.substr( 0, fs ) ) { + ls = lib.find_first_of(' '); + fs = file.find_first_of(' '); + if(lib.substr(0, ls) == file.substr(0, fs)) { return true; } std::cerr << "This pair of schema names do not match - " << lib << " and " << file << std::endl; @@ -61,40 +62,43 @@ bool compareOneSchName( std::string lib, std::string file ) { * Loop through all available schemas and attributes, looking * for a match. If match not found, print error and exit(1) */ -void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) { +void checkSchemaName(Registry ®, STEPfile &sf, bool ignoreErr) +{ bool match = false; std::string sname; - STEPattribute * attr; - const Schema * sc; + STEPattribute *attr; + const Schema *sc; reg.ResetSchemas(); //file id 3 is always the schema name - SDAI_Application_instance * ai = - sf.HeaderInstances()->FindFileId( 3 )->GetApplication_instance(); - while( ( attr = ai->NextAttribute() ) ) { + SDAI_Application_instance *ai = + sf.HeaderInstances()->FindFileId(3)->GetApplication_instance(); + while((attr = ai->NextAttribute())) { sname = attr->asStr(); - while( ( sc = reg.NextSchema() ) ) { - if( compareOneSchName( sname, sc->Name() ) ) { + while((sc = reg.NextSchema())) { + if(compareOneSchName(sname, sc->Name())) { match = true; break; } } - if( match ) { + if(match) { break; } } - if( !match ) { + if(!match) { std::cerr << "ERROR - schema name mismatch. Tried all available combinations." << std::endl; - if( !ignoreErr ) { - exit( 1 ); + if(!ignoreErr) { + exit(1); } } } -void printVersion( const char * exe ) { +void printVersion(const char *exe) +{ std::cout << exe << " build info: " << sc_version << std::endl; } -void printUse( const char * exe ) { +void printUse(const char *exe) +{ std::cout << "p21read - read a STEP Part 21 exchange file using SCL, and write the data to another file." << std::endl; std::cout << "Syntax: " << exe << " [-i] [-s] infile [outfile]" << std::endl; std::cout << "Use '-i' to ignore a schema name mismatch." << std::endl; @@ -102,23 +106,24 @@ void printUse( const char * exe ) { std::cout << "Use '-s' for strict interpretation (attributes that are \"missing and required\" will cause errors)." << std::endl; std::cout << "Use '-v' to print the version info below and exit." << std::endl; std::cout << "Use '--' as the last argument if a file name starts with a dash." << std::endl; - printVersion( exe ); - exit( 1 ); + printVersion(exe); + exit(1); } -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ bool ignoreErr = false; bool strict = false; bool trackStats = true; char c; - if( argc > 4 || argc < 2 ) { - printUse( argv[0] ); + if(argc > 4 || argc < 2) { + printUse(argv[0]); } char opts[] = "itsv"; - while( ( c = sc_getopt( argc, argv, opts ) ) != -1 ) { - switch( c ) { + while((c = sc_getopt(argc, argv, opts)) != -1) { + switch(c) { case 'i': ignoreErr = true; break; @@ -129,11 +134,11 @@ int main( int argc, char * argv[] ) { strict = true; break; case 'v': - printVersion( argv[0] ); - exit( 0 ); + printVersion(argv[0]); + exit(0); case '?': default: - printUse( argv[0] ); + printUse(argv[0]); } } @@ -145,50 +150,50 @@ int main( int argc, char * argv[] ) { // // The registry is always going to be in memory. /////////////////////////////////////////////////////////////////////////////// - Registry registry( SchemaInit ); + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", strict ); - char * flnm; + STEPfile sfile(registry, instance_list, "", strict); + char *flnm; - benchmark stats( "p21 ReadExchangeFile()" ); + benchmark stats("p21 ReadExchangeFile()"); cout << argv[0] << ": load file ..." << endl; - if( argc >= ( sc_optind + 1 ) ) { + if(argc >= (sc_optind + 1)) { flnm = argv[sc_optind]; } else { - flnm = ( char * )"testfile.step"; + flnm = (char *)"testfile.step"; } - sfile.ReadExchangeFile( flnm ); - if( sfile.Error().severity() < SEVERITY_USERMSG ) { - sfile.Error().PrintContents( cout ); + sfile.ReadExchangeFile(flnm); + if(sfile.Error().severity() < SEVERITY_USERMSG) { + sfile.Error().PrintContents(cout); } - if( trackStats ) { + if(trackStats) { stats.stop(); - stats.out( ); + stats.out(); } - if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { - exit( 1 ); + if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { + exit(1); } - checkSchemaName( registry, sfile, ignoreErr ); + checkSchemaName(registry, sfile, ignoreErr); Severity readSev = sfile.Error().severity(); //otherwise, errors from reading will be wiped out by sfile.WriteExchangeFile() cout << argv[0] << ": write file ..." << endl; - if( argc == sc_optind + 2 ) { + if(argc == sc_optind + 2) { flnm = argv[sc_optind + 1]; } else { - flnm = ( char * )"file.out"; + flnm = (char *)"file.out"; } - sfile.WriteExchangeFile( flnm ); - if( sfile.Error().severity() < SEVERITY_USERMSG ) { - sfile.Error().PrintContents( cout ); + sfile.WriteExchangeFile(flnm); + if(sfile.Error().severity() < SEVERITY_USERMSG) { + sfile.Error().PrintContents(cout); } cout << argv[0] << ": " << flnm << " written" << endl; - if( ( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) || ( readSev <= SEVERITY_INCOMPLETE ) ) { //lower is worse - exit( 1 ); + if((sfile.Error().severity() <= SEVERITY_INCOMPLETE) || (readSev <= SEVERITY_INCOMPLETE)) { //lower is worse + exit(1); } } diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index f597b36e4..6de41407b 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -46,7 +46,8 @@ // you what kind of _aggragation_ (no pun intended) you have, as in giving // you a code or "Bag" or something by itself. It probably doesn't work // aesthetically for compound aggregates (i.e., a list of lists). -void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtml ) { +void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) +{ std::string buf; // The type. See src/clstepcore/baseType.h for info @@ -55,45 +56,45 @@ void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtm // the type descriptor for the "referent type," if any. // This is NULL if the attribute is a fundamental type. // All we use it for now is checking for NULL. - const TypeDescriptor * reference = typeDesc->ReferentType(); + const TypeDescriptor *reference = typeDesc->ReferentType(); // Do we need an anchor? int anchor = 0; // First, figure out if we need an anchor... - if( reference ) { // if this has a referent type (i.e., is a non-base type) - if( base != sdaiAGGR ) { // anchor all non-bases except for aggregates + if(reference) { // if this has a referent type (i.e., is a non-base type) + if(base != sdaiAGGR) { // anchor all non-bases except for aggregates anchor = 1; // which we'll take care of recursively } } else { // entities and enumerations show up as base, but we want to // anchor them anyway - if( base == sdaiENUMERATION || base == sdaiINSTANCE ) { + if(base == sdaiENUMERATION || base == sdaiINSTANCE) { anchor = 1; } } // Now, print type, with anchor if necessary - if( anchor && base != sdaiINSTANCE ) { + if(anchor && base != sdaiINSTANCE) { // for regular TYPEs, anchor to the index at that definition outhtml << "Name() << "\">"; - } else if( anchor && base == sdaiINSTANCE ) { + } else if(anchor && base == sdaiINSTANCE) { // for entities, anchor to that entity's page outhtml << "Name(); outhtml << ".html\">"; } - typeDesc->AttrTypeName( buf ); + typeDesc->AttrTypeName(buf); outhtml << buf; - if( base == sdaiAGGR ) { + if(base == sdaiAGGR) { outhtml << " (contains elements of type "; - PrintAttrTypeWithAnchor( typeDesc->AggrElemTypeDescriptor(), outhtml ); + PrintAttrTypeWithAnchor(typeDesc->AggrElemTypeDescriptor(), outhtml); outhtml << ")" << endl; } - if( anchor ) { + if(anchor) { outhtml << ""; } } @@ -102,7 +103,8 @@ void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtm // Given an entity, print out to the HTML file an unordered list of // the entity's attributes and their types. It returns the number of // explicit attributes that the entity has. -int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { +int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) +{ int attrCount = 0; // To traverse the attributes of the entity, we're going to use @@ -110,19 +112,19 @@ int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { // been done using GetHead() and NextNode() of the entity's attribute // list (nearly identical to how the entity lists are traversed), see // PrintParentAttrsHTML() and also main() below. - AttrDescItr aditr( ent->ExplicitAttr() ); - const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); - if( attrDesc != 0 ) { + AttrDescItr aditr(ent->ExplicitAttr()); + const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); + if(attrDesc != 0) { outhtml << "\nName() << " >\n\n"; outhtml << "
    " << endl; - while( attrDesc != 0 ) { + while(attrDesc != 0) { attrCount++; outhtml << "
  • " << attrDesc->Name() << " : "; - if( ( attrDesc->Optional() ) == SDAI_LOGICAL( LTrue ) ) { + if((attrDesc->Optional()) == SDAI_LOGICAL(LTrue)) { outhtml << "optional "; } - PrintAttrTypeWithAnchor( attrDesc->ReferentType(), outhtml ); + PrintAttrTypeWithAnchor(attrDesc->ReferentType(), outhtml); outhtml << endl; attrDesc = aditr.NextAttrDesc(); } @@ -137,8 +139,9 @@ int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { // the inheritance tree of the entity, printing to the HTML file a // description-list structure showing all ancestors. For each ancestor, // the attributes are printed using the PrintAttrsHTML() function above. -void PrintParentAttrsHTML( const EntityDescriptor * ent, - const EntityDescriptor * parent, ofstream & outhtml ) { +void PrintParentAttrsHTML(const EntityDescriptor *ent, + const EntityDescriptor *parent, ofstream &outhtml) +{ // Passing this function the pointer to ent is really cosmetic, so // we can easily print out this 'header' information. outhtml << "\nName() << ">\n\n"; @@ -149,17 +152,17 @@ void PrintParentAttrsHTML( const EntityDescriptor * ent, // Here we're going to traverse the list of supertypes of the parent // using the EntityDescriptorList - const EntityDescriptorList * grandpaList = &( parent->Supertypes() ); - EntityDescLinkNode * grandpaNode = - ( EntityDescLinkNode * )grandpaList->GetHead(); - while( grandpaNode ) { + const EntityDescriptorList *grandpaList = &(parent->Supertypes()); + EntityDescLinkNode *grandpaNode = + (EntityDescLinkNode *)grandpaList->GetHead(); + while(grandpaNode) { // for each "grandparent" of ent, inside a descriptor body (
    ) // recursively call this function... the 'while' takes care of // multiple inheritance: for each grandparent, trace back. outhtml << "
    " << endl; - const EntityDescriptor * grandpa = grandpaNode->EntityDesc(); - PrintParentAttrsHTML( parent, grandpa, outhtml ); - grandpaNode = ( EntityDescLinkNode * )grandpaNode->NextNode(); + const EntityDescriptor *grandpa = grandpaNode->EntityDesc(); + PrintParentAttrsHTML(parent, grandpa, outhtml); + grandpaNode = (EntityDescLinkNode *)grandpaNode->NextNode(); } // Now print the parent's attributes. This calls PrintAttrsHTML() to @@ -167,13 +170,13 @@ void PrintParentAttrsHTML( const EntityDescriptor * ent, // any, we'll check to see if the head of the attribute descriptor list // exists. Conversely, once grabbing the head we could print out // the attributes by following the list (attrNode->NextNode()). - const AttrDescriptorList * attrList = &( parent->ExplicitAttr() ); - AttrDescLinkNode * attrNode = ( AttrDescLinkNode * )attrList->GetHead(); - if( attrNode ) { + const AttrDescriptorList *attrList = &(parent->ExplicitAttr()); + AttrDescLinkNode *attrNode = (AttrDescLinkNode *)attrList->GetHead(); + if(attrNode) { outhtml << "
    " << parent->Name(); outhtml << " has the following attributes" << endl; outhtml << "
    " << endl; - if( PrintAttrsHTML( parent, outhtml ) == 0 ) { + if(PrintAttrsHTML(parent, outhtml) == 0) { outhtml << "none" << endl; } } @@ -184,13 +187,14 @@ void PrintParentAttrsHTML( const EntityDescriptor * ent, /******************** main() ****************************/ -main() { +main() +{ // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry * registry = new Registry( SchemaInit ); + Registry *registry = new Registry(SchemaInit); // Rather than using the standard Registry class here, as in the treg // example, we are using MyRegistry, which is derived from the original. @@ -203,7 +207,7 @@ main() { registry->ResetSchemas(); registry->ResetTypes(); - const SchemaDescriptor * schema = registry->NextSchema(); + const SchemaDescriptor *schema = registry->NextSchema(); int num_ents = registry->GetEntityCnt(); cout << "Processing schema " << schema->Name(); cout << " with " << num_ents << " entities." << endl; @@ -213,7 +217,7 @@ main() { // the schema. cout << "Creating 'index.html'" << endl; - ofstream root( "index.html" ); + ofstream root("index.html"); root << "" << schema->Name() << "" << endl; root << "

    Schema: " << schema->Name() << "

    " << endl; @@ -223,11 +227,11 @@ main() { root << "

    Types

    " << endl; root << "
      " << endl; - const TypeDescriptor * type; + const TypeDescriptor *type; type = registry->NextType(); root << "\n"; root << "\n"; - while( type != 0 ) { + while(type != 0) { cout << "."; root << "
    • Name() << "\">"; root << type->Name() << ": "; @@ -250,12 +254,12 @@ main() { // for ancestors, but we'll use subs to list subclasses and make links // to them. - const EntityDescriptor * ent; - const EntityDescriptorList * supers; - const EntityDescriptorList * subs; - EntityDescLinkNode * entNode; + const EntityDescriptor *ent; + const EntityDescriptorList *supers; + const EntityDescriptorList *subs; + EntityDescLinkNode *entNode; - for( int i = 0; i < num_ents; i++ ) { + for(int i = 0; i < num_ents; i++) { ent = registry->NextEntity(); cout << "Processing " << ent->Name() << endl; @@ -264,8 +268,8 @@ main() { root << ent->Name() << "" << endl; // construct page for entity - char * tmpstr = new char[strlen( ent->Name() ) + 6]; - ofstream entout( strcat( strcpy( tmpstr, ent->Name() ), ".html" ) ); + char *tmpstr = new char[strlen(ent->Name()) + 6]; + ofstream entout(strcat(strcpy(tmpstr, ent->Name()), ".html")); delete [] tmpstr; entout << "Entity " << ent->Name() << "" << endl; entout << "

      " << ent->Name() << "

      " << endl; @@ -274,22 +278,22 @@ main() { entout << "
      \n

      Inherited Attributes

      " << endl; entout << "Name() << ">\n"; - supers = &( ent->Supertypes() ); - entNode = ( EntityDescLinkNode * )supers->GetHead(); - if( !entNode ) { + supers = &(ent->Supertypes()); + entNode = (EntityDescLinkNode *)supers->GetHead(); + if(!entNode) { entout << "none" << endl; } - while( entNode ) { + while(entNode) { // call PrintParentAttrsHTML to explore the parents // of the entity, for each parent. - const EntityDescriptor * parent = entNode->EntityDesc(); - PrintParentAttrsHTML( ent, parent, entout ); - entNode = ( EntityDescLinkNode * )entNode->NextNode(); + const EntityDescriptor *parent = entNode->EntityDesc(); + PrintParentAttrsHTML(ent, parent, entout); + entNode = (EntityDescLinkNode *)entNode->NextNode(); } // local attributes entout << "
      \n

      Local Attributes

      " << endl; - if( PrintAttrsHTML( ent, entout ) == 0 ) { + if(PrintAttrsHTML(ent, entout) == 0) { entout << "none" << endl; } @@ -298,16 +302,16 @@ main() { // of the entity, a little more simply than in PrintParentAttrsHTML() entout << "
      \n

      Subtypes

      " << endl; entout << "\n"; - subs = &( ent->Subtypes() ); - entNode = ( EntityDescLinkNode * )subs->GetHead(); - if( entNode ) { + subs = &(ent->Subtypes()); + entNode = (EntityDescLinkNode *)subs->GetHead(); + if(entNode) { entout << "
        " << endl; - EntityDescriptor * child; - while( entNode ) { + EntityDescriptor *child; + while(entNode) { child = entNode->EntityDesc(); entout << "
      • Name() << ".html\">"; entout << child->Name() << "" << endl; - entNode = ( EntityDescLinkNode * )entNode->NextNode(); + entNode = (EntityDescLinkNode *)entNode->NextNode(); } entout << "
      " << endl; } else { diff --git a/src/test/tests.h b/src/test/tests.h index 52fcb3a59..148fca03f 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -31,4 +31,4 @@ #include -extern void SchemaInit( Registry & ); +extern void SchemaInit(Registry &); diff --git a/src/test/tio/tio.cc b/src/test/tio/tio.cc index a73aab4b2..9936965bd 100644 --- a/src/test/tio/tio.cc +++ b/src/test/tio/tio.cc @@ -18,13 +18,14 @@ #define DONT_NEED_HEADER #include "tests.h" -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ int using_outfile = 0; - if( argc > 3 || argc < 2 ) { + if(argc > 3 || argc < 2) { cout << "Syntax: tio infile [outfile]" << endl; - exit( 1 ); - } else if( argc > 2 ) { + exit(1); + } else if(argc > 2) { using_outfile = 1; // output filename is in argv[2] } @@ -36,7 +37,7 @@ int main( int argc, char * argv[] ) { // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry * registry = new Registry( SchemaInit ); + Registry *registry = new Registry(SchemaInit); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -46,7 +47,7 @@ int main( int argc, char * argv[] ) { // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile * sfile = new STEPfile( *registry, instance_list ); + STEPfile *sfile = new STEPfile(*registry, instance_list); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -59,28 +60,28 @@ int main( int argc, char * argv[] ) { // The instances get pointers into the InstMgr, and each type // and entity gets a pointer into the registry. cout << "\n### Reading exchange file from " << argv[1] << endl; - sfile->ReadExchangeFile( argv[1] ); + sfile->ReadExchangeFile(argv[1]); // Just checking... ;-) cout << "\n### The InstMgr says there are "; cout << instance_list.InstanceCount() << " instantiated objects" << endl; cout << "\n### Here is the exchange file:" << endl << endl; - sfile->WriteExchangeFile( cout ); + sfile->WriteExchangeFile(cout); // If you append in another exchange file, it creates new instances // starting at a 1000-block of numbers. Just 'Read'ing again // would clobber the instances already there. cout << "\n### Now appending in another copy" << endl; - sfile->AppendExchangeFile( argv[1] ); + sfile->AppendExchangeFile(argv[1]); // Browsing the registry... cout << "\n### Here is a list of entities now in the registry:" << endl; registry->ResetEntities(); - const EntityDescriptor * ent = registry->NextEntity(); + const EntityDescriptor *ent = registry->NextEntity(); std::string tmpstr; - while( ent ) { - cout << ent->Name() << ": " << ent->TypeString( tmpstr ) << endl; + while(ent) { + cout << ent->Name() << ": " << ent->TypeString(tmpstr) << endl; ent = registry->NextEntity(); } @@ -90,22 +91,22 @@ int main( int argc, char * argv[] ) { int numInstances = instance_list.InstanceCount(); cout << "### The InstMgr says we have " << numInstances; cout << " things instantiated.\n"; - for( int i = 0; i < numInstances; i++ ) { - cout << i << ": " << instance_list.GetSTEPentity( i )->EntityName(); + for(int i = 0; i < numInstances; i++) { + cout << i << ": " << instance_list.GetSTEPentity(i)->EntityName(); cout << " (" << - instance_list.GetSTEPentity( i )->eDesc->Description(); + instance_list.GetSTEPentity(i)->eDesc->Description(); cout << ")" << endl; } // Dump everything to STEPfiles... cout << "\n### Here it is in STEPfile format:" << endl << endl; - sfile->WriteExchangeFile( cout ); + sfile->WriteExchangeFile(cout); - if( using_outfile ) { - ofstream stepout( argv[2] ); + if(using_outfile) { + ofstream stepout(argv[2]); cout << "\n### Writing that to outfile " << argv[2] << endl; - sfile->WriteExchangeFile( stepout ); + sfile->WriteExchangeFile(stepout); } - exit( 0 ); + exit(0); } diff --git a/src/test/treg/treg.cc b/src/test/treg/treg.cc index aea466013..c35f2b33f 100644 --- a/src/test/treg/treg.cc +++ b/src/test/treg/treg.cc @@ -27,16 +27,17 @@ // put data values in its attributes. PopulateEntity doesn't care what // attributes your entity has. It goes through them, one at a time, checks // their type, and puts an appropriate random value in. -void PopulateEntity( STEPentity * ent ) { +void PopulateEntity(STEPentity *ent) +{ int attrCount = ent->AttributeCount(); cout << "Populating " << ent->EntityName() << " which has "; cout << attrCount << " attributes." << endl; ent->ResetAttributes(); // start us walking at the top of the list - STEPattribute * attr = ent->NextAttribute(); - while( attr != 0 ) { - const AttrDescriptor * attrDesc = attr->aDesc; + STEPattribute *attr = ent->NextAttribute(); + while(attr != 0) { + const AttrDescriptor *attrDesc = attr->aDesc; cout << " attribute " << attrDesc->Name(); cout << " [" << attrDesc->TypeName() << "] = "; int needOutput = 1; // true if we need to output the value @@ -47,7 +48,7 @@ void PopulateEntity( STEPentity * ent ) { // a string value as the value of the attribute. Then, depending on // the type of the attribute, put something nearly appropriate in. ostringstream valstr; - switch( attrDesc->NonRefType() ) { + switch(attrDesc->NonRefType()) { case INTEGER_TYPE: // for these types, just put in a random number case REAL_TYPE: // from 0-99. case NUMBER_TYPE: @@ -62,8 +63,8 @@ void PopulateEntity( STEPentity * ent ) { case BOOLEAN_TYPE: // the trick here is that the value needs to be case LOGICAL_TYPE: { // the word, not the int value, because of StrToVal cout << "(enum/bool/logi) "; - STEPenumeration * se = attr->ptr.e; // grab the enumeration... - valstr << se->element_at( rand() % se->no_elements() ); + STEPenumeration *se = attr->ptr.e; // grab the enumeration... + valstr << se->element_at(rand() % se->no_elements()); } break; default: // for other stuff like aggregates and selects, just leave @@ -73,24 +74,25 @@ void PopulateEntity( STEPentity * ent ) { } valstr << ends; // flush and null-terminate the stream /*** char *val = valstr.str(); ***/ // fix stream into char* string - char * val = &( valstr.str()[0] ); - if( needOutput ) { + char *val = &(valstr.str()[0]); + if(needOutput) { cout << val << endl; } - attr->StrToVal( val ); // and assign + attr->StrToVal(val); // and assign attr = ent->NextAttribute(); } } -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ int using_outfile = 0; - if( argc > 2 ) { + if(argc > 2) { cout << "Syntax: treg [filename]" << endl; - exit( 1 ); - } else if( argc > 1 ) { + exit(1); + } else if(argc > 1) { using_outfile = 1; // output filename is in argc[1] } @@ -99,7 +101,7 @@ int main( int argc, char * argv[] ) { // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry * registry = new Registry( SchemaInit ); + Registry *registry = new Registry(SchemaInit); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -109,7 +111,7 @@ int main( int argc, char * argv[] ) { // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile * sfile = new STEPfile( *registry, instance_list ); + STEPfile *sfile = new STEPfile(*registry, instance_list); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -125,7 +127,7 @@ int main( int argc, char * argv[] ) { // to store a pointer to one of each. int num_ents = registry->GetEntityCnt(); - STEPentity ** SEarray = new STEPentity*[num_ents]; + STEPentity **SEarray = new STEPentity*[num_ents]; // "Reset" the Schema and Entity hash tables... this sets things up // so we can walk through the table using registry->NextEntity() @@ -135,46 +137,46 @@ int main( int argc, char * argv[] ) { // Print out what schema we're running through. - const SchemaDescriptor * schema = registry->NextSchema(); + const SchemaDescriptor *schema = registry->NextSchema(); cout << "Building entities in schema " << schema->Name() << endl; // "Loop" through the schema, building one of each entity type. - const EntityDescriptor * ent; // needs to be declared const... - for( int i = 0; i < num_ents; i++ ) { + const EntityDescriptor *ent; // needs to be declared const... + for(int i = 0; i < num_ents; i++) { ent = registry->NextEntity(); cout << " Building entity " << ent->Name() << endl; // Build object, using its name, through the registry - SEarray[i] = registry->ObjCreate( ent->Name() ); + SEarray[i] = registry->ObjCreate(ent->Name()); // Add each realized entity to the instance list - instance_list.Append( SEarray[i], completeSE ); + instance_list.Append(SEarray[i], completeSE); // Put some data into each instance - PopulateEntity( SEarray[i] ); + PopulateEntity(SEarray[i]); } // Print out all entities - SEarrIterator SEitr( ( const STEPentity ** ) SEarray, num_ents ); + SEarrIterator SEitr((const STEPentity **) SEarray, num_ents); // the above cast is needed because the SEarrIterator // constructor takes a const entity array pointer argument cout << endl << "Here are the entities instantiated, via the SEarray:"; cout << endl; - for( SEitr = 0; !SEitr; ++SEitr ) { - SEitr()->STEPwrite( cout ); + for(SEitr = 0; !SEitr; ++SEitr) { + SEitr()->STEPwrite(cout); } cout << endl << "Here are all the entities via the STEPfile:" << endl; - sfile->WriteExchangeFile( cout ); + sfile->WriteExchangeFile(cout); - if( using_outfile ) { + if(using_outfile) { cout << "\nWriting STEPfile to output file " << argv[1] << endl; - ofstream step_out( argv[1] ); - sfile->WriteExchangeFile( step_out ); + ofstream step_out(argv[1]); + sfile->WriteExchangeFile(step_out); } - exit( 0 ); + exit(0); } diff --git a/src/test/tstatic/tstatic.cc b/src/test/tstatic/tstatic.cc index eb6d6f2c5..56f0c4e7d 100644 --- a/src/test/tstatic/tstatic.cc +++ b/src/test/tstatic/tstatic.cc @@ -17,7 +17,8 @@ /* STEPentity* Iterator class definition */ #include "../SEarritr.h" -int main() { +int main() +{ // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see @@ -30,15 +31,15 @@ int main() { // For specifics on the structure of the entity classes, see // the SdaiEXAMPLE_SCHEMA.h header file. - const STEPentity * entArr[4]; // our array of entity pointers + const STEPentity *entArr[4]; // our array of entity pointers cout << "Creating an SdaiRectangle..." << endl; SdaiRectangle rect; - rect.item_name_( "MyRect" ); - rect.item_color_( Color__orange ); - rect.number_of_sides_( 4 ); - rect.height_( 5 ); - rect.width_( 10 ); + rect.item_name_("MyRect"); + rect.item_color_(Color__orange); + rect.number_of_sides_(4); + rect.height_(5); + rect.width_(10); cout << "Rectangle: (" << rect.opcode() << ") " << endl; cout << " Name: " << rect.item_name_().c_str() << endl; cout << " Color: " << rect.item_color_() << endl; @@ -50,11 +51,11 @@ int main() { cout << "Creating an SdaiSquare..." << endl; SdaiSquare square; - square.item_name_( "MySquare" ); - square.item_color_( Color__green ); - square.number_of_sides_( 4 ); - square.height_( 3 ); - square.width_( 3 ); + square.item_name_("MySquare"); + square.item_color_(Color__green); + square.number_of_sides_(4); + square.height_(3); + square.width_(3); cout << "Square: (" << square.opcode() << ") " << endl; cout << " Name: " << square.item_name_().c_str() << endl; cout << " Color: " << square.item_color_() << endl; @@ -66,12 +67,12 @@ int main() { cout << "Creating an SdaiTriangle..." << endl; SdaiTriangle tri; - tri.item_name_( "MyTri" ); - tri.item_color_( Color__blue ); - tri.number_of_sides_( 3 ); - tri.side1_length_( 3 ); - tri.side2_length_( 4 ); - tri.side3_length_( 5 ); + tri.item_name_("MyTri"); + tri.item_color_(Color__blue); + tri.number_of_sides_(3); + tri.side1_length_(3); + tri.side2_length_(4); + tri.side3_length_(5); cout << "Triangle: (" << tri.opcode() << ") " << endl; cout << " Name: " << tri.item_name_().c_str() << endl; cout << " Color: " << tri.item_color_() << endl; @@ -84,10 +85,10 @@ int main() { cout << "Creating an SdaiCircle..." << endl; SdaiCircle circ; - circ.item_name_( "MyCirc" ); - circ.item_color_( Color__red ); - circ.number_of_sides_( 1 ); - circ.radius_( 15 ); + circ.item_name_("MyCirc"); + circ.item_color_(Color__red); + circ.number_of_sides_(1); + circ.radius_(15); cout << "Circle: (" << circ.opcode() << ") " << endl; cout << " Name: " << circ.item_name_().c_str() << endl; cout << " Color: " << circ.item_color_() << endl; @@ -97,9 +98,9 @@ int main() { entArr[3] = ˆ cout << "And now, all entities in STEP Exchange Format!" << endl << endl; - SEarrIterator SEitr( entArr, 4 ); - for( SEitr = 0; !SEitr; ++SEitr ) { - SEitr()->STEPwrite( cout ); + SEarrIterator SEitr(entArr, 4); + for(SEitr = 0; !SEitr; ++SEitr) { + SEitr()->STEPwrite(cout); } } diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index fe103ab8e..d7394417f 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -13,111 +13,112 @@ #include "SdaiTEST_ARRAY_BOUNDS_EXPR.h" -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ - if( argc != 2 ) { + if(argc != 2) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit( 1 ); + exit(1); } - Registry registry( SchemaInit ); + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", false ); + STEPfile sfile(registry, instance_list, "", false); - sfile.ReadExchangeFile( argv[1] ); + sfile.ReadExchangeFile(argv[1]); Severity readSev = sfile.Error().severity(); - if( readSev != SEVERITY_NULL ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(readSev != SEVERITY_NULL) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } // Keeps track of the last processed ent id int search_index = 0; //find structured_mesh, find the array attribute, and check its bounds as much as possible. need an instance to check 100%. - const EntityDescriptor * ed = registry.FindEntity( "Structured_mesh" ); - AttrDescItr aditr( ed->ExplicitAttr() ); - const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); + const EntityDescriptor *ed = registry.FindEntity("Structured_mesh"); + AttrDescItr aditr(ed->ExplicitAttr()); + const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); int descAggrCount = 0; - while( attrDesc != 0 ) { - if( ( attrDesc->NonRefType() == ARRAY_TYPE ) && ( attrDesc->AggrElemType() == sdaiINTEGER ) ) { + while(attrDesc != 0) { + if((attrDesc->NonRefType() == ARRAY_TYPE) && (attrDesc->AggrElemType() == sdaiINTEGER)) { cout << "Array attribute: " << attrDesc->Name(); - const AggrTypeDescriptor * atd = ( const AggrTypeDescriptor * ) attrDesc->DomainType(); - if( !( atd->Bound1Type() == bound_constant ) || !( atd->Bound2Type() == bound_runtime ) ) { + const AggrTypeDescriptor *atd = (const AggrTypeDescriptor *) attrDesc->DomainType(); + if(!(atd->Bound1Type() == bound_constant) || !(atd->Bound2Type() == bound_runtime)) { cerr << "Invalid bounds. Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } cout << " -- bound 1 is a constant (" << atd->Bound1() << "). bound 2 depends upon the instance." << endl; descAggrCount++; } attrDesc = aditr.NextAttrDesc(); } - if( descAggrCount != 1 ) { + if(descAggrCount != 1) { cerr << "Expected 1 aggregate attribute descriptor, found " << descAggrCount << ". Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } // Loop over the instances in the file, check the bound for each - SdaiStructured_mesh * ent; - while( ENTITY_NULL != ( ent = ( SdaiStructured_mesh * ) - instance_list.GetApplication_instance( "Structured_mesh", search_index ) ) ) { + SdaiStructured_mesh *ent; + while(ENTITY_NULL != (ent = (SdaiStructured_mesh *) + instance_list.GetApplication_instance("Structured_mesh", search_index))) { SDAI_Integer b2; int instAggrCnt = 0; - IntAggregate * vertex_counts = ent->vertex_counts_(); + IntAggregate *vertex_counts = ent->vertex_counts_(); int cnt = ent->AttributeCount(); - STEPattributeList & sal = ent->attributes; + STEPattributeList &sal = ent->attributes; int id = ent->StepFileId(); cout << "Ent #" << id << " - "; - if( cnt != 3 ) { + if(cnt != 3) { cerr << "Expected 3 attributes, found " << cnt << ". Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - if( id > 2 ) { + if(id > 2) { cerr << "Expected 2 instances, found " << cnt << ". Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } //loop over the attributes - for( int i = 0; i < cnt; i++ ) { - const AttrDescriptor * ad = sal[i].getADesc(); - if( ( ad->NonRefType() == ARRAY_TYPE ) && ( ad->AggrElemType() == sdaiINTEGER ) ) { - b2 = ( ( AggrTypeDescriptor * ) ad->DomainType() )->Bound2Runtime( ent ); + for(int i = 0; i < cnt; i++) { + const AttrDescriptor *ad = sal[i].getADesc(); + if((ad->NonRefType() == ARRAY_TYPE) && (ad->AggrElemType() == sdaiINTEGER)) { + b2 = ((AggrTypeDescriptor *) ad->DomainType())->Bound2Runtime(ent); cout << "bound 2: " << b2 << " values: "; instAggrCnt++; - if( ( ( id == 1 ) && ( b2 != 3 ) ) || ( ( id == 2 ) && ( b2 != 5 ) ) ) { + if(((id == 1) && (b2 != 3)) || ((id == 2) && (b2 != 5))) { cerr << "Instance " << id << ": value " << b2 << " is invalid for bound 2."; cerr << " Expecting 3 for instance #1 or 5 for #2." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } } } int node = 0; int aggrValues[2][5] = {{1, 2, 3, -1, -1}, {9, 34, 0, 3, 999999}}; - IntNode * aggrNode = ( IntNode * ) vertex_counts->GetHead(); - while( aggrNode != 0 ) { - if( node >= b2 ) { + IntNode *aggrNode = (IntNode *) vertex_counts->GetHead(); + while(aggrNode != 0) { + if(node >= b2) { cerr << "Instance " << id << ": Number of values exceeds upper bound. Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } cout << aggrNode->value << " "; - if( aggrValues[id - 1][node] != aggrNode->value ) { + if(aggrValues[id - 1][node] != aggrNode->value) { cerr << "Instance " << id << ": aggregate value " << aggrNode->value << " at index " << node << " is incorrect. Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - aggrNode = ( IntNode * ) aggrNode->NextNode(); + aggrNode = (IntNode *) aggrNode->NextNode(); node++; } cout << endl; - if( instAggrCnt != 1 ) { + if(instAggrCnt != 1) { cerr << "Expected 1 aggregate attribute in this instance, found " << instAggrCnt << ". Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - MgrNode * mnode = instance_list.FindFileId( id ); - search_index = instance_list.GetIndex( mnode ) + 1; + MgrNode *mnode = instance_list.FindFileId(id); + search_index = instance_list.GetIndex(mnode) + 1; } } diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index bc624143a..c0129203c 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -19,42 +19,43 @@ #include "schema.h" -int main( int argc, char * argv[] ) { - Registry registry( SchemaInit ); +int main(int argc, char *argv[]) +{ + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", false ); + STEPfile sfile(registry, instance_list, "", false); bool foundMatch = false; - const char * attrname = "description"; - if( argc != 2 ) { - exit( EXIT_FAILURE ); + const char *attrname = "description"; + if(argc != 2) { + exit(EXIT_FAILURE); } - sfile.ReadExchangeFile( argv[1] ); + sfile.ReadExchangeFile(argv[1]); - if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } - const SdaiWindow * wind = dynamic_cast< SdaiWindow * >( instance_list.GetApplication_instance( "window" ) ); + const SdaiWindow *wind = dynamic_cast< SdaiWindow * >(instance_list.GetApplication_instance("window")); int i = 0; - if( wind ) { + if(wind) { STEPattributeList attrlist = wind->attributes; - for( ; i < attrlist.list_length(); i++ ) { + for(; i < attrlist.list_length(); i++) { cout << "attr " << i << ": " << attrlist[i].Name() << endl; - if( 0 == strcmp( attrname, attrlist[i].Name() ) ) { + if(0 == strcmp(attrname, attrlist[i].Name())) { foundMatch = true; cout << "attribute " << '"' << attrname << '"' << " found at " << i << endl; } } } - if( !i ) { + if(!i) { cout << "no attrs found" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - if( !foundMatch ) { + if(!foundMatch) { cout << "attribute " << '"' << attrname << '"' << " not found" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } else { - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } } diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 2ff14bc3f..92985a617 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -21,76 +21,78 @@ #include "schema.h" ///first way of finding inverse attrs -bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { - const Inverse_attribute * ia; +bool findInverseAttrs1(InverseAItr iai, InstMgr &instList) +{ + const Inverse_attribute *ia; int j = 0; - while( 0 != ( ia = iai.NextInverse_attribute() ) ) { + while(0 != (ia = iai.NextInverse_attribute())) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - SdaiReldefinesbytype * rdbt; + SdaiReldefinesbytype *rdbt; int ent_id = 0; - while( 0 != ( rdbt = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( "reldefinesbytype", ent_id ) ) ) { + while(0 != (rdbt = (SdaiReldefinesbytype *) instList.GetApplication_instance("reldefinesbytype", ent_id))) { int i = rdbt->StepFileId(); - if( i < ent_id ) { + if(i < ent_id) { break; } - EntityAggregate * relObj = rdbt->relatedobjects_(); - if( !( relObj && ( relObj->is_null() == 0 ) ) ) { + EntityAggregate *relObj = rdbt->relatedobjects_(); + if(!(relObj && (relObj->is_null() == 0))) { return false; } else { - EntityNode * en = ( EntityNode * ) relObj->GetHead(); - SdaiObject * obj = ( SdaiObject * ) en->node; + EntityNode *en = (EntityNode *) relObj->GetHead(); + SdaiObject *obj = (SdaiObject *) en->node; cout << "file id " << obj->StepFileId() << "; name " - << instList.GetApplication_instance( obj->StepFileId() - 1 )->eDesc->Name() << endl; + << instList.GetApplication_instance(obj->StepFileId() - 1)->eDesc->Name() << endl; } ent_id = i; } j++; } - return( j != 0 ); + return(j != 0); } -int main( int argc, char * argv[] ) { - Registry registry( SchemaInit ); +int main(int argc, char *argv[]) +{ + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", false ); + STEPfile sfile(registry, instance_list, "", false); bool inverseAttrsFound = false; - if( argc != 2 ) { + if(argc != 2) { cout << "wrong args" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - sfile.ReadExchangeFile( argv[1] ); + sfile.ReadExchangeFile(argv[1]); - if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor * ed = registry.FindEntity( "window" ); - InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes - if( findInverseAttrs1( iaIter, instance_list ) ) { + const EntityDescriptor *ed = registry.FindEntity("window"); + InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes + if(findInverseAttrs1(iaIter, instance_list)) { inverseAttrsFound = true; } //now, find inherited inverse attrs - supertypesIterator iter( ed ); - const EntityDescriptor * super; - for( ; !iter.empty(); iter++ ) { + supertypesIterator iter(ed); + const EntityDescriptor *super; + for(; !iter.empty(); iter++) { super = iter.current(); cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter( &( super->InverseAttr() ) ); - if( findInverseAttrs1( superIaIter, instance_list ) ) { + InverseAItr superIaIter(&(super->InverseAttr())); + if(findInverseAttrs1(superIaIter, instance_list)) { inverseAttrsFound = true; } } - if( !inverseAttrsFound ) { + if(!inverseAttrsFound) { cout << "no inverse attrs found" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index d30eabe7b..b017a7b71 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -20,20 +20,21 @@ #include "schema.h" ///second way of finding inverse attrs -bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { - const Inverse_attribute * ia; +bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) +{ + const Inverse_attribute *ia; int j = 0; - while( 0 != ( ia = iai.NextInverse_attribute() ) ) { + while(0 != (ia = iai.NextInverse_attribute())) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - const EntityDescriptor * inv_ed = reg.FindEntity( ia->inverted_entity_id_() ); - AttrDescItr attr_desc_itr( inv_ed->ExplicitAttr() ); - const AttrDescriptor * attrDesc; + const EntityDescriptor *inv_ed = reg.FindEntity(ia->inverted_entity_id_()); + AttrDescItr attr_desc_itr(inv_ed->ExplicitAttr()); + const AttrDescriptor *attrDesc; int k = 0; - while( 0 != ( attrDesc = attr_desc_itr.NextAttrDesc() ) ) { - if( !strcmp( ia->inverted_attr_id_(), attrDesc->Name() ) ) { + while(0 != (attrDesc = attr_desc_itr.NextAttrDesc())) { + if(!strcmp(ia->inverted_attr_id_(), attrDesc->Name())) { cout << "attribute '" << attrDesc->Name() << "' is attribute #" << k << " of '" << inv_ed->Name() << "'." << endl; @@ -41,20 +42,20 @@ bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { // entity type 'inv_ed', looking for references to 'ed' in the // attribute described by 'attrDesc' int l = 0; - SdaiReldefinesbytype * inst; - while( 0 != ( inst = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( inv_ed->Name(), l ) ) ) { + SdaiReldefinesbytype *inst; + while(0 != (inst = (SdaiReldefinesbytype *) instList.GetApplication_instance(inv_ed->Name(), l))) { int i = inst->StepFileId(); - if( i < l ) { + if(i < l) { break; } STEPattributeList attrlist = inst->attributes; - if( attrlist.list_length() < k + 1 ) { + if(attrlist.list_length() < k + 1) { return false; } STEPattribute sa = attrlist[k]; - if( sa.getADesc()->DomainType()->Type() == SET_TYPE ) { - STEPaggregate * aggr = sa.Aggregate(); - if( !aggr || aggr->is_null() != 0 ) { + if(sa.getADesc()->DomainType()->Type() == SET_TYPE) { + STEPaggregate *aggr = sa.Aggregate(); + if(!aggr || aggr->is_null() != 0) { cout << "findInverseAttrs2 FAILED" << endl; return false; } @@ -69,45 +70,46 @@ bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { } j++; } - return( j != 0 ); + return(j != 0); } -int main( int argc, char * argv[] ) { - Registry registry( SchemaInit ); +int main(int argc, char *argv[]) +{ + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", false ); + STEPfile sfile(registry, instance_list, "", false); bool inverseAttrsFound = false; - if( argc != 2 ) { - exit( EXIT_FAILURE ); + if(argc != 2) { + exit(EXIT_FAILURE); } - sfile.ReadExchangeFile( argv[1] ); + sfile.ReadExchangeFile(argv[1]); - if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor * ed = registry.FindEntity( "window" ); - InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes - if( findInverseAttrs2( iaIter, instance_list, registry ) ) { + const EntityDescriptor *ed = registry.FindEntity("window"); + InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes + if(findInverseAttrs2(iaIter, instance_list, registry)) { inverseAttrsFound = true; } //now, find inherited inverse attrs - EntityDescItr edi( ed->GetSupertypes() ); - const EntityDescriptor * super; - while( 0 != ( super = edi.NextEntityDesc() ) ) { + EntityDescItr edi(ed->GetSupertypes()); + const EntityDescriptor *super; + while(0 != (super = edi.NextEntityDesc())) { cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter( &( super->InverseAttr() ) ); - if( findInverseAttrs2( superIaIter, instance_list, registry ) ) { + InverseAItr superIaIter(&(super->InverseAttr())); + if(findInverseAttrs2(superIaIter, instance_list, registry)) { inverseAttrsFound = true; } } - if( !inverseAttrsFound ) { + if(!inverseAttrsFound) { cout << "no inverse attrs found" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 866801dbf..f1e5d842b 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -22,50 +22,51 @@ #include #include "schema.h" -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ int exitStatus = EXIT_SUCCESS; - if( argc != 2 ) { + if(argc != 2) { cerr << "Wrong number of args!" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } lazyInstMgr lim; - lim.initRegistry( SchemaInit ); + lim.initRegistry(SchemaInit); - lim.openFile( argv[1] ); + lim.openFile(argv[1]); //find attributes - instanceTypes_t::cvector * insts = lim.getInstances( "window" ); - if( !insts || insts->empty() ) { + instanceTypes_t::cvector *insts = lim.getInstances("window"); + if(!insts || insts->empty()) { cout << "No window instances found!" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - SdaiWindow * instance = dynamic_cast< SdaiWindow * >( lim.loadInstance( insts->at( 0 ) ) ); - if( !instance ) { + SdaiWindow *instance = dynamic_cast< SdaiWindow * >(lim.loadInstance(insts->at(0))); + if(!instance) { cout << "Problem loading instance" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } cout << "instance #" << instance->StepFileId() << endl; SDAI_Application_instance::iAMap_t::value_type v = instance->getInvAttr("isdefinedby"); iAstruct attr = v.second; //instance->getInvAttr(ia); - if( attr.a && attr.a->EntryCount() ) { - cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; - } else { - cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void*) v.first << endl; - exitStatus = EXIT_FAILURE; - } + if(attr.a && attr.a->EntryCount()) { + cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; + } else { + cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void *) v.first << endl; + exitStatus = EXIT_FAILURE; + } - EntityAggregate * aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... - if( attr.a != aggr ) { + EntityAggregate *aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... + if(attr.a != aggr) { cout << "Error! got different EntityAggregate's when using map vs method" << endl; exitStatus = EXIT_FAILURE; } - if( aggr && aggr->EntryCount() ) { + if(aggr && aggr->EntryCount()) { cout << "Found " << aggr->EntryCount() << " inverse references." << endl; } else { cout << "inverse attr is not defined" << endl; exitStatus = EXIT_FAILURE; } - exit( exitStatus ); + exit(exitStatus); } diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 3b9e17d04..ae6071ad0 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -41,72 +41,75 @@ // NOTE this test requires std::thread, part of C++11. It will fail to compile otherwise. -void readProgressParallel( STEPfile & f, float & maxProgress ) { - while( 1 ) { +void readProgressParallel(STEPfile &f, float &maxProgress) +{ + while(1) { float p = f.GetReadProgress(); - if( p > maxProgress ) { + if(p > maxProgress) { maxProgress = p; } - DELAY( 5 ); + DELAY(5); } } -void writeProgressParallel( STEPfile & f, float & maxProgress ) { - while( 1 ) { +void writeProgressParallel(STEPfile &f, float &maxProgress) +{ + while(1) { float p = f.GetWriteProgress(); - if( p > maxProgress ) { + if(p > maxProgress) { maxProgress = p; } - DELAY( 5 ); + DELAY(5); } } -int main( int argc, char * argv[] ) { +int main(int argc, char *argv[]) +{ float progress = 0.0; - if( argc != 2 ) { + if(argc != 2) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } - Registry registry( SchemaInit ); + Registry registry(SchemaInit); InstMgr instance_list; - STEPfile sfile( registry, instance_list, "", false ); + STEPfile sfile(registry, instance_list, "", false); // read the file - std::thread r( readProgressParallel, std::ref( sfile ), std::ref( progress ) ); - sfile.ReadExchangeFile( argv[1] ); + std::thread r(readProgressParallel, std::ref(sfile), std::ref(progress)); + sfile.ReadExchangeFile(argv[1]); r.detach(); Severity readSev = sfile.Error().severity(); - if( readSev != SEVERITY_NULL ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(readSev != SEVERITY_NULL) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } - if( progress < 55 ) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. + if(progress < 55) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. cerr << "Error: Read progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } else { cout << "Read progress reached " << progress << "% - success." << endl; } progress = 0; // write the file - std::thread w( writeProgressParallel, std::ref( sfile ), std::ref( progress ) ); - sfile.WriteExchangeFile( "out.stp" ); + std::thread w(writeProgressParallel, std::ref(sfile), std::ref(progress)); + sfile.WriteExchangeFile("out.stp"); w.detach(); readSev = sfile.Error().severity(); - if( readSev != SEVERITY_NULL ) { - sfile.Error().PrintContents( cout ); - exit( EXIT_FAILURE ); + if(readSev != SEVERITY_NULL) { + sfile.Error().PrintContents(cout); + exit(EXIT_FAILURE); } - if( progress < 55 ) { + if(progress < 55) { cerr << "Error: Write progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit( EXIT_FAILURE ); + exit(EXIT_FAILURE); } else { cout << "Write progress reached " << progress << "% - success." << endl; } - exit( EXIT_SUCCESS ); + exit(EXIT_SUCCESS); } From 713b3e67b6c7d2e8529661cd3de1e8ba2086907e Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 9 Dec 2020 09:29:59 -0500 Subject: [PATCH 088/244] Try exporting MEMORYinitialize and FACTORYinitialize for Windows. --- include/express/factory.h | 4 +++- include/express/memory.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/express/factory.h b/include/express/factory.h index 77075720d..4942256fe 100644 --- a/include/express/factory.h +++ b/include/express/factory.h @@ -1,6 +1,8 @@ #ifndef __FACTORY_H_ #define __FACTORY_H_ -void FACTORYinitialize(); +#include "sc_export.h" + +SC_EXPRESS_EXPORT void FACTORYinitialize(); #endif /* __FACTORY_H_ */ diff --git a/include/express/memory.h b/include/express/memory.h index 77357cf7e..3d1e58c74 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -1,6 +1,8 @@ #ifndef __MEMORY_H #define __MEMORY_H -void MEMORYinitialize(); +#include "sc_export.h" + +SC_EXPRESS_EXPORT void MEMORYinitialize(); #endif // __MEMORY_H From f8783577d5cb9f26c22ebc1c0a9621fa7a34ff27 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 12:58:49 -0500 Subject: [PATCH 089/244] Clear some C++ compilation warnings from the main stepcode libs --- src/base/judy/src/judy.c | 3 +- src/cldai/sdaiEntity_extent.cc | 2 +- src/cldai/sdaiEntity_extent.h | 2 +- src/cldai/sdaiModel_contents.cc | 6 ++-- src/cldai/sdaiModel_contents.h | 2 +- src/cldai/sdaiString.cc | 6 ++++ src/cldai/sdaiString.h | 2 ++ src/clstepcore/STEPattribute.cc | 1 + src/clstepcore/STEPattribute.h | 7 ++-- src/clstepcore/globalRule.h | 2 +- src/clstepcore/interfaceSpec.h | 14 +++++--- src/clstepcore/sdaiApplication_instance.cc | 6 +++- src/clutils/sc_hash.cc | 2 +- src/exp2cxx/classes_type.c | 4 +-- src/exp2cxx/classes_wrapper.cc | 36 ++++++++++++++++---- src/exp2python/src/classes_python.c | 4 +-- src/exp2python/src/classes_wrapper_python.cc | 11 ++++-- src/express/expr.c | 14 ++++---- src/express/info.c | 2 +- src/express/stack.h | 8 ----- 20 files changed, 89 insertions(+), 45 deletions(-) diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index b9f314a0a..54d14c776 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -1097,7 +1097,7 @@ JudySlot *judy_prv(Judy *judy) JudySlot *judy_del(Judy *judy) { - int slot, off, size, type, high; + int slot, off, size, type; JudySlot *table, *inner; JudySlot next, *node; int keysize, cnt; @@ -1150,7 +1150,6 @@ JudySlot *judy_del(Judy *judy) table = (JudySlot *)(next & JUDY_mask); inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); inner[slot & 0x0F] = 0; - high = slot & 0xF0; for(cnt = 16; cnt--;) if(inner[cnt]) { diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index 68fcb0af8..5728b0f66 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -63,7 +63,7 @@ void SDAI_Entity_extent::owned_by_(SDAI_Model_contents__list_var &mclv) SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const { - return (const SDAI_Model_contents__list_var) &_owned_by; + return (SDAI_Model_contents__list_var) &_owned_by; } /* diff --git a/src/cldai/sdaiEntity_extent.h b/src/cldai/sdaiEntity_extent.h index b2471839e..b8b2254ab 100644 --- a/src/cldai/sdaiEntity_extent.h +++ b/src/cldai/sdaiEntity_extent.h @@ -60,7 +60,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance } SDAI_DAObject__set_var instances_() const { - return (const SDAI_DAObject__set_var)&_instances; + return (SDAI_DAObject__set_var)&_instances; } // need to implement Model_contents__list diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index 84d2389f9..89636fbec 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -33,7 +33,7 @@ SDAI_Model_contents::instances_() SDAI_Model_contents_instances_ptr SDAI_Model_contents::instances_() const { - return (const SDAI_Model_contents_instances_ptr) &_instances; + return (SDAI_Model_contents_instances_ptr) &_instances; } SDAI_Entity_extent__set_var @@ -45,7 +45,7 @@ SDAI_Model_contents::folders_() SDAI_Entity_extent__set_var SDAI_Model_contents::folders_() const { - return (const SDAI_Entity_extent__set_var)&_folders; + return (SDAI_Entity_extent__set_var)&_folders; } SDAI_Entity_extent__set_var @@ -57,7 +57,7 @@ SDAI_Model_contents::populated_folders_() SDAI_Entity_extent__set_var SDAI_Model_contents::populated_folders_() const { - return (const SDAI_Entity_extent__set_var)&_populated_folders; + return (SDAI_Entity_extent__set_var)&_populated_folders; } SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid(const SDAI_DAObject_ptr &d) const diff --git a/src/cldai/sdaiModel_contents.h b/src/cldai/sdaiModel_contents.h index 060b20f06..86dec9cad 100644 --- a/src/cldai/sdaiModel_contents.h +++ b/src/cldai/sdaiModel_contents.h @@ -43,7 +43,7 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject } SDAI_DAObject__set_var contents_() const { - return (const SDAI_DAObject__set_var) &_instances; + return (SDAI_DAObject__set_var) &_instances; } }; diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 9d12b8bbc..82c0ac5b4 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -46,6 +46,12 @@ SDAI_String &SDAI_String::operator= (const char *s) return *this; } +SDAI_String &SDAI_String::operator= (const SDAI_String &s) +{ + content = s.content; + return *this; +} + bool SDAI_String::operator== (const char *s) const { return (content == s); diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index 7021d5e70..f1b3e4fd0 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -12,6 +12,7 @@ */ #include +#include #include @@ -37,6 +38,7 @@ class SC_DAI_EXPORT SDAI_String // operators SDAI_String &operator= (const char *s); + SDAI_String &operator= (const SDAI_String &s); bool operator== (const char *s) const; void clear(void); diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index f67b2fee5..4509fdf9a 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -1498,6 +1498,7 @@ STEPattribute::~STEPattribute() delete(SDAI_BOOLEAN *) ptr.e; ptr.e = 0; } + break; case LOGICAL_TYPE: if(ptr.e) { delete(SDAI_LOGICAL *) ptr.e; diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 63d2abecf..01cc1465e 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -98,14 +98,17 @@ class SC_CORE_EXPORT STEPattribute void *p; } ptr; - const AttrDescriptor *aDesc; protected: bool _derive; bool _mustDeletePtr; ///if a member uses new to create an object in ptr ErrorDescriptor _error; STEPattribute *_redefAttr; - int refCount; + public: + const AttrDescriptor *aDesc; + + protected: + int refCount; char SkipBadAttr(istream &in, char *StopChars); void AddErrorInfo(); diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index 1c47bdbbe..3a8aa9d9b 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -15,7 +15,6 @@ class SC_CORE_EXPORT Global_rule : public Dictionary_instance #pragma warning( disable: 4251 ) #endif Express_id _name; - std::string _rule_text; // non-SDAI #ifdef _MSC_VER #pragma warning( pop ) #endif @@ -23,6 +22,7 @@ class SC_CORE_EXPORT Global_rule : public Dictionary_instance Entity__set_var _entities; // not implemented Where_rule__list_var _where_rules; Schema_ptr _parent_schema; + std::string _rule_text; // non-SDAI Global_rule(); Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt); diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index 8ae4b4b27..a109bb22f 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -15,7 +15,17 @@ class SC_CORE_EXPORT Interface_spec : public Dictionary_instance #pragma warning( disable: 4251 ) #endif Express_id _current_schema_id; // schema containing the USE/REF stmt +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif // non-SDAI, not useful for SDAI use of Interface_spec (it would need to // be a list). // schema that defined the USE/REFd objects @@ -24,10 +34,6 @@ class SC_CORE_EXPORT Interface_spec : public Dictionary_instance #pragma warning( pop ) #endif - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to // be a list of ints). // schema USEs or REFERENCEs all objects from foreign schema diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index c770a8f9c..586c290ae 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -706,6 +706,7 @@ SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, cons err->AppendToDetailMsg("Use of @ instead of # to identify entity.\n"); err->GreaterSeverity(SEVERITY_WARNING); // no break statement here on purpose + [[gnu::fallthrough]]; case '#': { int id = -1; in >> id; @@ -914,9 +915,12 @@ Severity EntityValidLevel(const char *attrValue, // string contain entity ref if((found1 > 0) || (found2 > 0)) { if((found1 == 2) || (found2 == 2)) { - sprintf(messageBuf, + int ocnt = snprintf(messageBuf, BUFSIZ, " Attribute's Entity Reference %s is %s data \'%s\'.\n", attrValue, "followed by invalid", tmp); + if (ocnt < BUFSIZ) { + fprintf(stderr, "Warning - truncation of Attribute's Entry Reference msg\n"); + } err->AppendToUserMsg(messageBuf); err->AppendToDetailMsg(messageBuf); err->GreaterSeverity(SEVERITY_WARNING); diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index 654e110a3..c2c884d72 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -65,7 +65,7 @@ void SC_HASHinsert(Hash_TableP t, char *s, void *data) e.symbol = 0; e2 = SC_HASHsearch(t, &e, HASH_INSERT); if(e2) { - fprintf(stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s); + fprintf(stderr, "%s: Redeclaration of %s\n", __func__, s); } } diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index c37221554..fa001eefc 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -124,7 +124,7 @@ char *CheckEnumSymbol(char *s) } else { strcpy(b, s); strcat(b, "_"); - fprintf(stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b); + fprintf(stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __func__, s, b); return (b); } } @@ -1313,7 +1313,7 @@ char *TYPEget_express_type(const Type t) /* default returns undefined */ - fprintf(stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name(t)); + fprintf(stderr, "Warning in %s: type %s is undefined\n", __func__, TYPEget_name(t)); return ("SCLundefined"); } diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 4d1381d9a..f5756e8b1 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -405,6 +405,7 @@ void INITFileFinish(FILE *initfile, Schema schema) ******************************************************************/ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) { + int ocnt = 0; char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ FILE *libfile, @@ -422,11 +423,20 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) /* 1. header file */ sprintf(schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper(SCHEMAget_name(schema))); //TODO change file names to CamelCase? if(suffix == 0) { - sprintf(sufnm, "%s", schnm); + ocnt = snprintf(sufnm, MAX_LEN, "%s", schnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; + } } else { - sprintf(sufnm, "%s_%d", schnm, suffix); + ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; + } + } + ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; } - sprintf(fnm, "%s.h", sufnm); if(!(incfile = (files -> inc) = FILEcreate(fnm))) { return; @@ -467,7 +477,11 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) fprintf(libfile, "\n#include \"%s.h\"\n", schnm); // 3. header for namespace to contain all formerly-global variables - sprintf(fnm, "%sNames.h", schnm); + ocnt = snprintf(fnm, MAX_LEN, "%sNames.h", schnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; + } + if(!(files->names = FILEcreate(fnm))) { return; } @@ -482,7 +496,11 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) if(suffix <= 1) { /* I.e., if this is our first pass with schema */ - sprintf(fnm, "%s.init.cc", schnm); + ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; + } + /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ if(!(initfile = (files -> init) = FILEcreate(fnm))) { @@ -545,8 +563,12 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) fprintf(files->classes, "\n#include \"%sNames.h\"\n", schnm); } else { /* Just reopen the .init.cc (in append mode): */ - sprintf(fnm, "%s.init.cc", schnm); - initfile = files->init = fopen(fnm, "a"); + ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; + } + + initfile = files->init = fopen(fnm, "a"); } /********** record in files relating to entire input ***********/ diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 087388402..6c1f60707 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -386,7 +386,7 @@ char *EXPRto_python(Expression e) buf = (char *)sc_malloc(bufsize); if(!buf) { - fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno)); + fprintf(stderr, "%s failed to allocate buffer: %s\n", __func__, strerror(errno)); abort(); } @@ -483,7 +483,7 @@ char *EXPRto_python(Expression e) temp = (char *)sc_realloc(buf, 1 + strlen(buf)); if(temp == 0) { - fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno)); + fprintf(stderr, "%s failed to realloc buffer: %s\n", __func__, strerror(errno)); abort(); } diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index 3fa6ed5ec..e61eefa00 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -153,6 +153,7 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) void SCHEMAprint(Schema schema, FILES *files, int suffix) { + int ocnt = 0; char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ FILE *libfile; @@ -163,9 +164,15 @@ void SCHEMAprint(Schema schema, FILES *files, int suffix) if(suffix == 0) { sprintf(sufnm, "%s", schnm); } else { - sprintf(sufnm, "%s_%d", schnm, suffix); + ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; + } + } + ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); + if (ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; } - sprintf(fnm, "%s.h", sufnm); np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ diff --git a/src/express/expr.c b/src/express/expr.c index 2c2e279c6..679b2b086 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -238,7 +238,9 @@ static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, *e = item; *dt = DICT_type; return 1; - } + } else { + return 0; + } default: return 0; } @@ -325,8 +327,8 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) } else { fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); ERRORabort(0); - } - + return(Type_Bad); + } default: /* compile-time ambiguous */ if(where) { @@ -613,11 +615,11 @@ void EXPresolve_op_default(Expression e, Scope s) { int failed = 0; - switch(OPget_number_of_operands(e->e.op_code)) { - case 3: + if (OPget_number_of_operands(e->e.op_code) == 3) { EXPresolve(e->e.op3, s, Type_Dont_Care); failed = is_resolve_failed(e->e.op3); - case 2: + } + if (OPget_number_of_operands(e->e.op_code) == 2) { EXPresolve(e->e.op2, s, Type_Dont_Care); failed |= is_resolve_failed(e->e.op2); } diff --git a/src/express/info.c b/src/express/info.c index da8788ef7..8588a648b 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -28,7 +28,7 @@ void EXPRESSusage(int _exit) fprintf(stderr, "\t-i warning ignore\n"); fprintf(stderr, "and is one of:\n"); fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, ERRORget_warnings_help("\t", "\n")); + fprintf(stderr, "%s", ERRORget_warnings_help("\t", "\n")); fprintf(stderr, "and is one or more of:\n"); fprintf(stderr, " e entity\n"); fprintf(stderr, " p procedure\n"); diff --git a/src/express/stack.h b/src/express/stack.h index d0d99e14f..cb80180c9 100644 --- a/src/express/stack.h +++ b/src/express/stack.h @@ -75,12 +75,4 @@ typedef Linked_List Stack; /* function prototypes */ /***********************/ -/*******************************/ -/* inline function definitions */ -/*******************************/ - -#if supports_inline_functions || defined(STACK_C) - -#endif /* supports_inline_functions || defined(STACK_C) */ - #endif /* STACK_H */ From 670600e67b2191bf15b8cc143efbb57ac1d2091a Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:41:56 -0500 Subject: [PATCH 090/244] Try removing some consts for Wignored-qualifiers Const setting on return casts is tripping a lot of Wignored-qualifiers on return types. Figuring out when to use them is going to be tricky - checkpoint a few minor changes in that direction. --- src/exp2cxx/classes_attribute.c | 10 +++++----- src/exp2cxx/selects.c | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index 6233b7e3d..2b35e3fd4 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -359,7 +359,7 @@ void ATTRprint_access_methods_str_bin(const char *entnm, const char *attrnm, con ATTRprint_access_methods_get_head(entnm, a, file, true); fprintf(file, "const {\n"); ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); ATTRprint_access_methods_put_head(entnm, a, file); fprintf(file, "{\n"); ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, false); @@ -401,7 +401,7 @@ void ATTRprint_access_methods_enum(const char *entnm, const char *attrnm, const ATTRprint_access_methods_get_head(entnm, a, file, true); fprintf(file, "const {\n"); ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (const %s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); + fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); ATTRprint_access_methods_put_head(entnm, a, file); fprintf(file, "{\n"); @@ -442,7 +442,7 @@ void ATTRprint_access_methods_log_bool(const char *entnm, const char *attrnm, co { fprintf(file, "const {\n"); ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); /* don't need a const method for logical or boolean * ATTRprint_access_methods_get_head( entnm, a, file, true ); @@ -554,7 +554,7 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema if(classType == select_) { fprintf(file, " {\n return &_%s;\n}\n", attrnm); ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n return (const %s) &_%s;\n}\n", ctype, attrnm); + fprintf(file, "const {\n return (%s) &_%s;\n}\n", ctype, attrnm); ATTRprint_access_methods_put_head(entnm, a, file); fprintf(file, " {\n _%s = x;\n}\n", attrnm); return; @@ -588,7 +588,7 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema } /* default: INTEGER */ /* is the same type as the data member */ - fprintf(file, " return (const %s) _%s;\n}\n", ctype, attrnm); + fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); ATTRprint_access_methods_put_head(entnm, a, file); fprintf(file, "{\n"); if(print_logging) { diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 8bb9bb520..e1e0b12cb 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -1113,6 +1113,9 @@ void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) /* get methods */ TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false); + /* TODO - This isn't good enough - the compiler warning Wignored-qualifiers is picking up + * a lot of spurious const expressions coming from these outputs. Not sure of the pattern + * yet, but it looks like not all attrIsObj entities should be using it. */ if(attrIsObj(VARget_type(a))) { TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true); } From 7a3d8f0ce5dde571472b328f5c0953d5bed54220 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:57:18 -0500 Subject: [PATCH 091/244] Turn on the C/C++11 standards. Rather than enable extensions, add a few defines in particular locations. --- CMakeLists.txt | 35 +++++++++++++----------- src/base/sc_mkdir.c | 2 +- src/exp2python/src/classes_misc_python.c | 2 ++ src/express/expscan.l | 5 ++++ src/express/generated/expscan.c | 4 +++ 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f99de18f..ac8dfcfe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# C M A K E L I S T S . T X T F O R S T E P C O D E +# C M A K E L I S T S . T X T # # This file is Copyright (c) 2010 United States Government as # represented by the U.S. Army Research Laboratory. @@ -38,29 +38,32 @@ # This file contains the top level CMakeLists.txt logic for the # STEPcode software package. - project(SC) +# Minimum required version of CMake +cmake_minimum_required(VERSION 3.12) +if (POLICY CMP0077) + cmake_policy(SET CMP0077 OLD) +endif (POLICY CMP0077) + # SC version set(SC_VERSION_MAJOR 0) set(SC_VERSION_MINOR 9) set(SC_VERSION_PATCH 1) set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) -# Minimum required version of CMake -cmake_minimum_required(VERSION 3.12) -if (POLICY CMP0077) - cmake_policy(SET CMP0077 OLD) -endif (POLICY CMP0077) +# Set language standards +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # 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") -if(NOT SC_IS_SUBBUILD) - set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}") -else(NOT SC_IS_SUBBUILD) - set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}") -endif(NOT SC_IS_SUBBUILD) +list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}") # OpenBSD has its own naming conventions. Set a platform variable based on # the OS name so we can test for it succinctly. @@ -72,13 +75,13 @@ endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc -include(${SC_CMAKE_DIR}/SC_Targets.cmake) +include(SC_Targets) # Macros related to paths -include(${SC_CMAKE_DIR}/SC_Paths.cmake) +include(SC_Paths) # locale stuff -include(${SC_CMAKE_DIR}/SC_Locale.cmake) +include(SC_Locale) # logic related to regenerating the lexer and parser source code include(${SC_CMAKE_DIR}/SC_Regenerate.cmake) @@ -91,7 +94,7 @@ 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 +#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) diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c index f48829973..bcfaac0e3 100644 --- a/src/base/sc_mkdir.c +++ b/src/base/sc_mkdir.c @@ -1,4 +1,4 @@ - +#define _XOPEN_SOURCE /* for S_IFDIR */ #include "sc_mkdir.h" #include diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 9e32f6189..0420b74d9 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -1,5 +1,7 @@ #define CLASSES_MISC_C +#define _POSIX_C_SOURCE 200809L /* for strdup */ #include +#include #include "classes.h" /******************************************************************* ** FedEx parser output module for generating C++ class definitions diff --git a/src/express/expscan.l b/src/express/expscan.l index cbd56c535..cde644887 100644 --- a/src/express/expscan.l +++ b/src/express/expscan.l @@ -118,6 +118,11 @@ static int nesting_level = 0; #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; +/* isascii isn't part of newer C standards */ +#ifndef isascii +# define isascii(c) ((unsigned)((c) + 1) < 129) +#endif + static_inline int SCANnextchar(char* buffer) diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index 0be5c8970..1c5727001 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -112,6 +112,10 @@ static int nesting_level = 0; /* can't imagine this will ever be more than 2 or 3 - DEL */ #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; +/* isascii isn't part of newer C standards */ +#ifndef isascii +# define isascii(c) ((unsigned)((c) + 1) < 129) +#endif static_inline int SCANnextchar(char *buffer) From 46717ab714bf3762ea1e4142042b9103c703e1fc Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:17:05 -0500 Subject: [PATCH 092/244] remove nullptr.h, minor CMake cleanup, one more posix define --- src/base/sc_nullptr.h | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/base/sc_nullptr.h diff --git a/src/base/sc_nullptr.h b/src/base/sc_nullptr.h deleted file mode 100644 index 342397001..000000000 --- a/src/base/sc_nullptr.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef NULLPTR_H -#define NULLPTR_H - -#include - -#ifdef HAVE_NULLPTR -#include -#else -# define nullptr_t void* -# define nullptr NULL -#endif //HAVE_NULLPTR - -#endif //NULLPTR_H From 6368ed08f92537a742f5c978ffc58b457239afc7 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:26:31 -0500 Subject: [PATCH 093/244] Dispense with the separate version header --- CMakeLists.txt | 4 ++-- cmake/SC_Config_Headers.cmake | 14 +------------- include/CMakeLists.txt | 1 - include/sc_cf_cmake.h.in | 1 + src/base/CMakeLists.txt | 1 - src/clstepcore/mgrnode.h | 4 +--- src/clstepcore/sdaiApplication_instance.cc | 4 +--- src/exp2cxx/classes_misc.c | 3 +-- src/exp2python/src/classes_python.c | 2 ++ src/exppp/pretty_schema.c | 3 +-- src/express/fedex.c | 3 +-- src/express/info.c | 10 +--------- 12 files changed, 12 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac8dfcfe5..824a6ed3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,7 @@ if(NOT DEFINED SC_BUILD_SCHEMAS) "** 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") + 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(NOT SC_IS_SUBBUILD) @@ -105,7 +105,7 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -# create config headers sc_cf.h and sc_version_string.h +# create config headers sc_cf.h include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 64f9bdef1..ce35de6f6 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,4 +1,4 @@ -# create sc_cf.h and sc_version_string.h +# create sc_cf.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 @@ -101,18 +101,6 @@ 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) -set(VER_HDR " -#ifndef SC_VERSION_STRING -#define SC_VERSION_STRING -static char sc_version[512] = {\"${SC_VERSION}\"}; -#endif" -) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") -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 diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 566c3780d..d6281e482 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -36,7 +36,6 @@ install(FILES ordered_attrs.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) # Local Variables: diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf_cmake.h.in index 6caec92aa..67d88c433 100644 --- a/include/sc_cf_cmake.h.in +++ b/include/sc_cf_cmake.h.in @@ -2,6 +2,7 @@ #define SCL_CF_H /**** Define statements for CMake ****/ +#cmakedefine SC_VERSION "@SC_VERSION@" #cmakedefine HAVE_NDIR_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_SYS_STAT_H 1 diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index cd41f97b6..04d5487d2 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -15,7 +15,6 @@ set(SC_BASE_HDRS sc_getopt.h sc_trace_fprintf.h sc_mkdir.h - sc_nullptr.h path2str.h judy/src/judy.h judy/src/judyLArray.h diff --git a/src/clstepcore/mgrnode.h b/src/clstepcore/mgrnode.h index f230877ed..4f14f4bf2 100644 --- a/src/clstepcore/mgrnode.h +++ b/src/clstepcore/mgrnode.h @@ -25,8 +25,6 @@ class DisplayNode; #include -#include - class InstMgr; class SC_CORE_EXPORT MgrNodeBase : public GenericNode @@ -35,7 +33,7 @@ class SC_CORE_EXPORT MgrNodeBase : public GenericNode virtual inline SDAI_Application_instance *GetSTEPentity() { abort(); - return nullptr; + return NULL; }; virtual ~MgrNodeBase() {}; }; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 586c290ae..5c5bfa671 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -20,8 +20,6 @@ #include "sdaiApplication_instance.h" #include "superInvAttrIter.h" -#include - SDAI_Application_instance NilSTEPentity; bool isNilSTEPentity(const SDAI_Application_instance *ai) @@ -995,7 +993,7 @@ const SDAI_Application_instance::iAMap_t::value_type SDAI_Application_instance:: } iAstruct z; memset(&z, 0, sizeof z); - iAMap_t::value_type nil((Inverse_attribute *) nullptr, z); + iAMap_t::value_type nil((Inverse_attribute *) NULL, z); return nil; } diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 559a45552..2b8ba07bf 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -4,7 +4,6 @@ #include "classes.h" #include -#include "sc_version_string.h" #include "class_strings.h" /** \file classes_misc.c @@ -45,7 +44,7 @@ FILE *FILEcreate(const char *filename) fprintf(file, "#ifndef %s\n", fn); fprintf(file, "#define %s\n\n", fn); - fprintf(file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version); + fprintf(file, "// This file was generated by exp2cxx,\n// %s.\n", SC_VERSION); fprintf(file, "// You probably don't want to edit it since your modifications\n"); fprintf(file, "// will be lost if exp2cxx is used to regenerate it.\n\n"); return (file); diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 6c1f60707..e8d53564d 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -24,8 +24,10 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ +#define _POSIX_C_SOURCE 200809L /* for strdup */ #include #include +#include #include "sc_memmgr.h" #include "classes.h" diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index be6f4f7d2..50940c413 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -109,7 +108,7 @@ char *SCHEMAout(Schema s) for(hp = expheader; *hp; hp++) { if((**hp == '\0') && (**(hp + 1) == '\0')) { /* if this and the next lines are blank, put version string on this line */ - raw("%s\n", sc_version); + raw("%s\n", SC_VERSION); } else { raw("%s\n", *hp); } diff --git a/src/express/fedex.c b/src/express/fedex.c index 4288a51b9..9c03bcf99 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -77,7 +77,6 @@ #include "sc_cf.h" #include "sc_memmgr.h" #include "sc_export.h" -#include "sc_version_string.h" #include "sc_getopt.h" #include "express/error.h" #include "express/express.h" @@ -93,7 +92,7 @@ static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing void print_fedex_version(void) { - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version); + fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, SC_VERSION); no_need_to_work = 1; } diff --git a/src/express/info.c b/src/express/info.c index 8588a648b..2839d5c15 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -4,14 +4,6 @@ #include "express/info.h" #include "express/express.h" -#ifndef SCHEMA_SCANNER -# include "sc_version_string.h" -#else -/* dummy string to make the compiler happy when building the schema scanner, - * should never be seen by users */ -const char *sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; -#endif - char *EXPRESSversion(void) { return("Express Language, IS (N65), October 24, 1994"); @@ -21,7 +13,7 @@ void EXPRESSusage(int _exit) { fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); fprintf(stderr, "where\t-v produces the following version description:\n"); - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version); + fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, SC_VERSION); fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); fprintf(stderr, "\t-w warning enable\n"); From 18a65280908cdf91afd2296328f14fa21c742a19 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:28:42 -0500 Subject: [PATCH 094/244] Look for a different root file --- SC_VERSION.txt | 1 - example/ap203min/CMakeLists.txt | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 SC_VERSION.txt diff --git a/SC_VERSION.txt b/SC_VERSION.txt deleted file mode 100644 index aec258df7..000000000 --- a/SC_VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -0.8 diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index 624ca44a4..f1fccb2ea 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -14,14 +14,14 @@ if(NOT DEFINED STEPCODE_ROOT_DIR) 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") +if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") 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") + if(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c") 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") + endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c") +endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") # Use STEPcode as library, but build from this build process. From 44fb19669bb8c817971532fb205a8a8b470817e0 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:43:54 -0500 Subject: [PATCH 095/244] Simplify relative directory settings --- CMakeLists.txt | 3 + cmake/Path_Setup.cmake | 164 +++++++++++++++++++++++ cmake/SC_Build_opts.cmake | 30 ----- cmake/SC_CXX_schema_macros.cmake | 3 - cmake/SC_Config_Headers.cmake | 2 +- cmake/schema_scanner/schemaScanner.cmake | 4 +- include/CMakeLists.txt | 10 +- src/base/CMakeLists.txt | 2 +- src/cldai/CMakeLists.txt | 2 +- src/cleditor/CMakeLists.txt | 2 +- src/cllazyfile/CMakeLists.txt | 2 +- src/clstepcore/CMakeLists.txt | 2 +- src/clutils/CMakeLists.txt | 2 +- 13 files changed, 181 insertions(+), 47 deletions(-) create mode 100644 cmake/Path_Setup.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 824a6ed3b..da7371212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,9 @@ if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") set(OPENBSD ON) endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") +# Path setup - relative build paths and output directories +include(Path_Setup) + # testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) diff --git a/cmake/Path_Setup.cmake b/cmake/Path_Setup.cmake new file mode 100644 index 000000000..f5db3b411 --- /dev/null +++ b/cmake/Path_Setup.cmake @@ -0,0 +1,164 @@ +# Copyright (c) 2010-2020 United States Government as represented by +# the U.S. Army Research Laboratory. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#--------------------------------------------------------------------- +# Define relative install locations. Don't set these if they have already +# been set by some other means (like a higher level CMakeLists.txt file +# including this one). + +# The location in which to install BRL-CAD executables. +if(NOT BIN_DIR) + set(BIN_DIR bin) +endif(NOT BIN_DIR) + +# Define a relative path that will "reset" a path back to +# the point before BIN_DIR was appended. This is primarily +# useful when working with generator expressions +unset(RBIN_DIR CACHE) +set(LBIN_DIR "${BIN_DIR}") +while (NOT "${LBIN_DIR}" STREQUAL "") + get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY) + set(LBIN_DIR "${LBDIR}") + if ("${RBIN_DIR}" STREQUAL "") + set(RBIN_DIR "..") + else ("${RBIN_DIR}" STREQUAL "") + set(RBIN_DIR "../${RBIN_DIR}") + endif ("${RBIN_DIR}" STREQUAL "") +endwhile (NOT "${LBIN_DIR}" STREQUAL "") + +# The location in which to install BRL-CAD libraries. +if(NOT LIB_DIR) + set(LIB_DIR lib) +endif(NOT LIB_DIR) +if(NOT LIBEXEC_DIR) + set(LIBEXEC_DIR libexec) +endif(NOT LIBEXEC_DIR) + +# The location in which to install BRL-CAD header files. +if(NOT INCLUDE_DIR) + set(INCLUDE_DIR include) +endif(NOT INCLUDE_DIR) + +# The location in which to install BRL-CAD data files +if(NOT DATA_DIR) + set(DATA_DIR share) +endif(NOT DATA_DIR) + +# The location in which to install BRL-CAD documentation files +if(NOT DOC_DIR) + set(DOC_DIR ${DATA_DIR}/doc) +endif(NOT DOC_DIR) + +# The location in which to install BRL-CAD Manual pages +if(NOT MAN_DIR) + set(MAN_DIR ${DATA_DIR}/man) +endif(NOT MAN_DIR) + +# Make sure no absolute paths have been supplied to these variables +set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC) +foreach(instdir ${INSTALL_DIRS}) + get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE) + if("${${instdir}_DIR}" STREQUAL "${instdir_full}") + message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"") + set(HAVE_INSTALL_DIR_FULL_PATH 1) + endif("${${instdir}_DIR}" STREQUAL "${instdir_full}") +endforeach(instdir ${INSTALL_DIRS}) + +#--------------------------------------------------------------------- +# Output directories - this is where built library and executable +# files will be placed after building but prior to install. The +# necessary variables change between single and multi configuration +# build systems, so it is necessary to handle both cases on a +# conditional basis. + +if(NOT CMAKE_CONFIGURATION_TYPES) + # If we're not doing multi-configuration, just set the three main + # variables to the correct values. + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) +else(NOT CMAKE_CONFIGURATION_TYPES) + # Multi-configuration is more difficult. Not only do we need to + # properly set the output directories, but we also need to + # identify the "toplevel" directory for each configuration so + # we can place files, documentation, etc. in the correct + # relative positions. Because files may be placed by CMake + # without a build target to put them in their proper relative build + # directory position using these paths, we must fully qualify them + # without using CMAKE_CFG_INTDIR. + # + # We define directories that may not be quite "standard" + # for a particular build tool - for example, native VS2010 projects use + # another directory to denote CPU type being compiled for - but CMake only + # supports multi-configuration setups having multiple configurations, + # not multiple compilers. + # + # One additional wrinkle we must watch for here is the case where + # a multi-configuration setup uses "." for its internal directory - + # if that's the case, we need to just set the various config output + # directories to the same value. + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}) + foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE}) + endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") + endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") + endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) + set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) + if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) + set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) + endforeach() +endif(NOT CMAKE_CONFIGURATION_TYPES) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index 9b14c5125..cc025faa9 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -1,27 +1,3 @@ -# BIN and LIB directories -if(NOT DEFINED BIN_DIR) - set(BIN_DIR bin) -endif(NOT DEFINED BIN_DIR) - -if(NOT DEFINED LIB_DIR) - set(LIB_DIR lib) -endif(NOT DEFINED LIB_DIR) - -# 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) @@ -51,12 +27,6 @@ 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) -# Should we use C++11? -OPTION_WITH_DEFAULT(SC_ENABLE_CXX11 "Build with C++ 11 features" ON) - -# Get version from git -OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON) - option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) mark_as_advanced(SC_BUILD_EXPRESS_ONLY) diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 388d820a5..da47ab78c 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -28,10 +28,8 @@ endmacro(P21_TESTS sfile) macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) - #add_dependencies(p21read_${PROJECT_NAME} version_string) if(NOT WIN32) SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) - #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) #add user-defined executables @@ -39,7 +37,6 @@ macro(SCHEMA_EXES) get_filename_component(name ${src} NAME_WE) get_filename_component(path ${src} ABSOLUTE) SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${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) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index ce35de6f6..cb7e02406 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -99,7 +99,7 @@ endif(SC_ENABLE_CXX11) # 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) +configure_file(${CONFIG_H_FILE} ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) # Local Variables: # tab-width: 8 diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index 0c345d931..affe5c5cc 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -71,9 +71,9 @@ message( STATUS "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}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_DIR}) else(WIN32) - install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR}) endif(WIN32) # macro SCHEMA_CMLIST diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index d6281e482..da3ae5eb5 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,21 +22,21 @@ set(express_HDRS express/variable.h ) install(FILES ${express_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express) + DESTINATION ${INCLUDE_DIR}/stepcode/express) set(exppp_HDRS exppp/exppp.h ) install(FILES ${exppp_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp) + DESTINATION ${INCLUDE_DIR}/stepcode/exppp) install(FILES ordered_attrs.h sc_export.h sc_stdbool.h - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode) + DESTINATION ${INCLUDE_DIR}/stepcode) -install(FILES ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode) +install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h + DESTINATION ${INCLUDE_DIR}/stepcode) # Local Variables: # tab-width: 8 diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 04d5487d2..92d48837b 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -61,7 +61,7 @@ if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") install(FILES ${SC_BASE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base) + DESTINATION ${INCLUDE_DIR}/stepcode/base) # Local Variables: # tab-width: 8 diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 2978f8c7a..aa1aa0895 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -48,7 +48,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) endif() install(FILES ${SC_CLDAI_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai) + DESTINATION ${INCLUDE_DIR}/stepcode/cldai) # Local Variables: # tab-width: 8 diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 4c40f73fc..b85a54a3b 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -39,7 +39,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) endif() install(FILES ${SC_CLEDITOR_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor) + DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) # Local Variables: # tab-width: 8 diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index d737a9c89..496c9475b 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -47,7 +47,7 @@ SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile) + DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) # Local Variables: # tab-width: 8 diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 937985fff..5ebd98b07 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -145,7 +145,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) endif() install(FILES ${SC_CLSTEPCORE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore) + DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 2553f4fa5..39a47052a 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -41,7 +41,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) endif() install(FILES ${SC_CLUTILS_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils) + DESTINATION ${INCLUDE_DIR}/stepcode/clutils) # Local Variables: # tab-width: 8 From a3663392203375244f4d8aed9ffb7efab001d1ec Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:49:37 -0500 Subject: [PATCH 096/244] See if we can just do a straight up check on these. --- src/base/CMakeLists.txt | 4 ++-- src/cldai/CMakeLists.txt | 4 ++-- src/cleditor/CMakeLists.txt | 4 ++-- src/cllazyfile/CMakeLists.txt | 4 ++-- src/clstepcore/CMakeLists.txt | 4 ++-- src/clutils/CMakeLists.txt | 4 ++-- src/exppp/CMakeLists.txt | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 92d48837b..5aad0a929 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -32,7 +32,7 @@ if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) endif() -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base psapi) @@ -40,7 +40,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base-static psapi) diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index aa1aa0895..023ce1ab6 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -36,14 +36,14 @@ include_directories( set(_libdeps steputils base) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) endif() diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index b85a54a3b..6370bcacb 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -27,14 +27,14 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) endif() diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index 496c9475b..765ac9ce0 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -32,14 +32,14 @@ include_directories( set(_libdeps stepcore stepdai steputils base stepeditor) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) endif() diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 5ebd98b07..910235973 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -133,14 +133,14 @@ include_directories( set(_libdeps steputils stepdai base) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) endif() diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 39a47052a..514980ad9 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) @@ -33,7 +33,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) if(WIN32) target_link_libraries(steputils-static shlwapi) diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 5d6b7a6f3..0d1fb9649 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories( ${SC_SOURCE_DIR}/src/express ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) set_target_properties(libexppp PROPERTIES PREFIX "") if(WIN32) @@ -38,7 +38,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) set_target_properties(libexppp-static PROPERTIES PREFIX "") endif() From 5d8c597d8f734b9d74c1fb1ab08748d10595abee Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:58:24 -0500 Subject: [PATCH 097/244] Simplify BUILD_SHARED_LIBS and BUILD_STATIC_LIBS options. --- CMakeLists.txt | 2 +- cmake/SC_Build_opts.cmake | 8 ++++---- cmake/SC_CXX_schema_macros.cmake | 2 +- .../ExternalProjectBuild/cmake/External_STEPCode.cmake | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da7371212..246c777fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,7 @@ add_subdirectory(doc) # 'make core' builds everything that isn't generated. for devs. add_custom_target(core) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) add_dependencies(core stepdai stepeditor exp2cxx check-express) else() add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index cc025faa9..c94aa84da 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -16,10 +16,10 @@ macro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT) 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) +option(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(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) @@ -39,8 +39,8 @@ 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(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE) + set(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) diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index da47ab78c..93e6dd400 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -93,7 +93,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ${SC_SOURCE_DIR}/src/base/judy/src ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation - if($CACHE{SC_BUILD_SHARED_LIBS}) + if(BUILD_SHARED_LIBS) SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) if(WIN32) diff --git a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake index 62df14322..b5cdbee02 100644 --- a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake +++ b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake @@ -26,4 +26,3 @@ SET( STEPCODE_BINARY_DIR ${BINARY_DIR} ) # Consequently, force Debug so it installs in ../sc-install directory # instead of /usr/local/lib. # -# SC's own programs fail to build with -DSC_BUILD_SHARED_LIBS=OFF \ No newline at end of file From 725ec378c7ad02ff283f561112ae6d492f4136bc Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:00:58 -0500 Subject: [PATCH 098/244] Remove unused file, line wrap scanner README --- cmake/Generated_Source_Utils.cmake | 67 ------------------------------ cmake/schema_scanner/README | 14 ++++--- 2 files changed, 9 insertions(+), 72 deletions(-) delete mode 100644 cmake/Generated_Source_Utils.cmake diff --git a/cmake/Generated_Source_Utils.cmake b/cmake/Generated_Source_Utils.cmake deleted file mode 100644 index 601f92364..000000000 --- a/cmake/Generated_Source_Utils.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# Utility routines for managing generated files with CMake - -macro(MD5 filename md5sum) - file(READ "${filename}" RAW_MD5_FILE) - string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}") - string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}") -endmacro(MD5) - -macro(FILEVAR filename var) - string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${var} ${filename}) -endmacro(FILEVAR) - -macro(VERIFY_FILES filelist warn resultvar) - set(${resultvar} 1) - foreach(fileitem ${filelist}) - # Deal with absolute and relative paths a bit differently - get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) - if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${fileitem}") - else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") - endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - get_filename_component(filename "${fileitem}" NAME) - # Got filename components sorted - proceed - if(NOT EXISTS ${filefullname}) - message(FATAL_ERROR "Attempted to verify non-existant file ${filefullname}") - endif(NOT EXISTS ${filefullname}) - FILEVAR(${filename} filevar) - if(NOT baseline_${filevar}_md5) - message(FATAL_ERROR "No baseline MD5 available for ${filename} - baseline_${filevar}_md5 is not defined") - endif(NOT baseline_${filevar}_md5) - MD5(${filefullname} ${filevar}_md5) - if(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") - if("${warn}" STREQUAL "1") - message("\n${filename} differs from baseline: baseline md5 hash is ${baseline_${filevar}_md5} and current hash is ${${filevar}_md5}\n") - endif("${warn}" STREQUAL "1") - set(${resultvar} 0) - endif(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") - endforeach(fileitem ${filelist}) -endmacro(VERIFY_FILES filelist resultvar) - -macro(WRITE_MD5_SUMS filelist outfile) - foreach(fileitem ${filelist}) - # Deal with absolute and relative paths a bit differently - get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) - if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${fileitem}") - else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") - endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - get_filename_component(filename "${fileitem}" NAME) - # Got filename components sorted - proceed - if(NOT EXISTS ${filefullname}) - message(FATAL_ERROR "Attempted to get MD5 sum of non-existant file ${filefullname}") - endif(NOT EXISTS ${filefullname}) - FILEVAR(${filename} filevar) - MD5(${filefullname} ${filevar}_md5) - file(APPEND ${outfile} "set(baseline_${filevar}_md5 ${${filevar}_md5})\n") - endforeach(fileitem ${filelist}) -endmacro(WRITE_MD5_SUMS) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/schema_scanner/README b/cmake/schema_scanner/README index 8e0996f29..eabd37087 100644 --- a/cmake/schema_scanner/README +++ b/cmake/schema_scanner/README @@ -1,10 +1,14 @@ README for STEPcode schema scanner -------------- -The files in this directory are for a schema scanner executable, built by CMake during the configuration stage. +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 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. -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. From 853aeb4e8b2ddb62f10571797a5c070fc84e536a Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:03:30 -0500 Subject: [PATCH 099/244] Minor CMakeLists.txt cleanups --- CMakeLists.txt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 246c777fb..aa8f1adb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,8 @@ if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") set(OPENBSD ON) endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") -# Path setup - relative build paths and output directories +#--------------------------------------------------------------------- +# Set up various relative path variables and build output directories include(Path_Setup) # testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc @@ -87,7 +88,7 @@ include(SC_Paths) include(SC_Locale) # logic related to regenerating the lexer and parser source code -include(${SC_CMAKE_DIR}/SC_Regenerate.cmake) +include(SC_Regenerate) 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") @@ -109,22 +110,17 @@ if(NOT SC_IS_SUBBUILD) endif(NOT SC_IS_SUBBUILD) # create config headers sc_cf.h -include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) +include(SC_Config_Headers) ################ -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 11) - if(MSVC) # 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) -else() +endif() +if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) - if(HAVE_NULLPTR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif(HAVE_NULLPTR) endif() include_directories( From 4bf478b6e37676a87f06acb11564cbcb1ce854a4 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:09:26 -0500 Subject: [PATCH 100/244] Remove the express-only option --- cmake/SC_Build_opts.cmake | 11 +++-------- data/CMakeLists.txt | 2 +- test/CMakeLists.txt | 6 ++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index c94aa84da..a8d81cfa5 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -27,9 +27,6 @@ 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) - option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) mark_as_advanced(DEBUGGING_GENERATED_SOURCES) @@ -51,12 +48,10 @@ endif(SC_ENABLE_COVERAGE) #--------------------------------------------------------------------- # Testing option OPTION_WITH_DEFAULT(SC_ENABLE_TESTING "Enable unittesting framework" OFF) -if(SC_ENABLE_TESTING) - if(NOT ${SC_BUILD_EXPRESS_ONLY} AND NOT DEFINED SC_BUILD_SCHEMAS) - set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified - endif() +if(SC_ENABLE_TESTING AND NOT DEFINED SC_BUILD_SCHEMAS) + set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified include(CTest) -endif(SC_ENABLE_TESTING) +endif() #--------------------------------------------------------------------- # Executable install option diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 819403e6f..d4452117b 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,7 +10,7 @@ # .exp file inside, which it uses. otherwise, ${path} is assumed to # be an express file. -if(NOT ${SC_BUILD_EXPRESS_ONLY} AND NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 48d826458..05530cb5b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,10 +13,8 @@ foreach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) endif( UNITARY_SCHEMA MATCHES "fail_.*" ) endforeach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) -if(NOT ${SC_BUILD_EXPRESS_ONLY}) - add_subdirectory(p21) - add_subdirectory(cpp) -endif() +add_subdirectory(p21) +add_subdirectory(cpp) # Local Variables: # tab-width: 8 From 9bba7d5157f2744875d356b7f26e502214de2a47 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:16:56 -0500 Subject: [PATCH 101/244] Simplify build options. This strips down the build options to more vanilla CMake, removes the uninstall target, and goes back to respecting CMAKE_INSTALL_PREFIX. --- CMakeLists.txt | 93 +++++++++-- cmake/SC_Build_opts.cmake | 151 ------------------ .../cmake/External_STEPCode.cmake | 4 - 3 files changed, 84 insertions(+), 164 deletions(-) delete mode 100644 cmake/SC_Build_opts.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index aa8f1adb4..7224efff4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,74 @@ endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") # Set up various relative path variables and build output directories include(Path_Setup) -# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc -include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) +#--------------------------------------------------------------------- +# 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 +if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) + set(CMAKE_SKIP_BUILD_RPATH FALSE) +endif() + +# when building, don't use the install RPATH already +# (but later on when installing) +if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +endif() + +# the RPATH/INSTALL_NAME_DIR to be used when installing +if (NOT APPLE) + if(NOT DEFINED CMAKE_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") + endif() +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 +if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +endif() + +# add the automatically determined parts of the RPATH which point to +# directories outside the build tree to the install RPATH +if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + + +#--------------------------------------------------------------------- +# Build options +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +option(BUILD_STATIC_LIBS "Build static libraries" OFF) + +option(SC_PYTHON_GENERATOR "Compile exp2python" ON) +option(SC_CPP_GENERATOR "Compile exp2cxx" ON) + +option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) +option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) + +option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) +if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) + set(CMAKE_CXX_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) +endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + +option(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) +endif(SC_ENABLE_TESTING) + +# TODO - BRL-CAD is the only known user of this option, and it will be +# transitioning to a new setup that won't need it - once that's done, +# we should just remove this option. +option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) +mark_as_advanced(SC_SKIP_EXEC_INSTALL) # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc include(SC_Targets) @@ -90,6 +156,9 @@ include(SC_Locale) # logic related to regenerating the lexer and parser source code include(SC_Regenerate) +# create config headers sc_cf.h and sc_version_string.h +include(SC_Config_Headers) + 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) @@ -145,13 +214,19 @@ if(SC_ENABLE_TESTING) endif(SC_ENABLE_TESTING) add_subdirectory(doc) -# 'make core' builds everything that isn't generated. for devs. -add_custom_target(core) -if(BUILD_SHARED_LIBS) - add_dependencies(core stepdai stepeditor exp2cxx check-express) -else() - add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) -endif() +if(NOT SC_IS_SUBBUILD) + #----------------------------------------------------------------------------- + # 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 ") + include(CPack) +endif(NOT SC_IS_SUBBUILD) + # 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. diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake deleted file mode 100644 index a8d81cfa5..000000000 --- a/cmake/SC_Build_opts.cmake +++ /dev/null @@ -1,151 +0,0 @@ -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(BUILD_SHARED_LIBS "Build shared libs" ON) - -# don't build static libs by default -OPTION_WITH_DEFAULT(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(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) -mark_as_advanced(DEBUGGING_GENERATED_SOURCES) - -#--------------------------------------------------------------------- -# 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(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE) - set(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 AND NOT DEFINED SC_BUILD_SCHEMAS) - set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified - include(CTest) -endif() - -#--------------------------------------------------------------------- -# Executable install option -OPTION_WITH_DEFAULT(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) -if(SC_SKIP_EXEC_INSTALL) - set(SC_EXEC_NOINSTALL "NO_INSTALL") -endif(SC_SKIP_EXEC_INSTALL) - -#--------------------------------------------------------------------- -# 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 -if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) - set(CMAKE_SKIP_BUILD_RPATH FALSE) -endif() - -# when building, don't use the install RPATH already -# (but later on when installing) -if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -endif() - -# the RPATH/INSTALL_NAME_DIR to be used when installing -if (NOT APPLE) - if(NOT DEFINED CMAKE_INSTALL_RPATH) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") - endif() -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 -if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) - set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -endif() - -# add the automatically determined parts of the RPATH which point to -# directories outside the build tree to the install RPATH -if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -endif() - -# 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 ") - 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 - diff --git a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake index b5cdbee02..96fca295b 100644 --- a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake +++ b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake @@ -22,7 +22,3 @@ ENDIF() SET( STEPCODE_BINARY_DIR ${BINARY_DIR} ) -# SC CMake does not honor -DCMAKE_INSTALL_PREFIX:PATH= -# Consequently, force Debug so it installs in ../sc-install directory -# instead of /usr/local/lib. -# From ec359043423a9060ea49b30acb894bf97accc867 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:27:15 -0500 Subject: [PATCH 102/244] Wignored-qualifiers errors make looking for any other issues difficult - suppress them until we can figure out how not to trigger them. --- cmake/SC_CXX_schema_macros.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 93e6dd400..016450c2c 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -102,6 +102,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj") endif() endif() + # TODO - ideally we would avoid generating code that triggers this warning, but figuring out + # how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings + # we get due to this issue so it doesn't mask other problems. + if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers") + endif() endif() if($CACHE{SC_BUILD_STATIC_LIBS}) From beeb5614c1eb2e61f722d7ae2beaf8537a891708 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 14 Dec 2020 16:35:07 -0500 Subject: [PATCH 103/244] Clear deprecated-copy warning from C++ class. Getting a -Wdeprecated-copy trigger from ap210e3's use of SDAI_BOOLEAN - make an explicit assignment operator. --- src/cldai/sdaiEnum.cc | 6 ++++++ src/cldai/sdaiEnum.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index c303df7e3..35529276b 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -339,6 +339,12 @@ SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_LOGICAL &t) return *this; } +SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_BOOLEAN &t) +{ + v = t; + return *this; +} + SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const Boolean t) { v = t; diff --git a/src/cldai/sdaiEnum.h b/src/cldai/sdaiEnum.h index ed1579f07..320208c1d 100644 --- a/src/cldai/sdaiEnum.h +++ b/src/cldai/sdaiEnum.h @@ -146,6 +146,7 @@ class SC_DAI_EXPORT SDAI_BOOLEAN : operator ::Boolean() const; SDAI_BOOLEAN &operator=(const SDAI_LOGICAL &t); + SDAI_BOOLEAN &operator=(const SDAI_BOOLEAN &t); SDAI_BOOLEAN &operator=(const ::Boolean t); SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; From b2287b3b53fab1632bb5b653e6917d3174548309 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 09:23:59 -0500 Subject: [PATCH 104/244] Simplify for BRL-CAD build. --- src/cllazyfile/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index 765ac9ce0..b5e763628 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -40,7 +40,8 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) + set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) endif() SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) From bfff9e6f8682001bef04413fb61f2bc85c055353 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 14:37:25 -0500 Subject: [PATCH 105/244] Remove the C4251 warning elements from sc_benchmark.h, adjust code. --- src/base/sc_benchmark.cc | 32 +++++++++++++++++++------------- src/base/sc_benchmark.h | 20 +++++--------------- src/cllazyfile/lazy_test.cc | 13 +++++++++---- src/test/p21read/p21read.cc | 6 +++--- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index a4dbab273..96770de7a 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -13,6 +13,7 @@ #endif #include +#include #include #include #include @@ -83,8 +84,7 @@ benchVals getMemAndTime() // --------------------- benchmark class --------------------- -benchmark::benchmark(std::string description, bool debugMessages, std::ostream &o_stream): ostr(o_stream), - descr(description), debug(debugMessages), stopped(false) +benchmark::benchmark(bool debugMessages): debug(debugMessages), stopped(false) { initialVals = getMemAndTime(); } @@ -94,10 +94,14 @@ benchmark::~benchmark() if(!stopped) { stop(); if(debug) { - ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; + std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; } out(); } + if (benchVals_str) { + free((void *)benchVals_str); + benchVals_str = NULL; + } } void benchmark::stop() @@ -129,32 +133,34 @@ benchVals benchmark::get() return delta; } -void benchmark::reset(std::string description) -{ - descr = description; - reset(); -} void benchmark::reset() { stopped = false; initialVals = getMemAndTime(); } -std::string benchmark::str() +const char *benchmark::str() { return str(get()); } void benchmark::out() { - ostr << str() << std::endl; + std::cout << str() << std::endl; } -std::string benchmark::str(const benchVals &bv) +const char *benchmark::str(const benchVals &bv) { std::stringstream ss; - ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; + ss << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; - return ss.str(); + if (benchVals_str) { + free((void *)benchVals_str); + benchVals_str = NULL; + } + benchVals_str = (char *)calloc(ss.str().length() + 1, sizeof(char)); + snprintf(benchVals_str, ss.str().length(), "%s", ss.str().c_str()); + benchVals_str[ss.str().length()] = '\0'; + return benchVals_str; } diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index 70b5876f5..81a0441ec 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -5,9 +5,7 @@ #include "sc_export.h" #ifdef __cplusplus -#include #include -#include #include "sc_memmgr.h" extern "C" { @@ -43,34 +41,26 @@ class SC_BASE_EXPORT benchmark { protected: benchVals initialVals, laterVals; -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable: 4251 ) -#endif - std::ostream &ostr; - std::string descr; -#ifdef _MSC_VER -#pragma warning( pop ) -#endif bool debug, stopped; + char *benchVals_str = NULL; + public: - benchmark(std::string description = "", bool debugMessages = true, std::ostream &o_stream = std::cout); + benchmark(bool debugMessages = true); /// if 'stopped' is false, uses str(true) to print to ostream ~benchmark(); void reset(); - void reset(std::string description); benchVals get(); void stop(); /// converts data member 'laterVals' into a string and returns it - std::string str(); + const char *str(); /// outputs result of str() on ostream 'ostr' void out(); /// converts 'bv' into a string, prefixed by data member 'descr' - std::string str(const benchVals &bv); + const char *str(const benchVals &bv); }; diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index b01a13fa2..3659b4137 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,7 +1,9 @@ +#include +#include #include "lazyInstMgr.h" -#include #include "SdaiSchemaInit.h" #include "sc_memmgr.h" +#include "sc_benchmark.h" #include #ifndef NO_REGISTRY @@ -148,13 +150,15 @@ int main(int argc, char **argv) #endif //NO_REGISTRY instanceID instWithRef; - benchmark stats("================ p21 lazy load: scanning the file ================\n"); + benchmark stats; + std::cout << "================ p21 lazy load: scanning the file ================\n"; mgr->openFile(argv[1]); stats.stop(); benchVals scanStats = stats.get(); stats.out(); - stats.reset("================ p21 lazy load: gathering statistics ================\n"); + std::cout << "================ p21 lazy load: gathering statistics ================\n"; + stats.reset(); int instances = mgr->totalInstanceCount(); std::cout << "Total instances: " << instances << " (" << (float)(scanStats.userMilliseconds * 1000) / instances << "us per instance, "; @@ -197,7 +201,8 @@ int main(int argc, char **argv) #endif //NO_REGISTRY stats.out(); - stats.reset("================ p21 lazy load: freeing memory ================\n"); + std::cout << "================ p21 lazy load: freeing memory ================\n"; + stats.reset(); delete mgr; //stats will print from its destructor } diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index 35e999396..cae0df598 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -13,7 +13,6 @@ */ extern void SchemaInit(class Registry &); -#include "sc_version_string.h" #include #include #include @@ -94,7 +93,7 @@ void checkSchemaName(Registry ®, STEPfile &sf, bool ignoreErr) void printVersion(const char *exe) { - std::cout << exe << " build info: " << sc_version << std::endl; + std::cout << exe << " build info: " << SC_VERSION << std::endl; } void printUse(const char *exe) @@ -155,7 +154,8 @@ int main(int argc, char *argv[]) STEPfile sfile(registry, instance_list, "", strict); char *flnm; - benchmark stats("p21 ReadExchangeFile()"); + // p21 ReadExchangeFile() + benchmark stats(); cout << argv[0] << ": load file ..." << endl; if(argc >= (sc_optind + 1)) { From fe796629a2938b5fec76377aba52074e3d978785 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 14:49:54 -0500 Subject: [PATCH 106/244] Fix p21read compilation. --- src/test/p21read/p21read.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index cae0df598..04211ee98 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) char *flnm; // p21 ReadExchangeFile() - benchmark stats(); + benchmark stats; cout << argv[0] << ": load file ..." << endl; if(argc >= (sc_optind + 1)) { From 30683985cad5807406933177776fc2b780bc44c0 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:07:37 -0500 Subject: [PATCH 107/244] Stray version header includes in test cc files --- test/cpp/schema_specific/attribute.cc | 1 - test/cpp/schema_specific/inverse_attr1.cc | 1 - test/cpp/schema_specific/inverse_attr2.cc | 1 - 3 files changed, 3 deletions(-) diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index c0129203c..578e14911 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,7 +3,6 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include -#include "sc_version_string.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 92985a617..717baec3a 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,7 +4,6 @@ ** */ #include -#include "sc_version_string.h" #include "SubSuperIterators.h" #include #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index b017a7b71..0feef4b5b 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,7 +4,6 @@ ** */ #include -#include "sc_version_string.h" #include #include #include From d27564c5ed8cc7e2617694e56c203f4f34af6e60 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:13:04 -0500 Subject: [PATCH 108/244] Switch SdaiBinary content container to a plain C string to avoid the 4251 warning. --- src/cldai/sdaiBinary.cc | 60 ++++++++++++++++++++++++++++++++++++----- src/cldai/sdaiBinary.h | 18 ++++++------- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index 3763f9490..d82dcdbee 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -9,43 +9,91 @@ * and is not subject to copyright. */ +#include #include #include #include "sc_memmgr.h" SDAI_Binary::SDAI_Binary(const char *str, int max) { - content = std::string(str, max); + if(content) { + free((void *)content); + } + + content = (char *)calloc(max + 1, sizeof(char)); + snprintf(content, max, "%s", str); +} + +SDAI_Binary::SDAI_Binary(const char *s) +{ + if(content) { + free((void *)content); + } + + content = (char *)calloc(strlen(s) + 1, sizeof(char)); + snprintf(content, strlen(s), "%s", s); } SDAI_Binary::SDAI_Binary(const std::string &s) { - content = std::string(s); + if(content) { + free((void *)content); + } + + content = (char *)calloc(s.length() + 1, sizeof(char)); + snprintf(content, s.length(), "%s", s.c_str()); +} + +SDAI_Binary::SDAI_Binary(int i) +{ + if(content) { + free((void *)content); + } + + content = (char *)calloc(2, sizeof(char)); + if(i) { + content[0] = '1'; + } else { + content[0] = '0'; + } + content[1] = '\0'; } SDAI_Binary::~SDAI_Binary(void) { + if(content) { + free((void *)content); + } + content = NULL; } SDAI_Binary &SDAI_Binary::operator= (const char *s) { - content = std::string(s); + if(content) { + free((void *)content); + } + + content = (char *)calloc(strlen(s) + 1, sizeof(char)); + snprintf(content, strlen(s), "%s", s); return *this; } void SDAI_Binary::clear(void) { - content.clear(); + if(content) { + free((void *)content); + } + content = NULL; } bool SDAI_Binary::empty(void) const { - return content.empty(); + return (!content) ? true : false; } const char *SDAI_Binary::c_str(void) const { - return content.c_str(); + return (const char *)content; } void SDAI_Binary::STEPwrite(ostream &out) const diff --git a/src/cldai/sdaiBinary.h b/src/cldai/sdaiBinary.h index c07350fda..fb2204f9b 100644 --- a/src/cldai/sdaiBinary.h +++ b/src/cldai/sdaiBinary.h @@ -1,7 +1,10 @@ #ifndef SDAIBINARY_H #define SDAIBINARY_H 1 -#include +#include "sc_export.h" +#include "errordesc.h" + +#include /* * NIST STEP Core Class Library @@ -16,20 +19,15 @@ class SC_DAI_EXPORT SDAI_Binary { private: -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable: 4251 ) -#endif - std::string content; -#ifdef _MSC_VER -#pragma warning( pop ) -#endif + char *content = NULL; public: //constructor(s) & destructor SDAI_Binary(const char *str = 0, int max = 0); + SDAI_Binary(const char *s); SDAI_Binary(const std::string &s); + SDAI_Binary(int i); ~SDAI_Binary(void); // operators @@ -43,7 +41,7 @@ class SC_DAI_EXPORT SDAI_Binary { return c_str(); } - void STEPwrite(ostream &out = cout) const; + void STEPwrite(std::ostream &out = std::cout) const; const char *STEPwrite(std::string &s) const; Severity StrToVal(const char *s, ErrorDescriptor *err); From 359f949ed602d45b8d88d4da3e06e21f43fe763d Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:13:47 -0500 Subject: [PATCH 109/244] Formatting fixes. --- src/base/sc_benchmark.cc | 16 ++++----- src/base/sc_benchmark.h | 2 +- src/clstepcore/STEPattribute.h | 4 +-- src/clstepcore/sdaiApplication_instance.cc | 14 ++++---- src/exp2cxx/classes_wrapper.cc | 36 ++++++++++---------- src/exp2cxx/selects.c | 6 ++-- src/exp2python/src/classes_wrapper_python.cc | 10 +++--- src/express/expr.c | 20 +++++------ 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index 96770de7a..fcea26dd7 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -94,13 +94,13 @@ benchmark::~benchmark() if(!stopped) { stop(); if(debug) { - std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; + std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; } out(); } - if (benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; + if(benchVals_str) { + free((void *)benchVals_str); + benchVals_str = NULL; } } @@ -146,7 +146,7 @@ const char *benchmark::str() void benchmark::out() { - std::cout << str() << std::endl; + std::cout << str() << std::endl; } const char *benchmark::str(const benchVals &bv) @@ -154,9 +154,9 @@ const char *benchmark::str(const benchVals &bv) std::stringstream ss; ss << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; - if (benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; + if(benchVals_str) { + free((void *)benchVals_str); + benchVals_str = NULL; } benchVals_str = (char *)calloc(ss.str().length() + 1, sizeof(char)); snprintf(benchVals_str, ss.str().length(), "%s", ss.str().c_str()); diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index 81a0441ec..b11017c6a 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -42,7 +42,7 @@ class SC_BASE_EXPORT benchmark protected: benchVals initialVals, laterVals; bool debug, stopped; - char *benchVals_str = NULL; + char *benchVals_str = NULL; public: benchmark(bool debugMessages = true); diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 01cc1465e..7e80c8edc 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -105,10 +105,10 @@ class SC_CORE_EXPORT STEPattribute ErrorDescriptor _error; STEPattribute *_redefAttr; public: - const AttrDescriptor *aDesc; + const AttrDescriptor *aDesc; protected: - int refCount; + int refCount; char SkipBadAttr(istream &in, char *StopChars); void AddErrorInfo(); diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 5c5bfa671..3fc61b6fd 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -703,8 +703,8 @@ SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, cons case '@': err->AppendToDetailMsg("Use of @ instead of # to identify entity.\n"); err->GreaterSeverity(SEVERITY_WARNING); - // no break statement here on purpose - [[gnu::fallthrough]]; + // no break statement here on purpose + [[gnu::fallthrough]]; case '#': { int id = -1; in >> id; @@ -914,11 +914,11 @@ Severity EntityValidLevel(const char *attrValue, // string contain entity ref if((found1 > 0) || (found2 > 0)) { if((found1 == 2) || (found2 == 2)) { int ocnt = snprintf(messageBuf, BUFSIZ, - " Attribute's Entity Reference %s is %s data \'%s\'.\n", - attrValue, "followed by invalid", tmp); - if (ocnt < BUFSIZ) { - fprintf(stderr, "Warning - truncation of Attribute's Entry Reference msg\n"); - } + " Attribute's Entity Reference %s is %s data \'%s\'.\n", + attrValue, "followed by invalid", tmp); + if(ocnt < BUFSIZ) { + fprintf(stderr, "Warning - truncation of Attribute's Entry Reference msg\n"); + } err->AppendToUserMsg(messageBuf); err->AppendToDetailMsg(messageBuf); err->GreaterSeverity(SEVERITY_WARNING); diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index f5756e8b1..8b1daca64 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -424,18 +424,18 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) sprintf(schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper(SCHEMAget_name(schema))); //TODO change file names to CamelCase? if(suffix == 0) { ocnt = snprintf(sufnm, MAX_LEN, "%s", schnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; - } + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; + } } else { ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; - } + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; + } } ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; } if(!(incfile = (files -> inc) = FILEcreate(fnm))) { @@ -478,8 +478,8 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) // 3. header for namespace to contain all formerly-global variables ocnt = snprintf(fnm, MAX_LEN, "%sNames.h", schnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; } if(!(files->names = FILEcreate(fnm))) { @@ -497,9 +497,9 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) if(suffix <= 1) { /* I.e., if this is our first pass with schema */ ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; - } + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; + } /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ @@ -563,12 +563,12 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) fprintf(files->classes, "\n#include \"%sNames.h\"\n", schnm); } else { /* Just reopen the .init.cc (in append mode): */ - ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; - } + ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; + } - initfile = files->init = fopen(fnm, "a"); + initfile = files->init = fopen(fnm, "a"); } /********** record in files relating to entire input ***********/ diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index e1e0b12cb..1360e3551 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -1113,9 +1113,9 @@ void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) /* get methods */ TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false); - /* TODO - This isn't good enough - the compiler warning Wignored-qualifiers is picking up - * a lot of spurious const expressions coming from these outputs. Not sure of the pattern - * yet, but it looks like not all attrIsObj entities should be using it. */ + /* TODO - This isn't good enough - the compiler warning Wignored-qualifiers is picking up + * a lot of spurious const expressions coming from these outputs. Not sure of the pattern + * yet, but it looks like not all attrIsObj entities should be using it. */ if(attrIsObj(VARget_type(a))) { TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true); } diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index e61eefa00..dbc6e9a50 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -165,13 +165,13 @@ void SCHEMAprint(Schema schema, FILES *files, int suffix) sprintf(sufnm, "%s", schnm); } else { ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; - } + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; + } } ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if (ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; + if(ocnt > MAX_LEN) { + std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; } np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ diff --git a/src/express/expr.c b/src/express/expr.c index 679b2b086..a4870dd08 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -239,8 +239,8 @@ static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, *dt = DICT_type; return 1; } else { - return 0; - } + return 0; + } default: return 0; } @@ -327,8 +327,8 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) } else { fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); ERRORabort(0); - return(Type_Bad); - } + return(Type_Bad); + } default: /* compile-time ambiguous */ if(where) { @@ -615,13 +615,13 @@ void EXPresolve_op_default(Expression e, Scope s) { int failed = 0; - if (OPget_number_of_operands(e->e.op_code) == 3) { - EXPresolve(e->e.op3, s, Type_Dont_Care); - failed = is_resolve_failed(e->e.op3); + if(OPget_number_of_operands(e->e.op_code) == 3) { + EXPresolve(e->e.op3, s, Type_Dont_Care); + failed = is_resolve_failed(e->e.op3); } - if (OPget_number_of_operands(e->e.op_code) == 2) { - EXPresolve(e->e.op2, s, Type_Dont_Care); - failed |= is_resolve_failed(e->e.op2); + if(OPget_number_of_operands(e->e.op_code) == 2) { + EXPresolve(e->e.op2, s, Type_Dont_Care); + failed |= is_resolve_failed(e->e.op2); } EXPresolve(e->e.op1, s, Type_Dont_Care); if(failed || is_resolve_failed(e->e.op1)) { From bbc20e3ba22c639b75b731ea3f029bab8c75e788 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:03:48 -0500 Subject: [PATCH 110/244] Check for null before deferencing, and initialize to NULL. (Crash observed in Release build for BRL-CAD's step-g on Ubuntu Linux.) --- src/clstepcore/complexSupport.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index 00490df23..860bac36e 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -193,22 +193,22 @@ class SC_CORE_EXPORT EntList EntList *firstNot(JoinType); EntList *nextNot(JoinType j) { - return next->firstNot(j); + return (next) ? next->firstNot(j) : NULL; } EntList *firstWanted(MatchType); EntList *nextWanted(MatchType mat) { - return next->firstWanted(mat); + return (next) ? next->firstWanted(mat) : NULL; } EntList *lastNot(JoinType); EntList *prevNot(JoinType j) { - return prev->lastNot(j); + return (prev) ? prev->lastNot(j) : NULL; } EntList *lastWanted(MatchType); EntList *prevWanted(MatchType mat) { - return prev->lastWanted(mat); + return (prev) ? prev->lastWanted(mat) : NULL; } JoinType join; @@ -216,7 +216,8 @@ class SC_CORE_EXPORT EntList { return (join != SIMPLE); } - EntList *next, *prev; + EntList *next = NULL; + EntList *prev = NULL; protected: MatchType viable; From a1462e99b0d446954790f4c2530ab051fef89687 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 17 Dec 2020 23:57:22 -0500 Subject: [PATCH 111/244] Simplify header generation. --- cmake/SC_Config_Headers.cmake | 24 ++---------------------- include/{sc_cf_cmake.h.in => sc_cf.h.in} | 0 2 files changed, 2 insertions(+), 22 deletions(-) rename include/{sc_cf_cmake.h.in => sc_cf.h.in} (100%) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index cb7e02406..f9a8cc86b 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,24 +1,5 @@ # create sc_cf.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(CheckSymbolExists) @@ -97,9 +78,8 @@ int main() {return !(f() == f());} endif(SC_ENABLE_CXX11) # 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_DIR}/sc_cf.h) +configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) # Local Variables: # tab-width: 8 diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf.h.in similarity index 100% rename from include/sc_cf_cmake.h.in rename to include/sc_cf.h.in From 880a42bb909188a4a4b49c78cd9504b4ad6389aa Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 9 Jan 2021 21:17:44 -0500 Subject: [PATCH 112/244] Fix example build (Issue #404) by adding the sc_cf.h.in file (making a copy rather than a symlink for the sake of Windows.) --- example/ap203min/include/sc_cf.h.in | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 example/ap203min/include/sc_cf.h.in diff --git a/example/ap203min/include/sc_cf.h.in b/example/ap203min/include/sc_cf.h.in new file mode 100644 index 000000000..67d88c433 --- /dev/null +++ b/example/ap203min/include/sc_cf.h.in @@ -0,0 +1,32 @@ +#ifndef SCL_CF_H +#define SCL_CF_H + +/**** Define statements for CMake ****/ +#cmakedefine SC_VERSION "@SC_VERSION@" +#cmakedefine HAVE_NDIR_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_PARAM_H 1 +#cmakedefine HAVE_SYSENT_H 1 +#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine HAVE_DIRENT_H 1 +#cmakedefine HAVE_STDBOOL_H 1 +#cmakedefine HAVE_PROCESS_H 1 +#cmakedefine HAVE_IO_H 1 + +#cmakedefine SC_TRACE_FPRINTF 1 +#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 + +#cmakedefine HAVE_ABS 1 +#cmakedefine HAVE_MEMCPY 1 +#cmakedefine HAVE_MEMMOVE 1 +#cmakedefine HAVE_GETOPT 1 +#cmakedefine HAVE_VSNPRINTF 1 + +#cmakedefine HAVE_SSIZE_T 1 + +#cmakedefine HAVE_STD_THREAD 1 +#cmakedefine HAVE_STD_CHRONO 1 +#cmakedefine HAVE_NULLPTR 1 + +#endif /* SCL_CF_H */ From 29f87a6d582569b2b8a2d85175650245aa13a201 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 4 Aug 2021 15:54:49 -0400 Subject: [PATCH 113/244] Reverting back to state at commit 548fd82ad7ec3730 Subsequent changes caused problems for development, and will need to be merged in more carefully from develop --- CMakeLists.txt | 164 +- README.md | 18 +- SC_VERSION.txt | 1 + cmake/FindLEMON.cmake | 40 +- cmake/FindPERPLEX.cmake | 42 +- cmake/FindRE2C.cmake | 26 +- cmake/Generated_Source_Utils.cmake | 67 + cmake/Path_Setup.cmake | 164 - cmake/SC_Build_opts.cmake | 176 + cmake/SC_CXX_schema_macros.cmake | 11 +- cmake/SC_Config_Headers.cmake | 53 +- cmake/SC_Targets.cmake | 6 +- cmake/md5_gen.cmake.in | 35 + cmake/md5_verify.cmake.in | 30 + cmake/sc_version_string.cmake | 84 + cmake/schema_scanner/README | 14 +- cmake/schema_scanner/schemaScanner.cmake | 4 +- data/CMakeLists.txt | 2 +- example/ap203min/CMakeLists.txt | 8 +- .../cmake/External_STEPCode.cmake | 5 + include/CMakeLists.txt | 11 +- include/exppp/exppp.h | 84 +- include/express/alg.h | 20 +- include/express/alloc.h | 14 +- include/express/basic.h | 4 +- include/express/caseitem.h | 8 +- include/express/dict.h | 20 +- include/express/entity.h | 30 +- include/express/error.h | 42 +- include/express/exp_kw.h | 240 +- include/express/expbasic.h | 10 +- include/express/expr.h | 52 +- include/express/express.h | 48 +- include/express/factory.h | 4 +- include/express/hash.h | 30 +- include/express/info.h | 4 +- include/express/lexact.h | 42 +- include/express/linklist.h | 42 +- include/express/memory.h | 4 +- include/express/object.h | 4 +- include/express/resolve.h | 40 +- include/express/schema.h | 38 +- include/express/scope.h | 40 +- include/express/stmt.h | 70 +- include/express/symbol.h | 8 +- include/express/type.h | 34 +- include/express/variable.h | 10 +- include/ordered_attrs.h | 4 +- include/sc_cf.h.in | 32 - .../sc_cf.h.in => include/sc_cf_cmake.h.in | 1 - misc/astyle.cfg | 5 +- src/base/CMakeLists.txt | 7 +- src/base/judy/misc/judy64n.c | 2200 +++-- src/base/judy/src/judy.c | 866 +- src/base/judy/src/judy.h | 54 +- src/base/judy/src/judyL2Array.h | 127 +- src/base/judy/src/judyLArray.h | 114 +- src/base/judy/src/judyS2Array.h | 163 +- src/base/judy/src/judySArray.h | 138 +- src/base/judy/test/hexSort.c | 83 +- src/base/judy/test/judyL2test.cc | 48 +- src/base/judy/test/judyLtest.cc | 31 +- src/base/judy/test/judyS2test.cc | 52 +- src/base/judy/test/judyStest.cc | 33 +- src/base/judy/test/pennySort.c | 163 +- src/base/judy/test/sort.c | 194 +- src/base/judy/test/sort.h | 4 +- src/base/path2str.c | 23 +- src/base/path2str.h | 2 +- src/base/sc_benchmark.cc | 98 +- src/base/sc_benchmark.h | 53 +- src/base/sc_getopt.cc | 31 +- src/base/sc_getopt.h | 6 +- src/base/sc_memmgr.cc | 223 +- src/base/sc_memmgr.h | 44 +- src/base/sc_mkdir.c | 26 +- src/base/sc_mkdir.h | 4 +- src/base/sc_nullptr.h | 13 + src/base/sc_stdio.h | 12 +- src/base/sc_trace_fprintf.c | 13 +- src/base/sc_trace_fprintf.h | 8 +- src/cldai/CMakeLists.txt | 6 +- src/cldai/sdaiApplication_instance_set.cc | 85 +- src/cldai/sdaiApplication_instance_set.h | 23 +- src/cldai/sdaiBinary.cc | 231 +- src/cldai/sdaiBinary.h | 62 +- src/cldai/sdaiDaObject.cc | 114 +- src/cldai/sdaiDaObject.h | 115 +- src/cldai/sdaiEntity_extent.cc | 39 +- src/cldai/sdaiEntity_extent.h | 26 +- src/cldai/sdaiEntity_extent_set.cc | 158 +- src/cldai/sdaiEntity_extent_set.h | 23 +- src/cldai/sdaiEnum.cc | 509 +- src/cldai/sdaiEnum.h | 123 +- src/cldai/sdaiModel_contents.cc | 67 +- src/cldai/sdaiModel_contents.h | 32 +- src/cldai/sdaiModel_contents_list.cc | 84 +- src/cldai/sdaiModel_contents_list.h | 21 +- src/cldai/sdaiObject.cc | 6 +- src/cldai/sdaiObject.h | 5 +- src/cldai/sdaiSession_instance.cc | 6 +- src/cldai/sdaiSession_instance.h | 5 +- src/cldai/sdaiString.cc | 84 +- src/cldai/sdaiString.h | 36 +- src/cleditor/CMakeLists.txt | 6 +- src/cleditor/STEPfile.cc | 1230 ++- src/cleditor/STEPfile.h | 168 +- src/cleditor/STEPfile.inline.cc | 235 +- src/cleditor/SdaiHeaderSchema.cc | 537 +- src/cleditor/SdaiHeaderSchema.h | 163 +- src/cleditor/SdaiHeaderSchemaAll.cc | 65 +- src/cleditor/SdaiHeaderSchemaClasses.h | 74 +- src/cleditor/SdaiHeaderSchemaInit.cc | 273 +- src/cleditor/SdaiSchemaInit.cc | 9 +- src/cleditor/SdaiSchemaInit.h | 6 +- src/cleditor/cmdmgr.cc | 108 +- src/cleditor/cmdmgr.h | 124 +- src/cleditor/seeinfodefault.h | 19 +- src/cllazyfile/CMakeLists.txt | 9 +- src/cllazyfile/headerSectionReader.h | 16 +- src/cllazyfile/instMgrHelper.h | 26 +- src/cllazyfile/lazyDataSectionReader.cc | 7 +- src/cllazyfile/lazyDataSectionReader.h | 8 +- src/cllazyfile/lazyFileReader.cc | 55 +- src/cllazyfile/lazyFileReader.h | 25 +- src/cllazyfile/lazyInstMgr.cc | 122 +- src/cllazyfile/lazyInstMgr.h | 130 +- src/cllazyfile/lazyP21DataSectionReader.cc | 50 +- src/cllazyfile/lazyP21DataSectionReader.h | 10 +- src/cllazyfile/lazyRefs.h | 217 +- src/cllazyfile/lazyTypes.h | 4 +- src/cllazyfile/lazy_test.cc | 146 +- src/cllazyfile/p21HeaderSectionReader.cc | 43 +- src/cllazyfile/p21HeaderSectionReader.h | 5 +- src/cllazyfile/sectionReader.cc | 224 +- src/cllazyfile/sectionReader.h | 61 +- src/clstepcore/CMakeLists.txt | 6 +- src/clstepcore/Registry.cc | 269 +- src/clstepcore/Registry.h | 68 +- src/clstepcore/STEPaggrBinary.cc | 80 +- src/clstepcore/STEPaggrBinary.h | 66 +- src/clstepcore/STEPaggrEntity.cc | 196 +- src/clstepcore/STEPaggrEntity.h | 126 +- src/clstepcore/STEPaggrEnum.cc | 117 +- src/clstepcore/STEPaggrEnum.h | 100 +- src/clstepcore/STEPaggrGeneric.cc | 78 +- src/clstepcore/STEPaggrGeneric.h | 66 +- src/clstepcore/STEPaggrInt.cc | 79 +- src/clstepcore/STEPaggrInt.h | 54 +- src/clstepcore/STEPaggrReal.cc | 77 +- src/clstepcore/STEPaggrReal.h | 54 +- src/clstepcore/STEPaggrSelect.cc | 182 +- src/clstepcore/STEPaggrSelect.h | 130 +- src/clstepcore/STEPaggrString.cc | 82 +- src/clstepcore/STEPaggrString.h | 66 +- src/clstepcore/STEPaggregate.cc | 250 +- src/clstepcore/STEPaggregate.h | 111 +- src/clstepcore/STEPattribute.cc | 949 +-- src/clstepcore/STEPattribute.h | 234 +- src/clstepcore/STEPattributeList.cc | 47 +- src/clstepcore/STEPattributeList.h | 14 +- src/clstepcore/STEPcomplex.cc | 524 +- src/clstepcore/STEPcomplex.h | 85 +- src/clstepcore/STEPinvAttrList.cc | 52 +- src/clstepcore/STEPinvAttrList.h | 61 +- src/clstepcore/STEPundefined.cc | 91 +- src/clstepcore/STEPundefined.h | 21 +- src/clstepcore/SingleLinkList.cc | 79 +- src/clstepcore/SingleLinkList.h | 33 +- src/clstepcore/SubSuperIterators.h | 181 +- src/clstepcore/aggrTypeDescriptor.cc | 27 +- src/clstepcore/aggrTypeDescriptor.h | 371 +- src/clstepcore/attrDescriptor.cc | 109 +- src/clstepcore/attrDescriptor.h | 140 +- src/clstepcore/attrDescriptorList.cc | 40 +- src/clstepcore/attrDescriptorList.h | 35 +- src/clstepcore/collect.cc | 66 +- src/clstepcore/complexSupport.h | 338 +- src/clstepcore/complexlist.cc | 114 +- src/clstepcore/create_Aggr.cc | 24 +- src/clstepcore/create_Aggr.h | 36 +- src/clstepcore/derivedAttribute.cc | 35 +- src/clstepcore/derivedAttribute.h | 19 +- src/clstepcore/dictSchema.cc | 156 +- src/clstepcore/dictSchema.h | 260 +- src/clstepcore/dictdefs.h | 30 +- src/clstepcore/dictionaryInstance.h | 11 +- src/clstepcore/dispnode.cc | 20 +- src/clstepcore/dispnode.h | 37 +- src/clstepcore/dispnodelist.cc | 28 +- src/clstepcore/dispnodelist.h | 23 +- src/clstepcore/entityDescriptor.cc | 249 +- src/clstepcore/entityDescriptor.h | 125 +- src/clstepcore/entityDescriptorList.cc | 29 +- src/clstepcore/entityDescriptorList.h | 47 +- src/clstepcore/entlist.cc | 63 +- src/clstepcore/entnode.cc | 85 +- src/clstepcore/enumTypeDescriptor.cc | 70 +- src/clstepcore/enumTypeDescriptor.h | 30 +- src/clstepcore/explicitItemId.cc | 85 +- src/clstepcore/explicitItemId.h | 204 +- src/clstepcore/globalRule.cc | 106 +- src/clstepcore/globalRule.h | 122 +- src/clstepcore/implicitItemId.cc | 85 +- src/clstepcore/implicitItemId.h | 82 +- src/clstepcore/instmgr.cc | 240 +- src/clstepcore/instmgr.h | 82 +- src/clstepcore/interfaceSpec.cc | 102 +- src/clstepcore/interfaceSpec.h | 166 +- src/clstepcore/interfacedItem.cc | 20 +- src/clstepcore/interfacedItem.h | 23 +- src/clstepcore/inverseAttribute.cc | 21 +- src/clstepcore/inverseAttribute.h | 45 +- src/clstepcore/inverseAttributeList.cc | 48 +- src/clstepcore/inverseAttributeList.h | 37 +- src/clstepcore/match-ors.cc | 61 +- src/clstepcore/mgrnode.cc | 114 +- src/clstepcore/mgrnode.h | 74 +- src/clstepcore/mgrnodearray.cc | 132 +- src/clstepcore/mgrnodearray.h | 48 +- src/clstepcore/mgrnodelist.cc | 46 +- src/clstepcore/mgrnodelist.h | 15 +- src/clstepcore/multlist.cc | 118 +- src/clstepcore/needFunc.cc | 3 +- src/clstepcore/needFunc.h | 5 +- src/clstepcore/non-ors.cc | 49 +- src/clstepcore/orlist.cc | 35 +- src/clstepcore/print.cc | 53 +- src/clstepcore/read_func.cc | 562 +- src/clstepcore/read_func.h | 72 +- src/clstepcore/realTypeDescriptor.h | 32 +- src/clstepcore/schRename.cc | 20 +- src/clstepcore/schRename.h | 51 +- src/clstepcore/sdai.cc | 2 +- src/clstepcore/sdai.h | 28 +- src/clstepcore/sdaiApplication_instance.cc | 782 +- src/clstepcore/sdaiApplication_instance.h | 151 +- src/clstepcore/sdaiSelect.cc | 345 +- src/clstepcore/sdaiSelect.h | 75 +- src/clstepcore/selectTypeDescriptor.cc | 51 +- src/clstepcore/selectTypeDescriptor.h | 92 +- src/clstepcore/stringTypeDescriptor.h | 65 +- src/clstepcore/superInvAttrIter.h | 107 +- src/clstepcore/test/CMakeLists.txt | 2 +- .../test/test_SupertypesIterator.cc | 83 +- src/clstepcore/test/test_null_attr.cc | 13 +- .../test/test_operators_SDAI_Select.cc | 79 +- .../test/test_operators_STEPattribute.cc | 57 +- src/clstepcore/trynext.cc | 72 +- src/clstepcore/typeDescriptor.cc | 323 +- src/clstepcore/typeDescriptor.h | 114 +- src/clstepcore/typeDescriptorList.cc | 29 +- src/clstepcore/typeDescriptorList.h | 42 +- src/clstepcore/typeOrRuleVar.cc | 11 +- src/clstepcore/typeOrRuleVar.h | 13 +- src/clstepcore/uniquenessRule.cc | 85 +- src/clstepcore/uniquenessRule.h | 116 +- src/clstepcore/whereRule.cc | 85 +- src/clstepcore/whereRule.h | 108 +- src/clutils/CMakeLists.txt | 6 +- src/clutils/Str.cc | 177 +- src/clutils/Str.h | 36 +- src/clutils/dirobj.cc | 156 +- src/clutils/dirobj.h | 56 +- src/clutils/errordesc.cc | 105 +- src/clutils/errordesc.h | 93 +- src/clutils/gennode.cc | 5 +- src/clutils/gennode.h | 22 +- src/clutils/gennodearray.cc | 91 +- src/clutils/gennodearray.h | 31 +- src/clutils/gennodelist.cc | 38 +- src/clutils/gennodelist.h | 24 +- src/clutils/sc_hash.cc | 233 +- src/clutils/sc_hash.h | 34 +- src/exp2cxx/CMakeLists.txt | 4 + src/exp2cxx/class_strings.c | 213 +- src/exp2cxx/class_strings.h | 20 +- src/exp2cxx/classes.c | 219 +- src/exp2cxx/classes.h | 88 +- src/exp2cxx/classes_attribute.c | 668 +- src/exp2cxx/classes_attribute.h | 18 +- src/exp2cxx/classes_entity.c | 1087 ++- src/exp2cxx/classes_entity.h | 16 +- src/exp2cxx/classes_misc.c | 285 +- src/exp2cxx/classes_type.c | 1116 ++- src/exp2cxx/classes_type.h | 40 +- src/exp2cxx/classes_wrapper.cc | 742 +- src/exp2cxx/collect.cc | 62 +- src/exp2cxx/complexSupport.h | 368 +- src/exp2cxx/complexlist.cc | 110 +- src/exp2cxx/entlist.cc | 58 +- src/exp2cxx/entnode.cc | 48 +- src/exp2cxx/expressbuild.cc | 182 +- src/exp2cxx/fedex_main.c | 72 +- src/exp2cxx/genCxxFilenames.c | 18 +- src/exp2cxx/genCxxFilenames.h | 8 +- src/exp2cxx/match-ors.cc | 58 +- src/exp2cxx/multlist.cc | 135 +- src/exp2cxx/multpass.c | 445 +- src/exp2cxx/non-ors.cc | 46 +- src/exp2cxx/orlist.cc | 32 +- src/exp2cxx/print.cc | 48 +- src/exp2cxx/rules.c | 69 +- src/exp2cxx/rules.h | 4 +- src/exp2cxx/selects.c | 1816 ++-- src/exp2cxx/trynext.cc | 68 +- src/exp2cxx/write.cc | 56 +- src/exp2python/CMakeLists.txt | 3 + src/exp2python/src/classes.h | 118 +- src/exp2python/src/classes_misc_python.c | 363 +- src/exp2python/src/classes_python.c | 1719 ++-- src/exp2python/src/classes_wrapper_python.cc | 227 +- src/exp2python/src/complexSupport.h | 368 +- src/exp2python/src/fedex_main_python.c | 62 +- src/exp2python/src/multpass_python.c | 319 +- src/exp2python/src/selects_python.c | 293 +- src/exppp/CMakeLists.txt | 4 +- src/exppp/exppp-main.c | 73 +- src/exppp/exppp.c | 308 +- src/exppp/pp.h | 24 +- src/exppp/pretty_alg.c | 49 +- src/exppp/pretty_alg.h | 4 +- src/exppp/pretty_case.c | 61 +- src/exppp/pretty_case.h | 2 +- src/exppp/pretty_entity.c | 234 +- src/exppp/pretty_entity.h | 14 +- src/exppp/pretty_expr.c | 361 +- src/exppp/pretty_expr.h | 14 +- src/exppp/pretty_express.c | 9 +- src/exppp/pretty_express.h | 2 +- src/exppp/pretty_func.c | 58 +- src/exppp/pretty_func.h | 8 +- src/exppp/pretty_loop.c | 41 +- src/exppp/pretty_loop.h | 2 +- src/exppp/pretty_proc.c | 44 +- src/exppp/pretty_proc.h | 8 +- src/exppp/pretty_ref.c | 56 +- src/exppp/pretty_ref.h | 2 +- src/exppp/pretty_rule.c | 52 +- src/exppp/pretty_rule.h | 8 +- src/exppp/pretty_schema.c | 143 +- src/exppp/pretty_schema.h | 8 +- src/exppp/pretty_scope.c | 322 +- src/exppp/pretty_scope.h | 18 +- src/exppp/pretty_stmt.c | 115 +- src/exppp/pretty_stmt.h | 10 +- src/exppp/pretty_subtype.c | 18 +- src/exppp/pretty_subtype.h | 4 +- src/exppp/pretty_type.c | 255 +- src/exppp/pretty_type.h | 26 +- src/exppp/pretty_where.c | 60 +- src/exppp/pretty_where.h | 8 +- src/exppp/test/test_breakLongStr.c | 33 +- src/express/CMakeLists.txt | 163 +- src/express/alg.c | 15 +- src/express/alloc.c | 84 +- src/express/caseitem.c | 8 +- src/express/dict.c | 89 +- src/express/entity.c | 218 +- src/express/error.c | 250 +- src/express/exp_kw.c | 240 +- src/express/expr.c | 625 +- src/express/express.c | 613 +- src/express/expscan.l | 5 - src/express/factory.c | 201 +- src/express/fedex.c | 115 +- src/express/generated/CMakeLists.txt | 8 + src/express/generated/README | 11 +- src/express/generated/expparse.c | 7334 ++++++++--------- src/express/generated/expscan.c | 2154 +++-- src/express/generated/expscan.h | 10 +- src/express/generated/verification_info.cmake | 7 + src/express/hash.c | 259 +- src/express/info.c | 58 +- src/express/inithook.c | 3 +- src/express/lexact.c | 211 +- src/express/linklist.c | 134 +- src/express/memory.c | 91 +- src/express/object.c | 70 +- src/express/ordered_attrs.cc | 67 +- src/express/resolve.c | 862 +- src/express/resolve2.c | 91 +- src/express/schema.c | 150 +- src/express/scope.c | 131 +- src/express/stack.h | 8 + src/express/stmt.c | 75 +- src/express/symbol.c | 3 +- src/express/test/CMakeLists.txt | 42 +- src/express/test/driver.c | 30 +- src/express/test/driver.h | 2 +- src/express/test/fff.h | 174 +- src/express/test/print_attrs.c | 82 +- src/express/test/print_schemas.c | 18 +- src/express/test/test_expr.c | 60 +- src/express/test/test_express.c | 22 +- src/express/test/test_resolve.c | 143 +- src/express/test/test_resolve2.c | 31 +- src/express/test/test_schema.c | 79 +- src/express/test/test_scope.c | 22 +- src/express/test/test_type.c | 20 +- src/express/token_type.h | 6 +- src/express/type.c | 77 +- src/express/variable.c | 18 +- src/test/SEarritr.h | 24 +- src/test/generate_express/generate_express.cc | 35 +- src/test/needFunc.cc | 3 +- src/test/needFunc.h | 5 +- src/test/p21read/p21read.cc | 121 +- src/test/scl2html/scl2html.cc | 120 +- src/test/tests.h | 2 +- src/test/tio/tio.cc | 41 +- src/test/treg/treg.cc | 64 +- src/test/tstatic/tstatic.cc | 51 +- test/CMakeLists.txt | 6 +- test/cpp/CMakeLists.txt | 2 +- test/cpp/schema_specific/CMakeLists.txt | 4 - .../aggregate_bound_runtime.cc | 91 +- test/cpp/schema_specific/attribute.cc | 40 +- test/cpp/schema_specific/inverse_attr1.cc | 67 +- test/cpp/schema_specific/inverse_attr2.cc | 75 +- test/cpp/schema_specific/inverse_attr3.cc | 43 +- .../schema_specific/stepfile_rw_progress.cc | 59 +- test/p21/CMakeLists.txt | 2 +- 423 files changed, 26968 insertions(+), 30278 deletions(-) create mode 100644 SC_VERSION.txt create mode 100644 cmake/Generated_Source_Utils.cmake delete mode 100644 cmake/Path_Setup.cmake create mode 100644 cmake/SC_Build_opts.cmake create mode 100644 cmake/md5_gen.cmake.in create mode 100644 cmake/md5_verify.cmake.in create mode 100644 cmake/sc_version_string.cmake delete mode 100644 include/sc_cf.h.in rename example/ap203min/include/sc_cf.h.in => include/sc_cf_cmake.h.in (94%) create mode 100644 src/base/sc_nullptr.h create mode 100644 src/express/generated/CMakeLists.txt create mode 100644 src/express/generated/verification_info.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7224efff4..d897264c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# C M A K E L I S T S . T X T +# C M A K E L I S T S . T X T F O R S T E P C O D E # # This file is Copyright (c) 2010 United States Government as # represented by the U.S. Army Research Laboratory. @@ -40,124 +40,45 @@ project(SC) -# Minimum required version of CMake -cmake_minimum_required(VERSION 3.12) -if (POLICY CMP0077) - cmake_policy(SET CMP0077 OLD) -endif (POLICY CMP0077) - # SC version set(SC_VERSION_MAJOR 0) -set(SC_VERSION_MINOR 9) -set(SC_VERSION_PATCH 1) -set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) +set(SC_VERSION_MINOR 8-dev) +set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) -# Set language standards -set(CMAKE_C_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +# 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) + +# Minimum required version of CMake +cmake_minimum_required(VERSION 3.6.3) +cmake_policy(SET CMP0003 NEW) +cmake_policy(SET CMP0026 NEW) +cmake_policy(SET CMP0057 NEW) # 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") -list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}") - -# OpenBSD has its own naming conventions. Set a platform variable based on -# the OS name so we can test for it succinctly. -if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") - set(OPENBSD ON) -endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") - -#--------------------------------------------------------------------- -# Set up various relative path variables and build output directories -include(Path_Setup) - -#--------------------------------------------------------------------- -# 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 -if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) - set(CMAKE_SKIP_BUILD_RPATH FALSE) -endif() - -# when building, don't use the install RPATH already -# (but later on when installing) -if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -endif() - -# the RPATH/INSTALL_NAME_DIR to be used when installing -if (NOT APPLE) - if(NOT DEFINED CMAKE_INSTALL_RPATH) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") - endif() -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 -if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) - set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -endif() - -# add the automatically determined parts of the RPATH which point to -# directories outside the build tree to the install RPATH -if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -endif() - - -#--------------------------------------------------------------------- -# Build options -option(BUILD_SHARED_LIBS "Build shared libraries" ON) -option(BUILD_STATIC_LIBS "Build static libraries" OFF) - -option(SC_PYTHON_GENERATOR "Compile exp2python" ON) -option(SC_CPP_GENERATOR "Compile exp2cxx" ON) - -option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) -option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) - -option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) -if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) - set(CMAKE_CXX_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) -endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - -option(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) -endif(SC_ENABLE_TESTING) +if(NOT SC_IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}") +else(NOT SC_IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}") +endif(NOT SC_IS_SUBBUILD) -# TODO - BRL-CAD is the only known user of this option, and it will be -# transitioning to a new setup that won't need it - once that's done, -# we should just remove this option. -option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) -mark_as_advanced(SC_SKIP_EXEC_INSTALL) +# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc +include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc -include(SC_Targets) +include(${SC_CMAKE_DIR}/SC_Targets.cmake) # Macros related to paths -include(SC_Paths) +include(${SC_CMAKE_DIR}/SC_Paths.cmake) # locale stuff -include(SC_Locale) +include(${SC_CMAKE_DIR}/SC_Locale.cmake) # logic related to regenerating the lexer and parser source code -include(SC_Regenerate) - -# create config headers sc_cf.h and sc_version_string.h -include(SC_Config_Headers) +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") @@ -167,8 +88,8 @@ 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") + #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(NOT SC_IS_SUBBUILD) @@ -178,18 +99,23 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -# create config headers sc_cf.h -include(SC_Config_Headers) +# create config headers sc_cf.h and sc_version_string.h +include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) ################ +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 11) + if(MSVC) # 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) -endif() -if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") +else() add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) + if(HAVE_NULLPTR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif(HAVE_NULLPTR) endif() include_directories( @@ -214,19 +140,13 @@ if(SC_ENABLE_TESTING) endif(SC_ENABLE_TESTING) add_subdirectory(doc) -if(NOT SC_IS_SUBBUILD) - #----------------------------------------------------------------------------- - # 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 ") - include(CPack) -endif(NOT SC_IS_SUBBUILD) - +# 'make core' builds everything that isn't generated. for devs. +add_custom_target(core) +if($CACHE{SC_BUILD_SHARED_LIBS}) + add_dependencies(core stepdai stepeditor exp2cxx check-express) +else() + add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) +endif() # 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. diff --git a/README.md b/README.md index e34c4c2ef..4df78fd0d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Linux, OSX (LLVM) | Windows (MSVC) [![Build Status](https://travis-ci.org/stepcode/stepcode.svg?branch=master)](https://travis-ci.org/stepcode/stepcode) | [![Build status](https://ci.appveyor.com/api/projects/status/3fbr9t9gfa812oqu?svg=true)](https://ci.appveyor.com/project/mpictor/stepcode) *********************************************************************** -STEPcode v0.9 -- 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 @@ -36,16 +36,14 @@ CODING STANDARDS SC's source has been reformatted with astyle. When making changes, try to match the current formatting. The main points are: - - K&R (Kernighan & Ritchie) brackets: + - compact (java-style) brackets: ```C - int Foo(bool isBar) - { - if (isBar) { - bar(); - return 1; - } else - return 0; - } + if( a == 3 ) { + c = 5; + function( a, b ); + } else { + somefunc( ); + } ``` - indents are 4 spaces - no tab characters diff --git a/SC_VERSION.txt b/SC_VERSION.txt new file mode 100644 index 000000000..aec258df7 --- /dev/null +++ b/SC_VERSION.txt @@ -0,0 +1 @@ +0.8 diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index ebd7af001..19aa0d500 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,35 +44,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -set(_LEMON_SEARCHES) - -# Search LEMON_ROOT first if it is set. -if(LEMON_ROOT) - set(_LEMON_SEARCH_ROOT PATHS ${LEMON_ROOT} NO_DEFAULT_PATH) - list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_ROOT) -endif() - -# Normal search. -set(_LEMON_x86 "(x86)") -set(_LEMON_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/lemon" - "$ENV{ProgramFiles${_LEMON_x86}}/lemon") -unset(_LEMON_x86) -list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_NORMAL) - -set(LEMON_NAMES lemon) - -# Try each search configuration. -foreach(search ${_LEMON_SEARCHES}) - find_program(LEMON_EXECUTABLE lemon ${${search}} PATH_SUFFIXES bin) -endforeach() +find_program(LEMON_EXECUTABLE lemon DOC "path to the lemon executable") mark_as_advanced(LEMON_EXECUTABLE) -foreach(search ${_LEMON_SEARCHES}) - find_file(LEMON_TEMPLATE lempar.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/lemon) -endforeach() -mark_as_advanced(LEMON_TEMPLATE) - if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) # look for the template in share if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") @@ -139,10 +113,6 @@ if(NOT COMMAND LEMON_TARGET) CMAKE_PARSE_ARGUMENTS(${LVAR_PREFIX} "" "OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR;EXTRA_ARGS" "" ${ARGN}) endif(${ARGC} GREATER 3) - if (TARGET perplex_stage) - set(DEPS_TARGET perplex_stage) - endif (TARGET perplex_stage) - # Need a working directory if("${${LVAR_PREFIX}_WORKING_DIR}" STREQUAL "") set(${LVAR_PREFIX}_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LVAR_PREFIX}") @@ -191,7 +161,7 @@ if(NOT COMMAND LEMON_TARGET) OUTPUT ${LEMON_GEN_OUT} ${LEMON_GEN_SOURCE} ${LEMON_GEN_HEADER} COMMAND ${CMAKE_COMMAND} -E copy ${lemon_in_file} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} ${${LVAR_PREFIX}__EXTRA_ARGS} - DEPENDS ${Input} ${LEMON_EXECUTABLE_TARGET} ${DEPS_TARGET} + DEPENDS ${Input} ${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${LVAR_PREFIX}_WORKING_DIR} COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" ) @@ -201,7 +171,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${${LVAR_PREFIX}_OUT_SRC_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ${DEPS_TARGET} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_SRC_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "${LEMON_GEN_SOURCE}") @@ -209,7 +179,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_HDR_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${${LVAR_PREFIX}_OUT_HDR_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ${DEPS_TARGET} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_HDR_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "${LEMON_GEN_HEADER}") diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index d1482d67c..22d632032 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,35 +44,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -set(_PERPLEX_SEARCHES) - -# Search PERPLEX_ROOT first if it is set. -if(PERPLEX_ROOT) - set(_PERPLEX_SEARCH_ROOT PATHS ${PERPLEX_ROOT} NO_DEFAULT_PATH) - list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_ROOT) -endif() - -# Normal search. -set(_PERPLEX_x86 "(x86)") -set(_PERPLEX_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/perplex" - "$ENV{ProgramFiles${_PERPLEX_x86}}/perplex") -unset(_PERPLEX_x86) -list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_NORMAL) - -set(PERPLEX_NAMES perplex) - -# Try each search configuration. -foreach(search ${_PERPLEX_SEARCHES}) - find_program(PERPLEX_EXECUTABLE perplex ${${search}} PATH_SUFFIXES bin) -endforeach() +find_program(PERPLEX_EXECUTABLE perplex DOC "path to the perplex executable") mark_as_advanced(PERPLEX_EXECUTABLE) -foreach(search ${_PERPLEX_SEARCHES}) - find_file(PERPLEX_TEMPLATE perplex_template.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/perplex) -endforeach() -mark_as_advanced(PERPLEX_TEMPLATE) - if(PERPLEX_EXECUTABLE AND NOT PERPLEX_TEMPLATE) get_filename_component(perplex_path ${PERPLEX_EXECUTABLE} PATH) if(perplex_path) @@ -122,7 +96,7 @@ mark_as_advanced(PERPLEX_TEMPLATE) # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -167,10 +141,6 @@ if(NOT COMMAND PERPLEX_TARGET) get_filename_component(IN_FILE_WE ${Input} NAME_WE) set(PVAR_PREFIX ${Name}_${IN_FILE_WE}) - if (TARGET perplex_stage) - set(DEP_TARGET perplex_stage) - endif (TARGET perplex_stage) - if(${ARGC} GREATER 3) CMAKE_PARSE_ARGUMENTS(${PVAR_PREFIX} "" "TEMPLATE;OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR" "" ${ARGN}) endif(${ARGC} GREATER 3) @@ -230,7 +200,7 @@ if(NOT COMMAND PERPLEX_TARGET) OUTPUT ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${perplex_in_file} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${PERPLEX_EXECUTABLE} -c -o ${re2c_src} -i ${${PVAR_PREFIX}_OUT_HDR_FILE} -t ${${PVAR_PREFIX}_TEMPLATE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} - DEPENDS ${Input} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${${PVAR_PREFIX}_TEMPLATE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[PERPLEX][${Name}] Generating re2c input with ${PERPLEX_EXECUTABLE}" ) @@ -239,7 +209,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-debug-info --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) @@ -247,7 +217,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) diff --git a/cmake/FindRE2C.cmake b/cmake/FindRE2C.cmake index 2b3a9492b..5450c34a9 100644 --- a/cmake/FindRE2C.cmake +++ b/cmake/FindRE2C.cmake @@ -3,29 +3,7 @@ # #============================================================================= -set(_RE2C_SEARCHES) - -# Search RE2C_ROOT first if it is set. -if(RE2C_ROOT) - set(_RE2C_SEARCH_ROOT PATHS ${RE2C_ROOT} NO_DEFAULT_PATH) - list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_ROOT) -endif() - -# Normal search. -set(_RE2C_x86 "(x86)") -set(_RE2C_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/re2c" - "$ENV{ProgramFiles${_RE2C_x86}}/re2c") -unset(_RE2C_x86) -list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_NORMAL) - -set(RE2C_NAMES re2c) - -# Try each search configuration. -foreach(search ${_RE2C_SEARCHES}) - find_program(RE2C_EXECUTABLE re2c ${${search}} PATH_SUFFIXES bin) -endforeach() - +find_program(RE2C_EXECUTABLE re2c DOC "path to the re2c executable") mark_as_advanced(RE2C_EXECUTABLE) include(FindPackageHandleStandardArgs) @@ -64,7 +42,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(RE2C DEFAULT_MSG RE2C_EXECUTABLE) # ==================================================================== # #============================================================================= -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel diff --git a/cmake/Generated_Source_Utils.cmake b/cmake/Generated_Source_Utils.cmake new file mode 100644 index 000000000..601f92364 --- /dev/null +++ b/cmake/Generated_Source_Utils.cmake @@ -0,0 +1,67 @@ +# Utility routines for managing generated files with CMake + +macro(MD5 filename md5sum) + file(READ "${filename}" RAW_MD5_FILE) + string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}") + string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}") +endmacro(MD5) + +macro(FILEVAR filename var) + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${var} ${filename}) +endmacro(FILEVAR) + +macro(VERIFY_FILES filelist warn resultvar) + set(${resultvar} 1) + foreach(fileitem ${filelist}) + # Deal with absolute and relative paths a bit differently + get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) + if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${fileitem}") + else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") + endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + get_filename_component(filename "${fileitem}" NAME) + # Got filename components sorted - proceed + if(NOT EXISTS ${filefullname}) + message(FATAL_ERROR "Attempted to verify non-existant file ${filefullname}") + endif(NOT EXISTS ${filefullname}) + FILEVAR(${filename} filevar) + if(NOT baseline_${filevar}_md5) + message(FATAL_ERROR "No baseline MD5 available for ${filename} - baseline_${filevar}_md5 is not defined") + endif(NOT baseline_${filevar}_md5) + MD5(${filefullname} ${filevar}_md5) + if(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") + if("${warn}" STREQUAL "1") + message("\n${filename} differs from baseline: baseline md5 hash is ${baseline_${filevar}_md5} and current hash is ${${filevar}_md5}\n") + endif("${warn}" STREQUAL "1") + set(${resultvar} 0) + endif(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") + endforeach(fileitem ${filelist}) +endmacro(VERIFY_FILES filelist resultvar) + +macro(WRITE_MD5_SUMS filelist outfile) + foreach(fileitem ${filelist}) + # Deal with absolute and relative paths a bit differently + get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) + if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${fileitem}") + else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") + endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + get_filename_component(filename "${fileitem}" NAME) + # Got filename components sorted - proceed + if(NOT EXISTS ${filefullname}) + message(FATAL_ERROR "Attempted to get MD5 sum of non-existant file ${filefullname}") + endif(NOT EXISTS ${filefullname}) + FILEVAR(${filename} filevar) + MD5(${filefullname} ${filevar}_md5) + file(APPEND ${outfile} "set(baseline_${filevar}_md5 ${${filevar}_md5})\n") + endforeach(fileitem ${filelist}) +endmacro(WRITE_MD5_SUMS) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/Path_Setup.cmake b/cmake/Path_Setup.cmake deleted file mode 100644 index f5db3b411..000000000 --- a/cmake/Path_Setup.cmake +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright (c) 2010-2020 United States Government as represented by -# the U.S. Army Research Laboratory. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. 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. -# -# 3. The name of the author may not be used to endorse or promote -# products derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS -# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -#--------------------------------------------------------------------- -# Define relative install locations. Don't set these if they have already -# been set by some other means (like a higher level CMakeLists.txt file -# including this one). - -# The location in which to install BRL-CAD executables. -if(NOT BIN_DIR) - set(BIN_DIR bin) -endif(NOT BIN_DIR) - -# Define a relative path that will "reset" a path back to -# the point before BIN_DIR was appended. This is primarily -# useful when working with generator expressions -unset(RBIN_DIR CACHE) -set(LBIN_DIR "${BIN_DIR}") -while (NOT "${LBIN_DIR}" STREQUAL "") - get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY) - set(LBIN_DIR "${LBDIR}") - if ("${RBIN_DIR}" STREQUAL "") - set(RBIN_DIR "..") - else ("${RBIN_DIR}" STREQUAL "") - set(RBIN_DIR "../${RBIN_DIR}") - endif ("${RBIN_DIR}" STREQUAL "") -endwhile (NOT "${LBIN_DIR}" STREQUAL "") - -# The location in which to install BRL-CAD libraries. -if(NOT LIB_DIR) - set(LIB_DIR lib) -endif(NOT LIB_DIR) -if(NOT LIBEXEC_DIR) - set(LIBEXEC_DIR libexec) -endif(NOT LIBEXEC_DIR) - -# The location in which to install BRL-CAD header files. -if(NOT INCLUDE_DIR) - set(INCLUDE_DIR include) -endif(NOT INCLUDE_DIR) - -# The location in which to install BRL-CAD data files -if(NOT DATA_DIR) - set(DATA_DIR share) -endif(NOT DATA_DIR) - -# The location in which to install BRL-CAD documentation files -if(NOT DOC_DIR) - set(DOC_DIR ${DATA_DIR}/doc) -endif(NOT DOC_DIR) - -# The location in which to install BRL-CAD Manual pages -if(NOT MAN_DIR) - set(MAN_DIR ${DATA_DIR}/man) -endif(NOT MAN_DIR) - -# Make sure no absolute paths have been supplied to these variables -set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC) -foreach(instdir ${INSTALL_DIRS}) - get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE) - if("${${instdir}_DIR}" STREQUAL "${instdir_full}") - message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"") - set(HAVE_INSTALL_DIR_FULL_PATH 1) - endif("${${instdir}_DIR}" STREQUAL "${instdir_full}") -endforeach(instdir ${INSTALL_DIRS}) - -#--------------------------------------------------------------------- -# Output directories - this is where built library and executable -# files will be placed after building but prior to install. The -# necessary variables change between single and multi configuration -# build systems, so it is necessary to handle both cases on a -# conditional basis. - -if(NOT CMAKE_CONFIGURATION_TYPES) - # If we're not doing multi-configuration, just set the three main - # variables to the correct values. - if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") - endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) -else(NOT CMAKE_CONFIGURATION_TYPES) - # Multi-configuration is more difficult. Not only do we need to - # properly set the output directories, but we also need to - # identify the "toplevel" directory for each configuration so - # we can place files, documentation, etc. in the correct - # relative positions. Because files may be placed by CMake - # without a build target to put them in their proper relative build - # directory position using these paths, we must fully qualify them - # without using CMAKE_CFG_INTDIR. - # - # We define directories that may not be quite "standard" - # for a particular build tool - for example, native VS2010 projects use - # another directory to denote CPU type being compiled for - but CMake only - # supports multi-configuration setups having multiple configurations, - # not multiple compilers. - # - # One additional wrinkle we must watch for here is the case where - # a multi-configuration setup uses "." for its internal directory - - # if that's the case, we need to just set the various config output - # directories to the same value. - set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}) - foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") - set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE}) - endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") - string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) - if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") - endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") - endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") - endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) - set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") - endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) - if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) - set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") - endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) - endforeach() -endif(NOT CMAKE_CONFIGURATION_TYPES) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake new file mode 100644 index 000000000..8ca942615 --- /dev/null +++ b/cmake/SC_Build_opts.cmake @@ -0,0 +1,176 @@ +# BIN and LIB directories +if(NOT DEFINED BIN_DIR) + set(BIN_DIR bin) +endif(NOT DEFINED BIN_DIR) + +if(NOT DEFINED LIB_DIR) + set(LIB_DIR lib) +endif(NOT DEFINED LIB_DIR) + +# 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) + +# Should we use C++11? +OPTION_WITH_DEFAULT(SC_ENABLE_CXX11 "Build with C++ 11 features" ON) + +# Get version from git +OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON) + +option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) +mark_as_advanced(SC_BUILD_EXPRESS_ONLY) + +option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) +mark_as_advanced(DEBUGGING_GENERATED_SOURCES) + +#--------------------------------------------------------------------- +# 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 ${SC_BUILD_EXPRESS_ONLY} AND NOT DEFINED SC_BUILD_SCHEMAS) + set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified + endif() + include(CTest) +endif(SC_ENABLE_TESTING) + +#--------------------------------------------------------------------- +# Executable install option +OPTION_WITH_DEFAULT(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) +if(SC_SKIP_EXEC_INSTALL) + set(SC_EXEC_NOINSTALL "NO_INSTALL") +endif(SC_SKIP_EXEC_INSTALL) + +#--------------------------------------------------------------------- +# 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 ") + 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 + diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 016450c2c..388d820a5 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -28,8 +28,10 @@ endmacro(P21_TESTS sfile) macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) + #add_dependencies(p21read_${PROJECT_NAME} version_string) if(NOT WIN32) SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) + #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) #add user-defined executables @@ -37,6 +39,7 @@ macro(SCHEMA_EXES) get_filename_component(name ${src} NAME_WE) get_filename_component(path ${src} ABSOLUTE) SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${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) @@ -93,7 +96,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ${SC_SOURCE_DIR}/src/base/judy/src ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation - if(BUILD_SHARED_LIBS) + if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) if(WIN32) @@ -102,12 +105,6 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj") endif() endif() - # TODO - ideally we would avoid generating code that triggers this warning, but figuring out - # how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings - # we get due to this issue so it doesn't mask other problems. - if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers") - endif() endif() if($CACHE{SC_BUILD_STATIC_LIBS}) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index f9a8cc86b..17d0c2774 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,4 +1,23 @@ -# create sc_cf.h +# 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) @@ -78,8 +97,36 @@ int main() {return !(f() == f());} endif(SC_ENABLE_CXX11) # Now that all the tests are done, configure the sc_cf.h file: -configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) +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. +if(SC_GIT_VERSION) + 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 + 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 +else(SC_GIT_VERSION) + set(VER_HDR " + #ifndef SC_VERSION_STRING + #define SC_VERSION_STRING + static char sc_version[512] = {\"${SC_VERSION}\"}; + #endif" + ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") +endif(SC_GIT_VERSION) +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 diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index cb2d11dd6..09204146c 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -46,11 +46,7 @@ macro(SC_ADDLIB _addlib_target) if(${_arg_prefix}_SHARED) add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES}) - if(OPENBSD) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) - else(OPENBSD) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) - endif(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION}) if(APPLE) set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") endif(APPLE) diff --git a/cmake/md5_gen.cmake.in b/cmake/md5_gen.cmake.in new file mode 100644 index 000000000..9d664baa0 --- /dev/null +++ b/cmake/md5_gen.cmake.in @@ -0,0 +1,35 @@ +# Inherit the parent CMake setting +set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) +set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) + +# Define a variety of convenience routines +include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake) + +# The following steps are executed to sync generated sources: +# +# 1. Create a new verification_info.cmake file and populate +# it with the MD5 sums for current files. +# +# 2. Overwrite the original cached verification_info.cmake +# and generated files with the new ones. If LOCKED_SOURCE_DIR +# is ON, this step will not be carried out - instead, an +# informational message with manual updating instructions +# will be printed. + +set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake") + + +file(WRITE ${new_info_file} "# Autogenerated verification information\n") + +# Handle input files +set(input_files "@MD5_FILELIST@") +WRITE_MD5_SUMS("${input_files}" "${new_info_file}") + +message("New verification file created: ${new_info_file}") + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/md5_verify.cmake.in b/cmake/md5_verify.cmake.in new file mode 100644 index 000000000..5eb105337 --- /dev/null +++ b/cmake/md5_verify.cmake.in @@ -0,0 +1,30 @@ +# Inherit the parent CMake setting +set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@) +set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") + +# Include the file the provides the baseline against which +# current files will be compared + + include("@BASELINE_INFORMATION_FILE@") + + # Define a variety of convenience routines + include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake") + + # Individually verify all of the files in question. + set(filelist "@MD5_FILELIST@") + VERIFY_FILES("${filelist}" 1 srcs_pass) + if(NOT srcs_pass) + if(NOT DEBUGGING_GENERATED_SOURCES) + message(FATAL_ERROR "Sources have been modified and md5 sums have not been updated. This generally indicates either\n a) an input file has been modified but generated files have not been updated, or\n b) genenerated files have been edited directly.\nTo clear the error:\n a) Copy the new generated sources from the build directory to the generated/ sources directory, use the _md5gen build target to create a new verifictation_info.cmake file, and copy verfication_info.cmake to generated/ as well.\n b) install Perplex/Re2C/LEMON and make the changes to the input file rather than the generated file.\nNote:\n If this is a debugging situation where multiple sequential tests must be conducted, temporarily set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure to disable this check.\nThis measure is necessary to ensure that compilations using either Perplex/Re2C/LEMON generation or the cached outputs of those tools produce consistent results.") + else(NOT DEBUGGING_GENERATED_SOURCES) + message(WARNING "Note: Sources have been modified and md5 sums have not been updated - build failure condition temporarily overridden by DEBUGGING_GENERATED_SOURCES setting.") + endif(NOT DEBUGGING_GENERATED_SOURCES) + endif(NOT srcs_pass) + + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake new file mode 100644 index 000000000..ed53ac27e --- /dev/null +++ b/cmake/sc_version_string.cmake @@ -0,0 +1,84 @@ +# creates sc_version_string.h, which defines sc_version() +# sc_version() returns a pretty commit description and a build timestamp. + +# only update the file if the git commit has changed, because whenever the file is updated files including the header must rebuild +# parallel rebuilds can result in race conditions and failures, particularly when running ctest in parallel + +# http://stackoverflow.com/questions/3780667 +# http://www.cmake.org/pipermail/cmake/2009-February/027014.html + +set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") +set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@") + +set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h") + +#---------- find commit id ------------------ +#use git for a pretty commit id +#uses 'git describe --tags', so tags are required in the repo +#create a tag with 'git tag ' 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) + if(NOT SC_IS_SUBBUILD) + message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.") + endif(NOT SC_IS_SUBBUILD) + 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) +endif() +string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) + +#-------------- date and time --------------- + +if(SC_ENABLE_TESTING) + set (date_time_string "NA - disabled for testing") +else() + string(TIMESTAMP date_time_string UTC) +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" + ) + +#don't update the file unless something changed +string(RANDOM tmpsuffix) +file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) +execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix}) + +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 diff --git a/cmake/schema_scanner/README b/cmake/schema_scanner/README index eabd37087..8e0996f29 100644 --- a/cmake/schema_scanner/README +++ b/cmake/schema_scanner/README @@ -1,14 +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. +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. +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. diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index affe5c5cc..0c345d931 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -71,9 +71,9 @@ message( STATUS "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_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_INSTALL_DIR}) else(WIN32) - install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR}) endif(WIN32) # macro SCHEMA_CMLIST diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index d4452117b..819403e6f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,7 +10,7 @@ # .exp file inside, which it uses. otherwise, ${path} is assumed to # be an express file. -if(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +if(NOT ${SC_BUILD_EXPRESS_ONLY} AND 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) diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index f1fccb2ea..624ca44a4 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -14,14 +14,14 @@ if(NOT DEFINED STEPCODE_ROOT_DIR) endif(NOT DEFINED STEPCODE_ROOT_DIR) # STEPCODE_ROOT_DIR is relative or absolute path? -if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") +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}/src/express/express.c") + 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}/src/express/express.c") -endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") + 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. diff --git a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake index 96fca295b..62df14322 100644 --- a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake +++ b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake @@ -22,3 +22,8 @@ ENDIF() SET( STEPCODE_BINARY_DIR ${BINARY_DIR} ) +# SC CMake does not honor -DCMAKE_INSTALL_PREFIX:PATH= +# Consequently, force Debug so it installs in ../sc-install directory +# instead of /usr/local/lib. +# +# SC's own programs fail to build with -DSC_BUILD_SHARED_LIBS=OFF \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index da3ae5eb5..566c3780d 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,21 +22,22 @@ set(express_HDRS express/variable.h ) install(FILES ${express_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/express) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express) set(exppp_HDRS exppp/exppp.h ) install(FILES ${exppp_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/exppp) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp) install(FILES ordered_attrs.h sc_export.h sc_stdbool.h - DESTINATION ${INCLUDE_DIR}/stepcode) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode) -install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h - DESTINATION ${INCLUDE_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) # Local Variables: # tab-width: 8 diff --git a/include/exppp/exppp.h b/include/exppp/exppp.h index 1e7e78cc7..f6159cbf5 100644 --- a/include/exppp/exppp.h +++ b/include/exppp/exppp.h @@ -15,56 +15,56 @@ extern SC_EXPPP_EXPORT int exppp_linelength; /**< leave some slop extern SC_EXPPP_EXPORT bool exppp_alphabetize; /**< if true, alphabetize */ extern SC_EXPPP_EXPORT bool exppp_terse; /**< don't describe action to stdout */ extern SC_EXPPP_EXPORT bool exppp_reference_info; /**< if true, add commentary about where things came from */ -extern SC_EXPPP_EXPORT char *exppp_output_filename; /**< force output filename */ +extern SC_EXPPP_EXPORT char * exppp_output_filename; /**< force output filename */ extern SC_EXPPP_EXPORT bool exppp_output_filename_reset; /**< if true, force output filename */ extern SC_EXPPP_EXPORT bool exppp_print_to_stdout; /**< if true, print to stdout */ extern SC_EXPPP_EXPORT bool exppp_aggressively_wrap_consts; /**< for constants, print one item per line */ extern SC_EXPPP_EXPORT bool exppp_tail_comment; /**< print tail comment, such as END_ENTITY; --entity_name */ -SC_EXPPP_EXPORT void EXPRESSout(Express e); +SC_EXPPP_EXPORT void EXPRESSout( Express e ); -SC_EXPPP_EXPORT void ENTITYout(Entity e); -SC_EXPPP_EXPORT void EXPRout(Expression expr); -SC_EXPPP_EXPORT void FUNCout(Function f); -SC_EXPPP_EXPORT void PROCout(Procedure p); -SC_EXPPP_EXPORT void RULEout(Rule r); -SC_EXPPP_EXPORT char *SCHEMAout(Schema s); -SC_EXPPP_EXPORT void SCHEMAref_out(Schema s); -SC_EXPPP_EXPORT void STMTout(Statement s); -SC_EXPPP_EXPORT void TYPEout(Type t); -SC_EXPPP_EXPORT void TYPEhead_out(Type t); -SC_EXPPP_EXPORT void TYPEbody_out(Type t); -SC_EXPPP_EXPORT void WHEREout(Linked_List w); +SC_EXPPP_EXPORT void ENTITYout( Entity e ); +SC_EXPPP_EXPORT void EXPRout( Expression expr ); +SC_EXPPP_EXPORT void FUNCout( Function f ); +SC_EXPPP_EXPORT void PROCout( Procedure p ); +SC_EXPPP_EXPORT void RULEout( Rule r ); +SC_EXPPP_EXPORT char * SCHEMAout( Schema s ); +SC_EXPPP_EXPORT void SCHEMAref_out( Schema s ); +SC_EXPPP_EXPORT void STMTout( Statement s ); +SC_EXPPP_EXPORT void TYPEout( Type t ); +SC_EXPPP_EXPORT void TYPEhead_out( Type t ); +SC_EXPPP_EXPORT void TYPEbody_out( Type t ); +SC_EXPPP_EXPORT void WHEREout( Linked_List w ); -SC_EXPPP_EXPORT char *REFto_string(Dictionary refdict, Linked_List reflist, char *type, int level); -SC_EXPPP_EXPORT char *ENTITYto_string(Entity e); -SC_EXPPP_EXPORT char *SUBTYPEto_string(Expression e); -SC_EXPPP_EXPORT char *EXPRto_string(Expression expr); -SC_EXPPP_EXPORT char *FUNCto_string(Function f); -SC_EXPPP_EXPORT char *PROCto_string(Procedure p); -SC_EXPPP_EXPORT char *RULEto_string(Rule r); -SC_EXPPP_EXPORT char *SCHEMAref_to_string(Schema s); -SC_EXPPP_EXPORT char *STMTto_string(Statement s); -SC_EXPPP_EXPORT char *TYPEto_string(Type t); -SC_EXPPP_EXPORT char *TYPEhead_to_string(Type t); -SC_EXPPP_EXPORT char *TYPEbody_to_string(Type t); -SC_EXPPP_EXPORT char *WHEREto_string(Linked_List w); +SC_EXPPP_EXPORT char * REFto_string( Dictionary refdict, Linked_List reflist, char * type, int level ); +SC_EXPPP_EXPORT char * ENTITYto_string( Entity e ); +SC_EXPPP_EXPORT char * SUBTYPEto_string( Expression e ); +SC_EXPPP_EXPORT char * EXPRto_string( Expression expr ); +SC_EXPPP_EXPORT char * FUNCto_string( Function f ); +SC_EXPPP_EXPORT char * PROCto_string( Procedure p ); +SC_EXPPP_EXPORT char * RULEto_string( Rule r ); +SC_EXPPP_EXPORT char * SCHEMAref_to_string( Schema s ); +SC_EXPPP_EXPORT char * STMTto_string( Statement s ); +SC_EXPPP_EXPORT char * TYPEto_string( Type t ); +SC_EXPPP_EXPORT char * TYPEhead_to_string( Type t ); +SC_EXPPP_EXPORT char * TYPEbody_to_string( Type t ); +SC_EXPPP_EXPORT char * WHEREto_string( Linked_List w ); -SC_EXPPP_EXPORT int REFto_buffer(Dictionary refdict, Linked_List reflist, char *type, int level, char *buffer, int length); -SC_EXPPP_EXPORT int ENTITYto_buffer(Entity e, char *buffer, int length); -SC_EXPPP_EXPORT int EXPRto_buffer(Expression e, char *buffer, int length); -SC_EXPPP_EXPORT int FUNCto_buffer(Function e, char *buffer, int length); -SC_EXPPP_EXPORT int PROCto_buffer(Procedure e, char *buffer, int length); -SC_EXPPP_EXPORT int RULEto_buffer(Rule e, char *buffer, int length); -SC_EXPPP_EXPORT int SCHEMAref_to_buffer(Schema s, char *buffer, int length); -SC_EXPPP_EXPORT int STMTto_buffer(Statement s, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEto_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEhead_to_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEbody_to_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int WHEREto_buffer(Linked_List w, char *buffer, int length); +SC_EXPPP_EXPORT int REFto_buffer( Dictionary refdict, Linked_List reflist, char * type, int level, char * buffer, int length ); +SC_EXPPP_EXPORT int ENTITYto_buffer( Entity e, char * buffer, int length ); +SC_EXPPP_EXPORT int EXPRto_buffer( Expression e, char * buffer, int length ); +SC_EXPPP_EXPORT int FUNCto_buffer( Function e, char * buffer, int length ); +SC_EXPPP_EXPORT int PROCto_buffer( Procedure e, char * buffer, int length ); +SC_EXPPP_EXPORT int RULEto_buffer( Rule e, char * buffer, int length ); +SC_EXPPP_EXPORT int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); +SC_EXPPP_EXPORT int STMTto_buffer( Statement s, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEto_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEhead_to_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEbody_to_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int WHEREto_buffer( Linked_List w, char * buffer, int length ); -SC_EXPPP_EXPORT int EXPRlength(Expression e); -extern SC_EXPPP_EXPORT void tail_comment(const char *name); -extern SC_EXPPP_EXPORT int count_newlines(char *s); +SC_EXPPP_EXPORT int EXPRlength( Expression e ); +extern SC_EXPPP_EXPORT void tail_comment( const char * name ); +extern SC_EXPPP_EXPORT int count_newlines( char * s ); #endif diff --git a/include/express/alg.h b/include/express/alg.h index 20b2891a7..bc76c5ddd 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -50,10 +50,10 @@ /* typedefs */ /************/ -typedef struct Scope_ *Procedure; -typedef struct Scope_ *Function; -typedef struct Scope_ *Rule; -typedef struct Where_ *Where; +typedef struct Scope_ * Procedure; +typedef struct Scope_ * Function; +typedef struct Scope_ * Rule; +typedef struct Where_ * Where; /***************************/ /* hidden type definitions */ @@ -63,13 +63,13 @@ typedef struct Where_ *Where; * As each (real) call is resolved, the tag->type is temporarily borrowed */ struct tag { - char *name; + char * name; Type type; }; /** location of fulltext of algorithm in source file */ struct FullText { - const char *filename; + const char * filename; unsigned int start, end; }; @@ -101,7 +101,7 @@ struct Rule_ { /** define a where clause */ struct Where_ { - Symbol *label; + Symbol * label; Expression expr; }; @@ -161,8 +161,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Scope ALGcreate(char); -extern SC_EXPRESS_EXPORT void ALGinitialize(void); -extern SC_EXPRESS_EXPORT void ALGput_full_text(Scope, int, int); +extern SC_EXPRESS_EXPORT Scope ALGcreate( char ); +extern SC_EXPRESS_EXPORT void ALGinitialize( void ); +extern SC_EXPRESS_EXPORT void ALGput_full_text( Scope, int, int ); #endif /* ALGORITHM_H */ diff --git a/include/express/alloc.h b/include/express/alloc.h index 11a476878..79199773a 100644 --- a/include/express/alloc.h +++ b/include/express/alloc.h @@ -35,7 +35,7 @@ typedef long Align; union freelist { - union freelist *next; /**< next block on freelist */ + union freelist * next; /**< next block on freelist */ char memory; /**< user data */ Align aligner; /**< force alignment of blocks */ }; @@ -52,13 +52,13 @@ struct freelist_head { #endif int size; /**< size of a single elt incl. next ptr */ int bytes; /**< if we run out, allocate memory by this many bytes */ - Freelist *freelist; + Freelist * freelist; #ifdef SPACE_PROFILE int count; #endif }; -char *nnew(); +char * nnew(); #include "error.h" @@ -75,10 +75,10 @@ extern SC_EXPRESS_EXPORT int yylineno; fprintf(stderr,"fedex: out of space");\ } else {} -SC_EXPRESS_EXPORT void _ALLOCinitialize(void); -SC_EXPRESS_EXPORT void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2); -SC_EXPRESS_EXPORT void ALLOC_destroy(struct freelist_head *, Freelist *); -SC_EXPRESS_EXPORT void *ALLOC_new(struct freelist_head *); +SC_EXPRESS_EXPORT void _ALLOCinitialize( void ); +SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); +SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * ); +SC_EXPRESS_EXPORT void * ALLOC_new( struct freelist_head * ); #endif /* ALLOC_H */ diff --git a/include/express/basic.h b/include/express/basic.h index 6e348c586..2dffecf3c 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -93,8 +93,8 @@ /* function pointer types */ /**************************/ -typedef void (*voidFuncptr)(); -typedef int (*intFuncptr)(); +typedef void ( *voidFuncptr )(); +typedef int ( *intFuncptr )(); #endif /* BASIC_H */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index ff422ad78..1c75f55bd 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -48,7 +48,7 @@ /* typedefs */ /************/ -typedef struct Case_Item_ *Case_Item; +typedef struct Case_Item_ * Case_Item; /****************/ /* modules used */ @@ -63,7 +63,7 @@ typedef struct Case_Item_ *Case_Item; struct Case_Item_ { Symbol symbol; Linked_List labels; - struct Statement_ *action; + struct Statement_ * action; }; /********************/ @@ -86,7 +86,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; #define CASE_IT_new() (struct Case_Item_ *)ALLOC_new(&CASE_IT_fl) #define CASE_IT_destroy(x) ALLOC_destroy(&CASE_IT_fl,(Freelist *)x) -extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate(Linked_List, struct Statement_ *); -extern SC_EXPRESS_EXPORT void CASE_ITinitialize(void); +extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); +extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); #endif /*CASE_ITEM_H*/ diff --git a/include/express/dict.h b/include/express/dict.h index d22f4c33c..f289ecca3 100644 --- a/include/express/dict.h +++ b/include/express/dict.h @@ -55,7 +55,7 @@ /* typedefs */ /************/ -typedef struct Hash_Table_ *Dictionary; +typedef struct Hash_Table_ * Dictionary; typedef HashEntry DictionaryEntry; /****************/ @@ -97,14 +97,14 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void DICTinitialize(void); -extern SC_EXPRESS_EXPORT void DICTcleanup(void); -extern SC_EXPRESS_EXPORT int DICTdefine(Dictionary, char *, void *, Symbol *, char); -extern SC_EXPRESS_EXPORT int DICT_define(Dictionary, char *, void *, Symbol *, char); -extern SC_EXPRESS_EXPORT void DICTundefine(Dictionary, char *); -extern SC_EXPRESS_EXPORT void *DICTlookup(Dictionary, char *); -extern SC_EXPRESS_EXPORT void *DICTlookup_symbol(Dictionary, char *, Symbol **); -extern SC_EXPRESS_EXPORT void *DICTdo(DictionaryEntry *); -extern SC_EXPRESS_EXPORT void DICTprint(Dictionary); +extern SC_EXPRESS_EXPORT void DICTinitialize( void ); +extern SC_EXPRESS_EXPORT void DICTcleanup( void ); +extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, void *, Symbol *, char ); +extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, void *, Symbol *, char ); +extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * ); +extern SC_EXPRESS_EXPORT void * DICTlookup( Dictionary, char * ); +extern SC_EXPRESS_EXPORT void * DICTlookup_symbol( Dictionary, char *, Symbol ** ); +extern SC_EXPRESS_EXPORT void * DICTdo( DictionaryEntry * ); +extern SC_EXPRESS_EXPORT void DICTprint( Dictionary ); #endif /*DICTIONARY_H*/ diff --git a/include/express/entity.h b/include/express/entity.h index 4c26c1c88..3440dc9bc 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -69,7 +69,7 @@ /* typedefs */ /************/ -typedef struct Scope_ *Entity; +typedef struct Scope_ * Entity; /****************/ /* modules used */ @@ -140,19 +140,19 @@ extern SC_EXPRESS_EXPORT int ENTITY_MARK; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcreate(struct Symbol_ *); -extern SC_EXPRESS_EXPORT void ENTITYinitialize(void); -extern SC_EXPRESS_EXPORT void ENTITYadd_attribute(struct Scope_ *, struct Variable_ *); -extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcopy(struct Scope_ *); -extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity(struct Scope_ *, char *, int); -extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute(struct Scope_ *, char *, struct Symbol_ **); -extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref(Entity, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype(Entity, Entity); -extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute(Entity, char *); -extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes(Entity); -extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype(Entity, Entity); -extern SC_EXPRESS_EXPORT void ENTITYadd_instance(Entity, void *); -extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset(Entity); -extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable(Entity, struct Variable_ *); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT void ENTITYinitialize( void ); +extern SC_EXPRESS_EXPORT void ENTITYadd_attribute( struct Scope_ *, struct Variable_ * ); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy( struct Scope_ * ); +extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, char *, int ); +extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute( struct Scope_ *, char *, struct Symbol_ ** ); +extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref( Entity, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * ); +extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, void *); +extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset( Entity ); +extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable( Entity, struct Variable_ * ); #endif /* ENTITY_H */ diff --git a/include/express/error.h b/include/express/error.h index 65e32387c..7eef340c4 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -166,7 +166,7 @@ typedef struct Error_ *Error; /********************/ extern SC_EXPRESS_EXPORT bool __ERROR_buffer_errors; -extern SC_EXPRESS_EXPORT const 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; @@ -180,28 +180,26 @@ extern SC_EXPRESS_EXPORT int malloc_debug_resolve; /* for debugging yacc/lex */ extern SC_EXPRESS_EXPORT int debug; -extern SC_EXPRESS_EXPORT void (*ERRORusage_function)(void); +extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /***********************/ /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer(void); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer(void); +extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); +extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); -static inline void ERRORbuffer_messages(bool flag) -{ +static inline void ERRORbuffer_messages( bool flag ) { __ERROR_buffer_errors = flag; - if(__ERROR_buffer_errors) { + if( __ERROR_buffer_errors ) { ERROR_start_message_buffer(); } else { ERROR_flush_message_buffer(); } } -static inline void ERRORflush_messages(void) -{ - if(__ERROR_buffer_errors) { +static inline void ERRORflush_messages( void ) { + if( __ERROR_buffer_errors ) { ERROR_flush_message_buffer(); ERROR_start_message_buffer(); } @@ -212,22 +210,22 @@ static inline void ERRORflush_messages(void) /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERRORinitialize(void); -extern SC_EXPRESS_EXPORT void ERRORcleanup(void); -extern SC_EXPRESS_EXPORT void ERRORnospace(void); -extern SC_EXPRESS_EXPORT void ERRORabort(int); -extern SC_EXPRESS_EXPORT void ERRORreport(enum ErrorCode, ...); +extern SC_EXPRESS_EXPORT void ERRORinitialize( void ); +extern SC_EXPRESS_EXPORT void ERRORcleanup( void ); +extern SC_EXPRESS_EXPORT void ERRORnospace( void ); +extern SC_EXPRESS_EXPORT void ERRORabort( int ); +extern SC_EXPRESS_EXPORT void ERRORreport( enum ErrorCode, ... ); struct Symbol_; /* mention Symbol to avoid warning on following line */ -extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol(enum ErrorCode, struct Symbol_ *, ...); -extern SC_EXPRESS_EXPORT void ERRORreport_with_line(enum ErrorCode, int, ...); +extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( enum ErrorCode, struct Symbol_ *, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_line( enum ErrorCode, int, ... ); -extern SC_EXPRESS_EXPORT void ERRORset_warning(char *, bool); -extern SC_EXPRESS_EXPORT void ERRORset_all_warnings(bool); -extern SC_EXPRESS_EXPORT void ERRORsafe(jmp_buf env); -extern SC_EXPRESS_EXPORT void ERRORunsafe(void); +extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, bool ); +extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); +extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); +extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); -extern SC_EXPRESS_EXPORT char *ERRORget_warnings_help(const char *prefix, const char *eol); +extern char * ERRORget_warnings_help(const char* prefix, const char *eol); extern bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ diff --git a/include/express/exp_kw.h b/include/express/exp_kw.h index 71974db6c..d8f1f6ec2 100644 --- a/include/express/exp_kw.h +++ b/include/express/exp_kw.h @@ -3,125 +3,125 @@ #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; +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 */ diff --git a/include/express/expbasic.h b/include/express/expbasic.h index 2db340b5a..63ab6e291 100644 --- a/include/express/expbasic.h +++ b/include/express/expbasic.h @@ -46,7 +46,7 @@ typedef enum { Lfalse, Lunknown, Ltrue } Logical; /* typedef ... Binary; done below because String not defined yet */ #ifndef _CLIENTDATA -typedef void *ClientData; +typedef void * ClientData; #define _CLIENTDATA #endif @@ -56,11 +56,11 @@ typedef void *ClientData; #include "alloc.h" -typedef struct Scope_ *Type; -typedef struct Scope_ *Scope; -typedef struct Scope_ *Schema; +typedef struct Scope_ * Type; +typedef struct Scope_ * Scope; +typedef struct Scope_ * Schema; -typedef char *Binary; +typedef char * Binary; #include "linklist.h" #define UNRESOLVED 0x0 diff --git a/include/express/expr.h b/include/express/expr.h index 73f2a1b1c..57191d5b6 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -88,10 +88,10 @@ typedef enum { } Op_Code; typedef struct Qualified_Attr Qualified_Attr; -typedef struct Expression_ *Expression; +typedef struct Expression_ * Expression; typedef Expression Ary_Expression, One_Of_Expression, Identifier, Literal; -typedef struct Query_ *Query; +typedef struct Query_ * Query; typedef One_Of_Expression Function_Call; typedef Ary_Expression Ternary_Expression, Binary_Expression, Unary_Expression; @@ -116,9 +116,9 @@ typedef Literal Aggregate_Literal, Integer_Literal, /* expression types */ struct Qualified_Attr { - struct Expression_ *complex; /**< complex entity instance */ - Symbol *entity; - Symbol *attribute; + struct Expression_ * complex; /**< complex entity instance */ + Symbol * entity; + Symbol * attribute; }; struct Op_Subexpression { @@ -132,22 +132,22 @@ struct Query_ { Variable local; Expression aggregate; /**< set from which to test */ Expression expression; /**< logical expression */ - struct Scope_ *scope; + struct Scope_ * scope; }; struct Funcall { - struct Scope_ *function; /**< can also be an entity because entities can be called as functions */ + struct Scope_ * function; /**< can also be an entity because entities can be called as functions */ Linked_List list; }; union expr_union { int integer; double real; - char *attribute; /**< inverse .... for 'attr' */ - char *binary; + char * attribute; /**< inverse .... for 'attr' */ + char * binary; int logical; bool boolean; - struct Query_ *query; + struct Query_ * query; struct Funcall funcall; /* if etype == aggregate, list of expressions */ @@ -158,7 +158,7 @@ union expr_union { * initializer in local vars, or * enumeration tags * or oneof value */ - struct Scope_ *entity; /**< used by subtype exp, group expr + struct Scope_ * entity; /**< used by subtype exp, group expr * and self expr, some funcall's and any * expr that results in an entity */ Variable variable; /**< attribute reference */ @@ -177,8 +177,8 @@ struct Expression_ { /** indexed by the op enumeration values */ struct EXPop_entry { - char *token; /**< literal token, e.g., "<>" */ - Type(*resolve)(Expression, struct Scope_ *); + char * token; /**< literal token, e.g., "<>" */ + Type( *resolve )( Expression, struct Scope_ * ); }; /********************/ @@ -249,18 +249,18 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Expression EXPcreate(Type); -extern SC_EXPRESS_EXPORT Expression EXPcreate_simple(Type); -extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol(Type, Symbol *); -extern SC_EXPRESS_EXPORT Expression UN_EXPcreate(Op_Code, Expression); -extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate(Op_Code, Expression, Expression); -extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate(Op_Code, Expression, Expression, Expression); -extern SC_EXPRESS_EXPORT Expression QUERYcreate(Symbol *, Expression); -extern SC_EXPRESS_EXPORT void EXPinitialize(void); -extern SC_EXPRESS_EXPORT void EXPcleanup(void); -extern SC_EXPRESS_EXPORT Type EXPtype(Expression, struct Scope_ *); -extern SC_EXPRESS_EXPORT int EXPget_integer_value(Expression); - -Type EXPresolve_op_dot(Expression, Scope); +extern SC_EXPRESS_EXPORT Expression EXPcreate( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_simple( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol( Type, Symbol * ); +extern SC_EXPRESS_EXPORT Expression UN_EXPcreate( Op_Code, Expression ); +extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate( Op_Code, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate( Op_Code, Expression, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression QUERYcreate( Symbol *, Expression ); +extern SC_EXPRESS_EXPORT void EXPinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPcleanup( void ); +extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); +extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); + +Type EXPresolve_op_dot( Expression, Scope ); #endif /*EXPRESSION_H*/ diff --git a/include/express/express.h b/include/express/express.h index a89c67391..e849ae56a 100644 --- a/include/express/express.h +++ b/include/express/express.h @@ -68,7 +68,7 @@ /* typedefs */ /************/ -typedef struct Scope_ *Express; +typedef struct Scope_ * Express; /****************/ /* modules used */ @@ -79,33 +79,33 @@ typedef struct Scope_ *Express; /***************************/ struct Express_ { - FILE *file; - char *filename; - char *basename; /**< name of file but without directory or .exp suffix */ + FILE * file; + char * filename; + char * basename; /**< name of file but without directory or .exp suffix */ }; /********************/ /* global variables */ /********************/ -extern SC_EXPRESS_EXPORT char *input_filename; +extern SC_EXPRESS_EXPORT char * input_filename; extern SC_EXPRESS_EXPORT Linked_List EXPRESS_path; extern SC_EXPRESS_EXPORT int EXPRESSpass; -extern SC_EXPRESS_EXPORT void (*EXPRESSinit_args)(int, char **); -extern SC_EXPRESS_EXPORT void (*EXPRESSinit_parse)(void); -extern SC_EXPRESS_EXPORT int (*EXPRESSfail)(Express); -extern SC_EXPRESS_EXPORT int (*EXPRESSsucceed)(Express); -extern SC_EXPRESS_EXPORT void (*EXPRESSbackend)(Express); -extern SC_EXPRESS_EXPORT char *EXPRESSprogram_name; +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_args )( int, char ** ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_parse )( void ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSfail )( Express ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSsucceed )( Express ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSbackend )( Express ); +extern SC_EXPRESS_EXPORT char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -extern SC_EXPRESS_EXPORT int (*EXPRESSgetopt)(int, char *); +extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt )( int, char * ); extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas; extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */ -extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_NVL; -extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_USEDIN; +extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_NVL; +extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN; /******************************/ /* macro function definitions */ @@ -120,15 +120,15 @@ extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_USEDIN; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Express EXPRESScreate(void); -extern SC_EXPRESS_EXPORT void EXPRESSdestroy(Express); -extern SC_EXPRESS_EXPORT void EXPRESSparse(Express, FILE *, char *); -extern SC_EXPRESS_EXPORT void EXPRESSinitialize(void); -extern SC_EXPRESS_EXPORT void EXPRESScleanup(void); -extern SC_EXPRESS_EXPORT void EXPRESSresolve(Express); -extern SC_EXPRESS_EXPORT int EXPRESS_fail(Express model); -extern SC_EXPRESS_EXPORT int EXPRESS_succeed(Express model); -extern void EXPRESSinit_init(void); -extern SC_EXPRESS_EXPORT void build_complex(Express); +extern SC_EXPRESS_EXPORT Express EXPRESScreate( void ); +extern SC_EXPRESS_EXPORT void EXPRESSdestroy( Express ); +extern SC_EXPRESS_EXPORT void EXPRESSparse( Express, FILE *, char * ); +extern SC_EXPRESS_EXPORT void EXPRESSinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPRESScleanup( void ); +extern SC_EXPRESS_EXPORT void EXPRESSresolve( Express ); +extern SC_EXPRESS_EXPORT int EXPRESS_fail( Express model ); +extern SC_EXPRESS_EXPORT int EXPRESS_succeed( Express model ); +extern void EXPRESSinit_init( void ); +extern SC_EXPRESS_EXPORT void build_complex( Express ); #endif /*EXPRESS_H*/ diff --git a/include/express/factory.h b/include/express/factory.h index 4942256fe..77075720d 100644 --- a/include/express/factory.h +++ b/include/express/factory.h @@ -1,8 +1,6 @@ #ifndef __FACTORY_H_ #define __FACTORY_H_ -#include "sc_export.h" - -SC_EXPRESS_EXPORT void FACTORYinitialize(); +void FACTORYinitialize(); #endif /* __FACTORY_H_ */ diff --git a/include/express/hash.h b/include/express/hash.h index 5b3e9b150..c5d1dfffe 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -116,14 +116,14 @@ typedef unsigned long Address; /****************/ typedef struct Element_ { - char *key; - char *data; - struct Element_ *next; - Symbol *symbol; /**< for debugging hash conflicts */ + char * key; + char * data; + struct Element_ * next; + Symbol * symbol; /**< for debugging hash conflicts */ char type; /**< user-supplied type */ -} *Element; +} * Element; -typedef Element *Segment; +typedef Element * Segment; typedef struct Hash_Table_ { #if 0 @@ -136,7 +136,7 @@ typedef struct Hash_Table_ { unsigned int MinLoadFactor; unsigned int MaxLoadFactor; Segment Directory[DIRECTORY_SIZE]; -} *Hash_Table; +} * Hash_Table; typedef struct { unsigned int i; /**< segment index (i think) */ @@ -192,13 +192,13 @@ This change only seems to have affected hash.h and hash.c /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void HASHinitialize(void); -extern SC_EXPRESS_EXPORT Hash_Table HASHcreate(unsigned); -extern SC_EXPRESS_EXPORT Hash_Table HASHcopy(Hash_Table); -extern SC_EXPRESS_EXPORT void HASHdestroy(Hash_Table); -extern SC_EXPRESS_EXPORT Element HASHsearch(Hash_Table, Element, Action); -extern SC_EXPRESS_EXPORT void HASHlistinit(Hash_Table, HashEntry *); -extern SC_EXPRESS_EXPORT void HASHlistinit_by_type(Hash_Table, HashEntry *, char); -extern SC_EXPRESS_EXPORT Element HASHlist(HashEntry *); +extern SC_EXPRESS_EXPORT void HASHinitialize( void ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( unsigned ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table ); +extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table ); +extern SC_EXPRESS_EXPORT Element HASHsearch( Hash_Table, Element, Action ); +extern SC_EXPRESS_EXPORT void HASHlistinit( Hash_Table, HashEntry * ); +extern SC_EXPRESS_EXPORT void HASHlistinit_by_type( Hash_Table, HashEntry *, char ); +extern SC_EXPRESS_EXPORT Element HASHlist( HashEntry * ); #endif /*HASH_H*/ diff --git a/include/express/info.h b/include/express/info.h index 2a8c40d63..1a96cf679 100644 --- a/include/express/info.h +++ b/include/express/info.h @@ -6,9 +6,9 @@ * informative functions that were in express.c/express.h */ -extern SC_EXPRESS_EXPORT char *EXPRESSversion(void); +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); +extern SC_EXPRESS_EXPORT void EXPRESSusage( int _exit ); #endif /* INFO_H */ diff --git a/include/express/lexact.h b/include/express/lexact.h index 5fb2212f2..9e9ac3559 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -56,9 +56,9 @@ typedef struct Scan_Buffer { #ifdef keep_nul int numRead; #endif - char *savedPos; - FILE *file; - const char *filename; + char * savedPos; + FILE * file; + const char * filename; bool readEof; int lineno; int bol; @@ -70,7 +70,7 @@ typedef struct Scan_Buffer { extern SC_EXPRESS_EXPORT Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; extern SC_EXPRESS_EXPORT int SCAN_current_buffer; -extern SC_EXPRESS_EXPORT char *SCANcurrent; +extern SC_EXPRESS_EXPORT char * SCANcurrent; /******************************/ /* macro function definitions */ @@ -93,22 +93,22 @@ extern SC_EXPRESS_EXPORT char *SCANcurrent; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SCANinitialize(void); -extern SC_EXPRESS_EXPORT void SCANcleanup(void); -extern SC_EXPRESS_EXPORT int SCANprocess_real_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal(char *); -extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_string(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_semicolon(const char *, int); -extern SC_EXPRESS_EXPORT void SCANsave_comment(const char *); -extern SC_EXPRESS_EXPORT bool SCANread(void); -extern SC_EXPRESS_EXPORT void SCANinclude_file(char *); -SC_EXPRESS_EXPORT void SCANlowerize(char *); -SC_EXPRESS_EXPORT void SCANupperize(char *); -extern SC_EXPRESS_EXPORT char *SCANstrdup(const char *); -extern SC_EXPRESS_EXPORT long SCANtell(void); +extern SC_EXPRESS_EXPORT void SCANinitialize( void ); +extern SC_EXPRESS_EXPORT void SCANcleanup( void ); +extern SC_EXPRESS_EXPORT int SCANprocess_real_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal( char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_semicolon( const char *, int ); +extern SC_EXPRESS_EXPORT void SCANsave_comment( const char * ); +extern SC_EXPRESS_EXPORT bool SCANread( void ); +extern SC_EXPRESS_EXPORT void SCANinclude_file( char * ); + SC_EXPRESS_EXPORT void SCANlowerize( char * ); + SC_EXPRESS_EXPORT void SCANupperize( char * ); +extern SC_EXPRESS_EXPORT char * SCANstrdup( const char * ); +extern SC_EXPRESS_EXPORT long SCANtell( void ); #endif /* LEX_ACTIONS_H */ diff --git a/include/express/linklist.h b/include/express/linklist.h index 794ee9bcc..76c31a461 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -44,7 +44,7 @@ /* typedefs */ /************/ -typedef struct Linked_List_ *Linked_List; +typedef struct Linked_List_ * Linked_List; /****************/ /* modules used */ @@ -57,10 +57,10 @@ typedef struct Linked_List_ *Linked_List; /***************************/ typedef struct Link_ { - struct Link_ *next; - struct Link_ *prev; + struct Link_ * next; + struct Link_ * prev; void *data; -} *Link; +} * Link; struct Linked_List_ { Link mark; @@ -124,22 +124,22 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void LISTinitialize(void); -extern SC_EXPRESS_EXPORT void LISTcleanup(void); -extern SC_EXPRESS_EXPORT Linked_List LISTcreate(void); -extern SC_EXPRESS_EXPORT Linked_List LISTcopy(Linked_List); -extern SC_EXPRESS_EXPORT void LISTsort(Linked_List, int (*comp)(void *, void *)); -extern SC_EXPRESS_EXPORT void LISTswap(Link, Link); -extern SC_EXPRESS_EXPORT void *LISTadd_first(Linked_List, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_last(Linked_List, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_after(Linked_List, Link, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_before(Linked_List, Link, void *); -extern SC_EXPRESS_EXPORT void *LISTremove_first(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_first(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_second(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_nth(Linked_List, int); -extern SC_EXPRESS_EXPORT void LISTfree(Linked_List); -extern SC_EXPRESS_EXPORT int LISTget_length(Linked_List); -extern SC_EXPRESS_EXPORT bool LISTempty(Linked_List list); +extern SC_EXPRESS_EXPORT void LISTinitialize( void ); +extern SC_EXPRESS_EXPORT void LISTcleanup( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcreate( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcopy( Linked_List ); +extern SC_EXPRESS_EXPORT void LISTsort( Linked_List, int (*comp)(void*, void*) ); +extern SC_EXPRESS_EXPORT void LISTswap( Link, Link ); +extern SC_EXPRESS_EXPORT void * LISTadd_first( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_last( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_after( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_before( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTremove_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_second( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_nth( Linked_List, int ); +extern SC_EXPRESS_EXPORT void LISTfree( Linked_List ); +extern SC_EXPRESS_EXPORT int LISTget_length( Linked_List ); +extern SC_EXPRESS_EXPORT bool LISTempty( Linked_List list ); #endif /*LINKED_LIST_H*/ diff --git a/include/express/memory.h b/include/express/memory.h index 3d1e58c74..77357cf7e 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -1,8 +1,6 @@ #ifndef __MEMORY_H #define __MEMORY_H -#include "sc_export.h" - -SC_EXPRESS_EXPORT void MEMORYinitialize(); +void MEMORYinitialize(); #endif // __MEMORY_H diff --git a/include/express/object.h b/include/express/object.h index 524451081..e5736f45b 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -68,8 +68,8 @@ /***************************/ struct Object { - struct Symbol_ *(*get_symbol)(); - char *type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ + struct Symbol_ * ( *get_symbol )(); + char * type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ int bits; /**< a bitwise selector of a type, i.e. OBJ_XX_BITS */ }; diff --git a/include/express/resolve.h b/include/express/resolve.h index 497c1a023..7eca8aa07 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -60,29 +60,29 @@ extern SC_EXPRESS_EXPORT int print_objects_while_running; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void RESOLVEinitialize(void); -extern SC_EXPRESS_EXPORT void RESOLVEcleanup(void); -extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements(Scope); -extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers(Scope); -extern SC_EXPRESS_EXPORT void SCOPEresolve_types(Scope); -extern SC_EXPRESS_EXPORT void TYPE_resolve(Type *); -extern SC_EXPRESS_EXPORT void EXP_resolve(Expression, Scope, Type); -extern SC_EXPRESS_EXPORT void ALGresolve(Scope); -extern SC_EXPRESS_EXPORT void SCHEMAresolve(Scope); -extern SC_EXPRESS_EXPORT void RENAMEresolve(Rename *, Schema); +extern SC_EXPRESS_EXPORT void RESOLVEinitialize( void ); +extern SC_EXPRESS_EXPORT void RESOLVEcleanup( void ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_types( Scope ); +extern SC_EXPRESS_EXPORT void TYPE_resolve( Type * ); +extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); +extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); +extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); +extern SC_EXPRESS_EXPORT void RENAMEresolve( Rename *, Schema ); /* * for unit tests, no extern / export */ -void VAR_resolve_expressions(Variable, Entity); -void ENTITYresolve_subtypes(Schema); -void ENTITYresolve_supertypes(Entity); -void ENTITYresolve_expressions(Entity e); -void ALGresolve_expressions_statements(Scope, Linked_List); -int WHEREresolve(Linked_List, Scope, int); -void TYPEresolve_expressions(Type, Scope); -void STMTresolve(Statement, Scope); -void STMTlist_resolve(Linked_List, Scope); -int ENTITYresolve_subtype_expression(Expression, Entity, Linked_List *); +void VAR_resolve_expressions( Variable, Entity ); +void ENTITYresolve_subtypes( Schema ); +void ENTITYresolve_supertypes( Entity ); +void ENTITYresolve_expressions( Entity e ); +void ALGresolve_expressions_statements( Scope, Linked_List ); +int WHEREresolve( Linked_List, Scope, int ); +void TYPEresolve_expressions( Type, Scope ); +void STMTresolve( Statement, Scope ); +void STMTlist_resolve( Linked_List, Scope ); +int ENTITYresolve_subtype_expression( Expression, Entity, Linked_List * ); #endif /*RESOLVE_H*/ diff --git a/include/express/schema.h b/include/express/schema.h index c2d1c6ca0..1d2ce5c4b 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -72,10 +72,10 @@ enum rename_type { use, ref }; typedef struct Rename { - struct Symbol_ *schema_sym; + struct Symbol_ * schema_sym; Schema schema; - struct Symbol_ *old; - struct Symbol_ *nnew; + struct Symbol_ * old; + struct Symbol_ * nnew; void *object; /**< once object has been looked up */ char type; /**< drat, need to remember this once renames have been * resolved to avoid looking them up in the dictionary again */ @@ -133,22 +133,22 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARfind(Scope, char *, int); -extern SC_EXPRESS_EXPORT Schema SCHEMAcreate(void); -extern SC_EXPRESS_EXPORT void SCHEMAinitialize(void); -extern SC_EXPRESS_EXPORT void SCHEMAadd_use(Schema, Symbol *, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT void SCHEMAadd_reference(Schema, Symbol *, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_use(Schema, Rename *); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference(Schema, Rename *); -extern SC_EXPRESS_EXPORT void *SCHEMAfind(Schema, char *name, int search_refs); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate(char); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny(char); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab(char); -extern SC_EXPRESS_EXPORT void SCOPEdestroy(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref(Scope); - -void SCHEMA_get_entities_ref(Scope, Linked_List); +extern SC_EXPRESS_EXPORT Variable VARfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT Schema SCHEMAcreate( void ); +extern SC_EXPRESS_EXPORT void SCHEMAinitialize( void ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_use( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_reference( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_use( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void * SCHEMAfind( Schema, char * name, int search_refs ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab( char ); +extern SC_EXPRESS_EXPORT void SCOPEdestroy( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref( Scope ); + +void SCHEMA_get_entities_ref( Scope, Linked_List ); #endif /* SCHEMA_H */ diff --git a/include/express/scope.h b/include/express/scope.h index 26e4a7f3f..8f16fafbf 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -83,16 +83,16 @@ struct Scope_ { ClientData clientData; /**< user may use this for any purpose */ int search_id; /**< key to avoid searching this scope twice */ Dictionary symbol_table, enum_table; - struct Scope_ *superscope; + struct Scope_ * superscope; union { - struct Procedure_ *proc; - struct Function_ *func; - struct Rule_ *rule; - struct Entity_ *entity; - struct Schema_ *schema; - struct Express_ *express; - struct Increment_ *incr; - struct TypeHead_ *type; + struct Procedure_ * proc; + struct Function_ * func; + struct Rule_ * rule; + struct Entity_ * entity; + struct Schema_ * schema; + struct Express_ * express; + struct Increment_ * incr; + struct TypeHead_ * type; /* no, query owns a scope rather than scope owning a query * struct Query *query; */ } u; @@ -134,16 +134,16 @@ struct Scope_ { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Symbol_ *SCOPE_get_symbol(void *); -extern SC_EXPRESS_EXPORT void SCOPE_get_entities(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order(Scope); -extern SC_EXPRESS_EXPORT void *SCOPEfind(Scope, char *, int); -extern SC_EXPRESS_EXPORT void SCOPE_get_functions(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions(Scope); -extern SC_EXPRESS_EXPORT void SCOPE_get_rules(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules(Scope); - -void *SCOPE_find(Scope, char *, int); +extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( void * ); +extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope ); +extern SC_EXPRESS_EXPORT void * SCOPEfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); +extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); + +void * SCOPE_find( Scope, char *, int ); #endif /* SCOPE_H */ diff --git a/include/express/stmt.h b/include/express/stmt.h index b0d49f3ff..21f5e4645 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -56,17 +56,17 @@ /* typedefs */ /************/ -typedef struct Statement_ *Statement, - *Alias, - *Assignment, - *Case_Statement, - *Compound_Statement, - *Conditional, - *Loop, - *Procedure_Call, - *Return_Statement; - -typedef struct Scope_ *Increment; +typedef struct Statement_ * Statement, + *Alias, + *Assignment, + *Case_Statement, + *Compound_Statement, + *Conditional, + *Loop, + *Procedure_Call, + *Return_Statement; + +typedef struct Scope_ * Increment; /****************/ /* modules used */ @@ -97,21 +97,21 @@ struct Statement_ { int type; /**< one of STMT_XXX above */ /* hey, is there nothing in common beside symbol and private data?? */ union u_statement { - struct Alias_ *alias; - struct Assignment_ *assign; - struct Case_Statement_ *Case; - struct Compound_Statement_ *compound; - struct Conditional_ *cond; - struct Loop_ *loop; - struct Procedure_Call_ *proc; - struct Return_Statement_ *ret; + struct Alias_ * alias; + struct Assignment_ * assign; + struct Case_Statement_ * Case; + struct Compound_Statement_ * compound; + struct Conditional_ * cond; + struct Loop_ * loop; + struct Procedure_Call_ * proc; + struct Return_Statement_ * ret; /* skip & escape have no data */ } u; }; struct Alias_ { - struct Scope_ *scope; - struct Variable_ *variable; + struct Scope_ * scope; + struct Variable_ * variable; Linked_List statements; /**< list of statements */ }; @@ -136,7 +136,7 @@ struct Conditional_ { }; struct Loop_ { - struct Scope_ *scope; /**< scope for increment control */ + struct Scope_ * scope; /**< scope for increment control */ Expression while_expr; Expression until_expr; Linked_List statements; /**< list of statements */ @@ -150,7 +150,7 @@ struct Increment_ { }; struct Procedure_Call_ { - struct Scope_ *procedure; + struct Scope_ * procedure; Linked_List parameters; /**< list of expressions */ }; @@ -225,17 +225,17 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Statement STMTcreate(int); -extern SC_EXPRESS_EXPORT Statement ALIAScreate(struct Scope_ *, Variable, Linked_List); -extern SC_EXPRESS_EXPORT Statement CASEcreate(Expression, Linked_List); -extern SC_EXPRESS_EXPORT Statement ASSIGNcreate(Expression, Expression); -extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate(Linked_List); -extern SC_EXPRESS_EXPORT Statement CONDcreate(Expression, Linked_List, Linked_List); -extern SC_EXPRESS_EXPORT Statement LOOPcreate(struct Scope_ *, Expression, Expression, Linked_List); -extern SC_EXPRESS_EXPORT Statement PCALLcreate(Linked_List); -extern SC_EXPRESS_EXPORT Statement RETcreate(Expression); -extern SC_EXPRESS_EXPORT void STMTinitialize(void); -extern SC_EXPRESS_EXPORT struct Scope_ *INCR_CTLcreate(Symbol *, Expression start, - Expression end, Expression increment); +extern SC_EXPRESS_EXPORT Statement STMTcreate( int ); +extern SC_EXPRESS_EXPORT Statement ALIAScreate( struct Scope_ *, Variable, Linked_List ); +extern SC_EXPRESS_EXPORT Statement CASEcreate( Expression , Linked_List ); +extern SC_EXPRESS_EXPORT Statement ASSIGNcreate( Expression , Expression ); +extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement CONDcreate( Expression, Linked_List, Linked_List ); +extern SC_EXPRESS_EXPORT Statement LOOPcreate( struct Scope_ *, Expression, Expression, Linked_List ); +extern SC_EXPRESS_EXPORT Statement PCALLcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement RETcreate( Expression ); +extern SC_EXPRESS_EXPORT void STMTinitialize( void ); +extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate( Symbol *, Expression start, + Expression end, Expression increment ); #endif /*STATEMENT_H*/ diff --git a/include/express/symbol.h b/include/express/symbol.h index 8da717b51..b589b01e2 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -58,8 +58,8 @@ typedef struct Symbol_ Symbol; /***************************/ struct Symbol_ { - char *name; - const char *filename; + char * name; + const char * filename; int line; char resolved; }; @@ -88,7 +88,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SYMBOLinitialize(void); -SC_EXPRESS_EXPORT Symbol *SYMBOLcreate(char *name, int line, const char *filename); +extern SC_EXPRESS_EXPORT void SYMBOLinitialize( void ); +SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename ); #endif /* SYMBOL_H */ diff --git a/include/express/type.h b/include/express/type.h index c0680aea5..321fe716e 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -115,8 +115,8 @@ enum type_enum { /* typedefs */ /************/ -typedef struct TypeHead_ *TypeHead; -typedef struct TypeBody_ *TypeBody; +typedef struct TypeHead_ * TypeHead; +typedef struct TypeBody_ * TypeBody; typedef enum type_enum TypeType; /* provide a replacement for Class */ @@ -140,7 +140,7 @@ typedef enum type_enum Class; struct TypeHead_ { Type head; /**< if we are a defined type this is who we point to */ - struct TypeBody_ *body; /**< true type, ignoring defined types */ + struct TypeBody_ * body; /**< true type, ignoring defined types */ #if 0 /* if we are concerned about memory (over time) uncomment this and */ /* other references to refcount in parser and TYPEresolve. It is */ @@ -151,7 +151,7 @@ struct TypeHead_ { struct TypeBody_ { #if 1 - struct TypeHead_ *head; /**< for debugging only */ + struct TypeHead_ * head; /**< for debugging only */ #endif enum type_enum type; /**< bits describing this type, int, real, etc */ struct { @@ -174,7 +174,7 @@ struct TypeBody_ { Linked_List list; /**< used by select_types and composed types, such as for a list of entities in an instance */ Expression upper; Expression lower; - struct Scope_ *entity; /**< only used by entity types */ + struct Scope_ * entity; /**< only used by entity types */ }; /********************/ @@ -291,20 +291,20 @@ extern SC_EXPRESS_EXPORT struct freelist_head TYPEBODY_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Type TYPEcreate_partial(struct Symbol_ *, Scope); +extern SC_EXPRESS_EXPORT Type TYPEcreate_partial( struct Symbol_ *, Scope ); -extern SC_EXPRESS_EXPORT Type TYPEcreate(enum type_enum); -extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously(TypeBody); -extern SC_EXPRESS_EXPORT Type TYPEcreate_name(struct Symbol_ *); -extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab(struct Symbol_ *, Scope, char); -extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate(enum type_enum); -extern SC_EXPRESS_EXPORT void TYPEinitialize(void); -extern SC_EXPRESS_EXPORT void TYPEcleanup(void); +extern SC_EXPRESS_EXPORT Type TYPEcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously( TypeBody ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_name( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab( struct Symbol_ *, Scope, char ); +extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT void TYPEinitialize( void ); +extern SC_EXPRESS_EXPORT void TYPEcleanup( void ); -extern SC_EXPRESS_EXPORT bool TYPEinherits_from(Type, enum type_enum); -extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type(Type); +extern SC_EXPRESS_EXPORT bool TYPEinherits_from( Type, enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type( Type ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type(Type, Scope, struct Symbol_ *); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag(Type, Scope, struct Symbol_ *); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type( Type, Scope, struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag( Type, Scope, struct Symbol_ * ); #endif /* TYPE_H */ diff --git a/include/express/variable.h b/include/express/variable.h index b9d09a57d..308116459 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -62,7 +62,7 @@ /* typedefs */ /************/ -typedef struct Variable_ *Variable; +typedef struct Variable_ * Variable; /****************/ /* modules used */ @@ -91,7 +91,7 @@ struct Variable_ { unsigned int attribute : 1; /**< is an attribute (rule parameters are marked this way, too) */ } flags; - Symbol *inverse_symbol; /**< entity symbol */ + Symbol * inverse_symbol; /**< entity symbol */ Variable inverse_attribute; /**< attribute related by inverse relationship */ }; @@ -125,8 +125,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARcreate(Expression, Type); -extern SC_EXPRESS_EXPORT void VARinitialize(void); -extern SC_EXPRESS_EXPORT char *VARget_simple_name(Variable); +extern SC_EXPRESS_EXPORT Variable VARcreate( Expression, Type ); +extern SC_EXPRESS_EXPORT void VARinitialize( void ); +extern SC_EXPRESS_EXPORT char * VARget_simple_name( Variable ); #endif /* VARIABLE_H */ diff --git a/include/ordered_attrs.h b/include/ordered_attrs.h index dded023f6..56a3b410f 100644 --- a/include/ordered_attrs.h +++ b/include/ordered_attrs.h @@ -16,13 +16,13 @@ typedef struct { } orderedAttr; /**set the entity we're working on, init working variables */ -extern SC_EXPRESS_EXPORT void orderedAttrsInit(Entity e); +extern SC_EXPRESS_EXPORT void orderedAttrsInit( Entity e ); /**free memory */ extern SC_EXPRESS_EXPORT void orderedAttrsCleanup(); /**get next attr; not thread safe (as if the rest of libexpress is) */ -extern SC_EXPRESS_EXPORT const orderedAttr *nextAttr(); +extern SC_EXPRESS_EXPORT const orderedAttr * nextAttr(); #ifdef __cplusplus } diff --git a/include/sc_cf.h.in b/include/sc_cf.h.in deleted file mode 100644 index 67d88c433..000000000 --- a/include/sc_cf.h.in +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SCL_CF_H -#define SCL_CF_H - -/**** Define statements for CMake ****/ -#cmakedefine SC_VERSION "@SC_VERSION@" -#cmakedefine HAVE_NDIR_H 1 -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_SYS_STAT_H 1 -#cmakedefine HAVE_SYS_PARAM_H 1 -#cmakedefine HAVE_SYSENT_H 1 -#cmakedefine HAVE_UNISTD_H 1 -#cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_STDBOOL_H 1 -#cmakedefine HAVE_PROCESS_H 1 -#cmakedefine HAVE_IO_H 1 - -#cmakedefine SC_TRACE_FPRINTF 1 -#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 - -#cmakedefine HAVE_ABS 1 -#cmakedefine HAVE_MEMCPY 1 -#cmakedefine HAVE_MEMMOVE 1 -#cmakedefine HAVE_GETOPT 1 -#cmakedefine HAVE_VSNPRINTF 1 - -#cmakedefine HAVE_SSIZE_T 1 - -#cmakedefine HAVE_STD_THREAD 1 -#cmakedefine HAVE_STD_CHRONO 1 -#cmakedefine HAVE_NULLPTR 1 - -#endif /* SCL_CF_H */ diff --git a/example/ap203min/include/sc_cf.h.in b/include/sc_cf_cmake.h.in similarity index 94% rename from example/ap203min/include/sc_cf.h.in rename to include/sc_cf_cmake.h.in index 67d88c433..6caec92aa 100644 --- a/example/ap203min/include/sc_cf.h.in +++ b/include/sc_cf_cmake.h.in @@ -2,7 +2,6 @@ #define SCL_CF_H /**** Define statements for CMake ****/ -#cmakedefine SC_VERSION "@SC_VERSION@" #cmakedefine HAVE_NDIR_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_SYS_STAT_H 1 diff --git a/misc/astyle.cfg b/misc/astyle.cfg index da64a0c92..40268faed 100644 --- a/misc/astyle.cfg +++ b/misc/astyle.cfg @@ -11,7 +11,7 @@ suffix=none #don't create backup files -style=kr #Kernighan & Ritchie style +style=java #compact bracket style indent=spaces=4 @@ -19,10 +19,11 @@ indent-classes indent-switches indent-namespaces pad-oper #pad (space) around operators +pad-paren-in #pad inside parenthesis unpad-paren #remove parenthesis padding other than requested above add-brackets #add brackets on one-line conditionals convert-tabs #convert all tabs to spaces -align-pointer=name #char *foo +align-pointer=middle #char * foo lineend=linux #lines end with LF (linux), not CRLF (windows) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 5aad0a929..cd41f97b6 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -15,6 +15,7 @@ set(SC_BASE_HDRS sc_getopt.h sc_trace_fprintf.h sc_mkdir.h + sc_nullptr.h path2str.h judy/src/judy.h judy/src/judyLArray.h @@ -32,7 +33,7 @@ if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) endif() -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base psapi) @@ -40,7 +41,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base-static psapi) @@ -61,7 +62,7 @@ if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") install(FILES ${SC_BASE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/base) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base) # Local Variables: # tab-width: 8 diff --git a/src/base/judy/misc/judy64n.c b/src/base/judy/misc/judy64n.c index 5e9d61d02..8dc8f909a 100644 --- a/src/base/judy/misc/judy64n.c +++ b/src/base/judy/misc/judy64n.c @@ -40,24 +40,24 @@ #include #ifdef linux -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE -#define __USE_FILE_OFFSET64 + #define _FILE_OFFSET_BITS 64 + #define _LARGEFILE_SOURCE + #define __USE_FILE_OFFSET64 -#include + #include #else -#ifdef __BIG_ENDIAN__ -#ifndef BYTE_ORDER -#define BYTE_ORDER 4321 -#endif -#else -#ifndef BYTE_ORDER -#define BYTE_ORDER 1234 -#endif -#endif -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif + #ifdef __BIG_ENDIAN__ + #ifndef BYTE_ORDER + #define BYTE_ORDER 4321 + #endif + #else + #ifndef BYTE_ORDER + #define BYTE_ORDER 1234 + #endif + #endif + #ifndef BIG_ENDIAN + #define BIG_ENDIAN 4321 + #endif #endif @@ -72,32 +72,32 @@ defined(__arch64__) || \ defined(__powerpc64__) || \ defined (__s390x__) -// defines for 64 bit + // defines for 64 bit -typedef unsigned long long judyvalue; -typedef unsigned long long JudySlot; -#define JUDY_key_mask (0x07) -#define JUDY_key_size 8 -#define JUDY_slot_size 8 -#define JUDY_span_bytes (3 * JUDY_key_size) -#define JUDY_span_equiv JUDY_2 -#define JUDY_radix_equiv JUDY_8 + typedef unsigned long long judyvalue; + typedef unsigned long long JudySlot; + #define JUDY_key_mask (0x07) + #define JUDY_key_size 8 + #define JUDY_slot_size 8 + #define JUDY_span_bytes (3 * JUDY_key_size) + #define JUDY_span_equiv JUDY_2 + #define JUDY_radix_equiv JUDY_8 -#define PRIjudyvalue "llu" + #define PRIjudyvalue "llu" #else -// defines for 32 bit + // defines for 32 bit -typedef unsigned int judyvalue; -typedef unsigned int JudySlot; -#define JUDY_key_mask (0x03) -#define JUDY_key_size 4 -#define JUDY_slot_size 4 -#define JUDY_span_bytes (7 * JUDY_key_size) -#define JUDY_span_equiv JUDY_4 -#define JUDY_radix_equiv JUDY_8 + typedef unsigned int judyvalue; + typedef unsigned int JudySlot; + #define JUDY_key_mask (0x03) + #define JUDY_key_size 4 + #define JUDY_slot_size 4 + #define JUDY_span_bytes (7 * JUDY_key_size) + #define JUDY_span_equiv JUDY_4 + #define JUDY_radix_equiv JUDY_8 -#define PRIjudyvalue "u" + #define PRIjudyvalue "u" #endif @@ -115,7 +115,7 @@ typedef unsigned int JudySlot; unsigned int MaxMem = 0; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort(char *msg) +void judy_abort (char *msg) { fprintf(stderr, "%s\n", msg); exit(1); @@ -155,9 +155,9 @@ int JudySize[] = { }; judyvalue JudyMask[9] = { - 0, 0xff, 0xffff, 0xffffff, 0xffffffff, +0, 0xff, 0xffff, 0xffffff, 0xffffffff, #if JUDY_key_size > 4 - 0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL +0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL #endif }; @@ -200,20 +200,20 @@ int Found = 0; // call with max key size // and Integer tree depth. -void *judy_open(unsigned int max, unsigned int depth) +void *judy_open (unsigned int max, unsigned int depth) { - JudySeg *seg; - Judy *judy; - unsigned int amt; +JudySeg *seg; +Judy *judy; +unsigned int amt; max++; // allow for zero terminator on keys - if((seg = malloc(JUDY_seg))) { + if( (seg = malloc(JUDY_seg)) ) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("No virtual memory"); + judy_abort ("No virtual memory"); #else return NULL; #endif @@ -221,9 +221,8 @@ void *judy_open(unsigned int max, unsigned int depth) amt = sizeof(Judy) + max * sizeof(JudyStack); - if(amt & (JUDY_cache_line - 1)) { + if( amt & (JUDY_cache_line - 1) ) amt |= JUDY_cache_line - 1, amt++; - } #if defined(STANDALONE) || defined(ASKITIS) MaxMem += JUDY_seg; @@ -235,79 +234,75 @@ void *judy_open(unsigned int max, unsigned int depth) judy = (Judy *)((unsigned char *)seg + seg->next); memset(judy, 0, amt); judy->depth = depth; - judy->seg = seg; + judy->seg = seg; judy->max = max; return judy; } -void judy_close(Judy *judy) +void judy_close (Judy *judy) { - JudySeg *seg, *nxt = judy->seg; +JudySeg *seg, *nxt = judy->seg; - while((seg = nxt)) { - nxt = seg->seg, free(seg); - } + while( (seg = nxt) ) + nxt = seg->seg, free (seg); } // allocate judy node -void *judy_alloc(Judy *judy, unsigned int type) +void *judy_alloc (Judy *judy, unsigned int type) { - unsigned int amt, idx, min; - JudySeg *seg; - void **block; - void **rtn; +unsigned int amt, idx, min; +JudySeg *seg; +void **block; +void **rtn; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if(type == JUDY_radix) { + if( type == JUDY_radix ) type = JUDY_radix_equiv; - } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) type = JUDY_span_equiv; - } #endif amt = JudySize[type]; - if(amt & 0x07) { + if( amt & 0x07 ) amt |= 0x07, amt += 1; - } // see if free block is already available - if((block = judy->reuse[type])) { + if( (block = judy->reuse[type]) ) { judy->reuse[type] = *block; - memset(block, 0, amt); + memset (block, 0, amt); return (void *)block; } // break down available larger block // for reuse into smaller blocks - if(type >= JUDY_1) - for(idx = type; idx++ < JUDY_max;) - if(block = judy->reuse[idx]) { - judy->reuse[idx] = *block; - while(idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; - } - memset(block, 0, amt); - return (void *)block; - } + if( type >= JUDY_1 ) + for( idx = type; idx++ < JUDY_max; ) + if( block = judy->reuse[idx] ) { + judy->reuse[idx] = *block; + while( idx-- > type) { + judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); + block[JudySize[idx] / sizeof(void *)] = 0; + } + memset (block, 0, amt); + return (void *)block; + } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if(judy->seg->next < min + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < min + sizeof(*seg) ) { + if( (seg = malloc (JUDY_seg)) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -330,36 +325,35 @@ void *judy_alloc(Judy *judy, unsigned int type) rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); - for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { + for( idx = type; amt & (JUDY_cache_line - 1); amt <<= 1 ) { block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset(rtn, 0, JudySize[type]); + memset (rtn, 0, JudySize[type]); return (void *)rtn; } -void *judy_data(Judy *judy, unsigned int amt) +void *judy_data (Judy *judy, unsigned int amt) { - JudySeg *seg; - void *block; +JudySeg *seg; +void *block; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if(amt & (JUDY_cache_line - 1)) { + if( amt & (JUDY_cache_line - 1)) amt |= (JUDY_cache_line - 1), amt += 1; - } - if(judy->seg->next < amt + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < amt + sizeof(*seg) ) { + if( (seg = malloc (JUDY_seg)) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -380,32 +374,30 @@ void *judy_data(Judy *judy, unsigned int amt) judy->seg->next -= amt; block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset(block, 0, amt); + memset (block, 0, amt); return block; } -void *judy_clone(Judy *judy) +void *judy_clone (Judy *judy) { - Judy *clone; - unsigned int amt; +Judy *clone; +unsigned int amt; amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data(judy, amt); - memcpy(clone, judy, amt); + clone = judy_data (judy, amt); + memcpy (clone, judy, amt); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free(Judy *judy, void *block, int type) +void judy_free (Judy *judy, void *block, int type) { - if(type == JUDY_radix) { + if( type == JUDY_radix ) type = JUDY_radix_equiv; - } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) type = JUDY_span_equiv; - } #endif *((void **)(block)) = judy->reuse[type]; @@ -415,104 +407,95 @@ void judy_free(Judy *judy, void *block, int type) // assemble key from current path -unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) +unsigned int judy_key (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *dest = (judyvalue *)buff; - unsigned int len = 0, idx = 0, depth; - int slot, off, type; - judyvalue value; - unsigned char *base; - int keysize; - - if(judy->depth) { +judyvalue *dest = (judyvalue *)buff; +unsigned int len = 0, idx = 0, depth; +int slot, off, type; +judyvalue value; +unsigned char *base; +int keysize; + + if( judy->depth ) max = judy->depth * JUDY_key_size; - } else { - max--; // leave room for zero terminator - } + else + max--; // leave room for zero terminator - while(len < max && ++idx <= judy->level) { + while( len < max && ++idx <= judy->level ) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if(judy->depth) - if(!(len & JUDY_key_mask)) { - dest[depth] = 0; - } - - switch(type) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + if( judy->depth ) + if( !(len & JUDY_key_mask) ) + dest[depth] = 0; + + switch( type ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - if(judy->depth) { - value = *(judyvalue *)(base + slot * keysize); - value &= JudyMask[keysize]; - dest[depth++] |= value; - len += keysize; + if( judy->depth ) { + value = *(judyvalue *)(base + slot * keysize); + value &= JudyMask[keysize]; + dest[depth++] |= value; + len += keysize; - if(depth < judy->depth) { - continue; - } + if( depth < judy->depth ) + continue; - return len; - } + return len; + } #if BYTE_ORDER != BIG_ENDIAN - off = keysize; - - while(off-- && len < max) - if(buff[len] = base[slot * keysize + off]) { - len++; - } else { - break; - } + off = keysize; + + while( off-- && len < max ) + if( buff[len] = base[slot * keysize + off] ) + len++; + else + break; #else - for(off = 0; off < keysize && len < max; off++) - if(buff[len] = base[slot * keysize + off]) { - len++; - } else { - break; - } + for( off = 0; off < keysize && len < max; off++ ) + if( buff[len] = base[slot * keysize + off] ) + len++; + else + break; #endif - continue; + continue; - case JUDY_radix: - if(judy->depth) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if(!(len & JUDY_key_mask)) { - depth++; - } - if(depth < judy->depth) { - continue; - } - - return len; - } + case JUDY_radix: + if( judy->depth ) { + dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; + if( !(len & JUDY_key_mask) ) + depth++; + if( depth < judy->depth ) + continue; - if(!slot) { - break; - } - buff[len++] = (unsigned char)slot; - continue; + return len; + } + + if( !slot ) + break; + buff[len++] = (unsigned char)slot; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + case JUDY_span: + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) - if(len < max) { - buff[len++] = base[slot]; - } - continue; + for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) + if( len < max ) + buff[len++] = base[slot]; + continue; #endif } } @@ -522,149 +505,139 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) // find slot & setup cursor -JudySlot *judy_slot(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_slot (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *src = (judyvalue *)buff; - int slot, size, keysize, tst, cnt; - JudySlot next = *judy->root; - judyvalue value, test = 0; - JudySlot *table; - JudySlot *node; - unsigned int depth = 0; - unsigned int off = 0; - unsigned char *base; +judyvalue *src = (judyvalue *)buff; +int slot, size, keysize, tst, cnt; +JudySlot next = *judy->root; +judyvalue value, test = 0; +JudySlot *table; +JudySlot *node; +unsigned int depth = 0; +unsigned int off = 0; +unsigned char *base; #ifndef ASKITIS judy->level = 0; #endif - while(next) { + while( next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; #endif size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: -#endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - slot = cnt; - value = 0; - - if(judy->depth) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if(off < max) { - value |= buff[off]; - } - } while(++off & JUDY_key_mask); - - // find slot > key - - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + case JUDY_64: +#endif + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + slot = cnt; + value = 0; + + if( judy->depth ) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if( off < max ) + value |= buff[off]; + } while( ++off & JUDY_key_mask ); + + // find slot > key + + while( slot-- ) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if(test <= value) { - break; - } - } + if( test <= value ) + break; + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if(test == value) { + if( test == value ) { - // is this a leaf? + // is this a leaf? - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) + return &node[-slot-1]; - next = node[-slot - 1]; - continue; - } + next = node[-slot-1]; + continue; + } - return NULL; + return NULL; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); // outer radix - if(judy->depth) { - slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { - slot = buff[off++]; - } else { - slot = 0; - } + if( judy->depth ) + slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; + else if( off < max ) + slot = buff[off++]; + else + slot = 0; #ifndef ASKITIS - // put radix slot on judy stack + // put radix slot on judy stack - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if((next = table[slot >> 4])) { - table = (JudySlot *)(next & JUDY_mask); // inner radix - } else { - return NULL; - } + if( (next = table[slot >> 4]) ) + table = (JudySlot *)(next & JUDY_mask); // inner radix + else + return NULL; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) // leaf? - if(table[slot & 0x0F]) { // occupied? - return &table[slot & 0x0F]; - } else { - return NULL; - } + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) // leaf? + if( table[slot & 0x0F] ) // occupied? + return &table[slot & 0x0F]; + else + return NULL; - next = table[slot & 0x0F]; - continue; + next = table[slot & 0x0F]; + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { - tst = max - off; - } - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if(!value && tst < cnt && !base[tst]) { // leaf? - return &node[-1]; - } + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = tst = JUDY_span_bytes; + if( tst > (int)(max - off) ) + tst = max - off; + value = strncmp((const char *)base, (const char *)(buff + off), tst); + if( !value && tst < cnt && !base[tst] ) // leaf? + return &node[-1]; - if(!value && tst == cnt) { - next = node[-1]; - off += cnt; - continue; - } - return NULL; + if( !value && tst == cnt ) { + next = node[-1]; + off += cnt; + continue; + } + return NULL; #endif } } @@ -674,26 +647,26 @@ JudySlot *judy_slot(Judy *judy, unsigned char *buff, unsigned int max) // promote full nodes to next larger size -JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) +JudySlot *judy_promote (Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) { - unsigned char *base = (unsigned char *)(*next & JUDY_mask); - int oldcnt, newcnt, slot; +unsigned char *base = (unsigned char *)(*next & JUDY_mask); +int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif - JudySlot *newnode, *node; - JudySlot *result; - unsigned char *newbase; - unsigned int type; +JudySlot *newnode, *node; +JudySlot *result; +unsigned char *newbase; +unsigned int type; type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); - oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[type-1]); + oldcnt = JudySize[type-1] / (sizeof(JudySlot) + keysize); newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); // promote node to next larger size - newbase = judy_alloc(judy, type); + newbase = judy_alloc (judy, type); newnode = (JudySlot *)(newbase + JudySize[type]); *next = (JudySlot)newbase | type; @@ -701,9 +674,8 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys - for(slot = 0; slot < idx; slot++) { + for( slot = 0; slot < idx; slot++ ) newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr - } // fill in new node @@ -712,9 +684,8 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int #else i = keysize; - while(i--) { - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; - } + while( i-- ) + newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; #endif result = &newnode[-(idx + newcnt - oldcnt)]; @@ -722,15 +693,14 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys - for(; slot < oldcnt; slot++) { + for( ; slot < oldcnt; slot++ ) newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr - } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free(judy, (void **)base, type - 1); + judy_free (judy, (void **)base, type - 1); return result; } @@ -738,18 +708,18 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int // make node with slot - start entries // moving key over one offset -void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) +void judy_radix (Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) { - int size, idx, cnt = slot - start, newcnt; - JudySlot *node, *oldnode; - unsigned int type = JUDY_1 - 1; - JudySlot *table; - unsigned char *base; +int size, idx, cnt = slot - start, newcnt; +JudySlot *node, *oldnode; +unsigned int type = JUDY_1 - 1; +JudySlot *table; +unsigned char *base; // if necessary, setup inner radix node - if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { - table = judy_alloc(judy, JUDY_radix); + if( !(table = (JudySlot *)(radix[key >> 4] & JUDY_mask)) ) { + table = judy_alloc (judy, JUDY_radix); radix[key >> 4] = (JudySlot)table | JUDY_radix; } @@ -757,8 +727,8 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int // is this slot a leaf? - if(!judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { - table[key & 0x0F] = oldnode[-start - 1]; + if( !judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { + table[key & 0x0F] = oldnode[-start-1]; return; } @@ -768,22 +738,22 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int type++; size = JudySize[type]; newcnt = size / (sizeof(JudySlot) + keysize); - } while(cnt > newcnt && type < JUDY_max); + } while( cnt > newcnt && type < JUDY_max ); // store new node pointer in inner table - base = judy_alloc(judy, type); + base = judy_alloc (judy, type); node = (JudySlot *)(base + size); table[key & 0x0F] = (JudySlot)base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for(idx = 0; idx < cnt; idx++) { + for( idx = 0; idx < cnt; idx++ ) { #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); + memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); #else - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); + memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); #endif node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; } @@ -791,132 +761,122 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int // decompose full node to radix nodes -void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) +void judy_splitnode (Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) { - int cnt, slot, start = 0; - unsigned int key = 0x0100, nxt; - JudySlot *newradix; - unsigned char *base; +int cnt, slot, start = 0; +unsigned int key = 0x0100, nxt; +JudySlot *newradix; +unsigned char *base; - base = (unsigned char *)(*next & JUDY_mask); + base = (unsigned char *)(*next & JUDY_mask); cnt = size / (sizeof(JudySlot) + keysize); // allocate outer judy_radix node - newradix = judy_alloc(judy, JUDY_radix); + newradix = judy_alloc (judy, JUDY_radix); *next = (JudySlot)newradix | JUDY_radix; - for(slot = 0; slot < cnt; slot++) { + for( slot = 0; slot < cnt; slot++ ) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if(key > 0xFF) { + if( key > 0xFF ) key = nxt; - } - if(nxt == key) { + if( nxt == key ) continue; - } // decompose portion of old node into radix nodes - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); start = slot; key = nxt; } - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free(judy, (void **)base, JUDY_max); + judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_free (judy, (void **)base, JUDY_max); } // return first leaf -JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_first (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { - JudySlot *table, *inner; - unsigned int keysize, size; - JudySlot *node; - int slot, cnt; - unsigned char *base; - - while(next) { - if(judy->level < judy->max) { +JudySlot *table, *inner; +unsigned int keysize, size; +JudySlot *node; +int slot, cnt; +unsigned char *base; + + while( next ) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].off = off; judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + cnt = size / (sizeof(JudySlot) + keysize); - for(slot = 0; slot < cnt; slot++) - if(node[-slot - 1]) { - break; - } + for( slot = 0; slot < cnt; slot++ ) + if( node[-slot-1] ) + break; - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + return &node[-slot-1]; #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + return &node[-slot-1]; #endif - next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; - continue; - case JUDY_radix: - off++; + next = node[-slot - 1]; + off = (off | JUDY_key_mask) + 1; + continue; + case JUDY_radix: + off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } - - table = (JudySlot *)(next & JUDY_mask); - for(slot = 0; slot < 256; slot++) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { - judy->stack[judy->level].slot = slot; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[slot & 0x0F]; - } else { - break; - } - } - } else { - slot |= 0x0F; - } - continue; -#ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? - return &node[-1]; + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; + + table = (JudySlot *)(next & JUDY_mask); + for( slot = 0; slot < 256; slot++ ) + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( (next = inner[slot & 0x0F]) ) { + judy->stack[judy->level].slot = slot; + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[slot & 0x0F]; + else + break; } - next = node[-1]; - off += cnt; - continue; + } else + slot |= 0x0F; + continue; +#ifndef ASKITIS + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if( !base[cnt - 1] ) // leaf node? + return &node[-1]; + next = node[-1]; + off += cnt; + continue; #endif } } @@ -925,84 +885,79 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d // return last leaf cell pointer -JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_last (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { - JudySlot *table, *inner; - unsigned int keysize, size; - JudySlot *node; - int slot, cnt; - unsigned char *base; - - while(next) { - if(judy->level < judy->max) { +JudySlot *table, *inner; +unsigned int keysize, size; +JudySlot *node; +int slot, cnt; +unsigned char *base; + + while( next ) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - judy->stack[judy->level].slot = --slot; + keysize = JUDY_key_size - (off & JUDY_key_mask); + slot = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) #endif - return &node[-slot - 1]; + return &node[-slot-1]; - next = node[-slot - 1]; - off += keysize; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - off++; + next = node[-slot-1]; + off += keysize; + continue; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + off++; - for(slot = 256; slot--;) { - judy->stack[judy->level].slot = slot; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[0]; - } else { - break; - } - } else { - slot &= 0xF0; - } - } - continue; + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; + + for( slot = 256; slot--; ) { + judy->stack[judy->level].slot = slot; + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( (next = inner[slot & 0x0F]) ) + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[0]; + else + break; + } else + slot &= 0xF0; + } + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? - return &node[-1]; - } - next = node[-1]; - off += cnt; - continue; + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if( !base[cnt - 1] ) // leaf node? + return &node[-1]; + next = node[-1]; + off += cnt; + continue; #endif } } @@ -1011,28 +966,27 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de // judy_end: return last entry -JudySlot *judy_end(Judy *judy) +JudySlot *judy_end (Judy *judy) { judy->level = 0; - return judy_last(judy, *judy->root, 0, 0); + return judy_last (judy, *judy->root, 0, 0); } // judy_nxt: return next entry -JudySlot *judy_nxt(Judy *judy) +JudySlot *judy_nxt (Judy *judy) { - JudySlot *table, *inner; - int slot, size, cnt; - JudySlot *node; - JudySlot next; - unsigned int keysize; - unsigned char *base; - unsigned int depth; - unsigned int off; - - if(!judy->level) { - return judy_first(judy, *judy->root, 0, 0); - } - - while(judy->level) { +JudySlot *table, *inner; +int slot, size, cnt; +JudySlot *node; +JudySlot next; +unsigned int keysize; +unsigned char *base; +unsigned int depth; +unsigned int off; + + if( !judy->level ) + return judy_first (judy, *judy->root, 0, 0); + + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; @@ -1040,62 +994,59 @@ JudySlot *judy_nxt(Judy *judy) size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if(++slot < cnt) + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + if( ++slot < cnt ) #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) -#endif - { - judy->stack[judy->level].slot = slot; - return &node[-slot - 1]; - } else { - judy->stack[judy->level].slot = slot; - return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); - } - judy->level--; - continue; + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) +#endif + { + judy->stack[judy->level].slot = slot; + return &node[-slot - 1]; + } else { + judy->stack[judy->level].slot = slot; + return judy_first (judy, node[-slot-1], (off | JUDY_key_mask) + 1, depth); + } + judy->level--; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { - depth++; - } - - while(++slot < 256) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if(inner[slot & 0x0F]) { - judy->stack[judy->level].slot = slot; - if(!judy->depth || depth < judy->depth) { - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); - } - return &inner[slot & 0x0F]; - } - } else { - slot |= 0x0F; - } + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); - judy->level--; - continue; + if( judy->depth ) + if( !((off+1) & JUDY_key_mask) ) + depth++; + + while( ++slot < 256 ) + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( inner[slot & 0x0F] ) { + judy->stack[judy->level].slot = slot; + if( !judy->depth || depth < judy->depth ) + return judy_first(judy, inner[slot & 0x0F], off + 1, depth); + return &inner[slot & 0x0F]; + } + } else + slot |= 0x0F; + + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1104,80 +1055,77 @@ JudySlot *judy_nxt(Judy *judy) // judy_prv: return ptr to previous entry -JudySlot *judy_prv(Judy *judy) +JudySlot *judy_prv (Judy *judy) { - int slot, size, keysize; - JudySlot *table, *inner; - JudySlot *node, next; - unsigned char *base; - unsigned int depth; - unsigned int off; - - if(!judy->level) { - return judy_last(judy, *judy->root, 0, 0); - } +int slot, size, keysize; +JudySlot *table, *inner; +JudySlot *node, next; +unsigned char *base; +unsigned int depth; +unsigned int off; + + if( !judy->level ) + return judy_last (judy, *judy->root, 0, 0); - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - node = (JudySlot *)((next & JUDY_mask) + size); - if(!slot || !node[-slot]) { - judy->level--; - continue; - } + node = (JudySlot *)((next & JUDY_mask) + size); + if( !slot || !node[-slot] ) { + judy->level--; + continue; + } - base = (unsigned char *)(next & JUDY_mask); - judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); + base = (unsigned char *)(next & JUDY_mask); + judy->stack[judy->level].slot--; + keysize = JUDY_key_size - (off & JUDY_key_mask); #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) -#endif - return &node[-slot]; - return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { - depth++; - } - - while(slot--) { - judy->stack[judy->level].slot--; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) - if(inner[slot & 0x0F]) - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[0]; - } else { - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); - } - } + if( !judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) +#endif + return &node[-slot]; + return judy_last (judy, node[-slot], (off | JUDY_key_mask) + 1, depth); + + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + + if( judy->depth ) + if( !((off + 1) & JUDY_key_mask) ) + depth++; + + while( slot-- ) { + judy->stack[judy->level].slot--; + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) + if( inner[slot & 0x0F] ) + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[0]; + else + return judy_last(judy, inner[slot & 0x0F], off + 1, depth); + } - judy->level--; - continue; + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1187,86 +1135,84 @@ JudySlot *judy_prv(Judy *judy) // judy_del: delete string from judy array // returning previous entry. -JudySlot *judy_del(Judy *judy) +JudySlot *judy_del (Judy *judy) { - int slot, off, size, type, high; - JudySlot *table, *inner; - JudySlot next, *node; - int keysize, cnt; - unsigned char *base; +int slot, off, size, type, high; +JudySlot *table, *inner; +JudySlot next, *node; +int keysize, cnt; +unsigned char *base; - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch(type = next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( type = next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); - // move deleted slot to first slot + // move deleted slot to first slot - while(slot) { - node[-slot - 1] = node[-slot]; - memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); - slot--; - } + while( slot ) { + node[-slot-1] = node[-slot]; + memcpy (base + slot * keysize, base + (slot - 1) * keysize, keysize); + slot--; + } - // zero out first slot + // zero out first slot - node[-1] = 0; - memset(base, 0, keysize); + node[-1] = 0; + memset (base, 0, keysize); - if(node[-cnt]) { // does node have any slots left? - judy->stack[judy->level].slot++; - return judy_prv(judy); - } + if( node[-cnt] ) { // does node have any slots left? + judy->stack[judy->level].slot++; + return judy_prv (judy); + } - judy_free(judy, base, type); - judy->level--; - continue; + judy_free (judy, base, type); + judy->level--; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); - inner[slot & 0x0F] = 0; - high = slot & 0xF0; + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); + inner[slot & 0x0F] = 0; + high = slot & 0xF0; - for(cnt = 16; cnt--;) - if(inner[cnt]) { - return judy_prv(judy); - } + for( cnt = 16; cnt--; ) + if( inner[cnt] ) + return judy_prv (judy); - judy_free(judy, inner, JUDY_radix); - table[slot >> 4] = 0; + judy_free (judy, inner, JUDY_radix); + table[slot >> 4] = 0; - for(cnt = 16; cnt--;) - if(table[cnt]) { - return judy_prv(judy); - } + for( cnt = 16; cnt--; ) + if( table[cnt] ) + return judy_prv (judy); - judy_free(judy, table, JUDY_radix); - judy->level--; - continue; + judy_free (judy, table, JUDY_radix); + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free(judy, base, type); - judy->level--; - continue; + case JUDY_span: + base = (unsigned char *)(next & JUDY_mask); + judy_free (judy, base, type); + judy->level--; + continue; #endif } } @@ -1279,284 +1225,266 @@ JudySlot *judy_del(Judy *judy) // return cell for first key greater than or equal to given key -JudySlot *judy_strt(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_strt (Judy *judy, unsigned char *buff, unsigned int max) { - JudySlot *cell; +JudySlot *cell; judy->level = 0; - if(!max) { - return judy_first(judy, *judy->root, 0, 0); - } + if( !max ) + return judy_first (judy, *judy->root, 0, 0); - if((cell = judy_slot(judy, buff, max))) { + if( (cell = judy_slot (judy, buff, max)) ) return cell; - } - return judy_nxt(judy); + return judy_nxt (judy); } // split open span node #ifndef ASKITIS -void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) +void judy_splitspan (Judy *judy, JudySlot *next, unsigned char *base) { - JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); - unsigned int cnt = JUDY_span_bytes; - unsigned char *newbase; - unsigned int off = 0; +JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); +unsigned int cnt = JUDY_span_bytes; +unsigned char *newbase; +unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN - int i; +int i; #endif do { - newbase = judy_alloc(judy, JUDY_1); + newbase = judy_alloc (judy, JUDY_1); *next = (JudySlot)newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while(i--) { + while( i-- ) *newbase++ = base[off + i]; - } #else - memcpy(newbase, base + off, JUDY_key_size); + memcpy (newbase, base + off, JUDY_key_size); newbase += JUDY_key_size; #endif next = (JudySlot *)newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while(cnt && base[off - 1]); + } while( cnt && base[off - 1] ); *next = node[-1]; - judy_free(judy, base, JUDY_span); + judy_free (judy, base, JUDY_span); } #endif // judy_cell: add string to judy array -JudySlot *judy_cell(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_cell (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *src = (judyvalue *)buff; - int size, idx, slot, cnt, tst; - JudySlot *next = judy->root; - judyvalue test, value; - unsigned int off = 0, start; - JudySlot *table; - JudySlot *node; - unsigned int depth = 0; - unsigned int keysize; - unsigned char *base; +judyvalue *src = (judyvalue *)buff; +int size, idx, slot, cnt, tst; +JudySlot *next = judy->root; +judyvalue test, value; +unsigned int off = 0, start; +JudySlot *table; +JudySlot *node; +unsigned int depth = 0; +unsigned int keysize; +unsigned char *base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while(*next) { + while( *next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch(*next & 0x07) { - default: - size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); - start = off; - slot = cnt; - value = 0; - - if(judy->depth) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if(off < max) { - value |= buff[off]; - } - } while(++off & JUDY_key_mask); - - // find slot > key - - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + switch( *next & 0x07 ) { + default: + size = JudySize[*next & 0x07]; + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + size); + start = off; + slot = cnt; + value = 0; + + if( judy->depth ) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if( off < max ) + value |= buff[off]; + } while( ++off & JUDY_key_mask ); + + // find slot > key + + while( slot-- ) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if(test <= value) { - break; - } - } + if( test <= value ) + break; + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if(test == value) { // new key is equal to slot key - next = &node[-slot - 1]; + if( test == value ) { // new key is equal to slot key + next = &node[-slot-1]; - // is this a leaf? + // is this a leaf? - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } - - continue; + return next; } - // if this node is not full - // open up cell after slot + continue; + } + + // if this node is not full + // open up cell after slot - if(!node[-1]) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot + if( !node[-1] ) { + memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot + memcpy(base + slot * keysize, &value, keysize); // copy new key into slot #else - test = value; - idx = keysize; + test = value; + idx = keysize; - while(idx--) { - base[slot * keysize + idx] = test, test >>= 8; - } + while( idx-- ) + base[slot * keysize + idx] = test, test >>= 8; #endif - for(idx = 0; idx < slot; idx++) { - node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot - } + for( idx = 0; idx < slot; idx++ ) + node[-idx-1] = node[-idx-2];// copy tree ptrs/cells down one slot - node[-slot - 1] = 0; // set new tree ptr/cell - next = &node[-slot - 1]; + node[-slot-1] = 0; // set new tree ptr/cell + next = &node[-slot-1]; - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; - } + continue; + } - if(size < JudySize[JUDY_max]) { - next = judy_promote(judy, next, slot + 1, value, keysize); + if( size < JudySize[JUDY_max] ) { + next = judy_promote (judy, next, slot+1, value, keysize); - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; - } + continue; + } - // split full maximal node into JUDY_radix nodes - // loop to reprocess new insert + // split full maximal node into JUDY_radix nodes + // loop to reprocess new insert - judy_splitnode(judy, next, size, keysize, depth); + judy_splitnode (judy, next, size, keysize, depth); #ifndef ASKITIS - judy->level--; + judy->level--; #endif - off = start; - if(judy->depth) { - depth--; - } - continue; + off = start; + if( judy->depth ) + depth--; + continue; - case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(*next & JUDY_mask); // outer radix - if(judy->depth) { - slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { - slot = buff[off++]; - } else { - slot = 0, off++; - } + if( judy->depth ) + slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; + else if( off < max ) + slot = buff[off++]; + else + slot = 0, off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; - // allocate inner radix if empty + // allocate inner radix if empty - if(!table[slot >> 4]) { - table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; - } + if( !table[slot >> 4] ) + table[slot >> 4] = (JudySlot)judy_alloc (judy, JUDY_radix) | JUDY_radix; - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = (JudySlot *)(table[slot >> 4] & JUDY_mask); #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - next = &table[slot & 0x0F]; + next = &table[slot & 0x0F]; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { // leaf? + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { // leaf? #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); - cnt = JUDY_span_bytes; - tst = cnt; - - if(tst > (int)(max - off)) { - tst = max - off; - } + case JUDY_span: + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); + cnt = JUDY_span_bytes; + tst = cnt; - value = strncmp((const char *)base, (const char *)(buff + off), tst); - - if(!value && tst < cnt && !base[tst]) { // leaf? - return &node[-1]; - } + if( tst > (int)(max - off) ) + tst = max - off; - if(!value && tst == cnt) { - next = &node[-1]; - off += cnt; - continue; - } + value = strncmp((const char *)base, (const char *)(buff + off), tst); - // bust up JUDY_span node and produce JUDY_1 nodes - // then loop to reprocess insert + if( !value && tst < cnt && !base[tst] ) // leaf? + return &node[-1]; - judy_splitspan(judy, next, base); - judy->level--; + if( !value && tst == cnt ) { + next = &node[-1]; + off += cnt; continue; + } + + // bust up JUDY_span node and produce JUDY_1 nodes + // then loop to reprocess insert + + judy_splitspan (judy, next, base); + judy->level--; + continue; #endif } } @@ -1564,109 +1492,102 @@ JudySlot *judy_cell(Judy *judy, unsigned char *buff, unsigned int max) // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if(off & JUDY_key_mask) - if(judy->depth || off <= max) { + if( off & JUDY_key_mask ) + if( judy->depth || off <= max ) { #else - while(off <= max) { + while( off <= max ) { #endif - base = judy_alloc(judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + base = judy_alloc (judy, JUDY_1); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - if(judy->depth) { - value = src[depth]; + if( judy->depth ) { + value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot + memcpy(base, &value, keysize); // copy new key into slot #else - while(keysize--) { - base[keysize] = value, value >>= 8; - } + while( keysize-- ) + base[keysize] = value, value >>= 8; #endif - } else { + } else { #if BYTE_ORDER != BIG_ENDIAN - while(keysize) - if(off + keysize <= max) { - *base++ = buff[off + --keysize]; - } else { - base++, --keysize; - } + while( keysize ) + if( off + keysize <= max ) + *base++ = buff[off + --keysize]; + else + base++, --keysize; #else - tst = keysize; + tst = keysize; - if(tst > (int)(max - off)) { - tst = max - off; - } + if( tst > (int)(max - off) ) + tst = max - off; - memcpy(base, buff + off, tst); + memcpy (base, buff + off, tst); #endif - } + } #ifndef ASKITIS - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; #endif - next = &node[-1]; + next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + off |= JUDY_key_mask; + depth++; + off++; + } // produce span nodes to consume rest of key // or judy_1 nodes if not string tree #ifndef ASKITIS - if(!judy->depth) - while(off <= max) { - base = judy_alloc(judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); - cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { - tst = max - off; - } - memcpy(base, buff + off, tst); + if( !judy->depth ) + while( off <= max ) { + base = judy_alloc (judy, JUDY_span); + *next = (JudySlot)base | JUDY_span; + node = (JudySlot *)(base + JudySize[JUDY_span]); + cnt = tst = JUDY_span_bytes; + if( tst > (int)(max - off) ) + tst = max - off; + memcpy (base, buff + off, tst); + + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off += tst; + depth++; - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off += tst; - depth++; - - if(!base[cnt - 1]) { // done on leaf - break; - } - } else - while(depth < judy->depth) { - base = judy_alloc(judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + if( !base[cnt-1] ) // done on leaf + break; + } + else + while( depth < judy->depth ) { + base = judy_alloc (judy, JUDY_1); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - *(judyvalue *)base = src[depth]; + *(judyvalue *)base = src[depth]; - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off |= JUDY_key_mask; + depth++; + off++; + } #endif #ifdef ASKITIS @@ -1709,203 +1630,195 @@ typedef struct { void *next; // duplicate chain } PennySort; -void sort(FILE *infile, char *outname) +void sort (FILE *infile, char *outname) { - unsigned long long size, off, offset, part; - int ifd = fileno(infile); - char filename[512]; - PennySort *line; - JudySlot *cell; - unsigned char *inbuff; - void *judy; - FILE *out; +unsigned long long size, off, offset, part; +int ifd = fileno (infile); +char filename[512]; +PennySort *line; +JudySlot *cell; +unsigned char *inbuff; +void *judy; +FILE *out; #if defined(_WIN32) - HANDLE hndl, fm; - DWORD hiword; - FILETIME dummy[1]; - FILETIME user[1]; +HANDLE hndl, fm; +DWORD hiword; +FILETIME dummy[1]; +FILETIME user[1]; #else - struct tms buff[1]; +struct tms buff[1]; #endif - time_t start = time(NULL); +time_t start = time(NULL); - if(PennyOff + PennyKey > PennyLine) { - fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); - } + if( PennyOff + PennyKey > PennyLine ) + fprintf (stderr, "Key Offset + Key Length > Record Length\n"), exit(1); - offset = 0; - PennyPasses = 0; + offset = 0; + PennyPasses = 0; #if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize(hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if(!fm) { - fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); - } - size |= (unsigned long long)hiword << 32; + hndl = (HANDLE)_get_osfhandle(ifd); + size = GetFileSize (hndl, &hiword); + fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); + if( !fm ) + fprintf (stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); + size |= (unsigned long long)hiword << 32; #else - size = lseek(ifd, 0L, 2); + size = lseek (ifd, 0L, 2); #endif - while(offset < size) { + while( offset < size ) { #if defined(_WIN32) - part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); - if(!inbuff) { - fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); - } + part = offset + PennyMerge > size ? size - offset : PennyMerge; + inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part); + if( !inbuff ) + fprintf (stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); #else - inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); + inbuff = mmap (NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); - if(inbuff == MAP_FAILED) { - fprintf(stderr, "mmap error %d\n", errno), exit(1); - } + if( inbuff == MAP_FAILED ) + fprintf (stderr, "mmap error %d\n", errno), exit(1); - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { - fprintf(stderr, "madvise error %d\n", errno); - } + if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0 ) + fprintf (stderr, "madvise error %d\n", errno); #endif - judy = judy_open(PennyKey, 0); + judy = judy_open (PennyKey, 0); - off = 0; + off = 0; - // build judy array from mapped input chunk + // build judy array from mapped input chunk - while(offset + off < size && off < PennyMerge) { - line = judy_data(judy, sizeof(PennySort)); - cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; - line->buff = inbuff + off; + while( offset + off < size && off < PennyMerge ) { + line = judy_data (judy, sizeof(PennySort)); + cell = judy_cell (judy, inbuff + off + PennyOff, PennyKey); + line->next = *(void **)cell; + line->buff = inbuff + off; - *(PennySort **)cell = line; - off += PennyLine; - } + *(PennySort **)cell = line; + off += PennyLine; + } - sprintf(filename, "%s.%d", outname, PennyPasses); - out = fopen(filename, "wb"); - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + sprintf (filename, "%s.%d", outname, PennyPasses); + out = fopen (filename, "wb"); + setvbuf (out, NULL, _IOFBF, 4096 * 1024); #ifndef _WIN32 - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { - fprintf(stderr, "madvise error %d\n", errno); - } + if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0 ) + fprintf (stderr, "madvise error %d\n", errno); #endif - // write judy array in sorted order to temporary file + // write judy array in sorted order to temporary file - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - line = *(PennySort **)cell; - do { - fwrite(line->buff, PennyLine, 1, out); - } while(line = line->next); - } while(cell = judy_nxt(judy)); + if( cell ) do { + line = *(PennySort **)cell; + do fwrite (line->buff, PennyLine, 1, out); + while( line = line->next ); + } while( cell = judy_nxt (judy) ); #if defined(_WIN32) - UnmapViewOfFile(inbuff); + UnmapViewOfFile (inbuff); #else - munmap(inbuff, PennyMerge); -#endif - judy_close(judy); - offset += off; - fflush(out); - fclose(out); - PennyPasses++; - } - fprintf(stderr, "End Sort %d secs", time(NULL) - start); + munmap (inbuff, PennyMerge); +#endif + judy_close (judy); + offset += off; + fflush (out); + fclose (out); + PennyPasses++; + } + fprintf (stderr, "End Sort %d secs", time(NULL) - start); #if defined(_WIN32) - CloseHandle(fm); - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long *)user / 10000000; + CloseHandle (fm); + GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); + PennySortTime = *(unsigned long long*)user / 10000000; #else - times(buff); - PennySortTime = buff->tms_utime / 100; + times (buff); + PennySortTime = buff->tms_utime/100; #endif - fprintf(stderr, " Cpu %d\n", PennySortTime); + fprintf (stderr, " Cpu %d\n", PennySortTime); } -int merge(FILE *out, char *outname) +int merge (FILE *out, char *outname) { - time_t start = time(NULL); - char filename[512]; - JudySlot *cell; - unsigned int nxt, idx; - unsigned char **line; - unsigned int *next; - void *judy; - FILE **in; +time_t start = time(NULL); +char filename[512]; +JudySlot *cell; +unsigned int nxt, idx; +unsigned char **line; +unsigned int *next; +void *judy; +FILE **in; - next = calloc(PennyPasses + 1, sizeof(unsigned int)); - line = calloc(PennyPasses, sizeof(void *)); - in = calloc(PennyPasses, sizeof(void *)); + next = calloc (PennyPasses + 1, sizeof(unsigned int)); + line = calloc (PennyPasses, sizeof(void *)); + in = calloc (PennyPasses, sizeof(void *)); - judy = judy_open(PennyKey, 0); + judy = judy_open (PennyKey, 0); // initialize merge with one record from each temp file - for(idx = 0; idx < PennyPasses; idx++) { - sprintf(filename, "%s.%d", outname, idx); - in[idx] = fopen(filename, "rb"); - line[idx] = malloc(PennyLine); - setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); - fread(line[idx], PennyLine, 1, in[idx]); - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + for( idx = 0; idx < PennyPasses; idx++ ) { + sprintf (filename, "%s.%d", outname, idx); + in[idx] = fopen (filename, "rb"); + line[idx] = malloc (PennyLine); + setvbuf (in[idx], NULL, _IOFBF, 4096 * 1024); + fread (line[idx], PennyLine, 1, in[idx]); + cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; } // output records, replacing smallest each time - while(cell = judy_strt(judy, NULL, 0)) { + while( cell = judy_strt (judy, NULL, 0) ) { nxt = *(unsigned int *)cell; - judy_del(judy); + judy_del (judy); // process duplicates - while(idx = nxt) { + while( idx = nxt ) { nxt = next[idx--]; - fwrite(line[idx], PennyLine, 1, out); + fwrite (line[idx], PennyLine, 1, out); - if(fread(line[idx], PennyLine, 1, in[idx])) { - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + if( fread (line[idx], PennyLine, 1, in[idx]) ) { + cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; - } else { + } else next[idx + 1] = 0; - } } } - for(idx = 0; idx < PennyPasses; idx++) { - fclose(in[idx]); - free(line[idx]); + for( idx = 0; idx < PennyPasses; idx++ ) { + fclose (in[idx]); + free (line[idx]); } - free(line); - free(next); - free(in); + free (line); + free (next); + free (in); - fprintf(stderr, "End Merge %d secs", time(NULL) - start); + fprintf (stderr, "End Merge %d secs", time(NULL) - start); #ifdef _WIN32 { - FILETIME dummy[1]; - FILETIME user[1]; - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long *)user / 10000000; + FILETIME dummy[1]; + FILETIME user[1]; + GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); + PennyMergeTime = *(unsigned long long*)user / 10000000; } #else { - struct tms buff[1]; - times(buff); - PennyMergeTime = buff->tms_utime / 100; + struct tms buff[1]; + times (buff); + PennyMergeTime = buff->tms_utime/100; } #endif - fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close(judy); - fflush(out); - fclose(out); + fprintf (stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); + judy_close (judy); + fflush (out); + fclose (out); return 0; } @@ -1938,78 +1851,71 @@ typedef struct timeval timer; // Also, the file to search judy is hardcoded to skew1_1. -int main(int argc, char **argv) +int main (int argc, char **argv) { - unsigned char buff[1024]; - JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; - unsigned int len; - unsigned int idx; +unsigned char buff[1024]; +JudySlot max = 0; +JudySlot *cell; +FILE *in, *out; +void *judy; +unsigned int len; +unsigned int idx; #ifdef ASKITIS - char *askitis; - int prev, off; - float insert_real_time = 0.0; - float search_real_time = 0.0; - int size; +char *askitis; +int prev, off; +float insert_real_time=0.0; +float search_real_time=0.0; +int size; #if !defined(_WIN32) - timer start, stop; +timer start, stop; #else - time_t start[1], stop[1]; +time_t start[1], stop[1]; #endif #endif - if(argc > 1) { - in = fopen(argv[1], "rb"); - } else { + if( argc > 1 ) + in = fopen (argv[1], "rb"); + else in = stdin; - } - if(argc > 2) { - out = fopen(argv[2], "wb"); - } else { + if( argc > 2 ) + out = fopen (argv[2], "wb"); + else out = stdout; - } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf (out, NULL, _IOFBF, 4096 * 1024); - if(!in) { - fprintf(stderr, "unable to open input file\n"); - } + if( !in ) + fprintf (stderr, "unable to open input file\n"); - if(!out) { - fprintf(stderr, "unable to open output file\n"); - } + if( !out ) + fprintf (stderr, "unable to open output file\n"); - if(argc > 6) { + if( argc > 6 ) PennyRecs = atoi(argv[6]); - } - if(argc > 5) { + if( argc > 5 ) PennyOff = atoi(argv[5]); - } - if(argc > 4) { + if( argc > 4 ) PennyLine = atoi(argv[4]); - } PennyMerge = (unsigned long long)PennyLine * PennyRecs; - if(argc > 3) { + if( argc > 3 ) { PennyKey = atoi(argv[3]); - sort(in, argv[2]); - return merge(out, argv[2]); + sort (in, argv[2]); + return merge (out, argv[2]); } #ifdef ASKITIS - judy = judy_open(1024, 0); + judy = judy_open (1024, 0); // build judy array - size = lseek(fileno(in), 0L, 2); + size = lseek (fileno(in), 0L, 2); askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + lseek (fileno(in), 0L, 0); + read (fileno(in), askitis,size); prev = 0; // naskitis.com: // Start the timer. @@ -2020,29 +1926,29 @@ int main(int argc, char **argv) time(start); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string - prev = off + 1; - } + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *(judy_cell (judy, askitis+prev, off - prev)) += 1; // count instances of string + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); - insert_real_time = insert_real_time / 1000.0; + insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * (stop.tv_usec - start.tv_usec ); + insert_real_time = insert_real_time/1000.0; #else - time(stop); + time (stop); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free(askitis); + free (askitis); fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); + "Judy Array size:", MaxMem/1000000., "Time to insert:", insert_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); @@ -2052,14 +1958,13 @@ int main(int argc, char **argv) Found = 0; // search judy array - if(in = freopen("skew1_1", "rb", in)) { - size = lseek(fileno(in), 0L, 2); - } else { + if( in = freopen ("skew1_1", "rb", in) ) + size = lseek (fileno(in), 0L, 2); + else exit(0); - } askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + lseek (fileno(in), 0L, 0); + read (fileno(in), askitis,size); prev = 0; #if !defined(_WIN32) @@ -2068,19 +1973,19 @@ int main(int argc, char **argv) time(start); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *judy_cell(judy, askitis + prev, off - prev) += 1; - prev = off + 1; - } + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *judy_cell (judy, askitis+prev, off - prev) += 1; + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 - * (stop.tv_usec - start.tv_usec); - search_real_time = search_real_time / 1000.0; + search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 + * (stop.tv_usec - start.tv_usec ); + search_real_time = search_real_time/1000.0; #else time(stop); search_real_time = *stop - *start; @@ -2089,91 +1994,88 @@ int main(int argc, char **argv) // naskitis.com: // To do: report a count on the number of strings found. - fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); + fprintf(stderr,"\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem/1000000., "Time to search:", search_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); exit(0); #endif #ifdef HEXKEYS - judy = judy_open(1024, 16 / JUDY_key_size); + judy = judy_open (1024, 16/JUDY_key_size); - while(fgets((char *)buff, sizeof(buff), in)) { - judyvalue key[16 / JUDY_key_size]; - if(len = strlen((const char *)buff)) { - buff[--len] = 0; // remove LF - } + while( fgets((char *)buff, sizeof(buff), in) ) { + judyvalue key[16/JUDY_key_size]; + if( len = strlen((const char *)buff) ) + buff[--len] = 0; // remove LF #if JUDY_key_size == 4 - key[3] = strtoul(buff + 24, NULL, 16); + key[3] = strtoul (buff + 24, NULL, 16); buff[24] = 0; - key[2] = strtoul(buff + 16, NULL, 16); + key[2] = strtoul (buff + 16, NULL, 16); buff[16] = 0; - key[1] = strtoul(buff + 8, NULL, 16); + key[1] = strtoul (buff + 8, NULL, 16); buff[8] = 0; - key[0] = strtoul(buff, NULL, 16); + key[0] = strtoul (buff, NULL, 16); #else - key[1] = strtoull(buff + 16, NULL, 16); + key[1] = strtoull (buff + 16, NULL, 16); buff[16] = 0; - key[0] = strtoull(buff, NULL, 16); + key[0] = strtoull (buff, NULL, 16); #endif - *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string + *(judy_cell (judy, (void *)key, 0)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - judyvalue key[16 / JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates + if( cell ) do { + judyvalue key[16/JUDY_key_size]; + len = judy_key(judy, (void *)key, 0); + for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates #if JUDY_key_size == 4 - fprintf(out, "%.8X", key[0]); - fprintf(out, "%.8X", key[1]); - fprintf(out, "%.8X", key[2]); - fprintf(out, "%.8X", key[3]); + fprintf (out, "%.8X", key[0]); + fprintf (out, "%.8X", key[1]); + fprintf (out, "%.8X", key[2]); + fprintf (out, "%.8X", key[3]); #else - fprintf(out, "%.16llX", key[0]); - fprintf(out, "%.16llX", key[1]); + fprintf (out, "%.16llX", key[0]); + fprintf (out, "%.16llX", key[1]); #endif - fputc('\n', out); - } - } while(cell = judy_nxt(judy)); + fputc('\n', out); + } + } while( cell = judy_nxt (judy) ); #else - judy = judy_open(1024, 0); + judy = judy_open (1024, 0); - while(fgets((char *)buff, sizeof(buff), in)) { - if(len = strlen((const char *)buff)) { - buff[--len] = 0; // remove LF - } - *(judy_cell(judy, buff, len)) += 1; // count instances of string + while( fgets((char *)buff, sizeof(buff), in) ) { + if( len = strlen((const char *)buff) ) + buff[--len] = 0; // remove LF + *(judy_cell (judy, buff, len)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - len = judy_key(judy, buff, sizeof(buff)); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); - } - } while(cell = judy_nxt(judy)); + if( cell ) do { + len = judy_key(judy, buff, sizeof(buff)); + for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates + fwrite(buff, len, 1, out); + fputc('\n', out); + } + } while( cell = judy_nxt (judy) ); #endif #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) - do { - max -= *cell; - } while(cell = judy_del(judy)); + if( cell = judy_prv (judy) ) + do max -= *cell; + while( cell = judy_del (judy) ); - assert(max == 0); + assert (max == 0); #endif judy_close(judy); return 0; diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index 54d14c776..45e0cba44 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -70,25 +70,24 @@ extern unsigned int MaxMem; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort(char *msg) -{ - fprintf(stderr, "%s\n", msg); - exit(1); +void judy_abort( char * msg ) { + fprintf( stderr, "%s\n", msg ); + exit( 1 ); } #endif int JudySize[] = { - (JUDY_slot_size * 16), // JUDY_radix node size - (JUDY_slot_size + JUDY_key_size), // JUDY_1 node size - (2 * JUDY_slot_size + 2 * JUDY_key_size), - (4 * JUDY_slot_size + 4 * JUDY_key_size), - (8 * JUDY_slot_size + 8 * JUDY_key_size), - (16 * JUDY_slot_size + 16 * JUDY_key_size), - (32 * JUDY_slot_size + 32 * JUDY_key_size), + ( JUDY_slot_size * 16 ), // JUDY_radix node size + ( JUDY_slot_size + JUDY_key_size ), // JUDY_1 node size + ( 2 * JUDY_slot_size + 2 * JUDY_key_size ), + ( 4 * JUDY_slot_size + 4 * JUDY_key_size ), + ( 8 * JUDY_slot_size + 8 * JUDY_key_size ), + ( 16 * JUDY_slot_size + 16 * JUDY_key_size ), + ( 32 * JUDY_slot_size + 32 * JUDY_key_size ), #ifndef ASKITIS - (JUDY_span_bytes + JUDY_slot_size) + ( JUDY_span_bytes + JUDY_slot_size ) #else - (64 * JUDY_slot_size + 64 * JUDY_key_size) + ( 64 * JUDY_slot_size + 64 * JUDY_key_size ) #endif }; @@ -103,28 +102,27 @@ judyvalue JudyMask[9] = { // call with max key size // and Integer tree depth. -Judy *judy_open(unsigned int max, unsigned int depth) -{ - JudySeg *seg; - Judy *judy; +Judy * judy_open( unsigned int max, unsigned int depth ) { + JudySeg * seg; + Judy * judy; unsigned int amt; max++; // allow for zero terminator on keys - if((seg = malloc(JUDY_seg))) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("No virtual memory"); + judy_abort( "No virtual memory" ); #else return NULL; #endif } - amt = sizeof(Judy) + max * sizeof(JudyStack); + amt = sizeof( Judy ) + max * sizeof( JudyStack ); - if(amt & (JUDY_cache_line - 1)) { + if( amt & ( JUDY_cache_line - 1 ) ) { amt |= JUDY_cache_line - 1, amt++; } @@ -132,92 +130,90 @@ Judy *judy_open(unsigned int max, unsigned int depth) MaxMem += JUDY_seg; #endif - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); seg->next -= amt; - judy = (Judy *)((unsigned char *)seg + seg->next); - memset(judy, 0, amt); + judy = ( Judy * )( ( unsigned char * )seg + seg->next ); + memset( judy, 0, amt ); judy->depth = depth; judy->seg = seg; judy->max = max; return judy; } -void judy_close(Judy *judy) -{ - JudySeg *seg, *nxt = judy->seg; +void judy_close( Judy * judy ) { + JudySeg * seg, *nxt = judy->seg; - while((seg = nxt)) { - nxt = seg->seg, free(seg); + while( ( seg = nxt ) ) { + nxt = seg->seg, free( seg ); } } // allocate judy node -void *judy_alloc(Judy *judy, unsigned int type) -{ +void * judy_alloc( Judy * judy, unsigned int type ) { unsigned int amt, idx, min; - JudySeg *seg; - void **block; - void **rtn; + JudySeg * seg; + void ** block; + void ** rtn; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort( "illegal allocation from judy clone" ); #else return NULL; #endif - if(type == JUDY_radix) { + if( type == JUDY_radix ) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) { type = JUDY_span_equiv; } #endif amt = JudySize[type]; - if(amt & 0x07) { + if( amt & 0x07 ) { amt |= 0x07, amt += 1; } // see if free block is already available - if((block = judy->reuse[type])) { + if( ( block = judy->reuse[type] ) ) { judy->reuse[type] = *block; - memset(block, 0, amt); - return (void *)block; + memset( block, 0, amt ); + return ( void * )block; } // break down available larger block // for reuse into smaller blocks - if(type >= JUDY_1) - for(idx = type; idx++ < JUDY_max;) - if((block = judy->reuse[idx])) { + if( type >= JUDY_1 ) + for( idx = type; idx++ < JUDY_max; ) + if( (block = judy->reuse[idx]) ) { judy->reuse[idx] = *block; - while(idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; + while( idx-- > type ) { + judy->reuse[idx] = block + JudySize[idx] / sizeof( void * ); + block[JudySize[idx] / sizeof( void * )] = 0; } - memset(block, 0, amt); - return (void *)block; + memset( block, 0, amt ); + return ( void * )block; } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if(judy->seg->next < min + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < min + sizeof( *seg ) ) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); + judy_abort( "Out of virtual memory" ); #else return NULL; #endif @@ -231,45 +227,45 @@ void *judy_alloc(Judy *judy, unsigned int type) // generate additional free blocks // to fill up to cache line size - rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); + rtn = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - amt ); - for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { - block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); + for( idx = type; amt & ( JUDY_cache_line - 1 ); amt <<= 1 ) { + block = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - 2 * amt ); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset(rtn, 0, JudySize[type]); - return (void *)rtn; + memset( rtn, 0, JudySize[type] ); + return ( void * )rtn; } -void *judy_data(Judy *judy, unsigned int amt) +void * judy_data( Judy * judy, unsigned int amt ) { - JudySeg *seg; - void *block; + JudySeg * seg; + void * block; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort( "illegal allocation from judy clone" ); #else return NULL; #endif - if(amt & (JUDY_cache_line - 1)) { - amt |= (JUDY_cache_line - 1), amt += 1; + if( amt & ( JUDY_cache_line - 1 ) ) { + amt |= ( JUDY_cache_line - 1 ), amt += 1; } - if(judy->seg->next < amt + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < amt + sizeof( *seg ) ) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); + judy_abort( "Out of virtual memory" ); #else return NULL; #endif @@ -282,68 +278,65 @@ void *judy_data(Judy *judy, unsigned int amt) judy->seg->next -= amt; - block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset(block, 0, amt); + block = ( void * )( ( unsigned char * )judy->seg + judy->seg->next ); + memset( block, 0, amt ); return block; } -Judy *judy_clone(Judy *judy) -{ - Judy *clone; +Judy * judy_clone( Judy * judy ) { + Judy * clone; unsigned int amt; - amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data(judy, amt); - memcpy(clone, judy, amt); + amt = sizeof( Judy ) + judy->max * sizeof( JudyStack ); + clone = judy_data( judy, amt ); + memcpy( clone, judy, amt ); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free(Judy *judy, void *block, int type) -{ - if(type == JUDY_radix) { +void judy_free( Judy * judy, void * block, int type ) { + if( type == JUDY_radix ) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) { type = JUDY_span_equiv; } #endif - *((void **)(block)) = judy->reuse[type]; - judy->reuse[type] = (void **)block; + *( ( void ** )( block ) ) = judy->reuse[type]; + judy->reuse[type] = ( void ** )block; return; } // assemble key from current path -unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) -{ - judyvalue *dest = (judyvalue *)buff; +unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { + judyvalue * dest = ( judyvalue * )buff; unsigned int len = 0, idx = 0, depth; int slot, off, type; judyvalue value; - unsigned char *base; + unsigned char * base; int keysize; - if(judy->depth) { + if( judy->depth ) { max = judy->depth * JUDY_key_size; } else { max--; // leave room for zero terminator } - while(len < max && ++idx <= judy->level) { + while( len < max && ++idx <= judy->level ) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if(judy->depth) - if(!(len & JUDY_key_mask)) { + if( judy->depth ) + if( !( len & JUDY_key_mask ) ) { dest[depth] = 0; } - switch(type) { + switch( type ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -353,16 +346,16 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + keysize = JUDY_key_size - ( judy->stack[idx].off & JUDY_key_mask ); + base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); - if(judy->depth) { - value = *(judyvalue *)(base + slot * keysize); + if( judy->depth ) { + value = *( judyvalue * )( base + slot * keysize ); value &= JudyMask[keysize]; dest[depth++] |= value; len += keysize; - if(depth < judy->depth) { + if( depth < judy->depth ) { continue; } @@ -372,15 +365,15 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) #if BYTE_ORDER != BIG_ENDIAN off = keysize; - while(off-- && len < max) - if((buff[len] = base[slot * keysize + off])) { + while( off-- && len < max ) + if( (buff[len] = base[slot * keysize + off]) ) { len++; } else { break; } #else - for(off = 0; off < keysize && len < max; off++) - if(buff[len] = base[slot * keysize + off]) { + for( off = 0; off < keysize && len < max; off++ ) + if( buff[len] = base[slot * keysize + off] ) { len++; } else { break; @@ -389,30 +382,30 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) continue; case JUDY_radix: - if(judy->depth) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if(!(len & JUDY_key_mask)) { + if( judy->depth ) { + dest[depth] |= ( judyvalue )slot << ( JUDY_key_size - ( ++len & JUDY_key_mask ) ) * 8; + if( !( len & JUDY_key_mask ) ) { depth++; } - if(depth < judy->depth) { + if( depth < judy->depth ) { continue; } return len; } - if(!slot) { + if( !slot ) { break; } - buff[len++] = (unsigned char)slot; + buff[len++] = ( unsigned char )slot; continue; #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); - for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) - if(len < max) { + for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) + if( len < max ) { buff[len++] = base[slot]; } continue; @@ -425,25 +418,24 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) // find slot & setup cursor -JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) -{ - judyvalue *src = (judyvalue *)buff; +JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ) { + judyvalue * src = ( judyvalue * )buff; int slot, size, keysize, tst, cnt; JudySlot next = *judy->root; judyvalue value, test = 0; - JudySlot *table; - JudySlot *node; + JudySlot * table; + JudySlot * node; unsigned int depth = 0; unsigned int off = 0; - unsigned char *base; + unsigned char * base; #ifndef ASKITIS judy->level = 0; #endif - while(next) { + while( next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } @@ -452,7 +444,7 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #endif size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: @@ -463,14 +455,14 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #ifdef ASKITIS case JUDY_64: #endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); + base = ( unsigned char * )( next & JUDY_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); slot = cnt; value = 0; - if(judy->depth) { + if( judy->depth ) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -478,32 +470,32 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) } else do { value <<= 8; - if(off < max) { + if( off < max ) { value |= buff[off]; } - } while(++off & JUDY_key_mask); + } while( ++off & JUDY_key_mask ); // find slot > key - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + while( slot-- ) { + test = *( judyvalue * )( base + slot * keysize ); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * ( JUDY_key_size - keysize ); #else test &= JudyMask[keysize]; #endif - if(test <= value) { + if( test <= value ) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if(test == value) { + if( test == value ) { // is this a leaf? - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { return &node[-slot - 1]; } @@ -514,11 +506,11 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) return NULL; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix + table = ( JudySlot * )( next & JUDY_mask ); // outer radix - if(judy->depth) { - slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { + if( judy->depth ) { + slot = ( src[depth] >> ( (( JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; + } else if( off < max ) { slot = buff[off++]; } else { slot = 0; @@ -528,19 +520,19 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) judy->stack[judy->level].slot = slot; #endif - if((next = table[slot >> 4])) { - table = (JudySlot *)(next & JUDY_mask); // inner radix + if( ( next = table[slot >> 4] ) ) { + table = ( JudySlot * )( next & JUDY_mask ); // inner radix } else { return NULL; } - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? - if(table[slot & 0x0F]) { // occupied? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? + if( table[slot & 0x0F] ) { // occupied? return &table[slot & 0x0F]; } else { return NULL; @@ -552,18 +544,18 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if(!value && tst < cnt && !base[tst]) { // leaf? + value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); + if( !value && tst < cnt && !base[tst] ) { // leaf? return &node[-1]; } - if(!value && tst == cnt) { + if( !value && tst == cnt ) { next = node[-1]; off += cnt; continue; @@ -578,63 +570,62 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) // promote full nodes to next larger size -JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) -{ - unsigned char *base = (unsigned char *)(*next & JUDY_mask); +JudySlot * judy_promote( Judy * judy, JudySlot * next, int idx, judyvalue value, int keysize ) { + unsigned char * base = ( unsigned char * )( *next & JUDY_mask ); int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif - JudySlot *newnode, *node; - JudySlot *result; - unsigned char *newbase; + JudySlot * newnode, *node; + JudySlot * result; + unsigned char * newbase; unsigned int type; - type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); - oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); - newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); + type = ( *next & 0x07 ) + 1; + node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[type - 1] ); + oldcnt = JudySize[type - 1] / ( sizeof( JudySlot ) + keysize ); + newcnt = JudySize[type] / ( sizeof( JudySlot ) + keysize ); // promote node to next larger size - newbase = judy_alloc(judy, type); - newnode = (JudySlot *)(newbase + JudySize[type]); - *next = (JudySlot)newbase | type; + newbase = judy_alloc( judy, type ); + newnode = ( JudySlot * )( newbase + JudySize[type] ); + *next = ( JudySlot )newbase | type; // open up slot at idx - memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys + memcpy( newbase + ( newcnt - oldcnt - 1 ) * keysize, base, idx * keysize ); // copy keys - for(slot = 0; slot < idx; slot++) { - newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr + for( slot = 0; slot < idx; slot++ ) { + newnode[-( slot + newcnt - oldcnt )] = node[-( slot + 1 )]; // copy ptr } // fill in new node #if BYTE_ORDER != BIG_ENDIAN - memcpy(newbase + (idx + newcnt - oldcnt - 1) * keysize, &value, keysize); // copy key + memcpy( newbase + ( idx + newcnt - oldcnt - 1 ) * keysize, &value, keysize ); // copy key #else i = keysize; - while(i--) { - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; + while( i-- ) { + newbase[( idx + newcnt - oldcnt - 1 ) * keysize + i] = value, value >>= 8; } #endif - result = &newnode[-(idx + newcnt - oldcnt)]; + result = &newnode[-( idx + newcnt - oldcnt )]; // copy rest of old node - memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys + memcpy( newbase + ( idx + newcnt - oldcnt ) * keysize, base + ( idx * keysize ), ( oldcnt - slot ) * keysize ); // copy keys - for(; slot < oldcnt; slot++) { - newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr + for( ; slot < oldcnt; slot++ ) { + newnode[-( slot + newcnt - oldcnt + 1 )] = node[-( slot + 1 )]; // copy ptr } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free(judy, (void **)base, type - 1); + judy_free( judy, ( void ** )base, type - 1 ); return result; } @@ -642,26 +633,25 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int // make node with slot - start entries // moving key over one offset -void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) -{ +void judy_radix( Judy * judy, JudySlot * radix, unsigned char * old, int start, int slot, int keysize, unsigned char key, unsigned int depth ) { int size, idx, cnt = slot - start, newcnt; - JudySlot *node, *oldnode; + JudySlot * node, *oldnode; unsigned int type = JUDY_1 - 1; - JudySlot *table; - unsigned char *base; + JudySlot * table; + unsigned char * base; // if necessary, setup inner radix node - if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { - table = judy_alloc(judy, JUDY_radix); - radix[key >> 4] = (JudySlot)table | JUDY_radix; + if( !( table = ( JudySlot * )( radix[key >> 4] & JUDY_mask ) ) ) { + table = judy_alloc( judy, JUDY_radix ); + radix[key >> 4] = ( JudySlot )table | JUDY_radix; } - oldnode = (JudySlot *)(old + JudySize[JUDY_max]); + oldnode = ( JudySlot * )( old + JudySize[JUDY_max] ); // is this slot a leaf? - if((!judy->depth && (!key || !keysize)) || (judy->depth && !keysize && depth == judy->depth)) { + if( (!judy->depth && ( !key || !keysize )) || (judy->depth && !keysize && depth == judy->depth) ) { table[key & 0x0F] = oldnode[-start - 1]; return; } @@ -671,82 +661,80 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int do { type++; size = JudySize[type]; - newcnt = size / (sizeof(JudySlot) + keysize); - } while(cnt > newcnt && type < JUDY_max); + newcnt = size / ( sizeof( JudySlot ) + keysize ); + } while( cnt > newcnt && type < JUDY_max ); // store new node pointer in inner table - base = judy_alloc(judy, type); - node = (JudySlot *)(base + size); - table[key & 0x0F] = (JudySlot)base | type; + base = judy_alloc( judy, type ); + node = ( JudySlot * )( base + size ); + table[key & 0x0F] = ( JudySlot )base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for(idx = 0; idx < cnt; idx++) { + for( idx = 0; idx < cnt; idx++ ) { #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); + memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ), keysize ); #else - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); + memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ) + 1, keysize ); #endif - node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; + node[-( newcnt - idx )] = oldnode[-( start + cnt - idx )]; } } // decompose full node to radix nodes -void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) -{ +void judy_splitnode( Judy * judy, JudySlot * next, unsigned int size, unsigned int keysize, unsigned int depth ) { int cnt, slot, start = 0; unsigned int key = 0x0100, nxt; - JudySlot *newradix; - unsigned char *base; + JudySlot * newradix; + unsigned char * base; - base = (unsigned char *)(*next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + base = ( unsigned char * )( *next & JUDY_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); // allocate outer judy_radix node - newradix = judy_alloc(judy, JUDY_radix); - *next = (JudySlot)newradix | JUDY_radix; + newradix = judy_alloc( judy, JUDY_radix ); + *next = ( JudySlot )newradix | JUDY_radix; - for(slot = 0; slot < cnt; slot++) { + for( slot = 0; slot < cnt; slot++ ) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if(key > 0xFF) { + if( key > 0xFF ) { key = nxt; } - if(nxt == key) { + if( nxt == key ) { continue; } // decompose portion of old node into radix nodes - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); start = slot; key = nxt; } - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free(judy, (void **)base, JUDY_max); + judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); + judy_free( judy, ( void ** )base, JUDY_max ); } // return first leaf -JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ - JudySlot *table, *inner; +JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { + JudySlot * table, *inner; unsigned int keysize, size; - JudySlot *node; + JudySlot * node; int slot, cnt; - unsigned char *base; + unsigned char * base; - while(next) { - if(judy->level < judy->max) { + while( next ) { + if( judy->level < judy->max ) { judy->level++; } @@ -754,7 +742,7 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -764,43 +752,43 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); - for(slot = 0; slot < cnt; slot++) - if(node[-slot - 1]) { + for( slot = 0; slot < cnt; slot++ ) + if( node[-slot - 1] ) { break; } judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) { + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) { return &node[-slot - 1]; } #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) { return &node[-slot - 1]; } #endif next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; + off = ( off | JUDY_key_mask ) + 1; continue; case JUDY_radix: off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - table = (JudySlot *)(next & JUDY_mask); - for(slot = 0; slot < 256; slot++) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { + table = ( JudySlot * )( next & JUDY_mask ); + for( slot = 0; slot < 256; slot++ ) + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( ( next = inner[slot & 0x0F] ) ) { judy->stack[judy->level].slot = slot; - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[slot & 0x0F]; } else { break; @@ -812,10 +800,10 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d continue; #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? + if( !base[cnt - 1] ) { // leaf node? return &node[-1]; } next = node[-1]; @@ -829,23 +817,22 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d // return last leaf cell pointer -JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ - JudySlot *table, *inner; +JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { + JudySlot * table, *inner; unsigned int keysize, size; - JudySlot *node; + JudySlot * node; int slot, cnt; - unsigned char *base; + unsigned char * base; - while(next) { - if(judy->level < judy->max) { + while( next ) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -855,16 +842,16 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + slot = size / ( sizeof( JudySlot ) + keysize ); + base = ( unsigned char * )( next & JUDY_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth ) #endif return &node[-slot - 1]; @@ -873,19 +860,19 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - for(slot = 256; slot--;) { + for( slot = 256; slot--; ) { judy->stack[judy->level].slot = slot; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( ( next = inner[slot & 0x0F] ) ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { break; @@ -899,10 +886,10 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? + if( !base[cnt - 1] ) { // leaf node? return &node[-1]; } next = node[-1]; @@ -916,37 +903,35 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de // judy_end: return last entry -JudySlot *judy_end(Judy *judy) -{ +JudySlot * judy_end( Judy * judy ) { judy->level = 0; - return judy_last(judy, *judy->root, 0, 0); + return judy_last( judy, *judy->root, 0, 0 ); } // judy_nxt: return next entry -JudySlot *judy_nxt(Judy *judy) -{ - JudySlot *table, *inner; +JudySlot * judy_nxt( Judy * judy ) { + JudySlot * table, *inner; int slot, size, cnt; - JudySlot *node; + JudySlot * node; JudySlot next; unsigned int keysize; - unsigned char *base; + unsigned char * base; unsigned int depth; unsigned int off; - if(!judy->level) { - return judy_first(judy, *judy->root, 0, 0); + if( !judy->level ) { + return judy_first( judy, *judy->root, 0, 0 ); } - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; - keysize = JUDY_key_size - (off & JUDY_key_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -956,40 +941,40 @@ JudySlot *judy_nxt(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if(++slot < cnt) { + cnt = size / ( sizeof( JudySlot ) + keysize ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); + if( ++slot < cnt ) { #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif { judy->stack[judy->level].slot = slot; return &node[-slot - 1]; } else { judy->stack[judy->level].slot = slot; - return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); + return judy_first( judy, node[-slot - 1], ( off | JUDY_key_mask ) + 1, depth ); } } judy->level--; continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { + if( judy->depth ) + if( !( ( off + 1 ) & JUDY_key_mask ) ) { depth++; } - while(++slot < 256) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if(inner[slot & 0x0F]) { + while( ++slot < 256 ) + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( inner[slot & 0x0F] ) { judy->stack[judy->level].slot = slot; - if(!judy->depth || depth < judy->depth) { - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); + if( !judy->depth || depth < judy->depth ) { + return judy_first( judy, inner[slot & 0x0F], off + 1, depth ); } return &inner[slot & 0x0F]; } @@ -1011,27 +996,26 @@ JudySlot *judy_nxt(Judy *judy) // judy_prv: return ptr to previous entry -JudySlot *judy_prv(Judy *judy) -{ +JudySlot * judy_prv( Judy * judy ) { int slot, size, keysize; - JudySlot *table, *inner; - JudySlot *node, next; - unsigned char *base; + JudySlot * table, *inner; + JudySlot * node, next; + unsigned char * base; unsigned int depth; unsigned int off; - if(!judy->level) { - return judy_last(judy, *judy->root, 0, 0); + if( !judy->level ) { + return judy_last( judy, *judy->root, 0, 0 ); } - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1041,40 +1025,40 @@ JudySlot *judy_prv(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - node = (JudySlot *)((next & JUDY_mask) + size); - if(!slot || !node[-slot]) { + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + if( !slot || !node[-slot] ) { judy->level--; continue; } - base = (unsigned char *)(next & JUDY_mask); + base = ( unsigned char * )( next & JUDY_mask ); judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[(slot - 1) * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[( slot - 1 ) * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[(slot - 1) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[( slot - 1 ) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif return &node[-slot]; - return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); + return judy_last( judy, node[-slot], ( off | JUDY_key_mask ) + 1, depth ); case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { + if( judy->depth ) + if( !( ( off + 1 ) & JUDY_key_mask ) ) { depth++; } - while(slot--) { + while( slot-- ) { judy->stack[judy->level].slot--; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) - if(inner[slot & 0x0F]) { - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) + if( inner[slot & 0x0F] ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); + return judy_last( judy, inner[slot & 0x0F], off + 1, depth ); } } } @@ -1095,21 +1079,20 @@ JudySlot *judy_prv(Judy *judy) // judy_del: delete string from judy array // returning previous entry. -JudySlot *judy_del(Judy *judy) -{ - int slot, off, size, type; - JudySlot *table, *inner; +JudySlot * judy_del( Judy * judy ) { + int slot, off, size, type, high; + JudySlot * table, *inner; JudySlot next, *node; int keysize, cnt; - unsigned char *base; + unsigned char * base; - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch(type = next & 0x07) { + switch( type = next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1119,59 +1102,60 @@ JudySlot *judy_del(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); // move deleted slot to first slot - while(slot) { + while( slot ) { node[-slot - 1] = node[-slot]; - memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); + memcpy( base + slot * keysize, base + ( slot - 1 ) * keysize, keysize ); slot--; } // zero out first slot node[-1] = 0; - memset(base, 0, keysize); + memset( base, 0, keysize ); - if(node[-cnt]) { // does node have any slots left? + if( node[-cnt] ) { // does node have any slots left? judy->stack[judy->level].slot++; - return judy_prv(judy); + return judy_prv( judy ); } - judy_free(judy, base, type); + judy_free( judy, base, type ); judy->level--; continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); + inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); inner[slot & 0x0F] = 0; + high = slot & 0xF0; - for(cnt = 16; cnt--;) - if(inner[cnt]) { - return judy_prv(judy); + for( cnt = 16; cnt--; ) + if( inner[cnt] ) { + return judy_prv( judy ); } - judy_free(judy, inner, JUDY_radix); + judy_free( judy, inner, JUDY_radix ); table[slot >> 4] = 0; - for(cnt = 16; cnt--;) - if(table[cnt]) { - return judy_prv(judy); + for( cnt = 16; cnt--; ) + if( table[cnt] ) { + return judy_prv( judy ); } - judy_free(judy, table, JUDY_radix); + judy_free( judy, table, JUDY_radix ); judy->level--; continue; #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free(judy, base, type); + base = ( unsigned char * )( next & JUDY_mask ); + judy_free( judy, base, type ); judy->level--; continue; #endif @@ -1186,101 +1170,98 @@ JudySlot *judy_del(Judy *judy) // return cell for first key greater than or equal to given key -JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max) -{ - JudySlot *cell; +JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ) { + JudySlot * cell; judy->level = 0; - if(!max) { - return judy_first(judy, *judy->root, 0, 0); + if( !max ) { + return judy_first( judy, *judy->root, 0, 0 ); } - if((cell = judy_slot(judy, buff, max))) { + if( ( cell = judy_slot( judy, buff, max ) ) ) { return cell; } - return judy_nxt(judy); + return judy_nxt( judy ); } // split open span node #ifndef ASKITIS -void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) -{ - JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); +void judy_splitspan( Judy * judy, JudySlot * next, unsigned char * base ) { + JudySlot * node = ( JudySlot * )( base + JudySize[JUDY_span] ); unsigned int cnt = JUDY_span_bytes; - unsigned char *newbase; + unsigned char * newbase; unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN int i; #endif do { - newbase = judy_alloc(judy, JUDY_1); - *next = (JudySlot)newbase | JUDY_1; + newbase = judy_alloc( judy, JUDY_1 ); + *next = ( JudySlot )newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while(i--) { + while( i-- ) { *newbase++ = base[off + i]; } #else - memcpy(newbase, base + off, JUDY_key_size); + memcpy( newbase, base + off, JUDY_key_size ); newbase += JUDY_key_size; #endif - next = (JudySlot *)newbase; + next = ( JudySlot * )newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while(cnt && base[off - 1]); + } while( cnt && base[off - 1] ); *next = node[-1]; - judy_free(judy, base, JUDY_span); + judy_free( judy, base, JUDY_span ); } #endif // judy_cell: add string to judy array -JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) -{ - judyvalue *src = (judyvalue *)buff; +JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ) { + judyvalue * src = ( judyvalue * )buff; int size, idx, slot, cnt, tst; - JudySlot *next = judy->root; + JudySlot * next = judy->root; judyvalue test, value; unsigned int off = 0, start; - JudySlot *table; - JudySlot *node; + JudySlot * table; + JudySlot * node; unsigned int depth = 0; unsigned int keysize; - unsigned char *base; + unsigned char * base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while(*next) { + while( *next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch(*next & 0x07) { + switch( *next & 0x07 ) { default: size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); + base = ( unsigned char * )( *next & JUDY_mask ); + node = ( JudySlot * )( ( *next & JUDY_mask ) + size ); start = off; slot = cnt; value = 0; - if(judy->depth) { + if( judy->depth ) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -1288,35 +1269,35 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) } else do { value <<= 8; - if(off < max) { + if( off < max ) { value |= buff[off]; } - } while(++off & JUDY_key_mask); + } while( ++off & JUDY_key_mask ); // find slot > key - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + while( slot-- ) { + test = *( judyvalue * )( base + slot * keysize ); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * ( JUDY_key_size - keysize ); #else test &= JudyMask[keysize]; #endif - if(test <= value) { + if( test <= value ) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if(test == value) { // new key is equal to slot key + if( test == value ) { // new key is equal to slot key next = &node[-slot - 1]; // is this a leaf? - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1331,28 +1312,28 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // if this node is not full // open up cell after slot - if(!node[-1]) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot + if( !node[-1] ) { + memmove( base, base + keysize, slot * keysize ); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot + memcpy( base + slot * keysize, &value, keysize ); // copy new key into slot #else test = value; idx = keysize; - while(idx--) { + while( idx-- ) { base[slot * keysize + idx] = test, test >>= 8; } #endif - for(idx = 0; idx < slot; idx++) { + for( idx = 0; idx < slot; idx++ ) { node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot } node[-slot - 1] = 0; // set new tree ptr/cell next = &node[-slot - 1]; - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1364,12 +1345,12 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) continue; } - if(size < JudySize[JUDY_max]) { - next = judy_promote(judy, next, slot + 1, value, keysize); + if( size < JudySize[JUDY_max] ) { + next = judy_promote( judy, next, slot + 1, value, keysize ); - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1384,47 +1365,47 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // split full maximal node into JUDY_radix nodes // loop to reprocess new insert - judy_splitnode(judy, next, size, keysize, depth); + judy_splitnode( judy, next, size, keysize, depth ); #ifndef ASKITIS judy->level--; #endif off = start; - if(judy->depth) { + if( judy->depth ) { depth--; } continue; case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix + table = ( JudySlot * )( *next & JUDY_mask ); // outer radix - if(judy->depth) { - slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { + if( judy->depth ) { + slot = ( src[depth] >> ( ( (JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; + } else if( off < max ) { slot = buff[off++]; } else { slot = 0, off++; } - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } // allocate inner radix if empty - if(!table[slot >> 4]) { - table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; + if( !table[slot >> 4] ) { + table[slot >> 4] = ( JudySlot )judy_alloc( judy, JUDY_radix ) | JUDY_radix; } - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif next = &table[slot & 0x0F]; - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1437,22 +1418,22 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); + base = ( unsigned char * )( *next & JUDY_mask ); + node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[JUDY_span] ); cnt = JUDY_span_bytes; tst = cnt; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - value = strncmp((const char *)base, (const char *)(buff + off), tst); + value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); - if(!value && tst < cnt && !base[tst]) { // leaf? + if( !value && tst < cnt && !base[tst] ) { // leaf? return &node[-1]; } - if(!value && tst == cnt) { + if( !value && tst == cnt ) { next = &node[-1]; off += cnt; continue; @@ -1461,7 +1442,7 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // bust up JUDY_span node and produce JUDY_1 nodes // then loop to reprocess insert - judy_splitspan(judy, next, base); + judy_splitspan( judy, next, base ); judy->level--; continue; #endif @@ -1471,31 +1452,31 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if(off & JUDY_key_mask) - if(judy->depth || off <= max) { + if( off & JUDY_key_mask ) + if( judy->depth || off <= max ) { #else - while(off <= max) { + while( off <= max ) { #endif - base = judy_alloc(judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + base = judy_alloc( judy, JUDY_1 ); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + node = ( JudySlot * )( base + JudySize[JUDY_1] ); + *next = ( JudySlot )base | JUDY_1; // fill in slot 0 with bytes of key - if(judy->depth) { + if( judy->depth ) { value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot + memcpy( base, &value, keysize ); // copy new key into slot #else - while(keysize--) { + while( keysize-- ) { base[keysize] = value, value >>= 8; } #endif } else { #if BYTE_ORDER != BIG_ENDIAN - while(keysize) - if(off + keysize <= max) { + while( keysize ) + if( off + keysize <= max ) { *base++ = buff[off + --keysize]; } else { base++, --keysize; @@ -1503,15 +1484,15 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) #else tst = keysize; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - memcpy(base, buff + off, tst); + memcpy( base, buff + off, tst ); #endif } #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1529,18 +1510,18 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // or judy_1 nodes if not string tree #ifndef ASKITIS - if(!judy->depth) - while(off <= max) { - base = judy_alloc(judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); + if( !judy->depth ) + while( off <= max ) { + base = judy_alloc( judy, JUDY_span ); + *next = ( JudySlot )base | JUDY_span; + node = ( JudySlot * )( base + JudySize[JUDY_span] ); cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - memcpy(base, buff + off, tst); + memcpy( base, buff + off, tst ); - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1550,20 +1531,21 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) off += tst; depth++; - if(!base[cnt - 1]) { // done on leaf + if( !base[cnt - 1] ) { // done on leaf break; } - } else - while(depth < judy->depth) { - base = judy_alloc(judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + } + else + while( depth < judy->depth ) { + base = judy_alloc( judy, JUDY_1 ); + node = ( JudySlot * )( base + JudySize[JUDY_1] ); + *next = ( JudySlot )base | JUDY_1; // fill in slot 0 with bytes of key - *(judyvalue *)base = src[depth]; + *( judyvalue * )base = src[depth]; - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; diff --git a/src/base/judy/src/judy.h b/src/base/judy/src/judy.h index 5ef2497ea..dfd193cf3 100644 --- a/src/base/judy/src/judy.h +++ b/src/base/judy/src/judy.h @@ -96,7 +96,7 @@ enum JUDY_types { }; typedef struct { - void *seg; // next used allocator + void * seg; // next used allocator unsigned int next; // next available offset } JudySeg; @@ -108,8 +108,8 @@ typedef struct { typedef struct { JudySlot root[1]; // root of judy array - void **reuse[8]; // reuse judy blocks - JudySeg *seg; // current judy allocator + void ** reuse[8]; // reuse judy blocks + JudySeg * seg; // current judy allocator unsigned int level; // current height of stack unsigned int max; // max height of stack unsigned int depth; // number of Integers in a key, or zero for string keys @@ -133,41 +133,41 @@ int Found = 0; extern "C" { #endif -/// open a new judy array returning a judy object. -SC_BASE_EXPORT Judy *judy_open(unsigned int max, unsigned int depth); + /// open a new judy array returning a judy object. + SC_BASE_EXPORT Judy * judy_open( unsigned int max, unsigned int depth ); -/// close an open judy array, freeing all memory. -SC_BASE_EXPORT void judy_close(Judy *judy); + /// close an open judy array, freeing all memory. + SC_BASE_EXPORT void judy_close( Judy * judy ); -/// clone an open judy array, duplicating the stack. -SC_BASE_EXPORT Judy *judy_clone(Judy *judy); + /// clone an open judy array, duplicating the stack. + SC_BASE_EXPORT Judy * judy_clone( Judy * judy ); -/// allocate data memory within judy array for external use. -SC_BASE_EXPORT void *judy_data(Judy *judy, unsigned int amt); + /// allocate data memory within judy array for external use. + SC_BASE_EXPORT void * judy_data( Judy * judy, unsigned int amt ); -/// insert a key into the judy array, return cell pointer. -SC_BASE_EXPORT JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max); + /// insert a key into the judy array, return cell pointer. + SC_BASE_EXPORT JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer greater than or equal to given key -SC_BASE_EXPORT JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max); + /// retrieve the cell pointer greater than or equal to given key + SC_BASE_EXPORT JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer, or return NULL for a given key. -SC_BASE_EXPORT JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max); + /// retrieve the cell pointer, or return NULL for a given key. + SC_BASE_EXPORT JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the string value for the most recent judy query. -SC_BASE_EXPORT unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max); + /// retrieve the string value for the most recent judy query. + SC_BASE_EXPORT unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer for the last string in the array. -SC_BASE_EXPORT JudySlot *judy_end(Judy *judy); + /// retrieve the cell pointer for the last string in the array. + SC_BASE_EXPORT JudySlot * judy_end( Judy * judy ); -/// retrieve the cell pointer for the next string in the array. -SC_BASE_EXPORT JudySlot *judy_nxt(Judy *judy); + /// retrieve the cell pointer for the next string in the array. + SC_BASE_EXPORT JudySlot * judy_nxt( Judy * judy ); -/// retrieve the cell pointer for the prev string in the array. -SC_BASE_EXPORT JudySlot *judy_prv(Judy *judy); + /// retrieve the cell pointer for the prev string in the array. + SC_BASE_EXPORT JudySlot * judy_prv( Judy * judy ); -/// delete the key and cell for the current stack entry. -SC_BASE_EXPORT JudySlot *judy_del(Judy *judy); + /// delete the key and cell for the current stack entry. + SC_BASE_EXPORT JudySlot * judy_del( Judy * judy ); #ifdef __cplusplus } diff --git a/src/base/judy/src/judyL2Array.h b/src/base/judy/src/judyL2Array.h index e5b58bcfd..02b416827 100644 --- a/src/base/judy/src/judyL2Array.h +++ b/src/base/judy/src/judyL2Array.h @@ -29,68 +29,60 @@ struct judyl2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. With judyL2Array, the size of this value can vary. */ template< typename JudyKey, typename JudyValue > -class judyL2Array -{ +class judyL2Array { public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judyl2KVpair< JudyKey, vector * > pair; typedef judyl2KVpair< JudyKey, cvector * > cpair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxLevels, _depth; - vector **_lastSlot; + vector ** _lastSlot; JudyKey _buff[1]; bool _success; cpair kv; public: - judyL2Array(): _maxLevels(sizeof(JudyKey)), _depth(1), _lastSlot(0), _success(true) - { - assert(sizeof(JudyKey) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!"); - _judyarray = judy_open(_maxLevels, _depth); + judyL2Array(): _maxLevels( sizeof( JudyKey ) ), _depth( 1 ), _lastSlot( 0 ), _success( true ) { + assert( sizeof( JudyKey ) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!" ); + _judyarray = judy_open( _maxLevels, _depth ); _buff[0] = 0; } - explicit judyL2Array(const judyL2Array< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), - _depth(other._depth), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyL2Array( const judyL2Array< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), + _depth( other._depth ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff[0] = other._buff[0]; - find(*_buff); //set _lastSlot + find( *_buff ); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyL2Array() - { + ~judyL2Array() { clear(); - judy_close(_judyarray); + judy_close( _judyarray ); } /// delete all vectors and empty the array - void clear() - { + void clear() { JudyKey key = 0; - while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { + while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { //( * _lastSlot )->~vector(); //TODO: placement new - delete(* _lastSlot); - judy_del(_judyarray); + delete( * _lastSlot ); + judy_del( _judyarray ); } } - vector *getLastValue() - { - assert(_lastSlot); + vector * getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(vector *value) - { - assert(_lastSlot); + void setLastValue( vector * value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } @@ -104,11 +96,10 @@ class judyL2Array // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert(JudyKey key, JudyValue value) - { - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { - if(!(* _lastSlot)) { + bool insert( JudyKey key, JudyValue value ) { + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -118,7 +109,7 @@ class judyL2Array * also use placement new in the other insert function, below */ } - (* _lastSlot)->push_back(value); + ( * _lastSlot )->push_back( value ); _success = true; } else { _success = false; @@ -130,19 +121,18 @@ class judyL2Array * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert(JudyKey key, const vector &values, bool overwrite = false) - { - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { - if(!(* _lastSlot)) { + bool insert( JudyKey key, const vector & values, bool overwrite = false ) { + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if(overwrite) { - (* _lastSlot)->clear(); + } else if( overwrite ) { + ( * _lastSlot )->clear(); } - std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); + std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); _success = true; } else { _success = false; @@ -152,17 +142,15 @@ class judyL2Array /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter(JudyKey key) - { - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + const cpair atOrAfter( JudyKey key ) { + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector *find(JudyKey key) - { - _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if((_lastSlot) && (* _lastSlot)) { + cvector * find( JudyKey key ) { + _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( ( _lastSlot ) && ( * _lastSlot ) ) { _success = true; return * _lastSlot; } else { @@ -172,10 +160,9 @@ class judyL2Array } /// retrieve the key-value pair for the most recent judy query. - inline const cpair &mostRecentPair() - { - judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); - if(_lastSlot) { + inline const cpair & mostRecentPair() { + judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { @@ -187,31 +174,27 @@ class judyL2Array } /// retrieve the first key-value pair in the array - const cpair &begin() - { + const cpair & begin() { JudyKey key = 0; - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair &end() - { - _lastSlot = (vector **) judy_end(_judyarray); + const cpair & end() { + _lastSlot = ( vector ** ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next string in the array. - const cpair &next() - { - _lastSlot = (vector **) judy_nxt(_judyarray); + const cpair & next() { + _lastSlot = ( vector ** ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev string in the array. - const cpair &previous() - { - _lastSlot = (vector **) judy_prv(_judyarray); + const cpair & previous() { + _lastSlot = ( vector ** ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -219,12 +202,11 @@ class judyL2Array * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(JudyKey key) - { - if(0 != (_lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size))) { + bool removeEntry( JudyKey key ) { + if( 0 != ( _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = (vector **) judy_del(_judyarray); + _lastSlot = ( vector ** ) judy_del( _judyarray ); return true; } else { return false; @@ -232,10 +214,9 @@ class judyL2Array } /// true if the array is empty - bool isEmpty() - { + bool isEmpty() { JudyKey key = 0; - return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); } }; #endif //JUDYL2ARRAY_H diff --git a/src/base/judy/src/judyLArray.h b/src/base/judy/src/judyLArray.h index a70e787c7..b78dc0bb9 100644 --- a/src/base/judy/src/judyLArray.h +++ b/src/base/judy/src/judyLArray.h @@ -28,64 +28,56 @@ struct judylKVpair { * \param JudyValue the type of the value */ template< typename JudyKey, typename JudyValue > -class judyLArray -{ +class judyLArray { public: typedef judylKVpair< JudyKey, JudyValue > pair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxLevels, _depth; - JudyValue *_lastSlot; + JudyValue * _lastSlot; JudyKey _buff[1]; bool _success; pair _kv; public: - 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!"); - _judyarray = judy_open(_maxLevels, _depth); + 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!" ); + _judyarray = judy_open( _maxLevels, _depth ); _buff[0] = 0; } - explicit judyLArray(const judyLArray< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), - _depth(other._depth), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyLArray( const judyLArray< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), + _depth( other._depth ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff[0] = other._buff[0]; - find(*_buff); //set _lastSlot + find( *_buff ); //set _lastSlot } - ~judyLArray() - { - judy_close(_judyarray); + ~judyLArray() { + judy_close( _judyarray ); } - void clear(bool deleteContents = false) - { + void clear( bool deleteContents = false ) { JudyKey key = 0; - while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { - if(deleteContents) { + while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { + if( deleteContents ) { delete *_lastSlot; } - judy_del(_judyarray); + judy_del( _judyarray ); } } - JudyValue getLastValue() - { - assert(_lastSlot); + JudyValue getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(JudyValue value) - { - assert(_lastSlot); + void setLastValue( JudyValue value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } //TODO @@ -93,11 +85,10 @@ class judyLArray // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert(JudyKey key, JudyValue value) - { - assert(value != 0); - _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { + bool insert( JudyKey key, JudyValue value ) { + assert( value != 0 ); + _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { *_lastSlot = value; _success = true; } else { @@ -108,17 +99,15 @@ class judyLArray /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter(JudyKey key) - { - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + const pair atOrAfter( JudyKey key ) { + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find(JudyKey key) - { - _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { + JudyValue find( JudyKey key ) { + _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { _success = true; return *_lastSlot; } else { @@ -128,14 +117,13 @@ class judyLArray } /// retrieve the key-value pair for the most recent judy query. - inline const pair &mostRecentPair() - { - judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); - if(_lastSlot) { + inline const pair & mostRecentPair() { + judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); + if( _lastSlot ) { _kv.value = *_lastSlot; _success = true; } else { - _kv.value = (JudyValue) 0; + _kv.value = ( JudyValue ) 0; _success = false; } _kv.key = _buff[0]; @@ -143,31 +131,27 @@ class judyLArray } /// retrieve the first key-value pair in the array - const pair &begin() - { + const pair & begin() { JudyKey key = 0; - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair &end() - { - _lastSlot = (JudyValue *) judy_end(_judyarray); + const pair & end() { + _lastSlot = ( JudyValue * ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair &next() - { - _lastSlot = (JudyValue *) judy_nxt(_judyarray); + const pair & next() { + _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair &previous() - { - _lastSlot = (JudyValue *) judy_prv(_judyarray); + const pair & previous() { + _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -175,10 +159,9 @@ class judyLArray * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(JudyKey *key) - { - if(judy_slot(_judyarray, key, _depth * JUDY_key_size)) { - _lastSlot = (JudyValue *) judy_del(_judyarray); + bool removeEntry( JudyKey * key ) { + if( judy_slot( _judyarray, key, _depth * JUDY_key_size ) ) { + _lastSlot = ( JudyValue * ) judy_del( _judyarray ); return true; } else { return false; @@ -186,10 +169,9 @@ class judyLArray } /// true if the array is empty - bool isEmpty() - { + bool isEmpty() { JudyKey key = 0; - return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); } }; #endif //JUDYLARRAY_H diff --git a/src/base/judy/src/judyS2Array.h b/src/base/judy/src/judyS2Array.h index 421c310f0..726a6449a 100644 --- a/src/base/judy/src/judyS2Array.h +++ b/src/base/judy/src/judyS2Array.h @@ -19,7 +19,7 @@ template< typename JudyValue > struct judys2KVpair { - unsigned char *key; + unsigned char * key; JudyValue value; }; @@ -28,70 +28,62 @@ struct judys2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. */ template< typename JudyValue > -class judyS2Array -{ +class judyS2Array { public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judys2KVpair< vector * > pair; typedef judys2KVpair< cvector * > cpair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxKeyLen; - vector **_lastSlot; - unsigned char *_buff; + vector ** _lastSlot; + unsigned char * _buff; bool _success; cpair kv; public: - judyS2Array(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _lastSlot(0), _success(true) - { - _judyarray = judy_open(_maxKeyLen, 0); + judyS2Array( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _lastSlot( 0 ), _success( true ) { + _judyarray = judy_open( _maxKeyLen, 0 ); _buff = new unsigned char[_maxKeyLen]; - assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); + assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); } - explicit judyS2Array(const judyS2Array< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyS2Array( const judyS2Array< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff = new unsigned char[_maxKeyLen]; - strncpy(_buff, other._buff, _maxKeyLen); + strncpy( _buff, other._buff, _maxKeyLen ); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find(_buff); //set _lastSlot + find( _buff ); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyS2Array() - { + ~judyS2Array() { clear(); - judy_close(_judyarray); + judy_close( _judyarray ); delete[] _buff; } /// delete all vectors and empty the array - void clear() - { + void clear() { _buff[0] = '\0'; - while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { + while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { //( * _lastSlot )->~vector(); //TODO: placement new - delete(* _lastSlot); - judy_del(_judyarray); + delete( * _lastSlot ); + judy_del( _judyarray ); } } - vector *getLastValue() - { - assert(_lastSlot); + vector * getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(vector *value) - { - assert(_lastSlot); + void setLastValue( vector * value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } @@ -105,17 +97,16 @@ class judyS2Array // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { - if(!(* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -125,7 +116,7 @@ class judyS2Array * also use placement new in the other insert function, below */ } - (* _lastSlot)->push_back(value); + ( * _lastSlot )->push_back( value ); _success = true; } else { _success = false; @@ -137,25 +128,24 @@ class judyS2Array * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert(const char *key, const vector &values, unsigned int keyLen = 0, bool overwrite = false) - { - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, const vector & values, unsigned int keyLen = 0, bool overwrite = false ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { - if(!(* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if(overwrite) { - (* _lastSlot)->clear(); + } else if( overwrite ) { + ( * _lastSlot )->clear(); } - std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); + std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); _success = true; } else { _success = false; @@ -165,29 +155,27 @@ class judyS2Array /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + const cpair atOrAfter( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *)key, keyLen); + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector *find(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + cvector * find( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) key, keyLen); - if((_lastSlot) && (* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); + if( ( _lastSlot ) && ( * _lastSlot ) ) { _success = true; return * _lastSlot; } else { @@ -197,10 +185,9 @@ class judyS2Array } /// retrieve the key-value pair for the most recent judy query. - inline const cpair &mostRecentPair() - { - judy_key(_judyarray, _buff, _maxKeyLen); - if(_lastSlot) { + inline const cpair & mostRecentPair() { + judy_key( _judyarray, _buff, _maxKeyLen ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { @@ -212,31 +199,27 @@ class judyS2Array } /// retrieve the first key-value pair in the array - const cpair &begin() - { + const cpair & begin() { _buff[0] = '\0'; - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair &end() - { - _lastSlot = (vector **) judy_end(_judyarray); + const cpair & end() { + _lastSlot = ( vector ** ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const cpair &next() - { - _lastSlot = (vector **) judy_nxt(_judyarray); + const cpair & next() { + _lastSlot = ( vector ** ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const cpair &previous() - { - _lastSlot = (vector **) judy_prv(_judyarray); + const cpair & previous() { + _lastSlot = ( vector ** ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -244,12 +227,11 @@ class judyS2Array * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(const char *key) - { - if(0 != (judy_slot(_judyarray, (const unsigned char *)key, strlen(key)))) { + bool removeEntry( const char * key ) { + if( 0 != ( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) ) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = (vector **) judy_del(_judyarray); + _lastSlot = ( vector ** ) judy_del( _judyarray ); return true; } else { return false; @@ -257,10 +239,9 @@ class judyS2Array } ///return true if the array is empty - bool isEmpty() - { + bool isEmpty() { _buff[0] = 0; - return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); } }; #endif //JUDYS2ARRAY_H diff --git a/src/base/judy/src/judySArray.h b/src/base/judy/src/judySArray.h index 2a6079a2c..db75ec91c 100644 --- a/src/base/judy/src/judySArray.h +++ b/src/base/judy/src/judySArray.h @@ -17,64 +17,56 @@ template< typename JudyValue > struct judysKVpair { - unsigned char *key; + unsigned char * key; JudyValue value; }; template< typename JudyValue > -class judySArray -{ +class judySArray { protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxKeyLen; - JudyValue *_lastSlot; - unsigned char *_buff; + JudyValue * _lastSlot; + unsigned char * _buff; bool _success; public: typedef judysKVpair< JudyValue > pair; - judySArray(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _success(true) - { - _judyarray = judy_open(_maxKeyLen, 0); + judySArray( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _success( true ) { + _judyarray = judy_open( _maxKeyLen, 0 ); _buff = new unsigned char[_maxKeyLen]; - assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); + assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); } - explicit judySArray(const judySArray< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judySArray( const judySArray< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff = new unsigned char[_maxKeyLen]; - strncpy(_buff, other._buff, _maxKeyLen); + strncpy( _buff, other._buff, _maxKeyLen ); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find(_buff); //set _lastSlot + find( _buff ); //set _lastSlot } - ~judySArray() - { - judy_close(_judyarray); + ~judySArray() { + judy_close( _judyarray ); delete[] _buff; } - void clear() - { + void clear() { _buff[0] = '\0'; - while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { - judy_del(_judyarray); + while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { + judy_del( _judyarray ); } } - JudyValue getLastValue() - { - assert(_lastSlot); + JudyValue getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(JudyValue value) - { - assert(_lastSlot); + void setLastValue( JudyValue value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } //TODO @@ -82,17 +74,16 @@ class judySArray // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) - { - assert(value != 0); - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { + assert( value != 0 ); + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { *_lastSlot = value; _success = true; } else { @@ -103,29 +94,27 @@ class judySArray /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + const pair atOrAfter( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *)key, keyLen); + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + JudyValue find( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) key, keyLen); - if(_lastSlot) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); + if( _lastSlot ) { _success = true; return *_lastSlot; } else { @@ -135,15 +124,14 @@ class judySArray } /// retrieve the key-value pair for the most recent judy query. - inline const pair mostRecentPair() - { + inline const pair mostRecentPair() { pair kv; - judy_key(_judyarray, _buff, _maxKeyLen); - if(_lastSlot) { + judy_key( _judyarray, _buff, _maxKeyLen ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { - kv.value = (JudyValue) 0; + kv.value = ( JudyValue ) 0; _success = false; } kv.key = _buff; @@ -151,31 +139,27 @@ class judySArray } /// retrieve the first key-value pair in the array - const pair &begin() - { + const pair & begin() { _buff[0] = '\0'; - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair &end() - { - _lastSlot = (JudyValue *) judy_end(_judyarray); + const pair & end() { + _lastSlot = ( JudyValue * ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair &next() - { - _lastSlot = (JudyValue *) judy_nxt(_judyarray); + const pair & next() { + _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair &previous() - { - _lastSlot = (JudyValue *) judy_prv(_judyarray); + const pair & previous() { + _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -183,10 +167,9 @@ class judySArray * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(const char *key) - { - if(judy_slot(_judyarray, (const unsigned char *)key, strlen(key))) { - _lastSlot = (JudyValue *) judy_del(_judyarray); + bool removeEntry( const char * key ) { + if( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) { + _lastSlot = ( JudyValue * ) judy_del( _judyarray ); return true; } else { return false; @@ -194,10 +177,9 @@ class judySArray } ///return true if the array is empty - bool isEmpty() - { + bool isEmpty() { _buff[0] = 0; - return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); } }; #endif //JUDYSARRAY_H diff --git a/src/base/judy/test/hexSort.c b/src/base/judy/test/hexSort.c index 9d9523af8..0d770d752 100644 --- a/src/base/judy/test/hexSort.c +++ b/src/base/judy/test/hexSort.c @@ -30,96 +30,95 @@ unsigned int MaxMem = 0; On linux, a 1M-line file can be created with the following: hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >in-file */ -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { unsigned char buff[1024]; JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; + JudySlot * cell; + FILE * in, *out; + void * judy; unsigned int len; unsigned int idx; - if(argc > 1) { - in = fopen(argv[1], "rb"); + if( argc > 1 ) { + in = fopen( argv[1], "rb" ); } else { in = stdin; } - if(argc > 2) { - out = fopen(argv[2], "wb"); + if( argc > 2 ) { + out = fopen( argv[2], "wb" ); } else { out = stdout; } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - if(!in) { - fprintf(stderr, "unable to open input file\n"); + if( !in ) { + fprintf( stderr, "unable to open input file\n" ); } - if(!out) { - fprintf(stderr, "unable to open output file\n"); + if( !out ) { + fprintf( stderr, "unable to open output file\n" ); } - PennyMerge = (unsigned long long)PennyLine * PennyRecs; + PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - judy = judy_open(1024, 16 / JUDY_key_size); + judy = judy_open( 1024, 16 / JUDY_key_size ); - while(fgets((char *)buff, sizeof(buff), in)) { + while( fgets( ( char * )buff, sizeof( buff ), in ) ) { judyvalue key[16 / JUDY_key_size]; - if(len = strlen((const char *)buff)) { + if( len = strlen( ( const char * )buff ) ) { buff[--len] = 0; // remove LF } #if JUDY_key_size == 4 - key[3] = strtoul(buff + 24, NULL, 16); + key[3] = strtoul( buff + 24, NULL, 16 ); buff[24] = 0; - key[2] = strtoul(buff + 16, NULL, 16); + key[2] = strtoul( buff + 16, NULL, 16 ); buff[16] = 0; - key[1] = strtoul(buff + 8, NULL, 16); + key[1] = strtoul( buff + 8, NULL, 16 ); buff[8] = 0; - key[0] = strtoul(buff, NULL, 16); + key[0] = strtoul( buff, NULL, 16 ); #else - key[1] = strtoull(buff + 16, NULL, 16); + key[1] = strtoull( buff + 16, NULL, 16 ); buff[16] = 0; - key[0] = strtoull(buff, NULL, 16); + key[0] = strtoull( buff, NULL, 16 ); #endif - *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string + *( judy_cell( judy, ( void * )key, 0 ) ) += 1; // count instances of string max++; } - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); + fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { + if( cell ) do { judyvalue key[16 / JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates + len = judy_key( judy, ( void * )key, 0 ); + for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates #if JUDY_key_size == 4 - fprintf(out, "%.8X", key[0]); - fprintf(out, "%.8X", key[1]); - fprintf(out, "%.8X", key[2]); - fprintf(out, "%.8X", key[3]); + fprintf( out, "%.8X", key[0] ); + fprintf( out, "%.8X", key[1] ); + fprintf( out, "%.8X", key[2] ); + fprintf( out, "%.8X", key[3] ); #else - fprintf(out, "%.16llX", key[0]); - fprintf(out, "%.16llX", key[1]); + fprintf( out, "%.16llX", key[0] ); + fprintf( out, "%.16llX", key[1] ); #endif - fputc('\n', out); + fputc( '\n', out ); } - } while(cell = judy_nxt(judy)); + } while( cell = judy_nxt( judy ) ); #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) + if( cell = judy_prv( judy ) ) do { max -= *cell; - } while(cell = judy_del(judy)); + } while( cell = judy_del( judy ) ); - assert(max == 0); + assert( max == 0 ); #endif - judy_close(judy); + judy_close( judy ); return 0; } diff --git a/src/base/judy/test/judyL2test.cc b/src/base/judy/test/judyL2test.cc index fdf16e58e..20ef559a9 100644 --- a/src/base/judy/test/judyL2test.cc +++ b/src/base/judy/test/judyL2test.cc @@ -5,14 +5,13 @@ #include "judyL2Array.h" typedef judyL2Array< uint64_t, uint64_t > jl2a; -bool testFind(jl2a &j, uint64_t key, unsigned int count) -{ - jl2a::cvector *v = j.find(key); +bool testFind( jl2a & j, uint64_t key, unsigned int count ) { + jl2a::cvector * v = j.find( key ); std::cout << "find: key " << key << " ..." << std::endl; - if(count > 0) { - if(!v || !j.success() || (v->size() != count)) { + if( count > 0 ) { + if( !v || !j.success() || ( v->size() != count ) ) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if(v) { + if( v ) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -21,13 +20,13 @@ bool testFind(jl2a &j, uint64_t key, unsigned int count) // note - this doesn't verify that the right keys are returned, just the right number! jl2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for(; it != v->end(); it++) { + for( ; it != v->end(); it++ ) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if(v || j.success()) { + if( v || j.success() ) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -37,38 +36,37 @@ bool testFind(jl2a &j, uint64_t key, unsigned int count) return true; } -int main() -{ +int main() { bool pass = true; jl2a jl; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); // std::cout << "size of judyL2Array: " << sizeof( jl ) << std::endl; - jl.insert(5, 12); - jl.insert(6, 2); - jl.insert(7, 312); - jl.insert(11, 412); - jl.insert(7, 313); - jl2a::cpair kv = jl.atOrAfter(4); + jl.insert( 5, 12 ); + jl.insert( 6, 2 ); + jl.insert( 7, 312 ); + jl.insert( 11, 412 ); + jl.insert( 7, 313 ); + jl2a::cpair kv = jl.atOrAfter( 4 ); std::cout << "atOrAfter test ..." << std::endl; - if(kv.value != 0 && jl.success()) { - std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; + if( kv.value != 0 && jl.success() ) { + std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind(jl, 8, 0); - pass &= testFind(jl, 11, 1); - pass &= testFind(jl, 7, 2); + pass &= testFind( jl, 8, 0 ); + pass &= testFind( jl, 11, 1 ); + pass &= testFind( jl, 7, 2 ); jl.clear(); //TODO test all of judyL2Array - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/judyLtest.cc b/src/base/judy/test/judyLtest.cc index 81815d4d5..01ae3d5d7 100644 --- a/src/base/judy/test/judyLtest.cc +++ b/src/base/judy/test/judyLtest.cc @@ -4,31 +4,30 @@ #include "judyLArray.h" -int main() -{ - std::cout.setf(std::ios::boolalpha); +int main() { + std::cout.setf( std::ios::boolalpha ); judyLArray< uint64_t, uint64_t > jl; - std::cout << "size of judyLArray: " << sizeof(jl) << std::endl; - jl.insert(5, 12); - jl.insert(6, 2); - jl.insert(7, 312); - jl.insert(8, 412); - judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter(4); + std::cout << "size of judyLArray: " << sizeof( jl ) << std::endl; + jl.insert( 5, 12 ); + jl.insert( 6, 2 ); + jl.insert( 7, 312 ); + jl.insert( 8, 412 ); + judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter( 4 ); std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = jl.find(11); - if(v != 0 || jl.success()) { + long v = jl.find( 11 ); + if( v != 0 || jl.success() ) { std::cout << "find: false positive - v: " << v << " success: " << jl.success() << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - v = jl.find(7); - if(v != 312 || !jl.success()) { + v = jl.find( 7 ); + if( v != 312 || !jl.success() ) { std::cout << "find: false negative - v: " << v << " success: " << jl.success() << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } jl.clear(); //TODO test all of judyLArray - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } \ No newline at end of file diff --git a/src/base/judy/test/judyS2test.cc b/src/base/judy/test/judyS2test.cc index 4e0678cd7..ec25f960b 100644 --- a/src/base/judy/test/judyS2test.cc +++ b/src/base/judy/test/judyS2test.cc @@ -6,14 +6,13 @@ typedef judyS2Array< uint64_t > js2a; -bool testFind(js2a &j, const char *key, unsigned int count) -{ - js2a::cvector *v = j.find(key); +bool testFind( js2a & j, const char * key, unsigned int count ) { + js2a::cvector * v = j.find( key ); std::cout << "find: key " << key << " ..." << std::endl; - if(count > 0) { - if(!v || !j.success() || (v->size() != count)) { + if( count > 0 ) { + if( !v || !j.success() || ( v->size() != count ) ) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if(v) { + if( v ) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -22,13 +21,13 @@ bool testFind(js2a &j, const char *key, unsigned int count) // note - this doesn't verify that the right keys are returned, just the right number! js2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for(; it != v->end(); it++) { + for( ; it != v->end(); it++ ) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if(v || j.success()) { + if( v || j.success() ) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -38,40 +37,39 @@ bool testFind(js2a &j, const char *key, unsigned int count) return true; } -int main() -{ +int main() { bool pass = true; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); - js2a js(255); - js.insert("blah", 1234); - js.insert("bah", 124); - js.insert("blh", 123); - js.insert("blh", 4123); - js.insert("bla", 134); - js.insert("bh", 234); + js2a js( 255 ); + js.insert( "blah", 1234 ); + js.insert( "bah", 124 ); + js.insert( "blh", 123 ); + js.insert( "blh", 4123 ); + js.insert( "bla", 134 ); + js.insert( "bh", 234 ); - js2a::cpair kv = js.atOrAfter("ab"); + js2a::cpair kv = js.atOrAfter( "ab" ); std::cout << "atOrAfter test ..." << std::endl; - if(kv.value != 0 && js.success()) { - std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; + if( kv.value != 0 && js.success() ) { + std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind(js, "sdafsd", 0); - pass &= testFind(js, "bah", 1); - pass &= testFind(js, "blh", 2); + pass &= testFind( js, "sdafsd", 0 ); + pass &= testFind( js, "bah", 1 ); + pass &= testFind( js, "blh", 2 ); js.clear(); //TODO test all of judyS2Array - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/judyStest.cc b/src/base/judy/test/judyStest.cc index f6fc74ffa..3d620b015 100644 --- a/src/base/judy/test/judyStest.cc +++ b/src/base/judy/test/judyStest.cc @@ -4,41 +4,40 @@ #include "judySArray.h" -int main() -{ +int main() { bool pass = true; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); - judySArray< uint64_t > js(255); - js.insert("blah", 1234); - js.insert("bah", 124); - js.insert("blh", 123); - js.insert("bla", 134); - js.insert("bh", 234); + judySArray< uint64_t > js( 255 ); + js.insert( "blah", 1234 ); + js.insert( "bah", 124 ); + js.insert( "blh", 123 ); + js.insert( "bla", 134 ); + js.insert( "bh", 234 ); - judySArray< uint64_t >::pair kv = js.atOrAfter("ab"); + judySArray< uint64_t >::pair kv = js.atOrAfter( "ab" ); //TODO if()... std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = js.find("sdafsd"); - if(v != 0 || js.success()) { + long v = js.find( "sdafsd" ); + if( v != 0 || js.success() ) { std::cout << "find: false positive - v: " << v << " success: " << js.success() << std::endl; pass = false; } - v = js.find("bah"); - if(v != 124 || !js.success()) { + v = js.find( "bah" ); + if( v != 124 || !js.success() ) { std::cout << "find: false negative - v: " << v << " success: " << js.success() << std::endl; pass = false; } //TODO test all of judySArray - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/pennySort.c b/src/base/judy/test/pennySort.c index 0bc3a4f42..a279b1a70 100644 --- a/src/base/judy/test/pennySort.c +++ b/src/base/judy/test/pennySort.c @@ -40,17 +40,16 @@ unsigned int MaxMem = 0; // Also, the file to search judy is hardcoded to skew1_1. -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { unsigned char buff[1024]; JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; + JudySlot * cell; + FILE * in, *out; + void * judy; unsigned int len; unsigned int idx; #ifdef ASKITIS - char *askitis; + char * askitis; int prev, off; float insert_real_time = 0.0; float search_real_time = 0.0; @@ -62,176 +61,176 @@ int main(int argc, char **argv) #endif #endif - if(argc > 1) { - in = fopen(argv[1], "rb"); + if( argc > 1 ) { + in = fopen( argv[1], "rb" ); } else { in = stdin; } - if(argc > 2) { - out = fopen(argv[2], "wb"); + if( argc > 2 ) { + out = fopen( argv[2], "wb" ); } else { out = stdout; } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - if(!in) { - fprintf(stderr, "unable to open input file\n"); + if( !in ) { + fprintf( stderr, "unable to open input file\n" ); } - if(!out) { - fprintf(stderr, "unable to open output file\n"); + if( !out ) { + fprintf( stderr, "unable to open output file\n" ); } - if(argc > 6) { - PennyRecs = atoi(argv[6]); + if( argc > 6 ) { + PennyRecs = atoi( argv[6] ); } - if(argc > 5) { - PennyOff = atoi(argv[5]); + if( argc > 5 ) { + PennyOff = atoi( argv[5] ); } - if(argc > 4) { - PennyLine = atoi(argv[4]); + if( argc > 4 ) { + PennyLine = atoi( argv[4] ); } - PennyMerge = (unsigned long long)PennyLine * PennyRecs; + PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - if(argc > 3) { - PennyKey = atoi(argv[3]); - sort(in, argv[2]); - return merge(out, argv[2]); + if( argc > 3 ) { + PennyKey = atoi( argv[3] ); + sort( in, argv[2] ); + return merge( out, argv[2] ); } #ifdef ASKITIS - judy = judy_open(1024, 0); + judy = judy_open( 1024, 0 ); // build judy array - size = lseek(fileno(in), 0L, 2); - askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + size = lseek( fileno( in ), 0L, 2 ); + askitis = malloc( size ); + lseek( fileno( in ), 0L, 0 ); + read( fileno( in ), askitis, size ); prev = 0; // naskitis.com: // Start the timer. #if !defined(_WIN32) - gettimeofday(&start, NULL); + gettimeofday( &start, NULL ); #else - time(start); + time( start ); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *( judy_cell( judy, askitis + prev, off - prev ) ) += 1; // count instances of string prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) - gettimeofday(&stop, NULL); + gettimeofday( &stop, NULL ); - insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); + insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * ( stop.tv_usec - start.tv_usec ); insert_real_time = insert_real_time / 1000.0; #else - time(stop); + time( stop ); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free(askitis); - fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); + free( askitis ); + fprintf( stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time ); + fprintf( stderr, "%-20s %d\n", "Words:", Words ); + fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); + fprintf( stderr, "%-20s %d\n", "Found:", Found ); Words = 0; Inserts = 0; Found = 0; // search judy array - if(in = freopen("skew1_1", "rb", in)) { - size = lseek(fileno(in), 0L, 2); + if( in = freopen( "skew1_1", "rb", in ) ) { + size = lseek( fileno( in ), 0L, 2 ); } else { - exit(0); + exit( 0 ); } - askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + askitis = malloc( size ); + lseek( fileno( in ), 0L, 0 ); + read( fileno( in ), askitis, size ); prev = 0; #if !defined(_WIN32) - gettimeofday(&start, NULL); + gettimeofday( &start, NULL ); #else - time(start); + time( start ); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *judy_cell(judy, askitis + prev, off - prev) += 1; + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *judy_cell( judy, askitis + prev, off - prev ) += 1; prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) - gettimeofday(&stop, NULL); - search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 - * (stop.tv_usec - start.tv_usec); + gettimeofday( &stop, NULL ); + search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 + * ( stop.tv_usec - start.tv_usec ); search_real_time = search_real_time / 1000.0; #else - time(stop); + time( stop ); search_real_time = *stop - *start; #endif // naskitis.com: // To do: report a count on the number of strings found. - fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); - exit(0); + fprintf( stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time ); + fprintf( stderr, "%-20s %d\n", "Words:", Words ); + fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); + fprintf( stderr, "%-20s %d\n", "Found:", Found ); + exit( 0 ); #endif - judy = judy_open(1024, 0); + judy = judy_open( 1024, 0 ); - while(fgets((char *)buff, sizeof(buff), in)) { - if(len = strlen((const char *)buff)) { + while( fgets( ( char * )buff, sizeof( buff ), in ) ) { + if( len = strlen( ( const char * )buff ) ) { buff[--len] = 0; // remove LF } - *(judy_cell(judy, buff, len)) += 1; // count instances of string + *( judy_cell( judy, buff, len ) ) += 1; // count instances of string max++; } - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); + fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { - len = judy_key(judy, buff, sizeof(buff)); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); + if( cell ) do { + len = judy_key( judy, buff, sizeof( buff ) ); + for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates + fwrite( buff, len, 1, out ); + fputc( '\n', out ); } - } while(cell = judy_nxt(judy)); + } while( cell = judy_nxt( judy ) ); #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) + if( cell = judy_prv( judy ) ) do { max -= *cell; - } while(cell = judy_del(judy)); + } while( cell = judy_del( judy ) ); - assert(max == 0); + assert( max == 0 ); #endif - judy_close(judy); + judy_close( judy ); return 0; } diff --git a/src/base/judy/test/sort.c b/src/base/judy/test/sort.c index 53a460312..e483b92e0 100644 --- a/src/base/judy/test/sort.c +++ b/src/base/judy/test/sort.c @@ -24,7 +24,7 @@ // memory map input file and sort // define pennysort parameters -unsigned int PennyRecs = (4096 * 400); // records to sort to temp files +unsigned int PennyRecs = ( 4096 * 400 ); // records to sort to temp files unsigned int PennyLine = 100; // length of input record unsigned int PennyKey = 10; // length of input key unsigned int PennyOff = 0; // key offset in input record @@ -34,16 +34,15 @@ unsigned int PennyPasses; // number of intermediate files created unsigned int PennySortTime; // cpu time to run sort unsigned int PennyMergeTime; // cpu time to run merge -void sort(FILE *infile, char *outname) -{ +void sort( FILE * infile, char * outname ) { unsigned long long size, off, offset, part; - int ifd = fileno(infile); + int ifd = fileno( infile ); char filename[512]; - PennySort *line; - JudySlot *cell; - unsigned char *inbuff; - void *judy; - FILE *out; + PennySort * line; + JudySlot * cell; + unsigned char * inbuff; + void * judy; + FILE * out; #if defined(_WIN32) HANDLE hndl, fm; DWORD hiword; @@ -52,150 +51,149 @@ void sort(FILE *infile, char *outname) #else struct tms buff[1]; #endif - time_t start = time(NULL); + time_t start = time( NULL ); - if(PennyOff + PennyKey > PennyLine) { - fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); + if( PennyOff + PennyKey > PennyLine ) { + fprintf( stderr, "Key Offset + Key Length > Record Length\n" ), exit( 1 ); } offset = 0; PennyPasses = 0; #if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize(hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if(!fm) { - fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); + hndl = ( HANDLE )_get_osfhandle( ifd ); + size = GetFileSize( hndl, &hiword ); + fm = CreateFileMapping( hndl, NULL, PAGE_READONLY, hiword, ( DWORD )size, NULL ); + if( !fm ) { + fprintf( stderr, "CreateFileMapping error %d\n", GetLastError() ), exit( 1 ); } - size |= (unsigned long long)hiword << 32; + size |= ( unsigned long long )hiword << 32; #else - size = lseek(ifd, 0L, 2); + size = lseek( ifd, 0L, 2 ); #endif - while(offset < size) { + while( offset < size ) { #if defined(_WIN32) part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); - if(!inbuff) { - fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); + inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part ); + if( !inbuff ) { + fprintf( stderr, "MapViewOfFile error %d\n", GetLastError() ), exit( 1 ); } #else - inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); + inbuff = mmap( NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset ); - if(inbuff == MAP_FAILED) { - fprintf(stderr, "mmap error %d\n", errno), exit(1); + if( inbuff == MAP_FAILED ) { + fprintf( stderr, "mmap error %d\n", errno ), exit( 1 ); } - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { - fprintf(stderr, "madvise error %d\n", errno); + if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL ) < 0 ) { + fprintf( stderr, "madvise error %d\n", errno ); } #endif - judy = judy_open(PennyKey, 0); + judy = judy_open( PennyKey, 0 ); off = 0; // build judy array from mapped input chunk - while(offset + off < size && off < PennyMerge) { - line = judy_data(judy, sizeof(PennySort)); - cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; + while( offset + off < size && off < PennyMerge ) { + line = judy_data( judy, sizeof( PennySort ) ); + cell = judy_cell( judy, inbuff + off + PennyOff, PennyKey ); + line->next = *( void ** )cell; line->buff = inbuff + off; - *(PennySort **)cell = line; + *( PennySort ** )cell = line; off += PennyLine; } - sprintf(filename, "%s.%d", outname, PennyPasses); - out = fopen(filename, "wb"); - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + sprintf( filename, "%s.%d", outname, PennyPasses ); + out = fopen( filename, "wb" ); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); #ifndef _WIN32 - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { - fprintf(stderr, "madvise error %d\n", errno); + if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM ) < 0 ) { + fprintf( stderr, "madvise error %d\n", errno ); } #endif // write judy array in sorted order to temporary file - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { - line = *(PennySort **)cell; + if( cell ) do { + line = *( PennySort ** )cell; do { - fwrite(line->buff, PennyLine, 1, out); - } while(line = line->next); - } while(cell = judy_nxt(judy)); + fwrite( line->buff, PennyLine, 1, out ); + } while( line = line->next ); + } while( cell = judy_nxt( judy ) ); #if defined(_WIN32) - UnmapViewOfFile(inbuff); + UnmapViewOfFile( inbuff ); #else - munmap(inbuff, PennyMerge); + munmap( inbuff, PennyMerge ); #endif - judy_close(judy); + judy_close( judy ); offset += off; - fflush(out); - fclose(out); + fflush( out ); + fclose( out ); PennyPasses++; } - fprintf(stderr, "End Sort %llu secs", (unsigned long long) time(NULL) - start); + fprintf( stderr, "End Sort %llu secs", ( unsigned long long ) time( NULL ) - start ); #if defined(_WIN32) - CloseHandle(fm); - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long *)user / 10000000; + CloseHandle( fm ); + GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); + PennySortTime = *( unsigned long long * )user / 10000000; #else - times(buff); + times( buff ); PennySortTime = buff->tms_utime / 100; #endif - fprintf(stderr, " Cpu %d\n", PennySortTime); + fprintf( stderr, " Cpu %d\n", PennySortTime ); } -int merge(FILE *out, char *outname) -{ - time_t start = time(NULL); +int merge( FILE * out, char * outname ) { + time_t start = time( NULL ); char filename[512]; - JudySlot *cell; + JudySlot * cell; unsigned int nxt, idx; - unsigned char **line; - unsigned int *next; - void *judy; - FILE **in; + unsigned char ** line; + unsigned int * next; + void * judy; + FILE ** in; - next = calloc(PennyPasses + 1, sizeof(unsigned int)); - line = calloc(PennyPasses, sizeof(void *)); - in = calloc(PennyPasses, sizeof(void *)); + next = calloc( PennyPasses + 1, sizeof( unsigned int ) ); + line = calloc( PennyPasses, sizeof( void * ) ); + in = calloc( PennyPasses, sizeof( void * ) ); - judy = judy_open(PennyKey, 0); + judy = judy_open( PennyKey, 0 ); // initialize merge with one record from each temp file - for(idx = 0; idx < PennyPasses; idx++) { - sprintf(filename, "%s.%d", outname, idx); - in[idx] = fopen(filename, "rb"); - line[idx] = malloc(PennyLine); - setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); - fread(line[idx], PennyLine, 1, in[idx]); - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; + for( idx = 0; idx < PennyPasses; idx++ ) { + sprintf( filename, "%s.%d", outname, idx ); + in[idx] = fopen( filename, "rb" ); + line[idx] = malloc( PennyLine ); + setvbuf( in[idx], NULL, _IOFBF, 4096 * 1024 ); + fread( line[idx], PennyLine, 1, in[idx] ); + cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); + next[idx + 1] = *( unsigned int * )cell; *cell = idx + 1; } // output records, replacing smallest each time - while(cell = judy_strt(judy, NULL, 0)) { - nxt = *(unsigned int *)cell; - judy_del(judy); + while( cell = judy_strt( judy, NULL, 0 ) ) { + nxt = *( unsigned int * )cell; + judy_del( judy ); // process duplicates - while(idx = nxt) { + while( idx = nxt ) { nxt = next[idx--]; - fwrite(line[idx], PennyLine, 1, out); + fwrite( line[idx], PennyLine, 1, out ); - if(fread(line[idx], PennyLine, 1, in[idx])) { - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; + if( fread( line[idx], PennyLine, 1, in[idx] ) ) { + cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); + next[idx + 1] = *( unsigned int * )cell; *cell = idx + 1; } else { next[idx + 1] = 0; @@ -203,33 +201,33 @@ int merge(FILE *out, char *outname) } } - for(idx = 0; idx < PennyPasses; idx++) { - fclose(in[idx]); - free(line[idx]); + for( idx = 0; idx < PennyPasses; idx++ ) { + fclose( in[idx] ); + free( line[idx] ); } - free(line); - free(next); - free(in); + free( line ); + free( next ); + free( in ); - fprintf(stderr, "End Merge %llu secs", (unsigned long long) time(NULL) - start); + fprintf( stderr, "End Merge %llu secs", ( unsigned long long ) time( NULL ) - start ); #ifdef _WIN32 { FILETIME dummy[1]; FILETIME user[1]; - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long *)user / 10000000; + GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); + PennyMergeTime = *( unsigned long long * )user / 10000000; } #else { struct tms buff[1]; - times(buff); + times( buff ); PennyMergeTime = buff->tms_utime / 100; } #endif - fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close(judy); - fflush(out); - fclose(out); + fprintf( stderr, " Cpu %d\n", PennyMergeTime - PennySortTime ); + judy_close( judy ); + fflush( out ); + fclose( out ); return 0; } diff --git a/src/base/judy/test/sort.h b/src/base/judy/test/sort.h index f3f497e72..785e58d69 100644 --- a/src/base/judy/test/sort.h +++ b/src/base/judy/test/sort.h @@ -51,8 +51,8 @@ extern unsigned int PennyOff; extern unsigned long long PennyMerge; typedef struct { - void *buff; // record pointer in input file map - void *next; // duplicate chain + void * buff; // record pointer in input file map + void * next; // duplicate chain } PennySort; #endif //SORT_H \ No newline at end of file diff --git a/src/base/path2str.c b/src/base/path2str.c index a4f88ee3a..6f5aedd7c 100644 --- a/src/base/path2str.c +++ b/src/base/path2str.c @@ -6,22 +6,21 @@ /* for windows, rewrite backslashes in paths * that will be written to generated code */ -const char *path2str_fn(const char *fileMacro) -{ - static char *result = 0; +const char * path2str_fn( const char * fileMacro ) { + static char * result = 0; static size_t rlen = 0; - char *p; - if(rlen < strlen(fileMacro)) { - if(result) { - sc_free(result); + char * p; + if( rlen < strlen( fileMacro ) ) { + if( result ) { + sc_free( result ); } - rlen = strlen(fileMacro); - result = (char *)sc_malloc(rlen * sizeof(char) + 1); + rlen = strlen( fileMacro ); + result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 ); } - strcpy(result, fileMacro); + strcpy( result, fileMacro ); p = result; - while(*p) { - if(*p == '\\') { + while( *p ) { + if( *p == '\\' ) { *p = '/'; } p++; diff --git a/src/base/path2str.h b/src/base/path2str.h index 57f735142..84155cd9f 100644 --- a/src/base/path2str.h +++ b/src/base/path2str.h @@ -9,7 +9,7 @@ * silence "unknown escape sequence" warning when contents of __FILE__ * are fprintf'd into string in generated code */ -SC_BASE_EXPORT const char *path2str_fn(const char *fileMacro); +SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro ); #ifdef _WIN32 # define path2str(path) path2str_fn(path) diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index fcea26dd7..44f085f2f 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -13,7 +13,6 @@ #endif #include -#include #include #include #include @@ -22,12 +21,11 @@ #include /// mem values in kb, times in ms (granularity may be higher than 1ms) -benchVals getMemAndTime() -{ +benchVals getMemAndTime( ) { benchVals vals; #ifdef __linux__ // adapted from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c - std::ifstream stat_stream("/proc/self/stat", std::ios_base::in); + std::ifstream stat_stream( "/proc/self/stat", std::ios_base::in ); // dummy vars for leading entries in stat that we don't care about std::string pid, comm, state, ppid, pgrp, session, tty_nr; @@ -44,11 +42,11 @@ benchVals getMemAndTime() >> utime >> stime >> cutime >> cstime >> priority >> nice >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest - long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages + long page_size_kb = sysconf( _SC_PAGE_SIZE ) / 1024; // in case x86-64 is configured to use 2MB pages vals.physMemKB = rss * page_size_kb; - vals.virtMemKB = (vsize / 1024) - vals.physMemKB; - vals.userMilliseconds = (utime * 1000) / sysconf(_SC_CLK_TCK); - vals.sysMilliseconds = (stime * 1000) / sysconf(_SC_CLK_TCK); + vals.virtMemKB = ( vsize / 1024 ) - vals.physMemKB; + vals.userMilliseconds = ( utime * 1000 ) / sysconf( _SC_CLK_TCK ); + vals.sysMilliseconds = ( stime * 1000 ) / sysconf( _SC_CLK_TCK ); #elif defined(__APPLE__) // http://stackoverflow.com/a/1911863/382458 #elif defined(_WIN32) @@ -58,7 +56,7 @@ benchVals getMemAndTime() long page_size_kb = 1024; ULARGE_INTEGER kTime, uTime; - if(GetProcessMemoryInfo(GetCurrentProcess(), &MemoryCntrs, sizeof(MemoryCntrs))) { + if( GetProcessMemoryInfo( GetCurrentProcess(), &MemoryCntrs, sizeof( MemoryCntrs ) ) ) { vals.physMemKB = MemoryCntrs.PeakWorkingSetSize / page_size_kb; vals.virtMemKB = MemoryCntrs.PeakPagefileUsage / page_size_kb; } else { @@ -66,12 +64,12 @@ benchVals getMemAndTime() vals.virtMemKB = 0; } - if(GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime)) { - assert(sizeof(FILETIME) == sizeof(ULARGE_INTEGER)); - memcpy(&kTime, &KernelTime, sizeof(FILETIME)); - memcpy(&uTime, &UserTime, sizeof(FILETIME)); - vals.userMilliseconds = (long)(uTime.QuadPart / 100000L); - vals.sysMilliseconds = (long)(kTime.QuadPart / 100000L); + if( GetProcessTimes( GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime ) ) { + assert( sizeof( FILETIME ) == sizeof( ULARGE_INTEGER ) ); + memcpy( &kTime, &KernelTime, sizeof( FILETIME ) ); + memcpy( &uTime, &UserTime, sizeof( FILETIME ) ); + vals.userMilliseconds = ( long )( uTime.QuadPart / 100000L ); + vals.sysMilliseconds = ( long )( kTime.QuadPart / 100000L ); } else { vals.userMilliseconds = 0; vals.sysMilliseconds = 0; @@ -84,40 +82,33 @@ benchVals getMemAndTime() // --------------------- benchmark class --------------------- -benchmark::benchmark(bool debugMessages): debug(debugMessages), stopped(false) -{ - initialVals = getMemAndTime(); +benchmark::benchmark( std::string description, bool debugMessages, std::ostream & o_stream ): ostr( o_stream ), + descr( description ), debug( debugMessages ), stopped( false ) { + initialVals = getMemAndTime( ); } -benchmark::~benchmark() -{ - if(!stopped) { - stop(); - if(debug) { - std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; +benchmark::~benchmark() { + if( !stopped ) { + stop( ); + if( debug ) { + ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; } - out(); - } - if(benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; + out( ); } } -void benchmark::stop() -{ - if(stopped) { +void benchmark::stop( ) { + if( stopped ) { std::cerr << "benchmark::stop(): tried to stop a benchmark that was already stopped!" << std::endl; } else { - laterVals = getMemAndTime(); + laterVals = getMemAndTime( ); stopped = true; } } -benchVals benchmark::get() -{ - if(!stopped) { - laterVals = getMemAndTime(); +benchVals benchmark::get( ) { + if( !stopped ) { + laterVals = getMemAndTime( ); } benchVals delta; delta.physMemKB = laterVals.physMemKB - initialVals.physMemKB; @@ -126,41 +117,34 @@ benchVals benchmark::get() delta.userMilliseconds = laterVals.userMilliseconds - initialVals.userMilliseconds; //If vm is negative, the memory had been requested before initialVals was set. Don't count it - if(delta.virtMemKB < 0) { + if( delta.virtMemKB < 0 ) { delta.physMemKB -= delta.virtMemKB; delta.virtMemKB = 0; } return delta; } -void benchmark::reset() -{ +void benchmark::reset( std::string description ) { + descr = description; + reset(); +} +void benchmark::reset( ) { stopped = false; initialVals = getMemAndTime(); } -const char *benchmark::str() -{ - return str(get()); +std::string benchmark::str( ) { + return str( get( ) ); } -void benchmark::out() -{ - std::cout << str() << std::endl; +void benchmark::out() { + ostr << str( ) << std::endl; } -const char *benchmark::str(const benchVals &bv) -{ +std::string benchmark::str( const benchVals & bv ) { std::stringstream ss; - ss << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; + ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; - if(benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; - } - benchVals_str = (char *)calloc(ss.str().length() + 1, sizeof(char)); - snprintf(benchVals_str, ss.str().length(), "%s", ss.str().c_str()); - benchVals_str[ss.str().length()] = '\0'; - return benchVals_str; + return ss.str(); } diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index b11017c6a..8512bd892 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -5,23 +5,25 @@ #include "sc_export.h" #ifdef __cplusplus +#include #include +#include #include "sc_memmgr.h" extern "C" { #endif -typedef struct { - long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; -} benchVals; + typedef struct { + long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; + } benchVals; -/** return a benchVals struct with four current statistics for this process: - * virtual and physical memory use in kb, - * user and system cpu time in ms - * - * not yet implemented for OSX or Windows. - */ -SC_BASE_EXPORT benchVals getMemAndTime(); + /** return a benchVals struct with four current statistics for this process: + * virtual and physical memory use in kb, + * user and system cpu time in ms + * + * not yet implemented for OSX or Windows. + */ + SC_BASE_EXPORT benchVals getMemAndTime( ); #ifdef __cplusplus } @@ -37,30 +39,37 @@ SC_BASE_EXPORT benchVals getMemAndTime(); * depends on getMemAndTime() above - may not work on all platforms. */ -class SC_BASE_EXPORT benchmark -{ +class SC_BASE_EXPORT benchmark { protected: benchVals initialVals, laterVals; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + std::ostream & ostr; + std::string descr; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif bool debug, stopped; - char *benchVals_str = NULL; - public: - benchmark(bool debugMessages = true); + benchmark( std::string description = "", bool debugMessages = true, std::ostream & o_stream = std::cout ); /// if 'stopped' is false, uses str(true) to print to ostream - ~benchmark(); - void reset(); - benchVals get(); - void stop(); + ~benchmark( ); + void reset( ); + void reset( std::string description ); + benchVals get( ); + void stop( ); /// converts data member 'laterVals' into a string and returns it - const char *str(); + std::string str( ); /// outputs result of str() on ostream 'ostr' - void out(); + void out( ); /// converts 'bv' into a string, prefixed by data member 'descr' - const char *str(const benchVals &bv); + std::string str( const benchVals & bv ); }; diff --git a/src/base/sc_getopt.cc b/src/base/sc_getopt.cc index e135f1f31..01e925b56 100644 --- a/src/base/sc_getopt.cc +++ b/src/base/sc_getopt.cc @@ -152,35 +152,34 @@ // /////////////////////////////////////////////////////////////////////////////// -char *sc_optarg; // global argument pointer +char * sc_optarg; // global argument pointer int sc_optind = 0; // global argv index -int sc_getopt(int argc, char *argv[], char *optstring) -{ - static char *next = NULL; - if(sc_optind == 0) { +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { next = NULL; } sc_optarg = NULL; - if(next == NULL || *next == '\0') { - if(sc_optind == 0) { + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { sc_optind++; } - if(sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0') { + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { sc_optarg = NULL; - if(sc_optind < argc) { + if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; } return EOF; } - if(strcmp(argv[sc_optind], "--") == 0) { + if( strcmp( argv[sc_optind], "--" ) == 0 ) { sc_optind++; sc_optarg = NULL; - if(sc_optind < argc) { + if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; } return EOF; @@ -192,18 +191,18 @@ int sc_getopt(int argc, char *argv[], char *optstring) } char c = *next++; - char *cp = strchr(optstring, c); + char * cp = strchr( optstring, c ); - if(cp == NULL || c == ':') { + if( cp == NULL || c == ':' ) { return '?'; } cp++; - if(*cp == ':') { - if(*next != '\0') { + if( *cp == ':' ) { + if( *next != '\0' ) { sc_optarg = next; next = NULL; - } else if(sc_optind < argc) { + } else if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; sc_optind++; } else { diff --git a/src/base/sc_getopt.h b/src/base/sc_getopt.h index 2eedcdf3b..e1421a7bf 100644 --- a/src/base/sc_getopt.h +++ b/src/base/sc_getopt.h @@ -20,10 +20,10 @@ extern "C" { #endif -extern SC_BASE_EXPORT int sc_optind, sc_opterr; -extern SC_BASE_EXPORT char *sc_optarg; + extern SC_BASE_EXPORT int sc_optind, sc_opterr; + extern SC_BASE_EXPORT char * sc_optarg; -int SC_BASE_EXPORT sc_getopt(int argc, char *argv[], char *optstring); + int SC_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring ); #ifdef __cplusplus } diff --git a/src/base/sc_memmgr.cc b/src/base/sc_memmgr.cc index 223bac4db..262d26e28 100644 --- a/src/base/sc_memmgr.cc +++ b/src/base/sc_memmgr.cc @@ -15,22 +15,21 @@ /** sc_memmgr_error definition */ -class sc_memmgr_error -{ +class sc_memmgr_error { private: std::string _srcfile; unsigned int _srcline; unsigned int _occurences; public: - sc_memmgr_error(const std::string &file, const unsigned int line); - sc_memmgr_error(const sc_memmgr_error &rhs); - ~sc_memmgr_error(void); + sc_memmgr_error( const std::string & file, const unsigned int line ); + sc_memmgr_error( const sc_memmgr_error & rhs ); + ~sc_memmgr_error( void ); - bool operator<(const sc_memmgr_error &rhs) const; + bool operator<( const sc_memmgr_error & rhs ) const; - std::string getsrcfile(void) const; - unsigned int getsrcline(void) const; - unsigned int getoccurences(void) const; + std::string getsrcfile( void ) const; + unsigned int getsrcline( void ) const; + unsigned int getoccurences( void ) const; }; typedef std::set sc_memmgr_errors; @@ -39,25 +38,24 @@ typedef std::set::iterator sc_memmgr_error_iterator; /** sc_memmgr_record definition */ -class sc_memmgr_record -{ +class sc_memmgr_record { private: - void *_addr; + void * _addr; size_t _size; std::string _srcfile; unsigned int _srcline; public: - sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line); - sc_memmgr_record(void *addr); - sc_memmgr_record(const sc_memmgr_record &rhs); - ~sc_memmgr_record(void); + sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ); + sc_memmgr_record( void * addr ); + sc_memmgr_record( const sc_memmgr_record & rhs ); + ~sc_memmgr_record( void ); - bool operator<(const sc_memmgr_record &rhs) const; + bool operator<( const sc_memmgr_record & rhs ) const; - void *getaddr(void) const; - size_t getsize(void) const; - std::string getsrcfile(void) const; - unsigned int getsrcline(void) const; + void * getaddr( void ) const; + size_t getsize( void ) const; + std::string getsrcfile( void ) const; + unsigned int getsrcline( void ) const; }; typedef std::set sc_memmgr_records; @@ -68,8 +66,7 @@ typedef std::set::iterator sc_memmgr_record_iterator; /** sc_memmgr definition */ -class sc_memmgr -{ +class sc_memmgr { private: #ifdef SC_MEMMGR_ENABLE_CHECKS bool _record_insert_busy, _record_erase_busy; @@ -84,12 +81,12 @@ class sc_memmgr #endif /* SC_MEMMGR_ENABLE_CHECKS */ protected: public: - sc_memmgr(void); - ~sc_memmgr(void); + sc_memmgr( void ); + ~sc_memmgr( void ); - void *allocate(size_t size, const char *file, const int line); - void *reallocate(void *addr, size_t size, const char *file, const int line); - void deallocate(void *addr, const char *file, const int line); + void * allocate( size_t size, const char * file, const int line ); + void * reallocate( void * addr, size_t size, const char * file, const int line ); + void deallocate( void * addr, const char * file, const int line ); }; /** @@ -105,24 +102,20 @@ sc_memmgr memmgr; */ extern "C" { - void *sc_malloc_fn(unsigned int size, const char *file, const int line) - { - return memmgr.allocate(size, file, line); + void * sc_malloc_fn( unsigned int size, const char * file, const int line ) { + return memmgr.allocate( size, file, line ); } - void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line) - { - return memmgr.allocate(count * size, file, line); + void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) { + return memmgr.allocate( count * size, file, line ); } - void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line) - { - return memmgr.reallocate(addr, size, file, line); + void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) { + return memmgr.reallocate( addr, size, file, line ); } - void sc_free_fn(void *addr) - { - memmgr.deallocate(addr, "", 0); + void sc_free_fn( void * addr ) { + memmgr.deallocate( addr, "", 0 ); } } @@ -130,26 +123,22 @@ extern "C" { /** c++ memory operators implementation */ -void *sc_operator_new(size_t size, const char *file, const int line) -{ - return memmgr.allocate(size, file, line); +void * sc_operator_new( size_t size, const char * file, const int line ) { + return memmgr.allocate( size, file, line ); } -void sc_operator_delete(void *addr, const char *file, const int line) -{ - memmgr.deallocate(addr, file, line); +void sc_operator_delete( void * addr, const char * file, const int line ) { + memmgr.deallocate( addr, file, line ); } -void sc_operator_delete(void *addr) -{ - memmgr.deallocate(addr, "", 0); +void sc_operator_delete( void * addr ) { + memmgr.deallocate( addr, "", 0 ); } /** sc_memmgr implementation */ -sc_memmgr::sc_memmgr(void) -{ +sc_memmgr::sc_memmgr( void ) { #ifdef SC_MEMMGR_ENABLE_CHECKS _record_insert_busy = false; _record_erase_busy = false; @@ -170,29 +159,28 @@ sc_memmgr::sc_memmgr(void) All records still present when sc_memmgr instance is destroyed can be considered as memory leaks. */ -sc_memmgr::~sc_memmgr(void) -{ +sc_memmgr::~sc_memmgr( void ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator irecord; sc_memmgr_errors errors; sc_memmgr_error_iterator ierror; // Check if total allocated equals total deallocated - if(_allocated_total != _deallocated_total) { + if( _allocated_total != _deallocated_total ) { // todo: generate warning for possible memory leaks, enable full memory leak checking - fprintf(stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total); + fprintf( stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total ); } // Compact leaks into an error list to prevent same leak being reported multiple times. _record_insert_busy = true; _record_erase_busy = true; - for(irecord = _records.begin(); + for( irecord = _records.begin(); irecord != _records.end(); - irecord ++) { - sc_memmgr_error error(irecord->getsrcfile(), irecord->getsrcline()); - ierror = errors.find(error); - if(ierror == errors.end()) { - errors.insert(error); + irecord ++ ) { + sc_memmgr_error error( irecord->getsrcfile(), irecord->getsrcline() ); + ierror = errors.find( error ); + if( ierror == errors.end() ) { + errors.insert( error ); } //else // ierror->occurences ++; @@ -201,11 +189,11 @@ sc_memmgr::~sc_memmgr(void) _record_erase_busy = false; // Loop through memory leaks to generate/buffer errors - for(ierror = errors.begin(); + for( ierror = errors.begin(); ierror != errors.end(); - ierror ++) { + ierror ++ ) { // todo: generate error for memory leak - fprintf(stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline()); + fprintf( stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline() ); } // Clear remaining records @@ -216,15 +204,14 @@ sc_memmgr::~sc_memmgr(void) #endif /* SC_MEMMGR_ENABLE_CHECKS */ } -void *sc_memmgr::allocate(size_t size, const char *file, const int line) -{ - void *addr; +void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { + void * addr; // Allocate - addr = malloc(size); - if(addr == NULL) { + addr = malloc( size ); + if( addr == NULL ) { // todo: error allocation failed - fprintf(stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line ); } // Some stl implementations (for example debian gcc) use the new operator to construct @@ -232,15 +219,15 @@ void *sc_memmgr::allocate(size_t size, const char *file, const int line) // for this operation, this would result in an infinite loop. This is fixed by the // _record_insert_busy flag. #ifdef SC_MEMMGR_ENABLE_CHECKS - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Store record for this allocation _record_insert_busy = true; - _records.insert(sc_memmgr_record(addr, size, file, line)); + _records.insert( sc_memmgr_record( addr, size, file, line ) ); _record_insert_busy = false; // Update stats _allocated += size; - if(_allocated > _maximum_allocated) { + if( _allocated > _maximum_allocated ) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -250,17 +237,16 @@ void *sc_memmgr::allocate(size_t size, const char *file, const int line) return addr; } -void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int line) -{ +void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const int line ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Find record of previous allocation/reallocation - record = _records.find(sc_memmgr_record(addr)); - if(record == _records.end()) { + record = _records.find( sc_memmgr_record( addr ) ); + if( record == _records.end() ) { // todo: error reallocating memory not allocated? - fprintf(stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line ); } else { // Update stats _allocated -= record->getsize(); @@ -268,29 +254,29 @@ void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int // Erase previous allocation/reallocation _record_erase_busy = true; - _records.erase(record); + _records.erase( record ); _record_erase_busy = false; } } #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Reallocate - addr = realloc(addr, size); - if(addr == NULL) { + addr = realloc( addr, size ); + if( addr == NULL ) { // todo: error reallocation failed - fprintf(stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line ); } #ifdef SC_MEMMGR_ENABLE_CHECKS - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Store record for this reallocation _record_insert_busy = true; - _records.insert(sc_memmgr_record(addr, size, file, line)); + _records.insert( sc_memmgr_record( addr, size, file, line ) ); _record_insert_busy = false; // Update stats _allocated += size; - if(_allocated > _maximum_allocated) { + if( _allocated > _maximum_allocated ) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -301,17 +287,16 @@ void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int return addr; } -void sc_memmgr::deallocate(void *addr, const char *file, const int line) -{ +void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if(!_record_erase_busy) { + if( !_record_erase_busy ) { // Find record of previous allocation/reallocation - record = _records.find(sc_memmgr_record(addr)); - if(record == _records.end()) { + record = _records.find( sc_memmgr_record( addr ) ); + if( record == _records.end() ) { // todo: error free called for not allocated memory? - fprintf(stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line ); } else { // Update stats _allocated -= record->getsize(); @@ -319,7 +304,7 @@ void sc_memmgr::deallocate(void *addr, const char *file, const int line) // Erase record _record_erase_busy = true; - _records.erase(record); + _records.erase( record ); _record_erase_busy = false; } } @@ -329,107 +314,91 @@ void sc_memmgr::deallocate(void *addr, const char *file, const int line) #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Deallocate - free(addr); + free( addr ); } #ifdef SC_MEMMGR_ENABLE_CHECKS /** sc_memmgr_error implementation */ -sc_memmgr_error::sc_memmgr_error(const std::string &file, const unsigned int line) -{ +sc_memmgr_error::sc_memmgr_error( const std::string & file, const unsigned int line ) { _srcfile = file; _srcline = line; _occurences = 1; } -sc_memmgr_error::sc_memmgr_error(const sc_memmgr_error &rhs) -{ +sc_memmgr_error::sc_memmgr_error( const sc_memmgr_error & rhs ) { _srcfile = rhs._srcfile; _srcline = rhs._srcline; _occurences = rhs._occurences; } -sc_memmgr_error::~sc_memmgr_error(void) -{ +sc_memmgr_error::~sc_memmgr_error( void ) { } -bool sc_memmgr_error::operator<(const sc_memmgr_error &rhs) const -{ - if(_srcfile == rhs._srcfile) { +bool sc_memmgr_error::operator<( const sc_memmgr_error & rhs ) const { + if( _srcfile == rhs._srcfile ) { return _srcline < rhs._srcline; } return _srcfile < rhs._srcfile; } -std::string sc_memmgr_error::getsrcfile(void) const -{ +std::string sc_memmgr_error::getsrcfile( void ) const { return _srcfile; } -unsigned int sc_memmgr_error::getsrcline(void) const -{ +unsigned int sc_memmgr_error::getsrcline( void ) const { return _srcline; } -unsigned int sc_memmgr_error::getoccurences(void) const -{ +unsigned int sc_memmgr_error::getoccurences( void ) const { return _occurences; } /** sc_memmgr_record implementation */ -sc_memmgr_record::sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line) -{ +sc_memmgr_record::sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ) { _addr = addr; _size = size; _srcfile = file; _srcline = line; } -sc_memmgr_record::sc_memmgr_record(void *addr) -{ +sc_memmgr_record::sc_memmgr_record( void * addr ) { _addr = addr; _size = 0; _srcfile = ""; _srcline = -1; } -sc_memmgr_record::sc_memmgr_record(const sc_memmgr_record &rhs) -{ +sc_memmgr_record::sc_memmgr_record( const sc_memmgr_record & rhs ) { _addr = rhs._addr; _size = rhs._size; _srcfile = rhs._srcfile; _srcline = rhs._srcline; } -sc_memmgr_record::~sc_memmgr_record(void) -{ +sc_memmgr_record::~sc_memmgr_record( void ) { } -bool sc_memmgr_record::operator<(const sc_memmgr_record &rhs) const -{ +bool sc_memmgr_record::operator<( const sc_memmgr_record & rhs ) const { return _addr < rhs._addr; } -void *sc_memmgr_record::getaddr(void) const -{ +void * sc_memmgr_record::getaddr( void ) const { return _addr; } -size_t sc_memmgr_record::getsize(void) const -{ +size_t sc_memmgr_record::getsize( void ) const { return _size; } -std::string sc_memmgr_record::getsrcfile(void) const -{ +std::string sc_memmgr_record::getsrcfile( void ) const { return _srcfile; } -unsigned int sc_memmgr_record::getsrcline(void) const -{ +unsigned int sc_memmgr_record::getsrcline( void ) const { return _srcline; } diff --git a/src/base/sc_memmgr.h b/src/base/sc_memmgr.h index b1b05d2d4..9517a20bc 100644 --- a/src/base/sc_memmgr.h +++ b/src/base/sc_memmgr.h @@ -11,10 +11,10 @@ extern "C" { #endif /* __cplusplus */ -SC_BASE_EXPORT void *sc_malloc_fn(unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void sc_free_fn(void *addr); + SC_BASE_EXPORT void * sc_malloc_fn( unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void sc_free_fn( void * addr ); #ifdef __cplusplus } @@ -22,9 +22,9 @@ SC_BASE_EXPORT void sc_free_fn(void *addr); #ifdef __cplusplus -SC_BASE_EXPORT void *sc_operator_new(size_t size, const char *file, const int line); -SC_BASE_EXPORT void sc_operator_delete(void *addr, const char *file, const int line); -SC_BASE_EXPORT void sc_operator_delete(void *addr); +SC_BASE_EXPORT void * sc_operator_new( size_t size, const char * file, const int line ); +SC_BASE_EXPORT void sc_operator_delete( void * addr, const char * file, const int line ); +SC_BASE_EXPORT void sc_operator_delete( void * addr ); #endif /* __cplusplus */ @@ -39,34 +39,28 @@ SC_BASE_EXPORT void sc_operator_delete(void *addr); #include -inline void *operator new(size_t size, const char *file, const int line) throw(std::bad_alloc) -{ - return sc_operator_new(size, file, line); +inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) { + return sc_operator_new( size, file, line ); } -inline void *operator new[](size_t size, const char *file, const int line) throw(std::bad_alloc) -{ - return sc_operator_new(size, file, line); +inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) { + return sc_operator_new( size, file, line ); } -inline void operator delete(void *addr, const char *file, const int line) throw(std::bad_alloc) -{ - sc_operator_delete(addr, file, line); +inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) { + sc_operator_delete( addr, file, line ); } -inline void operator delete[](void *addr, const char *file, const int line) throw(std::bad_alloc) -{ - sc_operator_delete(addr, file, line); +inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) { + sc_operator_delete( addr, file, line ); } -inline void operator delete(void *addr) throw() -{ - sc_operator_delete(addr); +inline void operator delete( void * addr ) throw () { + sc_operator_delete( addr ); } -inline void operator delete[](void *addr) throw() -{ - sc_operator_delete(addr); +inline void operator delete[]( void * addr ) throw () { + sc_operator_delete( addr ); } #define new new(__FILE__, __LINE__) diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c index bcfaac0e3..1a908155c 100644 --- a/src/base/sc_mkdir.c +++ b/src/base/sc_mkdir.c @@ -1,4 +1,4 @@ -#define _XOPEN_SOURCE /* for S_IFDIR */ + #include "sc_mkdir.h" #include @@ -9,24 +9,22 @@ #endif /* _WIN32 */ /* cross-platform mkdir */ -int sc_mkdir(const char *path) -{ -#ifdef _WIN32 - return mkdir(path); -#else - return mkdir(path, 0777); -#endif /* _WIN32 */ +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) -{ +int mkDirIfNone( const char * path ) { struct stat s; - if(stat(path, &s) != 0) { - if(errno == ENOENT) { - return sc_mkdir(path); + if( stat( path, &s ) != 0 ) { + if( errno == ENOENT ) { + return sc_mkdir( path ); } - } else if(s.st_mode & S_IFDIR) { + } 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 */ diff --git a/src/base/sc_mkdir.h b/src/base/sc_mkdir.h index 34bea074c..21c8d9c5c 100644 --- a/src/base/sc_mkdir.h +++ b/src/base/sc_mkdir.h @@ -4,12 +4,12 @@ #include /** cross-platform mkdir() */ -SC_BASE_EXPORT int sc_mkdir(const char *path); +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); +SC_BASE_EXPORT int mkDirIfNone( const char * path ); #endif /* SC_MKDIR */ diff --git a/src/base/sc_nullptr.h b/src/base/sc_nullptr.h new file mode 100644 index 000000000..342397001 --- /dev/null +++ b/src/base/sc_nullptr.h @@ -0,0 +1,13 @@ +#ifndef NULLPTR_H +#define NULLPTR_H + +#include + +#ifdef HAVE_NULLPTR +#include +#else +# define nullptr_t void* +# define nullptr NULL +#endif //HAVE_NULLPTR + +#endif //NULLPTR_H diff --git a/src/base/sc_stdio.h b/src/base/sc_stdio.h index 717be249c..78fefc53b 100644 --- a/src/base/sc_stdio.h +++ b/src/base/sc_stdio.h @@ -10,23 +10,19 @@ #include static __inline int -c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) -{ +c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) { int count = -1; - if(sz != 0) { + if (sz != 0) count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap); - } - if(count == -1) { + if (count == -1) count = _vscprintf(format, ap); - } return count; } static __inline int -c99_snprintf(char *buffer, size_t sz, const char *format, ...) -{ +c99_snprintf(char *buffer, size_t sz, const char *format, ...) { int count; va_list ap; diff --git a/src/base/sc_trace_fprintf.c b/src/base/sc_trace_fprintf.c index 4ec3fde56..95ca6b9c6 100644 --- a/src/base/sc_trace_fprintf.c +++ b/src/base/sc_trace_fprintf.c @@ -4,14 +4,13 @@ #include "sc_trace_fprintf.h" -void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...) -{ +void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) { va_list args; - if((file != stdout) && (file != stderr)) { - fprintf(file, "/* source: %s:%d */", sourcefile, line); + if( ( file != stdout ) && ( file != stderr ) ) { + fprintf( file, "/* source: %s:%d */", sourcefile, line ); } - va_start(args, format); - vfprintf(file, format, args); - va_end(args); + va_start( args, format ); + vfprintf( file, format, args ); + va_end( args ); } diff --git a/src/base/sc_trace_fprintf.h b/src/base/sc_trace_fprintf.h index c09803ef0..b7aa05fa2 100644 --- a/src/base/sc_trace_fprintf.h +++ b/src/base/sc_trace_fprintf.h @@ -17,10 +17,10 @@ #ifdef __cplusplus extern "C" { #endif -/** Used to find where generated c++ originates from in exp2cxx. - * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' - */ -SC_BASE_EXPORT void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...); + /** Used to find where generated c++ originates from in exp2cxx. + * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' + */ + SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ); #ifdef __cplusplus } #endif diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 023ce1ab6..2978f8c7a 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -36,19 +36,19 @@ include_directories( set(_libdeps steputils base) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLDAI_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cldai) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai) # Local Variables: # tab-width: 8 diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index 768cdded9..30a9103f4 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -37,116 +37,105 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Application_instance__set::SDAI_Application_instance__set(int defaultSize) -{ +SDAI_Application_instance__set::SDAI_Application_instance__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Application_instance_ptr[_bufsize]; _count = 0; } -SDAI_Application_instance__set::~SDAI_Application_instance__set() -{ +SDAI_Application_instance__set::~SDAI_Application_instance__set() { delete _buf; } -void SDAI_Application_instance__set::Check(int index) -{ - SDAI_Application_instance_ptr *newbuf; +void SDAI_Application_instance__set::Check( int index ) { + SDAI_Application_instance_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Application_instance_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Application_instance_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Application_instance_ptr ) ); delete _buf; _buf = newbuf; } } -void SDAI_Application_instance__set::Insert(SDAI_Application_instance_ptr v, int index) -{ - SDAI_Application_instance_ptr *spot; - index = (index < 0) ? _count : index; +void SDAI_Application_instance__set::Insert( SDAI_Application_instance_ptr v, int index ) { + SDAI_Application_instance_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Append(SDAI_Application_instance_ptr v) -{ +void SDAI_Application_instance__set::Append( SDAI_Application_instance_ptr v ) { int index = _count; - SDAI_Application_instance_ptr *spot; + SDAI_Application_instance_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void SDAI_Application_instance__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Application_instance_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + SDAI_Application_instance_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } } -void SDAI_Application_instance__set::Remove(SDAI_Application_instance_ptr a) -{ - int index = Index(a); - if(!(index < 0)) { - Remove(index); +void SDAI_Application_instance__set::Remove( SDAI_Application_instance_ptr a ) { + int index = Index( a ); + if( !( index < 0 ) ) { + Remove( index ); } } -int SDAI_Application_instance__set::Index(SDAI_Application_instance_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int SDAI_Application_instance__set::Index( SDAI_Application_instance_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -SDAI_Application_instance_ptr &SDAI_Application_instance__set::operator[](int index) -{ - Check(index); +SDAI_Application_instance_ptr & SDAI_Application_instance__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Application_instance__set::Count() -{ +SDAI_Application_instance__set::Count() { return _count; } void -SDAI_Application_instance__set::Clear() -{ +SDAI_Application_instance__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiApplication_instance_set.h b/src/cldai/sdaiApplication_instance_set.h index ebe1dbfbe..378e65443 100644 --- a/src/cldai/sdaiApplication_instance_set.h +++ b/src/cldai/sdaiApplication_instance_set.h @@ -34,28 +34,27 @@ class SDAI_Application_instance; class SDAI_Application_instance__set; -typedef SDAI_Application_instance__set *SDAI_Application_instance__set_ptr; +typedef SDAI_Application_instance__set * SDAI_Application_instance__set_ptr; typedef SDAI_Application_instance__set_ptr SDAI_Application_instance__set_var; -class SC_DAI_EXPORT SDAI_Application_instance__set -{ +class SC_DAI_EXPORT SDAI_Application_instance__set { public: - SDAI_Application_instance__set(int = 16); + SDAI_Application_instance__set( int = 16 ); ~SDAI_Application_instance__set(); - SDAI_Application_instance *&operator[](int index); - void Insert(SDAI_Application_instance *, int index); - void Append(SDAI_Application_instance *); - void Remove(int index); - void Remove(SDAI_Application_instance *); - int Index(SDAI_Application_instance *); + SDAI_Application_instance *& operator[]( int index ); + void Insert( SDAI_Application_instance *, int index ); + void Append( SDAI_Application_instance * ); + void Remove( int index ); + void Remove( SDAI_Application_instance * ); + int Index( SDAI_Application_instance * ); int Count(); void Clear(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Application_instance **_buf; + SDAI_Application_instance ** _buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index d82dcdbee..678add01c 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -9,102 +9,46 @@ * and is not subject to copyright. */ -#include #include #include #include "sc_memmgr.h" -SDAI_Binary::SDAI_Binary(const char *str, int max) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(max + 1, sizeof(char)); - snprintf(content, max, "%s", str); -} - -SDAI_Binary::SDAI_Binary(const char *s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(strlen(s) + 1, sizeof(char)); - snprintf(content, strlen(s), "%s", s); -} - -SDAI_Binary::SDAI_Binary(const std::string &s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(s.length() + 1, sizeof(char)); - snprintf(content, s.length(), "%s", s.c_str()); +SDAI_Binary::SDAI_Binary( const char * str, int max ) { + content = std::string( str, max ); } -SDAI_Binary::SDAI_Binary(int i) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(2, sizeof(char)); - if(i) { - content[0] = '1'; - } else { - content[0] = '0'; - } - content[1] = '\0'; +SDAI_Binary::SDAI_Binary( const std::string & s ) { + content = std::string( s ); } -SDAI_Binary::~SDAI_Binary(void) -{ - if(content) { - free((void *)content); - } - content = NULL; +SDAI_Binary::~SDAI_Binary( void ) { } -SDAI_Binary &SDAI_Binary::operator= (const char *s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(strlen(s) + 1, sizeof(char)); - snprintf(content, strlen(s), "%s", s); +SDAI_Binary & SDAI_Binary::operator= ( const char * s ) { + content = std::string( s ); return *this; } -void SDAI_Binary::clear(void) -{ - if(content) { - free((void *)content); - } - content = NULL; +void SDAI_Binary::clear( void ) { + content.clear(); } -bool SDAI_Binary::empty(void) const -{ - return (!content) ? true : false; +bool SDAI_Binary::empty( void ) const { + return content.empty(); } -const char *SDAI_Binary::c_str(void) const -{ - return (const char *)content; +const char * SDAI_Binary::c_str( void ) const { + return content.c_str(); } -void SDAI_Binary::STEPwrite(ostream &out) const -{ - const char *str = 0; - if(empty()) { +void SDAI_Binary::STEPwrite( ostream & out ) const { + const char * str = 0; + if( empty() ) { out << "$"; } else { out << '\"'; str = c_str(); - while(*str) { + while( *str ) { out << *str; str++; } @@ -112,27 +56,25 @@ void SDAI_Binary::STEPwrite(ostream &out) const } } -const char *SDAI_Binary::STEPwrite(std::string &s) const -{ - const char *str = 0; - if(empty()) { +const char * SDAI_Binary::STEPwrite( std::string & s ) const { + const char * str = 0; + if( empty() ) { s = "$"; } else { s = "\""; str = c_str(); - while(*str) { + while( *str ) { s += *str; str++; } s += BINARY_DELIM; } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -Severity SDAI_Binary::ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_Binary::ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { clear(); } @@ -142,82 +84,79 @@ Severity SDAI_Binary::ReadBinary(istream &in, ErrorDescriptor *err, int AssignVa in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if((c == '\"') || isxdigit(c)) { + in.get( c ); + if( ( c == '\"' ) || isxdigit( c ) ) { int validDelimiters = 1; - if(c == '\"') { - in.get(c); // push past the delimiter + if( c == '\"' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } - while(in.good() && isxdigit(c)) { + while( in.good() && isxdigit( c ) ) { str += c; - in.get(c); + in.get( c ); } - if(in.good() && (c != '\"')) { - in.putback(c); + if( in.good() && ( c != '\"' ) ) { + in.putback( c ); } - if(AssignVal && (str.length() > 0)) { - operator= (str.c_str()); + if( AssignVal && ( str.length() > 0 ) ) { + operator= ( str.c_str() ); } - if(c == '\"') { // if found ending delimiter + if( c == '\"' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Binary value missing double quote delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Binary value missing double quote delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched double quote delimiters for binary.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched double quote delimiters for binary.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid binary value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid binary value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } -Severity SDAI_Binary::StrToVal(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); // sz defaults to length of s - return ReadBinary(in, err, 1, 0); +Severity SDAI_Binary::StrToVal( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); // sz defaults to length of s + return ReadBinary( in, err, 1, 0 ); } ///////////////////////////////////////////////// /// reads a binary in exchange file format delimited by double quotes -Severity SDAI_Binary::STEPread(istream &in, ErrorDescriptor *err) -{ - return ReadBinary(in, err, 1, 1); +Severity SDAI_Binary::STEPread( istream & in, ErrorDescriptor * err ) { + return ReadBinary( in, err, 1, 1 ); } -Severity SDAI_Binary::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); - return STEPread(in, err); +Severity SDAI_Binary::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); + return STEPread( in, err ); } /***************************************************************************//** @@ -239,47 +178,45 @@ Severity SDAI_Binary::STEPread(const char *s, ErrorDescriptor *err) ** null then attrValue must only contain a valid value and nothing else ** following. ******************************************************************************/ -Severity SDAI_Binary::BinaryValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - if(clearError) { +Severity SDAI_Binary::BinaryValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + if( clearError ) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = in.peek(); - if(c == '$' || in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( c == '$' || in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - if(in) { + if( in ) { in >> c; } - CheckRemainingInput(in, err, "binary", tokenList); + CheckRemainingInput( in, err, "binary", tokenList ); return err->severity(); } else { ErrorDescriptor error; - ReadBinary(in, &error, 0, needDelims); - CheckRemainingInput(in, &error, "binary", tokenList); + ReadBinary( in, &error, 0, needDelims ); + CheckRemainingInput( in, &error, "binary", tokenList ); Severity sev = error.severity(); - if(sev < SEVERITY_INCOMPLETE) { - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); - } else if(sev == SEVERITY_INCOMPLETE && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( sev < SEVERITY_INCOMPLETE ) { + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); + } else if( sev == SEVERITY_INCOMPLETE && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -Severity SDAI_Binary::BinaryValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - istringstream in((char *)value); - return BinaryValidLevel(in, err, optional, tokenList, - needDelims, clearError); +Severity SDAI_Binary::BinaryValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + istringstream in( ( char * )value ); + return BinaryValidLevel( in, err, optional, tokenList, + needDelims, clearError ); } diff --git a/src/cldai/sdaiBinary.h b/src/cldai/sdaiBinary.h index fb2204f9b..76bb56d18 100644 --- a/src/cldai/sdaiBinary.h +++ b/src/cldai/sdaiBinary.h @@ -1,10 +1,7 @@ #ifndef SDAIBINARY_H #define SDAIBINARY_H 1 -#include "sc_export.h" -#include "errordesc.h" - -#include +#include /* * NIST STEP Core Class Library @@ -16,48 +13,51 @@ * and is not subject to copyright. */ -class SC_DAI_EXPORT SDAI_Binary -{ +class SC_DAI_EXPORT SDAI_Binary { private: - char *content = NULL; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + std::string content; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif public: //constructor(s) & destructor - SDAI_Binary(const char *str = 0, int max = 0); - SDAI_Binary(const char *s); - SDAI_Binary(const std::string &s); - SDAI_Binary(int i); - ~SDAI_Binary(void); + SDAI_Binary( const char * str = 0, int max = 0 ); + SDAI_Binary( const std::string & s ); + ~SDAI_Binary( void ); // operators - SDAI_Binary &operator= (const char *s); + SDAI_Binary & operator= ( const char * s ); - void clear(void); - bool empty(void) const; - const char *c_str(void) const; + void clear( void ); + bool empty( void ) const; + const char * c_str( void ) const; // format for STEP - const char *asStr() const - { + const char * asStr() const { return c_str(); } - void STEPwrite(std::ostream &out = std::cout) const; - const char *STEPwrite(std::string &s) const; + void STEPwrite( ostream & out = cout ) const; + const char * STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s, ErrorDescriptor *err); - Severity STEPread(istream &in, ErrorDescriptor *err); - Severity STEPread(const char *s, ErrorDescriptor *err); + Severity StrToVal( const char * s, ErrorDescriptor * err ); + Severity STEPread( istream & in, ErrorDescriptor * err ); + Severity STEPread( const char * s, ErrorDescriptor * err ); - Severity BinaryValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); - Severity BinaryValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity BinaryValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); + Severity BinaryValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); protected: - Severity ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal = 1, - int needDelims = 1); + Severity ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal = 1, + int needDelims = 1 ); }; #endif diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index 5c35e4e7e..2f43ab284 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -9,45 +9,36 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif -SDAI_PID::SDAI_PID() -{ +SDAI_PID::SDAI_PID() { } -SDAI_PID::~SDAI_PID() -{ +SDAI_PID::~SDAI_PID() { } -SDAI_PID_DA::SDAI_PID_DA() -{ +SDAI_PID_DA::SDAI_PID_DA() { } -SDAI_PID_DA::~SDAI_PID_DA() -{ +SDAI_PID_DA::~SDAI_PID_DA() { } -SDAI_PID_SDAI::SDAI_PID_SDAI() -{ +SDAI_PID_SDAI::SDAI_PID_SDAI() { } -SDAI_PID_SDAI::~SDAI_PID_SDAI() -{ +SDAI_PID_SDAI::~SDAI_PID_SDAI() { } -SDAI_DAObject::SDAI_DAObject() -{ +SDAI_DAObject::SDAI_DAObject() { } -SDAI_DAObject::~SDAI_DAObject() -{ +SDAI_DAObject::~SDAI_DAObject() { } -SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() -{ +SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() { } /* @@ -56,8 +47,7 @@ SDAI_DAObject_SDAI::SDAI_DAObject_SDAI(const DAObject_SDAI&) } */ -SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() -{ +SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() { } /* @@ -88,86 +78,79 @@ SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() /*****************************************************************************/ -SDAI_DAObject__set::SDAI_DAObject__set(int defaultSize) -{ +SDAI_DAObject__set::SDAI_DAObject__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_DAObject_ptr[_bufsize]; _count = 0; } -SDAI_DAObject__set::~SDAI_DAObject__set() -{ +SDAI_DAObject__set::~SDAI_DAObject__set() { delete _buf; } -void SDAI_DAObject__set::Check(int index) -{ +void SDAI_DAObject__set::Check( int index ) { - SDAI_DAObject_ptr *newbuf; + SDAI_DAObject_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_DAObject_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_DAObject_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_DAObject_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_DAObject__set::Insert(SDAI_DAObject_ptr v, int index) -{ +SDAI_DAObject__set::Insert( SDAI_DAObject_ptr v, int index ) { - SDAI_DAObject_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_DAObject_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Append(SDAI_DAObject_ptr v) -{ +void SDAI_DAObject__set::Append( SDAI_DAObject_ptr v ) { int index = _count; - SDAI_DAObject_ptr *spot; + SDAI_DAObject_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Remove(int index) -{ +void SDAI_DAObject__set::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_DAObject_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_DAObject_ptr)); + SDAI_DAObject_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } } -int SDAI_DAObject__set::Index(SDAI_DAObject_ptr v) -{ +int SDAI_DAObject__set::Index( SDAI_DAObject_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -175,34 +158,29 @@ int SDAI_DAObject__set::Index(SDAI_DAObject_ptr v) } SDAI_DAObject_ptr -SDAI_DAObject__set::retrieve(int index) -{ - return operator[](index); +SDAI_DAObject__set::retrieve( int index ) { + return operator[]( index ); } -SDAI_DAObject_ptr &SDAI_DAObject__set::operator[](int index) -{ +SDAI_DAObject_ptr & SDAI_DAObject__set::operator[]( int index ) { - Check(index); + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_DAObject__set::Count() -{ +SDAI_DAObject__set::Count() { return _count; } int -SDAI_DAObject__set::is_empty() -{ +SDAI_DAObject__set::is_empty() { return _count; } void -SDAI_DAObject__set::Clear() -{ +SDAI_DAObject__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiDaObject.h b/src/cldai/sdaiDaObject.h index 97af663be..168c7bfbc 100644 --- a/src/cldai/sdaiDaObject.h +++ b/src/cldai/sdaiDaObject.h @@ -7,7 +7,7 @@ #include -typedef char *SDAI_DAObjectID; +typedef char * SDAI_DAObjectID; // // The PID class maintains the persistent object identifier for every @@ -24,8 +24,7 @@ typedef char *SDAI_DAObjectID; SDAI_DAObjectID as follows: */ /// interface PID (ISO/DIS 10303-23:1996(E) 5.3.10.1) -class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject { public: // These are in the IDL generated code for Part 26. I will have to think about @@ -45,22 +44,20 @@ class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject The Datestore_type attribute shall identify the type of the underlying datastore. */ - char *Datastore_type() const - { - return const_cast(_datastore_type.c_str()); + char * Datastore_type() const { + return const_cast( _datastore_type.c_str() ); } - void Datastore_type(char *x) - { + void Datastore_type( char * x ) { _datastore_type = x; } /* This function shall return a string version of the receiver. */ - char *get_PIDString(); + char * get_PIDString(); }; -typedef SDAI_PID *SDAI_PID_ptr; +typedef SDAI_PID * SDAI_PID_ptr; typedef SDAI_PID_ptr SDAI_PID_var; @@ -84,8 +81,7 @@ typedef SDAI_PID_ptr SDAI_PID_var; // interface. // /// interface PID_DA (ISO/DIS 10303-23:1996(E) 5.3.10.3) -class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID -{ +class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID { public: SDAI_String _oid; @@ -105,17 +101,15 @@ class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID SDAI_PID_DA(); virtual ~SDAI_PID_DA(); - virtual void oid(const SDAI_DAObjectID x) - { + virtual void oid( const SDAI_DAObjectID x ) { _oid = x; } - virtual SDAI_DAObjectID oid() const - { - return const_cast(_oid.c_str()); + virtual SDAI_DAObjectID oid() const { + return const_cast( _oid.c_str() ); } }; -typedef SDAI_PID_DA *SDAI_PID_DA_ptr; +typedef SDAI_PID_DA * SDAI_PID_DA_ptr; typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // @@ -123,8 +117,7 @@ typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // a Model_contents object. // /// interface PID_SDAI (ISO/DIS 10303-23:1996(E) 5.3.10.2) -class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID -{ +class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID { public: SDAI_String _modelid; @@ -138,17 +131,15 @@ class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID // the persistent identifier of the cluster of data for the // Model_contents referred to by this PID. // - virtual void Modelid(const char *x) - { + virtual void Modelid( const char * x ) { _modelid = x; } - virtual char *Modelid() const - { - return const_cast(_modelid.c_str()); + virtual char * Modelid() const { + return const_cast( _modelid.c_str() ); } }; -typedef SDAI_PID_SDAI *SDAI_PID_SDAI_ptr; +typedef SDAI_PID_SDAI * SDAI_PID_SDAI_ptr; typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // @@ -162,12 +153,11 @@ typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // predefine these _ptr since they are used inside this class class SDAI_DAObject; -typedef SDAI_DAObject *SDAI_DAObject_ptr; +typedef SDAI_DAObject * SDAI_DAObject_ptr; typedef SDAI_DAObject_ptr SDAI_DAObject_var; /// interface DAObject (ISO/DIS 10303-23:1996(E) 5.3.10.5) -class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { public: SDAI_String _dado_oid; @@ -186,11 +176,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject SDAI_DAObject(); virtual ~SDAI_DAObject(); - Logical dado_same(SDAI_DAObject_ptr obj) - { - if(obj == this) { - return LTrue; - } + Logical dado_same( SDAI_DAObject_ptr obj ) { + if (obj == this) return LTrue; return LUnknown; } @@ -223,9 +210,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject note that the return value as described in the text above should be a string type. */ - SDAI_DAObjectID dado_oid() - { - return const_cast(_dado_oid.c_str()); + SDAI_DAObjectID dado_oid() { + return const_cast( _dado_oid.c_str() ); } // dado_pid @@ -237,8 +223,7 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject part of interface DAObject in the specification of the Persistent Object Service. */ - SDAI_PID_DA_ptr dado_pid() - { + SDAI_PID_DA_ptr dado_pid() { return 0; } @@ -272,8 +257,7 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject 5.3.10.1 DAObject_SDAI */ -class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject -{ +class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { public: SDAI_DAObject_SDAI(); @@ -320,7 +304,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.3 Is same */ - Logical IsSame(const SDAI_sdaiObject_ptr &otherEntity) const; + Logical IsSame( const SDAI_sdaiObject_ptr & otherEntity ) const; /* Function: @@ -345,8 +329,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifdef SDAI_CPP_LATE_BINDING - Any_var GetAttr(const Attribute_ptr &attDef); - Any_var GetAttr(const char *attName); + Any_var GetAttr( const Attribute_ptr & attDef ); + Any_var GetAttr( const char * attName ); #endif /* @@ -385,9 +369,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.6 Is instance of */ - ::Boolean IsInstanceOf(const char *typeName) const; + ::Boolean IsInstanceOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsInstanceOf(const Entity_ptr &otherEntity) const; + ::Boolean IsInstanceOf( const Entity_ptr & otherEntity ) const; #endif /* @@ -407,9 +391,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.7 Is kind of */ - ::Boolean IsKindOf(const char *typeName) const; + ::Boolean IsKindOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsKindOf(const Entity_ptr &theType) const; + ::Boolean IsKindOf( const Entity_ptr & theType ) const; #endif /* @@ -427,10 +411,10 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.8 Is SDAI kind of */ - ::Boolean IsSDAIKindOf(const char *typeName) const; + ::Boolean IsSDAIKindOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsSDAIKindOf(const Entity_ptr &theType) const; + ::Boolean IsSDAIKindOf( const Entity_ptr & theType ) const; #endif /* @@ -450,8 +434,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifdef SDAI_CPP_LATE_BINDING - ::Boolean TestAttr(const Attribute_ptr &attDef); - ::Boolean TestAttr(const char *attName) const; + ::Boolean TestAttr( const Attribute_ptr & attDef ); + ::Boolean TestAttr( const char * attName ) const; #endif /* @@ -471,7 +455,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifndef SDAI_CPP_LATE_BINDING - char *GetInstanceTypeName() const; + char * GetInstanceTypeName() const; #endif /* Function: @@ -493,33 +477,32 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject }; -typedef SDAI_DAObject_SDAI *SDAI_DAObject_SDAI_ptr; +typedef SDAI_DAObject_SDAI * SDAI_DAObject_SDAI_ptr; typedef SDAI_DAObject_SDAI_ptr SDAI_DAObject_SDAI_var; -class SC_DAI_EXPORT SDAI_DAObject__set -{ +class SC_DAI_EXPORT SDAI_DAObject__set { public: - SDAI_DAObject__set(int = 16); + SDAI_DAObject__set( int = 16 ); ~SDAI_DAObject__set(); - SDAI_DAObject_ptr retrieve(int index); + SDAI_DAObject_ptr retrieve( int index ); int is_empty(); - SDAI_DAObject_ptr &operator[](int index); + SDAI_DAObject_ptr & operator[]( int index ); - void Insert(SDAI_DAObject_ptr, int index); - void Append(SDAI_DAObject_ptr); - void Remove(int index); + void Insert( SDAI_DAObject_ptr, int index ); + void Append( SDAI_DAObject_ptr ); + void Remove( int index ); - int Index(SDAI_DAObject_ptr); + int Index( SDAI_DAObject_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_DAObject_ptr *_buf; + SDAI_DAObject_ptr * _buf; int _bufsize; int _count; @@ -527,7 +510,7 @@ class SC_DAI_EXPORT SDAI_DAObject__set }; -typedef SDAI_DAObject__set *SDAI_DAObject__set_ptr; +typedef SDAI_DAObject__set * SDAI_DAObject__set_ptr; typedef SDAI_DAObject__set_ptr SDAI_DAObject__set_var; #endif diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index 5728b0f66..f98d5d279 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -5,9 +5,8 @@ #include #include "sc_memmgr.h" -SDAI_Entity_extent::SDAI_Entity_extent() - : _definition(0), _definition_name(0), _owned_by(0) -{ +SDAI_Entity_extent::SDAI_Entity_extent( ) + : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { /* _definition = 0; _definition_name = 0; @@ -24,14 +23,12 @@ SDAI_Entity_extent::SDAI_Entity_extent(const SDAI_Entity_extent& ee) } */ -SDAI_Entity_extent::~SDAI_Entity_extent() -{ +SDAI_Entity_extent::~SDAI_Entity_extent() { delete _definition_name; } Entity_ptr -SDAI_Entity_extent ::definition_() const -{ +SDAI_Entity_extent ::definition_() const { return _definition; } @@ -44,26 +41,22 @@ SDAI_Entity_extent::definition_name_() const */ void -SDAI_Entity_extent::definition_(const Entity_ptr &ep) -{ +SDAI_Entity_extent::definition_( const Entity_ptr & ep ) { _definition = ep; } void -SDAI_Entity_extent::definition_name_(const SDAI_Entity_name &en) -{ - _definition_name = new char[strlen(en) + 1]; - strncpy(_definition_name, en, strlen(en) + 1); +SDAI_Entity_extent::definition_name_( const SDAI_Entity_name & en ) { + _definition_name = new char[strlen( en ) + 1]; + strncpy( _definition_name, en, strlen( en ) + 1 ); } -void SDAI_Entity_extent::owned_by_(SDAI_Model_contents__list_var &mclv) -{ +void SDAI_Entity_extent::owned_by_( SDAI_Model_contents__list_var& mclv ) { _owned_by = *mclv; } -SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const -{ - return (SDAI_Model_contents__list_var) &_owned_by; +SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const { + return ( const SDAI_Model_contents__list_var ) &_owned_by; } /* @@ -98,9 +91,8 @@ SDAI_DAObject__set_var instances_() const */ void -SDAI_Entity_extent::AddInstance(const SDAI_DAObject_ptr &appInst) -{ - _instances.Append(appInst); +SDAI_Entity_extent::AddInstance( const SDAI_DAObject_ptr & appInst ) { + _instances.Append( appInst ); } /* @@ -121,9 +113,8 @@ SDAI_Entity_extent::AddInstance(const SDAI_DAObject_ptr &appInst) void -SDAI_Entity_extent::RemoveInstance(const SDAI_DAObject_ptr &appInst) -{ - _instances.Remove(_instances.Index(appInst)); +SDAI_Entity_extent::RemoveInstance( const SDAI_DAObject_ptr & appInst ) { + _instances.Remove( _instances.Index( appInst ) ); } ///////// END_ENTITY SDAI_Entity_extent diff --git a/src/cldai/sdaiEntity_extent.h b/src/cldai/sdaiEntity_extent.h index b8b2254ab..0dcca471f 100644 --- a/src/cldai/sdaiEntity_extent.h +++ b/src/cldai/sdaiEntity_extent.h @@ -15,11 +15,10 @@ */ class SDAI_Entity_extent; -typedef SDAI_Entity_extent *SDAI_Entity_extent_ptr; +typedef SDAI_Entity_extent * SDAI_Entity_extent_ptr; typedef SDAI_Entity_extent_ptr SDAI_Entity_extent_var; -class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance -{ +class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { friend class SDAI_Model_contents; /* @@ -44,8 +43,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance public: - SDAI_Entity_name definition_name_() const - { + SDAI_Entity_name definition_name_() const { return _definition_name; } @@ -54,13 +52,11 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance // const Entity_ptr definition_() const; #endif - SDAI_DAObject__set_var instances_() - { + SDAI_DAObject__set_var instances_() { return &_instances; } - SDAI_DAObject__set_var instances_() const - { - return (SDAI_DAObject__set_var)&_instances; + SDAI_DAObject__set_var instances_() const { + return ( const SDAI_DAObject__set_var )&_instances; } // need to implement Model_contents__list @@ -72,12 +68,12 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance // static SDAI_Entity_extent_ptr _nil(); // private: - void definition_(const Entity_ptr &ep); + void definition_( const Entity_ptr & ep ); #ifdef SDAI_CPP_LATE_BINDING // void definition_(const Entity_ptr& ep); #endif - void definition_name_(const SDAI_Entity_name &ep); - void owned_by_(SDAI_Model_contents__list_var &mclv); + void definition_name_( const SDAI_Entity_name & ep ); + void owned_by_( SDAI_Model_contents__list_var & mclv ); /* 7.3.3.1 SDAI operation declarations @@ -86,7 +82,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance */ // this is no longer in Part 23 - void AddInstance(const SDAI_DAObject_ptr &appInst); + void AddInstance( const SDAI_DAObject_ptr & appInst ); /* Function: @@ -105,7 +101,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance */ // this is no longer in Part 23 - void RemoveInstance(const SDAI_DAObject_ptr &appInst); + void RemoveInstance( const SDAI_DAObject_ptr & appInst ); /* 7.3.3.1.2 RemoveInstance diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index d96ccc057..af3658222 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -38,92 +38,85 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Entity_extent__set::SDAI_Entity_extent__set(int defaultSize) -{ +SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Entity_extent_ptr[_bufsize]; _count = 0; } -SDAI_Entity_extent__set::~SDAI_Entity_extent__set() -{ +SDAI_Entity_extent__set::~SDAI_Entity_extent__set() { delete _buf; } -void SDAI_Entity_extent__set::Check(int index) -{ +void SDAI_Entity_extent__set::Check( int index ) { - SDAI_Entity_extent_ptr *newbuf; + SDAI_Entity_extent_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Entity_extent_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Entity_extent_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_Entity_extent__set::Insert(SDAI_Entity_extent_ptr v, int index) -{ +SDAI_Entity_extent__set::Insert( SDAI_Entity_extent_ptr v, int index ) { - SDAI_Entity_extent_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_Entity_extent_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Append(SDAI_Entity_extent_ptr v) -{ +void SDAI_Entity_extent__set::Append( SDAI_Entity_extent_ptr v ) { int index = _count; - SDAI_Entity_extent_ptr *spot; + SDAI_Entity_extent_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Remove(int index) -{ +void SDAI_Entity_extent__set::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Entity_extent_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + SDAI_Entity_extent_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } } -int SDAI_Entity_extent__set::Index(SDAI_Entity_extent_ptr v) -{ +int SDAI_Entity_extent__set::Index( SDAI_Entity_extent_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -131,34 +124,29 @@ int SDAI_Entity_extent__set::Index(SDAI_Entity_extent_ptr v) } SDAI_Entity_extent_ptr -SDAI_Entity_extent__set::retrieve(int index) -{ - return operator[](index); +SDAI_Entity_extent__set::retrieve( int index ) { + return operator[]( index ); } -SDAI_Entity_extent_ptr &SDAI_Entity_extent__set::operator[](int index) -{ - Check(index); +SDAI_Entity_extent_ptr & SDAI_Entity_extent__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Entity_extent__set::Count() -{ +SDAI_Entity_extent__set::Count() { return _count; } int -SDAI_Entity_extent__set::is_empty() -{ +SDAI_Entity_extent__set::is_empty() { return _count; } void -SDAI_Entity_extent__set::Clear() -{ +SDAI_Entity_extent__set::Clear() { _count = 0; } @@ -166,103 +154,93 @@ SDAI_Entity_extent__set::Clear() #if 0 -Entity_extent__set::Entity_extent__set(int defaultSize) -{ +Entity_extent__set::Entity_extent__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Entity_extent_ptr[_bufsize]; _count = 0; } -Entity_extent__set::~Entity_extent__set() -{ +Entity_extent__set::~Entity_extent__set() { delete _buf; } -void Entity_extent__set::Check(int index) -{ - Entity_extent_ptr *newbuf; +void Entity_extent__set::Check( int index ) { + Entity_extent_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Entity_extent_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Entity_extent_ptr)); + memmove( newbuf, _buf, _count * sizeof( Entity_extent_ptr ) ); delete _buf; _buf = newbuf; } } -void Entity_extent__set::Insert(Entity_extent_ptr v, int index) -{ - Entity_extent_ptr *spot; - index = (index < 0) ? _count : index; +void Entity_extent__set::Insert( Entity_extent_ptr v, int index ) { + Entity_extent_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Append(Entity_extent_ptr v) -{ +void Entity_extent__set::Append( Entity_extent_ptr v ) { int index = _count; - Entity_extent_ptr *spot; + Entity_extent_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Entity_extent__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Entity_extent_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Entity_extent_ptr)); + Entity_extent_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Entity_extent_ptr ) ); } } -int Entity_extent__set::Index(Entity_extent_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Entity_extent__set::Index( Entity_extent_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Entity_extent_ptr &Entity_extent__set::operator[](int index) -{ - Check(index); +Entity_extent_ptr & Entity_extent__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -Entity_extent__set::Count() -{ +Entity_extent__set::Count() { return _count; } void -Entity_extent__set::Clear() -{ +Entity_extent__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiEntity_extent_set.h b/src/cldai/sdaiEntity_extent_set.h index a7541cd83..b6b893078 100644 --- a/src/cldai/sdaiEntity_extent_set.h +++ b/src/cldai/sdaiEntity_extent_set.h @@ -37,36 +37,35 @@ //#include */ -class SC_DAI_EXPORT SDAI_Entity_extent__set -{ +class SC_DAI_EXPORT SDAI_Entity_extent__set { public: - SDAI_Entity_extent__set(int = 16); + SDAI_Entity_extent__set( int = 16 ); ~SDAI_Entity_extent__set(); - SDAI_Entity_extent_ptr retrieve(int index); + SDAI_Entity_extent_ptr retrieve( int index ); int is_empty(); - SDAI_Entity_extent_ptr &operator[](int index); + SDAI_Entity_extent_ptr & operator[]( int index ); - void Insert(SDAI_Entity_extent_ptr, int index); - void Append(SDAI_Entity_extent_ptr); - void Remove(int index); - int Index(SDAI_Entity_extent_ptr); + void Insert( SDAI_Entity_extent_ptr, int index ); + void Append( SDAI_Entity_extent_ptr ); + void Remove( int index ); + int Index( SDAI_Entity_extent_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Entity_extent_ptr *_buf; + SDAI_Entity_extent_ptr * _buf; int _bufsize; int _count; }; -typedef SDAI_Entity_extent__set *SDAI_Entity_extent__set_ptr; +typedef SDAI_Entity_extent__set * SDAI_Entity_extent__set_ptr; typedef SDAI_Entity_extent__set_ptr SDAI_Entity_extent__set_var; /* diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index 35529276b..a8e37d407 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -19,47 +19,39 @@ // class Logical /////////////////////////////////////////////////////////////////////////////// -SDAI_LOGICAL::SDAI_LOGICAL(const char *val) -{ - set_value(val); +SDAI_LOGICAL::SDAI_LOGICAL( const char * val ) { + set_value( val ); } -SDAI_LOGICAL::SDAI_LOGICAL(Logical state) -{ - set_value(state); +SDAI_LOGICAL::SDAI_LOGICAL( Logical state ) { + set_value( state ); } -SDAI_LOGICAL::SDAI_LOGICAL(const SDAI_LOGICAL &source) -{ - set_value(source.asInt()); +SDAI_LOGICAL::SDAI_LOGICAL( const SDAI_LOGICAL & source ) { + set_value( source.asInt() ); } -SDAI_LOGICAL::SDAI_LOGICAL(int i) -{ - if(i == 0) { +SDAI_LOGICAL::SDAI_LOGICAL( int i ) { + if( i == 0 ) { v = LFalse ; } else { v = LTrue ; } } -SDAI_LOGICAL::~SDAI_LOGICAL() -{ +SDAI_LOGICAL::~SDAI_LOGICAL() { } -const char *SDAI_LOGICAL::Name() const -{ +const char * SDAI_LOGICAL::Name() const { return "Logical"; } -int SDAI_LOGICAL::no_elements() const -{ +int SDAI_LOGICAL::no_elements() const { return 3; } -const char *SDAI_LOGICAL::element_at(int n) const -{ - switch(n) { +const char * SDAI_LOGICAL::element_at( int n ) const { + switch( n ) { case LUnknown : return "U"; case LFalse : @@ -71,19 +63,16 @@ const char *SDAI_LOGICAL::element_at(int n) const } } -int SDAI_LOGICAL::exists() const // return 0 if unset otherwise return 1 -{ - return !(v == 2); +int SDAI_LOGICAL::exists() const { // return 0 if unset otherwise return 1 + return !( v == 2 ); } -void SDAI_LOGICAL::nullify() // change the receiver to an unset status -{ +void SDAI_LOGICAL::nullify() { // change the receiver to an unset status v = 2; } -SDAI_LOGICAL::operator Logical() const -{ - switch(v) { +SDAI_LOGICAL::operator Logical() const { + switch( v ) { case LFalse : return LFalse ; case LTrue : @@ -96,29 +85,26 @@ SDAI_LOGICAL::operator Logical() const } } -SDAI_LOGICAL &SDAI_LOGICAL::operator= (const SDAI_LOGICAL &t) -{ - set_value(t.asInt()); +SDAI_LOGICAL & SDAI_LOGICAL::operator= ( const SDAI_LOGICAL & t ) { + set_value( t.asInt() ); return *this; } -SDAI_LOGICAL SDAI_LOGICAL::operator ==(const SDAI_LOGICAL &t) const -{ - if(v == t.asInt()) { +SDAI_LOGICAL SDAI_LOGICAL::operator ==( const SDAI_LOGICAL & t ) const { + if( v == t.asInt() ) { return LTrue ; } return LFalse ; } -int SDAI_LOGICAL::set_value(const int i) -{ - if(i > no_elements() + 1) { +int SDAI_LOGICAL::set_value( const int i ) { + if( i > no_elements() + 1 ) { v = 2; return v; } - const char *tmp = element_at(i); - if(tmp[0] != '\0') { - return (v = i); + const char * tmp = element_at( i ); + if( tmp[0] != '\0' ) { + return ( v = i ); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -127,21 +113,20 @@ int SDAI_LOGICAL::set_value(const int i) return no_elements() + 1 ; } -int SDAI_LOGICAL::set_value(const char *n) -{ +int SDAI_LOGICAL::set_value( const char * n ) { // assigns the appropriate value based on n - if(!n || (!strcmp(n, ""))) { + if( !n || ( !strcmp( n, "" ) ) ) { nullify(); return asInt(); } int i = 0; std::string tmp; - while((i < (no_elements() + 1)) && - (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { + while( ( i < ( no_elements() + 1 ) ) && + ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { ++i; } - if((no_elements() + 1) == i) { // exhausted all the possible values + if( ( no_elements() + 1 ) == i ) { // exhausted all the possible values nullify(); return v; } @@ -149,10 +134,9 @@ int SDAI_LOGICAL::set_value(const char *n) return v; } -Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { set_null(); } @@ -162,85 +146,85 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if(c == '.' || isalpha(c)) { + in.get( c ); + if( c == '.' || isalpha( c ) ) { int validDelimiters = 1; - if(c == '.') { - in.get(c); // push past the delimiter + if( c == '.' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if(in.good() && (isalpha(c) || c == '_')) { + if( in.good() && ( isalpha( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // look for UPPER or DIGIT - while(in.good() && (isalnum(c) || c == '_')) { + while( in.good() && ( isalnum( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // if character is not the delimiter unread it - if(in.good() && (c != '.')) { - in.putback(c); + if( in.good() && ( c != '.' ) ) { + in.putback( c ); } // a value was read - if(str.length() > 0) { + if( str.length() > 0 ) { int i = 0; - const char *strval = str.c_str(); + const char * strval = str.c_str(); std::string tmp; - while((i < (no_elements() + 1)) && - (strcmp((char *)StrToUpper(strval, tmp), - element_at(i)) != 0)) { + while( ( i < ( no_elements() + 1 ) ) && + ( strcmp( ( char * )StrToUpper( strval, tmp ), + element_at( i ) ) != 0 ) ) { ++i; } - if((no_elements() + 1) == i) { + if( ( no_elements() + 1 ) == i ) { // exhausted all the possible values - err->GreaterSeverity(SEVERITY_WARNING); - err->AppendToDetailMsg("Invalid Enumeration value.\n"); - err->AppendToUserMsg("Invalid Enumeration value.\n"); + err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); + err->AppendToUserMsg( "Invalid Enumeration value.\n" ); } else { - if(AssignVal) { + if( AssignVal ) { v = i; } } // now also check the delimiter situation - if(c == '.') { // if found ending delimiter + if( c == '.' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Enumerated value has invalid period delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Enumerated value has invalid period delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched period delimiters for enumeration.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched period delimiters for enumeration.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if((c == '.') || !validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); + else if( ( c == '.' ) || !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -249,21 +233,21 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if((c == ',') || (c == ')')) { - in.putback(c); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( ( c == ',' ) || ( c == ')' ) ) { + in.putback( c ); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } else { - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid enumeration value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid enumeration value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } @@ -272,57 +256,48 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal // class BOOLEAN Jan 97 /////////////////////////////////////////////////////////////////////////////// -const char *SDAI_BOOLEAN::Name() const -{ +const char * SDAI_BOOLEAN::Name() const { return "Bool"; } -SDAI_BOOLEAN::SDAI_BOOLEAN(char *val) -{ - set_value(val); +SDAI_BOOLEAN::SDAI_BOOLEAN( char * val ) { + set_value( val ); } -SDAI_BOOLEAN::SDAI_BOOLEAN(Boolean state) -{ - set_value(state); +SDAI_BOOLEAN::SDAI_BOOLEAN( Boolean state ) { + set_value( state ); } -SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_BOOLEAN &source) -{ - set_value(source.asInt()); +SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_BOOLEAN & source ) { + set_value( source.asInt() ); } -SDAI_BOOLEAN::~SDAI_BOOLEAN() -{ +SDAI_BOOLEAN::~SDAI_BOOLEAN() { } -int SDAI_BOOLEAN::no_elements() const -{ +int SDAI_BOOLEAN::no_elements() const { return 2; } -SDAI_BOOLEAN::SDAI_BOOLEAN(int i) -{ - if(i == 0) { +SDAI_BOOLEAN::SDAI_BOOLEAN( int i ) { + if( i == 0 ) { v = BFalse ; } else { v = BTrue ; } } -SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_LOGICAL &val) -{ - if(val.asInt() == LUnknown) { +SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_LOGICAL & val ) { + if( val.asInt() == LUnknown ) { // this should set error code sdaiVT_NVLD i.e. Invalid value type. v = BUnset; return; } - set_value(val); + set_value( val ); } -SDAI_BOOLEAN::operator Boolean() const -{ - switch(v) { +SDAI_BOOLEAN::operator Boolean() const { + switch( v ) { case BFalse : return BFalse ; case BTrue : @@ -333,27 +308,18 @@ SDAI_BOOLEAN::operator Boolean() const } } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_LOGICAL &t) -{ - set_value(t.asInt()); +SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_LOGICAL & t ) { + set_value( t.asInt() ); return *this; } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_BOOLEAN &t) -{ +SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const Boolean t ) { v = t; return *this; } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const Boolean t) -{ - v = t; - return *this; -} - -const char *SDAI_BOOLEAN::element_at(int n) const -{ - switch(n) { +const char * SDAI_BOOLEAN::element_at( int n ) const { + switch( n ) { case BFalse : return "F"; case BTrue : @@ -363,9 +329,8 @@ const char *SDAI_BOOLEAN::element_at(int n) const } } -SDAI_LOGICAL SDAI_BOOLEAN::operator ==(const SDAI_LOGICAL &t) const -{ - if(v == t.asInt()) { +SDAI_LOGICAL SDAI_BOOLEAN::operator ==( const SDAI_LOGICAL & t ) const { + if( v == t.asInt() ) { return LTrue ; } return LFalse ; @@ -373,40 +338,35 @@ SDAI_LOGICAL SDAI_BOOLEAN::operator ==(const SDAI_LOGICAL &t) const /////////////////////////////////////////////////////////////////////////////// -SDAI_Enum::SDAI_Enum() -{ +SDAI_Enum::SDAI_Enum() { v = 0; } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put(int val) -{ - return set_value(val); +int SDAI_Enum::put( int val ) { + return set_value( val ); } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put(const char *n) -{ - return set_value(n); +int SDAI_Enum::put( const char * n ) { + return set_value( n ); } /// return 0 if unset otherwise return 1 /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? -int SDAI_Enum::exists() const -{ - return !(v > no_elements()); +int SDAI_Enum::exists() const { + return !( v > no_elements() ); } /** * change the receiver to an unset status * unset is generated to be 1 greater than last element */ -void SDAI_Enum::nullify() -{ - set_value(no_elements() + 1); +void SDAI_Enum::nullify() { + set_value( no_elements() + 1 ); } /**************************************************************//** @@ -414,20 +374,19 @@ void SDAI_Enum::nullify() ** debugging purposes ** Status: ok 2/1/91 ******************************************************************/ -void SDAI_Enum::DebugDisplay(ostream &out) const -{ +void SDAI_Enum::DebugDisplay( ostream & out ) const { std::string tmp; out << "Current " << Name() << " value: " << endl << " cardinal: " << v << endl - << " string: " << asStr(tmp) << endl + << " string: " << asStr( tmp ) << endl << " Part 21 file format: "; - STEPwrite(out); + STEPwrite( out ); out << endl; out << "Valid values are: " << endl; int i = 0; - while(i < (no_elements() + 1)) { - out << i << " " << element_at(i) << endl; + while( i < ( no_elements() + 1 ) ) { + out << i << " " << element_at( i ) << endl; i++; } out << "\n"; @@ -448,10 +407,9 @@ void SDAI_Enum::DebugDisplay(ostream &out) const ** true => delimiters must be valid; ** true or false => non-matching delimiters are flagged as an error */ -Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_Enum::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { set_null(); } @@ -461,85 +419,85 @@ Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if(c == '.' || isalpha(c)) { + in.get( c ); + if( c == '.' || isalpha( c ) ) { int validDelimiters = 1; - if(c == '.') { - in.get(c); // push past the delimiter + if( c == '.' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if(in.good() && (isalpha(c) || c == '_')) { + if( in.good() && ( isalpha( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // look for UPPER or DIGIT - while(in.good() && (isalnum(c) || c == '_')) { + while( in.good() && ( isalnum( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // if character is not the delimiter unread it - if(in.good() && (c != '.')) { - in.putback(c); + if( in.good() && ( c != '.' ) ) { + in.putback( c ); } // a value was read - if(str.length() > 0) { + if( str.length() > 0 ) { int i = 0; - const char *strval = str.c_str(); + const char * strval = str.c_str(); std::string tmp; - while((i < no_elements()) && - (strcmp((char *)StrToUpper(strval, tmp), - element_at(i)) != 0)) { + while( ( i < no_elements() ) && + ( strcmp( ( char * )StrToUpper( strval, tmp ), + element_at( i ) ) != 0 ) ) { ++i; } - if(no_elements() == i) { + if( no_elements() == i ) { // exhausted all the possible values - err->GreaterSeverity(SEVERITY_WARNING); - err->AppendToDetailMsg("Invalid Enumeration value.\n"); - err->AppendToUserMsg("Invalid Enumeration value.\n"); + err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); + err->AppendToUserMsg( "Invalid Enumeration value.\n" ); } else { - if(AssignVal) { + if( AssignVal ) { v = i; } } // now also check the delimiter situation - if(c == '.') { // if found ending delimiter + if( c == '.' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Enumerated value has invalid period delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Enumerated value has invalid period delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched period delimiters for enumeration.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched period delimiters for enumeration.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if((c == '.') || !validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); + else if( ( c == '.' ) || !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -548,59 +506,55 @@ Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if((c == ',') || (c == ')')) { - in.putback(c); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( ( c == ',' ) || ( c == ')' ) ) { + in.putback( c ); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } else { - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid enumeration value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid enumeration value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } -Severity SDAI_Enum::StrToVal(const char *s, ErrorDescriptor *err, int optional) -{ - istringstream in((char *)s); // sz defaults to length of s +Severity SDAI_Enum::StrToVal( const char * s, ErrorDescriptor * err, int optional ) { + istringstream in( ( char * )s ); // sz defaults to length of s - ReadEnum(in, err, 1, 0); - if((err->severity() == SEVERITY_INCOMPLETE) && optional) { - err->severity(SEVERITY_NULL); + ReadEnum( in, err, 1, 0 ); + if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread(const char *s, ErrorDescriptor *err, int optional) -{ - istringstream in((char *)s); - return STEPread(in, err, optional); +Severity SDAI_Enum::STEPread( const char * s, ErrorDescriptor * err, int optional ) { + istringstream in( ( char * )s ); + return STEPread( in, err, optional ); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread(istream &in, ErrorDescriptor *err, int optional) -{ - ReadEnum(in, err, 1, 1); - if((err->severity() == SEVERITY_INCOMPLETE) && optional) { - err->severity(SEVERITY_NULL); +Severity SDAI_Enum::STEPread( istream & in, ErrorDescriptor * err, int optional ) { + ReadEnum( in, err, 1, 1 ); + if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } -const char *SDAI_Enum::asStr(std::string &s) const -{ - if(exists()) { - s = element_at(v); +const char * SDAI_Enum::asStr( std::string & s ) const { + if( exists() ) { + s = element_at( v ); return s.c_str(); } else { s.clear(); @@ -608,74 +562,70 @@ const char *SDAI_Enum::asStr(std::string &s) const } } -void SDAI_Enum::STEPwrite(ostream &out) const -{ - if(is_null()) { +void SDAI_Enum::STEPwrite( ostream & out ) const { + if( is_null() ) { out << '$'; } else { std::string tmp; - out << "." << asStr(tmp) << "."; + out << "." << asStr( tmp ) << "."; } } -const char *SDAI_Enum::STEPwrite(std::string &s) const -{ - if(is_null()) { +const char * SDAI_Enum::STEPwrite( std::string & s ) const { + if( is_null() ) { s.clear(); } else { std::string tmp; s = "."; - s.append(asStr(tmp)); - s.append("."); + s.append( asStr( tmp ) ); + s.append( "." ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -Severity SDAI_Enum::EnumValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - if(clearError) { +Severity SDAI_Enum::EnumValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + if( clearError ) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = ' '; c = in.peek(); - if(c == '$' || in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( c == '$' || in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - if(in) { + if( in ) { in >> c; } - CheckRemainingInput(in, err, "enumeration", tokenList); + CheckRemainingInput( in, err, "enumeration", tokenList ); return err->severity(); } else { ErrorDescriptor error; - ReadEnum(in, &error, 0, needDelims); - CheckRemainingInput(in, &error, "enumeration", tokenList); + ReadEnum( in, &error, 0, needDelims ); + CheckRemainingInput( in, &error, "enumeration", tokenList ); Severity sev = error.severity(); - if(sev < SEVERITY_INCOMPLETE) { - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); - } else if(sev == SEVERITY_INCOMPLETE && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( sev < SEVERITY_INCOMPLETE ) { + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); + } else if( sev == SEVERITY_INCOMPLETE && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -Severity SDAI_Enum::EnumValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - istringstream in((char *)value); - return EnumValidLevel(in, err, optional, tokenList, needDelims, - clearError); +Severity SDAI_Enum::EnumValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + istringstream in( ( char * )value ); + return EnumValidLevel( in, err, optional, tokenList, needDelims, + clearError ); } /**************************************************************//** @@ -689,20 +639,19 @@ Severity SDAI_Enum::EnumValidLevel(const char *value, ErrorDescriptor *err, ** Status: ok 2.91 ** \returns: value set ******************************************************************/ -int SDAI_Enum::set_value(const char *n) -{ - if(!n || (!strcmp(n, ""))) { +int SDAI_Enum::set_value( const char * n ) { + if( !n || ( !strcmp( n, "" ) ) ) { nullify(); return asInt(); } int i = 0; std::string tmp; - while((i < no_elements()) && - (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { + while( ( i < no_elements() ) && + ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { ++i; } - if(no_elements() == i) { // exhausted all the possible values + if( no_elements() == i ) { // exhausted all the possible values return v = no_elements() + 1; // defined as UNSET } v = i; @@ -713,15 +662,14 @@ int SDAI_Enum::set_value(const char *n) /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::set_value(const int i) -{ - if(i > no_elements()) { +int SDAI_Enum::set_value( const int i ) { + if( i > no_elements() ) { v = no_elements() + 1; return v; } - const char *tmp = element_at(i); - if(tmp[0] != '\0') { - return (v = i); + const char * tmp = element_at( i ); + if( tmp[0] != '\0' ) { + return ( v = i ); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -730,22 +678,19 @@ int SDAI_Enum::set_value(const int i) return no_elements() + 1 ; } -SDAI_Enum &SDAI_Enum::operator= (const int i) -{ - put(i); +SDAI_Enum & SDAI_Enum::operator= ( const int i ) { + put( i ); return *this; } -SDAI_Enum &SDAI_Enum::operator= (const SDAI_Enum &Senum) -{ - put(Senum.asInt()); +SDAI_Enum & SDAI_Enum::operator= ( const SDAI_Enum & Senum ) { + put( Senum.asInt() ); return *this; } -ostream &operator<< (ostream &out, const SDAI_Enum &a) -{ +ostream & operator<< ( ostream & out, const SDAI_Enum & a ) { std::string tmp; - out << a.asStr(tmp); + out << a.asStr( tmp ); return out; } diff --git a/src/cldai/sdaiEnum.h b/src/cldai/sdaiEnum.h index 320208c1d..c883f2be6 100644 --- a/src/cldai/sdaiEnum.h +++ b/src/cldai/sdaiEnum.h @@ -15,76 +15,70 @@ #include #include -class SC_DAI_EXPORT SDAI_Enum -{ - friend ostream &operator<< (ostream &, const SDAI_Enum &); +class SC_DAI_EXPORT SDAI_Enum { + friend ostream & operator<< ( ostream &, const SDAI_Enum & ); protected: int v; // integer value of enumeration instance // mapped to a symbolic value in the elements - virtual int set_value(const char *n); - virtual int set_value(const int n); + virtual int set_value( const char * n ); + virtual int set_value( const int n ); SDAI_Enum(); public: virtual ~SDAI_Enum() {}; - void PrintContents(ostream &out = std::cout) const - { - DebugDisplay(out); + void PrintContents( ostream & out = std::cout ) const { + DebugDisplay( out ); } virtual int no_elements() const = 0; - virtual const char *Name() const = 0; - const char *get_value_at(int n) const - { - return element_at(n); + virtual const char * Name() const = 0; + const char * get_value_at( int n ) const { + return element_at( n ); } - virtual const char *element_at(int n) const = 0; + virtual const char * element_at( int n ) const = 0; - Severity EnumValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity EnumValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); - Severity EnumValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity EnumValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); - int asInt() const - { + int asInt() const { return v; } - const char *asStr(std::string &s) const; - void STEPwrite(ostream &out = std::cout) const; - const char *STEPwrite(std::string &s) const; + const char * asStr( std::string & s ) const; + void STEPwrite( ostream & out = std::cout ) const; + const char * STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s, ErrorDescriptor *err, int optional = 1); - Severity STEPread(istream &in, ErrorDescriptor *err, int optional = 1); - Severity STEPread(const char *s, ErrorDescriptor *err, int optional = 1); + Severity StrToVal( const char * s, ErrorDescriptor * err, int optional = 1 ); + Severity STEPread( istream & in, ErrorDescriptor * err, int optional = 1 ); + Severity STEPread( const char * s, ErrorDescriptor * err, int optional = 1 ); - virtual int put(int val); - virtual int put(const char *n); - bool is_null() const - { - return (exists() == 0); + virtual int put( int val ); + virtual int put( const char * n ); + bool is_null() const { + return ( exists() == 0 ); } - void set_null() - { + void set_null() { nullify(); } - SDAI_Enum &operator= (const int); - SDAI_Enum &operator= (const SDAI_Enum &); + SDAI_Enum & operator= ( const int ); + SDAI_Enum & operator= ( const SDAI_Enum & ); /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? ///FIXME need to rewrite this function, but strange implementation... virtual int exists() const; virtual void nullify(); - void DebugDisplay(ostream &out = std::cout) const; + void DebugDisplay( ostream & out = std::cout ) const; protected: - virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, - int AssignVal = 1, int needDelims = 1); + virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, + int AssignVal = 1, int needDelims = 1 ); }; @@ -96,60 +90,57 @@ enum Boolean { BFalse, BTrue, BUnset }; enum Logical { LFalse, LTrue, LUnset, LUnknown }; class SC_DAI_EXPORT SDAI_LOGICAL : - public SDAI_Enum -{ + public SDAI_Enum { public: - const char *Name() const; + const char * Name() const; - SDAI_LOGICAL(const char *val = 0); - SDAI_LOGICAL(Logical state); - SDAI_LOGICAL(const SDAI_LOGICAL &source); - SDAI_LOGICAL(int i); + SDAI_LOGICAL( const char * val = 0 ); + SDAI_LOGICAL( Logical state ); + SDAI_LOGICAL( const SDAI_LOGICAL & source ); + SDAI_LOGICAL( int i ); virtual ~SDAI_LOGICAL(); virtual int no_elements() const; - virtual const char *element_at(int n) const; + virtual const char * element_at( int n ) const; operator Logical() const; - SDAI_LOGICAL &operator=(const SDAI_LOGICAL &t); + SDAI_LOGICAL & operator=( const SDAI_LOGICAL & t ); - SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; + SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; // these 2 are redefined because LUnknown has cardinal value > LUnset int exists() const; // return 0 if unset otherwise return 1 void nullify(); // change the receiver to an unset status protected: - virtual int set_value(const int n); - virtual int set_value(const char *n); - virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, - int AssignVal = 1, int needDelims = 1); + virtual int set_value( const int n ); + virtual int set_value( const char * n ); + virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, + int AssignVal = 1, int needDelims = 1 ); }; class SC_DAI_EXPORT SDAI_BOOLEAN : - public SDAI_Enum -{ + public SDAI_Enum { public: - const char *Name() const; + const char * Name() const; - SDAI_BOOLEAN(char *val = 0); - SDAI_BOOLEAN(::Boolean state); - SDAI_BOOLEAN(const SDAI_BOOLEAN &source); - SDAI_BOOLEAN(int i); - SDAI_BOOLEAN(const SDAI_LOGICAL &val); + SDAI_BOOLEAN( char * val = 0 ); + SDAI_BOOLEAN( ::Boolean state ); + SDAI_BOOLEAN( const SDAI_BOOLEAN & source ); + SDAI_BOOLEAN( int i ); + SDAI_BOOLEAN( const SDAI_LOGICAL & val ); virtual ~SDAI_BOOLEAN(); virtual int no_elements() const; - virtual const char *element_at(int n) const; + virtual const char * element_at( int n ) const; operator ::Boolean() const; - SDAI_BOOLEAN &operator=(const SDAI_LOGICAL &t); - SDAI_BOOLEAN &operator=(const SDAI_BOOLEAN &t); + SDAI_BOOLEAN & operator=( const SDAI_LOGICAL & t ); - SDAI_BOOLEAN &operator=(const ::Boolean t); - SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; + SDAI_BOOLEAN & operator=( const ::Boolean t ); + SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; }; diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index 89636fbec..67140916a 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -4,91 +4,76 @@ ///////// SDAI_Model_contents_instances -SDAI_Model_contents_instances::SDAI_Model_contents_instances() -{ +SDAI_Model_contents_instances::SDAI_Model_contents_instances( ) { } -SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() -{ +SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() { } ///////// SDAI_Model_contents -SDAI_Model_contents::SDAI_Model_contents() -{ +SDAI_Model_contents::SDAI_Model_contents( ) { } -SDAI_Model_contents ::~SDAI_Model_contents() -{ +SDAI_Model_contents ::~SDAI_Model_contents() { } // const Entity_instance__set_var instances() const; //const SDAIAGGRH(Set, EntityInstanceH) Instances() const; SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() -{ +SDAI_Model_contents::instances_() { return &_instances; } SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() const -{ - return (SDAI_Model_contents_instances_ptr) &_instances; +SDAI_Model_contents::instances_() const { + return ( const SDAI_Model_contents_instances_ptr ) &_instances; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() -{ +SDAI_Model_contents::folders_() { return &_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() const -{ - return (SDAI_Entity_extent__set_var)&_folders; +SDAI_Model_contents::folders_() const { + return ( const SDAI_Entity_extent__set_var )&_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() -{ +SDAI_Model_contents::populated_folders_() { return &_populated_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() const -{ - return (SDAI_Entity_extent__set_var)&_populated_folders; +SDAI_Model_contents::populated_folders_() const { + return ( const SDAI_Entity_extent__set_var )&_populated_folders; } -SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid(const SDAI_DAObject_ptr &d) const -{ +SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid( const SDAI_DAObject_ptr & d ) const { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::get_object_pid() unimplemented!" << std::endl; (void) d; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::lookup(const SDAI_PID_DA_ptr &p) const -{ +SDAI_DAObject_ptr SDAI_Model_contents::lookup( const SDAI_PID_DA_ptr & p ) const { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::lookup() unimplemented!" << std::endl; (void) p; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance(const char *Type) -{ +SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance( const char * Type ) { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::CreateEntityInstance() unimplemented!" << std::endl; (void) Type; //unused return 0; } -void SDAI_Model_contents::AddInstance(const SDAI_DAObject_SDAI_ptr &appInst) -{ - _instances.contents_()->Append(appInst); +void SDAI_Model_contents::AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ) { + _instances.contents_()->Append( appInst ); } -void SDAI_Model_contents::RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst) -{ - _instances.contents_()->Remove(_instances.contents_()->Index(appInst)); +void SDAI_Model_contents::RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ) { + _instances.contents_()->Remove( _instances.contents_()->Index( appInst ) ); } @@ -96,23 +81,19 @@ void SDAI_Model_contents::RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst) #if 0 // for now Any_var -SDAI_Model_contents::GetEntity_extent(const std::string &entityName) -{ +SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) { } const Any_var -SDAI_Model_contents::GetEntity_extent(const std::string &entityName) const -{ +SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) const { } Any_var -SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) -{ +SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) { } const Any_var -SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) const -{ +SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) const { } #endif diff --git a/src/cldai/sdaiModel_contents.h b/src/cldai/sdaiModel_contents.h index 86dec9cad..5795232dc 100644 --- a/src/cldai/sdaiModel_contents.h +++ b/src/cldai/sdaiModel_contents.h @@ -26,8 +26,7 @@ // The class SDAI_Model_contents_instances shall implement convenience functions by // SDAI_Model_contents in this part of ISO 10303 -class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject -{ +class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject { public: SDAI_DAObject__set _instances; @@ -37,13 +36,11 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject // This function shall return the set of DAObjects contained in // the receiver. - SDAI_DAObject__set_var contents_() - { + SDAI_DAObject__set_var contents_() { return &_instances; } - SDAI_DAObject__set_var contents_() const - { - return (SDAI_DAObject__set_var) &_instances; + SDAI_DAObject__set_var contents_() const { + return ( const SDAI_DAObject__set_var ) &_instances; } }; @@ -55,8 +52,7 @@ SDAI_Model_contents_instances_var; // Model_contents_ptr def pushed ahead of #include for Entity_extent -class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance -{ +class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { //friend class SDAI_Model; @@ -93,9 +89,9 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance SDAI_Entity_extent__set_var populated_folders_(); SDAI_PID_DA_ptr - get_object_pid(const SDAI_DAObject_ptr &d) const; + get_object_pid( const SDAI_DAObject_ptr & d ) const; - SDAI_DAObject_ptr lookup(const SDAI_PID_DA_ptr &p) const; + SDAI_DAObject_ptr lookup( const SDAI_PID_DA_ptr & p ) const; /* SDAI operation declarations @@ -107,10 +103,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance // private: public: // for now at least SDAI_DAObject_ptr - CreateEntityInstance(const char *Type); + CreateEntityInstance( const char * Type ); // until we find out what this should really be in the spec - void AddInstance(const SDAI_DAObject_SDAI_ptr &appInst); + void AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ); // void AddInstance(const Entity_instance_ptr& entityHandle); //void AddInstance(EntityInstanceH& entityHandle); /* Function: @@ -135,7 +131,7 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance */ // until we find out what this should really be in the spec - void RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst); + void RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ); // void RemoveInstance(Entity_instance_ptr& entityHandle); //void RemoveInstance(EntityInstanceH& entityHandle); /* Function @@ -166,10 +162,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance */ #ifdef SDAI_CPP_LATE_BINDING #if 0 // for now - Any_var GetEntity_extent(const std::string &entityName); - const Any_var GetEntity_extent(const std::string &entityName) const; - Any_var GetEntity_extent(const Entity_ptr &ep); - const Any_var GetEntity_extent(const Entity_ptr &ep) const; + Any_var GetEntity_extent( const std::string & entityName ); + const Any_var GetEntity_extent( const std::string & entityName ) const; + Any_var GetEntity_extent( const Entity_ptr & ep ); + const Any_var GetEntity_extent( const Entity_ptr & ep ) const; #endif /* Function: The GetEntity_extent function shall retrieve an entity folder from diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index 9d0f24a56..8f6440e8e 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -30,92 +30,85 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Model_contents__list::SDAI_Model_contents__list(int defaultSize) -{ +SDAI_Model_contents__list::SDAI_Model_contents__list( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Model_contents_ptr[_bufsize]; _count = 0; } -SDAI_Model_contents__list::~SDAI_Model_contents__list() -{ +SDAI_Model_contents__list::~SDAI_Model_contents__list() { delete _buf; } -void SDAI_Model_contents__list::Check(int index) -{ +void SDAI_Model_contents__list::Check( int index ) { - SDAI_Model_contents_ptr *newbuf; + SDAI_Model_contents_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Model_contents_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Model_contents_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Model_contents_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_Model_contents__list::Insert(SDAI_Model_contents_ptr v, int index) -{ +SDAI_Model_contents__list::Insert( SDAI_Model_contents_ptr v, int index ) { - SDAI_Model_contents_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_Model_contents_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Append(SDAI_Model_contents_ptr v) -{ +void SDAI_Model_contents__list::Append( SDAI_Model_contents_ptr v ) { int index = _count; - SDAI_Model_contents_ptr *spot; + SDAI_Model_contents_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Remove(int index) -{ +void SDAI_Model_contents__list::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Model_contents_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + SDAI_Model_contents_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } } -int SDAI_Model_contents__list::Index(SDAI_Model_contents_ptr v) -{ +int SDAI_Model_contents__list::Index( SDAI_Model_contents_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -123,36 +116,31 @@ int SDAI_Model_contents__list::Index(SDAI_Model_contents_ptr v) } SDAI_Model_contents_ptr -SDAI_Model_contents__list::retrieve(int index) -{ - return operator[](index); +SDAI_Model_contents__list::retrieve( int index ) { + return operator[]( index ); } SDAI_Model_contents_ptr & -SDAI_Model_contents__list::operator[](int index) -{ +SDAI_Model_contents__list::operator[]( int index ) { - Check(index); + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Model_contents__list::Count() -{ +SDAI_Model_contents__list::Count() { return _count; } int -SDAI_Model_contents__list::is_empty() -{ +SDAI_Model_contents__list::is_empty() { return _count; } void -SDAI_Model_contents__list::Clear() -{ +SDAI_Model_contents__list::Clear() { _count = 0; } diff --git a/src/cldai/sdaiModel_contents_list.h b/src/cldai/sdaiModel_contents_list.h index 58bd13eb6..47e98a072 100644 --- a/src/cldai/sdaiModel_contents_list.h +++ b/src/cldai/sdaiModel_contents_list.h @@ -3,29 +3,28 @@ #include -class SC_DAI_EXPORT SDAI_Model_contents__list -{ +class SC_DAI_EXPORT SDAI_Model_contents__list { public: - SDAI_Model_contents__list(int = 16); + SDAI_Model_contents__list( int = 16 ); ~SDAI_Model_contents__list(); - SDAI_Model_contents_ptr retrieve(int index); + SDAI_Model_contents_ptr retrieve( int index ); int is_empty(); - SDAI_Model_contents_ptr &operator[](int index); + SDAI_Model_contents_ptr & operator[]( int index ); - void Insert(SDAI_Model_contents_ptr, int index); - void Append(SDAI_Model_contents_ptr); - void Remove(int index); - int Index(SDAI_Model_contents_ptr); + void Insert( SDAI_Model_contents_ptr, int index ); + void Append( SDAI_Model_contents_ptr ); + void Remove( int index ); + int Index( SDAI_Model_contents_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Model_contents_ptr *_buf; + SDAI_Model_contents_ptr * _buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index f68838b29..14cf6c26a 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,10 +1,8 @@ #include #include "sc_memmgr.h" -SDAI_sdaiObject::SDAI_sdaiObject() -{ +SDAI_sdaiObject::SDAI_sdaiObject() { } -SDAI_sdaiObject::~SDAI_sdaiObject() -{ +SDAI_sdaiObject::~SDAI_sdaiObject() { } diff --git a/src/cldai/sdaiObject.h b/src/cldai/sdaiObject.h index 1479af3f1..99936f17c 100644 --- a/src/cldai/sdaiObject.h +++ b/src/cldai/sdaiObject.h @@ -13,8 +13,7 @@ The class Entity_instance shall be a subtype of the C++ class Object: */ -class SC_DAI_EXPORT SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_sdaiObject { public: SDAI_sdaiObject(); virtual ~SDAI_sdaiObject(); @@ -23,7 +22,7 @@ class SC_DAI_EXPORT SDAI_sdaiObject }; -typedef SDAI_sdaiObject *SDAI_sdaiObject_ptr; +typedef SDAI_sdaiObject * SDAI_sdaiObject_ptr; typedef SDAI_sdaiObject_ptr SDAI_sdaiObject_var; /* diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 7c79543e4..6f48be442 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,10 +1,8 @@ #include #include "sc_memmgr.h" -SDAI_Session_instance::SDAI_Session_instance() -{ +SDAI_Session_instance::SDAI_Session_instance() { } -SDAI_Session_instance::~SDAI_Session_instance() -{ +SDAI_Session_instance::~SDAI_Session_instance() { } diff --git a/src/cldai/sdaiSession_instance.h b/src/cldai/sdaiSession_instance.h index 02c8e7acd..fcc8fad15 100644 --- a/src/cldai/sdaiSession_instance.h +++ b/src/cldai/sdaiSession_instance.h @@ -5,8 +5,7 @@ #include //#include -class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { public: int x; @@ -15,7 +14,7 @@ class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject virtual ~SDAI_Session_instance(); }; -typedef SDAI_Session_instance *SDAI_Session_instance_ptr; +typedef SDAI_Session_instance * SDAI_Session_instance_ptr; typedef SDAI_Session_instance_ptr SDAI_Session_instance_var; // the old names diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 82c0ac5b4..664a39358 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -13,80 +13,62 @@ #include #include "sc_memmgr.h" -SDAI_String::SDAI_String(const char *str, size_t max) -{ - if(!str) { +SDAI_String::SDAI_String( const char * str, size_t max ) { + if( !str ) { str = ""; } - if(max == std::string::npos) { - content = std::string(str); + if( max == std::string::npos ) { + content = std::string( str ); } else { - content = std::string(str, max); + content = std::string( str, max ); } } -SDAI_String::SDAI_String(const std::string &s) - : content(std::string(s)) -{ +SDAI_String::SDAI_String( const std::string & s ) + : content( std::string( s ) ) { } -SDAI_String::SDAI_String(const SDAI_String &s) - : content(std::string(s.c_str())) -{ +SDAI_String::SDAI_String( const SDAI_String & s ) + : content( std::string( s.c_str() ) ) { } -SDAI_String::~SDAI_String(void) -{ +SDAI_String::~SDAI_String( void ) { } -SDAI_String &SDAI_String::operator= (const char *s) -{ - content = std::string(s); +SDAI_String & SDAI_String::operator= ( const char * s ) { + content = std::string( s ); return *this; } -SDAI_String &SDAI_String::operator= (const SDAI_String &s) -{ - content = s.content; - return *this; -} - -bool SDAI_String::operator== (const char *s) const -{ - return (content == s); +bool SDAI_String::operator== ( const char * s ) const { + return ( content == s ); } -void SDAI_String::clear(void) -{ +void SDAI_String::clear( void ) { content.clear(); } -bool SDAI_String::empty(void) const -{ +bool SDAI_String::empty( void ) const { return content.empty(); } -const char *SDAI_String::c_str(void) const -{ +const char * SDAI_String::c_str( void ) const { return content.c_str(); } -void SDAI_String::STEPwrite(ostream &out) const -{ +void SDAI_String::STEPwrite( ostream & out ) const { out << c_str(); } -void SDAI_String::STEPwrite(std::string &s) const -{ +void SDAI_String::STEPwrite( std::string & s ) const { s += c_str(); } -Severity SDAI_String::StrToVal(const char *s) -{ - operator= (s); - if(! strcmp(c_str(), s)) { +Severity SDAI_String::StrToVal( const char * s ) { + operator= ( s ); + if( ! strcmp( c_str(), s ) ) { return SEVERITY_NULL ; } else { return SEVERITY_INPUT_ERROR; @@ -97,26 +79,25 @@ Severity SDAI_String::StrToVal(const char *s) * STEPread reads a string in exchange file format * starting with a single quote */ -Severity SDAI_String::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity SDAI_String::STEPread( istream & in, ErrorDescriptor * err ) { clear(); // clear the old string // remember the current format state to restore the previous settings ios_base::fmtflags flags = in.flags(); - in.unsetf(ios::skipws); + in.unsetf( ios::skipws ); // extract the string from the inputstream - std::string s = GetLiteralStr(in, err); + std::string s = GetLiteralStr( in, err ); content += s; // retrieve current severity Severity sev = err -> severity(); - if(s.empty()) { + if( s.empty() ) { // no string was read - in.flags(flags); // set the format state back to previous settings - err -> GreaterSeverity(SEVERITY_INCOMPLETE); + in.flags( flags ); // set the format state back to previous settings + err -> GreaterSeverity( SEVERITY_INCOMPLETE ); sev = SEVERITY_INCOMPLETE; - } else if(sev != SEVERITY_INPUT_ERROR) { + } else if( sev != SEVERITY_INPUT_ERROR ) { // read valid string sev = SEVERITY_NULL; } @@ -126,8 +107,7 @@ Severity SDAI_String::STEPread(istream &in, ErrorDescriptor *err) /** * \copydoc STEPread( istream & in, ErrorDescriptor * err ) */ -Severity SDAI_String::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); - return STEPread(in, err); +Severity SDAI_String::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); + return STEPread( in, err ); } diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index f1b3e4fd0..083da80ea 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -12,12 +12,10 @@ */ #include -#include #include -class SC_DAI_EXPORT SDAI_String -{ +class SC_DAI_EXPORT SDAI_String { private: #ifdef _MSC_VER #pragma warning( push ) @@ -31,31 +29,29 @@ class SC_DAI_EXPORT SDAI_String public: //constructor(s) & destructor - SDAI_String(const char *str = "", size_t max = std::string::npos); - SDAI_String(const std::string &s); - SDAI_String(const SDAI_String &s); - ~SDAI_String(void); + SDAI_String( const char * str = "", size_t max = std::string::npos ); + SDAI_String( const std::string & s ); + SDAI_String( const SDAI_String & s ); + ~SDAI_String( void ); // operators - SDAI_String &operator= (const char *s); - SDAI_String &operator= (const SDAI_String &s); - bool operator== (const char *s) const; + SDAI_String & operator= ( const char * s ); + bool operator== ( const char * s ) const; - void clear(void); - bool empty(void) const; - const char *c_str(void) const; + void clear( void ); + bool empty( void ) const; + const char * c_str( void ) const; // format for STEP - const char *asStr(std::string &s) const - { + const char * asStr( std::string & s ) const { s = c_str(); return s.c_str(); } - void STEPwrite(ostream &out = cout) const; - void STEPwrite(std::string &s) const; + void STEPwrite( ostream & out = cout ) const; + void STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s); - Severity STEPread(istream &in, ErrorDescriptor *err); - Severity STEPread(const char *s, ErrorDescriptor *err); + Severity StrToVal( const char * s ); + Severity STEPread( istream & in, ErrorDescriptor * err ); + Severity STEPread( const char * s, ErrorDescriptor * err ); }; diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 6370bcacb..4c40f73fc 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -27,19 +27,19 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) endif() install(FILES ${SC_CLEDITOR_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor) # Local Variables: # tab-width: 8 diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 7b414aa45..cb1fe5bca 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -46,14 +46,13 @@ * * side effects: STEPfile::_fileName value may change. */ -std::string STEPfile::SetFileName(const std::string newName) -{ +std::string STEPfile::SetFileName( const std::string newName ) { // if a newName is not given or is the same as the old, use the old name - if((newName.empty()) || (newName == _fileName)) { + if( ( newName.empty() ) || ( newName == _fileName ) ) { return FileName(); } - _fileName = DirObj::Normalize(newName); + _fileName = DirObj::Normalize( newName ); return _fileName; } @@ -64,14 +63,13 @@ std::string STEPfile::SetFileName(const std::string newName) * * This function is useless unless it is called from another thread. */ -float STEPfile::GetReadProgress() const -{ - if(_iFileSize < 1) { +float STEPfile::GetReadProgress() const { + if( _iFileSize < 1 ) { return -1; } //the file is read once by ReadData1(), and again by ReadData2. Each gets 50%. - float percent = (static_cast(_iFileCurrentPosition) / _iFileSize) * 50.0; - if(_iFileStage1Done) { + float percent = ( static_cast( _iFileCurrentPosition ) / _iFileSize ) * 50.0; + if( _iFileStage1Done ) { percent += 50; } return percent; @@ -86,11 +84,10 @@ float STEPfile::GetReadProgress() const * * This function is useless unless it is called from another thread. */ -float STEPfile::GetWriteProgress() const -{ +float STEPfile::GetWriteProgress() const { int total = _instances.InstanceCount(); - if(total > 0) { - return (static_cast(_oFileInstsWritten) / total) * 100.0; + if( total > 0 ) { + return ( static_cast( _oFileInstsWritten ) / total ) * 100.0; } else { return -1; } @@ -108,12 +105,11 @@ float STEPfile::GetWriteProgress() const * next "ENDSEC;" from in. * The STEPfile::_headerInstances may change. */ -Severity STEPfile::ReadHeader(istream &in) -{ +Severity STEPfile::ReadHeader( istream & in ) { std::string cmtStr; - InstMgr *im = new InstMgr; - SDAI_Application_instance *obj; + InstMgr * im = new InstMgr; + SDAI_Application_instance * obj; Severity objsev = SEVERITY_NULL; int endsec = 0; @@ -125,41 +121,41 @@ Severity STEPfile::ReadHeader(istream &in) std::string strbuf; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); // Read and gobble all 'junk' up to "HEADER;" - if(!FindHeaderSection(in)) { + if( !FindHeaderSection( in ) ) { delete im; return SEVERITY_INPUT_ERROR; } //read the header instances - while(!endsec) { - ReadTokenSeparator(in, &cmtStr); - if(in.eof()) { - _error.AppendToDetailMsg("End of file reached in reading header section.\n"); - _error.GreaterSeverity(SEVERITY_EXIT); + while( !endsec ) { + ReadTokenSeparator( in, &cmtStr ); + if( in.eof() ) { + _error.AppendToDetailMsg( "End of file reached in reading header section.\n" ); + _error.GreaterSeverity( SEVERITY_EXIT ); delete im; return SEVERITY_EXIT; } //check for user defined instances //if it is userDefined, the '!' does not get put back on the istream - in.get(c); - if(c == '!') { + in.get( c ); + if( c == '!' ) { userDefined = 1; } else { - in.putback(c); + in.putback( c ); } //get the entity keyword - keywd = GetKeyword(in, ";( /\\", _error); - ReadTokenSeparator(in, &cmtStr); + keywd = GetKeyword( in, ";( /\\", _error ); + ReadTokenSeparator( in, &cmtStr ); //check for "ENDSEC" - if(!strncmp(const_cast(keywd.c_str()), "ENDSEC", 7)) { + if( !strncmp( const_cast( keywd.c_str() ), "ENDSEC", 7 ) ) { //get the token delimiter - in.get(c); //should be ';' + in.get( c ); //should be ';' endsec = 1; break; //from while-loop } else { @@ -168,69 +164,69 @@ Severity STEPfile::ReadHeader(istream &in) //create header instance buf[0] = '\0'; - if(_fileType == VERSION_OLD) { - _error.AppendToDetailMsg("N279 header detected. Files this old are no longer supported.\n"); - _error.GreaterSeverity(SEVERITY_EXIT); + if( _fileType == VERSION_OLD ) { + _error.AppendToDetailMsg( "N279 header detected. Files this old are no longer supported.\n" ); + _error.GreaterSeverity( SEVERITY_EXIT ); delete im; return SEVERITY_EXIT; } else { - strncpy(buf, const_cast(keywd.c_str()), BUFSIZ); + strncpy( buf, const_cast( keywd.c_str() ), BUFSIZ ); } - if(userDefined) { + if( userDefined ) { //create user defined header instance // BUG: user defined entities are ignored //obj = _headerUserDefined->ObjCreate (buf); //objsev = AppendEntityErrorMsg( &(obj->Error()) ); - SkipInstance(in, strbuf); + SkipInstance( in, strbuf ); cerr << "User defined entity in header section " << "is ignored.\n\tdata lost: !" << buf << strbuf << "\n"; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); break; //from while loop } else { //not userDefined - obj = _headerRegistry->ObjCreate(buf); + obj = _headerRegistry->ObjCreate( buf ); } //read header instance - if(!obj || (obj == ENTITY_NULL)) { + if( !obj || ( obj == ENTITY_NULL ) ) { ++_errorCount; - SkipInstance(in, strbuf); + SkipInstance( in, strbuf ); cerr << "Unable to create header section entity: \'" << keywd << "\'.\n\tdata lost: " << strbuf << "\n"; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); } else { //not ENTITY_NULL //read the header instance - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); //set file_id to reflect the appropriate Header Section Entity - fileid = HeaderId(const_cast(keywd.c_str())); + fileid = HeaderId( const_cast( keywd.c_str() ) ); //read the values from the istream - objsev = obj->STEPread(fileid, 0, (InstMgr *)0, in, NULL, true, _strict); - _error.GreaterSeverity(objsev); - if(!cmtStr.empty()) { - obj->PrependP21Comment(cmtStr); + objsev = obj->STEPread( fileid, 0, ( InstMgr * )0, in, NULL, true, _strict ); + _error.GreaterSeverity( objsev ); + if( !cmtStr.empty() ) { + obj->PrependP21Comment( cmtStr ); } in >> ws; c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } //check to see if object was successfully read - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); //append to header instance manager - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } } cmtStr.clear(); } - HeaderVerifyInstances(im); - HeaderMergeInstances(im); // handles delete for im + HeaderVerifyInstances( im ); + HeaderMergeInstances( im ); // handles delete for im return _error.severity(); } @@ -244,92 +240,88 @@ Severity STEPfile::ReadHeader(istream &in) * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -Severity STEPfile::HeaderVerifyInstances(InstMgr *im) -{ +Severity STEPfile::HeaderVerifyInstances( InstMgr * im ) { int err = 0; int fileid; - SDAI_Application_instance *obj; + SDAI_Application_instance * obj; //check File_Name - fileid = HeaderId("File_Name"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Name" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_NAME instance not found in header section\n"; // create a File_Name entity and assign default values obj = HeaderDefaultFileName(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } //check File_Description - fileid = HeaderId("File_Description"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Description" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_DESCRIPTION instance not found in header section\n"; // create a File_Description entity and assign default values obj = HeaderDefaultFileDescription(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } //check File_Schema - fileid = HeaderId("File_Schema"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Schema" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_SCHEMA instance not found in header section\n"; // create a File_Schema entity and read in default values obj = HeaderDefaultFileSchema(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } - if(!err) { + if( !err ) { return SEVERITY_NULL; } - _error.AppendToUserMsg("Missing required entity in header section.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "Missing required entity in header section.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileName() -{ - SdaiFile_name *fn = new SdaiFile_name; +SDAI_Application_instance * STEPfile::HeaderDefaultFileName() { + SdaiFile_name * fn = new SdaiFile_name; StringAggregate_ptr tmp = new StringAggregate; - fn->name_(""); - fn->time_stamp_(""); - tmp->StrToVal("", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances); - fn->author_(tmp); + fn->name_( "" ); + fn->time_stamp_( "" ); + tmp->StrToVal( "", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances ); + fn->author_( tmp ); - tmp->StrToVal("", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances); - fn->organization_(tmp); + tmp->StrToVal( "", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances ); + fn->organization_( tmp ); - fn->preprocessor_version_(""); - fn->originating_system_(""); - fn->authorization_(""); + fn->preprocessor_version_( "" ); + fn->originating_system_( "" ); + fn->authorization_( "" ); - fn->STEPfile_id = HeaderId("File_Name"); + fn->STEPfile_id = HeaderId( "File_Name" ); return fn; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileDescription() -{ - SdaiFile_description *fd = new SdaiFile_description; +SDAI_Application_instance * STEPfile::HeaderDefaultFileDescription() { + SdaiFile_description * fd = new SdaiFile_description; - fd->implementation_level_(""); + fd->implementation_level_( "" ); - fd->STEPfile_id = HeaderId("File_Description"); + fd->STEPfile_id = HeaderId( "File_Description" ); return fd; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileSchema() -{ - SdaiFile_schema *fs = new SdaiFile_schema; +SDAI_Application_instance * STEPfile::HeaderDefaultFileSchema() { + SdaiFile_schema * fs = new SdaiFile_schema; StringAggregate_ptr tmp = new StringAggregate; - tmp->StrToVal("", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances); - fs->schema_identifiers_(tmp); + tmp->StrToVal( "", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances ); + fs->schema_identifiers_( tmp ); - fs->STEPfile_id = HeaderId("File_Schema"); + fs->STEPfile_id = HeaderId( "File_Schema" ); return fs; } @@ -355,30 +347,29 @@ SDAI_Application_instance *STEPfile::HeaderDefaultFileSchema() * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -void STEPfile::HeaderMergeInstances(InstMgr *im) -{ - SDAI_Application_instance *se = 0; - SDAI_Application_instance *from = 0; +void STEPfile::HeaderMergeInstances( InstMgr * im ) { + SDAI_Application_instance * se = 0; + SDAI_Application_instance * from = 0; int idnum; //check for _headerInstances - if(!_headerInstances) { + if( !_headerInstances ) { _headerInstances = im; return; } - if(_headerInstances->InstanceCount() < 4) { + if( _headerInstances->InstanceCount() < 4 ) { delete _headerInstances; _headerInstances = im; return; } //checking for _headerInstances::FILE_NAME - idnum = HeaderId("File_Name"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Name" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); // name: // time_stamp: keep the newer time_stamp @@ -388,34 +379,34 @@ void STEPfile::HeaderMergeInstances(InstMgr *im) // originating_system: // authorization: } else { // No current File_Name instance - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } //checking for _headerInstances::FILE_DESCRIPTION - idnum = HeaderId("File_Description"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Description" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); //description //implementation_level } else { - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } //checking for _headerInstances::FILE_SCHEMA - idnum = HeaderId("File_Schema"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Schema" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); //description //implementation_level } else { - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } delete im; @@ -423,9 +414,8 @@ void STEPfile::HeaderMergeInstances(InstMgr *im) } -stateEnum STEPfile::EntityWfState(char c) -{ - switch(c) { +stateEnum STEPfile::EntityWfState( char c ) { + switch( c ) { case wsSaveComplete: return completeSE; case wsSaveIncomplete: @@ -443,8 +433,7 @@ stateEnum STEPfile::EntityWfState(char c) * PASS 1: create instances * starts at the data section */ -int STEPfile::ReadData1(istream &in) -{ +int STEPfile::ReadData1( istream & in ) { int endsec = 0; _entsNotCreated = 0; @@ -457,66 +446,66 @@ int STEPfile::ReadData1(istream &in) buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; stateEnum inst_state = noStateSE; // used if reading working file ErrorDescriptor e; // PASS 1: create instances - endsec = FoundEndSecKywd(in); - while(in.good() && !endsec) { + endsec = FoundEndSecKywd( in ); + while( in.good() && !endsec ) { e.ClearErrorMsg(); - ReadTokenSeparator(in); // also skips white space + ReadTokenSeparator( in ); // also skips white space in >> c; - if(_fileType == WORKING_SESSION) { - if(strchr("CIND", c)) { // if there is a valid char - inst_state = EntityWfState(c); - ReadTokenSeparator(in); + if( _fileType == WORKING_SESSION ) { + if( strchr( "CIND", c ) ) { // if there is a valid char + inst_state = EntityWfState( c ); + ReadTokenSeparator( in ); in >> c; // read the ENTITY_NAME_DELIM } else { - e.AppendToDetailMsg("Invalid editing state character: "); - e.AppendToDetailMsg(c); - e.AppendToDetailMsg("\nAssigning editing state to be INCOMPLETE\n"); - e.GreaterSeverity(SEVERITY_WARNING); + e.AppendToDetailMsg( "Invalid editing state character: " ); + e.AppendToDetailMsg( c ); + e.AppendToDetailMsg( "\nAssigning editing state to be INCOMPLETE\n" ); + e.GreaterSeverity( SEVERITY_WARNING ); inst_state = incompleteSE; } } - if(c != ENTITY_NAME_DELIM) { - in.putback(c); - while(c != ENTITY_NAME_DELIM && in.good() && - !(endsec = FoundEndSecKywd(in))) { + if( c != ENTITY_NAME_DELIM ) { + in.putback( c ); + while( c != ENTITY_NAME_DELIM && in.good() && + !( endsec = FoundEndSecKywd( in ) ) ) { tmpbuf.clear(); - FindStartOfInstance(in, tmpbuf); + FindStartOfInstance( in, tmpbuf ); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } } - if(!endsec) { + if( !endsec ) { obj = ENTITY_NULL; - if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { - SkipInstance(in, tmpbuf); + if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { + SkipInstance( in, tmpbuf ); } else { - obj = CreateInstance(in, cout); + obj = CreateInstance( in, cout ); _iFileCurrentPosition = in.tellg(); } - if(obj != ENTITY_NULL) { - if(obj->Error().severity() < SEVERITY_WARNING) { + if( obj != ENTITY_NULL ) { + if( obj->Error().severity() < SEVERITY_WARNING ) { ++_errorCount; - } else if(obj->Error().severity() < SEVERITY_NULL) { + } else if( obj->Error().severity() < SEVERITY_NULL ) { ++_warningCount; } obj->Error().ClearErrorMsg(); - if(_fileType == WORKING_SESSION) { - instances().Append(obj, inst_state); + if( _fileType == WORKING_SESSION ) { + instances().Append( obj, inst_state ); } else { - instances().Append(obj, newSE); + instances().Append( obj, newSE ); } ++instance_count; @@ -526,46 +515,44 @@ int STEPfile::ReadData1(istream &in) ++_errorCount; } - if(_entsNotCreated > _maxErrorCount) { - _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); + if( _entsNotCreated > _maxErrorCount ) { + _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity(SEVERITY_EXIT); + Error().severity( SEVERITY_EXIT ); return instance_count; } - endsec = FoundEndSecKywd(in); + endsec = FoundEndSecKywd( in ); } } // end while loop - if(_entsNotCreated) { - sprintf(buf, - "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", - _entsNotCreated); - _error.AppendToUserMsg(buf); - _error.GreaterSeverity(SEVERITY_WARNING); + if( _entsNotCreated ) { + sprintf( buf, + "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", + _entsNotCreated ); + _error.AppendToUserMsg( buf ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - if(!in.good()) { - _error.AppendToUserMsg("Error in input file.\n"); + if( !in.good() ) { + _error.AppendToUserMsg( "Error in input file.\n" ); } _iFileStage1Done = true; return instance_count; } -int STEPfile::ReadWorkingData1(istream &in) -{ - return ReadData1(in); +int STEPfile::ReadWorkingData1( istream & in ) { + return ReadData1( in ); } /** * \returns number of valid instances read * reads in the data portion of the instances in an exchange file */ -int STEPfile::ReadData2(istream &in, bool useTechCor) -{ +int STEPfile::ReadData2( istream & in, bool useTechCor ) { _entsInvalid = 0; _entsIncomplete = 0; _entsWarning = 0; @@ -582,58 +569,58 @@ int STEPfile::ReadData2(istream &in, bool useTechCor) buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; std::string cmtStr; - int endsec = FoundEndSecKywd(in); + int endsec = FoundEndSecKywd( in ); // PASS 2: read instances - while(in.good() && !endsec) { - ReadTokenSeparator(in, &cmtStr); + while( in.good() && !endsec ) { + ReadTokenSeparator( in, &cmtStr ); in >> c; - if(_fileType == WORKING_SESSION) { - if(strchr("CIND", c)) { // if there is a valid char - inst_state = EntityWfState(c); - ReadTokenSeparator(in, &cmtStr); + if( _fileType == WORKING_SESSION ) { + if( strchr( "CIND", c ) ) { // if there is a valid char + inst_state = EntityWfState( c ); + ReadTokenSeparator( in, &cmtStr ); in >> c; // read the ENTITY_NAME_DELIM } } - if(c != ENTITY_NAME_DELIM) { - in.putback(c); - while(c != ENTITY_NAME_DELIM && in.good() && - !(endsec = FoundEndSecKywd(in))) { + if( c != ENTITY_NAME_DELIM ) { + in.putback( c ); + while( c != ENTITY_NAME_DELIM && in.good() && + !( endsec = FoundEndSecKywd( in ) ) ) { tmpbuf.clear(); - FindStartOfInstance(in, tmpbuf); + FindStartOfInstance( in, tmpbuf ); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); } } - if(!endsec) { + if( !endsec ) { obj = ENTITY_NULL; - if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { - SkipInstance(in, tmpbuf); + if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { + SkipInstance( in, tmpbuf ); } else { - obj = ReadInstance(in, cout, cmtStr, useTechCor); + obj = ReadInstance( in, cout, cmtStr, useTechCor ); _iFileCurrentPosition = in.tellg(); } cmtStr.clear(); - if(obj != ENTITY_NULL) { - if(obj->Error().severity() < SEVERITY_INCOMPLETE) { + if( obj != ENTITY_NULL ) { + if( obj->Error().severity() < SEVERITY_INCOMPLETE ) { ++_entsInvalid; // old ++_errorCount; - } else if(obj->Error().severity() == SEVERITY_INCOMPLETE) { + } else if( obj->Error().severity() == SEVERITY_INCOMPLETE ) { ++_entsIncomplete; ++_entsInvalid; - } else if(obj->Error().severity() == SEVERITY_USERMSG) { + } else if( obj->Error().severity() == SEVERITY_USERMSG ) { ++_entsWarning; } else { // i.e. if severity == SEVERITY_NULL ++valid_insts; @@ -648,75 +635,73 @@ int STEPfile::ReadData2(istream &in, bool useTechCor) ++_errorCount; } - if(_entsInvalid > _maxErrorCount) { - _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); + if( _entsInvalid > _maxErrorCount ) { + _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity(SEVERITY_EXIT); + Error().severity( SEVERITY_EXIT ); return valid_insts; } - endsec = FoundEndSecKywd(in); + endsec = FoundEndSecKywd( in ); } } // end while loop - if(_entsInvalid) { - sprintf(buf, - "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", - "Second pass complete - instance summary:", total_instances, - _entsInvalid, _entsIncomplete, "Warnings", - _entsWarning); + if( _entsInvalid ) { + sprintf( buf, + "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", + "Second pass complete - instance summary:", total_instances, + _entsInvalid, _entsIncomplete, "Warnings", + _entsWarning ); cout << buf << endl; - _error.AppendToUserMsg(buf); - _error.AppendToDetailMsg(buf); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( buf ); + _error.AppendToDetailMsg( buf ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - if(!in.good()) { - _error.AppendToUserMsg("Error in input file.\n"); + if( !in.good() ) { + _error.AppendToUserMsg( "Error in input file.\n" ); } return valid_insts; } -int STEPfile::ReadWorkingData2(istream &in, bool useTechCor) -{ - return ReadData2(in, useTechCor); +int STEPfile::ReadWorkingData2( istream & in, bool useTechCor ) { + return ReadData2( in, useTechCor ); } /** Looks for the word DATA followed by optional whitespace * followed by a semicolon. When it is looking for the word * DATA it skips over strings and comments. */ -int STEPfile::FindDataSection(istream &in) -{ +int STEPfile::FindDataSection( istream & in ) { ErrorDescriptor errs; SDAI_String tmp; std::string s; // used if need to read a comment char c; - while(in.good()) { + while( in.good() ) { in >> c; - if(in.eof()) { - _error.AppendToUserMsg("Can't find \"DATA;\" section."); + if( in.eof() ) { + _error.AppendToUserMsg( "Can't find \"DATA;\" section." ); return 0; //ERROR_WARNING } - switch(c) { + switch( c ) { case 'D': // look for string "DATA;" with optional whitespace after "DATA" c = in.peek(); // look at next char (for 'A') // only peek since it may be 'D' again a we need to start over - if(c == 'A') { - in.get(c); // read char 'A' + if( c == 'A' ) { + in.get( c ); // read char 'A' c = in.peek(); // look for 'T' - if(c == 'T') { - in.get(c); // read 'T' + if( c == 'T' ) { + in.get( c ); // read 'T' c = in.peek(); // look for 'A' - if(c == 'A') { - in.get(c); // read 'A' + if( c == 'A' ) { + in.get( c ); // read 'A' in >> ws; // may want to skip comments or print control directives? c = in.peek(); // look for semicolon - if(c == ';') { - in.get(c); // read the semicolon + if( c == ';' ) { + in.get( c ); // read the semicolon return 1; // success } } @@ -725,13 +710,13 @@ int STEPfile::FindDataSection(istream &in) break; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); + in.putback( c ); + tmp.STEPread( in, &errs ); break; case '/': // read p21 file comment - in.putback(c); // looks like a comment - ReadComment(in, s); + in.putback( c ); // looks like a comment + ReadComment( in, s ); break; case '\0': // problem in input ? @@ -744,23 +729,22 @@ int STEPfile::FindDataSection(istream &in) return 0; } -int STEPfile::FindHeaderSection(istream &in) -{ +int STEPfile::FindHeaderSection( istream & in ) { char buf[BUFSIZ]; - char *b = buf; + char * b = buf; *b = '\0'; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); // find the header section - while(!(b = strstr(buf, "HEADER"))) { - if(in.eof()) { + while( !( b = strstr( buf, "HEADER" ) ) ) { + if( in.eof() ) { _error.AppendToUserMsg( - "Error: Unable to find HEADER section. File not read.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + "Error: Unable to find HEADER section. File not read.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); return 0; } - in.getline(buf, BUFSIZ, ';'); // reads but does not store the ; + in.getline( buf, BUFSIZ, ';' ); // reads but does not store the ; } return 1; } @@ -785,8 +769,7 @@ an ENTITY_INSTANCE consists of: '#'(int)'=' [SCOPE] SUBSUPER_RECORD ';' The '#' is read from the istream before CreateInstance is called. */ -SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) -{ +SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & out ) { std::string tmpbuf; std::string objnm; @@ -794,53 +777,53 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) std::string schnm; int fileid = -1; - SDAI_Application_instance_ptr *scopelist = 0; + SDAI_Application_instance_ptr * scopelist = 0; - SDAI_Application_instance *obj; + SDAI_Application_instance * obj; ErrorDescriptor result; // Sent down to CreateSubSuperInstance() to receive error info - ReadTokenSeparator(in); + ReadTokenSeparator( in ); in >> fileid; // read instance id - fileid = IncrementFileId(fileid); - if(instances().FindFileId(fileid)) { - SkipInstance(in, tmpbuf); + fileid = IncrementFileId( fileid ); + if( instances().FindFileId( fileid ) ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " already exists.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in); - in.get(c); // read equal sign - if(c != '=') { + ReadTokenSeparator( in ); + in.get( c ); // read equal sign + if( c != '=' ) { // ERROR: '=' expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); c = in.peek(); // peek at the next character on the istream //check for optional "&SCOPE" construct - if(c == '&') { // TODO check this out - Severity s = CreateScopeInstances(in, &scopelist); - if(s < SEVERITY_WARNING) { + if( c == '&' ) { // TODO check this out + Severity s = CreateScopeInstances( in, &scopelist ); + if( s < SEVERITY_WARNING ) { return ENTITY_NULL; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); c = in.peek(); // peek at next char on istream again } //check for subtype/supertype record - if(c == '(') { + if( c == '(' ) { // TODO: implement complex inheritance - obj = CreateSubSuperInstance(in, fileid, result); - if(obj == ENTITY_NULL) { - SkipInstance(in, tmpbuf); + obj = CreateSubSuperInstance( in, fileid, result ); + if( obj == ENTITY_NULL ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " Illegal complex entity.\n" << result.UserMsg() << ".\n\n"; @@ -849,21 +832,21 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) } else { // not a complex entity // check for User Defined Entity int userDefined = 0; - if(c == '!') { + if( c == '!' ) { userDefined = 1; - in.get(c); + in.get( c ); } - ReadStdKeyword(in, objnm, 1); // read the type name - if(!in.good()) { + ReadStdKeyword( in, objnm, 1 ); // read the type name + if( !in.good() ) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::CreateInstance.\n"; } //create the instance using the Registry object - if(userDefined) { - SkipInstance(in, tmpbuf); + if( userDefined ) { + SkipInstance( in, tmpbuf ); out << "WARNING: instance #" << fileid << " User Defined Entity in DATA section ignored.\n" << "\tData lost: \'!" << objnm << "\': " << tmpbuf @@ -871,18 +854,18 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) return ENTITY_NULL; } else { schnm = schemaName(); - obj = reg().ObjCreate(objnm.c_str(), schnm.c_str()); - if(obj == ENTITY_NULL) { + obj = reg().ObjCreate( objnm.c_str(), schnm.c_str() ); + if( obj == ENTITY_NULL ) { // This will be the case if objnm does not exist in the reg. - result.UserMsg("Unknown ENTITY type"); - } else if(obj->Error().severity() <= SEVERITY_WARNING) { + result.UserMsg( "Unknown ENTITY type" ); + } else if( obj->Error().severity() <= SEVERITY_WARNING ) { // Common causes of error is that obj is an abstract supertype // or that it can only be instantiated using external mapping. // If neither are the case, create a generic message. - if(!obj->Error().UserMsg().empty()) { - result.UserMsg(obj->Error().UserMsg()); + if( !obj->Error().UserMsg().empty() ) { + result.UserMsg( obj->Error().UserMsg() ); } else { - result.UserMsg("Could not create ENTITY"); + result.UserMsg( "Could not create ENTITY" ); } // Delete obj so that below we'll know that an error occur: delete obj; @@ -891,8 +874,8 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) } } - if(obj == ENTITY_NULL) { - SkipInstance(in, tmpbuf); + if( obj == ENTITY_NULL ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'" << objnm << "\': " << result.UserMsg() << ".\n\tData lost: " << tmpbuf << "\n\n"; @@ -901,9 +884,9 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) obj -> STEPfile_id = fileid; // scan values - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); - ReadTokenSeparator(in); + ReadTokenSeparator( in ); return obj; } @@ -922,61 +905,60 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) < SEVERITY_WARNING: the istream was read up to and including the next ";" < SEVERITY_BUG: fatal */ -Severity STEPfile::CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist) -{ +Severity STEPfile::CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ) { Severity rval = SEVERITY_NULL; - SDAI_Application_instance *se; + SDAI_Application_instance * se; std::string tmpbuf; char c; std::vector< SDAI_Application_instance_ptr > inscope; std::string keywd; - keywd = GetKeyword(in, " \n\t/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { + keywd = GetKeyword( in, " \n\t/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { //ERROR: "&SCOPE" expected //TODO: should attempt to recover by reading through ENDSCOPE //currently recovery is attempted by reading through next ";" - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: " << "\'&SCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; return SEVERITY_INPUT_ERROR; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); - in.get(c); - while(c == '#') { - se = CreateInstance(in, cout); - if(se != ENTITY_NULL) { + in.get( c ); + while( c == '#' ) { + se = CreateInstance( in, cout ); + if( se != ENTITY_NULL ) { //TODO: apply scope information to se // Add se to scopelist - inscope.push_back(se); + inscope.push_back( se ); //append the se to the instance manager - instances().Append(se, newSE); + instances().Append( se, newSE ); } else { //ERROR: instance in SCOPE not created rval = SEVERITY_WARNING; - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "instance in SCOPE not created.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; } - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - in.putback(c); + in.putback( c ); *scopelist = new SDAI_Application_instance_ptr [inscope.size()]; - for(size_t i = 0; i < inscope.size(); ++i) { + for( size_t i = 0; i < inscope.size(); ++i ) { *scopelist[i] = inscope[i]; } //check for "ENDSCOPE" - keywd = GetKeyword(in, " \t\n/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { + keywd = GetKeyword( in, " \t\n/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { //ERROR: "ENDSCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: " << "\'ENDSCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; @@ -984,38 +966,37 @@ Severity STEPfile::CreateScopeInstances(istream &in, SDAI_Application_instance_p } //check for export list - ReadTokenSeparator(in); - in.get(c); - in.putback(c); - if(c == '/') { + ReadTokenSeparator( in ); + in.get( c ); + in.putback( c ); + if( c == '/' ) { //read export list - in.get(c); + in.get( c ); c = ','; - while(c == ',') { + while( c == ',' ) { int exportid; - ReadTokenSeparator(in); - in.get(c); - if(c != '#') { } //ERROR + ReadTokenSeparator( in ); + in.get( c ); + if( c != '#' ) { } //ERROR in >> exportid; //TODO: nothing is done with the idnums on the export list - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - if(c != '/') { + if( c != '/' ) { //ERROR: '/' expected while reading export list - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: \'/\' expected in export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_INPUT_ERROR; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } return rval; } -SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fileid, ErrorDescriptor &e) -{ - SDAI_Application_instance *obj = ENTITY_NULL; +SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int fileid, ErrorDescriptor & e ) { + SDAI_Application_instance * obj = ENTITY_NULL; char c; std::string schnm; @@ -1024,20 +1005,20 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil ErrorDescriptor err; // used to catch error msgs const int enaSize = 64; - std::string *entNmArr[enaSize]; // array of entity type names + std::string * entNmArr[enaSize]; // array of entity type names int enaIndex = 0; in >> ws; - in.get(c); // read the open paren + in.get( c ); // read the open paren c = in.peek(); // see if you have closed paren (ending the record) - while(in.good() && (c != ')') && (enaIndex < enaSize)) { - entNmArr[enaIndex] = new std::string(""); - ReadStdKeyword(in, *(entNmArr[enaIndex]), 1); // read the type name - if(entNmArr[enaIndex]->empty()) { + while( in.good() && ( c != ')' ) && ( enaIndex < enaSize ) ) { + entNmArr[enaIndex] = new std::string( "" ); + ReadStdKeyword( in, *( entNmArr[enaIndex] ), 1 ); // read the type name + if( entNmArr[enaIndex]->empty() ) { delete entNmArr[enaIndex]; entNmArr[enaIndex] = 0; } else { - SkipSimpleRecord(in, buf, &err); + SkipSimpleRecord( in, buf, &err ); buf.clear(); enaIndex++; } @@ -1047,7 +1028,7 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil // garbage or a comment) this will keep the read function from // infinite looping. If the entity name starts with a digit it is // incorrect and will be invalid. - while(in.good() && (c != ')') && !isalpha(c)) { + while( in.good() && ( c != ')' ) && !isalpha( c ) ) { in >> c; // skip the invalid char c = in.peek(); // see if you have closed paren (ending the record) } @@ -1055,18 +1036,18 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil entNmArr[enaIndex] = 0; schnm = schemaName(); - obj = new STEPcomplex(&_reg, (const std::string **)entNmArr, fileid, schnm.c_str()); + obj = new STEPcomplex( &_reg, ( const std::string ** )entNmArr, fileid, schnm.c_str() ); - if(obj->Error().severity() <= SEVERITY_WARNING) { + if( obj->Error().severity() <= SEVERITY_WARNING ) { // If obj is not legal, record its error info and delete it: - e.severity(obj->Error().severity()); - e.UserMsg(obj->Error().UserMsg()); + e.severity( obj->Error().severity() ); + e.UserMsg( obj->Error().UserMsg() ); delete obj; obj = ENTITY_NULL; } enaIndex = 0; - while(entNmArr[enaIndex] != 0) { + while( entNmArr[enaIndex] != 0 ) { delete entNmArr[enaIndex]; enaIndex ++; } @@ -1082,30 +1063,29 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil It first searches for "&SCOPE" and reads all characters from the istream up to and including "ENDSCOPE" */ -Severity STEPfile::ReadScopeInstances(istream &in) -{ +Severity STEPfile::ReadScopeInstances( istream & in ) { Severity rval = SEVERITY_NULL; - SDAI_Application_instance *se; + SDAI_Application_instance * se; std::string tmpbuf; char c; std::string keywd; std::string cmtStr; - keywd = GetKeyword(in, " \n\t/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { + keywd = GetKeyword( in, " \n\t/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { //ERROR: "&SCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "\'&SCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); - in.get(c); - while(c == '#') { - se = ReadInstance(in, cout, cmtStr); - if(se != ENTITY_NULL) { + in.get( c ); + while( c == '#' ) { + se = ReadInstance( in, cout, cmtStr ); + if( se != ENTITY_NULL ) { //apply scope information to se //TODO: not yet implemented } else { @@ -1113,46 +1093,46 @@ Severity STEPfile::ReadScopeInstances(istream &in) rval = SEVERITY_WARNING; } - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - in.putback(c); + in.putback( c ); //check for "ENDSCOPE" - keywd = GetKeyword(in, " \t\n/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { + keywd = GetKeyword( in, " \t\n/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { //ERROR: "ENDSCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << " \'ENDSCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } //check for export list - ReadTokenSeparator(in); - in.get(c); - in.putback(c); - if(c == '/') { + ReadTokenSeparator( in ); + in.get( c ); + in.putback( c ); + if( c == '/' ) { //read through export list - in.get(c); + in.get( c ); c = ','; - while(c == ',') { + while( c == ',' ) { int exportid; - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); in >> exportid; - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - if(c != '/') { + if( c != '/' ) { //ERROR: '/' expected while reading export list - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << " \'/\' expected while reading export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_WARNING; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } return rval; } @@ -1165,9 +1145,8 @@ Severity STEPfile::ReadScopeInstances(istream &in) reading the SDAI_Application_instance. It passes SDAI_Application_instance error information onto the STEPfile ErrorDescriptor. */ -SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std::string &cmtStr, - bool useTechCor) -{ +SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr, + bool useTechCor ) { Severity sev = SEVERITY_NULL; std::string tmpbuf; @@ -1178,33 +1157,33 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std char c; int fileid; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; int idIncrNum = FileIdIncr(); - ReadComment(in, cmtStr); + ReadComment( in, cmtStr ); in >> fileid; - fileid = IncrementFileId(fileid); + fileid = IncrementFileId( fileid ); // check to see that instance was created on PASS 1 - MgrNode *node = instances().FindFileId(fileid); - if((!node) || ((obj = node -> GetApplication_instance()) == ENTITY_NULL)) { - SkipInstance(in, tmpbuf); + MgrNode * node = instances().FindFileId( fileid ); + if( ( !node ) || ( ( obj = node -> GetApplication_instance() ) == ENTITY_NULL ) ) { + SkipInstance( in, tmpbuf ); // Changed the 2nd pass error message to report Part 21 User // Defined Entities. STEPfile still includes them in the error count // which is not valid. // Check to see if an User Defined Entity has been found. - const char *ude = tmpbuf.c_str(); - while(*ude && (*ude != '=')) { + const char * ude = tmpbuf.c_str(); + while( *ude && ( *ude != '=' ) ) { ude++; } - if(*ude == '=') { + if( *ude == '=' ) { ude++; } - while(*ude && isspace(*ude)) { + while( *ude && isspace( *ude ) ) { ude++; } - if(*ude == '!') { + if( *ude == '!' ) { out << "\nWARNING: #" << fileid << " - Ignoring User Defined Entity.\n\tData lost: " << tmpbuf << endl; @@ -1212,80 +1191,80 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std out << "\nERROR: in 2nd pass, instance #" << fileid << " not found.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; - } else if((_fileType != WORKING_SESSION) && (node->CurrState() != newSE)) { - SkipInstance(in, tmpbuf); + } else if( ( _fileType != WORKING_SESSION ) && ( node->CurrState() != newSE ) ) { + SkipInstance( in, tmpbuf ); out << "\nERROR: in 2nd pass, instance #" << fileid << " already exists - ignoring duplicate.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - in.get(c); - if(c != '=') { + in.get( c ); + if( c != '=' ) { //ERROR: '=' expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); //peek at the next character on the istream c = in.peek(); //check for optional "&SCOPE" construct - if(c == '&') { - ReadScopeInstances(in); - ReadTokenSeparator(in, &cmtStr); - in.get(c); - in.putback(c); + if( c == '&' ) { + ReadScopeInstances( in ); + ReadTokenSeparator( in, &cmtStr ); + in.get( c ); + in.putback( c ); } currSch = schemaName(); //check for subtype/supertype record - if(c == '(') { + if( c == '(' ) { // TODO - sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict); + sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict ); - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - if(!cmtStr.empty()) { - obj->AddP21Comment(cmtStr); + if( !cmtStr.empty() ) { + obj->AddP21Comment( cmtStr ); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } } else { - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); c = in.peek(); // check for User Defined Entity // DAS - I checked this out. It doesn't get into this code for user // defined entities because a ude isn't created. int userDefined = 0; - if(c == '!') { + if( c == '!' ) { userDefined = 1; - in.get(c); + in.get( c ); } - ReadStdKeyword(in, objnm, 1); // read the type name - if(!in.good()) { + ReadStdKeyword( in, objnm, 1 ); // read the type name + if( !in.good() ) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::ReadInstance." << endl; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); // read values - if(userDefined) { - SkipInstance(in, tmpbuf); + if( userDefined ) { + SkipInstance( in, tmpbuf ); out << "WARNING: #" << fileid << ". Ignoring User defined entity." << endl << " data lost: !" << objnm << tmpbuf << endl; @@ -1296,30 +1275,30 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std // NOTE: this function is called for all FileTypes // (WORKING_SESSION included) - sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict); + sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict ); - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - if(!cmtStr.empty()) { - obj->AddP21Comment(cmtStr); + if( !cmtStr.empty() ) { + obj->AddP21Comment( cmtStr ); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); } //set the node's state, //and set the STEPfile:_error (based on the type of file being read) - switch(sev) { + switch( sev ) { case SEVERITY_NULL: case SEVERITY_USERMSG: - if(_fileType != WORKING_SESSION) { - node->ChangeState(completeSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( completeSE ); } break; @@ -1328,18 +1307,18 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std case SEVERITY_BUG: case SEVERITY_INCOMPLETE: - if(_fileType == VERSION_CURRENT) { + if( _fileType == VERSION_CURRENT ) { cerr << "ERROR in EXCHANGE FILE: incomplete instance #" << obj -> STEPfile_id << ".\n"; - if(_fileType != WORKING_SESSION) { - node->ChangeState(incompleteSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( incompleteSE ); } } else { - if(node->CurrState() == completeSE) { - sprintf(errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid); - _error.AppendToUserMsg(errbuf); - if(_fileType != WORKING_SESSION) { - node->ChangeState(incompleteSE); + if( node->CurrState() == completeSE ) { + sprintf( errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid ); + _error.AppendToUserMsg( errbuf ); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( incompleteSE ); } } } @@ -1348,8 +1327,8 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std case SEVERITY_EXIT: case SEVERITY_DUMP: case SEVERITY_MAX: - if(_fileType != WORKING_SESSION) { - node->ChangeState(noStateSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( noStateSE ); } break; @@ -1380,100 +1359,96 @@ BUG: doesn't check to see if the backup command works. the results of the system call are not used by the by this function */ -void STEPfile::MakeBackupFile() -{ +void STEPfile::MakeBackupFile() { std::string bckup = FileName(); - bckup.append(".bak"); + bckup.append( ".bak" ); - std::fstream f(FileName().c_str(), std::fstream::in | std::fstream::binary); + std::fstream f( FileName().c_str(), std::fstream::in | std::fstream::binary ); f << std::noskipws; - std::istream_iterator begin(f); + std::istream_iterator begin( f ); std::istream_iterator end; - std::fstream f2(bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary); - std::ostream_iterator begin2(f2); + std::fstream f2( bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary ); + std::ostream_iterator begin2( f2 ); - copy(begin, end, begin2); + copy( begin, end, begin2 ); - _error.AppendToDetailMsg("Making backup file: "); - _error.AppendToDetailMsg(bckup.c_str()); - _error.AppendToDetailMsg("\n"); + _error.AppendToDetailMsg( "Making backup file: " ); + _error.AppendToDetailMsg( bckup.c_str() ); + _error.AppendToDetailMsg( "\n" ); } -Severity STEPfile::WriteExchangeFile(ostream &out, int validate, int clearError, - int writeComments) -{ +Severity STEPfile::WriteExchangeFile( ostream & out, int validate, int clearError, + int writeComments ) { Severity rval = SEVERITY_NULL; - SetFileType(VERSION_CURRENT); - if(clearError) { + SetFileType( VERSION_CURRENT ); + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } out << FILE_DELIM << "\n"; - WriteHeader(out); - WriteData(out, writeComments); + WriteHeader( out ); + WriteData( out, writeComments ); out << END_FILE_DELIM << "\n"; return rval; } -Severity STEPfile::WriteExchangeFile(const std::string filename, int validate, int clearError, - int writeComments) -{ +Severity STEPfile::WriteExchangeFile( const std::string filename, int validate, int clearError, + int writeComments ) { Severity rval = SEVERITY_NULL; - if(clearError) { + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File wasn't opened. Try saving as working session file.\n"); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File wasn't opened. Try saving as working session file.\n" ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } - ostream *out = OpenOutputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { + ostream * out = OpenOutputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } - rval = WriteExchangeFile(*out, 0, 0, writeComments); - CloseOutputFile(out); + rval = WriteExchangeFile( *out, 0, 0, writeComments ); + CloseOutputFile( out ); return rval; } -Severity STEPfile::WriteValuePairsFile(ostream &out, int validate, int clearError, - int writeComments, int mixedCase) -{ +Severity STEPfile::WriteValuePairsFile( ostream & out, int validate, int clearError, + int writeComments, int mixedCase ) { Severity rval = SEVERITY_NULL; - SetFileType(VERSION_CURRENT); - if(clearError) { + SetFileType( VERSION_CURRENT ); + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } - WriteValuePairsData(out, writeComments, mixedCase); + WriteValuePairsData( out, writeComments, mixedCase ); return rval; } @@ -1491,19 +1466,18 @@ The header section entities must be numbered in the following manner: #2=FILE_NAME #3=FILE_SCHEMA */ -int STEPfile::HeaderId(const char *name) -{ +int STEPfile::HeaderId( const char * name ) { std::string tmp = name; - std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::toupper); + std::transform( tmp.begin(), tmp.end(), tmp.begin(), ::toupper ); - if(tmp == "FILE_DESCRIPTION") { + if( tmp == "FILE_DESCRIPTION" ) { return 1; } - if(tmp == "FILE_NAME") { + if( tmp == "FILE_NAME" ) { return 2; } - if(tmp == "FILE_SCHEMA") { + if( tmp == "FILE_SCHEMA" ) { return 3; } return ++_headerId; @@ -1511,43 +1485,41 @@ int STEPfile::HeaderId(const char *name) /*************************** ***************************/ -void STEPfile::WriteHeader(ostream &out) -{ +void STEPfile::WriteHeader( ostream & out ) { out << "HEADER;\n"; - WriteHeaderInstanceFileDescription(out); - WriteHeaderInstanceFileName(out); - WriteHeaderInstanceFileSchema(out); + WriteHeaderInstanceFileDescription( out ); + WriteHeaderInstanceFileName( out ); + WriteHeaderInstanceFileSchema( out ); // Write the rest of the header instances - SDAI_Application_instance *se; + SDAI_Application_instance * se; int n = _headerInstances->InstanceCount(); - for(int i = 0; i < n; ++i) { - se = _headerInstances->GetMgrNode(i) ->GetApplication_instance(); - if(!( - (se->StepFileId() == HeaderId("File_Name")) || - (se->StepFileId() == HeaderId("File_Description")) || - (se->StepFileId() == HeaderId("File_Schema")) - )) + for( int i = 0; i < n; ++i ) { + se = _headerInstances->GetMgrNode( i ) ->GetApplication_instance(); + if( !( + ( se->StepFileId() == HeaderId( "File_Name" ) ) || + ( se->StepFileId() == HeaderId( "File_Description" ) ) || + ( se->StepFileId() == HeaderId( "File_Schema" ) ) + ) ) WriteHeaderInstance( - _headerInstances->GetMgrNode(i)->GetApplication_instance(), out); + _headerInstances->GetMgrNode( i )->GetApplication_instance(), out ); } out << "ENDSEC;\n"; } /*************************** ***************************/ -void STEPfile::WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out) -{ +void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ) { std::string tmp; - if(!obj->P21Comment().empty()) { + if( !obj->P21Comment().empty() ) { out << obj->P21Comment(); } - out << StrToUpper(obj->EntityName(), tmp) << "("; + out << StrToUpper( obj->EntityName(), tmp ) << "("; int n = obj->attributes.list_length(); - for(int i = 0; i < n; ++i) { - (obj->attributes[i]).STEPwrite(out); - if(i < n - 1) { + for( int i = 0; i < n; ++i ) { + ( obj->attributes[i] ).STEPwrite( out ); + if( i < n - 1 ) { out << ","; } } @@ -1556,17 +1528,16 @@ void STEPfile::WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out) /*************************** ***************************/ -void STEPfile::WriteHeaderInstanceFileName(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { // Get the FileName instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Name"); - if(se == ENTITY_NULL) { - se = (SDAI_Application_instance *)HeaderDefaultFileName(); + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Name" ); + if( se == ENTITY_NULL ) { + se = ( SDAI_Application_instance * )HeaderDefaultFileName(); } //set some of the attribute values at time of output - SdaiFile_name *fn = (SdaiFile_name *)se; + SdaiFile_name * fn = ( SdaiFile_name * )se; /* I'm not sure this is a good idea that Peter did but I'll leave around - DAS // write time_stamp (as specified in ISO Standard 8601) @@ -1574,135 +1545,130 @@ void STEPfile::WriteHeaderInstanceFileName(ostream &out) // example: '1994-04-12T15:27:46' // for Calendar Date, 12 April 1994, 27 minute 46 seconds past 15 hours */ - time_t t = time(NULL); - struct tm *timeptr = localtime(&t); + time_t t = time( NULL ); + struct tm * timeptr = localtime( &t ); char time_buf[26]; - strftime(time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr); - fn->time_stamp_(time_buf); + strftime( time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr ); + fn->time_stamp_( time_buf ); //output the values to the file - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteHeaderInstanceFileDescription(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) { // Get the FileDescription instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Description"); - if(se == ENTITY_NULL) { + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Description" ); + if( se == ENTITY_NULL ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = (SDAI_Application_instance *)HeaderDefaultFileDescription(); + se = ( SDAI_Application_instance * )HeaderDefaultFileDescription(); } - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteHeaderInstanceFileSchema(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) { // Get the FileName instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Schema"); - if(se == ENTITY_NULL) { + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Schema" ); + if( se == ENTITY_NULL ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = (SDAI_Application_instance *) HeaderDefaultFileSchema(); + se = ( SDAI_Application_instance * ) HeaderDefaultFileSchema(); } - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteData(ostream &out, int writeComments) -{ +void STEPfile::WriteData( ostream & out, int writeComments ) { _oFileInstsWritten = 0; std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - instances().GetMgrNode(i)->GetApplication_instance()->STEPwrite(out, currSch.c_str(), writeComments); + for( int i = 0; i < n; ++i ) { + instances().GetMgrNode( i )->GetApplication_instance()->STEPwrite( out, currSch.c_str(), writeComments ); _oFileInstsWritten++; } out << "ENDSEC;\n"; } -void STEPfile::WriteValuePairsData(ostream &out, int writeComments, int mixedCase) -{ +void STEPfile::WriteValuePairsData( ostream & out, int writeComments, int mixedCase ) { std::string currSch = schemaName(); int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - instances().GetMgrNode(i)->GetApplication_instance()->WriteValuePairs(out, currSch.c_str(), writeComments, mixedCase); + for( int i = 0; i < n; ++i ) { + instances().GetMgrNode( i )->GetApplication_instance()->WriteValuePairs( out, currSch.c_str(), writeComments, mixedCase ); } } -Severity STEPfile::AppendFile(istream *in, bool useTechCor) -{ +Severity STEPfile::AppendFile( istream * in, bool useTechCor ) { Severity rval = SEVERITY_NULL; char errbuf[BUFSIZ]; SetFileIdIncrement(); int total_insts = 0, valid_insts = 0; - ReadTokenSeparator(*in); - std::string keywd = GetKeyword(*in, "; #", _error); + ReadTokenSeparator( *in ); + std::string keywd = GetKeyword( *in, "; #", _error ); // get the delimiter off the istream char c; - in->get(c); - - if(!strncmp(const_cast(keywd.c_str()), "ISO-10303-21", - strlen(const_cast(keywd.c_str())))) { - SetFileType(VERSION_CURRENT); - } else if(!strncmp(const_cast(keywd.c_str()), "STEP_WORKING_SESSION", - strlen(const_cast(keywd.c_str())))) { - if(_fileType != WORKING_SESSION) { + in->get( c ); + + if( !strncmp( const_cast( keywd.c_str() ), "ISO-10303-21", + strlen( const_cast( keywd.c_str() ) ) ) ) { + SetFileType( VERSION_CURRENT ); + } else if( !strncmp( const_cast( keywd.c_str() ), "STEP_WORKING_SESSION", + strlen( const_cast( keywd.c_str() ) ) ) ) { + if( _fileType != WORKING_SESSION ) { _error.AppendToUserMsg( - "Warning: Reading in file as Working Session file.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + "Warning: Reading in file as Working Session file.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - SetFileType(WORKING_SESSION); + SetFileType( WORKING_SESSION ); } else { - sprintf(errbuf, - "Faulty input at beginning of file. \"ISO-10303-21;\" or" - " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", - ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); - _error.AppendToUserMsg(errbuf); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf( errbuf, + "Faulty input at beginning of file. \"ISO-10303-21;\" or" + " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", + ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); + _error.AppendToUserMsg( errbuf ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } - cout << "Reading Data from " << ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str()) << "...\n"; + cout << "Reading Data from " << ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) << "...\n"; // Read header - rval = ReadHeader(*in); + rval = ReadHeader( *in ); cout << "\nHEADER read:"; - if(rval < SEVERITY_WARNING) { - sprintf(errbuf, - "Error: non-recoverable error in reading header section. " - "There were %d errors encountered. Rest of file is ignored.\n", - _errorCount); - _error.AppendToUserMsg(errbuf); + if( rval < SEVERITY_WARNING ) { + sprintf( errbuf, + "Error: non-recoverable error in reading header section. " + "There were %d errors encountered. Rest of file is ignored.\n", + _errorCount ); + _error.AppendToUserMsg( errbuf ); return rval; - } else if(rval != SEVERITY_NULL) { - sprintf(errbuf, " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); + } else if( rval != SEVERITY_NULL ) { + sprintf( errbuf, " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); cout << errbuf; } else { cout << endl; } - if(!FindDataSection(*in)) { - _error.AppendToUserMsg("Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n"); + if( !FindDataSection( *in ) ) { + _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n" ); return SEVERITY_INPUT_ERROR; } // PASS 1 _errorCount = 0; - total_insts = ReadData1(*in); + total_insts = ReadData1( *in ); cout << "\nFIRST PASS complete: " << total_insts << " instances created.\n"; - sprintf(errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); + sprintf( errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); cout << errbuf; // PASS 2 @@ -1716,143 +1682,140 @@ Severity STEPfile::AppendFile(istream *in, bool useTechCor) // reset the error count so you're not counting things twice: _errorCount = 0; - istream *in2; - if(!((in2 = OpenInputFile()) && (in2 -> good()))) { + istream * in2; + if( !( ( in2 = OpenInputFile() ) && ( in2 -> good() ) ) ) { // if the stream is not readable, there's an error - _error.AppendToUserMsg("Cannot open file for 2nd pass -- No data read.\n"); - CloseInputFile(in2); + _error.AppendToUserMsg( "Cannot open file for 2nd pass -- No data read.\n" ); + CloseInputFile( in2 ); return SEVERITY_INPUT_ERROR; } - if(!FindDataSection(*in2)) { - _error.AppendToUserMsg("Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n"); - CloseInputFile(in2); + if( !FindDataSection( *in2 ) ) { + _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n" ); + CloseInputFile( in2 ); return SEVERITY_INPUT_ERROR; } - switch(_fileType) { + switch( _fileType ) { case VERSION_CURRENT: case VERSION_UNKNOWN: case WORKING_SESSION: - valid_insts = ReadData2(*in2, useTechCor); + valid_insts = ReadData2( *in2, useTechCor ); break; default: - _error.AppendToUserMsg("STEPfile::AppendFile: STEP file version set to unrecognized value.\n"); - CloseInputFile(in2); + _error.AppendToUserMsg( "STEPfile::AppendFile: STEP file version set to unrecognized value.\n" ); + CloseInputFile( in2 ); return SEVERITY_BUG; } //check for "ENDSEC;" - ReadTokenSeparator(*in2); - if(total_insts != valid_insts) { - sprintf(errbuf, "%d invalid instances in file: %s\n", - total_insts - valid_insts, ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); - _error.AppendToUserMsg(errbuf); - CloseInputFile(in2); - return _error.GreaterSeverity(SEVERITY_WARNING); + ReadTokenSeparator( *in2 ); + if( total_insts != valid_insts ) { + sprintf( errbuf, "%d invalid instances in file: %s\n", + total_insts - valid_insts, ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); + _error.AppendToUserMsg( errbuf ); + CloseInputFile( in2 ); + return _error.GreaterSeverity( SEVERITY_WARNING ); } cout << "\nSECOND PASS complete: " << valid_insts << " instances valid.\n"; - sprintf(errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); - _error.AppendToUserMsg(errbuf); + sprintf( errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); + _error.AppendToUserMsg( errbuf ); cout << errbuf; //check for "ENDSTEP;" || "END-ISO-10303-21;" - if(in2 -> good()) { - ReadTokenSeparator(*in2); - keywd = GetKeyword(*in2, ";", _error); + if( in2 -> good() ) { + ReadTokenSeparator( *in2 ); + keywd = GetKeyword( *in2, ";", _error ); //yank the ";" from the istream //if (';' == in2->peek()) in2->get(); char ch; - in2->get(ch); - if(ch != ';') { + in2->get( ch ); + if( ch != ';' ) { std::cerr << __FILE__ << ":" << __LINE__ << " - Expected ';' at Part 21 EOF, found '" << c << "'." << std::endl; } } - if((!keywd.compare(0, keywd.size(), END_FILE_DELIM)) || !(in2 -> good())) { - _error.AppendToUserMsg(END_FILE_DELIM); - _error.AppendToUserMsg(" missing at end of file.\n"); - CloseInputFile(in2); - return _error.GreaterSeverity(SEVERITY_WARNING); + if( ( !keywd.compare( 0, keywd.size(), END_FILE_DELIM ) ) || !( in2 -> good() ) ) { + _error.AppendToUserMsg( END_FILE_DELIM ); + _error.AppendToUserMsg( " missing at end of file.\n" ); + CloseInputFile( in2 ); + return _error.GreaterSeverity( SEVERITY_WARNING ); } - CloseInputFile(in2); + CloseInputFile( in2 ); cout << "Finished reading file.\n\n"; return SEVERITY_NULL; } -Severity STEPfile::WriteWorkingFile(ostream &out, int clearError, int writeComments) -{ - SetFileType(WORKING_SESSION); - if(clearError) { +Severity STEPfile::WriteWorkingFile( ostream & out, int clearError, int writeComments ) { + SetFileType( WORKING_SESSION ); + if( clearError ) { _error.ClearErrorMsg(); } - if(instances().VerifyInstances(_error) < SEVERITY_INCOMPLETE) { - _error.AppendToUserMsg("WARNING: some invalid instances written to working session file. Data may have been lost."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( instances().VerifyInstances( _error ) < SEVERITY_INCOMPLETE ) { + _error.AppendToUserMsg( "WARNING: some invalid instances written to working session file. Data may have been lost." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); } out << FILE_DELIM << "\n"; - WriteHeader(out); + WriteHeader( out ); - WriteWorkingData(out, writeComments); + WriteWorkingData( out, writeComments ); out << END_FILE_DELIM << "\n"; SetFileType(); return _error.severity(); } -Severity STEPfile::WriteWorkingFile(const std::string filename, int clearError, - int writeComments) -{ - if(clearError) { +Severity STEPfile::WriteWorkingFile( const std::string filename, int clearError, + int writeComments ) { + if( clearError ) { _error.ClearErrorMsg(); } - ostream *out = OpenOutputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { + ostream * out = OpenOutputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } - Severity rval = WriteWorkingFile(*out, 0, writeComments); - CloseOutputFile(out); + Severity rval = WriteWorkingFile( *out, 0, writeComments ); + CloseOutputFile( out ); return rval; } -void STEPfile::WriteWorkingData(ostream &out, int writeComments) -{ +void STEPfile::WriteWorkingData( ostream & out, int writeComments ) { std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - switch(instances().GetMgrNode(i)->CurrState()) { + for( int i = 0; i < n; ++i ) { + switch( instances().GetMgrNode( i )->CurrState() ) { case deleteSE: out << wsDelete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case completeSE: out << wsSaveComplete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case incompleteSE: out << wsSaveIncomplete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case newSE: out << wsNew; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case noStateSE: - _error.AppendToUserMsg("no state information for this node\n"); + _error.AppendToUserMsg( "no state information for this node\n" ); break; } } @@ -1870,19 +1833,18 @@ void STEPfile::WriteWorkingData(ostream &out, int writeComments) The STEPfile's error descriptor is set no lower than SEVERITY_WARNING. */ -Severity STEPfile::AppendEntityErrorMsg(ErrorDescriptor *e) -{ - ErrorDescriptor *ed = e; +Severity STEPfile::AppendEntityErrorMsg( ErrorDescriptor * e ) { + ErrorDescriptor * ed = e; Severity sev = ed->severity(); - if((sev < SEVERITY_MAX) || (sev > SEVERITY_NULL)) { + if( ( sev < SEVERITY_MAX ) || ( sev > SEVERITY_NULL ) ) { //ERROR: something wrong with ErrorDescriptor - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_BUG; } - switch(sev) { + switch( sev ) { case SEVERITY_NULL: return SEVERITY_NULL; @@ -1890,14 +1852,14 @@ Severity STEPfile::AppendEntityErrorMsg(ErrorDescriptor *e) cerr << e->DetailMsg(); e->ClearErrorMsg(); - if(sev < SEVERITY_USERMSG) { + if( sev < SEVERITY_USERMSG ) { ++_errorCount; } - if(sev < SEVERITY_WARNING) { + if( sev < SEVERITY_WARNING ) { sev = SEVERITY_WARNING; } - _error.GreaterSeverity(sev); + _error.GreaterSeverity( sev ); return sev; } } diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index dc41050dc..37c7d20bc 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -35,32 +35,29 @@ enum FileTypeCode { WORKING_SESSION = 2 }; -class SC_EDITOR_EXPORT STEPfile -{ +class SC_EDITOR_EXPORT STEPfile { protected: //data members - InstMgr &_instances; - Registry &_reg; + InstMgr & _instances; + Registry & _reg; - InstMgr &instances() - { + InstMgr & instances() { return _instances; } - Registry ®() - { + Registry & reg() { return _reg; } int _fileIdIncr; ///< Increment value to be added to FileId Numbers on input //header information - InstMgr *_headerInstances; - Registry *_headerRegistry; + InstMgr * _headerInstances; + Registry * _headerRegistry; int _headerId; ///< STEPfile_id given to SDAI_Application_instance from header section //file information - DirObj *_currentDir; + DirObj * _currentDir; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -117,147 +114,138 @@ class SC_EDITOR_EXPORT STEPfile //public access to member variables //header information - InstMgr *HeaderInstances() - { + InstMgr * HeaderInstances() { return _headerInstances; } - const Registry *HeaderRegistry() - { + const Registry * HeaderRegistry() { return _headerRegistry; } // to create header instances - SDAI_Application_instance *HeaderDefaultFileName(); - SDAI_Application_instance *HeaderDefaultFileDescription(); - SDAI_Application_instance *HeaderDefaultFileSchema(); + SDAI_Application_instance * HeaderDefaultFileName(); + SDAI_Application_instance * HeaderDefaultFileDescription(); + SDAI_Application_instance * HeaderDefaultFileSchema(); //file information - std::string FileName() const - { + std::string FileName() const { return _fileName; } - std::string SetFileName(const std::string name = ""); - std::string TruncFileName(const std::string name) const; + std::string SetFileName( const std::string name = "" ); + std::string TruncFileName( const std::string name ) const; float GetReadProgress() const; float GetWriteProgress() const; //error information - ErrorDescriptor &Error() /* const */ - { + ErrorDescriptor & Error() { /* const */ return _error; } - int ErrorCount() const - { + int ErrorCount() const { return _errorCount; } - int WarningCount() const - { + int WarningCount() const { return _warningCount; } - Severity AppendEntityErrorMsg(ErrorDescriptor *e); + Severity AppendEntityErrorMsg( ErrorDescriptor * e ); //version information - FileTypeCode FileType() const - { + FileTypeCode FileType() const { return _fileType; } - void FileType(FileTypeCode ft) - { + void FileType( FileTypeCode ft ) { _fileType = ft; } - int SetFileType(FileTypeCode ft = VERSION_CURRENT); + int SetFileType( FileTypeCode ft = VERSION_CURRENT ); //Reading and Writing - Severity ReadExchangeFile(const std::string filename = "", bool useTechCor = 1); - Severity AppendExchangeFile(const std::string filename = "", bool useTechCor = 1); + Severity ReadExchangeFile( const std::string filename = "", bool useTechCor = 1 ); + Severity AppendExchangeFile( const std::string filename = "", bool useTechCor = 1 ); - Severity ReadWorkingFile(const std::string filename = "", bool useTechCor = 1); - Severity AppendWorkingFile(const std::string filename = "", bool useTechCor = 1); + Severity ReadWorkingFile( const std::string filename = "", bool useTechCor = 1 ); + Severity AppendWorkingFile( const std::string filename = "", bool useTechCor = 1 ); - Severity AppendFile(istream *in, bool useTechCor = 1) ; + Severity AppendFile( istream * in, bool useTechCor = 1 ) ; - Severity WriteExchangeFile(ostream &out, int validate = 1, - int clearError = 1, int writeComments = 1); - Severity WriteExchangeFile(const std::string filename = "", int validate = 1, - int clearError = 1, int writeComments = 1); - Severity WriteValuePairsFile(ostream &out, int validate = 1, - int clearError = 1, - int writeComments = 1, int mixedCase = 1); + Severity WriteExchangeFile( ostream & out, int validate = 1, + int clearError = 1, int writeComments = 1 ); + Severity WriteExchangeFile( const std::string filename = "", int validate = 1, + int clearError = 1, int writeComments = 1 ); + Severity WriteValuePairsFile( ostream & out, int validate = 1, + int clearError = 1, + int writeComments = 1, int mixedCase = 1 ); - Severity WriteWorkingFile(ostream &out, int clearError = 1, - int writeComments = 1); - Severity WriteWorkingFile(const std::string filename = "", int clearError = 1, - int writeComments = 1); + Severity WriteWorkingFile( ostream & out, int clearError = 1, + int writeComments = 1 ); + Severity WriteWorkingFile( const std::string filename = "", int clearError = 1, + int writeComments = 1 ); - stateEnum EntityWfState(char c); + stateEnum EntityWfState( char c ); void Renumber(); //constructors - STEPfile(Registry &r, InstMgr &i, const std::string filename = "", bool strict = true); + STEPfile( Registry & r, InstMgr & i, const std::string filename = "", bool strict = true ); virtual ~STEPfile(); protected: //member functions std::string schemaName(); /**< Returns and copies out schema name from header instances. Called by ReadExchangeFile */ - istream *OpenInputFile(const std::string filename = ""); - void CloseInputFile(istream *in); + istream * OpenInputFile( const std::string filename = "" ); + void CloseInputFile( istream * in ); - Severity ReadHeader(istream &in); + Severity ReadHeader( istream & in ); - Severity HeaderVerifyInstances(InstMgr *im); - void HeaderMergeInstances(InstMgr *im); + Severity HeaderVerifyInstances( InstMgr * im ); + void HeaderMergeInstances( InstMgr * im ); - int HeaderId(int increment = 1); - int HeaderId(const char *nm = "\0"); + int HeaderId( int increment = 1 ); + int HeaderId( const char * nm = "\0" ); - int ReadData1(istream &in); /**< First pass, to create instances */ - int ReadData2(istream &in, bool useTechCor = true); /**< Second pass, to read instances */ + int ReadData1( istream & in ); /**< First pass, to create instances */ + int ReadData2( istream & in, bool useTechCor = true ); /**< Second pass, to read instances */ // obsolete - int ReadWorkingData1(istream &in); - int ReadWorkingData2(istream &in, bool useTechCor = true); + int ReadWorkingData1( istream & in ); + int ReadWorkingData2( istream & in, bool useTechCor = true ); - void ReadRestOfFile(istream &in); + void ReadRestOfFile( istream & in ); /// create instance - used by ReadData1() - SDAI_Application_instance *CreateInstance(istream &in, ostream &out); + SDAI_Application_instance * CreateInstance( istream & in, ostream & out ); /// create complex instance - used by CreateInstance() - SDAI_Application_instance *CreateSubSuperInstance(istream &in, int fileid, - ErrorDescriptor &); + SDAI_Application_instance * CreateSubSuperInstance( istream & in, int fileid, + ErrorDescriptor & ); // read the instance - used by ReadData2() - SDAI_Application_instance *ReadInstance(istream &in, ostream &out, - std::string &cmtStr, bool useTechCor = true); + SDAI_Application_instance * ReadInstance( istream & in, ostream & out, + std::string & cmtStr, bool useTechCor = true ); /// reading scopes are still incomplete, CreateScopeInstances and ReadScopeInstances are stubs - Severity CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist); - Severity ReadScopeInstances(istream &in); + Severity CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ); + Severity ReadScopeInstances( istream & in ); // Severity ReadSubSuperInstance(istream& in); - int FindDataSection(istream &in); - int FindHeaderSection(istream &in); + int FindDataSection( istream & in ); + int FindHeaderSection( istream & in ); // writing working session files - void WriteWorkingData(ostream &out, int writeComments = 1); + void WriteWorkingData( ostream & out, int writeComments = 1 ); //called by WriteExchangeFile - ofstream *OpenOutputFile(const std::string filename = ""); - void CloseOutputFile(ostream *out); - - void WriteHeader(ostream &out); - void WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out); - void WriteHeaderInstanceFileName(ostream &out); - void WriteHeaderInstanceFileDescription(ostream &out); - void WriteHeaderInstanceFileSchema(ostream &out); - - void WriteData(ostream &out, int writeComments = 1); - void WriteValuePairsData(ostream &out, int writeComments = 1, - int mixedCase = 1); - - int IncrementFileId(int fileid); - int FileIdIncr() - { + ofstream * OpenOutputFile( const std::string filename = "" ); + void CloseOutputFile( ostream * out ); + + void WriteHeader( ostream & out ); + void WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ); + void WriteHeaderInstanceFileName( ostream & out ); + void WriteHeaderInstanceFileDescription( ostream & out ); + void WriteHeaderInstanceFileSchema( ostream & out ); + + void WriteData( ostream & out, int writeComments = 1 ); + void WriteValuePairsData( ostream & out, int writeComments = 1, + int mixedCase = 1 ); + + int IncrementFileId( int fileid ); + int FileIdIncr() { return _fileIdIncr; } void SetFileIdIncrement(); diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 60d7c540e..0c5b937e0 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -19,30 +19,28 @@ #include #include "sc_memmgr.h" -extern void HeaderSchemaInit(Registry ®); +extern void HeaderSchemaInit( Registry & reg ); //To Be inline functions //constructor & destructor -STEPfile::STEPfile(Registry &r, InstMgr &i, const std::string filename, bool strict) : - _instances(i), _reg(r), _fileIdIncr(0), _headerId(0), _iFileSize(0), - _iFileCurrentPosition(0), _iFileStage1Done(false), _oFileInstsWritten(0), - _entsNotCreated(0), _entsInvalid(0), _entsIncomplete(0), _entsWarning(0), - _errorCount(0), _warningCount(0), _maxErrorCount(100000), _strict(strict) -{ - SetFileType(VERSION_CURRENT); +STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict ) : + _instances( i ), _reg( r ), _fileIdIncr( 0 ), _headerId( 0 ), _iFileSize( 0 ), + _iFileCurrentPosition( 0 ), _iFileStage1Done( false ), _oFileInstsWritten( 0 ), + _entsNotCreated( 0 ), _entsInvalid( 0 ), _entsIncomplete( 0 ), _entsWarning( 0 ), + _errorCount( 0 ), _warningCount( 0 ), _maxErrorCount( 100000 ), _strict( strict ) { + SetFileType( VERSION_CURRENT ); SetFileIdIncrement(); - _currentDir = new DirObj(""); - _headerRegistry = new Registry(HeaderSchemaInit); + _currentDir = new DirObj( "" ); + _headerRegistry = new Registry( HeaderSchemaInit ); _headerInstances = new InstMgr; - if(!filename.empty()) { - ReadExchangeFile(filename); + if( !filename.empty() ) { + ReadExchangeFile( filename ); } } -STEPfile::~STEPfile() -{ +STEPfile::~STEPfile() { delete _currentDir; delete _headerRegistry; @@ -51,23 +49,22 @@ STEPfile::~STEPfile() delete _headerInstances; } -int STEPfile::SetFileType(FileTypeCode ft) -{ - FileType(ft); +int STEPfile::SetFileType( FileTypeCode ft ) { + FileType( ft ); - switch(_fileType) { - case(VERSION_OLD): + switch( _fileType ) { + case( VERSION_OLD ): ENTITY_NAME_DELIM = '@'; FILE_DELIM = "STEP;"; END_FILE_DELIM = "ENDSTEP;"; break; - case(VERSION_UNKNOWN): - case(VERSION_CURRENT): + case( VERSION_UNKNOWN ): + case( VERSION_CURRENT ): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "ISO-10303-21;"; END_FILE_DELIM = "END-ISO-10303-21;"; break; - case(WORKING_SESSION): + case( WORKING_SESSION ): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "STEP_WORKING_SESSION;"; END_FILE_DELIM = "END-STEP_WORKING_SESSION;"; @@ -87,142 +84,135 @@ int STEPfile::SetFileType(FileTypeCode ft) ** remove any slashes, and anything before the slash, ** from filename */ -std::string STEPfile::TruncFileName(const std::string filename) const -{ +std::string STEPfile::TruncFileName( const std::string filename ) const { #if defined(_WIN32) && !defined(__mingw32__) char slash = '\\'; #else char slash = '/'; #endif - size_t l = filename.find_last_of(slash); - if(l == std::string::npos) { + size_t l = filename.find_last_of( slash ); + if( l == std::string::npos ) { return filename; } else { - return filename.substr(l); + return filename.substr( l ); } } /******************************************************/ -Severity STEPfile::ReadExchangeFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::ReadExchangeFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } instances().ClearInstances(); - if(_headerInstances) { + if( _headerInstances ) { _headerInstances->ClearInstances(); } _headerId = 5; - Severity rval = AppendFile(in, useTechCor); - CloseInputFile(in); + Severity rval = AppendFile( in, useTechCor ); + CloseInputFile( in ); return rval; } -Severity STEPfile::AppendExchangeFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::AppendExchangeFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } - Severity rval = AppendFile(in, useTechCor); - CloseInputFile(in); + Severity rval = AppendFile( in, useTechCor ); + CloseInputFile( in ); return rval; } /******************************************************/ -Severity STEPfile::ReadWorkingFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::ReadWorkingFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } instances().ClearInstances(); _headerInstances->ClearInstances(); - SetFileType(WORKING_SESSION); + SetFileType( WORKING_SESSION ); - Severity rval = AppendFile(in, useTechCor); + Severity rval = AppendFile( in, useTechCor ); SetFileType(); - CloseInputFile(in); + CloseInputFile( in ); return rval; } -Severity STEPfile::AppendWorkingFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::AppendWorkingFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } - SetFileType(WORKING_SESSION); - Severity rval = AppendFile(in, useTechCor); + SetFileType( WORKING_SESSION ); + Severity rval = AppendFile( in, useTechCor ); SetFileType(); - CloseInputFile(in); + CloseInputFile( in ); return rval; } /******************************************************/ -istream *STEPfile::OpenInputFile(const std::string filename) -{ +istream * STEPfile::OpenInputFile( const std::string filename ) { _iFileCurrentPosition = 0; // if there's no filename to use, fail - if(filename.empty() && FileName().empty()) { - _error.AppendToUserMsg("Unable to open file for input. No current file name.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return(0); + if( filename.empty() && FileName().empty() ) { + _error.AppendToUserMsg( "Unable to open file for input. No current file name.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return( 0 ); } else { - if(SetFileName(filename).empty() && (filename.compare("-") != 0)) { + if( SetFileName( filename ).empty() && ( filename.compare( "-" ) != 0 ) ) { char msg[BUFSIZ]; - sprintf(msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return(0); + sprintf( msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return( 0 ); } } - std::istream *in; + std::istream * in; - if(filename.compare("-") == 0) { + if( filename.compare( "-" ) == 0 ) { in = &std::cin; } else { - in = new ifstream(FileName().c_str()); + in = new ifstream( FileName().c_str() ); } - if(!in || !(in -> good())) { + if( !in || !( in -> good() ) ) { char msg[BUFSIZ]; - sprintf(msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return (0); + sprintf( msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return ( 0 ); } //check size of file - in->seekg(0, std::ifstream::end); + in->seekg( 0, std::ifstream::end ); _iFileSize = in->tellg(); - in->seekg(0, std::ifstream::beg); + in->seekg( 0, std::ifstream::beg ); return in; } /******************************************************/ -void STEPfile::CloseInputFile(istream *in) -{ - if(in != &std::cin) { +void STEPfile::CloseInputFile( istream * in ) { + if (in != &std::cin) { delete in; } @@ -233,53 +223,49 @@ void STEPfile::CloseInputFile(istream *in) /******************************************************/ -ofstream *STEPfile::OpenOutputFile(std::string filename) -{ - if(filename.empty()) { - if(FileName().empty()) { - _error.AppendToUserMsg("No current file name.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); +ofstream * STEPfile::OpenOutputFile( std::string filename ) { + if( filename.empty() ) { + if( FileName().empty() ) { + _error.AppendToUserMsg( "No current file name.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } else { - if(SetFileName(filename).empty()) { + if( SetFileName( filename ).empty() ) { char msg[BUFSIZ]; - sprintf(msg, "can't find file: %s\nFile not written.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf( msg, "can't find file: %s\nFile not written.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } - if(_currentDir->FileExists(TruncFileName(filename))) { + if( _currentDir->FileExists( TruncFileName( filename ) ) ) { MakeBackupFile(); } - ofstream *out = new ofstream(filename.c_str()); - if(!out) { - _error.AppendToUserMsg("unable to open file for output\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + ofstream * out = new ofstream( filename.c_str() ); + if( !out ) { + _error.AppendToUserMsg( "unable to open file for output\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } _oFileInstsWritten = 0; return out; } -void STEPfile::CloseOutputFile(ostream *out) -{ +void STEPfile::CloseOutputFile( ostream * out ) { _oFileInstsWritten = 0; delete out; } /******************************************************/ -int STEPfile::IncrementFileId(int fileid) -{ - return (fileid + FileIdIncr()); +int STEPfile::IncrementFileId( int fileid ) { + return ( fileid + FileIdIncr() ); } -void STEPfile::SetFileIdIncrement() -{ - if(instances().MaxFileId() < 0) { +void STEPfile::SetFileIdIncrement() { + if( instances().MaxFileId() < 0 ) { _fileIdIncr = 0; } else { - _fileIdIncr = (int)((ceil((instances().MaxFileId() + 99.0) / 1000.0) + 1.0) * 1000.0); + _fileIdIncr = ( int )( ( ceil( ( instances().MaxFileId() + 99.0 ) / 1000.0 ) + 1.0 ) * 1000.0 ); } } @@ -289,43 +275,42 @@ void STEPfile::SetFileIdIncrement() * is no header section or no value for file schema, NULL is returned and * schName is unset. */ -std::string STEPfile::schemaName() -{ - SdaiFile_schema *fs; +std::string STEPfile::schemaName() { + SdaiFile_schema * fs; std::string schName; - STEPnode *n; + STEPnode * n; - if(_headerInstances == NULL) { + if( _headerInstances == NULL ) { return schName; } - fs = (SdaiFile_schema *)_headerInstances->GetApplication_instance("File_Schema"); - if(fs == ENTITY_NULL) { + fs = ( SdaiFile_schema * )_headerInstances->GetApplication_instance( "File_Schema" ); + if( fs == ENTITY_NULL ) { return schName; } - n = (STEPnode *)fs->schema_identifiers_()->GetHead(); + n = ( STEPnode * )fs->schema_identifiers_()->GetHead(); // (take the first one) - if(n == NULL) { + if( n == NULL ) { return schName; } - n->STEPwrite(schName); - if(schName.empty() || schName[0] == '$') { + n->STEPwrite( schName ); + if( schName.empty() || schName[0] == '$' ) { schName.clear(); return schName; - } else if(schName[0] == '\0') { + } else if( schName[0] == '\0' ) { //probably never - it seems that putting null in std::string takes effort - _error.AppendToUserMsg("In STEPfile::schemaName: schName contains \\0 - it should be empty."); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "In STEPfile::schemaName: schName contains \\0 - it should be empty." ); + _error.GreaterSeverity( SEVERITY_WARNING ); schName.clear(); return schName; } - if(schName[ schName.length() - 1 ] == '\'') { - schName = schName.substr(1, schName.length() - 2); + if( schName[ schName.length() - 1 ] == '\'' ) { + schName = schName.substr( 1, schName.length() - 2 ); } else { - _error.AppendToUserMsg("In STEPfile::schemaName: schName was truncated."); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "In STEPfile::schemaName: schName was truncated." ); + _error.GreaterSeverity( SEVERITY_WARNING ); - schName = schName.substr(1, schName.length() - 1); + schName = schName.substr( 1, schName.length() - 1 ); } return schName; } diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index 7b642a25c..cea95b42f 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -6,7 +6,7 @@ #ifdef SC_LOGGING #include -extern ofstream *logStream; +extern ofstream * logStream; #define SCLLOGFILE "scl.log" #endif @@ -15,93 +15,88 @@ extern ofstream *logStream; #include #include "sc_memmgr.h" -Schema *s_header_section_schema = 0; +Schema * s_header_section_schema = 0; /* ************** TYPES */ -TypeDescriptor *header_section_schemat_time_stamp_text; -TypeDescriptor *header_section_schemat_section_name; -TypeDescriptor *header_section_schemat_context_name; -TypeDescriptor *header_section_schemat_schema_name; -TypeDescriptor *header_section_schemat_language_name; -TypeDescriptor *header_section_schemat_exchange_structure_identifier; +TypeDescriptor * header_section_schemat_time_stamp_text; +TypeDescriptor * header_section_schemat_section_name; +TypeDescriptor * header_section_schemat_context_name; +TypeDescriptor * header_section_schemat_schema_name; +TypeDescriptor * header_section_schemat_language_name; +TypeDescriptor * header_section_schemat_exchange_structure_identifier; /* ************** ENTITIES */ ///////// ENTITY section_language -EntityDescriptor *header_section_schemae_section_language = 0; -AttrDescriptor *a_0section = 0; -AttrDescriptor *a_1default_language = 0; -SdaiSection_language::SdaiSection_language() -{ +EntityDescriptor * header_section_schemae_section_language = 0; +AttrDescriptor * a_0section = 0; +AttrDescriptor * a_1default_language = 0; +SdaiSection_language::SdaiSection_language( ) { /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute *a = new STEPattribute(*a_0section, &_section); + STEPattribute * a = new STEPattribute( *a_0section, &_section ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_1default_language, &_default_language); + attributes.push( a ); + a = new STEPattribute( *a_1default_language, &_default_language ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiSection_language::SdaiSection_language(SdaiSection_language &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiSection_language::SdaiSection_language( SdaiSection_language & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiSection_language::~SdaiSection_language() { } -SdaiSection_language::SdaiSection_language(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiSection_language::SdaiSection_language( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute *a = new STEPattribute(*a_0section, &_section); + STEPattribute * a = new STEPattribute( *a_0section, &_section ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_1default_language, &_default_language); + a = new STEPattribute( *a_1default_language, &_default_language ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSection_name -SdaiSection_language::section_() const -{ - return (const SdaiSection_name) _section; +SdaiSection_language::section_() const { + return ( const SdaiSection_name ) _section; } void -SdaiSection_language::section_(const SdaiSection_name x) +SdaiSection_language::section_( const SdaiSection_name x ) { _section = x; } const SdaiLanguage_name -SdaiSection_language::default_language_() const -{ - return (const SdaiLanguage_name) _default_language; +SdaiSection_language::default_language_() const { + return ( const SdaiLanguage_name ) _default_language; } void -SdaiSection_language::default_language_(const SdaiLanguage_name x) +SdaiSection_language::default_language_( const SdaiLanguage_name x ) { _default_language = x; @@ -112,109 +107,103 @@ SdaiSection_language::default_language_(const SdaiLanguage_name x) ///////// ENTITY file_population -EntityDescriptor *header_section_schemae_file_population = 0; -AttrDescriptor *a_2governing_schema = 0; -AttrDescriptor *a_3determination_method = 0; -AttrDescriptor *a_4governed_sections = 0; -SdaiFile_population::SdaiFile_population() -{ +EntityDescriptor * header_section_schemae_file_population = 0; +AttrDescriptor * a_2governing_schema = 0; +AttrDescriptor * a_3determination_method = 0; +AttrDescriptor * a_4governed_sections = 0; +SdaiFile_population::SdaiFile_population( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); + STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_3determination_method, &_determination_method); + attributes.push( a ); + a = new STEPattribute( *a_3determination_method, &_determination_method ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_4governed_sections, &_governed_sections); + attributes.push( a ); + a = new STEPattribute( *a_4governed_sections, &_governed_sections ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_population::SdaiFile_population(SdaiFile_population &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_population::SdaiFile_population( SdaiFile_population & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_population::~SdaiFile_population() { } -SdaiFile_population::SdaiFile_population(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); + STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_3determination_method, &_determination_method); + a = new STEPattribute( *a_3determination_method, &_determination_method ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_4governed_sections, &_governed_sections); + a = new STEPattribute( *a_4governed_sections, &_governed_sections ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSchema_name -SdaiFile_population::governing_schema_() const -{ - return (const SdaiSchema_name) _governing_schema; +SdaiFile_population::governing_schema_() const { + return ( const SdaiSchema_name ) _governing_schema; } void -SdaiFile_population::governing_schema_(const SdaiSchema_name x) +SdaiFile_population::governing_schema_( const SdaiSchema_name x ) { _governing_schema = x; } const SdaiExchange_structure_identifier -SdaiFile_population::determination_method_() const -{ - return (const SdaiExchange_structure_identifier) _determination_method; +SdaiFile_population::determination_method_() const { + return ( const SdaiExchange_structure_identifier ) _determination_method; } void -SdaiFile_population::determination_method_(const SdaiExchange_structure_identifier x) +SdaiFile_population::determination_method_( const SdaiExchange_structure_identifier x ) { _determination_method = x; } StringAggregate_ptr -SdaiFile_population::governed_sections_() const -{ - return (StringAggregate_ptr) &_governed_sections; +SdaiFile_population::governed_sections_() const { + return ( StringAggregate_ptr ) &_governed_sections; } void -SdaiFile_population::governed_sections_(const StringAggregate_ptr x) +SdaiFile_population::governed_sections_( const StringAggregate_ptr x ) { - _governed_sections.ShallowCopy(*x); + _governed_sections.ShallowCopy( *x ); } ///////// END_ENTITY file_population @@ -222,214 +211,204 @@ SdaiFile_population::governed_sections_(const StringAggregate_ptr x) ///////// ENTITY file_name -EntityDescriptor *header_section_schemae_file_name = 0; -AttrDescriptor *a_5name = 0; -AttrDescriptor *a_6time_stamp = 0; -AttrDescriptor *a_7author = 0; -AttrDescriptor *a_8organization = 0; -AttrDescriptor *a_9preprocessor_version = 0; -AttrDescriptor *a_10originating_system = 0; -AttrDescriptor *a_11authorization = 0; -SdaiFile_name::SdaiFile_name() -{ +EntityDescriptor * header_section_schemae_file_name = 0; +AttrDescriptor * a_5name = 0; +AttrDescriptor * a_6time_stamp = 0; +AttrDescriptor * a_7author = 0; +AttrDescriptor * a_8organization = 0; +AttrDescriptor * a_9preprocessor_version = 0; +AttrDescriptor * a_10originating_system = 0; +AttrDescriptor * a_11authorization = 0; +SdaiFile_name::SdaiFile_name( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute *a = new STEPattribute(*a_5name, &_name); + STEPattribute * a = new STEPattribute( *a_5name, &_name ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_6time_stamp, &_time_stamp); + attributes.push( a ); + a = new STEPattribute( *a_6time_stamp, &_time_stamp ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_7author, &_author); + attributes.push( a ); + a = new STEPattribute( *a_7author, &_author ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_8organization, &_organization); + attributes.push( a ); + a = new STEPattribute( *a_8organization, &_organization ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); + attributes.push( a ); + a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_10originating_system, &_originating_system); + attributes.push( a ); + a = new STEPattribute( *a_10originating_system, &_originating_system ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_11authorization, &_authorization); + attributes.push( a ); + a = new STEPattribute( *a_11authorization, &_authorization ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_name::SdaiFile_name(SdaiFile_name &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_name::SdaiFile_name( SdaiFile_name & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_name::~SdaiFile_name() { } -SdaiFile_name::SdaiFile_name(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute *a = new STEPattribute(*a_5name, &_name); + STEPattribute * a = new STEPattribute( *a_5name, &_name ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_6time_stamp, &_time_stamp); + a = new STEPattribute( *a_6time_stamp, &_time_stamp ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_7author, &_author); + a = new STEPattribute( *a_7author, &_author ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_8organization, &_organization); + a = new STEPattribute( *a_8organization, &_organization ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); + a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_10originating_system, &_originating_system); + a = new STEPattribute( *a_10originating_system, &_originating_system ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_11authorization, &_authorization); + a = new STEPattribute( *a_11authorization, &_authorization ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SDAI_String -SdaiFile_name::name_() const -{ - return (const SDAI_String) _name; +SdaiFile_name::name_() const { + return ( const SDAI_String ) _name; } void -SdaiFile_name::name_(const SDAI_String x) +SdaiFile_name::name_( const SDAI_String x ) { _name = x; } const SdaiTime_stamp_text -SdaiFile_name::time_stamp_() const -{ - return (const SdaiTime_stamp_text) _time_stamp; +SdaiFile_name::time_stamp_() const { + return ( const SdaiTime_stamp_text ) _time_stamp; } void -SdaiFile_name::time_stamp_(const SdaiTime_stamp_text x) +SdaiFile_name::time_stamp_( const SdaiTime_stamp_text x ) { _time_stamp = x; } StringAggregate_ptr -SdaiFile_name::author_() const -{ - return (StringAggregate_ptr) &_author; +SdaiFile_name::author_() const { + return ( StringAggregate_ptr ) &_author; } void -SdaiFile_name::author_(const StringAggregate_ptr x) +SdaiFile_name::author_( const StringAggregate_ptr x ) { - _author.ShallowCopy(*x); + _author.ShallowCopy( *x ); } StringAggregate_ptr -SdaiFile_name::organization_() const -{ - return (StringAggregate_ptr) &_organization; +SdaiFile_name::organization_() const { + return ( StringAggregate_ptr ) &_organization; } void -SdaiFile_name::organization_(const StringAggregate_ptr x) +SdaiFile_name::organization_( const StringAggregate_ptr x ) { - _organization.ShallowCopy(*x); + _organization.ShallowCopy( *x ); } const SDAI_String -SdaiFile_name::preprocessor_version_() const -{ - return (const SDAI_String) _preprocessor_version; +SdaiFile_name::preprocessor_version_() const { + return ( const SDAI_String ) _preprocessor_version; } void -SdaiFile_name::preprocessor_version_(const SDAI_String x) +SdaiFile_name::preprocessor_version_( const SDAI_String x ) { _preprocessor_version = x; } const SDAI_String -SdaiFile_name::originating_system_() const -{ - return (const SDAI_String) _originating_system; +SdaiFile_name::originating_system_() const { + return ( const SDAI_String ) _originating_system; } void -SdaiFile_name::originating_system_(const SDAI_String x) +SdaiFile_name::originating_system_( const SDAI_String x ) { _originating_system = x; } const SDAI_String -SdaiFile_name::authorization_() const -{ - return (const SDAI_String) _authorization; +SdaiFile_name::authorization_() const { + return ( const SDAI_String ) _authorization; } void -SdaiFile_name::authorization_(const SDAI_String x) +SdaiFile_name::authorization_( const SDAI_String x ) { _authorization = x; @@ -440,82 +419,77 @@ SdaiFile_name::authorization_(const SDAI_String x) ///////// ENTITY section_context -EntityDescriptor *header_section_schemae_section_context = 0; -AttrDescriptor *a_12section = 0; -AttrDescriptor *a_13context_identifiers = 0; -SdaiSection_context::SdaiSection_context() -{ +EntityDescriptor * header_section_schemae_section_context = 0; +AttrDescriptor * a_12section = 0; +AttrDescriptor * a_13context_identifiers = 0; +SdaiSection_context::SdaiSection_context( ) { /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute *a = new STEPattribute(*a_12section, &_section); + STEPattribute * a = new STEPattribute( *a_12section, &_section ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); + attributes.push( a ); + a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiSection_context::SdaiSection_context(SdaiSection_context &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiSection_context::SdaiSection_context( SdaiSection_context & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiSection_context::~SdaiSection_context() { } -SdaiSection_context::SdaiSection_context(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiSection_context::SdaiSection_context( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute *a = new STEPattribute(*a_12section, &_section); + STEPattribute * a = new STEPattribute( *a_12section, &_section ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); + a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSection_name -SdaiSection_context::section_() const -{ - return (const SdaiSection_name) _section; +SdaiSection_context::section_() const { + return ( const SdaiSection_name ) _section; } void -SdaiSection_context::section_(const SdaiSection_name x) +SdaiSection_context::section_( const SdaiSection_name x ) { _section = x; } StringAggregate_ptr -SdaiSection_context::context_identifiers_() const -{ - return (StringAggregate_ptr) &_context_identifiers; +SdaiSection_context::context_identifiers_() const { + return ( StringAggregate_ptr ) &_context_identifiers; } void -SdaiSection_context::context_identifiers_(const StringAggregate_ptr x) +SdaiSection_context::context_identifiers_( const StringAggregate_ptr x ) { - _context_identifiers.ShallowCopy(*x); + _context_identifiers.ShallowCopy( *x ); } ///////// END_ENTITY section_context @@ -523,79 +497,74 @@ SdaiSection_context::context_identifiers_(const StringAggregate_ptr x) ///////// ENTITY file_description -EntityDescriptor *header_section_schemae_file_description = 0; -AttrDescriptor *a_14description = 0; -AttrDescriptor *a_15implementation_level = 0; -SdaiFile_description::SdaiFile_description() -{ +EntityDescriptor * header_section_schemae_file_description = 0; +AttrDescriptor * a_14description = 0; +AttrDescriptor * a_15implementation_level = 0; +SdaiFile_description::SdaiFile_description( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute *a = new STEPattribute(*a_14description, &_description); + STEPattribute * a = new STEPattribute( *a_14description, &_description ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_15implementation_level, &_implementation_level); + attributes.push( a ); + a = new STEPattribute( *a_15implementation_level, &_implementation_level ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_description::SdaiFile_description(SdaiFile_description &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_description::SdaiFile_description( SdaiFile_description & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_description::~SdaiFile_description() {} -SdaiFile_description::SdaiFile_description(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_description::SdaiFile_description( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute *a = new STEPattribute(*a_14description, &_description); + STEPattribute * a = new STEPattribute( *a_14description, &_description ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_15implementation_level, &_implementation_level); + a = new STEPattribute( *a_15implementation_level, &_implementation_level ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } StringAggregate_ptr -SdaiFile_description::description_() const -{ - return (StringAggregate_ptr) &_description; +SdaiFile_description::description_() const { + return ( StringAggregate_ptr ) &_description; } void -SdaiFile_description::description_(const StringAggregate_ptr x) +SdaiFile_description::description_( const StringAggregate_ptr x ) { - _description.ShallowCopy(*x); + _description.ShallowCopy( *x ); } const SDAI_String -SdaiFile_description::implementation_level_() const -{ - return (const SDAI_String) _implementation_level; +SdaiFile_description::implementation_level_() const { + return ( const SDAI_String ) _implementation_level; } void -SdaiFile_description::implementation_level_(const SDAI_String x) +SdaiFile_description::implementation_level_( const SDAI_String x ) { _implementation_level = x; @@ -606,122 +575,110 @@ SdaiFile_description::implementation_level_(const SDAI_String x) ///////// ENTITY file_schema -EntityDescriptor *header_section_schemae_file_schema = 0; -AttrDescriptor *a_16schema_identifiers = 0; -SdaiFile_schema::SdaiFile_schema() -{ +EntityDescriptor * header_section_schemae_file_schema = 0; +AttrDescriptor * a_16schema_identifiers = 0; +SdaiFile_schema::SdaiFile_schema( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); + STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_schema::SdaiFile_schema(SdaiFile_schema &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_schema::SdaiFile_schema( SdaiFile_schema & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_schema::~SdaiFile_schema() { } -SdaiFile_schema::SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_schema::SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); + STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } StringAggregate_ptr -SdaiFile_schema::schema_identifiers_() const -{ - return (StringAggregate_ptr) &_schema_identifiers; +SdaiFile_schema::schema_identifiers_() const { + return ( StringAggregate_ptr ) &_schema_identifiers; } void -SdaiFile_schema::schema_identifiers_(const StringAggregate_ptr x) +SdaiFile_schema::schema_identifiers_( const StringAggregate_ptr x ) { - _schema_identifiers.ShallowCopy(*x); + _schema_identifiers.ShallowCopy( *x ); } ///////// END_ENTITY file_schema -SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() -{ +SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() { return new SdaiModel_contents_header_section_schema ; } -SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() -{ - SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0; +SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() { + SDAI_Entity_extent_ptr eep = ( SDAI_Entity_extent_ptr )0; eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_section_language); - _folders.Append(eep); + eep->definition_( header_section_schemae_section_language ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_population); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_population ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_name); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_name ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_section_context); - _folders.Append(eep); + eep->definition_( header_section_schemae_section_context ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_description); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_description ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_schema); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_schema ); + _folders.Append( eep ); } -SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() -{ - return (SdaiSection_language__set_var)((_folders.retrieve(0))->instances_()); +SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() { + return ( SdaiSection_language__set_var )( ( _folders.retrieve( 0 ) )->instances_() ); } -SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() -{ - return (SdaiFile_population__set_var)((_folders.retrieve(1))->instances_()); +SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() { + return ( SdaiFile_population__set_var )( ( _folders.retrieve( 1 ) )->instances_() ); } -SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() -{ - return (SdaiFile_name__set_var)((_folders.retrieve(2))->instances_()); +SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() { + return ( SdaiFile_name__set_var )( ( _folders.retrieve( 2 ) )->instances_() ); } -SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() -{ - return (SdaiSection_context__set_var)((_folders.retrieve(3))->instances_()); +SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() { + return ( SdaiSection_context__set_var )( ( _folders.retrieve( 3 ) )->instances_() ); } -SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() -{ - return (SdaiFile_description__set_var)((_folders.retrieve(4))->instances_()); +SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() { + return ( SdaiFile_description__set_var )( ( _folders.retrieve( 4 ) )->instances_() ); } -SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() -{ - return (SdaiFile_schema__set_var)((_folders.retrieve(5))->instances_()); +SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() { + return ( SdaiFile_schema__set_var )( ( _folders.retrieve( 5 ) )->instances_() ); } #endif diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index 30e5b9f20..7cd45d848 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -13,36 +13,33 @@ ///////// ENTITY section_language -extern SC_EDITOR_EXPORT AttrDescriptor *a_0section; -extern SC_EDITOR_EXPORT AttrDescriptor *a_1default_language; +extern SC_EDITOR_EXPORT AttrDescriptor * a_0section; +extern SC_EDITOR_EXPORT AttrDescriptor * a_1default_language; -class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance { protected: SDAI_String _section ; // OPTIONAL SDAI_String _default_language ; public: - SdaiSection_language(); - SdaiSection_language(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiSection_language(SdaiSection_language &e); + SdaiSection_language( ); + SdaiSection_language( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiSection_language( SdaiSection_language & e ); ~SdaiSection_language(); - int opcode() - { + int opcode() { return 0 ; } const SdaiSection_name section_() const; - void section_(const SdaiSection_name x); + void section_( const SdaiSection_name x ); const SdaiLanguage_name default_language_() const; - void default_language_(const SdaiLanguage_name x); + void default_language_( const SdaiLanguage_name x ); }; inline SdaiSection_language * -create_SdaiSection_language() -{ +create_SdaiSection_language() { return new SdaiSection_language ; } @@ -51,12 +48,11 @@ create_SdaiSection_language() ///////// ENTITY file_population -extern SC_EDITOR_EXPORT AttrDescriptor *a_2governing_schema; -extern SC_EDITOR_EXPORT AttrDescriptor *a_3determination_method; -extern SC_EDITOR_EXPORT AttrDescriptor *a_4governed_sections; +extern SC_EDITOR_EXPORT AttrDescriptor * a_2governing_schema; +extern SC_EDITOR_EXPORT AttrDescriptor * a_3determination_method; +extern SC_EDITOR_EXPORT AttrDescriptor * a_4governed_sections; -class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance { protected: SDAI_String _governing_schema ; SDAI_String _determination_method ; @@ -64,29 +60,27 @@ class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instanc public: - SdaiFile_population(); - SdaiFile_population(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_population(SdaiFile_population &e); + SdaiFile_population( ); + SdaiFile_population( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_population( SdaiFile_population & e ); ~SdaiFile_population(); - int opcode() - { + int opcode() { return 1 ; } const SdaiSchema_name governing_schema_() const; - void governing_schema_(const SdaiSchema_name x); + void governing_schema_( const SdaiSchema_name x ); const SdaiExchange_structure_identifier determination_method_() const; - void determination_method_(const SdaiExchange_structure_identifier x); + void determination_method_( const SdaiExchange_structure_identifier x ); StringAggregate_ptr governed_sections_() const; - void governed_sections_(const StringAggregate_ptr x); + void governed_sections_( const StringAggregate_ptr x ); }; inline SdaiFile_population * -create_SdaiFile_population() -{ +create_SdaiFile_population() { return new SdaiFile_population ; } @@ -95,16 +89,15 @@ create_SdaiFile_population() ///////// ENTITY file_name -extern AttrDescriptor *a_5name; -extern AttrDescriptor *a_6time_stamp; -extern AttrDescriptor *a_7author; -extern AttrDescriptor *a_8organization; -extern AttrDescriptor *a_9preprocessor_version; -extern AttrDescriptor *a_10originating_system; -extern AttrDescriptor *a_11authorization; +extern AttrDescriptor * a_5name; +extern AttrDescriptor * a_6time_stamp; +extern AttrDescriptor * a_7author; +extern AttrDescriptor * a_8organization; +extern AttrDescriptor * a_9preprocessor_version; +extern AttrDescriptor * a_10originating_system; +extern AttrDescriptor * a_11authorization; -class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance { protected: SDAI_String _name ; SDAI_String _time_stamp ; @@ -115,41 +108,39 @@ class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance SDAI_String _authorization ; public: - SdaiFile_name(); - SdaiFile_name(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_name(SdaiFile_name &e); + SdaiFile_name( ); + SdaiFile_name( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_name( SdaiFile_name & e ); ~SdaiFile_name(); - int opcode() - { + int opcode() { return 2 ; } const SDAI_String name_() const; - void name_(const SDAI_String x); + void name_( const SDAI_String x ); const SdaiTime_stamp_text time_stamp_() const; - void time_stamp_(const SdaiTime_stamp_text x); + void time_stamp_( const SdaiTime_stamp_text x ); StringAggregate_ptr author_() const; - void author_(const StringAggregate_ptr x); + void author_( const StringAggregate_ptr x ); StringAggregate_ptr organization_() const; - void organization_(const StringAggregate_ptr x); + void organization_( const StringAggregate_ptr x ); const SDAI_String preprocessor_version_() const; - void preprocessor_version_(const SDAI_String x); + void preprocessor_version_( const SDAI_String x ); const SDAI_String originating_system_() const; - void originating_system_(const SDAI_String x); + void originating_system_( const SDAI_String x ); const SDAI_String authorization_() const; - void authorization_(const SDAI_String x); + void authorization_( const SDAI_String x ); }; inline SdaiFile_name * -create_SdaiFile_name() -{ +create_SdaiFile_name() { return new SdaiFile_name ; } @@ -158,37 +149,34 @@ create_SdaiFile_name() ///////// ENTITY section_context -extern SC_EDITOR_EXPORT AttrDescriptor *a_12section; -extern SC_EDITOR_EXPORT AttrDescriptor *a_13context_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor * a_12section; +extern SC_EDITOR_EXPORT AttrDescriptor * a_13context_identifiers; -class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance { protected: SDAI_String _section ; // OPTIONAL StringAggregate _context_identifiers ; // of context_name public: - SdaiSection_context(); - SdaiSection_context(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiSection_context(SdaiSection_context &e); + SdaiSection_context( ); + SdaiSection_context( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiSection_context( SdaiSection_context & e ); ~SdaiSection_context(); - int opcode() - { + int opcode() { return 3 ; } const SdaiSection_name section_() const; - void section_(const SdaiSection_name x); + void section_( const SdaiSection_name x ); StringAggregate_ptr context_identifiers_() const; - void context_identifiers_(const StringAggregate_ptr x); + void context_identifiers_( const StringAggregate_ptr x ); }; inline SdaiSection_context * -create_SdaiSection_context() -{ +create_SdaiSection_context() { return new SdaiSection_context ; } @@ -197,36 +185,33 @@ create_SdaiSection_context() ///////// ENTITY file_description -extern SC_EDITOR_EXPORT AttrDescriptor *a_14description; -extern SC_EDITOR_EXPORT AttrDescriptor *a_15implementation_level; +extern SC_EDITOR_EXPORT AttrDescriptor * a_14description; +extern SC_EDITOR_EXPORT AttrDescriptor * a_15implementation_level; -class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance { protected: StringAggregate _description ; SDAI_String _implementation_level ; public: - SdaiFile_description(); - SdaiFile_description(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_description(SdaiFile_description &e); + SdaiFile_description( ); + SdaiFile_description( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_description( SdaiFile_description & e ); ~SdaiFile_description(); - int opcode() - { + int opcode() { return 4 ; } StringAggregate_ptr description_() const; - void description_(const StringAggregate_ptr x); + void description_( const StringAggregate_ptr x ); const SDAI_String implementation_level_() const; - void implementation_level_(const SDAI_String x); + void implementation_level_( const SDAI_String x ); }; inline SdaiFile_description * -create_SdaiFile_description() -{ +create_SdaiFile_description() { return new SdaiFile_description ; } @@ -235,32 +220,29 @@ create_SdaiFile_description() ///////// ENTITY file_schema -extern SC_EDITOR_EXPORT AttrDescriptor *a_16schema_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor * a_16schema_identifiers; -class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance { protected: StringAggregate _schema_identifiers ; // of schema_name public: - SdaiFile_schema(); - SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_schema(SdaiFile_schema &e); + SdaiFile_schema( ); + SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_schema( SdaiFile_schema & e ); ~SdaiFile_schema(); - int opcode() - { + int opcode() { return 5 ; } StringAggregate_ptr schema_identifiers_() const; - void schema_identifiers_(const StringAggregate_ptr x); + void schema_identifiers_( const StringAggregate_ptr x ); }; inline SdaiFile_schema * -create_SdaiFile_schema() -{ +create_SdaiFile_schema() { return new SdaiFile_schema ; } @@ -269,8 +251,7 @@ create_SdaiFile_schema() // ***** generate Model related pieces -class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents -{ +class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents { public: SdaiModel_contents_header_section_schema(); @@ -290,7 +271,7 @@ class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Mo }; -typedef SdaiModel_contents_header_section_schema *SdaiModel_contents_header_section_schema_ptr; +typedef SdaiModel_contents_header_section_schema * SdaiModel_contents_header_section_schema_ptr; typedef SdaiModel_contents_header_section_schema_ptr SdaiModel_contents_header_section_schema_var; SC_EDITOR_EXPORT SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema(); #endif diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index d4431ebf5..3a469c7d3 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -7,84 +7,83 @@ #include #include "sc_memmgr.h" -void HeaderInitSchemasAndEnts(Registry ®) -{ +void HeaderInitSchemasAndEnts( Registry & reg ) { Uniqueness_rule_ptr ur; // Schema: SdaiHEADER_SECTION_SCHEMA - s_header_section_schema = new Schema("Header_Section_Schema"); + s_header_section_schema = new Schema( "Header_Section_Schema" ); s_header_section_schema->AssignModelContentsCreator( - (ModelContentsCreator) create_SdaiModel_contents_header_section_schema); - reg.AddSchema(*s_header_section_schema); + ( ModelContentsCreator ) create_SdaiModel_contents_header_section_schema ); + reg.AddSchema( *s_header_section_schema ); // ***** Initialize the Types header_section_schemat_time_stamp_text = new TypeDescriptor( "Time_Stamp_Text", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (256)"); // Description - s_header_section_schema->AddType(header_section_schemat_time_stamp_text); + "STRING (256)" ); // Description + s_header_section_schema->AddType( header_section_schemat_time_stamp_text ); header_section_schemat_section_name = new TypeDescriptor( "Section_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier"); // Description - s_header_section_schema->AddType(header_section_schemat_section_name); + "exchange_structure_identifier" ); // Description + s_header_section_schema->AddType( header_section_schemat_section_name ); header_section_schemat_context_name = new TypeDescriptor( "Context_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING"); // Description - s_header_section_schema->AddType(header_section_schemat_context_name); + "STRING" ); // Description + s_header_section_schema->AddType( header_section_schemat_context_name ); header_section_schemat_schema_name = new TypeDescriptor( "Schema_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (1024)"); // Description - s_header_section_schema->AddType(header_section_schemat_schema_name); + "STRING (1024)" ); // Description + s_header_section_schema->AddType( header_section_schemat_schema_name ); header_section_schemat_language_name = new TypeDescriptor( "Language_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier"); // Description - s_header_section_schema->AddType(header_section_schemat_language_name); + "exchange_structure_identifier" ); // Description + s_header_section_schema->AddType( header_section_schemat_language_name ); header_section_schemat_exchange_structure_identifier = new TypeDescriptor( "Exchange_Structure_Identifier", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING"); // Description - s_header_section_schema->AddType(header_section_schemat_exchange_structure_identifier); + "STRING" ); // Description + s_header_section_schema->AddType( header_section_schemat_exchange_structure_identifier ); // ***** Initialize the Entities header_section_schemae_section_language = new EntityDescriptor( "Section_Language", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiSection_language); - s_header_section_schema->AddEntity(header_section_schemae_section_language); + ( Creator ) create_SdaiSection_language ); + s_header_section_schema->AddEntity( header_section_schemae_section_language ); header_section_schemae_section_language->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule("UR1 : section;\n"); - header_section_schemae_section_language->_uniqueness_rules->Append(ur); + ur = new Uniqueness_rule( "UR1 : section;\n" ); + header_section_schemae_section_language->_uniqueness_rules->Append( ur ); header_section_schemae_file_population = new EntityDescriptor( "File_Population", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_population); - s_header_section_schema->AddEntity(header_section_schemae_file_population); + ( Creator ) create_SdaiFile_population ); + s_header_section_schema->AddEntity( header_section_schemae_file_population ); header_section_schemae_file_name = new EntityDescriptor( "File_Name", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_name); - s_header_section_schema->AddEntity(header_section_schemae_file_name); + ( Creator ) create_SdaiFile_name ); + s_header_section_schema->AddEntity( header_section_schemae_file_name ); header_section_schemae_section_context = new EntityDescriptor( "Section_Context", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiSection_context); - s_header_section_schema->AddEntity(header_section_schemae_section_context); + ( Creator ) create_SdaiSection_context ); + s_header_section_schema->AddEntity( header_section_schemae_section_context ); header_section_schemae_section_context->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule("UR1 : section;\n"); - header_section_schemae_section_context->_uniqueness_rules->Append(ur); + ur = new Uniqueness_rule( "UR1 : section;\n" ); + header_section_schemae_section_context->_uniqueness_rules->Append( ur ); header_section_schemae_file_description = new EntityDescriptor( "File_Description", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_description); - s_header_section_schema->AddEntity(header_section_schemae_file_description); + ( Creator ) create_SdaiFile_description ); + s_header_section_schema->AddEntity( header_section_schemae_file_description ); header_section_schemae_file_schema = new EntityDescriptor( "File_Schema", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_schema); - s_header_section_schema->AddEntity(header_section_schemae_file_schema); + ( Creator ) create_SdaiFile_schema ); + s_header_section_schema->AddEntity( header_section_schemae_file_schema ); //////////////// USE statements //////////////// REFERENCE statements diff --git a/src/cleditor/SdaiHeaderSchemaClasses.h b/src/cleditor/SdaiHeaderSchemaClasses.h index 307af452b..5427bd7b5 100644 --- a/src/cleditor/SdaiHeaderSchemaClasses.h +++ b/src/cleditor/SdaiHeaderSchemaClasses.h @@ -7,81 +7,81 @@ #include // Schema: SdaiHEADER_SECTION_SCHEMA -extern Schema *s_header_section_schema; +extern Schema * s_header_section_schema; // Types: typedef SDAI_String SdaiTime_stamp_text; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_time_stamp_text; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_time_stamp_text; typedef SDAI_String SdaiSection_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_section_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_section_name; typedef SDAI_String SdaiContext_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_context_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_context_name; typedef SDAI_String SdaiSchema_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_schema_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_schema_name; typedef SDAI_String SdaiLanguage_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_language_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_language_name; typedef SDAI_String SdaiExchange_structure_identifier; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_exchange_structure_identifier; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_exchange_structure_identifier; // Entities: class SdaiSection_language; -typedef SdaiSection_language *SdaiSection_languageH; -typedef SdaiSection_language *SdaiSection_language_ptr; +typedef SdaiSection_language * SdaiSection_languageH; +typedef SdaiSection_language * SdaiSection_language_ptr; typedef SdaiSection_language_ptr SdaiSection_language_var; -typedef const SdaiSection_language *const_SdaiSection_languageH; -typedef const SdaiSection_language *const_SdaiSection_language_ptr; +typedef const SdaiSection_language * const_SdaiSection_languageH; +typedef const SdaiSection_language * const_SdaiSection_language_ptr; #define SdaiSection_language__set SDAI_DAObject__set #define SdaiSection_language__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_language; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_language; class SdaiFile_population; -typedef SdaiFile_population *SdaiFile_populationH; -typedef SdaiFile_population *SdaiFile_population_ptr; +typedef SdaiFile_population * SdaiFile_populationH; +typedef SdaiFile_population * SdaiFile_population_ptr; typedef SdaiFile_population_ptr SdaiFile_population_var; -typedef const SdaiFile_population *const_SdaiFile_populationH; -typedef const SdaiFile_population *const_SdaiFile_population_ptr; +typedef const SdaiFile_population * const_SdaiFile_populationH; +typedef const SdaiFile_population * const_SdaiFile_population_ptr; #define SdaiFile_population__set SDAI_DAObject__set #define SdaiFile_population__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_population; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_population; class SdaiFile_name; -typedef SdaiFile_name *SdaiFile_nameH; -typedef SdaiFile_name *SdaiFile_name_ptr; +typedef SdaiFile_name * SdaiFile_nameH; +typedef SdaiFile_name * SdaiFile_name_ptr; typedef SdaiFile_name_ptr SdaiFile_name_var; -typedef const SdaiFile_name *const_SdaiFile_nameH; -typedef const SdaiFile_name *const_SdaiFile_name_ptr; +typedef const SdaiFile_name * const_SdaiFile_nameH; +typedef const SdaiFile_name * const_SdaiFile_name_ptr; #define SdaiFile_name__set SDAI_DAObject__set #define SdaiFile_name__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_name; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_name; class SdaiSection_context; -typedef SdaiSection_context *SdaiSection_contextH; -typedef SdaiSection_context *SdaiSection_context_ptr; +typedef SdaiSection_context * SdaiSection_contextH; +typedef SdaiSection_context * SdaiSection_context_ptr; typedef SdaiSection_context_ptr SdaiSection_context_var; -typedef const SdaiSection_context *const_SdaiSection_contextH; -typedef const SdaiSection_context *const_SdaiSection_context_ptr; +typedef const SdaiSection_context * const_SdaiSection_contextH; +typedef const SdaiSection_context * const_SdaiSection_context_ptr; #define SdaiSection_context__set SDAI_DAObject__set #define SdaiSection_context__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_context; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_context; class SdaiFile_description; -typedef SdaiFile_description *SdaiFile_descriptionH; -typedef SdaiFile_description *SdaiFile_description_ptr; +typedef SdaiFile_description * SdaiFile_descriptionH; +typedef SdaiFile_description * SdaiFile_description_ptr; typedef SdaiFile_description_ptr SdaiFile_description_var; -typedef const SdaiFile_description *const_SdaiFile_descriptionH; -typedef const SdaiFile_description *const_SdaiFile_description_ptr; +typedef const SdaiFile_description * const_SdaiFile_descriptionH; +typedef const SdaiFile_description * const_SdaiFile_description_ptr; #define SdaiFile_description__set SDAI_DAObject__set #define SdaiFile_description__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_description; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_description; class SdaiFile_schema; -typedef SdaiFile_schema *SdaiFile_schemaH; -typedef SdaiFile_schema *SdaiFile_schema_ptr; +typedef SdaiFile_schema * SdaiFile_schemaH; +typedef SdaiFile_schema * SdaiFile_schema_ptr; typedef SdaiFile_schema_ptr SdaiFile_schema_var; -typedef const SdaiFile_schema *const_SdaiFile_schemaH; -typedef const SdaiFile_schema *const_SdaiFile_schema_ptr; +typedef const SdaiFile_schema * const_SdaiFile_schemaH; +typedef const SdaiFile_schema * const_SdaiFile_schema_ptr; #define SdaiFile_schema__set SDAI_DAObject__set #define SdaiFile_schema__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_schema; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_schema; #endif diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 97661537a..35099d805 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -10,183 +10,182 @@ #include #include "sc_memmgr.h" -void SdaiHEADER_SECTION_SCHEMAInit(Registry ®) -{ - header_section_schemat_time_stamp_text->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_time_stamp_text); - header_section_schemat_section_name->ReferentType(header_section_schemat_exchange_structure_identifier); - reg.AddType(*header_section_schemat_section_name); - header_section_schemat_context_name->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_context_name); - header_section_schemat_schema_name->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_schema_name); - header_section_schemat_language_name->ReferentType(header_section_schemat_exchange_structure_identifier); - reg.AddType(*header_section_schemat_language_name); - header_section_schemat_exchange_structure_identifier->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_exchange_structure_identifier); +void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { + header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_time_stamp_text ); + header_section_schemat_section_name->ReferentType( header_section_schemat_exchange_structure_identifier ); + reg.AddType( *header_section_schemat_section_name ); + header_section_schemat_context_name->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_context_name ); + header_section_schemat_schema_name->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_schema_name ); + header_section_schemat_language_name->ReferentType( header_section_schemat_exchange_structure_identifier ); + reg.AddType( *header_section_schemat_language_name ); + header_section_schemat_exchange_structure_identifier->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_exchange_structure_identifier ); ///////// ENTITY section_language a_0section = - new AttrDescriptor("section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_language); - header_section_schemae_section_language->AddExplicitAttr(a_0section); + new AttrDescriptor( "section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_language ); + header_section_schemae_section_language->AddExplicitAttr( a_0section ); a_1default_language = - new AttrDescriptor("default_language", header_section_schemat_language_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_language); - header_section_schemae_section_language->AddExplicitAttr(a_1default_language); - reg.AddEntity(*header_section_schemae_section_language); + new AttrDescriptor( "default_language", header_section_schemat_language_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_language ); + header_section_schemae_section_language->AddExplicitAttr( a_1default_language ); + reg.AddEntity( *header_section_schemae_section_language ); ///////// END_ENTITY section_language ///////// ENTITY file_population a_2governing_schema = - new AttrDescriptor("governing_schema", header_section_schemat_schema_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_2governing_schema); + new AttrDescriptor( "governing_schema", header_section_schemat_schema_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_2governing_schema ); a_3determination_method = - new AttrDescriptor("determination_method", header_section_schemat_exchange_structure_identifier, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_3determination_method); - SetTypeDescriptor *t_0 = new SetTypeDescriptor; - t_0->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_0->SetBound1(1); - t_0->SetBound2(2147483647); - t_0->FundamentalType(SET_TYPE); - t_0->Description("SET [1:?] OF section_name"); - t_0->OriginatingSchema(s_header_section_schema); - t_0->ReferentType(header_section_schemat_section_name); - s_header_section_schema->AddUnnamedType(t_0); + new AttrDescriptor( "determination_method", header_section_schemat_exchange_structure_identifier, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_3determination_method ); + SetTypeDescriptor * t_0 = new SetTypeDescriptor; + t_0->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_0->SetBound1( 1 ); + t_0->SetBound2( 2147483647 ); + t_0->FundamentalType( SET_TYPE ); + t_0->Description( "SET [1:?] OF section_name" ); + t_0->OriginatingSchema( s_header_section_schema ); + t_0->ReferentType( header_section_schemat_section_name ); + s_header_section_schema->AddUnnamedType( t_0 ); a_4governed_sections = - new AttrDescriptor("governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_4governed_sections); - reg.AddEntity(*header_section_schemae_file_population); + new AttrDescriptor( "governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_4governed_sections ); + reg.AddEntity( *header_section_schemae_file_population ); ///////// END_ENTITY file_population ///////// ENTITY file_name a_5name = - new AttrDescriptor("name", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_5name); + new AttrDescriptor( "name", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_5name ); a_6time_stamp = - new AttrDescriptor("time_stamp", header_section_schemat_time_stamp_text, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_6time_stamp); - ListTypeDescriptor *t_1 = new ListTypeDescriptor; - t_1->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_1->SetBound1(1); - t_1->SetBound2(2147483647); - t_1->FundamentalType(LIST_TYPE); - t_1->Description("LIST [1:?] OF STRING (256)"); - t_1->OriginatingSchema(s_header_section_schema); - t_1->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_1); + new AttrDescriptor( "time_stamp", header_section_schemat_time_stamp_text, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_6time_stamp ); + ListTypeDescriptor * t_1 = new ListTypeDescriptor; + t_1->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_1->SetBound1( 1 ); + t_1->SetBound2( 2147483647 ); + t_1->FundamentalType( LIST_TYPE ); + t_1->Description( "LIST [1:?] OF STRING (256)" ); + t_1->OriginatingSchema( s_header_section_schema ); + t_1->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_1 ); a_7author = - new AttrDescriptor("author", t_1, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_7author); - ListTypeDescriptor *t_2 = new ListTypeDescriptor; - t_2->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_2->SetBound1(1); - t_2->SetBound2(2147483647); - t_2->FundamentalType(LIST_TYPE); - t_2->Description("LIST [1:?] OF STRING (256)"); - t_2->OriginatingSchema(s_header_section_schema); - t_2->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_2); + new AttrDescriptor( "author", t_1, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_7author ); + ListTypeDescriptor * t_2 = new ListTypeDescriptor; + t_2->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_2->SetBound1( 1 ); + t_2->SetBound2( 2147483647 ); + t_2->FundamentalType( LIST_TYPE ); + t_2->Description( "LIST [1:?] OF STRING (256)" ); + t_2->OriginatingSchema( s_header_section_schema ); + t_2->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_2 ); a_8organization = - new AttrDescriptor("organization", t_2, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_8organization); + new AttrDescriptor( "organization", t_2, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_8organization ); a_9preprocessor_version = - new AttrDescriptor("preprocessor_version", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_9preprocessor_version); + new AttrDescriptor( "preprocessor_version", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_9preprocessor_version ); a_10originating_system = - new AttrDescriptor("originating_system", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_10originating_system); + new AttrDescriptor( "originating_system", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_10originating_system ); a_11authorization = - new AttrDescriptor("authorization", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_11authorization); - reg.AddEntity(*header_section_schemae_file_name); + new AttrDescriptor( "authorization", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_11authorization ); + reg.AddEntity( *header_section_schemae_file_name ); ///////// END_ENTITY file_name ///////// ENTITY section_context a_12section = - new AttrDescriptor("section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_context); - header_section_schemae_section_context->AddExplicitAttr(a_12section); - ListTypeDescriptor *t_3 = new ListTypeDescriptor; - t_3->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_3->SetBound1(1); - t_3->SetBound2(2147483647); - t_3->FundamentalType(LIST_TYPE); - t_3->Description("LIST [1:?] OF context_name"); - t_3->OriginatingSchema(s_header_section_schema); - t_3->ReferentType(header_section_schemat_context_name); - s_header_section_schema->AddUnnamedType(t_3); + new AttrDescriptor( "section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_context ); + header_section_schemae_section_context->AddExplicitAttr( a_12section ); + ListTypeDescriptor * t_3 = new ListTypeDescriptor; + t_3->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_3->SetBound1( 1 ); + t_3->SetBound2( 2147483647 ); + t_3->FundamentalType( LIST_TYPE ); + t_3->Description( "LIST [1:?] OF context_name" ); + t_3->OriginatingSchema( s_header_section_schema ); + t_3->ReferentType( header_section_schemat_context_name ); + s_header_section_schema->AddUnnamedType( t_3 ); a_13context_identifiers = - new AttrDescriptor("context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_context); - header_section_schemae_section_context->AddExplicitAttr(a_13context_identifiers); - reg.AddEntity(*header_section_schemae_section_context); + new AttrDescriptor( "context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_context ); + header_section_schemae_section_context->AddExplicitAttr( a_13context_identifiers ); + reg.AddEntity( *header_section_schemae_section_context ); ///////// END_ENTITY section_context ///////// ENTITY file_description - ListTypeDescriptor *t_4 = new ListTypeDescriptor; - t_4->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_4->SetBound1(1); - t_4->SetBound2(2147483647); - t_4->FundamentalType(LIST_TYPE); - t_4->Description("LIST [1:?] OF STRING (256)"); - t_4->OriginatingSchema(s_header_section_schema); - t_4->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_4); + ListTypeDescriptor * t_4 = new ListTypeDescriptor; + t_4->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_4->SetBound1( 1 ); + t_4->SetBound2( 2147483647 ); + t_4->FundamentalType( LIST_TYPE ); + t_4->Description( "LIST [1:?] OF STRING (256)" ); + t_4->OriginatingSchema( s_header_section_schema ); + t_4->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_4 ); a_14description = - new AttrDescriptor("description", t_4, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description); - header_section_schemae_file_description->AddExplicitAttr(a_14description); + new AttrDescriptor( "description", t_4, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description ); + header_section_schemae_file_description->AddExplicitAttr( a_14description ); a_15implementation_level = - new AttrDescriptor("implementation_level", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description); - header_section_schemae_file_description->AddExplicitAttr(a_15implementation_level); - reg.AddEntity(*header_section_schemae_file_description); + new AttrDescriptor( "implementation_level", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description ); + header_section_schemae_file_description->AddExplicitAttr( a_15implementation_level ); + reg.AddEntity( *header_section_schemae_file_description ); ///////// END_ENTITY file_description ///////// ENTITY file_schema - ListTypeDescriptor *t_5 = new ListTypeDescriptor; - t_5->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_5->SetBound1(1); - t_5->SetBound2(2147483647); - t_5->UniqueElements(LTrue); - t_5->FundamentalType(LIST_TYPE); - t_5->Description("LIST [1:?] OF UNIQUE schema_name"); - t_5->OriginatingSchema(s_header_section_schema); - t_5->ReferentType(header_section_schemat_schema_name); - s_header_section_schema->AddUnnamedType(t_5); + ListTypeDescriptor * t_5 = new ListTypeDescriptor; + t_5->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_5->SetBound1( 1 ); + t_5->SetBound2( 2147483647 ); + t_5->UniqueElements( LTrue ); + t_5->FundamentalType( LIST_TYPE ); + t_5->Description( "LIST [1:?] OF UNIQUE schema_name" ); + t_5->OriginatingSchema( s_header_section_schema ); + t_5->ReferentType( header_section_schemat_schema_name ); + s_header_section_schema->AddUnnamedType( t_5 ); a_16schema_identifiers = - new AttrDescriptor("schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_schema); - header_section_schemae_file_schema->AddExplicitAttr(a_16schema_identifiers); - reg.AddEntity(*header_section_schemae_file_schema); + new AttrDescriptor( "schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_schema ); + header_section_schemae_file_schema->AddExplicitAttr( a_16schema_identifiers ); + reg.AddEntity( *header_section_schemae_file_schema ); ///////// END_ENTITY file_schema } diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index a5c2a45b3..05790a09c 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -7,11 +7,10 @@ #include #include "sc_memmgr.h" -void HeaderSchemaInit(Registry ®) -{ - HeaderInitSchemasAndEnts(reg); - SdaiHEADER_SECTION_SCHEMAInit(reg); - reg.SetCompCollect(0); +void HeaderSchemaInit( Registry & reg ) { + HeaderInitSchemasAndEnts( reg ); + SdaiHEADER_SECTION_SCHEMAInit( reg ); + reg.SetCompCollect( 0 ); } #endif diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index 2a9589ff7..a0868fbc6 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -20,8 +20,8 @@ #include #include -SC_EDITOR_EXPORT void HeaderSchemaInit(Registry &); -SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts(Registry &); -SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit(Registry &r); +SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & ); +SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & ); +SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit( Registry & r ); #endif diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index ed90f8887..7c015ce47 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -13,79 +13,72 @@ #include #include "sc_memmgr.h" -ReplicateLinkNode *ReplicateList::FindNode(MgrNode *mn) -{ - ReplicateLinkNode *rln = (ReplicateLinkNode *)GetHead(); +ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { + ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); int numEntries = EntryCount(); - while(numEntries--) { - if(rln->ReplicateNode() == mn) { + while( numEntries-- ) { + if( rln->ReplicateNode() == mn ) { return rln; } - rln = (ReplicateLinkNode *)rln->NextNode(); + rln = ( ReplicateLinkNode * )rln->NextNode(); } return 0; } -bool ReplicateList::IsOnList(MgrNode *mn) -{ - return (FindNode(mn) != 0); +bool ReplicateList::IsOnList( MgrNode * mn ) { + return ( FindNode( mn ) != 0 ); } /////////////////////////////////////////////////////////////////////////////// // returns true if it could delete the node /////////////////////////////////////////////////////////////////////////////// -bool ReplicateList::Remove(ReplicateLinkNode *rln) -{ - ReplicateLinkNode *rnFollow = (ReplicateLinkNode *)GetHead(); - if(!rnFollow || !rln) { +bool ReplicateList::Remove( ReplicateLinkNode * rln ) { + ReplicateLinkNode * rnFollow = ( ReplicateLinkNode * )GetHead(); + if( !rnFollow || !rln ) { return false; } else { - if(rnFollow == rln) { + if( rnFollow == rln ) { head = rln->NextNode(); delete rln; return true; } else { - ReplicateLinkNode *rn = (ReplicateLinkNode *)rnFollow->NextNode(); - while(rn) { - if(rn == rln) { - rnFollow->next = (SingleLinkNode *)rln->NextNode(); + ReplicateLinkNode * rn = ( ReplicateLinkNode * )rnFollow->NextNode(); + while( rn ) { + if( rn == rln ) { + rnFollow->next = ( SingleLinkNode * )rln->NextNode(); delete rln; return true; } rnFollow = rn; - rn = (ReplicateLinkNode *)rn->NextNode(); + rn = ( ReplicateLinkNode * )rn->NextNode(); } // end while(rn) } // end else } // end else return false; } -bool ReplicateList::Remove(MgrNode *rn) -{ - return Remove(FindNode(rn)); +bool ReplicateList::Remove( MgrNode * rn ) { + return Remove( FindNode( rn ) ); } -CmdMgr::CmdMgr() -{ - completeList = new MgrNodeList(completeSE); - incompleteList = new MgrNodeList(incompleteSE); - deleteList = new MgrNodeList(deleteSE); +CmdMgr::CmdMgr() { + completeList = new MgrNodeList( completeSE ); + incompleteList = new MgrNodeList( incompleteSE ); + deleteList = new MgrNodeList( deleteSE ); - mappedWriteList = new DisplayNodeList(mappedWrite); - mappedViewList = new DisplayNodeList(mappedView); - closeList = new DisplayNodeList(notMapped); + mappedWriteList = new DisplayNodeList( mappedWrite ); + mappedViewList = new DisplayNodeList( mappedView ); + closeList = new DisplayNodeList( notMapped ); replicateList = new ReplicateList(); } -void CmdMgr::ReplicateCmdList(MgrNode *mn) -{ - if(!(replicateList->IsOnList(mn))) { - replicateList->AddNode(mn); +void CmdMgr::ReplicateCmdList( MgrNode * mn ) { + if( !( replicateList->IsOnList( mn ) ) ) { + replicateList->AddNode( mn ); } } -void CmdMgr::ClearInstances() -{ +void CmdMgr::ClearInstances() { completeList->ClearEntries(); incompleteList->ClearEntries(); cancelList->ClearEntries(); @@ -94,15 +87,14 @@ void CmdMgr::ClearInstances() } /// searches current list for fileId -MgrNode *CmdMgr::StateFindFileId(stateEnum s, int fileId) -{ - switch(s) { +MgrNode * CmdMgr::StateFindFileId( stateEnum s, int fileId ) { + switch( s ) { case completeSE: - return completeList->FindFileId(fileId); + return completeList->FindFileId( fileId ); case incompleteSE: - return incompleteList->FindFileId(fileId); + return incompleteList->FindFileId( fileId ); case deleteSE: - return deleteList->FindFileId(fileId); + return deleteList->FindFileId( fileId ); case newSE: // there is no new list case noStateSE: default: @@ -112,31 +104,29 @@ MgrNode *CmdMgr::StateFindFileId(stateEnum s, int fileId) } } -MgrNode *CmdMgr::GetHead(stateEnum listType) -{ - switch(listType) { +MgrNode * CmdMgr::GetHead( stateEnum listType ) { + switch( listType ) { case completeSE: // saved complete list - return (MgrNode *)completeList->GetHead(); + return ( MgrNode * )completeList->GetHead(); case incompleteSE: // saved incomplete list - return (MgrNode *)incompleteList->GetHead(); + return ( MgrNode * )incompleteList->GetHead(); case deleteSE: // delete list - return (MgrNode *)deleteList->GetHead(); + return ( MgrNode * )deleteList->GetHead(); default: return 0; } } -DisplayNode *CmdMgr::GetHead(displayStateEnum listType) -{ - switch(listType) { +DisplayNode * CmdMgr::GetHead( displayStateEnum listType ) { + switch( listType ) { case mappedWrite: - return (DisplayNode *)mappedWriteList->GetHead(); + return ( DisplayNode * )mappedWriteList->GetHead(); case mappedView: - return (DisplayNode *)mappedViewList->GetHead(); + return ( DisplayNode * )mappedViewList->GetHead(); case notMapped: - return (DisplayNode *)closeList->GetHead(); + return ( DisplayNode * )closeList->GetHead(); case noMapState: default: @@ -144,9 +134,8 @@ DisplayNode *CmdMgr::GetHead(displayStateEnum listType) } } -void CmdMgr::ClearEntries(stateEnum listType) -{ - switch(listType) { +void CmdMgr::ClearEntries( stateEnum listType ) { + switch( listType ) { case completeSE: // saved complete list completeList->ClearEntries(); break; @@ -161,9 +150,8 @@ void CmdMgr::ClearEntries(stateEnum listType) } } -void CmdMgr::ClearEntries(displayStateEnum listType) -{ - switch(listType) { +void CmdMgr::ClearEntries( displayStateEnum listType ) { + switch( listType ) { case mappedWrite: mappedWriteList->ClearEntries(); break; diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 0f985cb24..7ef2f00b5 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -77,141 +77,121 @@ /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode -{ +class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode { private: protected: - MgrNode *_repNode; + MgrNode * _repNode; public: - ReplicateLinkNode() - { + ReplicateLinkNode() { _repNode = 0; } ~ReplicateLinkNode() { } - const char *ClassName() - { + const char * ClassName() { return "ReplicateLinkNode"; } - MgrNode *ReplicateNode() - { + MgrNode * ReplicateNode() { return _repNode; } - void ReplicateNode(MgrNode *rn) - { + void ReplicateNode( MgrNode * rn ) { _repNode = rn; } }; -class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList -{ +class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList { private: protected: public: ReplicateList() { } ~ReplicateList() { } - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new ReplicateLinkNode; } - bool IsOnList(MgrNode *mn); - ReplicateLinkNode *FindNode(MgrNode *mn); + bool IsOnList( MgrNode * mn ); + ReplicateLinkNode * FindNode( MgrNode * mn ); - ReplicateLinkNode *AddNode(MgrNode *rn) - { - ReplicateLinkNode *node = (ReplicateLinkNode *) NewNode(); - node->ReplicateNode(rn); - SingleLinkList::AppendNode(node); + ReplicateLinkNode * AddNode( MgrNode * rn ) { + ReplicateLinkNode * node = ( ReplicateLinkNode * ) NewNode(); + node->ReplicateNode( rn ); + SingleLinkList::AppendNode( node ); return node; } - bool Remove(ReplicateLinkNode *rln); - bool Remove(MgrNode *rn); + bool Remove( ReplicateLinkNode * rln ); + bool Remove( MgrNode * rn ); - const char *ClassName() - { + const char * ClassName() { return "ReplicateList"; } }; /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT CmdMgr -{ +class SC_EDITOR_EXPORT CmdMgr { protected: - MgrNodeList *completeList; - MgrNodeList *incompleteList; - MgrNodeList *cancelList; - MgrNodeList *deleteList; + MgrNodeList * completeList; + MgrNodeList * incompleteList; + MgrNodeList * cancelList; + MgrNodeList * deleteList; - DisplayNodeList *mappedWriteList; - DisplayNodeList *mappedViewList; - DisplayNodeList *closeList; + DisplayNodeList * mappedWriteList; + DisplayNodeList * mappedViewList; + DisplayNodeList * closeList; - ReplicateList *replicateList; + ReplicateList * replicateList; public: CmdMgr(); // STATE LIST OPERATIONS - MgrNode *GetHead(stateEnum listType); - DisplayNode *GetHead(displayStateEnum listType); - ReplicateLinkNode *GetReplicateHead() - { - return (ReplicateLinkNode *)(replicateList->GetHead()); + MgrNode * GetHead( stateEnum listType ); + DisplayNode * GetHead( displayStateEnum listType ); + ReplicateLinkNode * GetReplicateHead() { + return ( ReplicateLinkNode * )( replicateList->GetHead() ); } - void ClearEntries(stateEnum listType); - void ClearEntries(displayStateEnum listType); - void ClearReplicateEntries() - { + void ClearEntries( stateEnum listType ); + void ClearEntries( displayStateEnum listType ); + void ClearReplicateEntries() { replicateList->Empty(); } - ReplicateList *RepList() - { + ReplicateList * RepList() { return replicateList; } // searches current list for fileId - MgrNode *StateFindFileId(stateEnum s, int fileId); + MgrNode * StateFindFileId( stateEnum s, int fileId ); // returns stateNext or statePrev member variables // i.e. next or previous node on curr state list - int SaveCompleteCmdList(MgrNode *mn) - { - return mn->ChangeList(completeList); + int SaveCompleteCmdList( MgrNode * mn ) { + return mn->ChangeList( completeList ); } - int SaveIncompleteCmdList(MgrNode *mn) - { - return mn->ChangeList(incompleteList); + int SaveIncompleteCmdList( MgrNode * mn ) { + return mn->ChangeList( incompleteList ); } - int CancelCmdList(MgrNode *mn) - { - return mn->ChangeList(cancelList); + int CancelCmdList( MgrNode * mn ) { + return mn->ChangeList( cancelList ); } - int DeleteCmdList(MgrNode *mn) - { - return mn->ChangeList(deleteList); + int DeleteCmdList( MgrNode * mn ) { + return mn->ChangeList( deleteList ); } - int ModifyCmdList(MgrNode *mn) - { - return mn->ChangeList(mappedWriteList); + int ModifyCmdList( MgrNode * mn ) { + return mn->ChangeList( mappedWriteList ); } - int ViewCmdList(MgrNode *mn) - { - return mn->ChangeList(mappedViewList); + int ViewCmdList( MgrNode * mn ) { + return mn->ChangeList( mappedViewList ); } - int CloseCmdList(MgrNode *mn) - { - return ((mn->DisplayState() == mappedWrite) || - (mn->DisplayState() == mappedView)) ? - mn->ChangeList(closeList) : 0; + int CloseCmdList( MgrNode * mn ) { + return ( ( mn->DisplayState() == mappedWrite ) || + ( mn->DisplayState() == mappedView ) ) ? + mn->ChangeList( closeList ) : 0; } - void ReplicateCmdList(MgrNode *mn); + void ReplicateCmdList( MgrNode * mn ); void ClearInstances(); protected: diff --git a/src/cleditor/seeinfodefault.h b/src/cleditor/seeinfodefault.h index 5c24ba863..51198eac8 100644 --- a/src/cleditor/seeinfodefault.h +++ b/src/cleditor/seeinfodefault.h @@ -25,26 +25,23 @@ class DisplayNodelist; #include -class SC_EDITOR_EXPORT seeInfo : public DisplayNode -{ +class SC_EDITOR_EXPORT seeInfo : public DisplayNode { public: - seeInfo(MgrNode *node, - SDAI_Application_instance *se, - DisplayNodeList *dnl, displayStateEnum displaySt = mappedWrite); + seeInfo( MgrNode * node, + SDAI_Application_instance * se, + DisplayNodeList * dnl, displayStateEnum displaySt = mappedWrite ); - void *GetSEE() - { + void * GetSEE() { return see; } }; -inline seeInfo::seeInfo(MgrNode *node, SDAI_Application_instance *se, - DisplayNodeList *dnl, displayStateEnum displaySt) -{ +inline seeInfo::seeInfo( MgrNode * node, SDAI_Application_instance * se, + DisplayNodeList * dnl, displayStateEnum displaySt ) { mn = node; see = 0; displayState = displaySt; - dnl->Append(this); + dnl->Append( this ); } #endif diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index b5e763628..d737a9c89 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -32,23 +32,22 @@ include_directories( set(_libdeps stepcore stepdai steputils base stepeditor) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) - set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static) - SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) endif() SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile) # Local Variables: # tab-width: 8 diff --git a/src/cllazyfile/headerSectionReader.h b/src/cllazyfile/headerSectionReader.h index 6c5bf721d..8a51f5721 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/src/cllazyfile/headerSectionReader.h @@ -13,25 +13,21 @@ #include "sc_export.h" ///differs from the lazyDataSectionReader in that all instances are always loaded -class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader -{ +class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader { protected: - instancesLoaded_t *_headerInstances; + instancesLoaded_t * _headerInstances; /// must derive from this class - headerSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid): - sectionReader(parent, file, start, sid) - { + headerSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): + sectionReader( parent, file, start, sid ) { _headerInstances = new instancesLoaded_t; } public: - instancesLoaded_t *getInstances() const - { + instancesLoaded_t * getInstances() const { return _headerInstances; } - virtual ~headerSectionReader() - { + virtual ~headerSectionReader() { //FIXME delete each instance?! maybe add to clear, since it iterates over everything already //enum clearHow { rawData, deletePointers } _headerInstances->clear(); diff --git a/src/cllazyfile/instMgrHelper.h b/src/cllazyfile/instMgrHelper.h index 0d9321766..659f1ec8e 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/src/cllazyfile/instMgrHelper.h @@ -17,25 +17,21 @@ * 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 SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase -{ +class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase { protected: - lazyInstMgr *_lim; + lazyInstMgr * _lim; instanceID _id; public: - mgrNodeHelper(lazyInstMgr *lim) - { + mgrNodeHelper( lazyInstMgr * lim ) { _lim = lim; _id = 0; prev = next = 0; } - inline void setInstance(instanceID id) - { + inline void setInstance( instanceID id ) { _id = id; } - inline SDAI_Application_instance *GetSTEPentity() - { - return _lim->loadInstance(_id, true); + inline SDAI_Application_instance * GetSTEPentity() { + return _lim->loadInstance( _id, true ); } }; @@ -47,17 +43,15 @@ class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase * when an instance is looked up, this uses lazyInstMgr to load it, and then returns a pointer to it. */ -class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase -{ +class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase { protected: mgrNodeHelper _mn; public: - instMgrAdapter(lazyInstMgr *lim): InstMgrBase(), _mn(lim) {} + instMgrAdapter( lazyInstMgr * lim ): InstMgrBase(), _mn( lim ) {} - inline mgrNodeHelper *FindFileId(int fileId) - { + inline mgrNodeHelper * FindFileId( int fileId ) { //TODO check if fileId exists. if not, return null - _mn.setInstance(fileId); + _mn.setInstance( fileId ); return &_mn; } }; diff --git a/src/cllazyfile/lazyDataSectionReader.cc b/src/cllazyfile/lazyDataSectionReader.cc index 5d7941bd3..4b1bc1785 100644 --- a/src/cllazyfile/lazyDataSectionReader.cc +++ b/src/cllazyfile/lazyDataSectionReader.cc @@ -3,10 +3,9 @@ #include "lazyInstMgr.h" #include -lazyDataSectionReader::lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - sectionReader(parent, file, start, sid) -{ +lazyDataSectionReader::lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + sectionReader( parent, file, start, sid ) { _sectionIdentifier = ""; //FIXME set _sectionIdentifier from the data section identifier (2002 rev of Part 21), if present _error = false; } diff --git a/src/cllazyfile/lazyDataSectionReader.h b/src/cllazyfile/lazyDataSectionReader.h index 9f4d9763c..f2dc9dee4 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/src/cllazyfile/lazyDataSectionReader.h @@ -13,8 +13,7 @@ * \sa lazyP21DataSectionReader * \sa lazyP28DataSectionReader */ -class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader -{ +class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader { protected: bool _error, _completelyLoaded; #ifdef _MSC_VER @@ -27,11 +26,10 @@ class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader #endif /// only makes sense to call the ctor from derived class ctors - lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); public: virtual ~lazyDataSectionReader() {} - bool success() - { + bool success() { return !_error; } }; diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index baba1f137..9cc294df0 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -6,39 +6,37 @@ #include "headerSectionReader.h" #include "lazyInstMgr.h" -void lazyFileReader::initP21() -{ - _header = new p21HeaderSectionReader(this, _file, 0, -1); +void lazyFileReader::initP21() { + _header = new p21HeaderSectionReader( this, _file, 0, -1 ); - for(;;) { - lazyDataSectionReader *r; - r = new lazyP21DataSectionReader(this, _file, _file.tellg(), _parent->countDataSections()); - if(!r->success()) { + for( ;; ) { + lazyDataSectionReader * r; + r = new lazyP21DataSectionReader( this, _file, _file.tellg(), _parent->countDataSections() ); + if( !r->success() ) { delete r; //last read attempt failed std::cerr << "Corrupted data section" << std::endl; break; } - _parent->registerDataSection(r); + _parent->registerDataSection( r ); //check for new data section (DATA) or end of file (END-ISO-10303-21;) - while(isspace(_file.peek()) && _file.good()) { - _file.ignore(1); + while( isspace( _file.peek() ) && _file.good() ) { + _file.ignore( 1 ); } - if(needKW("END-ISO-10303-21;")) { + if( needKW( "END-ISO-10303-21;" ) ) { break; - } else if(!needKW("DATA")) { + } else if( !needKW( "DATA" ) ) { std::cerr << "Corrupted file - did not find new data section (\"DATA\") or end of file (\"END-ISO-10303-21;\") at offset " << _file.tellg() << std::endl; break; } } } -bool lazyFileReader::needKW(const char *kw) -{ - const char *c = kw; +bool lazyFileReader::needKW( const char * kw ) { + const char * c = kw; bool found = true; - while(*c) { - if(*c != _file.get()) { + while( *c ) { + if( *c != _file.get() ) { found = false; break; } @@ -47,34 +45,31 @@ bool lazyFileReader::needKW(const char *kw) return found; } -instancesLoaded_t *lazyFileReader::getHeaderInstances() -{ +instancesLoaded_t * lazyFileReader::getHeaderInstances() { return _header->getInstances(); } -lazyFileReader::lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid): _fileName(fname), _parent(i), _fileID(fid) -{ - _file.open(_fileName.c_str(), std::ios::binary); - _file.imbue(std::locale::classic()); - _file.unsetf(std::ios_base::skipws); - assert(_file.is_open() && _file.good()); +lazyFileReader::lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ): _fileName( fname ), _parent( i ), _fileID( fid ) { + _file.open( _fileName.c_str(), std::ios::binary ); + _file.imbue( std::locale::classic() ); + _file.unsetf( std::ios_base::skipws ); + assert( _file.is_open() && _file.good() ); detectType(); - switch(_fileType) { + switch( _fileType ) { case Part21: initP21(); break; case Part28: - //initP28(); - //break; + //initP28(); + //break; default: std::cerr << "Reached default case, " << __FILE__ << ":" << __LINE__ << std::endl; abort(); } } -lazyFileReader::~lazyFileReader() -{ +lazyFileReader::~lazyFileReader() { delete _header; } diff --git a/src/cllazyfile/lazyFileReader.h b/src/cllazyfile/lazyFileReader.h index 10a9baabd..49eea5b50 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/src/cllazyfile/lazyFileReader.h @@ -24,16 +24,15 @@ class headerSectionReader; ///read an exchange file of any supported type (currently only p21) ///for use only from within lazyInstMgr -class SC_LAZYFILE_EXPORT lazyFileReader -{ +class SC_LAZYFILE_EXPORT lazyFileReader { protected: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif std::string _fileName; - lazyInstMgr *_parent; - headerSectionReader *_header; + lazyInstMgr * _parent; + headerSectionReader * _header; std::ifstream _file; #ifdef _MSC_VER #pragma warning( pop ) @@ -44,30 +43,26 @@ class SC_LAZYFILE_EXPORT lazyFileReader void initP21(); ///TODO detect file type; for now, assume all are Part 21 - void detectType() - { + void detectType() { _fileType = Part21; } public: - fileID ID() const - { + fileID ID() const { return _fileID; } - instancesLoaded_t *getHeaderInstances(); + instancesLoaded_t * getHeaderInstances(); - lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid); + lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ); ~lazyFileReader(); - fileTypeEnum type() const - { + fileTypeEnum type() const { return _fileType; } - lazyInstMgr *getInstMgr() const - { + lazyInstMgr * getInstMgr() const { return _parent; } - bool needKW(const char *kw); + bool needKW( const char * kw ); }; #endif //LAZYFILEREADER_H diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 7d30d3c71..7ce253ee9 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -8,52 +8,48 @@ #include "sdaiApplication_instance.h" -lazyInstMgr::lazyInstMgr() -{ - _headerRegistry = new Registry(HeaderSchemaInit); - _instanceTypes = new instanceTypes_t(255); //NOTE arbitrary max of 255 chars for a type name +lazyInstMgr::lazyInstMgr() { + _headerRegistry = new Registry( HeaderSchemaInit ); + _instanceTypes = new instanceTypes_t( 255 ); //NOTE arbitrary max of 255 chars for a type name _lazyInstanceCount = 0; _loadedInstanceCount = 0; _longestTypeNameLen = 0; _mainRegistry = 0; _errors = new ErrorDescriptor(); - _ima = new instMgrAdapter(this); + _ima = new instMgrAdapter( this ); } -lazyInstMgr::~lazyInstMgr() -{ +lazyInstMgr::~lazyInstMgr() { delete _headerRegistry; delete _errors; delete _ima; //loop over files, sections, instances; delete header instances lazyFileReaderVec_t::iterator fit = _files.begin(); - for(; fit != _files.end(); ++fit) { + for( ; fit != _files.end(); ++fit ) { delete *fit; } dataSectionReaderVec_t::iterator sit = _dataSections.begin(); - for(; sit != _dataSections.end(); ++sit) { + for( ; sit != _dataSections.end(); ++sit ) { delete *sit; } _instancesLoaded.clear(); _instanceStreamPos.clear(); } -sectionID lazyInstMgr::registerDataSection(lazyDataSectionReader *sreader) -{ - _dataSections.push_back(sreader); +sectionID lazyInstMgr::registerDataSection( lazyDataSectionReader * sreader ) { + _dataSections.push_back( sreader ); return _dataSections.size() - 1; } -void lazyInstMgr::addLazyInstance(namedLazyInstance inst) -{ +void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) { _lazyInstanceCount++; - assert(inst.loc.begin > 0 && inst.loc.instance > 0); - int len = strlen(inst.name); - if(len > _longestTypeNameLen) { + assert( inst.loc.begin > 0 && inst.loc.instance > 0 ); + int len = strlen( inst.name ); + if( len > _longestTypeNameLen ) { _longestTypeNameLen = len; _longestTypeName = inst.name; } - _instanceTypes->insert(inst.name, inst.loc.instance); + _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? @@ -64,17 +60,17 @@ void lazyInstMgr::addLazyInstance(namedLazyInstance inst) */ positionAndSection ps = inst.loc.section; ps <<= 48; - ps |= (inst.loc.begin & 0xFFFFFFFFFFFFULL); - _instanceStreamPos.insert(inst.loc.instance, ps); + ps |= ( inst.loc.begin & 0xFFFFFFFFFFFFULL ); + _instanceStreamPos.insert( inst.loc.instance, ps ); - if(inst.refs) { - if(inst.refs->size() > 0) { + if( inst.refs ) { + if( inst.refs->size() > 0 ) { //forward refs - _fwdInstanceRefs.insert(inst.loc.instance, *inst.refs); + _fwdInstanceRefs.insert( inst.loc.instance, *inst.refs ); instanceRefs::iterator it = inst.refs->begin(); - for(; it != inst.refs->end(); ++it) { + for( ; it != inst.refs->end(); ++it ) { //reverse refs - _revInstanceRefs.insert(*it, inst.loc.instance); + _revInstanceRefs.insert( *it, inst.loc.instance ); } } else { delete inst.refs; @@ -82,15 +78,14 @@ void lazyInstMgr::addLazyInstance(namedLazyInstance inst) } } -unsigned long lazyInstMgr::getNumTypes() const -{ +unsigned long lazyInstMgr::getNumTypes() const { unsigned long n = 0 ; instanceTypes_t::cpair curr, end; end = _instanceTypes->end(); curr = _instanceTypes->begin(); - if(curr.value != 0) { + if( curr.value != 0 ) { n = 1; - while(curr.value != end.value) { + while( curr.value != end.value ) { n++; curr = _instanceTypes->next(); } @@ -98,58 +93,56 @@ unsigned long lazyInstMgr::getNumTypes() const return n ; } -void lazyInstMgr::openFile(std::string fname) -{ +void lazyInstMgr::openFile( std::string fname ) { //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); + _files.push_back( (lazyFileReader * ) 0 ); ///FIXME end atomic op - lazyFileReader *lfr = new lazyFileReader(fname, this, i); + 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, bool reSeek) -{ - assert(_mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()."); +SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id, bool reSeek ) { + assert( _mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()." ); std::streampos oldPos; positionAndSection ps; sectionID sid; - SDAI_Application_instance *inst = _instancesLoaded.find(id); - if(inst) { + SDAI_Application_instance * inst = _instancesLoaded.find( id ); + if( inst ) { return inst; } - instanceStreamPos_t::cvector *cv; - if(0 != (cv = _instanceStreamPos.find(id))) { - switch(cv->size()) { + instanceStreamPos_t::cvector * cv; + if( 0 != ( cv = _instanceStreamPos.find( id ) ) ) { + switch( cv->size() ) { case 0: std::cerr << "Instance #" << id << " not found in any section." << std::endl; break; case 1: long int off; - ps = cv->at(0); + ps = cv->at( 0 ); off = ps & 0xFFFFFFFFFFFFULL; sid = ps >> 48; - assert(_dataSections.size() > sid); - if(reSeek) { + assert( _dataSections.size() > sid ); + if( reSeek ) { oldPos = _dataSections[sid]->tellg(); } - inst = _dataSections[sid]->getRealInstance(_mainRegistry, off, id); - if(reSeek) { - _dataSections[sid]->seekg(oldPos); + 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; break; } - if(!isNilSTEPentity(inst)) { - _instancesLoaded.insert(id, inst); + if( !isNilSTEPentity( inst ) ) { + _instancesLoaded.insert( id, inst ); _loadedInstanceCount++; - lazyRefs lr(this, inst); + lazyRefs lr( this, inst ); lazyRefs::referentInstances_t insts = lr.result(); } else { std::cerr << "Error loading instance #" << id << "." << std::endl; @@ -161,27 +154,26 @@ SDAI_Application_instance *lazyInstMgr::loadInstance(instanceID id, bool reSeek) } -instanceSet *lazyInstMgr::instanceDependencies(instanceID id) -{ - instanceSet *checkedDependencies = new instanceSet(); +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); + 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()); + 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()); + 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() ); } } diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 63d12464e..78444a756 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -21,8 +21,7 @@ class Registry; class instMgrAdapter; -class SC_LAZYFILE_EXPORT lazyInstMgr -{ +class SC_LAZYFILE_EXPORT lazyInstMgr { protected: /** multimap from instance number to instances that it refers to * \sa instanceRefs_pair @@ -41,7 +40,7 @@ class SC_LAZYFILE_EXPORT lazyInstMgr * \sa instanceType_pair * \sa instanceType_range */ - instanceTypes_t *_instanceTypes; + instanceTypes_t * _instanceTypes; /** map from instance number to instance pointer (loaded instances only) * \sa instancesLoaded_pair @@ -63,14 +62,14 @@ class SC_LAZYFILE_EXPORT lazyInstMgr lazyFileReaderVec_t _files; - Registry *_headerRegistry, * _mainRegistry; - ErrorDescriptor *_errors; + Registry * _headerRegistry, * _mainRegistry; + ErrorDescriptor * _errors; unsigned long _lazyInstanceCount, _loadedInstanceCount; int _longestTypeNameLen; std::string _longestTypeName; - instMgrAdapter *_ima; + instMgrAdapter * _ima; #ifdef _MSC_VER #pragma warning( pop ) @@ -79,103 +78,88 @@ class SC_LAZYFILE_EXPORT lazyInstMgr public: lazyInstMgr(); ~lazyInstMgr(); - void openFile(std::string fname); + void openFile( std::string fname ); - void addLazyInstance(namedLazyInstance inst); - InstMgrBase *getAdapter() - { - return (InstMgrBase *) _ima; + void addLazyInstance( namedLazyInstance inst ); + InstMgrBase * getAdapter() { + return ( InstMgrBase * ) _ima; } - instanceRefs_t *getFwdRefs() - { + instanceRefs_t * getFwdRefs() { return & _fwdInstanceRefs; } - instanceRefs_t *getRevRefs() - { + instanceRefs_t * getRevRefs() { return & _revInstanceRefs; } /// returns a vector containing the instances that match `type` - instanceTypes_t::cvector *getInstances(std::string type, bool caseSensitive = false) /*const*/ - { - if(!caseSensitive) { + 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); + for( ; it != type.end(); ++it ) { + *it = toupper( *it ); } } - return _instanceTypes->find(type.c_str()); + return _instanceTypes->find( type.c_str() ); } /// get the number of instances of a certain type - unsigned int countInstances(std::string type) - { - instanceTypes_t::cvector *v = _instanceTypes->find(type.c_str()); - if(!v) { + unsigned int countInstances( std::string type ) { + instanceTypes_t::cvector * v = _instanceTypes->find( type.c_str() ); + if( !v ) { return 0; } return v->size(); } - instancesLoaded_t *getHeaderInstances(fileID file) - { + instancesLoaded_t * getHeaderInstances( fileID file ) { return _files[file]->getHeaderInstances(); } /// get the number of instances that have been found in the open files. - unsigned long totalInstanceCount() const - { + unsigned long totalInstanceCount() const { return _lazyInstanceCount; } /// get the number of instances that are loaded. - unsigned long loadedInstanceCount() const - { + unsigned long loadedInstanceCount() const { return _loadedInstanceCount; } /// get the number of data sections that have been identified - unsigned int countDataSections() - { + unsigned int countDataSections() { return _dataSections.size(); } ///builds the registry using the given initFunct - const Registry *initRegistry(CF_init initFunct) - { - setRegistry(new Registry(initFunct)); + const Registry * initRegistry( CF_init initFunct ) { + setRegistry( new Registry( initFunct ) ); return _mainRegistry; } /// set the registry to one already initialized - void setRegistry(Registry *reg) - { - assert(_mainRegistry == 0); + void setRegistry( Registry * reg ) { + assert( _mainRegistry == 0 ); _mainRegistry = reg; } - const Registry *getHeaderRegistry() const - { + const Registry * getHeaderRegistry() const { return _headerRegistry; } - const Registry *getMainRegistry() const - { + const Registry * getMainRegistry() const { return _mainRegistry; } /// get the longest type name - const std::string &getLongestTypeName() const - { + const std::string & getLongestTypeName() const { return _longestTypeName; } /// get the number of types of instances. unsigned long getNumTypes() const; - sectionID registerDataSection(lazyDataSectionReader *sreader); + sectionID registerDataSection( lazyDataSectionReader * sreader ); - ErrorDescriptor *getErrorDesc() - { + ErrorDescriptor * getErrorDesc() { return _errors; } @@ -183,30 +167,28 @@ class SC_LAZYFILE_EXPORT lazyInstMgr * \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); + 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); + 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) { + 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); + positionAndSection ps = cv->at( 0 ); //extract p, s, call long int off = ps & 0xFFFFFFFFFFFFULL; sectionID sid = ps >> 48; - return _dataSections[sid]->getType(off); + return _dataSections[sid]->getType( off ); } std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " not found." << std::endl; return 0; @@ -214,24 +196,24 @@ class SC_LAZYFILE_EXPORT lazyInstMgr // TODO implement these - // add another schema to registry - //void addSchema( void ( *initFn )() ); + // add another schema to registry + //void addSchema( void ( *initFn )() ); - //list all instances that one instance depends on (recursive) - //std::vector instanceDependencies( instanceID id ); //set is faster? + //list all instances that one instance depends on (recursive) + //std::vector 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 notDependencies(...) + /* * the opposite of instanceDependencies() - all instances that are *not* dependencies of one particular instance + same as above, but with list of instances */ + //std::vector notDependencies(...) - //renumber instances so that they are numbered 1..N where N is the total number of instances - //void normalizeInstanceIds(); + //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(); + //find data that is repeated and eliminate, if possible + //void eliminateDuplicates(); - //tell instMgr to use instances from this section - //void useDataSection( sectionID id ); + //tell instMgr to use instances from this section + //void useDataSection( sectionID id ); // TODO support references from one file to another }; diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index d3f873c82..9e9df2070 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -3,40 +3,39 @@ #include "lazyP21DataSectionReader.h" #include "lazyInstMgr.h" -lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - lazyDataSectionReader(parent, file, start, sid) -{ +lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + lazyDataSectionReader( parent, file, start, sid ) { findSectionStart(); namedLazyInstance nl; - while(nl = nextInstance(), ((nl.loc.begin > 0) && (nl.name != 0))) { - parent->getInstMgr()->addLazyInstance(nl); + 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) { + if( sectionReader::_error->severity() <= SEVERITY_WARNING ) { + sectionReader::_error->PrintContents( std::cerr ); + if( sectionReader::_error->severity() <= SEVERITY_INPUT_ERROR ) { _error = true; - return; + return; } } - - if(!_file.good()) { + + if( !_file.good() ) { _error = true; return; } - if(nl.loc.instance == 0) { + if( nl.loc.instance == 0 ) { //check for ENDSEC; skipWS(); std::streampos pos = _file.tellg(); - if(_file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' + if( _file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' && _file.get() == 'S' && _file.get() == 'E' && _file.get() == 'C' - && (skipWS(), _file.get() == ';')) { + && ( skipWS(), _file.get() == ';' ) ) { _sectionEnd = _file.tellg(); } else { - _file.seekg(pos); + _file.seekg( pos ); char found[26] = { '\0' }; - _file.read(found, 25); + _file.read( found, 25 ); std::cerr << "expected 'ENDSEC;', found " << found << std::endl; _error = true; } @@ -45,27 +44,26 @@ lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader *parent, std:: // part of readdata1 //if this changes, probably need to change sectionReader::getType() -const namedLazyInstance lazyP21DataSectionReader::nextInstance() -{ +const namedLazyInstance lazyP21DataSectionReader::nextInstance() { std::streampos end = -1; namedLazyInstance i; i.refs = 0; i.loc.begin = _file.tellg(); i.loc.instance = readInstanceNumber(); - if((_file.good()) && (i.loc.instance > 0)) { + if( ( _file.good() ) && ( i.loc.instance > 0 ) ) { skipWS(); i.loc.section = _sectionID; - i.name = getDelimitedKeyword(";( /\\"); - if(_file.good()) { - end = seekInstanceEnd(& i.refs); + i.name = getDelimitedKeyword( ";( /\\" ); + if( _file.good() ) { + end = seekInstanceEnd( & i.refs ); } } - if((i.loc.instance == 0) || (!_file.good()) || (end == (std::streampos) - 1)) { + if( ( i.loc.instance == 0 ) || ( !_file.good() ) || ( end == ( std::streampos ) - 1 ) ) { //invalid instance, so clear everything - _file.seekg(i.loc.begin); + _file.seekg( i.loc.begin ); i.loc.begin = -1; - if(i.refs) { + if( i.refs ) { delete i.refs; } i.name = 0; diff --git a/src/cllazyfile/lazyP21DataSectionReader.h b/src/cllazyfile/lazyP21DataSectionReader.h index a666fdeb2..423679142 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.h +++ b/src/cllazyfile/lazyP21DataSectionReader.h @@ -6,15 +6,13 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader -{ +class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { protected: public: - lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); - void findSectionStart() - { - _sectionStart = findNormalString("DATA", true); + void findSectionStart() { + _sectionStart = findNormalString( "DATA", true ); } /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index b38f626a7..6d2e093e4 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -40,21 +40,20 @@ class SDAI_Application_instance; * 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) -*/ + /* **** + * 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 instances 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 SC_LAZYFILE_EXPORT lazyRefs -{ +class SC_LAZYFILE_EXPORT lazyRefs { public: typedef std::set< instanceID > referentInstances_t; protected: @@ -66,131 +65,126 @@ class SC_LAZYFILE_EXPORT lazyRefs #pragma warning( disable: 4251 ) #endif iaList_t _iaList; - lazyInstMgr *_lim; + lazyInstMgr * _lim; instanceID _id; refMap_t _refMap; referentInstances_t _referentInstances; - SDAI_Application_instance *_inst; + SDAI_Application_instance * _inst; #ifdef _MSC_VER #pragma warning( pop ) #endif - void checkAnInvAttr(const Inverse_attribute *ia) - { - const EntityDescriptor *ed; - const Registry *reg = _lim->getMainRegistry(); - ed = reg->FindEntity(ia->_inverted_entity_id); - subtypesIterator subtypeIter(ed); + 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); + edL.insert( ed ); // 3b - use subtypeIter to add to edL - for(; !subtypeIter.empty(); ++subtypeIter) { - edL.insert(*subtypeIter); + for( ; !subtypeIter.empty(); ++subtypeIter ) { + edL.insert( *subtypeIter ); } //3c - for each item in both _refMap and edL, add it to _referentInstances - potentialReferentInsts(edL); + potentialReferentInsts( edL ); //3d - load each inst - iAstruct ias = invAttr(_inst, ia); + iAstruct ias = invAttr( _inst, ia ); referentInstances_t::iterator insts = _referentInstances.begin(); - for(; insts != _referentInstances.end(); ++insts) { - loadInstIFFreferent(*insts, ias, ia); + 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) { + 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); + _inst->setInvAttr( ia, ias ); + assert( invAttr( _inst, ia ).a == ias.a ); } - EntityAggregate *ea = ias.a; + EntityAggregate * ea = ias.a; //TODO check if duplicate - ea->AddNode(new EntityNode(rinst)); + ea->AddNode( new EntityNode( rinst ) ); } else { - SDAI_Application_instance *ai = ias.i; - if(!ai) { + SDAI_Application_instance * ai = ias.i; + if( !ai ) { ias.i = rinst; - _inst->setInvAttr(ia, ias); - } else if(ai->GetFileId() != (int)inst) { - std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->eDesc->Name(); - std::cerr << " and " << ai << ", #" << ai->GetFileId() << "=" << ai->eDesc->Name() << ") refer to inst "; + _inst->setInvAttr( ia, ias ); + } else if( ai->GetFileId() != (int)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) { + 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) - { + 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); + int rindex = attrIndex( referrer, ia->_inverted_attr_id, ia->_inverted_entity_id ); STEPattribute sa = referrer->attributes[ rindex ]; - assert(sa.getADesc()->BaseType() == ENTITY_TYPE); + assert( sa.getADesc()->BaseType() == ENTITY_TYPE ); bool found = false; - if(sa.getADesc()->IsAggrType()) { + 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) { + 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(); + en = ( EntityNode * ) en->NextNode(); } } else { //single instance - assert(sa.getADesc()->NonRefType() == ENTITY_TYPE); - if(sa.Entity() == _inst) { + assert( sa.getADesc()->NonRefType() == ENTITY_TYPE ); + if( sa.Entity() == _inst ) { found = true; } } - if(!found) { + if( !found ) { std::cerr << "inst #" << _inst->FileId() << " not found in #" << referrer->FileId(); std::cerr << ", attr #" << rindex << " [contents: "; - referrer->STEPwrite(std::cerr); + 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++) { + 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)) { + 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 */) - { + 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) { + 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->eDesc->Name() << std::endl; + std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->getEDesc()->Name() << std::endl; abort(); iAstruct nil = {nullptr}; return nil; @@ -199,14 +193,13 @@ class SC_LAZYFILE_EXPORT lazyRefs /** 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) - { + void potentialReferentInsts( edList_t & edL ) { refMap_t::pair kv = _refMap.begin(); - while(kv.value != 0) { + 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); + for( ; edi != edL.end(); ++edi ) { + if( 0 == strcasecmp( kv.value->c_str(), ( *edi )->Name() ) ) { + _referentInstances.insert( kv.key ); break; } } @@ -216,99 +209,91 @@ class SC_LAZYFILE_EXPORT lazyRefs ///find any inverse attributes, put in `iaList` /// attrs not necessarily in order! - void getInverseAttrs(const EntityDescriptor *ed, iaList_t &iaList) - { + void getInverseAttrs( const EntityDescriptor * ed, iaList_t & iaList ) { iaList.clear(); - supertypesIterator supersIter(ed); - const Inverse_attribute *iAttr; - for(; !supersIter.empty(); ++supersIter) { + 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); + 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); + 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()) { + 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)); + 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) - { + lazyRefs( lazyInstMgr * lmgr ): _lim( lmgr ), _id( 0 ) { _iaList.clear(); } - lazyRefs(lazyInstMgr *lmgr, SDAI_Application_instance *ai): _lim(lmgr), _id(0) - { + lazyRefs( lazyInstMgr * lmgr, SDAI_Application_instance * ai ): _lim( lmgr ), _id( 0 ) { _iaList.clear(); - init(0, ai); + init( 0, ai ); } - lazyRefs(lazyInstMgr *lmgr, instanceID iid): _lim(lmgr) - { + lazyRefs( lazyInstMgr * lmgr, instanceID iid ): _lim( lmgr ) { _iaList.clear(); - init(iid, 0); + init( iid, 0 ); } - ~lazyRefs() - { + ~lazyRefs() { // delete strings in refMap - _refMap.clear(true); + _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) { + 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); + if( !ai ) { + _inst = _lim->loadInstance( iid ); _id = iid; } else { _inst = ai; _id = _inst->GetFileId(); } - _refMap.clear(true); + _refMap.clear( true ); // 1. find inverse attrs with recursion - getInverseAttrs(ai->eDesc, _iaList); + 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()) { + if( _iaList.size() == 0 || !mapRefsToTypes() ) { return; } iaList_t::iterator iai = _iaList.begin(); - for(; iai != _iaList.end(); ++iai) { + for( ; iai != _iaList.end(); ++iai ) { // 3. for each IA, ... - checkAnInvAttr(*iai); + checkAnInvAttr( *iai ); } } - referentInstances_t result() - { + referentInstances_t result() { return _referentInstances; } diff --git a/src/cllazyfile/lazyTypes.h b/src/cllazyfile/lazyTypes.h index 35bcc1ba2..0ba2aa671 100644 --- a/src/cllazyfile/lazyTypes.h +++ b/src/cllazyfile/lazyTypes.h @@ -65,8 +65,8 @@ typedef struct { /// used when populating the instance type map \sa lazyInstMgr::_instanceTypeMMap typedef struct { lazyInstanceLoc loc; - const char *name; - instanceRefs *refs; + const char * name; + instanceRefs * refs; } namedLazyInstance; // instanceRefs - map between an instanceID and instances that refer to it diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 3659b4137..87838e467 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,9 +1,7 @@ -#include -#include #include "lazyInstMgr.h" +#include #include "SdaiSchemaInit.h" #include "sc_memmgr.h" -#include "sc_benchmark.h" #include #ifndef NO_REGISTRY @@ -11,33 +9,31 @@ #endif //NO_REGISTRY -void fileInfo(lazyInstMgr &mgr, fileID id) -{ - instancesLoaded_t *headerInsts = mgr.getHeaderInstances(id); - SDAI_Application_instance *hdrInst; - hdrInst = headerInsts->find(3); - if((hdrInst != 0) && (hdrInst->STEPfile_id == 3)) { - SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(hdrInst); - if(fs) { +void fileInfo( lazyInstMgr & mgr, fileID id ) { + instancesLoaded_t * headerInsts = mgr.getHeaderInstances( id ); + SDAI_Application_instance * hdrInst; + hdrInst = headerInsts->find( 3 ); + if( ( hdrInst != 0 ) && ( hdrInst->STEPfile_id == 3 ) ) { + SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( hdrInst ); + if( fs ) { StringAggregate_ptr p = fs->schema_identifiers_(); - StringNode *sn = (StringNode *) p->GetHead(); + StringNode * sn = ( StringNode * ) p->GetHead(); std::cout << "Schema(s): "; - while(sn) { + while( sn ) { std::cout << sn->value.c_str() << " "; - sn = (StringNode *) sn->NextNode(); + sn = ( StringNode * ) sn->NextNode(); } std::cout << std::endl; } } } -void countTypeInstances(lazyInstMgr &mgr, std::string type) -{ - int count = mgr.countInstances(type); +void countTypeInstances( lazyInstMgr & mgr, std::string type ) { + int count = mgr.countInstances( type ); std::cout << type << " instances: " << count; - if(count) { + if( count ) { instanceID ex; - ex = (* mgr.getInstances(type))[ 0 ]; + ex = ( * mgr.getInstances( type ) )[ 0 ]; std::cout << " -- example: #" << ex; } std::cout << std::endl; @@ -45,19 +41,18 @@ void countTypeInstances(lazyInstMgr &mgr, std::string type) } /// Called twice by printRefs. Returns the instanceID of one instance that has a reference. -instanceID printRefs1(instanceRefs_t *refs, bool forward) -{ - const char *d1 = forward ? "forward" : "reverse"; - const char *d2 = forward ? " refers to " : " is referred to by "; +instanceID printRefs1( instanceRefs_t * refs, bool forward ) { + const char * d1 = forward ? "forward" : "reverse"; + const char * d2 = forward ? " refers to " : " is referred to by "; instanceID id = 0; instanceRefs_t::cpair p = refs->begin(); - instanceRefs_t::cvector *v = p.value; - if(!v) { + instanceRefs_t::cvector * v = p.value; + if( !v ) { std::cout << "No " << d1 << " references" << std::endl; } else { - instanceRefs_t::cvector::const_iterator it(v->begin()), end(v->end()); + instanceRefs_t::cvector::const_iterator it( v->begin() ), end( v->end() ); std::cout << "Example of " << d1 << " references - Instance #" << p.key << d2 << v->size() << " other instances: "; - for(; it != end; it++) { + for( ; it != end; it++ ) { std::cout << *it << " "; } std::cout << std::endl; @@ -67,36 +62,34 @@ instanceID printRefs1(instanceRefs_t *refs, bool forward) } ///prints references; returns the instanceID for one instance that has a forward reference -instanceID printRefs(lazyInstMgr &mgr) -{ +instanceID printRefs( lazyInstMgr & mgr ) { instanceID id; std::cout << "\nReferences\n==============\n"; - id = printRefs1(mgr.getFwdRefs(), true); - printRefs1(mgr.getRevRefs(), false); + id = printRefs1( mgr.getFwdRefs(), true ); + printRefs1( mgr.getRevRefs(), false ); std::cout << std::endl; return id; } /// prints dependencies of an instance -void printDeps(lazyInstMgr &mgr) -{ +void printDeps( lazyInstMgr & mgr ) { const int displayInstances = 10; - instanceRefs_t *refs = mgr.getFwdRefs(); + 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()); + 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++) { + for(i = 0; it != end && i < displayInstances; it++, i++ ) { std::cout << *it << " "; } - if(dependencies->size() > displayInstances) { + if( dependencies->size() > displayInstances ) { std::cout << ".... (Displaying only " << displayInstances << " instances) "; } @@ -107,26 +100,25 @@ void printDeps(lazyInstMgr &mgr) } ///prints info about a complex instance -void dumpComplexInst(STEPcomplex *c) -{ +void dumpComplexInst( STEPcomplex * c ) { int depth = 0; - if(c) { + 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! // SDAI_Application_instance * attr = ( SDAI_Application_instance * ) *it; - STEPcomplex *complex = c->head; - while(complex) { - if(complex->IsComplex()) { - std::cout << "Complex component " << complex->eDesc->Name() << " at depth " << depth << " with attr list size "; + 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->eDesc->Name() << std::endl; + 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; } @@ -137,63 +129,60 @@ void dumpComplexInst(STEPcomplex *c) } } -int main(int argc, char **argv) -{ - if(argc != 2) { +int main( int argc, char ** argv ) { + if( argc != 2 ) { std::cerr << "Expected one argument, given " << argc - 1 << ". Exiting." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - lazyInstMgr *mgr = new lazyInstMgr; + lazyInstMgr * mgr = new lazyInstMgr; #ifndef NO_REGISTRY //init schema - mgr->initRegistry(SchemaInit); + mgr->initRegistry( SchemaInit ); #endif //NO_REGISTRY instanceID instWithRef; - benchmark stats; - std::cout << "================ p21 lazy load: scanning the file ================\n"; - mgr->openFile(argv[1]); + benchmark stats( "================ p21 lazy load: scanning the file ================\n" ); + mgr->openFile( argv[1] ); stats.stop(); benchVals scanStats = stats.get(); stats.out(); - std::cout << "================ p21 lazy load: gathering statistics ================\n"; - stats.reset(); + stats.reset( "================ p21 lazy load: gathering statistics ================\n" ); int instances = mgr->totalInstanceCount(); - std::cout << "Total instances: " << instances << " (" << (float)(scanStats.userMilliseconds * 1000) / instances << "us per instance, "; - std::cout << (float)(scanStats.physMemKB * 1000) / instances << " bytes per instance)" << std::endl << std::endl; + std::cout << "Total instances: " << instances << " (" << ( float )( scanStats.userMilliseconds * 1000 ) / instances << "us per instance, "; + std::cout << ( float )( scanStats.physMemKB * 1000 ) / instances << " bytes per instance)" << std::endl << std::endl; - fileInfo(*mgr, 0); + fileInfo( *mgr, 0 ); //these are just common types - countTypeInstances(*mgr, "CARTESIAN_POINT"); - countTypeInstances(*mgr, "POSITIVE_LENGTH_MEASURE"); - countTypeInstances(*mgr, "VERTEX_POINT"); + countTypeInstances( *mgr, "CARTESIAN_POINT" ); + countTypeInstances( *mgr, "POSITIVE_LENGTH_MEASURE" ); + countTypeInstances( *mgr, "VERTEX_POINT" ); //complex instances std::cout << "Complex"; - countTypeInstances(*mgr, ""); + countTypeInstances( *mgr, "" ); std::cout << "Longest type name: " << mgr->getLongestTypeName() << std::endl; // std::cout << "Total types: " << mgr->getNumTypes() << std::endl; - instWithRef = printRefs(*mgr); - printDeps(*mgr); + instWithRef = printRefs( *mgr ); + printDeps( *mgr ); #ifndef NO_REGISTRY - if(instWithRef) { + if( instWithRef ) { std::cout << "Number of data section instances fully loaded: " << mgr->loadedInstanceCount() << std::endl; std::cout << "Loading #" << instWithRef; - SDAI_Application_instance *inst = mgr->loadInstance(instWithRef); + SDAI_Application_instance * inst = mgr->loadInstance( instWithRef ); std::cout << " which is of type " << inst->EntityName() << std::endl; std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } - instanceTypes_t::cvector *complexInsts = mgr->getInstances(""); - if(complexInsts && complexInsts->size() > 0) { - std::cout << "loading complex instance #" << complexInsts->at(0) << "." << std::endl; - STEPcomplex *c = dynamic_cast(mgr->loadInstance(complexInsts->at(0))); - dumpComplexInst(c); + instanceTypes_t::cvector * complexInsts = mgr->getInstances( "" ); + if( complexInsts && complexInsts->size() > 0 ) { + std::cout << "loading complex instance #" << complexInsts->at( 0 ) << "." << std::endl; + STEPcomplex * c = dynamic_cast( mgr->loadInstance( complexInsts->at( 0 ) ) ); + dumpComplexInst( c ); std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } #else @@ -201,8 +190,7 @@ int main(int argc, char **argv) #endif //NO_REGISTRY stats.out(); - std::cout << "================ p21 lazy load: freeing memory ================\n"; - stats.reset(); + stats.reset( "================ p21 lazy load: freeing memory ================\n" ); delete mgr; //stats will print from its destructor } diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index e1f3f7fff..bcb78ac83 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -8,56 +8,53 @@ #include "judyL2Array.h" -void p21HeaderSectionReader::findSectionStart() -{ - _sectionStart = findNormalString("HEADER", true); - assert(_file.is_open() && _file.good()); +void p21HeaderSectionReader::findSectionStart() { + _sectionStart = findNormalString( "HEADER", true ); + assert( _file.is_open() && _file.good() ); } -p21HeaderSectionReader::p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - headerSectionReader(parent, file, start, sid) -{ +p21HeaderSectionReader::p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + headerSectionReader( parent, file, start, sid ) { findSectionStart(); findSectionEnd(); - _file.seekg(_sectionStart); + _file.seekg( _sectionStart ); namedLazyInstance nl; - while(nl = nextInstance(), (nl.loc.begin > 0)) { + while( nl = nextInstance(), ( nl.loc.begin > 0 ) ) { std::streampos pos = _file.tellg(); - _headerInstances->insert(nl.loc.instance, getRealInstance(_lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true)); - _file.seekg(pos); //reset stream position for next call to nextInstance() + _headerInstances->insert( nl.loc.instance, getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true ) ); + _file.seekg( pos ); //reset stream position for next call to nextInstance() } - _file.seekg(_sectionEnd); + _file.seekg( _sectionEnd ); } // part of readdata1 -const namedLazyInstance p21HeaderSectionReader::nextInstance() -{ +const namedLazyInstance p21HeaderSectionReader::nextInstance() { namedLazyInstance i; static instanceID nextFreeInstance = 4; // 1-3 are reserved per 10303-21 i.loc.begin = _file.tellg(); i.loc.section = _sectionID; skipWS(); - if(i.loc.begin <= 0) { + if( i.loc.begin <= 0 ) { i.name = 0; } else { - i.name = getDelimitedKeyword(";( /\\"); + i.name = getDelimitedKeyword( ";( /\\" ); - if(0 == strcmp("FILE_DESCRIPTION", i.name)) { + if( 0 == strcmp( "FILE_DESCRIPTION", i.name ) ) { i.loc.instance = 1; - } else if(0 == strcmp("FILE_NAME", i.name)) { + } else if( 0 == strcmp( "FILE_NAME", i.name ) ) { i.loc.instance = 2; - } else if(0 == strcmp("FILE_SCHEMA", i.name)) { + } else if( 0 == strcmp( "FILE_SCHEMA", i.name ) ) { i.loc.instance = 3; } else { i.loc.instance = nextFreeInstance++; } - assert(strlen(i.name) > 0); + assert( strlen( i.name ) > 0 ); - std::streampos end = seekInstanceEnd(0); //no references in file header - if(((signed long int)end == -1) || (end >= _sectionEnd)) { + std::streampos end = seekInstanceEnd( 0 ); //no references in file header + if( ( (signed long int)end == -1 ) || ( end >= _sectionEnd ) ) { //invalid instance, so clear everything i.loc.begin = -1; i.name = 0; diff --git a/src/cllazyfile/p21HeaderSectionReader.h b/src/cllazyfile/p21HeaderSectionReader.h index 5a4aea3ca..b5ce04948 100644 --- a/src/cllazyfile/p21HeaderSectionReader.h +++ b/src/cllazyfile/p21HeaderSectionReader.h @@ -5,10 +5,9 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader -{ +class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { public: - p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); void findSectionStart(); /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index cf38bb3c5..7a6053a46 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -20,61 +20,59 @@ #include "current_function.hpp" -sectionReader::sectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid): - _lazyFile(parent), _file(file), _sectionStart(start), _sectionID(sid) -{ +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(); } -std::streampos sectionReader::findNormalString(const std::string &str, bool semicolon) -{ +std::streampos sectionReader::findNormalString( const std::string & str, bool semicolon ) { std::streampos found = -1, startPos = _file.tellg(), nextTry = startPos; int i = 0, l = str.length(); char c; //i is reset every time a character doesn't match; if i == l, this means that we've found the entire string - while(i < l || semicolon) { + while( i < l || semicolon ) { skipWS(); c = _file.get(); - if((i == l) && (semicolon)) { - if(c == ';') { + if( ( i == l ) && ( semicolon ) ) { + if( c == ';' ) { break; } else { i = 0; - _file.seekg(nextTry); + _file.seekg( nextTry ); continue; } } - if(c == '\'') { + if( c == '\'' ) { //push past string - _file.seekg(_file.tellg() - std::streampos(1)); - GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); + _file.seekg( _file.tellg() - std::streampos(1) ); + GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); } - if((c == '/') && (_file.peek() == '*')) { + if( ( c == '/' ) && ( _file.peek() == '*' ) ) { //push past comment - findNormalString("*/"); + findNormalString( "*/" ); } - if(str[i] == c) { + if( str[i] == c ) { i++; - if(i == 1) { + if( i == 1 ) { nextTry = _file.tellg(); } } else { - if(!_file.good()) { + if( !_file.good() ) { break; } - if(i >= 1) { - _file.seekg(nextTry); + if( i >= 1 ) { + _file.seekg( nextTry ); } i = 0; } } - if(i == l) { + if( i == l ) { found = _file.tellg(); } - if(_file.is_open() && _file.good()) { + if( _file.is_open() && _file.good() ) { return found; } else { return -1; @@ -84,29 +82,28 @@ std::streampos sectionReader::findNormalString(const std::string &str, bool semi //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) -{ +const char * sectionReader::getDelimitedKeyword( const char * delimiters ) { static std::string str; char c; str.clear(); - str.reserve(100); + str.reserve( 100 ); skipWS(); - while(c = _file.get(), _file.good()) { - if(c == '-' || c == '_' || isupper(c) || isdigit(c) || - (c == '!' && str.length() == 0)) { - str.append(1, c); - } else if((c == '/') && (_file.peek() == '*') && (str.length() == 0)) { + while( c = _file.get(), _file.good() ) { + if( c == '-' || c == '_' || isupper( c ) || isdigit( c ) || + ( c == '!' && str.length() == 0 ) ) { + str.append( 1, c ); + } else if( ( c == '/' ) && ( _file.peek() == '*' ) && ( str.length() == 0 ) ) { //push past comment - findNormalString("*/"); + findNormalString( "*/" ); skipWS(); continue; } else { - _file.putback(c); + _file.putback( c ); break; } } c = _file.peek(); - if(!strchr(delimiters, c)) { + if( !strchr( delimiters, c ) ) { std::cerr << SC_CURRENT_FUNCTION << ": missing delimiter. Found " << c << ", expected one of " << delimiters << " at end of keyword " << str << ". File offset: " << _file.tellg() << std::endl; abort(); } @@ -116,50 +113,49 @@ const char *sectionReader::getDelimitedKeyword(const char *delimiters) /// search forward in the file for the end of the instance. Start position should /// be the opening parenthesis; otherwise, it is likely to fail. ///NOTE *must* check return value! -std::streampos sectionReader::seekInstanceEnd(instanceRefs **refs) -{ +std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { char c; int parenDepth = 0; - while(c = _file.get(), _file.good()) { - switch(c) { + while( c = _file.get(), _file.good() ) { + switch( c ) { case '(': parenDepth++; break; case '/': - if(_file.peek() == '*') { - findNormalString("*/"); + if( _file.peek() == '*' ) { + findNormalString( "*/" ); } else { return -1; } break; case '\'': - _file.seekg(_file.tellg() - std::streampos(1)); - GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); + _file.seekg( _file.tellg() - std::streampos(1) ); + GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); break; case '=': return -1; case '#': skipWS(); - if(isdigit(_file.peek())) { - if(refs != 0) { - if(! * refs) { + if( isdigit( _file.peek() ) ) { + if( refs != 0 ) { + if( ! * refs ) { *refs = new std::vector< instanceID >; } instanceID n; _file >> n; - (* refs)->push_back(n); + ( * refs )->push_back( n ); } } else { return -1; } break; case ')': - if(--parenDepth == 0) { + if( --parenDepth == 0 ) { skipWS(); - if(_file.get() == ';') { + if( _file.get() == ';' ) { return _file.tellg(); } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); } } default: @@ -172,16 +168,14 @@ std::streampos sectionReader::seekInstanceEnd(instanceRefs **refs) // new memory: 673340kb; User CPU time: 29890ms; System CPU time: 11650ms } -void sectionReader::locateAllInstances() -{ +void sectionReader::locateAllInstances() { namedLazyInstance inst; - while(inst = nextInstance(), (_file.good()) && (inst.loc.begin > 0)) { - _lazyFile->getInstMgr()->addLazyInstance(inst); + while( inst = nextInstance(), ( _file.good() ) && ( inst.loc.begin > 0 ) ) { + _lazyFile->getInstMgr()->addLazyInstance( inst ); } } -instanceID sectionReader::readInstanceNumber() -{ +instanceID sectionReader::readInstanceNumber() { char c; size_t digits = 0; instanceID id = 0; @@ -189,64 +183,64 @@ instanceID sectionReader::readInstanceNumber() //find instance number ("# nnnn ="), where ' ' is any whitespace found by isspace() skipWS(); c = _file.get(); - if((c == '/') && (_file.peek() == '*')) { - findNormalString("*/"); + if( ( c == '/' ) && ( _file.peek() == '*' ) ) { + findNormalString( "*/" ); } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); } skipWS(); c = _file.get(); - if(c != '#') { + if( c != '#' ) { return 0; } skipWS(); // The largest instance ID yet supported is the maximum value of unsigned long long int - assert(std::numeric_limits::max() <= std::numeric_limits::max()); + assert( std::numeric_limits::max() <= std::numeric_limits::max() ); size_t instanceIDLength = std::numeric_limits::digits10 + 1; - char *buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character - + char * buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character + std::stringstream errorMsg; do { c = _file.get(); - if(isdigit(c)) { + if( isdigit( c ) ) { buffer[ digits ] = c; //copy the character into the buffer digits++; } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); break; } - if(digits > instanceIDLength) { + 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()); + _error->GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error->UserMsg( "A very large instance ID encountered" ); + _error->DetailMsg( errorMsg.str() ); delete buffer; - return 0; + return 0; } - } while(_file.good()); + } while( _file.good() ); buffer[ digits ] = '\0'; //Append the terminating character skipWS(); - if(_file.good() && (digits > 0) && (_file.get() == '=')) { - id = strtoull(buffer, NULL, 10); - if(id == std::numeric_limits::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. + if( _file.good() && ( digits > 0 ) && ( _file.get() == '=' ) ) { + id = strtoull( buffer, NULL, 10); + if( id == std::numeric_limits::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()); + _error->GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error->UserMsg( "A very large instance ID encountered" ); + _error->DetailMsg( errorMsg.str() ); } - assert(id > 0); + assert( id > 0 ); } delete [] buffer; return id; @@ -255,25 +249,24 @@ instanceID sectionReader::readInstanceNumber() /** 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) -{ +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 + const char * tName = 0, * sName = 0; //these are necessary since typeName and schName are const std::string comment; Severity sev = SEVERITY_NULL; - SDAI_Application_instance *inst = 0; + SDAI_Application_instance * inst = 0; tName = typeName.c_str(); - if(schName.size() > 0) { + if( schName.size() > 0 ) { sName = schName.c_str(); - } else if(!header) { - SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(_lazyFile->getHeaderInstances()->find(3)); - if(fs) { - StringNode *sn = (StringNode *) fs->schema_identifiers_()->GetHead(); - if(sn) { + } else if( !header ) { + SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( _lazyFile->getHeaderInstances()->find( 3 ) ); + if( fs ) { + StringNode * sn = ( StringNode * ) fs->schema_identifiers_()->GetHead(); + if( sn ) { sName = sn->value.c_str(); - if(sn->NextNode()) { + if( sn->NextNode() ) { std::cerr << "Warning - multiple schema names found. Only searching with first one." << std::endl; } } @@ -282,79 +275,78 @@ SDAI_Application_instance *sectionReader::getRealInstance(const Registry *reg, l } } - _file.seekg(begin); + _file.seekg( begin ); skipWS(); - ReadTokenSeparator(_file, &comment); - if(!header) { - findNormalString("="); + ReadTokenSeparator( _file, &comment ); + if( !header ) { + findNormalString( "=" ); } skipWS(); - ReadTokenSeparator(_file, &comment); + ReadTokenSeparator( _file, &comment ); c = _file.peek(); - switch(c) { + switch( c ) { case '&': std::cerr << "Can't handle scope instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; // sev = CreateScopeInstances( in, &scopelist ); break; case '(': - inst = CreateSubSuperInstance(reg, instance, sev); + inst = CreateSubSuperInstance( reg, instance, sev ); break; case '!': std::cerr << "Can't handle user-defined instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; break; default: - if((!header) && (typeName.size() == 0)) { - tName = getDelimitedKeyword(";( /\\"); + if( ( !header ) && ( typeName.size() == 0 ) ) { + tName = getDelimitedKeyword( ";( /\\" ); } - inst = reg->ObjCreate(tName, sName); + inst = reg->ObjCreate( tName, sName ); break; } - if(!isNilSTEPentity(inst)) { - if(!comment.empty()) { - inst->AddP21Comment(comment); + if( !isNilSTEPentity( inst ) ) { + if( !comment.empty() ) { + inst->AddP21Comment( comment ); } - assert(inst->eDesc); - _file.seekg(begin); - findNormalString("("); - _file.seekg(_file.tellg() - std::streampos(1)); - sev = inst->STEPread(instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false); + assert( inst->getEDesc() ); + _file.seekg( begin ); + findNormalString( "(" ); + _file.seekg( _file.tellg() - std::streampos(1) ); + sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false ); //TODO do something with 'sev' inst->InitIAttrs(); } return inst; } -STEPcomplex *sectionReader::CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &) -{ +STEPcomplex * sectionReader::CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & ) { std::string buf; ErrorDescriptor err; std::vector typeNames; _file.get(); //move past the first '(' skipWS(); - while(_file.good() && (_file.peek() != ')')) { - typeNames.push_back(new std::string(getDelimitedKeyword(";( /\\\n"))); - if(typeNames.back()->empty()) { + while( _file.good() && ( _file.peek() != ')' ) ) { + typeNames.push_back( new std::string( getDelimitedKeyword( ";( /\\\n" ) ) ); + if( typeNames.back()->empty() ) { delete typeNames.back(); typeNames.pop_back(); } else { - SkipSimpleRecord(_file, buf, &err); //exactly what does this do? if it doesn't count parenthesis, it probably should + SkipSimpleRecord( _file, buf, &err ); //exactly what does this do? if it doesn't count parenthesis, it probably should buf.clear(); } skipWS(); - if(_file.peek() != ')') { + if( _file.peek() != ')' ) { // do something } } // STEPComplex needs an array of strings or of char*. construct the latter using c_str() on all strings in the vector //FIXME: STEPComplex ctor should accept std::vector ? const int s = typeNames.size(); - const char **names = new const char *[ s + 1 ]; + const char ** names = new const char * [ s + 1 ]; names[ s ] = 0; - for(int i = 0; i < s; i++) { + for( int i = 0; i < s; i++ ) { names[ i ] = typeNames[i]->c_str(); } //TODO still need the schema name - STEPcomplex *sc = new STEPcomplex((const_cast(reg)), names, (int) fileid /*, schnm*/); + STEPcomplex * sc = new STEPcomplex( ( const_cast( reg ) ), names, ( int ) fileid /*, schnm*/ ); delete[] names; //TODO also delete contents of typeNames! return sc; diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index c6508669d..c6a64b55a 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -14,16 +14,15 @@ class lazyFileReader; class ErrorDescriptor; class Registry; -class SC_LAZYFILE_EXPORT sectionReader -{ +class SC_LAZYFILE_EXPORT sectionReader { protected: //protected data members - lazyFileReader *_lazyFile; + lazyFileReader * _lazyFile; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::ifstream &_file; + std::ifstream & _file; std::streampos _sectionStart, ///< the start of this section as reported by tellg() _sectionEnd; ///< the end of this section as reported by tellg() @@ -32,61 +31,56 @@ class SC_LAZYFILE_EXPORT sectionReader #endif unsigned long _totalInstances; - ErrorDescriptor *_error; + ErrorDescriptor * _error; sectionID _sectionID; fileID _fileID; // protected member functions - sectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); /** Find a string, ignoring occurrences in comments or Part 21 strings (i.e. 'string with \S\' control directive' ) * \param str string to find * \param semicolon if true, 'str' must be followed by a semicolon, possibly preceded by whitespace. * \returns the position of the end of the found string */ - std::streampos findNormalString(const std::string &str, bool semicolon = false); + std::streampos findNormalString( const std::string & str, bool semicolon = false ); /** Get a keyword ending with one of delimiters. */ - const char *getDelimitedKeyword(const char *delimiters); + const char * getDelimitedKeyword( const char * delimiters ); /** Seek to the end of the current instance */ - std::streampos seekInstanceEnd(instanceRefs **refs); + std::streampos seekInstanceEnd( instanceRefs ** refs ); /// operator>> is very slow?! - inline void skipWS() - { - while(isspace(_file.peek()) && _file.good()) { - _file.ignore(1); + inline void skipWS() { + while( isspace( _file.peek() ) && _file.good() ) { + _file.ignore( 1 ); } } - STEPcomplex *CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &sev); + STEPcomplex * CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & sev ); public: - SDAI_Application_instance *getRealInstance(const Registry *reg, long int begin, instanceID instance, - const std::string &typeName = "", const std::string &schName = "", bool header = false); + SDAI_Application_instance * getRealInstance( const Registry * reg, long int begin, instanceID instance, + const std::string & typeName = "", const std::string & schName = "", bool header = false ); - sectionID ID() const - { + sectionID ID() const { return _sectionID; } virtual void findSectionStart() = 0; - void findSectionEnd() - { - _sectionEnd = findNormalString("ENDSEC", true); + void findSectionEnd() { + _sectionEnd = findNormalString( "ENDSEC", true ); } - std::streampos sectionStart() const - { + std::streampos sectionStart() const { return _sectionStart; } - std::streampos sectionEnd() const - { + std::streampos sectionEnd() const { return _sectionEnd; } @@ -97,25 +91,22 @@ class SC_LAZYFILE_EXPORT sectionReader /** 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) { + const char * getType( long int offset ) { + if( offset <= 0 ) { return 0; } - _file.seekg(offset); + _file.seekg( offset ); readInstanceNumber(); skipWS(); - return getDelimitedKeyword(";( /\\"); + return getDelimitedKeyword( ";( /\\" ); } instanceID readInstanceNumber(); - void seekg(std::streampos pos) - { - _file.seekg(pos); + void seekg( std::streampos pos ) { + _file.seekg( pos ); } - std::streampos tellg() - { + std::streampos tellg() { return _file.tellg(); } }; diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 910235973..937985fff 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -133,19 +133,19 @@ include_directories( set(_libdeps steputils stepdai base) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLSTEPCORE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 11ddde52a..6bbd3eaff 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -15,58 +15,55 @@ /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ -const TypeDescriptor *const t_sdaiINTEGER = new TypeDescriptor("INTEGER", sdaiINTEGER, 0, "INTEGER"); -const TypeDescriptor *const t_sdaiREAL = new TypeDescriptor("REAL", sdaiREAL, 0, "Real"); -const TypeDescriptor *const t_sdaiNUMBER = new TypeDescriptor("NUMBER", sdaiNUMBER, 0, "Number"); -const TypeDescriptor *const t_sdaiSTRING = new TypeDescriptor("STRING", sdaiSTRING, 0, "String"); -const TypeDescriptor *const t_sdaiBINARY = new TypeDescriptor("BINARY", sdaiBINARY, 0, "Binary"); -const TypeDescriptor *const t_sdaiBOOLEAN = new TypeDescriptor("BOOLEAN", sdaiBOOLEAN, 0, "Boolean"); -const TypeDescriptor *const t_sdaiLOGICAL = new TypeDescriptor("LOGICAL", sdaiLOGICAL, 0, "Logical"); - -static int uniqueNames(const char *, const SchRename *); - -Registry::Registry(CF_init initFunct) - : col(0), entity_cnt(0), all_ents_cnt(0) -{ - - primordialSwamp = SC_HASHcreate(1000); - active_schemas = SC_HASHcreate(10); - active_types = SC_HASHcreate(100); - - initFunct(*this); - SC_HASHlistinit(active_types, &cur_type); - SC_HASHlistinit(primordialSwamp, &cur_entity); // initialize cur's - SC_HASHlistinit(active_schemas, &cur_schema); +const TypeDescriptor * const t_sdaiINTEGER = new TypeDescriptor( "INTEGER", sdaiINTEGER, 0, "INTEGER" ); +const TypeDescriptor * const t_sdaiREAL = new TypeDescriptor( "REAL", sdaiREAL, 0, "Real" ); +const TypeDescriptor * const t_sdaiNUMBER = new TypeDescriptor( "NUMBER", sdaiNUMBER, 0, "Number" ); +const TypeDescriptor * const t_sdaiSTRING = new TypeDescriptor( "STRING", sdaiSTRING, 0, "String" ); +const TypeDescriptor * const t_sdaiBINARY = new TypeDescriptor( "BINARY", sdaiBINARY, 0, "Binary" ); +const TypeDescriptor * const t_sdaiBOOLEAN = new TypeDescriptor( "BOOLEAN", sdaiBOOLEAN, 0, "Boolean" ); +const TypeDescriptor * const t_sdaiLOGICAL = new TypeDescriptor( "LOGICAL", sdaiLOGICAL, 0, "Logical" ); + +static int uniqueNames( const char *, const SchRename * ); + +Registry::Registry( CF_init initFunct ) + : col( 0 ), entity_cnt( 0 ), all_ents_cnt( 0 ) { + + primordialSwamp = SC_HASHcreate( 1000 ); + active_schemas = SC_HASHcreate( 10 ); + active_types = SC_HASHcreate( 100 ); + + initFunct( *this ); + SC_HASHlistinit( active_types, &cur_type ); + SC_HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur's + SC_HASHlistinit( active_schemas, &cur_schema ); } -Registry::~Registry() -{ +Registry::~Registry() { DeleteContents(); - SC_HASHdestroy(primordialSwamp); - SC_HASHdestroy(active_schemas); - SC_HASHdestroy(active_types); + SC_HASHdestroy( primordialSwamp ); + SC_HASHdestroy( active_schemas ); + SC_HASHdestroy( active_types ); delete col; } -void Registry::DeleteContents() -{ +void Registry::DeleteContents() { // entities first - SC_HASHlistinit(primordialSwamp, &cur_entity); - while(SC_HASHlist(&cur_entity)) { - delete(EntityDescriptor *) cur_entity.e->data; + SC_HASHlistinit( primordialSwamp, &cur_entity ); + while( SC_HASHlist( &cur_entity ) ) { + delete( EntityDescriptor * ) cur_entity.e->data; } // schemas - SC_HASHlistinit(active_schemas, &cur_schema); - while(SC_HASHlist(&cur_schema)) { - delete(Schema *) cur_schema.e->data; + SC_HASHlistinit( active_schemas, &cur_schema ); + while( SC_HASHlist( &cur_schema ) ) { + delete( Schema * ) cur_schema.e->data; } // types - SC_HASHlistinit(active_types, &cur_type); - while(SC_HASHlist(&cur_type)) { - delete(TypeDescriptor *) cur_type.e->data; + SC_HASHlistinit( active_types, &cur_type ); + while( SC_HASHlist( &cur_type ) ) { + delete( TypeDescriptor * ) cur_type.e->data; } } @@ -79,34 +76,33 @@ void Registry::DeleteContents() * entity A from schema Y and renames it to B, X should only refer to A as * B. Thus, if schNm here = "X", only e="B" would be valid but not e="A". */ -const EntityDescriptor *Registry::FindEntity(const char *e, const char *schNm, int check_case) const -{ - const EntityDescriptor *entd; - const SchRename *altlist; +const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const { + const EntityDescriptor * entd; + const SchRename * altlist; char schformat[BUFSIZ], altName[BUFSIZ]; - if(check_case) { - entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, (char *)e); + if( check_case ) { + entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, ( char * )e ); } else { - entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, - (char *)PrettyTmpName(e)); + entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, + ( char * )PrettyTmpName( e ) ); } - if(entd && schNm) { + if( entd && schNm ) { // We've now found an entity. If schNm has a value, we must ensure we // have a valid name. - strcpy(schformat, PrettyTmpName(schNm)); - if(((altlist = entd->AltNameList()) != 0) - && (altlist->rename(schformat, altName))) { + strcpy( schformat, PrettyTmpName( schNm ) ); + if( ( ( altlist = entd->AltNameList() ) != 0 ) + && ( altlist->rename( schformat, altName ) ) ) { // If entd has other name choices, and entd is referred to with a // new name by schema schNm, then e had better = the new name. - if(!StrCmpIns(e, altName)) { + if( !StrCmpIns( e, altName ) ) { return entd; } return NULL; - } else if(FindSchema(schformat, 1)) { + } else if( FindSchema( schformat, 1 ) ) { // If schema schNm exists but we had no conditions above to use an // altName, we must use the original name: - if(!StrCmpIns(e, entd->Name())) { + if( !StrCmpIns( e, entd->Name() ) ) { return entd; } return NULL; @@ -120,55 +116,48 @@ const EntityDescriptor *Registry::FindEntity(const char *e, const char *schNm, i return entd; } -const Schema *Registry::FindSchema(const char *n, int check_case) const -{ - if(check_case) { - return (const Schema *) SC_HASHfind(active_schemas, (char *) n); +const Schema * Registry::FindSchema( const char * n, int check_case ) const { + if( check_case ) { + return ( const Schema * ) SC_HASHfind( active_schemas, ( char * ) n ); } - return (const Schema *) SC_HASHfind(active_schemas, - (char *)PrettyTmpName(n)); + return ( const Schema * ) SC_HASHfind( active_schemas, + ( char * )PrettyTmpName( n ) ); } -const TypeDescriptor *Registry::FindType(const char *n, int check_case) const -{ - if(check_case) { - return (const TypeDescriptor *) SC_HASHfind(active_types, (char *) n); +const TypeDescriptor * Registry::FindType( const char * n, int check_case ) const { + if( check_case ) { + return ( const TypeDescriptor * ) SC_HASHfind( active_types, ( char * ) n ); } - return (const TypeDescriptor *) SC_HASHfind(active_types, - (char *)PrettyTmpName(n)); + return ( const TypeDescriptor * ) SC_HASHfind( active_types, + ( char * )PrettyTmpName( n ) ); } -void Registry::ResetTypes() -{ - SC_HASHlistinit(active_types, &cur_type); +void Registry::ResetTypes() { + SC_HASHlistinit( active_types, &cur_type ); } -const TypeDescriptor *Registry::NextType() -{ - if(0 == SC_HASHlist(&cur_type)) { +const TypeDescriptor * Registry::NextType() { + if( 0 == SC_HASHlist( &cur_type ) ) { return 0; } - return (const TypeDescriptor *) cur_type.e->data; + return ( const TypeDescriptor * ) cur_type.e->data; } -void Registry::AddEntity(const EntityDescriptor &e) -{ - SC_HASHinsert(primordialSwamp, (char *) e.Name(), (EntityDescriptor *) &e); +void Registry::AddEntity( const EntityDescriptor & e ) { + SC_HASHinsert( primordialSwamp, ( char * ) e.Name(), ( EntityDescriptor * ) &e ); ++entity_cnt; ++all_ents_cnt; - AddClones(e); + AddClones( e ); } -void Registry::AddSchema(const Schema &d) -{ - SC_HASHinsert(active_schemas, (char *) d.Name(), (Schema *) &d); +void Registry::AddSchema( const Schema & d ) { + SC_HASHinsert( active_schemas, ( char * ) d.Name(), ( Schema * ) &d ); } -void Registry::AddType(const TypeDescriptor &d) -{ - SC_HASHinsert(active_types, (char *) d.Name(), (TypeDescriptor *) &d); +void Registry::AddType( const TypeDescriptor & d ) { + SC_HASHinsert( active_types, ( char * ) d.Name(), ( TypeDescriptor * ) &d ); } /** @@ -178,16 +167,15 @@ void Registry::AddType(const TypeDescriptor &d) * so that if we comes across one of them in a Part 21 file, we'll recog- * nize it. */ -void Registry::AddClones(const EntityDescriptor &e) -{ - const SchRename *alts = e.AltNameList(); +void Registry::AddClones( const EntityDescriptor & e ) { + const SchRename * alts = e.AltNameList(); - while(alts) { - SC_HASHinsert(primordialSwamp, (char *)alts->objName(), - (EntityDescriptor *)&e); + while( alts ) { + SC_HASHinsert( primordialSwamp, ( char * )alts->objName(), + ( EntityDescriptor * )&e ); alts = alts->next; } - all_ents_cnt += uniqueNames(e.Name(), e.AltNameList()); + all_ents_cnt += uniqueNames( e.Name(), e.AltNameList() ); } /** @@ -196,14 +184,13 @@ void Registry::AddClones(const EntityDescriptor &e) * does the same (or if C simply uses yy from B), altlist will contain 2 * entries with the same alt name. */ -static int uniqueNames(const char *entnm, const SchRename *altlist) -{ +static int uniqueNames( const char * entnm, const SchRename * altlist ) { int cnt = 0; - const SchRename *alt = altlist; + const SchRename * alt = altlist; - while(alt) { - if(!((alt->next && alt->next->choice(alt->objName())) - || !StrCmpIns(alt->objName(), entnm))) { + while( alt ) { + if( !( ( alt->next && alt->next->choice( alt->objName() ) ) + || !StrCmpIns( alt->objName(), entnm ) ) ) { // alt has a unique alternate name if it's not reused by a later // alt. alt->next->choice() returns 1 if one of the later alts // also has alt's name as its value. The final condition checks @@ -219,66 +206,61 @@ static int uniqueNames(const char *entnm, const SchRename *altlist) return cnt; } -void Registry::RemoveEntity(const char *n) -{ - const EntityDescriptor *e = FindEntity(n); +void Registry::RemoveEntity( const char * n ) { + const EntityDescriptor * e = FindEntity( n ); struct Element tmp; - if(e) { - RemoveClones(*e); + if( e ) { + RemoveClones( *e ); } - tmp.key = (char *) n; - SC_HASHsearch(primordialSwamp, &tmp, HASH_DELETE) ? --entity_cnt : 0; + tmp.key = ( char * ) n; + SC_HASHsearch( primordialSwamp, &tmp, HASH_DELETE ) ? --entity_cnt : 0; } -void Registry::RemoveSchema(const char *n) -{ +void Registry::RemoveSchema( const char * n ) { struct Element tmp; - tmp.key = (char *) n; - SC_HASHsearch(active_schemas, &tmp, HASH_DELETE); + tmp.key = ( char * ) n; + SC_HASHsearch( active_schemas, &tmp, HASH_DELETE ); } -void Registry::RemoveType(const char *n) -{ +void Registry::RemoveType( const char * n ) { struct Element tmp; - tmp.key = (char *) n; - SC_HASHsearch(active_types, &tmp, HASH_DELETE); + tmp.key = ( char * ) n; + SC_HASHsearch( active_types, &tmp, HASH_DELETE ); } /** * Remove all the "clones", or rename values of e. */ -void Registry::RemoveClones(const EntityDescriptor &e) -{ - const SchRename *alts = e.AltNameList(); - struct Element *tmp; +void Registry::RemoveClones( const EntityDescriptor & e ) { + const SchRename * alts = e.AltNameList(); + struct Element * tmp; - while(alts) { + while( alts ) { tmp = new Element; - tmp->key = (char *) alts->objName(); - SC_HASHsearch(primordialSwamp, tmp, HASH_DELETE); + tmp->key = ( char * ) alts->objName(); + SC_HASHsearch( primordialSwamp, tmp, HASH_DELETE ); alts = alts->next; } } -SDAI_Application_instance *Registry::ObjCreate(const char *nm, const char *schnm, int check_case) const -{ - const EntityDescriptor *entd = FindEntity(nm, schnm, check_case); - if(entd) { - SDAI_Application_instance *se = - ((EntityDescriptor *)entd) -> NewSTEPentity(); +SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * schnm, int check_case ) const { + const EntityDescriptor * entd = FindEntity( nm, schnm, check_case ); + if( entd ) { + SDAI_Application_instance * se = + ( ( EntityDescriptor * )entd ) -> NewSTEPentity(); // See comment in previous function. - if(entd->AbstractEntity().asInt() == 1) { - se->Error().severity(SEVERITY_WARNING); - se->Error().UserMsg("ENTITY is abstract supertype"); - } else if(entd->ExtMapping().asInt() == 1) { - se->Error().severity(SEVERITY_WARNING); - se->Error().UserMsg("ENTITY requires external mapping"); + if( entd->AbstractEntity().asInt() == 1 ) { + se->Error().severity( SEVERITY_WARNING ); + se->Error().UserMsg( "ENTITY is abstract supertype" ); + } else if( entd->ExtMapping().asInt() == 1 ) { + se->Error().severity( SEVERITY_WARNING ); + se->Error().UserMsg( "ENTITY requires external mapping" ); } - se->eDesc = entd; + se->setEDesc( entd ); return se; } else { return ENTITY_NULL; @@ -286,34 +268,29 @@ SDAI_Application_instance *Registry::ObjCreate(const char *nm, const char *schnm } -int Registry::GetEntityCnt() -{ +int Registry::GetEntityCnt() { return entity_cnt; } -void Registry::ResetEntities() -{ - SC_HASHlistinit(primordialSwamp, &cur_entity); +void Registry::ResetEntities() { + SC_HASHlistinit( primordialSwamp, &cur_entity ); } -const EntityDescriptor *Registry::NextEntity() -{ - if(0 == SC_HASHlist(&cur_entity)) { +const EntityDescriptor * Registry::NextEntity() { + if( 0 == SC_HASHlist( &cur_entity ) ) { return 0; } - return (const EntityDescriptor *) cur_entity.e->data; + return ( const EntityDescriptor * ) cur_entity.e->data; } -void Registry::ResetSchemas() -{ - SC_HASHlistinit(active_schemas, &cur_schema); +void Registry::ResetSchemas() { + SC_HASHlistinit( active_schemas, &cur_schema ); } -const Schema *Registry::NextSchema() -{ - if(0 == SC_HASHlist(&cur_schema)) { +const Schema * Registry::NextSchema() { + if( 0 == SC_HASHlist( &cur_schema ) ) { return 0; } - return (const Schema *) cur_schema.e->data; + return ( const Schema * ) cur_schema.e->data; } diff --git a/src/clstepcore/Registry.h b/src/clstepcore/Registry.h index d81d7d8c2..d4d4d4db0 100644 --- a/src/clstepcore/Registry.h +++ b/src/clstepcore/Registry.h @@ -21,26 +21,25 @@ // defined and created in Registry.cc -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiINTEGER; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiREAL; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiNUMBER; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiSTRING; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBINARY; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBOOLEAN; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiLOGICAL; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiINTEGER; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiREAL; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiNUMBER; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiSTRING; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBINARY; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBOOLEAN; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiLOGICAL; -typedef struct Hash_Table *HashTable; +typedef struct Hash_Table * HashTable; class Registry; -typedef void (* CF_init)(Registry &); // pointer to creation initialization +typedef void ( * CF_init )( Registry & ); // pointer to creation initialization -class SC_CORE_EXPORT Registry -{ +class SC_CORE_EXPORT Registry { protected: HashTable primordialSwamp; // dictionary of EntityDescriptors HashTable active_schemas; // dictionary of Schemas HashTable active_types; // dictionary of TypeDescriptors - ComplexCollect *col; // struct containing all complex entity info + ComplexCollect * col; // struct containing all complex entity info int entity_cnt, all_ents_cnt; @@ -51,53 +50,50 @@ class SC_CORE_EXPORT Registry // used by AddEntity() and RemoveEntity() to deal with renamings of an // entity done in a USE or REFERENCE clause - see header comments in // file Registry.inline.cc - void AddClones(const EntityDescriptor &); - void RemoveClones(const EntityDescriptor &); + void AddClones( const EntityDescriptor & ); + void RemoveClones( const EntityDescriptor & ); public: - Registry(CF_init initFunct); + Registry( CF_init initFunct ); ~Registry(); void DeleteContents(); // CAUTION: calls delete on all the descriptors - const EntityDescriptor *FindEntity(const char *, const char * = 0, - int check_case = 0) const; - const Schema *FindSchema(const char *, int check_case = 0) const; - const TypeDescriptor *FindType(const char *, int check_case = 0) const; + const EntityDescriptor * FindEntity( const char *, const char * = 0, + int check_case = 0 ) const; + const Schema * FindSchema( const char *, int check_case = 0 ) const; + const TypeDescriptor * FindType( const char *, int check_case = 0 ) const; - void AddEntity(const EntityDescriptor &); - void AddSchema(const Schema &); - void AddType(const TypeDescriptor &); + void AddEntity( const EntityDescriptor & ); + void AddSchema( const Schema & ); + void AddType( const TypeDescriptor & ); - void RemoveEntity(const char *); - void RemoveSchema(const char *); - void RemoveType(const char *); + void RemoveEntity( const char * ); + void RemoveSchema( const char * ); + void RemoveType( const char * ); int GetEntityCnt(); - int GetFullEntCnt() - { + int GetFullEntCnt() { return all_ents_cnt; } void ResetEntities(); - const EntityDescriptor *NextEntity(); + const EntityDescriptor * NextEntity(); void ResetSchemas(); - const Schema *NextSchema(); + const Schema * NextSchema(); void ResetTypes(); - const TypeDescriptor *NextType(); + const TypeDescriptor * NextType(); - const ComplexCollect *CompCol() - { + const ComplexCollect * CompCol() { return col; } - void SetCompCollect(ComplexCollect *c) - { + void SetCompCollect( ComplexCollect * c ) { col = c; } - SDAI_Application_instance *ObjCreate(const char *nm, const char * = 0, - int check_case = 0) const; + SDAI_Application_instance * ObjCreate( const char * nm, const char * = 0, + int check_case = 0 ) const; }; #endif /* _REGISTRY_H */ diff --git a/src/clstepcore/STEPaggrBinary.cc b/src/clstepcore/STEPaggrBinary.cc index 4b1df27d1..fd7302748 100644 --- a/src/clstepcore/STEPaggrBinary.cc +++ b/src/clstepcore/STEPaggrBinary.cc @@ -6,27 +6,24 @@ */ -BinaryAggregate::BinaryAggregate() -{ +BinaryAggregate::BinaryAggregate() { } -BinaryAggregate::~BinaryAggregate() -{ +BinaryAggregate::~BinaryAggregate() { } -STEPaggregate &BinaryAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & BinaryAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new BinaryNode(*(BinaryNode *)next); - AddNode(copy); + while( next ) { + copy = new BinaryNode( *( BinaryNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -35,35 +32,29 @@ STEPaggregate &BinaryAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *BinaryAggregate::NewNode() -{ +SingleLinkNode * BinaryAggregate::NewNode() { return new BinaryNode(); } -BinaryNode::BinaryNode() -{ +BinaryNode::BinaryNode() { value = 0; } -BinaryNode::~BinaryNode() -{ +BinaryNode::~BinaryNode() { } -BinaryNode::BinaryNode(BinaryNode &bn) -{ +BinaryNode::BinaryNode( BinaryNode & bn ) { value = bn.value.c_str(); } -BinaryNode::BinaryNode(const char *sStr) -{ +BinaryNode::BinaryNode( const char * sStr ) { // value is an SDAI_Binary (the memory is copied) value = sStr; } SingleLinkNode * -BinaryNode::NewNode() -{ +BinaryNode::NewNode() { return new BinaryNode(); } @@ -71,55 +62,48 @@ BinaryNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity BinaryNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity BinaryNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); +Severity BinaryNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); - value.STEPread(in, err); - CheckRemainingInput(in, err, "binary", ",)"); + value.STEPread( in, err ); + CheckRemainingInput( in, err, "binary", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity BinaryNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *BinaryNode::asStr(std::string &s) -{ +const char * BinaryNode::asStr( std::string & s ) { s = value.c_str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *BinaryNode::STEPwrite(std::string &s, const char *) -{ - value.STEPwrite(s); - return const_cast(s.c_str()); +const char * BinaryNode::STEPwrite( std::string & s, const char * ) { + value.STEPwrite( s ); + return const_cast( s.c_str() ); } -void BinaryNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void BinaryNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrBinary.h b/src/clstepcore/STEPaggrBinary.h index 7d627efa5..cd4991bbb 100644 --- a/src/clstepcore/STEPaggrBinary.h +++ b/src/clstepcore/STEPaggrBinary.h @@ -12,47 +12,45 @@ * * \class BinaryAggregate ** This class supports LIST OF BINARY type */ -class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - BinaryAggregate(); - virtual ~BinaryAggregate(); +class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + BinaryAggregate(); + virtual ~BinaryAggregate(); }; -typedef BinaryAggregate *BinaryAggregateH; -typedef BinaryAggregate *BinaryAggregate_ptr; -typedef const BinaryAggregate *BinaryAggregate_ptr_c; +typedef BinaryAggregate * BinaryAggregateH; +typedef BinaryAggregate * BinaryAggregate_ptr; +typedef const BinaryAggregate * BinaryAggregate_ptr_c; typedef BinaryAggregate_ptr BinaryAggregate_var; /** * * \class BinaryNode ** This class is for the Nodes of BinaryAggregates */ -class SC_CORE_EXPORT BinaryNode : public STEPnode -{ - public: - SDAI_Binary value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - BinaryNode(BinaryNode &bn); - BinaryNode(const char *sStr); - BinaryNode(); - ~BinaryNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT BinaryNode : public STEPnode { +public: + SDAI_Binary value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + BinaryNode( BinaryNode & bn ); + BinaryNode( const char * sStr ); + BinaryNode(); + ~BinaryNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index 480eb97dd..bda8f6db5 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -8,27 +8,24 @@ */ -EntityAggregate::EntityAggregate() -{ +EntityAggregate::EntityAggregate() { } -EntityAggregate::~EntityAggregate() -{ +EntityAggregate::~EntityAggregate() { } /// if exchangeFileFormat == 1 then delims are required. -Severity EntityAggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char *) -{ +Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char * ) { ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -38,99 +35,98 @@ Severity EntityAggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || (c == '$')) { + if( in.eof() || ( c == '$' ) ) { _null = 1; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - EntityNode *item = 0; + EntityNode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { + else if( !assignVal ) { item = new EntityNode(); } - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop + if( assignVal ) { // create a new node each time through the loop item = new EntityNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc, elem_type, insts, addFileId); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc, elem_type, insts, addFileId ); } else { - item->StrToVal(in, &errdesc, elem_type, insts, addFileId); + item->StrToVal( in, &errdesc, elem_type, insts, addFileId ); } - elem_type->AttrTypeName(buf); + elem_type->AttrTypeName( buf ); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput(in, &errdesc, buf, ",)"); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { - AddNode(item); + if( assignVal ) { + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate &EntityAggregate::ShallowCopy(const STEPaggregate &a) -{ - const EntityNode *tmp = (const EntityNode *) a.GetHead(); - while(tmp) { - AddNode(new EntityNode(tmp -> node)); - tmp = (const EntityNode *) tmp -> NextNode(); +STEPaggregate & EntityAggregate::ShallowCopy( const STEPaggregate & a ) { + const EntityNode * tmp = ( const EntityNode * ) a.GetHead(); + while( tmp ) { + AddNode( new EntityNode( tmp -> node ) ); + tmp = ( const EntityNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -140,44 +136,38 @@ STEPaggregate &EntityAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *EntityAggregate::NewNode() -{ +SingleLinkNode * EntityAggregate::NewNode() { return new EntityNode(); } -EntityNode::EntityNode() -{ +EntityNode::EntityNode() { } -EntityNode::~EntityNode() -{ +EntityNode::~EntityNode() { } -EntityNode::EntityNode(SDAI_Application_instance *e) : node(e) -{ +EntityNode::EntityNode( SDAI_Application_instance * e ) : node( e ) { } -SingleLinkNode *EntityNode::NewNode() -{ +SingleLinkNode * EntityNode::NewNode() { return new EntityNode(); } /////////////////////////////////////////////////////////////////////////////// -Severity EntityNode::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - SDAI_Application_instance *se = ReadEntityRef(s, err, ",)", insts, - addFileId); - if(se != S_ENTITY_NULL) { +Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + SDAI_Application_instance * se = ReadEntityRef( s, err, ",)", insts, + addFileId ); + if( se != S_ENTITY_NULL ) { ErrorDescriptor error; - if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { + if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); } } else { node = S_ENTITY_NULL; @@ -185,36 +175,33 @@ Severity EntityNode::StrToVal(const char *s, ErrorDescriptor *err, return err->severity(); } -Severity EntityNode::StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - return STEPread(in, err, elem_type, insts, addFileId); +Severity EntityNode::StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + return STEPread( in, err, elem_type, insts, addFileId ); } -Severity EntityNode::STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - istringstream in((char *)s); - return STEPread(in, err, elem_type, insts, addFileId); +Severity EntityNode::STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId) -{ - SDAI_Application_instance *se = ReadEntityRef(in, err, ",)", insts, - addFileId); - if(se != S_ENTITY_NULL) { +Severity EntityNode::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + SDAI_Application_instance * se = ReadEntityRef( in, err, ",)", insts, + addFileId ); + if( se != S_ENTITY_NULL ) { ErrorDescriptor error; - if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { + if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); } } else { node = S_ENTITY_NULL; @@ -222,36 +209,33 @@ Severity EntityNode::STEPread(istream &in, ErrorDescriptor *err, return err->severity(); } -const char *EntityNode::asStr(std::string &s) -{ +const char * EntityNode::asStr( std::string & s ) { s.clear(); - if(!node || (node == S_ENTITY_NULL)) { // nothing + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing return ""; } else { // otherwise return entity id char tmp [64]; - sprintf(tmp, "#%d", node->STEPfile_id); + sprintf( tmp, "#%d", node->STEPfile_id ); s = tmp; } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *EntityNode::STEPwrite(std::string &s, const char *) -{ - if(!node || (node == S_ENTITY_NULL)) { // nothing +const char * EntityNode::STEPwrite( std::string & s, const char * ) { + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing s = "$"; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } - asStr(s); - return const_cast(s.c_str()); + asStr( s ); + return const_cast( s.c_str() ); } -void EntityNode::STEPwrite(ostream &out) -{ - if(!node || (node == S_ENTITY_NULL)) { // nothing +void EntityNode::STEPwrite( ostream & out ) { + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing out << "$"; } std::string s; - out << asStr(s); + out << asStr( s ); } diff --git a/src/clstepcore/STEPaggrEntity.h b/src/clstepcore/STEPaggrEntity.h index a89a3e55f..f18bc3d0f 100644 --- a/src/clstepcore/STEPaggrEntity.h +++ b/src/clstepcore/STEPaggrEntity.h @@ -8,83 +8,77 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT EntityAggregate : public STEPaggregate -{ - public: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); +class SC_CORE_EXPORT EntityAggregate : public STEPaggregate { +public: + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - EntityAggregate(); - virtual ~EntityAggregate(); + EntityAggregate(); + virtual ~EntityAggregate(); }; -typedef EntityAggregate *EntityAggregateH; -typedef EntityAggregate *EntityAggregate_ptr; -typedef const EntityAggregate *EntityAggregate_ptr_c; +typedef EntityAggregate * EntityAggregateH; +typedef EntityAggregate * EntityAggregate_ptr; +typedef const EntityAggregate * EntityAggregate_ptr_c; typedef EntityAggregate_ptr EntityAggregate_var; -class SC_CORE_EXPORT EntityNode : public STEPnode -{ - public: - SDAI_Application_instance *node; +class SC_CORE_EXPORT EntityNode : public STEPnode { +public: + SDAI_Application_instance * node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + virtual Severity STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - EntityNode(SDAI_Application_instance *e); - EntityNode(); - ~EntityNode(); + // CONSTRUCTORS + EntityNode( SDAI_Application_instance * e ); + EntityNode(); + ~EntityNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); - // Calling these functions is an error. - Severity StrToVal(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(s, err, 0, 0, 0); - } - Severity StrToVal(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(in, err, 0, 0, 0); - } + // Calling these functions is an error. + Severity StrToVal( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( s, err, 0, 0, 0 ); + } + Severity StrToVal( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( in, err, 0, 0, 0 ); + } - Severity STEPread(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(s, err, 0, 0, 0); - } - Severity STEPread(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(in, err, 0, 0, 0); - } + Severity STEPread( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( s, err, 0, 0, 0 ); + } + Severity STEPread( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( in, err, 0, 0, 0 ); + } }; #endif //STEPAGGRENTITY_H diff --git a/src/clstepcore/STEPaggrEnum.cc b/src/clstepcore/STEPaggrEnum.cc index ded295cf4..41b77aa21 100644 --- a/src/clstepcore/STEPaggrEnum.cc +++ b/src/clstepcore/STEPaggrEnum.cc @@ -7,18 +7,17 @@ /// COPY -STEPaggregate &EnumAggregate::ShallowCopy(const STEPaggregate &a) -{ - const EnumNode *tmp = (const EnumNode *) a.GetHead(); - EnumNode *to; - - while(tmp) { - to = (EnumNode *) NewNode(); - to -> node -> put(tmp -> node ->asInt()); - AddNode(to); - tmp = (const EnumNode *) tmp -> NextNode(); +STEPaggregate & EnumAggregate::ShallowCopy( const STEPaggregate & a ) { + const EnumNode * tmp = ( const EnumNode * ) a.GetHead(); + EnumNode * to; + + while( tmp ) { + to = ( EnumNode * ) NewNode(); + to -> node -> put( tmp -> node ->asInt() ); + AddNode( to ); + tmp = ( const EnumNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -27,13 +26,11 @@ STEPaggregate &EnumAggregate::ShallowCopy(const STEPaggregate &a) return *this; } -EnumAggregate::EnumAggregate() -{ +EnumAggregate::EnumAggregate() { } -EnumAggregate::~EnumAggregate() -{ +EnumAggregate::~EnumAggregate() { } @@ -44,69 +41,56 @@ EnumAggregate::~EnumAggregate() ** created ** Status: ok 2/91 ******************************************************************/ -SingleLinkNode *EnumAggregate::NewNode() -{ +SingleLinkNode * EnumAggregate::NewNode() { // defined in subclass cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumAggregate::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } -LOGICALS::LOGICALS() -{ +LOGICALS::LOGICALS() { } -LOGICALS::~LOGICALS() -{ +LOGICALS::~LOGICALS() { } -SingleLinkNode *LOGICALS::NewNode() -{ - return new EnumNode(new SDAI_LOGICAL); +SingleLinkNode * LOGICALS::NewNode() { + return new EnumNode( new SDAI_LOGICAL ); } -LOGICALS *create_LOGICALS() -{ +LOGICALS * create_LOGICALS() { return new LOGICALS; } -BOOLEANS::BOOLEANS() -{ +BOOLEANS::BOOLEANS() { } -BOOLEANS::~BOOLEANS() -{ +BOOLEANS::~BOOLEANS() { } -SingleLinkNode *BOOLEANS::NewNode() -{ - return new EnumNode(new SDAI_BOOLEAN); +SingleLinkNode * BOOLEANS::NewNode() { + return new EnumNode( new SDAI_BOOLEAN ); } -BOOLEANS *create_BOOLEANS() -{ +BOOLEANS * create_BOOLEANS() { return new BOOLEANS ; } -EnumNode::EnumNode(SDAI_Enum *e) : node(e) -{ +EnumNode::EnumNode( SDAI_Enum * e ) : node( e ) { } -EnumNode::EnumNode() -{ +EnumNode::EnumNode() { } -EnumNode::~EnumNode() -{ +EnumNode::~EnumNode() { } /// defined in subclass -SingleLinkNode *EnumNode::NewNode() -{ +SingleLinkNode * EnumNode::NewNode() { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumNode::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } @@ -114,55 +98,48 @@ SingleLinkNode *EnumNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity EnumNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return node->STEPread(in, err); +Severity EnumNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return node->STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); // sz defaults to length of s +Severity EnumNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); // sz defaults to length of s int nullable = 0; - node->STEPread(in, err, nullable); - CheckRemainingInput(in, err, "enumeration", ",)"); + node->STEPread( in, err, nullable ); + CheckRemainingInput( in, err, "enumeration", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity EnumNode::STEPread( istream & in, ErrorDescriptor * err ) { int nullable = 0; - node->STEPread(in, err, nullable); + node->STEPread( in, err, nullable ); return err->severity(); } -const char *EnumNode::asStr(std::string &s) -{ - node -> asStr(s); - return const_cast(s.c_str()); +const char * EnumNode::asStr( std::string & s ) { + node -> asStr( s ); + return const_cast( s.c_str() ); } -const char *EnumNode::STEPwrite(std::string &s, const char *) -{ - node->STEPwrite(s); - return const_cast(s.c_str()); +const char * EnumNode::STEPwrite( std::string & s, const char * ) { + node->STEPwrite( s ); + return const_cast( s.c_str() ); } -void EnumNode::STEPwrite(ostream &out) -{ - node->STEPwrite(out); +void EnumNode::STEPwrite( ostream & out ) { + node->STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrEnum.h b/src/clstepcore/STEPaggrEnum.h index a1cf5d9dd..161706a48 100644 --- a/src/clstepcore/STEPaggrEnum.h +++ b/src/clstepcore/STEPaggrEnum.h @@ -11,77 +11,73 @@ * \class EnumAggregate * This is a minimal representions for a collection of SDAI_Enum */ -class SC_CORE_EXPORT EnumAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - EnumAggregate(); - virtual ~EnumAggregate(); +class SC_CORE_EXPORT EnumAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + EnumAggregate(); + virtual ~EnumAggregate(); }; -typedef EnumAggregate *EnumAggregateH; -typedef EnumAggregate *EnumAggregate_ptr; -typedef const EnumAggregate *EnumAggregate_ptr_c; +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: - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT LOGICALS : public EnumAggregate { +public: + virtual SingleLinkNode * NewNode(); - LOGICALS(); - virtual ~LOGICALS(); + LOGICALS(); + virtual ~LOGICALS(); }; -typedef LOGICALS *LogicalsH; -typedef LOGICALS *LOGICALS_ptr; -typedef const LOGICALS *LOGICALS_ptr_c; +typedef LOGICALS * LogicalsH; +typedef LOGICALS * LOGICALS_ptr; +typedef const LOGICALS * LOGICALS_ptr_c; typedef LOGICALS_ptr LOGICALS_var; -SC_CORE_EXPORT LOGICALS *create_LOGICALS(); +SC_CORE_EXPORT LOGICALS * create_LOGICALS(); -class SC_CORE_EXPORT BOOLEANS : public EnumAggregate -{ - public: - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT BOOLEANS : public EnumAggregate { +public: + virtual SingleLinkNode * NewNode(); - BOOLEANS(); - virtual ~BOOLEANS(); + BOOLEANS(); + virtual ~BOOLEANS(); }; -typedef BOOLEANS *BOOLEANS_ptr; -typedef const BOOLEANS *BOOLEANS_ptr_c; +typedef BOOLEANS * BOOLEANS_ptr; +typedef const BOOLEANS * BOOLEANS_ptr_c; typedef BOOLEANS_ptr BOOLEANS_var; -SC_CORE_EXPORT BOOLEANS *create_BOOLEANS(); +SC_CORE_EXPORT BOOLEANS * create_BOOLEANS(); /** * * \class EnumNode ** This is a minimal representions for node in lists of SDAI_Enum */ -class SC_CORE_EXPORT EnumNode : public STEPnode -{ - public: - SDAI_Enum *node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - EnumNode(SDAI_Enum *e); - EnumNode(); - ~EnumNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT EnumNode : public STEPnode { +public: + SDAI_Enum * node; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + EnumNode( SDAI_Enum * e ); + EnumNode(); + ~EnumNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrGeneric.cc b/src/clstepcore/STEPaggrGeneric.cc index fb94bfd83..899d6c656 100644 --- a/src/clstepcore/STEPaggrGeneric.cc +++ b/src/clstepcore/STEPaggrGeneric.cc @@ -5,32 +5,28 @@ * implement classes GenericAggregate, GenericAggrNode */ -GenericAggregate::GenericAggregate() -{ +GenericAggregate::GenericAggregate() { } -GenericAggregate::~GenericAggregate() -{ +GenericAggregate::~GenericAggregate() { } -SingleLinkNode *GenericAggregate::NewNode() -{ +SingleLinkNode * GenericAggregate::NewNode() { return new GenericAggrNode(); } -STEPaggregate &GenericAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & GenericAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new GenericAggrNode(*(GenericAggrNode *)next); - AddNode(copy); + while( next ) { + copy = new GenericAggrNode( *( GenericAggrNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -39,65 +35,53 @@ STEPaggregate &GenericAggregate::ShallowCopy(const STEPaggregate &a) } -GenericAggrNode::GenericAggrNode(const char *str) -{ +GenericAggrNode::GenericAggrNode( const char * str ) { value = str; } -GenericAggrNode::GenericAggrNode(GenericAggrNode &gan) -{ +GenericAggrNode::GenericAggrNode( GenericAggrNode & gan ) { value = gan.value; } -GenericAggrNode::GenericAggrNode() -{ +GenericAggrNode::GenericAggrNode() { } -GenericAggrNode::~GenericAggrNode() -{ +GenericAggrNode::~GenericAggrNode() { } -SingleLinkNode *GenericAggrNode::NewNode() -{ +SingleLinkNode * GenericAggrNode::NewNode() { return new GenericAggrNode(); } -Severity GenericAggrNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return value.STEPread(s, err); +Severity GenericAggrNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return value.STEPread( s, err ); } //TODO -Severity GenericAggrNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity GenericAggrNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -Severity GenericAggrNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *) s); - return value.STEPread(in, err); +Severity GenericAggrNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * ) s ); + return value.STEPread( in, err ); } -Severity GenericAggrNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity GenericAggrNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *GenericAggrNode::asStr(std::string &s) -{ +const char * GenericAggrNode::asStr( std::string & s ) { s.clear(); - value.asStr(s); - return const_cast(s.c_str()); + value.asStr( s ); + return const_cast( s.c_str() ); } -const char *GenericAggrNode::STEPwrite(std::string &s, const char *currSch) -{ +const char * GenericAggrNode::STEPwrite( std::string & s, const char * currSch ) { (void) currSch; //unused - return value.STEPwrite(s); + return value.STEPwrite( s ); } -void GenericAggrNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void GenericAggrNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrGeneric.h b/src/clstepcore/STEPaggrGeneric.h index 037572180..76190406e 100644 --- a/src/clstepcore/STEPaggrGeneric.h +++ b/src/clstepcore/STEPaggrGeneric.h @@ -13,46 +13,44 @@ * 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: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - GenericAggregate(); - virtual ~GenericAggregate(); +class SC_CORE_EXPORT GenericAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + GenericAggregate(); + virtual ~GenericAggregate(); }; -typedef GenericAggregate *GenericAggregateH; -typedef GenericAggregate *GenericAggregate_ptr; -typedef const GenericAggregate *GenericAggregate_ptr_c; +typedef GenericAggregate * GenericAggregateH; +typedef GenericAggregate * GenericAggregate_ptr; +typedef const GenericAggregate * GenericAggregate_ptr_c; typedef GenericAggregate_ptr GenericAggregate_var; /** * This class is for the Nodes of GenericAggregates */ -class SC_CORE_EXPORT GenericAggrNode : public STEPnode -{ - public: - SCLundefined value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - GenericAggrNode(const char *str); - GenericAggrNode(GenericAggrNode &gan); - GenericAggrNode(); - ~GenericAggrNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT GenericAggrNode : public STEPnode { +public: + SCLundefined value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + GenericAggrNode( const char * str ); + GenericAggrNode( GenericAggrNode & gan ); + GenericAggrNode(); + ~GenericAggrNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index cc729a455..2e61a1504 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -1,32 +1,28 @@ #include "STEPaggrInt.h" -IntAggregate::IntAggregate() -{ +IntAggregate::IntAggregate() { } -IntAggregate::~IntAggregate() -{ +IntAggregate::~IntAggregate() { } -SingleLinkNode *IntAggregate::NewNode() -{ +SingleLinkNode * IntAggregate::NewNode() { return new IntNode(); } /// COPY -STEPaggregate &IntAggregate::ShallowCopy(const STEPaggregate &a) -{ - const IntNode *tmp = (const IntNode *) a.GetHead(); - IntNode *to; +STEPaggregate & IntAggregate::ShallowCopy( const STEPaggregate & a ) { + const IntNode * tmp = ( const IntNode * ) a.GetHead(); + IntNode * to; - while(tmp) { - to = (IntNode *) NewNode(); + while( tmp ) { + to = ( IntNode * ) NewNode(); to -> value = tmp -> value; - AddNode(to); - tmp = (const IntNode *) tmp -> NextNode(); + AddNode( to ); + tmp = ( const IntNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -37,28 +33,23 @@ STEPaggregate &IntAggregate::ShallowCopy(const STEPaggregate &a) -IntNode::IntNode() -{ +IntNode::IntNode() { value = S_INT_NULL; } -IntNode::IntNode(SDAI_Integer v) -{ +IntNode::IntNode( SDAI_Integer v ) { value = v; } -IntNode::~IntNode() -{ +IntNode::~IntNode() { } -SingleLinkNode *IntNode::NewNode() -{ +SingleLinkNode * IntNode::NewNode() { return new IntNode(); } -Severity IntNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned +Severity IntNode::StrToVal( const char * s, ErrorDescriptor * err ) { + if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -67,9 +58,8 @@ Severity IntNode::StrToVal(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned +Severity IntNode::StrToVal( istream & in, ErrorDescriptor * err ) { + if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -78,9 +68,8 @@ Severity IntNode::StrToVal(istream &in, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::STEPread(const char *s, ErrorDescriptor *err) -{ - if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned +Severity IntNode::STEPread( const char * s, ErrorDescriptor * err ) { + if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -89,9 +78,8 @@ Severity IntNode::STEPread(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::STEPread(istream &in, ErrorDescriptor *err) -{ - if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned +Severity IntNode::STEPread( istream & in, ErrorDescriptor * err ) { + if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -100,26 +88,23 @@ Severity IntNode::STEPread(istream &in, ErrorDescriptor *err) return err->severity(); } -const char *IntNode::asStr(std::string &s) -{ - STEPwrite(s); - return const_cast(s.c_str()); +const char * IntNode::asStr( std::string & s ) { + STEPwrite( s ); + return const_cast( s.c_str() ); } -const char *IntNode::STEPwrite(std::string &s, const char *) -{ +const char * IntNode::STEPwrite( std::string & s, const char * ) { char tmp[BUFSIZ]; - if(value != S_INT_NULL) { - sprintf(tmp, "%ld", value); + if( value != S_INT_NULL ) { + sprintf( tmp, "%ld", value ); s = tmp; } else { s.clear(); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void IntNode::STEPwrite(ostream &out) -{ +void IntNode::STEPwrite( ostream & out ) { std::string s; - out << STEPwrite(s); + out << STEPwrite( s ); } diff --git a/src/clstepcore/STEPaggrInt.h b/src/clstepcore/STEPaggrInt.h index bf10ca8b0..726d07c0e 100644 --- a/src/clstepcore/STEPaggrInt.h +++ b/src/clstepcore/STEPaggrInt.h @@ -4,44 +4,42 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT IntAggregate : public STEPaggregate -{ +class SC_CORE_EXPORT IntAggregate : public STEPaggregate { - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - IntAggregate(); - virtual ~IntAggregate(); + IntAggregate(); + virtual ~IntAggregate(); }; -typedef IntAggregate *IntAggregateH; -typedef IntAggregate *IntAggregate_ptr; -typedef const IntAggregate *IntAggregate_ptr_c; +typedef IntAggregate * IntAggregateH; +typedef IntAggregate * IntAggregate_ptr; +typedef const IntAggregate * IntAggregate_ptr_c; typedef IntAggregate_ptr IntAggregate_var; -class SC_CORE_EXPORT IntNode : public STEPnode -{ - public: - SDAI_Integer value; // long int - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); +class SC_CORE_EXPORT IntNode : public STEPnode { +public: + SDAI_Integer value; // long int + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - IntNode(SDAI_Integer v); - IntNode(); - ~IntNode(); + // CONSTRUCTORS + IntNode( SDAI_Integer v ); + IntNode(); + ~IntNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrReal.cc b/src/clstepcore/STEPaggrReal.cc index d517d90ef..7d05c1333 100644 --- a/src/clstepcore/STEPaggrReal.cc +++ b/src/clstepcore/STEPaggrReal.cc @@ -4,32 +4,28 @@ * implementation of classes RealAggregate and RealNode */ -RealAggregate::RealAggregate() -{ +RealAggregate::RealAggregate() { } -RealAggregate::~RealAggregate() -{ +RealAggregate::~RealAggregate() { } -SingleLinkNode *RealAggregate::NewNode() -{ +SingleLinkNode * RealAggregate::NewNode() { return new RealNode(); } // COPY -STEPaggregate &RealAggregate::ShallowCopy(const STEPaggregate &a) -{ - const RealNode *tmp = (const RealNode *) a.GetHead(); - RealNode *to; +STEPaggregate & RealAggregate::ShallowCopy( const STEPaggregate & a ) { + const RealNode * tmp = ( const RealNode * ) a.GetHead(); + RealNode * to; - while(tmp) { - to = (RealNode *) NewNode(); + while( tmp ) { + to = ( RealNode * ) NewNode(); to -> value = tmp -> value; - AddNode(to); - tmp = (const RealNode *) tmp -> NextNode(); + AddNode( to ); + tmp = ( const RealNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -38,28 +34,23 @@ STEPaggregate &RealAggregate::ShallowCopy(const STEPaggregate &a) } -RealNode::RealNode() -{ +RealNode::RealNode() { value = S_REAL_NULL; } -RealNode::RealNode(SDAI_Real v) -{ +RealNode::RealNode( SDAI_Real v) { value = v; } -RealNode::~RealNode() -{ +RealNode::~RealNode() { } -SingleLinkNode *RealNode::NewNode() -{ +SingleLinkNode * RealNode::NewNode() { return new RealNode(); } -Severity RealNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned +Severity RealNode::StrToVal( const char * s, ErrorDescriptor * err ) { + if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -68,9 +59,8 @@ Severity RealNode::StrToVal(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned +Severity RealNode::StrToVal( istream & in, ErrorDescriptor * err ) { + if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -79,9 +69,8 @@ Severity RealNode::StrToVal(istream &in, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::STEPread(const char *s, ErrorDescriptor *err) -{ - if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned +Severity RealNode::STEPread( const char * s, ErrorDescriptor * err ) { + if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -90,9 +79,8 @@ Severity RealNode::STEPread(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::STEPread(istream &in, ErrorDescriptor *err) -{ - if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned +Severity RealNode::STEPread( istream & in, ErrorDescriptor * err ) { + if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -101,26 +89,23 @@ Severity RealNode::STEPread(istream &in, ErrorDescriptor *err) return err->severity(); } -const char *RealNode::asStr(std::string &s) -{ - STEPwrite(s); - return const_cast(s.c_str()); +const char * RealNode::asStr( std::string & s ) { + STEPwrite( s ); + return const_cast( s.c_str() ); } -const char *RealNode::STEPwrite(std::string &s, const char *) -{ +const char * RealNode::STEPwrite( std::string & s, const char * ) { //use memcmp to work around -Wfloat-equal warning SDAI_Real z = S_REAL_NULL; - if(0 != memcmp(&value, &z, sizeof z)) { - s = WriteReal(value); + if( 0 != memcmp( &value, &z, sizeof z ) ) { + s = WriteReal( value ); } else { s.clear(); } return s.c_str(); } -void RealNode::STEPwrite(ostream &out) -{ +void RealNode::STEPwrite( ostream & out ) { std::string s; - out << STEPwrite(s); + out << STEPwrite( s ); } diff --git a/src/clstepcore/STEPaggrReal.h b/src/clstepcore/STEPaggrReal.h index f3b6602d8..48cd90e51 100644 --- a/src/clstepcore/STEPaggrReal.h +++ b/src/clstepcore/STEPaggrReal.h @@ -4,43 +4,41 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT RealAggregate : public STEPaggregate -{ +class SC_CORE_EXPORT RealAggregate : public STEPaggregate { - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - RealAggregate(); - virtual ~RealAggregate(); + RealAggregate(); + virtual ~RealAggregate(); }; -typedef RealAggregate *RealAggregateH; -typedef RealAggregate *RealAggregate_ptr; -typedef const RealAggregate *RealAggregate_ptr_c; +typedef RealAggregate * RealAggregateH; +typedef RealAggregate * RealAggregate_ptr; +typedef const RealAggregate * RealAggregate_ptr_c; typedef RealAggregate_ptr RealAggregate_var; -class SC_CORE_EXPORT RealNode : public STEPnode -{ - public: - SDAI_Real value; // double - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); +class SC_CORE_EXPORT RealNode : public STEPnode { +public: + SDAI_Real value; // double + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - RealNode(SDAI_Real v); - RealNode(); - ~RealNode(); + // CONSTRUCTORS + RealNode( SDAI_Real v ); + RealNode(); + ~RealNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index f74fcf955..02970479c 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -6,27 +6,24 @@ * implement classes SelectAggregate, SelectNode */ -SelectAggregate::SelectAggregate() -{ +SelectAggregate::SelectAggregate() { } -SelectAggregate::~SelectAggregate() -{ +SelectAggregate::~SelectAggregate() { } /// if exchangeFileFormat == 1 then delims are required. -Severity SelectAggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char *currSch) -{ +Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char * currSch ) { ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -36,100 +33,99 @@ Severity SelectAggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || (c == '$')) { + if( in.eof() || ( c == '$' ) ) { _null = 1; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - SelectNode *item = 0; + SelectNode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { - item = (SelectNode *) NewNode(); + else if( !assignVal ) { + item = ( SelectNode * ) NewNode(); } - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop - item = (SelectNode *) NewNode(); + if( assignVal ) { // create a new node each time through the loop + item = ( SelectNode * ) NewNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc, elem_type, insts, addFileId, currSch); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc, elem_type, insts, addFileId, currSch ); } else { - item->StrToVal(in, &errdesc, elem_type, insts, addFileId, currSch); + item->StrToVal( in, &errdesc, elem_type, insts, addFileId, currSch ); } - elem_type->AttrTypeName(buf); + elem_type->AttrTypeName( buf ); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput(in, &errdesc, buf, ",)"); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { - AddNode(item); + if( assignVal ) { + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate &SelectAggregate::ShallowCopy(const STEPaggregate &a) -{ - const SelectNode *tmp = (const SelectNode *) a.GetHead(); - while(tmp) { - AddNode(new SelectNode(tmp -> node)); +STEPaggregate & SelectAggregate::ShallowCopy( const STEPaggregate & a ) { + const SelectNode * tmp = ( const SelectNode * ) a.GetHead(); + while( tmp ) { + AddNode( new SelectNode( tmp -> node ) ); - tmp = (const SelectNode *) tmp -> NextNode(); + tmp = ( const SelectNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -139,102 +135,90 @@ STEPaggregate &SelectAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *SelectAggregate::NewNode() -{ +SingleLinkNode * SelectAggregate::NewNode() { return new SelectNode(); } -SelectNode::SelectNode(SDAI_Select *s) : node(s) -{ +SelectNode::SelectNode( SDAI_Select * s ) : node( s ) { } -SelectNode::SelectNode() -{ +SelectNode::SelectNode() { } -SelectNode::~SelectNode() -{ +SelectNode::~SelectNode() { delete node; } -SingleLinkNode *SelectNode::NewNode() -{ +SingleLinkNode * SelectNode::NewNode() { return new SelectNode(); } -Severity SelectNode::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ +Severity SelectNode::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { (void) elem_type; //unused (void) addFileId; //unused - istringstream in((char *)s); - if(err->severity(node->STEPread(in, err, insts)) != SEVERITY_NULL) { - err->AppendToDetailMsg(node ->Error()); + istringstream in( ( char * )s ); + if( err->severity( node->STEPread( in, err, insts ) ) != SEVERITY_NULL ) { + err->AppendToDetailMsg( node ->Error() ); } return err->severity(); } -Severity SelectNode::StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId, const char *currSch) -{ - return STEPread(in, err, elem_type, insts, addFileId, currSch); +Severity SelectNode::StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId) -{ - istringstream in((char *)s); - return STEPread(in, err, elem_type, insts, addFileId); +Severity SelectNode::STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId, const char *currSch) -{ +Severity SelectNode::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId, const char * currSch ) { (void) elem_type; //unused - if(!node) { + if( !node ) { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; cerr << "function: SelectNode::STEPread \n" << "\n"; return SEVERITY_BUG; } - err->severity(node->STEPread(in, err, insts, 0, addFileId, currSch)); - CheckRemainingInput(in, err, "select", ",)"); + err->severity( node->STEPread( in, err, insts, 0, addFileId, currSch ) ); + CheckRemainingInput( in, err, "select", ",)" ); return err->severity(); } -const char *SelectNode::asStr(std::string &s) -{ +const char * SelectNode::asStr( std::string & s ) { s.clear(); - if(!node || (node->is_null())) { // nothing + if( !node || ( node->is_null() ) ) { // nothing return ""; } else { // otherwise return entity id - node -> STEPwrite(s); - return const_cast(s.c_str()); + node -> STEPwrite( s ); + return const_cast( s.c_str() ); } } -const char *SelectNode::STEPwrite(std::string &s, const char *currSch) -{ +const char * SelectNode::STEPwrite( std::string & s, const char * currSch ) { s.clear(); - if(!node || (node->is_null())) { // nothing + if( !node || ( node->is_null() ) ) { // nothing s = "$"; return "$"; } - node -> STEPwrite(s, currSch); - return const_cast(s.c_str()); + node -> STEPwrite( s, currSch ); + return const_cast( s.c_str() ); } -void SelectNode::STEPwrite(ostream &out) -{ - if(!node || (node->is_null())) { // nothing +void SelectNode::STEPwrite( ostream & out ) { + if( !node || ( node->is_null() ) ) { // nothing out << "$"; } std::string s; - out << asStr(s); + out << asStr( s ); } diff --git a/src/clstepcore/STEPaggrSelect.h b/src/clstepcore/STEPaggrSelect.h index 1db7ba252..b62a9c3fe 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/src/clstepcore/STEPaggrSelect.h @@ -13,24 +13,23 @@ * * \class SelectAggregate ** This is a minimal represention for a collection of SDAI_Select */ -class SC_CORE_EXPORT SelectAggregate : public STEPaggregate -{ - public: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); +class SC_CORE_EXPORT SelectAggregate : public STEPaggregate { +public: + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - SelectAggregate(); - virtual ~SelectAggregate(); + SelectAggregate(); + virtual ~SelectAggregate(); }; -typedef SelectAggregate *SelectAggregateH; -typedef SelectAggregate *SelectAggregate_ptr; -typedef const SelectAggregate *SelectAggregate_ptr_c; +typedef SelectAggregate * SelectAggregateH; +typedef SelectAggregate * SelectAggregate_ptr; +typedef const SelectAggregate * SelectAggregate_ptr_c; typedef SelectAggregate_ptr SelectAggregate_var; @@ -38,64 +37,59 @@ typedef SelectAggregate_ptr SelectAggregate_var; * * \class SelectNode ** This is a minimal representions for node in lists of SDAI_Select */ -class SC_CORE_EXPORT SelectNode : public STEPnode -{ - public: - SDAI_Select *node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - const char *currSch = 0); +class SC_CORE_EXPORT SelectNode : public STEPnode { +public: + SDAI_Select * node; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + const char * currSch = 0 ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - const char *currSch = 0); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + virtual Severity STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + const char * currSch = 0 ); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - SelectNode(SDAI_Select *s); - SelectNode(); - ~SelectNode(); + // CONSTRUCTORS + SelectNode( SDAI_Select * s ); + SelectNode(); + ~SelectNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); - // Calling these functions is an error. - Severity StrToVal(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(s, err, 0, 0, 0); - } - Severity StrToVal(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(in, err, 0, 0, 0); - } + // Calling these functions is an error. + Severity StrToVal( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( s, err, 0, 0, 0 ); + } + Severity StrToVal( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( in, err, 0, 0, 0 ); + } - Severity STEPread(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(s, err, 0, 0, 0); - } - Severity STEPread(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(in, err, 0, 0, 0); - } + Severity STEPread( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( s, err, 0, 0, 0 ); + } + Severity STEPread( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( in, err, 0, 0, 0 ); + } }; diff --git a/src/clstepcore/STEPaggrString.cc b/src/clstepcore/STEPaggrString.cc index 08179bb3d..fd9285ad3 100644 --- a/src/clstepcore/STEPaggrString.cc +++ b/src/clstepcore/STEPaggrString.cc @@ -6,27 +6,24 @@ */ -StringAggregate::StringAggregate() -{ +StringAggregate::StringAggregate() { } -StringAggregate::~StringAggregate() -{ +StringAggregate::~StringAggregate() { } -STEPaggregate &StringAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new StringNode(*(StringNode *)next); - AddNode(copy); + while( next ) { + copy = new StringNode( *( StringNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -35,34 +32,28 @@ STEPaggregate &StringAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *StringAggregate::NewNode() -{ +SingleLinkNode * StringAggregate::NewNode() { return new StringNode(); } -StringNode::StringNode() -{ +StringNode::StringNode() { value = ""; } -StringNode::~StringNode() -{ +StringNode::~StringNode() { } -StringNode::StringNode(StringNode &sn) -{ +StringNode::StringNode( StringNode & sn ) { value = sn.value.c_str(); } -StringNode::StringNode(const char *sStr) -{ +StringNode::StringNode( const char * sStr ) { // value is an SDAI_String (the memory is copied) value = sStr; } -SingleLinkNode *StringNode::NewNode() -{ +SingleLinkNode * StringNode::NewNode() { return new StringNode(); } @@ -70,54 +61,47 @@ SingleLinkNode *StringNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); +Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); - value.STEPread(in, err); - CheckRemainingInput(in, err, "string", ",)"); + value.STEPread( in, err ); + CheckRemainingInput( in, err, "string", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *StringNode::asStr(std::string &s) -{ - value.asStr(s); - return const_cast(s.c_str()); +const char * StringNode::asStr( std::string & s ) { + value.asStr( s ); + return const_cast( s.c_str() ); } -const char *StringNode::STEPwrite(std::string &s, const char *) -{ - value.STEPwrite(s); - return const_cast(s.c_str()); +const char * StringNode::STEPwrite( std::string & s, const char * ) { + value.STEPwrite( s ); + return const_cast( s.c_str() ); } -void StringNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void StringNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrString.h b/src/clstepcore/STEPaggrString.h index 5446a989a..6f5cc8331 100644 --- a/src/clstepcore/STEPaggrString.h +++ b/src/clstepcore/STEPaggrString.h @@ -12,47 +12,45 @@ * * \class StringAggregate ** This class supports LIST OF STRING type */ -class SC_CORE_EXPORT StringAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - StringAggregate(); - virtual ~StringAggregate(); +class SC_CORE_EXPORT StringAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + StringAggregate(); + virtual ~StringAggregate(); }; -typedef StringAggregate *StringAggregateH; -typedef StringAggregate *StringAggregate_ptr; -typedef const StringAggregate *StringAggregate_ptr_c; +typedef StringAggregate * StringAggregateH; +typedef StringAggregate * StringAggregate_ptr; +typedef const StringAggregate * StringAggregate_ptr_c; typedef StringAggregate_ptr StringAggregate_var; /** * * \class StringNode ** This class is for the Nodes of StringAggregates */ -class SC_CORE_EXPORT StringNode : public STEPnode -{ - public: - SDAI_String value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - StringNode(StringNode &sn); - StringNode(const char *sStr); - StringNode(); - ~StringNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT StringNode : public STEPnode { +public: + SDAI_String value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + StringNode( StringNode & sn ); + StringNode( const char * sStr ); + StringNode(); + ~StringNode(); + + virtual SingleLinkNode * NewNode(); }; #endif //STEPAGGRSTRING_H diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 7bf6933e6..db3bbf819 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -34,25 +34,22 @@ STEPaggregate NilSTEPaggregate; -STEPaggregate::STEPaggregate() -{ +STEPaggregate::STEPaggregate() { _null = true; } -STEPaggregate::~STEPaggregate() -{ - STEPnode *node; +STEPaggregate::~STEPaggregate() { + STEPnode * node; - node = (STEPnode *) head; - while(node) { + node = ( STEPnode * ) head; + while( node ) { head = node->NextNode(); delete node; - node = (STEPnode *) head; + node = ( STEPnode * ) head; } } -STEPaggregate &STEPaggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) { (void) a; // unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; @@ -61,53 +58,50 @@ STEPaggregate &STEPaggregate::ShallowCopy(const STEPaggregate &a) } /// do not require exchange file format -Severity STEPaggregate::AggrValidLevel(const char *value, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId, - int clearError) -{ +Severity STEPaggregate::AggrValidLevel( const char * value, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int optional, char * tokenList, int addFileId, + int clearError ) { std::string buf; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)value); // sz defaults to length of s + istringstream in( ( char * )value ); // sz defaults to length of s - ReadValue(in, err, elem_type, insts, addFileId, 0, 0); - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, err, buf, tokenList); - if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { - err->severity(SEVERITY_NULL); + ReadValue( in, err, elem_type, insts, addFileId, 0, 0 ); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, err, buf, tokenList ); + if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// require exchange file format -Severity STEPaggregate::AggrValidLevel(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId, - int clearError) -{ +Severity STEPaggregate::AggrValidLevel( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int optional, char * tokenList, int addFileId, + int clearError ) { std::string buf; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } - ReadValue(in, err, elem_type, insts, addFileId, 0, 1); - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, err, buf, tokenList); - if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { - err->severity(SEVERITY_NULL); + ReadValue( in, err, elem_type, insts, addFileId, 0, 1 ); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, err, buf, tokenList ); + if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// if exchangeFileFormat == 1 then paren delims are required. -Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, int exchangeFileFormat, - const char *) -{ +Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, int exchangeFileFormat, + const char * ) { (void) insts; //not used in ReadValue() for this class (void) addFileId; //not used in ReadValue() for this class @@ -116,7 +110,7 @@ Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -126,138 +120,134 @@ Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || c == '$') { + if( in.eof() || c == '$' ) { _null = true; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - STEPnode *item = 0; + STEPnode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { - item = (STEPnode *)NewNode(); + else if( !assignVal ) { + item = ( STEPnode * )NewNode(); } // ')' is the end of the aggregate - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop - item = (STEPnode *)NewNode(); + if( assignVal ) { // create a new node each time through the loop + item = ( STEPnode * )NewNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc ); } else { - item->StrToVal(in, &errdesc); + item->StrToVal( in, &errdesc ); } // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, &errdesc, buf, ",)"); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { // pass the node to STEPaggregate - AddNode(item); + if( assignVal ) { // pass the node to STEPaggregate + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = false; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -Severity STEPaggregate::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId) -{ - istringstream in((char *)s); - return ReadValue(in, err, elem_type, insts, addFileId, 1, 0); +Severity STEPaggregate::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId ) { + istringstream in( ( char * )s ); + return ReadValue( in, err, elem_type, insts, addFileId, 1, 0 ); } /////////////////////////////////////////////////////////////////////////////// -Severity STEPaggregate::STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, const char *currSch) -{ - return ReadValue(in, err, elem_type, insts, addFileId, 1, 1, currSch); +Severity STEPaggregate::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, const char * currSch ) { + return ReadValue( in, err, elem_type, insts, addFileId, 1, 1, currSch ); } -const char *STEPaggregate::asStr(std::string &s) const -{ +const char * STEPaggregate::asStr( std::string & s ) const { s.clear(); - if(!_null) { + if( !_null ) { s = "("; - STEPnode *n = (STEPnode *) head; + STEPnode * n = ( STEPnode * ) head; std::string tmp; - while(n) { - s.append(n->STEPwrite(tmp)); - n = (STEPnode *) n -> NextNode(); - if(n) { - s.append(","); + while( n ) { + s.append( n->STEPwrite( tmp ) ); + n = ( STEPnode * ) n -> NextNode(); + if( n ) { + s.append( "," ); } } - s.append(")"); + s.append( ")" ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void STEPaggregate::STEPwrite(ostream &out, const char *currSch) const -{ - if(!_null) { +void STEPaggregate::STEPwrite( ostream & out, const char * currSch ) const { + if( !_null ) { out << '('; - STEPnode *n = (STEPnode *)head; + STEPnode * n = ( STEPnode * )head; std::string s; - while(n) { - out << n->STEPwrite(s, currSch); - n = (STEPnode *) n -> NextNode(); - if(n) { + while( n ) { + out << n->STEPwrite( s, currSch ); + n = ( STEPnode * ) n -> NextNode(); + if( n ) { out << ','; } } @@ -267,21 +257,18 @@ void STEPaggregate::STEPwrite(ostream &out, const char *currSch) const } } -SingleLinkNode *STEPaggregate::NewNode() -{ +SingleLinkNode * STEPaggregate::NewNode() { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPaggregate::NewNode \n" << _POC_ << "\n"; return 0; } -void STEPaggregate::AddNode(SingleLinkNode *n) -{ - SingleLinkList::AppendNode(n); +void STEPaggregate::AddNode( SingleLinkNode * n ) { + SingleLinkList::AppendNode( n ); _null = false; } -void STEPaggregate::Empty() -{ +void STEPaggregate::Empty() { SingleLinkList::Empty(); _null = true; } @@ -291,38 +278,35 @@ void STEPaggregate::Empty() // STEPnode /////////////////////////////////////////////////////////////////////////////// -Severity STEPnode::StrToVal(const char *s, ErrorDescriptor *err) -{ +Severity STEPnode::StrToVal( const char * s, ErrorDescriptor * err ) { // defined in subtypes (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg("Aggr. attr value: '\n"); - err->AppendToDetailMsg("not assigned.\n"); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( "Aggr. attr value: '\n" ); + err->AppendToDetailMsg( "not assigned.\n" ); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::StrToVal(istream &in, ErrorDescriptor *err) -{ +Severity STEPnode::StrToVal( istream & in, ErrorDescriptor * err ) { // defined in subtypes (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg("Aggr. attr value: '\n"); - err->AppendToDetailMsg("not assigned.\n"); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( "Aggr. attr value: '\n" ); + err->AppendToDetailMsg( "not assigned.\n" ); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::STEPread(const char *s, ErrorDescriptor *err) -{ +Severity STEPnode::STEPread( const char * s, ErrorDescriptor * err ) { // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -332,14 +316,13 @@ Severity STEPnode::STEPread(const char *s, ErrorDescriptor *err) err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity STEPnode::STEPread( istream & in, ErrorDescriptor * err ) { (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPread called instead of virtual function.\n" @@ -348,13 +331,12 @@ Severity STEPnode::STEPread(istream &in, ErrorDescriptor *err) err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -const char *STEPnode::asStr(std::string &s) -{ +const char * STEPnode::asStr( std::string & s ) { // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -379,8 +361,7 @@ const char *STEPnode::asStr(std::string &s) * selects. But since currently (3/27/97) the SCL handles 2D+ aggrs using * SCLundefined's, this is not implemented.) */ -const char *STEPnode::STEPwrite(std::string &s, const char *currSch) -{ +const char * STEPnode::STEPwrite( std::string & s, const char * currSch ) { (void) s; //unused (void) currSch; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -389,8 +370,7 @@ const char *STEPnode::STEPwrite(std::string &s, const char *currSch) return ""; } -void STEPnode::STEPwrite(ostream &out) -{ +void STEPnode::STEPwrite( ostream & out ) { (void) out; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPwrite called instead of virtual function.\n" diff --git a/src/clstepcore/STEPaggregate.h b/src/clstepcore/STEPaggregate.h index c3882064c..df2178ee9 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/src/clstepcore/STEPaggregate.h @@ -30,90 +30,85 @@ extern STEPaggregate NilSTEPaggregate; class SingleLinkNode; -typedef STEPaggregate *STEPaggregateH; -typedef STEPaggregate *STEPaggregate_ptr; +typedef STEPaggregate * STEPaggregateH; +typedef STEPaggregate * STEPaggregate_ptr; typedef STEPaggregate_ptr STEPaggregate_var; -class SC_CORE_EXPORT STEPaggregate : public SingleLinkList -{ +class SC_CORE_EXPORT STEPaggregate : public SingleLinkList { protected: bool _null; protected: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); public: - bool is_null() - { + bool is_null() { return _null; } - virtual Severity AggrValidLevel(const char *value, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId = 0, - int clearError = 0); + virtual Severity AggrValidLevel( const char * value, ErrorDescriptor * err, + 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, InstMgrBase *insts, - int optional, char *tokenList, int addFileId = 0, - int clearError = 0); + virtual Severity AggrValidLevel( istream & in, ErrorDescriptor * err, + 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, - InstMgrBase *insts = 0, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type = 0, - InstMgrBase *insts = 0, int addFileId = 0, - const char *currSch = 0); + virtual Severity StrToVal( const char * s, ErrorDescriptor * err = 0, + const TypeDescriptor * elem_type = 0, + InstMgrBase * insts = 0, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type = 0, + InstMgrBase * insts = 0, int addFileId = 0, + const char * currSch = 0 ); // OUTPUT - virtual const char *asStr(std::string &s) const; - virtual void STEPwrite(ostream &out = cout, const char * = 0) const; + virtual const char * asStr( std::string & s ) const; + virtual void STEPwrite( ostream & out = cout, const char * = 0 ) const; - virtual SingleLinkNode *NewNode(); - void AddNode(SingleLinkNode *); + virtual SingleLinkNode * NewNode(); + void AddNode( SingleLinkNode * ); void Empty(); STEPaggregate(); virtual ~STEPaggregate(); // COPY - defined in subtypes - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); }; -class SC_CORE_EXPORT STEPnode : public SingleLinkNode -{ - protected: - int _null; - - public: - int is_null() - { - return _null; - } - void set_null() - { - _null = 1; - } - - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); +class SC_CORE_EXPORT STEPnode : public SingleLinkNode { +protected: + int _null; + +public: + int is_null() { + return _null; + } + void set_null() { + _null = 1; + } + + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); }; -typedef STEPnode *STEPnodeH; +typedef STEPnode * STEPnodeH; #include "STEPaggrGeneric.h" #include "STEPaggrEntity.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 4509fdf9a..251beb445 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -39,10 +39,9 @@ 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, InstMgrBase *instances, int addFileId) -{ - if(_redefAttr) { - return _redefAttr->StrToVal(s, instances, addFileId); +Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int addFileId ) { + if( _redefAttr ) { + return _redefAttr->StrToVal( s, instances, addFileId ); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -50,97 +49,97 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF // set the value to be null (reinitialize the attribute value) set_null(); - int nullable = (aDesc->Optional().asInt() == BTrue); + int nullable = ( aDesc->Optional().asInt() == BTrue ); // an empty str gets assigned NULL - if(!s) { - if(nullable || IsDerived()) { // if it is derived it doesn't + if( !s ) { + if( nullable || IsDerived() ) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity(SEVERITY_INCOMPLETE); + _error.severity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } - if(s[0] == '\0') { - if(NonRefType() == STRING_TYPE) { + if( s[0] == '\0' ) { + if( NonRefType() == STRING_TYPE ) { // this is interpreted as a string with no value i.e. "". - *(ptr.S) = s; // using string class - don't need to declare space + *( ptr.S ) = s; // using string class - don't need to declare space return SEVERITY_NULL; } - if(nullable || IsDerived()) { // if it is derived it doesn't + if( nullable || IsDerived() ) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity(SEVERITY_INCOMPLETE); + _error.severity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if(IsDerived()) { // check to see if value contains: optional space, + if( IsDerived() ) { // check to see if value contains: optional space, // followed by *, followed by optional space - const char *tmpSptr = s; - while(isspace(*tmpSptr)) { + const char * tmpSptr = s; + while( isspace( *tmpSptr ) ) { tmpSptr++; } - if(*tmpSptr == '*') { + if( *tmpSptr == '*' ) { tmpSptr++; char tmpC; - int charsFound = sscanf(tmpSptr, "%c", &tmpC); - if(charsFound == EOF) { // no non-white chars followed the * + int charsFound = sscanf( tmpSptr, "%c", &tmpC ); + if( charsFound == EOF ) { // no non-white chars followed the * return SEVERITY_NULL; } } _error.AppendToDetailMsg( - "Derived attribute must have \'*\' for its value.\n"); - return _error.severity(SEVERITY_INPUT_ERROR); + "Derived attribute must have \'*\' for its value.\n" ); + return _error.severity( SEVERITY_INPUT_ERROR ); } - istringstream in((char *)s); // sz defaults to length of s + istringstream in( ( char * )s ); // sz defaults to length of s // read in value for attribute - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: { - ReadInteger(*(ptr.i), s, &_error, 0); + ReadInteger( *( ptr.i ), s, &_error, 0 ); break; } case REAL_TYPE: { - ReadReal(*(ptr.r), s, &_error, 0); + ReadReal( *( ptr.r ), s, &_error, 0 ); break; } case NUMBER_TYPE: { - ReadNumber(*(ptr.r), s, &_error, 0); + ReadNumber( *( ptr.r ), s, &_error, 0 ); break; } case ENTITY_TYPE: { - STEPentity *se = ReadEntityRef(s, &_error, 0, instances, addFileId); - if(se != S_ENTITY_NULL) { - if(EntityValidLevel(se, aDesc->NonRefTypeDescriptor(), - &_error) - == SEVERITY_NULL) { - *(ptr.c) = se; + STEPentity * se = ReadEntityRef( s, &_error, 0, instances, addFileId ); + if( se != S_ENTITY_NULL ) { + if( EntityValidLevel( se, aDesc->NonRefTypeDescriptor(), + &_error ) + == SEVERITY_NULL ) { + *( ptr.c ) = se; } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } break; } case BINARY_TYPE: { - ptr.b->StrToVal(s, &_error); // call class SDAI_Binary::StrToVal() + ptr.b->StrToVal( s, &_error ); // call class SDAI_Binary::StrToVal() break; } case STRING_TYPE: { - *(ptr.S) = s; // using string class - don't need to declare space + *( ptr.S ) = s; // using string class - don't need to declare space break; } case BOOLEAN_TYPE: case LOGICAL_TYPE: case ENUM_TYPE: { - ptr.e->StrToVal(s, &_error, nullable); + ptr.e->StrToVal( s, &_error, nullable ); break; } @@ -149,15 +148,15 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> StrToVal(s, &_error, - aDesc -> AggrElemTypeDescriptor(), - instances, addFileId); + ptr.a -> StrToVal( s, &_error, + aDesc -> AggrElemTypeDescriptor(), + instances, addFileId ); break; case SELECT_TYPE: - if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0)) - != SEVERITY_NULL) { - _error.AppendToDetailMsg(ptr.sh ->Error()); + if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0 ) ) + != SEVERITY_NULL ) { + _error.AppendToDetailMsg( ptr.sh ->Error() ); } break; @@ -165,7 +164,7 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF case GENERIC_TYPE: default: // other cases are the same for StrToVal and file - return STEPread(in, instances, addFileId); + return STEPread( in, instances, addFileId ); } return _error.severity(); } @@ -188,14 +187,13 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF ** value >= SEVERITY_WARNING means program can continue parsing input, ** value <= SEVERITY_INPUT_ERROR is fatal read error ******************************************************************/ -Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFileId, - const char *currSch, bool strict) -{ +Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int addFileId, + const char * currSch, bool strict ) { // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->STEPread(in, instances, addFileId, currSch); + if( _redefAttr ) { + return _redefAttr->STEPread( in, instances, addFileId, currSch ); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -206,119 +204,119 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil in >> ws; // skip whitespace char c = in.peek(); - if(IsDerived()) { - if(c == '*') { - in.get(c); // take * off the istream - _error.severity(SEVERITY_NULL); + if( IsDerived() ) { + if( c == '*' ) { + in.get( c ); // take * off the istream + _error.severity( SEVERITY_NULL ); } else { - _error.severity(SEVERITY_WARNING); - _error.AppendToDetailMsg(" WARNING: attribute '"); - _error.AppendToDetailMsg(aDesc->Name()); - _error.AppendToDetailMsg("' of type '"); - _error.AppendToDetailMsg(aDesc->TypeName()); - _error.AppendToDetailMsg("' - missing asterisk for derived attribute.\n"); + _error.severity( SEVERITY_WARNING ); + _error.AppendToDetailMsg( " WARNING: attribute '" ); + _error.AppendToDetailMsg( aDesc->Name() ); + _error.AppendToDetailMsg( "' of type '" ); + _error.AppendToDetailMsg( aDesc->TypeName() ); + _error.AppendToDetailMsg( "' - missing asterisk for derived attribute.\n" ); } - CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); + CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); return _error.severity(); } PrimitiveType attrBaseType = NonRefType(); // check for NULL or derived attribute value, return if either - switch(c) { + switch( c ) { case '$': case ',': case ')': - if(c == '$') { + if( c == '$' ) { in.ignore(); - CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); + CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); } - if(Nullable()) { - _error.severity(SEVERITY_NULL); - } else if(!strict) { + if( Nullable() ) { + _error.severity( SEVERITY_NULL ); + } else if( !strict ) { std::string fillerValue; // we aren't in strict mode, so find out the type of the missing attribute and insert a suitable value. ErrorDescriptor err; //this will be discarded - switch(attrBaseType) { + switch( attrBaseType ) { case INTEGER_TYPE: { fillerValue = "'0',"; - ReadInteger(*(ptr.i), fillerValue.c_str(), &err, ",)"); + ReadInteger( *( ptr.i ), fillerValue.c_str(), &err, ",)" ); break; } case REAL_TYPE: { fillerValue = "'0.0',"; - ReadReal(*(ptr.r), fillerValue.c_str(), &err, ",)"); + ReadReal( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); break; } case NUMBER_TYPE: { fillerValue = "'0',"; - ReadNumber(*(ptr.r), fillerValue.c_str(), &err, ",)"); + ReadNumber( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); break; } case STRING_TYPE: { fillerValue = "'',"; - *(ptr.S) = "''"; + *( ptr.S ) = "''"; break; } default: { //do not know what a good value would be for other types - _error.severity(SEVERITY_INCOMPLETE); - _error.AppendToDetailMsg(" missing and required\n"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.AppendToDetailMsg( " missing and required\n" ); return _error.severity(); } } - if(err.severity() <= SEVERITY_INCOMPLETE) { - _error.severity(SEVERITY_BUG); - _error.AppendToDetailMsg(" Error in STEPattribute::STEPread()\n"); + if( err.severity() <= SEVERITY_INCOMPLETE ) { + _error.severity( SEVERITY_BUG ); + _error.AppendToDetailMsg( " Error in STEPattribute::STEPread()\n" ); return _error.severity(); } //create a warning. SEVERITY_WARNING makes more sense to me, but is considered more severe than SEVERITY_INCOMPLETE - _error.severity(SEVERITY_USERMSG); - _error.AppendToDetailMsg(" missing and required. For compatibility, replacing with "); - _error.AppendToDetailMsg(fillerValue.substr(0, fillerValue.length() - 1)); - _error.AppendToDetailMsg(".\n"); + _error.severity( SEVERITY_USERMSG ); + _error.AppendToDetailMsg( " missing and required. For compatibility, replacing with " ); + _error.AppendToDetailMsg( fillerValue.substr( 0, fillerValue.length() - 1 ) ); + _error.AppendToDetailMsg( ".\n" ); } else { - _error.severity(SEVERITY_INCOMPLETE); - _error.AppendToDetailMsg(" missing and required\n"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.AppendToDetailMsg( " missing and required\n" ); } return _error.severity(); } - switch(attrBaseType) { + switch( attrBaseType ) { case INTEGER_TYPE: { - ReadInteger(*(ptr.i), in, &_error, ",)"); + ReadInteger( *( ptr.i ), in, &_error, ",)" ); return _error.severity(); } case REAL_TYPE: { - ReadReal(*(ptr.r), in, &_error, ",)"); + ReadReal( *( ptr.r ), in, &_error, ",)" ); return _error.severity(); } case NUMBER_TYPE: { - ReadNumber(*(ptr.r), in, &_error, ",)"); + ReadNumber( *( ptr.r ), in, &_error, ",)" ); return _error.severity(); } case STRING_TYPE: { - ptr.S->STEPread(in, &_error); - CheckRemainingInput(in, &_error, "string", ",)"); + ptr.S->STEPread( in, &_error ); + CheckRemainingInput( in, &_error, "string", ",)" ); return _error.severity(); } case BINARY_TYPE: { // call class SDAI_Binary::STEPread() - ptr.b->STEPread(in, &_error); - CheckRemainingInput(in, &_error, "binary", ",)"); + ptr.b->STEPread( in, &_error ); + CheckRemainingInput( in, &_error, "binary", ",)" ); return _error.severity(); } case BOOLEAN_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "boolean", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "boolean", ",)" ); return _error.severity(); } case LOGICAL_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "logical", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "logical", ",)" ); return _error.severity(); } case ENUM_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "enumeration", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "enumeration", ",)" ); return _error.severity(); } case AGGREGATE_TYPE: @@ -326,49 +324,49 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - ptr.a->STEPread(in, &_error, - aDesc->AggrElemTypeDescriptor(), - instances, addFileId, currSch); + ptr.a->STEPread( in, &_error, + aDesc->AggrElemTypeDescriptor(), + instances, addFileId, currSch ); // cannot recover so give up and let STEPentity recover - if(_error.severity() < SEVERITY_WARNING) { + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } // check for garbage following the aggregate - CheckRemainingInput(in, &_error, "aggregate", ",)"); + CheckRemainingInput( in, &_error, "aggregate", ",)" ); return _error.severity(); } case ENTITY_TYPE: { - STEPentity *se = ReadEntityRef(in, &_error, ",)", instances, - addFileId); - if(se != S_ENTITY_NULL) { - if(EntityValidLevel(se, - aDesc->NonRefTypeDescriptor(), - &_error) == SEVERITY_NULL) { - *(ptr.c) = se; + STEPentity * se = ReadEntityRef( in, &_error, ",)", instances, + addFileId ); + if( se != S_ENTITY_NULL ) { + if( EntityValidLevel( se, + aDesc->NonRefTypeDescriptor(), + &_error ) == SEVERITY_NULL ) { + *( ptr.c ) = se; } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } return _error.severity(); } case SELECT_TYPE: - if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0, - addFileId, currSch)) - != SEVERITY_NULL) { - _error.AppendToDetailMsg(ptr.sh ->Error()); + if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0, + addFileId, currSch ) ) + != SEVERITY_NULL ) { + _error.AppendToDetailMsg( ptr.sh ->Error() ); } - CheckRemainingInput(in, &_error, "select", ",)"); + CheckRemainingInput( in, &_error, "select", ",)" ); return _error.severity(); case GENERIC_TYPE: { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return _error.severity(); } @@ -378,7 +376,7 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil // bug cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return _error.severity(); } } @@ -390,155 +388,59 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil ** \returns the value of the attribute ** Status: complete 3/91 *********************************************************************/ -const char *STEPattribute::asStr(std::string &str, const char *currSch) const -{ - ostringstream ss; - - str.clear(); - - // The attribute has been derived by a subtype's attribute - if(IsDerived()) { - str = "*"; - return const_cast(str.c_str()); - } - - // The attribute has been redefined by the attribute pointed - // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->asStr(str, currSch); - } - - if(is_null()) { - str = ""; - return const_cast(str.c_str()); - } - - switch(NonRefType()) { - case INTEGER_TYPE: - ss << *(ptr.i); - str += ss.str(); - break; - - case NUMBER_TYPE: - case REAL_TYPE: - - ss.precision((int) Real_Num_Precision); - ss << *(ptr.r); - str += ss.str(); - break; - - case ENTITY_TYPE: - // print instance id only if not empty pointer - // and has value assigned - if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { - break; - } else { - (*(ptr.c))->STEPwrite_reference(str); - } - break; - - case BINARY_TYPE: - if(!((ptr.b)->empty())) { - (ptr.b) -> STEPwrite(str); - } - break; - - case STRING_TYPE: - if(!((ptr.S)->empty())) { - return (ptr.S) -> asStr(str); - } - break; - - case AGGREGATE_TYPE: - case ARRAY_TYPE: // DAS - case BAG_TYPE: // DAS - case SET_TYPE: // DAS - case LIST_TYPE: // DAS - return ptr.a->asStr(str) ; - - case ENUM_TYPE: - case BOOLEAN_TYPE: - case LOGICAL_TYPE: - return ptr.e -> asStr(str); - - case SELECT_TYPE: - ptr.sh -> STEPwrite(str, currSch); - return const_cast(str.c_str()); - - case REFERENCE_TYPE: - case GENERIC_TYPE: - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return 0; - - case UNKNOWN_TYPE: - default: - return (ptr.u -> asStr(str)); - } - return const_cast(str.c_str()); -} - - -/*****************************************************************//** - ** \fn asStr - ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). - ** \returns the value of the attribute - ** Status: complete 3/91 - *********************************************************************/ -std::string STEPattribute::asStr(const char *currSch) const -{ +std::string STEPattribute::asStr( const char * currSch ) const { ostringstream ss; std::string str; // The attribute has been derived by a subtype's attribute - if(IsDerived()) { + if( IsDerived() ) { str = "*"; return str; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->asStr(currSch); + if( _redefAttr ) { + return _redefAttr->asStr( currSch ); } - if(is_null()) { + if( is_null() ) { return str; } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - ss << *(ptr.i); + ss << *( ptr.i ); str += ss.str(); break; case NUMBER_TYPE: case REAL_TYPE: - ss.precision((int) Real_Num_Precision); - ss << *(ptr.r); + ss.precision( ( int ) Real_Num_Precision ); + ss << *( ptr.r ); str += ss.str(); break; case ENTITY_TYPE: // print instance id only if not empty pointer // and has value assigned - if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { + if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { break; } else { - (*(ptr.c))->STEPwrite_reference(str); + ( *( ptr.c ) )->STEPwrite_reference( str ); } break; case BINARY_TYPE: - if(!(ptr.b->empty())) { - ptr.b->STEPwrite(str); + if( !( ptr.b->empty() ) ) { + ptr.b->STEPwrite( str ); } break; case STRING_TYPE: - if(!((ptr.S)->empty())) { - ptr.S->asStr(str); + if( !( ( ptr.S )->empty() ) ) { + ptr.S->asStr( str ); } break; @@ -547,17 +449,17 @@ std::string STEPattribute::asStr(const char *currSch) const case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a->asStr(str); + ptr.a->asStr( str ); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - ptr.e->asStr(str); + ptr.e->asStr( str ); break; case SELECT_TYPE: - ptr.sh->STEPwrite(str, currSch); + ptr.sh->STEPwrite( str, currSch ); break; case REFERENCE_TYPE: @@ -569,22 +471,21 @@ std::string STEPattribute::asStr(const char *currSch) const case UNKNOWN_TYPE: default: - ptr.u->asStr(str); + ptr.u->asStr( str ); } return str; } /// write '$' to out, put message in error, write brief error to stderr -void STEPattribute::STEPwriteError(ostream &out, unsigned int line, const char *desc) -{ +void STEPattribute::STEPwriteError( ostream & out, unsigned int line, const char* desc ) { out << "$"; cerr << "Internal error: " << __FILE__ << ":" << line << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); std::stringstream ss; ss << " Warning: attribute '" << Name() << " : " << TypeName() << "' " << desc << std::endl; - _error.AppendToUserMsg(ss.str()); - _error.AppendToDetailMsg(ss.str()); + _error.AppendToUserMsg( ss.str() ); + _error.AppendToDetailMsg( ss.str() ); } /** @@ -592,62 +493,61 @@ void STEPattribute::STEPwriteError(ostream &out, unsigned int line, const char * * The output is in physical file format. * */ -void STEPattribute::STEPwrite(ostream &out, const char *currSch) -{ +void STEPattribute::STEPwrite( ostream & out, const char * currSch ) { // The attribute has been derived by a subtype's attribute - if(IsDerived()) { + if( IsDerived() ) { out << "*"; return; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - _redefAttr->STEPwrite(out); + if( _redefAttr ) { + _redefAttr->STEPwrite( out ); return; } - if(is_null()) { + if( is_null() ) { out << "$"; return; } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - out << *(ptr.i); + out << *( ptr.i ); break; case NUMBER_TYPE: case REAL_TYPE: { - WriteReal(*(ptr.r), out); + WriteReal( *( ptr.r ), out ); break; } case ENTITY_TYPE: // print instance id only if not empty pointer - if((ptr.c == 0) || (*(ptr.c) == 0) || + if( ( ptr.c == 0 ) || ( *( ptr.c ) == 0 ) || // no value was assigned <-- this would be a BUG - (*(ptr.c) == S_ENTITY_NULL)) { - STEPwriteError(out, __LINE__, "is null and shouldn't be."); + ( *( ptr.c ) == S_ENTITY_NULL ) ) { + STEPwriteError( out, __LINE__, "is null and shouldn't be." ); } else { - (*(ptr.c)) -> STEPwrite_reference(out); + ( *( ptr.c ) ) -> STEPwrite_reference( out ); } break; case STRING_TYPE: // if null pointer or pointer to a string of length zero - if(ptr.S) { - (ptr.S) -> STEPwrite(out); + if( ptr.S ) { + ( ptr.S ) -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at an SDAI_String."); + STEPwriteError( out, __LINE__, "should be pointing at an SDAI_String." ); } break; case BINARY_TYPE: // if null pointer or pointer to a string of length zero - if(ptr.b) { - (ptr.b) -> STEPwrite(out); + if( ptr.b ) { + ( ptr.b ) -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at an SDAI_Binary."); + STEPwriteError( out, __LINE__, "should be pointing at an SDAI_Binary." ); } break; @@ -656,54 +556,53 @@ void STEPattribute::STEPwrite(ostream &out, const char *currSch) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> STEPwrite(out, currSch); + ptr.a -> STEPwrite( out, currSch ); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - if(ptr.e) { - ptr.e -> STEPwrite(out); + if( ptr.e ) { + ptr.e -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Enum class."); + STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Enum class." ); } break; case SELECT_TYPE: - if(ptr.sh) { - ptr.sh -> STEPwrite(out, currSch); + if( ptr.sh ) { + ptr.sh -> STEPwrite( out, currSch ); } else { - STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Select class."); + STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Select class." ); } break; case REFERENCE_TYPE: case GENERIC_TYPE: cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return; case UNKNOWN_TYPE: default: - ptr.u -> STEPwrite(out); + ptr.u -> STEPwrite( out ); break; } } -void STEPattribute::ShallowCopy(const STEPattribute *sa) -{ +void STEPattribute::ShallowCopy( const STEPattribute * sa ) { _mustDeletePtr = false; aDesc = sa->aDesc; refCount = 0; _derive = sa->_derive; _redefAttr = sa->_redefAttr; - if(_redefAttr) { - _redefAttr->ShallowCopy(sa); + if( _redefAttr ) { + _redefAttr->ShallowCopy( sa ); } //Should we just use memcpy()? That would be a true shallowCopy - switch(sa->NonRefType()) { + switch( sa->NonRefType() ) { case INTEGER_TYPE: ptr.i = sa->ptr.i; break; @@ -724,7 +623,7 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - switch(sa->BaseType()) { + switch( sa->BaseType() ) { case sdaiAGGR: ptr.a = new GenericAggregate; break; @@ -758,11 +657,11 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) break; default: std::cerr << "WARNING: Reached default case for BaseType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; + << "ShallowCopy(). New attribute may be invalid." << std::endl; ptr.a = new STEPaggregate; break; } - ptr.a->ShallowCopy(*(sa->ptr.a)); + ptr.a->ShallowCopy( *( sa->ptr.a ) ); _mustDeletePtr = true; break; case SELECT_TYPE: @@ -770,12 +669,12 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) break; case BOOLEAN_TYPE: ptr.e = new SDAI_BOOLEAN; - ptr.e->put(sa->ptr.e->asInt()); + ptr.e->put( sa->ptr.e->asInt() ); _mustDeletePtr = true; break; case LOGICAL_TYPE: ptr.e = new SDAI_LOGICAL; - ptr.e->put(sa->ptr.e->asInt()); + ptr.e->put( sa->ptr.e->asInt() ); _mustDeletePtr = true; break; @@ -783,8 +682,8 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) case ENUM_TYPE: default: std::cerr << "WARNING: Reached default case for NonRefType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; - memcpy(& ptr, & (sa->ptr), sizeof(sa->ptr)); + << "ShallowCopy(). New attribute may be invalid." << std::endl; + memcpy( & ptr, & ( sa->ptr ), sizeof( sa->ptr ) ); break; } } @@ -794,26 +693,25 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) * will exist in member variable ptr but SDAI_string will be told to report * as not containing a value (even a value of no chars). */ -Severity STEPattribute::set_null() -{ - if(_redefAttr) { +Severity STEPattribute::set_null() { + if( _redefAttr ) { return _redefAttr->set_null(); } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - *(ptr.i) = S_INT_NULL; + *( ptr.i ) = S_INT_NULL; break; case NUMBER_TYPE: - *(ptr.r) = S_NUMBER_NULL; + *( ptr.r ) = S_NUMBER_NULL; break; case REAL_TYPE: - *(ptr.r) = S_REAL_NULL; + *( ptr.r ) = S_REAL_NULL; break; case ENTITY_TYPE: - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; break; case STRING_TYPE: @@ -854,11 +752,11 @@ Severity STEPattribute::set_null() 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); + _error.AppendToDetailMsg( err.str() ); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } - if(Nullable()) { + if( Nullable() ) { return SEVERITY_NULL; } else { return SEVERITY_INCOMPLETE; @@ -869,32 +767,31 @@ Severity STEPattribute::set_null() * For a string value this reports whether the string exists (as reported by * SDAI_String ) not whether SDAI_String contains a null string. */ -bool STEPattribute::is_null() const -{ - if(_redefAttr) { +bool STEPattribute::is_null() const { + if( _redefAttr ) { return _redefAttr->is_null(); } /* for NUMBER_TYPE and REAL_TYPE, we want an exact comparison. however, doing so causes a compiler warning. * workaround is to use memcmp. need a variable, but can't declare it within the switch without errors. */ SDAI_Real z; - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - return (*(ptr.i) == S_INT_NULL); + return ( *( ptr.i ) == S_INT_NULL ); case NUMBER_TYPE: z = S_NUMBER_NULL; - return (0 == memcmp(ptr.r, &z, sizeof z)); + return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); case REAL_TYPE: z = S_REAL_NULL; - return (0 == memcmp(ptr.r, &z, sizeof z)); + return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); case ENTITY_TYPE: - return (*(ptr.c) == S_ENTITY_NULL); + return ( *( ptr.c ) == S_ENTITY_NULL ); case STRING_TYPE: - return (*(ptr.S) == S_STRING_NULL); + return ( *( ptr.S ) == S_STRING_NULL ); case BINARY_TYPE: return ptr.b->empty(); @@ -904,16 +801,16 @@ bool STEPattribute::is_null() const case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return (ptr.a -> is_null()); + return ( ptr.a -> is_null() ); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return (ptr.e -> is_null()); + return ( ptr.e -> is_null() ); case SELECT_TYPE: - return(ptr.sh->is_null()); + return( ptr.sh->is_null() ); case REFERENCE_TYPE: case GENERIC_TYPE: @@ -921,104 +818,92 @@ bool STEPattribute::is_null() const return true; case UNKNOWN_TYPE: default: - return (ptr.u -> is_null()); + return ( ptr.u -> is_null() ); } } // these get the attr value -SDAI_Integer *STEPattribute::Integer() -{ - if(NonRefType() == INTEGER_TYPE) { +SDAI_Integer * STEPattribute::Integer(){ + if( NonRefType() == INTEGER_TYPE ) { return ptr.i; } return 0; } -SDAI_Real *STEPattribute::Number() -{ - if(NonRefType() == NUMBER_TYPE) { +SDAI_Real * STEPattribute::Number() { + if( NonRefType() == NUMBER_TYPE ) { return ptr.r; } return 0; } -SDAI_Real *STEPattribute::Real() -{ - if(NonRefType() == REAL_TYPE) { +SDAI_Real * STEPattribute::Real() { + if( NonRefType() == REAL_TYPE ) { return ptr.r; } return 0; } -SDAI_Application_instance *STEPattribute::Entity() -{ - if(NonRefType() == ENTITY_TYPE) { - return *(ptr.c); +SDAI_Application_instance * STEPattribute::Entity() { + if( NonRefType() == ENTITY_TYPE ) { + return *( ptr.c ); } return 0; } -SDAI_String *STEPattribute::String() -{ - if(NonRefType() == STRING_TYPE) { +SDAI_String * STEPattribute::String() { + if( NonRefType() == STRING_TYPE ) { return ptr.S; } return 0; } -SDAI_Binary *STEPattribute::Binary() -{ - if(NonRefType() == BINARY_TYPE) { +SDAI_Binary * STEPattribute::Binary() { + if( NonRefType() == BINARY_TYPE ) { return ptr.b; } return 0; } -STEPaggregate *STEPattribute::Aggregate() -{ - if((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) - || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)) { +STEPaggregate * STEPattribute::Aggregate() { + if( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) + || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ) { return ptr.a; } return 0; } -SDAI_BOOLEAN *STEPattribute::Boolean() -{ - if(NonRefType() == BOOLEAN_TYPE) { - return (SDAI_BOOLEAN *) ptr.e; +SDAI_BOOLEAN * STEPattribute::Boolean() { + if( NonRefType() == BOOLEAN_TYPE ) { + return ( SDAI_BOOLEAN * ) ptr.e; } return 0; } -SDAI_LOGICAL *STEPattribute::Logical() -{ - if(NonRefType() == LOGICAL_TYPE) { - return (SDAI_LOGICAL *) ptr.e; +SDAI_LOGICAL * STEPattribute::Logical() { + if( NonRefType() == LOGICAL_TYPE ) { + return ( SDAI_LOGICAL * ) ptr.e; } return 0; } -SDAI_Enum *STEPattribute::Enum() -{ - if(NonRefType() == ENUM_TYPE) { +SDAI_Enum * STEPattribute::Enum() { + if( NonRefType() == ENUM_TYPE ) { return ptr.e; } return 0; } -SDAI_Select *STEPattribute::Select() -{ - if(NonRefType() == SELECT_TYPE) { +SDAI_Select * STEPattribute::Select() { + if( NonRefType() == SELECT_TYPE ) { return ptr.sh; } return 0; } -SCLundefined *STEPattribute::Undefined() -{ - if((NonRefType() != REFERENCE_TYPE) && (NonRefType() != GENERIC_TYPE)) { +SCLundefined * STEPattribute::Undefined() { + if( ( NonRefType() != REFERENCE_TYPE ) && ( NonRefType() != GENERIC_TYPE ) ) { return ptr.u; } return 0; @@ -1026,127 +911,115 @@ SCLundefined *STEPattribute::Undefined() // these set the attr value -void STEPattribute::Integer(SDAI_Integer *n) -{ - assert(NonRefType() == INTEGER_TYPE); - if(ptr.i) { - *(ptr.i) = * n; +void STEPattribute::Integer( SDAI_Integer * n ) { + assert( NonRefType() == INTEGER_TYPE ); + if( ptr.i ) { + *( ptr.i ) = * n; } else { ptr.i = n; } } -void STEPattribute::Real(SDAI_Real *n) -{ - assert(NonRefType() == REAL_TYPE); - if(ptr.r) { - *(ptr.r) = * n; +void STEPattribute::Real( SDAI_Real * n ) { + assert( NonRefType() == REAL_TYPE ); + if( ptr.r ) { + *( ptr.r ) = * n; } else { ptr.r = n; } } -void STEPattribute::Number(SDAI_Real *n) -{ - assert(NonRefType() == NUMBER_TYPE); - if(ptr.r) { - *(ptr.r) = * n; +void STEPattribute::Number( SDAI_Real * n ) { + assert( NonRefType() == NUMBER_TYPE ); + if( ptr.r ) { + *( ptr.r ) = * n; } else { ptr.r = n; } } -void STEPattribute::String(SDAI_String *str) -{ - assert(NonRefType() == STRING_TYPE); - if(ptr.S) { - *(ptr.S) = * str; +void STEPattribute::String( SDAI_String * str ) { + assert( NonRefType() == STRING_TYPE ); + if( ptr.S ) { + *( ptr.S ) = * str; } else { ptr.S = str; } } -void STEPattribute::Binary(SDAI_Binary *bin) -{ - assert(NonRefType() == BINARY_TYPE); - if(ptr.b) { - *(ptr.b) = * bin; +void STEPattribute::Binary( SDAI_Binary * bin ) { + assert( NonRefType() == BINARY_TYPE ); + if( ptr.b ) { + *( ptr.b ) = * bin; } else { ptr.b = bin; } } -void STEPattribute::Entity(SDAI_Application_instance *ent) -{ - assert(NonRefType() == ENTITY_TYPE); - if(ptr.c) { +void STEPattribute::Entity( SDAI_Application_instance * ent ) { + assert( NonRefType() == ENTITY_TYPE ); + if( ptr.c ) { delete ptr.c; } - ptr.c = new(SDAI_Application_instance *); - *(ptr.c) = ent; + ptr.c = new (SDAI_Application_instance * ); + *( ptr.c ) = ent; } -void STEPattribute::Aggregate(STEPaggregate *aggr) -{ - assert((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) - || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)); - if(ptr.a) { - *(ptr.a) = * aggr; +void STEPattribute::Aggregate( STEPaggregate * aggr ) { + assert( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) + || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ); + if( ptr.a ) { + *( ptr.a ) = * aggr; } else { ptr.a = aggr; } } -void STEPattribute::Enum(SDAI_Enum *enu) -{ - assert(NonRefType() == ENUM_TYPE); - if(ptr.e) { +void STEPattribute::Enum( SDAI_Enum * enu ) { + assert( NonRefType() == ENUM_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = * enu; + *( ptr.e ) = * enu; } else { ptr.e = enu; } } -void STEPattribute::Logical(SDAI_LOGICAL *log) -{ - assert(NonRefType() == LOGICAL_TYPE); - if(ptr.e) { +void STEPattribute::Logical( SDAI_LOGICAL * log ) { + assert( NonRefType() == LOGICAL_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = * log; + *( ptr.e ) = * log; } else { ptr.e = log; } } -void STEPattribute::Boolean(SDAI_BOOLEAN *boo) -{ - assert(NonRefType() == BOOLEAN_TYPE); - if(ptr.e) { +void STEPattribute::Boolean( SDAI_BOOLEAN * boo ) { + assert( NonRefType() == BOOLEAN_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = *boo; + *( ptr.e ) = *boo; } else { ptr.e = boo; } } -void STEPattribute::Select(SDAI_Select *sel) -{ - assert(NonRefType() == SELECT_TYPE); - if(ptr.sh) { +void STEPattribute::Select( SDAI_Select * sel ) { + assert( NonRefType() == SELECT_TYPE ); + if( ptr.sh ) { ptr.sh->set_null(); - *(ptr.sh) = * sel; + *( ptr.sh ) = * sel; } else { ptr.sh = sel; } } -void STEPattribute::Undefined(SCLundefined *undef) -{ +void STEPattribute::Undefined( SCLundefined * undef ) { //FIXME is this right, or is the Undefined() above right? - assert(NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE); - if(ptr.u) { - *(ptr.u) = * undef; + assert( NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE ); + if( ptr.u ) { + *( ptr.u ) = * undef; } else { ptr.u = undef; } @@ -1157,13 +1030,12 @@ void STEPattribute::Undefined(SCLundefined *undef) * ignores _error and refCount, since those are ancillary * \return true if equal */ -bool operator == (const STEPattribute &a1, const STEPattribute &a2) -{ - if(& a1 == & a2) { +bool operator == ( const STEPattribute & a1, const STEPattribute & a2 ) { + if( & a1 == & a2 ) { return true; } - if(a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr) { - if(0 == memcmp(& a1.ptr, & a2.ptr, sizeof(a1.ptr))) { + if( a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr ){ + if( 0 == memcmp( & a1.ptr, & a2.ptr, sizeof( a1.ptr ) ) ) { return true; } else { //ptr differs between a1 and a2, but contents aren't necessarily different @@ -1177,14 +1049,12 @@ bool operator == (const STEPattribute &a1, const STEPattribute &a2) * ignores _error and refCount, since those are ancillary * \return true if not equal */ -bool operator != (const STEPattribute &a1, const STEPattribute &a2) -{ - return !(a1 == a2); +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) -{ +bool sameADesc( const STEPattribute & a1, const STEPattribute & a2 ) { return a1.aDesc == a2.aDesc; } @@ -1196,85 +1066,84 @@ 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, InstMgrBase *im, bool clearError) -{ - if(clearError) { +Severity STEPattribute::ValidLevel( const char * attrValue, ErrorDescriptor * error, InstMgrBase * im, bool clearError ) { + if( clearError ) { ClearErrorMsg(); } - if(_redefAttr) { - return _redefAttr->ValidLevel(attrValue, error, im, clearError); + if( _redefAttr ) { + return _redefAttr->ValidLevel( attrValue, error, im, clearError ); } bool optional = Nullable(); - if(!attrValue) { - if(optional) { + if( !attrValue ) { + if( optional ) { return error->severity(); } else { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } - if(attrValue[0] == '\0') { - if(NonRefType() == STRING_TYPE) { + if( attrValue[0] == '\0' ) { + if( NonRefType() == STRING_TYPE ) { // this is interpreted as a string with no value i.e. "". // Thus if it exists it has to be valid. return SEVERITY_NULL; } - if(optional) { + if( optional ) { return error->severity(); } else { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if(IsDerived()) { - if(!strcmp(attrValue, "*")) { + if( IsDerived() ) { + if( !strcmp( attrValue, "*" ) ) { return SEVERITY_NULL; } else { - _error.AppendToDetailMsg("attr is derived - value not permitted\n"); - return _error.severity(SEVERITY_INPUT_ERROR); + _error.AppendToDetailMsg( "attr is derived - value not permitted\n" ); + return _error.severity( SEVERITY_INPUT_ERROR ); } } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - return IntValidLevel(attrValue, error, clearError, optional, 0); + return IntValidLevel( attrValue, error, clearError, optional, 0 ); case STRING_TYPE: // if a value exists (checked above) then that is the string value return SEVERITY_NULL; case REAL_TYPE: - return RealValidLevel(attrValue, error, clearError, optional, 0); + return RealValidLevel( attrValue, error, clearError, optional, 0 ); case NUMBER_TYPE: - return NumberValidLevel(attrValue, error, clearError, optional, 0); + return NumberValidLevel( attrValue, error, clearError, optional, 0 ); case ENTITY_TYPE: - return EntityValidLevel(attrValue, - aDesc->NonRefTypeDescriptor(), - error, im, 0); + return EntityValidLevel( attrValue, + aDesc->NonRefTypeDescriptor(), + error, im, 0 ); case BINARY_TYPE: - return ptr.b->BinaryValidLevel(attrValue, &_error, optional, 0); + return ptr.b->BinaryValidLevel( attrValue, &_error, optional, 0 ); case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return ptr.a->AggrValidLevel(attrValue, error, - aDesc->AggrElemTypeDescriptor(), im, - optional, 0, 0, 0); + return ptr.a->AggrValidLevel( attrValue, error, + aDesc->AggrElemTypeDescriptor(), im, + optional, 0, 0, 0 ); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return ptr.e->EnumValidLevel(attrValue, error, optional, 0, 0, 1); + return ptr.e->EnumValidLevel( attrValue, error, optional, 0, 0, 1 ); case SELECT_TYPE: - return ptr.sh->SelectValidLevel(attrValue, error, im); + return ptr.sh->SelectValidLevel( attrValue, error, im ); default: cerr << "Internal error: " << __FILE__ << __LINE__ @@ -1288,9 +1157,8 @@ Severity STEPattribute::ValidLevel(const char *attrValue, ErrorDescriptor *error ** \param a -- attribute to output ** Description: overloads the output operator to print an attribute ******************************************************************/ -ostream &operator<< (ostream &out, STEPattribute &a) -{ - a.STEPwrite(out); +ostream & operator<< ( ostream & out, STEPattribute & a ) { + a.STEPwrite( out ); return out; } @@ -1300,23 +1168,22 @@ ostream &operator<< (ostream &out, STEPattribute &a) * Aggregates, and SDAI_Strings which don't know they are a STEPattribute * value. ******************************************************************/ -void STEPattribute::AddErrorInfo() -{ +void STEPattribute::AddErrorInfo() { char errStr[BUFSIZ]; errStr[0] = '\0'; - if(SEVERITY_INPUT_ERROR < _error.severity() && - _error.severity() < SEVERITY_NULL) { - sprintf(errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); - } else if(_error.severity() == SEVERITY_INPUT_ERROR) { - sprintf(errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); - } else if(_error.severity() <= SEVERITY_BUG) { - sprintf(errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); + if( SEVERITY_INPUT_ERROR < _error.severity() && + _error.severity() < SEVERITY_NULL ) { + sprintf( errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); + } else if( _error.severity() == SEVERITY_INPUT_ERROR ) { + sprintf( errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); + } else if( _error.severity() <= SEVERITY_BUG ) { + sprintf( errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); } } @@ -1325,35 +1192,34 @@ void STEPattribute::AddErrorInfo() * if it hits one of StopChars it puts it back. * RETURNS: the last char it read. ******************************************************************/ -char STEPattribute::SkipBadAttr(istream &in, char *StopChars) -{ +char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { ios_base::fmtflags flbuf = in.flags(); - in.unsetf(ios::skipws); // turn skipping whitespace off + in.unsetf( ios::skipws ); // turn skipping whitespace off // read bad data until end of this attribute or entity. - char *foundCh = 0; + char * foundCh = 0; char c = '\0'; char errStr[BUFSIZ]; errStr[0] = '\0'; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); in >> c; - while(!in.eof() && !(foundCh = strchr(StopChars, c))) { + while( !in.eof() && !( foundCh = strchr( StopChars, c ) ) ) { in >> c; } - if(in.eof()) { - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), - "Unexpected EOF when skipping bad attr value"); - _error.AppendToDetailMsg(errStr); + if( in.eof() ) { + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), + "Unexpected EOF when skipping bad attr value" ); + _error.AppendToDetailMsg( errStr ); } else { - sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), "Invalid value"); - _error.AppendToDetailMsg(errStr); + sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), "Invalid value" ); + _error.AppendToDetailMsg( errStr ); } - in.putback(c); - in.flags(flbuf); // set skip whitespace to its original state + in.putback( c ); + in.flags( flbuf ); // set skip whitespace to its original state return c; } @@ -1374,10 +1240,9 @@ char STEPattribute::SkipBadAttr(istream &in, char *StopChars) /// This is needed so that STEPattribute's can be passed as references to inline functions /// NOTE this code only does shallow copies. It may be necessary to do more, in which case /// the destructor and assignment operator will also need examined. -STEPattribute::STEPattribute(const STEPattribute &a) : _derive(a._derive), _mustDeletePtr(false), - _redefAttr(a._redefAttr), aDesc(a.aDesc), refCount(a.refCount) -{ - ShallowCopy(& a); +STEPattribute::STEPattribute( const STEPattribute & a ) : _derive( a._derive ), _mustDeletePtr( false ), +_redefAttr( a._redefAttr ), aDesc( a.aDesc ), refCount( a.refCount ) { + ShallowCopy( & a ); //NOTE may need to do a deep copy for the following types since they are classes /* @@ -1402,106 +1267,95 @@ STEPattribute::STEPattribute(const STEPattribute &a) : _derive(a._derive), _must * * default: * break; - } - */ +} +*/ } /// INTEGER -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.i = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// BINARY -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.b = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// STRING -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_String *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_String * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.S = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// REAL & NUMBER -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Real *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.r = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// ENTITY -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p): - _derive(false), _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance * *p ): +_derive( false ), _mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.c = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// AGGREGATE -STEPattribute::STEPattribute(const class AttrDescriptor &d, STEPaggregate *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.a = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// ENUMERATION and Logical -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.e = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// SELECT -STEPattribute::STEPattribute(const class AttrDescriptor &d, class SDAI_Select *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, class SDAI_Select * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.sh = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// UNDEFINED -STEPattribute::STEPattribute(const class AttrDescriptor &d, SCLundefined *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SCLundefined * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.u = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// the destructor conditionally deletes the object in ptr -STEPattribute::~STEPattribute() -{ - if(_mustDeletePtr) { - switch(NonRefType()) { +STEPattribute::~STEPattribute() { + if( _mustDeletePtr ) { + switch( NonRefType() ) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if(ptr.a) { + if( ptr.a ) { delete ptr.a; ptr.a = 0; } break; case BOOLEAN_TYPE: - if(ptr.e) { - delete(SDAI_BOOLEAN *) ptr.e; + if( ptr.e ) { + delete ( SDAI_BOOLEAN * ) ptr.e; ptr.e = 0; } - break; case LOGICAL_TYPE: - if(ptr.e) { - delete(SDAI_LOGICAL *) ptr.e; + if( ptr.e ) { + delete ( SDAI_LOGICAL * ) ptr.e; ptr.e = 0; } break; @@ -1512,57 +1366,50 @@ STEPattribute::~STEPattribute() } /// name is the same even if redefined -const char *STEPattribute::Name() const -{ +const char * STEPattribute::Name() const { return aDesc->Name(); } -const char *STEPattribute::TypeName() const -{ - if(_redefAttr) { +const char * STEPattribute::TypeName() const { + if( _redefAttr ) { return _redefAttr->TypeName(); } return aDesc->TypeName().c_str(); } -BASE_TYPE STEPattribute::Type() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::Type() const { + if( _redefAttr ) { return _redefAttr->Type(); } return aDesc->Type(); } -BASE_TYPE STEPattribute::NonRefType() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::NonRefType() const { + if( _redefAttr ) { return _redefAttr->NonRefType(); - } else if(aDesc) { + } else if( aDesc ) { return aDesc->NonRefType(); } return UNKNOWN_TYPE; } -BASE_TYPE STEPattribute::BaseType() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::BaseType() const { + if( _redefAttr ) { return _redefAttr->BaseType(); } return aDesc->BaseType(); } -const TypeDescriptor *STEPattribute::ReferentType() const -{ - if(_redefAttr) { +const TypeDescriptor * STEPattribute::ReferentType() const { + if( _redefAttr ) { return _redefAttr->ReferentType(); } return aDesc->ReferentType(); } -bool STEPattribute::Nullable() const -{ - if(_redefAttr) { +bool STEPattribute::Nullable() const { + if( _redefAttr ) { return _redefAttr->Nullable(); } - return (aDesc->Optionality().asInt() == LTrue); + return ( aDesc->Optionality().asInt() == LTrue ); } diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 7e80c8edc..e3b43e0b4 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -37,124 +37,110 @@ class EntityDescriptor; #include -extern SC_CORE_EXPORT int SetErrOnNull(const char *attrValue, ErrorDescriptor *error); +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, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ); -extern SC_CORE_EXPORT SDAI_Application_instance *ReadEntityRef(const char *s, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList, + 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) - ErrorDescriptor *err); +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) + ErrorDescriptor * err ); -extern SC_CORE_EXPORT Severity EntityValidLevel(const char *attrValue, ///< string containing entity ref - const TypeDescriptor *ed, /**< entity type that entity in attrValue (if it exists) needs +extern SC_CORE_EXPORT Severity EntityValidLevel( const char * attrValue, ///< string containing entity ref + const TypeDescriptor * ed, /**< entity type that entity in attrValue (if it exists) needs * to match. (this must be an EntityDescriptor) */ - ErrorDescriptor *err, InstMgrBase *im, int clearError); + ErrorDescriptor * err, InstMgrBase * im, int clearError ); //////////////////// //////////////////// -extern SC_CORE_EXPORT SDAI_Application_instance *STEPread_reference(const char *s, ErrorDescriptor *err, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * STEPread_reference( const char * s, ErrorDescriptor * err, + InstMgrBase * instances, int addFileId ); //////////////////// -extern SC_CORE_EXPORT int QuoteInString(istream &in); +extern SC_CORE_EXPORT int QuoteInString( istream & in ); -extern SC_CORE_EXPORT void AppendChar(char c, int &index, char *&s, int &sSize); +extern SC_CORE_EXPORT void AppendChar( char c, int & index, char *& s, int & sSize ); -extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); -class SC_CORE_EXPORT STEPattribute -{ - friend ostream &operator<< (ostream &, STEPattribute &); +class SC_CORE_EXPORT STEPattribute { + friend ostream & operator<< ( ostream &, STEPattribute & ); friend class SDAI_Application_instance; - - public: - /** \union ptr - ** You know which of these to use based on the return value of - ** NonRefType() - see below. BASE_TYPE is defined in baseType.h - ** This variable points to an appropriate member variable in the entity - ** class in the generated schema class library (the entity class is - ** inherited from SDAI_Application_instance) - */ - union attrUnion { - SDAI_String *S; // STRING_TYPE - SDAI_Integer *i; // INTEGER_TYPE (Integer is a long int) - SDAI_Binary *b; // BINARY_TYPE - SDAI_Real *r; // REAL_TYPE and NUMBER_TYPE (Real is a double) - SDAI_Application_instance * *c; // ENTITY_TYPE - STEPaggregate *a; // AGGREGATE_TYPE - SDAI_Enum *e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE - SDAI_Select *sh; // SELECT_TYPE - SCLundefined *u; // UNKNOWN_TYPE - void *p; - } ptr; - - protected: bool _derive; bool _mustDeletePtr; ///if a member uses new to create an object in ptr ErrorDescriptor _error; - STEPattribute *_redefAttr; - public: - const AttrDescriptor *aDesc; - - protected: + STEPattribute * _redefAttr; + const AttrDescriptor * aDesc; int refCount; - char SkipBadAttr(istream &in, char *StopChars); + /** \union ptr + ** You know which of these to use based on the return value of + ** NonRefType() - see below. BASE_TYPE is defined in baseType.h + ** This variable points to an appropriate member variable in the entity + ** class in the generated schema class library (the entity class is + ** inherited from SDAI_Application_instance) + */ + union attrUnion { + SDAI_String * S; // STRING_TYPE + SDAI_Integer * i; // INTEGER_TYPE (Integer is a long int) + SDAI_Binary * b; // BINARY_TYPE + SDAI_Real * r; // REAL_TYPE and NUMBER_TYPE (Real is a double) + SDAI_Application_instance * * c; // ENTITY_TYPE + STEPaggregate * a; // AGGREGATE_TYPE + SDAI_Enum * e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE + SDAI_Select * sh; // SELECT_TYPE + SCLundefined * u; // UNKNOWN_TYPE + void * p; + } ptr; + + char SkipBadAttr( istream & in, char * StopChars ); void AddErrorInfo(); - void STEPwriteError(ostream &out, unsigned int line, const char *desc); + void STEPwriteError( ostream& out, unsigned int line, const char* desc ); public: - void incrRefCount() - { + void incrRefCount() { ++ refCount; } - void decrRefCount() - { + void decrRefCount() { -- refCount; } - int getRefCount() - { + int getRefCount() { return refCount; } - const AttrDescriptor *getADesc() - { + const AttrDescriptor * getADesc() { return aDesc; } - void Derive(bool n = true) - { + void Derive( bool n = true ) { _derive = n; } - void RedefiningAttr(STEPattribute *a) - { + void RedefiningAttr( STEPattribute * a ) { _redefAttr = a; } ///////////// Read, Write, Assign attr value - Severity StrToVal(const char *s, InstMgrBase *instances = 0, - int addFileId = 0); - Severity STEPread(istream &in = cin, InstMgrBase *instances = 0, - int addFileId = 0, const char *currSch = NULL, bool strict = true); + Severity StrToVal( const char * s, InstMgrBase * instances = 0, + int addFileId = 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 - string asStr(const char *currSch = 0) const; - const char *asStr(std::string &, const char * = 0) const; + string asStr( const char * currSch = 0 ) const; /// put the attr value in ostream - void STEPwrite(ostream &out = cout, const char *currSch = 0); - void ShallowCopy(const STEPattribute *sa); + void STEPwrite( ostream & out = cout, const char * currSch = 0 ); + void ShallowCopy( const STEPattribute * sa ); Severity set_null(); @@ -167,20 +153,25 @@ class SC_CORE_EXPORT STEPattribute * \sa is_null() */ ///@{ - SDAI_Integer *Integer(); - SDAI_Real *Real(); - SDAI_Real *Number(); - SDAI_String *String(); - SDAI_Binary *Binary(); - SDAI_Application_instance *Entity(); - STEPaggregate *Aggregate(); - SDAI_Enum *Enum(); - SDAI_LOGICAL *Logical(); - SDAI_BOOLEAN *Boolean(); - SDAI_Select *Select(); - SCLundefined *Undefined(); + SDAI_Integer * Integer(); + SDAI_Real * Real(); + SDAI_Real * Number(); + SDAI_String * String(); + SDAI_Binary * Binary(); + SDAI_Application_instance * Entity(); + STEPaggregate * Aggregate(); + SDAI_Enum * Enum(); + SDAI_LOGICAL * Logical(); + SDAI_BOOLEAN * Boolean(); + SDAI_Select * Select(); + SCLundefined * Undefined(); ///@} + /// allows direct access to the union containing attr data (dangerous!) + attrUnion * Raw() { + return & ptr; + } + /** * These functions allow setting the attribute value. * Attr type is verified using an assertion. @@ -189,86 +180,81 @@ class SC_CORE_EXPORT STEPattribute * what about ptr.c, which is ( SDAI_Application_instance ** ) ? */ ///@{ - void Integer(SDAI_Integer *n); - void Real(SDAI_Real *n); - void Number(SDAI_Real *n); - void String(SDAI_String *str); - void Binary(SDAI_Binary *bin); - void Entity(SDAI_Application_instance *ent); - void Aggregate(STEPaggregate *aggr); - void Enum(SDAI_Enum *enu); - void Logical(SDAI_LOGICAL *log); - void Boolean(SDAI_BOOLEAN *boo); - void Select(SDAI_Select *sel); - void Undefined(SCLundefined *undef); + void Integer( SDAI_Integer * n ); + void Real( SDAI_Real * n ); + void Number( SDAI_Real * n ); + void String( SDAI_String * str ); + void Binary( SDAI_Binary * bin ); + void Entity( SDAI_Application_instance * ent ); + void Aggregate( STEPaggregate * aggr ); + void Enum( SDAI_Enum * enu ); + void Logical( SDAI_LOGICAL * log ); + void Boolean( SDAI_BOOLEAN * boo ); + void Select( SDAI_Select * sel ); + void Undefined( SCLundefined * undef ); ///@} ////////////// Return info on attr bool Nullable() const; ///< may this attribute be null? bool is_null() const; ///< is this attribute null? - bool IsDerived() const - { + bool IsDerived() const { return _derive; } - STEPattribute *RedefiningAttr() - { + STEPattribute * RedefiningAttr() { return _redefAttr; } - const char *Name() const; - const char *TypeName() const; + const char * Name() const; + const char * TypeName() const; BASE_TYPE Type() const; BASE_TYPE NonRefType() const; BASE_TYPE BaseType() const; - const TypeDescriptor *ReferentType() const; + const TypeDescriptor * ReferentType() const; - ErrorDescriptor &Error() - { + ErrorDescriptor & Error() { return _error; } - void ClearErrorMsg() - { + void ClearErrorMsg() { _error.ClearErrorMsg(); } - Severity ValidLevel(const char *attrValue, ErrorDescriptor *error, InstMgrBase *im, bool clearError = true); + Severity ValidLevel( const char* attrValue, ErrorDescriptor* error, InstMgrBase * im, bool clearError = true ); ////////////////// Constructors - STEPattribute(const STEPattribute &a); - STEPattribute(): _derive(false), _mustDeletePtr(false), - _redefAttr(0), aDesc(0), refCount(0) - { - memset(& ptr, 0, sizeof(ptr)); + STEPattribute( const STEPattribute & a ); + STEPattribute(): _derive( false ), _mustDeletePtr( false ), + _redefAttr( 0 ), aDesc( 0 ), refCount( 0 ) { + memset( & ptr, 0, sizeof( ptr ) ); } ~STEPattribute(); // INTEGER - STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ); // BINARY - STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ); // STRING - STEPattribute(const class AttrDescriptor &d, SDAI_String *p); + STEPattribute( const class AttrDescriptor & d, SDAI_String * p ); // REAL & NUMBER - STEPattribute(const class AttrDescriptor &d, SDAI_Real *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ); // ENTITY - STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance* *p ); // AGGREGATE - STEPattribute(const class AttrDescriptor &d, STEPaggregate *p); + STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ); // ENUMERATION and Logical - STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ); // SELECT - STEPattribute(const class AttrDescriptor &d, SDAI_Select *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Select * p ); // UNDEFINED - STEPattribute(const class AttrDescriptor &d, SCLundefined *p); + STEPattribute( const class AttrDescriptor & d, SCLundefined * p ); /// return true if attr types and values match - SC_CORE_EXPORT friend bool operator == (const STEPattribute &a1, const STEPattribute &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 ); + SC_CORE_EXPORT friend bool operator != ( const STEPattribute & a1, const STEPattribute & a2 ); /// return true if aDesc's match (behavior of old operator==) - SC_CORE_EXPORT friend bool sameADesc(const STEPattribute &a1, const STEPattribute &a2); + SC_CORE_EXPORT friend bool sameADesc ( const STEPattribute & a1, const STEPattribute & a2 ); }; #endif diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 3ada09ea4..7774321b2 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -14,62 +14,55 @@ #include #include "sc_memmgr.h" -AttrListNode::AttrListNode(STEPattribute *a) -{ +AttrListNode::AttrListNode( STEPattribute * a ) { attr = a; } -AttrListNode::~AttrListNode() -{ +AttrListNode::~AttrListNode() { } -STEPattributeList::STEPattributeList() -{ +STEPattributeList::STEPattributeList() { } -STEPattributeList::~STEPattributeList() -{ +STEPattributeList::~STEPattributeList() { } -STEPattribute &STEPattributeList::operator [](int n) -{ +STEPattribute & STEPattributeList::operator []( int n ) { int x = 0; - AttrListNode *a = (AttrListNode *)head; + AttrListNode * a = ( AttrListNode * )head; int cnt = EntryCount(); - if(n < cnt) { - while(a && (x < n)) { - a = (AttrListNode *)(a->next); + if( n < cnt ) { + while( a && ( x < n ) ) { + a = ( AttrListNode * )( a->next ); x++; } } - if(a) { - return *(a->attr); + if( a ) { + return *( a->attr ); } // else cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ << "\n\n"; - return *(STEPattribute *) 0; + return *( STEPattribute * ) 0; } -int STEPattributeList::list_length() -{ +int STEPattributeList::list_length() { return EntryCount(); } -void STEPattributeList::push(STEPattribute *a) -{ - AttrListNode *a2 = (AttrListNode *)head; +void STEPattributeList::push( STEPattribute * a ) { + AttrListNode * a2 = ( AttrListNode * )head; // if the attribute already exists in the list, don't push it - while(a2) { - if(*a == *(a2 -> attr)) { + while( a2 ) { + if( *a == *( a2 -> attr ) ) { return; } - a2 = (AttrListNode *)(a2->next); + a2 = ( AttrListNode * )( a2->next ); } a->incrRefCount(); - AttrListNode *saln = new AttrListNode(a); - AppendNode(saln); + AttrListNode * saln = new AttrListNode( a ); + AppendNode( saln ); } diff --git a/src/clstepcore/STEPattributeList.h b/src/clstepcore/STEPattributeList.h index b8d00c6c3..9159f4664 100644 --- a/src/clstepcore/STEPattributeList.h +++ b/src/clstepcore/STEPattributeList.h @@ -20,28 +20,26 @@ class STEPattribute; class STEPattributeList; -class SC_CORE_EXPORT AttrListNode : public SingleLinkNode -{ +class SC_CORE_EXPORT AttrListNode : public SingleLinkNode { friend class STEPattributeList; protected: - STEPattribute *attr; + STEPattribute * attr; public: - AttrListNode(STEPattribute *a); + AttrListNode( STEPattribute * a ); virtual ~AttrListNode(); }; -class SC_CORE_EXPORT STEPattributeList : public SingleLinkList -{ +class SC_CORE_EXPORT STEPattributeList : public SingleLinkList { public: STEPattributeList(); virtual ~STEPattributeList(); - STEPattribute &operator [](int n); + STEPattribute & operator []( int n ); int list_length(); - void push(STEPattribute *a); + void push( STEPattribute * a ); }; /***************************************************************** diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 082079646..5daf31ab7 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -9,43 +9,40 @@ #include "sc_memmgr.h" extern const char * -ReadStdKeyword(istream &in, std::string &buf, int skipInitWS); +ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ); -STEPcomplex::STEPcomplex(Registry *registry, int fileid) - : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) -{ +STEPcomplex::STEPcomplex( Registry * registry, int fileid ) + : 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, true), sc(0), _registry(registry), visited(0) -{ - char *nms[BUFSIZ]; +STEPcomplex::STEPcomplex( Registry * registry, const std::string ** names, + int fileid, const char * schnm ) + : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { + char * nms[BUFSIZ]; int j, k; head = this; // Create a char ** list of names and call Initialize to build all: - for(j = 0; names[j]; j++) { - nms[j] = new char[(names[j])->length() + 1 ]; - strcpy(nms[j], names[j]->c_str()); + for( j = 0; names[j]; j++ ) { + nms[j] = new char[( names[j] )->length() + 1 ]; + strcpy( nms[j], names[j]->c_str() ); } nms[j] = NULL; - Initialize((const char **)nms, schnm); - for(k = 0; k < j; k++) { + Initialize( ( const char ** )nms, schnm ); + for( k = 0; k < j; k++ ) { delete [] nms[k]; } } -STEPcomplex::STEPcomplex(Registry *registry, const char **names, int fileid, - const char *schnm) - : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) -{ +STEPcomplex::STEPcomplex( Registry * registry, const char ** names, int fileid, + const char * schnm ) + : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { head = this; - Initialize(names, schnm); + Initialize( names, schnm ); } /** @@ -59,24 +56,23 @@ STEPcomplex::STEPcomplex(Registry *registry, const char **names, int fileid, * A and renames it to Y.) Registry::FindEntity() below knows how to * search using the current name of each entity based on schnm. */ -void STEPcomplex::Initialize(const char **names, const char *schnm) -{ +void STEPcomplex::Initialize( const char ** names, const char * schnm ) { // Create an EntNode list consisting of all the names in the complex ent: - EntNode *ents = new EntNode(names), + EntNode * ents = new EntNode( names ), *eptr = ents, *prev = NULL, *enext; - const EntityDescriptor *enDesc; + const EntityDescriptor * enDesc; char nm[BUFSIZ]; bool invalid = false, outOfOrder = false; // Splice out the invalid names from our list: - while(eptr) { + while( eptr ) { enext = eptr->next; - enDesc = _registry->FindEntity(*eptr, schnm); - if(enDesc) { - if(enDesc->Supertypes().EntryCount() > 1) { - eptr->multSuprs(true); + enDesc = _registry->FindEntity( *eptr, schnm ); + if( enDesc ) { + if( enDesc->Supertypes().EntryCount() > 1 ) { + eptr->multSuprs( true ); } - if(StrCmpIns(*eptr, enDesc->Name())) { + if( StrCmpIns( *eptr, enDesc->Name() ) ) { // If this entity was referred by another name rather than the // original. May be the case if FindEntity() determined that // eptr's name was a legal renaming of enDesc's. (Entities and @@ -84,7 +80,7 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) // comments.) If so, change eptr's name (since the complex // support structs only deal with the original names) and have // ents re-ort eptr properly in the list: - eptr->Name(StrToLower(enDesc->Name(), nm)); + eptr->Name( StrToLower( enDesc->Name(), nm ) ); outOfOrder = true; } prev = eptr; @@ -92,7 +88,7 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) invalid = true; cerr << "ERROR: Invalid entity \"" << eptr->Name() << "\" found in complex entity.\n"; - if(!prev) { + if( !prev ) { // if we need to delete the first node, ents = eptr->next; } else { @@ -106,36 +102,36 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) } // If we changed the name of any of the entities, resort: - if(outOfOrder) { - ents->sort(&ents); + if( outOfOrder ) { + ents->sort( &ents ); // This fn may change the value of ents if the list should have a new // first EndNode. } // Set error message according to results of above: - if(invalid) { - if(!ents) { + if( invalid ) { + if( !ents ) { // not a single legal name - _error.severity(SEVERITY_WARNING); + _error.severity( SEVERITY_WARNING ); // SEV_WARNING - we have to skip this entity altogether, but will // continue with the next entity. - _error.UserMsg("No legal entity names found in instance"); + _error.UserMsg( "No legal entity names found in instance" ); return; } - _error.severity(SEVERITY_INCOMPLETE); - _error.UserMsg("Some illegal entity names found in instance"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.UserMsg( "Some illegal entity names found in instance" ); // some illegal entity names, but some legal } // Check if a complex entity can be formed from the resulting combination: - if(!_registry->CompCol()->supports(ents)) { - _error.severity(SEVERITY_WARNING); + if( !_registry->CompCol()->supports( ents ) ) { + _error.severity( SEVERITY_WARNING ); _error.UserMsg( - "Entity combination does not represent a legal complex entity"); + "Entity combination does not represent a legal complex entity" ); cerr << "ERROR: Could not create instance of the following complex" << " entity:" << endl; eptr = ents; - while(eptr) { + while( eptr ) { cerr << *eptr << endl; eptr = eptr->next; } @@ -144,24 +140,23 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) } // Finally, build what we can: - BuildAttrs(*ents); - for(eptr = ents->next; eptr; eptr = eptr->next) { - AddEntityPart(*eptr); + BuildAttrs( *ents ); + for( eptr = ents->next; eptr; eptr = eptr->next ) { + AddEntityPart( *eptr ); } AssignDerives(); delete ents; } -STEPcomplex::~STEPcomplex() -{ +STEPcomplex::~STEPcomplex() { STEPcomplex_attr_data_iter attr_data; - if(sc) { + if( sc ) { delete sc; } - for(attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++) { + for( attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++ ) { attrData_t attrData = *attr_data; - switch(attrData.type) { + switch( attrData.type ) { case INTEGER_TYPE: delete attrData.i; break; @@ -185,12 +180,12 @@ STEPcomplex::~STEPcomplex() delete attrData.ai; break; case ENUM_TYPE: - if(attrData.e) { + if( attrData.e ) { delete attrData.e; } break; case SELECT_TYPE: - if(attrData.s) { + if( attrData.s ) { delete attrData.s; } break; @@ -199,7 +194,7 @@ STEPcomplex::~STEPcomplex() case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if(attrData.a) { + if( attrData.a ) { delete attrData.a; } break; @@ -213,61 +208,59 @@ STEPcomplex::~STEPcomplex() _attr_data_list.clear(); } -void STEPcomplex::AssignDerives() -{ - STEPattribute *a = 0; - STEPcomplex *scomp1 = head; - STEPcomplex *scomp2; +void STEPcomplex::AssignDerives() { + STEPattribute * a = 0; + STEPcomplex * scomp1 = head; + STEPcomplex * scomp2; - const AttrDescriptorList *attrList; - AttrDescLinkNode *attrPtr; - const AttrDescriptor *ad; + const AttrDescriptorList * attrList; + AttrDescLinkNode * attrPtr; + const AttrDescriptor * ad; - while(scomp1 && scomp1->eDesc) { + while( scomp1 && scomp1->eDesc ) { a = 0; - attrList = &(scomp1->eDesc->ExplicitAttr()); - attrPtr = (AttrDescLinkNode *)attrList->GetHead(); + attrList = &( scomp1->eDesc->ExplicitAttr() ); + attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); // assign nm to be derived attr // while( more derived attr for entity part ) - while(attrPtr != 0) { + while( attrPtr != 0 ) { ad = attrPtr->AttrDesc(); - if((ad->Derived()) == LTrue) { - const char *nm = ad->Name(); - const char *attrNm = 0; - if(strrchr(nm, '.')) { - attrNm = strrchr(nm, '.'); + if( ( ad->Derived() ) == LTrue ) { + const char * nm = ad->Name(); + const char * attrNm = 0; + if( strrchr( nm, '.' ) ) { + attrNm = strrchr( nm, '.' ); attrNm++; } else { attrNm = nm; } scomp2 = head; - while(scomp2 && !a) { - if(scomp1 != scomp2) { - scomp2->MakeDerived(attrNm); - a = scomp2->GetSTEPattribute(attrNm); + while( scomp2 && !a ) { + if( scomp1 != scomp2 ) { + scomp2->MakeDerived( attrNm ); + a = scomp2->GetSTEPattribute( attrNm ); } scomp2 = scomp2->sc; } } // increment attr - attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); + attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); } scomp1 = scomp1->sc; } } /** 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) { +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); + AppendEntity( scomplex ); } else { cout << scomplex->_error.DetailMsg() << endl; delete scomplex; @@ -275,12 +268,11 @@ void STEPcomplex::AddEntityPart(const char *name) } } -STEPcomplex *STEPcomplex::EntityPart(const char *name, const char *currSch) -{ - STEPcomplex *scomp = head; - while(scomp) { - if(scomp->eDesc) { - if(scomp->eDesc->CurrName(name, currSch)) { +STEPcomplex * STEPcomplex::EntityPart( const char * name, const char * currSch ) { + STEPcomplex * scomp = head; + while( scomp ) { + if( scomp->eDesc ) { + if( scomp->eDesc->CurrName( name, currSch ) ) { return scomp; } } else { @@ -292,9 +284,8 @@ STEPcomplex *STEPcomplex::EntityPart(const char *name, const char *currSch) return 0; } -int STEPcomplex::EntityExists(const char *name, const char *currSch) -{ - return (EntityPart(name, currSch) ? 1 : 0); +int STEPcomplex::EntityExists( const char * name, const char * currSch ) { + return ( EntityPart( name, currSch ) ? 1 : 0 ); } /** @@ -302,20 +293,18 @@ int STEPcomplex::EntityExists(const char *name, const char *currSch) ** For a complex entity, we'll check the EntityDescriptor of each entity ** in the complex 'chain' */ -const EntityDescriptor *STEPcomplex::IsA(const EntityDescriptor *ed) const -{ - const EntityDescriptor *return_ed = eDesc->IsA(ed); +const EntityDescriptor * STEPcomplex::IsA( const EntityDescriptor * ed ) const { + const EntityDescriptor * return_ed = eDesc->IsA( ed ); - if(!return_ed && sc) { - return sc->IsA(ed); + if( !return_ed && sc ) { + return sc->IsA( ed ); } else { return return_ed; } } -Severity STEPcomplex::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError) -{ +Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError ) { (void) error; //unused (void) im; (void) clearError; @@ -323,75 +312,73 @@ Severity STEPcomplex::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, return SEVERITY_NULL; } -void STEPcomplex::AppendEntity(STEPcomplex *stepc) -{ - if(sc) { - sc->AppendEntity(stepc); +void STEPcomplex::AppendEntity( STEPcomplex * stepc ) { + if( sc ) { + sc->AppendEntity( stepc ); } else { sc = stepc; } } // READ -Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instance_set, - istream &in, const char *currSch, bool /*useTechCor*/, bool /*strict*/) -{ +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; - STEPcomplex *stepc = 0; + STEPcomplex * stepc = 0; - ClearError(1); + ClearError( 1 ); STEPfile_id = id; stepc = head; - while(stepc) { + while( stepc ) { stepc->visited = 0; stepc = stepc->sc; } in >> ws; - in.get(c); - if(c == '(') { // opening paren for subsuperRecord + in.get( c ); + if( c == '(' ) { // opening paren for subsuperRecord in >> ws; c = in.peek(); - while(c != ')') { + while( c != ')' ) { typeNm.clear(); in >> ws; - ReadStdKeyword(in, typeNm, 1); // read the type name + ReadStdKeyword( in, typeNm, 1 ); // read the type name in >> ws; c = in.peek(); - if(c != '(') { - _error.AppendToDetailMsg("Missing open paren before entity attr values.\n"); + if( c != '(' ) { + _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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } - stepc = EntityPart(typeNm.c_str(), currSch); - if(stepc) { + stepc = EntityPart( typeNm.c_str(), currSch ); + 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); + 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); + _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(); } in >> ws; c = in.peek(); } - if(c != ')') { + if( c != ')' ) { cout << "ERROR: missing ending paren for complex entity instance." << endl; } else { - in.get(c); // read the closing paren + 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); + _error.AppendToDetailMsg( "Complex instances must begin with '('. Found '" ); + _error.AppendToDetailMsg( c ); + _error.AppendToDetailMsg( "' instead.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } return _error.severity(); } @@ -399,83 +386,82 @@ Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instanc //FIXME delete this? #ifdef buildwhileread // READ -Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instance_set, - istream &in, const char *currSch) -{ - ClearError(1); +Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set, + istream & in, const char * currSch ) { + ClearError( 1 ); STEPfile_id = id; STEPcomplex stepc = head; - while(stepc) { + while( stepc ) { stepc->visited = 0; stepc = stepc->sc; } char c; in >> ws; - in.get(c); - if(c == '(') { + in.get( c ); + if( c == '(' ) { std::string s; in >> ws; - in.get(c); - while(in && (c != '(') && !isspace(c)) { // get the entity name - s.Append(c); - in.get(c); + in.get( c ); + while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name + s.Append( c ); + in.get( c ); } - if(isspace(c)) { + if( isspace( c ) ) { in >> ws; - in.get(c); + in.get( c ); } - if(c != '(') { + if( c != '(' ) { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n"); + "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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } else { // c == '(' - in.putback(c); + in.putback( c ); } cout << s << endl; - BuildAttrs(s.c_str()); - SDAI_Application_instance::STEPread(id, addFileId, instance_set, - in, currSch); + BuildAttrs( s.c_str() ); + SDAI_Application_instance::STEPread( id, addFileId, instance_set, + in, currSch ); in >> ws; - in.get(c); - while(c != ')') { + in.get( c ); + while( c != ')' ) { s.set_null(); - while(in && (c != '(') && !isspace(c)) { // get the entity name - s.Append(c); - in.get(c); + while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name + s.Append( c ); + in.get( c ); } - if(isspace(c)) { + if( isspace( c ) ) { in >> ws; - in.get(c); + in.get( c ); } - if(c != '(') { + if( c != '(' ) { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n"); + "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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } else { // c == '(' - in.putback(c); + in.putback( c ); } cout << s << endl; // diagnostics DAS - STEPcomplex *stepc = new STEPcomplex(_registry); - AppendEntity(stepc); - stepc->BuildAttrs(s.c_str()); - stepc->SDAI_Application_instance::STEPread(id, addFileId, + STEPcomplex * stepc = new STEPcomplex( _registry ); + AppendEntity( stepc ); + stepc->BuildAttrs( s.c_str() ); + stepc->SDAI_Application_instance::STEPread( id, addFileId, instance_set, in, - currSch); + currSch ); in >> ws; - in.get(c); + in.get( c ); } } return _error.severity(); @@ -483,76 +469,75 @@ Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instanc #endif -void STEPcomplex::BuildAttrs(const char *s) -{ +void STEPcomplex::BuildAttrs( const char * s ) { // assign inherited member variable - eDesc = (class EntityDescriptor *)_registry->FindEntity(s); + eDesc = ( class EntityDescriptor * )_registry->FindEntity( s ); - if(eDesc) { - const AttrDescriptorList *attrList = &(eDesc->ExplicitAttr()); + if( eDesc ) { + const AttrDescriptorList * attrList = &( eDesc->ExplicitAttr() ); ////////////////////////////////////////////// // find out how many attrs there are ////////////////////////////////////////////// - STEPattribute *a = 0; + STEPattribute * a = 0; //_attr_data_list used to store everything as void *, but we couldn't correctly delete the contents in the dtor. - AttrDescLinkNode *attrPtr = (AttrDescLinkNode *)attrList->GetHead(); - while(attrPtr != 0) { - const AttrDescriptor *ad = attrPtr->AttrDesc(); + AttrDescLinkNode * attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); + while( attrPtr != 0 ) { + const AttrDescriptor * ad = attrPtr->AttrDesc(); - if((ad->Derived()) != LTrue) { + if( ( ad->Derived() ) != LTrue ) { attrData_t attrData; attrData.type = ad->NonRefType(); - switch(attrData.type) { + switch( attrData.type ) { case INTEGER_TYPE: attrData.i = new SDAI_Integer; - a = new STEPattribute(*ad, attrData.i); + a = new STEPattribute( *ad, attrData.i ); break; case STRING_TYPE: attrData.str = new SDAI_String; - a = new STEPattribute(*ad, attrData.str); + a = new STEPattribute( *ad, attrData.str ); break; case BINARY_TYPE: attrData.bin = new SDAI_Binary; - a = new STEPattribute(*ad, attrData.bin); + a = new STEPattribute( *ad, attrData.bin ); break; case REAL_TYPE: case NUMBER_TYPE: attrData.r = new SDAI_Real; - a = new STEPattribute(*ad, attrData.r); + a = new STEPattribute( *ad, attrData.r ); break; case BOOLEAN_TYPE: attrData.b = new SDAI_BOOLEAN; - a = new STEPattribute(*ad, attrData.b); + a = new STEPattribute( *ad, attrData.b ); break; case LOGICAL_TYPE: attrData.l = new SDAI_LOGICAL; - a = new STEPattribute(*ad, attrData.l); + a = new STEPattribute( *ad, attrData.l ); break; case ENTITY_TYPE: - attrData.ai = new(SDAI_Application_instance *); - a = new STEPattribute(*ad, attrData.ai); + attrData.ai = new( SDAI_Application_instance * ); + a = new STEPattribute( *ad, attrData.ai ); break; case ENUM_TYPE: { - EnumTypeDescriptor *enumD = (EnumTypeDescriptor *)ad->ReferentType(); + EnumTypeDescriptor * enumD = ( EnumTypeDescriptor * )ad->ReferentType(); attrData.e = enumD->CreateEnum(); - a = new STEPattribute(*ad, attrData.e); + a = new STEPattribute( *ad, attrData.e ); break; } case SELECT_TYPE: { - SelectTypeDescriptor *selectD = (SelectTypeDescriptor *)ad->ReferentType(); + SelectTypeDescriptor * selectD = ( SelectTypeDescriptor * )ad->ReferentType(); attrData.s = selectD->CreateSelect(); - a = new STEPattribute(*ad, attrData.s); + a = new STEPattribute( *ad, attrData.s ); break; } case AGGREGATE_TYPE: @@ -560,42 +545,41 @@ void STEPcomplex::BuildAttrs(const char *s) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - AggrTypeDescriptor *aggrD = (AggrTypeDescriptor *)ad->ReferentType(); + AggrTypeDescriptor * aggrD = ( AggrTypeDescriptor * )ad->ReferentType(); attrData.a = aggrD->CreateAggregate(); - a = new STEPattribute(*ad, attrData.a); + a = new STEPattribute( *ad, attrData.a ); break; } default: - _error.AppendToDetailMsg("STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToDetailMsg( "STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); a = new STEPattribute(); attrData.type = UNKNOWN_TYPE; //don't add to attr list } - if(attrData.type != UNKNOWN_TYPE) { - _attr_data_list.push_back(attrData); + if( attrData.type != UNKNOWN_TYPE ) { + _attr_data_list.push_back( attrData ); } a -> set_null(); - attributes.push(a); + attributes.push( a ); } - attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); + attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); } } else { - _error.AppendToDetailMsg("Entity does not exist.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + _error.AppendToDetailMsg( "Entity does not exist.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } -void STEPcomplex::STEPread_error(char c, int index, istream &in, const char *schnm) -{ +void STEPcomplex::STEPread_error( char c, int index, istream & in, const char * schnm ) { (void) schnm; //unused cout << "STEPcomplex::STEPread_error(), index=" << index << ", entity #" << STEPfile_id << "." << endl; streampos p = in.tellg(); std::string q, r; - getline(in, q); - getline(in, r); + getline( in, q ); + getline( in, r ); cout << "Remainder of this line:" << endl << c << q << endl << "Next line:" << endl << r << endl; - in.seekg(p); + in.seekg( p ); } /** @@ -606,138 +590,132 @@ void STEPcomplex::STEPread_error(char c, int index, istream &in, const char *sch ** alphabetical order. The nodes are sorted alphabetically according to their ** original names but not according to their renamed names (DAR 6/5/97). */ -void STEPcomplex::STEPwrite(ostream &out, const char *currSch, int writeComment) -{ - if(writeComment && !p21Comment.empty()) { +void STEPcomplex::STEPwrite( ostream & out, const char * currSch, int writeComment ) { + if( writeComment && !p21Comment.empty() ) { out << p21Comment; } out << "#" << STEPfile_id << "=(\n"; - WriteExtMapEntities(out, currSch); + WriteExtMapEntities( out, currSch ); out << ");\n"; } -const char *STEPcomplex::STEPwrite(std::string &buf, const char *currSch) -{ +const char * STEPcomplex::STEPwrite( std::string & buf, const char * currSch ) { buf.clear(); stringstream ss; ss << "#" << STEPfile_id << "=("; - WriteExtMapEntities(ss, currSch); + WriteExtMapEntities( ss, currSch ); ss << ");"; ss << ends; - buf.append(ss.str()); + buf.append( ss.str() ); - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /** \copydoc STEPcomplex::STEPwrite */ -void STEPcomplex::WriteExtMapEntities(ostream &out, const char *currSch) -{ +void STEPcomplex::WriteExtMapEntities( ostream & out, const char * currSch ) { std::string tmp; - out << StrToUpper(EntityName(currSch), tmp); + out << StrToUpper( EntityName( currSch ), tmp ); out << "("; int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - (attributes[i]).STEPwrite(out, currSch); - if(i < n - 1) { + for( int i = 0 ; i < n; i++ ) { + ( attributes[i] ).STEPwrite( out, currSch ); + if( i < n - 1 ) { out << ","; } } out << ")\n"; - if(sc) { - sc->WriteExtMapEntities(out, currSch); + if( sc ) { + sc->WriteExtMapEntities( out, currSch ); } } /** \copydoc STEPcomplex::STEPwrite */ -const char *STEPcomplex::WriteExtMapEntities(std::string &buf, const char *currSch) -{ +const char * STEPcomplex::WriteExtMapEntities( std::string & buf, const char * currSch ) { std::string tmp; - StrToUpper(EntityName(currSch), tmp); - buf.append(tmp); - buf.append("i"); + StrToUpper( EntityName( currSch ), tmp ); + buf.append( tmp ); + buf.append( "i" ); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - buf.append(attributes[i].asStr(currSch)); - if(i < n - 1) { - buf.append(","); + for( int i = 0 ; i < n; i++ ) { + buf.append( attributes[i].asStr( currSch ) ); + if( i < n - 1 ) { + buf.append( "," ); } } - buf.append(")\n"); + buf.append( ")\n" ); - if(sc) { - sc->WriteExtMapEntities(buf, currSch); + if( sc ) { + sc->WriteExtMapEntities( buf, currSch ); } return buf.c_str(); } -void STEPcomplex::CopyAs(SDAI_Application_instance *se) -{ - if(!se->IsComplex()) { +void STEPcomplex::CopyAs( SDAI_Application_instance * se ) { + if( !se->IsComplex() ) { char errStr[BUFSIZ]; cerr << "STEPcomplex::CopyAs() called with non-complex entity: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPcomplex::CopyAs(): %s - entity #%d.\n", - "Programming ERROR - called with non-complex entity", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPcomplex::CopyAs(): %s - entity #%d.\n", + "Programming ERROR - called with non-complex entity", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); return; } else { - STEPcomplex *scpartCpyTo = head; - STEPcomplex *scpartCpyFrom = ((STEPcomplex *)se)->head; - while(scpartCpyTo && scpartCpyFrom) { - scpartCpyTo->SDAI_Application_instance::CopyAs(scpartCpyFrom); + STEPcomplex * scpartCpyTo = head; + STEPcomplex * scpartCpyFrom = ( ( STEPcomplex * )se )->head; + while( scpartCpyTo && scpartCpyFrom ) { + scpartCpyTo->SDAI_Application_instance::CopyAs( scpartCpyFrom ); scpartCpyTo = scpartCpyTo->sc; scpartCpyFrom = scpartCpyFrom->sc; } } } -SDAI_Application_instance *STEPcomplex::Replicate() -{ - if(!IsComplex()) { +SDAI_Application_instance * STEPcomplex::Replicate() { + if( !IsComplex() ) { return SDAI_Application_instance::Replicate(); - } else if(!_registry) { + } else if( !_registry ) { return S_ENTITY_NULL; } else { int nameCount = 64; - std::string **nameList = new std::string *[nameCount]; - STEPcomplex *scomp = this->head; + std::string ** nameList = new std::string *[nameCount]; + STEPcomplex * scomp = this->head; int i = 0; - while(scomp && (i < 63)) { - nameList[i] = new std::string(""); - nameList[i]->append(scomp->eDesc->Name()); + while( scomp && ( i < 63 ) ) { + nameList[i] = new std::string( "" ); + nameList[i]->append( scomp->eDesc->Name() ); i++; scomp = scomp->sc; } - nameList[i] = (std::string *)0; - if(i == 63) { + nameList[i] = ( std::string * )0; + if( i == 63 ) { char errStr[BUFSIZ]; cerr << "STEPcomplex::Replicate() name buffer too small: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPcomplex::Replicate(): %s - entity #%d.\n", - "Programming ERROR - name buffer too small", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPcomplex::Replicate(): %s - entity #%d.\n", + "Programming ERROR - name buffer too small", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); } - STEPcomplex *seNew = new STEPcomplex(_registry, - (const std::string **)nameList, - 1111); - seNew -> CopyAs(this); + STEPcomplex * seNew = new STEPcomplex( _registry, + ( const std::string ** )nameList, + 1111 ); + seNew -> CopyAs( this ); return seNew; // TODO need to: diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index 10239ec01..caf7ea255 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -18,16 +18,16 @@ typedef struct { PrimitiveType type; union { - SDAI_Integer *i; - SDAI_String *str; - SDAI_Binary *bin; - SDAI_Real *r; - SDAI_BOOLEAN *b; - SDAI_LOGICAL *l; - SDAI_Application_instance **ai; - SDAI_Enum *e; - SDAI_Select *s; - STEPaggregate *a; + SDAI_Integer * i; + SDAI_String * str; + SDAI_Binary * bin; + SDAI_Real * r; + SDAI_BOOLEAN * b; + SDAI_LOGICAL * l; + SDAI_Application_instance ** ai; + SDAI_Enum * e; + SDAI_Select * s; + STEPaggregate * a; }; } attrData_t; typedef std::list< attrData_t > STEPcomplex_attr_data_list; @@ -36,12 +36,11 @@ typedef STEPcomplex_attr_data_list::iterator STEPcomplex_attr_data_iter; /** FIXME are inverse attr's initialized for STEPcomplex? */ -class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance -{ +class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance { public: //TODO should this _really_ be public?! - STEPcomplex *sc; - STEPcomplex *head; - Registry *_registry; + STEPcomplex * sc; + STEPcomplex * head; + Registry * _registry; int visited; ///< used when reading (or as you wish?) #ifdef _MSC_VER #pragma warning( push ) @@ -52,48 +51,48 @@ class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance #pragma warning( pop ) #endif public: - STEPcomplex(Registry *registry, int fileid); - STEPcomplex(Registry *registry, const std::string **names, int fileid, - const char *schnm = 0); - STEPcomplex(Registry *registry, const char **names, int fileid, - const char *schnm = 0); + STEPcomplex( Registry * registry, int fileid ); + STEPcomplex( Registry * registry, const std::string ** names, int fileid, + const char * schnm = 0 ); + STEPcomplex( Registry * registry, const char ** names, int fileid, + const char * schnm = 0 ); virtual ~STEPcomplex(); - int EntityExists(const char *name, const char *currSch = 0); - STEPcomplex *EntityPart(const char *name, const char *currSch = 0); + int EntityExists( const char * name, const char * currSch = 0 ); + STEPcomplex * EntityPart( const char * name, const char * currSch = 0 ); - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; - virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError = 1); + virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError = 1 ); // READ - virtual Severity STEPread(int id, int addFileId, - class InstMgrBase *instance_set, - istream &in = cin, const char *currSch = NULL, - bool useTechCor = true, bool strict = true); + virtual Severity STEPread( int id, int addFileId, + class InstMgrBase * instance_set, + istream & in = cin, const char * currSch = NULL, + bool useTechCor = true, bool strict = true ); - virtual void STEPread_error(char c, int index, istream &in, const char *schnm); + virtual void STEPread_error( char c, int index, istream& in, const char * schnm ); // WRITE - virtual void STEPwrite(ostream &out = cout, const char *currSch = NULL, - int writeComment = 1); - virtual const char *STEPwrite(std::string &buf, const char *currSch = NULL); + virtual void STEPwrite( ostream & out = cout, const char * currSch = NULL, + int writeComment = 1 ); + virtual const char * STEPwrite( std::string & buf, const char * currSch = NULL ); - SDAI_Application_instance *Replicate(); + SDAI_Application_instance * Replicate(); - virtual void WriteExtMapEntities(ostream &out = cout, - const char *currSch = NULL); - virtual const char *WriteExtMapEntities(std::string &buf, - const char *currSch = NULL); - virtual void AppendEntity(STEPcomplex *stepc); + virtual void WriteExtMapEntities( ostream & out = cout, + const char * currSch = NULL ); + virtual const char * WriteExtMapEntities( std::string & buf, + const char * currSch = NULL ); + virtual void AppendEntity( STEPcomplex * stepc ); protected: - virtual void CopyAs(SDAI_Application_instance *se); - void BuildAttrs(const char *s); - void AddEntityPart(const char *name); + virtual void CopyAs( SDAI_Application_instance * se ); + void BuildAttrs( const char * s ); + void AddEntityPart( const char * name ); void AssignDerives(); - void Initialize(const char **names, const char *schnm); + void Initialize( const char ** names, const char * schnm ); }; #endif diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index cd083a67a..52bdf1ee5 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -7,8 +7,8 @@ #include #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(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() {} @@ -16,55 +16,51 @@ invAttrListNodeA::~invAttrListNodeA() {} STEPinvAttrList::STEPinvAttrList() {} STEPinvAttrList::~STEPinvAttrList() {} -invAttrListNode *STEPinvAttrList::operator [](int n) -{ +invAttrListNode * STEPinvAttrList::operator []( int n ) { int x = 0; - invAttrListNode *a = (invAttrListNode *)head; + invAttrListNode * a = ( invAttrListNode * )head; int cnt = EntryCount(); - if(n < cnt) { - while(a && (x < n)) { - a = (invAttrListNode *)(a->next); + if( n < cnt ) { + while( a && ( x < n ) ) { + a = ( invAttrListNode * )( a->next ); x++; } } - if(!a) { + if( !a ) { cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" - << __LINE__ << "\n" << _POC_ << "\n\n"; + << __LINE__ << "\n" << _POC_ << "\n\n"; } return a; } -int STEPinvAttrList::list_length() -{ +int STEPinvAttrList::list_length() { return EntryCount(); } -void STEPinvAttrList::push(Inverse_attribute *a, setterA_t s, getterA_t g) -{ - invAttrListNode *an = (invAttrListNode *)head; +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)) { + while( an ) { + if( a == ( an -> attr ) ) { return; } - an = (invAttrListNode *)(an->next); + an = ( invAttrListNode * )( an->next ); } - invAttrListNode *ialn = (invAttrListNode *) new invAttrListNodeA(a, s, g); - AppendNode(ialn); + 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; +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)) { + while( an ) { + if( a == ( an -> attr ) ) { return; } - an = (invAttrListNode *)(an->next); + an = ( invAttrListNode * )( an->next ); } - invAttrListNode *ialn = (invAttrListNode *) new invAttrListNodeI(a, s, g); - AppendNode(ialn); + invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeI( a, s, g ); + AppendNode( ialn ); } diff --git a/src/clstepcore/STEPinvAttrList.h b/src/clstepcore/STEPinvAttrList.h index 6754fc99e..342720065 100644 --- a/src/clstepcore/STEPinvAttrList.h +++ b/src/clstepcore/STEPinvAttrList.h @@ -25,86 +25,75 @@ class SDAI_Application_instance; * 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 *); +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; +class SC_CORE_EXPORT invAttrListNode : public SingleLinkNode { + friend class STEPinvAttrList; protected: - invAttrListNode(Inverse_attribute *a) : attr(a) {}; - Inverse_attribute *attr; + invAttrListNode( Inverse_attribute * a ) : attr( a ) {}; + Inverse_attribute * attr; public: - Inverse_attribute *inverseADesc() - { + Inverse_attribute * inverseADesc() { return attr; } virtual bool isAggregate() = 0; }; -class SC_CORE_EXPORT invAttrListNodeI : public invAttrListNode -{ - friend class STEPinvAttrList; +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); + invAttrListNodeI( Inverse_attribute * a, setterI_t s, getterI_t g ); virtual ~invAttrListNodeI(); - setterI_t setter() - { + setterI_t setter() { return set; } - getterI_t getter() - { + getterI_t getter() { return get; } - virtual bool isAggregate() - { + virtual bool isAggregate() { return false; } }; -class SC_CORE_EXPORT invAttrListNodeA : public invAttrListNode -{ - friend class STEPinvAttrList; +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); + invAttrListNodeA( Inverse_attribute * a, setterA_t s, getterA_t g ); virtual ~invAttrListNodeA(); - setterA_t setter() - { + setterA_t setter() { return set; } - getterA_t getter() - { + getterA_t getter() { return get; } - virtual bool isAggregate() - { + 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 -{ +class SC_CORE_EXPORT STEPinvAttrList : public SingleLinkList { public: STEPinvAttrList(); virtual ~STEPinvAttrList(); - invAttrListNode *operator [](int n); + 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); + void push( Inverse_attribute * a, setterA_t s, getterA_t g ); + void push( Inverse_attribute * a, setterI_t s, getterI_t g ); }; diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index 71ad08705..6ca378099 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -19,26 +19,22 @@ ** helper functions for reading unknown types */ -Severity SCLundefined::StrToVal(const char *s, ErrorDescriptor *err) -{ +Severity SCLundefined::StrToVal( const char * s, ErrorDescriptor * err ) { (void) err; //unused val = s; return SEVERITY_NULL; } -Severity SCLundefined::StrToVal(istream &in, ErrorDescriptor *err) -{ - return STEPread(in, err); +Severity SCLundefined::StrToVal( istream & in, ErrorDescriptor * err ) { + return STEPread( in, err ); } -Severity SCLundefined::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *) s); - return STEPread(in, err); +Severity SCLundefined::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * ) s ); + return STEPread( in, err ); } -Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) { char c = '\0'; ostringstream ss; std::string str; @@ -47,38 +43,38 @@ Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) in >> ws; // skip white space in >> c; - if(c == '$') { + if( c == '$' ) { val = ""; - CheckRemainingInput(in, err, "aggregate item", ",)"); + CheckRemainingInput( in, err, "aggregate item", ",)" ); } else { - in.putback(c); + in.putback( c ); } - while(!terminal) { - in.get(c); - switch(c) { + while( !terminal ) { + in.get( c ); + switch( c ) { case '(': - in.putback(c); + in.putback( c ); - PushPastImbedAggr(in, str, err); + PushPastImbedAggr( in, str, err ); ss << str; break; case '\'': - in.putback(c); + in.putback( c ); - PushPastString(in, str, err); + PushPastString( in, str, err ); ss << str; break; case ',': terminal = 1; // it's a STEPattribute separator - in.putback(c); + in.putback( c ); c = '\0'; break; case ')': - in.putback(c); + in.putback( c ); terminal = 1; // found a valid delimiter break; @@ -88,58 +84,53 @@ Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) break; default: - ss.put(c); + ss.put( c ); break; } - if(!in.good()) { + if( !in.good() ) { terminal = 1; c = '\0'; } } ss << ends; - val = &(ss.str()[0]); + val = &( ss.str()[0] ); - err->GreaterSeverity(SEVERITY_NULL); + err->GreaterSeverity( SEVERITY_NULL ); return SEVERITY_NULL; } -const char *SCLundefined::asStr(std::string &s) const -{ +const char * SCLundefined::asStr( std::string & s ) const { s = val.c_str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *SCLundefined::STEPwrite(std::string &s) -{ - if(val.empty()) { +const char * SCLundefined::STEPwrite( std::string & s ) { + if( val.empty() ) { s = "$"; } else { s = val.c_str(); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void SCLundefined:: STEPwrite(ostream &out) -{ - if(val.empty()) { +void SCLundefined:: STEPwrite( ostream & out ) { + if( val.empty() ) { out << "$"; } else { out << val; } } -SCLundefined &SCLundefined::operator= (const SCLundefined &x) -{ +SCLundefined & SCLundefined::operator= ( const SCLundefined & x ) { std::string tmp; - val = x.asStr(tmp); + val = x.asStr( tmp ); return *this; } -SCLundefined &SCLundefined::operator= (const char *str) -{ - if(!str) { +SCLundefined & SCLundefined::operator= ( const char * str ) { + if( !str ) { val.clear(); } else { val = str; @@ -147,22 +138,18 @@ SCLundefined &SCLundefined::operator= (const char *str) return *this; } -SCLundefined::SCLundefined() -{ +SCLundefined::SCLundefined() { } -SCLundefined::~SCLundefined() -{ +SCLundefined::~SCLundefined() { } -int SCLundefined::set_null() -{ +int SCLundefined::set_null() { val = ""; return 1; } -bool SCLundefined::is_null() -{ - return (val.empty()); +bool SCLundefined::is_null() { + return ( val.empty() ); } diff --git a/src/clstepcore/STEPundefined.h b/src/clstepcore/STEPundefined.h index e83685f17..306eb0ef2 100644 --- a/src/clstepcore/STEPundefined.h +++ b/src/clstepcore/STEPundefined.h @@ -17,8 +17,7 @@ #include #include -class SC_CORE_EXPORT SCLundefined -{ +class SC_CORE_EXPORT SCLundefined { protected: #ifdef _MSC_VER #pragma warning( push ) @@ -31,21 +30,21 @@ class SC_CORE_EXPORT SCLundefined public: // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); // OUTPUT - virtual const char *asStr(std::string &s) const; - virtual const char *STEPwrite(std::string &s); - virtual void STEPwrite(ostream &out = cout); + virtual const char * asStr( std::string & s ) const; + virtual const char * STEPwrite( std::string & s ); + virtual void STEPwrite( ostream & out = cout ); int set_null(); bool is_null(); - SCLundefined &operator= (const SCLundefined &); - SCLundefined &operator= (const char *str); + SCLundefined & operator= ( const SCLundefined & ); + SCLundefined & operator= ( const char * str ); SCLundefined(); virtual ~SCLundefined(); }; diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index 1552b2707..b13e2061d 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -15,72 +15,65 @@ #include -SingleLinkList::SingleLinkList() : head(0), tail(0) -{ +SingleLinkList::SingleLinkList() : head( 0 ), tail( 0 ) { } -SingleLinkList::~SingleLinkList() -{ +SingleLinkList::~SingleLinkList() { Empty(); } -void SingleLinkList::Empty() -{ - SingleLinkNode *tmp = head; - while(tmp) { +void SingleLinkList::Empty() { + SingleLinkNode * tmp = head; + while( tmp ) { tmp = head -> NextNode(); delete head; head = tmp; } } -SingleLinkNode *SingleLinkList::NewNode() -{ +SingleLinkNode * SingleLinkList::NewNode() { // defined in subtypes std::cerr << "\n\n******BUG****** a virtually defined function should \n" - << "be called for SingleLinkList::NewNode()\n\n"; + << "be called for SingleLinkList::NewNode()\n\n"; return new SingleLinkNode(); } -SingleLinkNode *SingleLinkList::GetHead() const -{ - return (head); +SingleLinkNode * SingleLinkList::GetHead() const { + return ( head ); } -int SingleLinkList::EntryCount() const -{ +int SingleLinkList::EntryCount() const { int entryCount = 0; - SingleLinkNode *entryPtr = head; + SingleLinkNode * entryPtr = head; - while(entryPtr != 0) { + while( entryPtr != 0 ) { entryPtr = entryPtr->NextNode(); entryCount++; } return entryCount; } -void SingleLinkList::DeleteFollowingNodes(SingleLinkNode *item) -{ - if(head) { - SingleLinkNode *trailer = 0; - SingleLinkNode *leader = head; - while(leader) { - if(leader == item) { - while(leader) { - if(trailer) { +void SingleLinkList::DeleteFollowingNodes( SingleLinkNode * item ) { + if( head ) { + SingleLinkNode * trailer = 0; + SingleLinkNode * leader = head; + while( leader ) { + if( leader == item ) { + while( leader ) { + if( trailer ) { trailer->next = leader->next; - } else if(leader == head) { + } else if( leader == head ) { head = leader->next; trailer = head; } - if(leader == tail) { + if( leader == tail ) { tail = trailer; } delete leader; leader = trailer->next; } } else { - if(trailer) { + if( trailer ) { trailer = trailer->NextNode(); } else { trailer = leader; @@ -91,9 +84,8 @@ void SingleLinkList::DeleteFollowingNodes(SingleLinkNode *item) } } -void SingleLinkList::AppendNode(SingleLinkNode *item) -{ - if(head) { +void SingleLinkList::AppendNode( SingleLinkNode * item ) { + if( head ) { tail -> next = item; tail = item; } else { @@ -102,26 +94,25 @@ void SingleLinkList::AppendNode(SingleLinkNode *item) item->owner = this; } -void SingleLinkList::DeleteNode(SingleLinkNode *item) -{ - if(head) { - SingleLinkNode *trailer = 0; - SingleLinkNode *leader = head; - while(leader) { - if(leader == item) { - if(trailer) { +void SingleLinkList::DeleteNode( SingleLinkNode * item ) { + if( head ) { + SingleLinkNode * trailer = 0; + SingleLinkNode * leader = head; + while( leader ) { + if( leader == item ) { + if( trailer ) { trailer->next = leader->next; } leader = leader->next; - if(item == head) { + if( item == head ) { head = item->next; } - if(item == tail) { + if( item == tail ) { tail = trailer; } delete item; } else { - if(trailer) { + if( trailer ) { trailer = trailer->NextNode(); } else { trailer = leader; diff --git a/src/clstepcore/SingleLinkList.h b/src/clstepcore/SingleLinkList.h index a6fddd928..24726f194 100644 --- a/src/clstepcore/SingleLinkList.h +++ b/src/clstepcore/SingleLinkList.h @@ -20,19 +20,18 @@ * node which represents the value is contained in the subclass * since it may have different types for different lists */ -class SC_CORE_EXPORT SingleLinkList -{ +class SC_CORE_EXPORT SingleLinkList { protected: - class SingleLinkNode *head; - SingleLinkNode *tail; + class SingleLinkNode * head; + SingleLinkNode * tail; public: - virtual SingleLinkNode *NewNode(); - virtual void AppendNode(SingleLinkNode *); - virtual void DeleteNode(SingleLinkNode *); + virtual SingleLinkNode * NewNode(); + virtual void AppendNode( SingleLinkNode * ); + virtual void DeleteNode( SingleLinkNode * ); virtual void Empty(); - virtual void DeleteFollowingNodes(SingleLinkNode *); - virtual SingleLinkNode *GetHead() const; + virtual void DeleteFollowingNodes( SingleLinkNode * ); + virtual SingleLinkNode * GetHead() const; int EntryCount() const; @@ -43,24 +42,20 @@ class SC_CORE_EXPORT SingleLinkList /** Base class for nodes of a single-linked list. * \sa SingleLinkList */ -class SC_CORE_EXPORT SingleLinkNode -{ +class SC_CORE_EXPORT SingleLinkNode { friend class SingleLinkList; public: - SingleLinkList *owner; - SingleLinkNode *next; + SingleLinkList * owner; + SingleLinkNode * next; - virtual SingleLinkNode *NextNode() const - { + virtual SingleLinkNode * NextNode() const { return next; } - SingleLinkNode() : owner(0), next(0) - { + SingleLinkNode() : owner( 0 ), next( 0 ) { } - virtual ~SingleLinkNode() - { + virtual ~SingleLinkNode() { } }; diff --git a/src/clstepcore/SubSuperIterators.h b/src/clstepcore/SubSuperIterators.h index 029d0999e..9ca78765b 100644 --- a/src/clstepcore/SubSuperIterators.h +++ b/src/clstepcore/SubSuperIterators.h @@ -9,12 +9,11 @@ /** abstract base class for recursive breadth-first input iterators of EntityDescriptor/EntityDescLinkNode * NOTE: due to pure virtual functions being necessary for initialization, derived class constructor must call reset(t) */ -class recursiveEntDescripIterator -{ +class recursiveEntDescripIterator { protected: - const EntityDescriptor *startEntity; + const EntityDescriptor * startEntity; typedef struct { - const EntityDescriptor *ed; + const EntityDescriptor * ed; unsigned int depth; ///< for debugging; records how many lists had to be traversed to find the current node } queue_pair; @@ -22,166 +21,146 @@ class recursiveEntDescripIterator unsigned int position; ///< primarily used in comparisons between iterators ///add contents of a linked list to q - void addLinkedList(const queue_pair qp) - { - EntityDescLinkNode *a = listHead(qp.ed); + void addLinkedList( const queue_pair qp ) { + EntityDescLinkNode * a = listHead( qp.ed ); queue_pair tmp; tmp.depth = qp.depth + 1; - while(a != 0) { - tmp.ed = nodeContent(a); - q.push_back(tmp); - a = (EntityDescLinkNode *) a->NextNode(); + while( a != 0 ) { + tmp.ed = nodeContent( a ); + q.push_back( tmp ); + a = ( EntityDescLinkNode * ) a->NextNode( ); } } - virtual EntityDescLinkNode *listHead(const EntityDescriptor *t) const = 0; ///< returns the head of something inheriting SingleLinkList - virtual EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const = 0; ///< returns the content of a SingleLinkNode + virtual EntityDescLinkNode * listHead( const EntityDescriptor * t ) const = 0; ///< returns the head of something inheriting SingleLinkList + virtual EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const = 0; ///< returns the content of a SingleLinkNode public: - recursiveEntDescripIterator(const EntityDescriptor *t = 0): startEntity(t), position(0) - { + recursiveEntDescripIterator( const EntityDescriptor * t = 0 ): startEntity( t ), position( 0 ) { //NOTE due to pure virtual functions, derived class constructor *must* call reset(t) } - ~recursiveEntDescripIterator() - { + ~recursiveEntDescripIterator( ) { } - void reset(const EntityDescriptor *t = 0) - { + void reset( const EntityDescriptor * t = 0 ) { position = 0; - q.clear(); - if(t) { + q.clear( ); + if( t ) { startEntity = t; } - if(startEntity) { + if( startEntity ) { queue_pair p; p.depth = 0; p.ed = startEntity; - addLinkedList(p); + addLinkedList( p ); } } - const EntityDescriptor *next() - { - if(q.empty()) { - return (EntityDescriptor *) 0; + const EntityDescriptor * next( ) { + if( q.empty( ) ) { + return ( EntityDescriptor * ) 0; } else { position++; - queue_pair qp = q.front(); - q.pop_front(); - addLinkedList(qp); + queue_pair qp = q.front( ); + q.pop_front( ); + addLinkedList( qp ); return qp.ed; } } - const EntityDescriptor *current() const - { - if(q.empty()) { - return (EntityDescriptor *) 0; + const EntityDescriptor * current( ) const { + if( q.empty( ) ) { + return ( EntityDescriptor * ) 0; } - return(q.front().ed); + return( q.front( ).ed ); } - bool hasNext() const - { - return(((q.size() > 1) && (q[1].ed != 0)) //there is another EntityDescriptor in q - || (nodeContent(listHead(q[0].ed)) != 0)); //or, the only one in the queue has a non-empty list + bool hasNext( ) const { + return( ( ( q.size( ) > 1 ) && ( q[1].ed != 0 ) ) //there is another EntityDescriptor in q + || ( nodeContent( listHead( q[0].ed ) ) != 0 ) ); //or, the only one in the queue has a non-empty list } - bool empty() const - { - return q.empty(); + bool empty( ) const { + return q.empty( ); } - unsigned int pos() const - { + unsigned int pos( ) const { return position; } - unsigned int depth() const - { + unsigned int depth( ) const { return q[0].depth; } - const EntityDescriptor *operator *() const - { - return current(); + const EntityDescriptor * operator *( ) const { + return current( ); } - const EntityDescriptor *operator ->() const - { - return current(); + const EntityDescriptor * operator ->( ) const { + return current( ); } /// two iterators are not considered equal unless the startEntity pointers match and the positions match - bool operator ==(const recursiveEntDescripIterator &b) const - { - return((startEntity == b.startEntity) && (position == b.position)); + bool operator ==( const recursiveEntDescripIterator & b ) const { + return( ( startEntity == b.startEntity ) && ( position == b.position ) ); } - bool operator !=(const recursiveEntDescripIterator &b) const - { - return((startEntity != b.startEntity) || (position != b.position)); + bool operator !=( const recursiveEntDescripIterator & b ) const { + return( ( startEntity != b.startEntity ) || ( position != b.position ) ); } /// for inequality operators, return a Logical; LUnknown means that the startEntity pointers do not match - Logical operator >(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator >( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position > b.position) { + if( position > b.position ) { return LTrue; } else { return LFalse; } } - Logical operator <(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator <( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position < b.position) { + if( position < b.position ) { return LTrue; } else { return LFalse; } } - Logical operator >=(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator >=( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position >= b.position) { + if( position >= b.position ) { return LTrue; } else { return LFalse; } } - Logical operator <=(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator <=( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position <= b.position) { + if( position <= b.position ) { return LTrue; } else { return LFalse; } } - const EntityDescriptor *operator ++() - { - return next(); + const EntityDescriptor * operator ++( ) { + return next( ); } - const EntityDescriptor *operator ++(int) - { - const EntityDescriptor *c = current(); - next(); + const EntityDescriptor * operator ++( int ) { + const EntityDescriptor * c = current( ); + next( ); return c; } }; @@ -189,54 +168,46 @@ class recursiveEntDescripIterator /** Recursive breadth-first input iterator for supertypes * \sa subtypesIterator */ -class supertypesIterator : public recursiveEntDescripIterator -{ +class supertypesIterator : public recursiveEntDescripIterator { protected: - EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList - { - if(!t) { + EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList + if( !t ) { return 0; } - return (EntityDescLinkNode *) t->Supertypes().GetHead(); + return ( EntityDescLinkNode * ) t->Supertypes().GetHead(); } - EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode - { - if(!n) { + EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode + if( !n ) { return 0; } return n->EntityDesc(); } public: - supertypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) - { - reset(t); + supertypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { + reset( t ); } }; /** Recursive breadth-first input iterator for subtypes * \sa supertypesIterator */ -class subtypesIterator: public recursiveEntDescripIterator -{ +class subtypesIterator: public recursiveEntDescripIterator { protected: - EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList - { - if(!t) { + EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList + if( !t ) { return 0; } - return (EntityDescLinkNode *) t->Subtypes().GetHead(); + return ( EntityDescLinkNode * ) t->Subtypes().GetHead(); } - EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode - { - if(!n) { + EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode + if( !n ) { return 0; } return n->EntityDesc(); } public: - subtypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) - { - reset(t); + subtypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { + reset( t ); } }; diff --git a/src/clstepcore/aggrTypeDescriptor.cc b/src/clstepcore/aggrTypeDescriptor.cc index 6b6a5857e..91bed40be 100644 --- a/src/clstepcore/aggrTypeDescriptor.cc +++ b/src/clstepcore/aggrTypeDescriptor.cc @@ -1,36 +1,31 @@ #include "aggrTypeDescriptor.h" -STEPaggregate *AggrTypeDescriptor::CreateAggregate() -{ - if(CreateNewAggr) { +STEPaggregate * AggrTypeDescriptor::CreateAggregate() { + if( CreateNewAggr ) { return CreateNewAggr(); } else { return 0; } } -void AggrTypeDescriptor::AssignAggrCreator(AggregateCreator f) -{ +void AggrTypeDescriptor::AssignAggrCreator( AggregateCreator f ) { CreateNewAggr = f; } -AggrTypeDescriptor::AggrTypeDescriptor() : - _uniqueElements("UNKNOWN_TYPE") -{ +AggrTypeDescriptor::AggrTypeDescriptor( ) : +_uniqueElements( "UNKNOWN_TYPE" ) { _bound1 = -1; _bound2 = -1; _aggrDomainType = 0; } -AggrTypeDescriptor::AggrTypeDescriptor(SDAI_Integer b1, - SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor *aggrDomType) - : _bound1(b1), _bound2(b2), _uniqueElements(uniqElem) -{ +AggrTypeDescriptor::AggrTypeDescriptor( SDAI_Integer b1, + SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor * aggrDomType ) +: _bound1( b1 ), _bound2( b2 ), _uniqueElements( uniqElem ) { _aggrDomainType = aggrDomType; } -AggrTypeDescriptor::~AggrTypeDescriptor() -{ +AggrTypeDescriptor::~AggrTypeDescriptor() { } diff --git a/src/clstepcore/aggrTypeDescriptor.h b/src/clstepcore/aggrTypeDescriptor.h index 98da5579d..850a6b2e7 100644 --- a/src/clstepcore/aggrTypeDescriptor.h +++ b/src/clstepcore/aggrTypeDescriptor.h @@ -24,232 +24,203 @@ enum AggrBoundTypeEnum { * together by the _aggrDomainType variables. If you can make this * work then go for it. */ -class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor { - protected: +protected: - SDAI_Integer _bound1, _bound2; - SDAI_LOGICAL _uniqueElements; - TypeDescriptor *_aggrDomainType; - AggregateCreator CreateNewAggr; + SDAI_Integer _bound1, _bound2; + SDAI_LOGICAL _uniqueElements; + TypeDescriptor * _aggrDomainType; + AggregateCreator CreateNewAggr; - AggrBoundTypeEnum _bound1_type, _bound2_type; - boundCallbackFn _bound1_callback, _bound2_callback; + AggrBoundTypeEnum _bound1_type, _bound2_type; + boundCallbackFn _bound1_callback, _bound2_callback; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::string _bound1_str, _bound2_str; + std::string _bound1_str, _bound2_str; #ifdef _MSC_VER #pragma warning( pop ) #endif - public: - - void AssignAggrCreator(AggregateCreator f = 0); - - STEPaggregate *CreateAggregate(); - - AggrTypeDescriptor(); - AggrTypeDescriptor(SDAI_Integer b1, SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor *aggrDomType); - AggrTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : TypeDescriptor(nm, ft, origSchema, d), _bound1(0), _bound2(0), _uniqueElements(0), _aggrDomainType(NULL), CreateNewAggr(f) { } - virtual ~AggrTypeDescriptor(); - - - /// find bound type - AggrBoundTypeEnum Bound1Type() const - { - return _bound1_type; - } - /// get a constant bound - SDAI_Integer Bound1() const - { - assert(_bound1_type == bound_constant); - return _bound1; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound1Runtime(SDAI_Application_instance *this_ptr) const - { - assert(this_ptr && (_bound1_type == bound_runtime)); - return _bound1_callback(this_ptr) ; - } - /// get a bound's EXPRESS function call string - std::string Bound1Funcall() const - { - return _bound1_str; - } - /// set bound to a constant - void SetBound1(SDAI_Integer b1) - { - _bound1 = b1; - _bound1_type = bound_constant; - } - ///set bound's callback fn. only for bounds dependent on an attribute - void SetBound1FromMemberAccessor(boundCallbackFn callback) - { - _bound1_callback = callback; - _bound1_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound1FromExpressFuncall(std::string s) - { - _bound1_str = s; - _bound1_type = bound_funcall; - } - - /// find bound type - AggrBoundTypeEnum Bound2Type() const - { - return _bound2_type; - } - /// get a constant bound - SDAI_Integer Bound2() const - { - assert(_bound2_type == bound_constant); - return _bound2; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound2Runtime(SDAI_Application_instance *this_ptr) const - { - assert(this_ptr && (_bound2_type == bound_runtime)); - return _bound2_callback(this_ptr) ; - } - /// get a bound's EXPRESS function call string - std::string Bound2Funcall() const - { - return _bound2_str; - } - /// set bound to a constant - void SetBound2(SDAI_Integer b2) - { - _bound2 = b2; - _bound2_type = bound_constant; - } - ///set bound's callback fn - void SetBound2FromMemberAccessor(boundCallbackFn callback) - { - _bound2_callback = callback; - _bound2_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound2FromExpressFuncall(std::string s) - { - _bound2_str = s; - _bound2_type = bound_funcall; - } - - SDAI_LOGICAL &UniqueElements() - { - return _uniqueElements; - } - void UniqueElements(SDAI_LOGICAL &ue) - { - _uniqueElements.put(ue.asInt()); - } - void UniqueElements(Logical ue) - { - _uniqueElements.put(ue); - } - void UniqueElements(const char *ue) - { - _uniqueElements.put(ue); - } - - class TypeDescriptor *AggrDomainType() - { - return _aggrDomainType; - } - void AggrDomainType(TypeDescriptor *adt) - { - _aggrDomainType = adt; - } +public: + + void AssignAggrCreator( AggregateCreator f = 0 ); + + STEPaggregate * CreateAggregate(); + + AggrTypeDescriptor( ); + AggrTypeDescriptor( SDAI_Integer b1, SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor * aggrDomType ); + AggrTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ) { } + virtual ~AggrTypeDescriptor(); + + + /// find bound type + AggrBoundTypeEnum Bound1Type() const { + return _bound1_type; + } + /// get a constant bound + SDAI_Integer Bound1( ) const { + assert( _bound1_type == bound_constant ); + return _bound1; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound1Runtime( SDAI_Application_instance * this_ptr ) const { + assert( this_ptr && ( _bound1_type == bound_runtime ) ); + return _bound1_callback( this_ptr ) ; + } + /// get a bound's EXPRESS function call string + std::string Bound1Funcall() const { + return _bound1_str; + } + /// set bound to a constant + void SetBound1( SDAI_Integer b1 ) { + _bound1 = b1; + _bound1_type = bound_constant; + } + ///set bound's callback fn. only for bounds dependent on an attribute + void SetBound1FromMemberAccessor( boundCallbackFn callback ) { + _bound1_callback = callback; + _bound1_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound1FromExpressFuncall( std::string s ) { + _bound1_str = s; + _bound1_type = bound_funcall; + } + + /// find bound type + AggrBoundTypeEnum Bound2Type() const { + return _bound2_type; + } + /// get a constant bound + SDAI_Integer Bound2( ) const { + assert( _bound2_type == bound_constant ); + return _bound2; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound2Runtime( SDAI_Application_instance * this_ptr ) const { + assert( this_ptr && ( _bound2_type == bound_runtime ) ); + return _bound2_callback( this_ptr ) ; + } + /// get a bound's EXPRESS function call string + std::string Bound2Funcall() const { + return _bound2_str; + } + /// set bound to a constant + void SetBound2( SDAI_Integer b2 ) { + _bound2 = b2; + _bound2_type = bound_constant; + } + ///set bound's callback fn + void SetBound2FromMemberAccessor( boundCallbackFn callback ) { + _bound2_callback = callback; + _bound2_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound2FromExpressFuncall( std::string s ) { + _bound2_str = s; + _bound2_type = bound_funcall; + } + + SDAI_LOGICAL & UniqueElements() { + return _uniqueElements; + } + void UniqueElements( SDAI_LOGICAL & ue ) { + _uniqueElements.put( ue.asInt() ); + } + void UniqueElements( Logical ue ) { + _uniqueElements.put( ue ); + } + void UniqueElements( const char * ue ) { + _uniqueElements.put( ue ); + } + + class TypeDescriptor * AggrDomainType() { + return _aggrDomainType; + } + void AggrDomainType( TypeDescriptor * adt ) { + _aggrDomainType = adt; + } }; -class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor -{ - - protected: - SDAI_LOGICAL _optionalElements; - public: - - ArrayTypeDescriptor() : _optionalElements("UNKNOWN_TYPE") { } - ArrayTypeDescriptor(Logical optElem) : _optionalElements(optElem) - { } - ArrayTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f), - _optionalElements("UNKNOWN_TYPE") - { } - - virtual ~ArrayTypeDescriptor() {} - - - SDAI_LOGICAL &OptionalElements() - { - return _optionalElements; - } - void OptionalElements(SDAI_LOGICAL &oe) - { - _optionalElements.put(oe.asInt()); - } - void OptionalElements(Logical oe) - { - _optionalElements.put(oe); - } - void OptionalElements(const char *oe) - { - _optionalElements.put(oe); - } +class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor { + +protected: + SDAI_LOGICAL _optionalElements; +public: + + ArrayTypeDescriptor( ) : _optionalElements( "UNKNOWN_TYPE" ) { } + ArrayTypeDescriptor( Logical optElem ) : _optionalElements( optElem ) + { } + ArrayTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ), + _optionalElements( "UNKNOWN_TYPE" ) + { } + + virtual ~ArrayTypeDescriptor() {} + + + SDAI_LOGICAL & OptionalElements() { + return _optionalElements; + } + void OptionalElements( SDAI_LOGICAL & oe ) { + _optionalElements.put( oe.asInt() ); + } + void OptionalElements( Logical oe ) { + _optionalElements.put( oe ); + } + void OptionalElements( const char * oe ) { + _optionalElements.put( oe ); + } }; -class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor { - protected: - public: - ListTypeDescriptor() { } - ListTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~ListTypeDescriptor() { } +protected: +public: + ListTypeDescriptor( ) { } + ListTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~ListTypeDescriptor() { } }; -class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor { - protected: - public: +protected: +public: - SetTypeDescriptor() { } - SetTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~SetTypeDescriptor() { } + SetTypeDescriptor( ) { } + SetTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~SetTypeDescriptor() { } }; -class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor { - protected: - public: +protected: +public: - BagTypeDescriptor() { } - BagTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~BagTypeDescriptor() { } + BagTypeDescriptor( ) { } + BagTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~BagTypeDescriptor() { } }; diff --git a/src/clstepcore/attrDescriptor.cc b/src/clstepcore/attrDescriptor.cc index f95b8dfaa..329d90393 100644 --- a/src/clstepcore/attrDescriptor.cc +++ b/src/clstepcore/attrDescriptor.cc @@ -1,115 +1,101 @@ #include "attrDescriptor.h" -AttrDescriptor::AttrDescriptor(const char *name, const TypeDescriptor *domainType, - Logical optional, Logical unique, AttrType_Enum at, - const EntityDescriptor &owner) - : _name(name), _domainType(domainType), _optional(optional), - _unique(unique), _attrType(at), _owner((EntityDescriptor &)owner) -{ +AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType, + Logical optional, Logical unique, AttrType_Enum at, + const EntityDescriptor & owner ) + : _name( name ), _domainType( domainType ), _optional( optional ), + _unique( unique ), _attrType( at ), _owner( ( EntityDescriptor & )owner ) { } -AttrDescriptor::~AttrDescriptor() -{ +AttrDescriptor::~AttrDescriptor() { } -Logical AttrDescriptor::Explicit() const -{ - if(_attrType == AttrType_Explicit) { +Logical AttrDescriptor::Explicit() const { + if( _attrType == AttrType_Explicit ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Inverse() const -{ - if(_attrType == AttrType_Inverse) { +Logical AttrDescriptor::Inverse() const { + if( _attrType == AttrType_Inverse ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Redefining() const -{ - if(_attrType == AttrType_Redefining) { +Logical AttrDescriptor::Redefining() const { + if( _attrType == AttrType_Redefining ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Deriving() const -{ - if(_attrType == AttrType_Deriving) { +Logical AttrDescriptor::Deriving() const { + if( _attrType == AttrType_Deriving ) { return LTrue; } return LFalse; } -const char *AttrDescriptor::AttrExprDefStr(std::string &s) const -{ +const char * AttrDescriptor::AttrExprDefStr( std::string & s ) const { std::string buf; s = Name(); - s.append(" : "); - if(_optional.asInt() == LTrue) { - s.append("OPTIONAL "); + s.append( " : " ); + if( _optional.asInt() == LTrue ) { + s.append( "OPTIONAL " ); } - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -PrimitiveType AttrDescriptor::BaseType() const -{ - if(_domainType) { +PrimitiveType AttrDescriptor::BaseType() const { + if( _domainType ) { return _domainType->BaseType(); } return UNKNOWN_TYPE; } -int AttrDescriptor::IsAggrType() const -{ +int AttrDescriptor::IsAggrType() const { return ReferentType()->IsAggrType(); } -PrimitiveType AttrDescriptor::AggrElemType() const -{ - if(IsAggrType()) { +PrimitiveType AttrDescriptor::AggrElemType() const { + if( IsAggrType() ) { return ReferentType()->AggrElemType(); } return UNKNOWN_TYPE; } -const TypeDescriptor *AttrDescriptor::AggrElemTypeDescriptor() const -{ - if(IsAggrType()) { +const TypeDescriptor * AttrDescriptor::AggrElemTypeDescriptor() const { + if( IsAggrType() ) { return ReferentType()->AggrElemTypeDescriptor(); } return 0; } -const TypeDescriptor *AttrDescriptor::NonRefTypeDescriptor() const -{ - if(_domainType) { +const TypeDescriptor * AttrDescriptor::NonRefTypeDescriptor() const { + if( _domainType ) { return _domainType->NonRefTypeDescriptor(); } return 0; } PrimitiveType -AttrDescriptor::NonRefType() const -{ - if(_domainType) { +AttrDescriptor::NonRefType() const { + if( _domainType ) { return _domainType->NonRefType(); } return UNKNOWN_TYPE; } PrimitiveType -AttrDescriptor::Type() const -{ - if(_domainType) { +AttrDescriptor::Type() const { + if( _domainType ) { return _domainType->Type(); } return UNKNOWN_TYPE; @@ -119,37 +105,34 @@ AttrDescriptor::Type() const * right side of attr def * NOTE this returns a \'const char * \' instead of an std::string */ -const std::string AttrDescriptor::TypeName() const -{ +const std::string AttrDescriptor::TypeName() const { std::string buf; - if(_domainType) { - _domainType->AttrTypeName(buf); + if( _domainType ) { + _domainType->AttrTypeName( buf ); } return buf; } /// an expanded right side of attr def const char * -AttrDescriptor::ExpandedTypeName(std::string &s) const -{ +AttrDescriptor::ExpandedTypeName( std::string & s ) const { s.clear(); - if(Derived() == LTrue) { + if( Derived() == LTrue ) { s = "DERIVE "; } - if(_domainType) { + if( _domainType ) { std::string tmp; - return const_cast((s.append(_domainType->TypeString(tmp)).c_str())); + return const_cast( ( s.append( _domainType->TypeString( tmp ) ).c_str() ) ); } else { return 0; } } -const char *AttrDescriptor::GenerateExpress(std::string &buf) const -{ +const char * AttrDescriptor::GenerateExpress( std::string & buf ) const { std::string sstr; - buf = AttrExprDefStr(sstr); - buf.append(";\n"); - return const_cast(buf.c_str()); + buf = AttrExprDefStr( sstr ); + buf.append( ";\n" ); + return const_cast( buf.c_str() ); } diff --git a/src/clstepcore/attrDescriptor.h b/src/clstepcore/attrDescriptor.h index f681e111e..cee4d13bc 100644 --- a/src/clstepcore/attrDescriptor.h +++ b/src/clstepcore/attrDescriptor.h @@ -20,42 +20,39 @@ class EntityDescriptor; * An instance of this class will be generated for each attribute for * an Entity. They will be pointed to by the EntityTypeDescriptors. */ -class SC_CORE_EXPORT AttrDescriptor -{ +class SC_CORE_EXPORT AttrDescriptor { protected: - const char *_name; // the attributes name + const char * _name; // the attributes name // this defines the domain of the attribute - const TypeDescriptor *_domainType; + const TypeDescriptor * _domainType; SDAI_LOGICAL _optional; SDAI_LOGICAL _unique; AttrType_Enum _attrType; // former attribute _derived - const EntityDescriptor &_owner; // the owning entityDescriptor + const EntityDescriptor & _owner; // the owning entityDescriptor public: AttrDescriptor( - const char *name, // i.e. char * - const TypeDescriptor *domainType, + const char * name, // i.e. char * + const TypeDescriptor * domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor &owner + const EntityDescriptor & owner ); virtual ~AttrDescriptor(); - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; // the attribute Express def - virtual const char *AttrExprDefStr(std::string &s) const; + virtual const char * AttrExprDefStr( std::string & s ) const; // left side of attr def - const char *Name() const - { + const char * Name() const { return _name; } - void Name(const char *n) - { + void Name( const char * n ) { _name = n; } @@ -79,7 +76,7 @@ class SC_CORE_EXPORT AttrDescriptor */ ///@{ PrimitiveType BaseType() const; - const TypeDescriptor *BaseTypeDescriptor() const; + const TypeDescriptor * BaseTypeDescriptor() const; ///@} /** @@ -95,12 +92,12 @@ class SC_CORE_EXPORT AttrDescriptor */ ///@{ PrimitiveType NonRefType() const; - const TypeDescriptor *NonRefTypeDescriptor() const; + const TypeDescriptor * NonRefTypeDescriptor() const; ///@} int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor *AggrElemTypeDescriptor() const; + const TypeDescriptor * AggrElemTypeDescriptor() const; /// The type of the attributes TypeDescriptor PrimitiveType Type() const; @@ -109,71 +106,56 @@ class SC_CORE_EXPORT AttrDescriptor const std::string TypeName() const; /// an expanded right side of attr def - const char *ExpandedTypeName(std::string &s) const; + const char * ExpandedTypeName( std::string & s ) const; - int RefersToType() const - { - return !(_domainType == 0); + int RefersToType() const { + return !( _domainType == 0 ); } - const TypeDescriptor *ReferentType() const - { + const TypeDescriptor * ReferentType() const { return _domainType; } - const TypeDescriptor *DomainType() const - { + const TypeDescriptor * DomainType() const { return _domainType; } - void DomainType(const TypeDescriptor *td) - { + void DomainType( const TypeDescriptor * td ) { _domainType = td; } - void ReferentType(const TypeDescriptor *td) - { + void ReferentType( const TypeDescriptor * td ) { _domainType = td; } - const SDAI_LOGICAL &Optional() const - { + const SDAI_LOGICAL & Optional() const { return _optional; } - void Optional(SDAI_LOGICAL &opt) - { - _optional.put(opt.asInt()); + void Optional( SDAI_LOGICAL & opt ) { + _optional.put( opt.asInt() ); } - void Optional(Logical opt) - { - _optional.put(opt); + void Optional( Logical opt ) { + _optional.put( opt ); } - void Optional(const char *opt) - { - _optional.put(opt); + void Optional( const char * opt ) { + _optional.put( opt ); } - const SDAI_LOGICAL &Unique() const - { + const SDAI_LOGICAL & Unique() const { return _unique; } - void Unique(SDAI_LOGICAL uniq) - { - _unique.put(uniq.asInt()); + void Unique( SDAI_LOGICAL uniq ) { + _unique.put( uniq.asInt() ); } - void Unique(Logical uniq) - { - _unique.put(uniq); + void Unique( Logical uniq ) { + _unique.put( uniq ); } - void Unique(const char *uniq) - { - _unique.put(uniq); + void Unique( const char * uniq ) { + _unique.put( uniq ); } - void AttrType(enum AttrType_Enum ate) - { + void AttrType( enum AttrType_Enum ate ) { _attrType = ate; } - enum AttrType_Enum AttrType() const - { + enum AttrType_Enum AttrType() const { return _attrType; } @@ -183,50 +165,40 @@ class SC_CORE_EXPORT AttrDescriptor Logical Deriving() const; //outdated functions, use AttrType func above, new support of redefined - Logical Derived() const - { + Logical Derived() const { return Deriving(); } - void Derived(Logical x); // outdated DAS - void Derived(SDAI_LOGICAL x); // outdated DAS - void Derived(const char *x); // outdated DAS + void Derived( Logical x ); // outdated DAS + void Derived( SDAI_LOGICAL x ); // outdated DAS + void Derived( const char * x ); // outdated DAS - const SDAI_LOGICAL &Optionality() const - { + const SDAI_LOGICAL & Optionality() const { return _optional; } - void Optionality(SDAI_LOGICAL &opt) - { - _optional.put(opt.asInt()); + void Optionality( SDAI_LOGICAL & opt ) { + _optional.put( opt.asInt() ); } - void Optionality(Logical opt) - { - _optional.put(opt); + void Optionality( Logical opt ) { + _optional.put( opt ); } - void Optionality(const char *opt) - { - _optional.put(opt); + void Optionality( const char * opt ) { + _optional.put( opt ); } - const SDAI_LOGICAL &Uniqueness() const - { + const SDAI_LOGICAL & Uniqueness() const { return _unique; } - void Uniqueness(SDAI_LOGICAL uniq) - { - _unique.put(uniq.asInt()); + void Uniqueness( SDAI_LOGICAL uniq ) { + _unique.put( uniq.asInt() ); } - void Uniqueness(Logical uniq) - { - _unique.put(uniq); + void Uniqueness( Logical uniq ) { + _unique.put( uniq ); } - void Uniqueness(const char *uniq) - { - _unique.put(uniq); + void Uniqueness( const char * uniq ) { + _unique.put( uniq ); } - const EntityDescriptor &Owner() const - { + const EntityDescriptor & Owner() const { return _owner; } }; diff --git a/src/clstepcore/attrDescriptorList.cc b/src/clstepcore/attrDescriptorList.cc index e75f23c41..c197ac5e2 100644 --- a/src/clstepcore/attrDescriptorList.cc +++ b/src/clstepcore/attrDescriptorList.cc @@ -2,48 +2,40 @@ #include "attrDescriptor.h" -AttrDescriptorList::AttrDescriptorList() -{ +AttrDescriptorList::AttrDescriptorList() { } -AttrDescriptorList::~AttrDescriptorList() -{ +AttrDescriptorList::~AttrDescriptorList() { } -AttrDescLinkNode *AttrDescriptorList::AddNode(AttrDescriptor *ad) -{ - AttrDescLinkNode *node = (AttrDescLinkNode *) NewNode(); - node->AttrDesc(ad); - SingleLinkList::AppendNode(node); +AttrDescLinkNode * AttrDescriptorList::AddNode( AttrDescriptor * ad ) { + AttrDescLinkNode * node = ( AttrDescLinkNode * ) NewNode(); + node->AttrDesc( ad ); + SingleLinkList::AppendNode( node ); return node; } -AttrDescLinkNode::AttrDescLinkNode() -{ +AttrDescLinkNode::AttrDescLinkNode() { _attrDesc = 0; } -AttrDescLinkNode::~AttrDescLinkNode() -{ - if(_attrDesc) { +AttrDescLinkNode::~AttrDescLinkNode() { + if( _attrDesc ) { delete _attrDesc; } } -AttrDescItr::AttrDescItr(const AttrDescriptorList &adList) : adl(adList) -{ - cur = (AttrDescLinkNode *)(adl.GetHead()); +AttrDescItr::AttrDescItr( const AttrDescriptorList & adList ) : adl( adList ) { + cur = ( AttrDescLinkNode * )( adl.GetHead() ); } -AttrDescItr::~AttrDescItr() -{ +AttrDescItr::~AttrDescItr() { } -const AttrDescriptor *AttrDescItr::NextAttrDesc() -{ - if(cur) { - const AttrDescriptor *ad = cur->AttrDesc(); - cur = (AttrDescLinkNode *)(cur->NextNode()); +const AttrDescriptor * AttrDescItr::NextAttrDesc() { + if( cur ) { + const AttrDescriptor * ad = cur->AttrDesc(); + cur = ( AttrDescLinkNode * )( cur->NextNode() ); return ad; } return 0; diff --git a/src/clstepcore/attrDescriptorList.h b/src/clstepcore/attrDescriptorList.h index c6550ba82..a1c844a8f 100644 --- a/src/clstepcore/attrDescriptorList.h +++ b/src/clstepcore/attrDescriptorList.h @@ -9,57 +9,50 @@ class AttrDescriptor; -class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode { private: protected: - AttrDescriptor *_attrDesc; + AttrDescriptor * _attrDesc; public: AttrDescLinkNode(); virtual ~AttrDescLinkNode(); - const AttrDescriptor *AttrDesc() const - { + const AttrDescriptor * AttrDesc() const { return _attrDesc; } - void AttrDesc(AttrDescriptor *ad) - { + void AttrDesc( AttrDescriptor * ad ) { _attrDesc = ad; } }; -class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList { private: protected: public: AttrDescriptorList(); virtual ~AttrDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new AttrDescLinkNode; } - AttrDescLinkNode *AddNode(AttrDescriptor *ad); + AttrDescLinkNode * AddNode( AttrDescriptor * ad ); }; -class SC_CORE_EXPORT AttrDescItr -{ +class SC_CORE_EXPORT AttrDescItr { protected: - const AttrDescriptorList &adl; - const AttrDescLinkNode *cur; + const AttrDescriptorList & adl; + const AttrDescLinkNode * cur; public: - AttrDescItr(const AttrDescriptorList &adList); + AttrDescItr( const AttrDescriptorList & adList ); virtual ~AttrDescItr(); - void ResetItr() - { - cur = (AttrDescLinkNode *)(adl.GetHead()); + void ResetItr() { + cur = ( AttrDescLinkNode * )( adl.GetHead() ); } - const AttrDescriptor *NextAttrDesc(); + const AttrDescriptor * NextAttrDesc(); }; #endif //ATTRDESCRIPTORLIST_H diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index 92c95cc88..b6abef73c 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -18,15 +18,14 @@ * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ -void ComplexCollect::insert(ComplexList *c) -{ - ComplexList *prev = NULL, *cl = clists; +void ComplexCollect::insert( ComplexList * c ) { + ComplexList * prev = NULL, *cl = clists; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(prev == NULL) { + if( prev == NULL ) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -47,19 +46,18 @@ void ComplexCollect::insert(ComplexList *c) * be able to find it, and now that all its supers have accessed it, we * remove it from the Collect. */ -void ComplexCollect::remove(ComplexList *c) -{ - ComplexList *cl = clists, *prev = NULL; +void ComplexCollect::remove( ComplexList * c ) { + ComplexList * cl = clists, *prev = NULL; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(cl == NULL || cl != c) { + if( cl == NULL || cl != c ) { // Just in case c isn't in the list. return; } - if(prev == NULL) { + if( prev == NULL ) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -73,14 +71,13 @@ void ComplexCollect::remove(ComplexList *c) /** * Searches for and returns the ComplexList whose supertype name = name. */ -ComplexList *ComplexCollect::find(char *name) -{ - ComplexList *cl = clists; +ComplexList * ComplexCollect::find( char * name ) { + ComplexList * cl = clists; - while(cl && *cl < name) { + while( cl && *cl < name ) { cl = cl->next; } - if(cl && *cl == name) { + if( cl && *cl == name ) { return cl; } return NULL; @@ -94,38 +91,37 @@ ComplexList *ComplexCollect::find(char *name) * should be included in >1 CList. A more complicated algorithm is applied * to match it, as described in the commenting. */ -bool ComplexCollect::supports(EntNode *ents) const -{ - EntNode *node = ents, *nextnode; - AndList *alist = 0; - ComplexList *clist = clists, *cl = NULL, *current; +bool ComplexCollect::supports( EntNode * ents ) const { + EntNode * node = ents, *nextnode; + AndList * alist = 0; + ComplexList * clist = clists, *cl = NULL, *current; bool retval; - EntList *elist, *next; + EntList * elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while(node) { - if(node->multSuprs()) { + while( node ) { + if( node->multSuprs() ) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if(!cl) { + if( !cl ) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList(alist); + cl = new ComplexList( alist ); } current = clists; - while(current) { - if(current->contains(node)) { + while( current ) { + if( current->contains( node ) ) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if(! cl->toplevel(current->supertype())) { + if( ! cl->toplevel( current->supertype() ) ) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList(current->head->childList); + alist->appendList( current->head->childList ); } } current = current->next; @@ -137,11 +133,11 @@ bool ComplexCollect::supports(EntNode *ents) const // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if(!cl) { + if( !cl ) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while(clist != NULL) { - if(clist->matches(ents)) { + while( clist != NULL ) { + if( clist->matches( ents ) ) { return true; } clist = clist->next; @@ -152,13 +148,13 @@ bool ComplexCollect::supports(EntNode *ents) const // Use cl to test that the conditions of all supertypes are met: cl->multSupers = true; cl->buildList(); - retval = cl->matches(ents); + retval = cl->matches( ents ); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while(elist) { + while( elist ) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index 860bac36e..46b673b46 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -72,8 +72,7 @@ class OrList; class ComplexList; class ComplexCollect; -class SC_CORE_EXPORT EntNode -{ +class SC_CORE_EXPORT EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -81,108 +80,90 @@ class SC_CORE_EXPORT EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), multSupers(0) - { - StrToLower(nm, name); - } - EntNode(const char **); ///< given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), multSupers( 0 ) { + StrToLower( nm, name ); + } + EntNode( const char ** ); ///< given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - bool operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + bool operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - bool operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + bool operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - bool operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + bool operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - EntNode &operator= (EntNode &ent); - void Name(const char *nm) - { - strncpy(name, nm, BUFSIZ - 1); + EntNode & operator= ( EntNode & ent ); + void Name( const char * nm ) { + strncpy( name, nm, BUFSIZ - 1 ); } - const char *Name() - { + const char * Name() { return name; } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - bool marked(MarkType base = ORMARK) - { - return (mark >= base); + bool marked( MarkType base = ORMARK ) { + return ( mark >= base ); } bool allMarked(); ///< returns true if all nodes in list are marked int unmarkedCount(); - bool multSuprs() - { + bool multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - void sort(EntNode **); + void sort( EntNode ** ); - EntNode *next; + EntNode * next; private: MarkType mark; char name[BUFSIZ]; bool multSupers; ///< do I correspond to an entity with >1 supertype? - EntNode *lastSmaller(EntNode *); ///< used by ::sort() + EntNode * lastSmaller( EntNode * ); ///< used by ::sort() }; -class SC_CORE_EXPORT EntList -{ +class SC_CORE_EXPORT EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), next(0), prev(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), next( 0 ), prev( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual bool contains(char *) = 0; - virtual bool hit(char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual bool contains( char * ) = 0; + virtual bool hit( char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual bool acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual bool acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); @@ -190,34 +171,28 @@ class SC_CORE_EXPORT EntList // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return (next) ? next->firstNot(j) : NULL; + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return (next) ? next->firstWanted(mat) : NULL; + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return (prev) ? prev->lastNot(j) : NULL; + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return (prev) ? prev->lastWanted(mat) : NULL; + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *next = NULL; - EntList *prev = NULL; + EntList * next, *prev; protected: MatchType viable; @@ -231,39 +206,32 @@ class SC_CORE_EXPORT EntList int level; ///< How many levels deep are we (main use for printing). }; -class SC_CORE_EXPORT SimpleList : public EntList -{ +class SC_CORE_EXPORT SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strncpy(name, n, sizeof(name) - 1); - name[sizeof(name) - 1] = '\0'; /* sanity */ + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strncpy( name, n, sizeof( name ) - 1 ); + name[sizeof( name ) - 1] = '\0'; /* sanity */ } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - bool contains(char *nm) - { + bool contains( char * nm ) { return *this == nm; } - bool hit(char *nm) - { + bool hit( char * nm ) { return *this == nm; } - MatchType matchNonORs(EntNode *); - bool acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + MatchType matchNonORs( EntNode * ); + bool acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } @@ -277,43 +245,40 @@ class SC_CORE_EXPORT SimpleList : public EntList * Supports concepts and functionality common to all the compound list * types, especially AND and ANDOR. */ -class SC_CORE_EXPORT MultList : public EntList -{ +class SC_CORE_EXPORT MultList : public EntList { friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), supertype(0), numchildren(0), - childList(0) {} + MultList( JoinType j ) : EntList( j ), supertype( 0 ), numchildren( 0 ), + childList( 0 ) {} ~MultList(); - void setLevel(int); - bool contains(char *); - bool hit(char *); - void appendList(EntList *); - EntList *copyList(EntList *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + void setLevel( int ); + bool contains( char * ); + bool hit( char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - bool prevKnown(EntList *); + void unmarkAll( EntNode * ); + bool prevKnown( EntList * ); void reset(); protected: int supertype; ///< do I represent a supertype? int numchildren; - EntList *childList; + EntList * childList; /** \var childList * Points to a list of "children" of this EntList. E.g., if join = * AND, it would point to a list of the entity types we are AND'ing. @@ -326,55 +291,49 @@ class SC_CORE_EXPORT MultList : public EntList * A specialized MultList, super for subtypes AndOrList and AndList, or * ones which join their multiple children. */ -class SC_CORE_EXPORT JoinList : public MultList -{ +class SC_CORE_EXPORT JoinList : public MultList { public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - bool acceptChoice(EntNode *); + void setViableVal( EntNode * ); + bool acceptChoice( EntNode * ); }; -class SC_CORE_EXPORT AndOrList : public JoinList -{ +class SC_CORE_EXPORT AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class SC_CORE_EXPORT AndList : public JoinList -{ +class SC_CORE_EXPORT AndList : public JoinList { friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND) {} + AndList() : JoinList( AND ) {} ~AndList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class SC_CORE_EXPORT OrList : public MultList -{ +class SC_CORE_EXPORT OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-1), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -1 ), choiceCount( 0 ) {} ~OrList() {} - bool hit(char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - bool acceptChoice(EntNode *); - bool acceptNextChoice(EntNode *ents) - { + bool hit( char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + bool acceptChoice( EntNode * ); + bool acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -391,80 +350,71 @@ class SC_CORE_EXPORT OrList : public MultList * Contains the entire list of EntLists which describe the set of * instantiable complex entities defined by an EXPRESS expression. */ -class SC_CORE_EXPORT ComplexList -{ +class SC_CORE_EXPORT ComplexList { friend class ultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return (dynamic_cast< SimpleList * >(head->childList))->name ; + const char * supertype() { + return ( dynamic_cast< SimpleList * >(head->childList ))->name ; } /** \fn supertype * Based on knowledge that ComplexList always created by ANDing supertype * with subtypes. */ - bool toplevel(const char *); - bool contains(EntNode *); - bool matches(EntNode *); + bool toplevel( const char * ); + bool contains( EntNode * ); + bool matches( EntNode * ); - EntNode *list; /**< List of all entities contained in this complex type, + EntNode * list; /**< List of all entities contained in this complex type, * regardless of how. (Used as a quick way of determining * if this List *may* contain a certain complex type.) */ - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } private: - void addChildren(EntList *); - bool hitMultNodes(EntNode *); + void addChildren( EntList * ); + bool hitMultNodes( EntNode * ); int abstract; ///< is our supertype abstract? int dependent; ///< is our supertype also a subtype of other supertype(s)? bool multSupers; ///< am I a combo-CList created to test a subtype which has >1 supertypes? }; /// The collection of all the ComplexLists defined by the current schema. -class SC_CORE_EXPORT ComplexCollect -{ +class SC_CORE_EXPORT ComplexCollect { public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ~ComplexCollect() - { + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. - ComplexList *find(char *); - bool supports(EntNode *) const; + void insert( ComplexList * ); + void remove( ComplexList * ); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. + ComplexList * find( char * ); + bool supports( EntNode * ) const; - ComplexList *clists; + ComplexList * clists; private: int count; ///< # of clist children diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index e2cea3ee0..2fc289381 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -16,9 +16,8 @@ /** * Destructor for ComplexList. */ -ComplexList::~ComplexList() -{ - if(next) { +ComplexList::~ComplexList() { + if( next ) { delete next; } delete head; @@ -32,8 +31,7 @@ ComplexList::~ComplexList() * the supertypes' ComplexLists, this temp one can be deleted. Its sub- * structure, however, cannot be deleted since it's still being used. */ -void ComplexList::remove() -{ +void ComplexList::remove() { head = NULL; // Only the overall AND will be deleted. delete this; @@ -45,16 +43,15 @@ void ComplexList::remove() * is a highly specialized function which is used during the building of * a temporary CList to test entities which are subtypes of >1 supertype. */ -bool ComplexList::toplevel(const char *name) -{ - EntList *slist = head->childList; +bool ComplexList::toplevel( const char * name ) { + EntList * slist = head->childList; - while(slist) { - if(* dynamic_cast< SimpleList * >(slist) == name) { + while( slist ) { + if( * dynamic_cast< SimpleList * >(slist) == name ) { return true; } slist = slist->next; - if(slist) { + if( slist ) { slist = slist->next; } } @@ -69,21 +66,20 @@ bool ComplexList::toplevel(const char *name) * entity which contains an entity which is not contained in list, this * ComplexList certainly can't support it. */ -void ComplexList::buildList() -{ - EntList *sibling = head->childList->next; +void ComplexList::buildList() { + EntList * sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if(list) { + if( list ) { delete list; } // Add first node based on supertype: - list = new EntNode((dynamic_cast< SimpleList * >(head->childList))->name); + list = new EntNode( ( dynamic_cast< SimpleList * >(head->childList ))->name ); // Recursively add all descendents: - while(sibling) { - addChildren(sibling); + while( sibling ) { + addChildren( sibling ); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -96,33 +92,32 @@ void ComplexList::buildList() * Recursive function to add all the SimpleList descendents of ent into * this's list. */ -void ComplexList::addChildren(EntList *ent) -{ - EntList *child; - char *nm; - EntNode *prev = list, *prev2 = NULL, *newnode; +void ComplexList::addChildren( EntList * ent ) { + EntList * child; + char * nm; + EntNode * prev = list, *prev2 = NULL, *newnode; int comp = 0; - if(ent->multiple()) { - child = ((MultList *)ent)->childList; - while(child) { - addChildren(child); + if( ent->multiple() ) { + child = ( ( MultList * )ent )->childList; + while( child ) { + addChildren( child ); child = child->next; } } else { - nm = (dynamic_cast(ent))->name; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + nm = ( dynamic_cast(ent) )->name; + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -141,15 +136,14 @@ void ComplexList::addChildren(EntList *ent) * tion is simplified greatly because both EntNodes are ordered alphabeti- * cally. */ -bool ComplexList::contains(EntNode *ents) -{ - EntNode *ours = list, *theirs = ents; +bool ComplexList::contains( EntNode * ents ) { + EntNode * ours = list, *theirs = ents; - while(theirs != NULL) { - while(ours != NULL && *ours < *theirs) { + while( theirs != NULL ) { + while( ours != NULL && *ours < *theirs ) { ours = ours->next; } - if(ours == NULL || *ours > *theirs) { + if( ours == NULL || *ours > *theirs ) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return false; @@ -168,39 +162,38 @@ bool ComplexList::contains(EntNode *ents) * can be instantiated based on the list of EntLists which were generated * when the schema was read; false otherwise. */ -bool ComplexList::matches(EntNode *ents) -{ +bool ComplexList::matches( EntNode * ents ) { MatchType retval; int result = false; // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if(! contains(ents)) { + if( ! contains( ents ) ) { return false; } // Now start a thorough search through this ComplexList: - if((retval = head->matchNonORs(ents)) == MATCHALL) { + if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { result = true; - } else if(retval != UNKNOWN) { + } else if( retval != UNKNOWN ) { result = false; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if(((retval = head->matchORs(ents)) == MATCHALL) && - (hitMultNodes(ents))) { + if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && + ( hitMultNodes( ents ) ) ) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = true; - } else if(retval >= MATCHSOME) { + } else if( retval >= MATCHSOME ) { // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): MatchType otherChoices = NEWCHOICE; - while(otherChoices == NEWCHOICE) { - otherChoices = head->tryNext(ents); - if(otherChoices == MATCHALL) { - if(hitMultNodes(ents)) { + while( otherChoices == NEWCHOICE ) { + otherChoices = head->tryNext( ents ); + if( otherChoices == MATCHALL ) { + if( hitMultNodes( ents ) ) { result = true; } else { otherChoices = NEWCHOICE; @@ -229,36 +222,35 @@ bool ComplexList::matches(EntNode *ents) * valid. (This function is actually slightly more complicated because it * also deals with the possibility that >1 entities like C exist.) */ -bool ComplexList::hitMultNodes(EntNode *ents) -{ - EntNode *node; - EntList *child; +bool ComplexList::hitMultNodes( EntNode * ents ) { + EntNode * node; + EntList * child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if(!multSupers) { + if( !multSupers ) { return true; } - for(node = ents; node != NULL; node = node->next) { - if(node->multSuprs()) { + for( node = ents; node != NULL; node = node->next ) { + if( node->multSuprs() ) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while(child) { + while( child ) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if(child->contains(node->name)) { - if(! child->hit(node->name)) { + if( child->contains( node->name ) ) { + if( ! child->hit( node->name ) ) { return false; } } child = child->next; - if(child) { + if( child ) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 154e1be60..72f6adb53 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,42 +1,34 @@ #include "create_Aggr.h" #include -EnumAggregate *create_EnumAggregate() -{ +EnumAggregate * create_EnumAggregate() { return new EnumAggregate; } -GenericAggregate *create_GenericAggregate() -{ +GenericAggregate * create_GenericAggregate() { return new GenericAggregate; } -EntityAggregate *create_EntityAggregate() -{ +EntityAggregate * create_EntityAggregate() { return new EntityAggregate; } -SelectAggregate *create_SelectAggregate() -{ +SelectAggregate * create_SelectAggregate() { return new SelectAggregate; } -StringAggregate *create_StringAggregate() -{ +StringAggregate * create_StringAggregate() { return new StringAggregate; } -BinaryAggregate *create_BinaryAggregate() -{ +BinaryAggregate * create_BinaryAggregate() { return new BinaryAggregate; } -RealAggregate *create_RealAggregate() -{ +RealAggregate * create_RealAggregate() { return new RealAggregate; } -IntAggregate *create_IntAggregate() -{ +IntAggregate * create_IntAggregate() { return new IntAggregate; } diff --git a/src/clstepcore/create_Aggr.h b/src/clstepcore/create_Aggr.h index 61918e06a..a0483fa66 100644 --- a/src/clstepcore/create_Aggr.h +++ b/src/clstepcore/create_Aggr.h @@ -17,32 +17,32 @@ class BinaryAggregate; class RealAggregate; class IntAggregate; -typedef STEPaggregate *(* AggregateCreator)(); -typedef EnumAggregate *(* EnumAggregateCreator)(); -typedef GenericAggregate *(* GenericAggregateCreator)(); -typedef EntityAggregate *(* EntityAggregateCreator)(); -typedef SelectAggregate *(* SelectAggregateCreator)(); -typedef StringAggregate *(* StringAggregateCreator)(); -typedef BinaryAggregate *(* BinaryAggregateCreator)(); -typedef RealAggregate *(* RealAggregateCreator)(); -typedef IntAggregate *(* IntAggregateCreator)(); +typedef STEPaggregate * ( * AggregateCreator )(); +typedef EnumAggregate * ( * EnumAggregateCreator )(); +typedef GenericAggregate * ( * GenericAggregateCreator )(); +typedef EntityAggregate * ( * EntityAggregateCreator )(); +typedef SelectAggregate * ( * SelectAggregateCreator )(); +typedef StringAggregate * ( * StringAggregateCreator )(); +typedef BinaryAggregate * ( * BinaryAggregateCreator )(); +typedef RealAggregate * ( * RealAggregateCreator )(); +typedef IntAggregate * ( * IntAggregateCreator )(); -SC_CORE_EXPORT EnumAggregate *create_EnumAggregate(); +SC_CORE_EXPORT EnumAggregate * create_EnumAggregate(); -SC_CORE_EXPORT GenericAggregate *create_GenericAggregate(); +SC_CORE_EXPORT GenericAggregate * create_GenericAggregate(); -SC_CORE_EXPORT EntityAggregate *create_EntityAggregate(); +SC_CORE_EXPORT EntityAggregate * create_EntityAggregate(); -SC_CORE_EXPORT SelectAggregate *create_SelectAggregate(); +SC_CORE_EXPORT SelectAggregate * create_SelectAggregate(); -SC_CORE_EXPORT StringAggregate *create_StringAggregate(); +SC_CORE_EXPORT StringAggregate * create_StringAggregate(); -SC_CORE_EXPORT BinaryAggregate *create_BinaryAggregate(); +SC_CORE_EXPORT BinaryAggregate * create_BinaryAggregate(); -SC_CORE_EXPORT RealAggregate *create_RealAggregate(); +SC_CORE_EXPORT RealAggregate * create_RealAggregate(); -SC_CORE_EXPORT IntAggregate *create_IntAggregate(); +SC_CORE_EXPORT IntAggregate * create_IntAggregate(); -typedef SDAI_Integer(*boundCallbackFn)(SDAI_Application_instance *); +typedef SDAI_Integer( *boundCallbackFn )( SDAI_Application_instance * ); #endif //AGGRCREATORTD_H diff --git a/src/clstepcore/derivedAttribute.cc b/src/clstepcore/derivedAttribute.cc index 194f95471..7fca3b16f 100644 --- a/src/clstepcore/derivedAttribute.cc +++ b/src/clstepcore/derivedAttribute.cc @@ -1,33 +1,30 @@ #include "derivedAttribute.h" -Derived_attribute::Derived_attribute(const char *name, const TypeDescriptor *domainType, - Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor &owner) - : AttrDescriptor(name, domainType, optional, unique, at, owner) -{ - _initializer = (const char *)0; +Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType, + Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner ) + : AttrDescriptor( name, domainType, optional, unique, at, owner ) { + _initializer = ( const char * )0; } -Derived_attribute::~Derived_attribute() -{ +Derived_attribute::~Derived_attribute() { } -const char *Derived_attribute::AttrExprDefStr(std::string &s) const -{ +const char * Derived_attribute::AttrExprDefStr( std::string & s ) const { std::string buf; s.clear(); - if(Name() && strchr(Name(), '.')) { + if( Name() && strchr( Name(), '.' ) ) { s = "SELF\\"; } - s.append(Name()); - s.append(" : "); - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + s.append( Name() ); + s.append( " : " ); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - if(_initializer) { // this is supposed to exist for a derived attribute. - s.append(" \n\t\t:= "); - s.append(_initializer); + if( _initializer ) { // this is supposed to exist for a derived attribute. + s.append( " \n\t\t:= " ); + s.append( _initializer ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } diff --git a/src/clstepcore/derivedAttribute.h b/src/clstepcore/derivedAttribute.h index d894e3ede..234521a07 100644 --- a/src/clstepcore/derivedAttribute.h +++ b/src/clstepcore/derivedAttribute.h @@ -5,29 +5,26 @@ #include "sc_export.h" -class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor -{ +class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor { public: - const char *_initializer; + const char * _initializer; Derived_attribute( - const char *name, // i.e. char * - const TypeDescriptor *domainType, + const char * name, // i.e. char * + const TypeDescriptor * domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor &owner + const EntityDescriptor & owner ); virtual ~Derived_attribute(); - const char *AttrExprDefStr(std::string &s) const; + const char * AttrExprDefStr( std::string & s ) const; - const char *initializer_() - { + const char * initializer_() { return _initializer; } - void initializer_(const char *i) - { + void initializer_( const char * i ) { _initializer = i; } }; diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 2889e2117..11170d4df 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -3,52 +3,47 @@ #include "typeDescriptor.h" #include "entityDescriptor.h" -Schema::Schema(const char *schemaName) - : _use_interface_list(new Interface_spec__set), - _ref_interface_list(new Interface_spec__set), - _function_list(0), _procedure_list(0), _global_rules(0) -{ +Schema::Schema( const char * schemaName ) +: _use_interface_list( new Interface_spec__set ), +_ref_interface_list( new Interface_spec__set ), +_function_list( 0 ), _procedure_list( 0 ), _global_rules( 0 ) { _name = schemaName; } -Schema::~Schema() -{ - TypeDescLinkNode *node; +Schema::~Schema() { + TypeDescLinkNode * node; - if(_use_interface_list != 0) { + if( _use_interface_list != 0 ) { delete _use_interface_list; } - if(_ref_interface_list != 0) { + if( _ref_interface_list != 0 ) { delete _ref_interface_list; } - if(_global_rules != 0) { + if( _global_rules != 0 ) { delete _global_rules; } - node = (TypeDescLinkNode *) _unnamed_typeList.GetHead(); - while(node) { + node = ( TypeDescLinkNode * ) _unnamed_typeList.GetHead(); + while( node ) { delete node->TypeDesc(); - node = (TypeDescLinkNode *) node->NextNode(); + node = ( TypeDescLinkNode * ) node->NextNode(); } } -void Schema::AddFunction(const std::string &f) -{ - _function_list.push_back(f); +void Schema::AddFunction( const std::string & f ) { + _function_list.push_back( f ); } -void Schema::AddGlobal_rule(Global_rule_ptr gr) -{ - if(_global_rules == 0) { +void Schema::AddGlobal_rule( Global_rule_ptr gr ) { + if( _global_rules == 0 ) { _global_rules = new Global_rule__set; } - _global_rules->Append(gr); + _global_rules->Append( gr ); } /// hope I did this right (MP) - was "not implemented" -void Schema::global_rules_(Global_rule__set_var &grs) -{ - if(_global_rules) { - if(_global_rules->Count() > 0) { +void Schema::global_rules_( Global_rule__set_var & grs ) { + if( _global_rules ) { + if( _global_rules->Count() > 0 ) { std::cerr << "In " << __FILE__ << ", Schema::global_rules_(): overwriting non-empty global rule set!" << std::endl; } delete _global_rules; @@ -56,45 +51,43 @@ void Schema::global_rules_(Global_rule__set_var &grs) _global_rules = grs; } -void Schema::AddProcedure(const std::string &p) -{ - _procedure_list.push_back(p); +void Schema::AddProcedure( const std::string & p ) { + _procedure_list.push_back( p ); } /// the whole schema -void Schema::GenerateExpress(ostream &out) const -{ +void Schema::GenerateExpress( ostream & out ) const { std::string tmp; out << endl << "(* Generating: " << Name() << " *)" << endl; - out << endl << "SCHEMA " << StrToLower(Name(), tmp) << ";" << endl; - GenerateUseRefExpress(out); + out << endl << "SCHEMA " << StrToLower( Name(), tmp ) << ";" << endl; + GenerateUseRefExpress( out ); // print TYPE definitions out << endl << "(* ////////////// TYPE Definitions *)" << endl; - GenerateTypesExpress(out); + GenerateTypesExpress( out ); // print Entity definitions out << endl << "(* ////////////// ENTITY Definitions *)" << endl; - GenerateEntitiesExpress(out); + GenerateEntitiesExpress( out ); int count, i; - if(_global_rules != 0) { + if( _global_rules != 0 ) { out << endl << "(* *************RULES************* *)" << endl; count = _global_rules->Count(); - for(i = 0; i < count; i++) { - out << endl << (*_global_rules)[i]->rule_text_() << endl; + for( i = 0; i < count; i++ ) { + out << endl << ( *_global_rules )[i]->rule_text_() << endl; } } - if(!_function_list.empty()) { + if( !_function_list.empty() ) { out << "(* *************FUNCTIONS************* *)" << endl; count = _function_list.size(); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { out << endl << _function_list[i] << endl; } } - if(!_procedure_list.empty()) { + if( !_procedure_list.empty() ) { out << "(* *************PROCEDURES************* *)" << endl; count = _procedure_list.size(); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { out << endl << _procedure_list[i] << endl; } } @@ -102,8 +95,7 @@ void Schema::GenerateExpress(ostream &out) const } /// USE, REFERENCE definitions -void Schema::GenerateUseRefExpress(ostream &out) const -{ +void Schema::GenerateUseRefExpress( ostream & out ) const { int i, k; int intf_count; int count; @@ -114,38 +106,38 @@ void Schema::GenerateUseRefExpress(ostream &out) const /////////////////////// print USE statements intf_count = _use_interface_list->Count(); - if(intf_count) { // there is at least 1 USE interface to a foreign schema - for(i = 0; i < intf_count; i++) { // print out each USE interface - is = (*_use_interface_list)[i]; // the 1st USE interface + if( intf_count ) { // there is at least 1 USE interface to a foreign schema + for( i = 0; i < intf_count; i++ ) { // print out each USE interface + is = ( *_use_interface_list )[i]; // the 1st USE interface // count is # of USE items in interface count = is->explicit_items_()->Count(); - if(count > 0) { + if( count > 0 ) { out << endl << " USE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; out << " ("; first_time = 1; - for(k = 0; k < count; k++) { // print out each USE item - if(first_time) { + for( k = 0; k < count; k++ ) { // print out each USE item + if( first_time ) { first_time = 0; } else { out << "," << endl << "\t"; } - if(!((*(is->explicit_items_()))[k]->original_id_().size())) { + if( !( ( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { // not renamed - out << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->new_id_(); } else { // renamed - out << (*(is->explicit_items_()))[k]->original_id_(); - out << " AS " << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->original_id_(); + out << " AS " << ( *( is->explicit_items_() ) )[k]->new_id_(); } } out << ");" << endl; - } else if(is->all_objects_()) { + } else if( is->all_objects_() ) { out << endl << " USE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" - << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" + << endl; } } } @@ -153,69 +145,67 @@ void Schema::GenerateUseRefExpress(ostream &out) const /////////////////////// print REFERENCE stmts intf_count = _ref_interface_list->Count(); - if(intf_count) { //there is at least 1 REFERENCE interface to a foreign schema - for(i = 0; i < intf_count; i++) { // print out each REFERENCE interface - is = (*_ref_interface_list)[i]; // the 1st REFERENCE interface + if( intf_count ) { //there is at least 1 REFERENCE interface to a foreign schema + for( i = 0; i < intf_count; i++ ) { // print out each REFERENCE interface + is = ( *_ref_interface_list )[i]; // the 1st REFERENCE interface // count is # of REFERENCE items in interface count = is->explicit_items_()->Count(); - if(count > 0) { + if( count > 0 ) { out << endl << " REFERENCE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; out << " ("; first_time = 1; - for(k = 0; k < count; k++) { // print out each REFERENCE item - if(first_time) { + for( k = 0; k < count; k++ ) { // print out each REFERENCE item + if( first_time ) { first_time = 0; } else { out << "," << endl << "\t"; } - if((!(*(is->explicit_items_()))[k]->original_id_().size())) { + if( ( !( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { // not renamed - out << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->new_id_(); } else { // renamed - out << (*(is->explicit_items_()))[k]->original_id_(); + out << ( *( is->explicit_items_() ) )[k]->original_id_(); out << " AS " - << (*(is->explicit_items_()))[k]->new_id_(); + << ( *( is->explicit_items_() ) )[k]->new_id_(); } } out << ");" << endl; - } else if(is->all_objects_()) { + } else if( is->all_objects_() ) { out << endl << " REFERENCE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" - << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" + << endl; } } } } /// TYPE definitions -void Schema::GenerateTypesExpress(ostream &out) const -{ - TypeDescItr tdi(_typeList); +void Schema::GenerateTypesExpress( ostream & out ) const { + TypeDescItr tdi( _typeList ); tdi.ResetItr(); std::string tmp; - const TypeDescriptor *td = tdi.NextTypeDesc(); - while(td) { - out << endl << td->GenerateExpress(tmp); + const TypeDescriptor * td = tdi.NextTypeDesc(); + while( td ) { + out << endl << td->GenerateExpress( tmp ); td = tdi.NextTypeDesc(); } } /// Entity definitions -void Schema::GenerateEntitiesExpress(ostream &out) const -{ - EntityDescItr edi(_entList); +void Schema::GenerateEntitiesExpress( ostream & out ) const { + EntityDescItr edi( _entList ); edi.ResetItr(); std::string tmp; - const EntityDescriptor *ed = edi.NextEntityDesc(); - while(ed) { - out << endl << ed->GenerateExpress(tmp); + const EntityDescriptor * ed = edi.NextEntityDesc(); + while( ed ) { + out << endl << ed->GenerateExpress( tmp ); ed = edi.NextEntityDesc(); } } diff --git a/src/clstepcore/dictSchema.h b/src/clstepcore/dictSchema.h index 1617703e3..96977f98e 100644 --- a/src/clstepcore/dictSchema.h +++ b/src/clstepcore/dictSchema.h @@ -9,159 +9,137 @@ #include "dictionaryInstance.h" -typedef SDAI_Model_contents_ptr(* ModelContentsCreator)(); +typedef SDAI_Model_contents_ptr( * ModelContentsCreator )(); /** * \class Schema (was SchemaDescriptor) - a class of this type is generated and contains schema info. */ -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) - - // non-SDAI lists - Interface_spec__set_var _use_interface_list; // list of USE interfaces - Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces +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) + + // non-SDAI lists + Interface_spec__set_var _use_interface_list; // list of USE interfaces + Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::vector< std::string > _function_list; // of EXPRESS functions - std::vector< std::string > _procedure_list; // of EXPRESS procedures + std::vector< std::string > _function_list; // of EXPRESS functions + std::vector< std::string > _procedure_list; // of EXPRESS procedures #ifdef _MSC_VER #pragma warning( pop ) #endif - Global_rule__set_var _global_rules; - - public: - ModelContentsCreator CreateNewModelContents; - - Schema(const char *schemaName); - virtual ~Schema(); - - void AssignModelContentsCreator(ModelContentsCreator f = 0) - { - CreateNewModelContents = f; - } - - const char *Name() const - { - return _name; - } - void Name(const char *n) - { - _name = n; - } - - Interface_spec &interface_() - { - return _interface; - } - - Interface_spec__set_var use_interface_list_() - { - return - _use_interface_list; - } - - Interface_spec__set_var ref_interface_list_() - { - return _ref_interface_list; - } - - std::vector< std::string > function_list_() - { - return _function_list; - } - - void AddFunction(const std::string &f); - - Global_rule__set_var global_rules_() // const - { - return _global_rules; - } - - void AddGlobal_rule(Global_rule_ptr gr); - - void global_rules_(Global_rule__set_var &grs); // not implemented - - std::vector< std::string > procedure_list_() - { - return _procedure_list; - } - - void AddProcedure(const std::string &p); - - 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; - - // USE, REFERENCE definitions - void GenerateUseRefExpress(ostream &out) const; - - // TYPE definitions - void GenerateTypesExpress(ostream &out) const; - - // Entity definitions - void GenerateEntitiesExpress(ostream &out) const; + Global_rule__set_var _global_rules; + +public: + ModelContentsCreator CreateNewModelContents; + + Schema( const char * schemaName ); + virtual ~Schema(); + + void AssignModelContentsCreator( ModelContentsCreator f = 0 ) { + CreateNewModelContents = f; + } + + const char * Name() const { + return _name; + } + void Name( const char * n ) { + _name = n; + } + + Interface_spec & interface_() { + return _interface; + } + + Interface_spec__set_var use_interface_list_() { + return + _use_interface_list; + } + + Interface_spec__set_var ref_interface_list_() { + return _ref_interface_list; + } + + std::vector< std::string > function_list_() { + return _function_list; + } + + void AddFunction( const std::string & f ); + + Global_rule__set_var global_rules_() { // const + return _global_rules; + } + + void AddGlobal_rule( Global_rule_ptr gr ); + + void global_rules_( Global_rule__set_var & grs ); // not implemented + + std::vector< std::string > procedure_list_() { + return _procedure_list; + } + + void AddProcedure( const std::string & p ); + + 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; + + // USE, REFERENCE definitions + void GenerateUseRefExpress( ostream & out ) const; + + // TYPE definitions + void GenerateTypesExpress( ostream & out ) const; + + // Entity definitions + void GenerateEntitiesExpress( ostream & out ) const; }; typedef Schema SchemaDescriptor; diff --git a/src/clstepcore/dictdefs.h b/src/clstepcore/dictdefs.h index 0a6c8f241..1dbb7cdf9 100644 --- a/src/clstepcore/dictdefs.h +++ b/src/clstepcore/dictdefs.h @@ -29,37 +29,37 @@ class TypeDescriptorList; // currently commented out. FIXME The underlying class names should be updated // when the new dictionary is integrated. DAS -typedef class Schema *Schema_ptr; +typedef class Schema * Schema_ptr; typedef Schema_ptr Schema_var; -typedef class EntityDescriptor *Entity_ptr; +typedef class EntityDescriptor * Entity_ptr; typedef Entity_ptr Entity_var; -typedef class AttrDescriptor *Attribute_ptr; +typedef class AttrDescriptor * Attribute_ptr; typedef Attribute_ptr Attribute_var; -typedef class Derived_attribute *Derived_attribute_ptr; +typedef class Derived_attribute * Derived_attribute_ptr; typedef Derived_attribute_ptr Derived_attribute_var; -typedef class AttrDescriptor *Explicit_attribute_ptr; +typedef class AttrDescriptor * Explicit_attribute_ptr; typedef Explicit_attribute_ptr Explicit_attribute_var; -typedef Inverse_attribute *Inverse_attribute_ptr; +typedef Inverse_attribute * Inverse_attribute_ptr; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute InverseAttrDescriptor; -typedef class EnumTypeDescriptor *Enumeration_type_ptr; +typedef class EnumTypeDescriptor * Enumeration_type_ptr; typedef Enumeration_type_ptr Enumeration_type_var; -typedef class SelectTypeDescriptor *Select_type_ptr; +typedef class SelectTypeDescriptor * Select_type_ptr; typedef Select_type_ptr Select_type_var; -typedef class RealTypeDescriptor *Real_type_ptr; +typedef class RealTypeDescriptor * Real_type_ptr; typedef Real_type_ptr Real_type_var; -typedef class StringTypeDescriptor *String_type_ptr; +typedef class StringTypeDescriptor * String_type_ptr; typedef String_type_ptr String_type_var; -typedef class AggrTypeDescriptor *Aggr_type_ptr; +typedef class AggrTypeDescriptor * Aggr_type_ptr; typedef Aggr_type_ptr Aggr_type_var; -typedef class SetTypeDescriptor *Set_type_ptr; +typedef class SetTypeDescriptor * Set_type_ptr; typedef Set_type_ptr Set_type_var; -typedef class BagTypeDescriptor *Bag_type_ptr; +typedef class BagTypeDescriptor * Bag_type_ptr; typedef Bag_type_ptr Bag_type_var; -typedef class ListTypeDescriptor *List_type_ptr; +typedef class ListTypeDescriptor * List_type_ptr; typedef List_type_ptr List_type_var; -typedef class ArrayTypeDescriptor *Array_type_ptr; +typedef class ArrayTypeDescriptor * Array_type_ptr; typedef Array_type_ptr Array_type_var; // the following exist until everything is updated diff --git a/src/clstepcore/dictionaryInstance.h b/src/clstepcore/dictionaryInstance.h index 34fceee89..ac8734c68 100644 --- a/src/clstepcore/dictionaryInstance.h +++ b/src/clstepcore/dictionaryInstance.h @@ -3,14 +3,13 @@ #include "sc_export.h" -class SC_CORE_EXPORT Dictionary_instance -{ +class SC_CORE_EXPORT Dictionary_instance { - protected: - Dictionary_instance() {} - Dictionary_instance(const Dictionary_instance &) {} +protected: + Dictionary_instance() {} + Dictionary_instance( const Dictionary_instance & ) {} - virtual ~Dictionary_instance() {}; + virtual ~Dictionary_instance() {}; }; diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 903ba086d..2590e034c 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -29,32 +29,28 @@ class StepEntityEditor; // 2) delete the StepEntityEditor window // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); -DisplayNode::~DisplayNode() -{ +DisplayNode::~DisplayNode() { Remove(); - if(see) { - DeleteSEE((StepEntityEditor *)see); + if( see ) { + DeleteSEE( ( StepEntityEditor * )see ); //DAS PORT need the cast from void* DeleteSEE(see); } } -void DisplayNode::Remove() -{ +void DisplayNode::Remove() { GenericNode::Remove(); // DON'T DO THIS!! displayState = noMapState; } -int DisplayNode::ChangeState(displayStateEnum s) -{ +int DisplayNode::ChangeState( displayStateEnum s ) { displayState = s; return 1; } -int DisplayNode::ChangeList(DisplayNodeList *cmdList) -{ +int DisplayNode::ChangeList( DisplayNodeList * cmdList ) { Remove(); - cmdList->Append(this); + cmdList->Append( this ); return 1; } diff --git a/src/clstepcore/dispnode.h b/src/clstepcore/dispnode.h index 9e2ca5b7f..1209b9c3e 100644 --- a/src/clstepcore/dispnode.h +++ b/src/clstepcore/dispnode.h @@ -32,58 +32,49 @@ class MgrNode; // class DisplayNode ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNode : public GenericNode -{ +class SC_CORE_EXPORT DisplayNode : public GenericNode { protected: friend class GenNodeList; friend class DisplayNodeList; - MgrNode *mn; - void *see; + MgrNode * mn; + void * see; displayStateEnum displayState; // = { mappedWrite, mappedView, notMapped } public: // this should probably only be used to create head nodes for dispnodelists - DisplayNode() - { + DisplayNode() { displayState = noMapState; } - DisplayNode(MgrNode *node) - { + DisplayNode( MgrNode * node ) { mn = node; displayState = noMapState; } ~DisplayNode(); - void SEE(void *s) - { + void SEE( void * s ) { see = s; } - virtual void *SEE() - { + virtual void * SEE() { return see; } - void mgrNode(MgrNode *node) - { + void mgrNode( MgrNode * node ) { mn = node; } - class MgrNode *mgrNode() - { + class MgrNode * mgrNode() { return mn; } - displayStateEnum DisplayState() - { + displayStateEnum DisplayState() { return displayState; } - int DisplayListMember(displayStateEnum ds) - { - return (displayState == ds); + int DisplayListMember( displayStateEnum ds ) { + return ( displayState == ds ); } - int ChangeState(displayStateEnum s); - int ChangeList(DisplayNodeList *cmdList); + int ChangeState( displayStateEnum s ); + int ChangeList( DisplayNodeList * cmdList ); void Remove(); diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index 0aad7885c..f4d00a6aa 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -21,40 +21,36 @@ #include #include "sc_memmgr.h" -void DisplayNodeList::Remove(GenericNode *node) -{ - GenNodeList::Remove(node); +void DisplayNodeList::Remove( GenericNode * node ) { + GenNodeList::Remove( node ); // DON'T DO THIS ((DisplayNode *)node)->displayState = noMapState; } // deletes node from its previous list & appends // actually it puts it at the front of the list. -void DisplayNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void DisplayNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } // deletes newNode from its previous list & inserts after // existNode -void DisplayNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void DisplayNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertAfter(newNode, existNode); + GenNodeList::InsertAfter( newNode, existNode ); // DON'T DO THIS ((DisplayNode *)newNode)->displayState = listType; } // deletes newNode from its previous list & inserts before // existNode -void DisplayNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void DisplayNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertBefore(newNode, existNode); + GenNodeList::InsertBefore( newNode, existNode ); // DON'T DO THIS!!! ((DisplayNode *)newNode)->displayState = listType; } diff --git a/src/clstepcore/dispnodelist.h b/src/clstepcore/dispnodelist.h index a621e657e..c4fe4dde3 100644 --- a/src/clstepcore/dispnodelist.h +++ b/src/clstepcore/dispnodelist.h @@ -29,26 +29,24 @@ // This will be used to represent the display state lists. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNodeList : public GenNodeList -{ +class SC_CORE_EXPORT DisplayNodeList : public GenNodeList { public: - DisplayNodeList(displayStateEnum type); + DisplayNodeList( displayStateEnum type ); ~DisplayNodeList() { } // ADDED functions - displayStateEnum GetState() - { + displayStateEnum GetState() { return listType; } // REDEFINED functions // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); - virtual void Remove(GenericNode *node); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); + virtual void Remove( GenericNode * node ); protected: private: @@ -61,11 +59,10 @@ class SC_CORE_EXPORT DisplayNodeList : public GenNodeList // other classes) that aren't in this file except for Generic functions ////////////////////////////////////////////////////////////////////////////// -inline DisplayNodeList::DisplayNodeList(displayStateEnum type) - : GenNodeList(new DisplayNode()) -{ +inline DisplayNodeList::DisplayNodeList( displayStateEnum type ) + : GenNodeList( new DisplayNode() ) { listType = type; - ((DisplayNode *)head)->displayState = type; + ( ( DisplayNode * )head )->displayState = type; } #endif diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 2711c05f6..0e58c4db6 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -6,49 +6,45 @@ #include "inverseAttribute.h" #include "SubSuperIterators.h" -EntityDescriptor::EntityDescriptor() - : _abstractEntity(LUnknown), _extMapping(LUnknown), - _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(0) -{ +EntityDescriptor::EntityDescriptor( ) + : _abstractEntity( LUnknown ), _extMapping( LUnknown ), + _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( 0 ) { } -EntityDescriptor::EntityDescriptor(const char *name, // i.e. char * - Schema *origSchema, - Logical abstractEntity, // F U or T - Logical extMapping, - Creator f +EntityDescriptor::EntityDescriptor( const char * name, // i.e. char * + Schema * origSchema, + Logical abstractEntity, // F U or T + Logical extMapping, + Creator f ) - : TypeDescriptor(name, ENTITY_TYPE, origSchema, name), - _abstractEntity(abstractEntity), _extMapping(extMapping), - _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(f) -{ + : TypeDescriptor( name, ENTITY_TYPE, origSchema, name ), + _abstractEntity( abstractEntity ), _extMapping( extMapping ), + _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( f ) { } -EntityDescriptor::~EntityDescriptor() -{ +EntityDescriptor::~EntityDescriptor() { delete _uniqueness_rules; } // initialize one inverse attr; used in InitIAttrs, below -void initIAttr(Inverse_attribute *ia, Registry ®, 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); +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); + 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; } } @@ -63,62 +59,60 @@ void initIAttr(Inverse_attribute *ia, Registry ®, const char *schNm, const ch * must be called _after_ init_Sdai* functions for any ia->inverted_entity_id_'s * */ -void EntityDescriptor::InitIAttrs(Registry ®, const char *schNm) -{ - InverseAItr iai(&(InverseAttr())); - Inverse_attribute *ia; - while(0 != (ia = iai.NextInverse_attribute())) { - initIAttr(ia, reg, schNm, _name); +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 -{ +const char * EntityDescriptor::GenerateExpress( std::string & buf ) const { std::string sstr; int count; int i; int all_comments = 1; buf = "ENTITY "; - buf.append(StrToLower(Name(), sstr)); + buf.append( StrToLower( Name(), sstr ) ); - if(strlen(_supertype_stmt.c_str()) > 0) { - buf.append("\n "); + if( strlen( _supertype_stmt.c_str() ) > 0 ) { + buf.append( "\n " ); } - buf.append(_supertype_stmt); + buf.append( _supertype_stmt ); - const EntityDescriptor *ed = 0; + const EntityDescriptor * ed = 0; - EntityDescItr edi_super(_supertypes); + EntityDescItr edi_super( _supertypes ); edi_super.ResetItr(); ed = edi_super.NextEntityDesc(); int supertypes = 0; - if(ed) { - buf.append("\n SUBTYPE OF ("); - buf.append(StrToLower(ed->Name(), sstr)); + if( ed ) { + buf.append( "\n SUBTYPE OF (" ); + buf.append( StrToLower( ed->Name(), sstr ) ); supertypes = 1; } ed = edi_super.NextEntityDesc(); - while(ed) { - buf.append(",\n\t\t"); - buf.append(StrToLower(ed->Name(), sstr)); + while( ed ) { + buf.append( ",\n\t\t" ); + buf.append( StrToLower( ed->Name(), sstr ) ); ed = edi_super.NextEntityDesc(); } - if(supertypes) { - buf.append(")"); + if( supertypes ) { + buf.append( ")" ); } - buf.append(";\n"); + buf.append( ";\n" ); - AttrDescItr adi(_explicitAttr); + AttrDescItr adi( _explicitAttr ); adi.ResetItr(); - const AttrDescriptor *ad = adi.NextAttrDesc(); + const AttrDescriptor * ad = adi.NextAttrDesc(); - while(ad) { - if(ad->AttrType() == AttrType_Explicit) { - buf.append(" "); - buf.append(ad->GenerateExpress(sstr)); + while( ad ) { + if( ad->AttrType() == AttrType_Explicit ) { + buf.append( " " ); + buf.append( ad->GenerateExpress( sstr ) ); } ad = adi.NextAttrDesc(); } @@ -127,139 +121,136 @@ const char *EntityDescriptor::GenerateExpress(std::string &buf) const ad = adi.NextAttrDesc(); count = 1; - while(ad) { - if(ad->AttrType() == AttrType_Deriving) { - if(count == 1) { - buf.append(" DERIVE\n"); + while( ad ) { + if( ad->AttrType() == AttrType_Deriving ) { + if( count == 1 ) { + buf.append( " DERIVE\n" ); } - buf.append(" "); - buf.append(ad->GenerateExpress(sstr)); + buf.append( " " ); + buf.append( ad->GenerateExpress( sstr ) ); count++; } ad = adi.NextAttrDesc(); } ///////// - InverseAItr iai(&_inverseAttr); + InverseAItr iai( &_inverseAttr ); iai.ResetItr(); - const Inverse_attribute *ia = iai.NextInverse_attribute(); + const Inverse_attribute * ia = iai.NextInverse_attribute(); - if(ia) { - buf.append(" INVERSE\n"); + if( ia ) { + buf.append( " INVERSE\n" ); } - while(ia) { - buf.append(" "); - buf.append(ia->GenerateExpress(sstr)); + while( ia ) { + buf.append( " " ); + buf.append( ia->GenerateExpress( sstr ) ); ia = iai.NextInverse_attribute(); } /////////////// // count is # of UNIQUE rules - if(_uniqueness_rules != 0) { + if( _uniqueness_rules != 0 ) { count = _uniqueness_rules->Count(); - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_uniqueness_rules))[i]->_label.size()) { + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _uniqueness_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* UNIQUE *)\n"); + if( all_comments ) { + buf.append( " (* UNIQUE *)\n" ); } else { - buf.append(" UNIQUE\n"); + buf.append( " UNIQUE\n" ); } - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_uniqueness_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_uniqueness_rules))[i]->comment_()); - buf.append("\n"); + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _uniqueness_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _uniqueness_rules ) )[i]->comment_() ); + buf.append( "\n" ); } - if((*(_uniqueness_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_uniqueness_rules))[i]->label_()); - buf.append("\n"); + if( ( *( _uniqueness_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _uniqueness_rules ) )[i]->label_() ); + buf.append( "\n" ); } } } /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { all_comments = 1; count = _where_rules->Count(); - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(!all_comments) { - buf.append(" WHERE\n"); + if( !all_comments ) { + buf.append( " WHERE\n" ); } else { - buf.append(" (* WHERE *)\n"); + buf.append( " (* WHERE *)\n" ); } - for(i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); - buf.append("\n"); + for( i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); + buf.append( "\n" ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); - buf.append("\n"); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); + buf.append( "\n" ); } } } - buf.append("END_ENTITY;\n"); + buf.append( "END_ENTITY;\n" ); - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } -const char *EntityDescriptor::QualifiedName(std::string &s) const -{ +const char * EntityDescriptor::QualifiedName( std::string & s ) const { s.clear(); - EntityDescItr edi(_supertypes); + EntityDescItr edi( _supertypes ); int count = 1; - const EntityDescriptor *ed = edi.NextEntityDesc(); - while(ed) { - if(count > 1) { - s.append("&"); + const EntityDescriptor * ed = edi.NextEntityDesc(); + while( ed ) { + if( count > 1 ) { + s.append( "&" ); } - s.append(ed->Name()); + s.append( ed->Name() ); count++; ed = edi.NextEntityDesc(); } - if(count > 1) { - s.append("&"); + if( count > 1 ) { + s.append( "&" ); } - s.append(Name()); - return const_cast(s.c_str()); + s.append( Name() ); + return const_cast( s.c_str() ); } -const TypeDescriptor *EntityDescriptor::IsA(const TypeDescriptor *td) const -{ - if(td -> NonRefType() == ENTITY_TYPE) { - return IsA((EntityDescriptor *) td); +const TypeDescriptor * EntityDescriptor::IsA( const TypeDescriptor * td ) const { + if( td -> NonRefType() == ENTITY_TYPE ) { + return IsA( ( EntityDescriptor * ) td ); } else { return 0; } } -const EntityDescriptor *EntityDescriptor::IsA(const EntityDescriptor *other) const -{ - const EntityDescriptor *found = 0; - const EntityDescLinkNode *link = (const EntityDescLinkNode *)(GetSupertypes().GetHead()); +const EntityDescriptor * EntityDescriptor::IsA( const EntityDescriptor * other ) const { + const EntityDescriptor * found = 0; + const EntityDescLinkNode * link = ( const EntityDescLinkNode * )( GetSupertypes().GetHead() ); - if(this == other) { + if( this == other ) { return other; } else { - while(link && ! found) { - found = link -> EntityDesc() -> IsA(other); - link = (EntityDescLinkNode *) link -> NextNode(); + while( link && ! found ) { + found = link -> EntityDesc() -> IsA( other ); + link = ( EntityDescLinkNode * ) link -> NextNode(); } } return found; diff --git a/src/clstepcore/entityDescriptor.h b/src/clstepcore/entityDescriptor.h index 1510fe6a8..e0bd25ec8 100644 --- a/src/clstepcore/entityDescriptor.h +++ b/src/clstepcore/entityDescriptor.h @@ -9,7 +9,7 @@ #include "sc_export.h" -typedef SDAI_Application_instance *(* Creator)(); +typedef SDAI_Application_instance * ( * Creator )(); class Registry; @@ -22,8 +22,7 @@ class Registry; * will be building the same thing but using the new schema info. * nodes (i.e. EntityDesc nodes) for each entity. */ -class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor { protected: @@ -42,137 +41,113 @@ class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor #ifdef _MSC_VER #pragma warning( pop ) #endif - public: + public: Uniqueness_rule__set_var _uniqueness_rules; // initially a null pointer // pointer to a function that will create a new instance of a SDAI_Application_instance Creator NewSTEPentity; - EntityDescriptor(); - EntityDescriptor(const char *name, // i.e. char * - Schema *origSchema, - Logical abstractEntity, // i.e. F U or T - Logical extMapping, - Creator f = 0 + EntityDescriptor( ); + EntityDescriptor( const char * name, // i.e. char * + Schema * origSchema, + Logical abstractEntity, // i.e. F U or T + Logical extMapping, + Creator f = 0 ); virtual ~EntityDescriptor(); - void InitIAttrs(Registry ®, const char *schNm); + void InitIAttrs( Registry & reg, const char * schNm ); - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; - const char *QualifiedName(std::string &s) const; + const char * QualifiedName( std::string & s ) const; - const SDAI_LOGICAL &AbstractEntity() const - { + const SDAI_LOGICAL & AbstractEntity() const { return _abstractEntity; } - const SDAI_LOGICAL &ExtMapping() const - { + const SDAI_LOGICAL & ExtMapping() const { return _extMapping; } - void AbstractEntity(SDAI_LOGICAL &ae) - { - _abstractEntity.put(ae.asInt()); + void AbstractEntity( SDAI_LOGICAL & ae ) { + _abstractEntity.put( ae.asInt() ); } - void ExtMapping(SDAI_LOGICAL &em) - { - _extMapping.put(em.asInt()); + void ExtMapping( SDAI_LOGICAL & em ) { + _extMapping.put( em.asInt() ); } - void AbstractEntity(Logical ae) - { - _abstractEntity.put(ae); + void AbstractEntity( Logical ae ) { + _abstractEntity.put( ae ); } - void ExtMapping(Logical em) - { - _extMapping.put(em); + void ExtMapping( Logical em ) { + _extMapping.put( em ); } - void ExtMapping(const char *em) - { - _extMapping.put(em); + void ExtMapping( const char * em ) { + _extMapping.put( em ); } - const EntityDescriptorList &Subtypes() const - { + const EntityDescriptorList & Subtypes() const { return _subtypes; } - const EntityDescriptorList &Supertypes() const - { + const EntityDescriptorList & Supertypes() const { return _supertypes; } - const EntityDescriptorList &GetSupertypes() const - { + const EntityDescriptorList & GetSupertypes() const { return _supertypes; } - const AttrDescriptorList &ExplicitAttr() const - { + const AttrDescriptorList & ExplicitAttr() const { return _explicitAttr; } - const Inverse_attributeList &InverseAttr() const - { + const Inverse_attributeList & InverseAttr() const { return _inverseAttr; } - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; - virtual const TypeDescriptor *IsA(const TypeDescriptor *td) const; - virtual const TypeDescriptor *IsA(const char *n) const - { - return TypeDescriptor::IsA(n); + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; + virtual const TypeDescriptor * IsA( const TypeDescriptor * td ) const; + virtual const TypeDescriptor * IsA( const char * n ) const { + return TypeDescriptor::IsA( n ); } - virtual const TypeDescriptor *CanBe(const TypeDescriptor *o) const - { - return o -> IsA(this); + virtual const TypeDescriptor * CanBe( const TypeDescriptor * o ) const { + return o -> IsA( this ); } - virtual const TypeDescriptor *CanBe(const char *n) const - { - return TypeDescriptor::CanBe(n); + virtual const TypeDescriptor * CanBe( const char * n ) const { + return TypeDescriptor::CanBe( n ); } // The following will be used by schema initialization functions - void AddSubtype(EntityDescriptor *ed) - { - _subtypes.AddNode(ed); + void AddSubtype( EntityDescriptor * ed ) { + _subtypes.AddNode( ed ); } - void AddSupertype_Stmt(const std::string &s) - { + void AddSupertype_Stmt( const std::string & s ) { _supertype_stmt = s; } - const char *Supertype_Stmt() - { + const char * Supertype_Stmt() { return _supertype_stmt.c_str(); } - std::string &supertype_stmt_() - { + std::string & supertype_stmt_() { return _supertype_stmt; } - void AddSupertype(EntityDescriptor *ed) - { - _supertypes.AddNode(ed); + void AddSupertype( EntityDescriptor * ed ) { + _supertypes.AddNode( ed ); } - void AddExplicitAttr(AttrDescriptor *ad) - { - _explicitAttr.AddNode(ad); + void AddExplicitAttr( AttrDescriptor * ad ) { + _explicitAttr.AddNode( ad ); } - void AddInverseAttr(Inverse_attribute *ia) - { - _inverseAttr.AddNode(ia); + void AddInverseAttr( Inverse_attribute * ia ) { + _inverseAttr.AddNode( ia ); } - void uniqueness_rules_(Uniqueness_rule__set *urs) - { + void uniqueness_rules_( Uniqueness_rule__set * urs ) { _uniqueness_rules = urs; } - Uniqueness_rule__set_var &uniqueness_rules_() - { + Uniqueness_rule__set_var & uniqueness_rules_() { return _uniqueness_rules; } diff --git a/src/clstepcore/entityDescriptorList.cc b/src/clstepcore/entityDescriptorList.cc index 92b3001e1..86d937c76 100644 --- a/src/clstepcore/entityDescriptorList.cc +++ b/src/clstepcore/entityDescriptorList.cc @@ -1,36 +1,29 @@ #include "entityDescriptorList.h" -EntityDescLinkNode::EntityDescLinkNode() -{ +EntityDescLinkNode::EntityDescLinkNode() { _entityDesc = 0; } -EntityDescLinkNode::~EntityDescLinkNode() -{ +EntityDescLinkNode::~EntityDescLinkNode() { } -EntityDescriptorList::EntityDescriptorList() -{ +EntityDescriptorList::EntityDescriptorList() { } -EntityDescriptorList::~EntityDescriptorList() -{ +EntityDescriptorList::~EntityDescriptorList() { } -EntityDescItr::EntityDescItr(const EntityDescriptorList &edList) : edl(edList) -{ - cur = (EntityDescLinkNode *)(edl.GetHead()); +EntityDescItr::EntityDescItr( const EntityDescriptorList & edList ) : edl( edList ) { + cur = ( EntityDescLinkNode * )( edl.GetHead() ); } -EntityDescItr::~EntityDescItr() -{ +EntityDescItr::~EntityDescItr() { } -EntityDescriptor *EntityDescItr::NextEntityDesc_nc() -{ - if(cur) { - EntityDescriptor *ed = cur->EntityDesc(); - cur = (EntityDescLinkNode *)(cur->NextNode()); +EntityDescriptor * EntityDescItr::NextEntityDesc_nc() { + if( cur ) { + EntityDescriptor * ed = cur->EntityDesc(); + cur = ( EntityDescLinkNode * )( cur->NextNode() ); return ed; } return 0; diff --git a/src/clstepcore/entityDescriptorList.h b/src/clstepcore/entityDescriptorList.h index 5d8059b62..e34da432a 100644 --- a/src/clstepcore/entityDescriptorList.h +++ b/src/clstepcore/entityDescriptorList.h @@ -9,29 +9,25 @@ class EntityDescriptor; -class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode { private: protected: - EntityDescriptor *_entityDesc; + EntityDescriptor * _entityDesc; public: EntityDescLinkNode(); virtual ~EntityDescLinkNode(); - EntityDescriptor *EntityDesc() const - { + EntityDescriptor * EntityDesc() const { return _entityDesc; } - void EntityDesc(EntityDescriptor *ed) - { + void EntityDesc( EntityDescriptor * ed ) { _entityDesc = ed; } }; -class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList { private: protected: @@ -39,44 +35,39 @@ class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList EntityDescriptorList(); virtual ~EntityDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new EntityDescLinkNode; } - EntityDescLinkNode *AddNode(EntityDescriptor *ed) - { - EntityDescLinkNode *node = (EntityDescLinkNode *) NewNode(); - node->EntityDesc(ed); - SingleLinkList::AppendNode(node); + EntityDescLinkNode * AddNode( EntityDescriptor * ed ) { + EntityDescLinkNode * node = ( EntityDescLinkNode * ) NewNode(); + node->EntityDesc( ed ); + SingleLinkList::AppendNode( node ); return node; } }; -typedef EntityDescriptorList *Entity__set_ptr; +typedef EntityDescriptorList * Entity__set_ptr; typedef Entity__set_ptr Entity__set_var; -class SC_CORE_EXPORT EntityDescItr -{ +class SC_CORE_EXPORT EntityDescItr { protected: - const EntityDescriptorList &edl; - const EntityDescLinkNode *cur; + const EntityDescriptorList & edl; + const EntityDescLinkNode * cur; public: - EntityDescItr(const EntityDescriptorList &edList); + EntityDescItr( const EntityDescriptorList & edList ); virtual ~EntityDescItr(); - void ResetItr() - { - cur = (EntityDescLinkNode *)(edl.GetHead()); + void ResetItr() { + cur = ( EntityDescLinkNode * )( edl.GetHead() ); } - inline const EntityDescriptor *NextEntityDesc() - { + inline const EntityDescriptor * NextEntityDesc() { return NextEntityDesc_nc(); } - EntityDescriptor *NextEntityDesc_nc(); + EntityDescriptor * NextEntityDesc_nc(); }; #endif //ENTITYDESCRIPTORLIST_H diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index d74a68621..0dd35803a 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -20,12 +20,11 @@ * Returns the number of EntLists in this's list (EntList->next, next->next * etc.) including this. */ -int EntList::siblings() -{ +int EntList::siblings() { int count; - EntList *el; + EntList * el; - for(count = 1, el = next; el; count++, el = el->next) { + for( count = 1, el = next; el; count++, el = el->next ) { ; } return count; @@ -34,11 +33,10 @@ int EntList::siblings() /** * Returns the first EntList not of type join, starting from this. */ -EntList *EntList::firstNot(JoinType j) -{ - EntList *sibling = this; +EntList * EntList::firstNot( JoinType j ) { + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -47,11 +45,10 @@ EntList *EntList::firstNot(JoinType j) /** * Returns the first EntList where viable = match, starting from this. */ -EntList *EntList::firstWanted(MatchType match) -{ - EntList *sibling = this; +EntList * EntList::firstWanted( MatchType match ) { + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -61,11 +58,10 @@ EntList *EntList::firstWanted(MatchType match) * Returns the last EntList not of type join, searching backwards from * this. */ -EntList *EntList::lastNot(JoinType j) -{ - EntList *sibling = this; +EntList * EntList::lastNot( JoinType j ) { + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -75,11 +71,10 @@ EntList *EntList::lastNot(JoinType j) * Returns the last EntList where viable = match, searching backwards from * this. */ -EntList *EntList::lastWanted(MatchType match) -{ - EntList *sibling = this; +EntList * EntList::lastWanted( MatchType match ) { + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -90,22 +85,21 @@ EntList *EntList::lastWanted(MatchType match) * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ -void SimpleList::unmarkAll(EntNode *ents) -{ - EntNode *eptr = ents; +void SimpleList::unmarkAll( EntNode * ents ) { + EntNode * eptr = ents; int comp = -1; - if(viable < MATCHSOME) { + if( viable < MATCHSOME ) { return; } - while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { + while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if(eptr->mark <= I_marked) { + if( eptr->mark <= I_marked ) { // Only unmark if we gave it the strongest mark: - eptr->setmark(NOMARK); + eptr->setmark( NOMARK ); } // Either way (whether or not another List's mark remains), we no longer // marked: @@ -118,15 +112,14 @@ void SimpleList::unmarkAll(EntNode *ents) * viable val of MATCHSOME. Return true if we mark a previously unmarked * node; otherwise false. */ -bool SimpleList::acceptChoice(EntNode *ents) -{ - EntNode *eptr = ents; +bool SimpleList::acceptChoice( EntNode * ents ) { + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked()) { - eptr->setmark(ORMARK); + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked() ) { + eptr->setmark( ORMARK ); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -134,7 +127,7 @@ bool SimpleList::acceptChoice(EntNode *ents) } return false; // we didn't mark } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. return false; } diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 5fe71a6a5..792489e4b 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -21,31 +21,30 @@ * list, then sets this to the first element, and then deletes the first * element. This ensures that `this' points to the start of the list. */ -EntNode::EntNode(const char **names) -{ +EntNode::EntNode( const char ** names ) { int j = 1, comp; - EntNode *prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - const char *nm; + EntNode * prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + const char * nm; // Create a first EntNode: - firstnode = prev = new EntNode(names[0]); + firstnode = prev = new EntNode( names[0] ); - while(names[j] && *names[j] != '*') { + while( names[j] && *names[j] != '*' ) { nm = names[j]; - while(prev != NULL && (comp = StrCmpIns(prev->name, nm)) < 0) { + while( prev != NULL && ( comp = StrCmpIns( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -71,11 +70,10 @@ EntNode::EntNode(const char **names) /** * Copies all of ent's values here. */ -EntNode &EntNode::operator= (EntNode &ent) -{ - Name(ent.name); - setmark(ent.mark); - multSuprs(ent.multSupers); +EntNode & EntNode::operator= ( EntNode & ent ) { + Name( ent.name ); + setmark( ent.mark ); + multSuprs( ent.multSupers ); next = ent.next; return *this; } @@ -83,11 +81,10 @@ EntNode &EntNode::operator= (EntNode &ent) /** * Marks/unmarks all the nodes in this's list (default is to mark). */ -void EntNode::markAll(MarkType stamp) -{ - EntNode *node = this; +void EntNode::markAll( MarkType stamp ) { + EntNode * node = this; - while(node != NULL) { + while( node != NULL ) { node->mark = stamp; node = node->next; } @@ -96,12 +93,11 @@ void EntNode::markAll(MarkType stamp) /** * Returns true if this and all nodes following it are marked. */ -bool EntNode::allMarked() -{ - EntNode *node = this; +bool EntNode::allMarked() { + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { return false; } node = node->next; @@ -112,13 +108,12 @@ bool EntNode::allMarked() /** * Returns the number of unmarked nodes in this's list. */ -int EntNode::unmarkedCount() -{ +int EntNode::unmarkedCount() { int count = 0; - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { count++; } node = node->next; @@ -130,14 +125,13 @@ int EntNode::unmarkedCount() * Starting from `this', search for the last node (along our next's) which * alphabetically precedes ent. */ -EntNode *EntNode::lastSmaller(EntNode *ent) -{ - EntNode *eptr = next, *prev = this; +EntNode * EntNode::lastSmaller( EntNode * ent ) { + EntNode * eptr = next, *prev = this; - if(*this > *ent) { + if( *this > *ent ) { return NULL; } - while(eptr && *eptr > *prev && *eptr < *ent) { + while( eptr && *eptr > *prev && *eptr < *ent ) { prev = eptr; eptr = eptr->next; } @@ -153,11 +147,10 @@ EntNode *EntNode::lastSmaller(EntNode *ent) * few of the nodes. The nodes at first were in order; only the renamed * ones may be out of place.) */ -void EntNode::sort(EntNode **first) -{ - EntNode *eptr1, *eptr2, *temp1, *temp2; +void EntNode::sort( EntNode ** first ) { + EntNode * eptr1, *eptr2, *temp1, *temp2; - while(next && *this > *next) { + while( next && *this > *next ) { // Find the earliest node greater than next. (I.e., is not only this > // next but also some of this's preceding nodes. Since the nodes @@ -165,20 +158,20 @@ void EntNode::sort(EntNode **first) // ordered chunk of nodes which next should precede.) (eptr1 is // actually set to the one before, so that we'll know that eptr1->next // should now be set to next.) - eptr1 = (*first)->lastSmaller(next); + eptr1 = ( *first )->lastSmaller( next ); // Take the latest node eptr1 is greater than. (I.e., beyond next are // there more nodes which should be immediately after eptr1.) (The // succeeding nodes are not necessarily in order, so lastSmaller() also // checks that nodes later than next are also > their prev's.) - if(eptr1) { - eptr2 = next->lastSmaller(eptr1->next); + if( eptr1 ) { + eptr2 = next->lastSmaller( eptr1->next ); } else { - eptr2 = next->lastSmaller(*first); + eptr2 = next->lastSmaller( *first ); } // Switch the two lists: - if(eptr1) { + if( eptr1 ) { temp1 = eptr1->next; eptr1->next = next; temp2 = eptr2->next; @@ -193,7 +186,7 @@ void EntNode::sort(EntNode **first) } } - if(next) { - next->sort(first); + if( next ) { + next->sort( first ); } } diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 16a34ae7f..9200b196f 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -5,77 +5,73 @@ * this was in ExpDict.cc before splitting it up */ #ifdef NOT_YET -EnumerationTypeDescriptor::EnumerationTypeDescriptor() -{ +EnumerationTypeDescriptor::EnumerationTypeDescriptor( ) { _elements = new StringAggregate; } #endif -EnumTypeDescriptor::EnumTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, - const char *d, EnumCreator f) - : TypeDescriptor(nm, ft, origSchema, d), CreateNewEnum(f) -{ +EnumTypeDescriptor::EnumTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, + const char * d, EnumCreator f ) + : TypeDescriptor( nm, ft, origSchema, d ), CreateNewEnum( f ) { } -SDAI_Enum *EnumTypeDescriptor::CreateEnum() -{ - if(CreateNewEnum) { +SDAI_Enum * EnumTypeDescriptor::CreateEnum() { + if( CreateNewEnum ) { return CreateNewEnum(); } else { return 0; } } -const char *EnumTypeDescriptor::GenerateExpress(std::string &buf) const -{ +const char * EnumTypeDescriptor::GenerateExpress( std::string & buf ) const { char tmp[BUFSIZ]; buf = "TYPE "; - buf.append(StrToLower(Name(), tmp)); - buf.append(" = ENUMERATION OF \n ("); - const char *desc = Description(); - const char *ptr = &(desc[16]); + buf.append( StrToLower( Name(), tmp ) ); + buf.append( " = ENUMERATION OF \n (" ); + const char * desc = Description(); + const char * ptr = &( desc[16] ); - while(*ptr != '\0') { - if(*ptr == ',') { - buf.append(",\n "); - } else if(isupper(*ptr)) { - buf += (char)tolower(*ptr); + while( *ptr != '\0' ) { + if( *ptr == ',' ) { + buf.append( ",\n " ); + } else if( isupper( *ptr ) ) { + buf += ( char )tolower( *ptr ); } else { buf += *ptr; } ptr++; } - buf.append(";\n"); + buf.append( ";\n" ); /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { int all_comments = 1; int count = _where_rules->Count(); - for(int i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* WHERE *)\n"); + if( all_comments ) { + buf.append( " (* WHERE *)\n" ); } else { - buf.append(" WHERE\n"); + buf.append( " WHERE\n" ); } - for(int i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); + for( int i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); } } } - buf.append("END_TYPE;\n"); - return const_cast(buf.c_str()); + buf.append( "END_TYPE;\n" ); + return const_cast( buf.c_str() ); } diff --git a/src/clstepcore/enumTypeDescriptor.h b/src/clstepcore/enumTypeDescriptor.h index 1d4d3d226..de3a2c620 100644 --- a/src/clstepcore/enumTypeDescriptor.h +++ b/src/clstepcore/enumTypeDescriptor.h @@ -3,26 +3,24 @@ #include "typeDescriptor.h" -typedef SDAI_Enum *(* EnumCreator)(); +typedef SDAI_Enum * ( * EnumCreator )(); -class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor { public: EnumCreator CreateNewEnum; - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; - void AssignEnumCreator(EnumCreator f = 0) - { + void AssignEnumCreator( EnumCreator f = 0 ) { CreateNewEnum = f; } - SDAI_Enum *CreateEnum(); + SDAI_Enum * CreateEnum(); - EnumTypeDescriptor() { } - EnumTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - EnumCreator f = 0); + EnumTypeDescriptor( ) { } + EnumTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + EnumCreator f = 0 ); virtual ~EnumTypeDescriptor() { } }; @@ -34,19 +32,17 @@ class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor * why have EnumTypeDescriptor + EnumerationTypeDescriptor ??? */ #ifdef NOT_YET -class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor { protected: - StringAggregate *_elements; // of (null) + StringAggregate * _elements; // of (null) public: - EnumerationTypeDescriptor(); + EnumerationTypeDescriptor( ); virtual ~EnumerationTypeDescriptor() { } - StringAggregate &Elements() - { + StringAggregate & Elements() { return *_elements; } // void Elements (StringAggregate e); diff --git a/src/clstepcore/explicitItemId.cc b/src/clstepcore/explicitItemId.cc index e34a583e7..c229f6369 100644 --- a/src/clstepcore/explicitItemId.cc +++ b/src/clstepcore/explicitItemId.cc @@ -1,116 +1,103 @@ #include "explicitItemId.h" -Explicit_item_id::Explicit_item_id() -{ +Explicit_item_id::Explicit_item_id() { _local_definition = 0; } -Explicit_item_id::Explicit_item_id(const Explicit_item_id &eii) - : Interfaced_item(eii) -{ +Explicit_item_id::Explicit_item_id( const Explicit_item_id & eii ) +: Interfaced_item( eii ) { _local_definition = eii._local_definition; _original_id = eii._original_id; _new_id = eii._new_id; } -Explicit_item_id::~Explicit_item_id() -{ +Explicit_item_id::~Explicit_item_id() { _local_definition = 0; } -Explicit_item_id__set::Explicit_item_id__set(int defaultSize) -{ +Explicit_item_id__set::Explicit_item_id__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Explicit_item_id_ptr[_bufsize]; _count = 0; } -Explicit_item_id__set::~Explicit_item_id__set() -{ +Explicit_item_id__set::~Explicit_item_id__set() { delete[] _buf; } -void Explicit_item_id__set::Check(int index) -{ - Explicit_item_id_ptr *newbuf; +void Explicit_item_id__set::Check( int index ) { + Explicit_item_id_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Explicit_item_id_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Explicit_item_id_ptr)); + memmove( newbuf, _buf, _count * sizeof( Explicit_item_id_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Explicit_item_id__set::Insert(Explicit_item_id_ptr v, int index) -{ - Explicit_item_id_ptr *spot; - index = (index < 0) ? _count : index; +void Explicit_item_id__set::Insert( Explicit_item_id_ptr v, int index ) { + Explicit_item_id_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Append(Explicit_item_id_ptr v) -{ +void Explicit_item_id__set::Append( Explicit_item_id_ptr v ) { int index = _count; - Explicit_item_id_ptr *spot; + Explicit_item_id_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Explicit_item_id__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Explicit_item_id_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Explicit_item_id_ptr)); + Explicit_item_id_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } } -int Explicit_item_id__set::Index(Explicit_item_id_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Explicit_item_id__set::Index( Explicit_item_id_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Explicit_item_id_ptr &Explicit_item_id__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Explicit_item_id_ptr & Explicit_item_id__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Explicit_item_id__set::Count() -{ +int Explicit_item_id__set::Count() { return _count; } -void Explicit_item_id__set::Clear() -{ +void Explicit_item_id__set::Clear() { _count = 0; } diff --git a/src/clstepcore/explicitItemId.h b/src/clstepcore/explicitItemId.h index d16f05b21..8a4d22ca0 100644 --- a/src/clstepcore/explicitItemId.h +++ b/src/clstepcore/explicitItemId.h @@ -3,134 +3,122 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item -{ - protected: - Explicit_item_id(); - Explicit_item_id(const Explicit_item_id &); - Explicit_item_id(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Interfaced_item(foreign_schema), _local_definition(ld), _original_id(oi), _new_id(ni) {} - virtual ~Explicit_item_id(); - public: - // definition in the local schema. The TypeDescriptor (or subtype) is not - // implemented quite right - the name in it is the original (foreign - // schema) name. The USE or REFERENCED renames are listed in - // TypeDescriptor's altNames member variable. - // Warning: This is currently a null ptr for objects other than - // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE - // this ptr will be null. - const TypeDescriptor *_local_definition; +class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item { +protected: + Explicit_item_id(); + Explicit_item_id( const Explicit_item_id & ); + Explicit_item_id( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Interfaced_item( foreign_schema ), _local_definition( ld ), _original_id( oi ), _new_id( ni ) {} + virtual ~Explicit_item_id(); +public: + // definition in the local schema. The TypeDescriptor (or subtype) is not + // implemented quite right - the name in it is the original (foreign + // schema) name. The USE or REFERENCED renames are listed in + // TypeDescriptor's altNames member variable. + // Warning: This is currently a null ptr for objects other than + // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE + // this ptr will be null. + const TypeDescriptor * _local_definition; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - // name in originating schema - only exists if it has been renamed. - Express_id _original_id; + // name in originating schema - only exists if it has been renamed. + Express_id _original_id; - Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) + Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) #ifdef _MSC_VER #pragma warning( pop ) #endif - const TypeDescriptor *local_definition_() const - { - return _local_definition; - } - - const Express_id original_id_() const - { - return _original_id; - } - - // non-sdai, renamed name - const Express_id new_id_() const - { - return _new_id; - } - - // return string "USE" or "REFERENCE" - virtual const char *EXPRESS_type() = 0; - - // private: - void local_definition_(const TypeDescriptor *td) - { - _local_definition = td; - } - void original_id_(const Express_id &ei) - { - _original_id = ei; - } - - // non-sdai - void new_id_(const Express_id &ni) - { - _new_id = ni; - } + const TypeDescriptor * local_definition_() const { + return _local_definition; + } + + const Express_id original_id_() const { + return _original_id; + } + + // non-sdai, renamed name + const Express_id new_id_() const { + return _new_id; + } + + // return string "USE" or "REFERENCE" + virtual const char * EXPRESS_type() = 0; + + // private: + void local_definition_( const TypeDescriptor * td ) { + _local_definition = td; + } + void original_id_( const Express_id & ei ) { + _original_id = ei; + } + + // non-sdai + void new_id_( const Express_id & ni ) { + _new_id = ni; + } }; -typedef Explicit_item_id *Explicit_item_id_ptr; - - -class SC_CORE_EXPORT Explicit_item_id__set -{ - public: - Explicit_item_id__set(int = 16); - ~Explicit_item_id__set(); - - Explicit_item_id_ptr &operator[](int index); - void Insert(Explicit_item_id_ptr, int index); - void Append(Explicit_item_id_ptr); - void Remove(int index); - int Index(Explicit_item_id_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Explicit_item_id_ptr *_buf; - int _bufsize; - int _count; +typedef Explicit_item_id * Explicit_item_id_ptr; + + +class SC_CORE_EXPORT Explicit_item_id__set { +public: + Explicit_item_id__set( int = 16 ); + ~Explicit_item_id__set(); + + Explicit_item_id_ptr & operator[]( int index ); + void Insert( Explicit_item_id_ptr, int index ); + void Append( Explicit_item_id_ptr ); + void Remove( int index ); + int Index( Explicit_item_id_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Explicit_item_id_ptr * _buf; + int _bufsize; + int _count; }; -typedef Explicit_item_id__set *Explicit_item_id__set_ptr; +typedef Explicit_item_id__set * Explicit_item_id__set_ptr; typedef Explicit_item_id__set_ptr Explicit_item_id__set_var; -class SC_CORE_EXPORT Used_item : public Explicit_item_id -{ - public: - Used_item() {} - Used_item(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Explicit_item_id(foreign_schema, ld, oi, ni) {} - virtual ~Used_item() {} - - const char *EXPRESS_type() - { - return "USE"; - } +class SC_CORE_EXPORT Used_item : public Explicit_item_id { +public: + Used_item() {} + Used_item( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Explicit_item_id( foreign_schema, ld, oi, ni ) {} + virtual ~Used_item() {} + + const char * EXPRESS_type() { + return "USE"; + } }; -typedef Used_item *Used_item_ptr; - -class SC_CORE_EXPORT Referenced_item : public Explicit_item_id -{ - public: - Referenced_item() {} - Referenced_item(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Explicit_item_id(foreign_schema, ld, oi, ni) {} - virtual ~Referenced_item() {} - - const char *EXPRESS_type() - { - return "REFERENCE"; - } +typedef Used_item * Used_item_ptr; + +class SC_CORE_EXPORT Referenced_item : public Explicit_item_id { +public: + Referenced_item() {} + Referenced_item( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Explicit_item_id( foreign_schema, ld, oi, ni ) {} + virtual ~Referenced_item() {} + + const char * EXPRESS_type() { + return "REFERENCE"; + } }; -typedef Referenced_item *Referenced_item_ptr; +typedef Referenced_item * Referenced_item_ptr; #endif //EXPLICITITEMID_H diff --git a/src/clstepcore/globalRule.cc b/src/clstepcore/globalRule.cc index 126fbda1d..b6fdeb19a 100644 --- a/src/clstepcore/globalRule.cc +++ b/src/clstepcore/globalRule.cc @@ -1,33 +1,28 @@ #include "globalRule.h" Global_rule::Global_rule() - : _entities(0), _where_rules(0), _parent_schema(0) -{ +: _entities( 0 ), _where_rules( 0 ), _parent_schema( 0 ) { } -Global_rule::Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt) - : _name(n), _entities(0), _where_rules(0), _parent_schema(parent_sch), - _rule_text(rt) -{ +Global_rule::Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ) +: _name( n ), _entities( 0 ), _where_rules( 0 ), _parent_schema( parent_sch ), +_rule_text( rt ) { } /// not fully implemented -Global_rule::Global_rule(Global_rule &gr): Dictionary_instance() -{ +Global_rule::Global_rule( Global_rule & gr ): Dictionary_instance() { _name = gr._name; _parent_schema = gr._parent_schema; } -Global_rule::~Global_rule() -{ +Global_rule::~Global_rule() { delete _entities; delete _where_rules; } -void Global_rule::entities_(const Entity__set_var &e) -{ - if(_entities) { - if(_entities->EntryCount() > 0) { +void Global_rule::entities_( const Entity__set_var & e ) { + if( _entities ) { + if( _entities->EntryCount() > 0 ) { std::cerr << "In " << __FILE__ << ", Global_rule::entities_(): overwriting non-empty entity set!" << std::endl; } delete _entities; @@ -35,10 +30,9 @@ void Global_rule::entities_(const Entity__set_var &e) _entities = e; } -void Global_rule::where_rules_(const Where_rule__list_var &wrl) -{ - if(_where_rules) { - if(_where_rules->Count() > 0) { +void Global_rule::where_rules_( const Where_rule__list_var & wrl ) { + if( _where_rules ) { + if( _where_rules->Count() > 0 ) { std::cerr << "In " << __FILE__ << ", Global_rule::where_rules_(): overwriting non-empty rule set!" << std::endl; } delete _where_rules; @@ -48,102 +42,92 @@ void Global_rule::where_rules_(const Where_rule__list_var &wrl) /////////////////////////////////////////////////////////////////////////////// -Global_rule__set::Global_rule__set(int defaultSize) -{ +Global_rule__set::Global_rule__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Global_rule_ptr[_bufsize]; _count = 0; } -Global_rule__set::~Global_rule__set() -{ +Global_rule__set::~Global_rule__set() { Clear(); delete[] _buf; } -void Global_rule__set::Check(int index) -{ - Global_rule_ptr *newbuf; +void Global_rule__set::Check( int index ) { + Global_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Global_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Global_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Global_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Global_rule__set::Insert(Global_rule_ptr v, int index) -{ - Global_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Global_rule__set::Insert( Global_rule_ptr v, int index ) { + Global_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Append(Global_rule_ptr v) -{ +void Global_rule__set::Append( Global_rule_ptr v ) { int index = _count; - Global_rule_ptr *spot; + Global_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Global_rule__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Global_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Global_rule_ptr)); + Global_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Global_rule_ptr ) ); } } -int Global_rule__set::Index(Global_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Global_rule__set::Index( Global_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Global_rule_ptr &Global_rule__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Global_rule_ptr & Global_rule__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Global_rule__set::Count() -{ +int Global_rule__set::Count() { return _count; } -void Global_rule__set::Clear() -{ - for(int i = 0; i < _count; i ++) { +void Global_rule__set::Clear() { + for( int i = 0; i < _count; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index 3a8aa9d9b..c5614fdbf 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -7,91 +7,81 @@ #include "sc_export.h" -class SC_CORE_EXPORT Global_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Global_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _name; + Express_id _name; + std::string _rule_text; // non-SDAI #ifdef _MSC_VER #pragma warning( pop ) #endif - Entity__set_var _entities; // not implemented - Where_rule__list_var _where_rules; - Schema_ptr _parent_schema; - std::string _rule_text; // non-SDAI + Entity__set_var _entities; // not implemented + Where_rule__list_var _where_rules; + Schema_ptr _parent_schema; - Global_rule(); - Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt); - Global_rule(Global_rule &); // not fully implemented - virtual ~Global_rule(); + Global_rule(); + Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ); + Global_rule( Global_rule & ); // not fully implemented + virtual ~Global_rule(); - Express_id name_() const - { - return _name; - } - Entity__set_var entities_() const - { - return _entities; - } - Where_rule__list_var where_rules_() const - { - return _where_rules; - } - Schema_ptr parent_schema_() const - { - return _parent_schema; - } - const char *rule_text_() - { - return _rule_text.c_str(); - } + Express_id name_() const { + return _name; + } + Entity__set_var entities_() const { + return _entities; + } + Where_rule__list_var where_rules_() const { + return _where_rules; + } + Schema_ptr parent_schema_() const { + return _parent_schema; + } + const char * rule_text_() { + return _rule_text.c_str(); + } - void name_(Express_id &n) - { - _name = n; - } - void entities_(const Entity__set_var &e); // not implemented - void where_rules_(const Where_rule__list_var &wrl); // not implemented - void parent_schema_(const Schema_ptr &s) - { - _parent_schema = s; - } - void rule_text_(const char *rt) - { - _rule_text = rt; - } + void name_( Express_id & n ) { + _name = n; + } + void entities_( const Entity__set_var & e ); // not implemented + void where_rules_( const Where_rule__list_var & wrl ); // not implemented + void parent_schema_( const Schema_ptr & s ) { + _parent_schema = s; + } + void rule_text_( const char * rt ) { + _rule_text = rt; + } }; -typedef Global_rule *Global_rule_ptr; +typedef Global_rule * Global_rule_ptr; -class SC_CORE_EXPORT Global_rule__set -{ - public: - Global_rule__set(int = 16); - ~Global_rule__set(); +class SC_CORE_EXPORT Global_rule__set { +public: + Global_rule__set( int = 16 ); + ~Global_rule__set(); - Global_rule_ptr &operator[](int index); - void Insert(Global_rule_ptr, int index); - void Append(Global_rule_ptr); - void Remove(int index); - int Index(Global_rule_ptr); + Global_rule_ptr & operator[]( int index ); + void Insert( Global_rule_ptr, int index ); + void Append( Global_rule_ptr ); + void Remove( int index ); + int Index( Global_rule_ptr ); - int Count(); - void Clear(); - private: - void Check(int index); - private: - Global_rule_ptr *_buf; - int _bufsize; - int _count; + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Global_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Global_rule__set *Global_rule__set_ptr; +typedef Global_rule__set * Global_rule__set_ptr; typedef Global_rule__set_ptr Global_rule__set_var; diff --git a/src/clstepcore/implicitItemId.cc b/src/clstepcore/implicitItemId.cc index fa6443494..1961727af 100644 --- a/src/clstepcore/implicitItemId.cc +++ b/src/clstepcore/implicitItemId.cc @@ -1,114 +1,101 @@ #include "implicitItemId.h" -Implicit_item_id::Implicit_item_id() -{ +Implicit_item_id::Implicit_item_id() { _local_definition = 0; } -Implicit_item_id::Implicit_item_id(Implicit_item_id &iii) - : Interfaced_item(iii) -{ +Implicit_item_id::Implicit_item_id( Implicit_item_id & iii ) +: Interfaced_item( iii ) { _local_definition = iii._local_definition; } -Implicit_item_id::~Implicit_item_id() -{ +Implicit_item_id::~Implicit_item_id() { _local_definition = 0; } -Implicit_item_id__set::Implicit_item_id__set(int defaultSize) -{ +Implicit_item_id__set::Implicit_item_id__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Implicit_item_id_ptr[_bufsize]; _count = 0; } -Implicit_item_id__set::~Implicit_item_id__set() -{ +Implicit_item_id__set::~Implicit_item_id__set() { delete[] _buf; } -void Implicit_item_id__set::Check(int index) -{ - Implicit_item_id_ptr *newbuf; +void Implicit_item_id__set::Check( int index ) { + Implicit_item_id_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Implicit_item_id_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Implicit_item_id_ptr)); + memmove( newbuf, _buf, _count * sizeof( Implicit_item_id_ptr ) ); delete[]_buf; _buf = newbuf; } } -void Implicit_item_id__set::Insert(Implicit_item_id_ptr v, int index) -{ - Implicit_item_id_ptr *spot; - index = (index < 0) ? _count : index; +void Implicit_item_id__set::Insert( Implicit_item_id_ptr v, int index ) { + Implicit_item_id_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Append(Implicit_item_id_ptr v) -{ +void Implicit_item_id__set::Append( Implicit_item_id_ptr v ) { int index = _count; - Implicit_item_id_ptr *spot; + Implicit_item_id_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Implicit_item_id__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Implicit_item_id_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Implicit_item_id_ptr)); + Implicit_item_id_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } } -int Implicit_item_id__set::Index(Implicit_item_id_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Implicit_item_id__set::Index( Implicit_item_id_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Implicit_item_id_ptr &Implicit_item_id__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Implicit_item_id_ptr & Implicit_item_id__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Implicit_item_id__set::Count() -{ +int Implicit_item_id__set::Count() { return _count; } -void Implicit_item_id__set::Clear() -{ +void Implicit_item_id__set::Clear() { _count = 0; } diff --git a/src/clstepcore/implicitItemId.h b/src/clstepcore/implicitItemId.h index cea215d63..c8526324e 100644 --- a/src/clstepcore/implicitItemId.h +++ b/src/clstepcore/implicitItemId.h @@ -3,53 +3,49 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item -{ - protected: - Implicit_item_id(); - Implicit_item_id(Implicit_item_id &); - virtual ~Implicit_item_id(); - public: - const TypeDescriptor *_local_definition; - - const TypeDescriptor *local_definition_() const - { - return _local_definition; - } - - // private: - void local_definition_(const TypeDescriptor *td) - { - _local_definition = td; - } +class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item { +protected: + Implicit_item_id(); + Implicit_item_id( Implicit_item_id & ); + virtual ~Implicit_item_id(); +public: + const TypeDescriptor * _local_definition; + + const TypeDescriptor * local_definition_() const { + return _local_definition; + } + + // private: + void local_definition_( const TypeDescriptor * td ) { + _local_definition = td; + } }; -typedef Implicit_item_id *Implicit_item_id_ptr; - - -class SC_CORE_EXPORT Implicit_item_id__set -{ - public: - Implicit_item_id__set(int = 16); - ~Implicit_item_id__set(); - - Implicit_item_id_ptr &operator[](int index); - void Insert(Implicit_item_id_ptr, int index); - void Append(Implicit_item_id_ptr); - void Remove(int index); - int Index(Implicit_item_id_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Implicit_item_id_ptr *_buf; - int _bufsize; - int _count; +typedef Implicit_item_id * Implicit_item_id_ptr; + + +class SC_CORE_EXPORT Implicit_item_id__set { +public: + Implicit_item_id__set( int = 16 ); + ~Implicit_item_id__set(); + + Implicit_item_id_ptr & operator[]( int index ); + void Insert( Implicit_item_id_ptr, int index ); + void Append( Implicit_item_id_ptr ); + void Remove( int index ); + int Index( Implicit_item_id_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Implicit_item_id_ptr * _buf; + int _bufsize; + int _count; }; -typedef Implicit_item_id__set *Implicit_item_id__set_ptr; +typedef Implicit_item_id__set * Implicit_item_id__set_ptr; typedef Implicit_item_id__set_ptr Implicit_item_id__set_var; #endif //IMPLICITITEMID_H diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 6fa085168..702ea0869 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -36,27 +36,24 @@ static int debug_level = 3; /////////////////////////////////////////////////////////////////////////////// void -InstMgr::PrintSortedFileIds() -{ - MgrNode *mn = 0; +InstMgr::PrintSortedFileIds() { + MgrNode * mn = 0; int count = InstanceCount(); int i = 0; - for(i = 0; i < count; i++) { - mn = (MgrNode *)((*sortedMaster)[i]); + for( i = 0; i < count; i++ ) { + mn = ( MgrNode * )( ( *sortedMaster )[i] ); cout << i << " " << mn->GetFileId() << endl; } } -InstMgr::InstMgr(int ownsInstances) - : maxFileId(-1), _ownsInstances(ownsInstances) -{ +InstMgr::InstMgr( int ownsInstances ) + : maxFileId( -1 ), _ownsInstances( ownsInstances ) { master = new MgrNodeArray(); sortedMaster = new std::map; } -InstMgr::~InstMgr() -{ - if(_ownsInstances) { +InstMgr::~InstMgr() { + if( _ownsInstances ) { master->DeleteEntries(); } else { master->ClearEntries(); @@ -70,15 +67,13 @@ InstMgr::~InstMgr() /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ClearInstances() -{ +void InstMgr::ClearInstances() { master->ClearEntries(); sortedMaster->clear(); maxFileId = -1; } -void InstMgr::DeleteInstances() -{ +void InstMgr::DeleteInstances() { master->DeleteEntries(); sortedMaster->clear(); maxFileId = -1; @@ -97,13 +92,13 @@ void InstMgr::DeleteInstances() **************************************************/ enum Severity -InstMgr::VerifyInstances(ErrorDescriptor &err) { +InstMgr::VerifyInstances( ErrorDescriptor & err ) { int errorCount = 0; char errbuf[BUFSIZ]; int n = InstanceCount(); - MgrNode *mn; - SDAI_Application_instance *se; + MgrNode * mn; + SDAI_Application_instance * se; enum Severity rval = SEVERITY_NULL; //for each instance on the list, @@ -116,54 +111,52 @@ InstMgr::VerifyInstances(ErrorDescriptor &err) { // if it is not valid, then increment the error count // and set the rval to - for(int i = 0; i < n; ++i) - { - mn = GetMgrNode(i); - if(!mn) { + for( int i = 0; i < n; ++i ) { + mn = GetMgrNode( i ); + if( !mn ) { ++errorCount; - if(errorCount == 1) - sprintf(errbuf, - "VerifyInstances: Unable to verify the following instances: node %d", - i); + if( errorCount == 1 ) + sprintf( errbuf, + "VerifyInstances: Unable to verify the following instances: node %d", + i ); else { - sprintf(errbuf, ", node %d", i); + sprintf( errbuf, ", node %d", i ); } - err.AppendToDetailMsg(errbuf); + err.AppendToDetailMsg( errbuf ); rval = SEVERITY_INPUT_ERROR; - err.GreaterSeverity(SEVERITY_INPUT_ERROR); + err.GreaterSeverity( SEVERITY_INPUT_ERROR ); continue; } - if(debug_level > 3) + if( debug_level > 3 ) cerr << "In VerifyInstances: " << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if(!mn->MgrNodeListMember(completeSE)) { + if( !mn->MgrNodeListMember( completeSE ) ) { se = mn->GetApplication_instance(); - if(se->ValidLevel(&err, this, 0) < SEVERITY_USERMSG) { - if(rval > SEVERITY_INCOMPLETE) { + if( se->ValidLevel( &err, this, 0 ) < SEVERITY_USERMSG ) { + if( rval > SEVERITY_INCOMPLETE ) { rval = SEVERITY_INCOMPLETE; } ++errorCount; - if(errorCount == 1) - sprintf(errbuf, - "VerifyInstances: Unable to verify the following instances: #%d", - se->StepFileId()); + if( errorCount == 1 ) + sprintf( errbuf, + "VerifyInstances: Unable to verify the following instances: #%d", + se->StepFileId() ); else { - sprintf(errbuf, ", #%d", se->StepFileId()); + sprintf( errbuf, ", #%d", se->StepFileId() ); } - err.AppendToDetailMsg(errbuf); + err.AppendToDetailMsg( errbuf ); } } } - if(errorCount) - { - sprintf(errbuf, - "VerifyInstances: %d invalid instances in list.\n", - errorCount); - err.AppendToUserMsg(errbuf); - err.AppendToDetailMsg(".\n"); - err.GreaterSeverity(SEVERITY_INCOMPLETE); + if( errorCount ) { + sprintf( errbuf, + "VerifyInstances: %d invalid instances in list.\n", + errorCount ); + err.AppendToUserMsg( errbuf ); + err.AppendToDetailMsg( ".\n" ); + err.GreaterSeverity( SEVERITY_INCOMPLETE ); } return rval; @@ -171,32 +164,27 @@ InstMgr::VerifyInstances(ErrorDescriptor &err) { /////////////////////////////////////////////////////////////////////////////// -MgrNode *InstMgr::FindFileId(int fileId) -{ - std::map::iterator it; - it = sortedMaster->find(fileId); - if(it == sortedMaster->end()) { - return (MgrNode *)0; - } - return it->second; +MgrNode * InstMgr::FindFileId( int fileId ) { + std::map::iterator it; + it=sortedMaster->find(fileId); + if (it == sortedMaster->end()) return ( MgrNode * )0; + return it->second; } /////////////////////////////////////////////////////////////////////////////// // get the index into display list given a SDAI_Application_instance // called by see initiated functions -int InstMgr::GetIndex(MgrNode *mn) -{ +int InstMgr::GetIndex( MgrNode * mn ) { return mn->ArrayIndex(); } /////////////////////////////////////////////////////////////////////////////// -int InstMgr::VerifyEntity(int fileId, const char *expectedType) -{ - MgrNode *mn = FindFileId(fileId); - if(mn) { - if(!strcmp(expectedType, mn->GetApplication_instance()->EntityName())) { +int InstMgr::VerifyEntity( int fileId, const char * expectedType ) { + MgrNode * mn = FindFileId( fileId ); + if( mn ) { + if( !strcmp( expectedType, mn->GetApplication_instance()->EntityName() ) ) { return 2; // types match } else { return 1; // possible mismatch depending on descendants @@ -210,40 +198,39 @@ int InstMgr::VerifyEntity(int fileId, const char *expectedType) // Append instance to the list of instances. Checks the file id and // sets it if 1) it is not set already or 2) it already exists in the list. -MgrNode *InstMgr::Append(SDAI_Application_instance *se, stateEnum listState) -{ - if(debug_level > 3) { +MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState ) { + if( debug_level > 3 ) { cout << "#" << se->StepFileId() << " append node to InstMgr" << endl; } - MgrNode *mn = 0; + MgrNode * mn = 0; - if(se->StepFileId() == 0) { // no id assigned - se->StepFileId(NextFileId()); // assign a file id + if( se->StepFileId() == 0 ) { // no id assigned + se->StepFileId( NextFileId() ); // assign a file id } - mn = FindFileId(se->StepFileId()); - if(mn) { // if id already in list + mn = FindFileId( se->StepFileId() ); + if( mn ) { // if id already in list // and it's because instance is already in list - if(GetApplication_instance(mn) == se) { + if( GetApplication_instance( mn ) == se ) { return 0; // return 0 or mn? } else { - se->StepFileId(NextFileId()); // otherwise assign a new file id + se->StepFileId( NextFileId() ); // otherwise assign a new file id } } // update the maxFileId if needed - if(se->StepFileId() > MaxFileId()) { + if( se->StepFileId() > MaxFileId() ) { maxFileId = se->StepFileId(); } - mn = new MgrNode(se, listState); + mn = new MgrNode( se, listState ); - if(debug_level > 3) + if( debug_level > 3 ) cerr << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if(listState == noStateSE) + if( listState == noStateSE ) cout << "append to InstMgr **ERROR ** node #" << se->StepFileId() << " doesn't have state information" << endl; - master->Append(mn); + master->Append( mn ); (*sortedMaster)[mn->GetFileId()] = mn; //PrintSortedFileIds(); return mn; @@ -251,56 +238,53 @@ MgrNode *InstMgr::Append(SDAI_Application_instance *se, stateEnum listState) /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete(MgrNode *node) -{ +void InstMgr::Delete( MgrNode * node ) { // delete the node from its current state list node->Remove(); // remove the node from the sorted master array - sortedMaster->erase(node->GetFileId()); + sortedMaster->erase( node->GetFileId() ); // get the index into the master array by ptr arithmetic int index = node->ArrayIndex(); - master->Remove(index); + master->Remove( index ); delete node; } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete(SDAI_Application_instance *se) -{ - Delete(FindFileId(se->StepFileId())); +void InstMgr::Delete( SDAI_Application_instance * se ) { + Delete( FindFileId( se->StepFileId() ) ); } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ChangeState(MgrNode *node, stateEnum listState) -{ - switch(listState) { +void InstMgr::ChangeState( MgrNode * node, stateEnum listState ) { + switch( listState ) { case completeSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's complete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case incompleteSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's incomplete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case newSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's new list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case deleteSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's delete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case noStateSE: cout << "#" << node->GetApplication_instance()->StepFileId() << @@ -319,17 +303,16 @@ void InstMgr::ChangeState(MgrNode *node, stateEnum listState) on the instance manager. **************************************************/ int -InstMgr::EntityKeywordCount(const char *name) -{ +InstMgr::EntityKeywordCount( const char * name ) { int count = 0; - MgrNode *node; - SDAI_Application_instance *se; + MgrNode * node; + SDAI_Application_instance * se; int n = InstanceCount(); - const char *pretty_name = PrettyTmpName(name); - for(int j = 0; j < n; ++j) { - node = GetMgrNode(j); + const char *pretty_name = PrettyTmpName( name ); + for( int j = 0; j < n; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { ++count; } } @@ -339,10 +322,9 @@ InstMgr::EntityKeywordCount(const char *name) /////////////////////////////////////////////////////////////////////////////// SDAI_Application_instance * -InstMgr::GetApplication_instance(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetApplication_instance( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->GetApplication_instance(); } else { return 0; @@ -350,10 +332,9 @@ InstMgr::GetApplication_instance(int index) } SDAI_Application_instance * -InstMgr::GetSTEPentity(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetSTEPentity( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->GetApplication_instance(); } else { return 0; @@ -373,17 +354,16 @@ InstMgr::GetSTEPentity(int index) starting_index. **************************************************/ SDAI_Application_instance * -InstMgr::GetApplication_instance(const char *entityKeyword, int starting_index) -{ - MgrNode *node; - SDAI_Application_instance *se; - const char *pretty_name = PrettyTmpName(entityKeyword); +InstMgr::GetApplication_instance( const char * entityKeyword, int starting_index ) { + MgrNode * node; + SDAI_Application_instance * se; + const char *pretty_name = PrettyTmpName( entityKeyword ); int count = InstanceCount(); - for(int j = starting_index; j < count; ++j) { - node = GetMgrNode(j); + for( int j = starting_index; j < count; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { return se; } } @@ -391,17 +371,16 @@ InstMgr::GetApplication_instance(const char *entityKeyword, int starting_index) } SDAI_Application_instance * -InstMgr::GetSTEPentity(const char *entityKeyword, int starting_index) -{ - MgrNode *node; - SDAI_Application_instance *se; - const char *pretty_name = PrettyTmpName(entityKeyword); +InstMgr::GetSTEPentity( const char * entityKeyword, int starting_index ) { + MgrNode * node; + SDAI_Application_instance * se; + const char *pretty_name = PrettyTmpName( entityKeyword ); int count = InstanceCount(); - for(int j = starting_index; j < count; ++j) { - node = GetMgrNode(j); + for( int j = starting_index; j < count; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { return se; } } @@ -411,10 +390,9 @@ InstMgr::GetSTEPentity(const char *entityKeyword, int starting_index) /////////////////////////////////////////////////////////////////////////////// void * -InstMgr::GetSEE(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetSEE( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->SEE(); } else { return 0; diff --git a/src/clstepcore/instmgr.h b/src/clstepcore/instmgr.h index 0b8a8fa49..3f185b3fb 100644 --- a/src/clstepcore/instmgr.h +++ b/src/clstepcore/instmgr.h @@ -39,107 +39,95 @@ #include -class SC_CORE_EXPORT InstMgrBase -{ +class SC_CORE_EXPORT InstMgrBase { public: - virtual MgrNodeBase *FindFileId(int fileId) = 0; + virtual MgrNodeBase * FindFileId( int fileId ) = 0; virtual ~InstMgrBase() {}; }; -class SC_CORE_EXPORT InstMgr : public InstMgrBase -{ +class SC_CORE_EXPORT InstMgr : public InstMgrBase { protected: int maxFileId; int _ownsInstances; // if true will delete instances inside destructor - MgrNodeArray *master; // master array of all MgrNodes made up of + 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 - std::map *sortedMaster; // master array sorted by fileId + std::map *sortedMaster; // master array sorted by fileId // StateList *master; // this will be an sorted array of ptrs to MgrNodes public: - InstMgr(int ownsInstances = 0); + InstMgr( int ownsInstances = 0 ); virtual ~InstMgr(); // MASTER LIST OPERATIONS - int InstanceCount() const - { + int InstanceCount() const { return master->Count(); } - int OwnsInstances() const - { + int OwnsInstances() const { return _ownsInstances; } - void OwnsInstances(int ownsInstances) - { + void OwnsInstances( int ownsInstances ) { _ownsInstances = ownsInstances; } void ClearInstances(); //clears instance lists but doesn't delete instances void DeleteInstances(); // deletes the instances (ignores _ownsInstances) - Severity VerifyInstances(ErrorDescriptor &e); + Severity VerifyInstances( ErrorDescriptor & e ); // DAS PORT possible BUG two funct's below may create a temp for the cast - MgrNode *GetMgrNode(int index) - { - return (MgrNode *) * GetGenNode(index); + MgrNode * GetMgrNode( int index ) { + return ( MgrNode * ) * GetGenNode( index ); } - GenericNode **GetGenNode(int index) - { - return &(*master) [index]; + GenericNode ** GetGenNode( int index ) { + return &( *master ) [index]; } - MgrNode *FindFileId(int fileId); + MgrNode * FindFileId( int fileId ); // get the index into display list given a SDAI_Application_instance // called by see initiated functions - int GetIndex(SDAI_Application_instance *se); - int GetIndex(MgrNode *mn); - int VerifyEntity(int fileId, const char *expectedType); + int GetIndex( SDAI_Application_instance * se ); + int GetIndex( MgrNode * mn ); + int VerifyEntity( int fileId, const char * expectedType ); // void Append(MgrNode *node); - MgrNode *Append(SDAI_Application_instance *se, stateEnum listState); + MgrNode * Append( SDAI_Application_instance * se, stateEnum listState ); // deletes node from master list structure - void Delete(MgrNode *node); - void Delete(SDAI_Application_instance *se); + void Delete( MgrNode * node ); + void Delete( SDAI_Application_instance * se ); - void ChangeState(MgrNode *node, stateEnum listState); + void ChangeState( MgrNode * node, stateEnum listState ); - int MaxFileId() - { + int MaxFileId() { return maxFileId; } - int NextFileId() - { + int NextFileId() { return maxFileId = maxFileId + 1; } - int EntityKeywordCount(const char *name); + int EntityKeywordCount( const char * name ); - SDAI_Application_instance *GetApplication_instance(int index); + SDAI_Application_instance * GetApplication_instance( int index ); SDAI_Application_instance * - GetApplication_instance(const char *entityKeyword, - int starting_index = 0); - SDAI_Application_instance *GetApplication_instance(MgrNode *node) - { + GetApplication_instance( const char * entityKeyword, + int starting_index = 0 ); + SDAI_Application_instance * GetApplication_instance( MgrNode * node ) { return node->GetApplication_instance(); } - void *GetSEE(int index); - void *GetSEE(MgrNode *node) - { + void * GetSEE( int index ); + void * GetSEE( MgrNode * node ) { return node->SEE(); } void PrintSortedFileIds(); // OBSOLETE - SDAI_Application_instance *GetSTEPentity(int index); - SDAI_Application_instance *GetSTEPentity(const char *entityKeyword, - int starting_index = 0); - SDAI_Application_instance *GetSTEPentity(MgrNode *node) - { + SDAI_Application_instance * GetSTEPentity( int index ); + SDAI_Application_instance * GetSTEPentity( const char * entityKeyword, + int starting_index = 0 ); + SDAI_Application_instance * GetSTEPentity( MgrNode * node ) { return node->GetApplication_instance(); } diff --git a/src/clstepcore/interfaceSpec.cc b/src/clstepcore/interfaceSpec.cc index a8bf4ae2c..eb0fecf3a 100644 --- a/src/clstepcore/interfaceSpec.cc +++ b/src/clstepcore/interfaceSpec.cc @@ -1,119 +1,107 @@ #include "interfaceSpec.h" -Interface_spec__set::Interface_spec__set(int defaultSize) -{ +Interface_spec__set::Interface_spec__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Interface_spec_ptr[_bufsize]; _count = 0; } -Interface_spec__set::~Interface_spec__set() -{ +Interface_spec__set::~Interface_spec__set() { delete[] _buf; } -void Interface_spec__set::Check(int index) -{ - Interface_spec_ptr *newbuf; +void Interface_spec__set::Check( int index ) { + Interface_spec_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Interface_spec_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Interface_spec_ptr)); + memmove( newbuf, _buf, _count * sizeof( Interface_spec_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Interface_spec__set::Insert(Interface_spec_ptr v, int index) -{ - Interface_spec_ptr *spot; - index = (index < 0) ? _count : index; +void Interface_spec__set::Insert( Interface_spec_ptr v, int index ) { + Interface_spec_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Append(Interface_spec_ptr v) -{ +void Interface_spec__set::Append( Interface_spec_ptr v ) { int index = _count; - Interface_spec_ptr *spot; + Interface_spec_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Interface_spec__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Interface_spec_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Interface_spec_ptr)); + Interface_spec_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Interface_spec_ptr ) ); } } -int Interface_spec__set::Index(Interface_spec_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Interface_spec__set::Index( Interface_spec_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Interface_spec_ptr &Interface_spec__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Interface_spec_ptr & Interface_spec__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Interface_spec__set::Count() -{ +int Interface_spec__set::Count() { return _count; } -void Interface_spec__set::Clear() -{ +void Interface_spec__set::Clear() { _count = 0; } /////////////////////////////////////////////////////////////////////////////// Interface_spec::Interface_spec() - : _explicit_items(new Explicit_item_id__set), - _implicit_items(0), _all_objects(0) -{ +: _explicit_items( new Explicit_item_id__set ), +_implicit_items( 0 ), _all_objects( 0 ) { } /// not tested -Interface_spec::Interface_spec(Interface_spec &is): Dictionary_instance() -{ +Interface_spec::Interface_spec( Interface_spec & is ): Dictionary_instance() { _explicit_items = new Explicit_item_id__set; int count = is._explicit_items->Count(); int i; - for(i = 0; i < count; i++) { - (*_explicit_items)[i] = - (*(is._explicit_items))[i]; + for( i = 0; i < count; i++ ) { + ( *_explicit_items )[i] = + ( *( is._explicit_items ) )[i]; } _current_schema_id = is._current_schema_id; _foreign_schema_id = is._foreign_schema_id; @@ -121,16 +109,14 @@ Interface_spec::Interface_spec(Interface_spec &is): Dictionary_instance() _implicit_items = 0; } -Interface_spec::Interface_spec(const char *cur_sch_id, - const char *foreign_sch_id, int all_objects) - : _current_schema_id(cur_sch_id), _explicit_items(new Explicit_item_id__set), - _implicit_items(0), _foreign_schema_id(foreign_sch_id), - _all_objects(all_objects) -{ +Interface_spec::Interface_spec( const char * cur_sch_id, + const char * foreign_sch_id, int all_objects ) +: _current_schema_id( cur_sch_id ), _explicit_items( new Explicit_item_id__set ), +_implicit_items( 0 ), _foreign_schema_id( foreign_sch_id ), +_all_objects( all_objects ) { } -Interface_spec::~Interface_spec() -{ +Interface_spec::~Interface_spec() { delete _explicit_items; delete _implicit_items; } diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index a109bb22f..8469a555d 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -7,109 +7,93 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interface_spec : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Interface_spec : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _current_schema_id; // schema containing the USE/REF stmt + Express_id _current_schema_id; // schema containing the USE/REF stmt + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list). + // schema that defined the USE/REFd objects + Express_id _foreign_schema_id; #ifdef _MSC_VER #pragma warning( pop ) #endif - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable: 4251 ) -#endif - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list). - // schema that defined the USE/REFd objects - Express_id _foreign_schema_id; -#ifdef _MSC_VER -#pragma warning( pop ) -#endif - - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list of ints). - // schema USEs or REFERENCEs all objects from foreign schema - int _all_objects; - - Interface_spec(); - Interface_spec(Interface_spec &); // not tested - Interface_spec(const char *cur_sch_id, const char *foreign_sch_id, - int all_objects = 0); - virtual ~Interface_spec(); - - Express_id current_schema_id_() - { - return _current_schema_id; - } - Express_id foreign_schema_id_() - { - return _foreign_schema_id; - } - - Explicit_item_id__set_var explicit_items_() - { - return _explicit_items; - } - - // this is not yet initialized for the schema - Implicit_item_id__set_var implicit_items_() - { - return _implicit_items; - } - - // private: - void current_schema_id_(const Express_id &ei) - { - _current_schema_id = ei; - } - void foreign_schema_id_(const Express_id &fi) - { - _foreign_schema_id = fi; - } - - int all_objects_() - { - return _all_objects; - } - void all_objects_(int ao) - { - _all_objects = ao; - } + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list of ints). + // schema USEs or REFERENCEs all objects from foreign schema + int _all_objects; + + Interface_spec(); + Interface_spec( Interface_spec & ); // not tested + Interface_spec( const char * cur_sch_id, const char * foreign_sch_id, + int all_objects = 0 ); + virtual ~Interface_spec(); + + Express_id current_schema_id_() { + return _current_schema_id; + } + Express_id foreign_schema_id_() { + return _foreign_schema_id; + } + + Explicit_item_id__set_var explicit_items_() { + return _explicit_items; + } + + // this is not yet initialized for the schema + Implicit_item_id__set_var implicit_items_() { + return _implicit_items; + } + + // private: + void current_schema_id_( const Express_id & ei ) { + _current_schema_id = ei; + } + void foreign_schema_id_( const Express_id & fi ) { + _foreign_schema_id = fi; + } + + int all_objects_() { + return _all_objects; + } + void all_objects_( int ao ) { + _all_objects = ao; + } }; -typedef Interface_spec *Interface_spec_ptr; - -class SC_CORE_EXPORT Interface_spec__set -{ - public: - Interface_spec__set(int = 16); - ~Interface_spec__set(); - - Interface_spec_ptr &operator[](int index); - void Insert(Interface_spec_ptr, int index); - void Append(Interface_spec_ptr); - void Remove(int index); - int Index(Interface_spec_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Interface_spec_ptr *_buf; - int _bufsize; - int _count; +typedef Interface_spec * Interface_spec_ptr; + +class SC_CORE_EXPORT Interface_spec__set { +public: + Interface_spec__set( int = 16 ); + ~Interface_spec__set(); + + Interface_spec_ptr & operator[]( int index ); + void Insert( Interface_spec_ptr, int index ); + void Append( Interface_spec_ptr ); + void Remove( int index ); + int Index( Interface_spec_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Interface_spec_ptr * _buf; + int _bufsize; + int _count; }; -typedef Interface_spec__set *Interface_spec__set_ptr; +typedef Interface_spec__set * Interface_spec__set_ptr; typedef Interface_spec__set_ptr Interface_spec__set_var; diff --git a/src/clstepcore/interfacedItem.cc b/src/clstepcore/interfacedItem.cc index fe3a67fdf..749a5922e 100644 --- a/src/clstepcore/interfacedItem.cc +++ b/src/clstepcore/interfacedItem.cc @@ -1,30 +1,24 @@ #include "interfacedItem.h" -Interfaced_item::Interfaced_item() -{ +Interfaced_item::Interfaced_item() { } -Interfaced_item::Interfaced_item(const Interfaced_item &ii): Dictionary_instance() -{ +Interfaced_item::Interfaced_item( const Interfaced_item & ii ): Dictionary_instance() { _foreign_schema = ii._foreign_schema; } -Interfaced_item::Interfaced_item(const char *foreign_schema) - : _foreign_schema(foreign_schema) -{ +Interfaced_item::Interfaced_item( const char * foreign_schema ) +: _foreign_schema( foreign_schema ) { } -Interfaced_item::~Interfaced_item() -{ +Interfaced_item::~Interfaced_item() { } -const Express_id Interfaced_item::foreign_schema_() -{ +const Express_id Interfaced_item::foreign_schema_() { return _foreign_schema; } -void Interfaced_item::foreign_schema_(const Express_id &fs) -{ +void Interfaced_item::foreign_schema_( const Express_id & fs ) { _foreign_schema = fs; } diff --git a/src/clstepcore/interfacedItem.h b/src/clstepcore/interfacedItem.h index 78b74c1fa..00401b68b 100644 --- a/src/clstepcore/interfacedItem.h +++ b/src/clstepcore/interfacedItem.h @@ -7,26 +7,25 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance -{ - protected: - Interfaced_item(); - Interfaced_item(const Interfaced_item &); - Interfaced_item(const char *foreign_schema); - virtual ~Interfaced_item(); - public: +class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance { +protected: + Interfaced_item(); + Interfaced_item( const Interfaced_item & ); + Interfaced_item( const char * foreign_schema ); + virtual ~Interfaced_item(); +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _foreign_schema; + Express_id _foreign_schema; #ifdef _MSC_VER #pragma warning( pop ) #endif - const Express_id foreign_schema_(); - // private: - void foreign_schema_(const Express_id &); + const Express_id foreign_schema_(); + // private: + void foreign_schema_( const Express_id & ); }; #endif //INTERFACEDITEM_H diff --git a/src/clstepcore/inverseAttribute.cc b/src/clstepcore/inverseAttribute.cc index 13ae8721a..eeccec90a 100644 --- a/src/clstepcore/inverseAttribute.cc +++ b/src/clstepcore/inverseAttribute.cc @@ -1,20 +1,19 @@ #include "inverseAttribute.h" #include -const char *Inverse_attribute::AttrExprDefStr(std::string &s) const -{ +const char * Inverse_attribute::AttrExprDefStr( std::string & s ) const { std::string buf; s = Name(); - s.append(" : "); - if(_optional.asInt() == LTrue) { - s.append("OPTIONAL "); + s.append( " : " ); + if( _optional.asInt() == LTrue ) { + s.append( "OPTIONAL " ); } - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - s.append(" FOR "); - s.append(_inverted_attr_id); - return const_cast(s.c_str()); + s.append( " FOR " ); + s.append( _inverted_attr_id ); + return const_cast( s.c_str() ); } diff --git a/src/clstepcore/inverseAttribute.h b/src/clstepcore/inverseAttribute.h index 3032cac15..0d02b793d 100644 --- a/src/clstepcore/inverseAttribute.h +++ b/src/clstepcore/inverseAttribute.h @@ -3,61 +3,54 @@ #include "attrDescriptor.h" -class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor -{ +class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor { public: - const char *_inverted_attr_id; - const char *_inverted_entity_id; + const char * _inverted_attr_id; + const char * _inverted_entity_id; protected: - const AttrDescriptor *_inverted_attr; // not implemented (?!) (perhaps this means "not used"?) + const AttrDescriptor * _inverted_attr; // not implemented (?!) (perhaps this means "not used"?) public: Inverse_attribute( - const char *name, // i.e. char * - TypeDescriptor *domainType, + const char * name, // i.e. char * + TypeDescriptor * domainType, Logical optional, // i.e. F U or T*/ Logical unique, // i.e. F U or T - const EntityDescriptor &owner, - const char *inverted_attr_id = 0 - ) : AttrDescriptor(name, domainType, optional, unique, - AttrType_Inverse, owner), - _inverted_attr_id(inverted_attr_id), - _inverted_entity_id(0), _inverted_attr(0) + const EntityDescriptor & owner, + const char * inverted_attr_id = 0 + ) : AttrDescriptor( name, domainType, optional, unique, + AttrType_Inverse, owner ), + _inverted_attr_id( inverted_attr_id ), + _inverted_entity_id( 0 ), _inverted_attr( 0 ) { } virtual ~Inverse_attribute() { } - const char *AttrExprDefStr(std::string &s) const; + const char * AttrExprDefStr( std::string & s ) const; - const char *inverted_attr_id_() const - { + const char * inverted_attr_id_() const { return _inverted_attr_id; } - void inverted_attr_id_(const char *iai) - { + void inverted_attr_id_( const char * iai ) { _inverted_attr_id = iai; } - const char *inverted_entity_id_() const - { + const char * inverted_entity_id_() const { return _inverted_entity_id; } - void inverted_entity_id_(const char *iei) - { + void inverted_entity_id_( const char * iei ) { _inverted_entity_id = iei; } /// 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 - { + const class AttrDescriptor * inverted_attr_() const { return _inverted_attr; } - void inverted_attr_(const AttrDescriptor *ia) - { + void inverted_attr_( const AttrDescriptor * ia ) { _inverted_attr = ia; } diff --git a/src/clstepcore/inverseAttributeList.cc b/src/clstepcore/inverseAttributeList.cc index 96207adf2..22591d41c 100644 --- a/src/clstepcore/inverseAttributeList.cc +++ b/src/clstepcore/inverseAttributeList.cc @@ -1,53 +1,45 @@ #include "inverseAttributeList.h" #include "inverseAttribute.h" -Inverse_attributeLinkNode::Inverse_attributeLinkNode() -{ +Inverse_attributeLinkNode::Inverse_attributeLinkNode() { _invAttr = 0; } -Inverse_attributeLinkNode::~Inverse_attributeLinkNode() -{ +Inverse_attributeLinkNode::~Inverse_attributeLinkNode() { } -Inverse_attributeList::Inverse_attributeList() -{ +Inverse_attributeList::Inverse_attributeList() { } -Inverse_attributeList::~Inverse_attributeList() -{ - Inverse_attributeLinkNode *node; +Inverse_attributeList::~Inverse_attributeList() { + Inverse_attributeLinkNode * node; - node = (Inverse_attributeLinkNode *) head; - while(node) { + node = ( Inverse_attributeLinkNode * ) head; + while( node ) { delete node->Inverse_attr(); - node = (Inverse_attributeLinkNode *) node->NextNode(); + node = ( Inverse_attributeLinkNode * ) node->NextNode(); } } -Inverse_attributeLinkNode *Inverse_attributeList::AddNode(Inverse_attribute *ad) -{ - Inverse_attributeLinkNode *node = (Inverse_attributeLinkNode *) NewNode(); - node->Inverse_attr(ad); - SingleLinkList::AppendNode(node); +Inverse_attributeLinkNode * Inverse_attributeList::AddNode( Inverse_attribute * ad ) { + Inverse_attributeLinkNode * node = ( Inverse_attributeLinkNode * ) NewNode(); + node->Inverse_attr( ad ); + SingleLinkList::AppendNode( node ); return node; } -InverseAItr::InverseAItr(const Inverse_attributeList *iaList) - : ial(iaList) -{ - cur = (Inverse_attributeLinkNode *)(ial->GetHead()); +InverseAItr::InverseAItr( const Inverse_attributeList * iaList ) + : ial( iaList ) { + cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); } -InverseAItr::~InverseAItr() -{ +InverseAItr::~InverseAItr() { } -Inverse_attribute *InverseAItr::NextInverse_attribute() -{ - if(cur) { - Inverse_attribute *ia = cur->Inverse_attr(); - cur = (Inverse_attributeLinkNode *)(cur->NextNode()); +Inverse_attribute * InverseAItr::NextInverse_attribute() { + if( cur ) { + Inverse_attribute * ia = cur->Inverse_attr(); + cur = ( Inverse_attributeLinkNode * )( cur->NextNode() ); return ia; } return 0; diff --git a/src/clstepcore/inverseAttributeList.h b/src/clstepcore/inverseAttributeList.h index 1bacf6f95..e7dc8a7d6 100644 --- a/src/clstepcore/inverseAttributeList.h +++ b/src/clstepcore/inverseAttributeList.h @@ -6,58 +6,51 @@ #include "SingleLinkList.h" class Inverse_attribute; -class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode { private: protected: - Inverse_attribute *_invAttr; + Inverse_attribute * _invAttr; public: Inverse_attributeLinkNode(); virtual ~Inverse_attributeLinkNode(); - Inverse_attribute *Inverse_attr() const - { + Inverse_attribute * Inverse_attr() const { return _invAttr; } - void Inverse_attr(Inverse_attribute *ia) - { + void Inverse_attr( Inverse_attribute * ia ) { _invAttr = ia; } }; -class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList -{ +class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList { private: protected: - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new Inverse_attributeLinkNode; } public: Inverse_attributeList(); virtual ~Inverse_attributeList(); - Inverse_attributeLinkNode *AddNode(Inverse_attribute *ia); + Inverse_attributeLinkNode * AddNode( Inverse_attribute * ia ); }; -class SC_CORE_EXPORT InverseAItr -{ +class SC_CORE_EXPORT InverseAItr { protected: - const Inverse_attributeList *ial; - const Inverse_attributeLinkNode *cur; + const Inverse_attributeList * ial; + const Inverse_attributeLinkNode * cur; public: - InverseAItr(const Inverse_attributeList *iaList); + InverseAItr( const Inverse_attributeList * iaList ); virtual ~InverseAItr(); - void ResetItr(const Inverse_attributeList *iaList = 0) - { - if(iaList) { + void ResetItr( const Inverse_attributeList * iaList = 0 ) { + if( iaList ) { ial = iaList; } - cur = (Inverse_attributeLinkNode *)(ial->GetHead()); + cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); } - Inverse_attribute *NextInverse_attribute(); + Inverse_attribute * NextInverse_attribute(); }; #endif //INVERSEATTRIBUTELIST_H diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index ec33b65db..5f17f7d93 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -25,25 +25,24 @@ * OR descendants we didn't test. Thus, UNKNOWN tells us that this child * is an OR, or has an OR somewhere beneath it which we must process now. */ -MatchType AndOrList::matchORs(EntNode *ents) -{ - EntList *child = childList->firstWanted(UNKNOWN); +MatchType AndOrList::matchORs( EntNode * ents ) { + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child))->matchORs( ents ) == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -53,24 +52,23 @@ MatchType AndOrList::matchORs(EntNode *ents) * descendants match the nodes of ents. We only take UNKNOWN's because * they will lead us to OR's, as explained in AndOrList::matchORs(). */ -MatchType AndList::matchORs(EntNode *ents) -{ - EntList *child = childList->firstWanted(UNKNOWN); +MatchType AndList::matchORs( EntNode * ents ) { + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -82,44 +80,43 @@ MatchType AndList::matchORs(EntNode *ents) * retain the info that these were only conditionally marked. Also, if a * MATCHALL solution was found, that is returned immediately. */ -MatchType OrList::matchORs(EntNode *ents) -{ +MatchType OrList::matchORs( EntNode * ents ) { int count; - EntList *child = childList; + EntList * child = childList; MatchType retval = UNKNOWN; - for(count = 0; count < numchildren; count++, child = child->next) { + for( count = 0; count < numchildren; count++, child = child->next ) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if(child->join != OR) { - retval = child->matchNonORs(ents); + if( child->join != OR ) { + retval = child->matchNonORs( ents ); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if(child->viable == UNKNOWN) { + if( child->viable == UNKNOWN ) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = (dynamic_cast< MultList * >(child))->matchORs(ents); + retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); } // Now register the result: - if(retval >= MATCHSOME) { + if( retval >= MATCHSOME ) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if(choice == -1) { + if( choice == -1 ) { choice1 = choice = count; } choiceCount++; - if(viable < retval) { + if( viable < retval ) { viable = retval; } } else { @@ -131,17 +128,17 @@ MatchType OrList::matchORs(EntNode *ents) // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if(viable < retval) { + if( viable < retval ) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll(ents); + child->unmarkAll( ents ); } // Accept the first viable solution, if there is one: - if(viable >= MATCHSOME) { + if( viable >= MATCHSOME ) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -150,10 +147,10 @@ MatchType OrList::matchORs(EntNode *ents) // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice(ents); + acceptChoice( ents ); } - if(viable == MATCHALL) { - return getChild(choice1)->viable; + if( viable == MATCHALL ) { + return getChild( choice1 )->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 9abde8d0b..8e44443ee 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -24,18 +24,15 @@ #include #include "sc_memmgr.h" -void *MgrNode::SEE() -{ - return (di ? di->SEE() : 0); +void * MgrNode::SEE() { + return ( di ? di->SEE() : 0 ); } -int MgrNode::GetFileId() -{ - return (se ? se->GetFileId() : -1); +int MgrNode::GetFileId() { + return ( se ? se->GetFileId() : -1 ); } -void MgrNode::Remove() -{ +void MgrNode::Remove() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Remove()\n"; // if(debug_level >= PrintValues) @@ -45,36 +42,34 @@ void MgrNode::Remove() } // searches current list for fileId -MgrNode *MgrNode::StateFindFileId(int fileId) -{ +MgrNode * MgrNode::StateFindFileId( int fileId ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::StateFindFileId()\n"; - MgrNode *startNode = this; - if(startNode->GetFileId() == fileId) { + MgrNode * startNode = this; + if( startNode->GetFileId() == fileId ) { return this; } else { // mn is really a MgrNode - MgrNode *mn = (MgrNode *)(startNode->Next()); - while(mn != startNode) { - if(mn->GetFileId() == fileId) { - return (MgrNode *)mn; + MgrNode * mn = ( MgrNode * )( startNode->Next() ); + while( mn != startNode ) { + if( mn->GetFileId() == fileId ) { + return ( MgrNode * )mn; } - mn = ((MgrNode *)mn->Next()); + mn = ( ( MgrNode * )mn->Next() ); } - return (MgrNode *)0; + return ( MgrNode * )0; } } -MgrNode::~MgrNode() -{ +MgrNode::~MgrNode() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::~MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - if(se) { + if( se ) { delete se; } - if(di) { + if( di ) { delete di; } // GenericNode::Remove(); // this is called by default. @@ -82,26 +77,23 @@ MgrNode::~MgrNode() ///////////////////// class MgrNode Display Functions ///////////////////////// -displayStateEnum MgrNode::DisplayState() -{ +displayStateEnum MgrNode::DisplayState() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::DisplayState()\n"; - return (di ? di->DisplayState() : noMapState); + return ( di ? di->DisplayState() : noMapState ); } -int MgrNode::IsDisplayState(displayStateEnum ds) -{ +int MgrNode::IsDisplayState( displayStateEnum ds ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::IsDisplayState()\n"; - return (di ? di->DisplayListMember(ds) : 0); + return ( di ? di->DisplayListMember( ds ) : 0 ); } -GenericNode *MgrNode::NextDisplay() -{ +GenericNode * MgrNode::NextDisplay() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::NextDisplay()\n"; // return (di ? ((DisplayNode *)di->Next()) : (DisplayNode *)0); - if(di) { + if( di ) { // GenericNode *dn = di->Next(); // return (DisplayNode *)dn; // return (DisplayNode *)(di->Next()); @@ -111,12 +103,11 @@ GenericNode *MgrNode::NextDisplay() } } -GenericNode *MgrNode::PrevDisplay() -{ +GenericNode * MgrNode::PrevDisplay() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::PrevDisplay()\n"; // return (di ? ((DisplayNode *)di->Prev()) : 0); - if(di) { + if( di ) { return di->Prev(); } else { return 0; @@ -126,34 +117,30 @@ GenericNode *MgrNode::PrevDisplay() // STATE LIST OPERATIONS // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList(DisplayNodeList *cmdList) -{ - if(!di) { - di = new class DisplayNode(this); +int MgrNode::ChangeList( DisplayNodeList * cmdList ) { + if( !di ) { + di = new class DisplayNode( this ); } - return di->ChangeList(cmdList); + return di->ChangeList( cmdList ); } // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList(MgrNodeList *cmdList) -{ +int MgrNode::ChangeList( MgrNodeList * cmdList ) { Remove(); - cmdList->Append(this); + cmdList->Append( this ); return 1; } -int MgrNode::ChangeState(displayStateEnum s) -{ +int MgrNode::ChangeState( displayStateEnum s ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; - if(di) { - return di->ChangeState(s); + if( di ) { + return di->ChangeState( s ); } return 0; } -int MgrNode::ChangeState(stateEnum s) -{ +int MgrNode::ChangeState( stateEnum s ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; currState = s; @@ -161,62 +148,57 @@ int MgrNode::ChangeState(stateEnum s) return 1; } -void MgrNode::Init(SDAI_Application_instance *s, - stateEnum listState, - MgrNodeList *list) -{ +void MgrNode::Init( SDAI_Application_instance * s, + stateEnum listState, + MgrNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Init()\n"; se = s; arrayIndex = -1; di = 0; currState = listState; - if(list) { - list->Append(this); + if( list ) { + list->Append( this ); } } // used for sentinel node on lists of MgrNodes -MgrNode::MgrNode() -{ +MgrNode::MgrNode() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(0, noStateSE, 0); + Init( 0, noStateSE, 0 ); } -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, noStateSE, 0); + Init( StepEntPtr, noStateSE, 0 ); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, listState, 0); + Init( StepEntPtr, listState, 0 ); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState, MgrNodeList *list) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState, MgrNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, listState, list); + Init( StepEntPtr, listState, list ); } diff --git a/src/clstepcore/mgrnode.h b/src/clstepcore/mgrnode.h index 4f14f4bf2..435b6aa70 100644 --- a/src/clstepcore/mgrnode.h +++ b/src/clstepcore/mgrnode.h @@ -25,17 +25,17 @@ class DisplayNode; #include +#include + class InstMgr; -class SC_CORE_EXPORT MgrNodeBase : public GenericNode -{ +class SC_CORE_EXPORT MgrNodeBase : public GenericNode { public: - virtual inline SDAI_Application_instance *GetSTEPentity() - { + virtual inline SDAI_Application_instance * GetSTEPentity() { abort(); - return NULL; + return nullptr; }; - virtual ~MgrNodeBase() {}; + virtual ~MgrNodeBase() {}; }; ////////////////////////////////////////////////////////////////////////////// @@ -44,8 +44,7 @@ class SC_CORE_EXPORT MgrNodeBase : public GenericNode // the DisplayNode, and removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNode : public MgrNodeBase -{ +class SC_CORE_EXPORT MgrNode : public MgrNodeBase { friend class GenNodeList; friend class MgrNodeList; friend class InstMgr; @@ -58,100 +57,93 @@ class SC_CORE_EXPORT MgrNode : public MgrNodeBase stateEnum currState; // SDAI_Application_instance this node is representing info for - SDAI_Application_instance *se; + SDAI_Application_instance * se; // this is the index (in the InstMgr master array) of the ptr to // this node. int arrayIndex; // display info (SEE, etc) for this node - DisplayNode *di; + DisplayNode * di; public: // used for sentinel node on lists of MgrNodes MgrNode(); - MgrNode(SDAI_Application_instance *se); + MgrNode( SDAI_Application_instance * se ); // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) - MgrNode(SDAI_Application_instance *se, stateEnum listState); - MgrNode(SDAI_Application_instance *se, stateEnum listState, MgrNodeList *list); + MgrNode( SDAI_Application_instance * se, stateEnum listState ); + MgrNode( SDAI_Application_instance * se, stateEnum listState, MgrNodeList * list ); virtual ~MgrNode(); // STATE LIST OPERATIONS - int MgrNodeListMember(stateEnum s) - { - return (currState == s); + int MgrNodeListMember( stateEnum s ) { + return ( currState == s ); } - stateEnum CurrState() - { + stateEnum CurrState() { return currState; } // returns next or prev member variables // i.e. next or previous node on curr state list // searches current list for fileId - MgrNode *StateFindFileId(int fileId); + MgrNode * StateFindFileId( int fileId ); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList(MgrNodeList *cmdList); - int ChangeState(stateEnum s); + int ChangeList( MgrNodeList * cmdList ); + int ChangeState( stateEnum s ); // Removes from current list. // Called before adding to diff list or when destructor is called. void Remove(); // DISPLAY LIST OPERATIONS - void *SEE(); + void * SEE(); displayStateEnum DisplayState(); - int IsDisplayState(displayStateEnum ds); + int IsDisplayState( displayStateEnum ds ); // returns next or prev member variables // i.e. next or previous node on display state list - GenericNode *NextDisplay(); - GenericNode *PrevDisplay(); + GenericNode * NextDisplay(); + GenericNode * PrevDisplay(); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList(DisplayNodeList *cmdList); + int ChangeList( DisplayNodeList * cmdList ); // deletes from previous display list, assigns ds to // displayState & puts on list dsList - int ChangeState(displayStateEnum ds); + int ChangeState( displayStateEnum ds ); // might not want these three? since it won't actually map them? - void MapModifiable(DisplayNodeList *dnList); - void MapViewable(DisplayNodeList *dnList); - void UnMap(DisplayNodeList *dnList); + void MapModifiable( DisplayNodeList * dnList ); + void MapViewable( DisplayNodeList * dnList ); + void UnMap( DisplayNodeList * dnList ); // ACCESS FUNCTIONS int GetFileId(); - SDAI_Application_instance *GetApplication_instance() - { + SDAI_Application_instance * GetApplication_instance() { return se; } - DisplayNode *&displayNode() - { + DisplayNode *& displayNode() { return di; } - int ArrayIndex() - { + int ArrayIndex() { return arrayIndex; } - void ArrayIndex(int index) - { + void ArrayIndex( int index ) { arrayIndex = index; } // OBSOLETE - SDAI_Application_instance *GetSTEPentity() - { + SDAI_Application_instance * GetSTEPentity() { return se; } protected: private: - void Init(SDAI_Application_instance *s, stateEnum listState, MgrNodeList *list); + void Init( SDAI_Application_instance * s, stateEnum listState, MgrNodeList * list ); }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 87ef68c1b..23069f02b 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -43,21 +43,18 @@ static int PrintFunctionTrace = 2; // class MgrNodeArray member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArray::MgrNodeArray(int defaultSize) - : GenNodeArray(defaultSize) -{ +MgrNodeArray::MgrNodeArray( int defaultSize ) + : GenNodeArray( defaultSize ) { } -void MgrNodeArray::AssignIndexAddress(int index) -{ +void MgrNodeArray::AssignIndexAddress( int index ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArray::AssignIndexAddress()\n"; - ((MgrNode *)_buf[index])->ArrayIndex(index); + ( ( MgrNode * )_buf[index] )->ArrayIndex( index ); } -MgrNodeArray::~MgrNodeArray() -{ - if(debug_level >= PrintFunctionTrace) { +MgrNodeArray::~MgrNodeArray() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::~MgrNodeArray()\n"; } DeleteEntries(); @@ -65,13 +62,12 @@ MgrNodeArray::~MgrNodeArray() /*****************************************************************************/ -void MgrNodeArray::ClearEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::ClearEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::ClearEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; @@ -79,59 +75,55 @@ void MgrNodeArray::ClearEntries() /*****************************************************************************/ -void MgrNodeArray::DeleteEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::DeleteEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::DeleteEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { - delete((MgrNode *)_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( ( MgrNode * )_buf[i] ); } _count = 0; } /*****************************************************************************/ -int MgrNodeArray::Insert(GenericNode *gn, int index) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArray::Insert( GenericNode * gn, int index ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::Insert()\n"; } - int AssignedIndex = GenNodeArray::Insert(gn, index); + int AssignedIndex = GenNodeArray::Insert( gn, index ); int i; - for(i = AssignedIndex ; i < _count; i++) { - ((MgrNode *)_buf[i])->ArrayIndex(i); + for( i = AssignedIndex ; i < _count; i++ ) { + ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); } return AssignedIndex; } /*****************************************************************************/ -void MgrNodeArray::Remove(int index) -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::Remove( int index ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::Remove()\n"; } - if(0 <= index && index < _count) { - GenNodeArray::Remove(index); + if( 0 <= index && index < _count ) { + GenNodeArray::Remove( index ); int i; - for(i = index; i < _count; i++) { - ((MgrNode *)_buf[i])->ArrayIndex(i); + for( i = index; i < _count; i++ ) { + ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); } } } /*****************************************************************************/ -int MgrNodeArray::MgrNodeIndex(int fileId) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArray::MgrNodeIndex( int fileId ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::MgrNodeIndex()\n"; } int i; - for(i = 0; i < _count; ++i) { - if(((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId() == fileId) { + for( i = 0; i < _count; ++i ) { + if( ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId() == fileId ) { return i; } } @@ -142,47 +134,42 @@ int MgrNodeArray::MgrNodeIndex(int fileId) // class MgrNodeArraySorted member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArraySorted::MgrNodeArraySorted(int defaultSize) - : GenNodeArray(defaultSize) -{ +MgrNodeArraySorted::MgrNodeArraySorted( int defaultSize ) + : GenNodeArray( defaultSize ) { } -int MgrNodeArraySorted::Insert(GenericNode *gn) -{ +int MgrNodeArraySorted::Insert( GenericNode * gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Insert()\n"; // since gn is really a MgrNode - int fileId = ((MgrNode *)gn)->GetApplication_instance()->GetFileId(); + int fileId = ( ( MgrNode * )gn )->GetApplication_instance()->GetFileId(); - int index = FindInsertPosition(fileId); + int index = FindInsertPosition( fileId ); - return GenNodeArray::Insert(gn, index); + return GenNodeArray::Insert( gn, index ); } -int MgrNodeArraySorted::Index(GenericNode *gn) -{ +int MgrNodeArraySorted::Index( GenericNode * gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex(((MgrNode *)gn)->GetFileId()); + return MgrNodeIndex( ( ( MgrNode * )gn )->GetFileId() ); } -int MgrNodeArraySorted::Index(GenericNode **gn) -{ +int MgrNodeArraySorted::Index( GenericNode ** gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex(((MgrNode *)(*gn))->GetFileId()); + return MgrNodeIndex( ( ( MgrNode * )( *gn ) )->GetFileId() ); } -void MgrNodeArraySorted::ClearEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArraySorted::ClearEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::ClearEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; @@ -190,14 +177,13 @@ void MgrNodeArraySorted::ClearEntries() /*****************************************************************************/ -void MgrNodeArraySorted::DeleteEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArraySorted::DeleteEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::DeleteEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { - delete((MgrNode *)_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( ( MgrNode * )_buf[i] ); } _count = 0; } @@ -207,17 +193,16 @@ void MgrNodeArraySorted::DeleteEntries() // the reason this is written this way is because most of the // time the file id will be higher than any seen so far and // thus the insert position will be at the end -int MgrNodeArraySorted::FindInsertPosition(const int fileId) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArraySorted::FindInsertPosition( const int fileId ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::FindInsertPosition()\n"; } int i; int curFileId; - for(i = _count - 1; i >= 0; --i) { - curFileId = ((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId(); - if(curFileId < fileId /*|| curFileId == fileId*/) { + for( i = _count - 1; i >= 0; --i ) { + curFileId = ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId(); + if( curFileId < fileId /*|| curFileId == fileId*/ ) { return i + 1; } } @@ -226,12 +211,11 @@ int MgrNodeArraySorted::FindInsertPosition(const int fileId) /*****************************************************************************/ -int MgrNodeArraySorted::MgrNodeIndex(int fileId) -{ +int MgrNodeArraySorted::MgrNodeIndex( int fileId ) { // this function assumes that _buf[0] to _buf[_count] ALL point to MgrNodes // that are sorted by fileId - if(debug_level >= PrintFunctionTrace) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::MgrNodeIndex()\n"; } int low = 0; @@ -240,18 +224,18 @@ int MgrNodeArraySorted::MgrNodeIndex(int fileId) int found = 0; int curFileId; - while(!found && (low <= high)) { - mid = (low + high) / 2; - curFileId = ((MgrNode *)_buf[mid])->GetApplication_instance()->GetFileId(); - if(curFileId == fileId) { + while( !found && ( low <= high ) ) { + mid = ( low + high ) / 2; + curFileId = ( ( MgrNode * )_buf[mid] )->GetApplication_instance()->GetFileId(); + if( curFileId == fileId ) { found = 1; - } else if(curFileId < fileId) { + } else if( curFileId < fileId ) { low = mid + 1; } else { high = mid - 1; } } - if(found) { + if( found ) { return mid; } return -1; diff --git a/src/clstepcore/mgrnodearray.h b/src/clstepcore/mgrnodearray.h index 43e422f99..22019d071 100644 --- a/src/clstepcore/mgrnodearray.h +++ b/src/clstepcore/mgrnodearray.h @@ -38,31 +38,28 @@ // If you delete this object it deletes all of the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray -{ +class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray { public: - MgrNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); + MgrNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); ~MgrNodeArray(); // REDEFINED functions // need to redefine Append() & Insert(GenericNode *) so they call // MgrNodeArray::Insert(GenericNode *, int index); - virtual int Insert(GenericNode *gn, int index); - virtual void Append(GenericNode *gn) - { - Insert(gn, _count); + virtual int Insert( GenericNode * gn, int index ); + virtual void Append( GenericNode * gn ) { + Insert( gn, _count ); } - virtual int Insert(GenericNode *gn) - { - return Insert(gn, _count); + virtual int Insert( GenericNode * gn ) { + return Insert( gn, _count ); } - virtual void Remove(int index); + virtual void Remove( int index ); virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex(int fileId); - void AssignIndexAddress(int index); + virtual int MgrNodeIndex( int fileId ); + void AssignIndexAddress( int index ); }; ////////////////////////////////////////////////////////////////////////////// @@ -73,34 +70,31 @@ class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray // If you delete this object it won't delete the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray -{ +class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray { public: - MgrNodeArraySorted(int defaultSize = ARRAY_DEFAULT_SIZE); + MgrNodeArraySorted( int defaultSize = ARRAY_DEFAULT_SIZE ); ~MgrNodeArraySorted() { } // REDEFINED functions - virtual int Index(GenericNode *gn); - virtual int Index(GenericNode **gn); + virtual int Index( GenericNode * gn ); + virtual int Index( GenericNode ** gn ); - virtual int Insert(GenericNode *gn); - virtual int Insert(GenericNode *gn, int index) - { + virtual int Insert( GenericNode * gn ); + virtual int Insert( GenericNode * gn, int index ) { cerr << "Call MgrNodeArraySorted::Insert() without index argument instead.\n" << "index argument: " << index << " being ignored.\n"; - return Insert(gn); + return Insert( gn ); } - virtual void Append(GenericNode *gn) - { - Insert(gn); + virtual void Append( GenericNode * gn ) { + Insert( gn ); } virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex(int fileId); - int FindInsertPosition(const int fileId); + virtual int MgrNodeIndex( int fileId ); + int FindInsertPosition( const int fileId ); }; diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index 641deada5..9bff8e254 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -18,62 +18,56 @@ #include #include "sc_memmgr.h" -MgrNodeList::MgrNodeList(stateEnum type) : GenNodeList(new MgrNode()) -{ +MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::MgrNodeList()\n"; listType = type; - ((MgrNode *)head)->currState = type; + ( ( MgrNode * )head )->currState = type; } -void MgrNodeList::Remove(GenericNode *node) -{ +void MgrNodeList::Remove( GenericNode * node ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::Remove()\n"; - GenNodeList::Remove(node); + GenNodeList::Remove( node ); // DON'T DO THIS ((MgrNode *)node)->currState = noStateSE; } // deletes node from its previous list & appends... // actually it puts it at the front of the list. -void MgrNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void MgrNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } // deletes newNode from its previous list & inserts after // existNode -void MgrNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous list +void MgrNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous list newNode->Remove(); } - GenNodeList::InsertAfter(newNode, existNode); + GenNodeList::InsertAfter( newNode, existNode ); // DON'T DO THIS ((MgrNode *)newNode)->currState = listType; } // deletes newNode from its previous list & inserts before // existNode -void MgrNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void MgrNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // state list } - GenNodeList::InsertBefore(newNode, existNode); + GenNodeList::InsertBefore( newNode, existNode ); // DON'T DO THIS!! ((MgrNode *)newNode)->currState = listType; } -MgrNode *MgrNodeList::FindFileId(int fileId) -{ - MgrNode *mn = (MgrNode *)head->next; - while(mn != head) { - if(mn->GetFileId() == fileId) { +MgrNode * MgrNodeList::FindFileId( int fileId ) { + MgrNode * mn = ( MgrNode * )head->next; + while( mn != head ) { + if( mn->GetFileId() == fileId ) { return mn; } - mn = (MgrNode *)mn->next; + mn = ( MgrNode * )mn->next; } - return (MgrNode *)0; + return ( MgrNode * )0; } diff --git a/src/clstepcore/mgrnodelist.h b/src/clstepcore/mgrnodelist.h index c477d9601..be822c798 100644 --- a/src/clstepcore/mgrnodelist.h +++ b/src/clstepcore/mgrnodelist.h @@ -29,23 +29,22 @@ class MgrNode; -class SC_CORE_EXPORT MgrNodeList : public GenNodeList -{ +class SC_CORE_EXPORT MgrNodeList : public GenNodeList { public: - MgrNodeList(stateEnum type); + MgrNodeList( stateEnum type ); virtual ~MgrNodeList() { } // ADDED functions - virtual MgrNode *FindFileId(int fileId); + virtual MgrNode * FindFileId( int fileId ); // REDEFINED functions // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); - virtual void Remove(GenericNode *node); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); + virtual void Remove( GenericNode * node ); protected: stateEnum listType; diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index 79455607e..959720ed0 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -19,11 +19,10 @@ /** * Deletes the childList of this, before this is deleted. */ -MultList::~MultList() -{ - EntList *child = childList, *cnext; +MultList::~MultList() { + EntList * child = childList, *cnext; - while(child) { + while( child ) { cnext = child->next; delete child; child = cnext; @@ -34,25 +33,23 @@ MultList::~MultList() * Sets this's level, and tells all its children to set their level to our * level +1. */ -void MultList::setLevel(int l) -{ - EntList *child = childList; +void MultList::setLevel( int l ) { + EntList * child = childList; level = l; - for(; child != NULL; child = child->next) { - child->setLevel(l + 1); + for( ; child != NULL; child = child->next ) { + child->setLevel( l + 1 ); } } /** * Check if one of this's descendants matches nm. */ -bool MultList::contains(char *nm) -{ - EntList *child = childList; +bool MultList::contains( char * nm ) { + EntList * child = childList; - while(child) { - if(child->contains(nm)) { + while( child ) { + if( child->contains( nm ) ) { return true; } child = child->next; @@ -63,11 +60,10 @@ bool MultList::contains(char *nm) /** * Check if one of our descendants matches nm. */ -bool MultList::hit(char *nm) -{ - EntList *child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { +bool MultList::hit( char * nm ) { + EntList * child = childList; + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -83,16 +79,15 @@ bool MultList::hit(char *nm) /** * Returns a pointer to the num'th child of MultList. */ -EntList *MultList::getChild(int num) -{ - EntList *child = childList; +EntList * MultList::getChild( int num ) { + EntList * child = childList; int j; - if(num < 0 || num >= numchildren) { + if( num < 0 || num >= numchildren ) { // Check for error situations (shouldn't normally occur): return NULL; } - for(j = 0; j < num; j++, child = child->next) { + for( j = 0; j < num; j++, child = child->next ) { ; } return child; @@ -102,11 +97,10 @@ EntList *MultList::getChild(int num) * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ -void MultList::appendList(EntList *ent) -{ - EntList *eprev; +void MultList::appendList( EntList * ent ) { + EntList * eprev; - if(numchildren == 0) { + if( numchildren == 0 ) { childList = ent; } else { eprev = getLast(); @@ -120,13 +114,12 @@ void MultList::appendList(EntList *ent) * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ -EntList *MultList::copyList(EntList *ent) -{ - EntList *newlist = 0, *child; +EntList * MultList::copyList( EntList * ent ) { + EntList * newlist = 0, *child; - switch(ent->join) { + switch( ent->join ) { case SIMPLE: - newlist = new SimpleList((dynamic_cast(ent))->Name()); + newlist = new SimpleList( ( dynamic_cast(ent) )->Name() ); break; case AND: newlist = new AndList; @@ -138,12 +131,12 @@ EntList *MultList::copyList(EntList *ent) newlist = new AndOrList; break; }; - appendList(newlist); - if(ent->multiple()) { + appendList( newlist ); + if( ent->multiple() ) { // For the multlists, we must recurse for all their children: - child = (dynamic_cast< MultList * >(ent))->childList; - while(child) { - (dynamic_cast< MultList * >(newlist))->copyList(child); + child = ( dynamic_cast< MultList * >(ent) )->childList; + while( child ) { + ( dynamic_cast< MultList * >(newlist) )->copyList( child ); child = child->next; } } @@ -155,12 +148,11 @@ EntList *MultList::copyList(EntList *ent) * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ -void MultList::unmarkAll(EntNode *ents) -{ - EntList *child = childList; +void MultList::unmarkAll( EntNode * ents ) { + EntList * child = childList; - while(child != NULL) { - child->unmarkAll(ents); + while( child != NULL ) { + child->unmarkAll( ents ); child = child->next; } } @@ -169,12 +161,11 @@ void MultList::unmarkAll(EntNode *ents) * Resets this to default values. Iterates through child list, calling * each child's reset function. */ -void MultList::reset() -{ - EntList *child; +void MultList::reset() { + EntList * child; viable = UNKNOWN; - for(child = childList; child; child = child->next) { + for( child = childList; child; child = child->next ) { child->reset(); } } @@ -189,24 +180,23 @@ void MultList::reset() * children which are UNSATISFIED and return UNSAT if found, we don't * worry about coming across them down here. */ -void JoinList::setViableVal(EntNode *ents) -{ - EntList *child = childList; +void JoinList::setViableVal( EntNode * ents ) { + EntList * child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while(child != NULL) { - if(child->viable == UNKNOWN) { + while( child != NULL ) { + if( child->viable == UNKNOWN ) { viable = UNKNOWN; return; } - if(child->viable > viable) { + if( child->viable > viable ) { viable = child->viable; } child = child->next; } - if(viable == MATCHALL && !ents->allMarked()) { + if( viable == MATCHALL && !ents->allMarked() ) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -220,13 +210,12 @@ void JoinList::setViableVal(EntNode *ents) * value will = mark (either MARK or ORMARK). Return true if we mark any- * thing; false otherwise. */ -bool JoinList::acceptChoice(EntNode *ents) -{ - EntList *child; +bool JoinList::acceptChoice( EntNode * ents ) { + EntList * child; int result = false; - for(child = childList; child != NULL; child = child->next) { - if(child->viable >= MATCHSOME) { + for( child = childList; child != NULL; child = child->next ) { + if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -237,7 +226,7 @@ bool JoinList::acceptChoice(EntNode *ents) // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice(ents) || result; + result = child->acceptChoice( ents ) || result; // (NOTE - must run acceptChoice() first in above line. If result // were true and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -251,12 +240,11 @@ bool JoinList::acceptChoice(EntNode *ents) * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ -bool MultList::prevKnown(EntList *desc) -{ - EntList *child = childList; +bool MultList::prevKnown( EntList * desc ) { + EntList * child = childList; - while(child != NULL && child != desc) { - if(child->viable == UNKNOWN) { + while( child != NULL && child != desc ) { + if( child->viable == UNKNOWN ) { return false; } child = child->next; diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index 046a0e6ba..eea46ddb5 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -15,7 +15,6 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE(StepEntityEditor *se) -{ +void DeleteSEE( StepEntityEditor * se ) { delete se; } diff --git a/src/clstepcore/needFunc.h b/src/clstepcore/needFunc.h index 91170be39..74148bcc6 100644 --- a/src/clstepcore/needFunc.h +++ b/src/clstepcore/needFunc.h @@ -3,11 +3,10 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class SC_CORE_EXPORT StepEntityEditor -{ +class SC_CORE_EXPORT StepEntityEditor { public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index 5d83d8776..14607f606 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -19,14 +19,13 @@ * other return values. (See descript of MatchType values in complex- * Support.h.) */ -MatchType SimpleList::matchNonORs(EntNode *ents) -{ - EntNode *eptr = ents; +MatchType SimpleList::matchNonORs( EntNode * ents ) { + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked(MARK)) { + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked( MARK ) ) { // NOTE - this cond also returns true if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -35,13 +34,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if(eptr->mark == NOMARK) { + if( eptr->mark == NOMARK ) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if(ents->allMarked()) { + if( ents->allMarked() ) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -55,7 +54,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. break; } @@ -75,14 +74,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) * processing them we'll be able to tell which OR choices are viable, and * which are unnec. */ -MatchType AndOrList::matchNonORs(EntNode *ents) -{ - EntList *child = childList->firstNot(OR); +MatchType AndOrList::matchNonORs( EntNode * ents ) { + EntList * child = childList->firstNot( OR ); MatchType retval; - while(child != NULL) { - if((retval = child->matchNonORs(ents)) == MATCHALL) { - if(prevKnown(child)) { + while( child != NULL ) { + if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { + if( prevKnown( child ) ) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -109,15 +107,15 @@ MatchType AndOrList::matchNonORs(EntNode *ents) // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if(retval == UNSATISFIED) { + } else if( retval == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextNot(OR); + child = child->nextNot( OR ); } - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -125,23 +123,22 @@ MatchType AndOrList::matchNonORs(EntNode *ents) * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ -MatchType AndList::matchNonORs(EntNode *ents) -{ - EntList *child = childList->firstNot(OR); +MatchType AndList::matchNonORs( EntNode * ents ) { + EntList * child = childList->firstNot( OR ); - while(child != NULL) { - if(child->matchNonORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( child->matchNonORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot(OR); + child = child->nextNot( OR ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index ddcc260c2..b820bea53 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -25,17 +25,16 @@ * context of a sub w/ >1 super, in which case we build a combo-CList and * may need to check if all sub-CLists matched the multi-sub, C.) */ -bool OrList::hit(char *nm) -{ - EntList *child = getChild(choice); +bool OrList::hit( char * nm ) { + EntList * child = getChild( choice ); - if(child) { + if( child ) { // I.e., if we have a choice selected, check it only. - return (child->hit(nm)); + return ( child->hit( nm ) ); } else { child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // See MultList::hit() on why we must skip UNSATs. return true; } @@ -48,13 +47,12 @@ bool OrList::hit(char *nm) /** * Unmarks all the nodes of ents marked by the descendants of this. */ -void OrList::unmarkAll(EntNode *ents) -{ - EntList *child; +void OrList::unmarkAll( EntNode * ents ) { + EntList * child; - if((child = getChild(choice)) != NULL) { + if( ( child = getChild( choice ) ) != NULL ) { // choice = the last selected path which we'll now undo. - child->unmarkAll(ents); + child->unmarkAll( ents ); } } @@ -64,16 +62,15 @@ void OrList::unmarkAll(EntNode *ents) * LISTEND. If choice was set to LISTEND before calling aC(), we reset * choice to choice1, and search again. */ -bool OrList::acceptChoice(EntNode *ents) -{ - EntList *child; +bool OrList::acceptChoice( EntNode * ents ) { + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { choice = choice1; } - child = getChild(choice); - while(child) { - if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { + child = getChild( choice ); + while( child ) { + if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { // acceptChoice() returns true if we marked something. return true; } diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index c4ecf9778..2139d1f61 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -11,14 +11,13 @@ #include "sc_memmgr.h" // Local function prototypes: -static char *joinText(JoinType, char *); +static char * joinText( JoinType, char * ); /** * Prints out a ComplexList, by iterating through its children. */ -ostream &operator << (ostream &os, ComplexList &clist) -{ - os << "ComplexList - \"" << *(SimpleList *)clist.head->childList +ostream & operator << ( ostream & os, ComplexList & clist ) { + os << "ComplexList - \"" << *( SimpleList * )clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -29,12 +28,11 @@ ostream &operator << (ostream &os, ComplexList &clist) /** * Prints out an EntList. Calls appropriate function based on JoinType. */ -ostream &operator << (ostream &os, EntList &list) -{ - if(list.join == SIMPLE) { - os << *(SimpleList *)&list; +ostream & operator << ( ostream & os, EntList & list ) { + if( list.join == SIMPLE ) { + os << *( SimpleList * )&list; } else { - os << *(MultList *)&list; + os << *( MultList * )&list; } return os; } @@ -42,8 +40,7 @@ ostream &operator << (ostream &os, EntList &list) /** * Prints out a SimpleList. */ -ostream &operator << (ostream &os, SimpleList &slist) -{ +ostream & operator << ( ostream & os, SimpleList & slist ) { os << slist.name; return os; } @@ -51,27 +48,26 @@ ostream &operator << (ostream &os, SimpleList &slist) /** * Prints out a MultList. */ -ostream &operator << (ostream &os, MultList &mlist) -{ +ostream & operator << ( ostream & os, MultList & mlist ) { char jointype[7]; int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList *child = mlist.childList; + EntList * child = mlist.childList; - os << joinText(mlist.join, jointype) << endl; - for(k = 0; k <= mlist.level; k++) { + os << joinText( mlist.join, jointype ) << endl; + for( k = 0; k <= mlist.level; k++ ) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while(child != NULL) { + while( child != NULL ) { os << *child; - if(child->next == NULL) { - lastSimple = (child->join == SIMPLE); + if( child->next == NULL ) { + lastSimple = ( child->join == SIMPLE ); break; // We don't want to do the conditions below if we're done. } - if(child->join == SIMPLE) { + if( child->join == SIMPLE ) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -79,13 +75,13 @@ ostream &operator << (ostream &os, MultList &mlist) // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for(k = 0; k <= mlist.level; k++) { + for( k = 0; k <= mlist.level; k++ ) { os << " "; } } child = child->next; } - if(lastSimple) { + if( lastSimple ) { os << endl; } return os; @@ -94,20 +90,19 @@ ostream &operator << (ostream &os, MultList &mlist) /** * Copies and returns the string equivalent of a JoinType. */ -static char *joinText(JoinType j, char *buf) -{ - switch(j) { +static char * joinText( JoinType j, char * buf ) { + switch( j ) { case SIMPLE: - strcpy(buf, "SIMPLE"); + strcpy( buf, "SIMPLE" ); return buf; case AND: - strcpy(buf, "AND"); + strcpy( buf, "AND" ); return buf; case OR: - strcpy(buf, "OR"); + strcpy( buf, "OR" ); return buf; case ANDOR: - strcpy(buf, "ANDOR"); + strcpy( buf, "ANDOR" ); return buf; }; return NULL; diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index cfc83f548..395e52cfd 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -11,10 +11,9 @@ const int RealNumPrecision = REAL_NUM_PRECISION; // print Error information for debugging purposes void -PrintErrorState(ErrorDescriptor &err) -{ +PrintErrorState( ErrorDescriptor & err ) { cout << "** severity: "; - switch(err.severity()) { + switch( err.severity() ) { case SEVERITY_NULL : cout << "\n Null\n"; break; @@ -38,15 +37,14 @@ PrintErrorState(ErrorDescriptor &err) } // print istream error information for debugging purposes -void IStreamState(istream &in) -{ - if(in.good()) { +void IStreamState( istream & in ) { + if( in.good() ) { cerr << "istream GOOD\n" << flush; } - if(in.fail()) { + if( in.fail() ) { cerr << "istream FAIL\n" << flush; } - if(in.eof()) { + if( in.eof() ) { cerr << "istream EOF\n" << flush; } } @@ -71,29 +69,27 @@ void IStreamState(istream &in) // by any characters other than white space (i.e. EOF must happen) // /////////////////////////////////////////////////////////////////////////////// -int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Integer i = 0; in >> ws; in >> i; int valAssigned = 0; - if(!in.fail()) { + if( !in.fail() ) { valAssigned = 1; val = i; } - CheckRemainingInput(in, err, "Integer", tokenList); + CheckRemainingInput( in, err, "Integer", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadInteger(val, in, err, tokenList); +int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadInteger( val, in, err, tokenList ); } /////////////////////////////////////////////////////////////////////////////// @@ -115,39 +111,37 @@ int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "integer", tokenList); + CheckRemainingInput( in, err, "integer", tokenList ); return err->severity(); } else { SDAI_Integer val = 0; - int valAssigned = ReadInteger(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadInteger( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -std::string WriteReal(SDAI_Real val) -{ +std::string WriteReal( SDAI_Real val ) { char rbuf[64]; std::string s; @@ -160,22 +154,22 @@ std::string WriteReal(SDAI_Real val) // Also use G instead of g since G writes uppercase E (E instead of e // is also required by Part 21) when scientific notation is used - DAS - sprintf(rbuf, "%.*G", (int) RealNumPrecision, val); - if(!strchr(rbuf, '.')) { - if(strchr(rbuf, 'E') || strchr(rbuf, 'e')) { - char *expon = strchr(rbuf, 'E'); + sprintf( rbuf, "%.*G", ( int ) RealNumPrecision, val ); + if( !strchr( rbuf, '.' ) ) { + if( strchr( rbuf, 'E' ) || strchr( rbuf, 'e' ) ) { + char * expon = strchr( rbuf, 'E' ); - if(!expon) { - expon = strchr(rbuf, 'e'); + if( !expon ) { + expon = strchr( rbuf, 'e' ); } *expon = '\0'; s = rbuf; - s.append("."); - s.append("E"); + s.append( "." ); + s.append( "E" ); expon++; s += expon; } else { - int rindex = strlen(rbuf); + int rindex = strlen( rbuf ); rbuf[rindex] = '.'; rbuf[rindex + 1] = '\0'; s = rbuf; @@ -186,9 +180,8 @@ std::string WriteReal(SDAI_Real val) return s; } -void WriteReal(SDAI_Real val, ostream &out) -{ - out << WriteReal(val); +void WriteReal( SDAI_Real val, ostream & out ) { + out << WriteReal( val ); } /////////////////////////////////////////////////////////////////////////////// @@ -216,9 +209,8 @@ void WriteReal(SDAI_Real val, ostream &out) // an error), optional sign, at least one decimal digit if there is an E. // /////////////////////////////////////////////////////////////////////////////// -int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Real d = 0; // Read the real's value into a string so we can make sure it is properly @@ -233,71 +225,71 @@ int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, // read optional sign c = in.peek(); - if(c == '+' || c == '-') { - in.get(buf[i++]); + if( c == '+' || c == '-' ) { + in.get( buf[i++] ); c = in.peek(); } // check for required initial decimal digit - if(!isdigit(c)) { - e.severity(SEVERITY_WARNING); - e.DetailMsg("Real must have an initial digit.\n"); + if( !isdigit( c ) ) { + e.severity( SEVERITY_WARNING ); + e.DetailMsg( "Real must have an initial digit.\n" ); } // read one or more decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } // read Part 21 required decimal point - if(c == '.') { - in.get(buf[i++]); + if( c == '.' ) { + in.get( buf[i++] ); c = in.peek(); } else { // It may be the number they wanted but it is incompletely specified // without a decimal and thus it is an error - e.GreaterSeverity(SEVERITY_WARNING); - e.AppendToDetailMsg("Reals are required to have a decimal point.\n"); + e.GreaterSeverity( SEVERITY_WARNING ); + e.AppendToDetailMsg( "Reals are required to have a decimal point.\n" ); } // read optional decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } // try to read an optional E for scientific notation - if((c == 'e') || (c == 'E')) { - if(c == 'e') { + if( ( c == 'e' ) || ( c == 'E' ) ) { + if( c == 'e' ) { // this is incorrectly specified and thus is an error - e.GreaterSeverity(SEVERITY_WARNING); + e.GreaterSeverity( SEVERITY_WARNING ); e.AppendToDetailMsg( - "Reals using scientific notation must use upper case E.\n"); + "Reals using scientific notation must use upper case E.\n" ); } - in.get(buf[i++]); // read the E + in.get( buf[i++] ); // read the E c = in.peek(); // read optional sign - if(c == '+' || c == '-') { - in.get(buf[i++]); + if( c == '+' || c == '-' ) { + in.get( buf[i++] ); c = in.peek(); } // read required decimal digit (since it has an E) - if(!isdigit(c)) { - e.GreaterSeverity(SEVERITY_WARNING); + if( !isdigit( c ) ) { + e.GreaterSeverity( SEVERITY_WARNING ); e.AppendToDetailMsg( - "Real must have at least one digit following E for scientific notation.\n"); + "Real must have at least one digit following E for scientific notation.\n" ); } // read one or more decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } } buf[i] = '\0'; - istringstream in2((char *)buf); + istringstream in2( ( char * )buf ); // now that we have the real the stream will be able to salvage reading // whatever kind of format was used to represent the real. @@ -305,25 +297,24 @@ int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, int valAssigned = 0; - if(!in2.fail()) { + if( !in2.fail() ) { valAssigned = 1; val = d; - err->GreaterSeverity(e.severity()); - err->AppendToDetailMsg(e.DetailMsg()); + err->GreaterSeverity( e.severity() ); + err->AppendToDetailMsg( e.DetailMsg() ); } else { val = S_REAL_NULL; } - CheckRemainingInput(in, err, "Real", tokenList); + CheckRemainingInput( in, err, "Real", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadReal(val, in, err, tokenList); +int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadReal( val, in, err, tokenList ); } /////////////////////////////////////////////////////////////////////////////// @@ -345,32 +336,31 @@ int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "real", tokenList); + CheckRemainingInput( in, err, "real", tokenList ); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadReal(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadReal( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); @@ -395,28 +385,26 @@ Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, * to be invalid. If tokenList is null then the value must not be followed * by any characters other than white space (i.e. EOF must happen) */ -int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Real d = 0; in >> ws; in >> d; int valAssigned = 0; - if(!in.fail()) { + if( !in.fail() ) { valAssigned = 1; val = d; } - CheckRemainingInput(in, err, "Number", tokenList); + CheckRemainingInput( in, err, "Number", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadNumber(val, in, err, tokenList); +int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadNumber( val, in, err, tokenList ); } @@ -439,76 +427,73 @@ int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "number", tokenList); + CheckRemainingInput( in, err, "number", tokenList ); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadNumber(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadNumber( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } /// assign 's' so that it contains an exchange file format string read from 'in'. -void PushPastString(istream &in, std::string &s, ErrorDescriptor *err) -{ - s += GetLiteralStr(in, err); +void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ) { + s += GetLiteralStr( in, err ); } /** * assign 's' so that it contains an exchange file format aggregate read from 'in'. * This is used to read aggregates that are part of multidimensional aggregates. */ -void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err) -{ +void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get(c); + in.get( c ); - if(c == '(') { + if( c == '(' ) { s += c; - in.get(c); - while(in.good() && (c != ')')) { - if(c == '(') { - in.putback(c); - PushPastImbedAggr(in, s, err); - } else if(c == STRING_DELIM) { - in.putback(c); - PushPastString(in, s, err); + in.get( c ); + while( in.good() && ( c != ')' ) ) { + if( c == '(' ) { + in.putback( c ); + PushPastImbedAggr( in, s, err ); + } else if( c == STRING_DELIM ) { + in.putback( c ); + PushPastString( in, s, err ); } else { s += c; } - in.get(c); + in.get( c ); } - if(c != ')') { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); - s.append(")"); + if( c != ')' ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); + s.append( ")" ); } else { s += c; } @@ -520,38 +505,37 @@ void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err) * This is used to read a single dimensional aggregate (i.e. it is not allowed * to contain an aggregate as an element. */ -void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err) -{ +void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ) { char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get(c); + in.get( c ); - if(c == '(') { + if( c == '(' ) { s += c; - in.get(c); - while(in.good() && (c != ')')) { - if(c == '(') { - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); + in.get( c ); + while( in.good() && ( c != ')' ) ) { + if( c == '(' ) { + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); } - if(c == STRING_DELIM) { - in.putback(c); - PushPastString(in, s, err); + if( c == STRING_DELIM ) { + in.putback( c ); + PushPastString( in, s, err ); } else { s += c; } - in.get(c); + in.get( c ); } - if(c != ')') { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); - s.append(")"); + if( c != ')' ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); + s.append( ")" ); } else { s += c; } @@ -563,23 +547,22 @@ void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err) * it copies what is read to the std::string inst. It leaves the # on the * istream. */ -Severity FindStartOfInstance(istream &in, std::string &inst) -{ +Severity FindStartOfInstance( istream & in, std::string & inst ) { char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while(in.good()) { + while( in.good() ) { in >> c; - switch(c) { + switch( c ) { case '#': // found char looking for. - in.putback(c); + in.putback( c ); return SEVERITY_NULL; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); - inst.append(tmp.c_str()); + in.putback( c ); + tmp.STEPread( in, &errs ); + inst.append( tmp.c_str() ); break; case '\0': // problem in input ? @@ -596,22 +579,21 @@ Severity FindStartOfInstance(istream &in, std::string &inst) * SkipInstance reads in an instance terminated with ;. it copies * what is read to the std::string inst. */ -Severity SkipInstance(istream &in, std::string &inst) -{ +Severity SkipInstance( istream & in, std::string & inst ) { char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while(in.good()) { + while( in.good() ) { in >> c; - switch(c) { + switch( c ) { case ';': // end of instance reached return SEVERITY_NULL; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); - inst.append(tmp.c_str()); + in.putback( c ); + tmp.STEPread( in, &errs ); + inst.append( tmp.c_str() ); break; case '\0': // problem in input ? @@ -632,39 +614,38 @@ Severity SkipInstance(istream &in, std::string &inst) // external mapping don't have them. If you are reading a simple record in the // form of an internal mapping you will have to read the semicolon. */ -const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err) -{ +const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ) { char c; std::string s; in >> ws; - in.get(c); - if(c == '(') { // beginning of record + in.get( c ); + if( c == '(' ) { // beginning of record buf += c; - while(in.get(c) && (c != ')') && (err->severity() > SEVERITY_INPUT_ERROR)) { - if(c == '\'') { - in.putback(c); + while( in.get( c ) && ( c != ')' ) && ( err->severity() > SEVERITY_INPUT_ERROR ) ) { + if( c == '\'' ) { + in.putback( c ); s.clear(); - PushPastString(in, s, err); - buf.append(s.c_str()); - } else if(c == '(') { - in.putback(c); + PushPastString( in, s, err ); + buf.append( s.c_str() ); + } else if( c == '(' ) { + in.putback( c ); s.clear(); - PushPastImbedAggr(in, s, err); - buf.append(s.c_str()); + PushPastImbedAggr( in, s, err ); + buf.append( s.c_str() ); } else { buf += c; } } - if(!in.good()) { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->DetailMsg("File problems reading simple record.\n"); + if( !in.good() ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->DetailMsg( "File problems reading simple record.\n" ); } - buf.append(")"); + buf.append( ")" ); } else { - in.putback(c); // put back open paren + in.putback( c ); // put back open paren } - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /** @@ -672,22 +653,21 @@ const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err // entity types. To read a user-defined keyword: read the '!' then call // this function with skipInitWS turned off. **/ -const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS) -{ +const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ) { char c; - if(skipInitWS) { + if( skipInitWS ) { in >> ws; } - while(in.get(c) && !isspace(c) && (isalnum(c) || (c == '_'))) { + while( in.get( c ) && !isspace( c ) && ( isalnum( c ) || ( c == '_' ) ) ) { buf += c; } - if(in.eof() || in.good()) { - in.putback(c); + if( in.eof() || in.good() ) { + in.putback( c ); } - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /*************************** @@ -704,36 +684,35 @@ of an entity of a specific type. They shall consist of uppercase letters, digits, underscore characters, and possibly an exclamation mark. The "!" shall appear only once, and only as the first character. ***************************/ -const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err) -{ +const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) { char c; int sz = 1; static std::string str; str = ""; - in.get(c); - while(!((isspace(c)) || (strchr(delims, c)))) { + in.get( c ); + while( !( ( isspace( c ) ) || ( strchr( delims, c ) ) ) ) { //check to see if the char is valid - if(!((isupper(c)) || - (isdigit(c)) || - (c == '_') || - (c == '-') || //for reading 'ISO-10303-21' - ((c == '!') && (sz == 1)))) { + if( !( ( isupper( c ) ) || + ( isdigit( c ) ) || + ( c == '_' ) || + ( c == '-' ) || //for reading 'ISO-10303-21' + ( ( c == '!' ) && ( sz == 1 ) ) ) ) { cerr << "Error: Invalid character \'" << c << "\' in GetKeyword.\nkeyword was: " << str << "\n"; - err.GreaterSeverity(SEVERITY_WARNING); - in.putback(c); - return const_cast(str.c_str()); + err.GreaterSeverity( SEVERITY_WARNING ); + in.putback( c ); + return const_cast( str.c_str() ); } - if(!in.good()) { + if( !in.good() ) { break; //BUG: should do something on eof() } str += c; ++sz; - in.get(c); + in.get( c ); } - in.putback(c); - return const_cast(str.c_str()); + in.putback( c ); + return const_cast( str.c_str() ); } /** @@ -748,47 +727,46 @@ const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err) * next chars are DATA; for the beginning of the data section). * FIXME putback() doesn't work well on all platforms */ -int FoundEndSecKywd(istream &in) -{ +int FoundEndSecKywd( istream & in ) { char c; in >> ws; - in.get(c); - - if(c == 'E') { - in.get(c); - if(c == 'N') { - in.get(c); - if(c == 'D') { - in.get(c); - if(c == 'S') { - in.get(c); - if(c == 'E') { - in.get(c); - if(c == 'C') { + in.get( c ); + + if( c == 'E' ) { + in.get( c ); + if( c == 'N' ) { + in.get( c ); + if( c == 'D' ) { + in.get( c ); + if( c == 'S' ) { + in.get( c ); + if( c == 'E' ) { + in.get( c ); + if( c == 'C' ) { in >> ws; - in.get(c); - if(c == ';') { + in.get( c ); + if( c == ';' ) { return 1; } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } // error return 0; @@ -801,28 +779,27 @@ int FoundEndSecKywd(istream &in) // returned. If one is found ss is appended with it and a pointer just // past the comment in s is returned. Note* a carraige return ('\n') is added // after the comment that is appended. -const char *ReadComment(std::string &ss, const char *s) -{ +const char * ReadComment( std::string & ss, const char * s ) { std::string ssTmp; - if(s) { + if( s ) { int endComment = 0; - while(*s && *s != '/') { + while( *s && *s != '/' ) { s++; // skip leading everything } - if(*s == '/') { + if( *s == '/' ) { s++; - if(*s == '*') { // found a comment - ssTmp.append("/*"); + if( *s == '*' ) { // found a comment + ssTmp.append( "/*" ); s++; - while(*s && !endComment) { - if(*s == '*') { + while( *s && !endComment ) { + if( *s == '*' ) { ssTmp += *s; s++; - if(*s == '/') { + if( *s == '/' ) { endComment = 1; ssTmp += *s; - ssTmp.append("\n"); + ssTmp.append( "\n" ); } else { s--; } @@ -833,8 +810,8 @@ const char *ReadComment(std::string &ss, const char *s) } } } - if(endComment) { - ss.append(ssTmp.c_str()); + if( endComment ) { + ss.append( ssTmp.c_str() ); } } return s; @@ -852,30 +829,29 @@ const char *ReadComment(std::string &ss, const char *s) * only the slash will be read from 'in'. * FIXME putback() doesn't work well on all platforms ***************************/ -const char *ReadComment(istream &in, std::string &s) -{ +const char * ReadComment( istream & in, std::string & s ) { char c = '\0'; in >> ws; in >> c; // it looks like a comment so far - if(c == '/') { // leave slash read from stream - in.get(c); // won't skip space - if(c == '*') { // it is a comment + if( c == '/' ) { // leave slash read from stream + in.get( c ); // won't skip space + if( c == '*' ) { // it is a comment in >> ws; // skip leading comment space int commentLength = 0; // only to keep it from completely gobbling up input - while(commentLength <= MAX_COMMENT_LENGTH) { - in.get(c); - if(c == '*') { // looks like start of end comment - in.get(c); - if(c == '/') { // it is end of comment + while( commentLength <= MAX_COMMENT_LENGTH ) { + in.get( c ); + if( c == '*' ) { // looks like start of end comment + in.get( c ); + if( c == '/' ) { // it is end of comment return s.c_str(); // return comment as a string } else { // it is not end of comment // so store the * and put back the other char - s.append("*"); - in.putback(c); + s.append( "*" ); + in.putback( c ); commentLength++; } } else { @@ -887,17 +863,17 @@ const char *ReadComment(istream &in, std::string &s) << MAX_COMMENT_LENGTH << "\n" << "Will try to recover...\n"; std::string tmp; - SkipInstance(in, tmp); + SkipInstance( in, tmp ); return s.c_str(); } // leave slash read from stream... assume caller already knew there was // a slash, leave it off stream so they don't think this funct needs // to be called again else { // not a comment - in.putback(c); // put non asterisk char back on input stream + in.putback( c ); // put non asterisk char back on input stream } } else { // first non-white char is not a slash - in.putback(c); // put non slash char back on input stream + in.putback( c ); // put non slash char back on input stream } return 0; // no comment string to return @@ -908,16 +884,15 @@ const char *ReadComment(istream &in, std::string &s) ** "\F\" == formfeed ** "\N\" == newline ***************************/ -Severity ReadPcd(istream &in) -{ +Severity ReadPcd( istream & in ) { char c; - in.get(c); - if(c == '\\') { - in.get(c); - if(c == 'F' || c == 'N') { - in.get(c); - if(c == '\\') { - in.get(c); + in.get( c ); + if( c == '\\' ) { + in.get( c ); + if( c == 'F' || c == 'N' ) { + in.get( c ); + if( c == '\\' ) { + in.get( c ); return SEVERITY_NULL; } } @@ -936,33 +911,32 @@ and comments. Part 21 considers the blank to be the space character, but this function considers blanks to be the return value of isspace(c) ******************************/ -void ReadTokenSeparator(istream &in, std::string *comments) -{ +void ReadTokenSeparator( istream & in, std::string * comments ) { char c; std::string s; // used if need to read a comment - if(in.eof()) { + if( in.eof() ) { //BUG: no error message is reported return; } - while(in) { + while( in ) { in >> ws; // skip white space. c = in.peek(); // look at next char on input stream - switch(c) { + switch( c ) { case '/': // read p21 file comment s.clear(); - ReadComment(in, s); - if(!s.empty() && comments) { - comments->append("/*"); - comments->append(s.c_str()); - comments->append("*/\n"); + ReadComment( in, s ); + if( !s.empty() && comments ) { + comments->append( "/*" ); + comments->append( s.c_str() ); + comments->append( "*/\n" ); } break; case '\\': // try to read a print control directive - ReadPcd(in); + ReadPcd( in ); break; case '\n': in.ignore(); diff --git a/src/clstepcore/read_func.h b/src/clstepcore/read_func.h index 1b5d0c101..92cff5705 100644 --- a/src/clstepcore/read_func.h +++ b/src/clstepcore/read_func.h @@ -8,75 +8,75 @@ #define MAX_COMMENT_LENGTH 8192 // print Error information for debugging purposes -extern SC_CORE_EXPORT void PrintErrorState(ErrorDescriptor &err); +extern SC_CORE_EXPORT void PrintErrorState( ErrorDescriptor & err ); // print istream error information for debugging purposes -extern SC_CORE_EXPORT void IStreamState(istream &in); +extern SC_CORE_EXPORT void IStreamState( istream & in ); -extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); -extern SC_CORE_EXPORT std::string WriteReal(SDAI_Real val); +extern SC_CORE_EXPORT std::string WriteReal( SDAI_Real val ); -extern SC_CORE_EXPORT void WriteReal(SDAI_Real val, ostream &out); +extern SC_CORE_EXPORT void WriteReal( SDAI_Real val, ostream & out ); -extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); -extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); //////////////////// -extern SC_CORE_EXPORT int QuoteInString(istream &in); +extern SC_CORE_EXPORT int QuoteInString( istream & in ); -extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); //////////////////// -extern SC_CORE_EXPORT Severity FindStartOfInstance(istream &in, std::string &inst); +extern SC_CORE_EXPORT Severity FindStartOfInstance( istream & in, std::string & inst ); /// used for instances that aren\'t valid - reads to next \';\' -extern SC_CORE_EXPORT Severity SkipInstance(istream &in, std::string &inst); +extern SC_CORE_EXPORT Severity SkipInstance( istream & in, std::string & inst ); -extern SC_CORE_EXPORT const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err); +extern SC_CORE_EXPORT const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ); /// this includes entity names -extern SC_CORE_EXPORT const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS = 1); +extern SC_CORE_EXPORT const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS = 1 ); -extern SC_CORE_EXPORT const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err); +extern SC_CORE_EXPORT const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ); -extern SC_CORE_EXPORT int FoundEndSecKywd(istream &in); +extern SC_CORE_EXPORT int FoundEndSecKywd( istream& in ); -extern SC_CORE_EXPORT const char *ReadComment(std::string &ss, const char *s); +extern SC_CORE_EXPORT const char * ReadComment( std::string & ss, const char * s ); -extern SC_CORE_EXPORT const char *ReadComment(istream &in, std::string &s); +extern SC_CORE_EXPORT const char * ReadComment( istream & in, std::string & s ); -extern SC_CORE_EXPORT Severity ReadPcd(istream &in); //print control directive +extern SC_CORE_EXPORT Severity ReadPcd( istream & in ); //print control directive -extern SC_CORE_EXPORT void ReadTokenSeparator(istream &in, std::string *comments = 0); +extern SC_CORE_EXPORT void ReadTokenSeparator( istream & in, std::string * comments = 0 ); #endif diff --git a/src/clstepcore/realTypeDescriptor.h b/src/clstepcore/realTypeDescriptor.h index 155598bd3..8f1519540 100644 --- a/src/clstepcore/realTypeDescriptor.h +++ b/src/clstepcore/realTypeDescriptor.h @@ -3,27 +3,23 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor { - protected: - SDAI_Integer _precisionSpec; // OPTIONAL - public: +protected: + SDAI_Integer _precisionSpec; // OPTIONAL +public: - RealTypeDescriptor() - { - _precisionSpec = 0; - } - virtual ~RealTypeDescriptor() { } + RealTypeDescriptor( ) { + _precisionSpec = 0; + } + virtual ~RealTypeDescriptor() { } - SDAI_Integer PrecisionSpec() - { - return _precisionSpec; - } - void PrecisionSpec(SDAI_Integer ps) - { - _precisionSpec = ps; - } + SDAI_Integer PrecisionSpec() { + return _precisionSpec; + } + void PrecisionSpec( SDAI_Integer ps ) { + _precisionSpec = ps; + } }; #endif //REALTYPEDESCRIPTOR_H diff --git a/src/clstepcore/schRename.cc b/src/clstepcore/schRename.cc index 32e1fe8c0..b7159a6e0 100644 --- a/src/clstepcore/schRename.cc +++ b/src/clstepcore/schRename.cc @@ -5,13 +5,12 @@ * See if nm = one of our choices (either ours or that of a SchRename * later in the list. */ -bool SchRename::choice(const char *nm) const -{ - if(!StrCmpIns(nm, newName)) { +bool SchRename::choice( const char * nm ) const { + if( !StrCmpIns( nm, newName ) ) { return true; } - if(next) { - return (next->choice(nm)); + if( next ) { + return ( next->choice( nm ) ); } return false; } @@ -23,14 +22,13 @@ bool SchRename::choice(const char *nm) const * on next. Thus, this function will tell us if this or any later SchRe- * name in this list provide a new name for TypeDesc for schema schnm. */ -char *SchRename::rename(const char *schnm, char *newnm) const -{ - if(!StrCmpIns(schnm, schName)) { - strcpy(newnm, newName); +char * SchRename::rename( const char * schnm, char * newnm ) const { + if( !StrCmpIns( schnm, schName ) ) { + strcpy( newnm, newName ); return newnm; } - if(next) { - return (next->rename(schnm, newnm)); + if( next ) { + return ( next->rename( schnm, newnm ) ); } return NULL; } diff --git a/src/clstepcore/schRename.h b/src/clstepcore/schRename.h index d9ada7db8..a0403a5d8 100644 --- a/src/clstepcore/schRename.h +++ b/src/clstepcore/schRename.h @@ -19,35 +19,30 @@ * schema is determined by the file schema section of the header section of a * part21 file (the _headerInstances of STEPfile). */ -class SC_CORE_EXPORT SchRename -{ - public: - SchRename(const char *sch = "\0", const char *newnm = "\0") : next(0) - { - strcpy(schName, sch); - strcpy(newName, newnm); - } - ~SchRename() - { - delete next; - } - const char *objName() const - { - return newName; - } - int operator< (SchRename &schrnm) - { - return (strcmp(schName, schrnm.schName) < 0); - } - bool choice(const char *nm) const; - // is nm one of our possible choices? - char *rename(const char *schm, char *newnm) const; - // given a schema name, returns new object name if exists - SchRename *next; +class SC_CORE_EXPORT SchRename { +public: + SchRename( const char * sch = "\0", const char * newnm = "\0" ) : next( 0 ) { + strcpy( schName, sch ); + strcpy( newName, newnm ); + } + ~SchRename() { + delete next; + } + const char * objName() const { + return newName; + } + int operator< ( SchRename & schrnm ) { + return ( strcmp( schName, schrnm.schName ) < 0 ); + } + bool choice( const char * nm ) const; + // is nm one of our possible choices? + char * rename( const char * schm, char * newnm ) const; + // given a schema name, returns new object name if exists + SchRename * next; - private: - char schName[BUFSIZ]; - char newName[BUFSIZ]; +private: + char schName[BUFSIZ]; + char newName[BUFSIZ]; }; diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index 6ebf71f71..731a381f5 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -4,7 +4,7 @@ #include #include "sc_memmgr.h" -const char *SCLversion = "STEPcode, github.com/stepcode/stepcode"; +const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; const SDAI_Integer SDAI_INT_NULL = LONG_MAX; const SDAI_Real SDAI_REAL_NULL = FLT_MIN; diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index d066720b3..5751996a0 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -21,7 +21,7 @@ #include "sc_cf.h" #include -extern const char *SCLversion; +extern const char * SCLversion; #include #include @@ -151,9 +151,9 @@ enum SDAI_Error_id { SDAI_sdaiSY_ERR = 1000 // Underlying system error }; -typedef char *SDAI_Time_stamp; -typedef char *SDAI_Entity_name; -typedef char *SDAI_Schema_name; +typedef char * SDAI_Time_stamp; +typedef char * SDAI_Entity_name; +typedef char * SDAI_Schema_name; #include @@ -201,7 +201,7 @@ SELECT #include class SDAI_Model_contents; -typedef SDAI_Model_contents *SDAI_Model_contents_ptr; +typedef SDAI_Model_contents * SDAI_Model_contents_ptr; typedef SDAI_Model_contents_ptr SDAI_Model_contents_var; #include @@ -221,15 +221,15 @@ extern SC_CORE_EXPORT SDAI_Application_instance NilSTEPentity; typedef SDAI_Application_instance STEPentity; -typedef SDAI_Application_instance *STEPentity_ptr; +typedef SDAI_Application_instance * STEPentity_ptr; typedef STEPentity_ptr STEPentity_var; -typedef SDAI_Application_instance *STEPentityPtr; -typedef SDAI_Application_instance *STEPentityH; +typedef SDAI_Application_instance * STEPentityPtr; +typedef SDAI_Application_instance * STEPentityH; extern SC_CORE_EXPORT SDAI_Application_instance * -ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId); +ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ); #define SdaiInteger SDAI_Integer #define SdaiReal SDAI_Real @@ -252,17 +252,15 @@ AGGREGATE TYPES ******************************************************************************/ -inline SDAI_BOOLEAN *create_BOOLEAN() -{ +inline SDAI_BOOLEAN * create_BOOLEAN() { return new SDAI_BOOLEAN ; } -inline SDAI_LOGICAL *create_LOGICAL() -{ +inline SDAI_LOGICAL * create_LOGICAL() { return new SDAI_LOGICAL ; } // below is outdated -typedef SDAI_Select *SdaiSelectH; +typedef SDAI_Select * SdaiSelectH; #endif diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 3fc61b6fd..2bbf6b31c 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -20,11 +20,12 @@ #include "sdaiApplication_instance.h" #include "superInvAttrIter.h" +#include + SDAI_Application_instance NilSTEPentity; -bool isNilSTEPentity(const SDAI_Application_instance *ai) -{ - if(ai && ai == &NilSTEPentity) { +bool isNilSTEPentity( const SDAI_Application_instance * ai ) { + if( ai && ai == &NilSTEPentity ) { return true; } return false; @@ -42,44 +43,41 @@ bool isNilSTEPentity(const SDAI_Application_instance *ai) */ SDAI_Application_instance::SDAI_Application_instance() - : _cur(0), - eDesc(NULL), - _complex(false), - STEPfile_id(0), - p21Comment(std::string("")), - headMiEntity(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("")), - headMiEntity(0), - nextMiEntity(0) -{ -} - -SDAI_Application_instance::~SDAI_Application_instance() -{ - STEPattribute *attr; + : _cur( 0 ), + eDesc( NULL ), + _complex( false ), + STEPfile_id( 0 ), + p21Comment( std::string( "" ) ), + headMiEntity( 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( "" ) ), + headMiEntity( 0 ), + nextMiEntity( 0 ) { +} + +SDAI_Application_instance::~SDAI_Application_instance() { + STEPattribute * attr; ResetAttributes(); do { attr = NextAttribute(); - if(attr) { + if( attr ) { attr->refCount --; - if(attr->refCount <= 0) { + if( attr->refCount <= 0 ) { delete attr; } } - } while(attr); + } while( attr ); - if(MultipleInheritance()) { + if( MultipleInheritance() ) { delete nextMiEntity; } } @@ -88,93 +86,85 @@ 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; +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)); + 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()) { + superInvAttrIter siai( eDesc ); + while( !siai.empty() ) { ia = siai.next(); - assert(ia && "Null inverse attr!"); - iAMap.insert(iAMap_t::value_type(ia, s)); + assert( ia && "Null inverse attr!" ); + iAMap.insert( iAMap_t::value_type( ia, s ) ); } } -SDAI_Application_instance *SDAI_Application_instance::Replicate() -{ +SDAI_Application_instance * SDAI_Application_instance::Replicate() { char errStr[BUFSIZ]; - if(IsComplex()) { + if( IsComplex() ) { cerr << "STEPcomplex::Replicate() should be called: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", - "Programming ERROR - STEPcomplex::Replicate() should be called", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", + "Programming ERROR - STEPcomplex::Replicate() should be called", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } else { - if(!eDesc) { + if( !eDesc ) { return S_ENTITY_NULL; } - SDAI_Application_instance *seNew = eDesc->NewSTEPentity(); - seNew -> CopyAs(this); + SDAI_Application_instance * seNew = eDesc->NewSTEPentity(); + seNew -> CopyAs( this ); return seNew; } } -void SDAI_Application_instance::AddP21Comment(const char *s, bool replace) -{ - if(replace) { +void SDAI_Application_instance::AddP21Comment( const char * s, bool replace ) { + if( replace ) { p21Comment.clear(); } - if(s) { + if( s ) { p21Comment += s; } } -void SDAI_Application_instance::AddP21Comment(const std::string &s, bool replace) -{ - if(replace) { +void SDAI_Application_instance::AddP21Comment( const std::string & s, bool replace ) { + if( replace ) { p21Comment.clear(); } p21Comment += s; } -void SDAI_Application_instance::PrependP21Comment(const std::string &s) -{ - p21Comment.insert(0, s); +void SDAI_Application_instance::PrependP21Comment( const std::string & s ) { + p21Comment.insert( 0, s ); } -void SDAI_Application_instance::STEPwrite_reference(ostream &out) -{ +void SDAI_Application_instance::STEPwrite_reference( ostream & out ) { out << "#" << STEPfile_id; } -const char *SDAI_Application_instance::STEPwrite_reference(std::string &buf) -{ +const char * SDAI_Application_instance::STEPwrite_reference( std::string & buf ) { char tmp[64]; - sprintf(tmp, "#%d", STEPfile_id); + sprintf( tmp, "#%d", STEPfile_id ); buf = tmp; - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } -void SDAI_Application_instance::AppendMultInstance(SDAI_Application_instance *se) -{ - if(nextMiEntity == 0) { +void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * se ) { + if( nextMiEntity == 0 ) { nextMiEntity = se; } else { - SDAI_Application_instance *link = nextMiEntity; - SDAI_Application_instance *linkTrailing = 0; - while(link) { + SDAI_Application_instance * link = nextMiEntity; + SDAI_Application_instance * linkTrailing = 0; + while( link ) { linkTrailing = link; link = link->nextMiEntity; } @@ -182,29 +172,32 @@ void SDAI_Application_instance::AppendMultInstance(SDAI_Application_instance *se } } +const EntityDescriptor* SDAI_Application_instance::getEDesc() const { + return eDesc; +} + // BUG implement this -- FIXME function is never used -SDAI_Application_instance *SDAI_Application_instance::GetMiEntity(char *entName) -{ +SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entName ) { std::string s1, s2; - const EntityDescLinkNode *edln = 0; - const EntityDescriptor *ed = eDesc; + const EntityDescLinkNode * edln = 0; + const EntityDescriptor * ed = eDesc; // compare up the *leftmost* parent path - while(ed) { - if(!strcmp(StrToLower(ed->Name(), s1), StrToLower(entName, s2))) { + while( ed ) { + if( !strcmp( StrToLower( ed->Name(), s1 ), StrToLower( entName, s2 ) ) ) { return this; // return this parent path } - edln = (EntityDescLinkNode *)(ed->Supertypes().GetHead()); - if(edln) { + edln = ( EntityDescLinkNode * )( ed->Supertypes().GetHead() ); + if( edln ) { ed = edln->EntityDesc(); } else { ed = 0; } } // search alternate parent path since didn't find it in this one. - if(nextMiEntity) { - return nextMiEntity->GetMiEntity(entName); + if( nextMiEntity ) { + return nextMiEntity->GetMiEntity( entName ); } return 0; } @@ -215,19 +208,18 @@ SDAI_Application_instance *SDAI_Application_instance::GetMiEntity(char *entName) * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When MakeDerived is called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute *SDAI_Application_instance::GetSTEPattribute(const char *nm, const char *entity) -{ - if(!nm) { +STEPattribute * SDAI_Application_instance::GetSTEPattribute( const char * nm, const char * entity ) { + if( !nm ) { return 0; } - STEPattribute *a = 0; + STEPattribute * a = 0; ResetAttributes(); // keep going until no more attributes, or attribute is found - while((a = NextAttribute())) { - if(0 == strcmp(nm, a ->Name()) && - //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? - (entity ? (0 != a->aDesc->Owner().IsA(entity)) : true)) { + while( ( a = NextAttribute() ) ) { + if( 0 == strcmp( nm, a ->Name() ) && + //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? + ( entity ? ( 0 != a->aDesc->Owner().IsA( entity ) ) : true ) ) { break; } } @@ -235,14 +227,13 @@ STEPattribute *SDAI_Application_instance::GetSTEPattribute(const char *nm, const return a; } -STEPattribute *SDAI_Application_instance::MakeRedefined(STEPattribute *redefiningAttr, const char *nm) -{ +STEPattribute * SDAI_Application_instance::MakeRedefined( STEPattribute * redefiningAttr, const char * nm ) { // find the attribute being redefined - STEPattribute *a = GetSTEPattribute(nm); + STEPattribute * a = GetSTEPattribute( nm ); // assign its pointer to the redefining attribute - if(a) { - a->RedefiningAttr(redefiningAttr); + if( a ) { + a->RedefiningAttr( redefiningAttr ); } return a; } @@ -252,66 +243,61 @@ STEPattribute *SDAI_Application_instance::MakeRedefined(STEPattribute *redefinin * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute *SDAI_Application_instance::MakeDerived(const char *nm, const char *entity) -{ - STEPattribute *a = GetSTEPattribute(nm, entity); - if(a) { +STEPattribute * SDAI_Application_instance::MakeDerived( const char * nm, const char * entity ) { + STEPattribute * a = GetSTEPattribute( nm, entity ); + if( a ) { a ->Derive(); } return a; } -void SDAI_Application_instance::CopyAs(SDAI_Application_instance *other) -{ +void SDAI_Application_instance::CopyAs( SDAI_Application_instance * other ) { int numAttrs = AttributeCount(); ResetAttributes(); other -> ResetAttributes(); - STEPattribute *this_attr = 0; - STEPattribute *other_attr = 0; - while((this_attr = NextAttribute()) && numAttrs) { + STEPattribute * this_attr = 0; + STEPattribute * other_attr = 0; + while( ( this_attr = NextAttribute() ) && numAttrs ) { other_attr = other -> NextAttribute(); - this_attr -> ShallowCopy(other_attr); + this_attr -> ShallowCopy( other_attr ); numAttrs--; } } -const char *SDAI_Application_instance::EntityName(const char *schnm) const -{ - if(!eDesc) { +const char * SDAI_Application_instance::EntityName( const char * schnm ) const { + if( !eDesc ) { return NULL; } - return eDesc->Name(schnm); + return eDesc->Name( schnm ); } /** * Checks if a given SDAI_Application_instance is the same * type as this one */ -const EntityDescriptor *SDAI_Application_instance::IsA(const EntityDescriptor *ed) const -{ - if(!eDesc) { +const EntityDescriptor * SDAI_Application_instance::IsA( const EntityDescriptor * ed ) const { + if( !eDesc ) { return NULL; } - return (eDesc->IsA(ed)); + return ( eDesc->IsA( ed ) ); } /** * Checks the validity of the current attribute values for the entity */ -Severity SDAI_Application_instance::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError) -{ +Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError ) { ErrorDescriptor err; - if(clearError) { + if( clearError ) { ClearError(); } int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) - error->GreaterSeverity(attributes[i].ValidLevel( - attributes[i].asStr().c_str(), &err, im, 0)); + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) + error->GreaterSeverity( attributes[i].ValidLevel( + attributes[i].asStr().c_str(), &err, im, 0 ) ); } return error->severity(); } @@ -319,10 +305,9 @@ Severity SDAI_Application_instance::ValidLevel(ErrorDescriptor *error, InstMgrBa /** * clears all attr's errors */ -void SDAI_Application_instance::ClearAttrError() -{ +void SDAI_Application_instance::ClearAttrError() { int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { + for( int i = 0 ; i < n; i++ ) { attributes[i].Error().ClearErrorMsg(); } } @@ -330,10 +315,9 @@ void SDAI_Application_instance::ClearAttrError() /** * clears entity's error and optionally all attr's errors */ -void SDAI_Application_instance::ClearError(int clearAttrs) -{ +void SDAI_Application_instance::ClearError( int clearAttrs ) { _error.ClearErrorMsg(); - if(clearAttrs) { + if( clearAttrs ) { ClearAttrError(); } } @@ -344,16 +328,15 @@ void SDAI_Application_instance::ClearError(int clearAttrs) ** Side Effects: writes out the SCOPE section for an entity ** Status: stub FIXME *******************************************************************/ -void SDAI_Application_instance::beginSTEPwrite(ostream &out) -{ +void SDAI_Application_instance::beginSTEPwrite( ostream & out ) { out << "begin STEPwrite ... \n" ; out.flush(); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(attributes[i].Type() == ENTITY_TYPE - && *(attributes[i].ptr.c) != S_ENTITY_NULL) { - (*(attributes[i].ptr.c)) -> STEPwrite(); + for( int i = 0 ; i < n; i++ ) { + if( attributes[i].Type() == ENTITY_TYPE + && *( attributes[i].ptr.c ) != S_ENTITY_NULL ) { + ( *( attributes[i].ptr.c ) ) -> STEPwrite(); } } } @@ -366,68 +349,65 @@ void SDAI_Application_instance::beginSTEPwrite(ostream &out) ** Problems: does not print out the SCOPE section of an entity ** *******************************************************************/ -void SDAI_Application_instance::STEPwrite(ostream &out, const char *currSch, - int writeComments) -{ +void SDAI_Application_instance::STEPwrite( ostream & out, const char * currSch, + int writeComments ) { std::string tmp; - if(writeComments && !p21Comment.empty()) { + if( writeComments && !p21Comment.empty() ) { out << p21Comment; } - out << "#" << STEPfile_id << "=" << StrToUpper(EntityName(currSch), tmp) + out << "#" << STEPfile_id << "=" << StrToUpper( EntityName( currSch ), tmp ) << "("; int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(i > 0) { + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( i > 0 ) { out << ","; } - (attributes[i]).STEPwrite(out, currSch); + ( attributes[i] ).STEPwrite( out, currSch ); } } out << ");\n"; } -void SDAI_Application_instance::endSTEPwrite(ostream &out) -{ +void SDAI_Application_instance::endSTEPwrite( ostream & out ) { out << "end STEPwrite ... \n" ; out.flush(); } -void SDAI_Application_instance::WriteValuePairs(ostream &out, - const char *currSch, - int writeComments, int mixedCase) -{ +void SDAI_Application_instance::WriteValuePairs( ostream & out, + const char * currSch, + int writeComments, int mixedCase ) { std::string s, tmp, tmp2; - if(writeComments && !p21Comment.empty()) { + if( writeComments && !p21Comment.empty() ) { out << p21Comment; } - if(eDesc) { - if(mixedCase) { + if( eDesc ) { + if( mixedCase ) { out << "#" << STEPfile_id << " " - << eDesc->QualifiedName(s) << endl; + << eDesc->QualifiedName( s ) << endl; } else { out << "#" << STEPfile_id << " " - << StrToUpper(eDesc->QualifiedName(s), tmp) << endl; + << StrToUpper( eDesc->QualifiedName( s ), tmp ) << endl; } } int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(mixedCase) { + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( mixedCase ) { out << "\t" - << attributes[i].aDesc->Owner().Name(s.c_str()) + << attributes[i].aDesc->Owner().Name( s.c_str() ) << "." << attributes[i].aDesc->Name() << " "; } else { out << "\t" - << StrToUpper(attributes[i].aDesc->Owner().Name(s.c_str()), tmp) - << "." << StrToUpper(attributes[i].aDesc->Name(), tmp2) << " "; + << StrToUpper( attributes[i].aDesc->Owner().Name( s.c_str() ), tmp ) + << "." << StrToUpper( attributes[i].aDesc->Name(), tmp2 ) << " "; } - (attributes[i]).STEPwrite(out, currSch); + ( attributes[i] ).STEPwrite( out, currSch ); out << endl; } } @@ -439,41 +419,39 @@ void SDAI_Application_instance::WriteValuePairs(ostream &out, ** Procedure: STEPwrite ** Problems: does not print out the SCOPE section of an entity ******************************************************************/ -const char *SDAI_Application_instance::STEPwrite(std::string &buf, const char *currSch) -{ +const char * SDAI_Application_instance::STEPwrite( std::string & buf, const char * currSch ) { buf.clear(); char instanceInfo[BUFSIZ]; std::string tmp; - sprintf(instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper(EntityName(currSch), tmp)); - buf.append(instanceInfo); + sprintf( instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper( EntityName( currSch ), tmp ) ); + buf.append( instanceInfo ); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(i > 0) { - buf.append(","); + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( i > 0 ) { + buf.append( "," ); } - tmp = attributes[i].asStr(currSch) ; - buf.append(tmp); + tmp = attributes[i].asStr( currSch ) ; + buf.append( tmp ); } } - buf.append(");"); - return const_cast(buf.c_str()); + buf.append( ");" ); + return const_cast( buf.c_str() ); } -void SDAI_Application_instance::PrependEntityErrMsg() -{ +void SDAI_Application_instance::PrependEntityErrMsg() { char errStr[BUFSIZ]; errStr[0] = '\0'; - if(_error.severity() == SEVERITY_NULL) { + if( _error.severity() == SEVERITY_NULL ) { // if there is not an error already - sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName()); - _error.PrependToDetailMsg(errStr); + sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName() ); + _error.PrependToDetailMsg( errStr ); } } @@ -485,39 +463,38 @@ void SDAI_Application_instance::PrependEntityErrMsg() ** instance. i.e. a close quote followed by a semicolon optionally ** having whitespace between them. ******************************************************************/ -void SDAI_Application_instance::STEPread_error(char c, int i, istream &in, const char *schnm) -{ +void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, const char * schnm ) { (void) in; char errStr[BUFSIZ]; errStr[0] = '\0'; - if(_error.severity() == SEVERITY_NULL) { + if( _error.severity() == SEVERITY_NULL ) { // if there is not an error already - sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName()); - _error.PrependToDetailMsg(errStr); + sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName() ); + _error.PrependToDetailMsg( errStr ); } - if((i >= 0) && (i < attributes.list_length())) { // i is an attribute - Error().GreaterSeverity(SEVERITY_WARNING); - sprintf(errStr, " invalid data before type \'%s\'\n", - attributes[i].TypeName()); - _error.AppendToDetailMsg(errStr); + if( ( i >= 0 ) && ( i < attributes.list_length() ) ) { // i is an attribute + Error().GreaterSeverity( SEVERITY_WARNING ); + sprintf( errStr, " invalid data before type \'%s\'\n", + attributes[i].TypeName() ); + _error.AppendToDetailMsg( errStr ); } else { - Error().GreaterSeverity(SEVERITY_INPUT_ERROR); - _error.AppendToDetailMsg(" No more attributes were expected.\n"); + Error().GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error.AppendToDetailMsg( " No more attributes were expected.\n" ); } std::string tmp; - STEPwrite(tmp, schnm); // STEPwrite writes to a static buffer inside function - _error.AppendToDetailMsg(" The invalid instance to this point looks like :\n"); - _error.AppendToDetailMsg(tmp); - _error.AppendToDetailMsg("\nUnexpected character: "); - _error.AppendToDetailMsg(c); - _error.AppendToDetailMsg('\n'); - - sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); - _error.AppendToDetailMsg(errStr); + STEPwrite( tmp, schnm ); // STEPwrite writes to a static buffer inside function + _error.AppendToDetailMsg( " The invalid instance to this point looks like :\n" ); + _error.AppendToDetailMsg( tmp ); + _error.AppendToDetailMsg( "\nUnexpected character: " ); + _error.AppendToDetailMsg( c ); + _error.AppendToDetailMsg( '\n' ); + + sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); + _error.AppendToDetailMsg( errStr ); return; } @@ -535,10 +512,9 @@ void SDAI_Application_instance::STEPread_error(char c, int i, istream &in, const ** Side Effects: gobbles up input stream ** Status: ******************************************************************/ -Severity SDAI_Application_instance::STEPread(int id, int idIncr, - InstMgrBase *instance_set, istream &in, - const char *currSch, bool useTechCor, bool strict) -{ +Severity SDAI_Application_instance::STEPread( int id, int idIncr, + InstMgrBase * instance_set, istream & in, + const char * currSch, bool useTechCor, bool strict ) { STEPfile_id = id; char c = '\0'; char errStr[BUFSIZ]; @@ -546,53 +522,53 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, Severity severe; int i = 0; - ClearError(1); + ClearError( 1 ); in >> ws; in >> c; // read the open paren - if(c != '(') { + if( c != '(' ) { PrependEntityErrMsg(); _error.AppendToDetailMsg( - " Missing initial open paren... Trying to recover.\n"); - in.putback(c); // assume you can recover by reading 1st attr value + " Missing initial open paren... Trying to recover.\n" ); + in.putback( c ); // assume you can recover by reading 1st attr value } - ReadTokenSeparator(in, &p21Comment); + ReadTokenSeparator( in, &p21Comment ); int n = attributes.list_length(); - if(n == 0) { // no attributes + if( n == 0 ) { // no attributes in >> c; // look for the close paren - if(c == ')') { + if( c == ')' ) { return _error.severity(); } } - for(i = 0 ; i < n; i++) { - ReadTokenSeparator(in, &p21Comment); - if(attributes[i].aDesc->AttrType() == AttrType_Redefining) { + for( i = 0 ; i < n; i++ ) { + ReadTokenSeparator( in, &p21Comment ); + if( attributes[i].aDesc->AttrType() == AttrType_Redefining ) { in >> ws; c = in.peek(); - if(!useTechCor) { // i.e. use pre-technical corrigendum encoding + if( !useTechCor ) { // i.e. use pre-technical corrigendum encoding in >> c; // read what should be the '*' in >> ws; - if(c == '*') { + if( c == '*' ) { in >> c; // read the delimiter i.e. ',' or ')' } else { severe = SEVERITY_INCOMPLETE; PrependEntityErrMsg(); // adds entity info if necessary // set the severity for this entity - _error.GreaterSeverity(severe); - sprintf(errStr, " %s : ", attributes[i].Name()); - _error.AppendToDetailMsg(errStr); // add attr name + _error.GreaterSeverity( severe ); + sprintf( errStr, " %s : ", attributes[i].Name() ); + _error.AppendToDetailMsg( errStr ); // add attr name _error.AppendToDetailMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n"); + "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n" ); _error.AppendToUserMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr. "); + "Since using pre-technical corrigendum... missing asterisk for redefined attr. " ); } } else { // using technical corrigendum // should be nothing to do except loop again unless... // if at end need to have read the closing paren. - if(c == ')') { // assume you are at the end so read last char + if( c == ')' ) { // assume you are at the end so read last char in >> c; } cout << "Entity #" << STEPfile_id @@ -602,54 +578,54 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, // increment counter to read following attr since these attrs // aren't written or read => there won't be a delimiter either } else { - attributes[i].STEPread(in, instance_set, idIncr, currSch, strict); + attributes[i].STEPread( in, instance_set, idIncr, currSch, strict ); in >> c; // read the , or ) following the attr read severe = attributes[i].Error().severity(); - if(severe <= SEVERITY_USERMSG) { + if( severe <= SEVERITY_USERMSG ) { // if there is some type of error PrependEntityErrMsg(); // set the severity for this entity - _error.GreaterSeverity(severe); - sprintf(errStr, " %s : ", attributes[i].Name()); - _error.AppendToDetailMsg(errStr); // add attr name - _error.AppendToDetailMsg(attributes[i].Error().DetailMsg()); // add attr error - _error.AppendToUserMsg(attributes[i].Error().UserMsg()); + _error.GreaterSeverity( severe ); + sprintf( errStr, " %s : ", attributes[i].Name() ); + _error.AppendToDetailMsg( errStr ); // add attr name + _error.AppendToDetailMsg( attributes[i].Error().DetailMsg() ); // add attr error + _error.AppendToUserMsg( attributes[i].Error().UserMsg() ); } } // if technical corrigendum redefined, input is at next attribute value // if pre-technical corrigendum redefined, don't process - if((!(attributes[i].aDesc->AttrType() == AttrType_Redefining) || - !useTechCor) && - !((c == ',') || (c == ')'))) { // input is not a delimiter + if( ( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) || + !useTechCor ) && + !( ( c == ',' ) || ( c == ')' ) ) ) { // input is not a delimiter PrependEntityErrMsg(); _error.AppendToDetailMsg( - "Delimiter expected after attribute value.\n"); - if(!useTechCor) { + "Delimiter expected after attribute value.\n" ); + if( !useTechCor ) { _error.AppendToDetailMsg( - "I.e. since using pre-technical corrigendum, redefined "); + "I.e. since using pre-technical corrigendum, redefined " ); _error.AppendToDetailMsg( - "attribute is mapped as an asterisk so needs delimiter.\n"); + "attribute is mapped as an asterisk so needs delimiter.\n" ); } - CheckRemainingInput(in, &_error, "ENTITY", ",)"); - if(!in.good()) { + CheckRemainingInput( in, &_error, "ENTITY", ",)" ); + if( !in.good() ) { return _error.severity(); } - if(_error.severity() <= SEVERITY_INPUT_ERROR) { + if( _error.severity() <= SEVERITY_INPUT_ERROR ) { return _error.severity(); } - } else if(c == ')') { - while(i < n - 1) { + } else if( c == ')' ) { + while( i < n - 1 ) { i++; // check if following attributes are redefined - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { PrependEntityErrMsg(); - _error.AppendToDetailMsg("Missing attribute value[s].\n"); + _error.AppendToDetailMsg( "Missing attribute value[s].\n" ); // recoverable error - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); return _error.severity(); } i++; @@ -657,7 +633,7 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, return _error.severity(); } } - STEPread_error(c, i, in, currSch); + STEPread_error( c, i, in, currSch ); // code fragment imported from STEPread_error // for some currently unknown reason it was commented out of STEPread_error errStr[0] = '\0'; @@ -668,148 +644,144 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, // Search until a close paren is found followed by (skipping optional // whitespace) a semicolon - while(in.good() && !foundEnd) { - while(in.good() && (c != ')')) { - in.get(c); + while( in.good() && !foundEnd ) { + while( in.good() && ( c != ')' ) ) { + in.get( c ); tmp += c; } - if(in.good() && (c == ')')) { + if( in.good() && ( c == ')' ) ) { in >> ws; // skip whitespace - in.get(c); + in.get( c ); tmp += c; - if(c == ';') { + if( c == ';' ) { foundEnd = 1; } } } - _error.AppendToDetailMsg(tmp.c_str()); - sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); - _error.AppendToDetailMsg(errStr); + _error.AppendToDetailMsg( tmp.c_str() ); + sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); + _error.AppendToDetailMsg( errStr ); // end of imported code return _error.severity(); } /// read an entity reference and return a pointer to the SDAI_Application_instance -SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId) -{ +SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ) { char c; char errStr[BUFSIZ]; errStr[0] = '\0'; in >> ws; in >> c; - switch(c) { + switch( c ) { case '@': - err->AppendToDetailMsg("Use of @ instead of # to identify entity.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Use of @ instead of # to identify entity.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); // no break statement here on purpose - [[gnu::fallthrough]]; case '#': { int id = -1; in >> id; - if(in.fail()) { // there's been an error in input - sprintf(errStr, "Invalid entity reference value.\n"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_WARNING); - CheckRemainingInput(in, err, "Entity Reference", tokenList); + if( in.fail() ) { // there's been an error in input + sprintf( errStr, "Invalid entity reference value.\n" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_WARNING ); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); return S_ENTITY_NULL; } else { // found an entity id // check to make sure garbage does not follow the id - CheckRemainingInput(in, err, "Entity Reference", tokenList); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); id += addFileId; - if(!instances) { + if( !instances ) { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - cannot read reference without the InstMgr", - id, "is unknown"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - cannot read reference without the InstMgr", + id, "is unknown" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } // lookup which object has id as its instance id - SDAI_Application_instance *inst; + SDAI_Application_instance * inst; /* If there is a ManagerNode it should have a SDAI_Application_instance */ - MgrNodeBase *mn = 0; - mn = instances->FindFileId(id); - if(mn) { + MgrNodeBase * mn = 0; + mn = instances->FindFileId( id ); + if( mn ) { inst = mn->GetSTEPentity() ; - if(inst) { - return (inst); + if( inst ) { + return ( inst ); } else { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - MgrNode::GetSTEPentity returned NULL pointer", - id, "is unknown"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - MgrNode::GetSTEPentity returned NULL pointer", + id, "is unknown" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } } else { - sprintf(errStr, "Reference to non-existent ENTITY #%d.\n", - id); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( errStr, "Reference to non-existent ENTITY #%d.\n", + id ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_WARNING ); return S_ENTITY_NULL; } } } default: { - in.putback(c); + in.putback( c ); // read past garbage up to delim in tokenList // if tokenList is null it will not read anything - CheckRemainingInput(in, err, "Entity Reference", tokenList); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); return S_ENTITY_NULL; } } } /// 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, - InstMgrBase *instances, int addFileId) -{ - istringstream in((char *)s); - return ReadEntityRef(in, err, tokenList, instances, addFileId); +SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ) { + istringstream in( ( char * )s ); + return ReadEntityRef( in, err, tokenList, instances, addFileId ); } /// return SEVERITY_NULL if se's entity type matches the supplied entity type -Severity EntityValidLevel(SDAI_Application_instance *se, - const TypeDescriptor *ed, // entity type that entity se needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor *err) -{ +Severity EntityValidLevel( SDAI_Application_instance * se, + const TypeDescriptor * ed, // entity type that entity se needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor * err ) { char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; - if(!ed || (ed->NonRefType() != ENTITY_TYPE)) { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel() called with %s", - "missing or invalid EntityDescriptor\n"); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + if( !ed || ( ed->NonRefType() != ENTITY_TYPE ) ) { + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel() called with %s", + "missing or invalid EntityDescriptor\n" ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; } - if(!se || (se == S_ENTITY_NULL)) { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel() called with null pointer %s\n", - "for SDAI_Application_instance argument."); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + if( !se || ( se == S_ENTITY_NULL ) ) { + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel() called with null pointer %s\n", + "for SDAI_Application_instance argument." ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -818,35 +790,35 @@ 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()) { + if( se->IsComplex() ) { // This way assumes that the complex has all it's parts i.e. the // complete hierarchy so it should be able to find ed's part if // it is an ed. - STEPcomplex *sc = ((STEPcomplex *)se)->sc; - if(sc->EntityExists(ed->Name())) { + STEPcomplex * sc = ( ( STEPcomplex * )se )->sc; + if( sc->EntityExists( ed->Name() ) ) { return SEVERITY_NULL; } } - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, - " Entity #%d exists but is not a %s or descendant.\n", - se->STEPfile_id, ed->Name()); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, + " Entity #%d exists but is not a %s or descendant.\n", + se->STEPfile_id, ed->Name() ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); return SEVERITY_WARNING; } } else { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", - se->STEPfile_id, "missing or invalid EntityDescriptor\n"); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", + se->STEPfile_id, "missing or invalid EntityDescriptor\n" ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -857,19 +829,18 @@ Severity EntityValidLevel(SDAI_Application_instance *se, * return 1 if attrValue has the equivalent of a null value. * DAVE: Is this needed will sscanf return 1 if assignment suppression is used? */ -int SetErrOnNull(const char *attrValue, ErrorDescriptor *error) -{ +int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ) { char scanBuf[BUFSIZ]; scanBuf[0] = '\0'; std::stringstream fmtstr; - fmtstr << " %" << BUFSIZ - 1 << "s "; + fmtstr << " %" << BUFSIZ -1 << "s "; //fmtstr contains " %ns " where n is BUFSIZ -1 - int numFound = sscanf((char *)attrValue, fmtstr.str().c_str(), scanBuf); + int numFound = sscanf( ( char * )attrValue , fmtstr.str().c_str() , scanBuf ); - if(numFound == EOF) { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + if( numFound == EOF ) { + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return 1; } return 0; @@ -881,73 +852,69 @@ int SetErrOnNull(const char *attrValue, ErrorDescriptor *error) ** without the # sign: e.g. either #23 or 23 will be read. ** If non-whitespace characters follow the entity reference an error is set. */ -Severity EntityValidLevel(const char *attrValue, // string contain entity ref - const TypeDescriptor *ed, // entity type that entity in - // attrValue (if it exists) needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor *err, InstMgrBase *im, int clearError) -{ +Severity EntityValidLevel( const char * attrValue, // string contain entity ref + const TypeDescriptor * ed, // entity type that entity in + // attrValue (if it exists) needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor * err, InstMgrBase * im, int clearError ) { char tmp [BUFSIZ]; tmp[0] = '\0'; char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; std::stringstream fmtstr1, fmtstr2; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } int fileId; - MgrNodeBase *mn = 0; + MgrNodeBase * mn = 0; // fmtstr1 contains "#%d %ns" where n is BUFSIZ-1 fmtstr1 << " #%d %" << BUFSIZ - 1 << "s "; // fmtstr2 contains "%d %ns" where n is BUFSIZ-1 fmtstr2 << " %d %" << BUFSIZ - 1 << "s "; - + // check for both forms: #id or id - int found1 = sscanf((char *)attrValue, fmtstr1.str().c_str(), &fileId, tmp); - int found2 = sscanf((char *)attrValue, fmtstr2.str().c_str(), &fileId, tmp); - - if((found1 > 0) || (found2 > 0)) { - if((found1 == 2) || (found2 == 2)) { - int ocnt = snprintf(messageBuf, BUFSIZ, - " Attribute's Entity Reference %s is %s data \'%s\'.\n", - attrValue, "followed by invalid", tmp); - if(ocnt < BUFSIZ) { - fprintf(stderr, "Warning - truncation of Attribute's Entry Reference msg\n"); - } - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + int found1 = sscanf( ( char * )attrValue, fmtstr1.str().c_str() , &fileId, tmp ); + int found2 = sscanf( ( char * )attrValue, fmtstr2.str().c_str() , &fileId, tmp ); + + if( ( found1 > 0 ) || ( found2 > 0 ) ) { + if( ( found1 == 2 ) || ( found2 == 2 ) ) { + sprintf( messageBuf, + " Attribute's Entity Reference %s is %s data \'%s\'.\n", + attrValue, "followed by invalid", tmp ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); } - mn = im->FindFileId(fileId); - if(mn) { - SDAI_Application_instance *se = mn->GetSTEPentity(); - return EntityValidLevel(se, ed, err); + mn = im->FindFileId( fileId ); + if( mn ) { + SDAI_Application_instance * se = mn->GetSTEPentity(); + return EntityValidLevel( se, ed, err ); } else { - sprintf(messageBuf, - " Attribute's Entity Reference %s does not exist.\n", - attrValue); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( messageBuf, + " Attribute's Entity Reference %s does not exist.\n", + attrValue ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } } // if the attrValue contains no value return - if(SetErrOnNull(attrValue, err)) { + if( SetErrOnNull( attrValue, err ) ) { return err->severity(); } - sprintf(messageBuf, "Invalid attribute entity reference value: '%s'.\n", - attrValue); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( messageBuf, "Invalid attribute entity reference value: '%s'.\n", + attrValue ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } @@ -957,52 +924,47 @@ Severity EntityValidLevel(const char *attrValue, // string contain entity ref ** Status: untested 7/31/90 ** \Returns reference to an attribute pointer ******************************************************************/ -STEPattribute *SDAI_Application_instance::NextAttribute() -{ +STEPattribute * SDAI_Application_instance::NextAttribute() { int i = AttributeCount(); ++_cur; - if(i < _cur) { + if( i < _cur ) { return 0; } return &attributes [_cur - 1]; } -int SDAI_Application_instance::AttributeCount() -{ +int SDAI_Application_instance::AttributeCount() { return attributes.list_length(); } -const iAstruct SDAI_Application_instance::getInvAttr(const Inverse_attribute *const ia) const -{ +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()) { + 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 -{ +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)) { + 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((Inverse_attribute *) NULL, z); + memset( &z, 0, sizeof z ); + iAMap_t::value_type nil( (Inverse_attribute *) nullptr, z ); return nil; } -void SDAI_Application_instance::setInvAttr(const Inverse_attribute *const ia, const iAstruct ias) -{ +void SDAI_Application_instance::setInvAttr( const Inverse_attribute * const ia, const iAstruct ias ) { iAMap_t::iterator it = iAMap.find(ia); - if(it != iAMap.end()) { + if( it != iAMap.end() ) { it->second = ias; } else { - iAMap.insert(iAMap_t::value_type(ia, ias)); + iAMap.insert( iAMap_t::value_type( ia, ias ) ); } } diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index 991e06fa8..70b7b3308 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -22,23 +22,22 @@ class EntityAggregate; class Inverse_attribute; typedef struct { union { - EntityAggregate *a; - SDAI_Application_instance *i; + EntityAggregate * a; + SDAI_Application_instance * i; }; } iAstruct; /** @class * this used to be STEPentity */ -class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI -{ +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; - const EntityDescriptor *eDesc; + typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t; protected: + const EntityDescriptor * eDesc; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -52,10 +51,10 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI public: //TODO make these private? STEPattributeList attributes; - /* see mgrnode.cc where -1 is returned when there is no sdai - * instance. might be possible to treat 0 for this purpose - * instead of negative so the ID's can become unsigned. - */ + /* see mgrnode.cc where -1 is returned when there is no sdai + * instance. might be possible to treat 0 for this purpose + * instead of negative so the ID's can become unsigned. + */ int STEPfile_id; ErrorDescriptor _error; @@ -75,152 +74,140 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI ** and head points at the root SDAI_Application_instance of the primary inheritance ** path (the one that is the root of the leaf entity). */ - SDAI_Application_instance *headMiEntity; + SDAI_Application_instance * headMiEntity; /// these form a chain of other entity parents for multiple inheritance - SDAI_Application_instance *nextMiEntity; + SDAI_Application_instance * nextMiEntity; public: SDAI_Application_instance(); - SDAI_Application_instance(int fileid, int complex = 0); + SDAI_Application_instance( int fileid, int complex = 0 ); virtual ~SDAI_Application_instance(); - bool IsComplex() const - { + bool IsComplex() const { return _complex; } /// initialize inverse attribute list void InitIAttrs(); - void StepFileId(int fid) - { + void setEDesc( const EntityDescriptor * const ed ) { + eDesc = ed; + } + const EntityDescriptor * getEDesc() const; + void StepFileId( int fid ) { STEPfile_id = fid; } - int StepFileId() const - { + int StepFileId() const { return STEPfile_id; } - void AddP21Comment(const std::string &s, bool replace = true); - void AddP21Comment(const char *s, bool replace = true); - void PrependP21Comment(const std::string &s); - void DeleteP21Comment() - { + void AddP21Comment( const std::string & s, bool replace = true ); + void AddP21Comment( const char * s, bool replace = true ); + void PrependP21Comment( const std::string & s ); + void DeleteP21Comment() { p21Comment = ""; } - std::string P21Comment() const - { + std::string P21Comment() const { return p21Comment; } - const char *EntityName(const char *schnm = NULL) const; + const char * EntityName( const char * schnm = NULL ) const; - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; - virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError = 1); - ErrorDescriptor &Error() - { + virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError = 1 ); + ErrorDescriptor & Error() { return _error; } // clears entity's error and optionally all attr's errors - void ClearError(int clearAttrs = 1); + void ClearError( int clearAttrs = 1 ); // clears all attr's errors void ClearAttrError(); - virtual SDAI_Application_instance *Replicate(); + virtual SDAI_Application_instance * Replicate(); // ACCESS attributes in order. int AttributeCount(); - STEPattribute *NextAttribute(); - void ResetAttributes() - { + STEPattribute * NextAttribute(); + 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 - { + 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 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); + virtual Severity STEPread( int id, int addFileId, + 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(std::ostream &out = std::cout, const char *currSch = NULL, - int writeComments = 1); - virtual const char *STEPwrite(std::string &buf, 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(std::ostream &out, const char *currSch = NULL, - int writeComments = 1, int mixedCase = 1); + void WriteValuePairs( std::ostream & out, const char * currSch = NULL, + int writeComments = 1, int mixedCase = 1 ); - void STEPwrite_reference(std::ostream &out = std::cout); - const char *STEPwrite_reference(std::string &buf); + void STEPwrite_reference( std::ostream & out = std::cout ); + const char * STEPwrite_reference( std::string & buf ); - void beginSTEPwrite(std::ostream &out = std::cout); ///< writes out the SCOPE section - void endSTEPwrite(std::ostream &out = std::cout); + void beginSTEPwrite( std::ostream & out = std::cout ); ///< writes out the SCOPE section + void endSTEPwrite( std::ostream & out = std::cout ); // MULTIPLE INHERITANCE - int MultipleInheritance() - { - return !(headMiEntity == 0); + int MultipleInheritance() { + return !( headMiEntity == 0 ); } - void HeadEntity(SDAI_Application_instance *se) - { + void HeadEntity( SDAI_Application_instance * se ) { headMiEntity = se; } - SDAI_Application_instance *HeadEntity() - { + SDAI_Application_instance * HeadEntity() { return headMiEntity; } - SDAI_Application_instance *GetNextMiEntity() - { + SDAI_Application_instance * GetNextMiEntity() { return nextMiEntity; } - SDAI_Application_instance *GetMiEntity(char *entName); - void AppendMultInstance(SDAI_Application_instance *se); + SDAI_Application_instance * GetMiEntity( char * entName ); + void AppendMultInstance( SDAI_Application_instance * se ); protected: - STEPattribute *GetSTEPattribute(const char *nm, const char *entity = NULL); - STEPattribute *MakeDerived(const char *nm, const char *entity = NULL); - STEPattribute *MakeRedefined(STEPattribute *redefiningAttr, - const char *nm); + STEPattribute * GetSTEPattribute( const char * nm, const char * entity = NULL ); + STEPattribute * MakeDerived( const char * nm, const char * entity = NULL ); + STEPattribute * MakeRedefined( STEPattribute * redefiningAttr, + const char * nm ); - virtual void CopyAs(SDAI_Application_instance *); + virtual void CopyAs( SDAI_Application_instance * ); void PrependEntityErrMsg(); public: // these functions are going to go away in the future. - int SetFileId(int fid) - { + int SetFileId( int fid ) { return STEPfile_id = fid; } - int GetFileId() const - { + int GetFileId() const { return STEPfile_id; } - int FileId(int fid) - { + int FileId( int fid ) { return STEPfile_id = fid; } - int FileId() const - { + int FileId() const { return STEPfile_id; } }; // current style of CORBA handles for Part 23 - NOTE - used for more than CORBA -typedef SDAI_Application_instance *SDAI_Application_instance_ptr; +typedef SDAI_Application_instance * SDAI_Application_instance_ptr; typedef SDAI_Application_instance_ptr SDAI_Application_instance_var; -SC_CORE_EXPORT bool isNilSTEPentity(const SDAI_Application_instance *ai); +SC_CORE_EXPORT bool isNilSTEPentity( const SDAI_Application_instance * ai ); #endif //STEPENTITY_H diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 1d1d741ce..08e789a6d 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -19,23 +19,21 @@ #ifdef SC_LOGGING #include -extern ofstream *logStream; +extern ofstream * logStream; #endif /********** (member) functions for the select class SDAI_Select **********/ -SDAI_Select::SDAI_Select(const SelectTypeDescriptor *s, - const TypeDescriptor *td) - : _type(s), underlying_type(td) -{ +SDAI_Select::SDAI_Select( const SelectTypeDescriptor * s, + const TypeDescriptor * td ) + : _type( s ), underlying_type( td ) { #ifdef SC_LOGGING *logStream << "Exiting SDAI_Select constructor." << endl; #endif } -SDAI_Select::SDAI_Select(const SDAI_Select &other) -{ +SDAI_Select::SDAI_Select( const SDAI_Select & other ) { underlying_type = other.underlying_type; base_type = other.base_type; _type = other._type; @@ -44,13 +42,11 @@ SDAI_Select::SDAI_Select(const SDAI_Select &other) #endif } -SDAI_Select::~SDAI_Select() -{ +SDAI_Select::~SDAI_Select() { } -SDAI_Select &SDAI_Select::operator=(const SDAI_Select &other) -{ - if(&other != this) { +SDAI_Select & SDAI_Select::operator=( const SDAI_Select & other ) { + if( &other != this ) { _error = other._error; _type = other._type; base_type = other.base_type; @@ -60,101 +56,88 @@ SDAI_Select &SDAI_Select::operator=(const SDAI_Select &other) return *this; } -Severity SDAI_Select::severity() const -{ +Severity SDAI_Select::severity() const { return _error.severity(); } -Severity SDAI_Select::severity(Severity s) -{ - return _error.severity(s); +Severity SDAI_Select::severity( Severity s ) { + return _error.severity( s ); } -std::string SDAI_Select::Error() -{ +std::string SDAI_Select::Error() { return _error.DetailMsg(); } -void SDAI_Select::Error(const char *e) -{ - _error.DetailMsg(e); +void SDAI_Select::Error( const char * e ) { + _error.DetailMsg( e ); } -void SDAI_Select::ClearError() -{ +void SDAI_Select::ClearError() { _error.ClearErrorMsg(); } const TypeDescriptor * -SDAI_Select::CanBe(const char *n) const -{ - return _type -> CanBe(n); +SDAI_Select::CanBe( const char * n ) const { + return _type -> CanBe( n ); } const TypeDescriptor * -SDAI_Select::CanBe(BASE_TYPE bt) const -{ - const TypeDescLinkNode *tdn = - (const TypeDescLinkNode *) _type -> GetElements().GetHead(); - const TypeDescriptor *td = tdn -> TypeDesc(); +SDAI_Select::CanBe( BASE_TYPE bt ) const { + const TypeDescLinkNode * tdn = + ( const TypeDescLinkNode * ) _type -> GetElements().GetHead(); + const TypeDescriptor * td = tdn -> TypeDesc(); BASE_TYPE bt_thisnode; - while(tdn) { + while( tdn ) { td = tdn -> TypeDesc(); - if(((bt_thisnode = td -> NonRefType()) == bt) || - (bt == AGGREGATE_TYPE && ((bt_thisnode == ARRAY_TYPE) || - (bt_thisnode == LIST_TYPE) || - (bt_thisnode == SET_TYPE) || - (bt_thisnode == BAG_TYPE)))) { + if( ( ( bt_thisnode = td -> NonRefType() ) == bt ) || + ( bt == AGGREGATE_TYPE && ( ( bt_thisnode == ARRAY_TYPE ) || + ( bt_thisnode == LIST_TYPE ) || + ( bt_thisnode == SET_TYPE ) || + ( bt_thisnode == BAG_TYPE ) ) ) ) { return td; // they are the same } - tdn = (TypeDescLinkNode *)(tdn -> NextNode()); + tdn = ( TypeDescLinkNode * )( tdn -> NextNode() ); } return 0; } const TypeDescriptor * -SDAI_Select::CanBe(const TypeDescriptor *td) const -{ - return _type -> CanBe(td); +SDAI_Select::CanBe( const TypeDescriptor * td ) const { + return _type -> CanBe( td ); } const TypeDescriptor * -SDAI_Select::CanBeSet(const char *n, const char *schnm) const -{ - return _type -> CanBeSet(n, schnm); +SDAI_Select::CanBeSet( const char * n, const char * schnm ) const { + return _type -> CanBeSet( n, schnm ); } int -SDAI_Select::IsUnique(const BASE_TYPE bt) const -{ - if(bt == ARRAY_TYPE || +SDAI_Select::IsUnique( const BASE_TYPE bt ) const { + if( bt == ARRAY_TYPE || bt == LIST_TYPE || bt == BAG_TYPE || - bt == SET_TYPE) { - return ((_type->UniqueElements()) & AGGREGATE_TYPE); + bt == SET_TYPE ) { + return ( ( _type->UniqueElements() ) & AGGREGATE_TYPE ); } else { - return ((_type->UniqueElements()) & bt); + return ( ( _type->UniqueElements() ) & bt ); } } -SDAI_String SDAI_Select::UnderlyingTypeName() const -{ +SDAI_String SDAI_Select::UnderlyingTypeName() const { return underlying_type -> Name(); } -const TypeDescriptor *SDAI_Select::CurrentUnderlyingType() const -{ +const TypeDescriptor * SDAI_Select::CurrentUnderlyingType() const { return underlying_type; } const TypeDescriptor * -SDAI_Select::SetUnderlyingType(const TypeDescriptor *td) -{ +SDAI_Select::SetUnderlyingType( const TypeDescriptor * td ) { // don\'t do anything if the descriptor is bad - if(!td || !(_type -> CanBe(td))) { + if( !td || !( _type -> CanBe( td ) ) ) { return 0; } @@ -163,49 +146,45 @@ SDAI_Select::SetUnderlyingType(const TypeDescriptor *td) return underlying_type = td; } -bool SDAI_Select::exists() const -{ +bool SDAI_Select::exists() const { return underlying_type != NULL; } -void SDAI_Select::nullify() -{ +void SDAI_Select::nullify() { underlying_type = 0; } -Severity SDAI_Select::SelectValidLevel(const char *attrValue, ErrorDescriptor *err, - InstMgrBase *im) -{ - SDAI_Select *tmp = NewSelect(); +Severity SDAI_Select::SelectValidLevel( const char * attrValue, ErrorDescriptor * err, + InstMgrBase * im ) { + SDAI_Select * tmp = NewSelect(); Severity s = SEVERITY_NULL; - istringstream strtmp(attrValue); - s = tmp -> STEPread(strtmp, err, im); + istringstream strtmp( attrValue ); + s = tmp -> STEPread( strtmp, err, im ); delete tmp; return s; } -Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, - ErrorDescriptor *err, InstMgrBase *instances) -{ - severity(SEVERITY_NULL); - if(SetUnderlyingType(CanBe(selectType))) +Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, + ErrorDescriptor * err, InstMgrBase * instances ) { + severity( SEVERITY_NULL ); + if( SetUnderlyingType( CanBe( selectType ) ) ) // the underlying type is set to a valid type // call read on underlying type in subclass - switch(base_type) { + switch( base_type ) { case ENTITY_TYPE: { - STEPentity *tmp = - ReadEntityRef(Val, err, ",)", instances, 0); - if(tmp && (tmp != ENTITY_NULL)) { - AssignEntity(tmp); + STEPentity * tmp = + ReadEntityRef( Val, err, ",)", instances, 0 ); + if( tmp && ( tmp != ENTITY_NULL ) ) { + AssignEntity( tmp ); return severity(); } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n"); + "Reference to entity that is not a valid type for SELECT.\n" ); nullify(); - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } } @@ -221,9 +200,9 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, case SELECT_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: { - err->GreaterSeverity(StrToVal_content(Val, instances)); - if(_error.severity() != SEVERITY_NULL) { - err->AppendFromErrorArg(&_error); + err->GreaterSeverity( StrToVal_content( Val, instances ) ); + if( _error.severity() != SEVERITY_NULL ) { + err->AppendFromErrorArg( &_error ); } return err->severity(); } @@ -234,10 +213,10 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, case REAL_TYPE: case INTEGER_TYPE: default: { - istringstream strtmp(Val); - err->GreaterSeverity(STEPread_content(strtmp)); - if(_error.severity() != SEVERITY_NULL) { - err->AppendFromErrorArg(&_error); + istringstream strtmp( Val ); + err->GreaterSeverity( STEPread_content( strtmp ) ); + if( _error.severity() != SEVERITY_NULL ) { + err->AppendFromErrorArg( &_error ); } return err->severity(); } @@ -248,10 +227,9 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, /** updated to Technical Corrigendum. DAS 2/4/97 * This function does the following: */ -Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, - InstMgrBase *instances, const char *utype, - int addFileId, const char *currSch) -{ +Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, + InstMgrBase * instances, const char * utype, + int addFileId, const char * currSch ) { char c = '\0'; std::string tmp; @@ -268,19 +246,19 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** select types, then the text is passed down to each select in the utype ** parameter as STEPread is called on each contained select type.DAS 2/4/97 */ - if(utype) { - if(SetUnderlyingType(CanBeSet(utype, currSch))) { + if( utype ) { + if( SetUnderlyingType( CanBeSet( utype, currSch ) ) ) { // assign the value to the underlying type in >> ws; // skip white space - if((underlying_type->Type() == REFERENCE_TYPE) && - (underlying_type->NonRefType() == sdaiSELECT)) { + if( ( underlying_type->Type() == REFERENCE_TYPE ) && + ( underlying_type->NonRefType() == sdaiSELECT ) ) { // See comments below for a similar code segment. - STEPread_content(in, instances, 0, addFileId, currSch); + STEPread_content( in, instances, 0, addFileId, currSch ); } else { - STEPread_content(in, instances, utype, addFileId, currSch); + STEPread_content( in, instances, utype, addFileId, currSch ); } - err->AppendToDetailMsg(Error()); - err->GreaterSeverity(severity()); + err->AppendToDetailMsg( Error() ); + err->GreaterSeverity( severity() ); } return err->severity(); } @@ -305,11 +283,11 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** will cause the contained Select STEPread function to read it. DAS 2/4/97 */ - if(isalpha(c)) { // case B + if( isalpha( c ) ) { // case B int eot = 0; // end of token flag // token is a type name - get the type - while((c != '(') && in.good()) { - if(!eot && !(eot = isspace(c))) + while( ( c != '(' ) && in.good() ) { + if( !eot && !( eot = isspace( c ) ) ) // as long as eot hasn\'t been reached keep appending { tmp += c; @@ -318,7 +296,7 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, } // check for valid type and set the underlying type - if(SetUnderlyingType(CanBeSet(tmp.c_str(), currSch))) { + if( SetUnderlyingType( CanBeSet( tmp.c_str(), currSch ) ) ) { /** ** Assign the value to the underlying type. CanBeSet() is a ** slightly modified CanBe(). It ensures that a renamed select @@ -329,8 +307,8 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** case if "selX" appears first and is what we just read. */ in >> ws; // skip white space - if((underlying_type->Type() == REFERENCE_TYPE) && - (underlying_type->NonRefType() == sdaiSELECT)) { + if( ( underlying_type->Type() == REFERENCE_TYPE ) && + ( underlying_type->NonRefType() == sdaiSELECT ) ) { /** * This means (1) that the underlying type is itself a select ** (cond 2), and (2) it's not defined in the EXPRESS as a @@ -345,7 +323,7 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** would appear (according to TC) and we already read the value ** of sel1. If so, we pass the already-read value down. */ - STEPread_content(in, instances, 0, addFileId, currSch); + STEPread_content( in, instances, 0, addFileId, currSch ); } else { /** ** In most cases (see above note), we've already read the value @@ -353,19 +331,19 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** This also handles all other cases? other than the if part ** above and elements of type entity ref? */ - STEPread_content(in, instances, tmp.c_str(), addFileId, - currSch); + STEPread_content( in, instances, tmp.c_str(), addFileId, + currSch ); // STEPread_content uses the ErrorDesc data member from the // SDAI_Select class } - err->AppendToDetailMsg(Error()); - err->GreaterSeverity(severity()); + err->AppendToDetailMsg( Error() ); + err->GreaterSeverity( severity() ); in >> ws >> c; - if(c != ')') { + if( c != ')' ) { err->AppendToDetailMsg( - "Bad data or missing closing ')' for SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); - in.putback(c); + "Bad data or missing closing ')' for SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); + in.putback( c ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -376,16 +354,16 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, #endif return err->severity(); } else { // ERROR -- the type wasn't one of the choices - if(!in.good()) { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + if( !in.good() ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_INPUT_ERROR; } else { err->AppendToDetailMsg( - "The type name for the SELECT type is not valid.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + "The type name for the SELECT type is not valid.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -402,10 +380,10 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, */ else { /// case A - switch(c) { + switch( c ) { case '$': nullify(); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -414,9 +392,9 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case ',': case '\0': // ERROR IN INPUT - in.putback(c); - err->AppendToDetailMsg("No value found for SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + in.putback( c ); + err->AppendToDetailMsg( "No value found for SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -424,44 +402,44 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case '.': // assign enum base_type = ENUM_TYPE; - err->AppendToDetailMsg("Invalid Enumeration, Logical, or Boolean value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid Enumeration, Logical, or Boolean value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; - // set the underlying type - // call STEPread - // return + // set the underlying type + // call STEPread + // return case '\'': // assign string base_type = STRING_TYPE; - err->AppendToDetailMsg("Invalid String value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid String value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; case '"': // assign string base_type = BINARY_TYPE; - err->AppendToDetailMsg("Invalid Binary value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid Binary value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; case '#': base_type = ENTITY_TYPE; break; - // call STEPread_reference - // set the underlying type + // call STEPread_reference + // set the underlying type - // assign entity - // read the reference - // match type to underlying type - // assign the value - // set the underlying type + // assign entity + // read the reference + // match type to underlying type + // assign the value + // set the underlying type case '(': { - err->AppendToDetailMsg("Invalid aggregate value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid aggregate value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); char n; in >> n; - in.putback(n); - if(isalpha(n)) { + in.putback( n ); + if( isalpha( n ) ) { base_type = SELECT_TYPE; } else { base_type = AGGREGATE_TYPE; @@ -480,9 +458,9 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case '8': case '9': case '-': - err->AppendToDetailMsg("Invalid Integer or Real value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); - if(CanBe(REAL_TYPE)) { + err->AppendToDetailMsg( "Invalid Integer or Real value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); + if( CanBe( REAL_TYPE ) ) { base_type = REAL_TYPE; } else { base_type = INTEGER_TYPE; @@ -492,54 +470,54 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, default: // ambiguous - ERROR: underlying type should have been set err->AppendToDetailMsg( - "type for SELECT could not be determined from value.\n"); + "type for SELECT could not be determined from value.\n" ); nullify(); - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - in.putback(c); + in.putback( c ); // now the type descriptor should be derivable from the base_type // if it's not issue a warning - if(_type && !(IsUnique(base_type))) { - err->AppendToDetailMsg("Value for SELECT will be assigned to first possible choice.\n"); - err->GreaterSeverity(SEVERITY_USERMSG); + if( _type && !( IsUnique( base_type ) ) ) { + err->AppendToDetailMsg( "Value for SELECT will be assigned to first possible choice.\n" ); + err->GreaterSeverity( SEVERITY_USERMSG ); } - if(base_type == ENTITY_TYPE) { + if( base_type == ENTITY_TYPE ) { // you don't know if this is an ENTITY or a SELECT // have to do this here - not in STEPread_content - STEPentity *temp = - ReadEntityRef(in, err, ",)", instances, addFileId); - if(temp && (temp != ENTITY_NULL) && AssignEntity(temp)) { + STEPentity * temp = + ReadEntityRef( in, err, ",)", instances, addFileId ); + if( temp && ( temp != ENTITY_NULL ) && AssignEntity( temp ) ) { #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_NULL; } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n"); + "Reference to entity that is not a valid type for SELECT.\n" ); nullify(); - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - } else if(SetUnderlyingType(CanBe(base_type))) { - STEPread_content(in, instances, 0, addFileId); + } else if( SetUnderlyingType( CanBe( base_type ) ) ) { + STEPread_content( in, instances, 0, addFileId ); } else { // ERROR -- the type wasn't one of the choices err->AppendToDetailMsg( - "The type of the SELECT type is not valid.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + "The type of the SELECT type is not valid.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -555,25 +533,24 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, /// updated to Technical Corrigendum DAS Feb 4, 1997 -void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const -{ - if(!exists()) { +void SDAI_Select::STEPwrite( ostream & out, const char * currSch ) const { + if( !exists() ) { out << "$"; return; } - switch(underlying_type->NonRefType()) { + switch( underlying_type->NonRefType() ) { case sdaiINSTANCE: { - STEPwrite_content(out); + STEPwrite_content( out ); break; } case sdaiSELECT: { // The name of a select is never written DAS 1/31/97 - if(underlying_type->Type() == REFERENCE_TYPE) { + if( underlying_type->Type() == REFERENCE_TYPE ) { std::string s; - out << StrToUpper(underlying_type->Name(currSch), s) << "("; - STEPwrite_content(out, currSch); + out << StrToUpper( underlying_type->Name( currSch ), s ) << "("; + STEPwrite_content( out, currSch ); out << ")"; } else { - STEPwrite_content(out, currSch); + STEPwrite_content( out, currSch ); } break; } @@ -590,7 +567,7 @@ void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const case BAG_TYPE: case SET_TYPE: case LIST_TYPE: { - STEPwrite_verbose(out, currSch); + STEPwrite_verbose( out, currSch ); break; } case REFERENCE_TYPE: // this should never happen? DAS @@ -600,30 +577,26 @@ void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const } } -void SDAI_Select::STEPwrite_verbose(ostream &out, const char *currSch) const -{ +void SDAI_Select::STEPwrite_verbose( ostream & out, const char * currSch ) const { std::string tmp; - out << StrToUpper(CurrentUnderlyingType()->Name(currSch), tmp) << "("; - STEPwrite_content(out); + out << StrToUpper( CurrentUnderlyingType()->Name( currSch ), tmp ) << "("; + STEPwrite_content( out ); out << ")"; } -const char *SDAI_Select::STEPwrite(std::string &s, const char *currSch) const -{ +const char * SDAI_Select::STEPwrite( std::string & s, const char * currSch ) const { ostringstream buf; - STEPwrite(buf, currSch); + STEPwrite( buf, currSch ); buf << ends; // add the terminating \0 char s = buf.str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -bool SDAI_Select::set_null() -{ +bool SDAI_Select::set_null() { nullify(); return true; } -bool SDAI_Select::is_null() -{ - return (!exists()); +bool SDAI_Select::is_null() { + return ( !exists() ); } diff --git a/src/clstepcore/sdaiSelect.h b/src/clstepcore/sdaiSelect.h index c0c50ed42..04307b1f4 100644 --- a/src/clstepcore/sdaiSelect.h +++ b/src/clstepcore/sdaiSelect.h @@ -17,33 +17,32 @@ /** ** \file sdaiSelect.h class definition for the select superclass SDAI_Select. **/ -class SC_CORE_EXPORT SDAI_Select -{ +class SC_CORE_EXPORT SDAI_Select { protected: - const SelectTypeDescriptor *_type; - const TypeDescriptor *underlying_type; + const SelectTypeDescriptor * _type; + const TypeDescriptor * underlying_type; BASE_TYPE base_type; // used by the subtypes // it looks like this member, val, is not used anywhere 9/27/96 - DAS SDAI_String val; ErrorDescriptor _error; - const TypeDescriptor *SetUnderlyingType(const TypeDescriptor *); + const TypeDescriptor * SetUnderlyingType( const TypeDescriptor * ); - const TypeDescriptor *CanBe(const char *) const; - const TypeDescriptor *CanBe(BASE_TYPE) const; - const TypeDescriptor *CanBe(const TypeDescriptor *td) const; - const TypeDescriptor *CanBeSet(const char *, const char *) const; + const TypeDescriptor * CanBe( const char * ) const; + const TypeDescriptor * CanBe( BASE_TYPE ) const; + const TypeDescriptor * CanBe( const TypeDescriptor * td ) const; + const TypeDescriptor * CanBeSet( const char *, const char * ) const; - int IsUnique(const BASE_TYPE bt) const; + int IsUnique( const BASE_TYPE bt ) const; - virtual const TypeDescriptor *AssignEntity(SDAI_Application_instance *se) = 0; - virtual SDAI_Select *NewSelect() = 0; + virtual const TypeDescriptor * AssignEntity( SDAI_Application_instance * se ) = 0; + virtual SDAI_Select * NewSelect() = 0; public: Severity severity() const; - Severity severity(Severity); + Severity severity( Severity ); std::string Error(); - void Error(const char *); + void Error( const char * ); // clears select's error void ClearError(); // clears error @@ -51,50 +50,50 @@ class SC_CORE_EXPORT SDAI_Select virtual BASE_TYPE ValueType() const = 0; // constructors - SDAI_Select(const SelectTypeDescriptor *s = 0, - const TypeDescriptor *td = 0); - SDAI_Select(const SDAI_Select &other); + SDAI_Select( const SelectTypeDescriptor * s = 0, + const TypeDescriptor * td = 0 ); + SDAI_Select( const SDAI_Select & other ); virtual ~SDAI_Select(); // from SDAI binding SDAI_String UnderlyingTypeName() const; - const TypeDescriptor *CurrentUnderlyingType() const; + const TypeDescriptor * CurrentUnderlyingType() const; bool exists() const; void nullify(); - Severity SelectValidLevel(const char *attrValue, ErrorDescriptor *err, - InstMgrBase *im); + Severity SelectValidLevel( const char * attrValue, ErrorDescriptor * err, + InstMgrBase * im ); // reading and writing - const char *STEPwrite(std::string &s, const char *currSch = 0) const; - void STEPwrite(ostream &out = cout, const char *currSch = 0) const; + const char * STEPwrite( std::string & s, const char * currSch = 0 ) const; + void STEPwrite( ostream & out = cout, const char * currSch = 0 ) const; // IMS 8/2/95: added as part of new select implementation - virtual void STEPwrite_verbose(ostream &out = cout, const char * = 0) + virtual void STEPwrite_verbose( ostream & out = cout, const char * = 0 ) const; - virtual void STEPwrite_content(ostream &out, const char * = 0) const = 0; + virtual void STEPwrite_content( ostream & out, const char * = 0 ) const = 0; - Severity StrToVal(const char *val, const char *selectType, - ErrorDescriptor *err, InstMgrBase *instances = 0); - virtual Severity StrToVal_content(const char *, - InstMgrBase *instances = 0) = 0; + Severity StrToVal( const char * val, const char * selectType, + ErrorDescriptor * err, InstMgrBase * instances = 0 ); + virtual Severity StrToVal_content( const char *, + InstMgrBase * instances = 0 ) = 0; - Severity STEPread(istream &in, ErrorDescriptor *err, - InstMgrBase *instances = 0, const char *utype = 0, - int addFileId = 0, const char * = NULL); + Severity STEPread( istream & in, ErrorDescriptor * err, + InstMgrBase * instances = 0, const char * utype = 0, + int addFileId = 0, const char * = NULL ); // abstract function - virtual Severity STEPread_content(istream &in = cin, - InstMgrBase *instances = 0, - const char *utype = 0, - int addFileId = 0, - const char *currSch = 0) = 0; + virtual Severity STEPread_content( istream & in = cin, + InstMgrBase * instances = 0, + const char * utype = 0, + int addFileId = 0, + const char * currSch = 0 ) = 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); + virtual SDAI_Select & operator =( const SDAI_Select & other ); //FIXME set_null always returns true. why not void?! bool set_null(); @@ -102,7 +101,7 @@ class SC_CORE_EXPORT SDAI_Select }; /** end class **/ -typedef SDAI_Select *SDAI_Select_ptr; +typedef SDAI_Select * SDAI_Select_ptr; typedef SDAI_Select_ptr SDAI_Select_var; #endif diff --git a/src/clstepcore/selectTypeDescriptor.cc b/src/clstepcore/selectTypeDescriptor.cc index f4c9d1f6d..a7c0ad032 100644 --- a/src/clstepcore/selectTypeDescriptor.cc +++ b/src/clstepcore/selectTypeDescriptor.cc @@ -4,18 +4,16 @@ // SelectTypeDescriptor functions /////////////////////////////////////////////////////////////////////////////// -SDAI_Select *SelectTypeDescriptor::CreateSelect() -{ - if(CreateNewSelect) { +SDAI_Select * SelectTypeDescriptor::CreateSelect() { + if( CreateNewSelect ) { return CreateNewSelect(); } else { return 0; } } -const TypeDescriptor *SelectTypeDescriptor::IsA(const TypeDescriptor *other) const -{ - return TypeDescriptor::IsA(other); +const TypeDescriptor * SelectTypeDescriptor::IsA( const TypeDescriptor * other ) const { + return TypeDescriptor::IsA( other ); } /** @@ -23,16 +21,15 @@ const TypeDescriptor *SelectTypeDescriptor::IsA(const TypeDescriptor *other) con * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor *SelectTypeDescriptor::CanBe(const TypeDescriptor *other) const -{ - if(this == other) { +const TypeDescriptor * SelectTypeDescriptor::CanBe( const TypeDescriptor * other ) const { + if( this == other ) { return other; } - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = elements.NextTypeDesc(); - while(td) { - if(td -> CanBe(other)) { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = elements.NextTypeDesc(); + while( td ) { + if( td -> CanBe( other ) ) { return td; } td = elements.NextTypeDesc(); @@ -45,19 +42,18 @@ const TypeDescriptor *SelectTypeDescriptor::CanBe(const TypeDescriptor *other) c * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor *SelectTypeDescriptor::CanBe(const char *other) const -{ - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = 0; +const TypeDescriptor * SelectTypeDescriptor::CanBe( const char * other ) const { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = 0; // see if other is the select - if(!StrCmpIns(_name, other)) { + if( !StrCmpIns( _name, other ) ) { return this; } // see if other is one of the elements - while((td = elements.NextTypeDesc())) { - if(td -> CanBe(other)) { + while( ( td = elements.NextTypeDesc() ) ) { + if( td -> CanBe( other ) ) { return td; } } @@ -83,18 +79,17 @@ const TypeDescriptor *SelectTypeDescriptor::CanBe(const char *other) const * if schNm = a schema which USEs or REFERENCEs this and renames it (e.g., "USE * from XX (A as B)"). */ -const TypeDescriptor *SelectTypeDescriptor::CanBeSet(const char *other, const char *schNm) const -{ - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = elements.NextTypeDesc(); +const TypeDescriptor * SelectTypeDescriptor::CanBeSet( const char * other, const char * schNm ) const { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = elements.NextTypeDesc(); - while(td) { - if(td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT) { + while( td ) { + if( td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT ) { // Just look at this level, don't look at my items (see intro). - if(td->CurrName(other, schNm)) { + if( td->CurrName( other, schNm ) ) { return td; } - } else if(td->CanBeSet(other, schNm)) { + } else if( td->CanBeSet( other, schNm ) ) { return td; } td = elements.NextTypeDesc(); diff --git a/src/clstepcore/selectTypeDescriptor.h b/src/clstepcore/selectTypeDescriptor.h index bb491ca6d..8dbfd1b19 100644 --- a/src/clstepcore/selectTypeDescriptor.h +++ b/src/clstepcore/selectTypeDescriptor.h @@ -3,55 +3,49 @@ #include "typeDescriptor.h" -typedef SDAI_Select *(* SelectCreator)(); - -class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor -{ - - protected: - TypeDescriptorList _elements; // of TYPE_DESCRIPTOR - int _unique_elements; - - public: - - SelectCreator CreateNewSelect; - - void AssignSelectCreator(SelectCreator f = 0) - { - CreateNewSelect = f; - } - - SDAI_Select *CreateSelect(); - - SelectTypeDescriptor(int b, const char *nm, PrimitiveType ft, - Schema *origSchema, - const char *d, SelectCreator f = 0) - : TypeDescriptor(nm, ft, origSchema, d), - _unique_elements(b), CreateNewSelect(f) - { } - virtual ~SelectTypeDescriptor() { } - - TypeDescriptorList &Elements() - { - return _elements; - } - const TypeDescriptorList &GetElements() const - { - return _elements; - } - int UniqueElements() const - { - return _unique_elements; - } - virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; - virtual const TypeDescriptor *IsA(const char *n) const - { - return TypeDescriptor::IsA(n); - } - virtual const TypeDescriptor *CanBe(const TypeDescriptor *) const; - virtual const TypeDescriptor *CanBe(const char *n) const; - virtual const TypeDescriptor *CanBeSet(const char *, const char *) - const; +typedef SDAI_Select * ( * SelectCreator )(); + +class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor { + +protected: + TypeDescriptorList _elements; // of TYPE_DESCRIPTOR + int _unique_elements; + +public: + + SelectCreator CreateNewSelect; + + void AssignSelectCreator( SelectCreator f = 0 ) { + CreateNewSelect = f; + } + + SDAI_Select * CreateSelect(); + + SelectTypeDescriptor( int b, const char * nm, PrimitiveType ft, + Schema * origSchema, + const char * d, SelectCreator f = 0 ) + : TypeDescriptor( nm, ft, origSchema, d ), + _unique_elements( b ), CreateNewSelect( f ) + { } + virtual ~SelectTypeDescriptor() { } + + TypeDescriptorList & Elements() { + return _elements; + } + const TypeDescriptorList & GetElements() const { + return _elements; + } + int UniqueElements() const { + return _unique_elements; + } + virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; + virtual const TypeDescriptor * IsA( const char * n ) const { + return TypeDescriptor::IsA( n ); + } + virtual const TypeDescriptor * CanBe( const TypeDescriptor * ) const; + virtual const TypeDescriptor * CanBe( const char * n ) const; + virtual const TypeDescriptor * CanBeSet( const char *, const char * ) + const; }; #endif //SELECTTYPEDESCRIPTOR_H diff --git a/src/clstepcore/stringTypeDescriptor.h b/src/clstepcore/stringTypeDescriptor.h index aff628617..b328dafaa 100644 --- a/src/clstepcore/stringTypeDescriptor.h +++ b/src/clstepcore/stringTypeDescriptor.h @@ -3,42 +3,35 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor -{ - - protected: - SDAI_Integer _width; // OPTIONAL - SDAI_LOGICAL _fixedSize; - public: - - StringTypeDescriptor() : _fixedSize("UNKNOWN_TYPE") - { - _width = 0; - } - virtual ~StringTypeDescriptor() { } - - - SDAI_Integer Width() - { - return _width; - } - void Width(SDAI_Integer w) - { - _width = w; - } - - SDAI_LOGICAL &FixedSize() - { - return _fixedSize; - } - void FixedSize(SDAI_LOGICAL fs) - { - _fixedSize.put(fs.asInt()); - } - void FixedSize(Logical fs) - { - _fixedSize.put(fs); - } +class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor { + +protected: + SDAI_Integer _width; // OPTIONAL + SDAI_LOGICAL _fixedSize; +public: + + StringTypeDescriptor( ) : _fixedSize( "UNKNOWN_TYPE" ) { + _width = 0; + } + virtual ~StringTypeDescriptor() { } + + + SDAI_Integer Width() { + return _width; + } + void Width( SDAI_Integer w ) { + _width = w; + } + + SDAI_LOGICAL & FixedSize() { + return _fixedSize; + } + void FixedSize( SDAI_LOGICAL fs ) { + _fixedSize.put( fs.asInt() ); + } + void FixedSize( Logical fs ) { + _fixedSize.put( fs ); + } }; #endif //STRINGTYPEDESCRIPTOR_H diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index 9270ad3a0..bfe73dc17 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -10,70 +10,63 @@ * * 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(); +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; } - 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(); - } + 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; - } + } + ~superInvAttrIter() { + if( invIter ) { + delete invIter; + invIter = 0; } - const EntityDescriptor *currentEDesc() - { - if(isempty) { - return NULL; - } - return sit.current(); + } + const EntityDescriptor * currentEDesc() { + if( isempty ) { + return NULL; } - bool empty() - { - if(isempty) { - return true; - } - return (!sit.hasNext() && !nextInv); + return sit.current(); + } + bool empty() { + if( isempty ) { + return true; } - 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; + 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 diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index f9f353e26..1de017638 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #c++ tests for clstepcore include_directories( diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index f06028309..f557d7c72 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -8,77 +8,76 @@ #include "ExpDict.h" #include -int main(int /*argc*/, char ** /*argv*/) -{ - Schema *a = 0; - Logical b(LFalse); +int main( int /*argc*/, char ** /*argv*/ ) { + Schema * a = 0; + Logical b( LFalse ); char buf[20][2] = { { '\0' } }; int i, d; - EntityDescriptor *descriptors[20], ed("ed", a, b, b); + EntityDescriptor * descriptors[20], ed( "ed", a, b, b ); bool failed = false; //create 20 more ed's - for(i = 0; i < 20; i++) { + for( i = 0; i < 20; i++ ) { buf[i][0] = 'a' + i; //ed names are 1st 20 lowercase chars - descriptors[i] = new EntityDescriptor(buf[i], a, b, b); + descriptors[i] = new EntityDescriptor( buf[i], a, b, b ); } //link the ed's together - ed.AddSupertype(descriptors[0]); - for(i = 0; i < 10; i++) { - descriptors[i]->AddSupertype(descriptors[i + 1]); + ed.AddSupertype( descriptors[0] ); + for( i = 0; i < 10; i++ ) { + descriptors[i]->AddSupertype( descriptors[i + 1] ); } - for(i = 11; i < 20; i++) { - descriptors[5]->AddSupertype(descriptors[i]); + for( i = 11; i < 20; i++ ) { + descriptors[5]->AddSupertype( descriptors[i] ); } //print the ed's i = 0; d = 0; std::cout << "head, name " << ed.Name() << std::endl; - supertypesIterator iter(&ed); - for(; !iter.empty(); iter++) { - if(!iter.hasNext()) { //hasNext should be false once and once only + supertypesIterator iter( &ed ); + for( ; !iter.empty(); iter++ ) { + if( !iter.hasNext() ) { //hasNext should be false once and once only i++; } - if(iter.depth() > d) { + if( iter.depth() > d ) { d = iter.depth(); } - std::cout << "position " << std::setw(3) << iter.pos() << ", name " << std::setw(iter.depth()) << iter->Name() << std::endl; + std::cout << "position " << std::setw( 3 ) << iter.pos() << ", name " << std::setw( iter.depth() ) << iter->Name() << std::endl; } - if(iter.pos() == 20) { + if( iter.pos() == 20 ) { std::cout << "success" << std::endl; } else { std::cout << "expected 20, got " << iter.pos() << std::endl; failed = true; } - if(i != 1) { + if( i != 1 ) { std::cout << "problem with hasNext(): expected 1, got " << i << std::endl; failed = true; } - if(d != 11) { + if( d != 11 ) { std::cout << "problem with depth(): expected 11, got " << d << std::endl; failed = true; } - supertypesIterator it2(&ed), it3, uninitializedIter; + supertypesIterator it2( &ed ), it3, uninitializedIter; it3 = it2; //test operator==, operator!= - if((it2 == iter) || (it2 == uninitializedIter)) { + if( ( it2 == iter ) || ( it2 == uninitializedIter ) ) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 1st" << std::endl; } - if(!(it2 == it3)) { + if( !( it2 == it3 ) ) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 2nd" << std::endl; } - if(!(it2 != iter)) { + if( !( it2 != iter ) ) { std::cout << "problem with operator!=" << std::endl; failed = true; } else { @@ -89,19 +88,19 @@ int main(int /*argc*/, char ** /*argv*/) ++it3; // operator> - if((it3 > it2) != LTrue) { + if( ( it3 > it2 ) != LTrue ) { std::cout << "problem with operator>, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator> passed LTrue" << std::endl; } - if((uninitializedIter > it2) != LUnknown) { + if( ( uninitializedIter > it2 ) != LUnknown ) { std::cout << "problem with operator>, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator> passed LUnknown" << std::endl; } - if((it2 > it2) != LFalse) { + if( ( it2 > it2 ) != LFalse ) { std::cout << "problem with operator>, expected LFalse" << std::endl; failed = true; } else { @@ -109,19 +108,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator< - if((it2 < it3) != LTrue) { + if( ( it2 < it3 ) != LTrue ) { std::cout << "problem with operator<, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator< passed LTrue" << std::endl; } - if((it2 < uninitializedIter) != LUnknown) { + if( ( it2 < uninitializedIter ) != LUnknown ) { std::cout << "problem with operator<, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator< passed LUnknown" << std::endl; } - if((it2 < it2) != LFalse) { + if( ( it2 < it2 ) != LFalse ) { std::cout << "problem with operator<, expected LFalse" << std::endl; failed = true; } else { @@ -129,19 +128,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator<= - if((it2 <= it2) != LTrue) { + if( ( it2 <= it2 ) != LTrue ) { std::cout << "problem with operator<=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator<= passed LTrue" << std::endl; } - if((it2 <= uninitializedIter) != LUnknown) { + if( ( it2 <= uninitializedIter ) != LUnknown ) { std::cout << "problem with operator<=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator<= passed LUnknown" << std::endl; } - if((it3 <= it2) != LFalse) { + if( ( it3 <= it2 ) != LFalse ) { std::cout << "problem with operator<=, expected LFalse" << std::endl; failed = true; } else { @@ -149,19 +148,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator>= - if((it2 >= it2) != LTrue) { + if( ( it2 >= it2 ) != LTrue ) { std::cout << "problem with operator>=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator>= passed LTrue" << std::endl; } - if((it2 >= uninitializedIter) != LUnknown) { + if( ( it2 >= uninitializedIter ) != LUnknown ) { std::cout << "problem with operator>=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator>= passed LUnknown" << std::endl; } - if((it2 >= it3) != LFalse) { + if( ( it2 >= it3 ) != LFalse ) { std::cout << "problem with operator>=, expected LFalse" << std::endl; failed = true; } else { @@ -170,19 +169,19 @@ int main(int /*argc*/, char ** /*argv*/) /// still need operator* >= it3.reset(); - const EntityDescriptor *e = *it3; - const char *n = "a"; - if(strcmp(e->Name(), n)) { + const EntityDescriptor * e = *it3; + const char * n = "a"; + if( strcmp( e->Name(), n ) ) { std::cout << "problem with operator*" << std::endl; failed = true; } else { std::cout << "operator* passed " << std::endl; } - if(failed) { - exit(EXIT_FAILURE); + if( failed ) { + exit( EXIT_FAILURE ); } else { - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } } /* output: diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index 0cd86b654..0c96c5798 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -7,14 +7,13 @@ EntityDescriptor *ed = 0; TypeDescriptor *td; Schema *sch = 0; -int main() -{ +int main () { SDAI_String _description; - sch = new Schema("Ifc2x3"); - td = new TypeDescriptor("Ifctext", sdaiSTRING, sch, "STRING"); - ed = new EntityDescriptor("Ifcroot", sch, LTrue, LFalse); - ad = new AttrDescriptor("description", td, LTrue, LFalse, AttrType_Explicit, *ed); - ed->AddExplicitAttr(ad); + sch = new Schema( "Ifc2x3" ); + td = new TypeDescriptor( "Ifctext", sdaiSTRING, sch, "STRING" ); + ed = new EntityDescriptor( "Ifcroot", sch, LTrue, LFalse ); + ad = new AttrDescriptor( "description", td, LTrue, LFalse, AttrType_Explicit, *ed ); + ed->AddExplicitAttr( ad ); STEPattribute *a = new STEPattribute(*ad, &_description); a -> set_null(); delete a; diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index e65969097..fcb6cde4d 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -12,82 +12,58 @@ using namespace std; -class TestSdaiSelect: public SDAI_Select -{ +class TestSdaiSelect: public SDAI_Select { public: - TestSdaiSelect(SelectTypeDescriptor *s, TypeDescriptor *t, BASE_TYPE b, SDAI_String v, ErrorDescriptor e): - SDAI_Select(s, t) - { + 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); + TestSdaiSelect & operator=( const TestSdaiSelect & other ) { + SDAI_Select::operator=( other ); return *this; } - SDAI_Select &operator=(const SDAI_Select &other) - { - SDAI_Select::operator=(other); + 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 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()); + 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; + 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"); +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); + 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)) { + if( s2.compare( &s, &t, b, &v, &e ) ) { return true; } else { cerr << __FILE__ << ":" << __LINE__ << " - error: test for SDAI_Select::operator= failed" << endl; @@ -95,15 +71,14 @@ bool testOperatorEq() } } -int main(int /*argc*/, char ** /*argv*/) -{ +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); + if( pass ) { + exit( EXIT_SUCCESS ); } else { - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index 8d2fba7ab..abd396816 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -6,25 +6,24 @@ /// test copying a STEPattribute; returns true on success -bool testCopy(STEPattribute &attr, const char *desc) -{ +bool testCopy( STEPattribute & attr, const char * desc ) { bool pass = true; STEPattribute b = attr; STEPattribute c; - if(!(attr == attr)) { + if( !( attr == attr ) ) { std::cerr << "test class initialization failed " << desc << std::endl; pass = false; } - if(!(attr == b)) { + if( !( attr == b ) ) { std::cerr << "assignment operator failed " << desc << std::endl; pass = false; } - c.ShallowCopy(& attr); - if(!(attr == c)) { + c.ShallowCopy( & attr ); + if( !( attr == c ) ) { std::cerr << "ShallowCopy() failed " << desc << std::endl; pass = false; } @@ -32,45 +31,43 @@ bool testCopy(STEPattribute &attr, const char *desc) return pass; } -bool testEqu(const STEPattribute &a1, const STEPattribute &a2, bool invert, const char *desc) -{ - bool pass = (invert ? (!(a1 == a2)) : (a1 == a2)); - if(!pass) { +bool testEqu( const STEPattribute & a1, const STEPattribute & a2, bool invert, const char * desc ) { + bool pass = ( invert ? ( !( a1 == a2 ) ) : ( a1 == a2 ) ); + if( !pass ) { std::cerr << "Comparison test " << desc << " failed." << std::endl; } return pass; } -int main(int /*argc*/, char ** /*argv*/) -{ +int main( int /*argc*/, char ** /*argv*/ ) { bool pass = true; - EntityDescriptor ed("ename", 0, LFalse, LFalse); + EntityDescriptor ed( "ename", 0, LFalse, LFalse ); // used to test copying without operator new - TypeDescriptor tdi("tint", sdaiINTEGER, 0, "int"); - AttrDescriptor adi("aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed); + TypeDescriptor tdi( "tint", sdaiINTEGER, 0, "int" ); + AttrDescriptor adi( "aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed ); SDAI_Integer sint = 1234L, s2int = 123L; - STEPattribute ai(adi, & sint); + STEPattribute ai( adi, & sint ); //test copying with operator new (SDAI_Logical requires new) - TypeDescriptor tdl("tlog", sdaiLOGICAL, 0, "str"); - AttrDescriptor adl("alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed); - SDAI_LOGICAL slog(LTrue); - STEPattribute al(adl, & slog); + TypeDescriptor tdl( "tlog", sdaiLOGICAL, 0, "str" ); + AttrDescriptor adl( "alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed ); + SDAI_LOGICAL slog( LTrue ); + STEPattribute al( adl, & slog ); - pass &= testCopy(ai, "without operator new"); - pass &= testCopy(al, "with operator new"); + pass &= testCopy( ai, "without operator new" ); + pass &= testCopy( al, "with operator new" ); - pass &= testEqu(al, al, false, "LOGICAL =="); - pass &= testEqu(ai, ai, false, "int =="); - pass &= testEqu(ai, al, true, "int != LOGICAL"); + pass &= testEqu( al, al, false, "LOGICAL ==" ); + pass &= testEqu( ai, ai, false, "int ==" ); + pass &= testEqu( ai, al, true, "int != LOGICAL" ); - STEPattribute aii(adi, & s2int); - pass &= testEqu(ai, aii, true, "ints !="); + STEPattribute aii( adi, & s2int ); + pass &= testEqu( ai, aii, true, "ints !=" ); - if(pass) { - exit(EXIT_SUCCESS); + if( pass ) { + exit( EXIT_SUCCESS ); } - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 24a5a3516..145af7699 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -15,8 +15,8 @@ #include "sc_memmgr.h" // Local function prototypes: -static EntList *firstCandidate(EntList *); -static EntList *nextCandidate(EntList *); +static EntList * firstCandidate( EntList * ); +static EntList * nextCandidate( EntList * ); /** * Loops backwards through the children of this, recursively searching for @@ -28,18 +28,17 @@ static EntList *nextCandidate(EntList *); * (reasons discussed in notes, 10/17). This function is the tryNext() * for AND and ANDOR; the OR version is redefined. */ -MatchType MultList::tryNext(EntNode *ents) -{ +MatchType MultList::tryNext( EntNode * ents ) { MatchType retval; - EntList *child = getLast(); + EntList * child = getLast(); - child = firstCandidate(child); - while(child != NULL) { - if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { + child = firstCandidate( child ); + while( child != NULL ) { + if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { // We're done - a good solution was found. return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -47,14 +46,14 @@ MatchType MultList::tryNext(EntNode *ents) // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while((child = nextCandidate(child)) != NULL) { - if(child->acceptChoice(ents) && ents->allMarked()) { + while( ( child = nextCandidate( child ) ) != NULL ) { + if( child->acceptChoice( ents ) && ents->allMarked() ) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate(child->prev); + child = firstCandidate( child->prev ); } // If we got here, we didn't find any new OR choices: return NOMORE; @@ -65,18 +64,17 @@ MatchType MultList::tryNext(EntNode *ents) * choices below it. The acceptable choices are described in commenting * below. */ -static EntList *firstCandidate(EntList *child) -{ - EntList *ent = child->lastNot(SIMPLE); +static EntList * firstCandidate( EntList * child ) { + EntList * ent = child->lastNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot(SIMPLE); + ent = ent->prevNot( SIMPLE ); } return ent; } @@ -84,15 +82,14 @@ static EntList *firstCandidate(EntList *child) /** * Same as prev function, searches forwards from ent after child. */ -static EntList *nextCandidate(EntList *child) -{ - EntList *ent = child->nextNot(SIMPLE); +static EntList * nextCandidate( EntList * child ) { + EntList * ent = child->nextNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { return ent; } - ent = ent->nextNot(SIMPLE); + ent = ent->nextNot( SIMPLE ); } return ent; } @@ -102,28 +99,27 @@ static EntList *nextCandidate(EntList *child) * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ -MatchType OrList::tryNext(EntNode *ents) -{ - EntList *child; +MatchType OrList::tryNext( EntNode * ents ) { + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild(choice); - if(child->multiple()) { + child = getChild( choice ); + if( child->multiple() ) { // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - MatchType retval; - retval = ((MultList *)child)->tryNext(ents); - if(retval == MATCHALL) { + MatchType retval; + retval = ( ( MultList * )child )->tryNext( ents ); + if( retval == MATCHALL ) { return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -134,8 +130,8 @@ MatchType OrList::tryNext(EntNode *ents) // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll(ents); - if(choiceCount == 1) { + child->unmarkAll( ents ); + if( choiceCount == 1 ) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -144,8 +140,8 @@ MatchType OrList::tryNext(EntNode *ents) } // Otherwise, try our next: - if(acceptNextChoice(ents)) { - if(ents->allMarked()) { + if( acceptNextChoice( ents ) ) { + if( ents->allMarked() ) { return MATCHALL; } return NEWCHOICE; diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index 7b207ea89..e37d931bb 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -1,23 +1,20 @@ #include "typeDescriptor.h" -TypeDescriptor::TypeDescriptor() - : _name(0), altNames(0), _fundamentalType(UNKNOWN_TYPE), - _originatingSchema(0), _referentType(0), _description(0), _where_rules(0) -{ +TypeDescriptor::TypeDescriptor( ) + : _name( 0 ), altNames( 0 ), _fundamentalType( UNKNOWN_TYPE ), + _originatingSchema( 0 ), _referentType( 0 ), _description( 0 ), _where_rules( 0 ) { } TypeDescriptor::TypeDescriptor -(const char *nm, PrimitiveType ft, Schema *origSchema, - const char *d) - : _name(nm), altNames(0), _fundamentalType(ft), - _originatingSchema(origSchema), _referentType(0), _description(d), - _where_rules(0) -{ +( const char * nm, PrimitiveType ft, Schema * origSchema, + const char * d ) + : _name( nm ), altNames( 0 ), _fundamentalType( ft ), + _originatingSchema( origSchema ), _referentType( 0 ), _description( d ), + _where_rules( 0 ) { } -TypeDescriptor::~TypeDescriptor() -{ - if(_where_rules) { +TypeDescriptor::~TypeDescriptor() { + if( _where_rules ) { delete _where_rules; } } @@ -32,12 +29,11 @@ TypeDescriptor::~TypeDescriptor() * and returns the new name if found. (See header comments to function * SchRename::rename().) */ -const char *TypeDescriptor::Name(const char *schnm) const -{ - if(schnm == NULL) { +const char * TypeDescriptor::Name( const char * schnm ) const { + if( schnm == NULL ) { return _name; } - if(altNames && altNames->rename(schnm, (char *)_altname)) { + if( altNames && altNames->rename( schnm, ( char * )_altname ) ) { // If our altNames list has an alternate for schnm, copy it into // _altname, and return it: return _altname; @@ -45,20 +41,18 @@ const char *TypeDescriptor::Name(const char *schnm) const return _name; } -const char *TypeDescriptor::BaseTypeName() const -{ +const char * TypeDescriptor::BaseTypeName() const { return BaseTypeDescriptor() ? BaseTypeDescriptor() -> Name() : 0; } -const TypeDescriptor *TypeDescriptor::BaseTypeIsA(const TypeDescriptor *td) const -{ - switch(NonRefType()) { +const TypeDescriptor * TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const { + switch( NonRefType() ) { case AGGREGATE_TYPE: - return AggrElemTypeDescriptor() -> IsA(td); + return AggrElemTypeDescriptor() -> IsA( td ); case ENTITY_TYPE: case SELECT_TYPE: default: - return IsA(td); + return IsA( td ); } } @@ -70,41 +64,37 @@ const TypeDescriptor *TypeDescriptor::BaseTypeIsA(const TypeDescriptor *td) cons * case if schNm USEs or REFERENCEs type and renames it in the process * (e.g., "USE (X as Y)". */ -bool TypeDescriptor::CurrName(const char *other, const char *schNm) const -{ - if(!schNm || *schNm == '\0') { +bool TypeDescriptor::CurrName( const char * other, const char * schNm ) const { + if( !schNm || *schNm == '\0' ) { // If there's no current schema, accept any possible name of this. // (I.e., accept its actual name or any substitute): - return (PossName(other)); + return ( PossName( other ) ); } - if(altNames && altNames->rename(schNm, (char *)_altname)) { + if( altNames && altNames->rename( schNm, ( char * )_altname ) ) { // If we have a different name when the current schema = schNm, then // other better = the alt name. - return (!StrCmpIns(_altname, other)); + return ( !StrCmpIns( _altname, other ) ); } else { // If we have no desginated alternate name when the current schema = // schNm, other must = our _name. - return (OurName(other)); + return ( OurName( other ) ); } } /** * return true if nm is either our name or one of the possible alternates. */ -bool TypeDescriptor::PossName(const char *nm) const -{ - return (OurName(nm) || AltName(nm)); +bool TypeDescriptor::PossName( const char * nm ) const { + return ( OurName( nm ) || AltName( nm ) ); } -bool TypeDescriptor::OurName(const char *nm) const -{ - return !StrCmpIns(nm, _name); +bool TypeDescriptor::OurName( const char * nm ) const { + return !StrCmpIns( nm, _name ); } -bool TypeDescriptor::AltName(const char *nm) const -{ - if(altNames) { - return (altNames->choice(nm)); +bool TypeDescriptor::AltName( const char * nm ) const { + if( altNames ) { + return ( altNames->choice( nm ) ); } return false; } @@ -113,17 +103,16 @@ bool TypeDescriptor::AltName(const char *nm) const * Creates a SchRename consisting of schnm & newnm. Places it in alphabe- * tical order in this's altNames list. */ -void TypeDescriptor::addAltName(const char *schnm, const char *newnm) -{ - SchRename *newpair = new SchRename(schnm, newnm), - *node = (SchRename *)altNames, *prev = NULL; +void TypeDescriptor::addAltName( const char * schnm, const char * newnm ) { + SchRename * newpair = new SchRename( schnm, newnm ), + *node = ( SchRename * )altNames, *prev = NULL; - while(node && *node < *newpair) { + while( node && *node < *newpair ) { prev = node; node = node->next; } newpair->next = node; // node may = NULL - if(prev) { + if( prev ) { // Will be the case if new node should not be first (and above while // loop was entered). prev->next = newpair; @@ -133,69 +122,67 @@ void TypeDescriptor::addAltName(const char *schnm, const char *newnm) } } -void TypeDescriptor::AttrTypeName(std::string &buf, const char *schnm) const -{ - const char *sn = Name(schnm); - if(sn) { - StrToLower(sn, buf); +void TypeDescriptor::AttrTypeName( std::string & buf, const char * schnm ) const { + const char * sn = Name( schnm ); + if( sn ) { + StrToLower( sn , buf ); } else { buf = _description; } } -const char *TypeDescriptor::GenerateExpress(std::string &buf) const -{ +const char * TypeDescriptor::GenerateExpress( std::string & buf ) const { char tmp[BUFSIZ]; buf = "TYPE "; - buf.append(StrToLower(Name(), tmp)); - buf.append(" = "); - const char *desc = Description(); - const char *ptr = desc; - - while(*ptr != '\0') { - if(*ptr == ',') { - buf.append(",\n "); - } else if(*ptr == '(') { - buf.append("\n ("); - } else if(isupper(*ptr)) { - buf += (char)tolower(*ptr); + buf.append( StrToLower( Name(), tmp ) ); + buf.append( " = " ); + const char * desc = Description(); + const char * ptr = desc; + + while( *ptr != '\0' ) { + if( *ptr == ',' ) { + buf.append( ",\n " ); + } else if( *ptr == '(' ) { + buf.append( "\n (" ); + } else if( isupper( *ptr ) ) { + buf += ( char )tolower( *ptr ); } else { buf += *ptr; } ptr++; } - buf.append(";\n"); + buf.append( ";\n" ); /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { int all_comments = 1; int count = _where_rules->Count(); - for(int i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* WHERE *)\n"); + if( all_comments ) { + buf.append( " (* WHERE *)\n" ); } else { - buf.append(" WHERE\n"); + buf.append( " WHERE\n" ); } - for(int i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); + for( int i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); } } } - buf.append("END_TYPE;\n"); - return const_cast(buf.c_str()); + buf.append( "END_TYPE;\n" ); + return const_cast( buf.c_str() ); } /** @@ -205,107 +192,106 @@ const char *TypeDescriptor::GenerateExpress(std::string &buf) const * e.g. if the description contains a TYPE name it will also * be explained. */ -const char *TypeDescriptor::TypeString(std::string &s) const -{ - switch(Type()) { +const char * TypeDescriptor::TypeString( std::string & s ) const { + switch( Type() ) { case REFERENCE_TYPE: - if(Name()) { - s.append("TYPE "); - s.append(Name()); - s.append(" = "); + if( Name() ) { + s.append( "TYPE " ); + s.append( Name() ); + s.append( " = " ); } - if(Description()) { - s.append(Description()); + if( Description() ) { + s.append( Description() ); } - if(ReferentType()) { - s.append(" -- "); + if( ReferentType() ) { + s.append( " -- " ); std::string tmp; - s.append(ReferentType()->TypeString(tmp)); + s.append( ReferentType()->TypeString( tmp ) ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); case INTEGER_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Integer"); + s.append( "Integer" ); break; case STRING_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("String"); + s.append( "String" ); break; case REAL_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Real"); + s.append( "Real" ); break; case ENUM_TYPE: s = "Enumeration: "; - if(Name()) { - s.append("TYPE "); - s.append(Name()); - s.append(" = "); + if( Name() ) { + s.append( "TYPE " ); + s.append( Name() ); + s.append( " = " ); } - if(Description()) { - s.append(Description()); + if( Description() ) { + s.append( Description() ); } break; case BOOLEAN_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Boolean: F, T"); + s.append( "Boolean: F, T" ); break; case LOGICAL_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Logical: F, T, U"); + s.append( "Logical: F, T, U" ); break; case NUMBER_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Number"); + s.append( "Number" ); break; case BINARY_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Binary"); + s.append( "Binary" ); break; case ENTITY_TYPE: s = "Entity: "; - if(Name()) { - s.append(Name()); + if( Name() ) { + s.append( Name() ); } break; case AGGREGATE_TYPE: @@ -314,41 +300,39 @@ const char *TypeDescriptor::TypeString(std::string &s) const case SET_TYPE: // DAS case LIST_TYPE: // DAS s = Description(); - if(ReferentType()) { - s.append(" -- "); + if( ReferentType() ) { + s.append( " -- " ); std::string tmp; - s.append(ReferentType()->TypeString(tmp)); + s.append( ReferentType()->TypeString( tmp ) ); } break; case SELECT_TYPE: - s.append(Description()); + s.append( Description() ); break; case GENERIC_TYPE: case UNKNOWN_TYPE: s = "Unknown"; break; } // end switch - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const TypeDescriptor *TypeDescriptor::IsA(const TypeDescriptor *other) const -{ - if(this == other) { +const TypeDescriptor * TypeDescriptor::IsA( const TypeDescriptor * other ) const { + if( this == other ) { return other; } return 0; } -const TypeDescriptor *TypeDescriptor::IsA(const char *other) const -{ - if(!Name()) { +const TypeDescriptor * TypeDescriptor::IsA( const char * other ) const { + if( !Name() ) { return 0; } - if(!StrCmpIns(_name, other)) { // this is the type + if( !StrCmpIns( _name, other ) ) { // this is the type return this; } - return (ReferentType() ? ReferentType() -> IsA(other) : 0); + return ( ReferentType() ? ReferentType() -> IsA( other ) : 0 ); } /** @@ -360,22 +344,20 @@ const TypeDescriptor *TypeDescriptor::IsA(const char *other) const * an element by calling AggrElemType(). Select types * would work the same? */ -PrimitiveType TypeDescriptor::NonRefType() const -{ - const TypeDescriptor *td = NonRefTypeDescriptor(); - if(td) { +PrimitiveType TypeDescriptor::NonRefType() const { + const TypeDescriptor * td = NonRefTypeDescriptor(); + if( td ) { return td->FundamentalType(); } return UNKNOWN_TYPE; } -const TypeDescriptor *TypeDescriptor::NonRefTypeDescriptor() const -{ - const TypeDescriptor *td = this; +const TypeDescriptor * TypeDescriptor::NonRefTypeDescriptor() const { + const TypeDescriptor * td = this; - while(td->ReferentType()) { - if(td->Type() != REFERENCE_TYPE) { + while( td->ReferentType() ) { + if( td->Type() != REFERENCE_TYPE ) { return td; } td = td->ReferentType(); @@ -385,9 +367,8 @@ const TypeDescriptor *TypeDescriptor::NonRefTypeDescriptor() const } /// This returns the PrimitiveType of the first non-aggregate element of an aggregate -int TypeDescriptor::IsAggrType() const -{ - switch(NonRefType()) { +int TypeDescriptor::IsAggrType() const { + switch( NonRefType() ) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS @@ -400,20 +381,18 @@ int TypeDescriptor::IsAggrType() const } } -PrimitiveType TypeDescriptor::AggrElemType() const -{ - const TypeDescriptor *aggrElemTD = AggrElemTypeDescriptor(); - if(aggrElemTD) { +PrimitiveType TypeDescriptor::AggrElemType() const { + const TypeDescriptor * aggrElemTD = AggrElemTypeDescriptor(); + if( aggrElemTD ) { return aggrElemTD->Type(); } return UNKNOWN_TYPE; } -const TypeDescriptor *TypeDescriptor::AggrElemTypeDescriptor() const -{ - const TypeDescriptor *aggrTD = NonRefTypeDescriptor(); - const TypeDescriptor *aggrElemTD = aggrTD->ReferentType(); - if(aggrElemTD) { +const TypeDescriptor * TypeDescriptor::AggrElemTypeDescriptor() const { + const TypeDescriptor * aggrTD = NonRefTypeDescriptor(); + const TypeDescriptor * aggrElemTD = aggrTD->ReferentType(); + if( aggrElemTD ) { aggrElemTD = aggrElemTD->NonRefTypeDescriptor(); } return aggrElemTD; @@ -429,21 +408,19 @@ const TypeDescriptor *TypeDescriptor::AggrElemTypeDescriptor() const * TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor * for Integer */ -PrimitiveType TypeDescriptor::BaseType() const -{ - const TypeDescriptor *td = BaseTypeDescriptor(); - if(td) { +PrimitiveType TypeDescriptor::BaseType() const { + const TypeDescriptor * td = BaseTypeDescriptor(); + if( td ) { return td->FundamentalType(); } else { return ENTITY_TYPE; } } -const TypeDescriptor *TypeDescriptor::BaseTypeDescriptor() const -{ - const TypeDescriptor *td = this; +const TypeDescriptor * TypeDescriptor::BaseTypeDescriptor() const { + const TypeDescriptor * td = this; - while(td -> ReferentType()) { + while( td -> ReferentType() ) { td = td->ReferentType(); } return td; diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 3790707e2..915c1831d 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -93,8 +93,7 @@ * It is the same as _name for EXPRESS base types TypeDescriptors (with * the possible exception of upper or lower case differences). */ -class SC_CORE_EXPORT TypeDescriptor -{ +class SC_CORE_EXPORT TypeDescriptor { protected: @@ -106,7 +105,7 @@ class SC_CORE_EXPORT TypeDescriptor /// generated code, for example, places a literal string in its /// TypeDesc constructor calls. This creates a location in me- /// mory static throughout the lifetime of the calling program. - const char *_name ; + const char * _name ; /// an alternate name of type - such as one given by a different /// schema which USEs/ REFERENCEs this. (A complete list of @@ -116,58 +115,56 @@ class SC_CORE_EXPORT TypeDescriptor /// contains list of renamings of type - used by other schemas /// which USE/ REFERENCE this - const SchRename *altNames; + const SchRename * altNames; /// the type of the type (see above). /// it is an enum see file clstepcore/baseType.h PrimitiveType _fundamentalType; - const Schema *_originatingSchema; + const Schema * _originatingSchema; /// further describes the type (see above) /// most often (or always) points at a subtype. - const TypeDescriptor *_referentType; + const TypeDescriptor * _referentType; /// Express file description (see above) /// e.g. the right side of an Express TYPE stmt /// (See note above by _name regarding memory allocation.) - const char *_description; + const char * _description; public: /// a Where_rule may contain only a comment Where_rule__list_var _where_rules; // initially a null pointer - Where_rule__list_var &where_rules_() - { + Where_rule__list_var & where_rules_() { return _where_rules; } - void where_rules_(Where_rule__list *wrl) - { + void where_rules_( Where_rule__list * wrl ) { _where_rules = wrl; } protected: /// Functions used to check the current name of the type (may /// != _name if altNames has diff name for current schema). - bool PossName(const char *) const; - bool OurName(const char *) const; - bool AltName(const char *) const; + bool PossName( const char * ) const; + bool OurName( const char * ) const; + bool AltName( const char * ) const; public: - TypeDescriptor(const char *nm, PrimitiveType ft, const char *d); - TypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d); - TypeDescriptor(); + TypeDescriptor( const char * nm, PrimitiveType ft, const char * d ); + TypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d ); + TypeDescriptor( ); virtual ~TypeDescriptor(); - virtual const char *GenerateExpress(std::string &buf) const; + virtual const char * GenerateExpress( std::string & buf ) const; /// The name of this type. If schnm != NULL, the name we're /// referred to by schema schnm (may be diff name in our alt- /// names list (based on schnm's USE/REF list)). - const char *Name(const char *schnm = NULL) const; + const char * Name( const char * schnm = NULL ) const; /// The name that would be found on the right side of an /// attribute definition. In the case of a type defined like @@ -177,11 +174,10 @@ class SC_CORE_EXPORT TypeDescriptor /// defined in an attribute it will be the _description /// member variable since _name will be null. e.g. attr. def. /// project_names : ARRAY [1..10] name; - void AttrTypeName(std::string &buf, const char *schnm = NULL) const; + void AttrTypeName( std::string & buf, const char * schnm = NULL ) const; /// Linked link of alternate names for the type: - const SchRename *AltNameList() const - { + const SchRename * AltNameList() const { return altNames; } @@ -190,15 +186,13 @@ class SC_CORE_EXPORT TypeDescriptor /// except it is more thorough of a description where possible /// e.g. if the description contains a TYPE name it will also /// be explained. - const char *TypeString(std::string &s) const; + const char * TypeString( std::string & s ) const; /// This TypeDescriptor's type - PrimitiveType Type() const - { + PrimitiveType Type() const { return _fundamentalType; } - void Type(const PrimitiveType type) - { + void Type( const PrimitiveType type ) { _fundamentalType = type; } @@ -213,8 +207,8 @@ class SC_CORE_EXPORT TypeDescriptor /// TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor /// for Integer. PrimitiveType BaseType() const; - const TypeDescriptor *BaseTypeDescriptor() const; - const char *BaseTypeName() const; + const TypeDescriptor * BaseTypeDescriptor() const; + const char * BaseTypeName() const; /// the first PrimitiveType that is not REFERENCE_TYPE (the first /// TypeDescriptor *_referentType that does not have REFERENCE_TYPE @@ -225,43 +219,36 @@ class SC_CORE_EXPORT TypeDescriptor /// would work the same? PrimitiveType NonRefType() const; - const TypeDescriptor *NonRefTypeDescriptor() const; + const TypeDescriptor * NonRefTypeDescriptor() const; int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor *AggrElemTypeDescriptor() const; + const TypeDescriptor * AggrElemTypeDescriptor() const; - PrimitiveType FundamentalType() const - { + PrimitiveType FundamentalType() const { return _fundamentalType; } - void FundamentalType(PrimitiveType ftype) - { + void FundamentalType( PrimitiveType ftype ) { _fundamentalType = ftype; } /// The TypeDescriptor for the type this type is based on - const TypeDescriptor *ReferentType() const - { + const TypeDescriptor * ReferentType() const { return _referentType; } - void ReferentType(const TypeDescriptor *rtype) - { + void ReferentType( const TypeDescriptor * rtype ) { _referentType = rtype; } - const Schema *OriginatingSchema() const - { + const Schema * OriginatingSchema() const { return _originatingSchema; } - void OriginatingSchema(const Schema *os) - { + void OriginatingSchema( const Schema * os ) { _originatingSchema = os; } - const char *schemaName() const - { - if(_originatingSchema) { + const char * schemaName() const { + if( _originatingSchema ) { return _originatingSchema->Name(); } else { return ""; @@ -271,35 +258,30 @@ class SC_CORE_EXPORT TypeDescriptor /// A description of this type's type. Basically you /// get the right side of a TYPE statement minus END_TYPE. /// For base type TypeDescriptors it is the same as _name. - const char *Description() const - { + const char * Description() const { return _description; } - void Description(const char *desc) - { + void Description( const char * desc ) { _description = desc; } - virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; - virtual const TypeDescriptor *BaseTypeIsA(const TypeDescriptor *) + virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; + virtual const TypeDescriptor * BaseTypeIsA( const TypeDescriptor * ) const; - virtual const TypeDescriptor *IsA(const char *) const; - virtual const TypeDescriptor *CanBe(const TypeDescriptor *n) const - { - return IsA(n); + virtual const TypeDescriptor * IsA( const char * ) const; + virtual const TypeDescriptor * CanBe( const TypeDescriptor * n ) const { + return IsA( n ); } - virtual const TypeDescriptor *CanBe(const char *n) const - { - return IsA(n); + virtual const TypeDescriptor * CanBe( const char * n ) const { + return IsA( n ); } - virtual const TypeDescriptor *CanBeSet(const char *n, - const char *schNm = 0) const - { - return (CurrName(n, schNm) ? this : 0); + virtual const TypeDescriptor * CanBeSet( const char * n, + const char * schNm = 0 ) const { + return ( CurrName( n, schNm ) ? this : 0 ); } - bool CurrName(const char *, const char * = 0) const; + bool CurrName( const char *, const char * = 0 ) const; /// Adds an additional name, newnm, to be use when schema schnm is USE/REFERENCE'ing us (added to altNames). - void addAltName(const char *schnm, const char *newnm); + void addAltName( const char * schnm, const char * newnm ); }; #endif //TYPEDESCRIPTOR_H diff --git a/src/clstepcore/typeDescriptorList.cc b/src/clstepcore/typeDescriptorList.cc index 606e667f8..f47e8f502 100644 --- a/src/clstepcore/typeDescriptorList.cc +++ b/src/clstepcore/typeDescriptorList.cc @@ -1,36 +1,29 @@ #include "typeDescriptorList.h" -TypeDescLinkNode::TypeDescLinkNode() -{ +TypeDescLinkNode::TypeDescLinkNode() { _typeDesc = 0; } -TypeDescLinkNode::~TypeDescLinkNode() -{ +TypeDescLinkNode::~TypeDescLinkNode() { } -TypeDescriptorList::TypeDescriptorList() -{ +TypeDescriptorList::TypeDescriptorList() { } -TypeDescriptorList::~TypeDescriptorList() -{ +TypeDescriptorList::~TypeDescriptorList() { } -TypeDescItr::TypeDescItr(const TypeDescriptorList &tdList) : tdl(tdList) -{ - cur = (TypeDescLinkNode *)(tdl.GetHead()); +TypeDescItr::TypeDescItr( const TypeDescriptorList & tdList ) : tdl( tdList ) { + cur = ( TypeDescLinkNode * )( tdl.GetHead() ); } -TypeDescItr::~TypeDescItr() -{ +TypeDescItr::~TypeDescItr() { } -const TypeDescriptor *TypeDescItr::NextTypeDesc() -{ - if(cur) { - const TypeDescriptor *td = cur->TypeDesc(); - cur = (TypeDescLinkNode *)(cur->NextNode()); +const TypeDescriptor * TypeDescItr::NextTypeDesc() { + if( cur ) { + const TypeDescriptor * td = cur->TypeDesc(); + cur = ( TypeDescLinkNode * )( cur->NextNode() ); return td; } return 0; diff --git a/src/clstepcore/typeDescriptorList.h b/src/clstepcore/typeDescriptorList.h index faff6712a..b8bbc614c 100644 --- a/src/clstepcore/typeDescriptorList.h +++ b/src/clstepcore/typeDescriptorList.h @@ -9,63 +9,55 @@ class TypeDescriptor; -class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode { private: protected: - TypeDescriptor *_typeDesc; + TypeDescriptor * _typeDesc; public: TypeDescLinkNode(); virtual ~TypeDescLinkNode(); - const TypeDescriptor *TypeDesc() const - { + const TypeDescriptor * TypeDesc() const { return _typeDesc; } - void TypeDesc(TypeDescriptor *td) - { + void TypeDesc( TypeDescriptor * td ) { _typeDesc = td; } }; -class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList { private: protected: public: TypeDescriptorList(); virtual ~TypeDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new TypeDescLinkNode; } - TypeDescLinkNode *AddNode(TypeDescriptor *td) - { - TypeDescLinkNode *node = (TypeDescLinkNode *) NewNode(); - node->TypeDesc(td); - SingleLinkList::AppendNode(node); + TypeDescLinkNode * AddNode( TypeDescriptor * td ) { + TypeDescLinkNode * node = ( TypeDescLinkNode * ) NewNode(); + node->TypeDesc( td ); + SingleLinkList::AppendNode( node ); return node; } }; -class SC_CORE_EXPORT TypeDescItr -{ +class SC_CORE_EXPORT TypeDescItr { protected: - const TypeDescriptorList &tdl; - const TypeDescLinkNode *cur; + const TypeDescriptorList & tdl; + const TypeDescLinkNode * cur; public: - TypeDescItr(const TypeDescriptorList &tdList); + TypeDescItr( const TypeDescriptorList & tdList ); virtual ~TypeDescItr(); - void ResetItr() - { - cur = (TypeDescLinkNode *)(tdl.GetHead()); + void ResetItr() { + cur = ( TypeDescLinkNode * )( tdl.GetHead() ); } - const TypeDescriptor *NextTypeDesc(); + const TypeDescriptor * NextTypeDesc(); }; #endif //TYPEDESCRIPTORLIST_H diff --git a/src/clstepcore/typeOrRuleVar.cc b/src/clstepcore/typeOrRuleVar.cc index ced514c00..0b06f1949 100644 --- a/src/clstepcore/typeOrRuleVar.cc +++ b/src/clstepcore/typeOrRuleVar.cc @@ -2,16 +2,13 @@ #include -Type_or_rule::Type_or_rule() -{ +Type_or_rule::Type_or_rule() { std::cerr << "WARNING - Type_or_rule class doesn't seem to be complete - it has no members!" << std::endl; } -Type_or_rule::Type_or_rule(const Type_or_rule &tor): Dictionary_instance() -{ - (void) tor; //TODO once this class has some members, we'll actually have something to copy +Type_or_rule::Type_or_rule( const Type_or_rule & tor ): Dictionary_instance() { + ( void ) tor; //TODO once this class has some members, we'll actually have something to copy } -Type_or_rule::~Type_or_rule() -{ +Type_or_rule::~Type_or_rule() { } diff --git a/src/clstepcore/typeOrRuleVar.h b/src/clstepcore/typeOrRuleVar.h index a8c7cc959..09f78da59 100644 --- a/src/clstepcore/typeOrRuleVar.h +++ b/src/clstepcore/typeOrRuleVar.h @@ -5,15 +5,14 @@ #include "sc_export.h" -class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance -{ - public: - Type_or_rule(); - Type_or_rule(const Type_or_rule &); - virtual ~Type_or_rule(); +class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance { +public: + Type_or_rule(); + Type_or_rule( const Type_or_rule & ); + virtual ~Type_or_rule(); }; -typedef Type_or_rule *Type_or_rule_ptr; +typedef Type_or_rule * Type_or_rule_ptr; typedef Type_or_rule_ptr Type_or_rule_var; diff --git a/src/clstepcore/uniquenessRule.cc b/src/clstepcore/uniquenessRule.cc index 501ac9e4b..038f1a68f 100644 --- a/src/clstepcore/uniquenessRule.cc +++ b/src/clstepcore/uniquenessRule.cc @@ -3,118 +3,105 @@ #include Uniqueness_rule::Uniqueness_rule() - : _parent_entity(0) -{ +: _parent_entity( 0 ) { } -Uniqueness_rule::Uniqueness_rule(const Uniqueness_rule &ur): Dictionary_instance() -{ +Uniqueness_rule::Uniqueness_rule( const Uniqueness_rule & ur ): Dictionary_instance() { _label = ur._label; _parent_entity = ur._parent_entity; } -Uniqueness_rule::~Uniqueness_rule() -{ +Uniqueness_rule::~Uniqueness_rule() { // don't delete _parent_entity } -Uniqueness_rule__set::Uniqueness_rule__set(int defaultSize) -{ +Uniqueness_rule__set::Uniqueness_rule__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Uniqueness_rule_ptr[_bufsize]; _count = 0; } -Uniqueness_rule__set::~Uniqueness_rule__set() -{ +Uniqueness_rule__set::~Uniqueness_rule__set() { Clear(); delete[] _buf; } -void Uniqueness_rule__set::Check(int index) -{ - Uniqueness_rule_ptr *newbuf; +void Uniqueness_rule__set::Check( int index ) { + Uniqueness_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Uniqueness_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Uniqueness_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Uniqueness_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Uniqueness_rule__set::Insert(Uniqueness_rule_ptr v, int index) -{ - Uniqueness_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Uniqueness_rule__set::Insert( Uniqueness_rule_ptr v, int index ) { + Uniqueness_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Append(Uniqueness_rule_ptr v) -{ +void Uniqueness_rule__set::Append( Uniqueness_rule_ptr v ) { int index = _count; - Uniqueness_rule_ptr *spot; + Uniqueness_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Uniqueness_rule__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Uniqueness_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Uniqueness_rule_ptr)); + Uniqueness_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } } -int Uniqueness_rule__set::Index(Uniqueness_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Uniqueness_rule__set::Index( Uniqueness_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Uniqueness_rule_ptr &Uniqueness_rule__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Uniqueness_rule_ptr & Uniqueness_rule__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Uniqueness_rule__set::Count() -{ +int Uniqueness_rule__set::Count() { return _count; } -void Uniqueness_rule__set::Clear() -{ - for(int i = 0; i < _count; i ++) { +void Uniqueness_rule__set::Clear() { + for( int i = 0; i < _count; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/uniquenessRule.h b/src/clstepcore/uniquenessRule.h index ccac487c9..4751ce97b 100644 --- a/src/clstepcore/uniquenessRule.h +++ b/src/clstepcore/uniquenessRule.h @@ -9,85 +9,77 @@ class EntityDescriptor; -class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; /** Comment contained in the EXPRESS. + // non-SDAI + std::string _comment; /** Comment contained in the EXPRESS. * Should be properly formatted to include (* *) * Will be written to EXPRESS as-is (w/out formatting) */ #ifdef _MSC_VER #pragma warning( pop ) #endif - const EntityDescriptor *_parent_entity; - - Uniqueness_rule(); - Uniqueness_rule(const Uniqueness_rule &); - Uniqueness_rule(const char *label, EntityDescriptor *pe = 0) - : _label(label), _parent_entity(pe) { } - virtual ~Uniqueness_rule(); - - Express_id label_() const - { - return _label; - } - const EntityDescriptor *parent_() const - { - return _parent_entity; - } - std::string &comment_() - { - return _comment; - } - - void label_(const Express_id &ei) - { - _label = ei; - } - void parent_(const EntityDescriptor *pe) - { - _parent_entity = pe; - } - void comment_(const char *c) - { - _comment = c; - } + const EntityDescriptor * _parent_entity; + + Uniqueness_rule(); + Uniqueness_rule( const Uniqueness_rule & ); + Uniqueness_rule( const char * label, EntityDescriptor * pe = 0 ) + : _label( label ), _parent_entity( pe ) { } + virtual ~Uniqueness_rule(); + + Express_id label_() const { + return _label; + } + const EntityDescriptor * parent_() const { + return _parent_entity; + } + std::string & comment_() { + return _comment; + } + + void label_( const Express_id & ei ) { + _label = ei; + } + void parent_( const EntityDescriptor * pe ) { + _parent_entity = pe; + } + void comment_( const char * c ) { + _comment = c; + } }; -typedef Uniqueness_rule *Uniqueness_rule_ptr; - -class SC_CORE_EXPORT Uniqueness_rule__set -{ - public: - Uniqueness_rule__set(int = 16); - ~Uniqueness_rule__set(); - - Uniqueness_rule_ptr &operator[](int index); - void Insert(Uniqueness_rule_ptr, int index); - void Append(Uniqueness_rule_ptr); - void Remove(int index); - int Index(Uniqueness_rule_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Uniqueness_rule_ptr *_buf; - int _bufsize; - int _count; +typedef Uniqueness_rule * Uniqueness_rule_ptr; + +class SC_CORE_EXPORT Uniqueness_rule__set { +public: + Uniqueness_rule__set( int = 16 ); + ~Uniqueness_rule__set(); + + Uniqueness_rule_ptr & operator[]( int index ); + void Insert( Uniqueness_rule_ptr, int index ); + void Append( Uniqueness_rule_ptr ); + void Remove( int index ); + int Index( Uniqueness_rule_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Uniqueness_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Uniqueness_rule__set *Uniqueness_rule__set_ptr; +typedef Uniqueness_rule__set * Uniqueness_rule__set_ptr; typedef Uniqueness_rule__set_ptr Uniqueness_rule__set_var; #endif //UNIQUENESSRULE_H diff --git a/src/clstepcore/whereRule.cc b/src/clstepcore/whereRule.cc index 43db2f1e5..e60c64940 100644 --- a/src/clstepcore/whereRule.cc +++ b/src/clstepcore/whereRule.cc @@ -1,119 +1,106 @@ #include "whereRule.h" -Where_rule::Where_rule() -{ +Where_rule::Where_rule() { _type_or_rule = 0; } -Where_rule::Where_rule(const Where_rule &wr): Dictionary_instance() -{ +Where_rule::Where_rule( const Where_rule & wr ): Dictionary_instance() { _label = wr._label; _type_or_rule = wr._type_or_rule; } -Where_rule::~Where_rule() -{ +Where_rule::~Where_rule() { } /////////////////////////////////////////////////////////////////////////////// -Where_rule__list::Where_rule__list(int defaultSize) -{ +Where_rule__list::Where_rule__list( int defaultSize ) { _bufsize = defaultSize; _buf = new Where_rule_ptr[_bufsize]; _count = 0; } -Where_rule__list::~Where_rule__list() -{ +Where_rule__list::~Where_rule__list() { Clear(); delete[] _buf; } -void Where_rule__list::Check(int index) -{ - Where_rule_ptr *newbuf; +void Where_rule__list::Check( int index ) { + Where_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Where_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Where_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Where_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Where_rule__list::Insert(Where_rule_ptr v, int index) -{ - Where_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Where_rule__list::Insert( Where_rule_ptr v, int index ) { + Where_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Append(Where_rule_ptr v) -{ +void Where_rule__list::Append( Where_rule_ptr v ) { int index = _count; - Where_rule_ptr *spot; + Where_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Remove(int index) -{ - if(0 <= index && index < _count) { +void Where_rule__list::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Where_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Where_rule_ptr)); + Where_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Where_rule_ptr ) ); } } -int Where_rule__list::Index(Where_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Where_rule__list::Index( Where_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Where_rule_ptr &Where_rule__list::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Where_rule_ptr & Where_rule__list::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Where_rule__list::Count() -{ +int Where_rule__list::Count() { return _count; } -void Where_rule__list::Clear() -{ - for(int i = 0; i < _count ; i ++) { +void Where_rule__list::Clear() { + for( int i = 0; i < _count ; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/whereRule.h b/src/clstepcore/whereRule.h index 7ed9954a2..ef9043a4b 100644 --- a/src/clstepcore/whereRule.h +++ b/src/clstepcore/whereRule.h @@ -8,82 +8,74 @@ #include "sc_export.h" -class SC_CORE_EXPORT Where_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Where_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; // Comment contained in the EXPRESS. - // Should be properly formatted to include (* *) - // Will be written to EXPRESS as-is (w/out formatting) + // non-SDAI + std::string _comment; // Comment contained in the EXPRESS. + // Should be properly formatted to include (* *) + // Will be written to EXPRESS as-is (w/out formatting) #ifdef _MSC_VER #pragma warning( pop ) #endif - Type_or_rule_var _type_or_rule; + Type_or_rule_var _type_or_rule; - Where_rule(); - Where_rule(const Where_rule &); - Where_rule(const char *label, Type_or_rule_var tor = 0) - : _label(label), _type_or_rule(tor) { } - virtual ~Where_rule(); + Where_rule(); + Where_rule( const Where_rule & ); + Where_rule( const char * label, Type_or_rule_var tor = 0 ) + : _label( label ), _type_or_rule( tor ) { } + virtual ~Where_rule(); - Express_id label_() const - { - return _label; - } - Type_or_rule_var parent_item() const - { - return _type_or_rule; - } - std::string comment_() const - { - return _comment; - } + Express_id label_() const { + return _label; + } + Type_or_rule_var parent_item() const { + return _type_or_rule; + } + std::string comment_() const { + return _comment; + } - void label_(const Express_id &ei) - { - _label = ei; - } - void parent_item(const Type_or_rule_var &tor) - { - _type_or_rule = tor; - } - void comment_(const char *c) - { - _comment = c; - } + void label_( const Express_id & ei ) { + _label = ei; + } + void parent_item( const Type_or_rule_var & tor ) { + _type_or_rule = tor; + } + void comment_( const char * c ) { + _comment = c; + } }; -typedef Where_rule *Where_rule_ptr; +typedef Where_rule * Where_rule_ptr; -class SC_CORE_EXPORT Where_rule__list -{ - public: - Where_rule__list(int = 16); - ~Where_rule__list(); +class SC_CORE_EXPORT Where_rule__list { +public: + Where_rule__list( int = 16 ); + ~Where_rule__list(); - Where_rule_ptr &operator[](int index); - void Insert(Where_rule_ptr, int index); - void Append(Where_rule_ptr); - void Remove(int index); - int Index(Where_rule_ptr); + Where_rule_ptr & operator[]( int index ); + void Insert( Where_rule_ptr, int index ); + void Append( Where_rule_ptr ); + void Remove( int index ); + int Index( Where_rule_ptr ); - int Count(); - void Clear(); - private: - void Check(int index); - private: - Where_rule_ptr *_buf; - int _bufsize; - int _count; + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Where_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Where_rule__list *Where_rule__list_ptr; +typedef Where_rule__list * Where_rule__list_ptr; typedef Where_rule__list_ptr Where_rule__list_var; #endif //WHERERULE_H diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 514980ad9..2553f4fa5 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) @@ -33,7 +33,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) if(WIN32) target_link_libraries(steputils-static shlwapi) @@ -41,7 +41,7 @@ if(BUILD_STATIC_LIBS) endif() install(FILES ${SC_CLUTILS_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clutils) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils) # Local Variables: # tab-width: 8 diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index e97083dc0..a14f0dc08 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -23,82 +23,76 @@ ** Status: complete ******************************************************************/ -char ToLower(const char c) -{ - if(isupper(c)) { - return (tolower(c)); +char ToLower( const char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } -char ToUpper(const char c) -{ - if(islower(c)) { - return (toupper(c)); +char ToUpper( const char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } // Place in strNew a lowercase version of strOld. -char *StrToLower(const char *strOld, char *strNew) -{ +char * StrToLower( const char * strOld, char * strNew ) { int i = 0; - while(strOld[i] != '\0') { - strNew[i] = ToLower(strOld[i]); + while( strOld[i] != '\0' ) { + strNew[i] = ToLower( strOld[i] ); i++; } strNew[i] = '\0'; return strNew; } -const char *StrToLower(const char *word, std::string &s) -{ +const char * StrToLower( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *StrToUpper(const char *word, std::string &s) -{ +const char * StrToUpper( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *StrToConstant(const char *word, std::string &s) -{ +const char * StrToConstant( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } /**************************************************************//** @@ -109,10 +103,9 @@ const char *StrToConstant(const char *word, std::string &s) ** == 0 when str1 equals str2 ** > 0 when str1 greater then str2 ******************************************************************/ -int StrCmpIns(const char *str1, const char *str2) -{ +int StrCmpIns( const char * str1, const char * str2 ) { char c1, c2; - while((c1 = tolower(*str1)) == (c2 = tolower(*str2)) && c1 != '\0') { + while( ( c1 = tolower( *str1 ) ) == ( c2 = tolower( *str2 ) ) && c1 != '\0' ) { str1++; str2++; } @@ -122,18 +115,17 @@ int StrCmpIns(const char *str1, const char *str2) /** * Test if a string ends with the given suffix. */ -bool StrEndsWith(const std::string &s, const char *suf) -{ - if(suf == NULL) { +bool StrEndsWith( const std::string & s, const char * suf ) { + if( suf == NULL ) { return false; } std::string suffix = suf; size_t sLen = s.length(); size_t suffixLen = suffix.length(); - if(sLen < suffixLen) { + if( sLen < suffixLen ) { return false; } - if(s.substr(sLen - suffixLen).compare(suffix) == 0) { + if( s.substr( sLen - suffixLen ).compare( suffix ) == 0 ) { return true; } return false; @@ -142,39 +134,38 @@ bool StrEndsWith(const std::string &s, const char *suf) /** * Extract the next delimited string from the istream. */ -std::string GetLiteralStr(istream &in, ErrorDescriptor *err) -{ +std::string GetLiteralStr( istream & in, ErrorDescriptor * err ) { std::string s; in >> std::ws; // skip whitespace - if(in.good() && in.peek() == STRING_DELIM) { + if( in.good() && in.peek() == STRING_DELIM ) { s += in.get(); bool allDelimsEscaped = true; - while(in.good()) { - if(in.peek() == STRING_DELIM) { + while( in.good() ) { + if( in.peek() == STRING_DELIM ) { // A delimiter closes the string unless it's followed by another // delimiter, in which case it's escaped. \S\ starts an ISO // 8859 character escape sequence, so we ignore delimiters // prefixed with \S\. - if(!StrEndsWith(s, "\\S\\")) { + if( !StrEndsWith( s, "\\S\\" ) ) { allDelimsEscaped = !allDelimsEscaped; } - } else if(!allDelimsEscaped) { + } else if( !allDelimsEscaped ) { // Found normal char after unescaped delim, so last delim // that was appended terminated the string. break; } - if(!in.eof()) { + if( !in.eof() ) { s += in.get(); } } - if(allDelimsEscaped) { + if( allDelimsEscaped ) { // Any delimiters found after the opening delimiter were escaped, // so the string is unclosed. // non-recoverable error - err->AppendToDetailMsg("Missing closing quote on string value.\n"); - err->AppendToUserMsg("Missing closing quote on string value.\n"); - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->AppendToDetailMsg( "Missing closing quote on string value.\n" ); + err->AppendToUserMsg( "Missing closing quote on string value.\n" ); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); } } return s; @@ -186,22 +177,21 @@ std::string GetLiteralStr(istream &in, ErrorDescriptor *err) ** Capitalizes first char of word, rest is lowercase. Removes '_'. ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } @@ -213,10 +203,9 @@ const char *PrettyTmpName(const char *oldname) ** Side Effects: allocates memory for the new name ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -char *PrettyNewName(const char *oldname) -{ - char *name = new char [strlen(oldname) + 1]; - strcpy(name, PrettyTmpName(oldname)); +char * PrettyNewName( const char * oldname ) { + char * name = new char [strlen( oldname ) + 1]; + strcpy( name, PrettyTmpName( oldname ) ); return name; } @@ -256,82 +245,80 @@ char *PrettyNewName(const char *oldname) *** not then it is an error but the bad chars are not read since you have *** no way to know when to stop. **/ -Severity CheckRemainingInput(istream &in, ErrorDescriptor *err, - const char *typeName, // used in error message - const char *delimiterList) // e.g. ",)" -{ +Severity CheckRemainingInput( istream & in, ErrorDescriptor * err, + const char * typeName, // used in error message + const char * delimiterList ) { // e.g. ",)" string skipBuf; ostringstream errMsg; - if(in.eof()) { + if( in.eof() ) { // no error return err->severity(); - } else if(in.bad()) { + } else if( in.bad() ) { // Bad bit must have been set during read. Recovery is impossible. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); } else { // At most the fail bit is set, so stream can still be read. // Clear errors and skip whitespace. in.clear(); in >> ws; - if(in.eof()) { + if( in.eof() ) { // no error return err->severity(); } - if(delimiterList != NULL) { + if( delimiterList != NULL ) { // If the next char is a delimiter then there's no error. char c = in.peek(); - if(strchr(delimiterList, c) == NULL) { + if( strchr( delimiterList, c ) == NULL ) { // Error. Extra input is more than just a delimiter and is // now considered invalid. We'll try to recover by skipping // to the next delimiter. - for(in.get(c); in && !strchr(delimiterList, c); in.get(c)) { + for( in.get( c ); in && !strchr( delimiterList, c ); in.get( c ) ) { skipBuf += c; } - if(strchr(delimiterList, c) != NULL) { + if( strchr( delimiterList, c ) != NULL ) { // Delimiter found. Recovery succeeded. - in.putback(c); + in.putback( c ); errMsg << "\tFound invalid " << typeName << " value...\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); - err->AppendToDetailMsg("\tdata lost looking for end of " - "attribute: "); - err->AppendToDetailMsg(skipBuf.c_str()); - err->AppendToDetailMsg("\n"); - - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( "\tdata lost looking for end of " + "attribute: " ); + err->AppendToDetailMsg( skipBuf.c_str() ); + err->AppendToDetailMsg( "\n" ); + + err->GreaterSeverity( SEVERITY_WARNING ); } else { // No delimiter found. Recovery failed. errMsg << "Unable to recover from input error while " << "reading " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); } } - } else if(in.good()) { + } else if( in.good() ) { // Error. Have more input, but lack of delimiter list means we // don't know where we can safely resume. Recovery is impossible. - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); } } return err->severity(); } -Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList) -{ - return CheckRemainingInput(in, err, typeName.c_str(), tokenList); +Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ) { + return CheckRemainingInput( in, err, typeName.c_str(), tokenList ); } diff --git a/src/clutils/Str.h b/src/clutils/Str.h index fb1859c4e..f605bfdda 100644 --- a/src/clutils/Str.h +++ b/src/clutils/Str.h @@ -25,23 +25,23 @@ #define STRING_DELIM '\'' #endif -SC_UTILS_EXPORT char ToLower(const char c); -SC_UTILS_EXPORT char ToUpper(const char c); -SC_UTILS_EXPORT char *StrToLower(const char *, char *); -SC_UTILS_EXPORT const char *StrToLower(const char *word, std::string &s); -SC_UTILS_EXPORT const char *StrToUpper(const char *word, std::string &s); -SC_UTILS_EXPORT const char *StrToConstant(const char *word, std::string &s); -SC_UTILS_EXPORT int StrCmpIns(const char *str1, const char *str2); -SC_UTILS_EXPORT const char *PrettyTmpName(const char *oldname); -SC_UTILS_EXPORT char *PrettyNewName(const char *oldname); -SC_UTILS_EXPORT char *EntityClassName(char *oldname); - -SC_UTILS_EXPORT bool StrEndsWith(const std::string &s, const char *suffix); -SC_UTILS_EXPORT std::string GetLiteralStr(istream &in, ErrorDescriptor *err); - -extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, - const char *typeName, // used in error message - const char *tokenList); // e.g. ",)" -extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList); +SC_UTILS_EXPORT char ToLower( const char c ); +SC_UTILS_EXPORT char ToUpper( const char c ); +SC_UTILS_EXPORT char * StrToLower( const char *, char * ); +SC_UTILS_EXPORT const char * StrToLower( const char * word, std::string & s ); +SC_UTILS_EXPORT const char * StrToUpper( const char * word, std::string & s ); +SC_UTILS_EXPORT const char * StrToConstant( const char * word, std::string & s ); +SC_UTILS_EXPORT int StrCmpIns( const char * str1, const char * str2 ); +SC_UTILS_EXPORT const char * PrettyTmpName( const char * oldname ); +SC_UTILS_EXPORT char * PrettyNewName( const char * oldname ); +SC_UTILS_EXPORT char * EntityClassName( char * oldname ); + +SC_UTILS_EXPORT bool StrEndsWith( const std::string & s, const char * suffix ); +SC_UTILS_EXPORT std::string GetLiteralStr( istream & in, ErrorDescriptor * err ); + +extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, + const char * typeName, // used in error message + const char * tokenList ); // e.g. ",)" +extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ); #endif diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index a55786762..337774342 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -66,14 +66,13 @@ // /////////////////////////////////////////////////////////////////////////////// -DirObj::DirObj(const char *dirName) -{ +DirObj::DirObj( const char * dirName ) { const int defaultSize = 256; fileListSize = defaultSize; - fileList = new char *[fileListSize]; + fileList = new char*[fileListSize]; fileCount = 0; - LoadDirectory(dirName); + LoadDirectory( dirName ); } /////////////////////////////////////////////////////////////////////////////// @@ -82,8 +81,7 @@ DirObj::DirObj(const char *dirName) // /////////////////////////////////////////////////////////////////////////////// -DirObj::~DirObj() -{ +DirObj::~DirObj() { ClearFileList(); delete [] fileList; } @@ -96,11 +94,10 @@ DirObj::~DirObj() // /////////////////////////////////////////////////////////////////////////////// -const char *DirObj::RealPath(const char *path) -{ - const char *realpath; +const char * DirObj::RealPath( const char * path ) { + const char * realpath; - if(path == 0 || *path == '\0') { + if( path == 0 || *path == '\0' ) { realpath = "./"; } else { realpath = path; @@ -114,12 +111,11 @@ const char *DirObj::RealPath(const char *path) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::LoadDirectory(const std::string &name) -{ - if(name.empty()) { - return Reset("./"); +bool DirObj::LoadDirectory( const std::string & name ) { + if( name.empty() ) { + return Reset( "./" ); } else { - return Reset(name); + return Reset( name ); } } @@ -130,10 +126,9 @@ bool DirObj::LoadDirectory(const std::string &name) // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Index(const char *name) -{ - for(int i = 0; i < fileCount; ++i) { - if(strcmp(fileList[i], name) == 0) { +int DirObj::Index( const char * name ) { + for( int i = 0; i < fileCount; ++i ) { + if( strcmp( fileList[i], name ) == 0 ) { return i; } } @@ -148,31 +143,30 @@ int DirObj::Index(const char *name) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::Reset(const std::string &path) -{ - bool successful = IsADirectory(path.c_str()); - if(successful) { +bool DirObj::Reset( const std::string & path ) { + bool successful = IsADirectory( path.c_str() ); + if( successful ) { #ifdef _WIN32 WIN32_FIND_DATA FindFileData; HANDLE hFind; ClearFileList(); - hFind = FindFirstFile(path.c_str(), &FindFileData); - if(hFind != INVALID_HANDLE_VALUE) { + hFind = FindFirstFile( path.c_str(), &FindFileData ); + if( hFind != INVALID_HANDLE_VALUE ) { int i = 0; do { - InsertFile(FindFileData.cFileName, i++); - } while(FindNextFile(hFind, &FindFileData)); - FindClose(hFind); + InsertFile( FindFileData.cFileName, i++ ); + } while( FindNextFile( hFind, &FindFileData ) ); + FindClose( hFind ); } #else - DIR *dir = opendir(path.c_str()); + DIR * dir = opendir( path.c_str() ); ClearFileList(); - for(struct dirent *d = readdir(dir); d != NULL; d = readdir(dir)) { - InsertFile(d->d_name, Position(d->d_name)); + for( struct dirent * d = readdir( dir ); d != NULL; d = readdir( dir ) ) { + InsertFile( d->d_name, Position( d->d_name ) ); } - closedir(dir); + closedir( dir ); #endif } else { std::cout << "not a directory: " << path << "!" << std::endl; @@ -188,16 +182,15 @@ bool DirObj::Reset(const std::string &path) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::IsADirectory(const char *path) -{ +bool DirObj::IsADirectory( const char * path ) { #ifdef _WIN32 - if(PathIsDirectory(path)) { + if( PathIsDirectory( path ) ) { return true; } return false; #else struct stat st; - return stat(path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR; + return stat( path, &st ) == 0 && ( st.st_mode & S_IFMT ) == S_IFDIR; #endif } @@ -222,36 +215,35 @@ bool DirObj::IsADirectory(const char *path) // /////////////////////////////////////////////////////////////////////////////// -std::string DirObj::Normalize(const std::string &path) -{ +std::string DirObj::Normalize( const std::string & path ) { std::string buf; - const char *slash; + const char * slash; #ifdef _WIN32 char b[MAX_PATH]; - PathCanonicalize(b, path.c_str()); + PathCanonicalize( b, path.c_str() ); slash = "\\"; #else - char *b; - b = realpath(path.c_str(), 0); + char * b; + b = realpath( path.c_str(), 0 ); slash = "/"; #endif - if(b == 0) { + if( b == 0 ) { buf.clear(); } else { - buf.assign(b); + buf.assign( b ); #if !defined(_WIN32) - free(b); + free(b); #endif } - if(buf.empty()) { + if( buf.empty() ) { buf = "."; - buf.append(slash); + buf.append( slash ); // if buf is a path to a directory and doesn't end with '/' - } else if(IsADirectory(buf.c_str()) && buf[buf.size()] != slash[0]) { - buf.append(slash); + } else if( IsADirectory( buf.c_str() ) && buf[buf.size()] != slash[0] ) { + buf.append( slash ); } return buf; } @@ -262,18 +254,17 @@ std::string DirObj::Normalize(const std::string &path) // /////////////////////////////////////////////////////////////////////////////// -const char *DirObj::ValidDirectories(const char *path) -{ +const char * DirObj::ValidDirectories( const char * path ) { #ifdef _WIN32 static char buf[MAX_PATH + 1]; #else static char buf[MAXPATHLEN + 1]; #endif - strcpy(buf, path); - int i = strlen(path); + strcpy( buf, path ); + int i = strlen( path ); - while(!IsADirectory(RealPath(buf)) && i >= 0) { - for(--i; buf[i] != '/' && i >= 0; --i) { + while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) { + for( --i; buf[i] != '/' && i >= 0; --i ) { ; } buf[i + 1] = '\0'; @@ -288,14 +279,13 @@ const char *DirObj::ValidDirectories(const char *path) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::CheckIndex(int index) -{ - char **newstrbuf; +void DirObj::CheckIndex( int index ) { + char ** newstrbuf; - if(index >= fileListSize) { - fileListSize = (index + 1) * 2; - newstrbuf = new char *[fileListSize]; - memmove(newstrbuf, fileList, fileCount * sizeof(char *)); + if( index >= fileListSize ) { + fileListSize = ( index + 1 ) * 2; + newstrbuf = new char*[fileListSize]; + memmove( newstrbuf, fileList, fileCount * sizeof( char * ) ); delete [] fileList; fileList = newstrbuf; } @@ -307,23 +297,22 @@ void DirObj::CheckIndex(int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::InsertFile(const char *f, int index) -{ - char **spot; - index = (index < 0) ? fileCount : index; +void DirObj::InsertFile( const char * f, int index ) { + char ** spot; + index = ( index < 0 ) ? fileCount : index; - if(index < fileCount) { - CheckIndex(fileCount + 1); + if( index < fileCount ) { + CheckIndex( fileCount + 1 ); spot = &fileList[index]; - memmove(spot + 1, spot, (fileCount - index)*sizeof(char *)); + memmove( spot + 1, spot, ( fileCount - index )*sizeof( char * ) ); } else { - CheckIndex(index); + CheckIndex( index ); spot = &fileList[index]; } #ifdef _MSC_VER - char *string = _strdup(f); + char * string = _strdup( f ); #else - char *string = strdup(f); + char * string = strdup( f ); #endif *spot = string; ++fileCount; @@ -335,12 +324,11 @@ void DirObj::InsertFile(const char *f, int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::RemoveFile(int index) -{ - if(index < --fileCount) { - const char **spot = (const char **)&fileList[index]; +void DirObj::RemoveFile( int index ) { + if( index < --fileCount ) { + const char ** spot = ( const char ** )&fileList[index]; delete spot; - memmove(spot, spot + 1, (fileCount - index)*sizeof(char *)); + memmove( spot, spot + 1, ( fileCount - index )*sizeof( char * ) ); } } @@ -350,10 +338,9 @@ void DirObj::RemoveFile(int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::ClearFileList() -{ - for(int i = 0; i < fileCount; ++i) { - free(fileList[i]); +void DirObj::ClearFileList() { + for( int i = 0; i < fileCount; ++i ) { + free( fileList[i] ); } fileCount = 0; } @@ -365,12 +352,11 @@ void DirObj::ClearFileList() // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Position(const char *f) -{ +int DirObj::Position( const char * f ) { int i; - for(i = 0; i < fileCount; ++i) { - if(strcmp(f, fileList[i]) < 0) { + for( i = 0; i < fileCount; ++i ) { + if( strcmp( f, fileList[i] ) < 0 ) { return i; } } diff --git a/src/clutils/dirobj.h b/src/clutils/dirobj.h index 534d9bc97..a89e28dad 100644 --- a/src/clutils/dirobj.h +++ b/src/clutils/dirobj.h @@ -47,63 +47,57 @@ /*****************************************************************************/ -class SC_UTILS_EXPORT DirObj -{ +class SC_UTILS_EXPORT DirObj { public: - DirObj(const char *dirName); + DirObj( const char * dirName ); virtual ~DirObj(); - bool LoadDirectory(const std::string &name); - static std::string Normalize(const std::string &s); + bool LoadDirectory( const std::string & name ); + static std::string Normalize( const std::string & s ); - const char *ValidDirectories(const char *); + const char * ValidDirectories( const char * ); - int Index(const char *); - const char *File(int index); + int Index( const char * ); + const char * File( int index ); // check for file in the currently loaded directory - bool FileExists(const char *file) - { - return Index(file) ? 1 : 0; + bool FileExists( const char * file ) { + return Index( file ) ? 1 : 0; } - bool FileExists(const std::string &file) - { - return Index(file.c_str()) ? true : false; + bool FileExists( const std::string & file ) { + return Index( file.c_str() ) ? true : false; } int Count(); - static bool IsADirectory(const char *); + static bool IsADirectory( const char * ); private: - const char *RealPath(const char *); + const char * RealPath( const char * ); - bool Reset(const std::string &path); + bool Reset( const std::string & path ); void ClearFileList(); - void CheckIndex(int index); - void InsertFile(const char *, int index); - void AppendFile(const char *); - void RemoveFile(int index); - virtual int Position(const char *); + void CheckIndex( int index ); + void InsertFile( const char *, int index ); + void AppendFile( const char * ); + void RemoveFile( int index ); + virtual int Position( const char * ); private: - char **fileList; + char ** fileList; int fileCount; int fileListSize; }; // Return the number of files in the loaded directory. -inline int DirObj::Count() -{ +inline int DirObj::Count() { return fileCount; } // Insert a new file into the fileList. -inline void DirObj::AppendFile(const char *s) -{ - InsertFile(s, fileCount); +inline void DirObj::AppendFile( const char * s ) { + InsertFile( s, fileCount ); } // Return the file at the given index (starting at 0) in the fileList -inline const char *DirObj::File(int index) -{ - return (0 <= index && index < fileCount) ? fileList[index] : 0; +inline const char * DirObj::File( int index ) { + return ( 0 <= index && index < fileCount ) ? fileList[index] : 0; } #endif diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index 9d76c6e22..c5a998c8c 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -15,60 +15,58 @@ #include DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; -ostream *ErrorDescriptor::_out = 0; +ostream * ErrorDescriptor::_out = 0; void -ErrorDescriptor::PrintContents(ostream &out) const -{ +ErrorDescriptor::PrintContents( ostream & out ) const { out << "Severity: " << severityString() << endl; - if(!_userMsg.empty()) { + if( !_userMsg.empty() ) { out << "User message in parens:" << endl << "("; out << UserMsg() << ")" << endl; } - if(!_detailMsg.empty()) { + if( !_detailMsg.empty() ) { out << "Detailed message in parens:" << endl << "("; out << DetailMsg() << ")" << endl; } } -std::string ErrorDescriptor::severityString() const -{ +std::string ErrorDescriptor::severityString() const { std::string s; - switch(severity()) { + switch( severity() ) { case SEVERITY_NULL : { - s.assign("SEVERITY_NULL"); + s.assign( "SEVERITY_NULL" ); break; } case SEVERITY_USERMSG : { - s.assign("SEVERITY_USERMSG"); + s.assign( "SEVERITY_USERMSG" ); break; } case SEVERITY_INCOMPLETE : { - s.assign("SEVERITY_INCOMPLETE"); + s.assign( "SEVERITY_INCOMPLETE" ); break; } case SEVERITY_WARNING : { - s.assign("SEVERITY_WARNING"); + s.assign( "SEVERITY_WARNING" ); break; } case SEVERITY_INPUT_ERROR : { - s.assign("SEVERITY_INPUT_ERROR"); + s.assign( "SEVERITY_INPUT_ERROR" ); break; } case SEVERITY_BUG : { - s.assign("SEVERITY_BUG"); + s.assign( "SEVERITY_BUG" ); break; } case SEVERITY_EXIT : { - s.assign("SEVERITY_EXIT"); + s.assign( "SEVERITY_EXIT" ); break; } case SEVERITY_DUMP : { - s.assign("SEVERITY_DUMP"); + s.assign( "SEVERITY_DUMP" ); break; } case SEVERITY_MAX : { - s.assign("SEVERITY_MAX"); + s.assign( "SEVERITY_MAX" ); break; } } @@ -77,36 +75,35 @@ std::string ErrorDescriptor::severityString() const Severity -ErrorDescriptor::GetCorrSeverity(const char *s) -{ - if(s && s[0] != 0) { +ErrorDescriptor::GetCorrSeverity( const char * s ) { + if( s && s[0] != 0 ) { std::string s2; - StrToUpper(s, s2); - if(!s2.compare("SEVERITY_NULL")) { + StrToUpper( s, s2 ); + if( !s2.compare( "SEVERITY_NULL" ) ) { return SEVERITY_NULL; } - if(!s2.compare("SEVERITY_USERMSG")) { + if( !s2.compare( "SEVERITY_USERMSG" ) ) { return SEVERITY_USERMSG; } - if(!s2.compare("SEVERITY_INCOMPLETE")) { + if( !s2.compare( "SEVERITY_INCOMPLETE" ) ) { return SEVERITY_INCOMPLETE; } - if(!s2.compare("SEVERITY_WARNING")) { + if( !s2.compare( "SEVERITY_WARNING" ) ) { return SEVERITY_WARNING; } - if(!s2.compare("SEVERITY_INPUT_ERROR")) { + if( !s2.compare( "SEVERITY_INPUT_ERROR" ) ) { return SEVERITY_INPUT_ERROR; } - if(!s2.compare("SEVERITY_BUG")) { + if( !s2.compare( "SEVERITY_BUG" ) ) { return SEVERITY_BUG; } - if(!s2.compare("SEVERITY_EXIT")) { + if( !s2.compare( "SEVERITY_EXIT" ) ) { return SEVERITY_EXIT; } - if(!s2.compare("SEVERITY_DUMP")) { + if( !s2.compare( "SEVERITY_DUMP" ) ) { return SEVERITY_DUMP; } - if(!s2.compare("SEVERITY_MAX")) { + if( !s2.compare( "SEVERITY_MAX" ) ) { return SEVERITY_MAX; } } @@ -116,53 +113,43 @@ ErrorDescriptor::GetCorrSeverity(const char *s) return SEVERITY_BUG; } -ErrorDescriptor::ErrorDescriptor(Severity s, DebugLevel d) : _severity(s) -{ - if(d != DEBUG_OFF) { +ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) { + if( d != DEBUG_OFF ) { _debug_level = d; } } -ErrorDescriptor::~ErrorDescriptor(void) -{ +ErrorDescriptor::~ErrorDescriptor( void ) { } -void ErrorDescriptor::UserMsg(const char *msg) -{ - _userMsg.assign(msg); +void ErrorDescriptor::UserMsg( const char * msg ) { + _userMsg.assign( msg ); } -void ErrorDescriptor::PrependToUserMsg(const char *msg) -{ - _userMsg.insert(0, msg); +void ErrorDescriptor::PrependToUserMsg( const char * msg ) { + _userMsg.insert( 0, msg ); } -void ErrorDescriptor::AppendToUserMsg(const char c) -{ - _userMsg.push_back(c); +void ErrorDescriptor::AppendToUserMsg( const char c ) { + _userMsg.push_back( c ); } -void ErrorDescriptor::AppendToUserMsg(const char *msg) -{ - _userMsg.append(msg); +void ErrorDescriptor::AppendToUserMsg( const char * msg ) { + _userMsg.append( msg ); } -void ErrorDescriptor::DetailMsg(const char *msg) -{ - _detailMsg.assign(msg); +void ErrorDescriptor::DetailMsg( const char * msg ) { + _detailMsg.assign( msg ); } -void ErrorDescriptor::PrependToDetailMsg(const char *msg) -{ - _detailMsg.insert(0, msg); +void ErrorDescriptor::PrependToDetailMsg( const char * msg ) { + _detailMsg.insert( 0, msg ); } -void ErrorDescriptor::AppendToDetailMsg(const char c) -{ - _detailMsg.push_back(c); +void ErrorDescriptor::AppendToDetailMsg( const char c ) { + _detailMsg.push_back( c ); } -void ErrorDescriptor::AppendToDetailMsg(const char *msg) -{ - _detailMsg.append(msg); +void ErrorDescriptor::AppendToDetailMsg( const char * msg ) { + _detailMsg.append( msg ); } diff --git a/src/clutils/errordesc.h b/src/clutils/errordesc.h index c2c3671e4..4ab284b2d 100644 --- a/src/clutils/errordesc.h +++ b/src/clutils/errordesc.h @@ -53,8 +53,7 @@ typedef int DebugLevel; ** Status: ******************************************************************/ -class SC_UTILS_EXPORT ErrorDescriptor -{ +class SC_UTILS_EXPORT ErrorDescriptor { private: #ifdef _MSC_VER #pragma warning( push ) @@ -68,90 +67,76 @@ class SC_UTILS_EXPORT ErrorDescriptor Severity _severity; static DebugLevel _debug_level; - static ostream *_out; // note this will not be persistent + static ostream * _out; // note this will not be persistent public: - ErrorDescriptor(Severity s = SEVERITY_NULL, - DebugLevel d = DEBUG_OFF); - ~ErrorDescriptor(void); + ErrorDescriptor( Severity s = SEVERITY_NULL, + DebugLevel d = DEBUG_OFF ); + ~ErrorDescriptor( void ); - void PrintContents(ostream &out = cout) const; + void PrintContents( ostream & out = cout ) const; - void ClearErrorMsg() - { + void ClearErrorMsg() { _severity = SEVERITY_NULL; _userMsg.clear(); _detailMsg.clear(); } // return the enum value of _severity - Severity severity() const - { + Severity severity() const { return _severity; } - Severity severity(Severity s) - { - return (_severity = s); + Severity severity( Severity s ) { + return ( _severity = s ); } std::string severityString() const; - Severity GetCorrSeverity(const char *s); - Severity GreaterSeverity(Severity s) - { - return ((s < _severity) ? _severity = s : _severity); + Severity GetCorrSeverity( const char * s ); + Severity GreaterSeverity( Severity s ) { + return ( ( s < _severity ) ? _severity = s : _severity ); } - std::string UserMsg() const - { + std::string UserMsg() const { return _userMsg; } - void UserMsg(const char *msg); - void UserMsg(const std::string msg) - { - _userMsg.assign(msg); + void UserMsg( const char * msg ); + void UserMsg( const std::string msg ) { + _userMsg.assign( msg ); } - void AppendToUserMsg(const char *msg); - void AppendToUserMsg(const char c); - void AppendToUserMsg(const std::string &msg) - { - _userMsg.append(msg); + void AppendToUserMsg( const char * msg ); + void AppendToUserMsg( const char c ); + void AppendToUserMsg( const std::string & msg ) { + _userMsg.append( msg ); } - void PrependToUserMsg(const char *msg); + void PrependToUserMsg( const char * msg ); - std::string DetailMsg() const - { + std::string DetailMsg() const { return _detailMsg; } - void DetailMsg(const std::string msg) - { - _detailMsg.assign(msg); + void DetailMsg( const std::string msg ) { + _detailMsg.assign( msg ); } - void DetailMsg(const char *msg); - void AppendToDetailMsg(const char *msg); - void AppendToDetailMsg(const std::string &msg) - { - _detailMsg.append(msg); + void DetailMsg( const char * msg ); + void AppendToDetailMsg( const char * msg ); + void AppendToDetailMsg( const std::string & msg ) { + _detailMsg.append( msg ); } - void PrependToDetailMsg(const char *msg); - void AppendToDetailMsg(const char c); - - Severity AppendFromErrorArg(ErrorDescriptor *err) - { - GreaterSeverity(err->severity()); - AppendToDetailMsg(err->DetailMsg()); - AppendToUserMsg(err->UserMsg()); + void PrependToDetailMsg( const char * msg ); + void AppendToDetailMsg( const char c ); + + Severity AppendFromErrorArg( ErrorDescriptor * err ) { + GreaterSeverity( err->severity() ); + AppendToDetailMsg( err->DetailMsg() ); + AppendToUserMsg( err->UserMsg() ); return severity(); } - DebugLevel debug_level() const - { + DebugLevel debug_level() const { return _debug_level; } - void debug_level(DebugLevel d) - { + void debug_level( DebugLevel d ) { _debug_level = d; } - void SetOutput(ostream *o) - { + void SetOutput( ostream * o ) { _out = o; } } ; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index b29c021a2..3036ab19d 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -24,12 +24,11 @@ // void GenNodeList::Append(GenericNode *node) from the gennodelist.h ////////////////////////////////////////////////////////////////////////////// -void GenericNode::Append(GenNodeList *list) -{ +void GenericNode::Append( GenNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "GenericNode::Append()\n"; // if(debug_level >= PrintValues) // cout << "GenericNode::this : '" << this << "'\n"; - list->Append(this); + list->Append( this ); } diff --git a/src/clutils/gennode.h b/src/clutils/gennode.h index f8285a827..c4c630244 100644 --- a/src/clutils/gennode.h +++ b/src/clutils/gennode.h @@ -27,32 +27,28 @@ class DisplayNodeList; // If you delete this object it first removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenericNode -{ +class SC_UTILS_EXPORT GenericNode { friend class GenNodeList; friend class MgrNodeList; friend class DisplayNodeList; protected: - GenericNode *next; - GenericNode *prev; + GenericNode * next; + GenericNode * prev; public: GenericNode(); virtual ~GenericNode(); - GenericNode *Next() - { + GenericNode * Next() { return next; } - GenericNode *Prev() - { + GenericNode * Prev() { return prev; } - virtual void Append(GenNodeList *list); - virtual void Remove() - { - (next) ? (next->prev = prev) : 0; - (prev) ? (prev->next = next) : 0; + virtual void Append( GenNodeList * list ); + virtual void Remove() { + ( next ) ? ( next->prev = prev ) : 0; + ( prev ) ? ( prev->next = next ) : 0; /* // if(next) // next->prev = prev; diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index 16e3a3b7b..f78acbd14 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -20,79 +20,70 @@ #ifndef HAVE_MEMMOVE extern "C" { - extern void *memmove(void *, const void *, size_t); + extern void * memmove( void *, const void *, size_t ); } #endif -GenericNode::GenericNode() -{ +GenericNode::GenericNode() { next = 0; prev = 0; } -GenericNode::~GenericNode() -{ +GenericNode::~GenericNode() { Remove(); } -GenNodeArray::GenNodeArray(int defaultSize) -{ +GenNodeArray::GenNodeArray( int defaultSize ) { _bufsize = defaultSize; _buf = new GenericNode*[_bufsize]; - memset(_buf, 0, _bufsize * sizeof(GenericNode *)); + memset( _buf, 0, _bufsize * sizeof( GenericNode * ) ); _count = 0; } -GenNodeArray::~GenNodeArray() -{ +GenNodeArray::~GenNodeArray() { delete [] _buf; } -int GenNodeArray::Index(GenericNode **gn) -{ - return ((gn - _buf) / sizeof(GenericNode *)); +int GenNodeArray::Index( GenericNode ** gn ) { + return ( ( gn - _buf ) / sizeof( GenericNode * ) ); } -void GenNodeArray::Append(GenericNode *gn) -{ - Insert(gn, _count); +void GenNodeArray::Append( GenericNode * gn ) { + Insert( gn, _count ); } -int GenNodeArray::Insert(GenericNode *gn) -{ - return Insert(gn, _count); +int GenNodeArray::Insert( GenericNode * gn ) { + return Insert( gn, _count ); } void -GenNodeArray::Check(int index) -{ - GenericNode **newbuf; +GenNodeArray::Check( int index ) { + GenericNode ** newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new GenericNode*[_bufsize]; - memset(newbuf, 0, _bufsize * sizeof(GenericNode *)); - memmove(newbuf, _buf, _count * sizeof(GenericNode *)); + memset( newbuf, 0, _bufsize * sizeof( GenericNode * ) ); + memmove( newbuf, _buf, _count * sizeof( GenericNode * ) ); delete [] _buf; _buf = newbuf; } } int -GenNodeArray::Insert(GenericNode *gn, int index) -{ - const GenericNode **spot; - index = (index < 0) ? _count : index; +GenNodeArray::Insert( GenericNode * gn, int index ) { + const GenericNode ** spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); - spot = (const GenericNode **)&_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(GenericNode *)); + if( index < _count ) { + Check( _count + 1 ); + spot = ( const GenericNode ** )&_buf[index]; + memmove( spot + 1, spot, ( _count - index )*sizeof( GenericNode * ) ); } else { - Check(index); - spot = (const GenericNode **)&_buf[index]; + Check( index ); + spot = ( const GenericNode ** )&_buf[index]; } *spot = gn; ++_count; @@ -100,39 +91,35 @@ GenNodeArray::Insert(GenericNode *gn, int index) } void -GenNodeArray::Remove(int index) -{ - if(0 <= index && index < _count) { +GenNodeArray::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - const GenericNode **spot = (const GenericNode **)&_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(GenericNode *)); + const GenericNode ** spot = ( const GenericNode ** )&_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( GenericNode * ) ); _buf[_count] = 0; } } -void GenNodeArray::ClearEntries() -{ +void GenNodeArray::ClearEntries() { int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; } -void GenNodeArray::DeleteEntries() -{ +void GenNodeArray::DeleteEntries() { int i; - for(i = 0 ; i < _count; i++) { - delete(_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( _buf[i] ); } _count = 0; } -int GenNodeArray::Index(GenericNode *gn) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == gn) { +int GenNodeArray::Index( GenericNode * gn ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == gn ) { return i; } } diff --git a/src/clutils/gennodearray.h b/src/clutils/gennodearray.h index 19de427c1..4c0ee075a 100644 --- a/src/clutils/gennodearray.h +++ b/src/clutils/gennodearray.h @@ -38,30 +38,29 @@ // DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeArray -{ +class SC_UTILS_EXPORT GenNodeArray { public: - GenNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); + GenNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); virtual ~GenNodeArray(); - GenericNode *&operator[](int index); - virtual int Index(GenericNode *gn); - virtual int Index(GenericNode **gn); + GenericNode *& operator[]( int index ); + virtual int Index( GenericNode * gn ); + virtual int Index( GenericNode ** gn ); int Count() const; - virtual void Append(GenericNode *gn); - virtual int Insert(GenericNode *gn); - virtual int Insert(GenericNode *gn, int index); - virtual void Remove(int index); + virtual void Append( GenericNode * gn ); + virtual int Insert( GenericNode * gn ); + virtual int Insert( GenericNode * gn, int index ); + virtual void Remove( int index ); virtual void ClearEntries(); virtual void DeleteEntries(); protected: - virtual void Check(int index); + virtual void Check( int index ); - GenericNode **_buf; // the array + GenericNode ** _buf; // the array int _bufsize; // the possible number of entries in the array int _count; // the number of entries in the array }; @@ -70,14 +69,12 @@ class SC_UTILS_EXPORT GenNodeArray // class GenNodeArray inline public functions ////////////////////////////////////////////////////////////////////////////// -inline GenericNode *&GenNodeArray::operator[](int index) -{ - Check(index); +inline GenericNode *& GenNodeArray::operator[]( int index ) { + Check( index ); return _buf[index]; } -inline int GenNodeArray::Count() const -{ +inline int GenNodeArray::Count() const { return _count; } diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index 478601172..9560a72b1 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -19,9 +19,8 @@ #include // inserts after existNode -void GenNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ +void GenNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { newNode->next = existNode->next; newNode->next->prev = newNode; @@ -30,9 +29,8 @@ void GenNodeList::InsertAfter(GenericNode *newNode, } // inserts before existNode -void GenNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ +void GenNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { existNode->prev->next = newNode; newNode->prev = existNode->prev; @@ -41,29 +39,26 @@ void GenNodeList::InsertBefore(GenericNode *newNode, } // inserts before the head node -void GenNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void GenNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } void -GenNodeList::Remove(GenericNode *node) -{ - if(node != head) { +GenNodeList::Remove( GenericNode * node ) { + if( node != head ) { node->next->prev = node->prev; node->prev->next = node->next; node->next = 0; node->prev = 0; } } -void GenNodeList::ClearEntries() -{ +void GenNodeList::ClearEntries() { // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::ClearEntries()\n"; - GenericNode *gnPrev = head->Next(); - GenericNode *gn = gnPrev->Next(); + GenericNode * gnPrev = head->Next(); + GenericNode * gn = gnPrev->Next(); - while(gnPrev != head) { + while( gnPrev != head ) { gnPrev->prev = 0; gnPrev->next = 0; gnPrev = gn; @@ -73,15 +68,14 @@ void GenNodeList::ClearEntries() head->prev = head; } -void GenNodeList::DeleteEntries() -{ +void GenNodeList::DeleteEntries() { // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::DeleteEntries()\n"; - GenericNode *gnPrev = head->Next(); - GenericNode *gn; + GenericNode * gnPrev = head->Next(); + GenericNode * gn; head->next = 0; - while(gnPrev != head) { + while( gnPrev != head ) { gn = gnPrev->Next(); delete gnPrev; gnPrev = gn; diff --git a/src/clutils/gennodelist.h b/src/clutils/gennodelist.h index 3ba1f50c2..4751f6044 100644 --- a/src/clutils/gennodelist.h +++ b/src/clutils/gennodelist.h @@ -26,33 +26,30 @@ // as its head, you need to call DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeList -{ +class SC_UTILS_EXPORT GenNodeList { public: - GenNodeList(GenericNode *headNode); - virtual ~GenNodeList() - { + GenNodeList( GenericNode * headNode ); + virtual ~GenNodeList() { delete head; } - GenericNode *GetHead() - { + GenericNode * GetHead() { return head; } virtual void ClearEntries(); virtual void DeleteEntries(); // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); - virtual void Remove(GenericNode *node); + virtual void Remove( GenericNode * node ); protected: - GenericNode *head; + GenericNode * head; }; ////////////////////////////////////////////////////////////////////////////// @@ -61,8 +58,7 @@ class SC_UTILS_EXPORT GenNodeList // other classes) that aren't in this file ////////////////////////////////////////////////////////////////////////////// -inline GenNodeList::GenNodeList(GenericNode *headNode) -{ +inline GenNodeList::GenNodeList( GenericNode * headNode ) { head = headNode; head->next = head; head->prev = head; diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index c2c884d72..706780411 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -32,46 +32,43 @@ /* typedefs */ typedef unsigned long Address; -typedef struct Element *ElementP; -typedef struct Hash_Table *Hash_TableP; +typedef struct Element * ElementP; +typedef struct Hash_Table * Hash_TableP; /* Internal routines */ -Address SC_HASHhash(char *, Hash_TableP); -static void SC_HASHexpand_table(Hash_TableP); +Address SC_HASHhash( char *, Hash_TableP ); +static void SC_HASHexpand_table( Hash_TableP ); # ifdef HASH_STATISTICS static long HashAccesses, HashCollisions; # endif /// find entry in given hash table -void *SC_HASHfind(Hash_TableP t, char *s) -{ +void * SC_HASHfind( Hash_TableP t, char * s ) { struct Element e; - struct Element *ep; + struct Element * ep; e.key = s; e.symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ - ep = SC_HASHsearch(t, &e, HASH_FIND); - return(ep ? ep->data : 0); + ep = SC_HASHsearch( t, &e, HASH_FIND ); + return( ep ? ep->data : 0 ); } /// insert entry into given hash table -void SC_HASHinsert(Hash_TableP t, char *s, void *data) -{ +void SC_HASHinsert( Hash_TableP t, char * s, void * data ) { struct Element e, *e2; e.key = s; e.data = data; e.symbol = 0; - e2 = SC_HASHsearch(t, &e, HASH_INSERT); - if(e2) { - fprintf(stderr, "%s: Redeclaration of %s\n", __func__, s); + e2 = SC_HASHsearch( t, &e, HASH_INSERT ); + if( e2 ) { + fprintf( stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s ); } } /// create a hash table -Hash_TableP SC_HASHcreate(unsigned count) -{ +Hash_TableP SC_HASHcreate( unsigned count ) { unsigned int i; Hash_TableP table; @@ -80,52 +77,51 @@ Hash_TableP SC_HASHcreate(unsigned count) ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while(i < count) { + while( i < count ) { i <<= 1; } - count = DIV(i, SEGMENT_SIZE); + count = DIV( i, SEGMENT_SIZE ); - table = (Hash_TableP) SC_HASH_Table_new(); + table = ( Hash_TableP ) SC_HASH_Table_new(); table->SegmentCount = table->p = table->KeyCount = 0; /* ** First initialize directory to 0\'s ** DIRECTORY_SIZE must be same as in header */ - for(i = 0; i < DIRECTORY_SIZE; i++) { + for( i = 0; i < DIRECTORY_SIZE; i++ ) { table->Directory[i] = 0; } /* ** Allocate initial 'i' segments of buckets */ - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { table->Directory[i] = new struct Element * [SEGMENT_SIZE]; - for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL + for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL table->Directory[i][h] = 0; } } table->SegmentCount = count; - table->maxp = MUL(count, SEGMENT_SIZE); + table->maxp = MUL( count, SEGMENT_SIZE ); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef DEBUG - fprintf(stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount); + fprintf( stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount ); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return(table); + return( table ); } /** initialize pointer to beginning of hash table so we can * step through it on repeated calls to HASHlist - DEL */ -void SC_HASHlistinit(Hash_TableP table, HashEntry *he) -{ +void SC_HASHlistinit( Hash_TableP table, HashEntry * he ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -133,8 +129,7 @@ void SC_HASHlistinit(Hash_TableP table, HashEntry *he) he->e = 0; } -void SC_HASHlistinit_by_type(Hash_TableP table, HashEntry *he, char type) -{ +void SC_HASHlistinit_by_type( Hash_TableP table, HashEntry * he, char type ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -143,19 +138,18 @@ void SC_HASHlistinit_by_type(Hash_TableP table, HashEntry *he, char type) } /** provide a way to step through the hash */ -struct Element *SC_HASHlist(HashEntry *he) -{ +struct Element * SC_HASHlist( HashEntry * he ) { int i2 = he->i; int j2 = he->j; - struct Element **s; + struct Element ** s; he->e = 0; - for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { + for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { /* test probably unnecessary */ - if((s = he->table->Directory[he->i]) != NULL) { - for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { - if(!he->p) { + if( ( s = he->table->Directory[he->i] ) != NULL ) { + for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { + if( !he->p ) { he->p = s[he->j]; } @@ -163,45 +157,44 @@ struct Element *SC_HASHlist(HashEntry *he) setting it to he->e) and begin looking for a new value for he->p */ - while(he->p && he->type != '*' && he->type != he->p->type) { + while( he->p && he->type != '*' && he->type != he->p->type ) { he->p = he->p->next; } - if(he->p) { - if(he->e) { - return(he->e); + if( he->p ) { + if( he->e ) { + return( he->e ); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if(he->p) { - return(he->e); + if( he->p ) { + return( he->e ); } } j2 = 0; } } /* if he->e was set then it is last one */ - return(he->e); + return( he->e ); } /// destroy all elements in given table, then the table itself -void SC_HASHdestroy(Hash_TableP table) -{ - struct Element **s; - struct Element *p, *q; +void SC_HASHdestroy( Hash_TableP table ) { + struct Element ** s; + struct Element * p, *q; - if(table != HASH_NULL) { + if( table != HASH_NULL ) { unsigned int i, j; - for(i = 0; i < table->SegmentCount; i++) { + for( i = 0; i < table->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = table->Directory[i]) != NULL) { - for(j = 0; j < SEGMENT_SIZE; j++) { + if( ( s = table->Directory[i] ) != NULL ) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { p = s[j]; - while(p != NULL) { + while( p != NULL ) { q = p->next; - SC_HASH_Element_destroy(p); + SC_HASH_Element_destroy( p ); p = q; } } @@ -209,30 +202,29 @@ void SC_HASHdestroy(Hash_TableP table) delete [] table->Directory[i]; } } - SC_HASH_Table_destroy(table); + SC_HASH_Table_destroy( table ); # if defined(HASH_STATISTICS) && defined(DEBUG) - fprintf(stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions); + fprintf( stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions ); # endif } } /// search table for 'item', perform 'action' (find/insert/delete) -struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Action action) -{ +struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, Action action ) { Address h; - struct Element **CurrentSegment; + struct Element ** CurrentSegment; int SegmentIndex; int SegmentDir; - struct Element **p; - struct Element *q; - struct Element *deleteme; + struct Element ** p; + struct Element * q; + struct Element * deleteme; # ifdef HASH_STATISTICS HashAccesses++; # endif - h = SC_HASHhash(item->key, table); - SegmentDir = (int) DIV(h, SEGMENT_SIZE); - SegmentIndex = (int) MOD(h, SEGMENT_SIZE); + h = SC_HASHhash( item->key, table ); + SegmentDir = ( int ) DIV( h, SEGMENT_SIZE ); + SegmentIndex = ( int ) MOD( h, SEGMENT_SIZE ); /* ** valid segment ensured by HASHhash() */ @@ -245,7 +237,7 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act ** p = &element, and ** q = element */ - while(q != NULL && strcmp(q->key, item->key)) { + while( q != NULL && strcmp( q->key, item->key ) ) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -253,28 +245,28 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act # endif } /* at this point, we have either found the element or it doesn't exist */ - switch(action) { + switch( action ) { case HASH_FIND: - return((struct Element *)q); + return( ( struct Element * )q ); case HASH_DELETE: - if(!q) { - return(0); + if( !q ) { + return( 0 ); } /* at this point, element exists and action == DELETE */ deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - SC_HASH_Element_destroy(deleteme); + SC_HASH_Element_destroy( deleteme ); --table->KeyCount; - return(deleteme); /* of course, user shouldn't deref this! */ + return( deleteme ); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if(q != NULL) { - return(q); /* was return(0);!!!!!?!?! */ + if( q != NULL ) { + return( q ); /* was return(0);!!!!!?!?! */ } /* at this point, element does not exist and action == INSERT */ - q = (ElementP) SC_HASH_Element_new(); + q = ( ElementP ) SC_HASH_Element_new(); *p = q; /* link into chain */ /* ** Initialize new element @@ -289,61 +281,59 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act /* ** table over-full? */ - if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE) > table->MaxLoadFactor) { - SC_HASHexpand_table(table); /* doesn't affect q */ + if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE ) > table->MaxLoadFactor ) { + SC_HASHexpand_table( table ); /* doesn't affect q */ } } - return((struct Element *)0); /* was return (Element)q */ + return( ( struct Element * )0 ); /* was return (Element)q */ } /* ** Internal routines */ -Address SC_HASHhash(char *Key, Hash_TableP table) -{ +Address SC_HASHhash( char * Key, Hash_TableP table ) { Address h, address; - unsigned char *k = (unsigned char *)Key; + unsigned char * k = ( unsigned char * )Key; h = 0; /* ** Convert string to integer */ - while(*k) { - h = h * PRIME1 ^ (*k++ - ' '); + while( *k ) { + h = h * PRIME1 ^ ( *k++ - ' ' ); } h %= PRIME2; - address = MOD(h, table->maxp); - if(address < table->p) { - address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ + address = MOD( h, table->maxp ); + if( address < table->p ) { + address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ } - return(address); + return( address ); } -static void SC_HASHexpand_table(Hash_TableP table) -{ - struct Element **OldSegment, **NewSegment; - struct Element *Current, **Previous, **LastOfNew; +static void SC_HASHexpand_table( Hash_TableP table ) { + struct Element ** OldSegment, **NewSegment; + struct Element * Current, **Previous, **LastOfNew; - if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE)) { + if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE ) ) { /* ** Locate the bucket to be split */ Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; - OldSegmentDir = DIV(table->p, SEGMENT_SIZE); + OldSegmentDir = DIV( table->p, SEGMENT_SIZE ); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); + OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = (int) DIV(NewAddress, SEGMENT_SIZE); - NewSegmentIndex = (int) MOD(NewAddress, SEGMENT_SIZE); - if(NewSegmentIndex == 0) { + NewSegmentDir = ( int ) DIV( NewAddress, SEGMENT_SIZE ); + NewSegmentIndex = ( int ) MOD( NewAddress, SEGMENT_SIZE ); + if( NewSegmentIndex == 0 ) { table->Directory[NewSegmentDir] = new struct Element * [SEGMENT_SIZE]; - for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL + for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL table->Directory[NewSegmentDir][h] = 0; } } @@ -353,7 +343,7 @@ static void SC_HASHexpand_table(Hash_TableP table) ** Adjust state variables */ table->p++; - if(table->p == table->maxp) { + if( table->p == table->maxp ) { table->maxp <<= 1; table->p = 0; } @@ -365,8 +355,8 @@ static void SC_HASHexpand_table(Hash_TableP table) Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while(Current != NULL) { - if(SC_HASHhash(Current->key, table) == NewAddress) { + while( Current != NULL ) { + if( SC_HASHhash( Current->key, table ) == NewAddress ) { /* ** Attach it to the end of the new chain */ @@ -392,29 +382,28 @@ static void SC_HASHexpand_table(Hash_TableP table) /* for testing sc_hash */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table *t; +struct Hash_Table * t; HashEntry he; -main() -{ +main() { e1.key = "foo"; - e1.data = (char *)1; + e1.data = ( char * )1; e2.key = "bar"; - e2.data = (char *)2; + e2.data = ( char * )2; e3.key = "herschel"; - e3.data = (char *)3; - - t = SC_HASHcreate(100); - e = SC_HASHsearch(t, &e1, HASH_INSERT); - e = SC_HASHsearch(t, &e2, HASH_INSERT); - e = SC_HASHsearch(t, &e3, HASH_INSERT); - SC_HASHlistinit(t, &he); - for(;;) { - e = SC_HASHlist(&he); - if(!e) { - exit(0); + e3.data = ( char * )3; + + t = SC_HASHcreate( 100 ); + e = SC_HASHsearch( t, &e1, HASH_INSERT ); + e = SC_HASHsearch( t, &e2, HASH_INSERT ); + e = SC_HASHsearch( t, &e3, HASH_INSERT ); + SC_HASHlistinit( t, &he ); + for( ;; ) { + e = SC_HASHlist( &he ); + if( !e ) { + exit( 0 ); } - printf("found key %s, data %d\n", e->key, (int)e->data); + printf( "found key %s, data %d\n", e->key, ( int )e->data ); } } #endif diff --git a/src/clutils/sc_hash.h b/src/clutils/sc_hash.h index dde8245f3..f6a230ba9 100644 --- a/src/clutils/sc_hash.h +++ b/src/clutils/sc_hash.h @@ -96,10 +96,10 @@ typedef enum { HASH_FIND, HASH_INSERT, HASH_DELETE } Action; struct Element { - char *key; - void *data; - struct Element *next; - struct Symbol *symbol; //for debugging hash conflicts + char * key; + void * data; + struct Element * next; + struct Symbol * symbol; //for debugging hash conflicts char type; //user-supplied type }; @@ -112,16 +112,16 @@ struct Hash_Table { unsigned int MaxLoadFactor; #define DIRECTORY_SIZE 256 #define DIRECTORY_SIZE_SHIFT 8 // log2(DIRECTORY_SIZE) - struct Element **Directory[DIRECTORY_SIZE]; + struct Element ** Directory[DIRECTORY_SIZE]; }; typedef struct { unsigned int i; // segment index (i think) unsigned int j; // key index in segment (ditto) - struct Element *p; // usually the next element to be returned - struct Hash_Table *table; + struct Element * p; // usually the next element to be returned + struct Hash_Table * table; char type; - struct Element *e; /* originally thought of as a place for */ + struct Element * e; /* originally thought of as a place for */ /* the caller of HASHlist to temporarily stash the return value */ /* to allow the caller (i.e., DICTdo) to be macroized, but now */ /* conveniently used by HASHlist, which both stores the ultimate */ @@ -132,15 +132,15 @@ typedef struct { extern "C" { #endif -SC_UTILS_EXPORT struct Hash_Table *SC_HASHcreate(unsigned); -SC_UTILS_EXPORT void SC_HASHinitialize(void); -SC_UTILS_EXPORT void *SC_HASHfind(struct Hash_Table *, char *); -SC_UTILS_EXPORT void SC_HASHinsert(struct Hash_Table *, char *, void *); -SC_UTILS_EXPORT void SC_HASHdestroy(struct Hash_Table *); -SC_UTILS_EXPORT struct Element *SC_HASHsearch(struct Hash_Table *, const struct Element *, Action); -SC_UTILS_EXPORT void SC_HASHlistinit(struct Hash_Table *, HashEntry *); -SC_UTILS_EXPORT void SC_HASHlistinit_by_type(struct Hash_Table *, HashEntry *, char); -SC_UTILS_EXPORT struct Element *SC_HASHlist(HashEntry *); + SC_UTILS_EXPORT struct Hash_Table * SC_HASHcreate( unsigned ); + SC_UTILS_EXPORT void SC_HASHinitialize( void ); + SC_UTILS_EXPORT void * SC_HASHfind( struct Hash_Table *, char * ); + SC_UTILS_EXPORT void SC_HASHinsert( struct Hash_Table *, char *, void * ); + SC_UTILS_EXPORT void SC_HASHdestroy( struct Hash_Table * ); + SC_UTILS_EXPORT struct Element * SC_HASHsearch( struct Hash_Table *, const struct Element *, Action ); + SC_UTILS_EXPORT void SC_HASHlistinit( struct Hash_Table *, HashEntry * ); + SC_UTILS_EXPORT void SC_HASHlistinit_by_type( struct Hash_Table *, HashEntry *, char ); + SC_UTILS_EXPORT struct Element * SC_HASHlist( HashEntry * ); #ifdef __cplusplus } diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index 93cf8c911..fe438ad28 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -39,6 +39,10 @@ include_directories( SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) +if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(exp2cxx version_string) +endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + if(SC_ENABLE_TESTING) add_subdirectory(test) endif(SC_ENABLE_TESTING) diff --git a/src/exp2cxx/class_strings.c b/src/exp2cxx/class_strings.c index 69fe2b4b8..d1736a644 100644 --- a/src/exp2cxx/class_strings.c +++ b/src/exp2cxx/class_strings.c @@ -4,20 +4,19 @@ #include "class_strings.h" #include "express/type.h" -const char *ClassName(const char *oldname) -{ +const char * ClassName( const char * oldname ) { int i = 0, j = 0; static char newname [BUFSIZ]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENTITYCLASS_PREFIX) ; - j = strlen(ENTITYCLASS_PREFIX) ; - newname [j] = ToUpper(oldname [i]); + strcpy( newname, ENTITYCLASS_PREFIX ) ; + j = strlen( ENTITYCLASS_PREFIX ) ; + newname [j] = ToUpper( oldname [i] ); ++i; ++j; - while(oldname [i] != '\0') { - newname [j] = ToLower(oldname [i]); + while( oldname [i] != '\0' ) { + newname [j] = ToLower( oldname [i] ); /* if (oldname [i] == '_') */ /* character is '_' */ /* newname [++j] = ToUpper (oldname [++i]);*/ @@ -25,110 +24,108 @@ const char *ClassName(const char *oldname) ++j; } newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *ENTITYget_classname(Entity ent) -{ - const char *oldname = ENTITYget_name(ent); - return (ClassName(oldname)); +const char * ENTITYget_classname( Entity ent ) { + const char * oldname = ENTITYget_name( ent ); + return ( ClassName( oldname ) ); } /** like TYPEget_ctype, but caller must alloc a buffer of at least buf_siz * in many circumstances, this func will return a short string rather than using that buffer * buf_siz is ignored in those cases since it is meaningless */ -const char *TYPE_get_ctype(const Type t, char *retval, size_t buf_siz) -{ - const char *ptr = "_ptr", * var = "_var", * agg = "_agg"; - const char *overflowMsg = "buffer overflow detected at %s:%d!"; +const char * TYPE_get_ctype( const Type t, char * retval, size_t buf_siz ) { + const char * ptr = "_ptr", * var = "_var", * agg = "_agg"; + const char * overflowMsg = "buffer overflow detected at %s:%d!"; Class_Of_Type ctype; Type bt; - if(TYPEinherits_from(t, aggregate_)) { - bt = TYPEget_body(t)->base; - if(TYPEinherits_from(bt, aggregate_)) { - return("GenericAggregate"); + if( TYPEinherits_from( t, aggregate_ ) ) { + bt = TYPEget_body( t )->base; + if( TYPEinherits_from( bt, aggregate_ ) ) { + return( "GenericAggregate" ); } - ctype = TYPEget_type(bt); - if(ctype == integer_) { - return ("IntAggregate"); + ctype = TYPEget_type( bt ); + if( ctype == integer_ ) { + return ( "IntAggregate" ); } - if((ctype == number_) || (ctype == real_)) { - return ("RealAggregate"); + if( ( ctype == number_ ) || ( ctype == real_ ) ) { + return ( "RealAggregate" ); } - if(ctype == entity_) { - return("EntityAggregate"); + if( ctype == entity_ ) { + return( "EntityAggregate" ); } - if((ctype == enumeration_) || (ctype == select_)) { - const char *tmp = TYPE_get_ctype(bt, retval, buf_siz - strlen(retval) - 1); - if(tmp != retval) { - strncpy(retval, tmp, buf_siz - strlen(retval) - 1); + if( ( ctype == enumeration_ ) || ( ctype == select_ ) ) { + const char * tmp = TYPE_get_ctype( bt, retval, buf_siz - strlen( retval ) - 1 ); + if( tmp != retval ) { + strncpy( retval, tmp, buf_siz - strlen( retval ) - 1 ); } - if(strlen(retval) + strlen(agg) < buf_siz) { - strcat(retval, agg); + if( strlen( retval ) + strlen( agg ) < buf_siz ) { + strcat( retval, agg ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } - return (retval); + return ( retval ); } - if(ctype == logical_) { - return ("LOGICALS"); + if( ctype == logical_ ) { + return ( "LOGICALS" ); } - if(ctype == boolean_) { - return ("BOOLEANS"); + if( ctype == boolean_ ) { + return ( "BOOLEANS" ); } - if(ctype == string_) { - return("StringAggregate"); + if( ctype == string_ ) { + return( "StringAggregate" ); } - if(ctype == binary_) { - return("BinaryAggregate"); + if( ctype == binary_ ) { + return( "BinaryAggregate" ); } } /* the rest is for things that are not aggregates */ - ctype = TYPEget_type(t); + ctype = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if(ctype == logical_) { - return ("SDAI_LOGICAL"); + if( ctype == logical_ ) { + return ( "SDAI_LOGICAL" ); } /* case TYPE_BOOLEAN: */ - if(ctype == boolean_) { - return ("SDAI_BOOLEAN"); + if( ctype == boolean_ ) { + return ( "SDAI_BOOLEAN" ); } /* case TYPE_INTEGER: */ - if(ctype == integer_) { - return ("SDAI_Integer"); + if( ctype == integer_ ) { + return ( "SDAI_Integer" ); } /* case TYPE_REAL: * case TYPE_NUMBER: */ - if((ctype == number_) || (ctype == real_)) { - return ("SDAI_Real"); + if( ( ctype == number_ ) || ( ctype == real_ ) ) { + return ( "SDAI_Real" ); } /* case TYPE_STRING: */ - if(ctype == string_) { - return ("SDAI_String"); + if( ctype == string_ ) { + return ( "SDAI_String" ); } /* case TYPE_BINARY: */ - if(ctype == binary_) { - return ("SDAI_Binary"); + if( ctype == binary_ ) { + return ( "SDAI_Binary" ); } /* case TYPE_ENTITY: */ - if(ctype == entity_) { - strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); - if(strlen(retval) + strlen(ptr) < buf_siz) { - strcat(retval, ptr); + if( ctype == entity_ ) { + strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); + if( strlen( retval ) + strlen( ptr ) < buf_siz ) { + strcat( retval, ptr ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } return retval; @@ -136,113 +133,105 @@ const char *TYPE_get_ctype(const Type t, char *retval, size_t buf_siz) } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if(ctype == enumeration_) { - strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); - if(strlen(retval) + strlen(var) < buf_siz) { - strcat(retval, var); + if( ctype == enumeration_ ) { + strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); + if( strlen( retval ) + strlen( var ) < buf_siz ) { + strcat( retval, var ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } return retval; } - if(ctype == select_) { - return (TypeName(t)); + if( ctype == select_ ) { + return ( TypeName( t ) ); } /* default returns undefined */ - return ("SCLundefined"); + return ( "SCLundefined" ); } -const char *TYPEget_ctype(const Type t) -{ +const char * TYPEget_ctype( const Type t ) { static char retval [BUFSIZ] = {0}; - return TYPE_get_ctype(t, retval, BUFSIZ); + return TYPE_get_ctype( t, retval, BUFSIZ ); } -const char *TypeName(Type t) -{ +const char * TypeName( Type t ) { static char name [BUFSIZ]; - strcpy(name, TYPE_PREFIX); - if(TYPEget_name(t)) { - strncat(name, FirstToUpper(TYPEget_name(t)), BUFSIZ - strlen(TYPE_PREFIX) - 1); + strcpy( name, TYPE_PREFIX ); + if( TYPEget_name( t ) ) { + strncat( name, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - strlen( TYPE_PREFIX ) - 1 ); } else { - return TYPEget_ctype(t); + return TYPEget_ctype( t ); } return name; } -char ToLower(char c) -{ - if(isupper(c)) { - return (tolower(c)); +char ToLower( char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } -char ToUpper(char c) -{ - if(islower(c)) { - return (toupper(c)); +char ToUpper( char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } -const char *StrToLower(const char *word) -{ +const char * StrToLower( const char * word ) { static char newword [MAX_LEN]; int i = 0; - if(!word) { + if( !word ) { return 0; } - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; - return (newword) ; + return ( newword ) ; } -const char *StrToUpper(const char *word) -{ +const char * StrToUpper( const char * word ) { static char newword [MAX_LEN]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *StrToConstant(const char *word) -{ +const char * StrToConstant( const char * word ) { static char newword[MAX_LEN]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *FirstToUpper(const char *word) -{ +const char * FirstToUpper( const char * word ) { static char newword [MAX_LEN]; - strncpy(newword, word, MAX_LEN); - newword[0] = ToUpper(newword[0]); - return (newword); + strncpy( newword, word, MAX_LEN ); + newword[0] = ToUpper( newword[0] ); + return ( newword ); } diff --git a/src/exp2cxx/class_strings.h b/src/exp2cxx/class_strings.h index bae97af28..147c970fb 100644 --- a/src/exp2cxx/class_strings.h +++ b/src/exp2cxx/class_strings.h @@ -20,18 +20,18 @@ /** \returns: temporary copy of name suitable for use as a class name * Side Effects: erases the name created by a previous call to this function */ -const char *ClassName(const char *oldname); +const char * ClassName( const char * oldname ); /** \returns the name of the c++ class representing the entity */ -const char *ENTITYget_classname(Entity ent); +const char * ENTITYget_classname( Entity ent ); /** supplies the type of a data member for the c++ class * \returns: a string which is the type of the data member in the c++ class */ -const char *TYPEget_ctype(const Type t); +const char * TYPEget_ctype( const Type t ); /** name of type as defined in SDAI C++ binding 4-Nov-1993 */ -const char *TypeName(Type t); +const char * TypeName( Type t ); /** These functions take a character or a string and return ** a temporary copy of the string with the function applied to it. @@ -42,11 +42,11 @@ const char *TypeName(Type t); ** \returns a temporary copy of characters ** @{ */ -char ToLower(char c); -char ToUpper(char c); -const char *StrToLower(const char *word); -const char *StrToUpper(const char *word); -const char *StrToConstant(const char *word); -const char *FirstToUpper(const char *word); +char ToLower( char c ); +char ToUpper( char c ); +const char * StrToLower( const char * word ); +const char * StrToUpper( const char * word ); +const char * StrToConstant( const char * word ); +const char * FirstToUpper( const char * word ); /* @} */ #endif /* CLASS_STRINGS_H */ diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 42f7eefa0..0f1494ded 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -46,16 +46,15 @@ int old_accessors = 0; * Mostly replaced by format_for_std_stringout, below. This function is * still used in one place in ENTITYincode_print(). */ -char *format_for_stringout(char *orig_buf, char *return_buf) -{ - char *optr = orig_buf; - char *rptr = return_buf; - while(*optr) { - if(*optr == '\n') { +char * format_for_stringout( char * orig_buf, char * return_buf ) { + char * optr = orig_buf; + char * rptr = return_buf; + while( *optr ) { + if( *optr == '\n' ) { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if(*optr == '\\') { + } else if( *optr == '\\' ) { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -76,183 +75,175 @@ char *format_for_stringout(char *orig_buf, char *return_buf) * * This version takes a file pointer and eliminates use of the temp buffer. */ -void format_for_std_stringout(FILE *f, char *orig_buf) -{ - const char *optr = orig_buf; - char *s_end = "\\n\" );\n"; - char *s_begin = " str.append( \""; - fprintf(f, "%s", s_begin); - while(*optr) { - if(*optr == '\n') { - if(* (optr + 1) == '\n') { /* skip blank lines */ +void format_for_std_stringout( FILE * f, char * orig_buf ) { + const char * optr = orig_buf; + char * s_end = "\\n\" );\n"; + char * s_begin = " str.append( \""; + fprintf( f, "%s", s_begin ); + while( *optr ) { + if( *optr == '\n' ) { + if( * ( optr + 1 ) == '\n' ) { /* skip blank lines */ optr++; continue; } - fprintf(f, "%s", s_end); - fprintf(f, "%s", s_begin); - } else if(*optr == '\\') { - fprintf(f, "\\\\"); + fprintf( f, "%s", s_end ); + fprintf( f, "%s", s_begin ); + } else if( *optr == '\\' ) { + fprintf( f, "\\\\" ); } else { - fprintf(f, "%c", *optr); + fprintf( f, "%c", *optr ); } optr++; } - fprintf(f, "%s", s_end); - sc_free(orig_buf); + fprintf( f, "%s", s_end ); + sc_free( orig_buf ); } -void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file) -{ +void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ) { Dictionary dict; DictionaryEntry de; - struct Rename *r; + struct Rename * r; Linked_List list; char td_name[BUFSIZ]; char sch_name[BUFSIZ]; - strncpy(sch_name, PrettyTmpName(SCHEMAget_name(schema)), BUFSIZ); + strncpy( sch_name, PrettyTmpName( SCHEMAget_name( schema ) ), BUFSIZ ); - LISTdo(reflist, s, Schema) { - fprintf(file, " // %s FROM %s; (all objects)\n", type, s->symbol.name); - fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(s->symbol.name)); - fprintf(file, " is->all_objects_(1);\n"); - if(!strcmp(type, "USE")) { - fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + LISTdo( reflist, s, Schema ) { + fprintf( file, " // %s FROM %s; (all objects)\n", type, s->symbol.name ); + fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( s->symbol.name ) ); + fprintf( file, " is->all_objects_(1);\n" ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } - } - LISTod + } LISTod - if(!refdict) { + if( !refdict ) { return; } - dict = DICTcreate(10); + dict = DICTcreate( 10 ); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init(refdict, &de); - while(0 != (r = (struct Rename *)DICTdo(&de))) { + DICTdo_init( refdict, &de ); + while( 0 != ( r = ( struct Rename * )DICTdo( &de ) ) ) { Linked_List wlist; - wlist = (Linked_List)DICTlookup(dict, r->schema->symbol.name); - if(!wlist) { + wlist = ( Linked_List )DICTlookup( dict, r->schema->symbol.name ); + if( !wlist ) { wlist = LISTcreate(); - DICTdefine(dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN); + DICTdefine( dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN ); } - LISTadd_last(wlist, r); + LISTadd_last( wlist, r ); } /* step 2: for each list, print out the renames */ - DICTdo_init(dict, &de); - while(0 != (list = (Linked_List)DICTdo(&de))) { + DICTdo_init( dict, &de ); + while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { bool first_time = true; - LISTdo(list, re, struct Rename *) { + LISTdo( list, re, struct Rename * ) { /* note: SCHEMAget_name(r->schema) equals r->schema->symbol.name) */ - if(first_time) { - fprintf(file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name); - fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(re->schema->symbol.name)); - if(!strcmp(type, "USE")) { - fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + if( first_time ) { + fprintf( file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name ); + fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( re->schema->symbol.name ) ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } } - if(first_time) { + if( first_time ) { first_time = false; } - if(re->type == OBJ_TYPE) { - sprintf(td_name, "%s", TYPEtd_name((Type)re->object)); - } else if(re->type == OBJ_FUNCTION) { - sprintf(td_name, "/* Function not implemented */ 0"); - } else if(re->type == OBJ_PROCEDURE) { - sprintf(td_name, "/* Procedure not implemented */ 0"); - } else if(re->type == OBJ_RULE) { - sprintf(td_name, "/* Rule not implemented */ 0"); - } else if(re->type == OBJ_ENTITY) { - sprintf(td_name, "%s%s%s", - SCOPEget_name(((Entity)re->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)re->object)); + if( re->type == OBJ_TYPE ) { + sprintf( td_name, "%s", TYPEtd_name( ( Type )re->object ) ); + } else if( re->type == OBJ_FUNCTION ) { + sprintf( td_name, "/* Function not implemented */ 0" ); + } else if( re->type == OBJ_PROCEDURE ) { + sprintf( td_name, "/* Procedure not implemented */ 0" ); + } else if( re->type == OBJ_RULE ) { + sprintf( td_name, "/* Rule not implemented */ 0" ); + } else if( re->type == OBJ_ENTITY ) { + sprintf( td_name, "%s%s%s", + SCOPEget_name( ( ( Entity )re->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )re->object ) ); } else { - sprintf(td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type); + sprintf( td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type ); } - if(re->old != re->nnew) { - fprintf(file, " // object %s AS %s\n", re->old->name, - re->nnew->name); - if(!strcmp(type, "USE")) { - fprintf(file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ui);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); + if( re->old != re->nnew ) { + fprintf( file, " // object %s AS %s\n", re->old->name, + re->nnew->name ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ui);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ri);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); + fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ri);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); } } else { - fprintf(file, " // object %s\n", re->old->name); - if(!strcmp(type, "USE")) { - fprintf(file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ui);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); + fprintf( file, " // object %s\n", re->old->name ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ui);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ri);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); + fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ri);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); } } - } - LISTod + } LISTod } - HASHdestroy(dict); + HASHdestroy( dict ); } -int Handle_FedPlus_Args(int i, char *arg) -{ +int Handle_FedPlus_Args( int i, char * arg ) { (void) arg; /* unused */ - if(((char)i == 's') || ((char)i == 'S')) { + if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { multiple_inheritance = 0; } - if(((char)i == 'a') || ((char)i == 'A')) { + if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { old_accessors = 1; } - if(((char)i == 'l') || ((char)i == 'L')) { + if( ( ( char )i == 'l' ) || ( ( char )i == 'L' ) ) { print_logging = 1; } return 0; } -void MODELPrintConstructorBody(Entity entity, FILES *files, Schema schema) -{ - const char *n; - DEBUG("Entering MODELPrintConstructorBody for %s\n", n); +void MODELPrintConstructorBody( Entity entity, FILES * files, Schema schema ) { + const char * n; + DEBUG( "Entering MODELPrintConstructorBody for %s\n", n ); - n = ENTITYget_classname(entity); + n = ENTITYget_classname( entity ); - fprintf(files->lib, " eep = new SDAI_Entity_extent;\n"); + fprintf( files->lib, " eep = new SDAI_Entity_extent;\n" ); - fprintf(files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(files->lib, " _folders.Append(eep);\n\n"); + fprintf( files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( files->lib, " _folders.Append(eep);\n\n" ); } -void MODELPrint(Entity entity, FILES *files, Schema schema, int index) -{ +void MODELPrint( Entity entity, FILES * files, Schema schema, int index ) { - const char *n; - DEBUG("Entering MODELPrint for %s\n", n); + const char * n; + DEBUG( "Entering MODELPrint for %s\n", n ); - n = ENTITYget_classname(entity); - fprintf(files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name(schema), n); - fprintf(files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index); - DEBUG("DONE MODELPrint\n") ; + n = ENTITYget_classname( entity ); + fprintf( files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name( schema ), n ); + fprintf( files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index ); + DEBUG( "DONE MODELPrint\n" ) ; } -void MODELprint_new(Entity entity, FILES *files) -{ - const char *n; +void MODELprint_new( Entity entity, FILES * files ) { + const char * n; - n = ENTITYget_classname(entity); - fprintf(files->inc, "\n %s__set_var %s_get_extents();\n", n, n); + n = ENTITYget_classname( entity ); + fprintf( files->inc, "\n %s__set_var %s_get_extents();\n", n, n ); } diff --git a/src/exp2cxx/classes.h b/src/exp2cxx/classes.h index eac80fbf5..462e22687 100644 --- a/src/exp2cxx/classes.h +++ b/src/exp2cxx/classes.h @@ -48,29 +48,29 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define move(b) (b = (b + strlen(b))) #define TYPEtd_name(t) TypeDescriptorName (t) -Variable VARis_type_shifter(Variable a); -int isAggregateType(const Type t); -int isAggregate(Variable a); +Variable VARis_type_shifter( Variable a ); +int isAggregateType( const Type t ); +int isAggregate( Variable a ); typedef struct file_holder { - FILE *inc; /**< include file */ - FILE *lib; /**< library file */ - FILE *incall; /**< include file for collecting all include files */ - FILE *initall; /**< for registering all entities from all schemas */ - FILE *init; /**< contains function to initialize program to use schema's entities */ - FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE * inc; /**< include file */ + FILE * lib; /**< library file */ + FILE * incall; /**< include file for collecting all include files */ + FILE * initall; /**< for registering all entities from all schemas */ + FILE * init; /**< contains function to initialize program to use schema's entities */ + FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ struct { struct { - FILE *impl; - FILE *hdr; + FILE * impl; + FILE * hdr; } entity, type; } unity; } File_holder, FILES; @@ -78,7 +78,7 @@ typedef struct file_holder { /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ *EntityTag; +typedef struct EntityTag_ * EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ @@ -86,36 +86,36 @@ struct EntityTag_ { }; /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ *SelectTag; +typedef struct SelectTag_ * SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char *GetTypeDescriptorName(Type t); -char *format_for_stringout(char *orig_buf, char *return_buf); -void format_for_std_stringout(FILE *f, char *orig_buf); -const char *CheckWord(const char *); -const char *StrToLower(const char *); -const char *StrToUpper(const char *); -const char *FirstToUpper(const char *); -const char *SelectName(const char *); -FILE *FILEcreate(const char *); -void FILEclose(FILE *); -const char *ClassName(const char *); -void FUNCPrint(Function, FILES *, Schema); -void RULEPrint(Rule, FILES *, Schema); -const char *StrToConstant(const char *); -void MODELPrint(Entity, FILES *, Schema, int); -void MODELprint_new(Entity entity, FILES *files); -void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); -const char *PrettyTmpName(const char *oldname); -const char *EnumName(const char *oldname); -void print_file(Express); -void resolution_success(void); -void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix); -const char *FundamentalType(const Type t, int report_reftypes); -void numberAttributes(Scope scope); +const char * GetTypeDescriptorName( Type t ); +char * format_for_stringout( char * orig_buf, char * return_buf ); +void format_for_std_stringout( FILE* f, char* orig_buf ); +const char * CheckWord( const char * ); +const char * StrToLower( const char * ); +const char * StrToUpper( const char * ); +const char * FirstToUpper( const char * ); +const char * SelectName( const char * ); +FILE * FILEcreate( const char * ); +void FILEclose( FILE * ); +const char * ClassName( const char * ); +void FUNCPrint( Function, FILES *, Schema ); +void RULEPrint( Rule, FILES *, Schema ); +const char * StrToConstant( const char * ); +void MODELPrint( Entity, FILES *, Schema, int ); +void MODELprint_new( Entity entity, FILES* files ); +void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); +const char * PrettyTmpName( const char * oldname ); +const char * EnumName( const char * oldname ); +void print_file( Express ); +void resolution_success( void ); +void SCHEMAprint( Schema schema, FILES* files, void* complexCol, int suffix ); +const char * FundamentalType( const Type t, int report_reftypes ); +void numberAttributes( Scope scope ); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -123,14 +123,14 @@ void numberAttributes(Scope scope); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider(Entity e, Variable a); +Variable VARis_overrider( Entity e, Variable a ); /* Added for multiple schema support: */ -void print_schemas_separate(Express, void *, FILES *); -void getMCPrint(Express, FILE *, FILE *); -int sameSchema(Scope, Scope); +void print_schemas_separate( Express, void *, FILES * ); +void getMCPrint( Express, FILE *, FILE * ); +int sameSchema( Scope, Scope ); -void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file); +void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ); #include "classes_attribute.h" #include "classes_type.h" diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index 2b35e3fd4..f304ba176 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -38,24 +38,23 @@ extern int print_logging; ** Side Effects: ** Status: complete 8/5/93 ******************************************************************/ -char *generate_attribute_name(Variable a, char *out) -{ - char *temp, *q; - const char *p; +char * generate_attribute_name( Variable a, char * out ) { + char * temp, *q; + const char * p; int i; - temp = EXPRto_string(VARget_name(a)); - p = StrToLower(temp); - if(! strncmp(p, "self\\", 5)) { + temp = EXPRto_string( VARget_name( a ) ); + p = StrToLower( temp ); + if( ! strncmp( p, "self\\", 5 ) ) { p += 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for(i = 0, q = out; *p != '\0' && i < BUFSIZ; p++) { + for( i = 0, q = out; *p != '\0' && i < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert * '.' to '_', and convert to lowercase. */ - if((*p != '\n') && (*p != ' ')) { - if(*p == '.') { + if( ( *p != '\n' ) && ( *p != ' ' ) ) { + if( *p == '.' ) { *q = '_'; } else { *q = *p; @@ -65,31 +64,29 @@ char *generate_attribute_name(Variable a, char *out) } } *q = '\0'; - sc_free(temp); + sc_free( temp ); return out; } -char *generate_attribute_func_name(Variable a, char *out) -{ - generate_attribute_name(a, out); - strncpy(out, StrToLower(out), BUFSIZ); - if(old_accessors) { - out[0] = toupper(out[0]); +char * generate_attribute_func_name( Variable a, char * out ) { + generate_attribute_name( a, out ); + strncpy( out, StrToLower( out ), BUFSIZ ); + if( old_accessors ) { + out[0] = toupper( out[0] ); } else { - out[strlen(out)] = '_'; + out[strlen( out )] = '_'; } return out; } /* return true if attr needs const and non-const getters */ -bool attrIsObj(Type t) -{ +bool attrIsObj( Type t ) { /* if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { / * const doesn't make sense for pointer types * / return false; } else */ - Class_Of_Type class = TYPEget_type(t); - switch(class) { + Class_Of_Type class = TYPEget_type( t ); + switch( class ) { case number_: case real_: case integer_: @@ -104,19 +101,17 @@ bool attrIsObj(Type t) /** print attr descriptors to the namespace * \p attr_count_tmp is a _copy_ of attr_count */ -void ATTRnames_print(Entity entity, FILE *file) -{ +void ATTRnames_print( Entity entity, FILE* file ) { char attrnm [BUFSIZ]; - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - fprintf(file, " extern %s *%s%d%s%s;\n", - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), - attrnm); - } - LISTod + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + fprintf( file, " extern %s *%s%d%s%s;\n", + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + } LISTod } /** prints out the current attribute for an entity's c++ class definition @@ -125,33 +120,32 @@ void ATTRnames_print(Entity entity, FILE *file) * \param a attribute being processed * \param file file being written to */ -void DataMemberPrintAttr(Entity entity, Variable a, FILE *file) -{ +void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { char attrnm [BUFSIZ]; - const char *ctype, * etype; - if(!VARget_inverse(a) && (VARget_initializer(a) == EXPRESSION_NULL)) { - ctype = TYPEget_ctype(VARget_type(a)); - generate_attribute_name(a, attrnm); - if(!strcmp(ctype, "SCLundefined")) { - fprintf(stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name(entity), attrnm); + const char * ctype, * etype; + if( !VARget_inverse( a ) && ( VARget_initializer( a ) == EXPRESSION_NULL ) ) { + ctype = TYPEget_ctype( VARget_type( a ) ); + generate_attribute_name( a, attrnm ); + if( !strcmp( ctype, "SCLundefined" ) ) { + fprintf( stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name( entity ), attrnm ); } - if(TYPEis_entity(VARget_type(a))) { - fprintf(file, " SDAI_Application_instance_ptr _%s;", attrnm); - } else if(TYPEis_aggregate(VARget_type(a))) { - fprintf(file, " %s_ptr _%s;", ctype, attrnm); + if( TYPEis_entity( VARget_type( a ) ) ) { + fprintf( file, " SDAI_Application_instance_ptr _%s;", attrnm ); + } else if( TYPEis_aggregate( VARget_type( a ) ) ) { + fprintf( file, " %s_ptr _%s;", ctype, attrnm ); } else { - fprintf(file, " %s _%s;", ctype, attrnm); + fprintf( file, " %s _%s;", ctype, attrnm ); } - if(VARget_optional(a)) { - fprintf(file, " // OPTIONAL"); + if( VARget_optional( a ) ) { + fprintf( file, " // OPTIONAL" ); } - if(isAggregate(a)) { + if( isAggregate( a ) ) { /* if it's a named type, comment the type */ - if((etype = TYPEget_name(TYPEget_nonaggregate_base_type(VARget_type(a))))) { - fprintf(file, " // of %s\n", etype); + if( ( etype = TYPEget_name ( TYPEget_nonaggregate_base_type( VARget_type( a ) ) ) ) ) { + fprintf( file, " // of %s\n", etype ); } } - fprintf(file, "\n"); + fprintf( file, "\n" ); } } @@ -168,32 +162,31 @@ void DataMemberPrintAttr(Entity entity, Variable a, FILE *file) ** Side Effects: ** Status: complete 17-Feb-1992 ******************************************************************/ -void ATTRsign_access_methods(Variable a, FILE *file) -{ +void ATTRsign_access_methods( Variable a, FILE * file ) { - Type t = VARget_type(a); + Type t = VARget_type( a ); char ctype [BUFSIZ]; char attrnm [BUFSIZ]; - generate_attribute_func_name(a, attrnm); + generate_attribute_func_name( a, attrnm ); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; - if(attrIsObj(t)) { + if( attrIsObj( t ) ) { /* object or pointer, so provide const and non-const methods */ - if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { + if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { /* it's a typedef, so prefacing with 'const' won't do what we desire */ - fprintf(file, " %s_c %s() const;\n", ctype, attrnm); + fprintf( file, " %s_c %s() const;\n", ctype, attrnm ); } else { - fprintf(file, " const %s %s() const;\n", ctype, attrnm); + fprintf( file, " const %s %s() const;\n", ctype, attrnm ); } - fprintf(file, " %s %s();\n", ctype, attrnm); + fprintf( file, " %s %s();\n", ctype, attrnm ); } else { - fprintf(file, " %s %s() const;\n", ctype, attrnm); + fprintf( file, " %s %s() const;\n", ctype, attrnm ); } - fprintf(file, " void %s( const %s x );\n", attrnm, ctype); - fprintf(file, "\n"); + fprintf( file, " void %s( const %s x );\n", attrnm, ctype ); + fprintf( file, "\n" ); return; } @@ -213,18 +206,17 @@ void ATTRsign_access_methods(Variable a, FILE *file) ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst) -{ - Type t = VARget_type(a); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ) { + Type t = VARget_type( a ); char ctype [BUFSIZ]; /* return type of the get function */ char funcnm [BUFSIZ]; /* name of member function */ - generate_attribute_func_name(a, funcnm); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; - if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { - fprintf(file, "\n%s%s %s::%s() ", ctype, (returnsConst ? "_c" : ""), classnm, funcnm); + generate_attribute_func_name( a, funcnm ); + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; + if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + fprintf( file, "\n%s%s %s::%s() ", ctype, ( returnsConst ? "_c" : "" ), classnm, funcnm ); } else { - fprintf(file, "\n%s%s %s::%s() ", (returnsConst ? "const " : ""), ctype, classnm, funcnm); + fprintf( file, "\n%s%s %s::%s() ", ( returnsConst ? "const " : "" ), ctype, classnm, funcnm ); } return; } @@ -245,35 +237,33 @@ void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *fi ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file) -{ +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ) { - Type t = VARget_type(a); + Type t = VARget_type( a ); char ctype [BUFSIZ]; char funcnm [BUFSIZ]; - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; - fprintf(file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype); + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; + fprintf( file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype ); return; } /** print access methods for aggregate attribute */ -void AGGRprint_access_methods(const char *entnm, Variable a, FILE *file, - char *ctype, char *attrnm) -{ - ATTRprint_access_methods_get_head(entnm, a, file, false); - fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ((a->type->u.type->body->base) ? "->" : ".")); +void AGGRprint_access_methods( const char * entnm, Variable a, FILE * file, + char * ctype, char * attrnm ) { + ATTRprint_access_methods_get_head( entnm, a, file, false ); + fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ( ( a->type->u.type->body->base ) ? "->" : "." ) ); return; } @@ -281,221 +271,212 @@ void AGGRprint_access_methods(const char *entnm, Variable a, FILE *file, * \p var is the variable name, minus preceding underscore, or null if 'x' is to be used * \p dir is either "returned" or "assigned" */ -void ATTRprint_access_methods_entity_logging(const char *entnm, const char *funcnm, const char *nm, - const char *var, const char *dir, FILE *file) -{ - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if( *logStream ) {\n"); - fprintf(file, " logStream -> open( SCLLOGFILE, ios::app );\n"); - fprintf(file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", (var ? "_" : ""), (var ? var : "x")); - fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); - fprintf(file, " *logStream << \"reference to Sdai%s entity #\"", nm); - fprintf(file, " << %s%s->STEPfile_id << std::endl;\n", (var ? "_" : ""), (var ? var : "x")); - fprintf(file, " } else {\n"); - fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); - fprintf(file, " *logStream << \"null entity\" << std::endl;\n }\n"); - fprintf(file, " logStream->close();\n"); - fprintf(file, " }\n"); - fprintf(file, "#endif\n"); +void ATTRprint_access_methods_entity_logging( const char * entnm, const char * funcnm, const char * nm, + const char * var, const char * dir, FILE * file ) { + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if( *logStream ) {\n" ); + fprintf( file, " logStream -> open( SCLLOGFILE, ios::app );\n" ); + fprintf( file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); + fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); + fprintf( file, " *logStream << \"reference to Sdai%s entity #\"", nm ); + fprintf( file, " << %s%s->STEPfile_id << std::endl;\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); + fprintf( file, " } else {\n" ); + fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); + fprintf( file, " *logStream << \"null entity\" << std::endl;\n }\n" ); + fprintf( file, " logStream->close();\n" ); + fprintf( file, " }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for attrs that are entities * prints const and non-const getters and a setter */ -void ATTRprint_access_methods_entity(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); - fprintf(file, " _%s = x;\n}\n", attrnm); +void ATTRprint_access_methods_entity( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); + fprintf( file, " _%s = x;\n}\n", attrnm ); return; } /** logging code for string and binary attribute access methods */ -void ATTRprint_access_methods_str_bin_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(setter) { - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); +void ATTRprint_access_methods_str_bin_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( setter ) { + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } else { - fprintf(file, " if(x)\n {\n"); + fprintf( file, " if(x)\n {\n" ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << x << std::endl;\n"); + fprintf( file, " *logStream << x << std::endl;\n" ); } - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for string or bin attribute */ -void ATTRprint_access_methods_str_bin(const char *entnm, const char *attrnm, const char *funcnm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " return _%s;\n}\n", attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " _%s = x;\n}\n", attrnm); +void ATTRprint_access_methods_str_bin( const char * entnm, const char * attrnm, const char * funcnm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " return _%s;\n}\n", attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " _%s = x;\n}\n", attrnm ); return; } /** print logging code for access methods for enumeration attribute */ -void ATTRprint_access_methods_enum_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(!setter) { - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); +void ATTRprint_access_methods_enum_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( !setter ) { + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); + fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); } - fprintf(file, " }\n#endif\n"); + fprintf( file, " }\n#endif\n" ); } } /** print access methods for enumeration attribute */ -void ATTRprint_access_methods_enum(const char *entnm, const char *attrnm, const char *funcnm, - Variable a, Type t, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " _%s.put( x );\n}\n", attrnm); +void ATTRprint_access_methods_enum( const char * entnm, const char * attrnm, const char * funcnm, + Variable a, Type t, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (%s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (const %s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " _%s.put( x );\n}\n", attrnm ); return; } /** print logging code for access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(!setter) { +void ATTRprint_access_methods_log_bool_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( !setter ) { /* fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" ); */ - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); + fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); /* fprintf( file, " logStream->close();\n" ); */ } - fprintf(file, " }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool(const char *entnm, const char *attrnm, const char *funcnm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "const {\n"); - ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - /* don't need a const method for logical or boolean - * ATTRprint_access_methods_get_head( entnm, a, file, true ); - * fprintf( file, "const {\n" ); - * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); - * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); - */ - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " _%s.put (x);\n}\n", attrnm); +void ATTRprint_access_methods_log_bool( const char * entnm, const char * attrnm, const char * funcnm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "const {\n" ); + ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + +/* don't need a const method for logical or boolean + * ATTRprint_access_methods_get_head( entnm, a, file, true ); + * fprintf( file, "const {\n" ); + * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); + * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); +*/ + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " _%s.put (x);\n}\n", attrnm ); return; } /** print access methods for inverse attrs, using iAMap */ -void INVprint_access_methods(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, - const char *ctype, Variable a, FILE *file, Schema schema) -{ +void INVprint_access_methods( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, + const char * ctype, Variable a, FILE * file, Schema schema ) { char iaName[BUFSIZ] = {0}; - snprintf(iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name(schema), ATTR_PREFIX, a->idx, - /* can it ever be anything but "I"? */ - (VARis_derived(a) ? "D" : (VARis_type_shifter(a) ? "R" : (VARget_inverse(a) ? "I" : ""))), attrnm); + snprintf( iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, + /* can it ever be anything but "I"? */ + ( VARis_derived( a ) ? "D" : ( VARis_type_shifter( a ) ? "R" : ( VARget_inverse( a ) ? "I" : "" ) ) ), attrnm ); - if(isAggregate(a)) { + if( isAggregate( a ) ) { /* following started as AGGRprint_access_methods() */ - ATTRprint_access_methods_get_head(entnm, a, file, false); - fprintf(file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName); - fprintf(file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName); - fprintf(file, " return ias.a;\n}\n"); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - fprintf(file, " return getInvAttr( %s ).a;\n}\n", iaName); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName); + ATTRprint_access_methods_get_head( entnm, a, file, false ); + fprintf( file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName ); + fprintf( file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName ); + fprintf( file, " return ias.a;\n}\n" ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + fprintf( file, " return getInvAttr( %s ).a;\n}\n", iaName ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName ); } else { - ATTRprint_access_methods_get_head(entnm, a, file, false); + ATTRprint_access_methods_get_head( entnm, a, file, false ); /* following started as ATTRprint_access_methods_entity() */ - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); - fprintf(file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); - fprintf(file, " return (%s) ias.i;\n}\n", ctype); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); - fprintf(file, " return (%s) ias.i;\n}\n", ctype); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); - fprintf(file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); + fprintf( file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); + fprintf( file, " return (%s) ias.i;\n}\n", ctype ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); + fprintf( file, " return (%s) ias.i;\n}\n", ctype ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); + fprintf( file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName ); } } @@ -506,9 +487,8 @@ void INVprint_access_methods(const char *entnm, const char *attrnm, const char * * \param a attribute to print methods for * \param file file being written to */ -void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema) -{ - Type t = VARget_type(a); +void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ) { + Type t = VARget_type( a ); Class_Of_Type classType; char ctype [BUFSIZ]; /* type of data member */ char attrnm [BUFSIZ]; @@ -517,46 +497,46 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema char nm [BUFSIZ]; /* I believe nm has the name of the underlying type without Sdai in front of it */ - if(TYPEget_name(t)) { - strncpy(nm, FirstToUpper(TYPEget_name(t)), BUFSIZ - 1); + if( TYPEget_name( t ) ) { + strncpy( nm, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - 1 ); } - generate_attribute_func_name(a, funcnm); - generate_attribute_name(a, attrnm); - strcpy(membernm, attrnm); - membernm[0] = toupper(membernm[0]); - classType = TYPEget_type(t); - strncpy(ctype, AccessType(t), BUFSIZ); - if(VARget_inverse(a)) { - INVprint_access_methods(entnm, attrnm, funcnm, nm, ctype, a, file, schema); + generate_attribute_func_name( a, funcnm ); + generate_attribute_name( a, attrnm ); + strcpy( membernm, attrnm ); + membernm[0] = toupper( membernm[0] ); + classType = TYPEget_type( t ); + strncpy( ctype, AccessType( t ), BUFSIZ ); + if( VARget_inverse( a ) ) { + INVprint_access_methods( entnm, attrnm, funcnm, nm, ctype, a, file, schema ); return; } - if(isAggregate(a)) { - AGGRprint_access_methods(entnm, a, file, ctype, attrnm); + if( isAggregate( a ) ) { + AGGRprint_access_methods( entnm, a, file, ctype, attrnm ); return; } - ATTRprint_access_methods_get_head(entnm, a, file, false); + ATTRprint_access_methods_get_head( entnm, a, file, false ); /* case TYPE_ENTITY: */ - if(classType == entity_) { - ATTRprint_access_methods_entity(entnm, attrnm, funcnm, nm, ctype, a, file); + if( classType == entity_ ) { + ATTRprint_access_methods_entity( entnm, attrnm, funcnm, nm, ctype, a, file ); return; } /* case TYPE_LOGICAL: */ - if((classType == boolean_) || (classType == logical_)) { - ATTRprint_access_methods_log_bool(entnm, attrnm, funcnm, ctype, a, file); + if( ( classType == boolean_ ) || ( classType == logical_ ) ) { + ATTRprint_access_methods_log_bool( entnm, attrnm, funcnm, ctype, a, file ); } /* case TYPE_ENUM: */ - if(classType == enumeration_) { - ATTRprint_access_methods_enum(entnm, attrnm, funcnm, a, t, file); + if( classType == enumeration_ ) { + ATTRprint_access_methods_enum( entnm, attrnm, funcnm, a, t, file ); } /* case TYPE_SELECT: */ - if(classType == select_) { - fprintf(file, " {\n return &_%s;\n}\n", attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n return (%s) &_%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, " {\n _%s = x;\n}\n", attrnm); + if( classType == select_ ) { + fprintf( file, " {\n return &_%s;\n}\n", attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n return (const %s) &_%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, " {\n _%s = x;\n}\n", attrnm ); return; } /* case TYPE_AGGRETATES: */ @@ -565,77 +545,77 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema /* case STRING:*/ /* case TYPE_BINARY: */ - if((classType == string_) || (classType == binary_)) { - ATTRprint_access_methods_str_bin(entnm, attrnm, funcnm, ctype, a, file); + if( ( classType == string_ ) || ( classType == binary_ ) ) { + ATTRprint_access_methods_str_bin( entnm, attrnm, funcnm, ctype, a, file ); } /* case TYPE_INTEGER: */ - if(classType == integer_) { - fprintf(file, "const {\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm); - fprintf(file, - " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm); - fprintf(file, - " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + if( classType == integer_ ) { + fprintf( file, "const {\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm ); + fprintf( file, + " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm ); + fprintf( file, + " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } /* default: INTEGER */ /* is the same type as the data member */ - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(x == S_INT_NULL) )\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << x << std::endl;\n"); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(x == S_INT_NULL) )\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << x << std::endl;\n" ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); /* default: INTEGER */ /* is the same type as the data member */ } - fprintf(file, " _%s = x;\n}\n", attrnm); + fprintf( file, " _%s = x;\n}\n", attrnm ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((classType == number_) || (classType == real_)) { - fprintf(file, "const {\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + if( ( classType == number_ ) || ( classType == real_ ) ) { + fprintf( file, "const {\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } - fprintf(file, " _%s = x;\n}\n", attrnm); + fprintf( file, " _%s = x;\n}\n", attrnm ); } } diff --git a/src/exp2cxx/classes_attribute.h b/src/exp2cxx/classes_attribute.h index f06273a77..5a32b3074 100644 --- a/src/exp2cxx/classes_attribute.h +++ b/src/exp2cxx/classes_attribute.h @@ -1,17 +1,17 @@ #ifndef CLASSES_ATTRIBUTE_H #define CLASSES_ATTRIBUTE_H -char *generate_attribute_name(Variable a, char *out); -char *generate_attribute_func_name(Variable a, char *out); +char * generate_attribute_name( Variable a, char * out ); +char * generate_attribute_func_name( Variable a, char * out ); -void DataMemberPrintAttr(Entity entity, Variable a, FILE *file); -void ATTRnames_print(Entity entity, FILE *file); -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst); -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); -void ATTRsign_access_methods(Variable a, FILE *file); -void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema); +void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ); +void ATTRnames_print( Entity entity, FILE * file ); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ); +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); +void ATTRsign_access_methods( Variable a, FILE* file ); +void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ); /** return true if attr needs const and non-const getters */ -bool attrIsObj(Type t); +bool attrIsObj( Type t ); #endif diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 13bbc5ecd..10a6af92c 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -45,9 +45,8 @@ extern int old_accessors; * Nov 2011 - MAP - This function was split out of ENTITYhead_print to enable * use of a separate header with a namespace. */ -void ENTITYnames_print(Entity entity, FILE *file) -{ - fprintf(file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name(entity)); +void ENTITYnames_print( Entity entity, FILE * file ) { + fprintf( file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name( entity ) ); } /** declares the global pointer to the EntityDescriptor representing a particular entity @@ -59,20 +58,18 @@ void ENTITYnames_print(Entity entity, FILE *file) * \param file file being written to * \param schema schema being processed */ -void LIBdescribe_entity(Entity entity, FILE *file, Schema schema) -{ +void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { char attrnm [BUFSIZ]; - fprintf(file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - fprintf(file, "%s * %s::%s%d%s%s = 0;\n", - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), attrnm); - } - LISTod - fprintf(file, "\n"); + fprintf( file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + fprintf( file, "%s * %s::%s%d%s%s = 0;\n", + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm ); + } LISTod + fprintf( file, "\n"); } /** prints the member functions for the class representing an entity. These go in the .cc file @@ -81,73 +78,67 @@ void LIBdescribe_entity(Entity entity, FILE *file, Schema schema) * \param file file being written to * \param schema needed for name of namespace */ -void LIBmemberFunctionPrint(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBmemberFunctionPrint( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; char entnm [BUFSIZ]; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ /* 1. put in member functions which belong to all entities */ /* the common function are still in the class definition 17-Feb-1992 */ /* 2. print access functions for attributes */ - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, a, Variable) { + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, a, Variable ) { /* do for EXPLICIT, REDEFINED, and INVERSE attributes - but not DERIVED */ - if(! VARis_derived(a)) { + if( ! VARis_derived( a ) ) { /* retrieval and assignment */ - ATTRprint_access_methods(entnm, a, file, schema); + ATTRprint_access_methods( entnm, a, file, schema ); } - } - LISTod + } LISTod /* //////////////// */ - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { - ATTRprint_access_methods(entnm, attr, file, schema); + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { + ATTRprint_access_methods( entnm, attr, file, schema ); } - } - LISTod + } LISTod } /* //////////////// */ - - fprintf(file, "\n"); + + fprintf( file, "\n" ); } -int get_attribute_number(Entity entity) -{ +int get_attribute_number( Entity entity ) { int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes(entity); - local = ENTITYget_attributes(entity); + complete = ENTITYget_all_attributes( entity ); + local = ENTITYget_attributes( entity ); - LISTdo(local, a, Variable) { + LISTdo( local, a, Variable ) { /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - LISTdo_n(complete, p, Variable, b) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + LISTdo_n( complete, p, Variable, b ) { /* cycle through all the explicit attributes until the child's attribute is found */ - if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { - if(p != a) { + if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { + if( p != a ) { ++i; } else { found = 1; } } - } - LISTod - if(found) { + } LISTod + if( found ) { return i; } else { - fprintf(stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name(VARget_name(a))); + fprintf( stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name( VARget_name( a ) ) ); } } - } - LISTod + } LISTod return -1; } @@ -157,71 +148,66 @@ int get_attribute_number(Entity entity) * \p entity entity to print * \p file file being written to */ -void ENTITYhead_print(Entity entity, FILE *file) -{ +void ENTITYhead_print( Entity entity, FILE * file ) { char entnm [BUFSIZ]; Linked_List list; Entity super = 0; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); - entnm[BUFSIZ - 1] = '\0'; + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); + entnm[BUFSIZ-1] = '\0'; /* inherit from either supertype entity class or root class of all - i.e. SDAI_Application_instance */ - if(multiple_inheritance) { - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - super = (Entity)LISTpeek_first(list); + if( multiple_inheritance ) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + super = ( Entity )LISTpeek_first( list ); } } else { /* the old way */ - super = ENTITYput_superclass(entity); + super = ENTITYput_superclass( entity ); } - fprintf(file, "class SC_SCHEMA_EXPORT %s : ", entnm); - if(super) { - fprintf(file, "public %s {\n ", ENTITYget_classname(super)); + fprintf( file, "class SC_SCHEMA_EXPORT %s : ", entnm ); + if( super ) { + fprintf( file, "public %s {\n ", ENTITYget_classname( super ) ); } else { - fprintf(file, "public SDAI_Application_instance {\n"); + fprintf( file, "public SDAI_Application_instance {\n" ); } } /** print an attr initializer * skip inverse attrs */ -void DataMemberInit(bool *first, Variable a, FILE *lib) -{ +void DataMemberInit( bool * first, Variable a, FILE * lib ) { char attrnm [BUFSIZ]; - if(VARis_derived(a) || VARget_inverse(a)) { + if( VARis_derived( a ) || VARget_inverse( a ) ) { return; } - if(TYPEis_entity(VARget_type(a)) || TYPEis_aggregate(VARget_type(a))) { - if(*first) { + if( TYPEis_entity( VARget_type( a ) ) || TYPEis_aggregate( VARget_type( a ) ) ) { + if( *first ) { *first = false; - fprintf(lib, " :"); + fprintf( lib, " :" ); } else { - fprintf(lib, ","); + fprintf( lib, "," ); } - generate_attribute_name(a, attrnm); - fprintf(lib, " _%s( 0 )", attrnm); + generate_attribute_name( a, attrnm ); + fprintf( lib, " _%s( 0 )", attrnm ); } } /** print attribute initializers; call before printing constructor body * \param first true if this is the first initializer */ -void DataMemberInitializers(Entity entity, bool *first, Linked_List neededAttr, FILE *lib) -{ - Linked_List attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, attr, Variable) { - DataMemberInit(first, attr, lib); - } - LISTod; - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - DataMemberInit(first, attr, lib); - } - LISTod +void DataMemberInitializers( Entity entity, bool * first, Linked_List neededAttr, FILE * lib ) { + Linked_List attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, attr, Variable ) { + DataMemberInit( first, attr, lib ); + } LISTod; + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + DataMemberInit( first, attr, lib ); + } LISTod } } @@ -229,23 +215,22 @@ void DataMemberInitializers(Entity entity, bool *first, Linked_List neededAttr, * \param entity entity being processed * \param file file being written to */ -void DataMemberPrint(Entity entity, Linked_List neededAttr, FILE *file) -{ +void DataMemberPrint( Entity entity, Linked_List neededAttr, FILE * file ) { Linked_List attr_list; /* print list of attributes in the protected access area */ - fprintf(file, " protected:\n"); + fprintf( file, " protected:\n" ); - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, attr, Variable) { - DataMemberPrintAttr(entity, attr, file); + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, attr, Variable ) { + DataMemberPrintAttr( entity, attr, file ); } LISTod; /* add attributes for parent attributes not inherited through C++ inheritance. */ - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - DataMemberPrintAttr(entity, attr, file); + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + DataMemberPrintAttr( entity, attr, file ); } LISTod; } @@ -255,55 +240,52 @@ void DataMemberPrint(Entity entity, Linked_List neededAttr, FILE *file) * \param entity entity being processed * \param file file being written to */ -void MemberFunctionSign(Entity entity, Linked_List neededAttr, FILE *file) -{ +void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) { Linked_List attr_list; static int entcode = 0; char entnm [BUFSIZ]; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ - entnm[BUFSIZ - 1] = '\0'; + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ + entnm[BUFSIZ-1] = '\0'; - fprintf(file, " public: \n"); + fprintf( file, " public: \n" ); /* put in member functions which belong to all entities */ /* constructors: */ - fprintf(file, " %s();\n", entnm); - fprintf(file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm); + fprintf( file, " %s();\n", entnm ); + fprintf( file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm ); /* copy constructor */ - fprintf(file, " %s( %s & e );\n", entnm, entnm); + fprintf( file, " %s( %s & e );\n", entnm, entnm ); /* destructor: */ - fprintf(file, " ~%s();\n", entnm); + fprintf( file, " ~%s();\n", entnm ); - fprintf(file, " int opcode() {\n return %d;\n }\n", entcode++); + fprintf( file, " int opcode() {\n return %d;\n }\n", entcode++ ); /* print signature of access functions for attributes */ - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* retrieval and assignment */ - ATTRsign_access_methods(a, file); + ATTRsign_access_methods( a, file ); } - } - LISTod + } LISTod /* //////////////// */ - if(multiple_inheritance) { + if( multiple_inheritance ) { /* add the EXPRESS inherited attributes which are non */ /* inherited in C++ */ - LISTdo(neededAttr, attr, Variable) { - if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { - ATTRsign_access_methods(attr, file); + LISTdo( neededAttr, attr, Variable ) { + if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { + ATTRsign_access_methods( attr, file ); } - } - LISTod + } LISTod } /* //////////////// */ - fprintf(file, "};\n\n"); + fprintf( file, "};\n\n" ); /* print creation function for class */ - fprintf(file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm); + fprintf( file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm ); } /** drives the generation of the c++ class definition code @@ -313,21 +295,19 @@ void MemberFunctionSign(Entity entity, Linked_List neededAttr, FILE *file) * \param entity entity being processed * \param file file being written to */ -void ENTITYinc_print(Entity entity, Linked_List neededAttr, FILE *file) -{ - ENTITYhead_print(entity, file); - DataMemberPrint(entity, neededAttr, file); - MemberFunctionSign(entity, neededAttr, file); +void ENTITYinc_print( Entity entity, Linked_List neededAttr, FILE * file ) { + ENTITYhead_print( entity, file ); + DataMemberPrint( entity, neededAttr, file ); + MemberFunctionSign( entity, neededAttr, file ); } /** initialize attributes in the constructor; used for two different constructors */ -void initializeAttrs(Entity e, FILE *file) -{ - const orderedAttr *oa; - orderedAttrsInit(e); - while(0 != (oa = nextAttr())) { - if(oa->deriver) { - fprintf(file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name); +void initializeAttrs( Entity e, FILE* file ) { + const orderedAttr * oa; + orderedAttrsInit( e ); + while( 0 != ( oa = nextAttr() ) ) { + if( oa->deriver ) { + fprintf( file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name ); } } orderedAttrsCleanup(); @@ -345,8 +325,7 @@ void initializeAttrs(Entity e, FILE *file) * \param entity entity being processed * \param file file being written to */ -void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -354,154 +333,152 @@ void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema Linked_List list; Entity principalSuper = 0; - const char *entnm = ENTITYget_classname(entity); + const char * entnm = ENTITYget_classname( entity ); bool first = true; /* constructor definition */ /* parent class initializer (if any) and '{' printed below */ - fprintf(file, "%s::%s()", entnm, entnm); + fprintf( file, "%s::%s()", entnm, entnm ); /* ////MULTIPLE INHERITANCE//////// */ - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { /* if there's no super class yet, or the super class doesn't have any attributes */ super_cnt++; - if(super_cnt == 1) { + if( super_cnt == 1 ) { bool firstInitializer = false; /* ignore the 1st parent */ - const char *parent = ENTITYget_classname(e); + const char * parent = ENTITYget_classname( e ); /* parent class initializer */ - fprintf(file, ": %s()", parent); - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); - fprintf(file, " /* parent: %s */\n%s\n%s\n", parent, + fprintf( file, ": %s()", parent ); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); + fprintf( file, " /* parent: %s */\n%s\n%s\n", parent, " /* Ignore the first parent since it is */", - " /* part of the main inheritance hierarchy */"); + " /* part of the main inheritance hierarchy */" ); principalSuper = e; /* principal SUPERTYPE */ } else { - fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); - fprintf(file, " HeadEntity(this);\n"); - fprintf(file, " AppendMultInstance(new %s(this));\n", - ENTITYget_classname(e)); - - if(super_cnt == 2) { - printf("\nMULTIPLE INHERITANCE for entity: %s\n", - ENTITYget_name(entity)); - printf(" SUPERTYPE 1: %s (principal supertype)\n", - ENTITYget_name(principalSuper)); + fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); + fprintf( file, " HeadEntity(this);\n" ); + fprintf( file, " AppendMultInstance(new %s(this));\n", + ENTITYget_classname( e ) ); + + if( super_cnt == 2 ) { + printf( "\nMULTIPLE INHERITANCE for entity: %s\n", + ENTITYget_name( entity ) ); + printf( " SUPERTYPE 1: %s (principal supertype)\n", + ENTITYget_name( principalSuper ) ); } - printf(" SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name(e)); + printf( " SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name( e ) ); } - } - LISTod; + } LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ /* no parent class constructor has been printed, so still need an opening brace */ bool firstInitializer = true; - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); - fprintf(file, " /* no SuperTypes */\n"); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); + fprintf( file, " /* no SuperTypes */\n" ); } } /* what if entity comes from other schema? * It appears that entity.superscope.symbol.name is the schema name (but only if entity.superscope.type == 's'?) --MAP 27Nov11 */ - fprintf(file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* include attribute if it is not derived */ - generate_attribute_name(a, attrnm); - t = VARget_type(a); + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); - if(!VARget_inverse(a) && !VARis_derived(a)) { + if( !VARget_inverse( a ) && !VARis_derived( a ) ) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if(TYPEis_aggregate(t)) { - fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); + if( TYPEis_aggregate( t ) ) { + fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); } - fprintf(file, " %sa = new STEPattribute( * %s::", - (first ? "STEPattribute * " : ""), /* first time through, declare 'a' */ - SCHEMAget_name(schema)); - fprintf(file, "%s%d%s%s", ATTR_PREFIX, a->idx, (VARis_type_shifter(a) ? "R" : ""), attrnm); - fprintf(file, ", %s%s_%s );\n", - (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * ) " : ""), - (TYPEis_aggregate(t) ? "" : "& "), attrnm); - if(first) { + fprintf( file, " %sa = new STEPattribute( * %s::", + ( first ? "STEPattribute * " : "" ), /* first time through, declare 'a' */ + SCHEMAget_name( schema ) ); + fprintf( file, "%s%d%s%s", ATTR_PREFIX, a->idx, ( VARis_type_shifter( a ) ? "R" : "" ), attrnm ); + fprintf( file, ", %s%s_%s );\n", + ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * ) " : "" ), + ( TYPEis_aggregate( t ) ? "" : "& " ), attrnm ); + if( first ) { first = false; } /* 2. initialize everything to NULL (even if not optional) */ - fprintf(file, " a->set_null();\n"); + fprintf( file, " a->set_null();\n" ); /* 3. put attribute on attributes list */ - fprintf(file, " attributes.push( a );\n"); + fprintf( file, " attributes.push( a );\n" ); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if(VARis_type_shifter(a)) { - fprintf(file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name(a)); + if( VARis_type_shifter( a ) ) { + fprintf( file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name( a ) ); } } } - } - LISTod; + } LISTod; - initializeAttrs(entity, file); + initializeAttrs( entity, file ); - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); /* copy constructor */ - entnm = ENTITYget_classname(entity); - fprintf(file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm); + entnm = ENTITYget_classname( entity ); + fprintf( file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm ); /* include explicit initialization of base class */ - if(principalSuper) { - fprintf(file, "%s()", ENTITYget_classname(principalSuper)); + if( principalSuper ) { + fprintf( file, "%s()", ENTITYget_classname( principalSuper ) ); } else { - fprintf(file, "SDAI_Application_instance()"); + fprintf( file, "SDAI_Application_instance()" ); } - fprintf(file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n"); + fprintf( file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n" ); /* print destructor */ /* currently empty, but should check to see if any attributes need to be deleted -- attributes will need reference count */ - entnm = ENTITYget_classname(entity); - fprintf(file, "%s::~%s() {\n", entnm, entnm); + entnm = ENTITYget_classname( entity ); + fprintf( file, "%s::~%s() {\n", entnm, entnm ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { - generate_attribute_name(a, attrnm); - t = VARget_type(a); + LISTdo( attr_list, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - if(TYPEis_aggregate(t)) { - fprintf(file, " delete _%s;\n", attrnm); + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + if( TYPEis_aggregate( t ) ) { + fprintf( file, " delete _%s;\n", attrnm ); } } } LISTod; - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); } /********************/ @@ -509,8 +486,7 @@ void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema when building multiply inherited entities. \sa LIBstructor_print() */ -void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -520,19 +496,19 @@ void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, /* added for calling parents constructor if there is one */ char parentnm [BUFSIZ]; - char *parent = 0; + char * parent = 0; - const char *entnm; + const char * entnm; bool first = true; - if(multiple_inheritance) { + if( multiple_inheritance ) { bool firstInitializer = true; Entity parentEntity = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - parentEntity = (Entity)LISTpeek_first(list); - if(parentEntity) { - strcpy(parentnm, ENTITYget_classname(parentEntity)); + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + parentEntity = ( Entity )LISTpeek_first( list ); + if( parentEntity ) { + strcpy( parentnm, ENTITYget_classname( parentEntity ) ); parent = parentnm; } else { parent = 0; /* no parent */ @@ -544,111 +520,109 @@ void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, /* ENTITYget_classname returns a static buffer so don't call it twice before it gets used - (I didn't write it) - I had to move it below the above use. DAS */ - entnm = ENTITYget_classname(entity); + entnm = ENTITYget_classname( entity ); /* constructor definition */ - if(parent) { + if( parent ) { firstInitializer = false; - fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm); + fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm ); } else { - fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm); + fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm ); } - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); - fprintf(file, " /* Set this to point to the head entity. */\n"); - fprintf(file, " HeadEntity(se);\n"); - if(!parent) { - fprintf(file, " ( void ) addAttrs; /* quell potentially unused var */\n\n"); + fprintf( file, " /* Set this to point to the head entity. */\n" ); + fprintf( file, " HeadEntity(se);\n" ); + if( !parent ) { + fprintf( file, " ( void ) addAttrs; /* quell potentially unused var */\n\n" ); } - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - LISTdo(list, e, Entity) + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) /* if there's no super class yet, or the super class doesn't have any attributes */ - fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); + fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); super_cnt++; - if(super_cnt == 1) { + if( super_cnt == 1 ) { /* ignore the 1st parent */ - fprintf(file, - " /* Ignore the first parent since it is part *\n%s\n", - " ** of the main inheritance hierarchy */"); + fprintf( file, + " /* Ignore the first parent since it is part *\n%s\n", + " ** of the main inheritance hierarchy */" ); } else { - fprintf(file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", - ENTITYget_classname(e)); + fprintf( file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", + ENTITYget_classname( e ) ); } LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ - fprintf(file, " /* no SuperTypes */\n"); + fprintf( file, " /* no SuperTypes */\n" ); } /* what if entity comes from other schema? */ - fprintf(file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* include attribute if it is not derived */ - generate_attribute_name(a, attrnm); - t = VARget_type(a); - if(!VARget_inverse(a) && !VARis_derived(a)) { + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); + if( !VARget_inverse( a ) && !VARis_derived( a ) ) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if(TYPEis_aggregate(t)) { - fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); + if( TYPEis_aggregate( t ) ) { + fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); } - fprintf(file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", - (first ? "STEPattribute * " : ""), /* first time through, declare a */ - SCHEMAget_name(schema), + fprintf( file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", + ( first ? "STEPattribute * " : "" ), /* first time through, declare a */ + SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, - (VARis_type_shifter(a) ? "R" : ""), + ( VARis_type_shifter( a ) ? "R" : "" ), attrnm, - (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * )" : ""), - (TYPEis_aggregate(t) ? "" : "&"), - attrnm); + ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * )" : "" ), + ( TYPEis_aggregate( t ) ? "" : "&" ), + attrnm ); - if(first) { + if( first ) { first = false; } - fprintf(file, " /* initialize to NULL (even if not optional) */\n"); - fprintf(file, " a ->set_null();\n"); + fprintf( file, " /* initialize to NULL (even if not optional) */\n" ); + fprintf( file, " a ->set_null();\n" ); - fprintf(file, " /* Put attribute on this class' attributes list so the access functions still work. */\n"); - fprintf(file, " attributes.push( a );\n"); + fprintf( file, " /* Put attribute on this class' attributes list so the access functions still work. */\n" ); + fprintf( file, " attributes.push( a );\n" ); - fprintf(file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n"); - fprintf(file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n"); - fprintf(file, " if( addAttrs ) {\n"); - fprintf(file, " se->attributes.push( a );\n }\n"); + fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n" ); + fprintf( file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); + fprintf( file, " if( addAttrs ) {\n" ); + fprintf( file, " se->attributes.push( a );\n }\n" ); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if(VARis_type_shifter(a)) { - fprintf(file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name(a)); + if( VARis_type_shifter( a ) ) { + fprintf( file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name( a ) ); } } } - } - LISTod + } LISTod - initializeAttrs(entity, file); + initializeAttrs( entity, file ); - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); } /* end if(multiple_inheritance) */ } /** return 1 if types are predefined by us */ -bool TYPEis_builtin(const Type t) -{ - switch(TYPEget_body(t)->type) { /* dunno if correct*/ +bool TYPEis_builtin( const Type t ) { + switch( TYPEget_body( t )->type ) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -680,30 +654,29 @@ bool TYPEis_builtin(const Type t) * \param a, an Express attribute * \param out, the C++ name */ -char *generate_dict_attr_name(Variable a, char *out) -{ - char *temp, *p, *q; +char * generate_dict_attr_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - temp = EXPRto_string(VARget_name(a)); + temp = EXPRto_string( VARget_name( a ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ - strncpy(out, StrToLower(p), BUFSIZ); + strncpy( out, StrToLower( p ), BUFSIZ ); /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; *p != '\0' && j < BUFSIZ; p++) { + for( j = 0, q = out; *p != '\0' && j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if(*p != '\n') { - *q = tolower(*p); + if( *p != '\n' ) { + *q = tolower( *p ); j++; q++; } } *q = '\0'; - sc_free(temp); + sc_free( temp ); return out; } @@ -714,238 +687,237 @@ char *generate_dict_attr_name(Variable a, char *out) * \param impl implementation file being written to * \param schema schema the entity is in */ -void ENTITYincode_print(Entity entity, FILE *header, FILE *impl, Schema schema) -{ +void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schema ) { #define entity_name ENTITYget_name(entity) #define schema_name SCHEMAget_name(schema) char attrnm [BUFSIZ]; char dict_attrnm [BUFSIZ]; - const char *super_schema; - char *tmp, *tmp2; + const char * super_schema; + char * tmp, *tmp2; bool hasInverse = false; #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the entity into the schema descriptor */ - fprintf(impl, - " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", - schema_name, schema_name, ENT_PREFIX, entity_name); + fprintf( impl, + " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", + schema_name, schema_name, ENT_PREFIX, entity_name ); #endif - if(ENTITYget_abstract(entity)) { - if(entity->u.entity->subtype_expression) { + if( ENTITYget_abstract( entity ) ) { + if( entity->u.entity->subtype_expression ) { - fprintf(impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n"); + fprintf( impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n" ); - format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); - fprintf(impl, " str.append( \")\" );\n"); - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); + format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); + fprintf( impl, " str.append( \")\" );\n" ); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); } else { - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", - schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", + schema_name, ENT_PREFIX, entity_name ); } } else { - if(entity->u.entity->subtype_expression) { - fprintf(impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n"); - format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); - fprintf(impl, " str.append( \")\" );\n"); - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); + if( entity->u.entity->subtype_expression ) { + fprintf( impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n" ); + format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); + fprintf( impl, " str.append( \")\" );\n" ); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); } } - LISTdo(ENTITYget_supertypes(entity), sup, Entity) + LISTdo( ENTITYget_supertypes( entity ), sup, Entity ) /* set the owning schema of the supertype */ - super_schema = SCHEMAget_name(ENTITYget_schema(sup)); + super_schema = SCHEMAget_name( ENTITYget_schema( sup ) ); /* print the supertype list for this entity */ - fprintf(impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", - schema_name, ENT_PREFIX, entity_name, - super_schema, - ENT_PREFIX, ENTITYget_name(sup)); + fprintf( impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", + schema_name, ENT_PREFIX, entity_name, + super_schema, + ENT_PREFIX, ENTITYget_name( sup ) ); /* add this entity to the subtype list of it's supertype */ - fprintf(impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", - super_schema, - ENT_PREFIX, ENTITYget_name(sup), - schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", + super_schema, + ENT_PREFIX, ENTITYget_name( sup ), + schema_name, ENT_PREFIX, entity_name ); LISTod - LISTdo(ENTITYget_attributes(entity), v, Variable) - if(VARget_inverse(v)) { + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + if( VARget_inverse( v ) ) { hasInverse = true; } - generate_attribute_name(v, attrnm); + generate_attribute_name( v, attrnm ); /* do EXPLICIT and DERIVED attributes first */ /* if ( ! VARget_inverse (v)) {*/ /* first make sure that type descriptor exists */ - if(TYPEget_name(v->type)) { - if((!TYPEget_head(v->type)) && - (TYPEget_body(v->type)->type == entity_)) { - fprintf(impl, " %s::%s%d%s%s =", SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), - attrnm); - fprintf(impl, "\n new %s( \"%s\",", - (VARget_inverse(v) ? "Inverse_attribute" : - (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm)); - - /* following assumes we are not in a nested */ - /* entity otherwise we should search upward */ - /* for schema */ - /* attribute's type */ - fprintf(impl, " %s::%s%s, %s,\n", TYPEget_name(TYPEget_body(v->type)->entity->superscope), - ENT_PREFIX, TYPEget_name(v->type), (VARget_optional(v) ? "LTrue" : "LFalse")); - fprintf(impl, " %s%s, *%s::%s%s);\n", (VARget_unique(v) ? "LTrue" : "LFalse"), - /* Support REDEFINED */ - (VARget_inverse(v) ? "" : (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity)); + if( TYPEget_name( v->type ) ) { + if( ( !TYPEget_head( v->type ) ) && + ( TYPEget_body( v->type )->type == entity_ ) ) { + fprintf( impl, " %s::%s%d%s%s =", SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + fprintf( impl, "\n new %s( \"%s\",", + ( VARget_inverse( v ) ? "Inverse_attribute" : + ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ) ); + + /* following assumes we are not in a nested */ + /* entity otherwise we should search upward */ + /* for schema */ + /* attribute's type */ + fprintf( impl, " %s::%s%s, %s,\n", TYPEget_name( TYPEget_body( v->type )->entity->superscope ), + ENT_PREFIX, TYPEget_name( v->type ), ( VARget_optional( v ) ? "LTrue" : "LFalse" ) ); + fprintf( impl, " %s%s, *%s::%s%s);\n", ( VARget_unique( v ) ? "LTrue" : "LFalse" ), + /* Support REDEFINED */ + ( VARget_inverse( v ) ? "" : ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } else { /* type reference */ - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), - SCHEMAget_name(v->type->superscope), - TD_PREFIX, TYPEget_name(v->type), + SCHEMAget_name( v->type->superscope ), + TD_PREFIX, TYPEget_name( v->type ), - (VARget_optional(v) ? "LTrue" : "LFalse"), + ( VARget_optional( v ) ? "LTrue" : "LFalse" ), - (VARget_unique(v) ? "LTrue" : "LFalse"), + ( VARget_unique( v ) ? "LTrue" : "LFalse" ), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), - schema_name, ENT_PREFIX, TYPEget_name(entity) + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } - } else if(TYPEis_builtin(v->type)) { + } else if( TYPEis_builtin( v->type ) ) { /* the type wasn't named -- it must be built in or aggregate */ - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), - /* not sure about 0 here */ TD_PREFIX, FundamentalType(v->type, 0), - (VARget_optional(v) ? "LTrue" : - "LFalse"), - (VARget_unique(v) ? "LTrue" : - "LFalse"), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? - ", AttrType_Redefining" : - ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity) + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), + /* not sure about 0 here */ TD_PREFIX, FundamentalType( v->type, 0 ), + ( VARget_optional( v ) ? "LTrue" : + "LFalse" ), + ( VARget_unique( v ) ? "LTrue" : + "LFalse" ), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? + ", AttrType_Redefining" : + ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } else { /* manufacture new one(s) on the spot */ char typename_buf[MAX_LEN]; - print_typechain(header, impl, v->type, typename_buf, schema, v->name->symbol.name); - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), - typename_buf, - (VARget_optional(v) ? "LTrue" : - "LFalse"), - (VARget_unique(v) ? "LTrue" : - "LFalse"), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? - ", AttrType_Redefining" : - ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity) + print_typechain( header, impl, v->type, typename_buf, schema, v->name->symbol.name ); + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), + typename_buf, + ( VARget_optional( v ) ? "LTrue" : + "LFalse" ), + ( VARget_unique( v ) ? "LTrue" : + "LFalse" ), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? + ", AttrType_Redefining" : + ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } - fprintf(impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", - schema_name, ENT_PREFIX, TYPEget_name(entity), - (VARget_inverse(v) ? "Inverse" : "Explicit"), - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm); - - if(VARis_derived(v) && v->initializer) { - tmp = EXPRto_string(v->initializer); - tmp2 = (char *)sc_malloc(sizeof(char) * (strlen(tmp) + BUFSIZ)); - fprintf(impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, format_for_stringout(tmp, tmp2)); - sc_free(tmp); - sc_free(tmp2); + fprintf( impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", + schema_name, ENT_PREFIX, TYPEget_name( entity ), + ( VARget_inverse( v ) ? "Inverse" : "Explicit" ), + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + + if( VARis_derived( v ) && v->initializer ) { + tmp = EXPRto_string( v->initializer ); + tmp2 = ( char * )sc_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); + fprintf( impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, format_for_stringout( tmp, tmp2 ) ); + sc_free( tmp ); + sc_free( tmp2 ); } - if(VARget_inverse(v)) { - fprintf(impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, v->inverse_attribute->name->symbol.name); - if(v->type->symbol.name) { - fprintf(impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - v->type->symbol.name); - fprintf(impl, "// inverse entity 1 %s\n", v->type->symbol.name); + if( VARget_inverse( v ) ) { + fprintf( impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, v->inverse_attribute->name->symbol.name ); + if( v->type->symbol.name ) { + fprintf( impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + v->type->symbol.name ); + fprintf( impl, "// inverse entity 1 %s\n", v->type->symbol.name ); } else { - switch(TYPEget_body(v->type)->type) { + switch( TYPEget_body( v->type )->type ) { case entity_: - fprintf(impl, - " %s%d%s%s->inverted_entity_id_(\"%s\");\n", - ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - TYPEget_body(v->type)->entity->symbol.name); - fprintf(impl, "// inverse entity 2 %s\n", TYPEget_body(v->type)->entity->symbol.name); + fprintf( impl, + " %s%d%s%s->inverted_entity_id_(\"%s\");\n", + ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + TYPEget_body( v->type )->entity->symbol.name ); + fprintf( impl, "// inverse entity 2 %s\n", TYPEget_body( v->type )->entity->symbol.name ); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf(impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - TYPEget_body(v->type)->base->symbol.name); - fprintf(impl, "// inverse entity 3 %s\n", TYPEget_body(v->type)->base->symbol.name); + fprintf( impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + TYPEget_body( v->type )->base->symbol.name ); + fprintf( impl, "// inverse entity 3 %s\n", TYPEget_body( v->type )->base->symbol.name ); break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); abort(); } } @@ -953,57 +925,55 @@ void ENTITYincode_print(Entity entity, FILE *header, FILE *impl, Schema schema) LISTod - fprintf(impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name); - if(hasInverse) { - fprintf(impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name ); + if( hasInverse ) { + fprintf( impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name ); } #undef schema_name } -void ENTITYPrint_h(const Entity entity, FILE *header, Linked_List neededAttr, Schema schema) -{ - const char *name = ENTITYget_classname(entity); - DEBUG("Entering ENTITYPrint_h for %s\n", name); +void ENTITYPrint_h( const Entity entity, FILE * header, Linked_List neededAttr, Schema schema ) { + const char *name = ENTITYget_classname( entity ); + DEBUG( "Entering ENTITYPrint_h for %s\n", name ); - ENTITYhead_print(entity, header); - DataMemberPrint(entity, neededAttr, header); - MemberFunctionSign(entity, neededAttr, header); + ENTITYhead_print( entity, header ); + DataMemberPrint( entity, neededAttr, header ); + MemberFunctionSign( entity, neededAttr, header ); + + fprintf( header, "void init_%s(Registry& reg);\n\n", name ); - fprintf(header, "void init_%s(Registry& reg);\n\n", name); + fprintf( header, "namespace %s {\n", SCHEMAget_name( schema ) ); + ENTITYnames_print( entity, header ); + ATTRnames_print( entity, header ); + fprintf( header, "}\n\n" ); - fprintf(header, "namespace %s {\n", SCHEMAget_name(schema)); - ENTITYnames_print(entity, header); - ATTRnames_print(entity, header); - fprintf(header, "}\n\n"); - - DEBUG("DONE ENTITYPrint_h\n"); + DEBUG( "DONE ENTITYPrint_h\n" ); } -void ENTITYPrint_cc(const Entity entity, FILE *createall, FILE *header, FILE *impl, Linked_List neededAttr, Schema schema, bool externMap) -{ - const char *name = ENTITYget_classname(entity); - - DEBUG("Entering ENTITYPrint_cc for %s\n", name); +void ENTITYPrint_cc( const Entity entity, FILE * createall, FILE * header, FILE * impl, Linked_List neededAttr, Schema schema, bool externMap ) { + const char * name = ENTITYget_classname( entity ); + + DEBUG( "Entering ENTITYPrint_cc for %s\n", name ); - fprintf(impl, "#include \"schema.h\"\n"); - fprintf(impl, "#include \"sc_memmgr.h\"\n"); - fprintf(impl, "#include \"entity/%s.h\"\n\n", name); + fprintf( impl, "#include \"schema.h\"\n" ); + fprintf( impl, "#include \"sc_memmgr.h\"\n" ); + fprintf( impl, "#include \"entity/%s.h\"\n\n", name ); - LIBdescribe_entity(entity, impl, schema); - LIBstructor_print(entity, neededAttr, impl, schema); - if(multiple_inheritance) { - LIBstructor_print_w_args(entity, neededAttr, impl, schema); + LIBdescribe_entity( entity, impl, schema ); + LIBstructor_print( entity, neededAttr, impl, schema ); + if( multiple_inheritance ) { + LIBstructor_print_w_args( entity, neededAttr, impl, schema ); } - LIBmemberFunctionPrint(entity, neededAttr, impl, schema); - - fprintf(impl, "void init_%s( Registry& reg ) {\n", name); - fprintf(impl, " std::string str;\n\n"); - ENTITYprint_descriptors(entity, createall, impl, schema, externMap); - ENTITYincode_print(entity, header, impl, schema); - fprintf(impl, "}\n\n"); - - DEBUG("DONE ENTITYPrint_cc\n"); + LIBmemberFunctionPrint( entity, neededAttr, impl, schema ); + + fprintf( impl, "void init_%s( Registry& reg ) {\n", name ); + fprintf( impl, " std::string str;\n\n" ); + ENTITYprint_descriptors( entity, createall, impl, schema, externMap ); + ENTITYincode_print( entity, header, impl, schema ); + fprintf( impl, "}\n\n" ); + + DEBUG( "DONE ENTITYPrint_cc\n" ); } /** \sa collectAttributes */ @@ -1014,40 +984,37 @@ enum CollectType { ALL, ALL_BUT_FIRST, FIRST_ONLY }; * \param curEntity current Entity being processed * \param collect selects attrs to be collected */ -static void collectAttributes(Linked_List curList, const Entity curEntity, enum CollectType collect) -{ - Linked_List parent_list = ENTITYget_supertypes(curEntity); +static void collectAttributes( Linked_List curList, const Entity curEntity, enum CollectType collect ) { + Linked_List parent_list = ENTITYget_supertypes( curEntity ); - if(! LISTempty(parent_list)) { - if(collect != FIRST_ONLY) { + if( ! LISTempty( parent_list ) ) { + if( collect != FIRST_ONLY ) { /* collect attributes from parents and their supertypes */ - LISTdo(parent_list, e, Entity) { - if(collect == ALL_BUT_FIRST) { + LISTdo( parent_list, e, Entity ) { + if( collect == ALL_BUT_FIRST ) { /* skip first and collect from the rest */ collect = ALL; } else { /* collect attributes of this parent and its supertypes */ - collectAttributes(curList, e, ALL); + collectAttributes( curList, e, ALL ); } } LISTod; } else { /* collect attributes of only first parent and its supertypes */ - collectAttributes(curList, (Entity) LISTpeek_first(parent_list), ALL); + collectAttributes( curList, ( Entity ) LISTpeek_first( parent_list ), ALL ); } } /* prepend this entity's attributes to the result list */ - LISTdo(ENTITYget_attributes(curEntity), attr, Variable) { - LISTadd_first(curList, attr); - } - LISTod; + LISTdo( ENTITYget_attributes( curEntity ), attr, Variable ) { + LISTadd_first( curList, attr ); + } LISTod; } -static bool listContainsVar(Linked_List l, Variable v) -{ - const char *vName = VARget_simple_name(v); - LISTdo(l, curr, Variable) { - if(!strcmp(vName, VARget_simple_name(curr))) { +static bool listContainsVar( Linked_List l, Variable v ) { + const char * vName = VARget_simple_name( v ); + LISTdo( l, curr, Variable ) { + if( !strcmp( vName, VARget_simple_name( curr ) ) ) { return true; } } @@ -1064,14 +1031,13 @@ static bool listContainsVar(Linked_List l, Variable v) * \param entity entity being processed * \param file file being written to */ -void ENTITYlib_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ - LIBdescribe_entity(entity, file, schema); - LIBstructor_print(entity, neededAttr, file, schema); - if(multiple_inheritance) { - LIBstructor_print_w_args(entity, neededAttr, file, schema); +void ENTITYlib_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { + LIBdescribe_entity( entity, file, schema ); + LIBstructor_print( entity, neededAttr, file, schema ); + if( multiple_inheritance ) { + LIBstructor_print_w_args( entity, neededAttr, file, schema ); } - LIBmemberFunctionPrint(entity, neededAttr, file, schema); + LIBmemberFunctionPrint( entity, neededAttr, file, schema ); } /** drives the functions for printing out code in lib, @@ -1081,59 +1047,58 @@ void ENTITYlib_print(Entity entity, Linked_List neededAttr, FILE *file, Schema s * \p schema name of the schema * \p col the ComplexCollect */ -void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap) -{ - FILE *hdr, * impl; - char *n = ENTITYget_name(entity); +void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) { + FILE * hdr, * impl; + char * n = ENTITYget_name( entity ); Linked_List remaining = LISTcreate(); - filenames_t names = getEntityFilenames(entity); + filenames_t names = getEntityFilenames( entity ); - DEBUG("Entering ENTITYPrint for %s\n", n); + DEBUG( "Entering ENTITYPrint for %s\n", n ); - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List existing = LISTcreate(); Linked_List required = LISTcreate(); /* create list of attr inherited from the parents in C++ */ - collectAttributes(existing, entity, FIRST_ONLY); + collectAttributes( existing, entity, FIRST_ONLY ); /* create list of attr that have to be inherited in EXPRESS */ - collectAttributes(required, entity, ALL_BUT_FIRST); + collectAttributes( required, entity, ALL_BUT_FIRST ); /* build list of unique attr that are required but haven't been */ /* inherited */ - LISTdo(required, attr, Variable) { - if(!listContainsVar(existing, attr) && - !listContainsVar(remaining, attr)) { - LISTadd_first(remaining, attr); + LISTdo( required, attr, Variable ) { + if( !listContainsVar( existing, attr ) && + !listContainsVar( remaining, attr ) ) { + LISTadd_first( remaining, attr ); } } LISTod; - LIST_destroy(existing); - LIST_destroy(required); + LIST_destroy( existing ); + LIST_destroy( required ); } - if(mkDirIfNone("entity") == -1) { - fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror(0); + if( mkDirIfNone( "entity" ) == -1 ) { + fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror( 0 ); abort(); } - hdr = FILEcreate(names.header); - impl = FILEcreate(names.impl); - assert(hdr && impl && "error creating files"); - fprintf(files->unity.entity.hdr, "#include \"%s\"\n", names.header); /* TODO this is not necessary? */ - fprintf(files->unity.entity.impl, "#include \"%s\"\n", names.impl); + hdr = FILEcreate( names.header ); + impl = FILEcreate( names.impl ); + assert( hdr && impl && "error creating files" ); + fprintf( files->unity.entity.hdr, "#include \"%s\"\n", names.header ); /* TODO this is not necessary? */ + fprintf( files->unity.entity.impl, "#include \"%s\"\n", names.impl ); - ENTITYPrint_h(entity, hdr, remaining, schema); - ENTITYPrint_cc(entity, files->create, hdr, impl, remaining, schema, externMap); - FILEclose(hdr); - FILEclose(impl); + ENTITYPrint_h( entity, hdr, remaining, schema ); + ENTITYPrint_cc( entity, files->create, hdr, impl, remaining, schema, externMap ); + FILEclose( hdr ); + FILEclose( impl ); - fprintf(files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname(entity)); - fprintf(files->init, " init_%s( reg );\n", ENTITYget_classname(entity)); + fprintf( files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname( entity ) ); + fprintf( files->init, " init_%s( reg );\n", ENTITYget_classname( entity ) ); - DEBUG("DONE ENTITYPrint\n"); - LIST_destroy(remaining); + DEBUG( "DONE ENTITYPrint\n" ); + LIST_destroy( remaining ); } /** create entity descriptors @@ -1149,29 +1114,27 @@ void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap) * eDesc is printed into createall because it must be initialized before other entity init fn's are called * alternative is two init fn's per ent. call init1 for each ent, then repeat with init2 */ -void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap) -{ - fprintf(createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(createall, "\"%s\", %s::schema, %s, ", PrettyTmpName(ENTITYget_name(entity)), SCHEMAget_name(schema), (ENTITYget_abstract(entity) ? "LTrue" : "LFalse")); - fprintf(createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname(entity)); +void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ) { + fprintf( createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( createall, "\"%s\", %s::schema, %s, ", PrettyTmpName( ENTITYget_name( entity ) ), SCHEMAget_name( schema ), ( ENTITYget_abstract( entity ) ? "LTrue" : "LFalse" ) ); + fprintf( createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname( entity ) ); /* add the entity to the Schema dictionary entry */ - fprintf(createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name(schema), SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - WHEREprint(ENTITYget_name(entity), TYPEget_where(entity), impl, schema, true); - UNIQUEprint(entity, impl, schema); + WHEREprint( ENTITYget_name( entity ), TYPEget_where( entity ), impl, schema, true ); + UNIQUEprint( entity, impl, schema ); } /** print in classes file: class forward prototype, class typedefs * split out of ENTITYprint_new, which is now ENTITYprint_descriptors */ -void ENTITYprint_classes(Entity entity, FILE *classes) -{ - const char *n = ENTITYget_classname(entity); - fprintf(classes, "\nclass %s;\n", n); - fprintf(classes, "typedef %s * %sH;\n", n, n); - fprintf(classes, "typedef %s * %s_ptr;\n", n, n); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", n, n); - fprintf(classes, "typedef %s_ptr %s_var;\n", n, n); - fprintf(classes, "#define %s__set SDAI_DAObject__set\n", n); - fprintf(classes, "#define %s__set_var SDAI_DAObject__set_var\n", n); +void ENTITYprint_classes( Entity entity, FILE * classes ) { + const char * n = ENTITYget_classname( entity ); + fprintf( classes, "\nclass %s;\n", n ); + fprintf( classes, "typedef %s * %sH;\n", n, n ); + fprintf( classes, "typedef %s * %s_ptr;\n", n, n ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", n, n ); + fprintf( classes, "typedef %s_ptr %s_var;\n", n, n ); + fprintf( classes, "#define %s__set SDAI_DAObject__set\n", n ); + fprintf( classes, "#define %s__set_var SDAI_DAObject__set_var\n", n ); } diff --git a/src/exp2cxx/classes_entity.h b/src/exp2cxx/classes_entity.h index 32f184bc3..8e1c6e0be 100644 --- a/src/exp2cxx/classes_entity.h +++ b/src/exp2cxx/classes_entity.h @@ -1,12 +1,12 @@ #ifndef CLASSES_ENTITY_H #define CLASSES_ENTITY_H -const char *ENTITYget_classname(Entity); -Entity ENTITYget_superclass(Entity entity); -Entity ENTITYput_superclass(Entity entity); -int ENTITYhas_explicit_attributes(Entity e); -void ENTITYget_first_attribs(Entity entity, Linked_List result); -void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap); -void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap); -void ENTITYprint_classes(Entity entity, FILE *classes); +const char * ENTITYget_classname( Entity ); +Entity ENTITYget_superclass( Entity entity ); +Entity ENTITYput_superclass( Entity entity ); +int ENTITYhas_explicit_attributes( Entity e ); +void ENTITYget_first_attribs( Entity entity, Linked_List result ); +void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ); +void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ); +void ENTITYprint_classes( Entity entity, FILE * classes ); #endif diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 2b8ba07bf..4e24a8d24 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -4,6 +4,7 @@ #include "classes.h" #include +#include "sc_version_string.h" #include "class_strings.h" /** \file classes_misc.c @@ -30,73 +31,68 @@ extern int multiple_inheritance; * Returns: FILE* pointer to file created or NULL * Status: complete */ -FILE *FILEcreate(const char *filename) -{ - FILE *file; - const char *fn; - - if((file = fopen(filename, "w")) == NULL) { - fprintf(stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename); - return (NULL); +FILE * FILEcreate( const char * filename ) { + FILE * file; + const char * fn; + + if( ( file = fopen( filename, "w" ) ) == NULL ) { + fprintf( stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename ); + return ( NULL ); } - fn = StrToConstant(filename); - fprintf(file, "#ifndef %s\n", fn); - fprintf(file, "#define %s\n\n", fn); + fn = StrToConstant ( filename ); + fprintf( file, "#ifndef %s\n", fn ); + fprintf( file, "#define %s\n\n", fn ); - fprintf(file, "// This file was generated by exp2cxx,\n// %s.\n", SC_VERSION); - fprintf(file, "// You probably don't want to edit it since your modifications\n"); - fprintf(file, "// will be lost if exp2cxx is used to regenerate it.\n\n"); - return (file); + fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version ); + fprintf( file, "// You probably don't want to edit it since your modifications\n" ); + fprintf( file, "// will be lost if exp2cxx is used to regenerate it.\n\n" ); + return ( file ); } /** closes a file opened with FILEcreate */ -void FILEclose(FILE *file) -{ - fprintf(file, "#endif\n"); - fclose(file); +void FILEclose( FILE * file ) { + fprintf( file, "#endif\n" ); + fclose( file ); } /** indicates whether the attribute is an aggregate */ -int isAggregate(Variable a) -{ - return(TYPEinherits_from(VARget_type(a), aggregate_)); +int isAggregate( Variable a ) { + return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); } /** indicates whether the attribute is an aggregate */ -int isAggregateType(const Type t) -{ - return(TYPEinherits_from(t, aggregate_)); +int isAggregateType( const Type t ) { + return( TYPEinherits_from( t, aggregate_ ) ); } /** \returns a pointer to a static buffer, containing a string which is the type used by the c++ data member access functions */ -const char *AccessType(Type t) -{ +const char * AccessType( Type t ) { Class_Of_Type class; static char nm [BUFSIZ]; - strncpy(nm, TypeName(t), BUFSIZ - 4); - if(TYPEis_entity(t)) { - strcat(nm, "_ptr"); + strncpy( nm, TypeName( t ), BUFSIZ - 4 ); + if( TYPEis_entity( t ) ) { + strcat( nm, "_ptr" ); return nm; - } else if(TYPEis_select(t) || TYPEis_aggregate(t)) { - strcat(nm, "_ptr"); + } else if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + strcat( nm, "_ptr" ); return nm; } - class = TYPEget_type(t); - if(class == enumeration_) { - strncpy(nm, TypeName(t), BUFSIZ - 2); - strcat(nm, "_var"); + class = TYPEget_type( t ); + if( class == enumeration_ ) { + strncpy( nm, TypeName( t ), BUFSIZ - 2 ); + strcat( nm, "_var" ); return nm; } - if(class == logical_) { - strncpy(nm, "Logical", BUFSIZ - 2); + if( class == logical_ ) { + strncpy( nm, "Logical", BUFSIZ - 2 ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - strncpy(nm, "Boolean", BUFSIZ - 2); + if( class == boolean_ ) { + strncpy( nm, "Boolean", BUFSIZ - 2 ); } return nm; } @@ -105,139 +101,133 @@ const char *AccessType(Type t) * * creates a new name with first character's in caps */ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } /* This function is out of date DAS */ -const char *EnumName(const char *oldname) -{ +const char * EnumName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENUM_PREFIX); - j = strlen(ENUM_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); - j = strlen(newname); + strcpy( newname, ENUM_PREFIX ); + j = strlen( ENUM_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *SelectName(const char *oldname) -{ +const char * SelectName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, TYPE_PREFIX); - newname [0] = ToUpper(newname [0]); - j = strlen(TYPE_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); - j = strlen(newname); + strcpy( newname, TYPE_PREFIX ); + newname [0] = ToUpper( newname [0] ); + j = strlen( TYPE_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } /** \return fundamental type but as the string which corresponds to the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char *FundamentalType(const Type t, int report_reftypes) -{ - if(report_reftypes && TYPEget_head(t)) { - return("REFERENCE_TYPE"); +const char * FundamentalType( const Type t, int report_reftypes ) { + if( report_reftypes && TYPEget_head( t ) ) { + return( "REFERENCE_TYPE" ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: - return("sdaiINTEGER"); + return( "sdaiINTEGER" ); case real_: - return("sdaiREAL"); + return( "sdaiREAL" ); case string_: - return("sdaiSTRING"); + return( "sdaiSTRING" ); case binary_: - return("sdaiBINARY"); + return( "sdaiBINARY" ); case boolean_: - return("sdaiBOOLEAN"); + return( "sdaiBOOLEAN" ); case logical_: - return("sdaiLOGICAL"); + return( "sdaiLOGICAL" ); case number_: - return("sdaiNUMBER"); + return( "sdaiNUMBER" ); case generic_: - return("GENERIC_TYPE"); + return( "GENERIC_TYPE" ); case aggregate_: - return("AGGREGATE_TYPE"); + return( "AGGREGATE_TYPE" ); case array_: - return("ARRAY_TYPE"); + return( "ARRAY_TYPE" ); case bag_: - return("BAG_TYPE"); + return( "BAG_TYPE" ); case set_: - return("SET_TYPE"); + return( "SET_TYPE" ); case list_: - return("LIST_TYPE"); + return( "LIST_TYPE" ); case entity_: - return("sdaiINSTANCE"); + return( "sdaiINSTANCE" ); case enumeration_: - return("sdaiENUMERATION"); + return( "sdaiENUMERATION" ); case select_: - return ("sdaiSELECT"); + return ( "sdaiSELECT" ); default: - return("UNKNOWN_TYPE"); + return( "UNKNOWN_TYPE" ); } } /** this actually gets you the name of the variable that will be generated to be a * TypeDescriptor or subtype of TypeDescriptor to represent Type t in the dictionary. */ -const char *TypeDescriptorName(Type t) -{ +const char * TypeDescriptorName( Type t ) { static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if(!parent) { - parent = TYPEget_body(t)->entity->superscope; + if( !parent ) { + parent = TYPEget_body( t )->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf(b, "%s::%s%s", SCHEMAget_name(parent), TYPEprefix(t), - TYPEget_name(t)); + sprintf( b, "%s::%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), + TYPEget_name( t ) ); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char *GetTypeDescriptorName(Type t) -{ - switch(TYPEget_body(t)->type) { +const char * GetTypeDescriptorName( Type t ) { + switch( TYPEget_body( t )->type ) { case aggregate_: return "AggrTypeDescriptor"; @@ -272,19 +262,18 @@ const char *GetTypeDescriptorName(Type t) case generic_: return "TypeDescriptor"; default: - fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } /* NOTREACHED */ return ""; } -int ENTITYhas_explicit_attributes(Entity e) -{ - Linked_List l = ENTITYget_attributes(e); +int ENTITYhas_explicit_attributes( Entity e ) { + Linked_List l = ENTITYget_attributes( e ); int cnt = 0; - LISTdo(l, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( l, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { ++cnt; } LISTod; @@ -292,22 +281,21 @@ int ENTITYhas_explicit_attributes(Entity e) } -Entity ENTITYput_superclass(Entity entity) -{ +Entity ENTITYput_superclass( Entity entity ) { #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes(entity); + Linked_List l = ENTITYget_supertypes( entity ); EntityTag tag; - if(! LISTempty(l)) { + if( ! LISTempty( l ) ) { Entity super = 0; - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List list = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { /* assign superclass to be the first one on the list of parents */ - super = (Entity)LISTpeek_first(list); + super = ( Entity )LISTpeek_first( list ); } } else { Entity ignore = 0; @@ -315,51 +303,49 @@ Entity ENTITYput_superclass(Entity entity) /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo(l, e, Entity) + LISTdo( l, e, Entity ) /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if((! super) || (! ENTITYhas_explicit_attributes(super))) { + if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if(ignore) { - fprintf(stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name(entity), ENTITYget_name(e)); + if( ignore ) { + fprintf( stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name( entity ), ENTITYget_name( e ) ); } LISTod; } - tag = (EntityTag) sc_malloc(sizeof(struct EntityTag_)); + tag = ( EntityTag ) sc_malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; - TYPEput_clientData(ENTITYget_type(entity), (ClientData) tag); + TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); return super; } return 0; } -Entity ENTITYget_superclass(Entity entity) -{ +Entity ENTITYget_superclass( Entity entity ) { EntityTag tag; - tag = (EntityTag) TYPEget_clientData(ENTITYget_type(entity)); - return (tag ? tag -> superclass : 0); + tag = ( EntityTag ) TYPEget_clientData( ENTITYget_type( entity ) ); + return ( tag ? tag -> superclass : 0 ); } -void ENTITYget_first_attribs(Entity entity, Linked_List result) -{ +void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo(ENTITYget_attributes(entity), attr, void *) - LISTadd_last(result, attr); + LISTdo( ENTITYget_attributes( entity ), attr, void * ) + LISTadd_last( result, attr ); LISTod; - supers = ENTITYget_supertypes(entity); - if(supers) { - ENTITYget_first_attribs((Entity)LISTget_first(supers), result); + supers = ENTITYget_supertypes( entity ); + if( supers ) { + ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); } } @@ -393,30 +379,28 @@ void ENTITYget_first_attribs(Entity entity, Linked_List result) ** if STEPattribute found with same name ** tell it to be * for reading and writing **/ -Variable VARis_type_shifter(Variable a) -{ - char *temp; - if(VARis_derived(a) || VARget_inverse(a)) { +Variable VARis_type_shifter( Variable a ) { + char * temp; + if( VARis_derived( a ) || VARget_inverse( a ) ) { return 0; } - temp = EXPRto_string(VARget_name(a)); - if(! strncmp(StrToLower(temp), "self\\", 5)) { + temp = EXPRto_string( VARget_name( a ) ); + if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - sc_free(temp); + sc_free( temp ); return a; } - sc_free(temp); + sc_free( temp ); return 0; } -Variable VARis_overrider(Entity e, Variable a) -{ +Variable VARis_overrider( Entity e, Variable a ) { Variable other; - char *tmp; - tmp = VARget_simple_name(a); - LISTdo(ENTITYget_supertypes(e), s, Entity) - if((other = ENTITYget_named_attribute(s, tmp)) - && other != a) { + char * tmp; + tmp = VARget_simple_name( a ); + LISTdo( ENTITYget_supertypes( e ), s, Entity ) + if( ( other = ENTITYget_named_attribute( s, tmp ) ) + && other != a ) { return other; } LISTod; @@ -426,16 +410,15 @@ Variable VARis_overrider(Entity e, Variable a) /** For a renamed type, returns the original (ancestor) type * from which t descends. Return NULL if t is top level. */ -Type TYPEget_ancestor(Type t) -{ +Type TYPEget_ancestor( Type t ) { Type i = t; - if(!TYPEget_head(i)) { + if( !TYPEget_head( i ) ) { return NULL; } - while(TYPEget_head(i)) { - i = TYPEget_head(i); + while( TYPEget_head( i ) ) { + i = TYPEget_head( i ); } return i; diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index fa001eefc..62d737aba 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -29,44 +29,43 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. static int type_count; /**< number each temporary type for same reason as \sa attr_count */ -extern char *non_unique_types_string(const Type type); +extern char * non_unique_types_string( const Type type ); -static void printEnumCreateHdr(FILE *, const Type); -static void printEnumCreateBody(FILE *, const Type); -static void printEnumAggrCrHdr(FILE *, const Type); -static void printEnumAggrCrBody(FILE *, const Type); +static void printEnumCreateHdr( FILE *, const Type ); +static void printEnumCreateBody( FILE *, const Type ); +static void printEnumAggrCrHdr( FILE *, const Type ); +static void printEnumAggrCrBody( FILE *, const Type ); -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); -int isMultiDimAggregateType(const Type t); +int isMultiDimAggregateType( const Type t ); -void Type_Description(const Type, char *); -void TypeBody_Description(TypeBody body, char *buf); +void Type_Description( const Type, char * ); +void TypeBody_Description( TypeBody body, char * buf ); /** write representation of expression to end of buf * * TODO: add buflen arg and check for overflow */ -void strcat_expr(Expression e, char *buf) -{ - if(e == LITERAL_INFINITY) { - strcat(buf, "?"); - } else if(e == LITERAL_PI) { - strcat(buf, "PI"); - } else if(e == LITERAL_E) { - strcat(buf, "E"); - } else if(e == LITERAL_ZERO) { - strcat(buf, "0"); - } else if(e == LITERAL_ONE) { - strcat(buf, "1"); - } else if(TYPEget_name(e)) { - strcat(buf, TYPEget_name(e)); - } else if(TYPEget_body(e->type)->type == integer_) { +void strcat_expr( Expression e, char * buf ) { + if( e == LITERAL_INFINITY ) { + strcat( buf, "?" ); + } else if( e == LITERAL_PI ) { + strcat( buf, "PI" ); + } else if( e == LITERAL_E ) { + strcat( buf, "E" ); + } else if( e == LITERAL_ZERO ) { + strcat( buf, "0" ); + } else if( e == LITERAL_ONE ) { + strcat( buf, "1" ); + } else if( TYPEget_name( e ) ) { + strcat( buf, TYPEget_name( e ) ); + } else if( TYPEget_body( e->type )->type == integer_ ) { char tmpbuf[30]; - sprintf(tmpbuf, "%d", e->u.integer); - strcat(buf, tmpbuf); + sprintf( tmpbuf, "%d", e->u.integer ); + strcat( buf, tmpbuf ); } else { - strcat(buf, "??"); + strcat( buf, "??" ); } } @@ -74,17 +73,16 @@ void strcat_expr(Expression e, char *buf) * * TODO: add buflen arg and check for overflow */ -void strcat_bounds(TypeBody b, char *buf) -{ - if(!b->upper) { +void strcat_bounds( TypeBody b, char * buf ) { + if( !b->upper ) { return; } - strcat(buf, " ["); - strcat_expr(b->lower, buf); - strcat(buf, ":"); - strcat_expr(b->upper, buf); - strcat(buf, "]"); + strcat( buf, " [" ); + strcat_expr( b->lower, buf ); + strcat( buf, ":" ); + strcat_expr( b->upper, buf ); + strcat( buf, "]" ); } /****************************************************************** @@ -102,30 +100,28 @@ void strcat_bounds(TypeBody b, char *buf) ** - Changed to match CD2 Part 23, 1/14/97 DAS ** Change Date: 5/22/91 CD ******************************************************************/ -const char *EnumCElementName(Type type, Expression expr) -{ +const char * EnumCElementName( Type type, Expression expr ) { static char buf [BUFSIZ]; - sprintf(buf, "%s__", - EnumName(TYPEget_name(type))); - strcat(buf, StrToLower(EXPget_name(expr))); + sprintf( buf, "%s__", + EnumName( TYPEget_name( type ) ) ); + strcat( buf, StrToLower( EXPget_name( expr ) ) ); return buf; } -char *CheckEnumSymbol(char *s) -{ +char * CheckEnumSymbol( char * s ) { static char b [BUFSIZ]; - if(strcmp(s, "sdaiTRUE") - && strcmp(s, "sdaiFALSE") - && strcmp(s, "sdaiUNKNOWN")) { + if( strcmp( s, "sdaiTRUE" ) + && strcmp( s, "sdaiFALSE" ) + && strcmp( s, "sdaiUNKNOWN" ) ) { /* if the symbol is not a reserved one */ - return (s); + return ( s ); } else { - strcpy(b, s); - strcat(b, "_"); - fprintf(stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __func__, s, b); - return (b); + strcpy( b, s ); + strcat( b, "_" ); + fprintf( stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b ); + return ( b ); } } @@ -133,16 +129,15 @@ char *CheckEnumSymbol(char *s) * return printable version of entire type definition * return it in static buffer */ -char *TypeDescription(const Type t) -{ +char * TypeDescription( const Type t ) { static char buf[6000]; buf[0] = '\0'; - if(TYPEget_head(t)) { - Type_Description(TYPEget_head(t), buf); + if( TYPEget_head( t ) ) { + Type_Description( TYPEget_head( t ), buf ); } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } /* should also print out where clause here */ @@ -155,222 +150,217 @@ char *TypeDescription(const Type t) ** Description: Writes enum type descriptors and classes. ** Change Date: ********************************************************************/ -void TYPEenum_inc_print(const Type type, FILE *inc) -{ +void TYPEenum_inc_print( const Type type, FILE * inc ) { Expression expr; char tdnm[BUFSIZ], enumAggrNm[BUFSIZ]; - const char *n; /* pointer to class name */ + const char * n; /* pointer to class name */ int cnt = 0; /* print c++ enumerated values for class */ - fprintf(inc, "enum %s {\n", EnumName(TYPEget_name(type))); + fprintf( inc, "enum %s {\n", EnumName( TYPEget_name( type ) ) ); - LISTdo_links(TYPEget_body(type)->list, link) + LISTdo_links( TYPEget_body( type )->list, link ) /* print the elements of the c++ enum type */ - expr = (Expression)link->data; - if(cnt != 0) { - fprintf(inc, ",\n"); + expr = ( Expression )link->data; + if( cnt != 0 ) { + fprintf( inc, ",\n" ); } ++cnt; - fprintf(inc, " %s", EnumCElementName(type, expr)); + fprintf( inc, " %s", EnumCElementName( type, expr ) ); LISTod - fprintf(inc, ",\n %s_unset\n};\n", EnumName(TYPEget_name(type))); + fprintf( inc, ",\n %s_unset\n};\n", EnumName( TYPEget_name( type ) ) ); /* print class for enumeration */ - n = TYPEget_ctype(type); - fprintf(inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n); + n = TYPEget_ctype( type ); + fprintf( inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n ); - fprintf(inc, " protected:\n EnumTypeDescriptor *type;\n\n"); + fprintf( inc, " protected:\n EnumTypeDescriptor *type;\n\n" ); /* constructors */ - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; - fprintf(inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm); - fprintf(inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" - " : type(et) { set_value (e); }\n", - n, EnumName(TYPEget_name(type)), tdnm); - fprintf(inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype(type)); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; + fprintf( inc, " public:\n %s (const char * n =0, Enum" + "TypeDescriptor *et =%s);\n", n, tdnm ); + fprintf( inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" + " : type(et) { set_value (e); }\n", + n, EnumName( TYPEget_name( type ) ), tdnm ); /* destructor */ - fprintf(inc, " ~%s () { }\n", n); + fprintf( inc, " ~%s () { }\n", n ); /* operator = */ - fprintf(inc, " %s& operator= (const %s& e)\n", - n, TYPEget_ctype(type)); - fprintf(inc, " { set_value (e); return *this; }\n"); + fprintf( inc, " %s& operator= (const %s& e)\n", + n, TYPEget_ctype( type ) ); + fprintf( inc, " { set_value (e); return *this; }\n" ); /* operator to cast to an enumerated type */ - fprintf(inc, " operator %s () const;\n", - EnumName(TYPEget_name(type))); + fprintf( inc, " operator %s () const;\n", + EnumName( TYPEget_name( type ) ) ); /* others */ - fprintf(inc, "\n inline virtual const char * Name () const\n"); - fprintf(inc, " { return type->Name(); }\n"); - fprintf(inc, " inline virtual int no_elements () const" - " { return %d; }\n", cnt); - fprintf(inc, " virtual const char * element_at (int n) const;\n"); + fprintf( inc, "\n inline virtual const char * Name () const\n" ); + fprintf( inc, " { return type->Name(); }\n" ); + fprintf( inc, " inline virtual int no_elements () const" + " { return %d; }\n", cnt ); + fprintf( inc, " virtual const char * element_at (int n) const;\n" ); /* end class definition */ - fprintf(inc, "};\n"); + fprintf( inc, "};\n" ); - fprintf(inc, "\ntypedef %s * %s_ptr;\n", n, n); - fprintf(inc, "\ntypedef const %s * %s_ptr_c;\n", n, n); + fprintf( inc, "\ntypedef %s * %s_ptr;\n", n, n ); + fprintf( inc, "\ntypedef const %s * %s_ptr_c;\n", n, n ); /* Print ObjectStore Access Hook function */ - printEnumCreateHdr(inc, type); + printEnumCreateHdr( inc, type ); /* DAS brandnew above */ /* print things for aggregate class */ - sprintf(enumAggrNm, "%s_agg", n); + sprintf( enumAggrNm, "%s_agg", n ); - fprintf(inc, "\nclass %s_agg : public EnumAggregate {\n", n); + fprintf( inc, "\nclass %s_agg : public EnumAggregate {\n", n ); - fprintf(inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n"); - fprintf(inc, " public:\n"); - fprintf(inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm); - fprintf(inc, " virtual ~%s_agg();\n", n); - fprintf(inc, " virtual SingleLinkNode * NewNode()\n"); - fprintf(inc, " { return new EnumNode (new %s( \"\", enum_type )); }" - "\n", n); + fprintf( inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n" ); + fprintf( inc, " public:\n" ); + fprintf( inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm ); + fprintf( inc, " virtual ~%s_agg();\n", n ); + fprintf( inc, " virtual SingleLinkNode * NewNode()\n" ); + fprintf( inc, " { return new EnumNode (new %s( \"\", enum_type )); }" + "\n", n ); - fprintf(inc, "};\n"); + fprintf( inc, "};\n" ); - fprintf(inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n); - fprintf(inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n); + fprintf( inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n ); + fprintf( inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n ); /* DAS brandnew below */ /* DAS creation function for enum aggregate class */ - printEnumAggrCrHdr(inc, type); + printEnumAggrCrHdr( inc, type ); /* DAS brandnew above */ } -void TYPEenum_lib_print(const Type type, FILE *f) -{ +void TYPEenum_lib_print( const Type type, FILE * f ) { DictionaryEntry de; Expression expr; - const char *n; /* pointer to class name */ + const char * n; /* pointer to class name */ char c_enum_ele [BUFSIZ]; - n = TYPEget_ctype(type); + n = TYPEget_ctype( type ); /* set up the dictionary info */ - fprintf(f, "const char *\n%s::element_at (int n) const {\n", n); - fprintf(f, " switch (n) {\n"); - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); - c_enum_ele[BUFSIZ - 1] = '\0'; - fprintf(f, " case %s: return \"%s\";\n", - c_enum_ele, - StrToUpper(EXPget_name(expr))); + fprintf( f, "const char *\n%s::element_at (int n) const {\n", n ); + fprintf( f, " switch (n) {\n" ); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); + c_enum_ele[BUFSIZ-1] = '\0'; + fprintf( f, " case %s: return \"%s\";\n", + c_enum_ele, + StrToUpper( EXPget_name( expr ) ) ); } - fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); - fprintf(f, " default : return \"UNSET\";\n }\n}\n"); + fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); + fprintf( f, " default : return \"UNSET\";\n }\n}\n" ); /* constructors */ /* construct with character string */ - fprintf(f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" - " : type(et)\n{\n", n, n); - fprintf(f, " set_value (n);\n}\n"); + fprintf( f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" + " : type(et)\n{\n", n, n ); + fprintf( f, " set_value (n);\n}\n" ); /* cast operator to an enumerated type */ - fprintf(f, "\n%s::operator %s () const {\n", n, - EnumName(TYPEget_name(type))); - fprintf(f, " switch (v) {\n"); - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); - fprintf(f, " case %s : ", c_enum_ele); - fprintf(f, "return %s;\n", c_enum_ele); + fprintf( f, "\n%s::operator %s () const {\n", n, + EnumName( TYPEget_name( type ) ) ); + fprintf( f, " switch (v) {\n" ); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); + fprintf( f, " case %s : ", c_enum_ele ); + fprintf( f, "return %s;\n", c_enum_ele ); } /* print the last case with the default so sun c++ doesn't complain */ - fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); - fprintf(f, " default : return %s_unset;\n }\n}\n", EnumName(TYPEget_name(type))); + fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); + fprintf( f, " default : return %s_unset;\n }\n}\n", EnumName( TYPEget_name( type ) ) ); - printEnumCreateBody(f, type); + printEnumCreateBody( f, type ); /* print the enum aggregate functions */ - fprintf(f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n); - fprintf(f, " : enum_type(et)\n{\n}\n\n"); - fprintf(f, "%s_agg::~%s_agg()\n{\n}\n", n, n); + fprintf( f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n ); + fprintf( f, " : enum_type(et)\n{\n}\n\n" ); + fprintf( f, "%s_agg::~%s_agg()\n{\n}\n", n, n ); - printEnumAggrCrBody(f, type); + printEnumAggrCrBody( f, type ); } -void TYPEPrint_h(const Type type, FILE *file) -{ - DEBUG("Entering TYPEPrint_h for %s\n", TYPEget_ctype(type)); +void TYPEPrint_h( const Type type, FILE * file ) { + DEBUG( "Entering TYPEPrint_h for %s\n", TYPEget_ctype( type ) ); - if(TYPEis_enumeration(type)) { - TYPEenum_inc_print(type, file); - } else if(TYPEis_select(type)) { - TYPEselect_inc_print(type, file); + if ( TYPEis_enumeration( type ) ) { + TYPEenum_inc_print( type, file ); + } else if ( TYPEis_select( type ) ) { + TYPEselect_inc_print( type, file ); } - fprintf(file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype(type)); + fprintf( file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype( type ) ); - DEBUG("DONE TYPEPrint_h\n"); + DEBUG( "DONE TYPEPrint_h\n" ); } -void TYPEPrint_cc(const Type type, const filenames_t *names, FILE *hdr, FILE *impl, Schema schema) -{ - DEBUG("Entering TYPEPrint_cc for %s\n", names->impl); +void TYPEPrint_cc( const Type type, const filenames_t * names, FILE * hdr, FILE * impl, Schema schema ) { + DEBUG( "Entering TYPEPrint_cc for %s\n", names->impl ); - fprintf(impl, "#include \"schema.h\"\n"); - fprintf(impl, "#include \"sc_memmgr.h\"\n"); - fprintf(impl, "#include \"%s\"\n\n", names->header); + fprintf( impl, "#include \"schema.h\"\n" ); + fprintf( impl, "#include \"sc_memmgr.h\"\n" ); + fprintf( impl, "#include \"%s\"\n\n", names->header ); - if(TYPEis_enumeration(type)) { - TYPEenum_lib_print(type, impl); - } else if(TYPEis_select(type)) { - TYPEselect_lib_print(type, impl); + if ( TYPEis_enumeration( type ) ) { + TYPEenum_lib_print( type, impl ); + } else if ( TYPEis_select( type ) ) { + TYPEselect_lib_print( type, impl ); } - fprintf(impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype(type)); - fprintf(impl, " std::string str;\n"); + fprintf( impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype( type ) ); + fprintf( impl, " std::string str;\n" ); /* moved from SCOPEPrint in classes_wrapper */ - TYPEprint_new(type, impl, schema, true); - TYPEprint_init(type, hdr, impl, schema); - fprintf(impl, "}\n\n"); + TYPEprint_new( type, impl, schema, true ); + TYPEprint_init( type, hdr, impl, schema ); + fprintf( impl, "}\n\n" ); - DEBUG("DONE TYPEPrint_cc\n"); + DEBUG( "DONE TYPEPrint_cc\n" ); } -void TYPEPrint(const Type type, FILES *files, Schema schema) -{ - FILE *hdr, * impl; - filenames_t names = getTypeFilenames(type); +void TYPEPrint( const Type type, FILES *files, Schema schema ) { + FILE * hdr, * impl; + filenames_t names = getTypeFilenames( type ); - fprintf(files->inc, "#include \"%s\"\n", names.header); + fprintf( files->inc, "#include \"%s\"\n", names.header ); - fprintf(files->init, " init_%s( reg );\n", TYPEget_ctype(type)); + fprintf( files->init, " init_%s( reg );\n", TYPEget_ctype( type ) ); - if(mkDirIfNone("type") == -1) { - fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror(0); + if( mkDirIfNone( "type" ) == -1 ) { + fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror( 0 ); abort(); } - hdr = FILEcreate(names.header); - impl = FILEcreate(names.impl); - assert(hdr && impl && "error creating files"); - fprintf(files->unity.type.hdr, "#include \"%s\"\n", names.header); - fprintf(files->unity.type.impl, "#include \"%s\"\n", names.impl); + hdr = FILEcreate( names.header ); + impl = FILEcreate( names.impl ); + assert( hdr && impl && "error creating files" ); + fprintf( files->unity.type.hdr, "#include \"%s\"\n", names.header ); + fprintf( files->unity.type.impl, "#include \"%s\"\n", names.impl ); - TYPEPrint_h(type, hdr); - TYPEPrint_cc(type, &names, hdr, impl, schema); + TYPEPrint_h( type, hdr ); + TYPEPrint_cc( type, &names, hdr, impl, schema ); - FILEclose(hdr); - FILEclose(impl); + FILEclose( hdr ); + FILEclose( impl ); } /** @@ -381,45 +371,41 @@ void TYPEPrint(const Type type, FILES *files, Schema schema) * NOTE - "Print ObjectStore Access Hook function" comment seen at one of * the calls seems to imply it's ObjectStore specific... */ -static void printEnumCreateHdr(FILE *inc, const Type type) -{ - const char *nm = TYPEget_ctype(type); +static void printEnumCreateHdr( FILE * inc, const Type type ) { + const char * nm = TYPEget_ctype( type ); - fprintf(inc, " SDAI_Enum * create_%s();\n", nm); + fprintf( inc, " SDAI_Enum * create_%s();\n", nm ); } /** See header comment above by printEnumCreateHdr. */ -static void printEnumCreateBody(FILE *lib, const Type type) -{ - const char *nm = TYPEget_ctype(type); +static void printEnumCreateBody( FILE * lib, const Type type ) { + const char * nm = TYPEget_ctype( type ); char tdnm[BUFSIZ]; - tdnm[BUFSIZ - 1] = '\0'; + tdnm[BUFSIZ-1] = '\0'; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - fprintf(lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm); - fprintf(lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm); + fprintf( lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm ); + fprintf( lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm ); } /** Similar to printEnumCreateHdr above for the enum aggregate. */ -static void printEnumAggrCrHdr(FILE *inc, const Type type) -{ - const char *n = TYPEget_ctype(type); +static void printEnumAggrCrHdr( FILE * inc, const Type type ) { + const char * n = TYPEget_ctype( type ); /* const char *n = ClassName( TYPEget_name(type) ));*/ - fprintf(inc, " STEPaggregate * create_%s_agg ();\n", n); + fprintf( inc, " STEPaggregate * create_%s_agg ();\n", n ); } -static void printEnumAggrCrBody(FILE *lib, const Type type) -{ - const char *n = TYPEget_ctype(type); +static void printEnumAggrCrBody( FILE * lib, const Type type ) { + const char * n = TYPEget_ctype( type ); char tdnm[BUFSIZ]; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - fprintf(lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n); - fprintf(lib, " return new %s_agg( %s );\n}\n", n, tdnm); + fprintf( lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n ); + fprintf( lib, " return new %s_agg( %s );\n}\n", n, tdnm ); } /** ************************************************************************ @@ -437,14 +423,13 @@ static void printEnumAggrCrBody(FILE *lib, const Type type) ** Status: 16-Mar-1993 kcm; updated 04-Feb-1997 dar ** Dec 2011 - MAP - remove goto **************************************************************************/ -void TYPEprint_typedefs(Type t, FILE *classes) -{ +void TYPEprint_typedefs( Type t, FILE * classes ) { char nm [BUFSIZ]; Type i; bool aggrNot1d = true; /* added so I can get rid of a goto */ /* Print the typedef statement (poss also a forward class def: */ - if(TYPEis_enumeration(t)) { + if( TYPEis_enumeration( t ) ) { /* For enums and sels (else clause below), we need forward decl's so that if we later come across a type which is an aggregate of one of them, we'll be able to process it. For selects, we also need a decl @@ -453,32 +438,32 @@ void TYPEprint_typedefs(Type t, FILE *classes) same is basically true for the select, but a sel containing an ent containing a sel needs the forward decl (trust me ;-) ). */ - if(!TYPEget_head(t)) { + if( !TYPEget_head( t ) ) { /* Only print this enum if it is an actual type and not a redefi- nition of another enum. (Those are printed at the end of the classes file - after all the actual enum's. They must be printed last since they depend on the others.) */ - strncpy(nm, TYPEget_ctype(t), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "class %s_agg;\n", nm); + strncpy( nm, TYPEget_ctype( t ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "class %s_agg;\n", nm ); } - } else if(TYPEis_select(t)) { - if(!TYPEget_head(t)) { + } else if( TYPEis_select( t ) ) { + if( !TYPEget_head( t ) ) { /* Same comment as above. */ - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "class %s;\n", nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "class %s_agg;\n", nm); - fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "class %s;\n", nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "class %s_agg;\n", nm ); + fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); } } else { - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* One exceptional case - a 1d aggregate of an enum or select. We must wait till the enum/sel itself has been processed. To ensure this, we process all such 1d aggrs in a special @@ -489,26 +474,26 @@ void TYPEprint_typedefs(Type t, FILE *classes) aggrNot1d = false; } } - if(aggrNot1d) { + if( aggrNot1d ) { /* At this point, we'll print typedefs for types which are redefined fundamental types and their aggregates, and for 2D aggregates(aggre- gates of aggregates) of enum's and selects. */ - strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); - if(TYPEis_aggregate(t)) { - fprintf(classes, "typedef %s * %sH;\n", nm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "typedef %s_ptr %s_var;\n", nm, nm); + strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); + if( TYPEis_aggregate( t ) ) { + fprintf( classes, "typedef %s * %sH;\n", nm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "typedef %s_ptr %s_var;\n", nm, nm ); } } } /* Print the extern statement: */ - strncpy(nm, TYPEtd_name(t), BUFSIZ); - fprintf(classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName(t), nm); + strncpy( nm, TYPEtd_name( t ), BUFSIZ ); + fprintf( classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName( t ), nm ); } /** ** @@ -520,92 +505,90 @@ void TYPEprint_typedefs(Type t, FILE *classes) initialize it in the .init.cc file (DAR - all initialization done in fn TYPEprint_init() (below) which is done in exp2cxx's 1st pass only.) *****/ -void TYPEprint_descriptions(const Type type, FILES *files, Schema schema) -{ +void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], nm [BUFSIZ]; Type i; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; /* define type descriptor pointer */ /* in source - declare the real definition of the pointer */ /* i.e. in the .cc file */ - fprintf(files -> lib, "%s *%s;\n", GetTypeDescriptorName(type), tdnm); + fprintf( files -> lib, "%s *%s;\n", GetTypeDescriptorName( type ), tdnm ); - if(isAggregateType(type)) { - const char *ctype = TYPEget_ctype(type); + if( isAggregateType( type ) ) { + const char * ctype = TYPEget_ctype( type ); - fprintf(files->inc, "STEPaggregate * create_%s ();\n\n", - ClassName(TYPEget_name(type))); + fprintf( files->inc, "STEPaggregate * create_%s ();\n\n", + ClassName( TYPEget_name( type ) ) ); - fprintf(files->lib, - "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", - ClassName(TYPEget_name(type)), ctype); + fprintf( files->lib, + "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", + ClassName( TYPEget_name( type ) ), ctype ); /* this function is assigned to the aggrCreator var in TYPEprint_new */ } - if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { + if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { /* If we're a renamed enum type, just print a few typedef's to the * original and some specialized create functions: */ - strncpy(base, EnumName(TYPEget_name(i)), BUFSIZ); - strncpy(nm, EnumName(TYPEget_name(type)), BUFSIZ); - fprintf(files->inc, "typedef %s %s;\n", base, nm); - strncpy(base, TYPEget_ctype(i), BUFSIZ); - strncpy(nm, TYPEget_ctype(type), BUFSIZ); - fprintf(files->inc, "typedef %s %s;\n", base, nm); - printEnumCreateHdr(files->inc, type); - printEnumCreateBody(files->lib, type); - fprintf(files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); - printEnumAggrCrHdr(files->inc, type); - printEnumAggrCrBody(files->lib, type); + strncpy( base, EnumName( TYPEget_name( i ) ), BUFSIZ ); + strncpy( nm, EnumName( TYPEget_name( type ) ), BUFSIZ ); + fprintf( files->inc, "typedef %s %s;\n", base, nm ); + strncpy( base, TYPEget_ctype( i ), BUFSIZ ); + strncpy( nm, TYPEget_ctype( type ), BUFSIZ ); + fprintf( files->inc, "typedef %s %s;\n", base, nm ); + printEnumCreateHdr( files->inc, type ); + printEnumCreateBody( files->lib, type ); + fprintf( files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); + printEnumAggrCrHdr( files->inc, type ); + printEnumAggrCrBody( files->lib, type ); return; } - if(!TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - if(TYPEis_enumeration(type)) { - TYPEPrint(type, files, schema); + if( !TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + if( TYPEis_enumeration( type ) ) { + TYPEPrint( type, files, schema ); } /* so we don't do anything for non-enums??? */ } else { - TYPEprint_new(type, files->create, schema, false); - TYPEprint_init(type, files->inc, files->init, schema); + TYPEprint_new( type, files->create, schema, false ); + TYPEprint_init( type, files->inc, files->init, schema ); } } -void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema) -{ +void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ) { char tdnm [BUFSIZ]; char typename_buf[MAX_LEN]; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - if(isAggregateType(type)) { - AGGRprint_init(header, impl, type, tdnm, type->symbol.name); + if( isAggregateType( type ) ) { + AGGRprint_init( header, impl, type, tdnm, type->symbol.name ); } /* fill in the TD's values in the SchemaInit function (it is already declared with basic values) */ - if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - fprintf(impl, " %s->ReferentType(%s);\n", tdnm, typename_buf); + if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + fprintf( impl, " %s->ReferentType(%s);\n", tdnm, typename_buf ); } else { - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case aggregate_: /* aggregate_ should not happen? DAS */ case array_: case bag_: case set_: case list_: { - if(isMultiDimAggregateType(type)) { - print_typechain(header, impl, TYPEget_body(type)->base, - typename_buf, schema, type->symbol.name); - fprintf(impl, " %s->ReferentType(%s);\n", tdnm, - typename_buf); + if( isMultiDimAggregateType( type ) ) { + print_typechain( header, impl, TYPEget_body( type )->base, + typename_buf, schema, type->symbol.name ); + fprintf( impl, " %s->ReferentType(%s);\n", tdnm, + typename_buf ); } break; } @@ -616,73 +599,71 @@ void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema) /* DAR - moved fn call below from TYPEselect_print to here to put all init ** info together. */ - if(TYPEis_select(type)) { - TYPEselect_init_print(type, impl); + if( TYPEis_select( type ) ) { + TYPEselect_init_print( type, impl ); } #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the type into the schema descriptor */ - fprintf(impl, - " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", - SCHEMAget_name(schema), tdnm); + fprintf( impl, + " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", + SCHEMAget_name( schema ), tdnm ); #endif /* insert into type dictionary */ - fprintf(impl, " reg.AddType (*%s);\n", tdnm); + fprintf( impl, " reg.AddType (*%s);\n", tdnm ); } /** print name, fundamental type, and description initialization function calls */ -void TYPEprint_nm_ft_desc(Schema schema, const Type type, FILE *f, char *endChars) -{ - fprintf(f, " \"%s\", // Name\n", PrettyTmpName(TYPEget_name(type))); - fprintf(f, " %s, // FundamentalType\n", FundamentalType(type, 1)); - fprintf(f, " %s::schema, // Originating Schema\n", SCHEMAget_name(schema)); - fprintf(f, " \"%s\"%s // Description\n", TypeDescription(type), endChars); +void TYPEprint_nm_ft_desc( Schema schema, const Type type, FILE * f, char * endChars ) { + fprintf( f, " \"%s\", // Name\n", PrettyTmpName( TYPEget_name( type ) ) ); + fprintf( f, " %s, // FundamentalType\n", FundamentalType( type, 1 ) ); + fprintf( f, " %s::schema, // Originating Schema\n", SCHEMAget_name( schema ) ); + fprintf( f, " \"%s\"%s // Description\n", TypeDescription( type ), endChars ); } /** new space for a variable of type TypeDescriptor (or subtype). This * function is called for Types that have an Express name. */ -void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) -{ - Type tmpType = TYPEget_head(type); +void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) { + Type tmpType = TYPEget_head( type ); Type bodyType = tmpType; /* define type definition */ /* in source - the real definition of the TypeDescriptor */ - if(TYPEis_select(type)) { - char *temp; - temp = non_unique_types_string(type); - fprintf(create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name(type), temp); - sc_free(temp); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (SelectCreator) create_%s); // Creator function\n", SelectName(TYPEget_name(type))); + if( TYPEis_select( type ) ) { + char * temp; + temp = non_unique_types_string( type ); + fprintf( create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name( type ), temp ); + sc_free( temp ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (SelectCreator) create_%s); // Creator function\n", SelectName( TYPEget_name( type ) ) ); } else { - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case boolean_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (EnumCreator) create_BOOLEAN); // Creator function\n"); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (EnumCreator) create_BOOLEAN); // Creator function\n" ); break; case logical_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (EnumCreator) create_LOGICAL); // Creator function\n"); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (EnumCreator) create_LOGICAL); // Creator function\n" ); break; case enumeration_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); /* get the type name of the underlying type - it is the type that needs to get created */ - tmpType = TYPEget_head(type); - if(tmpType) { + tmpType = TYPEget_head( type ); + if( tmpType ) { bodyType = tmpType; - while(tmpType) { + while( tmpType ) { bodyType = tmpType; - tmpType = TYPEget_head(tmpType); + tmpType = TYPEget_head( tmpType ); } - fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(bodyType)); + fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( bodyType ) ); } else { - fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(type)); + fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( type ) ); } break; case aggregate_: @@ -690,20 +671,20 @@ void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) case bag_: case set_: case list_: - fprintf(create, "\n %s = new %s (\n", TYPEtd_name(type), GetTypeDescriptorName(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName(TYPEget_name(type))); + fprintf( create, "\n %s = new %s (\n", TYPEtd_name( type ), GetTypeDescriptorName( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName( TYPEget_name( type ) ) ); break; default: - fprintf(create, " %s = new TypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ");"); + fprintf( create, " %s = new TypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, ");" ); break; } } /* add the type to the Schema dictionary entry */ - fprintf(create, " %s::schema->AddType(%s);\n", SCHEMAget_name(schema), TYPEtd_name(type)); + fprintf( create, " %s::schema->AddType(%s);\n", SCHEMAget_name( schema ), TYPEtd_name( type ) ); - WHEREprint(TYPEtd_name(type), type->where, create, 0, needWR); + WHEREprint( TYPEtd_name( type ), type->where, create, 0, needWR ); } /** Get the TypeDescriptor variable name that t's TypeDescriptor references (if @@ -725,23 +706,22 @@ void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) Nov 2011 - MAP - modified to insert scope operator into variable name. Reason: use of namespace for global variables */ -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) -{ +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { /* It looks like TYPEget_head(t) is true when processing a type that refers to another type. e.g. when processing "name" in: TYPE name = label; ENDTYPE; TYPE label = STRING; ENDTYPE; DAS */ - if(TYPEget_head(t)) { + if( TYPEget_head( t ) ) { /* this means that it is defined in an Express TYPE stmt and it refers to another Express TYPE stmt */ /* it would be a reference_ type */ /* a TypeDescriptor of the form t_ */ - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_head(t)->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_head(t))); + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_head( t )->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_head( t ) ) ); return 1; } else { - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: case real_: case boolean_: @@ -751,7 +731,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) case number_: /* one of the SCL builtin TypeDescriptors of the form t_STRING_TYPE, or t_REAL_TYPE */ - sprintf(buf, "%s%s", TD_PREFIX, FundamentalType(t, 0)); + sprintf( buf, "%s%s", TD_PREFIX, FundamentalType( t, 0 ) ); return 1; break; @@ -762,7 +742,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) break; case entity_: - sprintf(buf, "%s", TYPEtd_name(t)); + sprintf( buf, "%s", TYPEtd_name( t ) ); /* following assumes we are not in a nested entity */ /* otherwise we should search upward for schema */ return 1; @@ -776,11 +756,11 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) /* referent TypeDescriptor will be the one for the element unless it is a multidimensional aggregate then return 0 */ - if(isMultiDimAggregateType(t)) { - if(TYPEget_name(TYPEget_body(t)->base)) { - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_body(t)->base->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); + if( isMultiDimAggregateType( t ) ) { + if( TYPEget_name( TYPEget_body( t )->base ) ) { + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_body( t )->base->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); return 1; } @@ -792,22 +772,22 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) for element */ /* being an aggregate implies that base below is not 0 */ - if(TYPEget_body(TYPEget_body(t)->base)->type == enumeration_ || - TYPEget_body(TYPEget_body(t)->base)->type == select_) { + if( TYPEget_body( TYPEget_body( t )->base )->type == enumeration_ || + TYPEget_body( TYPEget_body( t )->base )->type == select_ ) { - sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); + sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); return 1; - } else if(TYPEget_name(TYPEget_body(t)->base)) { - if(TYPEget_body(TYPEget_body(t)->base)->type == entity_) { - sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); + } else if( TYPEget_name( TYPEget_body( t )->base ) ) { + if( TYPEget_body( TYPEget_body( t )->base )->type == entity_ ) { + sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); return 1; } - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_body(t)->base->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_body( t )->base->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); return 1; } - return TYPEget_RefTypeVarNm(TYPEget_body(t)->base, buf, schema); + return TYPEget_RefTypeVarNm( TYPEget_body( t )->base, buf, schema ); } break; default: @@ -845,284 +825,277 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) that can be referenced to refer to the type that was created for Type t. */ -void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name) -{ +void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ) { /* if we've been called, current type has no name */ /* nor is it a built-in type */ /* the type_count variable is there for debugging purposes */ - const char *ctype = TYPEget_ctype(t); + const char * ctype = TYPEget_ctype( t ); int count = type_count++; char name_buf[MAX_LEN]; int s; - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case aggregate_: case array_: case bag_: case set_: case list_: /* create a new TypeDescriptor variable, e.g. t1, and new space for it */ - fprintf(impl, " %s * %s%d = new %s;\n", - GetTypeDescriptorName(t), TD_PREFIX, count, - GetTypeDescriptorName(t)); + fprintf( impl, " %s * %s%d = new %s;\n", + GetTypeDescriptorName( t ), TD_PREFIX, count, + GetTypeDescriptorName( t ) ); - fprintf(impl, - " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", - TD_PREFIX, count, ctype, " // Creator function\n"); + fprintf( impl, + " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", + TD_PREFIX, count, ctype, " // Creator function\n" ); - s = sprintf(name_buf, "%s%d", TD_PREFIX, count); - assert((s > 0) && (s < MAX_LEN)); - AGGRprint_init(header, impl, t, name_buf, type_name); + s = sprintf( name_buf, "%s%d", TD_PREFIX, count ); + assert( ( s > 0 ) && ( s < MAX_LEN ) ); + AGGRprint_init( header, impl, t, name_buf, type_name ); break; default: /* this should not happen since only aggregates are allowed to not have a name. This funct should only be called for aggrs without names. */ - fprintf(impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", - TD_PREFIX, count); + fprintf( impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", + TD_PREFIX, count ); } /* there is no name so name doesn't need to be initialized */ - fprintf(impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, - FundamentalType(t, 1)); - fprintf(impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, - TypeDescription(t)); + fprintf( impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, + FundamentalType( t, 1 ) ); + fprintf( impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, + TypeDescription( t ) ); /* DAS ORIG SCHEMA FIX */ - fprintf(impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name(schema)); + fprintf( impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name( schema ) ); - if(TYPEget_RefTypeVarNm(t, name_buf, schema)) { - fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf); + if( TYPEget_RefTypeVarNm( t, name_buf, schema ) ) { + fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf ); } else { Type base = 0; /* no name, recurse */ char callee_buffer[MAX_LEN]; - if(TYPEget_body(t)) { - base = TYPEget_body(t)->base; + if( TYPEget_body( t ) ) { + base = TYPEget_body( t )->base; } - print_typechain(header, impl, base, callee_buffer, schema, type_name); - fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer); + print_typechain( header, impl, base, callee_buffer, schema, type_name ); + fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer ); } - sprintf(buf, "%s%d", TD_PREFIX, count); + sprintf( buf, "%s%d", TD_PREFIX, count ); /* Types */ - fprintf(impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name(schema), TD_PREFIX, count); + fprintf( impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name( schema ), TD_PREFIX, count ); } /** return 1 if it is a multidimensional aggregate at the level passed in otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ -int isMultiDimAggregateType(const Type t) -{ - if(TYPEget_body(t)->base) - if(isAggregateType(TYPEget_body(t)->base)) { +int isMultiDimAggregateType( const Type t ) { + if( TYPEget_body( t )->base ) + if( isAggregateType( TYPEget_body( t )->base ) ) { return 1; } return 0; } -void Type_Description(const Type t, char *buf) -{ - if(TYPEget_name(t)) { - strcat(buf, " "); - strcat(buf, TYPEget_name(t)); +void Type_Description( const Type t, char * buf ) { + if( TYPEget_name( t ) ) { + strcat( buf, " " ); + strcat( buf, TYPEget_name( t ) ); } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } } -void TypeBody_Description(TypeBody body, char *buf) -{ - char *s; +void TypeBody_Description( TypeBody body, char * buf ) { + char * s; - switch(body->type) { + switch( body->type ) { case integer_: - strcat(buf, " INTEGER"); + strcat( buf, " INTEGER" ); break; case real_: - strcat(buf, " REAL"); + strcat( buf, " REAL" ); break; case string_: - strcat(buf, " STRING"); + strcat( buf, " STRING" ); break; case binary_: - strcat(buf, " BINARY"); + strcat( buf, " BINARY" ); break; case boolean_: - strcat(buf, " BOOLEAN"); + strcat( buf, " BOOLEAN" ); break; case logical_: - strcat(buf, " LOGICAL"); + strcat( buf, " LOGICAL" ); break; case number_: - strcat(buf, " NUMBER"); + strcat( buf, " NUMBER" ); break; case entity_: - strcat(buf, " "); - strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); + strcat( buf, " " ); + strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(body->type) { - /* ignore the aggregate bounds for now */ + switch( body->type ) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat(buf, " AGGREGATE OF"); + strcat( buf, " AGGREGATE OF" ); break; case array_: - strcat(buf, " ARRAY"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.optional) { - strcat(buf, " OPTIONAL"); + strcat( buf, " ARRAY" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.optional ) { + strcat( buf, " OPTIONAL" ); } - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; case bag_: - strcat(buf, " BAG"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " BAG" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case set_: - strcat(buf, " SET"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " SET" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case list_: - strcat(buf, " LIST"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + strcat( buf, " LIST" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); abort(); } - Type_Description(body->base, buf); + Type_Description( body->base, buf ); break; case enumeration_: - strcat(buf, " ENUMERATION of ("); - LISTdo(body->list, e, Expression) - strcat(buf, ENUMget_name(e)); - strcat(buf, ", "); + strcat( buf, " ENUMERATION of (" ); + LISTdo( body->list, e, Expression ) + strcat( buf, ENUMget_name( e ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; case select_: - strcat(buf, " SELECT ("); - LISTdo(body->list, t, Type) - strcat(buf, PrettyTmpName(TYPEget_name(t))); - strcat(buf, ", "); + strcat( buf, " SELECT (" ); + LISTdo( body->list, t, Type ) + strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; default: - strcat(buf, " UNKNOWN"); + strcat( buf, " UNKNOWN" ); } - if(body->precision) { - strcat(buf, " ("); - strcat_expr(body->precision, buf); - strcat(buf, ")"); + if( body->precision ) { + strcat( buf, " (" ); + strcat_expr( body->precision, buf ); + strcat( buf, ")" ); } - if(body->flags.fixed) { - strcat(buf, " FIXED"); + if( body->flags.fixed ) { + strcat( buf, " FIXED" ); } } -const char *IdlEntityTypeName(Type t) -{ +const char * IdlEntityTypeName( Type t ) { static char name [BUFSIZ]; - strcpy(name, TYPE_PREFIX); - if(TYPEget_name(t)) { - strcpy(name, FirstToUpper(TYPEget_name(t))); + strcpy( name, TYPE_PREFIX ); + if( TYPEget_name( t ) ) { + strcpy( name, FirstToUpper( TYPEget_name( t ) ) ); } else { - return TYPEget_ctype(t); + return TYPEget_ctype( t ); } return name; } -const char *GetAggrElemType(const Type type) -{ +const char * GetAggrElemType( const Type type ) { Class_Of_Type class; Type bt; static char retval [BUFSIZ]; - if(isAggregateType(type)) { - bt = TYPEget_nonaggregate_base_type(type); - if(isAggregateType(bt)) { - strcpy(retval, "ERROR_aggr_of_aggr"); + if( isAggregateType( type ) ) { + bt = TYPEget_nonaggregate_base_type( type ); + if( isAggregateType( bt ) ) { + strcpy( retval, "ERROR_aggr_of_aggr" ); } - class = TYPEget_type(bt); + class = TYPEget_type( bt ); /* case TYPE_INTEGER: */ - if(class == integer_) { - strcpy(retval, "long"); + if( class == integer_ ) { + strcpy( retval, "long" ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - strcpy(retval, "double"); + if( ( class == number_ ) || ( class == real_ ) ) { + strcpy( retval, "double" ); } /* case TYPE_ENTITY: */ - if(class == entity_) { - strcpy(retval, IdlEntityTypeName(bt)); + if( class == entity_ ) { + strcpy( retval, IdlEntityTypeName( bt ) ); } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if((class == enumeration_) - || (class == select_)) { - strcpy(retval, TYPEget_ctype(bt)); + if( ( class == enumeration_ ) + || ( class == select_ ) ) { + strcpy( retval, TYPEget_ctype( bt ) ); } /* case TYPE_LOGICAL: */ - if(class == logical_) { - strcpy(retval, "Logical"); + if( class == logical_ ) { + strcpy( retval, "Logical" ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - strcpy(retval, "Bool"); + if( class == boolean_ ) { + strcpy( retval, "Bool" ); } /* case TYPE_STRING: */ - if(class == string_) { - strcpy(retval, "string"); + if( class == string_ ) { + strcpy( retval, "string" ); } /* case TYPE_BINARY: */ - if(class == binary_) { - strcpy(retval, "binary"); + if( class == binary_ ) { + strcpy( retval, "binary" ); } } return retval; } -const char *TYPEget_idl_type(const Type t) -{ +const char * TYPEget_idl_type( const Type t ) { Class_Of_Type class; static char retval [BUFSIZ]; @@ -1133,86 +1106,86 @@ const char *TYPEget_idl_type(const Type t) case TYPE_SET: */ - if(isAggregateType(t)) { - strcpy(retval, GetAggrElemType(t)); + if( isAggregateType( t ) ) { + strcpy( retval, GetAggrElemType( t ) ); /* case TYPE_ARRAY: */ - if(TYPEget_type(t) == array_) { - strcat(retval, "__array"); + if( TYPEget_type( t ) == array_ ) { + strcat( retval, "__array" ); } /* case TYPE_LIST: */ - if(TYPEget_type(t) == list_) { - strcat(retval, "__list"); + if( TYPEget_type( t ) == list_ ) { + strcat( retval, "__list" ); } /* case TYPE_SET: */ - if(TYPEget_type(t) == set_) { - strcat(retval, "__set"); + if( TYPEget_type( t ) == set_ ) { + strcat( retval, "__set" ); } /* case TYPE_BAG: */ - if(TYPEget_type(t) == bag_) { - strcat(retval, "__bag"); + if( TYPEget_type( t ) == bag_ ) { + strcat( retval, "__bag" ); } return retval; } /* the rest is for things that are not aggregates */ - class = TYPEget_type(t); + class = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if(class == logical_) { - return ("Logical"); + if( class == logical_ ) { + return ( "Logical" ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - return ("Boolean"); + if( class == boolean_ ) { + return ( "Boolean" ); } /* case TYPE_INTEGER: */ - if(class == integer_) { - return ("SDAI_Integer"); + if( class == integer_ ) { + return ( "SDAI_Integer" ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - return ("SDAI_Real"); + if( ( class == number_ ) || ( class == real_ ) ) { + return ( "SDAI_Real" ); } /* case TYPE_STRING: */ - if(class == string_) { - return ("char *"); + if( class == string_ ) { + return ( "char *" ); } /* case TYPE_BINARY: */ - if(class == binary_) { - return (AccessType(t)); + if( class == binary_ ) { + return ( AccessType( t ) ); } /* case TYPE_ENTITY: */ - if(class == entity_) { + if( class == entity_ ) { /* better do this because the return type might go away */ - strcpy(retval, IdlEntityTypeName(t)); - strcat(retval, "_ptr"); + strcpy( retval, IdlEntityTypeName( t ) ); + strcat( retval, "_ptr" ); return retval; } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if(class == enumeration_) { - strncpy(retval, EnumName(TYPEget_name(t)), BUFSIZ - 2); + if( class == enumeration_ ) { + strncpy( retval, EnumName( TYPEget_name( t ) ), BUFSIZ - 2 ); - strcat(retval, " /*"); - strcat(retval, IdlEntityTypeName(t)); - strcat(retval, "*/ "); + strcat( retval, " /*" ); + strcat( retval, IdlEntityTypeName( t ) ); + strcat( retval, "*/ " ); return retval; } - if(class == select_) { - return (IdlEntityTypeName(t)); + if( class == select_ ) { + return ( IdlEntityTypeName( t ) ); } /* default returns undefined */ - return ("SCLundefined"); + return ( "SCLundefined" ); } /**************************************************************//** @@ -1226,12 +1199,11 @@ const char *TYPEget_idl_type(const Type t) ** Side Effects: ** Status: new 1/24/91 ******************************************************************/ -char *TYPEget_express_type(const Type t) -{ +char * TYPEget_express_type( const Type t ) { Class_Of_Type class; Type bt; char retval [BUFSIZ]; - char *n, * permval, * aggr_type; + char * n, * permval, * aggr_type; /* 1. "DEFINED" types */ @@ -1239,38 +1211,38 @@ char *TYPEget_express_type(const Type t) /* case TYPE_ENTITY: */ /* case TYPE_SELECT: */ - n = TYPEget_name(t); - if(n) { - PrettyTmpName(n); + n = TYPEget_name( t ); + if( n ) { + PrettyTmpName( n ); } /* 2. "BASE" types */ - class = TYPEget_type(t); + class = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if((class == boolean_) || (class == logical_)) { - return ("Logical"); + if( ( class == boolean_ ) || ( class == logical_ ) ) { + return ( "Logical" ); } /* case TYPE_INTEGER: */ - if(class == integer_) { - return ("Integer "); + if( class == integer_ ) { + return ( "Integer " ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - return ("Real "); + if( ( class == number_ ) || ( class == real_ ) ) { + return ( "Real " ); } /* case TYPE_STRING: */ - if(class == string_) { - return ("String ") ; + if( class == string_ ) { + return ( "String " ) ; } /* case TYPE_BINARY: */ - if(class == binary_) { - return ("Binary ") ; + if( class == binary_ ) { + return ( "Binary " ) ; } /* AGGREGATES @@ -1279,71 +1251,70 @@ char *TYPEget_express_type(const Type t) case TYPE_LIST: case TYPE_SET: */ - if(isAggregateType(t)) { - bt = TYPEget_nonaggregate_base_type(t); - class = TYPEget_type(bt); + if( isAggregateType( t ) ) { + bt = TYPEget_nonaggregate_base_type( t ); + class = TYPEget_type( bt ); /* case TYPE_ARRAY: */ - if(TYPEget_type(t) == array_) { + if( TYPEget_type( t ) == array_ ) { aggr_type = "Array"; } /* case TYPE_LIST: */ - if(TYPEget_type(t) == list_) { + if( TYPEget_type( t ) == list_ ) { aggr_type = "List"; } /* case TYPE_SET: */ - if(TYPEget_type(t) == set_) { + if( TYPEget_type( t ) == set_ ) { aggr_type = "Set"; } /* case TYPE_BAG: */ - if(TYPEget_type(t) == bag_) { + if( TYPEget_type( t ) == bag_ ) { aggr_type = "Bag"; } - sprintf(retval, "%s of %s", - aggr_type, TYPEget_express_type(bt)); + sprintf( retval, "%s of %s", + aggr_type, TYPEget_express_type( bt ) ); /* this will declare extra memory when aggregate is > 1D */ - permval = (char *)sc_malloc(strlen(retval) * sizeof(char) + 1); - strcpy(permval, retval); + permval = ( char * )sc_malloc( strlen( retval ) * sizeof( char ) + 1 ); + strcpy( permval, retval ); return permval; } /* default returns undefined */ - fprintf(stderr, "Warning in %s: type %s is undefined\n", __func__, TYPEget_name(t)); - return ("SCLundefined"); + fprintf( stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name( t ) ); + return ( "SCLundefined" ); } /** Initialize an upper or lower bound for an aggregate. \sa AGGRprint_init */ -void AGGRprint_bound(FILE *header, FILE *impl, const char *var_name, const char *aggr_name, const char *cname, Expression bound, int boundNr) -{ - if(bound->symbol.resolved) { - if(bound->type == Type_Funcall) { - fprintf(impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string(bound)); +void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const char * aggr_name, const char * cname, Expression bound, int boundNr ) { + if( bound->symbol.resolved ) { + if( bound->type == Type_Funcall ) { + fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string( bound ) ); } else { - fprintf(impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer); + fprintf( impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer ); } } else { /* resolved == 0 seems to mean that this is Type_Runtime */ - assert(cname && (bound->e.op2) && (bound->e.op2->symbol.name)); - fprintf(impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name); - fprintf(header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name); - fprintf(header, " %s * ths = (%s *) this_ptr;\n", cname, cname); - fprintf(header, " ths->ResetAttributes();\n"); - fprintf(header, " STEPattribute * a = ths->NextAttribute();\n"); - fprintf(header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name); - fprintf(header, " a = ths->NextAttribute();\n"); - fprintf(header, " if( !a ) {\n"); - fprintf(header, " break;\n"); - fprintf(header, " }\n"); - fprintf(header, " }\n"); - fprintf(header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str(__FILE__), - __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com."); - fprintf(header, " return *( a->Integer() );\n"); /* always an integer? if not, would need to translate somehow due to return type... */ - fprintf(header, "}\n"); + assert( cname && ( bound->e.op2 ) && ( bound->e.op2->symbol.name ) ); + fprintf( impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name ); + fprintf( header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name ); + fprintf( header, " %s * ths = (%s *) this_ptr;\n", cname, cname ); + fprintf( header, " ths->ResetAttributes();\n" ); + fprintf( header, " STEPattribute * a = ths->NextAttribute();\n" ); + fprintf( header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name ); + fprintf( header, " a = ths->NextAttribute();\n" ); + fprintf( header, " if( !a ) {\n" ); + fprintf( header, " break;\n" ); + fprintf( header, " }\n" ); + fprintf( header, " }\n" ); + fprintf( header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str( __FILE__ ), + __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com." ); + fprintf( header, " return *( a->Integer() );\n" ); /* always an integer? if not, would need to translate somehow due to return type... */ + fprintf( header, "}\n" ); } } @@ -1358,29 +1329,28 @@ void AGGRprint_bound(FILE *header, FILE *impl, const char *var_name, const char * \param t the Type * \param var_name the name of the C++ variable, such as t_1 or schema::t_name */ -void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name) -{ - if(!header) { - fprintf(stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name); +void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ) { + if( !header ) { + fprintf( stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name ); abort(); } - if(!TYPEget_head(t)) { - const char *cname = 0; - if((t->superscope) && (t->superscope->symbol.name)) { - cname = ClassName(t->superscope->symbol.name); + if( !TYPEget_head( t ) ) { + const char * cname = 0; + if( ( t->superscope ) && ( t->superscope->symbol.name ) ) { + cname = ClassName( t->superscope->symbol.name ); } - if(TYPEget_body(t)->lower) { - AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->lower, 1); + if( TYPEget_body( t )->lower ) { + AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->lower, 1 ); } - if(TYPEget_body(t)->upper) { - AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->upper, 2); + if( TYPEget_body( t )->upper ) { + AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->upper, 2 ); } - if(TYPEget_body(t)->flags.unique) { - fprintf(impl, " %s->UniqueElements(LTrue);\n", var_name); + if( TYPEget_body( t )->flags.unique ) { + fprintf( impl, " %s->UniqueElements(LTrue);\n", var_name ); } - if(TYPEget_body(t)->flags.optional) { - fprintf(impl, " %s->OptionalElements(LTrue);\n", var_name); + if( TYPEget_body( t )->flags.optional ) { + fprintf( impl, " %s->OptionalElements(LTrue);\n", var_name ); } } } diff --git a/src/exp2cxx/classes_type.h b/src/exp2cxx/classes_type.h index ce178adc3..a15815b07 100644 --- a/src/exp2cxx/classes_type.h +++ b/src/exp2cxx/classes_type.h @@ -1,31 +1,31 @@ #ifndef CLASSES_TYPE_H #define CLASSES_TYPE_H -Type TYPEget_ancestor(Type); +Type TYPEget_ancestor( Type ); -const char *TypeName(Type t); -const char *TypeDescriptorName(Type); -char *TypeDescription(const Type t); -const char *AccessType(Type t); -const char *TYPEget_ctype(const Type t); +const char * TypeName( Type t ); +const char * TypeDescriptorName( Type ); +char * TypeDescription( const Type t ); +const char * AccessType( Type t ); +const char * TYPEget_ctype( const Type t ); -void TYPEPrint(const Type type, FILES *files, Schema schema); -void TYPEprint_descriptions(const Type, FILES *, Schema); -void TYPEprint_definition(Type, FILES *, Schema); -void TYPEprint_typedefs(Type, FILE *); -void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR); -void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema); +void TYPEPrint( const Type type, FILES *files, Schema schema ); +void TYPEprint_descriptions( const Type, FILES *, Schema ); +void TYPEprint_definition( Type, FILES *, Schema ); +void TYPEprint_typedefs( Type, FILE * ); +void TYPEprint_new( const Type type, FILE* create, Schema schema, bool needWR ); +void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ); -void TYPEenum_inc_print(const Type type, FILE *inc); -void TYPEenum_lib_print(const Type type, FILE *f); +void TYPEenum_inc_print( const Type type, FILE * inc ); +void TYPEenum_lib_print( const Type type, FILE * f ); -void TYPEselect_print(Type, FILES *, Schema); -void TYPEselect_init_print(const Type type, FILE *f); -void TYPEselect_inc_print(const Type type, FILE *f); -void TYPEselect_lib_print(const Type type, FILE *f); +void TYPEselect_print( Type, FILES *, Schema ); +void TYPEselect_init_print( const Type type, FILE* f ); +void TYPEselect_inc_print( const Type type, FILE * f ); +void TYPEselect_lib_print( const Type type, FILE * f ); -void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name); +void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ); -void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name); +void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ); #endif diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 8b1daca64..517fa8a89 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -31,20 +31,18 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. ** **/ -void use_ref(Schema, Express, FILES *); +void use_ref( Schema, Express, FILES * ); -void create_builtin_type_decl(FILES *files, char *name) -{ - fprintf(files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", - "SCHEMA", TD_PREFIX, name); +void create_builtin_type_decl( FILES * files, char * name ) { + fprintf( files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", + "SCHEMA", TD_PREFIX, name ); } -void create_builtin_type_defn(FILES *files, char *name) -{ - fprintf(files->initall, " %s%s_TYPE = new TypeDescriptor (", - TD_PREFIX, name); - fprintf(files->initall, "\"%s\", %s_TYPE, \"%s\");\n", - PrettyTmpName(name), StrToUpper(name), StrToLower(name)); +void create_builtin_type_defn( FILES * files, char * name ) { + fprintf( files->initall, " %s%s_TYPE = new TypeDescriptor (", + TD_PREFIX, name ); + fprintf( files->initall, "\"%s\", %s_TYPE, \"%s\");\n", + PrettyTmpName( name ), StrToUpper( name ), StrToLower( name ) ); } /** **************************************************************** @@ -57,66 +55,65 @@ void create_builtin_type_defn(FILES *files, char *name) ** In this case the file schema.h is initiated ** Status: ok 1/15/91 ******************************************************************/ -void print_file_header(FILES *files) -{ +void print_file_header( FILES * files ) { /* open file which unifies all schema specific header files of input Express source */ - files -> incall = FILEcreate("schema.h"); - fprintf(files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n"); - - fprintf(files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n"); - fprintf(files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n"); - fprintf(files->incall, "# else\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n"); - fprintf(files->incall, "# endif\n"); - fprintf(files->incall, "#else\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT\n"); - fprintf(files->incall, "#endif\n\n"); - - fprintf(files->incall, "#ifdef SC_LOGGING\n"); - fprintf(files->incall, "#include \n"); - fprintf(files->incall, "#endif\n"); - - fprintf(files->incall, "#include \n\n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - - fprintf(files->incall, "\n#include \n"); - - fprintf(files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA"); - fprintf(files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA"); - - files -> initall = FILEcreate("schema.cc"); - fprintf(files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n"); - fprintf(files->initall, "#include \"schema.h\"\n"); - fprintf(files->initall, "#include \"sc_memmgr.h\"\n"); - fprintf(files->initall, "class Registry;\n"); - - fprintf(files->initall, "\nvoid SchemaInit (Registry & reg) {\n"); - fprintf(files->initall, " extern void InitSchemasAndEnts "); - fprintf(files->initall, "(Registry & r);\n"); - fprintf(files->initall, " InitSchemasAndEnts (reg);\n"); + files -> incall = FILEcreate( "schema.h" ); + fprintf( files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n" ); + + fprintf( files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n" ); + fprintf( files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n" ); + fprintf( files->incall, "# else\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n" ); + fprintf( files->incall, "# endif\n" ); + fprintf( files->incall, "#else\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT\n" ); + fprintf( files->incall, "#endif\n\n" ); + + fprintf( files->incall, "#ifdef SC_LOGGING\n" ); + fprintf( files->incall, "#include \n" ); + fprintf( files->incall, "#endif\n" ); + + fprintf( files->incall, "#include \n\n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + + fprintf( files->incall, "\n#include \n" ); + + fprintf( files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA" ); + fprintf( files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA" ); + + files -> initall = FILEcreate( "schema.cc" ); + fprintf( files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n" ); + fprintf( files->initall, "#include \"schema.h\"\n" ); + fprintf( files->initall, "#include \"sc_memmgr.h\"\n" ); + fprintf( files->initall, "class Registry;\n" ); + + fprintf( files->initall, "\nvoid SchemaInit (Registry & reg) {\n" ); + fprintf( files->initall, " extern void InitSchemasAndEnts " ); + fprintf( files->initall, "(Registry & r);\n" ); + fprintf( files->initall, " InitSchemasAndEnts (reg);\n" ); // This file will contain instantiation statements for all the schemas and // entities in the express file. (They must all be in separate function // called first by SchemaInit() so that all entities will exist - files -> create = FILEcreate("SdaiAll.cc"); - fprintf(files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n"); - fprintf(files->create, "#include \"schema.h\"\n"); - fprintf(files->create, "#include \"sc_memmgr.h\"\n"); - fprintf(files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n"); + files -> create = FILEcreate( "SdaiAll.cc" ); + fprintf( files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n" ); + fprintf( files->create, "#include \"schema.h\"\n" ); + fprintf( files->create, "#include \"sc_memmgr.h\"\n" ); + fprintf( files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n" ); // This file declares all entity classes as incomplete types. This will // allow all the .h files to reference all .h's. We can then have e.g., // entX from schemaA have attribute attr1 = entY from schemaB. - files -> classes = FILEcreate("Sdaiclasses.h"); - fprintf(files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n"); - fprintf(files->classes, "#include \"schema.h\"\n"); + files -> classes = FILEcreate( "Sdaiclasses.h" ); + fprintf( files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n" ); + fprintf( files->classes, "#include \"schema.h\"\n" ); } /** **************************************************************** @@ -127,32 +124,28 @@ void print_file_header(FILES *files) ** Description: handles cleaning up things at end of processing ** Status: ok 1/15/91 ******************************************************************/ -void print_file_trailer(FILES *files) -{ - FILEclose(files->incall); - FILEclose(files->initall); - fprintf(files->create, "}\n\n"); - FILEclose(files->create); - fprintf(files->classes, "\n"); - FILEclose(files->classes); - fprintf(files->names, "\n}\n"); - FILEclose(files->names); +void print_file_trailer( FILES * files ) { + FILEclose( files->incall ); + FILEclose( files->initall ); + fprintf( files->create, "}\n\n" ); + FILEclose( files->create ); + fprintf( files->classes, "\n" ); + FILEclose( files->classes ); + fprintf( files->names, "\n}\n" ); + FILEclose( files->names ); } /* set attribute index to simplify attrdescriptor name calculation * and reduce/eliminate use of global attr_count */ -void numberAttributes(Scope scope) -{ +void numberAttributes( Scope scope ) { int count = 0; - Linked_List list = SCOPEget_entities_superclass_order(scope); - LISTdo(list, e, Entity) { - LISTdo_n(ENTITYget_attributes(e), v, Variable, b) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); + LISTdo( list, e, Entity ) { + LISTdo_n( ENTITYget_attributes( e ), v, Variable, b ) { v->idx = count++; - } - LISTod - } - LISTod + } LISTod + } LISTod } /****************************************************************** @@ -170,14 +163,13 @@ void numberAttributes(Scope scope) ** and what the relationship is between this organization and the ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint(Scope scope, FILES *files, Schema schema, ComplexCollect *col, int cnt) -{ - Linked_List list = SCOPEget_entities_superclass_order(scope); +void SCOPEPrint( Scope scope, FILES * files, Schema schema, ComplexCollect * col, int cnt ) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); DictionaryEntry de; Type i; int redefs = 0; - if(cnt <= 1) { + if( cnt <= 1 ) { /* This will be the case if this is the first time we are generating a ** file for this schema. (cnt = the file suffix. If it = 1, it's the ** first of multiple; if it = 0, it's the only one.) Basically, this @@ -185,209 +177,198 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema, ComplexCollect *col, i ** during multiple passes. This includes Sdaiclasses.h, SdaiAll.cc, ** and the Sdaixxx.init.cc files. */ - fprintf(files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name(schema)); + fprintf( files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name( schema ) ); /* Do \'new\'s for types descriptors (in SdaiAll.cc (files->create)), and the externs typedefs, and incomplete descriptors (in Sdai- classes.h (files->classes)). */ - fprintf(files->create, "\n // ***** Initialize the Types\n"); - fprintf(files->classes, "\n// Types:\n"); - SCOPEdo_types(scope, t, de) { + fprintf( files->create, "\n // ***** Initialize the Types\n" ); + fprintf( files->classes, "\n// Types:\n" ); + SCOPEdo_types( scope, t, de ) { //TYPEprint_new moved to TYPEPrint_cc and TYPEprint_descriptions in classes_type.c - TYPEprint_typedefs(t, files->classes); + TYPEprint_typedefs( t, files->classes ); //print in namespace. Some logic copied from TypeDescriptorName() - fprintf(files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName(t), TYPEprefix(t), TYPEget_name(t)); - } - SCOPEod + fprintf( files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName( t ), TYPEprefix( t ), TYPEget_name( t ) ); + } SCOPEod - fprintf(files->classes, "\n// Entity class typedefs:"); - LISTdo(list, e, Entity) { - ENTITYprint_classes(e, files->classes); - } - LISTod + fprintf( files->classes, "\n// Entity class typedefs:" ); + LISTdo( list, e, Entity ) { + ENTITYprint_classes( e, files->classes ); + } LISTod } /* fill in the values for the type descriptors and print the enumerations */ - fprintf(files -> inc, "\n/* ************** TYPES */\n"); - fprintf(files -> lib, "\n/* ************** TYPES */\n"); + fprintf( files -> inc, "\n/* ************** TYPES */\n" ); + fprintf( files -> lib, "\n/* ************** TYPES */\n" ); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - if(scope->enum_table) { - HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); + if( scope->enum_table ) { + HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); Type t; - while(0 != (t = (Type) DICTdo(&de))) { + while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if((t->search_id == CANPROCESS) - && (TYPEis_enumeration(t)) - && ((i = TYPEget_ancestor(t)) != NULL) - && (i->search_id >= CANPROCESS)) { + if( ( t->search_id == CANPROCESS ) + && ( TYPEis_enumeration( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) + && ( i->search_id >= CANPROCESS ) ) { redefs = 1; } } } - SCOPEdo_types(scope, t, de) { + SCOPEdo_types( scope, t, de ) { /* NOTE the following comment seems to contradict the logic below it (... && !( TYPEis_enumeration( t ) && ...) // Do the non-redefined enumerations:*/ - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) && TYPEget_head(t))) { - TYPEprint_descriptions(t, files, schema); - if(!TYPEis_select(t)) { + if( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { + TYPEprint_descriptions( t, files, schema ); + if( !TYPEis_select( t ) ) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } } - } - SCOPEod + } SCOPEod - if(redefs) { + if( redefs ) { // Here we process redefined enumerations. See note, 2 loops ago. - fprintf(files->inc, "// ***** Redefined Enumerations:\n"); + fprintf( files->inc, "// ***** Redefined Enumerations:\n" ); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); + HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); Type t; - while(0 != (t = (Type) DICTdo(&de))) { - if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { + if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } } } /* do the select definitions next, since they depend on the others */ - fprintf(files->inc, "\n// ***** Build the SELECT Types \n"); + fprintf( files->inc, "\n// ***** Build the SELECT Types \n" ); // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types(scope, t, de) { - if(t->search_id == CANPROCESS) { + SCOPEdo_types( scope, t, de ) { + if( t->search_id == CANPROCESS ) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. - if(TYPEis_select(t)) { - TYPEselect_print(t, files, schema); + if( TYPEis_select( t ) ) { + TYPEselect_print( t, files, schema ); } - if(TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + if( TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); } t->search_id = PROCESSED; } - } - SCOPEod + } SCOPEod - fprintf(files -> inc, "\n/* ************** ENTITIES */\n"); - fprintf(files -> lib, "\n/* ************** ENTITIES */\n"); + fprintf( files -> inc, "\n/* ************** ENTITIES */\n" ); + fprintf( files -> lib, "\n/* ************** ENTITIES */\n" ); - fprintf(files->inc, "\n// ***** Print Entity Classes \n"); - LISTdo(list, e, Entity) { - if(e->search_id == CANPROCESS) { - ENTITYPrint(e, files, schema, col->externMapping(ENTITYget_name(e))); + fprintf( files->inc, "\n// ***** Print Entity Classes \n" ); + LISTdo( list, e, Entity ) { + if( e->search_id == CANPROCESS ) { + ENTITYPrint( e, files, schema, col->externMapping( ENTITYget_name( e ) ) ); e->search_id = PROCESSED; } - } - LISTod + } LISTod - if(cnt <= 1) { + if( cnt <= 1 ) { int index = 0; // Do the model stuff: - fprintf(files->inc, "\n// ***** generate Model related pieces\n"); - fprintf(files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name(schema)); - fprintf(files -> inc, "\n public:\n"); - fprintf(files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); - LISTdo(list, e, Entity) { - MODELprint_new(e, files); - } - LISTod - - fprintf(files->inc, "\n};\n\n"); - - fprintf(files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); - - fprintf(files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name(schema)); - fprintf(files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name(schema)); - - fprintf(files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n"); - LISTdo(list, e, Entity) { - MODELPrintConstructorBody(e, files, schema); - } - LISTod - fprintf(files -> lib, "}\n"); + fprintf( files->inc, "\n// ***** generate Model related pieces\n" ); + fprintf( files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name( schema ) ); + fprintf( files -> inc, "\n public:\n" ); + fprintf( files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); + LISTdo( list, e, Entity ) { + MODELprint_new( e, files ); + } LISTod + + fprintf( files->inc, "\n};\n\n" ); + + fprintf( files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); + + fprintf( files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ) ); + fprintf( files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name( schema ) ); + + fprintf( files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n" ); + LISTdo( list, e, Entity ) { + MODELPrintConstructorBody( e, files, schema ); + } LISTod + fprintf( files -> lib, "}\n" ); index = 0; - LISTdo(list, e, Entity) { - MODELPrint(e, files, schema, index); + LISTdo( list, e, Entity ) { + MODELPrint( e, files, schema, index ); index++; - } - LISTod + } LISTod } - LISTfree(list); + LISTfree( list ); } /** open/init unity files which allow faster compilation with fewer translation units */ -void initUnityFiles(const char *schName, FILES *files) -{ - const char *unity = "\n/** this file is for unity builds, which allow faster compilation\n" - " * with fewer translation units. not compatible with all compilers!\n */\n\n" - "#include \"schema.h\"\n"; +void initUnityFiles( const char * schName, FILES * files ) { + const char * unity = "\n/** this file is for unity builds, which allow faster compilation\n" + " * with fewer translation units. not compatible with all compilers!\n */\n\n" + "#include \"schema.h\"\n"; std::string name = schName; - name.append("_unity_"); + name.append( "_unity_" ); size_t prefixLen = name.length(); - name.append("entities.cc"); - files->unity.entity.impl = FILEcreate(name.c_str()); + name.append( "entities.cc" ); + files->unity.entity.impl = FILEcreate( name.c_str() ); - name.resize(name.length() - 2); - name.append("h"); - fprintf(files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str()); + name.resize( name.length() - 2 ); + name.append( "h" ); + fprintf( files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str() ); - files->unity.entity.hdr = FILEcreate(name.c_str()); - fprintf(files->unity.entity.hdr, "%s\n", unity); + files->unity.entity.hdr = FILEcreate( name.c_str() ); + fprintf( files->unity.entity.hdr, "%s\n", unity ); - name.resize(prefixLen); - name.append("types.cc"); - files->unity.type.impl = FILEcreate(name.c_str()); + name.resize( prefixLen ); + name.append( "types.cc" ); + files->unity.type.impl = FILEcreate( name.c_str() ); - name.resize(name.length() - 2); - name.append("h"); - fprintf(files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str()); + name.resize( name.length() - 2 ); + name.append( "h" ); + fprintf( files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str() ); - files->unity.type.hdr = FILEcreate(name.c_str()); - fprintf(files->unity.type.hdr, "%s\n", unity); + files->unity.type.hdr = FILEcreate( name.c_str() ); + fprintf( files->unity.type.hdr, "%s\n", unity ); } /** close unity files * \sa initUnityFiles() */ -void closeUnityFiles(FILES *files) -{ - FILEclose(files->unity.type.hdr); - FILEclose(files->unity.type.impl); - FILEclose(files->unity.entity.hdr); - FILEclose(files->unity.entity.impl); +void closeUnityFiles( FILES * files ) { + FILEclose( files->unity.type.hdr ); + FILEclose( files->unity.type.impl ); + FILEclose( files->unity.entity.hdr ); + FILEclose( files->unity.entity.impl ); } ///write tail of initfile, close it -void INITFileFinish(FILE *initfile, Schema schema) -{ - fprintf(initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); - fprintf(initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name(schema)); - fprintf(initfile, " EntityDescriptor * ed;\n"); - fprintf(initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name(schema)); - fprintf(initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); - fprintf(initfile, " ed->InitIAttrs( reg, nm );\n"); - fprintf(initfile, " }\n}\n"); - FILEclose(initfile); +void INITFileFinish( FILE * initfile, Schema schema ) { + fprintf( initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); + fprintf( initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name( schema ) ); + fprintf( initfile, " EntityDescriptor * ed;\n"); + fprintf( initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name( schema ) ); + fprintf( initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); + fprintf( initfile, " ed->InitIAttrs( reg, nm );\n"); + fprintf( initfile, " }\n}\n" ); + FILEclose( initfile ); } /** **************************************************************** @@ -403,17 +384,15 @@ void INITFileFinish(FILE *initfile, Schema schema) ** Side Effects: ** Status: ******************************************************************/ -void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) -{ - int ocnt = 0; +void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) { char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE *libfile, + FILE * libfile, * incfile, * schemafile = files->incall, - * schemainit = files->initall, - * initfile, - * createall = files->create; + * schemainit = files->initall, + * initfile, + * createall = files->create; Rule r; Function f; Procedure p; @@ -421,181 +400,160 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper(SCHEMAget_name(schema))); //TODO change file names to CamelCase? - if(suffix == 0) { - ocnt = snprintf(sufnm, MAX_LEN, "%s", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; - } + sprintf( schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper( SCHEMAget_name( schema ) ) ); //TODO change file names to CamelCase? + if( suffix == 0 ) { + sprintf( sufnm, "%s", schnm ); } else { - ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; - } - } - ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; + sprintf( sufnm, "%s_%d", schnm, suffix ); } + sprintf( fnm, "%s.h", sufnm ); - if(!(incfile = (files -> inc) = FILEcreate(fnm))) { + if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); + fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); - fprintf(incfile, "#include \"schema.h\"\n"); - fprintf(incfile, "#include \"sc_memmgr.h\"\n"); + fprintf( incfile, "#include \"schema.h\"\n" ); + fprintf( incfile, "#include \"sc_memmgr.h\"\n" ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 1.9 open/init unity files which allow faster compilation with fewer translation units */ - initUnityFiles(sufnm, files); + initUnityFiles( sufnm, files ); /* 2. class source file */ - sprintf(np, "cc"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "cc" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); + fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); //TODO: Looks like this switches between 'schema.h' and a non-generic name. What is that name, //and how do we fully enable this feature (i.e. how to write the file with different name)? #ifdef SCHEMA_HANDLING - sprintf(np, "h"); - fprintf(libfile, "#include <%s.h> \n", sufnm); + sprintf( np, "h" ); + fprintf( libfile, "#include <%s.h> \n", sufnm ); #else - fprintf(libfile, "#include \"schema.h\"\n"); + fprintf( libfile, "#include \"schema.h\"\n" ); #endif - fprintf(libfile, "#include \"sc_memmgr.h\"\n"); + fprintf( libfile, "#include \"sc_memmgr.h\"\n" ); - fprintf(libfile, - "\n#ifdef SC_LOGGING \n" - "#include \n" - " extern ofstream *logStream;\n" - "#define SCLLOGFILE \"scl.log\"\n" - "#endif \n"); + fprintf( libfile, + "\n#ifdef SC_LOGGING \n" + "#include \n" + " extern ofstream *logStream;\n" + "#define SCLLOGFILE \"scl.log\"\n" + "#endif \n" ); - fprintf(libfile, "\n#include \"%s.h\"\n", schnm); + fprintf( libfile, "\n#include \"%s.h\"\n", schnm ); // 3. header for namespace to contain all formerly-global variables - ocnt = snprintf(fnm, MAX_LEN, "%sNames.h", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; - } - - if(!(files->names = FILEcreate(fnm))) { + sprintf( fnm, "%sNames.h", schnm ); + if( !( files->names = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "#include \"%sNames.h\"\n", schnm); - fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); - fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); - fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); - fprintf(files->names, " extern Schema * schema;\n\n"); + fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); + fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); + fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); + fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); + fprintf( files->names, " extern Schema * schema;\n\n" ); /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - if(suffix <= 1) { + if( suffix <= 1 ) { /* I.e., if this is our first pass with schema */ - ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; - } - + sprintf( fnm, "%s.init.cc", schnm ); /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ - if(!(initfile = (files -> init) = FILEcreate(fnm))) { + if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); + fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); #ifdef SCHEMA_HANDLING - if(suffix == 0) { - fprintf(initfile, "#include <%s.h>\n", schnm); + if( suffix == 0 ) { + fprintf( initfile, "#include <%s.h>\n", schnm ); } else { - fprintf(initfile, "#include <%s_%d.h>\n", schnm, suffix); + fprintf( initfile, "#include <%s_%d.h>\n", schnm, suffix ); } #else - fprintf(initfile, - "#ifndef SCHEMA_H\n" - "#include \"schema.h\"\n" - "#endif\n"); + fprintf( initfile, + "#ifndef SCHEMA_H\n" + "#include \"schema.h\"\n" + "#endif\n" ); #endif - fprintf(initfile, "#include \n#include \n"); - fprintf(initfile, "#include \n"); + fprintf( initfile, "#include \n#include \n" ); + fprintf( initfile, "#include \n" ); - fprintf(initfile, "\nvoid %sInit (Registry& reg) {\n", schnm); + fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); - fprintf(createall, "// Schema: %s\n", schnm); - fprintf(createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name(schema), PrettyTmpName(SCHEMAget_name(schema))); + fprintf( createall, "// Schema: %s\n", schnm ); + fprintf( createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name( schema ), PrettyTmpName( SCHEMAget_name( schema ) ) ); /* Add the SdaiModel_contents_ class constructor to the schema descriptor create function for it */ - fprintf(createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", - SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf( createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", + SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf(createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name(schema)); + fprintf( createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name( schema ) ); /**************/ /* add global RULEs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, RULEto_string(r)); - fprintf(createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name(schema)); - fprintf(createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, RULEto_string( r ) ); + fprintf( createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name( schema ) ); + fprintf( createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name( schema ) ); } /**************/ /* add FUNCTIONs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, FUNCto_string(f)); - fprintf(createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, FUNCto_string( f ) ); + fprintf( createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name( schema ) ); } /* add PROCEDUREs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, PROCto_string(p)); - fprintf(createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, PROCto_string( p ) ); + fprintf( createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name( schema ) ); } - fprintf(files->classes, "\n// Schema: %s", schnm); - fprintf(files->classes, "\n#include \"%sNames.h\"\n", schnm); + fprintf( files->classes, "\n// Schema: %s", schnm ); + fprintf( files->classes, "\n#include \"%sNames.h\"\n", schnm ); } else { /* Just reopen the .init.cc (in append mode): */ - ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; - } - - initfile = files->init = fopen(fnm, "a"); + sprintf( fnm, "%s.init.cc", schnm ); + initfile = files->init = fopen( fnm, "a" ); } /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); - fprintf(schemafile, "#include \"%s.h\" \n", sufnm); - if(schema->search_id == PROCESSED) { - fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " %sInit (reg); \n", schnm); + fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); + fprintf( schemafile, "#include \"%s.h\" \n", sufnm ); + if( schema->search_id == PROCESSED ) { + fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " %sInit (reg); \n", schnm ); } /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint(schema, files, schema, (ComplexCollect *)complexCol, suffix); + SCOPEPrint( schema, files, schema, ( ComplexCollect * )complexCol, suffix ); /********** close the files ***********/ - closeUnityFiles(files); - FILEclose(libfile); - FILEclose(incfile); - if(schema->search_id == PROCESSED) { - INITFileFinish(initfile, schema); + closeUnityFiles( files ); + FILEclose( libfile ); + FILEclose( incfile ); + if( schema->search_id == PROCESSED ) { + INITFileFinish( initfile, schema ); } else { - fclose(initfile); + fclose( initfile ); } } @@ -612,28 +570,27 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) -{ +void getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { DictionaryEntry de; Schema schema; - fprintf(schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n"); - fprintf(schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__); - fprintf(schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n"); - fprintf(schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n"); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - schema = (Scope)DICTdo(&de); - fprintf(schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); - fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); - fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); + fprintf( schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n" ); + fprintf( schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__ ); + fprintf( schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n" ); + fprintf( schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n" ); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + schema = ( Scope )DICTdo( &de ); + fprintf( schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); + fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); + fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); } - fprintf(schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n"); + fprintf( schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n" ); } /****************************************************************** @@ -648,15 +605,14 @@ void getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) -{ +void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { char fnm [MAX_LEN], *np; - const char *schnm; /* schnm is really "express name" */ - FILE *libfile; - FILE *incfile; - FILE *schemafile = files -> incall; - FILE *schemainit = files -> initall; - FILE *initfile; + const char * schnm; /* schnm is really "express name" */ + FILE * libfile; + FILE * incfile; + FILE * schemafile = files -> incall; + FILE * schemainit = files -> initall; + FILE * initfile; /* new */ Schema schema; DictionaryEntry de; @@ -665,81 +621,81 @@ void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); - if(!(incfile = (files -> inc) = FILEcreate(fnm))) { + sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); + if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); + fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); - fprintf(incfile, "#include \n"); + fprintf( incfile, "#include \n" ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 1.9 init unity files (large translation units, faster compilation) */ - initUnityFiles(schnm, files); + initUnityFiles( schnm, files ); /* 2. class source file */ - sprintf(np, "cc"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "cc" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); + fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); - fprintf(libfile, "#include \"%s.h\" n", schnm); + fprintf( libfile, "#include \"%s.h\" n", schnm ); // 3. header for namespace to contain all formerly-global variables - sprintf(fnm, "%sNames.h", schnm); - if(!(files->names = FILEcreate(fnm))) { + sprintf( fnm, "%sNames.h", schnm ); + if( !( files->names = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "#include \"%sNames.h\"\n", schnm); - fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); - fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); + fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); + fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); + fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); //the next line in this file depends on the schema name, so printing continues in the while loop ~25 lines below /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - sprintf(np, "init.cc"); - if(!(initfile = (files -> init) = FILEcreate(fnm))) { + sprintf( np, "init.cc" ); + if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); + fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); - fprintf(initfile, "#include \"%s.h\"\n\n", schnm); - fprintf(initfile, "void \n%sInit (Registry& reg)\n{\n", schnm); + fprintf( initfile, "#include \"%s.h\"\n\n", schnm ); + fprintf( initfile, "void \n%sInit (Registry& reg)\n{\n", schnm ); /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); - fprintf(schemafile, "#include \"%s.h\"\n\n", schnm); - fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " %sInit (reg);\n", schnm); + fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); + fprintf( schemafile, "#include \"%s.h\"\n\n", schnm ); + fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " %sInit (reg);\n", schnm ); /********** do all schemas ***********/ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - numberAttributes(schema); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + numberAttributes( schema ); } - DICTdo_init(express->symbol_table, &de); + DICTdo_init( express->symbol_table, &de ); bool first = true; - while(0 != (schema = (Scope)DICTdo(&de))) { - if(!first) { - fprintf(files->names, "} //namespace %s\n", SCHEMAget_name(schema)); + while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { + if( !first ) { + fprintf( files->names, "} //namespace %s\n", SCHEMAget_name( schema ) ); } first = false; - fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); - fprintf(files->names, " extern Schema * schema;\n\n"); + fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); + fprintf( files->names, " extern Schema * schema;\n\n" ); - SCOPEPrint(schema, files, schema, &col, 0); + SCOPEPrint( schema, files, schema, &col, 0 ); } /********** close the files ***********/ - closeUnityFiles(files); - FILEclose(libfile); - FILEclose(incfile); - INITFileFinish(initfile, schema); + closeUnityFiles( files ); + FILEclose( libfile ); + FILEclose( incfile ); + INITFileFinish( initfile, schema ); } /** @@ -748,30 +704,28 @@ void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) * Side Effects: generates code * Status: 24-Feb-1992 new -kcm */ -void print_schemas_combined(Express express, ComplexCollect &col, FILES *files) -{ - EXPRESSPrint(express, col, files); +void print_schemas_combined( Express express, ComplexCollect & col, FILES * files ) { + EXPRESSPrint( express, col, files ); } /** this function calls one of two different functions * depending on whether the output should be combined into a single * set of files or a separate set for each schema */ -void print_file(Express express) -{ - extern void RESOLUTIONsucceed(void); +void print_file( Express express ) { + extern void RESOLUTIONsucceed( void ); int separate_schemas = 1; - ComplexCollect col(express); + ComplexCollect col( express ); File_holder files; resolution_success(); - print_file_header(&files); - if(separate_schemas) { - print_schemas_separate(express, &col, &files); + print_file_header( &files ); + if( separate_schemas ) { + print_schemas_separate( express, &col, &files ); } else { - print_schemas_combined(express, col, &files); + print_schemas_combined( express, col, &files ); } - print_file_trailer(&files); - print_complex(col, "compstructs.cc"); + print_file_trailer( &files ); + print_complex( col, "compstructs.cc" ); } diff --git a/src/exp2cxx/collect.cc b/src/exp2cxx/collect.cc index 62a271498..d12db7346 100644 --- a/src/exp2cxx/collect.cc +++ b/src/exp2cxx/collect.cc @@ -14,19 +14,19 @@ #include "complexSupport.h" #include -void ComplexCollect::insert(ComplexList *c) +void ComplexCollect::insert( ComplexList * c ) /* * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ { - ComplexList *prev = NULL, *cl = clists; + ComplexList * prev = NULL, *cl = clists; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(prev == NULL) { + if( prev == NULL ) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -39,7 +39,7 @@ void ComplexCollect::insert(ComplexList *c) count++; } -void ComplexCollect::remove(ComplexList *c) +void ComplexCollect::remove( ComplexList * c ) /* * Removes the ComplexList whose supertype name = supername. "Removing" * deletes the list and removes it from this, but does not delete its @@ -49,17 +49,17 @@ void ComplexCollect::remove(ComplexList *c) * remove it from the Collect. */ { - ComplexList *cl = clists, *prev = NULL; + ComplexList * cl = clists, *prev = NULL; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(cl == NULL || cl != c) { + if( cl == NULL || cl != c ) { // Just in case c isn't in the list. return; } - if(prev == NULL) { + if( prev == NULL ) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -70,23 +70,23 @@ void ComplexCollect::remove(ComplexList *c) count--; } -ComplexList *ComplexCollect::find(char *name) +ComplexList * ComplexCollect::find( char * name ) /* * Searches for and returns the ComplexList whose supertype name = name. */ { - ComplexList *cl = clists; + ComplexList * cl = clists; - while(cl && *cl < name) { + while( cl && *cl < name ) { cl = cl->next; } - if(cl && *cl == name) { + if( cl && *cl == name ) { return cl; } return NULL; } -int ComplexCollect::supports(EntNode *ents) +int ComplexCollect::supports( EntNode * ents ) /* * Determines if the parent schema supports the instantiation of a complex * type consisting of the entities named in ents. Does so by attempting @@ -96,36 +96,36 @@ int ComplexCollect::supports(EntNode *ents) * to match it, as described in the commenting. */ { - EntNode *node = ents, *nextnode; - AndList *alist = 0; - ComplexList *clist = clists, *cl = NULL, *current; + EntNode * node = ents, *nextnode; + AndList * alist = 0; + ComplexList * clist = clists, *cl = NULL, *current; int retval; - EntList *elist, *next; + EntList * elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while(node) { - if(node->multSuprs()) { + while( node ) { + if( node->multSuprs() ) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if(!cl) { + if( !cl ) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList(alist); + cl = new ComplexList( alist ); } current = clists; - while(current) { - if(current->contains(node)) { + while( current ) { + if( current->contains( node ) ) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if(! cl->toplevel(current->supertype())) { + if( ! cl->toplevel( current->supertype() ) ) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList(current->head->childList); + alist->appendList( current->head->childList ); } } current = current->next; @@ -137,11 +137,11 @@ int ComplexCollect::supports(EntNode *ents) // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if(!cl) { + if( !cl ) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while(clist != NULL) { - if(clist->matches(ents)) { + while( clist != NULL ) { + if( clist->matches( ents ) ) { return TRUE; } clist = clist->next; @@ -152,13 +152,13 @@ int ComplexCollect::supports(EntNode *ents) // Use cl to test that the conditions of all supertypes are met: cl->multSupers = TRUE; cl->buildList(); - retval = cl->matches(ents); + retval = cl->matches( ents ); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while(elist) { + while( elist ) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/exp2cxx/complexSupport.h b/src/exp2cxx/complexSupport.h index 9055d92f8..8277a03fa 100644 --- a/src/exp2cxx/complexSupport.h +++ b/src/exp2cxx/complexSupport.h @@ -63,8 +63,7 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode -{ +class EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -72,59 +71,48 @@ class EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), - multSupers(0) - { - strcpy(name, nm); - } - EntNode(char *[]); // given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), + multSupers( 0 ) { + strcpy( name, nm ); + } + EntNode( char *[] ); // given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - int operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + int operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - int operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + int operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - int operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + int operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - int marked(MarkType base = ORMARK) - { - return (mark >= base); + int marked( MarkType base = ORMARK ) { + return ( mark >= base ); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() - { + int multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - EntNode *next; + EntNode * next; private: MarkType mark; @@ -132,79 +120,68 @@ class EntNode int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList -{ +class EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual int getMaxLevel() - { + virtual int getMaxLevel() { return level; } - virtual int contains(const char *) = 0; - virtual int hit(const char *) = 0; - virtual int isDependent(const char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual int contains( const char * ) = 0; + virtual int hit( const char * ) = 0; + virtual int isDependent( const char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual int acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual int acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); - virtual void write(ostream &) = 0; + virtual void write( ostream & ) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return next->firstNot(j); + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return next->firstWanted(mat); + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return prev->lastNot(j); + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return prev->lastWanted(mat); + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *prev, * next; + EntList * prev, * next; protected: MatchType viable; @@ -216,153 +193,137 @@ class EntList int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList -{ +class SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strcpy(name, n); + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strcpy( name, n ); } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - int contains(const char *nm) - { + int contains( const char * nm ) { return *this == nm; } - int hit(const char *nm) - { + int hit( const char * nm ) { return *this == nm; } - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - int acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + int acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } - void write(ostream &); + void write( ostream & ); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList -{ +class MultList : public EntList { // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} + MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} ~MultList(); - void setLevel(int); + void setLevel( int ); int getMaxLevel(); - int contains(const char *); - int hit(const char *); - int isDependent(const char *); - void appendList(EntList *); - EntList *copyList(EntList *); - void processSubExp(Expression, Entity, ComplexCollect *); - void addSimpleAndSubs(Entity, ComplexCollect *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + int contains( const char * ); + int hit( const char * ); + int isDependent( const char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + void processSubExp( Expression, Entity, ComplexCollect * ); + void addSimpleAndSubs( Entity, ComplexCollect * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - int prevKnown(EntList *); + void unmarkAll( EntNode * ); + int prevKnown( EntList * ); void reset(); - void write(ostream &); + void write( ostream & ); protected: int numchildren; - EntList *childList; + EntList * childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList -{ +class JoinList : public MultList { // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - int acceptChoice(EntNode *); + void setViableVal( EntNode * ); + int acceptChoice( EntNode * ); }; -class AndOrList : public JoinList -{ +class AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class AndList : public JoinList -{ +class AndList : public JoinList { friend class MultList; friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND), supertype(0) {} + AndList() : JoinList( AND ), supertype( 0 ) {} ~AndList() {} - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList -{ +class OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} ~OrList() {} - int hit(const char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - int acceptChoice(EntNode *); - int acceptNextChoice(EntNode *ents) - { + int hit( const char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + int acceptChoice( EntNode * ); + int acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -375,101 +336,90 @@ class OrList : public MultList // the first viable choice; and how many choices are there entirely. }; -class ComplexList -{ +class ComplexList { // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} - ComplexList(Entity, ComplexCollect *); + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} + ComplexList( Entity, ComplexCollect * ); ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return ((SimpleList *)head->childList)->name; + const char * supertype() { + return ( ( SimpleList * )head->childList )->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel(const char *); - int contains(EntNode *); - int matches(EntNode *); - int isDependent(const char *); + int toplevel( const char * ); + int contains( EntNode * ); + int matches( EntNode * ); + int isDependent( const char * ); - EntNode *list; // List of all entities contained in this complex type, + EntNode * list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } - void write(ostream &); - int getEntListMaxLevel() - { + void write( ostream & ); + int getEntListMaxLevel() { return head->getMaxLevel(); } private: - void addSuper(Entity); - void addSubExp(Expression); - void addImplicitSubs(Linked_List, ComplexCollect *); - void addChildren(EntList *); - int hitMultNodes(EntNode *); + void addSuper( Entity ); + void addSubExp( Expression ); + void addImplicitSubs( Linked_List, ComplexCollect * ); + void addChildren( EntList * ); + int hitMultNodes( EntNode * ); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect -{ +class ComplexCollect { // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ComplexCollect(Express); - ~ComplexCollect() - { + ComplexCollect( Express ); + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); + void insert( ComplexList * ); + void remove( ComplexList * ); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList *find(char *); - int supports(EntNode *); - bool externMapping(const char *ent) - { - return (clists ? clists->isDependent(ent) : 0); + ComplexList * find( char * ); + int supports( EntNode * ); + bool externMapping( const char * ent ) { + return ( clists ? clists->isDependent( ent ) : 0 ); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write(const char *); + void write( const char * ); - ComplexList *clists; + ComplexList * clists; private: int count; // # of clist children @@ -477,6 +427,6 @@ class ComplexCollect // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex(ComplexCollect &, const char *); +void print_complex( ComplexCollect &, const char * ); #endif diff --git a/src/exp2cxx/complexlist.cc b/src/exp2cxx/complexlist.cc index 672f2e9f0..2a42c6d96 100644 --- a/src/exp2cxx/complexlist.cc +++ b/src/exp2cxx/complexlist.cc @@ -18,7 +18,7 @@ ComplexList::~ComplexList() * Destructor for ComplexList. */ { - if(next) { + if( next ) { delete next; } delete head; @@ -39,7 +39,7 @@ void ComplexList::remove() delete this; } -int ComplexList::toplevel(const char *name) +int ComplexList::toplevel( const char * name ) /* * Returns TRUE if name is already contained at the top level of our * EntList hierarchy. By top level, we mean the level under head. This @@ -47,14 +47,14 @@ int ComplexList::toplevel(const char *name) * a temporary CList to test entities which are subtypes of >1 supertype. */ { - EntList *slist = head->childList; + EntList * slist = head->childList; - while(slist) { - if(*(SimpleList *)slist == name) { + while( slist ) { + if( *( SimpleList * )slist == name ) { return TRUE; } slist = slist->next; - if(slist) { + if( slist ) { slist = slist->next; } } @@ -71,20 +71,20 @@ void ComplexList::buildList() * ComplexList certainly can't support it. */ { - EntList *sibling = head->childList->next; + EntList * sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if(list) { + if( list ) { delete list; } // Add first node based on supertype: - list = new EntNode(((SimpleList *)head->childList)->name); + list = new EntNode( ( ( SimpleList * )head->childList )->name ); // Recursively add all descendents: - while(sibling) { - addChildren(sibling); + while( sibling ) { + addChildren( sibling ); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -93,37 +93,37 @@ void ComplexList::buildList() } -void ComplexList::addChildren(EntList *ent) +void ComplexList::addChildren( EntList * ent ) /* * Recursive function to add all the SimpleList descendents of ent into * this's list. */ { - EntList *child; - char *nm; - EntNode *prev = list, *prev2 = NULL, *newnode; + EntList * child; + char * nm; + EntNode * prev = list, *prev2 = NULL, *newnode; int comp = 0; - if(ent->multiple()) { - child = ((MultList *)ent)->childList; - while(child) { - addChildren(child); + if( ent->multiple() ) { + child = ( ( MultList * )ent )->childList; + while( child ) { + addChildren( child ); child = child->next; } } else { - nm = (dynamic_cast< SimpleList * >(ent))->name; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + nm = ( dynamic_cast< SimpleList * >(ent) )->name; + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -135,7 +135,7 @@ void ComplexList::addChildren(EntList *ent) } } -int ComplexList::contains(EntNode *ents) +int ComplexList::contains( EntNode * ents ) /* * Does a simple search to determine if this contains all the nodes of an * EntNode list. If not, there's no way this will match ents. If so, @@ -144,13 +144,13 @@ int ComplexList::contains(EntNode *ents) * cally. */ { - EntNode *ours = list, *theirs = ents; + EntNode * ours = list, *theirs = ents; - while(theirs != NULL) { - while(ours != NULL && *ours < *theirs) { + while( theirs != NULL ) { + while( ours != NULL && *ours < *theirs ) { ours = ours->next; } - if(ours == NULL || *ours > *theirs) { + if( ours == NULL || *ours > *theirs ) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return FALSE; @@ -163,7 +163,7 @@ int ComplexList::contains(EntNode *ents) return TRUE; } -int ComplexList::matches(EntNode *ents) +int ComplexList::matches( EntNode * ents ) /* * Receives as input an EntNode list, corresponding to a user request to * instantiate the corresponding complex type. Returns TRUE if such a list @@ -176,32 +176,32 @@ int ComplexList::matches(EntNode *ents) // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if(! contains(ents)) { + if( ! contains( ents ) ) { return FALSE; } // Now start a thorough search through this ComplexList: - if((retval = head->matchNonORs(ents)) == MATCHALL) { + if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { result = TRUE; - } else if(retval != UNKNOWN) { + } else if( retval != UNKNOWN ) { result = FALSE; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if(((retval = head->matchORs(ents)) == MATCHALL) && - (hitMultNodes(ents))) { + if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && + ( hitMultNodes( ents ) ) ) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = TRUE; - } else if(retval >= MATCHSOME) { + } else if( retval >= MATCHSOME ) { MatchType otherChoices = NEWCHOICE; // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): - while(otherChoices == NEWCHOICE) { - otherChoices = head->tryNext(ents); - if(otherChoices == MATCHALL) { - if(hitMultNodes(ents)) { + while( otherChoices == NEWCHOICE ) { + otherChoices = head->tryNext( ents ); + if( otherChoices == MATCHALL ) { + if( hitMultNodes( ents ) ) { result = TRUE; } else { otherChoices = NEWCHOICE; @@ -217,7 +217,7 @@ int ComplexList::matches(EntNode *ents) return result; } -int ComplexList::isDependent(const char *ent) +int ComplexList::isDependent( const char * ent ) /* * Do any of our members tell us that ent cannot be instantiated indepen- * dently. This is the case if ent = one of the subtypes beneath and the @@ -229,22 +229,22 @@ int ComplexList::isDependent(const char *ent) * it could (must?) be created with internal mapping. */ { - EntList *elist = head->childList->next; + EntList * elist = head->childList->next; // We start searching from the first sibling after head->childList. head-> // childList represents the supertype (`A' in header comments) which though // it of course is AND'ed with all its subtypes, it doesn't make its sub's // non-independent. - if(elist->isDependent(ent) == TRUE) { + if( elist->isDependent( ent ) == TRUE ) { return TRUE; } - if(next) { - return (next->isDependent(ent)); + if( next ) { + return ( next->isDependent( ent ) ); } return FALSE; } -int ComplexList::hitMultNodes(EntNode *ents) +int ComplexList::hitMultNodes( EntNode * ents ) /* * This function has a specialized application. If the user wants to * instantiate a complex type containing an entity with >1 supertype (call @@ -259,34 +259,34 @@ int ComplexList::hitMultNodes(EntNode *ents) * also deals with the possibility that >1 entities like C exist.) */ { - EntNode *node; - EntList *child; + EntNode * node; + EntList * child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if(!multSupers) { + if( !multSupers ) { return TRUE; } - for(node = ents; node != NULL; node = node->next) { - if(node->multSuprs()) { + for( node = ents; node != NULL; node = node->next ) { + if( node->multSuprs() ) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while(child) { + while( child ) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if(child->contains(node->name)) { - if(! child->hit(node->name)) { + if( child->contains( node->name ) ) { + if( ! child->hit( node->name ) ) { return FALSE; } } child = child->next; - if(child) { + if( child ) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/exp2cxx/entlist.cc b/src/exp2cxx/entlist.cc index 8c9c47aef..e27114294 100644 --- a/src/exp2cxx/entlist.cc +++ b/src/exp2cxx/entlist.cc @@ -23,108 +23,108 @@ int EntList::siblings() */ { int count; - EntList *el; + EntList * el; - for(count = 1, el = next; el; count++, el = el->next) { + for( count = 1, el = next; el; count++, el = el->next ) { ; } return count; } -EntList *EntList::firstNot(JoinType j) +EntList * EntList::firstNot( JoinType j ) /* * Returns the first EntList not of type join, starting from this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList *EntList::firstWanted(MatchType match) +EntList * EntList::firstWanted( MatchType match ) /* * Returns the first EntList where viable = match, starting from this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList *EntList::lastNot(JoinType j) +EntList * EntList::lastNot( JoinType j ) /* * Returns the last EntList not of type join, searching backwards from * this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->prev; } return sibling; // (may = NULL) } -EntList *EntList::lastWanted(MatchType match) +EntList * EntList::lastWanted( MatchType match ) /* * Returns the last EntList where viable = match, searching backwards from * this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->prev; } return sibling; // (may = NULL) } -int SimpleList::isDependent(const char *ent) +int SimpleList::isDependent( const char * ent ) /* * Can we determine that ent can be instantiated independently (a Simple- * List could never tell us that an entity is dependent - only a AndList * could determine that.) */ { - if(!strcmp(name, ent)) { + if( !strcmp( name, ent ) ) { return FALSE; } return DONT_KNOW; } -void SimpleList::unmarkAll(EntNode *ents) +void SimpleList::unmarkAll( EntNode * ents ) /* * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp = -1; - if(viable < MATCHSOME) { + if( viable < MATCHSOME ) { return; } - while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { + while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if(eptr->mark <= I_marked) { + if( eptr->mark <= I_marked ) { // Only unmark if we gave it the strongest mark: - eptr->setmark(NOMARK); + eptr->setmark( NOMARK ); } // Either way (whether or not another List's mark remains), we no longer // marked: I_marked = NOMARK; } -int SimpleList::acceptChoice(EntNode *ents) +int SimpleList::acceptChoice( EntNode * ents ) /* * Marks whichever node we can mark. We assume there is a match because * this function is only called by a parent MultList if its child had a @@ -132,13 +132,13 @@ int SimpleList::acceptChoice(EntNode *ents) * node; otherwise FALSE. */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked()) { - eptr->setmark(ORMARK); + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked() ) { + eptr->setmark( ORMARK ); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -146,7 +146,7 @@ int SimpleList::acceptChoice(EntNode *ents) } return FALSE; // we didn't mark } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. return FALSE; } diff --git a/src/exp2cxx/entnode.cc b/src/exp2cxx/entnode.cc index c042660fa..50f3a8659 100644 --- a/src/exp2cxx/entnode.cc +++ b/src/exp2cxx/entnode.cc @@ -14,7 +14,7 @@ #include "complexSupport.h" #include -EntNode::EntNode(char *namelist[]) +EntNode::EntNode( char * namelist[] ) /* * Given a list of entity names, creates a sorted linked list of EntNodes * corresponding to the list. Final name must be "*" (otherwise we won't @@ -24,41 +24,41 @@ EntNode::EntNode(char *namelist[]) */ { int j = 1, comp = 0; - EntNode *prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - char *nm; + EntNode * prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + char * nm; // Create a first EntNode: - firstnode = prev = new EntNode(namelist[0]); + firstnode = prev = new EntNode( namelist[0] ); // The following 3 lines are a ridiculous kludge to simplify testing. // We make the assumption that ents whose name start with C or M have // >1 supertype. (We make sure this is the case in the test file.) // When this code becomes a part of the SCL, it'll be easy to get this // info right from the entity structs anyway, so I'm not bothering // writing anything more sophisticated. - if(*namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j') { - firstnode->multSuprs(TRUE); + if( *namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j' ) { + firstnode->multSuprs( TRUE ); } - while(*namelist[j] != '*') { + while( *namelist[j] != '*' ) { nm = namelist[j]; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); // Same kludge: - if(*nm == 'c' || *nm == 'm' || *nm == 'j') { - newnode->multSuprs(TRUE); + if( *nm == 'c' || *nm == 'm' || *nm == 'j' ) { + newnode->multSuprs( TRUE ); } newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -75,7 +75,7 @@ EntNode::EntNode(char *namelist[]) // Finally, place the contents of firstnode in 'this', and delete first- // node. This ensures that 'this' is first. - strcpy(name, firstnode->name); + strcpy( name, firstnode->name ); next = firstnode->next; multSupers = firstnode->multSupers; firstnode->next = NULL; @@ -83,14 +83,14 @@ EntNode::EntNode(char *namelist[]) delete firstnode; } -void EntNode::markAll(MarkType stamp) +void EntNode::markAll( MarkType stamp ) /* * Marks/unmarks all the nodes in this's list (default is to mark). */ { - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { + while( node != NULL ) { node->mark = stamp; node = node->next; } @@ -101,10 +101,10 @@ int EntNode::allMarked() * Returns TRUE if this and all nodes following it are marked. */ { - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { return FALSE; } node = node->next; @@ -118,10 +118,10 @@ int EntNode::unmarkedCount() */ { int count = 0; - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { count++; } node = node->next; diff --git a/src/exp2cxx/expressbuild.cc b/src/exp2cxx/expressbuild.cc index 932978839..a1c665656 100644 --- a/src/exp2cxx/expressbuild.cc +++ b/src/exp2cxx/expressbuild.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static void initEnts(Express); -static Entity findEnt(Entity, char *); +static void initEnts( Express ); +static Entity findEnt( Entity, char * ); -ComplexCollect::ComplexCollect(Express express) +ComplexCollect::ComplexCollect( Express express ) /* * Builds a ComplexCollect, a collection of ComplexLists, based on the * entities contained in EXPRESS file express. @@ -26,7 +26,7 @@ ComplexCollect::ComplexCollect(Express express) { DictionaryEntry de_sch, de_ent; Schema schema; - ComplexList *cl, *prev = NULL; + ComplexList * cl, *prev = NULL; // Some initializing: clists = NULL; @@ -35,26 +35,26 @@ ComplexCollect::ComplexCollect(Express express) // Set all ent->search_id's to 0. Since entities - even ones in different // schemas - may be strongly connected, we must be sure not to process each // one more than once. - initEnts(express); + initEnts( express ); // Next loop through all the entities, building ComplexLists: - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - SCOPEdo_entities(schema, ent, de_ent) - if(ent->search_id == TRUE) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + SCOPEdo_entities( schema, ent, de_ent ) + if( ent->search_id == TRUE ) { // we've hit this entity already continue; } #ifdef COMPLEX_INFO - cout << "Processing entity " << ENTITYget_name(ent) << endl; + cout << "Processing entity " << ENTITYget_name( ent ) << endl; #endif - if(ent->u.entity->subtypes != NULL) { - cl = new ComplexList(ent, this); + if( ent->u.entity->subtypes != NULL ) { + cl = new ComplexList( ent, this ); // This constructor will not only create a ComplexList for // the ent subtypes, but it will recurse for all of their // subtypes. The entire hierarchy will become a single // ComplexList and is now appended to the Collect ("this"). - insert(cl); + insert( cl ); } SCOPEod } @@ -64,13 +64,13 @@ ComplexCollect::ComplexCollect(Express express) // supercede them. (They were added in the first place to be available // so that any supertype which accessed it would find it.) cl = clists; - while(cl) { - if(cl->Dependent()) { + while( cl ) { + if( cl->Dependent() ) { #ifdef COMPLEX_INFO cout << "\nRemoving dependent entity " << cl->supertype() << endl; #endif - remove(cl); - if(prev) { + remove( cl ); + if( prev ) { cl = prev->next; // prev->next was automatically set to cl->next in remove() // when cl was removed. @@ -86,7 +86,7 @@ ComplexCollect::ComplexCollect(Express express) } } -static void initEnts(Express express) +static void initEnts( Express express ) /* * Sets all the search_id's of all the entities to FALSE. The search_id's * will be used to keep track of which entities we've build ComplexLists @@ -96,15 +96,15 @@ static void initEnts(Express express) DictionaryEntry de_sch, de_ent; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - SCOPEdo_entities(schema, ent, de_ent) + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = FALSE; SCOPEod } } -ComplexList::ComplexList(Entity ent, ComplexCollect *col) +ComplexList::ComplexList( Entity ent, ComplexCollect * col ) /* * Builds a complex list from an entity which contains subtypes. (All our * members are set here or in called functions except next which is set @@ -118,39 +118,39 @@ ComplexList::ComplexList(Entity ent, ComplexCollect *col) next = NULL; maxlevel = 0; - addSuper(ent); - if((exp = ent->u.entity->subtype_expression) != NULL) { + addSuper( ent ); + if( ( exp = ent->u.entity->subtype_expression ) != NULL ) { #ifdef COMPLEX_INFO cout << " Has a sub expression\n"; #endif - head->processSubExp(exp, ent, col); + head->processSubExp( exp, ent, col ); buildList(); } // Check for any subtypes which were not a part of subtype_expr. Any // subtype which was not in sub_exp but is included in subtypes is ANDORed // with the rest of the List. - addImplicitSubs(ENTITYget_subtypes(ent), col); + addImplicitSubs( ENTITYget_subtypes( ent ), col ); - if(ENTITYget_supertypes(ent) == NULL) { + if( ENTITYget_supertypes( ent ) == NULL ) { dependent = FALSE; // Rebuild list in case implicit subs were added (we had to build the // first time also so addImplicitSubs() would work). buildList(); //maxlevel = head->setLevel( 0 ); - head->setLevel(0); + head->setLevel( 0 ); } else { // If this List has supertypes, we don't really need it as a List - // it will ultimately be a part of its super(s)' List(s). We need it // now so its supers will be able to find it. But mark that this // does not stand on its own: #ifdef COMPLEX_INFO - cout << " " << ENTITYget_name(ent) << " is dependent\n"; + cout << " " << ENTITYget_name( ent ) << " is dependent\n"; #endif dependent = TRUE; } } -void ComplexList::addSuper(Entity ent) +void ComplexList::addSuper( Entity ent ) /* * Sets our supertype. Assumes supertype was previously unset. */ @@ -160,12 +160,12 @@ void ComplexList::addSuper(Entity ent) // (Although this supertype may itself be a subtype of other supertypes, // we call this a supertype. We only need this info during the list- // creation stage (see MultList::processSubExp()).) - head->childList = new SimpleList(ENTITYget_name(ent)); + head->childList = new SimpleList( ENTITYget_name( ent ) ); head->numchildren = 1; } -void MultList::processSubExp(Expression exp, Entity super, - ComplexCollect *col) +void MultList::processSubExp( Expression exp, Entity super, + ComplexCollect * col ) /* * Recursive function which builds an EntList hierarchy from an entity's * subtype expression. First called with this = the ComplexList->head and @@ -173,26 +173,26 @@ void MultList::processSubExp(Expression exp, Entity super, * process the subexpressions. */ { - struct Op_Subexpression *oe = &exp->e; + struct Op_Subexpression * oe = &exp->e; Entity ent; - MultList *mult; + MultList * mult; int supertype = 0; - switch(TYPEis(exp->type)) { + switch( TYPEis( exp->type ) ) { case entity_: - ent = findEnt(super, exp->type->symbol.name); + ent = findEnt( super, exp->type->symbol.name ); #ifdef COMPLEX_INFO - cout << " Adding subtype " << ENTITYget_name(ent) << endl; + cout << " Adding subtype " << ENTITYget_name( ent ) << endl; #endif - addSimpleAndSubs(ent, col); + addSimpleAndSubs( ent, col ); break; case op_: - if(join == AND) { - supertype = (dynamic_cast< AndList * >(this))->supertype; + if( join == AND ) { + supertype = ( dynamic_cast< AndList * >(this) )->supertype; } - if(! supertype && - ((oe->op_code == OP_AND && join == AND) - || (oe->op_code == OP_ANDOR && join == ANDOR))) { + if( ! supertype && + ( ( oe->op_code == OP_AND && join == AND ) + || ( oe->op_code == OP_ANDOR && join == ANDOR ) ) ) { // If the subexp is of the same type as we, process its op's at // the same level (add them on to our childList). 1st cond says // we don't do this if this is the supertype. In that case, the @@ -200,10 +200,10 @@ void MultList::processSubExp(Expression exp, Entity super, // a lower level. One reason for this is in case we find implicit // subtypes, we'll want to ANDOR them with the rest of the subs. // So we'll want the subs at a distinct lower level. - processSubExp(oe->op1, super, col); - processSubExp(oe->op2, super, col); + processSubExp( oe->op1, super, col ); + processSubExp( oe->op2, super, col ); } else { - if(oe->op_code == OP_AND) { + if( oe->op_code == OP_AND ) { #ifdef COMPLEX_INFO cout << " Processing AND\n"; #endif @@ -214,9 +214,9 @@ void MultList::processSubExp(Expression exp, Entity super, #endif mult = new AndOrList; } - appendList(mult); - mult->processSubExp(oe->op1, super, col); - mult->processSubExp(oe->op2, super, col); + appendList( mult ); + mult->processSubExp( oe->op1, super, col ); + mult->processSubExp( oe->op2, super, col ); } break; case oneof_: @@ -224,9 +224,9 @@ void MultList::processSubExp(Expression exp, Entity super, cout << " Processing ONEOF\n"; #endif mult = new OrList; - appendList(mult); - LISTdo(exp->u.list, arg, Expression) - mult->processSubExp(arg, super, col); + appendList( mult ); + LISTdo( exp->u.list, arg, Expression ) + mult->processSubExp( arg, super, col ); LISTod break; default: @@ -235,20 +235,20 @@ void MultList::processSubExp(Expression exp, Entity super, } } -static Entity findEnt(Entity ent0, char *name) +static Entity findEnt( Entity ent0, char * name ) /* * Returns an entity named name. The desired entity is likely to be in the * same schema as ent0. findEnt first searches the schema which contains * ent, and then searches the other schemas in the express file. */ { - Schema schema = ENTITYget_schema(ent0), sch; + Schema schema = ENTITYget_schema( ent0 ), sch; DictionaryEntry de_ent, de_sch; Express express; // First look through the entities in the same schema as ent0: - SCOPEdo_entities(schema, ent, de_ent) - if(!strcmp(ENTITYget_name(ent), name)) { + SCOPEdo_entities( schema, ent, de_ent ) + if( !strcmp( ENTITYget_name( ent ), name ) ) { return ent; } SCOPEod @@ -256,14 +256,14 @@ static Entity findEnt(Entity ent0, char *name) // If we still haven't found it, look through all the entities in the // express file: express = schema->superscope; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((sch = (Scope)DICTdo(&de_sch)) != 0) { - if(sch == schema) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( sch = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + if( sch == schema ) { // Don't redo the schema which contains ent0 - we did it already. continue; } - SCOPEdo_entities(sch, ent, de_ent) - if(!strcmp(ENTITYget_name(ent), name)) { + SCOPEdo_entities( sch, ent, de_ent ) + if( !strcmp( ENTITYget_name( ent ), name ) ) { return ent; } SCOPEod @@ -273,34 +273,34 @@ static Entity findEnt(Entity ent0, char *name) // complained already. } -void ComplexList::addImplicitSubs(Linked_List subs, ComplexCollect *col) +void ComplexList::addImplicitSubs( Linked_List subs, ComplexCollect * col ) /* * Checks if there are any subtypes of entity this->supertype() which were * not in the entity's subtype_expression. (subs is the entity's subtypes * list.) If any are found they are ANDORed with the other subtypes. */ { - EntNode node((char *)""); + EntNode node( ( char * )"" ); // Temp var - used to check if this already contains certain values. int none_yet = TRUE; - AndOrList *ao = 0; + AndOrList * ao = 0; - LISTdo(subs, subEnt, Entity) - strcpy(node.name, ENTITYget_name(subEnt)); - if(!contains(&node)) { + LISTdo( subs, subEnt, Entity ) + strcpy( node.name, ENTITYget_name( subEnt ) ); + if( !contains( &node ) ) { // We've found an implicit subtype. #ifdef COMPLEX_INFO - cout << " Adding implicit subtype " << ENTITYget_name(subEnt) + cout << " Adding implicit subtype " << ENTITYget_name( subEnt ) << endl; #endif - if(none_yet) { + if( none_yet ) { // If this is the first one, replace the previous subtype list // with an ANDOR. none_yet = FALSE; ao = new AndOrList; // Make the previous sub exp a child of ao: ao->childList = head->childList->next; - if(ao->childList) { + if( ao->childList ) { ao->childList->prev = NULL; ao->numchildren = 1; } else { @@ -312,12 +312,12 @@ void ComplexList::addImplicitSubs(Linked_List subs, ComplexCollect *col) } // Add the new entity to the end of ao. In case it has its own // subtype list, call addSimpleAndSubs(). - ao->addSimpleAndSubs(subEnt, col); + ao->addSimpleAndSubs( subEnt, col ); } LISTod } -void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) +void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) /* * Called whenever we have a SimpleList (to be built from newEnt) to add * to our ComplexList. The purpose of this function is to check if the @@ -326,17 +326,17 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) * SimpleList corresponding to newEnt. */ { - ComplexList *sublist; - SimpleList *simple; - EntList *newlist; - OrList *olist; + ComplexList * sublist; + SimpleList * simple; + EntList * newlist; + OrList * olist; // First get the easy case out of the way. If newEnt has no subtypes // just create a corresponding SimpleList: - if(ENTITYget_subtypes(newEnt) == NULL) { + if( ENTITYget_subtypes( newEnt ) == NULL ) { newEnt->search_id = TRUE; - simple = new SimpleList(ENTITYget_name(newEnt)); - appendList(simple); + simple = new SimpleList( ENTITYget_name( newEnt ) ); + appendList( simple ); return; } @@ -344,14 +344,14 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) #ifdef COMPLEX_INFO cout << " Subtype is a supertype ...\n"; #endif - if(newEnt->search_id == TRUE) { + if( newEnt->search_id == TRUE ) { // We've processed child already, find its ComplexList in col: #ifdef COMPLEX_INFO cout << " was built already ... finding it\n"; #endif - sublist = col->find(ENTITYget_name(newEnt)); + sublist = col->find( ENTITYget_name( newEnt ) ); // Make a copy and append to this: - newlist = copyList(sublist->head); + newlist = copyList( sublist->head ); } else { // If this subtype has never been visited, we build a ComplexList out // of it and add it to our ComplexCollect. Even though it only exists @@ -363,32 +363,32 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) #ifdef COMPLEX_INFO cout << " never built before ... building it now\n"; #endif - sublist = new ComplexList(newEnt, col); - col->insert(sublist); + sublist = new ComplexList( newEnt, col ); + col->insert( sublist ); // Since this is the first time we're creating this list, we don't need // to copy it and append to this, as above. We'll use the same Lists // again and also point to them from this. - appendList(sublist->head); + appendList( sublist->head ); newlist = sublist->head; } // If the sub-list is not abstract, one more task: - if(! newEnt->u.entity->abstract) { + if( ! newEnt->u.entity->abstract ) { // Since the subtype is not abstract, it can be instantiated without // its subtypes. Create an OrList OR'ing the supertype alone and its // entire List: olist = new OrList; - simple = new SimpleList((char *)sublist->supertype()); - olist->appendList(simple); + simple = new SimpleList( ( char * )sublist->supertype() ); + olist->appendList( simple ); // We just added "newlist" to the end of this. We now replace it with // our new or, and place it underneath the or. This OR's the new // subtype alone with the subtype + its own subtypes - just what we // want for a non-abstract subtype. - olist->appendList(newlist); + olist->appendList( newlist ); numchildren--; // (Slightly ugly: Since we just grabbed newlist from this to or, we // had the side effect of making this's numcount incorrect. I could // have done this more elegantly, but was lazy.) - appendList(olist); + appendList( olist ); } } diff --git a/src/exp2cxx/fedex_main.c b/src/exp2cxx/fedex_main.c index ded6b6aea..81c6f1515 100644 --- a/src/exp2cxx/fedex_main.c +++ b/src/exp2cxx/fedex_main.c @@ -80,61 +80,57 @@ #include -extern void print_fedex_version(void); +extern void print_fedex_version( void ); -static void exp2cxx_usage(void) -{ +static void exp2cxx_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n"); - fprintf(stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n"); - fprintf(stderr, "\t-L prints logging code in the generated C++ classes\n"); - fprintf(stderr, "\t-v produces the version description below\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-n do not pause for internal errors (useful with delta script)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); + fprintf( stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n" ); + fprintf( stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n" ); + fprintf( stderr, "\t-L prints logging code in the generated C++ classes\n" ); + fprintf( stderr, "\t-v produces the version description below\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-n do not pause for internal errors (useful with delta script)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); print_fedex_version(); - exit(2); + exit( 2 ); } -int Handle_FedPlus_Args(int, char *); -void print_file(Express); +int Handle_FedPlus_Args( int, char * ); +void print_file( Express ); -void resolution_success(void) -{ - printf("Resolution successful. Writing C++ output...\n"); +void resolution_success( void ) { + printf( "Resolution successful. Writing C++ output...\n" ); } -int success(Express model) -{ +int success( Express model ) { (void) model; /* unused */ - printf("Finished writing files.\n"); - return(0); + printf( "Finished writing files.\n" ); + return( 0 ); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat(EXPRESSgetopt_options, "sSlLaA"); + strcat( EXPRESSgetopt_options, "sSlLaA" ); ERRORusage_function = exp2cxx_usage; } diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index 2d21580b4..47004e43d 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -24,18 +24,16 @@ char header[ BUFSIZ ] = {0}; filenames_t fnames = { impl, header }; -filenames_t getEntityFilenames(Entity e) -{ - const char *name = ENTITYget_classname(e); - snprintf(header, BUFSIZ - 1, "entity/%s.h", name); - snprintf(impl, BUFSIZ - 1, "entity/%s.cc", name); +filenames_t getEntityFilenames( Entity e ) { + const char * name = ENTITYget_classname( e ); + snprintf( header, BUFSIZ-1, "entity/%s.h", name ); + snprintf( impl, BUFSIZ-1, "entity/%s.cc", name ); return fnames; } -filenames_t getTypeFilenames(Type t) -{ - const char *name = TYPEget_ctype(t); - snprintf(header, BUFSIZ - 1, "type/%s.h", name); - snprintf(impl, BUFSIZ - 1, "type/%s.cc", name); +filenames_t getTypeFilenames( Type t ) { + const char * name = TYPEget_ctype( t ); + snprintf( header, BUFSIZ-1, "type/%s.h", name ); + snprintf( impl, BUFSIZ-1, "type/%s.cc", name ); return fnames; } diff --git a/src/exp2cxx/genCxxFilenames.h b/src/exp2cxx/genCxxFilenames.h index 1bdc65561..f79d33cd6 100644 --- a/src/exp2cxx/genCxxFilenames.h +++ b/src/exp2cxx/genCxxFilenames.h @@ -13,8 +13,8 @@ typedef struct { /* will we ever need more file names? */ - const char *impl; - const char *header; + const char * impl; + const char * header; } filenames_t; /** write entity filenames to a pair of shared static buffers. @@ -22,13 +22,13 @@ typedef struct { * * \sa getTypeFilenames() */ -filenames_t getEntityFilenames(Entity e); +filenames_t getEntityFilenames( Entity e ); /** write type filenames to a pair of shared static buffers. * names will be overwritten by next call to a function using those buffers! * * \sa getEntityFilenames() */ -filenames_t getTypeFilenames(Type t); +filenames_t getTypeFilenames( Type t ); #endif /* GENCXXFILENAMES_H */ diff --git a/src/exp2cxx/match-ors.cc b/src/exp2cxx/match-ors.cc index ee2bd7f48..1b86622e4 100644 --- a/src/exp2cxx/match-ors.cc +++ b/src/exp2cxx/match-ors.cc @@ -16,7 +16,7 @@ #include "complexSupport.h" #include -MatchType AndOrList::matchORs(EntNode *ents) +MatchType AndOrList::matchORs( EntNode * ents ) /* * Loops through descendants of this, invoking their matchOR functions. * Returns the status of how well this's OR descendants match the nodes of @@ -27,27 +27,27 @@ MatchType AndOrList::matchORs(EntNode *ents) * is an OR, or has an OR somewhere beneath it which we must process now. */ { - EntList *child = childList->firstWanted(UNKNOWN); + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType AndList::matchORs(EntNode *ents) +MatchType AndList::matchORs( EntNode * ents ) /* * Loops through the descendants of this with viable val = UNKNOWN, invo- * king their matchOR functions. Returns the status of how well this's OR @@ -55,26 +55,26 @@ MatchType AndList::matchORs(EntNode *ents) * they will lead us to OR's, as explained in AndOrList::matchORs(). */ { - EntList *child = childList->firstWanted(UNKNOWN); + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType OrList::matchORs(EntNode *ents) +MatchType OrList::matchORs( EntNode * ents ) /* * Checks the branches of an OrList to search for a match to the nodes of * ents. This function searches this's children and marks all the viable @@ -85,41 +85,41 @@ MatchType OrList::matchORs(EntNode *ents) */ { int count; - EntList *child = childList; + EntList * child = childList; MatchType retval = UNKNOWN; - for(count = 0; count < numchildren; count++, child = child->next) { + for( count = 0; count < numchildren; count++, child = child->next ) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if(child->join != OR) { - retval = child->matchNonORs(ents); + if( child->join != OR ) { + retval = child->matchNonORs( ents ); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if(child->viable == UNKNOWN) { + if( child->viable == UNKNOWN ) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = (dynamic_cast< MultList * >(child))->matchORs(ents); + retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); } // Now register the result: - if(retval >= MATCHSOME) { + if( retval >= MATCHSOME ) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if(choice == -1) { + if( choice == -1 ) { choice1 = choice = count; } choiceCount++; - if(viable < retval) { + if( viable < retval ) { viable = retval; } } else { @@ -131,17 +131,17 @@ MatchType OrList::matchORs(EntNode *ents) // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if(viable < retval) { + if( viable < retval ) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll(ents); + child->unmarkAll( ents ); } // Accept the first viable solution, if there is one: - if(viable >= MATCHSOME) { + if( viable >= MATCHSOME ) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -150,10 +150,10 @@ MatchType OrList::matchORs(EntNode *ents) // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice(ents); + acceptChoice( ents ); } - if(viable == MATCHALL) { - return getChild(choice1)->viable; + if( viable == MATCHALL ) { + return getChild( choice1 )->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/exp2cxx/multlist.cc b/src/exp2cxx/multlist.cc index f19b02827..fb74cf5d1 100644 --- a/src/exp2cxx/multlist.cc +++ b/src/exp2cxx/multlist.cc @@ -20,38 +20,37 @@ MultList::~MultList() * Deletes the childList of this, before this is deleted. */ { - EntList *child = childList, *nxt; + EntList * child = childList, *nxt; - while(child) { + while( child ) { nxt = child->next; delete child; child = nxt; } } -void MultList::setLevel(int l) +void MultList::setLevel( int l ) /* * Sets this's level, and tells all its children to set their level to our * level +1. */ { - EntList *child = childList; + EntList * child = childList; level = l; - for(; child != NULL; child = child->next) { - child->setLevel(l + 1); + for( ; child != NULL; child = child->next ) { + child->setLevel( l + 1 ); } } -int MultList::getMaxLevel() -{ - EntList *child = childList; +int MultList::getMaxLevel() { + EntList * child = childList; int maxLevel, childLevel; maxLevel = level; - while(child) { + while( child ) { childLevel = child->getMaxLevel(); - if(childLevel > maxLevel) { + if( childLevel > maxLevel ) { maxLevel = childLevel; } child = child->next; @@ -60,15 +59,15 @@ int MultList::getMaxLevel() return maxLevel; } -int MultList::contains(const char *nm) +int MultList::contains( const char * nm ) /* * Check if one of this's descendants matches nm. */ { - EntList *child = childList; + EntList * child = childList; - while(child) { - if(child->contains(nm)) { + while( child ) { + if( child->contains( nm ) ) { return TRUE; } child = child->next; @@ -76,15 +75,15 @@ int MultList::contains(const char *nm) return FALSE; } -int MultList::hit(const char *nm) +int MultList::hit( const char * nm ) /* * Check if one of our descendants matches nm. */ { - EntList *child = childList; + EntList * child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -97,7 +96,7 @@ int MultList::hit(const char *nm) return FALSE; } -int MultList::isDependent(const char *ent) +int MultList::isDependent( const char * ent ) /* * Can one of our descendants tell us that entity ent can or cannot be * instantiated independently (i.e., not as a complex entity with external @@ -108,14 +107,14 @@ int MultList::isDependent(const char *ent) * Dependent(). */ { - EntList *child = childList; + EntList * child = childList; int result = DONT_KNOW, retval; - while(child) { - if((retval = child->isDependent(ent)) == FALSE) { + while( child ) { + if( ( retval = child->isDependent( ent ) ) == FALSE ) { return FALSE; } - if(retval == TRUE) { + if( retval == TRUE ) { // If child tells us that ent must be created together with another // leaf node (e.g., child is an AndList AND'ing ent + ent_b), save // the result. Don't return TRUE yet because a later child may @@ -130,7 +129,7 @@ int MultList::isDependent(const char *ent) // either DONT_KNOW or TRUE if we got here } -int AndList::isDependent(const char *ent) +int AndList::isDependent( const char * ent ) /* * Tells us if entity ent cannot be instantiated independently. Say ent * A is a supertype of ( B AND C ). Neither B nor C can be instantiated @@ -141,7 +140,7 @@ int AndList::isDependent(const char *ent) * if nothing can be determined, it returns DONT_KNOW. */ { - if(supertype) { + if( supertype ) { // If we're a supertype, we have to make one exception. Normally if // we're an AND of A & B and ent = A, we'd be able to conclude that A // requires ext mapping. But here, the first child of the AND is a @@ -150,7 +149,7 @@ int AndList::isDependent(const char *ent) // we skip the first child. We then continue to check if among the // subtypes of A there are children requiring ext mapping (such as B // AND C). - return (childList->next->isDependent(ent)); + return ( childList->next->isDependent( ent ) ); // NOTE - actually the algorithm for a supertype is more complex. We // did not address here the possibility that ent = the super (A). In // such a case, if A is non-abstract, then by def it can be instanti- @@ -174,8 +173,8 @@ int AndList::isDependent(const char *ent) // Next possibility: We don't represent a supertype. Thus, if we have >1 // child and ent is one of them, it can only be created by being AND'ed // with at least 1 other child. - if(numchildren > 1) { - if(contains(ent)) { + if( numchildren > 1 ) { + if( contains( ent ) ) { return TRUE; } return DONT_KNOW; @@ -184,36 +183,36 @@ int AndList::isDependent(const char *ent) // If we have 1 child only, just move on. At this point, the fact that // we're an AND didn't go very far in telling us that our children are // dependent on one another since we only *have* one child. - return (childList->isDependent(ent)); + return ( childList->isDependent( ent ) ); } -EntList *MultList::getChild(int num) +EntList * MultList::getChild( int num ) /* * Returns a pointer to the num'th child of MultList. */ { - EntList *child = childList; + EntList * child = childList; int j; - if(num < 0 || num >= numchildren) { + if( num < 0 || num >= numchildren ) { // Check for error situations (shouldn't normally occur): return NULL; } - for(j = 0; j < num; j++, child = child->next) { + for( j = 0; j < num; j++, child = child->next ) { ; } return child; } -void MultList::appendList(EntList *ent) +void MultList::appendList( EntList * ent ) /* * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ { - EntList *prv; + EntList * prv; - if(numchildren == 0) { + if( numchildren == 0 ) { childList = ent; } else { prv = getLast(); @@ -223,21 +222,21 @@ void MultList::appendList(EntList *ent) numchildren += ent->siblings(); } -EntList *MultList::copyList(EntList *ent) +EntList * MultList::copyList( EntList * ent ) /* * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ { - EntList *newlist = 0, *child; + EntList * newlist = 0, *child; - switch(ent->join) { + switch( ent->join ) { case SIMPLE: - newlist = new SimpleList((dynamic_cast< SimpleList * >(ent))->Name()); + newlist = new SimpleList( ( dynamic_cast< SimpleList * >(ent) )->Name() ); break; case AND: newlist = new AndList; - ((AndList *)newlist)->supertype = (dynamic_cast< AndList * >(ent))->supertype; + ( ( AndList * )newlist )->supertype = ( dynamic_cast< AndList * >(ent) )->supertype; break; case OR: newlist = new OrList; @@ -246,29 +245,29 @@ EntList *MultList::copyList(EntList *ent) newlist = new AndOrList; break; }; - appendList(newlist); - if(ent->multiple()) { + appendList( newlist ); + if( ent->multiple() ) { // For the multlists, we must recurse for all their children: - child = (dynamic_cast< MultList * >(ent))->childList; - while(child) { - (dynamic_cast< MultList * >(newlist))->copyList(child); + child = ( dynamic_cast< MultList * >(ent) )->childList; + while( child ) { + ( dynamic_cast< MultList * >(newlist) )->copyList( child ); child = child->next; } } return newlist; } -void MultList::unmarkAll(EntNode *ents) +void MultList::unmarkAll( EntNode * ents ) /* * Unmarks all nodes of ents marked by any of the descendants of this. * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ { - EntList *child = childList; + EntList * child = childList; - while(child != NULL) { - child->unmarkAll(ents); + while( child != NULL ) { + child->unmarkAll( ents ); child = child->next; } } @@ -279,15 +278,15 @@ void MultList::reset() * each child's reset function. */ { - EntList *child; + EntList * child; viable = UNKNOWN; - for(child = childList; child; child = child->next) { + for( child = childList; child; child = child->next ) { child->reset(); } } -void JoinList::setViableVal(EntNode *ents) +void JoinList::setViableVal( EntNode * ents ) /* * Sets this's viable value based on the value of its children. This is * called at the end of matchNonOR() and matchOR() to determine the result @@ -299,22 +298,22 @@ void JoinList::setViableVal(EntNode *ents) * worry about coming across them down here. */ { - EntList *child = childList; + EntList * child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while(child != NULL) { - if(child->viable == UNKNOWN) { + while( child != NULL ) { + if( child->viable == UNKNOWN ) { viable = UNKNOWN; return; } - if(child->viable > viable) { + if( child->viable > viable ) { viable = child->viable; } child = child->next; } - if(viable == MATCHALL && !ents->allMarked()) { + if( viable == MATCHALL && !ents->allMarked() ) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -323,18 +322,18 @@ void JoinList::setViableVal(EntNode *ents) } } -int JoinList::acceptChoice(EntNode *ents) +int JoinList::acceptChoice( EntNode * ents ) /* * Accept the path we're a part of: Mark all nodes of ents we can. Mark * value will = mark (either MARK or ORMARK). Return TRUE if we mark any- * thing; FALSE otherwise. */ { - EntList *child; + EntList * child; int result = FALSE; - for(child = childList; child != NULL; child = child->next) { - if(child->viable >= MATCHSOME) { + for( child = childList; child != NULL; child = child->next ) { + if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -345,7 +344,7 @@ int JoinList::acceptChoice(EntNode *ents) // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice(ents) || result; + result = child->acceptChoice( ents ) || result; // (NOTE - must run acceptChoice() first in above line. If result // were TRUE and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -354,17 +353,17 @@ int JoinList::acceptChoice(EntNode *ents) return result; } -int MultList::prevKnown(EntList *desc) +int MultList::prevKnown( EntList * desc ) /* * Specialized function to test that none of the children prior to desc * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ { - EntList *child = childList; + EntList * child = childList; - while(child != NULL && child != desc) { - if(child->viable == UNKNOWN) { + while( child != NULL && child != desc ) { + if( child->viable == UNKNOWN ) { return FALSE; } child = child->next; diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 0af0731e9..51a210ecb 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -37,21 +37,21 @@ #include -int isAggregateType(const Type t); +int isAggregateType( const Type t ); /* Local function prototypes: */ -static void initializeMarks(Express); -static void cleanupMarks(Express); -static void unsetObjs(Schema); -static bool checkTypes(Schema); -static bool checkEnts(Schema); -static void markDescs(Entity); -static bool checkItem(Type, Scope, Schema, int *, int); -static int ENUMcanBeProcessed(Type, Schema); -static int inSchema(Scope, Scope); -static void addRenameTypedefs(Schema, FILE *); -static void addAggrTypedefs(Schema, FILE *); -static void addUseRefNames(Schema, FILE *); +static void initializeMarks( Express ); +static void cleanupMarks( Express ); +static void unsetObjs( Schema ); +static bool checkTypes( Schema ); +static bool checkEnts( Schema ); +static void markDescs( Entity ); +static bool checkItem( Type, Scope, Schema, int *, int ); +static int ENUMcanBeProcessed( Type, Schema ); +static int inSchema( Scope, Scope ); +static void addRenameTypedefs( Schema, FILE * ); +static void addAggrTypedefs( Schema , FILE * ); +static void addUseRefNames( Schema, FILE * ); /** * Generates the C++ files corresponding to a list of schemas. Does so in @@ -63,45 +63,44 @@ static void addUseRefNames(Schema, FILE *); * select types which have enum or select items (or entities containing * enums) which have not been processed. */ -void print_schemas_separate(Express express, void *complexCol, FILES *files) -{ +void print_schemas_separate( Express express, void * complexCol, FILES * files ) { bool complete = false; int val1, val2, suffix; DictionaryEntry de; Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks(express); + initializeMarks( express ); /* TODO only print gr, wr, str as needed, from SCHEMAprint in classes_wrapper.cc? */ - fprintf(files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n"); + fprintf( files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n" ); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - numberAttributes(schema); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + numberAttributes( schema ); } - while(!complete) { + while( !complete ) { complete = true; - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - if(schema->search_id == UNPROCESSED) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + if( schema->search_id == UNPROCESSED ) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs(schema); + unsetObjs( schema ); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes(schema); - val2 = checkEnts(schema); + val1 = checkTypes( schema ); + val2 = checkEnts( schema ); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if(val1 || val2) { - if(schema->search_id == UNPROCESSED || - *(int *)schema->clientData > 0) { + if( val1 || val2 ) { + if( schema->search_id == UNPROCESSED || + *( int * )schema->clientData > 0 ) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -111,13 +110,13 @@ void print_schemas_separate(Express express, void *complexCol, FILES *files) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*(int *)schema->clientData; - SCHEMAprint(schema, files, complexCol, suffix); + suffix = ++*( int * )schema->clientData; + SCHEMAprint( schema, files, complexCol, suffix ); } else { - SCHEMAprint(schema, files, complexCol, 0); + SCHEMAprint( schema, files, complexCol, 0 ); } } - complete = complete && (schema->search_id == PROCESSED); + complete = complete && ( schema->search_id == PROCESSED ); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -127,53 +126,53 @@ void print_schemas_separate(Express express, void *complexCol, FILES *files) /******************* *******************/ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(files->create, - "//////////////// USE statements\n"); - USEREFout(schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( files->create, + "//////////////// USE statements\n" ); + USEREFout( schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create ); - fprintf(files->create, - "//////////////// REFERENCE statements\n"); - USEREFout(schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create); + fprintf( files->create, + "//////////////// REFERENCE statements\n" ); + USEREFout( schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create ); } /***************** *****************/ /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addRenameTypedefs(schema, files->classes); - addUseRefNames(schema, files->create); + addRenameTypedefs( schema, files->classes ); + addUseRefNames( schema, files->create ); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - addAggrTypedefs(schema, files->classes); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + addAggrTypedefs( schema, files->classes ); } /* On our way out, print the necessary statements to add support for // complex entities. (The 1st line below is a part of SchemaInit(), // which hasn't been closed yet. (That's done on 2nd line below.)) */ - fprintf(files->initall, " reg.SetCompCollect( gencomplex() );\n"); - fprintf(files->initall, "}\n\n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "ComplexCollect *gencomplex();\n"); + fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); + fprintf( files->initall, "}\n\n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); /* Function GetModelContents() is printed at the end of the schema.xx // files. This is done in a separate loop through the schemas, in function // below. */ - getMCPrint(express, files->incall, files->initall); + getMCPrint( express, files->incall, files->initall ); /* Finally clean up memory allocated by initializeMarks. */ - cleanupMarks(express); + cleanupMarks( express ); } -static void initializeMarks(Express express) +static void initializeMarks( Express express ) /* * Set all schema->search_id's to UNPROCESSED, meaning we haven't processed * all the ents and types in it yet. Also, put an int=0 in each schema's @@ -187,35 +186,34 @@ static void initializeMarks(Express express) DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { schema->search_id = UNPROCESSED; - schema->clientData = (int *)sc_malloc(sizeof(int)); - *(int *)schema->clientData = 0; - SCOPEdo_entities(schema, ent, de_ent) + schema->clientData = ( int * )sc_malloc( sizeof( int ) ); + *( int * )schema->clientData = 0; + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types(schema, t, de_type) + SCOPEdo_types( schema, t, de_type ) t->search_id = NOTKNOWN; SCOPEod } } -static void cleanupMarks(Express express) -{ +static void cleanupMarks( Express express ) { DictionaryEntry de_sch; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - if(schema->clientData) { - sc_free(schema->clientData); + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + if( schema->clientData ) { + sc_free( schema->clientData ); schema->clientData = NULL; } } } -static void unsetObjs(Schema schema) +static void unsetObjs( Schema schema ) /* * Resets all the ents & types of schema which had been set to CANTPROCRSS * to NOTKNOWN. This function is called every time print_schemas_separate @@ -228,13 +226,13 @@ static void unsetObjs(Schema schema) { DictionaryEntry de; - SCOPEdo_types(schema, t, de) - if(t->search_id == CANTPROCESS) { + SCOPEdo_types( schema, t, de ) + if( t->search_id == CANTPROCESS ) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities(schema, ent, de) - if(ent->search_id == CANTPROCESS) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id == CANTPROCESS ) { ent->search_id = NOTKNOWN; } SCOPEod @@ -252,8 +250,7 @@ static void unsetObjs(Schema schema) * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static bool checkTypes(Schema schema) -{ +static bool checkTypes( Schema schema ) { DictionaryEntry de; bool retval = false; int unknowncnt; @@ -263,8 +260,8 @@ static bool checkTypes(Schema schema) do { unknowncnt = 0; - SCOPEdo_types(schema, type, de) { - if(type->search_id != NOTKNOWN) { + SCOPEdo_types( schema, type, de ) { + if( type->search_id != NOTKNOWN ) { continue; } /* We're only interested in the ones which haven't been processed @@ -273,9 +270,9 @@ static bool checkTypes(Schema schema) type->search_id = CANPROCESS; /* Assume this until disproven. */ - if(TYPEis_enumeration(type) && TYPEget_head(type)) { - i = TYPEget_ancestor(type); - if(!sameSchema(i, type) && i->search_id != PROCESSED) { + if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { + i = TYPEget_ancestor( type ); + if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -284,10 +281,10 @@ static bool checkTypes(Schema schema) type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if(TYPEis_select(type)) { - LISTdo(SEL_TYPEget_items(type), ii, Type) { - if(!TYPEis_entity(ii)) { - if(checkItem(ii, type, schema, &unknowncnt, 0)) { + } else if( TYPEis_select( type ) ) { + LISTdo( SEL_TYPEget_items( type ), ii, Type ) { + if( !TYPEis_entity( ii ) ) { + if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { break; } /* checkItem does most of the work of determining if @@ -301,8 +298,8 @@ static bool checkTypes(Schema schema) } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity(ii); - if(ent->search_id == PROCESSED) { + ent = ENT_TYPEget_entity( ii ); + if( ent->search_id == PROCESSED ) { continue; } /* If entity has been processed already, things must be @@ -312,33 +309,31 @@ static bool checkTypes(Schema schema) // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes(ent); - LISTdo_n(attribs, attr, Variable, z) { - if(checkItem(attr->type, type, schema, - &unknowncnt, 1)) { + attribs = ENTITYget_all_attributes( ent ); + LISTdo_n( attribs, attr, Variable, z ) { + if( checkItem( attr->type, type, schema, + &unknowncnt, 1 ) ) { break; } - } - LISTod - LISTfree(attribs); + } LISTod + LISTfree( attribs ); } - } - LISTod + } LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if((type->search_id == CANPROCESS) - && ((i = TYPEget_ancestor(type)) != NULL) - && (!sameSchema(i, type)) - && (i->search_id != PROCESSED)) { + if( ( type->search_id == CANPROCESS ) + && ( ( i = TYPEget_ancestor( type ) ) != NULL ) + && ( !sameSchema( i, type ) ) + && ( i->search_id != PROCESSED ) ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if(type->search_id == CANPROCESS) { + if( type->search_id == CANPROCESS ) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -346,9 +341,8 @@ static bool checkTypes(Schema schema) // go on. */ retval = true; } - } - SCOPEod - } while(unknowncnt > 0); + } SCOPEod + } while( unknowncnt > 0 ); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -382,15 +376,14 @@ static bool checkTypes(Schema schema) * of the inline commenting of checkTypes() is applicable here and is not * repeated.) */ -static bool checkEnts(Schema schema) -{ +static bool checkEnts( Schema schema ) { DictionaryEntry de; bool retval = false; int ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities(schema, ent, de) - if(ent->search_id != NOTKNOWN) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id != NOTKNOWN ) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -402,10 +395,10 @@ static bool checkEnts(Schema schema) /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo(ENTITYget_supertypes(ent), super, Entity) - if((!sameSchema(ent, super)) - && (super->search_id != PROCESSED)) { - markDescs(ent); + LISTdo( ENTITYget_supertypes( ent ), super, Entity ) + if( ( !sameSchema( ent, super ) ) + && ( super->search_id != PROCESSED ) ) { + markDescs( ent ); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -415,17 +408,17 @@ static bool checkEnts(Schema schema) /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo(ENTITYget_attributes(ent), attr, Variable) - if(checkItem(attr->type, ent, schema, &ignore, 0)) { - markDescs(ent); + LISTdo( ENTITYget_attributes( ent ), attr, Variable ) + if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { + markDescs( ent ); break; } LISTod } - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -446,13 +439,11 @@ static bool checkEnts(Schema schema) * function is called if we've determined that ent is a subtype of an * entity defined in a different schema which has not yet been processed. */ -static void markDescs(Entity ent) -{ +static void markDescs( Entity ent ) { ent->search_id = CANTPROCESS; - LISTdo(ENTITYget_subtypes(ent), sub, Entity) { - markDescs(sub); - } - LISTod + LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) { + markDescs( sub ); + } LISTod } /** @@ -477,12 +468,11 @@ static void markDescs(Entity ent) * noSel is set to 1 to tell it to worry about t if it's an enum but not * if it's a select. */ -static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int noSel) -{ +static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, int noSel ) { Type i = t; - if(isAggregateType(t)) { - i = TYPEget_base_type(t); + if( isAggregateType( t ) ) { + i = TYPEget_base_type( t ); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -491,26 +481,26 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int // Sdaiclasses.h. */ } - if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { + if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if(parent->search_id == NOTKNOWN) { + if( parent->search_id == NOTKNOWN ) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - (*unknowncnt)--; + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if(TYPEis_select(i) && !noSel) { - if(!sameSchema(i, parent)) { - if(i->search_id != PROCESSED) { - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + } else if( TYPEis_select( i ) && !noSel ) { + if( !sameSchema( i, parent ) ) { + if( i->search_id != PROCESSED ) { + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -520,24 +510,24 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if(i->search_id == CANTPROCESS) { + if( i->search_id == CANTPROCESS ) { /* We *have* checked i already and it can't be processed. */ - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if(i->search_id == NOTKNOWN) { + } else if( i->search_id == NOTKNOWN ) { /* We haven't processed i this pass. */ - if(parent->search_id != NOTKNOWN) { + if( parent->search_id != NOTKNOWN ) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping thru the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - (*unknowncnt)++; + ( *unknowncnt )++; } } } @@ -545,7 +535,7 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int return false; } -static int ENUMcanBeProcessed(Type e, Schema s) +static int ENUMcanBeProcessed( Type e, Schema s ) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -557,31 +547,31 @@ static int ENUMcanBeProcessed(Type e, Schema s) { Type a; - if(!inSchema(e, s)) { + if( !inSchema( e, s ) ) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return (e->search_id == PROCESSED); + return ( e->search_id == PROCESSED ); } - if(e->search_id != NOTKNOWN) { + if( e->search_id != NOTKNOWN ) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return (e->search_id >= CANPROCESS); + return ( e->search_id >= CANPROCESS ); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if((a = TYPEget_ancestor(e)) == NULL) { + if( ( a = TYPEget_ancestor( e ) ) == NULL ) { /* If e is not a rename of anything, it should be processed now. */ return true; } - if(inSchema(a, s) || a->search_id == PROCESSED) { + if( inSchema( a, s ) || a->search_id == PROCESSED ) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return true; @@ -589,23 +579,23 @@ static int ENUMcanBeProcessed(Type e, Schema s) return false; } -int sameSchema(Scope sc1, Scope sc2) +int sameSchema( Scope sc1, Scope sc2 ) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return (!strcmp(SCOPEget_name(sc1->superscope), - SCOPEget_name(sc2->superscope))); + return ( !strcmp( SCOPEget_name( sc1->superscope ), + SCOPEget_name( sc2->superscope ) ) ); } -static int inSchema(Scope scope, Scope super) +static int inSchema( Scope scope, Scope super ) /* * Checks if scope is contained in super's scope. */ { - return (!strcmp(SCOPEget_name(scope->superscope), - SCOPEget_name(super))); + return ( !strcmp( SCOPEget_name( scope->superscope ), + SCOPEget_name( super ) ) ); } /** @@ -615,44 +605,42 @@ static int inSchema(Scope scope, Scope super) * (Actually, for the enum only the aggregate class name is written in * Sdaiclasses.h (needs to have forward declarations here).) */ -static void addRenameTypedefs(Schema schema, FILE *classes) -{ +static void addRenameTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; char nm[BUFSIZ], basenm[BUFSIZ]; static bool firsttime = true; - SCOPEdo_types(schema, t, de) { - if((TYPEis_enumeration(t) || TYPEis_select(t)) - && ((i = TYPEget_ancestor(t)) != NULL)) { + SCOPEdo_types( schema, t, de ) { + if( ( TYPEis_enumeration( t ) || TYPEis_select( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) ) { /* I.e., t is a renamed enum/sel type. i is set to the orig enum/ // sel t is based on (in case it's a rename of a rename etc). */ - if(firsttime) { - fprintf(classes, "\n// Renamed enum and select"); - fprintf(classes, " types (from all schemas):\n"); + if( firsttime ) { + fprintf( classes, "\n// Renamed enum and select" ); + fprintf( classes, " types (from all schemas):\n" ); firsttime = false; } - if(TYPEis_enumeration(t)) { - strncpy(nm, TYPEget_ctype(t), BUFSIZ - 1); - nm[BUFSIZ - 1] = '\0'; - strncpy(basenm, TYPEget_ctype(i), BUFSIZ - 1); - basenm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s_agg %s_agg;\n", basenm, nm); + if( TYPEis_enumeration( t ) ) { + strncpy( nm, TYPEget_ctype( t ), BUFSIZ - 1 ); + nm[BUFSIZ-1] = '\0'; + strncpy( basenm, TYPEget_ctype( i ), BUFSIZ - 1 ); + basenm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s_agg %s_agg;\n", basenm, nm ); } else { - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ - 1); - nm[BUFSIZ - 1] = '\0'; - strncpy(basenm, SelectName(TYPEget_name(i)), BUFSIZ - 1); - basenm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", basenm, nm); - fprintf(classes, "typedef %s_agg %s_agg;\n\n", basenm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ - 1 ); + nm[BUFSIZ-1] = '\0'; + strncpy( basenm, SelectName( TYPEget_name( i ) ), BUFSIZ - 1 ); + basenm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", basenm, nm ); + fprintf( classes, "typedef %s_agg %s_agg;\n\n", basenm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); } } - } - SCOPEod + } SCOPEod } /** @@ -662,35 +650,33 @@ static void addRenameTypedefs(Schema schema, FILE *classes) * called after addRenameTypedefs() since an aggregate may also be based on * one of the renamed enum/sel's defined there. */ -static void addAggrTypedefs(Schema schema, FILE *classes) -{ +static void addAggrTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; static bool firsttime = true; char nm[BUFSIZ]; - SCOPEdo_types(schema, t, de) { - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + SCOPEdo_types( schema, t, de ) { + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - if(firsttime) { - fprintf(classes, "\n// Aggregate types (from all schemas) which depend on other types:\n"); + if( firsttime ) { + fprintf( classes, "\n// Aggregate types (from all schemas) which depend on other types:\n" ); firsttime = false; } - strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); - fprintf(classes, "typedef %s * %sH;\n", nm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); + strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); + fprintf( classes, "typedef %s * %sH;\n", nm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); } } - } - SCOPEod + } SCOPEod } /** @@ -701,63 +687,62 @@ static void addAggrTypedefs(Schema schema, FILE *classes) * list will be used in the SCL to use the correct name of this type or * entity when reading and writing files. */ -static void addUseRefNames(Schema schema, FILE *create) -{ +static void addUseRefNames( Schema schema, FILE * create ) { Dictionary useRefDict; DictionaryEntry de; - Rename *rnm; - char *oldnm, schNm[BUFSIZ]; + Rename * rnm; + char * oldnm, schNm[BUFSIZ]; static bool firsttime = true; - if((useRefDict = schema->u.schema->usedict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { + if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if(firsttime) { - fprintf(create, " // Alternate names for types and entities when used in other schemas:\n"); + if( firsttime ) { + fprintf( create, " // Alternate names for types and entities when used in other schemas:\n" ); firsttime = false; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); } else { /* must be an entity */ - fprintf(create, " %s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, " %s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } - if((useRefDict = schema->u.schema->refdict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { - if(firsttime) { - fprintf(create, " // Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if( firsttime ) { + fprintf( create, " // Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = false; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); } else { - fprintf(create, " %s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, " %s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } diff --git a/src/exp2cxx/non-ors.cc b/src/exp2cxx/non-ors.cc index 8a4b24acf..2ef5dd803 100644 --- a/src/exp2cxx/non-ors.cc +++ b/src/exp2cxx/non-ors.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -MatchType SimpleList::matchNonORs(EntNode *ents) +MatchType SimpleList::matchNonORs( EntNode * ents ) /* * Checks if we match the nodes of ents. If only one unmarked is left * and we match it, return MATCHALL. More likely, we'll return one of the @@ -21,12 +21,12 @@ MatchType SimpleList::matchNonORs(EntNode *ents) * Support.h.) */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked(MARK)) { + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked( MARK ) ) { // NOTE - this cond also returns TRUE if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -35,13 +35,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if(eptr->mark == NOMARK) { + if( eptr->mark == NOMARK ) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if(ents->allMarked()) { + if( ents->allMarked() ) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -55,7 +55,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. break; } @@ -68,7 +68,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) return UNSATISFIED; } -MatchType AndOrList::matchNonORs(EntNode *ents) +MatchType AndOrList::matchNonORs( EntNode * ents ) /* * Loop through the children of this matching as many of the nodes of ents * as we can. We skip all OrList descendants. Those are processed later @@ -77,12 +77,12 @@ MatchType AndOrList::matchNonORs(EntNode *ents) * which are unnec. */ { - EntList *child = childList->firstNot(OR); + EntList * child = childList->firstNot( OR ); MatchType retval; - while(child != NULL) { - if((retval = child->matchNonORs(ents)) == MATCHALL) { - if(prevKnown(child)) { + while( child != NULL ) { + if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { + if( prevKnown( child ) ) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -109,39 +109,39 @@ MatchType AndOrList::matchNonORs(EntNode *ents) // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if(retval == UNSATISFIED) { + } else if( retval == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextNot(OR); + child = child->nextNot( OR ); } - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType AndList::matchNonORs(EntNode *ents) +MatchType AndList::matchNonORs( EntNode * ents ) /* * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ { - EntList *child = childList->firstNot(OR); + EntList * child = childList->firstNot( OR ); - while(child != NULL) { - if(child->matchNonORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( child->matchNonORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot(OR); + child = child->nextNot( OR ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } diff --git a/src/exp2cxx/orlist.cc b/src/exp2cxx/orlist.cc index 4b90b01cf..dd0c9db88 100644 --- a/src/exp2cxx/orlist.cc +++ b/src/exp2cxx/orlist.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -int OrList::hit(const char *nm) +int OrList::hit( const char * nm ) /* * Check if we matched nm. We have two possibilities here: If we have a * choice selected, we only check the selected choice. Say we're an OR @@ -27,15 +27,15 @@ int OrList::hit(const char *nm) * may need to check if all sub-CLists matched the multi-sub, C.) */ { - EntList *child = getChild(choice); + EntList * child = getChild( choice ); - if(child) { + if( child ) { // I.e., if we have a choice selected, check it only. - return (child->hit(nm)); + return ( child->hit( nm ) ); } else { child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // See MultList::hit() on why we must skip UNSATs. return TRUE; } @@ -45,20 +45,20 @@ int OrList::hit(const char *nm) return FALSE; } -void OrList::unmarkAll(EntNode *ents) +void OrList::unmarkAll( EntNode * ents ) /* * Unmarks all the nodes of ents marked by the descendants of this. */ { - EntList *child; + EntList * child; - if((child = getChild(choice)) != NULL) { + if( ( child = getChild( choice ) ) != NULL ) { // choice = the last selected path which we'll now undo. - child->unmarkAll(ents); + child->unmarkAll( ents ); } } -int OrList::acceptChoice(EntNode *ents) +int OrList::acceptChoice( EntNode * ents ) /* * Accepts the first choice of our childList which marks any unmarked * nodes. If none of our current choices mark anything, choice is set to @@ -66,14 +66,14 @@ int OrList::acceptChoice(EntNode *ents) * choice to choice1, and search again. */ { - EntList *child; + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { choice = choice1; } - child = getChild(choice); - while(child) { - if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { + child = getChild( choice ); + while( child ) { + if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { // acceptChoice() returns TRUE if we marked something. return TRUE; } diff --git a/src/exp2cxx/print.cc b/src/exp2cxx/print.cc index 837592405..0b1398a6d 100644 --- a/src/exp2cxx/print.cc +++ b/src/exp2cxx/print.cc @@ -11,14 +11,14 @@ #include // Local function prototypes: -static char *joinText(JoinType, char *); +static char * joinText( JoinType, char * ); -ostream &operator << (ostream &os, ComplexList &clist) +ostream & operator << ( ostream & os, ComplexList & clist ) /* * Prints out a ComplexList, by iterating through its children. */ { - os << "ComplexList - \"" << *(SimpleList *)clist.head->childList + os << "ComplexList - \"" << *( SimpleList * )clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -26,20 +26,20 @@ ostream &operator << (ostream &os, ComplexList &clist) return os; } -ostream &operator << (ostream &os, EntList &list) +ostream & operator << ( ostream & os, EntList & list ) /* * Prints out an EntList. Calls appropriate function based on JoinType. */ { - if(list.join == SIMPLE) { - os << *(SimpleList *)&list; + if( list.join == SIMPLE ) { + os << *( SimpleList * )&list; } else { - os << *(MultList *)&list; + os << *( MultList * )&list; } return os; } -ostream &operator << (ostream &os, SimpleList &slist) +ostream & operator << ( ostream & os, SimpleList & slist ) /* * Prints out a SimpleList. */ @@ -48,7 +48,7 @@ ostream &operator << (ostream &os, SimpleList &slist) return os; } -ostream &operator << (ostream &os, MultList &mlist) +ostream & operator << ( ostream & os, MultList & mlist ) /* * Prints out a MultList. */ @@ -57,21 +57,21 @@ ostream &operator << (ostream &os, MultList &mlist) int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList *child = mlist.childList; + EntList * child = mlist.childList; - os << joinText(mlist.join, jointype) << endl; - for(k = 0; k <= mlist.level; k++) { + os << joinText( mlist.join, jointype ) << endl; + for( k = 0; k <= mlist.level; k++ ) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while(child != NULL) { + while( child != NULL ) { os << *child; - if(child->next == NULL) { - lastSimple = (child->join == SIMPLE); + if( child->next == NULL ) { + lastSimple = ( child->join == SIMPLE ); break; // We don't want to do the conditions below if we're done. } - if(child->join == SIMPLE) { + if( child->join == SIMPLE ) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -79,35 +79,35 @@ ostream &operator << (ostream &os, MultList &mlist) // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for(k = 0; k <= mlist.level; k++) { + for( k = 0; k <= mlist.level; k++ ) { os << " "; } } child = child->next; } - if(lastSimple) { + if( lastSimple ) { os << endl; } return os; } -static char *joinText(JoinType j, char *buf) +static char * joinText( JoinType j, char * buf ) /* * Copies and returns the string equivalent of a JoinType. */ { - switch(j) { + switch( j ) { case SIMPLE: - strcpy(buf, "SIMPLE"); + strcpy( buf, "SIMPLE" ); return buf; case AND: - strcpy(buf, "AND"); + strcpy( buf, "AND" ); return buf; case OR: - strcpy(buf, "OR"); + strcpy( buf, "OR" ); return buf; case ANDOR: - strcpy(buf, "ANDOR"); + strcpy( buf, "ANDOR" ); return buf; }; return NULL; diff --git a/src/exp2cxx/rules.c b/src/exp2cxx/rules.c index 3d39a3080..6dfe7aa96 100644 --- a/src/exp2cxx/rules.c +++ b/src/exp2cxx/rules.c @@ -5,62 +5,57 @@ #include /* print Where_rule's. for types, schema should be null - tename will include schema name */ -void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR) -{ - if(wheres) { - fprintf(impl, " %s%s%s->_where_rules = new Where_rule__list;\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); - if(needWR) { - fprintf(impl, " Where_rule * wr;\n"); +void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ) { + if( wheres ) { + fprintf( impl, " %s%s%s->_where_rules = new Where_rule__list;\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); + if( needWR ) { + fprintf( impl, " Where_rule * wr;\n" ); } - LISTdo(wheres, w, Where) { - fprintf(impl, " str.clear();\n"); - if(w->label) { - fprintf(impl, " str.append( \"%s: (\" );\n", w->label->name); + LISTdo( wheres, w, Where ) { + fprintf( impl, " str.clear();\n"); + if( w->label ) { + fprintf( impl, " str.append( \"%s: (\" );\n", w->label->name ); } else { /* no label */ - fprintf(impl, " str.append( \"(\" );\n"); + fprintf( impl, " str.append( \"(\" );\n"); } - format_for_std_stringout(impl, EXPRto_string(w->expr)); + format_for_std_stringout( impl, EXPRto_string( w->expr ) ); - fprintf(impl, " str.append( \");\\n\" );\n"); + fprintf( impl, " str.append( \");\\n\" );\n"); - fprintf(impl, " wr = new Where_rule( str.c_str() );\n"); - fprintf(impl, " %s%s%s->_where_rules->Append( wr );\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); + fprintf( impl, " wr = new Where_rule( str.c_str() );\n" ); + fprintf( impl, " %s%s%s->_where_rules->Append( wr );\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); - } - LISTod + } LISTod } } /* print Uniqueness_rule's */ -void UNIQUEprint(Entity entity, FILE *impl, Schema schema) -{ +void UNIQUEprint( Entity entity, FILE * impl, Schema schema ) { Linked_List uniqs = entity->u.entity->unique; - if(uniqs) { - fprintf(impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(impl, " Uniqueness_rule * ur;\n"); - LISTdo(uniqs, list, Linked_List) { + if( uniqs ) { + fprintf( impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( impl, " Uniqueness_rule * ur;\n" ); + LISTdo( uniqs, list, Linked_List ) { int i = 0; - fprintf(impl, " str.clear();\n"); - LISTdo_n(list, e, Expression, b) { + fprintf( impl, " str.clear();\n"); + LISTdo_n( list, e, Expression, b ) { i++; - if(i == 1) { + if( i == 1 ) { /* print label if present */ - if(e) { - fprintf(impl, " str.append( \"%s : \" );\n", StrToUpper(((Symbol *)e)->name)); + if( e ) { + fprintf( impl, " str.append( \"%s : \" );\n", StrToUpper( ( ( Symbol * )e )->name ) ); } } else { - if(i > 2) { - fprintf(impl, " str.append( \", \" );\n"); + if( i > 2 ) { + fprintf( impl, " str.append( \", \" );\n"); } - format_for_std_stringout(impl, EXPRto_string(e)); + format_for_std_stringout( impl, EXPRto_string( e ) ); } - } - LISTod - fprintf(impl, " ur = new Uniqueness_rule( str.c_str() );\n"); - fprintf(impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - } - LISTod + } LISTod + fprintf( impl, " ur = new Uniqueness_rule( str.c_str() );\n" ); + fprintf( impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + } LISTod } } diff --git a/src/exp2cxx/rules.h b/src/exp2cxx/rules.h index 3ad7d8d32..6f6e77cfb 100644 --- a/src/exp2cxx/rules.h +++ b/src/exp2cxx/rules.h @@ -4,10 +4,10 @@ #include /** print Where_rule's. for types, schema should be null - tename will include schema name + type prefix */ -void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR); +void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ); /** print Uniqueness_rule's. only Entity type has them? */ -void UNIQUEprint(Entity entity, FILE *impl, Schema schema); +void UNIQUEprint( Entity entity, FILE * impl, Schema schema ); #endif /* RULES_H */ diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 1360e3551..b4fd3e60d 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -34,7 +34,7 @@ extern int multiple_inheritance; ((t)->u.type->body->type == integer_) || \ ((t)->u.type->body->type == number_) ) #define PRINT_BUG_REPORT \ - fprintf( f, "std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ + fprintf( f, " std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ " in schema library: \\n\" \n << _POC_ << \"\\n\\n\";\n"); #define PRINT_SELECTBUG_WARNING(f) \ @@ -52,31 +52,28 @@ extern int multiple_inheritance; #define TRUE 1 #define FALSE 0 -static void initSelItems(const Type, FILE *); +static void initSelItems( const Type, FILE * ); -const char *SEL_ITEMget_enumtype(Type t) -{ - return StrToUpper(TYPEget_name(t)); +const char * SEL_ITEMget_enumtype( Type t ) { + return StrToUpper( TYPEget_name( t ) ); } /** \returns type used to represent the underlying type in a select class */ -const char *TYPEget_utype(Type t) -{ - return (TYPEis_entity(t) ? "SDAI_Application_instance_ptr" : TYPEget_ctype(t)); +const char * TYPEget_utype( Type t ) { + return ( TYPEis_entity( t ) ? "SDAI_Application_instance_ptr" : TYPEget_ctype( t ) ); } /** determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. */ -void *LISTmember(const Linked_List list, void *e) -{ +void *LISTmember( const Linked_List list, void *e ) { Link node; - for(node = list->mark->next; node != list->mark; node = node->next) - if(e == node -> data) { + for( node = list->mark->next; node != list->mark; node = node->next ) + if( e == node -> data ) { return e; } - return (0); + return ( 0 ); } /** Specialized function to catch if two enumerations, two selects, or two aggrs @@ -87,19 +84,18 @@ void *LISTmember(const Linked_List list, void *e) equivalent. This function is called in instances when they should be consi- dered equivalent. One such case is the generation of duplicate lists. */ -static int compareOrigTypes(Type a, Type b) -{ +static int compareOrigTypes( Type a, Type b ) { Type t, u; - if((TYPEis_select(a) && TYPEis_select(b)) - || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { + if( ( TYPEis_select( a ) && TYPEis_select( b ) ) + || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { t = a; u = b; - } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { - t = TYPEget_base_type(a); - u = TYPEget_base_type(b); - if(!((TYPEis_select(t) && TYPEis_select(u)) - || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { + } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { + t = TYPEget_base_type( a ); + u = TYPEget_base_type( b ); + if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) + || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that for 2D aggrs and higher we do not continue. These are all recog- @@ -110,13 +106,13 @@ static int compareOrigTypes(Type a, Type b) return FALSE; } - if(TYPEget_head(t)) { - t = TYPEget_ancestor(t); + if( TYPEget_head( t ) ) { + t = TYPEget_ancestor( t ); } - if(TYPEget_head(u)) { - u = TYPEget_ancestor(u); + if( TYPEget_head( u ) ) { + u = TYPEget_ancestor( u ); } - return (!strcmp(TYPEget_name(t), TYPEget_name(u))); + return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); } /** determines if the given "link's" underlying type is a member of the list. @@ -126,20 +122,19 @@ static int compareOrigTypes(Type a, Type b) list already has an item that check is a renaming of (see header comments to compareOrigTypes() above). */ -const char *utype_member(const Linked_List list, const Type check, int rename) -{ +const char * utype_member( const Linked_List list, const Type check, int rename ) { static char r [BUFSIZ]; - bool checkIsEntity = TYPEis_entity(check); + bool checkIsEntity = TYPEis_entity( check ); - LISTdo(list, t, Type) { - if(TYPEis_entity(t) && checkIsEntity) { + LISTdo( list, t, Type ) { + if( TYPEis_entity( t ) && checkIsEntity ) { return "SDAI_Application_instance_ptr"; } /* string returned by TYPEget_utype isn't necessarily static so we * need to copy between calls * */ - strncpy(r, TYPEget_ctype(t), BUFSIZ); - if(strcmp(r, TYPEget_ctype(check)) == 0 || (rename && compareOrigTypes(check, t))) { + strncpy( r, TYPEget_ctype( t ), BUFSIZ ); + if( strcmp( r, TYPEget_ctype( check ) ) == 0 || ( rename && compareOrigTypes( check, t ) ) ) { return r; } } @@ -153,16 +148,15 @@ const char *utype_member(const Linked_List list, const Type check, int rename) * * The list that is returned needs to be freed by the caller. */ -Linked_List SELgetnew_dmlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SELgetnew_dmlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); - LISTdo(complete, t, Type) + LISTdo( complete, t, Type ) /* if t\'s underlying type is not already in newlist, */ - if(! utype_member(newlist, t, 0)) { - LISTadd_last(newlist, t); + if( ! utype_member( newlist, t, 0 ) ) { + LISTadd_last( newlist, t ); } LISTod; @@ -171,10 +165,9 @@ Linked_List SELgetnew_dmlist(const Type type) } -const char *SEL_ITEMget_dmtype(Type t, const Linked_List l) -{ - const char *r = utype_member(l, t, 0); - return StrToLower(r ? r : TYPEget_utype(t)); +const char * SEL_ITEMget_dmtype( Type t, const Linked_List l ) { + const char * r = utype_member( l, t, 0 ); + return StrToLower( r ? r : TYPEget_utype( t ) ); } @@ -183,50 +176,48 @@ const char *SEL_ITEMget_dmtype(Type t, const Linked_List l) * Logical and boolean are handled as exceptions because TYPEget_utype() * returns "PSDAI::..." for them which is not a legal variable name. */ -const char *SEL_ITEMget_dmname(Type t) -{ - Class_Of_Type class = TYPEget_type(t); +const char * SEL_ITEMget_dmname( Type t ) { + Class_Of_Type class = TYPEget_type( t ); - if(class == integer_) { + if( class == integer_ ) { return "integer"; } - if(class == real_) { + if( class == real_ ) { return "real"; } - if(class == number_) { + if( class == number_ ) { return "real"; } - if(class == string_) { + if( class == string_ ) { return "string"; } - if(class == binary_) { + if( class == binary_ ) { return "binary"; } - if(class == logical_) { + if( class == logical_ ) { return "logical"; } - if(class == boolean_) { + if( class == boolean_ ) { return "boolean"; } - if(class == entity_) { + if( class == entity_ ) { return "app_inst"; } - return (StrToLower(TYPEget_utype(t))); + return ( StrToLower( TYPEget_utype( t ) ) ); } /** determines if the given "link's" underlying type is a multiple member of the list. RETURNS 1 if true, else 0. */ -int duplicate_in_express_list(const Linked_List list, const Type check) -{ - if(TYPEis_entity(check)) { +int duplicate_in_express_list( const Linked_List list, const Type check ) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; /* don't compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -239,10 +230,9 @@ int duplicate_in_express_list(const Linked_List list, const Type check) underlying Express type. RETURNS 1 if true, else 0. */ -int unique_types(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_in_express_list(list, t)) { +int unique_types( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_in_express_list( list, t ) ) { return FALSE; } LISTod; @@ -253,30 +243,29 @@ int unique_types(const Linked_List list) /** determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. */ -int duplicate_utype_member(const Linked_List list, const Type check) -{ +int duplicate_utype_member( const Linked_List list, const Type check ) { char b [BUFSIZ]; - if(TYPEis_entity(check)) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; } /* don't compare check to itself */ else { /* continue looking */ - strncpy(b, TYPEget_utype(t), BUFSIZ); - if((!strcmp(b, TYPEget_utype(check))) - || (compareOrigTypes(t, check))) + strncpy( b, TYPEget_utype( t ), BUFSIZ ); + if( ( !strcmp( b, TYPEget_utype( check ) ) ) + || ( compareOrigTypes( t, check ) ) ) /* if the underlying types are the same */ { return TRUE; } - if(! strcmp(b, "SDAI_Integer") && - (! strcmp(TYPEget_utype(check), "SDAI_Real"))) + if( ! strcmp( b, "SDAI_Integer" ) && + ( ! strcmp( TYPEget_utype( check ), "SDAI_Real" ) ) ) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -290,10 +279,9 @@ int duplicate_utype_member(const Linked_List list, const Type check) C++ representation for the underlying Express type. RETURNS 1 if true, else 0. */ -int any_duplicates_in_select(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_utype_member(list, t)) { +int any_duplicates_in_select( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_utype_member( list, t ) ) { return TRUE; } LISTod; @@ -305,25 +293,24 @@ This list is returned as dup_list. If a duplicate exists, the function returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. */ -int find_duplicate_list(const Type type, Linked_List *duplicate_list) -{ +int find_duplicate_list( const Type type, Linked_List * duplicate_list ) { Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if(any_duplicates_in_select(SEL_TYPEget_items(type))) { + if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo(SEL_TYPEget_items(type), u, Type) - if(!utype_member(*duplicate_list, u, 1)) { + LISTdo( SEL_TYPEget_items( type ), u, Type ) + if( !utype_member( *duplicate_list, u, 1 ) ) { /** if not already a duplicate **/ - if(utype_member(temp, u, 1)) { - LISTadd_first(*duplicate_list, u); + if( utype_member( temp, u, 1 ) ) { + LISTadd_first( *duplicate_list, u ); } else { - LISTadd_first(temp, u); + LISTadd_first( temp, u ); } } LISTod; - LISTfree(temp); + LISTfree( temp ); return TRUE; } return FALSE; @@ -351,10 +338,9 @@ enum __types { leaves. It passes around the vector described above, to track paths to the leaf nodes. */ -void non_unique_types_vector(const Type type, int *tvec) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - switch(TYPEget_body(t)->type) { +void non_unique_types_vector( const Type type, int * tvec ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + switch( TYPEget_body( t )->type ) { case integer_: tvec[tint]++; break; @@ -374,7 +360,7 @@ void non_unique_types_vector(const Type type, int *tvec) break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector(t, tvec); + non_unique_types_vector( t, tvec ); break; case entity_: tvec[tentity]++; @@ -390,8 +376,8 @@ void non_unique_types_vector(const Type type, int *tvec) tvec[tnumber]++; break; default: - fprintf(stderr, "non_unique_types_vector: can't handle unknown type %d\n", - TYPEget_body(t)->type); + fprintf( stderr, "non_unique_types_vector: can't handle unknown type %d\n", + TYPEget_body( t )->type ); abort(); } LISTod; @@ -402,60 +388,59 @@ void non_unique_types_vector(const Type type, int *tvec) (FOO_TYPE | BAR_TYPE | BAZ_TYPE), where FOO, BAR, and BAZ are EXPRESS types. If all types are unique, the string (0) is generated. */ -char *non_unique_types_string(const Type type) -{ +char * non_unique_types_string( const Type type ) { int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char *typestr; + char * typestr; int first = 1; int i; - non_unique_types_vector(type, tvec); + non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = (char *)sc_malloc(BUFSIZ); + typestr = ( char * )sc_malloc( BUFSIZ ); typestr[0] = '\0'; - strcat(typestr, (char *)"("); - for(i = 0; i <= tnumber; i++) { - if(tvec[i] < 2) { + strcat( typestr, ( char * )"(" ); + for( i = 0; i <= tnumber; i++ ) { + if( tvec[i] < 2 ) { continue; /* skip, this one is unique */ } - if(!first) { - strcat(typestr, (char *)" | "); + if( !first ) { + strcat( typestr, ( char * )" | " ); } else { first = 0; } - switch(i) { + switch( i ) { case tint : - strcat(typestr, (char *)"sdaiINTEGER"); + strcat( typestr, ( char * )"sdaiINTEGER" ); break; case treal : - strcat(typestr, (char *)"sdaiREAL"); + strcat( typestr, ( char * )"sdaiREAL" ); break; case tstring: - strcat(typestr, (char *)"sdaiSTRING"); + strcat( typestr, ( char * )"sdaiSTRING" ); break; case tbinary: - strcat(typestr, (char *)"sdaiBINARY"); + strcat( typestr, ( char * )"sdaiBINARY" ); break; case tenum : - strcat(typestr, (char *)"sdaiENUMERATION"); + strcat( typestr, ( char * )"sdaiENUMERATION" ); break; case tentity: - strcat(typestr, (char *)"sdaiINSTANCE"); + strcat( typestr, ( char * )"sdaiINSTANCE" ); break; case taggr : - strcat(typestr, (char *)"sdaiAGGR"); + strcat( typestr, ( char * )"sdaiAGGR" ); break; case tnumber: - strcat(typestr, (char *)"sdaiNUMBER"); + strcat( typestr, ( char * )"sdaiNUMBER" ); break; } } - if(first) { - strcat(typestr, (char *)"0"); + if( first ) { + strcat( typestr, ( char * )"0" ); } - strcat(typestr, (char *)")"); + strcat( typestr, ( char * )")" ); return typestr; } @@ -464,20 +449,18 @@ char *non_unique_types_string(const Type type) /** checks to see if an attribute is a member of the list * \returns the attribute 'check' if an attribute with the same name is on the list, 0 otherwise */ -Variable ATTR_LISTmember(Linked_List l, Variable check) -{ +Variable ATTR_LISTmember( Linked_List l, Variable check ) { char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name(check, nm); - LISTdo(l, a, Variable) { - generate_attribute_name(a, cur); - if(! strcmp(nm, cur)) { + generate_attribute_name( check, nm ); + LISTdo( l, a, Variable ) { + generate_attribute_name( a, cur ); + if( ! strcmp( nm, cur ) ) { return check; } - } - LISTod; - return (0); + } LISTod; + return ( 0 ); } @@ -485,241 +468,236 @@ Variable ATTR_LISTmember(Linked_List l, Variable check) * Side Effects: * The list that is returned needs to be freed by the caller. */ -Linked_List SEL_TYPEgetnew_attribute_list(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SEL_TYPEgetnew_attribute_list( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo(complete, t, Type) { - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - attrs = ENTITYget_all_attributes(cur); - LISTdo_n(attrs, a, Variable, b) { - if(! ATTR_LISTmember(newlist, a)) { - LISTadd_first(newlist, a); + LISTdo( complete, t, Type ) { + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + attrs = ENTITYget_all_attributes( cur ); + LISTdo_n( attrs, a, Variable, b ) { + if( ! ATTR_LISTmember( newlist, a ) ) { + LISTadd_first( newlist, a ); } - } - LISTod + } LISTod } - } - LISTod + } LISTod return newlist; } /** prints the class 'definition', that is, the objects * and the constructor(s)/destructor for a select class. */ -void TYPEselect_inc_print_vars(const Type type, FILE *f, Linked_List dups) -{ +void TYPEselect_inc_print_vars( const Type type, FILE * f, Linked_List dups ) { int size, j; - Linked_List data_members = SELgetnew_dmlist(type); + Linked_List data_members = SELgetnew_dmlist( type ); char dmname [BUFSIZ], classnm [BUFSIZ], tdnm [BUFSIZ]; - strncpy(classnm, SelectName(TYPEget_name(type)), BUFSIZ); - classnm[BUFSIZ - 1] = '\0'; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; - size = strlen(classnm) + 2; /* for formatting output */ - - fprintf(f, "\n////////// SELECT TYPE %s\n", SelectName(TYPEget_name(type))); - fprintf(f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm); - fprintf(f, " protected:\n"); - fprintf(f, " // types in SELECT \n"); - LISTdo(SEL_TYPEget_items(type), t, Type) { - fprintf(f, " // %s -- %s\n", SEL_ITEMget_enumtype(t), FundamentalType(t, 0)); + strncpy( classnm, SelectName( TYPEget_name( type ) ), BUFSIZ ); + classnm[BUFSIZ-1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; + size = strlen( classnm ) + 2; /* for formatting output */ + + fprintf( f, "\n////////// SELECT TYPE %s\n", SelectName( TYPEget_name( type ) ) ); + fprintf( f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm ); + fprintf( f, " protected:\n" ); + fprintf( f, " // types in SELECT \n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + fprintf( f, " // %s -- %s\n", SEL_ITEMget_enumtype( t ), FundamentalType( t, 0 ) ); } LISTod; - LISTdo(data_members, t, Type) { - strncpy(dmname, SEL_ITEMget_dmname(t), BUFSIZ); - fprintf(f, " %s%s _%s;\n", TYPEget_utype(t), TYPEis_aggregate(t) ? "_ptr" : "", dmname); + LISTdo( data_members, t, Type ) { + strncpy( dmname, SEL_ITEMget_dmname( t ), BUFSIZ ); + fprintf( f, " %s%s _%s;\n", TYPEget_utype( t ), TYPEis_aggregate( t ) ? "_ptr" : "", dmname ); } LISTod; - fprintf(f, "\n public:\n"); - fprintf(f, - " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" - " virtual SDAI_Select * NewSelect ();\n" + fprintf( f, "\n public:\n" ); + fprintf( f, + " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" + " virtual SDAI_Select * NewSelect ();\n" ); - fprintf(f, "\n virtual BASE_TYPE ValueType() const;\n"); + fprintf( f, "\n virtual BASE_TYPE ValueType() const;\n" ); - fprintf(f, "\n\n// STEP Part 21\n"); - fprintf(f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n"); - fprintf(f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n"); - fprintf(f, " virtual Severity STEPread_content (istream& in =cin,\n" - " InstMgrBase * instances =0, const char *utype =0,\n" - " int addFileId =0, const char *currSch =0);\n"); + fprintf( f, "\n\n// STEP Part 21\n" ); + fprintf( f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n" ); + fprintf( f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n" ); + fprintf( f, " virtual Severity STEPread_content (istream& in =cin,\n" + " InstMgrBase * instances =0, const char *utype =0,\n" + " int addFileId =0, const char *currSch =0);\n" ); /* read StrToVal_content */ - fprintf(f, " virtual Severity StrToVal_content " - "(const char *,\n InstMgrBase * instances =0);\n"); + fprintf( f, " virtual Severity StrToVal_content " + "(const char *,\n InstMgrBase * instances =0);\n" ); /* constructor(s) */ - fprintf(f, "\n// STEP Part 22: SDAI\n"); - fprintf(f, "\n// constructors\n"); - fprintf(f, " %s( const SelectTypeDescriptor * =%s );\n", - classnm, tdnm); + fprintf( f, "\n// STEP Part 22: SDAI\n" ); + fprintf( f, "\n// constructors\n" ); + fprintf( f, " %s( const SelectTypeDescriptor * =%s );\n", + classnm, tdnm ); - fprintf(f, " // part 1\n"); + fprintf( f, " // part 1\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " %s( const %s&,\n ", - SelectName(TYPEget_name(type)), AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, " %s( const %s&,\n ", + SelectName( TYPEget_name( type ) ), AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); + fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); } LISTod; - LISTdo(dups, t, Type) - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, " %s( const %s&,\n ", - SelectName(TYPEget_name(type)), - isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + LISTdo( dups, t, Type ) + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, " %s( const %s&,\n ", + SelectName( TYPEget_name( type ) ), + isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); + fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); } LISTod; /* destructor */ - fprintf(f, " virtual ~%s();\n", classnm); - LISTfree(data_members); + fprintf( f, " virtual ~%s();\n", classnm ); + LISTfree( data_members ); } /** * TYPEselect_inc_print prints the class member function declarations of a select * class. */ -void TYPEselect_inc_print(const Type type, FILE *f) -{ +void TYPEselect_inc_print( const Type type, FILE * f ) { char n[BUFSIZ]; /* class name */ char tdnm [BUFSIZ]; /* TypeDescriptor name */ Linked_List dups; int dup_result; Linked_List attrs; - dup_result = find_duplicate_list(type, &dups); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - TYPEselect_inc_print_vars(type, f, dups); + dup_result = find_duplicate_list( type, &dups ); + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + TYPEselect_inc_print_vars( type, f, dups ); - fprintf(f, "\n // part 2\n"); + fprintf( f, "\n // part 2\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " operator %s();\n", AccessType(t)); + fprintf( f, " operator %s();\n", AccessType( t ) ); } LISTod; - LISTdo(dups, t, Type) + LISTdo( dups, t, Type ) /* do the dups once only */ - if(! TYPEis_entity(t)) /* entities were done already */ - fprintf(f, " operator %s ();\n", - (TYPEis_aggregate(t) || TYPEis_select(t)) ? - AccessType(t) : TYPEget_utype(t)); + if( ! TYPEis_entity( t ) ) /* entities were done already */ + fprintf( f, " operator %s ();\n", + ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? + AccessType( t ) : TYPEget_utype( t ) ); LISTod; - fprintf(f, "\n // part 3\n"); - attrs = SEL_TYPEgetnew_attribute_list(type); + fprintf( f, "\n // part 3\n" ); + attrs = SEL_TYPEgetnew_attribute_list( type ); /* get the list of unique attributes from the entity items */ - LISTdo(attrs, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { - ATTRsign_access_methods(a, f); + LISTdo( attrs, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { + ATTRsign_access_methods( a, f ); } LISTod; - LISTfree(attrs); + LISTfree( attrs ); - fprintf(f, "\n // part 4\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + fprintf( f, "\n // part 4\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " %s& operator =( const %s& );\n", - SelectName(TYPEget_name(type)), AccessType(t)); + fprintf( f, " %s& operator =( const %s& );\n", + SelectName( TYPEget_name( type ) ), AccessType( t ) ); } LISTod; - LISTdo(dups, t, Type) - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, " %s& operator =( const %s& );\n", - SelectName(TYPEget_name(type)), - isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); + LISTdo( dups, t, Type ) + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, " %s& operator =( const %s& );\n", + SelectName( TYPEget_name( type ) ), + isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); } LISTod; - fprintf(f, " // not in SDAI\n" - " %s& ShallowCopy ( const %s& );\n", - n, n); + fprintf( f, " // not in SDAI\n" + " %s& ShallowCopy ( const %s& );\n", + n, n ); - fprintf(f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n"); - fprintf(f, " %s& operator =( %s * const & );\n", n, n); - fprintf(f, " SDAI_Select& operator =( const SDAI_Select& );\n"); - fprintf(f, "#endif\n"); + fprintf( f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n" ); + fprintf( f, " %s& operator =( %s * const & );\n", n, n ); + fprintf( f, " SDAI_Select& operator =( const SDAI_Select& );\n" ); + fprintf( f, "#endif\n" ); - fprintf(f, "\n // part 5\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - fprintf(f, " Logical Is%s() const;\n", - FirstToUpper(TYPEget_name(t))); + fprintf( f, "\n // part 5\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + fprintf( f, " Logical Is%s() const;\n", + FirstToUpper( TYPEget_name( t ) ) ); LISTod; - fprintf(f, "\n // part 6 ... UnderlyingTypeName () implemented in" - " SDAI_Select class ...\n"); + fprintf( f, "\n // part 6 ... UnderlyingTypeName () implemented in" + " SDAI_Select class ...\n" ); - if(dup_result) { + if( dup_result ) { /** if there are duplicate underlying types **/ - fprintf(f, "\n // part 7\n"); - fprintf(f, " const TypeDescriptor *" - "SetUnderlyingType ( const TypeDescriptor * td );\n"); + fprintf( f, "\n // part 7\n" ); + fprintf( f, " const TypeDescriptor *" + "SetUnderlyingType ( const TypeDescriptor * td );\n" ); } else { - fprintf(f, "\n // part 7 ... NONE only for complex selects...\n"); + fprintf( f, "\n // part 7 ... NONE only for complex selects...\n" ); } #ifdef PART8 - fprintf(f, "\n // part 8\n"); - fprintf(f, " %s* operator->();\n", n); + fprintf( f, "\n // part 8\n" ); + fprintf( f, " %s* operator->();\n", n ); #endif - fprintf(f, "};\n"); + fprintf( f, "};\n" ); - fprintf(f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n); + fprintf( f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n ); /* DAR - moved from SCOPEPrint() */ - fprintf(f, "typedef %s * %sH;\n", n, n); - fprintf(f, "typedef %s_ptr %s_var;\n\n", n, n); + fprintf( f, "typedef %s * %sH;\n", n, n ); + fprintf( f, "typedef %s_ptr %s_var;\n\n", n, n ); /* print things for aggregate class */ - fprintf(f, "\nclass %s_agg : public SelectAggregate {\n", n); - fprintf(f, " protected:\n"); - fprintf(f, " SelectTypeDescriptor *sel_type;\n\n"); - fprintf(f, " public:\n"); - fprintf(f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm); - fprintf(f, " ~%s_agg();\n", n); - fprintf(f, " virtual SingleLinkNode * NewNode()\n"); - fprintf(f, " { return new SelectNode (new %s( sel_type )); }\n", n); - fprintf(f, "};\n"); + fprintf( f, "\nclass %s_agg : public SelectAggregate {\n", n ); + fprintf( f, " protected:\n" ); + fprintf( f, " SelectTypeDescriptor *sel_type;\n\n" ); + fprintf( f, " public:\n" ); + fprintf( f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm ); + fprintf( f, " ~%s_agg();\n", n ); + fprintf( f, " virtual SingleLinkNode * NewNode()\n" ); + fprintf( f, " { return new SelectNode (new %s( sel_type )); }\n", n ); + fprintf( f, "};\n" ); /* DAS creation function for select aggregate class */ - fprintf(f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", - n, n); + fprintf( f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", + n, n ); - fprintf(f, "typedef %s_agg_ptr %s_agg_var;\n", n, n); + fprintf( f, "typedef %s_agg_ptr %s_agg_var;\n", n, n ); - fprintf(f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name(type)); + fprintf( f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name( type ) ); - LISTfree(dups); + LISTfree( dups ); } @@ -727,172 +705,166 @@ void TYPEselect_inc_print(const Type type, FILE *f) * TYPEselect_lib_print_part_one prints constructor(s)/destructor of a select * class. */ -void TYPEselect_lib_print_part_one(const Type type, FILE *f, - Linked_List dups, char *n) -{ +void TYPEselect_lib_print_part_one( const Type type, FILE * f, + Linked_List dups, char * n ) { #define schema_name SCHEMAget_name(schema) char tdnm[BUFSIZ], nm[BUFSIZ]; - int size = strlen(n) * 2 + 4, j; /* size - for formatting output */ + int size = strlen( n ) * 2 + 4, j; /* size - for formatting output */ - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - strncpy(nm, SelectName(TYPEget_name(type)), BUFSIZ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + strncpy( nm, SelectName( TYPEget_name( type ) ), BUFSIZ ); /* constructor(s) */ /* null constructor */ - fprintf(f, "\n// STEP Part 22: SDAI\n"); - fprintf(f, "\n // part 0\n"); - fprintf(f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n); - fprintf(f, " : " BASE_SELECT " (typedescript)"); + fprintf( f, "\n// STEP Part 22: SDAI\n" ); + fprintf( f, "\n // part 0\n" ); + fprintf( f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n ); + fprintf( f, " : " BASE_SELECT " (typedescript)" ); /* Initialize the select members with their correct typedescriptors: */ - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); /* create objects for data member pointers. also in two more ctors below, and deleted in dtor which is printed at end of this function. */ - LISTdo(dups, t, Type) { - if(isAggregateType(t) && t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + LISTdo( dups, t, Type ) { + if( isAggregateType( t ) && t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - } - LISTod + } LISTod /* above misses some attr's that are initialized in part 1 ctor below. * hopefully this won't add duplicates... */ - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { - if(isAggregateType(t) && (t->u.type->body->base)) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { + if( isAggregateType( t ) && ( t->u.type->body->base ) ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } } - } - LISTod - fprintf(f, " nullify();\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - fprintf(f, "}\n"); + } LISTod + fprintf( f, " nullify();\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + fprintf( f, "}\n" ); /* constructors with underlying types */ - fprintf(f, "\n // part 1\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { + fprintf( f, "\n // part 1\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { /* if there is not more than one underlying type that maps to the same * base type print out the constructor using the type from the TYPE * statement as the underlying type. Also skip enums/sels which are * renames of other items. That would create redundant constructors * since renames are typedef'ed to the original type. */ - fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } /* Did this for the heck of it, and to show how easy it would have been to make it all pretty - DAR. ;-) */ - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - - fprintf(f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); - fprintf(f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n); - fprintf(f, "#endif\n"); - - if(isAggregateType(t)) { - if(t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + + fprintf( f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); + fprintf( f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n ); + fprintf( f, "#endif\n" ); + + if( isAggregateType( t ) ) { + if( t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : ".")); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); - fprintf(f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n); - fprintf(f, "#endif\n"); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); + fprintf( f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n ); + fprintf( f, "#endif\n" ); - fprintf(f, "}\n\n"); + fprintf( f, "}\n\n" ); } - } - LISTod - LISTdo(dups, t, Type) { + } LISTod + LISTdo( dups, t, Type ) { /* if there is more than one underlying type that maps to the * same base type, print a constructor using the base type. */ - if(! TYPEis_entity(t)) { /* entities were done already */ - if(isAggregateType(t)) { - fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + if( isAggregateType( t ) ) { + fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\"" - " << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - if(t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + " << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + if( t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, + fprintf( f, "// NOTE: Underlying type defaults to %s instead of NULL\n", - TYPEtd_name(t)); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, + TYPEtd_name( t ) ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, "// *logStream << \"DAVE ERR exiting %s constructor.\"" - " << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - fprintf(f, "}\n\n"); + " << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + fprintf( f, "}\n\n" ); } - } - LISTod + } LISTod /* dtor */ - fprintf(f, "%s::~%s() {\n", n, n); + fprintf( f, "%s::~%s() {\n", n, n ); /* delete objects that data members point to */ - LISTdo(dups, t, Type) { - if(isAggregateType(t) && t->u.type->body->base) { - fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); - fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); - fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); + LISTdo( dups, t, Type ) { + if( isAggregateType( t ) && t->u.type->body->base ) { + fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); } } LISTod; - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { - if(isAggregateType(t) && (t->u.type->body->base)) { - fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); - fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); - fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { + if( isAggregateType( t ) && ( t->u.type->body->base ) ) { + fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); } } - } - LISTod + } LISTod - fprintf(f, "}\n\n"); + fprintf( f, "}\n\n" ); - fprintf(f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" - " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n); - fprintf(f, "%s_agg::~%s_agg() { }\n\n", n, n); + fprintf( f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" + " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n ); + fprintf( f, "%s_agg::~%s_agg() { }\n\n", n, n ); #undef schema_name } @@ -902,57 +874,54 @@ void TYPEselect_lib_print_part_one(const Type type, FILE *f, * renaming of another select ("TYPE selB = selA") its td would default to * selA's, so it must be set specifically. */ -static void initSelItems(const Type type, FILE *f) -{ - Linked_List data_members = SELgetnew_dmlist(type); - - LISTdo(data_members, t, Type) - if(TYPEis_select(t)) { - fprintf(f, ",\n _%s (%s)", SEL_ITEMget_dmname(t), - TYPEtd_name(t)); +static void initSelItems( const Type type, FILE * f ) { + Linked_List data_members = SELgetnew_dmlist( type ); + + LISTdo( data_members, t, Type ) + if( TYPEis_select( t ) ) { + fprintf( f, ",\n _%s (%s)", SEL_ITEMget_dmname( t ), + TYPEtd_name( t ) ); } LISTod; } -Linked_List ENTITYget_expanded_entities(Entity e, Linked_List l) -{ +Linked_List ENTITYget_expanded_entities( Entity e, Linked_List l ) { Linked_List supers; Entity super; - if(! LISTmember(l, e)) { - LISTadd_first(l, e); + if( ! LISTmember( l, e ) ) { + LISTadd_first( l, e ); } - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - supers = ENTITYget_supertypes(e); - LISTdo(supers, s, Entity) + supers = ENTITYget_supertypes( e ); + LISTdo( supers, s, Entity ) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if(super_cnt == 0) { - ENTITYget_expanded_entities(s, l); + if( super_cnt == 0 ) { + ENTITYget_expanded_entities( s, l ); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass(e); - ENTITYget_expanded_entities(super, l); + super = ENTITYget_superclass( e ); + ENTITYget_expanded_entities( super, l ); } return l; } -Linked_List SELget_entity_itemlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SELget_entity_itemlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - ENTITYget_expanded_entities(cur, newlist); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + ENTITYget_expanded_entities( cur, newlist ); } LISTod; return newlist; @@ -965,37 +934,35 @@ Linked_List SELget_entity_itemlist(const Type type) * to its primary path (is its own attr, that of its first super, that of * its first super's first super etc), and does necessary housekeeping. */ -static int memberOfEntPrimary(Entity ent, Variable uattr) -{ +static int memberOfEntPrimary( Entity ent, Variable uattr ) { Linked_List attrlist = LISTcreate(); int result; - ENTITYget_first_attribs(ent, attrlist); - result = (LISTmember(attrlist, uattr) != 0); - LIST_destroy(attrlist); + ENTITYget_first_attribs( ent, attrlist ); + result = ( LISTmember( attrlist, uattr ) != 0 ); + LIST_destroy( attrlist ); return result; } -void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, const char *attrnm, const char *utype, char *uent, char *funcnm, - Linked_List items, Variable a, Variable uattr, Entity ent, FILE *f, bool returnConst) -{ +void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, const char * attrnm, const char * utype, char * uent, char * funcnm, + Linked_List items, Variable a, Variable uattr, Entity ent, FILE * f, bool returnConst ) { /* return a const value? */ - const char *constStr = "const "; - const char *constReturn = (returnConst ? constStr : ""); + const char * constStr = "const "; + const char * constReturn = ( returnConst ? constStr : "" ); /* method can be const or non-const? */ - bool notAlwaysConst = attrIsObj(VARget_type(a)); + bool notAlwaysConst = attrIsObj( VARget_type( a ) ); - ATTRprint_access_methods_get_head(classnm, a, f, returnConst); + ATTRprint_access_methods_get_head( classnm, a, f, returnConst ); /* if there will not be const and non-const getters, then this method should be const */ - fprintf(f, "%s{\n", (notAlwaysConst ? constReturn : constStr)); + fprintf( f, "%s{\n", ( notAlwaysConst ? constReturn : constStr ) ); - LISTdo(items, t, Type) { - if(TYPEis_entity(t) && (uattr = ENTITYget_named_attribute( - (ent = ENT_TYPEget_entity(t)), (char *) StrToLower(attrnm)))) { + LISTdo( items, t, Type ) { + if( TYPEis_entity( t ) && ( uattr = ENTITYget_named_attribute( + ( ent = ENT_TYPEget_entity( t ) ), ( char * ) StrToLower( attrnm ) ) ) ) { /* for the select items which have the current attribute */ - if(!multiple_inheritance) { - if(!memberOfEntPrimary(ent, uattr)) { + if( !multiple_inheritance ) { + if( !memberOfEntPrimary( ent, uattr ) ) { /* If multiple inheritance is not supported, we must additionally check * that uattr is a member of the entity's primary inheritance path * (i.e., the entity, its first supertype, the super's first super, @@ -1005,43 +972,42 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons continue; } } - if(! VARis_derived(uattr)) { + if( ! VARis_derived( uattr ) ) { - if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { + if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { /* check to make sure the underlying attribute\'s type is * the same as the current attribute. */ - strncpy(uent, TYPEget_ctype(t), BUFSIZ); + strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); /* if the underlying type is that item's type, call the underlying_item's * member function if it is the same attribute */ - if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { + if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { /* update attribute_func_name because is has been overridden */ - generate_attribute_func_name(uattr, funcnm); + generate_attribute_func_name( uattr, funcnm ); } else { - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); } - fprintf(f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name(t), StrToUpper(TYPEget_name(t))); - fprintf(f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname(t), funcnm); + fprintf( f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", + TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); + fprintf( f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname( t ), funcnm ); } else { /* types are not the same issue a warning */ - fprintf(stderr, - "WARNING: in SELECT TYPE %s: ambiguous " - "attribute \"%s\" from underlying type \"%s\".\n\n", - TYPEget_name(type), attrnm, TYPEget_name(t)); - fprintf(f, " // %s\n // attribute access function" - " has a different return type\n", - StrToUpper(TYPEget_name(t))); + fprintf( stderr, + "WARNING: in SELECT TYPE %s: ambiguous " + "attribute \"%s\" from underlying type \"%s\".\n\n", + TYPEget_name( type ), attrnm, TYPEget_name( t ) ); + fprintf( f, " // %s\n // attribute access function" + " has a different return type\n", + StrToUpper( TYPEget_name( t ) ) ); } } else /* derived attributes */ - fprintf(f, " // for %s attribute is derived\n", - StrToUpper(TYPEget_name(t))); - } - } - LISTod; + fprintf( f, " // for %s attribute is derived\n", + StrToUpper( TYPEget_name( t ) ) ); + } + } LISTod; PRINT_BUG_REPORT /* If the return type is an enumeration class then you can\'t @@ -1060,18 +1026,18 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons */ /* EnumName (TYPEget_name (VARget_type (a)))*/ - switch(TYPEget_body(VARget_type(a)) -> type) { + switch( TYPEget_body( VARget_type( a ) ) -> type ) { case enumeration_: - fprintf(f, " return (%s) 0;\n}\n\n", EnumName(TYPEget_name(VARget_type(a)))); + fprintf( f, " return (%s) 0;\n}\n\n", EnumName( TYPEget_name( VARget_type( a ) ) ) ); break; case boolean_: - fprintf(f, " return (Boolean) 0;\n}\n\n"); + fprintf( f, " return (Boolean) 0;\n}\n\n" ); break; case logical_: - fprintf(f, " return (Logical) 0;\n}\n\n"); + fprintf( f, " return (Logical) 0;\n}\n\n" ); break; default: - fprintf(f, " return 0;\n}\n\n"); + fprintf( f, " return 0;\n}\n\n" ); } } @@ -1080,67 +1046,63 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons * a select class -- access functions for the data members of underlying entity * types. */ -void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) -{ +void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm ) { #define ENTITYget_type(e) ((e)->u.entity->type) char uent[BUFSIZ], /* name of underlying entity type */ utype[BUFSIZ], /* underlying type name */ attrnm [BUFSIZ], /* attribute name -> data member = _attrnm */ funcnm[BUFSIZ]; /* access function name = Attrnm */ - Linked_List items = SEL_TYPEget_items(type); + Linked_List items = SEL_TYPEget_items( type ); /* all the items in the select type */ - Linked_List attrs = SEL_TYPEgetnew_attribute_list(type); + Linked_List attrs = SEL_TYPEgetnew_attribute_list( type ); /* list of attributes with unique names */ Entity ent = NULL; Variable uattr = NULL; /* attribute in underlying type */ - fprintf(f, "\n // part 3\n"); + fprintf( f, "\n // part 3\n" ); /* go through all the unique attributes */ - LISTdo_n(attrs, a, Variable, b) { + LISTdo_n( attrs, a, Variable, b ) { bool putVarIsUsed = false; /* used to suppress unused var warning */ - if(VARget_initializer(a) == EXPRESSION_NULL) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* only do for explicit attributes */ - generate_attribute_func_name(a, funcnm); - generate_attribute_name(a, attrnm); + generate_attribute_func_name( a, funcnm ); + generate_attribute_name( a, attrnm ); /* strncpy (funcnm, attrnm, BUFSIZ); funcnm [0] = toupper (funcnm[0]); */ /* use the ctype since utype will be the same for all entities */ - strncpy(utype, TYPEget_ctype(VARget_type(a)), BUFSIZ); + strncpy( utype, TYPEget_ctype( VARget_type( a ) ), BUFSIZ ); /* get methods */ - TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false); - /* TODO - This isn't good enough - the compiler warning Wignored-qualifiers is picking up - * a lot of spurious const expressions coming from these outputs. Not sure of the pattern - * yet, but it looks like not all attrIsObj entities should be using it. */ - if(attrIsObj(VARget_type(a))) { - TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true); + TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false ); + if( attrIsObj( VARget_type( a ) ) ) { + TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true ); } /* put method */ - ATTRprint_access_methods_put_head(classnm, a, f); - fprintf(f, "{\n"); - LISTdo(items, t, Type) { - if(TYPEis_entity(t) && - (uattr = ENTITYget_named_attribute( - (ent = ENT_TYPEget_entity(t)), - (char *) StrToLower(attrnm)))) + ATTRprint_access_methods_put_head( classnm, a, f ); + fprintf( f, "{\n" ); + LISTdo( items, t, Type ) { + if( TYPEis_entity( t ) && + ( uattr = ENTITYget_named_attribute( + ( ent = ENT_TYPEget_entity( t ) ), + ( char * ) StrToLower( attrnm ) ) ) ) { /* for the select items which have the current attribute */ - if(!multiple_inheritance) { - if(!memberOfEntPrimary(ent, uattr)) { + if( !multiple_inheritance ) { + if( !memberOfEntPrimary( ent, uattr ) ) { /* See note for similar code segment in 1st part of fn. */ continue; } } - if(! VARis_derived(uattr)) { + if( ! VARis_derived( uattr ) ) { - if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { + if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { /* check to make sure the underlying attribute\'s type is the same as the current attribute. */ @@ -1148,218 +1110,209 @@ void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) /* if the underlying type is that item\'s type call the underlying_item\'s member function */ /* if it is the same attribute */ - if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { + if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { /* update attribute_func_name because is has been overrid */ - generate_attribute_func_name(uattr, funcnm); + generate_attribute_func_name( uattr, funcnm ); } else { - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); } - strncpy(uent, TYPEget_ctype(t), BUFSIZ); - fprintf(f, + strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); + fprintf( f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name(t), StrToUpper(TYPEget_name(t))); - fprintf(f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", - uent, SEL_ITEMget_dmname(t), funcnm); + TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); + fprintf( f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", + uent, SEL_ITEMget_dmname( t ), funcnm ); putVarIsUsed = true; } else { /* warning printed above */ - fprintf(f, " // for %s attribute access function" + fprintf( f, " // for %s attribute access function" " has a different argument type\n", - SEL_ITEMget_enumtype(t)); + SEL_ITEMget_enumtype( t ) ); } } else { /* derived attributes */ - fprintf(f, " // for %s attribute is derived\n", - SEL_ITEMget_enumtype(t)); + fprintf( f, " // for %s attribute is derived\n", + SEL_ITEMget_enumtype( t ) ); } } - } - LISTod; - if(!putVarIsUsed) { + } LISTod; + if( !putVarIsUsed ) { fprintf(f, " (void) x; //suppress unused var warning\n"); } - PRINT_SELECTBUG_WARNING(f); - fprintf(f, "}\n"); + PRINT_SELECTBUG_WARNING( f ); + fprintf( f, "}\n" ); } - } - LISTod; - LISTfree(attrs); + } LISTod; + LISTfree( attrs ); } /** * TYPEselect_lib_print_part_four prints part 4 of the SDAI document of a select class. */ -void TYPEselect_lib_print_part_four(const Type type, FILE *f, Linked_List dups, char *n) -{ +void TYPEselect_lib_print_part_four( const Type type, FILE * f, Linked_List dups, char * n ) { char x[BUFSIZ]; - fprintf(f, "\n // part 4\n"); + fprintf( f, "\n // part 4\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n" + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n" " nullify ();\n", - n, n, AccessType(t)); + n, n, AccessType( t ) ); - if(isAggregateType(t)) { - fprintf(f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : ".")); + if( isAggregateType( t ) ) { + fprintf( f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, " SetUnderlyingType( %s );\n", TYPEtd_name(t)); - fprintf(f, " return *this;\n}\n\n"); + fprintf( f, " SetUnderlyingType( %s );\n", TYPEtd_name( t ) ); + fprintf( f, " return *this;\n}\n\n" ); } - } - LISTod - LISTdo(dups, t, Type) { - if(! TYPEis_entity(t)) { /* entities were done already */ - if(isAggregateType(t)) { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, AccessType(t)); - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); + } LISTod + LISTdo( dups, t, Type ) { + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + if( isAggregateType( t ) ) { + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, AccessType( t ) ); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, TYPEget_utype(t)); - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, TYPEget_utype( t ) ); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, " underlying_type = 0; // MUST BE SET BY USER\n"); - fprintf(f, " // discriminator = UNSET\n"); - fprintf(f, " return *this;\n}\n"); + fprintf( f, " underlying_type = 0; // MUST BE SET BY USER\n" ); + fprintf( f, " // discriminator = UNSET\n" ); + fprintf( f, " return *this;\n}\n" ); } - } - LISTod - - fprintf(f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n"); - fprintf(f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n); - fprintf(f, " SDAI_Select::operator=( *o );\n"); - - LISTdo(SEL_TYPEget_items(type), t, Type) { - strncpy(x, TYPEget_name(t), BUFSIZ); - fprintf(f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name(t)); - if(TYPEis_select(t)) { - if(utype_member(dups, t, 1)) + } LISTod + + fprintf( f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n" ); + fprintf( f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n ); + fprintf( f, " SDAI_Select::operator=( *o );\n"); + + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + strncpy( x, TYPEget_name( t ), BUFSIZ ); + fprintf( f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name( t ) ); + if( TYPEis_select( t ) ) { + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname(t), - StrToLower(TYPEget_utype(t))); + fprintf( f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname( t ), + StrToLower( TYPEget_utype( t ) ) ); else - fprintf(f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname(t), - SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname( t ), + SEL_ITEMget_dmname( t ) ); } else { - if(utype_member(dups, t, 1)) { + if( utype_member( dups, t, 1 ) ) { /** if in the dup list **/ - fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); - /* I changed this although I'm not sure how the if and else differ */ - /* StrToLower(TYPEget_utype(t)) ); */ + fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); + /* I changed this although I'm not sure how the if and else differ */ + /* StrToLower(TYPEget_utype(t)) ); */ } else { - fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); } } - fprintf(f, " return *this;\n"); - fprintf(f, " }\n"); - } - LISTod; - fprintf(f, " return *this;\n}\n\n"); - - fprintf(f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n); - fprintf(f, " SDAI_Select::operator=( o );\n"); - - LISTdo(SEL_TYPEget_items(type), t, Type) { - strncpy(x, TYPEget_name(t), BUFSIZ); - x[BUFSIZ - 1] = '\0'; - fprintf(f, " if ( o.CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name(t)); - if(TYPEis_select(t)) { - if(utype_member(dups, t, 1)) + fprintf( f, " return *this;\n" ); + fprintf( f, " }\n" ); + } LISTod; + fprintf( f, " return *this;\n}\n\n" ); + + fprintf( f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n ); + fprintf( f, " SDAI_Select::operator=( o );\n"); + + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + strncpy( x, TYPEget_name( t ), BUFSIZ ); + x[BUFSIZ-1] = '\0'; + fprintf( f, " if ( o.CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name( t ) ); + if( TYPEis_select( t ) ) { + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); else - fprintf(f, " _%s = &( ( ( %s& ) o )._%s );\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = &( ( ( %s& ) o )._%s );\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); } else { - if(utype_member(dups, t, 1)) + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); else - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); } - fprintf(f, " return *this;\n"); - fprintf(f, " }\n"); - } - LISTod - fprintf(f, " return *this;\n}\n\n"); - fprintf(f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n"); + fprintf( f, " return *this;\n" ); + fprintf( f, " }\n" ); + } LISTod + fprintf( f, " return *this;\n}\n\n" ); + fprintf( f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n" ); } /** * TYPEselect_init_print prints the types that belong to the select type */ -void TYPEselect_init_print(const Type type, FILE *f) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - - fprintf(f, " %s -> Elements ().AddNode", - TYPEtd_name(type)); - fprintf(f, " (%s);\n", - TYPEtd_name(t)); +void TYPEselect_init_print( const Type type, FILE * f ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + + fprintf( f, " %s -> Elements ().AddNode", + TYPEtd_name( type ) ); + fprintf( f, " (%s);\n", + TYPEtd_name( t ) ); LISTod; } -void TYPEselect_lib_part21(const Type type, FILE *f) -{ +void TYPEselect_lib_part21( const Type type, FILE * f ) { char n[BUFSIZ]; /* pointers to class name(s) */ - const char *dm; /* data member name */ - Linked_List data_members = SELgetnew_dmlist(type); + const char * dm; /* data member name */ + Linked_List data_members = SELgetnew_dmlist( type ); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - n[BUFSIZ - 1] = '\0'; + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + n[BUFSIZ-1] = '\0'; - fprintf(f, "\n\n// STEP Part 21\n"); + fprintf( f, "\n\n// STEP Part 21\n" ); /* write part 21 */ - fprintf(f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" - " currSch) const {\n (void)currSch;\n ", n); + fprintf( f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" + " currSch) const {\n (void)currSch;\n ", n ); /* go through the items */ - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); - fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name(t)); + fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { - /* if it\'s a number, just print it */ + /* if it\'s a number, just print it */ case integer_: - fprintf(f, " out << _%s;\n", dm); + fprintf( f, " out << _%s;\n", dm ); break; case number_: case real_: - fprintf(f, " WriteReal(_%s,out);\n", dm); + fprintf( f, " WriteReal(_%s,out);\n", dm ); break; case entity_: - fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); + fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); break; case string_: @@ -1368,11 +1321,11 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case boolean_: case binary_: /* for string's, enum's, select's, and binary's it'll be embedded */ - fprintf(f, " _%s.STEPwrite (out);\n", dm); + fprintf( f, " _%s.STEPwrite (out);\n", dm ); break; case select_: - fprintf(f, " _%s.STEPwrite (out, currSch);\n", dm); + fprintf( f, " _%s.STEPwrite (out, currSch);\n", dm ); /* Select type needs currSch passed too. A Select writes the name of its current choice when it writes itself out (e.g. "DATA(33.5)"). Since the current choice name may depend on our current schema (it may be a @@ -1380,7 +1333,7 @@ void TYPEselect_lib_part21(const Type type, FILE *f) */ break; - /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ + /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ case aggregate_: case array_: case bag_: @@ -1388,88 +1341,88 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case list_: default: /* otherwise it\'s a pointer */ - fprintf(f, " _%s -> STEPwrite (out);\n", dm); + fprintf( f, " _%s -> STEPwrite (out);\n", dm ); break; } - fprintf(f, " return;\n"); - fprintf(f, " }\n"); + fprintf( f, " return;\n" ); + fprintf( f, " }\n" ); LISTod; PRINT_BUG_REPORT - fprintf(f, "}\n"); + fprintf( f, "}\n" ); /* ValueType() -- get type of value stored in select */ - fprintf(f, "\nBASE_TYPE\n%s::ValueType() const {\n", n); + fprintf( f, "\nBASE_TYPE\n%s::ValueType() const {\n", n ); - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); - fprintf(f, " if (CurrentUnderlyingType() == %s)\n", - TYPEtd_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); + fprintf( f, " if (CurrentUnderlyingType() == %s)\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case select_: - fprintf(f, " return _%s.ValueType();\n", dm); + fprintf( f, " return _%s.ValueType();\n", dm ); break; default: - fprintf(f, " return %s;\n", FundamentalType(t, 0)); + fprintf( f, " return %s;\n", FundamentalType( t, 0 ) ); } LISTod; PRINT_BUG_REPORT - fprintf(f, " return (BASE_TYPE)0;\n}\n"); + fprintf( f, " return (BASE_TYPE)0;\n}\n" ); /* STEPwrite_verbose() -- print value with specified type */ - fprintf(f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," - " const char *currSch) const\n{\n", n); + fprintf( f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," + " const char *currSch) const\n{\n", n ); /* Get name of typedescriptor, according to value of currSch: */ - fprintf(f, " const TypeDescriptor *td = CurrentUnderlyingType();\n"); - fprintf(f, " std::string tmp;\n\n"); - fprintf(f, " if ( td ) {\n"); - fprintf(f, " // If we have a legal underlying type, get its name acc\n"); - fprintf(f, " // to the current schema.\n"); - fprintf(f, " StrToUpper( td->Name(currSch), tmp );\n"); - fprintf(f, " }\n"); + fprintf( f, " const TypeDescriptor *td = CurrentUnderlyingType();\n" ); + fprintf( f, " std::string tmp;\n\n" ); + fprintf( f, " if ( td ) {\n" ); + fprintf( f, " // If we have a legal underlying type, get its name acc\n" ); + fprintf( f, " // to the current schema.\n" ); + fprintf( f, " StrToUpper( td->Name(currSch), tmp );\n" ); + fprintf( f, " }\n" ); /* Next loop through the possible items: */ - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); - fprintf(f, " if (td == %s) {\n", - TYPEtd_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); + fprintf( f, " if (td == %s) {\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: /* fprintf(f, " out << \"%s(\" << _%s << \")\";\n else ", StrToUpper(TYPEget_name(t)), dm);*/ - fprintf(f, " out << tmp << \"(\" << _%s << \")\";\n", - dm); + fprintf( f, " out << tmp << \"(\" << _%s << \")\";\n", + dm ); break; case real_: case number_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " WriteReal(_%s,out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " WriteReal(_%s,out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case entity_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case string_: case enumeration_: case logical_: case boolean_: case binary_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s.STEPwrite (out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s.STEPwrite (out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case aggregate_: case array_: @@ -1477,78 +1430,78 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case set_: case list_: /* Aggregates need currSch passed since they may be aggrs of sels. */ - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s%sSTEPwrite (out, currSch);\n", dm, - ((t->u.type->body->base) ? "->" : ".")); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s%sSTEPwrite (out, currSch);\n", dm, + ( ( t->u.type->body->base ) ? "->" : "." ) ); + fprintf( f, " out << \")\";\n" ); break; case select_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s.STEPwrite_verbose (out, currSch);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s.STEPwrite_verbose (out, currSch);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; default: - fprintf(f, " _%s -> STEPwrite (out); \n", dm); + fprintf( f, " _%s -> STEPwrite (out); \n", dm ); break; } - fprintf(f, " return;\n"); - fprintf(f, " }\n"); + fprintf( f, " return;\n" ); + fprintf( f, " }\n" ); LISTod; PRINT_BUG_REPORT - fprintf(f, " return;\n}\n"); + fprintf( f, " return;\n}\n" ); /* Read part 21 */ - fprintf(f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" - " const char *utype, int addFileId, const char *currSch)\n{\n" - " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n); + fprintf( f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" + " const char *utype, int addFileId, const char *currSch)\n{\n" + " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n ); /* go through the items */ - LISTdo(SEL_TYPEget_items(type), t, Type) + LISTdo( SEL_TYPEget_items( type ), t, Type ) - fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name(t)); + fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name( t ) ); - dm = SEL_ITEMget_dmname(t); + dm = SEL_ITEMget_dmname( t ); - switch(TYPEget_body(t)->type) { - /* if it's a number, just read it */ + switch( TYPEget_body( t )->type ) { + /* if it's a number, just read it */ case real_: case number_: /* since REAL and NUMBER are handled the same they both need to be included in the case stmt */ - fprintf(f, - " ReadReal (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm); + fprintf( f, + " ReadReal (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm ); break; case integer_: - fprintf(f, - " ReadInteger (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm); + fprintf( f, + " ReadInteger (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm ); break; case entity_: /* if it's an entity, use Assign - done in Select class */ - fprintf(f, - " // set Underlying Type in Select class\n" - " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm); - fprintf(f, - " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " - " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" - " return severity();\n", dm, dm, dm); - fprintf(f, - " } else {\n " - " Error (\"Reference to instance that is not indicated type\\n\");\n" - " _%s = 0;\n" - " nullify ();\n" - " return severity (SEVERITY_USERMSG);\n" - " }\n", dm); + fprintf( f, + " // set Underlying Type in Select class\n" + " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm ); + fprintf( f, + " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " + " ( CurrentUnderlyingType()->CanBe( _%s->getEDesc() ) ) ) {\n" + " return severity();\n", dm, dm, dm ); + fprintf( f, + " } else {\n " + " Error (\"Reference to instance that is not indicated type\\n\");\n" + " _%s = 0;\n" + " nullify ();\n" + " return severity (SEVERITY_USERMSG);\n" + " }\n", dm ); break; case string_: @@ -1556,69 +1509,68 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case logical_: case boolean_: case binary_: - fprintf(f, - " _%s.STEPread (in, &_error);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s.STEPread (in, &_error);\n" + " return severity ();\n", + dm ); break; case select_: - fprintf(f, - " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" + " return severity ();\n", + dm ); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf(f, - " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" - " instances, addFileId, currSch);\n", - dm, ((t->u.type->body->base) ? "->" : "."), - TYPEtd_name(t)); - fprintf(f, - " return severity ();\n"); + fprintf( f, + " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" + " instances, addFileId, currSch);\n", + dm, ( ( t->u.type->body->base ) ? "->" : "." ), + TYPEtd_name( t ) ); + fprintf( f, + " return severity ();\n" ); break; default: - fprintf(f, - " _%s -> STEPread (in, &_error, instances, addFileId);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s -> STEPread (in, &_error, instances, addFileId);\n" + " return severity ();\n", + dm ); break; } - fprintf(f, " }\n"); + fprintf( f, " }\n" ); LISTod; - PRINT_SELECTBUG_WARNING(f) ; + PRINT_SELECTBUG_WARNING( f ) ; - LISTfree(data_members); - fprintf(f, " return severity ();\n}\n"); + LISTfree( data_members ); + fprintf( f, " return severity ();\n}\n" ); } -void TYPEselect_lib_StrToVal(const Type type, FILE *f) -{ +void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { char n[BUFSIZ]; /* pointers to class name */ - Linked_List data_members = SELgetnew_dmlist(type); + Linked_List data_members = SELgetnew_dmlist( type ); int enum_cnt = 0; - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - n[BUFSIZ - 1] = '\0'; + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + n[BUFSIZ-1] = '\0'; /* read StrToVal_content */ - fprintf(f, "\nSeverity\n%s::StrToVal_content " - "(const char * str, InstMgrBase * instances)" - "\n{\n (void)str;\n (void)instances;\n", n); + fprintf( f, "\nSeverity\n%s::StrToVal_content " + "(const char * str, InstMgrBase * instances)" + "\n{\n (void)str;\n (void)instances;\n", n ); - fprintf(f, " switch (base_type) {\n"); - LISTdo(data_members, t, Type) + fprintf( f, " switch (base_type) {\n" ); + LISTdo( data_members, t, Type ) /* fprintf (f, " case %s : \n", FundamentalType (t, 0));*/ - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case real_: case integer_: @@ -1638,23 +1590,23 @@ void TYPEselect_lib_StrToVal(const Type type, FILE *f) case logical_: case boolean_: case enumeration_: - if(!enum_cnt) { + if( !enum_cnt ) { /* if there\'s more than one enumeration they are done in Select class */ - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s.StrToVal (str, &_error);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s.StrToVal (str, &_error);\n", + SEL_ITEMget_dmname( t ) ); } else { - fprintf(f, " // case %s : done in Select class\n", FundamentalType(t, 0)); + fprintf( f, " // case %s : done in Select class\n", FundamentalType( t, 0 ) ); } ++enum_cnt; break; case string_: - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s.StrToVal (str);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s.StrToVal (str);\n", + SEL_ITEMget_dmname( t ) ); break; case aggregate_: @@ -1662,265 +1614,258 @@ void TYPEselect_lib_StrToVal(const Type type, FILE *f) case bag_: case set_: case list_: - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : "."), - TYPEtd_name(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ), + TYPEtd_name( t ) ); break; default: /* otherwise use StrToVal on the contents to check the format */ - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s -> StrToVal (str, instances);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s -> StrToVal (str, instances);\n", + SEL_ITEMget_dmname( t ) ); } LISTod; - fprintf(f, " default: // should never be here - done in Select class\n"); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, "#ifdef __SUNCPLUSPLUS__\n" - "std::cerr << str << \" \" << instances << std::endl;\n" - "#endif\n"); - fprintf(f, " return SEVERITY_WARNING;\n }\n"); - - LISTfree(data_members); - fprintf(f, - "#ifdef __GNUG__\n" - "\n return SEVERITY_NULL;\n" - "#endif" - "\n}\n"); + fprintf( f, " default: // should never be here - done in Select class\n" ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, "#ifdef __SUNCPLUSPLUS__\n" + "std::cerr << str << \" \" << instances << std::endl;\n" + "#endif\n" ); + fprintf( f, " return SEVERITY_WARNING;\n }\n" ); + + LISTfree( data_members ); + fprintf( f, + "#ifdef __GNUG__\n" + "\n return SEVERITY_NULL;\n" + "#endif" + "\n}\n" ); } -void TYPEselect_lib_virtual(const Type type, FILE *f) -{ - TYPEselect_lib_part21(type, f); - TYPEselect_lib_StrToVal(type, f); +void TYPEselect_lib_virtual( const Type type, FILE * f ) { + TYPEselect_lib_part21( type, f ); + TYPEselect_lib_StrToVal( type, f ); } -void SELlib_print_protected(const Type type, FILE *f) -{ - const char *snm; +void SELlib_print_protected( const Type type, FILE * f ) { + const char * snm; /* SELECT::AssignEntity */ - fprintf(f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" - "{\n (void)se;\n", - SelectName(TYPEget_name(type)) + fprintf( f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" + "{\n (void)se;\n", + SelectName( TYPEget_name( type ) ) ); /* loop through the items in the SELECT */ - LISTdo(SEL_TYPEget_items(type), t, Type) - if(TYPEis_entity(t)) { - fprintf(f, - " // %s\n" /* item name */ - " if (se -> IsA (%s))\n" /* td */ - " { \n" - " _%s = (%s_ptr) se;\n" /* underlying data member */ - /* underlying data member type */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper(TYPEget_name(t)), - TYPEtd_name(t), - SEL_ITEMget_dmname(t), - ClassName(TYPEget_name(t)), - TYPEtd_name(t) + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( TYPEis_entity( t ) ) { + fprintf( f, + " // %s\n" /* item name */ + " if (se -> IsA (%s))\n" /* td */ + " { \n" + " _%s = (%s_ptr) se;\n" /* underlying data member */ + /* underlying data member type */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper( TYPEget_name( t ) ), + TYPEtd_name( t ), + SEL_ITEMget_dmname( t ), + ClassName( TYPEget_name( t ) ), + TYPEtd_name( t ) ); } - if(TYPEis_select(t)) { - fprintf(f, - " // %s\n" /* item name */ - " if( %s->CanBe( se->eDesc ) ) {\n" - " _%s.AssignEntity (se);\n" /* underlying data member */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper(TYPEget_name(t)), - TYPEtd_name(t), - SEL_ITEMget_dmname(t), - TYPEtd_name(t) + if( TYPEis_select( t ) ) { + fprintf( f, + " // %s\n" /* item name */ + " if( %s->CanBe( se->getEDesc() ) ) {\n" + " _%s.AssignEntity (se);\n" /* underlying data member */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper( TYPEget_name( t ) ), + TYPEtd_name( t ), + SEL_ITEMget_dmname( t ), + TYPEtd_name( t ) ); } LISTod; - fprintf(f, " // should never be here - done in Select class\n"); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, - "#ifdef __SUNCPLUSPLUS__\n" - " std::cerr << se -> EntityName () << std::endl;\n" - "#endif\n" - " return 0;\n}\n"); + fprintf( f, " // should never be here - done in Select class\n" ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, + "#ifdef __SUNCPLUSPLUS__\n" + " std::cerr << se -> EntityName () << std::endl;\n" + "#endif\n" + " return 0;\n}\n" ); /* SELECT::NewSelect */ - snm = SelectName(TYPEget_name(type)); - fprintf(f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm); + snm = SelectName( TYPEget_name( type ) ); + fprintf( f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm ); - fprintf(f, " %s * tmp = new %s();\n", snm, snm); - fprintf(f, " return tmp;\n}\n"); + fprintf( f, " %s * tmp = new %s();\n", snm, snm ); + fprintf( f, " return tmp;\n}\n" ); } /** * TYPEselect_lib_print prints the member functions (definitions) of a select class. */ -void TYPEselect_lib_print(const Type type, FILE *f) -{ +void TYPEselect_lib_print( const Type type, FILE * f ) { char n[BUFSIZ], m[BUFSIZ]; - const char *z; /* pointers to class name(s) */ + const char * z; /* pointers to class name(s) */ Linked_List dups; int dup_result; - dup_result = find_duplicate_list(type, &dups); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - fprintf(f, "\n////////// SELECT TYPE %s\n", TYPEget_name(type)); + dup_result = find_duplicate_list( type, &dups ); + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + fprintf( f, "\n////////// SELECT TYPE %s\n", TYPEget_name( type ) ); - SELlib_print_protected(type, f) ; - TYPEselect_lib_virtual(type, f); - TYPEselect_lib_print_part_one(type, f, dups, n); + SELlib_print_protected( type, f ) ; + TYPEselect_lib_virtual( type, f ); + TYPEselect_lib_print_part_one( type, f, dups, n ); - fprintf(f, "\n // part 2\n"); + fprintf( f, "\n // part 2\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if(TYPEis_entity(t)) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( TYPEis_entity( t ) ) { /* if an entity */ - fprintf(f, "%s::operator %s_ptr()\n{\n", n, ClassName(TYPEget_name(t))); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return ((%s_ptr) _%s);\n", ClassName(TYPEget_name(t)), SEL_ITEMget_dmname(t)); - PRINT_SELECTBUG_WARNING(f); - fprintf(f, " return NULL;\n}\n\n"); - } else if(!utype_member(dups, t, 1)) { + fprintf( f, "%s::operator %s_ptr()\n{\n", n, ClassName( TYPEget_name( t ) ) ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return ((%s_ptr) _%s);\n", ClassName( TYPEget_name( t ) ), SEL_ITEMget_dmname( t ) ); + PRINT_SELECTBUG_WARNING( f ); + fprintf( f, " return NULL;\n}\n\n" ); + } else if( !utype_member( dups, t, 1 ) ) { /** if not in the dup list **/ - fprintf(f, "%s::operator %s()\n{\n", n, AccessType(t)); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return %s _%s;\n", ((TYPEis_select(t)) ? "&" : ""), SEL_ITEMget_dmname(t)); - fprintf(f, "\n severity( SEVERITY_WARNING );\n"); - fprintf(f, " Error( \"Underlying type is not %s\" );\n", AccessType(t)); - PRINT_SELECTBUG_WARNING(f) ; - if(TYPEis_boolean(t) || TYPEis_logical(t)) { - fprintf(f, " return (%s)0;\n}\n\n", TYPEget_utype(t)); + fprintf( f, "%s::operator %s()\n{\n", n, AccessType( t ) ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return %s _%s;\n", ( ( TYPEis_select( t ) ) ? "&" : "" ), SEL_ITEMget_dmname( t ) ); + fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); + fprintf( f, " Error( \"Underlying type is not %s\" );\n", AccessType( t ) ); + PRINT_SELECTBUG_WARNING( f ) ; + if( TYPEis_boolean( t ) || TYPEis_logical( t ) ) { + fprintf( f, " return (%s)0;\n}\n\n", TYPEget_utype( t ) ); } else { - fprintf(f, " return 0;\n}\n\n"); + fprintf( f, " return 0;\n}\n\n" ); } } - } - LISTod - LISTdo(dups, t, Type) { - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, "%s::operator %s()\n{\n", n, - (TYPEis_aggregate(t) || TYPEis_select(t)) ? - AccessType(t) : TYPEget_utype(t)); - strncpy(m, TYPEget_utype(t), BUFSIZ); + } LISTod + LISTdo( dups, t, Type ) { + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, "%s::operator %s()\n{\n", n, + ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? + AccessType( t ) : TYPEget_utype( t ) ); + strncpy( m, TYPEget_utype( t ), BUFSIZ ); /**** MUST CHANGE FOR multiple big types ****/ - LISTdo_n(SEL_TYPEget_items(type), x, Type, b) { - if((strcmp(m, TYPEget_utype(x)) == 0) - || (compareOrigTypes(t, x))) { + LISTdo_n( SEL_TYPEget_items( type ), x, Type, b ) { + if( ( strcmp( m, TYPEget_utype( x ) ) == 0 ) + || ( compareOrigTypes( t, x ) ) ) { /* If this is one of the dups. compareOrigTypes checks if x\'s type is a rename of t\'s (see comments there). */ - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", - TYPEtd_name(x)); - fprintf(f, " return %s _%s;\n", - ((TYPEis_select(x)) ? "&" : ""), - SEL_ITEMget_dmname(x)); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", + TYPEtd_name( x ) ); + fprintf( f, " return %s _%s;\n", + ( ( TYPEis_select( x ) ) ? "&" : "" ), + SEL_ITEMget_dmname( x ) ); } - } - LISTod - fprintf(f, "\n severity( SEVERITY_WARNING );\n"); - fprintf(f, " Error( \"Underlying type is not %s\" );\n", - TYPEis_aggregate(t) ? - AccessType(t) : TYPEget_utype(t)); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, " return (%s)0;\n}\n\n", - TYPEis_aggregate(t) ? - AccessType(t) : TYPEget_utype(t)); + } LISTod + fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); + fprintf( f, " Error( \"Underlying type is not %s\" );\n", + TYPEis_aggregate( t ) ? + AccessType( t ) : TYPEget_utype( t ) ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, " return (%s)0;\n}\n\n", + TYPEis_aggregate( t ) ? + AccessType( t ) : TYPEget_utype( t ) ); /* fprintf( f, " return NULL;\n}\n\n" ); */ } - } - LISTod - - TYPEselect_lib_print_part_three(type, f, n); - TYPEselect_lib_print_part_four(type, f, dups, n); - - fprintf(f, "\n // part 5\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - z = FirstToUpper(TYPEget_name(t)); - fprintf(f, "Logical %s::Is%s() const\n{\n", n, z); - fprintf(f, " if( !exists() )\n"); - fprintf(f, " return LUnknown;\n"); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return LTrue;\n"); - fprintf(f, " return LFalse;\n}\n\n"); + } LISTod + + TYPEselect_lib_print_part_three( type, f, n ); + TYPEselect_lib_print_part_four( type, f, dups, n ); + + fprintf( f, "\n // part 5\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + z = FirstToUpper( TYPEget_name( t ) ); + fprintf( f, "Logical %s::Is%s() const\n{\n", n, z ); + fprintf( f, " if( !exists() )\n" ); + fprintf( f, " return LUnknown;\n" ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return LTrue;\n" ); + fprintf( f, " return LFalse;\n}\n\n" ); LISTod; #ifdef UNDERLYINGTYPE - fprintf(f, "\n // part 6\n"); - fprintf(f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n); - fprintf(f, " if( exists() )\n"); - fprintf(f, " {\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - if(TYPEis_entity(t)) - fprintf(f, " return( _%s->Name() );\n" - StrToLower(TYPEget_name(t))); + fprintf( f, "\n // part 6\n" ); + fprintf( f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n ); + fprintf( f, " if( exists() )\n" ); + fprintf( f, " {\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + if( TYPEis_entity( t ) ) + fprintf( f, " return( _%s->Name() );\n" + StrToLower( TYPEget_name( t ) ) ); else { - fprintf(f, " return( \"%s\" );\n", TYPEget_utype(t)); + fprintf( f, " return( \"%s\" );\n", TYPEget_utype( t ) ); } LISTod; - fprintf(f, " }\n return NULL;\n}\n\n"); - - fprintf(f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n); - fprintf(f, " if( exists() )\n"); - fprintf(f, " {\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - if(TYPEis_entity(t)) { - fprintf(f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype(t)); - fprintf(f, " return( _%s->eDesc );\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " }\n return NULL;\n}\n\n" ); + + fprintf( f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n ); + fprintf( f, " if( exists() )\n" ); + fprintf( f, " {\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( TYPEis_entity( t ) ) { + fprintf( f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype( t ) ); + fprintf( f, " return( _%s->eDesc );\n", + SEL_ITEMget_dmname( t ) ); } LISTod; - fprintf(f, " }\n return NULL;\n}\n\n"); + fprintf( f, " }\n return NULL;\n}\n\n" ); #endif - if(dup_result) { - fprintf(f, "\n // part 7\n"); - fprintf(f, - "const TypeDescriptor * \n" - "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" - " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", - n); + if( dup_result ) { + fprintf( f, "\n // part 7\n" ); + fprintf( f, + "const TypeDescriptor * \n" + "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" + " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", + n ); } #ifdef PART8 - fprintf(f, "\n // part 8\n"); - fprintf(f, "%s* %s::operator->()\n", n, n); - fprintf(f, "{\n return this;\n}\n"); + fprintf( f, "\n // part 8\n" ); + fprintf( f, "%s* %s::operator->()\n", n, n ); + fprintf( f, "{\n return this;\n}\n" ); #endif - LISTfree(dups); + LISTfree( dups ); - fprintf(f, "////////// END SELECT TYPE %s\n\n", n); + fprintf( f, "////////// END SELECT TYPE %s\n\n", n ); } -void TYPEselect_print(Type t, FILES *files, Schema schema) -{ +void TYPEselect_print( Type t, FILES * files, Schema schema ) { SelectTag tag, tmp; Type i, bt; /* type of elements in an aggregate */ char nm[BUFSIZ], tdnm[BUFSIZ]; - FILE *inc = files->inc; + FILE * inc = files->inc; /* if type is already marked, return */ - if((tmp = (SelectTag) TYPEget_clientData(t))) { - if((tmp ->started) && (! tmp ->complete)) - fprintf(stderr, "WARNING: SELECT type %s causes circular references\n", - TYPEget_name(t)); + if( ( tmp = ( SelectTag ) TYPEget_clientData( t ) ) ) { + if( ( tmp ->started ) && ( ! tmp ->complete ) ) + fprintf( stderr, "WARNING: SELECT type %s causes circular references\n", + TYPEget_name( t ) ); return; } /* mark the type as being processed */ - tag = (SelectTag) sc_malloc(sizeof(struct SelectTag_)); + tag = ( SelectTag ) sc_malloc( sizeof( struct SelectTag_ ) ); tag -> started = 1; tag -> complete = 0; - TYPEput_clientData(t, (ClientData) tag); + TYPEput_clientData( t, ( ClientData ) tag ); /* Check if we're a renamed type, e.g., TYPE B (sel) = A. If so, if A has @@ -1928,48 +1873,48 @@ void TYPEselect_print(Type t, FILES *files, Schema schema) some are printed in files->classes rather than here). If A has not been defined, we must recurse. */ - if((i = TYPEget_ancestor(t)) != NULL) { - if(!TYPEget_clientData(i)) { - TYPEselect_print(i, files, schema); + if( ( i = TYPEget_ancestor( t ) ) != NULL ) { + if( !TYPEget_clientData( i ) ) { + TYPEselect_print( i, files, schema ); } - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); - strncpy(tdnm, TYPEtd_name(t), BUFSIZ); - fprintf(inc, "typedef %s * %sH;\n", nm, nm); - fprintf(inc, "typedef %s_ptr * %s_var;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); + strncpy( tdnm, TYPEtd_name( t ), BUFSIZ ); + fprintf( inc, "typedef %s * %sH;\n", nm, nm ); + fprintf( inc, "typedef %s_ptr * %s_var;\n", nm, nm ); /* Below are specialized create functions for the renamed sel type (both single and aggregate). The functions call the original sel's con- structor, passing the new sel's typedescriptor to create a hybrid entity - the original select pointing to a new typedesc. These fns give the user an easy way to create the renamed type properly. */ - fprintf(inc, "inline SDAI_Select *\ncreate_%s ()", nm); - fprintf(inc, " { return new %s( %s ); }\n\n", nm, tdnm); - fprintf(inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm); - fprintf(inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm); + fprintf( inc, "inline SDAI_Select *\ncreate_%s ()", nm ); + fprintf( inc, " { return new %s( %s ); }\n\n", nm, tdnm ); + fprintf( inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm ); + fprintf( inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm ); return; } - LISTdo(SEL_TYPEget_items(t), ii, Type) { + LISTdo( SEL_TYPEget_items( t ), ii, Type ) { /* check the items for select types */ /* and do the referenced select types first */ /* check aggregates too */ /* set ii to the bt and catch in next ifs */ - if(isAggregateType(ii)) { - bt = TYPEget_base_type(ii); + if( isAggregateType( ii ) ) { + bt = TYPEget_base_type( ii ); /* DAR - corrected - prev'ly above line retrieved non-aggr base type. But unnec - we only need the item defined if it's a select or a 1D aggregate. If bt is also an aggr, we go on. */ - if(TYPEis_select(bt)) { + if( TYPEis_select( bt ) ) { ii = bt; - } else if(TYPEis_entity(bt)) { + } else if( TYPEis_entity( bt ) ) { ii = bt; } } - if(TYPEis_select(ii) && !TYPEget_clientData(ii)) { - TYPEselect_print(ii, files, schema); + if( TYPEis_select( ii ) && !TYPEget_clientData( ii ) ) { + TYPEselect_print( ii, files, schema ); } /* NOTE - there was a bug here because above if did not take into account that ii came from a different schema (and above loop would have printed @@ -1980,17 +1925,16 @@ void TYPEselect_print(Type t, FILES *files, Schema schema) schema. So the above if will only reorder the printing of the sel's in this schema, which is the intent. DAR */ - } - LISTod + } LISTod - TYPEPrint(t, files, schema); + TYPEPrint(t, files, schema ); /* TYPEselect_inc_print( t, files -> inc ); */ /* TYPEselect_lib_print( t, files -> lib ); */ /* TYPEselect_init_print (t, files -> init, schema); DAR - moved to TYPEprint_init() - to keep init info together. */ tag -> complete = 1; - sc_free(tag); + sc_free( tag ); } #undef BASE_SELECT diff --git a/src/exp2cxx/trynext.cc b/src/exp2cxx/trynext.cc index cb50d2eed..97cacc8a3 100644 --- a/src/exp2cxx/trynext.cc +++ b/src/exp2cxx/trynext.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static EntList *firstCandidate(EntList *); -static EntList *nextCandidate(EntList *); +static EntList * firstCandidate( EntList * ); +static EntList * nextCandidate( EntList * ); -MatchType MultList::tryNext(EntNode *ents) +MatchType MultList::tryNext( EntNode * ents ) /* * Loops backwards through the children of this, recursively searching for * alternate solutions (i.e., OR's which have alternate paths we haven't @@ -31,15 +31,15 @@ MatchType MultList::tryNext(EntNode *ents) */ { MatchType retval; - EntList *child = getLast(); + EntList * child = getLast(); - child = firstCandidate(child); - while(child != NULL) { - if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { + child = firstCandidate( child ); + while( child != NULL ) { + if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { // We're done - a good solution was found. return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -47,83 +47,83 @@ MatchType MultList::tryNext(EntNode *ents) // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while((child = nextCandidate(child)) != NULL) { - if(child->acceptChoice(ents) && ents->allMarked()) { + while( ( child = nextCandidate( child ) ) != NULL ) { + if( child->acceptChoice( ents ) && ents->allMarked() ) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate(child->prev); + child = firstCandidate( child->prev ); } // If we got here, we didn't find any new OR choices: return NOMORE; } -static EntList *firstCandidate(EntList *child) +static EntList * firstCandidate( EntList * child ) /* * Finds an EntList from child's list which may have an OR with more * choices below it. The acceptable choices are described in commenting * below. */ { - EntList *ent = child->lastNot(SIMPLE); + EntList * ent = child->lastNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot(SIMPLE); + ent = ent->prevNot( SIMPLE ); } return ent; } -static EntList *nextCandidate(EntList *child) +static EntList * nextCandidate( EntList * child ) /* * Same as prev function, searches forwards from ent after child. */ { - EntList *ent = child->nextNot(SIMPLE); + EntList * ent = child->nextNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { return ent; } - ent = ent->nextNot(SIMPLE); + ent = ent->nextNot( SIMPLE ); } return ent; } -MatchType OrList::tryNext(EntNode *ents) +MatchType OrList::tryNext( EntNode * ents ) /* * Tries out the next choice of this. Basic algorithm is to first recurse * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ { - EntList *child; + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild(choice); - if(child->multiple()) { - MatchType retval; + child = getChild( choice ); + if( child->multiple() ) { + MatchType retval; // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - retval = (dynamic_cast< MultList * >(child))->tryNext(ents); - if(retval == MATCHALL) { + retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ); + if( retval == MATCHALL ) { return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -134,8 +134,8 @@ MatchType OrList::tryNext(EntNode *ents) // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll(ents); - if(choiceCount == 1) { + child->unmarkAll( ents ); + if( choiceCount == 1 ) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -144,8 +144,8 @@ MatchType OrList::tryNext(EntNode *ents) } // Otherwise, try our next: - if(acceptNextChoice(ents)) { - if(ents->allMarked()) { + if( acceptNextChoice( ents ) ) { + if( ents->allMarked() ) { return MATCHALL; } return NEWCHOICE; diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 1318ec1ed..964aca652 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -14,9 +14,9 @@ #include // Local function prototypes: -static void writeheader(ostream &, int); +static void writeheader( ostream &, int ); -void print_complex(ComplexCollect &collect, const char *filename) +void print_complex( ComplexCollect & collect, const char * filename ) /* * Standalone function called from exp2cxx. Takes a ComplexCollect * and writes its contents to a file (filename) which can be used to @@ -24,19 +24,19 @@ void print_complex(ComplexCollect &collect, const char *filename) */ { #ifdef COMPLEX_INFO - ComplexList *cl; - if(collect.clists) { + ComplexList * cl; + if( collect.clists ) { // If there's something in this collect, print it out: cout << "\nHere's everything:\n"; - for(cl = collect.clists; cl != NULL; cl = cl->next) { + for( cl = collect.clists; cl != NULL; cl = cl->next ) { cout << *cl << endl; } } #endif - collect.write(filename); + collect.write( filename ); } -void ComplexCollect::write(const char *fname) +void ComplexCollect::write( const char * fname ) /* * Generates C++ code in os which may be compiled and run to create a * ComplexCollect structure. Functions are called to write out the @@ -44,22 +44,22 @@ void ComplexCollect::write(const char *fname) */ { ofstream complex; - ComplexList *clist; + ComplexList * clist; int maxlevel, listmax; // Open the stream: - complex.open(fname); - if(!complex) { + complex.open( fname ); + if( !complex ) { cerr << "ERROR: Could not create output file " << fname << endl; // yikes this is pretty drastic, Sun C++ doesn't like this anyway DAS // exit(-1); return; } - writeheader(complex, clists == NULL); + writeheader( complex, clists == NULL ); // If there's nothing in this, make function a stub (very little was // printed in writeheader() also): - if(clists == NULL) { + if( clists == NULL ) { complex << " return 0;" << endl; complex << "}" << endl; complex.close(); @@ -75,9 +75,9 @@ void ComplexCollect::write(const char *fname) // of an array to create. maxlevel = 0; clist = clists; - while(clist) { + while( clist ) { listmax = clist->getEntListMaxLevel(); - if(listmax > maxlevel) { + if( listmax > maxlevel ) { maxlevel = listmax; } clist = clist->next; @@ -88,11 +88,11 @@ void ComplexCollect::write(const char *fname) // Next create the CCollect and CLists: complex << " cc = new ComplexCollect;\n"; clist = clists; - while(clist) { + while( clist ) { complex << endl; complex << " // ComplexList with supertype \"" << clist->supertype() << "\":\n"; - clist->write(complex); + clist->write( complex ); complex << " cc->insert( cl );\n"; clist = clist->next; } @@ -103,14 +103,14 @@ void ComplexCollect::write(const char *fname) complex.close(); } -static void writeheader(ostream &os, int noLists) +static void writeheader( ostream & os, int noLists ) /* * Writes the header for the complex file. */ { // If there are no ComplexLists in the ComplexCollect, make this function // a stub: - if(noLists) { + if( noLists ) { os << "/*" << endl << " * This file normally contains instantiation statements to\n" << " * create complex support structures. For the current EXPRESS\n" @@ -142,39 +142,39 @@ static void writeheader(ostream &os, int noLists) os << "{" << endl; } -void ComplexList::write(ostream &os) +void ComplexList::write( ostream & os ) /* * Generates C++ code in os which will create an instantiation of a CList * which will recreate this. */ { - head->write(os); + head->write( os ); os << " cl = new ComplexList((AndList *)node);\n"; os << " cl->buildList();\n"; os << " cl->head->setLevel( 0 );\n"; } -void MultList::write(ostream &os) +void MultList::write( ostream & os ) /* * Writes to os code to instantiate a replica of this. Does so by first * recursing to replicate this's children, and then instantiating this. * When write() is finished, the "node" variable in os will point to this. */ { - EntList *child = getLast(); + EntList * child = getLast(); // First write our children, from last to first. (We go in backwards order // so that "node" (a variable name in the os) will = our first child when // this loop is done. See below.) - child->write(os); - while(child->prev) { + child->write( os ); + while( child->prev ) { // Whenever an EntList::write() function is called, it writes to os // an instantiation statement basically of the form "node = new XXX- // List;". So we know that in the output file (os) the newly-created // EntList is pointed to by variable node. os << " next[" << level + 1 << "] = node;\n"; child = child->prev; - child->write(os); + child->write( os ); os << " next[" << level + 1 << "]->prev = node;\n"; os << " node->next = next[" << level + 1 << "];\n"; } @@ -186,9 +186,9 @@ void MultList::write(ostream &os) // node. We do this so that node will = this when we're done and return // to the calling function (so the calling fn can make the same assumption // we just did). - if(join == AND) { + if( join == AND ) { os << " node = new AndList;\n"; - } else if(join == ANDOR) { + } else if( join == ANDOR ) { os << " node = new AndOrList;\n"; } else { os << " node = new OrList;\n"; @@ -197,7 +197,7 @@ void MultList::write(ostream &os) // The above line will set node's childList and numchidren count. } -void SimpleList::write(ostream &os) +void SimpleList::write( ostream & os ) /* * Writes to os a statement to instantiate this. */ diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index a9feb39d2..0cbf338aa 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -31,6 +31,9 @@ if(SC_PYTHON_GENERATOR) ) SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(exp2python version_string) + endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) endif(SC_PYTHON_GENERATOR) # Local Variables: diff --git a/src/exp2python/src/classes.h b/src/exp2python/src/classes.h index 715a7e550..a76cb6afa 100644 --- a/src/exp2python/src/classes.h +++ b/src/exp2python/src/classes.h @@ -51,86 +51,86 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define TYPEtd_name(t) TypeDescriptorName (t) typedef struct file_holder { - FILE *inc; /**< include file */ - FILE *lib; /**< library file */ - FILE *incall; /**< include file for collecting all include files */ - FILE *initall; /**< for registering all entities from all schemas */ - FILE *init; /**< contains function to initialize program to use schema's entities */ - FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE * inc; /**< include file */ + FILE * lib; /**< library file */ + FILE * incall; /**< include file for collecting all include files */ + FILE * initall; /**< for registering all entities from all schemas */ + FILE * init; /**< contains function to initialize program to use schema's entities */ + FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ - FILE *helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for + FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE * helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for helper functions to find runtime aggregate bounds */ } File_holder, FILES; /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ *EntityTag; +typedef struct EntityTag_ * EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ Entity superclass; /**< the entity being used as the supertype - with multiple inheritance only chose one */ }; -Entity ENTITYget_superclass(Entity entity); -Entity ENTITYput_superclass(Entity entity); -int ENTITYhas_explicit_attributes(Entity e); -void ENTITYget_first_attribs(Entity entity, Linked_List result); +Entity ENTITYget_superclass( Entity entity ); +Entity ENTITYput_superclass( Entity entity ); +int ENTITYhas_explicit_attributes( Entity e ); +void ENTITYget_first_attribs( Entity entity, Linked_List result ); /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ *SelectTag; +typedef struct SelectTag_ * SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char *GetTypeDescriptorName(Type t); -char *format_for_stringout(char *orig_buf, char *return_buf); -void format_for_std_stringout(FILE *f, char *orig_buf); -const char *CheckWord(const char *); -const char *StrToLower(const char *); -const char *StrToUpper(const char *); -const char *FirstToUpper(const char *); -const char *SelectName(const char *); -FILE *FILEcreate(const char *); -void FILEclose(FILE *); -const char *ClassName(const char *); -const char *ENTITYget_classname(Entity); -void FUNCPrint(Function function, FILES *files); -void RULEPrint(Rule rule, FILES *files); -void ENTITYPrint(Entity, FILES *); -const char *StrToConstant(const char *); -void TYPEselect_print(Type, FILES *, Schema); -void ENTITYprint_new(Entity, FILES *, Schema, int); -void TYPEprint_definition(Type, FILES *, Schema); -void TYPEprint_new(const Type, FILE *, Schema); -void TYPEprint_typedefs(Type, FILE *); -void TYPEprint_descriptions(const Type, FILES *, Schema); -void TYPEprint_init(const Type type, FILES *files, Schema schema); -void AGGRprint_init(FILES *files, const Type t, - const char *var_name, const char *aggr_name); -void TYPEselect_init_print(const Type type, FILE *f); -void MODELPrint(Entity, FILES *, Schema, int); -void MODELprint_new(Entity entity, FILES *files); -void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); -const char *PrettyTmpName(const char *oldname); -const char *EnumName(const char *oldname); -const char *TypeDescriptorName(Type); -char *TypeDescription(const Type t); -const char *AccessType(Type t); -const char *TYPEget_ctype(const Type t); -void print_file(Express); -void resolution_success(void); -void SCHEMAprint(Schema schema, FILES *files, int suffix); -Type TYPEget_ancestor(Type t); -const char *FundamentalType(const Type t, int report_reftypes); +const char * GetTypeDescriptorName( Type t ); +char * format_for_stringout( char * orig_buf, char * return_buf ); +void format_for_std_stringout( FILE* f, char* orig_buf ); +const char * CheckWord( const char * ); +const char * StrToLower( const char * ); +const char * StrToUpper( const char * ); +const char * FirstToUpper( const char * ); +const char * SelectName( const char * ); +FILE * FILEcreate( const char * ); +void FILEclose( FILE * ); +const char * ClassName( const char * ); +const char * ENTITYget_classname( Entity ); +void FUNCPrint( Function function, FILES* files ); +void RULEPrint( Rule rule, FILES* files ); +void ENTITYPrint( Entity, FILES * ); +const char * StrToConstant( const char * ); +void TYPEselect_print( Type, FILES *, Schema ); +void ENTITYprint_new( Entity, FILES *, Schema, int ); +void TYPEprint_definition( Type, FILES *, Schema ); +void TYPEprint_new( const Type, FILE *, Schema ); +void TYPEprint_typedefs( Type, FILE * ); +void TYPEprint_descriptions( const Type, FILES *, Schema ); +void TYPEprint_init( const Type type, FILES * files, Schema schema ); +void AGGRprint_init( FILES * files, const Type t, + const char * var_name, const char * aggr_name ); +void TYPEselect_init_print( const Type type, FILE* f ); +void MODELPrint( Entity, FILES *, Schema, int ); +void MODELprint_new( Entity entity, FILES* files ); +void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); +const char * PrettyTmpName( const char * oldname ); +const char * EnumName( const char * oldname ); +const char * TypeDescriptorName( Type ); +char * TypeDescription( const Type t ); +const char * AccessType( Type t ); +const char * TYPEget_ctype( const Type t ); +void print_file( Express ); +void resolution_success( void ); +void SCHEMAprint( Schema schema, FILES* files, int suffix ); +Type TYPEget_ancestor( Type t ); +const char * FundamentalType( const Type t, int report_reftypes ); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -138,12 +138,12 @@ const char *FundamentalType(const Type t, int report_reftypes); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider(Entity e, Variable a); +Variable VARis_overrider( Entity e, Variable a ); /* Added for multiple schema support: */ -void print_schemas_separate(Express, FILES *); -void getMCPrint(Express, FILE *, FILE *); -int sameSchema(Scope, Scope); +void print_schemas_separate( Express, FILES * ); +void getMCPrint( Express, FILE *, FILE * ); +int sameSchema( Scope, Scope ); #endif diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 0420b74d9..a425f0d88 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -1,7 +1,5 @@ #define CLASSES_MISC_C -#define _POSIX_C_SOURCE 200809L /* for strdup */ #include -#include #include "classes.h" /******************************************************************* ** FedEx parser output module for generating C++ class definitions @@ -36,12 +34,11 @@ extern int multiple_inheritance; ** Status: started 12/1 ******************************************************************/ const char * -CheckWord(const char *word) -{ +CheckWord( const char * word ) { #ifdef NOT_USING_SDAI_BINDING /* obsolete with proposed c++ binding */ - static char *reserved_words [] = { + static char * reserved_words [] = { "application_marker", "asm", "attributes", "auto", "break", "case", "char", "class", "const", "continue", "default", "delete", "do", "double", @@ -55,30 +52,30 @@ CheckWord(const char *word) "union", "unsigned", "val", "virtual", "void", "volatile" }; - int nwords = (sizeof reserved_words / sizeof reserved_words[0]); + int nwords = ( sizeof reserved_words / sizeof reserved_words[0] ); int cond, i, low = 0, high = nwords - 1; /* word is obviously not in list, if it is longer than any of the words in the list */ - if(strlen(word) > 18) { - return (word); + if( strlen( word ) > 18 ) { + return ( word ); } - while(low <= high) { - i = (low + high) / 2; - if((cond = strcmp(word, reserved_words [i])) < 0) { + while( low <= high ) { + i = ( low + high ) / 2; + if( ( cond = strcmp( word, reserved_words [i] ) ) < 0 ) { high = i - 1; - } else if(cond > 0) { + } else if( cond > 0 ) { low = i + 1; } else { /* word is a reserved word, capitalize it */ - fprintf(stderr, "Warning: reserved word %s capitalized\n", word); - *word = toupper(*word); + fprintf( stderr, "Warning: reserved word %s capitalized\n", word ); + *word = toupper( *word ); } } #endif - return (word); + return ( word ); } @@ -94,255 +91,239 @@ CheckWord(const char *word) ******************************************************************/ char -ToLower(char c) -{ - if(isupper(c)) { - return (tolower(c)); +ToLower( char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } char -ToUpper(char c) -{ - if(islower(c)) { - return (toupper(c)); +ToUpper( char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } const char * -StrToLower(const char *word) -{ +StrToLower( const char * word ) { static char newword [MAX_LEN]; int i = 0; - if(!word) { + if( !word ) { return 0; } - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; - return (newword) ; + return ( newword ) ; } -const char *StrToUpper(const char *word) -{ +const char * StrToUpper( const char * word ) { static char newword [MAX_LEN]; int i = 0; - char ToUpper(char c); + char ToUpper( char c ); - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *StrToConstant(const char *word) -{ +const char * StrToConstant( const char * word ) { static char newword [MAX_LEN]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } /** creates a file for python */ -FILE *FILEcreate(const char *filename) -{ - FILE *file; +FILE * FILEcreate( const char * filename ) { + FILE * file; - if((file = fopen(filename, "w")) == NULL) { - fprintf(stderr, "Error in SCHEMAprint: unable to create file %s\n", filename); - return (NULL); + if( ( file = fopen( filename, "w" ) ) == NULL ) { + fprintf( stderr, "Error in SCHEMAprint: unable to create file %s\n", filename ); + return ( NULL ); } - fprintf(file, "# This file was generated by exp2python. You probably don't want to edit\n"); - fprintf(file, "# it since your modifications will be lost if exp2python is used to\n"); - fprintf(file, "# regenerate it.\n"); - return (file); + fprintf( file, "# This file was generated by exp2python. You probably don't want to edit\n" ); + fprintf( file, "# it since your modifications will be lost if exp2python is used to\n" ); + fprintf( file, "# regenerate it.\n" ); + return ( file ); } /** closes a file opened with FILEcreate */ -void FILEclose(FILE *file) -{ - fclose(file); +void FILEclose( FILE * file ) { + fclose( file ); } /** indicates whether the attribute is an aggregate */ -int isAggregate(Variable a) -{ - return(TYPEinherits_from(VARget_type(a), aggregate_)); +int isAggregate( Variable a ) { + return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); } /** indicates whether the type is an aggregate type */ -int isAggregateType(const Type t) -{ - return(TYPEinherits_from(t, aggregate_)); +int isAggregateType( const Type t ) { + return( TYPEinherits_from( t, aggregate_ ) ); } /** returns temporary copy of name suitable for use as a class name * * each call erases the name created by a previous call to this function */ -const char *ClassName(const char *oldname) -{ +const char * ClassName( const char * oldname ) { int i = 0, j = 0; static char newname [BUFSIZ]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENTITYCLASS_PREFIX) ; - j = strlen(ENTITYCLASS_PREFIX) ; - newname [j] = ToUpper(oldname [i]); + strcpy( newname, ENTITYCLASS_PREFIX ) ; + j = strlen( ENTITYCLASS_PREFIX ) ; + newname [j] = ToUpper( oldname [i] ); ++i; ++j; - while(oldname [i] != '\0') { - newname [j] = ToLower(oldname [i]); + while( oldname [i] != '\0' ) { + newname [j] = ToLower( oldname [i] ); ++i; ++j; } newname [j] = '\0'; - return (newname); + return ( newname ); } /** returns the name of the c++ class representing the entity */ -const char *ENTITYget_classname(Entity ent) -{ - const char *oldname = ENTITYget_name(ent); - return (ClassName(oldname)); +const char * ENTITYget_classname( Entity ent ) { + const char * oldname = ENTITYget_name( ent ); + return ( ClassName( oldname ) ); } /** returns a new capitalized name, in internal static buffer */ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } /** This function is out of date DAS */ -const char *EnumName(const char *oldname) -{ +const char * EnumName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENUM_PREFIX) ; - j = strlen(ENUM_PREFIX) ; - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); - j = strlen(newname); + strcpy( newname, ENUM_PREFIX ) ; + j = strlen( ENUM_PREFIX ) ; + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *SelectName(const char *oldname) -{ +const char * SelectName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, TYPE_PREFIX); - newname [0] = ToUpper(newname [0]); - j = strlen(TYPE_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); - j = strlen(newname); + strcpy( newname, TYPE_PREFIX ); + newname [0] = ToUpper( newname [0] ); + j = strlen( TYPE_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *FirstToUpper(const char *word) -{ +const char * FirstToUpper( const char * word ) { static char newword [MAX_LEN]; - strncpy(newword, word, MAX_LEN); - newword[0] = ToUpper(newword[0]); - return (newword); + strncpy( newword, word, MAX_LEN ); + newword[0] = ToUpper( newword[0] ); + return ( newword ); } /** return fundamental type but as the string which corresponds to * the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char *FundamentalType(const Type t, int report_reftypes) -{ - if(report_reftypes && TYPEget_head(t)) { - return("REFERENCE_TYPE"); +const char * FundamentalType( const Type t, int report_reftypes ) { + if( report_reftypes && TYPEget_head( t ) ) { + return( "REFERENCE_TYPE" ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: - return("INTEGER"); + return( "INTEGER" ); case real_: - return("REAL"); + return( "REAL" ); case string_: - return("STRING"); + return( "STRING" ); case binary_: - return("BINARY"); + return( "BINARY" ); case boolean_: - return("BOOLEAN"); + return( "BOOLEAN" ); case logical_: - return("LOGICAL"); + return( "LOGICAL" ); case number_: - return("NUMBER"); + return( "NUMBER" ); case generic_: - return("GENERIC_TYPE"); + return( "GENERIC_TYPE" ); case aggregate_: - return("AGGREGATE_"); + return( "AGGREGATE_" ); case array_: - return("ARRAY_TYPE"); + return( "ARRAY_TYPE" ); case bag_: - return("BAG_TYPE"); + return( "BAG_TYPE" ); case set_: - return("'SET_TYPE not implemented'"); + return( "'SET_TYPE not implemented'" ); case list_: - return("'LIST TYPE Not implemented'"); + return( "'LIST TYPE Not implemented'" ); case entity_: - return("INSTANCE"); + return( "INSTANCE" ); case enumeration_: - return("ENUMERATION"); + return( "ENUMERATION" ); case select_: - return ("SELECT"); + return ( "SELECT" ); default: - return("UNKNOWN_TYPE"); + return( "UNKNOWN_TYPE" ); } } @@ -350,32 +331,30 @@ const char *FundamentalType(const Type t, int report_reftypes) * be a TypeDescriptor or subtype of TypeDescriptor to represent Type t in * the dictionary. */ -const char *TypeDescriptorName(Type t) -{ +const char * TypeDescriptorName( Type t ) { static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if(!parent) { - parent = TYPEget_body(t)->entity->superscope; + if( !parent ) { + parent = TYPEget_body( t )->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf(b, "%s%s%s", SCHEMAget_name(parent), TYPEprefix(t), - TYPEget_name(t)); + sprintf( b, "%s%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), + TYPEget_name( t ) ); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char *GetTypeDescriptorName(Type t) -{ - switch(TYPEget_body(t)->type) { +const char * GetTypeDescriptorName( Type t ) { + switch( TYPEget_body( t )->type ) { case aggregate_: return "AggrTypeDescriptor"; @@ -410,17 +389,16 @@ const char *GetTypeDescriptorName(Type t) case generic_: return "TypeDescriptor"; default: - fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } } -int ENTITYhas_explicit_attributes(Entity e) -{ - Linked_List l = ENTITYget_attributes(e); +int ENTITYhas_explicit_attributes( Entity e ) { + Linked_List l = ENTITYget_attributes( e ); int cnt = 0; - LISTdo(l, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( l, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { ++cnt; } LISTod; @@ -428,22 +406,21 @@ int ENTITYhas_explicit_attributes(Entity e) } -Entity ENTITYput_superclass(Entity entity) -{ +Entity ENTITYput_superclass( Entity entity ) { #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes(entity); + Linked_List l = ENTITYget_supertypes( entity ); EntityTag tag; - if(! LISTempty(l)) { + if( ! LISTempty( l ) ) { Entity super = 0; - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List list = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { /* assign superclass to be the first one on the list of parents */ - super = (Entity)LISTpeek_first(list); + super = ( Entity )LISTpeek_first( list ); } } else { Entity ignore = 0; @@ -451,53 +428,50 @@ Entity ENTITYput_superclass(Entity entity) /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo(l, e, Entity) { + LISTdo( l, e, Entity ) { /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if((! super) || (! ENTITYhas_explicit_attributes(super))) { + if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if(ignore) { - printf("WARNING: multiple inheritance not implemented.\n"); - printf("\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", - ENTITYget_name(entity), ENTITYget_name(e)); + if( ignore ) { + printf( "WARNING: multiple inheritance not implemented.\n" ); + printf( "\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", + ENTITYget_name( entity ), ENTITYget_name( e ) ); } - } - LISTod + } LISTod } - tag = (EntityTag) malloc(sizeof(struct EntityTag_)); + tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; - TYPEput_clientData(ENTITYget_type(entity), tag); + TYPEput_clientData( ENTITYget_type( entity ), tag ); return super; } return 0; } -Entity ENTITYget_superclass(Entity entity) -{ +Entity ENTITYget_superclass( Entity entity ) { EntityTag tag; - tag = TYPEget_clientData(ENTITYget_type(entity)); - return (tag ? tag -> superclass : 0); + tag = TYPEget_clientData( ENTITYget_type( entity ) ); + return ( tag ? tag -> superclass : 0 ); } -void ENTITYget_first_attribs(Entity entity, Linked_List result) -{ +void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo(ENTITYget_attributes(entity), attr, void *) - LISTadd_last(result, attr); + LISTdo( ENTITYget_attributes( entity ), attr, void * ) + LISTadd_last( result, attr ); LISTod; - supers = ENTITYget_supertypes(entity); - if(supers) { - ENTITYget_first_attribs((Entity)LISTget_first(supers), result); + supers = ENTITYget_supertypes( entity ); + if( supers ) { + ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); } } @@ -531,35 +505,33 @@ void ENTITYget_first_attribs(Entity entity, Linked_List result) ** // tell it to be * for reading and writing **/ -Variable VARis_type_shifter(Variable a) -{ - char *temp; +Variable VARis_type_shifter( Variable a ) { + char * temp; - if(VARis_derived(a) || VARget_inverse(a)) { + if( VARis_derived( a ) || VARget_inverse( a ) ) { return 0; } - temp = strdup(VARget_name(a)->symbol.name); - if(! strncmp(StrToLower(temp), "self\\", 5)) { + temp = strdup( VARget_name( a )->symbol.name ); + if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - free(temp); + free( temp ); return a; } - free(temp); + free( temp ); return 0; } -Variable VARis_overrider(Entity e, Variable a) -{ +Variable VARis_overrider( Entity e, Variable a ) { Variable other; - char *tmp; + char * tmp; - tmp = VARget_simple_name(a); + tmp = VARget_simple_name( a ); - LISTdo(ENTITYget_supertypes(e), s, Entity) - if((other = ENTITYget_named_attribute(s, tmp)) - && other != a) { + LISTdo( ENTITYget_supertypes( e ), s, Entity ) + if( ( other = ENTITYget_named_attribute( s, tmp ) ) + && other != a ) { return other; } LISTod; @@ -570,16 +542,15 @@ Variable VARis_overrider(Entity e, Variable a) * For a renamed type, returns the original (ancestor) type from which t * descends. Return NULL if t is top level. */ -Type TYPEget_ancestor(Type t) -{ +Type TYPEget_ancestor( Type t ) { Type i = t; - if(!TYPEget_head(i)) { + if( !TYPEget_head( i ) ) { return NULL; } - while(TYPEget_head(i)) { - i = TYPEget_head(i); + while( TYPEget_head( i ) ) { + i = TYPEget_head( i ); } return i; diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index e8d53564d..8c672868a 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -24,10 +24,8 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ -#define _POSIX_C_SOURCE 200809L /* for strdup */ #include #include -#include #include "sc_memmgr.h" #include "classes.h" @@ -51,11 +49,11 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. # define snprintf c99_snprintf #endif -int isAggregateType(const Type t); -int isAggregate(Variable a); -Variable VARis_type_shifter(Variable a); -const char *GetTypeDescriptorName(Type t); -void TYPEselect_lib_print(const Type type, FILE *f); +int isAggregateType( const Type t ); +int isAggregate( Variable a ); +Variable VARis_type_shifter( Variable a ); +const char * GetTypeDescriptorName( Type t ); +void TYPEselect_lib_print( const Type type, FILE * f ); int multiple_inheritance = 1; int print_logging = 0; @@ -76,37 +74,37 @@ int old_accessors = 0; static int attr_count; /* number each attr to avoid inter-entity clashes */ /* static int type_count; NOTE unused / * number each temporary type for same reason above */ -extern int any_duplicates_in_select(const Linked_List list); -extern int unique_types(const Linked_List list); -extern char *non_unique_types_string(const Type type); +extern int any_duplicates_in_select( const Linked_List list ); +extern int unique_types( const Linked_List list ); +extern char * non_unique_types_string( const Type type ); /* static void printEnumCreateHdr( FILE *, const Type ); //NOTE - unused * static void printEnumCreateBody( FILE *, const Type ); * static void printEnumAggrCrHdr( FILE *, const Type ); * static void printEnumAggrCrBody( FILE *, const Type ); */ -void printAccessHookFriend(FILE *, const char *); -void printAccessHookHdr(FILE *, const char *); -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); -void TypeBody_Description(TypeBody body, char *buf); - -void STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file); -void STATEMENTPrint(Statement s, int indent_level, FILE *file); -void STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file); -void EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file); -void EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); -void EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); -void EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); -void ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file); -void ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); -void ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); -void ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); -void CASEout(struct Case_Statement_ *c, int level, FILE *file); -void LOOPpyout(struct Loop_ *loop, int level, FILE *file); -void WHEREPrint(Linked_List wheres, int level, FILE *file); - -void Type_Description(const Type, char *); - -char *EXPRto_python(Expression e); +void printAccessHookFriend( FILE *, const char * ); +void printAccessHookHdr( FILE *, const char * ); +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); +void TypeBody_Description( TypeBody body, char * buf ); + +void STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ); +void STATEMENTPrint( Statement s, int indent_level, FILE * file ); +void STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ); +void EXPRESSION__out( Expression e, int paren, Op_Code previous_op , FILE * file ); +void EXPRESSIONop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); +void EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); +void EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); +void ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ); +void ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); +void ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); +void ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); +void CASEout( struct Case_Statement_ *c, int level, FILE * file ); +void LOOPpyout( struct Loop_ *loop, int level, FILE * file ); +void WHEREPrint( Linked_List wheres, int level , FILE * file ); + +void Type_Description( const Type, char * ); + +char * EXPRto_python( Expression e ); /* Turn the string into a new string that will be printed the same as the @@ -114,16 +112,15 @@ original string. That is, turn backslash into a quoted backslash and turn \n into "\n" (i.e. 2 chars). */ -char *format_for_stringout(char *orig_buf, char *return_buf) -{ - char *optr = orig_buf; - char *rptr = return_buf; - while(*optr) { - if(*optr == '\n') { +char * format_for_stringout( char * orig_buf, char * return_buf ) { + char * optr = orig_buf; + char * rptr = return_buf; + while( *optr ) { + if( *optr == '\n' ) { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if(*optr == '\\') { + } else if( *optr == '\\' ) { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -137,61 +134,52 @@ char *format_for_stringout(char *orig_buf, char *return_buf) return return_buf; } -char *strliteral_py_dup(char *orig_buf) -{ - char *new_buf = strdup(orig_buf); - char *tmp = new_buf; +char * strliteral_py_dup( char * orig_buf ) { + char * new_buf = strdup(orig_buf); + char * tmp = new_buf; - while((tmp = strstr(tmp, "\\x9"))) { - tmp++ ; - *tmp = 't'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\x9"))) { + tmp++ ; *tmp = 't'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } tmp = new_buf; - while((tmp = strstr(tmp, "\\xA"))) { - tmp++ ; - *tmp = 'n'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\xA"))) { + tmp++ ; *tmp = 'n'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } tmp = new_buf; - while((tmp = strstr(tmp, "\\xD"))) { - tmp++ ; - *tmp = 'r'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\xD"))) { + tmp++ ; *tmp = 'r'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } - + return new_buf; } -int Handle_FedPlus_Args(int i, char *arg) -{ +int Handle_FedPlus_Args( int i, char * arg ) { (void) arg; /* unused param */ - if(((char)i == 's') || ((char)i == 'S')) { + if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { multiple_inheritance = 0; } - if(((char)i == 'a') || ((char)i == 'A')) { + if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { old_accessors = 1; } - if((char)i == 'L') { + if( ( char )i == 'L' ) { print_logging = 1; } return 0; } -bool is_python_keyword(char *word) -{ +bool is_python_keyword( char * word ) { int i; - const char *keyword_list[] = {"class", "pass", NULL}; + const char* keyword_list[] = {"class", "pass", NULL}; bool python_keyword = false; - for(i = 0; keyword_list[i] != NULL; i++) { - if(strcmp(word, keyword_list[i]) == 0) { + for( i = 0; keyword_list[i] != NULL; i++ ) { + if( strcmp( word, keyword_list[i] ) == 0 ) { python_keyword = true; } } @@ -207,48 +195,46 @@ bool is_python_keyword(char *word) ** Status: complete 8/5/93 ******************************************************************/ char * -generate_attribute_name(Variable a, char *out) -{ - char *temp, *p, *q; +generate_attribute_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - Expression name = VARget_name(a); - temp = strdup(EXPget_name(name)); + Expression name = VARget_name( a ); + temp = strdup( EXPget_name( name ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; j < BUFSIZ; p++) { + for( j = 0, q = out; j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert */ /* '.' to '_', and convert to lowercase. */ - if((*p != '\n') && (*p != ' ')) { - if(*p == '.') { + if( ( *p != '\n' ) && ( *p != ' ' ) ) { + if( *p == '.' ) { *q = '_'; } else { - *q = tolower(*p); + *q = tolower( *p ); } j++; q++; } } - free(temp); + free( temp ); /* python generator : we should prevend an attr name to be a python reserved keyword */ - if(is_python_keyword(out)) { - strcat(out, "_"); + if( is_python_keyword( out ) ) { + strcat( out, "_" ); } return out; } char * -generate_attribute_func_name(Variable a, char *out) -{ - generate_attribute_name(a, out); - strncpy(out, CheckWord(StrToLower(out)), BUFSIZ); - if(old_accessors) { - out[0] = toupper(out[0]); +generate_attribute_func_name( Variable a, char * out ) { + generate_attribute_name( a, out ); + strncpy( out, CheckWord( StrToLower( out ) ), BUFSIZ ); + if( old_accessors ) { + out[0] = toupper( out[0] ); } else { - out[strlen(out)] = '_'; + out[strlen( out )] = '_'; } return out; } @@ -274,29 +260,28 @@ generate_attribute_func_name(Variable a, char *out) ** Status: complete 8/5/93 ******************************************************************/ char * -generate_dict_attr_name(Variable a, char *out) -{ - char *temp, *p, *q; +generate_dict_attr_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - Expression name = VARget_name(a); - temp = strdup(EXPget_name(name)); + Expression name = VARget_name( a ); + temp = strdup( EXPget_name( name ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ - strncpy(out, StrToLower(p), BUFSIZ); + strncpy( out, StrToLower( p ), BUFSIZ ); /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; j < BUFSIZ; p++) { + for( j = 0, q = out; j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if(*p != '\n') { - *q = tolower(*p); + if( *p != '\n' ) { + *q = tolower( *p ); j++; q++; } } - free(temp); + free( temp ); return out; } @@ -331,21 +316,20 @@ generate_dict_attr_name(Variable a, char *out) ** Status: ok 12-Apr-1993 ******************************************************************/ char * -GetAttrTypeName(Type t) -{ - char *attr_type; - if(TYPEis_string(t)) { +GetAttrTypeName( Type t ) { + char * attr_type; + if( TYPEis_string( t ) ) { attr_type = "STRING"; - } else if(TYPEis_logical(t)) { + } else if( TYPEis_logical( t ) ) { attr_type = "LOGICAL"; - } else if(TYPEis_boolean(t)) { + } else if( TYPEis_boolean( t ) ) { attr_type = "BOOLEAN"; - } else if(TYPEis_real(t)) { + } else if( TYPEis_real( t ) ) { attr_type = "REAL"; - } else if(TYPEis_integer(t)) { + } else if( TYPEis_integer( t ) ) { attr_type = "INTEGER"; } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } return attr_type; } @@ -357,20 +341,19 @@ GetAttrTypeName(Type t) */ void -print_aggregate_type(FILE *file, Type t) -{ - switch(TYPEget_body(t)->type) { +print_aggregate_type( FILE * file, Type t ) { + switch( TYPEget_body( t )->type ) { case array_: - fprintf(file, "ARRAY"); + fprintf( file, "ARRAY" ); break; case bag_: - fprintf(file, "BAG"); + fprintf( file, "BAG" ); break; case set_: - fprintf(file, "SET"); + fprintf( file, "SET" ); break; case list_: - fprintf(file, "LIST"); + fprintf( file, "LIST" ); break; default: break; @@ -380,112 +363,111 @@ print_aggregate_type(FILE *file, Type t) #define BIGBUFSIZ 100000 -char *EXPRto_python(Expression e) -{ - char *buf; - char *temp; +char* EXPRto_python( Expression e ) { + char * buf; + char * temp; unsigned int bufsize = BIGBUFSIZ; - buf = (char *)sc_malloc(bufsize); - if(!buf) { - fprintf(stderr, "%s failed to allocate buffer: %s\n", __func__, strerror(errno)); + buf = ( char * )sc_malloc( bufsize ); + if( !buf ) { + fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno) ); abort(); } - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - snprintf(buf, bufsize, "%d", e->u.integer); + snprintf( buf, bufsize, "%d", e->u.integer ); break; case real_: - if(e == LITERAL_PI) { - strcpy(buf, "math.pi"); - } else if(e == LITERAL_E) { - strcpy(buf, "math.e"); + if( e == LITERAL_PI ) { + strcpy( buf, "math.pi" ); + } else if( e == LITERAL_E ) { + strcpy( buf, "math.e" ); } else { - snprintf(buf, bufsize, "%e", e->u.real); + snprintf( buf, bufsize, "%e", e->u.real ); } break; case binary_: - snprintf(buf, bufsize, "%s", e->u.binary); + snprintf( buf, bufsize, "%s", e->u.binary ); break; case logical_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buf, "True"); + strcpy( buf, "True" ); break; case Lfalse: - strcpy(buf, "False"); + strcpy( buf, "False" ); break; default: - strcpy(buf, "None"); + strcpy( buf, "None" ); break; } - break; + break; case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buf, "True"); + strcpy( buf, "True" ); break; case Lfalse: - strcpy(buf, "False"); + strcpy( buf, "False" ); break; } - break; + break; case string_: - if(TYPEis_encoded(e->type)) { - snprintf(buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + snprintf( buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name ); } else { - temp = strliteral_py_dup(e->symbol.name); - strncpy(buf, temp, bufsize); - free(temp); + temp = strliteral_py_dup( e->symbol.name ); + strncpy( buf, temp, bufsize ); + free(temp); } break; case entity_: case identifier_: case attribute_: case enumeration_: - snprintf(buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name); + snprintf( buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: - strcpy(buf, "# query_ NOT_IMPLEMENTED!"); + strcpy( buf, "# query_ NOT_IMPLEMENTED!" ); break; case self_: - strcpy(buf, "self"); - break; - case funcall_: { - int i = 0; - snprintf(buf, bufsize, "%s(", e->symbol.name); - LISTdo(e->u.funcall.list, arg, Expression) { - i++; - if(i != 1) { - strcat(buf, ", "); - } - temp = EXPRto_python(arg); - strcat(buf, temp); - free(temp); - } - LISTod - strcat(buf, ")"); + strcpy( buf, "self" ); break; + case funcall_: + { + int i = 0; + snprintf( buf, bufsize, "%s(", e->symbol.name ); + LISTdo( e->u.funcall.list, arg, Expression ) { + i++; + if( i != 1 ) { + strcat( buf, ", " ); + } + temp = EXPRto_python( arg ); + strcat( buf, temp ); + free( temp ); + } LISTod + strcat( buf, ")" ); + break; } case op_: - strcpy(buf, "# op_ NOT_IMPLEMENTED!"); + strcpy( buf, "# op_ NOT_IMPLEMENTED!" ); break; case aggregate_: - strcpy(buf, "# aggregate_ NOT_IMPLEMENTED!"); + strcpy( buf, "# aggregate_ NOT_IMPLEMENTED!" ); break; case oneof_: { - strcpy(buf, "# oneof_ NOT_IMPLEMENTED!"); + strcpy( buf, "# oneof_ NOT_IMPLEMENTED!" ); break; } default: - fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); + fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); abort(); } - temp = (char *)sc_realloc(buf, 1 + strlen(buf)); - if(temp == 0) { - fprintf(stderr, "%s failed to realloc buffer: %s\n", __func__, strerror(errno)); + temp = ( char * )sc_realloc( buf, 1 + strlen(buf) ); + if( temp == 0 ) { + fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno) ); abort(); } @@ -498,77 +480,73 @@ char *EXPRto_python(Expression e) * */ void -process_aggregate(FILE *file, Type t) -{ - Expression lower = AGGR_TYPEget_lower_limit(t); - char *lower_str = EXPRto_python(lower); - Expression upper = AGGR_TYPEget_upper_limit(t); - char *upper_str = NULL; +process_aggregate( FILE * file, Type t ) { + Expression lower = AGGR_TYPEget_lower_limit( t ); + char * lower_str = EXPRto_python( lower ); + Expression upper = AGGR_TYPEget_upper_limit( t ); + char * upper_str = NULL; Type base_type; - if(upper == LITERAL_INFINITY) { + if( upper == LITERAL_INFINITY ) { upper_str = "None"; } else { - upper_str = EXPRto_python(upper); + upper_str = EXPRto_python( upper ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case array_: - fprintf(file, "ARRAY"); + fprintf( file, "ARRAY" ); break; case bag_: - fprintf(file, "BAG"); + fprintf( file, "BAG" ); break; case set_: - fprintf(file, "SET"); + fprintf( file, "SET" ); break; case list_: - fprintf(file, "LIST"); + fprintf( file, "LIST" ); break; default: break; } - fprintf(file, "(%s,%s,", lower_str, upper_str); + fprintf( file, "(%s,%s,", lower_str, upper_str ); /*write base type */ - base_type = TYPEget_base_type(t); - if(TYPEis_aggregate(base_type)) { - process_aggregate(file, base_type); - fprintf(file, ")"); /*close parenthesis */ + base_type = TYPEget_base_type( t ); + if( TYPEis_aggregate( base_type ) ) { + process_aggregate( file, base_type ); + fprintf( file, ")" ); /*close parenthesis */ } else { - char *array_base_type = GetAttrTypeName(TYPEget_base_type(t)); - fprintf(file, "'%s', scope = schema_scope)", array_base_type); + char * array_base_type = GetAttrTypeName( TYPEget_base_type( t ) ); + fprintf( file, "'%s', scope = schema_scope)", array_base_type ); } } -int count_supertypes(Entity f) -{ +int count_supertypes(Entity f) { int top_count; int child_count; Linked_List list; list = ENTITYget_supertypes(f); top_count = 0; - LISTdo(list, e, Entity) - child_count = 1; - child_count += count_supertypes(e); - if(child_count > top_count) { - top_count = child_count; - } + LISTdo( list, e, Entity ) + child_count = 1; + child_count += count_supertypes(e); + if (child_count > top_count) + top_count = child_count; LISTod; return top_count; } -int cmp_python_mro(void *e1, void *e2) -{ +int cmp_python_mro( void * e1, void * e2 ) { int e1_chain_len, e2_chain_len; /* TODO: This should do something more intelligent */ - e1_chain_len = count_supertypes((Entity) e1); - e2_chain_len = count_supertypes((Entity) e2); + e1_chain_len = count_supertypes( ( Entity ) e1); + e2_chain_len = count_supertypes( ( Entity ) e2); - if(e1_chain_len == e2_chain_len) { + if (e1_chain_len == e2_chain_len) { return 0; - } else if(e1_chain_len > e2_chain_len) { + } else if (e1_chain_len > e2_chain_len) { return 1; } else { return -1; @@ -576,11 +554,10 @@ int cmp_python_mro(void *e1, void *e2) } void -LIBdescribe_entity(Entity entity, FILE *file) -{ +LIBdescribe_entity( Entity entity, FILE * file ) { int attr_count_tmp = attr_count; char attrnm [BUFSIZ], parent_attrnm[BUFSIZ]; - char *attr_type; + char * attr_type; bool generate_constructor = true; /*by default, generates a python constructor */ bool single_inheritance = false; bool ent_multiple_inheritance = false; @@ -594,34 +571,34 @@ LIBdescribe_entity(Entity entity, FILE *file) /* class name need to use new-style classes for properties to work correctly so class must inherit from object */ - if(is_python_keyword(ENTITYget_name(entity))) { - fprintf(file, "class %s_(", ENTITYget_name(entity)); + if( is_python_keyword( ENTITYget_name( entity ) ) ) { + fprintf( file, "class %s_(", ENTITYget_name( entity ) ); } else { - fprintf(file, "class %s(", ENTITYget_name(entity)); + fprintf( file, "class %s(", ENTITYget_name( entity ) ); } /* * Look for inheritance and super classes */ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); LISTsort(list, cmp_python_mro); num_parent = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) /* if there\'s no super class yet, or the super class doesn\'t have any attributes */ - if(num_parent > 0) { - fprintf(file, ","); /*separator for parent classes names */ + if( num_parent > 0 ) { + fprintf( file, "," ); /*separator for parent classes names */ } - if(is_python_keyword(ENTITYget_name(e))) { - fprintf(file, "%s_", ENTITYget_name(e)); + if( is_python_keyword( ENTITYget_name( e ) ) ) { + fprintf( file, "%s_", ENTITYget_name( e ) ); } else { - fprintf(file, "%s", ENTITYget_name(e)); + fprintf( file, "%s", ENTITYget_name( e ) ); } num_parent++; LISTod; - if(num_parent == 1) { + if( num_parent == 1 ) { single_inheritance = true; ent_multiple_inheritance = false; } else { @@ -631,270 +608,261 @@ LIBdescribe_entity(Entity entity, FILE *file) } else { /*inherit from BaseEntityClass by default, in order to enable decorators */ /* as well as advanced __repr__ feature */ - fprintf(file, "BaseEntityClass"); + fprintf( file, "BaseEntityClass" ); } - fprintf(file, "):\n"); + fprintf( file, "):\n" ); /* * Write docstrings in a Sphinx compliant manner */ - fprintf(file, "\t'''Entity %s definition.\n", ENTITYget_name(entity)); - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - t = VARget_type(v); - fprintf(file, "\n\t:param %s\n", attrnm); - fprintf(file, "\t:type %s:", attrnm); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "\n"); + fprintf( file, "\t'''Entity %s definition.\n", ENTITYget_name( entity ) ); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + t = VARget_type( v ); + fprintf( file, "\n\t:param %s\n", attrnm ); + fprintf( file, "\t:type %s:", attrnm ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "\n" ); } else { - if(TYPEget_name(t) == NULL) { - attr_type = GetAttrTypeName(t); + if( TYPEget_name( t ) == NULL ) { + attr_type = GetAttrTypeName( t ); } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } - fprintf(file, "%s\n", attr_type); + fprintf( file, "%s\n", attr_type ); } attr_count_tmp++; LISTod - fprintf(file, "\t'''\n"); + fprintf( file, "\t'''\n" ); /* * Before writing constructor, check if this entity has any attribute * other wise just a 'pass' statement is enough */ attr_count_tmp = 0; num_derived_inverse_attr = 0; - LISTdo(ENTITYget_attributes(entity), v, Variable) - if(VARis_derived(v) || VARget_inverse(v)) { + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + if( VARis_derived( v ) || VARget_inverse( v ) ) { num_derived_inverse_attr++; } else { attr_count_tmp++; } LISTod - if((attr_count_tmp == 0) && !single_inheritance && !ent_multiple_inheritance) { - fprintf(file, "\t# This class does not define any attribute.\n"); - fprintf(file, "\tpass\n"); + if( ( attr_count_tmp == 0 ) && !single_inheritance && !ent_multiple_inheritance ) { + fprintf( file, "\t# This class does not define any attribute.\n" ); + fprintf( file, "\tpass\n" ); generate_constructor = false; } - if(false) {} + if( false ) {} else { /* * write class constructor */ - if(generate_constructor) { - fprintf(file, "\tdef __init__( self , "); + if( generate_constructor ) { + fprintf( file, "\tdef __init__( self , " ); } /* if inheritance, first write the inherited parameters */ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); num_parent = 0; index_attribute = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { /* search attribute names for superclass */ - LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { - generate_attribute_name(v2, parent_attrnm); - if(!VARis_derived(v2) && !VARget_inverse(v2)) { - fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); + LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { + generate_attribute_name( v2, parent_attrnm ); + if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { + fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); index_attribute++; } - } - LISTod + } LISTod num_parent++; - } - LISTod + } LISTod } - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - if(!VARis_derived(v) && !VARget_inverse(v)) { - fprintf(file, "%s,", attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { + fprintf( file, "%s,", attrnm ); } - } - LISTod + } LISTod /* close constructor method */ - if(generate_constructor) { - fprintf(file, " ):\n"); + if( generate_constructor ) { + fprintf( file, " ):\n" ); } /** if inheritance, first init base class **/ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); index_attribute = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { - if(is_python_keyword(ENTITYget_name(e))) { - fprintf(file, "\t\t%s_.__init__(self , ", ENTITYget_name(e)); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { + if (is_python_keyword(ENTITYget_name( e ))) { + fprintf( file, "\t\t%s_.__init__(self , ", ENTITYget_name( e ) ); } else { - fprintf(file, "\t\t%s.__init__(self , ", ENTITYget_name(e)); + fprintf( file, "\t\t%s.__init__(self , ", ENTITYget_name( e ) ); } /* search and write attribute names for superclass */ - LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { - generate_attribute_name(v2, parent_attrnm); - if(!VARis_derived(v2) && !VARget_inverse(v2)) { - fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); + LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { + generate_attribute_name( v2, parent_attrnm ); + if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { + fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); index_attribute++; } - } - LISTod + } LISTod num_parent++; - fprintf(file, ")\n"); /*separator for parent classes names */ - } - LISTod + fprintf( file, ")\n" ); /*separator for parent classes names */ + } LISTod } /* init variables in constructor */ - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - if(!VARis_derived(v) && !VARget_inverse(v)) { - fprintf(file, "\t\tself._%s = %s\n", attrnm, attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { + fprintf( file, "\t\tself._%s = %s\n", attrnm, attrnm ); } /*attr_count_tmp++; */ LISTod /* * write attributes as python properties */ - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - fprintf(file, "\n\t@property\n"); - if(!strcmp(attrnm, "property")) { - fprintf(file, "\tdef __%s(self):\n", attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + fprintf( file, "\n\t@property\n" ); + if ( !strcmp(attrnm, "property") ) { + fprintf( file, "\tdef __%s(self):\n", attrnm ); rename_python_property = true; } else { - fprintf(file, "\tdef %s(self):\n", attrnm); + fprintf( file, "\tdef %s(self):\n", attrnm ); } /* fget */ - if(!VARis_derived(v)) { - fprintf(file, "\t\treturn self._%s\n", attrnm); + if( !VARis_derived( v ) ) { + fprintf( file, "\t\treturn self._%s\n", attrnm ); } else { /* evaluation of attribute */ - fprintf(file, "\t\tattribute_eval = "); + fprintf( file, "\t\tattribute_eval = " ); /* outputs expression initializer */ - ATTRIBUTE_INITIALIZER_out(v->initializer, 1, file); + ATTRIBUTE_INITIALIZER_out( v->initializer, 1, file ); /* then returns the value */ - fprintf(file, "\n\t\treturn attribute_eval\n"); + fprintf( file, "\n\t\treturn attribute_eval\n" ); } /* fset */ - if(!strcmp(attrnm, "property")) { - fprintf(file, "\t@__%s.setter\n", attrnm); - fprintf(file, "\tdef __%s(self, value):\n", attrnm); + if ( !strcmp(attrnm, "property") ) { + fprintf( file, "\t@__%s.setter\n", attrnm ); + fprintf( file, "\tdef __%s(self, value):\n", attrnm ); } else { - fprintf(file, "\t@%s.setter\n", attrnm); - fprintf(file, "\tdef %s(self, value):\n", attrnm); + fprintf( file, "\t@%s.setter\n", attrnm ); + fprintf( file, "\tdef %s(self, value):\n", attrnm ); } - t = VARget_type(v); + t = VARget_type( v ); /* find attr type name */ - if(TYPEget_name(t) == NULL) { - attr_type = GetAttrTypeName(t); + if( TYPEget_name( t ) == NULL ) { + attr_type = GetAttrTypeName( t ); } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } - if(!VARis_derived(v) && !VARget_inverse(v)) { + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { /* if the argument is not optional */ - if(!VARget_optional(v)) { - fprintf(file, "\t\t# Mandatory argument\n"); - fprintf(file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n"); - fprintf(file, "\t\tif not check_type(value,"); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "):\n"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "%s_):\n", attr_type); + if( !VARget_optional( v ) ) { + fprintf( file, "\t\t# Mandatory argument\n" ); + fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); + fprintf( file, "\t\tif not check_type(value," ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "):\n" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "%s_):\n", attr_type ); } else { - fprintf(file, "%s):\n", attr_type); + fprintf( file, "%s):\n", attr_type ); } } else { - fprintf(file, "\t\tif value != None: # OPTIONAL attribute\n\t"); - fprintf(file, "\t\tif not check_type(value,"); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "):\n\t"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "%s_):\n\t", attr_type); + fprintf( file, "\t\tif value != None: # OPTIONAL attribute\n\t" ); + fprintf( file, "\t\tif not check_type(value," ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "):\n\t" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "%s_):\n\t", attr_type ); } else { - fprintf(file, "%s):\n\t", attr_type); + fprintf( file, "%s):\n\t", attr_type ); } } /* check whether attr_type is aggr or explicit */ - if(TYPEis_aggregate(t)) { - fprintf(file, "\t\t\tself._%s = ", attrnm); - print_aggregate_type(file, t); - fprintf(file, "(value)\n"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type); + if( TYPEis_aggregate( t ) ) { + fprintf( file, "\t\t\tself._%s = ", attrnm ); + print_aggregate_type( file, t ); + fprintf( file, "(value)\n" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type ); } else { - fprintf(file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type); + fprintf( file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type ); } - if(VARget_optional(v)) { - fprintf(file, "\t\t\telse:\n"); - fprintf(file, "\t\t\t\tself._%s = value\n", attrnm); + if( VARget_optional( v ) ) { + fprintf( file, "\t\t\telse:\n" ); + fprintf( file, "\t\t\t\tself._%s = value\n", attrnm ); } - fprintf(file, "\t\telse:\n\t"); - fprintf(file, "\t\tself._%s = value\n", attrnm); + fprintf( file, "\t\telse:\n\t" ); + fprintf( file, "\t\tself._%s = value\n", attrnm ); } /* if the attribute is derived, prevent fset to attribute to be set */ /* TODO: this can be done by NOT writing the setter method */ - else if(VARis_derived(v)) { - fprintf(file, "\t# DERIVED argument\n"); - fprintf(file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm); - } else if(VARget_inverse(v)) { - fprintf(file, "\t# INVERSE argument\n"); - fprintf(file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm); + else if( VARis_derived( v ) ) { + fprintf( file, "\t# DERIVED argument\n" ); + fprintf( file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm ); + } else if( VARget_inverse( v ) ) { + fprintf( file, "\t# INVERSE argument\n" ); + fprintf( file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm ); } LISTod } /* before exiting, process where rules */ - WHEREPrint(entity->where, 0, file); + WHEREPrint( entity->where, 0, file ); - if(rename_python_property) { - fprintf(file, "\tproperty = __property\n"); + if ( rename_python_property ) { + fprintf( file, "\tproperty = __property\n" ); } } int -get_local_attribute_number(Entity entity) -{ +get_local_attribute_number( Entity entity ) { int i = 0; - Linked_List local = ENTITYget_attributes(entity); - LISTdo(local, a, Variable) + Linked_List local = ENTITYget_attributes( entity ); + LISTdo( local, a, Variable ) /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { ++i; } LISTod; return i; } -int get_attribute_number(Entity entity) -{ +int get_attribute_number( Entity entity ) { int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes(entity); - local = ENTITYget_attributes(entity); + complete = ENTITYget_all_attributes( entity ); + local = ENTITYget_attributes( entity ); - LISTdo(local, a, Variable) { + LISTdo( local, a, Variable ) { /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - LISTdo_n(complete, p, Variable, b) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + LISTdo_n( complete, p, Variable, b ) { /* cycle through all the explicit attributes until the child's attribute is found */ - if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { - if(p != a) { + if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { + if( p != a ) { ++i; } else { found = 1; } } - } - LISTod - if(found) { + } LISTod + if( found ) { return i; } else { /* In this case, a is a Variable - so macro VARget_name (a) expands * * to an Expression. The first element of an Expression is a Symbol. * * The first element of a Symbol is char * name. */ - fprintf(stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name(a)->symbol.name); + fprintf( stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name( a )->symbol.name ); } } - } - LISTod + } LISTod return -1; } @@ -911,17 +879,15 @@ int get_attribute_number(Entity entity) ** Status: ok 1/15/91 ******************************************************************/ void -ENTITYlib_print(Entity entity, FILE *file) -{ - LIBdescribe_entity(entity, file); +ENTITYlib_print( Entity entity, FILE * file ) { + LIBdescribe_entity( entity, file ); } /*FIXME should return bool */ /* return 1 if types are predefined by us */ int -TYPEis_builtin(const Type t) -{ - switch(TYPEget_body(t)->type) { /* dunno if correct*/ +TYPEis_builtin( const Type t ) { + switch( TYPEget_body( t )->type ) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -949,12 +915,11 @@ TYPEis_builtin(const Type t) ** Status: started 2012/3/1 ******************************************************************/ void -RULEPrint(Rule rule, FILES *files) -{ - char *n = RULEget_name(rule); - fprintf(files->lib, "\n####################\n # RULE %s #\n####################\n", n); +RULEPrint( Rule rule, FILES * files ) { + char * n = RULEget_name( rule ); + fprintf( files->lib, "\n####################\n # RULE %s #\n####################\n", n ); /* write function definition */ - fprintf(files->lib, "%s = Rule()\n", n); + fprintf( files->lib, "%s = Rule()\n", n ); } @@ -968,227 +933,216 @@ RULEPrint(Rule rule, FILES *files) ** Status: started 2012/3/1 ******************************************************************/ void -FUNCPrint(Function function, FILES *files) -{ - char *function_name = FUNCget_name(function); - char *param_name; +FUNCPrint( Function function, FILES * files ) { + char * function_name = FUNCget_name( function ); + char * param_name; Expression expr_name = EXPRESSION_NULL; - fprintf(files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name); + fprintf( files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name ); /* write function definition */ - fprintf(files->lib, "def %s(", function_name); + fprintf( files->lib, "def %s(", function_name ); /* write parameter list */ - LISTdo(FUNCget_parameters(function), v, Variable) { - expr_name = VARget_name(v); - param_name = strdup(EXPget_name(expr_name)); - fprintf(files->lib, "%s,", param_name); - } - LISTod - fprintf(files->lib, "):\n"); + LISTdo( FUNCget_parameters( function ), v, Variable ) { + expr_name = VARget_name( v ); + param_name = strdup( EXPget_name( expr_name ) ); + fprintf( files->lib, "%s,", param_name ); + } LISTod + fprintf( files->lib, "):\n" ); /* print function docstring */ - fprintf(files->lib, "\t'''\n"); - LISTdo(FUNCget_parameters(function), v, Variable) { - expr_name = VARget_name(v); - param_name = strdup(EXPget_name(expr_name)); - fprintf(files->lib, "\t:param %s\n", param_name); - fprintf(files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName(VARget_type(v))); - } - LISTod - fprintf(files->lib, "\t'''\n"); + fprintf( files->lib, "\t'''\n" ); + LISTdo( FUNCget_parameters( function ), v, Variable ) { + expr_name = VARget_name( v ); + param_name = strdup( EXPget_name( expr_name ) ); + fprintf( files->lib, "\t:param %s\n", param_name ); + fprintf( files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName( VARget_type( v ) ) ); + } LISTod + fprintf( files->lib, "\t'''\n" ); /* process statements. The indent_level is set to 1 (the number of tabs \t) */ - STATEMENTSPrint(function->u.proc->body, 1, files->lib); + STATEMENTSPrint( function->u.proc->body, 1, files->lib ); } void -STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file) -{ - LISTdo(stmts, stmt, Statement) - STATEMENTPrint(stmt, indent_level, file); +STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ) { + LISTdo( stmts, stmt, Statement ) + STATEMENTPrint( stmt, indent_level, file ); LISTod } -void python_indent(FILE *file, int indent_level) -{ +void python_indent( FILE * file, int indent_level ) { int i; - for(i = 0; i < indent_level; i++) { - fprintf(file, "\t"); + for( i = 0; i < indent_level; i++ ) { + fprintf( file, "\t" ); } } void -STATEMENTPrint(Statement s, int indent_level, FILE *file) -{ +STATEMENTPrint( Statement s, int indent_level, FILE * file ) { bool first_time = true; - python_indent(file, indent_level); - if(!s) { /* null statement */ - fprintf(file, "pass"); + python_indent( file, indent_level ); + if( !s ) { /* null statement */ + fprintf( file, "pass" ); return; } - switch(s->type) { + switch( s->type ) { case STMT_ASSIGN: - EXPRESSION_out(s->u.assign->lhs, 0, file); - fprintf(file, " = "); - EXPRESSION_out(s->u.assign->rhs, 0, file); - fprintf(file, "\n"); + EXPRESSION_out( s->u.assign->lhs, 0, file ); + fprintf( file, " = " ); + EXPRESSION_out( s->u.assign->rhs, 0, file ); + fprintf( file, "\n" ); break; case STMT_CASE: - CASEout(s->u.Case, indent_level, file); + CASEout( s->u.Case, indent_level, file ); break; case STMT_RETURN: - fprintf(file, "return "); - if(s->u.ret->value) { - EXPRESSION_out(s->u.ret->value, 0, file); + fprintf( file, "return " ); + if( s->u.ret->value ) { + EXPRESSION_out( s->u.ret->value, 0, file ); } - fprintf(file, "\n"); + fprintf( file, "\n" ); break; case STMT_LOOP: - LOOPpyout(s->u.loop, indent_level, file); + LOOPpyout( s->u.loop, indent_level , file ); break; case STMT_ALIAS: - fprintf(file, "%s = %s\n", s->symbol.name, - s->u.alias->variable->name->symbol.name); - STATEMENTlist_out(s->u.alias->statements, indent_level, file); + fprintf( file, "%s = %s\n", s->symbol.name, + s->u.alias->variable->name->symbol.name ); + STATEMENTlist_out( s->u.alias->statements, indent_level , file ); break; case STMT_SKIP: - fprintf(file, "break\n"); /* @TODO: is that correct? */ + fprintf( file, "break\n" ); /* @TODO: is that correct? */ break; case STMT_ESCAPE: - fprintf(file, "break\n"); + fprintf( file, "break\n" ); break; case STMT_COMPOUND: /* following line is necessary other wise indentation */ /* errors in python */ - fprintf(file, "# begin/end block\n"); - STATEMENTlist_out(s->u.compound->statements, indent_level, file); + fprintf( file, "# begin/end block\n" ); + STATEMENTlist_out( s->u.compound->statements, indent_level, file ); break; case STMT_COND: - fprintf(file, "if ("); - EXPRESSION_out(s->u.cond->test, 0, file); - fprintf(file, "):\n"); - STATEMENTlist_out(s->u.cond->code, indent_level + 1, file); - if(s->u.cond->otherwise) { - python_indent(file, indent_level); - fprintf(file, "else:\n"); - STATEMENTlist_out(s->u.cond->otherwise, indent_level + 1, file); + fprintf( file, "if (" ); + EXPRESSION_out( s->u.cond->test, 0 , file ); + fprintf( file, "):\n" ); + STATEMENTlist_out( s->u.cond->code, indent_level + 1, file ); + if( s->u.cond->otherwise ) { + python_indent( file, indent_level ); + fprintf( file, "else:\n" ); + STATEMENTlist_out( s->u.cond->otherwise, indent_level + 1, file ); } break; case STMT_PCALL: - fprintf(file, "%s(", s->symbol.name); - LISTdo(s->u.proc->parameters, p, Expression) - if(first_time) { + fprintf( file, "%s(", s->symbol.name ); + LISTdo( s->u.proc->parameters, p, Expression ) + if( first_time ) { first_time = false; } else { - fprintf(file, ","); + fprintf( file, "," ); } - EXPRESSION_out(p, 0, file); + EXPRESSION_out( p, 0, file ); LISTod - fprintf(file, ")\n"); + fprintf( file, ")\n" ); } } void -CASEout(struct Case_Statement_ *c, int level, FILE *file) -{ +CASEout( struct Case_Statement_ *c, int level, FILE * file ) { int if_number = 0; - fprintf(file, "case_selector = "); - EXPRESSION_out(c->selector, 0, file); - fprintf(file, "\n"); + fprintf( file, "case_selector = " ); + EXPRESSION_out( c->selector, 0, file ); + fprintf( file, "\n" ); /* pass 2: print them */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { /* print label(s) */ - python_indent(file, level); - if(if_number == 0) { - fprintf(file, "if "); + python_indent( file, level ); + if( if_number == 0 ) { + fprintf( file, "if " ); } else { - fprintf(file, "elif"); + fprintf( file, "elif" ); } - fprintf(file, " case_selector == "); - EXPRESSION_out(label, 0, file); - fprintf(file, ":\n"); + fprintf( file, " case_selector == " ); + EXPRESSION_out( label, 0, file ); + fprintf( file, ":\n" ); /* print action */ - STATEMENTPrint(ci->action, level + 1, file); + STATEMENTPrint( ci->action, level + 1, file ); if_number++; - } - LISTod + } LISTod } else { /* print OTHERWISE */ - python_indent(file, level); - fprintf(file, "else:\n"); + python_indent( file, level ); + fprintf( file, "else:\n" ); /* print action */ - STATEMENTPrint(ci->action, level + 1, file); + STATEMENTPrint( ci->action, level + 1, file ); } - } - LISTod + } LISTod } void -LOOPpyout(struct Loop_ *loop, int level, FILE *file) -{ +LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { Variable v; - - if(loop->scope) { + + if (loop->scope) { DictionaryEntry de; /* TODO: if incr != 0 && ((incr > 0 && start < stop) || (incr < 0 && start > stop)): */ - DICTdo_init(loop->scope->symbol_table, &de); - v = (Variable)DICTdo(&de); - fprintf(file, "for %s in range(", v->name->symbol.name); - EXPRESSION_out(loop->scope->u.incr->init, 0, file); - fprintf(file, ","); - EXPRESSION_out(loop->scope->u.incr->end, 0, file); - fprintf(file, ","); /* parser always forces a "by" expr */ - EXPRESSION_out(loop->scope->u.incr->increment, 0, file); - fprintf(file, "):\n"); - - if(loop->while_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->while_expr, 0, file); - fprintf(file, ":\n"); - STATEMENTlist_out(loop->statements, level + 2, file); + DICTdo_init( loop->scope->symbol_table, &de ); + v = ( Variable )DICTdo( &de ); + fprintf( file, "for %s in range(", v->name->symbol.name ); + EXPRESSION_out( loop->scope->u.incr->init, 0 , file ); + fprintf( file, "," ); + EXPRESSION_out( loop->scope->u.incr->end, 0 , file ); + fprintf( file, "," ); /* parser always forces a "by" expr */ + EXPRESSION_out( loop->scope->u.incr->increment, 0 , file ); + fprintf( file, "):\n" ); + + if( loop->while_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->while_expr, 0 , file ); + fprintf( file, ":\n"); + STATEMENTlist_out( loop->statements, level + 2 , file ); } else { - STATEMENTlist_out(loop->statements, level + 1, file); + STATEMENTlist_out( loop->statements, level + 1 , file ); } - if(loop->until_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + if( loop->until_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } - } else if(loop->while_expr) { - fprintf(file, "while "); - EXPRESSION_out(loop->while_expr, 0, file); - fprintf(file, ":\n"); - STATEMENTlist_out(loop->statements, level + 1, file); - - if(loop->until_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + } else if( loop->while_expr ) { + fprintf( file, "while " ); + EXPRESSION_out( loop->while_expr, 0 , file ); + fprintf( file, ":\n"); + STATEMENTlist_out( loop->statements, level + 1 , file ); + + if( loop->until_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } } else { - fprintf(file, "while True:\n"); - STATEMENTlist_out(loop->statements, level + 1, file); + fprintf( file, "while True:\n" ); + STATEMENTlist_out( loop->statements, level + 1 , file ); - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } } void -STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file) -{ - LISTdo(stmts, stmt, Statement) - STATEMENTPrint(stmt, indent_level, file); +STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ) { + LISTdo( stmts, stmt, Statement ) + STATEMENTPrint( stmt, indent_level, file ); LISTod } /***************************************************************** @@ -1198,113 +1152,112 @@ STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file) ** ******************************************************************/ void -ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file) -{ +ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - fprintf(file, " None "); + if( e == LITERAL_INFINITY ) { + fprintf( file, " None " ); } else { - fprintf(file, "%d", e->u.integer); + fprintf( file, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - fprintf(file, " PI "); - } else if(e == LITERAL_E) { - fprintf(file, " E ");; + if( e == LITERAL_PI ) { + fprintf( file, " PI " ); + } else if( e == LITERAL_E ) { + fprintf( file, " E " );; } else { - fprintf(file, "%g", e->u.real); + fprintf( file, "%g", e->u.real ); } break; case binary_: - fprintf(file, "%%%s", e->u.binary); /* put "%" back */ + fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - fprintf(file, "TRUE"); + fprintf( file, "TRUE" ); break; case Lfalse: - fprintf(file, "FALSE"); + fprintf( file, "FALSE" ); break; default: - fprintf(file, "UNKNOWN"); + fprintf( file, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - fprintf(file, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + fprintf( file, "\"%s\"", e->symbol.name ); } else { - char *tmp = strliteral_py_dup(e->symbol.name); - fprintf(file, "'%s'", tmp); + char* tmp = strliteral_py_dup(e->symbol.name); + fprintf( file, "'%s'", tmp ); free(tmp); } break; case entity_: case identifier_: - fprintf(file, "self.%s", e->symbol.name); + fprintf( file, "self.%s", e->symbol.name ); break; case attribute_: - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); break; case enumeration_: - fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); + fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: /* so far we don't handle queries */ - fprintf(file, "None"); + fprintf( file, "None" ); break; case self_: - fprintf(file, "self"); + fprintf( file, "self" ); break; case funcall_: - fprintf(file, "%s(", e->symbol.name); + fprintf( file, "%s(", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; case op_: - ATTRIBUTE_INITIALIZERop__out(&e->e, paren, previous_op, file); + ATTRIBUTE_INITIALIZERop__out( &e->e, paren, previous_op, file ); break; case aggregate_: - fprintf(file, "["); + fprintf( file, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); LISTod - fprintf(file, "]"); + fprintf( file, "]" ); break; case oneof_: - fprintf(file, "ONEOF ("); + fprintf( file, "ONEOF (" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0, file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; default: - fprintf(file, "unknown expression, type %d", TYPEis(e->type)); + fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); } } @@ -1314,417 +1267,409 @@ ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file) ** include, and initialization files for a specific entity class ******************************************************************/ void -EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file) -{ +EXPRESSION__out( Expression e, int paren, Op_Code previous_op, FILE* file ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - fprintf(file, " None "); + if( e == LITERAL_INFINITY ) { + fprintf( file, " None " ); } else { - fprintf(file, "%d", e->u.integer); + fprintf( file, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - fprintf(file, " PI "); - } else if(e == LITERAL_E) { - fprintf(file, " E ");; + if( e == LITERAL_PI ) { + fprintf( file, " PI " ); + } else if( e == LITERAL_E ) { + fprintf( file, " E " );; } else { - fprintf(file, "%g", e->u.real); + fprintf( file, "%g", e->u.real ); } break; case binary_: - fprintf(file, "%%%s", e->u.binary); /* put "%" back */ + fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - fprintf(file, "TRUE"); + fprintf( file, "TRUE" ); break; case Lfalse: - fprintf(file, "FALSE"); + fprintf( file, "FALSE" ); break; default: - fprintf(file, "UNKNOWN"); + fprintf( file, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - fprintf(file, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + fprintf( file, "\"%s\"", e->symbol.name ); } else { - char *tmp = strliteral_py_dup(e->symbol.name); - fprintf(file, "'%s'", tmp); + char* tmp = strliteral_py_dup(e->symbol.name); + fprintf( file, "'%s'", tmp ); free(tmp); } break; case entity_: case identifier_: - if(is_python_keyword(e->symbol.name)) { - fprintf(file, "%s_", e->symbol.name); + if( is_python_keyword( e->symbol.name ) ) { + fprintf( file, "%s_", e->symbol.name ); } else { - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); } break; case attribute_: - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); break; case enumeration_: - fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); + fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: /* so far we don't handle queries */ - fprintf(file, "None"); + fprintf( file, "None" ); break; case self_: - fprintf(file, "self"); + fprintf( file, "self" ); break; case funcall_: - fprintf(file, "%s(", e->symbol.name); + fprintf( file, "%s(", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0 , file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; case op_: - EXPRESSIONop__out(&e->e, paren, previous_op, file); + EXPRESSIONop__out( &e->e, paren, previous_op, file ); break; case aggregate_: - fprintf(file, "["); + fprintf( file, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0 , file ); LISTod - fprintf(file, "]"); + fprintf( file, "]" ); break; case oneof_: - fprintf(file, "ONEOF ("); + fprintf( file, "ONEOF (" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0, file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; default: - fprintf(file, "unknown expression, type %d", TYPEis(e->type)); + fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); } } void -ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) -{ +ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { /* TODO: refactor, eliminate Op_Subexpression for enumerations */ - Type op1_type = EXPget_type(oe->op1); - if(TYPEis_enumeration(op1_type)) { - fprintf(file, "%s.%s", TYPEget_name(op1_type), EXPget_name(oe->op2)); + Type op1_type = EXPget_type( oe->op1 ); + if ( TYPEis_enumeration( op1_type ) ) { + fprintf( file, "%s.%s", TYPEget_name( op1_type ), EXPget_name( oe->op2 ) ); return; } - switch(oe->op_code) { + switch( oe->op_code ) { case OP_AND: - ATTRIBUTE_INITIALIZERop2_out(oe, " and ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " and ", paren, PAD, file ); break; case OP_ANDOR: case OP_OR: - ATTRIBUTE_INITIALIZERop2_out(oe, " or ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " or ", paren, PAD, file ); break; case OP_CONCAT: case OP_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); break; case OP_PLUS: - ATTRIBUTE_INITIALIZERop2_out(oe, " + ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " + ", paren, PAD, file ); break; case OP_TIMES: - ATTRIBUTE_INITIALIZERop2_out(oe, " * ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " * ", paren, PAD, file ); break; case OP_XOR: - ATTRIBUTE_INITIALIZERop2__out(oe, " != ", paren, PAD, previous_op, file); + ATTRIBUTE_INITIALIZERop2__out( oe, " != ", paren, PAD, previous_op, file ); break; case OP_EXP: - ATTRIBUTE_INITIALIZERop2_out(oe, " ** ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " ** ", paren, PAD, file ); break; case OP_GREATER_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " >= ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " >= ", paren, PAD, file ); break; case OP_GREATER_THAN: - ATTRIBUTE_INITIALIZERop2_out(oe, " > ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); break; case OP_INST_NOT_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD, file ); break; case OP_LESS_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " <= ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " <= ", paren, PAD, file ); break; case OP_LESS_THAN: - ATTRIBUTE_INITIALIZERop2_out(oe, " < ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " < ", paren, PAD, file ); break; case OP_LIKE: case OP_MOD: - ATTRIBUTE_INITIALIZERop2_out(oe, " % ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " % ", paren, PAD, file ); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD , file ); break; case OP_NOT: - ATTRIBUTE_INITIALIZERop1_out(oe, " not ", paren, file); + ATTRIBUTE_INITIALIZERop1_out( oe, " not ", paren, file ); break; case OP_REAL_DIV: case OP_DIV: - ATTRIBUTE_INITIALIZERop2_out(oe, "/", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, "/", paren, PAD, file ); break; case OP_MINUS: - ATTRIBUTE_INITIALIZERop2_out(oe, "-", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, "-", paren, PAD, file ); break; case OP_DOT: - ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); break; case OP_NEGATE: - ATTRIBUTE_INITIALIZERop1_out(oe, "-", paren, file); + ATTRIBUTE_INITIALIZERop1_out( oe, "-", paren, file ); break; case OP_ARRAY_ELEMENT: - ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); - fprintf(file, "["); - ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); - fprintf(file, "]"); + ATTRIBUTE_INITIALIZER_out( oe->op1, 1, file ); + fprintf( file, "[" ); + ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); + fprintf( file, "]" ); break; case OP_SUBCOMPONENT: - ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); - fprintf(file, "["); - ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); - fprintf(file, ":"); - ATTRIBUTE_INITIALIZER_out(oe->op3, 0, file); - fprintf(file, "]"); + ATTRIBUTE_INITIALIZER_out( oe->op1, 1 , file ); + fprintf( file, "[" ); + ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); + fprintf( file, ":" ); + ATTRIBUTE_INITIALIZER_out( oe->op3, 0, file ); + fprintf( file, "]" ); break; default: - fprintf(file, "(* unknown op-expression *)"); + fprintf( file, "(* unknown op-expression *)" ); } } /* print expression that has op and operands */ void -EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) -{ - switch(oe->op_code) { +EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { + switch( oe->op_code ) { case OP_AND: - EXPRESSIONop2_out(oe, " and ", paren, PAD, file); + EXPRESSIONop2_out( oe, " and ", paren, PAD, file ); break; case OP_ANDOR: case OP_OR: - EXPRESSIONop2_out(oe, " or ", paren, PAD, file); + EXPRESSIONop2_out( oe, " or ", paren, PAD, file ); break; case OP_CONCAT: case OP_EQUAL: - EXPRESSIONop2_out(oe, " == ", paren, PAD, file); + EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); break; case OP_PLUS: - EXPRESSIONop2_out(oe, " + ", paren, PAD, file); + EXPRESSIONop2_out( oe, " + ", paren, PAD, file ); break; case OP_TIMES: - EXPRESSIONop2_out(oe, " * ", paren, PAD, file); + EXPRESSIONop2_out( oe, " * ", paren, PAD, file ); break; case OP_XOR: - EXPRESSIONop2__out(oe, " != ", paren, PAD, previous_op, file); + EXPRESSIONop2__out( oe, " != ", paren, PAD, previous_op, file ); break; case OP_EXP: - EXPRESSIONop2_out(oe, " ** ", paren, PAD, file); + EXPRESSIONop2_out( oe, " ** ", paren, PAD, file ); break; case OP_GREATER_EQUAL: - EXPRESSIONop2_out(oe, " >= ", paren, PAD, file); + EXPRESSIONop2_out( oe, " >= ", paren, PAD, file ); break; case OP_GREATER_THAN: - EXPRESSIONop2_out(oe, " > ", paren, PAD, file); + EXPRESSIONop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - EXPRESSIONop2_out(oe, " == ", paren, PAD, file); + EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); break; case OP_INST_NOT_EQUAL: - EXPRESSIONop2_out(oe, " != ", paren, PAD, file); + EXPRESSIONop2_out( oe, " != ", paren, PAD, file ); break; case OP_LESS_EQUAL: - EXPRESSIONop2_out(oe, " <= ", paren, PAD, file); + EXPRESSIONop2_out( oe, " <= ", paren, PAD, file ); break; case OP_LESS_THAN: - EXPRESSIONop2_out(oe, " < ", paren, PAD, file); + EXPRESSIONop2_out( oe, " < ", paren, PAD, file ); break; case OP_LIKE: case OP_MOD: - EXPRESSIONop2_out(oe, " % ", paren, PAD, file); + EXPRESSIONop2_out( oe, " % ", paren, PAD, file ); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - EXPRESSIONop2_out(oe, " != ", paren, PAD, file); + EXPRESSIONop2_out( oe, " != ", paren, PAD , file ); break; case OP_NOT: - EXPRESSIONop1_out(oe, " not ", paren, file); + EXPRESSIONop1_out( oe, " not ", paren, file ); break; case OP_REAL_DIV: case OP_DIV: - EXPRESSIONop2_out(oe, "/", paren, PAD, file); + EXPRESSIONop2_out( oe, "/", paren, PAD, file ); break; case OP_MINUS: - EXPRESSIONop2_out(oe, "-", paren, PAD, file); + EXPRESSIONop2_out( oe, "-", paren, PAD, file ); break; case OP_DOT: - EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); + EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); + EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); break; case OP_NEGATE: - EXPRESSIONop1_out(oe, "-", paren, file); + EXPRESSIONop1_out( oe, "-", paren, file ); break; case OP_ARRAY_ELEMENT: - EXPRESSION_out(oe->op1, 1, file); - fprintf(file, "["); - EXPRESSION_out(oe->op2, 0, file); - fprintf(file, "]"); + EXPRESSION_out( oe->op1, 1, file ); + fprintf( file, "[" ); + EXPRESSION_out( oe->op2, 0, file ); + fprintf( file, "]" ); break; case OP_SUBCOMPONENT: - EXPRESSION_out(oe->op1, 1, file); - fprintf(file, "["); - EXPRESSION_out(oe->op2, 0, file); - fprintf(file, ":"); - EXPRESSION_out(oe->op3, 0, file); - fprintf(file, "]"); + EXPRESSION_out( oe->op1, 1 , file ); + fprintf( file, "[" ); + EXPRESSION_out( oe->op2, 0, file ); + fprintf( file, ":" ); + EXPRESSION_out( oe->op3, 0, file ); + fprintf( file, "]" ); break; default: - fprintf(file, "(* unknown op-expression *)"); + fprintf( file, "(* unknown op-expression *)" ); } } void -EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) -{ - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, "("); +EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, "(" ); } - EXPRESSION__out(eo->op1, 1, eo->op_code, file); - if(pad) { - fprintf(file, " "); + EXPRESSION__out( eo->op1, 1, eo->op_code , file ); + if( pad ) { + fprintf( file, " " ); } - fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - fprintf(file, " "); + fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + fprintf( file, " " ); } - EXPRESSION__out(eo->op2, 1, eo->op_code, file); - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, ")"); + EXPRESSION__out( eo->op2, 1, eo->op_code, file ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, ")" ); } } void -ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) -{ - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, "("); +ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, "(" ); } - ATTRIBUTE_INITIALIZER__out(eo->op1, 1, eo->op_code, file); - if(pad) { - fprintf(file, " "); + ATTRIBUTE_INITIALIZER__out( eo->op1, 1, eo->op_code , file ); + if( pad ) { + fprintf( file, " " ); } - fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - fprintf(file, " "); + fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + fprintf( file, " " ); } - ATTRIBUTE_INITIALIZER__out(eo->op2, 1, eo->op_code, file); - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, ")"); + ATTRIBUTE_INITIALIZER__out( eo->op2, 1, eo->op_code, file ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, ")" ); } } /* Print out a one-operand operation. If there were more than two of these */ /* I'd generalize it to do padding, but it's not worth it. */ void -EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) -{ - if(paren) { - fprintf(file, "("); +EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { + if( paren ) { + fprintf( file, "(" ); } - fprintf(file, "%s", opcode); - EXPRESSION_out(eo->op1, 1, file); - if(paren) { - fprintf(file, ")"); + fprintf( file, "%s", opcode ); + EXPRESSION_out( eo->op1, 1, file ); + if( paren ) { + fprintf( file, ")" ); } } void -ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) -{ - if(paren) { - fprintf(file, "("); +ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { + if( paren ) { + fprintf( file, "(" ); } - fprintf(file, "%s", opcode); - ATTRIBUTE_INITIALIZER_out(eo->op1, 1, file); - if(paren) { - fprintf(file, ")"); + fprintf( file, "%s", opcode ); + ATTRIBUTE_INITIALIZER_out( eo->op1, 1, file ); + if( paren ) { + fprintf( file, ")" ); } } void -WHEREPrint(Linked_List wheres, int level, FILE *file) -{ +WHEREPrint( Linked_List wheres, int level , FILE * file ) { int where_rule_number = 0; - python_indent(file, level); + python_indent( file, level ); - if(!wheres) { + if( !wheres ) { return; } /* pass 2: now print labels and exprs */ - LISTdo(wheres, w, Where) - if(strcmp(w->label->name, "")) { + LISTdo( wheres, w, Where ) + if( strcmp( w->label->name, "" ) ) { /* define a function with the name 'label' */ - fprintf(file, "\tdef %s(self):\n", w->label->name); - fprintf(file, "\t\teval_%s_wr = ", w->label->name); + fprintf( file, "\tdef %s(self):\n", w->label->name ); + fprintf( file, "\t\teval_%s_wr = ", w->label->name ); } else { /* no label */ - fprintf(file, "\tdef unnamed_wr_%i(self):\n", where_rule_number); - fprintf(file, "\t\teval_unnamed_wr_%i = ", where_rule_number); + fprintf( file, "\tdef unnamed_wr_%i(self):\n", where_rule_number ); + fprintf( file, "\t\teval_unnamed_wr_%i = ", where_rule_number ); } /*EXPRESSION_out( w->expr, level+1 , file ); */ - ATTRIBUTE_INITIALIZER_out(w->expr, level + 1, file); + ATTRIBUTE_INITIALIZER_out( w->expr, level + 1 , file ); /* raise exception if rule violated */ - if(strcmp(w->label->name, "")) { - fprintf(file, "\n\t\tif not eval_%s_wr:\n", w->label->name); - fprintf(file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name); - fprintf(file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name); + if( strcmp( w->label->name, "" ) ) { + fprintf( file, "\n\t\tif not eval_%s_wr:\n", w->label->name ); + fprintf( file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name ); + fprintf( file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name ); } else { /* no label */ - fprintf(file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number); - fprintf(file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number); - fprintf(file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number); + fprintf( file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number ); + fprintf( file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number ); + fprintf( file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number ); where_rule_number++; } LISTod @@ -1743,13 +1688,12 @@ WHEREPrint(Linked_List wheres, int level, FILE *file) ******************************************************************/ void -ENTITYPrint(Entity entity, FILES *files) -{ - char *n = ENTITYget_name(entity); - DEBUG("Entering ENTITYPrint for %s\n", n); - fprintf(files->lib, "\n####################\n # ENTITY %s #\n####################\n", n); - ENTITYlib_print(entity, files -> lib); - DEBUG("DONE ENTITYPrint\n") ; +ENTITYPrint( Entity entity, FILES * files ) { + char * n = ENTITYget_name( entity ); + DEBUG( "Entering ENTITYPrint for %s\n", n ); + fprintf( files->lib, "\n####################\n # ENTITY %s #\n####################\n", n ); + ENTITYlib_print( entity, files -> lib ); + DEBUG( "DONE ENTITYPrint\n" ) ; } @@ -1761,206 +1705,200 @@ ENTITYPrint(Entity entity, FILES *files) * FIXME implement or remove */ const char * -EnumCElementName(Type type, Expression expr) -{ +EnumCElementName( Type type, Expression expr ) { (void) type; (void) expr; return NULL; } void -TYPEenum_lib_print(const Type type, FILE *f) -{ +TYPEenum_lib_print( const Type type, FILE * f ) { DictionaryEntry de; Expression expr; /* begin the new enum type */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name( type ) ); } else { - fprintf(f, "\n# ENUMERATION TYPE %s\n", TYPEget_name(type)); + fprintf( f, "\n# ENUMERATION TYPE %s\n", TYPEget_name( type ) ); } /* then outputs the enum */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "%s_ = ENUMERATION('%s_','", TYPEget_name(type), TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "%s_ = ENUMERATION('%s_','", TYPEget_name( type ), TYPEget_name( type ) ); } else { - fprintf(f, "%s = ENUMERATION('%s','", TYPEget_name(type), TYPEget_name(type)); + fprintf( f, "%s = ENUMERATION('%s','", TYPEget_name( type ), TYPEget_name( type ) ); } /* set up the dictionary info */ - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - if(is_python_keyword(EXPget_name(expr))) { - fprintf(f, "%s_ ", EXPget_name(expr)); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + if( is_python_keyword( EXPget_name( expr ) ) ) { + fprintf( f, "%s_ ", EXPget_name( expr ) ); } else { - fprintf(f, "%s ", EXPget_name(expr)); + fprintf( f, "%s ", EXPget_name( expr ) ); } } - fprintf(f, "')\n"); + fprintf( f, "')\n" ); } -void strcat_expr(Expression e, char *buf) -{ - if(e == LITERAL_INFINITY) { - strcat(buf, "?"); - } else if(e == LITERAL_PI) { - strcat(buf, "PI"); - } else if(e == LITERAL_E) { - strcat(buf, "E"); - } else if(e == LITERAL_ZERO) { - strcat(buf, "0"); - } else if(e == LITERAL_ONE) { - strcat(buf, "1"); - } else if(TYPEget_name(e)) { - strcat(buf, TYPEget_name(e)); - } else if(TYPEget_body(e->type)->type == integer_) { +void strcat_expr( Expression e, char * buf ) { + if( e == LITERAL_INFINITY ) { + strcat( buf, "?" ); + } else if( e == LITERAL_PI ) { + strcat( buf, "PI" ); + } else if( e == LITERAL_E ) { + strcat( buf, "E" ); + } else if( e == LITERAL_ZERO ) { + strcat( buf, "0" ); + } else if( e == LITERAL_ONE ) { + strcat( buf, "1" ); + } else if( TYPEget_name( e ) ) { + strcat( buf, TYPEget_name( e ) ); + } else if( TYPEget_body( e->type )->type == integer_ ) { char tmpbuf[30]; - sprintf(tmpbuf, "%d", e->u.integer); - strcat(buf, tmpbuf); + sprintf( tmpbuf, "%d", e->u.integer ); + strcat( buf, tmpbuf ); } else { - strcat(buf, "??"); + strcat( buf, "??" ); } } /* print t's bounds to end of buf */ void -strcat_bounds(TypeBody b, char *buf) -{ - if(!b->upper) { +strcat_bounds( TypeBody b, char * buf ) { + if( !b->upper ) { return; } - strcat(buf, " ["); - strcat_expr(b->lower, buf); - strcat(buf, ":"); - strcat_expr(b->upper, buf); - strcat(buf, "]"); + strcat( buf, " [" ); + strcat_expr( b->lower, buf ); + strcat( buf, ":" ); + strcat_expr( b->upper, buf ); + strcat( buf, "]" ); } void -TypeBody_Description(TypeBody body, char *buf) -{ - char *s; +TypeBody_Description( TypeBody body, char * buf ) { + char * s; - switch(body->type) { + switch( body->type ) { case integer_: - strcat(buf, " INTEGER"); + strcat( buf, " INTEGER" ); break; case real_: - strcat(buf, " REAL"); + strcat( buf, " REAL" ); break; case string_: - strcat(buf, " STRING"); + strcat( buf, " STRING" ); break; case binary_: - strcat(buf, " BINARY"); + strcat( buf, " BINARY" ); break; case boolean_: - strcat(buf, " BOOLEAN"); + strcat( buf, " BOOLEAN" ); break; case logical_: - strcat(buf, " LOGICAL"); + strcat( buf, " LOGICAL" ); break; case number_: - strcat(buf, " NUMBER"); + strcat( buf, " NUMBER" ); break; case entity_: - strcat(buf, " "); - strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); + strcat( buf, " " ); + strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(body->type) { - /* ignore the aggregate bounds for now */ + switch( body->type ) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat(buf, " AGGREGATE OF"); + strcat( buf, " AGGREGATE OF" ); break; case array_: - strcat(buf, " ARRAY"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.optional) { - strcat(buf, " OPTIONAL"); + strcat( buf, " ARRAY" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.optional ) { + strcat( buf, " OPTIONAL" ); } - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; case bag_: - strcat(buf, " BAG"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " BAG" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case set_: - strcat(buf, " SET"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " SET" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case list_: - strcat(buf, " LIST"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + strcat( buf, " LIST" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; default: - fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type); + fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type ); abort(); } - Type_Description(body->base, buf); + Type_Description( body->base, buf ); break; case enumeration_: - strcat(buf, " ENUMERATION of ("); - LISTdo(body->list, e, Expression) - strcat(buf, ENUMget_name(e)); - strcat(buf, ", "); + strcat( buf, " ENUMERATION of (" ); + LISTdo( body->list, e, Expression ) + strcat( buf, ENUMget_name( e ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; case select_: - strcat(buf, " SELECT ("); - LISTdo(body->list, t, Type) - strcat(buf, PrettyTmpName(TYPEget_name(t))); - strcat(buf, ", "); + strcat( buf, " SELECT (" ); + LISTdo( body->list, t, Type ) + strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; default: - strcat(buf, " UNKNOWN"); + strcat( buf, " UNKNOWN" ); } - if(body->precision) { - strcat(buf, " ("); - strcat_expr(body->precision, buf); - strcat(buf, ")"); + if( body->precision ) { + strcat( buf, " (" ); + strcat_expr( body->precision, buf ); + strcat( buf, ")" ); } - if(body->flags.fixed) { - strcat(buf, " FIXED"); + if( body->flags.fixed ) { + strcat( buf, " FIXED" ); } } void -Type_Description(const Type t, char *buf) -{ - if(TYPEget_name(t)) { - strcat(buf, " "); - strcat(buf, TYPEget_name(t)); +Type_Description( const Type t, char * buf ) { + if( TYPEget_name( t ) ) { + strcat( buf, " " ); + strcat( buf, TYPEget_name( t ) ); /* strcat(buf,PrettyTmpName (TYPEget_name(t)));*/ } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } } @@ -1969,10 +1907,9 @@ Type_Description(const Type t, char *buf) otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ int -isMultiDimAggregateType(const Type t) -{ - if(TYPEget_body(t)->base) - if(isAggregateType(TYPEget_body(t)->base)) { +isMultiDimAggregateType( const Type t ) { + if( TYPEget_body( t )->base ) + if( isAggregateType( TYPEget_body( t )->base ) ) { return 1; } return 0; @@ -1994,8 +1931,7 @@ isMultiDimAggregateType(const Type t) return the name of the TD that arrlistSetAggr's ArrayTypeDescriptor should reference since it has an Express name associated with it. */ -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) -{ +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { (void) t; /* unused - FIXME implement or eliminate this function */ (void) buf; (void) schema; @@ -2014,8 +1950,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) *****/ void -TYPEprint_descriptions(const Type type, FILES *files, Schema schema) -{ +TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], @@ -2023,62 +1958,62 @@ TYPEprint_descriptions(const Type type, FILES *files, Schema schema) Type i; int where_rule_number = 0; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { + if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { /* If we're a renamed enum type, just print a few typedef's to the original and some specialized create functions: */ - strncpy(base, StrToLower(EnumName(TYPEget_name(i))), BUFSIZ); - base[BUFSIZ - 1] = '\0'; - strncpy(nm, StrToLower(EnumName(TYPEget_name(type))), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(files->lib, "%s = %s\n", nm, base); + strncpy( base, StrToLower( EnumName( TYPEget_name( i ) ) ), BUFSIZ ); + base[BUFSIZ-1]='\0'; + strncpy( nm, StrToLower( EnumName( TYPEget_name( type ) ) ), BUFSIZ ); + nm[BUFSIZ-1]='\0'; + fprintf( files->lib, "%s = %s\n", nm, base ); return; } - if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - const char *output = FundamentalType(type, 0); - if(TYPEis_aggregate(type)) { - fprintf(files->lib, "%s = ", TYPEget_name(type)); - process_aggregate(files->lib, type); - fprintf(files->lib, "\n"); - } else if(TYPEis_boolean(type)) { - fprintf(files->lib, "%s = bool\n", TYPEget_name(type)); - } else if(TYPEis_select(type)) { - TYPEselect_lib_print(type, files -> lib); - } else if(TYPEis_enumeration(type)) { - TYPEenum_lib_print(type, files -> lib); - } else { + if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + const char * output = FundamentalType( type, 0 ); + if( TYPEis_aggregate( type ) ) { + fprintf( files->lib, "%s = ", TYPEget_name( type ) ); + process_aggregate( files->lib, type ); + fprintf( files->lib, "\n" ); + } else if( TYPEis_boolean( type ) ) { + fprintf( files->lib, "%s = bool\n", TYPEget_name( type ) ); + } else if( TYPEis_select( type ) ) { + TYPEselect_lib_print( type, files -> lib ); + } else if( TYPEis_enumeration( type ) ) { + TYPEenum_lib_print( type, files -> lib ); + } else { /* the defined datatype inherits from the base type */ - fprintf(files->lib, "# Defined datatype %s\n", TYPEget_name(type)); - fprintf(files->lib, "class %s(", TYPEget_name(type)); - if(TYPEget_head(type) != NULL) { - fprintf(files->lib, "%s):\n", TYPEget_name(TYPEget_head(type))); + fprintf( files->lib, "# Defined datatype %s\n", TYPEget_name( type ) ); + fprintf( files->lib, "class %s(", TYPEget_name( type ) ); + if( TYPEget_head( type ) != NULL ) { + fprintf( files->lib, "%s):\n", TYPEget_name( TYPEget_head( type ) ) ); } else { - fprintf(files->lib, "%s):\n", output); + fprintf( files->lib, "%s):\n", output ); } - fprintf(files->lib, "\tdef __init__(self,*kargs):\n"); - fprintf(files->lib, "\t\tpass\n"); + fprintf( files->lib, "\tdef __init__(self,*kargs):\n" ); + fprintf( files->lib, "\t\tpass\n" ); /* call the where / rules */ - LISTdo(type->where, w, Where) - if(strcmp(w->label->name, "")) { + LISTdo( type->where, w, Where ) + if( strcmp( w->label->name, "" ) ) { /* define a function with the name 'label' */ - fprintf(files->lib, "\t\tself.%s()\n", w->label->name); + fprintf( files->lib, "\t\tself.%s()\n", w->label->name ); } else { /* no label */ - fprintf(files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number); + fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number ); where_rule_number ++; } LISTod - fprintf(files->lib, "\n"); + fprintf( files->lib, "\n" ); /* then we process the where rules */ - WHEREPrint(type->where, 0, files->lib); + WHEREPrint( type->where, 0, files->lib ); } } else { /* TODO: cleanup, currently this is deadcode */ - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case enumeration_: - TYPEenum_lib_print(type, files -> lib); + TYPEenum_lib_print( type, files -> lib ); break; case select_: break; diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index dbc6e9a50..21c16d1c4 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -4,7 +4,7 @@ #include "complexSupport.h" -void use_ref(Schema, Express, FILES *); +void use_ref( Schema, Express, FILES * ); /****************************************************************** ** SCHEMA SECTION **/ @@ -22,21 +22,20 @@ void use_ref(Schema, Express, FILES *); ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint(Scope scope, FILES *files, Schema schema) -{ - Linked_List list = SCOPEget_entities_superclass_order(scope); - Linked_List function_list = SCOPEget_functions(scope); - Linked_List rule_list = SCOPEget_rules(scope); +void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); + Linked_List function_list = SCOPEget_functions( scope ); + Linked_List rule_list = SCOPEget_rules( scope ); DictionaryEntry de; Type i; int redefs = 0;// index = 0; /* Defined Types based on SIMPLE types */ - SCOPEdo_types(scope, t, de) - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) - && (TYPEget_ancestor(t) == NULL)) { - TYPEprint_descriptions(t, files, schema); + SCOPEdo_types( scope, t, de ) + if ( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) + && ( TYPEget_ancestor( t ) == NULL) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } SCOPEod @@ -44,12 +43,12 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) /* Defined Types with defined ancestor head * TODO: recursive approach */ - SCOPEdo_types(scope, t, de) - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) - && ((i = TYPEget_head(t)) != NULL)) { - if(i->search_id == PROCESSED) { - TYPEprint_descriptions(t, files, schema); + SCOPEdo_types( scope, t, de ) + if ( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) + && ( ( i = TYPEget_head( t ) ) != NULL ) ) { + if (i->search_id == PROCESSED) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } } @@ -59,27 +58,27 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) /* and print the enumerations */ //fprintf( files -> inc, "\n/*\t************** TYPES \t*/\n" ); //fprintf( files -> lib, "\n/*\t************** TYPES \t*/\n" ); - SCOPEdo_types(scope, t, de) + SCOPEdo_types( scope, t, de ) // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if((t->search_id == CANPROCESS) - && (TYPEis_enumeration(t)) - && ((i = TYPEget_ancestor(t)) != NULL) - && (i->search_id >= CANPROCESS)) { + if( ( t->search_id == CANPROCESS ) + && ( TYPEis_enumeration( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) + && ( i->search_id >= CANPROCESS ) ) { redefs = 1; } SCOPEod - SCOPEdo_types(scope, t, de) + SCOPEdo_types( scope, t, de ) // Do the non-redefined enumerations: - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) && TYPEget_head(t))) { - TYPEprint_descriptions(t, files, schema); - if(!TYPEis_select(t)) { + if( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { + TYPEprint_descriptions( t, files, schema ); + if( !TYPEis_select( t ) ) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } @@ -87,10 +86,10 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) SCOPEod; // process redifined enumerations - if(redefs) { - SCOPEdo_types(scope, t, de) - if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + if( redefs ) { + SCOPEdo_types( scope, t, de ) + if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } SCOPEod; @@ -101,8 +100,8 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types(scope, t, de) - if(t->search_id == CANPROCESS) { + SCOPEdo_types( scope, t, de ) + if( t->search_id == CANPROCESS ) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. //FIXME this function is not implemented! @@ -112,25 +111,25 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) SCOPEod; // process each entity. This must be done *before* typedefs are defined - LISTdo(list, e, Entity); - if(e->search_id == CANPROCESS) { - ENTITYPrint(e, files); + LISTdo( list, e, Entity ); + if( e->search_id == CANPROCESS ) { + ENTITYPrint( e, files ); e->search_id = PROCESSED; } LISTod; - LISTfree(list); + LISTfree( list ); // process each function. This must be done *before* typedefs are defined - LISTdo(function_list, f, Function); - FUNCPrint(f, files); + LISTdo( function_list, f, Function ); + FUNCPrint( f, files ); LISTod; - LISTfree(function_list); + LISTfree( function_list ); // process each rule. This must be done *before* typedefs are defined - LISTdo(rule_list, r, Rule); - RULEPrint(r, files); + LISTdo( rule_list, r, Rule ); + RULEPrint( r, files ); LISTod; - LISTfree(rule_list); + LISTfree( rule_list ); } @@ -151,60 +150,52 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) ** Status: ******************************************************************/ -void SCHEMAprint(Schema schema, FILES *files, int suffix) -{ - int ocnt = 0; +void SCHEMAprint( Schema schema, FILES * files, int suffix ) { char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE *libfile; + FILE * libfile; /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(schnm, "%s", SCHEMAget_name(schema)); - if(suffix == 0) { - sprintf(sufnm, "%s", schnm); + sprintf( schnm, "%s", SCHEMAget_name( schema ) ); + if( suffix == 0 ) { + sprintf( sufnm, "%s", schnm ); } else { - ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; - } - } - ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; + sprintf( sufnm, "%s_%d", schnm, suffix ); } + sprintf( fnm, "%s.h", sufnm ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 2. class source file */ - sprintf(np, "py"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "py" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "import sys\n"); - fprintf(libfile, "\n"); - fprintf(libfile, "from SCL.SCLBase import *\n"); - fprintf(libfile, "from SCL.SimpleDataTypes import *\n"); - fprintf(libfile, "from SCL.ConstructedDataTypes import *\n"); - fprintf(libfile, "from SCL.AggregationDataTypes import *\n"); - fprintf(libfile, "from SCL.TypeChecker import check_type\n"); - fprintf(libfile, "from SCL.Builtin import *\n"); - fprintf(libfile, "from SCL.Rules import *\n"); + fprintf( libfile, "import sys\n" ); + fprintf( libfile, "\n" ); + fprintf( libfile, "from SCL.SCLBase import *\n" ); + fprintf( libfile, "from SCL.SimpleDataTypes import *\n" ); + fprintf( libfile, "from SCL.ConstructedDataTypes import *\n" ); + fprintf( libfile, "from SCL.AggregationDataTypes import *\n" ); + fprintf( libfile, "from SCL.TypeChecker import check_type\n" ); + fprintf( libfile, "from SCL.Builtin import *\n" ); + fprintf( libfile, "from SCL.Rules import *\n" ); /********* export schema name *******/ - fprintf(libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name(schema)); + fprintf( libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name( schema ) ); /******** export schema scope *******/ - fprintf(libfile, "schema_scope = sys.modules[__name__]\n\n"); + fprintf( libfile, "schema_scope = sys.modules[__name__]\n\n" ); /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint(schema, files, schema); + SCOPEPrint( schema, files, schema ); /********** close the files ***********/ - FILEclose(libfile); + FILEclose( libfile ); //FILEclose( incfile ); //if( schema->search_id == PROCESSED ) { // fprintf( initfile, "\n}\n" ); @@ -228,37 +219,36 @@ void SCHEMAprint(Schema schema, FILES *files, int suffix) ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) -{ +getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { DictionaryEntry de; Schema schema; - fprintf(schema_h, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n"); - fprintf(schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n"); - fprintf(schema_cc, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n"); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - schema = (Scope)DICTdo(&de); - fprintf(schema_cc, - " if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name(schema)); - fprintf(schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name(schema)); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(schema_cc, - " else if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name(schema)); - fprintf(schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name(schema)); + fprintf( schema_h, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n" ); + fprintf( schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n" ); + fprintf( schema_cc, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n" ); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + schema = ( Scope )DICTdo( &de ); + fprintf( schema_cc, + " if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name( schema ) ); + fprintf( schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name( schema ) ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( schema_cc, + " else if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name( schema ) ); + fprintf( schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name( schema ) ); } - fprintf(schema_cc, "}\n"); + fprintf( schema_cc, "}\n" ); } /****************************************************************** @@ -274,11 +264,10 @@ getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -EXPRESSPrint(Express express, FILES *files) -{ +EXPRESSPrint( Express express, FILES * files ) { char fnm [MAX_LEN]; - const char *schnm; /* schnm is really "express name" */ - FILE *libfile; + const char * schnm; /* schnm is really "express name" */ + FILE * libfile; /* new */ Schema schema; DictionaryEntry de; @@ -287,23 +276,23 @@ EXPRESSPrint(Express express, FILES *files) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); + sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); /* 2. class source file */ //sprintf( np, "cc" ); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } /********** do all schemas ***********/ - DICTdo_init(express->symbol_table, &de); - while(0 != (schema = (Scope)DICTdo(&de))) { - SCOPEPrint(schema, files, schema); + DICTdo_init( express->symbol_table, &de ); + while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { + SCOPEPrint( schema, files, schema ); } /********** close the files ***********/ - FILEclose(libfile); + FILEclose( libfile ); //FILEclose( incfile ); //fprintf( initfile, "\n}\n" ); //FILEclose( initfile ); @@ -323,10 +312,9 @@ EXPRESSPrint(Express express, FILES *files) ******************************************************************/ void -print_schemas_combined(Express express, FILES *files) -{ +print_schemas_combined( Express express, FILES * files ) { - EXPRESSPrint(express, files); + EXPRESSPrint( express, files ); } /* @@ -341,18 +329,17 @@ print_schemas_combined(Express express, FILES *files) */ void -print_file(Express express) -{ - extern void RESOLUTIONsucceed(void); +print_file( Express express ) { + extern void RESOLUTIONsucceed( void ); int separate_schemas = 1; File_holder files; resolution_success(); - if(separate_schemas) { - print_schemas_separate(express, &files); + if( separate_schemas ) { + print_schemas_separate( express, &files ); } else { - print_schemas_combined(express, &files); + print_schemas_combined( express, &files ); } } diff --git a/src/exp2python/src/complexSupport.h b/src/exp2python/src/complexSupport.h index 2f6731724..7cd781a37 100644 --- a/src/exp2python/src/complexSupport.h +++ b/src/exp2python/src/complexSupport.h @@ -63,8 +63,7 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode -{ +class EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -72,59 +71,48 @@ class EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), - multSupers(0) - { - strcpy(name, nm); - } - EntNode(char *[]); // given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), + multSupers( 0 ) { + strcpy( name, nm ); + } + EntNode( char *[] ); // given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - int operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + int operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - int operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + int operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - int operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + int operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - int marked(MarkType base = ORMARK) - { - return (mark >= base); + int marked( MarkType base = ORMARK ) { + return ( mark >= base ); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() - { + int multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - EntNode *next; + EntNode * next; private: MarkType mark; @@ -132,79 +120,68 @@ class EntNode int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList -{ +class EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual int getMaxLevel() - { + virtual int getMaxLevel() { return level; } - virtual int contains(const char *) = 0; - virtual int hit(const char *) = 0; - virtual int isDependent(const char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual int contains( const char * ) = 0; + virtual int hit( const char * ) = 0; + virtual int isDependent( const char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual int acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual int acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); - virtual void write(ostream &) = 0; + virtual void write( ostream & ) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return next->firstNot(j); + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return next->firstWanted(mat); + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return prev->lastNot(j); + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return prev->lastWanted(mat); + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *prev, * next; + EntList * prev, * next; protected: MatchType viable; @@ -216,153 +193,137 @@ class EntList int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList -{ +class SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strcpy(name, n); + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strcpy( name, n ); } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - int contains(const char *nm) - { + int contains( const char * nm ) { return *this == nm; } - int hit(const char *nm) - { + int hit( const char * nm ) { return *this == nm; } - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - int acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + int acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } - void write(ostream &); + void write( ostream & ); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList -{ +class MultList : public EntList { // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} + MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} ~MultList(); - void setLevel(int); + void setLevel( int ); int getMaxLevel(); - int contains(const char *); - int hit(const char *); - int isDependent(const char *); - void appendList(EntList *); - EntList *copyList(EntList *); - void processSubExp(Expression, Entity, ComplexCollect *); - void addSimpleAndSubs(Entity, ComplexCollect *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + int contains( const char * ); + int hit( const char * ); + int isDependent( const char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + void processSubExp( Expression, Entity, ComplexCollect * ); + void addSimpleAndSubs( Entity, ComplexCollect * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - int prevKnown(EntList *); + void unmarkAll( EntNode * ); + int prevKnown( EntList * ); void reset(); - void write(ostream &); + void write( ostream & ); protected: int numchildren; - EntList *childList; + EntList * childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList -{ +class JoinList : public MultList { // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - int acceptChoice(EntNode *); + void setViableVal( EntNode * ); + int acceptChoice( EntNode * ); }; -class AndOrList : public JoinList -{ +class AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class AndList : public JoinList -{ +class AndList : public JoinList { friend class MultList; friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND), supertype(0) {} + AndList() : JoinList( AND ), supertype( 0 ) {} ~AndList() {} - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList -{ +class OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} ~OrList() {} - int hit(const char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - int acceptChoice(EntNode *); - int acceptNextChoice(EntNode *ents) - { + int hit( const char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + int acceptChoice( EntNode * ); + int acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -375,101 +336,90 @@ class OrList : public MultList // the first viable choice; and how many choices are there entirely. }; -class ComplexList -{ +class ComplexList { // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} - ComplexList(Entity, ComplexCollect *); + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} + ComplexList( Entity, ComplexCollect * ); ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return ((SimpleList *)head->childList)->name; + const char * supertype() { + return ( ( SimpleList * )head->childList )->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel(const char *); - int contains(EntNode *); - int matches(EntNode *); - int isDependent(const char *); + int toplevel( const char * ); + int contains( EntNode * ); + int matches( EntNode * ); + int isDependent( const char * ); - EntNode *list; // List of all entities contained in this complex type, + EntNode * list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } - void write(ostream &); - int getEntListMaxLevel() - { + void write( ostream & ); + int getEntListMaxLevel() { return head->getMaxLevel(); } private: - void addSuper(Entity); - void addSubExp(Expression); - void addImplicitSubs(Linked_List, ComplexCollect *); - void addChildren(EntList *); - int hitMultNodes(EntNode *); + void addSuper( Entity ); + void addSubExp( Expression ); + void addImplicitSubs( Linked_List, ComplexCollect * ); + void addChildren( EntList * ); + int hitMultNodes( EntNode * ); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect -{ +class ComplexCollect { // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ComplexCollect(Express); - ~ComplexCollect() - { + ComplexCollect( Express ); + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); + void insert( ComplexList * ); + void remove( ComplexList * ); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList *find(char *); - int supports(EntNode *); - int externMapping(const char *ent) - { - return (clists ? clists->isDependent(ent) : 0); + ComplexList * find( char * ); + int supports( EntNode * ); + int externMapping( const char * ent ) { + return ( clists ? clists->isDependent( ent ) : 0 ); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write(const char *); + void write( const char * ); - ComplexList *clists; + ComplexList * clists; private: int count; // # of clist children @@ -477,6 +427,6 @@ class ComplexCollect // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex(ComplexCollect &, const char *); +void print_complex( ComplexCollect &, const char * ); #endif diff --git a/src/exp2python/src/fedex_main_python.c b/src/exp2python/src/fedex_main_python.c index d8d379ce9..be7bdd242 100644 --- a/src/exp2python/src/fedex_main_python.c +++ b/src/exp2python/src/fedex_main_python.c @@ -11,56 +11,52 @@ #include "../express/express.h" #include "../express/resolve.h" -extern void print_fedex_version(void); +extern void print_fedex_version( void ); -static void exp2python_usage(void) -{ +static void exp2python_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "\t-v produces the version description below\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); + fprintf( stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "\t-v produces the version description below\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); print_fedex_version(); - exit(2); + exit( 2 ); } -int Handle_FedPlus_Args(int, char *); -void print_file(Express); +int Handle_FedPlus_Args( int, char * ); +void print_file( Express ); -void resolution_success(void) -{ - printf("Resolution successful.\nWriting python module..."); +void resolution_success( void ) { + printf( "Resolution successful.\nWriting python module..." ); } -int success(Express model) -{ +int success( Express model ) { (void) model; /* unused */ - printf("Done.\n"); - return(0); + printf( "Done.\n" ); + return( 0 ); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat(EXPRESSgetopt_options, "sSLcCaA"); + strcat( EXPRESSgetopt_options, "sSLcCaA" ); ERRORusage_function = exp2python_usage; } diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index efc46a7b1..ece7e6617 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -37,22 +37,22 @@ #define FALSE 0 #define TRUE 1 -int isAggregateType(const Type t); +int isAggregateType( const Type t ); /* Local function prototypes: */ -static void initializeMarks(Express); -static void unsetObjs(Schema); -static int checkTypes(Schema); -static int checkEnts(Schema); -static void markDescs(Entity); -static int checkItem(Type, Scope, Schema, int *, int); -static int ENUMcanBeProcessed(Type, Schema); -static int inSchema(Scope, Scope); +static void initializeMarks( Express ); +static void unsetObjs( Schema ); +static int checkTypes( Schema ); +static int checkEnts( Schema ); +static void markDescs( Entity ); +static int checkItem( Type, Scope, Schema, int *, int ); +static int ENUMcanBeProcessed( Type, Schema ); +static int inSchema( Scope, Scope ); /* static void addRenameTypedefs( Schema, FILE * ); */ -static void addAggrTypedefs(Schema schema); -static void addUseRefNames(Schema, FILE *); +static void addAggrTypedefs( Schema schema ); +static void addUseRefNames( Schema, FILE * ); -void print_schemas_separate(Express express, FILES *files) +void print_schemas_separate( Express express, FILES * files ) /* * Generates the C++ files corresponding to a list of schemas. Does so in * multiple passes through the schemas. In each pass it checks for enti- @@ -69,31 +69,31 @@ void print_schemas_separate(Express express, FILES *files) Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks(express); + initializeMarks( express ); /* FIXME SdaiAll.cc:12:24: warning: unused variable ‘is’ [-Wunused-variable] (also for ui & ri) */ /* fprintf( files->create, " Interface_spec_ptr is;\n Used_item_ptr ui;\n Referenced_item_ptr ri;\n Uniqueness_rule_ptr ur;\n Where_rule_ptr wr;\n Global_rule_ptr gr;\n" ); */ - while(!complete) { + while( !complete ) { complete = TRUE; - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - if(schema->search_id == UNPROCESSED) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + if( schema->search_id == UNPROCESSED ) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs(schema); + unsetObjs( schema ); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes(schema); - val2 = checkEnts(schema); + val1 = checkTypes( schema ); + val2 = checkEnts( schema ); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if(val1 || val2) { - if(schema->search_id == UNPROCESSED || - *(int *)schema->clientData > 0) { + if( val1 || val2 ) { + if( schema->search_id == UNPROCESSED || + *( int * )schema->clientData > 0 ) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -103,13 +103,13 @@ void print_schemas_separate(Express express, FILES *files) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*(int *)schema->clientData; - SCHEMAprint(schema, files, suffix); + suffix = ++*( int * )schema->clientData; + SCHEMAprint( schema, files, suffix ); } else { - SCHEMAprint(schema, files, 0); + SCHEMAprint( schema, files, 0 ); } } - complete = complete && (schema->search_id == PROCESSED); + complete = complete && ( schema->search_id == PROCESSED ); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -131,18 +131,18 @@ void print_schemas_separate(Express express, FILES *files) /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addUseRefNames(schema, files->create); + addUseRefNames( schema, files->create ); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* addAggrTypedefs( schema, files->classes ); */ - addAggrTypedefs(schema); + addAggrTypedefs( schema ); } /* On our way out, print the necessary statements to add support for @@ -168,20 +168,19 @@ void print_schemas_separate(Express express, FILES *files) * an attribute/item which comes from another schema. All other types can * be processed the first time, but that will be caught in checkTypes().) */ -static void initializeMarks(Express express) -{ +static void initializeMarks( Express express ) { DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { schema->search_id = UNPROCESSED; - schema->clientData = (int *)malloc(sizeof(int)); - *(int *)schema->clientData = 0; - SCOPEdo_entities(schema, ent, de_ent) + schema->clientData = ( int * )malloc( sizeof( int ) ); + *( int * )schema->clientData = 0; + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types(schema, t, de_type) + SCOPEdo_types( schema, t, de_type ) t->search_id = NOTKNOWN; SCOPEod } @@ -196,17 +195,16 @@ static void initializeMarks(Express express) * types which have already been marked PROCESSED will not have to be * revisited, and are not changed. */ -static void unsetObjs(Schema schema) -{ +static void unsetObjs( Schema schema ) { DictionaryEntry de; - SCOPEdo_types(schema, t, de) - if(t->search_id == CANTPROCESS) { + SCOPEdo_types( schema, t, de ) + if( t->search_id == CANTPROCESS ) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities(schema, ent, de) - if(ent->search_id == CANTPROCESS) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id == CANTPROCESS ) { ent->search_id = NOTKNOWN; } SCOPEod @@ -224,8 +222,7 @@ static void unsetObjs(Schema schema) * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static int checkTypes(Schema schema) -{ +static int checkTypes( Schema schema ) { DictionaryEntry de; int retval = FALSE, unknowncnt; Type i; @@ -234,8 +231,8 @@ static int checkTypes(Schema schema) do { unknowncnt = 0; - SCOPEdo_types(schema, type, de) - if(type->search_id != NOTKNOWN) { + SCOPEdo_types( schema, type, de ) + if( type->search_id != NOTKNOWN ) { continue; } /* We're only interested in the ones which haven't been processed @@ -244,9 +241,9 @@ static int checkTypes(Schema schema) type->search_id = CANPROCESS; /* Assume this until disproven. */ - if(TYPEis_enumeration(type) && TYPEget_head(type)) { - i = TYPEget_ancestor(type); - if(!sameSchema(i, type) && i->search_id != PROCESSED) { + if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { + i = TYPEget_ancestor( type ); + if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -255,10 +252,10 @@ static int checkTypes(Schema schema) type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if(TYPEis_select(type)) { - LISTdo(SEL_TYPEget_items(type), ii, Type) { - if(!TYPEis_entity(ii)) { - if(checkItem(ii, type, schema, &unknowncnt, 0)) { + } else if( TYPEis_select( type ) ) { + LISTdo( SEL_TYPEget_items( type ), ii, Type ) { + if( !TYPEis_entity( ii ) ) { + if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { break; } /* checkItem does most of the work of determining if @@ -272,8 +269,8 @@ static int checkTypes(Schema schema) } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity(ii); - if(ent->search_id == PROCESSED) { + ent = ENT_TYPEget_entity( ii ); + if( ent->search_id == PROCESSED ) { continue; } /* If entity has been processed already, things must be @@ -283,33 +280,31 @@ static int checkTypes(Schema schema) // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes(ent); - LISTdo_n(attribs, attr, Variable, b) { - if(checkItem(attr->type, type, schema, - &unknowncnt, 1)) { + attribs = ENTITYget_all_attributes( ent ); + LISTdo_n( attribs, attr, Variable, b ) { + if( checkItem( attr->type, type, schema, + &unknowncnt, 1 ) ) { break; } - } - LISTod - LISTfree(attribs); + } LISTod + LISTfree( attribs ); } - } - LISTod + } LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if((type->search_id == CANPROCESS) - && ((i = TYPEget_ancestor(type)) != NULL) - && (!sameSchema(i, type)) - && (i->search_id != PROCESSED)) { + if( ( type->search_id == CANPROCESS ) + && ( ( i = TYPEget_ancestor( type ) ) != NULL ) + && ( !sameSchema( i, type ) ) + && ( i->search_id != PROCESSED ) ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if(type->search_id == CANPROCESS) { + if( type->search_id == CANPROCESS ) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -318,7 +313,7 @@ static int checkTypes(Schema schema) retval = TRUE; } SCOPEod - } while(unknowncnt > 0); + } while( unknowncnt > 0 ); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -336,7 +331,7 @@ static int checkTypes(Schema schema) return retval; } -static int checkEnts(Schema schema) +static int checkEnts( Schema schema ) /* * Goes through the entities contained in this schema checking for ones * which can't be processed. It checks for two situations: (1) If we find @@ -358,8 +353,8 @@ static int checkEnts(Schema schema) int retval = FALSE, ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities(schema, ent, de) - if(ent->search_id != NOTKNOWN) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id != NOTKNOWN ) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -371,10 +366,10 @@ static int checkEnts(Schema schema) /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo(ENTITYget_supertypes(ent), super, Entity) - if((!sameSchema(ent, super)) - && (super->search_id != PROCESSED)) { - markDescs(ent); + LISTdo( ENTITYget_supertypes( ent ), super, Entity ) + if( ( !sameSchema( ent, super ) ) + && ( super->search_id != PROCESSED ) ) { + markDescs( ent ); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -384,17 +379,17 @@ static int checkEnts(Schema schema) /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo(ENTITYget_attributes(ent), attr, Variable) - if(checkItem(attr->type, ent, schema, &ignore, 0)) { - markDescs(ent); + LISTdo( ENTITYget_attributes( ent ), attr, Variable ) + if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { + markDescs( ent ); break; } LISTod } - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -410,7 +405,7 @@ static int checkEnts(Schema schema) return retval; } -static void markDescs(Entity ent) +static void markDescs( Entity ent ) /* * Sets the mark value of ent and all its subtypes to CANTPROCESS. This * function is called if we've determined that ent is a subtype of an @@ -418,13 +413,13 @@ static void markDescs(Entity ent) */ { ent->search_id = CANTPROCESS; - LISTdo(ENTITYget_subtypes(ent), sub, Entity) - markDescs(sub); + LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) + markDescs( sub ); LISTod } -static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, - int noSel) +static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, + int noSel ) /* * Function with a lot of side effects: Checks if type t, a member of * `parent' makes parent unprocessable. parent may be an entity and t is @@ -450,8 +445,8 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, { Type i = t; - if(isAggregateType(t)) { - i = TYPEget_base_type(t); + if( isAggregateType( t ) ) { + i = TYPEget_base_type( t ); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -460,26 +455,26 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, // Sdaiclasses.h. */ } - if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { + if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if(parent->search_id == NOTKNOWN) { + if( parent->search_id == NOTKNOWN ) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - (*unknowncnt)--; + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if(TYPEis_select(i) && !noSel) { - if(!sameSchema(i, parent)) { - if(i->search_id != PROCESSED) { - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + } else if( TYPEis_select( i ) && !noSel ) { + if( !sameSchema( i, parent ) ) { + if( i->search_id != PROCESSED ) { + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -489,24 +484,24 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if(i->search_id == CANTPROCESS) { + if( i->search_id == CANTPROCESS ) { /* We *have* checked i already and it can't be processed. */ - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if(i->search_id == NOTKNOWN) { + } else if( i->search_id == NOTKNOWN ) { /* We haven't processed i this pass. */ - if(parent->search_id != NOTKNOWN) { + if( parent->search_id != NOTKNOWN ) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping through the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - (*unknowncnt)++; + ( *unknowncnt )++; } } } @@ -514,7 +509,7 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, return FALSE; } -static int ENUMcanBeProcessed(Type e, Schema s) +static int ENUMcanBeProcessed( Type e, Schema s ) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -526,31 +521,31 @@ static int ENUMcanBeProcessed(Type e, Schema s) { Type a; - if(!inSchema(e, s)) { + if( !inSchema( e, s ) ) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return (e->search_id == PROCESSED); + return ( e->search_id == PROCESSED ); } - if(e->search_id != NOTKNOWN) { + if( e->search_id != NOTKNOWN ) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return (e->search_id >= CANPROCESS); + return ( e->search_id >= CANPROCESS ); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if((a = TYPEget_ancestor(e)) == NULL) { + if( ( a = TYPEget_ancestor( e ) ) == NULL ) { /* If e is not a rename of anything, it should be processed now. */ return TRUE; } - if(inSchema(a, s) || a->search_id == PROCESSED) { + if( inSchema( a, s ) || a->search_id == PROCESSED ) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return TRUE; @@ -558,26 +553,26 @@ static int ENUMcanBeProcessed(Type e, Schema s) return FALSE; } -int sameSchema(Scope sc1, Scope sc2) +int sameSchema( Scope sc1, Scope sc2 ) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return (!strcmp(SCOPEget_name(sc1->superscope), - SCOPEget_name(sc2->superscope))); + return ( !strcmp( SCOPEget_name( sc1->superscope ), + SCOPEget_name( sc2->superscope ) ) ); } -static int inSchema(Scope scope, Scope super) +static int inSchema( Scope scope, Scope super ) /* * Checks if scope is contained in super's scope. */ { - return (!strcmp(SCOPEget_name(scope->superscope), - SCOPEget_name(super))); + return ( !strcmp( SCOPEget_name( scope->superscope ), + SCOPEget_name( super ) ) ); } -static void addAggrTypedefs(Schema schema) +static void addAggrTypedefs( Schema schema ) /* * Print typedefs at the end of Sdiaclasses.h for aggregates of enum's and * selects. Since the underlying enum/sel may appear in any schema, this @@ -589,15 +584,15 @@ static void addAggrTypedefs(Schema schema) DictionaryEntry de; Type i; - SCOPEdo_types(schema, t, de) - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + SCOPEdo_types( schema, t, de ) + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - printf("in addAggrTypedefs. %s is enum or select.\n", TYPEget_name(t)); + printf( "in addAggrTypedefs. %s is enum or select.\n", TYPEget_name( t ) ); /* strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); //printf("%s;%s",nm,TYPEget_ctype( t )); //if( firsttime ) { @@ -615,7 +610,7 @@ static void addAggrTypedefs(Schema schema) SCOPEod } -static void addUseRefNames(Schema schema, FILE *create) +static void addUseRefNames( Schema schema, FILE * create ) /* * Checks the USE and REFERENCE dicts contained in schema. If either dict * contains items (types or entities) which are renamed in this schema, @@ -627,60 +622,60 @@ static void addUseRefNames(Schema schema, FILE *create) { Dictionary useRefDict; DictionaryEntry de; - Rename *rnm; - char *oldnm, schNm[BUFSIZ]; + Rename * rnm; + char * oldnm, schNm[BUFSIZ]; static int firsttime = TRUE; - if((useRefDict = schema->u.schema->usedict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { + if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if(firsttime) { - fprintf(create, "\t// Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( firsttime ) { + fprintf( create, "\t// Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = FALSE; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); } else { /* must be an entity */ - fprintf(create, "\t%s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, "\t%s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } - if((useRefDict = schema->u.schema->refdict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { - if(firsttime) { - fprintf(create, "\t// Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if( firsttime ) { + fprintf( create, "\t// Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = FALSE; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); } else { - fprintf(create, "\t%s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, "\t%s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index 3a202d900..b44abab95 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -25,13 +25,13 @@ extern int multiple_inheritance; #include "classes.h" #include -bool is_python_keyword(char *word); -int isAggregateType(const Type t); -char *generate_attribute_name(Variable a, char *out); -void ATTRsign_access_methods(Variable a, FILE *file); -char *generate_attribute_func_name(Variable a, char *out); -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file); -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); +bool is_python_keyword( char * word ); +int isAggregateType( const Type t ); +char * generate_attribute_name( Variable a, char * out ); +void ATTRsign_access_methods( Variable a, FILE * file ); +char * generate_attribute_func_name( Variable a, char * out ); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file ); +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); #define BASE_SELECT "SCLP23(Select)" @@ -62,17 +62,15 @@ void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file #define FALSE 0 const char * -SEL_ITEMget_enumtype(Type t) -{ - return StrToUpper(TYPEget_name(t)); +SEL_ITEMget_enumtype( Type t ) { + return StrToUpper( TYPEget_name( t ) ); } /** FIXME implement for python or remove ** \returns type used to represent the underlying type in a select class */ -const char *TYPEget_utype(Type t) -{ +const char * TYPEget_utype( Type t ) { (void) t; /* unused */ return NULL; } @@ -84,14 +82,13 @@ determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. *******************/ void * -LISTmember(const Linked_List list, void *e) -{ +LISTmember( const Linked_List list, void *e ) { Link node; - for(node = list->mark->next; node != list->mark; node = node->next) - if(e == node -> data) { + for( node = list->mark->next; node != list->mark; node = node->next ) + if( e == node -> data ) { return e; } - return (0); + return ( 0 ); } /******************* @@ -106,19 +103,18 @@ LISTmember(const Linked_List list, void *e) dered equivalent. One such case is the generation of duplicate lists. *******************/ static int -compareOrigTypes(Type a, Type b) -{ +compareOrigTypes( Type a, Type b ) { Type t, u; - if((TYPEis_select(a) && TYPEis_select(b)) - || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { + if( ( TYPEis_select( a ) && TYPEis_select( b ) ) + || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { t = a; u = b; - } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { - t = TYPEget_base_type(a); - u = TYPEget_base_type(b); - if(!((TYPEis_select(t) && TYPEis_select(u)) - || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { + } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { + t = TYPEget_base_type( a ); + u = TYPEget_base_type( b ); + if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) + || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that // for 2D aggrs and higher we do not continue. These are all recog- @@ -129,13 +125,13 @@ compareOrigTypes(Type a, Type b) return FALSE; } - if(TYPEget_head(t)) { - t = TYPEget_ancestor(t); + if( TYPEget_head( t ) ) { + t = TYPEget_ancestor( t ); } - if(TYPEget_head(u)) { - u = TYPEget_ancestor(u); + if( TYPEget_head( u ) ) { + u = TYPEget_ancestor( u ); } - return (!strcmp(TYPEget_name(t), TYPEget_name(u))); + return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); } /******************* @@ -149,16 +145,15 @@ compareOrigTypes(Type a, Type b) compareOrigTypes() above). *******************/ const char * -utype_member(const Linked_List list, const Type check, int rename) -{ +utype_member( const Linked_List list, const Type check, int rename ) { static char r [BUFSIZ]; - LISTdo(list, t, Type) - strncpy(r, TYPEget_utype(t), BUFSIZ); - if(strcmp(r, TYPEget_utype(check)) == 0) { + LISTdo( list, t, Type ) + strncpy( r, TYPEget_utype( t ), BUFSIZ ); + if( strcmp( r, TYPEget_utype( check ) ) == 0 ) { return r; } - if(rename && compareOrigTypes(check, t)) { + if( rename && compareOrigTypes( check, t ) ) { return r; } LISTod; @@ -176,16 +171,15 @@ utype_member(const Linked_List list, const Type check, int rename) Linked_List -SELgetnew_dmlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SELgetnew_dmlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); - LISTdo(complete, t, Type) + LISTdo( complete, t, Type ) /* if t\'s underlying type is not already in newlist, */ - if(! utype_member(newlist, t, 0)) { - LISTadd_last(newlist, t); + if( ! utype_member( newlist, t, 0 ) ) { + LISTadd_last( newlist, t ); } LISTod; @@ -195,10 +189,9 @@ SELgetnew_dmlist(const Type type) } const char * -SEL_ITEMget_dmtype(Type t, const Linked_List l) -{ - const char *r = utype_member(l, t, 0); - return StrToLower(r ? r : TYPEget_utype(t)); +SEL_ITEMget_dmtype( Type t, const Linked_List l ) { + const char * r = utype_member( l, t, 0 ); + return StrToLower( r ? r : TYPEget_utype( t ) ); } @@ -211,15 +204,14 @@ of the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_in_express_list(const Linked_List list, const Type check) -{ - if(TYPEis_entity(check)) { +duplicate_in_express_list( const Linked_List list, const Type check ) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; /* don\'t compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -236,10 +228,9 @@ underlying Express type. RETURNS 1 if true, else 0. *******************/ int -unique_types(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_in_express_list(list, t)) { +unique_types( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_in_express_list( list, t ) ) { return FALSE; } LISTod; @@ -254,30 +245,29 @@ determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_utype_member(const Linked_List list, const Type check) -{ +duplicate_utype_member( const Linked_List list, const Type check ) { char b [BUFSIZ]; - if(TYPEis_entity(check)) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; } /* don\'t compare check to itself */ else { /* continue looking */ - strncpy(b, TYPEget_utype(t), BUFSIZ); - if((!strcmp(b, TYPEget_utype(check))) - || (compareOrigTypes(t, check))) + strncpy( b, TYPEget_utype( t ), BUFSIZ ); + if( ( !strcmp( b, TYPEget_utype( check ) ) ) + || ( compareOrigTypes( t, check ) ) ) /* if the underlying types are the same */ { return TRUE; } - if(! strcmp(b, "SCLP23(Integer)") && - (! strcmp(TYPEget_utype(check), "SCLP23(Real)"))) + if( ! strcmp( b, "SCLP23(Integer)" ) && + ( ! strcmp( TYPEget_utype( check ), "SCLP23(Real)" ) ) ) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -295,10 +285,9 @@ C++ representation for the underlying Express type. RETURNS 1 if true, else 0. *******************/ int -any_duplicates_in_select(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_utype_member(list, t)) { +any_duplicates_in_select( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_utype_member( list, t ) ) { return TRUE; } LISTod; @@ -314,25 +303,24 @@ returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. *******************/ int -find_duplicate_list(const Type type, Linked_List *duplicate_list) -{ +find_duplicate_list( const Type type, Linked_List * duplicate_list ) { Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if(any_duplicates_in_select(SEL_TYPEget_items(type))) { + if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo(SEL_TYPEget_items(type), u, Type) - if(!utype_member(*duplicate_list, u, 1)) { + LISTdo( SEL_TYPEget_items( type ), u, Type ) + if( !utype_member( *duplicate_list, u, 1 ) ) { /** if not already a duplicate **/ - if(utype_member(temp, u, 1)) { - LISTadd_first(*duplicate_list, u); + if( utype_member( temp, u, 1 ) ) { + LISTadd_first( *duplicate_list, u ); } else { - LISTadd_first(temp, u); + LISTadd_first( temp, u ); } } LISTod; - LISTfree(temp); + LISTfree( temp ); return TRUE; } return FALSE; @@ -367,10 +355,9 @@ enum __types { the leaf nodes. */ void -non_unique_types_vector(const Type type, int *tvec) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - switch(TYPEget_body(t)->type) { +non_unique_types_vector( const Type type, int * tvec ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + switch( TYPEget_body( t )->type ) { case integer_: tvec[tint]++; break; @@ -390,7 +377,7 @@ non_unique_types_vector(const Type type, int *tvec) break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector(t, tvec); + non_unique_types_vector( t, tvec ); break; case entity_: tvec[tentity]++; @@ -406,7 +393,7 @@ non_unique_types_vector(const Type type, int *tvec) tvec[tnumber]++; break; default: - fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } LISTod; @@ -418,60 +405,59 @@ non_unique_types_vector(const Type type, int *tvec) types. If all types are unique, the string (0) is generated. */ char * -non_unique_types_string(const Type type) -{ +non_unique_types_string( const Type type ) { int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char *typestr; + char * typestr; int first = 1; int i; - non_unique_types_vector(type, tvec); + non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = (char *)malloc(BUFSIZ); + typestr = ( char * )malloc( BUFSIZ ); typestr[0] = '\0'; - strcat(typestr, (char *)"("); - for(i = 0; i <= tnumber; i++) { - if(tvec[i] < 2) { + strcat( typestr, ( char * )"(" ); + for( i = 0; i <= tnumber; i++ ) { + if( tvec[i] < 2 ) { continue; /* skip, this one is unique */ } - if(!first) { - strcat(typestr, (char *)" | "); + if( !first ) { + strcat( typestr, ( char * )" | " ); } else { first = 0; } - switch(i) { + switch( i ) { case tint : - strcat(typestr, (char *)"sdaiINTEGER"); + strcat( typestr, ( char * )"sdaiINTEGER" ); break; case treal : - strcat(typestr, (char *)"sdaiREAL"); + strcat( typestr, ( char * )"sdaiREAL" ); break; case tstring: - strcat(typestr, (char *)"sdaiSTRING"); + strcat( typestr, ( char * )"sdaiSTRING" ); break; case tbinary: - strcat(typestr, (char *)"sdaiBINARY"); + strcat( typestr, ( char * )"sdaiBINARY" ); break; case tenum : - strcat(typestr, (char *)"sdaiENUMERATION"); + strcat( typestr, ( char * )"sdaiENUMERATION" ); break; case tentity: - strcat(typestr, (char *)"sdaiINSTANCE"); + strcat( typestr, ( char * )"sdaiINSTANCE" ); break; case taggr : - strcat(typestr, (char *)"sdaiAGGR"); + strcat( typestr, ( char * )"sdaiAGGR" ); break; case tnumber: - strcat(typestr, (char *)"sdaiNUMBER"); + strcat( typestr, ( char * )"sdaiNUMBER" ); break; } } - if(first) { - strcat(typestr, (char *)"0"); + if( first ) { + strcat( typestr, ( char * )"0" ); } - strcat(typestr, (char *)")"); + strcat( typestr, ( char * )")" ); return typestr; } @@ -488,19 +474,18 @@ non_unique_types_string(const Type type) ******************************************************************/ Variable -ATTR_LISTmember(Linked_List l, Variable check) -{ +ATTR_LISTmember( Linked_List l, Variable check ) { char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name(check, nm); - LISTdo(l, a, Variable) - generate_attribute_name(a, cur); - if(! strcmp(nm, cur)) { + generate_attribute_name( check, nm ); + LISTdo( l, a, Variable ) + generate_attribute_name( a, cur ); + if( ! strcmp( nm, cur ) ) { return check; } LISTod; - return (0); + return ( 0 ); } @@ -516,20 +501,19 @@ ATTR_LISTmember(Linked_List l, Variable check) ******************************************************************/ Linked_List -SEL_TYPEgetnew_attribute_list(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SEL_TYPEgetnew_attribute_list( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - attrs = ENTITYget_all_attributes(cur); - LISTdo_n(attrs, a, Variable, b) - if(! ATTR_LISTmember(newlist, a)) { - LISTadd_first(newlist, a); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + attrs = ENTITYget_all_attributes( cur ); + LISTdo_n( attrs, a, Variable, b ) + if( ! ATTR_LISTmember( newlist, a ) ) { + LISTadd_first( newlist, a ); } LISTod; } @@ -539,46 +523,44 @@ SEL_TYPEgetnew_attribute_list(const Type type) Linked_List -ENTITYget_expanded_entities(Entity e, Linked_List l) -{ +ENTITYget_expanded_entities( Entity e, Linked_List l ) { Linked_List supers; Entity super; - if(! LISTmember(l, e)) { - LISTadd_first(l, e); + if( ! LISTmember( l, e ) ) { + LISTadd_first( l, e ); } - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - supers = ENTITYget_supertypes(e); - LISTdo(supers, s, Entity) + supers = ENTITYget_supertypes( e ); + LISTdo( supers, s, Entity ) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if(super_cnt == 0) { - ENTITYget_expanded_entities(s, l); + if( super_cnt == 0 ) { + ENTITYget_expanded_entities( s, l ); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass(e); - ENTITYget_expanded_entities(super, l); + super = ENTITYget_superclass( e ); + ENTITYget_expanded_entities( super, l ); } return l; } Linked_List -SELget_entity_itemlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SELget_entity_itemlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - ENTITYget_expanded_entities(cur, newlist); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + ENTITYget_expanded_entities( cur, newlist ); } LISTod; return newlist; @@ -591,39 +573,38 @@ TYPEselect_lib_print prints the member functions (definitions) of a select class. *******************/ void -TYPEselect_lib_print(const Type type, FILE *f) -{ +TYPEselect_lib_print( const Type type, FILE * f ) { int nbr_select = 0; int num = 0; - fprintf(f, "# SELECT TYPE %s\n", TYPEget_name(type)); + fprintf( f, "# SELECT TYPE %s\n", TYPEget_name( type ) ); /* create the SELECT */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "%s_ = SELECT(", TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "%s_ = SELECT(", TYPEget_name( type ) ); } else { - fprintf(f, "%s = SELECT(", TYPEget_name(type)); + fprintf( f, "%s = SELECT(", TYPEget_name( type ) ); } /* first compute the number of types (necessary to insert commas) */ nbr_select = 0; - LISTdo(SEL_TYPEget_items(type), t, Type) + LISTdo( SEL_TYPEget_items( type ), t, Type ) (void) t; /* unused */ nbr_select++; LISTod; /* then write types */ num = 0; - LISTdo(SEL_TYPEget_items(type), t, Type) - if(is_python_keyword(TYPEget_name(t))) { - fprintf(f, "\n\t'%s_'", TYPEget_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( is_python_keyword( TYPEget_name( t ) ) ) { + fprintf( f, "\n\t'%s_'", TYPEget_name( t ) ); } else { - fprintf(f, "\n\t'%s'", TYPEget_name(t)); + fprintf( f, "\n\t'%s'", TYPEget_name( t ) ); } - if(num < nbr_select - 1) { - fprintf(f, ","); + if( num < nbr_select - 1 ) { + fprintf( f, "," ); } num++; LISTod; - fprintf(f, ",\n\tscope = schema_scope)\n"); + fprintf( f, ",\n\tscope = schema_scope)\n" ); } #undef BASE_SELECT diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 0d1fb9649..5d6b7a6f3 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories( ${SC_SOURCE_DIR}/src/express ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) set_target_properties(libexppp PROPERTIES PREFIX "") if(WIN32) @@ -38,7 +38,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) set_target_properties(libexppp-static PROPERTIES PREFIX "") endif() diff --git a/src/exppp/exppp-main.c b/src/exppp/exppp-main.c index 7ca23c034..670dd7a88 100644 --- a/src/exppp/exppp-main.c +++ b/src/exppp/exppp-main.c @@ -3,66 +3,63 @@ #include "../express/express.h" #include "exppp.h" -static void exppp_usage(void) -{ +static void exppp_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name); - fprintf(stderr, "\t-v produces a version description\n"); - fprintf(stderr, "\t-l specifies line length hint for output\n"); - fprintf(stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n"); - fprintf(stderr, "\t-c for constants, print one item per line (YMMV!)\n"); - fprintf(stderr, "\t-o specifies the name of the output file (-- for stdout)\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); - exit(2); + fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "\t-v produces a version description\n" ); + fprintf( stderr, "\t-l specifies line length hint for output\n" ); + fprintf( stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n" ); + fprintf( stderr, "\t-c for constants, print one item per line (YMMV!)\n" ); + fprintf( stderr, "\t-o specifies the name of the output file (-- for stdout)\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); + exit( 2 ); } -int Handle_Exppp_Args(int i, char *arg) -{ - if(tolower((char)i) == 'o') { - if(!strcmp("--", arg)) { +int Handle_Exppp_Args( int i, char * arg ) { + if( tolower( ( char )i ) == 'o' ) { + if( !strcmp( "--", arg ) ) { exppp_print_to_stdout = true; return 0; } exppp_output_filename_reset = false; exppp_output_filename = arg; return 0; - } else if(tolower((char)i) == 'l') { - if((strlen(arg) > 5) || (strlen(arg) < 2)) { - fprintf(stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg); + } else if( tolower( ( char )i ) == 'l' ) { + if( ( strlen( arg ) > 5 ) || ( strlen( arg ) < 2 ) ) { + fprintf( stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg ); return 1; } - exppp_linelength = atoi(arg); + exppp_linelength = atoi( arg ); return 0; - } else if(tolower((char)i) == 'c') { + } else if( tolower( ( char )i ) == 'c' ) { exppp_aggressively_wrap_consts = true; return 0; - } else if(tolower((char)i) == 't') { + } else if( tolower( ( char )i ) == 't' ) { exppp_tail_comment = true; return 0; } return 1; } -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { exppp_alphabetize = true; EXPRESSbackend = EXPRESSout; ERRORusage_function = exppp_usage; - strcat(EXPRESSgetopt_options, "o:l:ct"); + strcat( EXPRESSgetopt_options, "o:l:ct" ); EXPRESSgetopt = Handle_Exppp_Args; } diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index 0aba5bbfc..e40ffaee9 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -30,26 +30,26 @@ # error "PP_SMALL_BUF_SZ already defined" #endif -void ALGscope_out(Scope s, int level); -void ENTITYattrs_out(Linked_List attributes, int derived, int level); -void ENTITY_out(Entity e, int level); -void ENTITYinverse_out(Linked_List attrs, int level); -void ENTITYunique_out(Linked_List u, int level); -void FUNC_out(Function fn, int level); -void PROC_out(Procedure p, int level); -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); -void RULE_out(Rule r, int level); -void SCOPEalgs_out(Scope s, int level); -void SCOPEconsts_out(Scope s, int level); -void SCOPEentities_out(Scope s, int level); -void SCOPElocals_out(Scope s, int level); -void SCOPEtypes_out(Scope s, int level); -void STMT_out(Statement s, int level); -void STMTlist_out(Linked_List stmts, int level); -void TYPE_out(Type t, int level); -void TYPE_head_out(Type t, int level); -void TYPE_body_out(Type t, int level); -void WHERE_out(Linked_List wheres, int level); +void ALGscope_out( Scope s, int level ); +void ENTITYattrs_out( Linked_List attributes, int derived, int level ); +void ENTITY_out( Entity e, int level ); +void ENTITYinverse_out( Linked_List attrs, int level ); +void ENTITYunique_out( Linked_List u, int level ); +void FUNC_out( Function fn, int level ); +void PROC_out( Procedure p, int level ); +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); +void RULE_out( Rule r, int level ); +void SCOPEalgs_out( Scope s, int level ); +void SCOPEconsts_out( Scope s, int level ); +void SCOPEentities_out( Scope s, int level ); +void SCOPElocals_out( Scope s, int level ); +void SCOPEtypes_out( Scope s, int level ); +void STMT_out( Statement s, int level ); +void STMTlist_out( Linked_List stmts, int level ); +void TYPE_out( Type t, int level ); +void TYPE_head_out( Type t, int level ); +void TYPE_body_out( Type t, int level ); +void WHERE_out( Linked_List wheres, int level ); Error ERROR_select_empty; @@ -73,11 +73,11 @@ bool exppp_terse = false; bool exppp_reference_info = false; /* if true, add commentary about where things came from */ bool exppp_tail_comment = false; -FILE *exppp_fp = NULL; /* output file */ -char *exppp_buf = 0; /* output buffer */ +FILE * exppp_fp = NULL; /* output file */ +char * exppp_buf = 0; /* output buffer */ int exppp_maxbuflen = 0; /* size of expppbuf */ unsigned int exppp_buflen = 0; /* remaining space in expppbuf */ -char *exppp_bufp = 0; /* pointer to write position in expppbuf, +char * exppp_bufp = 0; /* pointer to write position in expppbuf, * should usually be pointing to a "\0" */ /** used to print a comment containing the name of a structure at the @@ -85,20 +85,18 @@ char *exppp_bufp = 0; /* pointer to write position in expppbuf, * * prints a newline regardless */ -void tail_comment(const char *name) -{ - if(exppp_tail_comment) { - raw(" -- %s", name); +void tail_comment( const char * name ) { + if( exppp_tail_comment ) { + raw( " -- %s", name ); } - raw("\n"); + raw( "\n" ); } /** count newlines in a string */ -int count_newlines(char *s) -{ +int count_newlines( char * s ) { int count = 0; - for(; *s; s++) { - if(*s == '\n') { + for( ; *s; s++ ) { + if( *s == '\n' ) { count++; } } @@ -108,48 +106,46 @@ int count_newlines(char *s) /** true if last char through exp_output was a space */ static bool printedSpaceLast = false; -void exp_output(char *buf, unsigned int len) -{ - FILE *fp = (exppp_fp ? exppp_fp : stdout); +void exp_output( char * buf, unsigned int len ) { + FILE * fp = ( exppp_fp ? exppp_fp : stdout ); - error_sym.line += count_newlines(buf); - printedSpaceLast = (*(buf + len - 1) == ' '); - if(exppp_buf) { + error_sym.line += count_newlines( buf ); + printedSpaceLast = ( *( buf + len - 1) == ' ' ); + if( exppp_buf ) { /* output to string */ - if(len > exppp_buflen) { + if( len > exppp_buflen ) { /* should provide flag to enable complaint */ /* for now, just ignore */ return; } - memcpy(exppp_bufp, buf, len + 1); + memcpy( exppp_bufp, buf, len + 1 ); exppp_bufp += len; exppp_buflen -= len; } else { /* output to file */ - size_t out = fwrite(buf, 1, len, fp); - if(out != len) { - const char *err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; - fprintf(stderr, err, __FILE__, __LINE__, len, out); + size_t out = fwrite( buf, 1, len, fp ); + if( out != len ) { + const char * err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; + fprintf( stderr, err, __FILE__, __LINE__, len, out ); abort(); } } } -void wrap(const char *fmt, ...) -{ +void wrap( const char * fmt, ... ) { char buf[10000]; - char *p, * start = buf; + char * p, * start = buf; int len; va_list args; - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); + va_start( args, fmt ); + vsprintf( buf, fmt, args ); + va_end( args ); - len = strlen(buf); + len = strlen( buf ); /* eliminate leading whitespace */ - while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { + while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ start++; len--; } @@ -161,26 +157,26 @@ void wrap(const char *fmt, ...) * 3rd condition: if exppp_linelength == indent2 and curpos > indent2, always newline * to use #3: temporarily change exppp_linelength; it doesn't make sense to change indent2 */ - if((((curpos + len) > exppp_linelength) && ((indent2 + len) < exppp_linelength)) - || ((exppp_linelength == indent2) && (curpos > indent2))) { + if( ( ( ( curpos + len ) > exppp_linelength ) && ( ( indent2 + len ) < exppp_linelength ) ) + || ( ( exppp_linelength == indent2 ) && ( curpos > indent2 ) ) ) { /* move to new continuation line */ char line[1000]; - sprintf(line, "\n%*s", indent2, ""); - exp_output(line, 1 + indent2); + sprintf( line, "\n%*s", indent2, "" ); + exp_output( line, 1 + indent2 ); curpos = indent2; /* reset current position */ } /* eliminate leading whitespace - again */ - while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { + while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ start++; len--; } - exp_output(start, len); + exp_output( start, len ); - if(len) { + if( len ) { /* reset cur position based on last newline seen */ - if(0 == (p = strrchr(start, '\n'))) { + if( 0 == ( p = strrchr( start, '\n' ) ) ) { curpos += len; } else { curpos = len + start - p; @@ -188,24 +184,23 @@ void wrap(const char *fmt, ...) } } -void raw(const char *fmt, ...) -{ - char *p; +void raw( const char * fmt, ... ) { + char * p; char buf[10000]; int len; va_list args; - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); + va_start( args, fmt ); + vsprintf( buf, fmt, args ); + va_end( args ); - len = strlen(buf); + len = strlen( buf ); - exp_output(buf, len); + exp_output( buf, len ); - if(len) { + if( len ) { /* reset cur position based on last newline seen */ - if(0 == (p = strrchr(buf, '\n'))) { + if( 0 == ( p = strrchr( buf, '\n' ) ) ) { curpos += len; } else { curpos = len + buf - p; @@ -213,21 +208,19 @@ void raw(const char *fmt, ...) } } -void exppp_init() -{ +void exppp_init() { static bool first_time = true; - if(!first_time) { + if( !first_time ) { return; } first_time = false; } -void exppp_ref_info(Symbol *s) -{ - if(exppp_reference_info) { - raw("--info %s %s %d\n", s->name, s->filename, s->line); +void exppp_ref_info( Symbol * s ) { + if( exppp_reference_info ) { + raw( "--info %s %s %d\n", s->name, s->filename, s->line ); } } @@ -237,21 +230,19 @@ void exppp_ref_info(Symbol *s) */ bool first_line = true; /* if first line */ -void first_newline() -{ - if(first_line) { +void first_newline() { + if( first_line ) { first_line = false; } else { - raw("\n"); + raw( "\n" ); } } -int minimum(int a, int b, int c) -{ - if(a < b) { - return ((a < c) ? a : c); +int minimum( int a, int b, int c ) { + if( a < b ) { + return ( ( a < c ) ? a : c ); } else { - return ((b < c) ? b : c); + return ( ( b < c ) ? b : c ); } } @@ -261,11 +252,10 @@ int minimum(int a, int b, int c) * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char *real2exp(double r) -{ -#define PP_SMALL_BUF_SZ 80 +const char * real2exp( double r ) { + #define PP_SMALL_BUF_SZ 80 static char result[PP_SMALL_BUF_SZ] = { 0 }; - char *pos = result, * lcNumeric = setlocale(LC_NUMERIC, NULL); + char * pos = result, * lcNumeric = setlocale( LC_NUMERIC, NULL ); /* the following ensures that PP_SMALL_BUF_SZ is at least * as big as the largest possible string: @@ -280,92 +270,89 @@ const char *real2exp(double r) * non-exotic platforms. */ unsigned int exponentDigits = 2, expMax = DBL_MAX_10_EXP; - while(expMax >= 10) { + while( expMax >= 10 ) { exponentDigits++; expMax /= 10; } - if(!((DBL_DIG + exponentDigits + 3) < PP_SMALL_BUF_SZ)) { - fprintf(stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__); + if( !( ( DBL_DIG + exponentDigits + 3 ) < PP_SMALL_BUF_SZ ) ) { + fprintf( stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__ ); abort(); } - if(strcmp("C", lcNumeric)) { - fprintf(stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, - "(are you calling exppp from Qt?). Incorrect formatting is possible.\n"); - setlocale(LC_NUMERIC, "C"); + if( strcmp( "C", lcNumeric ) ) { + fprintf( stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, + "(are you calling exppp from Qt?). Incorrect formatting is possible.\n" ); + setlocale( LC_NUMERIC, "C" ); } - snprintf(result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r); + snprintf( result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r ); /* eliminate trailing zeros in the mantissa */ - assert(strlen(result) < PP_SMALL_BUF_SZ - 1); - while((*pos != '.') && (*pos != '\0')) { + assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); + while( ( *pos != '.' ) && ( *pos != '\0' ) ) { /* search for '.' */ pos++; } - if(*pos != '\0') { - char *firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ + if( *pos != '\0' ) { + char * firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ pos++; - while(isdigit(*pos)) { - if((*pos == '0') && (firstUnnecessaryDigit == NULL)) { + while( isdigit( *pos ) ) { + if( ( *pos == '0' ) && ( firstUnnecessaryDigit == NULL ) ) { firstUnnecessaryDigit = pos; - } else if(*pos != '0') { + } else if( *pos != '0' ) { firstUnnecessaryDigit = NULL; } pos++; } - if((firstUnnecessaryDigit != NULL) && (firstUnnecessaryDigit < pos)) { - if((*(firstUnnecessaryDigit - 1) == '.') && (*pos == '\0')) { + if( ( firstUnnecessaryDigit != NULL ) && ( firstUnnecessaryDigit < pos ) ) { + if( ( *( firstUnnecessaryDigit - 1 ) == '.' ) && ( *pos == '\0' ) ) { /* no exponent, nothing after decimal point - remove decimal point */ - *(firstUnnecessaryDigit - 1) = '\0'; + *( firstUnnecessaryDigit - 1 ) = '\0'; } else { /* copy exponent (or \0) immediately after the decimal point */ - memmove(firstUnnecessaryDigit, pos, strlen(pos) + 1); + memmove( firstUnnecessaryDigit, pos, strlen( pos ) + 1 ); } } } - assert(strlen(result) < PP_SMALL_BUF_SZ - 1); + assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); return result; -#undef PP_SMALL_BUF_SZ + #undef PP_SMALL_BUF_SZ } /** Find next '.' in null-terminated string, return number of chars * If no '.' found, returns length of string */ -int nextBreakpoint(const char *pos, const char *end) -{ +int nextBreakpoint( const char * pos, const char * end ) { int i = 0; - while((*pos != '.') && (*pos != '\0') && (pos < end)) { + while( ( *pos != '.' ) && ( *pos != '\0' ) && ( pos < end ) ) { i++; pos++; } - if(*pos == '.') { + if( *pos == '.' ) { i++; } return i; } /** true if it makes sense to break before printing next part of the string */ -bool shouldBreak(int len) -{ - if((curpos > indent2) && - ((curpos + len) > exppp_linelength)) { +bool shouldBreak( int len ) { + if( ( curpos > indent2 ) && + ( ( curpos + len ) > exppp_linelength ) ) { return true; } return false; } /** Insert newline if it makes sense. */ -void maybeBreak(int len, bool first) -{ - if(shouldBreak(len)) { - if(first) { - raw("\n%*s'", indent2, ""); +void maybeBreak( int len, bool first ) { + if( shouldBreak( len ) ) { + if( first ) { + raw( "\n%*s'", indent2, "" ); } else { - raw("'\n%*s+ '", indent2, ""); + raw( "'\n%*s+ '", indent2, "" ); } - } else if(first) { + } else if( first ) { /* staying on same line */ - raw("%s", (printedSpaceLast ? "'" : " '")); + raw( "%s", ( printedSpaceLast ? "'": " '" ) ); } } @@ -376,29 +363,28 @@ void maybeBreak(int len, bool first) * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr(const char *in) -{ - const char *iptr = in, * end; - unsigned int inlen = strlen(in); +void breakLongStr( const char * in ) { + const char * iptr = in, * end; + unsigned int inlen = strlen( in ); bool first = true; /* used to ensure that we don't overrun the input buffer */ end = in + inlen; - if((inlen == 0) || (((int) inlen + curpos) < exppp_linelength)) { + if( ( inlen == 0 ) || ( ( ( int ) inlen + curpos ) < exppp_linelength ) ) { /* short enough to fit on current line */ - raw("%s'%s'", (printedSpaceLast ? "" : " "), in); + raw( "%s'%s'", ( printedSpaceLast ? "": " " ), in ); return; } /* insert newlines at dots as necessary */ - while((iptr < end) && (*iptr)) { - int i = nextBreakpoint(iptr, end); - maybeBreak(i, first); + while( ( iptr < end ) && ( *iptr ) ) { + int i = nextBreakpoint( iptr, end ); + maybeBreak( i, first ); first = false; - raw("%.*s", i, iptr); + raw( "%.*s", i, iptr ); iptr += i; } - raw("' "); + raw( "' "); } /* Interfacing Definitions */ @@ -410,11 +396,10 @@ static bool string_func_in_use = false; static bool file_func_in_use = false; /** return 0 if successful */ -int prep_buffer(char *buf, int len) -{ +int prep_buffer( char * buf, int len ) { /* this should never happen */ - if(string_func_in_use) { - fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); + if( string_func_in_use ) { + fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); return 1; } string_func_in_use = true; @@ -433,8 +418,7 @@ int prep_buffer(char *buf, int len) } /** \return length of string */ -int finish_buffer() -{ +int finish_buffer() { exppp_buf = 0; curpos = old_curpos; error_sym.line = old_lineno; @@ -443,18 +427,17 @@ int finish_buffer() } /** \return 0 if successful */ -int prep_string() -{ +int prep_string() { /* this should never happen */ - if(string_func_in_use) { - fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); + if( string_func_in_use ) { + fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); return 1; } string_func_in_use = true; - exppp_buf = exppp_bufp = (char *)sc_malloc(BIGBUFSIZ); - if(!exppp_buf) { - fprintf(stderr, "failed to allocate exppp buffer\n"); + exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ ); + if( !exppp_buf ) { + fprintf( stderr, "failed to allocate exppp buffer\n" ); return 1; } exppp_buflen = exppp_maxbuflen = BIGBUFSIZ; @@ -469,12 +452,11 @@ int prep_string() return 0; } -char *finish_string() -{ - char *b = (char *)sc_realloc(exppp_buf, 1 + exppp_maxbuflen - exppp_buflen); +char * finish_string() { + char * b = ( char * )sc_realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); - if(b == 0) { - fprintf(stderr, "failed to reallocate exppp buffer\n"); + if( b == 0 ) { + fprintf( stderr, "failed to reallocate exppp buffer\n" ); return 0; } exppp_buf = 0; @@ -485,14 +467,13 @@ char *finish_string() return b; } -static FILE *oldfp; +static FILE * oldfp; -void prep_file() -{ +void prep_file() { /* this can only happen if user calls output func while suspended */ /* inside another output func both called from debugger */ - if(file_func_in_use) { - fprintf(stderr, "cannot print EXPRESS representations recursively!\n"); + if( file_func_in_use ) { + fprintf( stderr, "cannot print EXPRESS representations recursively!\n" ); } file_func_in_use = true; @@ -503,13 +484,12 @@ void prep_file() curpos = 1; } -void finish_file() -{ +void finish_file() { exppp_fp = oldfp; /* reset back to original file */ file_func_in_use = false; } -char *placeholder = "placeholder"; +char * placeholder = "placeholder"; diff --git a/src/exppp/pp.h b/src/exppp/pp.h index e2bfad19b..89825de6a 100644 --- a/src/exppp/pp.h +++ b/src/exppp/pp.h @@ -13,19 +13,19 @@ extern const int NOLEVEL; /**< unused-level indicator */ extern Symbol error_sym; /**< only used when printing errors */ extern Error ERROR_select_empty; -extern FILE *exppp_fp; +extern FILE * exppp_fp; extern bool first_line; /** output a string, exactly as provided * \sa wrap() */ -void raw(const char *fmt, ...); +void raw( const char * fmt, ... ); /** output a string, insert newlines to keep line length down * TODO list globals this func uses * \sa raw() */ -void wrap(const char *fmt, ...); +void wrap( const char * fmt, ... ); /** convert a real into our preferred form compatible with 10303-11 * (i.e. decimal point is required; no trailing zeros) @@ -33,7 +33,7 @@ void wrap(const char *fmt, ...); * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char *real2exp(double r); +const char * real2exp( double r ); /** Break a long un-encoded string up, enclose in '', output via raw() * if short, don't insert line breaks @@ -42,21 +42,21 @@ const char *real2exp(double r); * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr(const char *in); +void breakLongStr( const char * in ); int finish_buffer(); -int minimum(int a, int b, int c); -int prep_buffer(char *buf, int len); +int minimum( int a, int b, int c ); +int prep_buffer( char * buf, int len ); int prep_string(); void finish_file(); void first_newline(); void prep_file(); -char *finish_string(); -const char *real2exp(double r); -void exp_output(char *buf, unsigned int len); +char * finish_string(); +const char * real2exp( double r ); +void exp_output( char * buf, unsigned int len ); void exppp_init(); -void exppp_ref_info(Symbol *s); -extern char *placeholder; +void exppp_ref_info( Symbol * s ); +extern char * placeholder; #endif /* PP_H */ diff --git a/src/exppp/pretty_alg.c b/src/exppp/pretty_alg.c index 3899b8492..ba8a07aa5 100644 --- a/src/exppp/pretty_alg.c +++ b/src/exppp/pretty_alg.c @@ -13,19 +13,17 @@ #include "pretty_scope.h" #include "pretty_alg.h" -void ALGscope_out(Scope s, int level) -{ - SCOPEtypes_out(s, level); - SCOPEentities_out(s, level); - SCOPEalgs_out(s, level); - - SCOPEconsts_out(s, level); - SCOPElocals_out(s, level); +void ALGscope_out( Scope s, int level ) { + SCOPEtypes_out( s, level ); + SCOPEentities_out( s, level ); + SCOPEalgs_out( s, level ); + + SCOPEconsts_out( s, level ); + SCOPElocals_out( s, level ); } /** last arg is not terminated with ; or \n */ -void ALGargs_out(Linked_List args, int level) -{ +void ALGargs_out( Linked_List args, int level ) { Type previoustype = 0; bool previousVAR = false; indent2 = level + exppp_continuation_indent; @@ -37,27 +35,26 @@ void ALGargs_out(Linked_List args, int level) * flags.var is set in the formal_parameter production */ - LISTdo(args, v, Variable) { - if((previoustype != v->type) || (previousVAR != v->flags.var)) { - if(previoustype) { - wrap(" : "); - TYPE_head_out(previoustype, NOLEVEL); - raw(";\n"); + LISTdo( args, v, Variable ) { + if( ( previoustype != v->type ) || ( previousVAR != v->flags.var ) ) { + if( previoustype ) { + wrap( " : " ); + TYPE_head_out( previoustype, NOLEVEL ); + raw( ";\n" ); } - raw("%*s", level, ""); - if(v->flags.var) { - raw("VAR "); + raw( "%*s", level, "" ); + if( v->flags.var ) { + raw( "VAR " ); } - EXPR_out(VARget_name(v), 0); + EXPR_out( VARget_name( v ), 0 ); } else { - raw(", "); - EXPR_out(VARget_name(v), 0); + raw( ", " ); + EXPR_out( VARget_name( v ), 0 ); } previoustype = v->type; previousVAR = v->flags.var; - } - LISTod + } LISTod - wrap(" : "); - TYPE_head_out(previoustype, NOLEVEL); + wrap( " : " ); + TYPE_head_out( previoustype, NOLEVEL ); } diff --git a/src/exppp/pretty_alg.h b/src/exppp/pretty_alg.h index ab0c5f566..a365da9fc 100644 --- a/src/exppp/pretty_alg.h +++ b/src/exppp/pretty_alg.h @@ -4,7 +4,7 @@ #include #include -void ALGargs_out(Linked_List args, int level); -void ALGscope_out(Scope s, int level); +void ALGargs_out( Linked_List args, int level ); +void ALGscope_out( Scope s, int level ); #endif /* PRETTY_ALG_H */ diff --git a/src/exppp/pretty_case.c b/src/exppp/pretty_case.c index 086ab53a9..82a9f2772 100644 --- a/src/exppp/pretty_case.c +++ b/src/exppp/pretty_case.c @@ -10,66 +10,61 @@ #include "pretty_stmt.h" #include "pretty_case.h" -void CASEout(struct Case_Statement_ * c, int level) -{ +void CASEout( struct Case_Statement_ * c, int level ) { int len = 0, max_indent = 0, old_curpos = 0; - raw("%*sCASE ", level, ""); - EXPR_out(c->selector, 0); - wrap(" OF\n"); + raw( "%*sCASE ", level, "" ); + EXPR_out( c->selector, 0 ); + wrap( " OF\n" ); /* EXPRlength messes up curpos */ old_curpos = curpos; /* pass 1: calculate length of longest label */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { - len = EXPRlength(label); - } - LISTod + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { + len = EXPRlength( label ); + } LISTod } else { - len = strlen("OTHERWISE"); + len = strlen( "OTHERWISE" ); } - if(len > max_indent) { + if( len > max_indent ) { max_indent = len; } - } - LISTod + } LISTod curpos = old_curpos; level += exppp_nesting_indent; - if(max_indent + level > exppp_linelength / 2) { - max_indent = (exppp_linelength / 3) - level; + if( max_indent + level > exppp_linelength / 2 ) { + max_indent = ( exppp_linelength / 3 ) - level; } /* pass 2: print them */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { int spaces; /* print label(s) */ indent2 = level + exppp_continuation_indent; - raw("%*s", level, ""); - EXPR_out(label, 0); + raw( "%*s", level, "" ); + EXPR_out( label, 0 ); spaces = level + max_indent - curpos; - raw("%*s : ", ((spaces > 0) ? spaces : 0), ""); + raw( "%*s : ", ( ( spaces > 0 ) ? spaces : 0 ), "" ); /* print action */ - STMT_out(ci->action, level + exppp_nesting_indent); - } - LISTod + STMT_out( ci->action, level + exppp_nesting_indent ); + } LISTod } else { /* print OTHERWISE */ indent2 = level + exppp_continuation_indent; - raw("%*s", level, ""); - raw("OTHERWISE"); - raw("%*s : ", level + max_indent - curpos, ""); + raw( "%*s", level, "" ); + raw( "OTHERWISE" ); + raw( "%*s : ", level + max_indent - curpos, "" ); /* print action */ - STMT_out(ci->action, level + exppp_nesting_indent); + STMT_out( ci->action, level + exppp_nesting_indent ); } - } - LISTod + } LISTod - raw("%*sEND_CASE;\n", level, ""); + raw( "%*sEND_CASE;\n", level, "" ); } diff --git a/src/exppp/pretty_case.h b/src/exppp/pretty_case.h index 1028e0bf5..de46f417f 100644 --- a/src/exppp/pretty_case.h +++ b/src/exppp/pretty_case.h @@ -3,6 +3,6 @@ #include -void CASEout(struct Case_Statement_ * c, int level); +void CASEout( struct Case_Statement_ * c, int level ); #endif /* PRETTY_CASE_H */ diff --git a/src/exppp/pretty_entity.c b/src/exppp/pretty_entity.c index 248294bab..73d167bba 100644 --- a/src/exppp/pretty_entity.c +++ b/src/exppp/pretty_entity.c @@ -14,258 +14,244 @@ #include "pretty_type.h" #include "pretty_entity.h" -void ENTITY_out(Entity e, int level) -{ +void ENTITY_out( Entity e, int level ) { const unsigned int EXPLICIT = 0, DERIVED = 1; int linelen = exppp_linelength; bool first_time = true; first_newline(); - exppp_ref_info(&e->symbol); + exppp_ref_info( &e->symbol ); - raw("%*sENTITY %s", level, "", e->symbol.name); + raw( "%*sENTITY %s", level, "", e->symbol.name ); level += exppp_nesting_indent; indent2 = level + exppp_continuation_indent; exppp_linelength = indent2; /* force newlines */ - if(ENTITYget_abstract(e)) { - if(e->u.entity->subtype_expression) { - raw("\n%*sABSTRACT SUPERTYPE OF ", level, ""); - SUBTYPEout(e->u.entity->subtype_expression); + if( ENTITYget_abstract( e ) ) { + if( e->u.entity->subtype_expression ) { + raw( "\n%*sABSTRACT SUPERTYPE OF ", level, "" ); + SUBTYPEout( e->u.entity->subtype_expression ); } else { - raw("\n%*sABSTRACT SUPERTYPE", level, ""); + raw( "\n%*sABSTRACT SUPERTYPE", level, "" ); } } else { - if(e->u.entity->subtype_expression) { - raw("\n%*sSUPERTYPE OF ", level, ""); - SUBTYPEout(e->u.entity->subtype_expression); + if( e->u.entity->subtype_expression ) { + raw( "\n%*sSUPERTYPE OF ", level, "" ); + SUBTYPEout( e->u.entity->subtype_expression ); } } exppp_linelength = linelen; - if(e->u.entity->supertype_symbols) { - raw("\n%*sSUBTYPE OF ( ", level, ""); + if( e->u.entity->supertype_symbols ) { + raw( "\n%*sSUBTYPE OF ( ", level, "" ); - LISTdo(e->u.entity->supertype_symbols, s, Symbol *) - if(first_time) { + LISTdo( e->u.entity->supertype_symbols, s, Symbol * ) + if( first_time ) { first_time = false; } else { - raw(", "); + raw( ", " ); } - wrap(s->name); + wrap( s->name ); LISTod - raw(" )"); + raw( " )" ); } - raw(";\n"); + raw( ";\n" ); #if 0 /* add a little more space before entities if sub or super appears */ - if(e->u.entity->supertype_symbols || e->u.entity->subtype_expression) { - raw("\n"); + if( e->u.entity->supertype_symbols || e->u.entity->subtype_expression ) { + raw( "\n" ); } #endif - ENTITYattrs_out(e->u.entity->attributes, EXPLICIT, level); - ENTITYattrs_out(e->u.entity->attributes, DERIVED, level); - ENTITYinverse_out(e->u.entity->attributes, level); - ENTITYunique_out(e->u.entity->unique, level); - WHERE_out(TYPEget_where(e), level); + ENTITYattrs_out( e->u.entity->attributes, EXPLICIT, level ); + ENTITYattrs_out( e->u.entity->attributes, DERIVED, level ); + ENTITYinverse_out( e->u.entity->attributes, level ); + ENTITYunique_out( e->u.entity->unique, level ); + WHERE_out( TYPEget_where( e ), level ); level -= exppp_nesting_indent; - raw("%*sEND_ENTITY;", level, ""); - tail_comment(e->symbol.name); + raw( "%*sEND_ENTITY;", level, "" ); + tail_comment( e->symbol.name ); } -void ENTITYunique_out(Linked_List u, int level) -{ +void ENTITYunique_out( Linked_List u, int level ) { int i; int max_indent; - Symbol *sym; + Symbol * sym; - if(!u) { + if( !u ) { return; } - raw("%*sUNIQUE\n", level, ""); + raw( "%*sUNIQUE\n", level, "" ); /* pass 1 */ max_indent = 0; - LISTdo(u, list, Linked_List) { - if(0 != (sym = (Symbol *)LISTget_first(list))) { + LISTdo( u, list, Linked_List ) { + if( 0 != ( sym = ( Symbol * )LISTget_first( list ) ) ) { int length; - length = strlen(sym->name); - if(length > max_indent) { + length = strlen( sym->name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod level += exppp_nesting_indent; - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; - LISTdo(u, list, Linked_List) { + LISTdo( u, list, Linked_List ) { i = 0; - LISTdo_n(list, e, Expression, b) { + LISTdo_n( list, e, Expression, b ) { i++; - if(i == 1) { + if( i == 1 ) { /* print label if present */ - if(e) { - raw("%*s%-*s : ", level, "", max_indent, ((Symbol *)e)->name); + if( e ) { + raw( "%*s%-*s : ", level, "", max_indent, ( ( Symbol * )e )->name ); } else { - raw("%*s%-*s ", level, "", max_indent, ""); + raw( "%*s%-*s ", level, "", max_indent, "" ); } } else { - if(i > 2) { - raw(", "); + if( i > 2 ) { + raw( ", " ); } - EXPR_out(e, 0); + EXPR_out( e, 0 ); } - } - LISTod - raw(";\n"); - } - LISTod + } LISTod + raw( ";\n" ); + } LISTod } -void ENTITYinverse_out(Linked_List attrs, int level) -{ +void ENTITYinverse_out( Linked_List attrs, int level ) { int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { int length; - length = strlen(v->name->symbol.name); - if(length > max_indent) { + length = strlen( v->name->symbol.name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod - if(max_indent == 0) { + if( max_indent == 0 ) { return; } - raw("%*sINVERSE\n", level, ""); + raw( "%*sINVERSE\n", level, "" ); level += exppp_nesting_indent; - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: print them */ - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { /* print attribute name */ - raw("%*s", level, ""); - EXPR_out(v->name, 0); - raw("%-*s :", (((max_indent - curpos) > 0) ? max_indent - curpos : 0), ""); + raw( "%*s", level, "" ); + EXPR_out( v->name, 0 ); + raw( "%-*s :", ( ( ( max_indent - curpos ) > 0 ) ? max_indent - curpos : 0 ), "" ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); - raw(" FOR "); + raw( " FOR " ); - wrap(v->inverse_attribute->name->symbol.name); + wrap( v->inverse_attribute->name->symbol.name ); - raw(";\n"); + raw( ";\n" ); } - } - LISTod + } LISTod } -void ENTITYattrs_out(Linked_List attrs, int derived, int level) -{ +void ENTITYattrs_out( Linked_List attrs, int derived, int level ) { int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { continue; } - if((derived && v->initializer) || - (!derived && !v->initializer)) { + if( ( derived && v->initializer ) || + ( !derived && !v->initializer ) ) { int length; - length = EXPRlength(v->name); - if(length > max_indent) { + length = EXPRlength( v->name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod - if(max_indent == 0) { + if( max_indent == 0 ) { return; } - if(derived) { - raw("%*sDERIVE\n", level, ""); + if( derived ) { + raw( "%*sDERIVE\n", level, "" ); } level += exppp_nesting_indent; - if(level + max_indent > exppp_linelength / 3) { - max_indent = (exppp_linelength / 3) - level; + if( level + max_indent > exppp_linelength / 3 ) { + max_indent = ( exppp_linelength / 3 ) - level; } - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: print them */ - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { continue; } - if((derived && v->initializer) || (!derived && !v->initializer)) { + if( ( derived && v->initializer ) || ( !derived && !v->initializer ) ) { int spaces; /* print attribute name */ - raw("%*s", level, ""); - EXPR_out(v->name, 0); + raw( "%*s", level, "" ); + EXPR_out( v->name, 0 ); spaces = level + max_indent + 2 - curpos; - if(spaces < 0) { + if( spaces < 0 ) { spaces = 0; } - raw("%*s :", spaces, ""); + raw( "%*s :", spaces, "" ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); - if(derived && v->initializer) { - wrap(" := "); - EXPR_out(v->initializer, 0); + if( derived && v->initializer ) { + wrap( " := " ); + EXPR_out( v->initializer, 0 ); } - raw(";\n"); + raw( ";\n" ); } - } - LISTod + } LISTod } -char *ENTITYto_string(Entity e) -{ - if(prep_string()) { +char * ENTITYto_string( Entity e ) { + if( prep_string() ) { return placeholder; } - ENTITY_out(e, 0); - return (finish_string()); + ENTITY_out( e, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int ENTITYto_buffer(Entity e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int ENTITYto_buffer( Entity e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - ENTITY_out(e, 0); - return(finish_buffer()); + ENTITY_out( e, 0 ); + return( finish_buffer() ); } -void ENTITYout(Entity e) -{ +void ENTITYout( Entity e ) { prep_file(); - ENTITY_out(e, 0); + ENTITY_out( e, 0 ); finish_file(); } diff --git a/src/exppp/pretty_entity.h b/src/exppp/pretty_entity.h index 9b21e27c3..7c54ae446 100644 --- a/src/exppp/pretty_entity.h +++ b/src/exppp/pretty_entity.h @@ -7,13 +7,13 @@ #include "pp.h" -char *ENTITYto_string(Entity e); -void ENTITY_out(Entity e, int level); -void ENTITYattrs_out(Linked_List attrs, int derived, int level); -void ENTITYinverse_out(Linked_List attrs, int level); -void ENTITYout(Entity e); -int ENTITYto_buffer(Entity e, char *buffer, int length); -void ENTITYunique_out(Linked_List u, int level); +char * ENTITYto_string( Entity e ); +void ENTITY_out( Entity e, int level ); +void ENTITYattrs_out( Linked_List attrs, int derived, int level ); +void ENTITYinverse_out( Linked_List attrs, int level ); +void ENTITYout( Entity e ); +int ENTITYto_buffer( Entity e, char * buffer, int length ); +void ENTITYunique_out( Linked_List u, int level ); #endif /* PRETTY_ENTITY_H */ diff --git a/src/exppp/pretty_expr.c b/src/exppp/pretty_expr.c index 2fb2f023a..60a1c2ded 100644 --- a/src/exppp/pretty_expr.c +++ b/src/exppp/pretty_expr.c @@ -14,17 +14,16 @@ /** print array bounds */ -void EXPRbounds_out(TypeBody tb) -{ - if(!tb->upper) { +void EXPRbounds_out( TypeBody tb ) { + if( !tb->upper ) { return; } - wrap(" ["); - EXPR_out(tb->lower, 0); - wrap(" : "); - EXPR_out(tb->upper, 0); - raw("]"); + wrap( " [" ); + EXPR_out( tb->lower, 0 ); + wrap( " : " ); + EXPR_out( tb->upper, 0 ); + raw( "]" ); } /** @@ -33,138 +32,135 @@ void EXPRbounds_out(TypeBody tb) * precedence/associativity is not a problem) parens may be omitted. * if paren == 0, then parens may be omitted without consequence */ -void EXPR__out(Expression e, int paren, unsigned int previous_op) -{ +void EXPR__out( Expression e, int paren, unsigned int previous_op ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - wrap("?"); + if( e == LITERAL_INFINITY ) { + wrap( "?" ); } else { - wrap("%d", e->u.integer); + wrap( "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - wrap("PI"); - } else if(e == LITERAL_E) { - wrap("E"); + if( e == LITERAL_PI ) { + wrap( "PI" ); + } else if( e == LITERAL_E ) { + wrap( "E" ); } else { - wrap(real2exp(e->u.real)); + wrap( real2exp( e->u.real ) ); } break; case binary_: - wrap("%%%s", e->u.binary); /* put "%" back */ + wrap( "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - wrap("TRUE"); + wrap( "TRUE" ); break; case Lfalse: - wrap("FALSE"); + wrap( "FALSE" ); break; default: - wrap("UNKNOWN"); + wrap( "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - wrap("\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + wrap( "\"%s\"", e->symbol.name ); } else { - breakLongStr(e->symbol.name); + breakLongStr( e->symbol.name ); } break; case entity_: case identifier_: case attribute_: case enumeration_: - wrap("%s", e->symbol.name); + wrap( "%s", e->symbol.name ); break; case query_: - wrap("QUERY ( %s <* ", e->u.query->local->name->symbol.name); - EXPR_out(e->u.query->aggregate, 1); - wrap(" | "); - EXPR_out(e->u.query->expression, 1); - raw(" )"); + wrap( "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); + EXPR_out( e->u.query->aggregate, 1 ); + wrap( " | " ); + EXPR_out( e->u.query->expression, 1 ); + raw( " )" ); break; case self_: - wrap("SELF"); + wrap( "SELF" ); break; case funcall_: - wrap("%s( ", e->symbol.name); + wrap( "%s( ", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - EXPR_out(arg, 0); + EXPR_out( arg, 0 ); LISTod - raw(" )"); + raw( " )" ); break; case op_: - EXPRop__out(&e->e, paren, previous_op); + EXPRop__out( &e->e, paren, previous_op ); break; case aggregate_: - wrap("["); + wrap( "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if(i != 1) { - if(repeat) { - raw(" : "); + if( i != 1 ) { + if( repeat ) { + raw( " : " ); } else { - raw(", "); + raw( ", " ); } } - EXPR_out(arg, 0); - } - LISTod - raw("]"); + EXPR_out( arg, 0 ); + } LISTod + raw( "]" ); break; case oneof_: { int old_indent = indent2; - wrap("ONEOF ( "); + wrap( "ONEOF ( " ); - if(exppp_linelength == indent2) { + if( exppp_linelength == indent2 ) { exppp_linelength += exppp_continuation_indent; } indent2 += exppp_continuation_indent; i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - EXPR_out(arg, 1); + EXPR_out( arg, 1 ); LISTod - if(exppp_linelength == indent2) { + if( exppp_linelength == indent2 ) { exppp_linelength = old_indent; } indent2 = old_indent; - raw(" )"); + raw( " )" ); break; } default: - fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); + fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); abort(); } } /** print expression that has op and operands */ -void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op) -{ +void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ) { const unsigned int PAD = 1, NOPAD = 0; - switch(oe->op_code) { + switch( oe->op_code ) { case OP_AND: case OP_ANDOR: case OP_OR: @@ -173,7 +169,7 @@ void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_o case OP_PLUS: case OP_TIMES: case OP_XOR: - EXPRop2__out(oe, (char *)0, paren, PAD, previous_op); + EXPRop2__out( oe, ( char * )0, paren, PAD, previous_op ); break; case OP_EXP: case OP_GREATER_EQUAL: @@ -186,91 +182,88 @@ void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_o case OP_LIKE: case OP_MOD: case OP_NOT_EQUAL: - EXPRop2_out(oe, (char *)0, paren, PAD); + EXPRop2_out( oe, ( char * )0, paren, PAD ); break; case OP_NOT: - EXPRop1_out(oe, "NOT ", paren); + EXPRop1_out( oe, "NOT ", paren ); break; case OP_REAL_DIV: - EXPRop2_out(oe, "/", paren, PAD); + EXPRop2_out( oe, "/", paren, PAD ); break; case OP_DIV: - EXPRop2_out(oe, "DIV", paren, PAD); + EXPRop2_out( oe, "DIV", paren, PAD ); break; case OP_MINUS: - EXPRop2_out(oe, "-", paren, PAD); + EXPRop2_out( oe, "-", paren, PAD ); break; case OP_DOT: - EXPRop2_out(oe, ".", paren, NOPAD); + EXPRop2_out( oe, ".", paren, NOPAD ); break; case OP_GROUP: - EXPRop2_out(oe, "\\", paren, NOPAD); + EXPRop2_out( oe, "\\", paren, NOPAD ); break; case OP_NEGATE: - EXPRop1_out(oe, "-", paren); + EXPRop1_out( oe, "-", paren ); break; case OP_ARRAY_ELEMENT: - EXPR_out(oe->op1, 1); - wrap("["); - EXPR_out(oe->op2, 0); - raw("]"); + EXPR_out( oe->op1, 1 ); + wrap( "[" ); + EXPR_out( oe->op2, 0 ); + raw( "]" ); break; case OP_SUBCOMPONENT: - EXPR_out(oe->op1, 1); - wrap("["); - EXPR_out(oe->op2, 0); - wrap(" : "); - EXPR_out(oe->op3, 0); - raw("]"); + EXPR_out( oe->op1, 1 ); + wrap( "[" ); + EXPR_out( oe->op2, 0 ); + wrap( " : " ); + EXPR_out( oe->op3, 0 ); + raw( "]" ); break; default: - wrap("(* unknown op-expression *)"); + wrap( "(* unknown op-expression *)" ); } } -void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op) -{ - if(pad && paren && (eo->op_code != previous_op)) { - wrap("( "); +void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + wrap( "( " ); } - EXPR__out(eo->op1, 1, eo->op_code); - if(pad) { - raw(" "); + EXPR__out( eo->op1, 1, eo->op_code ); + if( pad ) { + raw( " " ); } - wrap("%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - wrap(" "); + wrap( "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + wrap( " " ); } - EXPR__out(eo->op2, 1, eo->op_code); - if(pad && paren && (eo->op_code != previous_op)) { - raw(" )"); + EXPR__out( eo->op2, 1, eo->op_code ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + raw( " )" ); } } /** Print out a one-operand operation. If there were more than two of these * I'd generalize it to do padding, but it's not worth it. */ -void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren) -{ - if(paren) { - wrap("( "); +void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ) { + if( paren ) { + wrap( "( " ); } - wrap("%s", opcode); - EXPR_out(eo->op1, 1); - if(paren) { - raw(" )"); + wrap( "%s", opcode ); + EXPR_out( eo->op1, 1 ); + if( paren ) { + raw( " )" ); } } -int EXPRop_length(struct Op_Subexpression *oe) -{ - switch(oe->op_code) { +int EXPRop_length( struct Op_Subexpression * oe ) { + switch( oe->op_code ) { case OP_DOT: case OP_GROUP: - return(1 + EXPRlength(oe->op1) - + EXPRlength(oe->op2)); + return( 1 + EXPRlength( oe->op1 ) + + EXPRlength( oe->op2 ) ); default: - fprintf(stdout, "EXPRop_length: unknown op-expression"); + fprintf( stdout, "EXPRop_length: unknown op-expression" ); } return 0; } @@ -280,173 +273,165 @@ int EXPRop_length(struct Op_Subexpression *oe) * any kind of expression * contains fragment of string, adds to it */ -void EXPRstring(char *buffer, Expression e) -{ +void EXPRstring( char * buffer, Expression e ) { int i; - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - strcpy(buffer, "?"); + if( e == LITERAL_INFINITY ) { + strcpy( buffer, "?" ); } else { - sprintf(buffer, "%d", e->u.integer); + sprintf( buffer, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - strcpy(buffer, "PI"); - } else if(e == LITERAL_E) { - strcpy(buffer, "E"); + if( e == LITERAL_PI ) { + strcpy( buffer, "PI" ); + } else if( e == LITERAL_E ) { + strcpy( buffer, "E" ); } else { - sprintf(buffer, "%s", real2exp(e->u.real)); + sprintf( buffer, "%s", real2exp( e->u.real ) ); } break; case binary_: - sprintf(buffer, "%%%s", e->u.binary); /* put "%" back */ + sprintf( buffer, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buffer, "TRUE"); + strcpy( buffer, "TRUE" ); break; case Lfalse: - strcpy(buffer, "FALSE"); + strcpy( buffer, "FALSE" ); break; default: - strcpy(buffer, "UNKNOWN"); + strcpy( buffer, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - sprintf(buffer, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + sprintf( buffer, "\"%s\"", e->symbol.name ); } else { - sprintf(buffer, "%s", e->symbol.name); + sprintf( buffer, "%s", e->symbol.name ); } break; case entity_: case identifier_: case attribute_: case enumeration_: - strcpy(buffer, e->symbol.name); + strcpy( buffer, e->symbol.name ); break; case query_: - sprintf(buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name); - EXPRstring(buffer + strlen(buffer), e->u.query->aggregate); - strcat(buffer, " | "); - EXPRstring(buffer + strlen(buffer), e->u.query->expression); - strcat(buffer, " )"); + sprintf( buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); + EXPRstring( buffer + strlen( buffer ), e->u.query->aggregate ); + strcat( buffer, " | " ); + EXPRstring( buffer + strlen( buffer ), e->u.query->expression ); + strcat( buffer, " )" ); break; case self_: - strcpy(buffer, "SELF"); + strcpy( buffer, "SELF" ); break; case funcall_: - sprintf(buffer, "%s( ", e->symbol.name); + sprintf( buffer, "%s( ", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - strcat(buffer, ", "); + if( i != 1 ) { + strcat( buffer, ", " ); } - EXPRstring(buffer + strlen(buffer), arg); + EXPRstring( buffer + strlen( buffer ), arg ); LISTod - strcat(buffer, " )"); + strcat( buffer, " )" ); break; case op_: - EXPRop_string(buffer, &e->e); + EXPRop_string( buffer, &e->e ); break; case aggregate_: - strcpy(buffer, "["); + strcpy( buffer, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if(i != 1) { - if(repeat) { - strcat(buffer, " : "); + if( i != 1 ) { + if( repeat ) { + strcat( buffer, " : " ); } else { - strcat(buffer, ", "); + strcat( buffer, ", " ); } } - EXPRstring(buffer + strlen(buffer), arg); - } - LISTod - strcat(buffer, "]"); + EXPRstring( buffer + strlen( buffer ), arg ); + } LISTod + strcat( buffer, "]" ); break; case oneof_: - strcpy(buffer, "ONEOF ( "); + strcpy( buffer, "ONEOF ( " ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { i++; - if(i != 1) { - strcat(buffer, ", "); + if( i != 1 ) { + strcat( buffer, ", " ); } - EXPRstring(buffer + strlen(buffer), arg); - } - LISTod + EXPRstring( buffer + strlen( buffer ), arg ); + } LISTod - strcat(buffer, " )"); + strcat( buffer, " )" ); break; default: - sprintf(buffer, "EXPRstring: unknown expression, type %d", TYPEis(e->type)); - fprintf(stderr, "%s", buffer); + sprintf( buffer, "EXPRstring: unknown expression, type %d", TYPEis( e->type ) ); + fprintf( stderr, "%s", buffer ); } } -void EXPRop_string(char *buffer, struct Op_Subexpression *oe) -{ - EXPRstring(buffer, oe->op1); - switch(oe->op_code) { +void EXPRop_string( char * buffer, struct Op_Subexpression * oe ) { + EXPRstring( buffer, oe->op1 ); + switch( oe->op_code ) { case OP_DOT: - strcat(buffer, "."); + strcat( buffer, "." ); break; case OP_GROUP: - strcat(buffer, "\\"); + strcat( buffer, "\\" ); break; default: - strcat(buffer, "(* unknown op-expression *)"); + strcat( buffer, "(* unknown op-expression *)" ); } - EXPRstring(buffer + strlen(buffer), oe->op2); + EXPRstring( buffer + strlen( buffer ), oe->op2 ); } /** returns length of printable representation of expression w.o. printing it * doesn't understand as many expressions as the printing functions (!) * WARNING this *does* change the global 'curpos'! */ -int EXPRlength(Expression e) -{ +int EXPRlength( Expression e ) { char buffer[10000]; *buffer = '\0'; - EXPRstring(buffer, e); - return(strlen(buffer)); + EXPRstring( buffer, e ); + return( strlen( buffer ) ); } -char *EXPRto_string(Expression e) -{ - if(prep_string()) { +char * EXPRto_string( Expression e ) { + if( prep_string() ) { return placeholder; } - EXPR_out(e, 0); - return (finish_string()); + EXPR_out( e, 0 ); + return ( finish_string() ); } /** \return length of buffer used */ -int EXPRto_buffer(Expression e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int EXPRto_buffer( Expression e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - EXPR_out(e, 0); - return(finish_buffer()); + EXPR_out( e, 0 ); + return( finish_buffer() ); } -void EXPRout(Expression e) -{ +void EXPRout( Expression e ) { prep_file(); - EXPR_out(e, 0); + EXPR_out( e, 0 ); finish_file(); } diff --git a/src/exppp/pretty_expr.h b/src/exppp/pretty_expr.h index 39f9ce989..633bdf3f1 100644 --- a/src/exppp/pretty_expr.h +++ b/src/exppp/pretty_expr.h @@ -10,13 +10,13 @@ EXPRop2__out(oe,string,paren,pad,OP_UNKNOWN) #define EXPRop_out(oe,paren) EXPRop__out(oe,paren,OP_UNKNOWN) -void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op); -void EXPRop_string(char *buffer, struct Op_Subexpression *oe); -void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren); -void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op); -void EXPR__out(Expression e, int paren, unsigned int previous_op); -void EXPRbounds_out(TypeBody tb); -int EXPRlength(Expression e); +void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ); +void EXPRop_string( char * buffer, struct Op_Subexpression * oe ); +void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ); +void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ); +void EXPR__out( Expression e, int paren, unsigned int previous_op ); +void EXPRbounds_out( TypeBody tb ); +int EXPRlength( Expression e ); #endif /* PRETTY_EXPR_H */ diff --git a/src/exppp/pretty_express.c b/src/exppp/pretty_express.c index 911567126..610d5e938 100644 --- a/src/exppp/pretty_express.c +++ b/src/exppp/pretty_express.c @@ -9,15 +9,14 @@ #include "pretty_schema.h" #include "pretty_express.h" -void EXPRESSout(Express e) -{ +void EXPRESSout( Express e ) { Schema s; DictionaryEntry de; exppp_init(); - DICTdo_init(e->symbol_table, &de); - while(0 != (s = (Schema)DICTdo(&de))) { - (void) SCHEMAout(s); + DICTdo_init( e->symbol_table, &de ); + while( 0 != ( s = ( Schema )DICTdo( &de ) ) ) { + ( void ) SCHEMAout( s ); } } diff --git a/src/exppp/pretty_express.h b/src/exppp/pretty_express.h index 7ab337f4a..18d7e1296 100644 --- a/src/exppp/pretty_express.h +++ b/src/exppp/pretty_express.h @@ -1,6 +1,6 @@ #ifndef PRETTY_EXPRESS_H #define PRETTY_EXPRESS_H -void EXPRESSout(Express e); +void EXPRESSout( Express e ); #endif /* PRETTY_EXPRESS_H */ diff --git a/src/exppp/pretty_func.c b/src/exppp/pretty_func.c index f07f5291e..4129d7855 100644 --- a/src/exppp/pretty_func.c +++ b/src/exppp/pretty_func.c @@ -9,58 +9,54 @@ #include "pretty_stmt.h" #include "pretty_func.h" -void FUNC_out(Function fn, int level) -{ - if(fn->u.func->builtin) { +void FUNC_out( Function fn, int level ) { + if( fn->u.func->builtin ) { return; } first_newline(); - exppp_ref_info(&fn->symbol); - - raw("%*sFUNCTION %s", level, "", fn->symbol.name); - if(fn->u.func->parameters) { - unsigned int param_indent = level + strlen("FUNCTION "); - raw("(\n"); - ALGargs_out(fn->u.func->parameters, param_indent); - raw("\n%*s)", param_indent - exppp_continuation_indent, ""); + exppp_ref_info( &fn->symbol ); + + raw( "%*sFUNCTION %s", level, "", fn->symbol.name ); + if( fn->u.func->parameters ) { + unsigned int param_indent = level + strlen( "FUNCTION " ); + raw( "(\n" ); + ALGargs_out( fn->u.func->parameters, param_indent ); + raw( "\n%*s)", param_indent - exppp_continuation_indent, "" ); } - raw(" :"); + raw( " :" ); indent2 = curpos + exppp_continuation_indent; - TYPE_head_out(fn->u.func->return_type, NOLEVEL); - raw(";\n"); + TYPE_head_out( fn->u.func->return_type, NOLEVEL ); + raw( ";\n" ); - ALGscope_out(fn, level + exppp_nesting_indent); - STMTlist_out(fn->u.proc->body, level + exppp_nesting_indent); + ALGscope_out( fn, level + exppp_nesting_indent ); + STMTlist_out( fn->u.proc->body, level + exppp_nesting_indent ); - raw("\n%*sEND_FUNCTION;", level, ""); - tail_comment(fn->symbol.name); + raw( "\n%*sEND_FUNCTION;", level, "" ); + tail_comment( fn->symbol.name ); } -char *FUNCto_string(Function f) -{ - if(prep_string()) { +char * FUNCto_string( Function f ) { + if( prep_string() ) { return placeholder; } - FUNC_out(f, 0); - return (finish_string()); + FUNC_out( f, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int FUNCto_buffer(Function e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int FUNCto_buffer( Function e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - FUNC_out(e, 0); - return(finish_buffer()); + FUNC_out( e, 0 ); + return( finish_buffer() ); } -void FUNCout(Function f) -{ +void FUNCout( Function f ) { prep_file(); - FUNC_out(f, 0); + FUNC_out( f, 0 ); finish_file(); } diff --git a/src/exppp/pretty_func.h b/src/exppp/pretty_func.h index 71d857c6a..70d4b850d 100644 --- a/src/exppp/pretty_func.h +++ b/src/exppp/pretty_func.h @@ -3,10 +3,10 @@ #include -char *FUNCto_string(Function f); -void FUNC_out(Function fn, int level); -void FUNCout(Function f); -int FUNCto_buffer(Function e, char *buffer, int length); +char * FUNCto_string( Function f ); +void FUNC_out( Function fn, int level ); +void FUNCout( Function f ); +int FUNCto_buffer( Function e, char * buffer, int length ); #endif /* PRETTY_FUNC_H */ diff --git a/src/exppp/pretty_loop.c b/src/exppp/pretty_loop.c index da29fd58e..95a059f44 100644 --- a/src/exppp/pretty_loop.c +++ b/src/exppp/pretty_loop.c @@ -11,42 +11,41 @@ #include "pretty_stmt.h" #include "pretty_loop.h" -void LOOPout(struct Loop_ *loop, int level) -{ +void LOOPout( struct Loop_ *loop, int level ) { Variable v; - raw("%*sREPEAT", level, ""); + raw( "%*sREPEAT", level, "" ); /* increment */ /* if (loop->scope->u.incr) {*/ - if(loop->scope) { + if( loop->scope ) { DictionaryEntry de; - DICTdo_init(loop->scope->symbol_table, &de); - v = (Variable)DICTdo(&de); - wrap(" %s := ", v->name->symbol.name); - EXPR_out(loop->scope->u.incr->init, 0); - wrap(" TO "); - EXPR_out(loop->scope->u.incr->end, 0); - wrap(" BY "); /* parser always forces a "by" expr */ - EXPR_out(loop->scope->u.incr->increment, 0); + DICTdo_init( loop->scope->symbol_table, &de ); + v = ( Variable )DICTdo( &de ); + wrap( " %s := ", v->name->symbol.name ); + EXPR_out( loop->scope->u.incr->init, 0 ); + wrap( " TO " ); + EXPR_out( loop->scope->u.incr->end, 0 ); + wrap( " BY " ); /* parser always forces a "by" expr */ + EXPR_out( loop->scope->u.incr->increment, 0 ); } /* while */ - if(loop->while_expr) { - wrap(" WHILE "); - EXPR_out(loop->while_expr, 0); + if( loop->while_expr ) { + wrap( " WHILE " ); + EXPR_out( loop->while_expr, 0 ); } /* until */ - if(loop->until_expr) { - wrap(" UNTIL "); - EXPR_out(loop->until_expr, 0); + if( loop->until_expr ) { + wrap( " UNTIL " ); + EXPR_out( loop->until_expr, 0 ); } - raw(";\n"); + raw( ";\n" ); - STMTlist_out(loop->statements, level + exppp_nesting_indent); + STMTlist_out( loop->statements, level + exppp_nesting_indent ); - raw("%*sEND_REPEAT;\n", level, ""); + raw( "%*sEND_REPEAT;\n", level, "" ); } diff --git a/src/exppp/pretty_loop.h b/src/exppp/pretty_loop.h index 804f4b450..7a048211d 100644 --- a/src/exppp/pretty_loop.h +++ b/src/exppp/pretty_loop.h @@ -3,6 +3,6 @@ #include -void LOOPout(struct Loop_ *loop, int level); +void LOOPout( struct Loop_ *loop, int level ); #endif /* PRETTY_LOOP_H */ diff --git a/src/exppp/pretty_proc.c b/src/exppp/pretty_proc.c index cb297fbab..ee16d6853 100644 --- a/src/exppp/pretty_proc.c +++ b/src/exppp/pretty_proc.c @@ -8,51 +8,47 @@ #include "pretty_stmt.h" #include "pretty_proc.h" -char *PROCto_string(Procedure p) -{ - if(prep_string()) { +char * PROCto_string( Procedure p ) { + if( prep_string() ) { return placeholder; } - PROC_out(p, 0); - return (finish_string()); + PROC_out( p, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int PROCto_buffer(Procedure e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int PROCto_buffer( Procedure e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - PROC_out(e, 0); - return(finish_buffer()); + PROC_out( e, 0 ); + return( finish_buffer() ); } -void PROCout(Procedure p) -{ +void PROCout( Procedure p ) { prep_file(); - PROC_out(p, 0); + PROC_out( p, 0 ); finish_file(); } -void PROC_out(Procedure p, int level) -{ - if(p->u.proc->builtin) { +void PROC_out( Procedure p, int level ) { + if( p->u.proc->builtin ) { return; } first_newline(); - exppp_ref_info(&p->symbol); + exppp_ref_info( &p->symbol ); - raw("%*sPROCEDURE %s(\n", level, "", p->symbol.name); + raw( "%*sPROCEDURE %s(\n", level, "", p->symbol.name ); - ALGargs_out(p->u.proc->parameters, level + strlen("PROCEDURE ")); + ALGargs_out( p->u.proc->parameters, level + strlen( "PROCEDURE " ) ); - raw("%*s);\n", level + exppp_nesting_indent, ""); + raw( "%*s);\n", level + exppp_nesting_indent, "" ); - ALGscope_out(p, level + exppp_nesting_indent); - STMTlist_out(p->u.proc->body, level + exppp_nesting_indent); + ALGscope_out( p, level + exppp_nesting_indent ); + STMTlist_out( p->u.proc->body, level + exppp_nesting_indent ); - raw("\n%*sEND_PROCEDURE;", level, ""); - tail_comment(p->symbol.name); + raw( "\n%*sEND_PROCEDURE;", level, "" ); + tail_comment( p->symbol.name ); } diff --git a/src/exppp/pretty_proc.h b/src/exppp/pretty_proc.h index 46df8839e..22099878e 100644 --- a/src/exppp/pretty_proc.h +++ b/src/exppp/pretty_proc.h @@ -3,9 +3,9 @@ #include -char *PROCto_string(Procedure p); -void PROC_out(Procedure p, int level); -void PROCout(Procedure p); -int PROCto_buffer(Procedure e, char *buffer, int length); +char * PROCto_string( Procedure p ); +void PROC_out( Procedure p, int level ); +void PROCout( Procedure p ); +int PROCto_buffer( Procedure e, char * buffer, int length ); #endif /* PRETTY_PROC_H */ diff --git a/src/exppp/pretty_ref.c b/src/exppp/pretty_ref.c index 72cf13d1a..3d73efd77 100644 --- a/src/exppp/pretty_ref.c +++ b/src/exppp/pretty_ref.c @@ -8,64 +8,62 @@ #include "pp.h" #include "pretty_ref.h" -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level) -{ +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ) { Dictionary dict; DictionaryEntry de; - struct Rename *ren; + struct Rename * ren; Linked_List list; - LISTdo(reflist, s, Schema) - raw("%s FROM %s;\n", type, s->symbol.name); + LISTdo( reflist, s, Schema ) + raw( "%s FROM %s;\n", type, s->symbol.name ); LISTod - if(!refdict) { + if( !refdict ) { return; } - dict = DICTcreate(10); + dict = DICTcreate( 10 ); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init(refdict, &de); - while(0 != (ren = (struct Rename *)DICTdo(&de))) { + DICTdo_init( refdict, &de ); + while( 0 != ( ren = ( struct Rename * )DICTdo( &de ) ) ) { Linked_List nameList; - nameList = (Linked_List)DICTlookup(dict, ren->schema->symbol.name); - if(!nameList) { + nameList = ( Linked_List )DICTlookup( dict, ren->schema->symbol.name ); + if( !nameList ) { nameList = LISTcreate(); - DICTdefine(dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN); + DICTdefine( dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN ); } - LISTadd_last(nameList, ren); + LISTadd_last( nameList, ren ); } /* step 2: for each list, print out the renames */ level = 6; /* no special reason, feels good */ indent2 = level + exppp_continuation_indent; - DICTdo_init(dict, &de); - while(0 != (list = (Linked_List)DICTdo(&de))) { + DICTdo_init( dict, &de ); + while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { bool first_time = true; - LISTdo(list, r, struct Rename *) { - if(first_time) { - raw("%s FROM %s\n", type, r->schema->symbol.name); + LISTdo( list, r, struct Rename * ) { + if( first_time ) { + raw( "%s FROM %s\n", type, r->schema->symbol.name ); } else { /* finish previous line */ - raw(",\n"); + raw( ",\n" ); } - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(r->old->name); - if(r->old != r->nnew) { - wrap(" AS %s", r->nnew->name); + raw( r->old->name ); + if( r->old != r->nnew ) { + wrap( " AS %s", r->nnew->name ); } - } - LISTod - raw(" );\n"); + } LISTod + raw( " );\n" ); } - HASHdestroy(dict); + HASHdestroy( dict ); } diff --git a/src/exppp/pretty_ref.h b/src/exppp/pretty_ref.h index 7d1f22535..2b1c1cf84 100644 --- a/src/exppp/pretty_ref.h +++ b/src/exppp/pretty_ref.h @@ -4,6 +4,6 @@ #include #include -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); #endif /* PRETTY_REF_H */ diff --git a/src/exppp/pretty_rule.c b/src/exppp/pretty_rule.c index 9e18ef21e..49d4d0e15 100644 --- a/src/exppp/pretty_rule.c +++ b/src/exppp/pretty_rule.c @@ -9,54 +9,50 @@ #include "pretty_where.h" #include "pretty_rule.h" -char *RULEto_string(Rule r) -{ - if(prep_string()) { +char * RULEto_string( Rule r ) { + if( prep_string() ) { return placeholder; } - RULE_out(r, 0); - return (finish_string()); + RULE_out( r, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int RULEto_buffer(Rule e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int RULEto_buffer( Rule e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - RULE_out(e, 0); - return(finish_buffer()); + RULE_out( e, 0 ); + return( finish_buffer() ); } -void RULEout(Rule r) -{ +void RULEout( Rule r ) { prep_file(); - RULE_out(r, 0); + RULE_out( r, 0 ); finish_file(); } -void RULE_out(Rule r, int level) -{ +void RULE_out( Rule r, int level ) { int i = 0; first_newline(); - exppp_ref_info(&r->symbol); + exppp_ref_info( &r->symbol ); - raw("%*sRULE %s FOR ( ", level, "", r->symbol.name); + raw( "%*sRULE %s FOR ( ", level, "", r->symbol.name ); - LISTdo(r->u.rule->parameters, p, Variable) + LISTdo( r->u.rule->parameters, p, Variable ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - wrap(p->name->symbol.name); + wrap( p->name->symbol.name ); LISTod; - raw(" );\n"); + raw( " );\n" ); - ALGscope_out(r, level + exppp_nesting_indent); - STMTlist_out(r->u.rule->body, level + exppp_nesting_indent); - raw("\n"); - WHERE_out(RULEget_where(r), level); + ALGscope_out( r, level + exppp_nesting_indent ); + STMTlist_out( r->u.rule->body, level + exppp_nesting_indent ); + raw( "\n" ); + WHERE_out( RULEget_where( r ), level ); - raw("\n%*sEND_RULE;", level, ""); - tail_comment(r->symbol.name); + raw( "\n%*sEND_RULE;", level, "" ); + tail_comment( r->symbol.name ); } diff --git a/src/exppp/pretty_rule.h b/src/exppp/pretty_rule.h index f507bde20..18d29e0c8 100644 --- a/src/exppp/pretty_rule.h +++ b/src/exppp/pretty_rule.h @@ -3,9 +3,9 @@ #include "../express/alg.h" -char *RULEto_string(Rule r); -void RULE_out(Rule r, int level); -void RULEout(Rule r); -int RULEto_buffer(Rule e, char *buffer, int length); +char * RULEto_string( Rule r ); +void RULE_out( Rule r, int level ); +void RULEout( Rule r ); +int RULEto_buffer( Rule e, char * buffer, int length ); #endif /* PRETTY_RULE_H */ diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 50940c413..6b555f379 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -19,48 +20,47 @@ # include /* for unlink */ #endif -char *exppp_output_filename = (char *)0; /* if this is set, override default output filename */ +char * exppp_output_filename = ( char * )0; /* if this is set, override default output filename */ char exppp_filename_buffer[1000]; /* output file name */ /* Only the first line is compared to an existing file, so putting a * version number in here won't cause problems. The actual version must * be inserted later - this can't be initialized with non-constant. */ -char *expheader[] = { - "(* This file was generated by the EXPRESS Pretty Printer exppp,", - "part of STEPcode (formerly NIST's SCL). exppp version:", - "" /* if there are two consecutive blank lines, */, - "" /* the version string will be printed on the first */, - "WARNING: If you modify this file and want to save the changes,", - "delete this comment block or else the file will be rewritten", - "the next time exppp processes this schema. *)", +char * expheader[] = { + "(* This file was generated by the EXPRESS Pretty Printer exppp," , + "part of STEPcode (formerly NIST's SCL). exppp version:" , + "" /* if there are two consecutive blank lines, */ , + "" /* the version string will be printed on the first */ , + "WARNING: If you modify this file and want to save the changes," , + "delete this comment block or else the file will be rewritten" , + "the next time exppp processes this schema. *)" , 0 }; /** returns name of file written to in static storage */ -char *SCHEMAout(Schema s) -{ -#define PP_SMALL_BUF_SZ 80 +char * SCHEMAout( Schema s ) { + #define PP_SMALL_BUF_SZ 80 char buf[PP_SMALL_BUF_SZ]; - char *p; + char * p; int level = 0; - char **hp; + char ** hp; bool described = false; - if(exppp_print_to_stdout) { + if( exppp_print_to_stdout ) { exppp_fp = stdout; } else { - FILE *f; - if(exppp_output_filename_reset) { + FILE * f; + if( exppp_output_filename_reset ) { exppp_output_filename = 0; } - if(exppp_output_filename) { - if(!strcmp(input_filename, exppp_output_filename)) { - fprintf(stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename); - exit(EXIT_FAILURE); + if( exppp_output_filename ) { + if( !strcmp( input_filename, exppp_output_filename ) ) { + fprintf( stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename ); + exit( EXIT_FAILURE ); } - strcpy(exppp_filename_buffer, exppp_output_filename); + strcpy( exppp_filename_buffer, exppp_output_filename ); } else { /* when there is only a single file, allow user to find */ /* out what it is */ @@ -70,47 +70,47 @@ char *SCHEMAout(Schema s) /* since we have to generate a filename, make sure we don't */ /* overwrite a valuable file */ - sprintf(exppp_filename_buffer, "%s.exp", s->symbol.name); + sprintf( exppp_filename_buffer, "%s.exp", s->symbol.name ); - if(0 != (f = fopen(exppp_filename_buffer, "r"))) { - char *result = fgets(buf, PP_SMALL_BUF_SZ, f); - if(0 != (p = strchr(buf, '\n'))) { + if( 0 != ( f = fopen( exppp_filename_buffer, "r" ) ) ) { + char * result = fgets( buf, PP_SMALL_BUF_SZ, f ); + if( 0 != ( p = strchr( buf, '\n' ) ) ) { *p = '\0'; } - if((!result) || (!strcmp(buf, expheader[0]))) { - unlink(exppp_filename_buffer); + if( ( !result ) || ( !strcmp( buf, expheader[0] ) ) ) { + unlink( exppp_filename_buffer ); } else { - fprintf(stderr, "%s: %s already exists and appears to be hand-written\n", - EXPRESSprogram_name, exppp_filename_buffer); + fprintf( stderr, "%s: %s already exists and appears to be hand-written\n", + EXPRESSprogram_name, exppp_filename_buffer ); /* strcat(bp,".pp");*/ - strcat(exppp_filename_buffer, ".pp"); - fprintf(stderr, "%s: writing schema file %s instead\n", - EXPRESSprogram_name, exppp_filename_buffer); + strcat( exppp_filename_buffer, ".pp" ); + fprintf( stderr, "%s: writing schema file %s instead\n", + EXPRESSprogram_name, exppp_filename_buffer ); described = true; } } - if(f) { - fclose(f); + if( f ) { + fclose( f ); } } error_sym.filename = exppp_filename_buffer; - if(!described && !exppp_terse) { - fprintf(stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer); + if( !described && !exppp_terse ) { + fprintf( stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer ); } - if(!(exppp_fp = f = fopen(exppp_filename_buffer, "w"))) { - ERRORreport(FILE_UNWRITABLE, exppp_filename_buffer, strerror(errno)); + if( !( exppp_fp = f = fopen( exppp_filename_buffer, "w" ) ) ) { + ERRORreport( FILE_UNWRITABLE, exppp_filename_buffer, strerror( errno ) ); return 0; } } error_sym.line = 1; /* print our header - generated by exppp, don't edit, etc */ - for(hp = expheader; *hp; hp++) { - if((**hp == '\0') && (**(hp + 1) == '\0')) { + for( hp = expheader; *hp; hp++ ) { + if( ( **hp == '\0' ) && ( **( hp + 1 ) == '\0' ) ) { /* if this and the next lines are blank, put version string on this line */ - raw("%s\n", SC_VERSION); + raw( "%s\n", sc_version ); } else { - raw("%s\n", *hp); + raw( "%s\n", *hp ); } } @@ -118,15 +118,15 @@ char *SCHEMAout(Schema s) /* raw("SCHEMA %s;\n",s->symbol.name);*/ first_line = false; - raw("\nSCHEMA %s;\n", s->symbol.name); + raw( "\nSCHEMA %s;\n", s->symbol.name ); - if(s->u.schema->usedict || s->u.schema->use_schemas - || s->u.schema->refdict || s->u.schema->ref_schemas) { - raw("\n"); + if( s->u.schema->usedict || s->u.schema->use_schemas + || s->u.schema->refdict || s->u.schema->ref_schemas ) { + raw( "\n" ); } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent ); /* output order for DIS & IS schemas: * CONSTANT @@ -139,47 +139,44 @@ char *SCHEMAout(Schema s) * Within each of those groups, declarations must be sorted alphabetically. */ - SCOPEconsts_out(s, level + exppp_nesting_indent); - SCOPEtypes_out(s, level + exppp_nesting_indent); - SCOPEentities_out(s, level + exppp_nesting_indent); - SCOPEalgs_out(s, level + exppp_nesting_indent); + SCOPEconsts_out( s, level + exppp_nesting_indent ); + SCOPEtypes_out( s, level + exppp_nesting_indent ); + SCOPEentities_out( s, level + exppp_nesting_indent ); + SCOPEalgs_out( s, level + exppp_nesting_indent ); - raw("\nEND_SCHEMA;"); - tail_comment(s->symbol.name); + raw( "\nEND_SCHEMA;"); + tail_comment( s->symbol.name ); - fclose(exppp_fp); + fclose( exppp_fp ); return exppp_filename_buffer; -#undef PP_SMALL_BUF_SZ + #undef PP_SMALL_BUF_SZ } -char *SCHEMAref_to_string(Schema s) -{ - if(prep_string()) { +char * SCHEMAref_to_string( Schema s ) { + if( prep_string() ) { return placeholder; } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); - return (finish_string()); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int SCHEMAref_to_buffer(Schema s, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int SCHEMAref_to_buffer( Schema s, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); - return(finish_buffer()); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); + return( finish_buffer() ); } -void SCHEMAref_out(Schema s) -{ +void SCHEMAref_out( Schema s ) { prep_file(); - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); finish_file(); } diff --git a/src/exppp/pretty_schema.h b/src/exppp/pretty_schema.h index 7005bc363..b9c649f99 100644 --- a/src/exppp/pretty_schema.h +++ b/src/exppp/pretty_schema.h @@ -3,9 +3,9 @@ #include -char *SCHEMAout(Schema s); -char *SCHEMAref_to_string(Schema s); -void SCHEMAref_out(Schema s); -int SCHEMAref_to_buffer(Schema s, char *buffer, int length); +char * SCHEMAout( Schema s ); +char * SCHEMAref_to_string( Schema s ); +void SCHEMAref_out( Schema s ); +int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); #endif /* PRETTY_SCHEMA_H */ diff --git a/src/exppp/pretty_scope.c b/src/exppp/pretty_scope.c index b3c92fc43..85fe041d1 100644 --- a/src/exppp/pretty_scope.c +++ b/src/exppp/pretty_scope.c @@ -13,121 +13,111 @@ #include "pretty_scope.h" /** add items from s to list alphabetically */ -void SCOPEadd_inorder(Linked_List list, Scope s) -{ +void SCOPEadd_inorder( Linked_List list, Scope s ) { Link k = 0; - LISTdo_links(list, link) - if(0 > strcmp( - SCOPEget_name(s), - SCOPEget_name((Type)(link->data)))) { + LISTdo_links( list, link ) + if( 0 > strcmp( + SCOPEget_name( s ), + SCOPEget_name( ( Type )( link->data ) ) ) ) { k = link; break; - } - LISTod + } LISTod - LISTadd_before(list, k, s); + LISTadd_before( list, k, s ); } /** like SCOPEadd_inorder, but for Variables */ -void SCOPEaddvars_inorder(Linked_List list, Variable v) -{ +void SCOPEaddvars_inorder( Linked_List list, Variable v ) { Link k = 0; - LISTdo_links(list, link) - if(0 > strcmp(v->name->symbol.name, ((Variable) link->data)->name->symbol.name)) { + LISTdo_links( list, link ) + if( 0 > strcmp( v->name->symbol.name, ( ( Variable ) link->data )->name->symbol.name ) ) { k = link; break; - } - LISTod + } LISTod - LISTadd_before(list, k, v); + LISTadd_before( list, k, v ); } /** print the rules in a scope */ -void SCOPErules_out(Scope s, int level) -{ +void SCOPErules_out( Scope s, int level ) { Rule r; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - RULE_out(r, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + RULE_out( r, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - SCOPEadd_inorder(alpha, r); + DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, r ); } - LISTdo(alpha, ru, Rule) { - RULE_out(ru, level); - } - LISTod + LISTdo( alpha, ru, Rule ) { + RULE_out( ru, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /** print the functions in a scope */ -void SCOPEfuncs_out(Scope s, int level) -{ +void SCOPEfuncs_out( Scope s, int level ) { Function f; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - FUNC_out(f, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + FUNC_out( f, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - SCOPEadd_inorder(alpha, f); + DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, f ); } - LISTdo(alpha, fun, Function) { - FUNC_out(fun, level); - } - LISTod + LISTdo( alpha, fun, Function ) { + FUNC_out( fun, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /* print the procs in a scope */ -void SCOPEprocs_out(Scope s, int level) -{ +void SCOPEprocs_out( Scope s, int level ) { Procedure p; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - PROC_out(p, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + PROC_out( p, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - SCOPEadd_inorder(alpha, p); + DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, p ); } - LISTdo(alpha, pr, Procedure) { - PROC_out(pr, level); - } - LISTod + LISTdo( alpha, pr, Procedure ) { + PROC_out( pr, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } @@ -143,252 +133,240 @@ void SCOPEprocs_out(Scope s, int level) * Within each of those groups, declarations must be sorted alphabetically. */ /* print the algorithms in a scope */ -void SCOPEalgs_out(Scope s, int level) -{ +void SCOPEalgs_out( Scope s, int level ) { /* Supplementary Directivies 2.1.1 requires rules to be separated */ /* might as well separate funcs and procs, too */ - SCOPErules_out(s, level); - SCOPEfuncs_out(s, level); - SCOPEprocs_out(s, level); + SCOPErules_out( s, level ); + SCOPEfuncs_out( s, level ); + SCOPEprocs_out( s, level ); } /** output one const - used in SCOPEconsts_out, below */ -void SCOPEconst_out(Variable v, int level, size_t max_indent) -{ +void SCOPEconst_out( Variable v, int level, size_t max_indent ) { size_t old_indent2; /* print attribute name */ - raw("%*s%-*s :", level + 2, "", - max_indent, v->name->symbol.name); + raw( "%*s%-*s :", level + 2, "", + max_indent, v->name->symbol.name ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } /* let type definition stick out a bit to the left if it's on a new line */ old_indent2 = indent2; - if(indent2 > 4) { + if( indent2 > 4 ) { indent2 -= 4; } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); indent2 = old_indent2; - if(v->initializer) { + if( v->initializer ) { int old_ll = exppp_linelength; /* so exppp_linelength can be restored */ - raw(" :="); + raw( " :=" ); /* let '[' on first line of initializer stick out so strings are aligned */ - raw("\n%*s", indent2 - 2, ""); + raw( "\n%*s", indent2 - 2, "" ); - if(exppp_aggressively_wrap_consts) { + if( exppp_aggressively_wrap_consts ) { /* causes wrap() to always begin new line */ exppp_linelength = indent2; } - EXPR_out(v->initializer, 0); + EXPR_out( v->initializer, 0 ); exppp_linelength = old_ll; } - raw(";\n"); + raw( ";\n" ); } /** output all consts in this scope */ -void SCOPEconsts_out(Scope s, int level) -{ +void SCOPEconsts_out( Scope s, int level ) { Variable v; DictionaryEntry de; size_t max_indent = 0; Dictionary d = s->symbol_table; /* checks length of constant names */ - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - if(strlen(v->name->symbol.name) > max_indent) { - max_indent = strlen(v->name->symbol.name); + if( strlen( v->name->symbol.name ) > max_indent ) { + max_indent = strlen( v->name->symbol.name ); } } - if(!max_indent) { + if( !max_indent ) { return; } first_newline(); - raw("%*sCONSTANT\n", level, ""); + raw( "%*sCONSTANT\n", level, "" ); /* if max_indent is too big, wrap() won't insert any newlines * fiddled with this until it looked ok on 242 arm */ - if((max_indent + 20) > (size_t) exppp_linelength / 2) { - max_indent = (size_t) exppp_linelength / 3; + if( ( max_indent + 20 ) > ( size_t ) exppp_linelength / 2 ) { + max_indent = ( size_t ) exppp_linelength / 3; } - indent2 = level + max_indent + strlen(": ab") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": ab" ) + exppp_continuation_indent; - if(!exppp_alphabetize) { - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + if( !exppp_alphabetize ) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - SCOPEconst_out(v, level, max_indent); + SCOPEconst_out( v, level, max_indent ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - SCOPEaddvars_inorder(alpha, v); + SCOPEaddvars_inorder( alpha, v ); } - LISTdo(alpha, cnst, Variable) { - SCOPEconst_out(cnst, level, max_indent); - } - LISTod - LISTfree(alpha); + LISTdo( alpha, cnst, Variable ) { + SCOPEconst_out( cnst, level, max_indent ); + } LISTod + LISTfree( alpha ); } - raw("%*sEND_CONSTANT;\n", level, ""); + raw( "%*sEND_CONSTANT;\n", level, "" ); } /** insert variable v into list, keeping the list ordered by ascending v->offset */ -void SCOPElocals_order(Linked_List list, Variable v) -{ - LISTdo_links(list, link) { - if(v->offset < ((Variable) link->data)->offset) { - LISTadd_before(list, link, v); +void SCOPElocals_order( Linked_List list, Variable v ) { + LISTdo_links( list, link ) { + if( v->offset < ( (Variable) link->data )->offset ) { + LISTadd_before( list, link, v ); return; } - } - LISTod - LISTadd_last(list, v); + } LISTod + LISTadd_last( list, v ); } -void SCOPElocals_out(Scope s, int level) -{ +void SCOPElocals_out( Scope s, int level ) { Variable v; DictionaryEntry de; Linked_List orderedLocals = 0; /**< this list is used to order the vars the same way they were in the file */ size_t max_indent = 0; Dictionary d = s->symbol_table; - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( v->flags.constant ) { continue; } - if(v->flags.parameter) { + if( v->flags.parameter ) { continue; } - if(strlen(v->name->symbol.name) > max_indent) { - max_indent = strlen(v->name->symbol.name); + if( strlen( v->name->symbol.name ) > max_indent ) { + max_indent = strlen( v->name->symbol.name ); } } - if(!max_indent) { + if( !max_indent ) { return; } first_newline(); - raw("%*sLOCAL\n", level, ""); - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + raw( "%*sLOCAL\n", level, "" ); + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( v->flags.constant ) { continue; } - if(v->flags.parameter) { + if( v->flags.parameter ) { continue; } - if(!orderedLocals) { + if( !orderedLocals ) { orderedLocals = LISTcreate(); - LISTadd_first(orderedLocals, v); + LISTadd_first( orderedLocals, v ); } else { /* sort by v->offset */ - SCOPElocals_order(orderedLocals, v); + SCOPElocals_order( orderedLocals, v ); } } - LISTdo(orderedLocals, var, Variable) { + LISTdo( orderedLocals, var, Variable ) { /* print attribute name */ - raw("%*s%-*s :", level + exppp_nesting_indent, "", - max_indent, var->name->symbol.name); + raw( "%*s%-*s :", level + exppp_nesting_indent, "", + max_indent, var->name->symbol.name ); /* print attribute type */ - if(VARget_optional(var)) { - wrap(" OPTIONAL"); + if( VARget_optional( var ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(var->type, NOLEVEL); + TYPE_head_out( var->type, NOLEVEL ); - if(var->initializer) { - wrap(" := "); - EXPR_out(var->initializer, 0); + if( var->initializer ) { + wrap( " := " ); + EXPR_out( var->initializer, 0 ); } - raw(";\n"); - } - LISTod - LISTfree(orderedLocals); + raw( ";\n" ); + } LISTod + LISTfree( orderedLocals ); - raw("%*sEND_LOCAL;\n", level, ""); + raw( "%*sEND_LOCAL;\n", level, "" ); } /** print all entities in a scope */ -void SCOPEentities_out(Scope s, int level) -{ +void SCOPEentities_out( Scope s, int level ) { Entity e; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); - while(0 != (e = (Entity)DICTdo(&de))) { - ENTITY_out(e, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { + ENTITY_out( e, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); - while(0 != (e = (Entity)DICTdo(&de))) { - SCOPEadd_inorder(alpha, e); + DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, e ); } - LISTdo(alpha, en, Entity) { - ENTITY_out(en, level); - } - LISTod + LISTdo( alpha, en, Entity ) { + ENTITY_out( en, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /** print all types in a scope */ -void SCOPEtypes_out(Scope s, int level) -{ +void SCOPEtypes_out( Scope s, int level ) { DictionaryEntry de; Type t; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); - while(0 != (t = (Type)DICTdo(&de))) { - TYPE_out(t, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); + while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { + TYPE_out( t, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); - while(0 != (t = (Type)DICTdo(&de))) { - SCOPEadd_inorder(alpha, t); + DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); + while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, t ); } - LISTdo(alpha, ty, Type) { - TYPE_out(ty, level); - } - LISTod + LISTdo( alpha, ty, Type ) { + TYPE_out( ty, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } diff --git a/src/exppp/pretty_scope.h b/src/exppp/pretty_scope.h index 82a64221d..1e4e82e7d 100644 --- a/src/exppp/pretty_scope.h +++ b/src/exppp/pretty_scope.h @@ -6,15 +6,15 @@ #include "pp.h" -void SCOPEadd_inorder(Linked_List list, Scope s); -void SCOPEalgs_out(Scope s, int level); -void SCOPEconsts_out(Scope s, int level); -void SCOPEentities_out(Scope s, int level); -void SCOPEfuncs_out(Scope s, int level); -void SCOPElocals_out(Scope s, int level); -void SCOPEprocs_out(Scope s, int level); -void SCOPErules_out(Scope s, int level); -void SCOPEtypes_out(Scope s, int level); +void SCOPEadd_inorder( Linked_List list, Scope s ); +void SCOPEalgs_out( Scope s, int level ); +void SCOPEconsts_out( Scope s, int level ); +void SCOPEentities_out( Scope s, int level ); +void SCOPEfuncs_out( Scope s, int level ); +void SCOPElocals_out( Scope s, int level ); +void SCOPEprocs_out( Scope s, int level ); +void SCOPErules_out( Scope s, int level ); +void SCOPEtypes_out( Scope s, int level ); #endif /* PRETTY_SCOPE_H */ diff --git a/src/exppp/pretty_stmt.c b/src/exppp/pretty_stmt.c index b99aaa2e5..7694577ed 100644 --- a/src/exppp/pretty_stmt.c +++ b/src/exppp/pretty_stmt.c @@ -9,115 +9,110 @@ #include "pretty_loop.h" #include "pretty_stmt.h" -void STMT_out(Statement s, int level) -{ +void STMT_out( Statement s, int level ) { bool first_time = true; - if(!s) { /* null statement */ - raw("%*s;\n", level, ""); + if( !s ) { /* null statement */ + raw( "%*s;\n", level, "" ); return; } indent2 = level + exppp_continuation_indent; - switch(s->type) { + switch( s->type ) { case STMT_ASSIGN: - raw("%*s", level, ""); - EXPR_out(s->u.assign->lhs, 0); - wrap(" := "); - EXPR_out(s->u.assign->rhs, 0); - raw(";\n", level, ""); + raw( "%*s", level, "" ); + EXPR_out( s->u.assign->lhs, 0 ); + wrap( " := " ); + EXPR_out( s->u.assign->rhs, 0 ); + raw( ";\n", level, "" ); break; case STMT_CASE: - CASEout(s->u.Case, level); + CASEout( s->u.Case, level ); break; case STMT_COMPOUND: - raw("\n%*sBEGIN\n", level, ""); - STMTlist_out(s->u.compound->statements, level + exppp_nesting_indent); - raw("%*sEND;\n", level, ""); + raw( "\n%*sBEGIN\n", level, "" ); + STMTlist_out( s->u.compound->statements, level + exppp_nesting_indent ); + raw( "%*sEND;\n", level, "" ); break; case STMT_COND: - raw("%*sIF ", level, ""); - EXPR_out(s->u.cond->test, 0); - wrap(" THEN\n"); - STMTlist_out(s->u.cond->code, level + exppp_nesting_indent); - if(s->u.cond->otherwise) { - raw("%*sELSE\n", level, ""); - STMTlist_out(s->u.cond->otherwise, level + exppp_nesting_indent); + raw( "%*sIF ", level, "" ); + EXPR_out( s->u.cond->test, 0 ); + wrap( " THEN\n" ); + STMTlist_out( s->u.cond->code, level + exppp_nesting_indent ); + if( s->u.cond->otherwise ) { + raw( "%*sELSE\n", level, "" ); + STMTlist_out( s->u.cond->otherwise, level + exppp_nesting_indent ); } - raw("%*sEND_IF;\n", level, ""); + raw( "%*sEND_IF;\n", level, "" ); break; case STMT_LOOP: - LOOPout(s->u.loop, level); + LOOPout( s->u.loop, level ); break; case STMT_PCALL: - raw("%*s%s( ", level, "", s->symbol.name); - LISTdo(s->u.proc->parameters, p, Expression) - if(first_time) { + raw( "%*s%s( ", level, "", s->symbol.name ); + LISTdo( s->u.proc->parameters, p, Expression ) + if( first_time ) { first_time = false; } else { - raw(", "); + raw( ", " ); } - EXPR_out(p, 0); + EXPR_out( p, 0 ); LISTod - raw(" );\n"); + raw( " );\n" ); break; case STMT_RETURN: - raw("%*sRETURN", level, ""); - if(s->u.ret->value) { - wrap("( "); - EXPR_out(s->u.ret->value, 0); - raw(" )"); + raw( "%*sRETURN", level, "" ); + if( s->u.ret->value ) { + wrap( "( " ); + EXPR_out( s->u.ret->value, 0 ); + raw( " )" ); } - raw(";\n"); + raw( ";\n" ); break; case STMT_ALIAS: - raw("%*sALIAS %s for %s;\n", level, "", s->symbol.name, - /* should be generalized reference */ - s->u.alias->variable->name->symbol.name); - STMTlist_out(s->u.alias->statements, level + exppp_nesting_indent); - raw("%*sEND_ALIAS;", level, ""); - tail_comment(s->symbol.name); + raw( "%*sALIAS %s for %s;\n", level, "", s->symbol.name, + /* should be generalized reference */ + s->u.alias->variable->name->symbol.name ); + STMTlist_out( s->u.alias->statements, level + exppp_nesting_indent ); + raw( "%*sEND_ALIAS;", level, "" ); + tail_comment( s->symbol.name ); break; case STMT_SKIP: - raw("%*sSKIP;\n", level, ""); + raw( "%*sSKIP;\n", level, "" ); break; case STMT_ESCAPE: - raw("%*sESCAPE;\n", level, ""); + raw( "%*sESCAPE;\n", level, "" ); break; } } -void STMTlist_out(Linked_List stmts, int level) -{ - LISTdo(stmts, stmt, Statement) - STMT_out(stmt, level); +void STMTlist_out( Linked_List stmts, int level ) { + LISTdo( stmts, stmt, Statement ) + STMT_out( stmt, level ); LISTod } -char *STMTto_string(Statement s) -{ - if(prep_string()) { +char * STMTto_string( Statement s ) { + if( prep_string() ) { return placeholder; } - STMT_out(s, 0); - return (finish_string()); + STMT_out( s, 0 ); + return ( finish_string() ); } /* return length of buffer used */ -int STMTto_buffer(Statement s, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int STMTto_buffer( Statement s, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - STMT_out(s, 0); - return(finish_buffer()); + STMT_out( s, 0 ); + return( finish_buffer() ); } -void STMTout(Statement s) -{ +void STMTout( Statement s ) { prep_file(); - STMT_out(s, 0); + STMT_out( s, 0 ); finish_file(); } diff --git a/src/exppp/pretty_stmt.h b/src/exppp/pretty_stmt.h index f25d8bbde..fe75ff372 100644 --- a/src/exppp/pretty_stmt.h +++ b/src/exppp/pretty_stmt.h @@ -4,11 +4,11 @@ #include #include -char *STMTto_string(Statement s); -void STMT_out(Statement s, int level); -void STMTlist_out(Linked_List stmts, int level); -void STMTout(Statement s); -int STMTto_buffer(Statement s, char *buffer, int length); +char * STMTto_string( Statement s ); +void STMT_out( Statement s, int level ); +void STMTlist_out( Linked_List stmts, int level ); +void STMTout( Statement s ); +int STMTto_buffer( Statement s, char * buffer, int length ); #endif /* PRETTY_STMT_H */ diff --git a/src/exppp/pretty_subtype.c b/src/exppp/pretty_subtype.c index 1113d6ee1..d47298e49 100644 --- a/src/exppp/pretty_subtype.c +++ b/src/exppp/pretty_subtype.c @@ -10,27 +10,25 @@ #include "pretty_expr.h" #include "pretty_subtype.h" -void SUBTYPEout(Expression e) -{ +void SUBTYPEout( Expression e ) { /* language insists on having parens around entity names */ /* even if there is only one, but if the expression is */ /* complex, EXPRout will add on its own parens */ /* if (TYPEis_expression(e->type)) {*/ - raw("( "); + raw( "( " ); /* }*/ - EXPR_out(e, 0); + EXPR_out( e, 0 ); /* if (TYPEis_expression(e->type)) {*/ - raw(" )"); + raw( " )" ); /* }*/ } -char *SUBTYPEto_string(Expression e) -{ - if(prep_string()) { +char * SUBTYPEto_string( Expression e ) { + if( prep_string() ) { return placeholder; } - EXPR_out(e, 0); - return (finish_string()); + EXPR_out( e, 0 ); + return ( finish_string() ); } diff --git a/src/exppp/pretty_subtype.h b/src/exppp/pretty_subtype.h index d938093b1..4ff6ef085 100644 --- a/src/exppp/pretty_subtype.h +++ b/src/exppp/pretty_subtype.h @@ -3,8 +3,8 @@ #include -char *SUBTYPEto_string(Expression e); -void SUBTYPEout(Expression e); +char * SUBTYPEto_string( Expression e ); +void SUBTYPEout( Expression e ); #endif /* PRETTY_SUBTYPE_H */ diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index c6e7c580a..d18402ddc 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -14,293 +14,280 @@ #include "pretty_type.h" /** print a type definition. I.e., a TYPE statement */ -void TYPE_out(Type t, int level) -{ +void TYPE_out( Type t, int level ) { first_newline(); - exppp_ref_info(&t->symbol); + exppp_ref_info( &t->symbol ); - raw("%*sTYPE %s =", level, "", t->symbol.name); - if(TYPEget_head(t)) { - wrap(" %s", TYPEget_name(TYPEget_head(t))); + raw( "%*sTYPE %s =", level, "", t->symbol.name ); + if( TYPEget_head( t ) ) { + wrap( " %s", TYPEget_name( TYPEget_head( t ) ) ); } else { - TYPE_body_out(t, level + exppp_nesting_indent); + TYPE_body_out( t, level + exppp_nesting_indent ); } - raw(";\n"); + raw( ";\n" ); - WHERE_out(t->where, level); + WHERE_out( t->where, level ); - raw("%*sEND_TYPE;", level, ""); - tail_comment(t->symbol.name); + raw( "%*sEND_TYPE;", level, "" ); + tail_comment( t->symbol.name ); } /** prints type description (preceded by a space). * I.e., the type of an attribute or other object */ -void TYPE_head_out(Type t, int level) -{ - if(t->symbol.name) { +void TYPE_head_out( Type t, int level ) { + if( t->symbol.name ) { int old_indent = indent2; - if(indent2 + (int) strlen(t->symbol.name) > exppp_linelength) { - indent2 = (indent2 + level) / 2; + if( indent2 + ( int ) strlen( t->symbol.name ) > exppp_linelength ) { + indent2 = ( indent2 + level ) / 2; } - wrap(" %s", t->symbol.name); + wrap( " %s", t->symbol.name ); indent2 = old_indent; } else { - TYPE_body_out(t, level); + TYPE_body_out( t, level ); } } -void TYPEunique_or_optional_out(TypeBody tb) -{ - if(tb->flags.unique) { - wrap(" UNIQUE"); +void TYPEunique_or_optional_out( TypeBody tb ) { + if( tb->flags.unique ) { + wrap( " UNIQUE" ); } - if(tb->flags.optional) { - wrap(" OPTIONAL"); + if( tb->flags.optional ) { + wrap( " OPTIONAL" ); } } -void TYPE_body_out(Type t, int level) -{ +void TYPE_body_out( Type t, int level ) { bool first_time = true; Expression expr; DictionaryEntry de; - TypeBody tb = TYPEget_body(t); + TypeBody tb = TYPEget_body( t ); - switch(tb->type) { + switch( tb->type ) { case integer_: - wrap(" INTEGER"); + wrap( " INTEGER" ); break; case real_: - wrap(" REAL"); + wrap( " REAL" ); break; case string_: - wrap(" STRING"); + wrap( " STRING" ); break; case binary_: - wrap(" BINARY"); + wrap( " BINARY" ); break; case boolean_: - wrap(" BOOLEAN"); + wrap( " BOOLEAN" ); break; case logical_: - wrap(" LOGICAL"); + wrap( " LOGICAL" ); break; case number_: - wrap(" NUMBER"); + wrap( " NUMBER" ); break; case entity_: - wrap(" %s", tb->entity->symbol.name); + wrap( " %s", tb->entity->symbol.name ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(tb->type) { + switch( tb->type ) { /* ignore the aggregate bounds for now */ case aggregate_: - wrap(" AGGREGATE"); - if(tb->tag) { - wrap(":%s", tb->tag->symbol.name); + wrap( " AGGREGATE" ); + if( tb->tag ) { + wrap( ":%s", tb->tag->symbol.name ); } - wrap(" OF"); + wrap( " OF" ); break; case array_: - wrap(" ARRAY"); - EXPRbounds_out(tb); - wrap(" OF"); - TYPEunique_or_optional_out(tb); + wrap( " ARRAY" ); + EXPRbounds_out( tb ); + wrap( " OF" ); + TYPEunique_or_optional_out( tb ); break; case bag_: - wrap(" BAG"); - EXPRbounds_out(tb); - wrap(" OF"); + wrap( " BAG" ); + EXPRbounds_out( tb ); + wrap( " OF" ); break; case set_: - wrap(" SET"); - EXPRbounds_out(tb); - wrap(" OF"); + wrap( " SET" ); + EXPRbounds_out( tb ); + wrap( " OF" ); break; case list_: - wrap(" LIST"); - EXPRbounds_out(tb); - wrap(" OF"); - TYPEunique_or_optional_out(tb); + wrap( " LIST" ); + EXPRbounds_out( tb ); + wrap( " OF" ); + TYPEunique_or_optional_out( tb ); break; default: - fprintf(stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__); + fprintf( stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__ ); abort(); } - TYPE_head_out(tb->base, level); + TYPE_head_out( tb->base, level ); break; case enumeration_: { int i, count = 0; - char **names; + char ** names; /* * write names out in original order by first bucket sorting * to a temporary array. This is trivial since all buckets * will get filled with one and only one object. */ - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (expr = (Expression)DICTdo(&de))) { + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { count++; } - names = (char **)sc_malloc(count * sizeof(char *)); - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (expr = (Expression)DICTdo(&de))) { + names = ( char ** )sc_malloc( count * sizeof( char * ) ); + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { names[expr->u.integer - 1] = expr->symbol.name; } - wrap(" ENUMERATION OF\n"); + wrap( " ENUMERATION OF\n" ); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { /* finish line from previous enum item */ - if(!first_time) { - raw(",\n"); + if( !first_time ) { + raw( ",\n" ); } /* start new enum item */ - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(names[i]); + raw( names[i] ); } - raw(" )"); - sc_free((char *)names); + raw( " )" ); + sc_free( ( char * )names ); } break; case select_: - wrap(" SELECT\n"); - LISTdo(tb->list, type, Type) + wrap( " SELECT\n" ); + LISTdo( tb->list, type, Type ) /* finish line from previous entity */ - if(!first_time) { - raw(",\n"); + if( !first_time ) { + raw( ",\n" ); } /* start new entity */ - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(type->symbol.name); + raw( type->symbol.name ); LISTod /* if empty, force a left paren */ - if(first_time) { - ERRORreport_with_symbol(SELECT_EMPTY, &error_sym, t->symbol.name); - raw("%*s( ", level, ""); + if( first_time ) { + ERRORreport_with_symbol( SELECT_EMPTY, &error_sym, t->symbol.name ); + raw( "%*s( ", level, "" ); } - raw(" )"); + raw( " )" ); break; case generic_: - wrap(" GENERIC"); - if(tb->tag) { - wrap(":%s", tb->tag->symbol.name); + wrap( " GENERIC" ); + if( tb->tag ) { + wrap( ":%s", tb->tag->symbol.name ); } break; default: - wrap(" (* unknown type %d *)", tb->type); + wrap( " (* unknown type %d *)", tb->type ); } - if(tb->precision) { - wrap(" ( "); - EXPR_out(tb->precision, 0); - raw(" )"); + if( tb->precision ) { + wrap( " ( " ); + EXPR_out( tb->precision, 0 ); + raw( " )" ); } - if(tb->flags.fixed) { - wrap(" FIXED"); + if( tb->flags.fixed ) { + wrap( " FIXED" ); } } -char *TYPEto_string(Type t) -{ - if(prep_string()) { +char * TYPEto_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_out(t, 0); - return (finish_string()); + TYPE_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEto_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEto_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_out(t, 0); - return(finish_buffer()); + TYPE_out( t, 0 ); + return( finish_buffer() ); } -void TYPEout(Type t) -{ +void TYPEout( Type t ) { prep_file(); - TYPE_out(t, 0); + TYPE_out( t, 0 ); finish_file(); } -char *TYPEhead_to_string(Type t) -{ - if(prep_string()) { +char * TYPEhead_to_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_head_out(t, 0); - return (finish_string()); + TYPE_head_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEhead_to_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEhead_to_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_out(t, 0); - return(finish_buffer()); + TYPE_out( t, 0 ); + return( finish_buffer() ); } -void TYPEhead_out(Type t) -{ +void TYPEhead_out( Type t ) { prep_file(); - TYPE_head_out(t, 0); + TYPE_head_out( t, 0 ); finish_file(); } -char *TYPEbody_to_string(Type t) -{ - if(prep_string()) { +char * TYPEbody_to_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_body_out(t, 0); - return (finish_string()); + TYPE_body_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEbody_to_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEbody_to_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_body_out(t, 0); - return(finish_buffer()); + TYPE_body_out( t, 0 ); + return( finish_buffer() ); } -void TYPEbody_out(Type t) -{ +void TYPEbody_out( Type t ) { prep_file(); - TYPE_body_out(t, 0); + TYPE_body_out( t, 0 ); finish_file(); } diff --git a/src/exppp/pretty_type.h b/src/exppp/pretty_type.h index 91f788954..29101695b 100644 --- a/src/exppp/pretty_type.h +++ b/src/exppp/pretty_type.h @@ -3,19 +3,19 @@ #include "../express/type.h" -char *TYPEbody_to_string(Type t); -char *TYPEhead_to_string(Type t); -char *TYPEto_string(Type t); -void TYPE_body_out(Type t, int level); -void TYPE_head_out(Type t, int level); -void TYPE_out(Type t, int level); -void TYPEbody_out(Type t); -int TYPEbody_to_buffer(Type t, char *buffer, int length); -void TYPEhead_out(Type t); -int TYPEhead_to_buffer(Type t, char *buffer, int length); -void TYPEout(Type t); -int TYPEto_buffer(Type t, char *buffer, int length); -void TYPEunique_or_optional_out(TypeBody tb); +char * TYPEbody_to_string( Type t ); +char * TYPEhead_to_string( Type t ); +char * TYPEto_string( Type t ); +void TYPE_body_out( Type t, int level ); +void TYPE_head_out( Type t, int level ); +void TYPE_out( Type t, int level ); +void TYPEbody_out( Type t ); +int TYPEbody_to_buffer( Type t, char * buffer, int length ); +void TYPEhead_out( Type t ); +int TYPEhead_to_buffer( Type t, char * buffer, int length ); +void TYPEout( Type t ); +int TYPEto_buffer( Type t, char * buffer, int length ); +void TYPEunique_or_optional_out( TypeBody tb ); #endif /* PRETTY_TYPE_H */ diff --git a/src/exppp/pretty_where.c b/src/exppp/pretty_where.c index 3aef4197c..b461baaa6 100644 --- a/src/exppp/pretty_where.c +++ b/src/exppp/pretty_where.c @@ -10,71 +10,65 @@ #include "pretty_expr.h" #include "pretty_where.h" -char *WHEREto_string(Linked_List w) -{ - if(prep_string()) { +char * WHEREto_string( Linked_List w ) { + if( prep_string() ) { return placeholder; } - WHERE_out(w, 0); - return (finish_string()); + WHERE_out( w, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int WHEREto_buffer(Linked_List w, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int WHEREto_buffer( Linked_List w, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - WHERE_out(w, 0); - return(finish_buffer()); + WHERE_out( w, 0 ); + return( finish_buffer() ); } -void WHEREout(Linked_List w) -{ +void WHEREout( Linked_List w ) { prep_file(); - WHERE_out(w, 0); + WHERE_out( w, 0 ); finish_file(); } -void WHERE_out(Linked_List wheres, int level) -{ +void WHERE_out( Linked_List wheres, int level ) { size_t max_indent; - if(!wheres) { + if( !wheres ) { return; } - raw("%*s%s", level, "", "WHERE\n"); + raw( "%*s%s", level, "", "WHERE\n" ); level += exppp_nesting_indent; /* pass 1: calculate length of longest label */ max_indent = 0; - LISTdo(wheres, w, Where) { - if(w->label) { - if(strlen(w->label->name) > max_indent) { - max_indent = strlen(w->label->name); + LISTdo( wheres, w, Where ) { + if( w->label ) { + if( strlen( w->label->name ) > max_indent ) { + max_indent = strlen( w->label->name ); } } - } - LISTod + } LISTod - if(max_indent > 10) { + if( max_indent > 10 ) { /* don't bother indenting completely for * labels that are ridiculously long */ max_indent = 4; } - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: now print labels and exprs */ - LISTdo(wheres, w, Where) { - if(w->label) { - raw("%*s%-*s: ", level, "", max_indent, w->label->name); + LISTdo( wheres, w, Where ) { + if( w->label ) { + raw( "%*s%-*s: ", level, "", max_indent, w->label->name ); } else { /* no label */ - raw("%*s%-*s ", level, "", max_indent, ""); + raw( "%*s%-*s ", level, "", max_indent, "" ); } - EXPR_out(w->expr, max_indent); - raw(";\n"); - } - LISTod + EXPR_out( w->expr, max_indent ); + raw( ";\n" ); + } LISTod } diff --git a/src/exppp/pretty_where.h b/src/exppp/pretty_where.h index 68b5968ac..72d1a657a 100644 --- a/src/exppp/pretty_where.h +++ b/src/exppp/pretty_where.h @@ -3,10 +3,10 @@ #include -void WHERE_out(Linked_List wheres, int level); -void WHEREout(Linked_List w); -int WHEREto_buffer(Linked_List w, char *buffer, int length); -char *WHEREto_string(Linked_List w); +void WHERE_out( Linked_List wheres, int level ); +void WHEREout( Linked_List w ); +int WHEREto_buffer( Linked_List w, char * buffer, int length ); +char * WHEREto_string( Linked_List w ); #endif /* PRETTY_WHERE_H */ diff --git a/src/exppp/test/test_breakLongStr.c b/src/exppp/test/test_breakLongStr.c index 0382b3667..f93a5809d 100644 --- a/src/exppp/test/test_breakLongStr.c +++ b/src/exppp/test/test_breakLongStr.c @@ -2,9 +2,8 @@ #include "../pp.h" #include "exppp.h" -int main() -{ - char *testarr[] = { +int main() { + char * testarr[] = { "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION_RELATIONSHIP.RELATED_PRODUCT_DEFINITION", "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION" }; @@ -13,29 +12,29 @@ int main() /* globals */ exppp_fp = stdout; exppp_linelength = 40; - /* - indent2 = 30; - curpos = 20; - */ - for(i = 0; i < exppp_linelength + 10; i += 15) { - for(c = 2; c < exppp_linelength + 10; c += 13) { +/* + indent2 = 30; + curpos = 20; +*/ + for( i = 0; i < exppp_linelength + 10; i += 15 ) { + for( c = 2; c < exppp_linelength + 10; c += 13 ) { curpos = c; indent2 = i; - raw("indent2: %d, curpos: %d\n%*s||", i, c, c, ""); - breakLongStr(testarr[0]); + raw( "indent2: %d, curpos: %d\n%*s||", i, c, c, "" ); + breakLongStr( testarr[0] ); curpos = c; indent2 = i; - raw("\n%*s||", c, ""); - breakLongStr(testarr[1]); - raw("\n"); + raw( "\n%*s||", c, "" ); + breakLongStr( testarr[1] ); + raw( "\n" ); } } curpos = 77; exppp_linelength = 130; indent2 = 17; - raw("\n%*s||", 77, ""); - breakLongStr(testarr[0]); - raw("\n"); + raw( "\n%*s||", 77, "" ); + breakLongStr( testarr[0] ); + raw( "\n" ); return EXIT_SUCCESS; } diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 409d974ee..5ef962c83 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -4,29 +4,58 @@ include_directories( ${SC_SOURCE_DIR}/src/base ) +# Set up the information we need to feed the generated source management +# scripts +set(BASELINE_INFORMATION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/generated/verification_info.cmake") +set(PROJECT_CMAKE_DIR "${SC_SOURCE_DIR}/cmake") +set(MD5_FILELIST + "${CMAKE_CURRENT_SOURCE_DIR}/expscan.l" + "${CMAKE_CURRENT_SOURCE_DIR}/expparse.y" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h" + ) +configure_file(${SC_SOURCE_DIR}/cmake/md5_gen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake @ONLY) +configure_file(${SC_SOURCE_DIR}/cmake/md5_verify.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake @ONLY) + +# Convenience target to generate an updated verification_info.cmake file +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel + ) +add_custom_target(express_md5gen DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel) + +# Target for actually checking cached MD5 sums against files +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel + DEPENDS ${MD5_FILELIST} + ) +add_custom_target(express_verify DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel) + + # Depending on whether we're using pre-generated sources or building them on # the fly, set up targets and source lists. if(SC_GENERATE_LP_SOURCES) LEMON_TARGET(ExpParser expparse.y) PERPLEX_TARGET(ExpScanner expscan.l) ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner ExpParser) - include_directories( - ${LEMON_ExpParser_INCLUDE_DIR} - ${PERPLEX_ExpScanner_INCLUDE_DIR} - ) + + add_library(objlib_expscan_c OBJECT ${PERPLEX_ExpScanner_SRC}) + set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + + add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_SRC}) + set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + else(SC_GENERATE_LP_SOURCES) - set(LEMON_ExpParser_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c) - set(LEMON_ExpParser_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h) - set(PERPLEX_ExpScanner_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c) - set(PERPLEX_ExpScanner_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/generated) + add_subdirectory(generated) + include_directories(generated) endif(SC_GENERATE_LP_SOURCES) set(EXPRESS_SOURCES - ${LEMON_ExpParser_HDR} - ${LEMON_ExpParser_SRC} - ${PERPLEX_ExpScanner_HDR} - ${PERPLEX_ExpScanner_SRC} symbol.c type.c variable.c @@ -51,42 +80,30 @@ set(EXPRESS_SOURCES ordered_attrs.cc info.c factory.c - ) + ) + +set(EXPRESS_OBJS) +foreach(_src ${EXPRESS_SOURCES}) + string(REPLACE "." "_" _suffix ${_src}) + set(_objlib "objlib_${_suffix}") + add_library(${_objlib} OBJECT ${_src}) + # TODO: probably PIC should be used everywhere... + set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) + list(APPEND EXPRESS_OBJS $) +endforeach() -add_library(express-obj OBJECT ${EXPRESS_SOURCES}) -add_dependencies(express-obj base) -if(MSVC) - set_property(TARGET express-obj APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") -endif(MSVC) - - -add_library(express SHARED ${EXPRESS_SOURCES}) -target_link_libraries(express base) -if(OPENBSD) - set_target_properties(express PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) -else(OPENBSD) - set_target_properties(express PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) -endif(OPENBSD) -if(APPLE) - set_property(TARGET express APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress") -endif(APPLE) -install(TARGETS express - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) - -if(MSVC) - set_property(TARGET express APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") - set_property(TARGET express APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") -endif(MSVC) - -if (BUILD_STATIC_LIBS) - add_library(express-static STATIC ${EXPRESS_SOURCES}) - install(TARGETS express-static - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) -endif (BUILD_STATIC_LIBS) +list(APPEND EXPRESS_OBJS $) +list(APPEND EXPRESS_OBJS $) + + +if(SC_GENERATE_LP_SOURCES) + set_property(TARGET objlib_expparse_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") + set_property(TARGET objlib_expscan_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + # OBJECT libraries are not targets, and so an explicit dependency is required + set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") +endif() # TODO # Currently, fedex.c provides the main() for multiple programs. These programs @@ -101,13 +118,51 @@ set(CHECK_EXPRESS_SOURCES fedex.c inithook.c ) -add_executable(check-express ${CHECK_EXPRESS_SOURCES}) -target_link_libraries(check-express express base) -install(TARGETS check-express - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) +SET(EXPRESS_PRIVATE_HDRS + exptoks.h + stack.h + ) + +variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) +variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) + if(WIN32) + target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) + endif() + + if(SC_GENERATE_LP_SOURCES) + add_custom_command(TARGET express POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + ) + else() + add_dependencies(express express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express version_string) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) + + if(SC_GENERATE_LP_SOURCES) + add_custom_command(TARGET express-static POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + ) + else() + add_dependencies(express-static express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express-static version_string) + endif() +endif() + +SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/express/alg.c b/src/express/alg.c index f4966691e..2211eff1a 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -48,11 +48,10 @@ struct freelist_head RULE_fl; struct freelist_head PROC_fl; struct freelist_head WHERE_fl; -Scope ALGcreate(char type) -{ - Scope s = SCOPEcreate(type); +Scope ALGcreate( char type ) { + Scope s = SCOPEcreate( type ); - switch(type) { + switch( type ) { case OBJ_PROCEDURE: s->u.proc = PROC_new(); break; @@ -74,13 +73,11 @@ Scope ALGcreate(char type) */ /** Initialize the Algorithm module. */ -void ALGinitialize(void) -{ +void ALGinitialize( void ) { } -void ALGput_full_text(Scope s, int start, int end) -{ - switch(s->type) { +void ALGput_full_text( Scope s, int start, int end ) { + switch( s->type ) { case OBJ_FUNCTION: s->u.func->text.filename = s->symbol.filename; s->u.func->text.start = start; diff --git a/src/express/alloc.c b/src/express/alloc.c index 4fae5d50e..e20cfa943 100644 --- a/src/express/alloc.c +++ b/src/express/alloc.c @@ -49,11 +49,10 @@ Now you can say things like: * \param flh freelist head * \param bytes new memory size */ -Freelist *create_freelist(struct freelist_head *flh, int bytes) -{ - Freelist *current = (Freelist *)malloc(bytes); - if(current == 0) { - return(0); +Freelist * create_freelist( struct freelist_head * flh, int bytes ) { + Freelist * current = ( Freelist * )malloc( bytes ); + if( current == 0 ) { + return( 0 ); } flh->freelist = current; @@ -62,25 +61,24 @@ Freelist *create_freelist(struct freelist_head *flh, int bytes) flh->create++; /* set max to point to end of freelist */ - if((char *)flh->freelist + bytes > (char *)flh->max) { - flh->max = (char *)flh->freelist + bytes; + if( ( char * )flh->freelist + bytes > ( char * )flh->max ) { + flh->max = ( char * )flh->freelist + bytes; } #endif - while((char *)current + flh->size < - ((char *)flh->freelist + bytes)) { - current->next = (Freelist *)(¤t->memory + flh->size); + while( ( char * )current + flh->size < + ( ( char * )flh->freelist + bytes ) ) { + current->next = ( Freelist * )( ¤t->memory + flh->size ); current = current->next; } current->next = NULL; - return(current); + return( current ); } void -_ALLOCinitialize() -{ +_ALLOCinitialize() { #ifdef DEBUG_MALLOC - malloc_debug(2); + malloc_debug( 2 ); #endif } @@ -90,8 +88,7 @@ _ALLOCinitialize() * \param alloc1 number to allocate initially * \param alloc2 number to allocate if we run out */ -void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2) -{ +void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) { flh->size_elt = size; /* kludge for calloc-like behavior */ #ifndef NOSTAT flh->alloc = flh->dealloc = flh->create = 0; @@ -99,7 +96,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i #endif /* make block large enough to hold the linked list pointer */ - flh->size = (size > sizeof(Freelist *) ? size : sizeof(Freelist *)); + flh->size = ( size > sizeof( Freelist * ) ? size : sizeof( Freelist * ) ); /* set up for future allocations */ flh->bytes = flh->size * alloc2; @@ -107,7 +104,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i return; /*NOTREACHED*/ #else - if(0 == create_freelist(flh, flh->size * alloc1)) { + if( 0 == create_freelist( flh, flh->size * alloc1 ) ) { ERRORnospace(); } @@ -118,8 +115,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i #endif } -void *ALLOC_new(struct freelist_head *flh) -{ +void * ALLOC_new( struct freelist_head * flh ) { void *obj; #ifndef NOSTAT @@ -127,10 +123,10 @@ void *ALLOC_new(struct freelist_head *flh) #endif #ifdef REAL_MALLOC - return(calloc(1, flh->size_elt)); + return( calloc( 1, flh->size_elt ) ); /*NOTREACHED*/ #else - if(flh->freelist == NULL && 0 == create_freelist(flh, flh->bytes)) { + if( flh->freelist == NULL && 0 == create_freelist( flh, flh->bytes ) ) { ERRORnospace(); } @@ -138,7 +134,7 @@ void *ALLOC_new(struct freelist_head *flh) flh->freelist = flh->freelist->next; #ifndef NOSTAT - if(obj > flh->max) { + if( obj > flh->max ) { abort(); } #endif @@ -148,20 +144,19 @@ void *ALLOC_new(struct freelist_head *flh) #endif /*SPACE_PROFILE*/ /* calloc-like */ - memset(obj, 0, flh->size_elt); + memset( obj, 0, flh->size_elt ); - return(obj); + return( obj ); #endif } -void ALLOC_destroy(struct freelist_head *flh, Freelist *link) -{ +void ALLOC_destroy( struct freelist_head * flh, Freelist * link ) { #ifndef NOSTAT flh->dealloc++; #endif #ifdef REAL_MALLOC - free(link); + free( link ); return; /*NOTREACHED*/ #else @@ -186,35 +181,34 @@ struct oct { char a[16]; }; -main() -{ - struct oct *o1, *o2, *o3, *o4, *o5, *o6; +main() { + struct oct * o1, *o2, *o3, *o4, *o5, *o6; - memory_init(&oct_freelist, sizeof(struct oct), 5, 2); + memory_init( &oct_freelist, sizeof( struct oct ), 5, 2 ); o1 = new_oct(); - fprintf(stderr, "o1 = %x\n", o1); + fprintf( stderr, "o1 = %x\n", o1 ); o2 = new_oct(); - fprintf(stderr, "o2 = %x\n", o2); + fprintf( stderr, "o2 = %x\n", o2 ); o3 = new_oct(); - fprintf(stderr, "o3 = %x\n", o3); + fprintf( stderr, "o3 = %x\n", o3 ); o4 = new_oct(); - fprintf(stderr, "o4 = %x\n", o4); + fprintf( stderr, "o4 = %x\n", o4 ); o5 = new_oct(); - fprintf(stderr, "o5 = %x\n", o5); + fprintf( stderr, "o5 = %x\n", o5 ); o6 = new_oct(); - fprintf(stderr, "o6 = %x\n", o6); - destroy_oct(o1); - destroy_oct(o2); + fprintf( stderr, "o6 = %x\n", o6 ); + destroy_oct( o1 ); + destroy_oct( o2 ); o1 = new_oct(); - fprintf(stderr, "o1 = %x\n", o1); + fprintf( stderr, "o1 = %x\n", o1 ); o2 = new_oct(); - fprintf(stderr, "o2 = %x\n", o2); + fprintf( stderr, "o2 = %x\n", o2 ); o3 = new_oct(); - fprintf(stderr, "o3 = %x\n", o3); + fprintf( stderr, "o3 = %x\n", o3 ); o4 = new_oct(); - fprintf(stderr, "o4 = %x\n", o4); + fprintf( stderr, "o4 = %x\n", o4 ); o5 = new_oct(); - fprintf(stderr, "o5 = %x\n", o5); + fprintf( stderr, "o5 = %x\n", o5 ); } #endif /*ALLOC_MAIN*/ diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 67a06d4e8..fe8aa460f 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -34,8 +34,7 @@ /** Initialize the Case Item module. */ void -CASE_ITinitialize(void) -{ +CASE_ITinitialize( void ) { } /** @@ -48,11 +47,10 @@ CASE_ITinitialize(void) ** \note If the 'labels' parameter is LIST_NULL, a case item ** matching in the default case is created. */ -Case_Item CASE_ITcreate(Linked_List labels, Statement statement) -{ +Case_Item CASE_ITcreate( Linked_List labels, Statement statement ) { struct Case_Item_ *s = CASE_IT_new(); s->labels = labels; s->action = statement; - return(s); + return( s ); } diff --git a/src/express/dict.c b/src/express/dict.c index 506daf473..69d8d1dd8 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -39,28 +39,25 @@ char DICT_type; /**< set to type of object found, as a side-effect of DICT lookup routines */ -void DICTprint(Dictionary dict) -{ +void DICTprint( Dictionary dict ) { Element e; DictionaryEntry de; - HASHlistinit(dict, &de); + HASHlistinit( dict, &de ); - while(0 != (e = (HASHlist(&de)))) { - fprintf(stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", + while( 0 != ( e = ( HASHlist( &de ) ) ) ) { + fprintf( stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", e->key, e->data, e->symbol->line, e->type, - OBJget_type(e->type), e->symbol->filename); + OBJget_type( e->type ), e->symbol->filename ); } } /** Initialize the Dictionary module */ -void DICTinitialize(void) -{ +void DICTinitialize( void ) { } /** Clean up the Dictionary module */ -void DICTcleanup(void) -{ +void DICTcleanup( void ) { } /** @@ -68,8 +65,7 @@ void DICTcleanup(void) * error directly if there is a duplicate value. * \return 0 on success, 1 on failure */ -int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) -{ +int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ new, *old; new.key = name; @@ -77,8 +73,8 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) new.symbol = sym; new.type = type; - if(0 == (old = HASHsearch(dict, &new, HASH_INSERT))) { - return(0); + if( 0 == ( old = HASHsearch( dict, &new, HASH_INSERT ) ) ) { + return( 0 ); } /* allow multiple definitions of an enumeration id in its @@ -91,20 +87,20 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) * to have the same name. To fix this, I replaced the * || with && in the else-if below. */ - if((type == OBJ_ENUM) && (old->type == OBJ_ENUM)) { + if( ( type == OBJ_ENUM ) && ( old->type == OBJ_ENUM ) ) { /* if we're adding an enum, but we've already seen one */ /* (and only one enum), mark it ambiguous */ - DICTchange_type(old, OBJ_AMBIG_ENUM); - } else if((type != OBJ_ENUM) && (!IS_ENUM(old->type))) { + DICTchange_type( old, OBJ_AMBIG_ENUM ); + } else if( ( type != OBJ_ENUM ) && ( !IS_ENUM( old->type ) ) ) { /* if we're adding a non-enum, and we've * * already added a non-enum, complain */ - if(sym->filename == old->symbol->filename) { - ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, old->symbol->line); + if( sym->filename == old->symbol->filename ) { + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, old->symbol->line ); } else { - ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename ); } ERRORreport(SUBORDINATE_FAILED); - return(1); + return( 1 ); } return 0; } @@ -117,8 +113,7 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) * their unusual behavior with respect to scoping and visibility rules * \sa DICTdefine() */ -int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) -{ +int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ e, *e2; e.key = name; @@ -126,17 +121,17 @@ int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) e.symbol = sym; e.type = type; - if(0 == (e2 = HASHsearch(dict, &e, HASH_INSERT))) { - return(0); + if( 0 == ( e2 = HASHsearch( dict, &e, HASH_INSERT ) ) ) { + return( 0 ); } - if(sym->filename == e2->symbol->filename) { - ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, e2->symbol->line); + if( sym->filename == e2->symbol->filename ) { + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, e2->symbol->line ); } else { - ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename ); } ERRORreport(SUBORDINATE_FAILED); - return(1); + return( 1 ); } /** @@ -146,12 +141,11 @@ int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) Changed to return void, since the hash code frees the element, there is no way to return (without godawful casting) the generic itself. */ -void DICTundefine(Dictionary dict, char *name) -{ +void DICTundefine( Dictionary dict, char * name ) { struct Element_ e; e.key = name; - HASHsearch(dict, &e, HASH_DELETE); + HASHsearch( dict, &e, HASH_DELETE ); } /** @@ -159,47 +153,44 @@ void DICTundefine(Dictionary dict, char *name) ** \param name name to look up ** \return the value found, NULL if not found */ -void *DICTlookup(Dictionary dictionary, char *name) -{ +void *DICTlookup( Dictionary dictionary, char * name ) { struct Element_ e, *ep; - if(!dictionary) { + if( !dictionary ) { return 0; } e.key = name; - ep = HASHsearch(dictionary, &e, HASH_FIND); - if(ep) { + ep = HASHsearch( dictionary, &e, HASH_FIND ); + if( ep ) { DICT_type = ep->type; - return(ep->data); + return( ep->data ); } - return(NULL); + return( NULL ); } /** like DICTlookup but returns symbol, too * \sa DICTlookup() */ -void *DICTlookup_symbol(Dictionary dictionary, char *name, Symbol **sym) -{ +void *DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { struct Element_ e, *ep; - if(!dictionary) { + if( !dictionary ) { return 0; } e.key = name; - ep = HASHsearch(dictionary, &e, HASH_FIND); - if(ep) { + ep = HASHsearch( dictionary, &e, HASH_FIND ); + if( ep ) { DICT_type = ep->type; *sym = ep->symbol; - return(ep->data); + return( ep->data ); } - return(NULL); + return( NULL ); } -void *DICTdo(DictionaryEntry *dict_entry) -{ - if(0 == HASHlist(dict_entry)) { +void *DICTdo( DictionaryEntry * dict_entry ) { + if( 0 == HASHlist( dict_entry ) ) { return 0; } diff --git a/src/express/entity.c b/src/express/entity.c index 506f0450a..507b2c23f 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -120,10 +120,9 @@ int ENTITY_MARK = 0; /** returns true if variable is declared (or redeclared) directly by entity */ -int ENTITYdeclares_variable(Entity e, Variable v) -{ - LISTdo(e->u.entity->attributes, attr, Variable) - if(attr == v) { +int ENTITYdeclares_variable( Entity e, Variable v ) { + LISTdo( e->u.entity->attributes, attr, Variable ) + if( attr == v ) { return true; } LISTod; @@ -131,8 +130,7 @@ int ENTITYdeclares_variable(Entity e, Variable v) return false; } -static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) -{ +static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down ) { Entity result; /* avoid searching scopes that we've already searched */ @@ -140,34 +138,34 @@ static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if(entity->search_id == __SCOPE_search_id) { + if( entity->search_id == __SCOPE_search_id ) { return NULL; } entity->search_id = __SCOPE_search_id; - LISTdo(entity->u.entity->supertypes, super, Entity) - if(!strcmp(super->symbol.name, name)) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + if( !strcmp( super->symbol.name, name ) ) { return super; } LISTod - LISTdo(entity->u.entity->supertypes, super, Entity) - result = ENTITY_find_inherited_entity(super, name, down); - if(result) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + result = ENTITY_find_inherited_entity( super, name, down ); + if( result ) { return result; } LISTod; - if(down) { - LISTdo(entity->u.entity->subtypes, sub, Entity) - if(!strcmp(sub->symbol.name, name)) { + if( down ) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + if( !strcmp( sub->symbol.name, name ) ) { return sub; } LISTod; - LISTdo(entity->u.entity->subtypes, sub, Entity) - result = ENTITY_find_inherited_entity(sub, name, down); - if(result) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + result = ENTITY_find_inherited_entity( sub, name, down ); + if( result ) { return result; } LISTod; @@ -176,19 +174,17 @@ static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) return 0; } -struct Scope_ *ENTITYfind_inherited_entity(struct Scope_ *entity, char *name, int down) -{ - if(!strcmp(name, entity->symbol.name)) { - return(entity); +struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { + if( !strcmp( name, entity->symbol.name ) ) { + return( entity ); } __SCOPE_search_id++; - return ENTITY_find_inherited_entity(entity, name, down); + return ENTITY_find_inherited_entity( entity, name, down ); } /** find a (possibly inherited) attribute */ -Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, struct Symbol_ **where) -{ +Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct Symbol_ ** where ) { Variable result; /* avoid searching scopes that we've already searched */ @@ -196,34 +192,34 @@ Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, s /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if(entity->search_id == __SCOPE_search_id) { + if( entity->search_id == __SCOPE_search_id ) { return NULL; } entity->search_id = __SCOPE_search_id; /* first look locally */ - result = (Variable)DICTlookup(entity->symbol_table, name); - if(result) { - if(down && *down && where) { + result = ( Variable )DICTlookup( entity->symbol_table, name ); + if( result ) { + if( down && *down && where ) { *where = &entity->symbol; } return result; } /* check supertypes */ - LISTdo(entity->u.entity->supertypes, super, Entity) - result = ENTITY_find_inherited_attribute(super, name, down, where); - if(result) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + result = ENTITY_find_inherited_attribute( super, name, down, where ); + if( result ) { return result; } LISTod; /* check subtypes, if requested */ - if(down) { + if( down ) { ++*down; - LISTdo(entity->u.entity->subtypes, sub, Entity) - result = ENTITY_find_inherited_attribute(sub, name, down, where); - if(result) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + result = ENTITY_find_inherited_attribute( sub, name, down, where ); + if( result ) { return result; } LISTod; @@ -233,54 +229,52 @@ Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, s return 0; } -Variable ENTITYfind_inherited_attribute(struct Scope_ *entity, char *name, - struct Symbol_ **down_sym) -{ +Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, + struct Symbol_ ** down_sym ) { extern int __SCOPE_search_id; int down_flag = 0; __SCOPE_search_id++; - if(down_sym) { - return ENTITY_find_inherited_attribute(entity, name, &down_flag, down_sym); + if( down_sym ) { + return ENTITY_find_inherited_attribute( entity, name, &down_flag, down_sym ); } else { - return ENTITY_find_inherited_attribute(entity, name, 0, 0); + return ENTITY_find_inherited_attribute( entity, name, 0, 0 ); } } /** resolve a (possibly group-qualified) attribute ref. * report errors as appropriate */ -Variable ENTITYresolve_attr_ref(Entity e, Symbol *grp_ref, Symbol *attr_ref) -{ +Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { Entity ref_entity; Variable attr; struct Symbol_ *where; - if(grp_ref) { + if( grp_ref ) { /* use entity provided in group reference */ - ref_entity = ENTITYfind_inherited_entity(e, grp_ref->name, 0); - if(!ref_entity) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name); + ref_entity = ENTITYfind_inherited_entity( e, grp_ref->name, 0 ); + if( !ref_entity ) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name ); return 0; } - attr = (Variable)DICTlookup(ref_entity->symbol_table, - attr_ref->name); - if(!attr) { + attr = ( Variable )DICTlookup( ref_entity->symbol_table, + attr_ref->name ); + if( !attr ) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, attr_ref, attr_ref->name, - ref_entity->symbol.name); + ref_entity->symbol.name ); /* resolve_failed(e);*/ } } else { /* no entity provided, look through supertype chain */ where = NULL; - attr = ENTITYfind_inherited_attribute(e, attr_ref->name, &where); - if(!attr /* was ref_entity? */) { + attr = ENTITYfind_inherited_attribute( e, attr_ref->name, &where ); + if( !attr /* was ref_entity? */ ) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, - attr_ref, attr_ref->name, - e->symbol.name); - } else if(where != NULL) { + attr_ref, attr_ref->name, + e->symbol.name ); + } else if( where != NULL ) { ERRORreport_with_symbol(IMPLICIT_DOWNCAST, attr_ref, - where->name); + where->name ); } } return attr; @@ -290,8 +284,7 @@ Variable ENTITYresolve_attr_ref(Entity e, Symbol *grp_ref, Symbol *attr_ref) * currently, this is only used by USEresolve * low-level function for type Entity */ -Entity ENTITYcopy(Entity e) -{ +Entity ENTITYcopy( Entity e ) { /* for now, do a totally shallow copy */ Entity e2 = SCOPE_new(); *e2 = *e; @@ -299,8 +292,7 @@ Entity ENTITYcopy(Entity e) } /** Initialize the Entity module. */ -void ENTITYinitialize() -{ +void ENTITYinitialize() { } /** @@ -308,22 +300,21 @@ void ENTITYinitialize() ** \param attr attribute to add ** Add an attribute to an entity. */ -void ENTITYadd_attribute(Entity entity, Variable attr) -{ +void ENTITYadd_attribute( Entity entity, Variable attr ) { int rc; - if(attr->name->type->u.type->body->type != op_) { + if( attr->name->type->u.type->body->type != op_ ) { /* simple id */ - rc = DICTdefine(entity->symbol_table, attr->name->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE); + rc = DICTdefine( entity->symbol_table, attr->name->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE ); } else { /* SELF\ENTITY.SIMPLE_ID */ - rc = DICTdefine(entity->symbol_table, attr->name->e.op2->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE); + rc = DICTdefine( entity->symbol_table, attr->name->e.op2->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE ); } - if(rc == 0) { - LISTadd_last(entity->u.entity->attributes, attr); - VARput_offset(attr, entity->u.entity->attribute_count); + if( rc == 0 ) { + LISTadd_last( entity->u.entity->attributes, attr ); + VARput_offset( attr, entity->u.entity->attribute_count ); entity->u.entity->attribute_count++; } } @@ -333,12 +324,11 @@ void ENTITYadd_attribute(Entity entity, Variable attr) ** \param instance new instance ** Add an item to the instance list of an entity. */ -void ENTITYadd_instance(Entity entity, void *instance) -{ - if(entity->u.entity->instances == LIST_NULL) { +void ENTITYadd_instance( Entity entity, void *instance ) { + if( entity->u.entity->instances == LIST_NULL ) { entity->u.entity->instances = LISTcreate(); } - LISTadd_last(entity->u.entity->instances, instance); + LISTadd_last( entity->u.entity->instances, instance ); } /** @@ -347,13 +337,12 @@ void ENTITYadd_instance(Entity entity, void *instance) ** \return does child's superclass chain include parent? ** Look for a certain entity in the supertype graph of an entity. */ -bool ENTITYhas_supertype(Entity child, Entity parent) -{ - LISTdo(child->u.entity->supertypes, entity, Entity) - if(entity == parent) { +bool ENTITYhas_supertype( Entity child, Entity parent ) { + LISTdo( child->u.entity->supertypes, entity, Entity ) + if( entity == parent ) { return true; } - if(ENTITYhas_supertype(entity, parent)) { + if( ENTITYhas_supertype( entity, parent ) ) { return true; } LISTod; @@ -366,10 +355,9 @@ bool ENTITYhas_supertype(Entity child, Entity parent) ** \return is parent a direct supertype of child? ** Check whether an entity has a specific immediate superclass. */ -bool ENTITYhas_immediate_supertype(Entity child, Entity parent) -{ - LISTdo(child->u.entity->supertypes, entity, Entity) - if(entity == parent) { +bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) { + LISTdo( child->u.entity->supertypes, entity, Entity ) + if( entity == parent ) { return true; } LISTod; @@ -377,15 +365,14 @@ bool ENTITYhas_immediate_supertype(Entity child, Entity parent) } /** called by ENTITYget_all_attributes(). \sa ENTITYget_all_attributes */ -static void ENTITY_get_all_attributes(Entity entity, Linked_List result) -{ - LISTdo(entity->u.entity->supertypes, super, Entity) +static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) { + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity))*/ - ENTITY_get_all_attributes(super, result); + ENTITY_get_all_attributes( super, result ); LISTod; /* Gee, aren't they resolved by this time? */ - LISTdo(entity->u.entity->attributes, attr, void *) - LISTadd_last(result, attr); + LISTdo( entity->u.entity->attributes, attr, void * ) + LISTadd_last( result, attr ); LISTod; } @@ -400,11 +387,10 @@ static void ENTITY_get_all_attributes(Entity entity, Linked_List result) ** attributes, this call returns an empty list. Note ** that this is distinct from the constant LIST_NULL. */ -Linked_List ENTITYget_all_attributes(Entity entity) -{ +Linked_List ENTITYget_all_attributes( Entity entity ) { Linked_List result = LISTcreate(); - ENTITY_get_all_attributes(entity, result); + ENTITY_get_all_attributes( entity, result ); return result; } @@ -417,19 +403,18 @@ Linked_List ENTITYget_all_attributes(Entity entity) ** \note If the entity has no attribute with the given name, ** VARIABLE_NULL is returned. */ -Variable ENTITYget_named_attribute(Entity entity, char *name) -{ +Variable ENTITYget_named_attribute( Entity entity, char * name ) { Variable attribute; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(!strcmp(VARget_simple_name(attr), name)) { + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( !strcmp( VARget_simple_name( attr ), name ) ) { return attr; } LISTod; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity) && */ - if(0 != (attribute = ENTITYget_named_attribute(super, name))) { + if( 0 != ( attribute = ENTITYget_named_attribute( super, name ) ) ) { return attribute; } LISTod; @@ -445,23 +430,22 @@ Variable ENTITYget_named_attribute(Entity entity, char *name) ** \note If the entity does not include the attribute, -1 ** is returned. */ -int ENTITYget_attribute_offset(Entity entity, Variable attribute) -{ +int ENTITYget_attribute_offset( Entity entity, Variable attribute ) { int offset; int value; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(attr == attribute) { - return entity->u.entity->inheritance + VARget_offset(attribute); + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( attr == attribute ) { + return entity->u.entity->inheritance + VARget_offset( attribute ); } LISTod; offset = 0; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if((value = ENTITYget_attribute_offset(super, attribute)) != -1) { + if( ( value = ENTITYget_attribute_offset( super, attribute ) ) != -1 ) { return value + offset; } - offset += ENTITYget_initial_offset(super); + offset += ENTITYget_initial_offset( super ); /* }*/ LISTod; return -1; @@ -476,23 +460,22 @@ int ENTITYget_attribute_offset(Entity entity, Variable attribute) ** \note If the entity has no attribute with the given name, ** -1 is returned. */ -int ENTITYget_named_attribute_offset(Entity entity, char *name) -{ +int ENTITYget_named_attribute_offset( Entity entity, char * name ) { int offset; int value; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(!strcmp(VARget_simple_name(attr), name)) + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( !strcmp( VARget_simple_name( attr ), name ) ) return entity->u.entity->inheritance + - VARget_offset(ENTITY_find_inherited_attribute(entity, name, 0, 0)); + VARget_offset( ENTITY_find_inherited_attribute( entity, name, 0, 0 ) ); LISTod; offset = 0; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if((value = ENTITYget_named_attribute_offset(super, name)) != -1) { + if( ( value = ENTITYget_named_attribute_offset( super, name ) ) != -1 ) { return value + offset; } - offset += ENTITYget_initial_offset(super); + offset += ENTITYget_initial_offset( super ); /* }*/ LISTod; return -1; @@ -503,7 +486,6 @@ int ENTITYget_named_attribute_offset(Entity entity, char *name) ** \return number of inherited attributes ** Retrieve the initial offset to an entity's local frame. */ -int ENTITYget_initial_offset(Entity entity) -{ +int ENTITYget_initial_offset( Entity entity ) { return entity->u.entity->inheritance; } diff --git a/src/express/error.c b/src/express/error.c index 5d47a8e57..04bcc4154 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -98,10 +98,8 @@ static struct Error_ LibErrors[] = { [FILE_UNREADABLE] = {SEVERITY_ERROR, "Could not read file %s: %s", NULL, false}, [FILE_UNWRITABLE] = {SEVERITY_ERROR, "Could not write file %s: %s", NULL, false}, [WARN_UNSUPPORTED_LANG_FEAT] = {SEVERITY_WARNING, "Unsupported language feature (%s) at %s:%d", "unsupported", false}, - [WARN_SMALL_REAL] = { - SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " - "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false - }, + [WARN_SMALL_REAL] = {SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " + "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false}, /* lexact.c */ [INCLUDE_FILE] = {SEVERITY_ERROR, "Could not open include file `%s'.", NULL, false}, [UNMATCHED_CLOSE_COMMENT] = {SEVERITY_ERROR, "unmatched close comment", NULL, false}, @@ -159,7 +157,7 @@ static struct Error_ LibErrors[] = { bool __ERROR_buffer_errors = false; -const char *current_filename = "stdin"; +const char * current_filename = "stdin"; /* flag to remember whether non-warning errors have occurred */ bool ERRORoccurred = false; @@ -176,7 +174,7 @@ int malloc_debug_resolve = 0; /* for debugging yacc/lex */ int debug = 0; -void (*ERRORusage_function)(void); +void ( *ERRORusage_function )( void ); #define ERROR_MAX_ERRORS 100 /**< max line-numbered errors */ #define ERROR_MAX_SPACE 4000 /**< max space for line-numbered errors */ @@ -187,16 +185,16 @@ void (*ERRORusage_function)(void); static struct heap_element { int line; - char *msg; + char * msg; } heap[ERROR_MAX_ERRORS + 1]; /**< NOTE! element 0 is purposely ignored, and * an additional element is at the end. This * allows the later heap calculations to be * much simpler */ static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */ -static char *ERROR_string; -static char *ERROR_string_base; -static char *ERROR_string_end; +static char * ERROR_string; +static char * ERROR_string_base; +static char * ERROR_string_end; static bool ERROR_unsafe = false; static jmp_buf ERROR_safe_env; @@ -204,9 +202,8 @@ static jmp_buf ERROR_safe_env; #define error_file stderr /**< message buffer file */ -static int ERROR_vprintf(const char *format, va_list ap) -{ - int result = vsnprintf(ERROR_string, ERROR_string_end - ERROR_string, format, ap); +static int ERROR_vprintf( const char *format, va_list ap ) { + int result = vsnprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); if(result < 0) { ERROR_string = ERROR_string_end; @@ -218,109 +215,102 @@ static int ERROR_vprintf(const char *format, va_list ap) return result; } -static int ERROR_printf(const char *format, ...) -{ +static int ERROR_printf( const char *format, ... ) { int result; va_list ap; - va_start(ap, format); - result = ERROR_vprintf(format, ap); - va_end(ap); + va_start( ap, format ); + result = ERROR_vprintf( format, ap ); + va_end( ap ); return result; } -static void ERROR_nexterror() -{ - if(ERROR_string == ERROR_string_end) { +static void ERROR_nexterror() { + if( ERROR_string == ERROR_string_end ) { return; } ERROR_string++; } /** Initialize the Error module */ -void ERRORinitialize(void) -{ - ERROR_string_base = (char *)sc_malloc(ERROR_MAX_SPACE); +void ERRORinitialize( void ) { + ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); #ifdef SIGQUIT - signal(SIGQUIT, ERRORabort); + signal( SIGQUIT, ERRORabort ); #endif #ifdef SIGBUS - signal(SIGBUS, ERRORabort); + signal( SIGBUS, ERRORabort ); #endif #ifdef SIGSEGV - signal(SIGSEGV, ERRORabort); + signal( SIGSEGV, ERRORabort ); #endif #ifdef SIGABRT - signal(SIGABRT, ERRORabort); + signal( SIGABRT, ERRORabort ); #endif } /** Clean up the Error module */ -void ERRORcleanup(void) -{ - sc_free(ERROR_string_base); +void ERRORcleanup( void ) { + sc_free( ERROR_string_base ); } -void ERRORset_warning(char *name, bool warn_only) -{ +void ERRORset_warning(char * name, bool warn_only) { Error err; bool found = false; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { + if (err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { found = true; err->override = warn_only; } - } - - if(!found) { - fprintf(stderr, "unknown warning: %s\n", name); - if(ERRORusage_function) { - (*ERRORusage_function)(); + } + + if (!found) { + fprintf( stderr, "unknown warning: %s\n", name ); + if( ERRORusage_function ) { + ( *ERRORusage_function )(); } else { EXPRESSusage(1); } } } -void ERRORset_all_warnings(bool warn_only) -{ +void ERRORset_all_warnings( bool warn_only ) { Error err; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->severity <= SEVERITY_WARNING) { + if (err->severity <= SEVERITY_WARNING) { err->override = warn_only; - } - } + } + } } -char *ERRORget_warnings_help(const char *prefix, const char *eol) -{ +char * ERRORget_warnings_help(const char* prefix, const char *eol) { unsigned int sz = 2048, len, clen; char *buf, *nbuf; Error err; - + clen = strlen(prefix) + strlen(eol) + 1; - + buf = sc_malloc(sz); - if(!buf) { + if (!buf) { fprintf(error_file, "failed to allocate memory for warnings help!\n"); } buf[0] = '\0'; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->name) { + if (err->name) { len = strlen(buf) + strlen(err->name) + clen; - if(len > sz) { + if (len > sz) { sz *= 2; nbuf = sc_realloc(buf, sz); - if(!nbuf) { - fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); + if (!nbuf) { + fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); } buf = nbuf; } @@ -329,13 +319,12 @@ char *ERRORget_warnings_help(const char *prefix, const char *eol) strcat(buf, eol); } } - + return buf; } bool -ERRORis_enabled(enum ErrorCode errnum) -{ +ERRORis_enabled(enum ErrorCode errnum) { Error err = &LibErrors[errnum]; return !err->override; } @@ -349,34 +338,33 @@ ERRORis_enabled(enum ErrorCode errnum) ** format fields of the message generated by 'what.' */ void -ERRORreport(enum ErrorCode errnum, ...) -{ +ERRORreport( enum ErrorCode errnum, ... ) { va_list args; - va_start(args, errnum); + va_start( args, errnum ); Error what = &LibErrors[errnum]; - if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { - if(what->severity >= SEVERITY_ERROR) { - fprintf(error_file, "ERROR PE%03d: ", errnum); - vfprintf(error_file, what->message, args); - fputc('\n', error_file); + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum) ) { + if( what->severity >= SEVERITY_ERROR ) { + fprintf( error_file, "ERROR PE%03d: ", errnum ); + vfprintf( error_file, what->message, args ); + fputc( '\n', error_file ); ERRORoccurred = true; } else { - fprintf(error_file, "WARNING PW%03d: %d", errnum, what->severity); - vfprintf(error_file, what->message, args); - fputc('\n', error_file); + fprintf( error_file, "WARNING PW%03d: %d", errnum, what->severity ); + vfprintf( error_file, what->message, args ); + fputc( '\n', error_file ); } - if(what->severity >= SEVERITY_EXIT) { + if( what->severity >= SEVERITY_EXIT ) { ERROR_flush_message_buffer(); - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } - va_end(args); + va_end( args ); } /** @@ -389,11 +377,10 @@ ERRORreport(enum ErrorCode errnum, ...) ** format fields of the message generated by 'what.' */ void -ERRORreport_with_line(enum ErrorCode errnum, int line, ...) -{ +ERRORreport_with_line( enum ErrorCode errnum, int line, ... ) { Symbol sym; va_list args; - va_start(args, line); + va_start( args, line ); sym.filename = current_filename; sym.line = line; @@ -401,14 +388,13 @@ ERRORreport_with_line(enum ErrorCode errnum, int line, ...) } void -ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) -{ +ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { va_list args; - va_start(args, sym); + va_start( args, sym ); Error what = &LibErrors[errnum]; - if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { - if(__ERROR_buffer_errors) { + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { + if( __ERROR_buffer_errors ) { int child, parent; /* @@ -420,8 +406,8 @@ ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) child = ++ERROR_with_lines; parent = child / 2; - while(parent) { - if(sym->line < heap[parent].line) { + while( parent ) { + if( sym->line < heap[parent].line ) { heap[child] = heap[parent]; } else { break; @@ -432,53 +418,52 @@ ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) heap[child].line = sym->line; heap[child].msg = ERROR_string; - if(what->severity >= SEVERITY_ERROR) { - ERROR_printf("%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); - ERROR_vprintf(what->message, args); + if( what->severity >= SEVERITY_ERROR ) { + ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); + ERROR_vprintf( what->message, args ); ERROR_nexterror(); ERRORoccurred = true; } else { - ERROR_printf("%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); - ERROR_vprintf(what->message, args); + ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); + ERROR_vprintf( what->message, args ); ERROR_nexterror(); } - if(what->severity >= SEVERITY_EXIT || + if( what->severity >= SEVERITY_EXIT || ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE || - ERROR_with_lines == ERROR_MAX_ERRORS) { + ERROR_with_lines == ERROR_MAX_ERRORS ) { ERROR_flush_message_buffer(); - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } else { - if(what->severity >= SEVERITY_ERROR) { - fprintf(error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); - vfprintf(error_file, what->message, args); - fprintf(error_file, "\n"); + if( what->severity >= SEVERITY_ERROR ) { + fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); + vfprintf( error_file, what->message, args ); + fprintf( error_file, "\n" ); ERRORoccurred = true; } else { - fprintf(error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); - vfprintf(error_file, what->message, args); - fprintf(error_file, "\n"); + fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); + vfprintf( error_file, what->message, args ); + fprintf( error_file, "\n" ); } - if(what->severity >= SEVERITY_EXIT) { - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_EXIT ) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } } - va_end(args); + va_end( args ); } -void ERRORnospace() -{ - fprintf(stderr, "%s: out of space\n", EXPRESSprogram_name); - ERRORabort(0); +void ERRORnospace() { + fprintf( stderr, "%s: out of space\n", EXPRESSprogram_name ); + ERRORabort( 0 ); } /** \fn ERRORbuffer_messages @@ -494,40 +479,38 @@ void ERRORnospace() ** \note The error messages are sorted by line number (which appears in the third column). */ -void ERROR_start_message_buffer(void) -{ +void ERROR_start_message_buffer( void ) { ERROR_string = ERROR_string_base; ERROR_with_lines = 0; } -void ERROR_flush_message_buffer(void) -{ +void ERROR_flush_message_buffer( void ) { if(!__ERROR_buffer_errors) { return; } - while(ERROR_with_lines) { - struct heap_element *replace; + while( ERROR_with_lines ) { + struct heap_element * replace; int parent, child; /* pop off the top of the heap */ - fprintf(stderr, "%s", heap[1].msg); + fprintf( stderr, "%s", heap[1].msg ); replace = &heap[ERROR_with_lines--]; child = 1; - while(1) { + while( 1 ) { parent = child; child = 2 * parent; - if(child > ERROR_with_lines) { + if( child > ERROR_with_lines ) { break; } - if(child + 1 <= ERROR_with_lines) { - if(heap[child].line > heap[child + 1].line) { + if( child + 1 <= ERROR_with_lines ) { + if( heap[child].line > heap[child + 1].line ) { child++; } } - if(replace->line <= heap[child].line) { + if( replace->line <= heap[child].line ) { break; } heap[parent] = heap[child]; @@ -536,32 +519,29 @@ void ERROR_flush_message_buffer(void) } } -void ERRORabort(int sig) -{ +void ERRORabort( int sig ) { (void) sig; /* quell unused param warning */ /* TODO: rework - fprintf is not atomic * so ERRORflush_messages() is unsafe if __ERROR_buffer_errors is set */ - + /* NOTE: signals can be caught in gdb, * no need for special treatment of debugging scenario */ - if(ERROR_unsafe) { - longjmp(ERROR_safe_env, 1); + if( ERROR_unsafe ) { + longjmp( ERROR_safe_env, 1 ); } #ifdef SIGABRT - signal(SIGABRT, SIG_DFL); + signal( SIGABRT, SIG_DFL ); #endif /* TODO: library shouldn't abort an application? */ abort(); } -void ERRORsafe(jmp_buf env) -{ - memcpy(ERROR_safe_env, env, sizeof(jmp_buf)); +void ERRORsafe( jmp_buf env ) { + memcpy( ERROR_safe_env, env, sizeof( jmp_buf ) ); } -void ERRORunsafe() -{ +void ERRORunsafe() { ERROR_unsafe = true; } diff --git a/src/express/exp_kw.c b/src/express/exp_kw.c index e765fa510..837e49393 100644 --- a/src/express/exp_kw.c +++ b/src/express/exp_kw.c @@ -1,122 +1,122 @@ #include "express/exp_kw.h" -char *KW_ABS = "ABS"; -char *KW_ABSTRACT = "ABSTRACT"; -char *KW_ACOS = "ACOS"; -char *KW_AGGREGATE = "AGGREGATE"; -char *KW_ALIAS = "ALIAS"; -char *KW_AND = "AND"; -char *KW_ANDOR = "ANDOR"; -char *KW_ARRAY = "ARRAY"; -char *KW_AS = "AS"; -char *KW_ASIN = "ASIN"; -char *KW_ATAN = "ATAN"; -char *KW_BAG = "BAG"; -char *KW_BEGIN = "BEGIN"; -char *KW_BINARY = "BINARY"; -char *KW_BLENGTH = "BLENGTH"; -char *KW_BOOLEAN = "BOOLEAN"; -char *KW_BY = "BY"; -char *KW_CASE = "CASE"; -char *KW_CONST_E = "CONST_E"; -char *KW_CONSTANT = "CONSTANT"; -char *KW_CONTEXT = "CONTEXT"; -char *KW_COS = "COS"; -char *KW_DERIVE = "DERIVE"; -char *KW_DIV = "DIV"; -char *KW_ELSE = "ELSE"; -char *KW_END = "END"; -char *KW_END_ALIAS = "END_ALIAS"; -char *KW_END_CASE = "END_CASE"; -char *KW_END_CONSTANT = "END_CONSTANT"; -char *KW_END_CONTEXT = "END_CONTEXT"; -char *KW_END_ENTITY = "END_ENTITY"; -char *KW_END_FUNCTION = "END_FUNCTION"; -char *KW_END_IF = "END_IF"; -char *KW_END_LOCAL = "END_LOCAL"; -char *KW_END_MODEL = "END_MODEL"; -char *KW_END_PROCEDURE = "END_PROCEDURE"; -char *KW_END_REPEAT = "END_REPEAT"; -char *KW_END_RULE = "END_RULE"; -char *KW_END_SCHEMA = "END_SCHEMA"; -char *KW_END_TYPE = "END_TYPE"; -char *KW_ENTITY = "ENTITY"; -char *KW_ENUMERATION = "ENUMERATION"; -char *KW_ESCAPE = "ESCAPE"; -char *KW_EXISTS = "EXISTS"; -char *KW_EXP = "EXP"; -char *KW_FALSE = "FALSE"; -char *KW_FIXED = "FIXED"; -char *KW_FOR = "FOR"; -char *KW_FORMAT = "FORMAT"; -char *KW_FROM = "FROM"; -char *KW_FUNCTION = "FUNCTION"; -char *KW_GENERIC = "GENERIC"; -char *KW_HIBOUND = "HIBOUND"; -char *KW_HIINDEX = "HIINDEX"; -char *KW_IF = "IF"; -char *KW_IN = "IN"; -char *KW_INCLUDE = "INCLUDE"; -char *KW_INSERT = "INSERT"; -char *KW_INTEGER = "INTEGER"; -char *KW_INVERSE = "INVERSE"; -char *KW_LENGTH = "LENGTH"; -char *KW_LIKE = "LIKE"; -char *KW_LIST = "LIST"; -char *KW_LOBOUND = "LOBOUND"; -char *KW_LOCAL = "LOCAL"; -char *KW_LOG = "LOG"; -char *KW_LOG10 = "LOG10"; -char *KW_LOG2 = "LOG2"; -char *KW_LOGICAL = "LOGICAL"; -char *KW_LOINDEX = "LOINDEX"; -char *KW_MOD = "MOD"; -char *KW_MODEL = "MODEL"; -char *KW_NOT = "NOT"; -char *KW_NUMBER = "NUMBER"; -char *KW_NVL = "NVL"; -char *KW_ODD = "ODD"; -char *KW_OF = "OF"; -char *KW_ONEOF = "ONEOF"; -char *KW_OPTIONAL = "OPTIONAL"; -char *KW_OR = "OR"; -char *KW_OTHERWISE = "OTHERWISE"; -char *KW_PI = "PI"; -char *KW_PROCEDURE = "PROCEDURE"; -char *KW_QUERY = "QUERY"; -char *KW_REAL = "REAL"; -char *KW_REFERENCE = "REFERENCE"; -char *KW_REMOVE = "REMOVE"; -char *KW_REPEAT = "REPEAT"; -char *KW_RETURN = "RETURN"; -char *KW_ROLESOF = "ROLESOF"; -char *KW_RULE = "RULE"; -char *KW_SCHEMA = "SCHEMA"; -char *KW_SELECT = "SELECT"; -char *KW_SELF = "SELF"; -char *KW_SET = "SET"; -char *KW_SIN = "SIN"; -char *KW_SIZEOF = "SIZEOF"; -char *KW_SKIP = "SKIP"; -char *KW_SQRT = "SQRT"; -char *KW_STRING = "STRING"; -char *KW_SUBTYPE = "SUBTYPE"; -char *KW_SUPERTYPE = "SUPERTYPE"; -char *KW_TAN = "TAN"; -char *KW_THEN = "THEN"; -char *KW_TO = "TO"; -char *KW_TRUE = "TRUE"; -char *KW_TYPE = "TYPE"; -char *KW_TYPEOF = "TYPEOF"; -char *KW_UNIQUE = "UNIQUE"; -char *KW_UNKNOWN = "UNKNOWN"; -char *KW_UNTIL = "UNTIL"; -char *KW_USE = "USE"; -char *KW_USEDIN = "USEDIN"; -char *KW_VALUE = "VALUE"; -char *KW_VALUE_IN = "VALUE_IN"; -char *KW_VALUE_UNIQUE = "VALUE_UNIQUE"; -char *KW_VAR = "VAR"; -char *KW_WHERE = "WHERE"; -char *KW_WHILE = "WHILE"; -char *KW_XOR = "XOR"; +char * KW_ABS = "ABS"; +char * KW_ABSTRACT = "ABSTRACT"; +char * KW_ACOS = "ACOS"; +char * KW_AGGREGATE = "AGGREGATE"; +char * KW_ALIAS = "ALIAS"; +char * KW_AND = "AND"; +char * KW_ANDOR = "ANDOR"; +char * KW_ARRAY = "ARRAY"; +char * KW_AS = "AS"; +char * KW_ASIN = "ASIN"; +char * KW_ATAN = "ATAN"; +char * KW_BAG = "BAG"; +char * KW_BEGIN = "BEGIN"; +char * KW_BINARY = "BINARY"; +char * KW_BLENGTH = "BLENGTH"; +char * KW_BOOLEAN = "BOOLEAN"; +char * KW_BY = "BY"; +char * KW_CASE = "CASE"; +char * KW_CONST_E = "CONST_E"; +char * KW_CONSTANT = "CONSTANT"; +char * KW_CONTEXT = "CONTEXT"; +char * KW_COS = "COS"; +char * KW_DERIVE = "DERIVE"; +char * KW_DIV = "DIV"; +char * KW_ELSE = "ELSE"; +char * KW_END = "END"; +char * KW_END_ALIAS = "END_ALIAS"; +char * KW_END_CASE = "END_CASE"; +char * KW_END_CONSTANT = "END_CONSTANT"; +char * KW_END_CONTEXT = "END_CONTEXT"; +char * KW_END_ENTITY = "END_ENTITY"; +char * KW_END_FUNCTION = "END_FUNCTION"; +char * KW_END_IF = "END_IF"; +char * KW_END_LOCAL = "END_LOCAL"; +char * KW_END_MODEL = "END_MODEL"; +char * KW_END_PROCEDURE = "END_PROCEDURE"; +char * KW_END_REPEAT = "END_REPEAT"; +char * KW_END_RULE = "END_RULE"; +char * KW_END_SCHEMA = "END_SCHEMA"; +char * KW_END_TYPE = "END_TYPE"; +char * KW_ENTITY = "ENTITY"; +char * KW_ENUMERATION = "ENUMERATION"; +char * KW_ESCAPE = "ESCAPE"; +char * KW_EXISTS = "EXISTS"; +char * KW_EXP = "EXP"; +char * KW_FALSE = "FALSE"; +char * KW_FIXED = "FIXED"; +char * KW_FOR = "FOR"; +char * KW_FORMAT = "FORMAT"; +char * KW_FROM = "FROM"; +char * KW_FUNCTION = "FUNCTION"; +char * KW_GENERIC = "GENERIC"; +char * KW_HIBOUND = "HIBOUND"; +char * KW_HIINDEX = "HIINDEX"; +char * KW_IF = "IF"; +char * KW_IN = "IN"; +char * KW_INCLUDE = "INCLUDE"; +char * KW_INSERT = "INSERT"; +char * KW_INTEGER = "INTEGER"; +char * KW_INVERSE = "INVERSE"; +char * KW_LENGTH = "LENGTH"; +char * KW_LIKE = "LIKE"; +char * KW_LIST = "LIST"; +char * KW_LOBOUND = "LOBOUND"; +char * KW_LOCAL = "LOCAL"; +char * KW_LOG = "LOG"; +char * KW_LOG10 = "LOG10"; +char * KW_LOG2 = "LOG2"; +char * KW_LOGICAL = "LOGICAL"; +char * KW_LOINDEX = "LOINDEX"; +char * KW_MOD = "MOD"; +char * KW_MODEL = "MODEL"; +char * KW_NOT = "NOT"; +char * KW_NUMBER = "NUMBER"; +char * KW_NVL = "NVL"; +char * KW_ODD = "ODD"; +char * KW_OF = "OF"; +char * KW_ONEOF = "ONEOF"; +char * KW_OPTIONAL = "OPTIONAL"; +char * KW_OR = "OR"; +char * KW_OTHERWISE = "OTHERWISE"; +char * KW_PI = "PI"; +char * KW_PROCEDURE = "PROCEDURE"; +char * KW_QUERY = "QUERY"; +char * KW_REAL = "REAL"; +char * KW_REFERENCE = "REFERENCE"; +char * KW_REMOVE = "REMOVE"; +char * KW_REPEAT = "REPEAT"; +char * KW_RETURN = "RETURN"; +char * KW_ROLESOF = "ROLESOF"; +char * KW_RULE = "RULE"; +char * KW_SCHEMA = "SCHEMA"; +char * KW_SELECT = "SELECT"; +char * KW_SELF = "SELF"; +char * KW_SET = "SET"; +char * KW_SIN = "SIN"; +char * KW_SIZEOF = "SIZEOF"; +char * KW_SKIP = "SKIP"; +char * KW_SQRT = "SQRT"; +char * KW_STRING = "STRING"; +char * KW_SUBTYPE = "SUBTYPE"; +char * KW_SUPERTYPE = "SUPERTYPE"; +char * KW_TAN = "TAN"; +char * KW_THEN = "THEN"; +char * KW_TO = "TO"; +char * KW_TRUE = "TRUE"; +char * KW_TYPE = "TYPE"; +char * KW_TYPEOF = "TYPEOF"; +char * KW_UNIQUE = "UNIQUE"; +char * KW_UNKNOWN = "UNKNOWN"; +char * KW_UNTIL = "UNTIL"; +char * KW_USE = "USE"; +char * KW_USEDIN = "USEDIN"; +char * KW_VALUE = "VALUE"; +char * KW_VALUE_IN = "VALUE_IN"; +char * KW_VALUE_UNIQUE = "VALUE_UNIQUE"; +char * KW_VAR = "VAR"; +char * KW_WHERE = "WHERE"; +char * KW_WHILE = "WHILE"; +char * KW_XOR = "XOR"; diff --git a/src/express/expr.c b/src/express/expr.c index a4870dd08..7f814cf89 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -87,11 +87,10 @@ Expression LITERAL_ONE; void EXPop_init(); -static inline int OPget_number_of_operands(Op_Code op) -{ - if((op == OP_NEGATE) || (op == OP_NOT)) { +static inline int OPget_number_of_operands( Op_Code op ) { + if( ( op == OP_NEGATE ) || ( op == OP_NOT ) ) { return 1; - } else if(op == OP_SUBCOMPONENT) { + } else if( op == OP_SUBCOMPONENT ) { return 3; } else { return 2; @@ -99,47 +98,45 @@ static inline int OPget_number_of_operands(Op_Code op) } /** Description: Initialize the Expression module. */ -void EXPinitialize(void) -{ +void EXPinitialize( void ) { #ifdef does_not_appear_to_be_necessary_or_even_make_sense - LITERAL_EMPTY_SET = EXPcreate_simple(Type_Set); + LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); LITERAL_EMPTY_SET->u.list = LISTcreate(); - resolved_all(LITERAL_EMPTY_SET); + resolved_all( LITERAL_EMPTY_SET ); #endif /* E and PI might come out of math.h */ - LITERAL_E = EXPcreate_simple(Type_Real); + LITERAL_E = EXPcreate_simple( Type_Real ); #ifndef M_E #define M_E 2.7182818284590452354 #endif LITERAL_E->u.real = M_E; - resolved_all(LITERAL_E); + resolved_all( LITERAL_E ); - LITERAL_PI = EXPcreate_simple(Type_Real); + LITERAL_PI = EXPcreate_simple( Type_Real ); #ifndef M_PI #define M_PI 3.14159265358979323846 #endif LITERAL_PI->u.real = M_PI; - resolved_all(LITERAL_PI); + resolved_all( LITERAL_PI ); - LITERAL_INFINITY = EXPcreate_simple(Type_Integer); + LITERAL_INFINITY = EXPcreate_simple( Type_Integer ); LITERAL_INFINITY->u.integer = INT_MAX; - resolved_all(LITERAL_INFINITY); + resolved_all( LITERAL_INFINITY ); - LITERAL_ZERO = EXPcreate_simple(Type_Integer); + LITERAL_ZERO = EXPcreate_simple( Type_Integer ); LITERAL_ZERO->u.integer = 0; - resolved_all(LITERAL_ZERO); + resolved_all( LITERAL_ZERO ); - LITERAL_ONE = EXPcreate_simple(Type_Integer); + LITERAL_ONE = EXPcreate_simple( Type_Integer ); LITERAL_ONE->u.integer = 1; - resolved_all(LITERAL_ONE); + resolved_all( LITERAL_ONE ); EXPop_init(); } -void EXPcleanup(void) -{ +void EXPcleanup( void ) { } /** @@ -153,24 +150,23 @@ void EXPcleanup(void) * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, - Variable *v, char *dt, struct Symbol_ **where, int s_id) -{ +static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e, + Variable * v, char * dt, struct Symbol_ ** where, int s_id ) { Expression item; Variable tmp; int options = 0; struct Symbol_ *w = NULL; - if(selection->search_id == s_id) { + if( selection->search_id == s_id ) { return 0; } - switch(selection->u.type->body->type) { + switch( selection->u.type->body->type ) { case entity_: /* goes through supertypes and their subtypes (!!) */ - tmp = ENTITYfind_inherited_attribute(selection->u.type->body->entity, sref.name, &w); - if(tmp) { - if(w != NULL) { + tmp = ENTITYfind_inherited_attribute( selection->u.type->body->entity, sref.name, &w ); + if( tmp ) { + if( w != NULL ) { *where = w; } *v = tmp; @@ -184,70 +180,64 @@ static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, Linked_List subt = LISTcreate(); Linked_List uniqSubs = LISTcreate(); selection->search_id = s_id; - LISTdo(selection->u.type->body->list, t, Type) { - int nr = EXP_resolve_op_dot_fuzzy(t, sref, e, v, dt, &w, s_id); - if(nr) { - if(w != NULL) { + LISTdo( selection->u.type->body->list, t, Type ) { + int nr = EXP_resolve_op_dot_fuzzy( t, sref, e, v, dt, &w, s_id ); + if( nr ) { + if( w != NULL ) { /* only ever set due to ENTITYfind_inherited_attribute in case entity_. * it is set to a subtype of one of the current type's supertypes. not * sure of the circumstances in which this is beneficial. */ *where = w; - LISTadd_last(subt, w); + LISTadd_last( subt, w ); } else { - LISTadd_last(supert, t); + LISTadd_last( supert, t ); } options += nr; } - } - LISTod + } LISTod /* go through supertypes and subtypes, comparing. for any subtypes in supertypes, remove item from subtypes * would be possible to delete items from subt while going through the list... worth the effort? */ - LISTdo(subt, s, Symbol *) { + LISTdo( subt, s, Symbol* ) { bool found = false; - LISTdo_n(supert, t, Type, b) { - if(0 == strcmp(s->name, t->symbol.name)) { + LISTdo_n( supert, t, Type, b ) { + if( 0 == strcmp( s->name, t->symbol.name ) ) { found = true; break; } + } LISTod + if( !found ) { + LISTadd_last( uniqSubs, s ); } - LISTod - if(!found) { - LISTadd_last(uniqSubs, s); - } - } - LISTod - if((LISTget_length(uniqSubs) == 0) && (LISTget_length(supert) == 1) && (options > 1)) { + } LISTod + if( ( LISTget_length( uniqSubs ) == 0 ) && ( LISTget_length( supert ) == 1 ) && ( options > 1 ) ) { options = 1; /* this ensures that v is set correctly and wasn't overwritten */ - EXP_resolve_op_dot_fuzzy((Type) LISTget_first(supert), sref, e, v, dt, &w, s_id); + EXP_resolve_op_dot_fuzzy( (Type) LISTget_first( supert ), sref, e, v, dt, &w, s_id ); } - if(options > 1) { + if( options > 1 ) { /* found more than one, so ambiguous */ *v = VARIABLE_NULL; } - LISTfree(supert); - LISTfree(subt); - LISTfree(uniqSubs); + LISTfree( supert ); + LISTfree( subt ); + LISTfree( uniqSubs ); return options; } case enumeration_: - item = (Expression)DICTlookup(TYPEget_enum_tags(selection), sref.name); - if(item) { + item = ( Expression )DICTlookup( TYPEget_enum_tags( selection ), sref.name ); + if( item ) { *e = item; *dt = DICT_type; return 1; - } else { - return 0; } default: return 0; } } -Type EXPresolve_op_dot(Expression expr, Scope scope) -{ +Type EXPresolve_op_dot( Expression expr, Scope scope ) { Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Variable v = 0; @@ -263,151 +253,151 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) /* op1 is entity expression, op2 is attribute */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve(op1, scope, Type_Dont_Care); - if(is_resolve_failed(op1)) { - resolve_failed(expr); - return(Type_Bad); + EXPresolve( op1, scope, Type_Dont_Care ); + if( is_resolve_failed( op1 ) ) { + resolve_failed( expr ); + return( Type_Bad ); } op1type = op1->return_type; - switch(op1type->u.type->body->type) { + switch( op1type->u.type->body->type ) { case generic_: case runtime_: /* defer */ - return(Type_Runtime); + return( Type_Runtime ); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo(op1type->u.type->body->list, t, Type) { + LISTdo( op1type->u.type->body->list, t, Type ) { /* this used to increment options by 1 if EXP_resolve_op_dot_fuzzy found 1 or more possibilities. * thus the code for handling ambiguities was only used if the ambig was in the immediate type * and not a supertype. don't think that's right... */ - options += EXP_resolve_op_dot_fuzzy(t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id); + options += EXP_resolve_op_dot_fuzzy( t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id ); } LISTod; - switch(options) { + switch( options ) { case 0: - LISTdo(op1type->u.type->body->list, t, Type) { - if(t->u.type->body->type != enumeration_) { + LISTdo( op1type->u.type->body->list, t, Type ) { + if( t->u.type->body->type != enumeration_ ) { all_enums = false; } } LISTod; - if(all_enums) { - ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name); + if( all_enums ) { + ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name ); } else { /* no possible resolutions */ - ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name); + ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name ); } - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); case 1: /* only one possible resolution */ - if(dt == OBJ_VARIABLE) { - if(where) { - ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name); + if( dt == OBJ_VARIABLE ) { + if( where ) { + ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } - if(v == VARIABLE_NULL) { - fprintf(stderr, "EXPresolve_op_dot: nonsense value for Variable\n"); - ERRORabort(0); + if( v == VARIABLE_NULL ) { + fprintf( stderr, "EXPresolve_op_dot: nonsense value for Variable\n" ); + ERRORabort( 0 ); } op2->u.variable = v; op2->return_type = v->type; - resolved_all(expr); - return(v->type); - } else if(dt == OBJ_ENUM) { + resolved_all( expr ); + return( v->type ); + } else if( dt == OBJ_ENUM ) { op2->u.expression = item; op2->return_type = item->type; - resolved_all(expr); - return(item->type); + resolved_all( expr ); + return( item->type ); } else { - fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); - ERRORabort(0); - return(Type_Bad); + fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); + ERRORabort( 0 ); } + default: /* compile-time ambiguous */ - if(where) { + if( where ) { /* this is actually a warning, not an error */ - ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name); + ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } - return(Type_Runtime); + return( Type_Runtime ); } case attribute_: - v = ENTITYresolve_attr_ref(op1->u.variable->type->u.type->body->entity, (struct Symbol_ *)0, &op2->symbol); + v = ENTITYresolve_attr_ref( op1->u.variable->type->u.type->body->entity, ( struct Symbol_ * )0, &op2->symbol ); - if(!v) { + if( !v ) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); } - if(DICT_type != OBJ_VARIABLE) { - fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); - ERRORabort(0); + if( DICT_type != OBJ_VARIABLE ) { + fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); + ERRORabort( 0 ); } op2->u.variable = v; op2->return_type = v->type; - resolved_all(expr); - return(v->type); + resolved_all( expr ); + return( v->type ); case entity_: case op_: /* (op1).op2 */ - v = ENTITYresolve_attr_ref(op1type->u.type->body->entity, - (struct Symbol_ *)0, &op2->symbol); - if(!v) { + v = ENTITYresolve_attr_ref( op1type->u.type->body->entity, + ( struct Symbol_ * )0, &op2->symbol ); + if( !v ) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); } - if(DICT_type != OBJ_VARIABLE) { - fprintf(stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n"); + if( DICT_type != OBJ_VARIABLE ) { + fprintf( stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n" ); } op2->u.variable = v; /* changed to set return_type */ op2->return_type = op2->u.variable->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); case enumeration_: /* enumerations within a select will be handled by `case select_` above, * which calls EXP_resolve_op_dot_fuzzy(). */ - item = (Expression)DICTlookup(TYPEget_enum_tags(op1type), op2->symbol.name); - if(!item) { + item = ( Expression )DICTlookup( TYPEget_enum_tags( op1type ), op2->symbol.name ); + if( !item ) { ERRORreport_with_symbol(ENUM_NO_SUCH_ITEM, &op2->symbol, - op1type->symbol.name, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + op1type->symbol.name, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } op2->u.expression = item; op2->return_type = item->type; - resolved_all(expr); - return(item->type); + resolved_all( expr ); + return( item->type ); case aggregate_: case array_: case bag_: case list_: case set_: ERRORreport_with_symbol(ATTRIBUTE_REF_ON_AGGREGATE, - &op2->symbol, op2->symbol.name); - /*FALLTHRU*/ + &op2->symbol, op2->symbol.name ); + /*FALLTHRU*/ case unknown_: /* unable to resolved operand */ /* presumably error has already been reported */ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); default: ERRORreport_with_symbol(ATTRIBUTE_REF_FROM_NON_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } } @@ -416,21 +406,20 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, - int s_id) -{ +static int EXP_resolve_op_group_fuzzy( Type selection, Symbol sref, Entity * e, + int s_id ) { Entity tmp; int options = 0; - if(selection->search_id == s_id) { + if( selection->search_id == s_id ) { return 0; } - switch(selection->u.type->body->type) { + switch( selection->u.type->body->type ) { case entity_: - tmp = (Entity)ENTITYfind_inherited_entity( - selection->u.type->body->entity, sref.name, 1); - if(tmp) { + tmp = ( Entity )ENTITYfind_inherited_entity( + selection->u.type->body->entity, sref.name, 1 ); + if( tmp ) { *e = tmp; return 1; } @@ -439,16 +428,16 @@ static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, case select_: tmp = *e; selection->search_id = s_id; - LISTdo(selection->u.type->body->list, t, Type) - if(EXP_resolve_op_group_fuzzy(t, sref, e, s_id)) { - if(*e != tmp) { + LISTdo( selection->u.type->body->list, t, Type ) + if( EXP_resolve_op_group_fuzzy( t, sref, e, s_id ) ) { + if( *e != tmp ) { tmp = *e; ++options; } } LISTod; - switch(options) { + switch( options ) { case 0: return 0; case 1: @@ -463,8 +452,7 @@ static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, } } -Type EXPresolve_op_group(Expression expr, Scope scope) -{ +Type EXPresolve_op_group( Expression expr, Scope scope ) { Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Entity ent_ref = ENTITY_NULL; @@ -477,84 +465,84 @@ Type EXPresolve_op_group(Expression expr, Scope scope) /* op1 is entity expression, op2 is entity */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve(op1, scope, Type_Dont_Care); - if(is_resolve_failed(op1)) { - resolve_failed(expr); - return(Type_Bad); + EXPresolve( op1, scope, Type_Dont_Care ); + if( is_resolve_failed( op1 ) ) { + resolve_failed( expr ); + return( Type_Bad ); } op1type = op1->return_type; - switch(op1type->u.type->body->type) { + switch( op1type->u.type->body->type ) { case generic_: case runtime_: case op_: /* All these cases are very painful to do right */ /* "Generic" and sometimes others require runtime evaluation */ op2->return_type = Type_Runtime; - return(Type_Runtime); + return( Type_Runtime ); case self_: case entity_: /* Get entity denoted by "X\" */ - tmp = ((op1type->u.type->body->type == self_) - ? scope - : op1type->u.type->body->entity); + tmp = ( ( op1type->u.type->body->type == self_ ) + ? scope + : op1type->u.type->body->entity ); /* Now get entity denoted by "X\Y" */ ent_ref = - (Entity)ENTITYfind_inherited_entity(tmp, op2->symbol.name, 1); - if(!ent_ref) { + ( Entity )ENTITYfind_inherited_entity( tmp, op2->symbol.name, 1 ); + if( !ent_ref ) { ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the */ /* first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo(op1type->u.type->body->list, t, Type) - if(EXP_resolve_op_group_fuzzy(t, op2->symbol, &ent_ref, - __SCOPE_search_id)) { - if(ent_ref != tmp) { + LISTdo( op1type->u.type->body->list, t, Type ) + if( EXP_resolve_op_group_fuzzy( t, op2->symbol, &ent_ref, + __SCOPE_search_id ) ) { + if( ent_ref != tmp ) { tmp = ent_ref; ++options; } } LISTod; - switch(options) { + switch( options ) { case 0: /* no possible resolutions */ ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); case 1: /* only one possible resolution */ op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); default: /* compile-time ambiguous */ /* ERRORreport_with_symbol(ERROR_ambiguous_group,*/ /* &op2->symbol, op2->symbol.name);*/ - return(Type_Runtime); + return( Type_Runtime ); } case array_: - if(op1->type->u.type->body->type == self_) { - return(Type_Runtime); /* not sure if there are other cases where Type_Runtime should be returned, or not */ + if( op1->type->u.type->body->type == self_ ) { + return( Type_Runtime ); /* not sure if there are other cases where Type_Runtime should be returned, or not */ } /* else fallthrough */ case unknown_: /* unable to resolve operand */ /* presumably error has already been reported */ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); case aggregate_: case bag_: @@ -562,117 +550,112 @@ Type EXPresolve_op_group(Expression expr, Scope scope) case set_: default: ERRORreport_with_symbol(GROUP_REF_UNEXPECTED_TYPE, - &op1->symbol); - return(Type_Bad); + &op1->symbol ); + return( Type_Bad ); } } -Type EXPresolve_op_relational(Expression e, Scope s) -{ +Type EXPresolve_op_relational( Expression e, Scope s ) { Type t = 0; int failed = 0; Type op1type; /* Prevent op1 from complaining if it fails */ - EXPresolve(e->e.op1, s, Type_Unknown); - failed = is_resolve_failed(e->e.op1); + EXPresolve( e->e.op1, s, Type_Unknown ); + failed = is_resolve_failed( e->e.op1 ); op1type = e->e.op1->return_type; /* now, either op1 was resolved in which case, we use its return type */ /* for typechecking, OR, it wasn't resolved in which case we resolve */ /* op2 in such a way that it complains if it fails to resolved */ - if(op1type == Type_Unknown) { + if( op1type == Type_Unknown ) { t = Type_Dont_Care; } else { t = op1type; } - EXPresolve(e->e.op2, s, t); - if(is_resolve_failed(e->e.op2)) { + EXPresolve( e->e.op2, s, t ); + if( is_resolve_failed( e->e.op2 ) ) { failed = 1; } /* If op1 wasn't successfully resolved, retry it now with new information */ - if((failed == 0) && !is_resolved(e->e.op1)) { - EXPresolve(e->e.op1, s, e->e.op2->return_type); - if(is_resolve_failed(e->e.op1)) { + if( ( failed == 0 ) && !is_resolved( e->e.op1 ) ) { + EXPresolve( e->e.op1, s, e->e.op2->return_type ); + if( is_resolve_failed( e->e.op1 ) ) { failed = 1; } } - if(failed) { - resolve_failed(e); + if( failed ) { + resolve_failed( e ); } else { - resolved_all(e); + resolved_all( e ); } - return(Type_Logical); + return( Type_Logical ); } -void EXPresolve_op_default(Expression e, Scope s) -{ +void EXPresolve_op_default( Expression e, Scope s ) { int failed = 0; - if(OPget_number_of_operands(e->e.op_code) == 3) { - EXPresolve(e->e.op3, s, Type_Dont_Care); - failed = is_resolve_failed(e->e.op3); - } - if(OPget_number_of_operands(e->e.op_code) == 2) { - EXPresolve(e->e.op2, s, Type_Dont_Care); - failed |= is_resolve_failed(e->e.op2); + switch( OPget_number_of_operands( e->e.op_code ) ) { + case 3: + EXPresolve( e->e.op3, s, Type_Dont_Care ); + failed = is_resolve_failed( e->e.op3 ); + case 2: + EXPresolve( e->e.op2, s, Type_Dont_Care ); + failed |= is_resolve_failed( e->e.op2 ); } - EXPresolve(e->e.op1, s, Type_Dont_Care); - if(failed || is_resolve_failed(e->e.op1)) { - resolve_failed(e); + EXPresolve( e->e.op1, s, Type_Dont_Care ); + if( failed || is_resolve_failed( e->e.op1 ) ) { + resolve_failed( e ); } else { - resolved_all(e); + resolved_all( e ); } } /* prototype for this func cannot change - it is passed as a fn pointer */ -Type EXPresolve_op_unknown(Expression e, Scope s) -{ +Type EXPresolve_op_unknown( Expression e, Scope s ) { (void) e; /* quell unused param warning */ (void) s; - ERRORreport(INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE); + ERRORreport( INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE ); return Type_Bad; } -typedef Type(Resolve_expr_func)(Expression, Scope); +typedef Type (Resolve_expr_func) ( Expression , Scope ); -Type EXPresolve_op_logical(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); - return(Type_Logical); +Type EXPresolve_op_logical( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); + return( Type_Logical ); } -Type EXPresolve_op_array_like(Expression e, Scope s) -{ +Type EXPresolve_op_array_like( Expression e, Scope s ) { Type op1type; - EXPresolve_op_default(e, s); + EXPresolve_op_default( e, s ); op1type = e->e.op1->return_type; - if(TYPEis_aggregate(op1type)) { - return(op1type->u.type->body->base); - } else if(TYPEis_string(op1type)) { - return(op1type); - } else if(op1type == Type_Runtime) { - return(Type_Runtime); - } else if(op1type->u.type->body->type == binary_) { - ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__); - return(Type_Binary); - } else if(op1type->u.type->body->type == generic_) { - return(Type_Generic); - } else if(TYPEis_select(op1type)) { + if( TYPEis_aggregate( op1type ) ) { + return( op1type->u.type->body->base ); + } else if( TYPEis_string( op1type ) ) { + return( op1type ); + } else if( op1type == Type_Runtime ) { + return( Type_Runtime ); + } else if( op1type->u.type->body->type == binary_ ) { + ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__ ); + return( Type_Binary ); + } else if( op1type->u.type->body->type == generic_ ) { + return( Type_Generic ); + } else if( TYPEis_select( op1type ) ) { int numAggr = 0, numNonAggr = 0; bool sameAggrType = true; Type lasttype = 0; /* FIXME Is it possible that the base type hasn't yet been resolved? * If it is possible, we should signal that we need to come back later... but how? */ - assert(op1type->symbol.resolved == 1); + assert( op1type->symbol.resolved == 1 ); /* FIXME We should check for a not...or excluding non-aggregate types in the select, such as * WR1: NOT('INDEX_ATTRIBUTE.COMMON_DATUM_LIST' IN TYPEOF(base)) OR (SELF\shape_aspect.of_shape = base[1]\shape_aspect.of_shape); @@ -680,13 +663,13 @@ Type EXPresolve_op_array_like(Expression e, Scope s) */ /* count aggregates and non-aggregates, check aggregate types */ - LISTdo(op1type->u.type->body->list, item, Type) { - if(TYPEis_aggregate(item)) { + LISTdo( op1type->u.type->body->list, item, Type ) { + if( TYPEis_aggregate( item ) ) { numAggr++; - if(lasttype == TYPE_NULL) { + if( lasttype == TYPE_NULL ) { lasttype = item; } else { - if(lasttype->u.type->body->type != item->u.type->body->type) { + if( lasttype->u.type->body->type != item->u.type->body->type ) { sameAggrType = false; } } @@ -698,43 +681,40 @@ Type EXPresolve_op_array_like(Expression e, Scope s) /* NOTE the following code returns the same data for every case that isn't an error. * It needs to be simplified or extended, depending on whether it works or not. */ - if(sameAggrType && (numAggr != 0) && (numNonAggr == 0)) { + if( sameAggrType && ( numAggr != 0 ) && ( numNonAggr == 0 ) ) { /* All are the same aggregation type */ - return(lasttype->u.type->body->base); - } else if(numNonAggr == 0) { + return( lasttype->u.type->body->base ); + } else if( numNonAggr == 0 ) { /* All aggregates, but different types */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); - return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ - } else if(numAggr != 0) { + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); + return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ + } else if( numAggr != 0 ) { /* One or more aggregates, one or more nonaggregates */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); - return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); + return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ } /* Else, all are nonaggregates. This is an error. */ } - ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol); - return(Type_Unknown); + ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol ); + return( Type_Unknown ); } -Type EXPresolve_op_entity_constructor(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_entity_constructor( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); /* perhaps should return Type_Runtime? */ return Type_Entity; } -Type EXPresolve_op_int_div_like(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_int_div_like( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); return Type_Integer; } -Type EXPresolve_op_plus_like(Expression e, Scope s) -{ +Type EXPresolve_op_plus_like( Expression e, Scope s ) { /* i.e., Integer or Real */ - EXPresolve_op_default(e, s); - if(is_resolve_failed(e)) { - resolve_failed(e); - return(Type_Unknown); + EXPresolve_op_default( e, s ); + if( is_resolve_failed( e ) ) { + resolve_failed( e ); + return( Type_Unknown ); } /* could produce better results with a lot of pain but the EXPRESS */ @@ -745,22 +725,21 @@ Type EXPresolve_op_plus_like(Expression e, Scope s) /* and list+set=? */ /* crude but sufficient */ - if((TYPEis_aggregate(e->e.op1->return_type)) || - (TYPEis_aggregate(e->e.op2->return_type))) { + if( ( TYPEis_aggregate( e->e.op1->return_type ) ) || + ( TYPEis_aggregate( e->e.op2->return_type ) ) ) { return Type_Aggregate; } /* crude but sufficient */ - if((e->e.op1->return_type->u.type->body->type == real_) || - (e->e.op2->return_type->u.type->body->type == real_)) { - return(Type_Real); + if( ( e->e.op1->return_type->u.type->body->type == real_ ) || + ( e->e.op2->return_type->u.type->body->type == real_ ) ) { + return( Type_Real ); } return Type_Integer; } -Type EXPresolve_op_unary_minus(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_unary_minus( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); return e->e.op1->return_type; } @@ -773,43 +752,41 @@ Type EXPresolve_op_unary_minus(Expression e, Scope s) * \param string human-readable description * \param resolve_func resolves an expression of this type */ -void EXPop_create(int token_number, char *string, Resolve_expr_func *resolve_func) -{ +void EXPop_create( int token_number, char * string, Resolve_expr_func * resolve_func ) { EXPop_table[token_number].token = string; EXPop_table[token_number].resolve = resolve_func; } -void EXPop_init() -{ - EXPop_create(OP_AND, "AND", EXPresolve_op_logical); - EXPop_create(OP_ANDOR, "ANDOR", EXPresolve_op_logical); - EXPop_create(OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like); - EXPop_create(OP_CONCAT, "||", EXPresolve_op_entity_constructor); - EXPop_create(OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like); - EXPop_create(OP_DOT, ".", EXPresolve_op_dot); - EXPop_create(OP_EQUAL, "=", EXPresolve_op_relational); - EXPop_create(OP_EXP, "**", EXPresolve_op_plus_like); - EXPop_create(OP_GREATER_EQUAL, ">=", EXPresolve_op_relational); - EXPop_create(OP_GREATER_THAN, ">", EXPresolve_op_relational); - EXPop_create(OP_GROUP, "\\", EXPresolve_op_group); - EXPop_create(OP_IN, "IN", EXPresolve_op_relational); - EXPop_create(OP_INST_EQUAL, ":=:", EXPresolve_op_relational); - EXPop_create(OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational); - EXPop_create(OP_LESS_EQUAL, "<=", EXPresolve_op_relational); - EXPop_create(OP_LESS_THAN, "<", EXPresolve_op_relational); - EXPop_create(OP_LIKE, "LIKE", EXPresolve_op_relational); - EXPop_create(OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like); - EXPop_create(OP_MOD, "MOD", EXPresolve_op_int_div_like); - EXPop_create(OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus); - EXPop_create(OP_NOT, "NOT", EXPresolve_op_logical); - EXPop_create(OP_NOT_EQUAL, "<>", EXPresolve_op_relational); - EXPop_create(OP_OR, "OR", EXPresolve_op_logical); - EXPop_create(OP_PLUS, "+", EXPresolve_op_plus_like); - EXPop_create(OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like); - EXPop_create(OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like); - EXPop_create(OP_TIMES, "*", EXPresolve_op_plus_like); - EXPop_create(OP_XOR, "XOR", EXPresolve_op_logical); - EXPop_create(OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown); +void EXPop_init() { + EXPop_create( OP_AND, "AND", EXPresolve_op_logical ); + EXPop_create( OP_ANDOR, "ANDOR", EXPresolve_op_logical ); + EXPop_create( OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like ); + EXPop_create( OP_CONCAT, "||", EXPresolve_op_entity_constructor ); + EXPop_create( OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like ); + EXPop_create( OP_DOT, ".", EXPresolve_op_dot ); + EXPop_create( OP_EQUAL, "=", EXPresolve_op_relational ); + EXPop_create( OP_EXP, "**", EXPresolve_op_plus_like ); + EXPop_create( OP_GREATER_EQUAL, ">=", EXPresolve_op_relational ); + EXPop_create( OP_GREATER_THAN, ">", EXPresolve_op_relational ); + EXPop_create( OP_GROUP, "\\", EXPresolve_op_group ); + EXPop_create( OP_IN, "IN", EXPresolve_op_relational ); + EXPop_create( OP_INST_EQUAL, ":=:", EXPresolve_op_relational ); + EXPop_create( OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational ); + EXPop_create( OP_LESS_EQUAL, "<=", EXPresolve_op_relational ); + EXPop_create( OP_LESS_THAN, "<", EXPresolve_op_relational ); + EXPop_create( OP_LIKE, "LIKE", EXPresolve_op_relational ); + EXPop_create( OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like ); + EXPop_create( OP_MOD, "MOD", EXPresolve_op_int_div_like ); + EXPop_create( OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus ); + EXPop_create( OP_NOT, "NOT", EXPresolve_op_logical ); + EXPop_create( OP_NOT_EQUAL, "<>", EXPresolve_op_relational ); + EXPop_create( OP_OR, "OR", EXPresolve_op_logical ); + EXPop_create( OP_PLUS, "+", EXPresolve_op_plus_like ); + EXPop_create( OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like ); + EXPop_create( OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like ); + EXPop_create( OP_TIMES, "*", EXPresolve_op_plus_like ); + EXPop_create( OP_XOR, "XOR", EXPresolve_op_logical ); + EXPop_create( OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown ); } /** @@ -818,82 +795,80 @@ void EXPop_init() ** \returns value of expression ** Compute the value of an integer expression. */ -int EXPget_integer_value(Expression expression) -{ +int EXPget_integer_value( Expression expression ) { /* TODO: why is this treated differently than a type error below? */ - if(expression == EXPRESSION_NULL) { + if( expression == EXPRESSION_NULL ) { return 0; } - if(expression->return_type->u.type->body->type == integer_) { - return INT_LITget_value(expression); + if( expression->return_type->u.type->body->type == integer_ ) { + return INT_LITget_value( expression ); } else { ERRORreport(INTEGER_EXPRESSION_EXPECTED); return 0; } } -char *opcode_print(Op_Code o) -{ - switch(o) { +char * opcode_print( Op_Code o ) { + switch( o ) { case OP_AND: - return("OP_AND"); + return( "OP_AND" ); case OP_ANDOR: - return("OP_ANDOR"); + return( "OP_ANDOR" ); case OP_ARRAY_ELEMENT: - return("OP_ARRAY_ELEMENT"); + return( "OP_ARRAY_ELEMENT" ); case OP_CONCAT: - return("OP_CONCAT"); + return( "OP_CONCAT" ); case OP_DIV: - return("OP_DIV"); + return( "OP_DIV" ); case OP_DOT: - return("OP_DOT"); + return( "OP_DOT" ); case OP_EQUAL: - return("OP_EQUAL"); + return( "OP_EQUAL" ); case OP_EXP: - return("OP_EXP"); + return( "OP_EXP" ); case OP_GREATER_EQUAL: - return("OP_GREATER_EQUAL"); + return( "OP_GREATER_EQUAL" ); case OP_GREATER_THAN: - return("OP_GREATER_THAN"); + return( "OP_GREATER_THAN" ); case OP_GROUP: - return("OP_GROUP"); + return( "OP_GROUP" ); case OP_IN: - return("OP_IN"); + return( "OP_IN" ); case OP_INST_EQUAL: - return("OP_INST_EQUAL"); + return( "OP_INST_EQUAL" ); case OP_INST_NOT_EQUAL: - return("OP_INST_NOT_EQUAL"); + return( "OP_INST_NOT_EQUAL" ); case OP_LESS_EQUAL: - return("OP_LESS_EQUAL"); + return( "OP_LESS_EQUAL" ); case OP_LESS_THAN: - return("OP_LESS_THAN"); + return( "OP_LESS_THAN" ); case OP_LIKE: - return("OP_LIKE"); + return( "OP_LIKE" ); case OP_MINUS: - return("OP_MINUS"); + return( "OP_MINUS" ); case OP_MOD: - return("OP_MOD"); + return( "OP_MOD" ); case OP_NEGATE: - return("OP_NEGATE"); + return( "OP_NEGATE" ); case OP_NOT: - return("OP_NOT"); + return( "OP_NOT" ); case OP_NOT_EQUAL: - return("OP_NOT_EQUAL"); + return( "OP_NOT_EQUAL" ); case OP_OR: - return("OP_OR"); + return( "OP_OR" ); case OP_PLUS: - return("OP_PLUS"); + return( "OP_PLUS" ); case OP_REAL_DIV: - return("OP_REAL_DIV"); + return( "OP_REAL_DIV" ); case OP_SUBCOMPONENT: - return("OP_SUBCOMPONENT"); + return( "OP_SUBCOMPONENT" ); case OP_TIMES: - return("OP_TIMES"); + return( "OP_TIMES" ); case OP_XOR: - return("OP_XOR"); + return( "OP_XOR" ); case OP_UNKNOWN: - return("OP_UNKNOWN"); + return( "OP_UNKNOWN" ); default: - return("no such op"); + return( "no such op" ); } } diff --git a/src/express/express.c b/src/express/express.c index 783b142e3..82e7b7889 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -87,22 +87,22 @@ #include "parse_data.h" #include "express/lexact.h" -void *ParseAlloc(void *(*mallocProc)(size_t)); -void ParseFree(void *parser, void (*freeProc)(void *)); -void Parse(void *parser, int tokenID, YYSTYPE data, parse_data_t parseData); +void * ParseAlloc( void * ( *mallocProc )( size_t ) ); +void ParseFree( void * parser, void ( *freeProc )( void * ) ); +void Parse( void * parser, int tokenID, YYSTYPE data, parse_data_t parseData ); void ParseTrace(FILE *TraceFILE, char *zTracePrompt); Linked_List EXPRESS_path; int EXPRESSpass; -void (*EXPRESSinit_args)(int, char **) = NULL; -void (*EXPRESSinit_parse)(void) = NULL; -int (*EXPRESSfail)(Express) = NULL; -int (*EXPRESSsucceed)(Express) = NULL; -void (*EXPRESSbackend)(Express) = NULL; -char *EXPRESSprogram_name; +void ( *EXPRESSinit_args )( int, char ** ) = NULL; +void ( *EXPRESSinit_parse )( void ) = NULL; +int ( *EXPRESSfail )( Express ) = NULL; +int ( *EXPRESSsucceed )( Express ) = NULL; +void ( *EXPRESSbackend )( Express ) = NULL; +char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -int (*EXPRESSgetopt)(int, char *) = NULL; +int ( *EXPRESSgetopt )( int, char * ) = NULL; bool EXPRESSignore_duplicate_schemas = false; Function funcdef(char *name, int pcount, Type ret_typ); @@ -111,154 +111,146 @@ void BUILTINSinitialize(); Dictionary EXPRESSbuiltins; /* procedures/functions */ -struct Scope_ *FUNC_NVL; -struct Scope_ *FUNC_USEDIN; +struct Scope_ * FUNC_NVL; +struct Scope_ * FUNC_USEDIN; extern Express yyexpresult; extern Linked_List PARSEnew_schemas; -void SCOPEinitialize(void); +void SCOPEinitialize( void ); -static Express PARSERrun(char *, FILE *); +static Express PARSERrun( char *, FILE * ); /** name specified on command line */ -char *input_filename = 0; +char * input_filename = 0; -int EXPRESS_fail(Express model) -{ +int EXPRESS_fail( Express model ) { ERRORflush_messages(); - if(EXPRESSfail) { - return((*EXPRESSfail)(model)); + if( EXPRESSfail ) { + return( ( *EXPRESSfail )( model ) ); } - fprintf(stderr, "Errors in input\n"); + fprintf( stderr, "Errors in input\n" ); return 1; } -int EXPRESS_succeed(Express model) -{ - if(EXPRESSsucceed) { - return((*EXPRESSsucceed)(model)); +int EXPRESS_succeed( Express model ) { + if( EXPRESSsucceed ) { + return( ( *EXPRESSsucceed )( model ) ); } - fprintf(stderr, "No errors in input\n"); + fprintf( stderr, "No errors in input\n" ); return 0; } -Express EXPRESScreate() -{ - Express model = SCOPEcreate(OBJ_EXPRESS); - model->u.express = (struct Express_ *)sc_calloc(1, sizeof(struct Express_)); +Express EXPRESScreate() { + Express model = SCOPEcreate( OBJ_EXPRESS ); + model->u.express = ( struct Express_ * )sc_calloc( 1, sizeof( struct Express_ ) ); return model; } -void EXPRESSdestroy(Express model) -{ - if(model->u.express->basename) { - sc_free(model->u.express->basename); +void EXPRESSdestroy( Express model ) { + if( model->u.express->basename ) { + sc_free( model->u.express->basename ); } - if(model->u.express->filename) { - sc_free(model->u.express->filename); + if( model->u.express->filename ) { + sc_free( model->u.express->filename ); } - sc_free(model->u.express); - SCOPEdestroy(model); + sc_free( model->u.express ); + SCOPEdestroy( model ); } #define MAX_SCHEMA_FILENAME_SIZE 256 typedef struct Dir { char full[MAX_SCHEMA_FILENAME_SIZE]; - char *leaf; + char * leaf; } Dir; -static void EXPRESS_PATHinit() -{ - char *p; - Dir *dir; +static void EXPRESS_PATHinit() { + char * p; + Dir * dir; EXPRESS_path = LISTcreate(); - p = getenv("EXPRESS_PATH"); - if(!p) { + p = getenv( "EXPRESS_PATH" ); + if( !p ) { /* if no EXPRESS_PATH, search current directory anyway */ - dir = (Dir *)sc_malloc(sizeof(Dir)); + dir = ( Dir * )sc_malloc( sizeof( Dir ) ); dir->leaf = dir->full; - LISTadd_last(EXPRESS_path, dir); + LISTadd_last( EXPRESS_path, dir ); } else { int done = 0; - while(!done) { - char *start; /* start of current dir */ + while( !done ) { + char * start; /* start of current dir */ int length; /* length of dir */ - char *slash; /* last slash in dir */ + char * slash; /* last slash in dir */ char save; /* place to character from where we */ /* temporarily null terminate */ /* get next directory */ - while(isspace(*p)) { + while( isspace( *p ) ) { p++; } - if(*p == '\0') { + if( *p == '\0' ) { break; } start = p; /* find the end of the directory */ - while(*p != '\0' && !isspace(*p)) { + while( *p != '\0' && !isspace( *p ) ) { p++; } save = *p; - if(*p == 0) { + if( *p == 0 ) { done = 1; } else { *p = '\0'; } p++; /* leave p after terminating null */ - dir = (Dir *)sc_malloc(sizeof(Dir)); + dir = ( Dir * )sc_malloc( sizeof( Dir ) ); /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ - if(!strcmp(".", start)) { + if( !strcmp( ".", start ) ) { dir->leaf = dir->full; - LISTadd_last(EXPRESS_path, dir); - *(p - 1) = save; /* put char back where */ + LISTadd_last( EXPRESS_path, dir ); + *( p - 1 ) = save; /* put char back where */ /* temp null was */ continue; } - length = (p - 1) - start; + length = ( p - 1 ) - start; /* if slash present at end, don't add another */ - slash = strrchr(start, '/'); - if(slash && (slash[1] == '\0')) { - strcpy(dir->full, start); + slash = strrchr( start, '/' ); + if( slash && ( slash[1] == '\0' ) ) { + strcpy( dir->full, start ); dir->leaf = dir->full + length; } else { - sprintf(dir->full, "%s/", start); + sprintf( dir->full, "%s/", start ); dir->leaf = dir->full + length + 1; } - LISTadd_last(EXPRESS_path, dir); + LISTadd_last( EXPRESS_path, dir ); - *(p - 1) = save; /* put char back where temp null was */ + *( p - 1 ) = save; /* put char back where temp null was */ } } } -static void EXPRESS_PATHfree(void) -{ - LISTdo(EXPRESS_path, dir, Dir *) - sc_free(dir); +static void EXPRESS_PATHfree( void ) { + LISTdo( EXPRESS_path, dir, Dir * ) + sc_free( dir ); LISTod - LISTfree(EXPRESS_path); + LISTfree( EXPRESS_path ); } /** inform object system about bit representation for handling pass diagnostics */ -void PASSinitialize() -{ +void PASSinitialize() { } /** Initialize the Express package. */ -void EXPRESSinitialize(void) -{ +void EXPRESSinitialize( void ) { MEMORYinitialize(); ERRORinitialize(); @@ -287,15 +279,14 @@ void EXPRESSinitialize(void) STMTinitialize(); SCANinitialize(); - + BUILTINSinitialize(); EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */ } /** Clean up the EXPRESS package. */ -void EXPRESScleanup(void) -{ +void EXPRESScleanup( void ) { EXPRESS_PATHfree(); DICTcleanup(); @@ -312,103 +303,101 @@ void EXPRESScleanup(void) ** \return resulting Working Form model ** Parse an Express source file into the Working Form. */ -void EXPRESSparse(Express model, FILE *fp, char *filename) -{ +void EXPRESSparse( Express model, FILE * fp, char * filename ) { yyexpresult = model; - if(!fp) { - fp = fopen(filename, "r"); + if( !fp ) { + fp = fopen( filename, "r" ); } - if(!fp) { + if( !fp ) { /* go down path looking for file */ - LISTdo(EXPRESS_path, dir, Dir *) - sprintf(dir->leaf, "%s", filename); - if(0 != (fp = fopen(dir->full, "r"))) { + LISTdo( EXPRESS_path, dir, Dir * ) + sprintf( dir->leaf, "%s", filename ); + if( 0 != ( fp = fopen( dir->full, "r" ) ) ) { filename = dir->full; break; } LISTod } - if(!fp) { - ERRORreport(FILE_UNREADABLE, filename, strerror(errno)); + if( !fp ) { + ERRORreport( FILE_UNREADABLE, filename, strerror( errno ) ); return; } - if(filename) { - char *dot = strrchr(filename, '.'); - char *slash = strrchr(filename, '/'); + if( filename ) { + char * dot = strrchr( filename, '.' ); + char * slash = strrchr( filename, '/' ); /* get beginning of basename */ - char *start = slash ? (slash + 1) : filename; + char * start = slash ? ( slash + 1 ) : filename; - int length = strlen(start); + int length = strlen( start ); /* drop .exp suffix if present */ - if(dot && !strcmp(dot, ".exp")) { + if( dot && !strcmp( dot, ".exp" ) ) { length -= 4; } - model->u.express->basename = (char *)sc_malloc(length + 1); - memcpy(model->u.express->basename, filename, length); + model->u.express->basename = ( char * )sc_malloc( length + 1 ); + memcpy( model->u.express->basename, filename, length ); model->u.express->basename[length] = '\0'; /* get new copy of filename to avoid being smashed */ /* by subsequent lookups on EXPRESS_path */ - model->u.express->filename = SCANstrdup(filename); + model->u.express->filename = SCANstrdup( filename ); filename = model->u.express->filename; } PARSEnew_schemas = LISTcreate(); - PARSERrun(filename, model->u.express->file = fp); + PARSERrun( filename, model->u.express->file = fp ); } /* TODO LEMON ought to put this in expparse.h */ void parserInitState(); /** start parsing a new schema file */ -static Express PARSERrun(char *filename, FILE *fp) -{ - extern void SCAN_lex_init(char *, FILE *); +static Express PARSERrun( char * filename, FILE * fp ) { + extern void SCAN_lex_init( char *, FILE * ); extern YYSTYPE yylval; extern int yyerrstatus; int tokenID; parse_data_t parseData; - void *parser = ParseAlloc(malloc); - perplex_t scanner = perplexFileScanner(fp); + void * parser = ParseAlloc( malloc ); + perplex_t scanner = perplexFileScanner( fp ); parseData.scanner = scanner; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "parse (pass %d)\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "parse (pass %d)\n", EXPRESSpass ); } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: %s (schema file)\n", filename); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "parse: %s (schema file)\n", filename ); } - SCAN_lex_init(filename, fp); + SCAN_lex_init( filename, fp ); parserInitState(); yyerrstatus = 0; /* NOTE uncomment the next line to enable parser tracing */ /* ParseTrace( stderr, "- expparse - " ); */ - while((tokenID = yylex(scanner)) > 0) { - Parse(parser, tokenID, yylval, parseData); + while( ( tokenID = yylex( scanner ) ) > 0 ) { + Parse( parser, tokenID, yylval, parseData ); } - Parse(parser, 0, yylval, parseData); + Parse( parser, 0, yylval, parseData ); /* want 0 on success, 1 on invalid input, 2 on memory exhaustion */ - if(yyerrstatus != 0) { - fprintf(stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus); - ERRORreport(BAIL_OUT); + if( yyerrstatus != 0 ) { + fprintf( stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus ); + ERRORreport( BAIL_OUT ); /* free model and model->u.express */ return 0; } EXPRESSpass = 1; - perplexFree(scanner); - ParseFree(parser, free); + perplexFree( scanner ); + ParseFree( parser, free ); return yyexpresult; } @@ -420,42 +409,40 @@ static Express PARSERrun(char *filename, FILE *fp) * * Sept 2013 - remove unused param enum rename_type type (TODO should this be used)? */ -static void *SCOPEfind_for_rename(Scope schema, char *name) -{ +static void * SCOPEfind_for_rename( Scope schema, char * name ) { void *result; - Rename *rename; + Rename * rename; /* object can only appear in top level symbol table */ /* OR in another rename clause */ - result = DICTlookup(schema->symbol_table, name); - if(result) { + result = DICTlookup( schema->symbol_table, name ); + if( result ) { return result; } /* Occurs in a fully USE'd schema? */ - LISTdo(schema->u.schema->use_schemas, use_schema, Schema) { + LISTdo( schema->u.schema->use_schemas, use_schema, Schema ) { /* follow chain'd USEs */ - result = SCOPEfind_for_rename(use_schema, name); - if(result) { - return(result); + result = SCOPEfind_for_rename( use_schema, name ); + if( result ) { + return( result ); } - } - LISTod; + } LISTod; /* Occurs in a partially USE'd schema? */ - rename = (Rename *)DICTlookup(schema->u.schema->usedict, name); - if(rename) { - RENAMEresolve(rename, schema); + rename = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); + if( rename ) { + RENAMEresolve( rename, schema ); DICT_type = rename->type; - return(rename->object); + return( rename->object ); } - LISTdo(schema->u.schema->uselist, r, Rename *) - if(!strcmp((r->nnew ? r->nnew : r->old)->name, name)) { - RENAMEresolve(r, schema); + LISTdo( schema->u.schema->uselist, r, Rename * ) + if( !strcmp( ( r->nnew ? r->nnew : r->old )->name, name ) ) { + RENAMEresolve( r, schema ); DICT_type = r->type; - return(r->object); + return( r->object ); } LISTod; @@ -466,114 +453,111 @@ static void *SCOPEfind_for_rename(Scope schema, char *name) return 0; } -void RENAMEresolve(Rename *r, Schema s) -{ +void RENAMEresolve( Rename * r, Schema s ) { void *remote; /* if (is_resolved_rename_raw(r->old)) return;*/ - if(r->object) { + if( r->object ) { return; } - if(is_resolve_failed_raw(r->old)) { + if( is_resolve_failed_raw( r->old ) ) { return; } - if(is_resolve_in_progress_raw(r->old)) { - ERRORreport_with_symbol(CIRCULAR_REFERENCE, - r->old, r->old->name); - resolve_failed_raw(r->old); + if( is_resolve_in_progress_raw( r->old ) ) { + ERRORreport_with_symbol( CIRCULAR_REFERENCE, + r->old, r->old->name ); + resolve_failed_raw( r->old ); return; } - resolve_in_progress_raw(r->old); + resolve_in_progress_raw( r->old ); - remote = SCOPEfind_for_rename(r->schema, r->old->name); - if(remote == 0) { - ERRORreport_with_symbol(REF_NONEXISTENT, r->old, - r->old->name, r->schema->symbol.name); - resolve_failed_raw(r->old); + remote = SCOPEfind_for_rename( r->schema, r->old->name ); + if( remote == 0 ) { + ERRORreport_with_symbol( REF_NONEXISTENT, r->old, + r->old->name, r->schema->symbol.name ); + resolve_failed_raw( r->old ); } else { r->object = remote; r->type = DICT_type; - switch(r->rename_type) { + switch( r->rename_type ) { case use: - SCHEMAdefine_use(s, r); + SCHEMAdefine_use( s, r ); break; case ref: - SCHEMAdefine_reference(s, r); + SCHEMAdefine_reference( s, r ); break; } /* resolve_rename_raw(r->old);*/ } - resolve_not_in_progress_raw(r->old); + resolve_not_in_progress_raw( r->old ); } #ifdef using_enum_items_is_a_pain -static void RENAMEresolve_enum(Type t, Schema s) -{ +static void RENAMEresolve_enum( Type t, Schema s ) { DictionaryEntry de; Expression x; - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (x = (Expression)DICTdo(&de))) { + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( x = ( Expression )DICTdo( &de ) ) ) { /* SCHEMAadd_use(s, v*/ /* raw(x->symbol.name);*/ } } #endif -Schema EXPRESSfind_schema(Dictionary modeldict, char *name) -{ +Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) { Schema s; - FILE *fp; - char *src, *dest; + FILE * fp; + char * src, *dest; char lower[MAX_SCHEMA_FILENAME_SIZE]; /* avoid lowerizing original */ - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema reference)\n", - EXPRESSpass, name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema reference)\n", + EXPRESSpass, name ); } - s = (Schema)DICTlookup(modeldict, name); - if(s) { + s = ( Schema )DICTlookup( modeldict, name ); + if( s ) { return s; } dest = lower; - for(src = name; *src; src++) { - *dest++ = tolower(*src); + for( src = name; *src; src++ ) { + *dest++ = tolower( *src ); } *dest = '\0'; /* go down path looking for file */ - LISTdo(EXPRESS_path, dir, Dir *) - sprintf(dir->leaf, "%s.exp", lower); - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file?)\n", - EXPRESSpass, dir->full); - } - fp = fopen(dir->full, "r"); - if(fp) { + LISTdo( EXPRESS_path, dir, Dir * ) + sprintf( dir->leaf, "%s.exp", lower ); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file?)\n", + EXPRESSpass, dir->full ); + } + fp = fopen( dir->full, "r" ); + if( fp ) { Express express; - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file found)\n", - EXPRESSpass, dir->full); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file found)\n", + EXPRESSpass, dir->full ); } - express = PARSERrun(SCANstrdup(dir->full), fp); - if(express) { - s = (Schema)DICTlookup(modeldict, name); + express = PARSERrun( SCANstrdup( dir->full ), fp ); + if( express ) { + s = ( Schema )DICTlookup( modeldict, name ); } - if(s) { + if( s ) { return s; } - ERRORreport(SCHEMA_NOT_IN_OWN_SCHEMA_FILE, - name, dir->full); + ERRORreport( SCHEMA_NOT_IN_OWN_SCHEMA_FILE, + name, dir->full ); return 0; } else { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno ); } } LISTod @@ -587,20 +571,19 @@ Schema EXPRESSfind_schema(Dictionary modeldict, char *name) * because of partial schema references * \sa connect_schema_lists() */ -static void connect_lists(Dictionary modeldict, Schema schema, Linked_List list) -{ - Rename *r; +static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) { + Rename * r; /* translate symbols to schemas */ - LISTdo_links(list, l) - r = (Rename *)l->data; - r->schema = EXPRESSfind_schema(modeldict, r->schema_sym->name); - if(!r->schema) { + LISTdo_links( list, l ) + r = ( Rename * )l->data; + r->schema = EXPRESSfind_schema( modeldict, r->schema_sym->name ); + if( !r->schema ) { ERRORreport_with_symbol(UNDEFINED_SCHEMA, - r->schema_sym, - r->schema_sym->name); - resolve_failed_raw(r->old); - resolve_failed(schema); + r->schema_sym, + r->schema_sym->name ); + resolve_failed_raw( r->old ); + resolve_failed( schema ); } LISTod } @@ -609,18 +592,17 @@ static void connect_lists(Dictionary modeldict, Schema schema, Linked_List list) * same as `connect_lists` except for full schemas * \sa connect_lists() */ -static void connect_schema_lists(Dictionary modeldict, Schema schema, Linked_List schema_list) -{ - Symbol *sym; +static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_list ) { + Symbol * sym; Schema ref_schema; /* translate symbols to schemas */ - LISTdo_links(schema_list, list) - sym = (Symbol *)list->data; - ref_schema = EXPRESSfind_schema(modeldict, sym->name); - if(!ref_schema) { - ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name); - resolve_failed(schema); + LISTdo_links( schema_list, list ) + sym = ( Symbol * )list->data; + ref_schema = EXPRESSfind_schema( modeldict, sym->name ); + if( !ref_schema ) { + ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name ); + resolve_failed( schema ); list->data = NULL; } else { list->data = ref_schema; @@ -632,8 +614,7 @@ static void connect_schema_lists(Dictionary modeldict, Schema schema, Linked_Lis ** \param model - Working Form model to resolve ** Perform symbol resolution on a loosely-coupled WF. */ -void EXPRESSresolve(Express model) -{ +void EXPRESSresolve( Express model ) { /* resolve multiple schemas. Schemas will be resolved here or when */ /* they are first encountered by a use/reference clause, whichever */ /* comes first - DEL */ @@ -642,14 +623,14 @@ void EXPRESSresolve(Express model) DictionaryEntry de; jmp_buf env; - if(setjmp(env)) { + if( setjmp( env ) ) { return; } - ERRORsafe(env); + ERRORsafe( env ); EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving schema references\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving schema references\n", EXPRESSpass ); } /* connect the real schemas to all the rename clauses */ @@ -659,59 +640,58 @@ void EXPRESSresolve(Express model) /* add news schemas to end, drop old ones off the front as we */ /* process them. */ - LISTdo(PARSEnew_schemas, print_schema, Schema) { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, print_schema->symbol.name); + LISTdo( PARSEnew_schemas, print_schema, Schema ) { + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, print_schema->symbol.name ); } - if(print_schema->u.schema->uselist) - connect_lists(model->symbol_table, - print_schema, print_schema->u.schema->uselist); - if(print_schema->u.schema->reflist) - connect_lists(model->symbol_table, - print_schema, print_schema->u.schema->reflist); + if( print_schema->u.schema->uselist ) + connect_lists( model->symbol_table, + print_schema, print_schema->u.schema->uselist ); + if( print_schema->u.schema->reflist ) + connect_lists( model->symbol_table, + print_schema, print_schema->u.schema->reflist ); - connect_schema_lists(model->symbol_table, - print_schema, print_schema->u.schema->use_schemas); - connect_schema_lists(model->symbol_table, - print_schema, print_schema->u.schema->ref_schemas); - } - LISTod; + connect_schema_lists( model->symbol_table, + print_schema, print_schema->u.schema->use_schemas ); + connect_schema_lists( model->symbol_table, + print_schema, print_schema->u.schema->ref_schemas ); + } LISTod; - LISTfree(PARSEnew_schemas); + LISTfree( PARSEnew_schemas ); PARSEnew_schemas = 0; /* just in case */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass ); } /* connect the object in each rename clause to the real object */ - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name ); } /* do USE's first because they take precedence */ - if(schema->u.schema->uselist) { - LISTdo(schema->u.schema->uselist, r, Rename *) - RENAMEresolve(r, schema); + if( schema->u.schema->uselist ) { + LISTdo( schema->u.schema->uselist, r, Rename * ) + RENAMEresolve( r, schema ); LISTod; - LISTfree(schema->u.schema->uselist); + LISTfree( schema->u.schema->uselist ); schema->u.schema->uselist = 0; } - if(schema->u.schema->reflist) { - LISTdo(schema->u.schema->reflist, r, Rename *) - RENAMEresolve(r, schema); + if( schema->u.schema->reflist ) { + LISTdo( schema->u.schema->reflist, r, Rename * ) + RENAMEresolve( r, schema ); LISTod; - LISTfree(schema->u.schema->reflist); + LISTfree( schema->u.schema->reflist ); schema->u.schema->reflist = 0; } } @@ -719,29 +699,29 @@ void EXPRESSresolve(Express model) /* resolve sub- and supertype references. also resolve all */ /* defined types */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass ); } - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - SCOPEresolve_subsupers(schema); + SCOPEresolve_subsupers( schema ); } - if(ERRORoccurred) { + if( ERRORoccurred ) { ERRORunsafe(); } /* resolve types */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving types\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving types\n", EXPRESSpass ); } - SCOPEresolve_types(model); - if(ERRORoccurred) { + SCOPEresolve_types( model ); + if( ERRORoccurred ) { ERRORunsafe(); } @@ -750,57 +730,56 @@ void EXPRESSresolve(Express model) /* doesn't really deserve its own pass, but needs to come after */ /* type resolution */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving implied USE's\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving implied USE's\n", EXPRESSpass ); } - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name ); } - if(schema->u.schema->usedict) { - DICTdo_init(schema->u.schema->usedict, &fg) - while(0 != (r = (Rename)DICTdo(&fg))) { - if((r->type = OBJ_TYPE) && ((Type)r->object)->body && - TYPEis_enumeration((Type)r->object)) { - RENAMEresolve_enum((Type)r->object, schema); + if( schema->u.schema->usedict ) { + DICTdo_init( schema->u.schema->usedict, &fg ) + while( 0 != ( r = ( Rename )DICTdo( &fg ) ) ) { + if( ( r->type = OBJ_TYPE ) && ( ( Type )r->object )->body && + TYPEis_enumeration( ( Type )r->object ) ) { + RENAMEresolve_enum( ( Type )r->object, schema ); } } } } - if(ERRORoccurred) { + if( ERRORoccurred ) { ERRORunsafe(); } #endif EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass ); } - SCOPEresolve_expressions_statements(model); - if(ERRORoccurred) { + SCOPEresolve_expressions_statements( model ); + if( ERRORoccurred ) { ERRORunsafe(); } /* mark everything resolved if possible */ - DICTdo_init(model->symbol_table, &de); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_resolvable(schema)) { - resolved_all(schema); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_resolvable( schema ) ) { + resolved_all( schema ); } } } -Function funcdef(char *name, int pcount, Type ret_typ) -{ +Function funcdef(char *name, int pcount, Type ret_typ) { Function f = ALGcreate(OBJ_FUNCTION); f->symbol.name = name; f->u.func->pcount = pcount; @@ -811,8 +790,7 @@ Function funcdef(char *name, int pcount, Type ret_typ) return f; } -void procdef(char *name, int pcount) -{ +void procdef(char *name, int pcount) { Procedure p = ALGcreate(OBJ_PROCEDURE); p->symbol.name = name; p->u.proc->pcount = pcount; @@ -821,40 +799,39 @@ void procdef(char *name, int pcount) DICTdefine(EXPRESSbuiltins, name, p, 0, OBJ_PROCEDURE); } -void BUILTINSinitialize() -{ - EXPRESSbuiltins = DICTcreate(35); - procdef("INSERT", 3); - procdef("REMOVE", 2); - - funcdef("ABS", 1, Type_Number); - funcdef("ACOS", 1, Type_Real); - funcdef("ASIN", 1, Type_Real); - funcdef("ATAN", 2, Type_Real); - funcdef("BLENGTH", 1, Type_Integer); - funcdef("COS", 1, Type_Real); - funcdef("EXISTS", 1, Type_Boolean); - funcdef("EXP", 1, Type_Real); - funcdef("FORMAT", 2, Type_String); - funcdef("HIBOUND", 1, Type_Integer); - funcdef("HIINDEX", 1, Type_Integer); - funcdef("LENGTH", 1, Type_Integer); - funcdef("LOBOUND", 1, Type_Integer); - funcdef("LOG", 1, Type_Real); - funcdef("LOG10", 1, Type_Real); - funcdef("LOG2", 1, Type_Real); - funcdef("LOINDEX", 1, Type_Integer); - funcdef("ODD", 1, Type_Logical); - funcdef("ROLESOF", 1, Type_Set_Of_String); - funcdef("SIN", 1, Type_Real); - funcdef("SIZEOF", 1, Type_Integer); - funcdef("SQRT", 1, Type_Real); - funcdef("TAN", 1, Type_Real); - funcdef("TYPEOF", 1, Type_Set_Of_String); - funcdef("VALUE", 1, Type_Number); - funcdef("VALUE_IN", 2, Type_Logical); - funcdef("VALUE_UNIQUE", 1, Type_Logical); - - FUNC_NVL = funcdef("NVL", 2, Type_Generic); - FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic); +void BUILTINSinitialize() { + EXPRESSbuiltins = DICTcreate( 35 ); + procdef("INSERT", 3 ); + procdef("REMOVE", 2 ); + + funcdef("ABS", 1, Type_Number ); + funcdef("ACOS", 1, Type_Real ); + funcdef("ASIN", 1, Type_Real ); + funcdef("ATAN", 2, Type_Real ); + funcdef("BLENGTH", 1, Type_Integer ); + funcdef("COS", 1, Type_Real ); + funcdef("EXISTS", 1, Type_Boolean ); + funcdef("EXP", 1, Type_Real ); + funcdef("FORMAT", 2, Type_String ); + funcdef("HIBOUND", 1, Type_Integer ); + funcdef("HIINDEX", 1, Type_Integer ); + funcdef("LENGTH", 1, Type_Integer ); + funcdef("LOBOUND", 1, Type_Integer ); + funcdef("LOG", 1, Type_Real ); + funcdef("LOG10", 1, Type_Real ); + funcdef("LOG2", 1, Type_Real ); + funcdef("LOINDEX", 1, Type_Integer ); + funcdef("ODD", 1, Type_Logical ); + funcdef("ROLESOF", 1, Type_Set_Of_String ); + funcdef("SIN", 1, Type_Real ); + funcdef("SIZEOF", 1, Type_Integer ); + funcdef("SQRT", 1, Type_Real ); + funcdef("TAN", 1, Type_Real ); + funcdef("TYPEOF", 1, Type_Set_Of_String ); + funcdef("VALUE", 1, Type_Number ); + funcdef("VALUE_IN", 2, Type_Logical ); + funcdef("VALUE_UNIQUE", 1, Type_Logical ); + + FUNC_NVL = funcdef("NVL", 2, Type_Generic ); + FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic ); } diff --git a/src/express/expscan.l b/src/express/expscan.l index cde644887..cbd56c535 100644 --- a/src/express/expscan.l +++ b/src/express/expscan.l @@ -118,11 +118,6 @@ static int nesting_level = 0; #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; -/* isascii isn't part of newer C standards */ -#ifndef isascii -# define isascii(c) ((unsigned)((c) + 1) < 129) -#endif - static_inline int SCANnextchar(char* buffer) diff --git a/src/express/factory.c b/src/express/factory.c index 0e739518c..daf6ee7d3 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -34,144 +34,138 @@ Type Type_Set_Of_String; Type Type_Set_Of_Generic; Type Type_Bag_Of_Generic; -void FACTORYinitialize() -{ +void FACTORYinitialize() { /* Very commonly-used read-only types */ - Type_Unknown = TYPEcreate(unknown_); - Type_Dont_Care = TYPEcreate(special_); - Type_Bad = TYPEcreate(special_); - Type_Runtime = TYPEcreate(runtime_); + Type_Unknown = TYPEcreate( unknown_ ); + Type_Dont_Care = TYPEcreate( special_ ); + Type_Bad = TYPEcreate( special_ ); + Type_Runtime = TYPEcreate( runtime_ ); - Type_Enumeration = TYPEcreate(enumeration_); + Type_Enumeration = TYPEcreate( enumeration_ ); Type_Enumeration->u.type->body->flags.shared = 1; - resolved_all(Type_Enumeration); + resolved_all( Type_Enumeration ); - Type_Expression = TYPEcreate(op_); + Type_Expression = TYPEcreate( op_ ); Type_Expression->u.type->body->flags.shared = 1; - Type_Aggregate = TYPEcreate(aggregate_); + Type_Aggregate = TYPEcreate( aggregate_ ); Type_Aggregate->u.type->body->flags.shared = 1; Type_Aggregate->u.type->body->base = Type_Runtime; - Type_Integer = TYPEcreate(integer_); + Type_Integer = TYPEcreate( integer_ ); Type_Integer->u.type->body->flags.shared = 1; - resolved_all(Type_Integer); + resolved_all( Type_Integer ); - Type_Real = TYPEcreate(real_); + Type_Real = TYPEcreate( real_ ); Type_Real->u.type->body->flags.shared = 1; - resolved_all(Type_Real); + resolved_all( Type_Real ); - Type_Number = TYPEcreate(number_); + Type_Number = TYPEcreate( number_ ); Type_Number->u.type->body->flags.shared = 1; - resolved_all(Type_Number); + resolved_all( Type_Number ); - Type_String = TYPEcreate(string_); + Type_String = TYPEcreate( string_ ); Type_String->u.type->body->flags.shared = 1; - resolved_all(Type_String); + resolved_all( Type_String ); - Type_String_Encoded = TYPEcreate(string_); + Type_String_Encoded = TYPEcreate( string_ ); Type_String_Encoded->u.type->body->flags.shared = 1; Type_String_Encoded->u.type->body->flags.encoded = 1; - resolved_all(Type_String); + resolved_all( Type_String ); - Type_Logical = TYPEcreate(logical_); + Type_Logical = TYPEcreate( logical_ ); Type_Logical->u.type->body->flags.shared = 1; - resolved_all(Type_Logical); + resolved_all( Type_Logical ); - Type_Binary = TYPEcreate(binary_); + Type_Binary = TYPEcreate( binary_ ); Type_Binary->u.type->body->flags.shared = 1; - resolved_all(Type_Binary); + resolved_all( Type_Binary ); - Type_Number = TYPEcreate(number_); + Type_Number = TYPEcreate( number_ ); Type_Number->u.type->body->flags.shared = 1; - resolved_all(Type_Number); + resolved_all( Type_Number ); - Type_Boolean = TYPEcreate(boolean_); + Type_Boolean = TYPEcreate( boolean_ ); Type_Boolean->u.type->body->flags.shared = 1; - resolved_all(Type_Boolean); + resolved_all( Type_Boolean ); - Type_Generic = TYPEcreate(generic_); + Type_Generic = TYPEcreate( generic_ ); Type_Generic->u.type->body->flags.shared = 1; - resolved_all(Type_Generic); + resolved_all( Type_Generic ); - Type_Set_Of_String = TYPEcreate(set_); + Type_Set_Of_String = TYPEcreate( set_ ); Type_Set_Of_String->u.type->body->flags.shared = 1; Type_Set_Of_String->u.type->body->base = Type_String; - Type_Set_Of_Generic = TYPEcreate(set_); + Type_Set_Of_Generic = TYPEcreate( set_ ); Type_Set_Of_Generic->u.type->body->flags.shared = 1; Type_Set_Of_Generic->u.type->body->base = Type_Generic; - Type_Bag_Of_Generic = TYPEcreate(bag_); + Type_Bag_Of_Generic = TYPEcreate( bag_ ); Type_Bag_Of_Generic->u.type->body->flags.shared = 1; Type_Bag_Of_Generic->u.type->body->base = Type_Generic; - Type_Attribute = TYPEcreate(attribute_); + Type_Attribute = TYPEcreate( attribute_ ); Type_Attribute->u.type->body->flags.shared = 1; - Type_Entity = TYPEcreate(entity_); + Type_Entity = TYPEcreate( entity_ ); Type_Entity->u.type->body->flags.shared = 1; - Type_Funcall = TYPEcreate(funcall_); + Type_Funcall = TYPEcreate( funcall_ ); Type_Funcall->u.type->body->flags.shared = 1; - Type_Generic = TYPEcreate(generic_); + Type_Generic = TYPEcreate( generic_ ); Type_Generic->u.type->body->flags.shared = 1; - Type_Identifier = TYPEcreate(identifier_); + Type_Identifier = TYPEcreate( identifier_ ); Type_Identifier->u.type->body->flags.shared = 1; - Type_Repeat = TYPEcreate(integer_); + Type_Repeat = TYPEcreate( integer_ ); Type_Repeat->u.type->body->flags.shared = 1; Type_Repeat->u.type->body->flags.repeat = 1; - Type_Oneof = TYPEcreate(oneof_); + Type_Oneof = TYPEcreate( oneof_ ); Type_Oneof->u.type->body->flags.shared = 1; - Type_Query = TYPEcreate(query_); + Type_Query = TYPEcreate( query_ ); Type_Query->u.type->body->flags.shared = 1; - Type_Self = TYPEcreate(self_); + Type_Self = TYPEcreate( self_ ); Type_Self->u.type->body->flags.shared = 1; } /** Create and return an empty scope inside a parent scope. */ -Scope SCOPEcreate(char type) -{ +Scope SCOPEcreate( char type ) { Scope d = SCOPE_new(); - d->symbol_table = DICTcreate(50); + d->symbol_table = DICTcreate( 50 ); d->type = type; return d; } -Scope SCOPEcreate_tiny(char type) -{ +Scope SCOPEcreate_tiny( char type ) { Scope d = SCOPE_new(); - d->symbol_table = DICTcreate(1); + d->symbol_table = DICTcreate( 1 ); d->type = type; return d; } -void SCOPEdestroy(Scope scope) -{ - SCOPE_destroy(scope); +void SCOPEdestroy( Scope scope ) { + SCOPE_destroy( scope ); } /** * create a scope without a symbol table * used for simple types */ -Scope SCOPEcreate_nostab(char type) -{ +Scope SCOPEcreate_nostab( char type ) { Scope d = SCOPE_new(); d->type = type; return d; } /** Create and return a schema. */ -Schema SCHEMAcreate(void) -{ - Scope s = SCOPEcreate(OBJ_SCHEMA); +Schema SCHEMAcreate( void ) { + Scope s = SCOPEcreate( OBJ_SCHEMA ); s->enum_table = DICTcreate(50); s->u.schema = SCHEMA_new(); return s; @@ -180,14 +174,13 @@ Schema SCHEMAcreate(void) /** * create a type with no symbol table */ -Type TYPEcreate_nostab(struct Symbol_ *symbol, Scope scope, char objtype) -{ - Type t = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->symbol = *symbol; - DICTdefine(scope->symbol_table, symbol->name, t, &t->symbol, objtype); + DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); return t; } @@ -197,9 +190,8 @@ Type TYPEcreate_nostab(struct Symbol_ *symbol, Scope scope, char objtype) * such as enumerations (which have a symbol table added later) * or to be used as a type reference */ -Type TYPEcreate_name(Symbol *symbol) -{ - Scope s = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_name( Symbol * symbol ) { + Scope s = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead t = TYPEHEAD_new(); s->u.type = t; @@ -207,35 +199,31 @@ Type TYPEcreate_name(Symbol *symbol) return s; } -Type TYPEcreate(enum type_enum type) -{ - TypeBody tb = TYPEBODYcreate(type); - Type t = TYPEcreate_from_body_anonymously(tb); - return(t); +Type TYPEcreate( enum type_enum type ) { + TypeBody tb = TYPEBODYcreate( type ); + Type t = TYPEcreate_from_body_anonymously( tb ); + return( t ); } -Type TYPEcreate_from_body_anonymously(TypeBody tb) -{ - Type t = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_from_body_anonymously( TypeBody tb ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->u.type->body = tb; t->symbol.name = 0; - SYMBOLset(t); + SYMBOLset( t ); return t; } -TypeBody TYPEBODYcreate(enum type_enum type) -{ +TypeBody TYPEBODYcreate( enum type_enum type ) { TypeBody tb = TYPEBODY_new(); tb->type = type; return tb; } -Symbol *SYMBOLcreate(char *name, int line, const char *filename) -{ - Symbol *sym = SYMBOL_new(); +Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { + Symbol * sym = SYMBOL_new(); sym->name = name; sym->line = line; sym->filename = filename; /* NOTE this used the global 'current_filename', @@ -254,19 +242,18 @@ Symbol *SYMBOLcreate(char *name, int line, const char *filename) ** empty list; all other aspects of the entity are initially ** undefined (i.e., have appropriate NULL values). */ -Entity ENTITYcreate(Symbol *sym) -{ - Scope s = SCOPEcreate(OBJ_ENTITY); +Entity ENTITYcreate( Symbol * sym ) { + Scope s = SCOPEcreate( OBJ_ENTITY ); s->u.entity = ENTITY_new(); s->u.entity->attributes = LISTcreate(); s->u.entity->inheritance = ENTITY_INHERITANCE_UNINITIALIZED; /* it's so useful to have a type hanging around for each entity */ - s->u.entity->type = TYPEcreate_name(sym); - s->u.entity->type->u.type->body = TYPEBODYcreate(entity_); + s->u.entity->type = TYPEcreate_name( sym ); + s->u.entity->type->u.type->body = TYPEBODYcreate( entity_ ); s->u.entity->type->u.type->body->entity = s; - return(s); + return( s ); } /** VARcreate @@ -279,39 +266,35 @@ Entity ENTITYcreate(Symbol *sym) ** dynamic. Special flags associated with the variable ** (e.g., optional) are initially false. */ -Variable VARcreate(Expression name, Type type) -{ +Variable VARcreate( Expression name, Type type ) { Variable v = VAR_new(); v->name = name; v->type = type; return v; } -Expression EXPcreate(Type type) -{ +Expression EXPcreate( Type type ) { Expression e; e = EXP_new(); - SYMBOLset(e); + SYMBOLset( e ); e->type = type; e->return_type = Type_Unknown; - return(e); + return( e ); } /** * use this when the return_type is the same as the type * For example, for constant integers */ -Expression EXPcreate_simple(Type type) -{ +Expression EXPcreate_simple( Type type ) { Expression e; e = EXP_new(); - SYMBOLset(e); + SYMBOLset( e ); e->type = e->return_type = type; - return(e); + return( e ); } -Expression EXPcreate_from_symbol(Type type, Symbol *symbol) -{ +Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { Expression e; e = EXP_new(); e->type = type; @@ -328,9 +311,8 @@ Expression EXPcreate_from_symbol(Type type, Symbol *symbol) ** \returns Ternary_Expression - the expression created ** Create a ternary operation Expression. */ -Expression TERN_EXPcreate(Op_Code op, Expression operand1, Expression operand2, Expression operand3) -{ - Expression e = EXPcreate(Type_Expression); +Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, Expression operand3 ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand1; @@ -347,9 +329,8 @@ Expression TERN_EXPcreate(Op_Code op, Expression operand1, Expression operand2, ** \returns Binary_Expression - the expression created ** Create a binary operation Expression. */ -Expression BIN_EXPcreate(Op_Code op, Expression operand1, Expression operand2) -{ - Expression e = EXPcreate(Type_Expression); +Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand1; @@ -363,9 +344,8 @@ Expression BIN_EXPcreate(Op_Code op, Expression operand1, Expression operand2) ** \returns the expression created ** Create a unary operation Expression. */ -Expression UN_EXPcreate(Op_Code op, Expression operand) -{ - Expression e = EXPcreate(Type_Expression); +Expression UN_EXPcreate( Op_Code op, Expression operand ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand; @@ -379,15 +359,14 @@ Expression UN_EXPcreate(Op_Code op, Expression operand) ** Create a query Expression. ** NOTE Dec 2011 - MP - function description did not match actual params. Had to guess. */ -Expression QUERYcreate(Symbol *local, Expression aggregate) -{ - Expression e = EXPcreate_from_symbol(Type_Query, local); - Scope s = SCOPEcreate_tiny(OBJ_QUERY); - Expression e2 = EXPcreate_from_symbol(Type_Attribute, local); +Expression QUERYcreate( Symbol * local, Expression aggregate ) { + Expression e = EXPcreate_from_symbol( Type_Query, local ); + Scope s = SCOPEcreate_tiny( OBJ_QUERY ); + Expression e2 = EXPcreate_from_symbol( Type_Attribute, local ); - Variable v = VARcreate(e2, Type_Attribute); + Variable v = VARcreate( e2, Type_Attribute ); - DICTdefine(s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE); + DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); e->u.query = QUERY_new(); e->u.query->scope = s; e->u.query->local = v; diff --git a/src/express/fedex.c b/src/express/fedex.c index 9c03bcf99..805f8aeed 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -77,6 +77,7 @@ #include "sc_cf.h" #include "sc_memmgr.h" #include "sc_export.h" +#include "sc_version_string.h" #include "sc_getopt.h" #include "express/error.h" #include "express/express.h" @@ -90,17 +91,15 @@ extern int exp_yydebug; char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string because exp2cxx, exppp, etc may append their own options */ static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */ -void print_fedex_version(void) -{ - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, SC_VERSION); +void print_fedex_version( void ) { + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version ); no_need_to_work = 1; } -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { int c; int rc; - char *cp; + char * cp; int no_warnings = 1; int resolve = 1; int result; @@ -115,27 +114,27 @@ int main(int argc, char **argv) EXPRESSinitialize(); - if(EXPRESSinit_args) { - (*EXPRESSinit_args)(argc, argv); + if( EXPRESSinit_args ) { + ( *EXPRESSinit_args )( argc, argv ); } sc_optind = 1; - while((c = sc_getopt(argc, argv, EXPRESSgetopt_options)) != -1) { - switch(c) { + while( ( c = sc_getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 ) { + switch( c ) { case 'd': ERRORdebugging = 1; - switch(atoi(sc_optarg)) { + switch( atoi( sc_optarg ) ) { case 0: - fprintf(stderr, "\ndebug codes:\n"); - fprintf(stderr, " 0 - this help\n"); - fprintf(stderr, " 1 - basic debugging\n"); + fprintf( stderr, "\ndebug codes:\n" ); + fprintf( stderr, " 0 - this help\n" ); + fprintf( stderr, " 1 - basic debugging\n" ); #ifdef debugging - fprintf(stderr, " 4 - light malloc debugging\n"); - fprintf(stderr, " 5 - heavy malloc debugging\n"); - fprintf(stderr, " 6 - heavy malloc debugging while resolving\n"); + fprintf( stderr, " 4 - light malloc debugging\n" ); + fprintf( stderr, " 5 - heavy malloc debugging\n" ); + fprintf( stderr, " 6 - heavy malloc debugging while resolving\n" ); #endif /* debugging*/ #ifdef YYDEBUG - fprintf(stderr, " 8 - set YYDEBUG\n"); + fprintf( stderr, " 8 - set YYDEBUG\n" ); #endif /*YYDEBUG*/ break; case 1: @@ -143,10 +142,10 @@ int main(int argc, char **argv) break; #ifdef debugging case 4: - malloc_debug(1); + malloc_debug( 1 ); break; case 5: - malloc_debug(2); + malloc_debug( 2 ); break; case 6: malloc_debug_resolve = 1; @@ -174,16 +173,16 @@ int main(int argc, char **argv) case 'i': case 'w': no_warnings = 0; - ERRORset_warning(sc_optarg, c == 'w'); + ERRORset_warning( sc_optarg, c == 'w' ); break; case 'p': - for(cp = sc_optarg; *cp; cp++) { - if(*cp == '#') { + for( cp = sc_optarg; *cp; cp++ ) { + if( *cp == '#' ) { print_objects_while_running |= OBJ_PASS_BITS; - } else if(*cp == 'E') { + } else if( *cp == 'E' ) { print_objects_while_running = OBJ_ANYTHING_BITS; } else { - print_objects_while_running |= OBJget_bits(*cp); + print_objects_while_running |= OBJget_bits( *cp ); } } break; @@ -193,12 +192,12 @@ int main(int argc, char **argv) break; default: rc = 1; - if(EXPRESSgetopt) { - rc = (*EXPRESSgetopt)(c, sc_optarg); + if( EXPRESSgetopt ) { + rc = ( *EXPRESSgetopt )( c, sc_optarg ); } - if(rc == 1) { - if(ERRORusage_function) { - (*ERRORusage_function)(); + if( rc == 1 ) { + if( ERRORusage_function ) { + ( *ERRORusage_function )(); } else { EXPRESSusage(1); } @@ -206,66 +205,66 @@ int main(int argc, char **argv) break; } } - if(!input_filename) { + if( !input_filename ) { input_filename = argv[sc_optind]; - if(!input_filename) { + if( !input_filename ) { EXPRESScleanup(); - if(no_need_to_work) { - return(0); + if( no_need_to_work ) { + return( 0 ); } else { - (*ERRORusage_function)(); + ( *ERRORusage_function )(); } } } - if(no_warnings) { - ERRORset_all_warnings(1); + if( no_warnings ) { + ERRORset_all_warnings( 1 ); } - ERRORbuffer_messages(buffer_messages); + ERRORbuffer_messages( buffer_messages ); - if(EXPRESSinit_parse) { - (*EXPRESSinit_parse)(); + if( EXPRESSinit_parse ) { + ( *EXPRESSinit_parse )(); } model = EXPRESScreate(); - EXPRESSparse(model, (FILE *)0, input_filename); - if(ERRORoccurred) { - result = EXPRESS_fail(model); + EXPRESSparse( model, ( FILE * )0, input_filename ); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } #ifdef debugging - if(malloc_debug_resolve) { + if( malloc_debug_resolve ) { malloc_verify(); - malloc_debug(2); + malloc_debug( 2 ); } #endif /*debugging*/ - if(resolve) { - EXPRESSresolve(model); - if(ERRORoccurred) { - result = EXPRESS_fail(model); + if( resolve ) { + EXPRESSresolve( model ); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } } - if(EXPRESSbackend) { - (*EXPRESSbackend)(model); + if( EXPRESSbackend ) { + ( *EXPRESSbackend )( model ); } - if(ERRORoccurred) { - result = EXPRESS_fail(model); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } - result = EXPRESS_succeed(model); + result = EXPRESS_succeed( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } diff --git a/src/express/generated/CMakeLists.txt b/src/express/generated/CMakeLists.txt new file mode 100644 index 000000000..53e9293be --- /dev/null +++ b/src/express/generated/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(.) + +add_library(objlib_expscan_c OBJECT expscan.c) +set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + +add_library(objlib_expparse_c OBJECT expparse.c) +set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + diff --git a/src/express/generated/README b/src/express/generated/README index ccee594dd..7ca0ac13a 100644 --- a/src/express/generated/README +++ b/src/express/generated/README @@ -5,7 +5,8 @@ lexing and parsing logic. DO NOT EDIT THESE FILES. They are machine generated and should not be modified directly - bugs in these files need to be fixed in either the -Perplex/RE2C/Lemon input files or the tools themselves. +Perplex/RE2C/Lemon input files or the tools themselves. Directly changing +these files will result in a build failure. If changes need to be made, the correct approach is: @@ -13,4 +14,12 @@ If changes need to be made, the correct approach is: 2. make any necessary fixes to the input files and/or the generator tools. 3. run the build, and copy the new generated expscan and expparse c and h files to this directory. +4. run the build target "express_md5gen" to generate a new verification_info.cmake + file, and copy that file into this directory as well. +The verification_info.cmake file in this directory is used by CMake to protect +the integrity of the generated files. + +If iterative debugging is necessary, set the cmake configure variable +DEBUGGING_GENERATED_SOURCES to avoid having to update generated sources and md5 +sums each time an input file is changed. diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index bc97a5036..217c349d6 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -15,18 +15,18 @@ int yyerrstatus = 0; YYSTYPE yylval; -/* - * YACC grammar for Express parser. - * - * This software was developed by U.S. Government employees as part of - * their official duties and is not subject to copyright. - * - * $Log: expparse.y,v $ - * Revision 1.23 1997/11/14 17:09:04 libes - * allow multiple group references - * - * ** 22 older revision log records removed 3 January 2014 ** - */ + /* + * YACC grammar for Express parser. + * + * This software was developed by U.S. Government employees as part of + * their official duties and is not subject to copyright. + * + * $Log: expparse.y,v $ + * Revision 1.23 1997/11/14 17:09:04 libes + * allow multiple group references + * + * ** 22 older revision log records removed 3 January 2014 ** + */ #include "express/symbol.h" #include "express/linklist.h" @@ -38,9 +38,9 @@ YYSTYPE yylval; #include "expscan.h" #include -extern int print_objects_while_running; + extern int print_objects_while_running; -int tag_count; /**< use this to count tagged GENERIC types in the formal + int tag_count; /**< use this to count tagged GENERIC types in the formal * argument lists. Gross, but much easier to do it this * way then with the 'help' of yacc. Set it to -1 to * indicate that tags cannot be defined, only used @@ -50,46 +50,46 @@ int tag_count; /**< use this to count tagged GENERIC types in the formal * - snc */ -int local_var_count; /**< used to keep LOCAL variables in order + int local_var_count; /**< used to keep LOCAL variables in order * used in combination with Variable.offset */ -Express yyexpresult; /* hook to everything built by parser */ + Express yyexpresult; /* hook to everything built by parser */ -Symbol *interface_schema; /* schema of interest in use/ref clauses */ -void (*interface_func)(); /* func to attach rename clauses */ + Symbol *interface_schema; /* schema of interest in use/ref clauses */ + void (*interface_func)(); /* func to attach rename clauses */ -/* record schemas found in a single parse here, allowing them to be */ -/* differentiated from other schemas parsed earlier */ -Linked_List PARSEnew_schemas; + /* record schemas found in a single parse here, allowing them to be */ + /* differentiated from other schemas parsed earlier */ + Linked_List PARSEnew_schemas; -void SCANskip_to_end_schema(perplex_t scanner); + void SCANskip_to_end_schema(perplex_t scanner); -int yylineno; + int yylineno; -bool yyeof = false; + bool yyeof = false; #define MAX_SCOPE_DEPTH 20 /* max number of scopes that can be nested */ -static struct scope { - struct Scope_ *this_; - char type; /* one of OBJ_XXX */ - struct scope *pscope; /* pointer back to most recent scope */ - /* that has a printable name - for better */ - /* error messages */ -} scopes[MAX_SCOPE_DEPTH], *scope; + static struct scope { + struct Scope_ *this_; + char type; /* one of OBJ_XXX */ + struct scope *pscope; /* pointer back to most recent scope */ + /* that has a printable name - for better */ + /* error messages */ + } scopes[MAX_SCOPE_DEPTH], *scope; #define CURRENT_SCOPE (scope->this_) #define PREVIOUS_SCOPE ((scope-1)->this_) #define CURRENT_SCHEMA (scope->this_->u.schema) #define CURRENT_SCOPE_NAME (OBJget_symbol(scope->pscope->this_,scope->pscope->type)->name) #define CURRENT_SCOPE_TYPE_PRINTABLE (OBJget_type(scope->pscope->type)) -/* ths = new scope to enter */ -/* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ -/* are not named, in which case sym should be 0 */ -/* This is useful for when a diagnostic is printed, an earlier named */ -/* scoped can be used */ -/* typ = type of scope */ + /* ths = new scope to enter */ + /* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ + /* are not named, in which case sym should be 0 */ + /* This is useful for when a diagnostic is printed, an earlier named */ + /* scoped can be used */ + /* typ = type of scope */ #define PUSH_SCOPE(ths,sym,typ) \ if (sym) DICTdefine(scope->this_->symbol_table,(sym)->name,(Generic)ths,sym,typ);\ ths->superscope = scope->this_; \ @@ -102,12 +102,12 @@ static struct scope { } #define POP_SCOPE() scope-- -/* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ -/* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ + /* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ + /* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ #define PUSH_SCOPE_DUMMY() scope++ -/* normally the superscope is added by PUSH_SCOPE, but some things (types) */ -/* bother to get pushed so fix them this way */ + /* normally the superscope is added by PUSH_SCOPE, but some things (types) */ + /* bother to get pushed so fix them this way */ #define SCOPEadd_super(ths) ths->superscope = scope->this_; #define ERROR(code) ERRORreport(code, yylineno) @@ -127,10 +127,10 @@ void parserInitState() /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ -/* +/* ** These constants (all generated automatically by the parser generator) ** specify the various kinds of tokens (terminals) that the parser -** understands. +** understands. ** ** Each symbol here is a terminal symbol in the grammar. */ @@ -147,7 +147,7 @@ void parserInitState() ** and nonterminals. "int" is used otherwise. ** YYNOCODE is a number of type YYCODETYPE which corresponds ** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash +** number is used to fill in empty slots of the hash ** table. ** YYFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the @@ -156,7 +156,7 @@ void parserInitState() ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. -** ParseTOKENTYPE is the data type used for minor tokens given +** ParseTOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** YYMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of @@ -176,36 +176,36 @@ void parserInitState() #define YYCODETYPE unsigned short int #define YYNOCODE 280 #define YYACTIONTYPE unsigned short int -#define ParseTOKENTYPE YYSTYPE +#define ParseTOKENTYPE YYSTYPE typedef union { - int yyinit; - ParseTOKENTYPE yy0; - struct qualifier yy46; - Variable yy91; - Op_Code yy126; - struct entity_body yy176; - Where yy234; - struct subsuper_decl yy242; - struct type_flags yy252; - struct upper_lower yy253; - Symbol *yy275; - Type yy297; - Case_Item yy321; - Statement yy332; - Linked_List yy371; - struct type_either yy378; - struct subtypes yy385; - Expression yy401; - TypeBody yy477; - Integer yy507; + int yyinit; + ParseTOKENTYPE yy0; + struct qualifier yy46; + Variable yy91; + Op_Code yy126; + struct entity_body yy176; + Where yy234; + struct subsuper_decl yy242; + struct type_flags yy252; + struct upper_lower yy253; + Symbol* yy275; + Type yy297; + Case_Item yy321; + Statement yy332; + Linked_List yy371; + struct type_either yy378; + struct subtypes yy385; + Expression yy401; + TypeBody yy477; + Integer yy507; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 0 #endif #define ParseARG_SDECL parse_data_t parseData ; -#define ParseARG_PDECL , parse_data_t parseData -#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData -#define ParseARG_STORE yypParser->parseData = parseData +#define ParseARG_PDECL , parse_data_t parseData +#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData +#define ParseARG_STORE yypParser->parseData = parseData #define YYNSTATE 645 #define YYNRULE 332 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) @@ -232,7 +232,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; /* Next are the tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an -** action integer. +** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows @@ -257,7 +257,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; ** If the index value yy_shift_ofst[S]+X is out of range or if the value ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. +** and that yy_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after @@ -278,691 +278,691 @@ static const YYMINORTYPE yyzerominor = { 0 }; */ #define YY_ACTTAB_COUNT (2659) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, - /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, - /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, - /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, - /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, - /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, - /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, - /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, - /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, - /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, - /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, - /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, - /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, - /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, - /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, - /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, - /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, - /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, - /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, - /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, - /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, - /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, - /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, - /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, - /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, - /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, - /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, - /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, - /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, - /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, - /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, - /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, - /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, - /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, - /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, - /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, - /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, - /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, - /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, - /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, - /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, - /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, - /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, - /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, - /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, - /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, - /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, - /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, - /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, - /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, - /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, - /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, - /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, - /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, - /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, - /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, - /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, - /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, - /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, - /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, - /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, - /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, - /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, - /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, - /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, - /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, - /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, - /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, - /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, - /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, - /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, - /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, - /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, - /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, - /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, - /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, - /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, - /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, - /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, - /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, - /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, - /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, - /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, - /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, - /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, - /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, - /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, - /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, - /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, - /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, - /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, - /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, - /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, - /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, - /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, - /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, - /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, - /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, - /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, - /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, - /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, - /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, - /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, - /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, - /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, - /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, - /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, - /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, - /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, - /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, - /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, - /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, - /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, - /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, - /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, - /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, - /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, - /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, - /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, - /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, - /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, - /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, - /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, - /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, - /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, - /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, - /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, - /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, - /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, - /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, - /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, - /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, - /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, - /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, - /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, - /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, - /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, - /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, - /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, - /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, - /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, - /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, - /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, - /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, - /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, - /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, - /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, - /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, - /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, - /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, - /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, - /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, - /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, - /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, - /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, - /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, - /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, - /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, - /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, - /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, - /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, - /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, - /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, - /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, - /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, - /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, - /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, - /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, - /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, - /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, - /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, - /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, - /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, - /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, - /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, - /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, - /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, - /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, - /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, - /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, - /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, - /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, - /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, - /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, - /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, - /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, - /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, - /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, - /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, - /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, - /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, - /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, - /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, - /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, - /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, - /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, - /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, - /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, - /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, - /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, - /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, - /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, - /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, - /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, - /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, - /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, - /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, - /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, - /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, - /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, - /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, - /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, - /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, - /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, - /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, - /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, - /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, - /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, - /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, - /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, - /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, - /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, - /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, - /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, - /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, - /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, - /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, - /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, + /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, + /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, + /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, + /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, + /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, + /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, + /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, + /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, + /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, + /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, + /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, + /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, + /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, + /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, + /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, + /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, + /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, + /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, + /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, + /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, + /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, + /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, + /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, + /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, + /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, + /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, + /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, + /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, + /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, + /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, + /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, + /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, + /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, + /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, + /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, + /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, + /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, + /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, + /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, + /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, + /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, + /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, + /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, + /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, + /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, + /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, + /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, + /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, + /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, + /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, + /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, + /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, + /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, + /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, + /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, + /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, + /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, + /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, + /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, + /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, + /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, + /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, + /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, + /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, + /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, + /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, + /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, + /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, + /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, + /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, + /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, + /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, + /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, + /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, + /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, + /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, + /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, + /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, + /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, + /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, + /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, + /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, + /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, + /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, + /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, + /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, + /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, + /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, + /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, + /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, + /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, + /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, + /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, + /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, + /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, + /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, + /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, + /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, + /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, + /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, + /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, + /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, + /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, + /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, + /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, + /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, + /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, + /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, + /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, + /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, + /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, + /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, + /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, + /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, + /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, + /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, + /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, + /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, + /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, + /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, + /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, + /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, + /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, + /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, + /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, + /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, + /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, + /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, + /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, + /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, + /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, + /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, + /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, + /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, + /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, + /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, + /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, + /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, + /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, + /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, + /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, + /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, + /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, + /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, + /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, + /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, + /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, + /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, + /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, + /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, + /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, + /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, + /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, + /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, + /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, + /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, + /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, + /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, + /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, + /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, + /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, + /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, + /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, + /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, + /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, + /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, + /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, + /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, + /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, + /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, + /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, + /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, + /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, + /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, + /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, + /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, + /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, + /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, + /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, + /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, + /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, + /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, + /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, + /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, + /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, + /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, + /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, + /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, + /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, + /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, + /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, + /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, + /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, + /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, + /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, + /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, + /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, + /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, + /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, + /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, + /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, + /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, + /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, + /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, + /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, + /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, + /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, + /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, + /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, + /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, + /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, + /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, + /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, + /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, + /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, + /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, + /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, + /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, + /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, + /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, + /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, + /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, + /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, + /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, + /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, + /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, + /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, + /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, - /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, - /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, - /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, - /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, - /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, - /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, - /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, - /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, - /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, - /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, - /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, - /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, - /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, - /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, - /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, - /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, - /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, - /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, - /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, - /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, - /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, - /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, - /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, - /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, - /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, - /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, - /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, - /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, - /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, - /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, - /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, - /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, - /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, - /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, - /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, - /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, - /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, - /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, - /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, - /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, - /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, - /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, - /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, - /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, - /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, - /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, - /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, - /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, - /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, - /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, - /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, - /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, - /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, - /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, - /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, - /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, - /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, - /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, - /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, - /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, - /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, - /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, - /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, - /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, - /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, - /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, - /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, - /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, - /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, - /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, - /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, - /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, - /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, - /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, - /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, - /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, - /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, - /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, - /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, - /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, - /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, - /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, - /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, - /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, - /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, - /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, - /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, - /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, - /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, - /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, - /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, - /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, - /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, - /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, - /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, - /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, - /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, - /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, - /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, - /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, - /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, - /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, - /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, - /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, - /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, - /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, - /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, - /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, - /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, - /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, - /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, - /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, - /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, - /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, - /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, - /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, - /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, - /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, - /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, - /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, - /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, - /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, - /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, - /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, - /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, - /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, - /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, - /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, - /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, - /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, - /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, - /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, - /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, - /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, - /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, - /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, - /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, - /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, - /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, - /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, - /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, - /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, - /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, - /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, - /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, - /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, - /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, - /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, - /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, - /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, - /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, - /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, - /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, - /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, - /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, - /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, - /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, - /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, - /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, - /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, - /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, - /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, - /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, - /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, - /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, - /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, - /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, - /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, - /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, - /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, - /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, - /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, - /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, - /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, - /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, - /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, - /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, - /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, - /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, - /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, - /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, - /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, - /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, - /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, - /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, - /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, - /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, - /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, - /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, - /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, - /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, - /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, - /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, - /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, - /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, - /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, - /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, - /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, - /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, + /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, + /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, + /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, + /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, + /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, + /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, + /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, + /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, + /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, + /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, + /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, + /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, + /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, + /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, + /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, + /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, + /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, + /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, + /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, + /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, + /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, + /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, + /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, + /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, + /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, + /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, + /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, + /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, + /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, + /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, + /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, + /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, + /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, + /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, + /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, + /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, + /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, + /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, + /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, + /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, + /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, + /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, + /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, + /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, + /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, + /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, + /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, + /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, + /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, + /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, + /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, + /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, + /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, + /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, + /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, + /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, + /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, + /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, + /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, + /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, + /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, + /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, + /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, + /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, + /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, + /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, + /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, + /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, + /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, + /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, + /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, + /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, + /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, + /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, + /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, + /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, + /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, + /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, + /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, + /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, + /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, + /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, + /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, + /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, + /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, + /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, + /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, + /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, + /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, + /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, + /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, + /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, + /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, + /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, + /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, + /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, + /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, + /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, + /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, + /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, + /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, + /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, + /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, + /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, + /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, + /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, + /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, + /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, + /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, + /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, + /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, + /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, + /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, + /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, + /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, + /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, + /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, + /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, + /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, + /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, + /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, + /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, + /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, + /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, + /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, + /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, + /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, + /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, + /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, + /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, + /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, + /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, + /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, + /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, + /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, + /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, + /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, + /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, + /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, + /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, + /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, + /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, + /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, + /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, + /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, + /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, + /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, + /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, + /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, + /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, + /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, + /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, + /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, + /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, + /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, + /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, + /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, + /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, + /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, + /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, + /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, + /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, + /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, + /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, + /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, + /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, + /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, + /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, + /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, + /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, + /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, + /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, + /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, + /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, + /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, + /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, + /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, + /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, + /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, + /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, + /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, + /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, + /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, + /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, + /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, + /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, + /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, + /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, + /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, + /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, + /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, + /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, + /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, + /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, + /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, + /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, + /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, + /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, + /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, + /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, }; #define YY_SHIFT_USE_DFLT (-70) #define YY_SHIFT_COUNT (402) #define YY_SHIFT_MIN (-69) #define YY_SHIFT_MAX (2144) static const short yy_shift_ofst[] = { - /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, - /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, - /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, - /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, - /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, - /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, - /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, - /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, - /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, - /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, - /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, - /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, - /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, - /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, - /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, - /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, - /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, - /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, - /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, - /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, - /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, - /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, - /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, - /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, - /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, - /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, - /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, - /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, - /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, - /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, - /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, - /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, - /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, - /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, - /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, - /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, - /* 400 */ 34, 9, -69, + /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, + /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, + /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, + /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, + /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, + /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, + /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, + /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, + /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, + /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, + /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, + /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, + /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, + /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, + /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, + /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, + /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, + /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, + /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, + /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, + /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, + /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, + /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, + /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, + /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, + /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, + /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, + /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, + /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, + /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, + /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, + /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, + /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, + /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, + /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, + /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, + /* 400 */ 34, 9, -69, }; #define YY_REDUCE_USE_DFLT (-179) #define YY_REDUCE_COUNT (254) #define YY_REDUCE_MIN (-178) #define YY_REDUCE_MAX (2443) static const short yy_reduce_ofst[] = { - /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, - /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, - /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, - /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, - /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, - /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, - /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, - /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, - /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, - /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, - /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, - /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, - /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, - /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, - /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, - /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, - /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, - /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, - /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, - /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, - /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, - /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, - /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, - /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, - /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, - /* 250 */ 718, 700, 581, 569, 614, + /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, + /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, + /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, + /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, + /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, + /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, + /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, + /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, + /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, + /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, + /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, + /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, + /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, + /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, + /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, + /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, + /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, + /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, + /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, + /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, + /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, + /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, + /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, + /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, + /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, + /* 250 */ 718, 700, 581, 569, 614, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, - /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, - /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, - /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, - /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, - /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, - /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, - /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, - /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, - /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, - /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, - /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, - /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, - /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, - /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, - /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, - /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, - /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, - /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, - /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, - /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, - /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, - /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, - /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, - /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, - /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, - /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, - /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, - /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, - /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, - /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, - /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, - /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, - /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, - /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, - /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, - /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, - /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, - /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, - /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, - /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, - /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, - /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, - /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, - /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, - /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, - /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, - /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, - /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, - /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, - /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, - /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, - /* 640 */ 688, 687, 899, 797, 733, + /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, + /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, + /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, + /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, + /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, + /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, + /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, + /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, + /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, + /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, + /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, + /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, + /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, + /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, + /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, + /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, + /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, + /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, + /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, + /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, + /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, + /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, + /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, + /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, + /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, + /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, + /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, + /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, + /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, + /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, + /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, + /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, + /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, + /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, + /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, + /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, + /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, + /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, + /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, + /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, + /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, + /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, + /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, + /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, + /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, + /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, + /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, + /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, + /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, + /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, + /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, + /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, + /* 640 */ 688, 687, 899, 797, 733, }; /* The next table maps tokens into fallback tokens. If a construct ** like the following: -** +** ** %fallback ID X Y Z. ** ** appears in the grammar, then ID becomes a fallback token for X, Y, @@ -988,10 +988,10 @@ static const YYCODETYPE yyFallback[] = { ** It is sometimes called the "minor" token. */ struct yyStackEntry { - YYACTIONTYPE stateno; /* The state-number */ - YYCODETYPE major; /* The major token value. This is the code + YYACTIONTYPE stateno; /* The state-number */ + YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This + YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; @@ -999,17 +999,17 @@ typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { - int yyidx; /* Index of top element in stack */ + int yyidx; /* Index of top element in stack */ #ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ + int yyidxMax; /* Maximum value of yyidx */ #endif - int yyerrcnt; /* Shifts left before out of the error */ - ParseARG_SDECL /* A place to hold %extra_argument */ + int yyerrcnt; /* Shifts left before out of the error */ + ParseARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ + int yystksz; /* Current side of the stack */ + yyStackEntry *yystack; /* The parser's stack */ #else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ + yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ #endif }; typedef struct yyParser yyParser; @@ -1021,10 +1021,10 @@ static char *yyTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG -/* +/* ** Turn parser tracing on by giving a stream to which to write the trace ** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL +** by making either argument NULL ** ** Inputs: **
        @@ -1038,92 +1038,88 @@ static char *yyTracePrompt = 0; ** Outputs: ** None. */ -void ParseTrace(FILE *TraceFILE, char *zTracePrompt) -{ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if(yyTraceFILE == 0) { - yyTracePrompt = 0; - } else if(yyTracePrompt == 0) { - yyTraceFILE = 0; - } +void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if( yyTraceFILE==0 ) yyTracePrompt = 0; + else if( yyTracePrompt==0 ) yyTraceFILE = 0; } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", - "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", - "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", - "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", - "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", - "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", - "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", - "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", - "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", - "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", - "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", - "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", - "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", - "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", - "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", - "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", - "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", - "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", - "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", - "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", - "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", - "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", - "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", - "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", - "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", - "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", - "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", - "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", - "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", - "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", - "TOK_WHILE", "error", "statement_list", "case_action", - "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", - "assignable", "attribute_decl", "by_expression", "constant", - "expression", "function_call", "general_ref", "group_ref", - "identifier", "initializer", "interval", "literal", - "local_initializer", "precision_spec", "query_expression", "query_start", - "simple_expression", "unary_expression", "supertype_expression", "until_control", - "while_control", "function_header", "fh_lineno", "rule_header", - "rh_start", "rh_get_line", "procedure_header", "ph_get_line", - "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", - "case_action_list", "case_block", "case_labels", "where_clause_list", - "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", - "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", - "nested_id_list", "statement_rep", "subtype_decl", "where_rule", - "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", - "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", - "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", - "optional_or_unique", "optional_fixed", "optional", "var", - "unique", "qualified_attr", "qualifier", "alias_statement", - "assignment_statement", "case_statement", "compound_statement", "escape_statement", - "if_statement", "proc_call_statement", "repeat_statement", "return_statement", - "skip_statement", "statement", "subsuper_decl", "supertype_decl", - "supertype_factor", "function_id", "procedure_id", "attribute_type", - "defined_type", "parameter_type", "generic_type", "basic_type", - "select_type", "aggregate_type", "aggregation_type", "array_type", - "bag_type", "conformant_aggregation", "list_type", "set_type", - "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", - "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", - "action_body_item_rep", "action_body_item", "declaration", "constant_decl", - "local_decl", "semicolon", "alias_push_scope", "block_list", - "block_member", "include_directive", "rule_decl", "constant_body", - "constant_body_list", "entity_decl", "function_decl", "procedure_decl", - "type_decl", "entity_header", "enumeration_type", "express_file", - "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", - "increment_control", "rename", "rename_list", "parened_rename_list", - "reference_clause", "reference_head", "use_clause", "use_head", - "interface_specification", "interface_specification_list", "right_curl", "local_variable", - "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", - "ph_push_scope", "schema_body", "schema_header", "type_item_body", - "type_item", "ti_start", "td_start", +static const char *const yyTokenName[] = { + "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", + "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", + "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", + "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", + "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", + "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", + "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", + "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", + "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", + "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", + "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", + "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", + "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", + "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", + "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", + "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", + "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", + "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", + "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", + "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", + "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", + "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", + "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", + "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", + "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", + "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", + "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", + "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", + "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", + "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", + "TOK_WHILE", "error", "statement_list", "case_action", + "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", + "assignable", "attribute_decl", "by_expression", "constant", + "expression", "function_call", "general_ref", "group_ref", + "identifier", "initializer", "interval", "literal", + "local_initializer", "precision_spec", "query_expression", "query_start", + "simple_expression", "unary_expression", "supertype_expression", "until_control", + "while_control", "function_header", "fh_lineno", "rule_header", + "rh_start", "rh_get_line", "procedure_header", "ph_get_line", + "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", + "case_action_list", "case_block", "case_labels", "where_clause_list", + "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", + "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", + "nested_id_list", "statement_rep", "subtype_decl", "where_rule", + "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", + "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", + "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", + "optional_or_unique", "optional_fixed", "optional", "var", + "unique", "qualified_attr", "qualifier", "alias_statement", + "assignment_statement", "case_statement", "compound_statement", "escape_statement", + "if_statement", "proc_call_statement", "repeat_statement", "return_statement", + "skip_statement", "statement", "subsuper_decl", "supertype_decl", + "supertype_factor", "function_id", "procedure_id", "attribute_type", + "defined_type", "parameter_type", "generic_type", "basic_type", + "select_type", "aggregate_type", "aggregation_type", "array_type", + "bag_type", "conformant_aggregation", "list_type", "set_type", + "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", + "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", + "action_body_item_rep", "action_body_item", "declaration", "constant_decl", + "local_decl", "semicolon", "alias_push_scope", "block_list", + "block_member", "include_directive", "rule_decl", "constant_body", + "constant_body_list", "entity_decl", "function_decl", "procedure_decl", + "type_decl", "entity_header", "enumeration_type", "express_file", + "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", + "increment_control", "rename", "rename_list", "parened_rename_list", + "reference_clause", "reference_head", "use_clause", "use_head", + "interface_specification", "interface_specification_list", "right_curl", "local_variable", + "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", + "ph_push_scope", "schema_body", "schema_header", "type_item_body", + "type_item", "ti_start", "td_start", }; #endif /* NDEBUG */ @@ -1131,338 +1127,338 @@ static const char *const yyTokenName[] = { /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { - /* 0 */ "action_body ::= action_body_item_rep statement_rep", - /* 1 */ "action_body_item ::= declaration", - /* 2 */ "action_body_item ::= constant_decl", - /* 3 */ "action_body_item ::= local_decl", - /* 4 */ "action_body_item_rep ::=", - /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", - /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", - /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", - /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", - /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", - /* 10 */ "aggregate_init_element ::= expression", - /* 11 */ "aggregate_init_body ::= aggregate_init_element", - /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", - /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", - /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", - /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", - /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", - /* 17 */ "aggregation_type ::= array_type", - /* 18 */ "aggregation_type ::= bag_type", - /* 19 */ "aggregation_type ::= list_type", - /* 20 */ "aggregation_type ::= set_type", - /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", - /* 22 */ "alias_push_scope ::=", - /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", - /* 24 */ "assignable ::= assignable qualifier", - /* 25 */ "assignable ::= identifier", - /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", - /* 27 */ "attribute_type ::= aggregation_type", - /* 28 */ "attribute_type ::= basic_type", - /* 29 */ "attribute_type ::= defined_type", - /* 30 */ "explicit_attr_list ::=", - /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", - /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", - /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", - /* 34 */ "basic_type ::= TOK_BOOLEAN", - /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", - /* 36 */ "basic_type ::= TOK_REAL precision_spec", - /* 37 */ "basic_type ::= TOK_NUMBER", - /* 38 */ "basic_type ::= TOK_LOGICAL", - /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", - /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", - /* 41 */ "block_list ::=", - /* 42 */ "block_list ::= block_list block_member", - /* 43 */ "block_member ::= declaration", - /* 44 */ "block_member ::= include_directive", - /* 45 */ "block_member ::= rule_decl", - /* 46 */ "by_expression ::=", - /* 47 */ "by_expression ::= TOK_BY expression", - /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", - /* 49 */ "case_action ::= case_labels TOK_COLON statement", - /* 50 */ "case_action_list ::=", - /* 51 */ "case_action_list ::= case_action_list case_action", - /* 52 */ "case_block ::= case_action_list case_otherwise", - /* 53 */ "case_labels ::= expression", - /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", - /* 55 */ "case_otherwise ::=", - /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", - /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", - /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", - /* 59 */ "constant ::= TOK_PI", - /* 60 */ "constant ::= TOK_E", - /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", - /* 62 */ "constant_body_list ::=", - /* 63 */ "constant_body_list ::= constant_body constant_body_list", - /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", - /* 65 */ "declaration ::= entity_decl", - /* 66 */ "declaration ::= function_decl", - /* 67 */ "declaration ::= procedure_decl", - /* 68 */ "declaration ::= type_decl", - /* 69 */ "derive_decl ::=", - /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", - /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", - /* 72 */ "derived_attribute_rep ::= derived_attribute", - /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", - /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", - /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", - /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", - /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", - /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", - /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", - /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", - /* 81 */ "attribute_decl_list ::= attribute_decl", - /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", - /* 83 */ "optional ::=", - /* 84 */ "optional ::= TOK_OPTIONAL", - /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", - /* 86 */ "express_file ::= schema_decl_list", - /* 87 */ "schema_decl_list ::= schema_decl", - /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", - /* 89 */ "expression ::= simple_expression", - /* 90 */ "expression ::= expression TOK_AND expression", - /* 91 */ "expression ::= expression TOK_OR expression", - /* 92 */ "expression ::= expression TOK_XOR expression", - /* 93 */ "expression ::= expression TOK_LESS_THAN expression", - /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", - /* 95 */ "expression ::= expression TOK_EQUAL expression", - /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", - /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", - /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", - /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", - /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", - /* 101 */ "expression ::= expression TOK_IN expression", - /* 102 */ "expression ::= expression TOK_LIKE expression", - /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", - /* 104 */ "simple_expression ::= unary_expression", - /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", - /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", - /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", - /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", - /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", - /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", - /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", - /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", - /* 113 */ "expression_list ::= expression", - /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", - /* 115 */ "var ::=", - /* 116 */ "var ::= TOK_VAR", - /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", - /* 118 */ "formal_parameter_list ::=", - /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", - /* 120 */ "formal_parameter_rep ::= formal_parameter", - /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", - /* 122 */ "parameter_type ::= basic_type", - /* 123 */ "parameter_type ::= conformant_aggregation", - /* 124 */ "parameter_type ::= defined_type", - /* 125 */ "parameter_type ::= generic_type", - /* 126 */ "function_call ::= function_id actual_parameters", - /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", - /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", - /* 129 */ "fh_lineno ::= TOK_FUNCTION", - /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", - /* 131 */ "fh_plist ::= formal_parameter_list", - /* 132 */ "function_id ::= TOK_IDENTIFIER", - /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", - /* 134 */ "conformant_aggregation ::= aggregate_type", - /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", - /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", - /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", - /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", - /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", - /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", - /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", - /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", - /* 143 */ "generic_type ::= TOK_GENERIC", - /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", - /* 145 */ "id_list ::= TOK_IDENTIFIER", - /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", - /* 147 */ "identifier ::= TOK_SELF", - /* 148 */ "identifier ::= TOK_QUESTION_MARK", - /* 149 */ "identifier ::= TOK_IDENTIFIER", - /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", - /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", - /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", - /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", - /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", - /* 155 */ "rename ::= TOK_IDENTIFIER", - /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", - /* 157 */ "rename_list ::= rename", - /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", - /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", - /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", - /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", - /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", - /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", - /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", - /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", - /* 166 */ "interface_specification ::= use_clause", - /* 167 */ "interface_specification ::= reference_clause", - /* 168 */ "interface_specification_list ::=", - /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", - /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", - /* 171 */ "set_or_bag_of_entity ::= defined_type", - /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", - /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", - /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", - /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", - /* 176 */ "inverse_attr_list ::= inverse_attr", - /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", - /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", - /* 179 */ "inverse_clause ::=", - /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", - /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", - /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", - /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", - /* 184 */ "literal ::= TOK_INTEGER_LITERAL", - /* 185 */ "literal ::= TOK_REAL_LITERAL", - /* 186 */ "literal ::= TOK_STRING_LITERAL", - /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", - /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", - /* 189 */ "literal ::= TOK_BINARY_LITERAL", - /* 190 */ "literal ::= constant", - /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", - /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", - /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", - /* 194 */ "local_body ::=", - /* 195 */ "local_body ::= local_variable local_body", - /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", - /* 197 */ "local_decl_rules_on ::=", - /* 198 */ "local_decl_rules_off ::=", - /* 199 */ "defined_type ::= TOK_IDENTIFIER", - /* 200 */ "defined_type_list ::= defined_type", - /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", - /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", - /* 203 */ "oneof_op ::= TOK_ONEOF", - /* 204 */ "optional_or_unique ::=", - /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", - /* 206 */ "optional_or_unique ::= TOK_UNIQUE", - /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", - /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", - /* 209 */ "optional_fixed ::=", - /* 210 */ "optional_fixed ::= TOK_FIXED", - /* 211 */ "precision_spec ::=", - /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", - /* 214 */ "proc_call_statement ::= procedure_id semicolon", - /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", - /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", - /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", - /* 218 */ "ph_get_line ::=", - /* 219 */ "procedure_id ::= TOK_IDENTIFIER", - /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", - /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", - /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", - /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", - /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", - /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", - /* 228 */ "rel_op ::= TOK_LESS_THAN", - /* 229 */ "rel_op ::= TOK_GREATER_THAN", - /* 230 */ "rel_op ::= TOK_EQUAL", - /* 231 */ "rel_op ::= TOK_LESS_EQUAL", - /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", - /* 233 */ "rel_op ::= TOK_NOT_EQUAL", - /* 234 */ "rel_op ::= TOK_INST_EQUAL", - /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", - /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 238 */ "return_statement ::= TOK_RETURN semicolon", - /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", - /* 240 */ "right_curl ::= TOK_RIGHT_CURL", - /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", - /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", - /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", - /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", - /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", - /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", - /* 247 */ "rh_get_line ::=", - /* 248 */ "schema_body ::= interface_specification_list block_list", - /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", - /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", - /* 251 */ "schema_decl ::= include_directive", - /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", - /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 254 */ "semicolon ::= TOK_SEMICOLON", - /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", - /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", - /* 257 */ "skip_statement ::= TOK_SKIP semicolon", - /* 258 */ "statement ::= alias_statement", - /* 259 */ "statement ::= assignment_statement", - /* 260 */ "statement ::= case_statement", - /* 261 */ "statement ::= compound_statement", - /* 262 */ "statement ::= escape_statement", - /* 263 */ "statement ::= if_statement", - /* 264 */ "statement ::= proc_call_statement", - /* 265 */ "statement ::= repeat_statement", - /* 266 */ "statement ::= return_statement", - /* 267 */ "statement ::= skip_statement", - /* 268 */ "statement_rep ::=", - /* 269 */ "statement_rep ::= semicolon statement_rep", - /* 270 */ "statement_rep ::= statement statement_rep", - /* 271 */ "subsuper_decl ::=", - /* 272 */ "subsuper_decl ::= supertype_decl", - /* 273 */ "subsuper_decl ::= subtype_decl", - /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", - /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", - /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 279 */ "supertype_expression ::= supertype_factor", - /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", - /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", - /* 282 */ "supertype_expression_list ::= supertype_expression", - /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", - /* 284 */ "supertype_factor ::= identifier", - /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", - /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 287 */ "type ::= aggregation_type", - /* 288 */ "type ::= basic_type", - /* 289 */ "type ::= defined_type", - /* 290 */ "type ::= select_type", - /* 291 */ "type_item_body ::= enumeration_type", - /* 292 */ "type_item_body ::= type", - /* 293 */ "type_item ::= ti_start type_item_body semicolon", - /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", - /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", - /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", - /* 297 */ "general_ref ::= assignable group_ref", - /* 298 */ "general_ref ::= assignable", - /* 299 */ "unary_expression ::= aggregate_initializer", - /* 300 */ "unary_expression ::= unary_expression qualifier", - /* 301 */ "unary_expression ::= literal", - /* 302 */ "unary_expression ::= function_call", - /* 303 */ "unary_expression ::= identifier", - /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 305 */ "unary_expression ::= interval", - /* 306 */ "unary_expression ::= query_expression", - /* 307 */ "unary_expression ::= TOK_NOT unary_expression", - /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", - /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", - /* 310 */ "unique ::=", - /* 311 */ "unique ::= TOK_UNIQUE", - /* 312 */ "qualified_attr ::= attribute_decl", - /* 313 */ "qualified_attr_list ::= qualified_attr", - /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", - /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", - /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", - /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", - /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", - /* 319 */ "unique_clause ::=", - /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", - /* 321 */ "until_control ::=", - /* 322 */ "until_control ::= TOK_UNTIL expression", - /* 323 */ "where_clause ::= expression semicolon", - /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", - /* 325 */ "where_clause_list ::= where_clause", - /* 326 */ "where_clause_list ::= where_clause_list where_clause", - /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", - /* 328 */ "where_rule_OPT ::=", - /* 329 */ "where_rule_OPT ::= where_rule", - /* 330 */ "while_control ::=", - /* 331 */ "while_control ::= TOK_WHILE expression", + /* 0 */ "action_body ::= action_body_item_rep statement_rep", + /* 1 */ "action_body_item ::= declaration", + /* 2 */ "action_body_item ::= constant_decl", + /* 3 */ "action_body_item ::= local_decl", + /* 4 */ "action_body_item_rep ::=", + /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", + /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", + /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", + /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", + /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", + /* 10 */ "aggregate_init_element ::= expression", + /* 11 */ "aggregate_init_body ::= aggregate_init_element", + /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", + /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", + /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", + /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", + /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", + /* 17 */ "aggregation_type ::= array_type", + /* 18 */ "aggregation_type ::= bag_type", + /* 19 */ "aggregation_type ::= list_type", + /* 20 */ "aggregation_type ::= set_type", + /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", + /* 22 */ "alias_push_scope ::=", + /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", + /* 24 */ "assignable ::= assignable qualifier", + /* 25 */ "assignable ::= identifier", + /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", + /* 27 */ "attribute_type ::= aggregation_type", + /* 28 */ "attribute_type ::= basic_type", + /* 29 */ "attribute_type ::= defined_type", + /* 30 */ "explicit_attr_list ::=", + /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", + /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", + /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", + /* 34 */ "basic_type ::= TOK_BOOLEAN", + /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", + /* 36 */ "basic_type ::= TOK_REAL precision_spec", + /* 37 */ "basic_type ::= TOK_NUMBER", + /* 38 */ "basic_type ::= TOK_LOGICAL", + /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", + /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", + /* 41 */ "block_list ::=", + /* 42 */ "block_list ::= block_list block_member", + /* 43 */ "block_member ::= declaration", + /* 44 */ "block_member ::= include_directive", + /* 45 */ "block_member ::= rule_decl", + /* 46 */ "by_expression ::=", + /* 47 */ "by_expression ::= TOK_BY expression", + /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", + /* 49 */ "case_action ::= case_labels TOK_COLON statement", + /* 50 */ "case_action_list ::=", + /* 51 */ "case_action_list ::= case_action_list case_action", + /* 52 */ "case_block ::= case_action_list case_otherwise", + /* 53 */ "case_labels ::= expression", + /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", + /* 55 */ "case_otherwise ::=", + /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", + /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", + /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", + /* 59 */ "constant ::= TOK_PI", + /* 60 */ "constant ::= TOK_E", + /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", + /* 62 */ "constant_body_list ::=", + /* 63 */ "constant_body_list ::= constant_body constant_body_list", + /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", + /* 65 */ "declaration ::= entity_decl", + /* 66 */ "declaration ::= function_decl", + /* 67 */ "declaration ::= procedure_decl", + /* 68 */ "declaration ::= type_decl", + /* 69 */ "derive_decl ::=", + /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", + /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", + /* 72 */ "derived_attribute_rep ::= derived_attribute", + /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", + /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", + /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", + /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", + /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", + /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", + /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", + /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", + /* 81 */ "attribute_decl_list ::= attribute_decl", + /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", + /* 83 */ "optional ::=", + /* 84 */ "optional ::= TOK_OPTIONAL", + /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", + /* 86 */ "express_file ::= schema_decl_list", + /* 87 */ "schema_decl_list ::= schema_decl", + /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", + /* 89 */ "expression ::= simple_expression", + /* 90 */ "expression ::= expression TOK_AND expression", + /* 91 */ "expression ::= expression TOK_OR expression", + /* 92 */ "expression ::= expression TOK_XOR expression", + /* 93 */ "expression ::= expression TOK_LESS_THAN expression", + /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", + /* 95 */ "expression ::= expression TOK_EQUAL expression", + /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", + /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", + /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", + /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", + /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", + /* 101 */ "expression ::= expression TOK_IN expression", + /* 102 */ "expression ::= expression TOK_LIKE expression", + /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", + /* 104 */ "simple_expression ::= unary_expression", + /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", + /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", + /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", + /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", + /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", + /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", + /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", + /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", + /* 113 */ "expression_list ::= expression", + /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", + /* 115 */ "var ::=", + /* 116 */ "var ::= TOK_VAR", + /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", + /* 118 */ "formal_parameter_list ::=", + /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", + /* 120 */ "formal_parameter_rep ::= formal_parameter", + /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", + /* 122 */ "parameter_type ::= basic_type", + /* 123 */ "parameter_type ::= conformant_aggregation", + /* 124 */ "parameter_type ::= defined_type", + /* 125 */ "parameter_type ::= generic_type", + /* 126 */ "function_call ::= function_id actual_parameters", + /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", + /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", + /* 129 */ "fh_lineno ::= TOK_FUNCTION", + /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", + /* 131 */ "fh_plist ::= formal_parameter_list", + /* 132 */ "function_id ::= TOK_IDENTIFIER", + /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", + /* 134 */ "conformant_aggregation ::= aggregate_type", + /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", + /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", + /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", + /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", + /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", + /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", + /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", + /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", + /* 143 */ "generic_type ::= TOK_GENERIC", + /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", + /* 145 */ "id_list ::= TOK_IDENTIFIER", + /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", + /* 147 */ "identifier ::= TOK_SELF", + /* 148 */ "identifier ::= TOK_QUESTION_MARK", + /* 149 */ "identifier ::= TOK_IDENTIFIER", + /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", + /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", + /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", + /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", + /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", + /* 155 */ "rename ::= TOK_IDENTIFIER", + /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", + /* 157 */ "rename_list ::= rename", + /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", + /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", + /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", + /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", + /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", + /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", + /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", + /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", + /* 166 */ "interface_specification ::= use_clause", + /* 167 */ "interface_specification ::= reference_clause", + /* 168 */ "interface_specification_list ::=", + /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", + /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", + /* 171 */ "set_or_bag_of_entity ::= defined_type", + /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", + /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", + /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", + /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", + /* 176 */ "inverse_attr_list ::= inverse_attr", + /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", + /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", + /* 179 */ "inverse_clause ::=", + /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", + /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", + /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", + /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", + /* 184 */ "literal ::= TOK_INTEGER_LITERAL", + /* 185 */ "literal ::= TOK_REAL_LITERAL", + /* 186 */ "literal ::= TOK_STRING_LITERAL", + /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", + /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", + /* 189 */ "literal ::= TOK_BINARY_LITERAL", + /* 190 */ "literal ::= constant", + /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", + /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", + /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", + /* 194 */ "local_body ::=", + /* 195 */ "local_body ::= local_variable local_body", + /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", + /* 197 */ "local_decl_rules_on ::=", + /* 198 */ "local_decl_rules_off ::=", + /* 199 */ "defined_type ::= TOK_IDENTIFIER", + /* 200 */ "defined_type_list ::= defined_type", + /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", + /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", + /* 203 */ "oneof_op ::= TOK_ONEOF", + /* 204 */ "optional_or_unique ::=", + /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", + /* 206 */ "optional_or_unique ::= TOK_UNIQUE", + /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", + /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", + /* 209 */ "optional_fixed ::=", + /* 210 */ "optional_fixed ::= TOK_FIXED", + /* 211 */ "precision_spec ::=", + /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", + /* 214 */ "proc_call_statement ::= procedure_id semicolon", + /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", + /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", + /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", + /* 218 */ "ph_get_line ::=", + /* 219 */ "procedure_id ::= TOK_IDENTIFIER", + /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", + /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", + /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", + /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", + /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", + /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", + /* 228 */ "rel_op ::= TOK_LESS_THAN", + /* 229 */ "rel_op ::= TOK_GREATER_THAN", + /* 230 */ "rel_op ::= TOK_EQUAL", + /* 231 */ "rel_op ::= TOK_LESS_EQUAL", + /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", + /* 233 */ "rel_op ::= TOK_NOT_EQUAL", + /* 234 */ "rel_op ::= TOK_INST_EQUAL", + /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", + /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 238 */ "return_statement ::= TOK_RETURN semicolon", + /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", + /* 240 */ "right_curl ::= TOK_RIGHT_CURL", + /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", + /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", + /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", + /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", + /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", + /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", + /* 247 */ "rh_get_line ::=", + /* 248 */ "schema_body ::= interface_specification_list block_list", + /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", + /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", + /* 251 */ "schema_decl ::= include_directive", + /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", + /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 254 */ "semicolon ::= TOK_SEMICOLON", + /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", + /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", + /* 257 */ "skip_statement ::= TOK_SKIP semicolon", + /* 258 */ "statement ::= alias_statement", + /* 259 */ "statement ::= assignment_statement", + /* 260 */ "statement ::= case_statement", + /* 261 */ "statement ::= compound_statement", + /* 262 */ "statement ::= escape_statement", + /* 263 */ "statement ::= if_statement", + /* 264 */ "statement ::= proc_call_statement", + /* 265 */ "statement ::= repeat_statement", + /* 266 */ "statement ::= return_statement", + /* 267 */ "statement ::= skip_statement", + /* 268 */ "statement_rep ::=", + /* 269 */ "statement_rep ::= semicolon statement_rep", + /* 270 */ "statement_rep ::= statement statement_rep", + /* 271 */ "subsuper_decl ::=", + /* 272 */ "subsuper_decl ::= supertype_decl", + /* 273 */ "subsuper_decl ::= subtype_decl", + /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", + /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", + /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 279 */ "supertype_expression ::= supertype_factor", + /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", + /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", + /* 282 */ "supertype_expression_list ::= supertype_expression", + /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", + /* 284 */ "supertype_factor ::= identifier", + /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", + /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 287 */ "type ::= aggregation_type", + /* 288 */ "type ::= basic_type", + /* 289 */ "type ::= defined_type", + /* 290 */ "type ::= select_type", + /* 291 */ "type_item_body ::= enumeration_type", + /* 292 */ "type_item_body ::= type", + /* 293 */ "type_item ::= ti_start type_item_body semicolon", + /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", + /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", + /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", + /* 297 */ "general_ref ::= assignable group_ref", + /* 298 */ "general_ref ::= assignable", + /* 299 */ "unary_expression ::= aggregate_initializer", + /* 300 */ "unary_expression ::= unary_expression qualifier", + /* 301 */ "unary_expression ::= literal", + /* 302 */ "unary_expression ::= function_call", + /* 303 */ "unary_expression ::= identifier", + /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 305 */ "unary_expression ::= interval", + /* 306 */ "unary_expression ::= query_expression", + /* 307 */ "unary_expression ::= TOK_NOT unary_expression", + /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", + /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", + /* 310 */ "unique ::=", + /* 311 */ "unique ::= TOK_UNIQUE", + /* 312 */ "qualified_attr ::= attribute_decl", + /* 313 */ "qualified_attr_list ::= qualified_attr", + /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", + /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", + /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", + /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", + /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", + /* 319 */ "unique_clause ::=", + /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", + /* 321 */ "until_control ::=", + /* 322 */ "until_control ::= TOK_UNTIL expression", + /* 323 */ "where_clause ::= expression semicolon", + /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", + /* 325 */ "where_clause_list ::= where_clause", + /* 326 */ "where_clause_list ::= where_clause_list where_clause", + /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", + /* 328 */ "where_rule_OPT ::=", + /* 329 */ "where_rule_OPT ::= where_rule", + /* 330 */ "while_control ::=", + /* 331 */ "while_control ::= TOK_WHILE expression", }; #endif /* NDEBUG */ @@ -1471,27 +1467,26 @@ static const char *const yyRuleName[] = { /* ** Try to increase the size of the parser stack. */ -static void yyGrowStack(yyParser *p) -{ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz * 2 + 256; - pNew = realloc(p->yystack, newSize * sizeof(pNew[0])); - if(pNew) { - p->yystack = pNew; - p->yystksz = newSize; +static void yyGrowStack(yyParser *p){ + int newSize; + yyStackEntry *pNew; + + newSize = p->yystksz*2 + 256; + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + if( pNew ){ + p->yystack = pNew; + p->yystksz = newSize; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } -#endif + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", + yyTracePrompt, p->yystksz); } +#endif + } } #endif -/* +/* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. @@ -1503,22 +1498,21 @@ static void yyGrowStack(yyParser *p) ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(size_t)) -{ - yyParser *pParser; - pParser = (yyParser *)(*mallocProc)((size_t)sizeof(yyParser)); - if(pParser) { - pParser->yyidx = -1; +void *ParseAlloc(void *(*mallocProc)(size_t)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); + if( pParser ){ + pParser->yyidx = -1; #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; + pParser->yyidxMax = 0; #endif #if YYSTACKDEPTH<=0 - pParser->yystack = NULL; - pParser->yystksz = 0; - yyGrowStack(pParser); + pParser->yystack = NULL; + pParser->yystksz = 0; + yyGrowStack(pParser); #endif - } - return pParser; + } + return pParser; } /* The following function deletes the value associated with a @@ -1527,36 +1521,35 @@ void *ParseAlloc(void *(*mallocProc)(size_t)) ** the value. */ static void yy_destructor( - yyParser *yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE *yypminor /* The object to be destroyed */ -) -{ - ParseARG_FETCH; - switch(yymajor) { - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 122: { /* statement_list */ + yyParser *yypParser, /* The parser */ + YYCODETYPE yymajor, /* Type code for object to destroy */ + YYMINORTYPE *yypminor /* The object to be destroyed */ +){ + ParseARG_FETCH; + switch( yymajor ){ + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 122: /* statement_list */ +{ #line 124 "expparse.y" - if(parseData.scanner == NULL) { - (yypminor->yy0).string = (char *)NULL; - } + if (parseData.scanner == NULL) { + (yypminor->yy0).string = (char*)NULL; + } #line 1549 "expparse.c" - } - break; - default: - break; /* If no destructor action specified: do nothing */ - } +} + break; + default: break; /* If no destructor action specified: do nothing */ + } } /* @@ -1567,31 +1560,28 @@ static void yy_destructor( ** ** Return the major token number for the symbol popped. */ -static int yy_pop_parser_stack(yyParser *pParser) -{ - YYCODETYPE yymajor; - yyStackEntry *yytos; +static int yy_pop_parser_stack(yyParser *pParser){ + YYCODETYPE yymajor; + yyStackEntry *yytos; - if(pParser->yyidx < 0) { - return 0; - } + if( pParser->yyidx<0 ) return 0; - yytos = &pParser->yystack[pParser->yyidx]; + yytos = &pParser->yystack[pParser->yyidx]; #ifndef NDEBUG - if(yyTraceFILE && pParser->yyidx >= 0) { - fprintf(yyTraceFILE, "%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } + if( yyTraceFILE && pParser->yyidx>=0 ){ + fprintf(yyTraceFILE,"%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos->major]); + } #endif - yymajor = yytos->major; - yy_destructor(pParser, yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; + yymajor = yytos->major; + yy_destructor(pParser, yymajor, &yytos->minor); + pParser->yyidx--; + return yymajor; } -/* +/* ** Deallocate and destroy a parser. Destructors are all called for ** all stack elements before shutting the parser down. ** @@ -1604,31 +1594,25 @@ static int yy_pop_parser_stack(yyParser *pParser) **
      */ void ParseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void *) /* Function used to reclaim memory */ -) -{ - yyParser *pParser = (yyParser *)p; - if(pParser == 0) { - return; - } - while(pParser->yyidx >= 0) { - yy_pop_parser_stack(pParser); - } + void *p, /* The parser to be deleted */ + void (*freeProc)(void*) /* Function used to reclaim memory */ +){ + yyParser *pParser = (yyParser*)p; + if( pParser==0 ) return; + while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 - free(pParser->yystack); + free(pParser->yystack); #endif - (*freeProc)((void *)pParser); + (*freeProc)((void*)pParser); } /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH -int ParseStackPeak(void *p) -{ - yyParser *pParser = (yyParser *)p; - return pParser->yyidxMax; +int ParseStackPeak(void *p){ + yyParser *pParser = (yyParser*)p; + return pParser->yyidxMax; } #endif @@ -1641,61 +1625,60 @@ int ParseStackPeak(void *p) ** return YY_NO_ACTION. */ static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -) -{ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if(stateno > YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno]) == YY_SHIFT_USE_DFLT) { - return yy_default[stateno]; - } - assert(iLookAhead != YYNOCODE); - i += iLookAhead; - if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { - if(iLookAhead > 0) { + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->yystack[pParser->yyidx].stateno; + + if( stateno>YY_SHIFT_COUNT + || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ + return yy_default[stateno]; + } + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; + if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ + if( iLookAhead>0 ){ #ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if(iLookAhead < sizeof(yyFallback) / sizeof(yyFallback[0]) - && (iFallback = yyFallback[iLookAhead]) != 0) { + YYCODETYPE iFallback; /* Fallback token */ + if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + } #endif - return yy_find_shift_action(pParser, iFallback); - } + return yy_find_shift_action(pParser, iFallback); + } #endif #ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( + { + int j = i - iLookAhead + YYWILDCARD; + if( #if YY_SHIFT_MIN+YYWILDCARD<0 - j >= 0 && + j>=0 && #endif #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j < YY_ACTTAB_COUNT && + j %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } #endif /* NDEBUG */ - return yy_action[j]; - } - } -#endif /* YYWILDCARD */ + return yy_action[j]; } - return yy_default[stateno]; - } else { - return yy_action[i]; + } +#endif /* YYWILDCARD */ } + return yy_default[stateno]; + }else{ + return yy_action[i]; + } } /* @@ -1707,103 +1690,97 @@ static int yy_find_shift_action( ** return YY_NO_ACTION. */ static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -) -{ - int i; + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; #ifdef YYERRORSYMBOL - if(stateno > YY_REDUCE_COUNT) { - return yy_default[stateno]; - } + if( stateno>YY_REDUCE_COUNT ){ + return yy_default[stateno]; + } #else - assert(stateno <= YY_REDUCE_COUNT); + assert( stateno<=YY_REDUCE_COUNT ); #endif - i = yy_reduce_ofst[stateno]; - assert(i != YY_REDUCE_USE_DFLT); - assert(iLookAhead != YYNOCODE); - i += iLookAhead; + i = yy_reduce_ofst[stateno]; + assert( i!=YY_REDUCE_USE_DFLT ); + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; #ifdef YYERRORSYMBOL - if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { - return yy_default[stateno]; - } + if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ + return yy_default[stateno]; + } #else - assert(i >= 0 && i < YY_ACTTAB_COUNT); - assert(yy_lookahead[i] == iLookAhead); + assert( i>=0 && iyyidx--; +static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ + ParseARG_FETCH; + yypParser->yyidx--; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will execute if the parser - ** stack every overflows */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ #line 2440 "expparse.y" fprintf(stderr, "Express parser experienced stack overflow.\n"); fprintf(stderr, "Last token had value %x\n", yypMinor->yy0.val); #line 1738 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ } /* ** Perform a shift action. */ static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ -) -{ - yyStackEntry *yytos; - yypParser->yyidx++; + yyParser *yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ +){ + yyStackEntry *yytos; + yypParser->yyidx++; #ifdef YYTRACKMAXSTACKDEPTH - if(yypParser->yyidx > yypParser->yyidxMax) { - yypParser->yyidxMax = yypParser->yyidx; - } + if( yypParser->yyidx>yypParser->yyidxMax ){ + yypParser->yyidxMax = yypParser->yyidx; + } #endif -#if YYSTACKDEPTH>0 - if(yypParser->yyidx >= YYSTACKDEPTH) { - yyStackOverflow(yypParser, yypMinor); - return; - } +#if YYSTACKDEPTH>0 + if( yypParser->yyidx>=YYSTACKDEPTH ){ + yyStackOverflow(yypParser, yypMinor); + return; + } #else - if(yypParser->yyidx >= yypParser->yystksz) { - yyGrowStack(yypParser); - if(yypParser->yyidx >= yypParser->yystksz) { - yyStackOverflow(yypParser, yypMinor); - return; - } + if( yypParser->yyidx>=yypParser->yystksz ){ + yyGrowStack(yypParser); + if( yypParser->yyidx>=yypParser->yystksz ){ + yyStackOverflow(yypParser, yypMinor); + return; } + } #endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; - yytos->minor = *yypMinor; + yytos = &yypParser->yystack[yypParser->yyidx]; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; + yytos->minor = *yypMinor; #ifndef NDEBUG - if(yyTraceFILE && yypParser->yyidx > 0) { - int i; - fprintf(yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState); - fprintf(yyTraceFILE, "%sStack:", yyTracePrompt); - for(i = 1; i <= yypParser->yyidx; i++) { - fprintf(yyTraceFILE, " %s", yyTokenName[yypParser->yystack[i].major]); - } - fprintf(yyTraceFILE, "\n"); - } + if( yyTraceFILE && yypParser->yyidx>0 ){ + int i; + fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); + fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); + for(i=1; i<=yypParser->yyidx; i++) + fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); + fprintf(yyTraceFILE,"\n"); + } #endif } @@ -1811,2744 +1788,2639 @@ static void yy_shift( ** is used during the reduce. */ static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } yyRuleInfo[] = { - { 156, 2 }, - { 233, 1 }, - { 233, 1 }, - { 233, 1 }, - { 232, 0 }, - { 232, 2 }, - { 157, 3 }, - { 157, 2 }, - { 127, 2 }, - { 127, 3 }, - { 126, 1 }, - { 158, 1 }, - { 158, 3 }, - { 158, 3 }, - { 158, 5 }, - { 217, 3 }, - { 217, 5 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 195, 9 }, - { 238, 0 }, - { 219, 5 }, - { 128, 2 }, - { 128, 1 }, - { 196, 4 }, - { 211, 1 }, - { 211, 1 }, - { 211, 1 }, - { 159, 0 }, - { 159, 2 }, - { 220, 4 }, - { 220, 3 }, - { 215, 1 }, - { 215, 2 }, - { 215, 2 }, - { 215, 1 }, - { 215, 1 }, - { 215, 3 }, - { 215, 3 }, - { 239, 0 }, - { 239, 2 }, - { 240, 1 }, - { 240, 1 }, - { 240, 1 }, - { 130, 0 }, - { 130, 2 }, - { 226, 5 }, - { 123, 3 }, - { 160, 0 }, - { 160, 2 }, - { 161, 2 }, - { 162, 1 }, - { 162, 3 }, - { 124, 0 }, - { 124, 3 }, - { 197, 6 }, - { 198, 4 }, - { 131, 1 }, - { 131, 1 }, - { 243, 6 }, - { 244, 0 }, - { 244, 2 }, - { 235, 4 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 164, 0 }, - { 164, 2 }, - { 229, 5 }, - { 183, 1 }, - { 183, 2 }, - { 125, 5 }, - { 245, 6 }, - { 249, 2 }, - { 250, 3 }, - { 199, 2 }, - { 129, 1 }, - { 129, 5 }, - { 182, 1 }, - { 182, 3 }, - { 190, 0 }, - { 190, 1 }, - { 165, 5 }, - { 251, 1 }, - { 252, 1 }, - { 252, 2 }, - { 132, 1 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 144, 1 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 166, 1 }, - { 166, 3 }, - { 191, 0 }, - { 191, 1 }, - { 167, 4 }, - { 168, 0 }, - { 168, 3 }, - { 169, 1 }, - { 169, 3 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 133, 2 }, - { 246, 4 }, - { 149, 6 }, - { 150, 1 }, - { 254, 1 }, - { 255, 1 }, - { 209, 1 }, - { 209, 1 }, - { 221, 1 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 214, 1 }, - { 214, 3 }, - { 170, 1 }, - { 170, 3 }, - { 136, 1 }, - { 136, 1 }, - { 136, 1 }, - { 200, 6 }, - { 200, 8 }, - { 241, 3 }, - { 256, 6 }, - { 137, 2 }, - { 257, 1 }, - { 257, 3 }, - { 258, 1 }, - { 258, 3 }, - { 259, 3 }, - { 260, 4 }, - { 260, 3 }, - { 261, 3 }, - { 262, 4 }, - { 262, 3 }, - { 263, 3 }, - { 264, 1 }, - { 264, 1 }, - { 265, 0 }, - { 265, 2 }, - { 138, 7 }, - { 224, 1 }, - { 224, 3 }, - { 224, 4 }, - { 224, 4 }, - { 224, 3 }, - { 180, 1 }, - { 180, 2 }, - { 228, 6 }, - { 181, 0 }, - { 181, 2 }, - { 227, 5 }, - { 222, 5 }, - { 222, 4 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 140, 2 }, - { 267, 4 }, - { 267, 5 }, - { 268, 0 }, - { 268, 2 }, - { 236, 6 }, - { 269, 0 }, - { 270, 0 }, - { 212, 1 }, - { 171, 1 }, - { 171, 3 }, - { 172, 3 }, - { 271, 1 }, - { 188, 0 }, - { 188, 1 }, - { 188, 1 }, - { 188, 2 }, - { 188, 2 }, - { 189, 0 }, - { 189, 1 }, - { 141, 0 }, - { 141, 3 }, - { 201, 3 }, - { 201, 2 }, - { 247, 4 }, - { 154, 5 }, - { 272, 1 }, - { 155, 0 }, - { 210, 1 }, - { 210, 1 }, - { 135, 2 }, - { 194, 2 }, - { 194, 2 }, - { 194, 3 }, - { 194, 5 }, - { 142, 3 }, - { 143, 6 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 202, 8 }, - { 202, 7 }, - { 203, 2 }, - { 203, 5 }, - { 266, 1 }, - { 242, 5 }, - { 230, 1 }, - { 185, 1 }, - { 185, 3 }, - { 151, 4 }, - { 152, 5 }, - { 153, 0 }, - { 273, 2 }, - { 273, 3 }, - { 253, 4 }, - { 253, 1 }, - { 274, 3 }, - { 216, 4 }, - { 237, 1 }, - { 223, 4 }, - { 223, 3 }, - { 204, 2 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 173, 0 }, - { 173, 2 }, - { 173, 2 }, - { 206, 0 }, - { 206, 1 }, - { 206, 1 }, - { 206, 2 }, - { 174, 5 }, - { 207, 2 }, - { 207, 5 }, - { 207, 6 }, - { 146, 1 }, - { 146, 3 }, - { 146, 3 }, - { 177, 1 }, - { 177, 3 }, - { 208, 1 }, - { 208, 4 }, - { 208, 3 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 275, 1 }, - { 275, 1 }, - { 276, 3 }, - { 277, 2 }, - { 248, 3 }, - { 278, 3 }, - { 134, 2 }, - { 134, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 3 }, - { 145, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 2 }, - { 145, 2 }, - { 192, 0 }, - { 192, 1 }, - { 193, 1 }, - { 186, 1 }, - { 186, 3 }, - { 179, 2 }, - { 179, 4 }, - { 178, 1 }, - { 178, 2 }, - { 184, 0 }, - { 184, 2 }, - { 147, 0 }, - { 147, 2 }, - { 231, 2 }, - { 231, 4 }, - { 163, 1 }, - { 163, 2 }, - { 175, 2 }, - { 176, 0 }, - { 176, 1 }, - { 148, 0 }, - { 148, 2 }, + { 156, 2 }, + { 233, 1 }, + { 233, 1 }, + { 233, 1 }, + { 232, 0 }, + { 232, 2 }, + { 157, 3 }, + { 157, 2 }, + { 127, 2 }, + { 127, 3 }, + { 126, 1 }, + { 158, 1 }, + { 158, 3 }, + { 158, 3 }, + { 158, 5 }, + { 217, 3 }, + { 217, 5 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 195, 9 }, + { 238, 0 }, + { 219, 5 }, + { 128, 2 }, + { 128, 1 }, + { 196, 4 }, + { 211, 1 }, + { 211, 1 }, + { 211, 1 }, + { 159, 0 }, + { 159, 2 }, + { 220, 4 }, + { 220, 3 }, + { 215, 1 }, + { 215, 2 }, + { 215, 2 }, + { 215, 1 }, + { 215, 1 }, + { 215, 3 }, + { 215, 3 }, + { 239, 0 }, + { 239, 2 }, + { 240, 1 }, + { 240, 1 }, + { 240, 1 }, + { 130, 0 }, + { 130, 2 }, + { 226, 5 }, + { 123, 3 }, + { 160, 0 }, + { 160, 2 }, + { 161, 2 }, + { 162, 1 }, + { 162, 3 }, + { 124, 0 }, + { 124, 3 }, + { 197, 6 }, + { 198, 4 }, + { 131, 1 }, + { 131, 1 }, + { 243, 6 }, + { 244, 0 }, + { 244, 2 }, + { 235, 4 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 164, 0 }, + { 164, 2 }, + { 229, 5 }, + { 183, 1 }, + { 183, 2 }, + { 125, 5 }, + { 245, 6 }, + { 249, 2 }, + { 250, 3 }, + { 199, 2 }, + { 129, 1 }, + { 129, 5 }, + { 182, 1 }, + { 182, 3 }, + { 190, 0 }, + { 190, 1 }, + { 165, 5 }, + { 251, 1 }, + { 252, 1 }, + { 252, 2 }, + { 132, 1 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 144, 1 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 166, 1 }, + { 166, 3 }, + { 191, 0 }, + { 191, 1 }, + { 167, 4 }, + { 168, 0 }, + { 168, 3 }, + { 169, 1 }, + { 169, 3 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 133, 2 }, + { 246, 4 }, + { 149, 6 }, + { 150, 1 }, + { 254, 1 }, + { 255, 1 }, + { 209, 1 }, + { 209, 1 }, + { 221, 1 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 214, 1 }, + { 214, 3 }, + { 170, 1 }, + { 170, 3 }, + { 136, 1 }, + { 136, 1 }, + { 136, 1 }, + { 200, 6 }, + { 200, 8 }, + { 241, 3 }, + { 256, 6 }, + { 137, 2 }, + { 257, 1 }, + { 257, 3 }, + { 258, 1 }, + { 258, 3 }, + { 259, 3 }, + { 260, 4 }, + { 260, 3 }, + { 261, 3 }, + { 262, 4 }, + { 262, 3 }, + { 263, 3 }, + { 264, 1 }, + { 264, 1 }, + { 265, 0 }, + { 265, 2 }, + { 138, 7 }, + { 224, 1 }, + { 224, 3 }, + { 224, 4 }, + { 224, 4 }, + { 224, 3 }, + { 180, 1 }, + { 180, 2 }, + { 228, 6 }, + { 181, 0 }, + { 181, 2 }, + { 227, 5 }, + { 222, 5 }, + { 222, 4 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 140, 2 }, + { 267, 4 }, + { 267, 5 }, + { 268, 0 }, + { 268, 2 }, + { 236, 6 }, + { 269, 0 }, + { 270, 0 }, + { 212, 1 }, + { 171, 1 }, + { 171, 3 }, + { 172, 3 }, + { 271, 1 }, + { 188, 0 }, + { 188, 1 }, + { 188, 1 }, + { 188, 2 }, + { 188, 2 }, + { 189, 0 }, + { 189, 1 }, + { 141, 0 }, + { 141, 3 }, + { 201, 3 }, + { 201, 2 }, + { 247, 4 }, + { 154, 5 }, + { 272, 1 }, + { 155, 0 }, + { 210, 1 }, + { 210, 1 }, + { 135, 2 }, + { 194, 2 }, + { 194, 2 }, + { 194, 3 }, + { 194, 5 }, + { 142, 3 }, + { 143, 6 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 202, 8 }, + { 202, 7 }, + { 203, 2 }, + { 203, 5 }, + { 266, 1 }, + { 242, 5 }, + { 230, 1 }, + { 185, 1 }, + { 185, 3 }, + { 151, 4 }, + { 152, 5 }, + { 153, 0 }, + { 273, 2 }, + { 273, 3 }, + { 253, 4 }, + { 253, 1 }, + { 274, 3 }, + { 216, 4 }, + { 237, 1 }, + { 223, 4 }, + { 223, 3 }, + { 204, 2 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 173, 0 }, + { 173, 2 }, + { 173, 2 }, + { 206, 0 }, + { 206, 1 }, + { 206, 1 }, + { 206, 2 }, + { 174, 5 }, + { 207, 2 }, + { 207, 5 }, + { 207, 6 }, + { 146, 1 }, + { 146, 3 }, + { 146, 3 }, + { 177, 1 }, + { 177, 3 }, + { 208, 1 }, + { 208, 4 }, + { 208, 3 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 275, 1 }, + { 275, 1 }, + { 276, 3 }, + { 277, 2 }, + { 248, 3 }, + { 278, 3 }, + { 134, 2 }, + { 134, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 1 }, + { 145, 1 }, + { 145, 1 }, + { 145, 3 }, + { 145, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 2 }, + { 145, 2 }, + { 192, 0 }, + { 192, 1 }, + { 193, 1 }, + { 186, 1 }, + { 186, 3 }, + { 179, 2 }, + { 179, 4 }, + { 178, 1 }, + { 178, 2 }, + { 184, 0 }, + { 184, 2 }, + { 147, 0 }, + { 147, 2 }, + { 231, 2 }, + { 231, 4 }, + { 163, 1 }, + { 163, 2 }, + { 175, 2 }, + { 176, 0 }, + { 176, 1 }, + { 148, 0 }, + { 148, 2 }, }; -static void yy_accept(yyParser *); /* Forward Declaration */ +static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -) -{ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - ParseARG_FETCH; - - yymsp = &yypParser->yystack[yypParser->yyidx]; - - if(yyruleno >= 0) { + yyParser *yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ +){ + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yyStackEntry *yymsp; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + ParseARG_FETCH; + + yymsp = &yypParser->yystack[yypParser->yyidx]; + + if( yyruleno>=0 ) { #ifndef NDEBUG - if(yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0]))) { - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } - } -#endif /* NDEBUG */ - } else { - /* invalid rule number range */ - return; + if ( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0]))) { + if (yyTraceFILE) { + fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno]); } - - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - /*memset(&yygotominor, 0, sizeof(yygotominor));*/ - yygotominor = yyzerominor; - - - switch(yyruleno) { - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line - ** { ... } // User supplied code - ** #line - ** break; - */ - case 0: /* action_body ::= action_body_item_rep statement_rep */ - case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ - yytestcase(yyruleno == 70); - case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ - yytestcase(yyruleno == 180); - case 269: /* statement_rep ::= semicolon statement_rep */ - yytestcase(yyruleno == 269); - case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ - yytestcase(yyruleno == 320); - case 327: /* where_rule ::= TOK_WHERE where_clause_list */ - yytestcase(yyruleno == 327); - case 329: /* where_rule_OPT ::= where_rule */ - yytestcase(yyruleno == 329); + } +#endif /* NDEBUG */ + } else { + /* invalid rule number range */ + return; + } + + + /* Silence complaints from purify about yygotominor being uninitialized + ** in some cases when it is copied into the stack after the following + ** switch. yygotominor is uninitialized when a rule reduces that does + ** not set the value of its left-hand side nonterminal. Leaving the + ** value of the nonterminal uninitialized is utterly harmless as long + ** as the value is never used. So really the only thing this code + ** accomplishes is to quieten purify. + ** + ** 2007-01-16: The wireshark project (www.wireshark.org) reports that + ** without this code, their parser segfaults. I'm not sure what there + ** parser is doing to make this happen. This is the second bug report + ** from wireshark this week. Clearly they are stressing Lemon in ways + ** that it has not been previously stressed... (SQLite ticket #2172) + */ + /*memset(&yygotominor, 0, sizeof(yygotominor));*/ + yygotominor = yyzerominor; + + + switch( yyruleno ){ + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** #line + ** { ... } // User supplied code + ** #line + ** break; + */ + case 0: /* action_body ::= action_body_item_rep statement_rep */ + case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ yytestcase(yyruleno==70); + case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ yytestcase(yyruleno==180); + case 269: /* statement_rep ::= semicolon statement_rep */ yytestcase(yyruleno==269); + case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ yytestcase(yyruleno==320); + case 327: /* where_rule ::= TOK_WHERE where_clause_list */ yytestcase(yyruleno==327); + case 329: /* where_rule_OPT ::= where_rule */ yytestcase(yyruleno==329); #line 297 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; - } +{ + yygotominor.yy371 = yymsp[0].minor.yy371; +} #line 2201 "expparse.c" - break; - case 1: /* action_body_item ::= declaration */ - case 2: /* action_body_item ::= constant_decl */ - yytestcase(yyruleno == 2); - case 3: /* action_body_item ::= local_decl */ - yytestcase(yyruleno == 3); - case 43: /* block_member ::= declaration */ - yytestcase(yyruleno == 43); - case 44: /* block_member ::= include_directive */ - yytestcase(yyruleno == 44); - case 45: /* block_member ::= rule_decl */ - yytestcase(yyruleno == 45); - case 65: /* declaration ::= entity_decl */ - yytestcase(yyruleno == 65); - case 66: /* declaration ::= function_decl */ - yytestcase(yyruleno == 66); - case 67: /* declaration ::= procedure_decl */ - yytestcase(yyruleno == 67); - case 68: /* declaration ::= type_decl */ - yytestcase(yyruleno == 68); - case 87: /* schema_decl_list ::= schema_decl */ - yytestcase(yyruleno == 87); - case 157: /* rename_list ::= rename */ - yytestcase(yyruleno == 157); - case 166: /* interface_specification ::= use_clause */ - yytestcase(yyruleno == 166); - case 167: /* interface_specification ::= reference_clause */ - yytestcase(yyruleno == 167); - case 203: /* oneof_op ::= TOK_ONEOF */ - yytestcase(yyruleno == 203); - case 251: /* schema_decl ::= include_directive */ - yytestcase(yyruleno == 251); - case 291: /* type_item_body ::= enumeration_type */ - yytestcase(yyruleno == 291); + break; + case 1: /* action_body_item ::= declaration */ + case 2: /* action_body_item ::= constant_decl */ yytestcase(yyruleno==2); + case 3: /* action_body_item ::= local_decl */ yytestcase(yyruleno==3); + case 43: /* block_member ::= declaration */ yytestcase(yyruleno==43); + case 44: /* block_member ::= include_directive */ yytestcase(yyruleno==44); + case 45: /* block_member ::= rule_decl */ yytestcase(yyruleno==45); + case 65: /* declaration ::= entity_decl */ yytestcase(yyruleno==65); + case 66: /* declaration ::= function_decl */ yytestcase(yyruleno==66); + case 67: /* declaration ::= procedure_decl */ yytestcase(yyruleno==67); + case 68: /* declaration ::= type_decl */ yytestcase(yyruleno==68); + case 87: /* schema_decl_list ::= schema_decl */ yytestcase(yyruleno==87); + case 157: /* rename_list ::= rename */ yytestcase(yyruleno==157); + case 166: /* interface_specification ::= use_clause */ yytestcase(yyruleno==166); + case 167: /* interface_specification ::= reference_clause */ yytestcase(yyruleno==167); + case 203: /* oneof_op ::= TOK_ONEOF */ yytestcase(yyruleno==203); + case 251: /* schema_decl ::= include_directive */ yytestcase(yyruleno==251); + case 291: /* type_item_body ::= enumeration_type */ yytestcase(yyruleno==291); #line 303 "expparse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[0].minor.yy0; +} #line 2224 "expparse.c" - break; - case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ - case 42: /* block_list ::= block_list block_member */ - yytestcase(yyruleno == 42); - case 63: /* constant_body_list ::= constant_body constant_body_list */ - yytestcase(yyruleno == 63); - case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ - yytestcase(yyruleno == 88); - case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ - yytestcase(yyruleno == 169); - case 195: /* local_body ::= local_variable local_body */ - yytestcase(yyruleno == 195); - case 248: /* schema_body ::= interface_specification_list block_list */ - yytestcase(yyruleno == 248); + break; + case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ + case 42: /* block_list ::= block_list block_member */ yytestcase(yyruleno==42); + case 63: /* constant_body_list ::= constant_body constant_body_list */ yytestcase(yyruleno==63); + case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ yytestcase(yyruleno==88); + case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ yytestcase(yyruleno==169); + case 195: /* local_body ::= local_variable local_body */ yytestcase(yyruleno==195); + case 248: /* schema_body ::= interface_specification_list block_list */ yytestcase(yyruleno==248); #line 320 "expparse.y" - { - yygotominor.yy0 = yymsp[-1].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-1].minor.yy0; +} #line 2237 "expparse.c" - break; - case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ - case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 202); - case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 275); + break; + case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ + case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==202); + case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==275); #line 337 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 2246 "expparse.c" - break; - case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ - case 319: /* unique_clause ::= */ - yytestcase(yyruleno == 319); + break; + case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ + case 319: /* unique_clause ::= */ yytestcase(yyruleno==319); #line 341 "expparse.y" - { - yygotominor.yy371 = 0; - } +{ + yygotominor.yy371 = 0; +} #line 2254 "expparse.c" - break; - case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ + break; + case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ #line 347 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = LISTcreate(); - } +{ + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = LISTcreate(); +} #line 2262 "expparse.c" - break; - case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ + break; + case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ #line 353 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = yymsp[-1].minor.yy371; +} #line 2270 "expparse.c" - break; - case 10: /* aggregate_init_element ::= expression */ - case 25: /* assignable ::= identifier */ - yytestcase(yyruleno == 25); - case 47: /* by_expression ::= TOK_BY expression */ - yytestcase(yyruleno == 47); - case 89: /* expression ::= simple_expression */ - yytestcase(yyruleno == 89); - case 104: /* simple_expression ::= unary_expression */ - yytestcase(yyruleno == 104); - case 154: /* initializer ::= TOK_ASSIGNMENT expression */ - yytestcase(yyruleno == 154); - case 190: /* literal ::= constant */ - yytestcase(yyruleno == 190); - case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ - yytestcase(yyruleno == 191); - case 298: /* general_ref ::= assignable */ - yytestcase(yyruleno == 298); - case 299: /* unary_expression ::= aggregate_initializer */ - yytestcase(yyruleno == 299); - case 301: /* unary_expression ::= literal */ - yytestcase(yyruleno == 301); - case 302: /* unary_expression ::= function_call */ - yytestcase(yyruleno == 302); - case 303: /* unary_expression ::= identifier */ - yytestcase(yyruleno == 303); - case 305: /* unary_expression ::= interval */ - yytestcase(yyruleno == 305); - case 306: /* unary_expression ::= query_expression */ - yytestcase(yyruleno == 306); - case 308: /* unary_expression ::= TOK_PLUS unary_expression */ - yytestcase(yyruleno == 308); - case 312: /* qualified_attr ::= attribute_decl */ - yytestcase(yyruleno == 312); - case 322: /* until_control ::= TOK_UNTIL expression */ - yytestcase(yyruleno == 322); - case 331: /* while_control ::= TOK_WHILE expression */ - yytestcase(yyruleno == 331); + break; + case 10: /* aggregate_init_element ::= expression */ + case 25: /* assignable ::= identifier */ yytestcase(yyruleno==25); + case 47: /* by_expression ::= TOK_BY expression */ yytestcase(yyruleno==47); + case 89: /* expression ::= simple_expression */ yytestcase(yyruleno==89); + case 104: /* simple_expression ::= unary_expression */ yytestcase(yyruleno==104); + case 154: /* initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==154); + case 190: /* literal ::= constant */ yytestcase(yyruleno==190); + case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==191); + case 298: /* general_ref ::= assignable */ yytestcase(yyruleno==298); + case 299: /* unary_expression ::= aggregate_initializer */ yytestcase(yyruleno==299); + case 301: /* unary_expression ::= literal */ yytestcase(yyruleno==301); + case 302: /* unary_expression ::= function_call */ yytestcase(yyruleno==302); + case 303: /* unary_expression ::= identifier */ yytestcase(yyruleno==303); + case 305: /* unary_expression ::= interval */ yytestcase(yyruleno==305); + case 306: /* unary_expression ::= query_expression */ yytestcase(yyruleno==306); + case 308: /* unary_expression ::= TOK_PLUS unary_expression */ yytestcase(yyruleno==308); + case 312: /* qualified_attr ::= attribute_decl */ yytestcase(yyruleno==312); + case 322: /* until_control ::= TOK_UNTIL expression */ yytestcase(yyruleno==322); + case 331: /* while_control ::= TOK_WHILE expression */ yytestcase(yyruleno==331); #line 359 "expparse.y" - { - yygotominor.yy401 = yymsp[0].minor.yy401; - } +{ + yygotominor.yy401 = yymsp[0].minor.yy401; +} #line 2295 "expparse.c" - break; - case 11: /* aggregate_init_body ::= aggregate_init_element */ - case 113: /* expression_list ::= expression */ - yytestcase(yyruleno == 113); - case 282: /* supertype_expression_list ::= supertype_expression */ - yytestcase(yyruleno == 282); - case 313: /* qualified_attr_list ::= qualified_attr */ - yytestcase(yyruleno == 313); + break; + case 11: /* aggregate_init_body ::= aggregate_init_element */ + case 113: /* expression_list ::= expression */ yytestcase(yyruleno==113); + case 282: /* supertype_expression_list ::= supertype_expression */ yytestcase(yyruleno==282); + case 313: /* qualified_attr_list ::= qualified_attr */ yytestcase(yyruleno==313); #line 364 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2306 "expparse.c" - break; - case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ + break; + case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ #line 369 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; - } + yymsp[0].minor.yy401->type = Type_Repeat; +} #line 2318 "expparse.c" - break; - case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ + break; + case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ #line 379 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +} #line 2328 "expparse.c" - break; - case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ + break; + case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ #line 387 "expparse.y" - { - yygotominor.yy371 = yymsp[-4].minor.yy371; +{ + yygotominor.yy371 = yymsp[-4].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; - } + yymsp[0].minor.yy401->type = Type_Repeat; +} #line 2340 "expparse.c" - break; - case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ + break; + case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ #line 397 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - - if(tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } - } +{ + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + + if (tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } +} #line 2356 "expparse.c" - break; - case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ + break; + case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ #line 411 "expparse.y" - { - Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); - - if(t) { - SCOPEadd_super(t); - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->tag = t; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } - } +{ + Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); + + if (t) { + SCOPEadd_super(t); + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->tag = t; + yygotominor.yy477->base = yymsp[0].minor.yy297; + } +} #line 2370 "expparse.c" - break; - case 17: /* aggregation_type ::= array_type */ - case 18: /* aggregation_type ::= bag_type */ - yytestcase(yyruleno == 18); - case 19: /* aggregation_type ::= list_type */ - yytestcase(yyruleno == 19); - case 20: /* aggregation_type ::= set_type */ - yytestcase(yyruleno == 20); + break; + case 17: /* aggregation_type ::= array_type */ + case 18: /* aggregation_type ::= bag_type */ yytestcase(yyruleno==18); + case 19: /* aggregation_type ::= list_type */ yytestcase(yyruleno==19); + case 20: /* aggregation_type ::= set_type */ yytestcase(yyruleno==20); #line 423 "expparse.y" - { - yygotominor.yy477 = yymsp[0].minor.yy477; - } +{ + yygotominor.yy477 = yymsp[0].minor.yy477; +} #line 2380 "expparse.c" - break; - case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ + break; + case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ #line 442 "expparse.y" - { - Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); - Variable v = VARcreate(e, Type_Unknown); +{ + Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); + Variable v = VARcreate(e, Type_Unknown); - v->initializer = yymsp[-5].minor.yy401; + v->initializer = yymsp[-5].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, - yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); - yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, + yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); + yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); - POP_SCOPE(); - } + POP_SCOPE(); +} #line 2396 "expparse.c" - break; - case 22: /* alias_push_scope ::= */ + break; + case 22: /* alias_push_scope ::= */ #line 456 "expparse.y" - { - struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); - PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); - } +{ + struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); + PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); +} #line 2404 "expparse.c" - break; - case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ + break; + case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ #line 463 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 2417 "expparse.c" - break; - case 24: /* assignable ::= assignable qualifier */ - case 300: /* unary_expression ::= unary_expression qualifier */ - yytestcase(yyruleno == 300); + break; + case 24: /* assignable ::= assignable qualifier */ + case 300: /* unary_expression ::= unary_expression qualifier */ yytestcase(yyruleno==300); #line 475 "expparse.y" - { - yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy46.expr; - } +{ + yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy46.expr; +} #line 2426 "expparse.c" - break; - case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ + break; + case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ #line 486 "expparse.y" - { - yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); - } +{ + yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); +} #line 2433 "expparse.c" - break; - case 27: /* attribute_type ::= aggregation_type */ - case 28: /* attribute_type ::= basic_type */ - yytestcase(yyruleno == 28); - case 122: /* parameter_type ::= basic_type */ - yytestcase(yyruleno == 122); - case 123: /* parameter_type ::= conformant_aggregation */ - yytestcase(yyruleno == 123); + break; + case 27: /* attribute_type ::= aggregation_type */ + case 28: /* attribute_type ::= basic_type */ yytestcase(yyruleno==28); + case 122: /* parameter_type ::= basic_type */ yytestcase(yyruleno==122); + case 123: /* parameter_type ::= conformant_aggregation */ yytestcase(yyruleno==123); #line 491 "expparse.y" - { - yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); - SCOPEadd_super(yygotominor.yy297); - } +{ + yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); + SCOPEadd_super(yygotominor.yy297); +} #line 2444 "expparse.c" - break; - case 29: /* attribute_type ::= defined_type */ - case 124: /* parameter_type ::= defined_type */ - yytestcase(yyruleno == 124); - case 125: /* parameter_type ::= generic_type */ - yytestcase(yyruleno == 125); + break; + case 29: /* attribute_type ::= defined_type */ + case 124: /* parameter_type ::= defined_type */ yytestcase(yyruleno==124); + case 125: /* parameter_type ::= generic_type */ yytestcase(yyruleno==125); #line 501 "expparse.y" - { - yygotominor.yy297 = yymsp[0].minor.yy297; - } +{ + yygotominor.yy297 = yymsp[0].minor.yy297; +} #line 2453 "expparse.c" - break; - case 30: /* explicit_attr_list ::= */ - case 50: /* case_action_list ::= */ - yytestcase(yyruleno == 50); - case 69: /* derive_decl ::= */ - yytestcase(yyruleno == 69); - case 268: /* statement_rep ::= */ - yytestcase(yyruleno == 268); + break; + case 30: /* explicit_attr_list ::= */ + case 50: /* case_action_list ::= */ yytestcase(yyruleno==50); + case 69: /* derive_decl ::= */ yytestcase(yyruleno==69); + case 268: /* statement_rep ::= */ yytestcase(yyruleno==268); #line 506 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - } +{ + yygotominor.yy371 = LISTcreate(); +} #line 2463 "expparse.c" - break; - case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ + break; + case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ #line 510 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); +} #line 2471 "expparse.c" - break; - case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ - case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ - yytestcase(yyruleno == 138); + break; + case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ + case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ yytestcase(yyruleno==138); #line 516 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 2482 "expparse.c" - break; - case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ + break; + case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ #line 523 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 2490 "expparse.c" - break; - case 34: /* basic_type ::= TOK_BOOLEAN */ + break; + case 34: /* basic_type ::= TOK_BOOLEAN */ #line 529 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(boolean_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(boolean_); +} #line 2497 "expparse.c" - break; - case 35: /* basic_type ::= TOK_INTEGER precision_spec */ + break; + case 35: /* basic_type ::= TOK_INTEGER precision_spec */ #line 533 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(integer_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; - } +{ + yygotominor.yy477 = TYPEBODYcreate(integer_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; +} #line 2505 "expparse.c" - break; - case 36: /* basic_type ::= TOK_REAL precision_spec */ + break; + case 36: /* basic_type ::= TOK_REAL precision_spec */ #line 538 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(real_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; - } +{ + yygotominor.yy477 = TYPEBODYcreate(real_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; +} #line 2513 "expparse.c" - break; - case 37: /* basic_type ::= TOK_NUMBER */ + break; + case 37: /* basic_type ::= TOK_NUMBER */ #line 543 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(number_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(number_); +} #line 2520 "expparse.c" - break; - case 38: /* basic_type ::= TOK_LOGICAL */ + break; + case 38: /* basic_type ::= TOK_LOGICAL */ #line 547 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(logical_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(logical_); +} #line 2527 "expparse.c" - break; - case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ + break; + case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ #line 551 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(binary_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; - } +{ + yygotominor.yy477 = TYPEBODYcreate(binary_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; +} #line 2536 "expparse.c" - break; - case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ + break; + case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ #line 557 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(string_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; - } +{ + yygotominor.yy477 = TYPEBODYcreate(string_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; +} #line 2545 "expparse.c" - break; - case 46: /* by_expression ::= */ + break; + case 46: /* by_expression ::= */ #line 583 "expparse.y" - { - yygotominor.yy401 = LITERAL_ONE; - } +{ + yygotominor.yy401 = LITERAL_ONE; +} #line 2552 "expparse.c" - break; - case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ - case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ - yytestcase(yyruleno == 181); + break; + case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ + case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ yytestcase(yyruleno==181); #line 593 "expparse.y" - { - yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; - yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; + yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; +} #line 2561 "expparse.c" - break; - case 49: /* case_action ::= case_labels TOK_COLON statement */ + break; + case 49: /* case_action ::= case_labels TOK_COLON statement */ #line 599 "expparse.y" - { - yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); - } +{ + yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); +} #line 2569 "expparse.c" - break; - case 51: /* case_action_list ::= case_action_list case_action */ + break; + case 51: /* case_action_list ::= case_action_list case_action */ #line 609 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-1].minor.yy371; + yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); - } + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); +} #line 2580 "expparse.c" - break; - case 52: /* case_block ::= case_action_list case_otherwise */ + break; + case 52: /* case_block ::= case_action_list case_otherwise */ #line 618 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - - if(yymsp[0].minor.yy321) { - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy321); - } - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + + if (yymsp[0].minor.yy321) { + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy321); + } +} #line 2592 "expparse.c" - break; - case 53: /* case_labels ::= expression */ + break; + case 53: /* case_labels ::= expression */ #line 628 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); +{ + yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2601 "expparse.c" - break; - case 54: /* case_labels ::= case_labels TOK_COMMA expression */ + break; + case 54: /* case_labels ::= case_labels TOK_COMMA expression */ #line 634 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2611 "expparse.c" - break; - case 55: /* case_otherwise ::= */ + break; + case 55: /* case_otherwise ::= */ #line 642 "expparse.y" - { - yygotominor.yy321 = (Case_Item)0; - } +{ + yygotominor.yy321 = (Case_Item)0; +} #line 2618 "expparse.c" - break; - case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ + break; + case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ #line 646 "expparse.y" - { - yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); - } +{ + yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); +} #line 2626 "expparse.c" - break; - case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ + break; + case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ #line 653 "expparse.y" - { - yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +} #line 2633 "expparse.c" - break; - case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ + break; + case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ #line 658 "expparse.y" - { - yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); +} #line 2640 "expparse.c" - break; - case 59: /* constant ::= TOK_PI */ + break; + case 59: /* constant ::= TOK_PI */ #line 663 "expparse.y" - { - yygotominor.yy401 = LITERAL_PI; - } +{ + yygotominor.yy401 = LITERAL_PI; +} #line 2647 "expparse.c" - break; - case 60: /* constant ::= TOK_E */ + break; + case 60: /* constant ::= TOK_E */ #line 668 "expparse.y" - { - yygotominor.yy401 = LITERAL_E; - } +{ + yygotominor.yy401 = LITERAL_E; +} #line 2654 "expparse.c" - break; - case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ + break; + case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ #line 675 "expparse.y" - { - Variable v; - - yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; - v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); - v->initializer = yymsp[-1].minor.yy401; - v->flags.constant = 1; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, - &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); - } +{ + Variable v; + + yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; + v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); + v->initializer = yymsp[-1].minor.yy401; + v->flags.constant = 1; + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, + &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); +} #line 2668 "expparse.c" - break; - case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ + break; + case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ #line 694 "expparse.y" - { - yygotominor.yy0 = yymsp[-3].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-3].minor.yy0; +} #line 2675 "expparse.c" - break; - case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ + break; + case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ #line 726 "expparse.y" - { - yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); - yygotominor.yy91->initializer = yymsp[-1].minor.yy401; - yygotominor.yy91->flags.attribute = true; - } +{ + yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); + yygotominor.yy91->initializer = yymsp[-1].minor.yy401; + yygotominor.yy91->flags.attribute = true; +} #line 2684 "expparse.c" - break; - case 72: /* derived_attribute_rep ::= derived_attribute */ - case 176: /* inverse_attr_list ::= inverse_attr */ - yytestcase(yyruleno == 176); + break; + case 72: /* derived_attribute_rep ::= derived_attribute */ + case 176: /* inverse_attr_list ::= inverse_attr */ yytestcase(yyruleno==176); #line 733 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 2693 "expparse.c" - break; - case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ - case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ - yytestcase(yyruleno == 177); + break; + case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ + case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ yytestcase(yyruleno==177); #line 738 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 2702 "expparse.c" - break; - case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ + break; + case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ #line 745 "expparse.y" - { - yygotominor.yy176.attributes = yymsp[-4].minor.yy371; - /* this is flattened out in entity_decl - DEL */ - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); - - if(yymsp[-2].minor.yy371 != LIST_NULL) { - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); - } - - yygotominor.yy176.unique = yymsp[-1].minor.yy371; - yygotominor.yy176.where = yymsp[0].minor.yy371; - } +{ + yygotominor.yy176.attributes = yymsp[-4].minor.yy371; + /* this is flattened out in entity_decl - DEL */ + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); + + if (yymsp[-2].minor.yy371 != LIST_NULL) { + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); + } + + yygotominor.yy176.unique = yymsp[-1].minor.yy371; + yygotominor.yy176.where = yymsp[0].minor.yy371; +} #line 2718 "expparse.c" - break; - case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ + break; + case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ #line 760 "expparse.y" - { - CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; - CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; - LISTdo(yymsp[-2].minor.yy176.attributes, l, Linked_List) { - LISTdo_n(l, a, Variable, b) { - ENTITYadd_attribute(CURRENT_SCOPE, a); - } - LISTod; - } - LISTod; - CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; - CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; - CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; - POP_SCOPE(); - } +{ + CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; + CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; + LISTdo( yymsp[-2].minor.yy176.attributes, l, Linked_List ) { + LISTdo_n( l, a, Variable, b ) { + ENTITYadd_attribute(CURRENT_SCOPE, a); + } LISTod; + } LISTod; + CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; + CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; + CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; + POP_SCOPE(); +} #line 2735 "expparse.c" - break; - case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ + break; + case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ #line 775 "expparse.y" - { - Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); +{ + Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf( stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); - } + PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); +} #line 2748 "expparse.c" - break; - case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ + break; + case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ #line 786 "expparse.y" - { - int value = 0; - Expression x; - Symbol *tmp; - TypeBody tb; - tb = TYPEBODYcreate(enumeration_); - CURRENT_SCOPE->u.type->head = 0; - CURRENT_SCOPE->u.type->body = tb; - tb->list = yymsp[0].minor.yy371; - - if(!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - if(!PREVIOUS_SCOPE->enum_table) { - PREVIOUS_SCOPE->enum_table = DICTcreate(25); - } - LISTdo_links(yymsp[0].minor.yy371, id) { - tmp = (Symbol *)id->data; - id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); - x->symbol = *(tmp); - x->u.integer = ++value; - - /* define both in enum scope and scope of */ - /* 1st visibility */ - DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - SYMBOL_destroy(tmp); - } - LISTod; - } +{ + int value = 0; + Expression x; + Symbol *tmp; + TypeBody tb; + tb = TYPEBODYcreate(enumeration_); + CURRENT_SCOPE->u.type->head = 0; + CURRENT_SCOPE->u.type->body = tb; + tb->list = yymsp[0].minor.yy371; + + if (!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + if (!PREVIOUS_SCOPE->enum_table) { + PREVIOUS_SCOPE->enum_table = DICTcreate(25); + } + LISTdo_links(yymsp[0].minor.yy371, id) { + tmp = (Symbol *)id->data; + id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); + x->symbol = *(tmp); + x->u.integer = ++value; + + /* define both in enum scope and scope of */ + /* 1st visibility */ + DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + SYMBOL_destroy(tmp); + } LISTod; +} #line 2783 "expparse.c" - break; - case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ + break; + case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ #line 819 "expparse.y" - { - yygotominor.yy332 = STATEMENT_ESCAPE; - } +{ + yygotominor.yy332 = STATEMENT_ESCAPE; +} #line 2790 "expparse.c" - break; - case 79: /* attribute_decl ::= TOK_IDENTIFIER */ + break; + case 79: /* attribute_decl ::= TOK_IDENTIFIER */ #line 834 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Attribute); - yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Attribute); + yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 2799 "expparse.c" - break; - case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ + break; + case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ #line 841 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1->e.op_code = OP_GROUP; - yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); - yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); - SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); - - yygotominor.yy401->e.op_code = OP_DOT; - yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1->e.op_code = OP_GROUP; + yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); + yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); + SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); + + yygotominor.yy401->e.op_code = OP_DOT; + yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 2815 "expparse.c" - break; - case 81: /* attribute_decl_list ::= attribute_decl */ + break; + case 81: /* attribute_decl_list ::= attribute_decl */ #line 855 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +} #line 2824 "expparse.c" - break; - case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ - case 114: /* expression_list ::= expression_list TOK_COMMA expression */ - yytestcase(yyruleno == 114); - case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ - yytestcase(yyruleno == 314); + break; + case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ + case 114: /* expression_list ::= expression_list TOK_COMMA expression */ yytestcase(yyruleno==114); + case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ yytestcase(yyruleno==314); #line 862 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2834 "expparse.c" - break; - case 83: /* optional ::= */ + break; + case 83: /* optional ::= */ #line 868 "expparse.y" - { - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.optional = 0; +} #line 2841 "expparse.c" - break; - case 84: /* optional ::= TOK_OPTIONAL */ + break; + case 84: /* optional ::= TOK_OPTIONAL */ #line 872 "expparse.y" - { - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.optional = 1; +} #line 2848 "expparse.c" - break; - case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ + break; + case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ #line 878 "expparse.y" - { - Variable v; - - LISTdo_links(yymsp[-4].minor.yy371, attr) - v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); - v->flags.optional = yymsp[-2].minor.yy252.optional; - v->flags.attribute = true; - attr->data = (Generic)v; - LISTod; - - yygotominor.yy371 = yymsp[-4].minor.yy371; - } +{ + Variable v; + + LISTdo_links (yymsp[-4].minor.yy371, attr) + v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); + v->flags.optional = yymsp[-2].minor.yy252.optional; + v->flags.attribute = true; + attr->data = (Generic)v; + LISTod; + + yygotominor.yy371 = yymsp[-4].minor.yy371; +} #line 2864 "expparse.c" - break; - case 90: /* expression ::= expression TOK_AND expression */ + break; + case 90: /* expression ::= expression TOK_AND expression */ #line 907 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2873 "expparse.c" - break; - case 91: /* expression ::= expression TOK_OR expression */ + break; + case 91: /* expression ::= expression TOK_OR expression */ #line 913 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2882 "expparse.c" - break; - case 92: /* expression ::= expression TOK_XOR expression */ + break; + case 92: /* expression ::= expression TOK_XOR expression */ #line 919 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2891 "expparse.c" - break; - case 93: /* expression ::= expression TOK_LESS_THAN expression */ + break; + case 93: /* expression ::= expression TOK_LESS_THAN expression */ #line 925 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2900 "expparse.c" - break; - case 94: /* expression ::= expression TOK_GREATER_THAN expression */ + break; + case 94: /* expression ::= expression TOK_GREATER_THAN expression */ #line 931 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2909 "expparse.c" - break; - case 95: /* expression ::= expression TOK_EQUAL expression */ + break; + case 95: /* expression ::= expression TOK_EQUAL expression */ #line 937 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2918 "expparse.c" - break; - case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ + break; + case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ #line 943 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2927 "expparse.c" - break; - case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ + break; + case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ #line 949 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2936 "expparse.c" - break; - case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ + break; + case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ #line 955 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2945 "expparse.c" - break; - case 99: /* expression ::= expression TOK_INST_EQUAL expression */ + break; + case 99: /* expression ::= expression TOK_INST_EQUAL expression */ #line 961 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2954 "expparse.c" - break; - case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ + break; + case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ #line 967 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2963 "expparse.c" - break; - case 101: /* expression ::= expression TOK_IN expression */ + break; + case 101: /* expression ::= expression TOK_IN expression */ #line 973 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2972 "expparse.c" - break; - case 102: /* expression ::= expression TOK_LIKE expression */ + break; + case 102: /* expression ::= expression TOK_LIKE expression */ #line 979 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2981 "expparse.c" - break; - case 103: /* expression ::= simple_expression cardinality_op simple_expression */ - case 240: /* right_curl ::= TOK_RIGHT_CURL */ - yytestcase(yyruleno == 240); - case 254: /* semicolon ::= TOK_SEMICOLON */ - yytestcase(yyruleno == 254); + break; + case 103: /* expression ::= simple_expression cardinality_op simple_expression */ + case 240: /* right_curl ::= TOK_RIGHT_CURL */ yytestcase(yyruleno==240); + case 254: /* semicolon ::= TOK_SEMICOLON */ yytestcase(yyruleno==254); #line 985 "expparse.y" - { - yyerrok; - } +{ + yyerrok; +} #line 2990 "expparse.c" - break; - case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ + break; + case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ #line 995 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2999 "expparse.c" - break; - case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ + break; + case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ #line 1001 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3008 "expparse.c" - break; - case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ + break; + case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ #line 1007 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3017 "expparse.c" - break; - case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ + break; + case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ #line 1013 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3026 "expparse.c" - break; - case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ + break; + case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ #line 1019 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3035 "expparse.c" - break; - case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ + break; + case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ #line 1025 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3044 "expparse.c" - break; - case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ + break; + case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ #line 1031 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3053 "expparse.c" - break; - case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ + break; + case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ #line 1037 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3062 "expparse.c" - break; - case 115: /* var ::= */ + break; + case 115: /* var ::= */ #line 1055 "expparse.y" - { - yygotominor.yy252.var = 0; - } +{ + yygotominor.yy252.var = 0; +} #line 3069 "expparse.c" - break; - case 116: /* var ::= TOK_VAR */ + break; + case 116: /* var ::= TOK_VAR */ #line 1059 "expparse.y" - { - yygotominor.yy252.var = 1; - } +{ + yygotominor.yy252.var = 1; +} #line 3076 "expparse.c" - break; - case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ + break; + case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ #line 1064 "expparse.y" - { - Symbol *tmp; - Expression e; - Variable v; - - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTdo_links(yygotominor.yy371, param) - tmp = (Symbol *)param->data; - - e = EXPcreate_from_symbol(Type_Attribute, tmp); - v = VARcreate(e, yymsp[0].minor.yy297); - v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ - v->flags.parameter = true; - param->data = (Generic)v; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, - tmp->name, (Generic)v, tmp, OBJ_VARIABLE); - - LISTod; - } +{ + Symbol *tmp; + Expression e; + Variable v; + + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTdo_links(yygotominor.yy371, param) + tmp = (Symbol*)param->data; + + e = EXPcreate_from_symbol(Type_Attribute, tmp); + v = VARcreate(e, yymsp[0].minor.yy297); + v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ + v->flags.parameter = true; + param->data = (Generic)v; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, + tmp->name, (Generic)v, tmp, OBJ_VARIABLE); + + LISTod; +} #line 3101 "expparse.c" - break; - case 118: /* formal_parameter_list ::= */ - case 179: /* inverse_clause ::= */ - yytestcase(yyruleno == 179); - case 328: /* where_rule_OPT ::= */ - yytestcase(yyruleno == 328); + break; + case 118: /* formal_parameter_list ::= */ + case 179: /* inverse_clause ::= */ yytestcase(yyruleno==179); + case 328: /* where_rule_OPT ::= */ yytestcase(yyruleno==328); #line 1087 "expparse.y" - { - yygotominor.yy371 = LIST_NULL; - } +{ + yygotominor.yy371 = LIST_NULL; +} #line 3110 "expparse.c" - break; - case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ + break; + case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ #line 1092 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; - } +} #line 3118 "expparse.c" - break; - case 120: /* formal_parameter_rep ::= formal_parameter */ + break; + case 120: /* formal_parameter_rep ::= formal_parameter */ #line 1098 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; +{ + yygotominor.yy371 = yymsp[0].minor.yy371; - } +} #line 3126 "expparse.c" - break; - case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ + break; + case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ #line 1104 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); +} #line 3134 "expparse.c" - break; - case 126: /* function_call ::= function_id actual_parameters */ + break; + case 126: /* function_call ::= function_id actual_parameters */ #line 1129 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Funcall); - yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; - SYMBOL_destroy(yymsp[-1].minor.yy275); - yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; - } +{ + yygotominor.yy401 = EXPcreate(Type_Funcall); + yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; + SYMBOL_destroy(yymsp[-1].minor.yy275); + yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; +} #line 3144 "expparse.c" - break; - case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ + break; + case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ #line 1138 "expparse.y" - { - FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3153 "expparse.c" - break; - case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ + break; + case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ #line 1146 "expparse.y" - { - Function f = CURRENT_SCOPE; +{ + Function f = CURRENT_SCOPE; - f->u.func->return_type = yymsp[-1].minor.yy297; - yygotominor.yy507 = yymsp[-5].minor.yy507; - } + f->u.func->return_type = yymsp[-1].minor.yy297; + yygotominor.yy507 = yymsp[-5].minor.yy507; +} #line 3163 "expparse.c" - break; - case 129: /* fh_lineno ::= TOK_FUNCTION */ - case 218: /* ph_get_line ::= */ - yytestcase(yyruleno == 218); - case 247: /* rh_get_line ::= */ - yytestcase(yyruleno == 247); + break; + case 129: /* fh_lineno ::= TOK_FUNCTION */ + case 218: /* ph_get_line ::= */ yytestcase(yyruleno==218); + case 247: /* rh_get_line ::= */ yytestcase(yyruleno==247); #line 1154 "expparse.y" - { - yygotominor.yy507 = SCANtell(); - } +{ + yygotominor.yy507 = SCANtell(); +} #line 3172 "expparse.c" - break; - case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ + break; + case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ #line 1159 "expparse.y" - { - Function f = ALGcreate(OBJ_FUNCTION); - tag_count = 0; - if(print_objects_while_running & OBJ_FUNCTION_BITS) { - fprintf(stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); - } - PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); - } +{ + Function f = ALGcreate(OBJ_FUNCTION); + tag_count = 0; + if (print_objects_while_running & OBJ_FUNCTION_BITS) { + fprintf( stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); + } + PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); +} #line 3184 "expparse.c" - break; - case 131: /* fh_plist ::= formal_parameter_list */ + break; + case 131: /* fh_plist ::= formal_parameter_list */ #line 1169 "expparse.y" - { - Function f = CURRENT_SCOPE; - f->u.func->parameters = yymsp[0].minor.yy371; - f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); - f->u.func->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ - } +{ + Function f = CURRENT_SCOPE; + f->u.func->parameters = yymsp[0].minor.yy371; + f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); + f->u.func->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ +} #line 3195 "expparse.c" - break; - case 132: /* function_id ::= TOK_IDENTIFIER */ - case 219: /* procedure_id ::= TOK_IDENTIFIER */ - yytestcase(yyruleno == 219); - case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ - yytestcase(yyruleno == 220); + break; + case 132: /* function_id ::= TOK_IDENTIFIER */ + case 219: /* procedure_id ::= TOK_IDENTIFIER */ yytestcase(yyruleno==219); + case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ yytestcase(yyruleno==220); #line 1178 "expparse.y" - { - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; - } +{ + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; +} #line 3204 "expparse.c" - break; - case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ + break; + case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ #line 1182 "expparse.y" - { - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; +{ + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; - } +} #line 3212 "expparse.c" - break; - case 134: /* conformant_aggregation ::= aggregate_type */ + break; + case 134: /* conformant_aggregation ::= aggregate_type */ #line 1188 "expparse.y" - { - yygotominor.yy477 = yymsp[0].minor.yy477; +{ + yygotominor.yy477 = yymsp[0].minor.yy477; - } +} #line 3220 "expparse.c" - break; - case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ + break; + case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ #line 1194 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 3230 "expparse.c" - break; - case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ + break; + case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ #line 1202 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; +} #line 3242 "expparse.c" - break; - case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ + break; + case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ #line 1211 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; - } +} #line 3251 "expparse.c" - break; - case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ + break; + case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ #line 1224 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; - } +} #line 3261 "expparse.c" - break; - case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ + break; + case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ #line 1232 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; +} #line 3272 "expparse.c" - break; - case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ - case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ - yytestcase(yyruleno == 256); + break; + case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ + case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ yytestcase(yyruleno==256); #line 1240 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 3281 "expparse.c" - break; - case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ + break; + case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ #line 1245 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3291 "expparse.c" - break; - case 143: /* generic_type ::= TOK_GENERIC */ + break; + case 143: /* generic_type ::= TOK_GENERIC */ #line 1253 "expparse.y" - { - yygotominor.yy297 = Type_Generic; - - if(tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } - } +{ + yygotominor.yy297 = Type_Generic; + + if (tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } +} #line 3306 "expparse.c" - break; - case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ + break; + case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ #line 1265 "expparse.y" - { - TypeBody g = TYPEBODYcreate(generic_); - yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); +{ + TypeBody g = TYPEBODYcreate(generic_); + yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); - SCOPEadd_super(yygotominor.yy297); + SCOPEadd_super(yygotominor.yy297); - g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); - if(g->tag) { - SCOPEadd_super(g->tag); - } - } + g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); + if (g->tag) { + SCOPEadd_super(g->tag); + } +} #line 3321 "expparse.c" - break; - case 145: /* id_list ::= TOK_IDENTIFIER */ + break; + case 145: /* id_list ::= TOK_IDENTIFIER */ #line 1278 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); - } +} #line 3330 "expparse.c" - break; - case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ + break; + case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ #line 1284 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); - } + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); +} #line 3340 "expparse.c" - break; - case 147: /* identifier ::= TOK_SELF */ + break; + case 147: /* identifier ::= TOK_SELF */ #line 1292 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Self); - } +{ + yygotominor.yy401 = EXPcreate(Type_Self); +} #line 3347 "expparse.c" - break; - case 148: /* identifier ::= TOK_QUESTION_MARK */ + break; + case 148: /* identifier ::= TOK_QUESTION_MARK */ #line 1296 "expparse.y" - { - yygotominor.yy401 = LITERAL_INFINITY; - } +{ + yygotominor.yy401 = LITERAL_INFINITY; +} #line 3354 "expparse.c" - break; - case 149: /* identifier ::= TOK_IDENTIFIER */ + break; + case 149: /* identifier ::= TOK_IDENTIFIER */ #line 1300 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Identifier); - yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Identifier); + yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3363 "expparse.c" - break; - case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ + break; + case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ #line 1308 "expparse.y" - { - yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); - } +{ + yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); +} #line 3370 "expparse.c" - break; - case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ + break; + case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ #line 1313 "expparse.y" - { - yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); +} #line 3377 "expparse.c" - break; - case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ + break; + case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ #line 1318 "expparse.y" - { - SCANinclude_file(yymsp[-1].minor.yy0.string); - } +{ + SCANinclude_file(yymsp[-1].minor.yy0.string); +} #line 3384 "expparse.c" - break; - case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ + break; + case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ #line 1324 "expparse.y" - { - Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); +{ + Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); - /* scope doesn't really have/need a name, I suppose */ - /* naming it by the iterator variable is fine */ + /* scope doesn't really have/need a name, I suppose */ + /* naming it by the iterator variable is fine */ - PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); - } + PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); +} #line 3396 "expparse.c" - break; - case 155: /* rename ::= TOK_IDENTIFIER */ + break; + case 155: /* rename ::= TOK_IDENTIFIER */ #line 1342 "expparse.y" - { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); - } +{ + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); +} #line 3403 "expparse.c" - break; - case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ + break; + case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ #line 1346 "expparse.y" - { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); - } +{ + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); +} #line 3410 "expparse.c" - break; - case 158: /* rename_list ::= rename_list TOK_COMMA rename */ - case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ - yytestcase(yyruleno == 161); - case 164: /* use_clause ::= use_head parened_rename_list semicolon */ - yytestcase(yyruleno == 164); - case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ - yytestcase(yyruleno == 249); - case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ - yytestcase(yyruleno == 295); + break; + case 158: /* rename_list ::= rename_list TOK_COMMA rename */ + case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ yytestcase(yyruleno==161); + case 164: /* use_clause ::= use_head parened_rename_list semicolon */ yytestcase(yyruleno==164); + case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ yytestcase(yyruleno==249); + case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ yytestcase(yyruleno==295); #line 1355 "expparse.y" - { - yygotominor.yy0 = yymsp[-2].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-2].minor.yy0; +} #line 3421 "expparse.c" - break; - case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1365 "expparse.y" - { - if(!CURRENT_SCHEMA->ref_schemas) { - CURRENT_SCHEMA->ref_schemas = LISTcreate(); - } +{ + if (!CURRENT_SCHEMA->ref_schemas) { + CURRENT_SCHEMA->ref_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); - } + LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); +} #line 3432 "expparse.c" - break; - case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ + break; + case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ #line 1378 "expparse.y" - { - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_reference; - } +{ + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_reference; +} #line 3440 "expparse.c" - break; - case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1384 "expparse.y" - { - if(!CURRENT_SCHEMA->use_schemas) { - CURRENT_SCHEMA->use_schemas = LISTcreate(); - } +{ + if (!CURRENT_SCHEMA->use_schemas) { + CURRENT_SCHEMA->use_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); - } + LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); +} #line 3451 "expparse.c" - break; - case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ + break; + case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ #line 1397 "expparse.y" - { - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_use; - } +{ + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_use; +} #line 3459 "expparse.c" - break; - case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ + break; + case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ #line 1420 "expparse.y" - { - Expression tmp1, tmp2; - - yygotominor.yy401 = (Expression)0; - tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); - tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); - yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); - } +{ + Expression tmp1, tmp2; + + yygotominor.yy401 = (Expression)0; + tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); + tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); + yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); +} #line 3471 "expparse.c" - break; - case 171: /* set_or_bag_of_entity ::= defined_type */ - case 289: /* type ::= defined_type */ - yytestcase(yyruleno == 289); + break; + case 171: /* set_or_bag_of_entity ::= defined_type */ + case 289: /* type ::= defined_type */ yytestcase(yyruleno==289); #line 1432 "expparse.y" - { - yygotominor.yy378.type = yymsp[0].minor.yy297; - yygotominor.yy378.body = 0; - } +{ + yygotominor.yy378.type = yymsp[0].minor.yy297; + yygotominor.yy378.body = 0; +} #line 3480 "expparse.c" - break; - case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ + break; + case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ #line 1437 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; - } +} #line 3490 "expparse.c" - break; - case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ + break; + case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ #line 1444 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3501 "expparse.c" - break; - case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ + break; + case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ #line 1452 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3512 "expparse.c" - break; - case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ + break; + case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ #line 1460 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; +} #line 3521 "expparse.c" - break; - case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ + break; + case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ #line 1487 "expparse.y" - { - if(yymsp[-3].minor.yy378.type) { - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); - } else { - Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); - SCOPEadd_super(t); - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); - } - - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; - } +{ + if (yymsp[-3].minor.yy378.type) { + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); + } else { + Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); + SCOPEadd_super(t); + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); + } + + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; +} #line 3537 "expparse.c" - break; - case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ + break; + case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ #line 1521 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; +} #line 3548 "expparse.c" - break; - case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ + break; + case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ #line 1529 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; +} #line 3557 "expparse.c" - break; - case 184: /* literal ::= TOK_INTEGER_LITERAL */ + break; + case 184: /* literal ::= TOK_INTEGER_LITERAL */ #line 1536 "expparse.y" - { - if(yymsp[0].minor.yy0.iVal == 0) { - yygotominor.yy401 = LITERAL_ZERO; - } else if(yymsp[0].minor.yy0.iVal == 1) { - yygotominor.yy401 = LITERAL_ONE; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Integer); - yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; - resolved_all(yygotominor.yy401); - } - } +{ + if (yymsp[0].minor.yy0.iVal == 0) { + yygotominor.yy401 = LITERAL_ZERO; + } else if (yymsp[0].minor.yy0.iVal == 1) { + yygotominor.yy401 = LITERAL_ONE; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Integer); + yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; + resolved_all(yygotominor.yy401); + } +} #line 3572 "expparse.c" - break; - case 185: /* literal ::= TOK_REAL_LITERAL */ + break; + case 185: /* literal ::= TOK_REAL_LITERAL */ #line 1548 "expparse.y" - { - /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ - if((fabs(yymsp[0].minor.yy0.rVal) <= FLT_MIN) && (fabs(yymsp[0].minor.yy0.rVal) > 0)) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal); - } - if(fabs(yymsp[0].minor.yy0.rVal) < DBL_MIN) { - yygotominor.yy401 = LITERAL_ZERO; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Real); - yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; - resolved_all(yygotominor.yy401); - } - } +{ + /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ + if( ( fabs( yymsp[0].minor.yy0.rVal ) <= FLT_MIN ) && ( fabs( yymsp[0].minor.yy0.rVal ) > 0 ) ) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal ); + } + if( fabs( yymsp[0].minor.yy0.rVal ) < DBL_MIN ) { + yygotominor.yy401 = LITERAL_ZERO; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Real); + yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; + resolved_all(yygotominor.yy401); + } +} #line 3592 "expparse.c" - break; - case 186: /* literal ::= TOK_STRING_LITERAL */ + break; + case 186: /* literal ::= TOK_STRING_LITERAL */ #line 1565 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_String); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_String); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); +} #line 3601 "expparse.c" - break; - case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ + break; + case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ #line 1571 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); +} #line 3610 "expparse.c" - break; - case 188: /* literal ::= TOK_LOGICAL_LITERAL */ + break; + case 188: /* literal ::= TOK_LOGICAL_LITERAL */ #line 1577 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_Logical); - yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_Logical); + yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; + resolved_all(yygotominor.yy401); +} #line 3619 "expparse.c" - break; - case 189: /* literal ::= TOK_BINARY_LITERAL */ + break; + case 189: /* literal ::= TOK_BINARY_LITERAL */ #line 1583 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_Binary); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_Binary); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; + resolved_all(yygotominor.yy401); +} #line 3628 "expparse.c" - break; - case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ + break; + case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ #line 1599 "expparse.y" - { - Expression e; - Variable v; - LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) - - /* convert symbol to name-expression */ - - e = EXPcreate(Type_Attribute); - e->symbol = *sym; - SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-1].minor.yy297); - v->offset = local_var_count++; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-3].minor.yy371); - } +{ + Expression e; + Variable v; + LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) + + /* convert symbol to name-expression */ + + e = EXPcreate(Type_Attribute); + e->symbol = *sym; SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-1].minor.yy297); + v->offset = local_var_count++; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-3].minor.yy371); +} #line 3647 "expparse.c" - break; - case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ + break; + case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ #line 1616 "expparse.y" - { - Expression e; - Variable v; - LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) - e = EXPcreate(Type_Attribute); - e->symbol = *sym; - SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-2].minor.yy297); - v->offset = local_var_count++; - v->initializer = yymsp[-1].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, - &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-4].minor.yy371); - } +{ + Expression e; + Variable v; + LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) + e = EXPcreate(Type_Attribute); + e->symbol = *sym; SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-2].minor.yy297); + v->offset = local_var_count++; + v->initializer = yymsp[-1].minor.yy401; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, + &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-4].minor.yy371); +} #line 3665 "expparse.c" - break; - case 197: /* local_decl_rules_on ::= */ + break; + case 197: /* local_decl_rules_on ::= */ #line 1640 "expparse.y" - { - tag_count = 0; /* don't signal an error if we find a generic_type */ - local_var_count = 0; /* used to keep local var decl's in the same order */ - } +{ + tag_count = 0; /* don't signal an error if we find a generic_type */ + local_var_count = 0; /* used to keep local var decl's in the same order */ +} #line 3673 "expparse.c" - break; - case 198: /* local_decl_rules_off ::= */ + break; + case 198: /* local_decl_rules_off ::= */ #line 1646 "expparse.y" - { - tag_count = -1; /* signal an error if we find a generic_type */ - } +{ + tag_count = -1; /* signal an error if we find a generic_type */ +} #line 3680 "expparse.c" - break; - case 199: /* defined_type ::= TOK_IDENTIFIER */ + break; + case 199: /* defined_type ::= TOK_IDENTIFIER */ #line 1651 "expparse.y" - { - yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(yygotominor.yy297); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(yygotominor.yy297); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3689 "expparse.c" - break; - case 200: /* defined_type_list ::= defined_type */ + break; + case 200: /* defined_type_list ::= defined_type */ #line 1658 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); - } +} #line 3698 "expparse.c" - break; - case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ + break; + case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ #line 1664 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy297); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy297); +} #line 3707 "expparse.c" - break; - case 204: /* optional_or_unique ::= */ + break; + case 204: /* optional_or_unique ::= */ #line 1681 "expparse.y" - { - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 0; +} #line 3715 "expparse.c" - break; - case 205: /* optional_or_unique ::= TOK_OPTIONAL */ + break; + case 205: /* optional_or_unique ::= TOK_OPTIONAL */ #line 1686 "expparse.y" - { - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 1; +} #line 3723 "expparse.c" - break; - case 206: /* optional_or_unique ::= TOK_UNIQUE */ + break; + case 206: /* optional_or_unique ::= TOK_UNIQUE */ #line 1691 "expparse.y" - { - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 0; +} #line 3731 "expparse.c" - break; - case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ - case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ - yytestcase(yyruleno == 208); + break; + case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ + case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ yytestcase(yyruleno==208); #line 1696 "expparse.y" - { - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 1; +} #line 3740 "expparse.c" - break; - case 209: /* optional_fixed ::= */ + break; + case 209: /* optional_fixed ::= */ #line 1707 "expparse.y" - { - yygotominor.yy252.fixed = 0; - } +{ + yygotominor.yy252.fixed = 0; +} #line 3747 "expparse.c" - break; - case 210: /* optional_fixed ::= TOK_FIXED */ + break; + case 210: /* optional_fixed ::= TOK_FIXED */ #line 1711 "expparse.y" - { - yygotominor.yy252.fixed = 1; - } +{ + yygotominor.yy252.fixed = 1; +} #line 3754 "expparse.c" - break; - case 211: /* precision_spec ::= */ + break; + case 211: /* precision_spec ::= */ #line 1716 "expparse.y" - { - yygotominor.yy401 = (Expression)0; - } +{ + yygotominor.yy401 = (Expression)0; +} #line 3761 "expparse.c" - break; - case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ - case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 304); + break; + case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ + case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ yytestcase(yyruleno==304); #line 1720 "expparse.y" - { - yygotominor.yy401 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy401 = yymsp[-1].minor.yy401; +} #line 3769 "expparse.c" - break; - case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ + break; + case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ #line 1730 "expparse.y" - { - yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); - yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); - } +{ + yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); + yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); +} #line 3777 "expparse.c" - break; - case 214: /* proc_call_statement ::= procedure_id semicolon */ + break; + case 214: /* proc_call_statement ::= procedure_id semicolon */ #line 1735 "expparse.y" - { - yygotominor.yy332 = PCALLcreate((Linked_List)0); - yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); - } +{ + yygotominor.yy332 = PCALLcreate((Linked_List)0); + yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); +} #line 3785 "expparse.c" - break; - case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ + break; + case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ #line 1742 "expparse.y" - { - PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3794 "expparse.c" - break; - case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ + break; + case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ #line 1750 "expparse.y" - { - Procedure p = CURRENT_SCOPE; - p->u.proc->parameters = yymsp[-1].minor.yy371; - p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); - p->u.proc->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ - yygotominor.yy507 = yymsp[-3].minor.yy507; - } +{ + Procedure p = CURRENT_SCOPE; + p->u.proc->parameters = yymsp[-1].minor.yy371; + p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); + p->u.proc->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 3806 "expparse.c" - break; - case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ + break; + case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ #line 1760 "expparse.y" - { - Procedure p = ALGcreate(OBJ_PROCEDURE); - tag_count = 0; +{ + Procedure p = ALGcreate(OBJ_PROCEDURE); + tag_count = 0; - if(print_objects_while_running & OBJ_PROCEDURE_BITS) { - fprintf(stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_PROCEDURE_BITS) { + fprintf( stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); - } + PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); +} #line 3820 "expparse.c" - break; - case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1786 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3830 "expparse.c" - break; - case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ + break; + case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ #line 1794 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3840 "expparse.c" - break; - case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1801 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3850 "expparse.c" - break; - case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ + break; + case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ #line 1810 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, - (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, + (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; +} #line 3859 "expparse.c" - break; - case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ + break; + case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ #line 1819 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, - (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; - yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, + (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; + yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; +} #line 3869 "expparse.c" - break; - case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ + break; + case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ #line 1827 "expparse.y" - { - yygotominor.yy401 = yymsp[-2].minor.yy401; - yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; - POP_SCOPE(); - } +{ + yygotominor.yy401 = yymsp[-2].minor.yy401; + yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; + POP_SCOPE(); +} #line 3878 "expparse.c" - break; - case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ + break; + case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ #line 1835 "expparse.y" - { - yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); - SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); - PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); - } +{ + yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); + SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); + PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); +} #line 3887 "expparse.c" - break; - case 228: /* rel_op ::= TOK_LESS_THAN */ + break; + case 228: /* rel_op ::= TOK_LESS_THAN */ #line 1842 "expparse.y" - { - yygotominor.yy126 = OP_LESS_THAN; - } +{ + yygotominor.yy126 = OP_LESS_THAN; +} #line 3894 "expparse.c" - break; - case 229: /* rel_op ::= TOK_GREATER_THAN */ + break; + case 229: /* rel_op ::= TOK_GREATER_THAN */ #line 1846 "expparse.y" - { - yygotominor.yy126 = OP_GREATER_THAN; - } +{ + yygotominor.yy126 = OP_GREATER_THAN; +} #line 3901 "expparse.c" - break; - case 230: /* rel_op ::= TOK_EQUAL */ + break; + case 230: /* rel_op ::= TOK_EQUAL */ #line 1850 "expparse.y" - { - yygotominor.yy126 = OP_EQUAL; - } +{ + yygotominor.yy126 = OP_EQUAL; +} #line 3908 "expparse.c" - break; - case 231: /* rel_op ::= TOK_LESS_EQUAL */ + break; + case 231: /* rel_op ::= TOK_LESS_EQUAL */ #line 1854 "expparse.y" - { - yygotominor.yy126 = OP_LESS_EQUAL; - } +{ + yygotominor.yy126 = OP_LESS_EQUAL; +} #line 3915 "expparse.c" - break; - case 232: /* rel_op ::= TOK_GREATER_EQUAL */ + break; + case 232: /* rel_op ::= TOK_GREATER_EQUAL */ #line 1858 "expparse.y" - { - yygotominor.yy126 = OP_GREATER_EQUAL; - } +{ + yygotominor.yy126 = OP_GREATER_EQUAL; +} #line 3922 "expparse.c" - break; - case 233: /* rel_op ::= TOK_NOT_EQUAL */ + break; + case 233: /* rel_op ::= TOK_NOT_EQUAL */ #line 1862 "expparse.y" - { - yygotominor.yy126 = OP_NOT_EQUAL; - } +{ + yygotominor.yy126 = OP_NOT_EQUAL; +} #line 3929 "expparse.c" - break; - case 234: /* rel_op ::= TOK_INST_EQUAL */ + break; + case 234: /* rel_op ::= TOK_INST_EQUAL */ #line 1866 "expparse.y" - { - yygotominor.yy126 = OP_INST_EQUAL; - } +{ + yygotominor.yy126 = OP_INST_EQUAL; +} #line 3936 "expparse.c" - break; - case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ + break; + case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ #line 1870 "expparse.y" - { - yygotominor.yy126 = OP_INST_NOT_EQUAL; - } +{ + yygotominor.yy126 = OP_INST_NOT_EQUAL; +} #line 3943 "expparse.c" - break; - case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1878 "expparse.y" - { - yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +{ + yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - /* matching PUSH_SCOPE is in increment_control */ - POP_SCOPE(); - } + /* matching PUSH_SCOPE is in increment_control */ + POP_SCOPE(); +} #line 3953 "expparse.c" - break; - case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1886 "expparse.y" - { - yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +} #line 3960 "expparse.c" - break; - case 238: /* return_statement ::= TOK_RETURN semicolon */ + break; + case 238: /* return_statement ::= TOK_RETURN semicolon */ #line 1891 "expparse.y" - { - yygotominor.yy332 = RETcreate((Expression)0); - } +{ + yygotominor.yy332 = RETcreate((Expression)0); +} #line 3967 "expparse.c" - break; - case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ + break; + case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ #line 1896 "expparse.y" - { - yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); - } +{ + yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); +} #line 3974 "expparse.c" - break; - case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ + break; + case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ #line 1907 "expparse.y" - { - RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); - RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); + RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3984 "expparse.c" - break; - case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ + break; + case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ #line 1915 "expparse.y" - { - Expression e; - Type t; - - /* it's true that we know it will be an entity_ type later */ - TypeBody tb = TYPEBODYcreate(set_); - tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(tb->base); - t = TYPEcreate_from_body_anonymously(tb); - SCOPEadd_super(t); - e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); - yygotominor.yy91 = VARcreate(e, t); - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->flags.parameter = true; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, - yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); - } +{ + Expression e; + Type t; + + /* it's true that we know it will be an entity_ type later */ + TypeBody tb = TYPEBODYcreate(set_); + tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(tb->base); + t = TYPEcreate_from_body_anonymously(tb); + SCOPEadd_super(t); + e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); + yygotominor.yy91 = VARcreate(e, t); + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->flags.parameter = true; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, + yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); +} #line 4007 "expparse.c" - break; - case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ + break; + case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ #line 1936 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 4015 "expparse.c" - break; - case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ + break; + case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ #line 1942 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 4023 "expparse.c" - break; - case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ + break; + case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ #line 1949 "expparse.y" - { - CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; +{ + CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; - yygotominor.yy507 = yymsp[-3].minor.yy507; - } + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 4032 "expparse.c" - break; - case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ + break; + case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ #line 1957 "expparse.y" - { - Rule r = ALGcreate(OBJ_RULE); +{ + Rule r = ALGcreate(OBJ_RULE); - if(print_objects_while_running & OBJ_RULE_BITS) { - fprintf(stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_RULE_BITS) { + fprintf( stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); + } - PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); + PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); - yygotominor.yy507 = yymsp[-3].minor.yy507; - } + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 4047 "expparse.c" - break; - case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ + break; + case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ #line 1984 "expparse.y" - { - POP_SCOPE(); - } +{ + POP_SCOPE(); +} #line 4054 "expparse.c" - break; - case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ + break; + case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ #line 1993 "expparse.y" - { - Schema schema = (Schema) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); - - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); - } - - if(EXPRESSignore_duplicate_schemas && schema) { - SCANskip_to_end_schema(parseData.scanner); - PUSH_SCOPE_DUMMY(); - } else { - schema = SCHEMAcreate(); - LISTadd_last(PARSEnew_schemas, (Generic)schema); - PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); - } - } +{ + Schema schema = ( Schema ) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); + + if (print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf( stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); + } + + if (EXPRESSignore_duplicate_schemas && schema) { + SCANskip_to_end_schema(parseData.scanner); + PUSH_SCOPE_DUMMY(); + } else { + schema = SCHEMAcreate(); + LISTadd_last(PARSEnew_schemas, (Generic)schema); + PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); + } +} #line 4074 "expparse.c" - break; - case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ + break; + case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ #line 2012 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(select_); - yygotominor.yy477->list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy477 = TYPEBODYcreate(select_); + yygotominor.yy477->list = yymsp[-1].minor.yy371; +} #line 4082 "expparse.c" - break; - case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ + break; + case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ #line 2023 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; +} #line 4092 "expparse.c" - break; - case 257: /* skip_statement ::= TOK_SKIP semicolon */ + break; + case 257: /* skip_statement ::= TOK_SKIP semicolon */ #line 2036 "expparse.y" - { - yygotominor.yy332 = STATEMENT_SKIP; - } +{ + yygotominor.yy332 = STATEMENT_SKIP; +} #line 4099 "expparse.c" - break; - case 258: /* statement ::= alias_statement */ - case 259: /* statement ::= assignment_statement */ - yytestcase(yyruleno == 259); - case 260: /* statement ::= case_statement */ - yytestcase(yyruleno == 260); - case 261: /* statement ::= compound_statement */ - yytestcase(yyruleno == 261); - case 262: /* statement ::= escape_statement */ - yytestcase(yyruleno == 262); - case 263: /* statement ::= if_statement */ - yytestcase(yyruleno == 263); - case 264: /* statement ::= proc_call_statement */ - yytestcase(yyruleno == 264); - case 265: /* statement ::= repeat_statement */ - yytestcase(yyruleno == 265); - case 266: /* statement ::= return_statement */ - yytestcase(yyruleno == 266); - case 267: /* statement ::= skip_statement */ - yytestcase(yyruleno == 267); + break; + case 258: /* statement ::= alias_statement */ + case 259: /* statement ::= assignment_statement */ yytestcase(yyruleno==259); + case 260: /* statement ::= case_statement */ yytestcase(yyruleno==260); + case 261: /* statement ::= compound_statement */ yytestcase(yyruleno==261); + case 262: /* statement ::= escape_statement */ yytestcase(yyruleno==262); + case 263: /* statement ::= if_statement */ yytestcase(yyruleno==263); + case 264: /* statement ::= proc_call_statement */ yytestcase(yyruleno==264); + case 265: /* statement ::= repeat_statement */ yytestcase(yyruleno==265); + case 266: /* statement ::= return_statement */ yytestcase(yyruleno==266); + case 267: /* statement ::= skip_statement */ yytestcase(yyruleno==267); #line 2041 "expparse.y" - { - yygotominor.yy332 = yymsp[0].minor.yy332; - } +{ + yygotominor.yy332 = yymsp[0].minor.yy332; +} #line 4115 "expparse.c" - break; - case 270: /* statement_rep ::= statement statement_rep */ + break; + case 270: /* statement_rep ::= statement statement_rep */ #line 2090 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; - LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); - } +{ + yygotominor.yy371 = yymsp[0].minor.yy371; + LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); +} #line 4123 "expparse.c" - break; - case 271: /* subsuper_decl ::= */ + break; + case 271: /* subsuper_decl ::= */ #line 2100 "expparse.y" - { - yygotominor.yy242.subtypes = EXPRESSION_NULL; - yygotominor.yy242.abstract = false; - yygotominor.yy242.supertypes = LIST_NULL; - } +{ + yygotominor.yy242.subtypes = EXPRESSION_NULL; + yygotominor.yy242.abstract = false; + yygotominor.yy242.supertypes = LIST_NULL; +} #line 4132 "expparse.c" - break; - case 272: /* subsuper_decl ::= supertype_decl */ + break; + case 272: /* subsuper_decl ::= supertype_decl */ #line 2106 "expparse.y" - { - yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; - yygotominor.yy242.supertypes = LIST_NULL; - } +{ + yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; + yygotominor.yy242.supertypes = LIST_NULL; +} #line 4141 "expparse.c" - break; - case 273: /* subsuper_decl ::= subtype_decl */ + break; + case 273: /* subsuper_decl ::= subtype_decl */ #line 2112 "expparse.y" - { - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; - yygotominor.yy242.abstract = false; - yygotominor.yy242.subtypes = EXPRESSION_NULL; - } +{ + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; + yygotominor.yy242.abstract = false; + yygotominor.yy242.subtypes = EXPRESSION_NULL; +} #line 4150 "expparse.c" - break; - case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ + break; + case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ #line 2118 "expparse.y" - { - yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; - } +{ + yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; +} #line 4159 "expparse.c" - break; - case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ + break; + case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ #line 2131 "expparse.y" - { - yygotominor.yy385.subtypes = (Expression)0; - yygotominor.yy385.abstract = true; - } +{ + yygotominor.yy385.subtypes = (Expression)0; + yygotominor.yy385.abstract = true; +} #line 4167 "expparse.c" - break; - case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2137 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = false; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = false; +} #line 4175 "expparse.c" - break; - case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2143 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = true; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = true; +} #line 4183 "expparse.c" - break; - case 279: /* supertype_expression ::= supertype_factor */ + break; + case 279: /* supertype_expression ::= supertype_factor */ #line 2149 "expparse.y" - { - yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; - } +{ + yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; +} #line 4190 "expparse.c" - break; - case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ + break; + case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ #line 2153 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); +} #line 4197 "expparse.c" - break; - case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ + break; + case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ #line 2158 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); +} #line 4204 "expparse.c" - break; - case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ + break; + case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ #line 2169 "expparse.y" - { - LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); - yygotominor.yy371 = yymsp[-2].minor.yy371; - } +{ + LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); + yygotominor.yy371 = yymsp[-2].minor.yy371; +} #line 4212 "expparse.c" - break; - case 284: /* supertype_factor ::= identifier */ + break; + case 284: /* supertype_factor ::= identifier */ #line 2175 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[0].minor.yy401; - } +{ + yygotominor.yy385.subtypes = yymsp[0].minor.yy401; +} #line 4219 "expparse.c" - break; - case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ + break; + case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ #line 2180 "expparse.y" - { - yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); - yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); + yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; +} #line 4227 "expparse.c" - break; - case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2185 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; +} #line 4234 "expparse.c" - break; - case 287: /* type ::= aggregation_type */ - case 288: /* type ::= basic_type */ - yytestcase(yyruleno == 288); - case 290: /* type ::= select_type */ - yytestcase(yyruleno == 290); + break; + case 287: /* type ::= aggregation_type */ + case 288: /* type ::= basic_type */ yytestcase(yyruleno==288); + case 290: /* type ::= select_type */ yytestcase(yyruleno==290); #line 2190 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = yymsp[0].minor.yy477; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = yymsp[0].minor.yy477; +} #line 4244 "expparse.c" - break; - case 292: /* type_item_body ::= type */ + break; + case 292: /* type_item_body ::= type */ #line 2215 "expparse.y" - { - CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; - CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; - } +{ + CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; + CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; +} #line 4252 "expparse.c" - break; - case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ + break; + case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ #line 2223 "expparse.y" - { - Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); - PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); - } +{ + Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); + PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); +} #line 4260 "expparse.c" - break; - case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ + break; + case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ #line 2234 "expparse.y" - { - CURRENT_SCOPE->where = yymsp[0].minor.yy371; - POP_SCOPE(); - yygotominor.yy0 = yymsp[-2].minor.yy0; - } +{ + CURRENT_SCOPE->where = yymsp[0].minor.yy371; + POP_SCOPE(); + yygotominor.yy0 = yymsp[-2].minor.yy0; +} #line 4269 "expparse.c" - break; - case 297: /* general_ref ::= assignable group_ref */ + break; + case 297: /* general_ref ::= assignable group_ref */ #line 2241 "expparse.y" - { - yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy401; - } +{ + yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy401; +} #line 4277 "expparse.c" - break; - case 307: /* unary_expression ::= TOK_NOT unary_expression */ + break; + case 307: /* unary_expression ::= TOK_NOT unary_expression */ #line 2284 "expparse.y" - { - yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); - } +{ + yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); +} #line 4284 "expparse.c" - break; - case 309: /* unary_expression ::= TOK_MINUS unary_expression */ + break; + case 309: /* unary_expression ::= TOK_MINUS unary_expression */ #line 2292 "expparse.y" - { - yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); - } +{ + yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); +} #line 4291 "expparse.c" - break; - case 310: /* unique ::= */ + break; + case 310: /* unique ::= */ #line 2297 "expparse.y" - { - yygotominor.yy252.unique = 0; - } +{ + yygotominor.yy252.unique = 0; +} #line 4298 "expparse.c" - break; - case 311: /* unique ::= TOK_UNIQUE */ + break; + case 311: /* unique ::= TOK_UNIQUE */ #line 2301 "expparse.y" - { - yygotominor.yy252.unique = 1; - } +{ + yygotominor.yy252.unique = 1; +} #line 4305 "expparse.c" - break; - case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ + break; + case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ #line 2328 "expparse.y" - { - LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4313 "expparse.c" - break; - case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ + break; + case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ #line 2334 "expparse.y" - { - LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4321 "expparse.c" - break; - case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ + break; + case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ #line 2341 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); +} #line 4329 "expparse.c" - break; - case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ + break; + case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ #line 2347 "expparse.y" - { - LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4337 "expparse.c" - break; - case 321: /* until_control ::= */ - case 330: /* while_control ::= */ - yytestcase(yyruleno == 330); + break; + case 321: /* until_control ::= */ + case 330: /* while_control ::= */ yytestcase(yyruleno==330); #line 2362 "expparse.y" - { - yygotominor.yy401 = 0; - } +{ + yygotominor.yy401 = 0; +} #line 4345 "expparse.c" - break; - case 323: /* where_clause ::= expression semicolon */ + break; + case 323: /* where_clause ::= expression semicolon */ #line 2371 "expparse.y" - { - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); - yygotominor.yy234->expr = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); + yygotominor.yy234->expr = yymsp[-1].minor.yy401; +} #line 4354 "expparse.c" - break; - case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ + break; + case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ #line 2377 "expparse.y" - { - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; - yygotominor.yy234->expr = yymsp[-1].minor.yy401; - - if(!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, - yymsp[-3].minor.yy0.symbol, OBJ_WHERE); - } +{ + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; + yygotominor.yy234->expr = yymsp[-1].minor.yy401; + + if (!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, + yymsp[-3].minor.yy0.symbol, OBJ_WHERE); +} #line 4370 "expparse.c" - break; - case 325: /* where_clause_list ::= where_clause */ + break; + case 325: /* where_clause_list ::= where_clause */ #line 2391 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); +} #line 4378 "expparse.c" - break; - case 326: /* where_clause_list ::= where_clause_list where_clause */ + break; + case 326: /* where_clause_list ::= where_clause_list where_clause */ #line 2396 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); +} #line 4386 "expparse.c" - break; - default: - /* (4) action_body_item_rep ::= */ - yytestcase(yyruleno == 4); - /* (41) block_list ::= */ yytestcase(yyruleno == 41); - /* (62) constant_body_list ::= */ yytestcase(yyruleno == 62); - /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno == 86); - /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno == 159); - /* (168) interface_specification_list ::= */ yytestcase(yyruleno == 168); - /* (194) local_body ::= */ yytestcase(yyruleno == 194); - /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno == 196); - /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno == 293); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto); - if(yyact < YYNSTATE) { + break; + default: + /* (4) action_body_item_rep ::= */ yytestcase(yyruleno==4); + /* (41) block_list ::= */ yytestcase(yyruleno==41); + /* (62) constant_body_list ::= */ yytestcase(yyruleno==62); + /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno==86); + /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==159); + /* (168) interface_specification_list ::= */ yytestcase(yyruleno==168); + /* (194) local_body ::= */ yytestcase(yyruleno==194); + /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno==196); + /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno==293); + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser->yyidx -= yysize; + yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); + if( yyact < YYNSTATE ){ #ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if(yysize) { - yypParser->yyidx++; - yymsp -= yysize - 1; - yymsp->stateno = (YYACTIONTYPE)yyact; - yymsp->major = (YYCODETYPE)yygoto; - yymsp->minor = yygotominor; - } else + /* If we are not debugging and the reduce action popped at least + ** one element off the stack, then we can push the new element back + ** onto the stack here, and skip the stack overflow test in yy_shift(). + ** That gives a significant speed improvement. */ + if( yysize ){ + yypParser->yyidx++; + yymsp -= yysize-1; + yymsp->stateno = (YYACTIONTYPE)yyact; + yymsp->major = (YYCODETYPE)yygoto; + yymsp->minor = yygotominor; + }else #endif - { - yy_shift(yypParser, yyact, yygoto, &yygotominor); - } - } else { - assert(yyact == YYNSTATE + YYNRULE + 1); - yy_accept(yypParser); + { + yy_shift(yypParser,yyact,yygoto,&yygotominor); } + }else{ + assert( yyact == YYNSTATE + YYNRULE + 1 ); + yy_accept(yypParser); + } } /* @@ -4556,21 +4428,18 @@ static void yy_reduce( */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( - yyParser *yypParser /* The parser */ -) -{ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +){ + ParseARG_FETCH; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will be executed whenever the - ** parser fails */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -4578,12 +4447,11 @@ static void yy_parse_failed( ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -) -{ - ParseARG_FETCH; + yyParser *yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ +){ + ParseARG_FETCH; #define TOKEN (yyminor.yy0) #line 2424 "expparse.y" @@ -4597,30 +4465,27 @@ static void yy_syntax_error( sym.filename = current_filename; ERRORreport_with_symbol(SYNTAX, &sym, "Syntax error", - CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); + CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); #line 4470 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( - yyParser *yypParser /* The parser */ -) -{ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +){ + ParseARG_FETCH; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -4643,153 +4508,152 @@ static void yy_accept( ** None. */ void Parse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - ParseTOKENTYPE yyminor /* The value for the token */ - ParseARG_PDECL /* Optional %extra_argument parameter */ -) -{ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ + void *yyp, /* The parser */ + int yymajor, /* The major token code number */ + ParseTOKENTYPE yyminor /* The value for the token */ + ParseARG_PDECL /* Optional %extra_argument parameter */ +){ + YYMINORTYPE yyminorunion; + int yyact; /* The parser action. */ + int yyendofinput; /* True if we are at the end of input */ #ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ + int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser; /* The parser */ + yyParser *yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser *)yyp; - if(yypParser->yyidx < 0) { + /* (re)initialize the parser, if necessary */ + yypParser = (yyParser*)yyp; + if( yypParser->yyidx<0 ){ #if YYSTACKDEPTH<=0 - if(yypParser->yystksz <= 0) { - /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ - yyminorunion = yyzerominor; - yyStackOverflow(yypParser, &yyminorunion); - return; - } -#endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + if( yypParser->yystksz <=0 ){ + /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ + yyminorunion = yyzerominor; + yyStackOverflow(yypParser, &yyminorunion); + return; } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor == 0); - ParseARG_STORE; +#endif + yypParser->yyidx = 0; + yypParser->yyerrcnt = -1; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor; + yyendofinput = (yymajor==0); + ParseARG_STORE; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); + } #endif - do { - yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor); - if(yyact < YYNSTATE) { - assert(!yyendofinput); /* Impossible to shift the $ token */ - yy_shift(yypParser, yyact, yymajor, &yyminorunion); - yypParser->yyerrcnt--; - yymajor = YYNOCODE; - } else if(yyact < YYNSTATE + YYNRULE) { - yy_reduce(yypParser, yyact - YYNSTATE); - } else { - assert(yyact == YY_ERROR_ACTION); + do{ + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); + if( yyactyyerrcnt--; + yymajor = YYNOCODE; + }else if( yyact < YYNSTATE + YYNRULE ){ + yy_reduce(yypParser,yyact-YYNSTATE); + }else{ + assert( yyact == YY_ERROR_ACTION ); #ifdef YYERRORSYMBOL - int yymx; + int yymx; #endif #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); + } #endif #ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if(yypParser->yyerrcnt < 0) { - yy_syntax_error(yypParser, yymajor, yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if(yymx == YYERRORSYMBOL || yyerrorhit) { + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( yypParser->yyerrcnt<0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yymx = yypParser->yystack[yypParser->yyidx].major; + if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sDiscard input token %s\n", - yyTracePrompt, yyTokenName[yymajor]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sDiscard input token %s\n", + yyTracePrompt,yyTokenName[yymajor]); + } #endif - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yymajor = YYNOCODE; - } else { - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ) { - yy_pop_parser_stack(yypParser); - } - if(yypParser->yyidx < 0 || yymajor == 0) { - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - } else if(yymx != YYERRORSYMBOL) { - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser, yyact, YYERRORSYMBOL, &u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; + yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); + yymajor = YYNOCODE; + }else{ + while( + yypParser->yyidx >= 0 && + yymx != YYERRORSYMBOL && + (yyact = yy_find_reduce_action( + yypParser->yystack[yypParser->yyidx].stateno, + YYERRORSYMBOL)) >= YYNSTATE + ){ + yy_pop_parser_stack(yypParser); + } + if( yypParser->yyidx < 0 || yymajor==0 ){ + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + yy_parse_failed(yypParser); + yymajor = YYNOCODE; + }else if( yymx!=YYERRORSYMBOL ){ + YYMINORTYPE u2; + u2.YYERRSYMDT = 0; + yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); + } + } + yypParser->yyerrcnt = 3; + yyerrorhit = 1; #elif defined(YYNOERRORRECOVERY) - /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to - ** do any kind of error recovery. Instead, simply invoke the syntax - ** error routine and continue going as if nothing had happened. - ** - ** Applications can set this macro (for example inside %include) if - ** they intend to abandon the parse upon the first syntax error seen. - */ - yy_syntax_error(yypParser, yymajor, yyminorunion); - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yymajor = YYNOCODE; - + /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + yy_syntax_error(yypParser,yymajor,yyminorunion); + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if(yypParser->yyerrcnt <= 0) { - yy_syntax_error(yypParser, yymajor, yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - if(yyendofinput) { - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( yypParser->yyerrcnt<=0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yypParser->yyerrcnt = 3; + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + if( yyendofinput ){ + yy_parse_failed(yypParser); + } + yymajor = YYNOCODE; #endif - } - } while(yymajor != YYNOCODE && yypParser->yyidx >= 0); - return; + } + }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); + return; } diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index 1c5727001..b78b863a5 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -106,47 +106,42 @@ #include "expparse.h" #include "expscan.h" enum { INITIAL, code, comment, return_end_schema }; -extern int yylineno; -extern bool yyeof; -static int nesting_level = 0; +extern int yylineno; +extern bool yyeof; +static int nesting_level = 0; /* can't imagine this will ever be more than 2 or 3 - DEL */ #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; -/* isascii isn't part of newer C standards */ -#ifndef isascii -# define isascii(c) ((unsigned)((c) + 1) < 129) -#endif static_inline int -SCANnextchar(char *buffer) +SCANnextchar(char* buffer) { - extern bool SCANread(void); +extern bool SCANread(void); #ifdef keep_nul - static int escaped = 0; +static int escaped = 0; #endif - if(SCANtext_ready || SCANread()) { +if (SCANtext_ready || SCANread()) { #ifdef keep_nul - if(!*SCANcurrent) { - buffer[0] = SCAN_ESCAPE; - *SCANcurrent = '0'; - return 1; - } else if((*SCANcurrent == SCAN_ESCAPE) && !escaped) { - escaped = 1; - buffer[0] = SCAN_ESCAPE; - return 1; - } - SCANbuffer.numRead--; +if (!*SCANcurrent) { +buffer[0] = SCAN_ESCAPE; +*SCANcurrent = '0'; +return 1; +} else if ((*SCANcurrent == SCAN_ESCAPE) && !escaped) { +escaped = 1; +buffer[0] = SCAN_ESCAPE; +return 1; +} +SCANbuffer.numRead--; #endif - buffer[0] = *(SCANcurrent++); - if(!isascii(buffer[0])) { - ERRORreport_with_line(NONASCII_CHAR, yylineno, - 0xff & buffer[0]); - buffer[0] = ' '; /* substitute space */ - } - return 1; - } else { - return 0; - } +buffer[0] = *(SCANcurrent++); +if (!isascii(buffer[0])) { +ERRORreport_with_line(NONASCII_CHAR,yylineno, +0xff & buffer[0]); +buffer[0] = ' '; /* substitute space */ +} +return 1; +} else +return 0; } #define NEWLINE (yylineno++) /* when lex looks ahead over a newline, error messages get thrown off */ @@ -154,15 +149,14 @@ SCANnextchar(char *buffer) #define LINENO_FUDGE (yylineno - 1) /* added for re-initializing parser -snc 22-Apr-1992 */ void -SCAN_lex_init(char *filename, FILE *fp) -{ - /* return to initial scan buffer */ - SCAN_current_buffer = 0; - *(SCANcurrent = SCANbuffer.text) = '\0'; - SCANbuffer.readEof = false; - SCANbuffer.file = fp; - SCANbuffer.filename = (filename ? filename : ""); - current_filename = SCANbuffer.filename; +SCAN_lex_init(char *filename, FILE *fp) { +/* return to initial scan buffer */ +SCAN_current_buffer = 0; +*(SCANcurrent = SCANbuffer.text) = '\0'; +SCANbuffer.readEof = false; +SCANbuffer.file = fp; +SCANbuffer.filename = (filename ? filename : ""); +current_filename = SCANbuffer.filename; } #define PERPLEX_USING_CONDITIONS @@ -218,27 +212,27 @@ SCAN_lex_init(char *filename, FILE *fp) #include /* --- from flex's flexdef.h --- */ -void buf_init(struct Buf *buf, size_t elem_size); -void buf_destroy(struct Buf *buf); -struct Buf *buf_append(struct Buf *buf, const void *ptr, int n_elem); -struct Buf *buf_concat(struct Buf *dest, const struct Buf *src); +void buf_init(struct Buf * buf, size_t elem_size); +void buf_destroy(struct Buf * buf); +struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem); +struct Buf *buf_concat(struct Buf* dest, const struct Buf* src); struct Buf *buf_strappend(struct Buf *, const char *str); struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); -struct Buf *buf_strdefine(struct Buf *buf, const char *str, const char *def); -struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char *s); -struct Buf *buf_m4_define(struct Buf *buf, const char *def, const char *val); -struct Buf *buf_m4_undefine(struct Buf *buf, const char *def); -struct Buf *buf_print_strings(struct Buf *buf, FILE *out); -struct Buf *buf_linedir(struct Buf *buf, const char *filename, int lineno); +struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def); +struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); +struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val); +struct Buf *buf_m4_undefine(struct Buf *buf, const char* def); +struct Buf *buf_print_strings(struct Buf * buf, FILE* out); +struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno); /* --- from flex's misc.c --- */ -static void * +static void* allocate_array(int size, size_t element_size) { return malloc(element_size * size); } -static void * +static void* reallocate_array(void *array, int size, size_t element_size) { return realloc(array, element_size * size); @@ -248,17 +242,17 @@ reallocate_array(void *array, int size, size_t element_size) /* Take note: The buffer object is sometimes used as a String buffer (one * continuous string), and sometimes used as a list of strings, usually line by * line. - * + * * The type is specified in buf_init by the elt_size. If the elt_size is * sizeof(char), then the buffer should be treated as string buffer. If the * elt_size is sizeof(char*), then the buffer should be treated as a list of * strings. * - * Certain functions are only appropriate for one type or the other. + * Certain functions are only appropriate for one type or the other. */ -struct Buf * -buf_print_strings(struct Buf *buf, FILE *out) +struct Buf* +buf_print_strings(struct Buf * buf, FILE* out) { int i; @@ -266,22 +260,22 @@ buf_print_strings(struct Buf *buf, FILE *out) return buf; } - for(i = 0; i < buf->nelts; i++) { - const char *s = ((char **)buf->elts)[i]; + for (i = 0; i < buf->nelts; i++) { + const char *s = ((char**)buf->elts)[i]; if(s) { fprintf(out, "%s", s); - } + } } return buf; } /* Append a "%s" formatted string to a string buffer */ -struct Buf * +struct Buf* buf_prints(struct Buf *buf, const char *fmt, const char *s) { char *t; - t = (char *)malloc(strlen(fmt) + strlen(s) + 1); + t = (char*)malloc(strlen(fmt) + strlen(s) + 1); sprintf(t, fmt, s); buf = buf_strappend(buf, t); free(t); @@ -295,12 +289,12 @@ int numDigits(int n) /* take absolute value of n */ n = n >= 0 ? n : -n; - if(n == 0) { - return 1; + if (n == 0) { + return 1; } - for(digits = 0; n > 0; digits++) { - n /= 10; + for (digits = 0; n > 0; digits++) { + n /= 10; } return digits; @@ -312,13 +306,13 @@ int numDigits(int n) * @param lineno line number * @return buf */ -struct Buf * -buf_linedir(struct Buf *buf, const char *filename, int lineno) +struct Buf* +buf_linedir(struct Buf *buf, const char* filename, int lineno) { char *t; const char fmt[] = "#line %d \"%s\"\n"; - - t = (char *)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); + + t = (char*)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); sprintf(t, fmt, lineno, filename); buf = buf_strappend(buf, t); free(t); @@ -331,8 +325,8 @@ buf_linedir(struct Buf *buf, const char *filename, int lineno) * @param @a dest the source buffer * @return @a dest */ -struct Buf * -buf_concat(struct Buf *dest, const struct Buf *src) +struct Buf* +buf_concat(struct Buf* dest, const struct Buf* src) { buf_append(dest, src->elts, src->nelts); return dest; @@ -340,7 +334,7 @@ buf_concat(struct Buf *dest, const struct Buf *src) /* Appends n characters in str to buf. */ -struct Buf * +struct Buf* buf_strnappend(struct Buf *buf, const char *str, int n) { buf_append(buf, str, n + 1); @@ -352,14 +346,14 @@ buf_strnappend(struct Buf *buf, const char *str, int n) } /* Appends characters in str to buf. */ -struct Buf * +struct Buf* buf_strappend(struct Buf *buf, const char *str) { return buf_strnappend(buf, str, strlen(str)); } /* appends "#define str def\n" */ -struct Buf * +struct Buf* buf_strdefine(struct Buf *buf, const char *str, const char *def) { buf_strappend(buf, "#define "); @@ -377,14 +371,14 @@ buf_strdefine(struct Buf *buf, const char *str, const char *def) * @param val The definition; may be NULL. * @return buf */ -struct Buf * -buf_m4_define(struct Buf *buf, const char *def, const char *val) +struct Buf* +buf_m4_define(struct Buf *buf, const char* def, const char* val) { const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n"; char *str; val = val ? val : ""; - str = (char *)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); + str = (char*)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); sprintf(str, fmt, def, val); buf_append(buf, &str, 1); @@ -396,13 +390,13 @@ buf_m4_define(struct Buf *buf, const char *def, const char *val) * @param def The m4 symbol to undefine. * @return buf */ -struct Buf * -buf_m4_undefine(struct Buf *buf, const char *def) +struct Buf* +buf_m4_undefine(struct Buf *buf, const char* def) { const char *fmt = "m4_undefine( [[%s]])m4_dnl\n"; char *str; - str = (char *)malloc(strlen(fmt) + strlen(def) + 2); + str = (char*)malloc(strlen(fmt) + strlen(def) + 2); sprintf(str, fmt, def); buf_append(buf, &str, 1); @@ -413,7 +407,7 @@ buf_m4_undefine(struct Buf *buf, const char *def) void buf_init(struct Buf *buf, size_t elem_size) { - buf->elts = (void *)0; + buf->elts = (void*)0; buf->nelts = 0; buf->elt_size = elem_size; buf->nmax = 0; @@ -423,12 +417,11 @@ buf_init(struct Buf *buf, size_t elem_size) void buf_destroy(struct Buf *buf) { - if(buf && buf->elts) { - free(buf->elts); - } - if(buf) { - buf->elts = (void *)0; + if (buf && buf->elts) { + free(buf->elts); } + if (buf) + buf->elts = (void*)0; } /* appends ptr[] to buf, grow if necessary. @@ -436,33 +429,33 @@ buf_destroy(struct Buf *buf) * returns buf. * We grow by mod(512) boundaries. */ -struct Buf * +struct Buf* buf_append(struct Buf *buf, const void *ptr, int n_elem) { int n_alloc = 0; - if(!ptr || n_elem == 0) { - return buf; + if (!ptr || n_elem == 0) { + return buf; } /* May need to alloc more. */ - if(n_elem + buf->nelts > buf->nmax) { - /* exact amount needed... */ - n_alloc = (n_elem + buf->nelts) * buf->elt_size; - - /* ...plus some extra */ - if(((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { - n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; - } - if(!buf->elts) { - buf->elts = allocate_array(n_alloc, buf->elt_size); - } else { - buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); - } - buf->nmax = n_alloc; + if (n_elem + buf->nelts > buf->nmax) { + /* exact amount needed... */ + n_alloc = (n_elem + buf->nelts) * buf->elt_size; + + /* ...plus some extra */ + if (((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { + n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; + } + if (!buf->elts) { + buf->elts = allocate_array(n_alloc, buf->elt_size); + } else { + buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); + } + buf->nmax = n_alloc; } - memcpy((char *)buf->elts + buf->nelts * buf->elt_size, ptr, - n_elem * buf->elt_size); + memcpy((char*)buf->elts + buf->nelts * buf->elt_size, ptr, + n_elem * buf->elt_size); buf->nelts += n_elem; @@ -475,18 +468,18 @@ buf_append(struct Buf *buf, const void *ptr, int n_elem) */ /* get pointer to the start of the first element */ -static char * +static char* bufferFirstElt(struct Buf *buf) { - return (char *)buf->elts; + return (char*)buf->elts; } /* get pointer to the start of the last element */ -static char * +static char* bufferLastElt(struct Buf *buf) { - if(buf->nelts < 1) { - return NULL; + if (buf->nelts < 1) { + return NULL; } return bufferFirstElt(buf) + buf->nelts - 1; } @@ -515,7 +508,7 @@ bufferAppend(perplex_t scanner, size_t n) in = scanner->inFile; /* save marker offsets */ - bufStart = (char *)buf->elts; + bufStart = (char*)buf->elts; cursorOffset = (size_t)(scanner->cursor - bufStart); markerOffset = (size_t)(scanner->marker - bufStart); tokenStartOffset = (size_t)(scanner->tokenStart - bufStart); @@ -523,12 +516,12 @@ bufferAppend(perplex_t scanner, size_t n) /* remove last (null) element */ buf->nelts--; - for(i = 0; i < n; i++) { - if((c = fgetc(in)) == EOF) { - scanner->atEOI = 1; - break; - } - bufferAppendChar(buf, c); + for (i = 0; i < n; i++) { + if ((c = fgetc(in)) == EOF) { + scanner->atEOI = 1; + break; + } + bufferAppendChar(buf, c); } /* (scanner->null - eltSize) should be the last input element, @@ -538,7 +531,7 @@ bufferAppend(perplex_t scanner, size_t n) scanner->null = bufferLastElt(buf); /* update markers in case append caused buffer to be reallocated */ - bufStart = (char *)buf->elts; + bufStart = (char*)buf->elts; scanner->cursor = bufStart + cursorOffset; scanner->marker = bufStart + markerOffset; scanner->tokenStart = bufStart + tokenStartOffset; @@ -551,9 +544,9 @@ bufferFill(perplex_t scanner, size_t n) struct Buf *buf; size_t totalElts, usedElts, freeElts; - if(scanner->atEOI) { - /* nothing to add to buffer */ - return; + if (scanner->atEOI) { + /* nothing to add to buffer */ + return; } buf = scanner->buffer; @@ -563,53 +556,53 @@ bufferFill(perplex_t scanner, size_t n) freeElts = totalElts - usedElts; /* not enough room for append, shift buffer contents to avoid realloc */ - if(n > freeElts) { - void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; - size_t bytesInUse, shiftSize; + if (n > freeElts) { + void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; + size_t bytesInUse, shiftSize; - tokenStart = (void *)scanner->tokenStart; - marker = (void *)scanner->marker; - null = (void *)scanner->null; + tokenStart = (void*)scanner->tokenStart; + marker = (void*)scanner->marker; + null = (void*)scanner->null; - bufFirst = bufferFirstElt(buf); + bufFirst = bufferFirstElt(buf); - /* Find first buffer element still in use by scanner. Will be - * tokenStart unless backtracking marker is in use. - */ - scannerFirst = tokenStart; - if(marker >= bufFirst && marker < tokenStart) { - scannerFirst = marker; - } + /* Find first buffer element still in use by scanner. Will be + * tokenStart unless backtracking marker is in use. + */ + scannerFirst = tokenStart; + if (marker >= bufFirst && marker < tokenStart) { + scannerFirst = marker; + } - /* bytes of input being used by scanner */ - bytesInUse = (size_t)null - (size_t)scannerFirst + 1; + /* bytes of input being used by scanner */ + bytesInUse = (size_t)null - (size_t)scannerFirst + 1; - /* copy in-use elements to start of buffer */ - memmove(bufFirst, scannerFirst, bytesInUse); + /* copy in-use elements to start of buffer */ + memmove(bufFirst, scannerFirst, bytesInUse); - /* update number of elements */ + /* update number of elements */ buf->nelts = bytesInUse / buf->elt_size; - /* update markers */ - shiftSize = (size_t)scannerFirst - (size_t)bufFirst; - scanner->marker -= shiftSize; - scanner->cursor -= shiftSize; - scanner->null -= shiftSize; - scanner->tokenStart -= shiftSize; + /* update markers */ + shiftSize = (size_t)scannerFirst - (size_t)bufFirst; + scanner->marker -= shiftSize; + scanner->cursor -= shiftSize; + scanner->null -= shiftSize; + scanner->tokenStart -= shiftSize; } bufferAppend(scanner, n); } -static char * +static char* getTokenText(perplex_t scanner) { int tokenChars = scanner->cursor - scanner->tokenStart; - if(scanner->tokenText != NULL) { - free(scanner->tokenText); + if (scanner->tokenText != NULL) { + free(scanner->tokenText); } - scanner->tokenText = (char *)malloc(sizeof(char) * (tokenChars + 1)); + scanner->tokenText = (char*)malloc(sizeof(char) * (tokenChars + 1)); memcpy(scanner->tokenText, scanner->tokenStart, tokenChars); scanner->tokenText[tokenChars] = '\0'; @@ -635,7 +628,7 @@ newScanner() static void initBuffer(perplex_t scanner) { - scanner->buffer = (struct Buf *)malloc(sizeof(struct Buf)); + scanner->buffer = (struct Buf*)malloc(sizeof(struct Buf)); buf_init(scanner->buffer, sizeof(char)); } @@ -654,8 +647,8 @@ perplexStringScanner(char *firstChar, size_t numChars) buf = scanner->buffer; /* copy string to buffer */ - for(i = 0; i < numChars; i++) { - bufferAppendChar(buf, firstChar[i]); + for (i = 0; i < numChars; i++) { + bufferAppendChar(buf, firstChar[i]); } bufferAppendChar(buf, '\0'); @@ -686,9 +679,9 @@ perplexFileScanner(FILE *input) void perplexFree(perplex_t scanner) { - if(scanner->buffer != NULL) { - buf_destroy(scanner->buffer); - free(scanner->buffer); + if (scanner->buffer != NULL) { + buf_destroy(scanner->buffer); + free(scanner->buffer); } free(scanner); @@ -700,7 +693,7 @@ perplexSetExtra(perplex_t scanner, void *extra) scanner->extra = extra; } -void * +void* perplexGetExtra(perplex_t scanner) { return scanner->extra; @@ -738,8 +731,8 @@ perplexUnput(perplex_t scanner, char c) /* input from cursor to null is shifted to the right */ cursor = scanner->cursor; - for(curr = scanner->null; curr != cursor; curr--) { - curr[0] = curr[-1]; + for (curr = scanner->null; curr != cursor; curr--) { + curr[0] = curr[-1]; } /* insert c */ @@ -781,10 +774,9 @@ PERPLEX_PUBLIC_LEXER { ret = PERPLEX_LEXER_private(scanner); - if(scanner->tokenText != NULL) - { - free(scanner->tokenText); - scanner->tokenText = NULL; + if (scanner->tokenText != NULL) { + free(scanner->tokenText); + scanner->tokenText = NULL; } return ret; @@ -796,1109 +788,921 @@ PERPLEX_PRIVATE_LEXER { PERPLEX_ON_ENTER; - while(1) - { - if(scanner->atEOI && scanner->cursor >= scanner->null) { - return YYEOF; - } - - { - unsigned int yyaccept = 0; - switch(YYGETCONDITION) { - case 0: - goto yyc_0; - case code: - goto yyc_code; - case comment: - goto yyc_comment; - case return_end_schema: - goto yyc_return_end_schema; - } - /* *********************************** */ + while (1) { + if (scanner->atEOI && scanner->cursor >= scanner->null) { + return YYEOF; + } + + { + unsigned int yyaccept = 0; + switch (YYGETCONDITION) { + case 0: goto yyc_0; + case code: goto yyc_code; + case comment: goto yyc_comment; + case return_end_schema: goto yyc_return_end_schema; + } +/* *********************************** */ yyc_0: - YYSETCONDITION(code); - { - } - /* *********************************** */ + YYSETCONDITION(code); + { +} +/* *********************************** */ yyc_code: - if((scanner->null - scanner->cursor) < 4) { - YYFILL(4); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy8; - case '\n': - goto yy9; - case '"': - goto yy11; - case '$': - case '&': - case '@': - case '^': - case '~': - goto yy12; - case '%': - goto yy14; - case '\'': - goto yy15; - case '(': - goto yy16; - case ')': - goto yy18; - case '*': - goto yy20; - case '+': - goto yy22; - case ',': - goto yy24; - case '-': - goto yy26; - case '.': - goto yy28; - case '/': - goto yy30; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy32; - case ':': - goto yy34; - case ';': - goto yy36; - case '<': - goto yy38; - case '=': - goto yy40; - case '>': - goto yy42; - case '?': - goto yy44; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy46; - case '[': - goto yy48; - case '\\': - goto yy50; - case ']': - goto yy52; - case '_': - goto yy54; - case '{': - goto yy56; - case '|': - goto yy58; - case '}': - goto yy60; - default: - goto yy6; - } -yy5: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 4) YYFILL(4); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy8; + case '\n': goto yy9; + case '"': goto yy11; + case '$': + case '&': + case '@': + case '^': + case '~': goto yy12; + case '%': goto yy14; + case '\'': goto yy15; + case '(': goto yy16; + case ')': goto yy18; + case '*': goto yy20; + case '+': goto yy22; + case ',': goto yy24; + case '-': goto yy26; + case '.': goto yy28; + case '/': goto yy30; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy32; + case ':': goto yy34; + case ';': goto yy36; + case '<': goto yy38; + case '=': goto yy40; + case '>': goto yy42; + case '?': goto yy44; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy46; + case '[': goto yy48; + case '\\': goto yy50; + case ']': goto yy52; + case '_': goto yy54; + case '{': goto yy56; + case '|': goto yy58; + case '}': goto yy60; + default: goto yy6; + } +yy5: + { +IGNORE_TOKEN; } yy6: - ++scanner->cursor; -yy7: { - IGNORE_TOKEN; - } + ++scanner->cursor; +yy7: + { +IGNORE_TOKEN; } yy8: - yych = *++scanner->cursor; - goto yy127; + yych = *++scanner->cursor; + goto yy127; yy9: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy11: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy121; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy121; yy12: - ++scanner->cursor; -yy13: { - ERRORreport_with_line(UNEXPECTED_CHARACTER, yylineno, yytext[0]); - IGNORE_TOKEN; - } + ++scanner->cursor; +yy13: + { +ERRORreport_with_line(UNEXPECTED_CHARACTER,yylineno,yytext[0]); +IGNORE_TOKEN; +} yy14: - yych = *++scanner->cursor; - switch(yych) { - case '0': - case '1': - goto yy117; - default: - goto yy13; - } + yych = *++scanner->cursor; + switch (yych) { + case '0': + case '1': goto yy117; + default: goto yy13; + } yy15: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy112; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy112; yy16: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy109; - default: - goto yy17; - } -yy17: { - return TOK_LEFT_PAREN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy109; + default: goto yy17; + } +yy17: + { +return TOK_LEFT_PAREN; } yy18: - ++scanner->cursor; - { - return TOK_RIGHT_PAREN; - } + ++scanner->cursor; + { +return TOK_RIGHT_PAREN; } yy20: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case ')': - goto yy105; - case '*': - goto yy107; - default: - goto yy21; - } -yy21: { - return TOK_TIMES; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case ')': goto yy105; + case '*': goto yy107; + default: goto yy21; + } +yy21: + { +return TOK_TIMES; } yy22: - ++scanner->cursor; - { - return TOK_PLUS; - } + ++scanner->cursor; + { +return TOK_PLUS; } yy24: - ++scanner->cursor; - { - return TOK_COMMA; - } + ++scanner->cursor; + { +return TOK_COMMA; } yy26: - yyaccept = 1; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '-': - goto yy101; - default: - goto yy27; - } -yy27: { - return TOK_MINUS; - } + yyaccept = 1; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '-': goto yy101; + default: goto yy27; + } +yy27: + { +return TOK_MINUS; } yy28: - ++scanner->cursor; - { - return TOK_DOT; - } + ++scanner->cursor; + { +return TOK_DOT; } yy30: - ++scanner->cursor; - { - return TOK_REAL_DIV; - } + ++scanner->cursor; + { +return TOK_REAL_DIV; } yy32: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '.': - goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy92; - default: - goto yy33; - } -yy33: { - return SCANprocess_integer_literal(yytext); - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '.': goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy92; + default: goto yy33; + } +yy33: + { +return SCANprocess_integer_literal(yytext); +} yy34: - yyaccept = 2; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '<': - goto yy84; - case '=': - goto yy85; - default: - goto yy35; - } -yy35: { - return TOK_COLON; - } + yyaccept = 2; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '<': goto yy84; + case '=': goto yy85; + default: goto yy35; + } +yy35: + { +return TOK_COLON; } yy36: - yyaccept = 3; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '\t': - case ' ': - goto yy76; - case '-': - goto yy79; - default: - goto yy37; - } -yy37: { - return SCANprocess_semicolon(yytext, 0); - } + yyaccept = 3; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '\t': + case ' ': goto yy76; + case '-': goto yy79; + default: goto yy37; + } +yy37: + { +return SCANprocess_semicolon(yytext, 0); } yy38: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy74; - case '=': - goto yy72; - case '>': - goto yy70; - default: - goto yy39; - } -yy39: { - return TOK_LESS_THAN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy74; + case '=': goto yy72; + case '>': goto yy70; + default: goto yy39; + } +yy39: + { +return TOK_LESS_THAN; } yy40: - ++scanner->cursor; - { - return TOK_EQUAL; - } + ++scanner->cursor; + { +return TOK_EQUAL; } yy42: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '=': - goto yy68; - default: - goto yy43; - } -yy43: { - return TOK_GREATER_THAN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '=': goto yy68; + default: goto yy43; + } +yy43: + { +return TOK_GREATER_THAN; } yy44: - ++scanner->cursor; - { - return TOK_QUESTION_MARK; - } + ++scanner->cursor; + { +return TOK_QUESTION_MARK; } yy46: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy67; -yy47: { - return SCANprocess_identifier_or_keyword(yytext); - } + ++scanner->cursor; + yych = *scanner->cursor; + goto yy67; +yy47: + { +return SCANprocess_identifier_or_keyword(yytext); +} yy48: - ++scanner->cursor; - { - return TOK_LEFT_BRACKET; - } + ++scanner->cursor; + { +return TOK_LEFT_BRACKET; } yy50: - ++scanner->cursor; - { - return TOK_BACKSLASH; - } + ++scanner->cursor; + { +return TOK_BACKSLASH; } yy52: - ++scanner->cursor; - { - return TOK_RIGHT_BRACKET; - } + ++scanner->cursor; + { +return TOK_RIGHT_BRACKET; } yy54: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy65; -yy55: { - ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); - return SCANprocess_identifier_or_keyword(yytext); - } + ++scanner->cursor; + yych = *scanner->cursor; + goto yy65; +yy55: + { +ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); +return SCANprocess_identifier_or_keyword(yytext); +} yy56: - ++scanner->cursor; - { - return TOK_LEFT_CURL; - } + ++scanner->cursor; + { +return TOK_LEFT_CURL; } yy58: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '|': - goto yy62; - default: - goto yy59; - } -yy59: { - return TOK_SUCH_THAT; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '|': goto yy62; + default: goto yy59; + } +yy59: + { +return TOK_SUCH_THAT; } yy60: - ++scanner->cursor; - { - return TOK_RIGHT_CURL; - } + ++scanner->cursor; + { +return TOK_RIGHT_CURL; } yy62: - ++scanner->cursor; - { - return TOK_CONCAT_OP; - } + ++scanner->cursor; + { +return TOK_CONCAT_OP; } yy64: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy65: - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy64; - default: - goto yy55; - } + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy64; + default: goto yy55; + } yy66: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy67: - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy66; - default: - goto yy47; - } + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy66; + default: goto yy47; + } yy68: - ++scanner->cursor; - { - return TOK_GREATER_EQUAL; - } + ++scanner->cursor; + { +return TOK_GREATER_EQUAL; } yy70: - ++scanner->cursor; - { - return TOK_NOT_EQUAL; - } + ++scanner->cursor; + { +return TOK_NOT_EQUAL; } yy72: - ++scanner->cursor; - { - return TOK_LESS_EQUAL; - } + ++scanner->cursor; + { +return TOK_LESS_EQUAL; } yy74: - ++scanner->cursor; - { - return TOK_ALL_IN; - } + ++scanner->cursor; + { +return TOK_ALL_IN; } yy76: - ++scanner->cursor; - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy76; - case '-': - goto yy79; - default: - goto yy78; - } + ++scanner->cursor; + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy76; + case '-': goto yy79; + default: goto yy78; + } yy78: - scanner->cursor = scanner->marker; - switch(yyaccept) { - case 0: - goto yy7; - case 1: - goto yy27; - case 2: - goto yy35; - case 3: - goto yy37; - case 4: - goto yy96; - case 5: - goto yy114; - } + scanner->cursor = scanner->marker; + switch (yyaccept) { + case 0: goto yy7; + case 1: goto yy27; + case 2: goto yy35; + case 3: goto yy37; + case 4: goto yy96; + case 5: goto yy114; + } yy79: - yych = *++scanner->cursor; - switch(yych) { - case '-': - goto yy80; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '-': goto yy80; + default: goto yy78; + } yy80: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\n': - goto yy82; - default: - goto yy80; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\n': goto yy82; + default: goto yy80; + } yy82: - ++scanner->cursor; - { - NEWLINE; - return SCANprocess_semicolon(yytext, 1); - } + ++scanner->cursor; + { +NEWLINE; +return SCANprocess_semicolon(yytext, 1); +} yy84: - yych = *++scanner->cursor; - switch(yych) { - case '>': - goto yy89; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '>': goto yy89; + default: goto yy78; + } yy85: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case ':': - goto yy87; - default: - goto yy86; - } -yy86: { - return TOK_ASSIGNMENT; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case ':': goto yy87; + default: goto yy86; + } +yy86: + { +return TOK_ASSIGNMENT; } yy87: - ++scanner->cursor; - { - return TOK_INST_EQUAL; - } + ++scanner->cursor; + { +return TOK_INST_EQUAL; } yy89: - yych = *++scanner->cursor; - switch(yych) { - case ':': - goto yy90; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case ':': goto yy90; + default: goto yy78; + } yy90: - ++scanner->cursor; - { - return TOK_INST_NOT_EQUAL; - } + ++scanner->cursor; + { +return TOK_INST_NOT_EQUAL; } yy92: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '.': - goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy92; - default: - goto yy33; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '.': goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy92; + default: goto yy33; + } yy94: - yyaccept = 4; - scanner->marker = ++scanner->cursor; - if((scanner->null - scanner->cursor) < 3) { - YYFILL(3); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy94; - case 'E': - case 'e': - goto yy97; - default: - goto yy96; - } -yy96: { - return SCANprocess_real_literal(yytext); - } + yyaccept = 4; + scanner->marker = ++scanner->cursor; + if ((scanner->null - scanner->cursor) < 3) YYFILL(3); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy94; + case 'E': + case 'e': goto yy97; + default: goto yy96; + } +yy96: + { +return SCANprocess_real_literal(yytext); +} yy97: - yych = *++scanner->cursor; - switch(yych) { - case '+': - case '-': - goto yy98; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '+': + case '-': goto yy98; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy78; + } yy98: - yych = *++scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy78; + } yy99: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy96; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy96; + } yy101: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\n': - goto yy103; - default: - goto yy101; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\n': goto yy103; + default: goto yy101; + } yy103: - ++scanner->cursor; - { - NEWLINE; - SCANsave_comment(yytext); - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +SCANsave_comment(yytext); +IGNORE_TOKEN; +} yy105: - ++scanner->cursor; - { - ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); - IGNORE_TOKEN; - } + ++scanner->cursor; + { +ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); +IGNORE_TOKEN; +} yy107: - ++scanner->cursor; - { - return TOK_EXP; - } + ++scanner->cursor; + { +return TOK_EXP; } yy109: - ++scanner->cursor; - YYSETCONDITION(comment); - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + YYSETCONDITION(comment); + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy112: - switch(yych) { - case '\n': - goto yy115; - case '\'': - goto yy113; - default: - goto yy111; - } + switch (yych) { + case '\n': goto yy115; + case '\'': goto yy113; + default: goto yy111; + } yy113: - yyaccept = 5; - scanner->marker = ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\'': - goto yy111; - default: - goto yy114; - } -yy114: { - return SCANprocess_string(yytext); - } + yyaccept = 5; + scanner->marker = ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\'': goto yy111; + default: goto yy114; + } +yy114: + { +return SCANprocess_string(yytext); +} yy115: - ++scanner->cursor; - { - ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); - NEWLINE; - return SCANprocess_string(yytext); - } + ++scanner->cursor; + { +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); +NEWLINE; +return SCANprocess_string(yytext); +} yy117: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - goto yy117; - default: - goto yy119; - } -yy119: { - return SCANprocess_binary_literal(yytext); - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': goto yy117; + default: goto yy119; + } +yy119: + { +return SCANprocess_binary_literal(yytext); +} yy120: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy121: - switch(yych) { - case '\n': - goto yy122; - case '"': - goto yy124; - default: - goto yy120; - } + switch (yych) { + case '\n': goto yy122; + case '"': goto yy124; + default: goto yy120; + } yy122: - ++scanner->cursor; - { - ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); - NEWLINE; - return SCANprocess_encoded_string(yytext); - } + ++scanner->cursor; + { +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); +NEWLINE; +return SCANprocess_encoded_string(yytext); +} yy124: - ++scanner->cursor; - { - return SCANprocess_encoded_string(yytext); - } + ++scanner->cursor; + { +return SCANprocess_encoded_string(yytext); +} yy126: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy127: - switch(yych) { - case '\t': - case ' ': - goto yy126; - default: - goto yy5; - } - /* *********************************** */ + switch (yych) { + case '\t': + case ' ': goto yy126; + default: goto yy5; + } +/* *********************************** */ yyc_comment: - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy132; - case '\n': - goto yy133; - case '(': - goto yy135; - case ')': - goto yy137; - case '*': - goto yy138; - default: - goto yy131; - } -yy130: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy132; + case '\n': goto yy133; + case '(': goto yy135; + case ')': goto yy137; + case '*': goto yy138; + default: goto yy131; + } +yy130: + { +IGNORE_TOKEN; } yy131: - yych = *++scanner->cursor; - goto yy144; + yych = *++scanner->cursor; + goto yy144; yy132: - yych = *++scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy145; - default: - goto yy144; - } + yych = *++scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy145; + default: goto yy144; + } yy133: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy135: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy141; - default: - goto yy136; - } -yy136: { - IGNORE_TOKEN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy141; + default: goto yy136; + } +yy136: + { +IGNORE_TOKEN; } yy137: - yych = *++scanner->cursor; - goto yy136; + yych = *++scanner->cursor; + goto yy136; yy138: - yych = *++scanner->cursor; - switch(yych) { - case ')': - goto yy139; - default: - goto yy136; - } + yych = *++scanner->cursor; + switch (yych) { + case ')': goto yy139; + default: goto yy136; + } yy139: - ++scanner->cursor; - { - if(0 == --nesting_level) { - YYSETCONDITION(code); - } - IGNORE_TOKEN; - } + ++scanner->cursor; + { +if (0 == --nesting_level) { +YYSETCONDITION(code); +} +IGNORE_TOKEN; +} yy141: - ++scanner->cursor; - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy144: - switch(yych) { - case '\n': - case '(': - case ')': - case '*': - goto yy130; - default: - goto yy143; - } + switch (yych) { + case '\n': + case '(': + case ')': + case '*': goto yy130; + default: goto yy143; + } yy145: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy145; - case '\n': - case '(': - case ')': - case '*': - goto yy130; - default: - goto yy143; - } - /* *********************************** */ + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy145; + case '\n': + case '(': + case ')': + case '*': goto yy130; + default: goto yy143; + } +/* *********************************** */ yyc_return_end_schema: - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy152; - case '\n': - goto yy153; - case '(': - goto yy155; - case 'X': - case 'x': - goto yy156; - default: - goto yy150; - } -yy149: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy152; + case '\n': goto yy153; + case '(': goto yy155; + case 'X': + case 'x': goto yy156; + default: goto yy150; + } +yy149: + { +IGNORE_TOKEN; } yy150: - ++scanner->cursor; -yy151: { - IGNORE_TOKEN; - } + ++scanner->cursor; +yy151: + { +IGNORE_TOKEN; } yy152: - yych = *++scanner->cursor; - goto yy161; + yych = *++scanner->cursor; + goto yy161; yy153: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy155: - yych = *++scanner->cursor; - switch(yych) { - case '*': - goto yy158; - default: - goto yy151; - } + yych = *++scanner->cursor; + switch (yych) { + case '*': goto yy158; + default: goto yy151; + } yy156: - ++scanner->cursor; - YYSETCONDITION(code); - { - return TOK_END_SCHEMA; - } + ++scanner->cursor; + YYSETCONDITION(code); + { +return TOK_END_SCHEMA; +} yy158: - ++scanner->cursor; - YYSETCONDITION(comment); - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + YYSETCONDITION(comment); + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy161: - switch(yych) { - case '\t': - case ' ': - goto yy160; - default: - goto yy149; - } - } + switch (yych) { + case '\t': + case ' ': goto yy160; + default: goto yy149; + } + } } } @@ -1907,7 +1711,7 @@ yy151: { void SCANskip_to_end_schema(perplex_t scanner) { - while(yylex(scanner) != TOK_END_SCHEMA); - perplexUnput(scanner, 'X'); /* any old character */ - YYSETCONDITION(return_end_schema); +while (yylex(scanner) != TOK_END_SCHEMA); +perplexUnput(scanner, 'X'); /* any old character */ +YYSETCONDITION(return_end_schema); } diff --git a/src/express/generated/expscan.h b/src/express/generated/expscan.h index 7b0ccb3a6..a9e6705cf 100644 --- a/src/express/generated/expscan.h +++ b/src/express/generated/expscan.h @@ -56,10 +56,10 @@ #define YYEOF -1 struct Buf { - void *elts; /* elements. */ - int nelts; /* number of elements. */ - size_t elt_size; /* in bytes. */ - int nmax; /* max capacity of elements. */ + void *elts; /* elements. */ + int nelts; /* number of elements. */ + size_t elt_size; /* in bytes. */ + int nmax; /* max capacity of elements. */ }; /* scanner data */ @@ -82,7 +82,7 @@ void perplexFree(perplex_t scanner); void perplexUnput(perplex_t scanner, char c); void perplexSetExtra(perplex_t scanner, void *extra); -void *perplexGetExtra(perplex_t scanner); +void* perplexGetExtra(perplex_t scanner); #ifndef PERPLEX_LEXER #define PERPLEX_LEXER yylex diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake new file mode 100644 index 000000000..b3d7b3608 --- /dev/null +++ b/src/express/generated/verification_info.cmake @@ -0,0 +1,7 @@ +# Autogenerated verification information +set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) +set(baseline_expparse_y_md5 3722242f16c679c40323317833757a6d) +set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) +set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) +set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) +set(baseline_expparse_h_md5 e4a5599839b2a9f7a6915a0dcc7747b0) diff --git a/src/express/hash.c b/src/express/hash.c index eeb073a8a..5556ade92 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -116,8 +116,8 @@ ** Internal routines */ -static inline Address HASHhash(char *, Hash_Table); -static void HASHexpand_table(Hash_Table); +static inline Address HASHhash( char *, Hash_Table ); +static void HASHexpand_table( Hash_Table ); /* ** Local data @@ -132,13 +132,11 @@ static long HashAccesses, HashCollisions; */ void -HASHinitialize() -{ +HASHinitialize() { } Hash_Table -HASHcreate(unsigned count) -{ +HASHcreate( unsigned count ) { unsigned i; Hash_Table table; @@ -147,10 +145,10 @@ HASHcreate(unsigned count) ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while(i < count) { + while( i < count ) { i <<= 1; } - count = DIV(i, SEGMENT_SIZE_SHIFT); + count = DIV( i, SEGMENT_SIZE_SHIFT ); table = HASH_Table_new(); #if 0 @@ -160,33 +158,32 @@ HASHcreate(unsigned count) /* ** Allocate initial 'i' segments of buckets */ - for(i = 0; i < count; i++) - CALLOC(table->Directory[i], SEGMENT_SIZE, Element) + for( i = 0; i < count; i++ ) + CALLOC( table->Directory[i], SEGMENT_SIZE, Element ) /*, "segment in HASHcreate");*/ table->SegmentCount = count; - table->maxp = MUL(count, SEGMENT_SIZE_SHIFT); + table->maxp = MUL( count, SEGMENT_SIZE_SHIFT ); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef HASH_DEBUG - fprintf(stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount); + fprintf( stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount ); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return(table); + return( table ); } /* initialize pointer to beginning of hash table so we can step through it */ /* on repeated calls to HASHlist - DEL */ void -HASHlistinit(Hash_Table table, HashEntry *he) -{ +HASHlistinit( Hash_Table table, HashEntry * he ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -197,8 +194,7 @@ HASHlistinit(Hash_Table table, HashEntry *he) } void -HASHlistinit_by_type(Hash_Table table, HashEntry *he, char type) -{ +HASHlistinit_by_type( Hash_Table table, HashEntry * he, char type ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -211,27 +207,25 @@ HASHlistinit_by_type(Hash_Table table, HashEntry *he, char type) #if 0 /* if you don't step to the end, you can clear the flag this way */ void -HASHlistend(HashEntry *he) -{ +HASHlistend( HashEntry * he ) { he->table->in_use = 0; } #endif /* provide a way to step through the hash */ Element -HASHlist(HashEntry *he) -{ +HASHlist( HashEntry * he ) { int i2 = he->i; int j2 = he->j; Segment s; he->e = 0; - for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { + for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { /* test probably unnecessary */ - if((s = he->table->Directory[he->i]) != NULL) { - for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { - if(!he->p) { + if( ( s = he->table->Directory[he->i] ) != NULL ) { + for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { + if( !he->p ) { he->p = s[he->j]; } @@ -240,22 +234,22 @@ HASHlist(HashEntry *he) for he->p */ retry: - if(he->p) { - if((he->type != '*') && - (he->type != he->p->type)) { + if( he->p ) { + if( ( he->type != '*' ) && + ( he->type != he->p->type ) ) { he->p = he->p->next; goto retry; } - if(he->e) { - return(he->e); + if( he->e ) { + return( he->e ); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if(he->p) { - return(he->e); + if( he->p ) { + return( he->e ); } } j2 = 0; @@ -265,58 +259,55 @@ HASHlist(HashEntry *he) #if 0 he->table->in_use = 0; #endif - return(he->e); + return( he->e ); } #if 0 /* this verifies no one else is walking through the table that we might screw up */ /* it should be called before adding, deleting or destroying a table */ -HASH_in_use(Hash_Table table, char *action) -{ - fprintf(stderr, "HASH: attempted to %s but hash table in use\n", action); +HASH_in_use( Hash_Table table, char * action ) { + fprintf( stderr, "HASH: attempted to %s but hash table in use\n", action ); } #endif void -HASHdestroy(Hash_Table table) -{ +HASHdestroy( Hash_Table table ) { Segment s; Element p, q; - if(table != HASH_NULL) { + if( table != HASH_NULL ) { unsigned int i, j; #if 0 - if(table->in_use) { - HASH_in_use(table, "destroy hash table"); + if( table->in_use ) { + HASH_in_use( table, "destroy hash table" ); } #endif - for(i = 0; i < table->SegmentCount; i++) { + for( i = 0; i < table->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = table->Directory[i]) != NULL) { - for(j = 0; j < SEGMENT_SIZE; j++) { + if( ( s = table->Directory[i] ) != NULL ) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { p = s[j]; - while(p != NULL) { + while( p != NULL ) { q = p->next; - HASH_Element_destroy(p); + HASH_Element_destroy( p ); p = q; } } - sc_free(table->Directory[i]); + sc_free( table->Directory[i] ); } } - HASH_Table_destroy(table); + HASH_Table_destroy( table ); # if defined(HASH_STATISTICS) && defined(HASH_DEBUG) - fprintf(stderr, - "[hdestroy] Accesses %ld Collisions %ld\n", - HashAccesses, - HashCollisions); + fprintf( stderr, + "[hdestroy] Accesses %ld Collisions %ld\n", + HashAccesses, + HashCollisions ); # endif } } Element -HASHsearch(Hash_Table table, Element item, Action action) -{ +HASHsearch( Hash_Table table, Element item, Action action ) { Address h; Segment CurrentSegment; int SegmentIndex; @@ -325,18 +316,18 @@ HASHsearch(Hash_Table table, Element item, Action action) Element q; Element deleteme; - assert(table != HASH_NULL); /* Kinder really than return(NULL); */ + assert( table != HASH_NULL ); /* Kinder really than return(NULL); */ # ifdef HASH_STATISTICS HashAccesses++; # endif - h = HASHhash(item->key, table); - SegmentDir = DIV(h, SEGMENT_SIZE_SHIFT); - SegmentIndex = MOD(h, SEGMENT_SIZE); + h = HASHhash( item->key, table ); + SegmentDir = DIV( h, SEGMENT_SIZE_SHIFT ); + SegmentIndex = MOD( h, SEGMENT_SIZE ); /* ** valid segment ensured by HASHhash() */ CurrentSegment = table->Directory[SegmentDir]; - assert(CurrentSegment != NULL); /* bad failure if tripped */ + assert( CurrentSegment != NULL ); /* bad failure if tripped */ p = CurrentSegment + SegmentIndex; q = *p; /* @@ -345,7 +336,7 @@ HASHsearch(Hash_Table table, Element item, Action action) ** p = &element, and ** q = element */ - while(q != NULL && strcmp(q->key, item->key)) { + while( q != NULL && strcmp( q->key, item->key ) ) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -353,34 +344,34 @@ HASHsearch(Hash_Table table, Element item, Action action) # endif } /* at this point, we have either found the element or it doesn't exist */ - switch(action) { + switch( action ) { case HASH_FIND: - return((Element)q); + return( ( Element )q ); case HASH_DELETE: - if(!q) { - return(0); + if( !q ) { + return( 0 ); } /* at this point, element exists and action == DELETE */ #if 0 - if(table->in_use) { - HASH_in_use(table, "insert element"); + if( table->in_use ) { + HASH_in_use( table, "insert element" ); } #endif deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - HASH_Element_destroy(deleteme); + HASH_Element_destroy( deleteme ); --table->KeyCount; - return(deleteme); /* of course, user shouldn't deref this! */ + return( deleteme ); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if(q != NULL) { - return(q); /* was return(0);!!!!!?!?! */ + if( q != NULL ) { + return( q ); /* was return(0);!!!!!?!?! */ } #if 0 - if(table->in_use) { - HASH_in_use(table, "delete element"); + if( table->in_use ) { + HASH_in_use( table, "delete element" ); } #endif /* at this point, element does not exist and action == INSERT */ @@ -399,63 +390,61 @@ HASHsearch(Hash_Table table, Element item, Action action) /* ** table over-full? */ - if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE_SHIFT) > table->MaxLoadFactor) { - HASHexpand_table(table); /* doesn't affect q */ + if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE_SHIFT ) > table->MaxLoadFactor ) { + HASHexpand_table( table ); /* doesn't affect q */ } } - return((Element)0); /* was return (Element)q */ + return( ( Element )0 ); /* was return (Element)q */ } /* ** Internal routines */ -static inline Address HASHhash(char *Key, Hash_Table table) -{ +static inline Address HASHhash( char * Key, Hash_Table table ) { Address h, address; - register unsigned char *k = (unsigned char *)Key; + register unsigned char * k = ( unsigned char * )Key; h = 0; /* ** Convert string to integer */ /*SUPPRESS 112*/ - assert(Key); - while(*k) + assert( Key ); + while( *k ) /*SUPPRESS 8*/ { /*SUPPRESS 112*/ - h = h * PRIME1 ^ (*k++ - ' '); + h = h * PRIME1 ^ ( *k++ - ' ' ); } h %= PRIME2; - address = MOD(h, table->maxp); - if(address < table->p) { - address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ + address = MOD( h, table->maxp ); + if( address < table->p ) { + address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ } - return(address); + return( address ); } -static void HASHexpand_table(Hash_Table table) -{ +static void HASHexpand_table( Hash_Table table ) { Segment OldSegment, NewSegment; Element Current, *Previous, *LastOfNew; - if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT)) { + if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT ) ) { Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; /* ** Locate the bucket to be split */ - OldSegmentDir = DIV(table->p, SEGMENT_SIZE_SHIFT); + OldSegmentDir = DIV( table->p, SEGMENT_SIZE_SHIFT ); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); + OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = DIV(NewAddress, SEGMENT_SIZE_SHIFT); - NewSegmentIndex = MOD(NewAddress, SEGMENT_SIZE); - if(NewSegmentIndex == 0) { - CALLOC(table->Directory[NewSegmentDir], SEGMENT_SIZE, Element); + NewSegmentDir = DIV( NewAddress, SEGMENT_SIZE_SHIFT ); + NewSegmentIndex = MOD( NewAddress, SEGMENT_SIZE ); + if( NewSegmentIndex == 0 ) { + CALLOC( table->Directory[NewSegmentDir], SEGMENT_SIZE, Element ); } /* "segment in HASHexpand_table");*/ NewSegment = table->Directory[NewSegmentDir]; @@ -463,7 +452,7 @@ static void HASHexpand_table(Hash_Table table) ** Adjust state variables */ table->p++; - if(table->p == table->maxp) { + if( table->p == table->maxp ) { table->maxp <<= 1; /* table->maxp *= 2 */ table->p = 0; } @@ -475,8 +464,8 @@ static void HASHexpand_table(Hash_Table table) Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while(Current != NULL) { - if(HASHhash(Current->key, table) == NewAddress) { + while( Current != NULL ) { + if( HASHhash( Current->key, table ) == NewAddress ) { /* ** Attach it to the end of the new chain */ @@ -504,17 +493,16 @@ static void HASHexpand_table(Hash_Table table) /* But then, it isn't called when objects are inserted/deleted so this seems */ /* reasonable - DEL */ Hash_Table -HASHcopy(Hash_Table oldtable) -{ +HASHcopy( Hash_Table oldtable ) { Hash_Table newtable; Segment s, s2; - Element *pp; /* old element */ - Element *qq; /* new element */ + Element * pp; /* old element */ + Element * qq; /* new element */ unsigned int i, j; newtable = HASH_Table_new(); - for(i = 0; i < oldtable->SegmentCount; i++) { - CALLOC(newtable->Directory[i], SEGMENT_SIZE, Element); + for( i = 0; i < oldtable->SegmentCount; i++ ) { + CALLOC( newtable->Directory[i], SEGMENT_SIZE, Element ); /* "segment in HASHcopy");*/ } @@ -525,55 +513,54 @@ HASHcopy(Hash_Table oldtable) newtable->MaxLoadFactor = oldtable->MaxLoadFactor; newtable->KeyCount = oldtable->KeyCount; - for(i = 0; i < oldtable->SegmentCount; i++) { + for( i = 0; i < oldtable->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = oldtable->Directory[i]) != NULL) { + if( ( s = oldtable->Directory[i] ) != NULL ) { s2 = newtable->Directory[i]; - for(j = 0; j < SEGMENT_SIZE; j++) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { qq = &s2[j]; - for(pp = &s[j]; *pp; pp = &(*pp)->next) { + for( pp = &s[j]; *pp; pp = &( *pp )->next ) { *qq = HASH_Element_new(); /* (*qq)->key = STRINGcopy((*pp)->key);*/ /* I really doubt it is necessary to copy the key!!! */ - (*qq)->key = (*pp)->key; - (*qq)->data = (*pp)->data; - (*qq)->symbol = (*pp)->symbol; - (*qq)->type = (*pp)->type; - (*qq)->next = NULL; - qq = &((*qq)->next); + ( *qq )->key = ( *pp )->key; + ( *qq )->data = ( *pp )->data; + ( *qq )->symbol = ( *pp )->symbol; + ( *qq )->type = ( *pp )->type; + ( *qq )->next = NULL; + qq = &( ( *qq )->next ); } } } } - return(newtable); + return( newtable ); } /* following code is for testing hash package */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table *t; +struct Hash_Table * t; HashEntry he; -main() -{ +main() { e1.key = "foo"; - e1.data = (char *)1; + e1.data = ( char * )1; e2.key = "bar"; - e2.data = (char *)2; + e2.data = ( char * )2; e3.key = "herschel"; - e3.data = (char *)3; - - t = HASHcreate(100); - e = HASHsearch(t, &e1, HASH_INSERT); - e = HASHsearch(t, &e2, HASH_INSERT); - e = HASHsearch(t, &e3, HASH_INSERT); - HASHlistinit(t, &he); - for(;;) { - e = HASHlist(&he); - if(!e) { - exit(0); + e3.data = ( char * )3; + + t = HASHcreate( 100 ); + e = HASHsearch( t, &e1, HASH_INSERT ); + e = HASHsearch( t, &e2, HASH_INSERT ); + e = HASHsearch( t, &e3, HASH_INSERT ); + HASHlistinit( t, &he ); + for( ;; ) { + e = HASHlist( &he ); + if( !e ) { + exit( 0 ); } - fprintf(stderr, "found key %s, data %d\n", e->key, (int)e->data); + fprintf( stderr, "found key %s, data %d\n", e->key, ( int )e->data ); } } #endif diff --git a/src/express/info.c b/src/express/info.c index 2839d5c15..50af7ab11 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -4,34 +4,40 @@ #include "express/info.h" #include "express/express.h" -char *EXPRESSversion(void) -{ - return("Express Language, IS (N65), October 24, 1994"); +#ifndef SCHEMA_SCANNER +# include "sc_version_string.h" +#else + /* dummy string to make the compiler happy when building the schema scanner, + * should never be seen by users */ + const char * sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; +#endif + +char * EXPRESSversion( void ) { + return( "Express Language, IS (N65), October 24, 1994" ); } -void EXPRESSusage(int _exit) -{ - fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "where\t-v produces the following version description:\n"); - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, SC_VERSION); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", ERRORget_warnings_help("\t", "\n")); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); - if(_exit) { - exit(2); +void EXPRESSusage( int _exit ) { + fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "where\t-v produces the following version description:\n" ); + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, ERRORget_warnings_help("\t", "\n") ); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); + if( _exit ) { + exit( 2 ); } } diff --git a/src/express/inithook.c b/src/express/inithook.c index edf3fbcec..a3d3eac5d 100644 --- a/src/express/inithook.c +++ b/src/express/inithook.c @@ -2,7 +2,6 @@ /* dummy function, user can supply one allowing them to setup a backend */ /* or customize other parts of fedex application */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { } diff --git a/src/express/lexact.c b/src/express/lexact.c index 27db69163..abcde3176 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -71,20 +71,20 @@ extern YYSTYPE yylval; Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; int SCAN_current_buffer = 0; -char *SCANcurrent; +char * SCANcurrent; extern int yylineno; #define SCAN_COMMENT_LENGTH 256 static char last_comment_[256] = ""; -static char *last_comment = 0; +static char * last_comment = 0; /* keyword lookup table */ static Hash_Table keyword_dictionary; static struct keyword_entry { - char *key; + char * key; int token; } keywords[] = { { "ABS", TOK_BUILTIN_FUNCTION }, @@ -206,8 +206,7 @@ static struct keyword_entry { { 0, 0} }; -static void SCANpush_buffer(char *filename, FILE *fp) -{ +static void SCANpush_buffer( char * filename, FILE * fp ) { SCANbuffer.savedPos = SCANcurrent; SCANbuffer.lineno = yylineno; yylineno = 1; @@ -215,17 +214,16 @@ static void SCANpush_buffer(char *filename, FILE *fp) #ifdef keep_nul SCANbuffer.numRead = 0; #else - *(SCANcurrent = SCANbuffer.text) = '\0'; + *( SCANcurrent = SCANbuffer.text ) = '\0'; #endif SCANbuffer.readEof = false; SCANbuffer.file = fp; SCANbuffer.filename = current_filename = filename; } -static void SCANpop_buffer() -{ - if(SCANbuffer.file != NULL) { - fclose(SCANbuffer.file); +static void SCANpop_buffer() { + if( SCANbuffer.file != NULL ) { + fclose( SCANbuffer.file ); } --SCAN_current_buffer; SCANcurrent = SCANbuffer.savedPos; @@ -233,43 +231,37 @@ static void SCANpop_buffer() current_filename = SCANbuffer.filename; } -void SCANinitialize(void) -{ - struct keyword_entry *k; +void SCANinitialize( void ) { + struct keyword_entry * k; - keyword_dictionary = HASHcreate(100); /* not exact */ - for(k = keywords; k->key; k++) { - DICTdefine(keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN); + keyword_dictionary = HASHcreate( 100 ); /* not exact */ + for( k = keywords; k->key; k++ ) { + DICTdefine( keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN ); /* not "unknown", but certainly won't be looked up by type! */ } } /** Clean up the Scan module */ -void SCANcleanup(void) -{ +void SCANcleanup( void ) { } -int SCANprocess_real_literal(const char *yytext) -{ - sscanf(yytext, "%lf", &(yylval.rVal)); +int SCANprocess_real_literal( const char * yytext ) { + sscanf( yytext, "%lf", &( yylval.rVal ) ); return TOK_REAL_LITERAL; } -int SCANprocess_integer_literal(const char *yytext) -{ - sscanf(yytext, "%d", &(yylval.iVal)); +int SCANprocess_integer_literal( const char * yytext ) { + sscanf( yytext, "%d", &( yylval.iVal ) ); return TOK_INTEGER_LITERAL; } -int SCANprocess_binary_literal(const char *yytext) -{ - yylval.binary = SCANstrdup(yytext + 1); /* drop '%' prefix */ +int SCANprocess_binary_literal( const char * yytext ) { + yylval.binary = SCANstrdup( yytext + 1 ); /* drop '%' prefix */ return TOK_BINARY_LITERAL; } -int SCANprocess_logical_literal(char *string) -{ - switch(string[0]) { +int SCANprocess_logical_literal( char * string ) { + switch( string[0] ) { case 'T': yylval.logical = Ltrue; break; @@ -281,67 +273,65 @@ int SCANprocess_logical_literal(char *string) break; /* default will actually be triggered by 'UNKNOWN' keyword */ } - sc_free(string); + sc_free( string ); return TOK_LOGICAL_LITERAL; } -int SCANprocess_identifier_or_keyword(const char *yytext) -{ - char *test_string, * dest; - const char *src; - struct keyword_entry *k; +int SCANprocess_identifier_or_keyword( const char * yytext ) { + char * test_string, * dest; + const char * src; + struct keyword_entry * k; int len; /* make uppercase copy */ - len = strlen(yytext); - dest = test_string = (char *)sc_malloc(len + 1); - for(src = yytext; *src; src++, dest++) { - *dest = (islower(*src) ? toupper(*src) : *src); + len = strlen( yytext ); + dest = test_string = ( char * )sc_malloc( len + 1 ); + for( src = yytext; *src; src++, dest++ ) { + *dest = ( islower( *src ) ? toupper( *src ) : *src ); } *dest = '\0'; /* check for language keywords */ - k = (struct keyword_entry *)DICTlookup(keyword_dictionary, test_string); - if(k) { - switch(k->token) { + k = ( struct keyword_entry * )DICTlookup( keyword_dictionary, test_string ); + if( k ) { + switch( k->token ) { case TOK_BUILTIN_FUNCTION: case TOK_BUILTIN_PROCEDURE: break; case TOK_LOGICAL_LITERAL: - return SCANprocess_logical_literal(test_string); + return SCANprocess_logical_literal( test_string ); default: - sc_free(test_string); + sc_free( test_string ); return k->token; } } /* now we have an identifier token */ - yylval.symbol = SYMBOLcreate(test_string, yylineno, current_filename); - if(k) { + yylval.symbol = SYMBOLcreate( test_string, yylineno, current_filename ); + if( k ) { /* built-in function/procedure */ - return(k->token); + return( k->token ); } else { /* plain identifier */ /* translate back to lower-case */ - SCANlowerize(test_string); + SCANlowerize( test_string ); return TOK_IDENTIFIER; } } -int SCANprocess_string(const char *yytext) -{ - char *s, *d; /* source, destination */ +int SCANprocess_string( const char * yytext ) { + char * s, *d; /* source, destination */ /* strip off quotes */ - yylval.string = SCANstrdup(yytext + 1); /* remove 1st single quote */ + yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st single quote */ /* change pairs of quotes to single quotes */ - for(s = d = yylval.string; *s;) { - if(*s != '\'') { + for( s = d = yylval.string; *s; ) { + if( *s != '\'' ) { *d++ = *s++; - } else if(0 == strncmp(s, "''", 2)) { + } else if( 0 == strncmp( s, "''", 2 ) ) { *d++ = '\''; s += 2; - } else if(*s == '\'') { + } else if( *s == '\'' ) { /* trailing quote */ *s = '\0'; /* if string was unterminated, there will be no */ @@ -354,68 +344,64 @@ int SCANprocess_string(const char *yytext) return TOK_STRING_LITERAL; } -int SCANprocess_encoded_string(const char *yytext) -{ - char *s; /* source */ +int SCANprocess_encoded_string( const char * yytext ) { + char * s; /* source */ int count; /* strip off quotes */ - yylval.string = SCANstrdup(yytext + 1); /* remove 1st double quote */ + yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st double quote */ - s = strrchr(yylval.string, '"'); - if(s) { + s = strrchr( yylval.string, '"' ); + if( s ) { *s = '\0'; /* remove last double quote */ } /* if string was unterminated, there will be no quote to remove */ /* in which case the scanner has already complained about it */ count = 0; - for(s = yylval.string; *s; s++, count++) { - if(!isxdigit(*s)) { - ERRORreport_with_line(ENCODED_STRING_BAD_DIGIT, yylineno, *s); + for( s = yylval.string; *s; s++, count++ ) { + if( !isxdigit( *s ) ) { + ERRORreport_with_line( ENCODED_STRING_BAD_DIGIT, yylineno, *s ); } } - if(0 != (count % 8)) { - ERRORreport_with_line(ENCODED_STRING_BAD_COUNT, yylineno, count); + if( 0 != ( count % 8 ) ) { + ERRORreport_with_line( ENCODED_STRING_BAD_COUNT, yylineno, count ); } return TOK_STRING_LITERAL_ENCODED; } -int SCANprocess_semicolon(const char *yytext, int commentp) -{ +int SCANprocess_semicolon( const char * yytext, int commentp ) { - if(commentp) { - strcpy(last_comment_, strchr(yytext, '-')); + if( commentp ) { + strcpy( last_comment_, strchr( yytext, '-' ) ); yylval.string = last_comment_; } else { yylval.string = last_comment; } - if(last_comment) { + if( last_comment ) { last_comment = 0; } return TOK_SEMICOLON; } -void SCANsave_comment(const char *yytext) -{ - strncpy(last_comment_, yytext, SCAN_COMMENT_LENGTH - 1); +void SCANsave_comment( const char * yytext ) { + strncpy( last_comment_ , yytext, SCAN_COMMENT_LENGTH - 1 ); last_comment = last_comment_; } -bool SCANread(void) -{ +bool SCANread( void ) { int numRead; bool done; do { /* this loop is guaranteed to terminate, since buffer[0] is on yyin */ - while(SCANbuffer.file == NULL) { + while( SCANbuffer.file == NULL ) { SCANpop_buffer(); - if(SCANtext_ready) { + if( SCANtext_ready ) { return true; } } @@ -423,15 +409,15 @@ bool SCANread(void) /* now we have a file buffer */ /* check for more stuff already buffered */ - if(SCANtext_ready) { + if( SCANtext_ready ) { return true; } /* check whether we've seen eof on this file */ - if(!SCANbuffer.readEof) { - numRead = fread(SCANbuffer.text, sizeof(char), - SCAN_BUFFER_SIZE, SCANbuffer.file); - if(numRead < SCAN_BUFFER_SIZE) { + if( !SCANbuffer.readEof ) { + numRead = fread( SCANbuffer.text, sizeof( char ), + SCAN_BUFFER_SIZE, SCANbuffer.file ); + if( numRead < SCAN_BUFFER_SIZE ) { SCANbuffer.readEof = true; } #ifdef keep_nul @@ -442,66 +428,61 @@ bool SCANread(void) SCANcurrent = SCANbuffer.text; } - if(!(done = SCANtext_ready)) { - if(SCAN_current_buffer == 0) { + if( !( done = SCANtext_ready ) ) { + if( SCAN_current_buffer == 0 ) { done = true; - fclose(SCANbuffer.file); /* close yyin */ + fclose( SCANbuffer.file ); /* close yyin */ SCANbuffer.file = NULL; } else { SCANpop_buffer(); } } - } while(!done); + } while( !done ); return SCANtext_ready; } -void SCANinclude_file(char *filename) -{ +void SCANinclude_file( char * filename ) { extern int print_objects_while_running; - FILE *fp; + FILE * fp; - if((fp = fopen(filename, "r")) == NULL) { - ERRORreport_with_line(INCLUDE_FILE, yylineno); + if( ( fp = fopen( filename, "r" ) ) == NULL ) { + ERRORreport_with_line( INCLUDE_FILE, yylineno ); } else { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: including %s at line %d of %s\n", - filename, yylineno, SCANbuffer.filename); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "parse: including %s at line %d of %s\n", + filename, yylineno, SCANbuffer.filename ); } - SCANpush_buffer(filename, fp); + SCANpush_buffer( filename, fp ); } } -void SCANlowerize(char *s) -{ - for(; *s; s++) { - if(isupper(*s)) { - *s = tolower(*s); +void SCANlowerize( char * s ) { + for( ; *s; s++ ) { + if( isupper( *s ) ) { + *s = tolower( *s ); } } } -void SCANupperize(char *s) -{ - for(; *s; s++) { - if(islower(*s)) { - *s = toupper(*s); +void SCANupperize( char * s ) { + for( ; *s; s++ ) { + if( islower( *s ) ) { + *s = toupper( *s ); } } } -char *SCANstrdup(const char *s) -{ - char *s2 = (char *)sc_malloc(strlen(s) + 1); - if(!s2) { +char * SCANstrdup( const char * s ) { + char * s2 = ( char * )sc_malloc( strlen( s ) + 1 ); + if( !s2 ) { return 0; } - strcpy(s2, s); + strcpy( s2, s ); return s2; } -long SCANtell() -{ +long SCANtell() { return yylineno; } diff --git a/src/express/linklist.c b/src/express/linklist.c index 9a32e7bbe..7089dd81d 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -23,76 +23,66 @@ #include "express/linklist.h" -void LISTinitialize(void) -{ +void LISTinitialize( void ) { } -void LISTcleanup(void) -{ +void LISTcleanup( void ) { } -Linked_List LISTcreate() -{ +Linked_List LISTcreate() { Linked_List list = LIST_new(); list->mark = LINK_new(); list->mark->next = list->mark->prev = list->mark; - return(list); + return( list ); } -Linked_List LISTcopy(Linked_List src) -{ +Linked_List LISTcopy( Linked_List src ) { Linked_List dst = LISTcreate(); - LISTdo(src, x, void *) - LISTadd_last(dst, x); + LISTdo( src, x, void * ) + LISTadd_last( dst, x ); LISTod return dst; } -void LISTfree(Linked_List list) -{ +void LISTfree( Linked_List list ) { Link p, q = list->mark->next; - for(p = q->next; p != list->mark; q = p, p = p->next) { - LINK_destroy(q); + for( p = q->next; p != list->mark; q = p, p = p->next ) { + LINK_destroy( q ); } - if(q != list->mark) { - LINK_destroy(q); + if( q != list->mark ) { + LINK_destroy( q ); } - LINK_destroy(list->mark); - LIST_destroy(list); + LINK_destroy( list->mark ); + LIST_destroy( list ); } -void LISTsort(Linked_List list, int (*comp)(void *, void *)) -{ +void LISTsort( Linked_List list, int (*comp)(void*, void*)) { unsigned int moved; Link node, prev; - if(LISTempty(list)) { + if (LISTempty(list)) return; - } - while(true) { - for(node = list->mark->next, moved = 0; node != list->mark; node = node->next) { + while (true) { + for ( node = list->mark->next, moved = 0; node != list->mark; node = node->next ) { prev = node->prev; - if(prev != list->mark && comp(prev->data, node->data) < 0) { + if (prev != list->mark && comp(prev->data, node->data) < 0) { LISTswap(prev, node); moved++; } } - if(moved == 0) { + if (moved == 0) break; - } } } -void LISTswap(Link p, Link q) -{ +void LISTswap( Link p, Link q ) { void *tmp; - if(p == LINK_NULL || q == LINK_NULL || p == q) { + if( p == LINK_NULL || q == LINK_NULL || p == q ) return; - } tmp = p->data; p->data = q->data; @@ -100,49 +90,45 @@ void LISTswap(Link p, Link q) } -void *LISTadd_first(Linked_List list, void *item) -{ +void *LISTadd_first( Linked_List list, void *item ) { Link node; node = LINK_new(); node->data = item; - (node->next = list->mark->next)->prev = node; - (list->mark->next = node)->prev = list->mark; + ( node->next = list->mark->next )->prev = node; + ( list->mark->next = node )->prev = list->mark; return item; } -void *LISTadd_last(Linked_List list, void *item) -{ +void *LISTadd_last( Linked_List list, void *item ) { Link node; node = LINK_new(); node->data = item; - (node->prev = list->mark->prev)->next = node; - (list->mark->prev = node)->next = list->mark; + ( node->prev = list->mark->prev )->next = node; + ( list->mark->prev = node )->next = list->mark; return item; } -void *LISTadd_after(Linked_List list, Link link, void *item) -{ +void *LISTadd_after( Linked_List list, Link link, void *item ) { Link node; - if(link == LINK_NULL) { - LISTadd_first(list, item); + if( link == LINK_NULL ) { + LISTadd_first( list, item ); } else { node = LINK_new(); node->data = item; - (node->next = link->next)->prev = node; - (link->next = node)->prev = link; + ( node->next = link->next )->prev = node; + ( link->next = node )->prev = link; } return item; } -void *LISTadd_before(Linked_List list, Link link, void *item) -{ +void *LISTadd_before( Linked_List list, Link link, void *item ) { Link node; - if(link == LINK_NULL) { - LISTadd_last(list, item); + if( link == LINK_NULL ) { + LISTadd_last( list, item ); } else { node = LINK_new(); node->data = item; @@ -156,46 +142,43 @@ void *LISTadd_before(Linked_List list, Link link, void *item) } -void *LISTremove_first(Linked_List list) -{ +void *LISTremove_first( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { - ERRORreport(EMPTY_LIST, "LISTremove_first"); + if( node == list->mark ) { + ERRORreport( EMPTY_LIST, "LISTremove_first" ); return NULL; } item = node->data; - (list->mark->next = node->next)->prev = list->mark; - LINK_destroy(node); + ( list->mark->next = node->next )->prev = list->mark; + LINK_destroy( node ); return item; } -void *LISTget_first(Linked_List list) -{ +void *LISTget_first( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } item = node->data; return item; } -void *LISTget_second(Linked_List list) -{ +void *LISTget_second( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } node = node->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } item = node->data; @@ -203,40 +186,37 @@ void *LISTget_second(Linked_List list) } /** first is 1, not 0 */ -void *LISTget_nth(Linked_List list, int n) -{ +void *LISTget_nth( Linked_List list, int n ) { int count = 1; Link node; - for(node = list->mark->next; node != list->mark; node = node->next) { - if(n == count++) { - return(node->data); + for( node = list->mark->next; node != list->mark; node = node->next ) { + if( n == count++ ) { + return( node->data ); } } - return(0); + return( 0 ); } -int LISTget_length(Linked_List list) -{ +int LISTget_length( Linked_List list ) { Link node; int count = 0; - if(!list) { + if( !list ) { return 0; } - for(node = list->mark->next; node != list->mark; node = node->next) { + for( node = list->mark->next; node != list->mark; node = node->next ) { count++; } return count; } -bool LISTempty(Linked_List list) -{ - if(!list) { +bool LISTempty( Linked_List list ) { + if( !list ) { return true; } - if(list->mark->next == list->mark) { + if( list->mark->next == list->mark ) { return true; } return false; diff --git a/src/express/memory.c b/src/express/memory.c index a257582fb..f8b536e45 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -51,53 +51,52 @@ struct freelist_head PCALL_fl; struct freelist_head RET_fl; struct freelist_head INCR_fl; -void MEMORYinitialize() -{ +void MEMORYinitialize() { _ALLOCinitialize(); - - ALLOCinitialize(&HASH_Table_fl, sizeof(struct Hash_Table_), 50, 50); - ALLOCinitialize(&HASH_Element_fl, sizeof(struct Element_), 500, 100); - - ALLOCinitialize(&LINK_fl, sizeof(struct Link_), 500, 100); - ALLOCinitialize(&LIST_fl, sizeof(struct Linked_List_), 100, 50); - - ALLOCinitialize(&SYMBOL_fl, sizeof(struct Symbol_), 100, 100); - - ALLOCinitialize(&SCOPE_fl, sizeof(struct Scope_), 100, 50); - - ALLOCinitialize(&TYPEHEAD_fl, sizeof(struct TypeHead_), 500, 100); - ALLOCinitialize(&TYPEBODY_fl, sizeof(struct TypeBody_), 200, 100); - - ALLOCinitialize(&VAR_fl, sizeof(struct Variable_), 100, 50); - - ALLOCinitialize(&FUNC_fl, sizeof(struct Function_), 100, 50); - ALLOCinitialize(&RULE_fl, sizeof(struct Rule_), 100, 50); - ALLOCinitialize(&PROC_fl, sizeof(struct Procedure_), 100, 50); - ALLOCinitialize(&WHERE_fl, sizeof(struct Where_), 100, 50); - - ALLOCinitialize(&ENTITY_fl, sizeof(struct Entity_), 500, 100); - - ALLOCinitialize(&SCHEMA_fl, sizeof(struct Schema_), 40, 20); - ALLOCinitialize(&REN_fl, sizeof(struct Rename), 30, 30); - - ALLOCinitialize(&CASE_IT_fl, sizeof(struct Case_Item_), 500, 100); - - ALLOCinitialize(&EXP_fl, sizeof(struct Expression_), 500, 200); - ALLOCinitialize(&OP_fl, sizeof(struct Op_Subexpression), 500, 100); - ALLOCinitialize(&QUERY_fl, sizeof(struct Query_), 50, 10); - ALLOCinitialize(&QUAL_ATTR_fl, sizeof(struct Query_), 20, 10); - - ALLOCinitialize(&STMT_fl, sizeof(struct Statement_), 500, 100); - - ALLOCinitialize(&ALIAS_fl, sizeof(struct Alias_), 10, 10); - ALLOCinitialize(&ASSIGN_fl, sizeof(struct Assignment_), 100, 30); - ALLOCinitialize(&CASE_fl, sizeof(struct Case_Statement_), 100, 30); - ALLOCinitialize(&COMP_STMT_fl, sizeof(struct Compound_Statement_), 100, 30); - ALLOCinitialize(&COND_fl, sizeof(struct Conditional_), 100, 30); - ALLOCinitialize(&LOOP_fl, sizeof(struct Loop_), 100, 30); - ALLOCinitialize(&PCALL_fl, sizeof(struct Procedure_Call_), 100, 30); - ALLOCinitialize(&RET_fl, sizeof(struct Return_Statement_), 100, 30); - ALLOCinitialize(&INCR_fl, sizeof(struct Increment_), 100, 30); + + ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); + ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); + + ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); + ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); + + ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); + + ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); + + ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); + ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); + + ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); + + ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); + ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); + ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); + ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); + + ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); + + ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); + ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); + + ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); + + ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); + ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); + ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); + ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); + + ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); + + ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); + ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); + ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); + ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); + ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); + ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); + ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); + ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); + ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); } diff --git a/src/express/object.c b/src/express/object.c index 3aa76f2ec..f75e64274 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -30,84 +30,76 @@ #include "express/type.h" #include "express/expr.h" -Symbol *SCOPE_get_symbol(void *s); -Symbol *EXPRESS_get_symbol(void *e); -Symbol *RENAME_get_symbol(void *r); -Symbol *TYPE_get_symbol(void *t); -Symbol *EXP_get_symbol(void *e); -Symbol *WHERE_get_symbol(void *w); -Symbol *VAR_get_symbol(void *v); -Symbol *UNK_get_symbol(void *x); +Symbol * SCOPE_get_symbol( void *s ); +Symbol * EXPRESS_get_symbol( void *e ); +Symbol * RENAME_get_symbol( void *r ); +Symbol * TYPE_get_symbol( void *t ); +Symbol * EXP_get_symbol( void *e ); +Symbol * WHERE_get_symbol( void *w ); +Symbol * VAR_get_symbol( void *v ); +Symbol * UNK_get_symbol( void *x ); /* global Object type array */ struct Object OBJ[] = { [0] = {UNK_get_symbol, "of unknown type", 0}, - + [OBJ_VARIABLE] = {VAR_get_symbol, "variable", OBJ_VARIABLE_BITS}, [OBJ_ENTITY] = {SCOPE_get_symbol, "entity", OBJ_ENTITY_BITS}, - + [OBJ_EXPRESSION] = {EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS}, [OBJ_AMBIG_ENUM] = {EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS}, - + [OBJ_RULE] = {SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS}, [OBJ_PROCEDURE] = {SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS}, [OBJ_FUNCTION] = {SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS}, [OBJ_WHERE] = {WHERE_get_symbol, "where", OBJ_WHERE_BITS}, - + [OBJ_SCHEMA] = {SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS}, /* TODO: PASS should also have a symbol */ [OBJ_PASS] = {UNK_get_symbol, "pass", OBJ_PASS_BITS}, [OBJ_EXPRESS] = {EXPRESS_get_symbol, "express file", OBJ_UNUSED_BITS}, [OBJ_RENAME] = {RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS}, - + [OBJ_TYPE] = {TYPE_get_symbol, "type", OBJ_TYPE_BITS}, [OBJ_TAG] = {TYPE_get_symbol, "tag", OBJ_TYPE_BITS}, - + [OBJ_ALIAS] = {SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS }, [OBJ_INCREMENT] = {SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS }, {0} }; -Symbol *UNK_get_symbol(void *x) -{ +Symbol * UNK_get_symbol( void *x ) { (void) x; /* quell unused param warning; it appears that the prototype must match other functions */ - fprintf(stderr, "OBJget_symbol called on object of unknown type\n"); - ERRORabort(0); + fprintf( stderr, "OBJget_symbol called on object of unknown type\n" ); + ERRORabort( 0 ); return 0; } -Symbol *VAR_get_symbol(void *v) -{ - return &((Variable)v)->name->symbol; +Symbol * VAR_get_symbol( void *v ) { + return &( ( Variable )v )->name->symbol; } -Symbol *SCOPE_get_symbol(void *s) -{ - return &((Scope)s)->symbol; +Symbol * SCOPE_get_symbol( void *s ) { + return &( ( Scope )s )->symbol; } -Symbol *EXP_get_symbol(void *e) -{ - return &((Expression)e)->symbol; +Symbol * EXP_get_symbol( void *e ) { + return &( ( Expression )e )->symbol; } -Symbol *WHERE_get_symbol(void *w) -{ - return ((Where)w)->label; +Symbol * WHERE_get_symbol( void *w ) { + return ( ( Where )w )->label; } -Symbol *EXPRESS_get_symbol(void *e) -{ - return &((Express)e)->symbol; +Symbol * EXPRESS_get_symbol( void *e ) { + return &( ( Express )e )->symbol; } -Symbol *RENAME_get_symbol(void *r) -{ - return ((Rename *)r)->old; +Symbol * RENAME_get_symbol( void *r ) { + return ( ( Rename * )r )->old; } -Symbol *TYPE_get_symbol(void *t) -{ - return &((Type)t)->symbol; +Symbol * TYPE_get_symbol( void *t ) { + return &( ( Type )t )->symbol; } diff --git a/src/express/ordered_attrs.cc b/src/express/ordered_attrs.cc index ce3e2b08f..8081c16e3 100644 --- a/src/express/ordered_attrs.cc +++ b/src/express/ordered_attrs.cc @@ -15,20 +15,18 @@ oaList attrs; unsigned int attrIndex = 0; /// uses depth-first recursion to add attrs in order; looks for derived attrs -void populateAttrList(oaList &list, Entity ent) -{ +void populateAttrList( oaList & list, Entity ent ) { unsigned int attrCount = list.size(); //use to figure out how many attrs on end of list need to be checked for duplicates //recurse through supertypes - LISTdo(ent->u.entity->supertypes, super, Entity) { - populateAttrList(list, super); - } - LISTod + LISTdo( ent->u.entity->supertypes, super, Entity ) { + populateAttrList( list, super ); + } LISTod //then look at ent's own attrs, checking against attrs with index >= attrCount //derivation check only - leave deduplication for later - LISTdo(ent->u.entity->attributes, attr, Variable) { + LISTdo( ent->u.entity->attributes, attr, Variable ) { bool unique = true; - for(unsigned int i = attrCount; i < list.size(); i++) { - if(0 == strcasecmp(attr->name->symbol.name, list[i]->attr->name->symbol.name)) { + for( unsigned int i = attrCount; i < list.size(); i++ ) { + if( 0 == strcasecmp( attr->name->symbol.name, list[i]->attr->name->symbol.name ) ) { // an attr by this name exists in a supertype // originally printed a warning here, but that was misleading - they have more uses than I thought unique = false; @@ -36,68 +34,63 @@ void populateAttrList(oaList &list, Entity ent) break; } } - if(unique) { - orderedAttr *oa = new orderedAttr; - oa->attr = attr; - oa->creator = ent; - if(attr->initializer) { + if( unique ) { + orderedAttr * oa = new orderedAttr; + oa->attr=attr; + oa->creator=ent; + if( attr->initializer ) { // attrs derived by their owner are omitted from part 21 - section 10.2.3 oa->deriver = ent; } else { oa->deriver = 0; } oa->redefiner = 0; - list.push_back(oa); + list.push_back( oa ); } - } - LISTod + } LISTod } ///compare attr name and creator, remove all but first occurrence ///this is necessary for diamond inheritance -void dedupList(oaList &list) -{ +void dedupList( oaList & list ) { oaList::iterator it, jt; - for(it = list.begin(); it != list.end(); it++) { - for(jt = it + 1; jt != list.end(); jt++) { - if((0 == strcasecmp((* it)->attr->name->symbol.name, (* jt)->attr->name->symbol.name)) && - (0 == strcasecmp((* it)->creator->symbol.name, (* jt)->creator->symbol.name))) { + for( it = list.begin(); it != list.end(); it++ ) { + for( jt = it + 1; jt != list.end(); jt++ ) { + if( ( 0 == strcasecmp( ( * it )->attr->name->symbol.name, ( * jt )->attr->name->symbol.name ) ) && + ( 0 == strcasecmp( ( * it )->creator->symbol.name, ( * jt )->creator->symbol.name ) ) ) { //fprintf( stderr, "erasing %s created by %s\n", ( * jt )->attr->name->symbol.name, ( * jt )->creator->symbol.name ); jt--; - list.erase(jt + 1); + list.erase( jt + 1 ); } } } } /// set up ordered attrs for new entity -void orderedAttrsInit(Entity e) -{ +void orderedAttrsInit( Entity e ) { orderedAttrsCleanup(); attrIndex = 0; currentEntity = e; - if(currentEntity) { - populateAttrList(attrs, currentEntity); - if(attrs.size() > 1) { - dedupList(attrs); + if( currentEntity ) { + populateAttrList( attrs, currentEntity ); + if( attrs.size() > 1 ) { + dedupList( attrs ); } } } -void orderedAttrsCleanup() -{ - for(unsigned int i = 0; i < attrs.size(); i++) { +void orderedAttrsCleanup() { + for( unsigned int i = 0; i < attrs.size(); i++ ) { delete attrs[i]; } attrs.clear(); } -const orderedAttr *nextAttr() -{ - if(attrIndex < attrs.size()) { +const orderedAttr * nextAttr() { + if( attrIndex < attrs.size() ) { unsigned int i = attrIndex; attrIndex++; - return attrs.at(i); + return attrs.at( i ); } else { return 0; } diff --git a/src/express/resolve.c b/src/express/resolve.c index f4f1a233f..fa5797917 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -72,16 +72,14 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -extern void VAR_resolve_types(Variable v); +extern void VAR_resolve_types( Variable v ); /** Initialize the Fed-X second pass. */ -void RESOLVEinitialize(void) -{ +void RESOLVEinitialize( void ) { } /** Clean up the Fed-X second pass */ -void RESOLVEcleanup(void) -{ +void RESOLVEcleanup( void ) { } /** @@ -90,18 +88,17 @@ void RESOLVEcleanup(void) ** \param t_agg the current aggregate type ** \return the aggregate type */ -Type TYPE_retrieve_aggregate(Type t_select, Type t_agg) -{ - if(TYPEis_select(t_select)) { +Type TYPE_retrieve_aggregate( Type t_select, Type t_agg ) { + if( TYPEis_select( t_select ) ) { /* parse the underlying types */ - LISTdo_links(t_select->u.type->body->list, link) + LISTdo_links( t_select->u.type->body->list, link ) /* the current underlying type */ - Type t = (Type) link->data; - if(TYPEis_select(t)) { - t_agg = TYPE_retrieve_aggregate(t, t_agg); - } else if(TYPEis_aggregate(t)) { - if(t_agg) { - if(t_agg != t->u.type->body->base) { + Type t = ( Type ) link->data; + if( TYPEis_select( t ) ) { + t_agg = TYPE_retrieve_aggregate( t, t_agg ); + } else if( TYPEis_aggregate( t ) ) { + if( t_agg ) { + if( t_agg != t->u.type->body->base ) { /* 2 underlying types do not have to the same base */ return 0; } @@ -127,10 +124,9 @@ Type TYPE_retrieve_aggregate(Type t_select, Type t_agg) ** Resolve all references in an expression. ** \note the macro 'EXPresolve' calls this function after checking if expr is already resolved */ -void EXP_resolve(Expression expr, Scope scope, Type typecheck) -{ +void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { Function f = 0; - Symbol *sym; + Symbol * sym; void *x; Entity e; Type t; @@ -139,73 +135,73 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) /* if (expr == EXPRESSION_NULL) return; */ - switch(expr->type->u.type->body->type) { + switch( expr->type->u.type->body->type ) { case funcall_: /* functions with no arguments get handled elsewhere */ /* because the parser sees them just like attributes */ - x = SCOPEfind(scope, expr->symbol.name, - SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY); - if(!x) { - ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name); - resolve_failed(expr); + x = SCOPEfind( scope, expr->symbol.name, + SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY ); + if( !x ) { + ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name ); + resolve_failed( expr ); break; } - if((DICT_type != OBJ_FUNCTION) && (DICT_type != OBJ_ENTITY)) { - sym = OBJget_symbol(x, DICT_type); - ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name); - resolve_failed(expr); + if( ( DICT_type != OBJ_FUNCTION ) && ( DICT_type != OBJ_ENTITY ) ) { + sym = OBJget_symbol( x, DICT_type ); + ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name ); + resolve_failed( expr ); break; } /* original code accepted rules, too? */ /* entities are treated like implicit constructor functions */ - if(DICT_type == OBJ_ENTITY) { + if( DICT_type == OBJ_ENTITY ) { Type self_old = self; /* save previous in the unlikely but possible case that * SELF is in a derived initialization of an entity */ - e = (Entity)x; + e = ( Entity )x; self = e->u.entity->type; /* skip parameter resolution for now */ /* ARGresolve();*/ expr->return_type = e->u.entity->type; self = self_old; /* restore old SELF */ } else { - f = (Function)x; + f = ( Function )x; expr->return_type = f->u.func->return_type; /* do argument typechecking here if requested */ /* currently, we just check arg count; necessary */ /* to NVL code later which assumes args are present */ - if(LISTget_length(expr->u.funcall.list) != - f->u.func->pcount) { + if( LISTget_length( expr->u.funcall.list ) != + f->u.func->pcount ) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, - LISTget_length(expr->u.funcall.list), - f->u.func->pcount); + LISTget_length( expr->u.funcall.list ), + f->u.func->pcount ); } #ifdef future_work - if(EXPRESS_lint) { + if( EXPRESS_lint ) { /* verify parameters match function call */ } #endif /* should make this data-driven! */ - if(f == FUNC_NVL) { - EXPresolve((Expression)LISTget_first(expr->u.funcall.list), scope, typecheck); - EXPresolve((Expression)LISTget_second(expr->u.funcall.list), scope, typecheck); + if( f == FUNC_NVL ) { + EXPresolve( ( Expression )LISTget_first( expr->u.funcall.list ), scope, typecheck ); + EXPresolve( ( Expression )LISTget_second( expr->u.funcall.list ), scope, typecheck ); func_args_checked = true; } /* why is this here? (snc) */ - if(f == FUNC_USEDIN) { + if( f == FUNC_USEDIN ) { expr->return_type = Type_Bag_Of_Generic; } } - if(!func_args_checked) { - LISTdo(expr->u.funcall.list, param, Expression) - EXPresolve(param, scope, Type_Dont_Care); - if(is_resolve_failed(param)) { - resolve_failed(expr); + if( !func_args_checked ) { + LISTdo( expr->u.funcall.list, param, Expression ) + EXPresolve( param, scope, Type_Dont_Care ); + if( is_resolve_failed( param ) ) { + resolve_failed( expr ); break; } LISTod; @@ -213,48 +209,48 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) #if 0 /* add function or entity as first element of list */ - LISTadd_first(expr->u.list, x); + LISTadd_first( expr->u.list, x ); #endif - expr->u.funcall.function = (struct Scope_ *) x; + expr->u.funcall.function = ( struct Scope_ * ) x; - resolved_all(expr); + resolved_all( expr ); break; case aggregate_: - LISTdo(expr->u.list, elt, Expression) - EXPresolve(elt, scope, Type_Dont_Care); - if(is_resolve_failed(elt)) { - resolve_failed(expr); + LISTdo( expr->u.list, elt, Expression ) + EXPresolve( elt, scope, Type_Dont_Care ); + if( is_resolve_failed( elt ) ) { + resolve_failed( expr ); break; } LISTod; /* may have to do more work here! */ expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; case identifier_: x = 0; /* assume it's a variable/attribute */ - if(!x) { - x = VARfind(scope, expr->symbol.name, 0); + if( !x ) { + x = VARfind( scope, expr->symbol.name, 0 ); } /* if not found as a variable, try as function, etc ... */ - if(!x) { - x = SCOPEfind(scope, expr->symbol.name, - SCOPE_FIND_ANYTHING); + if( !x ) { + x = SCOPEfind( scope, expr->symbol.name, + SCOPE_FIND_ANYTHING ); } /* Not all enums have `typecheck->u.type->body->type` == `enumeration_` - ?! */ - if(!x) { + if( !x ) { Scope enumscope = scope; - while(1) { + while( 1 ) { /* look up locally, then go through the superscopes */ - x = DICTlookup(enumscope->enum_table, expr->symbol.name); - if(x) { + x = DICTlookup( enumscope->enum_table, expr->symbol.name ); + if( x ) { break; } - if(enumscope->type == OBJ_SCHEMA) { + if( enumscope->type == OBJ_SCHEMA ) { /* if we get here, this means that we've looked through all scopes */ x = 0; break; @@ -263,121 +259,121 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) } } - if(!x) { - if(typecheck == Type_Unknown) { + if( !x ) { + if( typecheck == Type_Unknown ) { return; } else { - ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name); - resolve_failed(expr); + ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name ); + resolve_failed( expr ); break; } } - switch(DICT_type) { + switch( DICT_type ) { case OBJ_VARIABLE: - expr->u.variable = (Variable)x; + expr->u.variable = ( Variable )x; #if 0 /* gee, I don't see what variables have to go through this right here */ - VARresolve_expressions(expr->u.variable, scope); - if(is_resolve_failed(expr->u.variable->name)) { - resolve_failed(expr); + VARresolve_expressions( expr->u.variable, scope ); + if( is_resolve_failed( expr->u.variable->name ) ) { + resolve_failed( expr ); break; } #endif /* Geez, don't wipe out original type! */ expr->return_type = expr->u.variable->type; - if(expr->u.variable->flags.attribute) { + if( expr->u.variable->flags.attribute ) { found_self = true; } - resolved_all(expr); + resolved_all( expr ); break; case OBJ_ENTITY: - expr->return_type = expr->type = ((Entity)x)->u.entity->type; + expr->return_type = expr->type = ( ( Entity )x )->u.entity->type; /* entity may not actually be resolved by now */ /* but I don't think that's a problem */ - resolved_all(expr); + resolved_all( expr ); break; case OBJ_EXPRESSION: /* so far only enumerations get returned this way */ - expr->u.expression = (Expression)x; - expr->type = expr->return_type = ((Expression)x)->type; - resolved_all(expr); + expr->u.expression = ( Expression )x; + expr->type = expr->return_type = ( ( Expression )x )->type; + resolved_all( expr ); break; case OBJ_FUNCTION: /* functions with no args end up here because the */ /* parser doesn't know any better */ expr->u.list = LISTcreate(); - LISTadd_last(expr->u.list, x); + LISTadd_last( expr->u.list, x ); expr->type = Type_Funcall; - expr->return_type = ((Function)x)->u.func->return_type; + expr->return_type = ( ( Function )x )->u.func->return_type; /* function may not actually be resolved by now */ /* but I don't think that's a problem */ - if(((Function)x)->u.func->pcount != 0) { + if( ( ( Function )x )->u.func->pcount != 0 ) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, 0, - f->u.func->pcount); - resolve_failed(expr); + f->u.func->pcount ); + resolve_failed( expr ); } else { - resolved_all(expr); + resolved_all( expr ); } break; case OBJ_TYPE: /* enumerations can appear here, I don't know about others */ - expr->type = (Type)x; - expr->return_type = (Type)x; + expr->type = ( Type )x; + expr->return_type = ( Type )x; expr->symbol.resolved = expr->type->symbol.resolved; break; default: - fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); + fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); break; } break; case op_: - expr->return_type = (*EXPop_table[expr->e.op_code].resolve)(expr, scope); + expr->return_type = ( *EXPop_table[expr->e.op_code].resolve )( expr, scope ); break; case entity_: /* only 'self' is seen this way */ case self_: - if(self) { + if( self ) { expr->return_type = self; /* we can't really call ourselves resolved, but we */ /* will be by the time we return, and besides, */ /* there's no way this will be accessed if the true */ /* entity fails resolution */ found_self = true; - resolved_all(expr); + resolved_all( expr ); } else { - ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol); - resolve_failed(expr); + ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol ); + resolve_failed( expr ); } break; case query_: - EXPresolve(expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care); + EXPresolve( expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care ); expr->return_type = expr->u.query->aggregate->return_type; /* verify that it's an aggregate */ - if(is_resolve_failed(expr->u.query->aggregate)) { - resolve_failed(expr); + if( is_resolve_failed( expr->u.query->aggregate ) ) { + resolve_failed( expr ); break; } - if(TYPEis_aggregate(expr->return_type)) { + if( TYPEis_aggregate( expr->return_type ) ) { t = expr->u.query->aggregate->return_type->u.type->body->base; - } else if(TYPEis_select(expr->return_type)) { + } else if( TYPEis_select( expr->return_type ) ) { /* retrieve the common aggregate type */ - t = TYPE_retrieve_aggregate(expr->return_type, 0); - if(!t) { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); - resolve_failed(expr); + t = TYPE_retrieve_aggregate( expr->return_type, 0 ); + if( !t ) { + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); + resolve_failed( expr ); break; } - } else if(TYPEis_runtime(expr->return_type)) { + } else if( TYPEis_runtime( expr->return_type ) ) { t = Type_Runtime; } else { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); - resolve_failed(expr); + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); + resolve_failed( expr ); break; } expr->u.query->local->type = t; expr->u.query->local->name->return_type = t; - EXPresolve(expr->u.query->expression, expr->u.query->scope, Type_Dont_Care); + EXPresolve( expr->u.query->expression, expr->u.query->scope, Type_Dont_Care ); expr->symbol.resolved = expr->u.query->expression->symbol.resolved; break; case integer_: @@ -388,62 +384,61 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) case logical_: case number_: expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; case attribute_: expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; default: - fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); + fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); } } -int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, Linked_List *flat) -{ +int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, Linked_List * flat ) { Entity ent_ref; int i = UNRESOLVED; - if(!expr) { - return (RESOLVED); - } else if(TYPEis_expression(expr->type)) { - i = ENTITYresolve_subtype_expression(expr->e.op1, ent, flat); - i |= ENTITYresolve_subtype_expression(expr->e.op2, ent, flat); - } else if(TYPEis_oneof(expr->type)) { - LISTdo(expr->u.list, sel, Expression) - i |= ENTITYresolve_subtype_expression(sel, ent, flat); + if( !expr ) { + return ( RESOLVED ); + } else if( TYPEis_expression( expr->type ) ) { + i = ENTITYresolve_subtype_expression( expr->e.op1, ent, flat ); + i |= ENTITYresolve_subtype_expression( expr->e.op2, ent, flat ); + } else if( TYPEis_oneof( expr->type ) ) { + LISTdo( expr->u.list, sel, Expression ) + i |= ENTITYresolve_subtype_expression( sel, ent, flat ); LISTod; } else { /* must be a simple entity reference */ - ent_ref = (Entity)SCOPEfind(ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY); - if(!ent_ref) { + ent_ref = ( Entity )SCOPEfind( ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY ); + if( !ent_ref ) { ERRORreport_with_symbol(UNKNOWN_SUBTYPE, &ent->symbol, - expr->symbol.name, ent->symbol.name); + expr->symbol.name, ent->symbol.name ); i = RESOLVE_FAILED; - } else if(DICT_type != OBJ_ENTITY) { - Symbol *sym = OBJget_symbol(ent_ref, DICT_type); + } else if( DICT_type != OBJ_ENTITY ) { + Symbol * sym = OBJget_symbol( ent_ref, DICT_type ); /* line number should really be on supertype name, */ /* but all we have easily is the entity line number */ ERRORreport_with_symbol(SUBTYPE_RESOLVE, &ent->symbol, - expr->symbol.name, sym->line); + expr->symbol.name, sym->line ); i = RESOLVE_FAILED; } else { bool found = false; /* link in to flat list */ - if(!*flat) { + if( !*flat ) { *flat = LISTcreate(); } - LISTdo(*flat, sub, Entity) - if(sub == ent_ref) { + LISTdo( *flat, sub, Entity ) + if( sub == ent_ref ) { found = true; break; } LISTod - if(!found) { - LISTadd_last(*flat, ent_ref); + if( !found ) { + LISTadd_last( *flat, ent_ref ); } /* link in to expression */ @@ -454,22 +449,22 @@ int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, L /* If the user said there was a subtype relationship but */ /* did not mention the reverse supertype relationship, */ /* complain (IS p. 44) */ - LISTdo(ent_ref->u.entity->supertypes, sup, Entity) - if(sup == ent) { + LISTdo( ent_ref->u.entity->supertypes, sup, Entity ) + if( sup == ent ) { found = true; break; } LISTod - if(!found) { - if(!ent_ref->u.entity->supertypes) { + if( !found ) { + if( !ent_ref->u.entity->supertypes ) { ent_ref->u.entity->supertypes = LISTcreate(); } - LISTadd_last(ent_ref->u.entity->supertypes, ent); + LISTadd_last( ent_ref->u.entity->supertypes, ent ); } #endif } } - return(i); + return( i ); } /** @@ -478,43 +473,42 @@ int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, L ** ** Resolve all references in a type. */ -void TYPE_resolve(Type *typeaddr /*, Scope scope*/) -{ +void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { Type type = *typeaddr; Type ref_type; TypeBody body = type->u.type->body; Scope scope = type->superscope; - if(body) { + if( body ) { /* complex type definition such as aggregates, enums, ... */ - resolve_in_progress(type); + resolve_in_progress( type ); - if(TYPEis_aggregate(type)) { - TYPEresolve(&body->base); + if( TYPEis_aggregate( type ) ) { + TYPEresolve( &body->base ); /* only really critical failure point for future use */ /* of this type is the base type, ignore others (above) */ type->symbol.resolved = body->base->symbol.resolved; - } else if(TYPEis_select(type)) { - LISTdo_links(body->list, link) - TYPEresolve((Type *)&link->data); - if(is_resolve_failed((Type)link->data)) { - resolve_failed(type); + } else if( TYPEis_select( type ) ) { + LISTdo_links( body->list, link ) + TYPEresolve( ( Type * )&link->data ); + if( is_resolve_failed( ( Type )link->data ) ) { + resolve_failed( type ); break; } LISTod; } - } else if(type->u.type->head) { + } else if( type->u.type->head ) { /* simple type definition such as "TYPE T = U" */ - resolve_in_progress(type); + resolve_in_progress( type ); - TYPEresolve(&type->u.type->head); + TYPEresolve( &type->u.type->head ); - if(!is_resolve_failed(type->u.type->head)) { - if(ERRORis_enabled(TYPE_IS_ENTITY)) { - if(TYPEis_entity(type->u.type->head)) { - ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name); - resolve_failed(type); + if( !is_resolve_failed( type->u.type->head ) ) { + if( ERRORis_enabled( TYPE_IS_ENTITY ) ) { + if( TYPEis_entity( type->u.type->head ) ) { + ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name ); + resolve_failed( type ); } } /* allow type ref's to be bypassed by caching true type */ @@ -527,14 +521,14 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) /* an attribute or formal parameter whose name is the same */ /* as its type, i.e. "foo : foo". unfortunately, babys like */ /* local variables get thrown out with the bathwater. -snc */ - ref_type = (Type)SCOPEfind(scope, type->symbol.name, - SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE); + ref_type = ( Type )SCOPEfind( scope, type->symbol.name, + SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE ); /* SCOPE_FIND_TYPE | SCOPE_FIND_ENTITY);*/ - if(!ref_type) { - ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name); + if( !ref_type ) { + ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name ); *typeaddr = Type_Bad; /* just in case */ - resolve_failed(type); - } else if(DICT_type == OBJ_TYPE) { + resolve_failed( type ); + } else if( DICT_type == OBJ_TYPE ) { /* due to declarations of multiple attributes off of a */ /* single type ref, we have to use reference counts */ /* to safely deallocate the TypeHead. It's trivial to do */ @@ -542,21 +536,21 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) /* if (type->refcount--) TYPE_destroy(type); */ type = *typeaddr = ref_type; - TYPEresolve(typeaddr); /* addr doesn't matter here */ + TYPEresolve( typeaddr ); /* addr doesn't matter here */ /* it will not be written through */ - } else if(DICT_type == OBJ_ENTITY) { + } else if( DICT_type == OBJ_ENTITY ) { /* if (type->refcount--) TYPE_destroy(type); see above */ - type = *typeaddr = ((Entity)ref_type)->u.entity->type; + type = *typeaddr = ( ( Entity )ref_type )->u.entity->type; } else { ERRORreport_with_symbol(NOT_A_TYPE, &type->symbol, type->symbol.name, - OBJget_type(DICT_type)); - resolve_failed(type); + OBJget_type( DICT_type ) ); + resolve_failed( type ); } } - if(!is_resolve_failed(type)) { - resolved_all(type); + if( !is_resolve_failed( type ) ) { + resolved_all( type ); } return; } @@ -567,15 +561,14 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) ** ** Resolve all references in a variable definition. */ -void VAR_resolve_expressions(Variable v, Entity entity /* was scope */) -{ - EXPresolve(v->name, entity, Type_Dont_Care); /* new!! */ +void VAR_resolve_expressions( Variable v, Entity entity /* was scope */ ) { + EXPresolve( v->name, entity, Type_Dont_Care ); /* new!! */ - if(v->initializer) { - EXPresolve(v->initializer, entity, v->type); + if( v->initializer ) { + EXPresolve( v->initializer, entity, v->type ); - if(is_resolve_failed(v->initializer)) { - resolve_failed(v->name); + if( is_resolve_failed( v->initializer ) ) { + resolve_failed( v->name ); } } } @@ -585,49 +578,48 @@ void VAR_resolve_expressions(Variable v, Entity entity /* was scope */) ** ** Resolve all references in a variable definition. */ -void VAR_resolve_types(Variable v) -{ +void VAR_resolve_types( Variable v ) { int failed = 0; - TYPEresolve(&v->type); - failed = is_resolve_failed(v->type); + TYPEresolve( &v->type ); + failed = is_resolve_failed( v->type ); - if(v->inverse_symbol && (!v->inverse_attribute)) { + if( v->inverse_symbol && ( !v->inverse_attribute ) ) { /* resolve inverse */ Variable attr; Type type = v->type; - if(TYPEis_aggregate(type)) { + if( TYPEis_aggregate( type ) ) { /* pull entity out of aggregate type defn for ... */ /* inverse var: set (or bag) of entity for ...; */ type = type->u.type->body->base; } - if(type->u.type->body->type != entity_) { + if( type->u.type->body->type != entity_ ) { ERRORreport_with_symbol(INVERSE_BAD_ENTITY, - &v->name->symbol, v->inverse_symbol->name); + &v->name->symbol, v->inverse_symbol->name ); } else { - attr = VARfind(type->u.type->body->entity, v->inverse_symbol->name, 1); - if(attr) { + attr = VARfind( type->u.type->body->entity, v->inverse_symbol->name, 1 ); + if( attr ) { v->inverse_attribute = attr; - failed |= is_resolve_failed(attr->name); + failed |= is_resolve_failed( attr->name ); } else { ERRORreport_with_symbol(INVERSE_BAD_ATTR, - v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name); + v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name ); } } /* symbol is no longer used here and could be gc'd */ /* but keep around anyway for ease in later reconstruction */ } - if(failed) { - resolve_failed(v->name); + if( failed ) { + resolve_failed( v->name ); } /* note: cannot set resolved bit since it has to be resolved again */ /* by VAR_resolve_expressions later on */ #if 0 else { - resolved_all(v->name); + resolved_all( v->name ); } #endif } @@ -639,10 +631,9 @@ void VAR_resolve_types(Variable v) ** Resolve all references in a statement. */ -void STMTlist_resolve(Linked_List list, Scope scope) -{ - LISTdo(list, s, Statement) - STMTresolve(s, scope); +void STMTlist_resolve( Linked_List list, Scope scope ) { + LISTdo( list, s, Statement ) + STMTresolve( s, scope ); LISTod; } @@ -653,100 +644,98 @@ void STMTlist_resolve(Linked_List list, Scope scope) * * Resolve all references in a case item */ -void CASE_ITresolve(Case_Item item, Scope scope, Statement statement) -{ +void CASE_ITresolve( Case_Item item, Scope scope, Statement statement ) { int validLabels = 0; - LISTdo(item->labels, e, Expression) { - EXPresolve(e, scope, statement->u.Case->selector->return_type); - if(e->return_type != Type_Bad) { + LISTdo( item->labels, e, Expression ) { + EXPresolve( e, scope, statement->u.Case->selector->return_type ); + if( e->return_type != Type_Bad ) { validLabels++; } } LISTod; - if(validLabels) { - STMTresolve(item->action, scope); + if( validLabels ) { + STMTresolve( item->action, scope ); } } -void STMTresolve(Statement statement, Scope scope) -{ +void STMTresolve( Statement statement, Scope scope ) { /* scope is always the function/procedure/rule from SCOPEresolve_expressions_statements(); */ Scope proc; - if(!statement) { + if( !statement ) { return; /* could be null statement */ } - switch(statement->type) { + switch( statement->type ) { case STMT_ALIAS: - EXPresolve(statement->u.alias->variable->initializer, scope, Type_Dont_Care); + EXPresolve( statement->u.alias->variable->initializer, scope, Type_Dont_Care ); statement->u.alias->variable->type = statement->u.alias->variable->initializer->type; - if(!is_resolve_failed(statement->u.alias->variable->initializer)) { - STMTlist_resolve(statement->u.alias->statements, statement->u.alias->scope); + if( !is_resolve_failed( statement->u.alias->variable->initializer ) ) { + STMTlist_resolve( statement->u.alias->statements, statement->u.alias->scope ); } break; case STMT_ASSIGN: - EXPresolve(statement->u.assign->lhs, scope, Type_Dont_Care); - EXPresolve(statement->u.assign->rhs, scope, statement->u.assign->lhs->type); + EXPresolve( statement->u.assign->lhs, scope, Type_Dont_Care ); + EXPresolve( statement->u.assign->rhs, scope, statement->u.assign->lhs->type ); break; case STMT_CASE: - EXPresolve(statement->u.Case->selector, scope, Type_Dont_Care); - LISTdo(statement->u.Case->cases, c, Case_Item) { - CASE_ITresolve(c, scope, statement); + EXPresolve( statement->u.Case->selector, scope, Type_Dont_Care ); + LISTdo( statement->u.Case->cases, c, Case_Item ) { + CASE_ITresolve( c, scope, statement ); } LISTod; break; case STMT_COMPOUND: - STMTlist_resolve(statement->u.compound->statements, scope); + STMTlist_resolve( statement->u.compound->statements, scope ); break; case STMT_COND: - EXPresolve(statement->u.cond->test, scope, Type_Dont_Care); - STMTlist_resolve(statement->u.cond->code, scope); - if(statement->u.cond->otherwise) { - STMTlist_resolve(statement->u.cond->otherwise, scope); + EXPresolve( statement->u.cond->test, scope, Type_Dont_Care ); + STMTlist_resolve( statement->u.cond->code, scope ); + if( statement->u.cond->otherwise ) { + STMTlist_resolve( statement->u.cond->otherwise, scope ); } break; case STMT_PCALL: #define proc_name statement->symbol.name - proc = (Scope)SCOPEfind(scope, proc_name, - SCOPE_FIND_PROCEDURE); - if(proc) { - if(DICT_type != OBJ_PROCEDURE) { - Symbol *newsym = OBJget_symbol(proc, DICT_type); - ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line); + proc = ( Scope )SCOPEfind( scope, proc_name, + SCOPE_FIND_PROCEDURE ); + if( proc ) { + if( DICT_type != OBJ_PROCEDURE ) { + Symbol * newsym = OBJget_symbol( proc, DICT_type ); + ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line ); } else { statement->u.proc->procedure = proc; } } else { - ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name); + ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name ); } - LISTdo(statement->u.proc->parameters, e, Expression) - EXPresolve(e, scope, Type_Dont_Care); + LISTdo( statement->u.proc->parameters, e, Expression ) + EXPresolve( e, scope, Type_Dont_Care ); LISTod; break; case STMT_LOOP: - if(statement->u.loop->scope) { + if( statement->u.loop->scope ) { /* resolve increment with old scope */ - EXPresolve(statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care); - EXPresolve(statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care); - EXPresolve(statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care); + EXPresolve( statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care ); + EXPresolve( statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care ); + EXPresolve( statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care ); /* resolve others with new scope! */ scope = statement->u.loop->scope; } - if(statement->u.loop->while_expr) { - EXPresolve(statement->u.loop->while_expr, scope, Type_Dont_Care); + if( statement->u.loop->while_expr ) { + EXPresolve( statement->u.loop->while_expr, scope, Type_Dont_Care ); } - if(statement->u.loop->until_expr) { - EXPresolve(statement->u.loop->until_expr, scope, Type_Dont_Care); + if( statement->u.loop->until_expr ) { + EXPresolve( statement->u.loop->until_expr, scope, Type_Dont_Care ); } - STMTlist_resolve(statement->u.loop->statements, scope); + STMTlist_resolve( statement->u.loop->statements, scope ); break; case STMT_RETURN: - if(statement->u.ret->value) { - EXPresolve(statement->u.ret->value, scope, Type_Dont_Care); + if( statement->u.ret->value ) { + EXPresolve( statement->u.ret->value, scope, Type_Dont_Care ); } break; case STMT_SKIP: @@ -756,87 +745,83 @@ void STMTresolve(Statement statement, Scope scope) } } -static Variable ENTITY_get_local_attribute(Entity e, char *name) -{ - LISTdo(e->u.entity->attributes, a, Variable) - if(!strcmp(VARget_simple_name(a), name)) { +static Variable ENTITY_get_local_attribute( Entity e, char * name ) { + LISTdo( e->u.entity->attributes, a, Variable ) + if( !strcmp( VARget_simple_name( a ), name ) ) { return a; } LISTod; return 0; } -void ENTITYresolve_expressions(Entity e) -{ +void ENTITYresolve_expressions( Entity e ) { Variable v; int status = 0; DictionaryEntry de; - char *sname; + char * sname; Entity sup; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } self = e->u.entity->type; - LISTdo(e->u.entity->attributes, attr, Variable) { - if(attr->name->type->u.type->body->type == op_) { + LISTdo( e->u.entity->attributes, attr, Variable ) { + if( attr->name->type->u.type->body->type == op_ ) { /* attribute redeclaration */ sname = attr->name->e.op1->e.op2->symbol.name; - if(!strcmp(sname, e->symbol.name) || - !(sup = ENTITYfind_inherited_entity(e, sname, 0))) { + if( !strcmp( sname, e->symbol.name ) || + !( sup = ENTITYfind_inherited_entity( e, sname, 0 ) ) ) { ERRORreport_with_symbol(REDECL_NO_SUCH_SUPERTYPE, &attr->name->e.op1->e.op2->symbol, attr->name->e.op1->e.op2->symbol.name, - VARget_simple_name(attr)); - resolve_failed(attr->name); + VARget_simple_name( attr ) ); + resolve_failed( attr->name ); } else { - sname = VARget_simple_name(attr); - if(!ENTITY_get_local_attribute(sup, sname)) { + sname = VARget_simple_name( attr ); + if( !ENTITY_get_local_attribute( sup, sname ) ) { ERRORreport_with_symbol(REDECL_NO_SUCH_ATTR, &attr->name->e.op2->symbol, sname, - sup->symbol.name); - resolve_failed(attr->name); + sup->symbol.name ); + resolve_failed( attr->name ); } /* should be ok to share this ptr */ attr->name->symbol.name = sname; } } else { /* new attribute declaration */ - LISTdo_n(e->u.entity->supertypes, supr, Entity, b) { - if(ENTITYget_named_attribute(supr, - attr->name->symbol.name)) { - ERRORreport_with_symbol(OVERLOADED_ATTR, - &attr->name->symbol, - attr->name->symbol.name, - supr->symbol.name); - resolve_failed(attr->name); - } - } - LISTod; + LISTdo_n( e->u.entity->supertypes, supr, Entity, b ) { + if( ENTITYget_named_attribute( supr, + attr->name->symbol.name ) ) { + ERRORreport_with_symbol(OVERLOADED_ATTR, + &attr->name->symbol, + attr->name->symbol.name, + supr->symbol.name ); + resolve_failed( attr->name ); + } + } LISTod; } - VARresolve_expressions(attr, e); - status |= is_resolve_failed(attr->name); - } - LISTod; - - DICTdo_type_init(e->symbol_table, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!is_resolve_failed(v->name)) { - TYPEresolve_expressions(v->type, e); - if(v->initializer) { - EXPresolve(v->initializer, e, v->type); - status |= is_resolve_failed(v->initializer); + VARresolve_expressions( attr, e ); + status |= is_resolve_failed( attr->name ); + } LISTod; + + DICTdo_type_init( e->symbol_table, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !is_resolve_failed( v->name ) ) { + TYPEresolve_expressions( v->type, e ); + if( v->initializer ) { + EXPresolve( v->initializer, e, v->type ); + status |= is_resolve_failed( v->initializer ); } } else { status = RESOLVE_FAILED; } } - if(!WHEREresolve(e->where, e, 1)) { + if( !WHEREresolve( e->where, e, 1 ) ) { status = RESOLVE_FAILED; } @@ -847,87 +832,80 @@ void ENTITYresolve_expressions(Entity e) -void ENTITYcheck_missing_supertypes(Entity ent) -{ +void ENTITYcheck_missing_supertypes( Entity ent ) { int found; /* Make sure each of my subtypes lists me as a supertype */ - LISTdo(ent->u.entity->subtypes, sub, Entity) { + LISTdo( ent->u.entity->subtypes, sub, Entity ) { found = false; - LISTdo_n(sub->u.entity->supertypes, sup, Entity, b) { - if(sup == ent) { + LISTdo_n( sub->u.entity->supertypes, sup, Entity, b ) { + if( sup == ent ) { found = true; break; } + } LISTod; + if( !found ) { + ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name ); + resolve_failed( sub ); } - LISTod; - if(!found) { - ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name); - resolve_failed(sub); - } - } - LISTod; + } LISTod; } /** calculate number of attributes inheritance, following up superclass chain */ -void ENTITYcalculate_inheritance(Entity e) -{ +void ENTITYcalculate_inheritance( Entity e ) { e->u.entity->inheritance = 0; - LISTdo(e->u.entity->supertypes, super, Entity) { - if(super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED) { - ENTITYcalculate_inheritance(super); + LISTdo( e->u.entity->supertypes, super, Entity ) { + if( super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED ) { + ENTITYcalculate_inheritance( super ); } - e->u.entity->inheritance += ENTITYget_size(super); + e->u.entity->inheritance += ENTITYget_size( super ); } LISTod } /** returns 1 if entity is involved in circularity, else 0 */ -int ENTITY_check_subsuper_cyclicity(Entity e, Entity enew) -{ +int ENTITY_check_subsuper_cyclicity( Entity e, Entity enew ) { /* just check subtypes - this implicitly checks supertypes */ /* as well */ - LISTdo(enew->u.entity->subtypes, sub, Entity) - if(e == sub) { - ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name); + LISTdo( enew->u.entity->subtypes, sub, Entity ) + if( e == sub ) { + ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name ); return 1; } - if(sub->search_id == __SCOPE_search_id) { + if( sub->search_id == __SCOPE_search_id ) { return 0; } sub->search_id = __SCOPE_search_id; - if(ENTITY_check_subsuper_cyclicity(e, sub)) { - ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name); + if( ENTITY_check_subsuper_cyclicity( e, sub ) ) { + ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name ); return 1; } LISTod; return 0; } -void ENTITYcheck_subsuper_cyclicity(Entity e) -{ +void ENTITYcheck_subsuper_cyclicity( Entity e ) { __SCOPE_search_id++; - (void) ENTITY_check_subsuper_cyclicity(e, e); + ( void ) ENTITY_check_subsuper_cyclicity( e, e ); } /** returns 1 if select type is involved in circularity, else 0 */ -int TYPE_check_select_cyclicity(TypeBody tb, Type tnew) -{ - LISTdo(tnew->u.type->body->list, item, Type) - if(item->u.type->body->type == select_) { - if(tb == item->u.type->body) { +int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { + LISTdo( tnew->u.type->body->list, item, Type ) + if( item->u.type->body->type == select_ ) { + if( tb == item->u.type->body ) { ERRORreport_with_symbol(SELECT_LOOP, - &item->symbol, item->symbol.name); + &item->symbol, item->symbol.name ); return 1; } - if(item->search_id == __SCOPE_search_id) { + if( item->search_id == __SCOPE_search_id ) { return 0; } item->search_id = __SCOPE_search_id; - if(TYPE_check_select_cyclicity(tb, item)) { + if( TYPE_check_select_cyclicity( tb, item ) ) { ERRORreport_with_symbol(SELECT_CONTINUATION, - &item->symbol, item->symbol.name); + &item->symbol, item->symbol.name ); return 1; } } @@ -935,115 +913,112 @@ int TYPE_check_select_cyclicity(TypeBody tb, Type tnew) return 0; } -void TYPEcheck_select_cyclicity(Type t) -{ - if(t->u.type->body->type == select_) { +void TYPEcheck_select_cyclicity( Type t ) { + if( t->u.type->body->type == select_ ) { __SCOPE_search_id++; - (void) TYPE_check_select_cyclicity(t->u.type->body, t); + ( void ) TYPE_check_select_cyclicity( t->u.type->body, t ); } } -void ENTITYresolve_types(Entity e); +void ENTITYresolve_types( Entity e ); /** also resolves inheritance counts and sub/super consistency */ -void SCOPEresolve_types(Scope s) -{ +void SCOPEresolve_types( Scope s ) { Variable var; DictionaryEntry de; void *x; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - DICTdo_init(s->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(DICT_type) { + DICTdo_init( s->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( DICT_type ) { case OBJ_TYPE: - if(ERRORis_enabled(SELECT_LOOP)) { - TYPEcheck_select_cyclicity((Type)x); + if( ERRORis_enabled( SELECT_LOOP ) ) { + TYPEcheck_select_cyclicity( ( Type )x ); } break; case OBJ_VARIABLE: /* really constants */ - var = (Variable)x; + var = ( Variable )x; /* before OBJ_BITS hack, we looked in s->superscope */ - TYPEresolve(&var->type); - if(is_resolve_failed(var->type)) { - resolve_failed(var->name); - resolve_failed(s); + TYPEresolve( &var->type ); + if( is_resolve_failed( var->type ) ) { + resolve_failed( var->name ); + resolve_failed( s ); } break; case OBJ_ENTITY: - ENTITYcheck_missing_supertypes((Entity)x); - ENTITYresolve_types((Entity)x); - ENTITYcalculate_inheritance((Entity)x); - if(ERRORis_enabled(SUBSUPER_LOOP)) { - ENTITYcheck_subsuper_cyclicity((Entity)x); + ENTITYcheck_missing_supertypes( ( Entity )x ); + ENTITYresolve_types( ( Entity )x ); + ENTITYcalculate_inheritance( ( Entity )x ); + if( ERRORis_enabled( SUBSUPER_LOOP ) ) { + ENTITYcheck_subsuper_cyclicity( ( Entity )x ); } - if(is_resolve_failed((Entity)x)) { - resolve_failed(s); + if( is_resolve_failed( ( Entity )x ) ) { + resolve_failed( s ); } break; case OBJ_SCHEMA: - if(is_not_resolvable((Schema)x)) { + if( is_not_resolvable( ( Schema )x ) ) { break; } - /*FALLTHRU*/ + /*FALLTHRU*/ case OBJ_PROCEDURE: case OBJ_RULE: case OBJ_FUNCTION: - SCOPEresolve_types((Scope)x); - if(is_resolve_failed((Scope)x)) { - resolve_failed(s); + SCOPEresolve_types( ( Scope )x ); + if( is_resolve_failed( ( Scope )x ) ) { + resolve_failed( s ); } break; default: break; } } - if(s->type == OBJ_FUNCTION) { - TYPEresolve(&s->u.func->return_type); + if( s->type == OBJ_FUNCTION ) { + TYPEresolve( &s->u.func->return_type ); } } /** for each supertype, find the entity it refs to */ -void ENTITYresolve_supertypes(Entity e) -{ +void ENTITYresolve_supertypes( Entity e ) { Entity ref_entity; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - if(e->u.entity->supertype_symbols) { + if( e->u.entity->supertype_symbols ) { e->u.entity->supertypes = LISTcreate(); } #if 0 - if(e->u.entity->supertype_symbols && !e->u.entity->supertypes) { + if( e->u.entity->supertype_symbols && !e->u.entity->supertypes ) { e->u.entity->supertypes = LISTcreate(); } #endif - LISTdo(e->u.entity->supertype_symbols, sym, Symbol *) { - ref_entity = (Entity)SCOPEfind(e->superscope, sym->name, SCOPE_FIND_ENTITY); - if(!ref_entity) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name); + LISTdo( e->u.entity->supertype_symbols, sym, Symbol * ) { + ref_entity = ( Entity )SCOPEfind( e->superscope, sym->name, SCOPE_FIND_ENTITY ); + if( !ref_entity ) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name ); /* ENTITY_resolve_failed = 1;*/ - resolve_failed(e); - } else if(DICT_type != OBJ_ENTITY) { - Symbol *newsym = OBJget_symbol(ref_entity, DICT_type); - ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line); + resolve_failed( e ); + } else if( DICT_type != OBJ_ENTITY ) { + Symbol * newsym = OBJget_symbol( ref_entity, DICT_type ); + ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line ); /* ENTITY_resolve_failed = 1;*/ - resolve_failed(e); + resolve_failed( e ); } else { bool found = false; - LISTadd_last(e->u.entity->supertypes, ref_entity); - if(is_resolve_failed(ref_entity)) { - resolve_failed(e); + LISTadd_last( e->u.entity->supertypes, ref_entity ); + if( is_resolve_failed( ref_entity ) ) { + resolve_failed( e ); } /* If the user said there was a supertype relationship but */ @@ -1051,36 +1026,33 @@ void ENTITYresolve_supertypes(Entity e) /* force it to be explicitly known by listing this entity */ /* in the ref'd entity's subtype list */ - LISTdo_n(ref_entity->u.entity->subtypes, sub, Entity, b) { - if(sub == e) { + LISTdo_n( ref_entity->u.entity->subtypes, sub, Entity, b ) { + if( sub == e ) { found = true; break; } - } - LISTod - if(!found) { - if(!ref_entity->u.entity->subtypes) { + } LISTod + if( !found ) { + if( !ref_entity->u.entity->subtypes ) { ref_entity->u.entity->subtypes = LISTcreate(); } - LISTadd_last(ref_entity->u.entity->subtypes, e); + LISTadd_last( ref_entity->u.entity->subtypes, e ); } } - } - LISTod; + } LISTod; } -void ENTITYresolve_subtypes(Entity e) -{ +void ENTITYresolve_subtypes( Entity e ) { int i; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - i = ENTITYresolve_subtype_expression(e->u.entity->subtype_expression, e, &e->u.entity->subtypes); - if(i & RESOLVE_FAILED) { - resolve_failed(e); + i = ENTITYresolve_subtype_expression( e->u.entity->subtype_expression, e, &e->u.entity->subtypes ); + if( i & RESOLVE_FAILED ) { + resolve_failed( e ); } } @@ -1090,86 +1062,80 @@ void ENTITYresolve_subtypes(Entity e) * where ref'd_attrs are either simple ids or SELF\entity.attr * where "entity" represents a supertype (only, I believe) */ -void ENTITYresolve_uniques(Entity e) -{ +void ENTITYresolve_uniques( Entity e ) { Variable attr, attr2 = 0; int failed = 0; - LISTdo(e->u.entity->unique, unique, Linked_List) { + LISTdo( e->u.entity->unique, unique, Linked_List ) { int i = 0; - LISTdo_links(unique, reflink) { + LISTdo_links( unique, reflink ) { Type old_self = self; Expression expr; /* skip first which is always the label (or NULL if no label) */ i++; - if(i == 1) { + if( i == 1 ) { continue; } - expr = (Expression) reflink->data; - assert(expr); + expr = ( Expression ) reflink->data; + assert( expr ); self = e->u.entity->type; - EXPresolve(expr, e, Type_Dont_Care); + EXPresolve( expr, e, Type_Dont_Care ); self = old_self; /* SELF\entity.attr, or just an attr name? */ - if((expr->e.op_code == OP_DOT) && - (expr->e.op1->e.op_code == OP_GROUP) && - (expr->e.op1->e.op1->type == Type_Self)) { - attr = ENTITYresolve_attr_ref(e, &(expr->e.op1->e.op2->symbol), &(expr->e.op2->symbol)); - attr2 = ENTITYresolve_attr_ref(e, 0, &(expr->e.op2->symbol)); + if( ( expr->e.op_code == OP_DOT ) && + ( expr->e.op1->e.op_code == OP_GROUP ) && + ( expr->e.op1->e.op1->type == Type_Self ) ) { + attr = ENTITYresolve_attr_ref( e, &( expr->e.op1->e.op2->symbol ), &( expr->e.op2->symbol ) ); + attr2 = ENTITYresolve_attr_ref( e, 0, &( expr->e.op2->symbol ) ); } else { - attr = ENTITYresolve_attr_ref(e, 0, &(expr->symbol)); + attr = ENTITYresolve_attr_ref( e, 0, &( expr->symbol ) ); } - if((attr2) && (attr != attr2) && (ENTITYdeclares_variable(e, attr2))) { + if( ( attr2 ) && ( attr != attr2 ) && ( ENTITYdeclares_variable( e, attr2 ) ) ) { /* attr exists in type + supertype - it's a redeclaration. * in this case, qualifiers are unnecessary; print a warning */ - ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &(expr->e.op2->symbol), expr->e.op2->symbol.name, e->symbol.name); + ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &( expr->e.op2->symbol ), expr->e.op2->symbol.name, e->symbol.name ); } - if(!attr) { + if( !attr ) { /* ERRORreport_with_symbol(ERROR_unknown_attr_in_entity,*/ /* aref->attribute, aref->attribute->name,*/ /* e->symbol.name);*/ failed = RESOLVE_FAILED; continue; } - if(ENTITYdeclares_variable(e, attr)) { + if( ENTITYdeclares_variable( e, attr ) ) { attr->flags.unique = 1; } - } - LISTod; - } - LISTod; + } LISTod; + } LISTod; e->symbol.resolved |= failed; } -void ENTITYresolve_types(Entity e) -{ +void ENTITYresolve_types( Entity e ) { int failed = 0; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - LISTdo(e->u.entity->attributes, att, Variable) { + LISTdo( e->u.entity->attributes, att, Variable ) { /* resolve in context of superscope to allow "X : X;" */ - VARresolve_types(att); - failed |= is_resolve_failed(att->name); - } - LISTod; + VARresolve_types( att ); + failed |= is_resolve_failed( att->name ); + } LISTod; /* * resolve the 'unique' list */ - ENTITYresolve_uniques(e); + ENTITYresolve_uniques( e ); /* don't wipe out any previous failure stat */ e->symbol.resolved |= failed; } /** resolve all expressions in type definitions */ -void TYPEresolve_expressions(Type t, Scope s) -{ +void TYPEresolve_expressions( Type t, Scope s ) { TypeBody body; /* meaning of self in a type declaration refers to the type itself, so */ @@ -1178,69 +1144,67 @@ void TYPEresolve_expressions(Type t, Scope s) self = t; /* recurse through base types */ - for(;; t = body->base) { - if(t->where) { - (void)WHEREresolve(t->where, s, 1); + for( ;; t = body->base ) { + if( t->where ) { + ( void )WHEREresolve( t->where, s, 1 ); } /* reached an indirect type definition, resolved elsewhere */ - if(t->u.type->head) { + if( t->u.type->head ) { break; } - if(!TYPEis_aggregate(t)) { + if( !TYPEis_aggregate( t ) ) { break; } body = t->u.type->body; - if(body->upper) { - EXPresolve(body->upper, s, Type_Dont_Care); + if( body->upper ) { + EXPresolve( body->upper, s, Type_Dont_Care ); } - if(body->lower) { - EXPresolve(body->lower, s, Type_Dont_Care); + if( body->lower ) { + EXPresolve( body->lower, s, Type_Dont_Care ); } - if(body->precision) { - EXPresolve(body->precision, s, Type_Dont_Care); + if( body->precision ) { + EXPresolve( body->precision, s, Type_Dont_Care ); } } self = self_old; } -int WHEREresolve(Linked_List list, Scope scope, int need_self) -{ +int WHEREresolve( Linked_List list, Scope scope, int need_self ) { int status = 0; - LISTdo(list, w, Where) + LISTdo( list, w, Where ) /* check if we've been here before */ /* i'm not sure why, but it happens */ status |= w->label->resolved; - if(w->label->resolved & (RESOLVED | RESOLVE_FAILED)) { + if( w->label->resolved & ( RESOLVED | RESOLVE_FAILED ) ) { break; } found_self = false; - EXPresolve(w->expr, scope, Type_Dont_Care); - if(need_self && ! found_self) { + EXPresolve( w->expr, scope, Type_Dont_Care ); + if( need_self && ! found_self ) { ERRORreport_with_symbol(MISSING_SELF, - w->label, - w->label->name); + w->label, + w->label->name ); w->label->resolved = RESOLVE_FAILED; } else { w->label->resolved = RESOLVED; } status |= w->label->resolved; LISTod - if(status == RESOLVE_FAILED) { + if( status == RESOLVE_FAILED ) { return 0; } else { return 1; } } -struct tag *TAGcreate_tags() -{ +struct tag * TAGcreate_tags() { extern int tag_count; - return((struct tag *)calloc(tag_count, sizeof(struct tag))); + return( ( struct tag * )calloc( tag_count, sizeof( struct tag ) ) ); } diff --git a/src/express/resolve2.c b/src/express/resolve2.c index e00e50e3c..bd5518595 100644 --- a/src/express/resolve2.c +++ b/src/express/resolve2.c @@ -7,91 +7,89 @@ #include "express/schema.h" #include "express/resolve.h" -void SCOPEresolve_subsupers(Scope scope) -{ +void SCOPEresolve_subsupers( Scope scope ) { DictionaryEntry de; void *x; char type; - Symbol *sym; + Symbol * sym; Type t; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(scope->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - scope->symbol.name, OBJget_type(scope->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( scope->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + scope->symbol.name, OBJget_type( scope->type ) ); } - DICTdo_init(scope->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(type = DICT_type) { + DICTdo_init( scope->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( type = DICT_type ) { case OBJ_ENTITY: - ENTITYresolve_supertypes((Entity)x); - ENTITYresolve_subtypes((Entity)x); + ENTITYresolve_supertypes( ( Entity )x ); + ENTITYresolve_subtypes( ( Entity )x ); break; case OBJ_FUNCTION: case OBJ_PROCEDURE: case OBJ_RULE: - SCOPEresolve_subsupers((Scope)x); + SCOPEresolve_subsupers( ( Scope )x ); break; case OBJ_TYPE: - t = (Type)x; - TYPEresolve(&t); + t = ( Type )x; + TYPEresolve( &t ); break; default: /* ignored everything else */ break; } - sym = OBJget_symbol(x, type); - if(is_resolve_failed_raw(sym)) { - resolve_failed(scope); + sym = OBJget_symbol( x, type ); + if( is_resolve_failed_raw( sym ) ) { + resolve_failed( scope ); } } } -void SCOPEresolve_expressions_statements(Scope s) -{ +void SCOPEresolve_expressions_statements( Scope s ) { DictionaryEntry de; void *x; Variable v; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - DICTdo_init(s->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(DICT_type) { + DICTdo_init( s->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( DICT_type ) { case OBJ_SCHEMA: - if(is_not_resolvable((Schema)x)) { + if( is_not_resolvable( ( Schema )x ) ) { break; } - SCOPEresolve_expressions_statements((Scope)x); + SCOPEresolve_expressions_statements( ( Scope )x ); break; case OBJ_ENTITY: - ENTITYresolve_expressions((Entity)x); + ENTITYresolve_expressions( ( Entity )x ); break; case OBJ_FUNCTION: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.func->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.func->body ); break; case OBJ_PROCEDURE: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.proc->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.proc->body ); break; case OBJ_RULE: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.rule->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.rule->body ); - WHEREresolve(RULEget_where((Scope)x), (Scope)x, 0); + WHEREresolve( RULEget_where( ( Scope )x ), ( Scope )x, 0 ); break; case OBJ_VARIABLE: - v = (Variable)x; - TYPEresolve_expressions(v->type, s); - if(v->initializer) { - EXPresolve(v->initializer, s, v->type); + v = ( Variable )x; + TYPEresolve_expressions( v->type, s ); + if( v->initializer ) { + EXPresolve( v->initializer, s, v->type ); } break; case OBJ_TYPE: - TYPEresolve_expressions((Type)x, s); + TYPEresolve_expressions( ( Type )x, s ); break; default: /* ignored everything else */ @@ -100,18 +98,17 @@ void SCOPEresolve_expressions_statements(Scope s) } } -void ALGresolve_expressions_statements(Scope s, Linked_List statements) -{ +void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { int status = 0; - if(print_objects_while_running & OBJ_ALGORITHM_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_ALGORITHM_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - SCOPEresolve_expressions_statements(s); - STMTlist_resolve(statements, s); + SCOPEresolve_expressions_statements( s ); + STMTlist_resolve( statements, s ); s->symbol.resolved = status; } diff --git a/src/express/schema.c b/src/express/schema.c index 7fc3d6899..5dd77873a 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -53,8 +53,7 @@ int __SCOPE_search_id = 0; /** Initialize the Schema module. */ -void SCHEMAinitialize(void) -{ +void SCHEMAinitialize( void ) { } @@ -74,125 +73,116 @@ void SCHEMAinitialize(void) */ void -SCHEMAdump(Schema schema, FILE *file) -{ - fprintf(file, "SCHEMA %s:\n", SCHEMAget_name(schema)); - SCOPEdump(schema, file); - fprintf(file, "END SCHEMA %s\n\n", SCHEMAget_name(schema)); +SCHEMAdump( Schema schema, FILE * file ) { + fprintf( file, "SCHEMA %s:\n", SCHEMAget_name( schema ) ); + SCOPEdump( schema, file ); + fprintf( file, "END SCHEMA %s\n\n", SCHEMAget_name( schema ) ); } #endif #if 0 -SYMBOLprint(Symbol *s) -{ - fprintf(stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename); +SYMBOLprint( Symbol * s ) { + fprintf( stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename ); } #endif -void SCHEMAadd_reference(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) -{ - Rename *r = REN_new(); +void SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { + Rename * r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = ref; - if(!cur_schema->u.schema->reflist) { + if( !cur_schema->u.schema->reflist ) { cur_schema->u.schema->reflist = LISTcreate(); } - LISTadd_last(cur_schema->u.schema->reflist, r); + LISTadd_last( cur_schema->u.schema->reflist, r ); } -void SCHEMAadd_use(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) -{ - Rename *r = REN_new(); +void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { + Rename * r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = use; - if(!cur_schema->u.schema->uselist) { + if( !cur_schema->u.schema->uselist ) { cur_schema->u.schema->uselist = LISTcreate(); } - LISTadd_last(cur_schema->u.schema->uselist, r); + LISTadd_last( cur_schema->u.schema->uselist, r ); } -void SCHEMAdefine_reference(Schema schema, Rename *r) -{ - Rename *old = 0; - char *name = (r->nnew ? r->nnew : r->old)->name; +void SCHEMAdefine_reference( Schema schema, Rename * r ) { + Rename * old = 0; + char * name = ( r->nnew ? r->nnew : r->old )->name; - if(!schema->u.schema->refdict) { - schema->u.schema->refdict = DICTcreate(20); + if( !schema->u.schema->refdict ) { + schema->u.schema->refdict = DICTcreate( 20 ); } else { - old = (Rename *)DICTlookup(schema->u.schema->refdict, name); + old = ( Rename * )DICTlookup( schema->u.schema->refdict, name ); } - if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { - DICTdefine(schema->u.schema->refdict, name, - r, r->old, OBJ_RENAME); + if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { + DICTdefine( schema->u.schema->refdict, name, + r, r->old, OBJ_RENAME ); } } -void SCHEMAdefine_use(Schema schema, Rename *r) -{ - Rename *old = 0; - char *name = (r->nnew ? r->nnew : r->old)->name; +void SCHEMAdefine_use( Schema schema, Rename * r ) { + Rename * old = 0; + char * name = ( r->nnew ? r->nnew : r->old )->name; - if(!schema->u.schema->usedict) { - schema->u.schema->usedict = DICTcreate(20); + if( !schema->u.schema->usedict ) { + schema->u.schema->usedict = DICTcreate( 20 ); } else { - old = (Rename *)DICTlookup(schema->u.schema->usedict, name); + old = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); } - if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { - DICTdefine(schema->u.schema->usedict, name, - r, r->old, OBJ_RENAME); + if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { + DICTdefine( schema->u.schema->usedict, name, + r, r->old, OBJ_RENAME ); } } -static void SCHEMA_get_entities_use(Scope scope, Linked_List result) -{ +static void SCHEMA_get_entities_use( Scope scope, Linked_List result ) { DictionaryEntry de; - Rename *rename; + Rename * rename; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return; } scope->search_id = __SCOPE_search_id; /* fully USE'd schema */ - LISTdo(scope->u.schema->use_schemas, schema, Schema) - SCOPE_get_entities(schema, result); - SCHEMA_get_entities_use(schema, result); + LISTdo( scope->u.schema->use_schemas, schema, Schema ) + SCOPE_get_entities( schema, result ); + SCHEMA_get_entities_use( schema, result ); LISTod /* partially USE'd schema */ - if(scope->u.schema->usedict) { - DICTdo_init(scope->u.schema->usedict, &de); - while(0 != (rename = (Rename *)DICTdo(&de))) { - LISTadd_last(result, rename->object); + if( scope->u.schema->usedict ) { + DICTdo_init( scope->u.schema->usedict, &de ); + while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { + LISTadd_last( result, rename->object ); } } } /** return use'd entities */ -Linked_List SCHEMAget_entities_use(Scope scope) -{ +Linked_List SCHEMAget_entities_use( Scope scope ) { Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_use(scope, result); - return(result); + SCHEMA_get_entities_use( scope, result ); + return( result ); } /** return ref'd entities */ -void SCHEMA_get_entities_ref(Scope scope, Linked_List result) -{ - Rename *rename; +void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { + Rename * rename; DictionaryEntry de; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return; } scope->search_id = __SCOPE_search_id; @@ -200,47 +190,45 @@ void SCHEMA_get_entities_ref(Scope scope, Linked_List result) ENTITY_MARK++; /* fully REF'd schema */ - LISTdo(scope->u.schema->ref_schemas, schema, Schema) - SCOPE_get_entities(schema, result); + LISTdo( scope->u.schema->ref_schemas, schema, Schema ) + SCOPE_get_entities( schema, result ); /* don't go down remote schema's ref_schemas */ LISTod /* partially REF'd schema */ - DICTdo_init(scope->u.schema->refdict, &de); - while(0 != (rename = (Rename *)DICTdo(&de))) { - if(DICT_type == OBJ_ENTITY) { - LISTadd_last(result, rename->object); + DICTdo_init( scope->u.schema->refdict, &de ); + while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { + if( DICT_type == OBJ_ENTITY ) { + LISTadd_last( result, rename->object ); } } } /** return ref'd entities */ -Linked_List SCHEMAget_entities_ref(Scope scope) -{ +Linked_List SCHEMAget_entities_ref( Scope scope ) { Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_ref(scope, result); - return(result); + SCHEMA_get_entities_ref( scope, result ); + return( result ); } /** * look up an attribute reference * if strict false, anything can be returned, not just attributes */ -Variable VARfind(Scope scope, char *name, int strict) -{ +Variable VARfind( Scope scope, char * name, int strict ) { Variable result; /* first look up locally */ - switch(scope->type) { + switch( scope->type ) { case OBJ_ENTITY: - result = ENTITYfind_inherited_attribute(scope, name, 0); - if(result) { - if(strict && (DICT_type != OBJ_VARIABLE)) { - fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); + result = ENTITYfind_inherited_attribute( scope, name, 0 ); + if( result ) { + if( strict && ( DICT_type != OBJ_VARIABLE ) ) { + fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); } return result; } @@ -248,14 +236,14 @@ Variable VARfind(Scope scope, char *name, int strict) case OBJ_INCREMENT: case OBJ_QUERY: case OBJ_ALIAS: - result = (Variable)DICTlookup(scope->symbol_table, name); - if(result) { - if(strict && (DICT_type != OBJ_VARIABLE)) { - fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); + result = ( Variable )DICTlookup( scope->symbol_table, name ); + if( result ) { + if( strict && ( DICT_type != OBJ_VARIABLE ) ) { + fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); } return result; } - return(VARfind(scope->superscope, name, strict)); + return( VARfind( scope->superscope, name, strict ) ); } return 0; } diff --git a/src/express/scope.c b/src/express/scope.c index f9193e6c5..3d93509d7 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -43,68 +43,62 @@ #include "express/scope.h" #include "express/resolve.h" -void SCOPEinitialize(void) -{ +void SCOPEinitialize( void ) { } /** * \sa SCOPEget_entities() */ -void SCOPE_get_entities(Scope scope, Linked_List result) -{ +void SCOPE_get_entities( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_ENTITY); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPEget_functions() */ -void SCOPE_get_functions(Scope scope, Linked_List result) -{ +void SCOPE_get_functions( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_FUNCTION); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPE_get_functions() */ -Linked_List SCOPEget_functions(Scope scope) -{ +Linked_List SCOPEget_functions( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_functions(scope, result); - return(result); + SCOPE_get_functions( scope, result ); + return( result ); } /** * \sa SCOPEget_rules() */ -void SCOPE_get_rules(Scope scope, Linked_List result) -{ +void SCOPE_get_rules( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_RULE); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_RULE ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPE_get_rules() */ -Linked_List SCOPEget_rules(Scope scope) -{ +Linked_List SCOPEget_rules( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_rules(scope, result); - return(result); + SCOPE_get_rules( scope, result ); + return( result ); } @@ -118,30 +112,28 @@ Linked_List SCOPEget_rules(Scope scope) ** SCOPEget_entities_superclass_order(), and should be used whenever ** the order of the entities on the list is not important. */ -Linked_List SCOPEget_entities(Scope scope) -{ +Linked_List SCOPEget_entities( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_entities(scope, result); - return(result); + SCOPE_get_entities( scope, result ); + return( result ); } /** * \sa SCOPEget_entities_superclass_order() */ -void SCOPE_dfs(Dictionary symbols, Entity root, Linked_List result) -{ +void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { Entity ent; - if((ENTITYget_mark(root) != ENTITY_MARK)) { - ENTITYput_mark(root, ENTITY_MARK); - LISTdo(ENTITYget_supertypes(root), super, Entity) + if( ( ENTITYget_mark( root ) != ENTITY_MARK ) ) { + ENTITYput_mark( root, ENTITY_MARK ); + LISTdo( ENTITYget_supertypes( root ), super, Entity ) /* if super explicitly defined in scope, recurse. */ /* this chops out USEd and REFd entities */ - if((ent = (Entity)DICTlookup(symbols, ENTITYget_name(super))) != ENTITY_NULL) { - SCOPE_dfs(symbols, ent, result); + if( ( ent = ( Entity )DICTlookup( symbols, ENTITYget_name( super ) ) ) != ENTITY_NULL ) { + SCOPE_dfs( symbols, ent, result ); } LISTod - LISTadd_last(result, root); + LISTadd_last( result, root ); } } @@ -154,15 +146,14 @@ void SCOPE_dfs(Dictionary symbols, Entity root, Linked_List result) ** \note The list returned is ordered such that an entity appears before all of its subtypes. ** \sa SCOPEget_entities() */ -Linked_List SCOPEget_entities_superclass_order(Scope scope) -{ +Linked_List SCOPEget_entities_superclass_order( Scope scope ) { Linked_List result; DictionaryEntry de; result = LISTcreate(); ++ENTITY_MARK; - SCOPEdo_entities(scope, e, de) - SCOPE_dfs(scope->symbol_table, e, result); + SCOPEdo_entities( scope, e, de ) + SCOPE_dfs( scope->symbol_table, e, result ); SCOPEod; return result; } @@ -172,20 +163,19 @@ Linked_List SCOPEget_entities_superclass_order(Scope scope) * note that object found is not actually checked, only because * caller is in a better position to describe the error with context */ -void *SCOPEfind(Scope scope, char *name, int type) -{ +void *SCOPEfind( Scope scope, char * name, int type ) { extern Dictionary EXPRESSbuiltins; /* procedures/functions */ void *x; __SCOPE_search_id++; - x = SCOPE_find(scope, name, type); - if(x) { + x = SCOPE_find( scope, name, type ); + if( x ) { return x; } - if(type & (SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE)) { - x = DICTlookup(EXPRESSbuiltins, name); + if( type & ( SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE ) ) { + x = DICTlookup( EXPRESSbuiltins, name ); } return x; } @@ -196,58 +186,57 @@ void *SCOPEfind(Scope scope, char *name, int type) * the supertype/subtype hierarchy * EH??? -> lookup an object when the current scope is not a schema */ -void *SCOPE_find(Scope scope, char *name, int type) -{ +void *SCOPE_find( Scope scope, char * name, int type ) { void *result; - Rename *rename; + Rename * rename; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return 0; } scope->search_id = __SCOPE_search_id; /* go up the superscopes, looking for object */ - while(1) { + while( 1 ) { /* first look up locally */ - result = DICTlookup(scope->symbol_table, name); - if(result && OBJtype_is_oneof(DICT_type, type)) { + result = DICTlookup( scope->symbol_table, name ); + if( result && OBJtype_is_oneof( DICT_type, type ) ) { return result; } - if(scope->type == OBJ_SCHEMA) { + if( scope->type == OBJ_SCHEMA ) { break; } scope = scope->superscope; } - if(type & (SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE)) { + if( type & ( SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE ) ) { /* Occurs in a fully USE'd schema? */ - LISTdo(scope->u.schema->use_schemas, schema, Schema) + LISTdo( scope->u.schema->use_schemas, schema, Schema ) /* follow chain'd USEs */ - if(schema == 0) { + if( schema == 0 ) { continue; } - result = SCOPE_find(schema, name, type); - if(result) { - return(result); + result = SCOPE_find( schema, name, type ); + if( result ) { + return( result ); } LISTod; /* Occurs in a partially USE'd schema? */ - rename = (Rename *)DICTlookup(scope->u.schema->usedict, name); - if(rename) { + rename = ( Rename * )DICTlookup( scope->u.schema->usedict, name ); + if( rename ) { DICT_type = rename->type; - return(rename->object); + return( rename->object ); } } /* Occurs in a fully REF'd schema? */ - LISTdo(scope->u.schema->ref_schemas, schema, Schema) - if(schema == 0) { + LISTdo( scope->u.schema->ref_schemas, schema, Schema ) + if( schema == 0 ) { continue; } - result = DICTlookup(schema->symbol_table, name); - if(result) { + result = DICTlookup( schema->symbol_table, name ); + if( result ) { return result; } else { continue; /* try another schema */ @@ -255,10 +244,10 @@ void *SCOPE_find(Scope scope, char *name, int type) LISTod; /* Occurs in a partially REF'd schema? */ - rename = (Rename *)DICTlookup(scope->u.schema->refdict, name); - if(rename) { + rename = ( Rename * )DICTlookup( scope->u.schema->refdict, name ); + if( rename ) { DICT_type = rename->type; - return(rename->object); + return( rename->object ); } return 0; diff --git a/src/express/stack.h b/src/express/stack.h index cb80180c9..d0d99e14f 100644 --- a/src/express/stack.h +++ b/src/express/stack.h @@ -75,4 +75,12 @@ typedef Linked_List Stack; /* function prototypes */ /***********************/ +/*******************************/ +/* inline function definitions */ +/*******************************/ + +#if supports_inline_functions || defined(STACK_C) + +#endif /* supports_inline_functions || defined(STACK_C) */ + #endif /* STACK_H */ diff --git a/src/express/stmt.c b/src/express/stmt.c index e5fd8ff5a..7f1579f25 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -45,20 +45,18 @@ Statement STATEMENT_ESCAPE = STATEMENT_NULL; Statement STATEMENT_SKIP = STATEMENT_NULL; -Statement STMTcreate(int type) -{ +Statement STMTcreate( int type ) { Statement s; s = STMT_new(); - SYMBOLset(s); + SYMBOLset( s ); s->type = type; return s; } /** Initialize the Statement module. */ -void STMTinitialize(void) -{ - STATEMENT_SKIP = STMTcreate(STMT_SKIP); - STATEMENT_ESCAPE = STMTcreate(STMT_ESCAPE); +void STMTinitialize( void ) { + STATEMENT_SKIP = STMTcreate( STMT_SKIP ); + STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE ); } /** @@ -68,10 +66,9 @@ void STMTinitialize(void) ** ** Create and return an assignment statement. */ -Statement ASSIGNcreate(Expression lhs, Expression rhs) -{ +Statement ASSIGNcreate( Expression lhs, Expression rhs ) { Statement s; - s = STMTcreate(STMT_ASSIGN); + s = STMTcreate( STMT_ASSIGN ); s->u.assign = ASSIGN_new(); s->u.assign->lhs = lhs; s->u.assign->rhs = rhs; @@ -85,15 +82,14 @@ Statement ASSIGNcreate(Expression lhs, Expression rhs) ** ** Create and return a case statement. */ -Statement CASEcreate(Expression selector, Linked_List cases) -{ +Statement CASEcreate( Expression selector, Linked_List cases ) { Statement s; - s = STMTcreate(STMT_CASE); + s = STMTcreate( STMT_CASE ); s->u.Case = CASE_new(); s->u.Case->selector = selector; s->u.Case->cases = cases; - return(s); + return( s ); } /** @@ -102,10 +98,9 @@ Statement CASEcreate(Expression selector, Linked_List cases) ** ** Create and return a compound statement. */ -Statement COMP_STMTcreate(Linked_List statements) -{ +Statement COMP_STMTcreate( Linked_List statements ) { Statement s; - s = STMTcreate(STMT_COMPOUND); + s = STMTcreate( STMT_COMPOUND ); s->u.compound = COMP_STMT_new(); s->u.compound->statements = statements; return s; @@ -119,15 +114,14 @@ Statement COMP_STMTcreate(Linked_List statements) ** ** Create and return an if statement. */ -Statement CONDcreate(Expression test, Linked_List then, Linked_List otherwise) -{ +Statement CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) { Statement s; - s = STMTcreate(STMT_COND); + s = STMTcreate( STMT_COND ); s->u.cond = COND_new(); s->u.cond->test = test; s->u.cond->code = then; s->u.cond->otherwise = otherwise; - return(s); + return( s ); } /** @@ -136,10 +130,9 @@ Statement CONDcreate(Expression test, Linked_List then, Linked_List otherwise) ** ** Create and return a procedure call statement. */ -Statement PCALLcreate(Linked_List parameters) -{ +Statement PCALLcreate( Linked_List parameters ) { Statement s; - s = STMTcreate(STMT_PCALL); + s = STMTcreate( STMT_PCALL ); s->u.proc = PCALL_new(); s->u.proc->parameters = parameters; return s; @@ -150,25 +143,23 @@ Statement PCALLcreate(Linked_List parameters) ** ** Create and return a loop statement. */ -Statement LOOPcreate(Scope scope, Expression while_expr, Expression until_expr, Linked_List statements) -{ - Statement s = STMTcreate(STMT_LOOP); +Statement LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_List statements ) { + Statement s = STMTcreate( STMT_LOOP ); s->u.loop = LOOP_new(); s->u.loop->scope = scope; s->u.loop->while_expr = while_expr; s->u.loop->until_expr = until_expr; s->u.loop->statements = statements; - return(s); + return( s ); } -Statement ALIAScreate(Scope scope, Variable variable, Linked_List statements) -{ - Statement s = STMTcreate(STMT_ALIAS); +Statement ALIAScreate( Scope scope, Variable variable, Linked_List statements ) { + Statement s = STMTcreate( STMT_ALIAS ); s->u.alias = ALIAS_new(); s->u.alias->scope = scope; s->u.alias->variable = variable; s->u.alias->statements = statements; - return(s); + return( s ); } /** @@ -180,14 +171,13 @@ Statement ALIAScreate(Scope scope, Variable variable, Linked_List statements) ** ** Create and return an increment control as specified. */ -Scope INCR_CTLcreate(Symbol *control, Expression start, - Expression end, Expression increment) -{ - Scope s = SCOPEcreate_tiny(OBJ_INCREMENT); - Expression e = EXPcreate_from_symbol(Type_Attribute, control); - Variable v = VARcreate(e, Type_Number); - DICTdefine(s->symbol_table, control->name, - v, control, OBJ_VARIABLE); +Scope INCR_CTLcreate( Symbol * control, Expression start, + Expression end, Expression increment ) { + Scope s = SCOPEcreate_tiny( OBJ_INCREMENT ); + Expression e = EXPcreate_from_symbol( Type_Attribute, control ); + Variable v = VARcreate( e, Type_Number ); + DICTdefine( s->symbol_table, control->name, + v, control, OBJ_VARIABLE ); s->u.incr = INCR_new(); s->u.incr->init = start; s->u.incr->end = end; @@ -200,9 +190,8 @@ Scope INCR_CTLcreate(Symbol *control, Expression start, ** \return the return statement created Create and return a return statement. */ -Statement RETcreate(Expression expression) -{ - Statement s = STMTcreate(STMT_RETURN); +Statement RETcreate( Expression expression ) { + Statement s = STMTcreate( STMT_RETURN ); s->u.ret = RET_new(); s->u.ret->value = expression; return s; diff --git a/src/express/symbol.c b/src/express/symbol.c index 2985cdcbe..ed71fb836 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -35,6 +35,5 @@ #include "express/symbol.h" /** Initialize the Symbol module */ -void SYMBOLinitialize(void) -{ +void SYMBOLinitialize( void ) { } diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 1c4fd7e90..6d2615a9b 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -4,17 +4,35 @@ if(SC_GENERATE_LP_SOURCES) include_directories("${PERPLEX_ExpScanner_INCLUDE_DIR}" "${LEMON_ExpParser_INCLUDE_DIR}") endif(SC_GENERATE_LP_SOURCES) -add_executable(test_expr driver.c test_expr.c) -target_link_libraries(test_expr express) +set(EXPRESS_CORE_OBJ + # base + $ + $ + $ + $ + + # global tables + $ + $ + + # AST creation + $ + $ + $ + + # deprecated + $ + $ +) + +add_executable(test_expr driver.c test_expr.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) -add_executable(test_express driver.c test_express.c) -target_link_libraries(test_express express) +add_executable(test_express driver.c test_express.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME express_rename_resolve COMMAND test_express express_rename_resolve) -add_executable(test_resolve driver.c test_resolve.c) -target_link_libraries(test_resolve express) +add_executable(test_resolve driver.c test_resolve.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME exp_resolve_bad_func_call COMMAND test_resolve exp_resolve_bad_func_call) add_test(NAME exp_resolve_func_call COMMAND test_resolve exp_resolve_func_call) @@ -25,24 +43,20 @@ add_test(NAME stmt_resolve_pcall_proc COMMAND test_resolve stmt_resolve_pcall_pr add_test(NAME scope_resolve_named_types COMMAND test_resolve scope_resolve_named_types) add_test(NAME entity_resolve_supertypes_entity COMMAND test_resolve entity_resolve_supertypes_entity) -add_executable(test_resolve2 driver.c test_resolve2.c) -target_link_libraries(test_resolve2 express) +add_executable(test_resolve2 driver.c test_resolve2.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME scope_resolve_expr_stmt COMMAND test_resolve2 scope_resolve_expr_stmt) add_test(NAME scope_resolve_subsupers COMMAND test_resolve2 scope_resolve_subsupers) -add_executable(test_schema driver.c test_schema.c) -target_link_libraries(test_schema express) +add_executable(test_schema driver.c test_schema.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME schema_define_ref COMMAND test_schema schema_define_ref) add_test(NAME schema_define_use COMMAND test_schema schema_define_use) add_test(NAME schema_get_entities_ref COMMAND test_schema schema_get_entities_ref) add_test(NAME var_find COMMAND test_schema var_find) -add_executable(test_scope driver.c test_scope.c) -target_link_libraries(test_scope express) +add_executable(test_scope driver.c test_scope.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME scope_find COMMAND test_scope scope_find) -add_executable(test_type driver.c test_type.c) -target_link_libraries(test_type express) +add_executable(test_type driver.c test_type.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME type_create_user_defined_tag COMMAND test_type type_create_user_defined_tag) add_test(NAME build_check_express diff --git a/src/express/test/driver.c b/src/express/test/driver.c index f53dbaf5c..d3e5f4dc5 100644 --- a/src/express/test/driver.c +++ b/src/express/test/driver.c @@ -8,40 +8,38 @@ extern struct test_def tests[]; -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { int status; - + /* enable libexpress allocator */ MEMORYinitialize(); FACTORYinitialize(); - + argc--; status = 0; - if(argc) { + if (argc) { int test_counter = argc; - + /* selected tests */ - for(int i = 1; i <= argc; i++) { - for(unsigned int j = 0; tests[j].name != NULL; j++) { + for (int i=1; i <= argc; i++) { + for (unsigned int j=0; tests[j].name != NULL; j++) { const char *test_name = tests[j].name; - int (*test_ptr)(void) = tests[j].testfunc; - - if(!strcmp(argv[i], test_name)) { + int (*test_ptr) (void) = tests[j].testfunc; + + if (!strcmp(argv[i], test_name)) { test_counter--; setup(); status |= test_ptr(); } } } - - if(test_counter) { + + if (test_counter) fprintf(stderr, "WARNING: some tests not found...\n"); - } } else { /* all tests */ - for(unsigned int j = 0; tests[j].name != NULL; j++) { - int (*test_ptr)(void) = tests[j].testfunc; + for (unsigned int j=0; tests[j].name != NULL; j++) { + int (*test_ptr) (void) = tests[j].testfunc; setup(); status |= test_ptr(); } diff --git a/src/express/test/driver.h b/src/express/test/driver.h index ba9acde42..0df5707cd 100644 --- a/src/express/test/driver.h +++ b/src/express/test/driver.h @@ -3,7 +3,7 @@ struct test_def { const char *name; - int (*testfunc)(void); + int (*testfunc) (void); }; void setup(); diff --git a/src/express/test/fff.h b/src/express/test/fff.h index 4f7135976..ecd19da4f 100644 --- a/src/express/test/fff.h +++ b/src/express/test/fff.h @@ -34,10 +34,10 @@ SOFTWARE. #define FFF_MAX_ARGS (20u) #ifndef FFF_ARG_HISTORY_LEN -#define FFF_ARG_HISTORY_LEN (50u) + #define FFF_ARG_HISTORY_LEN (50u) #endif #ifndef FFF_CALL_HISTORY_LEN -#define FFF_CALL_HISTORY_LEN (50u) + #define FFF_CALL_HISTORY_LEN (50u) #endif /* -- INTERNAL HELPER MACROS -- */ #define SET_RETURN_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ @@ -107,11 +107,11 @@ SOFTWARE. return FUNCNAME##_fake.return_val; \ #ifdef __cplusplus -#define FFF_EXTERN_C extern "C"{ -#define FFF_END_EXTERN_C } + #define FFF_EXTERN_C extern "C"{ + #define FFF_END_EXTERN_C } #else /* ansi c */ -#define FFF_EXTERN_C -#define FFF_END_EXTERN_C + #define FFF_EXTERN_C + #define FFF_END_EXTERN_C #endif /* cpp/ansi c */ #define DEFINE_RESET_FUNCTION(FUNCNAME) \ @@ -122,7 +122,7 @@ SOFTWARE. /* -- END INTERNAL HELPER MACROS -- */ typedef void (*fff_function_t)(void); -typedef struct { +typedef struct { fff_function_t call_history[FFF_CALL_HISTORY_LEN]; unsigned int call_history_idx; } fff_globals_t; @@ -182,7 +182,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC0(FUNCNAME) \ DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ DEFINE_FAKE_VOID_FUNC0(FUNCNAME) \ - + #define DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -227,7 +227,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -275,7 +275,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -326,7 +326,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -380,7 +380,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -437,7 +437,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -497,7 +497,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -560,7 +560,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -626,7 +626,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -695,7 +695,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -767,7 +767,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -842,7 +842,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -920,7 +920,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -1001,7 +1001,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -1085,7 +1085,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -1172,7 +1172,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -1262,7 +1262,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -1355,7 +1355,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -1451,7 +1451,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -1550,7 +1550,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -1652,7 +1652,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ FFF_EXTERN_C \ @@ -1702,7 +1702,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DEFINE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ - + #define DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -1755,7 +1755,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -1811,7 +1811,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -1870,7 +1870,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -1932,7 +1932,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -1997,7 +1997,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -2065,7 +2065,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -2136,7 +2136,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -2210,7 +2210,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -2287,7 +2287,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -2367,7 +2367,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -2450,7 +2450,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -2536,7 +2536,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -2625,7 +2625,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -2717,7 +2717,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -2812,7 +2812,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -2910,7 +2910,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -3011,7 +3011,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -3115,7 +3115,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -3222,7 +3222,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -3332,7 +3332,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -3374,7 +3374,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -3419,7 +3419,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -3467,7 +3467,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -3518,7 +3518,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -3572,7 +3572,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -3629,7 +3629,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -3689,7 +3689,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -3752,7 +3752,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -3818,7 +3818,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -3887,7 +3887,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -3959,7 +3959,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -4034,7 +4034,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -4112,7 +4112,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -4193,7 +4193,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -4277,7 +4277,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -4364,7 +4364,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -4454,7 +4454,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -4547,7 +4547,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -4643,7 +4643,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -4691,7 +4691,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -4742,7 +4742,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -4796,7 +4796,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -4853,7 +4853,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -4913,7 +4913,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -4976,7 +4976,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -5042,7 +5042,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -5111,7 +5111,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -5183,7 +5183,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -5258,7 +5258,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -5336,7 +5336,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -5417,7 +5417,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -5501,7 +5501,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -5588,7 +5588,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -5678,7 +5678,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -5771,7 +5771,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -5867,7 +5867,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -5966,7 +5966,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -6068,7 +6068,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + /* MSVC expand macro fix */ #define EXPAND(x) x diff --git a/src/express/test/print_attrs.c b/src/express/test/print_attrs.c index 99384de8e..881ada059 100644 --- a/src/express/test/print_attrs.c +++ b/src/express/test/print_attrs.c @@ -23,31 +23,29 @@ #include "ordered_attrs.h" #include -char *entityName, _buf[512] = { 0 }; +char * entityName, _buf[512] = { 0 }; /** prints usage info specific to print_attrs */ -void my_usage(void) -{ - EXPRESSusage(0); - printf(" ----\n\t-a : print attrs for \n"); - exit(2); +void my_usage(void) { + EXPRESSusage( 0 ); + printf( " ----\n\t-a : print attrs for \n" ); + exit( 2 ); } /** prints info about one attr */ -void describeAttr(const orderedAttr *oa) -{ - const char *visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; - const char *visibility, * descrip1 = "", * descrip2 = "", * descrip3 = 0; - if(oa->deriver) { - assert(0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute"); +void describeAttr( const orderedAttr * oa ) { + const char * visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; + const char * visibility, * descrip1="", * descrip2="", * descrip3=0; + if( oa->deriver ) { + assert( 0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute" ); descrip1 = "derived in "; descrip2 = oa->deriver->symbol.name; - if(oa->deriver == oa->creator) { + if( oa->deriver == oa->creator ) { visibility = hidden_p21; } else { visibility = explicit_derived; } - } else if(oa->attr->inverse_attribute) { + } else if( oa->attr->inverse_attribute ) { visibility = hidden_p21; descrip1 = "inverse of "; descrip2 = oa->attr->inverse_attribute->name->symbol.name; @@ -56,56 +54,53 @@ void describeAttr(const orderedAttr *oa) visibility = visible_p21; } printf("%s|%22s |%22s | %s%s%s%s\n", visibility, oa->attr->name->symbol.name, - oa->creator->symbol.name, descrip1, descrip2, ((descrip3) ? " in " : ""), ((descrip3) ? descrip3 : "")); + oa->creator->symbol.name, descrip1, descrip2, ( ( descrip3 ) ? " in " : "" ), ( ( descrip3 ) ? descrip3 : "" ) ); } -void print_attrs(Entity ent) -{ - const orderedAttr *oa; - const char *dashes = "--------------------------------------------------------------------------"; - printf("Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, - " In P21? | attr name | creator | detail", dashes); - orderedAttrsInit(ent); - while(0 != (oa = nextAttr())) { - describeAttr(oa); +void print_attrs( Entity ent ) { + const orderedAttr * oa; + const char * dashes="--------------------------------------------------------------------------"; + printf( "Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, + " In P21? | attr name | creator | detail", dashes ); + orderedAttrsInit( ent ); + while( 0 != ( oa = nextAttr() ) ) { + describeAttr( oa ); } orderedAttrsCleanup(); } -void find_and_print(Express model) -{ +void find_and_print( Express model ) { DictionaryEntry de; Schema s; Entity e; - DICTdo_init(model->symbol_table, &de); - while(0 != (s = (Schema) DICTdo(&de))) { - printf("Schema %s\n", s->symbol.name); - e = (Entity) DICTlookup(s->symbol_table, entityName); - if(e) { - print_attrs(e); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { + printf( "Schema %s\n", s->symbol.name ); + e = (Entity) DICTlookup( s->symbol_table, entityName ); + if( e ) { + print_attrs( e ); } } } /** reads arg setting entity name */ -int attr_arg(int i, char *arg) -{ - const char *src = arg; +int attr_arg( int i, char * arg ) { + const char * src = arg; int count = 0; - if((char)i == 'a') { + if( ( char )i == 'a' ) { entityName = _buf; - while(*src) { - _buf[count] = tolower(*src); + while( *src ) { + _buf[count] = tolower( *src ); src++; count++; - if(count == 511) { + if( count == 511 ) { break; } } - if(count == 0) { + if( count == 0 ) { entityName = 0; } - } else if(!entityName) { + } else if( !entityName ) { /* if libexpress comes across an unrecognized arg that isn't '-a', * and if the entityName isn't set, print usage and exit */ @@ -115,11 +110,10 @@ int attr_arg(int i, char *arg) } /** set the functions to be called by main() in libexpress */ -void EXPRESSinit_init() -{ +void EXPRESSinit_init() { entityName = 0; EXPRESSbackend = find_and_print; ERRORusage_function = my_usage; - strcat(EXPRESSgetopt_options, "a:"); + strcat( EXPRESSgetopt_options, "a:" ); EXPRESSgetopt = attr_arg; } diff --git a/src/express/test/print_schemas.c b/src/express/test/print_schemas.c index 3d3db9c1b..40bb0a1e0 100644 --- a/src/express/test/print_schemas.c +++ b/src/express/test/print_schemas.c @@ -15,23 +15,21 @@ #include "express/express.h" void -print_schemas(Express model) -{ +print_schemas( Express model ) { DictionaryEntry de; Schema s; - printf("File: %s\n ", model->u.express->filename); + printf( "File: %s\n ", model->u.express->filename ); - DICTdo_init(model->symbol_table, &de); - while(0 != (s = (Schema) DICTdo(&de))) { - printf("%s", s->symbol.name); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { + printf( "%s", s->symbol.name ); } - printf("\n"); - exit(0); + printf( "\n" ); + exit( 0 ); } -void EXPRESSinit_init() -{ +void EXPRESSinit_init() { EXPRESSbackend = print_schemas; } diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 8de1be0ab..72c4d3e14 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -17,7 +17,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -37,10 +37,9 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) -void setup() -{ +void setup() { EXPinitialize(); - + RESET_FAKE(EXPRESS_fail); RESET_FAKE(ENTITYfind_inherited_attribute); RESET_FAKE(ENTITYresolve_attr_ref); @@ -49,17 +48,15 @@ void setup() } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) -{ +void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) { (void) typ; - Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); + Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); exp->type = res_typ; exp->return_type = res_typ; exp->symbol.resolved = RESOLVED; } -int test_resolve_select_enum_member() -{ +int test_resolve_select_enum_member() { Schema scope; Symbol *e_type_id, *enum_id, *s_type_id; Type enum_typ, select_typ, chk_typ; @@ -74,56 +71,55 @@ int test_resolve_select_enum_member() s_type_id = SYMBOLcreate("sel1", 1, "test1"); e_type_id = SYMBOLcreate("enum1", 1, "test1"); enum_id = SYMBOLcreate("val1", 1, "test1"); - + enum_typ = TYPEcreate_name(e_type_id); enum_typ->symbol_table = DICTcreate(50); - + exp_enum_id = EXPcreate(enum_typ); exp_enum_id->symbol = *enum_id; exp_enum_id->u.integer = 1; - + tb = TYPEBODYcreate(enumeration_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_id); enum_typ->u.type->body = tb; - + DICT_define(scope->symbol_table, e_type_id->name, enum_typ, &enum_typ->symbol, OBJ_TYPE); - + /* TODO: OBJ_ENUM / OBJ_EXPRESSION are used interchangeably, this is confusing. */ DICT_define(scope->enum_table, exp_enum_id->symbol.name, exp_enum_id, &exp_enum_id->symbol, OBJ_EXPRESSION); DICT_define(enum_typ->symbol_table, enum_id->name, exp_enum_id, enum_id, OBJ_EXPRESSION); - + select_typ = TYPEcreate_name(s_type_id); tb = TYPEBODYcreate(select_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_typ); select_typ->u.type->body = tb; DICT_define(scope->symbol_table, s_type_id->name, select_typ, &select_typ->symbol, OBJ_TYPE); - + op1 = EXPcreate_from_symbol(Type_Identifier, s_type_id); op2 = EXPcreate_from_symbol(Type_Identifier, enum_id); - expr = BIN_EXPcreate(OP_DOT, op1, op2); + expr = BIN_EXPcreate(OP_DOT, op1, op2); /* * test: sel_ref '.' enum_id * expectation: enum_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_type_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == select_typ); assert(chk_typ == enum_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) -{ +void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) { (void) unused; Entity ent = DICTlookup(cxt->symbol_table, exp->symbol.name); Type typ = ent->u.entity->type; @@ -132,15 +128,13 @@ void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) exp->symbol.resolved = RESOLVED; } -Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) -{ +Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) { (void) grp_ref; Variable v = DICTlookup(ent->symbol_table, attr_ref->name); - return v; + return v; } -int test_resolve_entity_attribute() -{ +int test_resolve_entity_attribute() { Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -160,7 +154,7 @@ int test_resolve_entity_attribute() DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -168,29 +162,29 @@ int test_resolve_entity_attribute() var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); op1 = EXPcreate_from_symbol(Type_Identifier, e_type_id); op2 = EXPcreate_from_symbol(Type_Attribute, attr_id); expr = BIN_EXPcreate(OP_DOT, op1, op2); - + /* * test: entity_ref '.' attribute_id * expectation: attr_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_entity_handler; ENTITYresolve_attr_ref_fake.custom_fake = ENTITY_resolve_attr_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == ent->u.entity->type); assert(chk_typ == attr_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index ff51ec334..8ce3eb5e1 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -34,8 +34,8 @@ int yyerrstatus; /* * mock functions */ -typedef void *(*malloc_func_t)(size_t); -typedef void (*free_func_t)(void *); +typedef void * (*malloc_func_t) (size_t); +typedef void (*free_func_t) (void *); DEFINE_FFF_GLOBALS @@ -71,8 +71,7 @@ FAKE_VALUE_FUNC(char *, SCANstrdup, const char *) FAKE_VALUE_FUNC(perplex_t, perplexFileScanner, FILE *) FAKE_VALUE_FUNC(int, yylex, perplex_t) -void setup() -{ +void setup() { RESET_FAKE(RESOLVEinitialize); RESET_FAKE(SYMBOLinitialize); RESET_FAKE(SCOPEinitialize); @@ -105,8 +104,7 @@ void setup() RESET_FAKE(yylex); } -int test_express_rename_resolve() -{ +int test_express_rename_resolve() { Schema cur_schema, ref_schema; Rename *use_ref; Entity ent; @@ -116,17 +114,17 @@ int test_express_rename_resolve() ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->uselist = LISTcreate(); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + /* TODO: create RENcreate(...), refactor SCHEMAadd_use() */ use_ref = REN_new(); use_ref->schema_sym = ref_schema_id; @@ -135,9 +133,9 @@ int test_express_rename_resolve() use_ref->rename_type = use; LISTadd_last(cur_schema->u.schema->uselist, use_ref); use_ref->schema = ref_schema; - + RENAMEresolve(use_ref, cur_schema); - + assert(use_ref->type == OBJ_ENTITY); return 0; } diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index 9c974029c..2fc30ac68 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -19,12 +19,12 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; int EXPRESSpass; -struct Scope_ *FUNC_NVL; -struct Scope_ *FUNC_USEDIN; +struct Scope_ * FUNC_NVL; +struct Scope_ * FUNC_USEDIN; struct EXPop_entry EXPop_table[OP_LAST]; @@ -45,10 +45,9 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESOLVEinitialize(); - + RESET_FAKE(SCOPEfind); RESET_FAKE(VARfind); RESET_FAKE(VARget_simple_name); @@ -59,74 +58,69 @@ void setup() RESET_FAKE(EXPRESS_fail); } -void *SCOPEfind_handler(Scope scope, char *name, int type) -{ +void * SCOPEfind_handler(Scope scope, char * name, int type) { (void) type; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_bad_func_call() -{ +int test_exp_resolve_bad_func_call() { Schema scope; Symbol *func_id; Expression func_call; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - - SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved != RESOLVED); - + return 0; } -int test_exp_resolve_func_call() -{ +int test_exp_resolve_func_call() { Schema scope; Symbol *func_id; Expression func_call; Function func_def; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - + func_def = TYPEcreate_nostab(func_id, scope, OBJ_FUNCTION); - SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved == RESOLVED); assert(func_call->u.funcall.function == func_def); - + return 0; } -Variable VARfind_handler(Scope scope, char *name, int strict) -{ +Variable VARfind_handler(Scope scope, char *name, int strict) { (void) strict; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_local_identifier() -{ +int test_exp_resolve_local_identifier() { Schema scope; Entity ent; Expression ent_attr, ent_attr_ref; Symbol *attr_id, *attr_ref, *ent_id; Variable v_attr; Type attr_typ; - + scope = SCHEMAcreate(); - + ent_id = SYMBOLcreate("entity1", 1, "test_2"); - ent = ENTITYcreate(ent_id); + ent = ENTITYcreate(ent_id); DICT_define(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test_2"); @@ -135,35 +129,34 @@ int test_exp_resolve_local_identifier() v_attr = VARcreate(ent_attr, attr_typ); v_attr->flags.attribute = true; DICT_define(ent->symbol_table, attr_id->name, v_attr, attr_id, OBJ_VARIABLE); - + attr_ref = SYMBOLcreate("attr1", 1, "test_2"); ent_attr_ref = EXPcreate_from_symbol(Type_Identifier, attr_ref); - + VARfind_fake.custom_fake = VARfind_handler; - + EXP_resolve(ent_attr_ref, ent, Type_Dont_Care); - + assert(ent_attr_ref->u.variable == v_attr); assert(ent_attr_ref->symbol.resolved == RESOLVED); - + return 0; } -int test_entity_resolve_subtype_expr_entity() -{ +int test_entity_resolve_subtype_expr_entity() { Schema scope; Entity ent1, ent2; Expression subtype_exp; Symbol *ent1_id, *ent2_id, *ent2_ref; int chk; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); ent2_ref = SYMBOLcreate("ent2", 1, "test_3"); ent1 = ENTITYcreate(ent1_id); ent2 = ENTITYcreate(ent2_id); - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); @@ -171,26 +164,25 @@ int test_entity_resolve_subtype_expr_entity() ent1->superscope = scope; ent1->u.entity->subtypes = LISTcreate(); ent1->u.entity->subtype_expression = subtype_exp; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; chk = ENTITYresolve_subtype_expression(subtype_exp, ent1, &ent1->u.entity->subtypes); - + assert(chk == RESOLVED); - + return 0; } -int test_type_resolve_entity() -{ +int test_type_resolve_entity() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -200,62 +192,60 @@ int test_type_resolve_entity() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; TYPE_resolve(&sel); - + assert(sel->symbol.resolved == RESOLVED); - + return 0; } -int test_stmt_resolve_pcall_proc() -{ +int test_stmt_resolve_pcall_proc() { Schema scope; Function f; Procedure p; Statement s; Symbol *func_id, *proc_id, *proc_ref; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); proc_id = SYMBOLcreate("proc1", 1, "test_5"); proc_ref = SYMBOLcreate("proc1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + p = ALGcreate(OBJ_PROCEDURE); DICTdefine(f->symbol_table, proc_id->name, p, proc_id, OBJ_PROCEDURE); - + s = PCALLcreate(NULL); s->symbol = *proc_ref; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + STMTresolve(s, f); - + assert(s->u.proc->procedure == p); - + return 0; } -int test_scope_resolve_named_types() -{ +int test_scope_resolve_named_types() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); ent_id = SYMBOLcreate("ent", 1, "test_4"); - + ent_base = TYPEcreate(entity_); ent_base->symbol = *ent_id; ent_base->superscope = scope; @@ -266,27 +256,26 @@ int test_scope_resolve_named_types() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEresolve_types(scope); - + assert(!(ent->symbol.resolved & RESOLVE_FAILED)); assert(!(sel->symbol.resolved & RESOLVE_FAILED)); assert(!(scope->symbol.resolved & RESOLVE_FAILED)); - + return 0; } -int test_entity_resolve_supertypes() -{ +int test_entity_resolve_supertypes() { Schema scope; Entity ent1, ent2; Symbol *ent1_id, *ent2_id, *ent1_ref; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); @@ -295,19 +284,19 @@ int test_entity_resolve_supertypes() ent2 = ENTITYcreate(ent2_id); ent1->superscope = scope; ent2->superscope = scope; - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); - + ent2->u.entity->supertype_symbols = LISTcreate(); LISTadd_last(ent2->u.entity->supertype_symbols, ent1_ref); - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + ENTITYresolve_supertypes(ent2); assert(!(ent2->symbol.resolved & RESOLVE_FAILED)); - + return 0; } diff --git a/src/express/test/test_resolve2.c b/src/express/test/test_resolve2.c index 6fe469217..a293dce69 100644 --- a/src/express/test/test_resolve2.c +++ b/src/express/test/test_resolve2.c @@ -17,7 +17,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int EXPRESSpass; int yylineno; int print_objects_while_running; @@ -39,8 +39,7 @@ FAKE_VOID_FUNC(ENTITYresolve_expressions, Entity) FAKE_VALUE_FUNC(int, WHEREresolve, Linked_List, Scope, int) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(ENTITYresolve_supertypes); RESET_FAKE(ENTITYresolve_subtypes); RESET_FAKE(TYPE_resolve); @@ -52,17 +51,16 @@ void setup() RESET_FAKE(EXPRESS_fail); } -int test_scope_resolve_expr_stmt() -{ +int test_scope_resolve_expr_stmt() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -72,29 +70,28 @@ int test_scope_resolve_expr_stmt() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_expressions_statements(scope); - + assert(ENTITYresolve_expressions_fake.call_count == 1); assert(TYPEresolve_expressions_fake.call_count == 1); - + return 0; } -int test_scope_resolve_subsupers() -{ +int test_scope_resolve_subsupers() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -104,16 +101,16 @@ int test_scope_resolve_subsupers() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_subsupers(scope); - + assert(TYPE_resolve_fake.call_count == 1); assert(ENTITYresolve_supertypes_fake.call_count == 1); assert(ENTITYresolve_subtypes_fake.call_count == 1); - + return 0; } diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c index 106e9cca5..80fe0eadc 100644 --- a/src/express/test/test_schema.c +++ b/src/express/test/test_schema.c @@ -17,7 +17,7 @@ /* * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int ENTITY_MARK; @@ -33,15 +33,13 @@ FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) FAKE_VOID_FUNC(SCOPE_get_entities, Scope, Linked_List) FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail) RESET_FAKE(SCOPE_get_entities) RESET_FAKE(ENTITYfind_inherited_attribute) } -int test_schema_define_ref() -{ +int test_schema_define_ref() { Schema cur_schema, ref_schema; Rename *ref_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -49,31 +47,30 @@ int test_schema_define_ref() cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; ref_rename->nnew = ent_ref; ref_rename->rename_type = ref; ref_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_reference(cur_schema, ref_rename); - + assert(cur_schema->u.schema->refdict->KeyCount == 1); - + return 0; } -int test_schema_define_use() -{ +int test_schema_define_use() { Schema cur_schema, ref_schema; Rename *use_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -81,35 +78,34 @@ int test_schema_define_use() cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->usedict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + use_rename = REN_new(); use_rename->schema_sym = ref_schema_id; use_rename->old = ent_ref; use_rename->nnew = ent_ref; use_rename->rename_type = use; use_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_use(cur_schema, use_rename); - + assert(cur_schema->u.schema->usedict->KeyCount == 1); - + return 0; } -/* TODO: +/* TODO: * currently this function expects OBJ_RENAME stored as OBJ_ENTITY * (to indicate partial reference) */ -int test_schema_get_entities_ref() -{ +int test_schema_get_entities_ref() { Schema cur_schema, ref_schema; Rename *ref_rename; Entity ent; @@ -120,17 +116,17 @@ int test_schema_get_entities_ref() ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; @@ -138,19 +134,19 @@ int test_schema_get_entities_ref() ref_rename->rename_type = ref; ref_rename->schema = ref_schema; ref_rename->object = ent; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); + r = LISTcreate(); cur_schema->search_id = -1; SCHEMA_get_entities_ref(cur_schema, r); - + assert(LISTget_length(r) == 1); - + return 0; } -Variable -ENTITY_find_attr_handler(struct Scope_ *entity, char *name, struct Symbol_ **down_sym) +Variable +ENTITY_find_attr_handler(struct Scope_ *entity, char * name, struct Symbol_** down_sym) { Variable r; (void) down_sym; @@ -158,8 +154,7 @@ ENTITY_find_attr_handler(struct Scope_ *entity, char *name, struct Symbol_ **dow return r; } -int test_var_find() -{ +int test_var_find() { Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -176,7 +171,7 @@ int test_var_find() DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -184,16 +179,16 @@ int test_var_find() var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); - DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); - + DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); + ENTITYfind_inherited_attribute_fake.custom_fake = ENTITY_find_attr_handler; - + var_ref = VARfind(ent, "attr1", 1); - + assert(var_ref != NULL); - + return 0; } diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c index 17ac6bc81..b59ef4acc 100644 --- a/src/express/test/test_scope.c +++ b/src/express/test/test_scope.c @@ -15,7 +15,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -33,22 +33,20 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail); } -int test_scope_find() -{ +int test_scope_find() { Schema scope; Type sel, ent_base, chk_sel; Entity ent, chk_ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -58,19 +56,19 @@ int test_scope_find() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); - + scope->search_id = -1; chk_sel = SCOPE_find(scope, "sel_typ", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + scope->search_id = -1; chk_ent = SCOPE_find(scope, "ent", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + assert(chk_sel == sel); assert(chk_ent == ent); - + return 0; } diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c index 419d03a7e..94b1f8b5a 100644 --- a/src/express/test/test_type.c +++ b/src/express/test/test_type.c @@ -15,7 +15,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int tag_count; @@ -29,35 +29,33 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail) TYPEinitialize(); } -int test_type_create_user_defined_tag() -{ +int test_type_create_user_defined_tag() { Schema scope; Function f; Type t, g, chk; Symbol *func_id, *tag_id; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); tag_id = SYMBOLcreate("item1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); f->symbol = *func_id; DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + g = TYPEcreate(generic_); t = TYPEcreate_nostab(tag_id, f, OBJ_TAG); - + chk = TYPEcreate_user_defined_tag(g, f, tag_id); - + assert(chk == t); - + return 0; } diff --git a/src/express/token_type.h b/src/express/token_type.h index 6c2bf2240..03cd99ab5 100644 --- a/src/express/token_type.h +++ b/src/express/token_type.h @@ -60,11 +60,11 @@ typedef union YYSTYPE { Linked_List list; Logical logical; Op_Code op_code; - Qualified_Attr *qualified_attr; + Qualified_Attr * qualified_attr; Real rVal; Statement statement; - Symbol *symbol; - char *string; + Symbol * symbol; + char * string; Type type; TypeBody typebody; Variable variable; diff --git a/src/express/type.c b/src/express/type.c index 838ce6a29..ffcba5915 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -126,21 +126,20 @@ This module implements the type abstraction. It is #include "express/type.h" -Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) -{ +Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) { Type t; extern int tag_count; - t = (Type)DICTlookup(scope->symbol_table, symbol->name); - if(t) { - if(DICT_type == OBJ_TAG) { - return(t); + t = ( Type )DICTlookup( scope->symbol_table, symbol->name ); + if( t ) { + if( DICT_type == OBJ_TAG ) { + return( t ); } else { /* easiest to just generate the error this way! * following call WILL fail intentionally */ - DICTdefine(scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG); - return(0); + DICTdefine( scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG ); + return( 0 ); } } @@ -148,22 +147,22 @@ Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) * if we are outside a formal parameter list (hack, hack) * then we can only refer to existing tags, so produce an error */ - if(tag_count < 0) { - ERRORreport_with_symbol(UNDEFINED_TAG, symbol, - symbol->name); - return(0); + if( tag_count < 0 ) { + ERRORreport_with_symbol( UNDEFINED_TAG, symbol, + symbol->name ); + return( 0 ); } /* otherwise, we're in a formal parameter list, * so it's ok to define it */ - t = TYPEcreate_nostab(symbol, scope, OBJ_TAG); + t = TYPEcreate_nostab( symbol, scope, OBJ_TAG ); t->u.type->head = base; /* count unique type tags inside PROC and FUNC headers */ tag_count++; - return(t); + return( t ); } /** @@ -172,63 +171,60 @@ Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) */ #define TYPE_inherits_from(t,e) ((t) && TYPEinherits_from((t),(e))) -bool TYPEinherits_from(Type t, enum type_enum e) -{ +bool TYPEinherits_from( Type t, enum type_enum e ) { TypeBody tb = t->u.type->body; - assert((t->type == OBJ_TYPE) && (tb) && "Not a Type!"); - switch(e) { + assert( ( t->type == OBJ_TYPE ) && ( tb ) && "Not a Type!" ); + switch( e ) { case aggregate_: - if(tb->type == aggregate_ || + if( tb->type == aggregate_ || tb->type == array_ || tb->type == bag_ || tb->type == set_ || - tb->type == list_) { + tb->type == list_ ) { return true; } else { - return(TYPE_inherits_from(tb->base, e)); + return( TYPE_inherits_from( tb->base, e ) ); } case array_: - return((tb->type == array_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == array_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case bag_: - return((tb->type == bag_ || - tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == bag_ || + tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case set_: - return((tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case list_: - return((tb->type == list_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == list_ ) ? true : TYPE_inherits_from( tb->base, e ) ); default: break; } - return (tb->type == e); + return ( tb->type == e ); } #if 0 case binary_: -return((t->type == binary_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == binary_ ) ? true : TYPEinherits_from( t->base, e ) ); case integer_: -return((t->type == integer_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == integer_ ) ? true : TYPEinherits_from( t->base, e ) ); case real_: -return((t->type == real_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == real_ ) ? true : TYPEinherits_from( t->base, e ) ); case string_: -return((t->type == string_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == string_ ) ? true : TYPEinherits_from( t->base, e ) ); case logical_: -return((t->type == logical_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == logical_ ) ? true : TYPEinherits_from( t->base, e ) ); case boolean_: -return((t->type == boolean_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == boolean_ ) ? true : TYPEinherits_from( t->base, e ) ); default: -return(false); +return( false ); } } #endif /** Initialize the Type module */ -void TYPEinitialize() -{ +void TYPEinitialize() { } /** Clean up the Type module */ -void TYPEcleanup(void) -{ +void TYPEcleanup( void ) { } /** @@ -236,9 +232,8 @@ void TYPEcleanup(void) * \return the base type of the aggregate type * Retrieve the base type of an aggregate. */ -Type TYPEget_nonaggregate_base_type(Type t) -{ - while(TYPEis_aggregate(t)) { +Type TYPEget_nonaggregate_base_type( Type t ) { + while( TYPEis_aggregate( t ) ) { t = t->u.type->body->base; } return t; diff --git a/src/express/variable.c b/src/express/variable.c index e99ca0b6f..b3ec9f88a 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -87,31 +87,29 @@ #include "express/variable.h" #include "express/object.h" -char *opcode_print(Op_Code o); +char * opcode_print( Op_Code o ); /** Initialize the Variable module. */ -void VARinitialize() -{ +void VARinitialize() { } /** VARget_simple_name * returns simple name of variable * for example, if var is named SELF\xxx.yyy, return yyy */ -extern char *VARget_simple_name(Variable v) -{ - Expression e = VARget_name(v); +extern char * VARget_simple_name( Variable v ) { + Expression e = VARget_name( v ); - while(TYPEis_expression(EXPget_type(e))) { - switch(e->e.op_code) { + while( TYPEis_expression( EXPget_type( e ) ) ) { + switch( e->e.op_code ) { case OP_DOT: case OP_GROUP: e = e->e.op2; break; default: - fprintf(stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print(e->e.op_code)); + fprintf( stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print( e->e.op_code ) ); abort(); } } - return EXPget_name(e); + return EXPget_name( e ); } diff --git a/src/test/SEarritr.h b/src/test/SEarritr.h index bf1214c20..f84b6fbb8 100644 --- a/src/test/SEarritr.h +++ b/src/test/SEarritr.h @@ -17,42 +17,36 @@ // Best used in the form: for (SEitr=0; !SEitr; ++SEitr) { ... } // (this for loop walks the whole array) -class SEarrIterator -{ +class SEarrIterator { private: - const STEPentity **SEarr; // Array of pointers to STEPentity's + const STEPentity ** SEarr; // Array of pointers to STEPentity's int index; // current index int size; // size of array public: // Construct the iterator with a given array and its size - SEarrIterator(const STEPentity **entarr, int sz) - { + SEarrIterator( const STEPentity ** entarr, int sz ) { SEarr = entarr; index = 0; size = sz; } // set the value of the index: SEitr = 3 - void operator= (int newindex) - { + void operator= ( int newindex ) { index = newindex; } // check if we're out of range: if (!SEitr)... - int operator!() - { - return (index < size); + int operator!() { + return ( index < size ); } // return current element: SEptr = SEitr() - STEPentity *operator()() - { - return (STEPentity *)SEarr[index]; + STEPentity * operator()() { + return ( STEPentity * )SEarr[index]; } // PREFIX increment operator: ++SEitr - int operator++ () - { + int operator++ () { index++; return operator!(); } diff --git a/src/test/generate_express/generate_express.cc b/src/test/generate_express/generate_express.cc index 404929f4f..a6cb1ef29 100644 --- a/src/test/generate_express/generate_express.cc +++ b/src/test/generate_express/generate_express.cc @@ -12,44 +12,43 @@ /******************** main() ****************************/ -main() -{ +main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // "Reset" has tables for browsing registry->ResetSchemas(); - const SchemaDescriptor *schema = 0; + const SchemaDescriptor * schema = 0; - SchemaDescriptor *schema2 = 0; - schema = (SchemaDescriptor *)registry->FindSchema("Example_Schema"); - EntityDescriptor *ed = (EntityDescriptor *)registry->FindEntity("Circle"); + SchemaDescriptor * schema2 = 0; + schema = ( SchemaDescriptor * )registry->FindSchema( "Example_Schema" ); + EntityDescriptor * ed = ( EntityDescriptor * )registry->FindEntity( "Circle" ); Uniqueness_rule_ptr ur = new Uniqueness_rule; - ur->comment_("(* Hi Dave *)\n"); - if(ed->_uniqueness_rules) { - ed->_uniqueness_rules->Append(ur); + ur->comment_( "(* Hi Dave *)\n" ); + if( ed->_uniqueness_rules ) { + ed->_uniqueness_rules->Append( ur ); } else { - ed->uniqueness_rules_(new Uniqueness_rule__set); - ed->_uniqueness_rules->Append(ur); + ed->uniqueness_rules_( new Uniqueness_rule__set ); + ed->_uniqueness_rules->Append( ur ); } registry->ResetSchemas(); schema = registry->NextSchema(); - ofstream *efile; + ofstream * efile; std::string str, tmp; - while(schema != 0) { + while( schema != 0 ) { str = ""; - str.Append(StrToLower(schema->Name(), tmp)); - str.Append(".exp"); - efile = new ofstream(str.c_str()); + str.Append( StrToLower( schema->Name(), tmp ) ); + str.Append( ".exp" ); + efile = new ofstream( str.c_str() ); cout << "Generating: " << str << endl; - schema->GenerateExpress(*efile); + schema->GenerateExpress( *efile ); efile->close(); delete efile; diff --git a/src/test/needFunc.cc b/src/test/needFunc.cc index a8f507b04..d71c8f28c 100644 --- a/src/test/needFunc.cc +++ b/src/test/needFunc.cc @@ -14,7 +14,6 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE(StepEntityEditor *se) -{ +void DeleteSEE( StepEntityEditor * se ) { delete se; } diff --git a/src/test/needFunc.h b/src/test/needFunc.h index 471c41a62..a473c332c 100644 --- a/src/test/needFunc.h +++ b/src/test/needFunc.h @@ -1,11 +1,10 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class StepEntityEditor -{ +class StepEntityEditor { public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index 04211ee98..f3fc1a3c6 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -12,7 +12,8 @@ ** provided the file written out is called file.out */ -extern void SchemaInit(class Registry &); +extern void SchemaInit( class Registry & ); +#include "sc_version_string.h" #include #include #include @@ -34,23 +35,22 @@ extern void SchemaInit(class Registry &); * before comparison. If they are not identical, attempt to strip any * ASN.1 identifiers and compare again. Returns true for a match. */ -bool compareOneSchName(std::string lib, std::string file) -{ +bool compareOneSchName( std::string lib, std::string file ) { size_t b, e, ls, fs; - b = lib.find_first_of('\'') + 1; - e = lib.find_last_of('\''); - lib = lib.substr(b, e - b); - std::transform(lib.begin(), lib.end(), lib.begin(), ::toupper); - std::transform(file.begin(), file.end(), file.begin(), ::toupper); - if(lib == file) { + b = lib.find_first_of( '\'' ) + 1; + e = lib.find_last_of( '\'' ); + lib = lib.substr( b, e - b ); + std::transform( lib.begin(), lib.end(), lib.begin(), ::toupper ); + std::transform( file.begin(), file.end(), file.begin(), ::toupper ); + if( lib == file ) { return true; } //There are no spaces, unless there is an ASN.1 identifier. If //the strings don't already match, try to remove this identifier. - ls = lib.find_first_of(' '); - fs = file.find_first_of(' '); - if(lib.substr(0, ls) == file.substr(0, fs)) { + ls = lib.find_first_of( ' ' ); + fs = file.find_first_of( ' ' ); + if( lib.substr( 0, ls ) == file.substr( 0, fs ) ) { return true; } std::cerr << "This pair of schema names do not match - " << lib << " and " << file << std::endl; @@ -61,43 +61,40 @@ bool compareOneSchName(std::string lib, std::string file) * Loop through all available schemas and attributes, looking * for a match. If match not found, print error and exit(1) */ -void checkSchemaName(Registry ®, STEPfile &sf, bool ignoreErr) -{ +void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) { bool match = false; std::string sname; - STEPattribute *attr; - const Schema *sc; + STEPattribute * attr; + const Schema * sc; reg.ResetSchemas(); //file id 3 is always the schema name - SDAI_Application_instance *ai = - sf.HeaderInstances()->FindFileId(3)->GetApplication_instance(); - while((attr = ai->NextAttribute())) { + SDAI_Application_instance * ai = + sf.HeaderInstances()->FindFileId( 3 )->GetApplication_instance(); + while( ( attr = ai->NextAttribute() ) ) { sname = attr->asStr(); - while((sc = reg.NextSchema())) { - if(compareOneSchName(sname, sc->Name())) { + while( ( sc = reg.NextSchema() ) ) { + if( compareOneSchName( sname, sc->Name() ) ) { match = true; break; } } - if(match) { + if( match ) { break; } } - if(!match) { + if( !match ) { std::cerr << "ERROR - schema name mismatch. Tried all available combinations." << std::endl; - if(!ignoreErr) { - exit(1); + if( !ignoreErr ) { + exit( 1 ); } } } -void printVersion(const char *exe) -{ - std::cout << exe << " build info: " << SC_VERSION << std::endl; +void printVersion( const char * exe ) { + std::cout << exe << " build info: " << sc_version << std::endl; } -void printUse(const char *exe) -{ +void printUse( const char * exe ) { std::cout << "p21read - read a STEP Part 21 exchange file using SCL, and write the data to another file." << std::endl; std::cout << "Syntax: " << exe << " [-i] [-s] infile [outfile]" << std::endl; std::cout << "Use '-i' to ignore a schema name mismatch." << std::endl; @@ -105,24 +102,23 @@ void printUse(const char *exe) std::cout << "Use '-s' for strict interpretation (attributes that are \"missing and required\" will cause errors)." << std::endl; std::cout << "Use '-v' to print the version info below and exit." << std::endl; std::cout << "Use '--' as the last argument if a file name starts with a dash." << std::endl; - printVersion(exe); - exit(1); + printVersion( exe ); + exit( 1 ); } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { bool ignoreErr = false; bool strict = false; bool trackStats = true; char c; - if(argc > 4 || argc < 2) { - printUse(argv[0]); + if( argc > 4 || argc < 2 ) { + printUse( argv[0] ); } char opts[] = "itsv"; - while((c = sc_getopt(argc, argv, opts)) != -1) { - switch(c) { + while( ( c = sc_getopt( argc, argv, opts ) ) != -1 ) { + switch( c ) { case 'i': ignoreErr = true; break; @@ -133,11 +129,11 @@ int main(int argc, char *argv[]) strict = true; break; case 'v': - printVersion(argv[0]); - exit(0); + printVersion( argv[0] ); + exit( 0 ); case '?': default: - printUse(argv[0]); + printUse( argv[0] ); } } @@ -149,51 +145,50 @@ int main(int argc, char *argv[]) // // The registry is always going to be in memory. /////////////////////////////////////////////////////////////////////////////// - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", strict); - char *flnm; + STEPfile sfile( registry, instance_list, "", strict ); + char * flnm; - // p21 ReadExchangeFile() - benchmark stats; + benchmark stats( "p21 ReadExchangeFile()" ); cout << argv[0] << ": load file ..." << endl; - if(argc >= (sc_optind + 1)) { + if( argc >= ( sc_optind + 1 ) ) { flnm = argv[sc_optind]; } else { - flnm = (char *)"testfile.step"; + flnm = ( char * )"testfile.step"; } - sfile.ReadExchangeFile(flnm); - if(sfile.Error().severity() < SEVERITY_USERMSG) { - sfile.Error().PrintContents(cout); + sfile.ReadExchangeFile( flnm ); + if( sfile.Error().severity() < SEVERITY_USERMSG ) { + sfile.Error().PrintContents( cout ); } - if(trackStats) { + if( trackStats ) { stats.stop(); - stats.out(); + stats.out( ); } - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - exit(1); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + exit( 1 ); } - checkSchemaName(registry, sfile, ignoreErr); + checkSchemaName( registry, sfile, ignoreErr ); Severity readSev = sfile.Error().severity(); //otherwise, errors from reading will be wiped out by sfile.WriteExchangeFile() cout << argv[0] << ": write file ..." << endl; - if(argc == sc_optind + 2) { + if( argc == sc_optind + 2 ) { flnm = argv[sc_optind + 1]; } else { - flnm = (char *)"file.out"; + flnm = ( char * )"file.out"; } - sfile.WriteExchangeFile(flnm); - if(sfile.Error().severity() < SEVERITY_USERMSG) { - sfile.Error().PrintContents(cout); + sfile.WriteExchangeFile( flnm ); + if( sfile.Error().severity() < SEVERITY_USERMSG ) { + sfile.Error().PrintContents( cout ); } cout << argv[0] << ": " << flnm << " written" << endl; - if((sfile.Error().severity() <= SEVERITY_INCOMPLETE) || (readSev <= SEVERITY_INCOMPLETE)) { //lower is worse - exit(1); + if( ( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) || ( readSev <= SEVERITY_INCOMPLETE ) ) { //lower is worse + exit( 1 ); } } diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index 6de41407b..f597b36e4 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -46,8 +46,7 @@ // you what kind of _aggragation_ (no pun intended) you have, as in giving // you a code or "Bag" or something by itself. It probably doesn't work // aesthetically for compound aggregates (i.e., a list of lists). -void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) -{ +void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtml ) { std::string buf; // The type. See src/clstepcore/baseType.h for info @@ -56,45 +55,45 @@ void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) // the type descriptor for the "referent type," if any. // This is NULL if the attribute is a fundamental type. // All we use it for now is checking for NULL. - const TypeDescriptor *reference = typeDesc->ReferentType(); + const TypeDescriptor * reference = typeDesc->ReferentType(); // Do we need an anchor? int anchor = 0; // First, figure out if we need an anchor... - if(reference) { // if this has a referent type (i.e., is a non-base type) - if(base != sdaiAGGR) { // anchor all non-bases except for aggregates + if( reference ) { // if this has a referent type (i.e., is a non-base type) + if( base != sdaiAGGR ) { // anchor all non-bases except for aggregates anchor = 1; // which we'll take care of recursively } } else { // entities and enumerations show up as base, but we want to // anchor them anyway - if(base == sdaiENUMERATION || base == sdaiINSTANCE) { + if( base == sdaiENUMERATION || base == sdaiINSTANCE ) { anchor = 1; } } // Now, print type, with anchor if necessary - if(anchor && base != sdaiINSTANCE) { + if( anchor && base != sdaiINSTANCE ) { // for regular TYPEs, anchor to the index at that definition outhtml << "Name() << "\">"; - } else if(anchor && base == sdaiINSTANCE) { + } else if( anchor && base == sdaiINSTANCE ) { // for entities, anchor to that entity's page outhtml << "Name(); outhtml << ".html\">"; } - typeDesc->AttrTypeName(buf); + typeDesc->AttrTypeName( buf ); outhtml << buf; - if(base == sdaiAGGR) { + if( base == sdaiAGGR ) { outhtml << " (contains elements of type "; - PrintAttrTypeWithAnchor(typeDesc->AggrElemTypeDescriptor(), outhtml); + PrintAttrTypeWithAnchor( typeDesc->AggrElemTypeDescriptor(), outhtml ); outhtml << ")" << endl; } - if(anchor) { + if( anchor ) { outhtml << ""; } } @@ -103,8 +102,7 @@ void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) // Given an entity, print out to the HTML file an unordered list of // the entity's attributes and their types. It returns the number of // explicit attributes that the entity has. -int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) -{ +int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { int attrCount = 0; // To traverse the attributes of the entity, we're going to use @@ -112,19 +110,19 @@ int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) // been done using GetHead() and NextNode() of the entity's attribute // list (nearly identical to how the entity lists are traversed), see // PrintParentAttrsHTML() and also main() below. - AttrDescItr aditr(ent->ExplicitAttr()); - const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); - if(attrDesc != 0) { + AttrDescItr aditr( ent->ExplicitAttr() ); + const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); + if( attrDesc != 0 ) { outhtml << "\nName() << " >\n\n"; outhtml << "
        " << endl; - while(attrDesc != 0) { + while( attrDesc != 0 ) { attrCount++; outhtml << "
      • " << attrDesc->Name() << " : "; - if((attrDesc->Optional()) == SDAI_LOGICAL(LTrue)) { + if( ( attrDesc->Optional() ) == SDAI_LOGICAL( LTrue ) ) { outhtml << "optional "; } - PrintAttrTypeWithAnchor(attrDesc->ReferentType(), outhtml); + PrintAttrTypeWithAnchor( attrDesc->ReferentType(), outhtml ); outhtml << endl; attrDesc = aditr.NextAttrDesc(); } @@ -139,9 +137,8 @@ int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) // the inheritance tree of the entity, printing to the HTML file a // description-list structure showing all ancestors. For each ancestor, // the attributes are printed using the PrintAttrsHTML() function above. -void PrintParentAttrsHTML(const EntityDescriptor *ent, - const EntityDescriptor *parent, ofstream &outhtml) -{ +void PrintParentAttrsHTML( const EntityDescriptor * ent, + const EntityDescriptor * parent, ofstream & outhtml ) { // Passing this function the pointer to ent is really cosmetic, so // we can easily print out this 'header' information. outhtml << "\nName() << ">\n\n"; @@ -152,17 +149,17 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, // Here we're going to traverse the list of supertypes of the parent // using the EntityDescriptorList - const EntityDescriptorList *grandpaList = &(parent->Supertypes()); - EntityDescLinkNode *grandpaNode = - (EntityDescLinkNode *)grandpaList->GetHead(); - while(grandpaNode) { + const EntityDescriptorList * grandpaList = &( parent->Supertypes() ); + EntityDescLinkNode * grandpaNode = + ( EntityDescLinkNode * )grandpaList->GetHead(); + while( grandpaNode ) { // for each "grandparent" of ent, inside a descriptor body (
        ) // recursively call this function... the 'while' takes care of // multiple inheritance: for each grandparent, trace back. outhtml << "
        " << endl; - const EntityDescriptor *grandpa = grandpaNode->EntityDesc(); - PrintParentAttrsHTML(parent, grandpa, outhtml); - grandpaNode = (EntityDescLinkNode *)grandpaNode->NextNode(); + const EntityDescriptor * grandpa = grandpaNode->EntityDesc(); + PrintParentAttrsHTML( parent, grandpa, outhtml ); + grandpaNode = ( EntityDescLinkNode * )grandpaNode->NextNode(); } // Now print the parent's attributes. This calls PrintAttrsHTML() to @@ -170,13 +167,13 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, // any, we'll check to see if the head of the attribute descriptor list // exists. Conversely, once grabbing the head we could print out // the attributes by following the list (attrNode->NextNode()). - const AttrDescriptorList *attrList = &(parent->ExplicitAttr()); - AttrDescLinkNode *attrNode = (AttrDescLinkNode *)attrList->GetHead(); - if(attrNode) { + const AttrDescriptorList * attrList = &( parent->ExplicitAttr() ); + AttrDescLinkNode * attrNode = ( AttrDescLinkNode * )attrList->GetHead(); + if( attrNode ) { outhtml << "
        " << parent->Name(); outhtml << " has the following attributes" << endl; outhtml << "
        " << endl; - if(PrintAttrsHTML(parent, outhtml) == 0) { + if( PrintAttrsHTML( parent, outhtml ) == 0 ) { outhtml << "none" << endl; } } @@ -187,14 +184,13 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, /******************** main() ****************************/ -main() -{ +main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // Rather than using the standard Registry class here, as in the treg // example, we are using MyRegistry, which is derived from the original. @@ -207,7 +203,7 @@ main() registry->ResetSchemas(); registry->ResetTypes(); - const SchemaDescriptor *schema = registry->NextSchema(); + const SchemaDescriptor * schema = registry->NextSchema(); int num_ents = registry->GetEntityCnt(); cout << "Processing schema " << schema->Name(); cout << " with " << num_ents << " entities." << endl; @@ -217,7 +213,7 @@ main() // the schema. cout << "Creating 'index.html'" << endl; - ofstream root("index.html"); + ofstream root( "index.html" ); root << "" << schema->Name() << "" << endl; root << "

        Schema: " << schema->Name() << "

        " << endl; @@ -227,11 +223,11 @@ main() root << "

        Types

        " << endl; root << "
          " << endl; - const TypeDescriptor *type; + const TypeDescriptor * type; type = registry->NextType(); root << "\n"; root << "\n"; - while(type != 0) { + while( type != 0 ) { cout << "."; root << "
        • Name() << "\">"; root << type->Name() << ": "; @@ -254,12 +250,12 @@ main() // for ancestors, but we'll use subs to list subclasses and make links // to them. - const EntityDescriptor *ent; - const EntityDescriptorList *supers; - const EntityDescriptorList *subs; - EntityDescLinkNode *entNode; + const EntityDescriptor * ent; + const EntityDescriptorList * supers; + const EntityDescriptorList * subs; + EntityDescLinkNode * entNode; - for(int i = 0; i < num_ents; i++) { + for( int i = 0; i < num_ents; i++ ) { ent = registry->NextEntity(); cout << "Processing " << ent->Name() << endl; @@ -268,8 +264,8 @@ main() root << ent->Name() << "" << endl; // construct page for entity - char *tmpstr = new char[strlen(ent->Name()) + 6]; - ofstream entout(strcat(strcpy(tmpstr, ent->Name()), ".html")); + char * tmpstr = new char[strlen( ent->Name() ) + 6]; + ofstream entout( strcat( strcpy( tmpstr, ent->Name() ), ".html" ) ); delete [] tmpstr; entout << "Entity " << ent->Name() << "" << endl; entout << "

          " << ent->Name() << "

          " << endl; @@ -278,22 +274,22 @@ main() entout << "
          \n

          Inherited Attributes

          " << endl; entout << "Name() << ">\n"; - supers = &(ent->Supertypes()); - entNode = (EntityDescLinkNode *)supers->GetHead(); - if(!entNode) { + supers = &( ent->Supertypes() ); + entNode = ( EntityDescLinkNode * )supers->GetHead(); + if( !entNode ) { entout << "none" << endl; } - while(entNode) { + while( entNode ) { // call PrintParentAttrsHTML to explore the parents // of the entity, for each parent. - const EntityDescriptor *parent = entNode->EntityDesc(); - PrintParentAttrsHTML(ent, parent, entout); - entNode = (EntityDescLinkNode *)entNode->NextNode(); + const EntityDescriptor * parent = entNode->EntityDesc(); + PrintParentAttrsHTML( ent, parent, entout ); + entNode = ( EntityDescLinkNode * )entNode->NextNode(); } // local attributes entout << "
          \n

          Local Attributes

          " << endl; - if(PrintAttrsHTML(ent, entout) == 0) { + if( PrintAttrsHTML( ent, entout ) == 0 ) { entout << "none" << endl; } @@ -302,16 +298,16 @@ main() // of the entity, a little more simply than in PrintParentAttrsHTML() entout << "
          \n

          Subtypes

          " << endl; entout << "\n"; - subs = &(ent->Subtypes()); - entNode = (EntityDescLinkNode *)subs->GetHead(); - if(entNode) { + subs = &( ent->Subtypes() ); + entNode = ( EntityDescLinkNode * )subs->GetHead(); + if( entNode ) { entout << "
            " << endl; - EntityDescriptor *child; - while(entNode) { + EntityDescriptor * child; + while( entNode ) { child = entNode->EntityDesc(); entout << "
          • Name() << ".html\">"; entout << child->Name() << "" << endl; - entNode = (EntityDescLinkNode *)entNode->NextNode(); + entNode = ( EntityDescLinkNode * )entNode->NextNode(); } entout << "
          " << endl; } else { diff --git a/src/test/tests.h b/src/test/tests.h index 148fca03f..52fcb3a59 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -31,4 +31,4 @@ #include -extern void SchemaInit(Registry &); +extern void SchemaInit( Registry & ); diff --git a/src/test/tio/tio.cc b/src/test/tio/tio.cc index 9936965bd..a73aab4b2 100644 --- a/src/test/tio/tio.cc +++ b/src/test/tio/tio.cc @@ -18,14 +18,13 @@ #define DONT_NEED_HEADER #include "tests.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int using_outfile = 0; - if(argc > 3 || argc < 2) { + if( argc > 3 || argc < 2 ) { cout << "Syntax: tio infile [outfile]" << endl; - exit(1); - } else if(argc > 2) { + exit( 1 ); + } else if( argc > 2 ) { using_outfile = 1; // output filename is in argv[2] } @@ -37,7 +36,7 @@ int main(int argc, char *argv[]) // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -47,7 +46,7 @@ int main(int argc, char *argv[]) // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile *sfile = new STEPfile(*registry, instance_list); + STEPfile * sfile = new STEPfile( *registry, instance_list ); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -60,28 +59,28 @@ int main(int argc, char *argv[]) // The instances get pointers into the InstMgr, and each type // and entity gets a pointer into the registry. cout << "\n### Reading exchange file from " << argv[1] << endl; - sfile->ReadExchangeFile(argv[1]); + sfile->ReadExchangeFile( argv[1] ); // Just checking... ;-) cout << "\n### The InstMgr says there are "; cout << instance_list.InstanceCount() << " instantiated objects" << endl; cout << "\n### Here is the exchange file:" << endl << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); // If you append in another exchange file, it creates new instances // starting at a 1000-block of numbers. Just 'Read'ing again // would clobber the instances already there. cout << "\n### Now appending in another copy" << endl; - sfile->AppendExchangeFile(argv[1]); + sfile->AppendExchangeFile( argv[1] ); // Browsing the registry... cout << "\n### Here is a list of entities now in the registry:" << endl; registry->ResetEntities(); - const EntityDescriptor *ent = registry->NextEntity(); + const EntityDescriptor * ent = registry->NextEntity(); std::string tmpstr; - while(ent) { - cout << ent->Name() << ": " << ent->TypeString(tmpstr) << endl; + while( ent ) { + cout << ent->Name() << ": " << ent->TypeString( tmpstr ) << endl; ent = registry->NextEntity(); } @@ -91,22 +90,22 @@ int main(int argc, char *argv[]) int numInstances = instance_list.InstanceCount(); cout << "### The InstMgr says we have " << numInstances; cout << " things instantiated.\n"; - for(int i = 0; i < numInstances; i++) { - cout << i << ": " << instance_list.GetSTEPentity(i)->EntityName(); + for( int i = 0; i < numInstances; i++ ) { + cout << i << ": " << instance_list.GetSTEPentity( i )->EntityName(); cout << " (" << - instance_list.GetSTEPentity(i)->eDesc->Description(); + instance_list.GetSTEPentity( i )->eDesc->Description(); cout << ")" << endl; } // Dump everything to STEPfiles... cout << "\n### Here it is in STEPfile format:" << endl << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); - if(using_outfile) { - ofstream stepout(argv[2]); + if( using_outfile ) { + ofstream stepout( argv[2] ); cout << "\n### Writing that to outfile " << argv[2] << endl; - sfile->WriteExchangeFile(stepout); + sfile->WriteExchangeFile( stepout ); } - exit(0); + exit( 0 ); } diff --git a/src/test/treg/treg.cc b/src/test/treg/treg.cc index c35f2b33f..aea466013 100644 --- a/src/test/treg/treg.cc +++ b/src/test/treg/treg.cc @@ -27,17 +27,16 @@ // put data values in its attributes. PopulateEntity doesn't care what // attributes your entity has. It goes through them, one at a time, checks // their type, and puts an appropriate random value in. -void PopulateEntity(STEPentity *ent) -{ +void PopulateEntity( STEPentity * ent ) { int attrCount = ent->AttributeCount(); cout << "Populating " << ent->EntityName() << " which has "; cout << attrCount << " attributes." << endl; ent->ResetAttributes(); // start us walking at the top of the list - STEPattribute *attr = ent->NextAttribute(); - while(attr != 0) { - const AttrDescriptor *attrDesc = attr->aDesc; + STEPattribute * attr = ent->NextAttribute(); + while( attr != 0 ) { + const AttrDescriptor * attrDesc = attr->aDesc; cout << " attribute " << attrDesc->Name(); cout << " [" << attrDesc->TypeName() << "] = "; int needOutput = 1; // true if we need to output the value @@ -48,7 +47,7 @@ void PopulateEntity(STEPentity *ent) // a string value as the value of the attribute. Then, depending on // the type of the attribute, put something nearly appropriate in. ostringstream valstr; - switch(attrDesc->NonRefType()) { + switch( attrDesc->NonRefType() ) { case INTEGER_TYPE: // for these types, just put in a random number case REAL_TYPE: // from 0-99. case NUMBER_TYPE: @@ -63,8 +62,8 @@ void PopulateEntity(STEPentity *ent) case BOOLEAN_TYPE: // the trick here is that the value needs to be case LOGICAL_TYPE: { // the word, not the int value, because of StrToVal cout << "(enum/bool/logi) "; - STEPenumeration *se = attr->ptr.e; // grab the enumeration... - valstr << se->element_at(rand() % se->no_elements()); + STEPenumeration * se = attr->ptr.e; // grab the enumeration... + valstr << se->element_at( rand() % se->no_elements() ); } break; default: // for other stuff like aggregates and selects, just leave @@ -74,25 +73,24 @@ void PopulateEntity(STEPentity *ent) } valstr << ends; // flush and null-terminate the stream /*** char *val = valstr.str(); ***/ // fix stream into char* string - char *val = &(valstr.str()[0]); - if(needOutput) { + char * val = &( valstr.str()[0] ); + if( needOutput ) { cout << val << endl; } - attr->StrToVal(val); // and assign + attr->StrToVal( val ); // and assign attr = ent->NextAttribute(); } } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int using_outfile = 0; - if(argc > 2) { + if( argc > 2 ) { cout << "Syntax: treg [filename]" << endl; - exit(1); - } else if(argc > 1) { + exit( 1 ); + } else if( argc > 1 ) { using_outfile = 1; // output filename is in argc[1] } @@ -101,7 +99,7 @@ int main(int argc, char *argv[]) // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -111,7 +109,7 @@ int main(int argc, char *argv[]) // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile *sfile = new STEPfile(*registry, instance_list); + STEPfile * sfile = new STEPfile( *registry, instance_list ); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -127,7 +125,7 @@ int main(int argc, char *argv[]) // to store a pointer to one of each. int num_ents = registry->GetEntityCnt(); - STEPentity **SEarray = new STEPentity*[num_ents]; + STEPentity ** SEarray = new STEPentity*[num_ents]; // "Reset" the Schema and Entity hash tables... this sets things up // so we can walk through the table using registry->NextEntity() @@ -137,46 +135,46 @@ int main(int argc, char *argv[]) // Print out what schema we're running through. - const SchemaDescriptor *schema = registry->NextSchema(); + const SchemaDescriptor * schema = registry->NextSchema(); cout << "Building entities in schema " << schema->Name() << endl; // "Loop" through the schema, building one of each entity type. - const EntityDescriptor *ent; // needs to be declared const... - for(int i = 0; i < num_ents; i++) { + const EntityDescriptor * ent; // needs to be declared const... + for( int i = 0; i < num_ents; i++ ) { ent = registry->NextEntity(); cout << " Building entity " << ent->Name() << endl; // Build object, using its name, through the registry - SEarray[i] = registry->ObjCreate(ent->Name()); + SEarray[i] = registry->ObjCreate( ent->Name() ); // Add each realized entity to the instance list - instance_list.Append(SEarray[i], completeSE); + instance_list.Append( SEarray[i], completeSE ); // Put some data into each instance - PopulateEntity(SEarray[i]); + PopulateEntity( SEarray[i] ); } // Print out all entities - SEarrIterator SEitr((const STEPentity **) SEarray, num_ents); + SEarrIterator SEitr( ( const STEPentity ** ) SEarray, num_ents ); // the above cast is needed because the SEarrIterator // constructor takes a const entity array pointer argument cout << endl << "Here are the entities instantiated, via the SEarray:"; cout << endl; - for(SEitr = 0; !SEitr; ++SEitr) { - SEitr()->STEPwrite(cout); + for( SEitr = 0; !SEitr; ++SEitr ) { + SEitr()->STEPwrite( cout ); } cout << endl << "Here are all the entities via the STEPfile:" << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); - if(using_outfile) { + if( using_outfile ) { cout << "\nWriting STEPfile to output file " << argv[1] << endl; - ofstream step_out(argv[1]); - sfile->WriteExchangeFile(step_out); + ofstream step_out( argv[1] ); + sfile->WriteExchangeFile( step_out ); } - exit(0); + exit( 0 ); } diff --git a/src/test/tstatic/tstatic.cc b/src/test/tstatic/tstatic.cc index 56f0c4e7d..eb6d6f2c5 100644 --- a/src/test/tstatic/tstatic.cc +++ b/src/test/tstatic/tstatic.cc @@ -17,8 +17,7 @@ /* STEPentity* Iterator class definition */ #include "../SEarritr.h" -int main() -{ +int main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see @@ -31,15 +30,15 @@ int main() // For specifics on the structure of the entity classes, see // the SdaiEXAMPLE_SCHEMA.h header file. - const STEPentity *entArr[4]; // our array of entity pointers + const STEPentity * entArr[4]; // our array of entity pointers cout << "Creating an SdaiRectangle..." << endl; SdaiRectangle rect; - rect.item_name_("MyRect"); - rect.item_color_(Color__orange); - rect.number_of_sides_(4); - rect.height_(5); - rect.width_(10); + rect.item_name_( "MyRect" ); + rect.item_color_( Color__orange ); + rect.number_of_sides_( 4 ); + rect.height_( 5 ); + rect.width_( 10 ); cout << "Rectangle: (" << rect.opcode() << ") " << endl; cout << " Name: " << rect.item_name_().c_str() << endl; cout << " Color: " << rect.item_color_() << endl; @@ -51,11 +50,11 @@ int main() cout << "Creating an SdaiSquare..." << endl; SdaiSquare square; - square.item_name_("MySquare"); - square.item_color_(Color__green); - square.number_of_sides_(4); - square.height_(3); - square.width_(3); + square.item_name_( "MySquare" ); + square.item_color_( Color__green ); + square.number_of_sides_( 4 ); + square.height_( 3 ); + square.width_( 3 ); cout << "Square: (" << square.opcode() << ") " << endl; cout << " Name: " << square.item_name_().c_str() << endl; cout << " Color: " << square.item_color_() << endl; @@ -67,12 +66,12 @@ int main() cout << "Creating an SdaiTriangle..." << endl; SdaiTriangle tri; - tri.item_name_("MyTri"); - tri.item_color_(Color__blue); - tri.number_of_sides_(3); - tri.side1_length_(3); - tri.side2_length_(4); - tri.side3_length_(5); + tri.item_name_( "MyTri" ); + tri.item_color_( Color__blue ); + tri.number_of_sides_( 3 ); + tri.side1_length_( 3 ); + tri.side2_length_( 4 ); + tri.side3_length_( 5 ); cout << "Triangle: (" << tri.opcode() << ") " << endl; cout << " Name: " << tri.item_name_().c_str() << endl; cout << " Color: " << tri.item_color_() << endl; @@ -85,10 +84,10 @@ int main() cout << "Creating an SdaiCircle..." << endl; SdaiCircle circ; - circ.item_name_("MyCirc"); - circ.item_color_(Color__red); - circ.number_of_sides_(1); - circ.radius_(15); + circ.item_name_( "MyCirc" ); + circ.item_color_( Color__red ); + circ.number_of_sides_( 1 ); + circ.radius_( 15 ); cout << "Circle: (" << circ.opcode() << ") " << endl; cout << " Name: " << circ.item_name_().c_str() << endl; cout << " Color: " << circ.item_color_() << endl; @@ -98,9 +97,9 @@ int main() entArr[3] = ˆ cout << "And now, all entities in STEP Exchange Format!" << endl << endl; - SEarrIterator SEitr(entArr, 4); - for(SEitr = 0; !SEitr; ++SEitr) { - SEitr()->STEPwrite(cout); + SEarrIterator SEitr( entArr, 4 ); + for( SEitr = 0; !SEitr; ++SEitr ) { + SEitr()->STEPwrite( cout ); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05530cb5b..48d826458 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,8 +13,10 @@ foreach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) endif( UNITARY_SCHEMA MATCHES "fail_.*" ) endforeach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) -add_subdirectory(p21) -add_subdirectory(cpp) +if(NOT ${SC_BUILD_EXPRESS_ONLY}) + add_subdirectory(p21) + add_subdirectory(cpp) +endif() # Local Variables: # tab-width: 8 diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index 7af916d2c..cccf68811 100644 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #c++ tests diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index c96ea08f3..39ce6541a 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -9,10 +9,6 @@ include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${ # added as a workaround for changed behavior in newer cmake # versions (changes somewhere between 2.8 and 3.1) function(get_sdai_incl_dir out_path_var sdai_lib) - if (NOT TARGET sdai_${sdai_lib}) - message("sdai_${sdai_lib} is not a target") - return() - endif (NOT TARGET sdai_${sdai_lib}) if(NOT "${sdai_${sdai_lib}_SOURCE_DIR}" STREQUAL "") set(${out_path_var} "${sdai_${sdai_lib}_SOURCE_DIR}" PARENT_SCOPE) return() diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index d7394417f..fe103ab8e 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -13,112 +13,111 @@ #include "SdaiTEST_ARRAY_BOUNDS_EXPR.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit(1); + exit( 1 ); } - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); Severity readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } // Keeps track of the last processed ent id int search_index = 0; //find structured_mesh, find the array attribute, and check its bounds as much as possible. need an instance to check 100%. - const EntityDescriptor *ed = registry.FindEntity("Structured_mesh"); - AttrDescItr aditr(ed->ExplicitAttr()); - const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); + const EntityDescriptor * ed = registry.FindEntity( "Structured_mesh" ); + AttrDescItr aditr( ed->ExplicitAttr() ); + const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); int descAggrCount = 0; - while(attrDesc != 0) { - if((attrDesc->NonRefType() == ARRAY_TYPE) && (attrDesc->AggrElemType() == sdaiINTEGER)) { + while( attrDesc != 0 ) { + if( ( attrDesc->NonRefType() == ARRAY_TYPE ) && ( attrDesc->AggrElemType() == sdaiINTEGER ) ) { cout << "Array attribute: " << attrDesc->Name(); - const AggrTypeDescriptor *atd = (const AggrTypeDescriptor *) attrDesc->DomainType(); - if(!(atd->Bound1Type() == bound_constant) || !(atd->Bound2Type() == bound_runtime)) { + const AggrTypeDescriptor * atd = ( const AggrTypeDescriptor * ) attrDesc->DomainType(); + if( !( atd->Bound1Type() == bound_constant ) || !( atd->Bound2Type() == bound_runtime ) ) { cerr << "Invalid bounds. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << " -- bound 1 is a constant (" << atd->Bound1() << "). bound 2 depends upon the instance." << endl; descAggrCount++; } attrDesc = aditr.NextAttrDesc(); } - if(descAggrCount != 1) { + if( descAggrCount != 1 ) { cerr << "Expected 1 aggregate attribute descriptor, found " << descAggrCount << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } // Loop over the instances in the file, check the bound for each - SdaiStructured_mesh *ent; - while(ENTITY_NULL != (ent = (SdaiStructured_mesh *) - instance_list.GetApplication_instance("Structured_mesh", search_index))) { + SdaiStructured_mesh * ent; + while( ENTITY_NULL != ( ent = ( SdaiStructured_mesh * ) + instance_list.GetApplication_instance( "Structured_mesh", search_index ) ) ) { SDAI_Integer b2; int instAggrCnt = 0; - IntAggregate *vertex_counts = ent->vertex_counts_(); + IntAggregate * vertex_counts = ent->vertex_counts_(); int cnt = ent->AttributeCount(); - STEPattributeList &sal = ent->attributes; + STEPattributeList & sal = ent->attributes; int id = ent->StepFileId(); cout << "Ent #" << id << " - "; - if(cnt != 3) { + if( cnt != 3 ) { cerr << "Expected 3 attributes, found " << cnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - if(id > 2) { + if( id > 2 ) { cerr << "Expected 2 instances, found " << cnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } //loop over the attributes - for(int i = 0; i < cnt; i++) { - const AttrDescriptor *ad = sal[i].getADesc(); - if((ad->NonRefType() == ARRAY_TYPE) && (ad->AggrElemType() == sdaiINTEGER)) { - b2 = ((AggrTypeDescriptor *) ad->DomainType())->Bound2Runtime(ent); + for( int i = 0; i < cnt; i++ ) { + const AttrDescriptor * ad = sal[i].getADesc(); + if( ( ad->NonRefType() == ARRAY_TYPE ) && ( ad->AggrElemType() == sdaiINTEGER ) ) { + b2 = ( ( AggrTypeDescriptor * ) ad->DomainType() )->Bound2Runtime( ent ); cout << "bound 2: " << b2 << " values: "; instAggrCnt++; - if(((id == 1) && (b2 != 3)) || ((id == 2) && (b2 != 5))) { + if( ( ( id == 1 ) && ( b2 != 3 ) ) || ( ( id == 2 ) && ( b2 != 5 ) ) ) { cerr << "Instance " << id << ": value " << b2 << " is invalid for bound 2."; cerr << " Expecting 3 for instance #1 or 5 for #2." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } } int node = 0; int aggrValues[2][5] = {{1, 2, 3, -1, -1}, {9, 34, 0, 3, 999999}}; - IntNode *aggrNode = (IntNode *) vertex_counts->GetHead(); - while(aggrNode != 0) { - if(node >= b2) { + IntNode * aggrNode = ( IntNode * ) vertex_counts->GetHead(); + while( aggrNode != 0 ) { + if( node >= b2 ) { cerr << "Instance " << id << ": Number of values exceeds upper bound. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << aggrNode->value << " "; - if(aggrValues[id - 1][node] != aggrNode->value) { + if( aggrValues[id - 1][node] != aggrNode->value ) { cerr << "Instance " << id << ": aggregate value " << aggrNode->value << " at index " << node << " is incorrect. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - aggrNode = (IntNode *) aggrNode->NextNode(); + aggrNode = ( IntNode * ) aggrNode->NextNode(); node++; } cout << endl; - if(instAggrCnt != 1) { + if( instAggrCnt != 1 ) { cerr << "Expected 1 aggregate attribute in this instance, found " << instAggrCnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - MgrNode *mnode = instance_list.FindFileId(id); - search_index = instance_list.GetIndex(mnode) + 1; + MgrNode * mnode = instance_list.FindFileId( id ); + search_index = instance_list.GetIndex( mnode ) + 1; } } diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index 578e14911..bc624143a 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,6 +3,7 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include +#include "sc_version_string.h" #include #include #include @@ -18,43 +19,42 @@ #include "schema.h" -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool foundMatch = false; - const char *attrname = "description"; - if(argc != 2) { - exit(EXIT_FAILURE); + const char * attrname = "description"; + if( argc != 2 ) { + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - const SdaiWindow *wind = dynamic_cast< SdaiWindow * >(instance_list.GetApplication_instance("window")); + const SdaiWindow * wind = dynamic_cast< SdaiWindow * >( instance_list.GetApplication_instance( "window" ) ); int i = 0; - if(wind) { + if( wind ) { STEPattributeList attrlist = wind->attributes; - for(; i < attrlist.list_length(); i++) { + for( ; i < attrlist.list_length(); i++ ) { cout << "attr " << i << ": " << attrlist[i].Name() << endl; - if(0 == strcmp(attrname, attrlist[i].Name())) { + if( 0 == strcmp( attrname, attrlist[i].Name() ) ) { foundMatch = true; cout << "attribute " << '"' << attrname << '"' << " found at " << i << endl; } } } - if(!i) { + if( !i ) { cout << "no attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - if(!foundMatch) { + if( !foundMatch ) { cout << "attribute " << '"' << attrname << '"' << " not found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } } diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 717baec3a..3fd51454c 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,6 +4,7 @@ ** */ #include +#include "sc_version_string.h" #include "SubSuperIterators.h" #include #include @@ -20,78 +21,76 @@ #include "schema.h" ///first way of finding inverse attrs -bool findInverseAttrs1(InverseAItr iai, InstMgr &instList) -{ - const Inverse_attribute *ia; +bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { + const Inverse_attribute * ia; int j = 0; - while(0 != (ia = iai.NextInverse_attribute())) { + while( 0 != ( ia = iai.NextInverse_attribute() ) ) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - SdaiReldefinesbytype *rdbt; + SdaiReldefinesbytype * rdbt; int ent_id = 0; - while(0 != (rdbt = (SdaiReldefinesbytype *) instList.GetApplication_instance("reldefinesbytype", ent_id))) { + while( 0 != ( rdbt = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( "reldefinesbytype", ent_id ) ) ) { int i = rdbt->StepFileId(); - if(i < ent_id) { + if( i < ent_id ) { break; } - EntityAggregate *relObj = rdbt->relatedobjects_(); - if(!(relObj && (relObj->is_null() == 0))) { + EntityAggregate * relObj = rdbt->relatedobjects_(); + if( !( relObj && ( relObj->is_null() == 0 ) ) ) { return false; } else { - EntityNode *en = (EntityNode *) relObj->GetHead(); - SdaiObject *obj = (SdaiObject *) en->node; + EntityNode * en = ( EntityNode * ) relObj->GetHead(); + SdaiObject * obj = ( SdaiObject * ) en->node; cout << "file id " << obj->StepFileId() << "; name " - << instList.GetApplication_instance(obj->StepFileId() - 1)->eDesc->Name() << endl; + << instList.GetApplication_instance( obj->StepFileId() - 1 )->getEDesc()->Name() << endl; } ent_id = i; } j++; } - return(j != 0); + return( j != 0 ); } -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool inverseAttrsFound = false; - if(argc != 2) { + if( argc != 2 ) { cout << "wrong args" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor *ed = registry.FindEntity("window"); - InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes - if(findInverseAttrs1(iaIter, instance_list)) { + const EntityDescriptor * ed = registry.FindEntity( "window" ); + InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes + if( findInverseAttrs1( iaIter, instance_list ) ) { inverseAttrsFound = true; } //now, find inherited inverse attrs - supertypesIterator iter(ed); - const EntityDescriptor *super; - for(; !iter.empty(); iter++) { + supertypesIterator iter( ed ); + const EntityDescriptor * super; + for( ; !iter.empty(); iter++ ) { super = iter.current(); cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter(&(super->InverseAttr())); - if(findInverseAttrs1(superIaIter, instance_list)) { + InverseAItr superIaIter( &( super->InverseAttr() ) ); + if( findInverseAttrs1( superIaIter, instance_list ) ) { inverseAttrsFound = true; } } - if(!inverseAttrsFound) { + if( !inverseAttrsFound ) { cout << "no inverse attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 0feef4b5b..d30eabe7b 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,6 +4,7 @@ ** */ #include +#include "sc_version_string.h" #include #include #include @@ -19,21 +20,20 @@ #include "schema.h" ///second way of finding inverse attrs -bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) -{ - const Inverse_attribute *ia; +bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { + const Inverse_attribute * ia; int j = 0; - while(0 != (ia = iai.NextInverse_attribute())) { + while( 0 != ( ia = iai.NextInverse_attribute() ) ) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - const EntityDescriptor *inv_ed = reg.FindEntity(ia->inverted_entity_id_()); - AttrDescItr attr_desc_itr(inv_ed->ExplicitAttr()); - const AttrDescriptor *attrDesc; + const EntityDescriptor * inv_ed = reg.FindEntity( ia->inverted_entity_id_() ); + AttrDescItr attr_desc_itr( inv_ed->ExplicitAttr() ); + const AttrDescriptor * attrDesc; int k = 0; - while(0 != (attrDesc = attr_desc_itr.NextAttrDesc())) { - if(!strcmp(ia->inverted_attr_id_(), attrDesc->Name())) { + while( 0 != ( attrDesc = attr_desc_itr.NextAttrDesc() ) ) { + if( !strcmp( ia->inverted_attr_id_(), attrDesc->Name() ) ) { cout << "attribute '" << attrDesc->Name() << "' is attribute #" << k << " of '" << inv_ed->Name() << "'." << endl; @@ -41,20 +41,20 @@ bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) // entity type 'inv_ed', looking for references to 'ed' in the // attribute described by 'attrDesc' int l = 0; - SdaiReldefinesbytype *inst; - while(0 != (inst = (SdaiReldefinesbytype *) instList.GetApplication_instance(inv_ed->Name(), l))) { + SdaiReldefinesbytype * inst; + while( 0 != ( inst = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( inv_ed->Name(), l ) ) ) { int i = inst->StepFileId(); - if(i < l) { + if( i < l ) { break; } STEPattributeList attrlist = inst->attributes; - if(attrlist.list_length() < k + 1) { + if( attrlist.list_length() < k + 1 ) { return false; } STEPattribute sa = attrlist[k]; - if(sa.getADesc()->DomainType()->Type() == SET_TYPE) { - STEPaggregate *aggr = sa.Aggregate(); - if(!aggr || aggr->is_null() != 0) { + if( sa.getADesc()->DomainType()->Type() == SET_TYPE ) { + STEPaggregate * aggr = sa.Aggregate(); + if( !aggr || aggr->is_null() != 0 ) { cout << "findInverseAttrs2 FAILED" << endl; return false; } @@ -69,46 +69,45 @@ bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) } j++; } - return(j != 0); + return( j != 0 ); } -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool inverseAttrsFound = false; - if(argc != 2) { - exit(EXIT_FAILURE); + if( argc != 2 ) { + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor *ed = registry.FindEntity("window"); - InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes - if(findInverseAttrs2(iaIter, instance_list, registry)) { + const EntityDescriptor * ed = registry.FindEntity( "window" ); + InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes + if( findInverseAttrs2( iaIter, instance_list, registry ) ) { inverseAttrsFound = true; } //now, find inherited inverse attrs - EntityDescItr edi(ed->GetSupertypes()); - const EntityDescriptor *super; - while(0 != (super = edi.NextEntityDesc())) { + EntityDescItr edi( ed->GetSupertypes() ); + const EntityDescriptor * super; + while( 0 != ( super = edi.NextEntityDesc() ) ) { cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter(&(super->InverseAttr())); - if(findInverseAttrs2(superIaIter, instance_list, registry)) { + InverseAItr superIaIter( &( super->InverseAttr() ) ); + if( findInverseAttrs2( superIaIter, instance_list, registry ) ) { inverseAttrsFound = true; } } - if(!inverseAttrsFound) { + if( !inverseAttrsFound ) { cout << "no inverse attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index f1e5d842b..866801dbf 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -22,51 +22,50 @@ #include #include "schema.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int exitStatus = EXIT_SUCCESS; - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args!" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } lazyInstMgr lim; - lim.initRegistry(SchemaInit); + lim.initRegistry( SchemaInit ); - lim.openFile(argv[1]); + lim.openFile( argv[1] ); //find attributes - instanceTypes_t::cvector *insts = lim.getInstances("window"); - if(!insts || insts->empty()) { + instanceTypes_t::cvector * insts = lim.getInstances( "window" ); + if( !insts || insts->empty() ) { cout << "No window instances found!" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - SdaiWindow *instance = dynamic_cast< SdaiWindow * >(lim.loadInstance(insts->at(0))); - if(!instance) { + SdaiWindow * instance = dynamic_cast< SdaiWindow * >( lim.loadInstance( insts->at( 0 ) ) ); + if( !instance ) { cout << "Problem loading instance" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << "instance #" << instance->StepFileId() << endl; SDAI_Application_instance::iAMap_t::value_type v = instance->getInvAttr("isdefinedby"); iAstruct attr = v.second; //instance->getInvAttr(ia); - if(attr.a && attr.a->EntryCount()) { - cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; - } else { - cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void *) v.first << endl; - exitStatus = EXIT_FAILURE; - } + if( attr.a && attr.a->EntryCount() ) { + cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; + } else { + cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void*) v.first << endl; + exitStatus = EXIT_FAILURE; + } - EntityAggregate *aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... - if(attr.a != aggr) { + EntityAggregate * aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... + if( attr.a != aggr ) { cout << "Error! got different EntityAggregate's when using map vs method" << endl; exitStatus = EXIT_FAILURE; } - if(aggr && aggr->EntryCount()) { + if( aggr && aggr->EntryCount() ) { cout << "Found " << aggr->EntryCount() << " inverse references." << endl; } else { cout << "inverse attr is not defined" << endl; exitStatus = EXIT_FAILURE; } - exit(exitStatus); + exit( exitStatus ); } diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index ae6071ad0..3b9e17d04 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -41,75 +41,72 @@ // NOTE this test requires std::thread, part of C++11. It will fail to compile otherwise. -void readProgressParallel(STEPfile &f, float &maxProgress) -{ - while(1) { +void readProgressParallel( STEPfile & f, float & maxProgress ) { + while( 1 ) { float p = f.GetReadProgress(); - if(p > maxProgress) { + if( p > maxProgress ) { maxProgress = p; } - DELAY(5); + DELAY( 5 ); } } -void writeProgressParallel(STEPfile &f, float &maxProgress) -{ - while(1) { +void writeProgressParallel( STEPfile & f, float & maxProgress ) { + while( 1 ) { float p = f.GetWriteProgress(); - if(p > maxProgress) { + if( p > maxProgress ) { maxProgress = p; } - DELAY(5); + DELAY( 5 ); } } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { float progress = 0.0; - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); // read the file - std::thread r(readProgressParallel, std::ref(sfile), std::ref(progress)); - sfile.ReadExchangeFile(argv[1]); + std::thread r( readProgressParallel, std::ref( sfile ), std::ref( progress ) ); + sfile.ReadExchangeFile( argv[1] ); r.detach(); Severity readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - if(progress < 55) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. + if( progress < 55 ) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. cerr << "Error: Read progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { cout << "Read progress reached " << progress << "% - success." << endl; } progress = 0; // write the file - std::thread w(writeProgressParallel, std::ref(sfile), std::ref(progress)); - sfile.WriteExchangeFile("out.stp"); + std::thread w( writeProgressParallel, std::ref( sfile ), std::ref( progress ) ); + sfile.WriteExchangeFile( "out.stp" ); w.detach(); readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - if(progress < 55) { + if( progress < 55 ) { cerr << "Error: Write progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { cout << "Write progress reached " << progress << "% - success." << endl; } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/p21/CMakeLists.txt b/test/p21/CMakeLists.txt index 7d533f9ca..b16bdd7b3 100644 --- a/test/p21/CMakeLists.txt +++ b/test/p21/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #test part 21 files #necessary macros won't already be defined if SC_BUILD_SCHEMAS is set to "" From 4f20f391c669c6ad4fa9fb1caa280490808c90d5 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 4 Aug 2021 16:04:32 -0400 Subject: [PATCH 114/244] Reverting develop back to commit 548fd82ad7ec37301fd --- CMakeLists.txt | 164 +- README.md | 18 +- SC_VERSION.txt | 1 + cmake/FindLEMON.cmake | 40 +- cmake/FindPERPLEX.cmake | 42 +- cmake/FindRE2C.cmake | 26 +- cmake/Generated_Source_Utils.cmake | 67 + cmake/Path_Setup.cmake | 164 - cmake/SC_Build_opts.cmake | 176 + cmake/SC_CXX_schema_macros.cmake | 11 +- cmake/SC_Config_Headers.cmake | 53 +- cmake/SC_Targets.cmake | 6 +- cmake/md5_gen.cmake.in | 35 + cmake/md5_verify.cmake.in | 30 + cmake/sc_version_string.cmake | 84 + cmake/schema_scanner/README | 14 +- cmake/schema_scanner/schemaScanner.cmake | 4 +- data/CMakeLists.txt | 2 +- example/ap203min/CMakeLists.txt | 8 +- .../cmake/External_STEPCode.cmake | 5 + include/CMakeLists.txt | 11 +- include/exppp/exppp.h | 84 +- include/express/alg.h | 20 +- include/express/alloc.h | 14 +- include/express/basic.h | 4 +- include/express/caseitem.h | 8 +- include/express/dict.h | 20 +- include/express/entity.h | 30 +- include/express/error.h | 42 +- include/express/exp_kw.h | 240 +- include/express/expbasic.h | 10 +- include/express/expr.h | 52 +- include/express/express.h | 48 +- include/express/factory.h | 4 +- include/express/hash.h | 30 +- include/express/info.h | 4 +- include/express/lexact.h | 42 +- include/express/linklist.h | 42 +- include/express/memory.h | 4 +- include/express/object.h | 4 +- include/express/resolve.h | 40 +- include/express/schema.h | 38 +- include/express/scope.h | 40 +- include/express/stmt.h | 70 +- include/express/symbol.h | 8 +- include/express/type.h | 34 +- include/express/variable.h | 10 +- include/ordered_attrs.h | 4 +- include/{sc_cf.h.in => sc_cf_cmake.h.in} | 1 - misc/astyle.cfg | 5 +- src/base/CMakeLists.txt | 7 +- src/base/judy/misc/judy64n.c | 2200 +++-- src/base/judy/src/judy.c | 866 +- src/base/judy/src/judy.h | 54 +- src/base/judy/src/judyL2Array.h | 127 +- src/base/judy/src/judyLArray.h | 114 +- src/base/judy/src/judyS2Array.h | 163 +- src/base/judy/src/judySArray.h | 138 +- src/base/judy/test/hexSort.c | 83 +- src/base/judy/test/judyL2test.cc | 48 +- src/base/judy/test/judyLtest.cc | 31 +- src/base/judy/test/judyS2test.cc | 52 +- src/base/judy/test/judyStest.cc | 33 +- src/base/judy/test/pennySort.c | 163 +- src/base/judy/test/sort.c | 194 +- src/base/judy/test/sort.h | 4 +- src/base/path2str.c | 23 +- src/base/path2str.h | 2 +- src/base/sc_benchmark.cc | 98 +- src/base/sc_benchmark.h | 53 +- src/base/sc_getopt.cc | 31 +- src/base/sc_getopt.h | 6 +- src/base/sc_memmgr.cc | 223 +- src/base/sc_memmgr.h | 44 +- src/base/sc_mkdir.c | 26 +- src/base/sc_mkdir.h | 4 +- src/base/sc_nullptr.h | 13 + src/base/sc_stdio.h | 12 +- src/base/sc_trace_fprintf.c | 13 +- src/base/sc_trace_fprintf.h | 8 +- src/cldai/CMakeLists.txt | 6 +- src/cldai/sdaiApplication_instance_set.cc | 85 +- src/cldai/sdaiApplication_instance_set.h | 23 +- src/cldai/sdaiBinary.cc | 231 +- src/cldai/sdaiBinary.h | 62 +- src/cldai/sdaiDaObject.cc | 114 +- src/cldai/sdaiDaObject.h | 115 +- src/cldai/sdaiEntity_extent.cc | 39 +- src/cldai/sdaiEntity_extent.h | 26 +- src/cldai/sdaiEntity_extent_set.cc | 158 +- src/cldai/sdaiEntity_extent_set.h | 23 +- src/cldai/sdaiEnum.cc | 509 +- src/cldai/sdaiEnum.h | 123 +- src/cldai/sdaiModel_contents.cc | 67 +- src/cldai/sdaiModel_contents.h | 32 +- src/cldai/sdaiModel_contents_list.cc | 84 +- src/cldai/sdaiModel_contents_list.h | 21 +- src/cldai/sdaiObject.cc | 6 +- src/cldai/sdaiObject.h | 5 +- src/cldai/sdaiSession_instance.cc | 6 +- src/cldai/sdaiSession_instance.h | 5 +- src/cldai/sdaiString.cc | 84 +- src/cldai/sdaiString.h | 36 +- src/cleditor/CMakeLists.txt | 6 +- src/cleditor/STEPfile.cc | 1230 ++- src/cleditor/STEPfile.h | 168 +- src/cleditor/STEPfile.inline.cc | 235 +- src/cleditor/SdaiHeaderSchema.cc | 537 +- src/cleditor/SdaiHeaderSchema.h | 163 +- src/cleditor/SdaiHeaderSchemaAll.cc | 65 +- src/cleditor/SdaiHeaderSchemaClasses.h | 74 +- src/cleditor/SdaiHeaderSchemaInit.cc | 273 +- src/cleditor/SdaiSchemaInit.cc | 9 +- src/cleditor/SdaiSchemaInit.h | 6 +- src/cleditor/cmdmgr.cc | 108 +- src/cleditor/cmdmgr.h | 124 +- src/cleditor/seeinfodefault.h | 19 +- src/cllazyfile/CMakeLists.txt | 9 +- src/cllazyfile/headerSectionReader.h | 16 +- src/cllazyfile/instMgrHelper.h | 26 +- src/cllazyfile/lazyDataSectionReader.cc | 7 +- src/cllazyfile/lazyDataSectionReader.h | 8 +- src/cllazyfile/lazyFileReader.cc | 55 +- src/cllazyfile/lazyFileReader.h | 25 +- src/cllazyfile/lazyInstMgr.cc | 122 +- src/cllazyfile/lazyInstMgr.h | 130 +- src/cllazyfile/lazyP21DataSectionReader.cc | 50 +- src/cllazyfile/lazyP21DataSectionReader.h | 10 +- src/cllazyfile/lazyRefs.h | 217 +- src/cllazyfile/lazyTypes.h | 4 +- src/cllazyfile/lazy_test.cc | 146 +- src/cllazyfile/p21HeaderSectionReader.cc | 43 +- src/cllazyfile/p21HeaderSectionReader.h | 5 +- src/cllazyfile/sectionReader.cc | 224 +- src/cllazyfile/sectionReader.h | 61 +- src/clstepcore/CMakeLists.txt | 6 +- src/clstepcore/Registry.cc | 269 +- src/clstepcore/Registry.h | 68 +- src/clstepcore/STEPaggrBinary.cc | 80 +- src/clstepcore/STEPaggrBinary.h | 66 +- src/clstepcore/STEPaggrEntity.cc | 196 +- src/clstepcore/STEPaggrEntity.h | 126 +- src/clstepcore/STEPaggrEnum.cc | 117 +- src/clstepcore/STEPaggrEnum.h | 100 +- src/clstepcore/STEPaggrGeneric.cc | 78 +- src/clstepcore/STEPaggrGeneric.h | 66 +- src/clstepcore/STEPaggrInt.cc | 79 +- src/clstepcore/STEPaggrInt.h | 54 +- src/clstepcore/STEPaggrReal.cc | 77 +- src/clstepcore/STEPaggrReal.h | 54 +- src/clstepcore/STEPaggrSelect.cc | 182 +- src/clstepcore/STEPaggrSelect.h | 130 +- src/clstepcore/STEPaggrString.cc | 82 +- src/clstepcore/STEPaggrString.h | 66 +- src/clstepcore/STEPaggregate.cc | 250 +- src/clstepcore/STEPaggregate.h | 111 +- src/clstepcore/STEPattribute.cc | 949 +-- src/clstepcore/STEPattribute.h | 234 +- src/clstepcore/STEPattributeList.cc | 47 +- src/clstepcore/STEPattributeList.h | 14 +- src/clstepcore/STEPcomplex.cc | 524 +- src/clstepcore/STEPcomplex.h | 85 +- src/clstepcore/STEPinvAttrList.cc | 52 +- src/clstepcore/STEPinvAttrList.h | 61 +- src/clstepcore/STEPundefined.cc | 91 +- src/clstepcore/STEPundefined.h | 21 +- src/clstepcore/SingleLinkList.cc | 79 +- src/clstepcore/SingleLinkList.h | 33 +- src/clstepcore/SubSuperIterators.h | 181 +- src/clstepcore/aggrTypeDescriptor.cc | 27 +- src/clstepcore/aggrTypeDescriptor.h | 371 +- src/clstepcore/attrDescriptor.cc | 109 +- src/clstepcore/attrDescriptor.h | 140 +- src/clstepcore/attrDescriptorList.cc | 40 +- src/clstepcore/attrDescriptorList.h | 35 +- src/clstepcore/collect.cc | 66 +- src/clstepcore/complexSupport.h | 338 +- src/clstepcore/complexlist.cc | 114 +- src/clstepcore/create_Aggr.cc | 24 +- src/clstepcore/create_Aggr.h | 36 +- src/clstepcore/derivedAttribute.cc | 35 +- src/clstepcore/derivedAttribute.h | 19 +- src/clstepcore/dictSchema.cc | 156 +- src/clstepcore/dictSchema.h | 260 +- src/clstepcore/dictdefs.h | 30 +- src/clstepcore/dictionaryInstance.h | 11 +- src/clstepcore/dispnode.cc | 20 +- src/clstepcore/dispnode.h | 37 +- src/clstepcore/dispnodelist.cc | 28 +- src/clstepcore/dispnodelist.h | 23 +- src/clstepcore/entityDescriptor.cc | 249 +- src/clstepcore/entityDescriptor.h | 125 +- src/clstepcore/entityDescriptorList.cc | 29 +- src/clstepcore/entityDescriptorList.h | 47 +- src/clstepcore/entlist.cc | 63 +- src/clstepcore/entnode.cc | 85 +- src/clstepcore/enumTypeDescriptor.cc | 70 +- src/clstepcore/enumTypeDescriptor.h | 30 +- src/clstepcore/explicitItemId.cc | 85 +- src/clstepcore/explicitItemId.h | 204 +- src/clstepcore/globalRule.cc | 106 +- src/clstepcore/globalRule.h | 122 +- src/clstepcore/implicitItemId.cc | 85 +- src/clstepcore/implicitItemId.h | 82 +- src/clstepcore/instmgr.cc | 240 +- src/clstepcore/instmgr.h | 82 +- src/clstepcore/interfaceSpec.cc | 102 +- src/clstepcore/interfaceSpec.h | 166 +- src/clstepcore/interfacedItem.cc | 20 +- src/clstepcore/interfacedItem.h | 23 +- src/clstepcore/inverseAttribute.cc | 21 +- src/clstepcore/inverseAttribute.h | 45 +- src/clstepcore/inverseAttributeList.cc | 48 +- src/clstepcore/inverseAttributeList.h | 37 +- src/clstepcore/match-ors.cc | 61 +- src/clstepcore/mgrnode.cc | 114 +- src/clstepcore/mgrnode.h | 74 +- src/clstepcore/mgrnodearray.cc | 132 +- src/clstepcore/mgrnodearray.h | 48 +- src/clstepcore/mgrnodelist.cc | 46 +- src/clstepcore/mgrnodelist.h | 15 +- src/clstepcore/multlist.cc | 118 +- src/clstepcore/needFunc.cc | 3 +- src/clstepcore/needFunc.h | 5 +- src/clstepcore/non-ors.cc | 49 +- src/clstepcore/orlist.cc | 35 +- src/clstepcore/print.cc | 53 +- src/clstepcore/read_func.cc | 562 +- src/clstepcore/read_func.h | 72 +- src/clstepcore/realTypeDescriptor.h | 32 +- src/clstepcore/schRename.cc | 20 +- src/clstepcore/schRename.h | 51 +- src/clstepcore/sdai.cc | 2 +- src/clstepcore/sdai.h | 28 +- src/clstepcore/sdaiApplication_instance.cc | 782 +- src/clstepcore/sdaiApplication_instance.h | 151 +- src/clstepcore/sdaiSelect.cc | 345 +- src/clstepcore/sdaiSelect.h | 75 +- src/clstepcore/selectTypeDescriptor.cc | 51 +- src/clstepcore/selectTypeDescriptor.h | 92 +- src/clstepcore/stringTypeDescriptor.h | 65 +- src/clstepcore/superInvAttrIter.h | 107 +- src/clstepcore/test/CMakeLists.txt | 2 +- .../test/test_SupertypesIterator.cc | 83 +- src/clstepcore/test/test_null_attr.cc | 13 +- .../test/test_operators_SDAI_Select.cc | 79 +- .../test/test_operators_STEPattribute.cc | 57 +- src/clstepcore/trynext.cc | 72 +- src/clstepcore/typeDescriptor.cc | 323 +- src/clstepcore/typeDescriptor.h | 114 +- src/clstepcore/typeDescriptorList.cc | 29 +- src/clstepcore/typeDescriptorList.h | 42 +- src/clstepcore/typeOrRuleVar.cc | 11 +- src/clstepcore/typeOrRuleVar.h | 13 +- src/clstepcore/uniquenessRule.cc | 85 +- src/clstepcore/uniquenessRule.h | 116 +- src/clstepcore/whereRule.cc | 85 +- src/clstepcore/whereRule.h | 108 +- src/clutils/CMakeLists.txt | 6 +- src/clutils/Str.cc | 177 +- src/clutils/Str.h | 36 +- src/clutils/dirobj.cc | 156 +- src/clutils/dirobj.h | 56 +- src/clutils/errordesc.cc | 105 +- src/clutils/errordesc.h | 93 +- src/clutils/gennode.cc | 5 +- src/clutils/gennode.h | 22 +- src/clutils/gennodearray.cc | 91 +- src/clutils/gennodearray.h | 31 +- src/clutils/gennodelist.cc | 38 +- src/clutils/gennodelist.h | 24 +- src/clutils/sc_hash.cc | 233 +- src/clutils/sc_hash.h | 34 +- src/exp2cxx/CMakeLists.txt | 4 + src/exp2cxx/class_strings.c | 213 +- src/exp2cxx/class_strings.h | 20 +- src/exp2cxx/classes.c | 219 +- src/exp2cxx/classes.h | 88 +- src/exp2cxx/classes_attribute.c | 668 +- src/exp2cxx/classes_attribute.h | 18 +- src/exp2cxx/classes_entity.c | 1087 ++- src/exp2cxx/classes_entity.h | 16 +- src/exp2cxx/classes_misc.c | 285 +- src/exp2cxx/classes_type.c | 1116 ++- src/exp2cxx/classes_type.h | 40 +- src/exp2cxx/classes_wrapper.cc | 742 +- src/exp2cxx/collect.cc | 62 +- src/exp2cxx/complexSupport.h | 368 +- src/exp2cxx/complexlist.cc | 110 +- src/exp2cxx/entlist.cc | 58 +- src/exp2cxx/entnode.cc | 48 +- src/exp2cxx/expressbuild.cc | 182 +- src/exp2cxx/fedex_main.c | 72 +- src/exp2cxx/genCxxFilenames.c | 18 +- src/exp2cxx/genCxxFilenames.h | 8 +- src/exp2cxx/match-ors.cc | 58 +- src/exp2cxx/multlist.cc | 135 +- src/exp2cxx/multpass.c | 445 +- src/exp2cxx/non-ors.cc | 46 +- src/exp2cxx/orlist.cc | 32 +- src/exp2cxx/print.cc | 48 +- src/exp2cxx/rules.c | 69 +- src/exp2cxx/rules.h | 4 +- src/exp2cxx/selects.c | 1816 ++-- src/exp2cxx/trynext.cc | 68 +- src/exp2cxx/write.cc | 56 +- src/exp2python/CMakeLists.txt | 3 + src/exp2python/src/classes.h | 118 +- src/exp2python/src/classes_misc_python.c | 363 +- src/exp2python/src/classes_python.c | 1719 ++-- src/exp2python/src/classes_wrapper_python.cc | 227 +- src/exp2python/src/complexSupport.h | 368 +- src/exp2python/src/fedex_main_python.c | 62 +- src/exp2python/src/multpass_python.c | 319 +- src/exp2python/src/selects_python.c | 293 +- src/exppp/CMakeLists.txt | 4 +- src/exppp/exppp-main.c | 73 +- src/exppp/exppp.c | 308 +- src/exppp/pp.h | 24 +- src/exppp/pretty_alg.c | 49 +- src/exppp/pretty_alg.h | 4 +- src/exppp/pretty_case.c | 61 +- src/exppp/pretty_case.h | 2 +- src/exppp/pretty_entity.c | 234 +- src/exppp/pretty_entity.h | 14 +- src/exppp/pretty_expr.c | 361 +- src/exppp/pretty_expr.h | 14 +- src/exppp/pretty_express.c | 9 +- src/exppp/pretty_express.h | 2 +- src/exppp/pretty_func.c | 58 +- src/exppp/pretty_func.h | 8 +- src/exppp/pretty_loop.c | 41 +- src/exppp/pretty_loop.h | 2 +- src/exppp/pretty_proc.c | 44 +- src/exppp/pretty_proc.h | 8 +- src/exppp/pretty_ref.c | 56 +- src/exppp/pretty_ref.h | 2 +- src/exppp/pretty_rule.c | 52 +- src/exppp/pretty_rule.h | 8 +- src/exppp/pretty_schema.c | 143 +- src/exppp/pretty_schema.h | 8 +- src/exppp/pretty_scope.c | 322 +- src/exppp/pretty_scope.h | 18 +- src/exppp/pretty_stmt.c | 115 +- src/exppp/pretty_stmt.h | 10 +- src/exppp/pretty_subtype.c | 18 +- src/exppp/pretty_subtype.h | 4 +- src/exppp/pretty_type.c | 255 +- src/exppp/pretty_type.h | 26 +- src/exppp/pretty_where.c | 60 +- src/exppp/pretty_where.h | 8 +- src/exppp/test/test_breakLongStr.c | 33 +- src/express/CMakeLists.txt | 163 +- src/express/alg.c | 15 +- src/express/alloc.c | 84 +- src/express/caseitem.c | 8 +- src/express/dict.c | 89 +- src/express/entity.c | 218 +- src/express/error.c | 250 +- src/express/exp_kw.c | 240 +- src/express/expr.c | 625 +- src/express/express.c | 613 +- src/express/expscan.l | 5 - src/express/factory.c | 201 +- src/express/fedex.c | 115 +- src/express/generated/CMakeLists.txt | 8 + src/express/generated/README | 11 +- src/express/generated/expparse.c | 7334 ++++++++--------- src/express/generated/expscan.c | 2154 +++-- src/express/generated/expscan.h | 10 +- src/express/generated/verification_info.cmake | 7 + src/express/hash.c | 259 +- src/express/info.c | 58 +- src/express/inithook.c | 3 +- src/express/lexact.c | 211 +- src/express/linklist.c | 134 +- src/express/memory.c | 91 +- src/express/object.c | 70 +- src/express/ordered_attrs.cc | 67 +- src/express/resolve.c | 862 +- src/express/resolve2.c | 91 +- src/express/schema.c | 150 +- src/express/scope.c | 131 +- src/express/stack.h | 8 + src/express/stmt.c | 75 +- src/express/symbol.c | 3 +- src/express/test/CMakeLists.txt | 42 +- src/express/test/driver.c | 30 +- src/express/test/driver.h | 2 +- src/express/test/fff.h | 174 +- src/express/test/print_attrs.c | 82 +- src/express/test/print_schemas.c | 18 +- src/express/test/test_expr.c | 60 +- src/express/test/test_express.c | 22 +- src/express/test/test_resolve.c | 143 +- src/express/test/test_resolve2.c | 31 +- src/express/test/test_schema.c | 79 +- src/express/test/test_scope.c | 22 +- src/express/test/test_type.c | 20 +- src/express/token_type.h | 6 +- src/express/type.c | 77 +- src/express/variable.c | 18 +- src/test/SEarritr.h | 24 +- src/test/generate_express/generate_express.cc | 35 +- src/test/needFunc.cc | 3 +- src/test/needFunc.h | 5 +- src/test/p21read/p21read.cc | 121 +- src/test/scl2html/scl2html.cc | 120 +- src/test/tests.h | 2 +- src/test/tio/tio.cc | 41 +- src/test/treg/treg.cc | 64 +- src/test/tstatic/tstatic.cc | 51 +- test/CMakeLists.txt | 6 +- test/cpp/CMakeLists.txt | 2 +- test/cpp/schema_specific/CMakeLists.txt | 4 - .../aggregate_bound_runtime.cc | 91 +- test/cpp/schema_specific/attribute.cc | 40 +- test/cpp/schema_specific/inverse_attr1.cc | 67 +- test/cpp/schema_specific/inverse_attr2.cc | 75 +- test/cpp/schema_specific/inverse_attr3.cc | 43 +- .../schema_specific/stepfile_rw_progress.cc | 59 +- test/p21/CMakeLists.txt | 2 +- 422 files changed, 26968 insertions(+), 30246 deletions(-) create mode 100644 SC_VERSION.txt create mode 100644 cmake/Generated_Source_Utils.cmake delete mode 100644 cmake/Path_Setup.cmake create mode 100644 cmake/SC_Build_opts.cmake create mode 100644 cmake/md5_gen.cmake.in create mode 100644 cmake/md5_verify.cmake.in create mode 100644 cmake/sc_version_string.cmake rename include/{sc_cf.h.in => sc_cf_cmake.h.in} (94%) create mode 100644 src/base/sc_nullptr.h create mode 100644 src/express/generated/CMakeLists.txt create mode 100644 src/express/generated/verification_info.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7224efff4..d897264c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# C M A K E L I S T S . T X T +# C M A K E L I S T S . T X T F O R S T E P C O D E # # This file is Copyright (c) 2010 United States Government as # represented by the U.S. Army Research Laboratory. @@ -40,124 +40,45 @@ project(SC) -# Minimum required version of CMake -cmake_minimum_required(VERSION 3.12) -if (POLICY CMP0077) - cmake_policy(SET CMP0077 OLD) -endif (POLICY CMP0077) - # SC version set(SC_VERSION_MAJOR 0) -set(SC_VERSION_MINOR 9) -set(SC_VERSION_PATCH 1) -set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) +set(SC_VERSION_MINOR 8-dev) +set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) -# Set language standards -set(CMAKE_C_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +# 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) + +# Minimum required version of CMake +cmake_minimum_required(VERSION 3.6.3) +cmake_policy(SET CMP0003 NEW) +cmake_policy(SET CMP0026 NEW) +cmake_policy(SET CMP0057 NEW) # 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") -list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}") - -# OpenBSD has its own naming conventions. Set a platform variable based on -# the OS name so we can test for it succinctly. -if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") - set(OPENBSD ON) -endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") - -#--------------------------------------------------------------------- -# Set up various relative path variables and build output directories -include(Path_Setup) - -#--------------------------------------------------------------------- -# 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 -if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) - set(CMAKE_SKIP_BUILD_RPATH FALSE) -endif() - -# when building, don't use the install RPATH already -# (but later on when installing) -if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -endif() - -# the RPATH/INSTALL_NAME_DIR to be used when installing -if (NOT APPLE) - if(NOT DEFINED CMAKE_INSTALL_RPATH) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") - endif() -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 -if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) - set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -endif() - -# add the automatically determined parts of the RPATH which point to -# directories outside the build tree to the install RPATH -if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -endif() - - -#--------------------------------------------------------------------- -# Build options -option(BUILD_SHARED_LIBS "Build shared libraries" ON) -option(BUILD_STATIC_LIBS "Build static libraries" OFF) - -option(SC_PYTHON_GENERATOR "Compile exp2python" ON) -option(SC_CPP_GENERATOR "Compile exp2cxx" ON) - -option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) -option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) - -option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) -if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) - set(CMAKE_CXX_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) -endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - -option(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) -endif(SC_ENABLE_TESTING) +if(NOT SC_IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}") +else(NOT SC_IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}") +endif(NOT SC_IS_SUBBUILD) -# TODO - BRL-CAD is the only known user of this option, and it will be -# transitioning to a new setup that won't need it - once that's done, -# we should just remove this option. -option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) -mark_as_advanced(SC_SKIP_EXEC_INSTALL) +# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc +include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc -include(SC_Targets) +include(${SC_CMAKE_DIR}/SC_Targets.cmake) # Macros related to paths -include(SC_Paths) +include(${SC_CMAKE_DIR}/SC_Paths.cmake) # locale stuff -include(SC_Locale) +include(${SC_CMAKE_DIR}/SC_Locale.cmake) # logic related to regenerating the lexer and parser source code -include(SC_Regenerate) - -# create config headers sc_cf.h and sc_version_string.h -include(SC_Config_Headers) +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") @@ -167,8 +88,8 @@ 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") + #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(NOT SC_IS_SUBBUILD) @@ -178,18 +99,23 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -# create config headers sc_cf.h -include(SC_Config_Headers) +# create config headers sc_cf.h and sc_version_string.h +include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) ################ +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 11) + if(MSVC) # 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) -endif() -if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") +else() add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) + if(HAVE_NULLPTR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif(HAVE_NULLPTR) endif() include_directories( @@ -214,19 +140,13 @@ if(SC_ENABLE_TESTING) endif(SC_ENABLE_TESTING) add_subdirectory(doc) -if(NOT SC_IS_SUBBUILD) - #----------------------------------------------------------------------------- - # 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 ") - include(CPack) -endif(NOT SC_IS_SUBBUILD) - +# 'make core' builds everything that isn't generated. for devs. +add_custom_target(core) +if($CACHE{SC_BUILD_SHARED_LIBS}) + add_dependencies(core stepdai stepeditor exp2cxx check-express) +else() + add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) +endif() # 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. diff --git a/README.md b/README.md index e34c4c2ef..4df78fd0d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Linux, OSX (LLVM) | Windows (MSVC) [![Build Status](https://travis-ci.org/stepcode/stepcode.svg?branch=master)](https://travis-ci.org/stepcode/stepcode) | [![Build status](https://ci.appveyor.com/api/projects/status/3fbr9t9gfa812oqu?svg=true)](https://ci.appveyor.com/project/mpictor/stepcode) *********************************************************************** -STEPcode v0.9 -- 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 @@ -36,16 +36,14 @@ CODING STANDARDS SC's source has been reformatted with astyle. When making changes, try to match the current formatting. The main points are: - - K&R (Kernighan & Ritchie) brackets: + - compact (java-style) brackets: ```C - int Foo(bool isBar) - { - if (isBar) { - bar(); - return 1; - } else - return 0; - } + if( a == 3 ) { + c = 5; + function( a, b ); + } else { + somefunc( ); + } ``` - indents are 4 spaces - no tab characters diff --git a/SC_VERSION.txt b/SC_VERSION.txt new file mode 100644 index 000000000..aec258df7 --- /dev/null +++ b/SC_VERSION.txt @@ -0,0 +1 @@ +0.8 diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index ebd7af001..19aa0d500 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,35 +44,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -set(_LEMON_SEARCHES) - -# Search LEMON_ROOT first if it is set. -if(LEMON_ROOT) - set(_LEMON_SEARCH_ROOT PATHS ${LEMON_ROOT} NO_DEFAULT_PATH) - list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_ROOT) -endif() - -# Normal search. -set(_LEMON_x86 "(x86)") -set(_LEMON_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/lemon" - "$ENV{ProgramFiles${_LEMON_x86}}/lemon") -unset(_LEMON_x86) -list(APPEND _LEMON_SEARCHES _LEMON_SEARCH_NORMAL) - -set(LEMON_NAMES lemon) - -# Try each search configuration. -foreach(search ${_LEMON_SEARCHES}) - find_program(LEMON_EXECUTABLE lemon ${${search}} PATH_SUFFIXES bin) -endforeach() +find_program(LEMON_EXECUTABLE lemon DOC "path to the lemon executable") mark_as_advanced(LEMON_EXECUTABLE) -foreach(search ${_LEMON_SEARCHES}) - find_file(LEMON_TEMPLATE lempar.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/lemon) -endforeach() -mark_as_advanced(LEMON_TEMPLATE) - if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) # look for the template in share if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") @@ -139,10 +113,6 @@ if(NOT COMMAND LEMON_TARGET) CMAKE_PARSE_ARGUMENTS(${LVAR_PREFIX} "" "OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR;EXTRA_ARGS" "" ${ARGN}) endif(${ARGC} GREATER 3) - if (TARGET perplex_stage) - set(DEPS_TARGET perplex_stage) - endif (TARGET perplex_stage) - # Need a working directory if("${${LVAR_PREFIX}_WORKING_DIR}" STREQUAL "") set(${LVAR_PREFIX}_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LVAR_PREFIX}") @@ -191,7 +161,7 @@ if(NOT COMMAND LEMON_TARGET) OUTPUT ${LEMON_GEN_OUT} ${LEMON_GEN_SOURCE} ${LEMON_GEN_HEADER} COMMAND ${CMAKE_COMMAND} -E copy ${lemon_in_file} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} ${${LVAR_PREFIX}__EXTRA_ARGS} - DEPENDS ${Input} ${LEMON_EXECUTABLE_TARGET} ${DEPS_TARGET} + DEPENDS ${Input} ${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${LVAR_PREFIX}_WORKING_DIR} COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" ) @@ -201,7 +171,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${${LVAR_PREFIX}_OUT_SRC_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ${DEPS_TARGET} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_SRC_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "${LEMON_GEN_SOURCE}") @@ -209,7 +179,7 @@ if(NOT COMMAND LEMON_TARGET) add_custom_command( OUTPUT ${${LVAR_PREFIX}_OUT_HDR_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${${LVAR_PREFIX}_OUT_HDR_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ${DEPS_TARGET} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ) set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_HDR_FILE} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "${LEMON_GEN_HEADER}") diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index d1482d67c..22d632032 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -10,7 +10,7 @@ # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -44,35 +44,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -set(_PERPLEX_SEARCHES) - -# Search PERPLEX_ROOT first if it is set. -if(PERPLEX_ROOT) - set(_PERPLEX_SEARCH_ROOT PATHS ${PERPLEX_ROOT} NO_DEFAULT_PATH) - list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_ROOT) -endif() - -# Normal search. -set(_PERPLEX_x86 "(x86)") -set(_PERPLEX_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/perplex" - "$ENV{ProgramFiles${_PERPLEX_x86}}/perplex") -unset(_PERPLEX_x86) -list(APPEND _PERPLEX_SEARCHES _PERPLEX_SEARCH_NORMAL) - -set(PERPLEX_NAMES perplex) - -# Try each search configuration. -foreach(search ${_PERPLEX_SEARCHES}) - find_program(PERPLEX_EXECUTABLE perplex ${${search}} PATH_SUFFIXES bin) -endforeach() +find_program(PERPLEX_EXECUTABLE perplex DOC "path to the perplex executable") mark_as_advanced(PERPLEX_EXECUTABLE) -foreach(search ${_PERPLEX_SEARCHES}) - find_file(PERPLEX_TEMPLATE perplex_template.c ${${search}} PATH_SUFFIXES ${DATA_DIR} ${DATA_DIR}/perplex) -endforeach() -mark_as_advanced(PERPLEX_TEMPLATE) - if(PERPLEX_EXECUTABLE AND NOT PERPLEX_TEMPLATE) get_filename_component(perplex_path ${PERPLEX_EXECUTABLE} PATH) if(perplex_path) @@ -122,7 +96,7 @@ mark_as_advanced(PERPLEX_TEMPLATE) # # Originally based off of FindBISON.cmake from Kitware's CMake distribution # -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel @@ -167,10 +141,6 @@ if(NOT COMMAND PERPLEX_TARGET) get_filename_component(IN_FILE_WE ${Input} NAME_WE) set(PVAR_PREFIX ${Name}_${IN_FILE_WE}) - if (TARGET perplex_stage) - set(DEP_TARGET perplex_stage) - endif (TARGET perplex_stage) - if(${ARGC} GREATER 3) CMAKE_PARSE_ARGUMENTS(${PVAR_PREFIX} "" "TEMPLATE;OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR" "" ${ARGN}) endif(${ARGC} GREATER 3) @@ -230,7 +200,7 @@ if(NOT COMMAND PERPLEX_TARGET) OUTPUT ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${perplex_in_file} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} COMMAND ${PERPLEX_EXECUTABLE} -c -o ${re2c_src} -i ${${PVAR_PREFIX}_OUT_HDR_FILE} -t ${${PVAR_PREFIX}_TEMPLATE} ${${PVAR_PREFIX}_WORKING_DIR}/${IN_FILE} - DEPENDS ${Input} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${${PVAR_PREFIX}_TEMPLATE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[PERPLEX][${Name}] Generating re2c input with ${PERPLEX_EXECUTABLE}" ) @@ -239,7 +209,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-debug-info --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) @@ -247,7 +217,7 @@ if(NOT COMMAND PERPLEX_TARGET) add_custom_command( OUTPUT ${${PVAR_PREFIX}_OUT_SRC_FILE} COMMAND ${RE2C_EXECUTABLE} --no-generation-date -c -o ${${PVAR_PREFIX}_OUT_SRC_FILE} ${re2c_src} - DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} ${DEP_TARGET} + DEPENDS ${Input} ${re2c_src} ${${PVAR_PREFIX}_OUT_HDR_FILE} ${PERPLEX_EXECUTABLE_TARGET} ${RE2C_EXECUTABLE_TARGET} WORKING_DIRECTORY ${${PVAR_PREFIX}_WORKING_DIR} COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" ) diff --git a/cmake/FindRE2C.cmake b/cmake/FindRE2C.cmake index 2b3a9492b..5450c34a9 100644 --- a/cmake/FindRE2C.cmake +++ b/cmake/FindRE2C.cmake @@ -3,29 +3,7 @@ # #============================================================================= -set(_RE2C_SEARCHES) - -# Search RE2C_ROOT first if it is set. -if(RE2C_ROOT) - set(_RE2C_SEARCH_ROOT PATHS ${RE2C_ROOT} NO_DEFAULT_PATH) - list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_ROOT) -endif() - -# Normal search. -set(_RE2C_x86 "(x86)") -set(_RE2C_SEARCH_NORMAL - PATHS "$ENV{ProgramFiles}/re2c" - "$ENV{ProgramFiles${_RE2C_x86}}/re2c") -unset(_RE2C_x86) -list(APPEND _RE2C_SEARCHES _RE2C_SEARCH_NORMAL) - -set(RE2C_NAMES re2c) - -# Try each search configuration. -foreach(search ${_RE2C_SEARCHES}) - find_program(RE2C_EXECUTABLE re2c ${${search}} PATH_SUFFIXES bin) -endforeach() - +find_program(RE2C_EXECUTABLE re2c DOC "path to the re2c executable") mark_as_advanced(RE2C_EXECUTABLE) include(FindPackageHandleStandardArgs) @@ -64,7 +42,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(RE2C DEFAULT_MSG RE2C_EXECUTABLE) # ==================================================================== # #============================================================================= -# Copyright (c) 2010-2020 United States Government as represented by +# Copyright (c) 2010-2016 United States Government as represented by # the U.S. Army Research Laboratory. # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel diff --git a/cmake/Generated_Source_Utils.cmake b/cmake/Generated_Source_Utils.cmake new file mode 100644 index 000000000..601f92364 --- /dev/null +++ b/cmake/Generated_Source_Utils.cmake @@ -0,0 +1,67 @@ +# Utility routines for managing generated files with CMake + +macro(MD5 filename md5sum) + file(READ "${filename}" RAW_MD5_FILE) + string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}") + string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}") +endmacro(MD5) + +macro(FILEVAR filename var) + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${var} ${filename}) +endmacro(FILEVAR) + +macro(VERIFY_FILES filelist warn resultvar) + set(${resultvar} 1) + foreach(fileitem ${filelist}) + # Deal with absolute and relative paths a bit differently + get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) + if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${fileitem}") + else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") + endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + get_filename_component(filename "${fileitem}" NAME) + # Got filename components sorted - proceed + if(NOT EXISTS ${filefullname}) + message(FATAL_ERROR "Attempted to verify non-existant file ${filefullname}") + endif(NOT EXISTS ${filefullname}) + FILEVAR(${filename} filevar) + if(NOT baseline_${filevar}_md5) + message(FATAL_ERROR "No baseline MD5 available for ${filename} - baseline_${filevar}_md5 is not defined") + endif(NOT baseline_${filevar}_md5) + MD5(${filefullname} ${filevar}_md5) + if(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") + if("${warn}" STREQUAL "1") + message("\n${filename} differs from baseline: baseline md5 hash is ${baseline_${filevar}_md5} and current hash is ${${filevar}_md5}\n") + endif("${warn}" STREQUAL "1") + set(${resultvar} 0) + endif(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") + endforeach(fileitem ${filelist}) +endmacro(VERIFY_FILES filelist resultvar) + +macro(WRITE_MD5_SUMS filelist outfile) + foreach(fileitem ${filelist}) + # Deal with absolute and relative paths a bit differently + get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) + if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${fileitem}") + else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") + endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") + get_filename_component(filename "${fileitem}" NAME) + # Got filename components sorted - proceed + if(NOT EXISTS ${filefullname}) + message(FATAL_ERROR "Attempted to get MD5 sum of non-existant file ${filefullname}") + endif(NOT EXISTS ${filefullname}) + FILEVAR(${filename} filevar) + MD5(${filefullname} ${filevar}_md5) + file(APPEND ${outfile} "set(baseline_${filevar}_md5 ${${filevar}_md5})\n") + endforeach(fileitem ${filelist}) +endmacro(WRITE_MD5_SUMS) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/Path_Setup.cmake b/cmake/Path_Setup.cmake deleted file mode 100644 index f5db3b411..000000000 --- a/cmake/Path_Setup.cmake +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright (c) 2010-2020 United States Government as represented by -# the U.S. Army Research Laboratory. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. 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. -# -# 3. The name of the author may not be used to endorse or promote -# products derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS -# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -#--------------------------------------------------------------------- -# Define relative install locations. Don't set these if they have already -# been set by some other means (like a higher level CMakeLists.txt file -# including this one). - -# The location in which to install BRL-CAD executables. -if(NOT BIN_DIR) - set(BIN_DIR bin) -endif(NOT BIN_DIR) - -# Define a relative path that will "reset" a path back to -# the point before BIN_DIR was appended. This is primarily -# useful when working with generator expressions -unset(RBIN_DIR CACHE) -set(LBIN_DIR "${BIN_DIR}") -while (NOT "${LBIN_DIR}" STREQUAL "") - get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY) - set(LBIN_DIR "${LBDIR}") - if ("${RBIN_DIR}" STREQUAL "") - set(RBIN_DIR "..") - else ("${RBIN_DIR}" STREQUAL "") - set(RBIN_DIR "../${RBIN_DIR}") - endif ("${RBIN_DIR}" STREQUAL "") -endwhile (NOT "${LBIN_DIR}" STREQUAL "") - -# The location in which to install BRL-CAD libraries. -if(NOT LIB_DIR) - set(LIB_DIR lib) -endif(NOT LIB_DIR) -if(NOT LIBEXEC_DIR) - set(LIBEXEC_DIR libexec) -endif(NOT LIBEXEC_DIR) - -# The location in which to install BRL-CAD header files. -if(NOT INCLUDE_DIR) - set(INCLUDE_DIR include) -endif(NOT INCLUDE_DIR) - -# The location in which to install BRL-CAD data files -if(NOT DATA_DIR) - set(DATA_DIR share) -endif(NOT DATA_DIR) - -# The location in which to install BRL-CAD documentation files -if(NOT DOC_DIR) - set(DOC_DIR ${DATA_DIR}/doc) -endif(NOT DOC_DIR) - -# The location in which to install BRL-CAD Manual pages -if(NOT MAN_DIR) - set(MAN_DIR ${DATA_DIR}/man) -endif(NOT MAN_DIR) - -# Make sure no absolute paths have been supplied to these variables -set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC) -foreach(instdir ${INSTALL_DIRS}) - get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE) - if("${${instdir}_DIR}" STREQUAL "${instdir_full}") - message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"") - set(HAVE_INSTALL_DIR_FULL_PATH 1) - endif("${${instdir}_DIR}" STREQUAL "${instdir_full}") -endforeach(instdir ${INSTALL_DIRS}) - -#--------------------------------------------------------------------- -# Output directories - this is where built library and executable -# files will be placed after building but prior to install. The -# necessary variables change between single and multi configuration -# build systems, so it is necessary to handle both cases on a -# conditional basis. - -if(NOT CMAKE_CONFIGURATION_TYPES) - # If we're not doing multi-configuration, just set the three main - # variables to the correct values. - if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") - endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) -else(NOT CMAKE_CONFIGURATION_TYPES) - # Multi-configuration is more difficult. Not only do we need to - # properly set the output directories, but we also need to - # identify the "toplevel" directory for each configuration so - # we can place files, documentation, etc. in the correct - # relative positions. Because files may be placed by CMake - # without a build target to put them in their proper relative build - # directory position using these paths, we must fully qualify them - # without using CMAKE_CFG_INTDIR. - # - # We define directories that may not be quite "standard" - # for a particular build tool - for example, native VS2010 projects use - # another directory to denote CPU type being compiled for - but CMake only - # supports multi-configuration setups having multiple configurations, - # not multiple compilers. - # - # One additional wrinkle we must watch for here is the case where - # a multi-configuration setup uses "." for its internal directory - - # if that's the case, we need to just set the various config output - # directories to the same value. - set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}) - foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") - set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE}) - endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") - string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) - if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") - endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") - endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") - endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) - if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) - set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") - endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) - if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) - set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") - endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) - endforeach() -endif(NOT CMAKE_CONFIGURATION_TYPES) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake new file mode 100644 index 000000000..8ca942615 --- /dev/null +++ b/cmake/SC_Build_opts.cmake @@ -0,0 +1,176 @@ +# BIN and LIB directories +if(NOT DEFINED BIN_DIR) + set(BIN_DIR bin) +endif(NOT DEFINED BIN_DIR) + +if(NOT DEFINED LIB_DIR) + set(LIB_DIR lib) +endif(NOT DEFINED LIB_DIR) + +# 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) + +# Should we use C++11? +OPTION_WITH_DEFAULT(SC_ENABLE_CXX11 "Build with C++ 11 features" ON) + +# Get version from git +OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON) + +option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) +mark_as_advanced(SC_BUILD_EXPRESS_ONLY) + +option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) +mark_as_advanced(DEBUGGING_GENERATED_SOURCES) + +#--------------------------------------------------------------------- +# 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 ${SC_BUILD_EXPRESS_ONLY} AND NOT DEFINED SC_BUILD_SCHEMAS) + set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified + endif() + include(CTest) +endif(SC_ENABLE_TESTING) + +#--------------------------------------------------------------------- +# Executable install option +OPTION_WITH_DEFAULT(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) +if(SC_SKIP_EXEC_INSTALL) + set(SC_EXEC_NOINSTALL "NO_INSTALL") +endif(SC_SKIP_EXEC_INSTALL) + +#--------------------------------------------------------------------- +# 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 ") + 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 + diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 016450c2c..388d820a5 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -28,8 +28,10 @@ endmacro(P21_TESTS sfile) macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) + #add_dependencies(p21read_${PROJECT_NAME} version_string) if(NOT WIN32) SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) + #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) #add user-defined executables @@ -37,6 +39,7 @@ macro(SCHEMA_EXES) get_filename_component(name ${src} NAME_WE) get_filename_component(path ${src} ABSOLUTE) SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${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) @@ -93,7 +96,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ${SC_SOURCE_DIR}/src/base/judy/src ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation - if(BUILD_SHARED_LIBS) + if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) if(WIN32) @@ -102,12 +105,6 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj") endif() endif() - # TODO - ideally we would avoid generating code that triggers this warning, but figuring out - # how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings - # we get due to this issue so it doesn't mask other problems. - if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers") - endif() endif() if($CACHE{SC_BUILD_STATIC_LIBS}) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index f9a8cc86b..17d0c2774 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,4 +1,23 @@ -# create sc_cf.h +# 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) @@ -78,8 +97,36 @@ int main() {return !(f() == f());} endif(SC_ENABLE_CXX11) # Now that all the tests are done, configure the sc_cf.h file: -configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) +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. +if(SC_GIT_VERSION) + 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 + 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 +else(SC_GIT_VERSION) + set(VER_HDR " + #ifndef SC_VERSION_STRING + #define SC_VERSION_STRING + static char sc_version[512] = {\"${SC_VERSION}\"}; + #endif" + ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") +endif(SC_GIT_VERSION) +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 diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index cb2d11dd6..09204146c 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -46,11 +46,7 @@ macro(SC_ADDLIB _addlib_target) if(${_arg_prefix}_SHARED) add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES}) - if(OPENBSD) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) - else(OPENBSD) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) - endif(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION}) if(APPLE) set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") endif(APPLE) diff --git a/cmake/md5_gen.cmake.in b/cmake/md5_gen.cmake.in new file mode 100644 index 000000000..9d664baa0 --- /dev/null +++ b/cmake/md5_gen.cmake.in @@ -0,0 +1,35 @@ +# Inherit the parent CMake setting +set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) +set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) + +# Define a variety of convenience routines +include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake) + +# The following steps are executed to sync generated sources: +# +# 1. Create a new verification_info.cmake file and populate +# it with the MD5 sums for current files. +# +# 2. Overwrite the original cached verification_info.cmake +# and generated files with the new ones. If LOCKED_SOURCE_DIR +# is ON, this step will not be carried out - instead, an +# informational message with manual updating instructions +# will be printed. + +set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake") + + +file(WRITE ${new_info_file} "# Autogenerated verification information\n") + +# Handle input files +set(input_files "@MD5_FILELIST@") +WRITE_MD5_SUMS("${input_files}" "${new_info_file}") + +message("New verification file created: ${new_info_file}") + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/md5_verify.cmake.in b/cmake/md5_verify.cmake.in new file mode 100644 index 000000000..5eb105337 --- /dev/null +++ b/cmake/md5_verify.cmake.in @@ -0,0 +1,30 @@ +# Inherit the parent CMake setting +set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@) +set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") + +# Include the file the provides the baseline against which +# current files will be compared + + include("@BASELINE_INFORMATION_FILE@") + + # Define a variety of convenience routines + include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake") + + # Individually verify all of the files in question. + set(filelist "@MD5_FILELIST@") + VERIFY_FILES("${filelist}" 1 srcs_pass) + if(NOT srcs_pass) + if(NOT DEBUGGING_GENERATED_SOURCES) + message(FATAL_ERROR "Sources have been modified and md5 sums have not been updated. This generally indicates either\n a) an input file has been modified but generated files have not been updated, or\n b) genenerated files have been edited directly.\nTo clear the error:\n a) Copy the new generated sources from the build directory to the generated/ sources directory, use the _md5gen build target to create a new verifictation_info.cmake file, and copy verfication_info.cmake to generated/ as well.\n b) install Perplex/Re2C/LEMON and make the changes to the input file rather than the generated file.\nNote:\n If this is a debugging situation where multiple sequential tests must be conducted, temporarily set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure to disable this check.\nThis measure is necessary to ensure that compilations using either Perplex/Re2C/LEMON generation or the cached outputs of those tools produce consistent results.") + else(NOT DEBUGGING_GENERATED_SOURCES) + message(WARNING "Note: Sources have been modified and md5 sums have not been updated - build failure condition temporarily overridden by DEBUGGING_GENERATED_SOURCES setting.") + endif(NOT DEBUGGING_GENERATED_SOURCES) + endif(NOT srcs_pass) + + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake new file mode 100644 index 000000000..ed53ac27e --- /dev/null +++ b/cmake/sc_version_string.cmake @@ -0,0 +1,84 @@ +# creates sc_version_string.h, which defines sc_version() +# sc_version() returns a pretty commit description and a build timestamp. + +# only update the file if the git commit has changed, because whenever the file is updated files including the header must rebuild +# parallel rebuilds can result in race conditions and failures, particularly when running ctest in parallel + +# http://stackoverflow.com/questions/3780667 +# http://www.cmake.org/pipermail/cmake/2009-February/027014.html + +set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") +set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@") + +set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h") + +#---------- find commit id ------------------ +#use git for a pretty commit id +#uses 'git describe --tags', so tags are required in the repo +#create a tag with 'git tag ' 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) + if(NOT SC_IS_SUBBUILD) + message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.") + endif(NOT SC_IS_SUBBUILD) + 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) +endif() +string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) + +#-------------- date and time --------------- + +if(SC_ENABLE_TESTING) + set (date_time_string "NA - disabled for testing") +else() + string(TIMESTAMP date_time_string UTC) +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" + ) + +#don't update the file unless something changed +string(RANDOM tmpsuffix) +file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) +execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix}) + +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 diff --git a/cmake/schema_scanner/README b/cmake/schema_scanner/README index eabd37087..8e0996f29 100644 --- a/cmake/schema_scanner/README +++ b/cmake/schema_scanner/README @@ -1,14 +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. +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. +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. diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index affe5c5cc..0c345d931 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -71,9 +71,9 @@ message( STATUS "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_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_INSTALL_DIR}) else(WIN32) - install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR}) endif(WIN32) # macro SCHEMA_CMLIST diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index d4452117b..819403e6f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,7 +10,7 @@ # .exp file inside, which it uses. otherwise, ${path} is assumed to # be an express file. -if(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +if(NOT ${SC_BUILD_EXPRESS_ONLY} AND 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) diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index f1fccb2ea..624ca44a4 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -14,14 +14,14 @@ if(NOT DEFINED STEPCODE_ROOT_DIR) endif(NOT DEFINED STEPCODE_ROOT_DIR) # STEPCODE_ROOT_DIR is relative or absolute path? -if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") +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}/src/express/express.c") + 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}/src/express/express.c") -endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") + 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. diff --git a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake index 96fca295b..62df14322 100644 --- a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake +++ b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake @@ -22,3 +22,8 @@ ENDIF() SET( STEPCODE_BINARY_DIR ${BINARY_DIR} ) +# SC CMake does not honor -DCMAKE_INSTALL_PREFIX:PATH= +# Consequently, force Debug so it installs in ../sc-install directory +# instead of /usr/local/lib. +# +# SC's own programs fail to build with -DSC_BUILD_SHARED_LIBS=OFF \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index da3ae5eb5..566c3780d 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,21 +22,22 @@ set(express_HDRS express/variable.h ) install(FILES ${express_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/express) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express) set(exppp_HDRS exppp/exppp.h ) install(FILES ${exppp_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/exppp) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp) install(FILES ordered_attrs.h sc_export.h sc_stdbool.h - DESTINATION ${INCLUDE_DIR}/stepcode) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode) -install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h - DESTINATION ${INCLUDE_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) # Local Variables: # tab-width: 8 diff --git a/include/exppp/exppp.h b/include/exppp/exppp.h index 1e7e78cc7..f6159cbf5 100644 --- a/include/exppp/exppp.h +++ b/include/exppp/exppp.h @@ -15,56 +15,56 @@ extern SC_EXPPP_EXPORT int exppp_linelength; /**< leave some slop extern SC_EXPPP_EXPORT bool exppp_alphabetize; /**< if true, alphabetize */ extern SC_EXPPP_EXPORT bool exppp_terse; /**< don't describe action to stdout */ extern SC_EXPPP_EXPORT bool exppp_reference_info; /**< if true, add commentary about where things came from */ -extern SC_EXPPP_EXPORT char *exppp_output_filename; /**< force output filename */ +extern SC_EXPPP_EXPORT char * exppp_output_filename; /**< force output filename */ extern SC_EXPPP_EXPORT bool exppp_output_filename_reset; /**< if true, force output filename */ extern SC_EXPPP_EXPORT bool exppp_print_to_stdout; /**< if true, print to stdout */ extern SC_EXPPP_EXPORT bool exppp_aggressively_wrap_consts; /**< for constants, print one item per line */ extern SC_EXPPP_EXPORT bool exppp_tail_comment; /**< print tail comment, such as END_ENTITY; --entity_name */ -SC_EXPPP_EXPORT void EXPRESSout(Express e); +SC_EXPPP_EXPORT void EXPRESSout( Express e ); -SC_EXPPP_EXPORT void ENTITYout(Entity e); -SC_EXPPP_EXPORT void EXPRout(Expression expr); -SC_EXPPP_EXPORT void FUNCout(Function f); -SC_EXPPP_EXPORT void PROCout(Procedure p); -SC_EXPPP_EXPORT void RULEout(Rule r); -SC_EXPPP_EXPORT char *SCHEMAout(Schema s); -SC_EXPPP_EXPORT void SCHEMAref_out(Schema s); -SC_EXPPP_EXPORT void STMTout(Statement s); -SC_EXPPP_EXPORT void TYPEout(Type t); -SC_EXPPP_EXPORT void TYPEhead_out(Type t); -SC_EXPPP_EXPORT void TYPEbody_out(Type t); -SC_EXPPP_EXPORT void WHEREout(Linked_List w); +SC_EXPPP_EXPORT void ENTITYout( Entity e ); +SC_EXPPP_EXPORT void EXPRout( Expression expr ); +SC_EXPPP_EXPORT void FUNCout( Function f ); +SC_EXPPP_EXPORT void PROCout( Procedure p ); +SC_EXPPP_EXPORT void RULEout( Rule r ); +SC_EXPPP_EXPORT char * SCHEMAout( Schema s ); +SC_EXPPP_EXPORT void SCHEMAref_out( Schema s ); +SC_EXPPP_EXPORT void STMTout( Statement s ); +SC_EXPPP_EXPORT void TYPEout( Type t ); +SC_EXPPP_EXPORT void TYPEhead_out( Type t ); +SC_EXPPP_EXPORT void TYPEbody_out( Type t ); +SC_EXPPP_EXPORT void WHEREout( Linked_List w ); -SC_EXPPP_EXPORT char *REFto_string(Dictionary refdict, Linked_List reflist, char *type, int level); -SC_EXPPP_EXPORT char *ENTITYto_string(Entity e); -SC_EXPPP_EXPORT char *SUBTYPEto_string(Expression e); -SC_EXPPP_EXPORT char *EXPRto_string(Expression expr); -SC_EXPPP_EXPORT char *FUNCto_string(Function f); -SC_EXPPP_EXPORT char *PROCto_string(Procedure p); -SC_EXPPP_EXPORT char *RULEto_string(Rule r); -SC_EXPPP_EXPORT char *SCHEMAref_to_string(Schema s); -SC_EXPPP_EXPORT char *STMTto_string(Statement s); -SC_EXPPP_EXPORT char *TYPEto_string(Type t); -SC_EXPPP_EXPORT char *TYPEhead_to_string(Type t); -SC_EXPPP_EXPORT char *TYPEbody_to_string(Type t); -SC_EXPPP_EXPORT char *WHEREto_string(Linked_List w); +SC_EXPPP_EXPORT char * REFto_string( Dictionary refdict, Linked_List reflist, char * type, int level ); +SC_EXPPP_EXPORT char * ENTITYto_string( Entity e ); +SC_EXPPP_EXPORT char * SUBTYPEto_string( Expression e ); +SC_EXPPP_EXPORT char * EXPRto_string( Expression expr ); +SC_EXPPP_EXPORT char * FUNCto_string( Function f ); +SC_EXPPP_EXPORT char * PROCto_string( Procedure p ); +SC_EXPPP_EXPORT char * RULEto_string( Rule r ); +SC_EXPPP_EXPORT char * SCHEMAref_to_string( Schema s ); +SC_EXPPP_EXPORT char * STMTto_string( Statement s ); +SC_EXPPP_EXPORT char * TYPEto_string( Type t ); +SC_EXPPP_EXPORT char * TYPEhead_to_string( Type t ); +SC_EXPPP_EXPORT char * TYPEbody_to_string( Type t ); +SC_EXPPP_EXPORT char * WHEREto_string( Linked_List w ); -SC_EXPPP_EXPORT int REFto_buffer(Dictionary refdict, Linked_List reflist, char *type, int level, char *buffer, int length); -SC_EXPPP_EXPORT int ENTITYto_buffer(Entity e, char *buffer, int length); -SC_EXPPP_EXPORT int EXPRto_buffer(Expression e, char *buffer, int length); -SC_EXPPP_EXPORT int FUNCto_buffer(Function e, char *buffer, int length); -SC_EXPPP_EXPORT int PROCto_buffer(Procedure e, char *buffer, int length); -SC_EXPPP_EXPORT int RULEto_buffer(Rule e, char *buffer, int length); -SC_EXPPP_EXPORT int SCHEMAref_to_buffer(Schema s, char *buffer, int length); -SC_EXPPP_EXPORT int STMTto_buffer(Statement s, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEto_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEhead_to_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int TYPEbody_to_buffer(Type t, char *buffer, int length); -SC_EXPPP_EXPORT int WHEREto_buffer(Linked_List w, char *buffer, int length); +SC_EXPPP_EXPORT int REFto_buffer( Dictionary refdict, Linked_List reflist, char * type, int level, char * buffer, int length ); +SC_EXPPP_EXPORT int ENTITYto_buffer( Entity e, char * buffer, int length ); +SC_EXPPP_EXPORT int EXPRto_buffer( Expression e, char * buffer, int length ); +SC_EXPPP_EXPORT int FUNCto_buffer( Function e, char * buffer, int length ); +SC_EXPPP_EXPORT int PROCto_buffer( Procedure e, char * buffer, int length ); +SC_EXPPP_EXPORT int RULEto_buffer( Rule e, char * buffer, int length ); +SC_EXPPP_EXPORT int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); +SC_EXPPP_EXPORT int STMTto_buffer( Statement s, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEto_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEhead_to_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int TYPEbody_to_buffer( Type t, char * buffer, int length ); +SC_EXPPP_EXPORT int WHEREto_buffer( Linked_List w, char * buffer, int length ); -SC_EXPPP_EXPORT int EXPRlength(Expression e); -extern SC_EXPPP_EXPORT void tail_comment(const char *name); -extern SC_EXPPP_EXPORT int count_newlines(char *s); +SC_EXPPP_EXPORT int EXPRlength( Expression e ); +extern SC_EXPPP_EXPORT void tail_comment( const char * name ); +extern SC_EXPPP_EXPORT int count_newlines( char * s ); #endif diff --git a/include/express/alg.h b/include/express/alg.h index 20b2891a7..bc76c5ddd 100644 --- a/include/express/alg.h +++ b/include/express/alg.h @@ -50,10 +50,10 @@ /* typedefs */ /************/ -typedef struct Scope_ *Procedure; -typedef struct Scope_ *Function; -typedef struct Scope_ *Rule; -typedef struct Where_ *Where; +typedef struct Scope_ * Procedure; +typedef struct Scope_ * Function; +typedef struct Scope_ * Rule; +typedef struct Where_ * Where; /***************************/ /* hidden type definitions */ @@ -63,13 +63,13 @@ typedef struct Where_ *Where; * As each (real) call is resolved, the tag->type is temporarily borrowed */ struct tag { - char *name; + char * name; Type type; }; /** location of fulltext of algorithm in source file */ struct FullText { - const char *filename; + const char * filename; unsigned int start, end; }; @@ -101,7 +101,7 @@ struct Rule_ { /** define a where clause */ struct Where_ { - Symbol *label; + Symbol * label; Expression expr; }; @@ -161,8 +161,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head WHERE_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Scope ALGcreate(char); -extern SC_EXPRESS_EXPORT void ALGinitialize(void); -extern SC_EXPRESS_EXPORT void ALGput_full_text(Scope, int, int); +extern SC_EXPRESS_EXPORT Scope ALGcreate( char ); +extern SC_EXPRESS_EXPORT void ALGinitialize( void ); +extern SC_EXPRESS_EXPORT void ALGput_full_text( Scope, int, int ); #endif /* ALGORITHM_H */ diff --git a/include/express/alloc.h b/include/express/alloc.h index 11a476878..79199773a 100644 --- a/include/express/alloc.h +++ b/include/express/alloc.h @@ -35,7 +35,7 @@ typedef long Align; union freelist { - union freelist *next; /**< next block on freelist */ + union freelist * next; /**< next block on freelist */ char memory; /**< user data */ Align aligner; /**< force alignment of blocks */ }; @@ -52,13 +52,13 @@ struct freelist_head { #endif int size; /**< size of a single elt incl. next ptr */ int bytes; /**< if we run out, allocate memory by this many bytes */ - Freelist *freelist; + Freelist * freelist; #ifdef SPACE_PROFILE int count; #endif }; -char *nnew(); +char * nnew(); #include "error.h" @@ -75,10 +75,10 @@ extern SC_EXPRESS_EXPORT int yylineno; fprintf(stderr,"fedex: out of space");\ } else {} -SC_EXPRESS_EXPORT void _ALLOCinitialize(void); -SC_EXPRESS_EXPORT void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2); -SC_EXPRESS_EXPORT void ALLOC_destroy(struct freelist_head *, Freelist *); -SC_EXPRESS_EXPORT void *ALLOC_new(struct freelist_head *); +SC_EXPRESS_EXPORT void _ALLOCinitialize( void ); +SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ); +SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * ); +SC_EXPRESS_EXPORT void * ALLOC_new( struct freelist_head * ); #endif /* ALLOC_H */ diff --git a/include/express/basic.h b/include/express/basic.h index 6e348c586..2dffecf3c 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -93,8 +93,8 @@ /* function pointer types */ /**************************/ -typedef void (*voidFuncptr)(); -typedef int (*intFuncptr)(); +typedef void ( *voidFuncptr )(); +typedef int ( *intFuncptr )(); #endif /* BASIC_H */ diff --git a/include/express/caseitem.h b/include/express/caseitem.h index ff422ad78..1c75f55bd 100644 --- a/include/express/caseitem.h +++ b/include/express/caseitem.h @@ -48,7 +48,7 @@ /* typedefs */ /************/ -typedef struct Case_Item_ *Case_Item; +typedef struct Case_Item_ * Case_Item; /****************/ /* modules used */ @@ -63,7 +63,7 @@ typedef struct Case_Item_ *Case_Item; struct Case_Item_ { Symbol symbol; Linked_List labels; - struct Statement_ *action; + struct Statement_ * action; }; /********************/ @@ -86,7 +86,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head CASE_IT_fl; #define CASE_IT_new() (struct Case_Item_ *)ALLOC_new(&CASE_IT_fl) #define CASE_IT_destroy(x) ALLOC_destroy(&CASE_IT_fl,(Freelist *)x) -extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate(Linked_List, struct Statement_ *); -extern SC_EXPRESS_EXPORT void CASE_ITinitialize(void); +extern SC_EXPRESS_EXPORT Case_Item CASE_ITcreate( Linked_List, struct Statement_ * ); +extern SC_EXPRESS_EXPORT void CASE_ITinitialize( void ); #endif /*CASE_ITEM_H*/ diff --git a/include/express/dict.h b/include/express/dict.h index d22f4c33c..f289ecca3 100644 --- a/include/express/dict.h +++ b/include/express/dict.h @@ -55,7 +55,7 @@ /* typedefs */ /************/ -typedef struct Hash_Table_ *Dictionary; +typedef struct Hash_Table_ * Dictionary; typedef HashEntry DictionaryEntry; /****************/ @@ -97,14 +97,14 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void DICTinitialize(void); -extern SC_EXPRESS_EXPORT void DICTcleanup(void); -extern SC_EXPRESS_EXPORT int DICTdefine(Dictionary, char *, void *, Symbol *, char); -extern SC_EXPRESS_EXPORT int DICT_define(Dictionary, char *, void *, Symbol *, char); -extern SC_EXPRESS_EXPORT void DICTundefine(Dictionary, char *); -extern SC_EXPRESS_EXPORT void *DICTlookup(Dictionary, char *); -extern SC_EXPRESS_EXPORT void *DICTlookup_symbol(Dictionary, char *, Symbol **); -extern SC_EXPRESS_EXPORT void *DICTdo(DictionaryEntry *); -extern SC_EXPRESS_EXPORT void DICTprint(Dictionary); +extern SC_EXPRESS_EXPORT void DICTinitialize( void ); +extern SC_EXPRESS_EXPORT void DICTcleanup( void ); +extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, void *, Symbol *, char ); +extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, void *, Symbol *, char ); +extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * ); +extern SC_EXPRESS_EXPORT void * DICTlookup( Dictionary, char * ); +extern SC_EXPRESS_EXPORT void * DICTlookup_symbol( Dictionary, char *, Symbol ** ); +extern SC_EXPRESS_EXPORT void * DICTdo( DictionaryEntry * ); +extern SC_EXPRESS_EXPORT void DICTprint( Dictionary ); #endif /*DICTIONARY_H*/ diff --git a/include/express/entity.h b/include/express/entity.h index 4c26c1c88..3440dc9bc 100644 --- a/include/express/entity.h +++ b/include/express/entity.h @@ -69,7 +69,7 @@ /* typedefs */ /************/ -typedef struct Scope_ *Entity; +typedef struct Scope_ * Entity; /****************/ /* modules used */ @@ -140,19 +140,19 @@ extern SC_EXPRESS_EXPORT int ENTITY_MARK; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcreate(struct Symbol_ *); -extern SC_EXPRESS_EXPORT void ENTITYinitialize(void); -extern SC_EXPRESS_EXPORT void ENTITYadd_attribute(struct Scope_ *, struct Variable_ *); -extern SC_EXPRESS_EXPORT struct Scope_ *ENTITYcopy(struct Scope_ *); -extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity(struct Scope_ *, char *, int); -extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute(struct Scope_ *, char *, struct Symbol_ **); -extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref(Entity, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype(Entity, Entity); -extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute(Entity, char *); -extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes(Entity); -extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype(Entity, Entity); -extern SC_EXPRESS_EXPORT void ENTITYadd_instance(Entity, void *); -extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset(Entity); -extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable(Entity, struct Variable_ *); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT void ENTITYinitialize( void ); +extern SC_EXPRESS_EXPORT void ENTITYadd_attribute( struct Scope_ *, struct Variable_ * ); +extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy( struct Scope_ * ); +extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, char *, int ); +extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute( struct Scope_ *, char *, struct Symbol_ ** ); +extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref( Entity, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * ); +extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity ); +extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity ); +extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, void *); +extern SC_EXPRESS_EXPORT int ENTITYget_initial_offset( Entity ); +extern SC_EXPRESS_EXPORT int ENTITYdeclares_variable( Entity, struct Variable_ * ); #endif /* ENTITY_H */ diff --git a/include/express/error.h b/include/express/error.h index 65e32387c..7eef340c4 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -166,7 +166,7 @@ typedef struct Error_ *Error; /********************/ extern SC_EXPRESS_EXPORT bool __ERROR_buffer_errors; -extern SC_EXPRESS_EXPORT const 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; @@ -180,28 +180,26 @@ extern SC_EXPRESS_EXPORT int malloc_debug_resolve; /* for debugging yacc/lex */ extern SC_EXPRESS_EXPORT int debug; -extern SC_EXPRESS_EXPORT void (*ERRORusage_function)(void); +extern SC_EXPRESS_EXPORT void ( *ERRORusage_function )( void ); /***********************/ /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer(void); -extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer(void); +extern SC_EXPRESS_EXPORT void ERROR_start_message_buffer( void ); +extern SC_EXPRESS_EXPORT void ERROR_flush_message_buffer( void ); -static inline void ERRORbuffer_messages(bool flag) -{ +static inline void ERRORbuffer_messages( bool flag ) { __ERROR_buffer_errors = flag; - if(__ERROR_buffer_errors) { + if( __ERROR_buffer_errors ) { ERROR_start_message_buffer(); } else { ERROR_flush_message_buffer(); } } -static inline void ERRORflush_messages(void) -{ - if(__ERROR_buffer_errors) { +static inline void ERRORflush_messages( void ) { + if( __ERROR_buffer_errors ) { ERROR_flush_message_buffer(); ERROR_start_message_buffer(); } @@ -212,22 +210,22 @@ static inline void ERRORflush_messages(void) /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void ERRORinitialize(void); -extern SC_EXPRESS_EXPORT void ERRORcleanup(void); -extern SC_EXPRESS_EXPORT void ERRORnospace(void); -extern SC_EXPRESS_EXPORT void ERRORabort(int); -extern SC_EXPRESS_EXPORT void ERRORreport(enum ErrorCode, ...); +extern SC_EXPRESS_EXPORT void ERRORinitialize( void ); +extern SC_EXPRESS_EXPORT void ERRORcleanup( void ); +extern SC_EXPRESS_EXPORT void ERRORnospace( void ); +extern SC_EXPRESS_EXPORT void ERRORabort( int ); +extern SC_EXPRESS_EXPORT void ERRORreport( enum ErrorCode, ... ); struct Symbol_; /* mention Symbol to avoid warning on following line */ -extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol(enum ErrorCode, struct Symbol_ *, ...); -extern SC_EXPRESS_EXPORT void ERRORreport_with_line(enum ErrorCode, int, ...); +extern SC_EXPRESS_EXPORT void ERRORreport_with_symbol( enum ErrorCode, struct Symbol_ *, ... ); +extern SC_EXPRESS_EXPORT void ERRORreport_with_line( enum ErrorCode, int, ... ); -extern SC_EXPRESS_EXPORT void ERRORset_warning(char *, bool); -extern SC_EXPRESS_EXPORT void ERRORset_all_warnings(bool); -extern SC_EXPRESS_EXPORT void ERRORsafe(jmp_buf env); -extern SC_EXPRESS_EXPORT void ERRORunsafe(void); +extern SC_EXPRESS_EXPORT void ERRORset_warning( char *, bool ); +extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); +extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); +extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); -extern SC_EXPRESS_EXPORT char *ERRORget_warnings_help(const char *prefix, const char *eol); +extern char * ERRORget_warnings_help(const char* prefix, const char *eol); extern bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ diff --git a/include/express/exp_kw.h b/include/express/exp_kw.h index 71974db6c..d8f1f6ec2 100644 --- a/include/express/exp_kw.h +++ b/include/express/exp_kw.h @@ -3,125 +3,125 @@ #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; +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 */ diff --git a/include/express/expbasic.h b/include/express/expbasic.h index 2db340b5a..63ab6e291 100644 --- a/include/express/expbasic.h +++ b/include/express/expbasic.h @@ -46,7 +46,7 @@ typedef enum { Lfalse, Lunknown, Ltrue } Logical; /* typedef ... Binary; done below because String not defined yet */ #ifndef _CLIENTDATA -typedef void *ClientData; +typedef void * ClientData; #define _CLIENTDATA #endif @@ -56,11 +56,11 @@ typedef void *ClientData; #include "alloc.h" -typedef struct Scope_ *Type; -typedef struct Scope_ *Scope; -typedef struct Scope_ *Schema; +typedef struct Scope_ * Type; +typedef struct Scope_ * Scope; +typedef struct Scope_ * Schema; -typedef char *Binary; +typedef char * Binary; #include "linklist.h" #define UNRESOLVED 0x0 diff --git a/include/express/expr.h b/include/express/expr.h index 73f2a1b1c..57191d5b6 100644 --- a/include/express/expr.h +++ b/include/express/expr.h @@ -88,10 +88,10 @@ typedef enum { } Op_Code; typedef struct Qualified_Attr Qualified_Attr; -typedef struct Expression_ *Expression; +typedef struct Expression_ * Expression; typedef Expression Ary_Expression, One_Of_Expression, Identifier, Literal; -typedef struct Query_ *Query; +typedef struct Query_ * Query; typedef One_Of_Expression Function_Call; typedef Ary_Expression Ternary_Expression, Binary_Expression, Unary_Expression; @@ -116,9 +116,9 @@ typedef Literal Aggregate_Literal, Integer_Literal, /* expression types */ struct Qualified_Attr { - struct Expression_ *complex; /**< complex entity instance */ - Symbol *entity; - Symbol *attribute; + struct Expression_ * complex; /**< complex entity instance */ + Symbol * entity; + Symbol * attribute; }; struct Op_Subexpression { @@ -132,22 +132,22 @@ struct Query_ { Variable local; Expression aggregate; /**< set from which to test */ Expression expression; /**< logical expression */ - struct Scope_ *scope; + struct Scope_ * scope; }; struct Funcall { - struct Scope_ *function; /**< can also be an entity because entities can be called as functions */ + struct Scope_ * function; /**< can also be an entity because entities can be called as functions */ Linked_List list; }; union expr_union { int integer; double real; - char *attribute; /**< inverse .... for 'attr' */ - char *binary; + char * attribute; /**< inverse .... for 'attr' */ + char * binary; int logical; bool boolean; - struct Query_ *query; + struct Query_ * query; struct Funcall funcall; /* if etype == aggregate, list of expressions */ @@ -158,7 +158,7 @@ union expr_union { * initializer in local vars, or * enumeration tags * or oneof value */ - struct Scope_ *entity; /**< used by subtype exp, group expr + struct Scope_ * entity; /**< used by subtype exp, group expr * and self expr, some funcall's and any * expr that results in an entity */ Variable variable; /**< attribute reference */ @@ -177,8 +177,8 @@ struct Expression_ { /** indexed by the op enumeration values */ struct EXPop_entry { - char *token; /**< literal token, e.g., "<>" */ - Type(*resolve)(Expression, struct Scope_ *); + char * token; /**< literal token, e.g., "<>" */ + Type( *resolve )( Expression, struct Scope_ * ); }; /********************/ @@ -249,18 +249,18 @@ extern SC_EXPRESS_EXPORT struct freelist_head QUAL_ATTR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Expression EXPcreate(Type); -extern SC_EXPRESS_EXPORT Expression EXPcreate_simple(Type); -extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol(Type, Symbol *); -extern SC_EXPRESS_EXPORT Expression UN_EXPcreate(Op_Code, Expression); -extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate(Op_Code, Expression, Expression); -extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate(Op_Code, Expression, Expression, Expression); -extern SC_EXPRESS_EXPORT Expression QUERYcreate(Symbol *, Expression); -extern SC_EXPRESS_EXPORT void EXPinitialize(void); -extern SC_EXPRESS_EXPORT void EXPcleanup(void); -extern SC_EXPRESS_EXPORT Type EXPtype(Expression, struct Scope_ *); -extern SC_EXPRESS_EXPORT int EXPget_integer_value(Expression); - -Type EXPresolve_op_dot(Expression, Scope); +extern SC_EXPRESS_EXPORT Expression EXPcreate( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_simple( Type ); +extern SC_EXPRESS_EXPORT Expression EXPcreate_from_symbol( Type, Symbol * ); +extern SC_EXPRESS_EXPORT Expression UN_EXPcreate( Op_Code, Expression ); +extern SC_EXPRESS_EXPORT Expression BIN_EXPcreate( Op_Code, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression TERN_EXPcreate( Op_Code, Expression, Expression, Expression ); +extern SC_EXPRESS_EXPORT Expression QUERYcreate( Symbol *, Expression ); +extern SC_EXPRESS_EXPORT void EXPinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPcleanup( void ); +extern SC_EXPRESS_EXPORT Type EXPtype( Expression, struct Scope_ * ); +extern SC_EXPRESS_EXPORT int EXPget_integer_value( Expression ); + +Type EXPresolve_op_dot( Expression, Scope ); #endif /*EXPRESSION_H*/ diff --git a/include/express/express.h b/include/express/express.h index a89c67391..e849ae56a 100644 --- a/include/express/express.h +++ b/include/express/express.h @@ -68,7 +68,7 @@ /* typedefs */ /************/ -typedef struct Scope_ *Express; +typedef struct Scope_ * Express; /****************/ /* modules used */ @@ -79,33 +79,33 @@ typedef struct Scope_ *Express; /***************************/ struct Express_ { - FILE *file; - char *filename; - char *basename; /**< name of file but without directory or .exp suffix */ + FILE * file; + char * filename; + char * basename; /**< name of file but without directory or .exp suffix */ }; /********************/ /* global variables */ /********************/ -extern SC_EXPRESS_EXPORT char *input_filename; +extern SC_EXPRESS_EXPORT char * input_filename; extern SC_EXPRESS_EXPORT Linked_List EXPRESS_path; extern SC_EXPRESS_EXPORT int EXPRESSpass; -extern SC_EXPRESS_EXPORT void (*EXPRESSinit_args)(int, char **); -extern SC_EXPRESS_EXPORT void (*EXPRESSinit_parse)(void); -extern SC_EXPRESS_EXPORT int (*EXPRESSfail)(Express); -extern SC_EXPRESS_EXPORT int (*EXPRESSsucceed)(Express); -extern SC_EXPRESS_EXPORT void (*EXPRESSbackend)(Express); -extern SC_EXPRESS_EXPORT char *EXPRESSprogram_name; +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_args )( int, char ** ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSinit_parse )( void ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSfail )( Express ); +extern SC_EXPRESS_EXPORT int ( *EXPRESSsucceed )( Express ); +extern SC_EXPRESS_EXPORT void ( *EXPRESSbackend )( Express ); +extern SC_EXPRESS_EXPORT char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -extern SC_EXPRESS_EXPORT int (*EXPRESSgetopt)(int, char *); +extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt )( int, char * ); extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas; extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */ -extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_NVL; -extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_USEDIN; +extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_NVL; +extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN; /******************************/ /* macro function definitions */ @@ -120,15 +120,15 @@ extern SC_EXPRESS_EXPORT struct Scope_ *FUNC_USEDIN; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Express EXPRESScreate(void); -extern SC_EXPRESS_EXPORT void EXPRESSdestroy(Express); -extern SC_EXPRESS_EXPORT void EXPRESSparse(Express, FILE *, char *); -extern SC_EXPRESS_EXPORT void EXPRESSinitialize(void); -extern SC_EXPRESS_EXPORT void EXPRESScleanup(void); -extern SC_EXPRESS_EXPORT void EXPRESSresolve(Express); -extern SC_EXPRESS_EXPORT int EXPRESS_fail(Express model); -extern SC_EXPRESS_EXPORT int EXPRESS_succeed(Express model); -extern void EXPRESSinit_init(void); -extern SC_EXPRESS_EXPORT void build_complex(Express); +extern SC_EXPRESS_EXPORT Express EXPRESScreate( void ); +extern SC_EXPRESS_EXPORT void EXPRESSdestroy( Express ); +extern SC_EXPRESS_EXPORT void EXPRESSparse( Express, FILE *, char * ); +extern SC_EXPRESS_EXPORT void EXPRESSinitialize( void ); +extern SC_EXPRESS_EXPORT void EXPRESScleanup( void ); +extern SC_EXPRESS_EXPORT void EXPRESSresolve( Express ); +extern SC_EXPRESS_EXPORT int EXPRESS_fail( Express model ); +extern SC_EXPRESS_EXPORT int EXPRESS_succeed( Express model ); +extern void EXPRESSinit_init( void ); +extern SC_EXPRESS_EXPORT void build_complex( Express ); #endif /*EXPRESS_H*/ diff --git a/include/express/factory.h b/include/express/factory.h index 4942256fe..77075720d 100644 --- a/include/express/factory.h +++ b/include/express/factory.h @@ -1,8 +1,6 @@ #ifndef __FACTORY_H_ #define __FACTORY_H_ -#include "sc_export.h" - -SC_EXPRESS_EXPORT void FACTORYinitialize(); +void FACTORYinitialize(); #endif /* __FACTORY_H_ */ diff --git a/include/express/hash.h b/include/express/hash.h index 5b3e9b150..c5d1dfffe 100644 --- a/include/express/hash.h +++ b/include/express/hash.h @@ -116,14 +116,14 @@ typedef unsigned long Address; /****************/ typedef struct Element_ { - char *key; - char *data; - struct Element_ *next; - Symbol *symbol; /**< for debugging hash conflicts */ + char * key; + char * data; + struct Element_ * next; + Symbol * symbol; /**< for debugging hash conflicts */ char type; /**< user-supplied type */ -} *Element; +} * Element; -typedef Element *Segment; +typedef Element * Segment; typedef struct Hash_Table_ { #if 0 @@ -136,7 +136,7 @@ typedef struct Hash_Table_ { unsigned int MinLoadFactor; unsigned int MaxLoadFactor; Segment Directory[DIRECTORY_SIZE]; -} *Hash_Table; +} * Hash_Table; typedef struct { unsigned int i; /**< segment index (i think) */ @@ -192,13 +192,13 @@ This change only seems to have affected hash.h and hash.c /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void HASHinitialize(void); -extern SC_EXPRESS_EXPORT Hash_Table HASHcreate(unsigned); -extern SC_EXPRESS_EXPORT Hash_Table HASHcopy(Hash_Table); -extern SC_EXPRESS_EXPORT void HASHdestroy(Hash_Table); -extern SC_EXPRESS_EXPORT Element HASHsearch(Hash_Table, Element, Action); -extern SC_EXPRESS_EXPORT void HASHlistinit(Hash_Table, HashEntry *); -extern SC_EXPRESS_EXPORT void HASHlistinit_by_type(Hash_Table, HashEntry *, char); -extern SC_EXPRESS_EXPORT Element HASHlist(HashEntry *); +extern SC_EXPRESS_EXPORT void HASHinitialize( void ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( unsigned ); +extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table ); +extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table ); +extern SC_EXPRESS_EXPORT Element HASHsearch( Hash_Table, Element, Action ); +extern SC_EXPRESS_EXPORT void HASHlistinit( Hash_Table, HashEntry * ); +extern SC_EXPRESS_EXPORT void HASHlistinit_by_type( Hash_Table, HashEntry *, char ); +extern SC_EXPRESS_EXPORT Element HASHlist( HashEntry * ); #endif /*HASH_H*/ diff --git a/include/express/info.h b/include/express/info.h index 2a8c40d63..1a96cf679 100644 --- a/include/express/info.h +++ b/include/express/info.h @@ -6,9 +6,9 @@ * informative functions that were in express.c/express.h */ -extern SC_EXPRESS_EXPORT char *EXPRESSversion(void); +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); +extern SC_EXPRESS_EXPORT void EXPRESSusage( int _exit ); #endif /* INFO_H */ diff --git a/include/express/lexact.h b/include/express/lexact.h index 5fb2212f2..9e9ac3559 100644 --- a/include/express/lexact.h +++ b/include/express/lexact.h @@ -56,9 +56,9 @@ typedef struct Scan_Buffer { #ifdef keep_nul int numRead; #endif - char *savedPos; - FILE *file; - const char *filename; + char * savedPos; + FILE * file; + const char * filename; bool readEof; int lineno; int bol; @@ -70,7 +70,7 @@ typedef struct Scan_Buffer { extern SC_EXPRESS_EXPORT Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; extern SC_EXPRESS_EXPORT int SCAN_current_buffer; -extern SC_EXPRESS_EXPORT char *SCANcurrent; +extern SC_EXPRESS_EXPORT char * SCANcurrent; /******************************/ /* macro function definitions */ @@ -93,22 +93,22 @@ extern SC_EXPRESS_EXPORT char *SCANcurrent; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SCANinitialize(void); -extern SC_EXPRESS_EXPORT void SCANcleanup(void); -extern SC_EXPRESS_EXPORT int SCANprocess_real_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal(char *); -extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_string(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string(const char *); -extern SC_EXPRESS_EXPORT int SCANprocess_semicolon(const char *, int); -extern SC_EXPRESS_EXPORT void SCANsave_comment(const char *); -extern SC_EXPRESS_EXPORT bool SCANread(void); -extern SC_EXPRESS_EXPORT void SCANinclude_file(char *); -SC_EXPRESS_EXPORT void SCANlowerize(char *); -SC_EXPRESS_EXPORT void SCANupperize(char *); -extern SC_EXPRESS_EXPORT char *SCANstrdup(const char *); -extern SC_EXPRESS_EXPORT long SCANtell(void); +extern SC_EXPRESS_EXPORT void SCANinitialize( void ); +extern SC_EXPRESS_EXPORT void SCANcleanup( void ); +extern SC_EXPRESS_EXPORT int SCANprocess_real_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_integer_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_binary_literal( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_logical_literal( char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_identifier_or_keyword( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_encoded_string( const char * ); +extern SC_EXPRESS_EXPORT int SCANprocess_semicolon( const char *, int ); +extern SC_EXPRESS_EXPORT void SCANsave_comment( const char * ); +extern SC_EXPRESS_EXPORT bool SCANread( void ); +extern SC_EXPRESS_EXPORT void SCANinclude_file( char * ); + SC_EXPRESS_EXPORT void SCANlowerize( char * ); + SC_EXPRESS_EXPORT void SCANupperize( char * ); +extern SC_EXPRESS_EXPORT char * SCANstrdup( const char * ); +extern SC_EXPRESS_EXPORT long SCANtell( void ); #endif /* LEX_ACTIONS_H */ diff --git a/include/express/linklist.h b/include/express/linklist.h index 794ee9bcc..76c31a461 100644 --- a/include/express/linklist.h +++ b/include/express/linklist.h @@ -44,7 +44,7 @@ /* typedefs */ /************/ -typedef struct Linked_List_ *Linked_List; +typedef struct Linked_List_ * Linked_List; /****************/ /* modules used */ @@ -57,10 +57,10 @@ typedef struct Linked_List_ *Linked_List; /***************************/ typedef struct Link_ { - struct Link_ *next; - struct Link_ *prev; + struct Link_ * next; + struct Link_ * prev; void *data; -} *Link; +} * Link; struct Linked_List_ { Link mark; @@ -124,22 +124,22 @@ extern SC_EXPRESS_EXPORT struct freelist_head LIST_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void LISTinitialize(void); -extern SC_EXPRESS_EXPORT void LISTcleanup(void); -extern SC_EXPRESS_EXPORT Linked_List LISTcreate(void); -extern SC_EXPRESS_EXPORT Linked_List LISTcopy(Linked_List); -extern SC_EXPRESS_EXPORT void LISTsort(Linked_List, int (*comp)(void *, void *)); -extern SC_EXPRESS_EXPORT void LISTswap(Link, Link); -extern SC_EXPRESS_EXPORT void *LISTadd_first(Linked_List, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_last(Linked_List, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_after(Linked_List, Link, void *); -extern SC_EXPRESS_EXPORT void *LISTadd_before(Linked_List, Link, void *); -extern SC_EXPRESS_EXPORT void *LISTremove_first(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_first(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_second(Linked_List); -extern SC_EXPRESS_EXPORT void *LISTget_nth(Linked_List, int); -extern SC_EXPRESS_EXPORT void LISTfree(Linked_List); -extern SC_EXPRESS_EXPORT int LISTget_length(Linked_List); -extern SC_EXPRESS_EXPORT bool LISTempty(Linked_List list); +extern SC_EXPRESS_EXPORT void LISTinitialize( void ); +extern SC_EXPRESS_EXPORT void LISTcleanup( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcreate( void ); +extern SC_EXPRESS_EXPORT Linked_List LISTcopy( Linked_List ); +extern SC_EXPRESS_EXPORT void LISTsort( Linked_List, int (*comp)(void*, void*) ); +extern SC_EXPRESS_EXPORT void LISTswap( Link, Link ); +extern SC_EXPRESS_EXPORT void * LISTadd_first( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_last( Linked_List, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_after( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTadd_before( Linked_List, Link, void * ); +extern SC_EXPRESS_EXPORT void * LISTremove_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_first( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_second( Linked_List ); +extern SC_EXPRESS_EXPORT void * LISTget_nth( Linked_List, int ); +extern SC_EXPRESS_EXPORT void LISTfree( Linked_List ); +extern SC_EXPRESS_EXPORT int LISTget_length( Linked_List ); +extern SC_EXPRESS_EXPORT bool LISTempty( Linked_List list ); #endif /*LINKED_LIST_H*/ diff --git a/include/express/memory.h b/include/express/memory.h index 3d1e58c74..77357cf7e 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -1,8 +1,6 @@ #ifndef __MEMORY_H #define __MEMORY_H -#include "sc_export.h" - -SC_EXPRESS_EXPORT void MEMORYinitialize(); +void MEMORYinitialize(); #endif // __MEMORY_H diff --git a/include/express/object.h b/include/express/object.h index 524451081..e5736f45b 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -68,8 +68,8 @@ /***************************/ struct Object { - struct Symbol_ *(*get_symbol)(); - char *type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ + struct Symbol_ * ( *get_symbol )(); + char * type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ int bits; /**< a bitwise selector of a type, i.e. OBJ_XX_BITS */ }; diff --git a/include/express/resolve.h b/include/express/resolve.h index 497c1a023..7eca8aa07 100644 --- a/include/express/resolve.h +++ b/include/express/resolve.h @@ -60,29 +60,29 @@ extern SC_EXPRESS_EXPORT int print_objects_while_running; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void RESOLVEinitialize(void); -extern SC_EXPRESS_EXPORT void RESOLVEcleanup(void); -extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements(Scope); -extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers(Scope); -extern SC_EXPRESS_EXPORT void SCOPEresolve_types(Scope); -extern SC_EXPRESS_EXPORT void TYPE_resolve(Type *); -extern SC_EXPRESS_EXPORT void EXP_resolve(Expression, Scope, Type); -extern SC_EXPRESS_EXPORT void ALGresolve(Scope); -extern SC_EXPRESS_EXPORT void SCHEMAresolve(Scope); -extern SC_EXPRESS_EXPORT void RENAMEresolve(Rename *, Schema); +extern SC_EXPRESS_EXPORT void RESOLVEinitialize( void ); +extern SC_EXPRESS_EXPORT void RESOLVEcleanup( void ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_expressions_statements( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_subsupers( Scope ); +extern SC_EXPRESS_EXPORT void SCOPEresolve_types( Scope ); +extern SC_EXPRESS_EXPORT void TYPE_resolve( Type * ); +extern SC_EXPRESS_EXPORT void EXP_resolve( Expression, Scope, Type ); +extern SC_EXPRESS_EXPORT void ALGresolve( Scope ); +extern SC_EXPRESS_EXPORT void SCHEMAresolve( Scope ); +extern SC_EXPRESS_EXPORT void RENAMEresolve( Rename *, Schema ); /* * for unit tests, no extern / export */ -void VAR_resolve_expressions(Variable, Entity); -void ENTITYresolve_subtypes(Schema); -void ENTITYresolve_supertypes(Entity); -void ENTITYresolve_expressions(Entity e); -void ALGresolve_expressions_statements(Scope, Linked_List); -int WHEREresolve(Linked_List, Scope, int); -void TYPEresolve_expressions(Type, Scope); -void STMTresolve(Statement, Scope); -void STMTlist_resolve(Linked_List, Scope); -int ENTITYresolve_subtype_expression(Expression, Entity, Linked_List *); +void VAR_resolve_expressions( Variable, Entity ); +void ENTITYresolve_subtypes( Schema ); +void ENTITYresolve_supertypes( Entity ); +void ENTITYresolve_expressions( Entity e ); +void ALGresolve_expressions_statements( Scope, Linked_List ); +int WHEREresolve( Linked_List, Scope, int ); +void TYPEresolve_expressions( Type, Scope ); +void STMTresolve( Statement, Scope ); +void STMTlist_resolve( Linked_List, Scope ); +int ENTITYresolve_subtype_expression( Expression, Entity, Linked_List * ); #endif /*RESOLVE_H*/ diff --git a/include/express/schema.h b/include/express/schema.h index c2d1c6ca0..1d2ce5c4b 100644 --- a/include/express/schema.h +++ b/include/express/schema.h @@ -72,10 +72,10 @@ enum rename_type { use, ref }; typedef struct Rename { - struct Symbol_ *schema_sym; + struct Symbol_ * schema_sym; Schema schema; - struct Symbol_ *old; - struct Symbol_ *nnew; + struct Symbol_ * old; + struct Symbol_ * nnew; void *object; /**< once object has been looked up */ char type; /**< drat, need to remember this once renames have been * resolved to avoid looking them up in the dictionary again */ @@ -133,22 +133,22 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARfind(Scope, char *, int); -extern SC_EXPRESS_EXPORT Schema SCHEMAcreate(void); -extern SC_EXPRESS_EXPORT void SCHEMAinitialize(void); -extern SC_EXPRESS_EXPORT void SCHEMAadd_use(Schema, Symbol *, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT void SCHEMAadd_reference(Schema, Symbol *, Symbol *, Symbol *); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_use(Schema, Rename *); -extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference(Schema, Rename *); -extern SC_EXPRESS_EXPORT void *SCHEMAfind(Schema, char *name, int search_refs); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate(char); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny(char); -extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab(char); -extern SC_EXPRESS_EXPORT void SCOPEdestroy(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref(Scope); - -void SCHEMA_get_entities_ref(Scope, Linked_List); +extern SC_EXPRESS_EXPORT Variable VARfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT Schema SCHEMAcreate( void ); +extern SC_EXPRESS_EXPORT void SCHEMAinitialize( void ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_use( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAadd_reference( Schema, Symbol *, Symbol *, Symbol * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_use( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void SCHEMAdefine_reference( Schema, Rename * ); +extern SC_EXPRESS_EXPORT void * SCHEMAfind( Schema, char * name, int search_refs ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_tiny( char ); +extern SC_EXPRESS_EXPORT Scope SCOPEcreate_nostab( char ); +extern SC_EXPRESS_EXPORT void SCOPEdestroy( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref( Scope ); + +void SCHEMA_get_entities_ref( Scope, Linked_List ); #endif /* SCHEMA_H */ diff --git a/include/express/scope.h b/include/express/scope.h index 26e4a7f3f..8f16fafbf 100644 --- a/include/express/scope.h +++ b/include/express/scope.h @@ -83,16 +83,16 @@ struct Scope_ { ClientData clientData; /**< user may use this for any purpose */ int search_id; /**< key to avoid searching this scope twice */ Dictionary symbol_table, enum_table; - struct Scope_ *superscope; + struct Scope_ * superscope; union { - struct Procedure_ *proc; - struct Function_ *func; - struct Rule_ *rule; - struct Entity_ *entity; - struct Schema_ *schema; - struct Express_ *express; - struct Increment_ *incr; - struct TypeHead_ *type; + struct Procedure_ * proc; + struct Function_ * func; + struct Rule_ * rule; + struct Entity_ * entity; + struct Schema_ * schema; + struct Express_ * express; + struct Increment_ * incr; + struct TypeHead_ * type; /* no, query owns a scope rather than scope owning a query * struct Query *query; */ } u; @@ -134,16 +134,16 @@ struct Scope_ { /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT struct Symbol_ *SCOPE_get_symbol(void *); -extern SC_EXPRESS_EXPORT void SCOPE_get_entities(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities(Scope); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order(Scope); -extern SC_EXPRESS_EXPORT void *SCOPEfind(Scope, char *, int); -extern SC_EXPRESS_EXPORT void SCOPE_get_functions(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions(Scope); -extern SC_EXPRESS_EXPORT void SCOPE_get_rules(Scope, Linked_List); -extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules(Scope); - -void *SCOPE_find(Scope, char *, int); +extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( void * ); +extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope ); +extern SC_EXPRESS_EXPORT void * SCOPEfind( Scope, char *, int ); +extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope ); +extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List ); +extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope ); + +void * SCOPE_find( Scope, char *, int ); #endif /* SCOPE_H */ diff --git a/include/express/stmt.h b/include/express/stmt.h index b0d49f3ff..21f5e4645 100644 --- a/include/express/stmt.h +++ b/include/express/stmt.h @@ -56,17 +56,17 @@ /* typedefs */ /************/ -typedef struct Statement_ *Statement, - *Alias, - *Assignment, - *Case_Statement, - *Compound_Statement, - *Conditional, - *Loop, - *Procedure_Call, - *Return_Statement; - -typedef struct Scope_ *Increment; +typedef struct Statement_ * Statement, + *Alias, + *Assignment, + *Case_Statement, + *Compound_Statement, + *Conditional, + *Loop, + *Procedure_Call, + *Return_Statement; + +typedef struct Scope_ * Increment; /****************/ /* modules used */ @@ -97,21 +97,21 @@ struct Statement_ { int type; /**< one of STMT_XXX above */ /* hey, is there nothing in common beside symbol and private data?? */ union u_statement { - struct Alias_ *alias; - struct Assignment_ *assign; - struct Case_Statement_ *Case; - struct Compound_Statement_ *compound; - struct Conditional_ *cond; - struct Loop_ *loop; - struct Procedure_Call_ *proc; - struct Return_Statement_ *ret; + struct Alias_ * alias; + struct Assignment_ * assign; + struct Case_Statement_ * Case; + struct Compound_Statement_ * compound; + struct Conditional_ * cond; + struct Loop_ * loop; + struct Procedure_Call_ * proc; + struct Return_Statement_ * ret; /* skip & escape have no data */ } u; }; struct Alias_ { - struct Scope_ *scope; - struct Variable_ *variable; + struct Scope_ * scope; + struct Variable_ * variable; Linked_List statements; /**< list of statements */ }; @@ -136,7 +136,7 @@ struct Conditional_ { }; struct Loop_ { - struct Scope_ *scope; /**< scope for increment control */ + struct Scope_ * scope; /**< scope for increment control */ Expression while_expr; Expression until_expr; Linked_List statements; /**< list of statements */ @@ -150,7 +150,7 @@ struct Increment_ { }; struct Procedure_Call_ { - struct Scope_ *procedure; + struct Scope_ * procedure; Linked_List parameters; /**< list of expressions */ }; @@ -225,17 +225,17 @@ extern SC_EXPRESS_EXPORT Statement STATEMENT_SKIP; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Statement STMTcreate(int); -extern SC_EXPRESS_EXPORT Statement ALIAScreate(struct Scope_ *, Variable, Linked_List); -extern SC_EXPRESS_EXPORT Statement CASEcreate(Expression, Linked_List); -extern SC_EXPRESS_EXPORT Statement ASSIGNcreate(Expression, Expression); -extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate(Linked_List); -extern SC_EXPRESS_EXPORT Statement CONDcreate(Expression, Linked_List, Linked_List); -extern SC_EXPRESS_EXPORT Statement LOOPcreate(struct Scope_ *, Expression, Expression, Linked_List); -extern SC_EXPRESS_EXPORT Statement PCALLcreate(Linked_List); -extern SC_EXPRESS_EXPORT Statement RETcreate(Expression); -extern SC_EXPRESS_EXPORT void STMTinitialize(void); -extern SC_EXPRESS_EXPORT struct Scope_ *INCR_CTLcreate(Symbol *, Expression start, - Expression end, Expression increment); +extern SC_EXPRESS_EXPORT Statement STMTcreate( int ); +extern SC_EXPRESS_EXPORT Statement ALIAScreate( struct Scope_ *, Variable, Linked_List ); +extern SC_EXPRESS_EXPORT Statement CASEcreate( Expression , Linked_List ); +extern SC_EXPRESS_EXPORT Statement ASSIGNcreate( Expression , Expression ); +extern SC_EXPRESS_EXPORT Statement COMP_STMTcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement CONDcreate( Expression, Linked_List, Linked_List ); +extern SC_EXPRESS_EXPORT Statement LOOPcreate( struct Scope_ *, Expression, Expression, Linked_List ); +extern SC_EXPRESS_EXPORT Statement PCALLcreate( Linked_List ); +extern SC_EXPRESS_EXPORT Statement RETcreate( Expression ); +extern SC_EXPRESS_EXPORT void STMTinitialize( void ); +extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate( Symbol *, Expression start, + Expression end, Expression increment ); #endif /*STATEMENT_H*/ diff --git a/include/express/symbol.h b/include/express/symbol.h index 8da717b51..b589b01e2 100644 --- a/include/express/symbol.h +++ b/include/express/symbol.h @@ -58,8 +58,8 @@ typedef struct Symbol_ Symbol; /***************************/ struct Symbol_ { - char *name; - const char *filename; + char * name; + const char * filename; int line; char resolved; }; @@ -88,7 +88,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT void SYMBOLinitialize(void); -SC_EXPRESS_EXPORT Symbol *SYMBOLcreate(char *name, int line, const char *filename); +extern SC_EXPRESS_EXPORT void SYMBOLinitialize( void ); +SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename ); #endif /* SYMBOL_H */ diff --git a/include/express/type.h b/include/express/type.h index c0680aea5..321fe716e 100644 --- a/include/express/type.h +++ b/include/express/type.h @@ -115,8 +115,8 @@ enum type_enum { /* typedefs */ /************/ -typedef struct TypeHead_ *TypeHead; -typedef struct TypeBody_ *TypeBody; +typedef struct TypeHead_ * TypeHead; +typedef struct TypeBody_ * TypeBody; typedef enum type_enum TypeType; /* provide a replacement for Class */ @@ -140,7 +140,7 @@ typedef enum type_enum Class; struct TypeHead_ { Type head; /**< if we are a defined type this is who we point to */ - struct TypeBody_ *body; /**< true type, ignoring defined types */ + struct TypeBody_ * body; /**< true type, ignoring defined types */ #if 0 /* if we are concerned about memory (over time) uncomment this and */ /* other references to refcount in parser and TYPEresolve. It is */ @@ -151,7 +151,7 @@ struct TypeHead_ { struct TypeBody_ { #if 1 - struct TypeHead_ *head; /**< for debugging only */ + struct TypeHead_ * head; /**< for debugging only */ #endif enum type_enum type; /**< bits describing this type, int, real, etc */ struct { @@ -174,7 +174,7 @@ struct TypeBody_ { Linked_List list; /**< used by select_types and composed types, such as for a list of entities in an instance */ Expression upper; Expression lower; - struct Scope_ *entity; /**< only used by entity types */ + struct Scope_ * entity; /**< only used by entity types */ }; /********************/ @@ -291,20 +291,20 @@ extern SC_EXPRESS_EXPORT struct freelist_head TYPEBODY_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Type TYPEcreate_partial(struct Symbol_ *, Scope); +extern SC_EXPRESS_EXPORT Type TYPEcreate_partial( struct Symbol_ *, Scope ); -extern SC_EXPRESS_EXPORT Type TYPEcreate(enum type_enum); -extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously(TypeBody); -extern SC_EXPRESS_EXPORT Type TYPEcreate_name(struct Symbol_ *); -extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab(struct Symbol_ *, Scope, char); -extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate(enum type_enum); -extern SC_EXPRESS_EXPORT void TYPEinitialize(void); -extern SC_EXPRESS_EXPORT void TYPEcleanup(void); +extern SC_EXPRESS_EXPORT Type TYPEcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_from_body_anonymously( TypeBody ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_name( struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_nostab( struct Symbol_ *, Scope, char ); +extern SC_EXPRESS_EXPORT TypeBody TYPEBODYcreate( enum type_enum ); +extern SC_EXPRESS_EXPORT void TYPEinitialize( void ); +extern SC_EXPRESS_EXPORT void TYPEcleanup( void ); -extern SC_EXPRESS_EXPORT bool TYPEinherits_from(Type, enum type_enum); -extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type(Type); +extern SC_EXPRESS_EXPORT bool TYPEinherits_from( Type, enum type_enum ); +extern SC_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type( Type ); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type(Type, Scope, struct Symbol_ *); -extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag(Type, Scope, struct Symbol_ *); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_type( Type, Scope, struct Symbol_ * ); +extern SC_EXPRESS_EXPORT Type TYPEcreate_user_defined_tag( Type, Scope, struct Symbol_ * ); #endif /* TYPE_H */ diff --git a/include/express/variable.h b/include/express/variable.h index b9d09a57d..308116459 100644 --- a/include/express/variable.h +++ b/include/express/variable.h @@ -62,7 +62,7 @@ /* typedefs */ /************/ -typedef struct Variable_ *Variable; +typedef struct Variable_ * Variable; /****************/ /* modules used */ @@ -91,7 +91,7 @@ struct Variable_ { unsigned int attribute : 1; /**< is an attribute (rule parameters are marked this way, too) */ } flags; - Symbol *inverse_symbol; /**< entity symbol */ + Symbol * inverse_symbol; /**< entity symbol */ Variable inverse_attribute; /**< attribute related by inverse relationship */ }; @@ -125,8 +125,8 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl; /* function prototypes */ /***********************/ -extern SC_EXPRESS_EXPORT Variable VARcreate(Expression, Type); -extern SC_EXPRESS_EXPORT void VARinitialize(void); -extern SC_EXPRESS_EXPORT char *VARget_simple_name(Variable); +extern SC_EXPRESS_EXPORT Variable VARcreate( Expression, Type ); +extern SC_EXPRESS_EXPORT void VARinitialize( void ); +extern SC_EXPRESS_EXPORT char * VARget_simple_name( Variable ); #endif /* VARIABLE_H */ diff --git a/include/ordered_attrs.h b/include/ordered_attrs.h index dded023f6..56a3b410f 100644 --- a/include/ordered_attrs.h +++ b/include/ordered_attrs.h @@ -16,13 +16,13 @@ typedef struct { } orderedAttr; /**set the entity we're working on, init working variables */ -extern SC_EXPRESS_EXPORT void orderedAttrsInit(Entity e); +extern SC_EXPRESS_EXPORT void orderedAttrsInit( Entity e ); /**free memory */ extern SC_EXPRESS_EXPORT void orderedAttrsCleanup(); /**get next attr; not thread safe (as if the rest of libexpress is) */ -extern SC_EXPRESS_EXPORT const orderedAttr *nextAttr(); +extern SC_EXPRESS_EXPORT const orderedAttr * nextAttr(); #ifdef __cplusplus } diff --git a/include/sc_cf.h.in b/include/sc_cf_cmake.h.in similarity index 94% rename from include/sc_cf.h.in rename to include/sc_cf_cmake.h.in index 67d88c433..6caec92aa 100644 --- a/include/sc_cf.h.in +++ b/include/sc_cf_cmake.h.in @@ -2,7 +2,6 @@ #define SCL_CF_H /**** Define statements for CMake ****/ -#cmakedefine SC_VERSION "@SC_VERSION@" #cmakedefine HAVE_NDIR_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_SYS_STAT_H 1 diff --git a/misc/astyle.cfg b/misc/astyle.cfg index da64a0c92..40268faed 100644 --- a/misc/astyle.cfg +++ b/misc/astyle.cfg @@ -11,7 +11,7 @@ suffix=none #don't create backup files -style=kr #Kernighan & Ritchie style +style=java #compact bracket style indent=spaces=4 @@ -19,10 +19,11 @@ indent-classes indent-switches indent-namespaces pad-oper #pad (space) around operators +pad-paren-in #pad inside parenthesis unpad-paren #remove parenthesis padding other than requested above add-brackets #add brackets on one-line conditionals convert-tabs #convert all tabs to spaces -align-pointer=name #char *foo +align-pointer=middle #char * foo lineend=linux #lines end with LF (linux), not CRLF (windows) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 5aad0a929..cd41f97b6 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -15,6 +15,7 @@ set(SC_BASE_HDRS sc_getopt.h sc_trace_fprintf.h sc_mkdir.h + sc_nullptr.h path2str.h judy/src/judy.h judy/src/judyLArray.h @@ -32,7 +33,7 @@ if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) endif() -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base psapi) @@ -40,7 +41,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base-static psapi) @@ -61,7 +62,7 @@ if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") install(FILES ${SC_BASE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/base) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base) # Local Variables: # tab-width: 8 diff --git a/src/base/judy/misc/judy64n.c b/src/base/judy/misc/judy64n.c index 5e9d61d02..8dc8f909a 100644 --- a/src/base/judy/misc/judy64n.c +++ b/src/base/judy/misc/judy64n.c @@ -40,24 +40,24 @@ #include #ifdef linux -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE -#define __USE_FILE_OFFSET64 + #define _FILE_OFFSET_BITS 64 + #define _LARGEFILE_SOURCE + #define __USE_FILE_OFFSET64 -#include + #include #else -#ifdef __BIG_ENDIAN__ -#ifndef BYTE_ORDER -#define BYTE_ORDER 4321 -#endif -#else -#ifndef BYTE_ORDER -#define BYTE_ORDER 1234 -#endif -#endif -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif + #ifdef __BIG_ENDIAN__ + #ifndef BYTE_ORDER + #define BYTE_ORDER 4321 + #endif + #else + #ifndef BYTE_ORDER + #define BYTE_ORDER 1234 + #endif + #endif + #ifndef BIG_ENDIAN + #define BIG_ENDIAN 4321 + #endif #endif @@ -72,32 +72,32 @@ defined(__arch64__) || \ defined(__powerpc64__) || \ defined (__s390x__) -// defines for 64 bit + // defines for 64 bit -typedef unsigned long long judyvalue; -typedef unsigned long long JudySlot; -#define JUDY_key_mask (0x07) -#define JUDY_key_size 8 -#define JUDY_slot_size 8 -#define JUDY_span_bytes (3 * JUDY_key_size) -#define JUDY_span_equiv JUDY_2 -#define JUDY_radix_equiv JUDY_8 + typedef unsigned long long judyvalue; + typedef unsigned long long JudySlot; + #define JUDY_key_mask (0x07) + #define JUDY_key_size 8 + #define JUDY_slot_size 8 + #define JUDY_span_bytes (3 * JUDY_key_size) + #define JUDY_span_equiv JUDY_2 + #define JUDY_radix_equiv JUDY_8 -#define PRIjudyvalue "llu" + #define PRIjudyvalue "llu" #else -// defines for 32 bit + // defines for 32 bit -typedef unsigned int judyvalue; -typedef unsigned int JudySlot; -#define JUDY_key_mask (0x03) -#define JUDY_key_size 4 -#define JUDY_slot_size 4 -#define JUDY_span_bytes (7 * JUDY_key_size) -#define JUDY_span_equiv JUDY_4 -#define JUDY_radix_equiv JUDY_8 + typedef unsigned int judyvalue; + typedef unsigned int JudySlot; + #define JUDY_key_mask (0x03) + #define JUDY_key_size 4 + #define JUDY_slot_size 4 + #define JUDY_span_bytes (7 * JUDY_key_size) + #define JUDY_span_equiv JUDY_4 + #define JUDY_radix_equiv JUDY_8 -#define PRIjudyvalue "u" + #define PRIjudyvalue "u" #endif @@ -115,7 +115,7 @@ typedef unsigned int JudySlot; unsigned int MaxMem = 0; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort(char *msg) +void judy_abort (char *msg) { fprintf(stderr, "%s\n", msg); exit(1); @@ -155,9 +155,9 @@ int JudySize[] = { }; judyvalue JudyMask[9] = { - 0, 0xff, 0xffff, 0xffffff, 0xffffffff, +0, 0xff, 0xffff, 0xffffff, 0xffffffff, #if JUDY_key_size > 4 - 0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL +0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL #endif }; @@ -200,20 +200,20 @@ int Found = 0; // call with max key size // and Integer tree depth. -void *judy_open(unsigned int max, unsigned int depth) +void *judy_open (unsigned int max, unsigned int depth) { - JudySeg *seg; - Judy *judy; - unsigned int amt; +JudySeg *seg; +Judy *judy; +unsigned int amt; max++; // allow for zero terminator on keys - if((seg = malloc(JUDY_seg))) { + if( (seg = malloc(JUDY_seg)) ) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("No virtual memory"); + judy_abort ("No virtual memory"); #else return NULL; #endif @@ -221,9 +221,8 @@ void *judy_open(unsigned int max, unsigned int depth) amt = sizeof(Judy) + max * sizeof(JudyStack); - if(amt & (JUDY_cache_line - 1)) { + if( amt & (JUDY_cache_line - 1) ) amt |= JUDY_cache_line - 1, amt++; - } #if defined(STANDALONE) || defined(ASKITIS) MaxMem += JUDY_seg; @@ -235,79 +234,75 @@ void *judy_open(unsigned int max, unsigned int depth) judy = (Judy *)((unsigned char *)seg + seg->next); memset(judy, 0, amt); judy->depth = depth; - judy->seg = seg; + judy->seg = seg; judy->max = max; return judy; } -void judy_close(Judy *judy) +void judy_close (Judy *judy) { - JudySeg *seg, *nxt = judy->seg; +JudySeg *seg, *nxt = judy->seg; - while((seg = nxt)) { - nxt = seg->seg, free(seg); - } + while( (seg = nxt) ) + nxt = seg->seg, free (seg); } // allocate judy node -void *judy_alloc(Judy *judy, unsigned int type) +void *judy_alloc (Judy *judy, unsigned int type) { - unsigned int amt, idx, min; - JudySeg *seg; - void **block; - void **rtn; +unsigned int amt, idx, min; +JudySeg *seg; +void **block; +void **rtn; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if(type == JUDY_radix) { + if( type == JUDY_radix ) type = JUDY_radix_equiv; - } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) type = JUDY_span_equiv; - } #endif amt = JudySize[type]; - if(amt & 0x07) { + if( amt & 0x07 ) amt |= 0x07, amt += 1; - } // see if free block is already available - if((block = judy->reuse[type])) { + if( (block = judy->reuse[type]) ) { judy->reuse[type] = *block; - memset(block, 0, amt); + memset (block, 0, amt); return (void *)block; } // break down available larger block // for reuse into smaller blocks - if(type >= JUDY_1) - for(idx = type; idx++ < JUDY_max;) - if(block = judy->reuse[idx]) { - judy->reuse[idx] = *block; - while(idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; - } - memset(block, 0, amt); - return (void *)block; - } + if( type >= JUDY_1 ) + for( idx = type; idx++ < JUDY_max; ) + if( block = judy->reuse[idx] ) { + judy->reuse[idx] = *block; + while( idx-- > type) { + judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); + block[JudySize[idx] / sizeof(void *)] = 0; + } + memset (block, 0, amt); + return (void *)block; + } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if(judy->seg->next < min + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < min + sizeof(*seg) ) { + if( (seg = malloc (JUDY_seg)) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -330,36 +325,35 @@ void *judy_alloc(Judy *judy, unsigned int type) rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); - for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { + for( idx = type; amt & (JUDY_cache_line - 1); amt <<= 1 ) { block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset(rtn, 0, JudySize[type]); + memset (rtn, 0, JudySize[type]); return (void *)rtn; } -void *judy_data(Judy *judy, unsigned int amt) +void *judy_data (Judy *judy, unsigned int amt) { - JudySeg *seg; - void *block; +JudySeg *seg; +void *block; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort("illegal allocation from judy clone"); #else - return NULL; + return NULL; #endif - if(amt & (JUDY_cache_line - 1)) { + if( amt & (JUDY_cache_line - 1)) amt |= (JUDY_cache_line - 1), amt += 1; - } - if(judy->seg->next < amt + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < amt + sizeof(*seg) ) { + if( (seg = malloc (JUDY_seg)) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; @@ -380,32 +374,30 @@ void *judy_data(Judy *judy, unsigned int amt) judy->seg->next -= amt; block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset(block, 0, amt); + memset (block, 0, amt); return block; } -void *judy_clone(Judy *judy) +void *judy_clone (Judy *judy) { - Judy *clone; - unsigned int amt; +Judy *clone; +unsigned int amt; amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data(judy, amt); - memcpy(clone, judy, amt); + clone = judy_data (judy, amt); + memcpy (clone, judy, amt); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free(Judy *judy, void *block, int type) +void judy_free (Judy *judy, void *block, int type) { - if(type == JUDY_radix) { + if( type == JUDY_radix ) type = JUDY_radix_equiv; - } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) type = JUDY_span_equiv; - } #endif *((void **)(block)) = judy->reuse[type]; @@ -415,104 +407,95 @@ void judy_free(Judy *judy, void *block, int type) // assemble key from current path -unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) +unsigned int judy_key (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *dest = (judyvalue *)buff; - unsigned int len = 0, idx = 0, depth; - int slot, off, type; - judyvalue value; - unsigned char *base; - int keysize; - - if(judy->depth) { +judyvalue *dest = (judyvalue *)buff; +unsigned int len = 0, idx = 0, depth; +int slot, off, type; +judyvalue value; +unsigned char *base; +int keysize; + + if( judy->depth ) max = judy->depth * JUDY_key_size; - } else { - max--; // leave room for zero terminator - } + else + max--; // leave room for zero terminator - while(len < max && ++idx <= judy->level) { + while( len < max && ++idx <= judy->level ) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if(judy->depth) - if(!(len & JUDY_key_mask)) { - dest[depth] = 0; - } - - switch(type) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + if( judy->depth ) + if( !(len & JUDY_key_mask) ) + dest[depth] = 0; + + switch( type ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - if(judy->depth) { - value = *(judyvalue *)(base + slot * keysize); - value &= JudyMask[keysize]; - dest[depth++] |= value; - len += keysize; + if( judy->depth ) { + value = *(judyvalue *)(base + slot * keysize); + value &= JudyMask[keysize]; + dest[depth++] |= value; + len += keysize; - if(depth < judy->depth) { - continue; - } + if( depth < judy->depth ) + continue; - return len; - } + return len; + } #if BYTE_ORDER != BIG_ENDIAN - off = keysize; - - while(off-- && len < max) - if(buff[len] = base[slot * keysize + off]) { - len++; - } else { - break; - } + off = keysize; + + while( off-- && len < max ) + if( buff[len] = base[slot * keysize + off] ) + len++; + else + break; #else - for(off = 0; off < keysize && len < max; off++) - if(buff[len] = base[slot * keysize + off]) { - len++; - } else { - break; - } + for( off = 0; off < keysize && len < max; off++ ) + if( buff[len] = base[slot * keysize + off] ) + len++; + else + break; #endif - continue; + continue; - case JUDY_radix: - if(judy->depth) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if(!(len & JUDY_key_mask)) { - depth++; - } - if(depth < judy->depth) { - continue; - } - - return len; - } + case JUDY_radix: + if( judy->depth ) { + dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; + if( !(len & JUDY_key_mask) ) + depth++; + if( depth < judy->depth ) + continue; - if(!slot) { - break; - } - buff[len++] = (unsigned char)slot; - continue; + return len; + } + + if( !slot ) + break; + buff[len++] = (unsigned char)slot; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + case JUDY_span: + base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) - if(len < max) { - buff[len++] = base[slot]; - } - continue; + for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) + if( len < max ) + buff[len++] = base[slot]; + continue; #endif } } @@ -522,149 +505,139 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) // find slot & setup cursor -JudySlot *judy_slot(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_slot (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *src = (judyvalue *)buff; - int slot, size, keysize, tst, cnt; - JudySlot next = *judy->root; - judyvalue value, test = 0; - JudySlot *table; - JudySlot *node; - unsigned int depth = 0; - unsigned int off = 0; - unsigned char *base; +judyvalue *src = (judyvalue *)buff; +int slot, size, keysize, tst, cnt; +JudySlot next = *judy->root; +judyvalue value, test = 0; +JudySlot *table; +JudySlot *node; +unsigned int depth = 0; +unsigned int off = 0; +unsigned char *base; #ifndef ASKITIS judy->level = 0; #endif - while(next) { + while( next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; #endif size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: -#endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - slot = cnt; - value = 0; - - if(judy->depth) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if(off < max) { - value |= buff[off]; - } - } while(++off & JUDY_key_mask); - - // find slot > key - - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + case JUDY_64: +#endif + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + slot = cnt; + value = 0; + + if( judy->depth ) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if( off < max ) + value |= buff[off]; + } while( ++off & JUDY_key_mask ); + + // find slot > key + + while( slot-- ) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if(test <= value) { - break; - } - } + if( test <= value ) + break; + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if(test == value) { + if( test == value ) { - // is this a leaf? + // is this a leaf? - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) + return &node[-slot-1]; - next = node[-slot - 1]; - continue; - } + next = node[-slot-1]; + continue; + } - return NULL; + return NULL; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); // outer radix - if(judy->depth) { - slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { - slot = buff[off++]; - } else { - slot = 0; - } + if( judy->depth ) + slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; + else if( off < max ) + slot = buff[off++]; + else + slot = 0; #ifndef ASKITIS - // put radix slot on judy stack + // put radix slot on judy stack - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if((next = table[slot >> 4])) { - table = (JudySlot *)(next & JUDY_mask); // inner radix - } else { - return NULL; - } + if( (next = table[slot >> 4]) ) + table = (JudySlot *)(next & JUDY_mask); // inner radix + else + return NULL; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) // leaf? - if(table[slot & 0x0F]) { // occupied? - return &table[slot & 0x0F]; - } else { - return NULL; - } + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) // leaf? + if( table[slot & 0x0F] ) // occupied? + return &table[slot & 0x0F]; + else + return NULL; - next = table[slot & 0x0F]; - continue; + next = table[slot & 0x0F]; + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { - tst = max - off; - } - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if(!value && tst < cnt && !base[tst]) { // leaf? - return &node[-1]; - } + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = tst = JUDY_span_bytes; + if( tst > (int)(max - off) ) + tst = max - off; + value = strncmp((const char *)base, (const char *)(buff + off), tst); + if( !value && tst < cnt && !base[tst] ) // leaf? + return &node[-1]; - if(!value && tst == cnt) { - next = node[-1]; - off += cnt; - continue; - } - return NULL; + if( !value && tst == cnt ) { + next = node[-1]; + off += cnt; + continue; + } + return NULL; #endif } } @@ -674,26 +647,26 @@ JudySlot *judy_slot(Judy *judy, unsigned char *buff, unsigned int max) // promote full nodes to next larger size -JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) +JudySlot *judy_promote (Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) { - unsigned char *base = (unsigned char *)(*next & JUDY_mask); - int oldcnt, newcnt, slot; +unsigned char *base = (unsigned char *)(*next & JUDY_mask); +int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif - JudySlot *newnode, *node; - JudySlot *result; - unsigned char *newbase; - unsigned int type; +JudySlot *newnode, *node; +JudySlot *result; +unsigned char *newbase; +unsigned int type; type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); - oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[type-1]); + oldcnt = JudySize[type-1] / (sizeof(JudySlot) + keysize); newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); // promote node to next larger size - newbase = judy_alloc(judy, type); + newbase = judy_alloc (judy, type); newnode = (JudySlot *)(newbase + JudySize[type]); *next = (JudySlot)newbase | type; @@ -701,9 +674,8 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys - for(slot = 0; slot < idx; slot++) { + for( slot = 0; slot < idx; slot++ ) newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr - } // fill in new node @@ -712,9 +684,8 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int #else i = keysize; - while(i--) { - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; - } + while( i-- ) + newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; #endif result = &newnode[-(idx + newcnt - oldcnt)]; @@ -722,15 +693,14 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys - for(; slot < oldcnt; slot++) { + for( ; slot < oldcnt; slot++ ) newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr - } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free(judy, (void **)base, type - 1); + judy_free (judy, (void **)base, type - 1); return result; } @@ -738,18 +708,18 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int // make node with slot - start entries // moving key over one offset -void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) +void judy_radix (Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) { - int size, idx, cnt = slot - start, newcnt; - JudySlot *node, *oldnode; - unsigned int type = JUDY_1 - 1; - JudySlot *table; - unsigned char *base; +int size, idx, cnt = slot - start, newcnt; +JudySlot *node, *oldnode; +unsigned int type = JUDY_1 - 1; +JudySlot *table; +unsigned char *base; // if necessary, setup inner radix node - if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { - table = judy_alloc(judy, JUDY_radix); + if( !(table = (JudySlot *)(radix[key >> 4] & JUDY_mask)) ) { + table = judy_alloc (judy, JUDY_radix); radix[key >> 4] = (JudySlot)table | JUDY_radix; } @@ -757,8 +727,8 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int // is this slot a leaf? - if(!judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { - table[key & 0x0F] = oldnode[-start - 1]; + if( !judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { + table[key & 0x0F] = oldnode[-start-1]; return; } @@ -768,22 +738,22 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int type++; size = JudySize[type]; newcnt = size / (sizeof(JudySlot) + keysize); - } while(cnt > newcnt && type < JUDY_max); + } while( cnt > newcnt && type < JUDY_max ); // store new node pointer in inner table - base = judy_alloc(judy, type); + base = judy_alloc (judy, type); node = (JudySlot *)(base + size); table[key & 0x0F] = (JudySlot)base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for(idx = 0; idx < cnt; idx++) { + for( idx = 0; idx < cnt; idx++ ) { #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); + memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); #else - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); + memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); #endif node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; } @@ -791,132 +761,122 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int // decompose full node to radix nodes -void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) +void judy_splitnode (Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) { - int cnt, slot, start = 0; - unsigned int key = 0x0100, nxt; - JudySlot *newradix; - unsigned char *base; +int cnt, slot, start = 0; +unsigned int key = 0x0100, nxt; +JudySlot *newradix; +unsigned char *base; - base = (unsigned char *)(*next & JUDY_mask); + base = (unsigned char *)(*next & JUDY_mask); cnt = size / (sizeof(JudySlot) + keysize); // allocate outer judy_radix node - newradix = judy_alloc(judy, JUDY_radix); + newradix = judy_alloc (judy, JUDY_radix); *next = (JudySlot)newradix | JUDY_radix; - for(slot = 0; slot < cnt; slot++) { + for( slot = 0; slot < cnt; slot++ ) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if(key > 0xFF) { + if( key > 0xFF ) key = nxt; - } - if(nxt == key) { + if( nxt == key ) continue; - } // decompose portion of old node into radix nodes - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); start = slot; key = nxt; } - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free(judy, (void **)base, JUDY_max); + judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_free (judy, (void **)base, JUDY_max); } // return first leaf -JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_first (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { - JudySlot *table, *inner; - unsigned int keysize, size; - JudySlot *node; - int slot, cnt; - unsigned char *base; - - while(next) { - if(judy->level < judy->max) { +JudySlot *table, *inner; +unsigned int keysize, size; +JudySlot *node; +int slot, cnt; +unsigned char *base; + + while( next ) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].off = off; judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + cnt = size / (sizeof(JudySlot) + keysize); - for(slot = 0; slot < cnt; slot++) - if(node[-slot - 1]) { - break; - } + for( slot = 0; slot < cnt; slot++ ) + if( node[-slot-1] ) + break; - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) + return &node[-slot-1]; #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { - return &node[-slot - 1]; - } + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) + return &node[-slot-1]; #endif - next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; - continue; - case JUDY_radix: - off++; + next = node[-slot - 1]; + off = (off | JUDY_key_mask) + 1; + continue; + case JUDY_radix: + off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } - - table = (JudySlot *)(next & JUDY_mask); - for(slot = 0; slot < 256; slot++) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { - judy->stack[judy->level].slot = slot; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[slot & 0x0F]; - } else { - break; - } - } - } else { - slot |= 0x0F; - } - continue; -#ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? - return &node[-1]; + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; + + table = (JudySlot *)(next & JUDY_mask); + for( slot = 0; slot < 256; slot++ ) + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( (next = inner[slot & 0x0F]) ) { + judy->stack[judy->level].slot = slot; + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[slot & 0x0F]; + else + break; } - next = node[-1]; - off += cnt; - continue; + } else + slot |= 0x0F; + continue; +#ifndef ASKITIS + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if( !base[cnt - 1] ) // leaf node? + return &node[-1]; + next = node[-1]; + off += cnt; + continue; #endif } } @@ -925,84 +885,79 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d // return last leaf cell pointer -JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) +JudySlot *judy_last (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) { - JudySlot *table, *inner; - unsigned int keysize, size; - JudySlot *node; - int slot, cnt; - unsigned char *base; - - while(next) { - if(judy->level < judy->max) { +JudySlot *table, *inner; +unsigned int keysize, size; +JudySlot *node; +int slot, cnt; +unsigned char *base; + + while( next ) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - judy->stack[judy->level].slot = --slot; + keysize = JUDY_key_size - (off & JUDY_key_mask); + slot = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(next & JUDY_mask); + node = (JudySlot *)((next & JUDY_mask) + size); + judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) #endif - return &node[-slot - 1]; + return &node[-slot-1]; - next = node[-slot - 1]; - off += keysize; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - off++; + next = node[-slot-1]; + off += keysize; + continue; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + off++; - for(slot = 256; slot--;) { - judy->stack[judy->level].slot = slot; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[0]; - } else { - break; - } - } else { - slot &= 0xF0; - } - } - continue; + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; + + for( slot = 256; slot--; ) { + judy->stack[judy->level].slot = slot; + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( (next = inner[slot & 0x0F]) ) + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[0]; + else + break; + } else + slot &= 0xF0; + } + continue; #ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? - return &node[-1]; - } - next = node[-1]; - off += cnt; - continue; + case JUDY_span: + node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); + base = (unsigned char *)(next & JUDY_mask); + cnt = JUDY_span_bytes; + if( !base[cnt - 1] ) // leaf node? + return &node[-1]; + next = node[-1]; + off += cnt; + continue; #endif } } @@ -1011,28 +966,27 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de // judy_end: return last entry -JudySlot *judy_end(Judy *judy) +JudySlot *judy_end (Judy *judy) { judy->level = 0; - return judy_last(judy, *judy->root, 0, 0); + return judy_last (judy, *judy->root, 0, 0); } // judy_nxt: return next entry -JudySlot *judy_nxt(Judy *judy) +JudySlot *judy_nxt (Judy *judy) { - JudySlot *table, *inner; - int slot, size, cnt; - JudySlot *node; - JudySlot next; - unsigned int keysize; - unsigned char *base; - unsigned int depth; - unsigned int off; - - if(!judy->level) { - return judy_first(judy, *judy->root, 0, 0); - } - - while(judy->level) { +JudySlot *table, *inner; +int slot, size, cnt; +JudySlot *node; +JudySlot next; +unsigned int keysize; +unsigned char *base; +unsigned int depth; +unsigned int off; + + if( !judy->level ) + return judy_first (judy, *judy->root, 0, 0); + + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; @@ -1040,62 +994,59 @@ JudySlot *judy_nxt(Judy *judy) size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if(++slot < cnt) + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); + if( ++slot < cnt ) #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) -#endif - { - judy->stack[judy->level].slot = slot; - return &node[-slot - 1]; - } else { - judy->stack[judy->level].slot = slot; - return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); - } - judy->level--; - continue; + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) +#endif + { + judy->stack[judy->level].slot = slot; + return &node[-slot - 1]; + } else { + judy->stack[judy->level].slot = slot; + return judy_first (judy, node[-slot-1], (off | JUDY_key_mask) + 1, depth); + } + judy->level--; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { - depth++; - } - - while(++slot < 256) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if(inner[slot & 0x0F]) { - judy->stack[judy->level].slot = slot; - if(!judy->depth || depth < judy->depth) { - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); - } - return &inner[slot & 0x0F]; - } - } else { - slot |= 0x0F; - } + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); - judy->level--; - continue; + if( judy->depth ) + if( !((off+1) & JUDY_key_mask) ) + depth++; + + while( ++slot < 256 ) + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { + if( inner[slot & 0x0F] ) { + judy->stack[judy->level].slot = slot; + if( !judy->depth || depth < judy->depth ) + return judy_first(judy, inner[slot & 0x0F], off + 1, depth); + return &inner[slot & 0x0F]; + } + } else + slot |= 0x0F; + + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1104,80 +1055,77 @@ JudySlot *judy_nxt(Judy *judy) // judy_prv: return ptr to previous entry -JudySlot *judy_prv(Judy *judy) +JudySlot *judy_prv (Judy *judy) { - int slot, size, keysize; - JudySlot *table, *inner; - JudySlot *node, next; - unsigned char *base; - unsigned int depth; - unsigned int off; - - if(!judy->level) { - return judy_last(judy, *judy->root, 0, 0); - } +int slot, size, keysize; +JudySlot *table, *inner; +JudySlot *node, next; +unsigned char *base; +unsigned int depth; +unsigned int off; + + if( !judy->level ) + return judy_last (judy, *judy->root, 0, 0); - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - node = (JudySlot *)((next & JUDY_mask) + size); - if(!slot || !node[-slot]) { - judy->level--; - continue; - } + node = (JudySlot *)((next & JUDY_mask) + size); + if( !slot || !node[-slot] ) { + judy->level--; + continue; + } - base = (unsigned char *)(next & JUDY_mask); - judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); + base = (unsigned char *)(next & JUDY_mask); + judy->stack[judy->level].slot--; + keysize = JUDY_key_size - (off & JUDY_key_mask); #if BYTE_ORDER != BIG_ENDIAN - if(!judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth) + if( !judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth ) #else - if(!judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) -#endif - return &node[-slot]; - return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { - depth++; - } - - while(slot--) { - judy->stack[judy->level].slot--; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) - if(inner[slot & 0x0F]) - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { - return &inner[0]; - } else { - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); - } - } + if( !judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) +#endif + return &node[-slot]; + return judy_last (judy, node[-slot], (off | JUDY_key_mask) + 1, depth); + + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + + if( judy->depth ) + if( !((off + 1) & JUDY_key_mask) ) + depth++; + + while( slot-- ) { + judy->stack[judy->level].slot--; + if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) + if( inner[slot & 0x0F] ) + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) + return &inner[0]; + else + return judy_last(judy, inner[slot & 0x0F], off + 1, depth); + } - judy->level--; - continue; + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; + case JUDY_span: + judy->level--; + continue; #endif } } @@ -1187,86 +1135,84 @@ JudySlot *judy_prv(Judy *judy) // judy_del: delete string from judy array // returning previous entry. -JudySlot *judy_del(Judy *judy) +JudySlot *judy_del (Judy *judy) { - int slot, off, size, type, high; - JudySlot *table, *inner; - JudySlot next, *node; - int keysize, cnt; - unsigned char *base; +int slot, off, size, type, high; +JudySlot *table, *inner; +JudySlot next, *node; +int keysize, cnt; +unsigned char *base; - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch(type = next & 0x07) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: + switch( type = next & 0x07 ) { + case JUDY_1: + case JUDY_2: + case JUDY_4: + case JUDY_8: + case JUDY_16: + case JUDY_32: #ifdef ASKITIS - case JUDY_64: + case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + node = (JudySlot *)((next & JUDY_mask) + size); + base = (unsigned char *)(next & JUDY_mask); - // move deleted slot to first slot + // move deleted slot to first slot - while(slot) { - node[-slot - 1] = node[-slot]; - memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); - slot--; - } + while( slot ) { + node[-slot-1] = node[-slot]; + memcpy (base + slot * keysize, base + (slot - 1) * keysize, keysize); + slot--; + } - // zero out first slot + // zero out first slot - node[-1] = 0; - memset(base, 0, keysize); + node[-1] = 0; + memset (base, 0, keysize); - if(node[-cnt]) { // does node have any slots left? - judy->stack[judy->level].slot++; - return judy_prv(judy); - } + if( node[-cnt] ) { // does node have any slots left? + judy->stack[judy->level].slot++; + return judy_prv (judy); + } - judy_free(judy, base, type); - judy->level--; - continue; + judy_free (judy, base, type); + judy->level--; + continue; - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); - inner[slot & 0x0F] = 0; - high = slot & 0xF0; + case JUDY_radix: + table = (JudySlot *)(next & JUDY_mask); + inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); + inner[slot & 0x0F] = 0; + high = slot & 0xF0; - for(cnt = 16; cnt--;) - if(inner[cnt]) { - return judy_prv(judy); - } + for( cnt = 16; cnt--; ) + if( inner[cnt] ) + return judy_prv (judy); - judy_free(judy, inner, JUDY_radix); - table[slot >> 4] = 0; + judy_free (judy, inner, JUDY_radix); + table[slot >> 4] = 0; - for(cnt = 16; cnt--;) - if(table[cnt]) { - return judy_prv(judy); - } + for( cnt = 16; cnt--; ) + if( table[cnt] ) + return judy_prv (judy); - judy_free(judy, table, JUDY_radix); - judy->level--; - continue; + judy_free (judy, table, JUDY_radix); + judy->level--; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free(judy, base, type); - judy->level--; - continue; + case JUDY_span: + base = (unsigned char *)(next & JUDY_mask); + judy_free (judy, base, type); + judy->level--; + continue; #endif } } @@ -1279,284 +1225,266 @@ JudySlot *judy_del(Judy *judy) // return cell for first key greater than or equal to given key -JudySlot *judy_strt(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_strt (Judy *judy, unsigned char *buff, unsigned int max) { - JudySlot *cell; +JudySlot *cell; judy->level = 0; - if(!max) { - return judy_first(judy, *judy->root, 0, 0); - } + if( !max ) + return judy_first (judy, *judy->root, 0, 0); - if((cell = judy_slot(judy, buff, max))) { + if( (cell = judy_slot (judy, buff, max)) ) return cell; - } - return judy_nxt(judy); + return judy_nxt (judy); } // split open span node #ifndef ASKITIS -void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) +void judy_splitspan (Judy *judy, JudySlot *next, unsigned char *base) { - JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); - unsigned int cnt = JUDY_span_bytes; - unsigned char *newbase; - unsigned int off = 0; +JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); +unsigned int cnt = JUDY_span_bytes; +unsigned char *newbase; +unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN - int i; +int i; #endif do { - newbase = judy_alloc(judy, JUDY_1); + newbase = judy_alloc (judy, JUDY_1); *next = (JudySlot)newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while(i--) { + while( i-- ) *newbase++ = base[off + i]; - } #else - memcpy(newbase, base + off, JUDY_key_size); + memcpy (newbase, base + off, JUDY_key_size); newbase += JUDY_key_size; #endif next = (JudySlot *)newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while(cnt && base[off - 1]); + } while( cnt && base[off - 1] ); *next = node[-1]; - judy_free(judy, base, JUDY_span); + judy_free (judy, base, JUDY_span); } #endif // judy_cell: add string to judy array -JudySlot *judy_cell(Judy *judy, unsigned char *buff, unsigned int max) +JudySlot *judy_cell (Judy *judy, unsigned char *buff, unsigned int max) { - judyvalue *src = (judyvalue *)buff; - int size, idx, slot, cnt, tst; - JudySlot *next = judy->root; - judyvalue test, value; - unsigned int off = 0, start; - JudySlot *table; - JudySlot *node; - unsigned int depth = 0; - unsigned int keysize; - unsigned char *base; +judyvalue *src = (judyvalue *)buff; +int size, idx, slot, cnt, tst; +JudySlot *next = judy->root; +judyvalue test, value; +unsigned int off = 0, start; +JudySlot *table; +JudySlot *node; +unsigned int depth = 0; +unsigned int keysize; +unsigned char *base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while(*next) { + while( *next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) judy->level++; - } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch(*next & 0x07) { - default: - size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); - start = off; - slot = cnt; - value = 0; - - if(judy->depth) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if(off < max) { - value |= buff[off]; - } - } while(++off & JUDY_key_mask); - - // find slot > key - - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + switch( *next & 0x07 ) { + default: + size = JudySize[*next & 0x07]; + keysize = JUDY_key_size - (off & JUDY_key_mask); + cnt = size / (sizeof(JudySlot) + keysize); + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + size); + start = off; + slot = cnt; + value = 0; + + if( judy->depth ) { + value = src[depth++]; + off |= JUDY_key_mask; + off++; + value &= JudyMask[keysize]; + } else + do { + value <<= 8; + if( off < max ) + value |= buff[off]; + } while( ++off & JUDY_key_mask ); + + // find slot > key + + while( slot-- ) { + test = *(judyvalue *)(base + slot * keysize); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * (JUDY_key_size - keysize); #else - test &= JudyMask[keysize]; + test &= JudyMask[keysize]; #endif - if(test <= value) { - break; - } - } + if( test <= value ) + break; + } #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - if(test == value) { // new key is equal to slot key - next = &node[-slot - 1]; + if( test == value ) { // new key is equal to slot key + next = &node[-slot-1]; - // is this a leaf? + // is this a leaf? - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } - - continue; + return next; } - // if this node is not full - // open up cell after slot + continue; + } + + // if this node is not full + // open up cell after slot - if(!node[-1]) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot + if( !node[-1] ) { + memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot + memcpy(base + slot * keysize, &value, keysize); // copy new key into slot #else - test = value; - idx = keysize; + test = value; + idx = keysize; - while(idx--) { - base[slot * keysize + idx] = test, test >>= 8; - } + while( idx-- ) + base[slot * keysize + idx] = test, test >>= 8; #endif - for(idx = 0; idx < slot; idx++) { - node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot - } + for( idx = 0; idx < slot; idx++ ) + node[-idx-1] = node[-idx-2];// copy tree ptrs/cells down one slot - node[-slot - 1] = 0; // set new tree ptr/cell - next = &node[-slot - 1]; + node[-slot-1] = 0; // set new tree ptr/cell + next = &node[-slot-1]; - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; - } + continue; + } - if(size < JudySize[JUDY_max]) { - next = judy_promote(judy, next, slot + 1, value, keysize); + if( size < JudySize[JUDY_max] ) { + next = judy_promote (judy, next, slot+1, value, keysize); - if(!judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth) { + if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; - } + continue; + } - // split full maximal node into JUDY_radix nodes - // loop to reprocess new insert + // split full maximal node into JUDY_radix nodes + // loop to reprocess new insert - judy_splitnode(judy, next, size, keysize, depth); + judy_splitnode (judy, next, size, keysize, depth); #ifndef ASKITIS - judy->level--; + judy->level--; #endif - off = start; - if(judy->depth) { - depth--; - } - continue; + off = start; + if( judy->depth ) + depth--; + continue; - case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix + case JUDY_radix: + table = (JudySlot *)(*next & JUDY_mask); // outer radix - if(judy->depth) { - slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { - slot = buff[off++]; - } else { - slot = 0, off++; - } + if( judy->depth ) + slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; + else if( off < max ) + slot = buff[off++]; + else + slot = 0, off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { - depth++; - } + if( judy->depth ) + if( !(off & JUDY_key_mask) ) + depth++; - // allocate inner radix if empty + // allocate inner radix if empty - if(!table[slot >> 4]) { - table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; - } + if( !table[slot >> 4] ) + table[slot >> 4] = (JudySlot)judy_alloc (judy, JUDY_radix) | JUDY_radix; - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = (JudySlot *)(table[slot >> 4] & JUDY_mask); #ifndef ASKITIS - judy->stack[judy->level].slot = slot; + judy->stack[judy->level].slot = slot; #endif - next = &table[slot & 0x0F]; + next = &table[slot & 0x0F]; - if(!judy->depth && !slot || judy->depth && depth == judy->depth) { // leaf? + if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { // leaf? #ifdef ASKITIS - if(*next) { - Found++; - } else { - Inserts++; - } + if( *next ) + Found++; + else + Inserts++; #endif - return next; - } + return next; + } - continue; + continue; #ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); - cnt = JUDY_span_bytes; - tst = cnt; - - if(tst > (int)(max - off)) { - tst = max - off; - } + case JUDY_span: + base = (unsigned char *)(*next & JUDY_mask); + node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); + cnt = JUDY_span_bytes; + tst = cnt; - value = strncmp((const char *)base, (const char *)(buff + off), tst); - - if(!value && tst < cnt && !base[tst]) { // leaf? - return &node[-1]; - } + if( tst > (int)(max - off) ) + tst = max - off; - if(!value && tst == cnt) { - next = &node[-1]; - off += cnt; - continue; - } + value = strncmp((const char *)base, (const char *)(buff + off), tst); - // bust up JUDY_span node and produce JUDY_1 nodes - // then loop to reprocess insert + if( !value && tst < cnt && !base[tst] ) // leaf? + return &node[-1]; - judy_splitspan(judy, next, base); - judy->level--; + if( !value && tst == cnt ) { + next = &node[-1]; + off += cnt; continue; + } + + // bust up JUDY_span node and produce JUDY_1 nodes + // then loop to reprocess insert + + judy_splitspan (judy, next, base); + judy->level--; + continue; #endif } } @@ -1564,109 +1492,102 @@ JudySlot *judy_cell(Judy *judy, unsigned char *buff, unsigned int max) // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if(off & JUDY_key_mask) - if(judy->depth || off <= max) { + if( off & JUDY_key_mask ) + if( judy->depth || off <= max ) { #else - while(off <= max) { + while( off <= max ) { #endif - base = judy_alloc(judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + base = judy_alloc (judy, JUDY_1); + keysize = JUDY_key_size - (off & JUDY_key_mask); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - if(judy->depth) { - value = src[depth]; + if( judy->depth ) { + value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot + memcpy(base, &value, keysize); // copy new key into slot #else - while(keysize--) { - base[keysize] = value, value >>= 8; - } + while( keysize-- ) + base[keysize] = value, value >>= 8; #endif - } else { + } else { #if BYTE_ORDER != BIG_ENDIAN - while(keysize) - if(off + keysize <= max) { - *base++ = buff[off + --keysize]; - } else { - base++, --keysize; - } + while( keysize ) + if( off + keysize <= max ) + *base++ = buff[off + --keysize]; + else + base++, --keysize; #else - tst = keysize; + tst = keysize; - if(tst > (int)(max - off)) { - tst = max - off; - } + if( tst > (int)(max - off) ) + tst = max - off; - memcpy(base, buff + off, tst); + memcpy (base, buff + off, tst); #endif - } + } #ifndef ASKITIS - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; #endif - next = &node[-1]; + next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + off |= JUDY_key_mask; + depth++; + off++; + } // produce span nodes to consume rest of key // or judy_1 nodes if not string tree #ifndef ASKITIS - if(!judy->depth) - while(off <= max) { - base = judy_alloc(judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); - cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { - tst = max - off; - } - memcpy(base, buff + off, tst); + if( !judy->depth ) + while( off <= max ) { + base = judy_alloc (judy, JUDY_span); + *next = (JudySlot)base | JUDY_span; + node = (JudySlot *)(base + JudySize[JUDY_span]); + cnt = tst = JUDY_span_bytes; + if( tst > (int)(max - off) ) + tst = max - off; + memcpy (base, buff + off, tst); + + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off += tst; + depth++; - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off += tst; - depth++; - - if(!base[cnt - 1]) { // done on leaf - break; - } - } else - while(depth < judy->depth) { - base = judy_alloc(judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + if( !base[cnt-1] ) // done on leaf + break; + } + else + while( depth < judy->depth ) { + base = judy_alloc (judy, JUDY_1); + node = (JudySlot *)(base + JudySize[JUDY_1]); + *next = (JudySlot)base | JUDY_1; - // fill in slot 0 with bytes of key + // fill in slot 0 with bytes of key - *(judyvalue *)base = src[depth]; + *(judyvalue *)base = src[depth]; - if(judy->level < judy->max) { - judy->level++; - } - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } + if( judy->level < judy->max ) + judy->level++; + judy->stack[judy->level].next = *next; + judy->stack[judy->level].slot = 0; + judy->stack[judy->level].off = off; + next = &node[-1]; + off |= JUDY_key_mask; + depth++; + off++; + } #endif #ifdef ASKITIS @@ -1709,203 +1630,195 @@ typedef struct { void *next; // duplicate chain } PennySort; -void sort(FILE *infile, char *outname) +void sort (FILE *infile, char *outname) { - unsigned long long size, off, offset, part; - int ifd = fileno(infile); - char filename[512]; - PennySort *line; - JudySlot *cell; - unsigned char *inbuff; - void *judy; - FILE *out; +unsigned long long size, off, offset, part; +int ifd = fileno (infile); +char filename[512]; +PennySort *line; +JudySlot *cell; +unsigned char *inbuff; +void *judy; +FILE *out; #if defined(_WIN32) - HANDLE hndl, fm; - DWORD hiword; - FILETIME dummy[1]; - FILETIME user[1]; +HANDLE hndl, fm; +DWORD hiword; +FILETIME dummy[1]; +FILETIME user[1]; #else - struct tms buff[1]; +struct tms buff[1]; #endif - time_t start = time(NULL); +time_t start = time(NULL); - if(PennyOff + PennyKey > PennyLine) { - fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); - } + if( PennyOff + PennyKey > PennyLine ) + fprintf (stderr, "Key Offset + Key Length > Record Length\n"), exit(1); - offset = 0; - PennyPasses = 0; + offset = 0; + PennyPasses = 0; #if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize(hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if(!fm) { - fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); - } - size |= (unsigned long long)hiword << 32; + hndl = (HANDLE)_get_osfhandle(ifd); + size = GetFileSize (hndl, &hiword); + fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); + if( !fm ) + fprintf (stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); + size |= (unsigned long long)hiword << 32; #else - size = lseek(ifd, 0L, 2); + size = lseek (ifd, 0L, 2); #endif - while(offset < size) { + while( offset < size ) { #if defined(_WIN32) - part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); - if(!inbuff) { - fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); - } + part = offset + PennyMerge > size ? size - offset : PennyMerge; + inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part); + if( !inbuff ) + fprintf (stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); #else - inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); + inbuff = mmap (NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); - if(inbuff == MAP_FAILED) { - fprintf(stderr, "mmap error %d\n", errno), exit(1); - } + if( inbuff == MAP_FAILED ) + fprintf (stderr, "mmap error %d\n", errno), exit(1); - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { - fprintf(stderr, "madvise error %d\n", errno); - } + if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0 ) + fprintf (stderr, "madvise error %d\n", errno); #endif - judy = judy_open(PennyKey, 0); + judy = judy_open (PennyKey, 0); - off = 0; + off = 0; - // build judy array from mapped input chunk + // build judy array from mapped input chunk - while(offset + off < size && off < PennyMerge) { - line = judy_data(judy, sizeof(PennySort)); - cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; - line->buff = inbuff + off; + while( offset + off < size && off < PennyMerge ) { + line = judy_data (judy, sizeof(PennySort)); + cell = judy_cell (judy, inbuff + off + PennyOff, PennyKey); + line->next = *(void **)cell; + line->buff = inbuff + off; - *(PennySort **)cell = line; - off += PennyLine; - } + *(PennySort **)cell = line; + off += PennyLine; + } - sprintf(filename, "%s.%d", outname, PennyPasses); - out = fopen(filename, "wb"); - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + sprintf (filename, "%s.%d", outname, PennyPasses); + out = fopen (filename, "wb"); + setvbuf (out, NULL, _IOFBF, 4096 * 1024); #ifndef _WIN32 - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { - fprintf(stderr, "madvise error %d\n", errno); - } + if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0 ) + fprintf (stderr, "madvise error %d\n", errno); #endif - // write judy array in sorted order to temporary file + // write judy array in sorted order to temporary file - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - line = *(PennySort **)cell; - do { - fwrite(line->buff, PennyLine, 1, out); - } while(line = line->next); - } while(cell = judy_nxt(judy)); + if( cell ) do { + line = *(PennySort **)cell; + do fwrite (line->buff, PennyLine, 1, out); + while( line = line->next ); + } while( cell = judy_nxt (judy) ); #if defined(_WIN32) - UnmapViewOfFile(inbuff); + UnmapViewOfFile (inbuff); #else - munmap(inbuff, PennyMerge); -#endif - judy_close(judy); - offset += off; - fflush(out); - fclose(out); - PennyPasses++; - } - fprintf(stderr, "End Sort %d secs", time(NULL) - start); + munmap (inbuff, PennyMerge); +#endif + judy_close (judy); + offset += off; + fflush (out); + fclose (out); + PennyPasses++; + } + fprintf (stderr, "End Sort %d secs", time(NULL) - start); #if defined(_WIN32) - CloseHandle(fm); - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long *)user / 10000000; + CloseHandle (fm); + GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); + PennySortTime = *(unsigned long long*)user / 10000000; #else - times(buff); - PennySortTime = buff->tms_utime / 100; + times (buff); + PennySortTime = buff->tms_utime/100; #endif - fprintf(stderr, " Cpu %d\n", PennySortTime); + fprintf (stderr, " Cpu %d\n", PennySortTime); } -int merge(FILE *out, char *outname) +int merge (FILE *out, char *outname) { - time_t start = time(NULL); - char filename[512]; - JudySlot *cell; - unsigned int nxt, idx; - unsigned char **line; - unsigned int *next; - void *judy; - FILE **in; +time_t start = time(NULL); +char filename[512]; +JudySlot *cell; +unsigned int nxt, idx; +unsigned char **line; +unsigned int *next; +void *judy; +FILE **in; - next = calloc(PennyPasses + 1, sizeof(unsigned int)); - line = calloc(PennyPasses, sizeof(void *)); - in = calloc(PennyPasses, sizeof(void *)); + next = calloc (PennyPasses + 1, sizeof(unsigned int)); + line = calloc (PennyPasses, sizeof(void *)); + in = calloc (PennyPasses, sizeof(void *)); - judy = judy_open(PennyKey, 0); + judy = judy_open (PennyKey, 0); // initialize merge with one record from each temp file - for(idx = 0; idx < PennyPasses; idx++) { - sprintf(filename, "%s.%d", outname, idx); - in[idx] = fopen(filename, "rb"); - line[idx] = malloc(PennyLine); - setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); - fread(line[idx], PennyLine, 1, in[idx]); - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + for( idx = 0; idx < PennyPasses; idx++ ) { + sprintf (filename, "%s.%d", outname, idx); + in[idx] = fopen (filename, "rb"); + line[idx] = malloc (PennyLine); + setvbuf (in[idx], NULL, _IOFBF, 4096 * 1024); + fread (line[idx], PennyLine, 1, in[idx]); + cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; } // output records, replacing smallest each time - while(cell = judy_strt(judy, NULL, 0)) { + while( cell = judy_strt (judy, NULL, 0) ) { nxt = *(unsigned int *)cell; - judy_del(judy); + judy_del (judy); // process duplicates - while(idx = nxt) { + while( idx = nxt ) { nxt = next[idx--]; - fwrite(line[idx], PennyLine, 1, out); + fwrite (line[idx], PennyLine, 1, out); - if(fread(line[idx], PennyLine, 1, in[idx])) { - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); + if( fread (line[idx], PennyLine, 1, in[idx]) ) { + cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); next[idx + 1] = *(unsigned int *)cell; *cell = idx + 1; - } else { + } else next[idx + 1] = 0; - } } } - for(idx = 0; idx < PennyPasses; idx++) { - fclose(in[idx]); - free(line[idx]); + for( idx = 0; idx < PennyPasses; idx++ ) { + fclose (in[idx]); + free (line[idx]); } - free(line); - free(next); - free(in); + free (line); + free (next); + free (in); - fprintf(stderr, "End Merge %d secs", time(NULL) - start); + fprintf (stderr, "End Merge %d secs", time(NULL) - start); #ifdef _WIN32 { - FILETIME dummy[1]; - FILETIME user[1]; - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long *)user / 10000000; + FILETIME dummy[1]; + FILETIME user[1]; + GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); + PennyMergeTime = *(unsigned long long*)user / 10000000; } #else { - struct tms buff[1]; - times(buff); - PennyMergeTime = buff->tms_utime / 100; + struct tms buff[1]; + times (buff); + PennyMergeTime = buff->tms_utime/100; } #endif - fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close(judy); - fflush(out); - fclose(out); + fprintf (stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); + judy_close (judy); + fflush (out); + fclose (out); return 0; } @@ -1938,78 +1851,71 @@ typedef struct timeval timer; // Also, the file to search judy is hardcoded to skew1_1. -int main(int argc, char **argv) +int main (int argc, char **argv) { - unsigned char buff[1024]; - JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; - unsigned int len; - unsigned int idx; +unsigned char buff[1024]; +JudySlot max = 0; +JudySlot *cell; +FILE *in, *out; +void *judy; +unsigned int len; +unsigned int idx; #ifdef ASKITIS - char *askitis; - int prev, off; - float insert_real_time = 0.0; - float search_real_time = 0.0; - int size; +char *askitis; +int prev, off; +float insert_real_time=0.0; +float search_real_time=0.0; +int size; #if !defined(_WIN32) - timer start, stop; +timer start, stop; #else - time_t start[1], stop[1]; +time_t start[1], stop[1]; #endif #endif - if(argc > 1) { - in = fopen(argv[1], "rb"); - } else { + if( argc > 1 ) + in = fopen (argv[1], "rb"); + else in = stdin; - } - if(argc > 2) { - out = fopen(argv[2], "wb"); - } else { + if( argc > 2 ) + out = fopen (argv[2], "wb"); + else out = stdout; - } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf (out, NULL, _IOFBF, 4096 * 1024); - if(!in) { - fprintf(stderr, "unable to open input file\n"); - } + if( !in ) + fprintf (stderr, "unable to open input file\n"); - if(!out) { - fprintf(stderr, "unable to open output file\n"); - } + if( !out ) + fprintf (stderr, "unable to open output file\n"); - if(argc > 6) { + if( argc > 6 ) PennyRecs = atoi(argv[6]); - } - if(argc > 5) { + if( argc > 5 ) PennyOff = atoi(argv[5]); - } - if(argc > 4) { + if( argc > 4 ) PennyLine = atoi(argv[4]); - } PennyMerge = (unsigned long long)PennyLine * PennyRecs; - if(argc > 3) { + if( argc > 3 ) { PennyKey = atoi(argv[3]); - sort(in, argv[2]); - return merge(out, argv[2]); + sort (in, argv[2]); + return merge (out, argv[2]); } #ifdef ASKITIS - judy = judy_open(1024, 0); + judy = judy_open (1024, 0); // build judy array - size = lseek(fileno(in), 0L, 2); + size = lseek (fileno(in), 0L, 2); askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + lseek (fileno(in), 0L, 0); + read (fileno(in), askitis,size); prev = 0; // naskitis.com: // Start the timer. @@ -2020,29 +1926,29 @@ int main(int argc, char **argv) time(start); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string - prev = off + 1; - } + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *(judy_cell (judy, askitis+prev, off - prev)) += 1; // count instances of string + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); - insert_real_time = insert_real_time / 1000.0; + insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * (stop.tv_usec - start.tv_usec ); + insert_real_time = insert_real_time/1000.0; #else - time(stop); + time (stop); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free(askitis); + free (askitis); fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); + "Judy Array size:", MaxMem/1000000., "Time to insert:", insert_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); @@ -2052,14 +1958,13 @@ int main(int argc, char **argv) Found = 0; // search judy array - if(in = freopen("skew1_1", "rb", in)) { - size = lseek(fileno(in), 0L, 2); - } else { + if( in = freopen ("skew1_1", "rb", in) ) + size = lseek (fileno(in), 0L, 2); + else exit(0); - } askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + lseek (fileno(in), 0L, 0); + read (fileno(in), askitis,size); prev = 0; #if !defined(_WIN32) @@ -2068,19 +1973,19 @@ int main(int argc, char **argv) time(start); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *judy_cell(judy, askitis + prev, off - prev) += 1; - prev = off + 1; - } + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *judy_cell (judy, askitis+prev, off - prev) += 1; + prev = off + 1; + } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) gettimeofday(&stop, NULL); - search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 - * (stop.tv_usec - start.tv_usec); - search_real_time = search_real_time / 1000.0; + search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 + * (stop.tv_usec - start.tv_usec ); + search_real_time = search_real_time/1000.0; #else time(stop); search_real_time = *stop - *start; @@ -2089,91 +1994,88 @@ int main(int argc, char **argv) // naskitis.com: // To do: report a count on the number of strings found. - fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); + fprintf(stderr,"\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem/1000000., "Time to search:", search_real_time); fprintf(stderr, "%-20s %d\n", "Words:", Words); fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); fprintf(stderr, "%-20s %d\n", "Found:", Found); exit(0); #endif #ifdef HEXKEYS - judy = judy_open(1024, 16 / JUDY_key_size); + judy = judy_open (1024, 16/JUDY_key_size); - while(fgets((char *)buff, sizeof(buff), in)) { - judyvalue key[16 / JUDY_key_size]; - if(len = strlen((const char *)buff)) { - buff[--len] = 0; // remove LF - } + while( fgets((char *)buff, sizeof(buff), in) ) { + judyvalue key[16/JUDY_key_size]; + if( len = strlen((const char *)buff) ) + buff[--len] = 0; // remove LF #if JUDY_key_size == 4 - key[3] = strtoul(buff + 24, NULL, 16); + key[3] = strtoul (buff + 24, NULL, 16); buff[24] = 0; - key[2] = strtoul(buff + 16, NULL, 16); + key[2] = strtoul (buff + 16, NULL, 16); buff[16] = 0; - key[1] = strtoul(buff + 8, NULL, 16); + key[1] = strtoul (buff + 8, NULL, 16); buff[8] = 0; - key[0] = strtoul(buff, NULL, 16); + key[0] = strtoul (buff, NULL, 16); #else - key[1] = strtoull(buff + 16, NULL, 16); + key[1] = strtoull (buff + 16, NULL, 16); buff[16] = 0; - key[0] = strtoull(buff, NULL, 16); + key[0] = strtoull (buff, NULL, 16); #endif - *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string + *(judy_cell (judy, (void *)key, 0)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - judyvalue key[16 / JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates + if( cell ) do { + judyvalue key[16/JUDY_key_size]; + len = judy_key(judy, (void *)key, 0); + for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates #if JUDY_key_size == 4 - fprintf(out, "%.8X", key[0]); - fprintf(out, "%.8X", key[1]); - fprintf(out, "%.8X", key[2]); - fprintf(out, "%.8X", key[3]); + fprintf (out, "%.8X", key[0]); + fprintf (out, "%.8X", key[1]); + fprintf (out, "%.8X", key[2]); + fprintf (out, "%.8X", key[3]); #else - fprintf(out, "%.16llX", key[0]); - fprintf(out, "%.16llX", key[1]); + fprintf (out, "%.16llX", key[0]); + fprintf (out, "%.16llX", key[1]); #endif - fputc('\n', out); - } - } while(cell = judy_nxt(judy)); + fputc('\n', out); + } + } while( cell = judy_nxt (judy) ); #else - judy = judy_open(1024, 0); + judy = judy_open (1024, 0); - while(fgets((char *)buff, sizeof(buff), in)) { - if(len = strlen((const char *)buff)) { - buff[--len] = 0; // remove LF - } - *(judy_cell(judy, buff, len)) += 1; // count instances of string + while( fgets((char *)buff, sizeof(buff), in) ) { + if( len = strlen((const char *)buff) ) + buff[--len] = 0; // remove LF + *(judy_cell (judy, buff, len)) += 1; // count instances of string max++; } fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt (judy, NULL, 0); - if(cell) do { - len = judy_key(judy, buff, sizeof(buff)); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); - } - } while(cell = judy_nxt(judy)); + if( cell ) do { + len = judy_key(judy, buff, sizeof(buff)); + for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates + fwrite(buff, len, 1, out); + fputc('\n', out); + } + } while( cell = judy_nxt (judy) ); #endif #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) - do { - max -= *cell; - } while(cell = judy_del(judy)); + if( cell = judy_prv (judy) ) + do max -= *cell; + while( cell = judy_del (judy) ); - assert(max == 0); + assert (max == 0); #endif judy_close(judy); return 0; diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index 54d14c776..45e0cba44 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -70,25 +70,24 @@ extern unsigned int MaxMem; // void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort(char *msg) -{ - fprintf(stderr, "%s\n", msg); - exit(1); +void judy_abort( char * msg ) { + fprintf( stderr, "%s\n", msg ); + exit( 1 ); } #endif int JudySize[] = { - (JUDY_slot_size * 16), // JUDY_radix node size - (JUDY_slot_size + JUDY_key_size), // JUDY_1 node size - (2 * JUDY_slot_size + 2 * JUDY_key_size), - (4 * JUDY_slot_size + 4 * JUDY_key_size), - (8 * JUDY_slot_size + 8 * JUDY_key_size), - (16 * JUDY_slot_size + 16 * JUDY_key_size), - (32 * JUDY_slot_size + 32 * JUDY_key_size), + ( JUDY_slot_size * 16 ), // JUDY_radix node size + ( JUDY_slot_size + JUDY_key_size ), // JUDY_1 node size + ( 2 * JUDY_slot_size + 2 * JUDY_key_size ), + ( 4 * JUDY_slot_size + 4 * JUDY_key_size ), + ( 8 * JUDY_slot_size + 8 * JUDY_key_size ), + ( 16 * JUDY_slot_size + 16 * JUDY_key_size ), + ( 32 * JUDY_slot_size + 32 * JUDY_key_size ), #ifndef ASKITIS - (JUDY_span_bytes + JUDY_slot_size) + ( JUDY_span_bytes + JUDY_slot_size ) #else - (64 * JUDY_slot_size + 64 * JUDY_key_size) + ( 64 * JUDY_slot_size + 64 * JUDY_key_size ) #endif }; @@ -103,28 +102,27 @@ judyvalue JudyMask[9] = { // call with max key size // and Integer tree depth. -Judy *judy_open(unsigned int max, unsigned int depth) -{ - JudySeg *seg; - Judy *judy; +Judy * judy_open( unsigned int max, unsigned int depth ) { + JudySeg * seg; + Judy * judy; unsigned int amt; max++; // allow for zero terminator on keys - if((seg = malloc(JUDY_seg))) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->seg = NULL; seg->next = JUDY_seg; } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("No virtual memory"); + judy_abort( "No virtual memory" ); #else return NULL; #endif } - amt = sizeof(Judy) + max * sizeof(JudyStack); + amt = sizeof( Judy ) + max * sizeof( JudyStack ); - if(amt & (JUDY_cache_line - 1)) { + if( amt & ( JUDY_cache_line - 1 ) ) { amt |= JUDY_cache_line - 1, amt++; } @@ -132,92 +130,90 @@ Judy *judy_open(unsigned int max, unsigned int depth) MaxMem += JUDY_seg; #endif - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); seg->next -= amt; - judy = (Judy *)((unsigned char *)seg + seg->next); - memset(judy, 0, amt); + judy = ( Judy * )( ( unsigned char * )seg + seg->next ); + memset( judy, 0, amt ); judy->depth = depth; judy->seg = seg; judy->max = max; return judy; } -void judy_close(Judy *judy) -{ - JudySeg *seg, *nxt = judy->seg; +void judy_close( Judy * judy ) { + JudySeg * seg, *nxt = judy->seg; - while((seg = nxt)) { - nxt = seg->seg, free(seg); + while( ( seg = nxt ) ) { + nxt = seg->seg, free( seg ); } } // allocate judy node -void *judy_alloc(Judy *judy, unsigned int type) -{ +void * judy_alloc( Judy * judy, unsigned int type ) { unsigned int amt, idx, min; - JudySeg *seg; - void **block; - void **rtn; + JudySeg * seg; + void ** block; + void ** rtn; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort( "illegal allocation from judy clone" ); #else return NULL; #endif - if(type == JUDY_radix) { + if( type == JUDY_radix ) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) { type = JUDY_span_equiv; } #endif amt = JudySize[type]; - if(amt & 0x07) { + if( amt & 0x07 ) { amt |= 0x07, amt += 1; } // see if free block is already available - if((block = judy->reuse[type])) { + if( ( block = judy->reuse[type] ) ) { judy->reuse[type] = *block; - memset(block, 0, amt); - return (void *)block; + memset( block, 0, amt ); + return ( void * )block; } // break down available larger block // for reuse into smaller blocks - if(type >= JUDY_1) - for(idx = type; idx++ < JUDY_max;) - if((block = judy->reuse[idx])) { + if( type >= JUDY_1 ) + for( idx = type; idx++ < JUDY_max; ) + if( (block = judy->reuse[idx]) ) { judy->reuse[idx] = *block; - while(idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; + while( idx-- > type ) { + judy->reuse[idx] = block + JudySize[idx] / sizeof( void * ); + block[JudySize[idx] / sizeof( void * )] = 0; } - memset(block, 0, amt); - return (void *)block; + memset( block, 0, amt ); + return ( void * )block; } min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - if(judy->seg->next < min + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < min + sizeof( *seg ) ) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); + judy_abort( "Out of virtual memory" ); #else return NULL; #endif @@ -231,45 +227,45 @@ void *judy_alloc(Judy *judy, unsigned int type) // generate additional free blocks // to fill up to cache line size - rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); + rtn = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - amt ); - for(idx = type; amt & (JUDY_cache_line - 1); amt <<= 1) { - block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); + for( idx = type; amt & ( JUDY_cache_line - 1 ); amt <<= 1 ) { + block = ( void ** )( ( unsigned char * )judy->seg + judy->seg->next - 2 * amt ); judy->reuse[idx++] = block; *block = 0; } judy->seg->next -= amt; - memset(rtn, 0, JudySize[type]); - return (void *)rtn; + memset( rtn, 0, JudySize[type] ); + return ( void * )rtn; } -void *judy_data(Judy *judy, unsigned int amt) +void * judy_data( Judy * judy, unsigned int amt ) { - JudySeg *seg; - void *block; + JudySeg * seg; + void * block; - if(!judy->seg) + if( !judy->seg ) #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); + judy_abort( "illegal allocation from judy clone" ); #else return NULL; #endif - if(amt & (JUDY_cache_line - 1)) { - amt |= (JUDY_cache_line - 1), amt += 1; + if( amt & ( JUDY_cache_line - 1 ) ) { + amt |= ( JUDY_cache_line - 1 ), amt += 1; } - if(judy->seg->next < amt + sizeof(*seg)) { - if((seg = malloc(JUDY_seg))) { + if( judy->seg->next < amt + sizeof( *seg ) ) { + if( ( seg = malloc( JUDY_seg ) ) ) { seg->next = JUDY_seg; seg->seg = judy->seg; judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); + seg->next -= ( JudySlot )seg & ( JUDY_cache_line - 1 ); } else { #if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); + judy_abort( "Out of virtual memory" ); #else return NULL; #endif @@ -282,68 +278,65 @@ void *judy_data(Judy *judy, unsigned int amt) judy->seg->next -= amt; - block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset(block, 0, amt); + block = ( void * )( ( unsigned char * )judy->seg + judy->seg->next ); + memset( block, 0, amt ); return block; } -Judy *judy_clone(Judy *judy) -{ - Judy *clone; +Judy * judy_clone( Judy * judy ) { + Judy * clone; unsigned int amt; - amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data(judy, amt); - memcpy(clone, judy, amt); + amt = sizeof( Judy ) + judy->max * sizeof( JudyStack ); + clone = judy_data( judy, amt ); + memcpy( clone, judy, amt ); clone->seg = NULL; // stop allocations from cloned array return clone; } -void judy_free(Judy *judy, void *block, int type) -{ - if(type == JUDY_radix) { +void judy_free( Judy * judy, void * block, int type ) { + if( type == JUDY_radix ) { type = JUDY_radix_equiv; } #ifndef ASKITIS - if(type == JUDY_span) { + if( type == JUDY_span ) { type = JUDY_span_equiv; } #endif - *((void **)(block)) = judy->reuse[type]; - judy->reuse[type] = (void **)block; + *( ( void ** )( block ) ) = judy->reuse[type]; + judy->reuse[type] = ( void ** )block; return; } // assemble key from current path -unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) -{ - judyvalue *dest = (judyvalue *)buff; +unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ) { + judyvalue * dest = ( judyvalue * )buff; unsigned int len = 0, idx = 0, depth; int slot, off, type; judyvalue value; - unsigned char *base; + unsigned char * base; int keysize; - if(judy->depth) { + if( judy->depth ) { max = judy->depth * JUDY_key_size; } else { max--; // leave room for zero terminator } - while(len < max && ++idx <= judy->level) { + while( len < max && ++idx <= judy->level ) { type = judy->stack[idx].next & 0x07; slot = judy->stack[idx].slot; depth = len / JUDY_key_size; - if(judy->depth) - if(!(len & JUDY_key_mask)) { + if( judy->depth ) + if( !( len & JUDY_key_mask ) ) { dest[depth] = 0; } - switch(type) { + switch( type ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -353,16 +346,16 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + keysize = JUDY_key_size - ( judy->stack[idx].off & JUDY_key_mask ); + base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); - if(judy->depth) { - value = *(judyvalue *)(base + slot * keysize); + if( judy->depth ) { + value = *( judyvalue * )( base + slot * keysize ); value &= JudyMask[keysize]; dest[depth++] |= value; len += keysize; - if(depth < judy->depth) { + if( depth < judy->depth ) { continue; } @@ -372,15 +365,15 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) #if BYTE_ORDER != BIG_ENDIAN off = keysize; - while(off-- && len < max) - if((buff[len] = base[slot * keysize + off])) { + while( off-- && len < max ) + if( (buff[len] = base[slot * keysize + off]) ) { len++; } else { break; } #else - for(off = 0; off < keysize && len < max; off++) - if(buff[len] = base[slot * keysize + off]) { + for( off = 0; off < keysize && len < max; off++ ) + if( buff[len] = base[slot * keysize + off] ) { len++; } else { break; @@ -389,30 +382,30 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) continue; case JUDY_radix: - if(judy->depth) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if(!(len & JUDY_key_mask)) { + if( judy->depth ) { + dest[depth] |= ( judyvalue )slot << ( JUDY_key_size - ( ++len & JUDY_key_mask ) ) * 8; + if( !( len & JUDY_key_mask ) ) { depth++; } - if(depth < judy->depth) { + if( depth < judy->depth ) { continue; } return len; } - if(!slot) { + if( !slot ) { break; } - buff[len++] = (unsigned char)slot; + buff[len++] = ( unsigned char )slot; continue; #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); + base = ( unsigned char * )( judy->stack[idx].next & JUDY_mask ); - for(slot = 0; slot < JUDY_span_bytes && base[slot]; slot++) - if(len < max) { + for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) + if( len < max ) { buff[len++] = base[slot]; } continue; @@ -425,25 +418,24 @@ unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max) // find slot & setup cursor -JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) -{ - judyvalue *src = (judyvalue *)buff; +JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ) { + judyvalue * src = ( judyvalue * )buff; int slot, size, keysize, tst, cnt; JudySlot next = *judy->root; judyvalue value, test = 0; - JudySlot *table; - JudySlot *node; + JudySlot * table; + JudySlot * node; unsigned int depth = 0; unsigned int off = 0; - unsigned char *base; + unsigned char * base; #ifndef ASKITIS judy->level = 0; #endif - while(next) { + while( next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } @@ -452,7 +444,7 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #endif size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: @@ -463,14 +455,14 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #ifdef ASKITIS case JUDY_64: #endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); + base = ( unsigned char * )( next & JUDY_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); slot = cnt; value = 0; - if(judy->depth) { + if( judy->depth ) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -478,32 +470,32 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) } else do { value <<= 8; - if(off < max) { + if( off < max ) { value |= buff[off]; } - } while(++off & JUDY_key_mask); + } while( ++off & JUDY_key_mask ); // find slot > key - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + while( slot-- ) { + test = *( judyvalue * )( base + slot * keysize ); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * ( JUDY_key_size - keysize ); #else test &= JudyMask[keysize]; #endif - if(test <= value) { + if( test <= value ) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if(test == value) { + if( test == value ) { // is this a leaf? - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { return &node[-slot - 1]; } @@ -514,11 +506,11 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) return NULL; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix + table = ( JudySlot * )( next & JUDY_mask ); // outer radix - if(judy->depth) { - slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { + if( judy->depth ) { + slot = ( src[depth] >> ( (( JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; + } else if( off < max ) { slot = buff[off++]; } else { slot = 0; @@ -528,19 +520,19 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) judy->stack[judy->level].slot = slot; #endif - if((next = table[slot >> 4])) { - table = (JudySlot *)(next & JUDY_mask); // inner radix + if( ( next = table[slot >> 4] ) ) { + table = ( JudySlot * )( next & JUDY_mask ); // inner radix } else { return NULL; } - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? - if(table[slot & 0x0F]) { // occupied? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? + if( table[slot & 0x0F] ) { // occupied? return &table[slot & 0x0F]; } else { return NULL; @@ -552,18 +544,18 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if(!value && tst < cnt && !base[tst]) { // leaf? + value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); + if( !value && tst < cnt && !base[tst] ) { // leaf? return &node[-1]; } - if(!value && tst == cnt) { + if( !value && tst == cnt ) { next = node[-1]; off += cnt; continue; @@ -578,63 +570,62 @@ JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max) // promote full nodes to next larger size -JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) -{ - unsigned char *base = (unsigned char *)(*next & JUDY_mask); +JudySlot * judy_promote( Judy * judy, JudySlot * next, int idx, judyvalue value, int keysize ) { + unsigned char * base = ( unsigned char * )( *next & JUDY_mask ); int oldcnt, newcnt, slot; #if BYTE_ORDER == BIG_ENDIAN int i; #endif - JudySlot *newnode, *node; - JudySlot *result; - unsigned char *newbase; + JudySlot * newnode, *node; + JudySlot * result; + unsigned char * newbase; unsigned int type; - type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type - 1]); - oldcnt = JudySize[type - 1] / (sizeof(JudySlot) + keysize); - newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); + type = ( *next & 0x07 ) + 1; + node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[type - 1] ); + oldcnt = JudySize[type - 1] / ( sizeof( JudySlot ) + keysize ); + newcnt = JudySize[type] / ( sizeof( JudySlot ) + keysize ); // promote node to next larger size - newbase = judy_alloc(judy, type); - newnode = (JudySlot *)(newbase + JudySize[type]); - *next = (JudySlot)newbase | type; + newbase = judy_alloc( judy, type ); + newnode = ( JudySlot * )( newbase + JudySize[type] ); + *next = ( JudySlot )newbase | type; // open up slot at idx - memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys + memcpy( newbase + ( newcnt - oldcnt - 1 ) * keysize, base, idx * keysize ); // copy keys - for(slot = 0; slot < idx; slot++) { - newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr + for( slot = 0; slot < idx; slot++ ) { + newnode[-( slot + newcnt - oldcnt )] = node[-( slot + 1 )]; // copy ptr } // fill in new node #if BYTE_ORDER != BIG_ENDIAN - memcpy(newbase + (idx + newcnt - oldcnt - 1) * keysize, &value, keysize); // copy key + memcpy( newbase + ( idx + newcnt - oldcnt - 1 ) * keysize, &value, keysize ); // copy key #else i = keysize; - while(i--) { - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; + while( i-- ) { + newbase[( idx + newcnt - oldcnt - 1 ) * keysize + i] = value, value >>= 8; } #endif - result = &newnode[-(idx + newcnt - oldcnt)]; + result = &newnode[-( idx + newcnt - oldcnt )]; // copy rest of old node - memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys + memcpy( newbase + ( idx + newcnt - oldcnt ) * keysize, base + ( idx * keysize ), ( oldcnt - slot ) * keysize ); // copy keys - for(; slot < oldcnt; slot++) { - newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr + for( ; slot < oldcnt; slot++ ) { + newnode[-( slot + newcnt - oldcnt + 1 )] = node[-( slot + 1 )]; // copy ptr } #ifndef ASKITIS judy->stack[judy->level].next = *next; judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; #endif - judy_free(judy, (void **)base, type - 1); + judy_free( judy, ( void ** )base, type - 1 ); return result; } @@ -642,26 +633,25 @@ JudySlot *judy_promote(Judy *judy, JudySlot *next, int idx, judyvalue value, int // make node with slot - start entries // moving key over one offset -void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) -{ +void judy_radix( Judy * judy, JudySlot * radix, unsigned char * old, int start, int slot, int keysize, unsigned char key, unsigned int depth ) { int size, idx, cnt = slot - start, newcnt; - JudySlot *node, *oldnode; + JudySlot * node, *oldnode; unsigned int type = JUDY_1 - 1; - JudySlot *table; - unsigned char *base; + JudySlot * table; + unsigned char * base; // if necessary, setup inner radix node - if(!(table = (JudySlot *)(radix[key >> 4] & JUDY_mask))) { - table = judy_alloc(judy, JUDY_radix); - radix[key >> 4] = (JudySlot)table | JUDY_radix; + if( !( table = ( JudySlot * )( radix[key >> 4] & JUDY_mask ) ) ) { + table = judy_alloc( judy, JUDY_radix ); + radix[key >> 4] = ( JudySlot )table | JUDY_radix; } - oldnode = (JudySlot *)(old + JudySize[JUDY_max]); + oldnode = ( JudySlot * )( old + JudySize[JUDY_max] ); // is this slot a leaf? - if((!judy->depth && (!key || !keysize)) || (judy->depth && !keysize && depth == judy->depth)) { + if( (!judy->depth && ( !key || !keysize )) || (judy->depth && !keysize && depth == judy->depth) ) { table[key & 0x0F] = oldnode[-start - 1]; return; } @@ -671,82 +661,80 @@ void judy_radix(Judy *judy, JudySlot *radix, unsigned char *old, int start, int do { type++; size = JudySize[type]; - newcnt = size / (sizeof(JudySlot) + keysize); - } while(cnt > newcnt && type < JUDY_max); + newcnt = size / ( sizeof( JudySlot ) + keysize ); + } while( cnt > newcnt && type < JUDY_max ); // store new node pointer in inner table - base = judy_alloc(judy, type); - node = (JudySlot *)(base + size); - table[key & 0x0F] = (JudySlot)base | type; + base = judy_alloc( judy, type ); + node = ( JudySlot * )( base + size ); + table[key & 0x0F] = ( JudySlot )base | type; // allocate node and copy old contents // shorten keys by 1 byte during copy - for(idx = 0; idx < cnt; idx++) { + for( idx = 0; idx < cnt; idx++ ) { #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); + memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ), keysize ); #else - memcpy(base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); + memcpy( base + ( newcnt - idx - 1 ) * keysize, old + ( start + cnt - idx - 1 ) * ( keysize + 1 ) + 1, keysize ); #endif - node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; + node[-( newcnt - idx )] = oldnode[-( start + cnt - idx )]; } } // decompose full node to radix nodes -void judy_splitnode(Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) -{ +void judy_splitnode( Judy * judy, JudySlot * next, unsigned int size, unsigned int keysize, unsigned int depth ) { int cnt, slot, start = 0; unsigned int key = 0x0100, nxt; - JudySlot *newradix; - unsigned char *base; + JudySlot * newradix; + unsigned char * base; - base = (unsigned char *)(*next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + base = ( unsigned char * )( *next & JUDY_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); // allocate outer judy_radix node - newradix = judy_alloc(judy, JUDY_radix); - *next = (JudySlot)newradix | JUDY_radix; + newradix = judy_alloc( judy, JUDY_radix ); + *next = ( JudySlot )newradix | JUDY_radix; - for(slot = 0; slot < cnt; slot++) { + for( slot = 0; slot < cnt; slot++ ) { #if BYTE_ORDER != BIG_ENDIAN nxt = base[slot * keysize + keysize - 1]; #else nxt = base[slot * keysize]; #endif - if(key > 0xFF) { + if( key > 0xFF ) { key = nxt; } - if(nxt == key) { + if( nxt == key ) { continue; } // decompose portion of old node into radix nodes - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); + judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); start = slot; key = nxt; } - judy_radix(judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free(judy, (void **)base, JUDY_max); + judy_radix( judy, newradix, base, start, slot, keysize - 1, ( unsigned char )key, depth ); + judy_free( judy, ( void ** )base, JUDY_max ); } // return first leaf -JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ - JudySlot *table, *inner; +JudySlot * judy_first( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { + JudySlot * table, *inner; unsigned int keysize, size; - JudySlot *node; + JudySlot * node; int slot, cnt; - unsigned char *base; + unsigned char * base; - while(next) { - if(judy->level < judy->max) { + while( next ) { + if( judy->level < judy->max ) { judy->level++; } @@ -754,7 +742,7 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d judy->stack[judy->level].next = next; size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -764,43 +752,43 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); - for(slot = 0; slot < cnt; slot++) - if(node[-slot - 1]) { + for( slot = 0; slot < cnt; slot++ ) + if( node[-slot - 1] ) { break; } judy->stack[judy->level].slot = slot; #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) { + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) { return &node[-slot - 1]; } #else - if(!judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth) { + if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) { return &node[-slot - 1]; } #endif next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; + off = ( off | JUDY_key_mask ) + 1; continue; case JUDY_radix: off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - table = (JudySlot *)(next & JUDY_mask); - for(slot = 0; slot < 256; slot++) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { + table = ( JudySlot * )( next & JUDY_mask ); + for( slot = 0; slot < 256; slot++ ) + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( ( next = inner[slot & 0x0F] ) ) { judy->stack[judy->level].slot = slot; - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[slot & 0x0F]; } else { break; @@ -812,10 +800,10 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d continue; #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? + if( !base[cnt - 1] ) { // leaf node? return &node[-1]; } next = node[-1]; @@ -829,23 +817,22 @@ JudySlot *judy_first(Judy *judy, JudySlot next, unsigned int off, unsigned int d // return last leaf cell pointer -JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ - JudySlot *table, *inner; +JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int depth ) { + JudySlot * table, *inner; unsigned int keysize, size; - JudySlot *node; + JudySlot * node; int slot, cnt; - unsigned char *base; + unsigned char * base; - while(next) { - if(judy->level < judy->max) { + while( next ) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = next; judy->stack[judy->level].off = off; size = JudySize[next & 0x07]; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -855,16 +842,16 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + slot = size / ( sizeof( JudySlot ) + keysize ); + base = ( unsigned char * )( next & JUDY_mask ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); judy->stack[judy->level].slot = --slot; #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || judy->depth && ++depth == judy->depth ) #endif return &node[-slot - 1]; @@ -873,19 +860,19 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); off++; - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } - for(slot = 256; slot--;) { + for( slot = 256; slot--; ) { judy->stack[judy->level].slot = slot; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if((next = inner[slot & 0x0F])) { - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( ( next = inner[slot & 0x0F] ) ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { break; @@ -899,10 +886,10 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de #ifndef ASKITIS case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); + node = ( JudySlot * )( ( next & JUDY_mask ) + JudySize[JUDY_span] ); + base = ( unsigned char * )( next & JUDY_mask ); cnt = JUDY_span_bytes; - if(!base[cnt - 1]) { // leaf node? + if( !base[cnt - 1] ) { // leaf node? return &node[-1]; } next = node[-1]; @@ -916,37 +903,35 @@ JudySlot *judy_last(Judy *judy, JudySlot next, unsigned int off, unsigned int de // judy_end: return last entry -JudySlot *judy_end(Judy *judy) -{ +JudySlot * judy_end( Judy * judy ) { judy->level = 0; - return judy_last(judy, *judy->root, 0, 0); + return judy_last( judy, *judy->root, 0, 0 ); } // judy_nxt: return next entry -JudySlot *judy_nxt(Judy *judy) -{ - JudySlot *table, *inner; +JudySlot * judy_nxt( Judy * judy ) { + JudySlot * table, *inner; int slot, size, cnt; - JudySlot *node; + JudySlot * node; JudySlot next; unsigned int keysize; - unsigned char *base; + unsigned char * base; unsigned int depth; unsigned int off; - if(!judy->level) { - return judy_first(judy, *judy->root, 0, 0); + if( !judy->level ) { + return judy_first( judy, *judy->root, 0, 0 ); } - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; - keysize = JUDY_key_size - (off & JUDY_key_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -956,40 +941,40 @@ JudySlot *judy_nxt(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if(++slot < cnt) { + cnt = size / ( sizeof( JudySlot ) + keysize ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); + if( ++slot < cnt ) { #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[slot * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif { judy->stack[judy->level].slot = slot; return &node[-slot - 1]; } else { judy->stack[judy->level].slot = slot; - return judy_first(judy, node[-slot - 1], (off | JUDY_key_mask) + 1, depth); + return judy_first( judy, node[-slot - 1], ( off | JUDY_key_mask ) + 1, depth ); } } judy->level--; continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { + if( judy->depth ) + if( !( ( off + 1 ) & JUDY_key_mask ) ) { depth++; } - while(++slot < 256) - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) { - if(inner[slot & 0x0F]) { + while( ++slot < 256 ) + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) { + if( inner[slot & 0x0F] ) { judy->stack[judy->level].slot = slot; - if(!judy->depth || depth < judy->depth) { - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); + if( !judy->depth || depth < judy->depth ) { + return judy_first( judy, inner[slot & 0x0F], off + 1, depth ); } return &inner[slot & 0x0F]; } @@ -1011,27 +996,26 @@ JudySlot *judy_nxt(Judy *judy) // judy_prv: return ptr to previous entry -JudySlot *judy_prv(Judy *judy) -{ +JudySlot * judy_prv( Judy * judy ) { int slot, size, keysize; - JudySlot *table, *inner; - JudySlot *node, next; - unsigned char *base; + JudySlot * table, *inner; + JudySlot * node, next; + unsigned char * base; unsigned int depth; unsigned int off; - if(!judy->level) { - return judy_last(judy, *judy->root, 0, 0); + if( !judy->level ) { + return judy_last( judy, *judy->root, 0, 0 ); } - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; depth = off / JUDY_key_size; - switch(next & 0x07) { + switch( next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1041,40 +1025,40 @@ JudySlot *judy_prv(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - node = (JudySlot *)((next & JUDY_mask) + size); - if(!slot || !node[-slot]) { + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + if( !slot || !node[-slot] ) { judy->level--; continue; } - base = (unsigned char *)(next & JUDY_mask); + base = ( unsigned char * )( next & JUDY_mask ); judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); #if BYTE_ORDER != BIG_ENDIAN - if((!judy->depth && !base[(slot - 1) * keysize]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[( slot - 1 ) * keysize]) || (judy->depth && ++depth == judy->depth) ) #else - if((!judy->depth && !base[(slot - 1) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth)) + if( (!judy->depth && !base[( slot - 1 ) * keysize + keysize - 1]) || (judy->depth && ++depth == judy->depth) ) #endif return &node[-slot]; - return judy_last(judy, node[-slot], (off | JUDY_key_mask) + 1, depth); + return judy_last( judy, node[-slot], ( off | JUDY_key_mask ) + 1, depth ); case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); - if(judy->depth) - if(!((off + 1) & JUDY_key_mask)) { + if( judy->depth ) + if( !( ( off + 1 ) & JUDY_key_mask ) ) { depth++; } - while(slot--) { + while( slot-- ) { judy->stack[judy->level].slot--; - if((inner = (JudySlot *)(table[slot >> 4] & JUDY_mask))) - if(inner[slot & 0x0F]) { - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { + if( ( inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ) ) ) + if( inner[slot & 0x0F] ) { + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { return &inner[0]; } else { - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); + return judy_last( judy, inner[slot & 0x0F], off + 1, depth ); } } } @@ -1095,21 +1079,20 @@ JudySlot *judy_prv(Judy *judy) // judy_del: delete string from judy array // returning previous entry. -JudySlot *judy_del(Judy *judy) -{ - int slot, off, size, type; - JudySlot *table, *inner; +JudySlot * judy_del( Judy * judy ) { + int slot, off, size, type, high; + JudySlot * table, *inner; JudySlot next, *node; int keysize, cnt; - unsigned char *base; + unsigned char * base; - while(judy->level) { + while( judy->level ) { next = judy->stack[judy->level].next; slot = judy->stack[judy->level].slot; off = judy->stack[judy->level].off; size = JudySize[next & 0x07]; - switch(type = next & 0x07) { + switch( type = next & 0x07 ) { case JUDY_1: case JUDY_2: case JUDY_4: @@ -1119,59 +1102,60 @@ JudySlot *judy_del(Judy *judy) #ifdef ASKITIS case JUDY_64: #endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); + node = ( JudySlot * )( ( next & JUDY_mask ) + size ); + base = ( unsigned char * )( next & JUDY_mask ); // move deleted slot to first slot - while(slot) { + while( slot ) { node[-slot - 1] = node[-slot]; - memcpy(base + slot * keysize, base + (slot - 1) * keysize, keysize); + memcpy( base + slot * keysize, base + ( slot - 1 ) * keysize, keysize ); slot--; } // zero out first slot node[-1] = 0; - memset(base, 0, keysize); + memset( base, 0, keysize ); - if(node[-cnt]) { // does node have any slots left? + if( node[-cnt] ) { // does node have any slots left? judy->stack[judy->level].slot++; - return judy_prv(judy); + return judy_prv( judy ); } - judy_free(judy, base, type); + judy_free( judy, base, type ); judy->level--; continue; case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = ( JudySlot * )( next & JUDY_mask ); + inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); inner[slot & 0x0F] = 0; + high = slot & 0xF0; - for(cnt = 16; cnt--;) - if(inner[cnt]) { - return judy_prv(judy); + for( cnt = 16; cnt--; ) + if( inner[cnt] ) { + return judy_prv( judy ); } - judy_free(judy, inner, JUDY_radix); + judy_free( judy, inner, JUDY_radix ); table[slot >> 4] = 0; - for(cnt = 16; cnt--;) - if(table[cnt]) { - return judy_prv(judy); + for( cnt = 16; cnt--; ) + if( table[cnt] ) { + return judy_prv( judy ); } - judy_free(judy, table, JUDY_radix); + judy_free( judy, table, JUDY_radix ); judy->level--; continue; #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free(judy, base, type); + base = ( unsigned char * )( next & JUDY_mask ); + judy_free( judy, base, type ); judy->level--; continue; #endif @@ -1186,101 +1170,98 @@ JudySlot *judy_del(Judy *judy) // return cell for first key greater than or equal to given key -JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max) -{ - JudySlot *cell; +JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ) { + JudySlot * cell; judy->level = 0; - if(!max) { - return judy_first(judy, *judy->root, 0, 0); + if( !max ) { + return judy_first( judy, *judy->root, 0, 0 ); } - if((cell = judy_slot(judy, buff, max))) { + if( ( cell = judy_slot( judy, buff, max ) ) ) { return cell; } - return judy_nxt(judy); + return judy_nxt( judy ); } // split open span node #ifndef ASKITIS -void judy_splitspan(Judy *judy, JudySlot *next, unsigned char *base) -{ - JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); +void judy_splitspan( Judy * judy, JudySlot * next, unsigned char * base ) { + JudySlot * node = ( JudySlot * )( base + JudySize[JUDY_span] ); unsigned int cnt = JUDY_span_bytes; - unsigned char *newbase; + unsigned char * newbase; unsigned int off = 0; #if BYTE_ORDER != BIG_ENDIAN int i; #endif do { - newbase = judy_alloc(judy, JUDY_1); - *next = (JudySlot)newbase | JUDY_1; + newbase = judy_alloc( judy, JUDY_1 ); + *next = ( JudySlot )newbase | JUDY_1; #if BYTE_ORDER != BIG_ENDIAN i = JUDY_key_size; - while(i--) { + while( i-- ) { *newbase++ = base[off + i]; } #else - memcpy(newbase, base + off, JUDY_key_size); + memcpy( newbase, base + off, JUDY_key_size ); newbase += JUDY_key_size; #endif - next = (JudySlot *)newbase; + next = ( JudySlot * )newbase; off += JUDY_key_size; cnt -= JUDY_key_size; - } while(cnt && base[off - 1]); + } while( cnt && base[off - 1] ); *next = node[-1]; - judy_free(judy, base, JUDY_span); + judy_free( judy, base, JUDY_span ); } #endif // judy_cell: add string to judy array -JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) -{ - judyvalue *src = (judyvalue *)buff; +JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ) { + judyvalue * src = ( judyvalue * )buff; int size, idx, slot, cnt, tst; - JudySlot *next = judy->root; + JudySlot * next = judy->root; judyvalue test, value; unsigned int off = 0, start; - JudySlot *table; - JudySlot *node; + JudySlot * table; + JudySlot * node; unsigned int depth = 0; unsigned int keysize; - unsigned char *base; + unsigned char * base; judy->level = 0; #ifdef ASKITIS Words++; #endif - while(*next) { + while( *next ) { #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; judy->stack[judy->level].off = off; #endif - switch(*next & 0x07) { + switch( *next & 0x07 ) { default: size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + cnt = size / ( sizeof( JudySlot ) + keysize ); + base = ( unsigned char * )( *next & JUDY_mask ); + node = ( JudySlot * )( ( *next & JUDY_mask ) + size ); start = off; slot = cnt; value = 0; - if(judy->depth) { + if( judy->depth ) { value = src[depth++]; off |= JUDY_key_mask; off++; @@ -1288,35 +1269,35 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) } else do { value <<= 8; - if(off < max) { + if( off < max ) { value |= buff[off]; } - } while(++off & JUDY_key_mask); + } while( ++off & JUDY_key_mask ); // find slot > key - while(slot--) { - test = *(judyvalue *)(base + slot * keysize); + while( slot-- ) { + test = *( judyvalue * )( base + slot * keysize ); #if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); + test >>= 8 * ( JUDY_key_size - keysize ); #else test &= JudyMask[keysize]; #endif - if(test <= value) { + if( test <= value ) { break; } } #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif - if(test == value) { // new key is equal to slot key + if( test == value ) { // new key is equal to slot key next = &node[-slot - 1]; // is this a leaf? - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1331,28 +1312,28 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // if this node is not full // open up cell after slot - if(!node[-1]) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot + if( !node[-1] ) { + memmove( base, base + keysize, slot * keysize ); // move keys less than new key down one slot #if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot + memcpy( base + slot * keysize, &value, keysize ); // copy new key into slot #else test = value; idx = keysize; - while(idx--) { + while( idx-- ) { base[slot * keysize + idx] = test, test >>= 8; } #endif - for(idx = 0; idx < slot; idx++) { + for( idx = 0; idx < slot; idx++ ) { node[-idx - 1] = node[-idx - 2]; // copy tree ptrs/cells down one slot } node[-slot - 1] = 0; // set new tree ptr/cell next = &node[-slot - 1]; - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1364,12 +1345,12 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) continue; } - if(size < JudySize[JUDY_max]) { - next = judy_promote(judy, next, slot + 1, value, keysize); + if( size < JudySize[JUDY_max] ) { + next = judy_promote( judy, next, slot + 1, value, keysize ); - if((!judy->depth && !(value & 0xFF)) || (judy->depth && depth == judy->depth)) { + if( (!judy->depth && !( value & 0xFF )) || (judy->depth && depth == judy->depth) ) { #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1384,47 +1365,47 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // split full maximal node into JUDY_radix nodes // loop to reprocess new insert - judy_splitnode(judy, next, size, keysize, depth); + judy_splitnode( judy, next, size, keysize, depth ); #ifndef ASKITIS judy->level--; #endif off = start; - if(judy->depth) { + if( judy->depth ) { depth--; } continue; case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix + table = ( JudySlot * )( *next & JUDY_mask ); // outer radix - if(judy->depth) { - slot = (src[depth] >> (((JUDY_key_size - ++off) & JUDY_key_mask) * 8)) & 0xff; - } else if(off < max) { + if( judy->depth ) { + slot = ( src[depth] >> ( ( (JUDY_key_size - ++off) & JUDY_key_mask ) * 8 ) ) & 0xff; + } else if( off < max ) { slot = buff[off++]; } else { slot = 0, off++; } - if(judy->depth) - if(!(off & JUDY_key_mask)) { + if( judy->depth ) + if( !( off & JUDY_key_mask ) ) { depth++; } // allocate inner radix if empty - if(!table[slot >> 4]) { - table[slot >> 4] = (JudySlot)judy_alloc(judy, JUDY_radix) | JUDY_radix; + if( !table[slot >> 4] ) { + table[slot >> 4] = ( JudySlot )judy_alloc( judy, JUDY_radix ) | JUDY_radix; } - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); + table = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); #ifndef ASKITIS judy->stack[judy->level].slot = slot; #endif next = &table[slot & 0x0F]; - if((!judy->depth && !slot) || (judy->depth && depth == judy->depth)) { // leaf? + if( (!judy->depth && !slot) || (judy->depth && depth == judy->depth) ) { // leaf? #ifdef ASKITIS - if(*next) { + if( *next ) { Found++; } else { Inserts++; @@ -1437,22 +1418,22 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) #ifndef ASKITIS case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); + base = ( unsigned char * )( *next & JUDY_mask ); + node = ( JudySlot * )( ( *next & JUDY_mask ) + JudySize[JUDY_span] ); cnt = JUDY_span_bytes; tst = cnt; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - value = strncmp((const char *)base, (const char *)(buff + off), tst); + value = strncmp( ( const char * )base, ( const char * )( buff + off ), tst ); - if(!value && tst < cnt && !base[tst]) { // leaf? + if( !value && tst < cnt && !base[tst] ) { // leaf? return &node[-1]; } - if(!value && tst == cnt) { + if( !value && tst == cnt ) { next = &node[-1]; off += cnt; continue; @@ -1461,7 +1442,7 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // bust up JUDY_span node and produce JUDY_1 nodes // then loop to reprocess insert - judy_splitspan(judy, next, base); + judy_splitspan( judy, next, base ); judy->level--; continue; #endif @@ -1471,31 +1452,31 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // place JUDY_1 node under JUDY_radix node(s) #ifndef ASKITIS - if(off & JUDY_key_mask) - if(judy->depth || off <= max) { + if( off & JUDY_key_mask ) + if( judy->depth || off <= max ) { #else - while(off <= max) { + while( off <= max ) { #endif - base = judy_alloc(judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + base = judy_alloc( judy, JUDY_1 ); + keysize = JUDY_key_size - ( off & JUDY_key_mask ); + node = ( JudySlot * )( base + JudySize[JUDY_1] ); + *next = ( JudySlot )base | JUDY_1; // fill in slot 0 with bytes of key - if(judy->depth) { + if( judy->depth ) { value = src[depth]; #if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot + memcpy( base, &value, keysize ); // copy new key into slot #else - while(keysize--) { + while( keysize-- ) { base[keysize] = value, value >>= 8; } #endif } else { #if BYTE_ORDER != BIG_ENDIAN - while(keysize) - if(off + keysize <= max) { + while( keysize ) + if( off + keysize <= max ) { *base++ = buff[off + --keysize]; } else { base++, --keysize; @@ -1503,15 +1484,15 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) #else tst = keysize; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - memcpy(base, buff + off, tst); + memcpy( base, buff + off, tst ); #endif } #ifndef ASKITIS - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1529,18 +1510,18 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) // or judy_1 nodes if not string tree #ifndef ASKITIS - if(!judy->depth) - while(off <= max) { - base = judy_alloc(judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); + if( !judy->depth ) + while( off <= max ) { + base = judy_alloc( judy, JUDY_span ); + *next = ( JudySlot )base | JUDY_span; + node = ( JudySlot * )( base + JudySize[JUDY_span] ); cnt = tst = JUDY_span_bytes; - if(tst > (int)(max - off)) { + if( tst > ( int )( max - off ) ) { tst = max - off; } - memcpy(base, buff + off, tst); + memcpy( base, buff + off, tst ); - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; @@ -1550,20 +1531,21 @@ JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max) off += tst; depth++; - if(!base[cnt - 1]) { // done on leaf + if( !base[cnt - 1] ) { // done on leaf break; } - } else - while(depth < judy->depth) { - base = judy_alloc(judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; + } + else + while( depth < judy->depth ) { + base = judy_alloc( judy, JUDY_1 ); + node = ( JudySlot * )( base + JudySize[JUDY_1] ); + *next = ( JudySlot )base | JUDY_1; // fill in slot 0 with bytes of key - *(judyvalue *)base = src[depth]; + *( judyvalue * )base = src[depth]; - if(judy->level < judy->max) { + if( judy->level < judy->max ) { judy->level++; } judy->stack[judy->level].next = *next; diff --git a/src/base/judy/src/judy.h b/src/base/judy/src/judy.h index 5ef2497ea..dfd193cf3 100644 --- a/src/base/judy/src/judy.h +++ b/src/base/judy/src/judy.h @@ -96,7 +96,7 @@ enum JUDY_types { }; typedef struct { - void *seg; // next used allocator + void * seg; // next used allocator unsigned int next; // next available offset } JudySeg; @@ -108,8 +108,8 @@ typedef struct { typedef struct { JudySlot root[1]; // root of judy array - void **reuse[8]; // reuse judy blocks - JudySeg *seg; // current judy allocator + void ** reuse[8]; // reuse judy blocks + JudySeg * seg; // current judy allocator unsigned int level; // current height of stack unsigned int max; // max height of stack unsigned int depth; // number of Integers in a key, or zero for string keys @@ -133,41 +133,41 @@ int Found = 0; extern "C" { #endif -/// open a new judy array returning a judy object. -SC_BASE_EXPORT Judy *judy_open(unsigned int max, unsigned int depth); + /// open a new judy array returning a judy object. + SC_BASE_EXPORT Judy * judy_open( unsigned int max, unsigned int depth ); -/// close an open judy array, freeing all memory. -SC_BASE_EXPORT void judy_close(Judy *judy); + /// close an open judy array, freeing all memory. + SC_BASE_EXPORT void judy_close( Judy * judy ); -/// clone an open judy array, duplicating the stack. -SC_BASE_EXPORT Judy *judy_clone(Judy *judy); + /// clone an open judy array, duplicating the stack. + SC_BASE_EXPORT Judy * judy_clone( Judy * judy ); -/// allocate data memory within judy array for external use. -SC_BASE_EXPORT void *judy_data(Judy *judy, unsigned int amt); + /// allocate data memory within judy array for external use. + SC_BASE_EXPORT void * judy_data( Judy * judy, unsigned int amt ); -/// insert a key into the judy array, return cell pointer. -SC_BASE_EXPORT JudySlot *judy_cell(Judy *judy, const unsigned char *buff, unsigned int max); + /// insert a key into the judy array, return cell pointer. + SC_BASE_EXPORT JudySlot * judy_cell( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer greater than or equal to given key -SC_BASE_EXPORT JudySlot *judy_strt(Judy *judy, const unsigned char *buff, unsigned int max); + /// retrieve the cell pointer greater than or equal to given key + SC_BASE_EXPORT JudySlot * judy_strt( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer, or return NULL for a given key. -SC_BASE_EXPORT JudySlot *judy_slot(Judy *judy, const unsigned char *buff, unsigned int max); + /// retrieve the cell pointer, or return NULL for a given key. + SC_BASE_EXPORT JudySlot * judy_slot( Judy * judy, const unsigned char * buff, unsigned int max ); -/// retrieve the string value for the most recent judy query. -SC_BASE_EXPORT unsigned int judy_key(Judy *judy, unsigned char *buff, unsigned int max); + /// retrieve the string value for the most recent judy query. + SC_BASE_EXPORT unsigned int judy_key( Judy * judy, unsigned char * buff, unsigned int max ); -/// retrieve the cell pointer for the last string in the array. -SC_BASE_EXPORT JudySlot *judy_end(Judy *judy); + /// retrieve the cell pointer for the last string in the array. + SC_BASE_EXPORT JudySlot * judy_end( Judy * judy ); -/// retrieve the cell pointer for the next string in the array. -SC_BASE_EXPORT JudySlot *judy_nxt(Judy *judy); + /// retrieve the cell pointer for the next string in the array. + SC_BASE_EXPORT JudySlot * judy_nxt( Judy * judy ); -/// retrieve the cell pointer for the prev string in the array. -SC_BASE_EXPORT JudySlot *judy_prv(Judy *judy); + /// retrieve the cell pointer for the prev string in the array. + SC_BASE_EXPORT JudySlot * judy_prv( Judy * judy ); -/// delete the key and cell for the current stack entry. -SC_BASE_EXPORT JudySlot *judy_del(Judy *judy); + /// delete the key and cell for the current stack entry. + SC_BASE_EXPORT JudySlot * judy_del( Judy * judy ); #ifdef __cplusplus } diff --git a/src/base/judy/src/judyL2Array.h b/src/base/judy/src/judyL2Array.h index e5b58bcfd..02b416827 100644 --- a/src/base/judy/src/judyL2Array.h +++ b/src/base/judy/src/judyL2Array.h @@ -29,68 +29,60 @@ struct judyl2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. With judyL2Array, the size of this value can vary. */ template< typename JudyKey, typename JudyValue > -class judyL2Array -{ +class judyL2Array { public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judyl2KVpair< JudyKey, vector * > pair; typedef judyl2KVpair< JudyKey, cvector * > cpair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxLevels, _depth; - vector **_lastSlot; + vector ** _lastSlot; JudyKey _buff[1]; bool _success; cpair kv; public: - judyL2Array(): _maxLevels(sizeof(JudyKey)), _depth(1), _lastSlot(0), _success(true) - { - assert(sizeof(JudyKey) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!"); - _judyarray = judy_open(_maxLevels, _depth); + judyL2Array(): _maxLevels( sizeof( JudyKey ) ), _depth( 1 ), _lastSlot( 0 ), _success( true ) { + assert( sizeof( JudyKey ) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!" ); + _judyarray = judy_open( _maxLevels, _depth ); _buff[0] = 0; } - explicit judyL2Array(const judyL2Array< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), - _depth(other._depth), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyL2Array( const judyL2Array< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), + _depth( other._depth ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff[0] = other._buff[0]; - find(*_buff); //set _lastSlot + find( *_buff ); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyL2Array() - { + ~judyL2Array() { clear(); - judy_close(_judyarray); + judy_close( _judyarray ); } /// delete all vectors and empty the array - void clear() - { + void clear() { JudyKey key = 0; - while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { + while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { //( * _lastSlot )->~vector(); //TODO: placement new - delete(* _lastSlot); - judy_del(_judyarray); + delete( * _lastSlot ); + judy_del( _judyarray ); } } - vector *getLastValue() - { - assert(_lastSlot); + vector * getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(vector *value) - { - assert(_lastSlot); + void setLastValue( vector * value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } @@ -104,11 +96,10 @@ class judyL2Array // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert(JudyKey key, JudyValue value) - { - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { - if(!(* _lastSlot)) { + bool insert( JudyKey key, JudyValue value ) { + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -118,7 +109,7 @@ class judyL2Array * also use placement new in the other insert function, below */ } - (* _lastSlot)->push_back(value); + ( * _lastSlot )->push_back( value ); _success = true; } else { _success = false; @@ -130,19 +121,18 @@ class judyL2Array * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert(JudyKey key, const vector &values, bool overwrite = false) - { - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { - if(!(* _lastSlot)) { + bool insert( JudyKey key, const vector & values, bool overwrite = false ) { + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if(overwrite) { - (* _lastSlot)->clear(); + } else if( overwrite ) { + ( * _lastSlot )->clear(); } - std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); + std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); _success = true; } else { _success = false; @@ -152,17 +142,15 @@ class judyL2Array /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter(JudyKey key) - { - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + const cpair atOrAfter( JudyKey key ) { + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector *find(JudyKey key) - { - _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if((_lastSlot) && (* _lastSlot)) { + cvector * find( JudyKey key ) { + _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( ( _lastSlot ) && ( * _lastSlot ) ) { _success = true; return * _lastSlot; } else { @@ -172,10 +160,9 @@ class judyL2Array } /// retrieve the key-value pair for the most recent judy query. - inline const cpair &mostRecentPair() - { - judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); - if(_lastSlot) { + inline const cpair & mostRecentPair() { + judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { @@ -187,31 +174,27 @@ class judyL2Array } /// retrieve the first key-value pair in the array - const cpair &begin() - { + const cpair & begin() { JudyKey key = 0; - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) &key, 0); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair &end() - { - _lastSlot = (vector **) judy_end(_judyarray); + const cpair & end() { + _lastSlot = ( vector ** ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next string in the array. - const cpair &next() - { - _lastSlot = (vector **) judy_nxt(_judyarray); + const cpair & next() { + _lastSlot = ( vector ** ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev string in the array. - const cpair &previous() - { - _lastSlot = (vector **) judy_prv(_judyarray); + const cpair & previous() { + _lastSlot = ( vector ** ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -219,12 +202,11 @@ class judyL2Array * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(JudyKey key) - { - if(0 != (_lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size))) { + bool removeEntry( JudyKey key ) { + if( 0 != ( _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = (vector **) judy_del(_judyarray); + _lastSlot = ( vector ** ) judy_del( _judyarray ); return true; } else { return false; @@ -232,10 +214,9 @@ class judyL2Array } /// true if the array is empty - bool isEmpty() - { + bool isEmpty() { JudyKey key = 0; - return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); } }; #endif //JUDYL2ARRAY_H diff --git a/src/base/judy/src/judyLArray.h b/src/base/judy/src/judyLArray.h index a70e787c7..b78dc0bb9 100644 --- a/src/base/judy/src/judyLArray.h +++ b/src/base/judy/src/judyLArray.h @@ -28,64 +28,56 @@ struct judylKVpair { * \param JudyValue the type of the value */ template< typename JudyKey, typename JudyValue > -class judyLArray -{ +class judyLArray { public: typedef judylKVpair< JudyKey, JudyValue > pair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxLevels, _depth; - JudyValue *_lastSlot; + JudyValue * _lastSlot; JudyKey _buff[1]; bool _success; pair _kv; public: - 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!"); - _judyarray = judy_open(_maxLevels, _depth); + 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!" ); + _judyarray = judy_open( _maxLevels, _depth ); _buff[0] = 0; } - explicit judyLArray(const judyLArray< JudyKey, JudyValue > &other): _maxLevels(other._maxLevels), - _depth(other._depth), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyLArray( const judyLArray< JudyKey, JudyValue > & other ): _maxLevels( other._maxLevels ), + _depth( other._depth ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff[0] = other._buff[0]; - find(*_buff); //set _lastSlot + find( *_buff ); //set _lastSlot } - ~judyLArray() - { - judy_close(_judyarray); + ~judyLArray() { + judy_close( _judyarray ); } - void clear(bool deleteContents = false) - { + void clear( bool deleteContents = false ) { JudyKey key = 0; - while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0))) { - if(deleteContents) { + while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) { + if( deleteContents ) { delete *_lastSlot; } - judy_del(_judyarray); + judy_del( _judyarray ); } } - JudyValue getLastValue() - { - assert(_lastSlot); + JudyValue getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(JudyValue value) - { - assert(_lastSlot); + void setLastValue( JudyValue value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } //TODO @@ -93,11 +85,10 @@ class judyLArray // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert(JudyKey key, JudyValue value) - { - assert(value != 0); - _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { + bool insert( JudyKey key, JudyValue value ) { + assert( value != 0 ); + _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { *_lastSlot = value; _success = true; } else { @@ -108,17 +99,15 @@ class judyLArray /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter(JudyKey key) - { - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); + const pair atOrAfter( JudyKey key ) { + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find(JudyKey key) - { - _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size); - if(_lastSlot) { + JudyValue find( JudyKey key ) { + _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ); + if( _lastSlot ) { _success = true; return *_lastSlot; } else { @@ -128,14 +117,13 @@ class judyLArray } /// retrieve the key-value pair for the most recent judy query. - inline const pair &mostRecentPair() - { - judy_key(_judyarray, (unsigned char *) _buff, _depth * JUDY_key_size); - if(_lastSlot) { + inline const pair & mostRecentPair() { + judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size ); + if( _lastSlot ) { _kv.value = *_lastSlot; _success = true; } else { - _kv.value = (JudyValue) 0; + _kv.value = ( JudyValue ) 0; _success = false; } _kv.key = _buff[0]; @@ -143,31 +131,27 @@ class judyLArray } /// retrieve the first key-value pair in the array - const pair &begin() - { + const pair & begin() { JudyKey key = 0; - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) &key, 0); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair &end() - { - _lastSlot = (JudyValue *) judy_end(_judyarray); + const pair & end() { + _lastSlot = ( JudyValue * ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair &next() - { - _lastSlot = (JudyValue *) judy_nxt(_judyarray); + const pair & next() { + _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair &previous() - { - _lastSlot = (JudyValue *) judy_prv(_judyarray); + const pair & previous() { + _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -175,10 +159,9 @@ class judyLArray * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(JudyKey *key) - { - if(judy_slot(_judyarray, key, _depth * JUDY_key_size)) { - _lastSlot = (JudyValue *) judy_del(_judyarray); + bool removeEntry( JudyKey * key ) { + if( judy_slot( _judyarray, key, _depth * JUDY_key_size ) ) { + _lastSlot = ( JudyValue * ) judy_del( _judyarray ); return true; } else { return false; @@ -186,10 +169,9 @@ class judyLArray } /// true if the array is empty - bool isEmpty() - { + bool isEmpty() { JudyKey key = 0; - return ((judy_strt(_judyarray, (const unsigned char *) &key, _depth * JUDY_key_size)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) &key, _depth * JUDY_key_size ) ) ? false : true ); } }; #endif //JUDYLARRAY_H diff --git a/src/base/judy/src/judyS2Array.h b/src/base/judy/src/judyS2Array.h index 421c310f0..726a6449a 100644 --- a/src/base/judy/src/judyS2Array.h +++ b/src/base/judy/src/judyS2Array.h @@ -19,7 +19,7 @@ template< typename JudyValue > struct judys2KVpair { - unsigned char *key; + unsigned char * key; JudyValue value; }; @@ -28,70 +28,62 @@ struct judys2KVpair { * \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. */ template< typename JudyValue > -class judyS2Array -{ +class judyS2Array { public: typedef std::vector< JudyValue > vector; typedef const vector cvector; typedef judys2KVpair< vector * > pair; typedef judys2KVpair< cvector * > cpair; protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxKeyLen; - vector **_lastSlot; - unsigned char *_buff; + vector ** _lastSlot; + unsigned char * _buff; bool _success; cpair kv; public: - judyS2Array(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _lastSlot(0), _success(true) - { - _judyarray = judy_open(_maxKeyLen, 0); + judyS2Array( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _lastSlot( 0 ), _success( true ) { + _judyarray = judy_open( _maxKeyLen, 0 ); _buff = new unsigned char[_maxKeyLen]; - assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); + assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); } - explicit judyS2Array(const judyS2Array< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judyS2Array( const judyS2Array< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff = new unsigned char[_maxKeyLen]; - strncpy(_buff, other._buff, _maxKeyLen); + strncpy( _buff, other._buff, _maxKeyLen ); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find(_buff); //set _lastSlot + find( _buff ); //set _lastSlot } /// calls clear, so should be safe to call at any point - ~judyS2Array() - { + ~judyS2Array() { clear(); - judy_close(_judyarray); + judy_close( _judyarray ); delete[] _buff; } /// delete all vectors and empty the array - void clear() - { + void clear() { _buff[0] = '\0'; - while(0 != (_lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { + while( 0 != ( _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { //( * _lastSlot )->~vector(); //TODO: placement new - delete(* _lastSlot); - judy_del(_judyarray); + delete( * _lastSlot ); + judy_del( _judyarray ); } } - vector *getLastValue() - { - assert(_lastSlot); + vector * getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(vector *value) - { - assert(_lastSlot); + void setLastValue( vector * value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } @@ -105,17 +97,16 @@ class judyS2Array // void *judy_data (Judy *judy, unsigned int amt); /// insert value into the vector for key. - bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { - if(!(* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * vector * n = judy_data( _judyarray, sizeof( std::vector < JudyValue > ) ); @@ -125,7 +116,7 @@ class judyS2Array * also use placement new in the other insert function, below */ } - (* _lastSlot)->push_back(value); + ( * _lastSlot )->push_back( value ); _success = true; } else { _success = false; @@ -137,25 +128,24 @@ class judyS2Array * this never simply re-uses the pointer to the given vector because * that would mean that two keys could have the same value (pointer). */ - bool insert(const char *key, const vector &values, unsigned int keyLen = 0, bool overwrite = false) - { - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, const vector & values, unsigned int keyLen = 0, bool overwrite = false ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { - if(!(* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { + if( !( * _lastSlot ) ) { * _lastSlot = new vector; /* TODO store vectors inside judy with placement new * (see other insert(), above) */ - } else if(overwrite) { - (* _lastSlot)->clear(); + } else if( overwrite ) { + ( * _lastSlot )->clear(); } - std::copy(values.begin(), values.end(), std::back_inserter< vector >((** _lastSlot))); + std::copy( values.begin(), values.end(), std::back_inserter< vector >( ( ** _lastSlot ) ) ); _success = true; } else { _success = false; @@ -165,29 +155,27 @@ class judyS2Array /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const cpair atOrAfter(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + const cpair atOrAfter( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *)key, keyLen); + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - cvector *find(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + cvector * find( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (vector **) judy_slot(_judyarray, (const unsigned char *) key, keyLen); - if((_lastSlot) && (* _lastSlot)) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( vector ** ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); + if( ( _lastSlot ) && ( * _lastSlot ) ) { _success = true; return * _lastSlot; } else { @@ -197,10 +185,9 @@ class judyS2Array } /// retrieve the key-value pair for the most recent judy query. - inline const cpair &mostRecentPair() - { - judy_key(_judyarray, _buff, _maxKeyLen); - if(_lastSlot) { + inline const cpair & mostRecentPair() { + judy_key( _judyarray, _buff, _maxKeyLen ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { @@ -212,31 +199,27 @@ class judyS2Array } /// retrieve the first key-value pair in the array - const cpair &begin() - { + const cpair & begin() { _buff[0] = '\0'; - _lastSlot = (vector **) judy_strt(_judyarray, (const unsigned char *) _buff, 0); + _lastSlot = ( vector ** ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const cpair &end() - { - _lastSlot = (vector **) judy_end(_judyarray); + const cpair & end() { + _lastSlot = ( vector ** ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const cpair &next() - { - _lastSlot = (vector **) judy_nxt(_judyarray); + const cpair & next() { + _lastSlot = ( vector ** ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const cpair &previous() - { - _lastSlot = (vector **) judy_prv(_judyarray); + const cpair & previous() { + _lastSlot = ( vector ** ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -244,12 +227,11 @@ class judyS2Array * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(const char *key) - { - if(0 != (judy_slot(_judyarray, (const unsigned char *)key, strlen(key)))) { + bool removeEntry( const char * key ) { + if( 0 != ( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) ) { // _lastSlot->~vector(); //for use with placement new delete _lastSlot; - _lastSlot = (vector **) judy_del(_judyarray); + _lastSlot = ( vector ** ) judy_del( _judyarray ); return true; } else { return false; @@ -257,10 +239,9 @@ class judyS2Array } ///return true if the array is empty - bool isEmpty() - { + bool isEmpty() { _buff[0] = 0; - return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); } }; #endif //JUDYS2ARRAY_H diff --git a/src/base/judy/src/judySArray.h b/src/base/judy/src/judySArray.h index 2a6079a2c..db75ec91c 100644 --- a/src/base/judy/src/judySArray.h +++ b/src/base/judy/src/judySArray.h @@ -17,64 +17,56 @@ template< typename JudyValue > struct judysKVpair { - unsigned char *key; + unsigned char * key; JudyValue value; }; template< typename JudyValue > -class judySArray -{ +class judySArray { protected: - Judy *_judyarray; + Judy * _judyarray; unsigned int _maxKeyLen; - JudyValue *_lastSlot; - unsigned char *_buff; + JudyValue * _lastSlot; + unsigned char * _buff; bool _success; public: typedef judysKVpair< JudyValue > pair; - judySArray(unsigned int maxKeyLen): _maxKeyLen(maxKeyLen), _success(true) - { - _judyarray = judy_open(_maxKeyLen, 0); + judySArray( unsigned int maxKeyLen ): _maxKeyLen( maxKeyLen ), _success( true ) { + _judyarray = judy_open( _maxKeyLen, 0 ); _buff = new unsigned char[_maxKeyLen]; - assert(sizeof(JudyValue) == sizeof(this) && "JudyValue *must* be the same size as a pointer!"); + assert( sizeof( JudyValue ) == sizeof( this ) && "JudyValue *must* be the same size as a pointer!" ); } - explicit judySArray(const judySArray< JudyValue > &other): _maxKeyLen(other._maxKeyLen), _success(other._success) - { - _judyarray = judy_clone(other._judyarray); + explicit judySArray( const judySArray< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) { + _judyarray = judy_clone( other._judyarray ); _buff = new unsigned char[_maxKeyLen]; - strncpy(_buff, other._buff, _maxKeyLen); + strncpy( _buff, other._buff, _maxKeyLen ); _buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so - find(_buff); //set _lastSlot + find( _buff ); //set _lastSlot } - ~judySArray() - { - judy_close(_judyarray); + ~judySArray() { + judy_close( _judyarray ); delete[] _buff; } - void clear() - { + void clear() { _buff[0] = '\0'; - while(0 != (_lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0))) { - judy_del(_judyarray); + while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ) { + judy_del( _judyarray ); } } - JudyValue getLastValue() - { - assert(_lastSlot); + JudyValue getLastValue() { + assert( _lastSlot ); return &_lastSlot; } - void setLastValue(JudyValue value) - { - assert(_lastSlot); + void setLastValue( JudyValue value ) { + assert( _lastSlot ); &_lastSlot = value; } - bool success() - { + bool success() { return _success; } //TODO @@ -82,17 +74,16 @@ class judySArray // void *judy_data (Judy *judy, unsigned int amt); /// insert or overwrite value for key - bool insert(const char *key, JudyValue value, unsigned int keyLen = 0) - { - assert(value != 0); - if(keyLen == 0) { - keyLen = strlen(key); + bool insert( const char * key, JudyValue value, unsigned int keyLen = 0 ) { + assert( value != 0 ); + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_cell(_judyarray, (const unsigned char *)key, keyLen); - if(_lastSlot) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_cell( _judyarray, ( const unsigned char * )key, keyLen ); + if( _lastSlot ) { *_lastSlot = value; _success = true; } else { @@ -103,29 +94,27 @@ class judySArray /// retrieve the cell pointer greater than or equal to given key /// NOTE what about an atOrBefore function? - const pair atOrAfter(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + const pair atOrAfter( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *)key, keyLen); + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * )key, keyLen ); return mostRecentPair(); } /// retrieve the cell pointer, or return NULL for a given key. - JudyValue find(const char *key, unsigned int keyLen = 0) - { - if(keyLen == 0) { - keyLen = strlen(key); + JudyValue find( const char * key, unsigned int keyLen = 0 ) { + if( keyLen == 0 ) { + keyLen = strlen( key ); } else { - assert(keyLen == strlen(key)); + assert( keyLen == strlen( key ) ); } - assert(keyLen <= _maxKeyLen); - _lastSlot = (JudyValue *) judy_slot(_judyarray, (const unsigned char *) key, keyLen); - if(_lastSlot) { + assert( keyLen <= _maxKeyLen ); + _lastSlot = ( JudyValue * ) judy_slot( _judyarray, ( const unsigned char * ) key, keyLen ); + if( _lastSlot ) { _success = true; return *_lastSlot; } else { @@ -135,15 +124,14 @@ class judySArray } /// retrieve the key-value pair for the most recent judy query. - inline const pair mostRecentPair() - { + inline const pair mostRecentPair() { pair kv; - judy_key(_judyarray, _buff, _maxKeyLen); - if(_lastSlot) { + judy_key( _judyarray, _buff, _maxKeyLen ); + if( _lastSlot ) { kv.value = *_lastSlot; _success = true; } else { - kv.value = (JudyValue) 0; + kv.value = ( JudyValue ) 0; _success = false; } kv.key = _buff; @@ -151,31 +139,27 @@ class judySArray } /// retrieve the first key-value pair in the array - const pair &begin() - { + const pair & begin() { _buff[0] = '\0'; - _lastSlot = (JudyValue *) judy_strt(_judyarray, (const unsigned char *) _buff, 0); + _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ); return mostRecentPair(); } /// retrieve the last key-value pair in the array - const pair &end() - { - _lastSlot = (JudyValue *) judy_end(_judyarray); + const pair & end() { + _lastSlot = ( JudyValue * ) judy_end( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the next key in the array. - const pair &next() - { - _lastSlot = (JudyValue *) judy_nxt(_judyarray); + const pair & next() { + _lastSlot = ( JudyValue * ) judy_nxt( _judyarray ); return mostRecentPair(); } /// retrieve the key-value pair for the prev key in the array. - const pair &previous() - { - _lastSlot = (JudyValue *) judy_prv(_judyarray); + const pair & previous() { + _lastSlot = ( JudyValue * ) judy_prv( _judyarray ); return mostRecentPair(); } @@ -183,10 +167,9 @@ class judySArray * getLastValue() will return the entry before the one that was deleted * \sa isEmpty() */ - bool removeEntry(const char *key) - { - if(judy_slot(_judyarray, (const unsigned char *)key, strlen(key))) { - _lastSlot = (JudyValue *) judy_del(_judyarray); + bool removeEntry( const char * key ) { + if( judy_slot( _judyarray, ( const unsigned char * )key, strlen( key ) ) ) { + _lastSlot = ( JudyValue * ) judy_del( _judyarray ); return true; } else { return false; @@ -194,10 +177,9 @@ class judySArray } ///return true if the array is empty - bool isEmpty() - { + bool isEmpty() { _buff[0] = 0; - return ((judy_strt(_judyarray, (const unsigned char *) _buff, 0)) ? false : true); + return ( ( judy_strt( _judyarray, ( const unsigned char * ) _buff, 0 ) ) ? false : true ); } }; #endif //JUDYSARRAY_H diff --git a/src/base/judy/test/hexSort.c b/src/base/judy/test/hexSort.c index 9d9523af8..0d770d752 100644 --- a/src/base/judy/test/hexSort.c +++ b/src/base/judy/test/hexSort.c @@ -30,96 +30,95 @@ unsigned int MaxMem = 0; On linux, a 1M-line file can be created with the following: hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >in-file */ -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { unsigned char buff[1024]; JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; + JudySlot * cell; + FILE * in, *out; + void * judy; unsigned int len; unsigned int idx; - if(argc > 1) { - in = fopen(argv[1], "rb"); + if( argc > 1 ) { + in = fopen( argv[1], "rb" ); } else { in = stdin; } - if(argc > 2) { - out = fopen(argv[2], "wb"); + if( argc > 2 ) { + out = fopen( argv[2], "wb" ); } else { out = stdout; } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - if(!in) { - fprintf(stderr, "unable to open input file\n"); + if( !in ) { + fprintf( stderr, "unable to open input file\n" ); } - if(!out) { - fprintf(stderr, "unable to open output file\n"); + if( !out ) { + fprintf( stderr, "unable to open output file\n" ); } - PennyMerge = (unsigned long long)PennyLine * PennyRecs; + PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - judy = judy_open(1024, 16 / JUDY_key_size); + judy = judy_open( 1024, 16 / JUDY_key_size ); - while(fgets((char *)buff, sizeof(buff), in)) { + while( fgets( ( char * )buff, sizeof( buff ), in ) ) { judyvalue key[16 / JUDY_key_size]; - if(len = strlen((const char *)buff)) { + if( len = strlen( ( const char * )buff ) ) { buff[--len] = 0; // remove LF } #if JUDY_key_size == 4 - key[3] = strtoul(buff + 24, NULL, 16); + key[3] = strtoul( buff + 24, NULL, 16 ); buff[24] = 0; - key[2] = strtoul(buff + 16, NULL, 16); + key[2] = strtoul( buff + 16, NULL, 16 ); buff[16] = 0; - key[1] = strtoul(buff + 8, NULL, 16); + key[1] = strtoul( buff + 8, NULL, 16 ); buff[8] = 0; - key[0] = strtoul(buff, NULL, 16); + key[0] = strtoul( buff, NULL, 16 ); #else - key[1] = strtoull(buff + 16, NULL, 16); + key[1] = strtoull( buff + 16, NULL, 16 ); buff[16] = 0; - key[0] = strtoull(buff, NULL, 16); + key[0] = strtoull( buff, NULL, 16 ); #endif - *(judy_cell(judy, (void *)key, 0)) += 1; // count instances of string + *( judy_cell( judy, ( void * )key, 0 ) ) += 1; // count instances of string max++; } - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); + fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { + if( cell ) do { judyvalue key[16 / JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates + len = judy_key( judy, ( void * )key, 0 ); + for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates #if JUDY_key_size == 4 - fprintf(out, "%.8X", key[0]); - fprintf(out, "%.8X", key[1]); - fprintf(out, "%.8X", key[2]); - fprintf(out, "%.8X", key[3]); + fprintf( out, "%.8X", key[0] ); + fprintf( out, "%.8X", key[1] ); + fprintf( out, "%.8X", key[2] ); + fprintf( out, "%.8X", key[3] ); #else - fprintf(out, "%.16llX", key[0]); - fprintf(out, "%.16llX", key[1]); + fprintf( out, "%.16llX", key[0] ); + fprintf( out, "%.16llX", key[1] ); #endif - fputc('\n', out); + fputc( '\n', out ); } - } while(cell = judy_nxt(judy)); + } while( cell = judy_nxt( judy ) ); #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) + if( cell = judy_prv( judy ) ) do { max -= *cell; - } while(cell = judy_del(judy)); + } while( cell = judy_del( judy ) ); - assert(max == 0); + assert( max == 0 ); #endif - judy_close(judy); + judy_close( judy ); return 0; } diff --git a/src/base/judy/test/judyL2test.cc b/src/base/judy/test/judyL2test.cc index fdf16e58e..20ef559a9 100644 --- a/src/base/judy/test/judyL2test.cc +++ b/src/base/judy/test/judyL2test.cc @@ -5,14 +5,13 @@ #include "judyL2Array.h" typedef judyL2Array< uint64_t, uint64_t > jl2a; -bool testFind(jl2a &j, uint64_t key, unsigned int count) -{ - jl2a::cvector *v = j.find(key); +bool testFind( jl2a & j, uint64_t key, unsigned int count ) { + jl2a::cvector * v = j.find( key ); std::cout << "find: key " << key << " ..." << std::endl; - if(count > 0) { - if(!v || !j.success() || (v->size() != count)) { + if( count > 0 ) { + if( !v || !j.success() || ( v->size() != count ) ) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if(v) { + if( v ) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -21,13 +20,13 @@ bool testFind(jl2a &j, uint64_t key, unsigned int count) // note - this doesn't verify that the right keys are returned, just the right number! jl2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for(; it != v->end(); it++) { + for( ; it != v->end(); it++ ) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if(v || j.success()) { + if( v || j.success() ) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -37,38 +36,37 @@ bool testFind(jl2a &j, uint64_t key, unsigned int count) return true; } -int main() -{ +int main() { bool pass = true; jl2a jl; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); // std::cout << "size of judyL2Array: " << sizeof( jl ) << std::endl; - jl.insert(5, 12); - jl.insert(6, 2); - jl.insert(7, 312); - jl.insert(11, 412); - jl.insert(7, 313); - jl2a::cpair kv = jl.atOrAfter(4); + jl.insert( 5, 12 ); + jl.insert( 6, 2 ); + jl.insert( 7, 312 ); + jl.insert( 11, 412 ); + jl.insert( 7, 313 ); + jl2a::cpair kv = jl.atOrAfter( 4 ); std::cout << "atOrAfter test ..." << std::endl; - if(kv.value != 0 && jl.success()) { - std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; + if( kv.value != 0 && jl.success() ) { + std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind(jl, 8, 0); - pass &= testFind(jl, 11, 1); - pass &= testFind(jl, 7, 2); + pass &= testFind( jl, 8, 0 ); + pass &= testFind( jl, 11, 1 ); + pass &= testFind( jl, 7, 2 ); jl.clear(); //TODO test all of judyL2Array - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/judyLtest.cc b/src/base/judy/test/judyLtest.cc index 81815d4d5..01ae3d5d7 100644 --- a/src/base/judy/test/judyLtest.cc +++ b/src/base/judy/test/judyLtest.cc @@ -4,31 +4,30 @@ #include "judyLArray.h" -int main() -{ - std::cout.setf(std::ios::boolalpha); +int main() { + std::cout.setf( std::ios::boolalpha ); judyLArray< uint64_t, uint64_t > jl; - std::cout << "size of judyLArray: " << sizeof(jl) << std::endl; - jl.insert(5, 12); - jl.insert(6, 2); - jl.insert(7, 312); - jl.insert(8, 412); - judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter(4); + std::cout << "size of judyLArray: " << sizeof( jl ) << std::endl; + jl.insert( 5, 12 ); + jl.insert( 6, 2 ); + jl.insert( 7, 312 ); + jl.insert( 8, 412 ); + judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter( 4 ); std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = jl.find(11); - if(v != 0 || jl.success()) { + long v = jl.find( 11 ); + if( v != 0 || jl.success() ) { std::cout << "find: false positive - v: " << v << " success: " << jl.success() << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - v = jl.find(7); - if(v != 312 || !jl.success()) { + v = jl.find( 7 ); + if( v != 312 || !jl.success() ) { std::cout << "find: false negative - v: " << v << " success: " << jl.success() << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } jl.clear(); //TODO test all of judyLArray - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } \ No newline at end of file diff --git a/src/base/judy/test/judyS2test.cc b/src/base/judy/test/judyS2test.cc index 4e0678cd7..ec25f960b 100644 --- a/src/base/judy/test/judyS2test.cc +++ b/src/base/judy/test/judyS2test.cc @@ -6,14 +6,13 @@ typedef judyS2Array< uint64_t > js2a; -bool testFind(js2a &j, const char *key, unsigned int count) -{ - js2a::cvector *v = j.find(key); +bool testFind( js2a & j, const char * key, unsigned int count ) { + js2a::cvector * v = j.find( key ); std::cout << "find: key " << key << " ..." << std::endl; - if(count > 0) { - if(!v || !j.success() || (v->size() != count)) { + if( count > 0 ) { + if( !v || !j.success() || ( v->size() != count ) ) { std::cout << " false negative - v: " << v << " success: " << j.success(); - if(v) { + if( v ) { std::cout << " expected count: " << count << " actual: " << v->size(); } std::cout << std::endl; @@ -22,13 +21,13 @@ bool testFind(js2a &j, const char *key, unsigned int count) // note - this doesn't verify that the right keys are returned, just the right number! js2a::vector::const_iterator it = v->begin(); std::cout << " correct number of values -"; - for(; it != v->end(); it++) { + for( ; it != v->end(); it++ ) { std::cout << " " << *it; } std::cout << std::endl; } } else { - if(v || j.success()) { + if( v || j.success() ) { std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; return false; } else { @@ -38,40 +37,39 @@ bool testFind(js2a &j, const char *key, unsigned int count) return true; } -int main() -{ +int main() { bool pass = true; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); - js2a js(255); - js.insert("blah", 1234); - js.insert("bah", 124); - js.insert("blh", 123); - js.insert("blh", 4123); - js.insert("bla", 134); - js.insert("bh", 234); + js2a js( 255 ); + js.insert( "blah", 1234 ); + js.insert( "bah", 124 ); + js.insert( "blh", 123 ); + js.insert( "blh", 4123 ); + js.insert( "bla", 134 ); + js.insert( "bh", 234 ); - js2a::cpair kv = js.atOrAfter("ab"); + js2a::cpair kv = js.atOrAfter( "ab" ); std::cout << "atOrAfter test ..." << std::endl; - if(kv.value != 0 && js.success()) { - std::cout << " key " << kv.key << " value " << kv.value->at(0) << std::endl; + if( kv.value != 0 && js.success() ) { + std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; } else { std::cout << " failed" << std::endl; pass = false; } - pass &= testFind(js, "sdafsd", 0); - pass &= testFind(js, "bah", 1); - pass &= testFind(js, "blh", 2); + pass &= testFind( js, "sdafsd", 0 ); + pass &= testFind( js, "bah", 1 ); + pass &= testFind( js, "blh", 2 ); js.clear(); //TODO test all of judyS2Array - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/judyStest.cc b/src/base/judy/test/judyStest.cc index f6fc74ffa..3d620b015 100644 --- a/src/base/judy/test/judyStest.cc +++ b/src/base/judy/test/judyStest.cc @@ -4,41 +4,40 @@ #include "judySArray.h" -int main() -{ +int main() { bool pass = true; - std::cout.setf(std::ios::boolalpha); + std::cout.setf( std::ios::boolalpha ); - judySArray< uint64_t > js(255); - js.insert("blah", 1234); - js.insert("bah", 124); - js.insert("blh", 123); - js.insert("bla", 134); - js.insert("bh", 234); + judySArray< uint64_t > js( 255 ); + js.insert( "blah", 1234 ); + js.insert( "bah", 124 ); + js.insert( "blh", 123 ); + js.insert( "bla", 134 ); + js.insert( "bh", 234 ); - judySArray< uint64_t >::pair kv = js.atOrAfter("ab"); + judySArray< uint64_t >::pair kv = js.atOrAfter( "ab" ); //TODO if()... std::cout << "k " << kv.key << " v " << kv.value << std::endl; - long v = js.find("sdafsd"); - if(v != 0 || js.success()) { + long v = js.find( "sdafsd" ); + if( v != 0 || js.success() ) { std::cout << "find: false positive - v: " << v << " success: " << js.success() << std::endl; pass = false; } - v = js.find("bah"); - if(v != 124 || !js.success()) { + v = js.find( "bah" ); + if( v != 124 || !js.success() ) { std::cout << "find: false negative - v: " << v << " success: " << js.success() << std::endl; pass = false; } //TODO test all of judySArray - if(pass) { + if( pass ) { std::cout << "All tests passed." << std::endl; - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } else { std::cout << "At least one test failed." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } \ No newline at end of file diff --git a/src/base/judy/test/pennySort.c b/src/base/judy/test/pennySort.c index 0bc3a4f42..a279b1a70 100644 --- a/src/base/judy/test/pennySort.c +++ b/src/base/judy/test/pennySort.c @@ -40,17 +40,16 @@ unsigned int MaxMem = 0; // Also, the file to search judy is hardcoded to skew1_1. -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { unsigned char buff[1024]; JudySlot max = 0; - JudySlot *cell; - FILE *in, *out; - void *judy; + JudySlot * cell; + FILE * in, *out; + void * judy; unsigned int len; unsigned int idx; #ifdef ASKITIS - char *askitis; + char * askitis; int prev, off; float insert_real_time = 0.0; float search_real_time = 0.0; @@ -62,176 +61,176 @@ int main(int argc, char **argv) #endif #endif - if(argc > 1) { - in = fopen(argv[1], "rb"); + if( argc > 1 ) { + in = fopen( argv[1], "rb" ); } else { in = stdin; } - if(argc > 2) { - out = fopen(argv[2], "wb"); + if( argc > 2 ) { + out = fopen( argv[2], "wb" ); } else { out = stdout; } - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - if(!in) { - fprintf(stderr, "unable to open input file\n"); + if( !in ) { + fprintf( stderr, "unable to open input file\n" ); } - if(!out) { - fprintf(stderr, "unable to open output file\n"); + if( !out ) { + fprintf( stderr, "unable to open output file\n" ); } - if(argc > 6) { - PennyRecs = atoi(argv[6]); + if( argc > 6 ) { + PennyRecs = atoi( argv[6] ); } - if(argc > 5) { - PennyOff = atoi(argv[5]); + if( argc > 5 ) { + PennyOff = atoi( argv[5] ); } - if(argc > 4) { - PennyLine = atoi(argv[4]); + if( argc > 4 ) { + PennyLine = atoi( argv[4] ); } - PennyMerge = (unsigned long long)PennyLine * PennyRecs; + PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - if(argc > 3) { - PennyKey = atoi(argv[3]); - sort(in, argv[2]); - return merge(out, argv[2]); + if( argc > 3 ) { + PennyKey = atoi( argv[3] ); + sort( in, argv[2] ); + return merge( out, argv[2] ); } #ifdef ASKITIS - judy = judy_open(1024, 0); + judy = judy_open( 1024, 0 ); // build judy array - size = lseek(fileno(in), 0L, 2); - askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + size = lseek( fileno( in ), 0L, 2 ); + askitis = malloc( size ); + lseek( fileno( in ), 0L, 0 ); + read( fileno( in ), askitis, size ); prev = 0; // naskitis.com: // Start the timer. #if !defined(_WIN32) - gettimeofday(&start, NULL); + gettimeofday( &start, NULL ); #else - time(start); + time( start ); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *(judy_cell(judy, askitis + prev, off - prev)) += 1; // count instances of string + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *( judy_cell( judy, askitis + prev, off - prev ) ) += 1; // count instances of string prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to insert the strings into the judy array. #if !defined(_WIN32) - gettimeofday(&stop, NULL); + gettimeofday( &stop, NULL ); - insert_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 * (stop.tv_usec - start.tv_usec); + insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * ( stop.tv_usec - start.tv_usec ); insert_real_time = insert_real_time / 1000.0; #else - time(stop); + time( stop ); insert_real_time = *stop - *start; #endif // naskitis.com: // Free the input buffer used to store the first file. We must do this before we get the process size below. - free(askitis); - fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); + free( askitis ); + fprintf( stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time ); + fprintf( stderr, "%-20s %d\n", "Words:", Words ); + fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); + fprintf( stderr, "%-20s %d\n", "Found:", Found ); Words = 0; Inserts = 0; Found = 0; // search judy array - if(in = freopen("skew1_1", "rb", in)) { - size = lseek(fileno(in), 0L, 2); + if( in = freopen( "skew1_1", "rb", in ) ) { + size = lseek( fileno( in ), 0L, 2 ); } else { - exit(0); + exit( 0 ); } - askitis = malloc(size); - lseek(fileno(in), 0L, 0); - read(fileno(in), askitis, size); + askitis = malloc( size ); + lseek( fileno( in ), 0L, 0 ); + read( fileno( in ), askitis, size ); prev = 0; #if !defined(_WIN32) - gettimeofday(&start, NULL); + gettimeofday( &start, NULL ); #else - time(start); + time( start ); #endif - for(off = 0; off < size; off++) - if(askitis[off] == '\n') { - *judy_cell(judy, askitis + prev, off - prev) += 1; + for( off = 0; off < size; off++ ) + if( askitis[off] == '\n' ) { + *judy_cell( judy, askitis + prev, off - prev ) += 1; prev = off + 1; } // naskitis.com: // Stop the timer and do some math to compute the time required to search the judy array. #if !defined(_WIN32) - gettimeofday(&stop, NULL); - search_real_time = 1000.0 * (stop.tv_sec - start.tv_sec) + 0.001 - * (stop.tv_usec - start.tv_usec); + gettimeofday( &stop, NULL ); + search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 + * ( stop.tv_usec - start.tv_usec ); search_real_time = search_real_time / 1000.0; #else - time(stop); + time( stop ); search_real_time = *stop - *start; #endif // naskitis.com: // To do: report a count on the number of strings found. - fprintf(stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); - exit(0); + fprintf( stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", + "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time ); + fprintf( stderr, "%-20s %d\n", "Words:", Words ); + fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); + fprintf( stderr, "%-20s %d\n", "Found:", Found ); + exit( 0 ); #endif - judy = judy_open(1024, 0); + judy = judy_open( 1024, 0 ); - while(fgets((char *)buff, sizeof(buff), in)) { - if(len = strlen((const char *)buff)) { + while( fgets( ( char * )buff, sizeof( buff ), in ) ) { + if( len = strlen( ( const char * )buff ) ) { buff[--len] = 0; // remove LF } - *(judy_cell(judy, buff, len)) += 1; // count instances of string + *( judy_cell( judy, buff, len ) ) += 1; // count instances of string max++; } - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); + fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { - len = judy_key(judy, buff, sizeof(buff)); - for(idx = 0; idx < *cell; idx++) { // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); + if( cell ) do { + len = judy_key( judy, buff, sizeof( buff ) ); + for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates + fwrite( buff, len, 1, out ); + fputc( '\n', out ); } - } while(cell = judy_nxt(judy)); + } while( cell = judy_nxt( judy ) ); #if 0 // test deletion all the way to an empty tree - if(cell = judy_prv(judy)) + if( cell = judy_prv( judy ) ) do { max -= *cell; - } while(cell = judy_del(judy)); + } while( cell = judy_del( judy ) ); - assert(max == 0); + assert( max == 0 ); #endif - judy_close(judy); + judy_close( judy ); return 0; } diff --git a/src/base/judy/test/sort.c b/src/base/judy/test/sort.c index 53a460312..e483b92e0 100644 --- a/src/base/judy/test/sort.c +++ b/src/base/judy/test/sort.c @@ -24,7 +24,7 @@ // memory map input file and sort // define pennysort parameters -unsigned int PennyRecs = (4096 * 400); // records to sort to temp files +unsigned int PennyRecs = ( 4096 * 400 ); // records to sort to temp files unsigned int PennyLine = 100; // length of input record unsigned int PennyKey = 10; // length of input key unsigned int PennyOff = 0; // key offset in input record @@ -34,16 +34,15 @@ unsigned int PennyPasses; // number of intermediate files created unsigned int PennySortTime; // cpu time to run sort unsigned int PennyMergeTime; // cpu time to run merge -void sort(FILE *infile, char *outname) -{ +void sort( FILE * infile, char * outname ) { unsigned long long size, off, offset, part; - int ifd = fileno(infile); + int ifd = fileno( infile ); char filename[512]; - PennySort *line; - JudySlot *cell; - unsigned char *inbuff; - void *judy; - FILE *out; + PennySort * line; + JudySlot * cell; + unsigned char * inbuff; + void * judy; + FILE * out; #if defined(_WIN32) HANDLE hndl, fm; DWORD hiword; @@ -52,150 +51,149 @@ void sort(FILE *infile, char *outname) #else struct tms buff[1]; #endif - time_t start = time(NULL); + time_t start = time( NULL ); - if(PennyOff + PennyKey > PennyLine) { - fprintf(stderr, "Key Offset + Key Length > Record Length\n"), exit(1); + if( PennyOff + PennyKey > PennyLine ) { + fprintf( stderr, "Key Offset + Key Length > Record Length\n" ), exit( 1 ); } offset = 0; PennyPasses = 0; #if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize(hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if(!fm) { - fprintf(stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); + hndl = ( HANDLE )_get_osfhandle( ifd ); + size = GetFileSize( hndl, &hiword ); + fm = CreateFileMapping( hndl, NULL, PAGE_READONLY, hiword, ( DWORD )size, NULL ); + if( !fm ) { + fprintf( stderr, "CreateFileMapping error %d\n", GetLastError() ), exit( 1 ); } - size |= (unsigned long long)hiword << 32; + size |= ( unsigned long long )hiword << 32; #else - size = lseek(ifd, 0L, 2); + size = lseek( ifd, 0L, 2 ); #endif - while(offset < size) { + while( offset < size ) { #if defined(_WIN32) part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile(fm, FILE_MAP_READ, offset >> 32, offset, part); - if(!inbuff) { - fprintf(stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); + inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part ); + if( !inbuff ) { + fprintf( stderr, "MapViewOfFile error %d\n", GetLastError() ), exit( 1 ); } #else - inbuff = mmap(NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); + inbuff = mmap( NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset ); - if(inbuff == MAP_FAILED) { - fprintf(stderr, "mmap error %d\n", errno), exit(1); + if( inbuff == MAP_FAILED ) { + fprintf( stderr, "mmap error %d\n", errno ), exit( 1 ); } - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0) { - fprintf(stderr, "madvise error %d\n", errno); + if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL ) < 0 ) { + fprintf( stderr, "madvise error %d\n", errno ); } #endif - judy = judy_open(PennyKey, 0); + judy = judy_open( PennyKey, 0 ); off = 0; // build judy array from mapped input chunk - while(offset + off < size && off < PennyMerge) { - line = judy_data(judy, sizeof(PennySort)); - cell = judy_cell(judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; + while( offset + off < size && off < PennyMerge ) { + line = judy_data( judy, sizeof( PennySort ) ); + cell = judy_cell( judy, inbuff + off + PennyOff, PennyKey ); + line->next = *( void ** )cell; line->buff = inbuff + off; - *(PennySort **)cell = line; + *( PennySort ** )cell = line; off += PennyLine; } - sprintf(filename, "%s.%d", outname, PennyPasses); - out = fopen(filename, "wb"); - setvbuf(out, NULL, _IOFBF, 4096 * 1024); + sprintf( filename, "%s.%d", outname, PennyPasses ); + out = fopen( filename, "wb" ); + setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); #ifndef _WIN32 - if(madvise(inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0) { - fprintf(stderr, "madvise error %d\n", errno); + if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM ) < 0 ) { + fprintf( stderr, "madvise error %d\n", errno ); } #endif // write judy array in sorted order to temporary file - cell = judy_strt(judy, NULL, 0); + cell = judy_strt( judy, NULL, 0 ); - if(cell) do { - line = *(PennySort **)cell; + if( cell ) do { + line = *( PennySort ** )cell; do { - fwrite(line->buff, PennyLine, 1, out); - } while(line = line->next); - } while(cell = judy_nxt(judy)); + fwrite( line->buff, PennyLine, 1, out ); + } while( line = line->next ); + } while( cell = judy_nxt( judy ) ); #if defined(_WIN32) - UnmapViewOfFile(inbuff); + UnmapViewOfFile( inbuff ); #else - munmap(inbuff, PennyMerge); + munmap( inbuff, PennyMerge ); #endif - judy_close(judy); + judy_close( judy ); offset += off; - fflush(out); - fclose(out); + fflush( out ); + fclose( out ); PennyPasses++; } - fprintf(stderr, "End Sort %llu secs", (unsigned long long) time(NULL) - start); + fprintf( stderr, "End Sort %llu secs", ( unsigned long long ) time( NULL ) - start ); #if defined(_WIN32) - CloseHandle(fm); - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long *)user / 10000000; + CloseHandle( fm ); + GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); + PennySortTime = *( unsigned long long * )user / 10000000; #else - times(buff); + times( buff ); PennySortTime = buff->tms_utime / 100; #endif - fprintf(stderr, " Cpu %d\n", PennySortTime); + fprintf( stderr, " Cpu %d\n", PennySortTime ); } -int merge(FILE *out, char *outname) -{ - time_t start = time(NULL); +int merge( FILE * out, char * outname ) { + time_t start = time( NULL ); char filename[512]; - JudySlot *cell; + JudySlot * cell; unsigned int nxt, idx; - unsigned char **line; - unsigned int *next; - void *judy; - FILE **in; + unsigned char ** line; + unsigned int * next; + void * judy; + FILE ** in; - next = calloc(PennyPasses + 1, sizeof(unsigned int)); - line = calloc(PennyPasses, sizeof(void *)); - in = calloc(PennyPasses, sizeof(void *)); + next = calloc( PennyPasses + 1, sizeof( unsigned int ) ); + line = calloc( PennyPasses, sizeof( void * ) ); + in = calloc( PennyPasses, sizeof( void * ) ); - judy = judy_open(PennyKey, 0); + judy = judy_open( PennyKey, 0 ); // initialize merge with one record from each temp file - for(idx = 0; idx < PennyPasses; idx++) { - sprintf(filename, "%s.%d", outname, idx); - in[idx] = fopen(filename, "rb"); - line[idx] = malloc(PennyLine); - setvbuf(in[idx], NULL, _IOFBF, 4096 * 1024); - fread(line[idx], PennyLine, 1, in[idx]); - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; + for( idx = 0; idx < PennyPasses; idx++ ) { + sprintf( filename, "%s.%d", outname, idx ); + in[idx] = fopen( filename, "rb" ); + line[idx] = malloc( PennyLine ); + setvbuf( in[idx], NULL, _IOFBF, 4096 * 1024 ); + fread( line[idx], PennyLine, 1, in[idx] ); + cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); + next[idx + 1] = *( unsigned int * )cell; *cell = idx + 1; } // output records, replacing smallest each time - while(cell = judy_strt(judy, NULL, 0)) { - nxt = *(unsigned int *)cell; - judy_del(judy); + while( cell = judy_strt( judy, NULL, 0 ) ) { + nxt = *( unsigned int * )cell; + judy_del( judy ); // process duplicates - while(idx = nxt) { + while( idx = nxt ) { nxt = next[idx--]; - fwrite(line[idx], PennyLine, 1, out); + fwrite( line[idx], PennyLine, 1, out ); - if(fread(line[idx], PennyLine, 1, in[idx])) { - cell = judy_cell(judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; + if( fread( line[idx], PennyLine, 1, in[idx] ) ) { + cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); + next[idx + 1] = *( unsigned int * )cell; *cell = idx + 1; } else { next[idx + 1] = 0; @@ -203,33 +201,33 @@ int merge(FILE *out, char *outname) } } - for(idx = 0; idx < PennyPasses; idx++) { - fclose(in[idx]); - free(line[idx]); + for( idx = 0; idx < PennyPasses; idx++ ) { + fclose( in[idx] ); + free( line[idx] ); } - free(line); - free(next); - free(in); + free( line ); + free( next ); + free( in ); - fprintf(stderr, "End Merge %llu secs", (unsigned long long) time(NULL) - start); + fprintf( stderr, "End Merge %llu secs", ( unsigned long long ) time( NULL ) - start ); #ifdef _WIN32 { FILETIME dummy[1]; FILETIME user[1]; - GetProcessTimes(GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long *)user / 10000000; + GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); + PennyMergeTime = *( unsigned long long * )user / 10000000; } #else { struct tms buff[1]; - times(buff); + times( buff ); PennyMergeTime = buff->tms_utime / 100; } #endif - fprintf(stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close(judy); - fflush(out); - fclose(out); + fprintf( stderr, " Cpu %d\n", PennyMergeTime - PennySortTime ); + judy_close( judy ); + fflush( out ); + fclose( out ); return 0; } diff --git a/src/base/judy/test/sort.h b/src/base/judy/test/sort.h index f3f497e72..785e58d69 100644 --- a/src/base/judy/test/sort.h +++ b/src/base/judy/test/sort.h @@ -51,8 +51,8 @@ extern unsigned int PennyOff; extern unsigned long long PennyMerge; typedef struct { - void *buff; // record pointer in input file map - void *next; // duplicate chain + void * buff; // record pointer in input file map + void * next; // duplicate chain } PennySort; #endif //SORT_H \ No newline at end of file diff --git a/src/base/path2str.c b/src/base/path2str.c index a4f88ee3a..6f5aedd7c 100644 --- a/src/base/path2str.c +++ b/src/base/path2str.c @@ -6,22 +6,21 @@ /* for windows, rewrite backslashes in paths * that will be written to generated code */ -const char *path2str_fn(const char *fileMacro) -{ - static char *result = 0; +const char * path2str_fn( const char * fileMacro ) { + static char * result = 0; static size_t rlen = 0; - char *p; - if(rlen < strlen(fileMacro)) { - if(result) { - sc_free(result); + char * p; + if( rlen < strlen( fileMacro ) ) { + if( result ) { + sc_free( result ); } - rlen = strlen(fileMacro); - result = (char *)sc_malloc(rlen * sizeof(char) + 1); + rlen = strlen( fileMacro ); + result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 ); } - strcpy(result, fileMacro); + strcpy( result, fileMacro ); p = result; - while(*p) { - if(*p == '\\') { + while( *p ) { + if( *p == '\\' ) { *p = '/'; } p++; diff --git a/src/base/path2str.h b/src/base/path2str.h index 57f735142..84155cd9f 100644 --- a/src/base/path2str.h +++ b/src/base/path2str.h @@ -9,7 +9,7 @@ * silence "unknown escape sequence" warning when contents of __FILE__ * are fprintf'd into string in generated code */ -SC_BASE_EXPORT const char *path2str_fn(const char *fileMacro); +SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro ); #ifdef _WIN32 # define path2str(path) path2str_fn(path) diff --git a/src/base/sc_benchmark.cc b/src/base/sc_benchmark.cc index fcea26dd7..44f085f2f 100644 --- a/src/base/sc_benchmark.cc +++ b/src/base/sc_benchmark.cc @@ -13,7 +13,6 @@ #endif #include -#include #include #include #include @@ -22,12 +21,11 @@ #include /// mem values in kb, times in ms (granularity may be higher than 1ms) -benchVals getMemAndTime() -{ +benchVals getMemAndTime( ) { benchVals vals; #ifdef __linux__ // adapted from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c - std::ifstream stat_stream("/proc/self/stat", std::ios_base::in); + std::ifstream stat_stream( "/proc/self/stat", std::ios_base::in ); // dummy vars for leading entries in stat that we don't care about std::string pid, comm, state, ppid, pgrp, session, tty_nr; @@ -44,11 +42,11 @@ benchVals getMemAndTime() >> utime >> stime >> cutime >> cstime >> priority >> nice >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest - long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages + long page_size_kb = sysconf( _SC_PAGE_SIZE ) / 1024; // in case x86-64 is configured to use 2MB pages vals.physMemKB = rss * page_size_kb; - vals.virtMemKB = (vsize / 1024) - vals.physMemKB; - vals.userMilliseconds = (utime * 1000) / sysconf(_SC_CLK_TCK); - vals.sysMilliseconds = (stime * 1000) / sysconf(_SC_CLK_TCK); + vals.virtMemKB = ( vsize / 1024 ) - vals.physMemKB; + vals.userMilliseconds = ( utime * 1000 ) / sysconf( _SC_CLK_TCK ); + vals.sysMilliseconds = ( stime * 1000 ) / sysconf( _SC_CLK_TCK ); #elif defined(__APPLE__) // http://stackoverflow.com/a/1911863/382458 #elif defined(_WIN32) @@ -58,7 +56,7 @@ benchVals getMemAndTime() long page_size_kb = 1024; ULARGE_INTEGER kTime, uTime; - if(GetProcessMemoryInfo(GetCurrentProcess(), &MemoryCntrs, sizeof(MemoryCntrs))) { + if( GetProcessMemoryInfo( GetCurrentProcess(), &MemoryCntrs, sizeof( MemoryCntrs ) ) ) { vals.physMemKB = MemoryCntrs.PeakWorkingSetSize / page_size_kb; vals.virtMemKB = MemoryCntrs.PeakPagefileUsage / page_size_kb; } else { @@ -66,12 +64,12 @@ benchVals getMemAndTime() vals.virtMemKB = 0; } - if(GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime)) { - assert(sizeof(FILETIME) == sizeof(ULARGE_INTEGER)); - memcpy(&kTime, &KernelTime, sizeof(FILETIME)); - memcpy(&uTime, &UserTime, sizeof(FILETIME)); - vals.userMilliseconds = (long)(uTime.QuadPart / 100000L); - vals.sysMilliseconds = (long)(kTime.QuadPart / 100000L); + if( GetProcessTimes( GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime ) ) { + assert( sizeof( FILETIME ) == sizeof( ULARGE_INTEGER ) ); + memcpy( &kTime, &KernelTime, sizeof( FILETIME ) ); + memcpy( &uTime, &UserTime, sizeof( FILETIME ) ); + vals.userMilliseconds = ( long )( uTime.QuadPart / 100000L ); + vals.sysMilliseconds = ( long )( kTime.QuadPart / 100000L ); } else { vals.userMilliseconds = 0; vals.sysMilliseconds = 0; @@ -84,40 +82,33 @@ benchVals getMemAndTime() // --------------------- benchmark class --------------------- -benchmark::benchmark(bool debugMessages): debug(debugMessages), stopped(false) -{ - initialVals = getMemAndTime(); +benchmark::benchmark( std::string description, bool debugMessages, std::ostream & o_stream ): ostr( o_stream ), + descr( description ), debug( debugMessages ), stopped( false ) { + initialVals = getMemAndTime( ); } -benchmark::~benchmark() -{ - if(!stopped) { - stop(); - if(debug) { - std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; +benchmark::~benchmark() { + if( !stopped ) { + stop( ); + if( debug ) { + ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; } - out(); - } - if(benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; + out( ); } } -void benchmark::stop() -{ - if(stopped) { +void benchmark::stop( ) { + if( stopped ) { std::cerr << "benchmark::stop(): tried to stop a benchmark that was already stopped!" << std::endl; } else { - laterVals = getMemAndTime(); + laterVals = getMemAndTime( ); stopped = true; } } -benchVals benchmark::get() -{ - if(!stopped) { - laterVals = getMemAndTime(); +benchVals benchmark::get( ) { + if( !stopped ) { + laterVals = getMemAndTime( ); } benchVals delta; delta.physMemKB = laterVals.physMemKB - initialVals.physMemKB; @@ -126,41 +117,34 @@ benchVals benchmark::get() delta.userMilliseconds = laterVals.userMilliseconds - initialVals.userMilliseconds; //If vm is negative, the memory had been requested before initialVals was set. Don't count it - if(delta.virtMemKB < 0) { + if( delta.virtMemKB < 0 ) { delta.physMemKB -= delta.virtMemKB; delta.virtMemKB = 0; } return delta; } -void benchmark::reset() -{ +void benchmark::reset( std::string description ) { + descr = description; + reset(); +} +void benchmark::reset( ) { stopped = false; initialVals = getMemAndTime(); } -const char *benchmark::str() -{ - return str(get()); +std::string benchmark::str( ) { + return str( get( ) ); } -void benchmark::out() -{ - std::cout << str() << std::endl; +void benchmark::out() { + ostr << str( ) << std::endl; } -const char *benchmark::str(const benchVals &bv) -{ +std::string benchmark::str( const benchVals & bv ) { std::stringstream ss; - ss << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; + ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; - if(benchVals_str) { - free((void *)benchVals_str); - benchVals_str = NULL; - } - benchVals_str = (char *)calloc(ss.str().length() + 1, sizeof(char)); - snprintf(benchVals_str, ss.str().length(), "%s", ss.str().c_str()); - benchVals_str[ss.str().length()] = '\0'; - return benchVals_str; + return ss.str(); } diff --git a/src/base/sc_benchmark.h b/src/base/sc_benchmark.h index b11017c6a..8512bd892 100644 --- a/src/base/sc_benchmark.h +++ b/src/base/sc_benchmark.h @@ -5,23 +5,25 @@ #include "sc_export.h" #ifdef __cplusplus +#include #include +#include #include "sc_memmgr.h" extern "C" { #endif -typedef struct { - long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; -} benchVals; + typedef struct { + long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; + } benchVals; -/** return a benchVals struct with four current statistics for this process: - * virtual and physical memory use in kb, - * user and system cpu time in ms - * - * not yet implemented for OSX or Windows. - */ -SC_BASE_EXPORT benchVals getMemAndTime(); + /** return a benchVals struct with four current statistics for this process: + * virtual and physical memory use in kb, + * user and system cpu time in ms + * + * not yet implemented for OSX or Windows. + */ + SC_BASE_EXPORT benchVals getMemAndTime( ); #ifdef __cplusplus } @@ -37,30 +39,37 @@ SC_BASE_EXPORT benchVals getMemAndTime(); * depends on getMemAndTime() above - may not work on all platforms. */ -class SC_BASE_EXPORT benchmark -{ +class SC_BASE_EXPORT benchmark { protected: benchVals initialVals, laterVals; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + std::ostream & ostr; + std::string descr; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif bool debug, stopped; - char *benchVals_str = NULL; - public: - benchmark(bool debugMessages = true); + benchmark( std::string description = "", bool debugMessages = true, std::ostream & o_stream = std::cout ); /// if 'stopped' is false, uses str(true) to print to ostream - ~benchmark(); - void reset(); - benchVals get(); - void stop(); + ~benchmark( ); + void reset( ); + void reset( std::string description ); + benchVals get( ); + void stop( ); /// converts data member 'laterVals' into a string and returns it - const char *str(); + std::string str( ); /// outputs result of str() on ostream 'ostr' - void out(); + void out( ); /// converts 'bv' into a string, prefixed by data member 'descr' - const char *str(const benchVals &bv); + std::string str( const benchVals & bv ); }; diff --git a/src/base/sc_getopt.cc b/src/base/sc_getopt.cc index e135f1f31..01e925b56 100644 --- a/src/base/sc_getopt.cc +++ b/src/base/sc_getopt.cc @@ -152,35 +152,34 @@ // /////////////////////////////////////////////////////////////////////////////// -char *sc_optarg; // global argument pointer +char * sc_optarg; // global argument pointer int sc_optind = 0; // global argv index -int sc_getopt(int argc, char *argv[], char *optstring) -{ - static char *next = NULL; - if(sc_optind == 0) { +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { next = NULL; } sc_optarg = NULL; - if(next == NULL || *next == '\0') { - if(sc_optind == 0) { + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { sc_optind++; } - if(sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0') { + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { sc_optarg = NULL; - if(sc_optind < argc) { + if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; } return EOF; } - if(strcmp(argv[sc_optind], "--") == 0) { + if( strcmp( argv[sc_optind], "--" ) == 0 ) { sc_optind++; sc_optarg = NULL; - if(sc_optind < argc) { + if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; } return EOF; @@ -192,18 +191,18 @@ int sc_getopt(int argc, char *argv[], char *optstring) } char c = *next++; - char *cp = strchr(optstring, c); + char * cp = strchr( optstring, c ); - if(cp == NULL || c == ':') { + if( cp == NULL || c == ':' ) { return '?'; } cp++; - if(*cp == ':') { - if(*next != '\0') { + if( *cp == ':' ) { + if( *next != '\0' ) { sc_optarg = next; next = NULL; - } else if(sc_optind < argc) { + } else if( sc_optind < argc ) { sc_optarg = argv[sc_optind]; sc_optind++; } else { diff --git a/src/base/sc_getopt.h b/src/base/sc_getopt.h index 2eedcdf3b..e1421a7bf 100644 --- a/src/base/sc_getopt.h +++ b/src/base/sc_getopt.h @@ -20,10 +20,10 @@ extern "C" { #endif -extern SC_BASE_EXPORT int sc_optind, sc_opterr; -extern SC_BASE_EXPORT char *sc_optarg; + extern SC_BASE_EXPORT int sc_optind, sc_opterr; + extern SC_BASE_EXPORT char * sc_optarg; -int SC_BASE_EXPORT sc_getopt(int argc, char *argv[], char *optstring); + int SC_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring ); #ifdef __cplusplus } diff --git a/src/base/sc_memmgr.cc b/src/base/sc_memmgr.cc index 223bac4db..262d26e28 100644 --- a/src/base/sc_memmgr.cc +++ b/src/base/sc_memmgr.cc @@ -15,22 +15,21 @@ /** sc_memmgr_error definition */ -class sc_memmgr_error -{ +class sc_memmgr_error { private: std::string _srcfile; unsigned int _srcline; unsigned int _occurences; public: - sc_memmgr_error(const std::string &file, const unsigned int line); - sc_memmgr_error(const sc_memmgr_error &rhs); - ~sc_memmgr_error(void); + sc_memmgr_error( const std::string & file, const unsigned int line ); + sc_memmgr_error( const sc_memmgr_error & rhs ); + ~sc_memmgr_error( void ); - bool operator<(const sc_memmgr_error &rhs) const; + bool operator<( const sc_memmgr_error & rhs ) const; - std::string getsrcfile(void) const; - unsigned int getsrcline(void) const; - unsigned int getoccurences(void) const; + std::string getsrcfile( void ) const; + unsigned int getsrcline( void ) const; + unsigned int getoccurences( void ) const; }; typedef std::set sc_memmgr_errors; @@ -39,25 +38,24 @@ typedef std::set::iterator sc_memmgr_error_iterator; /** sc_memmgr_record definition */ -class sc_memmgr_record -{ +class sc_memmgr_record { private: - void *_addr; + void * _addr; size_t _size; std::string _srcfile; unsigned int _srcline; public: - sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line); - sc_memmgr_record(void *addr); - sc_memmgr_record(const sc_memmgr_record &rhs); - ~sc_memmgr_record(void); + sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ); + sc_memmgr_record( void * addr ); + sc_memmgr_record( const sc_memmgr_record & rhs ); + ~sc_memmgr_record( void ); - bool operator<(const sc_memmgr_record &rhs) const; + bool operator<( const sc_memmgr_record & rhs ) const; - void *getaddr(void) const; - size_t getsize(void) const; - std::string getsrcfile(void) const; - unsigned int getsrcline(void) const; + void * getaddr( void ) const; + size_t getsize( void ) const; + std::string getsrcfile( void ) const; + unsigned int getsrcline( void ) const; }; typedef std::set sc_memmgr_records; @@ -68,8 +66,7 @@ typedef std::set::iterator sc_memmgr_record_iterator; /** sc_memmgr definition */ -class sc_memmgr -{ +class sc_memmgr { private: #ifdef SC_MEMMGR_ENABLE_CHECKS bool _record_insert_busy, _record_erase_busy; @@ -84,12 +81,12 @@ class sc_memmgr #endif /* SC_MEMMGR_ENABLE_CHECKS */ protected: public: - sc_memmgr(void); - ~sc_memmgr(void); + sc_memmgr( void ); + ~sc_memmgr( void ); - void *allocate(size_t size, const char *file, const int line); - void *reallocate(void *addr, size_t size, const char *file, const int line); - void deallocate(void *addr, const char *file, const int line); + void * allocate( size_t size, const char * file, const int line ); + void * reallocate( void * addr, size_t size, const char * file, const int line ); + void deallocate( void * addr, const char * file, const int line ); }; /** @@ -105,24 +102,20 @@ sc_memmgr memmgr; */ extern "C" { - void *sc_malloc_fn(unsigned int size, const char *file, const int line) - { - return memmgr.allocate(size, file, line); + void * sc_malloc_fn( unsigned int size, const char * file, const int line ) { + return memmgr.allocate( size, file, line ); } - void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line) - { - return memmgr.allocate(count * size, file, line); + void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) { + return memmgr.allocate( count * size, file, line ); } - void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line) - { - return memmgr.reallocate(addr, size, file, line); + void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) { + return memmgr.reallocate( addr, size, file, line ); } - void sc_free_fn(void *addr) - { - memmgr.deallocate(addr, "", 0); + void sc_free_fn( void * addr ) { + memmgr.deallocate( addr, "", 0 ); } } @@ -130,26 +123,22 @@ extern "C" { /** c++ memory operators implementation */ -void *sc_operator_new(size_t size, const char *file, const int line) -{ - return memmgr.allocate(size, file, line); +void * sc_operator_new( size_t size, const char * file, const int line ) { + return memmgr.allocate( size, file, line ); } -void sc_operator_delete(void *addr, const char *file, const int line) -{ - memmgr.deallocate(addr, file, line); +void sc_operator_delete( void * addr, const char * file, const int line ) { + memmgr.deallocate( addr, file, line ); } -void sc_operator_delete(void *addr) -{ - memmgr.deallocate(addr, "", 0); +void sc_operator_delete( void * addr ) { + memmgr.deallocate( addr, "", 0 ); } /** sc_memmgr implementation */ -sc_memmgr::sc_memmgr(void) -{ +sc_memmgr::sc_memmgr( void ) { #ifdef SC_MEMMGR_ENABLE_CHECKS _record_insert_busy = false; _record_erase_busy = false; @@ -170,29 +159,28 @@ sc_memmgr::sc_memmgr(void) All records still present when sc_memmgr instance is destroyed can be considered as memory leaks. */ -sc_memmgr::~sc_memmgr(void) -{ +sc_memmgr::~sc_memmgr( void ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator irecord; sc_memmgr_errors errors; sc_memmgr_error_iterator ierror; // Check if total allocated equals total deallocated - if(_allocated_total != _deallocated_total) { + if( _allocated_total != _deallocated_total ) { // todo: generate warning for possible memory leaks, enable full memory leak checking - fprintf(stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total); + fprintf( stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total ); } // Compact leaks into an error list to prevent same leak being reported multiple times. _record_insert_busy = true; _record_erase_busy = true; - for(irecord = _records.begin(); + for( irecord = _records.begin(); irecord != _records.end(); - irecord ++) { - sc_memmgr_error error(irecord->getsrcfile(), irecord->getsrcline()); - ierror = errors.find(error); - if(ierror == errors.end()) { - errors.insert(error); + irecord ++ ) { + sc_memmgr_error error( irecord->getsrcfile(), irecord->getsrcline() ); + ierror = errors.find( error ); + if( ierror == errors.end() ) { + errors.insert( error ); } //else // ierror->occurences ++; @@ -201,11 +189,11 @@ sc_memmgr::~sc_memmgr(void) _record_erase_busy = false; // Loop through memory leaks to generate/buffer errors - for(ierror = errors.begin(); + for( ierror = errors.begin(); ierror != errors.end(); - ierror ++) { + ierror ++ ) { // todo: generate error for memory leak - fprintf(stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline()); + fprintf( stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline() ); } // Clear remaining records @@ -216,15 +204,14 @@ sc_memmgr::~sc_memmgr(void) #endif /* SC_MEMMGR_ENABLE_CHECKS */ } -void *sc_memmgr::allocate(size_t size, const char *file, const int line) -{ - void *addr; +void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { + void * addr; // Allocate - addr = malloc(size); - if(addr == NULL) { + addr = malloc( size ); + if( addr == NULL ) { // todo: error allocation failed - fprintf(stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line ); } // Some stl implementations (for example debian gcc) use the new operator to construct @@ -232,15 +219,15 @@ void *sc_memmgr::allocate(size_t size, const char *file, const int line) // for this operation, this would result in an infinite loop. This is fixed by the // _record_insert_busy flag. #ifdef SC_MEMMGR_ENABLE_CHECKS - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Store record for this allocation _record_insert_busy = true; - _records.insert(sc_memmgr_record(addr, size, file, line)); + _records.insert( sc_memmgr_record( addr, size, file, line ) ); _record_insert_busy = false; // Update stats _allocated += size; - if(_allocated > _maximum_allocated) { + if( _allocated > _maximum_allocated ) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -250,17 +237,16 @@ void *sc_memmgr::allocate(size_t size, const char *file, const int line) return addr; } -void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int line) -{ +void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const int line ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Find record of previous allocation/reallocation - record = _records.find(sc_memmgr_record(addr)); - if(record == _records.end()) { + record = _records.find( sc_memmgr_record( addr ) ); + if( record == _records.end() ) { // todo: error reallocating memory not allocated? - fprintf(stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line ); } else { // Update stats _allocated -= record->getsize(); @@ -268,29 +254,29 @@ void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int // Erase previous allocation/reallocation _record_erase_busy = true; - _records.erase(record); + _records.erase( record ); _record_erase_busy = false; } } #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Reallocate - addr = realloc(addr, size); - if(addr == NULL) { + addr = realloc( addr, size ); + if( addr == NULL ) { // todo: error reallocation failed - fprintf(stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line ); } #ifdef SC_MEMMGR_ENABLE_CHECKS - if(!_record_insert_busy) { + if( !_record_insert_busy ) { // Store record for this reallocation _record_insert_busy = true; - _records.insert(sc_memmgr_record(addr, size, file, line)); + _records.insert( sc_memmgr_record( addr, size, file, line ) ); _record_insert_busy = false; // Update stats _allocated += size; - if(_allocated > _maximum_allocated) { + if( _allocated > _maximum_allocated ) { _maximum_allocated = _allocated; } _allocated_total += size; @@ -301,17 +287,16 @@ void *sc_memmgr::reallocate(void *addr, size_t size, const char *file, const int return addr; } -void sc_memmgr::deallocate(void *addr, const char *file, const int line) -{ +void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { #ifdef SC_MEMMGR_ENABLE_CHECKS sc_memmgr_record_iterator record; - if(!_record_erase_busy) { + if( !_record_erase_busy ) { // Find record of previous allocation/reallocation - record = _records.find(sc_memmgr_record(addr)); - if(record == _records.end()) { + record = _records.find( sc_memmgr_record( addr ) ); + if( record == _records.end() ) { // todo: error free called for not allocated memory? - fprintf(stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line); + fprintf( stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line ); } else { // Update stats _allocated -= record->getsize(); @@ -319,7 +304,7 @@ void sc_memmgr::deallocate(void *addr, const char *file, const int line) // Erase record _record_erase_busy = true; - _records.erase(record); + _records.erase( record ); _record_erase_busy = false; } } @@ -329,107 +314,91 @@ void sc_memmgr::deallocate(void *addr, const char *file, const int line) #endif /* SC_MEMMGR_ENABLE_CHECKS */ // Deallocate - free(addr); + free( addr ); } #ifdef SC_MEMMGR_ENABLE_CHECKS /** sc_memmgr_error implementation */ -sc_memmgr_error::sc_memmgr_error(const std::string &file, const unsigned int line) -{ +sc_memmgr_error::sc_memmgr_error( const std::string & file, const unsigned int line ) { _srcfile = file; _srcline = line; _occurences = 1; } -sc_memmgr_error::sc_memmgr_error(const sc_memmgr_error &rhs) -{ +sc_memmgr_error::sc_memmgr_error( const sc_memmgr_error & rhs ) { _srcfile = rhs._srcfile; _srcline = rhs._srcline; _occurences = rhs._occurences; } -sc_memmgr_error::~sc_memmgr_error(void) -{ +sc_memmgr_error::~sc_memmgr_error( void ) { } -bool sc_memmgr_error::operator<(const sc_memmgr_error &rhs) const -{ - if(_srcfile == rhs._srcfile) { +bool sc_memmgr_error::operator<( const sc_memmgr_error & rhs ) const { + if( _srcfile == rhs._srcfile ) { return _srcline < rhs._srcline; } return _srcfile < rhs._srcfile; } -std::string sc_memmgr_error::getsrcfile(void) const -{ +std::string sc_memmgr_error::getsrcfile( void ) const { return _srcfile; } -unsigned int sc_memmgr_error::getsrcline(void) const -{ +unsigned int sc_memmgr_error::getsrcline( void ) const { return _srcline; } -unsigned int sc_memmgr_error::getoccurences(void) const -{ +unsigned int sc_memmgr_error::getoccurences( void ) const { return _occurences; } /** sc_memmgr_record implementation */ -sc_memmgr_record::sc_memmgr_record(void *addr, size_t size, const char *file, const unsigned int line) -{ +sc_memmgr_record::sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ) { _addr = addr; _size = size; _srcfile = file; _srcline = line; } -sc_memmgr_record::sc_memmgr_record(void *addr) -{ +sc_memmgr_record::sc_memmgr_record( void * addr ) { _addr = addr; _size = 0; _srcfile = ""; _srcline = -1; } -sc_memmgr_record::sc_memmgr_record(const sc_memmgr_record &rhs) -{ +sc_memmgr_record::sc_memmgr_record( const sc_memmgr_record & rhs ) { _addr = rhs._addr; _size = rhs._size; _srcfile = rhs._srcfile; _srcline = rhs._srcline; } -sc_memmgr_record::~sc_memmgr_record(void) -{ +sc_memmgr_record::~sc_memmgr_record( void ) { } -bool sc_memmgr_record::operator<(const sc_memmgr_record &rhs) const -{ +bool sc_memmgr_record::operator<( const sc_memmgr_record & rhs ) const { return _addr < rhs._addr; } -void *sc_memmgr_record::getaddr(void) const -{ +void * sc_memmgr_record::getaddr( void ) const { return _addr; } -size_t sc_memmgr_record::getsize(void) const -{ +size_t sc_memmgr_record::getsize( void ) const { return _size; } -std::string sc_memmgr_record::getsrcfile(void) const -{ +std::string sc_memmgr_record::getsrcfile( void ) const { return _srcfile; } -unsigned int sc_memmgr_record::getsrcline(void) const -{ +unsigned int sc_memmgr_record::getsrcline( void ) const { return _srcline; } diff --git a/src/base/sc_memmgr.h b/src/base/sc_memmgr.h index b1b05d2d4..9517a20bc 100644 --- a/src/base/sc_memmgr.h +++ b/src/base/sc_memmgr.h @@ -11,10 +11,10 @@ extern "C" { #endif /* __cplusplus */ -SC_BASE_EXPORT void *sc_malloc_fn(unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void *sc_calloc_fn(unsigned int count, unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void *sc_realloc_fn(void *addr, unsigned int size, const char *file, const int line); -SC_BASE_EXPORT void sc_free_fn(void *addr); + SC_BASE_EXPORT void * sc_malloc_fn( unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ); + SC_BASE_EXPORT void sc_free_fn( void * addr ); #ifdef __cplusplus } @@ -22,9 +22,9 @@ SC_BASE_EXPORT void sc_free_fn(void *addr); #ifdef __cplusplus -SC_BASE_EXPORT void *sc_operator_new(size_t size, const char *file, const int line); -SC_BASE_EXPORT void sc_operator_delete(void *addr, const char *file, const int line); -SC_BASE_EXPORT void sc_operator_delete(void *addr); +SC_BASE_EXPORT void * sc_operator_new( size_t size, const char * file, const int line ); +SC_BASE_EXPORT void sc_operator_delete( void * addr, const char * file, const int line ); +SC_BASE_EXPORT void sc_operator_delete( void * addr ); #endif /* __cplusplus */ @@ -39,34 +39,28 @@ SC_BASE_EXPORT void sc_operator_delete(void *addr); #include -inline void *operator new(size_t size, const char *file, const int line) throw(std::bad_alloc) -{ - return sc_operator_new(size, file, line); +inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) { + return sc_operator_new( size, file, line ); } -inline void *operator new[](size_t size, const char *file, const int line) throw(std::bad_alloc) -{ - return sc_operator_new(size, file, line); +inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) { + return sc_operator_new( size, file, line ); } -inline void operator delete(void *addr, const char *file, const int line) throw(std::bad_alloc) -{ - sc_operator_delete(addr, file, line); +inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) { + sc_operator_delete( addr, file, line ); } -inline void operator delete[](void *addr, const char *file, const int line) throw(std::bad_alloc) -{ - sc_operator_delete(addr, file, line); +inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) { + sc_operator_delete( addr, file, line ); } -inline void operator delete(void *addr) throw() -{ - sc_operator_delete(addr); +inline void operator delete( void * addr ) throw () { + sc_operator_delete( addr ); } -inline void operator delete[](void *addr) throw() -{ - sc_operator_delete(addr); +inline void operator delete[]( void * addr ) throw () { + sc_operator_delete( addr ); } #define new new(__FILE__, __LINE__) diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c index bcfaac0e3..1a908155c 100644 --- a/src/base/sc_mkdir.c +++ b/src/base/sc_mkdir.c @@ -1,4 +1,4 @@ -#define _XOPEN_SOURCE /* for S_IFDIR */ + #include "sc_mkdir.h" #include @@ -9,24 +9,22 @@ #endif /* _WIN32 */ /* cross-platform mkdir */ -int sc_mkdir(const char *path) -{ -#ifdef _WIN32 - return mkdir(path); -#else - return mkdir(path, 0777); -#endif /* _WIN32 */ +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) -{ +int mkDirIfNone( const char * path ) { struct stat s; - if(stat(path, &s) != 0) { - if(errno == ENOENT) { - return sc_mkdir(path); + if( stat( path, &s ) != 0 ) { + if( errno == ENOENT ) { + return sc_mkdir( path ); } - } else if(s.st_mode & S_IFDIR) { + } 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 */ diff --git a/src/base/sc_mkdir.h b/src/base/sc_mkdir.h index 34bea074c..21c8d9c5c 100644 --- a/src/base/sc_mkdir.h +++ b/src/base/sc_mkdir.h @@ -4,12 +4,12 @@ #include /** cross-platform mkdir() */ -SC_BASE_EXPORT int sc_mkdir(const char *path); +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); +SC_BASE_EXPORT int mkDirIfNone( const char * path ); #endif /* SC_MKDIR */ diff --git a/src/base/sc_nullptr.h b/src/base/sc_nullptr.h new file mode 100644 index 000000000..342397001 --- /dev/null +++ b/src/base/sc_nullptr.h @@ -0,0 +1,13 @@ +#ifndef NULLPTR_H +#define NULLPTR_H + +#include + +#ifdef HAVE_NULLPTR +#include +#else +# define nullptr_t void* +# define nullptr NULL +#endif //HAVE_NULLPTR + +#endif //NULLPTR_H diff --git a/src/base/sc_stdio.h b/src/base/sc_stdio.h index 717be249c..78fefc53b 100644 --- a/src/base/sc_stdio.h +++ b/src/base/sc_stdio.h @@ -10,23 +10,19 @@ #include static __inline int -c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) -{ +c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) { int count = -1; - if(sz != 0) { + if (sz != 0) count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap); - } - if(count == -1) { + if (count == -1) count = _vscprintf(format, ap); - } return count; } static __inline int -c99_snprintf(char *buffer, size_t sz, const char *format, ...) -{ +c99_snprintf(char *buffer, size_t sz, const char *format, ...) { int count; va_list ap; diff --git a/src/base/sc_trace_fprintf.c b/src/base/sc_trace_fprintf.c index 4ec3fde56..95ca6b9c6 100644 --- a/src/base/sc_trace_fprintf.c +++ b/src/base/sc_trace_fprintf.c @@ -4,14 +4,13 @@ #include "sc_trace_fprintf.h" -void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...) -{ +void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) { va_list args; - if((file != stdout) && (file != stderr)) { - fprintf(file, "/* source: %s:%d */", sourcefile, line); + if( ( file != stdout ) && ( file != stderr ) ) { + fprintf( file, "/* source: %s:%d */", sourcefile, line ); } - va_start(args, format); - vfprintf(file, format, args); - va_end(args); + va_start( args, format ); + vfprintf( file, format, args ); + va_end( args ); } diff --git a/src/base/sc_trace_fprintf.h b/src/base/sc_trace_fprintf.h index c09803ef0..b7aa05fa2 100644 --- a/src/base/sc_trace_fprintf.h +++ b/src/base/sc_trace_fprintf.h @@ -17,10 +17,10 @@ #ifdef __cplusplus extern "C" { #endif -/** Used to find where generated c++ originates from in exp2cxx. - * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' - */ -SC_BASE_EXPORT void trace_fprintf(char const *sourcefile, int line, FILE *file, const char *format, ...); + /** Used to find where generated c++ originates from in exp2cxx. + * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' + */ + SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ); #ifdef __cplusplus } #endif diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 023ce1ab6..2978f8c7a 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -36,19 +36,19 @@ include_directories( set(_libdeps steputils base) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLDAI_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cldai) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai) # Local Variables: # tab-width: 8 diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index 768cdded9..30a9103f4 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -37,116 +37,105 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Application_instance__set::SDAI_Application_instance__set(int defaultSize) -{ +SDAI_Application_instance__set::SDAI_Application_instance__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Application_instance_ptr[_bufsize]; _count = 0; } -SDAI_Application_instance__set::~SDAI_Application_instance__set() -{ +SDAI_Application_instance__set::~SDAI_Application_instance__set() { delete _buf; } -void SDAI_Application_instance__set::Check(int index) -{ - SDAI_Application_instance_ptr *newbuf; +void SDAI_Application_instance__set::Check( int index ) { + SDAI_Application_instance_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Application_instance_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Application_instance_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Application_instance_ptr ) ); delete _buf; _buf = newbuf; } } -void SDAI_Application_instance__set::Insert(SDAI_Application_instance_ptr v, int index) -{ - SDAI_Application_instance_ptr *spot; - index = (index < 0) ? _count : index; +void SDAI_Application_instance__set::Insert( SDAI_Application_instance_ptr v, int index ) { + SDAI_Application_instance_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Append(SDAI_Application_instance_ptr v) -{ +void SDAI_Application_instance__set::Append( SDAI_Application_instance_ptr v ) { int index = _count; - SDAI_Application_instance_ptr *spot; + SDAI_Application_instance_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Application_instance__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void SDAI_Application_instance__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Application_instance_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Application_instance_ptr)); + SDAI_Application_instance_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Application_instance_ptr ) ); } } -void SDAI_Application_instance__set::Remove(SDAI_Application_instance_ptr a) -{ - int index = Index(a); - if(!(index < 0)) { - Remove(index); +void SDAI_Application_instance__set::Remove( SDAI_Application_instance_ptr a ) { + int index = Index( a ); + if( !( index < 0 ) ) { + Remove( index ); } } -int SDAI_Application_instance__set::Index(SDAI_Application_instance_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int SDAI_Application_instance__set::Index( SDAI_Application_instance_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -SDAI_Application_instance_ptr &SDAI_Application_instance__set::operator[](int index) -{ - Check(index); +SDAI_Application_instance_ptr & SDAI_Application_instance__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Application_instance__set::Count() -{ +SDAI_Application_instance__set::Count() { return _count; } void -SDAI_Application_instance__set::Clear() -{ +SDAI_Application_instance__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiApplication_instance_set.h b/src/cldai/sdaiApplication_instance_set.h index ebe1dbfbe..378e65443 100644 --- a/src/cldai/sdaiApplication_instance_set.h +++ b/src/cldai/sdaiApplication_instance_set.h @@ -34,28 +34,27 @@ class SDAI_Application_instance; class SDAI_Application_instance__set; -typedef SDAI_Application_instance__set *SDAI_Application_instance__set_ptr; +typedef SDAI_Application_instance__set * SDAI_Application_instance__set_ptr; typedef SDAI_Application_instance__set_ptr SDAI_Application_instance__set_var; -class SC_DAI_EXPORT SDAI_Application_instance__set -{ +class SC_DAI_EXPORT SDAI_Application_instance__set { public: - SDAI_Application_instance__set(int = 16); + SDAI_Application_instance__set( int = 16 ); ~SDAI_Application_instance__set(); - SDAI_Application_instance *&operator[](int index); - void Insert(SDAI_Application_instance *, int index); - void Append(SDAI_Application_instance *); - void Remove(int index); - void Remove(SDAI_Application_instance *); - int Index(SDAI_Application_instance *); + SDAI_Application_instance *& operator[]( int index ); + void Insert( SDAI_Application_instance *, int index ); + void Append( SDAI_Application_instance * ); + void Remove( int index ); + void Remove( SDAI_Application_instance * ); + int Index( SDAI_Application_instance * ); int Count(); void Clear(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Application_instance **_buf; + SDAI_Application_instance ** _buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index d82dcdbee..678add01c 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -9,102 +9,46 @@ * and is not subject to copyright. */ -#include #include #include #include "sc_memmgr.h" -SDAI_Binary::SDAI_Binary(const char *str, int max) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(max + 1, sizeof(char)); - snprintf(content, max, "%s", str); -} - -SDAI_Binary::SDAI_Binary(const char *s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(strlen(s) + 1, sizeof(char)); - snprintf(content, strlen(s), "%s", s); -} - -SDAI_Binary::SDAI_Binary(const std::string &s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(s.length() + 1, sizeof(char)); - snprintf(content, s.length(), "%s", s.c_str()); +SDAI_Binary::SDAI_Binary( const char * str, int max ) { + content = std::string( str, max ); } -SDAI_Binary::SDAI_Binary(int i) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(2, sizeof(char)); - if(i) { - content[0] = '1'; - } else { - content[0] = '0'; - } - content[1] = '\0'; +SDAI_Binary::SDAI_Binary( const std::string & s ) { + content = std::string( s ); } -SDAI_Binary::~SDAI_Binary(void) -{ - if(content) { - free((void *)content); - } - content = NULL; +SDAI_Binary::~SDAI_Binary( void ) { } -SDAI_Binary &SDAI_Binary::operator= (const char *s) -{ - if(content) { - free((void *)content); - } - - content = (char *)calloc(strlen(s) + 1, sizeof(char)); - snprintf(content, strlen(s), "%s", s); +SDAI_Binary & SDAI_Binary::operator= ( const char * s ) { + content = std::string( s ); return *this; } -void SDAI_Binary::clear(void) -{ - if(content) { - free((void *)content); - } - content = NULL; +void SDAI_Binary::clear( void ) { + content.clear(); } -bool SDAI_Binary::empty(void) const -{ - return (!content) ? true : false; +bool SDAI_Binary::empty( void ) const { + return content.empty(); } -const char *SDAI_Binary::c_str(void) const -{ - return (const char *)content; +const char * SDAI_Binary::c_str( void ) const { + return content.c_str(); } -void SDAI_Binary::STEPwrite(ostream &out) const -{ - const char *str = 0; - if(empty()) { +void SDAI_Binary::STEPwrite( ostream & out ) const { + const char * str = 0; + if( empty() ) { out << "$"; } else { out << '\"'; str = c_str(); - while(*str) { + while( *str ) { out << *str; str++; } @@ -112,27 +56,25 @@ void SDAI_Binary::STEPwrite(ostream &out) const } } -const char *SDAI_Binary::STEPwrite(std::string &s) const -{ - const char *str = 0; - if(empty()) { +const char * SDAI_Binary::STEPwrite( std::string & s ) const { + const char * str = 0; + if( empty() ) { s = "$"; } else { s = "\""; str = c_str(); - while(*str) { + while( *str ) { s += *str; str++; } s += BINARY_DELIM; } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -Severity SDAI_Binary::ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_Binary::ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { clear(); } @@ -142,82 +84,79 @@ Severity SDAI_Binary::ReadBinary(istream &in, ErrorDescriptor *err, int AssignVa in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if((c == '\"') || isxdigit(c)) { + in.get( c ); + if( ( c == '\"' ) || isxdigit( c ) ) { int validDelimiters = 1; - if(c == '\"') { - in.get(c); // push past the delimiter + if( c == '\"' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } - while(in.good() && isxdigit(c)) { + while( in.good() && isxdigit( c ) ) { str += c; - in.get(c); + in.get( c ); } - if(in.good() && (c != '\"')) { - in.putback(c); + if( in.good() && ( c != '\"' ) ) { + in.putback( c ); } - if(AssignVal && (str.length() > 0)) { - operator= (str.c_str()); + if( AssignVal && ( str.length() > 0 ) ) { + operator= ( str.c_str() ); } - if(c == '\"') { // if found ending delimiter + if( c == '\"' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Binary value missing double quote delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Binary value missing double quote delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched double quote delimiters for binary.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched double quote delimiters for binary.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid binary value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid binary value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } -Severity SDAI_Binary::StrToVal(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); // sz defaults to length of s - return ReadBinary(in, err, 1, 0); +Severity SDAI_Binary::StrToVal( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); // sz defaults to length of s + return ReadBinary( in, err, 1, 0 ); } ///////////////////////////////////////////////// /// reads a binary in exchange file format delimited by double quotes -Severity SDAI_Binary::STEPread(istream &in, ErrorDescriptor *err) -{ - return ReadBinary(in, err, 1, 1); +Severity SDAI_Binary::STEPread( istream & in, ErrorDescriptor * err ) { + return ReadBinary( in, err, 1, 1 ); } -Severity SDAI_Binary::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); - return STEPread(in, err); +Severity SDAI_Binary::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); + return STEPread( in, err ); } /***************************************************************************//** @@ -239,47 +178,45 @@ Severity SDAI_Binary::STEPread(const char *s, ErrorDescriptor *err) ** null then attrValue must only contain a valid value and nothing else ** following. ******************************************************************************/ -Severity SDAI_Binary::BinaryValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - if(clearError) { +Severity SDAI_Binary::BinaryValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + if( clearError ) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = in.peek(); - if(c == '$' || in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( c == '$' || in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - if(in) { + if( in ) { in >> c; } - CheckRemainingInput(in, err, "binary", tokenList); + CheckRemainingInput( in, err, "binary", tokenList ); return err->severity(); } else { ErrorDescriptor error; - ReadBinary(in, &error, 0, needDelims); - CheckRemainingInput(in, &error, "binary", tokenList); + ReadBinary( in, &error, 0, needDelims ); + CheckRemainingInput( in, &error, "binary", tokenList ); Severity sev = error.severity(); - if(sev < SEVERITY_INCOMPLETE) { - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); - } else if(sev == SEVERITY_INCOMPLETE && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( sev < SEVERITY_INCOMPLETE ) { + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); + } else if( sev == SEVERITY_INCOMPLETE && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -Severity SDAI_Binary::BinaryValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - istringstream in((char *)value); - return BinaryValidLevel(in, err, optional, tokenList, - needDelims, clearError); +Severity SDAI_Binary::BinaryValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + istringstream in( ( char * )value ); + return BinaryValidLevel( in, err, optional, tokenList, + needDelims, clearError ); } diff --git a/src/cldai/sdaiBinary.h b/src/cldai/sdaiBinary.h index fb2204f9b..76bb56d18 100644 --- a/src/cldai/sdaiBinary.h +++ b/src/cldai/sdaiBinary.h @@ -1,10 +1,7 @@ #ifndef SDAIBINARY_H #define SDAIBINARY_H 1 -#include "sc_export.h" -#include "errordesc.h" - -#include +#include /* * NIST STEP Core Class Library @@ -16,48 +13,51 @@ * and is not subject to copyright. */ -class SC_DAI_EXPORT SDAI_Binary -{ +class SC_DAI_EXPORT SDAI_Binary { private: - char *content = NULL; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + std::string content; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif public: //constructor(s) & destructor - SDAI_Binary(const char *str = 0, int max = 0); - SDAI_Binary(const char *s); - SDAI_Binary(const std::string &s); - SDAI_Binary(int i); - ~SDAI_Binary(void); + SDAI_Binary( const char * str = 0, int max = 0 ); + SDAI_Binary( const std::string & s ); + ~SDAI_Binary( void ); // operators - SDAI_Binary &operator= (const char *s); + SDAI_Binary & operator= ( const char * s ); - void clear(void); - bool empty(void) const; - const char *c_str(void) const; + void clear( void ); + bool empty( void ) const; + const char * c_str( void ) const; // format for STEP - const char *asStr() const - { + const char * asStr() const { return c_str(); } - void STEPwrite(std::ostream &out = std::cout) const; - const char *STEPwrite(std::string &s) const; + void STEPwrite( ostream & out = cout ) const; + const char * STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s, ErrorDescriptor *err); - Severity STEPread(istream &in, ErrorDescriptor *err); - Severity STEPread(const char *s, ErrorDescriptor *err); + Severity StrToVal( const char * s, ErrorDescriptor * err ); + Severity STEPread( istream & in, ErrorDescriptor * err ); + Severity STEPread( const char * s, ErrorDescriptor * err ); - Severity BinaryValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); - Severity BinaryValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity BinaryValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); + Severity BinaryValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); protected: - Severity ReadBinary(istream &in, ErrorDescriptor *err, int AssignVal = 1, - int needDelims = 1); + Severity ReadBinary( istream & in, ErrorDescriptor * err, int AssignVal = 1, + int needDelims = 1 ); }; #endif diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index 5c35e4e7e..2f43ab284 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -9,45 +9,36 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif -SDAI_PID::SDAI_PID() -{ +SDAI_PID::SDAI_PID() { } -SDAI_PID::~SDAI_PID() -{ +SDAI_PID::~SDAI_PID() { } -SDAI_PID_DA::SDAI_PID_DA() -{ +SDAI_PID_DA::SDAI_PID_DA() { } -SDAI_PID_DA::~SDAI_PID_DA() -{ +SDAI_PID_DA::~SDAI_PID_DA() { } -SDAI_PID_SDAI::SDAI_PID_SDAI() -{ +SDAI_PID_SDAI::SDAI_PID_SDAI() { } -SDAI_PID_SDAI::~SDAI_PID_SDAI() -{ +SDAI_PID_SDAI::~SDAI_PID_SDAI() { } -SDAI_DAObject::SDAI_DAObject() -{ +SDAI_DAObject::SDAI_DAObject() { } -SDAI_DAObject::~SDAI_DAObject() -{ +SDAI_DAObject::~SDAI_DAObject() { } -SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() -{ +SDAI_DAObject_SDAI::SDAI_DAObject_SDAI() { } /* @@ -56,8 +47,7 @@ SDAI_DAObject_SDAI::SDAI_DAObject_SDAI(const DAObject_SDAI&) } */ -SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() -{ +SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() { } /* @@ -88,86 +78,79 @@ SDAI_DAObject_SDAI::~SDAI_DAObject_SDAI() /*****************************************************************************/ -SDAI_DAObject__set::SDAI_DAObject__set(int defaultSize) -{ +SDAI_DAObject__set::SDAI_DAObject__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_DAObject_ptr[_bufsize]; _count = 0; } -SDAI_DAObject__set::~SDAI_DAObject__set() -{ +SDAI_DAObject__set::~SDAI_DAObject__set() { delete _buf; } -void SDAI_DAObject__set::Check(int index) -{ +void SDAI_DAObject__set::Check( int index ) { - SDAI_DAObject_ptr *newbuf; + SDAI_DAObject_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_DAObject_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_DAObject_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_DAObject_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_DAObject__set::Insert(SDAI_DAObject_ptr v, int index) -{ +SDAI_DAObject__set::Insert( SDAI_DAObject_ptr v, int index ) { - SDAI_DAObject_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_DAObject_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Append(SDAI_DAObject_ptr v) -{ +void SDAI_DAObject__set::Append( SDAI_DAObject_ptr v ) { int index = _count; - SDAI_DAObject_ptr *spot; + SDAI_DAObject_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_DAObject_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_DAObject__set::Remove(int index) -{ +void SDAI_DAObject__set::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_DAObject_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_DAObject_ptr)); + SDAI_DAObject_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_DAObject_ptr ) ); } } -int SDAI_DAObject__set::Index(SDAI_DAObject_ptr v) -{ +int SDAI_DAObject__set::Index( SDAI_DAObject_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -175,34 +158,29 @@ int SDAI_DAObject__set::Index(SDAI_DAObject_ptr v) } SDAI_DAObject_ptr -SDAI_DAObject__set::retrieve(int index) -{ - return operator[](index); +SDAI_DAObject__set::retrieve( int index ) { + return operator[]( index ); } -SDAI_DAObject_ptr &SDAI_DAObject__set::operator[](int index) -{ +SDAI_DAObject_ptr & SDAI_DAObject__set::operator[]( int index ) { - Check(index); + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_DAObject__set::Count() -{ +SDAI_DAObject__set::Count() { return _count; } int -SDAI_DAObject__set::is_empty() -{ +SDAI_DAObject__set::is_empty() { return _count; } void -SDAI_DAObject__set::Clear() -{ +SDAI_DAObject__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiDaObject.h b/src/cldai/sdaiDaObject.h index 97af663be..168c7bfbc 100644 --- a/src/cldai/sdaiDaObject.h +++ b/src/cldai/sdaiDaObject.h @@ -7,7 +7,7 @@ #include -typedef char *SDAI_DAObjectID; +typedef char * SDAI_DAObjectID; // // The PID class maintains the persistent object identifier for every @@ -24,8 +24,7 @@ typedef char *SDAI_DAObjectID; SDAI_DAObjectID as follows: */ /// interface PID (ISO/DIS 10303-23:1996(E) 5.3.10.1) -class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject { public: // These are in the IDL generated code for Part 26. I will have to think about @@ -45,22 +44,20 @@ class SC_DAI_EXPORT SDAI_PID : public SDAI_sdaiObject The Datestore_type attribute shall identify the type of the underlying datastore. */ - char *Datastore_type() const - { - return const_cast(_datastore_type.c_str()); + char * Datastore_type() const { + return const_cast( _datastore_type.c_str() ); } - void Datastore_type(char *x) - { + void Datastore_type( char * x ) { _datastore_type = x; } /* This function shall return a string version of the receiver. */ - char *get_PIDString(); + char * get_PIDString(); }; -typedef SDAI_PID *SDAI_PID_ptr; +typedef SDAI_PID * SDAI_PID_ptr; typedef SDAI_PID_ptr SDAI_PID_var; @@ -84,8 +81,7 @@ typedef SDAI_PID_ptr SDAI_PID_var; // interface. // /// interface PID_DA (ISO/DIS 10303-23:1996(E) 5.3.10.3) -class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID -{ +class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID { public: SDAI_String _oid; @@ -105,17 +101,15 @@ class SC_DAI_EXPORT SDAI_PID_DA: public SDAI_PID SDAI_PID_DA(); virtual ~SDAI_PID_DA(); - virtual void oid(const SDAI_DAObjectID x) - { + virtual void oid( const SDAI_DAObjectID x ) { _oid = x; } - virtual SDAI_DAObjectID oid() const - { - return const_cast(_oid.c_str()); + virtual SDAI_DAObjectID oid() const { + return const_cast( _oid.c_str() ); } }; -typedef SDAI_PID_DA *SDAI_PID_DA_ptr; +typedef SDAI_PID_DA * SDAI_PID_DA_ptr; typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // @@ -123,8 +117,7 @@ typedef SDAI_PID_DA_ptr SDAI_PID_DA_var; // a Model_contents object. // /// interface PID_SDAI (ISO/DIS 10303-23:1996(E) 5.3.10.2) -class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID -{ +class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID { public: SDAI_String _modelid; @@ -138,17 +131,15 @@ class SC_DAI_EXPORT SDAI_PID_SDAI : public SDAI_PID // the persistent identifier of the cluster of data for the // Model_contents referred to by this PID. // - virtual void Modelid(const char *x) - { + virtual void Modelid( const char * x ) { _modelid = x; } - virtual char *Modelid() const - { - return const_cast(_modelid.c_str()); + virtual char * Modelid() const { + return const_cast( _modelid.c_str() ); } }; -typedef SDAI_PID_SDAI *SDAI_PID_SDAI_ptr; +typedef SDAI_PID_SDAI * SDAI_PID_SDAI_ptr; typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // @@ -162,12 +153,11 @@ typedef SDAI_PID_SDAI_ptr SDAI_PID_SDAI_var; // predefine these _ptr since they are used inside this class class SDAI_DAObject; -typedef SDAI_DAObject *SDAI_DAObject_ptr; +typedef SDAI_DAObject * SDAI_DAObject_ptr; typedef SDAI_DAObject_ptr SDAI_DAObject_var; /// interface DAObject (ISO/DIS 10303-23:1996(E) 5.3.10.5) -class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject { public: SDAI_String _dado_oid; @@ -186,11 +176,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject SDAI_DAObject(); virtual ~SDAI_DAObject(); - Logical dado_same(SDAI_DAObject_ptr obj) - { - if(obj == this) { - return LTrue; - } + Logical dado_same( SDAI_DAObject_ptr obj ) { + if (obj == this) return LTrue; return LUnknown; } @@ -223,9 +210,8 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject note that the return value as described in the text above should be a string type. */ - SDAI_DAObjectID dado_oid() - { - return const_cast(_dado_oid.c_str()); + SDAI_DAObjectID dado_oid() { + return const_cast( _dado_oid.c_str() ); } // dado_pid @@ -237,8 +223,7 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject part of interface DAObject in the specification of the Persistent Object Service. */ - SDAI_PID_DA_ptr dado_pid() - { + SDAI_PID_DA_ptr dado_pid() { return 0; } @@ -272,8 +257,7 @@ class SC_DAI_EXPORT SDAI_DAObject : public SDAI_sdaiObject 5.3.10.1 DAObject_SDAI */ -class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject -{ +class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject { public: SDAI_DAObject_SDAI(); @@ -320,7 +304,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.3 Is same */ - Logical IsSame(const SDAI_sdaiObject_ptr &otherEntity) const; + Logical IsSame( const SDAI_sdaiObject_ptr & otherEntity ) const; /* Function: @@ -345,8 +329,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifdef SDAI_CPP_LATE_BINDING - Any_var GetAttr(const Attribute_ptr &attDef); - Any_var GetAttr(const char *attName); + Any_var GetAttr( const Attribute_ptr & attDef ); + Any_var GetAttr( const char * attName ); #endif /* @@ -385,9 +369,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.6 Is instance of */ - ::Boolean IsInstanceOf(const char *typeName) const; + ::Boolean IsInstanceOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsInstanceOf(const Entity_ptr &otherEntity) const; + ::Boolean IsInstanceOf( const Entity_ptr & otherEntity ) const; #endif /* @@ -407,9 +391,9 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.7 Is kind of */ - ::Boolean IsKindOf(const char *typeName) const; + ::Boolean IsKindOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsKindOf(const Entity_ptr &theType) const; + ::Boolean IsKindOf( const Entity_ptr & theType ) const; #endif /* @@ -427,10 +411,10 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject 5.3.10.1.8 Is SDAI kind of */ - ::Boolean IsSDAIKindOf(const char *typeName) const; + ::Boolean IsSDAIKindOf( const char * typeName ) const; #ifdef SDAI_CPP_LATE_BINDING - ::Boolean IsSDAIKindOf(const Entity_ptr &theType) const; + ::Boolean IsSDAIKindOf( const Entity_ptr & theType ) const; #endif /* @@ -450,8 +434,8 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifdef SDAI_CPP_LATE_BINDING - ::Boolean TestAttr(const Attribute_ptr &attDef); - ::Boolean TestAttr(const char *attName) const; + ::Boolean TestAttr( const Attribute_ptr & attDef ); + ::Boolean TestAttr( const char * attName ) const; #endif /* @@ -471,7 +455,7 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject */ #ifndef SDAI_CPP_LATE_BINDING - char *GetInstanceTypeName() const; + char * GetInstanceTypeName() const; #endif /* Function: @@ -493,33 +477,32 @@ class SC_DAI_EXPORT SDAI_DAObject_SDAI : public SDAI_DAObject }; -typedef SDAI_DAObject_SDAI *SDAI_DAObject_SDAI_ptr; +typedef SDAI_DAObject_SDAI * SDAI_DAObject_SDAI_ptr; typedef SDAI_DAObject_SDAI_ptr SDAI_DAObject_SDAI_var; -class SC_DAI_EXPORT SDAI_DAObject__set -{ +class SC_DAI_EXPORT SDAI_DAObject__set { public: - SDAI_DAObject__set(int = 16); + SDAI_DAObject__set( int = 16 ); ~SDAI_DAObject__set(); - SDAI_DAObject_ptr retrieve(int index); + SDAI_DAObject_ptr retrieve( int index ); int is_empty(); - SDAI_DAObject_ptr &operator[](int index); + SDAI_DAObject_ptr & operator[]( int index ); - void Insert(SDAI_DAObject_ptr, int index); - void Append(SDAI_DAObject_ptr); - void Remove(int index); + void Insert( SDAI_DAObject_ptr, int index ); + void Append( SDAI_DAObject_ptr ); + void Remove( int index ); - int Index(SDAI_DAObject_ptr); + int Index( SDAI_DAObject_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_DAObject_ptr *_buf; + SDAI_DAObject_ptr * _buf; int _bufsize; int _count; @@ -527,7 +510,7 @@ class SC_DAI_EXPORT SDAI_DAObject__set }; -typedef SDAI_DAObject__set *SDAI_DAObject__set_ptr; +typedef SDAI_DAObject__set * SDAI_DAObject__set_ptr; typedef SDAI_DAObject__set_ptr SDAI_DAObject__set_var; #endif diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index 5728b0f66..f98d5d279 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -5,9 +5,8 @@ #include #include "sc_memmgr.h" -SDAI_Entity_extent::SDAI_Entity_extent() - : _definition(0), _definition_name(0), _owned_by(0) -{ +SDAI_Entity_extent::SDAI_Entity_extent( ) + : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { /* _definition = 0; _definition_name = 0; @@ -24,14 +23,12 @@ SDAI_Entity_extent::SDAI_Entity_extent(const SDAI_Entity_extent& ee) } */ -SDAI_Entity_extent::~SDAI_Entity_extent() -{ +SDAI_Entity_extent::~SDAI_Entity_extent() { delete _definition_name; } Entity_ptr -SDAI_Entity_extent ::definition_() const -{ +SDAI_Entity_extent ::definition_() const { return _definition; } @@ -44,26 +41,22 @@ SDAI_Entity_extent::definition_name_() const */ void -SDAI_Entity_extent::definition_(const Entity_ptr &ep) -{ +SDAI_Entity_extent::definition_( const Entity_ptr & ep ) { _definition = ep; } void -SDAI_Entity_extent::definition_name_(const SDAI_Entity_name &en) -{ - _definition_name = new char[strlen(en) + 1]; - strncpy(_definition_name, en, strlen(en) + 1); +SDAI_Entity_extent::definition_name_( const SDAI_Entity_name & en ) { + _definition_name = new char[strlen( en ) + 1]; + strncpy( _definition_name, en, strlen( en ) + 1 ); } -void SDAI_Entity_extent::owned_by_(SDAI_Model_contents__list_var &mclv) -{ +void SDAI_Entity_extent::owned_by_( SDAI_Model_contents__list_var& mclv ) { _owned_by = *mclv; } -SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const -{ - return (SDAI_Model_contents__list_var) &_owned_by; +SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const { + return ( const SDAI_Model_contents__list_var ) &_owned_by; } /* @@ -98,9 +91,8 @@ SDAI_DAObject__set_var instances_() const */ void -SDAI_Entity_extent::AddInstance(const SDAI_DAObject_ptr &appInst) -{ - _instances.Append(appInst); +SDAI_Entity_extent::AddInstance( const SDAI_DAObject_ptr & appInst ) { + _instances.Append( appInst ); } /* @@ -121,9 +113,8 @@ SDAI_Entity_extent::AddInstance(const SDAI_DAObject_ptr &appInst) void -SDAI_Entity_extent::RemoveInstance(const SDAI_DAObject_ptr &appInst) -{ - _instances.Remove(_instances.Index(appInst)); +SDAI_Entity_extent::RemoveInstance( const SDAI_DAObject_ptr & appInst ) { + _instances.Remove( _instances.Index( appInst ) ); } ///////// END_ENTITY SDAI_Entity_extent diff --git a/src/cldai/sdaiEntity_extent.h b/src/cldai/sdaiEntity_extent.h index b8b2254ab..0dcca471f 100644 --- a/src/cldai/sdaiEntity_extent.h +++ b/src/cldai/sdaiEntity_extent.h @@ -15,11 +15,10 @@ */ class SDAI_Entity_extent; -typedef SDAI_Entity_extent *SDAI_Entity_extent_ptr; +typedef SDAI_Entity_extent * SDAI_Entity_extent_ptr; typedef SDAI_Entity_extent_ptr SDAI_Entity_extent_var; -class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance -{ +class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { friend class SDAI_Model_contents; /* @@ -44,8 +43,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance public: - SDAI_Entity_name definition_name_() const - { + SDAI_Entity_name definition_name_() const { return _definition_name; } @@ -54,13 +52,11 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance // const Entity_ptr definition_() const; #endif - SDAI_DAObject__set_var instances_() - { + SDAI_DAObject__set_var instances_() { return &_instances; } - SDAI_DAObject__set_var instances_() const - { - return (SDAI_DAObject__set_var)&_instances; + SDAI_DAObject__set_var instances_() const { + return ( const SDAI_DAObject__set_var )&_instances; } // need to implement Model_contents__list @@ -72,12 +68,12 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance // static SDAI_Entity_extent_ptr _nil(); // private: - void definition_(const Entity_ptr &ep); + void definition_( const Entity_ptr & ep ); #ifdef SDAI_CPP_LATE_BINDING // void definition_(const Entity_ptr& ep); #endif - void definition_name_(const SDAI_Entity_name &ep); - void owned_by_(SDAI_Model_contents__list_var &mclv); + void definition_name_( const SDAI_Entity_name & ep ); + void owned_by_( SDAI_Model_contents__list_var & mclv ); /* 7.3.3.1 SDAI operation declarations @@ -86,7 +82,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance */ // this is no longer in Part 23 - void AddInstance(const SDAI_DAObject_ptr &appInst); + void AddInstance( const SDAI_DAObject_ptr & appInst ); /* Function: @@ -105,7 +101,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance */ // this is no longer in Part 23 - void RemoveInstance(const SDAI_DAObject_ptr &appInst); + void RemoveInstance( const SDAI_DAObject_ptr & appInst ); /* 7.3.3.1.2 RemoveInstance diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index d96ccc057..af3658222 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -38,92 +38,85 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Entity_extent__set::SDAI_Entity_extent__set(int defaultSize) -{ +SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Entity_extent_ptr[_bufsize]; _count = 0; } -SDAI_Entity_extent__set::~SDAI_Entity_extent__set() -{ +SDAI_Entity_extent__set::~SDAI_Entity_extent__set() { delete _buf; } -void SDAI_Entity_extent__set::Check(int index) -{ +void SDAI_Entity_extent__set::Check( int index ) { - SDAI_Entity_extent_ptr *newbuf; + SDAI_Entity_extent_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Entity_extent_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Entity_extent_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_Entity_extent__set::Insert(SDAI_Entity_extent_ptr v, int index) -{ +SDAI_Entity_extent__set::Insert( SDAI_Entity_extent_ptr v, int index ) { - SDAI_Entity_extent_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_Entity_extent_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Append(SDAI_Entity_extent_ptr v) -{ +void SDAI_Entity_extent__set::Append( SDAI_Entity_extent_ptr v ) { int index = _count; - SDAI_Entity_extent_ptr *spot; + SDAI_Entity_extent_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Entity_extent__set::Remove(int index) -{ +void SDAI_Entity_extent__set::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Entity_extent_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Entity_extent_ptr)); + SDAI_Entity_extent_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Entity_extent_ptr ) ); } } -int SDAI_Entity_extent__set::Index(SDAI_Entity_extent_ptr v) -{ +int SDAI_Entity_extent__set::Index( SDAI_Entity_extent_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -131,34 +124,29 @@ int SDAI_Entity_extent__set::Index(SDAI_Entity_extent_ptr v) } SDAI_Entity_extent_ptr -SDAI_Entity_extent__set::retrieve(int index) -{ - return operator[](index); +SDAI_Entity_extent__set::retrieve( int index ) { + return operator[]( index ); } -SDAI_Entity_extent_ptr &SDAI_Entity_extent__set::operator[](int index) -{ - Check(index); +SDAI_Entity_extent_ptr & SDAI_Entity_extent__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Entity_extent__set::Count() -{ +SDAI_Entity_extent__set::Count() { return _count; } int -SDAI_Entity_extent__set::is_empty() -{ +SDAI_Entity_extent__set::is_empty() { return _count; } void -SDAI_Entity_extent__set::Clear() -{ +SDAI_Entity_extent__set::Clear() { _count = 0; } @@ -166,103 +154,93 @@ SDAI_Entity_extent__set::Clear() #if 0 -Entity_extent__set::Entity_extent__set(int defaultSize) -{ +Entity_extent__set::Entity_extent__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Entity_extent_ptr[_bufsize]; _count = 0; } -Entity_extent__set::~Entity_extent__set() -{ +Entity_extent__set::~Entity_extent__set() { delete _buf; } -void Entity_extent__set::Check(int index) -{ - Entity_extent_ptr *newbuf; +void Entity_extent__set::Check( int index ) { + Entity_extent_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Entity_extent_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Entity_extent_ptr)); + memmove( newbuf, _buf, _count * sizeof( Entity_extent_ptr ) ); delete _buf; _buf = newbuf; } } -void Entity_extent__set::Insert(Entity_extent_ptr v, int index) -{ - Entity_extent_ptr *spot; - index = (index < 0) ? _count : index; +void Entity_extent__set::Insert( Entity_extent_ptr v, int index ) { + Entity_extent_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Append(Entity_extent_ptr v) -{ +void Entity_extent__set::Append( Entity_extent_ptr v ) { int index = _count; - Entity_extent_ptr *spot; + Entity_extent_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Entity_extent_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Entity_extent_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Entity_extent__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Entity_extent__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Entity_extent_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Entity_extent_ptr)); + Entity_extent_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Entity_extent_ptr ) ); } } -int Entity_extent__set::Index(Entity_extent_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Entity_extent__set::Index( Entity_extent_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Entity_extent_ptr &Entity_extent__set::operator[](int index) -{ - Check(index); +Entity_extent_ptr & Entity_extent__set::operator[]( int index ) { + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -Entity_extent__set::Count() -{ +Entity_extent__set::Count() { return _count; } void -Entity_extent__set::Clear() -{ +Entity_extent__set::Clear() { _count = 0; } diff --git a/src/cldai/sdaiEntity_extent_set.h b/src/cldai/sdaiEntity_extent_set.h index a7541cd83..b6b893078 100644 --- a/src/cldai/sdaiEntity_extent_set.h +++ b/src/cldai/sdaiEntity_extent_set.h @@ -37,36 +37,35 @@ //#include */ -class SC_DAI_EXPORT SDAI_Entity_extent__set -{ +class SC_DAI_EXPORT SDAI_Entity_extent__set { public: - SDAI_Entity_extent__set(int = 16); + SDAI_Entity_extent__set( int = 16 ); ~SDAI_Entity_extent__set(); - SDAI_Entity_extent_ptr retrieve(int index); + SDAI_Entity_extent_ptr retrieve( int index ); int is_empty(); - SDAI_Entity_extent_ptr &operator[](int index); + SDAI_Entity_extent_ptr & operator[]( int index ); - void Insert(SDAI_Entity_extent_ptr, int index); - void Append(SDAI_Entity_extent_ptr); - void Remove(int index); - int Index(SDAI_Entity_extent_ptr); + void Insert( SDAI_Entity_extent_ptr, int index ); + void Append( SDAI_Entity_extent_ptr ); + void Remove( int index ); + int Index( SDAI_Entity_extent_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Entity_extent_ptr *_buf; + SDAI_Entity_extent_ptr * _buf; int _bufsize; int _count; }; -typedef SDAI_Entity_extent__set *SDAI_Entity_extent__set_ptr; +typedef SDAI_Entity_extent__set * SDAI_Entity_extent__set_ptr; typedef SDAI_Entity_extent__set_ptr SDAI_Entity_extent__set_var; /* diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index 35529276b..a8e37d407 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -19,47 +19,39 @@ // class Logical /////////////////////////////////////////////////////////////////////////////// -SDAI_LOGICAL::SDAI_LOGICAL(const char *val) -{ - set_value(val); +SDAI_LOGICAL::SDAI_LOGICAL( const char * val ) { + set_value( val ); } -SDAI_LOGICAL::SDAI_LOGICAL(Logical state) -{ - set_value(state); +SDAI_LOGICAL::SDAI_LOGICAL( Logical state ) { + set_value( state ); } -SDAI_LOGICAL::SDAI_LOGICAL(const SDAI_LOGICAL &source) -{ - set_value(source.asInt()); +SDAI_LOGICAL::SDAI_LOGICAL( const SDAI_LOGICAL & source ) { + set_value( source.asInt() ); } -SDAI_LOGICAL::SDAI_LOGICAL(int i) -{ - if(i == 0) { +SDAI_LOGICAL::SDAI_LOGICAL( int i ) { + if( i == 0 ) { v = LFalse ; } else { v = LTrue ; } } -SDAI_LOGICAL::~SDAI_LOGICAL() -{ +SDAI_LOGICAL::~SDAI_LOGICAL() { } -const char *SDAI_LOGICAL::Name() const -{ +const char * SDAI_LOGICAL::Name() const { return "Logical"; } -int SDAI_LOGICAL::no_elements() const -{ +int SDAI_LOGICAL::no_elements() const { return 3; } -const char *SDAI_LOGICAL::element_at(int n) const -{ - switch(n) { +const char * SDAI_LOGICAL::element_at( int n ) const { + switch( n ) { case LUnknown : return "U"; case LFalse : @@ -71,19 +63,16 @@ const char *SDAI_LOGICAL::element_at(int n) const } } -int SDAI_LOGICAL::exists() const // return 0 if unset otherwise return 1 -{ - return !(v == 2); +int SDAI_LOGICAL::exists() const { // return 0 if unset otherwise return 1 + return !( v == 2 ); } -void SDAI_LOGICAL::nullify() // change the receiver to an unset status -{ +void SDAI_LOGICAL::nullify() { // change the receiver to an unset status v = 2; } -SDAI_LOGICAL::operator Logical() const -{ - switch(v) { +SDAI_LOGICAL::operator Logical() const { + switch( v ) { case LFalse : return LFalse ; case LTrue : @@ -96,29 +85,26 @@ SDAI_LOGICAL::operator Logical() const } } -SDAI_LOGICAL &SDAI_LOGICAL::operator= (const SDAI_LOGICAL &t) -{ - set_value(t.asInt()); +SDAI_LOGICAL & SDAI_LOGICAL::operator= ( const SDAI_LOGICAL & t ) { + set_value( t.asInt() ); return *this; } -SDAI_LOGICAL SDAI_LOGICAL::operator ==(const SDAI_LOGICAL &t) const -{ - if(v == t.asInt()) { +SDAI_LOGICAL SDAI_LOGICAL::operator ==( const SDAI_LOGICAL & t ) const { + if( v == t.asInt() ) { return LTrue ; } return LFalse ; } -int SDAI_LOGICAL::set_value(const int i) -{ - if(i > no_elements() + 1) { +int SDAI_LOGICAL::set_value( const int i ) { + if( i > no_elements() + 1 ) { v = 2; return v; } - const char *tmp = element_at(i); - if(tmp[0] != '\0') { - return (v = i); + const char * tmp = element_at( i ); + if( tmp[0] != '\0' ) { + return ( v = i ); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -127,21 +113,20 @@ int SDAI_LOGICAL::set_value(const int i) return no_elements() + 1 ; } -int SDAI_LOGICAL::set_value(const char *n) -{ +int SDAI_LOGICAL::set_value( const char * n ) { // assigns the appropriate value based on n - if(!n || (!strcmp(n, ""))) { + if( !n || ( !strcmp( n, "" ) ) ) { nullify(); return asInt(); } int i = 0; std::string tmp; - while((i < (no_elements() + 1)) && - (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { + while( ( i < ( no_elements() + 1 ) ) && + ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { ++i; } - if((no_elements() + 1) == i) { // exhausted all the possible values + if( ( no_elements() + 1 ) == i ) { // exhausted all the possible values nullify(); return v; } @@ -149,10 +134,9 @@ int SDAI_LOGICAL::set_value(const char *n) return v; } -Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_LOGICAL::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { set_null(); } @@ -162,85 +146,85 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if(c == '.' || isalpha(c)) { + in.get( c ); + if( c == '.' || isalpha( c ) ) { int validDelimiters = 1; - if(c == '.') { - in.get(c); // push past the delimiter + if( c == '.' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if(in.good() && (isalpha(c) || c == '_')) { + if( in.good() && ( isalpha( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // look for UPPER or DIGIT - while(in.good() && (isalnum(c) || c == '_')) { + while( in.good() && ( isalnum( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // if character is not the delimiter unread it - if(in.good() && (c != '.')) { - in.putback(c); + if( in.good() && ( c != '.' ) ) { + in.putback( c ); } // a value was read - if(str.length() > 0) { + if( str.length() > 0 ) { int i = 0; - const char *strval = str.c_str(); + const char * strval = str.c_str(); std::string tmp; - while((i < (no_elements() + 1)) && - (strcmp((char *)StrToUpper(strval, tmp), - element_at(i)) != 0)) { + while( ( i < ( no_elements() + 1 ) ) && + ( strcmp( ( char * )StrToUpper( strval, tmp ), + element_at( i ) ) != 0 ) ) { ++i; } - if((no_elements() + 1) == i) { + if( ( no_elements() + 1 ) == i ) { // exhausted all the possible values - err->GreaterSeverity(SEVERITY_WARNING); - err->AppendToDetailMsg("Invalid Enumeration value.\n"); - err->AppendToUserMsg("Invalid Enumeration value.\n"); + err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); + err->AppendToUserMsg( "Invalid Enumeration value.\n" ); } else { - if(AssignVal) { + if( AssignVal ) { v = i; } } // now also check the delimiter situation - if(c == '.') { // if found ending delimiter + if( c == '.' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Enumerated value has invalid period delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Enumerated value has invalid period delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched period delimiters for enumeration.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched period delimiters for enumeration.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if((c == '.') || !validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); + else if( ( c == '.' ) || !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -249,21 +233,21 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if((c == ',') || (c == ')')) { - in.putback(c); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( ( c == ',' ) || ( c == ')' ) ) { + in.putback( c ); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } else { - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid enumeration value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid enumeration value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } @@ -272,57 +256,48 @@ Severity SDAI_LOGICAL::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal // class BOOLEAN Jan 97 /////////////////////////////////////////////////////////////////////////////// -const char *SDAI_BOOLEAN::Name() const -{ +const char * SDAI_BOOLEAN::Name() const { return "Bool"; } -SDAI_BOOLEAN::SDAI_BOOLEAN(char *val) -{ - set_value(val); +SDAI_BOOLEAN::SDAI_BOOLEAN( char * val ) { + set_value( val ); } -SDAI_BOOLEAN::SDAI_BOOLEAN(Boolean state) -{ - set_value(state); +SDAI_BOOLEAN::SDAI_BOOLEAN( Boolean state ) { + set_value( state ); } -SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_BOOLEAN &source) -{ - set_value(source.asInt()); +SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_BOOLEAN & source ) { + set_value( source.asInt() ); } -SDAI_BOOLEAN::~SDAI_BOOLEAN() -{ +SDAI_BOOLEAN::~SDAI_BOOLEAN() { } -int SDAI_BOOLEAN::no_elements() const -{ +int SDAI_BOOLEAN::no_elements() const { return 2; } -SDAI_BOOLEAN::SDAI_BOOLEAN(int i) -{ - if(i == 0) { +SDAI_BOOLEAN::SDAI_BOOLEAN( int i ) { + if( i == 0 ) { v = BFalse ; } else { v = BTrue ; } } -SDAI_BOOLEAN::SDAI_BOOLEAN(const SDAI_LOGICAL &val) -{ - if(val.asInt() == LUnknown) { +SDAI_BOOLEAN::SDAI_BOOLEAN( const SDAI_LOGICAL & val ) { + if( val.asInt() == LUnknown ) { // this should set error code sdaiVT_NVLD i.e. Invalid value type. v = BUnset; return; } - set_value(val); + set_value( val ); } -SDAI_BOOLEAN::operator Boolean() const -{ - switch(v) { +SDAI_BOOLEAN::operator Boolean() const { + switch( v ) { case BFalse : return BFalse ; case BTrue : @@ -333,27 +308,18 @@ SDAI_BOOLEAN::operator Boolean() const } } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_LOGICAL &t) -{ - set_value(t.asInt()); +SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_LOGICAL & t ) { + set_value( t.asInt() ); return *this; } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const SDAI_BOOLEAN &t) -{ +SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const Boolean t ) { v = t; return *this; } -SDAI_BOOLEAN &SDAI_BOOLEAN::operator= (const Boolean t) -{ - v = t; - return *this; -} - -const char *SDAI_BOOLEAN::element_at(int n) const -{ - switch(n) { +const char * SDAI_BOOLEAN::element_at( int n ) const { + switch( n ) { case BFalse : return "F"; case BTrue : @@ -363,9 +329,8 @@ const char *SDAI_BOOLEAN::element_at(int n) const } } -SDAI_LOGICAL SDAI_BOOLEAN::operator ==(const SDAI_LOGICAL &t) const -{ - if(v == t.asInt()) { +SDAI_LOGICAL SDAI_BOOLEAN::operator ==( const SDAI_LOGICAL & t ) const { + if( v == t.asInt() ) { return LTrue ; } return LFalse ; @@ -373,40 +338,35 @@ SDAI_LOGICAL SDAI_BOOLEAN::operator ==(const SDAI_LOGICAL &t) const /////////////////////////////////////////////////////////////////////////////// -SDAI_Enum::SDAI_Enum() -{ +SDAI_Enum::SDAI_Enum() { v = 0; } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put(int val) -{ - return set_value(val); +int SDAI_Enum::put( int val ) { + return set_value( val ); } /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::put(const char *n) -{ - return set_value(n); +int SDAI_Enum::put( const char * n ) { + return set_value( n ); } /// return 0 if unset otherwise return 1 /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? -int SDAI_Enum::exists() const -{ - return !(v > no_elements()); +int SDAI_Enum::exists() const { + return !( v > no_elements() ); } /** * change the receiver to an unset status * unset is generated to be 1 greater than last element */ -void SDAI_Enum::nullify() -{ - set_value(no_elements() + 1); +void SDAI_Enum::nullify() { + set_value( no_elements() + 1 ); } /**************************************************************//** @@ -414,20 +374,19 @@ void SDAI_Enum::nullify() ** debugging purposes ** Status: ok 2/1/91 ******************************************************************/ -void SDAI_Enum::DebugDisplay(ostream &out) const -{ +void SDAI_Enum::DebugDisplay( ostream & out ) const { std::string tmp; out << "Current " << Name() << " value: " << endl << " cardinal: " << v << endl - << " string: " << asStr(tmp) << endl + << " string: " << asStr( tmp ) << endl << " Part 21 file format: "; - STEPwrite(out); + STEPwrite( out ); out << endl; out << "Valid values are: " << endl; int i = 0; - while(i < (no_elements() + 1)) { - out << i << " " << element_at(i) << endl; + while( i < ( no_elements() + 1 ) ) { + out << i << " " << element_at( i ) << endl; i++; } out << "\n"; @@ -448,10 +407,9 @@ void SDAI_Enum::DebugDisplay(ostream &out) const ** true => delimiters must be valid; ** true or false => non-matching delimiters are flagged as an error */ -Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, - int needDelims) -{ - if(AssignVal) { +Severity SDAI_Enum::ReadEnum( istream & in, ErrorDescriptor * err, int AssignVal, + int needDelims ) { + if( AssignVal ) { set_null(); } @@ -461,85 +419,85 @@ Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, in >> ws; // skip white space - if(in.good()) { + if( in.good() ) { char c; - in.get(c); - if(c == '.' || isalpha(c)) { + in.get( c ); + if( c == '.' || isalpha( c ) ) { int validDelimiters = 1; - if(c == '.') { - in.get(c); // push past the delimiter + if( c == '.' ) { + in.get( c ); // push past the delimiter // since found a valid delimiter it is now invalid until the // matching ending delim is found validDelimiters = 0; } // look for UPPER - if(in.good() && (isalpha(c) || c == '_')) { + if( in.good() && ( isalpha( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // look for UPPER or DIGIT - while(in.good() && (isalnum(c) || c == '_')) { + while( in.good() && ( isalnum( c ) || c == '_' ) ) { str += c; - in.get(c); + in.get( c ); } // if character is not the delimiter unread it - if(in.good() && (c != '.')) { - in.putback(c); + if( in.good() && ( c != '.' ) ) { + in.putback( c ); } // a value was read - if(str.length() > 0) { + if( str.length() > 0 ) { int i = 0; - const char *strval = str.c_str(); + const char * strval = str.c_str(); std::string tmp; - while((i < no_elements()) && - (strcmp((char *)StrToUpper(strval, tmp), - element_at(i)) != 0)) { + while( ( i < no_elements() ) && + ( strcmp( ( char * )StrToUpper( strval, tmp ), + element_at( i ) ) != 0 ) ) { ++i; } - if(no_elements() == i) { + if( no_elements() == i ) { // exhausted all the possible values - err->GreaterSeverity(SEVERITY_WARNING); - err->AppendToDetailMsg("Invalid Enumeration value.\n"); - err->AppendToUserMsg("Invalid Enumeration value.\n"); + err->GreaterSeverity( SEVERITY_WARNING ); + err->AppendToDetailMsg( "Invalid Enumeration value.\n" ); + err->AppendToUserMsg( "Invalid Enumeration value.\n" ); } else { - if(AssignVal) { + if( AssignVal ) { v = i; } } // now also check the delimiter situation - if(c == '.') { // if found ending delimiter + if( c == '.' ) { // if found ending delimiter // if expecting delim (i.e. validDelimiter == 0) - if(!validDelimiters) { + if( !validDelimiters ) { validDelimiters = 1; // everything is fine } else { // found ending delimiter but no initial delimiter validDelimiters = 0; } } // didn't find any delimiters at all and need them. - else if(needDelims) { + else if( needDelims ) { validDelimiters = 0; } - if(!validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); - if(needDelims) - sprintf(messageBuf, - "Enumerated value has invalid period delimiters.\n"); + if( !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); + if( needDelims ) + sprintf( messageBuf, + "Enumerated value has invalid period delimiters.\n" ); else - sprintf(messageBuf, - "Mismatched period delimiters for enumeration.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + sprintf( messageBuf, + "Mismatched period delimiters for enumeration.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } return err->severity(); } // found valid or invalid delimiters with no associated value - else if((c == '.') || !validDelimiters) { - err->GreaterSeverity(SEVERITY_WARNING); + else if( ( c == '.' ) || !validDelimiters ) { + err->GreaterSeverity( SEVERITY_WARNING ); err->AppendToDetailMsg( "Enumerated has valid or invalid period delimiters with no value.\n" ); @@ -548,59 +506,55 @@ Severity SDAI_Enum::ReadEnum(istream &in, ErrorDescriptor *err, int AssignVal, ); return err->severity(); } else { // no delims and no value - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if((c == ',') || (c == ')')) { - in.putback(c); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( ( c == ',' ) || ( c == ')' ) ) { + in.putback( c ); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } else { - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid enumeration value.\n"); - err->AppendToDetailMsg(messageBuf); - err->AppendToUserMsg(messageBuf); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid enumeration value.\n" ); + err->AppendToDetailMsg( messageBuf ); + err->AppendToUserMsg( messageBuf ); } } else { // hit eof (assuming there was no error state for istream passed in) - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } return err->severity(); } -Severity SDAI_Enum::StrToVal(const char *s, ErrorDescriptor *err, int optional) -{ - istringstream in((char *)s); // sz defaults to length of s +Severity SDAI_Enum::StrToVal( const char * s, ErrorDescriptor * err, int optional ) { + istringstream in( ( char * )s ); // sz defaults to length of s - ReadEnum(in, err, 1, 0); - if((err->severity() == SEVERITY_INCOMPLETE) && optional) { - err->severity(SEVERITY_NULL); + ReadEnum( in, err, 1, 0 ); + if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread(const char *s, ErrorDescriptor *err, int optional) -{ - istringstream in((char *)s); - return STEPread(in, err, optional); +Severity SDAI_Enum::STEPread( const char * s, ErrorDescriptor * err, int optional ) { + istringstream in( ( char * )s ); + return STEPread( in, err, optional ); } /// reads an enumerated value in STEP file format -Severity SDAI_Enum::STEPread(istream &in, ErrorDescriptor *err, int optional) -{ - ReadEnum(in, err, 1, 1); - if((err->severity() == SEVERITY_INCOMPLETE) && optional) { - err->severity(SEVERITY_NULL); +Severity SDAI_Enum::STEPread( istream & in, ErrorDescriptor * err, int optional ) { + ReadEnum( in, err, 1, 1 ); + if( ( err->severity() == SEVERITY_INCOMPLETE ) && optional ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } -const char *SDAI_Enum::asStr(std::string &s) const -{ - if(exists()) { - s = element_at(v); +const char * SDAI_Enum::asStr( std::string & s ) const { + if( exists() ) { + s = element_at( v ); return s.c_str(); } else { s.clear(); @@ -608,74 +562,70 @@ const char *SDAI_Enum::asStr(std::string &s) const } } -void SDAI_Enum::STEPwrite(ostream &out) const -{ - if(is_null()) { +void SDAI_Enum::STEPwrite( ostream & out ) const { + if( is_null() ) { out << '$'; } else { std::string tmp; - out << "." << asStr(tmp) << "."; + out << "." << asStr( tmp ) << "."; } } -const char *SDAI_Enum::STEPwrite(std::string &s) const -{ - if(is_null()) { +const char * SDAI_Enum::STEPwrite( std::string & s ) const { + if( is_null() ) { s.clear(); } else { std::string tmp; s = "."; - s.append(asStr(tmp)); - s.append("."); + s.append( asStr( tmp ) ); + s.append( "." ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -Severity SDAI_Enum::EnumValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - if(clearError) { +Severity SDAI_Enum::EnumValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + if( clearError ) { err->ClearErrorMsg(); } in >> ws; // skip white space char c = ' '; c = in.peek(); - if(c == '$' || in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( c == '$' || in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - if(in) { + if( in ) { in >> c; } - CheckRemainingInput(in, err, "enumeration", tokenList); + CheckRemainingInput( in, err, "enumeration", tokenList ); return err->severity(); } else { ErrorDescriptor error; - ReadEnum(in, &error, 0, needDelims); - CheckRemainingInput(in, &error, "enumeration", tokenList); + ReadEnum( in, &error, 0, needDelims ); + CheckRemainingInput( in, &error, "enumeration", tokenList ); Severity sev = error.severity(); - if(sev < SEVERITY_INCOMPLETE) { - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); - } else if(sev == SEVERITY_INCOMPLETE && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( sev < SEVERITY_INCOMPLETE ) { + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); + } else if( sev == SEVERITY_INCOMPLETE && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -Severity SDAI_Enum::EnumValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims, int clearError) -{ - istringstream in((char *)value); - return EnumValidLevel(in, err, optional, tokenList, needDelims, - clearError); +Severity SDAI_Enum::EnumValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims, int clearError ) { + istringstream in( ( char * )value ); + return EnumValidLevel( in, err, optional, tokenList, needDelims, + clearError ); } /**************************************************************//** @@ -689,20 +639,19 @@ Severity SDAI_Enum::EnumValidLevel(const char *value, ErrorDescriptor *err, ** Status: ok 2.91 ** \returns: value set ******************************************************************/ -int SDAI_Enum::set_value(const char *n) -{ - if(!n || (!strcmp(n, ""))) { +int SDAI_Enum::set_value( const char * n ) { + if( !n || ( !strcmp( n, "" ) ) ) { nullify(); return asInt(); } int i = 0; std::string tmp; - while((i < no_elements()) && - (strcmp((char *)StrToUpper(n, tmp), element_at(i)) != 0)) { + while( ( i < no_elements() ) && + ( strcmp( ( char * )StrToUpper( n, tmp ), element_at( i ) ) != 0 ) ) { ++i; } - if(no_elements() == i) { // exhausted all the possible values + if( no_elements() == i ) { // exhausted all the possible values return v = no_elements() + 1; // defined as UNSET } v = i; @@ -713,15 +662,14 @@ int SDAI_Enum::set_value(const char *n) /** * \copydoc set_value( const char * n ) */ -int SDAI_Enum::set_value(const int i) -{ - if(i > no_elements()) { +int SDAI_Enum::set_value( const int i ) { + if( i > no_elements() ) { v = no_elements() + 1; return v; } - const char *tmp = element_at(i); - if(tmp[0] != '\0') { - return (v = i); + const char * tmp = element_at( i ); + if( tmp[0] != '\0' ) { + return ( v = i ); } // otherwise cerr << "(OLD Warning:) invalid enumeration value " << i @@ -730,22 +678,19 @@ int SDAI_Enum::set_value(const int i) return no_elements() + 1 ; } -SDAI_Enum &SDAI_Enum::operator= (const int i) -{ - put(i); +SDAI_Enum & SDAI_Enum::operator= ( const int i ) { + put( i ); return *this; } -SDAI_Enum &SDAI_Enum::operator= (const SDAI_Enum &Senum) -{ - put(Senum.asInt()); +SDAI_Enum & SDAI_Enum::operator= ( const SDAI_Enum & Senum ) { + put( Senum.asInt() ); return *this; } -ostream &operator<< (ostream &out, const SDAI_Enum &a) -{ +ostream & operator<< ( ostream & out, const SDAI_Enum & a ) { std::string tmp; - out << a.asStr(tmp); + out << a.asStr( tmp ); return out; } diff --git a/src/cldai/sdaiEnum.h b/src/cldai/sdaiEnum.h index 320208c1d..c883f2be6 100644 --- a/src/cldai/sdaiEnum.h +++ b/src/cldai/sdaiEnum.h @@ -15,76 +15,70 @@ #include #include -class SC_DAI_EXPORT SDAI_Enum -{ - friend ostream &operator<< (ostream &, const SDAI_Enum &); +class SC_DAI_EXPORT SDAI_Enum { + friend ostream & operator<< ( ostream &, const SDAI_Enum & ); protected: int v; // integer value of enumeration instance // mapped to a symbolic value in the elements - virtual int set_value(const char *n); - virtual int set_value(const int n); + virtual int set_value( const char * n ); + virtual int set_value( const int n ); SDAI_Enum(); public: virtual ~SDAI_Enum() {}; - void PrintContents(ostream &out = std::cout) const - { - DebugDisplay(out); + void PrintContents( ostream & out = std::cout ) const { + DebugDisplay( out ); } virtual int no_elements() const = 0; - virtual const char *Name() const = 0; - const char *get_value_at(int n) const - { - return element_at(n); + virtual const char * Name() const = 0; + const char * get_value_at( int n ) const { + return element_at( n ); } - virtual const char *element_at(int n) const = 0; + virtual const char * element_at( int n ) const = 0; - Severity EnumValidLevel(const char *value, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity EnumValidLevel( const char * value, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); - Severity EnumValidLevel(istream &in, ErrorDescriptor *err, - int optional, char *tokenList, - int needDelims = 0, int clearError = 1); + Severity EnumValidLevel( istream & in, ErrorDescriptor * err, + int optional, char * tokenList, + int needDelims = 0, int clearError = 1 ); - int asInt() const - { + int asInt() const { return v; } - const char *asStr(std::string &s) const; - void STEPwrite(ostream &out = std::cout) const; - const char *STEPwrite(std::string &s) const; + const char * asStr( std::string & s ) const; + void STEPwrite( ostream & out = std::cout ) const; + const char * STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s, ErrorDescriptor *err, int optional = 1); - Severity STEPread(istream &in, ErrorDescriptor *err, int optional = 1); - Severity STEPread(const char *s, ErrorDescriptor *err, int optional = 1); + Severity StrToVal( const char * s, ErrorDescriptor * err, int optional = 1 ); + Severity STEPread( istream & in, ErrorDescriptor * err, int optional = 1 ); + Severity STEPread( const char * s, ErrorDescriptor * err, int optional = 1 ); - virtual int put(int val); - virtual int put(const char *n); - bool is_null() const - { - return (exists() == 0); + virtual int put( int val ); + virtual int put( const char * n ); + bool is_null() const { + return ( exists() == 0 ); } - void set_null() - { + void set_null() { nullify(); } - SDAI_Enum &operator= (const int); - SDAI_Enum &operator= (const SDAI_Enum &); + SDAI_Enum & operator= ( const int ); + SDAI_Enum & operator= ( const SDAI_Enum & ); /// WARNING it appears that exists() will return true after a call to nullify(). is this intended? ///FIXME need to rewrite this function, but strange implementation... virtual int exists() const; virtual void nullify(); - void DebugDisplay(ostream &out = std::cout) const; + void DebugDisplay( ostream & out = std::cout ) const; protected: - virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, - int AssignVal = 1, int needDelims = 1); + virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, + int AssignVal = 1, int needDelims = 1 ); }; @@ -96,60 +90,57 @@ enum Boolean { BFalse, BTrue, BUnset }; enum Logical { LFalse, LTrue, LUnset, LUnknown }; class SC_DAI_EXPORT SDAI_LOGICAL : - public SDAI_Enum -{ + public SDAI_Enum { public: - const char *Name() const; + const char * Name() const; - SDAI_LOGICAL(const char *val = 0); - SDAI_LOGICAL(Logical state); - SDAI_LOGICAL(const SDAI_LOGICAL &source); - SDAI_LOGICAL(int i); + SDAI_LOGICAL( const char * val = 0 ); + SDAI_LOGICAL( Logical state ); + SDAI_LOGICAL( const SDAI_LOGICAL & source ); + SDAI_LOGICAL( int i ); virtual ~SDAI_LOGICAL(); virtual int no_elements() const; - virtual const char *element_at(int n) const; + virtual const char * element_at( int n ) const; operator Logical() const; - SDAI_LOGICAL &operator=(const SDAI_LOGICAL &t); + SDAI_LOGICAL & operator=( const SDAI_LOGICAL & t ); - SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; + SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; // these 2 are redefined because LUnknown has cardinal value > LUnset int exists() const; // return 0 if unset otherwise return 1 void nullify(); // change the receiver to an unset status protected: - virtual int set_value(const int n); - virtual int set_value(const char *n); - virtual Severity ReadEnum(istream &in, ErrorDescriptor *err, - int AssignVal = 1, int needDelims = 1); + virtual int set_value( const int n ); + virtual int set_value( const char * n ); + virtual Severity ReadEnum( istream & in, ErrorDescriptor * err, + int AssignVal = 1, int needDelims = 1 ); }; class SC_DAI_EXPORT SDAI_BOOLEAN : - public SDAI_Enum -{ + public SDAI_Enum { public: - const char *Name() const; + const char * Name() const; - SDAI_BOOLEAN(char *val = 0); - SDAI_BOOLEAN(::Boolean state); - SDAI_BOOLEAN(const SDAI_BOOLEAN &source); - SDAI_BOOLEAN(int i); - SDAI_BOOLEAN(const SDAI_LOGICAL &val); + SDAI_BOOLEAN( char * val = 0 ); + SDAI_BOOLEAN( ::Boolean state ); + SDAI_BOOLEAN( const SDAI_BOOLEAN & source ); + SDAI_BOOLEAN( int i ); + SDAI_BOOLEAN( const SDAI_LOGICAL & val ); virtual ~SDAI_BOOLEAN(); virtual int no_elements() const; - virtual const char *element_at(int n) const; + virtual const char * element_at( int n ) const; operator ::Boolean() const; - SDAI_BOOLEAN &operator=(const SDAI_LOGICAL &t); - SDAI_BOOLEAN &operator=(const SDAI_BOOLEAN &t); + SDAI_BOOLEAN & operator=( const SDAI_LOGICAL & t ); - SDAI_BOOLEAN &operator=(const ::Boolean t); - SDAI_LOGICAL operator==(const SDAI_LOGICAL &t) const; + SDAI_BOOLEAN & operator=( const ::Boolean t ); + SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; }; diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index 89636fbec..67140916a 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -4,91 +4,76 @@ ///////// SDAI_Model_contents_instances -SDAI_Model_contents_instances::SDAI_Model_contents_instances() -{ +SDAI_Model_contents_instances::SDAI_Model_contents_instances( ) { } -SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() -{ +SDAI_Model_contents_instances ::~SDAI_Model_contents_instances() { } ///////// SDAI_Model_contents -SDAI_Model_contents::SDAI_Model_contents() -{ +SDAI_Model_contents::SDAI_Model_contents( ) { } -SDAI_Model_contents ::~SDAI_Model_contents() -{ +SDAI_Model_contents ::~SDAI_Model_contents() { } // const Entity_instance__set_var instances() const; //const SDAIAGGRH(Set, EntityInstanceH) Instances() const; SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() -{ +SDAI_Model_contents::instances_() { return &_instances; } SDAI_Model_contents_instances_ptr -SDAI_Model_contents::instances_() const -{ - return (SDAI_Model_contents_instances_ptr) &_instances; +SDAI_Model_contents::instances_() const { + return ( const SDAI_Model_contents_instances_ptr ) &_instances; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() -{ +SDAI_Model_contents::folders_() { return &_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::folders_() const -{ - return (SDAI_Entity_extent__set_var)&_folders; +SDAI_Model_contents::folders_() const { + return ( const SDAI_Entity_extent__set_var )&_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() -{ +SDAI_Model_contents::populated_folders_() { return &_populated_folders; } SDAI_Entity_extent__set_var -SDAI_Model_contents::populated_folders_() const -{ - return (SDAI_Entity_extent__set_var)&_populated_folders; +SDAI_Model_contents::populated_folders_() const { + return ( const SDAI_Entity_extent__set_var )&_populated_folders; } -SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid(const SDAI_DAObject_ptr &d) const -{ +SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid( const SDAI_DAObject_ptr & d ) const { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::get_object_pid() unimplemented!" << std::endl; (void) d; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::lookup(const SDAI_PID_DA_ptr &p) const -{ +SDAI_DAObject_ptr SDAI_Model_contents::lookup( const SDAI_PID_DA_ptr & p ) const { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::lookup() unimplemented!" << std::endl; (void) p; //unused return 0; } -SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance(const char *Type) -{ +SDAI_DAObject_ptr SDAI_Model_contents::CreateEntityInstance( const char * Type ) { std::cerr << __FILE__ << ":" << __LINE__ << " - SDAI_Model_contents::CreateEntityInstance() unimplemented!" << std::endl; (void) Type; //unused return 0; } -void SDAI_Model_contents::AddInstance(const SDAI_DAObject_SDAI_ptr &appInst) -{ - _instances.contents_()->Append(appInst); +void SDAI_Model_contents::AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ) { + _instances.contents_()->Append( appInst ); } -void SDAI_Model_contents::RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst) -{ - _instances.contents_()->Remove(_instances.contents_()->Index(appInst)); +void SDAI_Model_contents::RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ) { + _instances.contents_()->Remove( _instances.contents_()->Index( appInst ) ); } @@ -96,23 +81,19 @@ void SDAI_Model_contents::RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst) #if 0 // for now Any_var -SDAI_Model_contents::GetEntity_extent(const std::string &entityName) -{ +SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) { } const Any_var -SDAI_Model_contents::GetEntity_extent(const std::string &entityName) const -{ +SDAI_Model_contents::GetEntity_extent( const std::string & entityName ) const { } Any_var -SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) -{ +SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) { } const Any_var -SDAI_Model_contents::GetEntity_extent(const Entity_ptr &ep) const -{ +SDAI_Model_contents::GetEntity_extent( const Entity_ptr & ep ) const { } #endif diff --git a/src/cldai/sdaiModel_contents.h b/src/cldai/sdaiModel_contents.h index 86dec9cad..5795232dc 100644 --- a/src/cldai/sdaiModel_contents.h +++ b/src/cldai/sdaiModel_contents.h @@ -26,8 +26,7 @@ // The class SDAI_Model_contents_instances shall implement convenience functions by // SDAI_Model_contents in this part of ISO 10303 -class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject -{ +class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject { public: SDAI_DAObject__set _instances; @@ -37,13 +36,11 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject // This function shall return the set of DAObjects contained in // the receiver. - SDAI_DAObject__set_var contents_() - { + SDAI_DAObject__set_var contents_() { return &_instances; } - SDAI_DAObject__set_var contents_() const - { - return (SDAI_DAObject__set_var) &_instances; + SDAI_DAObject__set_var contents_() const { + return ( const SDAI_DAObject__set_var ) &_instances; } }; @@ -55,8 +52,7 @@ SDAI_Model_contents_instances_var; // Model_contents_ptr def pushed ahead of #include for Entity_extent -class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance -{ +class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance { //friend class SDAI_Model; @@ -93,9 +89,9 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance SDAI_Entity_extent__set_var populated_folders_(); SDAI_PID_DA_ptr - get_object_pid(const SDAI_DAObject_ptr &d) const; + get_object_pid( const SDAI_DAObject_ptr & d ) const; - SDAI_DAObject_ptr lookup(const SDAI_PID_DA_ptr &p) const; + SDAI_DAObject_ptr lookup( const SDAI_PID_DA_ptr & p ) const; /* SDAI operation declarations @@ -107,10 +103,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance // private: public: // for now at least SDAI_DAObject_ptr - CreateEntityInstance(const char *Type); + CreateEntityInstance( const char * Type ); // until we find out what this should really be in the spec - void AddInstance(const SDAI_DAObject_SDAI_ptr &appInst); + void AddInstance( const SDAI_DAObject_SDAI_ptr & appInst ); // void AddInstance(const Entity_instance_ptr& entityHandle); //void AddInstance(EntityInstanceH& entityHandle); /* Function: @@ -135,7 +131,7 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance */ // until we find out what this should really be in the spec - void RemoveInstance(SDAI_DAObject_SDAI_ptr &appInst); + void RemoveInstance( SDAI_DAObject_SDAI_ptr & appInst ); // void RemoveInstance(Entity_instance_ptr& entityHandle); //void RemoveInstance(EntityInstanceH& entityHandle); /* Function @@ -166,10 +162,10 @@ class SC_DAI_EXPORT SDAI_Model_contents : public SDAI_Session_instance */ #ifdef SDAI_CPP_LATE_BINDING #if 0 // for now - Any_var GetEntity_extent(const std::string &entityName); - const Any_var GetEntity_extent(const std::string &entityName) const; - Any_var GetEntity_extent(const Entity_ptr &ep); - const Any_var GetEntity_extent(const Entity_ptr &ep) const; + Any_var GetEntity_extent( const std::string & entityName ); + const Any_var GetEntity_extent( const std::string & entityName ) const; + Any_var GetEntity_extent( const Entity_ptr & ep ); + const Any_var GetEntity_extent( const Entity_ptr & ep ) const; #endif /* Function: The GetEntity_extent function shall retrieve an entity folder from diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index 9d0f24a56..8f6440e8e 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -30,92 +30,85 @@ #ifndef HAVE_MEMMOVE extern "C" { - void *memmove(void *__s1, const void *__s2, size_t __n); + void * memmove( void * __s1, const void * __s2, size_t __n ); } #endif /*****************************************************************************/ -SDAI_Model_contents__list::SDAI_Model_contents__list(int defaultSize) -{ +SDAI_Model_contents__list::SDAI_Model_contents__list( int defaultSize ) { _bufsize = defaultSize; _buf = new SDAI_Model_contents_ptr[_bufsize]; _count = 0; } -SDAI_Model_contents__list::~SDAI_Model_contents__list() -{ +SDAI_Model_contents__list::~SDAI_Model_contents__list() { delete _buf; } -void SDAI_Model_contents__list::Check(int index) -{ +void SDAI_Model_contents__list::Check( int index ) { - SDAI_Model_contents_ptr *newbuf; + SDAI_Model_contents_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Model_contents_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(SDAI_Model_contents_ptr)); + memmove( newbuf, _buf, _count * sizeof( SDAI_Model_contents_ptr ) ); delete _buf; _buf = newbuf; } } void -SDAI_Model_contents__list::Insert(SDAI_Model_contents_ptr v, int index) -{ +SDAI_Model_contents__list::Insert( SDAI_Model_contents_ptr v, int index ) { - SDAI_Model_contents_ptr *spot; - index = (index < 0) ? _count : index; + SDAI_Model_contents_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Append(SDAI_Model_contents_ptr v) -{ +void SDAI_Model_contents__list::Append( SDAI_Model_contents_ptr v ) { int index = _count; - SDAI_Model_contents_ptr *spot; + SDAI_Model_contents_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void SDAI_Model_contents__list::Remove(int index) -{ +void SDAI_Model_contents__list::Remove( int index ) { - if(0 <= index && index < _count) { + if( 0 <= index && index < _count ) { --_count; - SDAI_Model_contents_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(SDAI_Model_contents_ptr)); + SDAI_Model_contents_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( SDAI_Model_contents_ptr ) ); } } -int SDAI_Model_contents__list::Index(SDAI_Model_contents_ptr v) -{ +int SDAI_Model_contents__list::Index( SDAI_Model_contents_ptr v ) { - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } @@ -123,36 +116,31 @@ int SDAI_Model_contents__list::Index(SDAI_Model_contents_ptr v) } SDAI_Model_contents_ptr -SDAI_Model_contents__list::retrieve(int index) -{ - return operator[](index); +SDAI_Model_contents__list::retrieve( int index ) { + return operator[]( index ); } SDAI_Model_contents_ptr & -SDAI_Model_contents__list::operator[](int index) -{ +SDAI_Model_contents__list::operator[]( int index ) { - Check(index); + Check( index ); // _count = max(_count, index+1); - _count = ((_count > index + 1) ? _count : (index + 1)); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } int -SDAI_Model_contents__list::Count() -{ +SDAI_Model_contents__list::Count() { return _count; } int -SDAI_Model_contents__list::is_empty() -{ +SDAI_Model_contents__list::is_empty() { return _count; } void -SDAI_Model_contents__list::Clear() -{ +SDAI_Model_contents__list::Clear() { _count = 0; } diff --git a/src/cldai/sdaiModel_contents_list.h b/src/cldai/sdaiModel_contents_list.h index 58bd13eb6..47e98a072 100644 --- a/src/cldai/sdaiModel_contents_list.h +++ b/src/cldai/sdaiModel_contents_list.h @@ -3,29 +3,28 @@ #include -class SC_DAI_EXPORT SDAI_Model_contents__list -{ +class SC_DAI_EXPORT SDAI_Model_contents__list { public: - SDAI_Model_contents__list(int = 16); + SDAI_Model_contents__list( int = 16 ); ~SDAI_Model_contents__list(); - SDAI_Model_contents_ptr retrieve(int index); + SDAI_Model_contents_ptr retrieve( int index ); int is_empty(); - SDAI_Model_contents_ptr &operator[](int index); + SDAI_Model_contents_ptr & operator[]( int index ); - void Insert(SDAI_Model_contents_ptr, int index); - void Append(SDAI_Model_contents_ptr); - void Remove(int index); - int Index(SDAI_Model_contents_ptr); + void Insert( SDAI_Model_contents_ptr, int index ); + void Append( SDAI_Model_contents_ptr ); + void Remove( int index ); + int Index( SDAI_Model_contents_ptr ); void Clear(); int Count(); private: - void Check(int index); + void Check( int index ); private: - SDAI_Model_contents_ptr *_buf; + SDAI_Model_contents_ptr * _buf; int _bufsize; int _count; }; diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index f68838b29..14cf6c26a 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,10 +1,8 @@ #include #include "sc_memmgr.h" -SDAI_sdaiObject::SDAI_sdaiObject() -{ +SDAI_sdaiObject::SDAI_sdaiObject() { } -SDAI_sdaiObject::~SDAI_sdaiObject() -{ +SDAI_sdaiObject::~SDAI_sdaiObject() { } diff --git a/src/cldai/sdaiObject.h b/src/cldai/sdaiObject.h index 1479af3f1..99936f17c 100644 --- a/src/cldai/sdaiObject.h +++ b/src/cldai/sdaiObject.h @@ -13,8 +13,7 @@ The class Entity_instance shall be a subtype of the C++ class Object: */ -class SC_DAI_EXPORT SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_sdaiObject { public: SDAI_sdaiObject(); virtual ~SDAI_sdaiObject(); @@ -23,7 +22,7 @@ class SC_DAI_EXPORT SDAI_sdaiObject }; -typedef SDAI_sdaiObject *SDAI_sdaiObject_ptr; +typedef SDAI_sdaiObject * SDAI_sdaiObject_ptr; typedef SDAI_sdaiObject_ptr SDAI_sdaiObject_var; /* diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 7c79543e4..6f48be442 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,10 +1,8 @@ #include #include "sc_memmgr.h" -SDAI_Session_instance::SDAI_Session_instance() -{ +SDAI_Session_instance::SDAI_Session_instance() { } -SDAI_Session_instance::~SDAI_Session_instance() -{ +SDAI_Session_instance::~SDAI_Session_instance() { } diff --git a/src/cldai/sdaiSession_instance.h b/src/cldai/sdaiSession_instance.h index 02c8e7acd..fcc8fad15 100644 --- a/src/cldai/sdaiSession_instance.h +++ b/src/cldai/sdaiSession_instance.h @@ -5,8 +5,7 @@ #include //#include -class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject -{ +class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { public: int x; @@ -15,7 +14,7 @@ class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject virtual ~SDAI_Session_instance(); }; -typedef SDAI_Session_instance *SDAI_Session_instance_ptr; +typedef SDAI_Session_instance * SDAI_Session_instance_ptr; typedef SDAI_Session_instance_ptr SDAI_Session_instance_var; // the old names diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 82c0ac5b4..664a39358 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -13,80 +13,62 @@ #include #include "sc_memmgr.h" -SDAI_String::SDAI_String(const char *str, size_t max) -{ - if(!str) { +SDAI_String::SDAI_String( const char * str, size_t max ) { + if( !str ) { str = ""; } - if(max == std::string::npos) { - content = std::string(str); + if( max == std::string::npos ) { + content = std::string( str ); } else { - content = std::string(str, max); + content = std::string( str, max ); } } -SDAI_String::SDAI_String(const std::string &s) - : content(std::string(s)) -{ +SDAI_String::SDAI_String( const std::string & s ) + : content( std::string( s ) ) { } -SDAI_String::SDAI_String(const SDAI_String &s) - : content(std::string(s.c_str())) -{ +SDAI_String::SDAI_String( const SDAI_String & s ) + : content( std::string( s.c_str() ) ) { } -SDAI_String::~SDAI_String(void) -{ +SDAI_String::~SDAI_String( void ) { } -SDAI_String &SDAI_String::operator= (const char *s) -{ - content = std::string(s); +SDAI_String & SDAI_String::operator= ( const char * s ) { + content = std::string( s ); return *this; } -SDAI_String &SDAI_String::operator= (const SDAI_String &s) -{ - content = s.content; - return *this; -} - -bool SDAI_String::operator== (const char *s) const -{ - return (content == s); +bool SDAI_String::operator== ( const char * s ) const { + return ( content == s ); } -void SDAI_String::clear(void) -{ +void SDAI_String::clear( void ) { content.clear(); } -bool SDAI_String::empty(void) const -{ +bool SDAI_String::empty( void ) const { return content.empty(); } -const char *SDAI_String::c_str(void) const -{ +const char * SDAI_String::c_str( void ) const { return content.c_str(); } -void SDAI_String::STEPwrite(ostream &out) const -{ +void SDAI_String::STEPwrite( ostream & out ) const { out << c_str(); } -void SDAI_String::STEPwrite(std::string &s) const -{ +void SDAI_String::STEPwrite( std::string & s ) const { s += c_str(); } -Severity SDAI_String::StrToVal(const char *s) -{ - operator= (s); - if(! strcmp(c_str(), s)) { +Severity SDAI_String::StrToVal( const char * s ) { + operator= ( s ); + if( ! strcmp( c_str(), s ) ) { return SEVERITY_NULL ; } else { return SEVERITY_INPUT_ERROR; @@ -97,26 +79,25 @@ Severity SDAI_String::StrToVal(const char *s) * STEPread reads a string in exchange file format * starting with a single quote */ -Severity SDAI_String::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity SDAI_String::STEPread( istream & in, ErrorDescriptor * err ) { clear(); // clear the old string // remember the current format state to restore the previous settings ios_base::fmtflags flags = in.flags(); - in.unsetf(ios::skipws); + in.unsetf( ios::skipws ); // extract the string from the inputstream - std::string s = GetLiteralStr(in, err); + std::string s = GetLiteralStr( in, err ); content += s; // retrieve current severity Severity sev = err -> severity(); - if(s.empty()) { + if( s.empty() ) { // no string was read - in.flags(flags); // set the format state back to previous settings - err -> GreaterSeverity(SEVERITY_INCOMPLETE); + in.flags( flags ); // set the format state back to previous settings + err -> GreaterSeverity( SEVERITY_INCOMPLETE ); sev = SEVERITY_INCOMPLETE; - } else if(sev != SEVERITY_INPUT_ERROR) { + } else if( sev != SEVERITY_INPUT_ERROR ) { // read valid string sev = SEVERITY_NULL; } @@ -126,8 +107,7 @@ Severity SDAI_String::STEPread(istream &in, ErrorDescriptor *err) /** * \copydoc STEPread( istream & in, ErrorDescriptor * err ) */ -Severity SDAI_String::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); - return STEPread(in, err); +Severity SDAI_String::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); + return STEPread( in, err ); } diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index f1b3e4fd0..083da80ea 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -12,12 +12,10 @@ */ #include -#include #include -class SC_DAI_EXPORT SDAI_String -{ +class SC_DAI_EXPORT SDAI_String { private: #ifdef _MSC_VER #pragma warning( push ) @@ -31,31 +29,29 @@ class SC_DAI_EXPORT SDAI_String public: //constructor(s) & destructor - SDAI_String(const char *str = "", size_t max = std::string::npos); - SDAI_String(const std::string &s); - SDAI_String(const SDAI_String &s); - ~SDAI_String(void); + SDAI_String( const char * str = "", size_t max = std::string::npos ); + SDAI_String( const std::string & s ); + SDAI_String( const SDAI_String & s ); + ~SDAI_String( void ); // operators - SDAI_String &operator= (const char *s); - SDAI_String &operator= (const SDAI_String &s); - bool operator== (const char *s) const; + SDAI_String & operator= ( const char * s ); + bool operator== ( const char * s ) const; - void clear(void); - bool empty(void) const; - const char *c_str(void) const; + void clear( void ); + bool empty( void ) const; + const char * c_str( void ) const; // format for STEP - const char *asStr(std::string &s) const - { + const char * asStr( std::string & s ) const { s = c_str(); return s.c_str(); } - void STEPwrite(ostream &out = cout) const; - void STEPwrite(std::string &s) const; + void STEPwrite( ostream & out = cout ) const; + void STEPwrite( std::string & s ) const; - Severity StrToVal(const char *s); - Severity STEPread(istream &in, ErrorDescriptor *err); - Severity STEPread(const char *s, ErrorDescriptor *err); + Severity StrToVal( const char * s ); + Severity STEPread( istream & in, ErrorDescriptor * err ); + Severity STEPread( const char * s, ErrorDescriptor * err ); }; diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 6370bcacb..4c40f73fc 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -27,19 +27,19 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) endif() install(FILES ${SC_CLEDITOR_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor) # Local Variables: # tab-width: 8 diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 7b414aa45..cb1fe5bca 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -46,14 +46,13 @@ * * side effects: STEPfile::_fileName value may change. */ -std::string STEPfile::SetFileName(const std::string newName) -{ +std::string STEPfile::SetFileName( const std::string newName ) { // if a newName is not given or is the same as the old, use the old name - if((newName.empty()) || (newName == _fileName)) { + if( ( newName.empty() ) || ( newName == _fileName ) ) { return FileName(); } - _fileName = DirObj::Normalize(newName); + _fileName = DirObj::Normalize( newName ); return _fileName; } @@ -64,14 +63,13 @@ std::string STEPfile::SetFileName(const std::string newName) * * This function is useless unless it is called from another thread. */ -float STEPfile::GetReadProgress() const -{ - if(_iFileSize < 1) { +float STEPfile::GetReadProgress() const { + if( _iFileSize < 1 ) { return -1; } //the file is read once by ReadData1(), and again by ReadData2. Each gets 50%. - float percent = (static_cast(_iFileCurrentPosition) / _iFileSize) * 50.0; - if(_iFileStage1Done) { + float percent = ( static_cast( _iFileCurrentPosition ) / _iFileSize ) * 50.0; + if( _iFileStage1Done ) { percent += 50; } return percent; @@ -86,11 +84,10 @@ float STEPfile::GetReadProgress() const * * This function is useless unless it is called from another thread. */ -float STEPfile::GetWriteProgress() const -{ +float STEPfile::GetWriteProgress() const { int total = _instances.InstanceCount(); - if(total > 0) { - return (static_cast(_oFileInstsWritten) / total) * 100.0; + if( total > 0 ) { + return ( static_cast( _oFileInstsWritten ) / total ) * 100.0; } else { return -1; } @@ -108,12 +105,11 @@ float STEPfile::GetWriteProgress() const * next "ENDSEC;" from in. * The STEPfile::_headerInstances may change. */ -Severity STEPfile::ReadHeader(istream &in) -{ +Severity STEPfile::ReadHeader( istream & in ) { std::string cmtStr; - InstMgr *im = new InstMgr; - SDAI_Application_instance *obj; + InstMgr * im = new InstMgr; + SDAI_Application_instance * obj; Severity objsev = SEVERITY_NULL; int endsec = 0; @@ -125,41 +121,41 @@ Severity STEPfile::ReadHeader(istream &in) std::string strbuf; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); // Read and gobble all 'junk' up to "HEADER;" - if(!FindHeaderSection(in)) { + if( !FindHeaderSection( in ) ) { delete im; return SEVERITY_INPUT_ERROR; } //read the header instances - while(!endsec) { - ReadTokenSeparator(in, &cmtStr); - if(in.eof()) { - _error.AppendToDetailMsg("End of file reached in reading header section.\n"); - _error.GreaterSeverity(SEVERITY_EXIT); + while( !endsec ) { + ReadTokenSeparator( in, &cmtStr ); + if( in.eof() ) { + _error.AppendToDetailMsg( "End of file reached in reading header section.\n" ); + _error.GreaterSeverity( SEVERITY_EXIT ); delete im; return SEVERITY_EXIT; } //check for user defined instances //if it is userDefined, the '!' does not get put back on the istream - in.get(c); - if(c == '!') { + in.get( c ); + if( c == '!' ) { userDefined = 1; } else { - in.putback(c); + in.putback( c ); } //get the entity keyword - keywd = GetKeyword(in, ";( /\\", _error); - ReadTokenSeparator(in, &cmtStr); + keywd = GetKeyword( in, ";( /\\", _error ); + ReadTokenSeparator( in, &cmtStr ); //check for "ENDSEC" - if(!strncmp(const_cast(keywd.c_str()), "ENDSEC", 7)) { + if( !strncmp( const_cast( keywd.c_str() ), "ENDSEC", 7 ) ) { //get the token delimiter - in.get(c); //should be ';' + in.get( c ); //should be ';' endsec = 1; break; //from while-loop } else { @@ -168,69 +164,69 @@ Severity STEPfile::ReadHeader(istream &in) //create header instance buf[0] = '\0'; - if(_fileType == VERSION_OLD) { - _error.AppendToDetailMsg("N279 header detected. Files this old are no longer supported.\n"); - _error.GreaterSeverity(SEVERITY_EXIT); + if( _fileType == VERSION_OLD ) { + _error.AppendToDetailMsg( "N279 header detected. Files this old are no longer supported.\n" ); + _error.GreaterSeverity( SEVERITY_EXIT ); delete im; return SEVERITY_EXIT; } else { - strncpy(buf, const_cast(keywd.c_str()), BUFSIZ); + strncpy( buf, const_cast( keywd.c_str() ), BUFSIZ ); } - if(userDefined) { + if( userDefined ) { //create user defined header instance // BUG: user defined entities are ignored //obj = _headerUserDefined->ObjCreate (buf); //objsev = AppendEntityErrorMsg( &(obj->Error()) ); - SkipInstance(in, strbuf); + SkipInstance( in, strbuf ); cerr << "User defined entity in header section " << "is ignored.\n\tdata lost: !" << buf << strbuf << "\n"; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); break; //from while loop } else { //not userDefined - obj = _headerRegistry->ObjCreate(buf); + obj = _headerRegistry->ObjCreate( buf ); } //read header instance - if(!obj || (obj == ENTITY_NULL)) { + if( !obj || ( obj == ENTITY_NULL ) ) { ++_errorCount; - SkipInstance(in, strbuf); + SkipInstance( in, strbuf ); cerr << "Unable to create header section entity: \'" << keywd << "\'.\n\tdata lost: " << strbuf << "\n"; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); } else { //not ENTITY_NULL //read the header instance - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); //set file_id to reflect the appropriate Header Section Entity - fileid = HeaderId(const_cast(keywd.c_str())); + fileid = HeaderId( const_cast( keywd.c_str() ) ); //read the values from the istream - objsev = obj->STEPread(fileid, 0, (InstMgr *)0, in, NULL, true, _strict); - _error.GreaterSeverity(objsev); - if(!cmtStr.empty()) { - obj->PrependP21Comment(cmtStr); + objsev = obj->STEPread( fileid, 0, ( InstMgr * )0, in, NULL, true, _strict ); + _error.GreaterSeverity( objsev ); + if( !cmtStr.empty() ) { + obj->PrependP21Comment( cmtStr ); } in >> ws; c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } //check to see if object was successfully read - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); //append to header instance manager - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } } cmtStr.clear(); } - HeaderVerifyInstances(im); - HeaderMergeInstances(im); // handles delete for im + HeaderVerifyInstances( im ); + HeaderMergeInstances( im ); // handles delete for im return _error.severity(); } @@ -244,92 +240,88 @@ Severity STEPfile::ReadHeader(istream &in) * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -Severity STEPfile::HeaderVerifyInstances(InstMgr *im) -{ +Severity STEPfile::HeaderVerifyInstances( InstMgr * im ) { int err = 0; int fileid; - SDAI_Application_instance *obj; + SDAI_Application_instance * obj; //check File_Name - fileid = HeaderId("File_Name"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Name" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_NAME instance not found in header section\n"; // create a File_Name entity and assign default values obj = HeaderDefaultFileName(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } //check File_Description - fileid = HeaderId("File_Description"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Description" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_DESCRIPTION instance not found in header section\n"; // create a File_Description entity and assign default values obj = HeaderDefaultFileDescription(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } //check File_Schema - fileid = HeaderId("File_Schema"); - if(!(im->FindFileId(fileid))) { + fileid = HeaderId( "File_Schema" ); + if( !( im->FindFileId( fileid ) ) ) { ++err; cerr << "FILE_SCHEMA instance not found in header section\n"; // create a File_Schema entity and read in default values obj = HeaderDefaultFileSchema(); - im->Append(obj, completeSE); + im->Append( obj, completeSE ); } - if(!err) { + if( !err ) { return SEVERITY_NULL; } - _error.AppendToUserMsg("Missing required entity in header section.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "Missing required entity in header section.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileName() -{ - SdaiFile_name *fn = new SdaiFile_name; +SDAI_Application_instance * STEPfile::HeaderDefaultFileName() { + SdaiFile_name * fn = new SdaiFile_name; StringAggregate_ptr tmp = new StringAggregate; - fn->name_(""); - fn->time_stamp_(""); - tmp->StrToVal("", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances); - fn->author_(tmp); + fn->name_( "" ); + fn->time_stamp_( "" ); + tmp->StrToVal( "", &_error, fn->attributes[2].getADesc()->DomainType(), _headerInstances ); + fn->author_( tmp ); - tmp->StrToVal("", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances); - fn->organization_(tmp); + tmp->StrToVal( "", &_error, fn->attributes[3].getADesc()->DomainType(), _headerInstances ); + fn->organization_( tmp ); - fn->preprocessor_version_(""); - fn->originating_system_(""); - fn->authorization_(""); + fn->preprocessor_version_( "" ); + fn->originating_system_( "" ); + fn->authorization_( "" ); - fn->STEPfile_id = HeaderId("File_Name"); + fn->STEPfile_id = HeaderId( "File_Name" ); return fn; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileDescription() -{ - SdaiFile_description *fd = new SdaiFile_description; +SDAI_Application_instance * STEPfile::HeaderDefaultFileDescription() { + SdaiFile_description * fd = new SdaiFile_description; - fd->implementation_level_(""); + fd->implementation_level_( "" ); - fd->STEPfile_id = HeaderId("File_Description"); + fd->STEPfile_id = HeaderId( "File_Description" ); return fd; } -SDAI_Application_instance *STEPfile::HeaderDefaultFileSchema() -{ - SdaiFile_schema *fs = new SdaiFile_schema; +SDAI_Application_instance * STEPfile::HeaderDefaultFileSchema() { + SdaiFile_schema * fs = new SdaiFile_schema; StringAggregate_ptr tmp = new StringAggregate; - tmp->StrToVal("", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances); - fs->schema_identifiers_(tmp); + tmp->StrToVal( "", &_error, fs->attributes[0].getADesc()->DomainType(), _headerInstances ); + fs->schema_identifiers_( tmp ); - fs->STEPfile_id = HeaderId("File_Schema"); + fs->STEPfile_id = HeaderId( "File_Schema" ); return fs; } @@ -355,30 +347,29 @@ SDAI_Application_instance *STEPfile::HeaderDefaultFileSchema() * #2 = FILE_NAME * #3 = FILE_SCHEMA */ -void STEPfile::HeaderMergeInstances(InstMgr *im) -{ - SDAI_Application_instance *se = 0; - SDAI_Application_instance *from = 0; +void STEPfile::HeaderMergeInstances( InstMgr * im ) { + SDAI_Application_instance * se = 0; + SDAI_Application_instance * from = 0; int idnum; //check for _headerInstances - if(!_headerInstances) { + if( !_headerInstances ) { _headerInstances = im; return; } - if(_headerInstances->InstanceCount() < 4) { + if( _headerInstances->InstanceCount() < 4 ) { delete _headerInstances; _headerInstances = im; return; } //checking for _headerInstances::FILE_NAME - idnum = HeaderId("File_Name"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Name" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); // name: // time_stamp: keep the newer time_stamp @@ -388,34 +379,34 @@ void STEPfile::HeaderMergeInstances(InstMgr *im) // originating_system: // authorization: } else { // No current File_Name instance - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } //checking for _headerInstances::FILE_DESCRIPTION - idnum = HeaderId("File_Description"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Description" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); //description //implementation_level } else { - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } //checking for _headerInstances::FILE_SCHEMA - idnum = HeaderId("File_Schema"); - se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)); - if(se) { - from = im->GetApplication_instance(im->FindFileId(idnum)); + idnum = HeaderId( "File_Schema" ); + se = _headerInstances->GetApplication_instance( _headerInstances->FindFileId( idnum ) ); + if( se ) { + from = im->GetApplication_instance( im->FindFileId( idnum ) ); //description //implementation_level } else { - from = im->GetApplication_instance(im->FindFileId(idnum)); - _headerInstances->Append(from, completeSE); + from = im->GetApplication_instance( im->FindFileId( idnum ) ); + _headerInstances->Append( from, completeSE ); } delete im; @@ -423,9 +414,8 @@ void STEPfile::HeaderMergeInstances(InstMgr *im) } -stateEnum STEPfile::EntityWfState(char c) -{ - switch(c) { +stateEnum STEPfile::EntityWfState( char c ) { + switch( c ) { case wsSaveComplete: return completeSE; case wsSaveIncomplete: @@ -443,8 +433,7 @@ stateEnum STEPfile::EntityWfState(char c) * PASS 1: create instances * starts at the data section */ -int STEPfile::ReadData1(istream &in) -{ +int STEPfile::ReadData1( istream & in ) { int endsec = 0; _entsNotCreated = 0; @@ -457,66 +446,66 @@ int STEPfile::ReadData1(istream &in) buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; stateEnum inst_state = noStateSE; // used if reading working file ErrorDescriptor e; // PASS 1: create instances - endsec = FoundEndSecKywd(in); - while(in.good() && !endsec) { + endsec = FoundEndSecKywd( in ); + while( in.good() && !endsec ) { e.ClearErrorMsg(); - ReadTokenSeparator(in); // also skips white space + ReadTokenSeparator( in ); // also skips white space in >> c; - if(_fileType == WORKING_SESSION) { - if(strchr("CIND", c)) { // if there is a valid char - inst_state = EntityWfState(c); - ReadTokenSeparator(in); + if( _fileType == WORKING_SESSION ) { + if( strchr( "CIND", c ) ) { // if there is a valid char + inst_state = EntityWfState( c ); + ReadTokenSeparator( in ); in >> c; // read the ENTITY_NAME_DELIM } else { - e.AppendToDetailMsg("Invalid editing state character: "); - e.AppendToDetailMsg(c); - e.AppendToDetailMsg("\nAssigning editing state to be INCOMPLETE\n"); - e.GreaterSeverity(SEVERITY_WARNING); + e.AppendToDetailMsg( "Invalid editing state character: " ); + e.AppendToDetailMsg( c ); + e.AppendToDetailMsg( "\nAssigning editing state to be INCOMPLETE\n" ); + e.GreaterSeverity( SEVERITY_WARNING ); inst_state = incompleteSE; } } - if(c != ENTITY_NAME_DELIM) { - in.putback(c); - while(c != ENTITY_NAME_DELIM && in.good() && - !(endsec = FoundEndSecKywd(in))) { + if( c != ENTITY_NAME_DELIM ) { + in.putback( c ); + while( c != ENTITY_NAME_DELIM && in.good() && + !( endsec = FoundEndSecKywd( in ) ) ) { tmpbuf.clear(); - FindStartOfInstance(in, tmpbuf); + FindStartOfInstance( in, tmpbuf ); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } } - if(!endsec) { + if( !endsec ) { obj = ENTITY_NULL; - if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { - SkipInstance(in, tmpbuf); + if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { + SkipInstance( in, tmpbuf ); } else { - obj = CreateInstance(in, cout); + obj = CreateInstance( in, cout ); _iFileCurrentPosition = in.tellg(); } - if(obj != ENTITY_NULL) { - if(obj->Error().severity() < SEVERITY_WARNING) { + if( obj != ENTITY_NULL ) { + if( obj->Error().severity() < SEVERITY_WARNING ) { ++_errorCount; - } else if(obj->Error().severity() < SEVERITY_NULL) { + } else if( obj->Error().severity() < SEVERITY_NULL ) { ++_warningCount; } obj->Error().ClearErrorMsg(); - if(_fileType == WORKING_SESSION) { - instances().Append(obj, inst_state); + if( _fileType == WORKING_SESSION ) { + instances().Append( obj, inst_state ); } else { - instances().Append(obj, newSE); + instances().Append( obj, newSE ); } ++instance_count; @@ -526,46 +515,44 @@ int STEPfile::ReadData1(istream &in) ++_errorCount; } - if(_entsNotCreated > _maxErrorCount) { - _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); + if( _entsNotCreated > _maxErrorCount ) { + _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity(SEVERITY_EXIT); + Error().severity( SEVERITY_EXIT ); return instance_count; } - endsec = FoundEndSecKywd(in); + endsec = FoundEndSecKywd( in ); } } // end while loop - if(_entsNotCreated) { - sprintf(buf, - "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", - _entsNotCreated); - _error.AppendToUserMsg(buf); - _error.GreaterSeverity(SEVERITY_WARNING); + if( _entsNotCreated ) { + sprintf( buf, + "STEPfile Reading File: Unable to create %d instances.\n\tIn first pass through DATA section. Check for invalid entity types.\n", + _entsNotCreated ); + _error.AppendToUserMsg( buf ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - if(!in.good()) { - _error.AppendToUserMsg("Error in input file.\n"); + if( !in.good() ) { + _error.AppendToUserMsg( "Error in input file.\n" ); } _iFileStage1Done = true; return instance_count; } -int STEPfile::ReadWorkingData1(istream &in) -{ - return ReadData1(in); +int STEPfile::ReadWorkingData1( istream & in ) { + return ReadData1( in ); } /** * \returns number of valid instances read * reads in the data portion of the instances in an exchange file */ -int STEPfile::ReadData2(istream &in, bool useTechCor) -{ +int STEPfile::ReadData2( istream & in, bool useTechCor ) { _entsInvalid = 0; _entsIncomplete = 0; _entsWarning = 0; @@ -582,58 +569,58 @@ int STEPfile::ReadData2(istream &in, bool useTechCor) buf[0] = '\0'; std::string tmpbuf; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; std::string cmtStr; - int endsec = FoundEndSecKywd(in); + int endsec = FoundEndSecKywd( in ); // PASS 2: read instances - while(in.good() && !endsec) { - ReadTokenSeparator(in, &cmtStr); + while( in.good() && !endsec ) { + ReadTokenSeparator( in, &cmtStr ); in >> c; - if(_fileType == WORKING_SESSION) { - if(strchr("CIND", c)) { // if there is a valid char - inst_state = EntityWfState(c); - ReadTokenSeparator(in, &cmtStr); + if( _fileType == WORKING_SESSION ) { + if( strchr( "CIND", c ) ) { // if there is a valid char + inst_state = EntityWfState( c ); + ReadTokenSeparator( in, &cmtStr ); in >> c; // read the ENTITY_NAME_DELIM } } - if(c != ENTITY_NAME_DELIM) { - in.putback(c); - while(c != ENTITY_NAME_DELIM && in.good() && - !(endsec = FoundEndSecKywd(in))) { + if( c != ENTITY_NAME_DELIM ) { + in.putback( c ); + while( c != ENTITY_NAME_DELIM && in.good() && + !( endsec = FoundEndSecKywd( in ) ) ) { tmpbuf.clear(); - FindStartOfInstance(in, tmpbuf); + FindStartOfInstance( in, tmpbuf ); cout << "ERROR: trying to recover from invalid data. skipping: " << tmpbuf << endl; in >> c; - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); } } - if(!endsec) { + if( !endsec ) { obj = ENTITY_NULL; - if((_fileType == WORKING_SESSION) && (inst_state == deleteSE)) { - SkipInstance(in, tmpbuf); + if( ( _fileType == WORKING_SESSION ) && ( inst_state == deleteSE ) ) { + SkipInstance( in, tmpbuf ); } else { - obj = ReadInstance(in, cout, cmtStr, useTechCor); + obj = ReadInstance( in, cout, cmtStr, useTechCor ); _iFileCurrentPosition = in.tellg(); } cmtStr.clear(); - if(obj != ENTITY_NULL) { - if(obj->Error().severity() < SEVERITY_INCOMPLETE) { + if( obj != ENTITY_NULL ) { + if( obj->Error().severity() < SEVERITY_INCOMPLETE ) { ++_entsInvalid; // old ++_errorCount; - } else if(obj->Error().severity() == SEVERITY_INCOMPLETE) { + } else if( obj->Error().severity() == SEVERITY_INCOMPLETE ) { ++_entsIncomplete; ++_entsInvalid; - } else if(obj->Error().severity() == SEVERITY_USERMSG) { + } else if( obj->Error().severity() == SEVERITY_USERMSG ) { ++_entsWarning; } else { // i.e. if severity == SEVERITY_NULL ++valid_insts; @@ -648,75 +635,73 @@ int STEPfile::ReadData2(istream &in, bool useTechCor) ++_errorCount; } - if(_entsInvalid > _maxErrorCount) { - _error.AppendToUserMsg("Warning: Too Many Errors in File. Read function aborted.\n"); + if( _entsInvalid > _maxErrorCount ) { + _error.AppendToUserMsg( "Warning: Too Many Errors in File. Read function aborted.\n" ); cerr << Error().UserMsg(); cerr << Error().DetailMsg(); Error().ClearErrorMsg(); - Error().severity(SEVERITY_EXIT); + Error().severity( SEVERITY_EXIT ); return valid_insts; } - endsec = FoundEndSecKywd(in); + endsec = FoundEndSecKywd( in ); } } // end while loop - if(_entsInvalid) { - sprintf(buf, - "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", - "Second pass complete - instance summary:", total_instances, - _entsInvalid, _entsIncomplete, "Warnings", - _entsWarning); + if( _entsInvalid ) { + sprintf( buf, + "%s \n\tTotal instances: %d \n\tInvalid instances: %d \n\tIncomplete instances (includes invalid instances): %d \n\t%s: %d.\n", + "Second pass complete - instance summary:", total_instances, + _entsInvalid, _entsIncomplete, "Warnings", + _entsWarning ); cout << buf << endl; - _error.AppendToUserMsg(buf); - _error.AppendToDetailMsg(buf); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( buf ); + _error.AppendToDetailMsg( buf ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - if(!in.good()) { - _error.AppendToUserMsg("Error in input file.\n"); + if( !in.good() ) { + _error.AppendToUserMsg( "Error in input file.\n" ); } return valid_insts; } -int STEPfile::ReadWorkingData2(istream &in, bool useTechCor) -{ - return ReadData2(in, useTechCor); +int STEPfile::ReadWorkingData2( istream & in, bool useTechCor ) { + return ReadData2( in, useTechCor ); } /** Looks for the word DATA followed by optional whitespace * followed by a semicolon. When it is looking for the word * DATA it skips over strings and comments. */ -int STEPfile::FindDataSection(istream &in) -{ +int STEPfile::FindDataSection( istream & in ) { ErrorDescriptor errs; SDAI_String tmp; std::string s; // used if need to read a comment char c; - while(in.good()) { + while( in.good() ) { in >> c; - if(in.eof()) { - _error.AppendToUserMsg("Can't find \"DATA;\" section."); + if( in.eof() ) { + _error.AppendToUserMsg( "Can't find \"DATA;\" section." ); return 0; //ERROR_WARNING } - switch(c) { + switch( c ) { case 'D': // look for string "DATA;" with optional whitespace after "DATA" c = in.peek(); // look at next char (for 'A') // only peek since it may be 'D' again a we need to start over - if(c == 'A') { - in.get(c); // read char 'A' + if( c == 'A' ) { + in.get( c ); // read char 'A' c = in.peek(); // look for 'T' - if(c == 'T') { - in.get(c); // read 'T' + if( c == 'T' ) { + in.get( c ); // read 'T' c = in.peek(); // look for 'A' - if(c == 'A') { - in.get(c); // read 'A' + if( c == 'A' ) { + in.get( c ); // read 'A' in >> ws; // may want to skip comments or print control directives? c = in.peek(); // look for semicolon - if(c == ';') { - in.get(c); // read the semicolon + if( c == ';' ) { + in.get( c ); // read the semicolon return 1; // success } } @@ -725,13 +710,13 @@ int STEPfile::FindDataSection(istream &in) break; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); + in.putback( c ); + tmp.STEPread( in, &errs ); break; case '/': // read p21 file comment - in.putback(c); // looks like a comment - ReadComment(in, s); + in.putback( c ); // looks like a comment + ReadComment( in, s ); break; case '\0': // problem in input ? @@ -744,23 +729,22 @@ int STEPfile::FindDataSection(istream &in) return 0; } -int STEPfile::FindHeaderSection(istream &in) -{ +int STEPfile::FindHeaderSection( istream & in ) { char buf[BUFSIZ]; - char *b = buf; + char * b = buf; *b = '\0'; - ReadTokenSeparator(in); + ReadTokenSeparator( in ); // find the header section - while(!(b = strstr(buf, "HEADER"))) { - if(in.eof()) { + while( !( b = strstr( buf, "HEADER" ) ) ) { + if( in.eof() ) { _error.AppendToUserMsg( - "Error: Unable to find HEADER section. File not read.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + "Error: Unable to find HEADER section. File not read.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); return 0; } - in.getline(buf, BUFSIZ, ';'); // reads but does not store the ; + in.getline( buf, BUFSIZ, ';' ); // reads but does not store the ; } return 1; } @@ -785,8 +769,7 @@ an ENTITY_INSTANCE consists of: '#'(int)'=' [SCOPE] SUBSUPER_RECORD ';' The '#' is read from the istream before CreateInstance is called. */ -SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) -{ +SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & out ) { std::string tmpbuf; std::string objnm; @@ -794,53 +777,53 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) std::string schnm; int fileid = -1; - SDAI_Application_instance_ptr *scopelist = 0; + SDAI_Application_instance_ptr * scopelist = 0; - SDAI_Application_instance *obj; + SDAI_Application_instance * obj; ErrorDescriptor result; // Sent down to CreateSubSuperInstance() to receive error info - ReadTokenSeparator(in); + ReadTokenSeparator( in ); in >> fileid; // read instance id - fileid = IncrementFileId(fileid); - if(instances().FindFileId(fileid)) { - SkipInstance(in, tmpbuf); + fileid = IncrementFileId( fileid ); + if( instances().FindFileId( fileid ) ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " already exists.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in); - in.get(c); // read equal sign - if(c != '=') { + ReadTokenSeparator( in ); + in.get( c ); // read equal sign + if( c != '=' ) { // ERROR: '=' expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); c = in.peek(); // peek at the next character on the istream //check for optional "&SCOPE" construct - if(c == '&') { // TODO check this out - Severity s = CreateScopeInstances(in, &scopelist); - if(s < SEVERITY_WARNING) { + if( c == '&' ) { // TODO check this out + Severity s = CreateScopeInstances( in, &scopelist ); + if( s < SEVERITY_WARNING ) { return ENTITY_NULL; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); c = in.peek(); // peek at next char on istream again } //check for subtype/supertype record - if(c == '(') { + if( c == '(' ) { // TODO: implement complex inheritance - obj = CreateSubSuperInstance(in, fileid, result); - if(obj == ENTITY_NULL) { - SkipInstance(in, tmpbuf); + obj = CreateSubSuperInstance( in, fileid, result ); + if( obj == ENTITY_NULL ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " Illegal complex entity.\n" << result.UserMsg() << ".\n\n"; @@ -849,21 +832,21 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) } else { // not a complex entity // check for User Defined Entity int userDefined = 0; - if(c == '!') { + if( c == '!' ) { userDefined = 1; - in.get(c); + in.get( c ); } - ReadStdKeyword(in, objnm, 1); // read the type name - if(!in.good()) { + ReadStdKeyword( in, objnm, 1 ); // read the type name + if( !in.good() ) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::CreateInstance.\n"; } //create the instance using the Registry object - if(userDefined) { - SkipInstance(in, tmpbuf); + if( userDefined ) { + SkipInstance( in, tmpbuf ); out << "WARNING: instance #" << fileid << " User Defined Entity in DATA section ignored.\n" << "\tData lost: \'!" << objnm << "\': " << tmpbuf @@ -871,18 +854,18 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) return ENTITY_NULL; } else { schnm = schemaName(); - obj = reg().ObjCreate(objnm.c_str(), schnm.c_str()); - if(obj == ENTITY_NULL) { + obj = reg().ObjCreate( objnm.c_str(), schnm.c_str() ); + if( obj == ENTITY_NULL ) { // This will be the case if objnm does not exist in the reg. - result.UserMsg("Unknown ENTITY type"); - } else if(obj->Error().severity() <= SEVERITY_WARNING) { + result.UserMsg( "Unknown ENTITY type" ); + } else if( obj->Error().severity() <= SEVERITY_WARNING ) { // Common causes of error is that obj is an abstract supertype // or that it can only be instantiated using external mapping. // If neither are the case, create a generic message. - if(!obj->Error().UserMsg().empty()) { - result.UserMsg(obj->Error().UserMsg()); + if( !obj->Error().UserMsg().empty() ) { + result.UserMsg( obj->Error().UserMsg() ); } else { - result.UserMsg("Could not create ENTITY"); + result.UserMsg( "Could not create ENTITY" ); } // Delete obj so that below we'll know that an error occur: delete obj; @@ -891,8 +874,8 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) } } - if(obj == ENTITY_NULL) { - SkipInstance(in, tmpbuf); + if( obj == ENTITY_NULL ) { + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'" << objnm << "\': " << result.UserMsg() << ".\n\tData lost: " << tmpbuf << "\n\n"; @@ -901,9 +884,9 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) obj -> STEPfile_id = fileid; // scan values - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); - ReadTokenSeparator(in); + ReadTokenSeparator( in ); return obj; } @@ -922,61 +905,60 @@ SDAI_Application_instance *STEPfile::CreateInstance(istream &in, ostream &out) < SEVERITY_WARNING: the istream was read up to and including the next ";" < SEVERITY_BUG: fatal */ -Severity STEPfile::CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist) -{ +Severity STEPfile::CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ) { Severity rval = SEVERITY_NULL; - SDAI_Application_instance *se; + SDAI_Application_instance * se; std::string tmpbuf; char c; std::vector< SDAI_Application_instance_ptr > inscope; std::string keywd; - keywd = GetKeyword(in, " \n\t/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { + keywd = GetKeyword( in, " \n\t/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { //ERROR: "&SCOPE" expected //TODO: should attempt to recover by reading through ENDSCOPE //currently recovery is attempted by reading through next ";" - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: " << "\'&SCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; return SEVERITY_INPUT_ERROR; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); - in.get(c); - while(c == '#') { - se = CreateInstance(in, cout); - if(se != ENTITY_NULL) { + in.get( c ); + while( c == '#' ) { + se = CreateInstance( in, cout ); + if( se != ENTITY_NULL ) { //TODO: apply scope information to se // Add se to scopelist - inscope.push_back(se); + inscope.push_back( se ); //append the se to the instance manager - instances().Append(se, newSE); + instances().Append( se, newSE ); } else { //ERROR: instance in SCOPE not created rval = SEVERITY_WARNING; - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "instance in SCOPE not created.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; } - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - in.putback(c); + in.putback( c ); *scopelist = new SDAI_Application_instance_ptr [inscope.size()]; - for(size_t i = 0; i < inscope.size(); ++i) { + for( size_t i = 0; i < inscope.size(); ++i ) { *scopelist[i] = inscope[i]; } //check for "ENDSCOPE" - keywd = GetKeyword(in, " \t\n/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { + keywd = GetKeyword( in, " \t\n/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { //ERROR: "ENDSCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: " << "\'ENDSCOPE\' expected." << "\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; @@ -984,38 +966,37 @@ Severity STEPfile::CreateScopeInstances(istream &in, SDAI_Application_instance_p } //check for export list - ReadTokenSeparator(in); - in.get(c); - in.putback(c); - if(c == '/') { + ReadTokenSeparator( in ); + in.get( c ); + in.putback( c ); + if( c == '/' ) { //read export list - in.get(c); + in.get( c ); c = ','; - while(c == ',') { + while( c == ',' ) { int exportid; - ReadTokenSeparator(in); - in.get(c); - if(c != '#') { } //ERROR + ReadTokenSeparator( in ); + in.get( c ); + if( c != '#' ) { } //ERROR in >> exportid; //TODO: nothing is done with the idnums on the export list - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - if(c != '/') { + if( c != '/' ) { //ERROR: '/' expected while reading export list - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "ERROR: \'/\' expected in export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_INPUT_ERROR; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } return rval; } -SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fileid, ErrorDescriptor &e) -{ - SDAI_Application_instance *obj = ENTITY_NULL; +SDAI_Application_instance * STEPfile::CreateSubSuperInstance( istream & in, int fileid, ErrorDescriptor & e ) { + SDAI_Application_instance * obj = ENTITY_NULL; char c; std::string schnm; @@ -1024,20 +1005,20 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil ErrorDescriptor err; // used to catch error msgs const int enaSize = 64; - std::string *entNmArr[enaSize]; // array of entity type names + std::string * entNmArr[enaSize]; // array of entity type names int enaIndex = 0; in >> ws; - in.get(c); // read the open paren + in.get( c ); // read the open paren c = in.peek(); // see if you have closed paren (ending the record) - while(in.good() && (c != ')') && (enaIndex < enaSize)) { - entNmArr[enaIndex] = new std::string(""); - ReadStdKeyword(in, *(entNmArr[enaIndex]), 1); // read the type name - if(entNmArr[enaIndex]->empty()) { + while( in.good() && ( c != ')' ) && ( enaIndex < enaSize ) ) { + entNmArr[enaIndex] = new std::string( "" ); + ReadStdKeyword( in, *( entNmArr[enaIndex] ), 1 ); // read the type name + if( entNmArr[enaIndex]->empty() ) { delete entNmArr[enaIndex]; entNmArr[enaIndex] = 0; } else { - SkipSimpleRecord(in, buf, &err); + SkipSimpleRecord( in, buf, &err ); buf.clear(); enaIndex++; } @@ -1047,7 +1028,7 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil // garbage or a comment) this will keep the read function from // infinite looping. If the entity name starts with a digit it is // incorrect and will be invalid. - while(in.good() && (c != ')') && !isalpha(c)) { + while( in.good() && ( c != ')' ) && !isalpha( c ) ) { in >> c; // skip the invalid char c = in.peek(); // see if you have closed paren (ending the record) } @@ -1055,18 +1036,18 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil entNmArr[enaIndex] = 0; schnm = schemaName(); - obj = new STEPcomplex(&_reg, (const std::string **)entNmArr, fileid, schnm.c_str()); + obj = new STEPcomplex( &_reg, ( const std::string ** )entNmArr, fileid, schnm.c_str() ); - if(obj->Error().severity() <= SEVERITY_WARNING) { + if( obj->Error().severity() <= SEVERITY_WARNING ) { // If obj is not legal, record its error info and delete it: - e.severity(obj->Error().severity()); - e.UserMsg(obj->Error().UserMsg()); + e.severity( obj->Error().severity() ); + e.UserMsg( obj->Error().UserMsg() ); delete obj; obj = ENTITY_NULL; } enaIndex = 0; - while(entNmArr[enaIndex] != 0) { + while( entNmArr[enaIndex] != 0 ) { delete entNmArr[enaIndex]; enaIndex ++; } @@ -1082,30 +1063,29 @@ SDAI_Application_instance *STEPfile::CreateSubSuperInstance(istream &in, int fil It first searches for "&SCOPE" and reads all characters from the istream up to and including "ENDSCOPE" */ -Severity STEPfile::ReadScopeInstances(istream &in) -{ +Severity STEPfile::ReadScopeInstances( istream & in ) { Severity rval = SEVERITY_NULL; - SDAI_Application_instance *se; + SDAI_Application_instance * se; std::string tmpbuf; char c; std::string keywd; std::string cmtStr; - keywd = GetKeyword(in, " \n\t/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "&SCOPE", 6)) { + keywd = GetKeyword( in, " \n\t/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "&SCOPE", 6 ) ) { //ERROR: "&SCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << "\'&SCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); - in.get(c); - while(c == '#') { - se = ReadInstance(in, cout, cmtStr); - if(se != ENTITY_NULL) { + in.get( c ); + while( c == '#' ) { + se = ReadInstance( in, cout, cmtStr ); + if( se != ENTITY_NULL ) { //apply scope information to se //TODO: not yet implemented } else { @@ -1113,46 +1093,46 @@ Severity STEPfile::ReadScopeInstances(istream &in) rval = SEVERITY_WARNING; } - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - in.putback(c); + in.putback( c ); //check for "ENDSCOPE" - keywd = GetKeyword(in, " \t\n/\\#;", _error); - if(strncmp(const_cast(keywd.c_str()), "ENDSCOPE", 8)) { + keywd = GetKeyword( in, " \t\n/\\#;", _error ); + if( strncmp( const_cast( keywd.c_str() ), "ENDSCOPE", 8 ) ) { //ERROR: "ENDSCOPE" expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << " \'ENDSCOPE\' expected.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; return SEVERITY_WARNING; } //check for export list - ReadTokenSeparator(in); - in.get(c); - in.putback(c); - if(c == '/') { + ReadTokenSeparator( in ); + in.get( c ); + in.putback( c ); + if( c == '/' ) { //read through export list - in.get(c); + in.get( c ); c = ','; - while(c == ',') { + while( c == ',' ) { int exportid; - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); in >> exportid; - ReadTokenSeparator(in); - in.get(c); + ReadTokenSeparator( in ); + in.get( c ); } - if(c != '/') { + if( c != '/' ) { //ERROR: '/' expected while reading export list - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); cerr << " \'/\' expected while reading export list.\n\tdata lost: " << tmpbuf << "\n"; ++_errorCount; rval = SEVERITY_WARNING; } - ReadTokenSeparator(in); + ReadTokenSeparator( in ); } return rval; } @@ -1165,9 +1145,8 @@ Severity STEPfile::ReadScopeInstances(istream &in) reading the SDAI_Application_instance. It passes SDAI_Application_instance error information onto the STEPfile ErrorDescriptor. */ -SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std::string &cmtStr, - bool useTechCor) -{ +SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr, + bool useTechCor ) { Severity sev = SEVERITY_NULL; std::string tmpbuf; @@ -1178,33 +1157,33 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std char c; int fileid; - SDAI_Application_instance *obj = ENTITY_NULL; + SDAI_Application_instance * obj = ENTITY_NULL; int idIncrNum = FileIdIncr(); - ReadComment(in, cmtStr); + ReadComment( in, cmtStr ); in >> fileid; - fileid = IncrementFileId(fileid); + fileid = IncrementFileId( fileid ); // check to see that instance was created on PASS 1 - MgrNode *node = instances().FindFileId(fileid); - if((!node) || ((obj = node -> GetApplication_instance()) == ENTITY_NULL)) { - SkipInstance(in, tmpbuf); + MgrNode * node = instances().FindFileId( fileid ); + if( ( !node ) || ( ( obj = node -> GetApplication_instance() ) == ENTITY_NULL ) ) { + SkipInstance( in, tmpbuf ); // Changed the 2nd pass error message to report Part 21 User // Defined Entities. STEPfile still includes them in the error count // which is not valid. // Check to see if an User Defined Entity has been found. - const char *ude = tmpbuf.c_str(); - while(*ude && (*ude != '=')) { + const char * ude = tmpbuf.c_str(); + while( *ude && ( *ude != '=' ) ) { ude++; } - if(*ude == '=') { + if( *ude == '=' ) { ude++; } - while(*ude && isspace(*ude)) { + while( *ude && isspace( *ude ) ) { ude++; } - if(*ude == '!') { + if( *ude == '!' ) { out << "\nWARNING: #" << fileid << " - Ignoring User Defined Entity.\n\tData lost: " << tmpbuf << endl; @@ -1212,80 +1191,80 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std out << "\nERROR: in 2nd pass, instance #" << fileid << " not found.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; - } else if((_fileType != WORKING_SESSION) && (node->CurrState() != newSE)) { - SkipInstance(in, tmpbuf); + } else if( ( _fileType != WORKING_SESSION ) && ( node->CurrState() != newSE ) ) { + SkipInstance( in, tmpbuf ); out << "\nERROR: in 2nd pass, instance #" << fileid << " already exists - ignoring duplicate.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - in.get(c); - if(c != '=') { + in.get( c ); + if( c != '=' ) { //ERROR: '=' expected - SkipInstance(in, tmpbuf); + SkipInstance( in, tmpbuf ); out << "ERROR: instance #" << fileid << " \'=\' expected.\n\tData lost: " << tmpbuf << endl; return ENTITY_NULL; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); //peek at the next character on the istream c = in.peek(); //check for optional "&SCOPE" construct - if(c == '&') { - ReadScopeInstances(in); - ReadTokenSeparator(in, &cmtStr); - in.get(c); - in.putback(c); + if( c == '&' ) { + ReadScopeInstances( in ); + ReadTokenSeparator( in, &cmtStr ); + in.get( c ); + in.putback( c ); } currSch = schemaName(); //check for subtype/supertype record - if(c == '(') { + if( c == '(' ) { // TODO - sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict); + sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict ); - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - if(!cmtStr.empty()) { - obj->AddP21Comment(cmtStr); + if( !cmtStr.empty() ) { + obj->AddP21Comment( cmtStr ); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } } else { - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); c = in.peek(); // check for User Defined Entity // DAS - I checked this out. It doesn't get into this code for user // defined entities because a ude isn't created. int userDefined = 0; - if(c == '!') { + if( c == '!' ) { userDefined = 1; - in.get(c); + in.get( c ); } - ReadStdKeyword(in, objnm, 1); // read the type name - if(!in.good()) { + ReadStdKeyword( in, objnm, 1 ); // read the type name + if( !in.good() ) { out << "ERROR: instance #" << fileid << " Unexpected file problem in " << "STEPfile::ReadInstance." << endl; } - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); // read values - if(userDefined) { - SkipInstance(in, tmpbuf); + if( userDefined ) { + SkipInstance( in, tmpbuf ); out << "WARNING: #" << fileid << ". Ignoring User defined entity." << endl << " data lost: !" << objnm << tmpbuf << endl; @@ -1296,30 +1275,30 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std // NOTE: this function is called for all FileTypes // (WORKING_SESSION included) - sev = obj->STEPread(fileid, idIncrNum, &instances(), in, currSch.c_str(), - useTechCor, _strict); + sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(), + useTechCor, _strict ); - ReadTokenSeparator(in, &cmtStr); + ReadTokenSeparator( in, &cmtStr ); - if(!cmtStr.empty()) { - obj->AddP21Comment(cmtStr); + if( !cmtStr.empty() ) { + obj->AddP21Comment( cmtStr ); } c = in.peek(); // check for semicolon or keyword 'ENDSEC' - if(c != 'E') { + if( c != 'E' ) { in >> c; // read the semicolon } - AppendEntityErrorMsg(&(obj->Error())); + AppendEntityErrorMsg( &( obj->Error() ) ); } //set the node's state, //and set the STEPfile:_error (based on the type of file being read) - switch(sev) { + switch( sev ) { case SEVERITY_NULL: case SEVERITY_USERMSG: - if(_fileType != WORKING_SESSION) { - node->ChangeState(completeSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( completeSE ); } break; @@ -1328,18 +1307,18 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std case SEVERITY_BUG: case SEVERITY_INCOMPLETE: - if(_fileType == VERSION_CURRENT) { + if( _fileType == VERSION_CURRENT ) { cerr << "ERROR in EXCHANGE FILE: incomplete instance #" << obj -> STEPfile_id << ".\n"; - if(_fileType != WORKING_SESSION) { - node->ChangeState(incompleteSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( incompleteSE ); } } else { - if(node->CurrState() == completeSE) { - sprintf(errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid); - _error.AppendToUserMsg(errbuf); - if(_fileType != WORKING_SESSION) { - node->ChangeState(incompleteSE); + if( node->CurrState() == completeSE ) { + sprintf( errbuf, "WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n", fileid ); + _error.AppendToUserMsg( errbuf ); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( incompleteSE ); } } } @@ -1348,8 +1327,8 @@ SDAI_Application_instance *STEPfile::ReadInstance(istream &in, ostream &out, std case SEVERITY_EXIT: case SEVERITY_DUMP: case SEVERITY_MAX: - if(_fileType != WORKING_SESSION) { - node->ChangeState(noStateSE); + if( _fileType != WORKING_SESSION ) { + node->ChangeState( noStateSE ); } break; @@ -1380,100 +1359,96 @@ BUG: doesn't check to see if the backup command works. the results of the system call are not used by the by this function */ -void STEPfile::MakeBackupFile() -{ +void STEPfile::MakeBackupFile() { std::string bckup = FileName(); - bckup.append(".bak"); + bckup.append( ".bak" ); - std::fstream f(FileName().c_str(), std::fstream::in | std::fstream::binary); + std::fstream f( FileName().c_str(), std::fstream::in | std::fstream::binary ); f << std::noskipws; - std::istream_iterator begin(f); + std::istream_iterator begin( f ); std::istream_iterator end; - std::fstream f2(bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary); - std::ostream_iterator begin2(f2); + std::fstream f2( bckup.c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary ); + std::ostream_iterator begin2( f2 ); - copy(begin, end, begin2); + copy( begin, end, begin2 ); - _error.AppendToDetailMsg("Making backup file: "); - _error.AppendToDetailMsg(bckup.c_str()); - _error.AppendToDetailMsg("\n"); + _error.AppendToDetailMsg( "Making backup file: " ); + _error.AppendToDetailMsg( bckup.c_str() ); + _error.AppendToDetailMsg( "\n" ); } -Severity STEPfile::WriteExchangeFile(ostream &out, int validate, int clearError, - int writeComments) -{ +Severity STEPfile::WriteExchangeFile( ostream & out, int validate, int clearError, + int writeComments ) { Severity rval = SEVERITY_NULL; - SetFileType(VERSION_CURRENT); - if(clearError) { + SetFileType( VERSION_CURRENT ); + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } out << FILE_DELIM << "\n"; - WriteHeader(out); - WriteData(out, writeComments); + WriteHeader( out ); + WriteData( out, writeComments ); out << END_FILE_DELIM << "\n"; return rval; } -Severity STEPfile::WriteExchangeFile(const std::string filename, int validate, int clearError, - int writeComments) -{ +Severity STEPfile::WriteExchangeFile( const std::string filename, int validate, int clearError, + int writeComments ) { Severity rval = SEVERITY_NULL; - if(clearError) { + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File wasn't opened. Try saving as working session file.\n"); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File wasn't opened. Try saving as working session file.\n" ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } - ostream *out = OpenOutputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { + ostream * out = OpenOutputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } - rval = WriteExchangeFile(*out, 0, 0, writeComments); - CloseOutputFile(out); + rval = WriteExchangeFile( *out, 0, 0, writeComments ); + CloseOutputFile( out ); return rval; } -Severity STEPfile::WriteValuePairsFile(ostream &out, int validate, int clearError, - int writeComments, int mixedCase) -{ +Severity STEPfile::WriteValuePairsFile( ostream & out, int validate, int clearError, + int writeComments, int mixedCase ) { Severity rval = SEVERITY_NULL; - SetFileType(VERSION_CURRENT); - if(clearError) { + SetFileType( VERSION_CURRENT ); + if( clearError ) { _error.ClearErrorMsg(); } - if(validate) { - rval = instances().VerifyInstances(_error); - _error.GreaterSeverity(rval); - if(rval < SEVERITY_USERMSG) { - _error.AppendToUserMsg("Unable to verify instances. File not written. Try saving as working session file."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( validate ) { + rval = instances().VerifyInstances( _error ); + _error.GreaterSeverity( rval ); + if( rval < SEVERITY_USERMSG ) { + _error.AppendToUserMsg( "Unable to verify instances. File not written. Try saving as working session file." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); return rval; } } - WriteValuePairsData(out, writeComments, mixedCase); + WriteValuePairsData( out, writeComments, mixedCase ); return rval; } @@ -1491,19 +1466,18 @@ The header section entities must be numbered in the following manner: #2=FILE_NAME #3=FILE_SCHEMA */ -int STEPfile::HeaderId(const char *name) -{ +int STEPfile::HeaderId( const char * name ) { std::string tmp = name; - std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::toupper); + std::transform( tmp.begin(), tmp.end(), tmp.begin(), ::toupper ); - if(tmp == "FILE_DESCRIPTION") { + if( tmp == "FILE_DESCRIPTION" ) { return 1; } - if(tmp == "FILE_NAME") { + if( tmp == "FILE_NAME" ) { return 2; } - if(tmp == "FILE_SCHEMA") { + if( tmp == "FILE_SCHEMA" ) { return 3; } return ++_headerId; @@ -1511,43 +1485,41 @@ int STEPfile::HeaderId(const char *name) /*************************** ***************************/ -void STEPfile::WriteHeader(ostream &out) -{ +void STEPfile::WriteHeader( ostream & out ) { out << "HEADER;\n"; - WriteHeaderInstanceFileDescription(out); - WriteHeaderInstanceFileName(out); - WriteHeaderInstanceFileSchema(out); + WriteHeaderInstanceFileDescription( out ); + WriteHeaderInstanceFileName( out ); + WriteHeaderInstanceFileSchema( out ); // Write the rest of the header instances - SDAI_Application_instance *se; + SDAI_Application_instance * se; int n = _headerInstances->InstanceCount(); - for(int i = 0; i < n; ++i) { - se = _headerInstances->GetMgrNode(i) ->GetApplication_instance(); - if(!( - (se->StepFileId() == HeaderId("File_Name")) || - (se->StepFileId() == HeaderId("File_Description")) || - (se->StepFileId() == HeaderId("File_Schema")) - )) + for( int i = 0; i < n; ++i ) { + se = _headerInstances->GetMgrNode( i ) ->GetApplication_instance(); + if( !( + ( se->StepFileId() == HeaderId( "File_Name" ) ) || + ( se->StepFileId() == HeaderId( "File_Description" ) ) || + ( se->StepFileId() == HeaderId( "File_Schema" ) ) + ) ) WriteHeaderInstance( - _headerInstances->GetMgrNode(i)->GetApplication_instance(), out); + _headerInstances->GetMgrNode( i )->GetApplication_instance(), out ); } out << "ENDSEC;\n"; } /*************************** ***************************/ -void STEPfile::WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out) -{ +void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ) { std::string tmp; - if(!obj->P21Comment().empty()) { + if( !obj->P21Comment().empty() ) { out << obj->P21Comment(); } - out << StrToUpper(obj->EntityName(), tmp) << "("; + out << StrToUpper( obj->EntityName(), tmp ) << "("; int n = obj->attributes.list_length(); - for(int i = 0; i < n; ++i) { - (obj->attributes[i]).STEPwrite(out); - if(i < n - 1) { + for( int i = 0; i < n; ++i ) { + ( obj->attributes[i] ).STEPwrite( out ); + if( i < n - 1 ) { out << ","; } } @@ -1556,17 +1528,16 @@ void STEPfile::WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out) /*************************** ***************************/ -void STEPfile::WriteHeaderInstanceFileName(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { // Get the FileName instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Name"); - if(se == ENTITY_NULL) { - se = (SDAI_Application_instance *)HeaderDefaultFileName(); + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Name" ); + if( se == ENTITY_NULL ) { + se = ( SDAI_Application_instance * )HeaderDefaultFileName(); } //set some of the attribute values at time of output - SdaiFile_name *fn = (SdaiFile_name *)se; + SdaiFile_name * fn = ( SdaiFile_name * )se; /* I'm not sure this is a good idea that Peter did but I'll leave around - DAS // write time_stamp (as specified in ISO Standard 8601) @@ -1574,135 +1545,130 @@ void STEPfile::WriteHeaderInstanceFileName(ostream &out) // example: '1994-04-12T15:27:46' // for Calendar Date, 12 April 1994, 27 minute 46 seconds past 15 hours */ - time_t t = time(NULL); - struct tm *timeptr = localtime(&t); + time_t t = time( NULL ); + struct tm * timeptr = localtime( &t ); char time_buf[26]; - strftime(time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr); - fn->time_stamp_(time_buf); + strftime( time_buf, 26, "'%Y-%m-%dT%H:%M:%S'", timeptr ); + fn->time_stamp_( time_buf ); //output the values to the file - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteHeaderInstanceFileDescription(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) { // Get the FileDescription instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Description"); - if(se == ENTITY_NULL) { + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Description" ); + if( se == ENTITY_NULL ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = (SDAI_Application_instance *)HeaderDefaultFileDescription(); + se = ( SDAI_Application_instance * )HeaderDefaultFileDescription(); } - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteHeaderInstanceFileSchema(ostream &out) -{ +void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) { // Get the FileName instance from _headerInstances - SDAI_Application_instance *se = 0; - se = _headerInstances->GetApplication_instance("File_Schema"); - if(se == ENTITY_NULL) { + SDAI_Application_instance * se = 0; + se = _headerInstances->GetApplication_instance( "File_Schema" ); + if( se == ENTITY_NULL ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance - se = (SDAI_Application_instance *) HeaderDefaultFileSchema(); + se = ( SDAI_Application_instance * ) HeaderDefaultFileSchema(); } - WriteHeaderInstance(se, out); + WriteHeaderInstance( se, out ); } -void STEPfile::WriteData(ostream &out, int writeComments) -{ +void STEPfile::WriteData( ostream & out, int writeComments ) { _oFileInstsWritten = 0; std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - instances().GetMgrNode(i)->GetApplication_instance()->STEPwrite(out, currSch.c_str(), writeComments); + for( int i = 0; i < n; ++i ) { + instances().GetMgrNode( i )->GetApplication_instance()->STEPwrite( out, currSch.c_str(), writeComments ); _oFileInstsWritten++; } out << "ENDSEC;\n"; } -void STEPfile::WriteValuePairsData(ostream &out, int writeComments, int mixedCase) -{ +void STEPfile::WriteValuePairsData( ostream & out, int writeComments, int mixedCase ) { std::string currSch = schemaName(); int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - instances().GetMgrNode(i)->GetApplication_instance()->WriteValuePairs(out, currSch.c_str(), writeComments, mixedCase); + for( int i = 0; i < n; ++i ) { + instances().GetMgrNode( i )->GetApplication_instance()->WriteValuePairs( out, currSch.c_str(), writeComments, mixedCase ); } } -Severity STEPfile::AppendFile(istream *in, bool useTechCor) -{ +Severity STEPfile::AppendFile( istream * in, bool useTechCor ) { Severity rval = SEVERITY_NULL; char errbuf[BUFSIZ]; SetFileIdIncrement(); int total_insts = 0, valid_insts = 0; - ReadTokenSeparator(*in); - std::string keywd = GetKeyword(*in, "; #", _error); + ReadTokenSeparator( *in ); + std::string keywd = GetKeyword( *in, "; #", _error ); // get the delimiter off the istream char c; - in->get(c); - - if(!strncmp(const_cast(keywd.c_str()), "ISO-10303-21", - strlen(const_cast(keywd.c_str())))) { - SetFileType(VERSION_CURRENT); - } else if(!strncmp(const_cast(keywd.c_str()), "STEP_WORKING_SESSION", - strlen(const_cast(keywd.c_str())))) { - if(_fileType != WORKING_SESSION) { + in->get( c ); + + if( !strncmp( const_cast( keywd.c_str() ), "ISO-10303-21", + strlen( const_cast( keywd.c_str() ) ) ) ) { + SetFileType( VERSION_CURRENT ); + } else if( !strncmp( const_cast( keywd.c_str() ), "STEP_WORKING_SESSION", + strlen( const_cast( keywd.c_str() ) ) ) ) { + if( _fileType != WORKING_SESSION ) { _error.AppendToUserMsg( - "Warning: Reading in file as Working Session file.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + "Warning: Reading in file as Working Session file.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); } - SetFileType(WORKING_SESSION); + SetFileType( WORKING_SESSION ); } else { - sprintf(errbuf, - "Faulty input at beginning of file. \"ISO-10303-21;\" or" - " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", - ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); - _error.AppendToUserMsg(errbuf); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf( errbuf, + "Faulty input at beginning of file. \"ISO-10303-21;\" or" + " \"STEP_WORKING_SESSION;\" expected. File not read: %s\n", + ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); + _error.AppendToUserMsg( errbuf ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } - cout << "Reading Data from " << ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str()) << "...\n"; + cout << "Reading Data from " << ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) << "...\n"; // Read header - rval = ReadHeader(*in); + rval = ReadHeader( *in ); cout << "\nHEADER read:"; - if(rval < SEVERITY_WARNING) { - sprintf(errbuf, - "Error: non-recoverable error in reading header section. " - "There were %d errors encountered. Rest of file is ignored.\n", - _errorCount); - _error.AppendToUserMsg(errbuf); + if( rval < SEVERITY_WARNING ) { + sprintf( errbuf, + "Error: non-recoverable error in reading header section. " + "There were %d errors encountered. Rest of file is ignored.\n", + _errorCount ); + _error.AppendToUserMsg( errbuf ); return rval; - } else if(rval != SEVERITY_NULL) { - sprintf(errbuf, " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); + } else if( rval != SEVERITY_NULL ) { + sprintf( errbuf, " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); cout << errbuf; } else { cout << endl; } - if(!FindDataSection(*in)) { - _error.AppendToUserMsg("Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n"); + if( !FindDataSection( *in ) ) { + _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter. Data section not read. Rest of file ignored.\n" ); return SEVERITY_INPUT_ERROR; } // PASS 1 _errorCount = 0; - total_insts = ReadData1(*in); + total_insts = ReadData1( *in ); cout << "\nFIRST PASS complete: " << total_insts << " instances created.\n"; - sprintf(errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); + sprintf( errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); cout << errbuf; // PASS 2 @@ -1716,143 +1682,140 @@ Severity STEPfile::AppendFile(istream *in, bool useTechCor) // reset the error count so you're not counting things twice: _errorCount = 0; - istream *in2; - if(!((in2 = OpenInputFile()) && (in2 -> good()))) { + istream * in2; + if( !( ( in2 = OpenInputFile() ) && ( in2 -> good() ) ) ) { // if the stream is not readable, there's an error - _error.AppendToUserMsg("Cannot open file for 2nd pass -- No data read.\n"); - CloseInputFile(in2); + _error.AppendToUserMsg( "Cannot open file for 2nd pass -- No data read.\n" ); + CloseInputFile( in2 ); return SEVERITY_INPUT_ERROR; } - if(!FindDataSection(*in2)) { - _error.AppendToUserMsg("Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n"); - CloseInputFile(in2); + if( !FindDataSection( *in2 ) ) { + _error.AppendToUserMsg( "Error: Unable to find DATA section delimiter in second pass. \nData section not read. Rest of file ignored.\n" ); + CloseInputFile( in2 ); return SEVERITY_INPUT_ERROR; } - switch(_fileType) { + switch( _fileType ) { case VERSION_CURRENT: case VERSION_UNKNOWN: case WORKING_SESSION: - valid_insts = ReadData2(*in2, useTechCor); + valid_insts = ReadData2( *in2, useTechCor ); break; default: - _error.AppendToUserMsg("STEPfile::AppendFile: STEP file version set to unrecognized value.\n"); - CloseInputFile(in2); + _error.AppendToUserMsg( "STEPfile::AppendFile: STEP file version set to unrecognized value.\n" ); + CloseInputFile( in2 ); return SEVERITY_BUG; } //check for "ENDSEC;" - ReadTokenSeparator(*in2); - if(total_insts != valid_insts) { - sprintf(errbuf, "%d invalid instances in file: %s\n", - total_insts - valid_insts, ((FileName().compare("-") == 0) ? "standard input" : FileName().c_str())); - _error.AppendToUserMsg(errbuf); - CloseInputFile(in2); - return _error.GreaterSeverity(SEVERITY_WARNING); + ReadTokenSeparator( *in2 ); + if( total_insts != valid_insts ) { + sprintf( errbuf, "%d invalid instances in file: %s\n", + total_insts - valid_insts, ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) ); + _error.AppendToUserMsg( errbuf ); + CloseInputFile( in2 ); + return _error.GreaterSeverity( SEVERITY_WARNING ); } cout << "\nSECOND PASS complete: " << valid_insts << " instances valid.\n"; - sprintf(errbuf, - " %d ERRORS\t %d WARNINGS\n\n", - _errorCount, _warningCount); - _error.AppendToUserMsg(errbuf); + sprintf( errbuf, + " %d ERRORS\t %d WARNINGS\n\n", + _errorCount, _warningCount ); + _error.AppendToUserMsg( errbuf ); cout << errbuf; //check for "ENDSTEP;" || "END-ISO-10303-21;" - if(in2 -> good()) { - ReadTokenSeparator(*in2); - keywd = GetKeyword(*in2, ";", _error); + if( in2 -> good() ) { + ReadTokenSeparator( *in2 ); + keywd = GetKeyword( *in2, ";", _error ); //yank the ";" from the istream //if (';' == in2->peek()) in2->get(); char ch; - in2->get(ch); - if(ch != ';') { + in2->get( ch ); + if( ch != ';' ) { std::cerr << __FILE__ << ":" << __LINE__ << " - Expected ';' at Part 21 EOF, found '" << c << "'." << std::endl; } } - if((!keywd.compare(0, keywd.size(), END_FILE_DELIM)) || !(in2 -> good())) { - _error.AppendToUserMsg(END_FILE_DELIM); - _error.AppendToUserMsg(" missing at end of file.\n"); - CloseInputFile(in2); - return _error.GreaterSeverity(SEVERITY_WARNING); + if( ( !keywd.compare( 0, keywd.size(), END_FILE_DELIM ) ) || !( in2 -> good() ) ) { + _error.AppendToUserMsg( END_FILE_DELIM ); + _error.AppendToUserMsg( " missing at end of file.\n" ); + CloseInputFile( in2 ); + return _error.GreaterSeverity( SEVERITY_WARNING ); } - CloseInputFile(in2); + CloseInputFile( in2 ); cout << "Finished reading file.\n\n"; return SEVERITY_NULL; } -Severity STEPfile::WriteWorkingFile(ostream &out, int clearError, int writeComments) -{ - SetFileType(WORKING_SESSION); - if(clearError) { +Severity STEPfile::WriteWorkingFile( ostream & out, int clearError, int writeComments ) { + SetFileType( WORKING_SESSION ); + if( clearError ) { _error.ClearErrorMsg(); } - if(instances().VerifyInstances(_error) < SEVERITY_INCOMPLETE) { - _error.AppendToUserMsg("WARNING: some invalid instances written to working session file. Data may have been lost."); - _error.GreaterSeverity(SEVERITY_INCOMPLETE); + if( instances().VerifyInstances( _error ) < SEVERITY_INCOMPLETE ) { + _error.AppendToUserMsg( "WARNING: some invalid instances written to working session file. Data may have been lost." ); + _error.GreaterSeverity( SEVERITY_INCOMPLETE ); } out << FILE_DELIM << "\n"; - WriteHeader(out); + WriteHeader( out ); - WriteWorkingData(out, writeComments); + WriteWorkingData( out, writeComments ); out << END_FILE_DELIM << "\n"; SetFileType(); return _error.severity(); } -Severity STEPfile::WriteWorkingFile(const std::string filename, int clearError, - int writeComments) -{ - if(clearError) { +Severity STEPfile::WriteWorkingFile( const std::string filename, int clearError, + int writeComments ) { + if( clearError ) { _error.ClearErrorMsg(); } - ostream *out = OpenOutputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { + ostream * out = OpenOutputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } - Severity rval = WriteWorkingFile(*out, 0, writeComments); - CloseOutputFile(out); + Severity rval = WriteWorkingFile( *out, 0, writeComments ); + CloseOutputFile( out ); return rval; } -void STEPfile::WriteWorkingData(ostream &out, int writeComments) -{ +void STEPfile::WriteWorkingData( ostream & out, int writeComments ) { std::string currSch = schemaName(); out << "DATA;\n"; int n = instances().InstanceCount(); - for(int i = 0; i < n; ++i) { - switch(instances().GetMgrNode(i)->CurrState()) { + for( int i = 0; i < n; ++i ) { + switch( instances().GetMgrNode( i )->CurrState() ) { case deleteSE: out << wsDelete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case completeSE: out << wsSaveComplete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case incompleteSE: out << wsSaveIncomplete; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case newSE: out << wsNew; - instances().GetMgrNode(i)->GetApplication_instance()-> - STEPwrite(out, currSch.c_str(), writeComments); + instances().GetMgrNode( i )->GetApplication_instance()-> + STEPwrite( out, currSch.c_str(), writeComments ); break; case noStateSE: - _error.AppendToUserMsg("no state information for this node\n"); + _error.AppendToUserMsg( "no state information for this node\n" ); break; } } @@ -1870,19 +1833,18 @@ void STEPfile::WriteWorkingData(ostream &out, int writeComments) The STEPfile's error descriptor is set no lower than SEVERITY_WARNING. */ -Severity STEPfile::AppendEntityErrorMsg(ErrorDescriptor *e) -{ - ErrorDescriptor *ed = e; +Severity STEPfile::AppendEntityErrorMsg( ErrorDescriptor * e ) { + ErrorDescriptor * ed = e; Severity sev = ed->severity(); - if((sev < SEVERITY_MAX) || (sev > SEVERITY_NULL)) { + if( ( sev < SEVERITY_MAX ) || ( sev > SEVERITY_NULL ) ) { //ERROR: something wrong with ErrorDescriptor - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_BUG; } - switch(sev) { + switch( sev ) { case SEVERITY_NULL: return SEVERITY_NULL; @@ -1890,14 +1852,14 @@ Severity STEPfile::AppendEntityErrorMsg(ErrorDescriptor *e) cerr << e->DetailMsg(); e->ClearErrorMsg(); - if(sev < SEVERITY_USERMSG) { + if( sev < SEVERITY_USERMSG ) { ++_errorCount; } - if(sev < SEVERITY_WARNING) { + if( sev < SEVERITY_WARNING ) { sev = SEVERITY_WARNING; } - _error.GreaterSeverity(sev); + _error.GreaterSeverity( sev ); return sev; } } diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index dc41050dc..37c7d20bc 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -35,32 +35,29 @@ enum FileTypeCode { WORKING_SESSION = 2 }; -class SC_EDITOR_EXPORT STEPfile -{ +class SC_EDITOR_EXPORT STEPfile { protected: //data members - InstMgr &_instances; - Registry &_reg; + InstMgr & _instances; + Registry & _reg; - InstMgr &instances() - { + InstMgr & instances() { return _instances; } - Registry ®() - { + Registry & reg() { return _reg; } int _fileIdIncr; ///< Increment value to be added to FileId Numbers on input //header information - InstMgr *_headerInstances; - Registry *_headerRegistry; + InstMgr * _headerInstances; + Registry * _headerRegistry; int _headerId; ///< STEPfile_id given to SDAI_Application_instance from header section //file information - DirObj *_currentDir; + DirObj * _currentDir; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -117,147 +114,138 @@ class SC_EDITOR_EXPORT STEPfile //public access to member variables //header information - InstMgr *HeaderInstances() - { + InstMgr * HeaderInstances() { return _headerInstances; } - const Registry *HeaderRegistry() - { + const Registry * HeaderRegistry() { return _headerRegistry; } // to create header instances - SDAI_Application_instance *HeaderDefaultFileName(); - SDAI_Application_instance *HeaderDefaultFileDescription(); - SDAI_Application_instance *HeaderDefaultFileSchema(); + SDAI_Application_instance * HeaderDefaultFileName(); + SDAI_Application_instance * HeaderDefaultFileDescription(); + SDAI_Application_instance * HeaderDefaultFileSchema(); //file information - std::string FileName() const - { + std::string FileName() const { return _fileName; } - std::string SetFileName(const std::string name = ""); - std::string TruncFileName(const std::string name) const; + std::string SetFileName( const std::string name = "" ); + std::string TruncFileName( const std::string name ) const; float GetReadProgress() const; float GetWriteProgress() const; //error information - ErrorDescriptor &Error() /* const */ - { + ErrorDescriptor & Error() { /* const */ return _error; } - int ErrorCount() const - { + int ErrorCount() const { return _errorCount; } - int WarningCount() const - { + int WarningCount() const { return _warningCount; } - Severity AppendEntityErrorMsg(ErrorDescriptor *e); + Severity AppendEntityErrorMsg( ErrorDescriptor * e ); //version information - FileTypeCode FileType() const - { + FileTypeCode FileType() const { return _fileType; } - void FileType(FileTypeCode ft) - { + void FileType( FileTypeCode ft ) { _fileType = ft; } - int SetFileType(FileTypeCode ft = VERSION_CURRENT); + int SetFileType( FileTypeCode ft = VERSION_CURRENT ); //Reading and Writing - Severity ReadExchangeFile(const std::string filename = "", bool useTechCor = 1); - Severity AppendExchangeFile(const std::string filename = "", bool useTechCor = 1); + Severity ReadExchangeFile( const std::string filename = "", bool useTechCor = 1 ); + Severity AppendExchangeFile( const std::string filename = "", bool useTechCor = 1 ); - Severity ReadWorkingFile(const std::string filename = "", bool useTechCor = 1); - Severity AppendWorkingFile(const std::string filename = "", bool useTechCor = 1); + Severity ReadWorkingFile( const std::string filename = "", bool useTechCor = 1 ); + Severity AppendWorkingFile( const std::string filename = "", bool useTechCor = 1 ); - Severity AppendFile(istream *in, bool useTechCor = 1) ; + Severity AppendFile( istream * in, bool useTechCor = 1 ) ; - Severity WriteExchangeFile(ostream &out, int validate = 1, - int clearError = 1, int writeComments = 1); - Severity WriteExchangeFile(const std::string filename = "", int validate = 1, - int clearError = 1, int writeComments = 1); - Severity WriteValuePairsFile(ostream &out, int validate = 1, - int clearError = 1, - int writeComments = 1, int mixedCase = 1); + Severity WriteExchangeFile( ostream & out, int validate = 1, + int clearError = 1, int writeComments = 1 ); + Severity WriteExchangeFile( const std::string filename = "", int validate = 1, + int clearError = 1, int writeComments = 1 ); + Severity WriteValuePairsFile( ostream & out, int validate = 1, + int clearError = 1, + int writeComments = 1, int mixedCase = 1 ); - Severity WriteWorkingFile(ostream &out, int clearError = 1, - int writeComments = 1); - Severity WriteWorkingFile(const std::string filename = "", int clearError = 1, - int writeComments = 1); + Severity WriteWorkingFile( ostream & out, int clearError = 1, + int writeComments = 1 ); + Severity WriteWorkingFile( const std::string filename = "", int clearError = 1, + int writeComments = 1 ); - stateEnum EntityWfState(char c); + stateEnum EntityWfState( char c ); void Renumber(); //constructors - STEPfile(Registry &r, InstMgr &i, const std::string filename = "", bool strict = true); + STEPfile( Registry & r, InstMgr & i, const std::string filename = "", bool strict = true ); virtual ~STEPfile(); protected: //member functions std::string schemaName(); /**< Returns and copies out schema name from header instances. Called by ReadExchangeFile */ - istream *OpenInputFile(const std::string filename = ""); - void CloseInputFile(istream *in); + istream * OpenInputFile( const std::string filename = "" ); + void CloseInputFile( istream * in ); - Severity ReadHeader(istream &in); + Severity ReadHeader( istream & in ); - Severity HeaderVerifyInstances(InstMgr *im); - void HeaderMergeInstances(InstMgr *im); + Severity HeaderVerifyInstances( InstMgr * im ); + void HeaderMergeInstances( InstMgr * im ); - int HeaderId(int increment = 1); - int HeaderId(const char *nm = "\0"); + int HeaderId( int increment = 1 ); + int HeaderId( const char * nm = "\0" ); - int ReadData1(istream &in); /**< First pass, to create instances */ - int ReadData2(istream &in, bool useTechCor = true); /**< Second pass, to read instances */ + int ReadData1( istream & in ); /**< First pass, to create instances */ + int ReadData2( istream & in, bool useTechCor = true ); /**< Second pass, to read instances */ // obsolete - int ReadWorkingData1(istream &in); - int ReadWorkingData2(istream &in, bool useTechCor = true); + int ReadWorkingData1( istream & in ); + int ReadWorkingData2( istream & in, bool useTechCor = true ); - void ReadRestOfFile(istream &in); + void ReadRestOfFile( istream & in ); /// create instance - used by ReadData1() - SDAI_Application_instance *CreateInstance(istream &in, ostream &out); + SDAI_Application_instance * CreateInstance( istream & in, ostream & out ); /// create complex instance - used by CreateInstance() - SDAI_Application_instance *CreateSubSuperInstance(istream &in, int fileid, - ErrorDescriptor &); + SDAI_Application_instance * CreateSubSuperInstance( istream & in, int fileid, + ErrorDescriptor & ); // read the instance - used by ReadData2() - SDAI_Application_instance *ReadInstance(istream &in, ostream &out, - std::string &cmtStr, bool useTechCor = true); + SDAI_Application_instance * ReadInstance( istream & in, ostream & out, + std::string & cmtStr, bool useTechCor = true ); /// reading scopes are still incomplete, CreateScopeInstances and ReadScopeInstances are stubs - Severity CreateScopeInstances(istream &in, SDAI_Application_instance_ptr **scopelist); - Severity ReadScopeInstances(istream &in); + Severity CreateScopeInstances( istream & in, SDAI_Application_instance_ptr ** scopelist ); + Severity ReadScopeInstances( istream & in ); // Severity ReadSubSuperInstance(istream& in); - int FindDataSection(istream &in); - int FindHeaderSection(istream &in); + int FindDataSection( istream & in ); + int FindHeaderSection( istream & in ); // writing working session files - void WriteWorkingData(ostream &out, int writeComments = 1); + void WriteWorkingData( ostream & out, int writeComments = 1 ); //called by WriteExchangeFile - ofstream *OpenOutputFile(const std::string filename = ""); - void CloseOutputFile(ostream *out); - - void WriteHeader(ostream &out); - void WriteHeaderInstance(SDAI_Application_instance *obj, ostream &out); - void WriteHeaderInstanceFileName(ostream &out); - void WriteHeaderInstanceFileDescription(ostream &out); - void WriteHeaderInstanceFileSchema(ostream &out); - - void WriteData(ostream &out, int writeComments = 1); - void WriteValuePairsData(ostream &out, int writeComments = 1, - int mixedCase = 1); - - int IncrementFileId(int fileid); - int FileIdIncr() - { + ofstream * OpenOutputFile( const std::string filename = "" ); + void CloseOutputFile( ostream * out ); + + void WriteHeader( ostream & out ); + void WriteHeaderInstance( SDAI_Application_instance * obj, ostream & out ); + void WriteHeaderInstanceFileName( ostream & out ); + void WriteHeaderInstanceFileDescription( ostream & out ); + void WriteHeaderInstanceFileSchema( ostream & out ); + + void WriteData( ostream & out, int writeComments = 1 ); + void WriteValuePairsData( ostream & out, int writeComments = 1, + int mixedCase = 1 ); + + int IncrementFileId( int fileid ); + int FileIdIncr() { return _fileIdIncr; } void SetFileIdIncrement(); diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 60d7c540e..0c5b937e0 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -19,30 +19,28 @@ #include #include "sc_memmgr.h" -extern void HeaderSchemaInit(Registry ®); +extern void HeaderSchemaInit( Registry & reg ); //To Be inline functions //constructor & destructor -STEPfile::STEPfile(Registry &r, InstMgr &i, const std::string filename, bool strict) : - _instances(i), _reg(r), _fileIdIncr(0), _headerId(0), _iFileSize(0), - _iFileCurrentPosition(0), _iFileStage1Done(false), _oFileInstsWritten(0), - _entsNotCreated(0), _entsInvalid(0), _entsIncomplete(0), _entsWarning(0), - _errorCount(0), _warningCount(0), _maxErrorCount(100000), _strict(strict) -{ - SetFileType(VERSION_CURRENT); +STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict ) : + _instances( i ), _reg( r ), _fileIdIncr( 0 ), _headerId( 0 ), _iFileSize( 0 ), + _iFileCurrentPosition( 0 ), _iFileStage1Done( false ), _oFileInstsWritten( 0 ), + _entsNotCreated( 0 ), _entsInvalid( 0 ), _entsIncomplete( 0 ), _entsWarning( 0 ), + _errorCount( 0 ), _warningCount( 0 ), _maxErrorCount( 100000 ), _strict( strict ) { + SetFileType( VERSION_CURRENT ); SetFileIdIncrement(); - _currentDir = new DirObj(""); - _headerRegistry = new Registry(HeaderSchemaInit); + _currentDir = new DirObj( "" ); + _headerRegistry = new Registry( HeaderSchemaInit ); _headerInstances = new InstMgr; - if(!filename.empty()) { - ReadExchangeFile(filename); + if( !filename.empty() ) { + ReadExchangeFile( filename ); } } -STEPfile::~STEPfile() -{ +STEPfile::~STEPfile() { delete _currentDir; delete _headerRegistry; @@ -51,23 +49,22 @@ STEPfile::~STEPfile() delete _headerInstances; } -int STEPfile::SetFileType(FileTypeCode ft) -{ - FileType(ft); +int STEPfile::SetFileType( FileTypeCode ft ) { + FileType( ft ); - switch(_fileType) { - case(VERSION_OLD): + switch( _fileType ) { + case( VERSION_OLD ): ENTITY_NAME_DELIM = '@'; FILE_DELIM = "STEP;"; END_FILE_DELIM = "ENDSTEP;"; break; - case(VERSION_UNKNOWN): - case(VERSION_CURRENT): + case( VERSION_UNKNOWN ): + case( VERSION_CURRENT ): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "ISO-10303-21;"; END_FILE_DELIM = "END-ISO-10303-21;"; break; - case(WORKING_SESSION): + case( WORKING_SESSION ): ENTITY_NAME_DELIM = '#'; FILE_DELIM = "STEP_WORKING_SESSION;"; END_FILE_DELIM = "END-STEP_WORKING_SESSION;"; @@ -87,142 +84,135 @@ int STEPfile::SetFileType(FileTypeCode ft) ** remove any slashes, and anything before the slash, ** from filename */ -std::string STEPfile::TruncFileName(const std::string filename) const -{ +std::string STEPfile::TruncFileName( const std::string filename ) const { #if defined(_WIN32) && !defined(__mingw32__) char slash = '\\'; #else char slash = '/'; #endif - size_t l = filename.find_last_of(slash); - if(l == std::string::npos) { + size_t l = filename.find_last_of( slash ); + if( l == std::string::npos ) { return filename; } else { - return filename.substr(l); + return filename.substr( l ); } } /******************************************************/ -Severity STEPfile::ReadExchangeFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::ReadExchangeFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } instances().ClearInstances(); - if(_headerInstances) { + if( _headerInstances ) { _headerInstances->ClearInstances(); } _headerId = 5; - Severity rval = AppendFile(in, useTechCor); - CloseInputFile(in); + Severity rval = AppendFile( in, useTechCor ); + CloseInputFile( in ); return rval; } -Severity STEPfile::AppendExchangeFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::AppendExchangeFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } - Severity rval = AppendFile(in, useTechCor); - CloseInputFile(in); + Severity rval = AppendFile( in, useTechCor ); + CloseInputFile( in ); return rval; } /******************************************************/ -Severity STEPfile::ReadWorkingFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::ReadWorkingFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } instances().ClearInstances(); _headerInstances->ClearInstances(); - SetFileType(WORKING_SESSION); + SetFileType( WORKING_SESSION ); - Severity rval = AppendFile(in, useTechCor); + Severity rval = AppendFile( in, useTechCor ); SetFileType(); - CloseInputFile(in); + CloseInputFile( in ); return rval; } -Severity STEPfile::AppendWorkingFile(const std::string filename, bool useTechCor) -{ +Severity STEPfile::AppendWorkingFile( const std::string filename, bool useTechCor ) { _error.ClearErrorMsg(); _errorCount = 0; - istream *in = OpenInputFile(filename); - if(_error.severity() < SEVERITY_WARNING) { - CloseInputFile(in); + istream * in = OpenInputFile( filename ); + if( _error.severity() < SEVERITY_WARNING ) { + CloseInputFile( in ); return _error.severity(); } - SetFileType(WORKING_SESSION); - Severity rval = AppendFile(in, useTechCor); + SetFileType( WORKING_SESSION ); + Severity rval = AppendFile( in, useTechCor ); SetFileType(); - CloseInputFile(in); + CloseInputFile( in ); return rval; } /******************************************************/ -istream *STEPfile::OpenInputFile(const std::string filename) -{ +istream * STEPfile::OpenInputFile( const std::string filename ) { _iFileCurrentPosition = 0; // if there's no filename to use, fail - if(filename.empty() && FileName().empty()) { - _error.AppendToUserMsg("Unable to open file for input. No current file name.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return(0); + if( filename.empty() && FileName().empty() ) { + _error.AppendToUserMsg( "Unable to open file for input. No current file name.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return( 0 ); } else { - if(SetFileName(filename).empty() && (filename.compare("-") != 0)) { + if( SetFileName( filename ).empty() && ( filename.compare( "-" ) != 0 ) ) { char msg[BUFSIZ]; - sprintf(msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return(0); + sprintf( msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return( 0 ); } } - std::istream *in; + std::istream * in; - if(filename.compare("-") == 0) { + if( filename.compare( "-" ) == 0 ) { in = &std::cin; } else { - in = new ifstream(FileName().c_str()); + in = new ifstream( FileName().c_str() ); } - if(!in || !(in -> good())) { + if( !in || !( in -> good() ) ) { char msg[BUFSIZ]; - sprintf(msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - return (0); + sprintf( msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + return ( 0 ); } //check size of file - in->seekg(0, std::ifstream::end); + in->seekg( 0, std::ifstream::end ); _iFileSize = in->tellg(); - in->seekg(0, std::ifstream::beg); + in->seekg( 0, std::ifstream::beg ); return in; } /******************************************************/ -void STEPfile::CloseInputFile(istream *in) -{ - if(in != &std::cin) { +void STEPfile::CloseInputFile( istream * in ) { + if (in != &std::cin) { delete in; } @@ -233,53 +223,49 @@ void STEPfile::CloseInputFile(istream *in) /******************************************************/ -ofstream *STEPfile::OpenOutputFile(std::string filename) -{ - if(filename.empty()) { - if(FileName().empty()) { - _error.AppendToUserMsg("No current file name.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); +ofstream * STEPfile::OpenOutputFile( std::string filename ) { + if( filename.empty() ) { + if( FileName().empty() ) { + _error.AppendToUserMsg( "No current file name.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } else { - if(SetFileName(filename).empty()) { + if( SetFileName( filename ).empty() ) { char msg[BUFSIZ]; - sprintf(msg, "can't find file: %s\nFile not written.\n", filename.c_str()); - _error.AppendToUserMsg(msg); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + sprintf( msg, "can't find file: %s\nFile not written.\n", filename.c_str() ); + _error.AppendToUserMsg( msg ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } - if(_currentDir->FileExists(TruncFileName(filename))) { + if( _currentDir->FileExists( TruncFileName( filename ) ) ) { MakeBackupFile(); } - ofstream *out = new ofstream(filename.c_str()); - if(!out) { - _error.AppendToUserMsg("unable to open file for output\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + ofstream * out = new ofstream( filename.c_str() ); + if( !out ) { + _error.AppendToUserMsg( "unable to open file for output\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } _oFileInstsWritten = 0; return out; } -void STEPfile::CloseOutputFile(ostream *out) -{ +void STEPfile::CloseOutputFile( ostream * out ) { _oFileInstsWritten = 0; delete out; } /******************************************************/ -int STEPfile::IncrementFileId(int fileid) -{ - return (fileid + FileIdIncr()); +int STEPfile::IncrementFileId( int fileid ) { + return ( fileid + FileIdIncr() ); } -void STEPfile::SetFileIdIncrement() -{ - if(instances().MaxFileId() < 0) { +void STEPfile::SetFileIdIncrement() { + if( instances().MaxFileId() < 0 ) { _fileIdIncr = 0; } else { - _fileIdIncr = (int)((ceil((instances().MaxFileId() + 99.0) / 1000.0) + 1.0) * 1000.0); + _fileIdIncr = ( int )( ( ceil( ( instances().MaxFileId() + 99.0 ) / 1000.0 ) + 1.0 ) * 1000.0 ); } } @@ -289,43 +275,42 @@ void STEPfile::SetFileIdIncrement() * is no header section or no value for file schema, NULL is returned and * schName is unset. */ -std::string STEPfile::schemaName() -{ - SdaiFile_schema *fs; +std::string STEPfile::schemaName() { + SdaiFile_schema * fs; std::string schName; - STEPnode *n; + STEPnode * n; - if(_headerInstances == NULL) { + if( _headerInstances == NULL ) { return schName; } - fs = (SdaiFile_schema *)_headerInstances->GetApplication_instance("File_Schema"); - if(fs == ENTITY_NULL) { + fs = ( SdaiFile_schema * )_headerInstances->GetApplication_instance( "File_Schema" ); + if( fs == ENTITY_NULL ) { return schName; } - n = (STEPnode *)fs->schema_identifiers_()->GetHead(); + n = ( STEPnode * )fs->schema_identifiers_()->GetHead(); // (take the first one) - if(n == NULL) { + if( n == NULL ) { return schName; } - n->STEPwrite(schName); - if(schName.empty() || schName[0] == '$') { + n->STEPwrite( schName ); + if( schName.empty() || schName[0] == '$' ) { schName.clear(); return schName; - } else if(schName[0] == '\0') { + } else if( schName[0] == '\0' ) { //probably never - it seems that putting null in std::string takes effort - _error.AppendToUserMsg("In STEPfile::schemaName: schName contains \\0 - it should be empty."); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "In STEPfile::schemaName: schName contains \\0 - it should be empty." ); + _error.GreaterSeverity( SEVERITY_WARNING ); schName.clear(); return schName; } - if(schName[ schName.length() - 1 ] == '\'') { - schName = schName.substr(1, schName.length() - 2); + if( schName[ schName.length() - 1 ] == '\'' ) { + schName = schName.substr( 1, schName.length() - 2 ); } else { - _error.AppendToUserMsg("In STEPfile::schemaName: schName was truncated."); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToUserMsg( "In STEPfile::schemaName: schName was truncated." ); + _error.GreaterSeverity( SEVERITY_WARNING ); - schName = schName.substr(1, schName.length() - 1); + schName = schName.substr( 1, schName.length() - 1 ); } return schName; } diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index 7b642a25c..cea95b42f 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -6,7 +6,7 @@ #ifdef SC_LOGGING #include -extern ofstream *logStream; +extern ofstream * logStream; #define SCLLOGFILE "scl.log" #endif @@ -15,93 +15,88 @@ extern ofstream *logStream; #include #include "sc_memmgr.h" -Schema *s_header_section_schema = 0; +Schema * s_header_section_schema = 0; /* ************** TYPES */ -TypeDescriptor *header_section_schemat_time_stamp_text; -TypeDescriptor *header_section_schemat_section_name; -TypeDescriptor *header_section_schemat_context_name; -TypeDescriptor *header_section_schemat_schema_name; -TypeDescriptor *header_section_schemat_language_name; -TypeDescriptor *header_section_schemat_exchange_structure_identifier; +TypeDescriptor * header_section_schemat_time_stamp_text; +TypeDescriptor * header_section_schemat_section_name; +TypeDescriptor * header_section_schemat_context_name; +TypeDescriptor * header_section_schemat_schema_name; +TypeDescriptor * header_section_schemat_language_name; +TypeDescriptor * header_section_schemat_exchange_structure_identifier; /* ************** ENTITIES */ ///////// ENTITY section_language -EntityDescriptor *header_section_schemae_section_language = 0; -AttrDescriptor *a_0section = 0; -AttrDescriptor *a_1default_language = 0; -SdaiSection_language::SdaiSection_language() -{ +EntityDescriptor * header_section_schemae_section_language = 0; +AttrDescriptor * a_0section = 0; +AttrDescriptor * a_1default_language = 0; +SdaiSection_language::SdaiSection_language( ) { /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute *a = new STEPattribute(*a_0section, &_section); + STEPattribute * a = new STEPattribute( *a_0section, &_section ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_1default_language, &_default_language); + attributes.push( a ); + a = new STEPattribute( *a_1default_language, &_default_language ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiSection_language::SdaiSection_language(SdaiSection_language &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiSection_language::SdaiSection_language( SdaiSection_language & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiSection_language::~SdaiSection_language() { } -SdaiSection_language::SdaiSection_language(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiSection_language::SdaiSection_language( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_section_language; - STEPattribute *a = new STEPattribute(*a_0section, &_section); + STEPattribute * a = new STEPattribute( *a_0section, &_section ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_1default_language, &_default_language); + a = new STEPattribute( *a_1default_language, &_default_language ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSection_name -SdaiSection_language::section_() const -{ - return (const SdaiSection_name) _section; +SdaiSection_language::section_() const { + return ( const SdaiSection_name ) _section; } void -SdaiSection_language::section_(const SdaiSection_name x) +SdaiSection_language::section_( const SdaiSection_name x ) { _section = x; } const SdaiLanguage_name -SdaiSection_language::default_language_() const -{ - return (const SdaiLanguage_name) _default_language; +SdaiSection_language::default_language_() const { + return ( const SdaiLanguage_name ) _default_language; } void -SdaiSection_language::default_language_(const SdaiLanguage_name x) +SdaiSection_language::default_language_( const SdaiLanguage_name x ) { _default_language = x; @@ -112,109 +107,103 @@ SdaiSection_language::default_language_(const SdaiLanguage_name x) ///////// ENTITY file_population -EntityDescriptor *header_section_schemae_file_population = 0; -AttrDescriptor *a_2governing_schema = 0; -AttrDescriptor *a_3determination_method = 0; -AttrDescriptor *a_4governed_sections = 0; -SdaiFile_population::SdaiFile_population() -{ +EntityDescriptor * header_section_schemae_file_population = 0; +AttrDescriptor * a_2governing_schema = 0; +AttrDescriptor * a_3determination_method = 0; +AttrDescriptor * a_4governed_sections = 0; +SdaiFile_population::SdaiFile_population( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); + STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_3determination_method, &_determination_method); + attributes.push( a ); + a = new STEPattribute( *a_3determination_method, &_determination_method ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_4governed_sections, &_governed_sections); + attributes.push( a ); + a = new STEPattribute( *a_4governed_sections, &_governed_sections ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_population::SdaiFile_population(SdaiFile_population &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_population::SdaiFile_population( SdaiFile_population & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_population::~SdaiFile_population() { } -SdaiFile_population::SdaiFile_population(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_population::SdaiFile_population( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_population; - STEPattribute *a = new STEPattribute(*a_2governing_schema, &_governing_schema); + STEPattribute * a = new STEPattribute( *a_2governing_schema, &_governing_schema ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_3determination_method, &_determination_method); + a = new STEPattribute( *a_3determination_method, &_determination_method ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_4governed_sections, &_governed_sections); + a = new STEPattribute( *a_4governed_sections, &_governed_sections ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSchema_name -SdaiFile_population::governing_schema_() const -{ - return (const SdaiSchema_name) _governing_schema; +SdaiFile_population::governing_schema_() const { + return ( const SdaiSchema_name ) _governing_schema; } void -SdaiFile_population::governing_schema_(const SdaiSchema_name x) +SdaiFile_population::governing_schema_( const SdaiSchema_name x ) { _governing_schema = x; } const SdaiExchange_structure_identifier -SdaiFile_population::determination_method_() const -{ - return (const SdaiExchange_structure_identifier) _determination_method; +SdaiFile_population::determination_method_() const { + return ( const SdaiExchange_structure_identifier ) _determination_method; } void -SdaiFile_population::determination_method_(const SdaiExchange_structure_identifier x) +SdaiFile_population::determination_method_( const SdaiExchange_structure_identifier x ) { _determination_method = x; } StringAggregate_ptr -SdaiFile_population::governed_sections_() const -{ - return (StringAggregate_ptr) &_governed_sections; +SdaiFile_population::governed_sections_() const { + return ( StringAggregate_ptr ) &_governed_sections; } void -SdaiFile_population::governed_sections_(const StringAggregate_ptr x) +SdaiFile_population::governed_sections_( const StringAggregate_ptr x ) { - _governed_sections.ShallowCopy(*x); + _governed_sections.ShallowCopy( *x ); } ///////// END_ENTITY file_population @@ -222,214 +211,204 @@ SdaiFile_population::governed_sections_(const StringAggregate_ptr x) ///////// ENTITY file_name -EntityDescriptor *header_section_schemae_file_name = 0; -AttrDescriptor *a_5name = 0; -AttrDescriptor *a_6time_stamp = 0; -AttrDescriptor *a_7author = 0; -AttrDescriptor *a_8organization = 0; -AttrDescriptor *a_9preprocessor_version = 0; -AttrDescriptor *a_10originating_system = 0; -AttrDescriptor *a_11authorization = 0; -SdaiFile_name::SdaiFile_name() -{ +EntityDescriptor * header_section_schemae_file_name = 0; +AttrDescriptor * a_5name = 0; +AttrDescriptor * a_6time_stamp = 0; +AttrDescriptor * a_7author = 0; +AttrDescriptor * a_8organization = 0; +AttrDescriptor * a_9preprocessor_version = 0; +AttrDescriptor * a_10originating_system = 0; +AttrDescriptor * a_11authorization = 0; +SdaiFile_name::SdaiFile_name( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute *a = new STEPattribute(*a_5name, &_name); + STEPattribute * a = new STEPattribute( *a_5name, &_name ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_6time_stamp, &_time_stamp); + attributes.push( a ); + a = new STEPattribute( *a_6time_stamp, &_time_stamp ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_7author, &_author); + attributes.push( a ); + a = new STEPattribute( *a_7author, &_author ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_8organization, &_organization); + attributes.push( a ); + a = new STEPattribute( *a_8organization, &_organization ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); + attributes.push( a ); + a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_10originating_system, &_originating_system); + attributes.push( a ); + a = new STEPattribute( *a_10originating_system, &_originating_system ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_11authorization, &_authorization); + attributes.push( a ); + a = new STEPattribute( *a_11authorization, &_authorization ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_name::SdaiFile_name(SdaiFile_name &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_name::SdaiFile_name( SdaiFile_name & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_name::~SdaiFile_name() { } -SdaiFile_name::SdaiFile_name(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_name::SdaiFile_name( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_name; - STEPattribute *a = new STEPattribute(*a_5name, &_name); + STEPattribute * a = new STEPattribute( *a_5name, &_name ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_6time_stamp, &_time_stamp); + a = new STEPattribute( *a_6time_stamp, &_time_stamp ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_7author, &_author); + a = new STEPattribute( *a_7author, &_author ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_8organization, &_organization); + a = new STEPattribute( *a_8organization, &_organization ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_9preprocessor_version, &_preprocessor_version); + a = new STEPattribute( *a_9preprocessor_version, &_preprocessor_version ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_10originating_system, &_originating_system); + a = new STEPattribute( *a_10originating_system, &_originating_system ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_11authorization, &_authorization); + a = new STEPattribute( *a_11authorization, &_authorization ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SDAI_String -SdaiFile_name::name_() const -{ - return (const SDAI_String) _name; +SdaiFile_name::name_() const { + return ( const SDAI_String ) _name; } void -SdaiFile_name::name_(const SDAI_String x) +SdaiFile_name::name_( const SDAI_String x ) { _name = x; } const SdaiTime_stamp_text -SdaiFile_name::time_stamp_() const -{ - return (const SdaiTime_stamp_text) _time_stamp; +SdaiFile_name::time_stamp_() const { + return ( const SdaiTime_stamp_text ) _time_stamp; } void -SdaiFile_name::time_stamp_(const SdaiTime_stamp_text x) +SdaiFile_name::time_stamp_( const SdaiTime_stamp_text x ) { _time_stamp = x; } StringAggregate_ptr -SdaiFile_name::author_() const -{ - return (StringAggregate_ptr) &_author; +SdaiFile_name::author_() const { + return ( StringAggregate_ptr ) &_author; } void -SdaiFile_name::author_(const StringAggregate_ptr x) +SdaiFile_name::author_( const StringAggregate_ptr x ) { - _author.ShallowCopy(*x); + _author.ShallowCopy( *x ); } StringAggregate_ptr -SdaiFile_name::organization_() const -{ - return (StringAggregate_ptr) &_organization; +SdaiFile_name::organization_() const { + return ( StringAggregate_ptr ) &_organization; } void -SdaiFile_name::organization_(const StringAggregate_ptr x) +SdaiFile_name::organization_( const StringAggregate_ptr x ) { - _organization.ShallowCopy(*x); + _organization.ShallowCopy( *x ); } const SDAI_String -SdaiFile_name::preprocessor_version_() const -{ - return (const SDAI_String) _preprocessor_version; +SdaiFile_name::preprocessor_version_() const { + return ( const SDAI_String ) _preprocessor_version; } void -SdaiFile_name::preprocessor_version_(const SDAI_String x) +SdaiFile_name::preprocessor_version_( const SDAI_String x ) { _preprocessor_version = x; } const SDAI_String -SdaiFile_name::originating_system_() const -{ - return (const SDAI_String) _originating_system; +SdaiFile_name::originating_system_() const { + return ( const SDAI_String ) _originating_system; } void -SdaiFile_name::originating_system_(const SDAI_String x) +SdaiFile_name::originating_system_( const SDAI_String x ) { _originating_system = x; } const SDAI_String -SdaiFile_name::authorization_() const -{ - return (const SDAI_String) _authorization; +SdaiFile_name::authorization_() const { + return ( const SDAI_String ) _authorization; } void -SdaiFile_name::authorization_(const SDAI_String x) +SdaiFile_name::authorization_( const SDAI_String x ) { _authorization = x; @@ -440,82 +419,77 @@ SdaiFile_name::authorization_(const SDAI_String x) ///////// ENTITY section_context -EntityDescriptor *header_section_schemae_section_context = 0; -AttrDescriptor *a_12section = 0; -AttrDescriptor *a_13context_identifiers = 0; -SdaiSection_context::SdaiSection_context() -{ +EntityDescriptor * header_section_schemae_section_context = 0; +AttrDescriptor * a_12section = 0; +AttrDescriptor * a_13context_identifiers = 0; +SdaiSection_context::SdaiSection_context( ) { /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute *a = new STEPattribute(*a_12section, &_section); + STEPattribute * a = new STEPattribute( *a_12section, &_section ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); + attributes.push( a ); + a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiSection_context::SdaiSection_context(SdaiSection_context &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiSection_context::SdaiSection_context( SdaiSection_context & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiSection_context::~SdaiSection_context() { } -SdaiSection_context::SdaiSection_context(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiSection_context::SdaiSection_context( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_section_context; - STEPattribute *a = new STEPattribute(*a_12section, &_section); + STEPattribute * a = new STEPattribute( *a_12section, &_section ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_13context_identifiers, &_context_identifiers); + a = new STEPattribute( *a_13context_identifiers, &_context_identifiers ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } const SdaiSection_name -SdaiSection_context::section_() const -{ - return (const SdaiSection_name) _section; +SdaiSection_context::section_() const { + return ( const SdaiSection_name ) _section; } void -SdaiSection_context::section_(const SdaiSection_name x) +SdaiSection_context::section_( const SdaiSection_name x ) { _section = x; } StringAggregate_ptr -SdaiSection_context::context_identifiers_() const -{ - return (StringAggregate_ptr) &_context_identifiers; +SdaiSection_context::context_identifiers_() const { + return ( StringAggregate_ptr ) &_context_identifiers; } void -SdaiSection_context::context_identifiers_(const StringAggregate_ptr x) +SdaiSection_context::context_identifiers_( const StringAggregate_ptr x ) { - _context_identifiers.ShallowCopy(*x); + _context_identifiers.ShallowCopy( *x ); } ///////// END_ENTITY section_context @@ -523,79 +497,74 @@ SdaiSection_context::context_identifiers_(const StringAggregate_ptr x) ///////// ENTITY file_description -EntityDescriptor *header_section_schemae_file_description = 0; -AttrDescriptor *a_14description = 0; -AttrDescriptor *a_15implementation_level = 0; -SdaiFile_description::SdaiFile_description() -{ +EntityDescriptor * header_section_schemae_file_description = 0; +AttrDescriptor * a_14description = 0; +AttrDescriptor * a_15implementation_level = 0; +SdaiFile_description::SdaiFile_description( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute *a = new STEPattribute(*a_14description, &_description); + STEPattribute * a = new STEPattribute( *a_14description, &_description ); a -> set_null(); - attributes.push(a); - a = new STEPattribute(*a_15implementation_level, &_implementation_level); + attributes.push( a ); + a = new STEPattribute( *a_15implementation_level, &_implementation_level ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_description::SdaiFile_description(SdaiFile_description &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_description::SdaiFile_description( SdaiFile_description & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_description::~SdaiFile_description() {} -SdaiFile_description::SdaiFile_description(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_description::SdaiFile_description( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_description; - STEPattribute *a = new STEPattribute(*a_14description, &_description); + STEPattribute * a = new STEPattribute( *a_14description, &_description ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } - a = new STEPattribute(*a_15implementation_level, &_implementation_level); + a = new STEPattribute( *a_15implementation_level, &_implementation_level ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } StringAggregate_ptr -SdaiFile_description::description_() const -{ - return (StringAggregate_ptr) &_description; +SdaiFile_description::description_() const { + return ( StringAggregate_ptr ) &_description; } void -SdaiFile_description::description_(const StringAggregate_ptr x) +SdaiFile_description::description_( const StringAggregate_ptr x ) { - _description.ShallowCopy(*x); + _description.ShallowCopy( *x ); } const SDAI_String -SdaiFile_description::implementation_level_() const -{ - return (const SDAI_String) _implementation_level; +SdaiFile_description::implementation_level_() const { + return ( const SDAI_String ) _implementation_level; } void -SdaiFile_description::implementation_level_(const SDAI_String x) +SdaiFile_description::implementation_level_( const SDAI_String x ) { _implementation_level = x; @@ -606,122 +575,110 @@ SdaiFile_description::implementation_level_(const SDAI_String x) ///////// ENTITY file_schema -EntityDescriptor *header_section_schemae_file_schema = 0; -AttrDescriptor *a_16schema_identifiers = 0; -SdaiFile_schema::SdaiFile_schema() -{ +EntityDescriptor * header_section_schemae_file_schema = 0; +AttrDescriptor * a_16schema_identifiers = 0; +SdaiFile_schema::SdaiFile_schema( ) { /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); + STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); a -> set_null(); - attributes.push(a); + attributes.push( a ); } -SdaiFile_schema::SdaiFile_schema(SdaiFile_schema &e): SDAI_Application_instance() -{ - CopyAs((SDAI_Application_instance_ptr) &e); +SdaiFile_schema::SdaiFile_schema( SdaiFile_schema & e ): SDAI_Application_instance() { + CopyAs( ( SDAI_Application_instance_ptr ) &e ); } SdaiFile_schema::~SdaiFile_schema() { } -SdaiFile_schema::SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs) -{ +SdaiFile_schema::SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs ) { /* Set this to point to the head entity. */ - HeadEntity(se); + HeadEntity( se ); /* no SuperTypes */ eDesc = header_section_schemae_file_schema; - STEPattribute *a = new STEPattribute(*a_16schema_identifiers, &_schema_identifiers); + STEPattribute * a = new STEPattribute( *a_16schema_identifiers, &_schema_identifiers ); a -> set_null(); /* Put attribute on this class' attributes list so the */ /*access functions still work. */ - attributes.push(a); + attributes.push( a ); /* Put attribute on the attributes list for the */ /* main inheritance hierarchy. */ - if(!addAttrs || addAttrs[0]) { - se->attributes.push(a); + if( !addAttrs || addAttrs[0] ) { + se->attributes.push( a ); } } StringAggregate_ptr -SdaiFile_schema::schema_identifiers_() const -{ - return (StringAggregate_ptr) &_schema_identifiers; +SdaiFile_schema::schema_identifiers_() const { + return ( StringAggregate_ptr ) &_schema_identifiers; } void -SdaiFile_schema::schema_identifiers_(const StringAggregate_ptr x) +SdaiFile_schema::schema_identifiers_( const StringAggregate_ptr x ) { - _schema_identifiers.ShallowCopy(*x); + _schema_identifiers.ShallowCopy( *x ); } ///////// END_ENTITY file_schema -SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() -{ +SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema() { return new SdaiModel_contents_header_section_schema ; } -SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() -{ - SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0; +SdaiModel_contents_header_section_schema::SdaiModel_contents_header_section_schema() { + SDAI_Entity_extent_ptr eep = ( SDAI_Entity_extent_ptr )0; eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_section_language); - _folders.Append(eep); + eep->definition_( header_section_schemae_section_language ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_population); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_population ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_name); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_name ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_section_context); - _folders.Append(eep); + eep->definition_( header_section_schemae_section_context ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_description); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_description ); + _folders.Append( eep ); eep = new SDAI_Entity_extent; - eep->definition_(header_section_schemae_file_schema); - _folders.Append(eep); + eep->definition_( header_section_schemae_file_schema ); + _folders.Append( eep ); } -SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() -{ - return (SdaiSection_language__set_var)((_folders.retrieve(0))->instances_()); +SdaiSection_language__set_var SdaiModel_contents_header_section_schema::SdaiSection_language_get_extents() { + return ( SdaiSection_language__set_var )( ( _folders.retrieve( 0 ) )->instances_() ); } -SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() -{ - return (SdaiFile_population__set_var)((_folders.retrieve(1))->instances_()); +SdaiFile_population__set_var SdaiModel_contents_header_section_schema::SdaiFile_population_get_extents() { + return ( SdaiFile_population__set_var )( ( _folders.retrieve( 1 ) )->instances_() ); } -SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() -{ - return (SdaiFile_name__set_var)((_folders.retrieve(2))->instances_()); +SdaiFile_name__set_var SdaiModel_contents_header_section_schema::SdaiFile_name_get_extents() { + return ( SdaiFile_name__set_var )( ( _folders.retrieve( 2 ) )->instances_() ); } -SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() -{ - return (SdaiSection_context__set_var)((_folders.retrieve(3))->instances_()); +SdaiSection_context__set_var SdaiModel_contents_header_section_schema::SdaiSection_context_get_extents() { + return ( SdaiSection_context__set_var )( ( _folders.retrieve( 3 ) )->instances_() ); } -SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() -{ - return (SdaiFile_description__set_var)((_folders.retrieve(4))->instances_()); +SdaiFile_description__set_var SdaiModel_contents_header_section_schema::SdaiFile_description_get_extents() { + return ( SdaiFile_description__set_var )( ( _folders.retrieve( 4 ) )->instances_() ); } -SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() -{ - return (SdaiFile_schema__set_var)((_folders.retrieve(5))->instances_()); +SdaiFile_schema__set_var SdaiModel_contents_header_section_schema::SdaiFile_schema_get_extents() { + return ( SdaiFile_schema__set_var )( ( _folders.retrieve( 5 ) )->instances_() ); } #endif diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index 30e5b9f20..7cd45d848 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -13,36 +13,33 @@ ///////// ENTITY section_language -extern SC_EDITOR_EXPORT AttrDescriptor *a_0section; -extern SC_EDITOR_EXPORT AttrDescriptor *a_1default_language; +extern SC_EDITOR_EXPORT AttrDescriptor * a_0section; +extern SC_EDITOR_EXPORT AttrDescriptor * a_1default_language; -class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiSection_language : public SDAI_Application_instance { protected: SDAI_String _section ; // OPTIONAL SDAI_String _default_language ; public: - SdaiSection_language(); - SdaiSection_language(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiSection_language(SdaiSection_language &e); + SdaiSection_language( ); + SdaiSection_language( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiSection_language( SdaiSection_language & e ); ~SdaiSection_language(); - int opcode() - { + int opcode() { return 0 ; } const SdaiSection_name section_() const; - void section_(const SdaiSection_name x); + void section_( const SdaiSection_name x ); const SdaiLanguage_name default_language_() const; - void default_language_(const SdaiLanguage_name x); + void default_language_( const SdaiLanguage_name x ); }; inline SdaiSection_language * -create_SdaiSection_language() -{ +create_SdaiSection_language() { return new SdaiSection_language ; } @@ -51,12 +48,11 @@ create_SdaiSection_language() ///////// ENTITY file_population -extern SC_EDITOR_EXPORT AttrDescriptor *a_2governing_schema; -extern SC_EDITOR_EXPORT AttrDescriptor *a_3determination_method; -extern SC_EDITOR_EXPORT AttrDescriptor *a_4governed_sections; +extern SC_EDITOR_EXPORT AttrDescriptor * a_2governing_schema; +extern SC_EDITOR_EXPORT AttrDescriptor * a_3determination_method; +extern SC_EDITOR_EXPORT AttrDescriptor * a_4governed_sections; -class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instance { protected: SDAI_String _governing_schema ; SDAI_String _determination_method ; @@ -64,29 +60,27 @@ class SC_EDITOR_EXPORT SdaiFile_population : public SDAI_Application_instanc public: - SdaiFile_population(); - SdaiFile_population(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_population(SdaiFile_population &e); + SdaiFile_population( ); + SdaiFile_population( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_population( SdaiFile_population & e ); ~SdaiFile_population(); - int opcode() - { + int opcode() { return 1 ; } const SdaiSchema_name governing_schema_() const; - void governing_schema_(const SdaiSchema_name x); + void governing_schema_( const SdaiSchema_name x ); const SdaiExchange_structure_identifier determination_method_() const; - void determination_method_(const SdaiExchange_structure_identifier x); + void determination_method_( const SdaiExchange_structure_identifier x ); StringAggregate_ptr governed_sections_() const; - void governed_sections_(const StringAggregate_ptr x); + void governed_sections_( const StringAggregate_ptr x ); }; inline SdaiFile_population * -create_SdaiFile_population() -{ +create_SdaiFile_population() { return new SdaiFile_population ; } @@ -95,16 +89,15 @@ create_SdaiFile_population() ///////// ENTITY file_name -extern AttrDescriptor *a_5name; -extern AttrDescriptor *a_6time_stamp; -extern AttrDescriptor *a_7author; -extern AttrDescriptor *a_8organization; -extern AttrDescriptor *a_9preprocessor_version; -extern AttrDescriptor *a_10originating_system; -extern AttrDescriptor *a_11authorization; +extern AttrDescriptor * a_5name; +extern AttrDescriptor * a_6time_stamp; +extern AttrDescriptor * a_7author; +extern AttrDescriptor * a_8organization; +extern AttrDescriptor * a_9preprocessor_version; +extern AttrDescriptor * a_10originating_system; +extern AttrDescriptor * a_11authorization; -class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance { protected: SDAI_String _name ; SDAI_String _time_stamp ; @@ -115,41 +108,39 @@ class SC_EDITOR_EXPORT SdaiFile_name : public SDAI_Application_instance SDAI_String _authorization ; public: - SdaiFile_name(); - SdaiFile_name(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_name(SdaiFile_name &e); + SdaiFile_name( ); + SdaiFile_name( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_name( SdaiFile_name & e ); ~SdaiFile_name(); - int opcode() - { + int opcode() { return 2 ; } const SDAI_String name_() const; - void name_(const SDAI_String x); + void name_( const SDAI_String x ); const SdaiTime_stamp_text time_stamp_() const; - void time_stamp_(const SdaiTime_stamp_text x); + void time_stamp_( const SdaiTime_stamp_text x ); StringAggregate_ptr author_() const; - void author_(const StringAggregate_ptr x); + void author_( const StringAggregate_ptr x ); StringAggregate_ptr organization_() const; - void organization_(const StringAggregate_ptr x); + void organization_( const StringAggregate_ptr x ); const SDAI_String preprocessor_version_() const; - void preprocessor_version_(const SDAI_String x); + void preprocessor_version_( const SDAI_String x ); const SDAI_String originating_system_() const; - void originating_system_(const SDAI_String x); + void originating_system_( const SDAI_String x ); const SDAI_String authorization_() const; - void authorization_(const SDAI_String x); + void authorization_( const SDAI_String x ); }; inline SdaiFile_name * -create_SdaiFile_name() -{ +create_SdaiFile_name() { return new SdaiFile_name ; } @@ -158,37 +149,34 @@ create_SdaiFile_name() ///////// ENTITY section_context -extern SC_EDITOR_EXPORT AttrDescriptor *a_12section; -extern SC_EDITOR_EXPORT AttrDescriptor *a_13context_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor * a_12section; +extern SC_EDITOR_EXPORT AttrDescriptor * a_13context_identifiers; -class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiSection_context : public SDAI_Application_instance { protected: SDAI_String _section ; // OPTIONAL StringAggregate _context_identifiers ; // of context_name public: - SdaiSection_context(); - SdaiSection_context(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiSection_context(SdaiSection_context &e); + SdaiSection_context( ); + SdaiSection_context( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiSection_context( SdaiSection_context & e ); ~SdaiSection_context(); - int opcode() - { + int opcode() { return 3 ; } const SdaiSection_name section_() const; - void section_(const SdaiSection_name x); + void section_( const SdaiSection_name x ); StringAggregate_ptr context_identifiers_() const; - void context_identifiers_(const StringAggregate_ptr x); + void context_identifiers_( const StringAggregate_ptr x ); }; inline SdaiSection_context * -create_SdaiSection_context() -{ +create_SdaiSection_context() { return new SdaiSection_context ; } @@ -197,36 +185,33 @@ create_SdaiSection_context() ///////// ENTITY file_description -extern SC_EDITOR_EXPORT AttrDescriptor *a_14description; -extern SC_EDITOR_EXPORT AttrDescriptor *a_15implementation_level; +extern SC_EDITOR_EXPORT AttrDescriptor * a_14description; +extern SC_EDITOR_EXPORT AttrDescriptor * a_15implementation_level; -class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_description : public SDAI_Application_instance { protected: StringAggregate _description ; SDAI_String _implementation_level ; public: - SdaiFile_description(); - SdaiFile_description(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_description(SdaiFile_description &e); + SdaiFile_description( ); + SdaiFile_description( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_description( SdaiFile_description & e ); ~SdaiFile_description(); - int opcode() - { + int opcode() { return 4 ; } StringAggregate_ptr description_() const; - void description_(const StringAggregate_ptr x); + void description_( const StringAggregate_ptr x ); const SDAI_String implementation_level_() const; - void implementation_level_(const SDAI_String x); + void implementation_level_( const SDAI_String x ); }; inline SdaiFile_description * -create_SdaiFile_description() -{ +create_SdaiFile_description() { return new SdaiFile_description ; } @@ -235,32 +220,29 @@ create_SdaiFile_description() ///////// ENTITY file_schema -extern SC_EDITOR_EXPORT AttrDescriptor *a_16schema_identifiers; +extern SC_EDITOR_EXPORT AttrDescriptor * a_16schema_identifiers; -class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance -{ +class SC_EDITOR_EXPORT SdaiFile_schema : public SDAI_Application_instance { protected: StringAggregate _schema_identifiers ; // of schema_name public: - SdaiFile_schema(); - SdaiFile_schema(SDAI_Application_instance *se, int *addAttrs = 0); - SdaiFile_schema(SdaiFile_schema &e); + SdaiFile_schema( ); + SdaiFile_schema( SDAI_Application_instance * se, int * addAttrs = 0 ); + SdaiFile_schema( SdaiFile_schema & e ); ~SdaiFile_schema(); - int opcode() - { + int opcode() { return 5 ; } StringAggregate_ptr schema_identifiers_() const; - void schema_identifiers_(const StringAggregate_ptr x); + void schema_identifiers_( const StringAggregate_ptr x ); }; inline SdaiFile_schema * -create_SdaiFile_schema() -{ +create_SdaiFile_schema() { return new SdaiFile_schema ; } @@ -269,8 +251,7 @@ create_SdaiFile_schema() // ***** generate Model related pieces -class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents -{ +class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Model_contents { public: SdaiModel_contents_header_section_schema(); @@ -290,7 +271,7 @@ class SC_EDITOR_EXPORT SdaiModel_contents_header_section_schema : public SDAI_Mo }; -typedef SdaiModel_contents_header_section_schema *SdaiModel_contents_header_section_schema_ptr; +typedef SdaiModel_contents_header_section_schema * SdaiModel_contents_header_section_schema_ptr; typedef SdaiModel_contents_header_section_schema_ptr SdaiModel_contents_header_section_schema_var; SC_EDITOR_EXPORT SDAI_Model_contents_ptr create_SdaiModel_contents_header_section_schema(); #endif diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index d4431ebf5..3a469c7d3 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -7,84 +7,83 @@ #include #include "sc_memmgr.h" -void HeaderInitSchemasAndEnts(Registry ®) -{ +void HeaderInitSchemasAndEnts( Registry & reg ) { Uniqueness_rule_ptr ur; // Schema: SdaiHEADER_SECTION_SCHEMA - s_header_section_schema = new Schema("Header_Section_Schema"); + s_header_section_schema = new Schema( "Header_Section_Schema" ); s_header_section_schema->AssignModelContentsCreator( - (ModelContentsCreator) create_SdaiModel_contents_header_section_schema); - reg.AddSchema(*s_header_section_schema); + ( ModelContentsCreator ) create_SdaiModel_contents_header_section_schema ); + reg.AddSchema( *s_header_section_schema ); // ***** Initialize the Types header_section_schemat_time_stamp_text = new TypeDescriptor( "Time_Stamp_Text", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (256)"); // Description - s_header_section_schema->AddType(header_section_schemat_time_stamp_text); + "STRING (256)" ); // Description + s_header_section_schema->AddType( header_section_schemat_time_stamp_text ); header_section_schemat_section_name = new TypeDescriptor( "Section_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier"); // Description - s_header_section_schema->AddType(header_section_schemat_section_name); + "exchange_structure_identifier" ); // Description + s_header_section_schema->AddType( header_section_schemat_section_name ); header_section_schemat_context_name = new TypeDescriptor( "Context_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING"); // Description - s_header_section_schema->AddType(header_section_schemat_context_name); + "STRING" ); // Description + s_header_section_schema->AddType( header_section_schemat_context_name ); header_section_schemat_schema_name = new TypeDescriptor( "Schema_Name", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING (1024)"); // Description - s_header_section_schema->AddType(header_section_schemat_schema_name); + "STRING (1024)" ); // Description + s_header_section_schema->AddType( header_section_schemat_schema_name ); header_section_schemat_language_name = new TypeDescriptor( "Language_Name", // Name REFERENCE_TYPE, // FundamentalType s_header_section_schema, // Originating Schema - "exchange_structure_identifier"); // Description - s_header_section_schema->AddType(header_section_schemat_language_name); + "exchange_structure_identifier" ); // Description + s_header_section_schema->AddType( header_section_schemat_language_name ); header_section_schemat_exchange_structure_identifier = new TypeDescriptor( "Exchange_Structure_Identifier", // Name sdaiSTRING, // FundamentalType s_header_section_schema, // Originating Schema - "STRING"); // Description - s_header_section_schema->AddType(header_section_schemat_exchange_structure_identifier); + "STRING" ); // Description + s_header_section_schema->AddType( header_section_schemat_exchange_structure_identifier ); // ***** Initialize the Entities header_section_schemae_section_language = new EntityDescriptor( "Section_Language", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiSection_language); - s_header_section_schema->AddEntity(header_section_schemae_section_language); + ( Creator ) create_SdaiSection_language ); + s_header_section_schema->AddEntity( header_section_schemae_section_language ); header_section_schemae_section_language->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule("UR1 : section;\n"); - header_section_schemae_section_language->_uniqueness_rules->Append(ur); + ur = new Uniqueness_rule( "UR1 : section;\n" ); + header_section_schemae_section_language->_uniqueness_rules->Append( ur ); header_section_schemae_file_population = new EntityDescriptor( "File_Population", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_population); - s_header_section_schema->AddEntity(header_section_schemae_file_population); + ( Creator ) create_SdaiFile_population ); + s_header_section_schema->AddEntity( header_section_schemae_file_population ); header_section_schemae_file_name = new EntityDescriptor( "File_Name", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_name); - s_header_section_schema->AddEntity(header_section_schemae_file_name); + ( Creator ) create_SdaiFile_name ); + s_header_section_schema->AddEntity( header_section_schemae_file_name ); header_section_schemae_section_context = new EntityDescriptor( "Section_Context", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiSection_context); - s_header_section_schema->AddEntity(header_section_schemae_section_context); + ( Creator ) create_SdaiSection_context ); + s_header_section_schema->AddEntity( header_section_schemae_section_context ); header_section_schemae_section_context->_uniqueness_rules = new Uniqueness_rule__set; - ur = new Uniqueness_rule("UR1 : section;\n"); - header_section_schemae_section_context->_uniqueness_rules->Append(ur); + ur = new Uniqueness_rule( "UR1 : section;\n" ); + header_section_schemae_section_context->_uniqueness_rules->Append( ur ); header_section_schemae_file_description = new EntityDescriptor( "File_Description", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_description); - s_header_section_schema->AddEntity(header_section_schemae_file_description); + ( Creator ) create_SdaiFile_description ); + s_header_section_schema->AddEntity( header_section_schemae_file_description ); header_section_schemae_file_schema = new EntityDescriptor( "File_Schema", s_header_section_schema, LFalse, LFalse, - (Creator) create_SdaiFile_schema); - s_header_section_schema->AddEntity(header_section_schemae_file_schema); + ( Creator ) create_SdaiFile_schema ); + s_header_section_schema->AddEntity( header_section_schemae_file_schema ); //////////////// USE statements //////////////// REFERENCE statements diff --git a/src/cleditor/SdaiHeaderSchemaClasses.h b/src/cleditor/SdaiHeaderSchemaClasses.h index 307af452b..5427bd7b5 100644 --- a/src/cleditor/SdaiHeaderSchemaClasses.h +++ b/src/cleditor/SdaiHeaderSchemaClasses.h @@ -7,81 +7,81 @@ #include // Schema: SdaiHEADER_SECTION_SCHEMA -extern Schema *s_header_section_schema; +extern Schema * s_header_section_schema; // Types: typedef SDAI_String SdaiTime_stamp_text; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_time_stamp_text; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_time_stamp_text; typedef SDAI_String SdaiSection_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_section_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_section_name; typedef SDAI_String SdaiContext_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_context_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_context_name; typedef SDAI_String SdaiSchema_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_schema_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_schema_name; typedef SDAI_String SdaiLanguage_name; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_language_name; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_language_name; typedef SDAI_String SdaiExchange_structure_identifier; -extern SC_EDITOR_EXPORT TypeDescriptor *header_section_schemat_exchange_structure_identifier; +extern SC_EDITOR_EXPORT TypeDescriptor * header_section_schemat_exchange_structure_identifier; // Entities: class SdaiSection_language; -typedef SdaiSection_language *SdaiSection_languageH; -typedef SdaiSection_language *SdaiSection_language_ptr; +typedef SdaiSection_language * SdaiSection_languageH; +typedef SdaiSection_language * SdaiSection_language_ptr; typedef SdaiSection_language_ptr SdaiSection_language_var; -typedef const SdaiSection_language *const_SdaiSection_languageH; -typedef const SdaiSection_language *const_SdaiSection_language_ptr; +typedef const SdaiSection_language * const_SdaiSection_languageH; +typedef const SdaiSection_language * const_SdaiSection_language_ptr; #define SdaiSection_language__set SDAI_DAObject__set #define SdaiSection_language__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_language; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_language; class SdaiFile_population; -typedef SdaiFile_population *SdaiFile_populationH; -typedef SdaiFile_population *SdaiFile_population_ptr; +typedef SdaiFile_population * SdaiFile_populationH; +typedef SdaiFile_population * SdaiFile_population_ptr; typedef SdaiFile_population_ptr SdaiFile_population_var; -typedef const SdaiFile_population *const_SdaiFile_populationH; -typedef const SdaiFile_population *const_SdaiFile_population_ptr; +typedef const SdaiFile_population * const_SdaiFile_populationH; +typedef const SdaiFile_population * const_SdaiFile_population_ptr; #define SdaiFile_population__set SDAI_DAObject__set #define SdaiFile_population__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_population; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_population; class SdaiFile_name; -typedef SdaiFile_name *SdaiFile_nameH; -typedef SdaiFile_name *SdaiFile_name_ptr; +typedef SdaiFile_name * SdaiFile_nameH; +typedef SdaiFile_name * SdaiFile_name_ptr; typedef SdaiFile_name_ptr SdaiFile_name_var; -typedef const SdaiFile_name *const_SdaiFile_nameH; -typedef const SdaiFile_name *const_SdaiFile_name_ptr; +typedef const SdaiFile_name * const_SdaiFile_nameH; +typedef const SdaiFile_name * const_SdaiFile_name_ptr; #define SdaiFile_name__set SDAI_DAObject__set #define SdaiFile_name__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_name; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_name; class SdaiSection_context; -typedef SdaiSection_context *SdaiSection_contextH; -typedef SdaiSection_context *SdaiSection_context_ptr; +typedef SdaiSection_context * SdaiSection_contextH; +typedef SdaiSection_context * SdaiSection_context_ptr; typedef SdaiSection_context_ptr SdaiSection_context_var; -typedef const SdaiSection_context *const_SdaiSection_contextH; -typedef const SdaiSection_context *const_SdaiSection_context_ptr; +typedef const SdaiSection_context * const_SdaiSection_contextH; +typedef const SdaiSection_context * const_SdaiSection_context_ptr; #define SdaiSection_context__set SDAI_DAObject__set #define SdaiSection_context__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_section_context; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_section_context; class SdaiFile_description; -typedef SdaiFile_description *SdaiFile_descriptionH; -typedef SdaiFile_description *SdaiFile_description_ptr; +typedef SdaiFile_description * SdaiFile_descriptionH; +typedef SdaiFile_description * SdaiFile_description_ptr; typedef SdaiFile_description_ptr SdaiFile_description_var; -typedef const SdaiFile_description *const_SdaiFile_descriptionH; -typedef const SdaiFile_description *const_SdaiFile_description_ptr; +typedef const SdaiFile_description * const_SdaiFile_descriptionH; +typedef const SdaiFile_description * const_SdaiFile_description_ptr; #define SdaiFile_description__set SDAI_DAObject__set #define SdaiFile_description__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_description; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_description; class SdaiFile_schema; -typedef SdaiFile_schema *SdaiFile_schemaH; -typedef SdaiFile_schema *SdaiFile_schema_ptr; +typedef SdaiFile_schema * SdaiFile_schemaH; +typedef SdaiFile_schema * SdaiFile_schema_ptr; typedef SdaiFile_schema_ptr SdaiFile_schema_var; -typedef const SdaiFile_schema *const_SdaiFile_schemaH; -typedef const SdaiFile_schema *const_SdaiFile_schema_ptr; +typedef const SdaiFile_schema * const_SdaiFile_schemaH; +typedef const SdaiFile_schema * const_SdaiFile_schema_ptr; #define SdaiFile_schema__set SDAI_DAObject__set #define SdaiFile_schema__set_var SDAI_DAObject__set_var -extern SC_EDITOR_EXPORT EntityDescriptor *header_section_schemae_file_schema; +extern SC_EDITOR_EXPORT EntityDescriptor * header_section_schemae_file_schema; #endif diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 97661537a..35099d805 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -10,183 +10,182 @@ #include #include "sc_memmgr.h" -void SdaiHEADER_SECTION_SCHEMAInit(Registry ®) -{ - header_section_schemat_time_stamp_text->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_time_stamp_text); - header_section_schemat_section_name->ReferentType(header_section_schemat_exchange_structure_identifier); - reg.AddType(*header_section_schemat_section_name); - header_section_schemat_context_name->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_context_name); - header_section_schemat_schema_name->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_schema_name); - header_section_schemat_language_name->ReferentType(header_section_schemat_exchange_structure_identifier); - reg.AddType(*header_section_schemat_language_name); - header_section_schemat_exchange_structure_identifier->ReferentType(t_sdaiSTRING); - reg.AddType(*header_section_schemat_exchange_structure_identifier); +void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { + header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_time_stamp_text ); + header_section_schemat_section_name->ReferentType( header_section_schemat_exchange_structure_identifier ); + reg.AddType( *header_section_schemat_section_name ); + header_section_schemat_context_name->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_context_name ); + header_section_schemat_schema_name->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_schema_name ); + header_section_schemat_language_name->ReferentType( header_section_schemat_exchange_structure_identifier ); + reg.AddType( *header_section_schemat_language_name ); + header_section_schemat_exchange_structure_identifier->ReferentType( t_sdaiSTRING ); + reg.AddType( *header_section_schemat_exchange_structure_identifier ); ///////// ENTITY section_language a_0section = - new AttrDescriptor("section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_language); - header_section_schemae_section_language->AddExplicitAttr(a_0section); + new AttrDescriptor( "section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_language ); + header_section_schemae_section_language->AddExplicitAttr( a_0section ); a_1default_language = - new AttrDescriptor("default_language", header_section_schemat_language_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_language); - header_section_schemae_section_language->AddExplicitAttr(a_1default_language); - reg.AddEntity(*header_section_schemae_section_language); + new AttrDescriptor( "default_language", header_section_schemat_language_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_language ); + header_section_schemae_section_language->AddExplicitAttr( a_1default_language ); + reg.AddEntity( *header_section_schemae_section_language ); ///////// END_ENTITY section_language ///////// ENTITY file_population a_2governing_schema = - new AttrDescriptor("governing_schema", header_section_schemat_schema_name, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_2governing_schema); + new AttrDescriptor( "governing_schema", header_section_schemat_schema_name, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_2governing_schema ); a_3determination_method = - new AttrDescriptor("determination_method", header_section_schemat_exchange_structure_identifier, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_3determination_method); - SetTypeDescriptor *t_0 = new SetTypeDescriptor; - t_0->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_0->SetBound1(1); - t_0->SetBound2(2147483647); - t_0->FundamentalType(SET_TYPE); - t_0->Description("SET [1:?] OF section_name"); - t_0->OriginatingSchema(s_header_section_schema); - t_0->ReferentType(header_section_schemat_section_name); - s_header_section_schema->AddUnnamedType(t_0); + new AttrDescriptor( "determination_method", header_section_schemat_exchange_structure_identifier, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_3determination_method ); + SetTypeDescriptor * t_0 = new SetTypeDescriptor; + t_0->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_0->SetBound1( 1 ); + t_0->SetBound2( 2147483647 ); + t_0->FundamentalType( SET_TYPE ); + t_0->Description( "SET [1:?] OF section_name" ); + t_0->OriginatingSchema( s_header_section_schema ); + t_0->ReferentType( header_section_schemat_section_name ); + s_header_section_schema->AddUnnamedType( t_0 ); a_4governed_sections = - new AttrDescriptor("governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, - *header_section_schemae_file_population); - header_section_schemae_file_population->AddExplicitAttr(a_4governed_sections); - reg.AddEntity(*header_section_schemae_file_population); + new AttrDescriptor( "governed_sections", t_0, LTrue, LFalse, AttrType_Explicit, + *header_section_schemae_file_population ); + header_section_schemae_file_population->AddExplicitAttr( a_4governed_sections ); + reg.AddEntity( *header_section_schemae_file_population ); ///////// END_ENTITY file_population ///////// ENTITY file_name a_5name = - new AttrDescriptor("name", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_5name); + new AttrDescriptor( "name", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_5name ); a_6time_stamp = - new AttrDescriptor("time_stamp", header_section_schemat_time_stamp_text, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_6time_stamp); - ListTypeDescriptor *t_1 = new ListTypeDescriptor; - t_1->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_1->SetBound1(1); - t_1->SetBound2(2147483647); - t_1->FundamentalType(LIST_TYPE); - t_1->Description("LIST [1:?] OF STRING (256)"); - t_1->OriginatingSchema(s_header_section_schema); - t_1->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_1); + new AttrDescriptor( "time_stamp", header_section_schemat_time_stamp_text, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_6time_stamp ); + ListTypeDescriptor * t_1 = new ListTypeDescriptor; + t_1->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_1->SetBound1( 1 ); + t_1->SetBound2( 2147483647 ); + t_1->FundamentalType( LIST_TYPE ); + t_1->Description( "LIST [1:?] OF STRING (256)" ); + t_1->OriginatingSchema( s_header_section_schema ); + t_1->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_1 ); a_7author = - new AttrDescriptor("author", t_1, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_7author); - ListTypeDescriptor *t_2 = new ListTypeDescriptor; - t_2->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_2->SetBound1(1); - t_2->SetBound2(2147483647); - t_2->FundamentalType(LIST_TYPE); - t_2->Description("LIST [1:?] OF STRING (256)"); - t_2->OriginatingSchema(s_header_section_schema); - t_2->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_2); + new AttrDescriptor( "author", t_1, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_7author ); + ListTypeDescriptor * t_2 = new ListTypeDescriptor; + t_2->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_2->SetBound1( 1 ); + t_2->SetBound2( 2147483647 ); + t_2->FundamentalType( LIST_TYPE ); + t_2->Description( "LIST [1:?] OF STRING (256)" ); + t_2->OriginatingSchema( s_header_section_schema ); + t_2->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_2 ); a_8organization = - new AttrDescriptor("organization", t_2, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_8organization); + new AttrDescriptor( "organization", t_2, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_8organization ); a_9preprocessor_version = - new AttrDescriptor("preprocessor_version", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_9preprocessor_version); + new AttrDescriptor( "preprocessor_version", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_9preprocessor_version ); a_10originating_system = - new AttrDescriptor("originating_system", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_10originating_system); + new AttrDescriptor( "originating_system", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_10originating_system ); a_11authorization = - new AttrDescriptor("authorization", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_name); - header_section_schemae_file_name->AddExplicitAttr(a_11authorization); - reg.AddEntity(*header_section_schemae_file_name); + new AttrDescriptor( "authorization", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_name ); + header_section_schemae_file_name->AddExplicitAttr( a_11authorization ); + reg.AddEntity( *header_section_schemae_file_name ); ///////// END_ENTITY file_name ///////// ENTITY section_context a_12section = - new AttrDescriptor("section", header_section_schemat_section_name, - LTrue, LTrue, AttrType_Explicit, - *header_section_schemae_section_context); - header_section_schemae_section_context->AddExplicitAttr(a_12section); - ListTypeDescriptor *t_3 = new ListTypeDescriptor; - t_3->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_3->SetBound1(1); - t_3->SetBound2(2147483647); - t_3->FundamentalType(LIST_TYPE); - t_3->Description("LIST [1:?] OF context_name"); - t_3->OriginatingSchema(s_header_section_schema); - t_3->ReferentType(header_section_schemat_context_name); - s_header_section_schema->AddUnnamedType(t_3); + new AttrDescriptor( "section", header_section_schemat_section_name, + LTrue, LTrue, AttrType_Explicit, + *header_section_schemae_section_context ); + header_section_schemae_section_context->AddExplicitAttr( a_12section ); + ListTypeDescriptor * t_3 = new ListTypeDescriptor; + t_3->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_3->SetBound1( 1 ); + t_3->SetBound2( 2147483647 ); + t_3->FundamentalType( LIST_TYPE ); + t_3->Description( "LIST [1:?] OF context_name" ); + t_3->OriginatingSchema( s_header_section_schema ); + t_3->ReferentType( header_section_schemat_context_name ); + s_header_section_schema->AddUnnamedType( t_3 ); a_13context_identifiers = - new AttrDescriptor("context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_section_context); - header_section_schemae_section_context->AddExplicitAttr(a_13context_identifiers); - reg.AddEntity(*header_section_schemae_section_context); + new AttrDescriptor( "context_identifiers", t_3, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_section_context ); + header_section_schemae_section_context->AddExplicitAttr( a_13context_identifiers ); + reg.AddEntity( *header_section_schemae_section_context ); ///////// END_ENTITY section_context ///////// ENTITY file_description - ListTypeDescriptor *t_4 = new ListTypeDescriptor; - t_4->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_4->SetBound1(1); - t_4->SetBound2(2147483647); - t_4->FundamentalType(LIST_TYPE); - t_4->Description("LIST [1:?] OF STRING (256)"); - t_4->OriginatingSchema(s_header_section_schema); - t_4->ReferentType(t_sdaiSTRING); - s_header_section_schema->AddUnnamedType(t_4); + ListTypeDescriptor * t_4 = new ListTypeDescriptor; + t_4->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_4->SetBound1( 1 ); + t_4->SetBound2( 2147483647 ); + t_4->FundamentalType( LIST_TYPE ); + t_4->Description( "LIST [1:?] OF STRING (256)" ); + t_4->OriginatingSchema( s_header_section_schema ); + t_4->ReferentType( t_sdaiSTRING ); + s_header_section_schema->AddUnnamedType( t_4 ); a_14description = - new AttrDescriptor("description", t_4, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description); - header_section_schemae_file_description->AddExplicitAttr(a_14description); + new AttrDescriptor( "description", t_4, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description ); + header_section_schemae_file_description->AddExplicitAttr( a_14description ); a_15implementation_level = - new AttrDescriptor("implementation_level", t_sdaiSTRING, - LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_description); - header_section_schemae_file_description->AddExplicitAttr(a_15implementation_level); - reg.AddEntity(*header_section_schemae_file_description); + new AttrDescriptor( "implementation_level", t_sdaiSTRING, + LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_description ); + header_section_schemae_file_description->AddExplicitAttr( a_15implementation_level ); + reg.AddEntity( *header_section_schemae_file_description ); ///////// END_ENTITY file_description ///////// ENTITY file_schema - ListTypeDescriptor *t_5 = new ListTypeDescriptor; - t_5->AssignAggrCreator((AggregateCreator) create_StringAggregate); // Creator function - t_5->SetBound1(1); - t_5->SetBound2(2147483647); - t_5->UniqueElements(LTrue); - t_5->FundamentalType(LIST_TYPE); - t_5->Description("LIST [1:?] OF UNIQUE schema_name"); - t_5->OriginatingSchema(s_header_section_schema); - t_5->ReferentType(header_section_schemat_schema_name); - s_header_section_schema->AddUnnamedType(t_5); + ListTypeDescriptor * t_5 = new ListTypeDescriptor; + t_5->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function + t_5->SetBound1( 1 ); + t_5->SetBound2( 2147483647 ); + t_5->UniqueElements( LTrue ); + t_5->FundamentalType( LIST_TYPE ); + t_5->Description( "LIST [1:?] OF UNIQUE schema_name" ); + t_5->OriginatingSchema( s_header_section_schema ); + t_5->ReferentType( header_section_schemat_schema_name ); + s_header_section_schema->AddUnnamedType( t_5 ); a_16schema_identifiers = - new AttrDescriptor("schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, - *header_section_schemae_file_schema); - header_section_schemae_file_schema->AddExplicitAttr(a_16schema_identifiers); - reg.AddEntity(*header_section_schemae_file_schema); + new AttrDescriptor( "schema_identifiers", t_5, LFalse, LFalse, AttrType_Explicit, + *header_section_schemae_file_schema ); + header_section_schemae_file_schema->AddExplicitAttr( a_16schema_identifiers ); + reg.AddEntity( *header_section_schemae_file_schema ); ///////// END_ENTITY file_schema } diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index a5c2a45b3..05790a09c 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -7,11 +7,10 @@ #include #include "sc_memmgr.h" -void HeaderSchemaInit(Registry ®) -{ - HeaderInitSchemasAndEnts(reg); - SdaiHEADER_SECTION_SCHEMAInit(reg); - reg.SetCompCollect(0); +void HeaderSchemaInit( Registry & reg ) { + HeaderInitSchemasAndEnts( reg ); + SdaiHEADER_SECTION_SCHEMAInit( reg ); + reg.SetCompCollect( 0 ); } #endif diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index 2a9589ff7..a0868fbc6 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -20,8 +20,8 @@ #include #include -SC_EDITOR_EXPORT void HeaderSchemaInit(Registry &); -SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts(Registry &); -SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit(Registry &r); +SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & ); +SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & ); +SC_EDITOR_EXPORT void SdaiHEADER_SECTION_SCHEMAInit( Registry & r ); #endif diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index ed90f8887..7c015ce47 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -13,79 +13,72 @@ #include #include "sc_memmgr.h" -ReplicateLinkNode *ReplicateList::FindNode(MgrNode *mn) -{ - ReplicateLinkNode *rln = (ReplicateLinkNode *)GetHead(); +ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { + ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); int numEntries = EntryCount(); - while(numEntries--) { - if(rln->ReplicateNode() == mn) { + while( numEntries-- ) { + if( rln->ReplicateNode() == mn ) { return rln; } - rln = (ReplicateLinkNode *)rln->NextNode(); + rln = ( ReplicateLinkNode * )rln->NextNode(); } return 0; } -bool ReplicateList::IsOnList(MgrNode *mn) -{ - return (FindNode(mn) != 0); +bool ReplicateList::IsOnList( MgrNode * mn ) { + return ( FindNode( mn ) != 0 ); } /////////////////////////////////////////////////////////////////////////////// // returns true if it could delete the node /////////////////////////////////////////////////////////////////////////////// -bool ReplicateList::Remove(ReplicateLinkNode *rln) -{ - ReplicateLinkNode *rnFollow = (ReplicateLinkNode *)GetHead(); - if(!rnFollow || !rln) { +bool ReplicateList::Remove( ReplicateLinkNode * rln ) { + ReplicateLinkNode * rnFollow = ( ReplicateLinkNode * )GetHead(); + if( !rnFollow || !rln ) { return false; } else { - if(rnFollow == rln) { + if( rnFollow == rln ) { head = rln->NextNode(); delete rln; return true; } else { - ReplicateLinkNode *rn = (ReplicateLinkNode *)rnFollow->NextNode(); - while(rn) { - if(rn == rln) { - rnFollow->next = (SingleLinkNode *)rln->NextNode(); + ReplicateLinkNode * rn = ( ReplicateLinkNode * )rnFollow->NextNode(); + while( rn ) { + if( rn == rln ) { + rnFollow->next = ( SingleLinkNode * )rln->NextNode(); delete rln; return true; } rnFollow = rn; - rn = (ReplicateLinkNode *)rn->NextNode(); + rn = ( ReplicateLinkNode * )rn->NextNode(); } // end while(rn) } // end else } // end else return false; } -bool ReplicateList::Remove(MgrNode *rn) -{ - return Remove(FindNode(rn)); +bool ReplicateList::Remove( MgrNode * rn ) { + return Remove( FindNode( rn ) ); } -CmdMgr::CmdMgr() -{ - completeList = new MgrNodeList(completeSE); - incompleteList = new MgrNodeList(incompleteSE); - deleteList = new MgrNodeList(deleteSE); +CmdMgr::CmdMgr() { + completeList = new MgrNodeList( completeSE ); + incompleteList = new MgrNodeList( incompleteSE ); + deleteList = new MgrNodeList( deleteSE ); - mappedWriteList = new DisplayNodeList(mappedWrite); - mappedViewList = new DisplayNodeList(mappedView); - closeList = new DisplayNodeList(notMapped); + mappedWriteList = new DisplayNodeList( mappedWrite ); + mappedViewList = new DisplayNodeList( mappedView ); + closeList = new DisplayNodeList( notMapped ); replicateList = new ReplicateList(); } -void CmdMgr::ReplicateCmdList(MgrNode *mn) -{ - if(!(replicateList->IsOnList(mn))) { - replicateList->AddNode(mn); +void CmdMgr::ReplicateCmdList( MgrNode * mn ) { + if( !( replicateList->IsOnList( mn ) ) ) { + replicateList->AddNode( mn ); } } -void CmdMgr::ClearInstances() -{ +void CmdMgr::ClearInstances() { completeList->ClearEntries(); incompleteList->ClearEntries(); cancelList->ClearEntries(); @@ -94,15 +87,14 @@ void CmdMgr::ClearInstances() } /// searches current list for fileId -MgrNode *CmdMgr::StateFindFileId(stateEnum s, int fileId) -{ - switch(s) { +MgrNode * CmdMgr::StateFindFileId( stateEnum s, int fileId ) { + switch( s ) { case completeSE: - return completeList->FindFileId(fileId); + return completeList->FindFileId( fileId ); case incompleteSE: - return incompleteList->FindFileId(fileId); + return incompleteList->FindFileId( fileId ); case deleteSE: - return deleteList->FindFileId(fileId); + return deleteList->FindFileId( fileId ); case newSE: // there is no new list case noStateSE: default: @@ -112,31 +104,29 @@ MgrNode *CmdMgr::StateFindFileId(stateEnum s, int fileId) } } -MgrNode *CmdMgr::GetHead(stateEnum listType) -{ - switch(listType) { +MgrNode * CmdMgr::GetHead( stateEnum listType ) { + switch( listType ) { case completeSE: // saved complete list - return (MgrNode *)completeList->GetHead(); + return ( MgrNode * )completeList->GetHead(); case incompleteSE: // saved incomplete list - return (MgrNode *)incompleteList->GetHead(); + return ( MgrNode * )incompleteList->GetHead(); case deleteSE: // delete list - return (MgrNode *)deleteList->GetHead(); + return ( MgrNode * )deleteList->GetHead(); default: return 0; } } -DisplayNode *CmdMgr::GetHead(displayStateEnum listType) -{ - switch(listType) { +DisplayNode * CmdMgr::GetHead( displayStateEnum listType ) { + switch( listType ) { case mappedWrite: - return (DisplayNode *)mappedWriteList->GetHead(); + return ( DisplayNode * )mappedWriteList->GetHead(); case mappedView: - return (DisplayNode *)mappedViewList->GetHead(); + return ( DisplayNode * )mappedViewList->GetHead(); case notMapped: - return (DisplayNode *)closeList->GetHead(); + return ( DisplayNode * )closeList->GetHead(); case noMapState: default: @@ -144,9 +134,8 @@ DisplayNode *CmdMgr::GetHead(displayStateEnum listType) } } -void CmdMgr::ClearEntries(stateEnum listType) -{ - switch(listType) { +void CmdMgr::ClearEntries( stateEnum listType ) { + switch( listType ) { case completeSE: // saved complete list completeList->ClearEntries(); break; @@ -161,9 +150,8 @@ void CmdMgr::ClearEntries(stateEnum listType) } } -void CmdMgr::ClearEntries(displayStateEnum listType) -{ - switch(listType) { +void CmdMgr::ClearEntries( displayStateEnum listType ) { + switch( listType ) { case mappedWrite: mappedWriteList->ClearEntries(); break; diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 0f985cb24..7ef2f00b5 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -77,141 +77,121 @@ /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode -{ +class SC_EDITOR_EXPORT ReplicateLinkNode : public SingleLinkNode { private: protected: - MgrNode *_repNode; + MgrNode * _repNode; public: - ReplicateLinkNode() - { + ReplicateLinkNode() { _repNode = 0; } ~ReplicateLinkNode() { } - const char *ClassName() - { + const char * ClassName() { return "ReplicateLinkNode"; } - MgrNode *ReplicateNode() - { + MgrNode * ReplicateNode() { return _repNode; } - void ReplicateNode(MgrNode *rn) - { + void ReplicateNode( MgrNode * rn ) { _repNode = rn; } }; -class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList -{ +class SC_EDITOR_EXPORT ReplicateList : public SingleLinkList { private: protected: public: ReplicateList() { } ~ReplicateList() { } - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new ReplicateLinkNode; } - bool IsOnList(MgrNode *mn); - ReplicateLinkNode *FindNode(MgrNode *mn); + bool IsOnList( MgrNode * mn ); + ReplicateLinkNode * FindNode( MgrNode * mn ); - ReplicateLinkNode *AddNode(MgrNode *rn) - { - ReplicateLinkNode *node = (ReplicateLinkNode *) NewNode(); - node->ReplicateNode(rn); - SingleLinkList::AppendNode(node); + ReplicateLinkNode * AddNode( MgrNode * rn ) { + ReplicateLinkNode * node = ( ReplicateLinkNode * ) NewNode(); + node->ReplicateNode( rn ); + SingleLinkList::AppendNode( node ); return node; } - bool Remove(ReplicateLinkNode *rln); - bool Remove(MgrNode *rn); + bool Remove( ReplicateLinkNode * rln ); + bool Remove( MgrNode * rn ); - const char *ClassName() - { + const char * ClassName() { return "ReplicateList"; } }; /////////////////////////////////////////////////////////////////////////////// -class SC_EDITOR_EXPORT CmdMgr -{ +class SC_EDITOR_EXPORT CmdMgr { protected: - MgrNodeList *completeList; - MgrNodeList *incompleteList; - MgrNodeList *cancelList; - MgrNodeList *deleteList; + MgrNodeList * completeList; + MgrNodeList * incompleteList; + MgrNodeList * cancelList; + MgrNodeList * deleteList; - DisplayNodeList *mappedWriteList; - DisplayNodeList *mappedViewList; - DisplayNodeList *closeList; + DisplayNodeList * mappedWriteList; + DisplayNodeList * mappedViewList; + DisplayNodeList * closeList; - ReplicateList *replicateList; + ReplicateList * replicateList; public: CmdMgr(); // STATE LIST OPERATIONS - MgrNode *GetHead(stateEnum listType); - DisplayNode *GetHead(displayStateEnum listType); - ReplicateLinkNode *GetReplicateHead() - { - return (ReplicateLinkNode *)(replicateList->GetHead()); + MgrNode * GetHead( stateEnum listType ); + DisplayNode * GetHead( displayStateEnum listType ); + ReplicateLinkNode * GetReplicateHead() { + return ( ReplicateLinkNode * )( replicateList->GetHead() ); } - void ClearEntries(stateEnum listType); - void ClearEntries(displayStateEnum listType); - void ClearReplicateEntries() - { + void ClearEntries( stateEnum listType ); + void ClearEntries( displayStateEnum listType ); + void ClearReplicateEntries() { replicateList->Empty(); } - ReplicateList *RepList() - { + ReplicateList * RepList() { return replicateList; } // searches current list for fileId - MgrNode *StateFindFileId(stateEnum s, int fileId); + MgrNode * StateFindFileId( stateEnum s, int fileId ); // returns stateNext or statePrev member variables // i.e. next or previous node on curr state list - int SaveCompleteCmdList(MgrNode *mn) - { - return mn->ChangeList(completeList); + int SaveCompleteCmdList( MgrNode * mn ) { + return mn->ChangeList( completeList ); } - int SaveIncompleteCmdList(MgrNode *mn) - { - return mn->ChangeList(incompleteList); + int SaveIncompleteCmdList( MgrNode * mn ) { + return mn->ChangeList( incompleteList ); } - int CancelCmdList(MgrNode *mn) - { - return mn->ChangeList(cancelList); + int CancelCmdList( MgrNode * mn ) { + return mn->ChangeList( cancelList ); } - int DeleteCmdList(MgrNode *mn) - { - return mn->ChangeList(deleteList); + int DeleteCmdList( MgrNode * mn ) { + return mn->ChangeList( deleteList ); } - int ModifyCmdList(MgrNode *mn) - { - return mn->ChangeList(mappedWriteList); + int ModifyCmdList( MgrNode * mn ) { + return mn->ChangeList( mappedWriteList ); } - int ViewCmdList(MgrNode *mn) - { - return mn->ChangeList(mappedViewList); + int ViewCmdList( MgrNode * mn ) { + return mn->ChangeList( mappedViewList ); } - int CloseCmdList(MgrNode *mn) - { - return ((mn->DisplayState() == mappedWrite) || - (mn->DisplayState() == mappedView)) ? - mn->ChangeList(closeList) : 0; + int CloseCmdList( MgrNode * mn ) { + return ( ( mn->DisplayState() == mappedWrite ) || + ( mn->DisplayState() == mappedView ) ) ? + mn->ChangeList( closeList ) : 0; } - void ReplicateCmdList(MgrNode *mn); + void ReplicateCmdList( MgrNode * mn ); void ClearInstances(); protected: diff --git a/src/cleditor/seeinfodefault.h b/src/cleditor/seeinfodefault.h index 5c24ba863..51198eac8 100644 --- a/src/cleditor/seeinfodefault.h +++ b/src/cleditor/seeinfodefault.h @@ -25,26 +25,23 @@ class DisplayNodelist; #include -class SC_EDITOR_EXPORT seeInfo : public DisplayNode -{ +class SC_EDITOR_EXPORT seeInfo : public DisplayNode { public: - seeInfo(MgrNode *node, - SDAI_Application_instance *se, - DisplayNodeList *dnl, displayStateEnum displaySt = mappedWrite); + seeInfo( MgrNode * node, + SDAI_Application_instance * se, + DisplayNodeList * dnl, displayStateEnum displaySt = mappedWrite ); - void *GetSEE() - { + void * GetSEE() { return see; } }; -inline seeInfo::seeInfo(MgrNode *node, SDAI_Application_instance *se, - DisplayNodeList *dnl, displayStateEnum displaySt) -{ +inline seeInfo::seeInfo( MgrNode * node, SDAI_Application_instance * se, + DisplayNodeList * dnl, displayStateEnum displaySt ) { mn = node; see = 0; displayState = displaySt; - dnl->Append(this); + dnl->Append( this ); } #endif diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index b5e763628..d737a9c89 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -32,23 +32,22 @@ include_directories( set(_libdeps stepcore stepdai steputils base stepeditor) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) - set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static) - SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) endif() SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile) # Local Variables: # tab-width: 8 diff --git a/src/cllazyfile/headerSectionReader.h b/src/cllazyfile/headerSectionReader.h index 6c5bf721d..8a51f5721 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/src/cllazyfile/headerSectionReader.h @@ -13,25 +13,21 @@ #include "sc_export.h" ///differs from the lazyDataSectionReader in that all instances are always loaded -class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader -{ +class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader { protected: - instancesLoaded_t *_headerInstances; + instancesLoaded_t * _headerInstances; /// must derive from this class - headerSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid): - sectionReader(parent, file, start, sid) - { + headerSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): + sectionReader( parent, file, start, sid ) { _headerInstances = new instancesLoaded_t; } public: - instancesLoaded_t *getInstances() const - { + instancesLoaded_t * getInstances() const { return _headerInstances; } - virtual ~headerSectionReader() - { + virtual ~headerSectionReader() { //FIXME delete each instance?! maybe add to clear, since it iterates over everything already //enum clearHow { rawData, deletePointers } _headerInstances->clear(); diff --git a/src/cllazyfile/instMgrHelper.h b/src/cllazyfile/instMgrHelper.h index 0d9321766..659f1ec8e 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/src/cllazyfile/instMgrHelper.h @@ -17,25 +17,21 @@ * 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 SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase -{ +class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase { protected: - lazyInstMgr *_lim; + lazyInstMgr * _lim; instanceID _id; public: - mgrNodeHelper(lazyInstMgr *lim) - { + mgrNodeHelper( lazyInstMgr * lim ) { _lim = lim; _id = 0; prev = next = 0; } - inline void setInstance(instanceID id) - { + inline void setInstance( instanceID id ) { _id = id; } - inline SDAI_Application_instance *GetSTEPentity() - { - return _lim->loadInstance(_id, true); + inline SDAI_Application_instance * GetSTEPentity() { + return _lim->loadInstance( _id, true ); } }; @@ -47,17 +43,15 @@ class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase * when an instance is looked up, this uses lazyInstMgr to load it, and then returns a pointer to it. */ -class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase -{ +class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase { protected: mgrNodeHelper _mn; public: - instMgrAdapter(lazyInstMgr *lim): InstMgrBase(), _mn(lim) {} + instMgrAdapter( lazyInstMgr * lim ): InstMgrBase(), _mn( lim ) {} - inline mgrNodeHelper *FindFileId(int fileId) - { + inline mgrNodeHelper * FindFileId( int fileId ) { //TODO check if fileId exists. if not, return null - _mn.setInstance(fileId); + _mn.setInstance( fileId ); return &_mn; } }; diff --git a/src/cllazyfile/lazyDataSectionReader.cc b/src/cllazyfile/lazyDataSectionReader.cc index 5d7941bd3..4b1bc1785 100644 --- a/src/cllazyfile/lazyDataSectionReader.cc +++ b/src/cllazyfile/lazyDataSectionReader.cc @@ -3,10 +3,9 @@ #include "lazyInstMgr.h" #include -lazyDataSectionReader::lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - sectionReader(parent, file, start, sid) -{ +lazyDataSectionReader::lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + sectionReader( parent, file, start, sid ) { _sectionIdentifier = ""; //FIXME set _sectionIdentifier from the data section identifier (2002 rev of Part 21), if present _error = false; } diff --git a/src/cllazyfile/lazyDataSectionReader.h b/src/cllazyfile/lazyDataSectionReader.h index 9f4d9763c..f2dc9dee4 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/src/cllazyfile/lazyDataSectionReader.h @@ -13,8 +13,7 @@ * \sa lazyP21DataSectionReader * \sa lazyP28DataSectionReader */ -class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader -{ +class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader { protected: bool _error, _completelyLoaded; #ifdef _MSC_VER @@ -27,11 +26,10 @@ class SC_LAZYFILE_EXPORT lazyDataSectionReader: public sectionReader #endif /// only makes sense to call the ctor from derived class ctors - lazyDataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); public: virtual ~lazyDataSectionReader() {} - bool success() - { + bool success() { return !_error; } }; diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index baba1f137..9cc294df0 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -6,39 +6,37 @@ #include "headerSectionReader.h" #include "lazyInstMgr.h" -void lazyFileReader::initP21() -{ - _header = new p21HeaderSectionReader(this, _file, 0, -1); +void lazyFileReader::initP21() { + _header = new p21HeaderSectionReader( this, _file, 0, -1 ); - for(;;) { - lazyDataSectionReader *r; - r = new lazyP21DataSectionReader(this, _file, _file.tellg(), _parent->countDataSections()); - if(!r->success()) { + for( ;; ) { + lazyDataSectionReader * r; + r = new lazyP21DataSectionReader( this, _file, _file.tellg(), _parent->countDataSections() ); + if( !r->success() ) { delete r; //last read attempt failed std::cerr << "Corrupted data section" << std::endl; break; } - _parent->registerDataSection(r); + _parent->registerDataSection( r ); //check for new data section (DATA) or end of file (END-ISO-10303-21;) - while(isspace(_file.peek()) && _file.good()) { - _file.ignore(1); + while( isspace( _file.peek() ) && _file.good() ) { + _file.ignore( 1 ); } - if(needKW("END-ISO-10303-21;")) { + if( needKW( "END-ISO-10303-21;" ) ) { break; - } else if(!needKW("DATA")) { + } else if( !needKW( "DATA" ) ) { std::cerr << "Corrupted file - did not find new data section (\"DATA\") or end of file (\"END-ISO-10303-21;\") at offset " << _file.tellg() << std::endl; break; } } } -bool lazyFileReader::needKW(const char *kw) -{ - const char *c = kw; +bool lazyFileReader::needKW( const char * kw ) { + const char * c = kw; bool found = true; - while(*c) { - if(*c != _file.get()) { + while( *c ) { + if( *c != _file.get() ) { found = false; break; } @@ -47,34 +45,31 @@ bool lazyFileReader::needKW(const char *kw) return found; } -instancesLoaded_t *lazyFileReader::getHeaderInstances() -{ +instancesLoaded_t * lazyFileReader::getHeaderInstances() { return _header->getInstances(); } -lazyFileReader::lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid): _fileName(fname), _parent(i), _fileID(fid) -{ - _file.open(_fileName.c_str(), std::ios::binary); - _file.imbue(std::locale::classic()); - _file.unsetf(std::ios_base::skipws); - assert(_file.is_open() && _file.good()); +lazyFileReader::lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ): _fileName( fname ), _parent( i ), _fileID( fid ) { + _file.open( _fileName.c_str(), std::ios::binary ); + _file.imbue( std::locale::classic() ); + _file.unsetf( std::ios_base::skipws ); + assert( _file.is_open() && _file.good() ); detectType(); - switch(_fileType) { + switch( _fileType ) { case Part21: initP21(); break; case Part28: - //initP28(); - //break; + //initP28(); + //break; default: std::cerr << "Reached default case, " << __FILE__ << ":" << __LINE__ << std::endl; abort(); } } -lazyFileReader::~lazyFileReader() -{ +lazyFileReader::~lazyFileReader() { delete _header; } diff --git a/src/cllazyfile/lazyFileReader.h b/src/cllazyfile/lazyFileReader.h index 10a9baabd..49eea5b50 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/src/cllazyfile/lazyFileReader.h @@ -24,16 +24,15 @@ class headerSectionReader; ///read an exchange file of any supported type (currently only p21) ///for use only from within lazyInstMgr -class SC_LAZYFILE_EXPORT lazyFileReader -{ +class SC_LAZYFILE_EXPORT lazyFileReader { protected: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif std::string _fileName; - lazyInstMgr *_parent; - headerSectionReader *_header; + lazyInstMgr * _parent; + headerSectionReader * _header; std::ifstream _file; #ifdef _MSC_VER #pragma warning( pop ) @@ -44,30 +43,26 @@ class SC_LAZYFILE_EXPORT lazyFileReader void initP21(); ///TODO detect file type; for now, assume all are Part 21 - void detectType() - { + void detectType() { _fileType = Part21; } public: - fileID ID() const - { + fileID ID() const { return _fileID; } - instancesLoaded_t *getHeaderInstances(); + instancesLoaded_t * getHeaderInstances(); - lazyFileReader(std::string fname, lazyInstMgr *i, fileID fid); + lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ); ~lazyFileReader(); - fileTypeEnum type() const - { + fileTypeEnum type() const { return _fileType; } - lazyInstMgr *getInstMgr() const - { + lazyInstMgr * getInstMgr() const { return _parent; } - bool needKW(const char *kw); + bool needKW( const char * kw ); }; #endif //LAZYFILEREADER_H diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 7d30d3c71..7ce253ee9 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -8,52 +8,48 @@ #include "sdaiApplication_instance.h" -lazyInstMgr::lazyInstMgr() -{ - _headerRegistry = new Registry(HeaderSchemaInit); - _instanceTypes = new instanceTypes_t(255); //NOTE arbitrary max of 255 chars for a type name +lazyInstMgr::lazyInstMgr() { + _headerRegistry = new Registry( HeaderSchemaInit ); + _instanceTypes = new instanceTypes_t( 255 ); //NOTE arbitrary max of 255 chars for a type name _lazyInstanceCount = 0; _loadedInstanceCount = 0; _longestTypeNameLen = 0; _mainRegistry = 0; _errors = new ErrorDescriptor(); - _ima = new instMgrAdapter(this); + _ima = new instMgrAdapter( this ); } -lazyInstMgr::~lazyInstMgr() -{ +lazyInstMgr::~lazyInstMgr() { delete _headerRegistry; delete _errors; delete _ima; //loop over files, sections, instances; delete header instances lazyFileReaderVec_t::iterator fit = _files.begin(); - for(; fit != _files.end(); ++fit) { + for( ; fit != _files.end(); ++fit ) { delete *fit; } dataSectionReaderVec_t::iterator sit = _dataSections.begin(); - for(; sit != _dataSections.end(); ++sit) { + for( ; sit != _dataSections.end(); ++sit ) { delete *sit; } _instancesLoaded.clear(); _instanceStreamPos.clear(); } -sectionID lazyInstMgr::registerDataSection(lazyDataSectionReader *sreader) -{ - _dataSections.push_back(sreader); +sectionID lazyInstMgr::registerDataSection( lazyDataSectionReader * sreader ) { + _dataSections.push_back( sreader ); return _dataSections.size() - 1; } -void lazyInstMgr::addLazyInstance(namedLazyInstance inst) -{ +void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) { _lazyInstanceCount++; - assert(inst.loc.begin > 0 && inst.loc.instance > 0); - int len = strlen(inst.name); - if(len > _longestTypeNameLen) { + assert( inst.loc.begin > 0 && inst.loc.instance > 0 ); + int len = strlen( inst.name ); + if( len > _longestTypeNameLen ) { _longestTypeNameLen = len; _longestTypeName = inst.name; } - _instanceTypes->insert(inst.name, inst.loc.instance); + _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? @@ -64,17 +60,17 @@ void lazyInstMgr::addLazyInstance(namedLazyInstance inst) */ positionAndSection ps = inst.loc.section; ps <<= 48; - ps |= (inst.loc.begin & 0xFFFFFFFFFFFFULL); - _instanceStreamPos.insert(inst.loc.instance, ps); + ps |= ( inst.loc.begin & 0xFFFFFFFFFFFFULL ); + _instanceStreamPos.insert( inst.loc.instance, ps ); - if(inst.refs) { - if(inst.refs->size() > 0) { + if( inst.refs ) { + if( inst.refs->size() > 0 ) { //forward refs - _fwdInstanceRefs.insert(inst.loc.instance, *inst.refs); + _fwdInstanceRefs.insert( inst.loc.instance, *inst.refs ); instanceRefs::iterator it = inst.refs->begin(); - for(; it != inst.refs->end(); ++it) { + for( ; it != inst.refs->end(); ++it ) { //reverse refs - _revInstanceRefs.insert(*it, inst.loc.instance); + _revInstanceRefs.insert( *it, inst.loc.instance ); } } else { delete inst.refs; @@ -82,15 +78,14 @@ void lazyInstMgr::addLazyInstance(namedLazyInstance inst) } } -unsigned long lazyInstMgr::getNumTypes() const -{ +unsigned long lazyInstMgr::getNumTypes() const { unsigned long n = 0 ; instanceTypes_t::cpair curr, end; end = _instanceTypes->end(); curr = _instanceTypes->begin(); - if(curr.value != 0) { + if( curr.value != 0 ) { n = 1; - while(curr.value != end.value) { + while( curr.value != end.value ) { n++; curr = _instanceTypes->next(); } @@ -98,58 +93,56 @@ unsigned long lazyInstMgr::getNumTypes() const return n ; } -void lazyInstMgr::openFile(std::string fname) -{ +void lazyInstMgr::openFile( std::string fname ) { //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); + _files.push_back( (lazyFileReader * ) 0 ); ///FIXME end atomic op - lazyFileReader *lfr = new lazyFileReader(fname, this, i); + 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, bool reSeek) -{ - assert(_mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()."); +SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id, bool reSeek ) { + assert( _mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()." ); std::streampos oldPos; positionAndSection ps; sectionID sid; - SDAI_Application_instance *inst = _instancesLoaded.find(id); - if(inst) { + SDAI_Application_instance * inst = _instancesLoaded.find( id ); + if( inst ) { return inst; } - instanceStreamPos_t::cvector *cv; - if(0 != (cv = _instanceStreamPos.find(id))) { - switch(cv->size()) { + instanceStreamPos_t::cvector * cv; + if( 0 != ( cv = _instanceStreamPos.find( id ) ) ) { + switch( cv->size() ) { case 0: std::cerr << "Instance #" << id << " not found in any section." << std::endl; break; case 1: long int off; - ps = cv->at(0); + ps = cv->at( 0 ); off = ps & 0xFFFFFFFFFFFFULL; sid = ps >> 48; - assert(_dataSections.size() > sid); - if(reSeek) { + assert( _dataSections.size() > sid ); + if( reSeek ) { oldPos = _dataSections[sid]->tellg(); } - inst = _dataSections[sid]->getRealInstance(_mainRegistry, off, id); - if(reSeek) { - _dataSections[sid]->seekg(oldPos); + 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; break; } - if(!isNilSTEPentity(inst)) { - _instancesLoaded.insert(id, inst); + if( !isNilSTEPentity( inst ) ) { + _instancesLoaded.insert( id, inst ); _loadedInstanceCount++; - lazyRefs lr(this, inst); + lazyRefs lr( this, inst ); lazyRefs::referentInstances_t insts = lr.result(); } else { std::cerr << "Error loading instance #" << id << "." << std::endl; @@ -161,27 +154,26 @@ SDAI_Application_instance *lazyInstMgr::loadInstance(instanceID id, bool reSeek) } -instanceSet *lazyInstMgr::instanceDependencies(instanceID id) -{ - instanceSet *checkedDependencies = new instanceSet(); +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); + 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()); + 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()); + 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() ); } } diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 63d12464e..78444a756 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -21,8 +21,7 @@ class Registry; class instMgrAdapter; -class SC_LAZYFILE_EXPORT lazyInstMgr -{ +class SC_LAZYFILE_EXPORT lazyInstMgr { protected: /** multimap from instance number to instances that it refers to * \sa instanceRefs_pair @@ -41,7 +40,7 @@ class SC_LAZYFILE_EXPORT lazyInstMgr * \sa instanceType_pair * \sa instanceType_range */ - instanceTypes_t *_instanceTypes; + instanceTypes_t * _instanceTypes; /** map from instance number to instance pointer (loaded instances only) * \sa instancesLoaded_pair @@ -63,14 +62,14 @@ class SC_LAZYFILE_EXPORT lazyInstMgr lazyFileReaderVec_t _files; - Registry *_headerRegistry, * _mainRegistry; - ErrorDescriptor *_errors; + Registry * _headerRegistry, * _mainRegistry; + ErrorDescriptor * _errors; unsigned long _lazyInstanceCount, _loadedInstanceCount; int _longestTypeNameLen; std::string _longestTypeName; - instMgrAdapter *_ima; + instMgrAdapter * _ima; #ifdef _MSC_VER #pragma warning( pop ) @@ -79,103 +78,88 @@ class SC_LAZYFILE_EXPORT lazyInstMgr public: lazyInstMgr(); ~lazyInstMgr(); - void openFile(std::string fname); + void openFile( std::string fname ); - void addLazyInstance(namedLazyInstance inst); - InstMgrBase *getAdapter() - { - return (InstMgrBase *) _ima; + void addLazyInstance( namedLazyInstance inst ); + InstMgrBase * getAdapter() { + return ( InstMgrBase * ) _ima; } - instanceRefs_t *getFwdRefs() - { + instanceRefs_t * getFwdRefs() { return & _fwdInstanceRefs; } - instanceRefs_t *getRevRefs() - { + instanceRefs_t * getRevRefs() { return & _revInstanceRefs; } /// returns a vector containing the instances that match `type` - instanceTypes_t::cvector *getInstances(std::string type, bool caseSensitive = false) /*const*/ - { - if(!caseSensitive) { + 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); + for( ; it != type.end(); ++it ) { + *it = toupper( *it ); } } - return _instanceTypes->find(type.c_str()); + return _instanceTypes->find( type.c_str() ); } /// get the number of instances of a certain type - unsigned int countInstances(std::string type) - { - instanceTypes_t::cvector *v = _instanceTypes->find(type.c_str()); - if(!v) { + unsigned int countInstances( std::string type ) { + instanceTypes_t::cvector * v = _instanceTypes->find( type.c_str() ); + if( !v ) { return 0; } return v->size(); } - instancesLoaded_t *getHeaderInstances(fileID file) - { + instancesLoaded_t * getHeaderInstances( fileID file ) { return _files[file]->getHeaderInstances(); } /// get the number of instances that have been found in the open files. - unsigned long totalInstanceCount() const - { + unsigned long totalInstanceCount() const { return _lazyInstanceCount; } /// get the number of instances that are loaded. - unsigned long loadedInstanceCount() const - { + unsigned long loadedInstanceCount() const { return _loadedInstanceCount; } /// get the number of data sections that have been identified - unsigned int countDataSections() - { + unsigned int countDataSections() { return _dataSections.size(); } ///builds the registry using the given initFunct - const Registry *initRegistry(CF_init initFunct) - { - setRegistry(new Registry(initFunct)); + const Registry * initRegistry( CF_init initFunct ) { + setRegistry( new Registry( initFunct ) ); return _mainRegistry; } /// set the registry to one already initialized - void setRegistry(Registry *reg) - { - assert(_mainRegistry == 0); + void setRegistry( Registry * reg ) { + assert( _mainRegistry == 0 ); _mainRegistry = reg; } - const Registry *getHeaderRegistry() const - { + const Registry * getHeaderRegistry() const { return _headerRegistry; } - const Registry *getMainRegistry() const - { + const Registry * getMainRegistry() const { return _mainRegistry; } /// get the longest type name - const std::string &getLongestTypeName() const - { + const std::string & getLongestTypeName() const { return _longestTypeName; } /// get the number of types of instances. unsigned long getNumTypes() const; - sectionID registerDataSection(lazyDataSectionReader *sreader); + sectionID registerDataSection( lazyDataSectionReader * sreader ); - ErrorDescriptor *getErrorDesc() - { + ErrorDescriptor * getErrorDesc() { return _errors; } @@ -183,30 +167,28 @@ class SC_LAZYFILE_EXPORT lazyInstMgr * \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); + 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); + 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) { + 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); + positionAndSection ps = cv->at( 0 ); //extract p, s, call long int off = ps & 0xFFFFFFFFFFFFULL; sectionID sid = ps >> 48; - return _dataSections[sid]->getType(off); + return _dataSections[sid]->getType( off ); } std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " not found." << std::endl; return 0; @@ -214,24 +196,24 @@ class SC_LAZYFILE_EXPORT lazyInstMgr // TODO implement these - // add another schema to registry - //void addSchema( void ( *initFn )() ); + // add another schema to registry + //void addSchema( void ( *initFn )() ); - //list all instances that one instance depends on (recursive) - //std::vector instanceDependencies( instanceID id ); //set is faster? + //list all instances that one instance depends on (recursive) + //std::vector 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 notDependencies(...) + /* * the opposite of instanceDependencies() - all instances that are *not* dependencies of one particular instance + same as above, but with list of instances */ + //std::vector notDependencies(...) - //renumber instances so that they are numbered 1..N where N is the total number of instances - //void normalizeInstanceIds(); + //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(); + //find data that is repeated and eliminate, if possible + //void eliminateDuplicates(); - //tell instMgr to use instances from this section - //void useDataSection( sectionID id ); + //tell instMgr to use instances from this section + //void useDataSection( sectionID id ); // TODO support references from one file to another }; diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index d3f873c82..9e9df2070 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -3,40 +3,39 @@ #include "lazyP21DataSectionReader.h" #include "lazyInstMgr.h" -lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - lazyDataSectionReader(parent, file, start, sid) -{ +lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + lazyDataSectionReader( parent, file, start, sid ) { findSectionStart(); namedLazyInstance nl; - while(nl = nextInstance(), ((nl.loc.begin > 0) && (nl.name != 0))) { - parent->getInstMgr()->addLazyInstance(nl); + 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) { + if( sectionReader::_error->severity() <= SEVERITY_WARNING ) { + sectionReader::_error->PrintContents( std::cerr ); + if( sectionReader::_error->severity() <= SEVERITY_INPUT_ERROR ) { _error = true; - return; + return; } } - - if(!_file.good()) { + + if( !_file.good() ) { _error = true; return; } - if(nl.loc.instance == 0) { + if( nl.loc.instance == 0 ) { //check for ENDSEC; skipWS(); std::streampos pos = _file.tellg(); - if(_file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' + if( _file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D' && _file.get() == 'S' && _file.get() == 'E' && _file.get() == 'C' - && (skipWS(), _file.get() == ';')) { + && ( skipWS(), _file.get() == ';' ) ) { _sectionEnd = _file.tellg(); } else { - _file.seekg(pos); + _file.seekg( pos ); char found[26] = { '\0' }; - _file.read(found, 25); + _file.read( found, 25 ); std::cerr << "expected 'ENDSEC;', found " << found << std::endl; _error = true; } @@ -45,27 +44,26 @@ lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader *parent, std:: // part of readdata1 //if this changes, probably need to change sectionReader::getType() -const namedLazyInstance lazyP21DataSectionReader::nextInstance() -{ +const namedLazyInstance lazyP21DataSectionReader::nextInstance() { std::streampos end = -1; namedLazyInstance i; i.refs = 0; i.loc.begin = _file.tellg(); i.loc.instance = readInstanceNumber(); - if((_file.good()) && (i.loc.instance > 0)) { + if( ( _file.good() ) && ( i.loc.instance > 0 ) ) { skipWS(); i.loc.section = _sectionID; - i.name = getDelimitedKeyword(";( /\\"); - if(_file.good()) { - end = seekInstanceEnd(& i.refs); + i.name = getDelimitedKeyword( ";( /\\" ); + if( _file.good() ) { + end = seekInstanceEnd( & i.refs ); } } - if((i.loc.instance == 0) || (!_file.good()) || (end == (std::streampos) - 1)) { + if( ( i.loc.instance == 0 ) || ( !_file.good() ) || ( end == ( std::streampos ) - 1 ) ) { //invalid instance, so clear everything - _file.seekg(i.loc.begin); + _file.seekg( i.loc.begin ); i.loc.begin = -1; - if(i.refs) { + if( i.refs ) { delete i.refs; } i.name = 0; diff --git a/src/cllazyfile/lazyP21DataSectionReader.h b/src/cllazyfile/lazyP21DataSectionReader.h index a666fdeb2..423679142 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.h +++ b/src/cllazyfile/lazyP21DataSectionReader.h @@ -6,15 +6,13 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader -{ +class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { protected: public: - lazyP21DataSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); - void findSectionStart() - { - _sectionStart = findNormalString("DATA", true); + void findSectionStart() { + _sectionStart = findNormalString( "DATA", true ); } /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index b38f626a7..6d2e093e4 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -40,21 +40,20 @@ class SDAI_Application_instance; * 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) -*/ + /* **** + * 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 instances 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 SC_LAZYFILE_EXPORT lazyRefs -{ +class SC_LAZYFILE_EXPORT lazyRefs { public: typedef std::set< instanceID > referentInstances_t; protected: @@ -66,131 +65,126 @@ class SC_LAZYFILE_EXPORT lazyRefs #pragma warning( disable: 4251 ) #endif iaList_t _iaList; - lazyInstMgr *_lim; + lazyInstMgr * _lim; instanceID _id; refMap_t _refMap; referentInstances_t _referentInstances; - SDAI_Application_instance *_inst; + SDAI_Application_instance * _inst; #ifdef _MSC_VER #pragma warning( pop ) #endif - void checkAnInvAttr(const Inverse_attribute *ia) - { - const EntityDescriptor *ed; - const Registry *reg = _lim->getMainRegistry(); - ed = reg->FindEntity(ia->_inverted_entity_id); - subtypesIterator subtypeIter(ed); + 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); + edL.insert( ed ); // 3b - use subtypeIter to add to edL - for(; !subtypeIter.empty(); ++subtypeIter) { - edL.insert(*subtypeIter); + for( ; !subtypeIter.empty(); ++subtypeIter ) { + edL.insert( *subtypeIter ); } //3c - for each item in both _refMap and edL, add it to _referentInstances - potentialReferentInsts(edL); + potentialReferentInsts( edL ); //3d - load each inst - iAstruct ias = invAttr(_inst, ia); + iAstruct ias = invAttr( _inst, ia ); referentInstances_t::iterator insts = _referentInstances.begin(); - for(; insts != _referentInstances.end(); ++insts) { - loadInstIFFreferent(*insts, ias, ia); + 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) { + 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); + _inst->setInvAttr( ia, ias ); + assert( invAttr( _inst, ia ).a == ias.a ); } - EntityAggregate *ea = ias.a; + EntityAggregate * ea = ias.a; //TODO check if duplicate - ea->AddNode(new EntityNode(rinst)); + ea->AddNode( new EntityNode( rinst ) ); } else { - SDAI_Application_instance *ai = ias.i; - if(!ai) { + SDAI_Application_instance * ai = ias.i; + if( !ai ) { ias.i = rinst; - _inst->setInvAttr(ia, ias); - } else if(ai->GetFileId() != (int)inst) { - std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->eDesc->Name(); - std::cerr << " and " << ai << ", #" << ai->GetFileId() << "=" << ai->eDesc->Name() << ") refer to inst "; + _inst->setInvAttr( ia, ias ); + } else if( ai->GetFileId() != (int)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) { + 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) - { + 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); + int rindex = attrIndex( referrer, ia->_inverted_attr_id, ia->_inverted_entity_id ); STEPattribute sa = referrer->attributes[ rindex ]; - assert(sa.getADesc()->BaseType() == ENTITY_TYPE); + assert( sa.getADesc()->BaseType() == ENTITY_TYPE ); bool found = false; - if(sa.getADesc()->IsAggrType()) { + 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) { + 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(); + en = ( EntityNode * ) en->NextNode(); } } else { //single instance - assert(sa.getADesc()->NonRefType() == ENTITY_TYPE); - if(sa.Entity() == _inst) { + assert( sa.getADesc()->NonRefType() == ENTITY_TYPE ); + if( sa.Entity() == _inst ) { found = true; } } - if(!found) { + if( !found ) { std::cerr << "inst #" << _inst->FileId() << " not found in #" << referrer->FileId(); std::cerr << ", attr #" << rindex << " [contents: "; - referrer->STEPwrite(std::cerr); + 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++) { + 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)) { + 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 */) - { + 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) { + 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->eDesc->Name() << std::endl; + std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->getEDesc()->Name() << std::endl; abort(); iAstruct nil = {nullptr}; return nil; @@ -199,14 +193,13 @@ class SC_LAZYFILE_EXPORT lazyRefs /** 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) - { + void potentialReferentInsts( edList_t & edL ) { refMap_t::pair kv = _refMap.begin(); - while(kv.value != 0) { + 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); + for( ; edi != edL.end(); ++edi ) { + if( 0 == strcasecmp( kv.value->c_str(), ( *edi )->Name() ) ) { + _referentInstances.insert( kv.key ); break; } } @@ -216,99 +209,91 @@ class SC_LAZYFILE_EXPORT lazyRefs ///find any inverse attributes, put in `iaList` /// attrs not necessarily in order! - void getInverseAttrs(const EntityDescriptor *ed, iaList_t &iaList) - { + void getInverseAttrs( const EntityDescriptor * ed, iaList_t & iaList ) { iaList.clear(); - supertypesIterator supersIter(ed); - const Inverse_attribute *iAttr; - for(; !supersIter.empty(); ++supersIter) { + 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); + 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); + 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()) { + 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)); + 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) - { + lazyRefs( lazyInstMgr * lmgr ): _lim( lmgr ), _id( 0 ) { _iaList.clear(); } - lazyRefs(lazyInstMgr *lmgr, SDAI_Application_instance *ai): _lim(lmgr), _id(0) - { + lazyRefs( lazyInstMgr * lmgr, SDAI_Application_instance * ai ): _lim( lmgr ), _id( 0 ) { _iaList.clear(); - init(0, ai); + init( 0, ai ); } - lazyRefs(lazyInstMgr *lmgr, instanceID iid): _lim(lmgr) - { + lazyRefs( lazyInstMgr * lmgr, instanceID iid ): _lim( lmgr ) { _iaList.clear(); - init(iid, 0); + init( iid, 0 ); } - ~lazyRefs() - { + ~lazyRefs() { // delete strings in refMap - _refMap.clear(true); + _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) { + 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); + if( !ai ) { + _inst = _lim->loadInstance( iid ); _id = iid; } else { _inst = ai; _id = _inst->GetFileId(); } - _refMap.clear(true); + _refMap.clear( true ); // 1. find inverse attrs with recursion - getInverseAttrs(ai->eDesc, _iaList); + 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()) { + if( _iaList.size() == 0 || !mapRefsToTypes() ) { return; } iaList_t::iterator iai = _iaList.begin(); - for(; iai != _iaList.end(); ++iai) { + for( ; iai != _iaList.end(); ++iai ) { // 3. for each IA, ... - checkAnInvAttr(*iai); + checkAnInvAttr( *iai ); } } - referentInstances_t result() - { + referentInstances_t result() { return _referentInstances; } diff --git a/src/cllazyfile/lazyTypes.h b/src/cllazyfile/lazyTypes.h index 35bcc1ba2..0ba2aa671 100644 --- a/src/cllazyfile/lazyTypes.h +++ b/src/cllazyfile/lazyTypes.h @@ -65,8 +65,8 @@ typedef struct { /// used when populating the instance type map \sa lazyInstMgr::_instanceTypeMMap typedef struct { lazyInstanceLoc loc; - const char *name; - instanceRefs *refs; + const char * name; + instanceRefs * refs; } namedLazyInstance; // instanceRefs - map between an instanceID and instances that refer to it diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 3659b4137..87838e467 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,9 +1,7 @@ -#include -#include #include "lazyInstMgr.h" +#include #include "SdaiSchemaInit.h" #include "sc_memmgr.h" -#include "sc_benchmark.h" #include #ifndef NO_REGISTRY @@ -11,33 +9,31 @@ #endif //NO_REGISTRY -void fileInfo(lazyInstMgr &mgr, fileID id) -{ - instancesLoaded_t *headerInsts = mgr.getHeaderInstances(id); - SDAI_Application_instance *hdrInst; - hdrInst = headerInsts->find(3); - if((hdrInst != 0) && (hdrInst->STEPfile_id == 3)) { - SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(hdrInst); - if(fs) { +void fileInfo( lazyInstMgr & mgr, fileID id ) { + instancesLoaded_t * headerInsts = mgr.getHeaderInstances( id ); + SDAI_Application_instance * hdrInst; + hdrInst = headerInsts->find( 3 ); + if( ( hdrInst != 0 ) && ( hdrInst->STEPfile_id == 3 ) ) { + SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( hdrInst ); + if( fs ) { StringAggregate_ptr p = fs->schema_identifiers_(); - StringNode *sn = (StringNode *) p->GetHead(); + StringNode * sn = ( StringNode * ) p->GetHead(); std::cout << "Schema(s): "; - while(sn) { + while( sn ) { std::cout << sn->value.c_str() << " "; - sn = (StringNode *) sn->NextNode(); + sn = ( StringNode * ) sn->NextNode(); } std::cout << std::endl; } } } -void countTypeInstances(lazyInstMgr &mgr, std::string type) -{ - int count = mgr.countInstances(type); +void countTypeInstances( lazyInstMgr & mgr, std::string type ) { + int count = mgr.countInstances( type ); std::cout << type << " instances: " << count; - if(count) { + if( count ) { instanceID ex; - ex = (* mgr.getInstances(type))[ 0 ]; + ex = ( * mgr.getInstances( type ) )[ 0 ]; std::cout << " -- example: #" << ex; } std::cout << std::endl; @@ -45,19 +41,18 @@ void countTypeInstances(lazyInstMgr &mgr, std::string type) } /// Called twice by printRefs. Returns the instanceID of one instance that has a reference. -instanceID printRefs1(instanceRefs_t *refs, bool forward) -{ - const char *d1 = forward ? "forward" : "reverse"; - const char *d2 = forward ? " refers to " : " is referred to by "; +instanceID printRefs1( instanceRefs_t * refs, bool forward ) { + const char * d1 = forward ? "forward" : "reverse"; + const char * d2 = forward ? " refers to " : " is referred to by "; instanceID id = 0; instanceRefs_t::cpair p = refs->begin(); - instanceRefs_t::cvector *v = p.value; - if(!v) { + instanceRefs_t::cvector * v = p.value; + if( !v ) { std::cout << "No " << d1 << " references" << std::endl; } else { - instanceRefs_t::cvector::const_iterator it(v->begin()), end(v->end()); + instanceRefs_t::cvector::const_iterator it( v->begin() ), end( v->end() ); std::cout << "Example of " << d1 << " references - Instance #" << p.key << d2 << v->size() << " other instances: "; - for(; it != end; it++) { + for( ; it != end; it++ ) { std::cout << *it << " "; } std::cout << std::endl; @@ -67,36 +62,34 @@ instanceID printRefs1(instanceRefs_t *refs, bool forward) } ///prints references; returns the instanceID for one instance that has a forward reference -instanceID printRefs(lazyInstMgr &mgr) -{ +instanceID printRefs( lazyInstMgr & mgr ) { instanceID id; std::cout << "\nReferences\n==============\n"; - id = printRefs1(mgr.getFwdRefs(), true); - printRefs1(mgr.getRevRefs(), false); + id = printRefs1( mgr.getFwdRefs(), true ); + printRefs1( mgr.getRevRefs(), false ); std::cout << std::endl; return id; } /// prints dependencies of an instance -void printDeps(lazyInstMgr &mgr) -{ +void printDeps( lazyInstMgr & mgr ) { const int displayInstances = 10; - instanceRefs_t *refs = mgr.getFwdRefs(); + 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()); + 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++) { + for(i = 0; it != end && i < displayInstances; it++, i++ ) { std::cout << *it << " "; } - if(dependencies->size() > displayInstances) { + if( dependencies->size() > displayInstances ) { std::cout << ".... (Displaying only " << displayInstances << " instances) "; } @@ -107,26 +100,25 @@ void printDeps(lazyInstMgr &mgr) } ///prints info about a complex instance -void dumpComplexInst(STEPcomplex *c) -{ +void dumpComplexInst( STEPcomplex * c ) { int depth = 0; - if(c) { + 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! // SDAI_Application_instance * attr = ( SDAI_Application_instance * ) *it; - STEPcomplex *complex = c->head; - while(complex) { - if(complex->IsComplex()) { - std::cout << "Complex component " << complex->eDesc->Name() << " at depth " << depth << " with attr list size "; + 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->eDesc->Name() << std::endl; + 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; } @@ -137,63 +129,60 @@ void dumpComplexInst(STEPcomplex *c) } } -int main(int argc, char **argv) -{ - if(argc != 2) { +int main( int argc, char ** argv ) { + if( argc != 2 ) { std::cerr << "Expected one argument, given " << argc - 1 << ". Exiting." << std::endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - lazyInstMgr *mgr = new lazyInstMgr; + lazyInstMgr * mgr = new lazyInstMgr; #ifndef NO_REGISTRY //init schema - mgr->initRegistry(SchemaInit); + mgr->initRegistry( SchemaInit ); #endif //NO_REGISTRY instanceID instWithRef; - benchmark stats; - std::cout << "================ p21 lazy load: scanning the file ================\n"; - mgr->openFile(argv[1]); + benchmark stats( "================ p21 lazy load: scanning the file ================\n" ); + mgr->openFile( argv[1] ); stats.stop(); benchVals scanStats = stats.get(); stats.out(); - std::cout << "================ p21 lazy load: gathering statistics ================\n"; - stats.reset(); + stats.reset( "================ p21 lazy load: gathering statistics ================\n" ); int instances = mgr->totalInstanceCount(); - std::cout << "Total instances: " << instances << " (" << (float)(scanStats.userMilliseconds * 1000) / instances << "us per instance, "; - std::cout << (float)(scanStats.physMemKB * 1000) / instances << " bytes per instance)" << std::endl << std::endl; + std::cout << "Total instances: " << instances << " (" << ( float )( scanStats.userMilliseconds * 1000 ) / instances << "us per instance, "; + std::cout << ( float )( scanStats.physMemKB * 1000 ) / instances << " bytes per instance)" << std::endl << std::endl; - fileInfo(*mgr, 0); + fileInfo( *mgr, 0 ); //these are just common types - countTypeInstances(*mgr, "CARTESIAN_POINT"); - countTypeInstances(*mgr, "POSITIVE_LENGTH_MEASURE"); - countTypeInstances(*mgr, "VERTEX_POINT"); + countTypeInstances( *mgr, "CARTESIAN_POINT" ); + countTypeInstances( *mgr, "POSITIVE_LENGTH_MEASURE" ); + countTypeInstances( *mgr, "VERTEX_POINT" ); //complex instances std::cout << "Complex"; - countTypeInstances(*mgr, ""); + countTypeInstances( *mgr, "" ); std::cout << "Longest type name: " << mgr->getLongestTypeName() << std::endl; // std::cout << "Total types: " << mgr->getNumTypes() << std::endl; - instWithRef = printRefs(*mgr); - printDeps(*mgr); + instWithRef = printRefs( *mgr ); + printDeps( *mgr ); #ifndef NO_REGISTRY - if(instWithRef) { + if( instWithRef ) { std::cout << "Number of data section instances fully loaded: " << mgr->loadedInstanceCount() << std::endl; std::cout << "Loading #" << instWithRef; - SDAI_Application_instance *inst = mgr->loadInstance(instWithRef); + SDAI_Application_instance * inst = mgr->loadInstance( instWithRef ); std::cout << " which is of type " << inst->EntityName() << std::endl; std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } - instanceTypes_t::cvector *complexInsts = mgr->getInstances(""); - if(complexInsts && complexInsts->size() > 0) { - std::cout << "loading complex instance #" << complexInsts->at(0) << "." << std::endl; - STEPcomplex *c = dynamic_cast(mgr->loadInstance(complexInsts->at(0))); - dumpComplexInst(c); + instanceTypes_t::cvector * complexInsts = mgr->getInstances( "" ); + if( complexInsts && complexInsts->size() > 0 ) { + std::cout << "loading complex instance #" << complexInsts->at( 0 ) << "." << std::endl; + STEPcomplex * c = dynamic_cast( mgr->loadInstance( complexInsts->at( 0 ) ) ); + dumpComplexInst( c ); std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl; } #else @@ -201,8 +190,7 @@ int main(int argc, char **argv) #endif //NO_REGISTRY stats.out(); - std::cout << "================ p21 lazy load: freeing memory ================\n"; - stats.reset(); + stats.reset( "================ p21 lazy load: freeing memory ================\n" ); delete mgr; //stats will print from its destructor } diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index e1f3f7fff..bcb78ac83 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -8,56 +8,53 @@ #include "judyL2Array.h" -void p21HeaderSectionReader::findSectionStart() -{ - _sectionStart = findNormalString("HEADER", true); - assert(_file.is_open() && _file.good()); +void p21HeaderSectionReader::findSectionStart() { + _sectionStart = findNormalString( "HEADER", true ); + assert( _file.is_open() && _file.good() ); } -p21HeaderSectionReader::p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, - std::streampos start, sectionID sid): - headerSectionReader(parent, file, start, sid) -{ +p21HeaderSectionReader::p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, + std::streampos start, sectionID sid ): + headerSectionReader( parent, file, start, sid ) { findSectionStart(); findSectionEnd(); - _file.seekg(_sectionStart); + _file.seekg( _sectionStart ); namedLazyInstance nl; - while(nl = nextInstance(), (nl.loc.begin > 0)) { + while( nl = nextInstance(), ( nl.loc.begin > 0 ) ) { std::streampos pos = _file.tellg(); - _headerInstances->insert(nl.loc.instance, getRealInstance(_lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true)); - _file.seekg(pos); //reset stream position for next call to nextInstance() + _headerInstances->insert( nl.loc.instance, getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true ) ); + _file.seekg( pos ); //reset stream position for next call to nextInstance() } - _file.seekg(_sectionEnd); + _file.seekg( _sectionEnd ); } // part of readdata1 -const namedLazyInstance p21HeaderSectionReader::nextInstance() -{ +const namedLazyInstance p21HeaderSectionReader::nextInstance() { namedLazyInstance i; static instanceID nextFreeInstance = 4; // 1-3 are reserved per 10303-21 i.loc.begin = _file.tellg(); i.loc.section = _sectionID; skipWS(); - if(i.loc.begin <= 0) { + if( i.loc.begin <= 0 ) { i.name = 0; } else { - i.name = getDelimitedKeyword(";( /\\"); + i.name = getDelimitedKeyword( ";( /\\" ); - if(0 == strcmp("FILE_DESCRIPTION", i.name)) { + if( 0 == strcmp( "FILE_DESCRIPTION", i.name ) ) { i.loc.instance = 1; - } else if(0 == strcmp("FILE_NAME", i.name)) { + } else if( 0 == strcmp( "FILE_NAME", i.name ) ) { i.loc.instance = 2; - } else if(0 == strcmp("FILE_SCHEMA", i.name)) { + } else if( 0 == strcmp( "FILE_SCHEMA", i.name ) ) { i.loc.instance = 3; } else { i.loc.instance = nextFreeInstance++; } - assert(strlen(i.name) > 0); + assert( strlen( i.name ) > 0 ); - std::streampos end = seekInstanceEnd(0); //no references in file header - if(((signed long int)end == -1) || (end >= _sectionEnd)) { + std::streampos end = seekInstanceEnd( 0 ); //no references in file header + if( ( (signed long int)end == -1 ) || ( end >= _sectionEnd ) ) { //invalid instance, so clear everything i.loc.begin = -1; i.name = 0; diff --git a/src/cllazyfile/p21HeaderSectionReader.h b/src/cllazyfile/p21HeaderSectionReader.h index 5a4aea3ca..b5ce04948 100644 --- a/src/cllazyfile/p21HeaderSectionReader.h +++ b/src/cllazyfile/p21HeaderSectionReader.h @@ -5,10 +5,9 @@ #include "sc_memmgr.h" #include "sc_export.h" -class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader -{ +class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { public: - p21HeaderSectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); void findSectionStart(); /** gets information (start, end, name, etc) about the next * instance in the file and returns it in a namedLazyInstance diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index cf38bb3c5..7a6053a46 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -20,61 +20,59 @@ #include "current_function.hpp" -sectionReader::sectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid): - _lazyFile(parent), _file(file), _sectionStart(start), _sectionID(sid) -{ +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(); } -std::streampos sectionReader::findNormalString(const std::string &str, bool semicolon) -{ +std::streampos sectionReader::findNormalString( const std::string & str, bool semicolon ) { std::streampos found = -1, startPos = _file.tellg(), nextTry = startPos; int i = 0, l = str.length(); char c; //i is reset every time a character doesn't match; if i == l, this means that we've found the entire string - while(i < l || semicolon) { + while( i < l || semicolon ) { skipWS(); c = _file.get(); - if((i == l) && (semicolon)) { - if(c == ';') { + if( ( i == l ) && ( semicolon ) ) { + if( c == ';' ) { break; } else { i = 0; - _file.seekg(nextTry); + _file.seekg( nextTry ); continue; } } - if(c == '\'') { + if( c == '\'' ) { //push past string - _file.seekg(_file.tellg() - std::streampos(1)); - GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); + _file.seekg( _file.tellg() - std::streampos(1) ); + GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); } - if((c == '/') && (_file.peek() == '*')) { + if( ( c == '/' ) && ( _file.peek() == '*' ) ) { //push past comment - findNormalString("*/"); + findNormalString( "*/" ); } - if(str[i] == c) { + if( str[i] == c ) { i++; - if(i == 1) { + if( i == 1 ) { nextTry = _file.tellg(); } } else { - if(!_file.good()) { + if( !_file.good() ) { break; } - if(i >= 1) { - _file.seekg(nextTry); + if( i >= 1 ) { + _file.seekg( nextTry ); } i = 0; } } - if(i == l) { + if( i == l ) { found = _file.tellg(); } - if(_file.is_open() && _file.good()) { + if( _file.is_open() && _file.good() ) { return found; } else { return -1; @@ -84,29 +82,28 @@ std::streampos sectionReader::findNormalString(const std::string &str, bool semi //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) -{ +const char * sectionReader::getDelimitedKeyword( const char * delimiters ) { static std::string str; char c; str.clear(); - str.reserve(100); + str.reserve( 100 ); skipWS(); - while(c = _file.get(), _file.good()) { - if(c == '-' || c == '_' || isupper(c) || isdigit(c) || - (c == '!' && str.length() == 0)) { - str.append(1, c); - } else if((c == '/') && (_file.peek() == '*') && (str.length() == 0)) { + while( c = _file.get(), _file.good() ) { + if( c == '-' || c == '_' || isupper( c ) || isdigit( c ) || + ( c == '!' && str.length() == 0 ) ) { + str.append( 1, c ); + } else if( ( c == '/' ) && ( _file.peek() == '*' ) && ( str.length() == 0 ) ) { //push past comment - findNormalString("*/"); + findNormalString( "*/" ); skipWS(); continue; } else { - _file.putback(c); + _file.putback( c ); break; } } c = _file.peek(); - if(!strchr(delimiters, c)) { + if( !strchr( delimiters, c ) ) { std::cerr << SC_CURRENT_FUNCTION << ": missing delimiter. Found " << c << ", expected one of " << delimiters << " at end of keyword " << str << ". File offset: " << _file.tellg() << std::endl; abort(); } @@ -116,50 +113,49 @@ const char *sectionReader::getDelimitedKeyword(const char *delimiters) /// search forward in the file for the end of the instance. Start position should /// be the opening parenthesis; otherwise, it is likely to fail. ///NOTE *must* check return value! -std::streampos sectionReader::seekInstanceEnd(instanceRefs **refs) -{ +std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { char c; int parenDepth = 0; - while(c = _file.get(), _file.good()) { - switch(c) { + while( c = _file.get(), _file.good() ) { + switch( c ) { case '(': parenDepth++; break; case '/': - if(_file.peek() == '*') { - findNormalString("*/"); + if( _file.peek() == '*' ) { + findNormalString( "*/" ); } else { return -1; } break; case '\'': - _file.seekg(_file.tellg() - std::streampos(1)); - GetLiteralStr(_file, _lazyFile->getInstMgr()->getErrorDesc()); + _file.seekg( _file.tellg() - std::streampos(1) ); + GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() ); break; case '=': return -1; case '#': skipWS(); - if(isdigit(_file.peek())) { - if(refs != 0) { - if(! * refs) { + if( isdigit( _file.peek() ) ) { + if( refs != 0 ) { + if( ! * refs ) { *refs = new std::vector< instanceID >; } instanceID n; _file >> n; - (* refs)->push_back(n); + ( * refs )->push_back( n ); } } else { return -1; } break; case ')': - if(--parenDepth == 0) { + if( --parenDepth == 0 ) { skipWS(); - if(_file.get() == ';') { + if( _file.get() == ';' ) { return _file.tellg(); } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); } } default: @@ -172,16 +168,14 @@ std::streampos sectionReader::seekInstanceEnd(instanceRefs **refs) // new memory: 673340kb; User CPU time: 29890ms; System CPU time: 11650ms } -void sectionReader::locateAllInstances() -{ +void sectionReader::locateAllInstances() { namedLazyInstance inst; - while(inst = nextInstance(), (_file.good()) && (inst.loc.begin > 0)) { - _lazyFile->getInstMgr()->addLazyInstance(inst); + while( inst = nextInstance(), ( _file.good() ) && ( inst.loc.begin > 0 ) ) { + _lazyFile->getInstMgr()->addLazyInstance( inst ); } } -instanceID sectionReader::readInstanceNumber() -{ +instanceID sectionReader::readInstanceNumber() { char c; size_t digits = 0; instanceID id = 0; @@ -189,64 +183,64 @@ instanceID sectionReader::readInstanceNumber() //find instance number ("# nnnn ="), where ' ' is any whitespace found by isspace() skipWS(); c = _file.get(); - if((c == '/') && (_file.peek() == '*')) { - findNormalString("*/"); + if( ( c == '/' ) && ( _file.peek() == '*' ) ) { + findNormalString( "*/" ); } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); } skipWS(); c = _file.get(); - if(c != '#') { + if( c != '#' ) { return 0; } skipWS(); // The largest instance ID yet supported is the maximum value of unsigned long long int - assert(std::numeric_limits::max() <= std::numeric_limits::max()); + assert( std::numeric_limits::max() <= std::numeric_limits::max() ); size_t instanceIDLength = std::numeric_limits::digits10 + 1; - char *buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character - + char * buffer = new char[ instanceIDLength + 1 ]; // +1 for the terminating character + std::stringstream errorMsg; do { c = _file.get(); - if(isdigit(c)) { + if( isdigit( c ) ) { buffer[ digits ] = c; //copy the character into the buffer digits++; } else { - _file.seekg(_file.tellg() - std::streampos(1)); + _file.seekg( _file.tellg() - std::streampos(1) ); break; } - if(digits > instanceIDLength) { + 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()); + _error->GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error->UserMsg( "A very large instance ID encountered" ); + _error->DetailMsg( errorMsg.str() ); delete buffer; - return 0; + return 0; } - } while(_file.good()); + } while( _file.good() ); buffer[ digits ] = '\0'; //Append the terminating character skipWS(); - if(_file.good() && (digits > 0) && (_file.get() == '=')) { - id = strtoull(buffer, NULL, 10); - if(id == std::numeric_limits::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. + if( _file.good() && ( digits > 0 ) && ( _file.get() == '=' ) ) { + id = strtoull( buffer, NULL, 10); + if( id == std::numeric_limits::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()); + _error->GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error->UserMsg( "A very large instance ID encountered" ); + _error->DetailMsg( errorMsg.str() ); } - assert(id > 0); + assert( id > 0 ); } delete [] buffer; return id; @@ -255,25 +249,24 @@ instanceID sectionReader::readInstanceNumber() /** 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) -{ +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 + const char * tName = 0, * sName = 0; //these are necessary since typeName and schName are const std::string comment; Severity sev = SEVERITY_NULL; - SDAI_Application_instance *inst = 0; + SDAI_Application_instance * inst = 0; tName = typeName.c_str(); - if(schName.size() > 0) { + if( schName.size() > 0 ) { sName = schName.c_str(); - } else if(!header) { - SdaiFile_schema *fs = dynamic_cast< SdaiFile_schema * >(_lazyFile->getHeaderInstances()->find(3)); - if(fs) { - StringNode *sn = (StringNode *) fs->schema_identifiers_()->GetHead(); - if(sn) { + } else if( !header ) { + SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( _lazyFile->getHeaderInstances()->find( 3 ) ); + if( fs ) { + StringNode * sn = ( StringNode * ) fs->schema_identifiers_()->GetHead(); + if( sn ) { sName = sn->value.c_str(); - if(sn->NextNode()) { + if( sn->NextNode() ) { std::cerr << "Warning - multiple schema names found. Only searching with first one." << std::endl; } } @@ -282,79 +275,78 @@ SDAI_Application_instance *sectionReader::getRealInstance(const Registry *reg, l } } - _file.seekg(begin); + _file.seekg( begin ); skipWS(); - ReadTokenSeparator(_file, &comment); - if(!header) { - findNormalString("="); + ReadTokenSeparator( _file, &comment ); + if( !header ) { + findNormalString( "=" ); } skipWS(); - ReadTokenSeparator(_file, &comment); + ReadTokenSeparator( _file, &comment ); c = _file.peek(); - switch(c) { + switch( c ) { case '&': std::cerr << "Can't handle scope instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; // sev = CreateScopeInstances( in, &scopelist ); break; case '(': - inst = CreateSubSuperInstance(reg, instance, sev); + inst = CreateSubSuperInstance( reg, instance, sev ); break; case '!': std::cerr << "Can't handle user-defined instances. Skipping #" << instance << ", offset " << _file.tellg() << std::endl; break; default: - if((!header) && (typeName.size() == 0)) { - tName = getDelimitedKeyword(";( /\\"); + if( ( !header ) && ( typeName.size() == 0 ) ) { + tName = getDelimitedKeyword( ";( /\\" ); } - inst = reg->ObjCreate(tName, sName); + inst = reg->ObjCreate( tName, sName ); break; } - if(!isNilSTEPentity(inst)) { - if(!comment.empty()) { - inst->AddP21Comment(comment); + if( !isNilSTEPentity( inst ) ) { + if( !comment.empty() ) { + inst->AddP21Comment( comment ); } - assert(inst->eDesc); - _file.seekg(begin); - findNormalString("("); - _file.seekg(_file.tellg() - std::streampos(1)); - sev = inst->STEPread(instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false); + assert( inst->getEDesc() ); + _file.seekg( begin ); + findNormalString( "(" ); + _file.seekg( _file.tellg() - std::streampos(1) ); + sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false ); //TODO do something with 'sev' inst->InitIAttrs(); } return inst; } -STEPcomplex *sectionReader::CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &) -{ +STEPcomplex * sectionReader::CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & ) { std::string buf; ErrorDescriptor err; std::vector typeNames; _file.get(); //move past the first '(' skipWS(); - while(_file.good() && (_file.peek() != ')')) { - typeNames.push_back(new std::string(getDelimitedKeyword(";( /\\\n"))); - if(typeNames.back()->empty()) { + while( _file.good() && ( _file.peek() != ')' ) ) { + typeNames.push_back( new std::string( getDelimitedKeyword( ";( /\\\n" ) ) ); + if( typeNames.back()->empty() ) { delete typeNames.back(); typeNames.pop_back(); } else { - SkipSimpleRecord(_file, buf, &err); //exactly what does this do? if it doesn't count parenthesis, it probably should + SkipSimpleRecord( _file, buf, &err ); //exactly what does this do? if it doesn't count parenthesis, it probably should buf.clear(); } skipWS(); - if(_file.peek() != ')') { + if( _file.peek() != ')' ) { // do something } } // STEPComplex needs an array of strings or of char*. construct the latter using c_str() on all strings in the vector //FIXME: STEPComplex ctor should accept std::vector ? const int s = typeNames.size(); - const char **names = new const char *[ s + 1 ]; + const char ** names = new const char * [ s + 1 ]; names[ s ] = 0; - for(int i = 0; i < s; i++) { + for( int i = 0; i < s; i++ ) { names[ i ] = typeNames[i]->c_str(); } //TODO still need the schema name - STEPcomplex *sc = new STEPcomplex((const_cast(reg)), names, (int) fileid /*, schnm*/); + STEPcomplex * sc = new STEPcomplex( ( const_cast( reg ) ), names, ( int ) fileid /*, schnm*/ ); delete[] names; //TODO also delete contents of typeNames! return sc; diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index c6508669d..c6a64b55a 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -14,16 +14,15 @@ class lazyFileReader; class ErrorDescriptor; class Registry; -class SC_LAZYFILE_EXPORT sectionReader -{ +class SC_LAZYFILE_EXPORT sectionReader { protected: //protected data members - lazyFileReader *_lazyFile; + lazyFileReader * _lazyFile; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::ifstream &_file; + std::ifstream & _file; std::streampos _sectionStart, ///< the start of this section as reported by tellg() _sectionEnd; ///< the end of this section as reported by tellg() @@ -32,61 +31,56 @@ class SC_LAZYFILE_EXPORT sectionReader #endif unsigned long _totalInstances; - ErrorDescriptor *_error; + ErrorDescriptor * _error; sectionID _sectionID; fileID _fileID; // protected member functions - sectionReader(lazyFileReader *parent, std::ifstream &file, std::streampos start, sectionID sid); + sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); /** Find a string, ignoring occurrences in comments or Part 21 strings (i.e. 'string with \S\' control directive' ) * \param str string to find * \param semicolon if true, 'str' must be followed by a semicolon, possibly preceded by whitespace. * \returns the position of the end of the found string */ - std::streampos findNormalString(const std::string &str, bool semicolon = false); + std::streampos findNormalString( const std::string & str, bool semicolon = false ); /** Get a keyword ending with one of delimiters. */ - const char *getDelimitedKeyword(const char *delimiters); + const char * getDelimitedKeyword( const char * delimiters ); /** Seek to the end of the current instance */ - std::streampos seekInstanceEnd(instanceRefs **refs); + std::streampos seekInstanceEnd( instanceRefs ** refs ); /// operator>> is very slow?! - inline void skipWS() - { - while(isspace(_file.peek()) && _file.good()) { - _file.ignore(1); + inline void skipWS() { + while( isspace( _file.peek() ) && _file.good() ) { + _file.ignore( 1 ); } } - STEPcomplex *CreateSubSuperInstance(const Registry *reg, instanceID fileid, Severity &sev); + STEPcomplex * CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & sev ); public: - SDAI_Application_instance *getRealInstance(const Registry *reg, long int begin, instanceID instance, - const std::string &typeName = "", const std::string &schName = "", bool header = false); + SDAI_Application_instance * getRealInstance( const Registry * reg, long int begin, instanceID instance, + const std::string & typeName = "", const std::string & schName = "", bool header = false ); - sectionID ID() const - { + sectionID ID() const { return _sectionID; } virtual void findSectionStart() = 0; - void findSectionEnd() - { - _sectionEnd = findNormalString("ENDSEC", true); + void findSectionEnd() { + _sectionEnd = findNormalString( "ENDSEC", true ); } - std::streampos sectionStart() const - { + std::streampos sectionStart() const { return _sectionStart; } - std::streampos sectionEnd() const - { + std::streampos sectionEnd() const { return _sectionEnd; } @@ -97,25 +91,22 @@ class SC_LAZYFILE_EXPORT sectionReader /** 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) { + const char * getType( long int offset ) { + if( offset <= 0 ) { return 0; } - _file.seekg(offset); + _file.seekg( offset ); readInstanceNumber(); skipWS(); - return getDelimitedKeyword(";( /\\"); + return getDelimitedKeyword( ";( /\\" ); } instanceID readInstanceNumber(); - void seekg(std::streampos pos) - { - _file.seekg(pos); + void seekg( std::streampos pos ) { + _file.seekg( pos ); } - std::streampos tellg() - { + std::streampos tellg() { return _file.tellg(); } }; diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 910235973..937985fff 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -133,19 +133,19 @@ include_directories( set(_libdeps steputils stepdai base) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLSTEPCORE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 11ddde52a..6bbd3eaff 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -15,58 +15,55 @@ /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ -const TypeDescriptor *const t_sdaiINTEGER = new TypeDescriptor("INTEGER", sdaiINTEGER, 0, "INTEGER"); -const TypeDescriptor *const t_sdaiREAL = new TypeDescriptor("REAL", sdaiREAL, 0, "Real"); -const TypeDescriptor *const t_sdaiNUMBER = new TypeDescriptor("NUMBER", sdaiNUMBER, 0, "Number"); -const TypeDescriptor *const t_sdaiSTRING = new TypeDescriptor("STRING", sdaiSTRING, 0, "String"); -const TypeDescriptor *const t_sdaiBINARY = new TypeDescriptor("BINARY", sdaiBINARY, 0, "Binary"); -const TypeDescriptor *const t_sdaiBOOLEAN = new TypeDescriptor("BOOLEAN", sdaiBOOLEAN, 0, "Boolean"); -const TypeDescriptor *const t_sdaiLOGICAL = new TypeDescriptor("LOGICAL", sdaiLOGICAL, 0, "Logical"); - -static int uniqueNames(const char *, const SchRename *); - -Registry::Registry(CF_init initFunct) - : col(0), entity_cnt(0), all_ents_cnt(0) -{ - - primordialSwamp = SC_HASHcreate(1000); - active_schemas = SC_HASHcreate(10); - active_types = SC_HASHcreate(100); - - initFunct(*this); - SC_HASHlistinit(active_types, &cur_type); - SC_HASHlistinit(primordialSwamp, &cur_entity); // initialize cur's - SC_HASHlistinit(active_schemas, &cur_schema); +const TypeDescriptor * const t_sdaiINTEGER = new TypeDescriptor( "INTEGER", sdaiINTEGER, 0, "INTEGER" ); +const TypeDescriptor * const t_sdaiREAL = new TypeDescriptor( "REAL", sdaiREAL, 0, "Real" ); +const TypeDescriptor * const t_sdaiNUMBER = new TypeDescriptor( "NUMBER", sdaiNUMBER, 0, "Number" ); +const TypeDescriptor * const t_sdaiSTRING = new TypeDescriptor( "STRING", sdaiSTRING, 0, "String" ); +const TypeDescriptor * const t_sdaiBINARY = new TypeDescriptor( "BINARY", sdaiBINARY, 0, "Binary" ); +const TypeDescriptor * const t_sdaiBOOLEAN = new TypeDescriptor( "BOOLEAN", sdaiBOOLEAN, 0, "Boolean" ); +const TypeDescriptor * const t_sdaiLOGICAL = new TypeDescriptor( "LOGICAL", sdaiLOGICAL, 0, "Logical" ); + +static int uniqueNames( const char *, const SchRename * ); + +Registry::Registry( CF_init initFunct ) + : col( 0 ), entity_cnt( 0 ), all_ents_cnt( 0 ) { + + primordialSwamp = SC_HASHcreate( 1000 ); + active_schemas = SC_HASHcreate( 10 ); + active_types = SC_HASHcreate( 100 ); + + initFunct( *this ); + SC_HASHlistinit( active_types, &cur_type ); + SC_HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur's + SC_HASHlistinit( active_schemas, &cur_schema ); } -Registry::~Registry() -{ +Registry::~Registry() { DeleteContents(); - SC_HASHdestroy(primordialSwamp); - SC_HASHdestroy(active_schemas); - SC_HASHdestroy(active_types); + SC_HASHdestroy( primordialSwamp ); + SC_HASHdestroy( active_schemas ); + SC_HASHdestroy( active_types ); delete col; } -void Registry::DeleteContents() -{ +void Registry::DeleteContents() { // entities first - SC_HASHlistinit(primordialSwamp, &cur_entity); - while(SC_HASHlist(&cur_entity)) { - delete(EntityDescriptor *) cur_entity.e->data; + SC_HASHlistinit( primordialSwamp, &cur_entity ); + while( SC_HASHlist( &cur_entity ) ) { + delete( EntityDescriptor * ) cur_entity.e->data; } // schemas - SC_HASHlistinit(active_schemas, &cur_schema); - while(SC_HASHlist(&cur_schema)) { - delete(Schema *) cur_schema.e->data; + SC_HASHlistinit( active_schemas, &cur_schema ); + while( SC_HASHlist( &cur_schema ) ) { + delete( Schema * ) cur_schema.e->data; } // types - SC_HASHlistinit(active_types, &cur_type); - while(SC_HASHlist(&cur_type)) { - delete(TypeDescriptor *) cur_type.e->data; + SC_HASHlistinit( active_types, &cur_type ); + while( SC_HASHlist( &cur_type ) ) { + delete( TypeDescriptor * ) cur_type.e->data; } } @@ -79,34 +76,33 @@ void Registry::DeleteContents() * entity A from schema Y and renames it to B, X should only refer to A as * B. Thus, if schNm here = "X", only e="B" would be valid but not e="A". */ -const EntityDescriptor *Registry::FindEntity(const char *e, const char *schNm, int check_case) const -{ - const EntityDescriptor *entd; - const SchRename *altlist; +const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const { + const EntityDescriptor * entd; + const SchRename * altlist; char schformat[BUFSIZ], altName[BUFSIZ]; - if(check_case) { - entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, (char *)e); + if( check_case ) { + entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, ( char * )e ); } else { - entd = (EntityDescriptor *)SC_HASHfind(primordialSwamp, - (char *)PrettyTmpName(e)); + entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, + ( char * )PrettyTmpName( e ) ); } - if(entd && schNm) { + if( entd && schNm ) { // We've now found an entity. If schNm has a value, we must ensure we // have a valid name. - strcpy(schformat, PrettyTmpName(schNm)); - if(((altlist = entd->AltNameList()) != 0) - && (altlist->rename(schformat, altName))) { + strcpy( schformat, PrettyTmpName( schNm ) ); + if( ( ( altlist = entd->AltNameList() ) != 0 ) + && ( altlist->rename( schformat, altName ) ) ) { // If entd has other name choices, and entd is referred to with a // new name by schema schNm, then e had better = the new name. - if(!StrCmpIns(e, altName)) { + if( !StrCmpIns( e, altName ) ) { return entd; } return NULL; - } else if(FindSchema(schformat, 1)) { + } else if( FindSchema( schformat, 1 ) ) { // If schema schNm exists but we had no conditions above to use an // altName, we must use the original name: - if(!StrCmpIns(e, entd->Name())) { + if( !StrCmpIns( e, entd->Name() ) ) { return entd; } return NULL; @@ -120,55 +116,48 @@ const EntityDescriptor *Registry::FindEntity(const char *e, const char *schNm, i return entd; } -const Schema *Registry::FindSchema(const char *n, int check_case) const -{ - if(check_case) { - return (const Schema *) SC_HASHfind(active_schemas, (char *) n); +const Schema * Registry::FindSchema( const char * n, int check_case ) const { + if( check_case ) { + return ( const Schema * ) SC_HASHfind( active_schemas, ( char * ) n ); } - return (const Schema *) SC_HASHfind(active_schemas, - (char *)PrettyTmpName(n)); + return ( const Schema * ) SC_HASHfind( active_schemas, + ( char * )PrettyTmpName( n ) ); } -const TypeDescriptor *Registry::FindType(const char *n, int check_case) const -{ - if(check_case) { - return (const TypeDescriptor *) SC_HASHfind(active_types, (char *) n); +const TypeDescriptor * Registry::FindType( const char * n, int check_case ) const { + if( check_case ) { + return ( const TypeDescriptor * ) SC_HASHfind( active_types, ( char * ) n ); } - return (const TypeDescriptor *) SC_HASHfind(active_types, - (char *)PrettyTmpName(n)); + return ( const TypeDescriptor * ) SC_HASHfind( active_types, + ( char * )PrettyTmpName( n ) ); } -void Registry::ResetTypes() -{ - SC_HASHlistinit(active_types, &cur_type); +void Registry::ResetTypes() { + SC_HASHlistinit( active_types, &cur_type ); } -const TypeDescriptor *Registry::NextType() -{ - if(0 == SC_HASHlist(&cur_type)) { +const TypeDescriptor * Registry::NextType() { + if( 0 == SC_HASHlist( &cur_type ) ) { return 0; } - return (const TypeDescriptor *) cur_type.e->data; + return ( const TypeDescriptor * ) cur_type.e->data; } -void Registry::AddEntity(const EntityDescriptor &e) -{ - SC_HASHinsert(primordialSwamp, (char *) e.Name(), (EntityDescriptor *) &e); +void Registry::AddEntity( const EntityDescriptor & e ) { + SC_HASHinsert( primordialSwamp, ( char * ) e.Name(), ( EntityDescriptor * ) &e ); ++entity_cnt; ++all_ents_cnt; - AddClones(e); + AddClones( e ); } -void Registry::AddSchema(const Schema &d) -{ - SC_HASHinsert(active_schemas, (char *) d.Name(), (Schema *) &d); +void Registry::AddSchema( const Schema & d ) { + SC_HASHinsert( active_schemas, ( char * ) d.Name(), ( Schema * ) &d ); } -void Registry::AddType(const TypeDescriptor &d) -{ - SC_HASHinsert(active_types, (char *) d.Name(), (TypeDescriptor *) &d); +void Registry::AddType( const TypeDescriptor & d ) { + SC_HASHinsert( active_types, ( char * ) d.Name(), ( TypeDescriptor * ) &d ); } /** @@ -178,16 +167,15 @@ void Registry::AddType(const TypeDescriptor &d) * so that if we comes across one of them in a Part 21 file, we'll recog- * nize it. */ -void Registry::AddClones(const EntityDescriptor &e) -{ - const SchRename *alts = e.AltNameList(); +void Registry::AddClones( const EntityDescriptor & e ) { + const SchRename * alts = e.AltNameList(); - while(alts) { - SC_HASHinsert(primordialSwamp, (char *)alts->objName(), - (EntityDescriptor *)&e); + while( alts ) { + SC_HASHinsert( primordialSwamp, ( char * )alts->objName(), + ( EntityDescriptor * )&e ); alts = alts->next; } - all_ents_cnt += uniqueNames(e.Name(), e.AltNameList()); + all_ents_cnt += uniqueNames( e.Name(), e.AltNameList() ); } /** @@ -196,14 +184,13 @@ void Registry::AddClones(const EntityDescriptor &e) * does the same (or if C simply uses yy from B), altlist will contain 2 * entries with the same alt name. */ -static int uniqueNames(const char *entnm, const SchRename *altlist) -{ +static int uniqueNames( const char * entnm, const SchRename * altlist ) { int cnt = 0; - const SchRename *alt = altlist; + const SchRename * alt = altlist; - while(alt) { - if(!((alt->next && alt->next->choice(alt->objName())) - || !StrCmpIns(alt->objName(), entnm))) { + while( alt ) { + if( !( ( alt->next && alt->next->choice( alt->objName() ) ) + || !StrCmpIns( alt->objName(), entnm ) ) ) { // alt has a unique alternate name if it's not reused by a later // alt. alt->next->choice() returns 1 if one of the later alts // also has alt's name as its value. The final condition checks @@ -219,66 +206,61 @@ static int uniqueNames(const char *entnm, const SchRename *altlist) return cnt; } -void Registry::RemoveEntity(const char *n) -{ - const EntityDescriptor *e = FindEntity(n); +void Registry::RemoveEntity( const char * n ) { + const EntityDescriptor * e = FindEntity( n ); struct Element tmp; - if(e) { - RemoveClones(*e); + if( e ) { + RemoveClones( *e ); } - tmp.key = (char *) n; - SC_HASHsearch(primordialSwamp, &tmp, HASH_DELETE) ? --entity_cnt : 0; + tmp.key = ( char * ) n; + SC_HASHsearch( primordialSwamp, &tmp, HASH_DELETE ) ? --entity_cnt : 0; } -void Registry::RemoveSchema(const char *n) -{ +void Registry::RemoveSchema( const char * n ) { struct Element tmp; - tmp.key = (char *) n; - SC_HASHsearch(active_schemas, &tmp, HASH_DELETE); + tmp.key = ( char * ) n; + SC_HASHsearch( active_schemas, &tmp, HASH_DELETE ); } -void Registry::RemoveType(const char *n) -{ +void Registry::RemoveType( const char * n ) { struct Element tmp; - tmp.key = (char *) n; - SC_HASHsearch(active_types, &tmp, HASH_DELETE); + tmp.key = ( char * ) n; + SC_HASHsearch( active_types, &tmp, HASH_DELETE ); } /** * Remove all the "clones", or rename values of e. */ -void Registry::RemoveClones(const EntityDescriptor &e) -{ - const SchRename *alts = e.AltNameList(); - struct Element *tmp; +void Registry::RemoveClones( const EntityDescriptor & e ) { + const SchRename * alts = e.AltNameList(); + struct Element * tmp; - while(alts) { + while( alts ) { tmp = new Element; - tmp->key = (char *) alts->objName(); - SC_HASHsearch(primordialSwamp, tmp, HASH_DELETE); + tmp->key = ( char * ) alts->objName(); + SC_HASHsearch( primordialSwamp, tmp, HASH_DELETE ); alts = alts->next; } } -SDAI_Application_instance *Registry::ObjCreate(const char *nm, const char *schnm, int check_case) const -{ - const EntityDescriptor *entd = FindEntity(nm, schnm, check_case); - if(entd) { - SDAI_Application_instance *se = - ((EntityDescriptor *)entd) -> NewSTEPentity(); +SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * schnm, int check_case ) const { + const EntityDescriptor * entd = FindEntity( nm, schnm, check_case ); + if( entd ) { + SDAI_Application_instance * se = + ( ( EntityDescriptor * )entd ) -> NewSTEPentity(); // See comment in previous function. - if(entd->AbstractEntity().asInt() == 1) { - se->Error().severity(SEVERITY_WARNING); - se->Error().UserMsg("ENTITY is abstract supertype"); - } else if(entd->ExtMapping().asInt() == 1) { - se->Error().severity(SEVERITY_WARNING); - se->Error().UserMsg("ENTITY requires external mapping"); + if( entd->AbstractEntity().asInt() == 1 ) { + se->Error().severity( SEVERITY_WARNING ); + se->Error().UserMsg( "ENTITY is abstract supertype" ); + } else if( entd->ExtMapping().asInt() == 1 ) { + se->Error().severity( SEVERITY_WARNING ); + se->Error().UserMsg( "ENTITY requires external mapping" ); } - se->eDesc = entd; + se->setEDesc( entd ); return se; } else { return ENTITY_NULL; @@ -286,34 +268,29 @@ SDAI_Application_instance *Registry::ObjCreate(const char *nm, const char *schnm } -int Registry::GetEntityCnt() -{ +int Registry::GetEntityCnt() { return entity_cnt; } -void Registry::ResetEntities() -{ - SC_HASHlistinit(primordialSwamp, &cur_entity); +void Registry::ResetEntities() { + SC_HASHlistinit( primordialSwamp, &cur_entity ); } -const EntityDescriptor *Registry::NextEntity() -{ - if(0 == SC_HASHlist(&cur_entity)) { +const EntityDescriptor * Registry::NextEntity() { + if( 0 == SC_HASHlist( &cur_entity ) ) { return 0; } - return (const EntityDescriptor *) cur_entity.e->data; + return ( const EntityDescriptor * ) cur_entity.e->data; } -void Registry::ResetSchemas() -{ - SC_HASHlistinit(active_schemas, &cur_schema); +void Registry::ResetSchemas() { + SC_HASHlistinit( active_schemas, &cur_schema ); } -const Schema *Registry::NextSchema() -{ - if(0 == SC_HASHlist(&cur_schema)) { +const Schema * Registry::NextSchema() { + if( 0 == SC_HASHlist( &cur_schema ) ) { return 0; } - return (const Schema *) cur_schema.e->data; + return ( const Schema * ) cur_schema.e->data; } diff --git a/src/clstepcore/Registry.h b/src/clstepcore/Registry.h index d81d7d8c2..d4d4d4db0 100644 --- a/src/clstepcore/Registry.h +++ b/src/clstepcore/Registry.h @@ -21,26 +21,25 @@ // defined and created in Registry.cc -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiINTEGER; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiREAL; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiNUMBER; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiSTRING; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBINARY; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiBOOLEAN; -extern SC_CORE_EXPORT const TypeDescriptor *const t_sdaiLOGICAL; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiINTEGER; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiREAL; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiNUMBER; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiSTRING; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBINARY; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBOOLEAN; +extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiLOGICAL; -typedef struct Hash_Table *HashTable; +typedef struct Hash_Table * HashTable; class Registry; -typedef void (* CF_init)(Registry &); // pointer to creation initialization +typedef void ( * CF_init )( Registry & ); // pointer to creation initialization -class SC_CORE_EXPORT Registry -{ +class SC_CORE_EXPORT Registry { protected: HashTable primordialSwamp; // dictionary of EntityDescriptors HashTable active_schemas; // dictionary of Schemas HashTable active_types; // dictionary of TypeDescriptors - ComplexCollect *col; // struct containing all complex entity info + ComplexCollect * col; // struct containing all complex entity info int entity_cnt, all_ents_cnt; @@ -51,53 +50,50 @@ class SC_CORE_EXPORT Registry // used by AddEntity() and RemoveEntity() to deal with renamings of an // entity done in a USE or REFERENCE clause - see header comments in // file Registry.inline.cc - void AddClones(const EntityDescriptor &); - void RemoveClones(const EntityDescriptor &); + void AddClones( const EntityDescriptor & ); + void RemoveClones( const EntityDescriptor & ); public: - Registry(CF_init initFunct); + Registry( CF_init initFunct ); ~Registry(); void DeleteContents(); // CAUTION: calls delete on all the descriptors - const EntityDescriptor *FindEntity(const char *, const char * = 0, - int check_case = 0) const; - const Schema *FindSchema(const char *, int check_case = 0) const; - const TypeDescriptor *FindType(const char *, int check_case = 0) const; + const EntityDescriptor * FindEntity( const char *, const char * = 0, + int check_case = 0 ) const; + const Schema * FindSchema( const char *, int check_case = 0 ) const; + const TypeDescriptor * FindType( const char *, int check_case = 0 ) const; - void AddEntity(const EntityDescriptor &); - void AddSchema(const Schema &); - void AddType(const TypeDescriptor &); + void AddEntity( const EntityDescriptor & ); + void AddSchema( const Schema & ); + void AddType( const TypeDescriptor & ); - void RemoveEntity(const char *); - void RemoveSchema(const char *); - void RemoveType(const char *); + void RemoveEntity( const char * ); + void RemoveSchema( const char * ); + void RemoveType( const char * ); int GetEntityCnt(); - int GetFullEntCnt() - { + int GetFullEntCnt() { return all_ents_cnt; } void ResetEntities(); - const EntityDescriptor *NextEntity(); + const EntityDescriptor * NextEntity(); void ResetSchemas(); - const Schema *NextSchema(); + const Schema * NextSchema(); void ResetTypes(); - const TypeDescriptor *NextType(); + const TypeDescriptor * NextType(); - const ComplexCollect *CompCol() - { + const ComplexCollect * CompCol() { return col; } - void SetCompCollect(ComplexCollect *c) - { + void SetCompCollect( ComplexCollect * c ) { col = c; } - SDAI_Application_instance *ObjCreate(const char *nm, const char * = 0, - int check_case = 0) const; + SDAI_Application_instance * ObjCreate( const char * nm, const char * = 0, + int check_case = 0 ) const; }; #endif /* _REGISTRY_H */ diff --git a/src/clstepcore/STEPaggrBinary.cc b/src/clstepcore/STEPaggrBinary.cc index 4b1df27d1..fd7302748 100644 --- a/src/clstepcore/STEPaggrBinary.cc +++ b/src/clstepcore/STEPaggrBinary.cc @@ -6,27 +6,24 @@ */ -BinaryAggregate::BinaryAggregate() -{ +BinaryAggregate::BinaryAggregate() { } -BinaryAggregate::~BinaryAggregate() -{ +BinaryAggregate::~BinaryAggregate() { } -STEPaggregate &BinaryAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & BinaryAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new BinaryNode(*(BinaryNode *)next); - AddNode(copy); + while( next ) { + copy = new BinaryNode( *( BinaryNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -35,35 +32,29 @@ STEPaggregate &BinaryAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *BinaryAggregate::NewNode() -{ +SingleLinkNode * BinaryAggregate::NewNode() { return new BinaryNode(); } -BinaryNode::BinaryNode() -{ +BinaryNode::BinaryNode() { value = 0; } -BinaryNode::~BinaryNode() -{ +BinaryNode::~BinaryNode() { } -BinaryNode::BinaryNode(BinaryNode &bn) -{ +BinaryNode::BinaryNode( BinaryNode & bn ) { value = bn.value.c_str(); } -BinaryNode::BinaryNode(const char *sStr) -{ +BinaryNode::BinaryNode( const char * sStr ) { // value is an SDAI_Binary (the memory is copied) value = sStr; } SingleLinkNode * -BinaryNode::NewNode() -{ +BinaryNode::NewNode() { return new BinaryNode(); } @@ -71,55 +62,48 @@ BinaryNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity BinaryNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity BinaryNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity BinaryNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); +Severity BinaryNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); - value.STEPread(in, err); - CheckRemainingInput(in, err, "binary", ",)"); + value.STEPread( in, err ); + CheckRemainingInput( in, err, "binary", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity BinaryNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity BinaryNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *BinaryNode::asStr(std::string &s) -{ +const char * BinaryNode::asStr( std::string & s ) { s = value.c_str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *BinaryNode::STEPwrite(std::string &s, const char *) -{ - value.STEPwrite(s); - return const_cast(s.c_str()); +const char * BinaryNode::STEPwrite( std::string & s, const char * ) { + value.STEPwrite( s ); + return const_cast( s.c_str() ); } -void BinaryNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void BinaryNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrBinary.h b/src/clstepcore/STEPaggrBinary.h index 7d627efa5..cd4991bbb 100644 --- a/src/clstepcore/STEPaggrBinary.h +++ b/src/clstepcore/STEPaggrBinary.h @@ -12,47 +12,45 @@ * * \class BinaryAggregate ** This class supports LIST OF BINARY type */ -class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - BinaryAggregate(); - virtual ~BinaryAggregate(); +class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + BinaryAggregate(); + virtual ~BinaryAggregate(); }; -typedef BinaryAggregate *BinaryAggregateH; -typedef BinaryAggregate *BinaryAggregate_ptr; -typedef const BinaryAggregate *BinaryAggregate_ptr_c; +typedef BinaryAggregate * BinaryAggregateH; +typedef BinaryAggregate * BinaryAggregate_ptr; +typedef const BinaryAggregate * BinaryAggregate_ptr_c; typedef BinaryAggregate_ptr BinaryAggregate_var; /** * * \class BinaryNode ** This class is for the Nodes of BinaryAggregates */ -class SC_CORE_EXPORT BinaryNode : public STEPnode -{ - public: - SDAI_Binary value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - BinaryNode(BinaryNode &bn); - BinaryNode(const char *sStr); - BinaryNode(); - ~BinaryNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT BinaryNode : public STEPnode { +public: + SDAI_Binary value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + BinaryNode( BinaryNode & bn ); + BinaryNode( const char * sStr ); + BinaryNode(); + ~BinaryNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index 480eb97dd..bda8f6db5 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -8,27 +8,24 @@ */ -EntityAggregate::EntityAggregate() -{ +EntityAggregate::EntityAggregate() { } -EntityAggregate::~EntityAggregate() -{ +EntityAggregate::~EntityAggregate() { } /// if exchangeFileFormat == 1 then delims are required. -Severity EntityAggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char *) -{ +Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char * ) { ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -38,99 +35,98 @@ Severity EntityAggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || (c == '$')) { + if( in.eof() || ( c == '$' ) ) { _null = 1; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - EntityNode *item = 0; + EntityNode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { + else if( !assignVal ) { item = new EntityNode(); } - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop + if( assignVal ) { // create a new node each time through the loop item = new EntityNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc, elem_type, insts, addFileId); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc, elem_type, insts, addFileId ); } else { - item->StrToVal(in, &errdesc, elem_type, insts, addFileId); + item->StrToVal( in, &errdesc, elem_type, insts, addFileId ); } - elem_type->AttrTypeName(buf); + elem_type->AttrTypeName( buf ); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput(in, &errdesc, buf, ",)"); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { - AddNode(item); + if( assignVal ) { + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate &EntityAggregate::ShallowCopy(const STEPaggregate &a) -{ - const EntityNode *tmp = (const EntityNode *) a.GetHead(); - while(tmp) { - AddNode(new EntityNode(tmp -> node)); - tmp = (const EntityNode *) tmp -> NextNode(); +STEPaggregate & EntityAggregate::ShallowCopy( const STEPaggregate & a ) { + const EntityNode * tmp = ( const EntityNode * ) a.GetHead(); + while( tmp ) { + AddNode( new EntityNode( tmp -> node ) ); + tmp = ( const EntityNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -140,44 +136,38 @@ STEPaggregate &EntityAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *EntityAggregate::NewNode() -{ +SingleLinkNode * EntityAggregate::NewNode() { return new EntityNode(); } -EntityNode::EntityNode() -{ +EntityNode::EntityNode() { } -EntityNode::~EntityNode() -{ +EntityNode::~EntityNode() { } -EntityNode::EntityNode(SDAI_Application_instance *e) : node(e) -{ +EntityNode::EntityNode( SDAI_Application_instance * e ) : node( e ) { } -SingleLinkNode *EntityNode::NewNode() -{ +SingleLinkNode * EntityNode::NewNode() { return new EntityNode(); } /////////////////////////////////////////////////////////////////////////////// -Severity EntityNode::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - SDAI_Application_instance *se = ReadEntityRef(s, err, ",)", insts, - addFileId); - if(se != S_ENTITY_NULL) { +Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + SDAI_Application_instance * se = ReadEntityRef( s, err, ",)", insts, + addFileId ); + if( se != S_ENTITY_NULL ) { ErrorDescriptor error; - if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { + if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); } } else { node = S_ENTITY_NULL; @@ -185,36 +175,33 @@ Severity EntityNode::StrToVal(const char *s, ErrorDescriptor *err, return err->severity(); } -Severity EntityNode::StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - return STEPread(in, err, elem_type, insts, addFileId); +Severity EntityNode::StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + return STEPread( in, err, elem_type, insts, addFileId ); } -Severity EntityNode::STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ - istringstream in((char *)s); - return STEPread(in, err, elem_type, insts, addFileId); +Severity EntityNode::STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId) -{ - SDAI_Application_instance *se = ReadEntityRef(in, err, ",)", insts, - addFileId); - if(se != S_ENTITY_NULL) { +Severity EntityNode::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { + SDAI_Application_instance * se = ReadEntityRef( in, err, ",)", insts, + addFileId ); + if( se != S_ENTITY_NULL ) { ErrorDescriptor error; - if(EntityValidLevel(se, elem_type, &error) == SEVERITY_NULL) { + if( EntityValidLevel( se, elem_type, &error ) == SEVERITY_NULL ) { node = se; } else { node = S_ENTITY_NULL; - err->AppendToDetailMsg(error.DetailMsg()); - err->AppendToUserMsg(error.UserMsg()); - err->GreaterSeverity(error.severity()); + err->AppendToDetailMsg( error.DetailMsg() ); + err->AppendToUserMsg( error.UserMsg() ); + err->GreaterSeverity( error.severity() ); } } else { node = S_ENTITY_NULL; @@ -222,36 +209,33 @@ Severity EntityNode::STEPread(istream &in, ErrorDescriptor *err, return err->severity(); } -const char *EntityNode::asStr(std::string &s) -{ +const char * EntityNode::asStr( std::string & s ) { s.clear(); - if(!node || (node == S_ENTITY_NULL)) { // nothing + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing return ""; } else { // otherwise return entity id char tmp [64]; - sprintf(tmp, "#%d", node->STEPfile_id); + sprintf( tmp, "#%d", node->STEPfile_id ); s = tmp; } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *EntityNode::STEPwrite(std::string &s, const char *) -{ - if(!node || (node == S_ENTITY_NULL)) { // nothing +const char * EntityNode::STEPwrite( std::string & s, const char * ) { + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing s = "$"; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } - asStr(s); - return const_cast(s.c_str()); + asStr( s ); + return const_cast( s.c_str() ); } -void EntityNode::STEPwrite(ostream &out) -{ - if(!node || (node == S_ENTITY_NULL)) { // nothing +void EntityNode::STEPwrite( ostream & out ) { + if( !node || ( node == S_ENTITY_NULL ) ) { // nothing out << "$"; } std::string s; - out << asStr(s); + out << asStr( s ); } diff --git a/src/clstepcore/STEPaggrEntity.h b/src/clstepcore/STEPaggrEntity.h index a89a3e55f..f18bc3d0f 100644 --- a/src/clstepcore/STEPaggrEntity.h +++ b/src/clstepcore/STEPaggrEntity.h @@ -8,83 +8,77 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT EntityAggregate : public STEPaggregate -{ - public: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); +class SC_CORE_EXPORT EntityAggregate : public STEPaggregate { +public: + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - EntityAggregate(); - virtual ~EntityAggregate(); + EntityAggregate(); + virtual ~EntityAggregate(); }; -typedef EntityAggregate *EntityAggregateH; -typedef EntityAggregate *EntityAggregate_ptr; -typedef const EntityAggregate *EntityAggregate_ptr_c; +typedef EntityAggregate * EntityAggregateH; +typedef EntityAggregate * EntityAggregate_ptr; +typedef const EntityAggregate * EntityAggregate_ptr_c; typedef EntityAggregate_ptr EntityAggregate_var; -class SC_CORE_EXPORT EntityNode : public STEPnode -{ - public: - SDAI_Application_instance *node; +class SC_CORE_EXPORT EntityNode : public STEPnode { +public: + SDAI_Application_instance * node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + virtual Severity STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - EntityNode(SDAI_Application_instance *e); - EntityNode(); - ~EntityNode(); + // CONSTRUCTORS + EntityNode( SDAI_Application_instance * e ); + EntityNode(); + ~EntityNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); - // Calling these functions is an error. - Severity StrToVal(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(s, err, 0, 0, 0); - } - Severity StrToVal(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(in, err, 0, 0, 0); - } + // Calling these functions is an error. + Severity StrToVal( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( s, err, 0, 0, 0 ); + } + Severity StrToVal( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( in, err, 0, 0, 0 ); + } - Severity STEPread(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(s, err, 0, 0, 0); - } - Severity STEPread(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(in, err, 0, 0, 0); - } + Severity STEPread( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( s, err, 0, 0, 0 ); + } + Severity STEPread( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( in, err, 0, 0, 0 ); + } }; #endif //STEPAGGRENTITY_H diff --git a/src/clstepcore/STEPaggrEnum.cc b/src/clstepcore/STEPaggrEnum.cc index ded295cf4..41b77aa21 100644 --- a/src/clstepcore/STEPaggrEnum.cc +++ b/src/clstepcore/STEPaggrEnum.cc @@ -7,18 +7,17 @@ /// COPY -STEPaggregate &EnumAggregate::ShallowCopy(const STEPaggregate &a) -{ - const EnumNode *tmp = (const EnumNode *) a.GetHead(); - EnumNode *to; - - while(tmp) { - to = (EnumNode *) NewNode(); - to -> node -> put(tmp -> node ->asInt()); - AddNode(to); - tmp = (const EnumNode *) tmp -> NextNode(); +STEPaggregate & EnumAggregate::ShallowCopy( const STEPaggregate & a ) { + const EnumNode * tmp = ( const EnumNode * ) a.GetHead(); + EnumNode * to; + + while( tmp ) { + to = ( EnumNode * ) NewNode(); + to -> node -> put( tmp -> node ->asInt() ); + AddNode( to ); + tmp = ( const EnumNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -27,13 +26,11 @@ STEPaggregate &EnumAggregate::ShallowCopy(const STEPaggregate &a) return *this; } -EnumAggregate::EnumAggregate() -{ +EnumAggregate::EnumAggregate() { } -EnumAggregate::~EnumAggregate() -{ +EnumAggregate::~EnumAggregate() { } @@ -44,69 +41,56 @@ EnumAggregate::~EnumAggregate() ** created ** Status: ok 2/91 ******************************************************************/ -SingleLinkNode *EnumAggregate::NewNode() -{ +SingleLinkNode * EnumAggregate::NewNode() { // defined in subclass cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumAggregate::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } -LOGICALS::LOGICALS() -{ +LOGICALS::LOGICALS() { } -LOGICALS::~LOGICALS() -{ +LOGICALS::~LOGICALS() { } -SingleLinkNode *LOGICALS::NewNode() -{ - return new EnumNode(new SDAI_LOGICAL); +SingleLinkNode * LOGICALS::NewNode() { + return new EnumNode( new SDAI_LOGICAL ); } -LOGICALS *create_LOGICALS() -{ +LOGICALS * create_LOGICALS() { return new LOGICALS; } -BOOLEANS::BOOLEANS() -{ +BOOLEANS::BOOLEANS() { } -BOOLEANS::~BOOLEANS() -{ +BOOLEANS::~BOOLEANS() { } -SingleLinkNode *BOOLEANS::NewNode() -{ - return new EnumNode(new SDAI_BOOLEAN); +SingleLinkNode * BOOLEANS::NewNode() { + return new EnumNode( new SDAI_BOOLEAN ); } -BOOLEANS *create_BOOLEANS() -{ +BOOLEANS * create_BOOLEANS() { return new BOOLEANS ; } -EnumNode::EnumNode(SDAI_Enum *e) : node(e) -{ +EnumNode::EnumNode( SDAI_Enum * e ) : node( e ) { } -EnumNode::EnumNode() -{ +EnumNode::EnumNode() { } -EnumNode::~EnumNode() -{ +EnumNode::~EnumNode() { } /// defined in subclass -SingleLinkNode *EnumNode::NewNode() -{ +SingleLinkNode * EnumNode::NewNode() { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: EnumNode::NewNode () called instead of virtual function. \n" - << _POC_ << "\n"; + << _POC_ << "\n"; return 0; } @@ -114,55 +98,48 @@ SingleLinkNode *EnumNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity EnumNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return node->STEPread(in, err); +Severity EnumNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return node->STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity EnumNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); // sz defaults to length of s +Severity EnumNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); // sz defaults to length of s int nullable = 0; - node->STEPread(in, err, nullable); - CheckRemainingInput(in, err, "enumeration", ",)"); + node->STEPread( in, err, nullable ); + CheckRemainingInput( in, err, "enumeration", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity EnumNode::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity EnumNode::STEPread( istream & in, ErrorDescriptor * err ) { int nullable = 0; - node->STEPread(in, err, nullable); + node->STEPread( in, err, nullable ); return err->severity(); } -const char *EnumNode::asStr(std::string &s) -{ - node -> asStr(s); - return const_cast(s.c_str()); +const char * EnumNode::asStr( std::string & s ) { + node -> asStr( s ); + return const_cast( s.c_str() ); } -const char *EnumNode::STEPwrite(std::string &s, const char *) -{ - node->STEPwrite(s); - return const_cast(s.c_str()); +const char * EnumNode::STEPwrite( std::string & s, const char * ) { + node->STEPwrite( s ); + return const_cast( s.c_str() ); } -void EnumNode::STEPwrite(ostream &out) -{ - node->STEPwrite(out); +void EnumNode::STEPwrite( ostream & out ) { + node->STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrEnum.h b/src/clstepcore/STEPaggrEnum.h index a1cf5d9dd..161706a48 100644 --- a/src/clstepcore/STEPaggrEnum.h +++ b/src/clstepcore/STEPaggrEnum.h @@ -11,77 +11,73 @@ * \class EnumAggregate * This is a minimal representions for a collection of SDAI_Enum */ -class SC_CORE_EXPORT EnumAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - EnumAggregate(); - virtual ~EnumAggregate(); +class SC_CORE_EXPORT EnumAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + EnumAggregate(); + virtual ~EnumAggregate(); }; -typedef EnumAggregate *EnumAggregateH; -typedef EnumAggregate *EnumAggregate_ptr; -typedef const EnumAggregate *EnumAggregate_ptr_c; +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: - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT LOGICALS : public EnumAggregate { +public: + virtual SingleLinkNode * NewNode(); - LOGICALS(); - virtual ~LOGICALS(); + LOGICALS(); + virtual ~LOGICALS(); }; -typedef LOGICALS *LogicalsH; -typedef LOGICALS *LOGICALS_ptr; -typedef const LOGICALS *LOGICALS_ptr_c; +typedef LOGICALS * LogicalsH; +typedef LOGICALS * LOGICALS_ptr; +typedef const LOGICALS * LOGICALS_ptr_c; typedef LOGICALS_ptr LOGICALS_var; -SC_CORE_EXPORT LOGICALS *create_LOGICALS(); +SC_CORE_EXPORT LOGICALS * create_LOGICALS(); -class SC_CORE_EXPORT BOOLEANS : public EnumAggregate -{ - public: - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT BOOLEANS : public EnumAggregate { +public: + virtual SingleLinkNode * NewNode(); - BOOLEANS(); - virtual ~BOOLEANS(); + BOOLEANS(); + virtual ~BOOLEANS(); }; -typedef BOOLEANS *BOOLEANS_ptr; -typedef const BOOLEANS *BOOLEANS_ptr_c; +typedef BOOLEANS * BOOLEANS_ptr; +typedef const BOOLEANS * BOOLEANS_ptr_c; typedef BOOLEANS_ptr BOOLEANS_var; -SC_CORE_EXPORT BOOLEANS *create_BOOLEANS(); +SC_CORE_EXPORT BOOLEANS * create_BOOLEANS(); /** * * \class EnumNode ** This is a minimal representions for node in lists of SDAI_Enum */ -class SC_CORE_EXPORT EnumNode : public STEPnode -{ - public: - SDAI_Enum *node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - EnumNode(SDAI_Enum *e); - EnumNode(); - ~EnumNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT EnumNode : public STEPnode { +public: + SDAI_Enum * node; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + EnumNode( SDAI_Enum * e ); + EnumNode(); + ~EnumNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrGeneric.cc b/src/clstepcore/STEPaggrGeneric.cc index fb94bfd83..899d6c656 100644 --- a/src/clstepcore/STEPaggrGeneric.cc +++ b/src/clstepcore/STEPaggrGeneric.cc @@ -5,32 +5,28 @@ * implement classes GenericAggregate, GenericAggrNode */ -GenericAggregate::GenericAggregate() -{ +GenericAggregate::GenericAggregate() { } -GenericAggregate::~GenericAggregate() -{ +GenericAggregate::~GenericAggregate() { } -SingleLinkNode *GenericAggregate::NewNode() -{ +SingleLinkNode * GenericAggregate::NewNode() { return new GenericAggrNode(); } -STEPaggregate &GenericAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & GenericAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new GenericAggrNode(*(GenericAggrNode *)next); - AddNode(copy); + while( next ) { + copy = new GenericAggrNode( *( GenericAggrNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -39,65 +35,53 @@ STEPaggregate &GenericAggregate::ShallowCopy(const STEPaggregate &a) } -GenericAggrNode::GenericAggrNode(const char *str) -{ +GenericAggrNode::GenericAggrNode( const char * str ) { value = str; } -GenericAggrNode::GenericAggrNode(GenericAggrNode &gan) -{ +GenericAggrNode::GenericAggrNode( GenericAggrNode & gan ) { value = gan.value; } -GenericAggrNode::GenericAggrNode() -{ +GenericAggrNode::GenericAggrNode() { } -GenericAggrNode::~GenericAggrNode() -{ +GenericAggrNode::~GenericAggrNode() { } -SingleLinkNode *GenericAggrNode::NewNode() -{ +SingleLinkNode * GenericAggrNode::NewNode() { return new GenericAggrNode(); } -Severity GenericAggrNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return value.STEPread(s, err); +Severity GenericAggrNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return value.STEPread( s, err ); } //TODO -Severity GenericAggrNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity GenericAggrNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -Severity GenericAggrNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *) s); - return value.STEPread(in, err); +Severity GenericAggrNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * ) s ); + return value.STEPread( in, err ); } -Severity GenericAggrNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity GenericAggrNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *GenericAggrNode::asStr(std::string &s) -{ +const char * GenericAggrNode::asStr( std::string & s ) { s.clear(); - value.asStr(s); - return const_cast(s.c_str()); + value.asStr( s ); + return const_cast( s.c_str() ); } -const char *GenericAggrNode::STEPwrite(std::string &s, const char *currSch) -{ +const char * GenericAggrNode::STEPwrite( std::string & s, const char * currSch ) { (void) currSch; //unused - return value.STEPwrite(s); + return value.STEPwrite( s ); } -void GenericAggrNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void GenericAggrNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrGeneric.h b/src/clstepcore/STEPaggrGeneric.h index 037572180..76190406e 100644 --- a/src/clstepcore/STEPaggrGeneric.h +++ b/src/clstepcore/STEPaggrGeneric.h @@ -13,46 +13,44 @@ * 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: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - GenericAggregate(); - virtual ~GenericAggregate(); +class SC_CORE_EXPORT GenericAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + GenericAggregate(); + virtual ~GenericAggregate(); }; -typedef GenericAggregate *GenericAggregateH; -typedef GenericAggregate *GenericAggregate_ptr; -typedef const GenericAggregate *GenericAggregate_ptr_c; +typedef GenericAggregate * GenericAggregateH; +typedef GenericAggregate * GenericAggregate_ptr; +typedef const GenericAggregate * GenericAggregate_ptr_c; typedef GenericAggregate_ptr GenericAggregate_var; /** * This class is for the Nodes of GenericAggregates */ -class SC_CORE_EXPORT GenericAggrNode : public STEPnode -{ - public: - SCLundefined value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - GenericAggrNode(const char *str); - GenericAggrNode(GenericAggrNode &gan); - GenericAggrNode(); - ~GenericAggrNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT GenericAggrNode : public STEPnode { +public: + SCLundefined value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + GenericAggrNode( const char * str ); + GenericAggrNode( GenericAggrNode & gan ); + GenericAggrNode(); + ~GenericAggrNode(); + + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index cc729a455..2e61a1504 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -1,32 +1,28 @@ #include "STEPaggrInt.h" -IntAggregate::IntAggregate() -{ +IntAggregate::IntAggregate() { } -IntAggregate::~IntAggregate() -{ +IntAggregate::~IntAggregate() { } -SingleLinkNode *IntAggregate::NewNode() -{ +SingleLinkNode * IntAggregate::NewNode() { return new IntNode(); } /// COPY -STEPaggregate &IntAggregate::ShallowCopy(const STEPaggregate &a) -{ - const IntNode *tmp = (const IntNode *) a.GetHead(); - IntNode *to; +STEPaggregate & IntAggregate::ShallowCopy( const STEPaggregate & a ) { + const IntNode * tmp = ( const IntNode * ) a.GetHead(); + IntNode * to; - while(tmp) { - to = (IntNode *) NewNode(); + while( tmp ) { + to = ( IntNode * ) NewNode(); to -> value = tmp -> value; - AddNode(to); - tmp = (const IntNode *) tmp -> NextNode(); + AddNode( to ); + tmp = ( const IntNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -37,28 +33,23 @@ STEPaggregate &IntAggregate::ShallowCopy(const STEPaggregate &a) -IntNode::IntNode() -{ +IntNode::IntNode() { value = S_INT_NULL; } -IntNode::IntNode(SDAI_Integer v) -{ +IntNode::IntNode( SDAI_Integer v ) { value = v; } -IntNode::~IntNode() -{ +IntNode::~IntNode() { } -SingleLinkNode *IntNode::NewNode() -{ +SingleLinkNode * IntNode::NewNode() { return new IntNode(); } -Severity IntNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned +Severity IntNode::StrToVal( const char * s, ErrorDescriptor * err ) { + if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -67,9 +58,8 @@ Severity IntNode::StrToVal(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned +Severity IntNode::StrToVal( istream & in, ErrorDescriptor * err ) { + if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -78,9 +68,8 @@ Severity IntNode::StrToVal(istream &in, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::STEPread(const char *s, ErrorDescriptor *err) -{ - if(ReadInteger(value, s, err, ",)")) { // returns true if value is assigned +Severity IntNode::STEPread( const char * s, ErrorDescriptor * err ) { + if( ReadInteger( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -89,9 +78,8 @@ Severity IntNode::STEPread(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity IntNode::STEPread(istream &in, ErrorDescriptor *err) -{ - if(ReadInteger(value, in, err, ",)")) { // returns true if value is assigned +Severity IntNode::STEPread( istream & in, ErrorDescriptor * err ) { + if( ReadInteger( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -100,26 +88,23 @@ Severity IntNode::STEPread(istream &in, ErrorDescriptor *err) return err->severity(); } -const char *IntNode::asStr(std::string &s) -{ - STEPwrite(s); - return const_cast(s.c_str()); +const char * IntNode::asStr( std::string & s ) { + STEPwrite( s ); + return const_cast( s.c_str() ); } -const char *IntNode::STEPwrite(std::string &s, const char *) -{ +const char * IntNode::STEPwrite( std::string & s, const char * ) { char tmp[BUFSIZ]; - if(value != S_INT_NULL) { - sprintf(tmp, "%ld", value); + if( value != S_INT_NULL ) { + sprintf( tmp, "%ld", value ); s = tmp; } else { s.clear(); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void IntNode::STEPwrite(ostream &out) -{ +void IntNode::STEPwrite( ostream & out ) { std::string s; - out << STEPwrite(s); + out << STEPwrite( s ); } diff --git a/src/clstepcore/STEPaggrInt.h b/src/clstepcore/STEPaggrInt.h index bf10ca8b0..726d07c0e 100644 --- a/src/clstepcore/STEPaggrInt.h +++ b/src/clstepcore/STEPaggrInt.h @@ -4,44 +4,42 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT IntAggregate : public STEPaggregate -{ +class SC_CORE_EXPORT IntAggregate : public STEPaggregate { - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - IntAggregate(); - virtual ~IntAggregate(); + IntAggregate(); + virtual ~IntAggregate(); }; -typedef IntAggregate *IntAggregateH; -typedef IntAggregate *IntAggregate_ptr; -typedef const IntAggregate *IntAggregate_ptr_c; +typedef IntAggregate * IntAggregateH; +typedef IntAggregate * IntAggregate_ptr; +typedef const IntAggregate * IntAggregate_ptr_c; typedef IntAggregate_ptr IntAggregate_var; -class SC_CORE_EXPORT IntNode : public STEPnode -{ - public: - SDAI_Integer value; // long int - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); +class SC_CORE_EXPORT IntNode : public STEPnode { +public: + SDAI_Integer value; // long int + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - IntNode(SDAI_Integer v); - IntNode(); - ~IntNode(); + // CONSTRUCTORS + IntNode( SDAI_Integer v ); + IntNode(); + ~IntNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrReal.cc b/src/clstepcore/STEPaggrReal.cc index d517d90ef..7d05c1333 100644 --- a/src/clstepcore/STEPaggrReal.cc +++ b/src/clstepcore/STEPaggrReal.cc @@ -4,32 +4,28 @@ * implementation of classes RealAggregate and RealNode */ -RealAggregate::RealAggregate() -{ +RealAggregate::RealAggregate() { } -RealAggregate::~RealAggregate() -{ +RealAggregate::~RealAggregate() { } -SingleLinkNode *RealAggregate::NewNode() -{ +SingleLinkNode * RealAggregate::NewNode() { return new RealNode(); } // COPY -STEPaggregate &RealAggregate::ShallowCopy(const STEPaggregate &a) -{ - const RealNode *tmp = (const RealNode *) a.GetHead(); - RealNode *to; +STEPaggregate & RealAggregate::ShallowCopy( const STEPaggregate & a ) { + const RealNode * tmp = ( const RealNode * ) a.GetHead(); + RealNode * to; - while(tmp) { - to = (RealNode *) NewNode(); + while( tmp ) { + to = ( RealNode * ) NewNode(); to -> value = tmp -> value; - AddNode(to); - tmp = (const RealNode *) tmp -> NextNode(); + AddNode( to ); + tmp = ( const RealNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -38,28 +34,23 @@ STEPaggregate &RealAggregate::ShallowCopy(const STEPaggregate &a) } -RealNode::RealNode() -{ +RealNode::RealNode() { value = S_REAL_NULL; } -RealNode::RealNode(SDAI_Real v) -{ +RealNode::RealNode( SDAI_Real v) { value = v; } -RealNode::~RealNode() -{ +RealNode::~RealNode() { } -SingleLinkNode *RealNode::NewNode() -{ +SingleLinkNode * RealNode::NewNode() { return new RealNode(); } -Severity RealNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned +Severity RealNode::StrToVal( const char * s, ErrorDescriptor * err ) { + if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -68,9 +59,8 @@ Severity RealNode::StrToVal(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned +Severity RealNode::StrToVal( istream & in, ErrorDescriptor * err ) { + if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -79,9 +69,8 @@ Severity RealNode::StrToVal(istream &in, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::STEPread(const char *s, ErrorDescriptor *err) -{ - if(ReadReal(value, s, err, ",)")) { // returns true if value is assigned +Severity RealNode::STEPread( const char * s, ErrorDescriptor * err ) { + if( ReadReal( value, s, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -90,9 +79,8 @@ Severity RealNode::STEPread(const char *s, ErrorDescriptor *err) return err->severity(); } -Severity RealNode::STEPread(istream &in, ErrorDescriptor *err) -{ - if(ReadReal(value, in, err, ",)")) { // returns true if value is assigned +Severity RealNode::STEPread( istream & in, ErrorDescriptor * err ) { + if( ReadReal( value, in, err, ",)" ) ) { // returns true if value is assigned _null = 0; } else { set_null(); @@ -101,26 +89,23 @@ Severity RealNode::STEPread(istream &in, ErrorDescriptor *err) return err->severity(); } -const char *RealNode::asStr(std::string &s) -{ - STEPwrite(s); - return const_cast(s.c_str()); +const char * RealNode::asStr( std::string & s ) { + STEPwrite( s ); + return const_cast( s.c_str() ); } -const char *RealNode::STEPwrite(std::string &s, const char *) -{ +const char * RealNode::STEPwrite( std::string & s, const char * ) { //use memcmp to work around -Wfloat-equal warning SDAI_Real z = S_REAL_NULL; - if(0 != memcmp(&value, &z, sizeof z)) { - s = WriteReal(value); + if( 0 != memcmp( &value, &z, sizeof z ) ) { + s = WriteReal( value ); } else { s.clear(); } return s.c_str(); } -void RealNode::STEPwrite(ostream &out) -{ +void RealNode::STEPwrite( ostream & out ) { std::string s; - out << STEPwrite(s); + out << STEPwrite( s ); } diff --git a/src/clstepcore/STEPaggrReal.h b/src/clstepcore/STEPaggrReal.h index f3b6602d8..48cd90e51 100644 --- a/src/clstepcore/STEPaggrReal.h +++ b/src/clstepcore/STEPaggrReal.h @@ -4,43 +4,41 @@ #include "STEPaggregate.h" #include -class SC_CORE_EXPORT RealAggregate : public STEPaggregate -{ +class SC_CORE_EXPORT RealAggregate : public STEPaggregate { - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - RealAggregate(); - virtual ~RealAggregate(); + RealAggregate(); + virtual ~RealAggregate(); }; -typedef RealAggregate *RealAggregateH; -typedef RealAggregate *RealAggregate_ptr; -typedef const RealAggregate *RealAggregate_ptr_c; +typedef RealAggregate * RealAggregateH; +typedef RealAggregate * RealAggregate_ptr; +typedef const RealAggregate * RealAggregate_ptr_c; typedef RealAggregate_ptr RealAggregate_var; -class SC_CORE_EXPORT RealNode : public STEPnode -{ - public: - SDAI_Real value; // double - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); +class SC_CORE_EXPORT RealNode : public STEPnode { +public: + SDAI_Real value; // double + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - RealNode(SDAI_Real v); - RealNode(); - ~RealNode(); + // CONSTRUCTORS + RealNode( SDAI_Real v ); + RealNode(); + ~RealNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); }; diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index f74fcf955..02970479c 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -6,27 +6,24 @@ * implement classes SelectAggregate, SelectNode */ -SelectAggregate::SelectAggregate() -{ +SelectAggregate::SelectAggregate() { } -SelectAggregate::~SelectAggregate() -{ +SelectAggregate::~SelectAggregate() { } /// if exchangeFileFormat == 1 then delims are required. -Severity SelectAggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, - int exchangeFileFormat, const char *currSch) -{ +Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, + int exchangeFileFormat, const char * currSch ) { ErrorDescriptor errdesc; char errmsg[BUFSIZ]; int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -36,100 +33,99 @@ Severity SelectAggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || (c == '$')) { + if( in.eof() || ( c == '$' ) ) { _null = 1; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // give up because you do not know where to stop reading. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - SelectNode *item = 0; + SelectNode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { - item = (SelectNode *) NewNode(); + else if( !assignVal ) { + item = ( SelectNode * ) NewNode(); } - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop - item = (SelectNode *) NewNode(); + if( assignVal ) { // create a new node each time through the loop + item = ( SelectNode * ) NewNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc, elem_type, insts, addFileId, currSch); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc, elem_type, insts, addFileId, currSch ); } else { - item->StrToVal(in, &errdesc, elem_type, insts, addFileId, currSch); + item->StrToVal( in, &errdesc, elem_type, insts, addFileId, currSch ); } - elem_type->AttrTypeName(buf); + elem_type->AttrTypeName( buf ); // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - CheckRemainingInput(in, &errdesc, buf, ",)"); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { - AddNode(item); + if( assignVal ) { + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = 0; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -STEPaggregate &SelectAggregate::ShallowCopy(const STEPaggregate &a) -{ - const SelectNode *tmp = (const SelectNode *) a.GetHead(); - while(tmp) { - AddNode(new SelectNode(tmp -> node)); +STEPaggregate & SelectAggregate::ShallowCopy( const STEPaggregate & a ) { + const SelectNode * tmp = ( const SelectNode * ) a.GetHead(); + while( tmp ) { + AddNode( new SelectNode( tmp -> node ) ); - tmp = (const SelectNode *) tmp -> NextNode(); + tmp = ( const SelectNode * ) tmp -> NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -139,102 +135,90 @@ STEPaggregate &SelectAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *SelectAggregate::NewNode() -{ +SingleLinkNode * SelectAggregate::NewNode() { return new SelectNode(); } -SelectNode::SelectNode(SDAI_Select *s) : node(s) -{ +SelectNode::SelectNode( SDAI_Select * s ) : node( s ) { } -SelectNode::SelectNode() -{ +SelectNode::SelectNode() { } -SelectNode::~SelectNode() -{ +SelectNode::~SelectNode() { delete node; } -SingleLinkNode *SelectNode::NewNode() -{ +SingleLinkNode * SelectNode::NewNode() { return new SelectNode(); } -Severity SelectNode::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId) -{ +Severity SelectNode::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId ) { (void) elem_type; //unused (void) addFileId; //unused - istringstream in((char *)s); - if(err->severity(node->STEPread(in, err, insts)) != SEVERITY_NULL) { - err->AppendToDetailMsg(node ->Error()); + istringstream in( ( char * )s ); + if( err->severity( node->STEPread( in, err, insts ) ) != SEVERITY_NULL ) { + err->AppendToDetailMsg( node ->Error() ); } return err->severity(); } -Severity SelectNode::StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId, const char *currSch) -{ - return STEPread(in, err, elem_type, insts, addFileId, currSch); +Severity SelectNode::StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId) -{ - istringstream in((char *)s); - return STEPread(in, err, elem_type, insts, addFileId); +Severity SelectNode::STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + 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, - InstMgrBase *insts, int addFileId, const char *currSch) -{ +Severity SelectNode::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId, const char * currSch ) { (void) elem_type; //unused - if(!node) { + if( !node ) { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; cerr << "function: SelectNode::STEPread \n" << "\n"; return SEVERITY_BUG; } - err->severity(node->STEPread(in, err, insts, 0, addFileId, currSch)); - CheckRemainingInput(in, err, "select", ",)"); + err->severity( node->STEPread( in, err, insts, 0, addFileId, currSch ) ); + CheckRemainingInput( in, err, "select", ",)" ); return err->severity(); } -const char *SelectNode::asStr(std::string &s) -{ +const char * SelectNode::asStr( std::string & s ) { s.clear(); - if(!node || (node->is_null())) { // nothing + if( !node || ( node->is_null() ) ) { // nothing return ""; } else { // otherwise return entity id - node -> STEPwrite(s); - return const_cast(s.c_str()); + node -> STEPwrite( s ); + return const_cast( s.c_str() ); } } -const char *SelectNode::STEPwrite(std::string &s, const char *currSch) -{ +const char * SelectNode::STEPwrite( std::string & s, const char * currSch ) { s.clear(); - if(!node || (node->is_null())) { // nothing + if( !node || ( node->is_null() ) ) { // nothing s = "$"; return "$"; } - node -> STEPwrite(s, currSch); - return const_cast(s.c_str()); + node -> STEPwrite( s, currSch ); + return const_cast( s.c_str() ); } -void SelectNode::STEPwrite(ostream &out) -{ - if(!node || (node->is_null())) { // nothing +void SelectNode::STEPwrite( ostream & out ) { + if( !node || ( node->is_null() ) ) { // nothing out << "$"; } std::string s; - out << asStr(s); + out << asStr( s ); } diff --git a/src/clstepcore/STEPaggrSelect.h b/src/clstepcore/STEPaggrSelect.h index 1db7ba252..b62a9c3fe 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/src/clstepcore/STEPaggrSelect.h @@ -13,24 +13,23 @@ * * \class SelectAggregate ** This is a minimal represention for a collection of SDAI_Select */ -class SC_CORE_EXPORT SelectAggregate : public STEPaggregate -{ - public: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); +class SC_CORE_EXPORT SelectAggregate : public STEPaggregate { +public: + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); - SelectAggregate(); - virtual ~SelectAggregate(); + SelectAggregate(); + virtual ~SelectAggregate(); }; -typedef SelectAggregate *SelectAggregateH; -typedef SelectAggregate *SelectAggregate_ptr; -typedef const SelectAggregate *SelectAggregate_ptr_c; +typedef SelectAggregate * SelectAggregateH; +typedef SelectAggregate * SelectAggregate_ptr; +typedef const SelectAggregate * SelectAggregate_ptr_c; typedef SelectAggregate_ptr SelectAggregate_var; @@ -38,64 +37,59 @@ typedef SelectAggregate_ptr SelectAggregate_var; * * \class SelectNode ** This is a minimal representions for node in lists of SDAI_Select */ -class SC_CORE_EXPORT SelectNode : public STEPnode -{ - public: - SDAI_Select *node; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - const char *currSch = 0); +class SC_CORE_EXPORT SelectNode : public STEPnode { +public: + SDAI_Select * node; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + const char * currSch = 0 ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - const char *currSch = 0); - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); + virtual Severity STEPread( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + const char * currSch = 0 ); + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); - // CONSTRUCTORS - SelectNode(SDAI_Select *s); - SelectNode(); - ~SelectNode(); + // CONSTRUCTORS + SelectNode( SDAI_Select * s ); + SelectNode(); + ~SelectNode(); - virtual SingleLinkNode *NewNode(); + virtual SingleLinkNode * NewNode(); - // Calling these functions is an error. - Severity StrToVal(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(s, err, 0, 0, 0); - } - Severity StrToVal(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return StrToVal(in, err, 0, 0, 0); - } + // Calling these functions is an error. + Severity StrToVal( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( s, err, 0, 0, 0 ); + } + Severity StrToVal( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return StrToVal( in, err, 0, 0, 0 ); + } - Severity STEPread(const char *s, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(s, err, 0, 0, 0); - } - Severity STEPread(istream &in, ErrorDescriptor *err) - { - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return STEPread(in, err, 0, 0, 0); - } + Severity STEPread( const char * s, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( s, err, 0, 0, 0 ); + } + Severity STEPread( istream & in, ErrorDescriptor * err ) { + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return STEPread( in, err, 0, 0, 0 ); + } }; diff --git a/src/clstepcore/STEPaggrString.cc b/src/clstepcore/STEPaggrString.cc index 08179bb3d..fd9285ad3 100644 --- a/src/clstepcore/STEPaggrString.cc +++ b/src/clstepcore/STEPaggrString.cc @@ -6,27 +6,24 @@ */ -StringAggregate::StringAggregate() -{ +StringAggregate::StringAggregate() { } -StringAggregate::~StringAggregate() -{ +StringAggregate::~StringAggregate() { } -STEPaggregate &StringAggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) { Empty(); - SingleLinkNode *next = a.GetHead(); - SingleLinkNode *copy; + SingleLinkNode * next = a.GetHead(); + SingleLinkNode * copy; - while(next) { - copy = new StringNode(*(StringNode *)next); - AddNode(copy); + while( next ) { + copy = new StringNode( *( StringNode * )next ); + AddNode( copy ); next = next->NextNode(); } - if(head) { + if( head ) { _null = 0; } else { _null = 1; @@ -35,34 +32,28 @@ STEPaggregate &StringAggregate::ShallowCopy(const STEPaggregate &a) } -SingleLinkNode *StringAggregate::NewNode() -{ +SingleLinkNode * StringAggregate::NewNode() { return new StringNode(); } -StringNode::StringNode() -{ +StringNode::StringNode() { value = ""; } -StringNode::~StringNode() -{ +StringNode::~StringNode() { } -StringNode::StringNode(StringNode &sn) -{ +StringNode::StringNode( StringNode & sn ) { value = sn.value.c_str(); } -StringNode::StringNode(const char *sStr) -{ +StringNode::StringNode( const char * sStr ) { // value is an SDAI_String (the memory is copied) value = sStr; } -SingleLinkNode *StringNode::NewNode() -{ +SingleLinkNode * StringNode::NewNode() { return new StringNode(); } @@ -70,54 +61,47 @@ SingleLinkNode *StringNode::NewNode() * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::StrToVal(const char *s, ErrorDescriptor *err) -{ - return STEPread(s, err); +Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) { + return STEPread( s, err ); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::StrToVal(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } /** * non-whitespace chars following s are considered garbage and is an error. * a valid value will still be assigned if it exists before the garbage. */ -Severity StringNode::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *)s); +Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * )s ); - value.STEPread(in, err); - CheckRemainingInput(in, err, "string", ",)"); + value.STEPread( in, err ); + CheckRemainingInput( in, err, "string", ",)" ); return err->severity(); } /** * this function assumes you will check for garbage following input */ -Severity StringNode::STEPread(istream &in, ErrorDescriptor *err) -{ - return value.STEPread(in, err); +Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) { + return value.STEPread( in, err ); } -const char *StringNode::asStr(std::string &s) -{ - value.asStr(s); - return const_cast(s.c_str()); +const char * StringNode::asStr( std::string & s ) { + value.asStr( s ); + return const_cast( s.c_str() ); } -const char *StringNode::STEPwrite(std::string &s, const char *) -{ - value.STEPwrite(s); - return const_cast(s.c_str()); +const char * StringNode::STEPwrite( std::string & s, const char * ) { + value.STEPwrite( s ); + return const_cast( s.c_str() ); } -void StringNode::STEPwrite(ostream &out) -{ - value.STEPwrite(out); +void StringNode::STEPwrite( ostream & out ) { + value.STEPwrite( out ); } diff --git a/src/clstepcore/STEPaggrString.h b/src/clstepcore/STEPaggrString.h index 5446a989a..6f5cc8331 100644 --- a/src/clstepcore/STEPaggrString.h +++ b/src/clstepcore/STEPaggrString.h @@ -12,47 +12,45 @@ * * \class StringAggregate ** This class supports LIST OF STRING type */ -class SC_CORE_EXPORT StringAggregate : public STEPaggregate -{ - public: - virtual SingleLinkNode *NewNode(); - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); - - StringAggregate(); - virtual ~StringAggregate(); +class SC_CORE_EXPORT StringAggregate : public STEPaggregate { +public: + virtual SingleLinkNode * NewNode(); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); + + StringAggregate(); + virtual ~StringAggregate(); }; -typedef StringAggregate *StringAggregateH; -typedef StringAggregate *StringAggregate_ptr; -typedef const StringAggregate *StringAggregate_ptr_c; +typedef StringAggregate * StringAggregateH; +typedef StringAggregate * StringAggregate_ptr; +typedef const StringAggregate * StringAggregate_ptr_c; typedef StringAggregate_ptr StringAggregate_var; /** * * \class StringNode ** This class is for the Nodes of StringAggregates */ -class SC_CORE_EXPORT StringNode : public STEPnode -{ - public: - SDAI_String value; - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); - - // CONSTRUCTORS - StringNode(StringNode &sn); - StringNode(const char *sStr); - StringNode(); - ~StringNode(); - - virtual SingleLinkNode *NewNode(); +class SC_CORE_EXPORT StringNode : public STEPnode { +public: + SDAI_String value; + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); + + // CONSTRUCTORS + StringNode( StringNode & sn ); + StringNode( const char * sStr ); + StringNode(); + ~StringNode(); + + virtual SingleLinkNode * NewNode(); }; #endif //STEPAGGRSTRING_H diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 7bf6933e6..db3bbf819 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -34,25 +34,22 @@ STEPaggregate NilSTEPaggregate; -STEPaggregate::STEPaggregate() -{ +STEPaggregate::STEPaggregate() { _null = true; } -STEPaggregate::~STEPaggregate() -{ - STEPnode *node; +STEPaggregate::~STEPaggregate() { + STEPnode * node; - node = (STEPnode *) head; - while(node) { + node = ( STEPnode * ) head; + while( node ) { head = node->NextNode(); delete node; - node = (STEPnode *) head; + node = ( STEPnode * ) head; } } -STEPaggregate &STEPaggregate::ShallowCopy(const STEPaggregate &a) -{ +STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) { (void) a; // unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" << _POC_ "\n"; @@ -61,53 +58,50 @@ STEPaggregate &STEPaggregate::ShallowCopy(const STEPaggregate &a) } /// do not require exchange file format -Severity STEPaggregate::AggrValidLevel(const char *value, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId, - int clearError) -{ +Severity STEPaggregate::AggrValidLevel( const char * value, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int optional, char * tokenList, int addFileId, + int clearError ) { std::string buf; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)value); // sz defaults to length of s + istringstream in( ( char * )value ); // sz defaults to length of s - ReadValue(in, err, elem_type, insts, addFileId, 0, 0); - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, err, buf, tokenList); - if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { - err->severity(SEVERITY_NULL); + ReadValue( in, err, elem_type, insts, addFileId, 0, 0 ); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, err, buf, tokenList ); + if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// require exchange file format -Severity STEPaggregate::AggrValidLevel(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId, - int clearError) -{ +Severity STEPaggregate::AggrValidLevel( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int optional, char * tokenList, int addFileId, + int clearError ) { std::string buf; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } - ReadValue(in, err, elem_type, insts, addFileId, 0, 1); - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, err, buf, tokenList); - if(optional && (err->severity() == SEVERITY_INCOMPLETE)) { - err->severity(SEVERITY_NULL); + ReadValue( in, err, elem_type, insts, addFileId, 0, 1 ); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, err, buf, tokenList ); + if( optional && ( err->severity() == SEVERITY_INCOMPLETE ) ) { + err->severity( SEVERITY_NULL ); } return err->severity(); } /// if exchangeFileFormat == 1 then paren delims are required. -Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, int assignVal, int exchangeFileFormat, - const char *) -{ +Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, int assignVal, int exchangeFileFormat, + const char * ) { (void) insts; //not used in ReadValue() for this class (void) addFileId; //not used in ReadValue() for this class @@ -116,7 +110,7 @@ Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, int value_cnt = 0; std::string buf; - if(assignVal) { + if( assignVal ) { Empty(); // read new values and discard existing ones } @@ -126,138 +120,134 @@ Severity STEPaggregate::ReadValue(istream &in, ErrorDescriptor *err, c = in.peek(); // does not advance input - if(in.eof() || c == '$') { + if( in.eof() || c == '$' ) { _null = true; - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - if(c == '(') { - in.get(c); - } else if(exchangeFileFormat) { + if( c == '(' ) { + in.get( c ); + } else if( exchangeFileFormat ) { // error did not find opening delim // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; - } else if(!in.good()) { + } else if( !in.good() ) { // this should actually have been caught by skipping white space above - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } - STEPnode *item = 0; + STEPnode * item = 0; in >> ws; // take a peek to see if there are any elements before committing to an // element c = in.peek(); // does not advance input - if(c == ')') { - in.get(c); + if( c == ')' ) { + in.get( c ); } // if not assigning values only need one node. So only one node is created. // It is used to read the values - else if(!assignVal) { - item = (STEPnode *)NewNode(); + else if( !assignVal ) { + item = ( STEPnode * )NewNode(); } // ')' is the end of the aggregate - while(in.good() && (c != ')')) { + while( in.good() && ( c != ')' ) ) { value_cnt++; - if(assignVal) { // create a new node each time through the loop - item = (STEPnode *)NewNode(); + if( assignVal ) { // create a new node each time through the loop + item = ( STEPnode * )NewNode(); } errdesc.ClearErrorMsg(); - if(exchangeFileFormat) { - item->STEPread(in, &errdesc); + if( exchangeFileFormat ) { + item->STEPread( in, &errdesc ); } else { - item->StrToVal(in, &errdesc); + item->StrToVal( in, &errdesc ); } // read up to the next delimiter and set errors if garbage is // found before specified delims (i.e. comma and quote) - elem_type->AttrTypeName(buf); - CheckRemainingInput(in, &errdesc, buf, ",)"); + elem_type->AttrTypeName( buf ); + CheckRemainingInput( in, &errdesc, buf, ",)" ); - if(errdesc.severity() < SEVERITY_INCOMPLETE) { - sprintf(errmsg, " index: %d\n", value_cnt); - errdesc.PrependToDetailMsg(errmsg); - err->AppendFromErrorArg(&errdesc); + if( errdesc.severity() < SEVERITY_INCOMPLETE ) { + sprintf( errmsg, " index: %d\n", value_cnt ); + errdesc.PrependToDetailMsg( errmsg ); + err->AppendFromErrorArg( &errdesc ); } - if(assignVal) { // pass the node to STEPaggregate - AddNode(item); + if( assignVal ) { // pass the node to STEPaggregate + AddNode( item ); } in >> ws; // skip white space (although should already be skipped) - in.get(c); // read delim + in.get( c ); // read delim // CheckRemainingInput should have left the input right at the delim // so that it would be read in in.get() above. Since it did not find // the delim this does not know how to find it either! - if((c != ',') && (c != ')')) { + if( ( c != ',' ) && ( c != ')' ) ) { // cannot recover so give up and let STEPattribute recover - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); return SEVERITY_INPUT_ERROR; } } - if(c == ')') { + if( c == ')' ) { _null = false; } else { // expectation for end paren delim has not been met - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->AppendToUserMsg("Missing close paren for aggregate value"); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->AppendToUserMsg( "Missing close paren for aggregate value" ); return SEVERITY_INPUT_ERROR; } return err->severity(); } -Severity STEPaggregate::StrToVal(const char *s, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId) -{ - istringstream in((char *)s); - return ReadValue(in, err, elem_type, insts, addFileId, 1, 0); +Severity STEPaggregate::StrToVal( const char * s, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId ) { + istringstream in( ( char * )s ); + return ReadValue( in, err, elem_type, insts, addFileId, 1, 0 ); } /////////////////////////////////////////////////////////////////////////////// -Severity STEPaggregate::STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int addFileId, const char *currSch) -{ - return ReadValue(in, err, elem_type, insts, addFileId, 1, 1, currSch); +Severity STEPaggregate::STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, InstMgrBase * insts, + int addFileId, const char * currSch ) { + return ReadValue( in, err, elem_type, insts, addFileId, 1, 1, currSch ); } -const char *STEPaggregate::asStr(std::string &s) const -{ +const char * STEPaggregate::asStr( std::string & s ) const { s.clear(); - if(!_null) { + if( !_null ) { s = "("; - STEPnode *n = (STEPnode *) head; + STEPnode * n = ( STEPnode * ) head; std::string tmp; - while(n) { - s.append(n->STEPwrite(tmp)); - n = (STEPnode *) n -> NextNode(); - if(n) { - s.append(","); + while( n ) { + s.append( n->STEPwrite( tmp ) ); + n = ( STEPnode * ) n -> NextNode(); + if( n ) { + s.append( "," ); } } - s.append(")"); + s.append( ")" ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void STEPaggregate::STEPwrite(ostream &out, const char *currSch) const -{ - if(!_null) { +void STEPaggregate::STEPwrite( ostream & out, const char * currSch ) const { + if( !_null ) { out << '('; - STEPnode *n = (STEPnode *)head; + STEPnode * n = ( STEPnode * )head; std::string s; - while(n) { - out << n->STEPwrite(s, currSch); - n = (STEPnode *) n -> NextNode(); - if(n) { + while( n ) { + out << n->STEPwrite( s, currSch ); + n = ( STEPnode * ) n -> NextNode(); + if( n ) { out << ','; } } @@ -267,21 +257,18 @@ void STEPaggregate::STEPwrite(ostream &out, const char *currSch) const } } -SingleLinkNode *STEPaggregate::NewNode() -{ +SingleLinkNode * STEPaggregate::NewNode() { cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPaggregate::NewNode \n" << _POC_ << "\n"; return 0; } -void STEPaggregate::AddNode(SingleLinkNode *n) -{ - SingleLinkList::AppendNode(n); +void STEPaggregate::AddNode( SingleLinkNode * n ) { + SingleLinkList::AppendNode( n ); _null = false; } -void STEPaggregate::Empty() -{ +void STEPaggregate::Empty() { SingleLinkList::Empty(); _null = true; } @@ -291,38 +278,35 @@ void STEPaggregate::Empty() // STEPnode /////////////////////////////////////////////////////////////////////////////// -Severity STEPnode::StrToVal(const char *s, ErrorDescriptor *err) -{ +Severity STEPnode::StrToVal( const char * s, ErrorDescriptor * err ) { // defined in subtypes (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg("Aggr. attr value: '\n"); - err->AppendToDetailMsg("not assigned.\n"); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( "Aggr. attr value: '\n" ); + err->AppendToDetailMsg( "not assigned.\n" ); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::StrToVal(istream &in, ErrorDescriptor *err) -{ +Severity STEPnode::StrToVal( istream & in, ErrorDescriptor * err ) { // defined in subtypes (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; err->AppendToDetailMsg( " function: STEPnode::StrToVal() called instead of virtual function.\n" ); - err->AppendToDetailMsg("Aggr. attr value: '\n"); - err->AppendToDetailMsg("not assigned.\n"); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( "Aggr. attr value: '\n" ); + err->AppendToDetailMsg( "not assigned.\n" ); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::STEPread(const char *s, ErrorDescriptor *err) -{ +Severity STEPnode::STEPread( const char * s, ErrorDescriptor * err ) { // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -332,14 +316,13 @@ Severity STEPnode::STEPread(const char *s, ErrorDescriptor *err) err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -Severity STEPnode::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity STEPnode::STEPread( istream & in, ErrorDescriptor * err ) { (void) in; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPread called instead of virtual function.\n" @@ -348,13 +331,12 @@ Severity STEPnode::STEPread(istream &in, ErrorDescriptor *err) err->AppendToDetailMsg( " function: STEPnode::STEPread() called instead of virtual function.\n" ); - err->AppendToDetailMsg(_POC_); - err->GreaterSeverity(SEVERITY_BUG); + err->AppendToDetailMsg( _POC_ ); + err->GreaterSeverity( SEVERITY_BUG ); return SEVERITY_BUG; } -const char *STEPnode::asStr(std::string &s) -{ +const char * STEPnode::asStr( std::string & s ) { // defined in subclasses (void) s; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -379,8 +361,7 @@ const char *STEPnode::asStr(std::string &s) * selects. But since currently (3/27/97) the SCL handles 2D+ aggrs using * SCLundefined's, this is not implemented.) */ -const char *STEPnode::STEPwrite(std::string &s, const char *currSch) -{ +const char * STEPnode::STEPwrite( std::string & s, const char * currSch ) { (void) s; //unused (void) currSch; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; @@ -389,8 +370,7 @@ const char *STEPnode::STEPwrite(std::string &s, const char *currSch) return ""; } -void STEPnode::STEPwrite(ostream &out) -{ +void STEPnode::STEPwrite( ostream & out ) { (void) out; //unused cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n" ; cerr << "function: STEPnode::STEPwrite called instead of virtual function.\n" diff --git a/src/clstepcore/STEPaggregate.h b/src/clstepcore/STEPaggregate.h index c3882064c..df2178ee9 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/src/clstepcore/STEPaggregate.h @@ -30,90 +30,85 @@ extern STEPaggregate NilSTEPaggregate; class SingleLinkNode; -typedef STEPaggregate *STEPaggregateH; -typedef STEPaggregate *STEPaggregate_ptr; +typedef STEPaggregate * STEPaggregateH; +typedef STEPaggregate * STEPaggregate_ptr; typedef STEPaggregate_ptr STEPaggregate_var; -class SC_CORE_EXPORT STEPaggregate : public SingleLinkList -{ +class SC_CORE_EXPORT STEPaggregate : public SingleLinkList { protected: bool _null; protected: - virtual Severity ReadValue(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type, - InstMgrBase *insts, int addFileId = 0, - int assignVal = 1, int ExchangeFileFormat = 1, - const char *currSch = 0); + virtual Severity ReadValue( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type, + InstMgrBase * insts, int addFileId = 0, + int assignVal = 1, int ExchangeFileFormat = 1, + const char * currSch = 0 ); public: - bool is_null() - { + bool is_null() { return _null; } - virtual Severity AggrValidLevel(const char *value, ErrorDescriptor *err, - const TypeDescriptor *elem_type, InstMgrBase *insts, - int optional, char *tokenList, int addFileId = 0, - int clearError = 0); + virtual Severity AggrValidLevel( const char * value, ErrorDescriptor * err, + 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, InstMgrBase *insts, - int optional, char *tokenList, int addFileId = 0, - int clearError = 0); + virtual Severity AggrValidLevel( istream & in, ErrorDescriptor * err, + 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, - InstMgrBase *insts = 0, int addFileId = 0); - virtual Severity STEPread(istream &in, ErrorDescriptor *err, - const TypeDescriptor *elem_type = 0, - InstMgrBase *insts = 0, int addFileId = 0, - const char *currSch = 0); + virtual Severity StrToVal( const char * s, ErrorDescriptor * err = 0, + const TypeDescriptor * elem_type = 0, + InstMgrBase * insts = 0, int addFileId = 0 ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err, + const TypeDescriptor * elem_type = 0, + InstMgrBase * insts = 0, int addFileId = 0, + const char * currSch = 0 ); // OUTPUT - virtual const char *asStr(std::string &s) const; - virtual void STEPwrite(ostream &out = cout, const char * = 0) const; + virtual const char * asStr( std::string & s ) const; + virtual void STEPwrite( ostream & out = cout, const char * = 0 ) const; - virtual SingleLinkNode *NewNode(); - void AddNode(SingleLinkNode *); + virtual SingleLinkNode * NewNode(); + void AddNode( SingleLinkNode * ); void Empty(); STEPaggregate(); virtual ~STEPaggregate(); // COPY - defined in subtypes - virtual STEPaggregate &ShallowCopy(const STEPaggregate &); + virtual STEPaggregate & ShallowCopy( const STEPaggregate & ); }; -class SC_CORE_EXPORT STEPnode : public SingleLinkNode -{ - protected: - int _null; - - public: - int is_null() - { - return _null; - } - void set_null() - { - _null = 1; - } - - // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); - - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); - - // OUTPUT - virtual const char *asStr(std::string &s); - virtual const char *STEPwrite(std::string &s, const char * = 0); - virtual void STEPwrite(ostream &out = cout); +class SC_CORE_EXPORT STEPnode : public SingleLinkNode { +protected: + int _null; + +public: + int is_null() { + return _null; + } + void set_null() { + _null = 1; + } + + // INPUT + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); + + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); + + // OUTPUT + virtual const char * asStr( std::string & s ); + virtual const char * STEPwrite( std::string & s, const char * = 0 ); + virtual void STEPwrite( ostream & out = cout ); }; -typedef STEPnode *STEPnodeH; +typedef STEPnode * STEPnodeH; #include "STEPaggrGeneric.h" #include "STEPaggrEntity.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 4509fdf9a..251beb445 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -39,10 +39,9 @@ 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, InstMgrBase *instances, int addFileId) -{ - if(_redefAttr) { - return _redefAttr->StrToVal(s, instances, addFileId); +Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int addFileId ) { + if( _redefAttr ) { + return _redefAttr->StrToVal( s, instances, addFileId ); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -50,97 +49,97 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF // set the value to be null (reinitialize the attribute value) set_null(); - int nullable = (aDesc->Optional().asInt() == BTrue); + int nullable = ( aDesc->Optional().asInt() == BTrue ); // an empty str gets assigned NULL - if(!s) { - if(nullable || IsDerived()) { // if it is derived it doesn't + if( !s ) { + if( nullable || IsDerived() ) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity(SEVERITY_INCOMPLETE); + _error.severity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } - if(s[0] == '\0') { - if(NonRefType() == STRING_TYPE) { + if( s[0] == '\0' ) { + if( NonRefType() == STRING_TYPE ) { // this is interpreted as a string with no value i.e. "". - *(ptr.S) = s; // using string class - don't need to declare space + *( ptr.S ) = s; // using string class - don't need to declare space return SEVERITY_NULL; } - if(nullable || IsDerived()) { // if it is derived it doesn't + if( nullable || IsDerived() ) { // if it is derived it doesn't return SEVERITY_NULL; // matter if it is null DAS } else { - _error.severity(SEVERITY_INCOMPLETE); + _error.severity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if(IsDerived()) { // check to see if value contains: optional space, + if( IsDerived() ) { // check to see if value contains: optional space, // followed by *, followed by optional space - const char *tmpSptr = s; - while(isspace(*tmpSptr)) { + const char * tmpSptr = s; + while( isspace( *tmpSptr ) ) { tmpSptr++; } - if(*tmpSptr == '*') { + if( *tmpSptr == '*' ) { tmpSptr++; char tmpC; - int charsFound = sscanf(tmpSptr, "%c", &tmpC); - if(charsFound == EOF) { // no non-white chars followed the * + int charsFound = sscanf( tmpSptr, "%c", &tmpC ); + if( charsFound == EOF ) { // no non-white chars followed the * return SEVERITY_NULL; } } _error.AppendToDetailMsg( - "Derived attribute must have \'*\' for its value.\n"); - return _error.severity(SEVERITY_INPUT_ERROR); + "Derived attribute must have \'*\' for its value.\n" ); + return _error.severity( SEVERITY_INPUT_ERROR ); } - istringstream in((char *)s); // sz defaults to length of s + istringstream in( ( char * )s ); // sz defaults to length of s // read in value for attribute - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: { - ReadInteger(*(ptr.i), s, &_error, 0); + ReadInteger( *( ptr.i ), s, &_error, 0 ); break; } case REAL_TYPE: { - ReadReal(*(ptr.r), s, &_error, 0); + ReadReal( *( ptr.r ), s, &_error, 0 ); break; } case NUMBER_TYPE: { - ReadNumber(*(ptr.r), s, &_error, 0); + ReadNumber( *( ptr.r ), s, &_error, 0 ); break; } case ENTITY_TYPE: { - STEPentity *se = ReadEntityRef(s, &_error, 0, instances, addFileId); - if(se != S_ENTITY_NULL) { - if(EntityValidLevel(se, aDesc->NonRefTypeDescriptor(), - &_error) - == SEVERITY_NULL) { - *(ptr.c) = se; + STEPentity * se = ReadEntityRef( s, &_error, 0, instances, addFileId ); + if( se != S_ENTITY_NULL ) { + if( EntityValidLevel( se, aDesc->NonRefTypeDescriptor(), + &_error ) + == SEVERITY_NULL ) { + *( ptr.c ) = se; } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } break; } case BINARY_TYPE: { - ptr.b->StrToVal(s, &_error); // call class SDAI_Binary::StrToVal() + ptr.b->StrToVal( s, &_error ); // call class SDAI_Binary::StrToVal() break; } case STRING_TYPE: { - *(ptr.S) = s; // using string class - don't need to declare space + *( ptr.S ) = s; // using string class - don't need to declare space break; } case BOOLEAN_TYPE: case LOGICAL_TYPE: case ENUM_TYPE: { - ptr.e->StrToVal(s, &_error, nullable); + ptr.e->StrToVal( s, &_error, nullable ); break; } @@ -149,15 +148,15 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> StrToVal(s, &_error, - aDesc -> AggrElemTypeDescriptor(), - instances, addFileId); + ptr.a -> StrToVal( s, &_error, + aDesc -> AggrElemTypeDescriptor(), + instances, addFileId ); break; case SELECT_TYPE: - if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0)) - != SEVERITY_NULL) { - _error.AppendToDetailMsg(ptr.sh ->Error()); + if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0 ) ) + != SEVERITY_NULL ) { + _error.AppendToDetailMsg( ptr.sh ->Error() ); } break; @@ -165,7 +164,7 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF case GENERIC_TYPE: default: // other cases are the same for StrToVal and file - return STEPread(in, instances, addFileId); + return STEPread( in, instances, addFileId ); } return _error.severity(); } @@ -188,14 +187,13 @@ Severity STEPattribute::StrToVal(const char *s, InstMgrBase *instances, int addF ** value >= SEVERITY_WARNING means program can continue parsing input, ** value <= SEVERITY_INPUT_ERROR is fatal read error ******************************************************************/ -Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFileId, - const char *currSch, bool strict) -{ +Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int addFileId, + const char * currSch, bool strict ) { // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->STEPread(in, instances, addFileId, currSch); + if( _redefAttr ) { + return _redefAttr->STEPread( in, instances, addFileId, currSch ); } _error.ClearErrorMsg(); // also sets Severity to SEVERITY_NULL @@ -206,119 +204,119 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil in >> ws; // skip whitespace char c = in.peek(); - if(IsDerived()) { - if(c == '*') { - in.get(c); // take * off the istream - _error.severity(SEVERITY_NULL); + if( IsDerived() ) { + if( c == '*' ) { + in.get( c ); // take * off the istream + _error.severity( SEVERITY_NULL ); } else { - _error.severity(SEVERITY_WARNING); - _error.AppendToDetailMsg(" WARNING: attribute '"); - _error.AppendToDetailMsg(aDesc->Name()); - _error.AppendToDetailMsg("' of type '"); - _error.AppendToDetailMsg(aDesc->TypeName()); - _error.AppendToDetailMsg("' - missing asterisk for derived attribute.\n"); + _error.severity( SEVERITY_WARNING ); + _error.AppendToDetailMsg( " WARNING: attribute '" ); + _error.AppendToDetailMsg( aDesc->Name() ); + _error.AppendToDetailMsg( "' of type '" ); + _error.AppendToDetailMsg( aDesc->TypeName() ); + _error.AppendToDetailMsg( "' - missing asterisk for derived attribute.\n" ); } - CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); + CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); return _error.severity(); } PrimitiveType attrBaseType = NonRefType(); // check for NULL or derived attribute value, return if either - switch(c) { + switch( c ) { case '$': case ',': case ')': - if(c == '$') { + if( c == '$' ) { in.ignore(); - CheckRemainingInput(in, &_error, aDesc->TypeName(), ",)"); + CheckRemainingInput( in, &_error, aDesc->TypeName(), ",)" ); } - if(Nullable()) { - _error.severity(SEVERITY_NULL); - } else if(!strict) { + if( Nullable() ) { + _error.severity( SEVERITY_NULL ); + } else if( !strict ) { std::string fillerValue; // we aren't in strict mode, so find out the type of the missing attribute and insert a suitable value. ErrorDescriptor err; //this will be discarded - switch(attrBaseType) { + switch( attrBaseType ) { case INTEGER_TYPE: { fillerValue = "'0',"; - ReadInteger(*(ptr.i), fillerValue.c_str(), &err, ",)"); + ReadInteger( *( ptr.i ), fillerValue.c_str(), &err, ",)" ); break; } case REAL_TYPE: { fillerValue = "'0.0',"; - ReadReal(*(ptr.r), fillerValue.c_str(), &err, ",)"); + ReadReal( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); break; } case NUMBER_TYPE: { fillerValue = "'0',"; - ReadNumber(*(ptr.r), fillerValue.c_str(), &err, ",)"); + ReadNumber( *( ptr.r ), fillerValue.c_str(), &err, ",)" ); break; } case STRING_TYPE: { fillerValue = "'',"; - *(ptr.S) = "''"; + *( ptr.S ) = "''"; break; } default: { //do not know what a good value would be for other types - _error.severity(SEVERITY_INCOMPLETE); - _error.AppendToDetailMsg(" missing and required\n"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.AppendToDetailMsg( " missing and required\n" ); return _error.severity(); } } - if(err.severity() <= SEVERITY_INCOMPLETE) { - _error.severity(SEVERITY_BUG); - _error.AppendToDetailMsg(" Error in STEPattribute::STEPread()\n"); + if( err.severity() <= SEVERITY_INCOMPLETE ) { + _error.severity( SEVERITY_BUG ); + _error.AppendToDetailMsg( " Error in STEPattribute::STEPread()\n" ); return _error.severity(); } //create a warning. SEVERITY_WARNING makes more sense to me, but is considered more severe than SEVERITY_INCOMPLETE - _error.severity(SEVERITY_USERMSG); - _error.AppendToDetailMsg(" missing and required. For compatibility, replacing with "); - _error.AppendToDetailMsg(fillerValue.substr(0, fillerValue.length() - 1)); - _error.AppendToDetailMsg(".\n"); + _error.severity( SEVERITY_USERMSG ); + _error.AppendToDetailMsg( " missing and required. For compatibility, replacing with " ); + _error.AppendToDetailMsg( fillerValue.substr( 0, fillerValue.length() - 1 ) ); + _error.AppendToDetailMsg( ".\n" ); } else { - _error.severity(SEVERITY_INCOMPLETE); - _error.AppendToDetailMsg(" missing and required\n"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.AppendToDetailMsg( " missing and required\n" ); } return _error.severity(); } - switch(attrBaseType) { + switch( attrBaseType ) { case INTEGER_TYPE: { - ReadInteger(*(ptr.i), in, &_error, ",)"); + ReadInteger( *( ptr.i ), in, &_error, ",)" ); return _error.severity(); } case REAL_TYPE: { - ReadReal(*(ptr.r), in, &_error, ",)"); + ReadReal( *( ptr.r ), in, &_error, ",)" ); return _error.severity(); } case NUMBER_TYPE: { - ReadNumber(*(ptr.r), in, &_error, ",)"); + ReadNumber( *( ptr.r ), in, &_error, ",)" ); return _error.severity(); } case STRING_TYPE: { - ptr.S->STEPread(in, &_error); - CheckRemainingInput(in, &_error, "string", ",)"); + ptr.S->STEPread( in, &_error ); + CheckRemainingInput( in, &_error, "string", ",)" ); return _error.severity(); } case BINARY_TYPE: { // call class SDAI_Binary::STEPread() - ptr.b->STEPread(in, &_error); - CheckRemainingInput(in, &_error, "binary", ",)"); + ptr.b->STEPread( in, &_error ); + CheckRemainingInput( in, &_error, "binary", ",)" ); return _error.severity(); } case BOOLEAN_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "boolean", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "boolean", ",)" ); return _error.severity(); } case LOGICAL_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "logical", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "logical", ",)" ); return _error.severity(); } case ENUM_TYPE: { - ptr.e->STEPread(in, &_error, Nullable()); - CheckRemainingInput(in, &_error, "enumeration", ",)"); + ptr.e->STEPread( in, &_error, Nullable() ); + CheckRemainingInput( in, &_error, "enumeration", ",)" ); return _error.severity(); } case AGGREGATE_TYPE: @@ -326,49 +324,49 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - ptr.a->STEPread(in, &_error, - aDesc->AggrElemTypeDescriptor(), - instances, addFileId, currSch); + ptr.a->STEPread( in, &_error, + aDesc->AggrElemTypeDescriptor(), + instances, addFileId, currSch ); // cannot recover so give up and let STEPentity recover - if(_error.severity() < SEVERITY_WARNING) { + if( _error.severity() < SEVERITY_WARNING ) { return _error.severity(); } // check for garbage following the aggregate - CheckRemainingInput(in, &_error, "aggregate", ",)"); + CheckRemainingInput( in, &_error, "aggregate", ",)" ); return _error.severity(); } case ENTITY_TYPE: { - STEPentity *se = ReadEntityRef(in, &_error, ",)", instances, - addFileId); - if(se != S_ENTITY_NULL) { - if(EntityValidLevel(se, - aDesc->NonRefTypeDescriptor(), - &_error) == SEVERITY_NULL) { - *(ptr.c) = se; + STEPentity * se = ReadEntityRef( in, &_error, ",)", instances, + addFileId ); + if( se != S_ENTITY_NULL ) { + if( EntityValidLevel( se, + aDesc->NonRefTypeDescriptor(), + &_error ) == SEVERITY_NULL ) { + *( ptr.c ) = se; } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } } else { - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; } return _error.severity(); } case SELECT_TYPE: - if(_error.severity(ptr.sh->STEPread(in, &_error, instances, 0, - addFileId, currSch)) - != SEVERITY_NULL) { - _error.AppendToDetailMsg(ptr.sh ->Error()); + if( _error.severity( ptr.sh->STEPread( in, &_error, instances, 0, + addFileId, currSch ) ) + != SEVERITY_NULL ) { + _error.AppendToDetailMsg( ptr.sh ->Error() ); } - CheckRemainingInput(in, &_error, "select", ",)"); + CheckRemainingInput( in, &_error, "select", ",)" ); return _error.severity(); case GENERIC_TYPE: { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return _error.severity(); } @@ -378,7 +376,7 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil // bug cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return _error.severity(); } } @@ -390,155 +388,59 @@ Severity STEPattribute::STEPread(istream &in, InstMgrBase *instances, int addFil ** \returns the value of the attribute ** Status: complete 3/91 *********************************************************************/ -const char *STEPattribute::asStr(std::string &str, const char *currSch) const -{ - ostringstream ss; - - str.clear(); - - // The attribute has been derived by a subtype's attribute - if(IsDerived()) { - str = "*"; - return const_cast(str.c_str()); - } - - // The attribute has been redefined by the attribute pointed - // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->asStr(str, currSch); - } - - if(is_null()) { - str = ""; - return const_cast(str.c_str()); - } - - switch(NonRefType()) { - case INTEGER_TYPE: - ss << *(ptr.i); - str += ss.str(); - break; - - case NUMBER_TYPE: - case REAL_TYPE: - - ss.precision((int) Real_Num_Precision); - ss << *(ptr.r); - str += ss.str(); - break; - - case ENTITY_TYPE: - // print instance id only if not empty pointer - // and has value assigned - if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { - break; - } else { - (*(ptr.c))->STEPwrite_reference(str); - } - break; - - case BINARY_TYPE: - if(!((ptr.b)->empty())) { - (ptr.b) -> STEPwrite(str); - } - break; - - case STRING_TYPE: - if(!((ptr.S)->empty())) { - return (ptr.S) -> asStr(str); - } - break; - - case AGGREGATE_TYPE: - case ARRAY_TYPE: // DAS - case BAG_TYPE: // DAS - case SET_TYPE: // DAS - case LIST_TYPE: // DAS - return ptr.a->asStr(str) ; - - case ENUM_TYPE: - case BOOLEAN_TYPE: - case LOGICAL_TYPE: - return ptr.e -> asStr(str); - - case SELECT_TYPE: - ptr.sh -> STEPwrite(str, currSch); - return const_cast(str.c_str()); - - case REFERENCE_TYPE: - case GENERIC_TYPE: - cerr << "Internal error: " << __FILE__ << __LINE__ - << "\n" << _POC_ "\n"; - return 0; - - case UNKNOWN_TYPE: - default: - return (ptr.u -> asStr(str)); - } - return const_cast(str.c_str()); -} - - -/*****************************************************************//** - ** \fn asStr - ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). - ** \returns the value of the attribute - ** Status: complete 3/91 - *********************************************************************/ -std::string STEPattribute::asStr(const char *currSch) const -{ +std::string STEPattribute::asStr( const char * currSch ) const { ostringstream ss; std::string str; // The attribute has been derived by a subtype's attribute - if(IsDerived()) { + if( IsDerived() ) { str = "*"; return str; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - return _redefAttr->asStr(currSch); + if( _redefAttr ) { + return _redefAttr->asStr( currSch ); } - if(is_null()) { + if( is_null() ) { return str; } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - ss << *(ptr.i); + ss << *( ptr.i ); str += ss.str(); break; case NUMBER_TYPE: case REAL_TYPE: - ss.precision((int) Real_Num_Precision); - ss << *(ptr.r); + ss.precision( ( int ) Real_Num_Precision ); + ss << *( ptr.r ); str += ss.str(); break; case ENTITY_TYPE: // print instance id only if not empty pointer // and has value assigned - if((*(ptr.c) == S_ENTITY_NULL) || (*(ptr.c) == 0)) { + if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { break; } else { - (*(ptr.c))->STEPwrite_reference(str); + ( *( ptr.c ) )->STEPwrite_reference( str ); } break; case BINARY_TYPE: - if(!(ptr.b->empty())) { - ptr.b->STEPwrite(str); + if( !( ptr.b->empty() ) ) { + ptr.b->STEPwrite( str ); } break; case STRING_TYPE: - if(!((ptr.S)->empty())) { - ptr.S->asStr(str); + if( !( ( ptr.S )->empty() ) ) { + ptr.S->asStr( str ); } break; @@ -547,17 +449,17 @@ std::string STEPattribute::asStr(const char *currSch) const case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a->asStr(str); + ptr.a->asStr( str ); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - ptr.e->asStr(str); + ptr.e->asStr( str ); break; case SELECT_TYPE: - ptr.sh->STEPwrite(str, currSch); + ptr.sh->STEPwrite( str, currSch ); break; case REFERENCE_TYPE: @@ -569,22 +471,21 @@ std::string STEPattribute::asStr(const char *currSch) const case UNKNOWN_TYPE: default: - ptr.u->asStr(str); + ptr.u->asStr( str ); } return str; } /// write '$' to out, put message in error, write brief error to stderr -void STEPattribute::STEPwriteError(ostream &out, unsigned int line, const char *desc) -{ +void STEPattribute::STEPwriteError( ostream & out, unsigned int line, const char* desc ) { out << "$"; cerr << "Internal error: " << __FILE__ << ":" << line << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); std::stringstream ss; ss << " Warning: attribute '" << Name() << " : " << TypeName() << "' " << desc << std::endl; - _error.AppendToUserMsg(ss.str()); - _error.AppendToDetailMsg(ss.str()); + _error.AppendToUserMsg( ss.str() ); + _error.AppendToDetailMsg( ss.str() ); } /** @@ -592,62 +493,61 @@ void STEPattribute::STEPwriteError(ostream &out, unsigned int line, const char * * The output is in physical file format. * */ -void STEPattribute::STEPwrite(ostream &out, const char *currSch) -{ +void STEPattribute::STEPwrite( ostream & out, const char * currSch ) { // The attribute has been derived by a subtype's attribute - if(IsDerived()) { + if( IsDerived() ) { out << "*"; return; } // The attribute has been redefined by the attribute pointed // to by _redefAttr so write the redefined value. - if(_redefAttr) { - _redefAttr->STEPwrite(out); + if( _redefAttr ) { + _redefAttr->STEPwrite( out ); return; } - if(is_null()) { + if( is_null() ) { out << "$"; return; } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - out << *(ptr.i); + out << *( ptr.i ); break; case NUMBER_TYPE: case REAL_TYPE: { - WriteReal(*(ptr.r), out); + WriteReal( *( ptr.r ), out ); break; } case ENTITY_TYPE: // print instance id only if not empty pointer - if((ptr.c == 0) || (*(ptr.c) == 0) || + if( ( ptr.c == 0 ) || ( *( ptr.c ) == 0 ) || // no value was assigned <-- this would be a BUG - (*(ptr.c) == S_ENTITY_NULL)) { - STEPwriteError(out, __LINE__, "is null and shouldn't be."); + ( *( ptr.c ) == S_ENTITY_NULL ) ) { + STEPwriteError( out, __LINE__, "is null and shouldn't be." ); } else { - (*(ptr.c)) -> STEPwrite_reference(out); + ( *( ptr.c ) ) -> STEPwrite_reference( out ); } break; case STRING_TYPE: // if null pointer or pointer to a string of length zero - if(ptr.S) { - (ptr.S) -> STEPwrite(out); + if( ptr.S ) { + ( ptr.S ) -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at an SDAI_String."); + STEPwriteError( out, __LINE__, "should be pointing at an SDAI_String." ); } break; case BINARY_TYPE: // if null pointer or pointer to a string of length zero - if(ptr.b) { - (ptr.b) -> STEPwrite(out); + if( ptr.b ) { + ( ptr.b ) -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at an SDAI_Binary."); + STEPwriteError( out, __LINE__, "should be pointing at an SDAI_Binary." ); } break; @@ -656,54 +556,53 @@ void STEPattribute::STEPwrite(ostream &out, const char *currSch) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - ptr.a -> STEPwrite(out, currSch); + ptr.a -> STEPwrite( out, currSch ); break; case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - if(ptr.e) { - ptr.e -> STEPwrite(out); + if( ptr.e ) { + ptr.e -> STEPwrite( out ); } else { - STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Enum class."); + STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Enum class." ); } break; case SELECT_TYPE: - if(ptr.sh) { - ptr.sh -> STEPwrite(out, currSch); + if( ptr.sh ) { + ptr.sh -> STEPwrite( out, currSch ); } else { - STEPwriteError(out, __LINE__, "should be pointing at a SDAI_Select class."); + STEPwriteError( out, __LINE__, "should be pointing at a SDAI_Select class." ); } break; case REFERENCE_TYPE: case GENERIC_TYPE: cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; - _error.GreaterSeverity(SEVERITY_BUG); + _error.GreaterSeverity( SEVERITY_BUG ); return; case UNKNOWN_TYPE: default: - ptr.u -> STEPwrite(out); + ptr.u -> STEPwrite( out ); break; } } -void STEPattribute::ShallowCopy(const STEPattribute *sa) -{ +void STEPattribute::ShallowCopy( const STEPattribute * sa ) { _mustDeletePtr = false; aDesc = sa->aDesc; refCount = 0; _derive = sa->_derive; _redefAttr = sa->_redefAttr; - if(_redefAttr) { - _redefAttr->ShallowCopy(sa); + if( _redefAttr ) { + _redefAttr->ShallowCopy( sa ); } //Should we just use memcpy()? That would be a true shallowCopy - switch(sa->NonRefType()) { + switch( sa->NonRefType() ) { case INTEGER_TYPE: ptr.i = sa->ptr.i; break; @@ -724,7 +623,7 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - switch(sa->BaseType()) { + switch( sa->BaseType() ) { case sdaiAGGR: ptr.a = new GenericAggregate; break; @@ -758,11 +657,11 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) break; default: std::cerr << "WARNING: Reached default case for BaseType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; + << "ShallowCopy(). New attribute may be invalid." << std::endl; ptr.a = new STEPaggregate; break; } - ptr.a->ShallowCopy(*(sa->ptr.a)); + ptr.a->ShallowCopy( *( sa->ptr.a ) ); _mustDeletePtr = true; break; case SELECT_TYPE: @@ -770,12 +669,12 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) break; case BOOLEAN_TYPE: ptr.e = new SDAI_BOOLEAN; - ptr.e->put(sa->ptr.e->asInt()); + ptr.e->put( sa->ptr.e->asInt() ); _mustDeletePtr = true; break; case LOGICAL_TYPE: ptr.e = new SDAI_LOGICAL; - ptr.e->put(sa->ptr.e->asInt()); + ptr.e->put( sa->ptr.e->asInt() ); _mustDeletePtr = true; break; @@ -783,8 +682,8 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) case ENUM_TYPE: default: std::cerr << "WARNING: Reached default case for NonRefType() in STEPattribute::" - << "ShallowCopy(). New attribute may be invalid." << std::endl; - memcpy(& ptr, & (sa->ptr), sizeof(sa->ptr)); + << "ShallowCopy(). New attribute may be invalid." << std::endl; + memcpy( & ptr, & ( sa->ptr ), sizeof( sa->ptr ) ); break; } } @@ -794,26 +693,25 @@ void STEPattribute::ShallowCopy(const STEPattribute *sa) * will exist in member variable ptr but SDAI_string will be told to report * as not containing a value (even a value of no chars). */ -Severity STEPattribute::set_null() -{ - if(_redefAttr) { +Severity STEPattribute::set_null() { + if( _redefAttr ) { return _redefAttr->set_null(); } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - *(ptr.i) = S_INT_NULL; + *( ptr.i ) = S_INT_NULL; break; case NUMBER_TYPE: - *(ptr.r) = S_NUMBER_NULL; + *( ptr.r ) = S_NUMBER_NULL; break; case REAL_TYPE: - *(ptr.r) = S_REAL_NULL; + *( ptr.r ) = S_REAL_NULL; break; case ENTITY_TYPE: - *(ptr.c) = S_ENTITY_NULL; + *( ptr.c ) = S_ENTITY_NULL; break; case STRING_TYPE: @@ -854,11 +752,11 @@ Severity STEPattribute::set_null() 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); + _error.AppendToDetailMsg( err.str() ); + _error.GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } - if(Nullable()) { + if( Nullable() ) { return SEVERITY_NULL; } else { return SEVERITY_INCOMPLETE; @@ -869,32 +767,31 @@ Severity STEPattribute::set_null() * For a string value this reports whether the string exists (as reported by * SDAI_String ) not whether SDAI_String contains a null string. */ -bool STEPattribute::is_null() const -{ - if(_redefAttr) { +bool STEPattribute::is_null() const { + if( _redefAttr ) { return _redefAttr->is_null(); } /* for NUMBER_TYPE and REAL_TYPE, we want an exact comparison. however, doing so causes a compiler warning. * workaround is to use memcmp. need a variable, but can't declare it within the switch without errors. */ SDAI_Real z; - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - return (*(ptr.i) == S_INT_NULL); + return ( *( ptr.i ) == S_INT_NULL ); case NUMBER_TYPE: z = S_NUMBER_NULL; - return (0 == memcmp(ptr.r, &z, sizeof z)); + return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); case REAL_TYPE: z = S_REAL_NULL; - return (0 == memcmp(ptr.r, &z, sizeof z)); + return ( 0 == memcmp( ptr.r, &z, sizeof z ) ); case ENTITY_TYPE: - return (*(ptr.c) == S_ENTITY_NULL); + return ( *( ptr.c ) == S_ENTITY_NULL ); case STRING_TYPE: - return (*(ptr.S) == S_STRING_NULL); + return ( *( ptr.S ) == S_STRING_NULL ); case BINARY_TYPE: return ptr.b->empty(); @@ -904,16 +801,16 @@ bool STEPattribute::is_null() const case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return (ptr.a -> is_null()); + return ( ptr.a -> is_null() ); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return (ptr.e -> is_null()); + return ( ptr.e -> is_null() ); case SELECT_TYPE: - return(ptr.sh->is_null()); + return( ptr.sh->is_null() ); case REFERENCE_TYPE: case GENERIC_TYPE: @@ -921,104 +818,92 @@ bool STEPattribute::is_null() const return true; case UNKNOWN_TYPE: default: - return (ptr.u -> is_null()); + return ( ptr.u -> is_null() ); } } // these get the attr value -SDAI_Integer *STEPattribute::Integer() -{ - if(NonRefType() == INTEGER_TYPE) { +SDAI_Integer * STEPattribute::Integer(){ + if( NonRefType() == INTEGER_TYPE ) { return ptr.i; } return 0; } -SDAI_Real *STEPattribute::Number() -{ - if(NonRefType() == NUMBER_TYPE) { +SDAI_Real * STEPattribute::Number() { + if( NonRefType() == NUMBER_TYPE ) { return ptr.r; } return 0; } -SDAI_Real *STEPattribute::Real() -{ - if(NonRefType() == REAL_TYPE) { +SDAI_Real * STEPattribute::Real() { + if( NonRefType() == REAL_TYPE ) { return ptr.r; } return 0; } -SDAI_Application_instance *STEPattribute::Entity() -{ - if(NonRefType() == ENTITY_TYPE) { - return *(ptr.c); +SDAI_Application_instance * STEPattribute::Entity() { + if( NonRefType() == ENTITY_TYPE ) { + return *( ptr.c ); } return 0; } -SDAI_String *STEPattribute::String() -{ - if(NonRefType() == STRING_TYPE) { +SDAI_String * STEPattribute::String() { + if( NonRefType() == STRING_TYPE ) { return ptr.S; } return 0; } -SDAI_Binary *STEPattribute::Binary() -{ - if(NonRefType() == BINARY_TYPE) { +SDAI_Binary * STEPattribute::Binary() { + if( NonRefType() == BINARY_TYPE ) { return ptr.b; } return 0; } -STEPaggregate *STEPattribute::Aggregate() -{ - if((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) - || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)) { +STEPaggregate * STEPattribute::Aggregate() { + if( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) + || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ) { return ptr.a; } return 0; } -SDAI_BOOLEAN *STEPattribute::Boolean() -{ - if(NonRefType() == BOOLEAN_TYPE) { - return (SDAI_BOOLEAN *) ptr.e; +SDAI_BOOLEAN * STEPattribute::Boolean() { + if( NonRefType() == BOOLEAN_TYPE ) { + return ( SDAI_BOOLEAN * ) ptr.e; } return 0; } -SDAI_LOGICAL *STEPattribute::Logical() -{ - if(NonRefType() == LOGICAL_TYPE) { - return (SDAI_LOGICAL *) ptr.e; +SDAI_LOGICAL * STEPattribute::Logical() { + if( NonRefType() == LOGICAL_TYPE ) { + return ( SDAI_LOGICAL * ) ptr.e; } return 0; } -SDAI_Enum *STEPattribute::Enum() -{ - if(NonRefType() == ENUM_TYPE) { +SDAI_Enum * STEPattribute::Enum() { + if( NonRefType() == ENUM_TYPE ) { return ptr.e; } return 0; } -SDAI_Select *STEPattribute::Select() -{ - if(NonRefType() == SELECT_TYPE) { +SDAI_Select * STEPattribute::Select() { + if( NonRefType() == SELECT_TYPE ) { return ptr.sh; } return 0; } -SCLundefined *STEPattribute::Undefined() -{ - if((NonRefType() != REFERENCE_TYPE) && (NonRefType() != GENERIC_TYPE)) { +SCLundefined * STEPattribute::Undefined() { + if( ( NonRefType() != REFERENCE_TYPE ) && ( NonRefType() != GENERIC_TYPE ) ) { return ptr.u; } return 0; @@ -1026,127 +911,115 @@ SCLundefined *STEPattribute::Undefined() // these set the attr value -void STEPattribute::Integer(SDAI_Integer *n) -{ - assert(NonRefType() == INTEGER_TYPE); - if(ptr.i) { - *(ptr.i) = * n; +void STEPattribute::Integer( SDAI_Integer * n ) { + assert( NonRefType() == INTEGER_TYPE ); + if( ptr.i ) { + *( ptr.i ) = * n; } else { ptr.i = n; } } -void STEPattribute::Real(SDAI_Real *n) -{ - assert(NonRefType() == REAL_TYPE); - if(ptr.r) { - *(ptr.r) = * n; +void STEPattribute::Real( SDAI_Real * n ) { + assert( NonRefType() == REAL_TYPE ); + if( ptr.r ) { + *( ptr.r ) = * n; } else { ptr.r = n; } } -void STEPattribute::Number(SDAI_Real *n) -{ - assert(NonRefType() == NUMBER_TYPE); - if(ptr.r) { - *(ptr.r) = * n; +void STEPattribute::Number( SDAI_Real * n ) { + assert( NonRefType() == NUMBER_TYPE ); + if( ptr.r ) { + *( ptr.r ) = * n; } else { ptr.r = n; } } -void STEPattribute::String(SDAI_String *str) -{ - assert(NonRefType() == STRING_TYPE); - if(ptr.S) { - *(ptr.S) = * str; +void STEPattribute::String( SDAI_String * str ) { + assert( NonRefType() == STRING_TYPE ); + if( ptr.S ) { + *( ptr.S ) = * str; } else { ptr.S = str; } } -void STEPattribute::Binary(SDAI_Binary *bin) -{ - assert(NonRefType() == BINARY_TYPE); - if(ptr.b) { - *(ptr.b) = * bin; +void STEPattribute::Binary( SDAI_Binary * bin ) { + assert( NonRefType() == BINARY_TYPE ); + if( ptr.b ) { + *( ptr.b ) = * bin; } else { ptr.b = bin; } } -void STEPattribute::Entity(SDAI_Application_instance *ent) -{ - assert(NonRefType() == ENTITY_TYPE); - if(ptr.c) { +void STEPattribute::Entity( SDAI_Application_instance * ent ) { + assert( NonRefType() == ENTITY_TYPE ); + if( ptr.c ) { delete ptr.c; } - ptr.c = new(SDAI_Application_instance *); - *(ptr.c) = ent; + ptr.c = new (SDAI_Application_instance * ); + *( ptr.c ) = ent; } -void STEPattribute::Aggregate(STEPaggregate *aggr) -{ - assert((NonRefType() == AGGREGATE_TYPE) || (NonRefType() == ARRAY_TYPE) || (NonRefType() == BAG_TYPE) - || (NonRefType() == SET_TYPE) || (NonRefType() == LIST_TYPE)); - if(ptr.a) { - *(ptr.a) = * aggr; +void STEPattribute::Aggregate( STEPaggregate * aggr ) { + assert( ( NonRefType() == AGGREGATE_TYPE ) || ( NonRefType() == ARRAY_TYPE ) || ( NonRefType() == BAG_TYPE ) + || ( NonRefType() == SET_TYPE ) || ( NonRefType() == LIST_TYPE ) ); + if( ptr.a ) { + *( ptr.a ) = * aggr; } else { ptr.a = aggr; } } -void STEPattribute::Enum(SDAI_Enum *enu) -{ - assert(NonRefType() == ENUM_TYPE); - if(ptr.e) { +void STEPattribute::Enum( SDAI_Enum * enu ) { + assert( NonRefType() == ENUM_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = * enu; + *( ptr.e ) = * enu; } else { ptr.e = enu; } } -void STEPattribute::Logical(SDAI_LOGICAL *log) -{ - assert(NonRefType() == LOGICAL_TYPE); - if(ptr.e) { +void STEPattribute::Logical( SDAI_LOGICAL * log ) { + assert( NonRefType() == LOGICAL_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = * log; + *( ptr.e ) = * log; } else { ptr.e = log; } } -void STEPattribute::Boolean(SDAI_BOOLEAN *boo) -{ - assert(NonRefType() == BOOLEAN_TYPE); - if(ptr.e) { +void STEPattribute::Boolean( SDAI_BOOLEAN * boo ) { + assert( NonRefType() == BOOLEAN_TYPE ); + if( ptr.e ) { ptr.e->set_null(); - *(ptr.e) = *boo; + *( ptr.e ) = *boo; } else { ptr.e = boo; } } -void STEPattribute::Select(SDAI_Select *sel) -{ - assert(NonRefType() == SELECT_TYPE); - if(ptr.sh) { +void STEPattribute::Select( SDAI_Select * sel ) { + assert( NonRefType() == SELECT_TYPE ); + if( ptr.sh ) { ptr.sh->set_null(); - *(ptr.sh) = * sel; + *( ptr.sh ) = * sel; } else { ptr.sh = sel; } } -void STEPattribute::Undefined(SCLundefined *undef) -{ +void STEPattribute::Undefined( SCLundefined * undef ) { //FIXME is this right, or is the Undefined() above right? - assert(NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE); - if(ptr.u) { - *(ptr.u) = * undef; + assert( NonRefType() == REFERENCE_TYPE || NonRefType() == UNKNOWN_TYPE ); + if( ptr.u ) { + *( ptr.u ) = * undef; } else { ptr.u = undef; } @@ -1157,13 +1030,12 @@ void STEPattribute::Undefined(SCLundefined *undef) * ignores _error and refCount, since those are ancillary * \return true if equal */ -bool operator == (const STEPattribute &a1, const STEPattribute &a2) -{ - if(& a1 == & a2) { +bool operator == ( const STEPattribute & a1, const STEPattribute & a2 ) { + if( & a1 == & a2 ) { return true; } - if(a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr) { - if(0 == memcmp(& a1.ptr, & a2.ptr, sizeof(a1.ptr))) { + if( a1._derive == a2._derive && a1.aDesc == a2.aDesc && a1._redefAttr == a2._redefAttr ){ + if( 0 == memcmp( & a1.ptr, & a2.ptr, sizeof( a1.ptr ) ) ) { return true; } else { //ptr differs between a1 and a2, but contents aren't necessarily different @@ -1177,14 +1049,12 @@ bool operator == (const STEPattribute &a1, const STEPattribute &a2) * ignores _error and refCount, since those are ancillary * \return true if not equal */ -bool operator != (const STEPattribute &a1, const STEPattribute &a2) -{ - return !(a1 == a2); +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) -{ +bool sameADesc( const STEPattribute & a1, const STEPattribute & a2 ) { return a1.aDesc == a2.aDesc; } @@ -1196,85 +1066,84 @@ 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, InstMgrBase *im, bool clearError) -{ - if(clearError) { +Severity STEPattribute::ValidLevel( const char * attrValue, ErrorDescriptor * error, InstMgrBase * im, bool clearError ) { + if( clearError ) { ClearErrorMsg(); } - if(_redefAttr) { - return _redefAttr->ValidLevel(attrValue, error, im, clearError); + if( _redefAttr ) { + return _redefAttr->ValidLevel( attrValue, error, im, clearError ); } bool optional = Nullable(); - if(!attrValue) { - if(optional) { + if( !attrValue ) { + if( optional ) { return error->severity(); } else { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } - if(attrValue[0] == '\0') { - if(NonRefType() == STRING_TYPE) { + if( attrValue[0] == '\0' ) { + if( NonRefType() == STRING_TYPE ) { // this is interpreted as a string with no value i.e. "". // Thus if it exists it has to be valid. return SEVERITY_NULL; } - if(optional) { + if( optional ) { return error->severity(); } else { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return SEVERITY_INCOMPLETE; } } // an overridden attribute always has a \'*\' value - if(IsDerived()) { - if(!strcmp(attrValue, "*")) { + if( IsDerived() ) { + if( !strcmp( attrValue, "*" ) ) { return SEVERITY_NULL; } else { - _error.AppendToDetailMsg("attr is derived - value not permitted\n"); - return _error.severity(SEVERITY_INPUT_ERROR); + _error.AppendToDetailMsg( "attr is derived - value not permitted\n" ); + return _error.severity( SEVERITY_INPUT_ERROR ); } } - switch(NonRefType()) { + switch( NonRefType() ) { case INTEGER_TYPE: - return IntValidLevel(attrValue, error, clearError, optional, 0); + return IntValidLevel( attrValue, error, clearError, optional, 0 ); case STRING_TYPE: // if a value exists (checked above) then that is the string value return SEVERITY_NULL; case REAL_TYPE: - return RealValidLevel(attrValue, error, clearError, optional, 0); + return RealValidLevel( attrValue, error, clearError, optional, 0 ); case NUMBER_TYPE: - return NumberValidLevel(attrValue, error, clearError, optional, 0); + return NumberValidLevel( attrValue, error, clearError, optional, 0 ); case ENTITY_TYPE: - return EntityValidLevel(attrValue, - aDesc->NonRefTypeDescriptor(), - error, im, 0); + return EntityValidLevel( attrValue, + aDesc->NonRefTypeDescriptor(), + error, im, 0 ); case BINARY_TYPE: - return ptr.b->BinaryValidLevel(attrValue, &_error, optional, 0); + return ptr.b->BinaryValidLevel( attrValue, &_error, optional, 0 ); case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - return ptr.a->AggrValidLevel(attrValue, error, - aDesc->AggrElemTypeDescriptor(), im, - optional, 0, 0, 0); + return ptr.a->AggrValidLevel( attrValue, error, + aDesc->AggrElemTypeDescriptor(), im, + optional, 0, 0, 0 ); } case ENUM_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: - return ptr.e->EnumValidLevel(attrValue, error, optional, 0, 0, 1); + return ptr.e->EnumValidLevel( attrValue, error, optional, 0, 0, 1 ); case SELECT_TYPE: - return ptr.sh->SelectValidLevel(attrValue, error, im); + return ptr.sh->SelectValidLevel( attrValue, error, im ); default: cerr << "Internal error: " << __FILE__ << __LINE__ @@ -1288,9 +1157,8 @@ Severity STEPattribute::ValidLevel(const char *attrValue, ErrorDescriptor *error ** \param a -- attribute to output ** Description: overloads the output operator to print an attribute ******************************************************************/ -ostream &operator<< (ostream &out, STEPattribute &a) -{ - a.STEPwrite(out); +ostream & operator<< ( ostream & out, STEPattribute & a ) { + a.STEPwrite( out ); return out; } @@ -1300,23 +1168,22 @@ ostream &operator<< (ostream &out, STEPattribute &a) * Aggregates, and SDAI_Strings which don't know they are a STEPattribute * value. ******************************************************************/ -void STEPattribute::AddErrorInfo() -{ +void STEPattribute::AddErrorInfo() { char errStr[BUFSIZ]; errStr[0] = '\0'; - if(SEVERITY_INPUT_ERROR < _error.severity() && - _error.severity() < SEVERITY_NULL) { - sprintf(errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); - } else if(_error.severity() == SEVERITY_INPUT_ERROR) { - sprintf(errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); - } else if(_error.severity() <= SEVERITY_BUG) { - sprintf(errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type()); - _error.PrependToDetailMsg(errStr); + if( SEVERITY_INPUT_ERROR < _error.severity() && + _error.severity() < SEVERITY_NULL ) { + sprintf( errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); + } else if( _error.severity() == SEVERITY_INPUT_ERROR ) { + sprintf( errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); + } else if( _error.severity() <= SEVERITY_BUG ) { + sprintf( errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", + Name(), TypeName(), Type() ); + _error.PrependToDetailMsg( errStr ); } } @@ -1325,35 +1192,34 @@ void STEPattribute::AddErrorInfo() * if it hits one of StopChars it puts it back. * RETURNS: the last char it read. ******************************************************************/ -char STEPattribute::SkipBadAttr(istream &in, char *StopChars) -{ +char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { ios_base::fmtflags flbuf = in.flags(); - in.unsetf(ios::skipws); // turn skipping whitespace off + in.unsetf( ios::skipws ); // turn skipping whitespace off // read bad data until end of this attribute or entity. - char *foundCh = 0; + char * foundCh = 0; char c = '\0'; char errStr[BUFSIZ]; errStr[0] = '\0'; - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); in >> c; - while(!in.eof() && !(foundCh = strchr(StopChars, c))) { + while( !in.eof() && !( foundCh = strchr( StopChars, c ) ) ) { in >> c; } - if(in.eof()) { - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), - "Unexpected EOF when skipping bad attr value"); - _error.AppendToDetailMsg(errStr); + if( in.eof() ) { + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), + "Unexpected EOF when skipping bad attr value" ); + _error.AppendToDetailMsg( errStr ); } else { - sprintf(errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), "Invalid value"); - _error.AppendToDetailMsg(errStr); + sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", + Name(), TypeName(), Type(), "Invalid value" ); + _error.AppendToDetailMsg( errStr ); } - in.putback(c); - in.flags(flbuf); // set skip whitespace to its original state + in.putback( c ); + in.flags( flbuf ); // set skip whitespace to its original state return c; } @@ -1374,10 +1240,9 @@ char STEPattribute::SkipBadAttr(istream &in, char *StopChars) /// This is needed so that STEPattribute's can be passed as references to inline functions /// NOTE this code only does shallow copies. It may be necessary to do more, in which case /// the destructor and assignment operator will also need examined. -STEPattribute::STEPattribute(const STEPattribute &a) : _derive(a._derive), _mustDeletePtr(false), - _redefAttr(a._redefAttr), aDesc(a.aDesc), refCount(a.refCount) -{ - ShallowCopy(& a); +STEPattribute::STEPattribute( const STEPattribute & a ) : _derive( a._derive ), _mustDeletePtr( false ), +_redefAttr( a._redefAttr ), aDesc( a.aDesc ), refCount( a.refCount ) { + ShallowCopy( & a ); //NOTE may need to do a deep copy for the following types since they are classes /* @@ -1402,106 +1267,95 @@ STEPattribute::STEPattribute(const STEPattribute &a) : _derive(a._derive), _must * * default: * break; - } - */ +} +*/ } /// INTEGER -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.i = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// BINARY -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.b = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// STRING -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_String *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_String * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.S = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// REAL & NUMBER -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Real *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.r = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// ENTITY -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p): - _derive(false), _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance * *p ): +_derive( false ), _mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.c = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// AGGREGATE -STEPattribute::STEPattribute(const class AttrDescriptor &d, STEPaggregate *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.a = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// ENUMERATION and Logical -STEPattribute::STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.e = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// SELECT -STEPattribute::STEPattribute(const class AttrDescriptor &d, class SDAI_Select *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, class SDAI_Select * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.sh = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// UNDEFINED -STEPattribute::STEPattribute(const class AttrDescriptor &d, SCLundefined *p): _derive(false), - _mustDeletePtr(false), _redefAttr(0), aDesc(&d), refCount(0) -{ +STEPattribute::STEPattribute( const class AttrDescriptor & d, SCLundefined * p ): _derive( false ), +_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) { ptr.u = p; - assert(&d); //ensure that the AttrDescriptor is not a null pointer + assert( &d ); //ensure that the AttrDescriptor is not a null pointer } /// the destructor conditionally deletes the object in ptr -STEPattribute::~STEPattribute() -{ - if(_mustDeletePtr) { - switch(NonRefType()) { +STEPattribute::~STEPattribute() { + if( _mustDeletePtr ) { + switch( NonRefType() ) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if(ptr.a) { + if( ptr.a ) { delete ptr.a; ptr.a = 0; } break; case BOOLEAN_TYPE: - if(ptr.e) { - delete(SDAI_BOOLEAN *) ptr.e; + if( ptr.e ) { + delete ( SDAI_BOOLEAN * ) ptr.e; ptr.e = 0; } - break; case LOGICAL_TYPE: - if(ptr.e) { - delete(SDAI_LOGICAL *) ptr.e; + if( ptr.e ) { + delete ( SDAI_LOGICAL * ) ptr.e; ptr.e = 0; } break; @@ -1512,57 +1366,50 @@ STEPattribute::~STEPattribute() } /// name is the same even if redefined -const char *STEPattribute::Name() const -{ +const char * STEPattribute::Name() const { return aDesc->Name(); } -const char *STEPattribute::TypeName() const -{ - if(_redefAttr) { +const char * STEPattribute::TypeName() const { + if( _redefAttr ) { return _redefAttr->TypeName(); } return aDesc->TypeName().c_str(); } -BASE_TYPE STEPattribute::Type() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::Type() const { + if( _redefAttr ) { return _redefAttr->Type(); } return aDesc->Type(); } -BASE_TYPE STEPattribute::NonRefType() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::NonRefType() const { + if( _redefAttr ) { return _redefAttr->NonRefType(); - } else if(aDesc) { + } else if( aDesc ) { return aDesc->NonRefType(); } return UNKNOWN_TYPE; } -BASE_TYPE STEPattribute::BaseType() const -{ - if(_redefAttr) { +BASE_TYPE STEPattribute::BaseType() const { + if( _redefAttr ) { return _redefAttr->BaseType(); } return aDesc->BaseType(); } -const TypeDescriptor *STEPattribute::ReferentType() const -{ - if(_redefAttr) { +const TypeDescriptor * STEPattribute::ReferentType() const { + if( _redefAttr ) { return _redefAttr->ReferentType(); } return aDesc->ReferentType(); } -bool STEPattribute::Nullable() const -{ - if(_redefAttr) { +bool STEPattribute::Nullable() const { + if( _redefAttr ) { return _redefAttr->Nullable(); } - return (aDesc->Optionality().asInt() == LTrue); + return ( aDesc->Optionality().asInt() == LTrue ); } diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 7e80c8edc..e3b43e0b4 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -37,124 +37,110 @@ class EntityDescriptor; #include -extern SC_CORE_EXPORT int SetErrOnNull(const char *attrValue, ErrorDescriptor *error); +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, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ); -extern SC_CORE_EXPORT SDAI_Application_instance *ReadEntityRef(const char *s, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList, + 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) - ErrorDescriptor *err); +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) + ErrorDescriptor * err ); -extern SC_CORE_EXPORT Severity EntityValidLevel(const char *attrValue, ///< string containing entity ref - const TypeDescriptor *ed, /**< entity type that entity in attrValue (if it exists) needs +extern SC_CORE_EXPORT Severity EntityValidLevel( const char * attrValue, ///< string containing entity ref + const TypeDescriptor * ed, /**< entity type that entity in attrValue (if it exists) needs * to match. (this must be an EntityDescriptor) */ - ErrorDescriptor *err, InstMgrBase *im, int clearError); + ErrorDescriptor * err, InstMgrBase * im, int clearError ); //////////////////// //////////////////// -extern SC_CORE_EXPORT SDAI_Application_instance *STEPread_reference(const char *s, ErrorDescriptor *err, - InstMgrBase *instances, int addFileId); +extern SC_CORE_EXPORT SDAI_Application_instance * STEPread_reference( const char * s, ErrorDescriptor * err, + InstMgrBase * instances, int addFileId ); //////////////////// -extern SC_CORE_EXPORT int QuoteInString(istream &in); +extern SC_CORE_EXPORT int QuoteInString( istream & in ); -extern SC_CORE_EXPORT void AppendChar(char c, int &index, char *&s, int &sSize); +extern SC_CORE_EXPORT void AppendChar( char c, int & index, char *& s, int & sSize ); -extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); -class SC_CORE_EXPORT STEPattribute -{ - friend ostream &operator<< (ostream &, STEPattribute &); +class SC_CORE_EXPORT STEPattribute { + friend ostream & operator<< ( ostream &, STEPattribute & ); friend class SDAI_Application_instance; - - public: - /** \union ptr - ** You know which of these to use based on the return value of - ** NonRefType() - see below. BASE_TYPE is defined in baseType.h - ** This variable points to an appropriate member variable in the entity - ** class in the generated schema class library (the entity class is - ** inherited from SDAI_Application_instance) - */ - union attrUnion { - SDAI_String *S; // STRING_TYPE - SDAI_Integer *i; // INTEGER_TYPE (Integer is a long int) - SDAI_Binary *b; // BINARY_TYPE - SDAI_Real *r; // REAL_TYPE and NUMBER_TYPE (Real is a double) - SDAI_Application_instance * *c; // ENTITY_TYPE - STEPaggregate *a; // AGGREGATE_TYPE - SDAI_Enum *e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE - SDAI_Select *sh; // SELECT_TYPE - SCLundefined *u; // UNKNOWN_TYPE - void *p; - } ptr; - - protected: bool _derive; bool _mustDeletePtr; ///if a member uses new to create an object in ptr ErrorDescriptor _error; - STEPattribute *_redefAttr; - public: - const AttrDescriptor *aDesc; - - protected: + STEPattribute * _redefAttr; + const AttrDescriptor * aDesc; int refCount; - char SkipBadAttr(istream &in, char *StopChars); + /** \union ptr + ** You know which of these to use based on the return value of + ** NonRefType() - see below. BASE_TYPE is defined in baseType.h + ** This variable points to an appropriate member variable in the entity + ** class in the generated schema class library (the entity class is + ** inherited from SDAI_Application_instance) + */ + union attrUnion { + SDAI_String * S; // STRING_TYPE + SDAI_Integer * i; // INTEGER_TYPE (Integer is a long int) + SDAI_Binary * b; // BINARY_TYPE + SDAI_Real * r; // REAL_TYPE and NUMBER_TYPE (Real is a double) + SDAI_Application_instance * * c; // ENTITY_TYPE + STEPaggregate * a; // AGGREGATE_TYPE + SDAI_Enum * e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE + SDAI_Select * sh; // SELECT_TYPE + SCLundefined * u; // UNKNOWN_TYPE + void * p; + } ptr; + + char SkipBadAttr( istream & in, char * StopChars ); void AddErrorInfo(); - void STEPwriteError(ostream &out, unsigned int line, const char *desc); + void STEPwriteError( ostream& out, unsigned int line, const char* desc ); public: - void incrRefCount() - { + void incrRefCount() { ++ refCount; } - void decrRefCount() - { + void decrRefCount() { -- refCount; } - int getRefCount() - { + int getRefCount() { return refCount; } - const AttrDescriptor *getADesc() - { + const AttrDescriptor * getADesc() { return aDesc; } - void Derive(bool n = true) - { + void Derive( bool n = true ) { _derive = n; } - void RedefiningAttr(STEPattribute *a) - { + void RedefiningAttr( STEPattribute * a ) { _redefAttr = a; } ///////////// Read, Write, Assign attr value - Severity StrToVal(const char *s, InstMgrBase *instances = 0, - int addFileId = 0); - Severity STEPread(istream &in = cin, InstMgrBase *instances = 0, - int addFileId = 0, const char *currSch = NULL, bool strict = true); + Severity StrToVal( const char * s, InstMgrBase * instances = 0, + int addFileId = 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 - string asStr(const char *currSch = 0) const; - const char *asStr(std::string &, const char * = 0) const; + string asStr( const char * currSch = 0 ) const; /// put the attr value in ostream - void STEPwrite(ostream &out = cout, const char *currSch = 0); - void ShallowCopy(const STEPattribute *sa); + void STEPwrite( ostream & out = cout, const char * currSch = 0 ); + void ShallowCopy( const STEPattribute * sa ); Severity set_null(); @@ -167,20 +153,25 @@ class SC_CORE_EXPORT STEPattribute * \sa is_null() */ ///@{ - SDAI_Integer *Integer(); - SDAI_Real *Real(); - SDAI_Real *Number(); - SDAI_String *String(); - SDAI_Binary *Binary(); - SDAI_Application_instance *Entity(); - STEPaggregate *Aggregate(); - SDAI_Enum *Enum(); - SDAI_LOGICAL *Logical(); - SDAI_BOOLEAN *Boolean(); - SDAI_Select *Select(); - SCLundefined *Undefined(); + SDAI_Integer * Integer(); + SDAI_Real * Real(); + SDAI_Real * Number(); + SDAI_String * String(); + SDAI_Binary * Binary(); + SDAI_Application_instance * Entity(); + STEPaggregate * Aggregate(); + SDAI_Enum * Enum(); + SDAI_LOGICAL * Logical(); + SDAI_BOOLEAN * Boolean(); + SDAI_Select * Select(); + SCLundefined * Undefined(); ///@} + /// allows direct access to the union containing attr data (dangerous!) + attrUnion * Raw() { + return & ptr; + } + /** * These functions allow setting the attribute value. * Attr type is verified using an assertion. @@ -189,86 +180,81 @@ class SC_CORE_EXPORT STEPattribute * what about ptr.c, which is ( SDAI_Application_instance ** ) ? */ ///@{ - void Integer(SDAI_Integer *n); - void Real(SDAI_Real *n); - void Number(SDAI_Real *n); - void String(SDAI_String *str); - void Binary(SDAI_Binary *bin); - void Entity(SDAI_Application_instance *ent); - void Aggregate(STEPaggregate *aggr); - void Enum(SDAI_Enum *enu); - void Logical(SDAI_LOGICAL *log); - void Boolean(SDAI_BOOLEAN *boo); - void Select(SDAI_Select *sel); - void Undefined(SCLundefined *undef); + void Integer( SDAI_Integer * n ); + void Real( SDAI_Real * n ); + void Number( SDAI_Real * n ); + void String( SDAI_String * str ); + void Binary( SDAI_Binary * bin ); + void Entity( SDAI_Application_instance * ent ); + void Aggregate( STEPaggregate * aggr ); + void Enum( SDAI_Enum * enu ); + void Logical( SDAI_LOGICAL * log ); + void Boolean( SDAI_BOOLEAN * boo ); + void Select( SDAI_Select * sel ); + void Undefined( SCLundefined * undef ); ///@} ////////////// Return info on attr bool Nullable() const; ///< may this attribute be null? bool is_null() const; ///< is this attribute null? - bool IsDerived() const - { + bool IsDerived() const { return _derive; } - STEPattribute *RedefiningAttr() - { + STEPattribute * RedefiningAttr() { return _redefAttr; } - const char *Name() const; - const char *TypeName() const; + const char * Name() const; + const char * TypeName() const; BASE_TYPE Type() const; BASE_TYPE NonRefType() const; BASE_TYPE BaseType() const; - const TypeDescriptor *ReferentType() const; + const TypeDescriptor * ReferentType() const; - ErrorDescriptor &Error() - { + ErrorDescriptor & Error() { return _error; } - void ClearErrorMsg() - { + void ClearErrorMsg() { _error.ClearErrorMsg(); } - Severity ValidLevel(const char *attrValue, ErrorDescriptor *error, InstMgrBase *im, bool clearError = true); + Severity ValidLevel( const char* attrValue, ErrorDescriptor* error, InstMgrBase * im, bool clearError = true ); ////////////////// Constructors - STEPattribute(const STEPattribute &a); - STEPattribute(): _derive(false), _mustDeletePtr(false), - _redefAttr(0), aDesc(0), refCount(0) - { - memset(& ptr, 0, sizeof(ptr)); + STEPattribute( const STEPattribute & a ); + STEPattribute(): _derive( false ), _mustDeletePtr( false ), + _redefAttr( 0 ), aDesc( 0 ), refCount( 0 ) { + memset( & ptr, 0, sizeof( ptr ) ); } ~STEPattribute(); // INTEGER - STEPattribute(const class AttrDescriptor &d, SDAI_Integer *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ); // BINARY - STEPattribute(const class AttrDescriptor &d, SDAI_Binary *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ); // STRING - STEPattribute(const class AttrDescriptor &d, SDAI_String *p); + STEPattribute( const class AttrDescriptor & d, SDAI_String * p ); // REAL & NUMBER - STEPattribute(const class AttrDescriptor &d, SDAI_Real *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ); // ENTITY - STEPattribute(const class AttrDescriptor &d, SDAI_Application_instance * *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance* *p ); // AGGREGATE - STEPattribute(const class AttrDescriptor &d, STEPaggregate *p); + STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ); // ENUMERATION and Logical - STEPattribute(const class AttrDescriptor &d, SDAI_Enum *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ); // SELECT - STEPattribute(const class AttrDescriptor &d, SDAI_Select *p); + STEPattribute( const class AttrDescriptor & d, SDAI_Select * p ); // UNDEFINED - STEPattribute(const class AttrDescriptor &d, SCLundefined *p); + STEPattribute( const class AttrDescriptor & d, SCLundefined * p ); /// return true if attr types and values match - SC_CORE_EXPORT friend bool operator == (const STEPattribute &a1, const STEPattribute &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 ); + SC_CORE_EXPORT friend bool operator != ( const STEPattribute & a1, const STEPattribute & a2 ); /// return true if aDesc's match (behavior of old operator==) - SC_CORE_EXPORT friend bool sameADesc(const STEPattribute &a1, const STEPattribute &a2); + SC_CORE_EXPORT friend bool sameADesc ( const STEPattribute & a1, const STEPattribute & a2 ); }; #endif diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 3ada09ea4..7774321b2 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -14,62 +14,55 @@ #include #include "sc_memmgr.h" -AttrListNode::AttrListNode(STEPattribute *a) -{ +AttrListNode::AttrListNode( STEPattribute * a ) { attr = a; } -AttrListNode::~AttrListNode() -{ +AttrListNode::~AttrListNode() { } -STEPattributeList::STEPattributeList() -{ +STEPattributeList::STEPattributeList() { } -STEPattributeList::~STEPattributeList() -{ +STEPattributeList::~STEPattributeList() { } -STEPattribute &STEPattributeList::operator [](int n) -{ +STEPattribute & STEPattributeList::operator []( int n ) { int x = 0; - AttrListNode *a = (AttrListNode *)head; + AttrListNode * a = ( AttrListNode * )head; int cnt = EntryCount(); - if(n < cnt) { - while(a && (x < n)) { - a = (AttrListNode *)(a->next); + if( n < cnt ) { + while( a && ( x < n ) ) { + a = ( AttrListNode * )( a->next ); x++; } } - if(a) { - return *(a->attr); + if( a ) { + return *( a->attr ); } // else cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ << "\n\n"; - return *(STEPattribute *) 0; + return *( STEPattribute * ) 0; } -int STEPattributeList::list_length() -{ +int STEPattributeList::list_length() { return EntryCount(); } -void STEPattributeList::push(STEPattribute *a) -{ - AttrListNode *a2 = (AttrListNode *)head; +void STEPattributeList::push( STEPattribute * a ) { + AttrListNode * a2 = ( AttrListNode * )head; // if the attribute already exists in the list, don't push it - while(a2) { - if(*a == *(a2 -> attr)) { + while( a2 ) { + if( *a == *( a2 -> attr ) ) { return; } - a2 = (AttrListNode *)(a2->next); + a2 = ( AttrListNode * )( a2->next ); } a->incrRefCount(); - AttrListNode *saln = new AttrListNode(a); - AppendNode(saln); + AttrListNode * saln = new AttrListNode( a ); + AppendNode( saln ); } diff --git a/src/clstepcore/STEPattributeList.h b/src/clstepcore/STEPattributeList.h index b8d00c6c3..9159f4664 100644 --- a/src/clstepcore/STEPattributeList.h +++ b/src/clstepcore/STEPattributeList.h @@ -20,28 +20,26 @@ class STEPattribute; class STEPattributeList; -class SC_CORE_EXPORT AttrListNode : public SingleLinkNode -{ +class SC_CORE_EXPORT AttrListNode : public SingleLinkNode { friend class STEPattributeList; protected: - STEPattribute *attr; + STEPattribute * attr; public: - AttrListNode(STEPattribute *a); + AttrListNode( STEPattribute * a ); virtual ~AttrListNode(); }; -class SC_CORE_EXPORT STEPattributeList : public SingleLinkList -{ +class SC_CORE_EXPORT STEPattributeList : public SingleLinkList { public: STEPattributeList(); virtual ~STEPattributeList(); - STEPattribute &operator [](int n); + STEPattribute & operator []( int n ); int list_length(); - void push(STEPattribute *a); + void push( STEPattribute * a ); }; /***************************************************************** diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 082079646..5daf31ab7 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -9,43 +9,40 @@ #include "sc_memmgr.h" extern const char * -ReadStdKeyword(istream &in, std::string &buf, int skipInitWS); +ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ); -STEPcomplex::STEPcomplex(Registry *registry, int fileid) - : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) -{ +STEPcomplex::STEPcomplex( Registry * registry, int fileid ) + : 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, true), sc(0), _registry(registry), visited(0) -{ - char *nms[BUFSIZ]; +STEPcomplex::STEPcomplex( Registry * registry, const std::string ** names, + int fileid, const char * schnm ) + : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { + char * nms[BUFSIZ]; int j, k; head = this; // Create a char ** list of names and call Initialize to build all: - for(j = 0; names[j]; j++) { - nms[j] = new char[(names[j])->length() + 1 ]; - strcpy(nms[j], names[j]->c_str()); + for( j = 0; names[j]; j++ ) { + nms[j] = new char[( names[j] )->length() + 1 ]; + strcpy( nms[j], names[j]->c_str() ); } nms[j] = NULL; - Initialize((const char **)nms, schnm); - for(k = 0; k < j; k++) { + Initialize( ( const char ** )nms, schnm ); + for( k = 0; k < j; k++ ) { delete [] nms[k]; } } -STEPcomplex::STEPcomplex(Registry *registry, const char **names, int fileid, - const char *schnm) - : SDAI_Application_instance(fileid, true), sc(0), _registry(registry), visited(0) -{ +STEPcomplex::STEPcomplex( Registry * registry, const char ** names, int fileid, + const char * schnm ) + : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { head = this; - Initialize(names, schnm); + Initialize( names, schnm ); } /** @@ -59,24 +56,23 @@ STEPcomplex::STEPcomplex(Registry *registry, const char **names, int fileid, * A and renames it to Y.) Registry::FindEntity() below knows how to * search using the current name of each entity based on schnm. */ -void STEPcomplex::Initialize(const char **names, const char *schnm) -{ +void STEPcomplex::Initialize( const char ** names, const char * schnm ) { // Create an EntNode list consisting of all the names in the complex ent: - EntNode *ents = new EntNode(names), + EntNode * ents = new EntNode( names ), *eptr = ents, *prev = NULL, *enext; - const EntityDescriptor *enDesc; + const EntityDescriptor * enDesc; char nm[BUFSIZ]; bool invalid = false, outOfOrder = false; // Splice out the invalid names from our list: - while(eptr) { + while( eptr ) { enext = eptr->next; - enDesc = _registry->FindEntity(*eptr, schnm); - if(enDesc) { - if(enDesc->Supertypes().EntryCount() > 1) { - eptr->multSuprs(true); + enDesc = _registry->FindEntity( *eptr, schnm ); + if( enDesc ) { + if( enDesc->Supertypes().EntryCount() > 1 ) { + eptr->multSuprs( true ); } - if(StrCmpIns(*eptr, enDesc->Name())) { + if( StrCmpIns( *eptr, enDesc->Name() ) ) { // If this entity was referred by another name rather than the // original. May be the case if FindEntity() determined that // eptr's name was a legal renaming of enDesc's. (Entities and @@ -84,7 +80,7 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) // comments.) If so, change eptr's name (since the complex // support structs only deal with the original names) and have // ents re-ort eptr properly in the list: - eptr->Name(StrToLower(enDesc->Name(), nm)); + eptr->Name( StrToLower( enDesc->Name(), nm ) ); outOfOrder = true; } prev = eptr; @@ -92,7 +88,7 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) invalid = true; cerr << "ERROR: Invalid entity \"" << eptr->Name() << "\" found in complex entity.\n"; - if(!prev) { + if( !prev ) { // if we need to delete the first node, ents = eptr->next; } else { @@ -106,36 +102,36 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) } // If we changed the name of any of the entities, resort: - if(outOfOrder) { - ents->sort(&ents); + if( outOfOrder ) { + ents->sort( &ents ); // This fn may change the value of ents if the list should have a new // first EndNode. } // Set error message according to results of above: - if(invalid) { - if(!ents) { + if( invalid ) { + if( !ents ) { // not a single legal name - _error.severity(SEVERITY_WARNING); + _error.severity( SEVERITY_WARNING ); // SEV_WARNING - we have to skip this entity altogether, but will // continue with the next entity. - _error.UserMsg("No legal entity names found in instance"); + _error.UserMsg( "No legal entity names found in instance" ); return; } - _error.severity(SEVERITY_INCOMPLETE); - _error.UserMsg("Some illegal entity names found in instance"); + _error.severity( SEVERITY_INCOMPLETE ); + _error.UserMsg( "Some illegal entity names found in instance" ); // some illegal entity names, but some legal } // Check if a complex entity can be formed from the resulting combination: - if(!_registry->CompCol()->supports(ents)) { - _error.severity(SEVERITY_WARNING); + if( !_registry->CompCol()->supports( ents ) ) { + _error.severity( SEVERITY_WARNING ); _error.UserMsg( - "Entity combination does not represent a legal complex entity"); + "Entity combination does not represent a legal complex entity" ); cerr << "ERROR: Could not create instance of the following complex" << " entity:" << endl; eptr = ents; - while(eptr) { + while( eptr ) { cerr << *eptr << endl; eptr = eptr->next; } @@ -144,24 +140,23 @@ void STEPcomplex::Initialize(const char **names, const char *schnm) } // Finally, build what we can: - BuildAttrs(*ents); - for(eptr = ents->next; eptr; eptr = eptr->next) { - AddEntityPart(*eptr); + BuildAttrs( *ents ); + for( eptr = ents->next; eptr; eptr = eptr->next ) { + AddEntityPart( *eptr ); } AssignDerives(); delete ents; } -STEPcomplex::~STEPcomplex() -{ +STEPcomplex::~STEPcomplex() { STEPcomplex_attr_data_iter attr_data; - if(sc) { + if( sc ) { delete sc; } - for(attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++) { + for( attr_data = _attr_data_list.begin(); attr_data != _attr_data_list.end(); attr_data ++ ) { attrData_t attrData = *attr_data; - switch(attrData.type) { + switch( attrData.type ) { case INTEGER_TYPE: delete attrData.i; break; @@ -185,12 +180,12 @@ STEPcomplex::~STEPcomplex() delete attrData.ai; break; case ENUM_TYPE: - if(attrData.e) { + if( attrData.e ) { delete attrData.e; } break; case SELECT_TYPE: - if(attrData.s) { + if( attrData.s ) { delete attrData.s; } break; @@ -199,7 +194,7 @@ STEPcomplex::~STEPcomplex() case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: // DAS - if(attrData.a) { + if( attrData.a ) { delete attrData.a; } break; @@ -213,61 +208,59 @@ STEPcomplex::~STEPcomplex() _attr_data_list.clear(); } -void STEPcomplex::AssignDerives() -{ - STEPattribute *a = 0; - STEPcomplex *scomp1 = head; - STEPcomplex *scomp2; +void STEPcomplex::AssignDerives() { + STEPattribute * a = 0; + STEPcomplex * scomp1 = head; + STEPcomplex * scomp2; - const AttrDescriptorList *attrList; - AttrDescLinkNode *attrPtr; - const AttrDescriptor *ad; + const AttrDescriptorList * attrList; + AttrDescLinkNode * attrPtr; + const AttrDescriptor * ad; - while(scomp1 && scomp1->eDesc) { + while( scomp1 && scomp1->eDesc ) { a = 0; - attrList = &(scomp1->eDesc->ExplicitAttr()); - attrPtr = (AttrDescLinkNode *)attrList->GetHead(); + attrList = &( scomp1->eDesc->ExplicitAttr() ); + attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); // assign nm to be derived attr // while( more derived attr for entity part ) - while(attrPtr != 0) { + while( attrPtr != 0 ) { ad = attrPtr->AttrDesc(); - if((ad->Derived()) == LTrue) { - const char *nm = ad->Name(); - const char *attrNm = 0; - if(strrchr(nm, '.')) { - attrNm = strrchr(nm, '.'); + if( ( ad->Derived() ) == LTrue ) { + const char * nm = ad->Name(); + const char * attrNm = 0; + if( strrchr( nm, '.' ) ) { + attrNm = strrchr( nm, '.' ); attrNm++; } else { attrNm = nm; } scomp2 = head; - while(scomp2 && !a) { - if(scomp1 != scomp2) { - scomp2->MakeDerived(attrNm); - a = scomp2->GetSTEPattribute(attrNm); + while( scomp2 && !a ) { + if( scomp1 != scomp2 ) { + scomp2->MakeDerived( attrNm ); + a = scomp2->GetSTEPattribute( attrNm ); } scomp2 = scomp2->sc; } } // increment attr - attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); + attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); } scomp1 = scomp1->sc; } } /** 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) { +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); + AppendEntity( scomplex ); } else { cout << scomplex->_error.DetailMsg() << endl; delete scomplex; @@ -275,12 +268,11 @@ void STEPcomplex::AddEntityPart(const char *name) } } -STEPcomplex *STEPcomplex::EntityPart(const char *name, const char *currSch) -{ - STEPcomplex *scomp = head; - while(scomp) { - if(scomp->eDesc) { - if(scomp->eDesc->CurrName(name, currSch)) { +STEPcomplex * STEPcomplex::EntityPart( const char * name, const char * currSch ) { + STEPcomplex * scomp = head; + while( scomp ) { + if( scomp->eDesc ) { + if( scomp->eDesc->CurrName( name, currSch ) ) { return scomp; } } else { @@ -292,9 +284,8 @@ STEPcomplex *STEPcomplex::EntityPart(const char *name, const char *currSch) return 0; } -int STEPcomplex::EntityExists(const char *name, const char *currSch) -{ - return (EntityPart(name, currSch) ? 1 : 0); +int STEPcomplex::EntityExists( const char * name, const char * currSch ) { + return ( EntityPart( name, currSch ) ? 1 : 0 ); } /** @@ -302,20 +293,18 @@ int STEPcomplex::EntityExists(const char *name, const char *currSch) ** For a complex entity, we'll check the EntityDescriptor of each entity ** in the complex 'chain' */ -const EntityDescriptor *STEPcomplex::IsA(const EntityDescriptor *ed) const -{ - const EntityDescriptor *return_ed = eDesc->IsA(ed); +const EntityDescriptor * STEPcomplex::IsA( const EntityDescriptor * ed ) const { + const EntityDescriptor * return_ed = eDesc->IsA( ed ); - if(!return_ed && sc) { - return sc->IsA(ed); + if( !return_ed && sc ) { + return sc->IsA( ed ); } else { return return_ed; } } -Severity STEPcomplex::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError) -{ +Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError ) { (void) error; //unused (void) im; (void) clearError; @@ -323,75 +312,73 @@ Severity STEPcomplex::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, return SEVERITY_NULL; } -void STEPcomplex::AppendEntity(STEPcomplex *stepc) -{ - if(sc) { - sc->AppendEntity(stepc); +void STEPcomplex::AppendEntity( STEPcomplex * stepc ) { + if( sc ) { + sc->AppendEntity( stepc ); } else { sc = stepc; } } // READ -Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instance_set, - istream &in, const char *currSch, bool /*useTechCor*/, bool /*strict*/) -{ +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; - STEPcomplex *stepc = 0; + STEPcomplex * stepc = 0; - ClearError(1); + ClearError( 1 ); STEPfile_id = id; stepc = head; - while(stepc) { + while( stepc ) { stepc->visited = 0; stepc = stepc->sc; } in >> ws; - in.get(c); - if(c == '(') { // opening paren for subsuperRecord + in.get( c ); + if( c == '(' ) { // opening paren for subsuperRecord in >> ws; c = in.peek(); - while(c != ')') { + while( c != ')' ) { typeNm.clear(); in >> ws; - ReadStdKeyword(in, typeNm, 1); // read the type name + ReadStdKeyword( in, typeNm, 1 ); // read the type name in >> ws; c = in.peek(); - if(c != '(') { - _error.AppendToDetailMsg("Missing open paren before entity attr values.\n"); + if( c != '(' ) { + _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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } - stepc = EntityPart(typeNm.c_str(), currSch); - if(stepc) { + stepc = EntityPart( typeNm.c_str(), currSch ); + 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); + 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); + _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(); } in >> ws; c = in.peek(); } - if(c != ')') { + if( c != ')' ) { cout << "ERROR: missing ending paren for complex entity instance." << endl; } else { - in.get(c); // read the closing paren + 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); + _error.AppendToDetailMsg( "Complex instances must begin with '('. Found '" ); + _error.AppendToDetailMsg( c ); + _error.AppendToDetailMsg( "' instead.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } return _error.severity(); } @@ -399,83 +386,82 @@ Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instanc //FIXME delete this? #ifdef buildwhileread // READ -Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instance_set, - istream &in, const char *currSch) -{ - ClearError(1); +Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set, + istream & in, const char * currSch ) { + ClearError( 1 ); STEPfile_id = id; STEPcomplex stepc = head; - while(stepc) { + while( stepc ) { stepc->visited = 0; stepc = stepc->sc; } char c; in >> ws; - in.get(c); - if(c == '(') { + in.get( c ); + if( c == '(' ) { std::string s; in >> ws; - in.get(c); - while(in && (c != '(') && !isspace(c)) { // get the entity name - s.Append(c); - in.get(c); + in.get( c ); + while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name + s.Append( c ); + in.get( c ); } - if(isspace(c)) { + if( isspace( c ) ) { in >> ws; - in.get(c); + in.get( c ); } - if(c != '(') { + if( c != '(' ) { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n"); + "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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } else { // c == '(' - in.putback(c); + in.putback( c ); } cout << s << endl; - BuildAttrs(s.c_str()); - SDAI_Application_instance::STEPread(id, addFileId, instance_set, - in, currSch); + BuildAttrs( s.c_str() ); + SDAI_Application_instance::STEPread( id, addFileId, instance_set, + in, currSch ); in >> ws; - in.get(c); - while(c != ')') { + in.get( c ); + while( c != ')' ) { s.set_null(); - while(in && (c != '(') && !isspace(c)) { // get the entity name - s.Append(c); - in.get(c); + while( in && ( c != '(' ) && !isspace( c ) ) { // get the entity name + s.Append( c ); + in.get( c ); } - if(isspace(c)) { + if( isspace( c ) ) { in >> ws; - in.get(c); + in.get( c ); } - if(c != '(') { + if( c != '(' ) { _error.AppendToDetailMsg( - "Missing open paren before entity attr values.\n"); + "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); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); + STEPread_error( c, 0, in, currSch ); return _error.severity(); } else { // c == '(' - in.putback(c); + in.putback( c ); } cout << s << endl; // diagnostics DAS - STEPcomplex *stepc = new STEPcomplex(_registry); - AppendEntity(stepc); - stepc->BuildAttrs(s.c_str()); - stepc->SDAI_Application_instance::STEPread(id, addFileId, + STEPcomplex * stepc = new STEPcomplex( _registry ); + AppendEntity( stepc ); + stepc->BuildAttrs( s.c_str() ); + stepc->SDAI_Application_instance::STEPread( id, addFileId, instance_set, in, - currSch); + currSch ); in >> ws; - in.get(c); + in.get( c ); } } return _error.severity(); @@ -483,76 +469,75 @@ Severity STEPcomplex::STEPread(int id, int addFileId, class InstMgrBase *instanc #endif -void STEPcomplex::BuildAttrs(const char *s) -{ +void STEPcomplex::BuildAttrs( const char * s ) { // assign inherited member variable - eDesc = (class EntityDescriptor *)_registry->FindEntity(s); + eDesc = ( class EntityDescriptor * )_registry->FindEntity( s ); - if(eDesc) { - const AttrDescriptorList *attrList = &(eDesc->ExplicitAttr()); + if( eDesc ) { + const AttrDescriptorList * attrList = &( eDesc->ExplicitAttr() ); ////////////////////////////////////////////// // find out how many attrs there are ////////////////////////////////////////////// - STEPattribute *a = 0; + STEPattribute * a = 0; //_attr_data_list used to store everything as void *, but we couldn't correctly delete the contents in the dtor. - AttrDescLinkNode *attrPtr = (AttrDescLinkNode *)attrList->GetHead(); - while(attrPtr != 0) { - const AttrDescriptor *ad = attrPtr->AttrDesc(); + AttrDescLinkNode * attrPtr = ( AttrDescLinkNode * )attrList->GetHead(); + while( attrPtr != 0 ) { + const AttrDescriptor * ad = attrPtr->AttrDesc(); - if((ad->Derived()) != LTrue) { + if( ( ad->Derived() ) != LTrue ) { attrData_t attrData; attrData.type = ad->NonRefType(); - switch(attrData.type) { + switch( attrData.type ) { case INTEGER_TYPE: attrData.i = new SDAI_Integer; - a = new STEPattribute(*ad, attrData.i); + a = new STEPattribute( *ad, attrData.i ); break; case STRING_TYPE: attrData.str = new SDAI_String; - a = new STEPattribute(*ad, attrData.str); + a = new STEPattribute( *ad, attrData.str ); break; case BINARY_TYPE: attrData.bin = new SDAI_Binary; - a = new STEPattribute(*ad, attrData.bin); + a = new STEPattribute( *ad, attrData.bin ); break; case REAL_TYPE: case NUMBER_TYPE: attrData.r = new SDAI_Real; - a = new STEPattribute(*ad, attrData.r); + a = new STEPattribute( *ad, attrData.r ); break; case BOOLEAN_TYPE: attrData.b = new SDAI_BOOLEAN; - a = new STEPattribute(*ad, attrData.b); + a = new STEPattribute( *ad, attrData.b ); break; case LOGICAL_TYPE: attrData.l = new SDAI_LOGICAL; - a = new STEPattribute(*ad, attrData.l); + a = new STEPattribute( *ad, attrData.l ); break; case ENTITY_TYPE: - attrData.ai = new(SDAI_Application_instance *); - a = new STEPattribute(*ad, attrData.ai); + attrData.ai = new( SDAI_Application_instance * ); + a = new STEPattribute( *ad, attrData.ai ); break; case ENUM_TYPE: { - EnumTypeDescriptor *enumD = (EnumTypeDescriptor *)ad->ReferentType(); + EnumTypeDescriptor * enumD = ( EnumTypeDescriptor * )ad->ReferentType(); attrData.e = enumD->CreateEnum(); - a = new STEPattribute(*ad, attrData.e); + a = new STEPattribute( *ad, attrData.e ); break; } case SELECT_TYPE: { - SelectTypeDescriptor *selectD = (SelectTypeDescriptor *)ad->ReferentType(); + SelectTypeDescriptor * selectD = ( SelectTypeDescriptor * )ad->ReferentType(); attrData.s = selectD->CreateSelect(); - a = new STEPattribute(*ad, attrData.s); + a = new STEPattribute( *ad, attrData.s ); break; } case AGGREGATE_TYPE: @@ -560,42 +545,41 @@ void STEPcomplex::BuildAttrs(const char *s) case BAG_TYPE: // DAS case SET_TYPE: // DAS case LIST_TYPE: { // DAS - AggrTypeDescriptor *aggrD = (AggrTypeDescriptor *)ad->ReferentType(); + AggrTypeDescriptor * aggrD = ( AggrTypeDescriptor * )ad->ReferentType(); attrData.a = aggrD->CreateAggregate(); - a = new STEPattribute(*ad, attrData.a); + a = new STEPattribute( *ad, attrData.a ); break; } default: - _error.AppendToDetailMsg("STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n"); - _error.GreaterSeverity(SEVERITY_WARNING); + _error.AppendToDetailMsg( "STEPcomplex::BuildAttrs: Found attribute of unknown type. Creating default attribute.\n" ); + _error.GreaterSeverity( SEVERITY_WARNING ); a = new STEPattribute(); attrData.type = UNKNOWN_TYPE; //don't add to attr list } - if(attrData.type != UNKNOWN_TYPE) { - _attr_data_list.push_back(attrData); + if( attrData.type != UNKNOWN_TYPE ) { + _attr_data_list.push_back( attrData ); } a -> set_null(); - attributes.push(a); + attributes.push( a ); } - attrPtr = (AttrDescLinkNode *)attrPtr->NextNode(); + attrPtr = ( AttrDescLinkNode * )attrPtr->NextNode(); } } else { - _error.AppendToDetailMsg("Entity does not exist.\n"); - _error.GreaterSeverity(SEVERITY_INPUT_ERROR); + _error.AppendToDetailMsg( "Entity does not exist.\n" ); + _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); } } -void STEPcomplex::STEPread_error(char c, int index, istream &in, const char *schnm) -{ +void STEPcomplex::STEPread_error( char c, int index, istream & in, const char * schnm ) { (void) schnm; //unused cout << "STEPcomplex::STEPread_error(), index=" << index << ", entity #" << STEPfile_id << "." << endl; streampos p = in.tellg(); std::string q, r; - getline(in, q); - getline(in, r); + getline( in, q ); + getline( in, r ); cout << "Remainder of this line:" << endl << c << q << endl << "Next line:" << endl << r << endl; - in.seekg(p); + in.seekg( p ); } /** @@ -606,138 +590,132 @@ void STEPcomplex::STEPread_error(char c, int index, istream &in, const char *sch ** alphabetical order. The nodes are sorted alphabetically according to their ** original names but not according to their renamed names (DAR 6/5/97). */ -void STEPcomplex::STEPwrite(ostream &out, const char *currSch, int writeComment) -{ - if(writeComment && !p21Comment.empty()) { +void STEPcomplex::STEPwrite( ostream & out, const char * currSch, int writeComment ) { + if( writeComment && !p21Comment.empty() ) { out << p21Comment; } out << "#" << STEPfile_id << "=(\n"; - WriteExtMapEntities(out, currSch); + WriteExtMapEntities( out, currSch ); out << ");\n"; } -const char *STEPcomplex::STEPwrite(std::string &buf, const char *currSch) -{ +const char * STEPcomplex::STEPwrite( std::string & buf, const char * currSch ) { buf.clear(); stringstream ss; ss << "#" << STEPfile_id << "=("; - WriteExtMapEntities(ss, currSch); + WriteExtMapEntities( ss, currSch ); ss << ");"; ss << ends; - buf.append(ss.str()); + buf.append( ss.str() ); - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /** \copydoc STEPcomplex::STEPwrite */ -void STEPcomplex::WriteExtMapEntities(ostream &out, const char *currSch) -{ +void STEPcomplex::WriteExtMapEntities( ostream & out, const char * currSch ) { std::string tmp; - out << StrToUpper(EntityName(currSch), tmp); + out << StrToUpper( EntityName( currSch ), tmp ); out << "("; int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - (attributes[i]).STEPwrite(out, currSch); - if(i < n - 1) { + for( int i = 0 ; i < n; i++ ) { + ( attributes[i] ).STEPwrite( out, currSch ); + if( i < n - 1 ) { out << ","; } } out << ")\n"; - if(sc) { - sc->WriteExtMapEntities(out, currSch); + if( sc ) { + sc->WriteExtMapEntities( out, currSch ); } } /** \copydoc STEPcomplex::STEPwrite */ -const char *STEPcomplex::WriteExtMapEntities(std::string &buf, const char *currSch) -{ +const char * STEPcomplex::WriteExtMapEntities( std::string & buf, const char * currSch ) { std::string tmp; - StrToUpper(EntityName(currSch), tmp); - buf.append(tmp); - buf.append("i"); + StrToUpper( EntityName( currSch ), tmp ); + buf.append( tmp ); + buf.append( "i" ); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - buf.append(attributes[i].asStr(currSch)); - if(i < n - 1) { - buf.append(","); + for( int i = 0 ; i < n; i++ ) { + buf.append( attributes[i].asStr( currSch ) ); + if( i < n - 1 ) { + buf.append( "," ); } } - buf.append(")\n"); + buf.append( ")\n" ); - if(sc) { - sc->WriteExtMapEntities(buf, currSch); + if( sc ) { + sc->WriteExtMapEntities( buf, currSch ); } return buf.c_str(); } -void STEPcomplex::CopyAs(SDAI_Application_instance *se) -{ - if(!se->IsComplex()) { +void STEPcomplex::CopyAs( SDAI_Application_instance * se ) { + if( !se->IsComplex() ) { char errStr[BUFSIZ]; cerr << "STEPcomplex::CopyAs() called with non-complex entity: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPcomplex::CopyAs(): %s - entity #%d.\n", - "Programming ERROR - called with non-complex entity", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPcomplex::CopyAs(): %s - entity #%d.\n", + "Programming ERROR - called with non-complex entity", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); return; } else { - STEPcomplex *scpartCpyTo = head; - STEPcomplex *scpartCpyFrom = ((STEPcomplex *)se)->head; - while(scpartCpyTo && scpartCpyFrom) { - scpartCpyTo->SDAI_Application_instance::CopyAs(scpartCpyFrom); + STEPcomplex * scpartCpyTo = head; + STEPcomplex * scpartCpyFrom = ( ( STEPcomplex * )se )->head; + while( scpartCpyTo && scpartCpyFrom ) { + scpartCpyTo->SDAI_Application_instance::CopyAs( scpartCpyFrom ); scpartCpyTo = scpartCpyTo->sc; scpartCpyFrom = scpartCpyFrom->sc; } } } -SDAI_Application_instance *STEPcomplex::Replicate() -{ - if(!IsComplex()) { +SDAI_Application_instance * STEPcomplex::Replicate() { + if( !IsComplex() ) { return SDAI_Application_instance::Replicate(); - } else if(!_registry) { + } else if( !_registry ) { return S_ENTITY_NULL; } else { int nameCount = 64; - std::string **nameList = new std::string *[nameCount]; - STEPcomplex *scomp = this->head; + std::string ** nameList = new std::string *[nameCount]; + STEPcomplex * scomp = this->head; int i = 0; - while(scomp && (i < 63)) { - nameList[i] = new std::string(""); - nameList[i]->append(scomp->eDesc->Name()); + while( scomp && ( i < 63 ) ) { + nameList[i] = new std::string( "" ); + nameList[i]->append( scomp->eDesc->Name() ); i++; scomp = scomp->sc; } - nameList[i] = (std::string *)0; - if(i == 63) { + nameList[i] = ( std::string * )0; + if( i == 63 ) { char errStr[BUFSIZ]; cerr << "STEPcomplex::Replicate() name buffer too small: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPcomplex::Replicate(): %s - entity #%d.\n", - "Programming ERROR - name buffer too small", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPcomplex::Replicate(): %s - entity #%d.\n", + "Programming ERROR - name buffer too small", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); } - STEPcomplex *seNew = new STEPcomplex(_registry, - (const std::string **)nameList, - 1111); - seNew -> CopyAs(this); + STEPcomplex * seNew = new STEPcomplex( _registry, + ( const std::string ** )nameList, + 1111 ); + seNew -> CopyAs( this ); return seNew; // TODO need to: diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index 10239ec01..caf7ea255 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -18,16 +18,16 @@ typedef struct { PrimitiveType type; union { - SDAI_Integer *i; - SDAI_String *str; - SDAI_Binary *bin; - SDAI_Real *r; - SDAI_BOOLEAN *b; - SDAI_LOGICAL *l; - SDAI_Application_instance **ai; - SDAI_Enum *e; - SDAI_Select *s; - STEPaggregate *a; + SDAI_Integer * i; + SDAI_String * str; + SDAI_Binary * bin; + SDAI_Real * r; + SDAI_BOOLEAN * b; + SDAI_LOGICAL * l; + SDAI_Application_instance ** ai; + SDAI_Enum * e; + SDAI_Select * s; + STEPaggregate * a; }; } attrData_t; typedef std::list< attrData_t > STEPcomplex_attr_data_list; @@ -36,12 +36,11 @@ typedef STEPcomplex_attr_data_list::iterator STEPcomplex_attr_data_iter; /** FIXME are inverse attr's initialized for STEPcomplex? */ -class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance -{ +class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance { public: //TODO should this _really_ be public?! - STEPcomplex *sc; - STEPcomplex *head; - Registry *_registry; + STEPcomplex * sc; + STEPcomplex * head; + Registry * _registry; int visited; ///< used when reading (or as you wish?) #ifdef _MSC_VER #pragma warning( push ) @@ -52,48 +51,48 @@ class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance #pragma warning( pop ) #endif public: - STEPcomplex(Registry *registry, int fileid); - STEPcomplex(Registry *registry, const std::string **names, int fileid, - const char *schnm = 0); - STEPcomplex(Registry *registry, const char **names, int fileid, - const char *schnm = 0); + STEPcomplex( Registry * registry, int fileid ); + STEPcomplex( Registry * registry, const std::string ** names, int fileid, + const char * schnm = 0 ); + STEPcomplex( Registry * registry, const char ** names, int fileid, + const char * schnm = 0 ); virtual ~STEPcomplex(); - int EntityExists(const char *name, const char *currSch = 0); - STEPcomplex *EntityPart(const char *name, const char *currSch = 0); + int EntityExists( const char * name, const char * currSch = 0 ); + STEPcomplex * EntityPart( const char * name, const char * currSch = 0 ); - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; - virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError = 1); + virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError = 1 ); // READ - virtual Severity STEPread(int id, int addFileId, - class InstMgrBase *instance_set, - istream &in = cin, const char *currSch = NULL, - bool useTechCor = true, bool strict = true); + virtual Severity STEPread( int id, int addFileId, + class InstMgrBase * instance_set, + istream & in = cin, const char * currSch = NULL, + bool useTechCor = true, bool strict = true ); - virtual void STEPread_error(char c, int index, istream &in, const char *schnm); + virtual void STEPread_error( char c, int index, istream& in, const char * schnm ); // WRITE - virtual void STEPwrite(ostream &out = cout, const char *currSch = NULL, - int writeComment = 1); - virtual const char *STEPwrite(std::string &buf, const char *currSch = NULL); + virtual void STEPwrite( ostream & out = cout, const char * currSch = NULL, + int writeComment = 1 ); + virtual const char * STEPwrite( std::string & buf, const char * currSch = NULL ); - SDAI_Application_instance *Replicate(); + SDAI_Application_instance * Replicate(); - virtual void WriteExtMapEntities(ostream &out = cout, - const char *currSch = NULL); - virtual const char *WriteExtMapEntities(std::string &buf, - const char *currSch = NULL); - virtual void AppendEntity(STEPcomplex *stepc); + virtual void WriteExtMapEntities( ostream & out = cout, + const char * currSch = NULL ); + virtual const char * WriteExtMapEntities( std::string & buf, + const char * currSch = NULL ); + virtual void AppendEntity( STEPcomplex * stepc ); protected: - virtual void CopyAs(SDAI_Application_instance *se); - void BuildAttrs(const char *s); - void AddEntityPart(const char *name); + virtual void CopyAs( SDAI_Application_instance * se ); + void BuildAttrs( const char * s ); + void AddEntityPart( const char * name ); void AssignDerives(); - void Initialize(const char **names, const char *schnm); + void Initialize( const char ** names, const char * schnm ); }; #endif diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index cd083a67a..52bdf1ee5 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -7,8 +7,8 @@ #include #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(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() {} @@ -16,55 +16,51 @@ invAttrListNodeA::~invAttrListNodeA() {} STEPinvAttrList::STEPinvAttrList() {} STEPinvAttrList::~STEPinvAttrList() {} -invAttrListNode *STEPinvAttrList::operator [](int n) -{ +invAttrListNode * STEPinvAttrList::operator []( int n ) { int x = 0; - invAttrListNode *a = (invAttrListNode *)head; + invAttrListNode * a = ( invAttrListNode * )head; int cnt = EntryCount(); - if(n < cnt) { - while(a && (x < n)) { - a = (invAttrListNode *)(a->next); + if( n < cnt ) { + while( a && ( x < n ) ) { + a = ( invAttrListNode * )( a->next ); x++; } } - if(!a) { + if( !a ) { cerr << "\nERROR in STEP Core library: " << __FILE__ << ":" - << __LINE__ << "\n" << _POC_ << "\n\n"; + << __LINE__ << "\n" << _POC_ << "\n\n"; } return a; } -int STEPinvAttrList::list_length() -{ +int STEPinvAttrList::list_length() { return EntryCount(); } -void STEPinvAttrList::push(Inverse_attribute *a, setterA_t s, getterA_t g) -{ - invAttrListNode *an = (invAttrListNode *)head; +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)) { + while( an ) { + if( a == ( an -> attr ) ) { return; } - an = (invAttrListNode *)(an->next); + an = ( invAttrListNode * )( an->next ); } - invAttrListNode *ialn = (invAttrListNode *) new invAttrListNodeA(a, s, g); - AppendNode(ialn); + 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; +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)) { + while( an ) { + if( a == ( an -> attr ) ) { return; } - an = (invAttrListNode *)(an->next); + an = ( invAttrListNode * )( an->next ); } - invAttrListNode *ialn = (invAttrListNode *) new invAttrListNodeI(a, s, g); - AppendNode(ialn); + invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeI( a, s, g ); + AppendNode( ialn ); } diff --git a/src/clstepcore/STEPinvAttrList.h b/src/clstepcore/STEPinvAttrList.h index 6754fc99e..342720065 100644 --- a/src/clstepcore/STEPinvAttrList.h +++ b/src/clstepcore/STEPinvAttrList.h @@ -25,86 +25,75 @@ class SDAI_Application_instance; * 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 *); +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; +class SC_CORE_EXPORT invAttrListNode : public SingleLinkNode { + friend class STEPinvAttrList; protected: - invAttrListNode(Inverse_attribute *a) : attr(a) {}; - Inverse_attribute *attr; + invAttrListNode( Inverse_attribute * a ) : attr( a ) {}; + Inverse_attribute * attr; public: - Inverse_attribute *inverseADesc() - { + Inverse_attribute * inverseADesc() { return attr; } virtual bool isAggregate() = 0; }; -class SC_CORE_EXPORT invAttrListNodeI : public invAttrListNode -{ - friend class STEPinvAttrList; +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); + invAttrListNodeI( Inverse_attribute * a, setterI_t s, getterI_t g ); virtual ~invAttrListNodeI(); - setterI_t setter() - { + setterI_t setter() { return set; } - getterI_t getter() - { + getterI_t getter() { return get; } - virtual bool isAggregate() - { + virtual bool isAggregate() { return false; } }; -class SC_CORE_EXPORT invAttrListNodeA : public invAttrListNode -{ - friend class STEPinvAttrList; +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); + invAttrListNodeA( Inverse_attribute * a, setterA_t s, getterA_t g ); virtual ~invAttrListNodeA(); - setterA_t setter() - { + setterA_t setter() { return set; } - getterA_t getter() - { + getterA_t getter() { return get; } - virtual bool isAggregate() - { + 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 -{ +class SC_CORE_EXPORT STEPinvAttrList : public SingleLinkList { public: STEPinvAttrList(); virtual ~STEPinvAttrList(); - invAttrListNode *operator [](int n); + 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); + void push( Inverse_attribute * a, setterA_t s, getterA_t g ); + void push( Inverse_attribute * a, setterI_t s, getterI_t g ); }; diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index 71ad08705..6ca378099 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -19,26 +19,22 @@ ** helper functions for reading unknown types */ -Severity SCLundefined::StrToVal(const char *s, ErrorDescriptor *err) -{ +Severity SCLundefined::StrToVal( const char * s, ErrorDescriptor * err ) { (void) err; //unused val = s; return SEVERITY_NULL; } -Severity SCLundefined::StrToVal(istream &in, ErrorDescriptor *err) -{ - return STEPread(in, err); +Severity SCLundefined::StrToVal( istream & in, ErrorDescriptor * err ) { + return STEPread( in, err ); } -Severity SCLundefined::STEPread(const char *s, ErrorDescriptor *err) -{ - istringstream in((char *) s); - return STEPread(in, err); +Severity SCLundefined::STEPread( const char * s, ErrorDescriptor * err ) { + istringstream in( ( char * ) s ); + return STEPread( in, err ); } -Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) -{ +Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) { char c = '\0'; ostringstream ss; std::string str; @@ -47,38 +43,38 @@ Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) in >> ws; // skip white space in >> c; - if(c == '$') { + if( c == '$' ) { val = ""; - CheckRemainingInput(in, err, "aggregate item", ",)"); + CheckRemainingInput( in, err, "aggregate item", ",)" ); } else { - in.putback(c); + in.putback( c ); } - while(!terminal) { - in.get(c); - switch(c) { + while( !terminal ) { + in.get( c ); + switch( c ) { case '(': - in.putback(c); + in.putback( c ); - PushPastImbedAggr(in, str, err); + PushPastImbedAggr( in, str, err ); ss << str; break; case '\'': - in.putback(c); + in.putback( c ); - PushPastString(in, str, err); + PushPastString( in, str, err ); ss << str; break; case ',': terminal = 1; // it's a STEPattribute separator - in.putback(c); + in.putback( c ); c = '\0'; break; case ')': - in.putback(c); + in.putback( c ); terminal = 1; // found a valid delimiter break; @@ -88,58 +84,53 @@ Severity SCLundefined::STEPread(istream &in, ErrorDescriptor *err) break; default: - ss.put(c); + ss.put( c ); break; } - if(!in.good()) { + if( !in.good() ) { terminal = 1; c = '\0'; } } ss << ends; - val = &(ss.str()[0]); + val = &( ss.str()[0] ); - err->GreaterSeverity(SEVERITY_NULL); + err->GreaterSeverity( SEVERITY_NULL ); return SEVERITY_NULL; } -const char *SCLundefined::asStr(std::string &s) const -{ +const char * SCLundefined::asStr( std::string & s ) const { s = val.c_str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *SCLundefined::STEPwrite(std::string &s) -{ - if(val.empty()) { +const char * SCLundefined::STEPwrite( std::string & s ) { + if( val.empty() ) { s = "$"; } else { s = val.c_str(); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -void SCLundefined:: STEPwrite(ostream &out) -{ - if(val.empty()) { +void SCLundefined:: STEPwrite( ostream & out ) { + if( val.empty() ) { out << "$"; } else { out << val; } } -SCLundefined &SCLundefined::operator= (const SCLundefined &x) -{ +SCLundefined & SCLundefined::operator= ( const SCLundefined & x ) { std::string tmp; - val = x.asStr(tmp); + val = x.asStr( tmp ); return *this; } -SCLundefined &SCLundefined::operator= (const char *str) -{ - if(!str) { +SCLundefined & SCLundefined::operator= ( const char * str ) { + if( !str ) { val.clear(); } else { val = str; @@ -147,22 +138,18 @@ SCLundefined &SCLundefined::operator= (const char *str) return *this; } -SCLundefined::SCLundefined() -{ +SCLundefined::SCLundefined() { } -SCLundefined::~SCLundefined() -{ +SCLundefined::~SCLundefined() { } -int SCLundefined::set_null() -{ +int SCLundefined::set_null() { val = ""; return 1; } -bool SCLundefined::is_null() -{ - return (val.empty()); +bool SCLundefined::is_null() { + return ( val.empty() ); } diff --git a/src/clstepcore/STEPundefined.h b/src/clstepcore/STEPundefined.h index e83685f17..306eb0ef2 100644 --- a/src/clstepcore/STEPundefined.h +++ b/src/clstepcore/STEPundefined.h @@ -17,8 +17,7 @@ #include #include -class SC_CORE_EXPORT SCLundefined -{ +class SC_CORE_EXPORT SCLundefined { protected: #ifdef _MSC_VER #pragma warning( push ) @@ -31,21 +30,21 @@ class SC_CORE_EXPORT SCLundefined public: // INPUT - virtual Severity StrToVal(const char *s, ErrorDescriptor *err); - virtual Severity StrToVal(istream &in, ErrorDescriptor *err); + virtual Severity StrToVal( const char * s, ErrorDescriptor * err ); + virtual Severity StrToVal( istream & in, ErrorDescriptor * err ); - virtual Severity STEPread(const char *s, ErrorDescriptor *err); - virtual Severity STEPread(istream &in, ErrorDescriptor *err); + virtual Severity STEPread( const char * s, ErrorDescriptor * err ); + virtual Severity STEPread( istream & in, ErrorDescriptor * err ); // OUTPUT - virtual const char *asStr(std::string &s) const; - virtual const char *STEPwrite(std::string &s); - virtual void STEPwrite(ostream &out = cout); + virtual const char * asStr( std::string & s ) const; + virtual const char * STEPwrite( std::string & s ); + virtual void STEPwrite( ostream & out = cout ); int set_null(); bool is_null(); - SCLundefined &operator= (const SCLundefined &); - SCLundefined &operator= (const char *str); + SCLundefined & operator= ( const SCLundefined & ); + SCLundefined & operator= ( const char * str ); SCLundefined(); virtual ~SCLundefined(); }; diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index 1552b2707..b13e2061d 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -15,72 +15,65 @@ #include -SingleLinkList::SingleLinkList() : head(0), tail(0) -{ +SingleLinkList::SingleLinkList() : head( 0 ), tail( 0 ) { } -SingleLinkList::~SingleLinkList() -{ +SingleLinkList::~SingleLinkList() { Empty(); } -void SingleLinkList::Empty() -{ - SingleLinkNode *tmp = head; - while(tmp) { +void SingleLinkList::Empty() { + SingleLinkNode * tmp = head; + while( tmp ) { tmp = head -> NextNode(); delete head; head = tmp; } } -SingleLinkNode *SingleLinkList::NewNode() -{ +SingleLinkNode * SingleLinkList::NewNode() { // defined in subtypes std::cerr << "\n\n******BUG****** a virtually defined function should \n" - << "be called for SingleLinkList::NewNode()\n\n"; + << "be called for SingleLinkList::NewNode()\n\n"; return new SingleLinkNode(); } -SingleLinkNode *SingleLinkList::GetHead() const -{ - return (head); +SingleLinkNode * SingleLinkList::GetHead() const { + return ( head ); } -int SingleLinkList::EntryCount() const -{ +int SingleLinkList::EntryCount() const { int entryCount = 0; - SingleLinkNode *entryPtr = head; + SingleLinkNode * entryPtr = head; - while(entryPtr != 0) { + while( entryPtr != 0 ) { entryPtr = entryPtr->NextNode(); entryCount++; } return entryCount; } -void SingleLinkList::DeleteFollowingNodes(SingleLinkNode *item) -{ - if(head) { - SingleLinkNode *trailer = 0; - SingleLinkNode *leader = head; - while(leader) { - if(leader == item) { - while(leader) { - if(trailer) { +void SingleLinkList::DeleteFollowingNodes( SingleLinkNode * item ) { + if( head ) { + SingleLinkNode * trailer = 0; + SingleLinkNode * leader = head; + while( leader ) { + if( leader == item ) { + while( leader ) { + if( trailer ) { trailer->next = leader->next; - } else if(leader == head) { + } else if( leader == head ) { head = leader->next; trailer = head; } - if(leader == tail) { + if( leader == tail ) { tail = trailer; } delete leader; leader = trailer->next; } } else { - if(trailer) { + if( trailer ) { trailer = trailer->NextNode(); } else { trailer = leader; @@ -91,9 +84,8 @@ void SingleLinkList::DeleteFollowingNodes(SingleLinkNode *item) } } -void SingleLinkList::AppendNode(SingleLinkNode *item) -{ - if(head) { +void SingleLinkList::AppendNode( SingleLinkNode * item ) { + if( head ) { tail -> next = item; tail = item; } else { @@ -102,26 +94,25 @@ void SingleLinkList::AppendNode(SingleLinkNode *item) item->owner = this; } -void SingleLinkList::DeleteNode(SingleLinkNode *item) -{ - if(head) { - SingleLinkNode *trailer = 0; - SingleLinkNode *leader = head; - while(leader) { - if(leader == item) { - if(trailer) { +void SingleLinkList::DeleteNode( SingleLinkNode * item ) { + if( head ) { + SingleLinkNode * trailer = 0; + SingleLinkNode * leader = head; + while( leader ) { + if( leader == item ) { + if( trailer ) { trailer->next = leader->next; } leader = leader->next; - if(item == head) { + if( item == head ) { head = item->next; } - if(item == tail) { + if( item == tail ) { tail = trailer; } delete item; } else { - if(trailer) { + if( trailer ) { trailer = trailer->NextNode(); } else { trailer = leader; diff --git a/src/clstepcore/SingleLinkList.h b/src/clstepcore/SingleLinkList.h index a6fddd928..24726f194 100644 --- a/src/clstepcore/SingleLinkList.h +++ b/src/clstepcore/SingleLinkList.h @@ -20,19 +20,18 @@ * node which represents the value is contained in the subclass * since it may have different types for different lists */ -class SC_CORE_EXPORT SingleLinkList -{ +class SC_CORE_EXPORT SingleLinkList { protected: - class SingleLinkNode *head; - SingleLinkNode *tail; + class SingleLinkNode * head; + SingleLinkNode * tail; public: - virtual SingleLinkNode *NewNode(); - virtual void AppendNode(SingleLinkNode *); - virtual void DeleteNode(SingleLinkNode *); + virtual SingleLinkNode * NewNode(); + virtual void AppendNode( SingleLinkNode * ); + virtual void DeleteNode( SingleLinkNode * ); virtual void Empty(); - virtual void DeleteFollowingNodes(SingleLinkNode *); - virtual SingleLinkNode *GetHead() const; + virtual void DeleteFollowingNodes( SingleLinkNode * ); + virtual SingleLinkNode * GetHead() const; int EntryCount() const; @@ -43,24 +42,20 @@ class SC_CORE_EXPORT SingleLinkList /** Base class for nodes of a single-linked list. * \sa SingleLinkList */ -class SC_CORE_EXPORT SingleLinkNode -{ +class SC_CORE_EXPORT SingleLinkNode { friend class SingleLinkList; public: - SingleLinkList *owner; - SingleLinkNode *next; + SingleLinkList * owner; + SingleLinkNode * next; - virtual SingleLinkNode *NextNode() const - { + virtual SingleLinkNode * NextNode() const { return next; } - SingleLinkNode() : owner(0), next(0) - { + SingleLinkNode() : owner( 0 ), next( 0 ) { } - virtual ~SingleLinkNode() - { + virtual ~SingleLinkNode() { } }; diff --git a/src/clstepcore/SubSuperIterators.h b/src/clstepcore/SubSuperIterators.h index 029d0999e..9ca78765b 100644 --- a/src/clstepcore/SubSuperIterators.h +++ b/src/clstepcore/SubSuperIterators.h @@ -9,12 +9,11 @@ /** abstract base class for recursive breadth-first input iterators of EntityDescriptor/EntityDescLinkNode * NOTE: due to pure virtual functions being necessary for initialization, derived class constructor must call reset(t) */ -class recursiveEntDescripIterator -{ +class recursiveEntDescripIterator { protected: - const EntityDescriptor *startEntity; + const EntityDescriptor * startEntity; typedef struct { - const EntityDescriptor *ed; + const EntityDescriptor * ed; unsigned int depth; ///< for debugging; records how many lists had to be traversed to find the current node } queue_pair; @@ -22,166 +21,146 @@ class recursiveEntDescripIterator unsigned int position; ///< primarily used in comparisons between iterators ///add contents of a linked list to q - void addLinkedList(const queue_pair qp) - { - EntityDescLinkNode *a = listHead(qp.ed); + void addLinkedList( const queue_pair qp ) { + EntityDescLinkNode * a = listHead( qp.ed ); queue_pair tmp; tmp.depth = qp.depth + 1; - while(a != 0) { - tmp.ed = nodeContent(a); - q.push_back(tmp); - a = (EntityDescLinkNode *) a->NextNode(); + while( a != 0 ) { + tmp.ed = nodeContent( a ); + q.push_back( tmp ); + a = ( EntityDescLinkNode * ) a->NextNode( ); } } - virtual EntityDescLinkNode *listHead(const EntityDescriptor *t) const = 0; ///< returns the head of something inheriting SingleLinkList - virtual EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const = 0; ///< returns the content of a SingleLinkNode + virtual EntityDescLinkNode * listHead( const EntityDescriptor * t ) const = 0; ///< returns the head of something inheriting SingleLinkList + virtual EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const = 0; ///< returns the content of a SingleLinkNode public: - recursiveEntDescripIterator(const EntityDescriptor *t = 0): startEntity(t), position(0) - { + recursiveEntDescripIterator( const EntityDescriptor * t = 0 ): startEntity( t ), position( 0 ) { //NOTE due to pure virtual functions, derived class constructor *must* call reset(t) } - ~recursiveEntDescripIterator() - { + ~recursiveEntDescripIterator( ) { } - void reset(const EntityDescriptor *t = 0) - { + void reset( const EntityDescriptor * t = 0 ) { position = 0; - q.clear(); - if(t) { + q.clear( ); + if( t ) { startEntity = t; } - if(startEntity) { + if( startEntity ) { queue_pair p; p.depth = 0; p.ed = startEntity; - addLinkedList(p); + addLinkedList( p ); } } - const EntityDescriptor *next() - { - if(q.empty()) { - return (EntityDescriptor *) 0; + const EntityDescriptor * next( ) { + if( q.empty( ) ) { + return ( EntityDescriptor * ) 0; } else { position++; - queue_pair qp = q.front(); - q.pop_front(); - addLinkedList(qp); + queue_pair qp = q.front( ); + q.pop_front( ); + addLinkedList( qp ); return qp.ed; } } - const EntityDescriptor *current() const - { - if(q.empty()) { - return (EntityDescriptor *) 0; + const EntityDescriptor * current( ) const { + if( q.empty( ) ) { + return ( EntityDescriptor * ) 0; } - return(q.front().ed); + return( q.front( ).ed ); } - bool hasNext() const - { - return(((q.size() > 1) && (q[1].ed != 0)) //there is another EntityDescriptor in q - || (nodeContent(listHead(q[0].ed)) != 0)); //or, the only one in the queue has a non-empty list + bool hasNext( ) const { + return( ( ( q.size( ) > 1 ) && ( q[1].ed != 0 ) ) //there is another EntityDescriptor in q + || ( nodeContent( listHead( q[0].ed ) ) != 0 ) ); //or, the only one in the queue has a non-empty list } - bool empty() const - { - return q.empty(); + bool empty( ) const { + return q.empty( ); } - unsigned int pos() const - { + unsigned int pos( ) const { return position; } - unsigned int depth() const - { + unsigned int depth( ) const { return q[0].depth; } - const EntityDescriptor *operator *() const - { - return current(); + const EntityDescriptor * operator *( ) const { + return current( ); } - const EntityDescriptor *operator ->() const - { - return current(); + const EntityDescriptor * operator ->( ) const { + return current( ); } /// two iterators are not considered equal unless the startEntity pointers match and the positions match - bool operator ==(const recursiveEntDescripIterator &b) const - { - return((startEntity == b.startEntity) && (position == b.position)); + bool operator ==( const recursiveEntDescripIterator & b ) const { + return( ( startEntity == b.startEntity ) && ( position == b.position ) ); } - bool operator !=(const recursiveEntDescripIterator &b) const - { - return((startEntity != b.startEntity) || (position != b.position)); + bool operator !=( const recursiveEntDescripIterator & b ) const { + return( ( startEntity != b.startEntity ) || ( position != b.position ) ); } /// for inequality operators, return a Logical; LUnknown means that the startEntity pointers do not match - Logical operator >(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator >( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position > b.position) { + if( position > b.position ) { return LTrue; } else { return LFalse; } } - Logical operator <(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator <( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position < b.position) { + if( position < b.position ) { return LTrue; } else { return LFalse; } } - Logical operator >=(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator >=( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position >= b.position) { + if( position >= b.position ) { return LTrue; } else { return LFalse; } } - Logical operator <=(const recursiveEntDescripIterator &b) const - { - if(startEntity != b.startEntity) { + Logical operator <=( const recursiveEntDescripIterator & b ) const { + if( startEntity != b.startEntity ) { return LUnknown; } - if(position <= b.position) { + if( position <= b.position ) { return LTrue; } else { return LFalse; } } - const EntityDescriptor *operator ++() - { - return next(); + const EntityDescriptor * operator ++( ) { + return next( ); } - const EntityDescriptor *operator ++(int) - { - const EntityDescriptor *c = current(); - next(); + const EntityDescriptor * operator ++( int ) { + const EntityDescriptor * c = current( ); + next( ); return c; } }; @@ -189,54 +168,46 @@ class recursiveEntDescripIterator /** Recursive breadth-first input iterator for supertypes * \sa subtypesIterator */ -class supertypesIterator : public recursiveEntDescripIterator -{ +class supertypesIterator : public recursiveEntDescripIterator { protected: - EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList - { - if(!t) { + EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList + if( !t ) { return 0; } - return (EntityDescLinkNode *) t->Supertypes().GetHead(); + return ( EntityDescLinkNode * ) t->Supertypes().GetHead(); } - EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode - { - if(!n) { + EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode + if( !n ) { return 0; } return n->EntityDesc(); } public: - supertypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) - { - reset(t); + supertypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { + reset( t ); } }; /** Recursive breadth-first input iterator for subtypes * \sa supertypesIterator */ -class subtypesIterator: public recursiveEntDescripIterator -{ +class subtypesIterator: public recursiveEntDescripIterator { protected: - EntityDescLinkNode *listHead(const EntityDescriptor *t) const ///< returns the head of an EntityDescriptorList - { - if(!t) { + EntityDescLinkNode * listHead( const EntityDescriptor * t ) const { ///< returns the head of an EntityDescriptorList + if( !t ) { return 0; } - return (EntityDescLinkNode *) t->Subtypes().GetHead(); + return ( EntityDescLinkNode * ) t->Subtypes().GetHead(); } - EntityDescriptor *nodeContent(const EntityDescLinkNode *n) const ///< returns the content of a EntityDescLinkNode - { - if(!n) { + EntityDescriptor * nodeContent( const EntityDescLinkNode * n ) const { ///< returns the content of a EntityDescLinkNode + if( !n ) { return 0; } return n->EntityDesc(); } public: - subtypesIterator(const EntityDescriptor *t = 0): recursiveEntDescripIterator(t) - { - reset(t); + subtypesIterator( const EntityDescriptor * t = 0 ): recursiveEntDescripIterator( t ) { + reset( t ); } }; diff --git a/src/clstepcore/aggrTypeDescriptor.cc b/src/clstepcore/aggrTypeDescriptor.cc index 6b6a5857e..91bed40be 100644 --- a/src/clstepcore/aggrTypeDescriptor.cc +++ b/src/clstepcore/aggrTypeDescriptor.cc @@ -1,36 +1,31 @@ #include "aggrTypeDescriptor.h" -STEPaggregate *AggrTypeDescriptor::CreateAggregate() -{ - if(CreateNewAggr) { +STEPaggregate * AggrTypeDescriptor::CreateAggregate() { + if( CreateNewAggr ) { return CreateNewAggr(); } else { return 0; } } -void AggrTypeDescriptor::AssignAggrCreator(AggregateCreator f) -{ +void AggrTypeDescriptor::AssignAggrCreator( AggregateCreator f ) { CreateNewAggr = f; } -AggrTypeDescriptor::AggrTypeDescriptor() : - _uniqueElements("UNKNOWN_TYPE") -{ +AggrTypeDescriptor::AggrTypeDescriptor( ) : +_uniqueElements( "UNKNOWN_TYPE" ) { _bound1 = -1; _bound2 = -1; _aggrDomainType = 0; } -AggrTypeDescriptor::AggrTypeDescriptor(SDAI_Integer b1, - SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor *aggrDomType) - : _bound1(b1), _bound2(b2), _uniqueElements(uniqElem) -{ +AggrTypeDescriptor::AggrTypeDescriptor( SDAI_Integer b1, + SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor * aggrDomType ) +: _bound1( b1 ), _bound2( b2 ), _uniqueElements( uniqElem ) { _aggrDomainType = aggrDomType; } -AggrTypeDescriptor::~AggrTypeDescriptor() -{ +AggrTypeDescriptor::~AggrTypeDescriptor() { } diff --git a/src/clstepcore/aggrTypeDescriptor.h b/src/clstepcore/aggrTypeDescriptor.h index 98da5579d..850a6b2e7 100644 --- a/src/clstepcore/aggrTypeDescriptor.h +++ b/src/clstepcore/aggrTypeDescriptor.h @@ -24,232 +24,203 @@ enum AggrBoundTypeEnum { * together by the _aggrDomainType variables. If you can make this * work then go for it. */ -class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor { - protected: +protected: - SDAI_Integer _bound1, _bound2; - SDAI_LOGICAL _uniqueElements; - TypeDescriptor *_aggrDomainType; - AggregateCreator CreateNewAggr; + SDAI_Integer _bound1, _bound2; + SDAI_LOGICAL _uniqueElements; + TypeDescriptor * _aggrDomainType; + AggregateCreator CreateNewAggr; - AggrBoundTypeEnum _bound1_type, _bound2_type; - boundCallbackFn _bound1_callback, _bound2_callback; + AggrBoundTypeEnum _bound1_type, _bound2_type; + boundCallbackFn _bound1_callback, _bound2_callback; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::string _bound1_str, _bound2_str; + std::string _bound1_str, _bound2_str; #ifdef _MSC_VER #pragma warning( pop ) #endif - public: - - void AssignAggrCreator(AggregateCreator f = 0); - - STEPaggregate *CreateAggregate(); - - AggrTypeDescriptor(); - AggrTypeDescriptor(SDAI_Integer b1, SDAI_Integer b2, - Logical uniqElem, - TypeDescriptor *aggrDomType); - AggrTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : TypeDescriptor(nm, ft, origSchema, d), _bound1(0), _bound2(0), _uniqueElements(0), _aggrDomainType(NULL), CreateNewAggr(f) { } - virtual ~AggrTypeDescriptor(); - - - /// find bound type - AggrBoundTypeEnum Bound1Type() const - { - return _bound1_type; - } - /// get a constant bound - SDAI_Integer Bound1() const - { - assert(_bound1_type == bound_constant); - return _bound1; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound1Runtime(SDAI_Application_instance *this_ptr) const - { - assert(this_ptr && (_bound1_type == bound_runtime)); - return _bound1_callback(this_ptr) ; - } - /// get a bound's EXPRESS function call string - std::string Bound1Funcall() const - { - return _bound1_str; - } - /// set bound to a constant - void SetBound1(SDAI_Integer b1) - { - _bound1 = b1; - _bound1_type = bound_constant; - } - ///set bound's callback fn. only for bounds dependent on an attribute - void SetBound1FromMemberAccessor(boundCallbackFn callback) - { - _bound1_callback = callback; - _bound1_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound1FromExpressFuncall(std::string s) - { - _bound1_str = s; - _bound1_type = bound_funcall; - } - - /// find bound type - AggrBoundTypeEnum Bound2Type() const - { - return _bound2_type; - } - /// get a constant bound - SDAI_Integer Bound2() const - { - assert(_bound2_type == bound_constant); - return _bound2; - } - /// get a runtime bound using an object's 'this' pointer - SDAI_Integer Bound2Runtime(SDAI_Application_instance *this_ptr) const - { - assert(this_ptr && (_bound2_type == bound_runtime)); - return _bound2_callback(this_ptr) ; - } - /// get a bound's EXPRESS function call string - std::string Bound2Funcall() const - { - return _bound2_str; - } - /// set bound to a constant - void SetBound2(SDAI_Integer b2) - { - _bound2 = b2; - _bound2_type = bound_constant; - } - ///set bound's callback fn - void SetBound2FromMemberAccessor(boundCallbackFn callback) - { - _bound2_callback = callback; - _bound2_type = bound_runtime; - } - ///set bound from express function call. currently, this only stores the function call as a string. - void SetBound2FromExpressFuncall(std::string s) - { - _bound2_str = s; - _bound2_type = bound_funcall; - } - - SDAI_LOGICAL &UniqueElements() - { - return _uniqueElements; - } - void UniqueElements(SDAI_LOGICAL &ue) - { - _uniqueElements.put(ue.asInt()); - } - void UniqueElements(Logical ue) - { - _uniqueElements.put(ue); - } - void UniqueElements(const char *ue) - { - _uniqueElements.put(ue); - } - - class TypeDescriptor *AggrDomainType() - { - return _aggrDomainType; - } - void AggrDomainType(TypeDescriptor *adt) - { - _aggrDomainType = adt; - } +public: + + void AssignAggrCreator( AggregateCreator f = 0 ); + + STEPaggregate * CreateAggregate(); + + AggrTypeDescriptor( ); + AggrTypeDescriptor( SDAI_Integer b1, SDAI_Integer b2, + Logical uniqElem, + TypeDescriptor * aggrDomType ); + AggrTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ) { } + virtual ~AggrTypeDescriptor(); + + + /// find bound type + AggrBoundTypeEnum Bound1Type() const { + return _bound1_type; + } + /// get a constant bound + SDAI_Integer Bound1( ) const { + assert( _bound1_type == bound_constant ); + return _bound1; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound1Runtime( SDAI_Application_instance * this_ptr ) const { + assert( this_ptr && ( _bound1_type == bound_runtime ) ); + return _bound1_callback( this_ptr ) ; + } + /// get a bound's EXPRESS function call string + std::string Bound1Funcall() const { + return _bound1_str; + } + /// set bound to a constant + void SetBound1( SDAI_Integer b1 ) { + _bound1 = b1; + _bound1_type = bound_constant; + } + ///set bound's callback fn. only for bounds dependent on an attribute + void SetBound1FromMemberAccessor( boundCallbackFn callback ) { + _bound1_callback = callback; + _bound1_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound1FromExpressFuncall( std::string s ) { + _bound1_str = s; + _bound1_type = bound_funcall; + } + + /// find bound type + AggrBoundTypeEnum Bound2Type() const { + return _bound2_type; + } + /// get a constant bound + SDAI_Integer Bound2( ) const { + assert( _bound2_type == bound_constant ); + return _bound2; + } + /// get a runtime bound using an object's 'this' pointer + SDAI_Integer Bound2Runtime( SDAI_Application_instance * this_ptr ) const { + assert( this_ptr && ( _bound2_type == bound_runtime ) ); + return _bound2_callback( this_ptr ) ; + } + /// get a bound's EXPRESS function call string + std::string Bound2Funcall() const { + return _bound2_str; + } + /// set bound to a constant + void SetBound2( SDAI_Integer b2 ) { + _bound2 = b2; + _bound2_type = bound_constant; + } + ///set bound's callback fn + void SetBound2FromMemberAccessor( boundCallbackFn callback ) { + _bound2_callback = callback; + _bound2_type = bound_runtime; + } + ///set bound from express function call. currently, this only stores the function call as a string. + void SetBound2FromExpressFuncall( std::string s ) { + _bound2_str = s; + _bound2_type = bound_funcall; + } + + SDAI_LOGICAL & UniqueElements() { + return _uniqueElements; + } + void UniqueElements( SDAI_LOGICAL & ue ) { + _uniqueElements.put( ue.asInt() ); + } + void UniqueElements( Logical ue ) { + _uniqueElements.put( ue ); + } + void UniqueElements( const char * ue ) { + _uniqueElements.put( ue ); + } + + class TypeDescriptor * AggrDomainType() { + return _aggrDomainType; + } + void AggrDomainType( TypeDescriptor * adt ) { + _aggrDomainType = adt; + } }; -class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor -{ - - protected: - SDAI_LOGICAL _optionalElements; - public: - - ArrayTypeDescriptor() : _optionalElements("UNKNOWN_TYPE") { } - ArrayTypeDescriptor(Logical optElem) : _optionalElements(optElem) - { } - ArrayTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f), - _optionalElements("UNKNOWN_TYPE") - { } - - virtual ~ArrayTypeDescriptor() {} - - - SDAI_LOGICAL &OptionalElements() - { - return _optionalElements; - } - void OptionalElements(SDAI_LOGICAL &oe) - { - _optionalElements.put(oe.asInt()); - } - void OptionalElements(Logical oe) - { - _optionalElements.put(oe); - } - void OptionalElements(const char *oe) - { - _optionalElements.put(oe); - } +class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor { + +protected: + SDAI_LOGICAL _optionalElements; +public: + + ArrayTypeDescriptor( ) : _optionalElements( "UNKNOWN_TYPE" ) { } + ArrayTypeDescriptor( Logical optElem ) : _optionalElements( optElem ) + { } + ArrayTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ), + _optionalElements( "UNKNOWN_TYPE" ) + { } + + virtual ~ArrayTypeDescriptor() {} + + + SDAI_LOGICAL & OptionalElements() { + return _optionalElements; + } + void OptionalElements( SDAI_LOGICAL & oe ) { + _optionalElements.put( oe.asInt() ); + } + void OptionalElements( Logical oe ) { + _optionalElements.put( oe ); + } + void OptionalElements( const char * oe ) { + _optionalElements.put( oe ); + } }; -class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor { - protected: - public: - ListTypeDescriptor() { } - ListTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~ListTypeDescriptor() { } +protected: +public: + ListTypeDescriptor( ) { } + ListTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~ListTypeDescriptor() { } }; -class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor { - protected: - public: +protected: +public: - SetTypeDescriptor() { } - SetTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~SetTypeDescriptor() { } + SetTypeDescriptor( ) { } + SetTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~SetTypeDescriptor() { } }; -class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor -{ +class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor { - protected: - public: +protected: +public: - BagTypeDescriptor() { } - BagTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - AggregateCreator f = 0) - : AggrTypeDescriptor(nm, ft, origSchema, d, f) { } - virtual ~BagTypeDescriptor() { } + BagTypeDescriptor( ) { } + BagTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + AggregateCreator f = 0 ) + : AggrTypeDescriptor( nm, ft, origSchema, d, f ) { } + virtual ~BagTypeDescriptor() { } }; diff --git a/src/clstepcore/attrDescriptor.cc b/src/clstepcore/attrDescriptor.cc index f95b8dfaa..329d90393 100644 --- a/src/clstepcore/attrDescriptor.cc +++ b/src/clstepcore/attrDescriptor.cc @@ -1,115 +1,101 @@ #include "attrDescriptor.h" -AttrDescriptor::AttrDescriptor(const char *name, const TypeDescriptor *domainType, - Logical optional, Logical unique, AttrType_Enum at, - const EntityDescriptor &owner) - : _name(name), _domainType(domainType), _optional(optional), - _unique(unique), _attrType(at), _owner((EntityDescriptor &)owner) -{ +AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType, + Logical optional, Logical unique, AttrType_Enum at, + const EntityDescriptor & owner ) + : _name( name ), _domainType( domainType ), _optional( optional ), + _unique( unique ), _attrType( at ), _owner( ( EntityDescriptor & )owner ) { } -AttrDescriptor::~AttrDescriptor() -{ +AttrDescriptor::~AttrDescriptor() { } -Logical AttrDescriptor::Explicit() const -{ - if(_attrType == AttrType_Explicit) { +Logical AttrDescriptor::Explicit() const { + if( _attrType == AttrType_Explicit ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Inverse() const -{ - if(_attrType == AttrType_Inverse) { +Logical AttrDescriptor::Inverse() const { + if( _attrType == AttrType_Inverse ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Redefining() const -{ - if(_attrType == AttrType_Redefining) { +Logical AttrDescriptor::Redefining() const { + if( _attrType == AttrType_Redefining ) { return LTrue; } return LFalse; } -Logical AttrDescriptor::Deriving() const -{ - if(_attrType == AttrType_Deriving) { +Logical AttrDescriptor::Deriving() const { + if( _attrType == AttrType_Deriving ) { return LTrue; } return LFalse; } -const char *AttrDescriptor::AttrExprDefStr(std::string &s) const -{ +const char * AttrDescriptor::AttrExprDefStr( std::string & s ) const { std::string buf; s = Name(); - s.append(" : "); - if(_optional.asInt() == LTrue) { - s.append("OPTIONAL "); + s.append( " : " ); + if( _optional.asInt() == LTrue ) { + s.append( "OPTIONAL " ); } - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -PrimitiveType AttrDescriptor::BaseType() const -{ - if(_domainType) { +PrimitiveType AttrDescriptor::BaseType() const { + if( _domainType ) { return _domainType->BaseType(); } return UNKNOWN_TYPE; } -int AttrDescriptor::IsAggrType() const -{ +int AttrDescriptor::IsAggrType() const { return ReferentType()->IsAggrType(); } -PrimitiveType AttrDescriptor::AggrElemType() const -{ - if(IsAggrType()) { +PrimitiveType AttrDescriptor::AggrElemType() const { + if( IsAggrType() ) { return ReferentType()->AggrElemType(); } return UNKNOWN_TYPE; } -const TypeDescriptor *AttrDescriptor::AggrElemTypeDescriptor() const -{ - if(IsAggrType()) { +const TypeDescriptor * AttrDescriptor::AggrElemTypeDescriptor() const { + if( IsAggrType() ) { return ReferentType()->AggrElemTypeDescriptor(); } return 0; } -const TypeDescriptor *AttrDescriptor::NonRefTypeDescriptor() const -{ - if(_domainType) { +const TypeDescriptor * AttrDescriptor::NonRefTypeDescriptor() const { + if( _domainType ) { return _domainType->NonRefTypeDescriptor(); } return 0; } PrimitiveType -AttrDescriptor::NonRefType() const -{ - if(_domainType) { +AttrDescriptor::NonRefType() const { + if( _domainType ) { return _domainType->NonRefType(); } return UNKNOWN_TYPE; } PrimitiveType -AttrDescriptor::Type() const -{ - if(_domainType) { +AttrDescriptor::Type() const { + if( _domainType ) { return _domainType->Type(); } return UNKNOWN_TYPE; @@ -119,37 +105,34 @@ AttrDescriptor::Type() const * right side of attr def * NOTE this returns a \'const char * \' instead of an std::string */ -const std::string AttrDescriptor::TypeName() const -{ +const std::string AttrDescriptor::TypeName() const { std::string buf; - if(_domainType) { - _domainType->AttrTypeName(buf); + if( _domainType ) { + _domainType->AttrTypeName( buf ); } return buf; } /// an expanded right side of attr def const char * -AttrDescriptor::ExpandedTypeName(std::string &s) const -{ +AttrDescriptor::ExpandedTypeName( std::string & s ) const { s.clear(); - if(Derived() == LTrue) { + if( Derived() == LTrue ) { s = "DERIVE "; } - if(_domainType) { + if( _domainType ) { std::string tmp; - return const_cast((s.append(_domainType->TypeString(tmp)).c_str())); + return const_cast( ( s.append( _domainType->TypeString( tmp ) ).c_str() ) ); } else { return 0; } } -const char *AttrDescriptor::GenerateExpress(std::string &buf) const -{ +const char * AttrDescriptor::GenerateExpress( std::string & buf ) const { std::string sstr; - buf = AttrExprDefStr(sstr); - buf.append(";\n"); - return const_cast(buf.c_str()); + buf = AttrExprDefStr( sstr ); + buf.append( ";\n" ); + return const_cast( buf.c_str() ); } diff --git a/src/clstepcore/attrDescriptor.h b/src/clstepcore/attrDescriptor.h index f681e111e..cee4d13bc 100644 --- a/src/clstepcore/attrDescriptor.h +++ b/src/clstepcore/attrDescriptor.h @@ -20,42 +20,39 @@ class EntityDescriptor; * An instance of this class will be generated for each attribute for * an Entity. They will be pointed to by the EntityTypeDescriptors. */ -class SC_CORE_EXPORT AttrDescriptor -{ +class SC_CORE_EXPORT AttrDescriptor { protected: - const char *_name; // the attributes name + const char * _name; // the attributes name // this defines the domain of the attribute - const TypeDescriptor *_domainType; + const TypeDescriptor * _domainType; SDAI_LOGICAL _optional; SDAI_LOGICAL _unique; AttrType_Enum _attrType; // former attribute _derived - const EntityDescriptor &_owner; // the owning entityDescriptor + const EntityDescriptor & _owner; // the owning entityDescriptor public: AttrDescriptor( - const char *name, // i.e. char * - const TypeDescriptor *domainType, + const char * name, // i.e. char * + const TypeDescriptor * domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor &owner + const EntityDescriptor & owner ); virtual ~AttrDescriptor(); - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; // the attribute Express def - virtual const char *AttrExprDefStr(std::string &s) const; + virtual const char * AttrExprDefStr( std::string & s ) const; // left side of attr def - const char *Name() const - { + const char * Name() const { return _name; } - void Name(const char *n) - { + void Name( const char * n ) { _name = n; } @@ -79,7 +76,7 @@ class SC_CORE_EXPORT AttrDescriptor */ ///@{ PrimitiveType BaseType() const; - const TypeDescriptor *BaseTypeDescriptor() const; + const TypeDescriptor * BaseTypeDescriptor() const; ///@} /** @@ -95,12 +92,12 @@ class SC_CORE_EXPORT AttrDescriptor */ ///@{ PrimitiveType NonRefType() const; - const TypeDescriptor *NonRefTypeDescriptor() const; + const TypeDescriptor * NonRefTypeDescriptor() const; ///@} int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor *AggrElemTypeDescriptor() const; + const TypeDescriptor * AggrElemTypeDescriptor() const; /// The type of the attributes TypeDescriptor PrimitiveType Type() const; @@ -109,71 +106,56 @@ class SC_CORE_EXPORT AttrDescriptor const std::string TypeName() const; /// an expanded right side of attr def - const char *ExpandedTypeName(std::string &s) const; + const char * ExpandedTypeName( std::string & s ) const; - int RefersToType() const - { - return !(_domainType == 0); + int RefersToType() const { + return !( _domainType == 0 ); } - const TypeDescriptor *ReferentType() const - { + const TypeDescriptor * ReferentType() const { return _domainType; } - const TypeDescriptor *DomainType() const - { + const TypeDescriptor * DomainType() const { return _domainType; } - void DomainType(const TypeDescriptor *td) - { + void DomainType( const TypeDescriptor * td ) { _domainType = td; } - void ReferentType(const TypeDescriptor *td) - { + void ReferentType( const TypeDescriptor * td ) { _domainType = td; } - const SDAI_LOGICAL &Optional() const - { + const SDAI_LOGICAL & Optional() const { return _optional; } - void Optional(SDAI_LOGICAL &opt) - { - _optional.put(opt.asInt()); + void Optional( SDAI_LOGICAL & opt ) { + _optional.put( opt.asInt() ); } - void Optional(Logical opt) - { - _optional.put(opt); + void Optional( Logical opt ) { + _optional.put( opt ); } - void Optional(const char *opt) - { - _optional.put(opt); + void Optional( const char * opt ) { + _optional.put( opt ); } - const SDAI_LOGICAL &Unique() const - { + const SDAI_LOGICAL & Unique() const { return _unique; } - void Unique(SDAI_LOGICAL uniq) - { - _unique.put(uniq.asInt()); + void Unique( SDAI_LOGICAL uniq ) { + _unique.put( uniq.asInt() ); } - void Unique(Logical uniq) - { - _unique.put(uniq); + void Unique( Logical uniq ) { + _unique.put( uniq ); } - void Unique(const char *uniq) - { - _unique.put(uniq); + void Unique( const char * uniq ) { + _unique.put( uniq ); } - void AttrType(enum AttrType_Enum ate) - { + void AttrType( enum AttrType_Enum ate ) { _attrType = ate; } - enum AttrType_Enum AttrType() const - { + enum AttrType_Enum AttrType() const { return _attrType; } @@ -183,50 +165,40 @@ class SC_CORE_EXPORT AttrDescriptor Logical Deriving() const; //outdated functions, use AttrType func above, new support of redefined - Logical Derived() const - { + Logical Derived() const { return Deriving(); } - void Derived(Logical x); // outdated DAS - void Derived(SDAI_LOGICAL x); // outdated DAS - void Derived(const char *x); // outdated DAS + void Derived( Logical x ); // outdated DAS + void Derived( SDAI_LOGICAL x ); // outdated DAS + void Derived( const char * x ); // outdated DAS - const SDAI_LOGICAL &Optionality() const - { + const SDAI_LOGICAL & Optionality() const { return _optional; } - void Optionality(SDAI_LOGICAL &opt) - { - _optional.put(opt.asInt()); + void Optionality( SDAI_LOGICAL & opt ) { + _optional.put( opt.asInt() ); } - void Optionality(Logical opt) - { - _optional.put(opt); + void Optionality( Logical opt ) { + _optional.put( opt ); } - void Optionality(const char *opt) - { - _optional.put(opt); + void Optionality( const char * opt ) { + _optional.put( opt ); } - const SDAI_LOGICAL &Uniqueness() const - { + const SDAI_LOGICAL & Uniqueness() const { return _unique; } - void Uniqueness(SDAI_LOGICAL uniq) - { - _unique.put(uniq.asInt()); + void Uniqueness( SDAI_LOGICAL uniq ) { + _unique.put( uniq.asInt() ); } - void Uniqueness(Logical uniq) - { - _unique.put(uniq); + void Uniqueness( Logical uniq ) { + _unique.put( uniq ); } - void Uniqueness(const char *uniq) - { - _unique.put(uniq); + void Uniqueness( const char * uniq ) { + _unique.put( uniq ); } - const EntityDescriptor &Owner() const - { + const EntityDescriptor & Owner() const { return _owner; } }; diff --git a/src/clstepcore/attrDescriptorList.cc b/src/clstepcore/attrDescriptorList.cc index e75f23c41..c197ac5e2 100644 --- a/src/clstepcore/attrDescriptorList.cc +++ b/src/clstepcore/attrDescriptorList.cc @@ -2,48 +2,40 @@ #include "attrDescriptor.h" -AttrDescriptorList::AttrDescriptorList() -{ +AttrDescriptorList::AttrDescriptorList() { } -AttrDescriptorList::~AttrDescriptorList() -{ +AttrDescriptorList::~AttrDescriptorList() { } -AttrDescLinkNode *AttrDescriptorList::AddNode(AttrDescriptor *ad) -{ - AttrDescLinkNode *node = (AttrDescLinkNode *) NewNode(); - node->AttrDesc(ad); - SingleLinkList::AppendNode(node); +AttrDescLinkNode * AttrDescriptorList::AddNode( AttrDescriptor * ad ) { + AttrDescLinkNode * node = ( AttrDescLinkNode * ) NewNode(); + node->AttrDesc( ad ); + SingleLinkList::AppendNode( node ); return node; } -AttrDescLinkNode::AttrDescLinkNode() -{ +AttrDescLinkNode::AttrDescLinkNode() { _attrDesc = 0; } -AttrDescLinkNode::~AttrDescLinkNode() -{ - if(_attrDesc) { +AttrDescLinkNode::~AttrDescLinkNode() { + if( _attrDesc ) { delete _attrDesc; } } -AttrDescItr::AttrDescItr(const AttrDescriptorList &adList) : adl(adList) -{ - cur = (AttrDescLinkNode *)(adl.GetHead()); +AttrDescItr::AttrDescItr( const AttrDescriptorList & adList ) : adl( adList ) { + cur = ( AttrDescLinkNode * )( adl.GetHead() ); } -AttrDescItr::~AttrDescItr() -{ +AttrDescItr::~AttrDescItr() { } -const AttrDescriptor *AttrDescItr::NextAttrDesc() -{ - if(cur) { - const AttrDescriptor *ad = cur->AttrDesc(); - cur = (AttrDescLinkNode *)(cur->NextNode()); +const AttrDescriptor * AttrDescItr::NextAttrDesc() { + if( cur ) { + const AttrDescriptor * ad = cur->AttrDesc(); + cur = ( AttrDescLinkNode * )( cur->NextNode() ); return ad; } return 0; diff --git a/src/clstepcore/attrDescriptorList.h b/src/clstepcore/attrDescriptorList.h index c6550ba82..a1c844a8f 100644 --- a/src/clstepcore/attrDescriptorList.h +++ b/src/clstepcore/attrDescriptorList.h @@ -9,57 +9,50 @@ class AttrDescriptor; -class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode { private: protected: - AttrDescriptor *_attrDesc; + AttrDescriptor * _attrDesc; public: AttrDescLinkNode(); virtual ~AttrDescLinkNode(); - const AttrDescriptor *AttrDesc() const - { + const AttrDescriptor * AttrDesc() const { return _attrDesc; } - void AttrDesc(AttrDescriptor *ad) - { + void AttrDesc( AttrDescriptor * ad ) { _attrDesc = ad; } }; -class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT AttrDescriptorList : public SingleLinkList { private: protected: public: AttrDescriptorList(); virtual ~AttrDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new AttrDescLinkNode; } - AttrDescLinkNode *AddNode(AttrDescriptor *ad); + AttrDescLinkNode * AddNode( AttrDescriptor * ad ); }; -class SC_CORE_EXPORT AttrDescItr -{ +class SC_CORE_EXPORT AttrDescItr { protected: - const AttrDescriptorList &adl; - const AttrDescLinkNode *cur; + const AttrDescriptorList & adl; + const AttrDescLinkNode * cur; public: - AttrDescItr(const AttrDescriptorList &adList); + AttrDescItr( const AttrDescriptorList & adList ); virtual ~AttrDescItr(); - void ResetItr() - { - cur = (AttrDescLinkNode *)(adl.GetHead()); + void ResetItr() { + cur = ( AttrDescLinkNode * )( adl.GetHead() ); } - const AttrDescriptor *NextAttrDesc(); + const AttrDescriptor * NextAttrDesc(); }; #endif //ATTRDESCRIPTORLIST_H diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index 92c95cc88..b6abef73c 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -18,15 +18,14 @@ * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ -void ComplexCollect::insert(ComplexList *c) -{ - ComplexList *prev = NULL, *cl = clists; +void ComplexCollect::insert( ComplexList * c ) { + ComplexList * prev = NULL, *cl = clists; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(prev == NULL) { + if( prev == NULL ) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -47,19 +46,18 @@ void ComplexCollect::insert(ComplexList *c) * be able to find it, and now that all its supers have accessed it, we * remove it from the Collect. */ -void ComplexCollect::remove(ComplexList *c) -{ - ComplexList *cl = clists, *prev = NULL; +void ComplexCollect::remove( ComplexList * c ) { + ComplexList * cl = clists, *prev = NULL; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(cl == NULL || cl != c) { + if( cl == NULL || cl != c ) { // Just in case c isn't in the list. return; } - if(prev == NULL) { + if( prev == NULL ) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -73,14 +71,13 @@ void ComplexCollect::remove(ComplexList *c) /** * Searches for and returns the ComplexList whose supertype name = name. */ -ComplexList *ComplexCollect::find(char *name) -{ - ComplexList *cl = clists; +ComplexList * ComplexCollect::find( char * name ) { + ComplexList * cl = clists; - while(cl && *cl < name) { + while( cl && *cl < name ) { cl = cl->next; } - if(cl && *cl == name) { + if( cl && *cl == name ) { return cl; } return NULL; @@ -94,38 +91,37 @@ ComplexList *ComplexCollect::find(char *name) * should be included in >1 CList. A more complicated algorithm is applied * to match it, as described in the commenting. */ -bool ComplexCollect::supports(EntNode *ents) const -{ - EntNode *node = ents, *nextnode; - AndList *alist = 0; - ComplexList *clist = clists, *cl = NULL, *current; +bool ComplexCollect::supports( EntNode * ents ) const { + EntNode * node = ents, *nextnode; + AndList * alist = 0; + ComplexList * clist = clists, *cl = NULL, *current; bool retval; - EntList *elist, *next; + EntList * elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while(node) { - if(node->multSuprs()) { + while( node ) { + if( node->multSuprs() ) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if(!cl) { + if( !cl ) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList(alist); + cl = new ComplexList( alist ); } current = clists; - while(current) { - if(current->contains(node)) { + while( current ) { + if( current->contains( node ) ) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if(! cl->toplevel(current->supertype())) { + if( ! cl->toplevel( current->supertype() ) ) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList(current->head->childList); + alist->appendList( current->head->childList ); } } current = current->next; @@ -137,11 +133,11 @@ bool ComplexCollect::supports(EntNode *ents) const // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if(!cl) { + if( !cl ) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while(clist != NULL) { - if(clist->matches(ents)) { + while( clist != NULL ) { + if( clist->matches( ents ) ) { return true; } clist = clist->next; @@ -152,13 +148,13 @@ bool ComplexCollect::supports(EntNode *ents) const // Use cl to test that the conditions of all supertypes are met: cl->multSupers = true; cl->buildList(); - retval = cl->matches(ents); + retval = cl->matches( ents ); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while(elist) { + while( elist ) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index 860bac36e..46b673b46 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -72,8 +72,7 @@ class OrList; class ComplexList; class ComplexCollect; -class SC_CORE_EXPORT EntNode -{ +class SC_CORE_EXPORT EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -81,108 +80,90 @@ class SC_CORE_EXPORT EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), multSupers(0) - { - StrToLower(nm, name); - } - EntNode(const char **); ///< given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), multSupers( 0 ) { + StrToLower( nm, name ); + } + EntNode( const char ** ); ///< given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - bool operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + bool operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - bool operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + bool operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - bool operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + bool operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - EntNode &operator= (EntNode &ent); - void Name(const char *nm) - { - strncpy(name, nm, BUFSIZ - 1); + EntNode & operator= ( EntNode & ent ); + void Name( const char * nm ) { + strncpy( name, nm, BUFSIZ - 1 ); } - const char *Name() - { + const char * Name() { return name; } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - bool marked(MarkType base = ORMARK) - { - return (mark >= base); + bool marked( MarkType base = ORMARK ) { + return ( mark >= base ); } bool allMarked(); ///< returns true if all nodes in list are marked int unmarkedCount(); - bool multSuprs() - { + bool multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - void sort(EntNode **); + void sort( EntNode ** ); - EntNode *next; + EntNode * next; private: MarkType mark; char name[BUFSIZ]; bool multSupers; ///< do I correspond to an entity with >1 supertype? - EntNode *lastSmaller(EntNode *); ///< used by ::sort() + EntNode * lastSmaller( EntNode * ); ///< used by ::sort() }; -class SC_CORE_EXPORT EntList -{ +class SC_CORE_EXPORT EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), next(0), prev(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), next( 0 ), prev( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual bool contains(char *) = 0; - virtual bool hit(char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual bool contains( char * ) = 0; + virtual bool hit( char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual bool acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual bool acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); @@ -190,34 +171,28 @@ class SC_CORE_EXPORT EntList // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return (next) ? next->firstNot(j) : NULL; + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return (next) ? next->firstWanted(mat) : NULL; + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return (prev) ? prev->lastNot(j) : NULL; + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return (prev) ? prev->lastWanted(mat) : NULL; + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *next = NULL; - EntList *prev = NULL; + EntList * next, *prev; protected: MatchType viable; @@ -231,39 +206,32 @@ class SC_CORE_EXPORT EntList int level; ///< How many levels deep are we (main use for printing). }; -class SC_CORE_EXPORT SimpleList : public EntList -{ +class SC_CORE_EXPORT SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strncpy(name, n, sizeof(name) - 1); - name[sizeof(name) - 1] = '\0'; /* sanity */ + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strncpy( name, n, sizeof( name ) - 1 ); + name[sizeof( name ) - 1] = '\0'; /* sanity */ } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - bool contains(char *nm) - { + bool contains( char * nm ) { return *this == nm; } - bool hit(char *nm) - { + bool hit( char * nm ) { return *this == nm; } - MatchType matchNonORs(EntNode *); - bool acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + MatchType matchNonORs( EntNode * ); + bool acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } @@ -277,43 +245,40 @@ class SC_CORE_EXPORT SimpleList : public EntList * Supports concepts and functionality common to all the compound list * types, especially AND and ANDOR. */ -class SC_CORE_EXPORT MultList : public EntList -{ +class SC_CORE_EXPORT MultList : public EntList { friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), supertype(0), numchildren(0), - childList(0) {} + MultList( JoinType j ) : EntList( j ), supertype( 0 ), numchildren( 0 ), + childList( 0 ) {} ~MultList(); - void setLevel(int); - bool contains(char *); - bool hit(char *); - void appendList(EntList *); - EntList *copyList(EntList *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + void setLevel( int ); + bool contains( char * ); + bool hit( char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - bool prevKnown(EntList *); + void unmarkAll( EntNode * ); + bool prevKnown( EntList * ); void reset(); protected: int supertype; ///< do I represent a supertype? int numchildren; - EntList *childList; + EntList * childList; /** \var childList * Points to a list of "children" of this EntList. E.g., if join = * AND, it would point to a list of the entity types we are AND'ing. @@ -326,55 +291,49 @@ class SC_CORE_EXPORT MultList : public EntList * A specialized MultList, super for subtypes AndOrList and AndList, or * ones which join their multiple children. */ -class SC_CORE_EXPORT JoinList : public MultList -{ +class SC_CORE_EXPORT JoinList : public MultList { public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - bool acceptChoice(EntNode *); + void setViableVal( EntNode * ); + bool acceptChoice( EntNode * ); }; -class SC_CORE_EXPORT AndOrList : public JoinList -{ +class SC_CORE_EXPORT AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class SC_CORE_EXPORT AndList : public JoinList -{ +class SC_CORE_EXPORT AndList : public JoinList { friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND) {} + AndList() : JoinList( AND ) {} ~AndList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class SC_CORE_EXPORT OrList : public MultList -{ +class SC_CORE_EXPORT OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-1), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -1 ), choiceCount( 0 ) {} ~OrList() {} - bool hit(char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - bool acceptChoice(EntNode *); - bool acceptNextChoice(EntNode *ents) - { + bool hit( char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + bool acceptChoice( EntNode * ); + bool acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -391,80 +350,71 @@ class SC_CORE_EXPORT OrList : public MultList * Contains the entire list of EntLists which describe the set of * instantiable complex entities defined by an EXPRESS expression. */ -class SC_CORE_EXPORT ComplexList -{ +class SC_CORE_EXPORT ComplexList { friend class ultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return (dynamic_cast< SimpleList * >(head->childList))->name ; + const char * supertype() { + return ( dynamic_cast< SimpleList * >(head->childList ))->name ; } /** \fn supertype * Based on knowledge that ComplexList always created by ANDing supertype * with subtypes. */ - bool toplevel(const char *); - bool contains(EntNode *); - bool matches(EntNode *); + bool toplevel( const char * ); + bool contains( EntNode * ); + bool matches( EntNode * ); - EntNode *list; /**< List of all entities contained in this complex type, + EntNode * list; /**< List of all entities contained in this complex type, * regardless of how. (Used as a quick way of determining * if this List *may* contain a certain complex type.) */ - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } private: - void addChildren(EntList *); - bool hitMultNodes(EntNode *); + void addChildren( EntList * ); + bool hitMultNodes( EntNode * ); int abstract; ///< is our supertype abstract? int dependent; ///< is our supertype also a subtype of other supertype(s)? bool multSupers; ///< am I a combo-CList created to test a subtype which has >1 supertypes? }; /// The collection of all the ComplexLists defined by the current schema. -class SC_CORE_EXPORT ComplexCollect -{ +class SC_CORE_EXPORT ComplexCollect { public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ~ComplexCollect() - { + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. - ComplexList *find(char *); - bool supports(EntNode *) const; + void insert( ComplexList * ); + void remove( ComplexList * ); ///< Remove this list but don't delete its hierarchy structure, because it's used elsewhere. + ComplexList * find( char * ); + bool supports( EntNode * ) const; - ComplexList *clists; + ComplexList * clists; private: int count; ///< # of clist children diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index e2cea3ee0..2fc289381 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -16,9 +16,8 @@ /** * Destructor for ComplexList. */ -ComplexList::~ComplexList() -{ - if(next) { +ComplexList::~ComplexList() { + if( next ) { delete next; } delete head; @@ -32,8 +31,7 @@ ComplexList::~ComplexList() * the supertypes' ComplexLists, this temp one can be deleted. Its sub- * structure, however, cannot be deleted since it's still being used. */ -void ComplexList::remove() -{ +void ComplexList::remove() { head = NULL; // Only the overall AND will be deleted. delete this; @@ -45,16 +43,15 @@ void ComplexList::remove() * is a highly specialized function which is used during the building of * a temporary CList to test entities which are subtypes of >1 supertype. */ -bool ComplexList::toplevel(const char *name) -{ - EntList *slist = head->childList; +bool ComplexList::toplevel( const char * name ) { + EntList * slist = head->childList; - while(slist) { - if(* dynamic_cast< SimpleList * >(slist) == name) { + while( slist ) { + if( * dynamic_cast< SimpleList * >(slist) == name ) { return true; } slist = slist->next; - if(slist) { + if( slist ) { slist = slist->next; } } @@ -69,21 +66,20 @@ bool ComplexList::toplevel(const char *name) * entity which contains an entity which is not contained in list, this * ComplexList certainly can't support it. */ -void ComplexList::buildList() -{ - EntList *sibling = head->childList->next; +void ComplexList::buildList() { + EntList * sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if(list) { + if( list ) { delete list; } // Add first node based on supertype: - list = new EntNode((dynamic_cast< SimpleList * >(head->childList))->name); + list = new EntNode( ( dynamic_cast< SimpleList * >(head->childList ))->name ); // Recursively add all descendents: - while(sibling) { - addChildren(sibling); + while( sibling ) { + addChildren( sibling ); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -96,33 +92,32 @@ void ComplexList::buildList() * Recursive function to add all the SimpleList descendents of ent into * this's list. */ -void ComplexList::addChildren(EntList *ent) -{ - EntList *child; - char *nm; - EntNode *prev = list, *prev2 = NULL, *newnode; +void ComplexList::addChildren( EntList * ent ) { + EntList * child; + char * nm; + EntNode * prev = list, *prev2 = NULL, *newnode; int comp = 0; - if(ent->multiple()) { - child = ((MultList *)ent)->childList; - while(child) { - addChildren(child); + if( ent->multiple() ) { + child = ( ( MultList * )ent )->childList; + while( child ) { + addChildren( child ); child = child->next; } } else { - nm = (dynamic_cast(ent))->name; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + nm = ( dynamic_cast(ent) )->name; + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -141,15 +136,14 @@ void ComplexList::addChildren(EntList *ent) * tion is simplified greatly because both EntNodes are ordered alphabeti- * cally. */ -bool ComplexList::contains(EntNode *ents) -{ - EntNode *ours = list, *theirs = ents; +bool ComplexList::contains( EntNode * ents ) { + EntNode * ours = list, *theirs = ents; - while(theirs != NULL) { - while(ours != NULL && *ours < *theirs) { + while( theirs != NULL ) { + while( ours != NULL && *ours < *theirs ) { ours = ours->next; } - if(ours == NULL || *ours > *theirs) { + if( ours == NULL || *ours > *theirs ) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return false; @@ -168,39 +162,38 @@ bool ComplexList::contains(EntNode *ents) * can be instantiated based on the list of EntLists which were generated * when the schema was read; false otherwise. */ -bool ComplexList::matches(EntNode *ents) -{ +bool ComplexList::matches( EntNode * ents ) { MatchType retval; int result = false; // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if(! contains(ents)) { + if( ! contains( ents ) ) { return false; } // Now start a thorough search through this ComplexList: - if((retval = head->matchNonORs(ents)) == MATCHALL) { + if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { result = true; - } else if(retval != UNKNOWN) { + } else if( retval != UNKNOWN ) { result = false; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if(((retval = head->matchORs(ents)) == MATCHALL) && - (hitMultNodes(ents))) { + if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && + ( hitMultNodes( ents ) ) ) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = true; - } else if(retval >= MATCHSOME) { + } else if( retval >= MATCHSOME ) { // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): MatchType otherChoices = NEWCHOICE; - while(otherChoices == NEWCHOICE) { - otherChoices = head->tryNext(ents); - if(otherChoices == MATCHALL) { - if(hitMultNodes(ents)) { + while( otherChoices == NEWCHOICE ) { + otherChoices = head->tryNext( ents ); + if( otherChoices == MATCHALL ) { + if( hitMultNodes( ents ) ) { result = true; } else { otherChoices = NEWCHOICE; @@ -229,36 +222,35 @@ bool ComplexList::matches(EntNode *ents) * valid. (This function is actually slightly more complicated because it * also deals with the possibility that >1 entities like C exist.) */ -bool ComplexList::hitMultNodes(EntNode *ents) -{ - EntNode *node; - EntList *child; +bool ComplexList::hitMultNodes( EntNode * ents ) { + EntNode * node; + EntList * child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if(!multSupers) { + if( !multSupers ) { return true; } - for(node = ents; node != NULL; node = node->next) { - if(node->multSuprs()) { + for( node = ents; node != NULL; node = node->next ) { + if( node->multSuprs() ) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while(child) { + while( child ) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if(child->contains(node->name)) { - if(! child->hit(node->name)) { + if( child->contains( node->name ) ) { + if( ! child->hit( node->name ) ) { return false; } } child = child->next; - if(child) { + if( child ) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 154e1be60..72f6adb53 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,42 +1,34 @@ #include "create_Aggr.h" #include -EnumAggregate *create_EnumAggregate() -{ +EnumAggregate * create_EnumAggregate() { return new EnumAggregate; } -GenericAggregate *create_GenericAggregate() -{ +GenericAggregate * create_GenericAggregate() { return new GenericAggregate; } -EntityAggregate *create_EntityAggregate() -{ +EntityAggregate * create_EntityAggregate() { return new EntityAggregate; } -SelectAggregate *create_SelectAggregate() -{ +SelectAggregate * create_SelectAggregate() { return new SelectAggregate; } -StringAggregate *create_StringAggregate() -{ +StringAggregate * create_StringAggregate() { return new StringAggregate; } -BinaryAggregate *create_BinaryAggregate() -{ +BinaryAggregate * create_BinaryAggregate() { return new BinaryAggregate; } -RealAggregate *create_RealAggregate() -{ +RealAggregate * create_RealAggregate() { return new RealAggregate; } -IntAggregate *create_IntAggregate() -{ +IntAggregate * create_IntAggregate() { return new IntAggregate; } diff --git a/src/clstepcore/create_Aggr.h b/src/clstepcore/create_Aggr.h index 61918e06a..a0483fa66 100644 --- a/src/clstepcore/create_Aggr.h +++ b/src/clstepcore/create_Aggr.h @@ -17,32 +17,32 @@ class BinaryAggregate; class RealAggregate; class IntAggregate; -typedef STEPaggregate *(* AggregateCreator)(); -typedef EnumAggregate *(* EnumAggregateCreator)(); -typedef GenericAggregate *(* GenericAggregateCreator)(); -typedef EntityAggregate *(* EntityAggregateCreator)(); -typedef SelectAggregate *(* SelectAggregateCreator)(); -typedef StringAggregate *(* StringAggregateCreator)(); -typedef BinaryAggregate *(* BinaryAggregateCreator)(); -typedef RealAggregate *(* RealAggregateCreator)(); -typedef IntAggregate *(* IntAggregateCreator)(); +typedef STEPaggregate * ( * AggregateCreator )(); +typedef EnumAggregate * ( * EnumAggregateCreator )(); +typedef GenericAggregate * ( * GenericAggregateCreator )(); +typedef EntityAggregate * ( * EntityAggregateCreator )(); +typedef SelectAggregate * ( * SelectAggregateCreator )(); +typedef StringAggregate * ( * StringAggregateCreator )(); +typedef BinaryAggregate * ( * BinaryAggregateCreator )(); +typedef RealAggregate * ( * RealAggregateCreator )(); +typedef IntAggregate * ( * IntAggregateCreator )(); -SC_CORE_EXPORT EnumAggregate *create_EnumAggregate(); +SC_CORE_EXPORT EnumAggregate * create_EnumAggregate(); -SC_CORE_EXPORT GenericAggregate *create_GenericAggregate(); +SC_CORE_EXPORT GenericAggregate * create_GenericAggregate(); -SC_CORE_EXPORT EntityAggregate *create_EntityAggregate(); +SC_CORE_EXPORT EntityAggregate * create_EntityAggregate(); -SC_CORE_EXPORT SelectAggregate *create_SelectAggregate(); +SC_CORE_EXPORT SelectAggregate * create_SelectAggregate(); -SC_CORE_EXPORT StringAggregate *create_StringAggregate(); +SC_CORE_EXPORT StringAggregate * create_StringAggregate(); -SC_CORE_EXPORT BinaryAggregate *create_BinaryAggregate(); +SC_CORE_EXPORT BinaryAggregate * create_BinaryAggregate(); -SC_CORE_EXPORT RealAggregate *create_RealAggregate(); +SC_CORE_EXPORT RealAggregate * create_RealAggregate(); -SC_CORE_EXPORT IntAggregate *create_IntAggregate(); +SC_CORE_EXPORT IntAggregate * create_IntAggregate(); -typedef SDAI_Integer(*boundCallbackFn)(SDAI_Application_instance *); +typedef SDAI_Integer( *boundCallbackFn )( SDAI_Application_instance * ); #endif //AGGRCREATORTD_H diff --git a/src/clstepcore/derivedAttribute.cc b/src/clstepcore/derivedAttribute.cc index 194f95471..7fca3b16f 100644 --- a/src/clstepcore/derivedAttribute.cc +++ b/src/clstepcore/derivedAttribute.cc @@ -1,33 +1,30 @@ #include "derivedAttribute.h" -Derived_attribute::Derived_attribute(const char *name, const TypeDescriptor *domainType, - Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor &owner) - : AttrDescriptor(name, domainType, optional, unique, at, owner) -{ - _initializer = (const char *)0; +Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType, + Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner ) + : AttrDescriptor( name, domainType, optional, unique, at, owner ) { + _initializer = ( const char * )0; } -Derived_attribute::~Derived_attribute() -{ +Derived_attribute::~Derived_attribute() { } -const char *Derived_attribute::AttrExprDefStr(std::string &s) const -{ +const char * Derived_attribute::AttrExprDefStr( std::string & s ) const { std::string buf; s.clear(); - if(Name() && strchr(Name(), '.')) { + if( Name() && strchr( Name(), '.' ) ) { s = "SELF\\"; } - s.append(Name()); - s.append(" : "); - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + s.append( Name() ); + s.append( " : " ); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - if(_initializer) { // this is supposed to exist for a derived attribute. - s.append(" \n\t\t:= "); - s.append(_initializer); + if( _initializer ) { // this is supposed to exist for a derived attribute. + s.append( " \n\t\t:= " ); + s.append( _initializer ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } diff --git a/src/clstepcore/derivedAttribute.h b/src/clstepcore/derivedAttribute.h index d894e3ede..234521a07 100644 --- a/src/clstepcore/derivedAttribute.h +++ b/src/clstepcore/derivedAttribute.h @@ -5,29 +5,26 @@ #include "sc_export.h" -class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor -{ +class SC_CORE_EXPORT Derived_attribute : public AttrDescriptor { public: - const char *_initializer; + const char * _initializer; Derived_attribute( - const char *name, // i.e. char * - const TypeDescriptor *domainType, + const char * name, // i.e. char * + const TypeDescriptor * domainType, Logical optional, // i.e. F U or T Logical unique, // i.e. F U or T AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse, // AttrType_Deriving,AttrType_Redefining - const EntityDescriptor &owner + const EntityDescriptor & owner ); virtual ~Derived_attribute(); - const char *AttrExprDefStr(std::string &s) const; + const char * AttrExprDefStr( std::string & s ) const; - const char *initializer_() - { + const char * initializer_() { return _initializer; } - void initializer_(const char *i) - { + void initializer_( const char * i ) { _initializer = i; } }; diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 2889e2117..11170d4df 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -3,52 +3,47 @@ #include "typeDescriptor.h" #include "entityDescriptor.h" -Schema::Schema(const char *schemaName) - : _use_interface_list(new Interface_spec__set), - _ref_interface_list(new Interface_spec__set), - _function_list(0), _procedure_list(0), _global_rules(0) -{ +Schema::Schema( const char * schemaName ) +: _use_interface_list( new Interface_spec__set ), +_ref_interface_list( new Interface_spec__set ), +_function_list( 0 ), _procedure_list( 0 ), _global_rules( 0 ) { _name = schemaName; } -Schema::~Schema() -{ - TypeDescLinkNode *node; +Schema::~Schema() { + TypeDescLinkNode * node; - if(_use_interface_list != 0) { + if( _use_interface_list != 0 ) { delete _use_interface_list; } - if(_ref_interface_list != 0) { + if( _ref_interface_list != 0 ) { delete _ref_interface_list; } - if(_global_rules != 0) { + if( _global_rules != 0 ) { delete _global_rules; } - node = (TypeDescLinkNode *) _unnamed_typeList.GetHead(); - while(node) { + node = ( TypeDescLinkNode * ) _unnamed_typeList.GetHead(); + while( node ) { delete node->TypeDesc(); - node = (TypeDescLinkNode *) node->NextNode(); + node = ( TypeDescLinkNode * ) node->NextNode(); } } -void Schema::AddFunction(const std::string &f) -{ - _function_list.push_back(f); +void Schema::AddFunction( const std::string & f ) { + _function_list.push_back( f ); } -void Schema::AddGlobal_rule(Global_rule_ptr gr) -{ - if(_global_rules == 0) { +void Schema::AddGlobal_rule( Global_rule_ptr gr ) { + if( _global_rules == 0 ) { _global_rules = new Global_rule__set; } - _global_rules->Append(gr); + _global_rules->Append( gr ); } /// hope I did this right (MP) - was "not implemented" -void Schema::global_rules_(Global_rule__set_var &grs) -{ - if(_global_rules) { - if(_global_rules->Count() > 0) { +void Schema::global_rules_( Global_rule__set_var & grs ) { + if( _global_rules ) { + if( _global_rules->Count() > 0 ) { std::cerr << "In " << __FILE__ << ", Schema::global_rules_(): overwriting non-empty global rule set!" << std::endl; } delete _global_rules; @@ -56,45 +51,43 @@ void Schema::global_rules_(Global_rule__set_var &grs) _global_rules = grs; } -void Schema::AddProcedure(const std::string &p) -{ - _procedure_list.push_back(p); +void Schema::AddProcedure( const std::string & p ) { + _procedure_list.push_back( p ); } /// the whole schema -void Schema::GenerateExpress(ostream &out) const -{ +void Schema::GenerateExpress( ostream & out ) const { std::string tmp; out << endl << "(* Generating: " << Name() << " *)" << endl; - out << endl << "SCHEMA " << StrToLower(Name(), tmp) << ";" << endl; - GenerateUseRefExpress(out); + out << endl << "SCHEMA " << StrToLower( Name(), tmp ) << ";" << endl; + GenerateUseRefExpress( out ); // print TYPE definitions out << endl << "(* ////////////// TYPE Definitions *)" << endl; - GenerateTypesExpress(out); + GenerateTypesExpress( out ); // print Entity definitions out << endl << "(* ////////////// ENTITY Definitions *)" << endl; - GenerateEntitiesExpress(out); + GenerateEntitiesExpress( out ); int count, i; - if(_global_rules != 0) { + if( _global_rules != 0 ) { out << endl << "(* *************RULES************* *)" << endl; count = _global_rules->Count(); - for(i = 0; i < count; i++) { - out << endl << (*_global_rules)[i]->rule_text_() << endl; + for( i = 0; i < count; i++ ) { + out << endl << ( *_global_rules )[i]->rule_text_() << endl; } } - if(!_function_list.empty()) { + if( !_function_list.empty() ) { out << "(* *************FUNCTIONS************* *)" << endl; count = _function_list.size(); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { out << endl << _function_list[i] << endl; } } - if(!_procedure_list.empty()) { + if( !_procedure_list.empty() ) { out << "(* *************PROCEDURES************* *)" << endl; count = _procedure_list.size(); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { out << endl << _procedure_list[i] << endl; } } @@ -102,8 +95,7 @@ void Schema::GenerateExpress(ostream &out) const } /// USE, REFERENCE definitions -void Schema::GenerateUseRefExpress(ostream &out) const -{ +void Schema::GenerateUseRefExpress( ostream & out ) const { int i, k; int intf_count; int count; @@ -114,38 +106,38 @@ void Schema::GenerateUseRefExpress(ostream &out) const /////////////////////// print USE statements intf_count = _use_interface_list->Count(); - if(intf_count) { // there is at least 1 USE interface to a foreign schema - for(i = 0; i < intf_count; i++) { // print out each USE interface - is = (*_use_interface_list)[i]; // the 1st USE interface + if( intf_count ) { // there is at least 1 USE interface to a foreign schema + for( i = 0; i < intf_count; i++ ) { // print out each USE interface + is = ( *_use_interface_list )[i]; // the 1st USE interface // count is # of USE items in interface count = is->explicit_items_()->Count(); - if(count > 0) { + if( count > 0 ) { out << endl << " USE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; out << " ("; first_time = 1; - for(k = 0; k < count; k++) { // print out each USE item - if(first_time) { + for( k = 0; k < count; k++ ) { // print out each USE item + if( first_time ) { first_time = 0; } else { out << "," << endl << "\t"; } - if(!((*(is->explicit_items_()))[k]->original_id_().size())) { + if( !( ( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { // not renamed - out << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->new_id_(); } else { // renamed - out << (*(is->explicit_items_()))[k]->original_id_(); - out << " AS " << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->original_id_(); + out << " AS " << ( *( is->explicit_items_() ) )[k]->new_id_(); } } out << ");" << endl; - } else if(is->all_objects_()) { + } else if( is->all_objects_() ) { out << endl << " USE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" - << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" + << endl; } } } @@ -153,69 +145,67 @@ void Schema::GenerateUseRefExpress(ostream &out) const /////////////////////// print REFERENCE stmts intf_count = _ref_interface_list->Count(); - if(intf_count) { //there is at least 1 REFERENCE interface to a foreign schema - for(i = 0; i < intf_count; i++) { // print out each REFERENCE interface - is = (*_ref_interface_list)[i]; // the 1st REFERENCE interface + if( intf_count ) { //there is at least 1 REFERENCE interface to a foreign schema + for( i = 0; i < intf_count; i++ ) { // print out each REFERENCE interface + is = ( *_ref_interface_list )[i]; // the 1st REFERENCE interface // count is # of REFERENCE items in interface count = is->explicit_items_()->Count(); - if(count > 0) { + if( count > 0 ) { out << endl << " REFERENCE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << endl; out << " ("; first_time = 1; - for(k = 0; k < count; k++) { // print out each REFERENCE item - if(first_time) { + for( k = 0; k < count; k++ ) { // print out each REFERENCE item + if( first_time ) { first_time = 0; } else { out << "," << endl << "\t"; } - if((!(*(is->explicit_items_()))[k]->original_id_().size())) { + if( ( !( *( is->explicit_items_() ) )[k]->original_id_().size() ) ) { // not renamed - out << (*(is->explicit_items_()))[k]->new_id_(); + out << ( *( is->explicit_items_() ) )[k]->new_id_(); } else { // renamed - out << (*(is->explicit_items_()))[k]->original_id_(); + out << ( *( is->explicit_items_() ) )[k]->original_id_(); out << " AS " - << (*(is->explicit_items_()))[k]->new_id_(); + << ( *( is->explicit_items_() ) )[k]->new_id_(); } } out << ");" << endl; - } else if(is->all_objects_()) { + } else if( is->all_objects_() ) { out << endl << " REFERENCE FROM " - << StrToLower(is->foreign_schema_id_().c_str(), tmp) << ";" - << endl; + << StrToLower( is->foreign_schema_id_().c_str(), tmp ) << ";" + << endl; } } } } /// TYPE definitions -void Schema::GenerateTypesExpress(ostream &out) const -{ - TypeDescItr tdi(_typeList); +void Schema::GenerateTypesExpress( ostream & out ) const { + TypeDescItr tdi( _typeList ); tdi.ResetItr(); std::string tmp; - const TypeDescriptor *td = tdi.NextTypeDesc(); - while(td) { - out << endl << td->GenerateExpress(tmp); + const TypeDescriptor * td = tdi.NextTypeDesc(); + while( td ) { + out << endl << td->GenerateExpress( tmp ); td = tdi.NextTypeDesc(); } } /// Entity definitions -void Schema::GenerateEntitiesExpress(ostream &out) const -{ - EntityDescItr edi(_entList); +void Schema::GenerateEntitiesExpress( ostream & out ) const { + EntityDescItr edi( _entList ); edi.ResetItr(); std::string tmp; - const EntityDescriptor *ed = edi.NextEntityDesc(); - while(ed) { - out << endl << ed->GenerateExpress(tmp); + const EntityDescriptor * ed = edi.NextEntityDesc(); + while( ed ) { + out << endl << ed->GenerateExpress( tmp ); ed = edi.NextEntityDesc(); } } diff --git a/src/clstepcore/dictSchema.h b/src/clstepcore/dictSchema.h index 1617703e3..96977f98e 100644 --- a/src/clstepcore/dictSchema.h +++ b/src/clstepcore/dictSchema.h @@ -9,159 +9,137 @@ #include "dictionaryInstance.h" -typedef SDAI_Model_contents_ptr(* ModelContentsCreator)(); +typedef SDAI_Model_contents_ptr( * ModelContentsCreator )(); /** * \class Schema (was SchemaDescriptor) - a class of this type is generated and contains schema info. */ -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) - - // non-SDAI lists - Interface_spec__set_var _use_interface_list; // list of USE interfaces - Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces +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) + + // non-SDAI lists + Interface_spec__set_var _use_interface_list; // list of USE interfaces + Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - std::vector< std::string > _function_list; // of EXPRESS functions - std::vector< std::string > _procedure_list; // of EXPRESS procedures + std::vector< std::string > _function_list; // of EXPRESS functions + std::vector< std::string > _procedure_list; // of EXPRESS procedures #ifdef _MSC_VER #pragma warning( pop ) #endif - Global_rule__set_var _global_rules; - - public: - ModelContentsCreator CreateNewModelContents; - - Schema(const char *schemaName); - virtual ~Schema(); - - void AssignModelContentsCreator(ModelContentsCreator f = 0) - { - CreateNewModelContents = f; - } - - const char *Name() const - { - return _name; - } - void Name(const char *n) - { - _name = n; - } - - Interface_spec &interface_() - { - return _interface; - } - - Interface_spec__set_var use_interface_list_() - { - return - _use_interface_list; - } - - Interface_spec__set_var ref_interface_list_() - { - return _ref_interface_list; - } - - std::vector< std::string > function_list_() - { - return _function_list; - } - - void AddFunction(const std::string &f); - - Global_rule__set_var global_rules_() // const - { - return _global_rules; - } - - void AddGlobal_rule(Global_rule_ptr gr); - - void global_rules_(Global_rule__set_var &grs); // not implemented - - std::vector< std::string > procedure_list_() - { - return _procedure_list; - } - - void AddProcedure(const std::string &p); - - 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; - - // USE, REFERENCE definitions - void GenerateUseRefExpress(ostream &out) const; - - // TYPE definitions - void GenerateTypesExpress(ostream &out) const; - - // Entity definitions - void GenerateEntitiesExpress(ostream &out) const; + Global_rule__set_var _global_rules; + +public: + ModelContentsCreator CreateNewModelContents; + + Schema( const char * schemaName ); + virtual ~Schema(); + + void AssignModelContentsCreator( ModelContentsCreator f = 0 ) { + CreateNewModelContents = f; + } + + const char * Name() const { + return _name; + } + void Name( const char * n ) { + _name = n; + } + + Interface_spec & interface_() { + return _interface; + } + + Interface_spec__set_var use_interface_list_() { + return + _use_interface_list; + } + + Interface_spec__set_var ref_interface_list_() { + return _ref_interface_list; + } + + std::vector< std::string > function_list_() { + return _function_list; + } + + void AddFunction( const std::string & f ); + + Global_rule__set_var global_rules_() { // const + return _global_rules; + } + + void AddGlobal_rule( Global_rule_ptr gr ); + + void global_rules_( Global_rule__set_var & grs ); // not implemented + + std::vector< std::string > procedure_list_() { + return _procedure_list; + } + + void AddProcedure( const std::string & p ); + + 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; + + // USE, REFERENCE definitions + void GenerateUseRefExpress( ostream & out ) const; + + // TYPE definitions + void GenerateTypesExpress( ostream & out ) const; + + // Entity definitions + void GenerateEntitiesExpress( ostream & out ) const; }; typedef Schema SchemaDescriptor; diff --git a/src/clstepcore/dictdefs.h b/src/clstepcore/dictdefs.h index 0a6c8f241..1dbb7cdf9 100644 --- a/src/clstepcore/dictdefs.h +++ b/src/clstepcore/dictdefs.h @@ -29,37 +29,37 @@ class TypeDescriptorList; // currently commented out. FIXME The underlying class names should be updated // when the new dictionary is integrated. DAS -typedef class Schema *Schema_ptr; +typedef class Schema * Schema_ptr; typedef Schema_ptr Schema_var; -typedef class EntityDescriptor *Entity_ptr; +typedef class EntityDescriptor * Entity_ptr; typedef Entity_ptr Entity_var; -typedef class AttrDescriptor *Attribute_ptr; +typedef class AttrDescriptor * Attribute_ptr; typedef Attribute_ptr Attribute_var; -typedef class Derived_attribute *Derived_attribute_ptr; +typedef class Derived_attribute * Derived_attribute_ptr; typedef Derived_attribute_ptr Derived_attribute_var; -typedef class AttrDescriptor *Explicit_attribute_ptr; +typedef class AttrDescriptor * Explicit_attribute_ptr; typedef Explicit_attribute_ptr Explicit_attribute_var; -typedef Inverse_attribute *Inverse_attribute_ptr; +typedef Inverse_attribute * Inverse_attribute_ptr; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute_ptr Inverse_attribute_var; typedef Inverse_attribute InverseAttrDescriptor; -typedef class EnumTypeDescriptor *Enumeration_type_ptr; +typedef class EnumTypeDescriptor * Enumeration_type_ptr; typedef Enumeration_type_ptr Enumeration_type_var; -typedef class SelectTypeDescriptor *Select_type_ptr; +typedef class SelectTypeDescriptor * Select_type_ptr; typedef Select_type_ptr Select_type_var; -typedef class RealTypeDescriptor *Real_type_ptr; +typedef class RealTypeDescriptor * Real_type_ptr; typedef Real_type_ptr Real_type_var; -typedef class StringTypeDescriptor *String_type_ptr; +typedef class StringTypeDescriptor * String_type_ptr; typedef String_type_ptr String_type_var; -typedef class AggrTypeDescriptor *Aggr_type_ptr; +typedef class AggrTypeDescriptor * Aggr_type_ptr; typedef Aggr_type_ptr Aggr_type_var; -typedef class SetTypeDescriptor *Set_type_ptr; +typedef class SetTypeDescriptor * Set_type_ptr; typedef Set_type_ptr Set_type_var; -typedef class BagTypeDescriptor *Bag_type_ptr; +typedef class BagTypeDescriptor * Bag_type_ptr; typedef Bag_type_ptr Bag_type_var; -typedef class ListTypeDescriptor *List_type_ptr; +typedef class ListTypeDescriptor * List_type_ptr; typedef List_type_ptr List_type_var; -typedef class ArrayTypeDescriptor *Array_type_ptr; +typedef class ArrayTypeDescriptor * Array_type_ptr; typedef Array_type_ptr Array_type_var; // the following exist until everything is updated diff --git a/src/clstepcore/dictionaryInstance.h b/src/clstepcore/dictionaryInstance.h index 34fceee89..ac8734c68 100644 --- a/src/clstepcore/dictionaryInstance.h +++ b/src/clstepcore/dictionaryInstance.h @@ -3,14 +3,13 @@ #include "sc_export.h" -class SC_CORE_EXPORT Dictionary_instance -{ +class SC_CORE_EXPORT Dictionary_instance { - protected: - Dictionary_instance() {} - Dictionary_instance(const Dictionary_instance &) {} +protected: + Dictionary_instance() {} + Dictionary_instance( const Dictionary_instance & ) {} - virtual ~Dictionary_instance() {}; + virtual ~Dictionary_instance() {}; }; diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 903ba086d..2590e034c 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -29,32 +29,28 @@ class StepEntityEditor; // 2) delete the StepEntityEditor window // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); -DisplayNode::~DisplayNode() -{ +DisplayNode::~DisplayNode() { Remove(); - if(see) { - DeleteSEE((StepEntityEditor *)see); + if( see ) { + DeleteSEE( ( StepEntityEditor * )see ); //DAS PORT need the cast from void* DeleteSEE(see); } } -void DisplayNode::Remove() -{ +void DisplayNode::Remove() { GenericNode::Remove(); // DON'T DO THIS!! displayState = noMapState; } -int DisplayNode::ChangeState(displayStateEnum s) -{ +int DisplayNode::ChangeState( displayStateEnum s ) { displayState = s; return 1; } -int DisplayNode::ChangeList(DisplayNodeList *cmdList) -{ +int DisplayNode::ChangeList( DisplayNodeList * cmdList ) { Remove(); - cmdList->Append(this); + cmdList->Append( this ); return 1; } diff --git a/src/clstepcore/dispnode.h b/src/clstepcore/dispnode.h index 9e2ca5b7f..1209b9c3e 100644 --- a/src/clstepcore/dispnode.h +++ b/src/clstepcore/dispnode.h @@ -32,58 +32,49 @@ class MgrNode; // class DisplayNode ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNode : public GenericNode -{ +class SC_CORE_EXPORT DisplayNode : public GenericNode { protected: friend class GenNodeList; friend class DisplayNodeList; - MgrNode *mn; - void *see; + MgrNode * mn; + void * see; displayStateEnum displayState; // = { mappedWrite, mappedView, notMapped } public: // this should probably only be used to create head nodes for dispnodelists - DisplayNode() - { + DisplayNode() { displayState = noMapState; } - DisplayNode(MgrNode *node) - { + DisplayNode( MgrNode * node ) { mn = node; displayState = noMapState; } ~DisplayNode(); - void SEE(void *s) - { + void SEE( void * s ) { see = s; } - virtual void *SEE() - { + virtual void * SEE() { return see; } - void mgrNode(MgrNode *node) - { + void mgrNode( MgrNode * node ) { mn = node; } - class MgrNode *mgrNode() - { + class MgrNode * mgrNode() { return mn; } - displayStateEnum DisplayState() - { + displayStateEnum DisplayState() { return displayState; } - int DisplayListMember(displayStateEnum ds) - { - return (displayState == ds); + int DisplayListMember( displayStateEnum ds ) { + return ( displayState == ds ); } - int ChangeState(displayStateEnum s); - int ChangeList(DisplayNodeList *cmdList); + int ChangeState( displayStateEnum s ); + int ChangeList( DisplayNodeList * cmdList ); void Remove(); diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index 0aad7885c..f4d00a6aa 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -21,40 +21,36 @@ #include #include "sc_memmgr.h" -void DisplayNodeList::Remove(GenericNode *node) -{ - GenNodeList::Remove(node); +void DisplayNodeList::Remove( GenericNode * node ) { + GenNodeList::Remove( node ); // DON'T DO THIS ((DisplayNode *)node)->displayState = noMapState; } // deletes node from its previous list & appends // actually it puts it at the front of the list. -void DisplayNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void DisplayNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } // deletes newNode from its previous list & inserts after // existNode -void DisplayNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void DisplayNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertAfter(newNode, existNode); + GenNodeList::InsertAfter( newNode, existNode ); // DON'T DO THIS ((DisplayNode *)newNode)->displayState = listType; } // deletes newNode from its previous list & inserts before // existNode -void DisplayNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void DisplayNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // display state list } - GenNodeList::InsertBefore(newNode, existNode); + GenNodeList::InsertBefore( newNode, existNode ); // DON'T DO THIS!!! ((DisplayNode *)newNode)->displayState = listType; } diff --git a/src/clstepcore/dispnodelist.h b/src/clstepcore/dispnodelist.h index a621e657e..c4fe4dde3 100644 --- a/src/clstepcore/dispnodelist.h +++ b/src/clstepcore/dispnodelist.h @@ -29,26 +29,24 @@ // This will be used to represent the display state lists. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT DisplayNodeList : public GenNodeList -{ +class SC_CORE_EXPORT DisplayNodeList : public GenNodeList { public: - DisplayNodeList(displayStateEnum type); + DisplayNodeList( displayStateEnum type ); ~DisplayNodeList() { } // ADDED functions - displayStateEnum GetState() - { + displayStateEnum GetState() { return listType; } // REDEFINED functions // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); - virtual void Remove(GenericNode *node); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); + virtual void Remove( GenericNode * node ); protected: private: @@ -61,11 +59,10 @@ class SC_CORE_EXPORT DisplayNodeList : public GenNodeList // other classes) that aren't in this file except for Generic functions ////////////////////////////////////////////////////////////////////////////// -inline DisplayNodeList::DisplayNodeList(displayStateEnum type) - : GenNodeList(new DisplayNode()) -{ +inline DisplayNodeList::DisplayNodeList( displayStateEnum type ) + : GenNodeList( new DisplayNode() ) { listType = type; - ((DisplayNode *)head)->displayState = type; + ( ( DisplayNode * )head )->displayState = type; } #endif diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 2711c05f6..0e58c4db6 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -6,49 +6,45 @@ #include "inverseAttribute.h" #include "SubSuperIterators.h" -EntityDescriptor::EntityDescriptor() - : _abstractEntity(LUnknown), _extMapping(LUnknown), - _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(0) -{ +EntityDescriptor::EntityDescriptor( ) + : _abstractEntity( LUnknown ), _extMapping( LUnknown ), + _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( 0 ) { } -EntityDescriptor::EntityDescriptor(const char *name, // i.e. char * - Schema *origSchema, - Logical abstractEntity, // F U or T - Logical extMapping, - Creator f +EntityDescriptor::EntityDescriptor( const char * name, // i.e. char * + Schema * origSchema, + Logical abstractEntity, // F U or T + Logical extMapping, + Creator f ) - : TypeDescriptor(name, ENTITY_TYPE, origSchema, name), - _abstractEntity(abstractEntity), _extMapping(extMapping), - _uniqueness_rules((Uniqueness_rule__set_var)0), NewSTEPentity(f) -{ + : TypeDescriptor( name, ENTITY_TYPE, origSchema, name ), + _abstractEntity( abstractEntity ), _extMapping( extMapping ), + _uniqueness_rules( ( Uniqueness_rule__set_var )0 ), NewSTEPentity( f ) { } -EntityDescriptor::~EntityDescriptor() -{ +EntityDescriptor::~EntityDescriptor() { delete _uniqueness_rules; } // initialize one inverse attr; used in InitIAttrs, below -void initIAttr(Inverse_attribute *ia, Registry ®, 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); +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); + 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; } } @@ -63,62 +59,60 @@ void initIAttr(Inverse_attribute *ia, Registry ®, const char *schNm, const ch * must be called _after_ init_Sdai* functions for any ia->inverted_entity_id_'s * */ -void EntityDescriptor::InitIAttrs(Registry ®, const char *schNm) -{ - InverseAItr iai(&(InverseAttr())); - Inverse_attribute *ia; - while(0 != (ia = iai.NextInverse_attribute())) { - initIAttr(ia, reg, schNm, _name); +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 -{ +const char * EntityDescriptor::GenerateExpress( std::string & buf ) const { std::string sstr; int count; int i; int all_comments = 1; buf = "ENTITY "; - buf.append(StrToLower(Name(), sstr)); + buf.append( StrToLower( Name(), sstr ) ); - if(strlen(_supertype_stmt.c_str()) > 0) { - buf.append("\n "); + if( strlen( _supertype_stmt.c_str() ) > 0 ) { + buf.append( "\n " ); } - buf.append(_supertype_stmt); + buf.append( _supertype_stmt ); - const EntityDescriptor *ed = 0; + const EntityDescriptor * ed = 0; - EntityDescItr edi_super(_supertypes); + EntityDescItr edi_super( _supertypes ); edi_super.ResetItr(); ed = edi_super.NextEntityDesc(); int supertypes = 0; - if(ed) { - buf.append("\n SUBTYPE OF ("); - buf.append(StrToLower(ed->Name(), sstr)); + if( ed ) { + buf.append( "\n SUBTYPE OF (" ); + buf.append( StrToLower( ed->Name(), sstr ) ); supertypes = 1; } ed = edi_super.NextEntityDesc(); - while(ed) { - buf.append(",\n\t\t"); - buf.append(StrToLower(ed->Name(), sstr)); + while( ed ) { + buf.append( ",\n\t\t" ); + buf.append( StrToLower( ed->Name(), sstr ) ); ed = edi_super.NextEntityDesc(); } - if(supertypes) { - buf.append(")"); + if( supertypes ) { + buf.append( ")" ); } - buf.append(";\n"); + buf.append( ";\n" ); - AttrDescItr adi(_explicitAttr); + AttrDescItr adi( _explicitAttr ); adi.ResetItr(); - const AttrDescriptor *ad = adi.NextAttrDesc(); + const AttrDescriptor * ad = adi.NextAttrDesc(); - while(ad) { - if(ad->AttrType() == AttrType_Explicit) { - buf.append(" "); - buf.append(ad->GenerateExpress(sstr)); + while( ad ) { + if( ad->AttrType() == AttrType_Explicit ) { + buf.append( " " ); + buf.append( ad->GenerateExpress( sstr ) ); } ad = adi.NextAttrDesc(); } @@ -127,139 +121,136 @@ const char *EntityDescriptor::GenerateExpress(std::string &buf) const ad = adi.NextAttrDesc(); count = 1; - while(ad) { - if(ad->AttrType() == AttrType_Deriving) { - if(count == 1) { - buf.append(" DERIVE\n"); + while( ad ) { + if( ad->AttrType() == AttrType_Deriving ) { + if( count == 1 ) { + buf.append( " DERIVE\n" ); } - buf.append(" "); - buf.append(ad->GenerateExpress(sstr)); + buf.append( " " ); + buf.append( ad->GenerateExpress( sstr ) ); count++; } ad = adi.NextAttrDesc(); } ///////// - InverseAItr iai(&_inverseAttr); + InverseAItr iai( &_inverseAttr ); iai.ResetItr(); - const Inverse_attribute *ia = iai.NextInverse_attribute(); + const Inverse_attribute * ia = iai.NextInverse_attribute(); - if(ia) { - buf.append(" INVERSE\n"); + if( ia ) { + buf.append( " INVERSE\n" ); } - while(ia) { - buf.append(" "); - buf.append(ia->GenerateExpress(sstr)); + while( ia ) { + buf.append( " " ); + buf.append( ia->GenerateExpress( sstr ) ); ia = iai.NextInverse_attribute(); } /////////////// // count is # of UNIQUE rules - if(_uniqueness_rules != 0) { + if( _uniqueness_rules != 0 ) { count = _uniqueness_rules->Count(); - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_uniqueness_rules))[i]->_label.size()) { + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _uniqueness_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* UNIQUE *)\n"); + if( all_comments ) { + buf.append( " (* UNIQUE *)\n" ); } else { - buf.append(" UNIQUE\n"); + buf.append( " UNIQUE\n" ); } - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_uniqueness_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_uniqueness_rules))[i]->comment_()); - buf.append("\n"); + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _uniqueness_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _uniqueness_rules ) )[i]->comment_() ); + buf.append( "\n" ); } - if((*(_uniqueness_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_uniqueness_rules))[i]->label_()); - buf.append("\n"); + if( ( *( _uniqueness_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _uniqueness_rules ) )[i]->label_() ); + buf.append( "\n" ); } } } /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { all_comments = 1; count = _where_rules->Count(); - for(i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(!all_comments) { - buf.append(" WHERE\n"); + if( !all_comments ) { + buf.append( " WHERE\n" ); } else { - buf.append(" (* WHERE *)\n"); + buf.append( " (* WHERE *)\n" ); } - for(i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); - buf.append("\n"); + for( i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); + buf.append( "\n" ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); - buf.append("\n"); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); + buf.append( "\n" ); } } } - buf.append("END_ENTITY;\n"); + buf.append( "END_ENTITY;\n" ); - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } -const char *EntityDescriptor::QualifiedName(std::string &s) const -{ +const char * EntityDescriptor::QualifiedName( std::string & s ) const { s.clear(); - EntityDescItr edi(_supertypes); + EntityDescItr edi( _supertypes ); int count = 1; - const EntityDescriptor *ed = edi.NextEntityDesc(); - while(ed) { - if(count > 1) { - s.append("&"); + const EntityDescriptor * ed = edi.NextEntityDesc(); + while( ed ) { + if( count > 1 ) { + s.append( "&" ); } - s.append(ed->Name()); + s.append( ed->Name() ); count++; ed = edi.NextEntityDesc(); } - if(count > 1) { - s.append("&"); + if( count > 1 ) { + s.append( "&" ); } - s.append(Name()); - return const_cast(s.c_str()); + s.append( Name() ); + return const_cast( s.c_str() ); } -const TypeDescriptor *EntityDescriptor::IsA(const TypeDescriptor *td) const -{ - if(td -> NonRefType() == ENTITY_TYPE) { - return IsA((EntityDescriptor *) td); +const TypeDescriptor * EntityDescriptor::IsA( const TypeDescriptor * td ) const { + if( td -> NonRefType() == ENTITY_TYPE ) { + return IsA( ( EntityDescriptor * ) td ); } else { return 0; } } -const EntityDescriptor *EntityDescriptor::IsA(const EntityDescriptor *other) const -{ - const EntityDescriptor *found = 0; - const EntityDescLinkNode *link = (const EntityDescLinkNode *)(GetSupertypes().GetHead()); +const EntityDescriptor * EntityDescriptor::IsA( const EntityDescriptor * other ) const { + const EntityDescriptor * found = 0; + const EntityDescLinkNode * link = ( const EntityDescLinkNode * )( GetSupertypes().GetHead() ); - if(this == other) { + if( this == other ) { return other; } else { - while(link && ! found) { - found = link -> EntityDesc() -> IsA(other); - link = (EntityDescLinkNode *) link -> NextNode(); + while( link && ! found ) { + found = link -> EntityDesc() -> IsA( other ); + link = ( EntityDescLinkNode * ) link -> NextNode(); } } return found; diff --git a/src/clstepcore/entityDescriptor.h b/src/clstepcore/entityDescriptor.h index 1510fe6a8..e0bd25ec8 100644 --- a/src/clstepcore/entityDescriptor.h +++ b/src/clstepcore/entityDescriptor.h @@ -9,7 +9,7 @@ #include "sc_export.h" -typedef SDAI_Application_instance *(* Creator)(); +typedef SDAI_Application_instance * ( * Creator )(); class Registry; @@ -22,8 +22,7 @@ class Registry; * will be building the same thing but using the new schema info. * nodes (i.e. EntityDesc nodes) for each entity. */ -class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor { protected: @@ -42,137 +41,113 @@ class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor #ifdef _MSC_VER #pragma warning( pop ) #endif - public: + public: Uniqueness_rule__set_var _uniqueness_rules; // initially a null pointer // pointer to a function that will create a new instance of a SDAI_Application_instance Creator NewSTEPentity; - EntityDescriptor(); - EntityDescriptor(const char *name, // i.e. char * - Schema *origSchema, - Logical abstractEntity, // i.e. F U or T - Logical extMapping, - Creator f = 0 + EntityDescriptor( ); + EntityDescriptor( const char * name, // i.e. char * + Schema * origSchema, + Logical abstractEntity, // i.e. F U or T + Logical extMapping, + Creator f = 0 ); virtual ~EntityDescriptor(); - void InitIAttrs(Registry ®, const char *schNm); + void InitIAttrs( Registry & reg, const char * schNm ); - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; - const char *QualifiedName(std::string &s) const; + const char * QualifiedName( std::string & s ) const; - const SDAI_LOGICAL &AbstractEntity() const - { + const SDAI_LOGICAL & AbstractEntity() const { return _abstractEntity; } - const SDAI_LOGICAL &ExtMapping() const - { + const SDAI_LOGICAL & ExtMapping() const { return _extMapping; } - void AbstractEntity(SDAI_LOGICAL &ae) - { - _abstractEntity.put(ae.asInt()); + void AbstractEntity( SDAI_LOGICAL & ae ) { + _abstractEntity.put( ae.asInt() ); } - void ExtMapping(SDAI_LOGICAL &em) - { - _extMapping.put(em.asInt()); + void ExtMapping( SDAI_LOGICAL & em ) { + _extMapping.put( em.asInt() ); } - void AbstractEntity(Logical ae) - { - _abstractEntity.put(ae); + void AbstractEntity( Logical ae ) { + _abstractEntity.put( ae ); } - void ExtMapping(Logical em) - { - _extMapping.put(em); + void ExtMapping( Logical em ) { + _extMapping.put( em ); } - void ExtMapping(const char *em) - { - _extMapping.put(em); + void ExtMapping( const char * em ) { + _extMapping.put( em ); } - const EntityDescriptorList &Subtypes() const - { + const EntityDescriptorList & Subtypes() const { return _subtypes; } - const EntityDescriptorList &Supertypes() const - { + const EntityDescriptorList & Supertypes() const { return _supertypes; } - const EntityDescriptorList &GetSupertypes() const - { + const EntityDescriptorList & GetSupertypes() const { return _supertypes; } - const AttrDescriptorList &ExplicitAttr() const - { + const AttrDescriptorList & ExplicitAttr() const { return _explicitAttr; } - const Inverse_attributeList &InverseAttr() const - { + const Inverse_attributeList & InverseAttr() const { return _inverseAttr; } - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; - virtual const TypeDescriptor *IsA(const TypeDescriptor *td) const; - virtual const TypeDescriptor *IsA(const char *n) const - { - return TypeDescriptor::IsA(n); + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; + virtual const TypeDescriptor * IsA( const TypeDescriptor * td ) const; + virtual const TypeDescriptor * IsA( const char * n ) const { + return TypeDescriptor::IsA( n ); } - virtual const TypeDescriptor *CanBe(const TypeDescriptor *o) const - { - return o -> IsA(this); + virtual const TypeDescriptor * CanBe( const TypeDescriptor * o ) const { + return o -> IsA( this ); } - virtual const TypeDescriptor *CanBe(const char *n) const - { - return TypeDescriptor::CanBe(n); + virtual const TypeDescriptor * CanBe( const char * n ) const { + return TypeDescriptor::CanBe( n ); } // The following will be used by schema initialization functions - void AddSubtype(EntityDescriptor *ed) - { - _subtypes.AddNode(ed); + void AddSubtype( EntityDescriptor * ed ) { + _subtypes.AddNode( ed ); } - void AddSupertype_Stmt(const std::string &s) - { + void AddSupertype_Stmt( const std::string & s ) { _supertype_stmt = s; } - const char *Supertype_Stmt() - { + const char * Supertype_Stmt() { return _supertype_stmt.c_str(); } - std::string &supertype_stmt_() - { + std::string & supertype_stmt_() { return _supertype_stmt; } - void AddSupertype(EntityDescriptor *ed) - { - _supertypes.AddNode(ed); + void AddSupertype( EntityDescriptor * ed ) { + _supertypes.AddNode( ed ); } - void AddExplicitAttr(AttrDescriptor *ad) - { - _explicitAttr.AddNode(ad); + void AddExplicitAttr( AttrDescriptor * ad ) { + _explicitAttr.AddNode( ad ); } - void AddInverseAttr(Inverse_attribute *ia) - { - _inverseAttr.AddNode(ia); + void AddInverseAttr( Inverse_attribute * ia ) { + _inverseAttr.AddNode( ia ); } - void uniqueness_rules_(Uniqueness_rule__set *urs) - { + void uniqueness_rules_( Uniqueness_rule__set * urs ) { _uniqueness_rules = urs; } - Uniqueness_rule__set_var &uniqueness_rules_() - { + Uniqueness_rule__set_var & uniqueness_rules_() { return _uniqueness_rules; } diff --git a/src/clstepcore/entityDescriptorList.cc b/src/clstepcore/entityDescriptorList.cc index 92b3001e1..86d937c76 100644 --- a/src/clstepcore/entityDescriptorList.cc +++ b/src/clstepcore/entityDescriptorList.cc @@ -1,36 +1,29 @@ #include "entityDescriptorList.h" -EntityDescLinkNode::EntityDescLinkNode() -{ +EntityDescLinkNode::EntityDescLinkNode() { _entityDesc = 0; } -EntityDescLinkNode::~EntityDescLinkNode() -{ +EntityDescLinkNode::~EntityDescLinkNode() { } -EntityDescriptorList::EntityDescriptorList() -{ +EntityDescriptorList::EntityDescriptorList() { } -EntityDescriptorList::~EntityDescriptorList() -{ +EntityDescriptorList::~EntityDescriptorList() { } -EntityDescItr::EntityDescItr(const EntityDescriptorList &edList) : edl(edList) -{ - cur = (EntityDescLinkNode *)(edl.GetHead()); +EntityDescItr::EntityDescItr( const EntityDescriptorList & edList ) : edl( edList ) { + cur = ( EntityDescLinkNode * )( edl.GetHead() ); } -EntityDescItr::~EntityDescItr() -{ +EntityDescItr::~EntityDescItr() { } -EntityDescriptor *EntityDescItr::NextEntityDesc_nc() -{ - if(cur) { - EntityDescriptor *ed = cur->EntityDesc(); - cur = (EntityDescLinkNode *)(cur->NextNode()); +EntityDescriptor * EntityDescItr::NextEntityDesc_nc() { + if( cur ) { + EntityDescriptor * ed = cur->EntityDesc(); + cur = ( EntityDescLinkNode * )( cur->NextNode() ); return ed; } return 0; diff --git a/src/clstepcore/entityDescriptorList.h b/src/clstepcore/entityDescriptorList.h index 5d8059b62..e34da432a 100644 --- a/src/clstepcore/entityDescriptorList.h +++ b/src/clstepcore/entityDescriptorList.h @@ -9,29 +9,25 @@ class EntityDescriptor; -class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode { private: protected: - EntityDescriptor *_entityDesc; + EntityDescriptor * _entityDesc; public: EntityDescLinkNode(); virtual ~EntityDescLinkNode(); - EntityDescriptor *EntityDesc() const - { + EntityDescriptor * EntityDesc() const { return _entityDesc; } - void EntityDesc(EntityDescriptor *ed) - { + void EntityDesc( EntityDescriptor * ed ) { _entityDesc = ed; } }; -class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList { private: protected: @@ -39,44 +35,39 @@ class SC_CORE_EXPORT EntityDescriptorList : public SingleLinkList EntityDescriptorList(); virtual ~EntityDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new EntityDescLinkNode; } - EntityDescLinkNode *AddNode(EntityDescriptor *ed) - { - EntityDescLinkNode *node = (EntityDescLinkNode *) NewNode(); - node->EntityDesc(ed); - SingleLinkList::AppendNode(node); + EntityDescLinkNode * AddNode( EntityDescriptor * ed ) { + EntityDescLinkNode * node = ( EntityDescLinkNode * ) NewNode(); + node->EntityDesc( ed ); + SingleLinkList::AppendNode( node ); return node; } }; -typedef EntityDescriptorList *Entity__set_ptr; +typedef EntityDescriptorList * Entity__set_ptr; typedef Entity__set_ptr Entity__set_var; -class SC_CORE_EXPORT EntityDescItr -{ +class SC_CORE_EXPORT EntityDescItr { protected: - const EntityDescriptorList &edl; - const EntityDescLinkNode *cur; + const EntityDescriptorList & edl; + const EntityDescLinkNode * cur; public: - EntityDescItr(const EntityDescriptorList &edList); + EntityDescItr( const EntityDescriptorList & edList ); virtual ~EntityDescItr(); - void ResetItr() - { - cur = (EntityDescLinkNode *)(edl.GetHead()); + void ResetItr() { + cur = ( EntityDescLinkNode * )( edl.GetHead() ); } - inline const EntityDescriptor *NextEntityDesc() - { + inline const EntityDescriptor * NextEntityDesc() { return NextEntityDesc_nc(); } - EntityDescriptor *NextEntityDesc_nc(); + EntityDescriptor * NextEntityDesc_nc(); }; #endif //ENTITYDESCRIPTORLIST_H diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index d74a68621..0dd35803a 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -20,12 +20,11 @@ * Returns the number of EntLists in this's list (EntList->next, next->next * etc.) including this. */ -int EntList::siblings() -{ +int EntList::siblings() { int count; - EntList *el; + EntList * el; - for(count = 1, el = next; el; count++, el = el->next) { + for( count = 1, el = next; el; count++, el = el->next ) { ; } return count; @@ -34,11 +33,10 @@ int EntList::siblings() /** * Returns the first EntList not of type join, starting from this. */ -EntList *EntList::firstNot(JoinType j) -{ - EntList *sibling = this; +EntList * EntList::firstNot( JoinType j ) { + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -47,11 +45,10 @@ EntList *EntList::firstNot(JoinType j) /** * Returns the first EntList where viable = match, starting from this. */ -EntList *EntList::firstWanted(MatchType match) -{ - EntList *sibling = this; +EntList * EntList::firstWanted( MatchType match ) { + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->next; } return sibling; // (may = NULL) @@ -61,11 +58,10 @@ EntList *EntList::firstWanted(MatchType match) * Returns the last EntList not of type join, searching backwards from * this. */ -EntList *EntList::lastNot(JoinType j) -{ - EntList *sibling = this; +EntList * EntList::lastNot( JoinType j ) { + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -75,11 +71,10 @@ EntList *EntList::lastNot(JoinType j) * Returns the last EntList where viable = match, searching backwards from * this. */ -EntList *EntList::lastWanted(MatchType match) -{ - EntList *sibling = this; +EntList * EntList::lastWanted( MatchType match ) { + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->prev; } return sibling; // (may = NULL) @@ -90,22 +85,21 @@ EntList *EntList::lastWanted(MatchType match) * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ -void SimpleList::unmarkAll(EntNode *ents) -{ - EntNode *eptr = ents; +void SimpleList::unmarkAll( EntNode * ents ) { + EntNode * eptr = ents; int comp = -1; - if(viable < MATCHSOME) { + if( viable < MATCHSOME ) { return; } - while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { + while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if(eptr->mark <= I_marked) { + if( eptr->mark <= I_marked ) { // Only unmark if we gave it the strongest mark: - eptr->setmark(NOMARK); + eptr->setmark( NOMARK ); } // Either way (whether or not another List's mark remains), we no longer // marked: @@ -118,15 +112,14 @@ void SimpleList::unmarkAll(EntNode *ents) * viable val of MATCHSOME. Return true if we mark a previously unmarked * node; otherwise false. */ -bool SimpleList::acceptChoice(EntNode *ents) -{ - EntNode *eptr = ents; +bool SimpleList::acceptChoice( EntNode * ents ) { + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked()) { - eptr->setmark(ORMARK); + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked() ) { + eptr->setmark( ORMARK ); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -134,7 +127,7 @@ bool SimpleList::acceptChoice(EntNode *ents) } return false; // we didn't mark } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. return false; } diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 5fe71a6a5..792489e4b 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -21,31 +21,30 @@ * list, then sets this to the first element, and then deletes the first * element. This ensures that `this' points to the start of the list. */ -EntNode::EntNode(const char **names) -{ +EntNode::EntNode( const char ** names ) { int j = 1, comp; - EntNode *prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - const char *nm; + EntNode * prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + const char * nm; // Create a first EntNode: - firstnode = prev = new EntNode(names[0]); + firstnode = prev = new EntNode( names[0] ); - while(names[j] && *names[j] != '*') { + while( names[j] && *names[j] != '*' ) { nm = names[j]; - while(prev != NULL && (comp = StrCmpIns(prev->name, nm)) < 0) { + while( prev != NULL && ( comp = StrCmpIns( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -71,11 +70,10 @@ EntNode::EntNode(const char **names) /** * Copies all of ent's values here. */ -EntNode &EntNode::operator= (EntNode &ent) -{ - Name(ent.name); - setmark(ent.mark); - multSuprs(ent.multSupers); +EntNode & EntNode::operator= ( EntNode & ent ) { + Name( ent.name ); + setmark( ent.mark ); + multSuprs( ent.multSupers ); next = ent.next; return *this; } @@ -83,11 +81,10 @@ EntNode &EntNode::operator= (EntNode &ent) /** * Marks/unmarks all the nodes in this's list (default is to mark). */ -void EntNode::markAll(MarkType stamp) -{ - EntNode *node = this; +void EntNode::markAll( MarkType stamp ) { + EntNode * node = this; - while(node != NULL) { + while( node != NULL ) { node->mark = stamp; node = node->next; } @@ -96,12 +93,11 @@ void EntNode::markAll(MarkType stamp) /** * Returns true if this and all nodes following it are marked. */ -bool EntNode::allMarked() -{ - EntNode *node = this; +bool EntNode::allMarked() { + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { return false; } node = node->next; @@ -112,13 +108,12 @@ bool EntNode::allMarked() /** * Returns the number of unmarked nodes in this's list. */ -int EntNode::unmarkedCount() -{ +int EntNode::unmarkedCount() { int count = 0; - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { count++; } node = node->next; @@ -130,14 +125,13 @@ int EntNode::unmarkedCount() * Starting from `this', search for the last node (along our next's) which * alphabetically precedes ent. */ -EntNode *EntNode::lastSmaller(EntNode *ent) -{ - EntNode *eptr = next, *prev = this; +EntNode * EntNode::lastSmaller( EntNode * ent ) { + EntNode * eptr = next, *prev = this; - if(*this > *ent) { + if( *this > *ent ) { return NULL; } - while(eptr && *eptr > *prev && *eptr < *ent) { + while( eptr && *eptr > *prev && *eptr < *ent ) { prev = eptr; eptr = eptr->next; } @@ -153,11 +147,10 @@ EntNode *EntNode::lastSmaller(EntNode *ent) * few of the nodes. The nodes at first were in order; only the renamed * ones may be out of place.) */ -void EntNode::sort(EntNode **first) -{ - EntNode *eptr1, *eptr2, *temp1, *temp2; +void EntNode::sort( EntNode ** first ) { + EntNode * eptr1, *eptr2, *temp1, *temp2; - while(next && *this > *next) { + while( next && *this > *next ) { // Find the earliest node greater than next. (I.e., is not only this > // next but also some of this's preceding nodes. Since the nodes @@ -165,20 +158,20 @@ void EntNode::sort(EntNode **first) // ordered chunk of nodes which next should precede.) (eptr1 is // actually set to the one before, so that we'll know that eptr1->next // should now be set to next.) - eptr1 = (*first)->lastSmaller(next); + eptr1 = ( *first )->lastSmaller( next ); // Take the latest node eptr1 is greater than. (I.e., beyond next are // there more nodes which should be immediately after eptr1.) (The // succeeding nodes are not necessarily in order, so lastSmaller() also // checks that nodes later than next are also > their prev's.) - if(eptr1) { - eptr2 = next->lastSmaller(eptr1->next); + if( eptr1 ) { + eptr2 = next->lastSmaller( eptr1->next ); } else { - eptr2 = next->lastSmaller(*first); + eptr2 = next->lastSmaller( *first ); } // Switch the two lists: - if(eptr1) { + if( eptr1 ) { temp1 = eptr1->next; eptr1->next = next; temp2 = eptr2->next; @@ -193,7 +186,7 @@ void EntNode::sort(EntNode **first) } } - if(next) { - next->sort(first); + if( next ) { + next->sort( first ); } } diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 16a34ae7f..9200b196f 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -5,77 +5,73 @@ * this was in ExpDict.cc before splitting it up */ #ifdef NOT_YET -EnumerationTypeDescriptor::EnumerationTypeDescriptor() -{ +EnumerationTypeDescriptor::EnumerationTypeDescriptor( ) { _elements = new StringAggregate; } #endif -EnumTypeDescriptor::EnumTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, - const char *d, EnumCreator f) - : TypeDescriptor(nm, ft, origSchema, d), CreateNewEnum(f) -{ +EnumTypeDescriptor::EnumTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, + const char * d, EnumCreator f ) + : TypeDescriptor( nm, ft, origSchema, d ), CreateNewEnum( f ) { } -SDAI_Enum *EnumTypeDescriptor::CreateEnum() -{ - if(CreateNewEnum) { +SDAI_Enum * EnumTypeDescriptor::CreateEnum() { + if( CreateNewEnum ) { return CreateNewEnum(); } else { return 0; } } -const char *EnumTypeDescriptor::GenerateExpress(std::string &buf) const -{ +const char * EnumTypeDescriptor::GenerateExpress( std::string & buf ) const { char tmp[BUFSIZ]; buf = "TYPE "; - buf.append(StrToLower(Name(), tmp)); - buf.append(" = ENUMERATION OF \n ("); - const char *desc = Description(); - const char *ptr = &(desc[16]); + buf.append( StrToLower( Name(), tmp ) ); + buf.append( " = ENUMERATION OF \n (" ); + const char * desc = Description(); + const char * ptr = &( desc[16] ); - while(*ptr != '\0') { - if(*ptr == ',') { - buf.append(",\n "); - } else if(isupper(*ptr)) { - buf += (char)tolower(*ptr); + while( *ptr != '\0' ) { + if( *ptr == ',' ) { + buf.append( ",\n " ); + } else if( isupper( *ptr ) ) { + buf += ( char )tolower( *ptr ); } else { buf += *ptr; } ptr++; } - buf.append(";\n"); + buf.append( ";\n" ); /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { int all_comments = 1; int count = _where_rules->Count(); - for(int i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* WHERE *)\n"); + if( all_comments ) { + buf.append( " (* WHERE *)\n" ); } else { - buf.append(" WHERE\n"); + buf.append( " WHERE\n" ); } - for(int i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); + for( int i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); } } } - buf.append("END_TYPE;\n"); - return const_cast(buf.c_str()); + buf.append( "END_TYPE;\n" ); + return const_cast( buf.c_str() ); } diff --git a/src/clstepcore/enumTypeDescriptor.h b/src/clstepcore/enumTypeDescriptor.h index 1d4d3d226..de3a2c620 100644 --- a/src/clstepcore/enumTypeDescriptor.h +++ b/src/clstepcore/enumTypeDescriptor.h @@ -3,26 +3,24 @@ #include "typeDescriptor.h" -typedef SDAI_Enum *(* EnumCreator)(); +typedef SDAI_Enum * ( * EnumCreator )(); -class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor { public: EnumCreator CreateNewEnum; - const char *GenerateExpress(std::string &buf) const; + const char * GenerateExpress( std::string & buf ) const; - void AssignEnumCreator(EnumCreator f = 0) - { + void AssignEnumCreator( EnumCreator f = 0 ) { CreateNewEnum = f; } - SDAI_Enum *CreateEnum(); + SDAI_Enum * CreateEnum(); - EnumTypeDescriptor() { } - EnumTypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d, - EnumCreator f = 0); + EnumTypeDescriptor( ) { } + EnumTypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d, + EnumCreator f = 0 ); virtual ~EnumTypeDescriptor() { } }; @@ -34,19 +32,17 @@ class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor * why have EnumTypeDescriptor + EnumerationTypeDescriptor ??? */ #ifdef NOT_YET -class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT EnumerationTypeDescriptor : public TypeDescriptor { protected: - StringAggregate *_elements; // of (null) + StringAggregate * _elements; // of (null) public: - EnumerationTypeDescriptor(); + EnumerationTypeDescriptor( ); virtual ~EnumerationTypeDescriptor() { } - StringAggregate &Elements() - { + StringAggregate & Elements() { return *_elements; } // void Elements (StringAggregate e); diff --git a/src/clstepcore/explicitItemId.cc b/src/clstepcore/explicitItemId.cc index e34a583e7..c229f6369 100644 --- a/src/clstepcore/explicitItemId.cc +++ b/src/clstepcore/explicitItemId.cc @@ -1,116 +1,103 @@ #include "explicitItemId.h" -Explicit_item_id::Explicit_item_id() -{ +Explicit_item_id::Explicit_item_id() { _local_definition = 0; } -Explicit_item_id::Explicit_item_id(const Explicit_item_id &eii) - : Interfaced_item(eii) -{ +Explicit_item_id::Explicit_item_id( const Explicit_item_id & eii ) +: Interfaced_item( eii ) { _local_definition = eii._local_definition; _original_id = eii._original_id; _new_id = eii._new_id; } -Explicit_item_id::~Explicit_item_id() -{ +Explicit_item_id::~Explicit_item_id() { _local_definition = 0; } -Explicit_item_id__set::Explicit_item_id__set(int defaultSize) -{ +Explicit_item_id__set::Explicit_item_id__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Explicit_item_id_ptr[_bufsize]; _count = 0; } -Explicit_item_id__set::~Explicit_item_id__set() -{ +Explicit_item_id__set::~Explicit_item_id__set() { delete[] _buf; } -void Explicit_item_id__set::Check(int index) -{ - Explicit_item_id_ptr *newbuf; +void Explicit_item_id__set::Check( int index ) { + Explicit_item_id_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Explicit_item_id_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Explicit_item_id_ptr)); + memmove( newbuf, _buf, _count * sizeof( Explicit_item_id_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Explicit_item_id__set::Insert(Explicit_item_id_ptr v, int index) -{ - Explicit_item_id_ptr *spot; - index = (index < 0) ? _count : index; +void Explicit_item_id__set::Insert( Explicit_item_id_ptr v, int index ) { + Explicit_item_id_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Append(Explicit_item_id_ptr v) -{ +void Explicit_item_id__set::Append( Explicit_item_id_ptr v ) { int index = _count; - Explicit_item_id_ptr *spot; + Explicit_item_id_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Explicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Explicit_item_id__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Explicit_item_id__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Explicit_item_id_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Explicit_item_id_ptr)); + Explicit_item_id_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Explicit_item_id_ptr ) ); } } -int Explicit_item_id__set::Index(Explicit_item_id_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Explicit_item_id__set::Index( Explicit_item_id_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Explicit_item_id_ptr &Explicit_item_id__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Explicit_item_id_ptr & Explicit_item_id__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Explicit_item_id__set::Count() -{ +int Explicit_item_id__set::Count() { return _count; } -void Explicit_item_id__set::Clear() -{ +void Explicit_item_id__set::Clear() { _count = 0; } diff --git a/src/clstepcore/explicitItemId.h b/src/clstepcore/explicitItemId.h index d16f05b21..8a4d22ca0 100644 --- a/src/clstepcore/explicitItemId.h +++ b/src/clstepcore/explicitItemId.h @@ -3,134 +3,122 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item -{ - protected: - Explicit_item_id(); - Explicit_item_id(const Explicit_item_id &); - Explicit_item_id(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Interfaced_item(foreign_schema), _local_definition(ld), _original_id(oi), _new_id(ni) {} - virtual ~Explicit_item_id(); - public: - // definition in the local schema. The TypeDescriptor (or subtype) is not - // implemented quite right - the name in it is the original (foreign - // schema) name. The USE or REFERENCED renames are listed in - // TypeDescriptor's altNames member variable. - // Warning: This is currently a null ptr for objects other than - // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE - // this ptr will be null. - const TypeDescriptor *_local_definition; +class SC_CORE_EXPORT Explicit_item_id : public Interfaced_item { +protected: + Explicit_item_id(); + Explicit_item_id( const Explicit_item_id & ); + Explicit_item_id( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Interfaced_item( foreign_schema ), _local_definition( ld ), _original_id( oi ), _new_id( ni ) {} + virtual ~Explicit_item_id(); +public: + // definition in the local schema. The TypeDescriptor (or subtype) is not + // implemented quite right - the name in it is the original (foreign + // schema) name. The USE or REFERENCED renames are listed in + // TypeDescriptor's altNames member variable. + // Warning: This is currently a null ptr for objects other than + // types and entities - that is - if this is a USEd FUNCTION or PROCEDURE + // this ptr will be null. + const TypeDescriptor * _local_definition; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - // name in originating schema - only exists if it has been renamed. - Express_id _original_id; + // name in originating schema - only exists if it has been renamed. + Express_id _original_id; - Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) + Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI) #ifdef _MSC_VER #pragma warning( pop ) #endif - const TypeDescriptor *local_definition_() const - { - return _local_definition; - } - - const Express_id original_id_() const - { - return _original_id; - } - - // non-sdai, renamed name - const Express_id new_id_() const - { - return _new_id; - } - - // return string "USE" or "REFERENCE" - virtual const char *EXPRESS_type() = 0; - - // private: - void local_definition_(const TypeDescriptor *td) - { - _local_definition = td; - } - void original_id_(const Express_id &ei) - { - _original_id = ei; - } - - // non-sdai - void new_id_(const Express_id &ni) - { - _new_id = ni; - } + const TypeDescriptor * local_definition_() const { + return _local_definition; + } + + const Express_id original_id_() const { + return _original_id; + } + + // non-sdai, renamed name + const Express_id new_id_() const { + return _new_id; + } + + // return string "USE" or "REFERENCE" + virtual const char * EXPRESS_type() = 0; + + // private: + void local_definition_( const TypeDescriptor * td ) { + _local_definition = td; + } + void original_id_( const Express_id & ei ) { + _original_id = ei; + } + + // non-sdai + void new_id_( const Express_id & ni ) { + _new_id = ni; + } }; -typedef Explicit_item_id *Explicit_item_id_ptr; - - -class SC_CORE_EXPORT Explicit_item_id__set -{ - public: - Explicit_item_id__set(int = 16); - ~Explicit_item_id__set(); - - Explicit_item_id_ptr &operator[](int index); - void Insert(Explicit_item_id_ptr, int index); - void Append(Explicit_item_id_ptr); - void Remove(int index); - int Index(Explicit_item_id_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Explicit_item_id_ptr *_buf; - int _bufsize; - int _count; +typedef Explicit_item_id * Explicit_item_id_ptr; + + +class SC_CORE_EXPORT Explicit_item_id__set { +public: + Explicit_item_id__set( int = 16 ); + ~Explicit_item_id__set(); + + Explicit_item_id_ptr & operator[]( int index ); + void Insert( Explicit_item_id_ptr, int index ); + void Append( Explicit_item_id_ptr ); + void Remove( int index ); + int Index( Explicit_item_id_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Explicit_item_id_ptr * _buf; + int _bufsize; + int _count; }; -typedef Explicit_item_id__set *Explicit_item_id__set_ptr; +typedef Explicit_item_id__set * Explicit_item_id__set_ptr; typedef Explicit_item_id__set_ptr Explicit_item_id__set_var; -class SC_CORE_EXPORT Used_item : public Explicit_item_id -{ - public: - Used_item() {} - Used_item(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Explicit_item_id(foreign_schema, ld, oi, ni) {} - virtual ~Used_item() {} - - const char *EXPRESS_type() - { - return "USE"; - } +class SC_CORE_EXPORT Used_item : public Explicit_item_id { +public: + Used_item() {} + Used_item( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Explicit_item_id( foreign_schema, ld, oi, ni ) {} + virtual ~Used_item() {} + + const char * EXPRESS_type() { + return "USE"; + } }; -typedef Used_item *Used_item_ptr; - -class SC_CORE_EXPORT Referenced_item : public Explicit_item_id -{ - public: - Referenced_item() {} - Referenced_item(const char *foreign_schema, TypeDescriptor *ld, - const char *oi, const char *ni) - : Explicit_item_id(foreign_schema, ld, oi, ni) {} - virtual ~Referenced_item() {} - - const char *EXPRESS_type() - { - return "REFERENCE"; - } +typedef Used_item * Used_item_ptr; + +class SC_CORE_EXPORT Referenced_item : public Explicit_item_id { +public: + Referenced_item() {} + Referenced_item( const char * foreign_schema, TypeDescriptor * ld, + const char * oi, const char * ni ) + : Explicit_item_id( foreign_schema, ld, oi, ni ) {} + virtual ~Referenced_item() {} + + const char * EXPRESS_type() { + return "REFERENCE"; + } }; -typedef Referenced_item *Referenced_item_ptr; +typedef Referenced_item * Referenced_item_ptr; #endif //EXPLICITITEMID_H diff --git a/src/clstepcore/globalRule.cc b/src/clstepcore/globalRule.cc index 126fbda1d..b6fdeb19a 100644 --- a/src/clstepcore/globalRule.cc +++ b/src/clstepcore/globalRule.cc @@ -1,33 +1,28 @@ #include "globalRule.h" Global_rule::Global_rule() - : _entities(0), _where_rules(0), _parent_schema(0) -{ +: _entities( 0 ), _where_rules( 0 ), _parent_schema( 0 ) { } -Global_rule::Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt) - : _name(n), _entities(0), _where_rules(0), _parent_schema(parent_sch), - _rule_text(rt) -{ +Global_rule::Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ) +: _name( n ), _entities( 0 ), _where_rules( 0 ), _parent_schema( parent_sch ), +_rule_text( rt ) { } /// not fully implemented -Global_rule::Global_rule(Global_rule &gr): Dictionary_instance() -{ +Global_rule::Global_rule( Global_rule & gr ): Dictionary_instance() { _name = gr._name; _parent_schema = gr._parent_schema; } -Global_rule::~Global_rule() -{ +Global_rule::~Global_rule() { delete _entities; delete _where_rules; } -void Global_rule::entities_(const Entity__set_var &e) -{ - if(_entities) { - if(_entities->EntryCount() > 0) { +void Global_rule::entities_( const Entity__set_var & e ) { + if( _entities ) { + if( _entities->EntryCount() > 0 ) { std::cerr << "In " << __FILE__ << ", Global_rule::entities_(): overwriting non-empty entity set!" << std::endl; } delete _entities; @@ -35,10 +30,9 @@ void Global_rule::entities_(const Entity__set_var &e) _entities = e; } -void Global_rule::where_rules_(const Where_rule__list_var &wrl) -{ - if(_where_rules) { - if(_where_rules->Count() > 0) { +void Global_rule::where_rules_( const Where_rule__list_var & wrl ) { + if( _where_rules ) { + if( _where_rules->Count() > 0 ) { std::cerr << "In " << __FILE__ << ", Global_rule::where_rules_(): overwriting non-empty rule set!" << std::endl; } delete _where_rules; @@ -48,102 +42,92 @@ void Global_rule::where_rules_(const Where_rule__list_var &wrl) /////////////////////////////////////////////////////////////////////////////// -Global_rule__set::Global_rule__set(int defaultSize) -{ +Global_rule__set::Global_rule__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Global_rule_ptr[_bufsize]; _count = 0; } -Global_rule__set::~Global_rule__set() -{ +Global_rule__set::~Global_rule__set() { Clear(); delete[] _buf; } -void Global_rule__set::Check(int index) -{ - Global_rule_ptr *newbuf; +void Global_rule__set::Check( int index ) { + Global_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Global_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Global_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Global_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Global_rule__set::Insert(Global_rule_ptr v, int index) -{ - Global_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Global_rule__set::Insert( Global_rule_ptr v, int index ) { + Global_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Append(Global_rule_ptr v) -{ +void Global_rule__set::Append( Global_rule_ptr v ) { int index = _count; - Global_rule_ptr *spot; + Global_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Global_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Global_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Global_rule__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Global_rule__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Global_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Global_rule_ptr)); + Global_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Global_rule_ptr ) ); } } -int Global_rule__set::Index(Global_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Global_rule__set::Index( Global_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Global_rule_ptr &Global_rule__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Global_rule_ptr & Global_rule__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Global_rule__set::Count() -{ +int Global_rule__set::Count() { return _count; } -void Global_rule__set::Clear() -{ - for(int i = 0; i < _count; i ++) { +void Global_rule__set::Clear() { + for( int i = 0; i < _count; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index 3a8aa9d9b..c5614fdbf 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -7,91 +7,81 @@ #include "sc_export.h" -class SC_CORE_EXPORT Global_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Global_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _name; + Express_id _name; + std::string _rule_text; // non-SDAI #ifdef _MSC_VER #pragma warning( pop ) #endif - Entity__set_var _entities; // not implemented - Where_rule__list_var _where_rules; - Schema_ptr _parent_schema; - std::string _rule_text; // non-SDAI + Entity__set_var _entities; // not implemented + Where_rule__list_var _where_rules; + Schema_ptr _parent_schema; - Global_rule(); - Global_rule(const char *n, Schema_ptr parent_sch, const std::string &rt); - Global_rule(Global_rule &); // not fully implemented - virtual ~Global_rule(); + Global_rule(); + Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ); + Global_rule( Global_rule & ); // not fully implemented + virtual ~Global_rule(); - Express_id name_() const - { - return _name; - } - Entity__set_var entities_() const - { - return _entities; - } - Where_rule__list_var where_rules_() const - { - return _where_rules; - } - Schema_ptr parent_schema_() const - { - return _parent_schema; - } - const char *rule_text_() - { - return _rule_text.c_str(); - } + Express_id name_() const { + return _name; + } + Entity__set_var entities_() const { + return _entities; + } + Where_rule__list_var where_rules_() const { + return _where_rules; + } + Schema_ptr parent_schema_() const { + return _parent_schema; + } + const char * rule_text_() { + return _rule_text.c_str(); + } - void name_(Express_id &n) - { - _name = n; - } - void entities_(const Entity__set_var &e); // not implemented - void where_rules_(const Where_rule__list_var &wrl); // not implemented - void parent_schema_(const Schema_ptr &s) - { - _parent_schema = s; - } - void rule_text_(const char *rt) - { - _rule_text = rt; - } + void name_( Express_id & n ) { + _name = n; + } + void entities_( const Entity__set_var & e ); // not implemented + void where_rules_( const Where_rule__list_var & wrl ); // not implemented + void parent_schema_( const Schema_ptr & s ) { + _parent_schema = s; + } + void rule_text_( const char * rt ) { + _rule_text = rt; + } }; -typedef Global_rule *Global_rule_ptr; +typedef Global_rule * Global_rule_ptr; -class SC_CORE_EXPORT Global_rule__set -{ - public: - Global_rule__set(int = 16); - ~Global_rule__set(); +class SC_CORE_EXPORT Global_rule__set { +public: + Global_rule__set( int = 16 ); + ~Global_rule__set(); - Global_rule_ptr &operator[](int index); - void Insert(Global_rule_ptr, int index); - void Append(Global_rule_ptr); - void Remove(int index); - int Index(Global_rule_ptr); + Global_rule_ptr & operator[]( int index ); + void Insert( Global_rule_ptr, int index ); + void Append( Global_rule_ptr ); + void Remove( int index ); + int Index( Global_rule_ptr ); - int Count(); - void Clear(); - private: - void Check(int index); - private: - Global_rule_ptr *_buf; - int _bufsize; - int _count; + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Global_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Global_rule__set *Global_rule__set_ptr; +typedef Global_rule__set * Global_rule__set_ptr; typedef Global_rule__set_ptr Global_rule__set_var; diff --git a/src/clstepcore/implicitItemId.cc b/src/clstepcore/implicitItemId.cc index fa6443494..1961727af 100644 --- a/src/clstepcore/implicitItemId.cc +++ b/src/clstepcore/implicitItemId.cc @@ -1,114 +1,101 @@ #include "implicitItemId.h" -Implicit_item_id::Implicit_item_id() -{ +Implicit_item_id::Implicit_item_id() { _local_definition = 0; } -Implicit_item_id::Implicit_item_id(Implicit_item_id &iii) - : Interfaced_item(iii) -{ +Implicit_item_id::Implicit_item_id( Implicit_item_id & iii ) +: Interfaced_item( iii ) { _local_definition = iii._local_definition; } -Implicit_item_id::~Implicit_item_id() -{ +Implicit_item_id::~Implicit_item_id() { _local_definition = 0; } -Implicit_item_id__set::Implicit_item_id__set(int defaultSize) -{ +Implicit_item_id__set::Implicit_item_id__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Implicit_item_id_ptr[_bufsize]; _count = 0; } -Implicit_item_id__set::~Implicit_item_id__set() -{ +Implicit_item_id__set::~Implicit_item_id__set() { delete[] _buf; } -void Implicit_item_id__set::Check(int index) -{ - Implicit_item_id_ptr *newbuf; +void Implicit_item_id__set::Check( int index ) { + Implicit_item_id_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Implicit_item_id_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Implicit_item_id_ptr)); + memmove( newbuf, _buf, _count * sizeof( Implicit_item_id_ptr ) ); delete[]_buf; _buf = newbuf; } } -void Implicit_item_id__set::Insert(Implicit_item_id_ptr v, int index) -{ - Implicit_item_id_ptr *spot; - index = (index < 0) ? _count : index; +void Implicit_item_id__set::Insert( Implicit_item_id_ptr v, int index ) { + Implicit_item_id_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Append(Implicit_item_id_ptr v) -{ +void Implicit_item_id__set::Append( Implicit_item_id_ptr v ) { int index = _count; - Implicit_item_id_ptr *spot; + Implicit_item_id_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Implicit_item_id_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Implicit_item_id__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Implicit_item_id__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Implicit_item_id_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Implicit_item_id_ptr)); + Implicit_item_id_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Implicit_item_id_ptr ) ); } } -int Implicit_item_id__set::Index(Implicit_item_id_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Implicit_item_id__set::Index( Implicit_item_id_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Implicit_item_id_ptr &Implicit_item_id__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Implicit_item_id_ptr & Implicit_item_id__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Implicit_item_id__set::Count() -{ +int Implicit_item_id__set::Count() { return _count; } -void Implicit_item_id__set::Clear() -{ +void Implicit_item_id__set::Clear() { _count = 0; } diff --git a/src/clstepcore/implicitItemId.h b/src/clstepcore/implicitItemId.h index cea215d63..c8526324e 100644 --- a/src/clstepcore/implicitItemId.h +++ b/src/clstepcore/implicitItemId.h @@ -3,53 +3,49 @@ #include "interfacedItem.h" -class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item -{ - protected: - Implicit_item_id(); - Implicit_item_id(Implicit_item_id &); - virtual ~Implicit_item_id(); - public: - const TypeDescriptor *_local_definition; - - const TypeDescriptor *local_definition_() const - { - return _local_definition; - } - - // private: - void local_definition_(const TypeDescriptor *td) - { - _local_definition = td; - } +class SC_CORE_EXPORT Implicit_item_id : public Interfaced_item { +protected: + Implicit_item_id(); + Implicit_item_id( Implicit_item_id & ); + virtual ~Implicit_item_id(); +public: + const TypeDescriptor * _local_definition; + + const TypeDescriptor * local_definition_() const { + return _local_definition; + } + + // private: + void local_definition_( const TypeDescriptor * td ) { + _local_definition = td; + } }; -typedef Implicit_item_id *Implicit_item_id_ptr; - - -class SC_CORE_EXPORT Implicit_item_id__set -{ - public: - Implicit_item_id__set(int = 16); - ~Implicit_item_id__set(); - - Implicit_item_id_ptr &operator[](int index); - void Insert(Implicit_item_id_ptr, int index); - void Append(Implicit_item_id_ptr); - void Remove(int index); - int Index(Implicit_item_id_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Implicit_item_id_ptr *_buf; - int _bufsize; - int _count; +typedef Implicit_item_id * Implicit_item_id_ptr; + + +class SC_CORE_EXPORT Implicit_item_id__set { +public: + Implicit_item_id__set( int = 16 ); + ~Implicit_item_id__set(); + + Implicit_item_id_ptr & operator[]( int index ); + void Insert( Implicit_item_id_ptr, int index ); + void Append( Implicit_item_id_ptr ); + void Remove( int index ); + int Index( Implicit_item_id_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Implicit_item_id_ptr * _buf; + int _bufsize; + int _count; }; -typedef Implicit_item_id__set *Implicit_item_id__set_ptr; +typedef Implicit_item_id__set * Implicit_item_id__set_ptr; typedef Implicit_item_id__set_ptr Implicit_item_id__set_var; #endif //IMPLICITITEMID_H diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 6fa085168..702ea0869 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -36,27 +36,24 @@ static int debug_level = 3; /////////////////////////////////////////////////////////////////////////////// void -InstMgr::PrintSortedFileIds() -{ - MgrNode *mn = 0; +InstMgr::PrintSortedFileIds() { + MgrNode * mn = 0; int count = InstanceCount(); int i = 0; - for(i = 0; i < count; i++) { - mn = (MgrNode *)((*sortedMaster)[i]); + for( i = 0; i < count; i++ ) { + mn = ( MgrNode * )( ( *sortedMaster )[i] ); cout << i << " " << mn->GetFileId() << endl; } } -InstMgr::InstMgr(int ownsInstances) - : maxFileId(-1), _ownsInstances(ownsInstances) -{ +InstMgr::InstMgr( int ownsInstances ) + : maxFileId( -1 ), _ownsInstances( ownsInstances ) { master = new MgrNodeArray(); sortedMaster = new std::map; } -InstMgr::~InstMgr() -{ - if(_ownsInstances) { +InstMgr::~InstMgr() { + if( _ownsInstances ) { master->DeleteEntries(); } else { master->ClearEntries(); @@ -70,15 +67,13 @@ InstMgr::~InstMgr() /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ClearInstances() -{ +void InstMgr::ClearInstances() { master->ClearEntries(); sortedMaster->clear(); maxFileId = -1; } -void InstMgr::DeleteInstances() -{ +void InstMgr::DeleteInstances() { master->DeleteEntries(); sortedMaster->clear(); maxFileId = -1; @@ -97,13 +92,13 @@ void InstMgr::DeleteInstances() **************************************************/ enum Severity -InstMgr::VerifyInstances(ErrorDescriptor &err) { +InstMgr::VerifyInstances( ErrorDescriptor & err ) { int errorCount = 0; char errbuf[BUFSIZ]; int n = InstanceCount(); - MgrNode *mn; - SDAI_Application_instance *se; + MgrNode * mn; + SDAI_Application_instance * se; enum Severity rval = SEVERITY_NULL; //for each instance on the list, @@ -116,54 +111,52 @@ InstMgr::VerifyInstances(ErrorDescriptor &err) { // if it is not valid, then increment the error count // and set the rval to - for(int i = 0; i < n; ++i) - { - mn = GetMgrNode(i); - if(!mn) { + for( int i = 0; i < n; ++i ) { + mn = GetMgrNode( i ); + if( !mn ) { ++errorCount; - if(errorCount == 1) - sprintf(errbuf, - "VerifyInstances: Unable to verify the following instances: node %d", - i); + if( errorCount == 1 ) + sprintf( errbuf, + "VerifyInstances: Unable to verify the following instances: node %d", + i ); else { - sprintf(errbuf, ", node %d", i); + sprintf( errbuf, ", node %d", i ); } - err.AppendToDetailMsg(errbuf); + err.AppendToDetailMsg( errbuf ); rval = SEVERITY_INPUT_ERROR; - err.GreaterSeverity(SEVERITY_INPUT_ERROR); + err.GreaterSeverity( SEVERITY_INPUT_ERROR ); continue; } - if(debug_level > 3) + if( debug_level > 3 ) cerr << "In VerifyInstances: " << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if(!mn->MgrNodeListMember(completeSE)) { + if( !mn->MgrNodeListMember( completeSE ) ) { se = mn->GetApplication_instance(); - if(se->ValidLevel(&err, this, 0) < SEVERITY_USERMSG) { - if(rval > SEVERITY_INCOMPLETE) { + if( se->ValidLevel( &err, this, 0 ) < SEVERITY_USERMSG ) { + if( rval > SEVERITY_INCOMPLETE ) { rval = SEVERITY_INCOMPLETE; } ++errorCount; - if(errorCount == 1) - sprintf(errbuf, - "VerifyInstances: Unable to verify the following instances: #%d", - se->StepFileId()); + if( errorCount == 1 ) + sprintf( errbuf, + "VerifyInstances: Unable to verify the following instances: #%d", + se->StepFileId() ); else { - sprintf(errbuf, ", #%d", se->StepFileId()); + sprintf( errbuf, ", #%d", se->StepFileId() ); } - err.AppendToDetailMsg(errbuf); + err.AppendToDetailMsg( errbuf ); } } } - if(errorCount) - { - sprintf(errbuf, - "VerifyInstances: %d invalid instances in list.\n", - errorCount); - err.AppendToUserMsg(errbuf); - err.AppendToDetailMsg(".\n"); - err.GreaterSeverity(SEVERITY_INCOMPLETE); + if( errorCount ) { + sprintf( errbuf, + "VerifyInstances: %d invalid instances in list.\n", + errorCount ); + err.AppendToUserMsg( errbuf ); + err.AppendToDetailMsg( ".\n" ); + err.GreaterSeverity( SEVERITY_INCOMPLETE ); } return rval; @@ -171,32 +164,27 @@ InstMgr::VerifyInstances(ErrorDescriptor &err) { /////////////////////////////////////////////////////////////////////////////// -MgrNode *InstMgr::FindFileId(int fileId) -{ - std::map::iterator it; - it = sortedMaster->find(fileId); - if(it == sortedMaster->end()) { - return (MgrNode *)0; - } - return it->second; +MgrNode * InstMgr::FindFileId( int fileId ) { + std::map::iterator it; + it=sortedMaster->find(fileId); + if (it == sortedMaster->end()) return ( MgrNode * )0; + return it->second; } /////////////////////////////////////////////////////////////////////////////// // get the index into display list given a SDAI_Application_instance // called by see initiated functions -int InstMgr::GetIndex(MgrNode *mn) -{ +int InstMgr::GetIndex( MgrNode * mn ) { return mn->ArrayIndex(); } /////////////////////////////////////////////////////////////////////////////// -int InstMgr::VerifyEntity(int fileId, const char *expectedType) -{ - MgrNode *mn = FindFileId(fileId); - if(mn) { - if(!strcmp(expectedType, mn->GetApplication_instance()->EntityName())) { +int InstMgr::VerifyEntity( int fileId, const char * expectedType ) { + MgrNode * mn = FindFileId( fileId ); + if( mn ) { + if( !strcmp( expectedType, mn->GetApplication_instance()->EntityName() ) ) { return 2; // types match } else { return 1; // possible mismatch depending on descendants @@ -210,40 +198,39 @@ int InstMgr::VerifyEntity(int fileId, const char *expectedType) // Append instance to the list of instances. Checks the file id and // sets it if 1) it is not set already or 2) it already exists in the list. -MgrNode *InstMgr::Append(SDAI_Application_instance *se, stateEnum listState) -{ - if(debug_level > 3) { +MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState ) { + if( debug_level > 3 ) { cout << "#" << se->StepFileId() << " append node to InstMgr" << endl; } - MgrNode *mn = 0; + MgrNode * mn = 0; - if(se->StepFileId() == 0) { // no id assigned - se->StepFileId(NextFileId()); // assign a file id + if( se->StepFileId() == 0 ) { // no id assigned + se->StepFileId( NextFileId() ); // assign a file id } - mn = FindFileId(se->StepFileId()); - if(mn) { // if id already in list + mn = FindFileId( se->StepFileId() ); + if( mn ) { // if id already in list // and it's because instance is already in list - if(GetApplication_instance(mn) == se) { + if( GetApplication_instance( mn ) == se ) { return 0; // return 0 or mn? } else { - se->StepFileId(NextFileId()); // otherwise assign a new file id + se->StepFileId( NextFileId() ); // otherwise assign a new file id } } // update the maxFileId if needed - if(se->StepFileId() > MaxFileId()) { + if( se->StepFileId() > MaxFileId() ) { maxFileId = se->StepFileId(); } - mn = new MgrNode(se, listState); + mn = new MgrNode( se, listState ); - if(debug_level > 3) + if( debug_level > 3 ) cerr << "new MgrNode for " << mn->GetFileId() << " with state " << mn->CurrState() << endl; - if(listState == noStateSE) + if( listState == noStateSE ) cout << "append to InstMgr **ERROR ** node #" << se->StepFileId() << " doesn't have state information" << endl; - master->Append(mn); + master->Append( mn ); (*sortedMaster)[mn->GetFileId()] = mn; //PrintSortedFileIds(); return mn; @@ -251,56 +238,53 @@ MgrNode *InstMgr::Append(SDAI_Application_instance *se, stateEnum listState) /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete(MgrNode *node) -{ +void InstMgr::Delete( MgrNode * node ) { // delete the node from its current state list node->Remove(); // remove the node from the sorted master array - sortedMaster->erase(node->GetFileId()); + sortedMaster->erase( node->GetFileId() ); // get the index into the master array by ptr arithmetic int index = node->ArrayIndex(); - master->Remove(index); + master->Remove( index ); delete node; } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::Delete(SDAI_Application_instance *se) -{ - Delete(FindFileId(se->StepFileId())); +void InstMgr::Delete( SDAI_Application_instance * se ) { + Delete( FindFileId( se->StepFileId() ) ); } /////////////////////////////////////////////////////////////////////////////// -void InstMgr::ChangeState(MgrNode *node, stateEnum listState) -{ - switch(listState) { +void InstMgr::ChangeState( MgrNode * node, stateEnum listState ) { + switch( listState ) { case completeSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's complete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case incompleteSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's incomplete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case newSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's new list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case deleteSE: - if(debug_level > 3) + if( debug_level > 3 ) cout << "#" << node->GetApplication_instance()->StepFileId() << " change node to InstMgr's delete list\n"; - node->ChangeState(listState); + node->ChangeState( listState ); break; case noStateSE: cout << "#" << node->GetApplication_instance()->StepFileId() << @@ -319,17 +303,16 @@ void InstMgr::ChangeState(MgrNode *node, stateEnum listState) on the instance manager. **************************************************/ int -InstMgr::EntityKeywordCount(const char *name) -{ +InstMgr::EntityKeywordCount( const char * name ) { int count = 0; - MgrNode *node; - SDAI_Application_instance *se; + MgrNode * node; + SDAI_Application_instance * se; int n = InstanceCount(); - const char *pretty_name = PrettyTmpName(name); - for(int j = 0; j < n; ++j) { - node = GetMgrNode(j); + const char *pretty_name = PrettyTmpName( name ); + for( int j = 0; j < n; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { ++count; } } @@ -339,10 +322,9 @@ InstMgr::EntityKeywordCount(const char *name) /////////////////////////////////////////////////////////////////////////////// SDAI_Application_instance * -InstMgr::GetApplication_instance(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetApplication_instance( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->GetApplication_instance(); } else { return 0; @@ -350,10 +332,9 @@ InstMgr::GetApplication_instance(int index) } SDAI_Application_instance * -InstMgr::GetSTEPentity(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetSTEPentity( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->GetApplication_instance(); } else { return 0; @@ -373,17 +354,16 @@ InstMgr::GetSTEPentity(int index) starting_index. **************************************************/ SDAI_Application_instance * -InstMgr::GetApplication_instance(const char *entityKeyword, int starting_index) -{ - MgrNode *node; - SDAI_Application_instance *se; - const char *pretty_name = PrettyTmpName(entityKeyword); +InstMgr::GetApplication_instance( const char * entityKeyword, int starting_index ) { + MgrNode * node; + SDAI_Application_instance * se; + const char *pretty_name = PrettyTmpName( entityKeyword ); int count = InstanceCount(); - for(int j = starting_index; j < count; ++j) { - node = GetMgrNode(j); + for( int j = starting_index; j < count; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { return se; } } @@ -391,17 +371,16 @@ InstMgr::GetApplication_instance(const char *entityKeyword, int starting_index) } SDAI_Application_instance * -InstMgr::GetSTEPentity(const char *entityKeyword, int starting_index) -{ - MgrNode *node; - SDAI_Application_instance *se; - const char *pretty_name = PrettyTmpName(entityKeyword); +InstMgr::GetSTEPentity( const char * entityKeyword, int starting_index ) { + MgrNode * node; + SDAI_Application_instance * se; + const char *pretty_name = PrettyTmpName( entityKeyword ); int count = InstanceCount(); - for(int j = starting_index; j < count; ++j) { - node = GetMgrNode(j); + for( int j = starting_index; j < count; ++j ) { + node = GetMgrNode( j ); se = node->GetApplication_instance(); - if(!strcmp(se->EntityName(), pretty_name)) { + if( !strcmp( se->EntityName(), pretty_name ) ) { return se; } } @@ -411,10 +390,9 @@ InstMgr::GetSTEPentity(const char *entityKeyword, int starting_index) /////////////////////////////////////////////////////////////////////////////// void * -InstMgr::GetSEE(int index) -{ - MgrNode *mn = (MgrNode *)(*master)[index]; - if(mn) { +InstMgr::GetSEE( int index ) { + MgrNode * mn = ( MgrNode * )( *master )[index]; + if( mn ) { return mn->SEE(); } else { return 0; diff --git a/src/clstepcore/instmgr.h b/src/clstepcore/instmgr.h index 0b8a8fa49..3f185b3fb 100644 --- a/src/clstepcore/instmgr.h +++ b/src/clstepcore/instmgr.h @@ -39,107 +39,95 @@ #include -class SC_CORE_EXPORT InstMgrBase -{ +class SC_CORE_EXPORT InstMgrBase { public: - virtual MgrNodeBase *FindFileId(int fileId) = 0; + virtual MgrNodeBase * FindFileId( int fileId ) = 0; virtual ~InstMgrBase() {}; }; -class SC_CORE_EXPORT InstMgr : public InstMgrBase -{ +class SC_CORE_EXPORT InstMgr : public InstMgrBase { protected: int maxFileId; int _ownsInstances; // if true will delete instances inside destructor - MgrNodeArray *master; // master array of all MgrNodes made up of + 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 - std::map *sortedMaster; // master array sorted by fileId + std::map *sortedMaster; // master array sorted by fileId // StateList *master; // this will be an sorted array of ptrs to MgrNodes public: - InstMgr(int ownsInstances = 0); + InstMgr( int ownsInstances = 0 ); virtual ~InstMgr(); // MASTER LIST OPERATIONS - int InstanceCount() const - { + int InstanceCount() const { return master->Count(); } - int OwnsInstances() const - { + int OwnsInstances() const { return _ownsInstances; } - void OwnsInstances(int ownsInstances) - { + void OwnsInstances( int ownsInstances ) { _ownsInstances = ownsInstances; } void ClearInstances(); //clears instance lists but doesn't delete instances void DeleteInstances(); // deletes the instances (ignores _ownsInstances) - Severity VerifyInstances(ErrorDescriptor &e); + Severity VerifyInstances( ErrorDescriptor & e ); // DAS PORT possible BUG two funct's below may create a temp for the cast - MgrNode *GetMgrNode(int index) - { - return (MgrNode *) * GetGenNode(index); + MgrNode * GetMgrNode( int index ) { + return ( MgrNode * ) * GetGenNode( index ); } - GenericNode **GetGenNode(int index) - { - return &(*master) [index]; + GenericNode ** GetGenNode( int index ) { + return &( *master ) [index]; } - MgrNode *FindFileId(int fileId); + MgrNode * FindFileId( int fileId ); // get the index into display list given a SDAI_Application_instance // called by see initiated functions - int GetIndex(SDAI_Application_instance *se); - int GetIndex(MgrNode *mn); - int VerifyEntity(int fileId, const char *expectedType); + int GetIndex( SDAI_Application_instance * se ); + int GetIndex( MgrNode * mn ); + int VerifyEntity( int fileId, const char * expectedType ); // void Append(MgrNode *node); - MgrNode *Append(SDAI_Application_instance *se, stateEnum listState); + MgrNode * Append( SDAI_Application_instance * se, stateEnum listState ); // deletes node from master list structure - void Delete(MgrNode *node); - void Delete(SDAI_Application_instance *se); + void Delete( MgrNode * node ); + void Delete( SDAI_Application_instance * se ); - void ChangeState(MgrNode *node, stateEnum listState); + void ChangeState( MgrNode * node, stateEnum listState ); - int MaxFileId() - { + int MaxFileId() { return maxFileId; } - int NextFileId() - { + int NextFileId() { return maxFileId = maxFileId + 1; } - int EntityKeywordCount(const char *name); + int EntityKeywordCount( const char * name ); - SDAI_Application_instance *GetApplication_instance(int index); + SDAI_Application_instance * GetApplication_instance( int index ); SDAI_Application_instance * - GetApplication_instance(const char *entityKeyword, - int starting_index = 0); - SDAI_Application_instance *GetApplication_instance(MgrNode *node) - { + GetApplication_instance( const char * entityKeyword, + int starting_index = 0 ); + SDAI_Application_instance * GetApplication_instance( MgrNode * node ) { return node->GetApplication_instance(); } - void *GetSEE(int index); - void *GetSEE(MgrNode *node) - { + void * GetSEE( int index ); + void * GetSEE( MgrNode * node ) { return node->SEE(); } void PrintSortedFileIds(); // OBSOLETE - SDAI_Application_instance *GetSTEPentity(int index); - SDAI_Application_instance *GetSTEPentity(const char *entityKeyword, - int starting_index = 0); - SDAI_Application_instance *GetSTEPentity(MgrNode *node) - { + SDAI_Application_instance * GetSTEPentity( int index ); + SDAI_Application_instance * GetSTEPentity( const char * entityKeyword, + int starting_index = 0 ); + SDAI_Application_instance * GetSTEPentity( MgrNode * node ) { return node->GetApplication_instance(); } diff --git a/src/clstepcore/interfaceSpec.cc b/src/clstepcore/interfaceSpec.cc index a8bf4ae2c..eb0fecf3a 100644 --- a/src/clstepcore/interfaceSpec.cc +++ b/src/clstepcore/interfaceSpec.cc @@ -1,119 +1,107 @@ #include "interfaceSpec.h" -Interface_spec__set::Interface_spec__set(int defaultSize) -{ +Interface_spec__set::Interface_spec__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Interface_spec_ptr[_bufsize]; _count = 0; } -Interface_spec__set::~Interface_spec__set() -{ +Interface_spec__set::~Interface_spec__set() { delete[] _buf; } -void Interface_spec__set::Check(int index) -{ - Interface_spec_ptr *newbuf; +void Interface_spec__set::Check( int index ) { + Interface_spec_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Interface_spec_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Interface_spec_ptr)); + memmove( newbuf, _buf, _count * sizeof( Interface_spec_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Interface_spec__set::Insert(Interface_spec_ptr v, int index) -{ - Interface_spec_ptr *spot; - index = (index < 0) ? _count : index; +void Interface_spec__set::Insert( Interface_spec_ptr v, int index ) { + Interface_spec_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Append(Interface_spec_ptr v) -{ +void Interface_spec__set::Append( Interface_spec_ptr v ) { int index = _count; - Interface_spec_ptr *spot; + Interface_spec_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Interface_spec_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Interface_spec__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Interface_spec__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Interface_spec_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Interface_spec_ptr)); + Interface_spec_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Interface_spec_ptr ) ); } } -int Interface_spec__set::Index(Interface_spec_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Interface_spec__set::Index( Interface_spec_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Interface_spec_ptr &Interface_spec__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Interface_spec_ptr & Interface_spec__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Interface_spec__set::Count() -{ +int Interface_spec__set::Count() { return _count; } -void Interface_spec__set::Clear() -{ +void Interface_spec__set::Clear() { _count = 0; } /////////////////////////////////////////////////////////////////////////////// Interface_spec::Interface_spec() - : _explicit_items(new Explicit_item_id__set), - _implicit_items(0), _all_objects(0) -{ +: _explicit_items( new Explicit_item_id__set ), +_implicit_items( 0 ), _all_objects( 0 ) { } /// not tested -Interface_spec::Interface_spec(Interface_spec &is): Dictionary_instance() -{ +Interface_spec::Interface_spec( Interface_spec & is ): Dictionary_instance() { _explicit_items = new Explicit_item_id__set; int count = is._explicit_items->Count(); int i; - for(i = 0; i < count; i++) { - (*_explicit_items)[i] = - (*(is._explicit_items))[i]; + for( i = 0; i < count; i++ ) { + ( *_explicit_items )[i] = + ( *( is._explicit_items ) )[i]; } _current_schema_id = is._current_schema_id; _foreign_schema_id = is._foreign_schema_id; @@ -121,16 +109,14 @@ Interface_spec::Interface_spec(Interface_spec &is): Dictionary_instance() _implicit_items = 0; } -Interface_spec::Interface_spec(const char *cur_sch_id, - const char *foreign_sch_id, int all_objects) - : _current_schema_id(cur_sch_id), _explicit_items(new Explicit_item_id__set), - _implicit_items(0), _foreign_schema_id(foreign_sch_id), - _all_objects(all_objects) -{ +Interface_spec::Interface_spec( const char * cur_sch_id, + const char * foreign_sch_id, int all_objects ) +: _current_schema_id( cur_sch_id ), _explicit_items( new Explicit_item_id__set ), +_implicit_items( 0 ), _foreign_schema_id( foreign_sch_id ), +_all_objects( all_objects ) { } -Interface_spec::~Interface_spec() -{ +Interface_spec::~Interface_spec() { delete _explicit_items; delete _implicit_items; } diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index a109bb22f..8469a555d 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -7,109 +7,93 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interface_spec : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Interface_spec : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _current_schema_id; // schema containing the USE/REF stmt + Express_id _current_schema_id; // schema containing the USE/REF stmt + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list). + // schema that defined the USE/REFd objects + Express_id _foreign_schema_id; #ifdef _MSC_VER #pragma warning( pop ) #endif - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable: 4251 ) -#endif - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list). - // schema that defined the USE/REFd objects - Express_id _foreign_schema_id; -#ifdef _MSC_VER -#pragma warning( pop ) -#endif - - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list of ints). - // schema USEs or REFERENCEs all objects from foreign schema - int _all_objects; - - Interface_spec(); - Interface_spec(Interface_spec &); // not tested - Interface_spec(const char *cur_sch_id, const char *foreign_sch_id, - int all_objects = 0); - virtual ~Interface_spec(); - - Express_id current_schema_id_() - { - return _current_schema_id; - } - Express_id foreign_schema_id_() - { - return _foreign_schema_id; - } - - Explicit_item_id__set_var explicit_items_() - { - return _explicit_items; - } - - // this is not yet initialized for the schema - Implicit_item_id__set_var implicit_items_() - { - return _implicit_items; - } - - // private: - void current_schema_id_(const Express_id &ei) - { - _current_schema_id = ei; - } - void foreign_schema_id_(const Express_id &fi) - { - _foreign_schema_id = fi; - } - - int all_objects_() - { - return _all_objects; - } - void all_objects_(int ao) - { - _all_objects = ao; - } + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema + + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list of ints). + // schema USEs or REFERENCEs all objects from foreign schema + int _all_objects; + + Interface_spec(); + Interface_spec( Interface_spec & ); // not tested + Interface_spec( const char * cur_sch_id, const char * foreign_sch_id, + int all_objects = 0 ); + virtual ~Interface_spec(); + + Express_id current_schema_id_() { + return _current_schema_id; + } + Express_id foreign_schema_id_() { + return _foreign_schema_id; + } + + Explicit_item_id__set_var explicit_items_() { + return _explicit_items; + } + + // this is not yet initialized for the schema + Implicit_item_id__set_var implicit_items_() { + return _implicit_items; + } + + // private: + void current_schema_id_( const Express_id & ei ) { + _current_schema_id = ei; + } + void foreign_schema_id_( const Express_id & fi ) { + _foreign_schema_id = fi; + } + + int all_objects_() { + return _all_objects; + } + void all_objects_( int ao ) { + _all_objects = ao; + } }; -typedef Interface_spec *Interface_spec_ptr; - -class SC_CORE_EXPORT Interface_spec__set -{ - public: - Interface_spec__set(int = 16); - ~Interface_spec__set(); - - Interface_spec_ptr &operator[](int index); - void Insert(Interface_spec_ptr, int index); - void Append(Interface_spec_ptr); - void Remove(int index); - int Index(Interface_spec_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Interface_spec_ptr *_buf; - int _bufsize; - int _count; +typedef Interface_spec * Interface_spec_ptr; + +class SC_CORE_EXPORT Interface_spec__set { +public: + Interface_spec__set( int = 16 ); + ~Interface_spec__set(); + + Interface_spec_ptr & operator[]( int index ); + void Insert( Interface_spec_ptr, int index ); + void Append( Interface_spec_ptr ); + void Remove( int index ); + int Index( Interface_spec_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Interface_spec_ptr * _buf; + int _bufsize; + int _count; }; -typedef Interface_spec__set *Interface_spec__set_ptr; +typedef Interface_spec__set * Interface_spec__set_ptr; typedef Interface_spec__set_ptr Interface_spec__set_var; diff --git a/src/clstepcore/interfacedItem.cc b/src/clstepcore/interfacedItem.cc index fe3a67fdf..749a5922e 100644 --- a/src/clstepcore/interfacedItem.cc +++ b/src/clstepcore/interfacedItem.cc @@ -1,30 +1,24 @@ #include "interfacedItem.h" -Interfaced_item::Interfaced_item() -{ +Interfaced_item::Interfaced_item() { } -Interfaced_item::Interfaced_item(const Interfaced_item &ii): Dictionary_instance() -{ +Interfaced_item::Interfaced_item( const Interfaced_item & ii ): Dictionary_instance() { _foreign_schema = ii._foreign_schema; } -Interfaced_item::Interfaced_item(const char *foreign_schema) - : _foreign_schema(foreign_schema) -{ +Interfaced_item::Interfaced_item( const char * foreign_schema ) +: _foreign_schema( foreign_schema ) { } -Interfaced_item::~Interfaced_item() -{ +Interfaced_item::~Interfaced_item() { } -const Express_id Interfaced_item::foreign_schema_() -{ +const Express_id Interfaced_item::foreign_schema_() { return _foreign_schema; } -void Interfaced_item::foreign_schema_(const Express_id &fs) -{ +void Interfaced_item::foreign_schema_( const Express_id & fs ) { _foreign_schema = fs; } diff --git a/src/clstepcore/interfacedItem.h b/src/clstepcore/interfacedItem.h index 78b74c1fa..00401b68b 100644 --- a/src/clstepcore/interfacedItem.h +++ b/src/clstepcore/interfacedItem.h @@ -7,26 +7,25 @@ #include "sc_export.h" -class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance -{ - protected: - Interfaced_item(); - Interfaced_item(const Interfaced_item &); - Interfaced_item(const char *foreign_schema); - virtual ~Interfaced_item(); - public: +class SC_CORE_EXPORT Interfaced_item : public Dictionary_instance { +protected: + Interfaced_item(); + Interfaced_item( const Interfaced_item & ); + Interfaced_item( const char * foreign_schema ); + virtual ~Interfaced_item(); +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _foreign_schema; + Express_id _foreign_schema; #ifdef _MSC_VER #pragma warning( pop ) #endif - const Express_id foreign_schema_(); - // private: - void foreign_schema_(const Express_id &); + const Express_id foreign_schema_(); + // private: + void foreign_schema_( const Express_id & ); }; #endif //INTERFACEDITEM_H diff --git a/src/clstepcore/inverseAttribute.cc b/src/clstepcore/inverseAttribute.cc index 13ae8721a..eeccec90a 100644 --- a/src/clstepcore/inverseAttribute.cc +++ b/src/clstepcore/inverseAttribute.cc @@ -1,20 +1,19 @@ #include "inverseAttribute.h" #include -const char *Inverse_attribute::AttrExprDefStr(std::string &s) const -{ +const char * Inverse_attribute::AttrExprDefStr( std::string & s ) const { std::string buf; s = Name(); - s.append(" : "); - if(_optional.asInt() == LTrue) { - s.append("OPTIONAL "); + s.append( " : " ); + if( _optional.asInt() == LTrue ) { + s.append( "OPTIONAL " ); } - if(DomainType()) { - DomainType()->AttrTypeName(buf); - s.append(buf); + if( DomainType() ) { + DomainType()->AttrTypeName( buf ); + s.append( buf ); } - s.append(" FOR "); - s.append(_inverted_attr_id); - return const_cast(s.c_str()); + s.append( " FOR " ); + s.append( _inverted_attr_id ); + return const_cast( s.c_str() ); } diff --git a/src/clstepcore/inverseAttribute.h b/src/clstepcore/inverseAttribute.h index 3032cac15..0d02b793d 100644 --- a/src/clstepcore/inverseAttribute.h +++ b/src/clstepcore/inverseAttribute.h @@ -3,61 +3,54 @@ #include "attrDescriptor.h" -class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor -{ +class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor { public: - const char *_inverted_attr_id; - const char *_inverted_entity_id; + const char * _inverted_attr_id; + const char * _inverted_entity_id; protected: - const AttrDescriptor *_inverted_attr; // not implemented (?!) (perhaps this means "not used"?) + const AttrDescriptor * _inverted_attr; // not implemented (?!) (perhaps this means "not used"?) public: Inverse_attribute( - const char *name, // i.e. char * - TypeDescriptor *domainType, + const char * name, // i.e. char * + TypeDescriptor * domainType, Logical optional, // i.e. F U or T*/ Logical unique, // i.e. F U or T - const EntityDescriptor &owner, - const char *inverted_attr_id = 0 - ) : AttrDescriptor(name, domainType, optional, unique, - AttrType_Inverse, owner), - _inverted_attr_id(inverted_attr_id), - _inverted_entity_id(0), _inverted_attr(0) + const EntityDescriptor & owner, + const char * inverted_attr_id = 0 + ) : AttrDescriptor( name, domainType, optional, unique, + AttrType_Inverse, owner ), + _inverted_attr_id( inverted_attr_id ), + _inverted_entity_id( 0 ), _inverted_attr( 0 ) { } virtual ~Inverse_attribute() { } - const char *AttrExprDefStr(std::string &s) const; + const char * AttrExprDefStr( std::string & s ) const; - const char *inverted_attr_id_() const - { + const char * inverted_attr_id_() const { return _inverted_attr_id; } - void inverted_attr_id_(const char *iai) - { + void inverted_attr_id_( const char * iai ) { _inverted_attr_id = iai; } - const char *inverted_entity_id_() const - { + const char * inverted_entity_id_() const { return _inverted_entity_id; } - void inverted_entity_id_(const char *iei) - { + void inverted_entity_id_( const char * iei ) { _inverted_entity_id = iei; } /// 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 - { + const class AttrDescriptor * inverted_attr_() const { return _inverted_attr; } - void inverted_attr_(const AttrDescriptor *ia) - { + void inverted_attr_( const AttrDescriptor * ia ) { _inverted_attr = ia; } diff --git a/src/clstepcore/inverseAttributeList.cc b/src/clstepcore/inverseAttributeList.cc index 96207adf2..22591d41c 100644 --- a/src/clstepcore/inverseAttributeList.cc +++ b/src/clstepcore/inverseAttributeList.cc @@ -1,53 +1,45 @@ #include "inverseAttributeList.h" #include "inverseAttribute.h" -Inverse_attributeLinkNode::Inverse_attributeLinkNode() -{ +Inverse_attributeLinkNode::Inverse_attributeLinkNode() { _invAttr = 0; } -Inverse_attributeLinkNode::~Inverse_attributeLinkNode() -{ +Inverse_attributeLinkNode::~Inverse_attributeLinkNode() { } -Inverse_attributeList::Inverse_attributeList() -{ +Inverse_attributeList::Inverse_attributeList() { } -Inverse_attributeList::~Inverse_attributeList() -{ - Inverse_attributeLinkNode *node; +Inverse_attributeList::~Inverse_attributeList() { + Inverse_attributeLinkNode * node; - node = (Inverse_attributeLinkNode *) head; - while(node) { + node = ( Inverse_attributeLinkNode * ) head; + while( node ) { delete node->Inverse_attr(); - node = (Inverse_attributeLinkNode *) node->NextNode(); + node = ( Inverse_attributeLinkNode * ) node->NextNode(); } } -Inverse_attributeLinkNode *Inverse_attributeList::AddNode(Inverse_attribute *ad) -{ - Inverse_attributeLinkNode *node = (Inverse_attributeLinkNode *) NewNode(); - node->Inverse_attr(ad); - SingleLinkList::AppendNode(node); +Inverse_attributeLinkNode * Inverse_attributeList::AddNode( Inverse_attribute * ad ) { + Inverse_attributeLinkNode * node = ( Inverse_attributeLinkNode * ) NewNode(); + node->Inverse_attr( ad ); + SingleLinkList::AppendNode( node ); return node; } -InverseAItr::InverseAItr(const Inverse_attributeList *iaList) - : ial(iaList) -{ - cur = (Inverse_attributeLinkNode *)(ial->GetHead()); +InverseAItr::InverseAItr( const Inverse_attributeList * iaList ) + : ial( iaList ) { + cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); } -InverseAItr::~InverseAItr() -{ +InverseAItr::~InverseAItr() { } -Inverse_attribute *InverseAItr::NextInverse_attribute() -{ - if(cur) { - Inverse_attribute *ia = cur->Inverse_attr(); - cur = (Inverse_attributeLinkNode *)(cur->NextNode()); +Inverse_attribute * InverseAItr::NextInverse_attribute() { + if( cur ) { + Inverse_attribute * ia = cur->Inverse_attr(); + cur = ( Inverse_attributeLinkNode * )( cur->NextNode() ); return ia; } return 0; diff --git a/src/clstepcore/inverseAttributeList.h b/src/clstepcore/inverseAttributeList.h index 1bacf6f95..e7dc8a7d6 100644 --- a/src/clstepcore/inverseAttributeList.h +++ b/src/clstepcore/inverseAttributeList.h @@ -6,58 +6,51 @@ #include "SingleLinkList.h" class Inverse_attribute; -class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode { private: protected: - Inverse_attribute *_invAttr; + Inverse_attribute * _invAttr; public: Inverse_attributeLinkNode(); virtual ~Inverse_attributeLinkNode(); - Inverse_attribute *Inverse_attr() const - { + Inverse_attribute * Inverse_attr() const { return _invAttr; } - void Inverse_attr(Inverse_attribute *ia) - { + void Inverse_attr( Inverse_attribute * ia ) { _invAttr = ia; } }; -class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList -{ +class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList { private: protected: - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new Inverse_attributeLinkNode; } public: Inverse_attributeList(); virtual ~Inverse_attributeList(); - Inverse_attributeLinkNode *AddNode(Inverse_attribute *ia); + Inverse_attributeLinkNode * AddNode( Inverse_attribute * ia ); }; -class SC_CORE_EXPORT InverseAItr -{ +class SC_CORE_EXPORT InverseAItr { protected: - const Inverse_attributeList *ial; - const Inverse_attributeLinkNode *cur; + const Inverse_attributeList * ial; + const Inverse_attributeLinkNode * cur; public: - InverseAItr(const Inverse_attributeList *iaList); + InverseAItr( const Inverse_attributeList * iaList ); virtual ~InverseAItr(); - void ResetItr(const Inverse_attributeList *iaList = 0) - { - if(iaList) { + void ResetItr( const Inverse_attributeList * iaList = 0 ) { + if( iaList ) { ial = iaList; } - cur = (Inverse_attributeLinkNode *)(ial->GetHead()); + cur = ( Inverse_attributeLinkNode * )( ial->GetHead() ); } - Inverse_attribute *NextInverse_attribute(); + Inverse_attribute * NextInverse_attribute(); }; #endif //INVERSEATTRIBUTELIST_H diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index ec33b65db..5f17f7d93 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -25,25 +25,24 @@ * OR descendants we didn't test. Thus, UNKNOWN tells us that this child * is an OR, or has an OR somewhere beneath it which we must process now. */ -MatchType AndOrList::matchORs(EntNode *ents) -{ - EntList *child = childList->firstWanted(UNKNOWN); +MatchType AndOrList::matchORs( EntNode * ents ) { + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child))->matchORs( ents ) == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -53,24 +52,23 @@ MatchType AndOrList::matchORs(EntNode *ents) * descendants match the nodes of ents. We only take UNKNOWN's because * they will lead us to OR's, as explained in AndOrList::matchORs(). */ -MatchType AndList::matchORs(EntNode *ents) -{ - EntList *child = childList->firstWanted(UNKNOWN); +MatchType AndList::matchORs( EntNode * ents ) { + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -82,44 +80,43 @@ MatchType AndList::matchORs(EntNode *ents) * retain the info that these were only conditionally marked. Also, if a * MATCHALL solution was found, that is returned immediately. */ -MatchType OrList::matchORs(EntNode *ents) -{ +MatchType OrList::matchORs( EntNode * ents ) { int count; - EntList *child = childList; + EntList * child = childList; MatchType retval = UNKNOWN; - for(count = 0; count < numchildren; count++, child = child->next) { + for( count = 0; count < numchildren; count++, child = child->next ) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if(child->join != OR) { - retval = child->matchNonORs(ents); + if( child->join != OR ) { + retval = child->matchNonORs( ents ); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if(child->viable == UNKNOWN) { + if( child->viable == UNKNOWN ) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = (dynamic_cast< MultList * >(child))->matchORs(ents); + retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); } // Now register the result: - if(retval >= MATCHSOME) { + if( retval >= MATCHSOME ) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if(choice == -1) { + if( choice == -1 ) { choice1 = choice = count; } choiceCount++; - if(viable < retval) { + if( viable < retval ) { viable = retval; } } else { @@ -131,17 +128,17 @@ MatchType OrList::matchORs(EntNode *ents) // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if(viable < retval) { + if( viable < retval ) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll(ents); + child->unmarkAll( ents ); } // Accept the first viable solution, if there is one: - if(viable >= MATCHSOME) { + if( viable >= MATCHSOME ) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -150,10 +147,10 @@ MatchType OrList::matchORs(EntNode *ents) // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice(ents); + acceptChoice( ents ); } - if(viable == MATCHALL) { - return getChild(choice1)->viable; + if( viable == MATCHALL ) { + return getChild( choice1 )->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 9abde8d0b..8e44443ee 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -24,18 +24,15 @@ #include #include "sc_memmgr.h" -void *MgrNode::SEE() -{ - return (di ? di->SEE() : 0); +void * MgrNode::SEE() { + return ( di ? di->SEE() : 0 ); } -int MgrNode::GetFileId() -{ - return (se ? se->GetFileId() : -1); +int MgrNode::GetFileId() { + return ( se ? se->GetFileId() : -1 ); } -void MgrNode::Remove() -{ +void MgrNode::Remove() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Remove()\n"; // if(debug_level >= PrintValues) @@ -45,36 +42,34 @@ void MgrNode::Remove() } // searches current list for fileId -MgrNode *MgrNode::StateFindFileId(int fileId) -{ +MgrNode * MgrNode::StateFindFileId( int fileId ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::StateFindFileId()\n"; - MgrNode *startNode = this; - if(startNode->GetFileId() == fileId) { + MgrNode * startNode = this; + if( startNode->GetFileId() == fileId ) { return this; } else { // mn is really a MgrNode - MgrNode *mn = (MgrNode *)(startNode->Next()); - while(mn != startNode) { - if(mn->GetFileId() == fileId) { - return (MgrNode *)mn; + MgrNode * mn = ( MgrNode * )( startNode->Next() ); + while( mn != startNode ) { + if( mn->GetFileId() == fileId ) { + return ( MgrNode * )mn; } - mn = ((MgrNode *)mn->Next()); + mn = ( ( MgrNode * )mn->Next() ); } - return (MgrNode *)0; + return ( MgrNode * )0; } } -MgrNode::~MgrNode() -{ +MgrNode::~MgrNode() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::~MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - if(se) { + if( se ) { delete se; } - if(di) { + if( di ) { delete di; } // GenericNode::Remove(); // this is called by default. @@ -82,26 +77,23 @@ MgrNode::~MgrNode() ///////////////////// class MgrNode Display Functions ///////////////////////// -displayStateEnum MgrNode::DisplayState() -{ +displayStateEnum MgrNode::DisplayState() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::DisplayState()\n"; - return (di ? di->DisplayState() : noMapState); + return ( di ? di->DisplayState() : noMapState ); } -int MgrNode::IsDisplayState(displayStateEnum ds) -{ +int MgrNode::IsDisplayState( displayStateEnum ds ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::IsDisplayState()\n"; - return (di ? di->DisplayListMember(ds) : 0); + return ( di ? di->DisplayListMember( ds ) : 0 ); } -GenericNode *MgrNode::NextDisplay() -{ +GenericNode * MgrNode::NextDisplay() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::NextDisplay()\n"; // return (di ? ((DisplayNode *)di->Next()) : (DisplayNode *)0); - if(di) { + if( di ) { // GenericNode *dn = di->Next(); // return (DisplayNode *)dn; // return (DisplayNode *)(di->Next()); @@ -111,12 +103,11 @@ GenericNode *MgrNode::NextDisplay() } } -GenericNode *MgrNode::PrevDisplay() -{ +GenericNode * MgrNode::PrevDisplay() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::PrevDisplay()\n"; // return (di ? ((DisplayNode *)di->Prev()) : 0); - if(di) { + if( di ) { return di->Prev(); } else { return 0; @@ -126,34 +117,30 @@ GenericNode *MgrNode::PrevDisplay() // STATE LIST OPERATIONS // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList(DisplayNodeList *cmdList) -{ - if(!di) { - di = new class DisplayNode(this); +int MgrNode::ChangeList( DisplayNodeList * cmdList ) { + if( !di ) { + di = new class DisplayNode( this ); } - return di->ChangeList(cmdList); + return di->ChangeList( cmdList ); } // deletes from previous cmd list & puts on cmd list cmdList -int MgrNode::ChangeList(MgrNodeList *cmdList) -{ +int MgrNode::ChangeList( MgrNodeList * cmdList ) { Remove(); - cmdList->Append(this); + cmdList->Append( this ); return 1; } -int MgrNode::ChangeState(displayStateEnum s) -{ +int MgrNode::ChangeState( displayStateEnum s ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; - if(di) { - return di->ChangeState(s); + if( di ) { + return di->ChangeState( s ); } return 0; } -int MgrNode::ChangeState(stateEnum s) -{ +int MgrNode::ChangeState( stateEnum s ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::ChangeState()\n"; currState = s; @@ -161,62 +148,57 @@ int MgrNode::ChangeState(stateEnum s) return 1; } -void MgrNode::Init(SDAI_Application_instance *s, - stateEnum listState, - MgrNodeList *list) -{ +void MgrNode::Init( SDAI_Application_instance * s, + stateEnum listState, + MgrNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::Init()\n"; se = s; arrayIndex = -1; di = 0; currState = listState; - if(list) { - list->Append(this); + if( list ) { + list->Append( this ); } } // used for sentinel node on lists of MgrNodes -MgrNode::MgrNode() -{ +MgrNode::MgrNode() { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(0, noStateSE, 0); + Init( 0, noStateSE, 0 ); } -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, noStateSE, 0); + Init( StepEntPtr, noStateSE, 0 ); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, listState, 0); + Init( StepEntPtr, listState, 0 ); } // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) -MgrNode::MgrNode(SDAI_Application_instance *StepEntPtr, stateEnum listState, MgrNodeList *list) -{ +MgrNode::MgrNode( SDAI_Application_instance * StepEntPtr, stateEnum listState, MgrNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNode::MgrNode()\n"; // if(debug_level >= PrintValues) // cout << "MgrNode::this : '" << this << "'\n"; - Init(StepEntPtr, listState, list); + Init( StepEntPtr, listState, list ); } diff --git a/src/clstepcore/mgrnode.h b/src/clstepcore/mgrnode.h index 4f14f4bf2..435b6aa70 100644 --- a/src/clstepcore/mgrnode.h +++ b/src/clstepcore/mgrnode.h @@ -25,17 +25,17 @@ class DisplayNode; #include +#include + class InstMgr; -class SC_CORE_EXPORT MgrNodeBase : public GenericNode -{ +class SC_CORE_EXPORT MgrNodeBase : public GenericNode { public: - virtual inline SDAI_Application_instance *GetSTEPentity() - { + virtual inline SDAI_Application_instance * GetSTEPentity() { abort(); - return NULL; + return nullptr; }; - virtual ~MgrNodeBase() {}; + virtual ~MgrNodeBase() {}; }; ////////////////////////////////////////////////////////////////////////////// @@ -44,8 +44,7 @@ class SC_CORE_EXPORT MgrNodeBase : public GenericNode // the DisplayNode, and removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNode : public MgrNodeBase -{ +class SC_CORE_EXPORT MgrNode : public MgrNodeBase { friend class GenNodeList; friend class MgrNodeList; friend class InstMgr; @@ -58,100 +57,93 @@ class SC_CORE_EXPORT MgrNode : public MgrNodeBase stateEnum currState; // SDAI_Application_instance this node is representing info for - SDAI_Application_instance *se; + SDAI_Application_instance * se; // this is the index (in the InstMgr master array) of the ptr to // this node. int arrayIndex; // display info (SEE, etc) for this node - DisplayNode *di; + DisplayNode * di; public: // used for sentinel node on lists of MgrNodes MgrNode(); - MgrNode(SDAI_Application_instance *se); + MgrNode( SDAI_Application_instance * se ); // 'listState' == // completeSE - if reading valid exchange file // incompleteSE or completeSE - if reading working session file // newSE - if instance is created by user using editor (probe) - MgrNode(SDAI_Application_instance *se, stateEnum listState); - MgrNode(SDAI_Application_instance *se, stateEnum listState, MgrNodeList *list); + MgrNode( SDAI_Application_instance * se, stateEnum listState ); + MgrNode( SDAI_Application_instance * se, stateEnum listState, MgrNodeList * list ); virtual ~MgrNode(); // STATE LIST OPERATIONS - int MgrNodeListMember(stateEnum s) - { - return (currState == s); + int MgrNodeListMember( stateEnum s ) { + return ( currState == s ); } - stateEnum CurrState() - { + stateEnum CurrState() { return currState; } // returns next or prev member variables // i.e. next or previous node on curr state list // searches current list for fileId - MgrNode *StateFindFileId(int fileId); + MgrNode * StateFindFileId( int fileId ); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList(MgrNodeList *cmdList); - int ChangeState(stateEnum s); + int ChangeList( MgrNodeList * cmdList ); + int ChangeState( stateEnum s ); // Removes from current list. // Called before adding to diff list or when destructor is called. void Remove(); // DISPLAY LIST OPERATIONS - void *SEE(); + void * SEE(); displayStateEnum DisplayState(); - int IsDisplayState(displayStateEnum ds); + int IsDisplayState( displayStateEnum ds ); // returns next or prev member variables // i.e. next or previous node on display state list - GenericNode *NextDisplay(); - GenericNode *PrevDisplay(); + GenericNode * NextDisplay(); + GenericNode * PrevDisplay(); // deletes from previous cmd list, // & puts on cmd list cmdList - int ChangeList(DisplayNodeList *cmdList); + int ChangeList( DisplayNodeList * cmdList ); // deletes from previous display list, assigns ds to // displayState & puts on list dsList - int ChangeState(displayStateEnum ds); + int ChangeState( displayStateEnum ds ); // might not want these three? since it won't actually map them? - void MapModifiable(DisplayNodeList *dnList); - void MapViewable(DisplayNodeList *dnList); - void UnMap(DisplayNodeList *dnList); + void MapModifiable( DisplayNodeList * dnList ); + void MapViewable( DisplayNodeList * dnList ); + void UnMap( DisplayNodeList * dnList ); // ACCESS FUNCTIONS int GetFileId(); - SDAI_Application_instance *GetApplication_instance() - { + SDAI_Application_instance * GetApplication_instance() { return se; } - DisplayNode *&displayNode() - { + DisplayNode *& displayNode() { return di; } - int ArrayIndex() - { + int ArrayIndex() { return arrayIndex; } - void ArrayIndex(int index) - { + void ArrayIndex( int index ) { arrayIndex = index; } // OBSOLETE - SDAI_Application_instance *GetSTEPentity() - { + SDAI_Application_instance * GetSTEPentity() { return se; } protected: private: - void Init(SDAI_Application_instance *s, stateEnum listState, MgrNodeList *list); + void Init( SDAI_Application_instance * s, stateEnum listState, MgrNodeList * list ); }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 87ef68c1b..23069f02b 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -43,21 +43,18 @@ static int PrintFunctionTrace = 2; // class MgrNodeArray member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArray::MgrNodeArray(int defaultSize) - : GenNodeArray(defaultSize) -{ +MgrNodeArray::MgrNodeArray( int defaultSize ) + : GenNodeArray( defaultSize ) { } -void MgrNodeArray::AssignIndexAddress(int index) -{ +void MgrNodeArray::AssignIndexAddress( int index ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArray::AssignIndexAddress()\n"; - ((MgrNode *)_buf[index])->ArrayIndex(index); + ( ( MgrNode * )_buf[index] )->ArrayIndex( index ); } -MgrNodeArray::~MgrNodeArray() -{ - if(debug_level >= PrintFunctionTrace) { +MgrNodeArray::~MgrNodeArray() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::~MgrNodeArray()\n"; } DeleteEntries(); @@ -65,13 +62,12 @@ MgrNodeArray::~MgrNodeArray() /*****************************************************************************/ -void MgrNodeArray::ClearEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::ClearEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::ClearEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; @@ -79,59 +75,55 @@ void MgrNodeArray::ClearEntries() /*****************************************************************************/ -void MgrNodeArray::DeleteEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::DeleteEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::DeleteEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { - delete((MgrNode *)_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( ( MgrNode * )_buf[i] ); } _count = 0; } /*****************************************************************************/ -int MgrNodeArray::Insert(GenericNode *gn, int index) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArray::Insert( GenericNode * gn, int index ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::Insert()\n"; } - int AssignedIndex = GenNodeArray::Insert(gn, index); + int AssignedIndex = GenNodeArray::Insert( gn, index ); int i; - for(i = AssignedIndex ; i < _count; i++) { - ((MgrNode *)_buf[i])->ArrayIndex(i); + for( i = AssignedIndex ; i < _count; i++ ) { + ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); } return AssignedIndex; } /*****************************************************************************/ -void MgrNodeArray::Remove(int index) -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArray::Remove( int index ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::Remove()\n"; } - if(0 <= index && index < _count) { - GenNodeArray::Remove(index); + if( 0 <= index && index < _count ) { + GenNodeArray::Remove( index ); int i; - for(i = index; i < _count; i++) { - ((MgrNode *)_buf[i])->ArrayIndex(i); + for( i = index; i < _count; i++ ) { + ( ( MgrNode * )_buf[i] )->ArrayIndex( i ); } } } /*****************************************************************************/ -int MgrNodeArray::MgrNodeIndex(int fileId) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArray::MgrNodeIndex( int fileId ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArray::MgrNodeIndex()\n"; } int i; - for(i = 0; i < _count; ++i) { - if(((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId() == fileId) { + for( i = 0; i < _count; ++i ) { + if( ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId() == fileId ) { return i; } } @@ -142,47 +134,42 @@ int MgrNodeArray::MgrNodeIndex(int fileId) // class MgrNodeArraySorted member functions ////////////////////////////////////////////////////////////////////////////// -MgrNodeArraySorted::MgrNodeArraySorted(int defaultSize) - : GenNodeArray(defaultSize) -{ +MgrNodeArraySorted::MgrNodeArraySorted( int defaultSize ) + : GenNodeArray( defaultSize ) { } -int MgrNodeArraySorted::Insert(GenericNode *gn) -{ +int MgrNodeArraySorted::Insert( GenericNode * gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Insert()\n"; // since gn is really a MgrNode - int fileId = ((MgrNode *)gn)->GetApplication_instance()->GetFileId(); + int fileId = ( ( MgrNode * )gn )->GetApplication_instance()->GetFileId(); - int index = FindInsertPosition(fileId); + int index = FindInsertPosition( fileId ); - return GenNodeArray::Insert(gn, index); + return GenNodeArray::Insert( gn, index ); } -int MgrNodeArraySorted::Index(GenericNode *gn) -{ +int MgrNodeArraySorted::Index( GenericNode * gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex(((MgrNode *)gn)->GetFileId()); + return MgrNodeIndex( ( ( MgrNode * )gn )->GetFileId() ); } -int MgrNodeArraySorted::Index(GenericNode **gn) -{ +int MgrNodeArraySorted::Index( GenericNode ** gn ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeArraySorted::Index()\n"; // since gn is really a MgrNode - return MgrNodeIndex(((MgrNode *)(*gn))->GetFileId()); + return MgrNodeIndex( ( ( MgrNode * )( *gn ) )->GetFileId() ); } -void MgrNodeArraySorted::ClearEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArraySorted::ClearEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::ClearEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; @@ -190,14 +177,13 @@ void MgrNodeArraySorted::ClearEntries() /*****************************************************************************/ -void MgrNodeArraySorted::DeleteEntries() -{ - if(debug_level >= PrintFunctionTrace) { +void MgrNodeArraySorted::DeleteEntries() { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::DeleteEntries()\n"; } int i; - for(i = 0 ; i < _count; i++) { - delete((MgrNode *)_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( ( MgrNode * )_buf[i] ); } _count = 0; } @@ -207,17 +193,16 @@ void MgrNodeArraySorted::DeleteEntries() // the reason this is written this way is because most of the // time the file id will be higher than any seen so far and // thus the insert position will be at the end -int MgrNodeArraySorted::FindInsertPosition(const int fileId) -{ - if(debug_level >= PrintFunctionTrace) { +int MgrNodeArraySorted::FindInsertPosition( const int fileId ) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::FindInsertPosition()\n"; } int i; int curFileId; - for(i = _count - 1; i >= 0; --i) { - curFileId = ((MgrNode *)_buf[i])->GetApplication_instance()->GetFileId(); - if(curFileId < fileId /*|| curFileId == fileId*/) { + for( i = _count - 1; i >= 0; --i ) { + curFileId = ( ( MgrNode * )_buf[i] )->GetApplication_instance()->GetFileId(); + if( curFileId < fileId /*|| curFileId == fileId*/ ) { return i + 1; } } @@ -226,12 +211,11 @@ int MgrNodeArraySorted::FindInsertPosition(const int fileId) /*****************************************************************************/ -int MgrNodeArraySorted::MgrNodeIndex(int fileId) -{ +int MgrNodeArraySorted::MgrNodeIndex( int fileId ) { // this function assumes that _buf[0] to _buf[_count] ALL point to MgrNodes // that are sorted by fileId - if(debug_level >= PrintFunctionTrace) { + if( debug_level >= PrintFunctionTrace ) { cout << "MgrNodeArraySorted::MgrNodeIndex()\n"; } int low = 0; @@ -240,18 +224,18 @@ int MgrNodeArraySorted::MgrNodeIndex(int fileId) int found = 0; int curFileId; - while(!found && (low <= high)) { - mid = (low + high) / 2; - curFileId = ((MgrNode *)_buf[mid])->GetApplication_instance()->GetFileId(); - if(curFileId == fileId) { + while( !found && ( low <= high ) ) { + mid = ( low + high ) / 2; + curFileId = ( ( MgrNode * )_buf[mid] )->GetApplication_instance()->GetFileId(); + if( curFileId == fileId ) { found = 1; - } else if(curFileId < fileId) { + } else if( curFileId < fileId ) { low = mid + 1; } else { high = mid - 1; } } - if(found) { + if( found ) { return mid; } return -1; diff --git a/src/clstepcore/mgrnodearray.h b/src/clstepcore/mgrnodearray.h index 43e422f99..22019d071 100644 --- a/src/clstepcore/mgrnodearray.h +++ b/src/clstepcore/mgrnodearray.h @@ -38,31 +38,28 @@ // If you delete this object it deletes all of the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray -{ +class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray { public: - MgrNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); + MgrNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); ~MgrNodeArray(); // REDEFINED functions // need to redefine Append() & Insert(GenericNode *) so they call // MgrNodeArray::Insert(GenericNode *, int index); - virtual int Insert(GenericNode *gn, int index); - virtual void Append(GenericNode *gn) - { - Insert(gn, _count); + virtual int Insert( GenericNode * gn, int index ); + virtual void Append( GenericNode * gn ) { + Insert( gn, _count ); } - virtual int Insert(GenericNode *gn) - { - return Insert(gn, _count); + virtual int Insert( GenericNode * gn ) { + return Insert( gn, _count ); } - virtual void Remove(int index); + virtual void Remove( int index ); virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex(int fileId); - void AssignIndexAddress(int index); + virtual int MgrNodeIndex( int fileId ); + void AssignIndexAddress( int index ); }; ////////////////////////////////////////////////////////////////////////////// @@ -73,34 +70,31 @@ class SC_CORE_EXPORT MgrNodeArray : public GenNodeArray // If you delete this object it won't delete the entries it points to. ////////////////////////////////////////////////////////////////////////////// -class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray -{ +class SC_CORE_EXPORT MgrNodeArraySorted : public GenNodeArray { public: - MgrNodeArraySorted(int defaultSize = ARRAY_DEFAULT_SIZE); + MgrNodeArraySorted( int defaultSize = ARRAY_DEFAULT_SIZE ); ~MgrNodeArraySorted() { } // REDEFINED functions - virtual int Index(GenericNode *gn); - virtual int Index(GenericNode **gn); + virtual int Index( GenericNode * gn ); + virtual int Index( GenericNode ** gn ); - virtual int Insert(GenericNode *gn); - virtual int Insert(GenericNode *gn, int index) - { + virtual int Insert( GenericNode * gn ); + virtual int Insert( GenericNode * gn, int index ) { cerr << "Call MgrNodeArraySorted::Insert() without index argument instead.\n" << "index argument: " << index << " being ignored.\n"; - return Insert(gn); + return Insert( gn ); } - virtual void Append(GenericNode *gn) - { - Insert(gn); + virtual void Append( GenericNode * gn ) { + Insert( gn ); } virtual void ClearEntries(); virtual void DeleteEntries(); // ADDED functions - virtual int MgrNodeIndex(int fileId); - int FindInsertPosition(const int fileId); + virtual int MgrNodeIndex( int fileId ); + int FindInsertPosition( const int fileId ); }; diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index 641deada5..9bff8e254 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -18,62 +18,56 @@ #include #include "sc_memmgr.h" -MgrNodeList::MgrNodeList(stateEnum type) : GenNodeList(new MgrNode()) -{ +MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::MgrNodeList()\n"; listType = type; - ((MgrNode *)head)->currState = type; + ( ( MgrNode * )head )->currState = type; } -void MgrNodeList::Remove(GenericNode *node) -{ +void MgrNodeList::Remove( GenericNode * node ) { // if(debug_level >= PrintFunctionTrace) // cout << "MgrNodeList::Remove()\n"; - GenNodeList::Remove(node); + GenNodeList::Remove( node ); // DON'T DO THIS ((MgrNode *)node)->currState = noStateSE; } // deletes node from its previous list & appends... // actually it puts it at the front of the list. -void MgrNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void MgrNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } // deletes newNode from its previous list & inserts after // existNode -void MgrNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous list +void MgrNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous list newNode->Remove(); } - GenNodeList::InsertAfter(newNode, existNode); + GenNodeList::InsertAfter( newNode, existNode ); // DON'T DO THIS ((MgrNode *)newNode)->currState = listType; } // deletes newNode from its previous list & inserts before // existNode -void MgrNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ - if(newNode->next != 0) { // remove the node from its previous +void MgrNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { + if( newNode->next != 0 ) { // remove the node from its previous newNode->Remove(); // state list } - GenNodeList::InsertBefore(newNode, existNode); + GenNodeList::InsertBefore( newNode, existNode ); // DON'T DO THIS!! ((MgrNode *)newNode)->currState = listType; } -MgrNode *MgrNodeList::FindFileId(int fileId) -{ - MgrNode *mn = (MgrNode *)head->next; - while(mn != head) { - if(mn->GetFileId() == fileId) { +MgrNode * MgrNodeList::FindFileId( int fileId ) { + MgrNode * mn = ( MgrNode * )head->next; + while( mn != head ) { + if( mn->GetFileId() == fileId ) { return mn; } - mn = (MgrNode *)mn->next; + mn = ( MgrNode * )mn->next; } - return (MgrNode *)0; + return ( MgrNode * )0; } diff --git a/src/clstepcore/mgrnodelist.h b/src/clstepcore/mgrnodelist.h index c477d9601..be822c798 100644 --- a/src/clstepcore/mgrnodelist.h +++ b/src/clstepcore/mgrnodelist.h @@ -29,23 +29,22 @@ class MgrNode; -class SC_CORE_EXPORT MgrNodeList : public GenNodeList -{ +class SC_CORE_EXPORT MgrNodeList : public GenNodeList { public: - MgrNodeList(stateEnum type); + MgrNodeList( stateEnum type ); virtual ~MgrNodeList() { } // ADDED functions - virtual MgrNode *FindFileId(int fileId); + virtual MgrNode * FindFileId( int fileId ); // REDEFINED functions // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); - virtual void Remove(GenericNode *node); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); + virtual void Remove( GenericNode * node ); protected: stateEnum listType; diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index 79455607e..959720ed0 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -19,11 +19,10 @@ /** * Deletes the childList of this, before this is deleted. */ -MultList::~MultList() -{ - EntList *child = childList, *cnext; +MultList::~MultList() { + EntList * child = childList, *cnext; - while(child) { + while( child ) { cnext = child->next; delete child; child = cnext; @@ -34,25 +33,23 @@ MultList::~MultList() * Sets this's level, and tells all its children to set their level to our * level +1. */ -void MultList::setLevel(int l) -{ - EntList *child = childList; +void MultList::setLevel( int l ) { + EntList * child = childList; level = l; - for(; child != NULL; child = child->next) { - child->setLevel(l + 1); + for( ; child != NULL; child = child->next ) { + child->setLevel( l + 1 ); } } /** * Check if one of this's descendants matches nm. */ -bool MultList::contains(char *nm) -{ - EntList *child = childList; +bool MultList::contains( char * nm ) { + EntList * child = childList; - while(child) { - if(child->contains(nm)) { + while( child ) { + if( child->contains( nm ) ) { return true; } child = child->next; @@ -63,11 +60,10 @@ bool MultList::contains(char *nm) /** * Check if one of our descendants matches nm. */ -bool MultList::hit(char *nm) -{ - EntList *child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { +bool MultList::hit( char * nm ) { + EntList * child = childList; + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -83,16 +79,15 @@ bool MultList::hit(char *nm) /** * Returns a pointer to the num'th child of MultList. */ -EntList *MultList::getChild(int num) -{ - EntList *child = childList; +EntList * MultList::getChild( int num ) { + EntList * child = childList; int j; - if(num < 0 || num >= numchildren) { + if( num < 0 || num >= numchildren ) { // Check for error situations (shouldn't normally occur): return NULL; } - for(j = 0; j < num; j++, child = child->next) { + for( j = 0; j < num; j++, child = child->next ) { ; } return child; @@ -102,11 +97,10 @@ EntList *MultList::getChild(int num) * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ -void MultList::appendList(EntList *ent) -{ - EntList *eprev; +void MultList::appendList( EntList * ent ) { + EntList * eprev; - if(numchildren == 0) { + if( numchildren == 0 ) { childList = ent; } else { eprev = getLast(); @@ -120,13 +114,12 @@ void MultList::appendList(EntList *ent) * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ -EntList *MultList::copyList(EntList *ent) -{ - EntList *newlist = 0, *child; +EntList * MultList::copyList( EntList * ent ) { + EntList * newlist = 0, *child; - switch(ent->join) { + switch( ent->join ) { case SIMPLE: - newlist = new SimpleList((dynamic_cast(ent))->Name()); + newlist = new SimpleList( ( dynamic_cast(ent) )->Name() ); break; case AND: newlist = new AndList; @@ -138,12 +131,12 @@ EntList *MultList::copyList(EntList *ent) newlist = new AndOrList; break; }; - appendList(newlist); - if(ent->multiple()) { + appendList( newlist ); + if( ent->multiple() ) { // For the multlists, we must recurse for all their children: - child = (dynamic_cast< MultList * >(ent))->childList; - while(child) { - (dynamic_cast< MultList * >(newlist))->copyList(child); + child = ( dynamic_cast< MultList * >(ent) )->childList; + while( child ) { + ( dynamic_cast< MultList * >(newlist) )->copyList( child ); child = child->next; } } @@ -155,12 +148,11 @@ EntList *MultList::copyList(EntList *ent) * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ -void MultList::unmarkAll(EntNode *ents) -{ - EntList *child = childList; +void MultList::unmarkAll( EntNode * ents ) { + EntList * child = childList; - while(child != NULL) { - child->unmarkAll(ents); + while( child != NULL ) { + child->unmarkAll( ents ); child = child->next; } } @@ -169,12 +161,11 @@ void MultList::unmarkAll(EntNode *ents) * Resets this to default values. Iterates through child list, calling * each child's reset function. */ -void MultList::reset() -{ - EntList *child; +void MultList::reset() { + EntList * child; viable = UNKNOWN; - for(child = childList; child; child = child->next) { + for( child = childList; child; child = child->next ) { child->reset(); } } @@ -189,24 +180,23 @@ void MultList::reset() * children which are UNSATISFIED and return UNSAT if found, we don't * worry about coming across them down here. */ -void JoinList::setViableVal(EntNode *ents) -{ - EntList *child = childList; +void JoinList::setViableVal( EntNode * ents ) { + EntList * child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while(child != NULL) { - if(child->viable == UNKNOWN) { + while( child != NULL ) { + if( child->viable == UNKNOWN ) { viable = UNKNOWN; return; } - if(child->viable > viable) { + if( child->viable > viable ) { viable = child->viable; } child = child->next; } - if(viable == MATCHALL && !ents->allMarked()) { + if( viable == MATCHALL && !ents->allMarked() ) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -220,13 +210,12 @@ void JoinList::setViableVal(EntNode *ents) * value will = mark (either MARK or ORMARK). Return true if we mark any- * thing; false otherwise. */ -bool JoinList::acceptChoice(EntNode *ents) -{ - EntList *child; +bool JoinList::acceptChoice( EntNode * ents ) { + EntList * child; int result = false; - for(child = childList; child != NULL; child = child->next) { - if(child->viable >= MATCHSOME) { + for( child = childList; child != NULL; child = child->next ) { + if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -237,7 +226,7 @@ bool JoinList::acceptChoice(EntNode *ents) // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice(ents) || result; + result = child->acceptChoice( ents ) || result; // (NOTE - must run acceptChoice() first in above line. If result // were true and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -251,12 +240,11 @@ bool JoinList::acceptChoice(EntNode *ents) * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ -bool MultList::prevKnown(EntList *desc) -{ - EntList *child = childList; +bool MultList::prevKnown( EntList * desc ) { + EntList * child = childList; - while(child != NULL && child != desc) { - if(child->viable == UNKNOWN) { + while( child != NULL && child != desc ) { + if( child->viable == UNKNOWN ) { return false; } child = child->next; diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index 046a0e6ba..eea46ddb5 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -15,7 +15,6 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE(StepEntityEditor *se) -{ +void DeleteSEE( StepEntityEditor * se ) { delete se; } diff --git a/src/clstepcore/needFunc.h b/src/clstepcore/needFunc.h index 91170be39..74148bcc6 100644 --- a/src/clstepcore/needFunc.h +++ b/src/clstepcore/needFunc.h @@ -3,11 +3,10 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class SC_CORE_EXPORT StepEntityEditor -{ +class SC_CORE_EXPORT StepEntityEditor { public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index 5d83d8776..14607f606 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -19,14 +19,13 @@ * other return values. (See descript of MatchType values in complex- * Support.h.) */ -MatchType SimpleList::matchNonORs(EntNode *ents) -{ - EntNode *eptr = ents; +MatchType SimpleList::matchNonORs( EntNode * ents ) { + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked(MARK)) { + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked( MARK ) ) { // NOTE - this cond also returns true if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -35,13 +34,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if(eptr->mark == NOMARK) { + if( eptr->mark == NOMARK ) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if(ents->allMarked()) { + if( ents->allMarked() ) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -55,7 +54,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. break; } @@ -75,14 +74,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) * processing them we'll be able to tell which OR choices are viable, and * which are unnec. */ -MatchType AndOrList::matchNonORs(EntNode *ents) -{ - EntList *child = childList->firstNot(OR); +MatchType AndOrList::matchNonORs( EntNode * ents ) { + EntList * child = childList->firstNot( OR ); MatchType retval; - while(child != NULL) { - if((retval = child->matchNonORs(ents)) == MATCHALL) { - if(prevKnown(child)) { + while( child != NULL ) { + if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { + if( prevKnown( child ) ) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -109,15 +107,15 @@ MatchType AndOrList::matchNonORs(EntNode *ents) // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if(retval == UNSATISFIED) { + } else if( retval == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextNot(OR); + child = child->nextNot( OR ); } - setViableVal(ents); + setViableVal( ents ); return viable; } @@ -125,23 +123,22 @@ MatchType AndOrList::matchNonORs(EntNode *ents) * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ -MatchType AndList::matchNonORs(EntNode *ents) -{ - EntList *child = childList->firstNot(OR); +MatchType AndList::matchNonORs( EntNode * ents ) { + EntList * child = childList->firstNot( OR ); - while(child != NULL) { - if(child->matchNonORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( child->matchNonORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot(OR); + child = child->nextNot( OR ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index ddcc260c2..b820bea53 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -25,17 +25,16 @@ * context of a sub w/ >1 super, in which case we build a combo-CList and * may need to check if all sub-CLists matched the multi-sub, C.) */ -bool OrList::hit(char *nm) -{ - EntList *child = getChild(choice); +bool OrList::hit( char * nm ) { + EntList * child = getChild( choice ); - if(child) { + if( child ) { // I.e., if we have a choice selected, check it only. - return (child->hit(nm)); + return ( child->hit( nm ) ); } else { child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // See MultList::hit() on why we must skip UNSATs. return true; } @@ -48,13 +47,12 @@ bool OrList::hit(char *nm) /** * Unmarks all the nodes of ents marked by the descendants of this. */ -void OrList::unmarkAll(EntNode *ents) -{ - EntList *child; +void OrList::unmarkAll( EntNode * ents ) { + EntList * child; - if((child = getChild(choice)) != NULL) { + if( ( child = getChild( choice ) ) != NULL ) { // choice = the last selected path which we'll now undo. - child->unmarkAll(ents); + child->unmarkAll( ents ); } } @@ -64,16 +62,15 @@ void OrList::unmarkAll(EntNode *ents) * LISTEND. If choice was set to LISTEND before calling aC(), we reset * choice to choice1, and search again. */ -bool OrList::acceptChoice(EntNode *ents) -{ - EntList *child; +bool OrList::acceptChoice( EntNode * ents ) { + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { choice = choice1; } - child = getChild(choice); - while(child) { - if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { + child = getChild( choice ); + while( child ) { + if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { // acceptChoice() returns true if we marked something. return true; } diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index c4ecf9778..2139d1f61 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -11,14 +11,13 @@ #include "sc_memmgr.h" // Local function prototypes: -static char *joinText(JoinType, char *); +static char * joinText( JoinType, char * ); /** * Prints out a ComplexList, by iterating through its children. */ -ostream &operator << (ostream &os, ComplexList &clist) -{ - os << "ComplexList - \"" << *(SimpleList *)clist.head->childList +ostream & operator << ( ostream & os, ComplexList & clist ) { + os << "ComplexList - \"" << *( SimpleList * )clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -29,12 +28,11 @@ ostream &operator << (ostream &os, ComplexList &clist) /** * Prints out an EntList. Calls appropriate function based on JoinType. */ -ostream &operator << (ostream &os, EntList &list) -{ - if(list.join == SIMPLE) { - os << *(SimpleList *)&list; +ostream & operator << ( ostream & os, EntList & list ) { + if( list.join == SIMPLE ) { + os << *( SimpleList * )&list; } else { - os << *(MultList *)&list; + os << *( MultList * )&list; } return os; } @@ -42,8 +40,7 @@ ostream &operator << (ostream &os, EntList &list) /** * Prints out a SimpleList. */ -ostream &operator << (ostream &os, SimpleList &slist) -{ +ostream & operator << ( ostream & os, SimpleList & slist ) { os << slist.name; return os; } @@ -51,27 +48,26 @@ ostream &operator << (ostream &os, SimpleList &slist) /** * Prints out a MultList. */ -ostream &operator << (ostream &os, MultList &mlist) -{ +ostream & operator << ( ostream & os, MultList & mlist ) { char jointype[7]; int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList *child = mlist.childList; + EntList * child = mlist.childList; - os << joinText(mlist.join, jointype) << endl; - for(k = 0; k <= mlist.level; k++) { + os << joinText( mlist.join, jointype ) << endl; + for( k = 0; k <= mlist.level; k++ ) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while(child != NULL) { + while( child != NULL ) { os << *child; - if(child->next == NULL) { - lastSimple = (child->join == SIMPLE); + if( child->next == NULL ) { + lastSimple = ( child->join == SIMPLE ); break; // We don't want to do the conditions below if we're done. } - if(child->join == SIMPLE) { + if( child->join == SIMPLE ) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -79,13 +75,13 @@ ostream &operator << (ostream &os, MultList &mlist) // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for(k = 0; k <= mlist.level; k++) { + for( k = 0; k <= mlist.level; k++ ) { os << " "; } } child = child->next; } - if(lastSimple) { + if( lastSimple ) { os << endl; } return os; @@ -94,20 +90,19 @@ ostream &operator << (ostream &os, MultList &mlist) /** * Copies and returns the string equivalent of a JoinType. */ -static char *joinText(JoinType j, char *buf) -{ - switch(j) { +static char * joinText( JoinType j, char * buf ) { + switch( j ) { case SIMPLE: - strcpy(buf, "SIMPLE"); + strcpy( buf, "SIMPLE" ); return buf; case AND: - strcpy(buf, "AND"); + strcpy( buf, "AND" ); return buf; case OR: - strcpy(buf, "OR"); + strcpy( buf, "OR" ); return buf; case ANDOR: - strcpy(buf, "ANDOR"); + strcpy( buf, "ANDOR" ); return buf; }; return NULL; diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index cfc83f548..395e52cfd 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -11,10 +11,9 @@ const int RealNumPrecision = REAL_NUM_PRECISION; // print Error information for debugging purposes void -PrintErrorState(ErrorDescriptor &err) -{ +PrintErrorState( ErrorDescriptor & err ) { cout << "** severity: "; - switch(err.severity()) { + switch( err.severity() ) { case SEVERITY_NULL : cout << "\n Null\n"; break; @@ -38,15 +37,14 @@ PrintErrorState(ErrorDescriptor &err) } // print istream error information for debugging purposes -void IStreamState(istream &in) -{ - if(in.good()) { +void IStreamState( istream & in ) { + if( in.good() ) { cerr << "istream GOOD\n" << flush; } - if(in.fail()) { + if( in.fail() ) { cerr << "istream FAIL\n" << flush; } - if(in.eof()) { + if( in.eof() ) { cerr << "istream EOF\n" << flush; } } @@ -71,29 +69,27 @@ void IStreamState(istream &in) // by any characters other than white space (i.e. EOF must happen) // /////////////////////////////////////////////////////////////////////////////// -int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Integer i = 0; in >> ws; in >> i; int valAssigned = 0; - if(!in.fail()) { + if( !in.fail() ) { valAssigned = 1; val = i; } - CheckRemainingInput(in, err, "Integer", tokenList); + CheckRemainingInput( in, err, "Integer", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadInteger(val, in, err, tokenList); +int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadInteger( val, in, err, tokenList ); } /////////////////////////////////////////////////////////////////////////////// @@ -115,39 +111,37 @@ int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "integer", tokenList); + CheckRemainingInput( in, err, "integer", tokenList ); return err->severity(); } else { SDAI_Integer val = 0; - int valAssigned = ReadInteger(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadInteger( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } -std::string WriteReal(SDAI_Real val) -{ +std::string WriteReal( SDAI_Real val ) { char rbuf[64]; std::string s; @@ -160,22 +154,22 @@ std::string WriteReal(SDAI_Real val) // Also use G instead of g since G writes uppercase E (E instead of e // is also required by Part 21) when scientific notation is used - DAS - sprintf(rbuf, "%.*G", (int) RealNumPrecision, val); - if(!strchr(rbuf, '.')) { - if(strchr(rbuf, 'E') || strchr(rbuf, 'e')) { - char *expon = strchr(rbuf, 'E'); + sprintf( rbuf, "%.*G", ( int ) RealNumPrecision, val ); + if( !strchr( rbuf, '.' ) ) { + if( strchr( rbuf, 'E' ) || strchr( rbuf, 'e' ) ) { + char * expon = strchr( rbuf, 'E' ); - if(!expon) { - expon = strchr(rbuf, 'e'); + if( !expon ) { + expon = strchr( rbuf, 'e' ); } *expon = '\0'; s = rbuf; - s.append("."); - s.append("E"); + s.append( "." ); + s.append( "E" ); expon++; s += expon; } else { - int rindex = strlen(rbuf); + int rindex = strlen( rbuf ); rbuf[rindex] = '.'; rbuf[rindex + 1] = '\0'; s = rbuf; @@ -186,9 +180,8 @@ std::string WriteReal(SDAI_Real val) return s; } -void WriteReal(SDAI_Real val, ostream &out) -{ - out << WriteReal(val); +void WriteReal( SDAI_Real val, ostream & out ) { + out << WriteReal( val ); } /////////////////////////////////////////////////////////////////////////////// @@ -216,9 +209,8 @@ void WriteReal(SDAI_Real val, ostream &out) // an error), optional sign, at least one decimal digit if there is an E. // /////////////////////////////////////////////////////////////////////////////// -int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Real d = 0; // Read the real's value into a string so we can make sure it is properly @@ -233,71 +225,71 @@ int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, // read optional sign c = in.peek(); - if(c == '+' || c == '-') { - in.get(buf[i++]); + if( c == '+' || c == '-' ) { + in.get( buf[i++] ); c = in.peek(); } // check for required initial decimal digit - if(!isdigit(c)) { - e.severity(SEVERITY_WARNING); - e.DetailMsg("Real must have an initial digit.\n"); + if( !isdigit( c ) ) { + e.severity( SEVERITY_WARNING ); + e.DetailMsg( "Real must have an initial digit.\n" ); } // read one or more decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } // read Part 21 required decimal point - if(c == '.') { - in.get(buf[i++]); + if( c == '.' ) { + in.get( buf[i++] ); c = in.peek(); } else { // It may be the number they wanted but it is incompletely specified // without a decimal and thus it is an error - e.GreaterSeverity(SEVERITY_WARNING); - e.AppendToDetailMsg("Reals are required to have a decimal point.\n"); + e.GreaterSeverity( SEVERITY_WARNING ); + e.AppendToDetailMsg( "Reals are required to have a decimal point.\n" ); } // read optional decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } // try to read an optional E for scientific notation - if((c == 'e') || (c == 'E')) { - if(c == 'e') { + if( ( c == 'e' ) || ( c == 'E' ) ) { + if( c == 'e' ) { // this is incorrectly specified and thus is an error - e.GreaterSeverity(SEVERITY_WARNING); + e.GreaterSeverity( SEVERITY_WARNING ); e.AppendToDetailMsg( - "Reals using scientific notation must use upper case E.\n"); + "Reals using scientific notation must use upper case E.\n" ); } - in.get(buf[i++]); // read the E + in.get( buf[i++] ); // read the E c = in.peek(); // read optional sign - if(c == '+' || c == '-') { - in.get(buf[i++]); + if( c == '+' || c == '-' ) { + in.get( buf[i++] ); c = in.peek(); } // read required decimal digit (since it has an E) - if(!isdigit(c)) { - e.GreaterSeverity(SEVERITY_WARNING); + if( !isdigit( c ) ) { + e.GreaterSeverity( SEVERITY_WARNING ); e.AppendToDetailMsg( - "Real must have at least one digit following E for scientific notation.\n"); + "Real must have at least one digit following E for scientific notation.\n" ); } // read one or more decimal digits - while(isdigit(c)) { - in.get(buf[i++]); + while( isdigit( c ) ) { + in.get( buf[i++] ); c = in.peek(); } } buf[i] = '\0'; - istringstream in2((char *)buf); + istringstream in2( ( char * )buf ); // now that we have the real the stream will be able to salvage reading // whatever kind of format was used to represent the real. @@ -305,25 +297,24 @@ int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, int valAssigned = 0; - if(!in2.fail()) { + if( !in2.fail() ) { valAssigned = 1; val = d; - err->GreaterSeverity(e.severity()); - err->AppendToDetailMsg(e.DetailMsg()); + err->GreaterSeverity( e.severity() ); + err->AppendToDetailMsg( e.DetailMsg() ); } else { val = S_REAL_NULL; } - CheckRemainingInput(in, err, "Real", tokenList); + CheckRemainingInput( in, err, "Real", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadReal(val, in, err, tokenList); +int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadReal( val, in, err, tokenList ); } /////////////////////////////////////////////////////////////////////////////// @@ -345,32 +336,31 @@ int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "real", tokenList); + CheckRemainingInput( in, err, "real", tokenList ); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadReal(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadReal( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); @@ -395,28 +385,26 @@ Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, * to be invalid. If tokenList is null then the value must not be followed * by any characters other than white space (i.e. EOF must happen) */ -int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList) -{ +int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ) { SDAI_Real d = 0; in >> ws; in >> d; int valAssigned = 0; - if(!in.fail()) { + if( !in.fail() ) { valAssigned = 1; val = d; } - CheckRemainingInput(in, err, "Number", tokenList); + CheckRemainingInput( in, err, "Number", tokenList ); return valAssigned; } /// same as above but reads from a const char * -int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList) -{ - istringstream in((char *)s); - return ReadNumber(val, in, err, tokenList); +int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ) { + istringstream in( ( char * )s ); + return ReadNumber( val, in, err, tokenList ); } @@ -439,76 +427,73 @@ int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, // null then attrValue must only contain a valid value and nothing else // following. /////////////////////////////////////////////////////////////////////////////// -Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList) -{ - if(clearError) { +Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ) { + if( clearError ) { err->ClearErrorMsg(); } - istringstream in((char *)attrValue); + istringstream in( ( char * )attrValue ); in >> ws; // skip white space char c = in.peek(); - if(in.eof()) { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + if( in.eof() ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } - } else if(c == '$') { - if(!optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + } else if( c == '$' ) { + if( !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } in >> c; - CheckRemainingInput(in, err, "number", tokenList); + CheckRemainingInput( in, err, "number", tokenList ); return err->severity(); } else { SDAI_Real val = 0; - int valAssigned = ReadNumber(val, in, err, tokenList); - if(!valAssigned && !optional) { - err->GreaterSeverity(SEVERITY_INCOMPLETE); + int valAssigned = ReadNumber( val, in, err, tokenList ); + if( !valAssigned && !optional ) { + err->GreaterSeverity( SEVERITY_INCOMPLETE ); } } return err->severity(); } /// assign 's' so that it contains an exchange file format string read from 'in'. -void PushPastString(istream &in, std::string &s, ErrorDescriptor *err) -{ - s += GetLiteralStr(in, err); +void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ) { + s += GetLiteralStr( in, err ); } /** * assign 's' so that it contains an exchange file format aggregate read from 'in'. * This is used to read aggregates that are part of multidimensional aggregates. */ -void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err) -{ +void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get(c); + in.get( c ); - if(c == '(') { + if( c == '(' ) { s += c; - in.get(c); - while(in.good() && (c != ')')) { - if(c == '(') { - in.putback(c); - PushPastImbedAggr(in, s, err); - } else if(c == STRING_DELIM) { - in.putback(c); - PushPastString(in, s, err); + in.get( c ); + while( in.good() && ( c != ')' ) ) { + if( c == '(' ) { + in.putback( c ); + PushPastImbedAggr( in, s, err ); + } else if( c == STRING_DELIM ) { + in.putback( c ); + PushPastString( in, s, err ); } else { s += c; } - in.get(c); + in.get( c ); } - if(c != ')') { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); - s.append(")"); + if( c != ')' ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); + s.append( ")" ); } else { s += c; } @@ -520,38 +505,37 @@ void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err) * This is used to read a single dimensional aggregate (i.e. it is not allowed * to contain an aggregate as an element. */ -void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err) -{ +void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ) { char messageBuf[BUFSIZ]; messageBuf[0] = '\0'; char c; in >> ws; - in.get(c); + in.get( c ); - if(c == '(') { + if( c == '(' ) { s += c; - in.get(c); - while(in.good() && (c != ')')) { - if(c == '(') { - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); + in.get( c ); + while( in.good() && ( c != ')' ) ) { + if( c == '(' ) { + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); } - if(c == STRING_DELIM) { - in.putback(c); - PushPastString(in, s, err); + if( c == STRING_DELIM ) { + in.putback( c ); + PushPastString( in, s, err ); } else { s += c; } - in.get(c); + in.get( c ); } - if(c != ')') { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - sprintf(messageBuf, "Invalid aggregate value.\n"); - err->AppendToDetailMsg(messageBuf); - s.append(")"); + if( c != ')' ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + sprintf( messageBuf, "Invalid aggregate value.\n" ); + err->AppendToDetailMsg( messageBuf ); + s.append( ")" ); } else { s += c; } @@ -563,23 +547,22 @@ void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err) * it copies what is read to the std::string inst. It leaves the # on the * istream. */ -Severity FindStartOfInstance(istream &in, std::string &inst) -{ +Severity FindStartOfInstance( istream & in, std::string & inst ) { char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while(in.good()) { + while( in.good() ) { in >> c; - switch(c) { + switch( c ) { case '#': // found char looking for. - in.putback(c); + in.putback( c ); return SEVERITY_NULL; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); - inst.append(tmp.c_str()); + in.putback( c ); + tmp.STEPread( in, &errs ); + inst.append( tmp.c_str() ); break; case '\0': // problem in input ? @@ -596,22 +579,21 @@ Severity FindStartOfInstance(istream &in, std::string &inst) * SkipInstance reads in an instance terminated with ;. it copies * what is read to the std::string inst. */ -Severity SkipInstance(istream &in, std::string &inst) -{ +Severity SkipInstance( istream & in, std::string & inst ) { char c = 0; ErrorDescriptor errs; SDAI_String tmp; - while(in.good()) { + while( in.good() ) { in >> c; - switch(c) { + switch( c ) { case ';': // end of instance reached return SEVERITY_NULL; case '\'': // get past the string - in.putback(c); - tmp.STEPread(in, &errs); - inst.append(tmp.c_str()); + in.putback( c ); + tmp.STEPread( in, &errs ); + inst.append( tmp.c_str() ); break; case '\0': // problem in input ? @@ -632,39 +614,38 @@ Severity SkipInstance(istream &in, std::string &inst) // external mapping don't have them. If you are reading a simple record in the // form of an internal mapping you will have to read the semicolon. */ -const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err) -{ +const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ) { char c; std::string s; in >> ws; - in.get(c); - if(c == '(') { // beginning of record + in.get( c ); + if( c == '(' ) { // beginning of record buf += c; - while(in.get(c) && (c != ')') && (err->severity() > SEVERITY_INPUT_ERROR)) { - if(c == '\'') { - in.putback(c); + while( in.get( c ) && ( c != ')' ) && ( err->severity() > SEVERITY_INPUT_ERROR ) ) { + if( c == '\'' ) { + in.putback( c ); s.clear(); - PushPastString(in, s, err); - buf.append(s.c_str()); - } else if(c == '(') { - in.putback(c); + PushPastString( in, s, err ); + buf.append( s.c_str() ); + } else if( c == '(' ) { + in.putback( c ); s.clear(); - PushPastImbedAggr(in, s, err); - buf.append(s.c_str()); + PushPastImbedAggr( in, s, err ); + buf.append( s.c_str() ); } else { buf += c; } } - if(!in.good()) { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); - err->DetailMsg("File problems reading simple record.\n"); + if( !in.good() ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); + err->DetailMsg( "File problems reading simple record.\n" ); } - buf.append(")"); + buf.append( ")" ); } else { - in.putback(c); // put back open paren + in.putback( c ); // put back open paren } - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /** @@ -672,22 +653,21 @@ const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err // entity types. To read a user-defined keyword: read the '!' then call // this function with skipInitWS turned off. **/ -const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS) -{ +const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ) { char c; - if(skipInitWS) { + if( skipInitWS ) { in >> ws; } - while(in.get(c) && !isspace(c) && (isalnum(c) || (c == '_'))) { + while( in.get( c ) && !isspace( c ) && ( isalnum( c ) || ( c == '_' ) ) ) { buf += c; } - if(in.eof() || in.good()) { - in.putback(c); + if( in.eof() || in.good() ) { + in.putback( c ); } - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } /*************************** @@ -704,36 +684,35 @@ of an entity of a specific type. They shall consist of uppercase letters, digits, underscore characters, and possibly an exclamation mark. The "!" shall appear only once, and only as the first character. ***************************/ -const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err) -{ +const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) { char c; int sz = 1; static std::string str; str = ""; - in.get(c); - while(!((isspace(c)) || (strchr(delims, c)))) { + in.get( c ); + while( !( ( isspace( c ) ) || ( strchr( delims, c ) ) ) ) { //check to see if the char is valid - if(!((isupper(c)) || - (isdigit(c)) || - (c == '_') || - (c == '-') || //for reading 'ISO-10303-21' - ((c == '!') && (sz == 1)))) { + if( !( ( isupper( c ) ) || + ( isdigit( c ) ) || + ( c == '_' ) || + ( c == '-' ) || //for reading 'ISO-10303-21' + ( ( c == '!' ) && ( sz == 1 ) ) ) ) { cerr << "Error: Invalid character \'" << c << "\' in GetKeyword.\nkeyword was: " << str << "\n"; - err.GreaterSeverity(SEVERITY_WARNING); - in.putback(c); - return const_cast(str.c_str()); + err.GreaterSeverity( SEVERITY_WARNING ); + in.putback( c ); + return const_cast( str.c_str() ); } - if(!in.good()) { + if( !in.good() ) { break; //BUG: should do something on eof() } str += c; ++sz; - in.get(c); + in.get( c ); } - in.putback(c); - return const_cast(str.c_str()); + in.putback( c ); + return const_cast( str.c_str() ); } /** @@ -748,47 +727,46 @@ const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err) * next chars are DATA; for the beginning of the data section). * FIXME putback() doesn't work well on all platforms */ -int FoundEndSecKywd(istream &in) -{ +int FoundEndSecKywd( istream & in ) { char c; in >> ws; - in.get(c); - - if(c == 'E') { - in.get(c); - if(c == 'N') { - in.get(c); - if(c == 'D') { - in.get(c); - if(c == 'S') { - in.get(c); - if(c == 'E') { - in.get(c); - if(c == 'C') { + in.get( c ); + + if( c == 'E' ) { + in.get( c ); + if( c == 'N' ) { + in.get( c ); + if( c == 'D' ) { + in.get( c ); + if( c == 'S' ) { + in.get( c ); + if( c == 'E' ) { + in.get( c ); + if( c == 'C' ) { in >> ws; - in.get(c); - if(c == ';') { + in.get( c ); + if( c == ';' ) { return 1; } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } } else { - in.putback(c); + in.putback( c ); } // error return 0; @@ -801,28 +779,27 @@ int FoundEndSecKywd(istream &in) // returned. If one is found ss is appended with it and a pointer just // past the comment in s is returned. Note* a carraige return ('\n') is added // after the comment that is appended. -const char *ReadComment(std::string &ss, const char *s) -{ +const char * ReadComment( std::string & ss, const char * s ) { std::string ssTmp; - if(s) { + if( s ) { int endComment = 0; - while(*s && *s != '/') { + while( *s && *s != '/' ) { s++; // skip leading everything } - if(*s == '/') { + if( *s == '/' ) { s++; - if(*s == '*') { // found a comment - ssTmp.append("/*"); + if( *s == '*' ) { // found a comment + ssTmp.append( "/*" ); s++; - while(*s && !endComment) { - if(*s == '*') { + while( *s && !endComment ) { + if( *s == '*' ) { ssTmp += *s; s++; - if(*s == '/') { + if( *s == '/' ) { endComment = 1; ssTmp += *s; - ssTmp.append("\n"); + ssTmp.append( "\n" ); } else { s--; } @@ -833,8 +810,8 @@ const char *ReadComment(std::string &ss, const char *s) } } } - if(endComment) { - ss.append(ssTmp.c_str()); + if( endComment ) { + ss.append( ssTmp.c_str() ); } } return s; @@ -852,30 +829,29 @@ const char *ReadComment(std::string &ss, const char *s) * only the slash will be read from 'in'. * FIXME putback() doesn't work well on all platforms ***************************/ -const char *ReadComment(istream &in, std::string &s) -{ +const char * ReadComment( istream & in, std::string & s ) { char c = '\0'; in >> ws; in >> c; // it looks like a comment so far - if(c == '/') { // leave slash read from stream - in.get(c); // won't skip space - if(c == '*') { // it is a comment + if( c == '/' ) { // leave slash read from stream + in.get( c ); // won't skip space + if( c == '*' ) { // it is a comment in >> ws; // skip leading comment space int commentLength = 0; // only to keep it from completely gobbling up input - while(commentLength <= MAX_COMMENT_LENGTH) { - in.get(c); - if(c == '*') { // looks like start of end comment - in.get(c); - if(c == '/') { // it is end of comment + while( commentLength <= MAX_COMMENT_LENGTH ) { + in.get( c ); + if( c == '*' ) { // looks like start of end comment + in.get( c ); + if( c == '/' ) { // it is end of comment return s.c_str(); // return comment as a string } else { // it is not end of comment // so store the * and put back the other char - s.append("*"); - in.putback(c); + s.append( "*" ); + in.putback( c ); commentLength++; } } else { @@ -887,17 +863,17 @@ const char *ReadComment(istream &in, std::string &s) << MAX_COMMENT_LENGTH << "\n" << "Will try to recover...\n"; std::string tmp; - SkipInstance(in, tmp); + SkipInstance( in, tmp ); return s.c_str(); } // leave slash read from stream... assume caller already knew there was // a slash, leave it off stream so they don't think this funct needs // to be called again else { // not a comment - in.putback(c); // put non asterisk char back on input stream + in.putback( c ); // put non asterisk char back on input stream } } else { // first non-white char is not a slash - in.putback(c); // put non slash char back on input stream + in.putback( c ); // put non slash char back on input stream } return 0; // no comment string to return @@ -908,16 +884,15 @@ const char *ReadComment(istream &in, std::string &s) ** "\F\" == formfeed ** "\N\" == newline ***************************/ -Severity ReadPcd(istream &in) -{ +Severity ReadPcd( istream & in ) { char c; - in.get(c); - if(c == '\\') { - in.get(c); - if(c == 'F' || c == 'N') { - in.get(c); - if(c == '\\') { - in.get(c); + in.get( c ); + if( c == '\\' ) { + in.get( c ); + if( c == 'F' || c == 'N' ) { + in.get( c ); + if( c == '\\' ) { + in.get( c ); return SEVERITY_NULL; } } @@ -936,33 +911,32 @@ and comments. Part 21 considers the blank to be the space character, but this function considers blanks to be the return value of isspace(c) ******************************/ -void ReadTokenSeparator(istream &in, std::string *comments) -{ +void ReadTokenSeparator( istream & in, std::string * comments ) { char c; std::string s; // used if need to read a comment - if(in.eof()) { + if( in.eof() ) { //BUG: no error message is reported return; } - while(in) { + while( in ) { in >> ws; // skip white space. c = in.peek(); // look at next char on input stream - switch(c) { + switch( c ) { case '/': // read p21 file comment s.clear(); - ReadComment(in, s); - if(!s.empty() && comments) { - comments->append("/*"); - comments->append(s.c_str()); - comments->append("*/\n"); + ReadComment( in, s ); + if( !s.empty() && comments ) { + comments->append( "/*" ); + comments->append( s.c_str() ); + comments->append( "*/\n" ); } break; case '\\': // try to read a print control directive - ReadPcd(in); + ReadPcd( in ); break; case '\n': in.ignore(); diff --git a/src/clstepcore/read_func.h b/src/clstepcore/read_func.h index 1b5d0c101..92cff5705 100644 --- a/src/clstepcore/read_func.h +++ b/src/clstepcore/read_func.h @@ -8,75 +8,75 @@ #define MAX_COMMENT_LENGTH 8192 // print Error information for debugging purposes -extern SC_CORE_EXPORT void PrintErrorState(ErrorDescriptor &err); +extern SC_CORE_EXPORT void PrintErrorState( ErrorDescriptor & err ); // print istream error information for debugging purposes -extern SC_CORE_EXPORT void IStreamState(istream &in); +extern SC_CORE_EXPORT void IStreamState( istream & in ); -extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadInteger(SDAI_Integer &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadInteger( SDAI_Integer & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity IntValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity IntValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); -extern SC_CORE_EXPORT std::string WriteReal(SDAI_Real val); +extern SC_CORE_EXPORT std::string WriteReal( SDAI_Real val ); -extern SC_CORE_EXPORT void WriteReal(SDAI_Real val, ostream &out); +extern SC_CORE_EXPORT void WriteReal( SDAI_Real val, ostream & out ); -extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadReal(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadReal( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity RealValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); -extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, istream &in, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, istream & in, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT int ReadNumber(SDAI_Real &val, const char *s, ErrorDescriptor *err, - const char *tokenList); +extern SC_CORE_EXPORT int ReadNumber( SDAI_Real & val, const char * s, ErrorDescriptor * err, + const char * tokenList ); -extern SC_CORE_EXPORT Severity NumberValidLevel(const char *attrValue, ErrorDescriptor *err, - int clearError, int optional, const char *tokenList); +extern SC_CORE_EXPORT Severity NumberValidLevel( const char * attrValue, ErrorDescriptor * err, + int clearError, int optional, const char * tokenList ); //////////////////// -extern SC_CORE_EXPORT int QuoteInString(istream &in); +extern SC_CORE_EXPORT int QuoteInString( istream & in ); -extern SC_CORE_EXPORT void PushPastString(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastImbedAggr(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ); -extern SC_CORE_EXPORT void PushPastAggr1Dim(istream &in, std::string &s, ErrorDescriptor *err); +extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ); //////////////////// -extern SC_CORE_EXPORT Severity FindStartOfInstance(istream &in, std::string &inst); +extern SC_CORE_EXPORT Severity FindStartOfInstance( istream & in, std::string & inst ); /// used for instances that aren\'t valid - reads to next \';\' -extern SC_CORE_EXPORT Severity SkipInstance(istream &in, std::string &inst); +extern SC_CORE_EXPORT Severity SkipInstance( istream & in, std::string & inst ); -extern SC_CORE_EXPORT const char *SkipSimpleRecord(istream &in, std::string &buf, ErrorDescriptor *err); +extern SC_CORE_EXPORT const char * SkipSimpleRecord( istream & in, std::string & buf, ErrorDescriptor * err ); /// this includes entity names -extern SC_CORE_EXPORT const char *ReadStdKeyword(istream &in, std::string &buf, int skipInitWS = 1); +extern SC_CORE_EXPORT const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS = 1 ); -extern SC_CORE_EXPORT const char *GetKeyword(istream &in, const char *delims, ErrorDescriptor &err); +extern SC_CORE_EXPORT const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ); -extern SC_CORE_EXPORT int FoundEndSecKywd(istream &in); +extern SC_CORE_EXPORT int FoundEndSecKywd( istream& in ); -extern SC_CORE_EXPORT const char *ReadComment(std::string &ss, const char *s); +extern SC_CORE_EXPORT const char * ReadComment( std::string & ss, const char * s ); -extern SC_CORE_EXPORT const char *ReadComment(istream &in, std::string &s); +extern SC_CORE_EXPORT const char * ReadComment( istream & in, std::string & s ); -extern SC_CORE_EXPORT Severity ReadPcd(istream &in); //print control directive +extern SC_CORE_EXPORT Severity ReadPcd( istream & in ); //print control directive -extern SC_CORE_EXPORT void ReadTokenSeparator(istream &in, std::string *comments = 0); +extern SC_CORE_EXPORT void ReadTokenSeparator( istream & in, std::string * comments = 0 ); #endif diff --git a/src/clstepcore/realTypeDescriptor.h b/src/clstepcore/realTypeDescriptor.h index 155598bd3..8f1519540 100644 --- a/src/clstepcore/realTypeDescriptor.h +++ b/src/clstepcore/realTypeDescriptor.h @@ -3,27 +3,23 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor -{ +class SC_CORE_EXPORT RealTypeDescriptor : public TypeDescriptor { - protected: - SDAI_Integer _precisionSpec; // OPTIONAL - public: +protected: + SDAI_Integer _precisionSpec; // OPTIONAL +public: - RealTypeDescriptor() - { - _precisionSpec = 0; - } - virtual ~RealTypeDescriptor() { } + RealTypeDescriptor( ) { + _precisionSpec = 0; + } + virtual ~RealTypeDescriptor() { } - SDAI_Integer PrecisionSpec() - { - return _precisionSpec; - } - void PrecisionSpec(SDAI_Integer ps) - { - _precisionSpec = ps; - } + SDAI_Integer PrecisionSpec() { + return _precisionSpec; + } + void PrecisionSpec( SDAI_Integer ps ) { + _precisionSpec = ps; + } }; #endif //REALTYPEDESCRIPTOR_H diff --git a/src/clstepcore/schRename.cc b/src/clstepcore/schRename.cc index 32e1fe8c0..b7159a6e0 100644 --- a/src/clstepcore/schRename.cc +++ b/src/clstepcore/schRename.cc @@ -5,13 +5,12 @@ * See if nm = one of our choices (either ours or that of a SchRename * later in the list. */ -bool SchRename::choice(const char *nm) const -{ - if(!StrCmpIns(nm, newName)) { +bool SchRename::choice( const char * nm ) const { + if( !StrCmpIns( nm, newName ) ) { return true; } - if(next) { - return (next->choice(nm)); + if( next ) { + return ( next->choice( nm ) ); } return false; } @@ -23,14 +22,13 @@ bool SchRename::choice(const char *nm) const * on next. Thus, this function will tell us if this or any later SchRe- * name in this list provide a new name for TypeDesc for schema schnm. */ -char *SchRename::rename(const char *schnm, char *newnm) const -{ - if(!StrCmpIns(schnm, schName)) { - strcpy(newnm, newName); +char * SchRename::rename( const char * schnm, char * newnm ) const { + if( !StrCmpIns( schnm, schName ) ) { + strcpy( newnm, newName ); return newnm; } - if(next) { - return (next->rename(schnm, newnm)); + if( next ) { + return ( next->rename( schnm, newnm ) ); } return NULL; } diff --git a/src/clstepcore/schRename.h b/src/clstepcore/schRename.h index d9ada7db8..a0403a5d8 100644 --- a/src/clstepcore/schRename.h +++ b/src/clstepcore/schRename.h @@ -19,35 +19,30 @@ * schema is determined by the file schema section of the header section of a * part21 file (the _headerInstances of STEPfile). */ -class SC_CORE_EXPORT SchRename -{ - public: - SchRename(const char *sch = "\0", const char *newnm = "\0") : next(0) - { - strcpy(schName, sch); - strcpy(newName, newnm); - } - ~SchRename() - { - delete next; - } - const char *objName() const - { - return newName; - } - int operator< (SchRename &schrnm) - { - return (strcmp(schName, schrnm.schName) < 0); - } - bool choice(const char *nm) const; - // is nm one of our possible choices? - char *rename(const char *schm, char *newnm) const; - // given a schema name, returns new object name if exists - SchRename *next; +class SC_CORE_EXPORT SchRename { +public: + SchRename( const char * sch = "\0", const char * newnm = "\0" ) : next( 0 ) { + strcpy( schName, sch ); + strcpy( newName, newnm ); + } + ~SchRename() { + delete next; + } + const char * objName() const { + return newName; + } + int operator< ( SchRename & schrnm ) { + return ( strcmp( schName, schrnm.schName ) < 0 ); + } + bool choice( const char * nm ) const; + // is nm one of our possible choices? + char * rename( const char * schm, char * newnm ) const; + // given a schema name, returns new object name if exists + SchRename * next; - private: - char schName[BUFSIZ]; - char newName[BUFSIZ]; +private: + char schName[BUFSIZ]; + char newName[BUFSIZ]; }; diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index 6ebf71f71..731a381f5 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -4,7 +4,7 @@ #include #include "sc_memmgr.h" -const char *SCLversion = "STEPcode, github.com/stepcode/stepcode"; +const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; const SDAI_Integer SDAI_INT_NULL = LONG_MAX; const SDAI_Real SDAI_REAL_NULL = FLT_MIN; diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index d066720b3..5751996a0 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -21,7 +21,7 @@ #include "sc_cf.h" #include -extern const char *SCLversion; +extern const char * SCLversion; #include #include @@ -151,9 +151,9 @@ enum SDAI_Error_id { SDAI_sdaiSY_ERR = 1000 // Underlying system error }; -typedef char *SDAI_Time_stamp; -typedef char *SDAI_Entity_name; -typedef char *SDAI_Schema_name; +typedef char * SDAI_Time_stamp; +typedef char * SDAI_Entity_name; +typedef char * SDAI_Schema_name; #include @@ -201,7 +201,7 @@ SELECT #include class SDAI_Model_contents; -typedef SDAI_Model_contents *SDAI_Model_contents_ptr; +typedef SDAI_Model_contents * SDAI_Model_contents_ptr; typedef SDAI_Model_contents_ptr SDAI_Model_contents_var; #include @@ -221,15 +221,15 @@ extern SC_CORE_EXPORT SDAI_Application_instance NilSTEPentity; typedef SDAI_Application_instance STEPentity; -typedef SDAI_Application_instance *STEPentity_ptr; +typedef SDAI_Application_instance * STEPentity_ptr; typedef STEPentity_ptr STEPentity_var; -typedef SDAI_Application_instance *STEPentityPtr; -typedef SDAI_Application_instance *STEPentityH; +typedef SDAI_Application_instance * STEPentityPtr; +typedef SDAI_Application_instance * STEPentityH; extern SC_CORE_EXPORT SDAI_Application_instance * -ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId); +ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ); #define SdaiInteger SDAI_Integer #define SdaiReal SDAI_Real @@ -252,17 +252,15 @@ AGGREGATE TYPES ******************************************************************************/ -inline SDAI_BOOLEAN *create_BOOLEAN() -{ +inline SDAI_BOOLEAN * create_BOOLEAN() { return new SDAI_BOOLEAN ; } -inline SDAI_LOGICAL *create_LOGICAL() -{ +inline SDAI_LOGICAL * create_LOGICAL() { return new SDAI_LOGICAL ; } // below is outdated -typedef SDAI_Select *SdaiSelectH; +typedef SDAI_Select * SdaiSelectH; #endif diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 3fc61b6fd..2bbf6b31c 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -20,11 +20,12 @@ #include "sdaiApplication_instance.h" #include "superInvAttrIter.h" +#include + SDAI_Application_instance NilSTEPentity; -bool isNilSTEPentity(const SDAI_Application_instance *ai) -{ - if(ai && ai == &NilSTEPentity) { +bool isNilSTEPentity( const SDAI_Application_instance * ai ) { + if( ai && ai == &NilSTEPentity ) { return true; } return false; @@ -42,44 +43,41 @@ bool isNilSTEPentity(const SDAI_Application_instance *ai) */ SDAI_Application_instance::SDAI_Application_instance() - : _cur(0), - eDesc(NULL), - _complex(false), - STEPfile_id(0), - p21Comment(std::string("")), - headMiEntity(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("")), - headMiEntity(0), - nextMiEntity(0) -{ -} - -SDAI_Application_instance::~SDAI_Application_instance() -{ - STEPattribute *attr; + : _cur( 0 ), + eDesc( NULL ), + _complex( false ), + STEPfile_id( 0 ), + p21Comment( std::string( "" ) ), + headMiEntity( 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( "" ) ), + headMiEntity( 0 ), + nextMiEntity( 0 ) { +} + +SDAI_Application_instance::~SDAI_Application_instance() { + STEPattribute * attr; ResetAttributes(); do { attr = NextAttribute(); - if(attr) { + if( attr ) { attr->refCount --; - if(attr->refCount <= 0) { + if( attr->refCount <= 0 ) { delete attr; } } - } while(attr); + } while( attr ); - if(MultipleInheritance()) { + if( MultipleInheritance() ) { delete nextMiEntity; } } @@ -88,93 +86,85 @@ 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; +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)); + 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()) { + superInvAttrIter siai( eDesc ); + while( !siai.empty() ) { ia = siai.next(); - assert(ia && "Null inverse attr!"); - iAMap.insert(iAMap_t::value_type(ia, s)); + assert( ia && "Null inverse attr!" ); + iAMap.insert( iAMap_t::value_type( ia, s ) ); } } -SDAI_Application_instance *SDAI_Application_instance::Replicate() -{ +SDAI_Application_instance * SDAI_Application_instance::Replicate() { char errStr[BUFSIZ]; - if(IsComplex()) { + if( IsComplex() ) { cerr << "STEPcomplex::Replicate() should be called: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", - "Programming ERROR - STEPcomplex::Replicate() should be called", - STEPfile_id); - _error.AppendToDetailMsg(errStr); - _error.AppendToUserMsg(errStr); - _error.GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "SDAI_Application_instance::Replicate(): %s - entity #%d.\n", + "Programming ERROR - STEPcomplex::Replicate() should be called", + STEPfile_id ); + _error.AppendToDetailMsg( errStr ); + _error.AppendToUserMsg( errStr ); + _error.GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } else { - if(!eDesc) { + if( !eDesc ) { return S_ENTITY_NULL; } - SDAI_Application_instance *seNew = eDesc->NewSTEPentity(); - seNew -> CopyAs(this); + SDAI_Application_instance * seNew = eDesc->NewSTEPentity(); + seNew -> CopyAs( this ); return seNew; } } -void SDAI_Application_instance::AddP21Comment(const char *s, bool replace) -{ - if(replace) { +void SDAI_Application_instance::AddP21Comment( const char * s, bool replace ) { + if( replace ) { p21Comment.clear(); } - if(s) { + if( s ) { p21Comment += s; } } -void SDAI_Application_instance::AddP21Comment(const std::string &s, bool replace) -{ - if(replace) { +void SDAI_Application_instance::AddP21Comment( const std::string & s, bool replace ) { + if( replace ) { p21Comment.clear(); } p21Comment += s; } -void SDAI_Application_instance::PrependP21Comment(const std::string &s) -{ - p21Comment.insert(0, s); +void SDAI_Application_instance::PrependP21Comment( const std::string & s ) { + p21Comment.insert( 0, s ); } -void SDAI_Application_instance::STEPwrite_reference(ostream &out) -{ +void SDAI_Application_instance::STEPwrite_reference( ostream & out ) { out << "#" << STEPfile_id; } -const char *SDAI_Application_instance::STEPwrite_reference(std::string &buf) -{ +const char * SDAI_Application_instance::STEPwrite_reference( std::string & buf ) { char tmp[64]; - sprintf(tmp, "#%d", STEPfile_id); + sprintf( tmp, "#%d", STEPfile_id ); buf = tmp; - return const_cast(buf.c_str()); + return const_cast( buf.c_str() ); } -void SDAI_Application_instance::AppendMultInstance(SDAI_Application_instance *se) -{ - if(nextMiEntity == 0) { +void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * se ) { + if( nextMiEntity == 0 ) { nextMiEntity = se; } else { - SDAI_Application_instance *link = nextMiEntity; - SDAI_Application_instance *linkTrailing = 0; - while(link) { + SDAI_Application_instance * link = nextMiEntity; + SDAI_Application_instance * linkTrailing = 0; + while( link ) { linkTrailing = link; link = link->nextMiEntity; } @@ -182,29 +172,32 @@ void SDAI_Application_instance::AppendMultInstance(SDAI_Application_instance *se } } +const EntityDescriptor* SDAI_Application_instance::getEDesc() const { + return eDesc; +} + // BUG implement this -- FIXME function is never used -SDAI_Application_instance *SDAI_Application_instance::GetMiEntity(char *entName) -{ +SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entName ) { std::string s1, s2; - const EntityDescLinkNode *edln = 0; - const EntityDescriptor *ed = eDesc; + const EntityDescLinkNode * edln = 0; + const EntityDescriptor * ed = eDesc; // compare up the *leftmost* parent path - while(ed) { - if(!strcmp(StrToLower(ed->Name(), s1), StrToLower(entName, s2))) { + while( ed ) { + if( !strcmp( StrToLower( ed->Name(), s1 ), StrToLower( entName, s2 ) ) ) { return this; // return this parent path } - edln = (EntityDescLinkNode *)(ed->Supertypes().GetHead()); - if(edln) { + edln = ( EntityDescLinkNode * )( ed->Supertypes().GetHead() ); + if( edln ) { ed = edln->EntityDesc(); } else { ed = 0; } } // search alternate parent path since didn't find it in this one. - if(nextMiEntity) { - return nextMiEntity->GetMiEntity(entName); + if( nextMiEntity ) { + return nextMiEntity->GetMiEntity( entName ); } return 0; } @@ -215,19 +208,18 @@ SDAI_Application_instance *SDAI_Application_instance::GetMiEntity(char *entName) * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When MakeDerived is called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute *SDAI_Application_instance::GetSTEPattribute(const char *nm, const char *entity) -{ - if(!nm) { +STEPattribute * SDAI_Application_instance::GetSTEPattribute( const char * nm, const char * entity ) { + if( !nm ) { return 0; } - STEPattribute *a = 0; + STEPattribute * a = 0; ResetAttributes(); // keep going until no more attributes, or attribute is found - while((a = NextAttribute())) { - if(0 == strcmp(nm, a ->Name()) && - //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? - (entity ? (0 != a->aDesc->Owner().IsA(entity)) : true)) { + while( ( a = NextAttribute() ) ) { + if( 0 == strcmp( nm, a ->Name() ) && + //if entity isn't null, check for a match. NOTE: should we use IsA(), CanBe(), or Name()? + ( entity ? ( 0 != a->aDesc->Owner().IsA( entity ) ) : true ) ) { break; } } @@ -235,14 +227,13 @@ STEPattribute *SDAI_Application_instance::GetSTEPattribute(const char *nm, const return a; } -STEPattribute *SDAI_Application_instance::MakeRedefined(STEPattribute *redefiningAttr, const char *nm) -{ +STEPattribute * SDAI_Application_instance::MakeRedefined( STEPattribute * redefiningAttr, const char * nm ) { // find the attribute being redefined - STEPattribute *a = GetSTEPattribute(nm); + STEPattribute * a = GetSTEPattribute( nm ); // assign its pointer to the redefining attribute - if(a) { - a->RedefiningAttr(redefiningAttr); + if( a ) { + a->RedefiningAttr( redefiningAttr ); } return a; } @@ -252,66 +243,61 @@ STEPattribute *SDAI_Application_instance::MakeRedefined(STEPattribute *redefinin * \param nm The name to search for. * \param entity If not null, check that the attribute comes from this entity. When called from generated code, this is used to ensure that the correct attr is marked as derived. Issue #232 */ -STEPattribute *SDAI_Application_instance::MakeDerived(const char *nm, const char *entity) -{ - STEPattribute *a = GetSTEPattribute(nm, entity); - if(a) { +STEPattribute * SDAI_Application_instance::MakeDerived( const char * nm, const char * entity ) { + STEPattribute * a = GetSTEPattribute( nm, entity ); + if( a ) { a ->Derive(); } return a; } -void SDAI_Application_instance::CopyAs(SDAI_Application_instance *other) -{ +void SDAI_Application_instance::CopyAs( SDAI_Application_instance * other ) { int numAttrs = AttributeCount(); ResetAttributes(); other -> ResetAttributes(); - STEPattribute *this_attr = 0; - STEPattribute *other_attr = 0; - while((this_attr = NextAttribute()) && numAttrs) { + STEPattribute * this_attr = 0; + STEPattribute * other_attr = 0; + while( ( this_attr = NextAttribute() ) && numAttrs ) { other_attr = other -> NextAttribute(); - this_attr -> ShallowCopy(other_attr); + this_attr -> ShallowCopy( other_attr ); numAttrs--; } } -const char *SDAI_Application_instance::EntityName(const char *schnm) const -{ - if(!eDesc) { +const char * SDAI_Application_instance::EntityName( const char * schnm ) const { + if( !eDesc ) { return NULL; } - return eDesc->Name(schnm); + return eDesc->Name( schnm ); } /** * Checks if a given SDAI_Application_instance is the same * type as this one */ -const EntityDescriptor *SDAI_Application_instance::IsA(const EntityDescriptor *ed) const -{ - if(!eDesc) { +const EntityDescriptor * SDAI_Application_instance::IsA( const EntityDescriptor * ed ) const { + if( !eDesc ) { return NULL; } - return (eDesc->IsA(ed)); + return ( eDesc->IsA( ed ) ); } /** * Checks the validity of the current attribute values for the entity */ -Severity SDAI_Application_instance::ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError) -{ +Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError ) { ErrorDescriptor err; - if(clearError) { + if( clearError ) { ClearError(); } int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) - error->GreaterSeverity(attributes[i].ValidLevel( - attributes[i].asStr().c_str(), &err, im, 0)); + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) + error->GreaterSeverity( attributes[i].ValidLevel( + attributes[i].asStr().c_str(), &err, im, 0 ) ); } return error->severity(); } @@ -319,10 +305,9 @@ Severity SDAI_Application_instance::ValidLevel(ErrorDescriptor *error, InstMgrBa /** * clears all attr's errors */ -void SDAI_Application_instance::ClearAttrError() -{ +void SDAI_Application_instance::ClearAttrError() { int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { + for( int i = 0 ; i < n; i++ ) { attributes[i].Error().ClearErrorMsg(); } } @@ -330,10 +315,9 @@ void SDAI_Application_instance::ClearAttrError() /** * clears entity's error and optionally all attr's errors */ -void SDAI_Application_instance::ClearError(int clearAttrs) -{ +void SDAI_Application_instance::ClearError( int clearAttrs ) { _error.ClearErrorMsg(); - if(clearAttrs) { + if( clearAttrs ) { ClearAttrError(); } } @@ -344,16 +328,15 @@ void SDAI_Application_instance::ClearError(int clearAttrs) ** Side Effects: writes out the SCOPE section for an entity ** Status: stub FIXME *******************************************************************/ -void SDAI_Application_instance::beginSTEPwrite(ostream &out) -{ +void SDAI_Application_instance::beginSTEPwrite( ostream & out ) { out << "begin STEPwrite ... \n" ; out.flush(); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(attributes[i].Type() == ENTITY_TYPE - && *(attributes[i].ptr.c) != S_ENTITY_NULL) { - (*(attributes[i].ptr.c)) -> STEPwrite(); + for( int i = 0 ; i < n; i++ ) { + if( attributes[i].Type() == ENTITY_TYPE + && *( attributes[i].ptr.c ) != S_ENTITY_NULL ) { + ( *( attributes[i].ptr.c ) ) -> STEPwrite(); } } } @@ -366,68 +349,65 @@ void SDAI_Application_instance::beginSTEPwrite(ostream &out) ** Problems: does not print out the SCOPE section of an entity ** *******************************************************************/ -void SDAI_Application_instance::STEPwrite(ostream &out, const char *currSch, - int writeComments) -{ +void SDAI_Application_instance::STEPwrite( ostream & out, const char * currSch, + int writeComments ) { std::string tmp; - if(writeComments && !p21Comment.empty()) { + if( writeComments && !p21Comment.empty() ) { out << p21Comment; } - out << "#" << STEPfile_id << "=" << StrToUpper(EntityName(currSch), tmp) + out << "#" << STEPfile_id << "=" << StrToUpper( EntityName( currSch ), tmp ) << "("; int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(i > 0) { + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( i > 0 ) { out << ","; } - (attributes[i]).STEPwrite(out, currSch); + ( attributes[i] ).STEPwrite( out, currSch ); } } out << ");\n"; } -void SDAI_Application_instance::endSTEPwrite(ostream &out) -{ +void SDAI_Application_instance::endSTEPwrite( ostream & out ) { out << "end STEPwrite ... \n" ; out.flush(); } -void SDAI_Application_instance::WriteValuePairs(ostream &out, - const char *currSch, - int writeComments, int mixedCase) -{ +void SDAI_Application_instance::WriteValuePairs( ostream & out, + const char * currSch, + int writeComments, int mixedCase ) { std::string s, tmp, tmp2; - if(writeComments && !p21Comment.empty()) { + if( writeComments && !p21Comment.empty() ) { out << p21Comment; } - if(eDesc) { - if(mixedCase) { + if( eDesc ) { + if( mixedCase ) { out << "#" << STEPfile_id << " " - << eDesc->QualifiedName(s) << endl; + << eDesc->QualifiedName( s ) << endl; } else { out << "#" << STEPfile_id << " " - << StrToUpper(eDesc->QualifiedName(s), tmp) << endl; + << StrToUpper( eDesc->QualifiedName( s ), tmp ) << endl; } } int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(mixedCase) { + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( mixedCase ) { out << "\t" - << attributes[i].aDesc->Owner().Name(s.c_str()) + << attributes[i].aDesc->Owner().Name( s.c_str() ) << "." << attributes[i].aDesc->Name() << " "; } else { out << "\t" - << StrToUpper(attributes[i].aDesc->Owner().Name(s.c_str()), tmp) - << "." << StrToUpper(attributes[i].aDesc->Name(), tmp2) << " "; + << StrToUpper( attributes[i].aDesc->Owner().Name( s.c_str() ), tmp ) + << "." << StrToUpper( attributes[i].aDesc->Name(), tmp2 ) << " "; } - (attributes[i]).STEPwrite(out, currSch); + ( attributes[i] ).STEPwrite( out, currSch ); out << endl; } } @@ -439,41 +419,39 @@ void SDAI_Application_instance::WriteValuePairs(ostream &out, ** Procedure: STEPwrite ** Problems: does not print out the SCOPE section of an entity ******************************************************************/ -const char *SDAI_Application_instance::STEPwrite(std::string &buf, const char *currSch) -{ +const char * SDAI_Application_instance::STEPwrite( std::string & buf, const char * currSch ) { buf.clear(); char instanceInfo[BUFSIZ]; std::string tmp; - sprintf(instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper(EntityName(currSch), tmp)); - buf.append(instanceInfo); + sprintf( instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper( EntityName( currSch ), tmp ) ); + buf.append( instanceInfo ); int n = attributes.list_length(); - for(int i = 0 ; i < n; i++) { - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { - if(i > 0) { - buf.append(","); + for( int i = 0 ; i < n; i++ ) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { + if( i > 0 ) { + buf.append( "," ); } - tmp = attributes[i].asStr(currSch) ; - buf.append(tmp); + tmp = attributes[i].asStr( currSch ) ; + buf.append( tmp ); } } - buf.append(");"); - return const_cast(buf.c_str()); + buf.append( ");" ); + return const_cast( buf.c_str() ); } -void SDAI_Application_instance::PrependEntityErrMsg() -{ +void SDAI_Application_instance::PrependEntityErrMsg() { char errStr[BUFSIZ]; errStr[0] = '\0'; - if(_error.severity() == SEVERITY_NULL) { + if( _error.severity() == SEVERITY_NULL ) { // if there is not an error already - sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName()); - _error.PrependToDetailMsg(errStr); + sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName() ); + _error.PrependToDetailMsg( errStr ); } } @@ -485,39 +463,38 @@ void SDAI_Application_instance::PrependEntityErrMsg() ** instance. i.e. a close quote followed by a semicolon optionally ** having whitespace between them. ******************************************************************/ -void SDAI_Application_instance::STEPread_error(char c, int i, istream &in, const char *schnm) -{ +void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, const char * schnm ) { (void) in; char errStr[BUFSIZ]; errStr[0] = '\0'; - if(_error.severity() == SEVERITY_NULL) { + if( _error.severity() == SEVERITY_NULL ) { // if there is not an error already - sprintf(errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), - EntityName()); - _error.PrependToDetailMsg(errStr); + sprintf( errStr, "\nERROR: ENTITY #%d %s\n", GetFileId(), + EntityName() ); + _error.PrependToDetailMsg( errStr ); } - if((i >= 0) && (i < attributes.list_length())) { // i is an attribute - Error().GreaterSeverity(SEVERITY_WARNING); - sprintf(errStr, " invalid data before type \'%s\'\n", - attributes[i].TypeName()); - _error.AppendToDetailMsg(errStr); + if( ( i >= 0 ) && ( i < attributes.list_length() ) ) { // i is an attribute + Error().GreaterSeverity( SEVERITY_WARNING ); + sprintf( errStr, " invalid data before type \'%s\'\n", + attributes[i].TypeName() ); + _error.AppendToDetailMsg( errStr ); } else { - Error().GreaterSeverity(SEVERITY_INPUT_ERROR); - _error.AppendToDetailMsg(" No more attributes were expected.\n"); + Error().GreaterSeverity( SEVERITY_INPUT_ERROR ); + _error.AppendToDetailMsg( " No more attributes were expected.\n" ); } std::string tmp; - STEPwrite(tmp, schnm); // STEPwrite writes to a static buffer inside function - _error.AppendToDetailMsg(" The invalid instance to this point looks like :\n"); - _error.AppendToDetailMsg(tmp); - _error.AppendToDetailMsg("\nUnexpected character: "); - _error.AppendToDetailMsg(c); - _error.AppendToDetailMsg('\n'); - - sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); - _error.AppendToDetailMsg(errStr); + STEPwrite( tmp, schnm ); // STEPwrite writes to a static buffer inside function + _error.AppendToDetailMsg( " The invalid instance to this point looks like :\n" ); + _error.AppendToDetailMsg( tmp ); + _error.AppendToDetailMsg( "\nUnexpected character: " ); + _error.AppendToDetailMsg( c ); + _error.AppendToDetailMsg( '\n' ); + + sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); + _error.AppendToDetailMsg( errStr ); return; } @@ -535,10 +512,9 @@ void SDAI_Application_instance::STEPread_error(char c, int i, istream &in, const ** Side Effects: gobbles up input stream ** Status: ******************************************************************/ -Severity SDAI_Application_instance::STEPread(int id, int idIncr, - InstMgrBase *instance_set, istream &in, - const char *currSch, bool useTechCor, bool strict) -{ +Severity SDAI_Application_instance::STEPread( int id, int idIncr, + InstMgrBase * instance_set, istream & in, + const char * currSch, bool useTechCor, bool strict ) { STEPfile_id = id; char c = '\0'; char errStr[BUFSIZ]; @@ -546,53 +522,53 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, Severity severe; int i = 0; - ClearError(1); + ClearError( 1 ); in >> ws; in >> c; // read the open paren - if(c != '(') { + if( c != '(' ) { PrependEntityErrMsg(); _error.AppendToDetailMsg( - " Missing initial open paren... Trying to recover.\n"); - in.putback(c); // assume you can recover by reading 1st attr value + " Missing initial open paren... Trying to recover.\n" ); + in.putback( c ); // assume you can recover by reading 1st attr value } - ReadTokenSeparator(in, &p21Comment); + ReadTokenSeparator( in, &p21Comment ); int n = attributes.list_length(); - if(n == 0) { // no attributes + if( n == 0 ) { // no attributes in >> c; // look for the close paren - if(c == ')') { + if( c == ')' ) { return _error.severity(); } } - for(i = 0 ; i < n; i++) { - ReadTokenSeparator(in, &p21Comment); - if(attributes[i].aDesc->AttrType() == AttrType_Redefining) { + for( i = 0 ; i < n; i++ ) { + ReadTokenSeparator( in, &p21Comment ); + if( attributes[i].aDesc->AttrType() == AttrType_Redefining ) { in >> ws; c = in.peek(); - if(!useTechCor) { // i.e. use pre-technical corrigendum encoding + if( !useTechCor ) { // i.e. use pre-technical corrigendum encoding in >> c; // read what should be the '*' in >> ws; - if(c == '*') { + if( c == '*' ) { in >> c; // read the delimiter i.e. ',' or ')' } else { severe = SEVERITY_INCOMPLETE; PrependEntityErrMsg(); // adds entity info if necessary // set the severity for this entity - _error.GreaterSeverity(severe); - sprintf(errStr, " %s : ", attributes[i].Name()); - _error.AppendToDetailMsg(errStr); // add attr name + _error.GreaterSeverity( severe ); + sprintf( errStr, " %s : ", attributes[i].Name() ); + _error.AppendToDetailMsg( errStr ); // add attr name _error.AppendToDetailMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n"); + "Since using pre-technical corrigendum... missing asterisk for redefined attr.\n" ); _error.AppendToUserMsg( - "Since using pre-technical corrigendum... missing asterisk for redefined attr. "); + "Since using pre-technical corrigendum... missing asterisk for redefined attr. " ); } } else { // using technical corrigendum // should be nothing to do except loop again unless... // if at end need to have read the closing paren. - if(c == ')') { // assume you are at the end so read last char + if( c == ')' ) { // assume you are at the end so read last char in >> c; } cout << "Entity #" << STEPfile_id @@ -602,54 +578,54 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, // increment counter to read following attr since these attrs // aren't written or read => there won't be a delimiter either } else { - attributes[i].STEPread(in, instance_set, idIncr, currSch, strict); + attributes[i].STEPread( in, instance_set, idIncr, currSch, strict ); in >> c; // read the , or ) following the attr read severe = attributes[i].Error().severity(); - if(severe <= SEVERITY_USERMSG) { + if( severe <= SEVERITY_USERMSG ) { // if there is some type of error PrependEntityErrMsg(); // set the severity for this entity - _error.GreaterSeverity(severe); - sprintf(errStr, " %s : ", attributes[i].Name()); - _error.AppendToDetailMsg(errStr); // add attr name - _error.AppendToDetailMsg(attributes[i].Error().DetailMsg()); // add attr error - _error.AppendToUserMsg(attributes[i].Error().UserMsg()); + _error.GreaterSeverity( severe ); + sprintf( errStr, " %s : ", attributes[i].Name() ); + _error.AppendToDetailMsg( errStr ); // add attr name + _error.AppendToDetailMsg( attributes[i].Error().DetailMsg() ); // add attr error + _error.AppendToUserMsg( attributes[i].Error().UserMsg() ); } } // if technical corrigendum redefined, input is at next attribute value // if pre-technical corrigendum redefined, don't process - if((!(attributes[i].aDesc->AttrType() == AttrType_Redefining) || - !useTechCor) && - !((c == ',') || (c == ')'))) { // input is not a delimiter + if( ( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) || + !useTechCor ) && + !( ( c == ',' ) || ( c == ')' ) ) ) { // input is not a delimiter PrependEntityErrMsg(); _error.AppendToDetailMsg( - "Delimiter expected after attribute value.\n"); - if(!useTechCor) { + "Delimiter expected after attribute value.\n" ); + if( !useTechCor ) { _error.AppendToDetailMsg( - "I.e. since using pre-technical corrigendum, redefined "); + "I.e. since using pre-technical corrigendum, redefined " ); _error.AppendToDetailMsg( - "attribute is mapped as an asterisk so needs delimiter.\n"); + "attribute is mapped as an asterisk so needs delimiter.\n" ); } - CheckRemainingInput(in, &_error, "ENTITY", ",)"); - if(!in.good()) { + CheckRemainingInput( in, &_error, "ENTITY", ",)" ); + if( !in.good() ) { return _error.severity(); } - if(_error.severity() <= SEVERITY_INPUT_ERROR) { + if( _error.severity() <= SEVERITY_INPUT_ERROR ) { return _error.severity(); } - } else if(c == ')') { - while(i < n - 1) { + } else if( c == ')' ) { + while( i < n - 1 ) { i++; // check if following attributes are redefined - if(!(attributes[i].aDesc->AttrType() == AttrType_Redefining)) { + if( !( attributes[i].aDesc->AttrType() == AttrType_Redefining ) ) { PrependEntityErrMsg(); - _error.AppendToDetailMsg("Missing attribute value[s].\n"); + _error.AppendToDetailMsg( "Missing attribute value[s].\n" ); // recoverable error - _error.GreaterSeverity(SEVERITY_WARNING); + _error.GreaterSeverity( SEVERITY_WARNING ); return _error.severity(); } i++; @@ -657,7 +633,7 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, return _error.severity(); } } - STEPread_error(c, i, in, currSch); + STEPread_error( c, i, in, currSch ); // code fragment imported from STEPread_error // for some currently unknown reason it was commented out of STEPread_error errStr[0] = '\0'; @@ -668,148 +644,144 @@ Severity SDAI_Application_instance::STEPread(int id, int idIncr, // Search until a close paren is found followed by (skipping optional // whitespace) a semicolon - while(in.good() && !foundEnd) { - while(in.good() && (c != ')')) { - in.get(c); + while( in.good() && !foundEnd ) { + while( in.good() && ( c != ')' ) ) { + in.get( c ); tmp += c; } - if(in.good() && (c == ')')) { + if( in.good() && ( c == ')' ) ) { in >> ws; // skip whitespace - in.get(c); + in.get( c ); tmp += c; - if(c == ';') { + if( c == ';' ) { foundEnd = 1; } } } - _error.AppendToDetailMsg(tmp.c_str()); - sprintf(errStr, "\nfinished reading #%d\n", STEPfile_id); - _error.AppendToDetailMsg(errStr); + _error.AppendToDetailMsg( tmp.c_str() ); + sprintf( errStr, "\nfinished reading #%d\n", STEPfile_id ); + _error.AppendToDetailMsg( errStr ); // end of imported code return _error.severity(); } /// read an entity reference and return a pointer to the SDAI_Application_instance -SDAI_Application_instance *ReadEntityRef(istream &in, ErrorDescriptor *err, const char *tokenList, - InstMgrBase *instances, int addFileId) -{ +SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ) { char c; char errStr[BUFSIZ]; errStr[0] = '\0'; in >> ws; in >> c; - switch(c) { + switch( c ) { case '@': - err->AppendToDetailMsg("Use of @ instead of # to identify entity.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Use of @ instead of # to identify entity.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); // no break statement here on purpose - [[gnu::fallthrough]]; case '#': { int id = -1; in >> id; - if(in.fail()) { // there's been an error in input - sprintf(errStr, "Invalid entity reference value.\n"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_WARNING); - CheckRemainingInput(in, err, "Entity Reference", tokenList); + if( in.fail() ) { // there's been an error in input + sprintf( errStr, "Invalid entity reference value.\n" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_WARNING ); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); return S_ENTITY_NULL; } else { // found an entity id // check to make sure garbage does not follow the id - CheckRemainingInput(in, err, "Entity Reference", tokenList); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); id += addFileId; - if(!instances) { + if( !instances ) { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - cannot read reference without the InstMgr", - id, "is unknown"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - cannot read reference without the InstMgr", + id, "is unknown" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } // lookup which object has id as its instance id - SDAI_Application_instance *inst; + SDAI_Application_instance * inst; /* If there is a ManagerNode it should have a SDAI_Application_instance */ - MgrNodeBase *mn = 0; - mn = instances->FindFileId(id); - if(mn) { + MgrNodeBase * mn = 0; + mn = instances->FindFileId( id ); + if( mn ) { inst = mn->GetSTEPentity() ; - if(inst) { - return (inst); + if( inst ) { + return ( inst ); } else { cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; - sprintf(errStr, - "STEPread_reference(): %s - entity #%d %s.\n", - "BUG - MgrNode::GetSTEPentity returned NULL pointer", - id, "is unknown"); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_BUG); + sprintf( errStr, + "STEPread_reference(): %s - entity #%d %s.\n", + "BUG - MgrNode::GetSTEPentity returned NULL pointer", + id, "is unknown" ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_BUG ); return S_ENTITY_NULL; } } else { - sprintf(errStr, "Reference to non-existent ENTITY #%d.\n", - id); - err->AppendToDetailMsg(errStr); - err->AppendToUserMsg(errStr); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( errStr, "Reference to non-existent ENTITY #%d.\n", + id ); + err->AppendToDetailMsg( errStr ); + err->AppendToUserMsg( errStr ); + err->GreaterSeverity( SEVERITY_WARNING ); return S_ENTITY_NULL; } } } default: { - in.putback(c); + in.putback( c ); // read past garbage up to delim in tokenList // if tokenList is null it will not read anything - CheckRemainingInput(in, err, "Entity Reference", tokenList); + CheckRemainingInput( in, err, "Entity Reference", tokenList ); return S_ENTITY_NULL; } } } /// 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, - InstMgrBase *instances, int addFileId) -{ - istringstream in((char *)s); - return ReadEntityRef(in, err, tokenList, instances, addFileId); +SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList, + InstMgrBase * instances, int addFileId ) { + istringstream in( ( char * )s ); + return ReadEntityRef( in, err, tokenList, instances, addFileId ); } /// return SEVERITY_NULL if se's entity type matches the supplied entity type -Severity EntityValidLevel(SDAI_Application_instance *se, - const TypeDescriptor *ed, // entity type that entity se needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor *err) -{ +Severity EntityValidLevel( SDAI_Application_instance * se, + const TypeDescriptor * ed, // entity type that entity se needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor * err ) { char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; - if(!ed || (ed->NonRefType() != ENTITY_TYPE)) { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel() called with %s", - "missing or invalid EntityDescriptor\n"); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + if( !ed || ( ed->NonRefType() != ENTITY_TYPE ) ) { + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel() called with %s", + "missing or invalid EntityDescriptor\n" ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; } - if(!se || (se == S_ENTITY_NULL)) { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel() called with null pointer %s\n", - "for SDAI_Application_instance argument."); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + if( !se || ( se == S_ENTITY_NULL ) ) { + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel() called with null pointer %s\n", + "for SDAI_Application_instance argument." ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -818,35 +790,35 @@ 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()) { + if( se->IsComplex() ) { // This way assumes that the complex has all it's parts i.e. the // complete hierarchy so it should be able to find ed's part if // it is an ed. - STEPcomplex *sc = ((STEPcomplex *)se)->sc; - if(sc->EntityExists(ed->Name())) { + STEPcomplex * sc = ( ( STEPcomplex * )se )->sc; + if( sc->EntityExists( ed->Name() ) ) { return SEVERITY_NULL; } } - err->GreaterSeverity(SEVERITY_WARNING); - sprintf(messageBuf, - " Entity #%d exists but is not a %s or descendant.\n", - se->STEPfile_id, ed->Name()); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity( SEVERITY_WARNING ); + sprintf( messageBuf, + " Entity #%d exists but is not a %s or descendant.\n", + se->STEPfile_id, ed->Name() ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); return SEVERITY_WARNING; } } else { - err->GreaterSeverity(SEVERITY_BUG); - sprintf(messageBuf, - " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", - se->STEPfile_id, "missing or invalid EntityDescriptor\n"); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); + err->GreaterSeverity( SEVERITY_BUG ); + sprintf( messageBuf, + " BUG: EntityValidLevel(): SDAI_Application_instance #%d has a %s", + se->STEPfile_id, "missing or invalid EntityDescriptor\n" ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); cerr << "Internal error: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; return SEVERITY_BUG; @@ -857,19 +829,18 @@ Severity EntityValidLevel(SDAI_Application_instance *se, * return 1 if attrValue has the equivalent of a null value. * DAVE: Is this needed will sscanf return 1 if assignment suppression is used? */ -int SetErrOnNull(const char *attrValue, ErrorDescriptor *error) -{ +int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ) { char scanBuf[BUFSIZ]; scanBuf[0] = '\0'; std::stringstream fmtstr; - fmtstr << " %" << BUFSIZ - 1 << "s "; + fmtstr << " %" << BUFSIZ -1 << "s "; //fmtstr contains " %ns " where n is BUFSIZ -1 - int numFound = sscanf((char *)attrValue, fmtstr.str().c_str(), scanBuf); + int numFound = sscanf( ( char * )attrValue , fmtstr.str().c_str() , scanBuf ); - if(numFound == EOF) { - error->GreaterSeverity(SEVERITY_INCOMPLETE); + if( numFound == EOF ) { + error->GreaterSeverity( SEVERITY_INCOMPLETE ); return 1; } return 0; @@ -881,73 +852,69 @@ int SetErrOnNull(const char *attrValue, ErrorDescriptor *error) ** without the # sign: e.g. either #23 or 23 will be read. ** If non-whitespace characters follow the entity reference an error is set. */ -Severity EntityValidLevel(const char *attrValue, // string contain entity ref - const TypeDescriptor *ed, // entity type that entity in - // attrValue (if it exists) needs - // to match. (this must be an - // EntityDescriptor) - ErrorDescriptor *err, InstMgrBase *im, int clearError) -{ +Severity EntityValidLevel( const char * attrValue, // string contain entity ref + const TypeDescriptor * ed, // entity type that entity in + // attrValue (if it exists) needs + // to match. (this must be an + // EntityDescriptor) + ErrorDescriptor * err, InstMgrBase * im, int clearError ) { char tmp [BUFSIZ]; tmp[0] = '\0'; char messageBuf [BUFSIZ]; messageBuf[0] = '\0'; std::stringstream fmtstr1, fmtstr2; - if(clearError) { + if( clearError ) { err->ClearErrorMsg(); } int fileId; - MgrNodeBase *mn = 0; + MgrNodeBase * mn = 0; // fmtstr1 contains "#%d %ns" where n is BUFSIZ-1 fmtstr1 << " #%d %" << BUFSIZ - 1 << "s "; // fmtstr2 contains "%d %ns" where n is BUFSIZ-1 fmtstr2 << " %d %" << BUFSIZ - 1 << "s "; - + // check for both forms: #id or id - int found1 = sscanf((char *)attrValue, fmtstr1.str().c_str(), &fileId, tmp); - int found2 = sscanf((char *)attrValue, fmtstr2.str().c_str(), &fileId, tmp); - - if((found1 > 0) || (found2 > 0)) { - if((found1 == 2) || (found2 == 2)) { - int ocnt = snprintf(messageBuf, BUFSIZ, - " Attribute's Entity Reference %s is %s data \'%s\'.\n", - attrValue, "followed by invalid", tmp); - if(ocnt < BUFSIZ) { - fprintf(stderr, "Warning - truncation of Attribute's Entry Reference msg\n"); - } - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + int found1 = sscanf( ( char * )attrValue, fmtstr1.str().c_str() , &fileId, tmp ); + int found2 = sscanf( ( char * )attrValue, fmtstr2.str().c_str() , &fileId, tmp ); + + if( ( found1 > 0 ) || ( found2 > 0 ) ) { + if( ( found1 == 2 ) || ( found2 == 2 ) ) { + sprintf( messageBuf, + " Attribute's Entity Reference %s is %s data \'%s\'.\n", + attrValue, "followed by invalid", tmp ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); } - mn = im->FindFileId(fileId); - if(mn) { - SDAI_Application_instance *se = mn->GetSTEPentity(); - return EntityValidLevel(se, ed, err); + mn = im->FindFileId( fileId ); + if( mn ) { + SDAI_Application_instance * se = mn->GetSTEPentity(); + return EntityValidLevel( se, ed, err ); } else { - sprintf(messageBuf, - " Attribute's Entity Reference %s does not exist.\n", - attrValue); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( messageBuf, + " Attribute's Entity Reference %s does not exist.\n", + attrValue ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } } // if the attrValue contains no value return - if(SetErrOnNull(attrValue, err)) { + if( SetErrOnNull( attrValue, err ) ) { return err->severity(); } - sprintf(messageBuf, "Invalid attribute entity reference value: '%s'.\n", - attrValue); - err->AppendToUserMsg(messageBuf); - err->AppendToDetailMsg(messageBuf); - err->GreaterSeverity(SEVERITY_WARNING); + sprintf( messageBuf, "Invalid attribute entity reference value: '%s'.\n", + attrValue ); + err->AppendToUserMsg( messageBuf ); + err->AppendToDetailMsg( messageBuf ); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } @@ -957,52 +924,47 @@ Severity EntityValidLevel(const char *attrValue, // string contain entity ref ** Status: untested 7/31/90 ** \Returns reference to an attribute pointer ******************************************************************/ -STEPattribute *SDAI_Application_instance::NextAttribute() -{ +STEPattribute * SDAI_Application_instance::NextAttribute() { int i = AttributeCount(); ++_cur; - if(i < _cur) { + if( i < _cur ) { return 0; } return &attributes [_cur - 1]; } -int SDAI_Application_instance::AttributeCount() -{ +int SDAI_Application_instance::AttributeCount() { return attributes.list_length(); } -const iAstruct SDAI_Application_instance::getInvAttr(const Inverse_attribute *const ia) const -{ +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()) { + 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 -{ +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)) { + 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((Inverse_attribute *) NULL, z); + memset( &z, 0, sizeof z ); + iAMap_t::value_type nil( (Inverse_attribute *) nullptr, z ); return nil; } -void SDAI_Application_instance::setInvAttr(const Inverse_attribute *const ia, const iAstruct ias) -{ +void SDAI_Application_instance::setInvAttr( const Inverse_attribute * const ia, const iAstruct ias ) { iAMap_t::iterator it = iAMap.find(ia); - if(it != iAMap.end()) { + if( it != iAMap.end() ) { it->second = ias; } else { - iAMap.insert(iAMap_t::value_type(ia, ias)); + iAMap.insert( iAMap_t::value_type( ia, ias ) ); } } diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index 991e06fa8..70b7b3308 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -22,23 +22,22 @@ class EntityAggregate; class Inverse_attribute; typedef struct { union { - EntityAggregate *a; - SDAI_Application_instance *i; + EntityAggregate * a; + SDAI_Application_instance * i; }; } iAstruct; /** @class * this used to be STEPentity */ -class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI -{ +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; - const EntityDescriptor *eDesc; + typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t; protected: + const EntityDescriptor * eDesc; #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -52,10 +51,10 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI public: //TODO make these private? STEPattributeList attributes; - /* see mgrnode.cc where -1 is returned when there is no sdai - * instance. might be possible to treat 0 for this purpose - * instead of negative so the ID's can become unsigned. - */ + /* see mgrnode.cc where -1 is returned when there is no sdai + * instance. might be possible to treat 0 for this purpose + * instead of negative so the ID's can become unsigned. + */ int STEPfile_id; ErrorDescriptor _error; @@ -75,152 +74,140 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI ** and head points at the root SDAI_Application_instance of the primary inheritance ** path (the one that is the root of the leaf entity). */ - SDAI_Application_instance *headMiEntity; + SDAI_Application_instance * headMiEntity; /// these form a chain of other entity parents for multiple inheritance - SDAI_Application_instance *nextMiEntity; + SDAI_Application_instance * nextMiEntity; public: SDAI_Application_instance(); - SDAI_Application_instance(int fileid, int complex = 0); + SDAI_Application_instance( int fileid, int complex = 0 ); virtual ~SDAI_Application_instance(); - bool IsComplex() const - { + bool IsComplex() const { return _complex; } /// initialize inverse attribute list void InitIAttrs(); - void StepFileId(int fid) - { + void setEDesc( const EntityDescriptor * const ed ) { + eDesc = ed; + } + const EntityDescriptor * getEDesc() const; + void StepFileId( int fid ) { STEPfile_id = fid; } - int StepFileId() const - { + int StepFileId() const { return STEPfile_id; } - void AddP21Comment(const std::string &s, bool replace = true); - void AddP21Comment(const char *s, bool replace = true); - void PrependP21Comment(const std::string &s); - void DeleteP21Comment() - { + void AddP21Comment( const std::string & s, bool replace = true ); + void AddP21Comment( const char * s, bool replace = true ); + void PrependP21Comment( const std::string & s ); + void DeleteP21Comment() { p21Comment = ""; } - std::string P21Comment() const - { + std::string P21Comment() const { return p21Comment; } - const char *EntityName(const char *schnm = NULL) const; + const char * EntityName( const char * schnm = NULL ) const; - virtual const EntityDescriptor *IsA(const EntityDescriptor *) const; + virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const; - virtual Severity ValidLevel(ErrorDescriptor *error, InstMgrBase *im, - int clearError = 1); - ErrorDescriptor &Error() - { + virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im, + int clearError = 1 ); + ErrorDescriptor & Error() { return _error; } // clears entity's error and optionally all attr's errors - void ClearError(int clearAttrs = 1); + void ClearError( int clearAttrs = 1 ); // clears all attr's errors void ClearAttrError(); - virtual SDAI_Application_instance *Replicate(); + virtual SDAI_Application_instance * Replicate(); // ACCESS attributes in order. int AttributeCount(); - STEPattribute *NextAttribute(); - void ResetAttributes() - { + STEPattribute * NextAttribute(); + 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 - { + 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 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); + virtual Severity STEPread( int id, int addFileId, + 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(std::ostream &out = std::cout, const char *currSch = NULL, - int writeComments = 1); - virtual const char *STEPwrite(std::string &buf, 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(std::ostream &out, const char *currSch = NULL, - int writeComments = 1, int mixedCase = 1); + void WriteValuePairs( std::ostream & out, const char * currSch = NULL, + int writeComments = 1, int mixedCase = 1 ); - void STEPwrite_reference(std::ostream &out = std::cout); - const char *STEPwrite_reference(std::string &buf); + void STEPwrite_reference( std::ostream & out = std::cout ); + const char * STEPwrite_reference( std::string & buf ); - void beginSTEPwrite(std::ostream &out = std::cout); ///< writes out the SCOPE section - void endSTEPwrite(std::ostream &out = std::cout); + void beginSTEPwrite( std::ostream & out = std::cout ); ///< writes out the SCOPE section + void endSTEPwrite( std::ostream & out = std::cout ); // MULTIPLE INHERITANCE - int MultipleInheritance() - { - return !(headMiEntity == 0); + int MultipleInheritance() { + return !( headMiEntity == 0 ); } - void HeadEntity(SDAI_Application_instance *se) - { + void HeadEntity( SDAI_Application_instance * se ) { headMiEntity = se; } - SDAI_Application_instance *HeadEntity() - { + SDAI_Application_instance * HeadEntity() { return headMiEntity; } - SDAI_Application_instance *GetNextMiEntity() - { + SDAI_Application_instance * GetNextMiEntity() { return nextMiEntity; } - SDAI_Application_instance *GetMiEntity(char *entName); - void AppendMultInstance(SDAI_Application_instance *se); + SDAI_Application_instance * GetMiEntity( char * entName ); + void AppendMultInstance( SDAI_Application_instance * se ); protected: - STEPattribute *GetSTEPattribute(const char *nm, const char *entity = NULL); - STEPattribute *MakeDerived(const char *nm, const char *entity = NULL); - STEPattribute *MakeRedefined(STEPattribute *redefiningAttr, - const char *nm); + STEPattribute * GetSTEPattribute( const char * nm, const char * entity = NULL ); + STEPattribute * MakeDerived( const char * nm, const char * entity = NULL ); + STEPattribute * MakeRedefined( STEPattribute * redefiningAttr, + const char * nm ); - virtual void CopyAs(SDAI_Application_instance *); + virtual void CopyAs( SDAI_Application_instance * ); void PrependEntityErrMsg(); public: // these functions are going to go away in the future. - int SetFileId(int fid) - { + int SetFileId( int fid ) { return STEPfile_id = fid; } - int GetFileId() const - { + int GetFileId() const { return STEPfile_id; } - int FileId(int fid) - { + int FileId( int fid ) { return STEPfile_id = fid; } - int FileId() const - { + int FileId() const { return STEPfile_id; } }; // current style of CORBA handles for Part 23 - NOTE - used for more than CORBA -typedef SDAI_Application_instance *SDAI_Application_instance_ptr; +typedef SDAI_Application_instance * SDAI_Application_instance_ptr; typedef SDAI_Application_instance_ptr SDAI_Application_instance_var; -SC_CORE_EXPORT bool isNilSTEPentity(const SDAI_Application_instance *ai); +SC_CORE_EXPORT bool isNilSTEPentity( const SDAI_Application_instance * ai ); #endif //STEPENTITY_H diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 1d1d741ce..08e789a6d 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -19,23 +19,21 @@ #ifdef SC_LOGGING #include -extern ofstream *logStream; +extern ofstream * logStream; #endif /********** (member) functions for the select class SDAI_Select **********/ -SDAI_Select::SDAI_Select(const SelectTypeDescriptor *s, - const TypeDescriptor *td) - : _type(s), underlying_type(td) -{ +SDAI_Select::SDAI_Select( const SelectTypeDescriptor * s, + const TypeDescriptor * td ) + : _type( s ), underlying_type( td ) { #ifdef SC_LOGGING *logStream << "Exiting SDAI_Select constructor." << endl; #endif } -SDAI_Select::SDAI_Select(const SDAI_Select &other) -{ +SDAI_Select::SDAI_Select( const SDAI_Select & other ) { underlying_type = other.underlying_type; base_type = other.base_type; _type = other._type; @@ -44,13 +42,11 @@ SDAI_Select::SDAI_Select(const SDAI_Select &other) #endif } -SDAI_Select::~SDAI_Select() -{ +SDAI_Select::~SDAI_Select() { } -SDAI_Select &SDAI_Select::operator=(const SDAI_Select &other) -{ - if(&other != this) { +SDAI_Select & SDAI_Select::operator=( const SDAI_Select & other ) { + if( &other != this ) { _error = other._error; _type = other._type; base_type = other.base_type; @@ -60,101 +56,88 @@ SDAI_Select &SDAI_Select::operator=(const SDAI_Select &other) return *this; } -Severity SDAI_Select::severity() const -{ +Severity SDAI_Select::severity() const { return _error.severity(); } -Severity SDAI_Select::severity(Severity s) -{ - return _error.severity(s); +Severity SDAI_Select::severity( Severity s ) { + return _error.severity( s ); } -std::string SDAI_Select::Error() -{ +std::string SDAI_Select::Error() { return _error.DetailMsg(); } -void SDAI_Select::Error(const char *e) -{ - _error.DetailMsg(e); +void SDAI_Select::Error( const char * e ) { + _error.DetailMsg( e ); } -void SDAI_Select::ClearError() -{ +void SDAI_Select::ClearError() { _error.ClearErrorMsg(); } const TypeDescriptor * -SDAI_Select::CanBe(const char *n) const -{ - return _type -> CanBe(n); +SDAI_Select::CanBe( const char * n ) const { + return _type -> CanBe( n ); } const TypeDescriptor * -SDAI_Select::CanBe(BASE_TYPE bt) const -{ - const TypeDescLinkNode *tdn = - (const TypeDescLinkNode *) _type -> GetElements().GetHead(); - const TypeDescriptor *td = tdn -> TypeDesc(); +SDAI_Select::CanBe( BASE_TYPE bt ) const { + const TypeDescLinkNode * tdn = + ( const TypeDescLinkNode * ) _type -> GetElements().GetHead(); + const TypeDescriptor * td = tdn -> TypeDesc(); BASE_TYPE bt_thisnode; - while(tdn) { + while( tdn ) { td = tdn -> TypeDesc(); - if(((bt_thisnode = td -> NonRefType()) == bt) || - (bt == AGGREGATE_TYPE && ((bt_thisnode == ARRAY_TYPE) || - (bt_thisnode == LIST_TYPE) || - (bt_thisnode == SET_TYPE) || - (bt_thisnode == BAG_TYPE)))) { + if( ( ( bt_thisnode = td -> NonRefType() ) == bt ) || + ( bt == AGGREGATE_TYPE && ( ( bt_thisnode == ARRAY_TYPE ) || + ( bt_thisnode == LIST_TYPE ) || + ( bt_thisnode == SET_TYPE ) || + ( bt_thisnode == BAG_TYPE ) ) ) ) { return td; // they are the same } - tdn = (TypeDescLinkNode *)(tdn -> NextNode()); + tdn = ( TypeDescLinkNode * )( tdn -> NextNode() ); } return 0; } const TypeDescriptor * -SDAI_Select::CanBe(const TypeDescriptor *td) const -{ - return _type -> CanBe(td); +SDAI_Select::CanBe( const TypeDescriptor * td ) const { + return _type -> CanBe( td ); } const TypeDescriptor * -SDAI_Select::CanBeSet(const char *n, const char *schnm) const -{ - return _type -> CanBeSet(n, schnm); +SDAI_Select::CanBeSet( const char * n, const char * schnm ) const { + return _type -> CanBeSet( n, schnm ); } int -SDAI_Select::IsUnique(const BASE_TYPE bt) const -{ - if(bt == ARRAY_TYPE || +SDAI_Select::IsUnique( const BASE_TYPE bt ) const { + if( bt == ARRAY_TYPE || bt == LIST_TYPE || bt == BAG_TYPE || - bt == SET_TYPE) { - return ((_type->UniqueElements()) & AGGREGATE_TYPE); + bt == SET_TYPE ) { + return ( ( _type->UniqueElements() ) & AGGREGATE_TYPE ); } else { - return ((_type->UniqueElements()) & bt); + return ( ( _type->UniqueElements() ) & bt ); } } -SDAI_String SDAI_Select::UnderlyingTypeName() const -{ +SDAI_String SDAI_Select::UnderlyingTypeName() const { return underlying_type -> Name(); } -const TypeDescriptor *SDAI_Select::CurrentUnderlyingType() const -{ +const TypeDescriptor * SDAI_Select::CurrentUnderlyingType() const { return underlying_type; } const TypeDescriptor * -SDAI_Select::SetUnderlyingType(const TypeDescriptor *td) -{ +SDAI_Select::SetUnderlyingType( const TypeDescriptor * td ) { // don\'t do anything if the descriptor is bad - if(!td || !(_type -> CanBe(td))) { + if( !td || !( _type -> CanBe( td ) ) ) { return 0; } @@ -163,49 +146,45 @@ SDAI_Select::SetUnderlyingType(const TypeDescriptor *td) return underlying_type = td; } -bool SDAI_Select::exists() const -{ +bool SDAI_Select::exists() const { return underlying_type != NULL; } -void SDAI_Select::nullify() -{ +void SDAI_Select::nullify() { underlying_type = 0; } -Severity SDAI_Select::SelectValidLevel(const char *attrValue, ErrorDescriptor *err, - InstMgrBase *im) -{ - SDAI_Select *tmp = NewSelect(); +Severity SDAI_Select::SelectValidLevel( const char * attrValue, ErrorDescriptor * err, + InstMgrBase * im ) { + SDAI_Select * tmp = NewSelect(); Severity s = SEVERITY_NULL; - istringstream strtmp(attrValue); - s = tmp -> STEPread(strtmp, err, im); + istringstream strtmp( attrValue ); + s = tmp -> STEPread( strtmp, err, im ); delete tmp; return s; } -Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, - ErrorDescriptor *err, InstMgrBase *instances) -{ - severity(SEVERITY_NULL); - if(SetUnderlyingType(CanBe(selectType))) +Severity SDAI_Select::StrToVal( const char * Val, const char * selectType, + ErrorDescriptor * err, InstMgrBase * instances ) { + severity( SEVERITY_NULL ); + if( SetUnderlyingType( CanBe( selectType ) ) ) // the underlying type is set to a valid type // call read on underlying type in subclass - switch(base_type) { + switch( base_type ) { case ENTITY_TYPE: { - STEPentity *tmp = - ReadEntityRef(Val, err, ",)", instances, 0); - if(tmp && (tmp != ENTITY_NULL)) { - AssignEntity(tmp); + STEPentity * tmp = + ReadEntityRef( Val, err, ",)", instances, 0 ); + if( tmp && ( tmp != ENTITY_NULL ) ) { + AssignEntity( tmp ); return severity(); } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n"); + "Reference to entity that is not a valid type for SELECT.\n" ); nullify(); - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); return SEVERITY_WARNING; } } @@ -221,9 +200,9 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, case SELECT_TYPE: case BOOLEAN_TYPE: case LOGICAL_TYPE: { - err->GreaterSeverity(StrToVal_content(Val, instances)); - if(_error.severity() != SEVERITY_NULL) { - err->AppendFromErrorArg(&_error); + err->GreaterSeverity( StrToVal_content( Val, instances ) ); + if( _error.severity() != SEVERITY_NULL ) { + err->AppendFromErrorArg( &_error ); } return err->severity(); } @@ -234,10 +213,10 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, case REAL_TYPE: case INTEGER_TYPE: default: { - istringstream strtmp(Val); - err->GreaterSeverity(STEPread_content(strtmp)); - if(_error.severity() != SEVERITY_NULL) { - err->AppendFromErrorArg(&_error); + istringstream strtmp( Val ); + err->GreaterSeverity( STEPread_content( strtmp ) ); + if( _error.severity() != SEVERITY_NULL ) { + err->AppendFromErrorArg( &_error ); } return err->severity(); } @@ -248,10 +227,9 @@ Severity SDAI_Select::StrToVal(const char *Val, const char *selectType, /** updated to Technical Corrigendum. DAS 2/4/97 * This function does the following: */ -Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, - InstMgrBase *instances, const char *utype, - int addFileId, const char *currSch) -{ +Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err, + InstMgrBase * instances, const char * utype, + int addFileId, const char * currSch ) { char c = '\0'; std::string tmp; @@ -268,19 +246,19 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** select types, then the text is passed down to each select in the utype ** parameter as STEPread is called on each contained select type.DAS 2/4/97 */ - if(utype) { - if(SetUnderlyingType(CanBeSet(utype, currSch))) { + if( utype ) { + if( SetUnderlyingType( CanBeSet( utype, currSch ) ) ) { // assign the value to the underlying type in >> ws; // skip white space - if((underlying_type->Type() == REFERENCE_TYPE) && - (underlying_type->NonRefType() == sdaiSELECT)) { + if( ( underlying_type->Type() == REFERENCE_TYPE ) && + ( underlying_type->NonRefType() == sdaiSELECT ) ) { // See comments below for a similar code segment. - STEPread_content(in, instances, 0, addFileId, currSch); + STEPread_content( in, instances, 0, addFileId, currSch ); } else { - STEPread_content(in, instances, utype, addFileId, currSch); + STEPread_content( in, instances, utype, addFileId, currSch ); } - err->AppendToDetailMsg(Error()); - err->GreaterSeverity(severity()); + err->AppendToDetailMsg( Error() ); + err->GreaterSeverity( severity() ); } return err->severity(); } @@ -305,11 +283,11 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** will cause the contained Select STEPread function to read it. DAS 2/4/97 */ - if(isalpha(c)) { // case B + if( isalpha( c ) ) { // case B int eot = 0; // end of token flag // token is a type name - get the type - while((c != '(') && in.good()) { - if(!eot && !(eot = isspace(c))) + while( ( c != '(' ) && in.good() ) { + if( !eot && !( eot = isspace( c ) ) ) // as long as eot hasn\'t been reached keep appending { tmp += c; @@ -318,7 +296,7 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, } // check for valid type and set the underlying type - if(SetUnderlyingType(CanBeSet(tmp.c_str(), currSch))) { + if( SetUnderlyingType( CanBeSet( tmp.c_str(), currSch ) ) ) { /** ** Assign the value to the underlying type. CanBeSet() is a ** slightly modified CanBe(). It ensures that a renamed select @@ -329,8 +307,8 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** case if "selX" appears first and is what we just read. */ in >> ws; // skip white space - if((underlying_type->Type() == REFERENCE_TYPE) && - (underlying_type->NonRefType() == sdaiSELECT)) { + if( ( underlying_type->Type() == REFERENCE_TYPE ) && + ( underlying_type->NonRefType() == sdaiSELECT ) ) { /** * This means (1) that the underlying type is itself a select ** (cond 2), and (2) it's not defined in the EXPRESS as a @@ -345,7 +323,7 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** would appear (according to TC) and we already read the value ** of sel1. If so, we pass the already-read value down. */ - STEPread_content(in, instances, 0, addFileId, currSch); + STEPread_content( in, instances, 0, addFileId, currSch ); } else { /** ** In most cases (see above note), we've already read the value @@ -353,19 +331,19 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, ** This also handles all other cases? other than the if part ** above and elements of type entity ref? */ - STEPread_content(in, instances, tmp.c_str(), addFileId, - currSch); + STEPread_content( in, instances, tmp.c_str(), addFileId, + currSch ); // STEPread_content uses the ErrorDesc data member from the // SDAI_Select class } - err->AppendToDetailMsg(Error()); - err->GreaterSeverity(severity()); + err->AppendToDetailMsg( Error() ); + err->GreaterSeverity( severity() ); in >> ws >> c; - if(c != ')') { + if( c != ')' ) { err->AppendToDetailMsg( - "Bad data or missing closing ')' for SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); - in.putback(c); + "Bad data or missing closing ')' for SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); + in.putback( c ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -376,16 +354,16 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, #endif return err->severity(); } else { // ERROR -- the type wasn't one of the choices - if(!in.good()) { - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + if( !in.good() ) { + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_INPUT_ERROR; } else { err->AppendToDetailMsg( - "The type name for the SELECT type is not valid.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + "The type name for the SELECT type is not valid.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -402,10 +380,10 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, */ else { /// case A - switch(c) { + switch( c ) { case '$': nullify(); - err->GreaterSeverity(SEVERITY_INCOMPLETE); + err->GreaterSeverity( SEVERITY_INCOMPLETE ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -414,9 +392,9 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case ',': case '\0': // ERROR IN INPUT - in.putback(c); - err->AppendToDetailMsg("No value found for SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + in.putback( c ); + err->AppendToDetailMsg( "No value found for SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -424,44 +402,44 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case '.': // assign enum base_type = ENUM_TYPE; - err->AppendToDetailMsg("Invalid Enumeration, Logical, or Boolean value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid Enumeration, Logical, or Boolean value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; - // set the underlying type - // call STEPread - // return + // set the underlying type + // call STEPread + // return case '\'': // assign string base_type = STRING_TYPE; - err->AppendToDetailMsg("Invalid String value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid String value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; case '"': // assign string base_type = BINARY_TYPE; - err->AppendToDetailMsg("Invalid Binary value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid Binary value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); break; case '#': base_type = ENTITY_TYPE; break; - // call STEPread_reference - // set the underlying type + // call STEPread_reference + // set the underlying type - // assign entity - // read the reference - // match type to underlying type - // assign the value - // set the underlying type + // assign entity + // read the reference + // match type to underlying type + // assign the value + // set the underlying type case '(': { - err->AppendToDetailMsg("Invalid aggregate value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToDetailMsg( "Invalid aggregate value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); char n; in >> n; - in.putback(n); - if(isalpha(n)) { + in.putback( n ); + if( isalpha( n ) ) { base_type = SELECT_TYPE; } else { base_type = AGGREGATE_TYPE; @@ -480,9 +458,9 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, case '8': case '9': case '-': - err->AppendToDetailMsg("Invalid Integer or Real value in SELECT type.\n"); - err->GreaterSeverity(SEVERITY_WARNING); - if(CanBe(REAL_TYPE)) { + err->AppendToDetailMsg( "Invalid Integer or Real value in SELECT type.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); + if( CanBe( REAL_TYPE ) ) { base_type = REAL_TYPE; } else { base_type = INTEGER_TYPE; @@ -492,54 +470,54 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, default: // ambiguous - ERROR: underlying type should have been set err->AppendToDetailMsg( - "type for SELECT could not be determined from value.\n"); + "type for SELECT could not be determined from value.\n" ); nullify(); - in.putback(c); - err->GreaterSeverity(SEVERITY_WARNING); + in.putback( c ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - in.putback(c); + in.putback( c ); // now the type descriptor should be derivable from the base_type // if it's not issue a warning - if(_type && !(IsUnique(base_type))) { - err->AppendToDetailMsg("Value for SELECT will be assigned to first possible choice.\n"); - err->GreaterSeverity(SEVERITY_USERMSG); + if( _type && !( IsUnique( base_type ) ) ) { + err->AppendToDetailMsg( "Value for SELECT will be assigned to first possible choice.\n" ); + err->GreaterSeverity( SEVERITY_USERMSG ); } - if(base_type == ENTITY_TYPE) { + if( base_type == ENTITY_TYPE ) { // you don't know if this is an ENTITY or a SELECT // have to do this here - not in STEPread_content - STEPentity *temp = - ReadEntityRef(in, err, ",)", instances, addFileId); - if(temp && (temp != ENTITY_NULL) && AssignEntity(temp)) { + STEPentity * temp = + ReadEntityRef( in, err, ",)", instances, addFileId ); + if( temp && ( temp != ENTITY_NULL ) && AssignEntity( temp ) ) { #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_NULL; } else { err->AppendToDetailMsg( - "Reference to entity that is not a valid type for SELECT.\n"); + "Reference to entity that is not a valid type for SELECT.\n" ); nullify(); - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif return SEVERITY_WARNING; } - } else if(SetUnderlyingType(CanBe(base_type))) { - STEPread_content(in, instances, 0, addFileId); + } else if( SetUnderlyingType( CanBe( base_type ) ) ) { + STEPread_content( in, instances, 0, addFileId ); } else { // ERROR -- the type wasn't one of the choices err->AppendToDetailMsg( - "The type of the SELECT type is not valid.\n"); - err->GreaterSeverity(SEVERITY_WARNING); + "The type of the SELECT type is not valid.\n" ); + err->GreaterSeverity( SEVERITY_WARNING ); #ifdef SC_LOGGING // *logStream << "DAVE ERR Exiting SDAI_Select::STEPread for " << _type->Name() << endl; #endif @@ -555,25 +533,24 @@ Severity SDAI_Select::STEPread(istream &in, ErrorDescriptor *err, /// updated to Technical Corrigendum DAS Feb 4, 1997 -void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const -{ - if(!exists()) { +void SDAI_Select::STEPwrite( ostream & out, const char * currSch ) const { + if( !exists() ) { out << "$"; return; } - switch(underlying_type->NonRefType()) { + switch( underlying_type->NonRefType() ) { case sdaiINSTANCE: { - STEPwrite_content(out); + STEPwrite_content( out ); break; } case sdaiSELECT: { // The name of a select is never written DAS 1/31/97 - if(underlying_type->Type() == REFERENCE_TYPE) { + if( underlying_type->Type() == REFERENCE_TYPE ) { std::string s; - out << StrToUpper(underlying_type->Name(currSch), s) << "("; - STEPwrite_content(out, currSch); + out << StrToUpper( underlying_type->Name( currSch ), s ) << "("; + STEPwrite_content( out, currSch ); out << ")"; } else { - STEPwrite_content(out, currSch); + STEPwrite_content( out, currSch ); } break; } @@ -590,7 +567,7 @@ void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const case BAG_TYPE: case SET_TYPE: case LIST_TYPE: { - STEPwrite_verbose(out, currSch); + STEPwrite_verbose( out, currSch ); break; } case REFERENCE_TYPE: // this should never happen? DAS @@ -600,30 +577,26 @@ void SDAI_Select::STEPwrite(ostream &out, const char *currSch) const } } -void SDAI_Select::STEPwrite_verbose(ostream &out, const char *currSch) const -{ +void SDAI_Select::STEPwrite_verbose( ostream & out, const char * currSch ) const { std::string tmp; - out << StrToUpper(CurrentUnderlyingType()->Name(currSch), tmp) << "("; - STEPwrite_content(out); + out << StrToUpper( CurrentUnderlyingType()->Name( currSch ), tmp ) << "("; + STEPwrite_content( out ); out << ")"; } -const char *SDAI_Select::STEPwrite(std::string &s, const char *currSch) const -{ +const char * SDAI_Select::STEPwrite( std::string & s, const char * currSch ) const { ostringstream buf; - STEPwrite(buf, currSch); + STEPwrite( buf, currSch ); buf << ends; // add the terminating \0 char s = buf.str(); - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -bool SDAI_Select::set_null() -{ +bool SDAI_Select::set_null() { nullify(); return true; } -bool SDAI_Select::is_null() -{ - return (!exists()); +bool SDAI_Select::is_null() { + return ( !exists() ); } diff --git a/src/clstepcore/sdaiSelect.h b/src/clstepcore/sdaiSelect.h index c0c50ed42..04307b1f4 100644 --- a/src/clstepcore/sdaiSelect.h +++ b/src/clstepcore/sdaiSelect.h @@ -17,33 +17,32 @@ /** ** \file sdaiSelect.h class definition for the select superclass SDAI_Select. **/ -class SC_CORE_EXPORT SDAI_Select -{ +class SC_CORE_EXPORT SDAI_Select { protected: - const SelectTypeDescriptor *_type; - const TypeDescriptor *underlying_type; + const SelectTypeDescriptor * _type; + const TypeDescriptor * underlying_type; BASE_TYPE base_type; // used by the subtypes // it looks like this member, val, is not used anywhere 9/27/96 - DAS SDAI_String val; ErrorDescriptor _error; - const TypeDescriptor *SetUnderlyingType(const TypeDescriptor *); + const TypeDescriptor * SetUnderlyingType( const TypeDescriptor * ); - const TypeDescriptor *CanBe(const char *) const; - const TypeDescriptor *CanBe(BASE_TYPE) const; - const TypeDescriptor *CanBe(const TypeDescriptor *td) const; - const TypeDescriptor *CanBeSet(const char *, const char *) const; + const TypeDescriptor * CanBe( const char * ) const; + const TypeDescriptor * CanBe( BASE_TYPE ) const; + const TypeDescriptor * CanBe( const TypeDescriptor * td ) const; + const TypeDescriptor * CanBeSet( const char *, const char * ) const; - int IsUnique(const BASE_TYPE bt) const; + int IsUnique( const BASE_TYPE bt ) const; - virtual const TypeDescriptor *AssignEntity(SDAI_Application_instance *se) = 0; - virtual SDAI_Select *NewSelect() = 0; + virtual const TypeDescriptor * AssignEntity( SDAI_Application_instance * se ) = 0; + virtual SDAI_Select * NewSelect() = 0; public: Severity severity() const; - Severity severity(Severity); + Severity severity( Severity ); std::string Error(); - void Error(const char *); + void Error( const char * ); // clears select's error void ClearError(); // clears error @@ -51,50 +50,50 @@ class SC_CORE_EXPORT SDAI_Select virtual BASE_TYPE ValueType() const = 0; // constructors - SDAI_Select(const SelectTypeDescriptor *s = 0, - const TypeDescriptor *td = 0); - SDAI_Select(const SDAI_Select &other); + SDAI_Select( const SelectTypeDescriptor * s = 0, + const TypeDescriptor * td = 0 ); + SDAI_Select( const SDAI_Select & other ); virtual ~SDAI_Select(); // from SDAI binding SDAI_String UnderlyingTypeName() const; - const TypeDescriptor *CurrentUnderlyingType() const; + const TypeDescriptor * CurrentUnderlyingType() const; bool exists() const; void nullify(); - Severity SelectValidLevel(const char *attrValue, ErrorDescriptor *err, - InstMgrBase *im); + Severity SelectValidLevel( const char * attrValue, ErrorDescriptor * err, + InstMgrBase * im ); // reading and writing - const char *STEPwrite(std::string &s, const char *currSch = 0) const; - void STEPwrite(ostream &out = cout, const char *currSch = 0) const; + const char * STEPwrite( std::string & s, const char * currSch = 0 ) const; + void STEPwrite( ostream & out = cout, const char * currSch = 0 ) const; // IMS 8/2/95: added as part of new select implementation - virtual void STEPwrite_verbose(ostream &out = cout, const char * = 0) + virtual void STEPwrite_verbose( ostream & out = cout, const char * = 0 ) const; - virtual void STEPwrite_content(ostream &out, const char * = 0) const = 0; + virtual void STEPwrite_content( ostream & out, const char * = 0 ) const = 0; - Severity StrToVal(const char *val, const char *selectType, - ErrorDescriptor *err, InstMgrBase *instances = 0); - virtual Severity StrToVal_content(const char *, - InstMgrBase *instances = 0) = 0; + Severity StrToVal( const char * val, const char * selectType, + ErrorDescriptor * err, InstMgrBase * instances = 0 ); + virtual Severity StrToVal_content( const char *, + InstMgrBase * instances = 0 ) = 0; - Severity STEPread(istream &in, ErrorDescriptor *err, - InstMgrBase *instances = 0, const char *utype = 0, - int addFileId = 0, const char * = NULL); + Severity STEPread( istream & in, ErrorDescriptor * err, + InstMgrBase * instances = 0, const char * utype = 0, + int addFileId = 0, const char * = NULL ); // abstract function - virtual Severity STEPread_content(istream &in = cin, - InstMgrBase *instances = 0, - const char *utype = 0, - int addFileId = 0, - const char *currSch = 0) = 0; + virtual Severity STEPread_content( istream & in = cin, + InstMgrBase * instances = 0, + const char * utype = 0, + int addFileId = 0, + const char * currSch = 0 ) = 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); + virtual SDAI_Select & operator =( const SDAI_Select & other ); //FIXME set_null always returns true. why not void?! bool set_null(); @@ -102,7 +101,7 @@ class SC_CORE_EXPORT SDAI_Select }; /** end class **/ -typedef SDAI_Select *SDAI_Select_ptr; +typedef SDAI_Select * SDAI_Select_ptr; typedef SDAI_Select_ptr SDAI_Select_var; #endif diff --git a/src/clstepcore/selectTypeDescriptor.cc b/src/clstepcore/selectTypeDescriptor.cc index f4c9d1f6d..a7c0ad032 100644 --- a/src/clstepcore/selectTypeDescriptor.cc +++ b/src/clstepcore/selectTypeDescriptor.cc @@ -4,18 +4,16 @@ // SelectTypeDescriptor functions /////////////////////////////////////////////////////////////////////////////// -SDAI_Select *SelectTypeDescriptor::CreateSelect() -{ - if(CreateNewSelect) { +SDAI_Select * SelectTypeDescriptor::CreateSelect() { + if( CreateNewSelect ) { return CreateNewSelect(); } else { return 0; } } -const TypeDescriptor *SelectTypeDescriptor::IsA(const TypeDescriptor *other) const -{ - return TypeDescriptor::IsA(other); +const TypeDescriptor * SelectTypeDescriptor::IsA( const TypeDescriptor * other ) const { + return TypeDescriptor::IsA( other ); } /** @@ -23,16 +21,15 @@ const TypeDescriptor *SelectTypeDescriptor::IsA(const TypeDescriptor *other) con * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor *SelectTypeDescriptor::CanBe(const TypeDescriptor *other) const -{ - if(this == other) { +const TypeDescriptor * SelectTypeDescriptor::CanBe( const TypeDescriptor * other ) const { + if( this == other ) { return other; } - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = elements.NextTypeDesc(); - while(td) { - if(td -> CanBe(other)) { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = elements.NextTypeDesc(); + while( td ) { + if( td -> CanBe( other ) ) { return td; } td = elements.NextTypeDesc(); @@ -45,19 +42,18 @@ const TypeDescriptor *SelectTypeDescriptor::CanBe(const TypeDescriptor *other) c * type but only at this unexpanded level. The td ultimately describing the * type may be an element of a td for a select that is returned. */ -const TypeDescriptor *SelectTypeDescriptor::CanBe(const char *other) const -{ - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = 0; +const TypeDescriptor * SelectTypeDescriptor::CanBe( const char * other ) const { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = 0; // see if other is the select - if(!StrCmpIns(_name, other)) { + if( !StrCmpIns( _name, other ) ) { return this; } // see if other is one of the elements - while((td = elements.NextTypeDesc())) { - if(td -> CanBe(other)) { + while( ( td = elements.NextTypeDesc() ) ) { + if( td -> CanBe( other ) ) { return td; } } @@ -83,18 +79,17 @@ const TypeDescriptor *SelectTypeDescriptor::CanBe(const char *other) const * if schNm = a schema which USEs or REFERENCEs this and renames it (e.g., "USE * from XX (A as B)"). */ -const TypeDescriptor *SelectTypeDescriptor::CanBeSet(const char *other, const char *schNm) const -{ - TypeDescItr elements(GetElements()) ; - const TypeDescriptor *td = elements.NextTypeDesc(); +const TypeDescriptor * SelectTypeDescriptor::CanBeSet( const char * other, const char * schNm ) const { + TypeDescItr elements( GetElements() ) ; + const TypeDescriptor * td = elements.NextTypeDesc(); - while(td) { - if(td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT) { + while( td ) { + if( td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT ) { // Just look at this level, don't look at my items (see intro). - if(td->CurrName(other, schNm)) { + if( td->CurrName( other, schNm ) ) { return td; } - } else if(td->CanBeSet(other, schNm)) { + } else if( td->CanBeSet( other, schNm ) ) { return td; } td = elements.NextTypeDesc(); diff --git a/src/clstepcore/selectTypeDescriptor.h b/src/clstepcore/selectTypeDescriptor.h index bb491ca6d..8dbfd1b19 100644 --- a/src/clstepcore/selectTypeDescriptor.h +++ b/src/clstepcore/selectTypeDescriptor.h @@ -3,55 +3,49 @@ #include "typeDescriptor.h" -typedef SDAI_Select *(* SelectCreator)(); - -class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor -{ - - protected: - TypeDescriptorList _elements; // of TYPE_DESCRIPTOR - int _unique_elements; - - public: - - SelectCreator CreateNewSelect; - - void AssignSelectCreator(SelectCreator f = 0) - { - CreateNewSelect = f; - } - - SDAI_Select *CreateSelect(); - - SelectTypeDescriptor(int b, const char *nm, PrimitiveType ft, - Schema *origSchema, - const char *d, SelectCreator f = 0) - : TypeDescriptor(nm, ft, origSchema, d), - _unique_elements(b), CreateNewSelect(f) - { } - virtual ~SelectTypeDescriptor() { } - - TypeDescriptorList &Elements() - { - return _elements; - } - const TypeDescriptorList &GetElements() const - { - return _elements; - } - int UniqueElements() const - { - return _unique_elements; - } - virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; - virtual const TypeDescriptor *IsA(const char *n) const - { - return TypeDescriptor::IsA(n); - } - virtual const TypeDescriptor *CanBe(const TypeDescriptor *) const; - virtual const TypeDescriptor *CanBe(const char *n) const; - virtual const TypeDescriptor *CanBeSet(const char *, const char *) - const; +typedef SDAI_Select * ( * SelectCreator )(); + +class SC_CORE_EXPORT SelectTypeDescriptor : public TypeDescriptor { + +protected: + TypeDescriptorList _elements; // of TYPE_DESCRIPTOR + int _unique_elements; + +public: + + SelectCreator CreateNewSelect; + + void AssignSelectCreator( SelectCreator f = 0 ) { + CreateNewSelect = f; + } + + SDAI_Select * CreateSelect(); + + SelectTypeDescriptor( int b, const char * nm, PrimitiveType ft, + Schema * origSchema, + const char * d, SelectCreator f = 0 ) + : TypeDescriptor( nm, ft, origSchema, d ), + _unique_elements( b ), CreateNewSelect( f ) + { } + virtual ~SelectTypeDescriptor() { } + + TypeDescriptorList & Elements() { + return _elements; + } + const TypeDescriptorList & GetElements() const { + return _elements; + } + int UniqueElements() const { + return _unique_elements; + } + virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; + virtual const TypeDescriptor * IsA( const char * n ) const { + return TypeDescriptor::IsA( n ); + } + virtual const TypeDescriptor * CanBe( const TypeDescriptor * ) const; + virtual const TypeDescriptor * CanBe( const char * n ) const; + virtual const TypeDescriptor * CanBeSet( const char *, const char * ) + const; }; #endif //SELECTTYPEDESCRIPTOR_H diff --git a/src/clstepcore/stringTypeDescriptor.h b/src/clstepcore/stringTypeDescriptor.h index aff628617..b328dafaa 100644 --- a/src/clstepcore/stringTypeDescriptor.h +++ b/src/clstepcore/stringTypeDescriptor.h @@ -3,42 +3,35 @@ #include "typeDescriptor.h" -class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor -{ - - protected: - SDAI_Integer _width; // OPTIONAL - SDAI_LOGICAL _fixedSize; - public: - - StringTypeDescriptor() : _fixedSize("UNKNOWN_TYPE") - { - _width = 0; - } - virtual ~StringTypeDescriptor() { } - - - SDAI_Integer Width() - { - return _width; - } - void Width(SDAI_Integer w) - { - _width = w; - } - - SDAI_LOGICAL &FixedSize() - { - return _fixedSize; - } - void FixedSize(SDAI_LOGICAL fs) - { - _fixedSize.put(fs.asInt()); - } - void FixedSize(Logical fs) - { - _fixedSize.put(fs); - } +class SC_CORE_EXPORT StringTypeDescriptor : public TypeDescriptor { + +protected: + SDAI_Integer _width; // OPTIONAL + SDAI_LOGICAL _fixedSize; +public: + + StringTypeDescriptor( ) : _fixedSize( "UNKNOWN_TYPE" ) { + _width = 0; + } + virtual ~StringTypeDescriptor() { } + + + SDAI_Integer Width() { + return _width; + } + void Width( SDAI_Integer w ) { + _width = w; + } + + SDAI_LOGICAL & FixedSize() { + return _fixedSize; + } + void FixedSize( SDAI_LOGICAL fs ) { + _fixedSize.put( fs.asInt() ); + } + void FixedSize( Logical fs ) { + _fixedSize.put( fs ); + } }; #endif //STRINGTYPEDESCRIPTOR_H diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index 9270ad3a0..bfe73dc17 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -10,70 +10,63 @@ * * 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(); +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; } - 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(); - } + 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; - } + } + ~superInvAttrIter() { + if( invIter ) { + delete invIter; + invIter = 0; } - const EntityDescriptor *currentEDesc() - { - if(isempty) { - return NULL; - } - return sit.current(); + } + const EntityDescriptor * currentEDesc() { + if( isempty ) { + return NULL; } - bool empty() - { - if(isempty) { - return true; - } - return (!sit.hasNext() && !nextInv); + return sit.current(); + } + bool empty() { + if( isempty ) { + return true; } - 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; + 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 diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index f9f353e26..1de017638 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #c++ tests for clstepcore include_directories( diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index f06028309..f557d7c72 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -8,77 +8,76 @@ #include "ExpDict.h" #include -int main(int /*argc*/, char ** /*argv*/) -{ - Schema *a = 0; - Logical b(LFalse); +int main( int /*argc*/, char ** /*argv*/ ) { + Schema * a = 0; + Logical b( LFalse ); char buf[20][2] = { { '\0' } }; int i, d; - EntityDescriptor *descriptors[20], ed("ed", a, b, b); + EntityDescriptor * descriptors[20], ed( "ed", a, b, b ); bool failed = false; //create 20 more ed's - for(i = 0; i < 20; i++) { + for( i = 0; i < 20; i++ ) { buf[i][0] = 'a' + i; //ed names are 1st 20 lowercase chars - descriptors[i] = new EntityDescriptor(buf[i], a, b, b); + descriptors[i] = new EntityDescriptor( buf[i], a, b, b ); } //link the ed's together - ed.AddSupertype(descriptors[0]); - for(i = 0; i < 10; i++) { - descriptors[i]->AddSupertype(descriptors[i + 1]); + ed.AddSupertype( descriptors[0] ); + for( i = 0; i < 10; i++ ) { + descriptors[i]->AddSupertype( descriptors[i + 1] ); } - for(i = 11; i < 20; i++) { - descriptors[5]->AddSupertype(descriptors[i]); + for( i = 11; i < 20; i++ ) { + descriptors[5]->AddSupertype( descriptors[i] ); } //print the ed's i = 0; d = 0; std::cout << "head, name " << ed.Name() << std::endl; - supertypesIterator iter(&ed); - for(; !iter.empty(); iter++) { - if(!iter.hasNext()) { //hasNext should be false once and once only + supertypesIterator iter( &ed ); + for( ; !iter.empty(); iter++ ) { + if( !iter.hasNext() ) { //hasNext should be false once and once only i++; } - if(iter.depth() > d) { + if( iter.depth() > d ) { d = iter.depth(); } - std::cout << "position " << std::setw(3) << iter.pos() << ", name " << std::setw(iter.depth()) << iter->Name() << std::endl; + std::cout << "position " << std::setw( 3 ) << iter.pos() << ", name " << std::setw( iter.depth() ) << iter->Name() << std::endl; } - if(iter.pos() == 20) { + if( iter.pos() == 20 ) { std::cout << "success" << std::endl; } else { std::cout << "expected 20, got " << iter.pos() << std::endl; failed = true; } - if(i != 1) { + if( i != 1 ) { std::cout << "problem with hasNext(): expected 1, got " << i << std::endl; failed = true; } - if(d != 11) { + if( d != 11 ) { std::cout << "problem with depth(): expected 11, got " << d << std::endl; failed = true; } - supertypesIterator it2(&ed), it3, uninitializedIter; + supertypesIterator it2( &ed ), it3, uninitializedIter; it3 = it2; //test operator==, operator!= - if((it2 == iter) || (it2 == uninitializedIter)) { + if( ( it2 == iter ) || ( it2 == uninitializedIter ) ) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 1st" << std::endl; } - if(!(it2 == it3)) { + if( !( it2 == it3 ) ) { std::cout << "problem with operator== at " << __LINE__ << std::endl; failed = true; } else { std::cout << "operator== passed 2nd" << std::endl; } - if(!(it2 != iter)) { + if( !( it2 != iter ) ) { std::cout << "problem with operator!=" << std::endl; failed = true; } else { @@ -89,19 +88,19 @@ int main(int /*argc*/, char ** /*argv*/) ++it3; // operator> - if((it3 > it2) != LTrue) { + if( ( it3 > it2 ) != LTrue ) { std::cout << "problem with operator>, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator> passed LTrue" << std::endl; } - if((uninitializedIter > it2) != LUnknown) { + if( ( uninitializedIter > it2 ) != LUnknown ) { std::cout << "problem with operator>, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator> passed LUnknown" << std::endl; } - if((it2 > it2) != LFalse) { + if( ( it2 > it2 ) != LFalse ) { std::cout << "problem with operator>, expected LFalse" << std::endl; failed = true; } else { @@ -109,19 +108,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator< - if((it2 < it3) != LTrue) { + if( ( it2 < it3 ) != LTrue ) { std::cout << "problem with operator<, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator< passed LTrue" << std::endl; } - if((it2 < uninitializedIter) != LUnknown) { + if( ( it2 < uninitializedIter ) != LUnknown ) { std::cout << "problem with operator<, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator< passed LUnknown" << std::endl; } - if((it2 < it2) != LFalse) { + if( ( it2 < it2 ) != LFalse ) { std::cout << "problem with operator<, expected LFalse" << std::endl; failed = true; } else { @@ -129,19 +128,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator<= - if((it2 <= it2) != LTrue) { + if( ( it2 <= it2 ) != LTrue ) { std::cout << "problem with operator<=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator<= passed LTrue" << std::endl; } - if((it2 <= uninitializedIter) != LUnknown) { + if( ( it2 <= uninitializedIter ) != LUnknown ) { std::cout << "problem with operator<=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator<= passed LUnknown" << std::endl; } - if((it3 <= it2) != LFalse) { + if( ( it3 <= it2 ) != LFalse ) { std::cout << "problem with operator<=, expected LFalse" << std::endl; failed = true; } else { @@ -149,19 +148,19 @@ int main(int /*argc*/, char ** /*argv*/) } // operator>= - if((it2 >= it2) != LTrue) { + if( ( it2 >= it2 ) != LTrue ) { std::cout << "problem with operator>=, expected LTrue" << std::endl; failed = true; } else { std::cout << "operator>= passed LTrue" << std::endl; } - if((it2 >= uninitializedIter) != LUnknown) { + if( ( it2 >= uninitializedIter ) != LUnknown ) { std::cout << "problem with operator>=, expected LUnknown" << std::endl; failed = true; } else { std::cout << "operator>= passed LUnknown" << std::endl; } - if((it2 >= it3) != LFalse) { + if( ( it2 >= it3 ) != LFalse ) { std::cout << "problem with operator>=, expected LFalse" << std::endl; failed = true; } else { @@ -170,19 +169,19 @@ int main(int /*argc*/, char ** /*argv*/) /// still need operator* >= it3.reset(); - const EntityDescriptor *e = *it3; - const char *n = "a"; - if(strcmp(e->Name(), n)) { + const EntityDescriptor * e = *it3; + const char * n = "a"; + if( strcmp( e->Name(), n ) ) { std::cout << "problem with operator*" << std::endl; failed = true; } else { std::cout << "operator* passed " << std::endl; } - if(failed) { - exit(EXIT_FAILURE); + if( failed ) { + exit( EXIT_FAILURE ); } else { - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } } /* output: diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index 0cd86b654..0c96c5798 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -7,14 +7,13 @@ EntityDescriptor *ed = 0; TypeDescriptor *td; Schema *sch = 0; -int main() -{ +int main () { SDAI_String _description; - sch = new Schema("Ifc2x3"); - td = new TypeDescriptor("Ifctext", sdaiSTRING, sch, "STRING"); - ed = new EntityDescriptor("Ifcroot", sch, LTrue, LFalse); - ad = new AttrDescriptor("description", td, LTrue, LFalse, AttrType_Explicit, *ed); - ed->AddExplicitAttr(ad); + sch = new Schema( "Ifc2x3" ); + td = new TypeDescriptor( "Ifctext", sdaiSTRING, sch, "STRING" ); + ed = new EntityDescriptor( "Ifcroot", sch, LTrue, LFalse ); + ad = new AttrDescriptor( "description", td, LTrue, LFalse, AttrType_Explicit, *ed ); + ed->AddExplicitAttr( ad ); STEPattribute *a = new STEPattribute(*ad, &_description); a -> set_null(); delete a; diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index e65969097..fcb6cde4d 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -12,82 +12,58 @@ using namespace std; -class TestSdaiSelect: public SDAI_Select -{ +class TestSdaiSelect: public SDAI_Select { public: - TestSdaiSelect(SelectTypeDescriptor *s, TypeDescriptor *t, BASE_TYPE b, SDAI_String v, ErrorDescriptor e): - SDAI_Select(s, t) - { + 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); + TestSdaiSelect & operator=( const TestSdaiSelect & other ) { + SDAI_Select::operator=( other ); return *this; } - SDAI_Select &operator=(const SDAI_Select &other) - { - SDAI_Select::operator=(other); + 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 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()); + 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; + 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"); +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); + 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)) { + if( s2.compare( &s, &t, b, &v, &e ) ) { return true; } else { cerr << __FILE__ << ":" << __LINE__ << " - error: test for SDAI_Select::operator= failed" << endl; @@ -95,15 +71,14 @@ bool testOperatorEq() } } -int main(int /*argc*/, char ** /*argv*/) -{ +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); + if( pass ) { + exit( EXIT_SUCCESS ); } else { - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index 8d2fba7ab..abd396816 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -6,25 +6,24 @@ /// test copying a STEPattribute; returns true on success -bool testCopy(STEPattribute &attr, const char *desc) -{ +bool testCopy( STEPattribute & attr, const char * desc ) { bool pass = true; STEPattribute b = attr; STEPattribute c; - if(!(attr == attr)) { + if( !( attr == attr ) ) { std::cerr << "test class initialization failed " << desc << std::endl; pass = false; } - if(!(attr == b)) { + if( !( attr == b ) ) { std::cerr << "assignment operator failed " << desc << std::endl; pass = false; } - c.ShallowCopy(& attr); - if(!(attr == c)) { + c.ShallowCopy( & attr ); + if( !( attr == c ) ) { std::cerr << "ShallowCopy() failed " << desc << std::endl; pass = false; } @@ -32,45 +31,43 @@ bool testCopy(STEPattribute &attr, const char *desc) return pass; } -bool testEqu(const STEPattribute &a1, const STEPattribute &a2, bool invert, const char *desc) -{ - bool pass = (invert ? (!(a1 == a2)) : (a1 == a2)); - if(!pass) { +bool testEqu( const STEPattribute & a1, const STEPattribute & a2, bool invert, const char * desc ) { + bool pass = ( invert ? ( !( a1 == a2 ) ) : ( a1 == a2 ) ); + if( !pass ) { std::cerr << "Comparison test " << desc << " failed." << std::endl; } return pass; } -int main(int /*argc*/, char ** /*argv*/) -{ +int main( int /*argc*/, char ** /*argv*/ ) { bool pass = true; - EntityDescriptor ed("ename", 0, LFalse, LFalse); + EntityDescriptor ed( "ename", 0, LFalse, LFalse ); // used to test copying without operator new - TypeDescriptor tdi("tint", sdaiINTEGER, 0, "int"); - AttrDescriptor adi("aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed); + TypeDescriptor tdi( "tint", sdaiINTEGER, 0, "int" ); + AttrDescriptor adi( "aint", & tdi, LFalse, LFalse, AttrType_Explicit, ed ); SDAI_Integer sint = 1234L, s2int = 123L; - STEPattribute ai(adi, & sint); + STEPattribute ai( adi, & sint ); //test copying with operator new (SDAI_Logical requires new) - TypeDescriptor tdl("tlog", sdaiLOGICAL, 0, "str"); - AttrDescriptor adl("alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed); - SDAI_LOGICAL slog(LTrue); - STEPattribute al(adl, & slog); + TypeDescriptor tdl( "tlog", sdaiLOGICAL, 0, "str" ); + AttrDescriptor adl( "alog", & tdl, LFalse, LFalse, AttrType_Explicit, ed ); + SDAI_LOGICAL slog( LTrue ); + STEPattribute al( adl, & slog ); - pass &= testCopy(ai, "without operator new"); - pass &= testCopy(al, "with operator new"); + pass &= testCopy( ai, "without operator new" ); + pass &= testCopy( al, "with operator new" ); - pass &= testEqu(al, al, false, "LOGICAL =="); - pass &= testEqu(ai, ai, false, "int =="); - pass &= testEqu(ai, al, true, "int != LOGICAL"); + pass &= testEqu( al, al, false, "LOGICAL ==" ); + pass &= testEqu( ai, ai, false, "int ==" ); + pass &= testEqu( ai, al, true, "int != LOGICAL" ); - STEPattribute aii(adi, & s2int); - pass &= testEqu(ai, aii, true, "ints !="); + STEPattribute aii( adi, & s2int ); + pass &= testEqu( ai, aii, true, "ints !=" ); - if(pass) { - exit(EXIT_SUCCESS); + if( pass ) { + exit( EXIT_SUCCESS ); } - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 24a5a3516..145af7699 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -15,8 +15,8 @@ #include "sc_memmgr.h" // Local function prototypes: -static EntList *firstCandidate(EntList *); -static EntList *nextCandidate(EntList *); +static EntList * firstCandidate( EntList * ); +static EntList * nextCandidate( EntList * ); /** * Loops backwards through the children of this, recursively searching for @@ -28,18 +28,17 @@ static EntList *nextCandidate(EntList *); * (reasons discussed in notes, 10/17). This function is the tryNext() * for AND and ANDOR; the OR version is redefined. */ -MatchType MultList::tryNext(EntNode *ents) -{ +MatchType MultList::tryNext( EntNode * ents ) { MatchType retval; - EntList *child = getLast(); + EntList * child = getLast(); - child = firstCandidate(child); - while(child != NULL) { - if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { + child = firstCandidate( child ); + while( child != NULL ) { + if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { // We're done - a good solution was found. return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -47,14 +46,14 @@ MatchType MultList::tryNext(EntNode *ents) // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while((child = nextCandidate(child)) != NULL) { - if(child->acceptChoice(ents) && ents->allMarked()) { + while( ( child = nextCandidate( child ) ) != NULL ) { + if( child->acceptChoice( ents ) && ents->allMarked() ) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate(child->prev); + child = firstCandidate( child->prev ); } // If we got here, we didn't find any new OR choices: return NOMORE; @@ -65,18 +64,17 @@ MatchType MultList::tryNext(EntNode *ents) * choices below it. The acceptable choices are described in commenting * below. */ -static EntList *firstCandidate(EntList *child) -{ - EntList *ent = child->lastNot(SIMPLE); +static EntList * firstCandidate( EntList * child ) { + EntList * ent = child->lastNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot(SIMPLE); + ent = ent->prevNot( SIMPLE ); } return ent; } @@ -84,15 +82,14 @@ static EntList *firstCandidate(EntList *child) /** * Same as prev function, searches forwards from ent after child. */ -static EntList *nextCandidate(EntList *child) -{ - EntList *ent = child->nextNot(SIMPLE); +static EntList * nextCandidate( EntList * child ) { + EntList * ent = child->nextNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { return ent; } - ent = ent->nextNot(SIMPLE); + ent = ent->nextNot( SIMPLE ); } return ent; } @@ -102,28 +99,27 @@ static EntList *nextCandidate(EntList *child) * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ -MatchType OrList::tryNext(EntNode *ents) -{ - EntList *child; +MatchType OrList::tryNext( EntNode * ents ) { + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild(choice); - if(child->multiple()) { + child = getChild( choice ); + if( child->multiple() ) { // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - MatchType retval; - retval = ((MultList *)child)->tryNext(ents); - if(retval == MATCHALL) { + MatchType retval; + retval = ( ( MultList * )child )->tryNext( ents ); + if( retval == MATCHALL ) { return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -134,8 +130,8 @@ MatchType OrList::tryNext(EntNode *ents) // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll(ents); - if(choiceCount == 1) { + child->unmarkAll( ents ); + if( choiceCount == 1 ) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -144,8 +140,8 @@ MatchType OrList::tryNext(EntNode *ents) } // Otherwise, try our next: - if(acceptNextChoice(ents)) { - if(ents->allMarked()) { + if( acceptNextChoice( ents ) ) { + if( ents->allMarked() ) { return MATCHALL; } return NEWCHOICE; diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index 7b207ea89..e37d931bb 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -1,23 +1,20 @@ #include "typeDescriptor.h" -TypeDescriptor::TypeDescriptor() - : _name(0), altNames(0), _fundamentalType(UNKNOWN_TYPE), - _originatingSchema(0), _referentType(0), _description(0), _where_rules(0) -{ +TypeDescriptor::TypeDescriptor( ) + : _name( 0 ), altNames( 0 ), _fundamentalType( UNKNOWN_TYPE ), + _originatingSchema( 0 ), _referentType( 0 ), _description( 0 ), _where_rules( 0 ) { } TypeDescriptor::TypeDescriptor -(const char *nm, PrimitiveType ft, Schema *origSchema, - const char *d) - : _name(nm), altNames(0), _fundamentalType(ft), - _originatingSchema(origSchema), _referentType(0), _description(d), - _where_rules(0) -{ +( const char * nm, PrimitiveType ft, Schema * origSchema, + const char * d ) + : _name( nm ), altNames( 0 ), _fundamentalType( ft ), + _originatingSchema( origSchema ), _referentType( 0 ), _description( d ), + _where_rules( 0 ) { } -TypeDescriptor::~TypeDescriptor() -{ - if(_where_rules) { +TypeDescriptor::~TypeDescriptor() { + if( _where_rules ) { delete _where_rules; } } @@ -32,12 +29,11 @@ TypeDescriptor::~TypeDescriptor() * and returns the new name if found. (See header comments to function * SchRename::rename().) */ -const char *TypeDescriptor::Name(const char *schnm) const -{ - if(schnm == NULL) { +const char * TypeDescriptor::Name( const char * schnm ) const { + if( schnm == NULL ) { return _name; } - if(altNames && altNames->rename(schnm, (char *)_altname)) { + if( altNames && altNames->rename( schnm, ( char * )_altname ) ) { // If our altNames list has an alternate for schnm, copy it into // _altname, and return it: return _altname; @@ -45,20 +41,18 @@ const char *TypeDescriptor::Name(const char *schnm) const return _name; } -const char *TypeDescriptor::BaseTypeName() const -{ +const char * TypeDescriptor::BaseTypeName() const { return BaseTypeDescriptor() ? BaseTypeDescriptor() -> Name() : 0; } -const TypeDescriptor *TypeDescriptor::BaseTypeIsA(const TypeDescriptor *td) const -{ - switch(NonRefType()) { +const TypeDescriptor * TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const { + switch( NonRefType() ) { case AGGREGATE_TYPE: - return AggrElemTypeDescriptor() -> IsA(td); + return AggrElemTypeDescriptor() -> IsA( td ); case ENTITY_TYPE: case SELECT_TYPE: default: - return IsA(td); + return IsA( td ); } } @@ -70,41 +64,37 @@ const TypeDescriptor *TypeDescriptor::BaseTypeIsA(const TypeDescriptor *td) cons * case if schNm USEs or REFERENCEs type and renames it in the process * (e.g., "USE (X as Y)". */ -bool TypeDescriptor::CurrName(const char *other, const char *schNm) const -{ - if(!schNm || *schNm == '\0') { +bool TypeDescriptor::CurrName( const char * other, const char * schNm ) const { + if( !schNm || *schNm == '\0' ) { // If there's no current schema, accept any possible name of this. // (I.e., accept its actual name or any substitute): - return (PossName(other)); + return ( PossName( other ) ); } - if(altNames && altNames->rename(schNm, (char *)_altname)) { + if( altNames && altNames->rename( schNm, ( char * )_altname ) ) { // If we have a different name when the current schema = schNm, then // other better = the alt name. - return (!StrCmpIns(_altname, other)); + return ( !StrCmpIns( _altname, other ) ); } else { // If we have no desginated alternate name when the current schema = // schNm, other must = our _name. - return (OurName(other)); + return ( OurName( other ) ); } } /** * return true if nm is either our name or one of the possible alternates. */ -bool TypeDescriptor::PossName(const char *nm) const -{ - return (OurName(nm) || AltName(nm)); +bool TypeDescriptor::PossName( const char * nm ) const { + return ( OurName( nm ) || AltName( nm ) ); } -bool TypeDescriptor::OurName(const char *nm) const -{ - return !StrCmpIns(nm, _name); +bool TypeDescriptor::OurName( const char * nm ) const { + return !StrCmpIns( nm, _name ); } -bool TypeDescriptor::AltName(const char *nm) const -{ - if(altNames) { - return (altNames->choice(nm)); +bool TypeDescriptor::AltName( const char * nm ) const { + if( altNames ) { + return ( altNames->choice( nm ) ); } return false; } @@ -113,17 +103,16 @@ bool TypeDescriptor::AltName(const char *nm) const * Creates a SchRename consisting of schnm & newnm. Places it in alphabe- * tical order in this's altNames list. */ -void TypeDescriptor::addAltName(const char *schnm, const char *newnm) -{ - SchRename *newpair = new SchRename(schnm, newnm), - *node = (SchRename *)altNames, *prev = NULL; +void TypeDescriptor::addAltName( const char * schnm, const char * newnm ) { + SchRename * newpair = new SchRename( schnm, newnm ), + *node = ( SchRename * )altNames, *prev = NULL; - while(node && *node < *newpair) { + while( node && *node < *newpair ) { prev = node; node = node->next; } newpair->next = node; // node may = NULL - if(prev) { + if( prev ) { // Will be the case if new node should not be first (and above while // loop was entered). prev->next = newpair; @@ -133,69 +122,67 @@ void TypeDescriptor::addAltName(const char *schnm, const char *newnm) } } -void TypeDescriptor::AttrTypeName(std::string &buf, const char *schnm) const -{ - const char *sn = Name(schnm); - if(sn) { - StrToLower(sn, buf); +void TypeDescriptor::AttrTypeName( std::string & buf, const char * schnm ) const { + const char * sn = Name( schnm ); + if( sn ) { + StrToLower( sn , buf ); } else { buf = _description; } } -const char *TypeDescriptor::GenerateExpress(std::string &buf) const -{ +const char * TypeDescriptor::GenerateExpress( std::string & buf ) const { char tmp[BUFSIZ]; buf = "TYPE "; - buf.append(StrToLower(Name(), tmp)); - buf.append(" = "); - const char *desc = Description(); - const char *ptr = desc; - - while(*ptr != '\0') { - if(*ptr == ',') { - buf.append(",\n "); - } else if(*ptr == '(') { - buf.append("\n ("); - } else if(isupper(*ptr)) { - buf += (char)tolower(*ptr); + buf.append( StrToLower( Name(), tmp ) ); + buf.append( " = " ); + const char * desc = Description(); + const char * ptr = desc; + + while( *ptr != '\0' ) { + if( *ptr == ',' ) { + buf.append( ",\n " ); + } else if( *ptr == '(' ) { + buf.append( "\n (" ); + } else if( isupper( *ptr ) ) { + buf += ( char )tolower( *ptr ); } else { buf += *ptr; } ptr++; } - buf.append(";\n"); + buf.append( ";\n" ); /////////////// // count is # of WHERE rules - if(_where_rules != 0) { + if( _where_rules != 0 ) { int all_comments = 1; int count = _where_rules->Count(); - for(int i = 0; i < count; i++) { // print out each UNIQUE rule - if(!(*(_where_rules))[i]->_label.size()) { + for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule + if( !( *( _where_rules ) )[i]->_label.size() ) { all_comments = 0; } } - if(all_comments) { - buf.append(" (* WHERE *)\n"); + if( all_comments ) { + buf.append( " (* WHERE *)\n" ); } else { - buf.append(" WHERE\n"); + buf.append( " WHERE\n" ); } - for(int i = 0; i < count; i++) { // print out each WHERE rule - if(!(*(_where_rules))[i]->_comment.empty()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->comment_()); + for( int i = 0; i < count; i++ ) { // print out each WHERE rule + if( !( *( _where_rules ) )[i]->_comment.empty() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->comment_() ); } - if((*(_where_rules))[i]->_label.size()) { - buf.append(" "); - buf.append((*(_where_rules))[i]->label_()); + if( ( *( _where_rules ) )[i]->_label.size() ) { + buf.append( " " ); + buf.append( ( *( _where_rules ) )[i]->label_() ); } } } - buf.append("END_TYPE;\n"); - return const_cast(buf.c_str()); + buf.append( "END_TYPE;\n" ); + return const_cast( buf.c_str() ); } /** @@ -205,107 +192,106 @@ const char *TypeDescriptor::GenerateExpress(std::string &buf) const * e.g. if the description contains a TYPE name it will also * be explained. */ -const char *TypeDescriptor::TypeString(std::string &s) const -{ - switch(Type()) { +const char * TypeDescriptor::TypeString( std::string & s ) const { + switch( Type() ) { case REFERENCE_TYPE: - if(Name()) { - s.append("TYPE "); - s.append(Name()); - s.append(" = "); + if( Name() ) { + s.append( "TYPE " ); + s.append( Name() ); + s.append( " = " ); } - if(Description()) { - s.append(Description()); + if( Description() ) { + s.append( Description() ); } - if(ReferentType()) { - s.append(" -- "); + if( ReferentType() ) { + s.append( " -- " ); std::string tmp; - s.append(ReferentType()->TypeString(tmp)); + s.append( ReferentType()->TypeString( tmp ) ); } - return const_cast(s.c_str()); + return const_cast( s.c_str() ); case INTEGER_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Integer"); + s.append( "Integer" ); break; case STRING_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("String"); + s.append( "String" ); break; case REAL_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Real"); + s.append( "Real" ); break; case ENUM_TYPE: s = "Enumeration: "; - if(Name()) { - s.append("TYPE "); - s.append(Name()); - s.append(" = "); + if( Name() ) { + s.append( "TYPE " ); + s.append( Name() ); + s.append( " = " ); } - if(Description()) { - s.append(Description()); + if( Description() ) { + s.append( Description() ); } break; case BOOLEAN_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Boolean: F, T"); + s.append( "Boolean: F, T" ); break; case LOGICAL_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Logical: F, T, U"); + s.append( "Logical: F, T, U" ); break; case NUMBER_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Number"); + s.append( "Number" ); break; case BINARY_TYPE: s.clear(); - if(_referentType != 0) { + if( _referentType != 0 ) { s = "TYPE "; - s.append(Name()); - s.append(" = "); + s.append( Name() ); + s.append( " = " ); } - s.append("Binary"); + s.append( "Binary" ); break; case ENTITY_TYPE: s = "Entity: "; - if(Name()) { - s.append(Name()); + if( Name() ) { + s.append( Name() ); } break; case AGGREGATE_TYPE: @@ -314,41 +300,39 @@ const char *TypeDescriptor::TypeString(std::string &s) const case SET_TYPE: // DAS case LIST_TYPE: // DAS s = Description(); - if(ReferentType()) { - s.append(" -- "); + if( ReferentType() ) { + s.append( " -- " ); std::string tmp; - s.append(ReferentType()->TypeString(tmp)); + s.append( ReferentType()->TypeString( tmp ) ); } break; case SELECT_TYPE: - s.append(Description()); + s.append( Description() ); break; case GENERIC_TYPE: case UNKNOWN_TYPE: s = "Unknown"; break; } // end switch - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const TypeDescriptor *TypeDescriptor::IsA(const TypeDescriptor *other) const -{ - if(this == other) { +const TypeDescriptor * TypeDescriptor::IsA( const TypeDescriptor * other ) const { + if( this == other ) { return other; } return 0; } -const TypeDescriptor *TypeDescriptor::IsA(const char *other) const -{ - if(!Name()) { +const TypeDescriptor * TypeDescriptor::IsA( const char * other ) const { + if( !Name() ) { return 0; } - if(!StrCmpIns(_name, other)) { // this is the type + if( !StrCmpIns( _name, other ) ) { // this is the type return this; } - return (ReferentType() ? ReferentType() -> IsA(other) : 0); + return ( ReferentType() ? ReferentType() -> IsA( other ) : 0 ); } /** @@ -360,22 +344,20 @@ const TypeDescriptor *TypeDescriptor::IsA(const char *other) const * an element by calling AggrElemType(). Select types * would work the same? */ -PrimitiveType TypeDescriptor::NonRefType() const -{ - const TypeDescriptor *td = NonRefTypeDescriptor(); - if(td) { +PrimitiveType TypeDescriptor::NonRefType() const { + const TypeDescriptor * td = NonRefTypeDescriptor(); + if( td ) { return td->FundamentalType(); } return UNKNOWN_TYPE; } -const TypeDescriptor *TypeDescriptor::NonRefTypeDescriptor() const -{ - const TypeDescriptor *td = this; +const TypeDescriptor * TypeDescriptor::NonRefTypeDescriptor() const { + const TypeDescriptor * td = this; - while(td->ReferentType()) { - if(td->Type() != REFERENCE_TYPE) { + while( td->ReferentType() ) { + if( td->Type() != REFERENCE_TYPE ) { return td; } td = td->ReferentType(); @@ -385,9 +367,8 @@ const TypeDescriptor *TypeDescriptor::NonRefTypeDescriptor() const } /// This returns the PrimitiveType of the first non-aggregate element of an aggregate -int TypeDescriptor::IsAggrType() const -{ - switch(NonRefType()) { +int TypeDescriptor::IsAggrType() const { + switch( NonRefType() ) { case AGGREGATE_TYPE: case ARRAY_TYPE: // DAS case BAG_TYPE: // DAS @@ -400,20 +381,18 @@ int TypeDescriptor::IsAggrType() const } } -PrimitiveType TypeDescriptor::AggrElemType() const -{ - const TypeDescriptor *aggrElemTD = AggrElemTypeDescriptor(); - if(aggrElemTD) { +PrimitiveType TypeDescriptor::AggrElemType() const { + const TypeDescriptor * aggrElemTD = AggrElemTypeDescriptor(); + if( aggrElemTD ) { return aggrElemTD->Type(); } return UNKNOWN_TYPE; } -const TypeDescriptor *TypeDescriptor::AggrElemTypeDescriptor() const -{ - const TypeDescriptor *aggrTD = NonRefTypeDescriptor(); - const TypeDescriptor *aggrElemTD = aggrTD->ReferentType(); - if(aggrElemTD) { +const TypeDescriptor * TypeDescriptor::AggrElemTypeDescriptor() const { + const TypeDescriptor * aggrTD = NonRefTypeDescriptor(); + const TypeDescriptor * aggrElemTD = aggrTD->ReferentType(); + if( aggrElemTD ) { aggrElemTD = aggrElemTD->NonRefTypeDescriptor(); } return aggrElemTD; @@ -429,21 +408,19 @@ const TypeDescriptor *TypeDescriptor::AggrElemTypeDescriptor() const * TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor * for Integer */ -PrimitiveType TypeDescriptor::BaseType() const -{ - const TypeDescriptor *td = BaseTypeDescriptor(); - if(td) { +PrimitiveType TypeDescriptor::BaseType() const { + const TypeDescriptor * td = BaseTypeDescriptor(); + if( td ) { return td->FundamentalType(); } else { return ENTITY_TYPE; } } -const TypeDescriptor *TypeDescriptor::BaseTypeDescriptor() const -{ - const TypeDescriptor *td = this; +const TypeDescriptor * TypeDescriptor::BaseTypeDescriptor() const { + const TypeDescriptor * td = this; - while(td -> ReferentType()) { + while( td -> ReferentType() ) { td = td->ReferentType(); } return td; diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 3790707e2..915c1831d 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -93,8 +93,7 @@ * It is the same as _name for EXPRESS base types TypeDescriptors (with * the possible exception of upper or lower case differences). */ -class SC_CORE_EXPORT TypeDescriptor -{ +class SC_CORE_EXPORT TypeDescriptor { protected: @@ -106,7 +105,7 @@ class SC_CORE_EXPORT TypeDescriptor /// generated code, for example, places a literal string in its /// TypeDesc constructor calls. This creates a location in me- /// mory static throughout the lifetime of the calling program. - const char *_name ; + const char * _name ; /// an alternate name of type - such as one given by a different /// schema which USEs/ REFERENCEs this. (A complete list of @@ -116,58 +115,56 @@ class SC_CORE_EXPORT TypeDescriptor /// contains list of renamings of type - used by other schemas /// which USE/ REFERENCE this - const SchRename *altNames; + const SchRename * altNames; /// the type of the type (see above). /// it is an enum see file clstepcore/baseType.h PrimitiveType _fundamentalType; - const Schema *_originatingSchema; + const Schema * _originatingSchema; /// further describes the type (see above) /// most often (or always) points at a subtype. - const TypeDescriptor *_referentType; + const TypeDescriptor * _referentType; /// Express file description (see above) /// e.g. the right side of an Express TYPE stmt /// (See note above by _name regarding memory allocation.) - const char *_description; + const char * _description; public: /// a Where_rule may contain only a comment Where_rule__list_var _where_rules; // initially a null pointer - Where_rule__list_var &where_rules_() - { + Where_rule__list_var & where_rules_() { return _where_rules; } - void where_rules_(Where_rule__list *wrl) - { + void where_rules_( Where_rule__list * wrl ) { _where_rules = wrl; } protected: /// Functions used to check the current name of the type (may /// != _name if altNames has diff name for current schema). - bool PossName(const char *) const; - bool OurName(const char *) const; - bool AltName(const char *) const; + bool PossName( const char * ) const; + bool OurName( const char * ) const; + bool AltName( const char * ) const; public: - TypeDescriptor(const char *nm, PrimitiveType ft, const char *d); - TypeDescriptor(const char *nm, PrimitiveType ft, - Schema *origSchema, const char *d); - TypeDescriptor(); + TypeDescriptor( const char * nm, PrimitiveType ft, const char * d ); + TypeDescriptor( const char * nm, PrimitiveType ft, + Schema * origSchema, const char * d ); + TypeDescriptor( ); virtual ~TypeDescriptor(); - virtual const char *GenerateExpress(std::string &buf) const; + virtual const char * GenerateExpress( std::string & buf ) const; /// The name of this type. If schnm != NULL, the name we're /// referred to by schema schnm (may be diff name in our alt- /// names list (based on schnm's USE/REF list)). - const char *Name(const char *schnm = NULL) const; + const char * Name( const char * schnm = NULL ) const; /// The name that would be found on the right side of an /// attribute definition. In the case of a type defined like @@ -177,11 +174,10 @@ class SC_CORE_EXPORT TypeDescriptor /// defined in an attribute it will be the _description /// member variable since _name will be null. e.g. attr. def. /// project_names : ARRAY [1..10] name; - void AttrTypeName(std::string &buf, const char *schnm = NULL) const; + void AttrTypeName( std::string & buf, const char * schnm = NULL ) const; /// Linked link of alternate names for the type: - const SchRename *AltNameList() const - { + const SchRename * AltNameList() const { return altNames; } @@ -190,15 +186,13 @@ class SC_CORE_EXPORT TypeDescriptor /// except it is more thorough of a description where possible /// e.g. if the description contains a TYPE name it will also /// be explained. - const char *TypeString(std::string &s) const; + const char * TypeString( std::string & s ) const; /// This TypeDescriptor's type - PrimitiveType Type() const - { + PrimitiveType Type() const { return _fundamentalType; } - void Type(const PrimitiveType type) - { + void Type( const PrimitiveType type ) { _fundamentalType = type; } @@ -213,8 +207,8 @@ class SC_CORE_EXPORT TypeDescriptor /// TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor /// for Integer. PrimitiveType BaseType() const; - const TypeDescriptor *BaseTypeDescriptor() const; - const char *BaseTypeName() const; + const TypeDescriptor * BaseTypeDescriptor() const; + const char * BaseTypeName() const; /// the first PrimitiveType that is not REFERENCE_TYPE (the first /// TypeDescriptor *_referentType that does not have REFERENCE_TYPE @@ -225,43 +219,36 @@ class SC_CORE_EXPORT TypeDescriptor /// would work the same? PrimitiveType NonRefType() const; - const TypeDescriptor *NonRefTypeDescriptor() const; + const TypeDescriptor * NonRefTypeDescriptor() const; int IsAggrType() const; PrimitiveType AggrElemType() const; - const TypeDescriptor *AggrElemTypeDescriptor() const; + const TypeDescriptor * AggrElemTypeDescriptor() const; - PrimitiveType FundamentalType() const - { + PrimitiveType FundamentalType() const { return _fundamentalType; } - void FundamentalType(PrimitiveType ftype) - { + void FundamentalType( PrimitiveType ftype ) { _fundamentalType = ftype; } /// The TypeDescriptor for the type this type is based on - const TypeDescriptor *ReferentType() const - { + const TypeDescriptor * ReferentType() const { return _referentType; } - void ReferentType(const TypeDescriptor *rtype) - { + void ReferentType( const TypeDescriptor * rtype ) { _referentType = rtype; } - const Schema *OriginatingSchema() const - { + const Schema * OriginatingSchema() const { return _originatingSchema; } - void OriginatingSchema(const Schema *os) - { + void OriginatingSchema( const Schema * os ) { _originatingSchema = os; } - const char *schemaName() const - { - if(_originatingSchema) { + const char * schemaName() const { + if( _originatingSchema ) { return _originatingSchema->Name(); } else { return ""; @@ -271,35 +258,30 @@ class SC_CORE_EXPORT TypeDescriptor /// A description of this type's type. Basically you /// get the right side of a TYPE statement minus END_TYPE. /// For base type TypeDescriptors it is the same as _name. - const char *Description() const - { + const char * Description() const { return _description; } - void Description(const char *desc) - { + void Description( const char * desc ) { _description = desc; } - virtual const TypeDescriptor *IsA(const TypeDescriptor *) const; - virtual const TypeDescriptor *BaseTypeIsA(const TypeDescriptor *) + virtual const TypeDescriptor * IsA( const TypeDescriptor * ) const; + virtual const TypeDescriptor * BaseTypeIsA( const TypeDescriptor * ) const; - virtual const TypeDescriptor *IsA(const char *) const; - virtual const TypeDescriptor *CanBe(const TypeDescriptor *n) const - { - return IsA(n); + virtual const TypeDescriptor * IsA( const char * ) const; + virtual const TypeDescriptor * CanBe( const TypeDescriptor * n ) const { + return IsA( n ); } - virtual const TypeDescriptor *CanBe(const char *n) const - { - return IsA(n); + virtual const TypeDescriptor * CanBe( const char * n ) const { + return IsA( n ); } - virtual const TypeDescriptor *CanBeSet(const char *n, - const char *schNm = 0) const - { - return (CurrName(n, schNm) ? this : 0); + virtual const TypeDescriptor * CanBeSet( const char * n, + const char * schNm = 0 ) const { + return ( CurrName( n, schNm ) ? this : 0 ); } - bool CurrName(const char *, const char * = 0) const; + bool CurrName( const char *, const char * = 0 ) const; /// Adds an additional name, newnm, to be use when schema schnm is USE/REFERENCE'ing us (added to altNames). - void addAltName(const char *schnm, const char *newnm); + void addAltName( const char * schnm, const char * newnm ); }; #endif //TYPEDESCRIPTOR_H diff --git a/src/clstepcore/typeDescriptorList.cc b/src/clstepcore/typeDescriptorList.cc index 606e667f8..f47e8f502 100644 --- a/src/clstepcore/typeDescriptorList.cc +++ b/src/clstepcore/typeDescriptorList.cc @@ -1,36 +1,29 @@ #include "typeDescriptorList.h" -TypeDescLinkNode::TypeDescLinkNode() -{ +TypeDescLinkNode::TypeDescLinkNode() { _typeDesc = 0; } -TypeDescLinkNode::~TypeDescLinkNode() -{ +TypeDescLinkNode::~TypeDescLinkNode() { } -TypeDescriptorList::TypeDescriptorList() -{ +TypeDescriptorList::TypeDescriptorList() { } -TypeDescriptorList::~TypeDescriptorList() -{ +TypeDescriptorList::~TypeDescriptorList() { } -TypeDescItr::TypeDescItr(const TypeDescriptorList &tdList) : tdl(tdList) -{ - cur = (TypeDescLinkNode *)(tdl.GetHead()); +TypeDescItr::TypeDescItr( const TypeDescriptorList & tdList ) : tdl( tdList ) { + cur = ( TypeDescLinkNode * )( tdl.GetHead() ); } -TypeDescItr::~TypeDescItr() -{ +TypeDescItr::~TypeDescItr() { } -const TypeDescriptor *TypeDescItr::NextTypeDesc() -{ - if(cur) { - const TypeDescriptor *td = cur->TypeDesc(); - cur = (TypeDescLinkNode *)(cur->NextNode()); +const TypeDescriptor * TypeDescItr::NextTypeDesc() { + if( cur ) { + const TypeDescriptor * td = cur->TypeDesc(); + cur = ( TypeDescLinkNode * )( cur->NextNode() ); return td; } return 0; diff --git a/src/clstepcore/typeDescriptorList.h b/src/clstepcore/typeDescriptorList.h index faff6712a..b8bbc614c 100644 --- a/src/clstepcore/typeDescriptorList.h +++ b/src/clstepcore/typeDescriptorList.h @@ -9,63 +9,55 @@ class TypeDescriptor; -class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode -{ +class SC_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode { private: protected: - TypeDescriptor *_typeDesc; + TypeDescriptor * _typeDesc; public: TypeDescLinkNode(); virtual ~TypeDescLinkNode(); - const TypeDescriptor *TypeDesc() const - { + const TypeDescriptor * TypeDesc() const { return _typeDesc; } - void TypeDesc(TypeDescriptor *td) - { + void TypeDesc( TypeDescriptor * td ) { _typeDesc = td; } }; -class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList -{ +class SC_CORE_EXPORT TypeDescriptorList : public SingleLinkList { private: protected: public: TypeDescriptorList(); virtual ~TypeDescriptorList(); - virtual SingleLinkNode *NewNode() - { + virtual SingleLinkNode * NewNode() { return new TypeDescLinkNode; } - TypeDescLinkNode *AddNode(TypeDescriptor *td) - { - TypeDescLinkNode *node = (TypeDescLinkNode *) NewNode(); - node->TypeDesc(td); - SingleLinkList::AppendNode(node); + TypeDescLinkNode * AddNode( TypeDescriptor * td ) { + TypeDescLinkNode * node = ( TypeDescLinkNode * ) NewNode(); + node->TypeDesc( td ); + SingleLinkList::AppendNode( node ); return node; } }; -class SC_CORE_EXPORT TypeDescItr -{ +class SC_CORE_EXPORT TypeDescItr { protected: - const TypeDescriptorList &tdl; - const TypeDescLinkNode *cur; + const TypeDescriptorList & tdl; + const TypeDescLinkNode * cur; public: - TypeDescItr(const TypeDescriptorList &tdList); + TypeDescItr( const TypeDescriptorList & tdList ); virtual ~TypeDescItr(); - void ResetItr() - { - cur = (TypeDescLinkNode *)(tdl.GetHead()); + void ResetItr() { + cur = ( TypeDescLinkNode * )( tdl.GetHead() ); } - const TypeDescriptor *NextTypeDesc(); + const TypeDescriptor * NextTypeDesc(); }; #endif //TYPEDESCRIPTORLIST_H diff --git a/src/clstepcore/typeOrRuleVar.cc b/src/clstepcore/typeOrRuleVar.cc index ced514c00..0b06f1949 100644 --- a/src/clstepcore/typeOrRuleVar.cc +++ b/src/clstepcore/typeOrRuleVar.cc @@ -2,16 +2,13 @@ #include -Type_or_rule::Type_or_rule() -{ +Type_or_rule::Type_or_rule() { std::cerr << "WARNING - Type_or_rule class doesn't seem to be complete - it has no members!" << std::endl; } -Type_or_rule::Type_or_rule(const Type_or_rule &tor): Dictionary_instance() -{ - (void) tor; //TODO once this class has some members, we'll actually have something to copy +Type_or_rule::Type_or_rule( const Type_or_rule & tor ): Dictionary_instance() { + ( void ) tor; //TODO once this class has some members, we'll actually have something to copy } -Type_or_rule::~Type_or_rule() -{ +Type_or_rule::~Type_or_rule() { } diff --git a/src/clstepcore/typeOrRuleVar.h b/src/clstepcore/typeOrRuleVar.h index a8c7cc959..09f78da59 100644 --- a/src/clstepcore/typeOrRuleVar.h +++ b/src/clstepcore/typeOrRuleVar.h @@ -5,15 +5,14 @@ #include "sc_export.h" -class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance -{ - public: - Type_or_rule(); - Type_or_rule(const Type_or_rule &); - virtual ~Type_or_rule(); +class SC_CORE_EXPORT Type_or_rule : public Dictionary_instance { +public: + Type_or_rule(); + Type_or_rule( const Type_or_rule & ); + virtual ~Type_or_rule(); }; -typedef Type_or_rule *Type_or_rule_ptr; +typedef Type_or_rule * Type_or_rule_ptr; typedef Type_or_rule_ptr Type_or_rule_var; diff --git a/src/clstepcore/uniquenessRule.cc b/src/clstepcore/uniquenessRule.cc index 501ac9e4b..038f1a68f 100644 --- a/src/clstepcore/uniquenessRule.cc +++ b/src/clstepcore/uniquenessRule.cc @@ -3,118 +3,105 @@ #include Uniqueness_rule::Uniqueness_rule() - : _parent_entity(0) -{ +: _parent_entity( 0 ) { } -Uniqueness_rule::Uniqueness_rule(const Uniqueness_rule &ur): Dictionary_instance() -{ +Uniqueness_rule::Uniqueness_rule( const Uniqueness_rule & ur ): Dictionary_instance() { _label = ur._label; _parent_entity = ur._parent_entity; } -Uniqueness_rule::~Uniqueness_rule() -{ +Uniqueness_rule::~Uniqueness_rule() { // don't delete _parent_entity } -Uniqueness_rule__set::Uniqueness_rule__set(int defaultSize) -{ +Uniqueness_rule__set::Uniqueness_rule__set( int defaultSize ) { _bufsize = defaultSize; _buf = new Uniqueness_rule_ptr[_bufsize]; _count = 0; } -Uniqueness_rule__set::~Uniqueness_rule__set() -{ +Uniqueness_rule__set::~Uniqueness_rule__set() { Clear(); delete[] _buf; } -void Uniqueness_rule__set::Check(int index) -{ - Uniqueness_rule_ptr *newbuf; +void Uniqueness_rule__set::Check( int index ) { + Uniqueness_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Uniqueness_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Uniqueness_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Uniqueness_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Uniqueness_rule__set::Insert(Uniqueness_rule_ptr v, int index) -{ - Uniqueness_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Uniqueness_rule__set::Insert( Uniqueness_rule_ptr v, int index ) { + Uniqueness_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Append(Uniqueness_rule_ptr v) -{ +void Uniqueness_rule__set::Append( Uniqueness_rule_ptr v ) { int index = _count; - Uniqueness_rule_ptr *spot; + Uniqueness_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Uniqueness_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Uniqueness_rule__set::Remove(int index) -{ - if(0 <= index && index < _count) { +void Uniqueness_rule__set::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Uniqueness_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Uniqueness_rule_ptr)); + Uniqueness_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Uniqueness_rule_ptr ) ); } } -int Uniqueness_rule__set::Index(Uniqueness_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Uniqueness_rule__set::Index( Uniqueness_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Uniqueness_rule_ptr &Uniqueness_rule__set::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Uniqueness_rule_ptr & Uniqueness_rule__set::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Uniqueness_rule__set::Count() -{ +int Uniqueness_rule__set::Count() { return _count; } -void Uniqueness_rule__set::Clear() -{ - for(int i = 0; i < _count; i ++) { +void Uniqueness_rule__set::Clear() { + for( int i = 0; i < _count; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/uniquenessRule.h b/src/clstepcore/uniquenessRule.h index ccac487c9..4751ce97b 100644 --- a/src/clstepcore/uniquenessRule.h +++ b/src/clstepcore/uniquenessRule.h @@ -9,85 +9,77 @@ class EntityDescriptor; -class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Uniqueness_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; /** Comment contained in the EXPRESS. + // non-SDAI + std::string _comment; /** Comment contained in the EXPRESS. * Should be properly formatted to include (* *) * Will be written to EXPRESS as-is (w/out formatting) */ #ifdef _MSC_VER #pragma warning( pop ) #endif - const EntityDescriptor *_parent_entity; - - Uniqueness_rule(); - Uniqueness_rule(const Uniqueness_rule &); - Uniqueness_rule(const char *label, EntityDescriptor *pe = 0) - : _label(label), _parent_entity(pe) { } - virtual ~Uniqueness_rule(); - - Express_id label_() const - { - return _label; - } - const EntityDescriptor *parent_() const - { - return _parent_entity; - } - std::string &comment_() - { - return _comment; - } - - void label_(const Express_id &ei) - { - _label = ei; - } - void parent_(const EntityDescriptor *pe) - { - _parent_entity = pe; - } - void comment_(const char *c) - { - _comment = c; - } + const EntityDescriptor * _parent_entity; + + Uniqueness_rule(); + Uniqueness_rule( const Uniqueness_rule & ); + Uniqueness_rule( const char * label, EntityDescriptor * pe = 0 ) + : _label( label ), _parent_entity( pe ) { } + virtual ~Uniqueness_rule(); + + Express_id label_() const { + return _label; + } + const EntityDescriptor * parent_() const { + return _parent_entity; + } + std::string & comment_() { + return _comment; + } + + void label_( const Express_id & ei ) { + _label = ei; + } + void parent_( const EntityDescriptor * pe ) { + _parent_entity = pe; + } + void comment_( const char * c ) { + _comment = c; + } }; -typedef Uniqueness_rule *Uniqueness_rule_ptr; - -class SC_CORE_EXPORT Uniqueness_rule__set -{ - public: - Uniqueness_rule__set(int = 16); - ~Uniqueness_rule__set(); - - Uniqueness_rule_ptr &operator[](int index); - void Insert(Uniqueness_rule_ptr, int index); - void Append(Uniqueness_rule_ptr); - void Remove(int index); - int Index(Uniqueness_rule_ptr); - - int Count(); - void Clear(); - private: - void Check(int index); - private: - Uniqueness_rule_ptr *_buf; - int _bufsize; - int _count; +typedef Uniqueness_rule * Uniqueness_rule_ptr; + +class SC_CORE_EXPORT Uniqueness_rule__set { +public: + Uniqueness_rule__set( int = 16 ); + ~Uniqueness_rule__set(); + + Uniqueness_rule_ptr & operator[]( int index ); + void Insert( Uniqueness_rule_ptr, int index ); + void Append( Uniqueness_rule_ptr ); + void Remove( int index ); + int Index( Uniqueness_rule_ptr ); + + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Uniqueness_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Uniqueness_rule__set *Uniqueness_rule__set_ptr; +typedef Uniqueness_rule__set * Uniqueness_rule__set_ptr; typedef Uniqueness_rule__set_ptr Uniqueness_rule__set_var; #endif //UNIQUENESSRULE_H diff --git a/src/clstepcore/whereRule.cc b/src/clstepcore/whereRule.cc index 43db2f1e5..e60c64940 100644 --- a/src/clstepcore/whereRule.cc +++ b/src/clstepcore/whereRule.cc @@ -1,119 +1,106 @@ #include "whereRule.h" -Where_rule::Where_rule() -{ +Where_rule::Where_rule() { _type_or_rule = 0; } -Where_rule::Where_rule(const Where_rule &wr): Dictionary_instance() -{ +Where_rule::Where_rule( const Where_rule & wr ): Dictionary_instance() { _label = wr._label; _type_or_rule = wr._type_or_rule; } -Where_rule::~Where_rule() -{ +Where_rule::~Where_rule() { } /////////////////////////////////////////////////////////////////////////////// -Where_rule__list::Where_rule__list(int defaultSize) -{ +Where_rule__list::Where_rule__list( int defaultSize ) { _bufsize = defaultSize; _buf = new Where_rule_ptr[_bufsize]; _count = 0; } -Where_rule__list::~Where_rule__list() -{ +Where_rule__list::~Where_rule__list() { Clear(); delete[] _buf; } -void Where_rule__list::Check(int index) -{ - Where_rule_ptr *newbuf; +void Where_rule__list::Check( int index ) { + Where_rule_ptr * newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new Where_rule_ptr[_bufsize]; - memmove(newbuf, _buf, _count * sizeof(Where_rule_ptr)); + memmove( newbuf, _buf, _count * sizeof( Where_rule_ptr ) ); delete[] _buf; _buf = newbuf; } } -void Where_rule__list::Insert(Where_rule_ptr v, int index) -{ - Where_rule_ptr *spot; - index = (index < 0) ? _count : index; +void Where_rule__list::Insert( Where_rule_ptr v, int index ) { + Where_rule_ptr * spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Append(Where_rule_ptr v) -{ +void Where_rule__list::Append( Where_rule_ptr v ) { int index = _count; - Where_rule_ptr *spot; + Where_rule_ptr * spot; - if(index < _count) { - Check(_count + 1); + if( index < _count ) { + Check( _count + 1 ); spot = &_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(Where_rule_ptr)); + memmove( spot + 1, spot, ( _count - index )*sizeof( Where_rule_ptr ) ); } else { - Check(index); + Check( index ); spot = &_buf[index]; } *spot = v; ++_count; } -void Where_rule__list::Remove(int index) -{ - if(0 <= index && index < _count) { +void Where_rule__list::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - Where_rule_ptr *spot = &_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(Where_rule_ptr)); + Where_rule_ptr * spot = &_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( Where_rule_ptr ) ); } } -int Where_rule__list::Index(Where_rule_ptr v) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == v) { +int Where_rule__list::Index( Where_rule_ptr v ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == v ) { return i; } } return -1; } -Where_rule_ptr &Where_rule__list::operator[](int index) -{ - Check(index); - _count = ((_count > index + 1) ? _count : (index + 1)); +Where_rule_ptr & Where_rule__list::operator[]( int index ) { + Check( index ); + _count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) ); return _buf[index]; } -int Where_rule__list::Count() -{ +int Where_rule__list::Count() { return _count; } -void Where_rule__list::Clear() -{ - for(int i = 0; i < _count ; i ++) { +void Where_rule__list::Clear() { + for( int i = 0; i < _count ; i ++ ) { delete _buf[i]; } _count = 0; diff --git a/src/clstepcore/whereRule.h b/src/clstepcore/whereRule.h index 7ed9954a2..ef9043a4b 100644 --- a/src/clstepcore/whereRule.h +++ b/src/clstepcore/whereRule.h @@ -8,82 +8,74 @@ #include "sc_export.h" -class SC_CORE_EXPORT Where_rule : public Dictionary_instance -{ - public: +class SC_CORE_EXPORT Where_rule : public Dictionary_instance { +public: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _label; + Express_id _label; - // non-SDAI - std::string _comment; // Comment contained in the EXPRESS. - // Should be properly formatted to include (* *) - // Will be written to EXPRESS as-is (w/out formatting) + // non-SDAI + std::string _comment; // Comment contained in the EXPRESS. + // Should be properly formatted to include (* *) + // Will be written to EXPRESS as-is (w/out formatting) #ifdef _MSC_VER #pragma warning( pop ) #endif - Type_or_rule_var _type_or_rule; + Type_or_rule_var _type_or_rule; - Where_rule(); - Where_rule(const Where_rule &); - Where_rule(const char *label, Type_or_rule_var tor = 0) - : _label(label), _type_or_rule(tor) { } - virtual ~Where_rule(); + Where_rule(); + Where_rule( const Where_rule & ); + Where_rule( const char * label, Type_or_rule_var tor = 0 ) + : _label( label ), _type_or_rule( tor ) { } + virtual ~Where_rule(); - Express_id label_() const - { - return _label; - } - Type_or_rule_var parent_item() const - { - return _type_or_rule; - } - std::string comment_() const - { - return _comment; - } + Express_id label_() const { + return _label; + } + Type_or_rule_var parent_item() const { + return _type_or_rule; + } + std::string comment_() const { + return _comment; + } - void label_(const Express_id &ei) - { - _label = ei; - } - void parent_item(const Type_or_rule_var &tor) - { - _type_or_rule = tor; - } - void comment_(const char *c) - { - _comment = c; - } + void label_( const Express_id & ei ) { + _label = ei; + } + void parent_item( const Type_or_rule_var & tor ) { + _type_or_rule = tor; + } + void comment_( const char * c ) { + _comment = c; + } }; -typedef Where_rule *Where_rule_ptr; +typedef Where_rule * Where_rule_ptr; -class SC_CORE_EXPORT Where_rule__list -{ - public: - Where_rule__list(int = 16); - ~Where_rule__list(); +class SC_CORE_EXPORT Where_rule__list { +public: + Where_rule__list( int = 16 ); + ~Where_rule__list(); - Where_rule_ptr &operator[](int index); - void Insert(Where_rule_ptr, int index); - void Append(Where_rule_ptr); - void Remove(int index); - int Index(Where_rule_ptr); + Where_rule_ptr & operator[]( int index ); + void Insert( Where_rule_ptr, int index ); + void Append( Where_rule_ptr ); + void Remove( int index ); + int Index( Where_rule_ptr ); - int Count(); - void Clear(); - private: - void Check(int index); - private: - Where_rule_ptr *_buf; - int _bufsize; - int _count; + int Count(); + void Clear(); +private: + void Check( int index ); +private: + Where_rule_ptr * _buf; + int _bufsize; + int _count; }; -typedef Where_rule__list *Where_rule__list_ptr; +typedef Where_rule__list * Where_rule__list_ptr; typedef Where_rule__list_ptr Where_rule__list_var; #endif //WHERERULE_H diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 514980ad9..2553f4fa5 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) @@ -33,7 +33,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) if(WIN32) target_link_libraries(steputils-static shlwapi) @@ -41,7 +41,7 @@ if(BUILD_STATIC_LIBS) endif() install(FILES ${SC_CLUTILS_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clutils) + DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils) # Local Variables: # tab-width: 8 diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index e97083dc0..a14f0dc08 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -23,82 +23,76 @@ ** Status: complete ******************************************************************/ -char ToLower(const char c) -{ - if(isupper(c)) { - return (tolower(c)); +char ToLower( const char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } -char ToUpper(const char c) -{ - if(islower(c)) { - return (toupper(c)); +char ToUpper( const char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } // Place in strNew a lowercase version of strOld. -char *StrToLower(const char *strOld, char *strNew) -{ +char * StrToLower( const char * strOld, char * strNew ) { int i = 0; - while(strOld[i] != '\0') { - strNew[i] = ToLower(strOld[i]); + while( strOld[i] != '\0' ) { + strNew[i] = ToLower( strOld[i] ); i++; } strNew[i] = '\0'; return strNew; } -const char *StrToLower(const char *word, std::string &s) -{ +const char * StrToLower( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *StrToUpper(const char *word, std::string &s) -{ +const char * StrToUpper( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } -const char *StrToConstant(const char *word, std::string &s) -{ +const char * StrToConstant( const char * word, std::string & s ) { char newword [BUFSIZ]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; s = newword; - return const_cast(s.c_str()); + return const_cast( s.c_str() ); } /**************************************************************//** @@ -109,10 +103,9 @@ const char *StrToConstant(const char *word, std::string &s) ** == 0 when str1 equals str2 ** > 0 when str1 greater then str2 ******************************************************************/ -int StrCmpIns(const char *str1, const char *str2) -{ +int StrCmpIns( const char * str1, const char * str2 ) { char c1, c2; - while((c1 = tolower(*str1)) == (c2 = tolower(*str2)) && c1 != '\0') { + while( ( c1 = tolower( *str1 ) ) == ( c2 = tolower( *str2 ) ) && c1 != '\0' ) { str1++; str2++; } @@ -122,18 +115,17 @@ int StrCmpIns(const char *str1, const char *str2) /** * Test if a string ends with the given suffix. */ -bool StrEndsWith(const std::string &s, const char *suf) -{ - if(suf == NULL) { +bool StrEndsWith( const std::string & s, const char * suf ) { + if( suf == NULL ) { return false; } std::string suffix = suf; size_t sLen = s.length(); size_t suffixLen = suffix.length(); - if(sLen < suffixLen) { + if( sLen < suffixLen ) { return false; } - if(s.substr(sLen - suffixLen).compare(suffix) == 0) { + if( s.substr( sLen - suffixLen ).compare( suffix ) == 0 ) { return true; } return false; @@ -142,39 +134,38 @@ bool StrEndsWith(const std::string &s, const char *suf) /** * Extract the next delimited string from the istream. */ -std::string GetLiteralStr(istream &in, ErrorDescriptor *err) -{ +std::string GetLiteralStr( istream & in, ErrorDescriptor * err ) { std::string s; in >> std::ws; // skip whitespace - if(in.good() && in.peek() == STRING_DELIM) { + if( in.good() && in.peek() == STRING_DELIM ) { s += in.get(); bool allDelimsEscaped = true; - while(in.good()) { - if(in.peek() == STRING_DELIM) { + while( in.good() ) { + if( in.peek() == STRING_DELIM ) { // A delimiter closes the string unless it's followed by another // delimiter, in which case it's escaped. \S\ starts an ISO // 8859 character escape sequence, so we ignore delimiters // prefixed with \S\. - if(!StrEndsWith(s, "\\S\\")) { + if( !StrEndsWith( s, "\\S\\" ) ) { allDelimsEscaped = !allDelimsEscaped; } - } else if(!allDelimsEscaped) { + } else if( !allDelimsEscaped ) { // Found normal char after unescaped delim, so last delim // that was appended terminated the string. break; } - if(!in.eof()) { + if( !in.eof() ) { s += in.get(); } } - if(allDelimsEscaped) { + if( allDelimsEscaped ) { // Any delimiters found after the opening delimiter were escaped, // so the string is unclosed. // non-recoverable error - err->AppendToDetailMsg("Missing closing quote on string value.\n"); - err->AppendToUserMsg("Missing closing quote on string value.\n"); - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->AppendToDetailMsg( "Missing closing quote on string value.\n" ); + err->AppendToUserMsg( "Missing closing quote on string value.\n" ); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); } } return s; @@ -186,22 +177,21 @@ std::string GetLiteralStr(istream &in, ErrorDescriptor *err) ** Capitalizes first char of word, rest is lowercase. Removes '_'. ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } @@ -213,10 +203,9 @@ const char *PrettyTmpName(const char *oldname) ** Side Effects: allocates memory for the new name ** Status: OK 7-Oct-1992 kcm ******************************************************************/ -char *PrettyNewName(const char *oldname) -{ - char *name = new char [strlen(oldname) + 1]; - strcpy(name, PrettyTmpName(oldname)); +char * PrettyNewName( const char * oldname ) { + char * name = new char [strlen( oldname ) + 1]; + strcpy( name, PrettyTmpName( oldname ) ); return name; } @@ -256,82 +245,80 @@ char *PrettyNewName(const char *oldname) *** not then it is an error but the bad chars are not read since you have *** no way to know when to stop. **/ -Severity CheckRemainingInput(istream &in, ErrorDescriptor *err, - const char *typeName, // used in error message - const char *delimiterList) // e.g. ",)" -{ +Severity CheckRemainingInput( istream & in, ErrorDescriptor * err, + const char * typeName, // used in error message + const char * delimiterList ) { // e.g. ",)" string skipBuf; ostringstream errMsg; - if(in.eof()) { + if( in.eof() ) { // no error return err->severity(); - } else if(in.bad()) { + } else if( in.bad() ) { // Bad bit must have been set during read. Recovery is impossible. - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); } else { // At most the fail bit is set, so stream can still be read. // Clear errors and skip whitespace. in.clear(); in >> ws; - if(in.eof()) { + if( in.eof() ) { // no error return err->severity(); } - if(delimiterList != NULL) { + if( delimiterList != NULL ) { // If the next char is a delimiter then there's no error. char c = in.peek(); - if(strchr(delimiterList, c) == NULL) { + if( strchr( delimiterList, c ) == NULL ) { // Error. Extra input is more than just a delimiter and is // now considered invalid. We'll try to recover by skipping // to the next delimiter. - for(in.get(c); in && !strchr(delimiterList, c); in.get(c)) { + for( in.get( c ); in && !strchr( delimiterList, c ); in.get( c ) ) { skipBuf += c; } - if(strchr(delimiterList, c) != NULL) { + if( strchr( delimiterList, c ) != NULL ) { // Delimiter found. Recovery succeeded. - in.putback(c); + in.putback( c ); errMsg << "\tFound invalid " << typeName << " value...\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); - err->AppendToDetailMsg("\tdata lost looking for end of " - "attribute: "); - err->AppendToDetailMsg(skipBuf.c_str()); - err->AppendToDetailMsg("\n"); - - err->GreaterSeverity(SEVERITY_WARNING); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( "\tdata lost looking for end of " + "attribute: " ); + err->AppendToDetailMsg( skipBuf.c_str() ); + err->AppendToDetailMsg( "\n" ); + + err->GreaterSeverity( SEVERITY_WARNING ); } else { // No delimiter found. Recovery failed. errMsg << "Unable to recover from input error while " << "reading " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); - err->GreaterSeverity(SEVERITY_INPUT_ERROR); + err->GreaterSeverity( SEVERITY_INPUT_ERROR ); } } - } else if(in.good()) { + } else if( in.good() ) { // Error. Have more input, but lack of delimiter list means we // don't know where we can safely resume. Recovery is impossible. - err->GreaterSeverity(SEVERITY_WARNING); + err->GreaterSeverity( SEVERITY_WARNING ); errMsg << "Invalid " << typeName << " value.\n"; - err->AppendToUserMsg(errMsg.str().c_str()); - err->AppendToDetailMsg(errMsg.str().c_str()); + err->AppendToUserMsg( errMsg.str().c_str() ); + err->AppendToDetailMsg( errMsg.str().c_str() ); } } return err->severity(); } -Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList) -{ - return CheckRemainingInput(in, err, typeName.c_str(), tokenList); +Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ) { + return CheckRemainingInput( in, err, typeName.c_str(), tokenList ); } diff --git a/src/clutils/Str.h b/src/clutils/Str.h index fb1859c4e..f605bfdda 100644 --- a/src/clutils/Str.h +++ b/src/clutils/Str.h @@ -25,23 +25,23 @@ #define STRING_DELIM '\'' #endif -SC_UTILS_EXPORT char ToLower(const char c); -SC_UTILS_EXPORT char ToUpper(const char c); -SC_UTILS_EXPORT char *StrToLower(const char *, char *); -SC_UTILS_EXPORT const char *StrToLower(const char *word, std::string &s); -SC_UTILS_EXPORT const char *StrToUpper(const char *word, std::string &s); -SC_UTILS_EXPORT const char *StrToConstant(const char *word, std::string &s); -SC_UTILS_EXPORT int StrCmpIns(const char *str1, const char *str2); -SC_UTILS_EXPORT const char *PrettyTmpName(const char *oldname); -SC_UTILS_EXPORT char *PrettyNewName(const char *oldname); -SC_UTILS_EXPORT char *EntityClassName(char *oldname); - -SC_UTILS_EXPORT bool StrEndsWith(const std::string &s, const char *suffix); -SC_UTILS_EXPORT std::string GetLiteralStr(istream &in, ErrorDescriptor *err); - -extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, - const char *typeName, // used in error message - const char *tokenList); // e.g. ",)" -extern SC_UTILS_EXPORT Severity CheckRemainingInput(std::istream &in, ErrorDescriptor *err, const std::string typeName, const char *tokenList); +SC_UTILS_EXPORT char ToLower( const char c ); +SC_UTILS_EXPORT char ToUpper( const char c ); +SC_UTILS_EXPORT char * StrToLower( const char *, char * ); +SC_UTILS_EXPORT const char * StrToLower( const char * word, std::string & s ); +SC_UTILS_EXPORT const char * StrToUpper( const char * word, std::string & s ); +SC_UTILS_EXPORT const char * StrToConstant( const char * word, std::string & s ); +SC_UTILS_EXPORT int StrCmpIns( const char * str1, const char * str2 ); +SC_UTILS_EXPORT const char * PrettyTmpName( const char * oldname ); +SC_UTILS_EXPORT char * PrettyNewName( const char * oldname ); +SC_UTILS_EXPORT char * EntityClassName( char * oldname ); + +SC_UTILS_EXPORT bool StrEndsWith( const std::string & s, const char * suffix ); +SC_UTILS_EXPORT std::string GetLiteralStr( istream & in, ErrorDescriptor * err ); + +extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, + const char * typeName, // used in error message + const char * tokenList ); // e.g. ",)" +extern SC_UTILS_EXPORT Severity CheckRemainingInput( std::istream & in, ErrorDescriptor * err, const std::string typeName, const char * tokenList ); #endif diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index a55786762..337774342 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -66,14 +66,13 @@ // /////////////////////////////////////////////////////////////////////////////// -DirObj::DirObj(const char *dirName) -{ +DirObj::DirObj( const char * dirName ) { const int defaultSize = 256; fileListSize = defaultSize; - fileList = new char *[fileListSize]; + fileList = new char*[fileListSize]; fileCount = 0; - LoadDirectory(dirName); + LoadDirectory( dirName ); } /////////////////////////////////////////////////////////////////////////////// @@ -82,8 +81,7 @@ DirObj::DirObj(const char *dirName) // /////////////////////////////////////////////////////////////////////////////// -DirObj::~DirObj() -{ +DirObj::~DirObj() { ClearFileList(); delete [] fileList; } @@ -96,11 +94,10 @@ DirObj::~DirObj() // /////////////////////////////////////////////////////////////////////////////// -const char *DirObj::RealPath(const char *path) -{ - const char *realpath; +const char * DirObj::RealPath( const char * path ) { + const char * realpath; - if(path == 0 || *path == '\0') { + if( path == 0 || *path == '\0' ) { realpath = "./"; } else { realpath = path; @@ -114,12 +111,11 @@ const char *DirObj::RealPath(const char *path) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::LoadDirectory(const std::string &name) -{ - if(name.empty()) { - return Reset("./"); +bool DirObj::LoadDirectory( const std::string & name ) { + if( name.empty() ) { + return Reset( "./" ); } else { - return Reset(name); + return Reset( name ); } } @@ -130,10 +126,9 @@ bool DirObj::LoadDirectory(const std::string &name) // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Index(const char *name) -{ - for(int i = 0; i < fileCount; ++i) { - if(strcmp(fileList[i], name) == 0) { +int DirObj::Index( const char * name ) { + for( int i = 0; i < fileCount; ++i ) { + if( strcmp( fileList[i], name ) == 0 ) { return i; } } @@ -148,31 +143,30 @@ int DirObj::Index(const char *name) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::Reset(const std::string &path) -{ - bool successful = IsADirectory(path.c_str()); - if(successful) { +bool DirObj::Reset( const std::string & path ) { + bool successful = IsADirectory( path.c_str() ); + if( successful ) { #ifdef _WIN32 WIN32_FIND_DATA FindFileData; HANDLE hFind; ClearFileList(); - hFind = FindFirstFile(path.c_str(), &FindFileData); - if(hFind != INVALID_HANDLE_VALUE) { + hFind = FindFirstFile( path.c_str(), &FindFileData ); + if( hFind != INVALID_HANDLE_VALUE ) { int i = 0; do { - InsertFile(FindFileData.cFileName, i++); - } while(FindNextFile(hFind, &FindFileData)); - FindClose(hFind); + InsertFile( FindFileData.cFileName, i++ ); + } while( FindNextFile( hFind, &FindFileData ) ); + FindClose( hFind ); } #else - DIR *dir = opendir(path.c_str()); + DIR * dir = opendir( path.c_str() ); ClearFileList(); - for(struct dirent *d = readdir(dir); d != NULL; d = readdir(dir)) { - InsertFile(d->d_name, Position(d->d_name)); + for( struct dirent * d = readdir( dir ); d != NULL; d = readdir( dir ) ) { + InsertFile( d->d_name, Position( d->d_name ) ); } - closedir(dir); + closedir( dir ); #endif } else { std::cout << "not a directory: " << path << "!" << std::endl; @@ -188,16 +182,15 @@ bool DirObj::Reset(const std::string &path) // /////////////////////////////////////////////////////////////////////////////// -bool DirObj::IsADirectory(const char *path) -{ +bool DirObj::IsADirectory( const char * path ) { #ifdef _WIN32 - if(PathIsDirectory(path)) { + if( PathIsDirectory( path ) ) { return true; } return false; #else struct stat st; - return stat(path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR; + return stat( path, &st ) == 0 && ( st.st_mode & S_IFMT ) == S_IFDIR; #endif } @@ -222,36 +215,35 @@ bool DirObj::IsADirectory(const char *path) // /////////////////////////////////////////////////////////////////////////////// -std::string DirObj::Normalize(const std::string &path) -{ +std::string DirObj::Normalize( const std::string & path ) { std::string buf; - const char *slash; + const char * slash; #ifdef _WIN32 char b[MAX_PATH]; - PathCanonicalize(b, path.c_str()); + PathCanonicalize( b, path.c_str() ); slash = "\\"; #else - char *b; - b = realpath(path.c_str(), 0); + char * b; + b = realpath( path.c_str(), 0 ); slash = "/"; #endif - if(b == 0) { + if( b == 0 ) { buf.clear(); } else { - buf.assign(b); + buf.assign( b ); #if !defined(_WIN32) - free(b); + free(b); #endif } - if(buf.empty()) { + if( buf.empty() ) { buf = "."; - buf.append(slash); + buf.append( slash ); // if buf is a path to a directory and doesn't end with '/' - } else if(IsADirectory(buf.c_str()) && buf[buf.size()] != slash[0]) { - buf.append(slash); + } else if( IsADirectory( buf.c_str() ) && buf[buf.size()] != slash[0] ) { + buf.append( slash ); } return buf; } @@ -262,18 +254,17 @@ std::string DirObj::Normalize(const std::string &path) // /////////////////////////////////////////////////////////////////////////////// -const char *DirObj::ValidDirectories(const char *path) -{ +const char * DirObj::ValidDirectories( const char * path ) { #ifdef _WIN32 static char buf[MAX_PATH + 1]; #else static char buf[MAXPATHLEN + 1]; #endif - strcpy(buf, path); - int i = strlen(path); + strcpy( buf, path ); + int i = strlen( path ); - while(!IsADirectory(RealPath(buf)) && i >= 0) { - for(--i; buf[i] != '/' && i >= 0; --i) { + while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) { + for( --i; buf[i] != '/' && i >= 0; --i ) { ; } buf[i + 1] = '\0'; @@ -288,14 +279,13 @@ const char *DirObj::ValidDirectories(const char *path) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::CheckIndex(int index) -{ - char **newstrbuf; +void DirObj::CheckIndex( int index ) { + char ** newstrbuf; - if(index >= fileListSize) { - fileListSize = (index + 1) * 2; - newstrbuf = new char *[fileListSize]; - memmove(newstrbuf, fileList, fileCount * sizeof(char *)); + if( index >= fileListSize ) { + fileListSize = ( index + 1 ) * 2; + newstrbuf = new char*[fileListSize]; + memmove( newstrbuf, fileList, fileCount * sizeof( char * ) ); delete [] fileList; fileList = newstrbuf; } @@ -307,23 +297,22 @@ void DirObj::CheckIndex(int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::InsertFile(const char *f, int index) -{ - char **spot; - index = (index < 0) ? fileCount : index; +void DirObj::InsertFile( const char * f, int index ) { + char ** spot; + index = ( index < 0 ) ? fileCount : index; - if(index < fileCount) { - CheckIndex(fileCount + 1); + if( index < fileCount ) { + CheckIndex( fileCount + 1 ); spot = &fileList[index]; - memmove(spot + 1, spot, (fileCount - index)*sizeof(char *)); + memmove( spot + 1, spot, ( fileCount - index )*sizeof( char * ) ); } else { - CheckIndex(index); + CheckIndex( index ); spot = &fileList[index]; } #ifdef _MSC_VER - char *string = _strdup(f); + char * string = _strdup( f ); #else - char *string = strdup(f); + char * string = strdup( f ); #endif *spot = string; ++fileCount; @@ -335,12 +324,11 @@ void DirObj::InsertFile(const char *f, int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::RemoveFile(int index) -{ - if(index < --fileCount) { - const char **spot = (const char **)&fileList[index]; +void DirObj::RemoveFile( int index ) { + if( index < --fileCount ) { + const char ** spot = ( const char ** )&fileList[index]; delete spot; - memmove(spot, spot + 1, (fileCount - index)*sizeof(char *)); + memmove( spot, spot + 1, ( fileCount - index )*sizeof( char * ) ); } } @@ -350,10 +338,9 @@ void DirObj::RemoveFile(int index) // /////////////////////////////////////////////////////////////////////////////// -void DirObj::ClearFileList() -{ - for(int i = 0; i < fileCount; ++i) { - free(fileList[i]); +void DirObj::ClearFileList() { + for( int i = 0; i < fileCount; ++i ) { + free( fileList[i] ); } fileCount = 0; } @@ -365,12 +352,11 @@ void DirObj::ClearFileList() // /////////////////////////////////////////////////////////////////////////////// -int DirObj::Position(const char *f) -{ +int DirObj::Position( const char * f ) { int i; - for(i = 0; i < fileCount; ++i) { - if(strcmp(f, fileList[i]) < 0) { + for( i = 0; i < fileCount; ++i ) { + if( strcmp( f, fileList[i] ) < 0 ) { return i; } } diff --git a/src/clutils/dirobj.h b/src/clutils/dirobj.h index 534d9bc97..a89e28dad 100644 --- a/src/clutils/dirobj.h +++ b/src/clutils/dirobj.h @@ -47,63 +47,57 @@ /*****************************************************************************/ -class SC_UTILS_EXPORT DirObj -{ +class SC_UTILS_EXPORT DirObj { public: - DirObj(const char *dirName); + DirObj( const char * dirName ); virtual ~DirObj(); - bool LoadDirectory(const std::string &name); - static std::string Normalize(const std::string &s); + bool LoadDirectory( const std::string & name ); + static std::string Normalize( const std::string & s ); - const char *ValidDirectories(const char *); + const char * ValidDirectories( const char * ); - int Index(const char *); - const char *File(int index); + int Index( const char * ); + const char * File( int index ); // check for file in the currently loaded directory - bool FileExists(const char *file) - { - return Index(file) ? 1 : 0; + bool FileExists( const char * file ) { + return Index( file ) ? 1 : 0; } - bool FileExists(const std::string &file) - { - return Index(file.c_str()) ? true : false; + bool FileExists( const std::string & file ) { + return Index( file.c_str() ) ? true : false; } int Count(); - static bool IsADirectory(const char *); + static bool IsADirectory( const char * ); private: - const char *RealPath(const char *); + const char * RealPath( const char * ); - bool Reset(const std::string &path); + bool Reset( const std::string & path ); void ClearFileList(); - void CheckIndex(int index); - void InsertFile(const char *, int index); - void AppendFile(const char *); - void RemoveFile(int index); - virtual int Position(const char *); + void CheckIndex( int index ); + void InsertFile( const char *, int index ); + void AppendFile( const char * ); + void RemoveFile( int index ); + virtual int Position( const char * ); private: - char **fileList; + char ** fileList; int fileCount; int fileListSize; }; // Return the number of files in the loaded directory. -inline int DirObj::Count() -{ +inline int DirObj::Count() { return fileCount; } // Insert a new file into the fileList. -inline void DirObj::AppendFile(const char *s) -{ - InsertFile(s, fileCount); +inline void DirObj::AppendFile( const char * s ) { + InsertFile( s, fileCount ); } // Return the file at the given index (starting at 0) in the fileList -inline const char *DirObj::File(int index) -{ - return (0 <= index && index < fileCount) ? fileList[index] : 0; +inline const char * DirObj::File( int index ) { + return ( 0 <= index && index < fileCount ) ? fileList[index] : 0; } #endif diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index 9d76c6e22..c5a998c8c 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -15,60 +15,58 @@ #include DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; -ostream *ErrorDescriptor::_out = 0; +ostream * ErrorDescriptor::_out = 0; void -ErrorDescriptor::PrintContents(ostream &out) const -{ +ErrorDescriptor::PrintContents( ostream & out ) const { out << "Severity: " << severityString() << endl; - if(!_userMsg.empty()) { + if( !_userMsg.empty() ) { out << "User message in parens:" << endl << "("; out << UserMsg() << ")" << endl; } - if(!_detailMsg.empty()) { + if( !_detailMsg.empty() ) { out << "Detailed message in parens:" << endl << "("; out << DetailMsg() << ")" << endl; } } -std::string ErrorDescriptor::severityString() const -{ +std::string ErrorDescriptor::severityString() const { std::string s; - switch(severity()) { + switch( severity() ) { case SEVERITY_NULL : { - s.assign("SEVERITY_NULL"); + s.assign( "SEVERITY_NULL" ); break; } case SEVERITY_USERMSG : { - s.assign("SEVERITY_USERMSG"); + s.assign( "SEVERITY_USERMSG" ); break; } case SEVERITY_INCOMPLETE : { - s.assign("SEVERITY_INCOMPLETE"); + s.assign( "SEVERITY_INCOMPLETE" ); break; } case SEVERITY_WARNING : { - s.assign("SEVERITY_WARNING"); + s.assign( "SEVERITY_WARNING" ); break; } case SEVERITY_INPUT_ERROR : { - s.assign("SEVERITY_INPUT_ERROR"); + s.assign( "SEVERITY_INPUT_ERROR" ); break; } case SEVERITY_BUG : { - s.assign("SEVERITY_BUG"); + s.assign( "SEVERITY_BUG" ); break; } case SEVERITY_EXIT : { - s.assign("SEVERITY_EXIT"); + s.assign( "SEVERITY_EXIT" ); break; } case SEVERITY_DUMP : { - s.assign("SEVERITY_DUMP"); + s.assign( "SEVERITY_DUMP" ); break; } case SEVERITY_MAX : { - s.assign("SEVERITY_MAX"); + s.assign( "SEVERITY_MAX" ); break; } } @@ -77,36 +75,35 @@ std::string ErrorDescriptor::severityString() const Severity -ErrorDescriptor::GetCorrSeverity(const char *s) -{ - if(s && s[0] != 0) { +ErrorDescriptor::GetCorrSeverity( const char * s ) { + if( s && s[0] != 0 ) { std::string s2; - StrToUpper(s, s2); - if(!s2.compare("SEVERITY_NULL")) { + StrToUpper( s, s2 ); + if( !s2.compare( "SEVERITY_NULL" ) ) { return SEVERITY_NULL; } - if(!s2.compare("SEVERITY_USERMSG")) { + if( !s2.compare( "SEVERITY_USERMSG" ) ) { return SEVERITY_USERMSG; } - if(!s2.compare("SEVERITY_INCOMPLETE")) { + if( !s2.compare( "SEVERITY_INCOMPLETE" ) ) { return SEVERITY_INCOMPLETE; } - if(!s2.compare("SEVERITY_WARNING")) { + if( !s2.compare( "SEVERITY_WARNING" ) ) { return SEVERITY_WARNING; } - if(!s2.compare("SEVERITY_INPUT_ERROR")) { + if( !s2.compare( "SEVERITY_INPUT_ERROR" ) ) { return SEVERITY_INPUT_ERROR; } - if(!s2.compare("SEVERITY_BUG")) { + if( !s2.compare( "SEVERITY_BUG" ) ) { return SEVERITY_BUG; } - if(!s2.compare("SEVERITY_EXIT")) { + if( !s2.compare( "SEVERITY_EXIT" ) ) { return SEVERITY_EXIT; } - if(!s2.compare("SEVERITY_DUMP")) { + if( !s2.compare( "SEVERITY_DUMP" ) ) { return SEVERITY_DUMP; } - if(!s2.compare("SEVERITY_MAX")) { + if( !s2.compare( "SEVERITY_MAX" ) ) { return SEVERITY_MAX; } } @@ -116,53 +113,43 @@ ErrorDescriptor::GetCorrSeverity(const char *s) return SEVERITY_BUG; } -ErrorDescriptor::ErrorDescriptor(Severity s, DebugLevel d) : _severity(s) -{ - if(d != DEBUG_OFF) { +ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) { + if( d != DEBUG_OFF ) { _debug_level = d; } } -ErrorDescriptor::~ErrorDescriptor(void) -{ +ErrorDescriptor::~ErrorDescriptor( void ) { } -void ErrorDescriptor::UserMsg(const char *msg) -{ - _userMsg.assign(msg); +void ErrorDescriptor::UserMsg( const char * msg ) { + _userMsg.assign( msg ); } -void ErrorDescriptor::PrependToUserMsg(const char *msg) -{ - _userMsg.insert(0, msg); +void ErrorDescriptor::PrependToUserMsg( const char * msg ) { + _userMsg.insert( 0, msg ); } -void ErrorDescriptor::AppendToUserMsg(const char c) -{ - _userMsg.push_back(c); +void ErrorDescriptor::AppendToUserMsg( const char c ) { + _userMsg.push_back( c ); } -void ErrorDescriptor::AppendToUserMsg(const char *msg) -{ - _userMsg.append(msg); +void ErrorDescriptor::AppendToUserMsg( const char * msg ) { + _userMsg.append( msg ); } -void ErrorDescriptor::DetailMsg(const char *msg) -{ - _detailMsg.assign(msg); +void ErrorDescriptor::DetailMsg( const char * msg ) { + _detailMsg.assign( msg ); } -void ErrorDescriptor::PrependToDetailMsg(const char *msg) -{ - _detailMsg.insert(0, msg); +void ErrorDescriptor::PrependToDetailMsg( const char * msg ) { + _detailMsg.insert( 0, msg ); } -void ErrorDescriptor::AppendToDetailMsg(const char c) -{ - _detailMsg.push_back(c); +void ErrorDescriptor::AppendToDetailMsg( const char c ) { + _detailMsg.push_back( c ); } -void ErrorDescriptor::AppendToDetailMsg(const char *msg) -{ - _detailMsg.append(msg); +void ErrorDescriptor::AppendToDetailMsg( const char * msg ) { + _detailMsg.append( msg ); } diff --git a/src/clutils/errordesc.h b/src/clutils/errordesc.h index c2c3671e4..4ab284b2d 100644 --- a/src/clutils/errordesc.h +++ b/src/clutils/errordesc.h @@ -53,8 +53,7 @@ typedef int DebugLevel; ** Status: ******************************************************************/ -class SC_UTILS_EXPORT ErrorDescriptor -{ +class SC_UTILS_EXPORT ErrorDescriptor { private: #ifdef _MSC_VER #pragma warning( push ) @@ -68,90 +67,76 @@ class SC_UTILS_EXPORT ErrorDescriptor Severity _severity; static DebugLevel _debug_level; - static ostream *_out; // note this will not be persistent + static ostream * _out; // note this will not be persistent public: - ErrorDescriptor(Severity s = SEVERITY_NULL, - DebugLevel d = DEBUG_OFF); - ~ErrorDescriptor(void); + ErrorDescriptor( Severity s = SEVERITY_NULL, + DebugLevel d = DEBUG_OFF ); + ~ErrorDescriptor( void ); - void PrintContents(ostream &out = cout) const; + void PrintContents( ostream & out = cout ) const; - void ClearErrorMsg() - { + void ClearErrorMsg() { _severity = SEVERITY_NULL; _userMsg.clear(); _detailMsg.clear(); } // return the enum value of _severity - Severity severity() const - { + Severity severity() const { return _severity; } - Severity severity(Severity s) - { - return (_severity = s); + Severity severity( Severity s ) { + return ( _severity = s ); } std::string severityString() const; - Severity GetCorrSeverity(const char *s); - Severity GreaterSeverity(Severity s) - { - return ((s < _severity) ? _severity = s : _severity); + Severity GetCorrSeverity( const char * s ); + Severity GreaterSeverity( Severity s ) { + return ( ( s < _severity ) ? _severity = s : _severity ); } - std::string UserMsg() const - { + std::string UserMsg() const { return _userMsg; } - void UserMsg(const char *msg); - void UserMsg(const std::string msg) - { - _userMsg.assign(msg); + void UserMsg( const char * msg ); + void UserMsg( const std::string msg ) { + _userMsg.assign( msg ); } - void AppendToUserMsg(const char *msg); - void AppendToUserMsg(const char c); - void AppendToUserMsg(const std::string &msg) - { - _userMsg.append(msg); + void AppendToUserMsg( const char * msg ); + void AppendToUserMsg( const char c ); + void AppendToUserMsg( const std::string & msg ) { + _userMsg.append( msg ); } - void PrependToUserMsg(const char *msg); + void PrependToUserMsg( const char * msg ); - std::string DetailMsg() const - { + std::string DetailMsg() const { return _detailMsg; } - void DetailMsg(const std::string msg) - { - _detailMsg.assign(msg); + void DetailMsg( const std::string msg ) { + _detailMsg.assign( msg ); } - void DetailMsg(const char *msg); - void AppendToDetailMsg(const char *msg); - void AppendToDetailMsg(const std::string &msg) - { - _detailMsg.append(msg); + void DetailMsg( const char * msg ); + void AppendToDetailMsg( const char * msg ); + void AppendToDetailMsg( const std::string & msg ) { + _detailMsg.append( msg ); } - void PrependToDetailMsg(const char *msg); - void AppendToDetailMsg(const char c); - - Severity AppendFromErrorArg(ErrorDescriptor *err) - { - GreaterSeverity(err->severity()); - AppendToDetailMsg(err->DetailMsg()); - AppendToUserMsg(err->UserMsg()); + void PrependToDetailMsg( const char * msg ); + void AppendToDetailMsg( const char c ); + + Severity AppendFromErrorArg( ErrorDescriptor * err ) { + GreaterSeverity( err->severity() ); + AppendToDetailMsg( err->DetailMsg() ); + AppendToUserMsg( err->UserMsg() ); return severity(); } - DebugLevel debug_level() const - { + DebugLevel debug_level() const { return _debug_level; } - void debug_level(DebugLevel d) - { + void debug_level( DebugLevel d ) { _debug_level = d; } - void SetOutput(ostream *o) - { + void SetOutput( ostream * o ) { _out = o; } } ; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index b29c021a2..3036ab19d 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -24,12 +24,11 @@ // void GenNodeList::Append(GenericNode *node) from the gennodelist.h ////////////////////////////////////////////////////////////////////////////// -void GenericNode::Append(GenNodeList *list) -{ +void GenericNode::Append( GenNodeList * list ) { // if(debug_level >= PrintFunctionTrace) // cout << "GenericNode::Append()\n"; // if(debug_level >= PrintValues) // cout << "GenericNode::this : '" << this << "'\n"; - list->Append(this); + list->Append( this ); } diff --git a/src/clutils/gennode.h b/src/clutils/gennode.h index f8285a827..c4c630244 100644 --- a/src/clutils/gennode.h +++ b/src/clutils/gennode.h @@ -27,32 +27,28 @@ class DisplayNodeList; // If you delete this object it first removes itself from any list it is in. ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenericNode -{ +class SC_UTILS_EXPORT GenericNode { friend class GenNodeList; friend class MgrNodeList; friend class DisplayNodeList; protected: - GenericNode *next; - GenericNode *prev; + GenericNode * next; + GenericNode * prev; public: GenericNode(); virtual ~GenericNode(); - GenericNode *Next() - { + GenericNode * Next() { return next; } - GenericNode *Prev() - { + GenericNode * Prev() { return prev; } - virtual void Append(GenNodeList *list); - virtual void Remove() - { - (next) ? (next->prev = prev) : 0; - (prev) ? (prev->next = next) : 0; + virtual void Append( GenNodeList * list ); + virtual void Remove() { + ( next ) ? ( next->prev = prev ) : 0; + ( prev ) ? ( prev->next = next ) : 0; /* // if(next) // next->prev = prev; diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index 16e3a3b7b..f78acbd14 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -20,79 +20,70 @@ #ifndef HAVE_MEMMOVE extern "C" { - extern void *memmove(void *, const void *, size_t); + extern void * memmove( void *, const void *, size_t ); } #endif -GenericNode::GenericNode() -{ +GenericNode::GenericNode() { next = 0; prev = 0; } -GenericNode::~GenericNode() -{ +GenericNode::~GenericNode() { Remove(); } -GenNodeArray::GenNodeArray(int defaultSize) -{ +GenNodeArray::GenNodeArray( int defaultSize ) { _bufsize = defaultSize; _buf = new GenericNode*[_bufsize]; - memset(_buf, 0, _bufsize * sizeof(GenericNode *)); + memset( _buf, 0, _bufsize * sizeof( GenericNode * ) ); _count = 0; } -GenNodeArray::~GenNodeArray() -{ +GenNodeArray::~GenNodeArray() { delete [] _buf; } -int GenNodeArray::Index(GenericNode **gn) -{ - return ((gn - _buf) / sizeof(GenericNode *)); +int GenNodeArray::Index( GenericNode ** gn ) { + return ( ( gn - _buf ) / sizeof( GenericNode * ) ); } -void GenNodeArray::Append(GenericNode *gn) -{ - Insert(gn, _count); +void GenNodeArray::Append( GenericNode * gn ) { + Insert( gn, _count ); } -int GenNodeArray::Insert(GenericNode *gn) -{ - return Insert(gn, _count); +int GenNodeArray::Insert( GenericNode * gn ) { + return Insert( gn, _count ); } void -GenNodeArray::Check(int index) -{ - GenericNode **newbuf; +GenNodeArray::Check( int index ) { + GenericNode ** newbuf; - if(index >= _bufsize) { - _bufsize = (index + 1) * 2; + if( index >= _bufsize ) { + _bufsize = ( index + 1 ) * 2; newbuf = new GenericNode*[_bufsize]; - memset(newbuf, 0, _bufsize * sizeof(GenericNode *)); - memmove(newbuf, _buf, _count * sizeof(GenericNode *)); + memset( newbuf, 0, _bufsize * sizeof( GenericNode * ) ); + memmove( newbuf, _buf, _count * sizeof( GenericNode * ) ); delete [] _buf; _buf = newbuf; } } int -GenNodeArray::Insert(GenericNode *gn, int index) -{ - const GenericNode **spot; - index = (index < 0) ? _count : index; +GenNodeArray::Insert( GenericNode * gn, int index ) { + const GenericNode ** spot; + index = ( index < 0 ) ? _count : index; - if(index < _count) { - Check(_count + 1); - spot = (const GenericNode **)&_buf[index]; - memmove(spot + 1, spot, (_count - index)*sizeof(GenericNode *)); + if( index < _count ) { + Check( _count + 1 ); + spot = ( const GenericNode ** )&_buf[index]; + memmove( spot + 1, spot, ( _count - index )*sizeof( GenericNode * ) ); } else { - Check(index); - spot = (const GenericNode **)&_buf[index]; + Check( index ); + spot = ( const GenericNode ** )&_buf[index]; } *spot = gn; ++_count; @@ -100,39 +91,35 @@ GenNodeArray::Insert(GenericNode *gn, int index) } void -GenNodeArray::Remove(int index) -{ - if(0 <= index && index < _count) { +GenNodeArray::Remove( int index ) { + if( 0 <= index && index < _count ) { --_count; - const GenericNode **spot = (const GenericNode **)&_buf[index]; - memmove(spot, spot + 1, (_count - index)*sizeof(GenericNode *)); + const GenericNode ** spot = ( const GenericNode ** )&_buf[index]; + memmove( spot, spot + 1, ( _count - index )*sizeof( GenericNode * ) ); _buf[_count] = 0; } } -void GenNodeArray::ClearEntries() -{ +void GenNodeArray::ClearEntries() { int i; - for(i = 0 ; i < _count; i++) { + for( i = 0 ; i < _count; i++ ) { _buf[i] = 0; } _count = 0; } -void GenNodeArray::DeleteEntries() -{ +void GenNodeArray::DeleteEntries() { int i; - for(i = 0 ; i < _count; i++) { - delete(_buf[i]); + for( i = 0 ; i < _count; i++ ) { + delete( _buf[i] ); } _count = 0; } -int GenNodeArray::Index(GenericNode *gn) -{ - for(int i = 0; i < _count; ++i) { - if(_buf[i] == gn) { +int GenNodeArray::Index( GenericNode * gn ) { + for( int i = 0; i < _count; ++i ) { + if( _buf[i] == gn ) { return i; } } diff --git a/src/clutils/gennodearray.h b/src/clutils/gennodearray.h index 19de427c1..4c0ee075a 100644 --- a/src/clutils/gennodearray.h +++ b/src/clutils/gennodearray.h @@ -38,30 +38,29 @@ // DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeArray -{ +class SC_UTILS_EXPORT GenNodeArray { public: - GenNodeArray(int defaultSize = ARRAY_DEFAULT_SIZE); + GenNodeArray( int defaultSize = ARRAY_DEFAULT_SIZE ); virtual ~GenNodeArray(); - GenericNode *&operator[](int index); - virtual int Index(GenericNode *gn); - virtual int Index(GenericNode **gn); + GenericNode *& operator[]( int index ); + virtual int Index( GenericNode * gn ); + virtual int Index( GenericNode ** gn ); int Count() const; - virtual void Append(GenericNode *gn); - virtual int Insert(GenericNode *gn); - virtual int Insert(GenericNode *gn, int index); - virtual void Remove(int index); + virtual void Append( GenericNode * gn ); + virtual int Insert( GenericNode * gn ); + virtual int Insert( GenericNode * gn, int index ); + virtual void Remove( int index ); virtual void ClearEntries(); virtual void DeleteEntries(); protected: - virtual void Check(int index); + virtual void Check( int index ); - GenericNode **_buf; // the array + GenericNode ** _buf; // the array int _bufsize; // the possible number of entries in the array int _count; // the number of entries in the array }; @@ -70,14 +69,12 @@ class SC_UTILS_EXPORT GenNodeArray // class GenNodeArray inline public functions ////////////////////////////////////////////////////////////////////////////// -inline GenericNode *&GenNodeArray::operator[](int index) -{ - Check(index); +inline GenericNode *& GenNodeArray::operator[]( int index ) { + Check( index ); return _buf[index]; } -inline int GenNodeArray::Count() const -{ +inline int GenNodeArray::Count() const { return _count; } diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index 478601172..9560a72b1 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -19,9 +19,8 @@ #include // inserts after existNode -void GenNodeList::InsertAfter(GenericNode *newNode, - GenericNode *existNode) -{ +void GenNodeList::InsertAfter( GenericNode * newNode, + GenericNode * existNode ) { newNode->next = existNode->next; newNode->next->prev = newNode; @@ -30,9 +29,8 @@ void GenNodeList::InsertAfter(GenericNode *newNode, } // inserts before existNode -void GenNodeList::InsertBefore(GenericNode *newNode, - GenericNode *existNode) -{ +void GenNodeList::InsertBefore( GenericNode * newNode, + GenericNode * existNode ) { existNode->prev->next = newNode; newNode->prev = existNode->prev; @@ -41,29 +39,26 @@ void GenNodeList::InsertBefore(GenericNode *newNode, } // inserts before the head node -void GenNodeList::Append(GenericNode *node) -{ - InsertBefore(node, head); +void GenNodeList::Append( GenericNode * node ) { + InsertBefore( node, head ); } void -GenNodeList::Remove(GenericNode *node) -{ - if(node != head) { +GenNodeList::Remove( GenericNode * node ) { + if( node != head ) { node->next->prev = node->prev; node->prev->next = node->next; node->next = 0; node->prev = 0; } } -void GenNodeList::ClearEntries() -{ +void GenNodeList::ClearEntries() { // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::ClearEntries()\n"; - GenericNode *gnPrev = head->Next(); - GenericNode *gn = gnPrev->Next(); + GenericNode * gnPrev = head->Next(); + GenericNode * gn = gnPrev->Next(); - while(gnPrev != head) { + while( gnPrev != head ) { gnPrev->prev = 0; gnPrev->next = 0; gnPrev = gn; @@ -73,15 +68,14 @@ void GenNodeList::ClearEntries() head->prev = head; } -void GenNodeList::DeleteEntries() -{ +void GenNodeList::DeleteEntries() { // if(debug_level >= PrintFunctionTrace) // cout << "GenNodeList::DeleteEntries()\n"; - GenericNode *gnPrev = head->Next(); - GenericNode *gn; + GenericNode * gnPrev = head->Next(); + GenericNode * gn; head->next = 0; - while(gnPrev != head) { + while( gnPrev != head ) { gn = gnPrev->Next(); delete gnPrev; gnPrev = gn; diff --git a/src/clutils/gennodelist.h b/src/clutils/gennodelist.h index 3ba1f50c2..4751f6044 100644 --- a/src/clutils/gennodelist.h +++ b/src/clutils/gennodelist.h @@ -26,33 +26,30 @@ // as its head, you need to call DeleteEntries(). ////////////////////////////////////////////////////////////////////////////// -class SC_UTILS_EXPORT GenNodeList -{ +class SC_UTILS_EXPORT GenNodeList { public: - GenNodeList(GenericNode *headNode); - virtual ~GenNodeList() - { + GenNodeList( GenericNode * headNode ); + virtual ~GenNodeList() { delete head; } - GenericNode *GetHead() - { + GenericNode * GetHead() { return head; } virtual void ClearEntries(); virtual void DeleteEntries(); // deletes node from its previous list & appends - virtual void Append(GenericNode *node); + virtual void Append( GenericNode * node ); // deletes newNode from its previous list & inserts in // relation to existNode - virtual void InsertAfter(GenericNode *newNode, GenericNode *existNode); - virtual void InsertBefore(GenericNode *newNode, GenericNode *existNode); + virtual void InsertAfter( GenericNode * newNode, GenericNode * existNode ); + virtual void InsertBefore( GenericNode * newNode, GenericNode * existNode ); - virtual void Remove(GenericNode *node); + virtual void Remove( GenericNode * node ); protected: - GenericNode *head; + GenericNode * head; }; ////////////////////////////////////////////////////////////////////////////// @@ -61,8 +58,7 @@ class SC_UTILS_EXPORT GenNodeList // other classes) that aren't in this file ////////////////////////////////////////////////////////////////////////////// -inline GenNodeList::GenNodeList(GenericNode *headNode) -{ +inline GenNodeList::GenNodeList( GenericNode * headNode ) { head = headNode; head->next = head; head->prev = head; diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index c2c884d72..706780411 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -32,46 +32,43 @@ /* typedefs */ typedef unsigned long Address; -typedef struct Element *ElementP; -typedef struct Hash_Table *Hash_TableP; +typedef struct Element * ElementP; +typedef struct Hash_Table * Hash_TableP; /* Internal routines */ -Address SC_HASHhash(char *, Hash_TableP); -static void SC_HASHexpand_table(Hash_TableP); +Address SC_HASHhash( char *, Hash_TableP ); +static void SC_HASHexpand_table( Hash_TableP ); # ifdef HASH_STATISTICS static long HashAccesses, HashCollisions; # endif /// find entry in given hash table -void *SC_HASHfind(Hash_TableP t, char *s) -{ +void * SC_HASHfind( Hash_TableP t, char * s ) { struct Element e; - struct Element *ep; + struct Element * ep; e.key = s; e.symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ - ep = SC_HASHsearch(t, &e, HASH_FIND); - return(ep ? ep->data : 0); + ep = SC_HASHsearch( t, &e, HASH_FIND ); + return( ep ? ep->data : 0 ); } /// insert entry into given hash table -void SC_HASHinsert(Hash_TableP t, char *s, void *data) -{ +void SC_HASHinsert( Hash_TableP t, char * s, void * data ) { struct Element e, *e2; e.key = s; e.data = data; e.symbol = 0; - e2 = SC_HASHsearch(t, &e, HASH_INSERT); - if(e2) { - fprintf(stderr, "%s: Redeclaration of %s\n", __func__, s); + e2 = SC_HASHsearch( t, &e, HASH_INSERT ); + if( e2 ) { + fprintf( stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s ); } } /// create a hash table -Hash_TableP SC_HASHcreate(unsigned count) -{ +Hash_TableP SC_HASHcreate( unsigned count ) { unsigned int i; Hash_TableP table; @@ -80,52 +77,51 @@ Hash_TableP SC_HASHcreate(unsigned count) ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while(i < count) { + while( i < count ) { i <<= 1; } - count = DIV(i, SEGMENT_SIZE); + count = DIV( i, SEGMENT_SIZE ); - table = (Hash_TableP) SC_HASH_Table_new(); + table = ( Hash_TableP ) SC_HASH_Table_new(); table->SegmentCount = table->p = table->KeyCount = 0; /* ** First initialize directory to 0\'s ** DIRECTORY_SIZE must be same as in header */ - for(i = 0; i < DIRECTORY_SIZE; i++) { + for( i = 0; i < DIRECTORY_SIZE; i++ ) { table->Directory[i] = 0; } /* ** Allocate initial 'i' segments of buckets */ - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { table->Directory[i] = new struct Element * [SEGMENT_SIZE]; - for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL + for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL table->Directory[i][h] = 0; } } table->SegmentCount = count; - table->maxp = MUL(count, SEGMENT_SIZE); + table->maxp = MUL( count, SEGMENT_SIZE ); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef DEBUG - fprintf(stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount); + fprintf( stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount ); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return(table); + return( table ); } /** initialize pointer to beginning of hash table so we can * step through it on repeated calls to HASHlist - DEL */ -void SC_HASHlistinit(Hash_TableP table, HashEntry *he) -{ +void SC_HASHlistinit( Hash_TableP table, HashEntry * he ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -133,8 +129,7 @@ void SC_HASHlistinit(Hash_TableP table, HashEntry *he) he->e = 0; } -void SC_HASHlistinit_by_type(Hash_TableP table, HashEntry *he, char type) -{ +void SC_HASHlistinit_by_type( Hash_TableP table, HashEntry * he, char type ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -143,19 +138,18 @@ void SC_HASHlistinit_by_type(Hash_TableP table, HashEntry *he, char type) } /** provide a way to step through the hash */ -struct Element *SC_HASHlist(HashEntry *he) -{ +struct Element * SC_HASHlist( HashEntry * he ) { int i2 = he->i; int j2 = he->j; - struct Element **s; + struct Element ** s; he->e = 0; - for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { + for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { /* test probably unnecessary */ - if((s = he->table->Directory[he->i]) != NULL) { - for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { - if(!he->p) { + if( ( s = he->table->Directory[he->i] ) != NULL ) { + for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { + if( !he->p ) { he->p = s[he->j]; } @@ -163,45 +157,44 @@ struct Element *SC_HASHlist(HashEntry *he) setting it to he->e) and begin looking for a new value for he->p */ - while(he->p && he->type != '*' && he->type != he->p->type) { + while( he->p && he->type != '*' && he->type != he->p->type ) { he->p = he->p->next; } - if(he->p) { - if(he->e) { - return(he->e); + if( he->p ) { + if( he->e ) { + return( he->e ); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if(he->p) { - return(he->e); + if( he->p ) { + return( he->e ); } } j2 = 0; } } /* if he->e was set then it is last one */ - return(he->e); + return( he->e ); } /// destroy all elements in given table, then the table itself -void SC_HASHdestroy(Hash_TableP table) -{ - struct Element **s; - struct Element *p, *q; +void SC_HASHdestroy( Hash_TableP table ) { + struct Element ** s; + struct Element * p, *q; - if(table != HASH_NULL) { + if( table != HASH_NULL ) { unsigned int i, j; - for(i = 0; i < table->SegmentCount; i++) { + for( i = 0; i < table->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = table->Directory[i]) != NULL) { - for(j = 0; j < SEGMENT_SIZE; j++) { + if( ( s = table->Directory[i] ) != NULL ) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { p = s[j]; - while(p != NULL) { + while( p != NULL ) { q = p->next; - SC_HASH_Element_destroy(p); + SC_HASH_Element_destroy( p ); p = q; } } @@ -209,30 +202,29 @@ void SC_HASHdestroy(Hash_TableP table) delete [] table->Directory[i]; } } - SC_HASH_Table_destroy(table); + SC_HASH_Table_destroy( table ); # if defined(HASH_STATISTICS) && defined(DEBUG) - fprintf(stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions); + fprintf( stderr, "[hdestroy] Accesses %ld Collisions %ld\n", HashAccesses, HashCollisions ); # endif } } /// search table for 'item', perform 'action' (find/insert/delete) -struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Action action) -{ +struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, Action action ) { Address h; - struct Element **CurrentSegment; + struct Element ** CurrentSegment; int SegmentIndex; int SegmentDir; - struct Element **p; - struct Element *q; - struct Element *deleteme; + struct Element ** p; + struct Element * q; + struct Element * deleteme; # ifdef HASH_STATISTICS HashAccesses++; # endif - h = SC_HASHhash(item->key, table); - SegmentDir = (int) DIV(h, SEGMENT_SIZE); - SegmentIndex = (int) MOD(h, SEGMENT_SIZE); + h = SC_HASHhash( item->key, table ); + SegmentDir = ( int ) DIV( h, SEGMENT_SIZE ); + SegmentIndex = ( int ) MOD( h, SEGMENT_SIZE ); /* ** valid segment ensured by HASHhash() */ @@ -245,7 +237,7 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act ** p = &element, and ** q = element */ - while(q != NULL && strcmp(q->key, item->key)) { + while( q != NULL && strcmp( q->key, item->key ) ) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -253,28 +245,28 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act # endif } /* at this point, we have either found the element or it doesn't exist */ - switch(action) { + switch( action ) { case HASH_FIND: - return((struct Element *)q); + return( ( struct Element * )q ); case HASH_DELETE: - if(!q) { - return(0); + if( !q ) { + return( 0 ); } /* at this point, element exists and action == DELETE */ deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - SC_HASH_Element_destroy(deleteme); + SC_HASH_Element_destroy( deleteme ); --table->KeyCount; - return(deleteme); /* of course, user shouldn't deref this! */ + return( deleteme ); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if(q != NULL) { - return(q); /* was return(0);!!!!!?!?! */ + if( q != NULL ) { + return( q ); /* was return(0);!!!!!?!?! */ } /* at this point, element does not exist and action == INSERT */ - q = (ElementP) SC_HASH_Element_new(); + q = ( ElementP ) SC_HASH_Element_new(); *p = q; /* link into chain */ /* ** Initialize new element @@ -289,61 +281,59 @@ struct Element *SC_HASHsearch(Hash_TableP table, const struct Element *item, Act /* ** table over-full? */ - if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE) > table->MaxLoadFactor) { - SC_HASHexpand_table(table); /* doesn't affect q */ + if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE ) > table->MaxLoadFactor ) { + SC_HASHexpand_table( table ); /* doesn't affect q */ } } - return((struct Element *)0); /* was return (Element)q */ + return( ( struct Element * )0 ); /* was return (Element)q */ } /* ** Internal routines */ -Address SC_HASHhash(char *Key, Hash_TableP table) -{ +Address SC_HASHhash( char * Key, Hash_TableP table ) { Address h, address; - unsigned char *k = (unsigned char *)Key; + unsigned char * k = ( unsigned char * )Key; h = 0; /* ** Convert string to integer */ - while(*k) { - h = h * PRIME1 ^ (*k++ - ' '); + while( *k ) { + h = h * PRIME1 ^ ( *k++ - ' ' ); } h %= PRIME2; - address = MOD(h, table->maxp); - if(address < table->p) { - address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ + address = MOD( h, table->maxp ); + if( address < table->p ) { + address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ } - return(address); + return( address ); } -static void SC_HASHexpand_table(Hash_TableP table) -{ - struct Element **OldSegment, **NewSegment; - struct Element *Current, **Previous, **LastOfNew; +static void SC_HASHexpand_table( Hash_TableP table ) { + struct Element ** OldSegment, **NewSegment; + struct Element * Current, **Previous, **LastOfNew; - if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE)) { + if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE ) ) { /* ** Locate the bucket to be split */ Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; - OldSegmentDir = DIV(table->p, SEGMENT_SIZE); + OldSegmentDir = DIV( table->p, SEGMENT_SIZE ); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); + OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = (int) DIV(NewAddress, SEGMENT_SIZE); - NewSegmentIndex = (int) MOD(NewAddress, SEGMENT_SIZE); - if(NewSegmentIndex == 0) { + NewSegmentDir = ( int ) DIV( NewAddress, SEGMENT_SIZE ); + NewSegmentIndex = ( int ) MOD( NewAddress, SEGMENT_SIZE ); + if( NewSegmentIndex == 0 ) { table->Directory[NewSegmentDir] = new struct Element * [SEGMENT_SIZE]; - for(int h = 0; h < SEGMENT_SIZE; h++) { // initialize to NULL + for( int h = 0; h < SEGMENT_SIZE; h++ ) { // initialize to NULL table->Directory[NewSegmentDir][h] = 0; } } @@ -353,7 +343,7 @@ static void SC_HASHexpand_table(Hash_TableP table) ** Adjust state variables */ table->p++; - if(table->p == table->maxp) { + if( table->p == table->maxp ) { table->maxp <<= 1; table->p = 0; } @@ -365,8 +355,8 @@ static void SC_HASHexpand_table(Hash_TableP table) Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while(Current != NULL) { - if(SC_HASHhash(Current->key, table) == NewAddress) { + while( Current != NULL ) { + if( SC_HASHhash( Current->key, table ) == NewAddress ) { /* ** Attach it to the end of the new chain */ @@ -392,29 +382,28 @@ static void SC_HASHexpand_table(Hash_TableP table) /* for testing sc_hash */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table *t; +struct Hash_Table * t; HashEntry he; -main() -{ +main() { e1.key = "foo"; - e1.data = (char *)1; + e1.data = ( char * )1; e2.key = "bar"; - e2.data = (char *)2; + e2.data = ( char * )2; e3.key = "herschel"; - e3.data = (char *)3; - - t = SC_HASHcreate(100); - e = SC_HASHsearch(t, &e1, HASH_INSERT); - e = SC_HASHsearch(t, &e2, HASH_INSERT); - e = SC_HASHsearch(t, &e3, HASH_INSERT); - SC_HASHlistinit(t, &he); - for(;;) { - e = SC_HASHlist(&he); - if(!e) { - exit(0); + e3.data = ( char * )3; + + t = SC_HASHcreate( 100 ); + e = SC_HASHsearch( t, &e1, HASH_INSERT ); + e = SC_HASHsearch( t, &e2, HASH_INSERT ); + e = SC_HASHsearch( t, &e3, HASH_INSERT ); + SC_HASHlistinit( t, &he ); + for( ;; ) { + e = SC_HASHlist( &he ); + if( !e ) { + exit( 0 ); } - printf("found key %s, data %d\n", e->key, (int)e->data); + printf( "found key %s, data %d\n", e->key, ( int )e->data ); } } #endif diff --git a/src/clutils/sc_hash.h b/src/clutils/sc_hash.h index dde8245f3..f6a230ba9 100644 --- a/src/clutils/sc_hash.h +++ b/src/clutils/sc_hash.h @@ -96,10 +96,10 @@ typedef enum { HASH_FIND, HASH_INSERT, HASH_DELETE } Action; struct Element { - char *key; - void *data; - struct Element *next; - struct Symbol *symbol; //for debugging hash conflicts + char * key; + void * data; + struct Element * next; + struct Symbol * symbol; //for debugging hash conflicts char type; //user-supplied type }; @@ -112,16 +112,16 @@ struct Hash_Table { unsigned int MaxLoadFactor; #define DIRECTORY_SIZE 256 #define DIRECTORY_SIZE_SHIFT 8 // log2(DIRECTORY_SIZE) - struct Element **Directory[DIRECTORY_SIZE]; + struct Element ** Directory[DIRECTORY_SIZE]; }; typedef struct { unsigned int i; // segment index (i think) unsigned int j; // key index in segment (ditto) - struct Element *p; // usually the next element to be returned - struct Hash_Table *table; + struct Element * p; // usually the next element to be returned + struct Hash_Table * table; char type; - struct Element *e; /* originally thought of as a place for */ + struct Element * e; /* originally thought of as a place for */ /* the caller of HASHlist to temporarily stash the return value */ /* to allow the caller (i.e., DICTdo) to be macroized, but now */ /* conveniently used by HASHlist, which both stores the ultimate */ @@ -132,15 +132,15 @@ typedef struct { extern "C" { #endif -SC_UTILS_EXPORT struct Hash_Table *SC_HASHcreate(unsigned); -SC_UTILS_EXPORT void SC_HASHinitialize(void); -SC_UTILS_EXPORT void *SC_HASHfind(struct Hash_Table *, char *); -SC_UTILS_EXPORT void SC_HASHinsert(struct Hash_Table *, char *, void *); -SC_UTILS_EXPORT void SC_HASHdestroy(struct Hash_Table *); -SC_UTILS_EXPORT struct Element *SC_HASHsearch(struct Hash_Table *, const struct Element *, Action); -SC_UTILS_EXPORT void SC_HASHlistinit(struct Hash_Table *, HashEntry *); -SC_UTILS_EXPORT void SC_HASHlistinit_by_type(struct Hash_Table *, HashEntry *, char); -SC_UTILS_EXPORT struct Element *SC_HASHlist(HashEntry *); + SC_UTILS_EXPORT struct Hash_Table * SC_HASHcreate( unsigned ); + SC_UTILS_EXPORT void SC_HASHinitialize( void ); + SC_UTILS_EXPORT void * SC_HASHfind( struct Hash_Table *, char * ); + SC_UTILS_EXPORT void SC_HASHinsert( struct Hash_Table *, char *, void * ); + SC_UTILS_EXPORT void SC_HASHdestroy( struct Hash_Table * ); + SC_UTILS_EXPORT struct Element * SC_HASHsearch( struct Hash_Table *, const struct Element *, Action ); + SC_UTILS_EXPORT void SC_HASHlistinit( struct Hash_Table *, HashEntry * ); + SC_UTILS_EXPORT void SC_HASHlistinit_by_type( struct Hash_Table *, HashEntry *, char ); + SC_UTILS_EXPORT struct Element * SC_HASHlist( HashEntry * ); #ifdef __cplusplus } diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index 93cf8c911..fe438ad28 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -39,6 +39,10 @@ include_directories( SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) +if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(exp2cxx version_string) +endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + if(SC_ENABLE_TESTING) add_subdirectory(test) endif(SC_ENABLE_TESTING) diff --git a/src/exp2cxx/class_strings.c b/src/exp2cxx/class_strings.c index 69fe2b4b8..d1736a644 100644 --- a/src/exp2cxx/class_strings.c +++ b/src/exp2cxx/class_strings.c @@ -4,20 +4,19 @@ #include "class_strings.h" #include "express/type.h" -const char *ClassName(const char *oldname) -{ +const char * ClassName( const char * oldname ) { int i = 0, j = 0; static char newname [BUFSIZ]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENTITYCLASS_PREFIX) ; - j = strlen(ENTITYCLASS_PREFIX) ; - newname [j] = ToUpper(oldname [i]); + strcpy( newname, ENTITYCLASS_PREFIX ) ; + j = strlen( ENTITYCLASS_PREFIX ) ; + newname [j] = ToUpper( oldname [i] ); ++i; ++j; - while(oldname [i] != '\0') { - newname [j] = ToLower(oldname [i]); + while( oldname [i] != '\0' ) { + newname [j] = ToLower( oldname [i] ); /* if (oldname [i] == '_') */ /* character is '_' */ /* newname [++j] = ToUpper (oldname [++i]);*/ @@ -25,110 +24,108 @@ const char *ClassName(const char *oldname) ++j; } newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *ENTITYget_classname(Entity ent) -{ - const char *oldname = ENTITYget_name(ent); - return (ClassName(oldname)); +const char * ENTITYget_classname( Entity ent ) { + const char * oldname = ENTITYget_name( ent ); + return ( ClassName( oldname ) ); } /** like TYPEget_ctype, but caller must alloc a buffer of at least buf_siz * in many circumstances, this func will return a short string rather than using that buffer * buf_siz is ignored in those cases since it is meaningless */ -const char *TYPE_get_ctype(const Type t, char *retval, size_t buf_siz) -{ - const char *ptr = "_ptr", * var = "_var", * agg = "_agg"; - const char *overflowMsg = "buffer overflow detected at %s:%d!"; +const char * TYPE_get_ctype( const Type t, char * retval, size_t buf_siz ) { + const char * ptr = "_ptr", * var = "_var", * agg = "_agg"; + const char * overflowMsg = "buffer overflow detected at %s:%d!"; Class_Of_Type ctype; Type bt; - if(TYPEinherits_from(t, aggregate_)) { - bt = TYPEget_body(t)->base; - if(TYPEinherits_from(bt, aggregate_)) { - return("GenericAggregate"); + if( TYPEinherits_from( t, aggregate_ ) ) { + bt = TYPEget_body( t )->base; + if( TYPEinherits_from( bt, aggregate_ ) ) { + return( "GenericAggregate" ); } - ctype = TYPEget_type(bt); - if(ctype == integer_) { - return ("IntAggregate"); + ctype = TYPEget_type( bt ); + if( ctype == integer_ ) { + return ( "IntAggregate" ); } - if((ctype == number_) || (ctype == real_)) { - return ("RealAggregate"); + if( ( ctype == number_ ) || ( ctype == real_ ) ) { + return ( "RealAggregate" ); } - if(ctype == entity_) { - return("EntityAggregate"); + if( ctype == entity_ ) { + return( "EntityAggregate" ); } - if((ctype == enumeration_) || (ctype == select_)) { - const char *tmp = TYPE_get_ctype(bt, retval, buf_siz - strlen(retval) - 1); - if(tmp != retval) { - strncpy(retval, tmp, buf_siz - strlen(retval) - 1); + if( ( ctype == enumeration_ ) || ( ctype == select_ ) ) { + const char * tmp = TYPE_get_ctype( bt, retval, buf_siz - strlen( retval ) - 1 ); + if( tmp != retval ) { + strncpy( retval, tmp, buf_siz - strlen( retval ) - 1 ); } - if(strlen(retval) + strlen(agg) < buf_siz) { - strcat(retval, agg); + if( strlen( retval ) + strlen( agg ) < buf_siz ) { + strcat( retval, agg ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } - return (retval); + return ( retval ); } - if(ctype == logical_) { - return ("LOGICALS"); + if( ctype == logical_ ) { + return ( "LOGICALS" ); } - if(ctype == boolean_) { - return ("BOOLEANS"); + if( ctype == boolean_ ) { + return ( "BOOLEANS" ); } - if(ctype == string_) { - return("StringAggregate"); + if( ctype == string_ ) { + return( "StringAggregate" ); } - if(ctype == binary_) { - return("BinaryAggregate"); + if( ctype == binary_ ) { + return( "BinaryAggregate" ); } } /* the rest is for things that are not aggregates */ - ctype = TYPEget_type(t); + ctype = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if(ctype == logical_) { - return ("SDAI_LOGICAL"); + if( ctype == logical_ ) { + return ( "SDAI_LOGICAL" ); } /* case TYPE_BOOLEAN: */ - if(ctype == boolean_) { - return ("SDAI_BOOLEAN"); + if( ctype == boolean_ ) { + return ( "SDAI_BOOLEAN" ); } /* case TYPE_INTEGER: */ - if(ctype == integer_) { - return ("SDAI_Integer"); + if( ctype == integer_ ) { + return ( "SDAI_Integer" ); } /* case TYPE_REAL: * case TYPE_NUMBER: */ - if((ctype == number_) || (ctype == real_)) { - return ("SDAI_Real"); + if( ( ctype == number_ ) || ( ctype == real_ ) ) { + return ( "SDAI_Real" ); } /* case TYPE_STRING: */ - if(ctype == string_) { - return ("SDAI_String"); + if( ctype == string_ ) { + return ( "SDAI_String" ); } /* case TYPE_BINARY: */ - if(ctype == binary_) { - return ("SDAI_Binary"); + if( ctype == binary_ ) { + return ( "SDAI_Binary" ); } /* case TYPE_ENTITY: */ - if(ctype == entity_) { - strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); - if(strlen(retval) + strlen(ptr) < buf_siz) { - strcat(retval, ptr); + if( ctype == entity_ ) { + strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); + if( strlen( retval ) + strlen( ptr ) < buf_siz ) { + strcat( retval, ptr ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } return retval; @@ -136,113 +133,105 @@ const char *TYPE_get_ctype(const Type t, char *retval, size_t buf_siz) } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if(ctype == enumeration_) { - strncpy(retval, TypeName(t), buf_siz - strlen(retval) - 1); - if(strlen(retval) + strlen(var) < buf_siz) { - strcat(retval, var); + if( ctype == enumeration_ ) { + strncpy( retval, TypeName( t ), buf_siz - strlen( retval ) - 1 ); + if( strlen( retval ) + strlen( var ) < buf_siz ) { + strcat( retval, var ); } else { - fprintf(stderr, overflowMsg, __FILE__, __LINE__); + fprintf( stderr, overflowMsg, __FILE__, __LINE__ ); abort(); } return retval; } - if(ctype == select_) { - return (TypeName(t)); + if( ctype == select_ ) { + return ( TypeName( t ) ); } /* default returns undefined */ - return ("SCLundefined"); + return ( "SCLundefined" ); } -const char *TYPEget_ctype(const Type t) -{ +const char * TYPEget_ctype( const Type t ) { static char retval [BUFSIZ] = {0}; - return TYPE_get_ctype(t, retval, BUFSIZ); + return TYPE_get_ctype( t, retval, BUFSIZ ); } -const char *TypeName(Type t) -{ +const char * TypeName( Type t ) { static char name [BUFSIZ]; - strcpy(name, TYPE_PREFIX); - if(TYPEget_name(t)) { - strncat(name, FirstToUpper(TYPEget_name(t)), BUFSIZ - strlen(TYPE_PREFIX) - 1); + strcpy( name, TYPE_PREFIX ); + if( TYPEget_name( t ) ) { + strncat( name, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - strlen( TYPE_PREFIX ) - 1 ); } else { - return TYPEget_ctype(t); + return TYPEget_ctype( t ); } return name; } -char ToLower(char c) -{ - if(isupper(c)) { - return (tolower(c)); +char ToLower( char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } -char ToUpper(char c) -{ - if(islower(c)) { - return (toupper(c)); +char ToUpper( char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } -const char *StrToLower(const char *word) -{ +const char * StrToLower( const char * word ) { static char newword [MAX_LEN]; int i = 0; - if(!word) { + if( !word ) { return 0; } - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; - return (newword) ; + return ( newword ) ; } -const char *StrToUpper(const char *word) -{ +const char * StrToUpper( const char * word ) { static char newword [MAX_LEN]; int i = 0; - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *StrToConstant(const char *word) -{ +const char * StrToConstant( const char * word ) { static char newword[MAX_LEN]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *FirstToUpper(const char *word) -{ +const char * FirstToUpper( const char * word ) { static char newword [MAX_LEN]; - strncpy(newword, word, MAX_LEN); - newword[0] = ToUpper(newword[0]); - return (newword); + strncpy( newword, word, MAX_LEN ); + newword[0] = ToUpper( newword[0] ); + return ( newword ); } diff --git a/src/exp2cxx/class_strings.h b/src/exp2cxx/class_strings.h index bae97af28..147c970fb 100644 --- a/src/exp2cxx/class_strings.h +++ b/src/exp2cxx/class_strings.h @@ -20,18 +20,18 @@ /** \returns: temporary copy of name suitable for use as a class name * Side Effects: erases the name created by a previous call to this function */ -const char *ClassName(const char *oldname); +const char * ClassName( const char * oldname ); /** \returns the name of the c++ class representing the entity */ -const char *ENTITYget_classname(Entity ent); +const char * ENTITYget_classname( Entity ent ); /** supplies the type of a data member for the c++ class * \returns: a string which is the type of the data member in the c++ class */ -const char *TYPEget_ctype(const Type t); +const char * TYPEget_ctype( const Type t ); /** name of type as defined in SDAI C++ binding 4-Nov-1993 */ -const char *TypeName(Type t); +const char * TypeName( Type t ); /** These functions take a character or a string and return ** a temporary copy of the string with the function applied to it. @@ -42,11 +42,11 @@ const char *TypeName(Type t); ** \returns a temporary copy of characters ** @{ */ -char ToLower(char c); -char ToUpper(char c); -const char *StrToLower(const char *word); -const char *StrToUpper(const char *word); -const char *StrToConstant(const char *word); -const char *FirstToUpper(const char *word); +char ToLower( char c ); +char ToUpper( char c ); +const char * StrToLower( const char * word ); +const char * StrToUpper( const char * word ); +const char * StrToConstant( const char * word ); +const char * FirstToUpper( const char * word ); /* @} */ #endif /* CLASS_STRINGS_H */ diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 42f7eefa0..0f1494ded 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -46,16 +46,15 @@ int old_accessors = 0; * Mostly replaced by format_for_std_stringout, below. This function is * still used in one place in ENTITYincode_print(). */ -char *format_for_stringout(char *orig_buf, char *return_buf) -{ - char *optr = orig_buf; - char *rptr = return_buf; - while(*optr) { - if(*optr == '\n') { +char * format_for_stringout( char * orig_buf, char * return_buf ) { + char * optr = orig_buf; + char * rptr = return_buf; + while( *optr ) { + if( *optr == '\n' ) { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if(*optr == '\\') { + } else if( *optr == '\\' ) { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -76,183 +75,175 @@ char *format_for_stringout(char *orig_buf, char *return_buf) * * This version takes a file pointer and eliminates use of the temp buffer. */ -void format_for_std_stringout(FILE *f, char *orig_buf) -{ - const char *optr = orig_buf; - char *s_end = "\\n\" );\n"; - char *s_begin = " str.append( \""; - fprintf(f, "%s", s_begin); - while(*optr) { - if(*optr == '\n') { - if(* (optr + 1) == '\n') { /* skip blank lines */ +void format_for_std_stringout( FILE * f, char * orig_buf ) { + const char * optr = orig_buf; + char * s_end = "\\n\" );\n"; + char * s_begin = " str.append( \""; + fprintf( f, "%s", s_begin ); + while( *optr ) { + if( *optr == '\n' ) { + if( * ( optr + 1 ) == '\n' ) { /* skip blank lines */ optr++; continue; } - fprintf(f, "%s", s_end); - fprintf(f, "%s", s_begin); - } else if(*optr == '\\') { - fprintf(f, "\\\\"); + fprintf( f, "%s", s_end ); + fprintf( f, "%s", s_begin ); + } else if( *optr == '\\' ) { + fprintf( f, "\\\\" ); } else { - fprintf(f, "%c", *optr); + fprintf( f, "%c", *optr ); } optr++; } - fprintf(f, "%s", s_end); - sc_free(orig_buf); + fprintf( f, "%s", s_end ); + sc_free( orig_buf ); } -void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file) -{ +void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ) { Dictionary dict; DictionaryEntry de; - struct Rename *r; + struct Rename * r; Linked_List list; char td_name[BUFSIZ]; char sch_name[BUFSIZ]; - strncpy(sch_name, PrettyTmpName(SCHEMAget_name(schema)), BUFSIZ); + strncpy( sch_name, PrettyTmpName( SCHEMAget_name( schema ) ), BUFSIZ ); - LISTdo(reflist, s, Schema) { - fprintf(file, " // %s FROM %s; (all objects)\n", type, s->symbol.name); - fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(s->symbol.name)); - fprintf(file, " is->all_objects_(1);\n"); - if(!strcmp(type, "USE")) { - fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + LISTdo( reflist, s, Schema ) { + fprintf( file, " // %s FROM %s; (all objects)\n", type, s->symbol.name ); + fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( s->symbol.name ) ); + fprintf( file, " is->all_objects_(1);\n" ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } - } - LISTod + } LISTod - if(!refdict) { + if( !refdict ) { return; } - dict = DICTcreate(10); + dict = DICTcreate( 10 ); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init(refdict, &de); - while(0 != (r = (struct Rename *)DICTdo(&de))) { + DICTdo_init( refdict, &de ); + while( 0 != ( r = ( struct Rename * )DICTdo( &de ) ) ) { Linked_List wlist; - wlist = (Linked_List)DICTlookup(dict, r->schema->symbol.name); - if(!wlist) { + wlist = ( Linked_List )DICTlookup( dict, r->schema->symbol.name ); + if( !wlist ) { wlist = LISTcreate(); - DICTdefine(dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN); + DICTdefine( dict, r->schema->symbol.name, wlist, NULL, OBJ_UNKNOWN ); } - LISTadd_last(wlist, r); + LISTadd_last( wlist, r ); } /* step 2: for each list, print out the renames */ - DICTdo_init(dict, &de); - while(0 != (list = (Linked_List)DICTdo(&de))) { + DICTdo_init( dict, &de ); + while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { bool first_time = true; - LISTdo(list, re, struct Rename *) { + LISTdo( list, re, struct Rename * ) { /* note: SCHEMAget_name(r->schema) equals r->schema->symbol.name) */ - if(first_time) { - fprintf(file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name); - fprintf(file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName(re->schema->symbol.name)); - if(!strcmp(type, "USE")) { - fprintf(file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + if( first_time ) { + fprintf( file, " // %s FROM %s (selected objects)\n", type, re->schema->symbol.name ); + fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( re->schema->symbol.name ) ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name(schema)); + fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) ); } } - if(first_time) { + if( first_time ) { first_time = false; } - if(re->type == OBJ_TYPE) { - sprintf(td_name, "%s", TYPEtd_name((Type)re->object)); - } else if(re->type == OBJ_FUNCTION) { - sprintf(td_name, "/* Function not implemented */ 0"); - } else if(re->type == OBJ_PROCEDURE) { - sprintf(td_name, "/* Procedure not implemented */ 0"); - } else if(re->type == OBJ_RULE) { - sprintf(td_name, "/* Rule not implemented */ 0"); - } else if(re->type == OBJ_ENTITY) { - sprintf(td_name, "%s%s%s", - SCOPEget_name(((Entity)re->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)re->object)); + if( re->type == OBJ_TYPE ) { + sprintf( td_name, "%s", TYPEtd_name( ( Type )re->object ) ); + } else if( re->type == OBJ_FUNCTION ) { + sprintf( td_name, "/* Function not implemented */ 0" ); + } else if( re->type == OBJ_PROCEDURE ) { + sprintf( td_name, "/* Procedure not implemented */ 0" ); + } else if( re->type == OBJ_RULE ) { + sprintf( td_name, "/* Rule not implemented */ 0" ); + } else if( re->type == OBJ_ENTITY ) { + sprintf( td_name, "%s%s%s", + SCOPEget_name( ( ( Entity )re->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )re->object ) ); } else { - sprintf(td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type); + sprintf( td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", re->type ); } - if(re->old != re->nnew) { - fprintf(file, " // object %s AS %s\n", re->old->name, - re->nnew->name); - if(!strcmp(type, "USE")) { - fprintf(file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ui);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); + if( re->old != re->nnew ) { + fprintf( file, " // object %s AS %s\n", re->old->name, + re->nnew->name ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ui);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ri);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); + fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", re->schema->symbol.name, td_name, re->old->name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ri);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); } } else { - fprintf(file, " // object %s\n", re->old->name); - if(!strcmp(type, "USE")) { - fprintf(file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ui);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name(schema)); + fprintf( file, " // object %s\n", re->old->name ); + if( !strcmp( type, "USE" ) ) { + fprintf( file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ui);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) ); } else { - fprintf(file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name); - fprintf(file, " is->explicit_items_()->Append(ri);\n"); - fprintf(file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name(schema)); + fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", re->schema->symbol.name, td_name, re->nnew->name ); + fprintf( file, " is->explicit_items_()->Append(ri);\n" ); + fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) ); } } - } - LISTod + } LISTod } - HASHdestroy(dict); + HASHdestroy( dict ); } -int Handle_FedPlus_Args(int i, char *arg) -{ +int Handle_FedPlus_Args( int i, char * arg ) { (void) arg; /* unused */ - if(((char)i == 's') || ((char)i == 'S')) { + if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { multiple_inheritance = 0; } - if(((char)i == 'a') || ((char)i == 'A')) { + if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { old_accessors = 1; } - if(((char)i == 'l') || ((char)i == 'L')) { + if( ( ( char )i == 'l' ) || ( ( char )i == 'L' ) ) { print_logging = 1; } return 0; } -void MODELPrintConstructorBody(Entity entity, FILES *files, Schema schema) -{ - const char *n; - DEBUG("Entering MODELPrintConstructorBody for %s\n", n); +void MODELPrintConstructorBody( Entity entity, FILES * files, Schema schema ) { + const char * n; + DEBUG( "Entering MODELPrintConstructorBody for %s\n", n ); - n = ENTITYget_classname(entity); + n = ENTITYget_classname( entity ); - fprintf(files->lib, " eep = new SDAI_Entity_extent;\n"); + fprintf( files->lib, " eep = new SDAI_Entity_extent;\n" ); - fprintf(files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(files->lib, " _folders.Append(eep);\n\n"); + fprintf( files->lib, " eep->definition_(%s::%s%s);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( files->lib, " _folders.Append(eep);\n\n" ); } -void MODELPrint(Entity entity, FILES *files, Schema schema, int index) -{ +void MODELPrint( Entity entity, FILES * files, Schema schema, int index ) { - const char *n; - DEBUG("Entering MODELPrint for %s\n", n); + const char * n; + DEBUG( "Entering MODELPrint for %s\n", n ); - n = ENTITYget_classname(entity); - fprintf(files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name(schema), n); - fprintf(files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index); - DEBUG("DONE MODELPrint\n") ; + n = ENTITYget_classname( entity ); + fprintf( files->lib, "\n%s__set_var SdaiModel_contents_%s::%s_get_extents() {\n", n, SCHEMAget_name( schema ), n ); + fprintf( files->lib, "\n return (%s__set_var)((_folders.retrieve(%d))->instances_());\n}\n", n, index ); + DEBUG( "DONE MODELPrint\n" ) ; } -void MODELprint_new(Entity entity, FILES *files) -{ - const char *n; +void MODELprint_new( Entity entity, FILES * files ) { + const char * n; - n = ENTITYget_classname(entity); - fprintf(files->inc, "\n %s__set_var %s_get_extents();\n", n, n); + n = ENTITYget_classname( entity ); + fprintf( files->inc, "\n %s__set_var %s_get_extents();\n", n, n ); } diff --git a/src/exp2cxx/classes.h b/src/exp2cxx/classes.h index eac80fbf5..462e22687 100644 --- a/src/exp2cxx/classes.h +++ b/src/exp2cxx/classes.h @@ -48,29 +48,29 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define move(b) (b = (b + strlen(b))) #define TYPEtd_name(t) TypeDescriptorName (t) -Variable VARis_type_shifter(Variable a); -int isAggregateType(const Type t); -int isAggregate(Variable a); +Variable VARis_type_shifter( Variable a ); +int isAggregateType( const Type t ); +int isAggregate( Variable a ); typedef struct file_holder { - FILE *inc; /**< include file */ - FILE *lib; /**< library file */ - FILE *incall; /**< include file for collecting all include files */ - FILE *initall; /**< for registering all entities from all schemas */ - FILE *init; /**< contains function to initialize program to use schema's entities */ - FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE * inc; /**< include file */ + FILE * lib; /**< library file */ + FILE * incall; /**< include file for collecting all include files */ + FILE * initall; /**< for registering all entities from all schemas */ + FILE * init; /**< contains function to initialize program to use schema's entities */ + FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ struct { struct { - FILE *impl; - FILE *hdr; + FILE * impl; + FILE * hdr; } entity, type; } unity; } File_holder, FILES; @@ -78,7 +78,7 @@ typedef struct file_holder { /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ *EntityTag; +typedef struct EntityTag_ * EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ @@ -86,36 +86,36 @@ struct EntityTag_ { }; /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ *SelectTag; +typedef struct SelectTag_ * SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char *GetTypeDescriptorName(Type t); -char *format_for_stringout(char *orig_buf, char *return_buf); -void format_for_std_stringout(FILE *f, char *orig_buf); -const char *CheckWord(const char *); -const char *StrToLower(const char *); -const char *StrToUpper(const char *); -const char *FirstToUpper(const char *); -const char *SelectName(const char *); -FILE *FILEcreate(const char *); -void FILEclose(FILE *); -const char *ClassName(const char *); -void FUNCPrint(Function, FILES *, Schema); -void RULEPrint(Rule, FILES *, Schema); -const char *StrToConstant(const char *); -void MODELPrint(Entity, FILES *, Schema, int); -void MODELprint_new(Entity entity, FILES *files); -void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); -const char *PrettyTmpName(const char *oldname); -const char *EnumName(const char *oldname); -void print_file(Express); -void resolution_success(void); -void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix); -const char *FundamentalType(const Type t, int report_reftypes); -void numberAttributes(Scope scope); +const char * GetTypeDescriptorName( Type t ); +char * format_for_stringout( char * orig_buf, char * return_buf ); +void format_for_std_stringout( FILE* f, char* orig_buf ); +const char * CheckWord( const char * ); +const char * StrToLower( const char * ); +const char * StrToUpper( const char * ); +const char * FirstToUpper( const char * ); +const char * SelectName( const char * ); +FILE * FILEcreate( const char * ); +void FILEclose( FILE * ); +const char * ClassName( const char * ); +void FUNCPrint( Function, FILES *, Schema ); +void RULEPrint( Rule, FILES *, Schema ); +const char * StrToConstant( const char * ); +void MODELPrint( Entity, FILES *, Schema, int ); +void MODELprint_new( Entity entity, FILES* files ); +void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); +const char * PrettyTmpName( const char * oldname ); +const char * EnumName( const char * oldname ); +void print_file( Express ); +void resolution_success( void ); +void SCHEMAprint( Schema schema, FILES* files, void* complexCol, int suffix ); +const char * FundamentalType( const Type t, int report_reftypes ); +void numberAttributes( Scope scope ); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -123,14 +123,14 @@ void numberAttributes(Scope scope); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider(Entity e, Variable a); +Variable VARis_overrider( Entity e, Variable a ); /* Added for multiple schema support: */ -void print_schemas_separate(Express, void *, FILES *); -void getMCPrint(Express, FILE *, FILE *); -int sameSchema(Scope, Scope); +void print_schemas_separate( Express, void *, FILES * ); +void getMCPrint( Express, FILE *, FILE * ); +int sameSchema( Scope, Scope ); -void USEREFout(Schema schema, Dictionary refdict, Linked_List reflist, char *type, FILE *file); +void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ); #include "classes_attribute.h" #include "classes_type.h" diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index 2b35e3fd4..f304ba176 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -38,24 +38,23 @@ extern int print_logging; ** Side Effects: ** Status: complete 8/5/93 ******************************************************************/ -char *generate_attribute_name(Variable a, char *out) -{ - char *temp, *q; - const char *p; +char * generate_attribute_name( Variable a, char * out ) { + char * temp, *q; + const char * p; int i; - temp = EXPRto_string(VARget_name(a)); - p = StrToLower(temp); - if(! strncmp(p, "self\\", 5)) { + temp = EXPRto_string( VARget_name( a ) ); + p = StrToLower( temp ); + if( ! strncmp( p, "self\\", 5 ) ) { p += 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for(i = 0, q = out; *p != '\0' && i < BUFSIZ; p++) { + for( i = 0, q = out; *p != '\0' && i < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert * '.' to '_', and convert to lowercase. */ - if((*p != '\n') && (*p != ' ')) { - if(*p == '.') { + if( ( *p != '\n' ) && ( *p != ' ' ) ) { + if( *p == '.' ) { *q = '_'; } else { *q = *p; @@ -65,31 +64,29 @@ char *generate_attribute_name(Variable a, char *out) } } *q = '\0'; - sc_free(temp); + sc_free( temp ); return out; } -char *generate_attribute_func_name(Variable a, char *out) -{ - generate_attribute_name(a, out); - strncpy(out, StrToLower(out), BUFSIZ); - if(old_accessors) { - out[0] = toupper(out[0]); +char * generate_attribute_func_name( Variable a, char * out ) { + generate_attribute_name( a, out ); + strncpy( out, StrToLower( out ), BUFSIZ ); + if( old_accessors ) { + out[0] = toupper( out[0] ); } else { - out[strlen(out)] = '_'; + out[strlen( out )] = '_'; } return out; } /* return true if attr needs const and non-const getters */ -bool attrIsObj(Type t) -{ +bool attrIsObj( Type t ) { /* if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { / * const doesn't make sense for pointer types * / return false; } else */ - Class_Of_Type class = TYPEget_type(t); - switch(class) { + Class_Of_Type class = TYPEget_type( t ); + switch( class ) { case number_: case real_: case integer_: @@ -104,19 +101,17 @@ bool attrIsObj(Type t) /** print attr descriptors to the namespace * \p attr_count_tmp is a _copy_ of attr_count */ -void ATTRnames_print(Entity entity, FILE *file) -{ +void ATTRnames_print( Entity entity, FILE* file ) { char attrnm [BUFSIZ]; - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - fprintf(file, " extern %s *%s%d%s%s;\n", - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), - attrnm); - } - LISTod + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + fprintf( file, " extern %s *%s%d%s%s;\n", + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + } LISTod } /** prints out the current attribute for an entity's c++ class definition @@ -125,33 +120,32 @@ void ATTRnames_print(Entity entity, FILE *file) * \param a attribute being processed * \param file file being written to */ -void DataMemberPrintAttr(Entity entity, Variable a, FILE *file) -{ +void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { char attrnm [BUFSIZ]; - const char *ctype, * etype; - if(!VARget_inverse(a) && (VARget_initializer(a) == EXPRESSION_NULL)) { - ctype = TYPEget_ctype(VARget_type(a)); - generate_attribute_name(a, attrnm); - if(!strcmp(ctype, "SCLundefined")) { - fprintf(stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name(entity), attrnm); + const char * ctype, * etype; + if( !VARget_inverse( a ) && ( VARget_initializer( a ) == EXPRESSION_NULL ) ) { + ctype = TYPEget_ctype( VARget_type( a ) ); + generate_attribute_name( a, attrnm ); + if( !strcmp( ctype, "SCLundefined" ) ) { + fprintf( stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name( entity ), attrnm ); } - if(TYPEis_entity(VARget_type(a))) { - fprintf(file, " SDAI_Application_instance_ptr _%s;", attrnm); - } else if(TYPEis_aggregate(VARget_type(a))) { - fprintf(file, " %s_ptr _%s;", ctype, attrnm); + if( TYPEis_entity( VARget_type( a ) ) ) { + fprintf( file, " SDAI_Application_instance_ptr _%s;", attrnm ); + } else if( TYPEis_aggregate( VARget_type( a ) ) ) { + fprintf( file, " %s_ptr _%s;", ctype, attrnm ); } else { - fprintf(file, " %s _%s;", ctype, attrnm); + fprintf( file, " %s _%s;", ctype, attrnm ); } - if(VARget_optional(a)) { - fprintf(file, " // OPTIONAL"); + if( VARget_optional( a ) ) { + fprintf( file, " // OPTIONAL" ); } - if(isAggregate(a)) { + if( isAggregate( a ) ) { /* if it's a named type, comment the type */ - if((etype = TYPEget_name(TYPEget_nonaggregate_base_type(VARget_type(a))))) { - fprintf(file, " // of %s\n", etype); + if( ( etype = TYPEget_name ( TYPEget_nonaggregate_base_type( VARget_type( a ) ) ) ) ) { + fprintf( file, " // of %s\n", etype ); } } - fprintf(file, "\n"); + fprintf( file, "\n" ); } } @@ -168,32 +162,31 @@ void DataMemberPrintAttr(Entity entity, Variable a, FILE *file) ** Side Effects: ** Status: complete 17-Feb-1992 ******************************************************************/ -void ATTRsign_access_methods(Variable a, FILE *file) -{ +void ATTRsign_access_methods( Variable a, FILE * file ) { - Type t = VARget_type(a); + Type t = VARget_type( a ); char ctype [BUFSIZ]; char attrnm [BUFSIZ]; - generate_attribute_func_name(a, attrnm); + generate_attribute_func_name( a, attrnm ); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; - if(attrIsObj(t)) { + if( attrIsObj( t ) ) { /* object or pointer, so provide const and non-const methods */ - if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { + if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { /* it's a typedef, so prefacing with 'const' won't do what we desire */ - fprintf(file, " %s_c %s() const;\n", ctype, attrnm); + fprintf( file, " %s_c %s() const;\n", ctype, attrnm ); } else { - fprintf(file, " const %s %s() const;\n", ctype, attrnm); + fprintf( file, " const %s %s() const;\n", ctype, attrnm ); } - fprintf(file, " %s %s();\n", ctype, attrnm); + fprintf( file, " %s %s();\n", ctype, attrnm ); } else { - fprintf(file, " %s %s() const;\n", ctype, attrnm); + fprintf( file, " %s %s() const;\n", ctype, attrnm ); } - fprintf(file, " void %s( const %s x );\n", attrnm, ctype); - fprintf(file, "\n"); + fprintf( file, " void %s( const %s x );\n", attrnm, ctype ); + fprintf( file, "\n" ); return; } @@ -213,18 +206,17 @@ void ATTRsign_access_methods(Variable a, FILE *file) ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst) -{ - Type t = VARget_type(a); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ) { + Type t = VARget_type( a ); char ctype [BUFSIZ]; /* return type of the get function */ char funcnm [BUFSIZ]; /* name of member function */ - generate_attribute_func_name(a, funcnm); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; - if(TYPEis_entity(t) || TYPEis_select(t) || TYPEis_aggregate(t)) { - fprintf(file, "\n%s%s %s::%s() ", ctype, (returnsConst ? "_c" : ""), classnm, funcnm); + generate_attribute_func_name( a, funcnm ); + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; + if( TYPEis_entity( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + fprintf( file, "\n%s%s %s::%s() ", ctype, ( returnsConst ? "_c" : "" ), classnm, funcnm ); } else { - fprintf(file, "\n%s%s %s::%s() ", (returnsConst ? "const " : ""), ctype, classnm, funcnm); + fprintf( file, "\n%s%s %s::%s() ", ( returnsConst ? "const " : "" ), ctype, classnm, funcnm ); } return; } @@ -245,35 +237,33 @@ void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *fi ** Side Effects: ** Status: complete 7/15/93 by DDH ******************************************************************/ -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file) -{ +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ) { - Type t = VARget_type(a); + Type t = VARget_type( a ); char ctype [BUFSIZ]; char funcnm [BUFSIZ]; - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); - strncpy(ctype, AccessType(t), BUFSIZ); - ctype[BUFSIZ - 1] = '\0'; - fprintf(file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype); + strncpy( ctype, AccessType( t ), BUFSIZ ); + ctype[BUFSIZ-1] = '\0'; + fprintf( file, "\nvoid %s::%s( const %s x ) ", entnm, funcnm, ctype ); return; } /** print access methods for aggregate attribute */ -void AGGRprint_access_methods(const char *entnm, Variable a, FILE *file, - char *ctype, char *attrnm) -{ - ATTRprint_access_methods_get_head(entnm, a, file, false); - fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - fprintf(file, " return ( %s ) %s_%s;\n}\n", ctype, ((a->type->u.type->body->base) ? "" : "& "), attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ((a->type->u.type->body->base) ? "->" : ".")); +void AGGRprint_access_methods( const char * entnm, Variable a, FILE * file, + char * ctype, char * attrnm ) { + ATTRprint_access_methods_get_head( entnm, a, file, false ); + fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + fprintf( file, " return ( %s ) %s_%s;\n}\n", ctype, ( ( a->type->u.type->body->base ) ? "" : "& " ), attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " _%s%sShallowCopy( * x );\n}\n", attrnm, ( ( a->type->u.type->body->base ) ? "->" : "." ) ); return; } @@ -281,221 +271,212 @@ void AGGRprint_access_methods(const char *entnm, Variable a, FILE *file, * \p var is the variable name, minus preceding underscore, or null if 'x' is to be used * \p dir is either "returned" or "assigned" */ -void ATTRprint_access_methods_entity_logging(const char *entnm, const char *funcnm, const char *nm, - const char *var, const char *dir, FILE *file) -{ - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if( *logStream ) {\n"); - fprintf(file, " logStream -> open( SCLLOGFILE, ios::app );\n"); - fprintf(file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", (var ? "_" : ""), (var ? var : "x")); - fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); - fprintf(file, " *logStream << \"reference to Sdai%s entity #\"", nm); - fprintf(file, " << %s%s->STEPfile_id << std::endl;\n", (var ? "_" : ""), (var ? var : "x")); - fprintf(file, " } else {\n"); - fprintf(file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir); - fprintf(file, " *logStream << \"null entity\" << std::endl;\n }\n"); - fprintf(file, " logStream->close();\n"); - fprintf(file, " }\n"); - fprintf(file, "#endif\n"); +void ATTRprint_access_methods_entity_logging( const char * entnm, const char * funcnm, const char * nm, + const char * var, const char * dir, FILE * file ) { + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if( *logStream ) {\n" ); + fprintf( file, " logStream -> open( SCLLOGFILE, ios::app );\n" ); + fprintf( file, " if( !( %s%s == S_ENTITY_NULL ) )\n {\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); + fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); + fprintf( file, " *logStream << \"reference to Sdai%s entity #\"", nm ); + fprintf( file, " << %s%s->STEPfile_id << std::endl;\n", ( var ? "_" : "" ), ( var ? var : "x" ) ); + fprintf( file, " } else {\n" ); + fprintf( file, " *logStream << time( NULL ) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, dir ); + fprintf( file, " *logStream << \"null entity\" << std::endl;\n }\n" ); + fprintf( file, " logStream->close();\n" ); + fprintf( file, " }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for attrs that are entities * prints const and non-const getters and a setter */ -void ATTRprint_access_methods_entity(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName(a->type)); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); - fprintf(file, " _%s = x;\n}\n", attrnm); +void ATTRprint_access_methods_entity( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " if( !_%s ) {\n _%s = new %s;\n }\n", attrnm, attrnm, TypeName( a->type ) ); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); + fprintf( file, " _%s = x;\n}\n", attrnm ); return; } /** logging code for string and binary attribute access methods */ -void ATTRprint_access_methods_str_bin_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(setter) { - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); +void ATTRprint_access_methods_str_bin_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( setter ) { + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } else { - fprintf(file, " if(x)\n {\n"); + fprintf( file, " if(x)\n {\n" ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << x << std::endl;\n"); + fprintf( file, " *logStream << x << std::endl;\n" ); } - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for string or bin attribute */ -void ATTRprint_access_methods_str_bin(const char *entnm, const char *attrnm, const char *funcnm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " return _%s;\n}\n", attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_str_bin_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " _%s = x;\n}\n", attrnm); +void ATTRprint_access_methods_str_bin( const char * entnm, const char * attrnm, const char * funcnm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " return _%s;\n}\n", attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_str_bin_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " _%s = x;\n}\n", attrnm ); return; } /** print logging code for access methods for enumeration attribute */ -void ATTRprint_access_methods_enum_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(!setter) { - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); +void ATTRprint_access_methods_enum_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( !setter ) { + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); + fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); } - fprintf(file, " }\n#endif\n"); + fprintf( file, " }\n#endif\n" ); } } /** print access methods for enumeration attribute */ -void ATTRprint_access_methods_enum(const char *entnm, const char *attrnm, const char *funcnm, - Variable a, Type t, FILE *file) -{ - fprintf(file, "{\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", EnumName(TYPEget_name(t)), attrnm); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_enum_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " _%s.put( x );\n}\n", attrnm); +void ATTRprint_access_methods_enum( const char * entnm, const char * attrnm, const char * funcnm, + Variable a, Type t, FILE * file ) { + fprintf( file, "{\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (%s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (const %s) _%s;\n}\n", EnumName( TYPEget_name( t ) ), attrnm ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_enum_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " _%s.put( x );\n}\n", attrnm ); return; } /** print logging code for access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool_logging(const char *entnm, const char *attrnm, const char *funcnm, FILE *file, bool setter) -{ - if(print_logging) { - const char *direction = (setter ? "assigned" : "returned"); - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - if(!setter) { +void ATTRprint_access_methods_log_bool_logging( const char * entnm, const char * attrnm, const char * funcnm, FILE * file, bool setter ) { + if( print_logging ) { + const char * direction = ( setter ? "assigned" : "returned" ); + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + if( !setter ) { /* fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" ); */ - fprintf(file, " if(!_%s.is_null())\n {\n", attrnm); + fprintf( file, " if(!_%s.is_null())\n {\n", attrnm ); } - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - if(setter) { - fprintf(file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + if( setter ) { + fprintf( file, " *logStream << _%s.element_at(x) << std::endl;\n", attrnm ); } else { - fprintf(file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n"); + fprintf( file, " *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n", attrnm, attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() %s: \";\n", entnm, funcnm, direction ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n" ); /* fprintf( file, " logStream->close();\n" ); */ } - fprintf(file, " }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " }\n" ); + fprintf( file, "#endif\n" ); } } /** print access methods for logical or boolean attribute */ -void ATTRprint_access_methods_log_bool(const char *entnm, const char *attrnm, const char *funcnm, - const char *ctype, Variable a, FILE *file) -{ - fprintf(file, "const {\n"); - ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, false); - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - - /* don't need a const method for logical or boolean - * ATTRprint_access_methods_get_head( entnm, a, file, true ); - * fprintf( file, "const {\n" ); - * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); - * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); - */ - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_log_bool_logging(entnm, attrnm, funcnm, file, true); - fprintf(file, " _%s.put (x);\n}\n", attrnm); +void ATTRprint_access_methods_log_bool( const char * entnm, const char * attrnm, const char * funcnm, + const char * ctype, Variable a, FILE * file ) { + fprintf( file, "const {\n" ); + ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + +/* don't need a const method for logical or boolean + * ATTRprint_access_methods_get_head( entnm, a, file, true ); + * fprintf( file, "const {\n" ); + * ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, false ); + * fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); +*/ + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_log_bool_logging( entnm, attrnm, funcnm, file, true ); + fprintf( file, " _%s.put (x);\n}\n", attrnm ); return; } /** print access methods for inverse attrs, using iAMap */ -void INVprint_access_methods(const char *entnm, const char *attrnm, const char *funcnm, const char *nm, - const char *ctype, Variable a, FILE *file, Schema schema) -{ +void INVprint_access_methods( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, + const char * ctype, Variable a, FILE * file, Schema schema ) { char iaName[BUFSIZ] = {0}; - snprintf(iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name(schema), ATTR_PREFIX, a->idx, - /* can it ever be anything but "I"? */ - (VARis_derived(a) ? "D" : (VARis_type_shifter(a) ? "R" : (VARget_inverse(a) ? "I" : ""))), attrnm); + snprintf( iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, + /* can it ever be anything but "I"? */ + ( VARis_derived( a ) ? "D" : ( VARis_type_shifter( a ) ? "R" : ( VARget_inverse( a ) ? "I" : "" ) ) ), attrnm ); - if(isAggregate(a)) { + if( isAggregate( a ) ) { /* following started as AGGRprint_access_methods() */ - ATTRprint_access_methods_get_head(entnm, a, file, false); - fprintf(file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName); - fprintf(file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName); - fprintf(file, " return ias.a;\n}\n"); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - fprintf(file, " return getInvAttr( %s ).a;\n}\n", iaName); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName); + ATTRprint_access_methods_get_head( entnm, a, file, false ); + fprintf( file, "{\n iAstruct ias = getInvAttr( %s );\n if( !ias.a ) {\n", iaName ); + fprintf( file, " ias.a = new EntityAggregate;\n setInvAttr( %s, ias );\n }\n", iaName ); + fprintf( file, " return ias.a;\n}\n" ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + fprintf( file, " return getInvAttr( %s ).a;\n}\n", iaName ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n iAstruct ias;\n ias.a = x;\n setInvAttr( %s, ias );\n}\n", iaName ); } else { - ATTRprint_access_methods_get_head(entnm, a, file, false); + ATTRprint_access_methods_get_head( entnm, a, file, false ); /* following started as ATTRprint_access_methods_entity() */ - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); - fprintf(file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); - fprintf(file, " return (%s) ias.i;\n}\n", ctype); - - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, attrnm, "returned", file); - fprintf(file, " iAstruct ias = getInvAttr( %s );\n", iaName); - fprintf(file, " return (%s) ias.i;\n}\n", ctype); - - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - ATTRprint_access_methods_entity_logging(entnm, funcnm, nm, 0, "assigned", file); - fprintf(file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); + fprintf( file, " /* no 'new' - doesn't make sense to create an SDAI_Application_instance\n * since it isn't generic like EntityAggregate */\n"); + fprintf( file, " return (%s) ias.i;\n}\n", ctype ); + + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, attrnm, "returned", file); + fprintf( file, " iAstruct ias = getInvAttr( %s );\n", iaName ); + fprintf( file, " return (%s) ias.i;\n}\n", ctype ); + + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + ATTRprint_access_methods_entity_logging( entnm, funcnm, nm, 0, "assigned", file); + fprintf( file, " iAstruct ias;\n ias.i = x; setInvAttr( %s, ias );\n}\n", iaName ); } } @@ -506,9 +487,8 @@ void INVprint_access_methods(const char *entnm, const char *attrnm, const char * * \param a attribute to print methods for * \param file file being written to */ -void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema) -{ - Type t = VARget_type(a); +void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ) { + Type t = VARget_type( a ); Class_Of_Type classType; char ctype [BUFSIZ]; /* type of data member */ char attrnm [BUFSIZ]; @@ -517,46 +497,46 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema char nm [BUFSIZ]; /* I believe nm has the name of the underlying type without Sdai in front of it */ - if(TYPEget_name(t)) { - strncpy(nm, FirstToUpper(TYPEget_name(t)), BUFSIZ - 1); + if( TYPEget_name( t ) ) { + strncpy( nm, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - 1 ); } - generate_attribute_func_name(a, funcnm); - generate_attribute_name(a, attrnm); - strcpy(membernm, attrnm); - membernm[0] = toupper(membernm[0]); - classType = TYPEget_type(t); - strncpy(ctype, AccessType(t), BUFSIZ); - if(VARget_inverse(a)) { - INVprint_access_methods(entnm, attrnm, funcnm, nm, ctype, a, file, schema); + generate_attribute_func_name( a, funcnm ); + generate_attribute_name( a, attrnm ); + strcpy( membernm, attrnm ); + membernm[0] = toupper( membernm[0] ); + classType = TYPEget_type( t ); + strncpy( ctype, AccessType( t ), BUFSIZ ); + if( VARget_inverse( a ) ) { + INVprint_access_methods( entnm, attrnm, funcnm, nm, ctype, a, file, schema ); return; } - if(isAggregate(a)) { - AGGRprint_access_methods(entnm, a, file, ctype, attrnm); + if( isAggregate( a ) ) { + AGGRprint_access_methods( entnm, a, file, ctype, attrnm ); return; } - ATTRprint_access_methods_get_head(entnm, a, file, false); + ATTRprint_access_methods_get_head( entnm, a, file, false ); /* case TYPE_ENTITY: */ - if(classType == entity_) { - ATTRprint_access_methods_entity(entnm, attrnm, funcnm, nm, ctype, a, file); + if( classType == entity_ ) { + ATTRprint_access_methods_entity( entnm, attrnm, funcnm, nm, ctype, a, file ); return; } /* case TYPE_LOGICAL: */ - if((classType == boolean_) || (classType == logical_)) { - ATTRprint_access_methods_log_bool(entnm, attrnm, funcnm, ctype, a, file); + if( ( classType == boolean_ ) || ( classType == logical_ ) ) { + ATTRprint_access_methods_log_bool( entnm, attrnm, funcnm, ctype, a, file ); } /* case TYPE_ENUM: */ - if(classType == enumeration_) { - ATTRprint_access_methods_enum(entnm, attrnm, funcnm, a, t, file); + if( classType == enumeration_ ) { + ATTRprint_access_methods_enum( entnm, attrnm, funcnm, a, t, file ); } /* case TYPE_SELECT: */ - if(classType == select_) { - fprintf(file, " {\n return &_%s;\n}\n", attrnm); - ATTRprint_access_methods_get_head(entnm, a, file, true); - fprintf(file, "const {\n return (%s) &_%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, " {\n _%s = x;\n}\n", attrnm); + if( classType == select_ ) { + fprintf( file, " {\n return &_%s;\n}\n", attrnm ); + ATTRprint_access_methods_get_head( entnm, a, file, true ); + fprintf( file, "const {\n return (const %s) &_%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, " {\n _%s = x;\n}\n", attrnm ); return; } /* case TYPE_AGGRETATES: */ @@ -565,77 +545,77 @@ void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema /* case STRING:*/ /* case TYPE_BINARY: */ - if((classType == string_) || (classType == binary_)) { - ATTRprint_access_methods_str_bin(entnm, attrnm, funcnm, ctype, a, file); + if( ( classType == string_ ) || ( classType == binary_ ) ) { + ATTRprint_access_methods_str_bin( entnm, attrnm, funcnm, ctype, a, file ); } /* case TYPE_INTEGER: */ - if(classType == integer_) { - fprintf(file, "const {\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm); - fprintf(file, - " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", - entnm, funcnm); - fprintf(file, - " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + if( classType == integer_ ) { + fprintf( file, "const {\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm ); + fprintf( file, + " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", + entnm, funcnm ); + fprintf( file, + " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } /* default: INTEGER */ /* is the same type as the data member */ - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(x == S_INT_NULL) )\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << x << std::endl;\n"); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " return (const %s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(x == S_INT_NULL) )\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << x << std::endl;\n" ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); /* default: INTEGER */ /* is the same type as the data member */ } - fprintf(file, " _%s = x;\n}\n", attrnm); + fprintf( file, " _%s = x;\n}\n", attrnm ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((classType == number_) || (classType == real_)) { - fprintf(file, "const {\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + if( ( classType == number_ ) || ( classType == real_ ) ) { + fprintf( file, "const {\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } - fprintf(file, " return (%s) _%s;\n}\n", ctype, attrnm); - ATTRprint_access_methods_put_head(entnm, a, file); - fprintf(file, "{\n"); - if(print_logging) { - fprintf(file, "#ifdef SC_LOGGING\n"); - fprintf(file, " if(*logStream)\n {\n"); - fprintf(file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << _%s << std::endl;\n", attrnm); - fprintf(file, " }\n else\n {\n"); - fprintf(file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm); - fprintf(file, " *logStream << \"unset\" << std::endl;\n }\n }\n"); - fprintf(file, "#endif\n"); + fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm ); + ATTRprint_access_methods_put_head( entnm, a, file ); + fprintf( file, "{\n" ); + if( print_logging ) { + fprintf( file, "#ifdef SC_LOGGING\n" ); + fprintf( file, " if(*logStream)\n {\n" ); + fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << _%s << std::endl;\n", attrnm ); + fprintf( file, " }\n else\n {\n" ); + fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n", entnm, funcnm ); + fprintf( file, " *logStream << \"unset\" << std::endl;\n }\n }\n" ); + fprintf( file, "#endif\n" ); } - fprintf(file, " _%s = x;\n}\n", attrnm); + fprintf( file, " _%s = x;\n}\n", attrnm ); } } diff --git a/src/exp2cxx/classes_attribute.h b/src/exp2cxx/classes_attribute.h index f06273a77..5a32b3074 100644 --- a/src/exp2cxx/classes_attribute.h +++ b/src/exp2cxx/classes_attribute.h @@ -1,17 +1,17 @@ #ifndef CLASSES_ATTRIBUTE_H #define CLASSES_ATTRIBUTE_H -char *generate_attribute_name(Variable a, char *out); -char *generate_attribute_func_name(Variable a, char *out); +char * generate_attribute_name( Variable a, char * out ); +char * generate_attribute_func_name( Variable a, char * out ); -void DataMemberPrintAttr(Entity entity, Variable a, FILE *file); -void ATTRnames_print(Entity entity, FILE *file); -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file, bool returnsConst); -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); -void ATTRsign_access_methods(Variable a, FILE *file); -void ATTRprint_access_methods(const char *entnm, Variable a, FILE *file, Schema schema); +void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ); +void ATTRnames_print( Entity entity, FILE * file ); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ); +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); +void ATTRsign_access_methods( Variable a, FILE* file ); +void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ); /** return true if attr needs const and non-const getters */ -bool attrIsObj(Type t); +bool attrIsObj( Type t ); #endif diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 13bbc5ecd..10a6af92c 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -45,9 +45,8 @@ extern int old_accessors; * Nov 2011 - MAP - This function was split out of ENTITYhead_print to enable * use of a separate header with a namespace. */ -void ENTITYnames_print(Entity entity, FILE *file) -{ - fprintf(file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name(entity)); +void ENTITYnames_print( Entity entity, FILE * file ) { + fprintf( file, " extern EntityDescriptor *%s%s;\n", ENT_PREFIX, ENTITYget_name( entity ) ); } /** declares the global pointer to the EntityDescriptor representing a particular entity @@ -59,20 +58,18 @@ void ENTITYnames_print(Entity entity, FILE *file) * \param file file being written to * \param schema schema being processed */ -void LIBdescribe_entity(Entity entity, FILE *file, Schema schema) -{ +void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { char attrnm [BUFSIZ]; - fprintf(file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - fprintf(file, "%s * %s::%s%d%s%s = 0;\n", - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), attrnm); - } - LISTod - fprintf(file, "\n"); + fprintf( file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + fprintf( file, "%s * %s::%s%d%s%s = 0;\n", + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm ); + } LISTod + fprintf( file, "\n"); } /** prints the member functions for the class representing an entity. These go in the .cc file @@ -81,73 +78,67 @@ void LIBdescribe_entity(Entity entity, FILE *file, Schema schema) * \param file file being written to * \param schema needed for name of namespace */ -void LIBmemberFunctionPrint(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBmemberFunctionPrint( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; char entnm [BUFSIZ]; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ /* 1. put in member functions which belong to all entities */ /* the common function are still in the class definition 17-Feb-1992 */ /* 2. print access functions for attributes */ - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, a, Variable) { + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, a, Variable ) { /* do for EXPLICIT, REDEFINED, and INVERSE attributes - but not DERIVED */ - if(! VARis_derived(a)) { + if( ! VARis_derived( a ) ) { /* retrieval and assignment */ - ATTRprint_access_methods(entnm, a, file, schema); + ATTRprint_access_methods( entnm, a, file, schema ); } - } - LISTod + } LISTod /* //////////////// */ - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { - ATTRprint_access_methods(entnm, attr, file, schema); + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { + ATTRprint_access_methods( entnm, attr, file, schema ); } - } - LISTod + } LISTod } /* //////////////// */ - - fprintf(file, "\n"); + + fprintf( file, "\n" ); } -int get_attribute_number(Entity entity) -{ +int get_attribute_number( Entity entity ) { int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes(entity); - local = ENTITYget_attributes(entity); + complete = ENTITYget_all_attributes( entity ); + local = ENTITYget_attributes( entity ); - LISTdo(local, a, Variable) { + LISTdo( local, a, Variable ) { /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - LISTdo_n(complete, p, Variable, b) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + LISTdo_n( complete, p, Variable, b ) { /* cycle through all the explicit attributes until the child's attribute is found */ - if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { - if(p != a) { + if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { + if( p != a ) { ++i; } else { found = 1; } } - } - LISTod - if(found) { + } LISTod + if( found ) { return i; } else { - fprintf(stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name(VARget_name(a))); + fprintf( stderr, "Internal error at %s:%d: attribute %s not found\n", __FILE__, __LINE__, EXPget_name( VARget_name( a ) ) ); } } - } - LISTod + } LISTod return -1; } @@ -157,71 +148,66 @@ int get_attribute_number(Entity entity) * \p entity entity to print * \p file file being written to */ -void ENTITYhead_print(Entity entity, FILE *file) -{ +void ENTITYhead_print( Entity entity, FILE * file ) { char entnm [BUFSIZ]; Linked_List list; Entity super = 0; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); - entnm[BUFSIZ - 1] = '\0'; + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); + entnm[BUFSIZ-1] = '\0'; /* inherit from either supertype entity class or root class of all - i.e. SDAI_Application_instance */ - if(multiple_inheritance) { - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - super = (Entity)LISTpeek_first(list); + if( multiple_inheritance ) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + super = ( Entity )LISTpeek_first( list ); } } else { /* the old way */ - super = ENTITYput_superclass(entity); + super = ENTITYput_superclass( entity ); } - fprintf(file, "class SC_SCHEMA_EXPORT %s : ", entnm); - if(super) { - fprintf(file, "public %s {\n ", ENTITYget_classname(super)); + fprintf( file, "class SC_SCHEMA_EXPORT %s : ", entnm ); + if( super ) { + fprintf( file, "public %s {\n ", ENTITYget_classname( super ) ); } else { - fprintf(file, "public SDAI_Application_instance {\n"); + fprintf( file, "public SDAI_Application_instance {\n" ); } } /** print an attr initializer * skip inverse attrs */ -void DataMemberInit(bool *first, Variable a, FILE *lib) -{ +void DataMemberInit( bool * first, Variable a, FILE * lib ) { char attrnm [BUFSIZ]; - if(VARis_derived(a) || VARget_inverse(a)) { + if( VARis_derived( a ) || VARget_inverse( a ) ) { return; } - if(TYPEis_entity(VARget_type(a)) || TYPEis_aggregate(VARget_type(a))) { - if(*first) { + if( TYPEis_entity( VARget_type( a ) ) || TYPEis_aggregate( VARget_type( a ) ) ) { + if( *first ) { *first = false; - fprintf(lib, " :"); + fprintf( lib, " :" ); } else { - fprintf(lib, ","); + fprintf( lib, "," ); } - generate_attribute_name(a, attrnm); - fprintf(lib, " _%s( 0 )", attrnm); + generate_attribute_name( a, attrnm ); + fprintf( lib, " _%s( 0 )", attrnm ); } } /** print attribute initializers; call before printing constructor body * \param first true if this is the first initializer */ -void DataMemberInitializers(Entity entity, bool *first, Linked_List neededAttr, FILE *lib) -{ - Linked_List attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, attr, Variable) { - DataMemberInit(first, attr, lib); - } - LISTod; - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - DataMemberInit(first, attr, lib); - } - LISTod +void DataMemberInitializers( Entity entity, bool * first, Linked_List neededAttr, FILE * lib ) { + Linked_List attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, attr, Variable ) { + DataMemberInit( first, attr, lib ); + } LISTod; + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + DataMemberInit( first, attr, lib ); + } LISTod } } @@ -229,23 +215,22 @@ void DataMemberInitializers(Entity entity, bool *first, Linked_List neededAttr, * \param entity entity being processed * \param file file being written to */ -void DataMemberPrint(Entity entity, Linked_List neededAttr, FILE *file) -{ +void DataMemberPrint( Entity entity, Linked_List neededAttr, FILE * file ) { Linked_List attr_list; /* print list of attributes in the protected access area */ - fprintf(file, " protected:\n"); + fprintf( file, " protected:\n" ); - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, attr, Variable) { - DataMemberPrintAttr(entity, attr, file); + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, attr, Variable ) { + DataMemberPrintAttr( entity, attr, file ); } LISTod; /* add attributes for parent attributes not inherited through C++ inheritance. */ - if(multiple_inheritance) { - LISTdo(neededAttr, attr, Variable) { - DataMemberPrintAttr(entity, attr, file); + if( multiple_inheritance ) { + LISTdo( neededAttr, attr, Variable ) { + DataMemberPrintAttr( entity, attr, file ); } LISTod; } @@ -255,55 +240,52 @@ void DataMemberPrint(Entity entity, Linked_List neededAttr, FILE *file) * \param entity entity being processed * \param file file being written to */ -void MemberFunctionSign(Entity entity, Linked_List neededAttr, FILE *file) -{ +void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) { Linked_List attr_list; static int entcode = 0; char entnm [BUFSIZ]; - strncpy(entnm, ENTITYget_classname(entity), BUFSIZ); /* assign entnm */ - entnm[BUFSIZ - 1] = '\0'; + strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ + entnm[BUFSIZ-1] = '\0'; - fprintf(file, " public: \n"); + fprintf( file, " public: \n" ); /* put in member functions which belong to all entities */ /* constructors: */ - fprintf(file, " %s();\n", entnm); - fprintf(file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm); + fprintf( file, " %s();\n", entnm ); + fprintf( file, " %s( SDAI_Application_instance *se, bool addAttrs = true );\n", entnm ); /* copy constructor */ - fprintf(file, " %s( %s & e );\n", entnm, entnm); + fprintf( file, " %s( %s & e );\n", entnm, entnm ); /* destructor: */ - fprintf(file, " ~%s();\n", entnm); + fprintf( file, " ~%s();\n", entnm ); - fprintf(file, " int opcode() {\n return %d;\n }\n", entcode++); + fprintf( file, " int opcode() {\n return %d;\n }\n", entcode++ ); /* print signature of access functions for attributes */ - attr_list = ENTITYget_attributes(entity); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + attr_list = ENTITYget_attributes( entity ); + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* retrieval and assignment */ - ATTRsign_access_methods(a, file); + ATTRsign_access_methods( a, file ); } - } - LISTod + } LISTod /* //////////////// */ - if(multiple_inheritance) { + if( multiple_inheritance ) { /* add the EXPRESS inherited attributes which are non */ /* inherited in C++ */ - LISTdo(neededAttr, attr, Variable) { - if(! VARis_derived(attr) && ! VARis_overrider(entity, attr)) { - ATTRsign_access_methods(attr, file); + LISTdo( neededAttr, attr, Variable ) { + if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) { + ATTRsign_access_methods( attr, file ); } - } - LISTod + } LISTod } /* //////////////// */ - fprintf(file, "};\n\n"); + fprintf( file, "};\n\n" ); /* print creation function for class */ - fprintf(file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm); + fprintf( file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm ); } /** drives the generation of the c++ class definition code @@ -313,21 +295,19 @@ void MemberFunctionSign(Entity entity, Linked_List neededAttr, FILE *file) * \param entity entity being processed * \param file file being written to */ -void ENTITYinc_print(Entity entity, Linked_List neededAttr, FILE *file) -{ - ENTITYhead_print(entity, file); - DataMemberPrint(entity, neededAttr, file); - MemberFunctionSign(entity, neededAttr, file); +void ENTITYinc_print( Entity entity, Linked_List neededAttr, FILE * file ) { + ENTITYhead_print( entity, file ); + DataMemberPrint( entity, neededAttr, file ); + MemberFunctionSign( entity, neededAttr, file ); } /** initialize attributes in the constructor; used for two different constructors */ -void initializeAttrs(Entity e, FILE *file) -{ - const orderedAttr *oa; - orderedAttrsInit(e); - while(0 != (oa = nextAttr())) { - if(oa->deriver) { - fprintf(file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name); +void initializeAttrs( Entity e, FILE* file ) { + const orderedAttr * oa; + orderedAttrsInit( e ); + while( 0 != ( oa = nextAttr() ) ) { + if( oa->deriver ) { + fprintf( file, " MakeDerived( \"%s\", \"%s\" );\n", oa->attr->name->symbol.name, oa->creator->symbol.name ); } } orderedAttrsCleanup(); @@ -345,8 +325,7 @@ void initializeAttrs(Entity e, FILE *file) * \param entity entity being processed * \param file file being written to */ -void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -354,154 +333,152 @@ void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema Linked_List list; Entity principalSuper = 0; - const char *entnm = ENTITYget_classname(entity); + const char * entnm = ENTITYget_classname( entity ); bool first = true; /* constructor definition */ /* parent class initializer (if any) and '{' printed below */ - fprintf(file, "%s::%s()", entnm, entnm); + fprintf( file, "%s::%s()", entnm, entnm ); /* ////MULTIPLE INHERITANCE//////// */ - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { /* if there's no super class yet, or the super class doesn't have any attributes */ super_cnt++; - if(super_cnt == 1) { + if( super_cnt == 1 ) { bool firstInitializer = false; /* ignore the 1st parent */ - const char *parent = ENTITYget_classname(e); + const char * parent = ENTITYget_classname( e ); /* parent class initializer */ - fprintf(file, ": %s()", parent); - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); - fprintf(file, " /* parent: %s */\n%s\n%s\n", parent, + fprintf( file, ": %s()", parent ); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); + fprintf( file, " /* parent: %s */\n%s\n%s\n", parent, " /* Ignore the first parent since it is */", - " /* part of the main inheritance hierarchy */"); + " /* part of the main inheritance hierarchy */" ); principalSuper = e; /* principal SUPERTYPE */ } else { - fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); - fprintf(file, " HeadEntity(this);\n"); - fprintf(file, " AppendMultInstance(new %s(this));\n", - ENTITYget_classname(e)); - - if(super_cnt == 2) { - printf("\nMULTIPLE INHERITANCE for entity: %s\n", - ENTITYget_name(entity)); - printf(" SUPERTYPE 1: %s (principal supertype)\n", - ENTITYget_name(principalSuper)); + fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); + fprintf( file, " HeadEntity(this);\n" ); + fprintf( file, " AppendMultInstance(new %s(this));\n", + ENTITYget_classname( e ) ); + + if( super_cnt == 2 ) { + printf( "\nMULTIPLE INHERITANCE for entity: %s\n", + ENTITYget_name( entity ) ); + printf( " SUPERTYPE 1: %s (principal supertype)\n", + ENTITYget_name( principalSuper ) ); } - printf(" SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name(e)); + printf( " SUPERTYPE %d: %s\n", super_cnt, ENTITYget_name( e ) ); } - } - LISTod; + } LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ /* no parent class constructor has been printed, so still need an opening brace */ bool firstInitializer = true; - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); - fprintf(file, " /* no SuperTypes */\n"); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); + fprintf( file, " /* no SuperTypes */\n" ); } } /* what if entity comes from other schema? * It appears that entity.superscope.symbol.name is the schema name (but only if entity.superscope.type == 's'?) --MAP 27Nov11 */ - fprintf(file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* include attribute if it is not derived */ - generate_attribute_name(a, attrnm); - t = VARget_type(a); + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); - if(!VARget_inverse(a) && !VARis_derived(a)) { + if( !VARget_inverse( a ) && !VARis_derived( a ) ) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if(TYPEis_aggregate(t)) { - fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); + if( TYPEis_aggregate( t ) ) { + fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); } - fprintf(file, " %sa = new STEPattribute( * %s::", - (first ? "STEPattribute * " : ""), /* first time through, declare 'a' */ - SCHEMAget_name(schema)); - fprintf(file, "%s%d%s%s", ATTR_PREFIX, a->idx, (VARis_type_shifter(a) ? "R" : ""), attrnm); - fprintf(file, ", %s%s_%s );\n", - (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * ) " : ""), - (TYPEis_aggregate(t) ? "" : "& "), attrnm); - if(first) { + fprintf( file, " %sa = new STEPattribute( * %s::", + ( first ? "STEPattribute * " : "" ), /* first time through, declare 'a' */ + SCHEMAget_name( schema ) ); + fprintf( file, "%s%d%s%s", ATTR_PREFIX, a->idx, ( VARis_type_shifter( a ) ? "R" : "" ), attrnm ); + fprintf( file, ", %s%s_%s );\n", + ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * ) " : "" ), + ( TYPEis_aggregate( t ) ? "" : "& " ), attrnm ); + if( first ) { first = false; } /* 2. initialize everything to NULL (even if not optional) */ - fprintf(file, " a->set_null();\n"); + fprintf( file, " a->set_null();\n" ); /* 3. put attribute on attributes list */ - fprintf(file, " attributes.push( a );\n"); + fprintf( file, " attributes.push( a );\n" ); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if(VARis_type_shifter(a)) { - fprintf(file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name(a)); + if( VARis_type_shifter( a ) ) { + fprintf( file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name( a ) ); } } } - } - LISTod; + } LISTod; - initializeAttrs(entity, file); + initializeAttrs( entity, file ); - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); /* copy constructor */ - entnm = ENTITYget_classname(entity); - fprintf(file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm); + entnm = ENTITYget_classname( entity ); + fprintf( file, "%s::%s ( %s & e ) : ", entnm, entnm, entnm ); /* include explicit initialization of base class */ - if(principalSuper) { - fprintf(file, "%s()", ENTITYget_classname(principalSuper)); + if( principalSuper ) { + fprintf( file, "%s()", ENTITYget_classname( principalSuper ) ); } else { - fprintf(file, "SDAI_Application_instance()"); + fprintf( file, "SDAI_Application_instance()" ); } - fprintf(file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n"); + fprintf( file, " {\n CopyAs( ( SDAI_Application_instance_ptr ) & e );\n}\n\n" ); /* print destructor */ /* currently empty, but should check to see if any attributes need to be deleted -- attributes will need reference count */ - entnm = ENTITYget_classname(entity); - fprintf(file, "%s::~%s() {\n", entnm, entnm); + entnm = ENTITYget_classname( entity ); + fprintf( file, "%s::~%s() {\n", entnm, entnm ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { - generate_attribute_name(a, attrnm); - t = VARget_type(a); + LISTdo( attr_list, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - if(TYPEis_aggregate(t)) { - fprintf(file, " delete _%s;\n", attrnm); + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + if( TYPEis_aggregate( t ) ) { + fprintf( file, " delete _%s;\n", attrnm ); } } } LISTod; - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); } /********************/ @@ -509,8 +486,7 @@ void LIBstructor_print(Entity entity, Linked_List neededAttr, FILE *file, Schema when building multiply inherited entities. \sa LIBstructor_print() */ -void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ +void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; char attrnm [BUFSIZ]; @@ -520,19 +496,19 @@ void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, /* added for calling parents constructor if there is one */ char parentnm [BUFSIZ]; - char *parent = 0; + char * parent = 0; - const char *entnm; + const char * entnm; bool first = true; - if(multiple_inheritance) { + if( multiple_inheritance ) { bool firstInitializer = true; Entity parentEntity = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - parentEntity = (Entity)LISTpeek_first(list); - if(parentEntity) { - strcpy(parentnm, ENTITYget_classname(parentEntity)); + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + parentEntity = ( Entity )LISTpeek_first( list ); + if( parentEntity ) { + strcpy( parentnm, ENTITYget_classname( parentEntity ) ); parent = parentnm; } else { parent = 0; /* no parent */ @@ -544,111 +520,109 @@ void LIBstructor_print_w_args(Entity entity, Linked_List neededAttr, FILE *file, /* ENTITYget_classname returns a static buffer so don't call it twice before it gets used - (I didn't write it) - I had to move it below the above use. DAS */ - entnm = ENTITYget_classname(entity); + entnm = ENTITYget_classname( entity ); /* constructor definition */ - if(parent) { + if( parent ) { firstInitializer = false; - fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm); + fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs ) : %s( se, addAttrs )", entnm, entnm, parentnm ); } else { - fprintf(file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm); + fprintf( file, "%s::%s( SDAI_Application_instance * se, bool addAttrs )", entnm, entnm ); } - DataMemberInitializers(entity, &firstInitializer, neededAttr, file); - fprintf(file, " {\n"); + DataMemberInitializers( entity, &firstInitializer, neededAttr, file ); + fprintf( file, " {\n" ); - fprintf(file, " /* Set this to point to the head entity. */\n"); - fprintf(file, " HeadEntity(se);\n"); - if(!parent) { - fprintf(file, " ( void ) addAttrs; /* quell potentially unused var */\n\n"); + fprintf( file, " /* Set this to point to the head entity. */\n" ); + fprintf( file, " HeadEntity(se);\n" ); + if( !parent ) { + fprintf( file, " ( void ) addAttrs; /* quell potentially unused var */\n\n" ); } - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { - LISTdo(list, e, Entity) + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) /* if there's no super class yet, or the super class doesn't have any attributes */ - fprintf(file, " /* parent: %s */\n", ENTITYget_classname(e)); + fprintf( file, " /* parent: %s */\n", ENTITYget_classname( e ) ); super_cnt++; - if(super_cnt == 1) { + if( super_cnt == 1 ) { /* ignore the 1st parent */ - fprintf(file, - " /* Ignore the first parent since it is part *\n%s\n", - " ** of the main inheritance hierarchy */"); + fprintf( file, + " /* Ignore the first parent since it is part *\n%s\n", + " ** of the main inheritance hierarchy */" ); } else { - fprintf(file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", - ENTITYget_classname(e)); + fprintf( file, " se->AppendMultInstance( new %s( se, addAttrs ) );\n", + ENTITYget_classname( e ) ); } LISTod; } else { /* if entity has no supertypes, it's at top of hierarchy */ - fprintf(file, " /* no SuperTypes */\n"); + fprintf( file, " /* no SuperTypes */\n" ); } /* what if entity comes from other schema? */ - fprintf(file, "\n eDesc = %s::%s%s;\n", - SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( file, "\n eDesc = %s::%s%s;\n", + SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - attr_list = ENTITYget_attributes(entity); + attr_list = ENTITYget_attributes( entity ); - LISTdo(attr_list, a, Variable) { - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( attr_list, a, Variable ) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* include attribute if it is not derived */ - generate_attribute_name(a, attrnm); - t = VARget_type(a); - if(!VARget_inverse(a) && !VARis_derived(a)) { + generate_attribute_name( a, attrnm ); + t = VARget_type( a ); + if( !VARget_inverse( a ) && !VARis_derived( a ) ) { /* 1. create a new STEPattribute */ /* if type is aggregate, the variable is a pointer and needs initialized */ - if(TYPEis_aggregate(t)) { - fprintf(file, " _%s = new %s;\n", attrnm, TYPEget_ctype(t)); + if( TYPEis_aggregate( t ) ) { + fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) ); } - fprintf(file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", - (first ? "STEPattribute * " : ""), /* first time through, declare a */ - SCHEMAget_name(schema), + fprintf( file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n", + ( first ? "STEPattribute * " : "" ), /* first time through, declare a */ + SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, - (VARis_type_shifter(a) ? "R" : ""), + ( VARis_type_shifter( a ) ? "R" : "" ), attrnm, - (TYPEis_entity(t) ? "( SDAI_Application_instance_ptr * )" : ""), - (TYPEis_aggregate(t) ? "" : "&"), - attrnm); + ( TYPEis_entity( t ) ? "( SDAI_Application_instance_ptr * )" : "" ), + ( TYPEis_aggregate( t ) ? "" : "&" ), + attrnm ); - if(first) { + if( first ) { first = false; } - fprintf(file, " /* initialize to NULL (even if not optional) */\n"); - fprintf(file, " a ->set_null();\n"); + fprintf( file, " /* initialize to NULL (even if not optional) */\n" ); + fprintf( file, " a ->set_null();\n" ); - fprintf(file, " /* Put attribute on this class' attributes list so the access functions still work. */\n"); - fprintf(file, " attributes.push( a );\n"); + fprintf( file, " /* Put attribute on this class' attributes list so the access functions still work. */\n" ); + fprintf( file, " attributes.push( a );\n" ); - fprintf(file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n"); - fprintf(file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n"); - fprintf(file, " if( addAttrs ) {\n"); - fprintf(file, " se->attributes.push( a );\n }\n"); + fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n" ); + fprintf( file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); + fprintf( file, " if( addAttrs ) {\n" ); + fprintf( file, " se->attributes.push( a );\n }\n" ); /* if it is redefining another attribute make connection of redefined attribute to redefining attribute */ - if(VARis_type_shifter(a)) { - fprintf(file, " MakeRedefined( a, \"%s\" );\n", - VARget_simple_name(a)); + if( VARis_type_shifter( a ) ) { + fprintf( file, " MakeRedefined( a, \"%s\" );\n", + VARget_simple_name( a ) ); } } } - } - LISTod + } LISTod - initializeAttrs(entity, file); + initializeAttrs( entity, file ); - fprintf(file, "}\n\n"); + fprintf( file, "}\n\n" ); } /* end if(multiple_inheritance) */ } /** return 1 if types are predefined by us */ -bool TYPEis_builtin(const Type t) -{ - switch(TYPEget_body(t)->type) { /* dunno if correct*/ +bool TYPEis_builtin( const Type t ) { + switch( TYPEget_body( t )->type ) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -680,30 +654,29 @@ bool TYPEis_builtin(const Type t) * \param a, an Express attribute * \param out, the C++ name */ -char *generate_dict_attr_name(Variable a, char *out) -{ - char *temp, *p, *q; +char * generate_dict_attr_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - temp = EXPRto_string(VARget_name(a)); + temp = EXPRto_string( VARget_name( a ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ - strncpy(out, StrToLower(p), BUFSIZ); + strncpy( out, StrToLower( p ), BUFSIZ ); /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; *p != '\0' && j < BUFSIZ; p++) { + for( j = 0, q = out; *p != '\0' && j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if(*p != '\n') { - *q = tolower(*p); + if( *p != '\n' ) { + *q = tolower( *p ); j++; q++; } } *q = '\0'; - sc_free(temp); + sc_free( temp ); return out; } @@ -714,238 +687,237 @@ char *generate_dict_attr_name(Variable a, char *out) * \param impl implementation file being written to * \param schema schema the entity is in */ -void ENTITYincode_print(Entity entity, FILE *header, FILE *impl, Schema schema) -{ +void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schema ) { #define entity_name ENTITYget_name(entity) #define schema_name SCHEMAget_name(schema) char attrnm [BUFSIZ]; char dict_attrnm [BUFSIZ]; - const char *super_schema; - char *tmp, *tmp2; + const char * super_schema; + char * tmp, *tmp2; bool hasInverse = false; #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the entity into the schema descriptor */ - fprintf(impl, - " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", - schema_name, schema_name, ENT_PREFIX, entity_name); + fprintf( impl, + " ((SDAIAGGRH(Set,EntityH))%s::schema->Entities())->Add(%s::%s%s);\n", + schema_name, schema_name, ENT_PREFIX, entity_name ); #endif - if(ENTITYget_abstract(entity)) { - if(entity->u.entity->subtype_expression) { + if( ENTITYget_abstract( entity ) ) { + if( entity->u.entity->subtype_expression ) { - fprintf(impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n"); + fprintf( impl, " str.clear();\n str.append( \"ABSTRACT SUPERTYPE OF ( \" );\n" ); - format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); - fprintf(impl, " str.append( \")\" );\n"); - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); + format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); + fprintf( impl, " str.append( \")\" );\n" ); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); } else { - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", - schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", + schema_name, ENT_PREFIX, entity_name ); } } else { - if(entity->u.entity->subtype_expression) { - fprintf(impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n"); - format_for_std_stringout(impl, SUBTYPEto_string(entity->u.entity->subtype_expression)); - fprintf(impl, " str.append( \")\" );\n"); - fprintf(impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name); + if( entity->u.entity->subtype_expression ) { + fprintf( impl, " str.clear();\n str.append( \"SUPERTYPE OF ( \" );\n" ); + format_for_std_stringout( impl, SUBTYPEto_string( entity->u.entity->subtype_expression ) ); + fprintf( impl, " str.append( \")\" );\n" ); + fprintf( impl, " %s::%s%s->AddSupertype_Stmt( str );\n", schema_name, ENT_PREFIX, entity_name ); } } - LISTdo(ENTITYget_supertypes(entity), sup, Entity) + LISTdo( ENTITYget_supertypes( entity ), sup, Entity ) /* set the owning schema of the supertype */ - super_schema = SCHEMAget_name(ENTITYget_schema(sup)); + super_schema = SCHEMAget_name( ENTITYget_schema( sup ) ); /* print the supertype list for this entity */ - fprintf(impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", - schema_name, ENT_PREFIX, entity_name, - super_schema, - ENT_PREFIX, ENTITYget_name(sup)); + fprintf( impl, " %s::%s%s->AddSupertype(%s::%s%s);\n", + schema_name, ENT_PREFIX, entity_name, + super_schema, + ENT_PREFIX, ENTITYget_name( sup ) ); /* add this entity to the subtype list of it's supertype */ - fprintf(impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", - super_schema, - ENT_PREFIX, ENTITYget_name(sup), - schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " %s::%s%s->AddSubtype(%s::%s%s);\n", + super_schema, + ENT_PREFIX, ENTITYget_name( sup ), + schema_name, ENT_PREFIX, entity_name ); LISTod - LISTdo(ENTITYget_attributes(entity), v, Variable) - if(VARget_inverse(v)) { + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + if( VARget_inverse( v ) ) { hasInverse = true; } - generate_attribute_name(v, attrnm); + generate_attribute_name( v, attrnm ); /* do EXPLICIT and DERIVED attributes first */ /* if ( ! VARget_inverse (v)) {*/ /* first make sure that type descriptor exists */ - if(TYPEget_name(v->type)) { - if((!TYPEget_head(v->type)) && - (TYPEget_body(v->type)->type == entity_)) { - fprintf(impl, " %s::%s%d%s%s =", SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : (VARis_type_shifter(v) ? "R" : (VARget_inverse(v) ? "I" : ""))), - attrnm); - fprintf(impl, "\n new %s( \"%s\",", - (VARget_inverse(v) ? "Inverse_attribute" : - (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm)); - - /* following assumes we are not in a nested */ - /* entity otherwise we should search upward */ - /* for schema */ - /* attribute's type */ - fprintf(impl, " %s::%s%s, %s,\n", TYPEget_name(TYPEget_body(v->type)->entity->superscope), - ENT_PREFIX, TYPEget_name(v->type), (VARget_optional(v) ? "LTrue" : "LFalse")); - fprintf(impl, " %s%s, *%s::%s%s);\n", (VARget_unique(v) ? "LTrue" : "LFalse"), - /* Support REDEFINED */ - (VARget_inverse(v) ? "" : (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity)); + if( TYPEget_name( v->type ) ) { + if( ( !TYPEget_head( v->type ) ) && + ( TYPEget_body( v->type )->type == entity_ ) ) { + fprintf( impl, " %s::%s%d%s%s =", SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + fprintf( impl, "\n new %s( \"%s\",", + ( VARget_inverse( v ) ? "Inverse_attribute" : + ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ) ); + + /* following assumes we are not in a nested */ + /* entity otherwise we should search upward */ + /* for schema */ + /* attribute's type */ + fprintf( impl, " %s::%s%s, %s,\n", TYPEget_name( TYPEget_body( v->type )->entity->superscope ), + ENT_PREFIX, TYPEget_name( v->type ), ( VARget_optional( v ) ? "LTrue" : "LFalse" ) ); + fprintf( impl, " %s%s, *%s::%s%s);\n", ( VARget_unique( v ) ? "LTrue" : "LFalse" ), + /* Support REDEFINED */ + ( VARget_inverse( v ) ? "" : ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } else { /* type reference */ - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s::%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), - SCHEMAget_name(v->type->superscope), - TD_PREFIX, TYPEget_name(v->type), + SCHEMAget_name( v->type->superscope ), + TD_PREFIX, TYPEget_name( v->type ), - (VARget_optional(v) ? "LTrue" : "LFalse"), + ( VARget_optional( v ) ? "LTrue" : "LFalse" ), - (VARget_unique(v) ? "LTrue" : "LFalse"), + ( VARget_unique( v ) ? "LTrue" : "LFalse" ), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? ", AttrType_Redefining" : ", AttrType_Explicit"))), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? ", AttrType_Redefining" : ", AttrType_Explicit" ) ) ), - schema_name, ENT_PREFIX, TYPEget_name(entity) + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } - } else if(TYPEis_builtin(v->type)) { + } else if( TYPEis_builtin( v->type ) ) { /* the type wasn't named -- it must be built in or aggregate */ - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), - /* not sure about 0 here */ TD_PREFIX, FundamentalType(v->type, 0), - (VARget_optional(v) ? "LTrue" : - "LFalse"), - (VARget_unique(v) ? "LTrue" : - "LFalse"), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? - ", AttrType_Redefining" : - ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity) + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s%s,\n %s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), + /* not sure about 0 here */ TD_PREFIX, FundamentalType( v->type, 0 ), + ( VARget_optional( v ) ? "LTrue" : + "LFalse" ), + ( VARget_unique( v ) ? "LTrue" : + "LFalse" ), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? + ", AttrType_Redefining" : + ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } else { /* manufacture new one(s) on the spot */ char typename_buf[MAX_LEN]; - print_typechain(header, impl, v->type, typename_buf, schema, v->name->symbol.name); - fprintf(impl, " %s::%s%d%s%s =\n new %s" - "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, - (VARget_inverse(v) ? "Inverse_attribute" : (VARis_derived(v) ? "Derived_attribute" : "AttrDescriptor")), - /* attribute name param */ - generate_dict_attr_name(v, dict_attrnm), - typename_buf, - (VARget_optional(v) ? "LTrue" : - "LFalse"), - (VARget_unique(v) ? "LTrue" : - "LFalse"), - (VARget_inverse(v) ? "" : - (VARis_derived(v) ? ", AttrType_Deriving" : - (VARis_type_shifter(v) ? - ", AttrType_Redefining" : - ", AttrType_Explicit"))), - schema_name, ENT_PREFIX, TYPEget_name(entity) + print_typechain( header, impl, v->type, typename_buf, schema, v->name->symbol.name ); + fprintf( impl, " %s::%s%d%s%s =\n new %s" + "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, + ( VARget_inverse( v ) ? "Inverse_attribute" : ( VARis_derived( v ) ? "Derived_attribute" : "AttrDescriptor" ) ), + /* attribute name param */ + generate_dict_attr_name( v, dict_attrnm ), + typename_buf, + ( VARget_optional( v ) ? "LTrue" : + "LFalse" ), + ( VARget_unique( v ) ? "LTrue" : + "LFalse" ), + ( VARget_inverse( v ) ? "" : + ( VARis_derived( v ) ? ", AttrType_Deriving" : + ( VARis_type_shifter( v ) ? + ", AttrType_Redefining" : + ", AttrType_Explicit" ) ) ), + schema_name, ENT_PREFIX, TYPEget_name( entity ) ); } - fprintf(impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", - schema_name, ENT_PREFIX, TYPEget_name(entity), - (VARget_inverse(v) ? "Inverse" : "Explicit"), - SCHEMAget_name(schema), ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm); - - if(VARis_derived(v) && v->initializer) { - tmp = EXPRto_string(v->initializer); - tmp2 = (char *)sc_malloc(sizeof(char) * (strlen(tmp) + BUFSIZ)); - fprintf(impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, format_for_stringout(tmp, tmp2)); - sc_free(tmp); - sc_free(tmp2); + fprintf( impl, " %s::%s%s->Add%sAttr (%s::%s%d%s%s);\n", + schema_name, ENT_PREFIX, TYPEget_name( entity ), + ( VARget_inverse( v ) ? "Inverse" : "Explicit" ), + SCHEMAget_name( schema ), ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm ); + + if( VARis_derived( v ) && v->initializer ) { + tmp = EXPRto_string( v->initializer ); + tmp2 = ( char * )sc_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); + fprintf( impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, format_for_stringout( tmp, tmp2 ) ); + sc_free( tmp ); + sc_free( tmp2 ); } - if(VARget_inverse(v)) { - fprintf(impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), - attrnm, v->inverse_attribute->name->symbol.name); - if(v->type->symbol.name) { - fprintf(impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - v->type->symbol.name); - fprintf(impl, "// inverse entity 1 %s\n", v->type->symbol.name); + if( VARget_inverse( v ) ) { + fprintf( impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), + attrnm, v->inverse_attribute->name->symbol.name ); + if( v->type->symbol.name ) { + fprintf( impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + v->type->symbol.name ); + fprintf( impl, "// inverse entity 1 %s\n", v->type->symbol.name ); } else { - switch(TYPEget_body(v->type)->type) { + switch( TYPEget_body( v->type )->type ) { case entity_: - fprintf(impl, - " %s%d%s%s->inverted_entity_id_(\"%s\");\n", - ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - TYPEget_body(v->type)->entity->symbol.name); - fprintf(impl, "// inverse entity 2 %s\n", TYPEget_body(v->type)->entity->symbol.name); + fprintf( impl, + " %s%d%s%s->inverted_entity_id_(\"%s\");\n", + ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + TYPEget_body( v->type )->entity->symbol.name ); + fprintf( impl, "// inverse entity 2 %s\n", TYPEget_body( v->type )->entity->symbol.name ); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf(impl, - " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", - schema_name, ATTR_PREFIX, v->idx, - (VARis_derived(v) ? "D" : - (VARis_type_shifter(v) ? "R" : - (VARget_inverse(v) ? "I" : ""))), attrnm, - TYPEget_body(v->type)->base->symbol.name); - fprintf(impl, "// inverse entity 3 %s\n", TYPEget_body(v->type)->base->symbol.name); + fprintf( impl, + " %s::%s%d%s%s->inverted_entity_id_(\"%s\");\n", + schema_name, ATTR_PREFIX, v->idx, + ( VARis_derived( v ) ? "D" : + ( VARis_type_shifter( v ) ? "R" : + ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, + TYPEget_body( v->type )->base->symbol.name ); + fprintf( impl, "// inverse entity 3 %s\n", TYPEget_body( v->type )->base->symbol.name ); break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); abort(); } } @@ -953,57 +925,55 @@ void ENTITYincode_print(Entity entity, FILE *header, FILE *impl, Schema schema) LISTod - fprintf(impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name); - if(hasInverse) { - fprintf(impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name); + fprintf( impl, " reg.AddEntity( *%s::%s%s );\n", schema_name, ENT_PREFIX, entity_name ); + if( hasInverse ) { + fprintf( impl, " %s::schema->AddEntityWInverse( %s::%s%s );\n", schema_name, schema_name, ENT_PREFIX, entity_name ); } #undef schema_name } -void ENTITYPrint_h(const Entity entity, FILE *header, Linked_List neededAttr, Schema schema) -{ - const char *name = ENTITYget_classname(entity); - DEBUG("Entering ENTITYPrint_h for %s\n", name); +void ENTITYPrint_h( const Entity entity, FILE * header, Linked_List neededAttr, Schema schema ) { + const char *name = ENTITYget_classname( entity ); + DEBUG( "Entering ENTITYPrint_h for %s\n", name ); - ENTITYhead_print(entity, header); - DataMemberPrint(entity, neededAttr, header); - MemberFunctionSign(entity, neededAttr, header); + ENTITYhead_print( entity, header ); + DataMemberPrint( entity, neededAttr, header ); + MemberFunctionSign( entity, neededAttr, header ); + + fprintf( header, "void init_%s(Registry& reg);\n\n", name ); - fprintf(header, "void init_%s(Registry& reg);\n\n", name); + fprintf( header, "namespace %s {\n", SCHEMAget_name( schema ) ); + ENTITYnames_print( entity, header ); + ATTRnames_print( entity, header ); + fprintf( header, "}\n\n" ); - fprintf(header, "namespace %s {\n", SCHEMAget_name(schema)); - ENTITYnames_print(entity, header); - ATTRnames_print(entity, header); - fprintf(header, "}\n\n"); - - DEBUG("DONE ENTITYPrint_h\n"); + DEBUG( "DONE ENTITYPrint_h\n" ); } -void ENTITYPrint_cc(const Entity entity, FILE *createall, FILE *header, FILE *impl, Linked_List neededAttr, Schema schema, bool externMap) -{ - const char *name = ENTITYget_classname(entity); - - DEBUG("Entering ENTITYPrint_cc for %s\n", name); +void ENTITYPrint_cc( const Entity entity, FILE * createall, FILE * header, FILE * impl, Linked_List neededAttr, Schema schema, bool externMap ) { + const char * name = ENTITYget_classname( entity ); + + DEBUG( "Entering ENTITYPrint_cc for %s\n", name ); - fprintf(impl, "#include \"schema.h\"\n"); - fprintf(impl, "#include \"sc_memmgr.h\"\n"); - fprintf(impl, "#include \"entity/%s.h\"\n\n", name); + fprintf( impl, "#include \"schema.h\"\n" ); + fprintf( impl, "#include \"sc_memmgr.h\"\n" ); + fprintf( impl, "#include \"entity/%s.h\"\n\n", name ); - LIBdescribe_entity(entity, impl, schema); - LIBstructor_print(entity, neededAttr, impl, schema); - if(multiple_inheritance) { - LIBstructor_print_w_args(entity, neededAttr, impl, schema); + LIBdescribe_entity( entity, impl, schema ); + LIBstructor_print( entity, neededAttr, impl, schema ); + if( multiple_inheritance ) { + LIBstructor_print_w_args( entity, neededAttr, impl, schema ); } - LIBmemberFunctionPrint(entity, neededAttr, impl, schema); - - fprintf(impl, "void init_%s( Registry& reg ) {\n", name); - fprintf(impl, " std::string str;\n\n"); - ENTITYprint_descriptors(entity, createall, impl, schema, externMap); - ENTITYincode_print(entity, header, impl, schema); - fprintf(impl, "}\n\n"); - - DEBUG("DONE ENTITYPrint_cc\n"); + LIBmemberFunctionPrint( entity, neededAttr, impl, schema ); + + fprintf( impl, "void init_%s( Registry& reg ) {\n", name ); + fprintf( impl, " std::string str;\n\n" ); + ENTITYprint_descriptors( entity, createall, impl, schema, externMap ); + ENTITYincode_print( entity, header, impl, schema ); + fprintf( impl, "}\n\n" ); + + DEBUG( "DONE ENTITYPrint_cc\n" ); } /** \sa collectAttributes */ @@ -1014,40 +984,37 @@ enum CollectType { ALL, ALL_BUT_FIRST, FIRST_ONLY }; * \param curEntity current Entity being processed * \param collect selects attrs to be collected */ -static void collectAttributes(Linked_List curList, const Entity curEntity, enum CollectType collect) -{ - Linked_List parent_list = ENTITYget_supertypes(curEntity); +static void collectAttributes( Linked_List curList, const Entity curEntity, enum CollectType collect ) { + Linked_List parent_list = ENTITYget_supertypes( curEntity ); - if(! LISTempty(parent_list)) { - if(collect != FIRST_ONLY) { + if( ! LISTempty( parent_list ) ) { + if( collect != FIRST_ONLY ) { /* collect attributes from parents and their supertypes */ - LISTdo(parent_list, e, Entity) { - if(collect == ALL_BUT_FIRST) { + LISTdo( parent_list, e, Entity ) { + if( collect == ALL_BUT_FIRST ) { /* skip first and collect from the rest */ collect = ALL; } else { /* collect attributes of this parent and its supertypes */ - collectAttributes(curList, e, ALL); + collectAttributes( curList, e, ALL ); } } LISTod; } else { /* collect attributes of only first parent and its supertypes */ - collectAttributes(curList, (Entity) LISTpeek_first(parent_list), ALL); + collectAttributes( curList, ( Entity ) LISTpeek_first( parent_list ), ALL ); } } /* prepend this entity's attributes to the result list */ - LISTdo(ENTITYget_attributes(curEntity), attr, Variable) { - LISTadd_first(curList, attr); - } - LISTod; + LISTdo( ENTITYget_attributes( curEntity ), attr, Variable ) { + LISTadd_first( curList, attr ); + } LISTod; } -static bool listContainsVar(Linked_List l, Variable v) -{ - const char *vName = VARget_simple_name(v); - LISTdo(l, curr, Variable) { - if(!strcmp(vName, VARget_simple_name(curr))) { +static bool listContainsVar( Linked_List l, Variable v ) { + const char * vName = VARget_simple_name( v ); + LISTdo( l, curr, Variable ) { + if( !strcmp( vName, VARget_simple_name( curr ) ) ) { return true; } } @@ -1064,14 +1031,13 @@ static bool listContainsVar(Linked_List l, Variable v) * \param entity entity being processed * \param file file being written to */ -void ENTITYlib_print(Entity entity, Linked_List neededAttr, FILE *file, Schema schema) -{ - LIBdescribe_entity(entity, file, schema); - LIBstructor_print(entity, neededAttr, file, schema); - if(multiple_inheritance) { - LIBstructor_print_w_args(entity, neededAttr, file, schema); +void ENTITYlib_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { + LIBdescribe_entity( entity, file, schema ); + LIBstructor_print( entity, neededAttr, file, schema ); + if( multiple_inheritance ) { + LIBstructor_print_w_args( entity, neededAttr, file, schema ); } - LIBmemberFunctionPrint(entity, neededAttr, file, schema); + LIBmemberFunctionPrint( entity, neededAttr, file, schema ); } /** drives the functions for printing out code in lib, @@ -1081,59 +1047,58 @@ void ENTITYlib_print(Entity entity, Linked_List neededAttr, FILE *file, Schema s * \p schema name of the schema * \p col the ComplexCollect */ -void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap) -{ - FILE *hdr, * impl; - char *n = ENTITYget_name(entity); +void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ) { + FILE * hdr, * impl; + char * n = ENTITYget_name( entity ); Linked_List remaining = LISTcreate(); - filenames_t names = getEntityFilenames(entity); + filenames_t names = getEntityFilenames( entity ); - DEBUG("Entering ENTITYPrint for %s\n", n); + DEBUG( "Entering ENTITYPrint for %s\n", n ); - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List existing = LISTcreate(); Linked_List required = LISTcreate(); /* create list of attr inherited from the parents in C++ */ - collectAttributes(existing, entity, FIRST_ONLY); + collectAttributes( existing, entity, FIRST_ONLY ); /* create list of attr that have to be inherited in EXPRESS */ - collectAttributes(required, entity, ALL_BUT_FIRST); + collectAttributes( required, entity, ALL_BUT_FIRST ); /* build list of unique attr that are required but haven't been */ /* inherited */ - LISTdo(required, attr, Variable) { - if(!listContainsVar(existing, attr) && - !listContainsVar(remaining, attr)) { - LISTadd_first(remaining, attr); + LISTdo( required, attr, Variable ) { + if( !listContainsVar( existing, attr ) && + !listContainsVar( remaining, attr ) ) { + LISTadd_first( remaining, attr ); } } LISTod; - LIST_destroy(existing); - LIST_destroy(required); + LIST_destroy( existing ); + LIST_destroy( required ); } - if(mkDirIfNone("entity") == -1) { - fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror(0); + if( mkDirIfNone( "entity" ) == -1 ) { + fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror( 0 ); abort(); } - hdr = FILEcreate(names.header); - impl = FILEcreate(names.impl); - assert(hdr && impl && "error creating files"); - fprintf(files->unity.entity.hdr, "#include \"%s\"\n", names.header); /* TODO this is not necessary? */ - fprintf(files->unity.entity.impl, "#include \"%s\"\n", names.impl); + hdr = FILEcreate( names.header ); + impl = FILEcreate( names.impl ); + assert( hdr && impl && "error creating files" ); + fprintf( files->unity.entity.hdr, "#include \"%s\"\n", names.header ); /* TODO this is not necessary? */ + fprintf( files->unity.entity.impl, "#include \"%s\"\n", names.impl ); - ENTITYPrint_h(entity, hdr, remaining, schema); - ENTITYPrint_cc(entity, files->create, hdr, impl, remaining, schema, externMap); - FILEclose(hdr); - FILEclose(impl); + ENTITYPrint_h( entity, hdr, remaining, schema ); + ENTITYPrint_cc( entity, files->create, hdr, impl, remaining, schema, externMap ); + FILEclose( hdr ); + FILEclose( impl ); - fprintf(files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname(entity)); - fprintf(files->init, " init_%s( reg );\n", ENTITYget_classname(entity)); + fprintf( files->inc, "#include \"entity/%s.h\"\n", ENTITYget_classname( entity ) ); + fprintf( files->init, " init_%s( reg );\n", ENTITYget_classname( entity ) ); - DEBUG("DONE ENTITYPrint\n"); - LIST_destroy(remaining); + DEBUG( "DONE ENTITYPrint\n" ); + LIST_destroy( remaining ); } /** create entity descriptors @@ -1149,29 +1114,27 @@ void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap) * eDesc is printed into createall because it must be initialized before other entity init fn's are called * alternative is two init fn's per ent. call init1 for each ent, then repeat with init2 */ -void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap) -{ - fprintf(createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(createall, "\"%s\", %s::schema, %s, ", PrettyTmpName(ENTITYget_name(entity)), SCHEMAget_name(schema), (ENTITYget_abstract(entity) ? "LTrue" : "LFalse")); - fprintf(createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname(entity)); +void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ) { + fprintf( createall, " %s::%s%s = new EntityDescriptor( ", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( createall, "\"%s\", %s::schema, %s, ", PrettyTmpName( ENTITYget_name( entity ) ), SCHEMAget_name( schema ), ( ENTITYget_abstract( entity ) ? "LTrue" : "LFalse" ) ); + fprintf( createall, "%s, (Creator) create_%s );\n", externMap ? "LTrue" : "LFalse", ENTITYget_classname( entity ) ); /* add the entity to the Schema dictionary entry */ - fprintf(createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name(schema), SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); + fprintf( createall, " %s::schema->AddEntity(%s::%s%s);\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - WHEREprint(ENTITYget_name(entity), TYPEget_where(entity), impl, schema, true); - UNIQUEprint(entity, impl, schema); + WHEREprint( ENTITYget_name( entity ), TYPEget_where( entity ), impl, schema, true ); + UNIQUEprint( entity, impl, schema ); } /** print in classes file: class forward prototype, class typedefs * split out of ENTITYprint_new, which is now ENTITYprint_descriptors */ -void ENTITYprint_classes(Entity entity, FILE *classes) -{ - const char *n = ENTITYget_classname(entity); - fprintf(classes, "\nclass %s;\n", n); - fprintf(classes, "typedef %s * %sH;\n", n, n); - fprintf(classes, "typedef %s * %s_ptr;\n", n, n); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", n, n); - fprintf(classes, "typedef %s_ptr %s_var;\n", n, n); - fprintf(classes, "#define %s__set SDAI_DAObject__set\n", n); - fprintf(classes, "#define %s__set_var SDAI_DAObject__set_var\n", n); +void ENTITYprint_classes( Entity entity, FILE * classes ) { + const char * n = ENTITYget_classname( entity ); + fprintf( classes, "\nclass %s;\n", n ); + fprintf( classes, "typedef %s * %sH;\n", n, n ); + fprintf( classes, "typedef %s * %s_ptr;\n", n, n ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", n, n ); + fprintf( classes, "typedef %s_ptr %s_var;\n", n, n ); + fprintf( classes, "#define %s__set SDAI_DAObject__set\n", n ); + fprintf( classes, "#define %s__set_var SDAI_DAObject__set_var\n", n ); } diff --git a/src/exp2cxx/classes_entity.h b/src/exp2cxx/classes_entity.h index 32f184bc3..8e1c6e0be 100644 --- a/src/exp2cxx/classes_entity.h +++ b/src/exp2cxx/classes_entity.h @@ -1,12 +1,12 @@ #ifndef CLASSES_ENTITY_H #define CLASSES_ENTITY_H -const char *ENTITYget_classname(Entity); -Entity ENTITYget_superclass(Entity entity); -Entity ENTITYput_superclass(Entity entity); -int ENTITYhas_explicit_attributes(Entity e); -void ENTITYget_first_attribs(Entity entity, Linked_List result); -void ENTITYPrint(Entity entity, FILES *files, Schema schema, bool externMap); -void ENTITYprint_descriptors(Entity entity, FILE *createall, FILE *impl, Schema schema, bool externMap); -void ENTITYprint_classes(Entity entity, FILE *classes); +const char * ENTITYget_classname( Entity ); +Entity ENTITYget_superclass( Entity entity ); +Entity ENTITYput_superclass( Entity entity ); +int ENTITYhas_explicit_attributes( Entity e ); +void ENTITYget_first_attribs( Entity entity, Linked_List result ); +void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap ); +void ENTITYprint_descriptors( Entity entity, FILE * createall, FILE * impl, Schema schema, bool externMap ); +void ENTITYprint_classes( Entity entity, FILE * classes ); #endif diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 2b8ba07bf..4e24a8d24 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -4,6 +4,7 @@ #include "classes.h" #include +#include "sc_version_string.h" #include "class_strings.h" /** \file classes_misc.c @@ -30,73 +31,68 @@ extern int multiple_inheritance; * Returns: FILE* pointer to file created or NULL * Status: complete */ -FILE *FILEcreate(const char *filename) -{ - FILE *file; - const char *fn; - - if((file = fopen(filename, "w")) == NULL) { - fprintf(stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename); - return (NULL); +FILE * FILEcreate( const char * filename ) { + FILE * file; + const char * fn; + + if( ( file = fopen( filename, "w" ) ) == NULL ) { + fprintf( stderr, "**Error in SCHEMAprint: unable to create file %s ** \n", filename ); + return ( NULL ); } - fn = StrToConstant(filename); - fprintf(file, "#ifndef %s\n", fn); - fprintf(file, "#define %s\n\n", fn); + fn = StrToConstant ( filename ); + fprintf( file, "#ifndef %s\n", fn ); + fprintf( file, "#define %s\n\n", fn ); - fprintf(file, "// This file was generated by exp2cxx,\n// %s.\n", SC_VERSION); - fprintf(file, "// You probably don't want to edit it since your modifications\n"); - fprintf(file, "// will be lost if exp2cxx is used to regenerate it.\n\n"); - return (file); + fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version ); + fprintf( file, "// You probably don't want to edit it since your modifications\n" ); + fprintf( file, "// will be lost if exp2cxx is used to regenerate it.\n\n" ); + return ( file ); } /** closes a file opened with FILEcreate */ -void FILEclose(FILE *file) -{ - fprintf(file, "#endif\n"); - fclose(file); +void FILEclose( FILE * file ) { + fprintf( file, "#endif\n" ); + fclose( file ); } /** indicates whether the attribute is an aggregate */ -int isAggregate(Variable a) -{ - return(TYPEinherits_from(VARget_type(a), aggregate_)); +int isAggregate( Variable a ) { + return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); } /** indicates whether the attribute is an aggregate */ -int isAggregateType(const Type t) -{ - return(TYPEinherits_from(t, aggregate_)); +int isAggregateType( const Type t ) { + return( TYPEinherits_from( t, aggregate_ ) ); } /** \returns a pointer to a static buffer, containing a string which is the type used by the c++ data member access functions */ -const char *AccessType(Type t) -{ +const char * AccessType( Type t ) { Class_Of_Type class; static char nm [BUFSIZ]; - strncpy(nm, TypeName(t), BUFSIZ - 4); - if(TYPEis_entity(t)) { - strcat(nm, "_ptr"); + strncpy( nm, TypeName( t ), BUFSIZ - 4 ); + if( TYPEis_entity( t ) ) { + strcat( nm, "_ptr" ); return nm; - } else if(TYPEis_select(t) || TYPEis_aggregate(t)) { - strcat(nm, "_ptr"); + } else if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + strcat( nm, "_ptr" ); return nm; } - class = TYPEget_type(t); - if(class == enumeration_) { - strncpy(nm, TypeName(t), BUFSIZ - 2); - strcat(nm, "_var"); + class = TYPEget_type( t ); + if( class == enumeration_ ) { + strncpy( nm, TypeName( t ), BUFSIZ - 2 ); + strcat( nm, "_var" ); return nm; } - if(class == logical_) { - strncpy(nm, "Logical", BUFSIZ - 2); + if( class == logical_ ) { + strncpy( nm, "Logical", BUFSIZ - 2 ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - strncpy(nm, "Boolean", BUFSIZ - 2); + if( class == boolean_ ) { + strncpy( nm, "Boolean", BUFSIZ - 2 ); } return nm; } @@ -105,139 +101,133 @@ const char *AccessType(Type t) * * creates a new name with first character's in caps */ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } /* This function is out of date DAS */ -const char *EnumName(const char *oldname) -{ +const char * EnumName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENUM_PREFIX); - j = strlen(ENUM_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); - j = strlen(newname); + strcpy( newname, ENUM_PREFIX ); + j = strlen( ENUM_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *SelectName(const char *oldname) -{ +const char * SelectName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, TYPE_PREFIX); - newname [0] = ToUpper(newname [0]); - j = strlen(TYPE_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j - 1); - j = strlen(newname); + strcpy( newname, TYPE_PREFIX ); + newname [0] = ToUpper( newname [0] ); + j = strlen( TYPE_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j - 1 ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } /** \return fundamental type but as the string which corresponds to the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char *FundamentalType(const Type t, int report_reftypes) -{ - if(report_reftypes && TYPEget_head(t)) { - return("REFERENCE_TYPE"); +const char * FundamentalType( const Type t, int report_reftypes ) { + if( report_reftypes && TYPEget_head( t ) ) { + return( "REFERENCE_TYPE" ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: - return("sdaiINTEGER"); + return( "sdaiINTEGER" ); case real_: - return("sdaiREAL"); + return( "sdaiREAL" ); case string_: - return("sdaiSTRING"); + return( "sdaiSTRING" ); case binary_: - return("sdaiBINARY"); + return( "sdaiBINARY" ); case boolean_: - return("sdaiBOOLEAN"); + return( "sdaiBOOLEAN" ); case logical_: - return("sdaiLOGICAL"); + return( "sdaiLOGICAL" ); case number_: - return("sdaiNUMBER"); + return( "sdaiNUMBER" ); case generic_: - return("GENERIC_TYPE"); + return( "GENERIC_TYPE" ); case aggregate_: - return("AGGREGATE_TYPE"); + return( "AGGREGATE_TYPE" ); case array_: - return("ARRAY_TYPE"); + return( "ARRAY_TYPE" ); case bag_: - return("BAG_TYPE"); + return( "BAG_TYPE" ); case set_: - return("SET_TYPE"); + return( "SET_TYPE" ); case list_: - return("LIST_TYPE"); + return( "LIST_TYPE" ); case entity_: - return("sdaiINSTANCE"); + return( "sdaiINSTANCE" ); case enumeration_: - return("sdaiENUMERATION"); + return( "sdaiENUMERATION" ); case select_: - return ("sdaiSELECT"); + return ( "sdaiSELECT" ); default: - return("UNKNOWN_TYPE"); + return( "UNKNOWN_TYPE" ); } } /** this actually gets you the name of the variable that will be generated to be a * TypeDescriptor or subtype of TypeDescriptor to represent Type t in the dictionary. */ -const char *TypeDescriptorName(Type t) -{ +const char * TypeDescriptorName( Type t ) { static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if(!parent) { - parent = TYPEget_body(t)->entity->superscope; + if( !parent ) { + parent = TYPEget_body( t )->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf(b, "%s::%s%s", SCHEMAget_name(parent), TYPEprefix(t), - TYPEget_name(t)); + sprintf( b, "%s::%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), + TYPEget_name( t ) ); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char *GetTypeDescriptorName(Type t) -{ - switch(TYPEget_body(t)->type) { +const char * GetTypeDescriptorName( Type t ) { + switch( TYPEget_body( t )->type ) { case aggregate_: return "AggrTypeDescriptor"; @@ -272,19 +262,18 @@ const char *GetTypeDescriptorName(Type t) case generic_: return "TypeDescriptor"; default: - fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } /* NOTREACHED */ return ""; } -int ENTITYhas_explicit_attributes(Entity e) -{ - Linked_List l = ENTITYget_attributes(e); +int ENTITYhas_explicit_attributes( Entity e ) { + Linked_List l = ENTITYget_attributes( e ); int cnt = 0; - LISTdo(l, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( l, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { ++cnt; } LISTod; @@ -292,22 +281,21 @@ int ENTITYhas_explicit_attributes(Entity e) } -Entity ENTITYput_superclass(Entity entity) -{ +Entity ENTITYput_superclass( Entity entity ) { #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes(entity); + Linked_List l = ENTITYget_supertypes( entity ); EntityTag tag; - if(! LISTempty(l)) { + if( ! LISTempty( l ) ) { Entity super = 0; - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List list = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { /* assign superclass to be the first one on the list of parents */ - super = (Entity)LISTpeek_first(list); + super = ( Entity )LISTpeek_first( list ); } } else { Entity ignore = 0; @@ -315,51 +303,49 @@ Entity ENTITYput_superclass(Entity entity) /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo(l, e, Entity) + LISTdo( l, e, Entity ) /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if((! super) || (! ENTITYhas_explicit_attributes(super))) { + if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if(ignore) { - fprintf(stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name(entity), ENTITYget_name(e)); + if( ignore ) { + fprintf( stderr, "WARNING: multiple inheritance not implemented. In ENTITY %s, SUPERTYPE %s ignored.\n", ENTITYget_name( entity ), ENTITYget_name( e ) ); } LISTod; } - tag = (EntityTag) sc_malloc(sizeof(struct EntityTag_)); + tag = ( EntityTag ) sc_malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; - TYPEput_clientData(ENTITYget_type(entity), (ClientData) tag); + TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); return super; } return 0; } -Entity ENTITYget_superclass(Entity entity) -{ +Entity ENTITYget_superclass( Entity entity ) { EntityTag tag; - tag = (EntityTag) TYPEget_clientData(ENTITYget_type(entity)); - return (tag ? tag -> superclass : 0); + tag = ( EntityTag ) TYPEget_clientData( ENTITYget_type( entity ) ); + return ( tag ? tag -> superclass : 0 ); } -void ENTITYget_first_attribs(Entity entity, Linked_List result) -{ +void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo(ENTITYget_attributes(entity), attr, void *) - LISTadd_last(result, attr); + LISTdo( ENTITYget_attributes( entity ), attr, void * ) + LISTadd_last( result, attr ); LISTod; - supers = ENTITYget_supertypes(entity); - if(supers) { - ENTITYget_first_attribs((Entity)LISTget_first(supers), result); + supers = ENTITYget_supertypes( entity ); + if( supers ) { + ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); } } @@ -393,30 +379,28 @@ void ENTITYget_first_attribs(Entity entity, Linked_List result) ** if STEPattribute found with same name ** tell it to be * for reading and writing **/ -Variable VARis_type_shifter(Variable a) -{ - char *temp; - if(VARis_derived(a) || VARget_inverse(a)) { +Variable VARis_type_shifter( Variable a ) { + char * temp; + if( VARis_derived( a ) || VARget_inverse( a ) ) { return 0; } - temp = EXPRto_string(VARget_name(a)); - if(! strncmp(StrToLower(temp), "self\\", 5)) { + temp = EXPRto_string( VARget_name( a ) ); + if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - sc_free(temp); + sc_free( temp ); return a; } - sc_free(temp); + sc_free( temp ); return 0; } -Variable VARis_overrider(Entity e, Variable a) -{ +Variable VARis_overrider( Entity e, Variable a ) { Variable other; - char *tmp; - tmp = VARget_simple_name(a); - LISTdo(ENTITYget_supertypes(e), s, Entity) - if((other = ENTITYget_named_attribute(s, tmp)) - && other != a) { + char * tmp; + tmp = VARget_simple_name( a ); + LISTdo( ENTITYget_supertypes( e ), s, Entity ) + if( ( other = ENTITYget_named_attribute( s, tmp ) ) + && other != a ) { return other; } LISTod; @@ -426,16 +410,15 @@ Variable VARis_overrider(Entity e, Variable a) /** For a renamed type, returns the original (ancestor) type * from which t descends. Return NULL if t is top level. */ -Type TYPEget_ancestor(Type t) -{ +Type TYPEget_ancestor( Type t ) { Type i = t; - if(!TYPEget_head(i)) { + if( !TYPEget_head( i ) ) { return NULL; } - while(TYPEget_head(i)) { - i = TYPEget_head(i); + while( TYPEget_head( i ) ) { + i = TYPEget_head( i ); } return i; diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index fa001eefc..62d737aba 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -29,44 +29,43 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. static int type_count; /**< number each temporary type for same reason as \sa attr_count */ -extern char *non_unique_types_string(const Type type); +extern char * non_unique_types_string( const Type type ); -static void printEnumCreateHdr(FILE *, const Type); -static void printEnumCreateBody(FILE *, const Type); -static void printEnumAggrCrHdr(FILE *, const Type); -static void printEnumAggrCrBody(FILE *, const Type); +static void printEnumCreateHdr( FILE *, const Type ); +static void printEnumCreateBody( FILE *, const Type ); +static void printEnumAggrCrHdr( FILE *, const Type ); +static void printEnumAggrCrBody( FILE *, const Type ); -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); -int isMultiDimAggregateType(const Type t); +int isMultiDimAggregateType( const Type t ); -void Type_Description(const Type, char *); -void TypeBody_Description(TypeBody body, char *buf); +void Type_Description( const Type, char * ); +void TypeBody_Description( TypeBody body, char * buf ); /** write representation of expression to end of buf * * TODO: add buflen arg and check for overflow */ -void strcat_expr(Expression e, char *buf) -{ - if(e == LITERAL_INFINITY) { - strcat(buf, "?"); - } else if(e == LITERAL_PI) { - strcat(buf, "PI"); - } else if(e == LITERAL_E) { - strcat(buf, "E"); - } else if(e == LITERAL_ZERO) { - strcat(buf, "0"); - } else if(e == LITERAL_ONE) { - strcat(buf, "1"); - } else if(TYPEget_name(e)) { - strcat(buf, TYPEget_name(e)); - } else if(TYPEget_body(e->type)->type == integer_) { +void strcat_expr( Expression e, char * buf ) { + if( e == LITERAL_INFINITY ) { + strcat( buf, "?" ); + } else if( e == LITERAL_PI ) { + strcat( buf, "PI" ); + } else if( e == LITERAL_E ) { + strcat( buf, "E" ); + } else if( e == LITERAL_ZERO ) { + strcat( buf, "0" ); + } else if( e == LITERAL_ONE ) { + strcat( buf, "1" ); + } else if( TYPEget_name( e ) ) { + strcat( buf, TYPEget_name( e ) ); + } else if( TYPEget_body( e->type )->type == integer_ ) { char tmpbuf[30]; - sprintf(tmpbuf, "%d", e->u.integer); - strcat(buf, tmpbuf); + sprintf( tmpbuf, "%d", e->u.integer ); + strcat( buf, tmpbuf ); } else { - strcat(buf, "??"); + strcat( buf, "??" ); } } @@ -74,17 +73,16 @@ void strcat_expr(Expression e, char *buf) * * TODO: add buflen arg and check for overflow */ -void strcat_bounds(TypeBody b, char *buf) -{ - if(!b->upper) { +void strcat_bounds( TypeBody b, char * buf ) { + if( !b->upper ) { return; } - strcat(buf, " ["); - strcat_expr(b->lower, buf); - strcat(buf, ":"); - strcat_expr(b->upper, buf); - strcat(buf, "]"); + strcat( buf, " [" ); + strcat_expr( b->lower, buf ); + strcat( buf, ":" ); + strcat_expr( b->upper, buf ); + strcat( buf, "]" ); } /****************************************************************** @@ -102,30 +100,28 @@ void strcat_bounds(TypeBody b, char *buf) ** - Changed to match CD2 Part 23, 1/14/97 DAS ** Change Date: 5/22/91 CD ******************************************************************/ -const char *EnumCElementName(Type type, Expression expr) -{ +const char * EnumCElementName( Type type, Expression expr ) { static char buf [BUFSIZ]; - sprintf(buf, "%s__", - EnumName(TYPEget_name(type))); - strcat(buf, StrToLower(EXPget_name(expr))); + sprintf( buf, "%s__", + EnumName( TYPEget_name( type ) ) ); + strcat( buf, StrToLower( EXPget_name( expr ) ) ); return buf; } -char *CheckEnumSymbol(char *s) -{ +char * CheckEnumSymbol( char * s ) { static char b [BUFSIZ]; - if(strcmp(s, "sdaiTRUE") - && strcmp(s, "sdaiFALSE") - && strcmp(s, "sdaiUNKNOWN")) { + if( strcmp( s, "sdaiTRUE" ) + && strcmp( s, "sdaiFALSE" ) + && strcmp( s, "sdaiUNKNOWN" ) ) { /* if the symbol is not a reserved one */ - return (s); + return ( s ); } else { - strcpy(b, s); - strcat(b, "_"); - fprintf(stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __func__, s, b); - return (b); + strcpy( b, s ); + strcat( b, "_" ); + fprintf( stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b ); + return ( b ); } } @@ -133,16 +129,15 @@ char *CheckEnumSymbol(char *s) * return printable version of entire type definition * return it in static buffer */ -char *TypeDescription(const Type t) -{ +char * TypeDescription( const Type t ) { static char buf[6000]; buf[0] = '\0'; - if(TYPEget_head(t)) { - Type_Description(TYPEget_head(t), buf); + if( TYPEget_head( t ) ) { + Type_Description( TYPEget_head( t ), buf ); } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } /* should also print out where clause here */ @@ -155,222 +150,217 @@ char *TypeDescription(const Type t) ** Description: Writes enum type descriptors and classes. ** Change Date: ********************************************************************/ -void TYPEenum_inc_print(const Type type, FILE *inc) -{ +void TYPEenum_inc_print( const Type type, FILE * inc ) { Expression expr; char tdnm[BUFSIZ], enumAggrNm[BUFSIZ]; - const char *n; /* pointer to class name */ + const char * n; /* pointer to class name */ int cnt = 0; /* print c++ enumerated values for class */ - fprintf(inc, "enum %s {\n", EnumName(TYPEget_name(type))); + fprintf( inc, "enum %s {\n", EnumName( TYPEget_name( type ) ) ); - LISTdo_links(TYPEget_body(type)->list, link) + LISTdo_links( TYPEget_body( type )->list, link ) /* print the elements of the c++ enum type */ - expr = (Expression)link->data; - if(cnt != 0) { - fprintf(inc, ",\n"); + expr = ( Expression )link->data; + if( cnt != 0 ) { + fprintf( inc, ",\n" ); } ++cnt; - fprintf(inc, " %s", EnumCElementName(type, expr)); + fprintf( inc, " %s", EnumCElementName( type, expr ) ); LISTod - fprintf(inc, ",\n %s_unset\n};\n", EnumName(TYPEget_name(type))); + fprintf( inc, ",\n %s_unset\n};\n", EnumName( TYPEget_name( type ) ) ); /* print class for enumeration */ - n = TYPEget_ctype(type); - fprintf(inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n); + n = TYPEget_ctype( type ); + fprintf( inc, "\nclass SC_SCHEMA_EXPORT %s : public SDAI_Enum {\n", n ); - fprintf(inc, " protected:\n EnumTypeDescriptor *type;\n\n"); + fprintf( inc, " protected:\n EnumTypeDescriptor *type;\n\n" ); /* constructors */ - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; - fprintf(inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm); - fprintf(inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" - " : type(et) { set_value (e); }\n", - n, EnumName(TYPEget_name(type)), tdnm); - fprintf(inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype(type)); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; + fprintf( inc, " public:\n %s (const char * n =0, Enum" + "TypeDescriptor *et =%s);\n", n, tdnm ); + fprintf( inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" + " : type(et) { set_value (e); }\n", + n, EnumName( TYPEget_name( type ) ), tdnm ); /* destructor */ - fprintf(inc, " ~%s () { }\n", n); + fprintf( inc, " ~%s () { }\n", n ); /* operator = */ - fprintf(inc, " %s& operator= (const %s& e)\n", - n, TYPEget_ctype(type)); - fprintf(inc, " { set_value (e); return *this; }\n"); + fprintf( inc, " %s& operator= (const %s& e)\n", + n, TYPEget_ctype( type ) ); + fprintf( inc, " { set_value (e); return *this; }\n" ); /* operator to cast to an enumerated type */ - fprintf(inc, " operator %s () const;\n", - EnumName(TYPEget_name(type))); + fprintf( inc, " operator %s () const;\n", + EnumName( TYPEget_name( type ) ) ); /* others */ - fprintf(inc, "\n inline virtual const char * Name () const\n"); - fprintf(inc, " { return type->Name(); }\n"); - fprintf(inc, " inline virtual int no_elements () const" - " { return %d; }\n", cnt); - fprintf(inc, " virtual const char * element_at (int n) const;\n"); + fprintf( inc, "\n inline virtual const char * Name () const\n" ); + fprintf( inc, " { return type->Name(); }\n" ); + fprintf( inc, " inline virtual int no_elements () const" + " { return %d; }\n", cnt ); + fprintf( inc, " virtual const char * element_at (int n) const;\n" ); /* end class definition */ - fprintf(inc, "};\n"); + fprintf( inc, "};\n" ); - fprintf(inc, "\ntypedef %s * %s_ptr;\n", n, n); - fprintf(inc, "\ntypedef const %s * %s_ptr_c;\n", n, n); + fprintf( inc, "\ntypedef %s * %s_ptr;\n", n, n ); + fprintf( inc, "\ntypedef const %s * %s_ptr_c;\n", n, n ); /* Print ObjectStore Access Hook function */ - printEnumCreateHdr(inc, type); + printEnumCreateHdr( inc, type ); /* DAS brandnew above */ /* print things for aggregate class */ - sprintf(enumAggrNm, "%s_agg", n); + sprintf( enumAggrNm, "%s_agg", n ); - fprintf(inc, "\nclass %s_agg : public EnumAggregate {\n", n); + fprintf( inc, "\nclass %s_agg : public EnumAggregate {\n", n ); - fprintf(inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n"); - fprintf(inc, " public:\n"); - fprintf(inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm); - fprintf(inc, " virtual ~%s_agg();\n", n); - fprintf(inc, " virtual SingleLinkNode * NewNode()\n"); - fprintf(inc, " { return new EnumNode (new %s( \"\", enum_type )); }" - "\n", n); + fprintf( inc, " protected:\n EnumTypeDescriptor *enum_type;\n\n" ); + fprintf( inc, " public:\n" ); + fprintf( inc, " %s_agg( EnumTypeDescriptor * =%s);\n", n, tdnm ); + fprintf( inc, " virtual ~%s_agg();\n", n ); + fprintf( inc, " virtual SingleLinkNode * NewNode()\n" ); + fprintf( inc, " { return new EnumNode (new %s( \"\", enum_type )); }" + "\n", n ); - fprintf(inc, "};\n"); + fprintf( inc, "};\n" ); - fprintf(inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n); - fprintf(inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n); + fprintf( inc, "\ntypedef %s_agg * %s_agg_ptr;\n", n, n ); + fprintf( inc, "\ntypedef const %s_agg * %s_agg_ptr_c;\n", n, n ); /* DAS brandnew below */ /* DAS creation function for enum aggregate class */ - printEnumAggrCrHdr(inc, type); + printEnumAggrCrHdr( inc, type ); /* DAS brandnew above */ } -void TYPEenum_lib_print(const Type type, FILE *f) -{ +void TYPEenum_lib_print( const Type type, FILE * f ) { DictionaryEntry de; Expression expr; - const char *n; /* pointer to class name */ + const char * n; /* pointer to class name */ char c_enum_ele [BUFSIZ]; - n = TYPEget_ctype(type); + n = TYPEget_ctype( type ); /* set up the dictionary info */ - fprintf(f, "const char *\n%s::element_at (int n) const {\n", n); - fprintf(f, " switch (n) {\n"); - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); - c_enum_ele[BUFSIZ - 1] = '\0'; - fprintf(f, " case %s: return \"%s\";\n", - c_enum_ele, - StrToUpper(EXPget_name(expr))); + fprintf( f, "const char *\n%s::element_at (int n) const {\n", n ); + fprintf( f, " switch (n) {\n" ); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); + c_enum_ele[BUFSIZ-1] = '\0'; + fprintf( f, " case %s: return \"%s\";\n", + c_enum_ele, + StrToUpper( EXPget_name( expr ) ) ); } - fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); - fprintf(f, " default : return \"UNSET\";\n }\n}\n"); + fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); + fprintf( f, " default : return \"UNSET\";\n }\n}\n" ); /* constructors */ /* construct with character string */ - fprintf(f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" - " : type(et)\n{\n", n, n); - fprintf(f, " set_value (n);\n}\n"); + fprintf( f, "\n%s::%s (const char * n, EnumTypeDescriptor *et)\n" + " : type(et)\n{\n", n, n ); + fprintf( f, " set_value (n);\n}\n" ); /* cast operator to an enumerated type */ - fprintf(f, "\n%s::operator %s () const {\n", n, - EnumName(TYPEget_name(type))); - fprintf(f, " switch (v) {\n"); - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - strncpy(c_enum_ele, EnumCElementName(type, expr), BUFSIZ); - fprintf(f, " case %s : ", c_enum_ele); - fprintf(f, "return %s;\n", c_enum_ele); + fprintf( f, "\n%s::operator %s () const {\n", n, + EnumName( TYPEget_name( type ) ) ); + fprintf( f, " switch (v) {\n" ); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ ); + fprintf( f, " case %s : ", c_enum_ele ); + fprintf( f, "return %s;\n", c_enum_ele ); } /* print the last case with the default so sun c++ doesn't complain */ - fprintf(f, " case %s_unset :\n", EnumName(TYPEget_name(type))); - fprintf(f, " default : return %s_unset;\n }\n}\n", EnumName(TYPEget_name(type))); + fprintf( f, " case %s_unset :\n", EnumName( TYPEget_name( type ) ) ); + fprintf( f, " default : return %s_unset;\n }\n}\n", EnumName( TYPEget_name( type ) ) ); - printEnumCreateBody(f, type); + printEnumCreateBody( f, type ); /* print the enum aggregate functions */ - fprintf(f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n); - fprintf(f, " : enum_type(et)\n{\n}\n\n"); - fprintf(f, "%s_agg::~%s_agg()\n{\n}\n", n, n); + fprintf( f, "\n%s_agg::%s_agg( EnumTypeDescriptor *et )\n", n, n ); + fprintf( f, " : enum_type(et)\n{\n}\n\n" ); + fprintf( f, "%s_agg::~%s_agg()\n{\n}\n", n, n ); - printEnumAggrCrBody(f, type); + printEnumAggrCrBody( f, type ); } -void TYPEPrint_h(const Type type, FILE *file) -{ - DEBUG("Entering TYPEPrint_h for %s\n", TYPEget_ctype(type)); +void TYPEPrint_h( const Type type, FILE * file ) { + DEBUG( "Entering TYPEPrint_h for %s\n", TYPEget_ctype( type ) ); - if(TYPEis_enumeration(type)) { - TYPEenum_inc_print(type, file); - } else if(TYPEis_select(type)) { - TYPEselect_inc_print(type, file); + if ( TYPEis_enumeration( type ) ) { + TYPEenum_inc_print( type, file ); + } else if ( TYPEis_select( type ) ) { + TYPEselect_inc_print( type, file ); } - fprintf(file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype(type)); + fprintf( file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype( type ) ); - DEBUG("DONE TYPEPrint_h\n"); + DEBUG( "DONE TYPEPrint_h\n" ); } -void TYPEPrint_cc(const Type type, const filenames_t *names, FILE *hdr, FILE *impl, Schema schema) -{ - DEBUG("Entering TYPEPrint_cc for %s\n", names->impl); +void TYPEPrint_cc( const Type type, const filenames_t * names, FILE * hdr, FILE * impl, Schema schema ) { + DEBUG( "Entering TYPEPrint_cc for %s\n", names->impl ); - fprintf(impl, "#include \"schema.h\"\n"); - fprintf(impl, "#include \"sc_memmgr.h\"\n"); - fprintf(impl, "#include \"%s\"\n\n", names->header); + fprintf( impl, "#include \"schema.h\"\n" ); + fprintf( impl, "#include \"sc_memmgr.h\"\n" ); + fprintf( impl, "#include \"%s\"\n\n", names->header ); - if(TYPEis_enumeration(type)) { - TYPEenum_lib_print(type, impl); - } else if(TYPEis_select(type)) { - TYPEselect_lib_print(type, impl); + if ( TYPEis_enumeration( type ) ) { + TYPEenum_lib_print( type, impl ); + } else if ( TYPEis_select( type ) ) { + TYPEselect_lib_print( type, impl ); } - fprintf(impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype(type)); - fprintf(impl, " std::string str;\n"); + fprintf( impl, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype( type ) ); + fprintf( impl, " std::string str;\n" ); /* moved from SCOPEPrint in classes_wrapper */ - TYPEprint_new(type, impl, schema, true); - TYPEprint_init(type, hdr, impl, schema); - fprintf(impl, "}\n\n"); + TYPEprint_new( type, impl, schema, true ); + TYPEprint_init( type, hdr, impl, schema ); + fprintf( impl, "}\n\n" ); - DEBUG("DONE TYPEPrint_cc\n"); + DEBUG( "DONE TYPEPrint_cc\n" ); } -void TYPEPrint(const Type type, FILES *files, Schema schema) -{ - FILE *hdr, * impl; - filenames_t names = getTypeFilenames(type); +void TYPEPrint( const Type type, FILES *files, Schema schema ) { + FILE * hdr, * impl; + filenames_t names = getTypeFilenames( type ); - fprintf(files->inc, "#include \"%s\"\n", names.header); + fprintf( files->inc, "#include \"%s\"\n", names.header ); - fprintf(files->init, " init_%s( reg );\n", TYPEget_ctype(type)); + fprintf( files->init, " init_%s( reg );\n", TYPEget_ctype( type ) ); - if(mkDirIfNone("type") == -1) { - fprintf(stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); - perror(0); + if( mkDirIfNone( "type" ) == -1 ) { + fprintf( stderr, "At %s:%d - mkdir() failed with error ", __FILE__, __LINE__); + perror( 0 ); abort(); } - hdr = FILEcreate(names.header); - impl = FILEcreate(names.impl); - assert(hdr && impl && "error creating files"); - fprintf(files->unity.type.hdr, "#include \"%s\"\n", names.header); - fprintf(files->unity.type.impl, "#include \"%s\"\n", names.impl); + hdr = FILEcreate( names.header ); + impl = FILEcreate( names.impl ); + assert( hdr && impl && "error creating files" ); + fprintf( files->unity.type.hdr, "#include \"%s\"\n", names.header ); + fprintf( files->unity.type.impl, "#include \"%s\"\n", names.impl ); - TYPEPrint_h(type, hdr); - TYPEPrint_cc(type, &names, hdr, impl, schema); + TYPEPrint_h( type, hdr ); + TYPEPrint_cc( type, &names, hdr, impl, schema ); - FILEclose(hdr); - FILEclose(impl); + FILEclose( hdr ); + FILEclose( impl ); } /** @@ -381,45 +371,41 @@ void TYPEPrint(const Type type, FILES *files, Schema schema) * NOTE - "Print ObjectStore Access Hook function" comment seen at one of * the calls seems to imply it's ObjectStore specific... */ -static void printEnumCreateHdr(FILE *inc, const Type type) -{ - const char *nm = TYPEget_ctype(type); +static void printEnumCreateHdr( FILE * inc, const Type type ) { + const char * nm = TYPEget_ctype( type ); - fprintf(inc, " SDAI_Enum * create_%s();\n", nm); + fprintf( inc, " SDAI_Enum * create_%s();\n", nm ); } /** See header comment above by printEnumCreateHdr. */ -static void printEnumCreateBody(FILE *lib, const Type type) -{ - const char *nm = TYPEget_ctype(type); +static void printEnumCreateBody( FILE * lib, const Type type ) { + const char * nm = TYPEget_ctype( type ); char tdnm[BUFSIZ]; - tdnm[BUFSIZ - 1] = '\0'; + tdnm[BUFSIZ-1] = '\0'; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - fprintf(lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm); - fprintf(lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm); + fprintf( lib, "\nSDAI_Enum *\ncreate_%s ()\n{\n", nm ); + fprintf( lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm ); } /** Similar to printEnumCreateHdr above for the enum aggregate. */ -static void printEnumAggrCrHdr(FILE *inc, const Type type) -{ - const char *n = TYPEget_ctype(type); +static void printEnumAggrCrHdr( FILE * inc, const Type type ) { + const char * n = TYPEget_ctype( type ); /* const char *n = ClassName( TYPEget_name(type) ));*/ - fprintf(inc, " STEPaggregate * create_%s_agg ();\n", n); + fprintf( inc, " STEPaggregate * create_%s_agg ();\n", n ); } -static void printEnumAggrCrBody(FILE *lib, const Type type) -{ - const char *n = TYPEget_ctype(type); +static void printEnumAggrCrBody( FILE * lib, const Type type ) { + const char * n = TYPEget_ctype( type ); char tdnm[BUFSIZ]; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - fprintf(lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n); - fprintf(lib, " return new %s_agg( %s );\n}\n", n, tdnm); + fprintf( lib, "\nSTEPaggregate *\ncreate_%s_agg ()\n{\n", n ); + fprintf( lib, " return new %s_agg( %s );\n}\n", n, tdnm ); } /** ************************************************************************ @@ -437,14 +423,13 @@ static void printEnumAggrCrBody(FILE *lib, const Type type) ** Status: 16-Mar-1993 kcm; updated 04-Feb-1997 dar ** Dec 2011 - MAP - remove goto **************************************************************************/ -void TYPEprint_typedefs(Type t, FILE *classes) -{ +void TYPEprint_typedefs( Type t, FILE * classes ) { char nm [BUFSIZ]; Type i; bool aggrNot1d = true; /* added so I can get rid of a goto */ /* Print the typedef statement (poss also a forward class def: */ - if(TYPEis_enumeration(t)) { + if( TYPEis_enumeration( t ) ) { /* For enums and sels (else clause below), we need forward decl's so that if we later come across a type which is an aggregate of one of them, we'll be able to process it. For selects, we also need a decl @@ -453,32 +438,32 @@ void TYPEprint_typedefs(Type t, FILE *classes) same is basically true for the select, but a sel containing an ent containing a sel needs the forward decl (trust me ;-) ). */ - if(!TYPEget_head(t)) { + if( !TYPEget_head( t ) ) { /* Only print this enum if it is an actual type and not a redefi- nition of another enum. (Those are printed at the end of the classes file - after all the actual enum's. They must be printed last since they depend on the others.) */ - strncpy(nm, TYPEget_ctype(t), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "class %s_agg;\n", nm); + strncpy( nm, TYPEget_ctype( t ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "class %s_agg;\n", nm ); } - } else if(TYPEis_select(t)) { - if(!TYPEget_head(t)) { + } else if( TYPEis_select( t ) ) { + if( !TYPEget_head( t ) ) { /* Same comment as above. */ - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "class %s;\n", nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "class %s_agg;\n", nm); - fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "class %s;\n", nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "class %s_agg;\n", nm ); + fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); } } else { - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* One exceptional case - a 1d aggregate of an enum or select. We must wait till the enum/sel itself has been processed. To ensure this, we process all such 1d aggrs in a special @@ -489,26 +474,26 @@ void TYPEprint_typedefs(Type t, FILE *classes) aggrNot1d = false; } } - if(aggrNot1d) { + if( aggrNot1d ) { /* At this point, we'll print typedefs for types which are redefined fundamental types and their aggregates, and for 2D aggregates(aggre- gates of aggregates) of enum's and selects. */ - strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); - if(TYPEis_aggregate(t)) { - fprintf(classes, "typedef %s * %sH;\n", nm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "typedef %s_ptr %s_var;\n", nm, nm); + strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); + if( TYPEis_aggregate( t ) ) { + fprintf( classes, "typedef %s * %sH;\n", nm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "typedef %s_ptr %s_var;\n", nm, nm ); } } } /* Print the extern statement: */ - strncpy(nm, TYPEtd_name(t), BUFSIZ); - fprintf(classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName(t), nm); + strncpy( nm, TYPEtd_name( t ), BUFSIZ ); + fprintf( classes, "extern SC_SCHEMA_EXPORT %s *%s;\n", GetTypeDescriptorName( t ), nm ); } /** ** @@ -520,92 +505,90 @@ void TYPEprint_typedefs(Type t, FILE *classes) initialize it in the .init.cc file (DAR - all initialization done in fn TYPEprint_init() (below) which is done in exp2cxx's 1st pass only.) *****/ -void TYPEprint_descriptions(const Type type, FILES *files, Schema schema) -{ +void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], nm [BUFSIZ]; Type i; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; /* define type descriptor pointer */ /* in source - declare the real definition of the pointer */ /* i.e. in the .cc file */ - fprintf(files -> lib, "%s *%s;\n", GetTypeDescriptorName(type), tdnm); + fprintf( files -> lib, "%s *%s;\n", GetTypeDescriptorName( type ), tdnm ); - if(isAggregateType(type)) { - const char *ctype = TYPEget_ctype(type); + if( isAggregateType( type ) ) { + const char * ctype = TYPEget_ctype( type ); - fprintf(files->inc, "STEPaggregate * create_%s ();\n\n", - ClassName(TYPEget_name(type))); + fprintf( files->inc, "STEPaggregate * create_%s ();\n\n", + ClassName( TYPEget_name( type ) ) ); - fprintf(files->lib, - "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", - ClassName(TYPEget_name(type)), ctype); + fprintf( files->lib, + "STEPaggregate *\ncreate_%s () { return create_%s(); }\n", + ClassName( TYPEget_name( type ) ), ctype ); /* this function is assigned to the aggrCreator var in TYPEprint_new */ } - if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { + if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { /* If we're a renamed enum type, just print a few typedef's to the * original and some specialized create functions: */ - strncpy(base, EnumName(TYPEget_name(i)), BUFSIZ); - strncpy(nm, EnumName(TYPEget_name(type)), BUFSIZ); - fprintf(files->inc, "typedef %s %s;\n", base, nm); - strncpy(base, TYPEget_ctype(i), BUFSIZ); - strncpy(nm, TYPEget_ctype(type), BUFSIZ); - fprintf(files->inc, "typedef %s %s;\n", base, nm); - printEnumCreateHdr(files->inc, type); - printEnumCreateBody(files->lib, type); - fprintf(files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); - printEnumAggrCrHdr(files->inc, type); - printEnumAggrCrBody(files->lib, type); + strncpy( base, EnumName( TYPEget_name( i ) ), BUFSIZ ); + strncpy( nm, EnumName( TYPEget_name( type ) ), BUFSIZ ); + fprintf( files->inc, "typedef %s %s;\n", base, nm ); + strncpy( base, TYPEget_ctype( i ), BUFSIZ ); + strncpy( nm, TYPEget_ctype( type ), BUFSIZ ); + fprintf( files->inc, "typedef %s %s;\n", base, nm ); + printEnumCreateHdr( files->inc, type ); + printEnumCreateBody( files->lib, type ); + fprintf( files->inc, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( files->inc, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); + printEnumAggrCrHdr( files->inc, type ); + printEnumAggrCrBody( files->lib, type ); return; } - if(!TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - if(TYPEis_enumeration(type)) { - TYPEPrint(type, files, schema); + if( !TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + if( TYPEis_enumeration( type ) ) { + TYPEPrint( type, files, schema ); } /* so we don't do anything for non-enums??? */ } else { - TYPEprint_new(type, files->create, schema, false); - TYPEprint_init(type, files->inc, files->init, schema); + TYPEprint_new( type, files->create, schema, false ); + TYPEprint_init( type, files->inc, files->init, schema ); } } -void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema) -{ +void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ) { char tdnm [BUFSIZ]; char typename_buf[MAX_LEN]; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - if(isAggregateType(type)) { - AGGRprint_init(header, impl, type, tdnm, type->symbol.name); + if( isAggregateType( type ) ) { + AGGRprint_init( header, impl, type, tdnm, type->symbol.name ); } /* fill in the TD's values in the SchemaInit function (it is already declared with basic values) */ - if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - fprintf(impl, " %s->ReferentType(%s);\n", tdnm, typename_buf); + if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + fprintf( impl, " %s->ReferentType(%s);\n", tdnm, typename_buf ); } else { - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case aggregate_: /* aggregate_ should not happen? DAS */ case array_: case bag_: case set_: case list_: { - if(isMultiDimAggregateType(type)) { - print_typechain(header, impl, TYPEget_body(type)->base, - typename_buf, schema, type->symbol.name); - fprintf(impl, " %s->ReferentType(%s);\n", tdnm, - typename_buf); + if( isMultiDimAggregateType( type ) ) { + print_typechain( header, impl, TYPEget_body( type )->base, + typename_buf, schema, type->symbol.name ); + fprintf( impl, " %s->ReferentType(%s);\n", tdnm, + typename_buf ); } break; } @@ -616,73 +599,71 @@ void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema) /* DAR - moved fn call below from TYPEselect_print to here to put all init ** info together. */ - if(TYPEis_select(type)) { - TYPEselect_init_print(type, impl); + if( TYPEis_select( type ) ) { + TYPEselect_init_print( type, impl ); } #ifdef NEWDICT /* DAS New SDAI Dictionary 5/95 */ /* insert the type into the schema descriptor */ - fprintf(impl, - " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", - SCHEMAget_name(schema), tdnm); + fprintf( impl, + " ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n", + SCHEMAget_name( schema ), tdnm ); #endif /* insert into type dictionary */ - fprintf(impl, " reg.AddType (*%s);\n", tdnm); + fprintf( impl, " reg.AddType (*%s);\n", tdnm ); } /** print name, fundamental type, and description initialization function calls */ -void TYPEprint_nm_ft_desc(Schema schema, const Type type, FILE *f, char *endChars) -{ - fprintf(f, " \"%s\", // Name\n", PrettyTmpName(TYPEget_name(type))); - fprintf(f, " %s, // FundamentalType\n", FundamentalType(type, 1)); - fprintf(f, " %s::schema, // Originating Schema\n", SCHEMAget_name(schema)); - fprintf(f, " \"%s\"%s // Description\n", TypeDescription(type), endChars); +void TYPEprint_nm_ft_desc( Schema schema, const Type type, FILE * f, char * endChars ) { + fprintf( f, " \"%s\", // Name\n", PrettyTmpName( TYPEget_name( type ) ) ); + fprintf( f, " %s, // FundamentalType\n", FundamentalType( type, 1 ) ); + fprintf( f, " %s::schema, // Originating Schema\n", SCHEMAget_name( schema ) ); + fprintf( f, " \"%s\"%s // Description\n", TypeDescription( type ), endChars ); } /** new space for a variable of type TypeDescriptor (or subtype). This * function is called for Types that have an Express name. */ -void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) -{ - Type tmpType = TYPEget_head(type); +void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) { + Type tmpType = TYPEget_head( type ); Type bodyType = tmpType; /* define type definition */ /* in source - the real definition of the TypeDescriptor */ - if(TYPEis_select(type)) { - char *temp; - temp = non_unique_types_string(type); - fprintf(create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name(type), temp); - sc_free(temp); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (SelectCreator) create_%s); // Creator function\n", SelectName(TYPEget_name(type))); + if( TYPEis_select( type ) ) { + char * temp; + temp = non_unique_types_string( type ); + fprintf( create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name( type ), temp ); + sc_free( temp ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (SelectCreator) create_%s); // Creator function\n", SelectName( TYPEget_name( type ) ) ); } else { - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case boolean_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (EnumCreator) create_BOOLEAN); // Creator function\n"); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (EnumCreator) create_BOOLEAN); // Creator function\n" ); break; case logical_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (EnumCreator) create_LOGICAL); // Creator function\n"); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (EnumCreator) create_LOGICAL); // Creator function\n" ); break; case enumeration_: - fprintf(create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); + fprintf( create, " %s = new EnumTypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); /* get the type name of the underlying type - it is the type that needs to get created */ - tmpType = TYPEget_head(type); - if(tmpType) { + tmpType = TYPEget_head( type ); + if( tmpType ) { bodyType = tmpType; - while(tmpType) { + while( tmpType ) { bodyType = tmpType; - tmpType = TYPEget_head(tmpType); + tmpType = TYPEget_head( tmpType ); } - fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(bodyType)); + fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( bodyType ) ); } else { - fprintf(create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype(type)); + fprintf( create, " (EnumCreator) create_%s); // Creator function\n", TYPEget_ctype( type ) ); } break; case aggregate_: @@ -690,20 +671,20 @@ void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) case bag_: case set_: case list_: - fprintf(create, "\n %s = new %s (\n", TYPEtd_name(type), GetTypeDescriptorName(type)); - TYPEprint_nm_ft_desc(schema, type, create, ","); - fprintf(create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName(TYPEget_name(type))); + fprintf( create, "\n %s = new %s (\n", TYPEtd_name( type ), GetTypeDescriptorName( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, "," ); + fprintf( create, " (AggregateCreator) create_%s); // Creator function\n\n", ClassName( TYPEget_name( type ) ) ); break; default: - fprintf(create, " %s = new TypeDescriptor (\n", TYPEtd_name(type)); - TYPEprint_nm_ft_desc(schema, type, create, ");"); + fprintf( create, " %s = new TypeDescriptor (\n", TYPEtd_name( type ) ); + TYPEprint_nm_ft_desc( schema, type, create, ");" ); break; } } /* add the type to the Schema dictionary entry */ - fprintf(create, " %s::schema->AddType(%s);\n", SCHEMAget_name(schema), TYPEtd_name(type)); + fprintf( create, " %s::schema->AddType(%s);\n", SCHEMAget_name( schema ), TYPEtd_name( type ) ); - WHEREprint(TYPEtd_name(type), type->where, create, 0, needWR); + WHEREprint( TYPEtd_name( type ), type->where, create, 0, needWR ); } /** Get the TypeDescriptor variable name that t's TypeDescriptor references (if @@ -725,23 +706,22 @@ void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR) Nov 2011 - MAP - modified to insert scope operator into variable name. Reason: use of namespace for global variables */ -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) -{ +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { /* It looks like TYPEget_head(t) is true when processing a type that refers to another type. e.g. when processing "name" in: TYPE name = label; ENDTYPE; TYPE label = STRING; ENDTYPE; DAS */ - if(TYPEget_head(t)) { + if( TYPEget_head( t ) ) { /* this means that it is defined in an Express TYPE stmt and it refers to another Express TYPE stmt */ /* it would be a reference_ type */ /* a TypeDescriptor of the form t_ */ - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_head(t)->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_head(t))); + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_head( t )->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_head( t ) ) ); return 1; } else { - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: case real_: case boolean_: @@ -751,7 +731,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) case number_: /* one of the SCL builtin TypeDescriptors of the form t_STRING_TYPE, or t_REAL_TYPE */ - sprintf(buf, "%s%s", TD_PREFIX, FundamentalType(t, 0)); + sprintf( buf, "%s%s", TD_PREFIX, FundamentalType( t, 0 ) ); return 1; break; @@ -762,7 +742,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) break; case entity_: - sprintf(buf, "%s", TYPEtd_name(t)); + sprintf( buf, "%s", TYPEtd_name( t ) ); /* following assumes we are not in a nested entity */ /* otherwise we should search upward for schema */ return 1; @@ -776,11 +756,11 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) /* referent TypeDescriptor will be the one for the element unless it is a multidimensional aggregate then return 0 */ - if(isMultiDimAggregateType(t)) { - if(TYPEget_name(TYPEget_body(t)->base)) { - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_body(t)->base->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); + if( isMultiDimAggregateType( t ) ) { + if( TYPEget_name( TYPEget_body( t )->base ) ) { + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_body( t )->base->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); return 1; } @@ -792,22 +772,22 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) for element */ /* being an aggregate implies that base below is not 0 */ - if(TYPEget_body(TYPEget_body(t)->base)->type == enumeration_ || - TYPEget_body(TYPEget_body(t)->base)->type == select_) { + if( TYPEget_body( TYPEget_body( t )->base )->type == enumeration_ || + TYPEget_body( TYPEget_body( t )->base )->type == select_ ) { - sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); + sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); return 1; - } else if(TYPEget_name(TYPEget_body(t)->base)) { - if(TYPEget_body(TYPEget_body(t)->base)->type == entity_) { - sprintf(buf, "%s", TYPEtd_name(TYPEget_body(t)->base)); + } else if( TYPEget_name( TYPEget_body( t )->base ) ) { + if( TYPEget_body( TYPEget_body( t )->base )->type == entity_ ) { + sprintf( buf, "%s", TYPEtd_name( TYPEget_body( t )->base ) ); return 1; } - sprintf(buf, "%s::%s%s", - SCHEMAget_name(TYPEget_body(t)->base->superscope), - TYPEprefix(t), TYPEget_name(TYPEget_body(t)->base)); + sprintf( buf, "%s::%s%s", + SCHEMAget_name( TYPEget_body( t )->base->superscope ), + TYPEprefix( t ), TYPEget_name( TYPEget_body( t )->base ) ); return 1; } - return TYPEget_RefTypeVarNm(TYPEget_body(t)->base, buf, schema); + return TYPEget_RefTypeVarNm( TYPEget_body( t )->base, buf, schema ); } break; default: @@ -845,284 +825,277 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) that can be referenced to refer to the type that was created for Type t. */ -void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name) -{ +void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ) { /* if we've been called, current type has no name */ /* nor is it a built-in type */ /* the type_count variable is there for debugging purposes */ - const char *ctype = TYPEget_ctype(t); + const char * ctype = TYPEget_ctype( t ); int count = type_count++; char name_buf[MAX_LEN]; int s; - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case aggregate_: case array_: case bag_: case set_: case list_: /* create a new TypeDescriptor variable, e.g. t1, and new space for it */ - fprintf(impl, " %s * %s%d = new %s;\n", - GetTypeDescriptorName(t), TD_PREFIX, count, - GetTypeDescriptorName(t)); + fprintf( impl, " %s * %s%d = new %s;\n", + GetTypeDescriptorName( t ), TD_PREFIX, count, + GetTypeDescriptorName( t ) ); - fprintf(impl, - " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", - TD_PREFIX, count, ctype, " // Creator function\n"); + fprintf( impl, + " %s%d->AssignAggrCreator((AggregateCreator) create_%s);%s", + TD_PREFIX, count, ctype, " // Creator function\n" ); - s = sprintf(name_buf, "%s%d", TD_PREFIX, count); - assert((s > 0) && (s < MAX_LEN)); - AGGRprint_init(header, impl, t, name_buf, type_name); + s = sprintf( name_buf, "%s%d", TD_PREFIX, count ); + assert( ( s > 0 ) && ( s < MAX_LEN ) ); + AGGRprint_init( header, impl, t, name_buf, type_name ); break; default: /* this should not happen since only aggregates are allowed to not have a name. This funct should only be called for aggrs without names. */ - fprintf(impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", - TD_PREFIX, count); + fprintf( impl, " TypeDescriptor * %s%d = new TypeDescriptor;\n", + TD_PREFIX, count ); } /* there is no name so name doesn't need to be initialized */ - fprintf(impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, - FundamentalType(t, 1)); - fprintf(impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, - TypeDescription(t)); + fprintf( impl, " %s%d->FundamentalType(%s);\n", TD_PREFIX, count, + FundamentalType( t, 1 ) ); + fprintf( impl, " %s%d->Description(\"%s\");\n", TD_PREFIX, count, + TypeDescription( t ) ); /* DAS ORIG SCHEMA FIX */ - fprintf(impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name(schema)); + fprintf( impl, " %s%d->OriginatingSchema(%s::schema);\n", TD_PREFIX, count, SCHEMAget_name( schema ) ); - if(TYPEget_RefTypeVarNm(t, name_buf, schema)) { - fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf); + if( TYPEget_RefTypeVarNm( t, name_buf, schema ) ) { + fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, name_buf ); } else { Type base = 0; /* no name, recurse */ char callee_buffer[MAX_LEN]; - if(TYPEget_body(t)) { - base = TYPEget_body(t)->base; + if( TYPEget_body( t ) ) { + base = TYPEget_body( t )->base; } - print_typechain(header, impl, base, callee_buffer, schema, type_name); - fprintf(impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer); + print_typechain( header, impl, base, callee_buffer, schema, type_name ); + fprintf( impl, " %s%d->ReferentType(%s);\n", TD_PREFIX, count, callee_buffer ); } - sprintf(buf, "%s%d", TD_PREFIX, count); + sprintf( buf, "%s%d", TD_PREFIX, count ); /* Types */ - fprintf(impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name(schema), TD_PREFIX, count); + fprintf( impl, " %s::schema->AddUnnamedType(%s%d);\n", SCHEMAget_name( schema ), TD_PREFIX, count ); } /** return 1 if it is a multidimensional aggregate at the level passed in otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ -int isMultiDimAggregateType(const Type t) -{ - if(TYPEget_body(t)->base) - if(isAggregateType(TYPEget_body(t)->base)) { +int isMultiDimAggregateType( const Type t ) { + if( TYPEget_body( t )->base ) + if( isAggregateType( TYPEget_body( t )->base ) ) { return 1; } return 0; } -void Type_Description(const Type t, char *buf) -{ - if(TYPEget_name(t)) { - strcat(buf, " "); - strcat(buf, TYPEget_name(t)); +void Type_Description( const Type t, char * buf ) { + if( TYPEget_name( t ) ) { + strcat( buf, " " ); + strcat( buf, TYPEget_name( t ) ); } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } } -void TypeBody_Description(TypeBody body, char *buf) -{ - char *s; +void TypeBody_Description( TypeBody body, char * buf ) { + char * s; - switch(body->type) { + switch( body->type ) { case integer_: - strcat(buf, " INTEGER"); + strcat( buf, " INTEGER" ); break; case real_: - strcat(buf, " REAL"); + strcat( buf, " REAL" ); break; case string_: - strcat(buf, " STRING"); + strcat( buf, " STRING" ); break; case binary_: - strcat(buf, " BINARY"); + strcat( buf, " BINARY" ); break; case boolean_: - strcat(buf, " BOOLEAN"); + strcat( buf, " BOOLEAN" ); break; case logical_: - strcat(buf, " LOGICAL"); + strcat( buf, " LOGICAL" ); break; case number_: - strcat(buf, " NUMBER"); + strcat( buf, " NUMBER" ); break; case entity_: - strcat(buf, " "); - strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); + strcat( buf, " " ); + strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(body->type) { - /* ignore the aggregate bounds for now */ + switch( body->type ) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat(buf, " AGGREGATE OF"); + strcat( buf, " AGGREGATE OF" ); break; case array_: - strcat(buf, " ARRAY"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.optional) { - strcat(buf, " OPTIONAL"); + strcat( buf, " ARRAY" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.optional ) { + strcat( buf, " OPTIONAL" ); } - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; case bag_: - strcat(buf, " BAG"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " BAG" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case set_: - strcat(buf, " SET"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " SET" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case list_: - strcat(buf, " LIST"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + strcat( buf, " LIST" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; default: - fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__); + fprintf(stderr, "Error: reached default case at %s:%d", __FILE__, __LINE__ ); abort(); } - Type_Description(body->base, buf); + Type_Description( body->base, buf ); break; case enumeration_: - strcat(buf, " ENUMERATION of ("); - LISTdo(body->list, e, Expression) - strcat(buf, ENUMget_name(e)); - strcat(buf, ", "); + strcat( buf, " ENUMERATION of (" ); + LISTdo( body->list, e, Expression ) + strcat( buf, ENUMget_name( e ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; case select_: - strcat(buf, " SELECT ("); - LISTdo(body->list, t, Type) - strcat(buf, PrettyTmpName(TYPEget_name(t))); - strcat(buf, ", "); + strcat( buf, " SELECT (" ); + LISTdo( body->list, t, Type ) + strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; default: - strcat(buf, " UNKNOWN"); + strcat( buf, " UNKNOWN" ); } - if(body->precision) { - strcat(buf, " ("); - strcat_expr(body->precision, buf); - strcat(buf, ")"); + if( body->precision ) { + strcat( buf, " (" ); + strcat_expr( body->precision, buf ); + strcat( buf, ")" ); } - if(body->flags.fixed) { - strcat(buf, " FIXED"); + if( body->flags.fixed ) { + strcat( buf, " FIXED" ); } } -const char *IdlEntityTypeName(Type t) -{ +const char * IdlEntityTypeName( Type t ) { static char name [BUFSIZ]; - strcpy(name, TYPE_PREFIX); - if(TYPEget_name(t)) { - strcpy(name, FirstToUpper(TYPEget_name(t))); + strcpy( name, TYPE_PREFIX ); + if( TYPEget_name( t ) ) { + strcpy( name, FirstToUpper( TYPEget_name( t ) ) ); } else { - return TYPEget_ctype(t); + return TYPEget_ctype( t ); } return name; } -const char *GetAggrElemType(const Type type) -{ +const char * GetAggrElemType( const Type type ) { Class_Of_Type class; Type bt; static char retval [BUFSIZ]; - if(isAggregateType(type)) { - bt = TYPEget_nonaggregate_base_type(type); - if(isAggregateType(bt)) { - strcpy(retval, "ERROR_aggr_of_aggr"); + if( isAggregateType( type ) ) { + bt = TYPEget_nonaggregate_base_type( type ); + if( isAggregateType( bt ) ) { + strcpy( retval, "ERROR_aggr_of_aggr" ); } - class = TYPEget_type(bt); + class = TYPEget_type( bt ); /* case TYPE_INTEGER: */ - if(class == integer_) { - strcpy(retval, "long"); + if( class == integer_ ) { + strcpy( retval, "long" ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - strcpy(retval, "double"); + if( ( class == number_ ) || ( class == real_ ) ) { + strcpy( retval, "double" ); } /* case TYPE_ENTITY: */ - if(class == entity_) { - strcpy(retval, IdlEntityTypeName(bt)); + if( class == entity_ ) { + strcpy( retval, IdlEntityTypeName( bt ) ); } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if((class == enumeration_) - || (class == select_)) { - strcpy(retval, TYPEget_ctype(bt)); + if( ( class == enumeration_ ) + || ( class == select_ ) ) { + strcpy( retval, TYPEget_ctype( bt ) ); } /* case TYPE_LOGICAL: */ - if(class == logical_) { - strcpy(retval, "Logical"); + if( class == logical_ ) { + strcpy( retval, "Logical" ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - strcpy(retval, "Bool"); + if( class == boolean_ ) { + strcpy( retval, "Bool" ); } /* case TYPE_STRING: */ - if(class == string_) { - strcpy(retval, "string"); + if( class == string_ ) { + strcpy( retval, "string" ); } /* case TYPE_BINARY: */ - if(class == binary_) { - strcpy(retval, "binary"); + if( class == binary_ ) { + strcpy( retval, "binary" ); } } return retval; } -const char *TYPEget_idl_type(const Type t) -{ +const char * TYPEget_idl_type( const Type t ) { Class_Of_Type class; static char retval [BUFSIZ]; @@ -1133,86 +1106,86 @@ const char *TYPEget_idl_type(const Type t) case TYPE_SET: */ - if(isAggregateType(t)) { - strcpy(retval, GetAggrElemType(t)); + if( isAggregateType( t ) ) { + strcpy( retval, GetAggrElemType( t ) ); /* case TYPE_ARRAY: */ - if(TYPEget_type(t) == array_) { - strcat(retval, "__array"); + if( TYPEget_type( t ) == array_ ) { + strcat( retval, "__array" ); } /* case TYPE_LIST: */ - if(TYPEget_type(t) == list_) { - strcat(retval, "__list"); + if( TYPEget_type( t ) == list_ ) { + strcat( retval, "__list" ); } /* case TYPE_SET: */ - if(TYPEget_type(t) == set_) { - strcat(retval, "__set"); + if( TYPEget_type( t ) == set_ ) { + strcat( retval, "__set" ); } /* case TYPE_BAG: */ - if(TYPEget_type(t) == bag_) { - strcat(retval, "__bag"); + if( TYPEget_type( t ) == bag_ ) { + strcat( retval, "__bag" ); } return retval; } /* the rest is for things that are not aggregates */ - class = TYPEget_type(t); + class = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if(class == logical_) { - return ("Logical"); + if( class == logical_ ) { + return ( "Logical" ); } /* case TYPE_BOOLEAN: */ - if(class == boolean_) { - return ("Boolean"); + if( class == boolean_ ) { + return ( "Boolean" ); } /* case TYPE_INTEGER: */ - if(class == integer_) { - return ("SDAI_Integer"); + if( class == integer_ ) { + return ( "SDAI_Integer" ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - return ("SDAI_Real"); + if( ( class == number_ ) || ( class == real_ ) ) { + return ( "SDAI_Real" ); } /* case TYPE_STRING: */ - if(class == string_) { - return ("char *"); + if( class == string_ ) { + return ( "char *" ); } /* case TYPE_BINARY: */ - if(class == binary_) { - return (AccessType(t)); + if( class == binary_ ) { + return ( AccessType( t ) ); } /* case TYPE_ENTITY: */ - if(class == entity_) { + if( class == entity_ ) { /* better do this because the return type might go away */ - strcpy(retval, IdlEntityTypeName(t)); - strcat(retval, "_ptr"); + strcpy( retval, IdlEntityTypeName( t ) ); + strcat( retval, "_ptr" ); return retval; } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ - if(class == enumeration_) { - strncpy(retval, EnumName(TYPEget_name(t)), BUFSIZ - 2); + if( class == enumeration_ ) { + strncpy( retval, EnumName( TYPEget_name( t ) ), BUFSIZ - 2 ); - strcat(retval, " /*"); - strcat(retval, IdlEntityTypeName(t)); - strcat(retval, "*/ "); + strcat( retval, " /*" ); + strcat( retval, IdlEntityTypeName( t ) ); + strcat( retval, "*/ " ); return retval; } - if(class == select_) { - return (IdlEntityTypeName(t)); + if( class == select_ ) { + return ( IdlEntityTypeName( t ) ); } /* default returns undefined */ - return ("SCLundefined"); + return ( "SCLundefined" ); } /**************************************************************//** @@ -1226,12 +1199,11 @@ const char *TYPEget_idl_type(const Type t) ** Side Effects: ** Status: new 1/24/91 ******************************************************************/ -char *TYPEget_express_type(const Type t) -{ +char * TYPEget_express_type( const Type t ) { Class_Of_Type class; Type bt; char retval [BUFSIZ]; - char *n, * permval, * aggr_type; + char * n, * permval, * aggr_type; /* 1. "DEFINED" types */ @@ -1239,38 +1211,38 @@ char *TYPEget_express_type(const Type t) /* case TYPE_ENTITY: */ /* case TYPE_SELECT: */ - n = TYPEget_name(t); - if(n) { - PrettyTmpName(n); + n = TYPEget_name( t ); + if( n ) { + PrettyTmpName( n ); } /* 2. "BASE" types */ - class = TYPEget_type(t); + class = TYPEget_type( t ); /* case TYPE_LOGICAL: */ - if((class == boolean_) || (class == logical_)) { - return ("Logical"); + if( ( class == boolean_ ) || ( class == logical_ ) ) { + return ( "Logical" ); } /* case TYPE_INTEGER: */ - if(class == integer_) { - return ("Integer "); + if( class == integer_ ) { + return ( "Integer " ); } /* case TYPE_REAL: case TYPE_NUMBER: */ - if((class == number_) || (class == real_)) { - return ("Real "); + if( ( class == number_ ) || ( class == real_ ) ) { + return ( "Real " ); } /* case TYPE_STRING: */ - if(class == string_) { - return ("String ") ; + if( class == string_ ) { + return ( "String " ) ; } /* case TYPE_BINARY: */ - if(class == binary_) { - return ("Binary ") ; + if( class == binary_ ) { + return ( "Binary " ) ; } /* AGGREGATES @@ -1279,71 +1251,70 @@ char *TYPEget_express_type(const Type t) case TYPE_LIST: case TYPE_SET: */ - if(isAggregateType(t)) { - bt = TYPEget_nonaggregate_base_type(t); - class = TYPEget_type(bt); + if( isAggregateType( t ) ) { + bt = TYPEget_nonaggregate_base_type( t ); + class = TYPEget_type( bt ); /* case TYPE_ARRAY: */ - if(TYPEget_type(t) == array_) { + if( TYPEget_type( t ) == array_ ) { aggr_type = "Array"; } /* case TYPE_LIST: */ - if(TYPEget_type(t) == list_) { + if( TYPEget_type( t ) == list_ ) { aggr_type = "List"; } /* case TYPE_SET: */ - if(TYPEget_type(t) == set_) { + if( TYPEget_type( t ) == set_ ) { aggr_type = "Set"; } /* case TYPE_BAG: */ - if(TYPEget_type(t) == bag_) { + if( TYPEget_type( t ) == bag_ ) { aggr_type = "Bag"; } - sprintf(retval, "%s of %s", - aggr_type, TYPEget_express_type(bt)); + sprintf( retval, "%s of %s", + aggr_type, TYPEget_express_type( bt ) ); /* this will declare extra memory when aggregate is > 1D */ - permval = (char *)sc_malloc(strlen(retval) * sizeof(char) + 1); - strcpy(permval, retval); + permval = ( char * )sc_malloc( strlen( retval ) * sizeof( char ) + 1 ); + strcpy( permval, retval ); return permval; } /* default returns undefined */ - fprintf(stderr, "Warning in %s: type %s is undefined\n", __func__, TYPEget_name(t)); - return ("SCLundefined"); + fprintf( stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name( t ) ); + return ( "SCLundefined" ); } /** Initialize an upper or lower bound for an aggregate. \sa AGGRprint_init */ -void AGGRprint_bound(FILE *header, FILE *impl, const char *var_name, const char *aggr_name, const char *cname, Expression bound, int boundNr) -{ - if(bound->symbol.resolved) { - if(bound->type == Type_Funcall) { - fprintf(impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string(bound)); +void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const char * aggr_name, const char * cname, Expression bound, int boundNr ) { + if( bound->symbol.resolved ) { + if( bound->type == Type_Funcall ) { + fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string( bound ) ); } else { - fprintf(impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer); + fprintf( impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer ); } } else { /* resolved == 0 seems to mean that this is Type_Runtime */ - assert(cname && (bound->e.op2) && (bound->e.op2->symbol.name)); - fprintf(impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name); - fprintf(header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name); - fprintf(header, " %s * ths = (%s *) this_ptr;\n", cname, cname); - fprintf(header, " ths->ResetAttributes();\n"); - fprintf(header, " STEPattribute * a = ths->NextAttribute();\n"); - fprintf(header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name); - fprintf(header, " a = ths->NextAttribute();\n"); - fprintf(header, " if( !a ) {\n"); - fprintf(header, " break;\n"); - fprintf(header, " }\n"); - fprintf(header, " }\n"); - fprintf(header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str(__FILE__), - __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com."); - fprintf(header, " return *( a->Integer() );\n"); /* always an integer? if not, would need to translate somehow due to return type... */ - fprintf(header, "}\n"); + assert( cname && ( bound->e.op2 ) && ( bound->e.op2->symbol.name ) ); + fprintf( impl, " %s->SetBound%dFromMemberAccessor( &getBound%d_%s__%s );\n", var_name, boundNr, boundNr, cname, aggr_name ); + fprintf( header, "inline SDAI_Integer getBound%d_%s__%s( SDAI_Application_instance* this_ptr ) {\n", boundNr, cname, aggr_name ); + fprintf( header, " %s * ths = (%s *) this_ptr;\n", cname, cname ); + fprintf( header, " ths->ResetAttributes();\n" ); + fprintf( header, " STEPattribute * a = ths->NextAttribute();\n" ); + fprintf( header, " while( strcmp( a->Name(), \"%s\" ) != 0 ) {\n", bound->e.op2->symbol.name ); + fprintf( header, " a = ths->NextAttribute();\n" ); + fprintf( header, " if( !a ) {\n" ); + fprintf( header, " break;\n" ); + fprintf( header, " }\n" ); + fprintf( header, " }\n" ); + fprintf( header, " assert( a->NonRefType() == INTEGER_TYPE && \"Error in schema or in exp2cxx at %s:%d %s\" );\n", path2str( __FILE__ ), + __LINE__, "(incorrect assumption of integer type?) Please report error to STEPcode: scl-dev at groups.google.com." ); + fprintf( header, " return *( a->Integer() );\n" ); /* always an integer? if not, would need to translate somehow due to return type... */ + fprintf( header, "}\n" ); } } @@ -1358,29 +1329,28 @@ void AGGRprint_bound(FILE *header, FILE *impl, const char *var_name, const char * \param t the Type * \param var_name the name of the C++ variable, such as t_1 or schema::t_name */ -void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name) -{ - if(!header) { - fprintf(stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name); +void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ) { + if( !header ) { + fprintf( stderr, "ERROR at %s:%d! 'header' is null for aggregate %s.", __FILE__, __LINE__, t->symbol.name ); abort(); } - if(!TYPEget_head(t)) { - const char *cname = 0; - if((t->superscope) && (t->superscope->symbol.name)) { - cname = ClassName(t->superscope->symbol.name); + if( !TYPEget_head( t ) ) { + const char * cname = 0; + if( ( t->superscope ) && ( t->superscope->symbol.name ) ) { + cname = ClassName( t->superscope->symbol.name ); } - if(TYPEget_body(t)->lower) { - AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->lower, 1); + if( TYPEget_body( t )->lower ) { + AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->lower, 1 ); } - if(TYPEget_body(t)->upper) { - AGGRprint_bound(header, impl, var_name, aggr_name, cname, TYPEget_body(t)->upper, 2); + if( TYPEget_body( t )->upper ) { + AGGRprint_bound( header, impl, var_name, aggr_name, cname, TYPEget_body( t )->upper, 2 ); } - if(TYPEget_body(t)->flags.unique) { - fprintf(impl, " %s->UniqueElements(LTrue);\n", var_name); + if( TYPEget_body( t )->flags.unique ) { + fprintf( impl, " %s->UniqueElements(LTrue);\n", var_name ); } - if(TYPEget_body(t)->flags.optional) { - fprintf(impl, " %s->OptionalElements(LTrue);\n", var_name); + if( TYPEget_body( t )->flags.optional ) { + fprintf( impl, " %s->OptionalElements(LTrue);\n", var_name ); } } } diff --git a/src/exp2cxx/classes_type.h b/src/exp2cxx/classes_type.h index ce178adc3..a15815b07 100644 --- a/src/exp2cxx/classes_type.h +++ b/src/exp2cxx/classes_type.h @@ -1,31 +1,31 @@ #ifndef CLASSES_TYPE_H #define CLASSES_TYPE_H -Type TYPEget_ancestor(Type); +Type TYPEget_ancestor( Type ); -const char *TypeName(Type t); -const char *TypeDescriptorName(Type); -char *TypeDescription(const Type t); -const char *AccessType(Type t); -const char *TYPEget_ctype(const Type t); +const char * TypeName( Type t ); +const char * TypeDescriptorName( Type ); +char * TypeDescription( const Type t ); +const char * AccessType( Type t ); +const char * TYPEget_ctype( const Type t ); -void TYPEPrint(const Type type, FILES *files, Schema schema); -void TYPEprint_descriptions(const Type, FILES *, Schema); -void TYPEprint_definition(Type, FILES *, Schema); -void TYPEprint_typedefs(Type, FILE *); -void TYPEprint_new(const Type type, FILE *create, Schema schema, bool needWR); -void TYPEprint_init(const Type type, FILE *header, FILE *impl, Schema schema); +void TYPEPrint( const Type type, FILES *files, Schema schema ); +void TYPEprint_descriptions( const Type, FILES *, Schema ); +void TYPEprint_definition( Type, FILES *, Schema ); +void TYPEprint_typedefs( Type, FILE * ); +void TYPEprint_new( const Type type, FILE* create, Schema schema, bool needWR ); +void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ); -void TYPEenum_inc_print(const Type type, FILE *inc); -void TYPEenum_lib_print(const Type type, FILE *f); +void TYPEenum_inc_print( const Type type, FILE * inc ); +void TYPEenum_lib_print( const Type type, FILE * f ); -void TYPEselect_print(Type, FILES *, Schema); -void TYPEselect_init_print(const Type type, FILE *f); -void TYPEselect_inc_print(const Type type, FILE *f); -void TYPEselect_lib_print(const Type type, FILE *f); +void TYPEselect_print( Type, FILES *, Schema ); +void TYPEselect_init_print( const Type type, FILE* f ); +void TYPEselect_inc_print( const Type type, FILE * f ); +void TYPEselect_lib_print( const Type type, FILE * f ); -void AGGRprint_init(FILE *header, FILE *impl, const Type t, const char *var_name, const char *aggr_name); +void AGGRprint_init( FILE * header, FILE * impl, const Type t, const char * var_name, const char * aggr_name ); -void print_typechain(FILE *header, FILE *impl, const Type t, char *buf, Schema schema, const char *type_name); +void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Schema schema, const char * type_name ); #endif diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 8b1daca64..517fa8a89 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -31,20 +31,18 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. ** **/ -void use_ref(Schema, Express, FILES *); +void use_ref( Schema, Express, FILES * ); -void create_builtin_type_decl(FILES *files, char *name) -{ - fprintf(files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", - "SCHEMA", TD_PREFIX, name); +void create_builtin_type_decl( FILES * files, char * name ) { + fprintf( files->incall, "extern SC_%s_EXPORT TypeDescriptor *%s%s_TYPE;\n", + "SCHEMA", TD_PREFIX, name ); } -void create_builtin_type_defn(FILES *files, char *name) -{ - fprintf(files->initall, " %s%s_TYPE = new TypeDescriptor (", - TD_PREFIX, name); - fprintf(files->initall, "\"%s\", %s_TYPE, \"%s\");\n", - PrettyTmpName(name), StrToUpper(name), StrToLower(name)); +void create_builtin_type_defn( FILES * files, char * name ) { + fprintf( files->initall, " %s%s_TYPE = new TypeDescriptor (", + TD_PREFIX, name ); + fprintf( files->initall, "\"%s\", %s_TYPE, \"%s\");\n", + PrettyTmpName( name ), StrToUpper( name ), StrToLower( name ) ); } /** **************************************************************** @@ -57,66 +55,65 @@ void create_builtin_type_defn(FILES *files, char *name) ** In this case the file schema.h is initiated ** Status: ok 1/15/91 ******************************************************************/ -void print_file_header(FILES *files) -{ +void print_file_header( FILES * files ) { /* open file which unifies all schema specific header files of input Express source */ - files -> incall = FILEcreate("schema.h"); - fprintf(files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n"); - - fprintf(files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n"); - fprintf(files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n"); - fprintf(files->incall, "# else\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n"); - fprintf(files->incall, "# endif\n"); - fprintf(files->incall, "#else\n"); - fprintf(files->incall, "# define SC_SCHEMA_EXPORT\n"); - fprintf(files->incall, "#endif\n\n"); - - fprintf(files->incall, "#ifdef SC_LOGGING\n"); - fprintf(files->incall, "#include \n"); - fprintf(files->incall, "#endif\n"); - - fprintf(files->incall, "#include \n\n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "\n#include \n"); - - fprintf(files->incall, "\n#include \n"); - - fprintf(files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA"); - fprintf(files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA"); - - files -> initall = FILEcreate("schema.cc"); - fprintf(files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n"); - fprintf(files->initall, "#include \"schema.h\"\n"); - fprintf(files->initall, "#include \"sc_memmgr.h\"\n"); - fprintf(files->initall, "class Registry;\n"); - - fprintf(files->initall, "\nvoid SchemaInit (Registry & reg) {\n"); - fprintf(files->initall, " extern void InitSchemasAndEnts "); - fprintf(files->initall, "(Registry & r);\n"); - fprintf(files->initall, " InitSchemasAndEnts (reg);\n"); + files -> incall = FILEcreate( "schema.h" ); + fprintf( files->incall, "\n// in the exp2cxx source code, this file is generally referred to as files->incall or schemafile\n" ); + + fprintf( files->incall, "\n#if !defined(SC_STATIC) && defined(_WIN32)\n" ); + fprintf( files->incall, "# if defined(SC_SCHEMA_DLL_EXPORTS)\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllexport)\n" ); + fprintf( files->incall, "# else\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT __declspec(dllimport)\n" ); + fprintf( files->incall, "# endif\n" ); + fprintf( files->incall, "#else\n" ); + fprintf( files->incall, "# define SC_SCHEMA_EXPORT\n" ); + fprintf( files->incall, "#endif\n\n" ); + + fprintf( files->incall, "#ifdef SC_LOGGING\n" ); + fprintf( files->incall, "#include \n" ); + fprintf( files->incall, "#endif\n" ); + + fprintf( files->incall, "#include \n\n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \n" ); + + fprintf( files->incall, "\n#include \n" ); + + fprintf( files->incall, "extern SC_%s_EXPORT void SchemaInit (Registry &);\n", "SCHEMA" ); + fprintf( files->incall, "extern SC_%s_EXPORT void InitSchemasAndEnts (Registry &);\n", "SCHEMA" ); + + files -> initall = FILEcreate( "schema.cc" ); + fprintf( files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n" ); + fprintf( files->initall, "#include \"schema.h\"\n" ); + fprintf( files->initall, "#include \"sc_memmgr.h\"\n" ); + fprintf( files->initall, "class Registry;\n" ); + + fprintf( files->initall, "\nvoid SchemaInit (Registry & reg) {\n" ); + fprintf( files->initall, " extern void InitSchemasAndEnts " ); + fprintf( files->initall, "(Registry & r);\n" ); + fprintf( files->initall, " InitSchemasAndEnts (reg);\n" ); // This file will contain instantiation statements for all the schemas and // entities in the express file. (They must all be in separate function // called first by SchemaInit() so that all entities will exist - files -> create = FILEcreate("SdaiAll.cc"); - fprintf(files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n"); - fprintf(files->create, "#include \"schema.h\"\n"); - fprintf(files->create, "#include \"sc_memmgr.h\"\n"); - fprintf(files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n"); + files -> create = FILEcreate( "SdaiAll.cc" ); + fprintf( files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n" ); + fprintf( files->create, "#include \"schema.h\"\n" ); + fprintf( files->create, "#include \"sc_memmgr.h\"\n" ); + fprintf( files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n" ); // This file declares all entity classes as incomplete types. This will // allow all the .h files to reference all .h's. We can then have e.g., // entX from schemaA have attribute attr1 = entY from schemaB. - files -> classes = FILEcreate("Sdaiclasses.h"); - fprintf(files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n"); - fprintf(files->classes, "#include \"schema.h\"\n"); + files -> classes = FILEcreate( "Sdaiclasses.h" ); + fprintf( files->classes, "\n// in the exp2cxx source code, this file is generally referred to as files->classes\n" ); + fprintf( files->classes, "#include \"schema.h\"\n" ); } /** **************************************************************** @@ -127,32 +124,28 @@ void print_file_header(FILES *files) ** Description: handles cleaning up things at end of processing ** Status: ok 1/15/91 ******************************************************************/ -void print_file_trailer(FILES *files) -{ - FILEclose(files->incall); - FILEclose(files->initall); - fprintf(files->create, "}\n\n"); - FILEclose(files->create); - fprintf(files->classes, "\n"); - FILEclose(files->classes); - fprintf(files->names, "\n}\n"); - FILEclose(files->names); +void print_file_trailer( FILES * files ) { + FILEclose( files->incall ); + FILEclose( files->initall ); + fprintf( files->create, "}\n\n" ); + FILEclose( files->create ); + fprintf( files->classes, "\n" ); + FILEclose( files->classes ); + fprintf( files->names, "\n}\n" ); + FILEclose( files->names ); } /* set attribute index to simplify attrdescriptor name calculation * and reduce/eliminate use of global attr_count */ -void numberAttributes(Scope scope) -{ +void numberAttributes( Scope scope ) { int count = 0; - Linked_List list = SCOPEget_entities_superclass_order(scope); - LISTdo(list, e, Entity) { - LISTdo_n(ENTITYget_attributes(e), v, Variable, b) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); + LISTdo( list, e, Entity ) { + LISTdo_n( ENTITYget_attributes( e ), v, Variable, b ) { v->idx = count++; - } - LISTod - } - LISTod + } LISTod + } LISTod } /****************************************************************** @@ -170,14 +163,13 @@ void numberAttributes(Scope scope) ** and what the relationship is between this organization and the ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint(Scope scope, FILES *files, Schema schema, ComplexCollect *col, int cnt) -{ - Linked_List list = SCOPEget_entities_superclass_order(scope); +void SCOPEPrint( Scope scope, FILES * files, Schema schema, ComplexCollect * col, int cnt ) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); DictionaryEntry de; Type i; int redefs = 0; - if(cnt <= 1) { + if( cnt <= 1 ) { /* This will be the case if this is the first time we are generating a ** file for this schema. (cnt = the file suffix. If it = 1, it's the ** first of multiple; if it = 0, it's the only one.) Basically, this @@ -185,209 +177,198 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema, ComplexCollect *col, i ** during multiple passes. This includes Sdaiclasses.h, SdaiAll.cc, ** and the Sdaixxx.init.cc files. */ - fprintf(files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name(schema)); + fprintf( files -> lib, "\nSchema * %s::schema = 0;\n", SCHEMAget_name( schema ) ); /* Do \'new\'s for types descriptors (in SdaiAll.cc (files->create)), and the externs typedefs, and incomplete descriptors (in Sdai- classes.h (files->classes)). */ - fprintf(files->create, "\n // ***** Initialize the Types\n"); - fprintf(files->classes, "\n// Types:\n"); - SCOPEdo_types(scope, t, de) { + fprintf( files->create, "\n // ***** Initialize the Types\n" ); + fprintf( files->classes, "\n// Types:\n" ); + SCOPEdo_types( scope, t, de ) { //TYPEprint_new moved to TYPEPrint_cc and TYPEprint_descriptions in classes_type.c - TYPEprint_typedefs(t, files->classes); + TYPEprint_typedefs( t, files->classes ); //print in namespace. Some logic copied from TypeDescriptorName() - fprintf(files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName(t), TYPEprefix(t), TYPEget_name(t)); - } - SCOPEod + fprintf( files->names, " extern SC_SCHEMA_EXPORT %s * %s%s;\n", GetTypeDescriptorName( t ), TYPEprefix( t ), TYPEget_name( t ) ); + } SCOPEod - fprintf(files->classes, "\n// Entity class typedefs:"); - LISTdo(list, e, Entity) { - ENTITYprint_classes(e, files->classes); - } - LISTod + fprintf( files->classes, "\n// Entity class typedefs:" ); + LISTdo( list, e, Entity ) { + ENTITYprint_classes( e, files->classes ); + } LISTod } /* fill in the values for the type descriptors and print the enumerations */ - fprintf(files -> inc, "\n/* ************** TYPES */\n"); - fprintf(files -> lib, "\n/* ************** TYPES */\n"); + fprintf( files -> inc, "\n/* ************** TYPES */\n" ); + fprintf( files -> lib, "\n/* ************** TYPES */\n" ); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - if(scope->enum_table) { - HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); + if( scope->enum_table ) { + HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); Type t; - while(0 != (t = (Type) DICTdo(&de))) { + while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if((t->search_id == CANPROCESS) - && (TYPEis_enumeration(t)) - && ((i = TYPEget_ancestor(t)) != NULL) - && (i->search_id >= CANPROCESS)) { + if( ( t->search_id == CANPROCESS ) + && ( TYPEis_enumeration( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) + && ( i->search_id >= CANPROCESS ) ) { redefs = 1; } } } - SCOPEdo_types(scope, t, de) { + SCOPEdo_types( scope, t, de ) { /* NOTE the following comment seems to contradict the logic below it (... && !( TYPEis_enumeration( t ) && ...) // Do the non-redefined enumerations:*/ - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) && TYPEget_head(t))) { - TYPEprint_descriptions(t, files, schema); - if(!TYPEis_select(t)) { + if( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { + TYPEprint_descriptions( t, files, schema ); + if( !TYPEis_select( t ) ) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } } - } - SCOPEod + } SCOPEod - if(redefs) { + if( redefs ) { // Here we process redefined enumerations. See note, 2 loops ago. - fprintf(files->inc, "// ***** Redefined Enumerations:\n"); + fprintf( files->inc, "// ***** Redefined Enumerations:\n" ); /* The following was `SCOPEdo_types( scope, t, de ) ... SCOPEod;` * Modified Jan 2012 by MAP - moving enums to own dictionary */ - HASHlistinit_by_type(scope->enum_table, &de, OBJ_TYPE); + HASHlistinit_by_type( scope->enum_table, &de, OBJ_TYPE ); Type t; - while(0 != (t = (Type) DICTdo(&de))) { - if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + while( 0 != ( t = ( Type ) DICTdo( &de ) ) ) { + if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } } } /* do the select definitions next, since they depend on the others */ - fprintf(files->inc, "\n// ***** Build the SELECT Types \n"); + fprintf( files->inc, "\n// ***** Build the SELECT Types \n" ); // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types(scope, t, de) { - if(t->search_id == CANPROCESS) { + SCOPEdo_types( scope, t, de ) { + if( t->search_id == CANPROCESS ) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. - if(TYPEis_select(t)) { - TYPEselect_print(t, files, schema); + if( TYPEis_select( t ) ) { + TYPEselect_print( t, files, schema ); } - if(TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + if( TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); } t->search_id = PROCESSED; } - } - SCOPEod + } SCOPEod - fprintf(files -> inc, "\n/* ************** ENTITIES */\n"); - fprintf(files -> lib, "\n/* ************** ENTITIES */\n"); + fprintf( files -> inc, "\n/* ************** ENTITIES */\n" ); + fprintf( files -> lib, "\n/* ************** ENTITIES */\n" ); - fprintf(files->inc, "\n// ***** Print Entity Classes \n"); - LISTdo(list, e, Entity) { - if(e->search_id == CANPROCESS) { - ENTITYPrint(e, files, schema, col->externMapping(ENTITYget_name(e))); + fprintf( files->inc, "\n// ***** Print Entity Classes \n" ); + LISTdo( list, e, Entity ) { + if( e->search_id == CANPROCESS ) { + ENTITYPrint( e, files, schema, col->externMapping( ENTITYget_name( e ) ) ); e->search_id = PROCESSED; } - } - LISTod + } LISTod - if(cnt <= 1) { + if( cnt <= 1 ) { int index = 0; // Do the model stuff: - fprintf(files->inc, "\n// ***** generate Model related pieces\n"); - fprintf(files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name(schema)); - fprintf(files -> inc, "\n public:\n"); - fprintf(files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); - LISTdo(list, e, Entity) { - MODELprint_new(e, files); - } - LISTod - - fprintf(files->inc, "\n};\n\n"); - - fprintf(files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name(schema)); - - fprintf(files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name(schema)); - fprintf(files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name(schema)); - - fprintf(files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name(schema), SCHEMAget_name(schema)); - fprintf(files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n"); - LISTdo(list, e, Entity) { - MODELPrintConstructorBody(e, files, schema); - } - LISTod - fprintf(files -> lib, "}\n"); + fprintf( files->inc, "\n// ***** generate Model related pieces\n" ); + fprintf( files->inc, "\nclass SdaiModel_contents_%s : public SDAI_Model_contents {\n", SCHEMAget_name( schema ) ); + fprintf( files -> inc, "\n public:\n" ); + fprintf( files -> inc, " SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); + LISTdo( list, e, Entity ) { + MODELprint_new( e, files ); + } LISTod + + fprintf( files->inc, "\n};\n\n" ); + + fprintf( files->inc, "typedef SdaiModel_contents_%s * SdaiModel_contents_%s_ptr;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "typedef const SdaiModel_contents_%s * SdaiModel_contents_%s_ptr_c;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "typedef SdaiModel_contents_%s_ptr SdaiModel_contents_%s_var;\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->inc, "SDAI_Model_contents_ptr create_SdaiModel_contents_%s();\n", SCHEMAget_name( schema ) ); + + fprintf( files->lib, "\nSDAI_Model_contents_ptr create_SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ) ); + fprintf( files->lib, " return new SdaiModel_contents_%s;\n}\n", SCHEMAget_name( schema ) ); + + fprintf( files->lib, "\nSdaiModel_contents_%s::SdaiModel_contents_%s() {\n", SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); + fprintf( files->lib, " SDAI_Entity_extent_ptr eep = (SDAI_Entity_extent_ptr)0;\n\n" ); + LISTdo( list, e, Entity ) { + MODELPrintConstructorBody( e, files, schema ); + } LISTod + fprintf( files -> lib, "}\n" ); index = 0; - LISTdo(list, e, Entity) { - MODELPrint(e, files, schema, index); + LISTdo( list, e, Entity ) { + MODELPrint( e, files, schema, index ); index++; - } - LISTod + } LISTod } - LISTfree(list); + LISTfree( list ); } /** open/init unity files which allow faster compilation with fewer translation units */ -void initUnityFiles(const char *schName, FILES *files) -{ - const char *unity = "\n/** this file is for unity builds, which allow faster compilation\n" - " * with fewer translation units. not compatible with all compilers!\n */\n\n" - "#include \"schema.h\"\n"; +void initUnityFiles( const char * schName, FILES * files ) { + const char * unity = "\n/** this file is for unity builds, which allow faster compilation\n" + " * with fewer translation units. not compatible with all compilers!\n */\n\n" + "#include \"schema.h\"\n"; std::string name = schName; - name.append("_unity_"); + name.append( "_unity_" ); size_t prefixLen = name.length(); - name.append("entities.cc"); - files->unity.entity.impl = FILEcreate(name.c_str()); + name.append( "entities.cc" ); + files->unity.entity.impl = FILEcreate( name.c_str() ); - name.resize(name.length() - 2); - name.append("h"); - fprintf(files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str()); + name.resize( name.length() - 2 ); + name.append( "h" ); + fprintf( files->unity.entity.impl, "%s#include \"%s\"\n", unity, name.c_str() ); - files->unity.entity.hdr = FILEcreate(name.c_str()); - fprintf(files->unity.entity.hdr, "%s\n", unity); + files->unity.entity.hdr = FILEcreate( name.c_str() ); + fprintf( files->unity.entity.hdr, "%s\n", unity ); - name.resize(prefixLen); - name.append("types.cc"); - files->unity.type.impl = FILEcreate(name.c_str()); + name.resize( prefixLen ); + name.append( "types.cc" ); + files->unity.type.impl = FILEcreate( name.c_str() ); - name.resize(name.length() - 2); - name.append("h"); - fprintf(files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str()); + name.resize( name.length() - 2 ); + name.append( "h" ); + fprintf( files->unity.type.impl, "%s#include \"%s\"\n", unity, name.c_str() ); - files->unity.type.hdr = FILEcreate(name.c_str()); - fprintf(files->unity.type.hdr, "%s\n", unity); + files->unity.type.hdr = FILEcreate( name.c_str() ); + fprintf( files->unity.type.hdr, "%s\n", unity ); } /** close unity files * \sa initUnityFiles() */ -void closeUnityFiles(FILES *files) -{ - FILEclose(files->unity.type.hdr); - FILEclose(files->unity.type.impl); - FILEclose(files->unity.entity.hdr); - FILEclose(files->unity.entity.impl); +void closeUnityFiles( FILES * files ) { + FILEclose( files->unity.type.hdr ); + FILEclose( files->unity.type.impl ); + FILEclose( files->unity.entity.hdr ); + FILEclose( files->unity.entity.impl ); } ///write tail of initfile, close it -void INITFileFinish(FILE *initfile, Schema schema) -{ - fprintf(initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); - fprintf(initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name(schema)); - fprintf(initfile, " EntityDescriptor * ed;\n"); - fprintf(initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name(schema)); - fprintf(initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); - fprintf(initfile, " ed->InitIAttrs( reg, nm );\n"); - fprintf(initfile, " }\n}\n"); - FILEclose(initfile); +void INITFileFinish( FILE * initfile, Schema schema ) { + fprintf( initfile, "\n /* loop through any entities with inverse attrs, calling InitIAttrs */\n"); + fprintf( initfile, " EntityDescItr edi( *%s::schema->EntsWInverse() );\n", SCHEMAget_name( schema ) ); + fprintf( initfile, " EntityDescriptor * ed;\n"); + fprintf( initfile, " const char * nm = %s::schema->Name();\n", SCHEMAget_name( schema ) ); + fprintf( initfile, " while( 0 != ( ed = edi.NextEntityDesc_nc() ) ) {\n"); + fprintf( initfile, " ed->InitIAttrs( reg, nm );\n"); + fprintf( initfile, " }\n}\n" ); + FILEclose( initfile ); } /** **************************************************************** @@ -403,17 +384,15 @@ void INITFileFinish(FILE *initfile, Schema schema) ** Side Effects: ** Status: ******************************************************************/ -void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) -{ - int ocnt = 0; +void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) { char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE *libfile, + FILE * libfile, * incfile, * schemafile = files->incall, - * schemainit = files->initall, - * initfile, - * createall = files->create; + * schemainit = files->initall, + * initfile, + * createall = files->create; Rule r; Function f; Procedure p; @@ -421,181 +400,160 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper(SCHEMAget_name(schema))); //TODO change file names to CamelCase? - if(suffix == 0) { - ocnt = snprintf(sufnm, MAX_LEN, "%s", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; - } + sprintf( schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper( SCHEMAget_name( schema ) ) ); //TODO change file names to CamelCase? + if( suffix == 0 ) { + sprintf( sufnm, "%s", schnm ); } else { - ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; - } - } - ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; + sprintf( sufnm, "%s_%d", schnm, suffix ); } + sprintf( fnm, "%s.h", sufnm ); - if(!(incfile = (files -> inc) = FILEcreate(fnm))) { + if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); + fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); - fprintf(incfile, "#include \"schema.h\"\n"); - fprintf(incfile, "#include \"sc_memmgr.h\"\n"); + fprintf( incfile, "#include \"schema.h\"\n" ); + fprintf( incfile, "#include \"sc_memmgr.h\"\n" ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 1.9 open/init unity files which allow faster compilation with fewer translation units */ - initUnityFiles(sufnm, files); + initUnityFiles( sufnm, files ); /* 2. class source file */ - sprintf(np, "cc"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "cc" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); + fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); //TODO: Looks like this switches between 'schema.h' and a non-generic name. What is that name, //and how do we fully enable this feature (i.e. how to write the file with different name)? #ifdef SCHEMA_HANDLING - sprintf(np, "h"); - fprintf(libfile, "#include <%s.h> \n", sufnm); + sprintf( np, "h" ); + fprintf( libfile, "#include <%s.h> \n", sufnm ); #else - fprintf(libfile, "#include \"schema.h\"\n"); + fprintf( libfile, "#include \"schema.h\"\n" ); #endif - fprintf(libfile, "#include \"sc_memmgr.h\"\n"); + fprintf( libfile, "#include \"sc_memmgr.h\"\n" ); - fprintf(libfile, - "\n#ifdef SC_LOGGING \n" - "#include \n" - " extern ofstream *logStream;\n" - "#define SCLLOGFILE \"scl.log\"\n" - "#endif \n"); + fprintf( libfile, + "\n#ifdef SC_LOGGING \n" + "#include \n" + " extern ofstream *logStream;\n" + "#define SCLLOGFILE \"scl.log\"\n" + "#endif \n" ); - fprintf(libfile, "\n#include \"%s.h\"\n", schnm); + fprintf( libfile, "\n#include \"%s.h\"\n", schnm ); // 3. header for namespace to contain all formerly-global variables - ocnt = snprintf(fnm, MAX_LEN, "%sNames.h", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; - } - - if(!(files->names = FILEcreate(fnm))) { + sprintf( fnm, "%sNames.h", schnm ); + if( !( files->names = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "#include \"%sNames.h\"\n", schnm); - fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); - fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); - fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); - fprintf(files->names, " extern Schema * schema;\n\n"); + fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); + fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); + fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); + fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); + fprintf( files->names, " extern Schema * schema;\n\n" ); /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - if(suffix <= 1) { + if( suffix <= 1 ) { /* I.e., if this is our first pass with schema */ - ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; - } - + sprintf( fnm, "%s.init.cc", schnm ); /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ - if(!(initfile = (files -> init) = FILEcreate(fnm))) { + if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); + fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); #ifdef SCHEMA_HANDLING - if(suffix == 0) { - fprintf(initfile, "#include <%s.h>\n", schnm); + if( suffix == 0 ) { + fprintf( initfile, "#include <%s.h>\n", schnm ); } else { - fprintf(initfile, "#include <%s_%d.h>\n", schnm, suffix); + fprintf( initfile, "#include <%s_%d.h>\n", schnm, suffix ); } #else - fprintf(initfile, - "#ifndef SCHEMA_H\n" - "#include \"schema.h\"\n" - "#endif\n"); + fprintf( initfile, + "#ifndef SCHEMA_H\n" + "#include \"schema.h\"\n" + "#endif\n" ); #endif - fprintf(initfile, "#include \n#include \n"); - fprintf(initfile, "#include \n"); + fprintf( initfile, "#include \n#include \n" ); + fprintf( initfile, "#include \n" ); - fprintf(initfile, "\nvoid %sInit (Registry& reg) {\n", schnm); + fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); - fprintf(createall, "// Schema: %s\n", schnm); - fprintf(createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name(schema), PrettyTmpName(SCHEMAget_name(schema))); + fprintf( createall, "// Schema: %s\n", schnm ); + fprintf( createall, " %s::schema = new Schema(\"%s\");\n", SCHEMAget_name( schema ), PrettyTmpName( SCHEMAget_name( schema ) ) ); /* Add the SdaiModel_contents_ class constructor to the schema descriptor create function for it */ - fprintf(createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", - SCHEMAget_name(schema), SCHEMAget_name(schema)); + fprintf( createall, " %s::schema->AssignModelContentsCreator( (ModelContentsCreator) create_SdaiModel_contents_%s);\n", + SCHEMAget_name( schema ), SCHEMAget_name( schema ) ); - fprintf(createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name(schema)); + fprintf( createall, " reg.AddSchema (*%s::schema);\n", SCHEMAget_name( schema ) ); /**************/ /* add global RULEs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, RULEto_string(r)); - fprintf(createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name(schema)); - fprintf(createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, RULEto_string( r ) ); + fprintf( createall, "gr = new Global_rule(\"%s\",%s::schema, str );\n", r->symbol.name, SCHEMAget_name( schema ) ); + fprintf( createall, "%s::schema->AddGlobal_rule(gr);\n", SCHEMAget_name( schema ) ); } /**************/ /* add FUNCTIONs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, FUNCto_string(f)); - fprintf(createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, FUNCto_string( f ) ); + fprintf( createall, "%s::schema->AddFunction( str );\n", SCHEMAget_name( schema ) ); } /* add PROCEDUREs to Schema dictionary entry */ - DICTdo_type_init(schema->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - fprintf(createall, " str.clear();\n"); - format_for_std_stringout(createall, PROCto_string(p)); - fprintf(createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name(schema)); + DICTdo_type_init( schema->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + fprintf( createall, " str.clear();\n" ); + format_for_std_stringout( createall, PROCto_string( p ) ); + fprintf( createall, "%s::schema->AddProcedure( str );\n", SCHEMAget_name( schema ) ); } - fprintf(files->classes, "\n// Schema: %s", schnm); - fprintf(files->classes, "\n#include \"%sNames.h\"\n", schnm); + fprintf( files->classes, "\n// Schema: %s", schnm ); + fprintf( files->classes, "\n#include \"%sNames.h\"\n", schnm ); } else { /* Just reopen the .init.cc (in append mode): */ - ocnt = snprintf(fnm, MAX_LEN, "%s.init.cc", schnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; - } - - initfile = files->init = fopen(fnm, "a"); + sprintf( fnm, "%s.init.cc", schnm ); + initfile = files->init = fopen( fnm, "a" ); } /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); - fprintf(schemafile, "#include \"%s.h\" \n", sufnm); - if(schema->search_id == PROCESSED) { - fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " %sInit (reg); \n", schnm); + fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); + fprintf( schemafile, "#include \"%s.h\" \n", sufnm ); + if( schema->search_id == PROCESSED ) { + fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " %sInit (reg); \n", schnm ); } /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint(schema, files, schema, (ComplexCollect *)complexCol, suffix); + SCOPEPrint( schema, files, schema, ( ComplexCollect * )complexCol, suffix ); /********** close the files ***********/ - closeUnityFiles(files); - FILEclose(libfile); - FILEclose(incfile); - if(schema->search_id == PROCESSED) { - INITFileFinish(initfile, schema); + closeUnityFiles( files ); + FILEclose( libfile ); + FILEclose( incfile ); + if( schema->search_id == PROCESSED ) { + INITFileFinish( initfile, schema ); } else { - fclose(initfile); + fclose( initfile ); } } @@ -612,28 +570,27 @@ void SCHEMAprint(Schema schema, FILES *files, void *complexCol, int suffix) ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) -{ +void getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { DictionaryEntry de; Schema schema; - fprintf(schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n"); - fprintf(schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__); - fprintf(schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n"); - fprintf(schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n"); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - schema = (Scope)DICTdo(&de); - fprintf(schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); - fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name(schema)); - fprintf(schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name(schema)); + fprintf( schema_h, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName);\n" ); + fprintf( schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__ ); + fprintf( schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n" ); + fprintf( schema_cc, "\nSDAI_Model_contents_ptr GetModelContents(char *schemaName) {\n" ); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + schema = ( Scope )DICTdo( &de ); + fprintf( schema_cc, " if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); + fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( schema_cc, " else if(!strcmp(schemaName, \"%s\"))\n", SCHEMAget_name( schema ) ); + fprintf( schema_cc, " return (SDAI_Model_contents_ptr) new SdaiModel_contents_%s; \n", SCHEMAget_name( schema ) ); } - fprintf(schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n"); + fprintf( schema_cc, " else return (SDAI_Model_contents_ptr) 0;\n}\n" ); } /****************************************************************** @@ -648,15 +605,14 @@ void getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) ** Side Effects: generates code ** Status: 24-Feb-1992 new -kcm ******************************************************************/ -void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) -{ +void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { char fnm [MAX_LEN], *np; - const char *schnm; /* schnm is really "express name" */ - FILE *libfile; - FILE *incfile; - FILE *schemafile = files -> incall; - FILE *schemainit = files -> initall; - FILE *initfile; + const char * schnm; /* schnm is really "express name" */ + FILE * libfile; + FILE * incfile; + FILE * schemafile = files -> incall; + FILE * schemainit = files -> initall; + FILE * initfile; /* new */ Schema schema; DictionaryEntry de; @@ -665,81 +621,81 @@ void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); - if(!(incfile = (files -> inc) = FILEcreate(fnm))) { + sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); + if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n"); + fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); - fprintf(incfile, "#include \n"); + fprintf( incfile, "#include \n" ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 1.9 init unity files (large translation units, faster compilation) */ - initUnityFiles(schnm, files); + initUnityFiles( schnm, files ); /* 2. class source file */ - sprintf(np, "cc"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "cc" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n"); + fprintf( files->lib, "\n// in the exp2cxx source code, this file is generally referred to as files->lib or libfile\n" ); - fprintf(libfile, "#include \"%s.h\" n", schnm); + fprintf( libfile, "#include \"%s.h\" n", schnm ); // 3. header for namespace to contain all formerly-global variables - sprintf(fnm, "%sNames.h", schnm); - if(!(files->names = FILEcreate(fnm))) { + sprintf( fnm, "%sNames.h", schnm ); + if( !( files->names = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "#include \"%sNames.h\"\n", schnm); - fprintf(files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__); - fprintf(files->names, "//this file contains a namespace for all formerly-global variables\n\n"); + fprintf( libfile, "#include \"%sNames.h\"\n", schnm ); + fprintf( files->names, "\n// In the exp2cxx source code, this file is referred to as files->names.\n// This line printed at %s:%d (one of two possible locations).\n\n", __FILE__, __LINE__ ); + fprintf( files->names, "//this file contains a namespace for all formerly-global variables\n\n" ); //the next line in this file depends on the schema name, so printing continues in the while loop ~25 lines below /* 4. source code to initialize entity registry */ /* prints header of file for input function */ - sprintf(np, "init.cc"); - if(!(initfile = (files -> init) = FILEcreate(fnm))) { + sprintf( np, "init.cc" ); + if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { return; } - fprintf(files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n"); + fprintf( files->init, "\n// in the exp2cxx source code, this file is generally referred to as files->init or initfile\n" ); - fprintf(initfile, "#include \"%s.h\"\n\n", schnm); - fprintf(initfile, "void \n%sInit (Registry& reg)\n{\n", schnm); + fprintf( initfile, "#include \"%s.h\"\n\n", schnm ); + fprintf( initfile, "void \n%sInit (Registry& reg)\n{\n", schnm ); /********** record in files relating to entire input ***********/ /* add to schema's include and initialization file */ - fprintf(schemafile, "#include \"%sNames.h\"\n", schnm); - fprintf(schemafile, "#include \"%s.h\"\n\n", schnm); - fprintf(schemafile, "extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " extern void %sInit (Registry & r);\n", schnm); - fprintf(schemainit, " %sInit (reg);\n", schnm); + fprintf( schemafile, "#include \"%sNames.h\"\n", schnm ); + fprintf( schemafile, "#include \"%s.h\"\n\n", schnm ); + fprintf( schemafile, "extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " extern void %sInit (Registry & r);\n", schnm ); + fprintf( schemainit, " %sInit (reg);\n", schnm ); /********** do all schemas ***********/ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - numberAttributes(schema); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + numberAttributes( schema ); } - DICTdo_init(express->symbol_table, &de); + DICTdo_init( express->symbol_table, &de ); bool first = true; - while(0 != (schema = (Scope)DICTdo(&de))) { - if(!first) { - fprintf(files->names, "} //namespace %s\n", SCHEMAget_name(schema)); + while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { + if( !first ) { + fprintf( files->names, "} //namespace %s\n", SCHEMAget_name( schema ) ); } first = false; - fprintf(files->names, "namespace %s {\n\n", SCHEMAget_name(schema)); - fprintf(files->names, " extern Schema * schema;\n\n"); + fprintf( files->names, "namespace %s {\n\n", SCHEMAget_name( schema ) ); + fprintf( files->names, " extern Schema * schema;\n\n" ); - SCOPEPrint(schema, files, schema, &col, 0); + SCOPEPrint( schema, files, schema, &col, 0 ); } /********** close the files ***********/ - closeUnityFiles(files); - FILEclose(libfile); - FILEclose(incfile); - INITFileFinish(initfile, schema); + closeUnityFiles( files ); + FILEclose( libfile ); + FILEclose( incfile ); + INITFileFinish( initfile, schema ); } /** @@ -748,30 +704,28 @@ void EXPRESSPrint(Express express, ComplexCollect &col, FILES *files) * Side Effects: generates code * Status: 24-Feb-1992 new -kcm */ -void print_schemas_combined(Express express, ComplexCollect &col, FILES *files) -{ - EXPRESSPrint(express, col, files); +void print_schemas_combined( Express express, ComplexCollect & col, FILES * files ) { + EXPRESSPrint( express, col, files ); } /** this function calls one of two different functions * depending on whether the output should be combined into a single * set of files or a separate set for each schema */ -void print_file(Express express) -{ - extern void RESOLUTIONsucceed(void); +void print_file( Express express ) { + extern void RESOLUTIONsucceed( void ); int separate_schemas = 1; - ComplexCollect col(express); + ComplexCollect col( express ); File_holder files; resolution_success(); - print_file_header(&files); - if(separate_schemas) { - print_schemas_separate(express, &col, &files); + print_file_header( &files ); + if( separate_schemas ) { + print_schemas_separate( express, &col, &files ); } else { - print_schemas_combined(express, col, &files); + print_schemas_combined( express, col, &files ); } - print_file_trailer(&files); - print_complex(col, "compstructs.cc"); + print_file_trailer( &files ); + print_complex( col, "compstructs.cc" ); } diff --git a/src/exp2cxx/collect.cc b/src/exp2cxx/collect.cc index 62a271498..d12db7346 100644 --- a/src/exp2cxx/collect.cc +++ b/src/exp2cxx/collect.cc @@ -14,19 +14,19 @@ #include "complexSupport.h" #include -void ComplexCollect::insert(ComplexList *c) +void ComplexCollect::insert( ComplexList * c ) /* * Inserts a new ComplexList to our list. The ComplexLists are ordered by * supertype name. Increments count. */ { - ComplexList *prev = NULL, *cl = clists; + ComplexList * prev = NULL, *cl = clists; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(prev == NULL) { + if( prev == NULL ) { // I.e., c belongs before the first cl so the above loop was never // entered. (This may also be the case if there's nothing in the // collect yet and cl also = NULL.) @@ -39,7 +39,7 @@ void ComplexCollect::insert(ComplexList *c) count++; } -void ComplexCollect::remove(ComplexList *c) +void ComplexCollect::remove( ComplexList * c ) /* * Removes the ComplexList whose supertype name = supername. "Removing" * deletes the list and removes it from this, but does not delete its @@ -49,17 +49,17 @@ void ComplexCollect::remove(ComplexList *c) * remove it from the Collect. */ { - ComplexList *cl = clists, *prev = NULL; + ComplexList * cl = clists, *prev = NULL; - while(cl && *cl < *c) { + while( cl && *cl < *c ) { prev = cl; cl = cl->next; } - if(cl == NULL || cl != c) { + if( cl == NULL || cl != c ) { // Just in case c isn't in the list. return; } - if(prev == NULL) { + if( prev == NULL ) { // c is the first thing in clists (so prev while loop never entered) clists = c->next; } else { @@ -70,23 +70,23 @@ void ComplexCollect::remove(ComplexList *c) count--; } -ComplexList *ComplexCollect::find(char *name) +ComplexList * ComplexCollect::find( char * name ) /* * Searches for and returns the ComplexList whose supertype name = name. */ { - ComplexList *cl = clists; + ComplexList * cl = clists; - while(cl && *cl < name) { + while( cl && *cl < name ) { cl = cl->next; } - if(cl && *cl == name) { + if( cl && *cl == name ) { return cl; } return NULL; } -int ComplexCollect::supports(EntNode *ents) +int ComplexCollect::supports( EntNode * ents ) /* * Determines if the parent schema supports the instantiation of a complex * type consisting of the entities named in ents. Does so by attempting @@ -96,36 +96,36 @@ int ComplexCollect::supports(EntNode *ents) * to match it, as described in the commenting. */ { - EntNode *node = ents, *nextnode; - AndList *alist = 0; - ComplexList *clist = clists, *cl = NULL, *current; + EntNode * node = ents, *nextnode; + AndList * alist = 0; + ComplexList * clist = clists, *cl = NULL, *current; int retval; - EntList *elist, *next; + EntList * elist, *next; // Loop through the nodes of ents. If 1+ of them have >1 supertype, build // a combo-CList to handle it. - while(node) { - if(node->multSuprs()) { + while( node ) { + if( node->multSuprs() ) { // Temporarily slice out node from its list (so that CList-> // contains() will work properly below): nextnode = node->next; node->next = NULL; - if(!cl) { + if( !cl ) { // We may have created cl already in an earlier pass. alist = new AndList; - cl = new ComplexList(alist); + cl = new ComplexList( alist ); } current = clists; - while(current) { - if(current->contains(node)) { + while( current ) { + if( current->contains( node ) ) { // Must add current CList to new CList. First check if we // added current already (while testing an earlier node). - if(! cl->toplevel(current->supertype())) { + if( ! cl->toplevel( current->supertype() ) ) { // Below line adds current to cl. "current->head-> // childList" points to the EntLists directly under the // top-level AND. We'll add that list right under the // new AND we created at cl's top level. - alist->appendList(current->head->childList); + alist->appendList( current->head->childList ); } } current = current->next; @@ -137,11 +137,11 @@ int ComplexCollect::supports(EntNode *ents) // Now figure out if we match ents or not. Done differently depending on // if we had a sub of >1 supers (and built cl as a combo). - if(!cl) { + if( !cl ) { // If we never built up cl in the above loop, there were no entities // which had mult supers. Simply go through each CList separately: - while(clist != NULL) { - if(clist->matches(ents)) { + while( clist != NULL ) { + if( clist->matches( ents ) ) { return TRUE; } clist = clist->next; @@ -152,13 +152,13 @@ int ComplexCollect::supports(EntNode *ents) // Use cl to test that the conditions of all supertypes are met: cl->multSupers = TRUE; cl->buildList(); - retval = cl->matches(ents); + retval = cl->matches( ents ); // We have our return value. Now get rid of cl: // Unlink all the EntLists (gotten from other CLists) which were joined // to make cl: elist = cl->head->childList; - while(elist) { + while( elist ) { elist->prev = NULL; elist = elist->next; next = elist->next; diff --git a/src/exp2cxx/complexSupport.h b/src/exp2cxx/complexSupport.h index 9055d92f8..8277a03fa 100644 --- a/src/exp2cxx/complexSupport.h +++ b/src/exp2cxx/complexSupport.h @@ -63,8 +63,7 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode -{ +class EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -72,59 +71,48 @@ class EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), - multSupers(0) - { - strcpy(name, nm); - } - EntNode(char *[]); // given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), + multSupers( 0 ) { + strcpy( name, nm ); + } + EntNode( char *[] ); // given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - int operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + int operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - int operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + int operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - int operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + int operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - int marked(MarkType base = ORMARK) - { - return (mark >= base); + int marked( MarkType base = ORMARK ) { + return ( mark >= base ); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() - { + int multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - EntNode *next; + EntNode * next; private: MarkType mark; @@ -132,79 +120,68 @@ class EntNode int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList -{ +class EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual int getMaxLevel() - { + virtual int getMaxLevel() { return level; } - virtual int contains(const char *) = 0; - virtual int hit(const char *) = 0; - virtual int isDependent(const char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual int contains( const char * ) = 0; + virtual int hit( const char * ) = 0; + virtual int isDependent( const char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual int acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual int acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); - virtual void write(ostream &) = 0; + virtual void write( ostream & ) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return next->firstNot(j); + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return next->firstWanted(mat); + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return prev->lastNot(j); + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return prev->lastWanted(mat); + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *prev, * next; + EntList * prev, * next; protected: MatchType viable; @@ -216,153 +193,137 @@ class EntList int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList -{ +class SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strcpy(name, n); + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strcpy( name, n ); } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - int contains(const char *nm) - { + int contains( const char * nm ) { return *this == nm; } - int hit(const char *nm) - { + int hit( const char * nm ) { return *this == nm; } - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - int acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + int acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } - void write(ostream &); + void write( ostream & ); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList -{ +class MultList : public EntList { // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} + MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} ~MultList(); - void setLevel(int); + void setLevel( int ); int getMaxLevel(); - int contains(const char *); - int hit(const char *); - int isDependent(const char *); - void appendList(EntList *); - EntList *copyList(EntList *); - void processSubExp(Expression, Entity, ComplexCollect *); - void addSimpleAndSubs(Entity, ComplexCollect *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + int contains( const char * ); + int hit( const char * ); + int isDependent( const char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + void processSubExp( Expression, Entity, ComplexCollect * ); + void addSimpleAndSubs( Entity, ComplexCollect * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - int prevKnown(EntList *); + void unmarkAll( EntNode * ); + int prevKnown( EntList * ); void reset(); - void write(ostream &); + void write( ostream & ); protected: int numchildren; - EntList *childList; + EntList * childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList -{ +class JoinList : public MultList { // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - int acceptChoice(EntNode *); + void setViableVal( EntNode * ); + int acceptChoice( EntNode * ); }; -class AndOrList : public JoinList -{ +class AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class AndList : public JoinList -{ +class AndList : public JoinList { friend class MultList; friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND), supertype(0) {} + AndList() : JoinList( AND ), supertype( 0 ) {} ~AndList() {} - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList -{ +class OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} ~OrList() {} - int hit(const char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - int acceptChoice(EntNode *); - int acceptNextChoice(EntNode *ents) - { + int hit( const char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + int acceptChoice( EntNode * ); + int acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -375,101 +336,90 @@ class OrList : public MultList // the first viable choice; and how many choices are there entirely. }; -class ComplexList -{ +class ComplexList { // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} - ComplexList(Entity, ComplexCollect *); + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} + ComplexList( Entity, ComplexCollect * ); ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return ((SimpleList *)head->childList)->name; + const char * supertype() { + return ( ( SimpleList * )head->childList )->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel(const char *); - int contains(EntNode *); - int matches(EntNode *); - int isDependent(const char *); + int toplevel( const char * ); + int contains( EntNode * ); + int matches( EntNode * ); + int isDependent( const char * ); - EntNode *list; // List of all entities contained in this complex type, + EntNode * list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } - void write(ostream &); - int getEntListMaxLevel() - { + void write( ostream & ); + int getEntListMaxLevel() { return head->getMaxLevel(); } private: - void addSuper(Entity); - void addSubExp(Expression); - void addImplicitSubs(Linked_List, ComplexCollect *); - void addChildren(EntList *); - int hitMultNodes(EntNode *); + void addSuper( Entity ); + void addSubExp( Expression ); + void addImplicitSubs( Linked_List, ComplexCollect * ); + void addChildren( EntList * ); + int hitMultNodes( EntNode * ); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect -{ +class ComplexCollect { // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ComplexCollect(Express); - ~ComplexCollect() - { + ComplexCollect( Express ); + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); + void insert( ComplexList * ); + void remove( ComplexList * ); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList *find(char *); - int supports(EntNode *); - bool externMapping(const char *ent) - { - return (clists ? clists->isDependent(ent) : 0); + ComplexList * find( char * ); + int supports( EntNode * ); + bool externMapping( const char * ent ) { + return ( clists ? clists->isDependent( ent ) : 0 ); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write(const char *); + void write( const char * ); - ComplexList *clists; + ComplexList * clists; private: int count; // # of clist children @@ -477,6 +427,6 @@ class ComplexCollect // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex(ComplexCollect &, const char *); +void print_complex( ComplexCollect &, const char * ); #endif diff --git a/src/exp2cxx/complexlist.cc b/src/exp2cxx/complexlist.cc index 672f2e9f0..2a42c6d96 100644 --- a/src/exp2cxx/complexlist.cc +++ b/src/exp2cxx/complexlist.cc @@ -18,7 +18,7 @@ ComplexList::~ComplexList() * Destructor for ComplexList. */ { - if(next) { + if( next ) { delete next; } delete head; @@ -39,7 +39,7 @@ void ComplexList::remove() delete this; } -int ComplexList::toplevel(const char *name) +int ComplexList::toplevel( const char * name ) /* * Returns TRUE if name is already contained at the top level of our * EntList hierarchy. By top level, we mean the level under head. This @@ -47,14 +47,14 @@ int ComplexList::toplevel(const char *name) * a temporary CList to test entities which are subtypes of >1 supertype. */ { - EntList *slist = head->childList; + EntList * slist = head->childList; - while(slist) { - if(*(SimpleList *)slist == name) { + while( slist ) { + if( *( SimpleList * )slist == name ) { return TRUE; } slist = slist->next; - if(slist) { + if( slist ) { slist = slist->next; } } @@ -71,20 +71,20 @@ void ComplexList::buildList() * ComplexList certainly can't support it. */ { - EntList *sibling = head->childList->next; + EntList * sibling = head->childList->next; // sibling = the first EntList (below the overall AND) after the supertype. // If there was a list before, delete it: - if(list) { + if( list ) { delete list; } // Add first node based on supertype: - list = new EntNode(((SimpleList *)head->childList)->name); + list = new EntNode( ( ( SimpleList * )head->childList )->name ); // Recursively add all descendents: - while(sibling) { - addChildren(sibling); + while( sibling ) { + addChildren( sibling ); sibling = sibling->next; // Note - a CList usually has no more than 1 sibling, corresponding to // the subtype info of a supertype. But this may be a combo-CList used @@ -93,37 +93,37 @@ void ComplexList::buildList() } -void ComplexList::addChildren(EntList *ent) +void ComplexList::addChildren( EntList * ent ) /* * Recursive function to add all the SimpleList descendents of ent into * this's list. */ { - EntList *child; - char *nm; - EntNode *prev = list, *prev2 = NULL, *newnode; + EntList * child; + char * nm; + EntNode * prev = list, *prev2 = NULL, *newnode; int comp = 0; - if(ent->multiple()) { - child = ((MultList *)ent)->childList; - while(child) { - addChildren(child); + if( ent->multiple() ) { + child = ( ( MultList * )ent )->childList; + while( child ) { + addChildren( child ); child = child->next; } } else { - nm = (dynamic_cast< SimpleList * >(ent))->name; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + nm = ( dynamic_cast< SimpleList * >(ent) )->name; + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end // of the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -135,7 +135,7 @@ void ComplexList::addChildren(EntList *ent) } } -int ComplexList::contains(EntNode *ents) +int ComplexList::contains( EntNode * ents ) /* * Does a simple search to determine if this contains all the nodes of an * EntNode list. If not, there's no way this will match ents. If so, @@ -144,13 +144,13 @@ int ComplexList::contains(EntNode *ents) * cally. */ { - EntNode *ours = list, *theirs = ents; + EntNode * ours = list, *theirs = ents; - while(theirs != NULL) { - while(ours != NULL && *ours < *theirs) { + while( theirs != NULL ) { + while( ours != NULL && *ours < *theirs ) { ours = ours->next; } - if(ours == NULL || *ours > *theirs) { + if( ours == NULL || *ours > *theirs ) { // If either of these occurred, we couldn't find one of ours which // matched the current "theirs". return FALSE; @@ -163,7 +163,7 @@ int ComplexList::contains(EntNode *ents) return TRUE; } -int ComplexList::matches(EntNode *ents) +int ComplexList::matches( EntNode * ents ) /* * Receives as input an EntNode list, corresponding to a user request to * instantiate the corresponding complex type. Returns TRUE if such a list @@ -176,32 +176,32 @@ int ComplexList::matches(EntNode *ents) // First check if this ComplexList at least contains all the nodes of ents. // If it does, we'll search in detail. If not, we're done. - if(! contains(ents)) { + if( ! contains( ents ) ) { return FALSE; } // Now start a thorough search through this ComplexList: - if((retval = head->matchNonORs(ents)) == MATCHALL) { + if( ( retval = head->matchNonORs( ents ) ) == MATCHALL ) { result = TRUE; - } else if(retval != UNKNOWN) { + } else if( retval != UNKNOWN ) { result = FALSE; // UNKNOWN is the return val if there are ORs matchNonORs can't // analyze. Unless we got a MATCHALL already, that's our only hope. } else { - if(((retval = head->matchORs(ents)) == MATCHALL) && - (hitMultNodes(ents))) { + if( ( ( retval = head->matchORs( ents ) ) == MATCHALL ) && + ( hitMultNodes( ents ) ) ) { // hitMultNodes() checks that in case we're a combo-CList (see // CColect->supports()) we have a legal choice (see comments in // hitMultNodes()). result = TRUE; - } else if(retval >= MATCHSOME) { + } else if( retval >= MATCHSOME ) { MatchType otherChoices = NEWCHOICE; // We have a partial answer. Check if other solutions exist (i.e., // if there are OR's with other choices): - while(otherChoices == NEWCHOICE) { - otherChoices = head->tryNext(ents); - if(otherChoices == MATCHALL) { - if(hitMultNodes(ents)) { + while( otherChoices == NEWCHOICE ) { + otherChoices = head->tryNext( ents ); + if( otherChoices == MATCHALL ) { + if( hitMultNodes( ents ) ) { result = TRUE; } else { otherChoices = NEWCHOICE; @@ -217,7 +217,7 @@ int ComplexList::matches(EntNode *ents) return result; } -int ComplexList::isDependent(const char *ent) +int ComplexList::isDependent( const char * ent ) /* * Do any of our members tell us that ent cannot be instantiated indepen- * dently. This is the case if ent = one of the subtypes beneath and the @@ -229,22 +229,22 @@ int ComplexList::isDependent(const char *ent) * it could (must?) be created with internal mapping. */ { - EntList *elist = head->childList->next; + EntList * elist = head->childList->next; // We start searching from the first sibling after head->childList. head-> // childList represents the supertype (`A' in header comments) which though // it of course is AND'ed with all its subtypes, it doesn't make its sub's // non-independent. - if(elist->isDependent(ent) == TRUE) { + if( elist->isDependent( ent ) == TRUE ) { return TRUE; } - if(next) { - return (next->isDependent(ent)); + if( next ) { + return ( next->isDependent( ent ) ); } return FALSE; } -int ComplexList::hitMultNodes(EntNode *ents) +int ComplexList::hitMultNodes( EntNode * ents ) /* * This function has a specialized application. If the user wants to * instantiate a complex type containing an entity with >1 supertype (call @@ -259,34 +259,34 @@ int ComplexList::hitMultNodes(EntNode *ents) * also deals with the possibility that >1 entities like C exist.) */ { - EntNode *node; - EntList *child; + EntNode * node; + EntList * child; // First get rid of the trivial case: If this is not a combo-CList at all, // we have nothing to check for. (CList::matches() routinely checks for // hitMultNodes in case we're a combo.) - if(!multSupers) { + if( !multSupers ) { return TRUE; } - for(node = ents; node != NULL; node = node->next) { - if(node->multSuprs()) { + for( node = ents; node != NULL; node = node->next ) { + if( node->multSuprs() ) { child = head->childList->next; // child points to the sublist of the first CList. (head is the // AndList which AND's them all together.) - while(child) { + while( child ) { // child is one of the EntList members of this which corre- // sponds to one of the combined CLists. If child has node as // a member, it must have matched node, or we do not have a // legal match (see function header comments). We check this // below. - if(child->contains(node->name)) { - if(! child->hit(node->name)) { + if( child->contains( node->name ) ) { + if( ! child->hit( node->name ) ) { return FALSE; } } child = child->next; - if(child) { + if( child ) { child = child->next; } // We increment child twice. We know this is how CLists are diff --git a/src/exp2cxx/entlist.cc b/src/exp2cxx/entlist.cc index 8c9c47aef..e27114294 100644 --- a/src/exp2cxx/entlist.cc +++ b/src/exp2cxx/entlist.cc @@ -23,108 +23,108 @@ int EntList::siblings() */ { int count; - EntList *el; + EntList * el; - for(count = 1, el = next; el; count++, el = el->next) { + for( count = 1, el = next; el; count++, el = el->next ) { ; } return count; } -EntList *EntList::firstNot(JoinType j) +EntList * EntList::firstNot( JoinType j ) /* * Returns the first EntList not of type join, starting from this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList *EntList::firstWanted(MatchType match) +EntList * EntList::firstWanted( MatchType match ) /* * Returns the first EntList where viable = match, starting from this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->next; } return sibling; // (may = NULL) } -EntList *EntList::lastNot(JoinType j) +EntList * EntList::lastNot( JoinType j ) /* * Returns the last EntList not of type join, searching backwards from * this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->join == j) { + while( sibling != NULL && sibling->join == j ) { sibling = sibling->prev; } return sibling; // (may = NULL) } -EntList *EntList::lastWanted(MatchType match) +EntList * EntList::lastWanted( MatchType match ) /* * Returns the last EntList where viable = match, searching backwards from * this. */ { - EntList *sibling = this; + EntList * sibling = this; - while(sibling != NULL && sibling->viable != match) { + while( sibling != NULL && sibling->viable != match ) { sibling = sibling->prev; } return sibling; // (may = NULL) } -int SimpleList::isDependent(const char *ent) +int SimpleList::isDependent( const char * ent ) /* * Can we determine that ent can be instantiated independently (a Simple- * List could never tell us that an entity is dependent - only a AndList * could determine that.) */ { - if(!strcmp(name, ent)) { + if( !strcmp( name, ent ) ) { return FALSE; } return DONT_KNOW; } -void SimpleList::unmarkAll(EntNode *ents) +void SimpleList::unmarkAll( EntNode * ents ) /* * Unmarks the node that was marked by this List. Normally called when * undoing an OR choice to try out another. */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp = -1; - if(viable < MATCHSOME) { + if( viable < MATCHSOME ) { return; } - while(eptr != NULL && (comp = strcmp(eptr->name, name)) < 0) { + while( eptr != NULL && ( comp = strcmp( eptr->name, name ) ) < 0 ) { eptr = eptr->next; } // (We assume we have a match now since viable >= MATCHSOME.) - if(eptr->mark <= I_marked) { + if( eptr->mark <= I_marked ) { // Only unmark if we gave it the strongest mark: - eptr->setmark(NOMARK); + eptr->setmark( NOMARK ); } // Either way (whether or not another List's mark remains), we no longer // marked: I_marked = NOMARK; } -int SimpleList::acceptChoice(EntNode *ents) +int SimpleList::acceptChoice( EntNode * ents ) /* * Marks whichever node we can mark. We assume there is a match because * this function is only called by a parent MultList if its child had a @@ -132,13 +132,13 @@ int SimpleList::acceptChoice(EntNode *ents) * node; otherwise FALSE. */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked()) { - eptr->setmark(ORMARK); + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked() ) { + eptr->setmark( ORMARK ); I_marked = ORMARK; // Remember that we're the one who marked this. (Nec. in case // we have to unmark later to try out another OR branch.) @@ -146,7 +146,7 @@ int SimpleList::acceptChoice(EntNode *ents) } return FALSE; // we didn't mark } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. return FALSE; } diff --git a/src/exp2cxx/entnode.cc b/src/exp2cxx/entnode.cc index c042660fa..50f3a8659 100644 --- a/src/exp2cxx/entnode.cc +++ b/src/exp2cxx/entnode.cc @@ -14,7 +14,7 @@ #include "complexSupport.h" #include -EntNode::EntNode(char *namelist[]) +EntNode::EntNode( char * namelist[] ) /* * Given a list of entity names, creates a sorted linked list of EntNodes * corresponding to the list. Final name must be "*" (otherwise we won't @@ -24,41 +24,41 @@ EntNode::EntNode(char *namelist[]) */ { int j = 1, comp = 0; - EntNode *prev, *prev2 = NULL, // prev2 - the one before prev - *newnode, *firstnode; - char *nm; + EntNode * prev, *prev2 = NULL, // prev2 - the one before prev + *newnode, *firstnode; + char * nm; // Create a first EntNode: - firstnode = prev = new EntNode(namelist[0]); + firstnode = prev = new EntNode( namelist[0] ); // The following 3 lines are a ridiculous kludge to simplify testing. // We make the assumption that ents whose name start with C or M have // >1 supertype. (We make sure this is the case in the test file.) // When this code becomes a part of the SCL, it'll be easy to get this // info right from the entity structs anyway, so I'm not bothering // writing anything more sophisticated. - if(*namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j') { - firstnode->multSuprs(TRUE); + if( *namelist[0] == 'c' || *namelist[0] == 'm' || *namelist[0] == 'j' ) { + firstnode->multSuprs( TRUE ); } - while(*namelist[j] != '*') { + while( *namelist[j] != '*' ) { nm = namelist[j]; - while(prev != NULL && (comp = strcmp(prev->name, nm)) < 0) { + while( prev != NULL && ( comp = strcmp( prev->name, nm ) ) < 0 ) { prev2 = prev; prev = prev->next; } // One exceptional case: If new name is same as prev, skip it: - if(comp != 0) { + if( comp != 0 ) { // At this point, we know the new node belongs between prev2 and // prev. prev or prev2 may = NULL if newnode belongs at the end of // the list or before the beginning, respectively. - newnode = new EntNode(nm); + newnode = new EntNode( nm ); // Same kludge: - if(*nm == 'c' || *nm == 'm' || *nm == 'j') { - newnode->multSuprs(TRUE); + if( *nm == 'c' || *nm == 'm' || *nm == 'j' ) { + newnode->multSuprs( TRUE ); } newnode->next = prev; - if(prev2 == NULL) { + if( prev2 == NULL ) { // This will be the case if the inner while was never entered. // That happens when newnode belonged at the beginning of the // list. If so, reset firstnode. @@ -75,7 +75,7 @@ EntNode::EntNode(char *namelist[]) // Finally, place the contents of firstnode in 'this', and delete first- // node. This ensures that 'this' is first. - strcpy(name, firstnode->name); + strcpy( name, firstnode->name ); next = firstnode->next; multSupers = firstnode->multSupers; firstnode->next = NULL; @@ -83,14 +83,14 @@ EntNode::EntNode(char *namelist[]) delete firstnode; } -void EntNode::markAll(MarkType stamp) +void EntNode::markAll( MarkType stamp ) /* * Marks/unmarks all the nodes in this's list (default is to mark). */ { - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { + while( node != NULL ) { node->mark = stamp; node = node->next; } @@ -101,10 +101,10 @@ int EntNode::allMarked() * Returns TRUE if this and all nodes following it are marked. */ { - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { return FALSE; } node = node->next; @@ -118,10 +118,10 @@ int EntNode::unmarkedCount() */ { int count = 0; - EntNode *node = this; + EntNode * node = this; - while(node != NULL) { - if(node->mark == NOMARK) { + while( node != NULL ) { + if( node->mark == NOMARK ) { count++; } node = node->next; diff --git a/src/exp2cxx/expressbuild.cc b/src/exp2cxx/expressbuild.cc index 932978839..a1c665656 100644 --- a/src/exp2cxx/expressbuild.cc +++ b/src/exp2cxx/expressbuild.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static void initEnts(Express); -static Entity findEnt(Entity, char *); +static void initEnts( Express ); +static Entity findEnt( Entity, char * ); -ComplexCollect::ComplexCollect(Express express) +ComplexCollect::ComplexCollect( Express express ) /* * Builds a ComplexCollect, a collection of ComplexLists, based on the * entities contained in EXPRESS file express. @@ -26,7 +26,7 @@ ComplexCollect::ComplexCollect(Express express) { DictionaryEntry de_sch, de_ent; Schema schema; - ComplexList *cl, *prev = NULL; + ComplexList * cl, *prev = NULL; // Some initializing: clists = NULL; @@ -35,26 +35,26 @@ ComplexCollect::ComplexCollect(Express express) // Set all ent->search_id's to 0. Since entities - even ones in different // schemas - may be strongly connected, we must be sure not to process each // one more than once. - initEnts(express); + initEnts( express ); // Next loop through all the entities, building ComplexLists: - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - SCOPEdo_entities(schema, ent, de_ent) - if(ent->search_id == TRUE) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + SCOPEdo_entities( schema, ent, de_ent ) + if( ent->search_id == TRUE ) { // we've hit this entity already continue; } #ifdef COMPLEX_INFO - cout << "Processing entity " << ENTITYget_name(ent) << endl; + cout << "Processing entity " << ENTITYget_name( ent ) << endl; #endif - if(ent->u.entity->subtypes != NULL) { - cl = new ComplexList(ent, this); + if( ent->u.entity->subtypes != NULL ) { + cl = new ComplexList( ent, this ); // This constructor will not only create a ComplexList for // the ent subtypes, but it will recurse for all of their // subtypes. The entire hierarchy will become a single // ComplexList and is now appended to the Collect ("this"). - insert(cl); + insert( cl ); } SCOPEod } @@ -64,13 +64,13 @@ ComplexCollect::ComplexCollect(Express express) // supercede them. (They were added in the first place to be available // so that any supertype which accessed it would find it.) cl = clists; - while(cl) { - if(cl->Dependent()) { + while( cl ) { + if( cl->Dependent() ) { #ifdef COMPLEX_INFO cout << "\nRemoving dependent entity " << cl->supertype() << endl; #endif - remove(cl); - if(prev) { + remove( cl ); + if( prev ) { cl = prev->next; // prev->next was automatically set to cl->next in remove() // when cl was removed. @@ -86,7 +86,7 @@ ComplexCollect::ComplexCollect(Express express) } } -static void initEnts(Express express) +static void initEnts( Express express ) /* * Sets all the search_id's of all the entities to FALSE. The search_id's * will be used to keep track of which entities we've build ComplexLists @@ -96,15 +96,15 @@ static void initEnts(Express express) DictionaryEntry de_sch, de_ent; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - SCOPEdo_entities(schema, ent, de_ent) + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = FALSE; SCOPEod } } -ComplexList::ComplexList(Entity ent, ComplexCollect *col) +ComplexList::ComplexList( Entity ent, ComplexCollect * col ) /* * Builds a complex list from an entity which contains subtypes. (All our * members are set here or in called functions except next which is set @@ -118,39 +118,39 @@ ComplexList::ComplexList(Entity ent, ComplexCollect *col) next = NULL; maxlevel = 0; - addSuper(ent); - if((exp = ent->u.entity->subtype_expression) != NULL) { + addSuper( ent ); + if( ( exp = ent->u.entity->subtype_expression ) != NULL ) { #ifdef COMPLEX_INFO cout << " Has a sub expression\n"; #endif - head->processSubExp(exp, ent, col); + head->processSubExp( exp, ent, col ); buildList(); } // Check for any subtypes which were not a part of subtype_expr. Any // subtype which was not in sub_exp but is included in subtypes is ANDORed // with the rest of the List. - addImplicitSubs(ENTITYget_subtypes(ent), col); + addImplicitSubs( ENTITYget_subtypes( ent ), col ); - if(ENTITYget_supertypes(ent) == NULL) { + if( ENTITYget_supertypes( ent ) == NULL ) { dependent = FALSE; // Rebuild list in case implicit subs were added (we had to build the // first time also so addImplicitSubs() would work). buildList(); //maxlevel = head->setLevel( 0 ); - head->setLevel(0); + head->setLevel( 0 ); } else { // If this List has supertypes, we don't really need it as a List - // it will ultimately be a part of its super(s)' List(s). We need it // now so its supers will be able to find it. But mark that this // does not stand on its own: #ifdef COMPLEX_INFO - cout << " " << ENTITYget_name(ent) << " is dependent\n"; + cout << " " << ENTITYget_name( ent ) << " is dependent\n"; #endif dependent = TRUE; } } -void ComplexList::addSuper(Entity ent) +void ComplexList::addSuper( Entity ent ) /* * Sets our supertype. Assumes supertype was previously unset. */ @@ -160,12 +160,12 @@ void ComplexList::addSuper(Entity ent) // (Although this supertype may itself be a subtype of other supertypes, // we call this a supertype. We only need this info during the list- // creation stage (see MultList::processSubExp()).) - head->childList = new SimpleList(ENTITYget_name(ent)); + head->childList = new SimpleList( ENTITYget_name( ent ) ); head->numchildren = 1; } -void MultList::processSubExp(Expression exp, Entity super, - ComplexCollect *col) +void MultList::processSubExp( Expression exp, Entity super, + ComplexCollect * col ) /* * Recursive function which builds an EntList hierarchy from an entity's * subtype expression. First called with this = the ComplexList->head and @@ -173,26 +173,26 @@ void MultList::processSubExp(Expression exp, Entity super, * process the subexpressions. */ { - struct Op_Subexpression *oe = &exp->e; + struct Op_Subexpression * oe = &exp->e; Entity ent; - MultList *mult; + MultList * mult; int supertype = 0; - switch(TYPEis(exp->type)) { + switch( TYPEis( exp->type ) ) { case entity_: - ent = findEnt(super, exp->type->symbol.name); + ent = findEnt( super, exp->type->symbol.name ); #ifdef COMPLEX_INFO - cout << " Adding subtype " << ENTITYget_name(ent) << endl; + cout << " Adding subtype " << ENTITYget_name( ent ) << endl; #endif - addSimpleAndSubs(ent, col); + addSimpleAndSubs( ent, col ); break; case op_: - if(join == AND) { - supertype = (dynamic_cast< AndList * >(this))->supertype; + if( join == AND ) { + supertype = ( dynamic_cast< AndList * >(this) )->supertype; } - if(! supertype && - ((oe->op_code == OP_AND && join == AND) - || (oe->op_code == OP_ANDOR && join == ANDOR))) { + if( ! supertype && + ( ( oe->op_code == OP_AND && join == AND ) + || ( oe->op_code == OP_ANDOR && join == ANDOR ) ) ) { // If the subexp is of the same type as we, process its op's at // the same level (add them on to our childList). 1st cond says // we don't do this if this is the supertype. In that case, the @@ -200,10 +200,10 @@ void MultList::processSubExp(Expression exp, Entity super, // a lower level. One reason for this is in case we find implicit // subtypes, we'll want to ANDOR them with the rest of the subs. // So we'll want the subs at a distinct lower level. - processSubExp(oe->op1, super, col); - processSubExp(oe->op2, super, col); + processSubExp( oe->op1, super, col ); + processSubExp( oe->op2, super, col ); } else { - if(oe->op_code == OP_AND) { + if( oe->op_code == OP_AND ) { #ifdef COMPLEX_INFO cout << " Processing AND\n"; #endif @@ -214,9 +214,9 @@ void MultList::processSubExp(Expression exp, Entity super, #endif mult = new AndOrList; } - appendList(mult); - mult->processSubExp(oe->op1, super, col); - mult->processSubExp(oe->op2, super, col); + appendList( mult ); + mult->processSubExp( oe->op1, super, col ); + mult->processSubExp( oe->op2, super, col ); } break; case oneof_: @@ -224,9 +224,9 @@ void MultList::processSubExp(Expression exp, Entity super, cout << " Processing ONEOF\n"; #endif mult = new OrList; - appendList(mult); - LISTdo(exp->u.list, arg, Expression) - mult->processSubExp(arg, super, col); + appendList( mult ); + LISTdo( exp->u.list, arg, Expression ) + mult->processSubExp( arg, super, col ); LISTod break; default: @@ -235,20 +235,20 @@ void MultList::processSubExp(Expression exp, Entity super, } } -static Entity findEnt(Entity ent0, char *name) +static Entity findEnt( Entity ent0, char * name ) /* * Returns an entity named name. The desired entity is likely to be in the * same schema as ent0. findEnt first searches the schema which contains * ent, and then searches the other schemas in the express file. */ { - Schema schema = ENTITYget_schema(ent0), sch; + Schema schema = ENTITYget_schema( ent0 ), sch; DictionaryEntry de_ent, de_sch; Express express; // First look through the entities in the same schema as ent0: - SCOPEdo_entities(schema, ent, de_ent) - if(!strcmp(ENTITYget_name(ent), name)) { + SCOPEdo_entities( schema, ent, de_ent ) + if( !strcmp( ENTITYget_name( ent ), name ) ) { return ent; } SCOPEod @@ -256,14 +256,14 @@ static Entity findEnt(Entity ent0, char *name) // If we still haven't found it, look through all the entities in the // express file: express = schema->superscope; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((sch = (Scope)DICTdo(&de_sch)) != 0) { - if(sch == schema) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( sch = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + if( sch == schema ) { // Don't redo the schema which contains ent0 - we did it already. continue; } - SCOPEdo_entities(sch, ent, de_ent) - if(!strcmp(ENTITYget_name(ent), name)) { + SCOPEdo_entities( sch, ent, de_ent ) + if( !strcmp( ENTITYget_name( ent ), name ) ) { return ent; } SCOPEod @@ -273,34 +273,34 @@ static Entity findEnt(Entity ent0, char *name) // complained already. } -void ComplexList::addImplicitSubs(Linked_List subs, ComplexCollect *col) +void ComplexList::addImplicitSubs( Linked_List subs, ComplexCollect * col ) /* * Checks if there are any subtypes of entity this->supertype() which were * not in the entity's subtype_expression. (subs is the entity's subtypes * list.) If any are found they are ANDORed with the other subtypes. */ { - EntNode node((char *)""); + EntNode node( ( char * )"" ); // Temp var - used to check if this already contains certain values. int none_yet = TRUE; - AndOrList *ao = 0; + AndOrList * ao = 0; - LISTdo(subs, subEnt, Entity) - strcpy(node.name, ENTITYget_name(subEnt)); - if(!contains(&node)) { + LISTdo( subs, subEnt, Entity ) + strcpy( node.name, ENTITYget_name( subEnt ) ); + if( !contains( &node ) ) { // We've found an implicit subtype. #ifdef COMPLEX_INFO - cout << " Adding implicit subtype " << ENTITYget_name(subEnt) + cout << " Adding implicit subtype " << ENTITYget_name( subEnt ) << endl; #endif - if(none_yet) { + if( none_yet ) { // If this is the first one, replace the previous subtype list // with an ANDOR. none_yet = FALSE; ao = new AndOrList; // Make the previous sub exp a child of ao: ao->childList = head->childList->next; - if(ao->childList) { + if( ao->childList ) { ao->childList->prev = NULL; ao->numchildren = 1; } else { @@ -312,12 +312,12 @@ void ComplexList::addImplicitSubs(Linked_List subs, ComplexCollect *col) } // Add the new entity to the end of ao. In case it has its own // subtype list, call addSimpleAndSubs(). - ao->addSimpleAndSubs(subEnt, col); + ao->addSimpleAndSubs( subEnt, col ); } LISTod } -void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) +void MultList::addSimpleAndSubs( Entity newEnt, ComplexCollect * col ) /* * Called whenever we have a SimpleList (to be built from newEnt) to add * to our ComplexList. The purpose of this function is to check if the @@ -326,17 +326,17 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) * SimpleList corresponding to newEnt. */ { - ComplexList *sublist; - SimpleList *simple; - EntList *newlist; - OrList *olist; + ComplexList * sublist; + SimpleList * simple; + EntList * newlist; + OrList * olist; // First get the easy case out of the way. If newEnt has no subtypes // just create a corresponding SimpleList: - if(ENTITYget_subtypes(newEnt) == NULL) { + if( ENTITYget_subtypes( newEnt ) == NULL ) { newEnt->search_id = TRUE; - simple = new SimpleList(ENTITYget_name(newEnt)); - appendList(simple); + simple = new SimpleList( ENTITYget_name( newEnt ) ); + appendList( simple ); return; } @@ -344,14 +344,14 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) #ifdef COMPLEX_INFO cout << " Subtype is a supertype ...\n"; #endif - if(newEnt->search_id == TRUE) { + if( newEnt->search_id == TRUE ) { // We've processed child already, find its ComplexList in col: #ifdef COMPLEX_INFO cout << " was built already ... finding it\n"; #endif - sublist = col->find(ENTITYget_name(newEnt)); + sublist = col->find( ENTITYget_name( newEnt ) ); // Make a copy and append to this: - newlist = copyList(sublist->head); + newlist = copyList( sublist->head ); } else { // If this subtype has never been visited, we build a ComplexList out // of it and add it to our ComplexCollect. Even though it only exists @@ -363,32 +363,32 @@ void MultList::addSimpleAndSubs(Entity newEnt, ComplexCollect *col) #ifdef COMPLEX_INFO cout << " never built before ... building it now\n"; #endif - sublist = new ComplexList(newEnt, col); - col->insert(sublist); + sublist = new ComplexList( newEnt, col ); + col->insert( sublist ); // Since this is the first time we're creating this list, we don't need // to copy it and append to this, as above. We'll use the same Lists // again and also point to them from this. - appendList(sublist->head); + appendList( sublist->head ); newlist = sublist->head; } // If the sub-list is not abstract, one more task: - if(! newEnt->u.entity->abstract) { + if( ! newEnt->u.entity->abstract ) { // Since the subtype is not abstract, it can be instantiated without // its subtypes. Create an OrList OR'ing the supertype alone and its // entire List: olist = new OrList; - simple = new SimpleList((char *)sublist->supertype()); - olist->appendList(simple); + simple = new SimpleList( ( char * )sublist->supertype() ); + olist->appendList( simple ); // We just added "newlist" to the end of this. We now replace it with // our new or, and place it underneath the or. This OR's the new // subtype alone with the subtype + its own subtypes - just what we // want for a non-abstract subtype. - olist->appendList(newlist); + olist->appendList( newlist ); numchildren--; // (Slightly ugly: Since we just grabbed newlist from this to or, we // had the side effect of making this's numcount incorrect. I could // have done this more elegantly, but was lazy.) - appendList(olist); + appendList( olist ); } } diff --git a/src/exp2cxx/fedex_main.c b/src/exp2cxx/fedex_main.c index ded6b6aea..81c6f1515 100644 --- a/src/exp2cxx/fedex_main.c +++ b/src/exp2cxx/fedex_main.c @@ -80,61 +80,57 @@ #include -extern void print_fedex_version(void); +extern void print_fedex_version( void ); -static void exp2cxx_usage(void) -{ +static void exp2cxx_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n"); - fprintf(stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n"); - fprintf(stderr, "\t-L prints logging code in the generated C++ classes\n"); - fprintf(stderr, "\t-v produces the version description below\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-n do not pause for internal errors (useful with delta script)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); + fprintf( stderr, "usage: %s [-s|-S] [-a|-A] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n" ); + fprintf( stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n" ); + fprintf( stderr, "\t-L prints logging code in the generated C++ classes\n" ); + fprintf( stderr, "\t-v produces the version description below\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-n do not pause for internal errors (useful with delta script)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); print_fedex_version(); - exit(2); + exit( 2 ); } -int Handle_FedPlus_Args(int, char *); -void print_file(Express); +int Handle_FedPlus_Args( int, char * ); +void print_file( Express ); -void resolution_success(void) -{ - printf("Resolution successful. Writing C++ output...\n"); +void resolution_success( void ) { + printf( "Resolution successful. Writing C++ output...\n" ); } -int success(Express model) -{ +int success( Express model ) { (void) model; /* unused */ - printf("Finished writing files.\n"); - return(0); + printf( "Finished writing files.\n" ); + return( 0 ); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat(EXPRESSgetopt_options, "sSlLaA"); + strcat( EXPRESSgetopt_options, "sSlLaA" ); ERRORusage_function = exp2cxx_usage; } diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index 2d21580b4..47004e43d 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -24,18 +24,16 @@ char header[ BUFSIZ ] = {0}; filenames_t fnames = { impl, header }; -filenames_t getEntityFilenames(Entity e) -{ - const char *name = ENTITYget_classname(e); - snprintf(header, BUFSIZ - 1, "entity/%s.h", name); - snprintf(impl, BUFSIZ - 1, "entity/%s.cc", name); +filenames_t getEntityFilenames( Entity e ) { + const char * name = ENTITYget_classname( e ); + snprintf( header, BUFSIZ-1, "entity/%s.h", name ); + snprintf( impl, BUFSIZ-1, "entity/%s.cc", name ); return fnames; } -filenames_t getTypeFilenames(Type t) -{ - const char *name = TYPEget_ctype(t); - snprintf(header, BUFSIZ - 1, "type/%s.h", name); - snprintf(impl, BUFSIZ - 1, "type/%s.cc", name); +filenames_t getTypeFilenames( Type t ) { + const char * name = TYPEget_ctype( t ); + snprintf( header, BUFSIZ-1, "type/%s.h", name ); + snprintf( impl, BUFSIZ-1, "type/%s.cc", name ); return fnames; } diff --git a/src/exp2cxx/genCxxFilenames.h b/src/exp2cxx/genCxxFilenames.h index 1bdc65561..f79d33cd6 100644 --- a/src/exp2cxx/genCxxFilenames.h +++ b/src/exp2cxx/genCxxFilenames.h @@ -13,8 +13,8 @@ typedef struct { /* will we ever need more file names? */ - const char *impl; - const char *header; + const char * impl; + const char * header; } filenames_t; /** write entity filenames to a pair of shared static buffers. @@ -22,13 +22,13 @@ typedef struct { * * \sa getTypeFilenames() */ -filenames_t getEntityFilenames(Entity e); +filenames_t getEntityFilenames( Entity e ); /** write type filenames to a pair of shared static buffers. * names will be overwritten by next call to a function using those buffers! * * \sa getEntityFilenames() */ -filenames_t getTypeFilenames(Type t); +filenames_t getTypeFilenames( Type t ); #endif /* GENCXXFILENAMES_H */ diff --git a/src/exp2cxx/match-ors.cc b/src/exp2cxx/match-ors.cc index ee2bd7f48..1b86622e4 100644 --- a/src/exp2cxx/match-ors.cc +++ b/src/exp2cxx/match-ors.cc @@ -16,7 +16,7 @@ #include "complexSupport.h" #include -MatchType AndOrList::matchORs(EntNode *ents) +MatchType AndOrList::matchORs( EntNode * ents ) /* * Loops through descendants of this, invoking their matchOR functions. * Returns the status of how well this's OR descendants match the nodes of @@ -27,27 +27,27 @@ MatchType AndOrList::matchORs(EntNode *ents) * is an OR, or has an OR somewhere beneath it which we must process now. */ { - EntList *child = childList->firstWanted(UNKNOWN); + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); } // NOTE - We went through entire loop above even if we found a MATCHALL // sometime in the middle. After finding a bug, I realized we couldn't // stop in the middle. So long as there are more UNKNOWN children, one // of those children may become UNSAT later and we'll have to unmark all // its descendants. If so, some of the marks we have now may disappear. - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType AndList::matchORs(EntNode *ents) +MatchType AndList::matchORs( EntNode * ents ) /* * Loops through the descendants of this with viable val = UNKNOWN, invo- * king their matchOR functions. Returns the status of how well this's OR @@ -55,26 +55,26 @@ MatchType AndList::matchORs(EntNode *ents) * they will lead us to OR's, as explained in AndOrList::matchORs(). */ { - EntList *child = childList->firstWanted(UNKNOWN); + EntList * child = childList->firstWanted( UNKNOWN ); - while(child != NULL) { - if((dynamic_cast< MultList * >(child))->matchORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( ( dynamic_cast< MultList * >(child) )->matchORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextWanted(UNKNOWN); + child = child->nextWanted( UNKNOWN ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType OrList::matchORs(EntNode *ents) +MatchType OrList::matchORs( EntNode * ents ) /* * Checks the branches of an OrList to search for a match to the nodes of * ents. This function searches this's children and marks all the viable @@ -85,41 +85,41 @@ MatchType OrList::matchORs(EntNode *ents) */ { int count; - EntList *child = childList; + EntList * child = childList; MatchType retval = UNKNOWN; - for(count = 0; count < numchildren; count++, child = child->next) { + for( count = 0; count < numchildren; count++, child = child->next ) { // First call (recursively) matchNonORs() to check off all nodes that // the descendants of this branch can definitely mark off: - if(child->join != OR) { - retval = child->matchNonORs(ents); + if( child->join != OR ) { + retval = child->matchNonORs( ents ); } // Then try the OR's. At this point, any OR's that we get to (in // recursively checking the descendants of child) will know that if // it can mark new node(s), it's a viable option. - if(child->viable == UNKNOWN) { + if( child->viable == UNKNOWN ) { // If viable = UNKNOWN, this child must either be an OR or a Mult // with an OR underneath. Only ORs are still indeterminate after // running matchNonORs() above. (We also exclude the case of an // AND child who may have OR desc's, but already determined that // it can't satisfy one of its paths and so returned UNSAT.) - retval = (dynamic_cast< MultList * >(child))->matchORs(ents); + retval = ( dynamic_cast< MultList * >(child) )->matchORs( ents ); } // Now register the result: - if(retval >= MATCHSOME) { + if( retval >= MATCHSOME ) { // Note: In the past I would return immediately if retval = // MATCHALL, thinking our job was done. I changed it when we // started dealing with combo-CLists (sub w/ >1 super). I realized // that even if down here we got a MATCHALL, we may have to reject // above, so we must keep searching. - if(choice == -1) { + if( choice == -1 ) { choice1 = choice = count; } choiceCount++; - if(viable < retval) { + if( viable < retval ) { viable = retval; } } else { @@ -131,17 +131,17 @@ MatchType OrList::matchORs(EntNode *ents) // Will cause us to tell our parent that we have at least one // satisfactory path. Thus, if our parent is an AND, it'll know // that this branch doesn't violate anything. - if(viable < retval) { + if( viable < retval ) { viable = retval; } } // Undo this choice before we try the next: - child->unmarkAll(ents); + child->unmarkAll( ents ); } // Accept the first viable solution, if there is one: - if(viable >= MATCHSOME) { + if( viable >= MATCHSOME ) { // If there are some MATCHSOME solutions, accept the first. accept- // Choice() begins by accepting the child at "choice". But if this // does not mark anything new, it loops until it finds a choice that @@ -150,10 +150,10 @@ MatchType OrList::matchORs(EntNode *ents) // because they *may* mark (since they match nodes which are only // conditionally marked). But now we're looking for a child which // *actually* marks under the current circumstances. - acceptChoice(ents); + acceptChoice( ents ); } - if(viable == MATCHALL) { - return getChild(choice1)->viable; + if( viable == MATCHALL ) { + return getChild( choice1 )->viable; // viable == MATCHALL because we found a MATCHALL sol'n along the way, // but that wasn't necessarily the choice acceptChoice() took now. // (See note above why we don't drop everything and just accept the diff --git a/src/exp2cxx/multlist.cc b/src/exp2cxx/multlist.cc index f19b02827..fb74cf5d1 100644 --- a/src/exp2cxx/multlist.cc +++ b/src/exp2cxx/multlist.cc @@ -20,38 +20,37 @@ MultList::~MultList() * Deletes the childList of this, before this is deleted. */ { - EntList *child = childList, *nxt; + EntList * child = childList, *nxt; - while(child) { + while( child ) { nxt = child->next; delete child; child = nxt; } } -void MultList::setLevel(int l) +void MultList::setLevel( int l ) /* * Sets this's level, and tells all its children to set their level to our * level +1. */ { - EntList *child = childList; + EntList * child = childList; level = l; - for(; child != NULL; child = child->next) { - child->setLevel(l + 1); + for( ; child != NULL; child = child->next ) { + child->setLevel( l + 1 ); } } -int MultList::getMaxLevel() -{ - EntList *child = childList; +int MultList::getMaxLevel() { + EntList * child = childList; int maxLevel, childLevel; maxLevel = level; - while(child) { + while( child ) { childLevel = child->getMaxLevel(); - if(childLevel > maxLevel) { + if( childLevel > maxLevel ) { maxLevel = childLevel; } child = child->next; @@ -60,15 +59,15 @@ int MultList::getMaxLevel() return maxLevel; } -int MultList::contains(const char *nm) +int MultList::contains( const char * nm ) /* * Check if one of this's descendants matches nm. */ { - EntList *child = childList; + EntList * child = childList; - while(child) { - if(child->contains(nm)) { + while( child ) { + if( child->contains( nm ) ) { return TRUE; } child = child->next; @@ -76,15 +75,15 @@ int MultList::contains(const char *nm) return FALSE; } -int MultList::hit(const char *nm) +int MultList::hit( const char * nm ) /* * Check if one of our descendants matches nm. */ { - EntList *child = childList; + EntList * child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // For most child->join types ruling out UNSATs just saves us // trouble - we know nm won't be hit since child didn't hit any- // thing. If child->join = AND, we must skip child. One of its @@ -97,7 +96,7 @@ int MultList::hit(const char *nm) return FALSE; } -int MultList::isDependent(const char *ent) +int MultList::isDependent( const char * ent ) /* * Can one of our descendants tell us that entity ent can or cannot be * instantiated independently (i.e., not as a complex entity with external @@ -108,14 +107,14 @@ int MultList::isDependent(const char *ent) * Dependent(). */ { - EntList *child = childList; + EntList * child = childList; int result = DONT_KNOW, retval; - while(child) { - if((retval = child->isDependent(ent)) == FALSE) { + while( child ) { + if( ( retval = child->isDependent( ent ) ) == FALSE ) { return FALSE; } - if(retval == TRUE) { + if( retval == TRUE ) { // If child tells us that ent must be created together with another // leaf node (e.g., child is an AndList AND'ing ent + ent_b), save // the result. Don't return TRUE yet because a later child may @@ -130,7 +129,7 @@ int MultList::isDependent(const char *ent) // either DONT_KNOW or TRUE if we got here } -int AndList::isDependent(const char *ent) +int AndList::isDependent( const char * ent ) /* * Tells us if entity ent cannot be instantiated independently. Say ent * A is a supertype of ( B AND C ). Neither B nor C can be instantiated @@ -141,7 +140,7 @@ int AndList::isDependent(const char *ent) * if nothing can be determined, it returns DONT_KNOW. */ { - if(supertype) { + if( supertype ) { // If we're a supertype, we have to make one exception. Normally if // we're an AND of A & B and ent = A, we'd be able to conclude that A // requires ext mapping. But here, the first child of the AND is a @@ -150,7 +149,7 @@ int AndList::isDependent(const char *ent) // we skip the first child. We then continue to check if among the // subtypes of A there are children requiring ext mapping (such as B // AND C). - return (childList->next->isDependent(ent)); + return ( childList->next->isDependent( ent ) ); // NOTE - actually the algorithm for a supertype is more complex. We // did not address here the possibility that ent = the super (A). In // such a case, if A is non-abstract, then by def it can be instanti- @@ -174,8 +173,8 @@ int AndList::isDependent(const char *ent) // Next possibility: We don't represent a supertype. Thus, if we have >1 // child and ent is one of them, it can only be created by being AND'ed // with at least 1 other child. - if(numchildren > 1) { - if(contains(ent)) { + if( numchildren > 1 ) { + if( contains( ent ) ) { return TRUE; } return DONT_KNOW; @@ -184,36 +183,36 @@ int AndList::isDependent(const char *ent) // If we have 1 child only, just move on. At this point, the fact that // we're an AND didn't go very far in telling us that our children are // dependent on one another since we only *have* one child. - return (childList->isDependent(ent)); + return ( childList->isDependent( ent ) ); } -EntList *MultList::getChild(int num) +EntList * MultList::getChild( int num ) /* * Returns a pointer to the num'th child of MultList. */ { - EntList *child = childList; + EntList * child = childList; int j; - if(num < 0 || num >= numchildren) { + if( num < 0 || num >= numchildren ) { // Check for error situations (shouldn't normally occur): return NULL; } - for(j = 0; j < num; j++, child = child->next) { + for( j = 0; j < num; j++, child = child->next ) { ; } return child; } -void MultList::appendList(EntList *ent) +void MultList::appendList( EntList * ent ) /* * Appends a new entry into this's childList. The siblings of ent (ent-> * next ...) are automatically also appended. */ { - EntList *prv; + EntList * prv; - if(numchildren == 0) { + if( numchildren == 0 ) { childList = ent; } else { prv = getLast(); @@ -223,21 +222,21 @@ void MultList::appendList(EntList *ent) numchildren += ent->siblings(); } -EntList *MultList::copyList(EntList *ent) +EntList * MultList::copyList( EntList * ent ) /* * Makes a copy of ent (and its children if it's a MultList) and appends it * to the end of our list. */ { - EntList *newlist = 0, *child; + EntList * newlist = 0, *child; - switch(ent->join) { + switch( ent->join ) { case SIMPLE: - newlist = new SimpleList((dynamic_cast< SimpleList * >(ent))->Name()); + newlist = new SimpleList( ( dynamic_cast< SimpleList * >(ent) )->Name() ); break; case AND: newlist = new AndList; - ((AndList *)newlist)->supertype = (dynamic_cast< AndList * >(ent))->supertype; + ( ( AndList * )newlist )->supertype = ( dynamic_cast< AndList * >(ent) )->supertype; break; case OR: newlist = new OrList; @@ -246,29 +245,29 @@ EntList *MultList::copyList(EntList *ent) newlist = new AndOrList; break; }; - appendList(newlist); - if(ent->multiple()) { + appendList( newlist ); + if( ent->multiple() ) { // For the multlists, we must recurse for all their children: - child = (dynamic_cast< MultList * >(ent))->childList; - while(child) { - (dynamic_cast< MultList * >(newlist))->copyList(child); + child = ( dynamic_cast< MultList * >(ent) )->childList; + while( child ) { + ( dynamic_cast< MultList * >(newlist) )->copyList( child ); child = child->next; } } return newlist; } -void MultList::unmarkAll(EntNode *ents) +void MultList::unmarkAll( EntNode * ents ) /* * Unmarks all nodes of ents marked by any of the descendants of this. * This function is invoked by AndList and AndOrList. It is redefined for * OrList. */ { - EntList *child = childList; + EntList * child = childList; - while(child != NULL) { - child->unmarkAll(ents); + while( child != NULL ) { + child->unmarkAll( ents ); child = child->next; } } @@ -279,15 +278,15 @@ void MultList::reset() * each child's reset function. */ { - EntList *child; + EntList * child; viable = UNKNOWN; - for(child = childList; child; child = child->next) { + for( child = childList; child; child = child->next ) { child->reset(); } } -void JoinList::setViableVal(EntNode *ents) +void JoinList::setViableVal( EntNode * ents ) /* * Sets this's viable value based on the value of its children. This is * called at the end of matchNonOR() and matchOR() to determine the result @@ -299,22 +298,22 @@ void JoinList::setViableVal(EntNode *ents) * worry about coming across them down here. */ { - EntList *child = childList; + EntList * child = childList; viable = UNKNOWN; // Start viable at UNKNOWN. This is default val and the lowest enum val. - while(child != NULL) { - if(child->viable == UNKNOWN) { + while( child != NULL ) { + if( child->viable == UNKNOWN ) { viable = UNKNOWN; return; } - if(child->viable > viable) { + if( child->viable > viable ) { viable = child->viable; } child = child->next; } - if(viable == MATCHALL && !ents->allMarked()) { + if( viable == MATCHALL && !ents->allMarked() ) { // There are some situations where this may happen - a child claims // MATCHALL while that is not the case. If child #2 was checked and // later child #1 was unmarked (because we tried its OR's and ran into @@ -323,18 +322,18 @@ void JoinList::setViableVal(EntNode *ents) } } -int JoinList::acceptChoice(EntNode *ents) +int JoinList::acceptChoice( EntNode * ents ) /* * Accept the path we're a part of: Mark all nodes of ents we can. Mark * value will = mark (either MARK or ORMARK). Return TRUE if we mark any- * thing; FALSE otherwise. */ { - EntList *child; + EntList * child; int result = FALSE; - for(child = childList; child != NULL; child = child->next) { - if(child->viable >= MATCHSOME) { + for( child = childList; child != NULL; child = child->next ) { + if( child->viable >= MATCHSOME ) { // Only mark children which have new nodes they can mark. (This // condition is important. Sometimes, there will be children who // can mark but whose variable val = SATISFIED. This will be the @@ -345,7 +344,7 @@ int JoinList::acceptChoice(EntNode *ents) // EntList we won't mark with a conditional which may be undone // later.) Thus, our test here is - is this child the one who // MATCHSOME'd when we originally went through the hierarchy.) - result = child->acceptChoice(ents) || result; + result = child->acceptChoice( ents ) || result; // (NOTE - must run acceptChoice() first in above line. If result // were TRUE and we ||'ed it with acceptChoice(), aC() would never // be run.) @@ -354,17 +353,17 @@ int JoinList::acceptChoice(EntNode *ents) return result; } -int MultList::prevKnown(EntList *desc) +int MultList::prevKnown( EntList * desc ) /* * Specialized function to test that none of the children prior to desc * (a pointer to one of the EntLists of childList) have viable = UNKNOWN. * Used in MatchNonORs() (see). */ { - EntList *child = childList; + EntList * child = childList; - while(child != NULL && child != desc) { - if(child->viable == UNKNOWN) { + while( child != NULL && child != desc ) { + if( child->viable == UNKNOWN ) { return FALSE; } child = child->next; diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 0af0731e9..51a210ecb 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -37,21 +37,21 @@ #include -int isAggregateType(const Type t); +int isAggregateType( const Type t ); /* Local function prototypes: */ -static void initializeMarks(Express); -static void cleanupMarks(Express); -static void unsetObjs(Schema); -static bool checkTypes(Schema); -static bool checkEnts(Schema); -static void markDescs(Entity); -static bool checkItem(Type, Scope, Schema, int *, int); -static int ENUMcanBeProcessed(Type, Schema); -static int inSchema(Scope, Scope); -static void addRenameTypedefs(Schema, FILE *); -static void addAggrTypedefs(Schema, FILE *); -static void addUseRefNames(Schema, FILE *); +static void initializeMarks( Express ); +static void cleanupMarks( Express ); +static void unsetObjs( Schema ); +static bool checkTypes( Schema ); +static bool checkEnts( Schema ); +static void markDescs( Entity ); +static bool checkItem( Type, Scope, Schema, int *, int ); +static int ENUMcanBeProcessed( Type, Schema ); +static int inSchema( Scope, Scope ); +static void addRenameTypedefs( Schema, FILE * ); +static void addAggrTypedefs( Schema , FILE * ); +static void addUseRefNames( Schema, FILE * ); /** * Generates the C++ files corresponding to a list of schemas. Does so in @@ -63,45 +63,44 @@ static void addUseRefNames(Schema, FILE *); * select types which have enum or select items (or entities containing * enums) which have not been processed. */ -void print_schemas_separate(Express express, void *complexCol, FILES *files) -{ +void print_schemas_separate( Express express, void * complexCol, FILES * files ) { bool complete = false; int val1, val2, suffix; DictionaryEntry de; Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks(express); + initializeMarks( express ); /* TODO only print gr, wr, str as needed, from SCHEMAprint in classes_wrapper.cc? */ - fprintf(files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n"); + fprintf( files->create, " Global_rule_ptr gr;\n Where_rule_ptr wr;\n std::string str; //for large strings such as functions or global rules\n" ); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - numberAttributes(schema); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + numberAttributes( schema ); } - while(!complete) { + while( !complete ) { complete = true; - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - if(schema->search_id == UNPROCESSED) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + if( schema->search_id == UNPROCESSED ) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs(schema); + unsetObjs( schema ); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes(schema); - val2 = checkEnts(schema); + val1 = checkTypes( schema ); + val2 = checkEnts( schema ); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if(val1 || val2) { - if(schema->search_id == UNPROCESSED || - *(int *)schema->clientData > 0) { + if( val1 || val2 ) { + if( schema->search_id == UNPROCESSED || + *( int * )schema->clientData > 0 ) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -111,13 +110,13 @@ void print_schemas_separate(Express express, void *complexCol, FILES *files) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*(int *)schema->clientData; - SCHEMAprint(schema, files, complexCol, suffix); + suffix = ++*( int * )schema->clientData; + SCHEMAprint( schema, files, complexCol, suffix ); } else { - SCHEMAprint(schema, files, complexCol, 0); + SCHEMAprint( schema, files, complexCol, 0 ); } } - complete = complete && (schema->search_id == PROCESSED); + complete = complete && ( schema->search_id == PROCESSED ); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -127,53 +126,53 @@ void print_schemas_separate(Express express, void *complexCol, FILES *files) /******************* *******************/ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(files->create, - "//////////////// USE statements\n"); - USEREFout(schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( files->create, + "//////////////// USE statements\n" ); + USEREFout( schema, schema->u.schema->usedict, schema->u.schema->use_schemas, "USE", files->create ); - fprintf(files->create, - "//////////////// REFERENCE statements\n"); - USEREFout(schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create); + fprintf( files->create, + "//////////////// REFERENCE statements\n" ); + USEREFout( schema, schema->u.schema->refdict, schema->u.schema->ref_schemas, "REFERENCE", files->create ); } /***************** *****************/ /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addRenameTypedefs(schema, files->classes); - addUseRefNames(schema, files->create); + addRenameTypedefs( schema, files->classes ); + addUseRefNames( schema, files->create ); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - addAggrTypedefs(schema, files->classes); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + addAggrTypedefs( schema, files->classes ); } /* On our way out, print the necessary statements to add support for // complex entities. (The 1st line below is a part of SchemaInit(), // which hasn't been closed yet. (That's done on 2nd line below.)) */ - fprintf(files->initall, " reg.SetCompCollect( gencomplex() );\n"); - fprintf(files->initall, "}\n\n"); - fprintf(files->incall, "\n#include \n"); - fprintf(files->incall, "ComplexCollect *gencomplex();\n"); + fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); + fprintf( files->initall, "}\n\n" ); + fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); /* Function GetModelContents() is printed at the end of the schema.xx // files. This is done in a separate loop through the schemas, in function // below. */ - getMCPrint(express, files->incall, files->initall); + getMCPrint( express, files->incall, files->initall ); /* Finally clean up memory allocated by initializeMarks. */ - cleanupMarks(express); + cleanupMarks( express ); } -static void initializeMarks(Express express) +static void initializeMarks( Express express ) /* * Set all schema->search_id's to UNPROCESSED, meaning we haven't processed * all the ents and types in it yet. Also, put an int=0 in each schema's @@ -187,35 +186,34 @@ static void initializeMarks(Express express) DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { schema->search_id = UNPROCESSED; - schema->clientData = (int *)sc_malloc(sizeof(int)); - *(int *)schema->clientData = 0; - SCOPEdo_entities(schema, ent, de_ent) + schema->clientData = ( int * )sc_malloc( sizeof( int ) ); + *( int * )schema->clientData = 0; + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types(schema, t, de_type) + SCOPEdo_types( schema, t, de_type ) t->search_id = NOTKNOWN; SCOPEod } } -static void cleanupMarks(Express express) -{ +static void cleanupMarks( Express express ) { DictionaryEntry de_sch; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { - if(schema->clientData) { - sc_free(schema->clientData); + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { + if( schema->clientData ) { + sc_free( schema->clientData ); schema->clientData = NULL; } } } -static void unsetObjs(Schema schema) +static void unsetObjs( Schema schema ) /* * Resets all the ents & types of schema which had been set to CANTPROCRSS * to NOTKNOWN. This function is called every time print_schemas_separate @@ -228,13 +226,13 @@ static void unsetObjs(Schema schema) { DictionaryEntry de; - SCOPEdo_types(schema, t, de) - if(t->search_id == CANTPROCESS) { + SCOPEdo_types( schema, t, de ) + if( t->search_id == CANTPROCESS ) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities(schema, ent, de) - if(ent->search_id == CANTPROCESS) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id == CANTPROCESS ) { ent->search_id = NOTKNOWN; } SCOPEod @@ -252,8 +250,7 @@ static void unsetObjs(Schema schema) * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static bool checkTypes(Schema schema) -{ +static bool checkTypes( Schema schema ) { DictionaryEntry de; bool retval = false; int unknowncnt; @@ -263,8 +260,8 @@ static bool checkTypes(Schema schema) do { unknowncnt = 0; - SCOPEdo_types(schema, type, de) { - if(type->search_id != NOTKNOWN) { + SCOPEdo_types( schema, type, de ) { + if( type->search_id != NOTKNOWN ) { continue; } /* We're only interested in the ones which haven't been processed @@ -273,9 +270,9 @@ static bool checkTypes(Schema schema) type->search_id = CANPROCESS; /* Assume this until disproven. */ - if(TYPEis_enumeration(type) && TYPEget_head(type)) { - i = TYPEget_ancestor(type); - if(!sameSchema(i, type) && i->search_id != PROCESSED) { + if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { + i = TYPEget_ancestor( type ); + if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -284,10 +281,10 @@ static bool checkTypes(Schema schema) type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if(TYPEis_select(type)) { - LISTdo(SEL_TYPEget_items(type), ii, Type) { - if(!TYPEis_entity(ii)) { - if(checkItem(ii, type, schema, &unknowncnt, 0)) { + } else if( TYPEis_select( type ) ) { + LISTdo( SEL_TYPEget_items( type ), ii, Type ) { + if( !TYPEis_entity( ii ) ) { + if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { break; } /* checkItem does most of the work of determining if @@ -301,8 +298,8 @@ static bool checkTypes(Schema schema) } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity(ii); - if(ent->search_id == PROCESSED) { + ent = ENT_TYPEget_entity( ii ); + if( ent->search_id == PROCESSED ) { continue; } /* If entity has been processed already, things must be @@ -312,33 +309,31 @@ static bool checkTypes(Schema schema) // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes(ent); - LISTdo_n(attribs, attr, Variable, z) { - if(checkItem(attr->type, type, schema, - &unknowncnt, 1)) { + attribs = ENTITYget_all_attributes( ent ); + LISTdo_n( attribs, attr, Variable, z ) { + if( checkItem( attr->type, type, schema, + &unknowncnt, 1 ) ) { break; } - } - LISTod - LISTfree(attribs); + } LISTod + LISTfree( attribs ); } - } - LISTod + } LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if((type->search_id == CANPROCESS) - && ((i = TYPEget_ancestor(type)) != NULL) - && (!sameSchema(i, type)) - && (i->search_id != PROCESSED)) { + if( ( type->search_id == CANPROCESS ) + && ( ( i = TYPEget_ancestor( type ) ) != NULL ) + && ( !sameSchema( i, type ) ) + && ( i->search_id != PROCESSED ) ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if(type->search_id == CANPROCESS) { + if( type->search_id == CANPROCESS ) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -346,9 +341,8 @@ static bool checkTypes(Schema schema) // go on. */ retval = true; } - } - SCOPEod - } while(unknowncnt > 0); + } SCOPEod + } while( unknowncnt > 0 ); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -382,15 +376,14 @@ static bool checkTypes(Schema schema) * of the inline commenting of checkTypes() is applicable here and is not * repeated.) */ -static bool checkEnts(Schema schema) -{ +static bool checkEnts( Schema schema ) { DictionaryEntry de; bool retval = false; int ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities(schema, ent, de) - if(ent->search_id != NOTKNOWN) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id != NOTKNOWN ) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -402,10 +395,10 @@ static bool checkEnts(Schema schema) /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo(ENTITYget_supertypes(ent), super, Entity) - if((!sameSchema(ent, super)) - && (super->search_id != PROCESSED)) { - markDescs(ent); + LISTdo( ENTITYget_supertypes( ent ), super, Entity ) + if( ( !sameSchema( ent, super ) ) + && ( super->search_id != PROCESSED ) ) { + markDescs( ent ); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -415,17 +408,17 @@ static bool checkEnts(Schema schema) /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo(ENTITYget_attributes(ent), attr, Variable) - if(checkItem(attr->type, ent, schema, &ignore, 0)) { - markDescs(ent); + LISTdo( ENTITYget_attributes( ent ), attr, Variable ) + if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { + markDescs( ent ); break; } LISTod } - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -446,13 +439,11 @@ static bool checkEnts(Schema schema) * function is called if we've determined that ent is a subtype of an * entity defined in a different schema which has not yet been processed. */ -static void markDescs(Entity ent) -{ +static void markDescs( Entity ent ) { ent->search_id = CANTPROCESS; - LISTdo(ENTITYget_subtypes(ent), sub, Entity) { - markDescs(sub); - } - LISTod + LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) { + markDescs( sub ); + } LISTod } /** @@ -477,12 +468,11 @@ static void markDescs(Entity ent) * noSel is set to 1 to tell it to worry about t if it's an enum but not * if it's a select. */ -static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int noSel) -{ +static bool checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, int noSel ) { Type i = t; - if(isAggregateType(t)) { - i = TYPEget_base_type(t); + if( isAggregateType( t ) ) { + i = TYPEget_base_type( t ); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -491,26 +481,26 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int // Sdaiclasses.h. */ } - if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { + if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if(parent->search_id == NOTKNOWN) { + if( parent->search_id == NOTKNOWN ) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - (*unknowncnt)--; + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if(TYPEis_select(i) && !noSel) { - if(!sameSchema(i, parent)) { - if(i->search_id != PROCESSED) { - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + } else if( TYPEis_select( i ) && !noSel ) { + if( !sameSchema( i, parent ) ) { + if( i->search_id != PROCESSED ) { + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -520,24 +510,24 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if(i->search_id == CANTPROCESS) { + if( i->search_id == CANTPROCESS ) { /* We *have* checked i already and it can't be processed. */ - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return true; - } else if(i->search_id == NOTKNOWN) { + } else if( i->search_id == NOTKNOWN ) { /* We haven't processed i this pass. */ - if(parent->search_id != NOTKNOWN) { + if( parent->search_id != NOTKNOWN ) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping thru the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - (*unknowncnt)++; + ( *unknowncnt )++; } } } @@ -545,7 +535,7 @@ static bool checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, int return false; } -static int ENUMcanBeProcessed(Type e, Schema s) +static int ENUMcanBeProcessed( Type e, Schema s ) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -557,31 +547,31 @@ static int ENUMcanBeProcessed(Type e, Schema s) { Type a; - if(!inSchema(e, s)) { + if( !inSchema( e, s ) ) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return (e->search_id == PROCESSED); + return ( e->search_id == PROCESSED ); } - if(e->search_id != NOTKNOWN) { + if( e->search_id != NOTKNOWN ) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return (e->search_id >= CANPROCESS); + return ( e->search_id >= CANPROCESS ); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if((a = TYPEget_ancestor(e)) == NULL) { + if( ( a = TYPEget_ancestor( e ) ) == NULL ) { /* If e is not a rename of anything, it should be processed now. */ return true; } - if(inSchema(a, s) || a->search_id == PROCESSED) { + if( inSchema( a, s ) || a->search_id == PROCESSED ) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return true; @@ -589,23 +579,23 @@ static int ENUMcanBeProcessed(Type e, Schema s) return false; } -int sameSchema(Scope sc1, Scope sc2) +int sameSchema( Scope sc1, Scope sc2 ) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return (!strcmp(SCOPEget_name(sc1->superscope), - SCOPEget_name(sc2->superscope))); + return ( !strcmp( SCOPEget_name( sc1->superscope ), + SCOPEget_name( sc2->superscope ) ) ); } -static int inSchema(Scope scope, Scope super) +static int inSchema( Scope scope, Scope super ) /* * Checks if scope is contained in super's scope. */ { - return (!strcmp(SCOPEget_name(scope->superscope), - SCOPEget_name(super))); + return ( !strcmp( SCOPEget_name( scope->superscope ), + SCOPEget_name( super ) ) ); } /** @@ -615,44 +605,42 @@ static int inSchema(Scope scope, Scope super) * (Actually, for the enum only the aggregate class name is written in * Sdaiclasses.h (needs to have forward declarations here).) */ -static void addRenameTypedefs(Schema schema, FILE *classes) -{ +static void addRenameTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; char nm[BUFSIZ], basenm[BUFSIZ]; static bool firsttime = true; - SCOPEdo_types(schema, t, de) { - if((TYPEis_enumeration(t) || TYPEis_select(t)) - && ((i = TYPEget_ancestor(t)) != NULL)) { + SCOPEdo_types( schema, t, de ) { + if( ( TYPEis_enumeration( t ) || TYPEis_select( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) ) { /* I.e., t is a renamed enum/sel type. i is set to the orig enum/ // sel t is based on (in case it's a rename of a rename etc). */ - if(firsttime) { - fprintf(classes, "\n// Renamed enum and select"); - fprintf(classes, " types (from all schemas):\n"); + if( firsttime ) { + fprintf( classes, "\n// Renamed enum and select" ); + fprintf( classes, " types (from all schemas):\n" ); firsttime = false; } - if(TYPEis_enumeration(t)) { - strncpy(nm, TYPEget_ctype(t), BUFSIZ - 1); - nm[BUFSIZ - 1] = '\0'; - strncpy(basenm, TYPEget_ctype(i), BUFSIZ - 1); - basenm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s_agg %s_agg;\n", basenm, nm); + if( TYPEis_enumeration( t ) ) { + strncpy( nm, TYPEget_ctype( t ), BUFSIZ - 1 ); + nm[BUFSIZ-1] = '\0'; + strncpy( basenm, TYPEget_ctype( i ), BUFSIZ - 1 ); + basenm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s_agg %s_agg;\n", basenm, nm ); } else { - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ - 1); - nm[BUFSIZ - 1] = '\0'; - strncpy(basenm, SelectName(TYPEget_name(i)), BUFSIZ - 1); - basenm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", basenm, nm); - fprintf(classes, "typedef %s_agg %s_agg;\n\n", basenm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); - fprintf(classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ - 1 ); + nm[BUFSIZ-1] = '\0'; + strncpy( basenm, SelectName( TYPEget_name( i ) ), BUFSIZ - 1 ); + basenm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", basenm, nm ); + fprintf( classes, "typedef %s_agg %s_agg;\n\n", basenm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); + fprintf( classes, "typedef %s_agg * %s_agg_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s_agg * %s_agg_ptr_c;\n", nm, nm ); } } - } - SCOPEod + } SCOPEod } /** @@ -662,35 +650,33 @@ static void addRenameTypedefs(Schema schema, FILE *classes) * called after addRenameTypedefs() since an aggregate may also be based on * one of the renamed enum/sel's defined there. */ -static void addAggrTypedefs(Schema schema, FILE *classes) -{ +static void addAggrTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; static bool firsttime = true; char nm[BUFSIZ]; - SCOPEdo_types(schema, t, de) { - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + SCOPEdo_types( schema, t, de ) { + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - if(firsttime) { - fprintf(classes, "\n// Aggregate types (from all schemas) which depend on other types:\n"); + if( firsttime ) { + fprintf( classes, "\n// Aggregate types (from all schemas) which depend on other types:\n" ); firsttime = false; } - strncpy(nm, ClassName(TYPEget_name(t)), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(classes, "typedef %s %s;\n", TYPEget_ctype(t), nm); - fprintf(classes, "typedef %s * %sH;\n", nm, nm); - fprintf(classes, "typedef %s * %s_ptr;\n", nm, nm); - fprintf(classes, "typedef const %s * %s_ptr_c;\n", nm, nm); + strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); + nm[BUFSIZ-1] = '\0'; + fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm ); + fprintf( classes, "typedef %s * %sH;\n", nm, nm ); + fprintf( classes, "typedef %s * %s_ptr;\n", nm, nm ); + fprintf( classes, "typedef const %s * %s_ptr_c;\n", nm, nm ); } } - } - SCOPEod + } SCOPEod } /** @@ -701,63 +687,62 @@ static void addAggrTypedefs(Schema schema, FILE *classes) * list will be used in the SCL to use the correct name of this type or * entity when reading and writing files. */ -static void addUseRefNames(Schema schema, FILE *create) -{ +static void addUseRefNames( Schema schema, FILE * create ) { Dictionary useRefDict; DictionaryEntry de; - Rename *rnm; - char *oldnm, schNm[BUFSIZ]; + Rename * rnm; + char * oldnm, schNm[BUFSIZ]; static bool firsttime = true; - if((useRefDict = schema->u.schema->usedict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { + if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if(firsttime) { - fprintf(create, " // Alternate names for types and entities when used in other schemas:\n"); + if( firsttime ) { + fprintf( create, " // Alternate names for types and entities when used in other schemas:\n" ); firsttime = false; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); } else { /* must be an entity */ - fprintf(create, " %s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, " %s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } - if((useRefDict = schema->u.schema->refdict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { - if(firsttime) { - fprintf(create, " // Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if( firsttime ) { + fprintf( create, " // Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = false; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, " %s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, " %s", TYPEtd_name( ( Type )rnm->object ) ); } else { - fprintf(create, " %s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, " %s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } diff --git a/src/exp2cxx/non-ors.cc b/src/exp2cxx/non-ors.cc index 8a4b24acf..2ef5dd803 100644 --- a/src/exp2cxx/non-ors.cc +++ b/src/exp2cxx/non-ors.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -MatchType SimpleList::matchNonORs(EntNode *ents) +MatchType SimpleList::matchNonORs( EntNode * ents ) /* * Checks if we match the nodes of ents. If only one unmarked is left * and we match it, return MATCHALL. More likely, we'll return one of the @@ -21,12 +21,12 @@ MatchType SimpleList::matchNonORs(EntNode *ents) * Support.h.) */ { - EntNode *eptr = ents; + EntNode * eptr = ents; int comp; - while(eptr != NULL) { - if((comp = strcmp(name, eptr->name)) == 0) { - if(! eptr->marked(MARK)) { + while( eptr != NULL ) { + if( ( comp = strcmp( name, eptr->name ) ) == 0 ) { + if( ! eptr->marked( MARK ) ) { // NOTE - this cond also returns TRUE if eptr did have an OR- // MARK. We don't want to remark now (since we're also trying // out OR choices -- we know this because no OR's are done @@ -35,13 +35,13 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // may one time later try another path, we want to record that // our OR can also mark it. So we return MATCHSOME saying // this is a viable option we may one time want to try. - if(eptr->mark == NOMARK) { + if( eptr->mark == NOMARK ) { eptr->setmark(); I_marked = MARK; // Remember that we're the one who marked this. (Nec. in // case we have to unmark later to try out another OR // branch.) - if(ents->allMarked()) { + if( ents->allMarked() ) { // If this was the only unmarked left, viable = MATCHALL; return MATCHALL; @@ -55,7 +55,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) // Couldn't mark any more, but at least we're not placing a re- // quirement ents couldn't meet. } - if(comp < 0) { + if( comp < 0 ) { // We're beyond name in the ents list. No more checking to do. break; } @@ -68,7 +68,7 @@ MatchType SimpleList::matchNonORs(EntNode *ents) return UNSATISFIED; } -MatchType AndOrList::matchNonORs(EntNode *ents) +MatchType AndOrList::matchNonORs( EntNode * ents ) /* * Loop through the children of this matching as many of the nodes of ents * as we can. We skip all OrList descendants. Those are processed later @@ -77,12 +77,12 @@ MatchType AndOrList::matchNonORs(EntNode *ents) * which are unnec. */ { - EntList *child = childList->firstNot(OR); + EntList * child = childList->firstNot( OR ); MatchType retval; - while(child != NULL) { - if((retval = child->matchNonORs(ents)) == MATCHALL) { - if(prevKnown(child)) { + while( child != NULL ) { + if( ( retval = child->matchNonORs( ents ) ) == MATCHALL ) { + if( prevKnown( child ) ) { viable = MATCHALL; return MATCHALL; // We found a good solution. Nothing else to do. (Some higher @@ -109,39 +109,39 @@ MatchType AndOrList::matchNonORs(EntNode *ents) // visited already in matchNonORs(), we were not able to stop // in process as here at all.) } - } else if(retval == UNSATISFIED) { + } else if( retval == UNSATISFIED ) { // Unmark whatever we may have marked. (E.g., there may have // been an AND beneath and it started marking and then found one // it couldn't match.) - child->unmarkAll(ents); + child->unmarkAll( ents ); } - child = child->nextNot(OR); + child = child->nextNot( OR ); } - setViableVal(ents); + setViableVal( ents ); return viable; } -MatchType AndList::matchNonORs(EntNode *ents) +MatchType AndList::matchNonORs( EntNode * ents ) /* * Checks if the AndList contains the set of nodes in ents. Skip OrList * descendants. */ { - EntList *child = childList->firstNot(OR); + EntList * child = childList->firstNot( OR ); - while(child != NULL) { - if(child->matchNonORs(ents) == UNSATISFIED) { + while( child != NULL ) { + if( child->matchNonORs( ents ) == UNSATISFIED ) { viable = UNSATISFIED; return UNSATISFIED; // This means the whole AndList has failed, by definition. } - child = child->nextNot(OR); + child = child->nextNot( OR ); // Note - we loop through all even if one of our children returned // MATCHALL. Since we're an AND, we must look through all branches - // to search for any other conditions we can't meet. If one of our // children did MATCHALL, its viable val will be set to MATCHALL and // we'll catch it in setViableVal() called below. } - setViableVal(ents); + setViableVal( ents ); return viable; } diff --git a/src/exp2cxx/orlist.cc b/src/exp2cxx/orlist.cc index 4b90b01cf..dd0c9db88 100644 --- a/src/exp2cxx/orlist.cc +++ b/src/exp2cxx/orlist.cc @@ -13,7 +13,7 @@ #include "complexSupport.h" #include -int OrList::hit(const char *nm) +int OrList::hit( const char * nm ) /* * Check if we matched nm. We have two possibilities here: If we have a * choice selected, we only check the selected choice. Say we're an OR @@ -27,15 +27,15 @@ int OrList::hit(const char *nm) * may need to check if all sub-CLists matched the multi-sub, C.) */ { - EntList *child = getChild(choice); + EntList * child = getChild( choice ); - if(child) { + if( child ) { // I.e., if we have a choice selected, check it only. - return (child->hit(nm)); + return ( child->hit( nm ) ); } else { child = childList; - while(child) { - if(child->viable > UNSATISFIED && child->hit(nm)) { + while( child ) { + if( child->viable > UNSATISFIED && child->hit( nm ) ) { // See MultList::hit() on why we must skip UNSATs. return TRUE; } @@ -45,20 +45,20 @@ int OrList::hit(const char *nm) return FALSE; } -void OrList::unmarkAll(EntNode *ents) +void OrList::unmarkAll( EntNode * ents ) /* * Unmarks all the nodes of ents marked by the descendants of this. */ { - EntList *child; + EntList * child; - if((child = getChild(choice)) != NULL) { + if( ( child = getChild( choice ) ) != NULL ) { // choice = the last selected path which we'll now undo. - child->unmarkAll(ents); + child->unmarkAll( ents ); } } -int OrList::acceptChoice(EntNode *ents) +int OrList::acceptChoice( EntNode * ents ) /* * Accepts the first choice of our childList which marks any unmarked * nodes. If none of our current choices mark anything, choice is set to @@ -66,14 +66,14 @@ int OrList::acceptChoice(EntNode *ents) * choice to choice1, and search again. */ { - EntList *child; + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { choice = choice1; } - child = getChild(choice); - while(child) { - if(child->viable >= MATCHSOME && child->acceptChoice(ents)) { + child = getChild( choice ); + while( child ) { + if( child->viable >= MATCHSOME && child->acceptChoice( ents ) ) { // acceptChoice() returns TRUE if we marked something. return TRUE; } diff --git a/src/exp2cxx/print.cc b/src/exp2cxx/print.cc index 837592405..0b1398a6d 100644 --- a/src/exp2cxx/print.cc +++ b/src/exp2cxx/print.cc @@ -11,14 +11,14 @@ #include // Local function prototypes: -static char *joinText(JoinType, char *); +static char * joinText( JoinType, char * ); -ostream &operator << (ostream &os, ComplexList &clist) +ostream & operator << ( ostream & os, ComplexList & clist ) /* * Prints out a ComplexList, by iterating through its children. */ { - os << "ComplexList - \"" << *(SimpleList *)clist.head->childList + os << "ComplexList - \"" << *( SimpleList * )clist.head->childList << "\" supertype\n"; // head->childList will call << for head's 1st child. We know by def // that this is the supertype. @@ -26,20 +26,20 @@ ostream &operator << (ostream &os, ComplexList &clist) return os; } -ostream &operator << (ostream &os, EntList &list) +ostream & operator << ( ostream & os, EntList & list ) /* * Prints out an EntList. Calls appropriate function based on JoinType. */ { - if(list.join == SIMPLE) { - os << *(SimpleList *)&list; + if( list.join == SIMPLE ) { + os << *( SimpleList * )&list; } else { - os << *(MultList *)&list; + os << *( MultList * )&list; } return os; } -ostream &operator << (ostream &os, SimpleList &slist) +ostream & operator << ( ostream & os, SimpleList & slist ) /* * Prints out a SimpleList. */ @@ -48,7 +48,7 @@ ostream &operator << (ostream &os, SimpleList &slist) return os; } -ostream &operator << (ostream &os, MultList &mlist) +ostream & operator << ( ostream & os, MultList & mlist ) /* * Prints out a MultList. */ @@ -57,21 +57,21 @@ ostream &operator << (ostream &os, MultList &mlist) int k, lastSimple = 0; // lastSimple - is the last child simple? If so, we need to print another // line at the end. If not, the children of last child did already. - EntList *child = mlist.childList; + EntList * child = mlist.childList; - os << joinText(mlist.join, jointype) << endl; - for(k = 0; k <= mlist.level; k++) { + os << joinText( mlist.join, jointype ) << endl; + for( k = 0; k <= mlist.level; k++ ) { // Indent 1 more than our level (hence the "<=" ): os << " "; } - while(child != NULL) { + while( child != NULL ) { os << *child; - if(child->next == NULL) { - lastSimple = (child->join == SIMPLE); + if( child->next == NULL ) { + lastSimple = ( child->join == SIMPLE ); break; // We don't want to do the conditions below if we're done. } - if(child->join == SIMPLE) { + if( child->join == SIMPLE ) { // If so, we're just going to continue printing the next child // (if exists) in same line. os << " "; @@ -79,35 +79,35 @@ ostream &operator << (ostream &os, MultList &mlist) // If another MultList is coming, it printed a new line for its // childList (as we're doing). We must now start a new line at // our indent level: - for(k = 0; k <= mlist.level; k++) { + for( k = 0; k <= mlist.level; k++ ) { os << " "; } } child = child->next; } - if(lastSimple) { + if( lastSimple ) { os << endl; } return os; } -static char *joinText(JoinType j, char *buf) +static char * joinText( JoinType j, char * buf ) /* * Copies and returns the string equivalent of a JoinType. */ { - switch(j) { + switch( j ) { case SIMPLE: - strcpy(buf, "SIMPLE"); + strcpy( buf, "SIMPLE" ); return buf; case AND: - strcpy(buf, "AND"); + strcpy( buf, "AND" ); return buf; case OR: - strcpy(buf, "OR"); + strcpy( buf, "OR" ); return buf; case ANDOR: - strcpy(buf, "ANDOR"); + strcpy( buf, "ANDOR" ); return buf; }; return NULL; diff --git a/src/exp2cxx/rules.c b/src/exp2cxx/rules.c index 3d39a3080..6dfe7aa96 100644 --- a/src/exp2cxx/rules.c +++ b/src/exp2cxx/rules.c @@ -5,62 +5,57 @@ #include /* print Where_rule's. for types, schema should be null - tename will include schema name */ -void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR) -{ - if(wheres) { - fprintf(impl, " %s%s%s->_where_rules = new Where_rule__list;\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); - if(needWR) { - fprintf(impl, " Where_rule * wr;\n"); +void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ) { + if( wheres ) { + fprintf( impl, " %s%s%s->_where_rules = new Where_rule__list;\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); + if( needWR ) { + fprintf( impl, " Where_rule * wr;\n" ); } - LISTdo(wheres, w, Where) { - fprintf(impl, " str.clear();\n"); - if(w->label) { - fprintf(impl, " str.append( \"%s: (\" );\n", w->label->name); + LISTdo( wheres, w, Where ) { + fprintf( impl, " str.clear();\n"); + if( w->label ) { + fprintf( impl, " str.append( \"%s: (\" );\n", w->label->name ); } else { /* no label */ - fprintf(impl, " str.append( \"(\" );\n"); + fprintf( impl, " str.append( \"(\" );\n"); } - format_for_std_stringout(impl, EXPRto_string(w->expr)); + format_for_std_stringout( impl, EXPRto_string( w->expr ) ); - fprintf(impl, " str.append( \");\\n\" );\n"); + fprintf( impl, " str.append( \");\\n\" );\n"); - fprintf(impl, " wr = new Where_rule( str.c_str() );\n"); - fprintf(impl, " %s%s%s->_where_rules->Append( wr );\n", (schema ? SCHEMAget_name(schema) : ""), (schema ? "::" ENT_PREFIX : ""), tename); + fprintf( impl, " wr = new Where_rule( str.c_str() );\n" ); + fprintf( impl, " %s%s%s->_where_rules->Append( wr );\n", ( schema ? SCHEMAget_name( schema ) : "" ), ( schema ? "::" ENT_PREFIX : "" ), tename ); - } - LISTod + } LISTod } } /* print Uniqueness_rule's */ -void UNIQUEprint(Entity entity, FILE *impl, Schema schema) -{ +void UNIQUEprint( Entity entity, FILE * impl, Schema schema ) { Linked_List uniqs = entity->u.entity->unique; - if(uniqs) { - fprintf(impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - fprintf(impl, " Uniqueness_rule * ur;\n"); - LISTdo(uniqs, list, Linked_List) { + if( uniqs ) { + fprintf( impl, " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + fprintf( impl, " Uniqueness_rule * ur;\n" ); + LISTdo( uniqs, list, Linked_List ) { int i = 0; - fprintf(impl, " str.clear();\n"); - LISTdo_n(list, e, Expression, b) { + fprintf( impl, " str.clear();\n"); + LISTdo_n( list, e, Expression, b ) { i++; - if(i == 1) { + if( i == 1 ) { /* print label if present */ - if(e) { - fprintf(impl, " str.append( \"%s : \" );\n", StrToUpper(((Symbol *)e)->name)); + if( e ) { + fprintf( impl, " str.append( \"%s : \" );\n", StrToUpper( ( ( Symbol * )e )->name ) ); } } else { - if(i > 2) { - fprintf(impl, " str.append( \", \" );\n"); + if( i > 2 ) { + fprintf( impl, " str.append( \", \" );\n"); } - format_for_std_stringout(impl, EXPRto_string(e)); + format_for_std_stringout( impl, EXPRto_string( e ) ); } - } - LISTod - fprintf(impl, " ur = new Uniqueness_rule( str.c_str() );\n"); - fprintf(impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name(schema), ENT_PREFIX, ENTITYget_name(entity)); - } - LISTod + } LISTod + fprintf( impl, " ur = new Uniqueness_rule( str.c_str() );\n" ); + fprintf( impl, " %s::%s%s->_uniqueness_rules->Append(ur);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); + } LISTod } } diff --git a/src/exp2cxx/rules.h b/src/exp2cxx/rules.h index 3ad7d8d32..6f6e77cfb 100644 --- a/src/exp2cxx/rules.h +++ b/src/exp2cxx/rules.h @@ -4,10 +4,10 @@ #include /** print Where_rule's. for types, schema should be null - tename will include schema name + type prefix */ -void WHEREprint(const char *tename, Linked_List wheres, FILE *impl, Schema schema, bool needWR); +void WHEREprint( const char * tename, Linked_List wheres, FILE * impl, Schema schema, bool needWR ); /** print Uniqueness_rule's. only Entity type has them? */ -void UNIQUEprint(Entity entity, FILE *impl, Schema schema); +void UNIQUEprint( Entity entity, FILE * impl, Schema schema ); #endif /* RULES_H */ diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 1360e3551..b4fd3e60d 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -34,7 +34,7 @@ extern int multiple_inheritance; ((t)->u.type->body->type == integer_) || \ ((t)->u.type->body->type == number_) ) #define PRINT_BUG_REPORT \ - fprintf( f, "std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ + fprintf( f, " std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ " in schema library: \\n\" \n << _POC_ << \"\\n\\n\";\n"); #define PRINT_SELECTBUG_WARNING(f) \ @@ -52,31 +52,28 @@ extern int multiple_inheritance; #define TRUE 1 #define FALSE 0 -static void initSelItems(const Type, FILE *); +static void initSelItems( const Type, FILE * ); -const char *SEL_ITEMget_enumtype(Type t) -{ - return StrToUpper(TYPEget_name(t)); +const char * SEL_ITEMget_enumtype( Type t ) { + return StrToUpper( TYPEget_name( t ) ); } /** \returns type used to represent the underlying type in a select class */ -const char *TYPEget_utype(Type t) -{ - return (TYPEis_entity(t) ? "SDAI_Application_instance_ptr" : TYPEget_ctype(t)); +const char * TYPEget_utype( Type t ) { + return ( TYPEis_entity( t ) ? "SDAI_Application_instance_ptr" : TYPEget_ctype( t ) ); } /** determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. */ -void *LISTmember(const Linked_List list, void *e) -{ +void *LISTmember( const Linked_List list, void *e ) { Link node; - for(node = list->mark->next; node != list->mark; node = node->next) - if(e == node -> data) { + for( node = list->mark->next; node != list->mark; node = node->next ) + if( e == node -> data ) { return e; } - return (0); + return ( 0 ); } /** Specialized function to catch if two enumerations, two selects, or two aggrs @@ -87,19 +84,18 @@ void *LISTmember(const Linked_List list, void *e) equivalent. This function is called in instances when they should be consi- dered equivalent. One such case is the generation of duplicate lists. */ -static int compareOrigTypes(Type a, Type b) -{ +static int compareOrigTypes( Type a, Type b ) { Type t, u; - if((TYPEis_select(a) && TYPEis_select(b)) - || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { + if( ( TYPEis_select( a ) && TYPEis_select( b ) ) + || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { t = a; u = b; - } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { - t = TYPEget_base_type(a); - u = TYPEget_base_type(b); - if(!((TYPEis_select(t) && TYPEis_select(u)) - || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { + } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { + t = TYPEget_base_type( a ); + u = TYPEget_base_type( b ); + if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) + || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that for 2D aggrs and higher we do not continue. These are all recog- @@ -110,13 +106,13 @@ static int compareOrigTypes(Type a, Type b) return FALSE; } - if(TYPEget_head(t)) { - t = TYPEget_ancestor(t); + if( TYPEget_head( t ) ) { + t = TYPEget_ancestor( t ); } - if(TYPEget_head(u)) { - u = TYPEget_ancestor(u); + if( TYPEget_head( u ) ) { + u = TYPEget_ancestor( u ); } - return (!strcmp(TYPEget_name(t), TYPEget_name(u))); + return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); } /** determines if the given "link's" underlying type is a member of the list. @@ -126,20 +122,19 @@ static int compareOrigTypes(Type a, Type b) list already has an item that check is a renaming of (see header comments to compareOrigTypes() above). */ -const char *utype_member(const Linked_List list, const Type check, int rename) -{ +const char * utype_member( const Linked_List list, const Type check, int rename ) { static char r [BUFSIZ]; - bool checkIsEntity = TYPEis_entity(check); + bool checkIsEntity = TYPEis_entity( check ); - LISTdo(list, t, Type) { - if(TYPEis_entity(t) && checkIsEntity) { + LISTdo( list, t, Type ) { + if( TYPEis_entity( t ) && checkIsEntity ) { return "SDAI_Application_instance_ptr"; } /* string returned by TYPEget_utype isn't necessarily static so we * need to copy between calls * */ - strncpy(r, TYPEget_ctype(t), BUFSIZ); - if(strcmp(r, TYPEget_ctype(check)) == 0 || (rename && compareOrigTypes(check, t))) { + strncpy( r, TYPEget_ctype( t ), BUFSIZ ); + if( strcmp( r, TYPEget_ctype( check ) ) == 0 || ( rename && compareOrigTypes( check, t ) ) ) { return r; } } @@ -153,16 +148,15 @@ const char *utype_member(const Linked_List list, const Type check, int rename) * * The list that is returned needs to be freed by the caller. */ -Linked_List SELgetnew_dmlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SELgetnew_dmlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); - LISTdo(complete, t, Type) + LISTdo( complete, t, Type ) /* if t\'s underlying type is not already in newlist, */ - if(! utype_member(newlist, t, 0)) { - LISTadd_last(newlist, t); + if( ! utype_member( newlist, t, 0 ) ) { + LISTadd_last( newlist, t ); } LISTod; @@ -171,10 +165,9 @@ Linked_List SELgetnew_dmlist(const Type type) } -const char *SEL_ITEMget_dmtype(Type t, const Linked_List l) -{ - const char *r = utype_member(l, t, 0); - return StrToLower(r ? r : TYPEget_utype(t)); +const char * SEL_ITEMget_dmtype( Type t, const Linked_List l ) { + const char * r = utype_member( l, t, 0 ); + return StrToLower( r ? r : TYPEget_utype( t ) ); } @@ -183,50 +176,48 @@ const char *SEL_ITEMget_dmtype(Type t, const Linked_List l) * Logical and boolean are handled as exceptions because TYPEget_utype() * returns "PSDAI::..." for them which is not a legal variable name. */ -const char *SEL_ITEMget_dmname(Type t) -{ - Class_Of_Type class = TYPEget_type(t); +const char * SEL_ITEMget_dmname( Type t ) { + Class_Of_Type class = TYPEget_type( t ); - if(class == integer_) { + if( class == integer_ ) { return "integer"; } - if(class == real_) { + if( class == real_ ) { return "real"; } - if(class == number_) { + if( class == number_ ) { return "real"; } - if(class == string_) { + if( class == string_ ) { return "string"; } - if(class == binary_) { + if( class == binary_ ) { return "binary"; } - if(class == logical_) { + if( class == logical_ ) { return "logical"; } - if(class == boolean_) { + if( class == boolean_ ) { return "boolean"; } - if(class == entity_) { + if( class == entity_ ) { return "app_inst"; } - return (StrToLower(TYPEget_utype(t))); + return ( StrToLower( TYPEget_utype( t ) ) ); } /** determines if the given "link's" underlying type is a multiple member of the list. RETURNS 1 if true, else 0. */ -int duplicate_in_express_list(const Linked_List list, const Type check) -{ - if(TYPEis_entity(check)) { +int duplicate_in_express_list( const Linked_List list, const Type check ) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; /* don't compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -239,10 +230,9 @@ int duplicate_in_express_list(const Linked_List list, const Type check) underlying Express type. RETURNS 1 if true, else 0. */ -int unique_types(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_in_express_list(list, t)) { +int unique_types( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_in_express_list( list, t ) ) { return FALSE; } LISTod; @@ -253,30 +243,29 @@ int unique_types(const Linked_List list) /** determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. */ -int duplicate_utype_member(const Linked_List list, const Type check) -{ +int duplicate_utype_member( const Linked_List list, const Type check ) { char b [BUFSIZ]; - if(TYPEis_entity(check)) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; } /* don't compare check to itself */ else { /* continue looking */ - strncpy(b, TYPEget_utype(t), BUFSIZ); - if((!strcmp(b, TYPEget_utype(check))) - || (compareOrigTypes(t, check))) + strncpy( b, TYPEget_utype( t ), BUFSIZ ); + if( ( !strcmp( b, TYPEget_utype( check ) ) ) + || ( compareOrigTypes( t, check ) ) ) /* if the underlying types are the same */ { return TRUE; } - if(! strcmp(b, "SDAI_Integer") && - (! strcmp(TYPEget_utype(check), "SDAI_Real"))) + if( ! strcmp( b, "SDAI_Integer" ) && + ( ! strcmp( TYPEget_utype( check ), "SDAI_Real" ) ) ) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -290,10 +279,9 @@ int duplicate_utype_member(const Linked_List list, const Type check) C++ representation for the underlying Express type. RETURNS 1 if true, else 0. */ -int any_duplicates_in_select(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_utype_member(list, t)) { +int any_duplicates_in_select( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_utype_member( list, t ) ) { return TRUE; } LISTod; @@ -305,25 +293,24 @@ This list is returned as dup_list. If a duplicate exists, the function returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. */ -int find_duplicate_list(const Type type, Linked_List *duplicate_list) -{ +int find_duplicate_list( const Type type, Linked_List * duplicate_list ) { Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if(any_duplicates_in_select(SEL_TYPEget_items(type))) { + if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo(SEL_TYPEget_items(type), u, Type) - if(!utype_member(*duplicate_list, u, 1)) { + LISTdo( SEL_TYPEget_items( type ), u, Type ) + if( !utype_member( *duplicate_list, u, 1 ) ) { /** if not already a duplicate **/ - if(utype_member(temp, u, 1)) { - LISTadd_first(*duplicate_list, u); + if( utype_member( temp, u, 1 ) ) { + LISTadd_first( *duplicate_list, u ); } else { - LISTadd_first(temp, u); + LISTadd_first( temp, u ); } } LISTod; - LISTfree(temp); + LISTfree( temp ); return TRUE; } return FALSE; @@ -351,10 +338,9 @@ enum __types { leaves. It passes around the vector described above, to track paths to the leaf nodes. */ -void non_unique_types_vector(const Type type, int *tvec) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - switch(TYPEget_body(t)->type) { +void non_unique_types_vector( const Type type, int * tvec ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + switch( TYPEget_body( t )->type ) { case integer_: tvec[tint]++; break; @@ -374,7 +360,7 @@ void non_unique_types_vector(const Type type, int *tvec) break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector(t, tvec); + non_unique_types_vector( t, tvec ); break; case entity_: tvec[tentity]++; @@ -390,8 +376,8 @@ void non_unique_types_vector(const Type type, int *tvec) tvec[tnumber]++; break; default: - fprintf(stderr, "non_unique_types_vector: can't handle unknown type %d\n", - TYPEget_body(t)->type); + fprintf( stderr, "non_unique_types_vector: can't handle unknown type %d\n", + TYPEget_body( t )->type ); abort(); } LISTod; @@ -402,60 +388,59 @@ void non_unique_types_vector(const Type type, int *tvec) (FOO_TYPE | BAR_TYPE | BAZ_TYPE), where FOO, BAR, and BAZ are EXPRESS types. If all types are unique, the string (0) is generated. */ -char *non_unique_types_string(const Type type) -{ +char * non_unique_types_string( const Type type ) { int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char *typestr; + char * typestr; int first = 1; int i; - non_unique_types_vector(type, tvec); + non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = (char *)sc_malloc(BUFSIZ); + typestr = ( char * )sc_malloc( BUFSIZ ); typestr[0] = '\0'; - strcat(typestr, (char *)"("); - for(i = 0; i <= tnumber; i++) { - if(tvec[i] < 2) { + strcat( typestr, ( char * )"(" ); + for( i = 0; i <= tnumber; i++ ) { + if( tvec[i] < 2 ) { continue; /* skip, this one is unique */ } - if(!first) { - strcat(typestr, (char *)" | "); + if( !first ) { + strcat( typestr, ( char * )" | " ); } else { first = 0; } - switch(i) { + switch( i ) { case tint : - strcat(typestr, (char *)"sdaiINTEGER"); + strcat( typestr, ( char * )"sdaiINTEGER" ); break; case treal : - strcat(typestr, (char *)"sdaiREAL"); + strcat( typestr, ( char * )"sdaiREAL" ); break; case tstring: - strcat(typestr, (char *)"sdaiSTRING"); + strcat( typestr, ( char * )"sdaiSTRING" ); break; case tbinary: - strcat(typestr, (char *)"sdaiBINARY"); + strcat( typestr, ( char * )"sdaiBINARY" ); break; case tenum : - strcat(typestr, (char *)"sdaiENUMERATION"); + strcat( typestr, ( char * )"sdaiENUMERATION" ); break; case tentity: - strcat(typestr, (char *)"sdaiINSTANCE"); + strcat( typestr, ( char * )"sdaiINSTANCE" ); break; case taggr : - strcat(typestr, (char *)"sdaiAGGR"); + strcat( typestr, ( char * )"sdaiAGGR" ); break; case tnumber: - strcat(typestr, (char *)"sdaiNUMBER"); + strcat( typestr, ( char * )"sdaiNUMBER" ); break; } } - if(first) { - strcat(typestr, (char *)"0"); + if( first ) { + strcat( typestr, ( char * )"0" ); } - strcat(typestr, (char *)")"); + strcat( typestr, ( char * )")" ); return typestr; } @@ -464,20 +449,18 @@ char *non_unique_types_string(const Type type) /** checks to see if an attribute is a member of the list * \returns the attribute 'check' if an attribute with the same name is on the list, 0 otherwise */ -Variable ATTR_LISTmember(Linked_List l, Variable check) -{ +Variable ATTR_LISTmember( Linked_List l, Variable check ) { char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name(check, nm); - LISTdo(l, a, Variable) { - generate_attribute_name(a, cur); - if(! strcmp(nm, cur)) { + generate_attribute_name( check, nm ); + LISTdo( l, a, Variable ) { + generate_attribute_name( a, cur ); + if( ! strcmp( nm, cur ) ) { return check; } - } - LISTod; - return (0); + } LISTod; + return ( 0 ); } @@ -485,241 +468,236 @@ Variable ATTR_LISTmember(Linked_List l, Variable check) * Side Effects: * The list that is returned needs to be freed by the caller. */ -Linked_List SEL_TYPEgetnew_attribute_list(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SEL_TYPEgetnew_attribute_list( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo(complete, t, Type) { - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - attrs = ENTITYget_all_attributes(cur); - LISTdo_n(attrs, a, Variable, b) { - if(! ATTR_LISTmember(newlist, a)) { - LISTadd_first(newlist, a); + LISTdo( complete, t, Type ) { + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + attrs = ENTITYget_all_attributes( cur ); + LISTdo_n( attrs, a, Variable, b ) { + if( ! ATTR_LISTmember( newlist, a ) ) { + LISTadd_first( newlist, a ); } - } - LISTod + } LISTod } - } - LISTod + } LISTod return newlist; } /** prints the class 'definition', that is, the objects * and the constructor(s)/destructor for a select class. */ -void TYPEselect_inc_print_vars(const Type type, FILE *f, Linked_List dups) -{ +void TYPEselect_inc_print_vars( const Type type, FILE * f, Linked_List dups ) { int size, j; - Linked_List data_members = SELgetnew_dmlist(type); + Linked_List data_members = SELgetnew_dmlist( type ); char dmname [BUFSIZ], classnm [BUFSIZ], tdnm [BUFSIZ]; - strncpy(classnm, SelectName(TYPEget_name(type)), BUFSIZ); - classnm[BUFSIZ - 1] = '\0'; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; - size = strlen(classnm) + 2; /* for formatting output */ - - fprintf(f, "\n////////// SELECT TYPE %s\n", SelectName(TYPEget_name(type))); - fprintf(f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm); - fprintf(f, " protected:\n"); - fprintf(f, " // types in SELECT \n"); - LISTdo(SEL_TYPEget_items(type), t, Type) { - fprintf(f, " // %s -- %s\n", SEL_ITEMget_enumtype(t), FundamentalType(t, 0)); + strncpy( classnm, SelectName( TYPEget_name( type ) ), BUFSIZ ); + classnm[BUFSIZ-1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; + size = strlen( classnm ) + 2; /* for formatting output */ + + fprintf( f, "\n////////// SELECT TYPE %s\n", SelectName( TYPEget_name( type ) ) ); + fprintf( f, "class SC_SCHEMA_EXPORT %s : public " BASE_SELECT " {\n", classnm ); + fprintf( f, " protected:\n" ); + fprintf( f, " // types in SELECT \n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + fprintf( f, " // %s -- %s\n", SEL_ITEMget_enumtype( t ), FundamentalType( t, 0 ) ); } LISTod; - LISTdo(data_members, t, Type) { - strncpy(dmname, SEL_ITEMget_dmname(t), BUFSIZ); - fprintf(f, " %s%s _%s;\n", TYPEget_utype(t), TYPEis_aggregate(t) ? "_ptr" : "", dmname); + LISTdo( data_members, t, Type ) { + strncpy( dmname, SEL_ITEMget_dmname( t ), BUFSIZ ); + fprintf( f, " %s%s _%s;\n", TYPEget_utype( t ), TYPEis_aggregate( t ) ? "_ptr" : "", dmname ); } LISTod; - fprintf(f, "\n public:\n"); - fprintf(f, - " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" - " virtual SDAI_Select * NewSelect ();\n" + fprintf( f, "\n public:\n" ); + fprintf( f, + " virtual const TypeDescriptor * AssignEntity (SDAI_Application_instance * se);\n" + " virtual SDAI_Select * NewSelect ();\n" ); - fprintf(f, "\n virtual BASE_TYPE ValueType() const;\n"); + fprintf( f, "\n virtual BASE_TYPE ValueType() const;\n" ); - fprintf(f, "\n\n// STEP Part 21\n"); - fprintf(f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n"); - fprintf(f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" - " const char *currSch =0) const;\n"); - fprintf(f, " virtual Severity STEPread_content (istream& in =cin,\n" - " InstMgrBase * instances =0, const char *utype =0,\n" - " int addFileId =0, const char *currSch =0);\n"); + fprintf( f, "\n\n// STEP Part 21\n" ); + fprintf( f, " virtual void STEPwrite_content (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n" ); + fprintf( f, " virtual void STEPwrite_verbose (ostream& out =std::cout,\n" + " const char *currSch =0) const;\n" ); + fprintf( f, " virtual Severity STEPread_content (istream& in =cin,\n" + " InstMgrBase * instances =0, const char *utype =0,\n" + " int addFileId =0, const char *currSch =0);\n" ); /* read StrToVal_content */ - fprintf(f, " virtual Severity StrToVal_content " - "(const char *,\n InstMgrBase * instances =0);\n"); + fprintf( f, " virtual Severity StrToVal_content " + "(const char *,\n InstMgrBase * instances =0);\n" ); /* constructor(s) */ - fprintf(f, "\n// STEP Part 22: SDAI\n"); - fprintf(f, "\n// constructors\n"); - fprintf(f, " %s( const SelectTypeDescriptor * =%s );\n", - classnm, tdnm); + fprintf( f, "\n// STEP Part 22: SDAI\n" ); + fprintf( f, "\n// constructors\n" ); + fprintf( f, " %s( const SelectTypeDescriptor * =%s );\n", + classnm, tdnm ); - fprintf(f, " // part 1\n"); + fprintf( f, " // part 1\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " %s( const %s&,\n ", - SelectName(TYPEget_name(type)), AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, " %s( const %s&,\n ", + SelectName( TYPEget_name( type ) ), AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); + fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); } LISTod; - LISTdo(dups, t, Type) - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, " %s( const %s&,\n ", - SelectName(TYPEget_name(type)), - isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + LISTdo( dups, t, Type ) + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, " %s( const %s&,\n ", + SelectName( TYPEget_name( type ) ), + isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor * =%s );\n", tdnm); + fprintf( f, "const SelectTypeDescriptor * =%s );\n", tdnm ); } LISTod; /* destructor */ - fprintf(f, " virtual ~%s();\n", classnm); - LISTfree(data_members); + fprintf( f, " virtual ~%s();\n", classnm ); + LISTfree( data_members ); } /** * TYPEselect_inc_print prints the class member function declarations of a select * class. */ -void TYPEselect_inc_print(const Type type, FILE *f) -{ +void TYPEselect_inc_print( const Type type, FILE * f ) { char n[BUFSIZ]; /* class name */ char tdnm [BUFSIZ]; /* TypeDescriptor name */ Linked_List dups; int dup_result; Linked_List attrs; - dup_result = find_duplicate_list(type, &dups); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - TYPEselect_inc_print_vars(type, f, dups); + dup_result = find_duplicate_list( type, &dups ); + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + TYPEselect_inc_print_vars( type, f, dups ); - fprintf(f, "\n // part 2\n"); + fprintf( f, "\n // part 2\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " operator %s();\n", AccessType(t)); + fprintf( f, " operator %s();\n", AccessType( t ) ); } LISTod; - LISTdo(dups, t, Type) + LISTdo( dups, t, Type ) /* do the dups once only */ - if(! TYPEis_entity(t)) /* entities were done already */ - fprintf(f, " operator %s ();\n", - (TYPEis_aggregate(t) || TYPEis_select(t)) ? - AccessType(t) : TYPEget_utype(t)); + if( ! TYPEis_entity( t ) ) /* entities were done already */ + fprintf( f, " operator %s ();\n", + ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? + AccessType( t ) : TYPEget_utype( t ) ); LISTod; - fprintf(f, "\n // part 3\n"); - attrs = SEL_TYPEgetnew_attribute_list(type); + fprintf( f, "\n // part 3\n" ); + attrs = SEL_TYPEgetnew_attribute_list( type ); /* get the list of unique attributes from the entity items */ - LISTdo(attrs, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { - ATTRsign_access_methods(a, f); + LISTdo( attrs, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { + ATTRsign_access_methods( a, f ); } LISTod; - LISTfree(attrs); + LISTfree( attrs ); - fprintf(f, "\n // part 4\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { + fprintf( f, "\n // part 4\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { /** if an entity or not in the dup list **/ - fprintf(f, " %s& operator =( const %s& );\n", - SelectName(TYPEget_name(type)), AccessType(t)); + fprintf( f, " %s& operator =( const %s& );\n", + SelectName( TYPEget_name( type ) ), AccessType( t ) ); } LISTod; - LISTdo(dups, t, Type) - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, " %s& operator =( const %s& );\n", - SelectName(TYPEget_name(type)), - isAggregateType(t) ? AccessType(t) : TYPEget_utype(t)); + LISTdo( dups, t, Type ) + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, " %s& operator =( const %s& );\n", + SelectName( TYPEget_name( type ) ), + isAggregateType( t ) ? AccessType( t ) : TYPEget_utype( t ) ); } LISTod; - fprintf(f, " // not in SDAI\n" - " %s& ShallowCopy ( const %s& );\n", - n, n); + fprintf( f, " // not in SDAI\n" + " %s& ShallowCopy ( const %s& );\n", + n, n ); - fprintf(f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n"); - fprintf(f, " %s& operator =( %s * const & );\n", n, n); - fprintf(f, " SDAI_Select& operator =( const SDAI_Select& );\n"); - fprintf(f, "#endif\n"); + fprintf( f, "\n#ifdef COMPILER_DEFINES_OPERATOR_EQ\n#else\n" ); + fprintf( f, " %s& operator =( %s * const & );\n", n, n ); + fprintf( f, " SDAI_Select& operator =( const SDAI_Select& );\n" ); + fprintf( f, "#endif\n" ); - fprintf(f, "\n // part 5\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - fprintf(f, " Logical Is%s() const;\n", - FirstToUpper(TYPEget_name(t))); + fprintf( f, "\n // part 5\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + fprintf( f, " Logical Is%s() const;\n", + FirstToUpper( TYPEget_name( t ) ) ); LISTod; - fprintf(f, "\n // part 6 ... UnderlyingTypeName () implemented in" - " SDAI_Select class ...\n"); + fprintf( f, "\n // part 6 ... UnderlyingTypeName () implemented in" + " SDAI_Select class ...\n" ); - if(dup_result) { + if( dup_result ) { /** if there are duplicate underlying types **/ - fprintf(f, "\n // part 7\n"); - fprintf(f, " const TypeDescriptor *" - "SetUnderlyingType ( const TypeDescriptor * td );\n"); + fprintf( f, "\n // part 7\n" ); + fprintf( f, " const TypeDescriptor *" + "SetUnderlyingType ( const TypeDescriptor * td );\n" ); } else { - fprintf(f, "\n // part 7 ... NONE only for complex selects...\n"); + fprintf( f, "\n // part 7 ... NONE only for complex selects...\n" ); } #ifdef PART8 - fprintf(f, "\n // part 8\n"); - fprintf(f, " %s* operator->();\n", n); + fprintf( f, "\n // part 8\n" ); + fprintf( f, " %s* operator->();\n", n ); #endif - fprintf(f, "};\n"); + fprintf( f, "};\n" ); - fprintf(f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n); + fprintf( f, "\ninline SDAI_Select * create_%s () { return new %s; }\n", n, n ); /* DAR - moved from SCOPEPrint() */ - fprintf(f, "typedef %s * %sH;\n", n, n); - fprintf(f, "typedef %s_ptr %s_var;\n\n", n, n); + fprintf( f, "typedef %s * %sH;\n", n, n ); + fprintf( f, "typedef %s_ptr %s_var;\n\n", n, n ); /* print things for aggregate class */ - fprintf(f, "\nclass %s_agg : public SelectAggregate {\n", n); - fprintf(f, " protected:\n"); - fprintf(f, " SelectTypeDescriptor *sel_type;\n\n"); - fprintf(f, " public:\n"); - fprintf(f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm); - fprintf(f, " ~%s_agg();\n", n); - fprintf(f, " virtual SingleLinkNode * NewNode()\n"); - fprintf(f, " { return new SelectNode (new %s( sel_type )); }\n", n); - fprintf(f, "};\n"); + fprintf( f, "\nclass %s_agg : public SelectAggregate {\n", n ); + fprintf( f, " protected:\n" ); + fprintf( f, " SelectTypeDescriptor *sel_type;\n\n" ); + fprintf( f, " public:\n" ); + fprintf( f, " %s_agg( SelectTypeDescriptor * =%s );\n", n, tdnm ); + fprintf( f, " ~%s_agg();\n", n ); + fprintf( f, " virtual SingleLinkNode * NewNode()\n" ); + fprintf( f, " { return new SelectNode (new %s( sel_type )); }\n", n ); + fprintf( f, "};\n" ); /* DAS creation function for select aggregate class */ - fprintf(f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", - n, n); + fprintf( f, "inline STEPaggregate * create_%s_agg () { return new %s_agg; }\n", + n, n ); - fprintf(f, "typedef %s_agg_ptr %s_agg_var;\n", n, n); + fprintf( f, "typedef %s_agg_ptr %s_agg_var;\n", n, n ); - fprintf(f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name(type)); + fprintf( f, "\n///// END SELECT TYPE %s\n\n", TYPEget_name( type ) ); - LISTfree(dups); + LISTfree( dups ); } @@ -727,172 +705,166 @@ void TYPEselect_inc_print(const Type type, FILE *f) * TYPEselect_lib_print_part_one prints constructor(s)/destructor of a select * class. */ -void TYPEselect_lib_print_part_one(const Type type, FILE *f, - Linked_List dups, char *n) -{ +void TYPEselect_lib_print_part_one( const Type type, FILE * f, + Linked_List dups, char * n ) { #define schema_name SCHEMAget_name(schema) char tdnm[BUFSIZ], nm[BUFSIZ]; - int size = strlen(n) * 2 + 4, j; /* size - for formatting output */ + int size = strlen( n ) * 2 + 4, j; /* size - for formatting output */ - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - strncpy(nm, SelectName(TYPEget_name(type)), BUFSIZ); + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + strncpy( nm, SelectName( TYPEget_name( type ) ), BUFSIZ ); /* constructor(s) */ /* null constructor */ - fprintf(f, "\n// STEP Part 22: SDAI\n"); - fprintf(f, "\n // part 0\n"); - fprintf(f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n); - fprintf(f, " : " BASE_SELECT " (typedescript)"); + fprintf( f, "\n// STEP Part 22: SDAI\n" ); + fprintf( f, "\n // part 0\n" ); + fprintf( f, "%s::%s( const SelectTypeDescriptor *typedescript )\n", n, n ); + fprintf( f, " : " BASE_SELECT " (typedescript)" ); /* Initialize the select members with their correct typedescriptors: */ - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); /* create objects for data member pointers. also in two more ctors below, and deleted in dtor which is printed at end of this function. */ - LISTdo(dups, t, Type) { - if(isAggregateType(t) && t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + LISTdo( dups, t, Type ) { + if( isAggregateType( t ) && t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - } - LISTod + } LISTod /* above misses some attr's that are initialized in part 1 ctor below. * hopefully this won't add duplicates... */ - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { - if(isAggregateType(t) && (t->u.type->body->base)) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { + if( isAggregateType( t ) && ( t->u.type->body->base ) ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } } - } - LISTod - fprintf(f, " nullify();\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - fprintf(f, "}\n"); + } LISTod + fprintf( f, " nullify();\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, "// *logStream << \"DAVE ERR exiting %s constructor.\" << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + fprintf( f, "}\n" ); /* constructors with underlying types */ - fprintf(f, "\n // part 1\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { + fprintf( f, "\n // part 1\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { /* if there is not more than one underlying type that maps to the same * base type print out the constructor using the type from the TYPE * statement as the underlying type. Also skip enums/sels which are * renames of other items. That would create redundant constructors * since renames are typedef'ed to the original type. */ - fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } /* Did this for the heck of it, and to show how easy it would have been to make it all pretty - DAR. ;-) */ - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - - fprintf(f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); - fprintf(f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n); - fprintf(f, "#endif\n"); - - if(isAggregateType(t)) { - if(t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + + fprintf( f, " : " BASE_SELECT " (typedescript, %s)", TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); + fprintf( f, "*logStream << \"DAVE ERR entering %s constructor.\" << std::endl; }\n", n ); + fprintf( f, "#endif\n" ); + + if( isAggregateType( t ) ) { + if( t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : ".")); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream ) { "); - fprintf(f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n); - fprintf(f, "#endif\n"); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream ) { " ); + fprintf( f, "*logStream << \"DAVE ERR exiting %s constructor.\" << std::endl; }\n", n ); + fprintf( f, "#endif\n" ); - fprintf(f, "}\n\n"); + fprintf( f, "}\n\n" ); } - } - LISTod - LISTdo(dups, t, Type) { + } LISTod + LISTdo( dups, t, Type ) { /* if there is more than one underlying type that maps to the * same base type, print a constructor using the base type. */ - if(! TYPEis_entity(t)) { /* entities were done already */ - if(isAggregateType(t)) { - fprintf(f, "%s::%s( const %s& o,\n", n, n, AccessType(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + if( isAggregateType( t ) ) { + fprintf( f, "%s::%s( const %s& o,\n", n, n, AccessType( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\"" - " << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - if(t->u.type->body->base) { - fprintf(f, " _%s = new %s;\n", SEL_ITEMget_dmname(t), TYPEget_utype(t)); + " << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + if( t->u.type->body->base ) { + fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); } - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype(t)); - for(j = 0; j < size; j++) { - fprintf(f, " "); + fprintf( f, "%s::%s( const %s& o,\n", n, n, TYPEget_utype( t ) ); + for( j = 0; j < size; j++ ) { + fprintf( f, " " ); } - fprintf(f, "const SelectTypeDescriptor *typedescript )\n"); - fprintf(f, " : " BASE_SELECT " ( typedescript, %s )", - TYPEtd_name(t)); - initSelItems(type, f); - fprintf(f, "\n{\n"); - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, "const SelectTypeDescriptor *typedescript )\n" ); + fprintf( f, " : " BASE_SELECT " ( typedescript, %s )", + TYPEtd_name( t ) ); + initSelItems( type, f ); + fprintf( f, "\n{\n" ); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, + fprintf( f, "// NOTE: Underlying type defaults to %s instead of NULL\n", - TYPEtd_name(t)); - fprintf(f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n"); - fprintf(f, + TYPEtd_name( t ) ); + fprintf( f, "#ifdef SC_LOGGING\n if( *logStream )\n {\n" ); + fprintf( f, "// *logStream << \"DAVE ERR exiting %s constructor.\"" - " << std::endl;\n", n); - fprintf(f, " }\n#endif\n"); - fprintf(f, "}\n\n"); + " << std::endl;\n", n ); + fprintf( f, " }\n#endif\n" ); + fprintf( f, "}\n\n" ); } - } - LISTod + } LISTod /* dtor */ - fprintf(f, "%s::~%s() {\n", n, n); + fprintf( f, "%s::~%s() {\n", n, n ); /* delete objects that data members point to */ - LISTdo(dups, t, Type) { - if(isAggregateType(t) && t->u.type->body->base) { - fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); - fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); - fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); + LISTdo( dups, t, Type ) { + if( isAggregateType( t ) && t->u.type->body->base ) { + fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); } } LISTod; - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) || (!utype_member(dups, t, 1))) { - if(isAggregateType(t) && (t->u.type->body->base)) { - fprintf(f, " if( _%s ) {\n", SEL_ITEMget_dmname(t)); - fprintf(f, " delete _%s;\n", SEL_ITEMget_dmname(t)); - fprintf(f, " _%s = 0;\n }\n", SEL_ITEMget_dmname(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { + if( isAggregateType( t ) && ( t->u.type->body->base ) ) { + fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " delete _%s;\n", SEL_ITEMget_dmname( t ) ); + fprintf( f, " _%s = 0;\n }\n", SEL_ITEMget_dmname( t ) ); } } - } - LISTod + } LISTod - fprintf(f, "}\n\n"); + fprintf( f, "}\n\n" ); - fprintf(f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" - " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n); - fprintf(f, "%s_agg::~%s_agg() { }\n\n", n, n); + fprintf( f, "%s_agg::%s_agg( SelectTypeDescriptor *s)\n" + " : SelectAggregate(), sel_type(s)\n{\n}\n\n", n, n ); + fprintf( f, "%s_agg::~%s_agg() { }\n\n", n, n ); #undef schema_name } @@ -902,57 +874,54 @@ void TYPEselect_lib_print_part_one(const Type type, FILE *f, * renaming of another select ("TYPE selB = selA") its td would default to * selA's, so it must be set specifically. */ -static void initSelItems(const Type type, FILE *f) -{ - Linked_List data_members = SELgetnew_dmlist(type); - - LISTdo(data_members, t, Type) - if(TYPEis_select(t)) { - fprintf(f, ",\n _%s (%s)", SEL_ITEMget_dmname(t), - TYPEtd_name(t)); +static void initSelItems( const Type type, FILE * f ) { + Linked_List data_members = SELgetnew_dmlist( type ); + + LISTdo( data_members, t, Type ) + if( TYPEis_select( t ) ) { + fprintf( f, ",\n _%s (%s)", SEL_ITEMget_dmname( t ), + TYPEtd_name( t ) ); } LISTod; } -Linked_List ENTITYget_expanded_entities(Entity e, Linked_List l) -{ +Linked_List ENTITYget_expanded_entities( Entity e, Linked_List l ) { Linked_List supers; Entity super; - if(! LISTmember(l, e)) { - LISTadd_first(l, e); + if( ! LISTmember( l, e ) ) { + LISTadd_first( l, e ); } - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - supers = ENTITYget_supertypes(e); - LISTdo(supers, s, Entity) + supers = ENTITYget_supertypes( e ); + LISTdo( supers, s, Entity ) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if(super_cnt == 0) { - ENTITYget_expanded_entities(s, l); + if( super_cnt == 0 ) { + ENTITYget_expanded_entities( s, l ); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass(e); - ENTITYget_expanded_entities(super, l); + super = ENTITYget_superclass( e ); + ENTITYget_expanded_entities( super, l ); } return l; } -Linked_List SELget_entity_itemlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +Linked_List SELget_entity_itemlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - ENTITYget_expanded_entities(cur, newlist); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + ENTITYget_expanded_entities( cur, newlist ); } LISTod; return newlist; @@ -965,37 +934,35 @@ Linked_List SELget_entity_itemlist(const Type type) * to its primary path (is its own attr, that of its first super, that of * its first super's first super etc), and does necessary housekeeping. */ -static int memberOfEntPrimary(Entity ent, Variable uattr) -{ +static int memberOfEntPrimary( Entity ent, Variable uattr ) { Linked_List attrlist = LISTcreate(); int result; - ENTITYget_first_attribs(ent, attrlist); - result = (LISTmember(attrlist, uattr) != 0); - LIST_destroy(attrlist); + ENTITYget_first_attribs( ent, attrlist ); + result = ( LISTmember( attrlist, uattr ) != 0 ); + LIST_destroy( attrlist ); return result; } -void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, const char *attrnm, const char *utype, char *uent, char *funcnm, - Linked_List items, Variable a, Variable uattr, Entity ent, FILE *f, bool returnConst) -{ +void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, const char * attrnm, const char * utype, char * uent, char * funcnm, + Linked_List items, Variable a, Variable uattr, Entity ent, FILE * f, bool returnConst ) { /* return a const value? */ - const char *constStr = "const "; - const char *constReturn = (returnConst ? constStr : ""); + const char * constStr = "const "; + const char * constReturn = ( returnConst ? constStr : "" ); /* method can be const or non-const? */ - bool notAlwaysConst = attrIsObj(VARget_type(a)); + bool notAlwaysConst = attrIsObj( VARget_type( a ) ); - ATTRprint_access_methods_get_head(classnm, a, f, returnConst); + ATTRprint_access_methods_get_head( classnm, a, f, returnConst ); /* if there will not be const and non-const getters, then this method should be const */ - fprintf(f, "%s{\n", (notAlwaysConst ? constReturn : constStr)); + fprintf( f, "%s{\n", ( notAlwaysConst ? constReturn : constStr ) ); - LISTdo(items, t, Type) { - if(TYPEis_entity(t) && (uattr = ENTITYget_named_attribute( - (ent = ENT_TYPEget_entity(t)), (char *) StrToLower(attrnm)))) { + LISTdo( items, t, Type ) { + if( TYPEis_entity( t ) && ( uattr = ENTITYget_named_attribute( + ( ent = ENT_TYPEget_entity( t ) ), ( char * ) StrToLower( attrnm ) ) ) ) { /* for the select items which have the current attribute */ - if(!multiple_inheritance) { - if(!memberOfEntPrimary(ent, uattr)) { + if( !multiple_inheritance ) { + if( !memberOfEntPrimary( ent, uattr ) ) { /* If multiple inheritance is not supported, we must additionally check * that uattr is a member of the entity's primary inheritance path * (i.e., the entity, its first supertype, the super's first super, @@ -1005,43 +972,42 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons continue; } } - if(! VARis_derived(uattr)) { + if( ! VARis_derived( uattr ) ) { - if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { + if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { /* check to make sure the underlying attribute\'s type is * the same as the current attribute. */ - strncpy(uent, TYPEget_ctype(t), BUFSIZ); + strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); /* if the underlying type is that item's type, call the underlying_item's * member function if it is the same attribute */ - if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { + if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { /* update attribute_func_name because is has been overridden */ - generate_attribute_func_name(uattr, funcnm); + generate_attribute_func_name( uattr, funcnm ); } else { - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); } - fprintf(f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name(t), StrToUpper(TYPEget_name(t))); - fprintf(f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname(t), funcnm); + fprintf( f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", + TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); + fprintf( f, " return ((%s%s) _%s) ->%s();\n", constReturn, uent, SEL_ITEMget_dmname( t ), funcnm ); } else { /* types are not the same issue a warning */ - fprintf(stderr, - "WARNING: in SELECT TYPE %s: ambiguous " - "attribute \"%s\" from underlying type \"%s\".\n\n", - TYPEget_name(type), attrnm, TYPEget_name(t)); - fprintf(f, " // %s\n // attribute access function" - " has a different return type\n", - StrToUpper(TYPEget_name(t))); + fprintf( stderr, + "WARNING: in SELECT TYPE %s: ambiguous " + "attribute \"%s\" from underlying type \"%s\".\n\n", + TYPEget_name( type ), attrnm, TYPEget_name( t ) ); + fprintf( f, " // %s\n // attribute access function" + " has a different return type\n", + StrToUpper( TYPEget_name( t ) ) ); } } else /* derived attributes */ - fprintf(f, " // for %s attribute is derived\n", - StrToUpper(TYPEget_name(t))); - } - } - LISTod; + fprintf( f, " // for %s attribute is derived\n", + StrToUpper( TYPEget_name( t ) ) ); + } + } LISTod; PRINT_BUG_REPORT /* If the return type is an enumeration class then you can\'t @@ -1060,18 +1026,18 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons */ /* EnumName (TYPEget_name (VARget_type (a)))*/ - switch(TYPEget_body(VARget_type(a)) -> type) { + switch( TYPEget_body( VARget_type( a ) ) -> type ) { case enumeration_: - fprintf(f, " return (%s) 0;\n}\n\n", EnumName(TYPEget_name(VARget_type(a)))); + fprintf( f, " return (%s) 0;\n}\n\n", EnumName( TYPEget_name( VARget_type( a ) ) ) ); break; case boolean_: - fprintf(f, " return (Boolean) 0;\n}\n\n"); + fprintf( f, " return (Boolean) 0;\n}\n\n" ); break; case logical_: - fprintf(f, " return (Logical) 0;\n}\n\n"); + fprintf( f, " return (Logical) 0;\n}\n\n" ); break; default: - fprintf(f, " return 0;\n}\n\n"); + fprintf( f, " return 0;\n}\n\n" ); } } @@ -1080,67 +1046,63 @@ void TYPEselect_lib_part_three_getter(const Type type, const char *classnm, cons * a select class -- access functions for the data members of underlying entity * types. */ -void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) -{ +void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm ) { #define ENTITYget_type(e) ((e)->u.entity->type) char uent[BUFSIZ], /* name of underlying entity type */ utype[BUFSIZ], /* underlying type name */ attrnm [BUFSIZ], /* attribute name -> data member = _attrnm */ funcnm[BUFSIZ]; /* access function name = Attrnm */ - Linked_List items = SEL_TYPEget_items(type); + Linked_List items = SEL_TYPEget_items( type ); /* all the items in the select type */ - Linked_List attrs = SEL_TYPEgetnew_attribute_list(type); + Linked_List attrs = SEL_TYPEgetnew_attribute_list( type ); /* list of attributes with unique names */ Entity ent = NULL; Variable uattr = NULL; /* attribute in underlying type */ - fprintf(f, "\n // part 3\n"); + fprintf( f, "\n // part 3\n" ); /* go through all the unique attributes */ - LISTdo_n(attrs, a, Variable, b) { + LISTdo_n( attrs, a, Variable, b ) { bool putVarIsUsed = false; /* used to suppress unused var warning */ - if(VARget_initializer(a) == EXPRESSION_NULL) { + if( VARget_initializer( a ) == EXPRESSION_NULL ) { /* only do for explicit attributes */ - generate_attribute_func_name(a, funcnm); - generate_attribute_name(a, attrnm); + generate_attribute_func_name( a, funcnm ); + generate_attribute_name( a, attrnm ); /* strncpy (funcnm, attrnm, BUFSIZ); funcnm [0] = toupper (funcnm[0]); */ /* use the ctype since utype will be the same for all entities */ - strncpy(utype, TYPEget_ctype(VARget_type(a)), BUFSIZ); + strncpy( utype, TYPEget_ctype( VARget_type( a ) ), BUFSIZ ); /* get methods */ - TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false); - /* TODO - This isn't good enough - the compiler warning Wignored-qualifiers is picking up - * a lot of spurious const expressions coming from these outputs. Not sure of the pattern - * yet, but it looks like not all attrIsObj entities should be using it. */ - if(attrIsObj(VARget_type(a))) { - TYPEselect_lib_part_three_getter(type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true); + TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, false ); + if( attrIsObj( VARget_type( a ) ) ) { + TYPEselect_lib_part_three_getter( type, classnm, attrnm, utype, uent, funcnm, items, a, uattr, ent, f, true ); } /* put method */ - ATTRprint_access_methods_put_head(classnm, a, f); - fprintf(f, "{\n"); - LISTdo(items, t, Type) { - if(TYPEis_entity(t) && - (uattr = ENTITYget_named_attribute( - (ent = ENT_TYPEget_entity(t)), - (char *) StrToLower(attrnm)))) + ATTRprint_access_methods_put_head( classnm, a, f ); + fprintf( f, "{\n" ); + LISTdo( items, t, Type ) { + if( TYPEis_entity( t ) && + ( uattr = ENTITYget_named_attribute( + ( ent = ENT_TYPEget_entity( t ) ), + ( char * ) StrToLower( attrnm ) ) ) ) { /* for the select items which have the current attribute */ - if(!multiple_inheritance) { - if(!memberOfEntPrimary(ent, uattr)) { + if( !multiple_inheritance ) { + if( !memberOfEntPrimary( ent, uattr ) ) { /* See note for similar code segment in 1st part of fn. */ continue; } } - if(! VARis_derived(uattr)) { + if( ! VARis_derived( uattr ) ) { - if(!strcmp(utype, TYPEget_ctype(VARget_type(uattr)))) { + if( !strcmp( utype, TYPEget_ctype( VARget_type( uattr ) ) ) ) { /* check to make sure the underlying attribute\'s type is the same as the current attribute. */ @@ -1148,218 +1110,209 @@ void TYPEselect_lib_print_part_three(const Type type, FILE *f, char *classnm) /* if the underlying type is that item\'s type call the underlying_item\'s member function */ /* if it is the same attribute */ - if(VARis_overrider(ENT_TYPEget_entity(t), uattr)) { + if( VARis_overrider( ENT_TYPEget_entity( t ), uattr ) ) { /* update attribute_func_name because is has been overrid */ - generate_attribute_func_name(uattr, funcnm); + generate_attribute_func_name( uattr, funcnm ); } else { - generate_attribute_func_name(a, funcnm); + generate_attribute_func_name( a, funcnm ); } - strncpy(uent, TYPEget_ctype(t), BUFSIZ); - fprintf(f, + strncpy( uent, TYPEget_ctype( t ), BUFSIZ ); + fprintf( f, " if( CurrentUnderlyingType () == %s ) \n // %s\n", - TYPEtd_name(t), StrToUpper(TYPEget_name(t))); - fprintf(f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", - uent, SEL_ITEMget_dmname(t), funcnm); + TYPEtd_name( t ), StrToUpper( TYPEget_name( t ) ) ); + fprintf( f, " { ((%s) _%s) ->%s( x );\n return;\n }\n", + uent, SEL_ITEMget_dmname( t ), funcnm ); putVarIsUsed = true; } else { /* warning printed above */ - fprintf(f, " // for %s attribute access function" + fprintf( f, " // for %s attribute access function" " has a different argument type\n", - SEL_ITEMget_enumtype(t)); + SEL_ITEMget_enumtype( t ) ); } } else { /* derived attributes */ - fprintf(f, " // for %s attribute is derived\n", - SEL_ITEMget_enumtype(t)); + fprintf( f, " // for %s attribute is derived\n", + SEL_ITEMget_enumtype( t ) ); } } - } - LISTod; - if(!putVarIsUsed) { + } LISTod; + if( !putVarIsUsed ) { fprintf(f, " (void) x; //suppress unused var warning\n"); } - PRINT_SELECTBUG_WARNING(f); - fprintf(f, "}\n"); + PRINT_SELECTBUG_WARNING( f ); + fprintf( f, "}\n" ); } - } - LISTod; - LISTfree(attrs); + } LISTod; + LISTfree( attrs ); } /** * TYPEselect_lib_print_part_four prints part 4 of the SDAI document of a select class. */ -void TYPEselect_lib_print_part_four(const Type type, FILE *f, Linked_List dups, char *n) -{ +void TYPEselect_lib_print_part_four( const Type type, FILE * f, Linked_List dups, char * n ) { char x[BUFSIZ]; - fprintf(f, "\n // part 4\n"); + fprintf( f, "\n // part 4\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if((TYPEis_entity(t)) - || (!utype_member(dups, t, 1))) { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n" + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( ( TYPEis_entity( t ) ) + || ( !utype_member( dups, t, 1 ) ) ) { + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n" " nullify ();\n", - n, n, AccessType(t)); + n, n, AccessType( t ) ); - if(isAggregateType(t)) { - fprintf(f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : ".")); + if( isAggregateType( t ) ) { + fprintf( f, " _%s%sShallowCopy( *o );\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, " SetUnderlyingType( %s );\n", TYPEtd_name(t)); - fprintf(f, " return *this;\n}\n\n"); + fprintf( f, " SetUnderlyingType( %s );\n", TYPEtd_name( t ) ); + fprintf( f, " return *this;\n}\n\n" ); } - } - LISTod - LISTdo(dups, t, Type) { - if(! TYPEis_entity(t)) { /* entities were done already */ - if(isAggregateType(t)) { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, AccessType(t)); - fprintf(f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname(t), ((t->u.type->body->base) ? "->" : ".")); + } LISTod + LISTdo( dups, t, Type ) { + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + if( isAggregateType( t ) ) { + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, AccessType( t ) ); + fprintf( f, " _%s%sShallowCopy (*o);\n", SEL_ITEMget_dmname( t ), ( ( t->u.type->body->base ) ? "->" : "." ) ); } else { - fprintf(f, "%s& %s::operator =( const %s& o )\n{\n", - n, n, TYPEget_utype(t)); - fprintf(f, " _%s = o;\n", SEL_ITEMget_dmname(t)); + fprintf( f, "%s& %s::operator =( const %s& o )\n{\n", + n, n, TYPEget_utype( t ) ); + fprintf( f, " _%s = o;\n", SEL_ITEMget_dmname( t ) ); } - fprintf(f, " underlying_type = 0; // MUST BE SET BY USER\n"); - fprintf(f, " // discriminator = UNSET\n"); - fprintf(f, " return *this;\n}\n"); + fprintf( f, " underlying_type = 0; // MUST BE SET BY USER\n" ); + fprintf( f, " // discriminator = UNSET\n" ); + fprintf( f, " return *this;\n}\n" ); } - } - LISTod - - fprintf(f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n"); - fprintf(f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n); - fprintf(f, " SDAI_Select::operator=( *o );\n"); - - LISTdo(SEL_TYPEget_items(type), t, Type) { - strncpy(x, TYPEget_name(t), BUFSIZ); - fprintf(f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name(t)); - if(TYPEis_select(t)) { - if(utype_member(dups, t, 1)) + } LISTod + + fprintf( f, "\n#ifndef COMPILER_DEFINES_OPERATOR_EQ\n\n" ); + fprintf( f, "%s& %s::operator =( const %s_ptr& o ) {\n", n, n, n ); + fprintf( f, " SDAI_Select::operator=( *o );\n"); + + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + strncpy( x, TYPEget_name( t ), BUFSIZ ); + fprintf( f, " if ( o -> CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name( t ) ); + if( TYPEis_select( t ) ) { + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname(t), - StrToLower(TYPEget_utype(t))); + fprintf( f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname( t ), + StrToLower( TYPEget_utype( t ) ) ); else - fprintf(f, " _%s = &( o -> _%s );\n", - SEL_ITEMget_dmname(t), - SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = &( o -> _%s );\n", + SEL_ITEMget_dmname( t ), + SEL_ITEMget_dmname( t ) ); } else { - if(utype_member(dups, t, 1)) { + if( utype_member( dups, t, 1 ) ) { /** if in the dup list **/ - fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); - /* I changed this although I'm not sure how the if and else differ */ - /* StrToLower(TYPEget_utype(t)) ); */ + fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); + /* I changed this although I'm not sure how the if and else differ */ + /* StrToLower(TYPEget_utype(t)) ); */ } else { - fprintf(f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname(t), SEL_ITEMget_dmname(t)); + fprintf( f, " _%s = o -> _%s;\n", SEL_ITEMget_dmname( t ), SEL_ITEMget_dmname( t ) ); } } - fprintf(f, " return *this;\n"); - fprintf(f, " }\n"); - } - LISTod; - fprintf(f, " return *this;\n}\n\n"); - - fprintf(f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n); - fprintf(f, " SDAI_Select::operator=( o );\n"); - - LISTdo(SEL_TYPEget_items(type), t, Type) { - strncpy(x, TYPEget_name(t), BUFSIZ); - x[BUFSIZ - 1] = '\0'; - fprintf(f, " if ( o.CurrentUnderlyingType() == %s ) {\n", - TYPEtd_name(t)); - if(TYPEis_select(t)) { - if(utype_member(dups, t, 1)) + fprintf( f, " return *this;\n" ); + fprintf( f, " }\n" ); + } LISTod; + fprintf( f, " return *this;\n}\n\n" ); + + fprintf( f, "SDAI_Select& %s::operator =( const SDAI_Select& o ) {\n", n ); + fprintf( f, " SDAI_Select::operator=( o );\n"); + + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + strncpy( x, TYPEget_name( t ), BUFSIZ ); + x[BUFSIZ-1] = '\0'; + fprintf( f, " if ( o.CurrentUnderlyingType() == %s ) {\n", + TYPEtd_name( t ) ); + if( TYPEis_select( t ) ) { + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); else - fprintf(f, " _%s = &( ( ( %s& ) o )._%s );\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = &( ( ( %s& ) o )._%s );\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); } else { - if(utype_member(dups, t, 1)) + if( utype_member( dups, t, 1 ) ) /** if in the dup list **/ - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); else - fprintf(f, " _%s = ( ( %s& ) o )._%s;\n", - SEL_ITEMget_dmname(t), + fprintf( f, " _%s = ( ( %s& ) o )._%s;\n", + SEL_ITEMget_dmname( t ), n, - SEL_ITEMget_dmname(t)); + SEL_ITEMget_dmname( t ) ); } - fprintf(f, " return *this;\n"); - fprintf(f, " }\n"); - } - LISTod - fprintf(f, " return *this;\n}\n\n"); - fprintf(f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n"); + fprintf( f, " return *this;\n" ); + fprintf( f, " }\n" ); + } LISTod + fprintf( f, " return *this;\n}\n\n" ); + fprintf( f, "#endif //ndef COMPILER_DEFINES_OPERATOR_EQ\n" ); } /** * TYPEselect_init_print prints the types that belong to the select type */ -void TYPEselect_init_print(const Type type, FILE *f) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - - fprintf(f, " %s -> Elements ().AddNode", - TYPEtd_name(type)); - fprintf(f, " (%s);\n", - TYPEtd_name(t)); +void TYPEselect_init_print( const Type type, FILE * f ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + + fprintf( f, " %s -> Elements ().AddNode", + TYPEtd_name( type ) ); + fprintf( f, " (%s);\n", + TYPEtd_name( t ) ); LISTod; } -void TYPEselect_lib_part21(const Type type, FILE *f) -{ +void TYPEselect_lib_part21( const Type type, FILE * f ) { char n[BUFSIZ]; /* pointers to class name(s) */ - const char *dm; /* data member name */ - Linked_List data_members = SELgetnew_dmlist(type); + const char * dm; /* data member name */ + Linked_List data_members = SELgetnew_dmlist( type ); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - n[BUFSIZ - 1] = '\0'; + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + n[BUFSIZ-1] = '\0'; - fprintf(f, "\n\n// STEP Part 21\n"); + fprintf( f, "\n\n// STEP Part 21\n" ); /* write part 21 */ - fprintf(f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" - " currSch) const {\n (void)currSch;\n ", n); + fprintf( f, "\nvoid\n%s::STEPwrite_content (ostream& out, const char *" + " currSch) const {\n (void)currSch;\n ", n ); /* go through the items */ - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); - fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name(t)); + fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { - /* if it\'s a number, just print it */ + /* if it\'s a number, just print it */ case integer_: - fprintf(f, " out << _%s;\n", dm); + fprintf( f, " out << _%s;\n", dm ); break; case number_: case real_: - fprintf(f, " WriteReal(_%s,out);\n", dm); + fprintf( f, " WriteReal(_%s,out);\n", dm ); break; case entity_: - fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); + fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); break; case string_: @@ -1368,11 +1321,11 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case boolean_: case binary_: /* for string's, enum's, select's, and binary's it'll be embedded */ - fprintf(f, " _%s.STEPwrite (out);\n", dm); + fprintf( f, " _%s.STEPwrite (out);\n", dm ); break; case select_: - fprintf(f, " _%s.STEPwrite (out, currSch);\n", dm); + fprintf( f, " _%s.STEPwrite (out, currSch);\n", dm ); /* Select type needs currSch passed too. A Select writes the name of its current choice when it writes itself out (e.g. "DATA(33.5)"). Since the current choice name may depend on our current schema (it may be a @@ -1380,7 +1333,7 @@ void TYPEselect_lib_part21(const Type type, FILE *f) */ break; - /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ + /* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */ case aggregate_: case array_: case bag_: @@ -1388,88 +1341,88 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case list_: default: /* otherwise it\'s a pointer */ - fprintf(f, " _%s -> STEPwrite (out);\n", dm); + fprintf( f, " _%s -> STEPwrite (out);\n", dm ); break; } - fprintf(f, " return;\n"); - fprintf(f, " }\n"); + fprintf( f, " return;\n" ); + fprintf( f, " }\n" ); LISTod; PRINT_BUG_REPORT - fprintf(f, "}\n"); + fprintf( f, "}\n" ); /* ValueType() -- get type of value stored in select */ - fprintf(f, "\nBASE_TYPE\n%s::ValueType() const {\n", n); + fprintf( f, "\nBASE_TYPE\n%s::ValueType() const {\n", n ); - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); - fprintf(f, " if (CurrentUnderlyingType() == %s)\n", - TYPEtd_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); + fprintf( f, " if (CurrentUnderlyingType() == %s)\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case select_: - fprintf(f, " return _%s.ValueType();\n", dm); + fprintf( f, " return _%s.ValueType();\n", dm ); break; default: - fprintf(f, " return %s;\n", FundamentalType(t, 0)); + fprintf( f, " return %s;\n", FundamentalType( t, 0 ) ); } LISTod; PRINT_BUG_REPORT - fprintf(f, " return (BASE_TYPE)0;\n}\n"); + fprintf( f, " return (BASE_TYPE)0;\n}\n" ); /* STEPwrite_verbose() -- print value with specified type */ - fprintf(f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," - " const char *currSch) const\n{\n", n); + fprintf( f, "\nvoid\n%s::STEPwrite_verbose (ostream& out," + " const char *currSch) const\n{\n", n ); /* Get name of typedescriptor, according to value of currSch: */ - fprintf(f, " const TypeDescriptor *td = CurrentUnderlyingType();\n"); - fprintf(f, " std::string tmp;\n\n"); - fprintf(f, " if ( td ) {\n"); - fprintf(f, " // If we have a legal underlying type, get its name acc\n"); - fprintf(f, " // to the current schema.\n"); - fprintf(f, " StrToUpper( td->Name(currSch), tmp );\n"); - fprintf(f, " }\n"); + fprintf( f, " const TypeDescriptor *td = CurrentUnderlyingType();\n" ); + fprintf( f, " std::string tmp;\n\n" ); + fprintf( f, " if ( td ) {\n" ); + fprintf( f, " // If we have a legal underlying type, get its name acc\n" ); + fprintf( f, " // to the current schema.\n" ); + fprintf( f, " StrToUpper( td->Name(currSch), tmp );\n" ); + fprintf( f, " }\n" ); /* Next loop through the possible items: */ - LISTdo(SEL_TYPEget_items(type), t, Type) - dm = SEL_ITEMget_dmname(t); - fprintf(f, " if (td == %s) {\n", - TYPEtd_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + dm = SEL_ITEMget_dmname( t ); + fprintf( f, " if (td == %s) {\n", + TYPEtd_name( t ) ); - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: /* fprintf(f, " out << \"%s(\" << _%s << \")\";\n else ", StrToUpper(TYPEget_name(t)), dm);*/ - fprintf(f, " out << tmp << \"(\" << _%s << \")\";\n", - dm); + fprintf( f, " out << tmp << \"(\" << _%s << \")\";\n", + dm ); break; case real_: case number_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " WriteReal(_%s,out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " WriteReal(_%s,out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case entity_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s -> STEPwrite_reference (out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s -> STEPwrite_reference (out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case string_: case enumeration_: case logical_: case boolean_: case binary_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s.STEPwrite (out);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s.STEPwrite (out);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; case aggregate_: case array_: @@ -1477,78 +1430,78 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case set_: case list_: /* Aggregates need currSch passed since they may be aggrs of sels. */ - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s%sSTEPwrite (out, currSch);\n", dm, - ((t->u.type->body->base) ? "->" : ".")); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s%sSTEPwrite (out, currSch);\n", dm, + ( ( t->u.type->body->base ) ? "->" : "." ) ); + fprintf( f, " out << \")\";\n" ); break; case select_: - fprintf(f, " out << tmp << \"(\";\n"); - fprintf(f, " _%s.STEPwrite_verbose (out, currSch);\n", dm); - fprintf(f, " out << \")\";\n"); + fprintf( f, " out << tmp << \"(\";\n" ); + fprintf( f, " _%s.STEPwrite_verbose (out, currSch);\n", dm ); + fprintf( f, " out << \")\";\n" ); break; default: - fprintf(f, " _%s -> STEPwrite (out); \n", dm); + fprintf( f, " _%s -> STEPwrite (out); \n", dm ); break; } - fprintf(f, " return;\n"); - fprintf(f, " }\n"); + fprintf( f, " return;\n" ); + fprintf( f, " }\n" ); LISTod; PRINT_BUG_REPORT - fprintf(f, " return;\n}\n"); + fprintf( f, " return;\n}\n" ); /* Read part 21 */ - fprintf(f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" - " const char *utype, int addFileId, const char *currSch)\n{\n" - " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n); + fprintf( f, "\nSeverity\n%s::STEPread_content (istream& in, InstMgrBase * instances,\n" + " const char *utype, int addFileId, const char *currSch)\n{\n" + " (void)instances;\n (void)utype;\n (void)addFileId;\n (void)currSch;\n ", n ); /* go through the items */ - LISTdo(SEL_TYPEget_items(type), t, Type) + LISTdo( SEL_TYPEget_items( type ), t, Type ) - fprintf(f, " if (CurrentUnderlyingType () == %s) {\n", - TYPEtd_name(t)); + fprintf( f, " if (CurrentUnderlyingType () == %s) {\n", + TYPEtd_name( t ) ); - dm = SEL_ITEMget_dmname(t); + dm = SEL_ITEMget_dmname( t ); - switch(TYPEget_body(t)->type) { - /* if it's a number, just read it */ + switch( TYPEget_body( t )->type ) { + /* if it's a number, just read it */ case real_: case number_: /* since REAL and NUMBER are handled the same they both need to be included in the case stmt */ - fprintf(f, - " ReadReal (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm); + fprintf( f, + " ReadReal (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm ); break; case integer_: - fprintf(f, - " ReadInteger (_%s, in, &_error, \"),\");\n" - " return severity ();\n", - dm); + fprintf( f, + " ReadInteger (_%s, in, &_error, \"),\");\n" + " return severity ();\n", + dm ); break; case entity_: /* if it's an entity, use Assign - done in Select class */ - fprintf(f, - " // set Underlying Type in Select class\n" - " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm); - fprintf(f, - " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " - " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" - " return severity();\n", dm, dm, dm); - fprintf(f, - " } else {\n " - " Error (\"Reference to instance that is not indicated type\\n\");\n" - " _%s = 0;\n" - " nullify ();\n" - " return severity (SEVERITY_USERMSG);\n" - " }\n", dm); + fprintf( f, + " // set Underlying Type in Select class\n" + " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm ); + fprintf( f, + " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " + " ( CurrentUnderlyingType()->CanBe( _%s->getEDesc() ) ) ) {\n" + " return severity();\n", dm, dm, dm ); + fprintf( f, + " } else {\n " + " Error (\"Reference to instance that is not indicated type\\n\");\n" + " _%s = 0;\n" + " nullify ();\n" + " return severity (SEVERITY_USERMSG);\n" + " }\n", dm ); break; case string_: @@ -1556,69 +1509,68 @@ void TYPEselect_lib_part21(const Type type, FILE *f) case logical_: case boolean_: case binary_: - fprintf(f, - " _%s.STEPread (in, &_error);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s.STEPread (in, &_error);\n" + " return severity ();\n", + dm ); break; case select_: - fprintf(f, - " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s.STEPread (in, &_error, instances, utype, addFileId, currSch);\n" + " return severity ();\n", + dm ); break; case aggregate_: case array_: case bag_: case set_: case list_: - fprintf(f, - " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" - " instances, addFileId, currSch);\n", - dm, ((t->u.type->body->base) ? "->" : "."), - TYPEtd_name(t)); - fprintf(f, - " return severity ();\n"); + fprintf( f, + " _%s%sSTEPread (in, &_error, %s -> AggrElemTypeDescriptor (),\n" + " instances, addFileId, currSch);\n", + dm, ( ( t->u.type->body->base ) ? "->" : "." ), + TYPEtd_name( t ) ); + fprintf( f, + " return severity ();\n" ); break; default: - fprintf(f, - " _%s -> STEPread (in, &_error, instances, addFileId);\n" - " return severity ();\n", - dm); + fprintf( f, + " _%s -> STEPread (in, &_error, instances, addFileId);\n" + " return severity ();\n", + dm ); break; } - fprintf(f, " }\n"); + fprintf( f, " }\n" ); LISTod; - PRINT_SELECTBUG_WARNING(f) ; + PRINT_SELECTBUG_WARNING( f ) ; - LISTfree(data_members); - fprintf(f, " return severity ();\n}\n"); + LISTfree( data_members ); + fprintf( f, " return severity ();\n}\n" ); } -void TYPEselect_lib_StrToVal(const Type type, FILE *f) -{ +void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { char n[BUFSIZ]; /* pointers to class name */ - Linked_List data_members = SELgetnew_dmlist(type); + Linked_List data_members = SELgetnew_dmlist( type ); int enum_cnt = 0; - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - n[BUFSIZ - 1] = '\0'; + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + n[BUFSIZ-1] = '\0'; /* read StrToVal_content */ - fprintf(f, "\nSeverity\n%s::StrToVal_content " - "(const char * str, InstMgrBase * instances)" - "\n{\n (void)str;\n (void)instances;\n", n); + fprintf( f, "\nSeverity\n%s::StrToVal_content " + "(const char * str, InstMgrBase * instances)" + "\n{\n (void)str;\n (void)instances;\n", n ); - fprintf(f, " switch (base_type) {\n"); - LISTdo(data_members, t, Type) + fprintf( f, " switch (base_type) {\n" ); + LISTdo( data_members, t, Type ) /* fprintf (f, " case %s : \n", FundamentalType (t, 0));*/ - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case real_: case integer_: @@ -1638,23 +1590,23 @@ void TYPEselect_lib_StrToVal(const Type type, FILE *f) case logical_: case boolean_: case enumeration_: - if(!enum_cnt) { + if( !enum_cnt ) { /* if there\'s more than one enumeration they are done in Select class */ - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s.StrToVal (str, &_error);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s.StrToVal (str, &_error);\n", + SEL_ITEMget_dmname( t ) ); } else { - fprintf(f, " // case %s : done in Select class\n", FundamentalType(t, 0)); + fprintf( f, " // case %s : done in Select class\n", FundamentalType( t, 0 ) ); } ++enum_cnt; break; case string_: - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s.StrToVal (str);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s.StrToVal (str);\n", + SEL_ITEMget_dmname( t ) ); break; case aggregate_: @@ -1662,265 +1614,258 @@ void TYPEselect_lib_StrToVal(const Type type, FILE *f) case bag_: case set_: case list_: - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname(t), - ((t->u.type->body->base) ? "->" : "."), - TYPEtd_name(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, " return _%s%sStrToVal (str, &_error, %s -> AggrElemTypeDescriptor ());\n", SEL_ITEMget_dmname( t ), + ( ( t->u.type->body->base ) ? "->" : "." ), + TYPEtd_name( t ) ); break; default: /* otherwise use StrToVal on the contents to check the format */ - fprintf(f, " case %s : \n", FundamentalType(t, 0)); - fprintf(f, - " return _%s -> StrToVal (str, instances);\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " case %s : \n", FundamentalType( t, 0 ) ); + fprintf( f, + " return _%s -> StrToVal (str, instances);\n", + SEL_ITEMget_dmname( t ) ); } LISTod; - fprintf(f, " default: // should never be here - done in Select class\n"); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, "#ifdef __SUNCPLUSPLUS__\n" - "std::cerr << str << \" \" << instances << std::endl;\n" - "#endif\n"); - fprintf(f, " return SEVERITY_WARNING;\n }\n"); - - LISTfree(data_members); - fprintf(f, - "#ifdef __GNUG__\n" - "\n return SEVERITY_NULL;\n" - "#endif" - "\n}\n"); + fprintf( f, " default: // should never be here - done in Select class\n" ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, "#ifdef __SUNCPLUSPLUS__\n" + "std::cerr << str << \" \" << instances << std::endl;\n" + "#endif\n" ); + fprintf( f, " return SEVERITY_WARNING;\n }\n" ); + + LISTfree( data_members ); + fprintf( f, + "#ifdef __GNUG__\n" + "\n return SEVERITY_NULL;\n" + "#endif" + "\n}\n" ); } -void TYPEselect_lib_virtual(const Type type, FILE *f) -{ - TYPEselect_lib_part21(type, f); - TYPEselect_lib_StrToVal(type, f); +void TYPEselect_lib_virtual( const Type type, FILE * f ) { + TYPEselect_lib_part21( type, f ); + TYPEselect_lib_StrToVal( type, f ); } -void SELlib_print_protected(const Type type, FILE *f) -{ - const char *snm; +void SELlib_print_protected( const Type type, FILE * f ) { + const char * snm; /* SELECT::AssignEntity */ - fprintf(f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" - "{\n (void)se;\n", - SelectName(TYPEget_name(type)) + fprintf( f, "\nconst TypeDescriptor * \n%s::AssignEntity (SDAI_Application_instance * se)\n" + "{\n (void)se;\n", + SelectName( TYPEget_name( type ) ) ); /* loop through the items in the SELECT */ - LISTdo(SEL_TYPEget_items(type), t, Type) - if(TYPEis_entity(t)) { - fprintf(f, - " // %s\n" /* item name */ - " if (se -> IsA (%s))\n" /* td */ - " { \n" - " _%s = (%s_ptr) se;\n" /* underlying data member */ - /* underlying data member type */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper(TYPEget_name(t)), - TYPEtd_name(t), - SEL_ITEMget_dmname(t), - ClassName(TYPEget_name(t)), - TYPEtd_name(t) + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( TYPEis_entity( t ) ) { + fprintf( f, + " // %s\n" /* item name */ + " if (se -> IsA (%s))\n" /* td */ + " { \n" + " _%s = (%s_ptr) se;\n" /* underlying data member */ + /* underlying data member type */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper( TYPEget_name( t ) ), + TYPEtd_name( t ), + SEL_ITEMget_dmname( t ), + ClassName( TYPEget_name( t ) ), + TYPEtd_name( t ) ); } - if(TYPEis_select(t)) { - fprintf(f, - " // %s\n" /* item name */ - " if( %s->CanBe( se->eDesc ) ) {\n" - " _%s.AssignEntity (se);\n" /* underlying data member */ - " return SetUnderlyingType (%s);\n" /* td */ - " }\n", - StrToUpper(TYPEget_name(t)), - TYPEtd_name(t), - SEL_ITEMget_dmname(t), - TYPEtd_name(t) + if( TYPEis_select( t ) ) { + fprintf( f, + " // %s\n" /* item name */ + " if( %s->CanBe( se->getEDesc() ) ) {\n" + " _%s.AssignEntity (se);\n" /* underlying data member */ + " return SetUnderlyingType (%s);\n" /* td */ + " }\n", + StrToUpper( TYPEget_name( t ) ), + TYPEtd_name( t ), + SEL_ITEMget_dmname( t ), + TYPEtd_name( t ) ); } LISTod; - fprintf(f, " // should never be here - done in Select class\n"); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, - "#ifdef __SUNCPLUSPLUS__\n" - " std::cerr << se -> EntityName () << std::endl;\n" - "#endif\n" - " return 0;\n}\n"); + fprintf( f, " // should never be here - done in Select class\n" ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, + "#ifdef __SUNCPLUSPLUS__\n" + " std::cerr << se -> EntityName () << std::endl;\n" + "#endif\n" + " return 0;\n}\n" ); /* SELECT::NewSelect */ - snm = SelectName(TYPEget_name(type)); - fprintf(f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm); + snm = SelectName( TYPEget_name( type ) ); + fprintf( f, "\nSDAI_Select * \n%s::NewSelect ()\n{\n", snm ); - fprintf(f, " %s * tmp = new %s();\n", snm, snm); - fprintf(f, " return tmp;\n}\n"); + fprintf( f, " %s * tmp = new %s();\n", snm, snm ); + fprintf( f, " return tmp;\n}\n" ); } /** * TYPEselect_lib_print prints the member functions (definitions) of a select class. */ -void TYPEselect_lib_print(const Type type, FILE *f) -{ +void TYPEselect_lib_print( const Type type, FILE * f ) { char n[BUFSIZ], m[BUFSIZ]; - const char *z; /* pointers to class name(s) */ + const char * z; /* pointers to class name(s) */ Linked_List dups; int dup_result; - dup_result = find_duplicate_list(type, &dups); - strncpy(n, SelectName(TYPEget_name(type)), BUFSIZ); - fprintf(f, "\n////////// SELECT TYPE %s\n", TYPEget_name(type)); + dup_result = find_duplicate_list( type, &dups ); + strncpy( n, SelectName( TYPEget_name( type ) ), BUFSIZ ); + fprintf( f, "\n////////// SELECT TYPE %s\n", TYPEget_name( type ) ); - SELlib_print_protected(type, f) ; - TYPEselect_lib_virtual(type, f); - TYPEselect_lib_print_part_one(type, f, dups, n); + SELlib_print_protected( type, f ) ; + TYPEselect_lib_virtual( type, f ); + TYPEselect_lib_print_part_one( type, f, dups, n ); - fprintf(f, "\n // part 2\n"); + fprintf( f, "\n // part 2\n" ); - LISTdo(SEL_TYPEget_items(type), t, Type) { - if(TYPEis_entity(t)) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) { + if( TYPEis_entity( t ) ) { /* if an entity */ - fprintf(f, "%s::operator %s_ptr()\n{\n", n, ClassName(TYPEget_name(t))); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return ((%s_ptr) _%s);\n", ClassName(TYPEget_name(t)), SEL_ITEMget_dmname(t)); - PRINT_SELECTBUG_WARNING(f); - fprintf(f, " return NULL;\n}\n\n"); - } else if(!utype_member(dups, t, 1)) { + fprintf( f, "%s::operator %s_ptr()\n{\n", n, ClassName( TYPEget_name( t ) ) ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return ((%s_ptr) _%s);\n", ClassName( TYPEget_name( t ) ), SEL_ITEMget_dmname( t ) ); + PRINT_SELECTBUG_WARNING( f ); + fprintf( f, " return NULL;\n}\n\n" ); + } else if( !utype_member( dups, t, 1 ) ) { /** if not in the dup list **/ - fprintf(f, "%s::operator %s()\n{\n", n, AccessType(t)); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return %s _%s;\n", ((TYPEis_select(t)) ? "&" : ""), SEL_ITEMget_dmname(t)); - fprintf(f, "\n severity( SEVERITY_WARNING );\n"); - fprintf(f, " Error( \"Underlying type is not %s\" );\n", AccessType(t)); - PRINT_SELECTBUG_WARNING(f) ; - if(TYPEis_boolean(t) || TYPEis_logical(t)) { - fprintf(f, " return (%s)0;\n}\n\n", TYPEget_utype(t)); + fprintf( f, "%s::operator %s()\n{\n", n, AccessType( t ) ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return %s _%s;\n", ( ( TYPEis_select( t ) ) ? "&" : "" ), SEL_ITEMget_dmname( t ) ); + fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); + fprintf( f, " Error( \"Underlying type is not %s\" );\n", AccessType( t ) ); + PRINT_SELECTBUG_WARNING( f ) ; + if( TYPEis_boolean( t ) || TYPEis_logical( t ) ) { + fprintf( f, " return (%s)0;\n}\n\n", TYPEget_utype( t ) ); } else { - fprintf(f, " return 0;\n}\n\n"); + fprintf( f, " return 0;\n}\n\n" ); } } - } - LISTod - LISTdo(dups, t, Type) { - if(! TYPEis_entity(t)) { /* entities were done already */ - fprintf(f, "%s::operator %s()\n{\n", n, - (TYPEis_aggregate(t) || TYPEis_select(t)) ? - AccessType(t) : TYPEget_utype(t)); - strncpy(m, TYPEget_utype(t), BUFSIZ); + } LISTod + LISTdo( dups, t, Type ) { + if( ! TYPEis_entity( t ) ) { /* entities were done already */ + fprintf( f, "%s::operator %s()\n{\n", n, + ( TYPEis_aggregate( t ) || TYPEis_select( t ) ) ? + AccessType( t ) : TYPEget_utype( t ) ); + strncpy( m, TYPEget_utype( t ), BUFSIZ ); /**** MUST CHANGE FOR multiple big types ****/ - LISTdo_n(SEL_TYPEget_items(type), x, Type, b) { - if((strcmp(m, TYPEget_utype(x)) == 0) - || (compareOrigTypes(t, x))) { + LISTdo_n( SEL_TYPEget_items( type ), x, Type, b ) { + if( ( strcmp( m, TYPEget_utype( x ) ) == 0 ) + || ( compareOrigTypes( t, x ) ) ) { /* If this is one of the dups. compareOrigTypes checks if x\'s type is a rename of t\'s (see comments there). */ - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", - TYPEtd_name(x)); - fprintf(f, " return %s _%s;\n", - ((TYPEis_select(x)) ? "&" : ""), - SEL_ITEMget_dmname(x)); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", + TYPEtd_name( x ) ); + fprintf( f, " return %s _%s;\n", + ( ( TYPEis_select( x ) ) ? "&" : "" ), + SEL_ITEMget_dmname( x ) ); } - } - LISTod - fprintf(f, "\n severity( SEVERITY_WARNING );\n"); - fprintf(f, " Error( \"Underlying type is not %s\" );\n", - TYPEis_aggregate(t) ? - AccessType(t) : TYPEget_utype(t)); - PRINT_SELECTBUG_WARNING(f) ; - fprintf(f, " return (%s)0;\n}\n\n", - TYPEis_aggregate(t) ? - AccessType(t) : TYPEget_utype(t)); + } LISTod + fprintf( f, "\n severity( SEVERITY_WARNING );\n" ); + fprintf( f, " Error( \"Underlying type is not %s\" );\n", + TYPEis_aggregate( t ) ? + AccessType( t ) : TYPEget_utype( t ) ); + PRINT_SELECTBUG_WARNING( f ) ; + fprintf( f, " return (%s)0;\n}\n\n", + TYPEis_aggregate( t ) ? + AccessType( t ) : TYPEget_utype( t ) ); /* fprintf( f, " return NULL;\n}\n\n" ); */ } - } - LISTod - - TYPEselect_lib_print_part_three(type, f, n); - TYPEselect_lib_print_part_four(type, f, dups, n); - - fprintf(f, "\n // part 5\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - z = FirstToUpper(TYPEget_name(t)); - fprintf(f, "Logical %s::Is%s() const\n{\n", n, z); - fprintf(f, " if( !exists() )\n"); - fprintf(f, " return LUnknown;\n"); - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - fprintf(f, " return LTrue;\n"); - fprintf(f, " return LFalse;\n}\n\n"); + } LISTod + + TYPEselect_lib_print_part_three( type, f, n ); + TYPEselect_lib_print_part_four( type, f, dups, n ); + + fprintf( f, "\n // part 5\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + z = FirstToUpper( TYPEget_name( t ) ); + fprintf( f, "Logical %s::Is%s() const\n{\n", n, z ); + fprintf( f, " if( !exists() )\n" ); + fprintf( f, " return LUnknown;\n" ); + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + fprintf( f, " return LTrue;\n" ); + fprintf( f, " return LFalse;\n}\n\n" ); LISTod; #ifdef UNDERLYINGTYPE - fprintf(f, "\n // part 6\n"); - fprintf(f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n); - fprintf(f, " if( exists() )\n"); - fprintf(f, " {\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - fprintf(f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name(t)); - if(TYPEis_entity(t)) - fprintf(f, " return( _%s->Name() );\n" - StrToLower(TYPEget_name(t))); + fprintf( f, "\n // part 6\n" ); + fprintf( f, "SDAI_String %s::UnderlyingTypeName() const\n{\n", n ); + fprintf( f, " if( exists() )\n" ); + fprintf( f, " {\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + fprintf( f, " if( CurrentUnderlyingType () == %s )\n", TYPEtd_name( t ) ); + if( TYPEis_entity( t ) ) + fprintf( f, " return( _%s->Name() );\n" + StrToLower( TYPEget_name( t ) ) ); else { - fprintf(f, " return( \"%s\" );\n", TYPEget_utype(t)); + fprintf( f, " return( \"%s\" );\n", TYPEget_utype( t ) ); } LISTod; - fprintf(f, " }\n return NULL;\n}\n\n"); - - fprintf(f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n); - fprintf(f, " if( exists() )\n"); - fprintf(f, " {\n"); - LISTdo(SEL_TYPEget_items(type), t, Type) - if(TYPEis_entity(t)) { - fprintf(f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype(t)); - fprintf(f, " return( _%s->eDesc );\n", - SEL_ITEMget_dmname(t)); + fprintf( f, " }\n return NULL;\n}\n\n" ); + + fprintf( f, "const EntityDescriptor * %s::CurrentUnderlyingType()\n{\n", n ); + fprintf( f, " if( exists() )\n" ); + fprintf( f, " {\n" ); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( TYPEis_entity( t ) ) { + fprintf( f, " if( discriminator == %s )\n", SEL_ITEMget_enumtype( t ) ); + fprintf( f, " return( _%s->eDesc );\n", + SEL_ITEMget_dmname( t ) ); } LISTod; - fprintf(f, " }\n return NULL;\n}\n\n"); + fprintf( f, " }\n return NULL;\n}\n\n" ); #endif - if(dup_result) { - fprintf(f, "\n // part 7\n"); - fprintf(f, - "const TypeDescriptor * \n" - "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" - " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", - n); + if( dup_result ) { + fprintf( f, "\n // part 7\n" ); + fprintf( f, + "const TypeDescriptor * \n" + "%s::SetUnderlyingType (const TypeDescriptor * td)\n{\n" + " return " BASE_SELECT "::SetUnderlyingType (td);\n}\n", + n ); } #ifdef PART8 - fprintf(f, "\n // part 8\n"); - fprintf(f, "%s* %s::operator->()\n", n, n); - fprintf(f, "{\n return this;\n}\n"); + fprintf( f, "\n // part 8\n" ); + fprintf( f, "%s* %s::operator->()\n", n, n ); + fprintf( f, "{\n return this;\n}\n" ); #endif - LISTfree(dups); + LISTfree( dups ); - fprintf(f, "////////// END SELECT TYPE %s\n\n", n); + fprintf( f, "////////// END SELECT TYPE %s\n\n", n ); } -void TYPEselect_print(Type t, FILES *files, Schema schema) -{ +void TYPEselect_print( Type t, FILES * files, Schema schema ) { SelectTag tag, tmp; Type i, bt; /* type of elements in an aggregate */ char nm[BUFSIZ], tdnm[BUFSIZ]; - FILE *inc = files->inc; + FILE * inc = files->inc; /* if type is already marked, return */ - if((tmp = (SelectTag) TYPEget_clientData(t))) { - if((tmp ->started) && (! tmp ->complete)) - fprintf(stderr, "WARNING: SELECT type %s causes circular references\n", - TYPEget_name(t)); + if( ( tmp = ( SelectTag ) TYPEget_clientData( t ) ) ) { + if( ( tmp ->started ) && ( ! tmp ->complete ) ) + fprintf( stderr, "WARNING: SELECT type %s causes circular references\n", + TYPEget_name( t ) ); return; } /* mark the type as being processed */ - tag = (SelectTag) sc_malloc(sizeof(struct SelectTag_)); + tag = ( SelectTag ) sc_malloc( sizeof( struct SelectTag_ ) ); tag -> started = 1; tag -> complete = 0; - TYPEput_clientData(t, (ClientData) tag); + TYPEput_clientData( t, ( ClientData ) tag ); /* Check if we're a renamed type, e.g., TYPE B (sel) = A. If so, if A has @@ -1928,48 +1873,48 @@ void TYPEselect_print(Type t, FILES *files, Schema schema) some are printed in files->classes rather than here). If A has not been defined, we must recurse. */ - if((i = TYPEget_ancestor(t)) != NULL) { - if(!TYPEget_clientData(i)) { - TYPEselect_print(i, files, schema); + if( ( i = TYPEget_ancestor( t ) ) != NULL ) { + if( !TYPEget_clientData( i ) ) { + TYPEselect_print( i, files, schema ); } - strncpy(nm, SelectName(TYPEget_name(t)), BUFSIZ); - strncpy(tdnm, TYPEtd_name(t), BUFSIZ); - fprintf(inc, "typedef %s * %sH;\n", nm, nm); - fprintf(inc, "typedef %s_ptr * %s_var;\n", nm, nm); + strncpy( nm, SelectName( TYPEget_name( t ) ), BUFSIZ ); + strncpy( tdnm, TYPEtd_name( t ), BUFSIZ ); + fprintf( inc, "typedef %s * %sH;\n", nm, nm ); + fprintf( inc, "typedef %s_ptr * %s_var;\n", nm, nm ); /* Below are specialized create functions for the renamed sel type (both single and aggregate). The functions call the original sel's con- structor, passing the new sel's typedescriptor to create a hybrid entity - the original select pointing to a new typedesc. These fns give the user an easy way to create the renamed type properly. */ - fprintf(inc, "inline SDAI_Select *\ncreate_%s ()", nm); - fprintf(inc, " { return new %s( %s ); }\n\n", nm, tdnm); - fprintf(inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm); - fprintf(inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm); + fprintf( inc, "inline SDAI_Select *\ncreate_%s ()", nm ); + fprintf( inc, " { return new %s( %s ); }\n\n", nm, tdnm ); + fprintf( inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm ); + fprintf( inc, " { return new %s_agg( %s ); }\n\n", nm, tdnm ); return; } - LISTdo(SEL_TYPEget_items(t), ii, Type) { + LISTdo( SEL_TYPEget_items( t ), ii, Type ) { /* check the items for select types */ /* and do the referenced select types first */ /* check aggregates too */ /* set ii to the bt and catch in next ifs */ - if(isAggregateType(ii)) { - bt = TYPEget_base_type(ii); + if( isAggregateType( ii ) ) { + bt = TYPEget_base_type( ii ); /* DAR - corrected - prev'ly above line retrieved non-aggr base type. But unnec - we only need the item defined if it's a select or a 1D aggregate. If bt is also an aggr, we go on. */ - if(TYPEis_select(bt)) { + if( TYPEis_select( bt ) ) { ii = bt; - } else if(TYPEis_entity(bt)) { + } else if( TYPEis_entity( bt ) ) { ii = bt; } } - if(TYPEis_select(ii) && !TYPEget_clientData(ii)) { - TYPEselect_print(ii, files, schema); + if( TYPEis_select( ii ) && !TYPEget_clientData( ii ) ) { + TYPEselect_print( ii, files, schema ); } /* NOTE - there was a bug here because above if did not take into account that ii came from a different schema (and above loop would have printed @@ -1980,17 +1925,16 @@ void TYPEselect_print(Type t, FILES *files, Schema schema) schema. So the above if will only reorder the printing of the sel's in this schema, which is the intent. DAR */ - } - LISTod + } LISTod - TYPEPrint(t, files, schema); + TYPEPrint(t, files, schema ); /* TYPEselect_inc_print( t, files -> inc ); */ /* TYPEselect_lib_print( t, files -> lib ); */ /* TYPEselect_init_print (t, files -> init, schema); DAR - moved to TYPEprint_init() - to keep init info together. */ tag -> complete = 1; - sc_free(tag); + sc_free( tag ); } #undef BASE_SELECT diff --git a/src/exp2cxx/trynext.cc b/src/exp2cxx/trynext.cc index cb50d2eed..97cacc8a3 100644 --- a/src/exp2cxx/trynext.cc +++ b/src/exp2cxx/trynext.cc @@ -15,10 +15,10 @@ #include // Local function prototypes: -static EntList *firstCandidate(EntList *); -static EntList *nextCandidate(EntList *); +static EntList * firstCandidate( EntList * ); +static EntList * nextCandidate( EntList * ); -MatchType MultList::tryNext(EntNode *ents) +MatchType MultList::tryNext( EntNode * ents ) /* * Loops backwards through the children of this, recursively searching for * alternate solutions (i.e., OR's which have alternate paths we haven't @@ -31,15 +31,15 @@ MatchType MultList::tryNext(EntNode *ents) */ { MatchType retval; - EntList *child = getLast(); + EntList * child = getLast(); - child = firstCandidate(child); - while(child != NULL) { - if((retval = (dynamic_cast< MultList * >(child))->tryNext(ents)) == MATCHALL) { + child = firstCandidate( child ); + while( child != NULL ) { + if( ( retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ) ) == MATCHALL ) { // We're done - a good solution was found. return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // If a new viable choice was found below, we must now reset all // later OR's to their first choice. (That's what acceptChoice() // does when choice = LISTEND.) This is necessary so that we can @@ -47,83 +47,83 @@ MatchType MultList::tryNext(EntNode *ents) // first reset all our children, and then return NEWCHOICE so that // our parent (if exists) will also know to reset all its later OR // children. - while((child = nextCandidate(child)) != NULL) { - if(child->acceptChoice(ents) && ents->allMarked()) { + while( ( child = nextCandidate( child ) ) != NULL ) { + if( child->acceptChoice( ents ) && ents->allMarked() ) { return MATCHALL; } } return NEWCHOICE; } - child = firstCandidate(child->prev); + child = firstCandidate( child->prev ); } // If we got here, we didn't find any new OR choices: return NOMORE; } -static EntList *firstCandidate(EntList *child) +static EntList * firstCandidate( EntList * child ) /* * Finds an EntList from child's list which may have an OR with more * choices below it. The acceptable choices are described in commenting * below. */ { - EntList *ent = child->lastNot(SIMPLE); + EntList * ent = child->lastNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { // Return any non-SIMPLE ent where viable >= MATCHSOME. We even // want to check an OR where numChoices = 1, because it may have // an OR descendant with more choices. return ent; } - ent = ent->prevNot(SIMPLE); + ent = ent->prevNot( SIMPLE ); } return ent; } -static EntList *nextCandidate(EntList *child) +static EntList * nextCandidate( EntList * child ) /* * Same as prev function, searches forwards from ent after child. */ { - EntList *ent = child->nextNot(SIMPLE); + EntList * ent = child->nextNot( SIMPLE ); - while(ent != NULL) { - if(ent->viableVal() >= MATCHSOME) { + while( ent != NULL ) { + if( ent->viableVal() >= MATCHSOME ) { return ent; } - ent = ent->nextNot(SIMPLE); + ent = ent->nextNot( SIMPLE ); } return ent; } -MatchType OrList::tryNext(EntNode *ents) +MatchType OrList::tryNext( EntNode * ents ) /* * Tries out the next choice of this. Basic algorithm is to first recurse * to check for other solutions in the descendants of the current choice, * and then to try our next choice. */ { - EntList *child; + EntList * child; - if(choice == LISTEND) { + if( choice == LISTEND ) { // if we've already exhausted all the choices in this OR, return NOMORE; } // First try other choices of descendants of current choice: - child = getChild(choice); - if(child->multiple()) { - MatchType retval; + child = getChild( choice ); + if( child->multiple() ) { + MatchType retval; // I.e., if there are (or may be) more choices within the current // choice, try those first. We must be sure to exhaust all choices in // our descendants before moving on. - retval = (dynamic_cast< MultList * >(child))->tryNext(ents); - if(retval == MATCHALL) { + retval = ( dynamic_cast< MultList * >(child) )->tryNext( ents ); + if( retval == MATCHALL ) { return MATCHALL; } - if(retval == NEWCHOICE) { + if( retval == NEWCHOICE ) { // I.e., we found a next choice to go to, return so that the // EntLists on the higher levels (if there are) can retry all the // later choices with the new choice we just found. Otherwise, @@ -134,8 +134,8 @@ MatchType OrList::tryNext(EntNode *ents) // No other choices among our descendants. Look for new choice at our // level: - child->unmarkAll(ents); - if(choiceCount == 1) { + child->unmarkAll( ents ); + if( choiceCount == 1 ) { // Quick way to determine that there won't be any more choices here. // (Also, it's nec. to unmark now, as we did above before returning and // before the calling tryNext() tries earlier OR's - see notes, 11/12.) @@ -144,8 +144,8 @@ MatchType OrList::tryNext(EntNode *ents) } // Otherwise, try our next: - if(acceptNextChoice(ents)) { - if(ents->allMarked()) { + if( acceptNextChoice( ents ) ) { + if( ents->allMarked() ) { return MATCHALL; } return NEWCHOICE; diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 1318ec1ed..964aca652 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -14,9 +14,9 @@ #include // Local function prototypes: -static void writeheader(ostream &, int); +static void writeheader( ostream &, int ); -void print_complex(ComplexCollect &collect, const char *filename) +void print_complex( ComplexCollect & collect, const char * filename ) /* * Standalone function called from exp2cxx. Takes a ComplexCollect * and writes its contents to a file (filename) which can be used to @@ -24,19 +24,19 @@ void print_complex(ComplexCollect &collect, const char *filename) */ { #ifdef COMPLEX_INFO - ComplexList *cl; - if(collect.clists) { + ComplexList * cl; + if( collect.clists ) { // If there's something in this collect, print it out: cout << "\nHere's everything:\n"; - for(cl = collect.clists; cl != NULL; cl = cl->next) { + for( cl = collect.clists; cl != NULL; cl = cl->next ) { cout << *cl << endl; } } #endif - collect.write(filename); + collect.write( filename ); } -void ComplexCollect::write(const char *fname) +void ComplexCollect::write( const char * fname ) /* * Generates C++ code in os which may be compiled and run to create a * ComplexCollect structure. Functions are called to write out the @@ -44,22 +44,22 @@ void ComplexCollect::write(const char *fname) */ { ofstream complex; - ComplexList *clist; + ComplexList * clist; int maxlevel, listmax; // Open the stream: - complex.open(fname); - if(!complex) { + complex.open( fname ); + if( !complex ) { cerr << "ERROR: Could not create output file " << fname << endl; // yikes this is pretty drastic, Sun C++ doesn't like this anyway DAS // exit(-1); return; } - writeheader(complex, clists == NULL); + writeheader( complex, clists == NULL ); // If there's nothing in this, make function a stub (very little was // printed in writeheader() also): - if(clists == NULL) { + if( clists == NULL ) { complex << " return 0;" << endl; complex << "}" << endl; complex.close(); @@ -75,9 +75,9 @@ void ComplexCollect::write(const char *fname) // of an array to create. maxlevel = 0; clist = clists; - while(clist) { + while( clist ) { listmax = clist->getEntListMaxLevel(); - if(listmax > maxlevel) { + if( listmax > maxlevel ) { maxlevel = listmax; } clist = clist->next; @@ -88,11 +88,11 @@ void ComplexCollect::write(const char *fname) // Next create the CCollect and CLists: complex << " cc = new ComplexCollect;\n"; clist = clists; - while(clist) { + while( clist ) { complex << endl; complex << " // ComplexList with supertype \"" << clist->supertype() << "\":\n"; - clist->write(complex); + clist->write( complex ); complex << " cc->insert( cl );\n"; clist = clist->next; } @@ -103,14 +103,14 @@ void ComplexCollect::write(const char *fname) complex.close(); } -static void writeheader(ostream &os, int noLists) +static void writeheader( ostream & os, int noLists ) /* * Writes the header for the complex file. */ { // If there are no ComplexLists in the ComplexCollect, make this function // a stub: - if(noLists) { + if( noLists ) { os << "/*" << endl << " * This file normally contains instantiation statements to\n" << " * create complex support structures. For the current EXPRESS\n" @@ -142,39 +142,39 @@ static void writeheader(ostream &os, int noLists) os << "{" << endl; } -void ComplexList::write(ostream &os) +void ComplexList::write( ostream & os ) /* * Generates C++ code in os which will create an instantiation of a CList * which will recreate this. */ { - head->write(os); + head->write( os ); os << " cl = new ComplexList((AndList *)node);\n"; os << " cl->buildList();\n"; os << " cl->head->setLevel( 0 );\n"; } -void MultList::write(ostream &os) +void MultList::write( ostream & os ) /* * Writes to os code to instantiate a replica of this. Does so by first * recursing to replicate this's children, and then instantiating this. * When write() is finished, the "node" variable in os will point to this. */ { - EntList *child = getLast(); + EntList * child = getLast(); // First write our children, from last to first. (We go in backwards order // so that "node" (a variable name in the os) will = our first child when // this loop is done. See below.) - child->write(os); - while(child->prev) { + child->write( os ); + while( child->prev ) { // Whenever an EntList::write() function is called, it writes to os // an instantiation statement basically of the form "node = new XXX- // List;". So we know that in the output file (os) the newly-created // EntList is pointed to by variable node. os << " next[" << level + 1 << "] = node;\n"; child = child->prev; - child->write(os); + child->write( os ); os << " next[" << level + 1 << "]->prev = node;\n"; os << " node->next = next[" << level + 1 << "];\n"; } @@ -186,9 +186,9 @@ void MultList::write(ostream &os) // node. We do this so that node will = this when we're done and return // to the calling function (so the calling fn can make the same assumption // we just did). - if(join == AND) { + if( join == AND ) { os << " node = new AndList;\n"; - } else if(join == ANDOR) { + } else if( join == ANDOR ) { os << " node = new AndOrList;\n"; } else { os << " node = new OrList;\n"; @@ -197,7 +197,7 @@ void MultList::write(ostream &os) // The above line will set node's childList and numchidren count. } -void SimpleList::write(ostream &os) +void SimpleList::write( ostream & os ) /* * Writes to os a statement to instantiate this. */ diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index a9feb39d2..0cbf338aa 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -31,6 +31,9 @@ if(SC_PYTHON_GENERATOR) ) SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(exp2python version_string) + endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) endif(SC_PYTHON_GENERATOR) # Local Variables: diff --git a/src/exp2python/src/classes.h b/src/exp2python/src/classes.h index 715a7e550..a76cb6afa 100644 --- a/src/exp2python/src/classes.h +++ b/src/exp2python/src/classes.h @@ -51,86 +51,86 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define TYPEtd_name(t) TypeDescriptorName (t) typedef struct file_holder { - FILE *inc; /**< include file */ - FILE *lib; /**< library file */ - FILE *incall; /**< include file for collecting all include files */ - FILE *initall; /**< for registering all entities from all schemas */ - FILE *init; /**< contains function to initialize program to use schema's entities */ - FILE *create; /**< DAR - added - to create all schema & ent descriptors. In multiple + FILE * inc; /**< include file */ + FILE * lib; /**< library file */ + FILE * incall; /**< include file for collecting all include files */ + FILE * initall; /**< for registering all entities from all schemas */ + FILE * init; /**< contains function to initialize program to use schema's entities */ + FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple * interrelated schemas, must be done before attribute descriptors and * sub-super links created. */ - FILE *classes; /**< DAR - added - a new .h file to contain declarations of all the + FILE * classes; /**< DAR - added - a new .h file to contain declarations of all the * classes, so that all the .h files can refer any of the entity classes. * Nec. if ent1 of schemaA has attribute ent2 from schemaB. */ - FILE *names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ - FILE *helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for + FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */ + FILE * helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for helper functions to find runtime aggregate bounds */ } File_holder, FILES; /** these fields are used so that ENTITY types are processed in order * when appearing in different schemas */ -typedef struct EntityTag_ *EntityTag; +typedef struct EntityTag_ * EntityTag; struct EntityTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ Entity superclass; /**< the entity being used as the supertype - with multiple inheritance only chose one */ }; -Entity ENTITYget_superclass(Entity entity); -Entity ENTITYput_superclass(Entity entity); -int ENTITYhas_explicit_attributes(Entity e); -void ENTITYget_first_attribs(Entity entity, Linked_List result); +Entity ENTITYget_superclass( Entity entity ); +Entity ENTITYput_superclass( Entity entity ); +int ENTITYhas_explicit_attributes( Entity e ); +void ENTITYget_first_attribs( Entity entity, Linked_List result ); /** these fields are used so that SELECT types are processed in order */ -typedef struct SelectTag_ *SelectTag; +typedef struct SelectTag_ * SelectTag; struct SelectTag_ { unsigned int started : 1; /**< marks the beginning of processing */ unsigned int complete : 1; /**< marks the end of processing */ }; -const char *GetTypeDescriptorName(Type t); -char *format_for_stringout(char *orig_buf, char *return_buf); -void format_for_std_stringout(FILE *f, char *orig_buf); -const char *CheckWord(const char *); -const char *StrToLower(const char *); -const char *StrToUpper(const char *); -const char *FirstToUpper(const char *); -const char *SelectName(const char *); -FILE *FILEcreate(const char *); -void FILEclose(FILE *); -const char *ClassName(const char *); -const char *ENTITYget_classname(Entity); -void FUNCPrint(Function function, FILES *files); -void RULEPrint(Rule rule, FILES *files); -void ENTITYPrint(Entity, FILES *); -const char *StrToConstant(const char *); -void TYPEselect_print(Type, FILES *, Schema); -void ENTITYprint_new(Entity, FILES *, Schema, int); -void TYPEprint_definition(Type, FILES *, Schema); -void TYPEprint_new(const Type, FILE *, Schema); -void TYPEprint_typedefs(Type, FILE *); -void TYPEprint_descriptions(const Type, FILES *, Schema); -void TYPEprint_init(const Type type, FILES *files, Schema schema); -void AGGRprint_init(FILES *files, const Type t, - const char *var_name, const char *aggr_name); -void TYPEselect_init_print(const Type type, FILE *f); -void MODELPrint(Entity, FILES *, Schema, int); -void MODELprint_new(Entity entity, FILES *files); -void MODELPrintConstructorBody(Entity, FILES *, Schema/*, int*/); -const char *PrettyTmpName(const char *oldname); -const char *EnumName(const char *oldname); -const char *TypeDescriptorName(Type); -char *TypeDescription(const Type t); -const char *AccessType(Type t); -const char *TYPEget_ctype(const Type t); -void print_file(Express); -void resolution_success(void); -void SCHEMAprint(Schema schema, FILES *files, int suffix); -Type TYPEget_ancestor(Type t); -const char *FundamentalType(const Type t, int report_reftypes); +const char * GetTypeDescriptorName( Type t ); +char * format_for_stringout( char * orig_buf, char * return_buf ); +void format_for_std_stringout( FILE* f, char* orig_buf ); +const char * CheckWord( const char * ); +const char * StrToLower( const char * ); +const char * StrToUpper( const char * ); +const char * FirstToUpper( const char * ); +const char * SelectName( const char * ); +FILE * FILEcreate( const char * ); +void FILEclose( FILE * ); +const char * ClassName( const char * ); +const char * ENTITYget_classname( Entity ); +void FUNCPrint( Function function, FILES* files ); +void RULEPrint( Rule rule, FILES* files ); +void ENTITYPrint( Entity, FILES * ); +const char * StrToConstant( const char * ); +void TYPEselect_print( Type, FILES *, Schema ); +void ENTITYprint_new( Entity, FILES *, Schema, int ); +void TYPEprint_definition( Type, FILES *, Schema ); +void TYPEprint_new( const Type, FILE *, Schema ); +void TYPEprint_typedefs( Type, FILE * ); +void TYPEprint_descriptions( const Type, FILES *, Schema ); +void TYPEprint_init( const Type type, FILES * files, Schema schema ); +void AGGRprint_init( FILES * files, const Type t, + const char * var_name, const char * aggr_name ); +void TYPEselect_init_print( const Type type, FILE* f ); +void MODELPrint( Entity, FILES *, Schema, int ); +void MODELprint_new( Entity entity, FILES* files ); +void MODELPrintConstructorBody( Entity, FILES *, Schema/*, int*/ ); +const char * PrettyTmpName( const char * oldname ); +const char * EnumName( const char * oldname ); +const char * TypeDescriptorName( Type ); +char * TypeDescription( const Type t ); +const char * AccessType( Type t ); +const char * TYPEget_ctype( const Type t ); +void print_file( Express ); +void resolution_success( void ); +void SCHEMAprint( Schema schema, FILES* files, int suffix ); +Type TYPEget_ancestor( Type t ); +const char * FundamentalType( const Type t, int report_reftypes ); /*Variable*/ #define VARis_simple_explicit(a) (!VARis_type_shifter(a)) @@ -138,12 +138,12 @@ const char *FundamentalType(const Type t, int report_reftypes); /*Variable*/ #define VARis_simple_derived(a) (!VARis_overrider(a)) -Variable VARis_overrider(Entity e, Variable a); +Variable VARis_overrider( Entity e, Variable a ); /* Added for multiple schema support: */ -void print_schemas_separate(Express, FILES *); -void getMCPrint(Express, FILE *, FILE *); -int sameSchema(Scope, Scope); +void print_schemas_separate( Express, FILES * ); +void getMCPrint( Express, FILE *, FILE * ); +int sameSchema( Scope, Scope ); #endif diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 0420b74d9..a425f0d88 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -1,7 +1,5 @@ #define CLASSES_MISC_C -#define _POSIX_C_SOURCE 200809L /* for strdup */ #include -#include #include "classes.h" /******************************************************************* ** FedEx parser output module for generating C++ class definitions @@ -36,12 +34,11 @@ extern int multiple_inheritance; ** Status: started 12/1 ******************************************************************/ const char * -CheckWord(const char *word) -{ +CheckWord( const char * word ) { #ifdef NOT_USING_SDAI_BINDING /* obsolete with proposed c++ binding */ - static char *reserved_words [] = { + static char * reserved_words [] = { "application_marker", "asm", "attributes", "auto", "break", "case", "char", "class", "const", "continue", "default", "delete", "do", "double", @@ -55,30 +52,30 @@ CheckWord(const char *word) "union", "unsigned", "val", "virtual", "void", "volatile" }; - int nwords = (sizeof reserved_words / sizeof reserved_words[0]); + int nwords = ( sizeof reserved_words / sizeof reserved_words[0] ); int cond, i, low = 0, high = nwords - 1; /* word is obviously not in list, if it is longer than any of the words in the list */ - if(strlen(word) > 18) { - return (word); + if( strlen( word ) > 18 ) { + return ( word ); } - while(low <= high) { - i = (low + high) / 2; - if((cond = strcmp(word, reserved_words [i])) < 0) { + while( low <= high ) { + i = ( low + high ) / 2; + if( ( cond = strcmp( word, reserved_words [i] ) ) < 0 ) { high = i - 1; - } else if(cond > 0) { + } else if( cond > 0 ) { low = i + 1; } else { /* word is a reserved word, capitalize it */ - fprintf(stderr, "Warning: reserved word %s capitalized\n", word); - *word = toupper(*word); + fprintf( stderr, "Warning: reserved word %s capitalized\n", word ); + *word = toupper( *word ); } } #endif - return (word); + return ( word ); } @@ -94,255 +91,239 @@ CheckWord(const char *word) ******************************************************************/ char -ToLower(char c) -{ - if(isupper(c)) { - return (tolower(c)); +ToLower( char c ) { + if( isupper( c ) ) { + return ( tolower( c ) ); } else { - return (c); + return ( c ); } } char -ToUpper(char c) -{ - if(islower(c)) { - return (toupper(c)); +ToUpper( char c ) { + if( islower( c ) ) { + return ( toupper( c ) ); } else { - return (c); + return ( c ); } } const char * -StrToLower(const char *word) -{ +StrToLower( const char * word ) { static char newword [MAX_LEN]; int i = 0; - if(!word) { + if( !word ) { return 0; } - while(word [i] != '\0') { - newword [i] = ToLower(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToLower( word [i] ); ++i; } newword [i] = '\0'; - return (newword) ; + return ( newword ) ; } -const char *StrToUpper(const char *word) -{ +const char * StrToUpper( const char * word ) { static char newword [MAX_LEN]; int i = 0; - char ToUpper(char c); + char ToUpper( char c ); - while(word [i] != '\0') { - newword [i] = ToUpper(word [i]); + while( word [i] != '\0' ) { + newword [i] = ToUpper( word [i] ); ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } -const char *StrToConstant(const char *word) -{ +const char * StrToConstant( const char * word ) { static char newword [MAX_LEN]; int i = 0; - while(word [i] != '\0') { - if(word [i] == '/' || word [i] == '.') { + while( word [i] != '\0' ) { + if( word [i] == '/' || word [i] == '.' ) { newword [i] = '_'; } else { - newword [i] = ToUpper(word [i]); + newword [i] = ToUpper( word [i] ); } ++i; } newword [i] = '\0'; - return (newword); + return ( newword ); } /** creates a file for python */ -FILE *FILEcreate(const char *filename) -{ - FILE *file; +FILE * FILEcreate( const char * filename ) { + FILE * file; - if((file = fopen(filename, "w")) == NULL) { - fprintf(stderr, "Error in SCHEMAprint: unable to create file %s\n", filename); - return (NULL); + if( ( file = fopen( filename, "w" ) ) == NULL ) { + fprintf( stderr, "Error in SCHEMAprint: unable to create file %s\n", filename ); + return ( NULL ); } - fprintf(file, "# This file was generated by exp2python. You probably don't want to edit\n"); - fprintf(file, "# it since your modifications will be lost if exp2python is used to\n"); - fprintf(file, "# regenerate it.\n"); - return (file); + fprintf( file, "# This file was generated by exp2python. You probably don't want to edit\n" ); + fprintf( file, "# it since your modifications will be lost if exp2python is used to\n" ); + fprintf( file, "# regenerate it.\n" ); + return ( file ); } /** closes a file opened with FILEcreate */ -void FILEclose(FILE *file) -{ - fclose(file); +void FILEclose( FILE * file ) { + fclose( file ); } /** indicates whether the attribute is an aggregate */ -int isAggregate(Variable a) -{ - return(TYPEinherits_from(VARget_type(a), aggregate_)); +int isAggregate( Variable a ) { + return( TYPEinherits_from( VARget_type( a ), aggregate_ ) ); } /** indicates whether the type is an aggregate type */ -int isAggregateType(const Type t) -{ - return(TYPEinherits_from(t, aggregate_)); +int isAggregateType( const Type t ) { + return( TYPEinherits_from( t, aggregate_ ) ); } /** returns temporary copy of name suitable for use as a class name * * each call erases the name created by a previous call to this function */ -const char *ClassName(const char *oldname) -{ +const char * ClassName( const char * oldname ) { int i = 0, j = 0; static char newname [BUFSIZ]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENTITYCLASS_PREFIX) ; - j = strlen(ENTITYCLASS_PREFIX) ; - newname [j] = ToUpper(oldname [i]); + strcpy( newname, ENTITYCLASS_PREFIX ) ; + j = strlen( ENTITYCLASS_PREFIX ) ; + newname [j] = ToUpper( oldname [i] ); ++i; ++j; - while(oldname [i] != '\0') { - newname [j] = ToLower(oldname [i]); + while( oldname [i] != '\0' ) { + newname [j] = ToLower( oldname [i] ); ++i; ++j; } newname [j] = '\0'; - return (newname); + return ( newname ); } /** returns the name of the c++ class representing the entity */ -const char *ENTITYget_classname(Entity ent) -{ - const char *oldname = ENTITYget_name(ent); - return (ClassName(oldname)); +const char * ENTITYget_classname( Entity ent ) { + const char * oldname = ENTITYget_name( ent ); + return ( ClassName( oldname ) ); } /** returns a new capitalized name, in internal static buffer */ -const char *PrettyTmpName(const char *oldname) -{ +const char * PrettyTmpName( const char * oldname ) { int i = 0; static char newname [BUFSIZ]; newname [0] = '\0'; - while((oldname [i] != '\0') && (i < BUFSIZ)) { - newname [i] = ToLower(oldname [i]); - if(oldname [i] == '_') { /* character is '_' */ + while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { + newname [i] = ToLower( oldname [i] ); + if( oldname [i] == '_' ) { /* character is '_' */ ++i; - newname [i] = ToUpper(oldname [i]); + newname [i] = ToUpper( oldname [i] ); } - if(oldname [i] != '\0') { + if( oldname [i] != '\0' ) { ++i; } } - newname [0] = ToUpper(oldname [0]); + newname [0] = ToUpper( oldname [0] ); newname [i] = '\0'; return newname; } /** This function is out of date DAS */ -const char *EnumName(const char *oldname) -{ +const char * EnumName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, ENUM_PREFIX) ; - j = strlen(ENUM_PREFIX) ; - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); - j = strlen(newname); + strcpy( newname, ENUM_PREFIX ) ; + j = strlen( ENUM_PREFIX ) ; + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *SelectName(const char *oldname) -{ +const char * SelectName( const char * oldname ) { int j = 0; static char newname [MAX_LEN]; - if(!oldname) { - return (""); + if( !oldname ) { + return ( "" ); } - strcpy(newname, TYPE_PREFIX); - newname [0] = ToUpper(newname [0]); - j = strlen(TYPE_PREFIX); - newname [j] = ToUpper(oldname [0]); - strncpy(newname + j + 1, StrToLower(oldname + 1), MAX_LEN - j); - j = strlen(newname); + strcpy( newname, TYPE_PREFIX ); + newname [0] = ToUpper( newname [0] ); + j = strlen( TYPE_PREFIX ); + newname [j] = ToUpper( oldname [0] ); + strncpy( newname + j + 1, StrToLower( oldname + 1 ), MAX_LEN - j ); + j = strlen( newname ); newname [j] = '\0'; - return (newname); + return ( newname ); } -const char *FirstToUpper(const char *word) -{ +const char * FirstToUpper( const char * word ) { static char newword [MAX_LEN]; - strncpy(newword, word, MAX_LEN); - newword[0] = ToUpper(newword[0]); - return (newword); + strncpy( newword, word, MAX_LEN ); + newword[0] = ToUpper( newword[0] ); + return ( newword ); } /** return fundamental type but as the string which corresponds to * the appropriate type descriptor * if report_reftypes is true, report REFERENCE_TYPE when appropriate */ -const char *FundamentalType(const Type t, int report_reftypes) -{ - if(report_reftypes && TYPEget_head(t)) { - return("REFERENCE_TYPE"); +const char * FundamentalType( const Type t, int report_reftypes ) { + if( report_reftypes && TYPEget_head( t ) ) { + return( "REFERENCE_TYPE" ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case integer_: - return("INTEGER"); + return( "INTEGER" ); case real_: - return("REAL"); + return( "REAL" ); case string_: - return("STRING"); + return( "STRING" ); case binary_: - return("BINARY"); + return( "BINARY" ); case boolean_: - return("BOOLEAN"); + return( "BOOLEAN" ); case logical_: - return("LOGICAL"); + return( "LOGICAL" ); case number_: - return("NUMBER"); + return( "NUMBER" ); case generic_: - return("GENERIC_TYPE"); + return( "GENERIC_TYPE" ); case aggregate_: - return("AGGREGATE_"); + return( "AGGREGATE_" ); case array_: - return("ARRAY_TYPE"); + return( "ARRAY_TYPE" ); case bag_: - return("BAG_TYPE"); + return( "BAG_TYPE" ); case set_: - return("'SET_TYPE not implemented'"); + return( "'SET_TYPE not implemented'" ); case list_: - return("'LIST TYPE Not implemented'"); + return( "'LIST TYPE Not implemented'" ); case entity_: - return("INSTANCE"); + return( "INSTANCE" ); case enumeration_: - return("ENUMERATION"); + return( "ENUMERATION" ); case select_: - return ("SELECT"); + return ( "SELECT" ); default: - return("UNKNOWN_TYPE"); + return( "UNKNOWN_TYPE" ); } } @@ -350,32 +331,30 @@ const char *FundamentalType(const Type t, int report_reftypes) * be a TypeDescriptor or subtype of TypeDescriptor to represent Type t in * the dictionary. */ -const char *TypeDescriptorName(Type t) -{ +const char * TypeDescriptorName( Type t ) { static char b [BUFSIZ]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which ** Type t was defined - which was actually used to create t's name. DAR */ - if(!parent) { - parent = TYPEget_body(t)->entity->superscope; + if( !parent ) { + parent = TYPEget_body( t )->entity->superscope; /* This works in certain cases that don't work otherwise (basically a ** kludge). For some reason types which are really entity choices of ** a select have no superscope value, but their super may be tracked ** by following through the entity they reference, as above. */ } - sprintf(b, "%s%s%s", SCHEMAget_name(parent), TYPEprefix(t), - TYPEget_name(t)); + sprintf( b, "%s%s%s", SCHEMAget_name( parent ), TYPEprefix( t ), + TYPEget_name( t ) ); return b; } /** this gets you the name of the type of TypeDescriptor (or subtype) that a * variable generated to represent Type t would be an instance of. */ -const char *GetTypeDescriptorName(Type t) -{ - switch(TYPEget_body(t)->type) { +const char * GetTypeDescriptorName( Type t ) { + switch( TYPEget_body( t )->type ) { case aggregate_: return "AggrTypeDescriptor"; @@ -410,17 +389,16 @@ const char *GetTypeDescriptorName(Type t) case generic_: return "TypeDescriptor"; default: - fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } } -int ENTITYhas_explicit_attributes(Entity e) -{ - Linked_List l = ENTITYget_attributes(e); +int ENTITYhas_explicit_attributes( Entity e ) { + Linked_List l = ENTITYget_attributes( e ); int cnt = 0; - LISTdo(l, a, Variable) - if(VARget_initializer(a) == EXPRESSION_NULL) { + LISTdo( l, a, Variable ) + if( VARget_initializer( a ) == EXPRESSION_NULL ) { ++cnt; } LISTod; @@ -428,22 +406,21 @@ int ENTITYhas_explicit_attributes(Entity e) } -Entity ENTITYput_superclass(Entity entity) -{ +Entity ENTITYput_superclass( Entity entity ) { #define ENTITYget_type(e) ((e)->u.entity->type) - Linked_List l = ENTITYget_supertypes(entity); + Linked_List l = ENTITYget_supertypes( entity ); EntityTag tag; - if(! LISTempty(l)) { + if( ! LISTempty( l ) ) { Entity super = 0; - if(multiple_inheritance) { + if( multiple_inheritance ) { Linked_List list = 0; - list = ENTITYget_supertypes(entity); - if(! LISTempty(list)) { + list = ENTITYget_supertypes( entity ); + if( ! LISTempty( list ) ) { /* assign superclass to be the first one on the list of parents */ - super = (Entity)LISTpeek_first(list); + super = ( Entity )LISTpeek_first( list ); } } else { Entity ignore = 0; @@ -451,53 +428,50 @@ Entity ENTITYput_superclass(Entity entity) /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ - LISTdo(l, e, Entity) { + LISTdo( l, e, Entity ) { /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ - if((! super) || (! ENTITYhas_explicit_attributes(super))) { + if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } - if(ignore) { - printf("WARNING: multiple inheritance not implemented.\n"); - printf("\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", - ENTITYget_name(entity), ENTITYget_name(e)); + if( ignore ) { + printf( "WARNING: multiple inheritance not implemented.\n" ); + printf( "\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", + ENTITYget_name( entity ), ENTITYget_name( e ) ); } - } - LISTod + } LISTod } - tag = (EntityTag) malloc(sizeof(struct EntityTag_)); + tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; - TYPEput_clientData(ENTITYget_type(entity), tag); + TYPEput_clientData( ENTITYget_type( entity ), tag ); return super; } return 0; } -Entity ENTITYget_superclass(Entity entity) -{ +Entity ENTITYget_superclass( Entity entity ) { EntityTag tag; - tag = TYPEget_clientData(ENTITYget_type(entity)); - return (tag ? tag -> superclass : 0); + tag = TYPEget_clientData( ENTITYget_type( entity ) ); + return ( tag ? tag -> superclass : 0 ); } -void ENTITYget_first_attribs(Entity entity, Linked_List result) -{ +void ENTITYget_first_attribs( Entity entity, Linked_List result ) { Linked_List supers; - LISTdo(ENTITYget_attributes(entity), attr, void *) - LISTadd_last(result, attr); + LISTdo( ENTITYget_attributes( entity ), attr, void * ) + LISTadd_last( result, attr ); LISTod; - supers = ENTITYget_supertypes(entity); - if(supers) { - ENTITYget_first_attribs((Entity)LISTget_first(supers), result); + supers = ENTITYget_supertypes( entity ); + if( supers ) { + ENTITYget_first_attribs( ( Entity )LISTget_first( supers ), result ); } } @@ -531,35 +505,33 @@ void ENTITYget_first_attribs(Entity entity, Linked_List result) ** // tell it to be * for reading and writing **/ -Variable VARis_type_shifter(Variable a) -{ - char *temp; +Variable VARis_type_shifter( Variable a ) { + char * temp; - if(VARis_derived(a) || VARget_inverse(a)) { + if( VARis_derived( a ) || VARget_inverse( a ) ) { return 0; } - temp = strdup(VARget_name(a)->symbol.name); - if(! strncmp(StrToLower(temp), "self\\", 5)) { + temp = strdup( VARget_name( a )->symbol.name ); + if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - free(temp); + free( temp ); return a; } - free(temp); + free( temp ); return 0; } -Variable VARis_overrider(Entity e, Variable a) -{ +Variable VARis_overrider( Entity e, Variable a ) { Variable other; - char *tmp; + char * tmp; - tmp = VARget_simple_name(a); + tmp = VARget_simple_name( a ); - LISTdo(ENTITYget_supertypes(e), s, Entity) - if((other = ENTITYget_named_attribute(s, tmp)) - && other != a) { + LISTdo( ENTITYget_supertypes( e ), s, Entity ) + if( ( other = ENTITYget_named_attribute( s, tmp ) ) + && other != a ) { return other; } LISTod; @@ -570,16 +542,15 @@ Variable VARis_overrider(Entity e, Variable a) * For a renamed type, returns the original (ancestor) type from which t * descends. Return NULL if t is top level. */ -Type TYPEget_ancestor(Type t) -{ +Type TYPEget_ancestor( Type t ) { Type i = t; - if(!TYPEget_head(i)) { + if( !TYPEget_head( i ) ) { return NULL; } - while(TYPEget_head(i)) { - i = TYPEget_head(i); + while( TYPEget_head( i ) ) { + i = TYPEget_head( i ); } return i; diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index e8d53564d..8c672868a 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -24,10 +24,8 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ -#define _POSIX_C_SOURCE 200809L /* for strdup */ #include #include -#include #include "sc_memmgr.h" #include "classes.h" @@ -51,11 +49,11 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. # define snprintf c99_snprintf #endif -int isAggregateType(const Type t); -int isAggregate(Variable a); -Variable VARis_type_shifter(Variable a); -const char *GetTypeDescriptorName(Type t); -void TYPEselect_lib_print(const Type type, FILE *f); +int isAggregateType( const Type t ); +int isAggregate( Variable a ); +Variable VARis_type_shifter( Variable a ); +const char * GetTypeDescriptorName( Type t ); +void TYPEselect_lib_print( const Type type, FILE * f ); int multiple_inheritance = 1; int print_logging = 0; @@ -76,37 +74,37 @@ int old_accessors = 0; static int attr_count; /* number each attr to avoid inter-entity clashes */ /* static int type_count; NOTE unused / * number each temporary type for same reason above */ -extern int any_duplicates_in_select(const Linked_List list); -extern int unique_types(const Linked_List list); -extern char *non_unique_types_string(const Type type); +extern int any_duplicates_in_select( const Linked_List list ); +extern int unique_types( const Linked_List list ); +extern char * non_unique_types_string( const Type type ); /* static void printEnumCreateHdr( FILE *, const Type ); //NOTE - unused * static void printEnumCreateBody( FILE *, const Type ); * static void printEnumAggrCrHdr( FILE *, const Type ); * static void printEnumAggrCrBody( FILE *, const Type ); */ -void printAccessHookFriend(FILE *, const char *); -void printAccessHookHdr(FILE *, const char *); -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema); -void TypeBody_Description(TypeBody body, char *buf); - -void STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file); -void STATEMENTPrint(Statement s, int indent_level, FILE *file); -void STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file); -void EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file); -void EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); -void EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); -void EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); -void ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file); -void ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file); -void ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file); -void ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file); -void CASEout(struct Case_Statement_ *c, int level, FILE *file); -void LOOPpyout(struct Loop_ *loop, int level, FILE *file); -void WHEREPrint(Linked_List wheres, int level, FILE *file); - -void Type_Description(const Type, char *); - -char *EXPRto_python(Expression e); +void printAccessHookFriend( FILE *, const char * ); +void printAccessHookHdr( FILE *, const char * ); +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ); +void TypeBody_Description( TypeBody body, char * buf ); + +void STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ); +void STATEMENTPrint( Statement s, int indent_level, FILE * file ); +void STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ); +void EXPRESSION__out( Expression e, int paren, Op_Code previous_op , FILE * file ); +void EXPRESSIONop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); +void EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); +void EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); +void ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ); +void ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression * oe, int paren, Op_Code previous_op , FILE * file ); +void ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ); +void ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE* file ); +void CASEout( struct Case_Statement_ *c, int level, FILE * file ); +void LOOPpyout( struct Loop_ *loop, int level, FILE * file ); +void WHEREPrint( Linked_List wheres, int level , FILE * file ); + +void Type_Description( const Type, char * ); + +char * EXPRto_python( Expression e ); /* Turn the string into a new string that will be printed the same as the @@ -114,16 +112,15 @@ original string. That is, turn backslash into a quoted backslash and turn \n into "\n" (i.e. 2 chars). */ -char *format_for_stringout(char *orig_buf, char *return_buf) -{ - char *optr = orig_buf; - char *rptr = return_buf; - while(*optr) { - if(*optr == '\n') { +char * format_for_stringout( char * orig_buf, char * return_buf ) { + char * optr = orig_buf; + char * rptr = return_buf; + while( *optr ) { + if( *optr == '\n' ) { *rptr = '\\'; rptr++; *rptr = 'n'; - } else if(*optr == '\\') { + } else if( *optr == '\\' ) { *rptr = '\\'; rptr++; *rptr = '\\'; @@ -137,61 +134,52 @@ char *format_for_stringout(char *orig_buf, char *return_buf) return return_buf; } -char *strliteral_py_dup(char *orig_buf) -{ - char *new_buf = strdup(orig_buf); - char *tmp = new_buf; +char * strliteral_py_dup( char * orig_buf ) { + char * new_buf = strdup(orig_buf); + char * tmp = new_buf; - while((tmp = strstr(tmp, "\\x9"))) { - tmp++ ; - *tmp = 't'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\x9"))) { + tmp++ ; *tmp = 't'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } tmp = new_buf; - while((tmp = strstr(tmp, "\\xA"))) { - tmp++ ; - *tmp = 'n'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\xA"))) { + tmp++ ; *tmp = 'n'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } tmp = new_buf; - while((tmp = strstr(tmp, "\\xD"))) { - tmp++ ; - *tmp = 'r'; - tmp++; - memmove(tmp, tmp + 1, strlen(tmp)); + while ((tmp = strstr(tmp, "\\xD"))) { + tmp++ ; *tmp = 'r'; tmp++; + memmove(tmp, tmp+1, strlen(tmp)); } - + return new_buf; } -int Handle_FedPlus_Args(int i, char *arg) -{ +int Handle_FedPlus_Args( int i, char * arg ) { (void) arg; /* unused param */ - if(((char)i == 's') || ((char)i == 'S')) { + if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) { multiple_inheritance = 0; } - if(((char)i == 'a') || ((char)i == 'A')) { + if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) { old_accessors = 1; } - if((char)i == 'L') { + if( ( char )i == 'L' ) { print_logging = 1; } return 0; } -bool is_python_keyword(char *word) -{ +bool is_python_keyword( char * word ) { int i; - const char *keyword_list[] = {"class", "pass", NULL}; + const char* keyword_list[] = {"class", "pass", NULL}; bool python_keyword = false; - for(i = 0; keyword_list[i] != NULL; i++) { - if(strcmp(word, keyword_list[i]) == 0) { + for( i = 0; keyword_list[i] != NULL; i++ ) { + if( strcmp( word, keyword_list[i] ) == 0 ) { python_keyword = true; } } @@ -207,48 +195,46 @@ bool is_python_keyword(char *word) ** Status: complete 8/5/93 ******************************************************************/ char * -generate_attribute_name(Variable a, char *out) -{ - char *temp, *p, *q; +generate_attribute_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - Expression name = VARget_name(a); - temp = strdup(EXPget_name(name)); + Expression name = VARget_name( a ); + temp = strdup( EXPget_name( name ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; j < BUFSIZ; p++) { + for( j = 0, q = out; j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's and spaces, convert */ /* '.' to '_', and convert to lowercase. */ - if((*p != '\n') && (*p != ' ')) { - if(*p == '.') { + if( ( *p != '\n' ) && ( *p != ' ' ) ) { + if( *p == '.' ) { *q = '_'; } else { - *q = tolower(*p); + *q = tolower( *p ); } j++; q++; } } - free(temp); + free( temp ); /* python generator : we should prevend an attr name to be a python reserved keyword */ - if(is_python_keyword(out)) { - strcat(out, "_"); + if( is_python_keyword( out ) ) { + strcat( out, "_" ); } return out; } char * -generate_attribute_func_name(Variable a, char *out) -{ - generate_attribute_name(a, out); - strncpy(out, CheckWord(StrToLower(out)), BUFSIZ); - if(old_accessors) { - out[0] = toupper(out[0]); +generate_attribute_func_name( Variable a, char * out ) { + generate_attribute_name( a, out ); + strncpy( out, CheckWord( StrToLower( out ) ), BUFSIZ ); + if( old_accessors ) { + out[0] = toupper( out[0] ); } else { - out[strlen(out)] = '_'; + out[strlen( out )] = '_'; } return out; } @@ -274,29 +260,28 @@ generate_attribute_func_name(Variable a, char *out) ** Status: complete 8/5/93 ******************************************************************/ char * -generate_dict_attr_name(Variable a, char *out) -{ - char *temp, *p, *q; +generate_dict_attr_name( Variable a, char * out ) { + char * temp, *p, *q; int j; - Expression name = VARget_name(a); - temp = strdup(EXPget_name(name)); + Expression name = VARget_name( a ); + temp = strdup( EXPget_name( name ) ); p = temp; - if(! strncmp(StrToLower(p), "self\\", 5)) { + if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) { p = p + 5; } /* copy p to out */ - strncpy(out, StrToLower(p), BUFSIZ); + strncpy( out, StrToLower( p ), BUFSIZ ); /* DAR - fixed so that '\n's removed */ - for(j = 0, q = out; j < BUFSIZ; p++) { + for( j = 0, q = out; j < BUFSIZ; p++ ) { /* copy p to out, 1 char at time. Skip \n's, and convert to lc. */ - if(*p != '\n') { - *q = tolower(*p); + if( *p != '\n' ) { + *q = tolower( *p ); j++; q++; } } - free(temp); + free( temp ); return out; } @@ -331,21 +316,20 @@ generate_dict_attr_name(Variable a, char *out) ** Status: ok 12-Apr-1993 ******************************************************************/ char * -GetAttrTypeName(Type t) -{ - char *attr_type; - if(TYPEis_string(t)) { +GetAttrTypeName( Type t ) { + char * attr_type; + if( TYPEis_string( t ) ) { attr_type = "STRING"; - } else if(TYPEis_logical(t)) { + } else if( TYPEis_logical( t ) ) { attr_type = "LOGICAL"; - } else if(TYPEis_boolean(t)) { + } else if( TYPEis_boolean( t ) ) { attr_type = "BOOLEAN"; - } else if(TYPEis_real(t)) { + } else if( TYPEis_real( t ) ) { attr_type = "REAL"; - } else if(TYPEis_integer(t)) { + } else if( TYPEis_integer( t ) ) { attr_type = "INTEGER"; } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } return attr_type; } @@ -357,20 +341,19 @@ GetAttrTypeName(Type t) */ void -print_aggregate_type(FILE *file, Type t) -{ - switch(TYPEget_body(t)->type) { +print_aggregate_type( FILE * file, Type t ) { + switch( TYPEget_body( t )->type ) { case array_: - fprintf(file, "ARRAY"); + fprintf( file, "ARRAY" ); break; case bag_: - fprintf(file, "BAG"); + fprintf( file, "BAG" ); break; case set_: - fprintf(file, "SET"); + fprintf( file, "SET" ); break; case list_: - fprintf(file, "LIST"); + fprintf( file, "LIST" ); break; default: break; @@ -380,112 +363,111 @@ print_aggregate_type(FILE *file, Type t) #define BIGBUFSIZ 100000 -char *EXPRto_python(Expression e) -{ - char *buf; - char *temp; +char* EXPRto_python( Expression e ) { + char * buf; + char * temp; unsigned int bufsize = BIGBUFSIZ; - buf = (char *)sc_malloc(bufsize); - if(!buf) { - fprintf(stderr, "%s failed to allocate buffer: %s\n", __func__, strerror(errno)); + buf = ( char * )sc_malloc( bufsize ); + if( !buf ) { + fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno) ); abort(); } - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - snprintf(buf, bufsize, "%d", e->u.integer); + snprintf( buf, bufsize, "%d", e->u.integer ); break; case real_: - if(e == LITERAL_PI) { - strcpy(buf, "math.pi"); - } else if(e == LITERAL_E) { - strcpy(buf, "math.e"); + if( e == LITERAL_PI ) { + strcpy( buf, "math.pi" ); + } else if( e == LITERAL_E ) { + strcpy( buf, "math.e" ); } else { - snprintf(buf, bufsize, "%e", e->u.real); + snprintf( buf, bufsize, "%e", e->u.real ); } break; case binary_: - snprintf(buf, bufsize, "%s", e->u.binary); + snprintf( buf, bufsize, "%s", e->u.binary ); break; case logical_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buf, "True"); + strcpy( buf, "True" ); break; case Lfalse: - strcpy(buf, "False"); + strcpy( buf, "False" ); break; default: - strcpy(buf, "None"); + strcpy( buf, "None" ); break; } - break; + break; case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buf, "True"); + strcpy( buf, "True" ); break; case Lfalse: - strcpy(buf, "False"); + strcpy( buf, "False" ); break; } - break; + break; case string_: - if(TYPEis_encoded(e->type)) { - snprintf(buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + snprintf( buf, bufsize, "binascii.unhexlify('%s')", e->symbol.name ); } else { - temp = strliteral_py_dup(e->symbol.name); - strncpy(buf, temp, bufsize); - free(temp); + temp = strliteral_py_dup( e->symbol.name ); + strncpy( buf, temp, bufsize ); + free(temp); } break; case entity_: case identifier_: case attribute_: case enumeration_: - snprintf(buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name); + snprintf( buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: - strcpy(buf, "# query_ NOT_IMPLEMENTED!"); + strcpy( buf, "# query_ NOT_IMPLEMENTED!" ); break; case self_: - strcpy(buf, "self"); - break; - case funcall_: { - int i = 0; - snprintf(buf, bufsize, "%s(", e->symbol.name); - LISTdo(e->u.funcall.list, arg, Expression) { - i++; - if(i != 1) { - strcat(buf, ", "); - } - temp = EXPRto_python(arg); - strcat(buf, temp); - free(temp); - } - LISTod - strcat(buf, ")"); + strcpy( buf, "self" ); break; + case funcall_: + { + int i = 0; + snprintf( buf, bufsize, "%s(", e->symbol.name ); + LISTdo( e->u.funcall.list, arg, Expression ) { + i++; + if( i != 1 ) { + strcat( buf, ", " ); + } + temp = EXPRto_python( arg ); + strcat( buf, temp ); + free( temp ); + } LISTod + strcat( buf, ")" ); + break; } case op_: - strcpy(buf, "# op_ NOT_IMPLEMENTED!"); + strcpy( buf, "# op_ NOT_IMPLEMENTED!" ); break; case aggregate_: - strcpy(buf, "# aggregate_ NOT_IMPLEMENTED!"); + strcpy( buf, "# aggregate_ NOT_IMPLEMENTED!" ); break; case oneof_: { - strcpy(buf, "# oneof_ NOT_IMPLEMENTED!"); + strcpy( buf, "# oneof_ NOT_IMPLEMENTED!" ); break; } default: - fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); + fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); abort(); } - temp = (char *)sc_realloc(buf, 1 + strlen(buf)); - if(temp == 0) { - fprintf(stderr, "%s failed to realloc buffer: %s\n", __func__, strerror(errno)); + temp = ( char * )sc_realloc( buf, 1 + strlen(buf) ); + if( temp == 0 ) { + fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno) ); abort(); } @@ -498,77 +480,73 @@ char *EXPRto_python(Expression e) * */ void -process_aggregate(FILE *file, Type t) -{ - Expression lower = AGGR_TYPEget_lower_limit(t); - char *lower_str = EXPRto_python(lower); - Expression upper = AGGR_TYPEget_upper_limit(t); - char *upper_str = NULL; +process_aggregate( FILE * file, Type t ) { + Expression lower = AGGR_TYPEget_lower_limit( t ); + char * lower_str = EXPRto_python( lower ); + Expression upper = AGGR_TYPEget_upper_limit( t ); + char * upper_str = NULL; Type base_type; - if(upper == LITERAL_INFINITY) { + if( upper == LITERAL_INFINITY ) { upper_str = "None"; } else { - upper_str = EXPRto_python(upper); + upper_str = EXPRto_python( upper ); } - switch(TYPEget_body(t)->type) { + switch( TYPEget_body( t )->type ) { case array_: - fprintf(file, "ARRAY"); + fprintf( file, "ARRAY" ); break; case bag_: - fprintf(file, "BAG"); + fprintf( file, "BAG" ); break; case set_: - fprintf(file, "SET"); + fprintf( file, "SET" ); break; case list_: - fprintf(file, "LIST"); + fprintf( file, "LIST" ); break; default: break; } - fprintf(file, "(%s,%s,", lower_str, upper_str); + fprintf( file, "(%s,%s,", lower_str, upper_str ); /*write base type */ - base_type = TYPEget_base_type(t); - if(TYPEis_aggregate(base_type)) { - process_aggregate(file, base_type); - fprintf(file, ")"); /*close parenthesis */ + base_type = TYPEget_base_type( t ); + if( TYPEis_aggregate( base_type ) ) { + process_aggregate( file, base_type ); + fprintf( file, ")" ); /*close parenthesis */ } else { - char *array_base_type = GetAttrTypeName(TYPEget_base_type(t)); - fprintf(file, "'%s', scope = schema_scope)", array_base_type); + char * array_base_type = GetAttrTypeName( TYPEget_base_type( t ) ); + fprintf( file, "'%s', scope = schema_scope)", array_base_type ); } } -int count_supertypes(Entity f) -{ +int count_supertypes(Entity f) { int top_count; int child_count; Linked_List list; list = ENTITYget_supertypes(f); top_count = 0; - LISTdo(list, e, Entity) - child_count = 1; - child_count += count_supertypes(e); - if(child_count > top_count) { - top_count = child_count; - } + LISTdo( list, e, Entity ) + child_count = 1; + child_count += count_supertypes(e); + if (child_count > top_count) + top_count = child_count; LISTod; return top_count; } -int cmp_python_mro(void *e1, void *e2) -{ +int cmp_python_mro( void * e1, void * e2 ) { int e1_chain_len, e2_chain_len; /* TODO: This should do something more intelligent */ - e1_chain_len = count_supertypes((Entity) e1); - e2_chain_len = count_supertypes((Entity) e2); + e1_chain_len = count_supertypes( ( Entity ) e1); + e2_chain_len = count_supertypes( ( Entity ) e2); - if(e1_chain_len == e2_chain_len) { + if (e1_chain_len == e2_chain_len) { return 0; - } else if(e1_chain_len > e2_chain_len) { + } else if (e1_chain_len > e2_chain_len) { return 1; } else { return -1; @@ -576,11 +554,10 @@ int cmp_python_mro(void *e1, void *e2) } void -LIBdescribe_entity(Entity entity, FILE *file) -{ +LIBdescribe_entity( Entity entity, FILE * file ) { int attr_count_tmp = attr_count; char attrnm [BUFSIZ], parent_attrnm[BUFSIZ]; - char *attr_type; + char * attr_type; bool generate_constructor = true; /*by default, generates a python constructor */ bool single_inheritance = false; bool ent_multiple_inheritance = false; @@ -594,34 +571,34 @@ LIBdescribe_entity(Entity entity, FILE *file) /* class name need to use new-style classes for properties to work correctly so class must inherit from object */ - if(is_python_keyword(ENTITYget_name(entity))) { - fprintf(file, "class %s_(", ENTITYget_name(entity)); + if( is_python_keyword( ENTITYget_name( entity ) ) ) { + fprintf( file, "class %s_(", ENTITYget_name( entity ) ); } else { - fprintf(file, "class %s(", ENTITYget_name(entity)); + fprintf( file, "class %s(", ENTITYget_name( entity ) ); } /* * Look for inheritance and super classes */ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); LISTsort(list, cmp_python_mro); num_parent = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) /* if there\'s no super class yet, or the super class doesn\'t have any attributes */ - if(num_parent > 0) { - fprintf(file, ","); /*separator for parent classes names */ + if( num_parent > 0 ) { + fprintf( file, "," ); /*separator for parent classes names */ } - if(is_python_keyword(ENTITYget_name(e))) { - fprintf(file, "%s_", ENTITYget_name(e)); + if( is_python_keyword( ENTITYget_name( e ) ) ) { + fprintf( file, "%s_", ENTITYget_name( e ) ); } else { - fprintf(file, "%s", ENTITYget_name(e)); + fprintf( file, "%s", ENTITYget_name( e ) ); } num_parent++; LISTod; - if(num_parent == 1) { + if( num_parent == 1 ) { single_inheritance = true; ent_multiple_inheritance = false; } else { @@ -631,270 +608,261 @@ LIBdescribe_entity(Entity entity, FILE *file) } else { /*inherit from BaseEntityClass by default, in order to enable decorators */ /* as well as advanced __repr__ feature */ - fprintf(file, "BaseEntityClass"); + fprintf( file, "BaseEntityClass" ); } - fprintf(file, "):\n"); + fprintf( file, "):\n" ); /* * Write docstrings in a Sphinx compliant manner */ - fprintf(file, "\t'''Entity %s definition.\n", ENTITYget_name(entity)); - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - t = VARget_type(v); - fprintf(file, "\n\t:param %s\n", attrnm); - fprintf(file, "\t:type %s:", attrnm); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "\n"); + fprintf( file, "\t'''Entity %s definition.\n", ENTITYget_name( entity ) ); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + t = VARget_type( v ); + fprintf( file, "\n\t:param %s\n", attrnm ); + fprintf( file, "\t:type %s:", attrnm ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "\n" ); } else { - if(TYPEget_name(t) == NULL) { - attr_type = GetAttrTypeName(t); + if( TYPEget_name( t ) == NULL ) { + attr_type = GetAttrTypeName( t ); } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } - fprintf(file, "%s\n", attr_type); + fprintf( file, "%s\n", attr_type ); } attr_count_tmp++; LISTod - fprintf(file, "\t'''\n"); + fprintf( file, "\t'''\n" ); /* * Before writing constructor, check if this entity has any attribute * other wise just a 'pass' statement is enough */ attr_count_tmp = 0; num_derived_inverse_attr = 0; - LISTdo(ENTITYget_attributes(entity), v, Variable) - if(VARis_derived(v) || VARget_inverse(v)) { + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + if( VARis_derived( v ) || VARget_inverse( v ) ) { num_derived_inverse_attr++; } else { attr_count_tmp++; } LISTod - if((attr_count_tmp == 0) && !single_inheritance && !ent_multiple_inheritance) { - fprintf(file, "\t# This class does not define any attribute.\n"); - fprintf(file, "\tpass\n"); + if( ( attr_count_tmp == 0 ) && !single_inheritance && !ent_multiple_inheritance ) { + fprintf( file, "\t# This class does not define any attribute.\n" ); + fprintf( file, "\tpass\n" ); generate_constructor = false; } - if(false) {} + if( false ) {} else { /* * write class constructor */ - if(generate_constructor) { - fprintf(file, "\tdef __init__( self , "); + if( generate_constructor ) { + fprintf( file, "\tdef __init__( self , " ); } /* if inheritance, first write the inherited parameters */ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); num_parent = 0; index_attribute = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { /* search attribute names for superclass */ - LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { - generate_attribute_name(v2, parent_attrnm); - if(!VARis_derived(v2) && !VARget_inverse(v2)) { - fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); + LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { + generate_attribute_name( v2, parent_attrnm ); + if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { + fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); index_attribute++; } - } - LISTod + } LISTod num_parent++; - } - LISTod + } LISTod } - LISTdo(ENTITYget_attributes(entity), v, Variable) { - generate_attribute_name(v, attrnm); - if(!VARis_derived(v) && !VARget_inverse(v)) { - fprintf(file, "%s,", attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) { + generate_attribute_name( v, attrnm ); + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { + fprintf( file, "%s,", attrnm ); } - } - LISTod + } LISTod /* close constructor method */ - if(generate_constructor) { - fprintf(file, " ):\n"); + if( generate_constructor ) { + fprintf( file, " ):\n" ); } /** if inheritance, first init base class **/ - list = ENTITYget_supertypes(entity); + list = ENTITYget_supertypes( entity ); index_attribute = 0; - if(! LISTempty(list)) { - LISTdo(list, e, Entity) { - if(is_python_keyword(ENTITYget_name(e))) { - fprintf(file, "\t\t%s_.__init__(self , ", ENTITYget_name(e)); + if( ! LISTempty( list ) ) { + LISTdo( list, e, Entity ) { + if (is_python_keyword(ENTITYget_name( e ))) { + fprintf( file, "\t\t%s_.__init__(self , ", ENTITYget_name( e ) ); } else { - fprintf(file, "\t\t%s.__init__(self , ", ENTITYget_name(e)); + fprintf( file, "\t\t%s.__init__(self , ", ENTITYget_name( e ) ); } /* search and write attribute names for superclass */ - LISTdo_n(ENTITYget_all_attributes(e), v2, Variable, b) { - generate_attribute_name(v2, parent_attrnm); - if(!VARis_derived(v2) && !VARget_inverse(v2)) { - fprintf(file, "inherited%i__%s , ", index_attribute, parent_attrnm); + LISTdo_n( ENTITYget_all_attributes( e ), v2, Variable, b ) { + generate_attribute_name( v2, parent_attrnm ); + if( !VARis_derived( v2 ) && !VARget_inverse( v2 ) ) { + fprintf( file, "inherited%i__%s , ", index_attribute, parent_attrnm ); index_attribute++; } - } - LISTod + } LISTod num_parent++; - fprintf(file, ")\n"); /*separator for parent classes names */ - } - LISTod + fprintf( file, ")\n" ); /*separator for parent classes names */ + } LISTod } /* init variables in constructor */ - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - if(!VARis_derived(v) && !VARget_inverse(v)) { - fprintf(file, "\t\tself._%s = %s\n", attrnm, attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { + fprintf( file, "\t\tself._%s = %s\n", attrnm, attrnm ); } /*attr_count_tmp++; */ LISTod /* * write attributes as python properties */ - LISTdo(ENTITYget_attributes(entity), v, Variable) - generate_attribute_name(v, attrnm); - fprintf(file, "\n\t@property\n"); - if(!strcmp(attrnm, "property")) { - fprintf(file, "\tdef __%s(self):\n", attrnm); + LISTdo( ENTITYget_attributes( entity ), v, Variable ) + generate_attribute_name( v, attrnm ); + fprintf( file, "\n\t@property\n" ); + if ( !strcmp(attrnm, "property") ) { + fprintf( file, "\tdef __%s(self):\n", attrnm ); rename_python_property = true; } else { - fprintf(file, "\tdef %s(self):\n", attrnm); + fprintf( file, "\tdef %s(self):\n", attrnm ); } /* fget */ - if(!VARis_derived(v)) { - fprintf(file, "\t\treturn self._%s\n", attrnm); + if( !VARis_derived( v ) ) { + fprintf( file, "\t\treturn self._%s\n", attrnm ); } else { /* evaluation of attribute */ - fprintf(file, "\t\tattribute_eval = "); + fprintf( file, "\t\tattribute_eval = " ); /* outputs expression initializer */ - ATTRIBUTE_INITIALIZER_out(v->initializer, 1, file); + ATTRIBUTE_INITIALIZER_out( v->initializer, 1, file ); /* then returns the value */ - fprintf(file, "\n\t\treturn attribute_eval\n"); + fprintf( file, "\n\t\treturn attribute_eval\n" ); } /* fset */ - if(!strcmp(attrnm, "property")) { - fprintf(file, "\t@__%s.setter\n", attrnm); - fprintf(file, "\tdef __%s(self, value):\n", attrnm); + if ( !strcmp(attrnm, "property") ) { + fprintf( file, "\t@__%s.setter\n", attrnm ); + fprintf( file, "\tdef __%s(self, value):\n", attrnm ); } else { - fprintf(file, "\t@%s.setter\n", attrnm); - fprintf(file, "\tdef %s(self, value):\n", attrnm); + fprintf( file, "\t@%s.setter\n", attrnm ); + fprintf( file, "\tdef %s(self, value):\n", attrnm ); } - t = VARget_type(v); + t = VARget_type( v ); /* find attr type name */ - if(TYPEget_name(t) == NULL) { - attr_type = GetAttrTypeName(t); + if( TYPEget_name( t ) == NULL ) { + attr_type = GetAttrTypeName( t ); } else { - attr_type = TYPEget_name(t); + attr_type = TYPEget_name( t ); } - if(!VARis_derived(v) && !VARget_inverse(v)) { + if( !VARis_derived( v ) && !VARget_inverse( v ) ) { /* if the argument is not optional */ - if(!VARget_optional(v)) { - fprintf(file, "\t\t# Mandatory argument\n"); - fprintf(file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n"); - fprintf(file, "\t\tif not check_type(value,"); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "):\n"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "%s_):\n", attr_type); + if( !VARget_optional( v ) ) { + fprintf( file, "\t\t# Mandatory argument\n" ); + fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); + fprintf( file, "\t\tif not check_type(value," ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "):\n" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "%s_):\n", attr_type ); } else { - fprintf(file, "%s):\n", attr_type); + fprintf( file, "%s):\n", attr_type ); } } else { - fprintf(file, "\t\tif value != None: # OPTIONAL attribute\n\t"); - fprintf(file, "\t\tif not check_type(value,"); - if(TYPEis_aggregate(t)) { - process_aggregate(file, t); - fprintf(file, "):\n\t"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "%s_):\n\t", attr_type); + fprintf( file, "\t\tif value != None: # OPTIONAL attribute\n\t" ); + fprintf( file, "\t\tif not check_type(value," ); + if( TYPEis_aggregate( t ) ) { + process_aggregate( file, t ); + fprintf( file, "):\n\t" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "%s_):\n\t", attr_type ); } else { - fprintf(file, "%s):\n\t", attr_type); + fprintf( file, "%s):\n\t", attr_type ); } } /* check whether attr_type is aggr or explicit */ - if(TYPEis_aggregate(t)) { - fprintf(file, "\t\t\tself._%s = ", attrnm); - print_aggregate_type(file, t); - fprintf(file, "(value)\n"); - } else if(attr_type && is_python_keyword(attr_type)) { - fprintf(file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type); + if( TYPEis_aggregate( t ) ) { + fprintf( file, "\t\t\tself._%s = ", attrnm ); + print_aggregate_type( file, t ); + fprintf( file, "(value)\n" ); + } else if (attr_type && is_python_keyword(attr_type)) { + fprintf( file, "\t\t\tself._%s = %s_(value)\n", attrnm, attr_type ); } else { - fprintf(file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type); + fprintf( file, "\t\t\tself._%s = %s(value)\n", attrnm, attr_type ); } - if(VARget_optional(v)) { - fprintf(file, "\t\t\telse:\n"); - fprintf(file, "\t\t\t\tself._%s = value\n", attrnm); + if( VARget_optional( v ) ) { + fprintf( file, "\t\t\telse:\n" ); + fprintf( file, "\t\t\t\tself._%s = value\n", attrnm ); } - fprintf(file, "\t\telse:\n\t"); - fprintf(file, "\t\tself._%s = value\n", attrnm); + fprintf( file, "\t\telse:\n\t" ); + fprintf( file, "\t\tself._%s = value\n", attrnm ); } /* if the attribute is derived, prevent fset to attribute to be set */ /* TODO: this can be done by NOT writing the setter method */ - else if(VARis_derived(v)) { - fprintf(file, "\t# DERIVED argument\n"); - fprintf(file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm); - } else if(VARget_inverse(v)) { - fprintf(file, "\t# INVERSE argument\n"); - fprintf(file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm); + else if( VARis_derived( v ) ) { + fprintf( file, "\t# DERIVED argument\n" ); + fprintf( file, "\t\traise AssertionError('Argument %s is DERIVED. It is computed and can not be set to any value')\n", attrnm ); + } else if( VARget_inverse( v ) ) { + fprintf( file, "\t# INVERSE argument\n" ); + fprintf( file, "\t\traise AssertionError('Argument %s is INVERSE. It is computed and can not be set to any value')\n", attrnm ); } LISTod } /* before exiting, process where rules */ - WHEREPrint(entity->where, 0, file); + WHEREPrint( entity->where, 0, file ); - if(rename_python_property) { - fprintf(file, "\tproperty = __property\n"); + if ( rename_python_property ) { + fprintf( file, "\tproperty = __property\n" ); } } int -get_local_attribute_number(Entity entity) -{ +get_local_attribute_number( Entity entity ) { int i = 0; - Linked_List local = ENTITYget_attributes(entity); - LISTdo(local, a, Variable) + Linked_List local = ENTITYget_attributes( entity ); + LISTdo( local, a, Variable ) /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { ++i; } LISTod; return i; } -int get_attribute_number(Entity entity) -{ +int get_attribute_number( Entity entity ) { int i = 0; int found = 0; Linked_List local, complete; - complete = ENTITYget_all_attributes(entity); - local = ENTITYget_attributes(entity); + complete = ENTITYget_all_attributes( entity ); + local = ENTITYget_attributes( entity ); - LISTdo(local, a, Variable) { + LISTdo( local, a, Variable ) { /* go to the child's first explicit attribute */ - if((! VARget_inverse(a)) && (! VARis_derived(a))) { - LISTdo_n(complete, p, Variable, b) { + if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) { + LISTdo_n( complete, p, Variable, b ) { /* cycle through all the explicit attributes until the child's attribute is found */ - if(!found && (! VARget_inverse(p)) && (! VARis_derived(p))) { - if(p != a) { + if( !found && ( ! VARget_inverse( p ) ) && ( ! VARis_derived( p ) ) ) { + if( p != a ) { ++i; } else { found = 1; } } - } - LISTod - if(found) { + } LISTod + if( found ) { return i; } else { /* In this case, a is a Variable - so macro VARget_name (a) expands * * to an Expression. The first element of an Expression is a Symbol. * * The first element of a Symbol is char * name. */ - fprintf(stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name(a)->symbol.name); + fprintf( stderr, "Internal error: %s:%d\nAttribute %s not found. \n", __FILE__, __LINE__, VARget_name( a )->symbol.name ); } } - } - LISTod + } LISTod return -1; } @@ -911,17 +879,15 @@ int get_attribute_number(Entity entity) ** Status: ok 1/15/91 ******************************************************************/ void -ENTITYlib_print(Entity entity, FILE *file) -{ - LIBdescribe_entity(entity, file); +ENTITYlib_print( Entity entity, FILE * file ) { + LIBdescribe_entity( entity, file ); } /*FIXME should return bool */ /* return 1 if types are predefined by us */ int -TYPEis_builtin(const Type t) -{ - switch(TYPEget_body(t)->type) { /* dunno if correct*/ +TYPEis_builtin( const Type t ) { + switch( TYPEget_body( t )->type ) { /* dunno if correct*/ case integer_: case real_: case string_: @@ -949,12 +915,11 @@ TYPEis_builtin(const Type t) ** Status: started 2012/3/1 ******************************************************************/ void -RULEPrint(Rule rule, FILES *files) -{ - char *n = RULEget_name(rule); - fprintf(files->lib, "\n####################\n # RULE %s #\n####################\n", n); +RULEPrint( Rule rule, FILES * files ) { + char * n = RULEget_name( rule ); + fprintf( files->lib, "\n####################\n # RULE %s #\n####################\n", n ); /* write function definition */ - fprintf(files->lib, "%s = Rule()\n", n); + fprintf( files->lib, "%s = Rule()\n", n ); } @@ -968,227 +933,216 @@ RULEPrint(Rule rule, FILES *files) ** Status: started 2012/3/1 ******************************************************************/ void -FUNCPrint(Function function, FILES *files) -{ - char *function_name = FUNCget_name(function); - char *param_name; +FUNCPrint( Function function, FILES * files ) { + char * function_name = FUNCget_name( function ); + char * param_name; Expression expr_name = EXPRESSION_NULL; - fprintf(files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name); + fprintf( files->lib, "\n####################\n # FUNCTION %s #\n####################\n", function_name ); /* write function definition */ - fprintf(files->lib, "def %s(", function_name); + fprintf( files->lib, "def %s(", function_name ); /* write parameter list */ - LISTdo(FUNCget_parameters(function), v, Variable) { - expr_name = VARget_name(v); - param_name = strdup(EXPget_name(expr_name)); - fprintf(files->lib, "%s,", param_name); - } - LISTod - fprintf(files->lib, "):\n"); + LISTdo( FUNCget_parameters( function ), v, Variable ) { + expr_name = VARget_name( v ); + param_name = strdup( EXPget_name( expr_name ) ); + fprintf( files->lib, "%s,", param_name ); + } LISTod + fprintf( files->lib, "):\n" ); /* print function docstring */ - fprintf(files->lib, "\t'''\n"); - LISTdo(FUNCget_parameters(function), v, Variable) { - expr_name = VARget_name(v); - param_name = strdup(EXPget_name(expr_name)); - fprintf(files->lib, "\t:param %s\n", param_name); - fprintf(files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName(VARget_type(v))); - } - LISTod - fprintf(files->lib, "\t'''\n"); + fprintf( files->lib, "\t'''\n" ); + LISTdo( FUNCget_parameters( function ), v, Variable ) { + expr_name = VARget_name( v ); + param_name = strdup( EXPget_name( expr_name ) ); + fprintf( files->lib, "\t:param %s\n", param_name ); + fprintf( files->lib, "\t:type %s:%s\n", param_name, GetAttrTypeName( VARget_type( v ) ) ); + } LISTod + fprintf( files->lib, "\t'''\n" ); /* process statements. The indent_level is set to 1 (the number of tabs \t) */ - STATEMENTSPrint(function->u.proc->body, 1, files->lib); + STATEMENTSPrint( function->u.proc->body, 1, files->lib ); } void -STATEMENTSPrint(Linked_List stmts, int indent_level, FILE *file) -{ - LISTdo(stmts, stmt, Statement) - STATEMENTPrint(stmt, indent_level, file); +STATEMENTSPrint( Linked_List stmts , int indent_level, FILE * file ) { + LISTdo( stmts, stmt, Statement ) + STATEMENTPrint( stmt, indent_level, file ); LISTod } -void python_indent(FILE *file, int indent_level) -{ +void python_indent( FILE * file, int indent_level ) { int i; - for(i = 0; i < indent_level; i++) { - fprintf(file, "\t"); + for( i = 0; i < indent_level; i++ ) { + fprintf( file, "\t" ); } } void -STATEMENTPrint(Statement s, int indent_level, FILE *file) -{ +STATEMENTPrint( Statement s, int indent_level, FILE * file ) { bool first_time = true; - python_indent(file, indent_level); - if(!s) { /* null statement */ - fprintf(file, "pass"); + python_indent( file, indent_level ); + if( !s ) { /* null statement */ + fprintf( file, "pass" ); return; } - switch(s->type) { + switch( s->type ) { case STMT_ASSIGN: - EXPRESSION_out(s->u.assign->lhs, 0, file); - fprintf(file, " = "); - EXPRESSION_out(s->u.assign->rhs, 0, file); - fprintf(file, "\n"); + EXPRESSION_out( s->u.assign->lhs, 0, file ); + fprintf( file, " = " ); + EXPRESSION_out( s->u.assign->rhs, 0, file ); + fprintf( file, "\n" ); break; case STMT_CASE: - CASEout(s->u.Case, indent_level, file); + CASEout( s->u.Case, indent_level, file ); break; case STMT_RETURN: - fprintf(file, "return "); - if(s->u.ret->value) { - EXPRESSION_out(s->u.ret->value, 0, file); + fprintf( file, "return " ); + if( s->u.ret->value ) { + EXPRESSION_out( s->u.ret->value, 0, file ); } - fprintf(file, "\n"); + fprintf( file, "\n" ); break; case STMT_LOOP: - LOOPpyout(s->u.loop, indent_level, file); + LOOPpyout( s->u.loop, indent_level , file ); break; case STMT_ALIAS: - fprintf(file, "%s = %s\n", s->symbol.name, - s->u.alias->variable->name->symbol.name); - STATEMENTlist_out(s->u.alias->statements, indent_level, file); + fprintf( file, "%s = %s\n", s->symbol.name, + s->u.alias->variable->name->symbol.name ); + STATEMENTlist_out( s->u.alias->statements, indent_level , file ); break; case STMT_SKIP: - fprintf(file, "break\n"); /* @TODO: is that correct? */ + fprintf( file, "break\n" ); /* @TODO: is that correct? */ break; case STMT_ESCAPE: - fprintf(file, "break\n"); + fprintf( file, "break\n" ); break; case STMT_COMPOUND: /* following line is necessary other wise indentation */ /* errors in python */ - fprintf(file, "# begin/end block\n"); - STATEMENTlist_out(s->u.compound->statements, indent_level, file); + fprintf( file, "# begin/end block\n" ); + STATEMENTlist_out( s->u.compound->statements, indent_level, file ); break; case STMT_COND: - fprintf(file, "if ("); - EXPRESSION_out(s->u.cond->test, 0, file); - fprintf(file, "):\n"); - STATEMENTlist_out(s->u.cond->code, indent_level + 1, file); - if(s->u.cond->otherwise) { - python_indent(file, indent_level); - fprintf(file, "else:\n"); - STATEMENTlist_out(s->u.cond->otherwise, indent_level + 1, file); + fprintf( file, "if (" ); + EXPRESSION_out( s->u.cond->test, 0 , file ); + fprintf( file, "):\n" ); + STATEMENTlist_out( s->u.cond->code, indent_level + 1, file ); + if( s->u.cond->otherwise ) { + python_indent( file, indent_level ); + fprintf( file, "else:\n" ); + STATEMENTlist_out( s->u.cond->otherwise, indent_level + 1, file ); } break; case STMT_PCALL: - fprintf(file, "%s(", s->symbol.name); - LISTdo(s->u.proc->parameters, p, Expression) - if(first_time) { + fprintf( file, "%s(", s->symbol.name ); + LISTdo( s->u.proc->parameters, p, Expression ) + if( first_time ) { first_time = false; } else { - fprintf(file, ","); + fprintf( file, "," ); } - EXPRESSION_out(p, 0, file); + EXPRESSION_out( p, 0, file ); LISTod - fprintf(file, ")\n"); + fprintf( file, ")\n" ); } } void -CASEout(struct Case_Statement_ *c, int level, FILE *file) -{ +CASEout( struct Case_Statement_ *c, int level, FILE * file ) { int if_number = 0; - fprintf(file, "case_selector = "); - EXPRESSION_out(c->selector, 0, file); - fprintf(file, "\n"); + fprintf( file, "case_selector = " ); + EXPRESSION_out( c->selector, 0, file ); + fprintf( file, "\n" ); /* pass 2: print them */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { /* print label(s) */ - python_indent(file, level); - if(if_number == 0) { - fprintf(file, "if "); + python_indent( file, level ); + if( if_number == 0 ) { + fprintf( file, "if " ); } else { - fprintf(file, "elif"); + fprintf( file, "elif" ); } - fprintf(file, " case_selector == "); - EXPRESSION_out(label, 0, file); - fprintf(file, ":\n"); + fprintf( file, " case_selector == " ); + EXPRESSION_out( label, 0, file ); + fprintf( file, ":\n" ); /* print action */ - STATEMENTPrint(ci->action, level + 1, file); + STATEMENTPrint( ci->action, level + 1, file ); if_number++; - } - LISTod + } LISTod } else { /* print OTHERWISE */ - python_indent(file, level); - fprintf(file, "else:\n"); + python_indent( file, level ); + fprintf( file, "else:\n" ); /* print action */ - STATEMENTPrint(ci->action, level + 1, file); + STATEMENTPrint( ci->action, level + 1, file ); } - } - LISTod + } LISTod } void -LOOPpyout(struct Loop_ *loop, int level, FILE *file) -{ +LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { Variable v; - - if(loop->scope) { + + if (loop->scope) { DictionaryEntry de; /* TODO: if incr != 0 && ((incr > 0 && start < stop) || (incr < 0 && start > stop)): */ - DICTdo_init(loop->scope->symbol_table, &de); - v = (Variable)DICTdo(&de); - fprintf(file, "for %s in range(", v->name->symbol.name); - EXPRESSION_out(loop->scope->u.incr->init, 0, file); - fprintf(file, ","); - EXPRESSION_out(loop->scope->u.incr->end, 0, file); - fprintf(file, ","); /* parser always forces a "by" expr */ - EXPRESSION_out(loop->scope->u.incr->increment, 0, file); - fprintf(file, "):\n"); - - if(loop->while_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->while_expr, 0, file); - fprintf(file, ":\n"); - STATEMENTlist_out(loop->statements, level + 2, file); + DICTdo_init( loop->scope->symbol_table, &de ); + v = ( Variable )DICTdo( &de ); + fprintf( file, "for %s in range(", v->name->symbol.name ); + EXPRESSION_out( loop->scope->u.incr->init, 0 , file ); + fprintf( file, "," ); + EXPRESSION_out( loop->scope->u.incr->end, 0 , file ); + fprintf( file, "," ); /* parser always forces a "by" expr */ + EXPRESSION_out( loop->scope->u.incr->increment, 0 , file ); + fprintf( file, "):\n" ); + + if( loop->while_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->while_expr, 0 , file ); + fprintf( file, ":\n"); + STATEMENTlist_out( loop->statements, level + 2 , file ); } else { - STATEMENTlist_out(loop->statements, level + 1, file); + STATEMENTlist_out( loop->statements, level + 1 , file ); } - if(loop->until_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + if( loop->until_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } - } else if(loop->while_expr) { - fprintf(file, "while "); - EXPRESSION_out(loop->while_expr, 0, file); - fprintf(file, ":\n"); - STATEMENTlist_out(loop->statements, level + 1, file); - - if(loop->until_expr) { - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + } else if( loop->while_expr ) { + fprintf( file, "while " ); + EXPRESSION_out( loop->while_expr, 0 , file ); + fprintf( file, ":\n"); + STATEMENTlist_out( loop->statements, level + 1 , file ); + + if( loop->until_expr ) { + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } } else { - fprintf(file, "while True:\n"); - STATEMENTlist_out(loop->statements, level + 1, file); + fprintf( file, "while True:\n" ); + STATEMENTlist_out( loop->statements, level + 1 , file ); - fprintf(file, "if "); - EXPRESSION_out(loop->until_expr, 0, file); - fprintf(file, ":\n\tbreak\n"); + fprintf( file, "if " ); + EXPRESSION_out( loop->until_expr, 0 , file ); + fprintf( file, ":\n\tbreak\n"); } } void -STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file) -{ - LISTdo(stmts, stmt, Statement) - STATEMENTPrint(stmt, indent_level, file); +STATEMENTlist_out( Linked_List stmts, int indent_level, FILE * file ) { + LISTdo( stmts, stmt, Statement ) + STATEMENTPrint( stmt, indent_level, file ); LISTod } /***************************************************************** @@ -1198,113 +1152,112 @@ STATEMENTlist_out(Linked_List stmts, int indent_level, FILE *file) ** ******************************************************************/ void -ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file) -{ +ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * file ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - fprintf(file, " None "); + if( e == LITERAL_INFINITY ) { + fprintf( file, " None " ); } else { - fprintf(file, "%d", e->u.integer); + fprintf( file, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - fprintf(file, " PI "); - } else if(e == LITERAL_E) { - fprintf(file, " E ");; + if( e == LITERAL_PI ) { + fprintf( file, " PI " ); + } else if( e == LITERAL_E ) { + fprintf( file, " E " );; } else { - fprintf(file, "%g", e->u.real); + fprintf( file, "%g", e->u.real ); } break; case binary_: - fprintf(file, "%%%s", e->u.binary); /* put "%" back */ + fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - fprintf(file, "TRUE"); + fprintf( file, "TRUE" ); break; case Lfalse: - fprintf(file, "FALSE"); + fprintf( file, "FALSE" ); break; default: - fprintf(file, "UNKNOWN"); + fprintf( file, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - fprintf(file, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + fprintf( file, "\"%s\"", e->symbol.name ); } else { - char *tmp = strliteral_py_dup(e->symbol.name); - fprintf(file, "'%s'", tmp); + char* tmp = strliteral_py_dup(e->symbol.name); + fprintf( file, "'%s'", tmp ); free(tmp); } break; case entity_: case identifier_: - fprintf(file, "self.%s", e->symbol.name); + fprintf( file, "self.%s", e->symbol.name ); break; case attribute_: - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); break; case enumeration_: - fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); + fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: /* so far we don't handle queries */ - fprintf(file, "None"); + fprintf( file, "None" ); break; case self_: - fprintf(file, "self"); + fprintf( file, "self" ); break; case funcall_: - fprintf(file, "%s(", e->symbol.name); + fprintf( file, "%s(", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; case op_: - ATTRIBUTE_INITIALIZERop__out(&e->e, paren, previous_op, file); + ATTRIBUTE_INITIALIZERop__out( &e->e, paren, previous_op, file ); break; case aggregate_: - fprintf(file, "["); + fprintf( file, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0 , file ); LISTod - fprintf(file, "]"); + fprintf( file, "]" ); break; case oneof_: - fprintf(file, "ONEOF ("); + fprintf( file, "ONEOF (" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - ATTRIBUTE_INITIALIZER_out(arg, 0, file); + ATTRIBUTE_INITIALIZER_out( arg, 0, file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; default: - fprintf(file, "unknown expression, type %d", TYPEis(e->type)); + fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); } } @@ -1314,417 +1267,409 @@ ATTRIBUTE_INITIALIZER__out(Expression e, int paren, int previous_op, FILE *file) ** include, and initialization files for a specific entity class ******************************************************************/ void -EXPRESSION__out(Expression e, int paren, Op_Code previous_op, FILE *file) -{ +EXPRESSION__out( Expression e, int paren, Op_Code previous_op, FILE* file ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - fprintf(file, " None "); + if( e == LITERAL_INFINITY ) { + fprintf( file, " None " ); } else { - fprintf(file, "%d", e->u.integer); + fprintf( file, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - fprintf(file, " PI "); - } else if(e == LITERAL_E) { - fprintf(file, " E ");; + if( e == LITERAL_PI ) { + fprintf( file, " PI " ); + } else if( e == LITERAL_E ) { + fprintf( file, " E " );; } else { - fprintf(file, "%g", e->u.real); + fprintf( file, "%g", e->u.real ); } break; case binary_: - fprintf(file, "%%%s", e->u.binary); /* put "%" back */ + fprintf( file, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - fprintf(file, "TRUE"); + fprintf( file, "TRUE" ); break; case Lfalse: - fprintf(file, "FALSE"); + fprintf( file, "FALSE" ); break; default: - fprintf(file, "UNKNOWN"); + fprintf( file, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - fprintf(file, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + fprintf( file, "\"%s\"", e->symbol.name ); } else { - char *tmp = strliteral_py_dup(e->symbol.name); - fprintf(file, "'%s'", tmp); + char* tmp = strliteral_py_dup(e->symbol.name); + fprintf( file, "'%s'", tmp ); free(tmp); } break; case entity_: case identifier_: - if(is_python_keyword(e->symbol.name)) { - fprintf(file, "%s_", e->symbol.name); + if( is_python_keyword( e->symbol.name ) ) { + fprintf( file, "%s_", e->symbol.name ); } else { - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); } break; case attribute_: - fprintf(file, "%s", e->symbol.name); + fprintf( file, "%s", e->symbol.name ); break; case enumeration_: - fprintf(file, "%s.%s", TYPEget_name(e->type), e->symbol.name); + fprintf( file, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: /* so far we don't handle queries */ - fprintf(file, "None"); + fprintf( file, "None" ); break; case self_: - fprintf(file, "self"); + fprintf( file, "self" ); break; case funcall_: - fprintf(file, "%s(", e->symbol.name); + fprintf( file, "%s(", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0 , file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; case op_: - EXPRESSIONop__out(&e->e, paren, previous_op, file); + EXPRESSIONop__out( &e->e, paren, previous_op, file ); break; case aggregate_: - fprintf(file, "["); + fprintf( file, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0 , file ); LISTod - fprintf(file, "]"); + fprintf( file, "]" ); break; case oneof_: - fprintf(file, "ONEOF ("); + fprintf( file, "ONEOF (" ); i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - fprintf(file, ","); + if( i != 1 ) { + fprintf( file, "," ); } - EXPRESSION_out(arg, 0, file); + EXPRESSION_out( arg, 0, file ); LISTod - fprintf(file, ")"); + fprintf( file, ")" ); break; default: - fprintf(file, "unknown expression, type %d", TYPEis(e->type)); + fprintf( file, "unknown expression, type %d", TYPEis( e->type ) ); } } void -ATTRIBUTE_INITIALIZERop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) -{ +ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { /* TODO: refactor, eliminate Op_Subexpression for enumerations */ - Type op1_type = EXPget_type(oe->op1); - if(TYPEis_enumeration(op1_type)) { - fprintf(file, "%s.%s", TYPEget_name(op1_type), EXPget_name(oe->op2)); + Type op1_type = EXPget_type( oe->op1 ); + if ( TYPEis_enumeration( op1_type ) ) { + fprintf( file, "%s.%s", TYPEget_name( op1_type ), EXPget_name( oe->op2 ) ); return; } - switch(oe->op_code) { + switch( oe->op_code ) { case OP_AND: - ATTRIBUTE_INITIALIZERop2_out(oe, " and ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " and ", paren, PAD, file ); break; case OP_ANDOR: case OP_OR: - ATTRIBUTE_INITIALIZERop2_out(oe, " or ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " or ", paren, PAD, file ); break; case OP_CONCAT: case OP_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); break; case OP_PLUS: - ATTRIBUTE_INITIALIZERop2_out(oe, " + ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " + ", paren, PAD, file ); break; case OP_TIMES: - ATTRIBUTE_INITIALIZERop2_out(oe, " * ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " * ", paren, PAD, file ); break; case OP_XOR: - ATTRIBUTE_INITIALIZERop2__out(oe, " != ", paren, PAD, previous_op, file); + ATTRIBUTE_INITIALIZERop2__out( oe, " != ", paren, PAD, previous_op, file ); break; case OP_EXP: - ATTRIBUTE_INITIALIZERop2_out(oe, " ** ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " ** ", paren, PAD, file ); break; case OP_GREATER_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " >= ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " >= ", paren, PAD, file ); break; case OP_GREATER_THAN: - ATTRIBUTE_INITIALIZERop2_out(oe, " > ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " == ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); break; case OP_INST_NOT_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD, file ); break; case OP_LESS_EQUAL: - ATTRIBUTE_INITIALIZERop2_out(oe, " <= ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " <= ", paren, PAD, file ); break; case OP_LESS_THAN: - ATTRIBUTE_INITIALIZERop2_out(oe, " < ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " < ", paren, PAD, file ); break; case OP_LIKE: case OP_MOD: - ATTRIBUTE_INITIALIZERop2_out(oe, " % ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " % ", paren, PAD, file ); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - ATTRIBUTE_INITIALIZERop2_out(oe, " != ", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, " != ", paren, PAD , file ); break; case OP_NOT: - ATTRIBUTE_INITIALIZERop1_out(oe, " not ", paren, file); + ATTRIBUTE_INITIALIZERop1_out( oe, " not ", paren, file ); break; case OP_REAL_DIV: case OP_DIV: - ATTRIBUTE_INITIALIZERop2_out(oe, "/", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, "/", paren, PAD, file ); break; case OP_MINUS: - ATTRIBUTE_INITIALIZERop2_out(oe, "-", paren, PAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, "-", paren, PAD, file ); break; case OP_DOT: - ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - ATTRIBUTE_INITIALIZERop2_out(oe, ".", paren, NOPAD, file); + ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); break; case OP_NEGATE: - ATTRIBUTE_INITIALIZERop1_out(oe, "-", paren, file); + ATTRIBUTE_INITIALIZERop1_out( oe, "-", paren, file ); break; case OP_ARRAY_ELEMENT: - ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); - fprintf(file, "["); - ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); - fprintf(file, "]"); + ATTRIBUTE_INITIALIZER_out( oe->op1, 1, file ); + fprintf( file, "[" ); + ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); + fprintf( file, "]" ); break; case OP_SUBCOMPONENT: - ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); - fprintf(file, "["); - ATTRIBUTE_INITIALIZER_out(oe->op2, 0, file); - fprintf(file, ":"); - ATTRIBUTE_INITIALIZER_out(oe->op3, 0, file); - fprintf(file, "]"); + ATTRIBUTE_INITIALIZER_out( oe->op1, 1 , file ); + fprintf( file, "[" ); + ATTRIBUTE_INITIALIZER_out( oe->op2, 0, file ); + fprintf( file, ":" ); + ATTRIBUTE_INITIALIZER_out( oe->op3, 0, file ); + fprintf( file, "]" ); break; default: - fprintf(file, "(* unknown op-expression *)"); + fprintf( file, "(* unknown op-expression *)" ); } } /* print expression that has op and operands */ void -EXPRESSIONop__out(struct Op_Subexpression *oe, int paren, Op_Code previous_op, FILE *file) -{ - switch(oe->op_code) { +EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, FILE* file ) { + switch( oe->op_code ) { case OP_AND: - EXPRESSIONop2_out(oe, " and ", paren, PAD, file); + EXPRESSIONop2_out( oe, " and ", paren, PAD, file ); break; case OP_ANDOR: case OP_OR: - EXPRESSIONop2_out(oe, " or ", paren, PAD, file); + EXPRESSIONop2_out( oe, " or ", paren, PAD, file ); break; case OP_CONCAT: case OP_EQUAL: - EXPRESSIONop2_out(oe, " == ", paren, PAD, file); + EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); break; case OP_PLUS: - EXPRESSIONop2_out(oe, " + ", paren, PAD, file); + EXPRESSIONop2_out( oe, " + ", paren, PAD, file ); break; case OP_TIMES: - EXPRESSIONop2_out(oe, " * ", paren, PAD, file); + EXPRESSIONop2_out( oe, " * ", paren, PAD, file ); break; case OP_XOR: - EXPRESSIONop2__out(oe, " != ", paren, PAD, previous_op, file); + EXPRESSIONop2__out( oe, " != ", paren, PAD, previous_op, file ); break; case OP_EXP: - EXPRESSIONop2_out(oe, " ** ", paren, PAD, file); + EXPRESSIONop2_out( oe, " ** ", paren, PAD, file ); break; case OP_GREATER_EQUAL: - EXPRESSIONop2_out(oe, " >= ", paren, PAD, file); + EXPRESSIONop2_out( oe, " >= ", paren, PAD, file ); break; case OP_GREATER_THAN: - EXPRESSIONop2_out(oe, " > ", paren, PAD, file); + EXPRESSIONop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ + /* break; */ case OP_INST_EQUAL: - EXPRESSIONop2_out(oe, " == ", paren, PAD, file); + EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); break; case OP_INST_NOT_EQUAL: - EXPRESSIONop2_out(oe, " != ", paren, PAD, file); + EXPRESSIONop2_out( oe, " != ", paren, PAD, file ); break; case OP_LESS_EQUAL: - EXPRESSIONop2_out(oe, " <= ", paren, PAD, file); + EXPRESSIONop2_out( oe, " <= ", paren, PAD, file ); break; case OP_LESS_THAN: - EXPRESSIONop2_out(oe, " < ", paren, PAD, file); + EXPRESSIONop2_out( oe, " < ", paren, PAD, file ); break; case OP_LIKE: case OP_MOD: - EXPRESSIONop2_out(oe, " % ", paren, PAD, file); + EXPRESSIONop2_out( oe, " % ", paren, PAD, file ); break; case OP_NOT_EQUAL: /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - EXPRESSIONop2_out(oe, " != ", paren, PAD, file); + EXPRESSIONop2_out( oe, " != ", paren, PAD , file ); break; case OP_NOT: - EXPRESSIONop1_out(oe, " not ", paren, file); + EXPRESSIONop1_out( oe, " not ", paren, file ); break; case OP_REAL_DIV: case OP_DIV: - EXPRESSIONop2_out(oe, "/", paren, PAD, file); + EXPRESSIONop2_out( oe, "/", paren, PAD, file ); break; case OP_MINUS: - EXPRESSIONop2_out(oe, "-", paren, PAD, file); + EXPRESSIONop2_out( oe, "-", paren, PAD, file ); break; case OP_DOT: - EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); + EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - EXPRESSIONop2_out(oe, ".", paren, NOPAD, file); + EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); break; case OP_NEGATE: - EXPRESSIONop1_out(oe, "-", paren, file); + EXPRESSIONop1_out( oe, "-", paren, file ); break; case OP_ARRAY_ELEMENT: - EXPRESSION_out(oe->op1, 1, file); - fprintf(file, "["); - EXPRESSION_out(oe->op2, 0, file); - fprintf(file, "]"); + EXPRESSION_out( oe->op1, 1, file ); + fprintf( file, "[" ); + EXPRESSION_out( oe->op2, 0, file ); + fprintf( file, "]" ); break; case OP_SUBCOMPONENT: - EXPRESSION_out(oe->op1, 1, file); - fprintf(file, "["); - EXPRESSION_out(oe->op2, 0, file); - fprintf(file, ":"); - EXPRESSION_out(oe->op3, 0, file); - fprintf(file, "]"); + EXPRESSION_out( oe->op1, 1 , file ); + fprintf( file, "[" ); + EXPRESSION_out( oe->op2, 0, file ); + fprintf( file, ":" ); + EXPRESSION_out( oe->op3, 0, file ); + fprintf( file, "]" ); break; default: - fprintf(file, "(* unknown op-expression *)"); + fprintf( file, "(* unknown op-expression *)" ); } } void -EXPRESSIONop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) -{ - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, "("); +EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, "(" ); } - EXPRESSION__out(eo->op1, 1, eo->op_code, file); - if(pad) { - fprintf(file, " "); + EXPRESSION__out( eo->op1, 1, eo->op_code , file ); + if( pad ) { + fprintf( file, " " ); } - fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - fprintf(file, " "); + fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + fprintf( file, " " ); } - EXPRESSION__out(eo->op2, 1, eo->op_code, file); - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, ")"); + EXPRESSION__out( eo->op2, 1, eo->op_code, file ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, ")" ); } } void -ATTRIBUTE_INITIALIZERop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, Op_Code previous_op, FILE *file) -{ - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, "("); +ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, Op_Code previous_op, FILE * file ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, "(" ); } - ATTRIBUTE_INITIALIZER__out(eo->op1, 1, eo->op_code, file); - if(pad) { - fprintf(file, " "); + ATTRIBUTE_INITIALIZER__out( eo->op1, 1, eo->op_code , file ); + if( pad ) { + fprintf( file, " " ); } - fprintf(file, "%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - fprintf(file, " "); + fprintf( file, "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + fprintf( file, " " ); } - ATTRIBUTE_INITIALIZER__out(eo->op2, 1, eo->op_code, file); - if(pad && paren && (eo->op_code != previous_op)) { - fprintf(file, ")"); + ATTRIBUTE_INITIALIZER__out( eo->op2, 1, eo->op_code, file ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + fprintf( file, ")" ); } } /* Print out a one-operand operation. If there were more than two of these */ /* I'd generalize it to do padding, but it's not worth it. */ void -EXPRESSIONop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) -{ - if(paren) { - fprintf(file, "("); +EXPRESSIONop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { + if( paren ) { + fprintf( file, "(" ); } - fprintf(file, "%s", opcode); - EXPRESSION_out(eo->op1, 1, file); - if(paren) { - fprintf(file, ")"); + fprintf( file, "%s", opcode ); + EXPRESSION_out( eo->op1, 1, file ); + if( paren ) { + fprintf( file, ")" ); } } void -ATTRIBUTE_INITIALIZERop1_out(struct Op_Subexpression *eo, char *opcode, int paren, FILE *file) -{ - if(paren) { - fprintf(file, "("); +ATTRIBUTE_INITIALIZERop1_out( struct Op_Subexpression * eo, char * opcode, int paren, FILE * file ) { + if( paren ) { + fprintf( file, "(" ); } - fprintf(file, "%s", opcode); - ATTRIBUTE_INITIALIZER_out(eo->op1, 1, file); - if(paren) { - fprintf(file, ")"); + fprintf( file, "%s", opcode ); + ATTRIBUTE_INITIALIZER_out( eo->op1, 1, file ); + if( paren ) { + fprintf( file, ")" ); } } void -WHEREPrint(Linked_List wheres, int level, FILE *file) -{ +WHEREPrint( Linked_List wheres, int level , FILE * file ) { int where_rule_number = 0; - python_indent(file, level); + python_indent( file, level ); - if(!wheres) { + if( !wheres ) { return; } /* pass 2: now print labels and exprs */ - LISTdo(wheres, w, Where) - if(strcmp(w->label->name, "")) { + LISTdo( wheres, w, Where ) + if( strcmp( w->label->name, "" ) ) { /* define a function with the name 'label' */ - fprintf(file, "\tdef %s(self):\n", w->label->name); - fprintf(file, "\t\teval_%s_wr = ", w->label->name); + fprintf( file, "\tdef %s(self):\n", w->label->name ); + fprintf( file, "\t\teval_%s_wr = ", w->label->name ); } else { /* no label */ - fprintf(file, "\tdef unnamed_wr_%i(self):\n", where_rule_number); - fprintf(file, "\t\teval_unnamed_wr_%i = ", where_rule_number); + fprintf( file, "\tdef unnamed_wr_%i(self):\n", where_rule_number ); + fprintf( file, "\t\teval_unnamed_wr_%i = ", where_rule_number ); } /*EXPRESSION_out( w->expr, level+1 , file ); */ - ATTRIBUTE_INITIALIZER_out(w->expr, level + 1, file); + ATTRIBUTE_INITIALIZER_out( w->expr, level + 1 , file ); /* raise exception if rule violated */ - if(strcmp(w->label->name, "")) { - fprintf(file, "\n\t\tif not eval_%s_wr:\n", w->label->name); - fprintf(file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name); - fprintf(file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name); + if( strcmp( w->label->name, "" ) ) { + fprintf( file, "\n\t\tif not eval_%s_wr:\n", w->label->name ); + fprintf( file, "\t\t\traise AssertionError('Rule %s violated')\n", w->label->name ); + fprintf( file, "\t\telse:\n\t\t\treturn eval_%s_wr\n\n", w->label->name ); } else { /* no label */ - fprintf(file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number); - fprintf(file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number); - fprintf(file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number); + fprintf( file, "\n\t\tif not eval_unnamed_wr_%i:\n", where_rule_number ); + fprintf( file, "\t\t\traise AssertionError('Rule unnamed_wr_%i violated')\n", where_rule_number ); + fprintf( file, "\t\telse:\n\t\t\treturn eval_unnamed_wr_%i\n\n", where_rule_number ); where_rule_number++; } LISTod @@ -1743,13 +1688,12 @@ WHEREPrint(Linked_List wheres, int level, FILE *file) ******************************************************************/ void -ENTITYPrint(Entity entity, FILES *files) -{ - char *n = ENTITYget_name(entity); - DEBUG("Entering ENTITYPrint for %s\n", n); - fprintf(files->lib, "\n####################\n # ENTITY %s #\n####################\n", n); - ENTITYlib_print(entity, files -> lib); - DEBUG("DONE ENTITYPrint\n") ; +ENTITYPrint( Entity entity, FILES * files ) { + char * n = ENTITYget_name( entity ); + DEBUG( "Entering ENTITYPrint for %s\n", n ); + fprintf( files->lib, "\n####################\n # ENTITY %s #\n####################\n", n ); + ENTITYlib_print( entity, files -> lib ); + DEBUG( "DONE ENTITYPrint\n" ) ; } @@ -1761,206 +1705,200 @@ ENTITYPrint(Entity entity, FILES *files) * FIXME implement or remove */ const char * -EnumCElementName(Type type, Expression expr) -{ +EnumCElementName( Type type, Expression expr ) { (void) type; (void) expr; return NULL; } void -TYPEenum_lib_print(const Type type, FILE *f) -{ +TYPEenum_lib_print( const Type type, FILE * f ) { DictionaryEntry de; Expression expr; /* begin the new enum type */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "\n# ENUMERATION TYPE %s_\n", TYPEget_name( type ) ); } else { - fprintf(f, "\n# ENUMERATION TYPE %s\n", TYPEget_name(type)); + fprintf( f, "\n# ENUMERATION TYPE %s\n", TYPEget_name( type ) ); } /* then outputs the enum */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "%s_ = ENUMERATION('%s_','", TYPEget_name(type), TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "%s_ = ENUMERATION('%s_','", TYPEget_name( type ), TYPEget_name( type ) ); } else { - fprintf(f, "%s = ENUMERATION('%s','", TYPEget_name(type), TYPEget_name(type)); + fprintf( f, "%s = ENUMERATION('%s','", TYPEget_name( type ), TYPEget_name( type ) ); } /* set up the dictionary info */ - DICTdo_type_init(ENUM_TYPEget_items(type), &de, OBJ_ENUM); - while(0 != (expr = (Expression)DICTdo(&de))) { - if(is_python_keyword(EXPget_name(expr))) { - fprintf(f, "%s_ ", EXPget_name(expr)); + DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { + if( is_python_keyword( EXPget_name( expr ) ) ) { + fprintf( f, "%s_ ", EXPget_name( expr ) ); } else { - fprintf(f, "%s ", EXPget_name(expr)); + fprintf( f, "%s ", EXPget_name( expr ) ); } } - fprintf(f, "')\n"); + fprintf( f, "')\n" ); } -void strcat_expr(Expression e, char *buf) -{ - if(e == LITERAL_INFINITY) { - strcat(buf, "?"); - } else if(e == LITERAL_PI) { - strcat(buf, "PI"); - } else if(e == LITERAL_E) { - strcat(buf, "E"); - } else if(e == LITERAL_ZERO) { - strcat(buf, "0"); - } else if(e == LITERAL_ONE) { - strcat(buf, "1"); - } else if(TYPEget_name(e)) { - strcat(buf, TYPEget_name(e)); - } else if(TYPEget_body(e->type)->type == integer_) { +void strcat_expr( Expression e, char * buf ) { + if( e == LITERAL_INFINITY ) { + strcat( buf, "?" ); + } else if( e == LITERAL_PI ) { + strcat( buf, "PI" ); + } else if( e == LITERAL_E ) { + strcat( buf, "E" ); + } else if( e == LITERAL_ZERO ) { + strcat( buf, "0" ); + } else if( e == LITERAL_ONE ) { + strcat( buf, "1" ); + } else if( TYPEget_name( e ) ) { + strcat( buf, TYPEget_name( e ) ); + } else if( TYPEget_body( e->type )->type == integer_ ) { char tmpbuf[30]; - sprintf(tmpbuf, "%d", e->u.integer); - strcat(buf, tmpbuf); + sprintf( tmpbuf, "%d", e->u.integer ); + strcat( buf, tmpbuf ); } else { - strcat(buf, "??"); + strcat( buf, "??" ); } } /* print t's bounds to end of buf */ void -strcat_bounds(TypeBody b, char *buf) -{ - if(!b->upper) { +strcat_bounds( TypeBody b, char * buf ) { + if( !b->upper ) { return; } - strcat(buf, " ["); - strcat_expr(b->lower, buf); - strcat(buf, ":"); - strcat_expr(b->upper, buf); - strcat(buf, "]"); + strcat( buf, " [" ); + strcat_expr( b->lower, buf ); + strcat( buf, ":" ); + strcat_expr( b->upper, buf ); + strcat( buf, "]" ); } void -TypeBody_Description(TypeBody body, char *buf) -{ - char *s; +TypeBody_Description( TypeBody body, char * buf ) { + char * s; - switch(body->type) { + switch( body->type ) { case integer_: - strcat(buf, " INTEGER"); + strcat( buf, " INTEGER" ); break; case real_: - strcat(buf, " REAL"); + strcat( buf, " REAL" ); break; case string_: - strcat(buf, " STRING"); + strcat( buf, " STRING" ); break; case binary_: - strcat(buf, " BINARY"); + strcat( buf, " BINARY" ); break; case boolean_: - strcat(buf, " BOOLEAN"); + strcat( buf, " BOOLEAN" ); break; case logical_: - strcat(buf, " LOGICAL"); + strcat( buf, " LOGICAL" ); break; case number_: - strcat(buf, " NUMBER"); + strcat( buf, " NUMBER" ); break; case entity_: - strcat(buf, " "); - strcat(buf, PrettyTmpName(TYPEget_name(body->entity))); + strcat( buf, " " ); + strcat( buf, PrettyTmpName( TYPEget_name( body->entity ) ) ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(body->type) { - /* ignore the aggregate bounds for now */ + switch( body->type ) { + /* ignore the aggregate bounds for now */ case aggregate_: - strcat(buf, " AGGREGATE OF"); + strcat( buf, " AGGREGATE OF" ); break; case array_: - strcat(buf, " ARRAY"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.optional) { - strcat(buf, " OPTIONAL"); + strcat( buf, " ARRAY" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.optional ) { + strcat( buf, " OPTIONAL" ); } - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; case bag_: - strcat(buf, " BAG"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " BAG" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case set_: - strcat(buf, " SET"); - strcat_bounds(body, buf); - strcat(buf, " OF"); + strcat( buf, " SET" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); break; case list_: - strcat(buf, " LIST"); - strcat_bounds(body, buf); - strcat(buf, " OF"); - if(body->flags.unique) { - strcat(buf, " UNIQUE"); + strcat( buf, " LIST" ); + strcat_bounds( body, buf ); + strcat( buf, " OF" ); + if( body->flags.unique ) { + strcat( buf, " UNIQUE" ); } break; default: - fprintf(stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type); + fprintf( stderr, "Error in %s, line %d: type %d not handled by switch statement.", __FILE__, __LINE__, body->type ); abort(); } - Type_Description(body->base, buf); + Type_Description( body->base, buf ); break; case enumeration_: - strcat(buf, " ENUMERATION of ("); - LISTdo(body->list, e, Expression) - strcat(buf, ENUMget_name(e)); - strcat(buf, ", "); + strcat( buf, " ENUMERATION of (" ); + LISTdo( body->list, e, Expression ) + strcat( buf, ENUMget_name( e ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; case select_: - strcat(buf, " SELECT ("); - LISTdo(body->list, t, Type) - strcat(buf, PrettyTmpName(TYPEget_name(t))); - strcat(buf, ", "); + strcat( buf, " SELECT (" ); + LISTdo( body->list, t, Type ) + strcat( buf, PrettyTmpName( TYPEget_name( t ) ) ); + strcat( buf, ", " ); LISTod /* find last comma and replace with ')' */ - s = strrchr(buf, ','); - if(s) { - strcpy(s, ")"); + s = strrchr( buf, ',' ); + if( s ) { + strcpy( s, ")" ); } break; default: - strcat(buf, " UNKNOWN"); + strcat( buf, " UNKNOWN" ); } - if(body->precision) { - strcat(buf, " ("); - strcat_expr(body->precision, buf); - strcat(buf, ")"); + if( body->precision ) { + strcat( buf, " (" ); + strcat_expr( body->precision, buf ); + strcat( buf, ")" ); } - if(body->flags.fixed) { - strcat(buf, " FIXED"); + if( body->flags.fixed ) { + strcat( buf, " FIXED" ); } } void -Type_Description(const Type t, char *buf) -{ - if(TYPEget_name(t)) { - strcat(buf, " "); - strcat(buf, TYPEget_name(t)); +Type_Description( const Type t, char * buf ) { + if( TYPEget_name( t ) ) { + strcat( buf, " " ); + strcat( buf, TYPEget_name( t ) ); /* strcat(buf,PrettyTmpName (TYPEget_name(t)));*/ } else { - TypeBody_Description(TYPEget_body(t), buf); + TypeBody_Description( TYPEget_body( t ), buf ); } } @@ -1969,10 +1907,9 @@ Type_Description(const Type t, char *buf) otherwise return 0; If it refers to a type that is a multidimensional aggregate 0 is still returned. */ int -isMultiDimAggregateType(const Type t) -{ - if(TYPEget_body(t)->base) - if(isAggregateType(TYPEget_body(t)->base)) { +isMultiDimAggregateType( const Type t ) { + if( TYPEget_body( t )->base ) + if( isAggregateType( TYPEget_body( t )->base ) ) { return 1; } return 0; @@ -1994,8 +1931,7 @@ isMultiDimAggregateType(const Type t) return the name of the TD that arrlistSetAggr's ArrayTypeDescriptor should reference since it has an Express name associated with it. */ -int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) -{ +int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { (void) t; /* unused - FIXME implement or eliminate this function */ (void) buf; (void) schema; @@ -2014,8 +1950,7 @@ int TYPEget_RefTypeVarNm(const Type t, char *buf, Schema schema) *****/ void -TYPEprint_descriptions(const Type type, FILES *files, Schema schema) -{ +TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { char tdnm [BUFSIZ], typename_buf [MAX_LEN], base [BUFSIZ], @@ -2023,62 +1958,62 @@ TYPEprint_descriptions(const Type type, FILES *files, Schema schema) Type i; int where_rule_number = 0; - strncpy(tdnm, TYPEtd_name(type), BUFSIZ); - tdnm[BUFSIZ - 1] = '\0'; + strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); + tdnm[BUFSIZ-1] = '\0'; - if(TYPEis_enumeration(type) && (i = TYPEget_ancestor(type)) != NULL) { + if( TYPEis_enumeration( type ) && ( i = TYPEget_ancestor( type ) ) != NULL ) { /* If we're a renamed enum type, just print a few typedef's to the original and some specialized create functions: */ - strncpy(base, StrToLower(EnumName(TYPEget_name(i))), BUFSIZ); - base[BUFSIZ - 1] = '\0'; - strncpy(nm, StrToLower(EnumName(TYPEget_name(type))), BUFSIZ); - nm[BUFSIZ - 1] = '\0'; - fprintf(files->lib, "%s = %s\n", nm, base); + strncpy( base, StrToLower( EnumName( TYPEget_name( i ) ) ), BUFSIZ ); + base[BUFSIZ-1]='\0'; + strncpy( nm, StrToLower( EnumName( TYPEget_name( type ) ) ), BUFSIZ ); + nm[BUFSIZ-1]='\0'; + fprintf( files->lib, "%s = %s\n", nm, base ); return; } - if(TYPEget_RefTypeVarNm(type, typename_buf, schema)) { - const char *output = FundamentalType(type, 0); - if(TYPEis_aggregate(type)) { - fprintf(files->lib, "%s = ", TYPEget_name(type)); - process_aggregate(files->lib, type); - fprintf(files->lib, "\n"); - } else if(TYPEis_boolean(type)) { - fprintf(files->lib, "%s = bool\n", TYPEget_name(type)); - } else if(TYPEis_select(type)) { - TYPEselect_lib_print(type, files -> lib); - } else if(TYPEis_enumeration(type)) { - TYPEenum_lib_print(type, files -> lib); - } else { + if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) { + const char * output = FundamentalType( type, 0 ); + if( TYPEis_aggregate( type ) ) { + fprintf( files->lib, "%s = ", TYPEget_name( type ) ); + process_aggregate( files->lib, type ); + fprintf( files->lib, "\n" ); + } else if( TYPEis_boolean( type ) ) { + fprintf( files->lib, "%s = bool\n", TYPEget_name( type ) ); + } else if( TYPEis_select( type ) ) { + TYPEselect_lib_print( type, files -> lib ); + } else if( TYPEis_enumeration( type ) ) { + TYPEenum_lib_print( type, files -> lib ); + } else { /* the defined datatype inherits from the base type */ - fprintf(files->lib, "# Defined datatype %s\n", TYPEget_name(type)); - fprintf(files->lib, "class %s(", TYPEget_name(type)); - if(TYPEget_head(type) != NULL) { - fprintf(files->lib, "%s):\n", TYPEget_name(TYPEget_head(type))); + fprintf( files->lib, "# Defined datatype %s\n", TYPEget_name( type ) ); + fprintf( files->lib, "class %s(", TYPEget_name( type ) ); + if( TYPEget_head( type ) != NULL ) { + fprintf( files->lib, "%s):\n", TYPEget_name( TYPEget_head( type ) ) ); } else { - fprintf(files->lib, "%s):\n", output); + fprintf( files->lib, "%s):\n", output ); } - fprintf(files->lib, "\tdef __init__(self,*kargs):\n"); - fprintf(files->lib, "\t\tpass\n"); + fprintf( files->lib, "\tdef __init__(self,*kargs):\n" ); + fprintf( files->lib, "\t\tpass\n" ); /* call the where / rules */ - LISTdo(type->where, w, Where) - if(strcmp(w->label->name, "")) { + LISTdo( type->where, w, Where ) + if( strcmp( w->label->name, "" ) ) { /* define a function with the name 'label' */ - fprintf(files->lib, "\t\tself.%s()\n", w->label->name); + fprintf( files->lib, "\t\tself.%s()\n", w->label->name ); } else { /* no label */ - fprintf(files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number); + fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number ); where_rule_number ++; } LISTod - fprintf(files->lib, "\n"); + fprintf( files->lib, "\n" ); /* then we process the where rules */ - WHEREPrint(type->where, 0, files->lib); + WHEREPrint( type->where, 0, files->lib ); } } else { /* TODO: cleanup, currently this is deadcode */ - switch(TYPEget_body(type)->type) { + switch( TYPEget_body( type )->type ) { case enumeration_: - TYPEenum_lib_print(type, files -> lib); + TYPEenum_lib_print( type, files -> lib ); break; case select_: break; diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index dbc6e9a50..21c16d1c4 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -4,7 +4,7 @@ #include "complexSupport.h" -void use_ref(Schema, Express, FILES *); +void use_ref( Schema, Express, FILES * ); /****************************************************************** ** SCHEMA SECTION **/ @@ -22,21 +22,20 @@ void use_ref(Schema, Express, FILES *); ** organization of the schemas in the input Express ******************************************************************/ -void SCOPEPrint(Scope scope, FILES *files, Schema schema) -{ - Linked_List list = SCOPEget_entities_superclass_order(scope); - Linked_List function_list = SCOPEget_functions(scope); - Linked_List rule_list = SCOPEget_rules(scope); +void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { + Linked_List list = SCOPEget_entities_superclass_order( scope ); + Linked_List function_list = SCOPEget_functions( scope ); + Linked_List rule_list = SCOPEget_rules( scope ); DictionaryEntry de; Type i; int redefs = 0;// index = 0; /* Defined Types based on SIMPLE types */ - SCOPEdo_types(scope, t, de) - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) - && (TYPEget_ancestor(t) == NULL)) { - TYPEprint_descriptions(t, files, schema); + SCOPEdo_types( scope, t, de ) + if ( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) + && ( TYPEget_ancestor( t ) == NULL) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } SCOPEod @@ -44,12 +43,12 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) /* Defined Types with defined ancestor head * TODO: recursive approach */ - SCOPEdo_types(scope, t, de) - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) || TYPEis_select(t) || TYPEis_aggregate(t)) - && ((i = TYPEget_head(t)) != NULL)) { - if(i->search_id == PROCESSED) { - TYPEprint_descriptions(t, files, schema); + SCOPEdo_types( scope, t, de ) + if ( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) + && ( ( i = TYPEget_head( t ) ) != NULL ) ) { + if (i->search_id == PROCESSED) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } } @@ -59,27 +58,27 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) /* and print the enumerations */ //fprintf( files -> inc, "\n/*\t************** TYPES \t*/\n" ); //fprintf( files -> lib, "\n/*\t************** TYPES \t*/\n" ); - SCOPEdo_types(scope, t, de) + SCOPEdo_types( scope, t, de ) // First check for one exception: Say enumeration type B is defined // to be a rename of enum A. If A is in this schema but has not been // processed yet, we must wait till it's processed first. The reason // is because B will basically be defined with a couple of typedefs to // the classes which represent A. (To simplify, we wait even if A is // in another schema, so long as it's been processed.) - if((t->search_id == CANPROCESS) - && (TYPEis_enumeration(t)) - && ((i = TYPEget_ancestor(t)) != NULL) - && (i->search_id >= CANPROCESS)) { + if( ( t->search_id == CANPROCESS ) + && ( TYPEis_enumeration( t ) ) + && ( ( i = TYPEget_ancestor( t ) ) != NULL ) + && ( i->search_id >= CANPROCESS ) ) { redefs = 1; } SCOPEod - SCOPEdo_types(scope, t, de) + SCOPEdo_types( scope, t, de ) // Do the non-redefined enumerations: - if((t->search_id == CANPROCESS) - && !(TYPEis_enumeration(t) && TYPEget_head(t))) { - TYPEprint_descriptions(t, files, schema); - if(!TYPEis_select(t)) { + if( ( t->search_id == CANPROCESS ) + && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { + TYPEprint_descriptions( t, files, schema ); + if( !TYPEis_select( t ) ) { // Selects have a lot more processing and are done below. t->search_id = PROCESSED; } @@ -87,10 +86,10 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) SCOPEod; // process redifined enumerations - if(redefs) { - SCOPEdo_types(scope, t, de) - if(t->search_id == CANPROCESS && TYPEis_enumeration(t)) { - TYPEprint_descriptions(t, files, schema); + if( redefs ) { + SCOPEdo_types( scope, t, de ) + if( t->search_id == CANPROCESS && TYPEis_enumeration( t ) ) { + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } SCOPEod; @@ -101,8 +100,8 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) // Note - say we have sel B, rename of sel A (as above by enum's). Here // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). - SCOPEdo_types(scope, t, de) - if(t->search_id == CANPROCESS) { + SCOPEdo_types( scope, t, de ) + if( t->search_id == CANPROCESS ) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. //FIXME this function is not implemented! @@ -112,25 +111,25 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) SCOPEod; // process each entity. This must be done *before* typedefs are defined - LISTdo(list, e, Entity); - if(e->search_id == CANPROCESS) { - ENTITYPrint(e, files); + LISTdo( list, e, Entity ); + if( e->search_id == CANPROCESS ) { + ENTITYPrint( e, files ); e->search_id = PROCESSED; } LISTod; - LISTfree(list); + LISTfree( list ); // process each function. This must be done *before* typedefs are defined - LISTdo(function_list, f, Function); - FUNCPrint(f, files); + LISTdo( function_list, f, Function ); + FUNCPrint( f, files ); LISTod; - LISTfree(function_list); + LISTfree( function_list ); // process each rule. This must be done *before* typedefs are defined - LISTdo(rule_list, r, Rule); - RULEPrint(r, files); + LISTdo( rule_list, r, Rule ); + RULEPrint( r, files ); LISTod; - LISTfree(rule_list); + LISTfree( rule_list ); } @@ -151,60 +150,52 @@ void SCOPEPrint(Scope scope, FILES *files, Schema schema) ** Status: ******************************************************************/ -void SCHEMAprint(Schema schema, FILES *files, int suffix) -{ - int ocnt = 0; +void SCHEMAprint( Schema schema, FILES * files, int suffix ) { char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ - FILE *libfile; + FILE * libfile; /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(schnm, "%s", SCHEMAget_name(schema)); - if(suffix == 0) { - sprintf(sufnm, "%s", schnm); + sprintf( schnm, "%s", SCHEMAget_name( schema ) ); + if( suffix == 0 ) { + sprintf( sufnm, "%s", schnm ); } else { - ocnt = snprintf(sufnm, MAX_LEN, "%s_%d", schnm, suffix); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; - } - } - ocnt = snprintf(fnm, MAX_LEN, "%s.h", sufnm); - if(ocnt > MAX_LEN) { - std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; + sprintf( sufnm, "%s_%d", schnm, suffix ); } + sprintf( fnm, "%s.h", sufnm ); - np = fnm + strlen(fnm) - 1; /* point to end of constant part of string */ + np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 2. class source file */ - sprintf(np, "py"); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + sprintf( np, "py" ); + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } - fprintf(libfile, "import sys\n"); - fprintf(libfile, "\n"); - fprintf(libfile, "from SCL.SCLBase import *\n"); - fprintf(libfile, "from SCL.SimpleDataTypes import *\n"); - fprintf(libfile, "from SCL.ConstructedDataTypes import *\n"); - fprintf(libfile, "from SCL.AggregationDataTypes import *\n"); - fprintf(libfile, "from SCL.TypeChecker import check_type\n"); - fprintf(libfile, "from SCL.Builtin import *\n"); - fprintf(libfile, "from SCL.Rules import *\n"); + fprintf( libfile, "import sys\n" ); + fprintf( libfile, "\n" ); + fprintf( libfile, "from SCL.SCLBase import *\n" ); + fprintf( libfile, "from SCL.SimpleDataTypes import *\n" ); + fprintf( libfile, "from SCL.ConstructedDataTypes import *\n" ); + fprintf( libfile, "from SCL.AggregationDataTypes import *\n" ); + fprintf( libfile, "from SCL.TypeChecker import check_type\n" ); + fprintf( libfile, "from SCL.Builtin import *\n" ); + fprintf( libfile, "from SCL.Rules import *\n" ); /********* export schema name *******/ - fprintf(libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name(schema)); + fprintf( libfile, "\nschema_name = '%s'\n\n", SCHEMAget_name( schema ) ); /******** export schema scope *******/ - fprintf(libfile, "schema_scope = sys.modules[__name__]\n\n"); + fprintf( libfile, "schema_scope = sys.modules[__name__]\n\n" ); /********** do the schemas ***********/ /* really, create calls for entity constructors */ - SCOPEPrint(schema, files, schema); + SCOPEPrint( schema, files, schema ); /********** close the files ***********/ - FILEclose(libfile); + FILEclose( libfile ); //FILEclose( incfile ); //if( schema->search_id == PROCESSED ) { // fprintf( initfile, "\n}\n" ); @@ -228,37 +219,36 @@ void SCHEMAprint(Schema schema, FILES *files, int suffix) ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) -{ +getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { DictionaryEntry de; Schema schema; - fprintf(schema_h, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n"); - fprintf(schema_cc, "%s%s%s%s", - "// Generate a function to be called by Model to help it\n", - "// create the necessary Model_contents without the\n", - "// dictionary (Registry) handle since it doesn't have a\n", - "// predetermined way to access to the handle.\n"); - fprintf(schema_cc, - "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n"); - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - schema = (Scope)DICTdo(&de); - fprintf(schema_cc, - " if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name(schema)); - fprintf(schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name(schema)); - while((schema = (Scope)DICTdo(&de)) != 0) { - fprintf(schema_cc, - " else if(!strcmp(schemaName, \"%s\"))\n", - SCHEMAget_name(schema)); - fprintf(schema_cc, - " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", - SCHEMAget_name(schema)); + fprintf( schema_h, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n" ); + fprintf( schema_cc, "%s%s%s%s", + "// Generate a function to be called by Model to help it\n", + "// create the necessary Model_contents without the\n", + "// dictionary (Registry) handle since it doesn't have a\n", + "// predetermined way to access to the handle.\n" ); + fprintf( schema_cc, + "\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName)\n{\n" ); + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + schema = ( Scope )DICTdo( &de ); + fprintf( schema_cc, + " if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name( schema ) ); + fprintf( schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name( schema ) ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + fprintf( schema_cc, + " else if(!strcmp(schemaName, \"%s\"))\n", + SCHEMAget_name( schema ) ); + fprintf( schema_cc, + " return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n", + SCHEMAget_name( schema ) ); } - fprintf(schema_cc, "}\n"); + fprintf( schema_cc, "}\n" ); } /****************************************************************** @@ -274,11 +264,10 @@ getMCPrint(Express express, FILE *schema_h, FILE *schema_cc) ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void -EXPRESSPrint(Express express, FILES *files) -{ +EXPRESSPrint( Express express, FILES * files ) { char fnm [MAX_LEN]; - const char *schnm; /* schnm is really "express name" */ - FILE *libfile; + const char * schnm; /* schnm is really "express name" */ + FILE * libfile; /* new */ Schema schema; DictionaryEntry de; @@ -287,23 +276,23 @@ EXPRESSPrint(Express express, FILES *files) /********** create files based on name of schema ***********/ /* return if failure */ /* 1. header file */ - sprintf(fnm, "%s.h", schnm = ClassName(EXPRESSget_basename(express))); + sprintf( fnm, "%s.h", schnm = ClassName( EXPRESSget_basename( express ) ) ); /* 2. class source file */ //sprintf( np, "cc" ); - if(!(libfile = (files -> lib) = FILEcreate(fnm))) { + if( !( libfile = ( files -> lib ) = FILEcreate( fnm ) ) ) { return; } /********** do all schemas ***********/ - DICTdo_init(express->symbol_table, &de); - while(0 != (schema = (Scope)DICTdo(&de))) { - SCOPEPrint(schema, files, schema); + DICTdo_init( express->symbol_table, &de ); + while( 0 != ( schema = ( Scope )DICTdo( &de ) ) ) { + SCOPEPrint( schema, files, schema ); } /********** close the files ***********/ - FILEclose(libfile); + FILEclose( libfile ); //FILEclose( incfile ); //fprintf( initfile, "\n}\n" ); //FILEclose( initfile ); @@ -323,10 +312,9 @@ EXPRESSPrint(Express express, FILES *files) ******************************************************************/ void -print_schemas_combined(Express express, FILES *files) -{ +print_schemas_combined( Express express, FILES * files ) { - EXPRESSPrint(express, files); + EXPRESSPrint( express, files ); } /* @@ -341,18 +329,17 @@ print_schemas_combined(Express express, FILES *files) */ void -print_file(Express express) -{ - extern void RESOLUTIONsucceed(void); +print_file( Express express ) { + extern void RESOLUTIONsucceed( void ); int separate_schemas = 1; File_holder files; resolution_success(); - if(separate_schemas) { - print_schemas_separate(express, &files); + if( separate_schemas ) { + print_schemas_separate( express, &files ); } else { - print_schemas_combined(express, &files); + print_schemas_combined( express, &files ); } } diff --git a/src/exp2python/src/complexSupport.h b/src/exp2python/src/complexSupport.h index 2f6731724..7cd781a37 100644 --- a/src/exp2python/src/complexSupport.h +++ b/src/exp2python/src/complexSupport.h @@ -63,8 +63,7 @@ class OrList; class ComplexList; class ComplexCollect; -class EntNode -{ +class EntNode { friend class SimpleList; friend class AndOrList; friend class AndList; @@ -72,59 +71,48 @@ class EntNode friend class ComplexList; public: - EntNode(const char *nm = "") : next(0), mark(NOMARK), - multSupers(0) - { - strcpy(name, nm); - } - EntNode(char *[]); // given a list, create a linked list of EntNodes - ~EntNode() - { - if(next) { + EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), + multSupers( 0 ) { + strcpy( name, nm ); + } + EntNode( char *[] ); // given a list, create a linked list of EntNodes + ~EntNode() { + if( next ) { delete next; } } - operator const char *() - { + operator const char * () { return name; } - int operator== (EntNode &ent) - { - return (strcmp(name, ent.name) == 0); + int operator== ( EntNode & ent ) { + return ( strcmp( name, ent.name ) == 0 ); } - int operator< (EntNode &ent) - { - return (strcmp(name, ent.name) < 0); + int operator< ( EntNode & ent ) { + return ( strcmp( name, ent.name ) < 0 ); } - int operator> (EntNode &ent) - { - return (strcmp(name, ent.name) > 0); + int operator> ( EntNode & ent ) { + return ( strcmp( name, ent.name ) > 0 ); } - void setmark(MarkType stamp = MARK) - { + void setmark( MarkType stamp = MARK ) { mark = stamp; } - void markAll(MarkType = MARK); - void unmarkAll() - { - markAll(NOMARK); + void markAll( MarkType = MARK ); + void unmarkAll() { + markAll( NOMARK ); } - int marked(MarkType base = ORMARK) - { - return (mark >= base); + int marked( MarkType base = ORMARK ) { + return ( mark >= base ); } int allMarked(); // returns TRUE if all nodes in list are marked int unmarkedCount(); - int multSuprs() - { + int multSuprs() { return multSupers; } - void multSuprs(int j) - { + void multSuprs( int j ) { multSupers = j; } - EntNode *next; + EntNode * next; private: MarkType mark; @@ -132,79 +120,68 @@ class EntNode int multSupers; // do I correspond to an entity with >1 supertype? }; -class EntList -{ +class EntList { friend class MultList; friend class JoinList; friend class OrList; friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, EntList &); - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, EntList & ); + friend ostream & operator<< ( ostream &, MultList & ); public: - EntList(JoinType j) : join(j), prev(0), next(0), viable(UNKNOWN), - level(0) {} + EntList( JoinType j ) : join( j ), prev( 0 ), next( 0 ), viable( UNKNOWN ), + level( 0 ) {} virtual ~EntList() {} - MatchType viableVal() - { + MatchType viableVal() { return viable; } - virtual void setLevel(int l) - { + virtual void setLevel( int l ) { level = l; } - virtual int getMaxLevel() - { + virtual int getMaxLevel() { return level; } - virtual int contains(const char *) = 0; - virtual int hit(const char *) = 0; - virtual int isDependent(const char *) = 0; - virtual MatchType matchNonORs(EntNode *) - { + virtual int contains( const char * ) = 0; + virtual int hit( const char * ) = 0; + virtual int isDependent( const char * ) = 0; + virtual MatchType matchNonORs( EntNode * ) { return UNKNOWN; } - virtual int acceptChoice(EntNode *) = 0; - virtual void unmarkAll(EntNode *) = 0; - virtual void reset() - { + virtual int acceptChoice( EntNode * ) = 0; + virtual void unmarkAll( EntNode * ) = 0; + virtual void reset() { viable = UNKNOWN; } int siblings(); - virtual void write(ostream &) = 0; + virtual void write( ostream & ) = 0; // write out my contents to stream // List access functions. They access desired children based on their // join or viable values. Below is an incomplete list of possible fns, // but all we need. - EntList *firstNot(JoinType); - EntList *nextNot(JoinType j) - { - return next->firstNot(j); + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { + return next->firstNot( j ); } - EntList *firstWanted(MatchType); - EntList *nextWanted(MatchType mat) - { - return next->firstWanted(mat); + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { + return next->firstWanted( mat ); } - EntList *lastNot(JoinType); - EntList *prevNot(JoinType j) - { - return prev->lastNot(j); + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { + return prev->lastNot( j ); } - EntList *lastWanted(MatchType); - EntList *prevWanted(MatchType mat) - { - return prev->lastWanted(mat); + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { + return prev->lastWanted( mat ); } JoinType join; - int multiple() - { - return (join != SIMPLE); + int multiple() { + return ( join != SIMPLE ); } - EntList *prev, * next; + EntList * prev, * next; protected: MatchType viable; @@ -216,153 +193,137 @@ class EntList int level; // How many levels deep are we (main use for printing). }; -class SimpleList : public EntList -{ +class SimpleList : public EntList { friend class ComplexList; - friend ostream &operator<< (ostream &, SimpleList &); + friend ostream & operator<< ( ostream &, SimpleList & ); public: - SimpleList(const char *n) : EntList(SIMPLE), I_marked(NOMARK) - { - strcpy(name, n); + SimpleList( const char * n ) : EntList( SIMPLE ), I_marked( NOMARK ) { + strcpy( name, n ); } ~SimpleList() {} - int operator== (const char *nm) - { - return (strcmp(name, nm) == 0); + int operator== ( const char * nm ) { + return ( strcmp( name, nm ) == 0 ); } - const char *Name() - { + const char * Name() { return name; } - int contains(const char *nm) - { + int contains( const char * nm ) { return *this == nm; } - int hit(const char *nm) - { + int hit( const char * nm ) { return *this == nm; } - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - int acceptChoice(EntNode *); - void unmarkAll(EntNode *); - void reset() - { + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + int acceptChoice( EntNode * ); + void unmarkAll( EntNode * ); + void reset() { viable = UNKNOWN; I_marked = NOMARK; } - void write(ostream &); + void write( ostream & ); private: char name[BUFSIZ]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; -class MultList : public EntList -{ +class MultList : public EntList { // Supports concepts and functionality common to all the compound list // types, especially AND and ANDOR. friend class ComplexList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, MultList &); + friend ostream & operator<< ( ostream &, MultList & ); public: - MultList(JoinType j) : EntList(j), numchildren(0), childList(0) {} + MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {} ~MultList(); - void setLevel(int); + void setLevel( int ); int getMaxLevel(); - int contains(const char *); - int hit(const char *); - int isDependent(const char *); - void appendList(EntList *); - EntList *copyList(EntList *); - void processSubExp(Expression, Entity, ComplexCollect *); - void addSimpleAndSubs(Entity, ComplexCollect *); - virtual MatchType matchORs(EntNode *) = 0; - virtual MatchType tryNext(EntNode *); - - int childCount() - { + int contains( const char * ); + int hit( const char * ); + int isDependent( const char * ); + void appendList( EntList * ); + EntList * copyList( EntList * ); + void processSubExp( Expression, Entity, ComplexCollect * ); + void addSimpleAndSubs( Entity, ComplexCollect * ); + virtual MatchType matchORs( EntNode * ) = 0; + virtual MatchType tryNext( EntNode * ); + + int childCount() { return numchildren; } // EntList *operator[]( int ); - EntList *getChild(int); - EntList *getLast() - { - return (getChild(numchildren - 1)); + EntList * getChild( int ); + EntList * getLast() { + return ( getChild( numchildren - 1 ) ); } - void unmarkAll(EntNode *); - int prevKnown(EntList *); + void unmarkAll( EntNode * ); + int prevKnown( EntList * ); void reset(); - void write(ostream &); + void write( ostream & ); protected: int numchildren; - EntList *childList; + EntList * childList; // Points to a list of "children" of this EntList. E.g., if join = // AND, it would point to a list of the entity types we are AND'ing. // The children may be SIMPLE EntLists (contain entity names) or may // themselves be And-, Or-, or AndOrLists. }; -class JoinList : public MultList -{ +class JoinList : public MultList { // A specialized MultList, super for subtypes AndOrList and AndList, or // ones which join their multiple children. public: - JoinList(JoinType j) : MultList(j) {} + JoinList( JoinType j ) : MultList( j ) {} ~JoinList() {} - void setViableVal(EntNode *); - int acceptChoice(EntNode *); + void setViableVal( EntNode * ); + int acceptChoice( EntNode * ); }; -class AndOrList : public JoinList -{ +class AndOrList : public JoinList { friend class ComplexList; public: - AndOrList() : JoinList(ANDOR) {} + AndOrList() : JoinList( ANDOR ) {} ~AndOrList() {} - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); }; -class AndList : public JoinList -{ +class AndList : public JoinList { friend class MultList; friend class ComplexList; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - AndList() : JoinList(AND), supertype(0) {} + AndList() : JoinList( AND ), supertype( 0 ) {} ~AndList() {} - int isDependent(const char *); - MatchType matchNonORs(EntNode *); - MatchType matchORs(EntNode *); + int isDependent( const char * ); + MatchType matchNonORs( EntNode * ); + MatchType matchORs( EntNode * ); private: int supertype; // do I represent a supertype? }; -class OrList : public MultList -{ +class OrList : public MultList { public: - OrList() : MultList(OR), choice(-1), choice1(-2), choiceCount(0) {} + OrList() : MultList( OR ), choice( -1 ), choice1( -2 ), choiceCount( 0 ) {} ~OrList() {} - int hit(const char *); - MatchType matchORs(EntNode *); - MatchType tryNext(EntNode *); - void unmarkAll(EntNode *); - int acceptChoice(EntNode *); - int acceptNextChoice(EntNode *ents) - { + int hit( const char * ); + MatchType matchORs( EntNode * ); + MatchType tryNext( EntNode * ); + void unmarkAll( EntNode * ); + int acceptChoice( EntNode * ); + int acceptNextChoice( EntNode * ents ) { choice++; - return (acceptChoice(ents)); + return ( acceptChoice( ents ) ); } - void reset() - { + void reset() { choice = -1; choice1 = -2; choiceCount = 0; @@ -375,101 +336,90 @@ class OrList : public MultList // the first viable choice; and how many choices are there entirely. }; -class ComplexList -{ +class ComplexList { // Contains the entire list of EntLists which describe the set of // instantiable complex entities defined by an EXPRESS expression. friend class MultList; friend class ComplexCollect; - friend ostream &operator<< (ostream &, ComplexList &); + friend ostream & operator<< ( ostream &, ComplexList & ); public: - ComplexList(AndList *alist = NULL) : list(0), head(alist), next(0), - abstract(0), dependent(0), - multSupers(0) {} - ComplexList(Entity, ComplexCollect *); + ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ), + abstract( 0 ), dependent( 0 ), + multSupers( 0 ) {} + ComplexList( Entity, ComplexCollect * ); ~ComplexList(); void buildList(); void remove(); - int operator< (ComplexList &c) - { - return (strcmp(supertype(), c.supertype()) < 0); + int operator< ( ComplexList & c ) { + return ( strcmp( supertype(), c.supertype() ) < 0 ); } - int operator< (char *name) - { - return (strcmp(supertype(), name) < 0); + int operator< ( char * name ) { + return ( strcmp( supertype(), name ) < 0 ); } - int operator== (char *name) - { - return (strcmp(supertype(), name) == 0); + int operator== ( char * name ) { + return ( strcmp( supertype(), name ) == 0 ); } - const char *supertype() - { - return ((SimpleList *)head->childList)->name; + const char * supertype() { + return ( ( SimpleList * )head->childList )->name; } // Based on knowledge that ComplexList always created by ANDing supertype // with subtypes. - int toplevel(const char *); - int contains(EntNode *); - int matches(EntNode *); - int isDependent(const char *); + int toplevel( const char * ); + int contains( EntNode * ); + int matches( EntNode * ); + int isDependent( const char * ); - EntNode *list; // List of all entities contained in this complex type, + EntNode * list; // List of all entities contained in this complex type, // regardless of how. (Used as a quick way of determining // if this List *may* contain a certain complex type.) - AndList *head; - ComplexList *next; - int Dependent() - { + AndList * head; + ComplexList * next; + int Dependent() { return dependent; } - void write(ostream &); - int getEntListMaxLevel() - { + void write( ostream & ); + int getEntListMaxLevel() { return head->getMaxLevel(); } private: - void addSuper(Entity); - void addSubExp(Expression); - void addImplicitSubs(Linked_List, ComplexCollect *); - void addChildren(EntList *); - int hitMultNodes(EntNode *); + void addSuper( Entity ); + void addSubExp( Expression ); + void addImplicitSubs( Linked_List, ComplexCollect * ); + void addChildren( EntList * ); + int hitMultNodes( EntNode * ); int abstract; // is our supertype abstract? int dependent; // is our supertype also a subtype of other supertype(s)? int multSupers; // am I a combo-CList created to test a subtype which has int maxlevel; }; // >1 supertypes? -class ComplexCollect -{ +class ComplexCollect { // The collection of all the ComplexLists defined by the current schema. public: - ComplexCollect(ComplexList *c = NULL) : clists(c) - { - count = (c ? 1 : 0); + ComplexCollect( ComplexList * c = NULL ) : clists( c ) { + count = ( c ? 1 : 0 ); } - ComplexCollect(Express); - ~ComplexCollect() - { + ComplexCollect( Express ); + ~ComplexCollect() { delete clists; } - void insert(ComplexList *); - void remove(ComplexList *); + void insert( ComplexList * ); + void remove( ComplexList * ); // Remove this list but don't delete its hierarchy structure, because // it's used elsewhere. - ComplexList *find(char *); - int supports(EntNode *); - int externMapping(const char *ent) - { - return (clists ? clists->isDependent(ent) : 0); + ComplexList * find( char * ); + int supports( EntNode * ); + int externMapping( const char * ent ) { + return ( clists ? clists->isDependent( ent ) : 0 ); } // One of our clists shows that ent will have to be instantiated // using external mapping (see Part 21, sect 11.2.5.1). - void write(const char *); + void write( const char * ); - ComplexList *clists; + ComplexList * clists; private: int count; // # of clist children @@ -477,6 +427,6 @@ class ComplexCollect // Standalone function which can be used to print out the complex info in an // express file (prints out CCollect, CList & EntList instant. statements): -void print_complex(ComplexCollect &, const char *); +void print_complex( ComplexCollect &, const char * ); #endif diff --git a/src/exp2python/src/fedex_main_python.c b/src/exp2python/src/fedex_main_python.c index d8d379ce9..be7bdd242 100644 --- a/src/exp2python/src/fedex_main_python.c +++ b/src/exp2python/src/fedex_main_python.c @@ -11,56 +11,52 @@ #include "../express/express.h" #include "../express/resolve.h" -extern void print_fedex_version(void); +extern void print_fedex_version( void ); -static void exp2python_usage(void) -{ +static void exp2python_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "\t-v produces the version description below\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); + fprintf( stderr, "usage: %s [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "\t-v produces the version description below\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); print_fedex_version(); - exit(2); + exit( 2 ); } -int Handle_FedPlus_Args(int, char *); -void print_file(Express); +int Handle_FedPlus_Args( int, char * ); +void print_file( Express ); -void resolution_success(void) -{ - printf("Resolution successful.\nWriting python module..."); +void resolution_success( void ) { + printf( "Resolution successful.\nWriting python module..." ); } -int success(Express model) -{ +int success( Express model ) { (void) model; /* unused */ - printf("Done.\n"); - return(0); + printf( "Done.\n" ); + return( 0 ); } /* This function is called from main() which is part of the NIST Express Toolkit. It assigns 2 pointers to functions which are called in main() */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { EXPRESSbackend = print_file; EXPRESSsucceed = success; EXPRESSgetopt = Handle_FedPlus_Args; /* so the function getopt (see man 3 getopt) will not report an error */ - strcat(EXPRESSgetopt_options, "sSLcCaA"); + strcat( EXPRESSgetopt_options, "sSLcCaA" ); ERRORusage_function = exp2python_usage; } diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index efc46a7b1..ece7e6617 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -37,22 +37,22 @@ #define FALSE 0 #define TRUE 1 -int isAggregateType(const Type t); +int isAggregateType( const Type t ); /* Local function prototypes: */ -static void initializeMarks(Express); -static void unsetObjs(Schema); -static int checkTypes(Schema); -static int checkEnts(Schema); -static void markDescs(Entity); -static int checkItem(Type, Scope, Schema, int *, int); -static int ENUMcanBeProcessed(Type, Schema); -static int inSchema(Scope, Scope); +static void initializeMarks( Express ); +static void unsetObjs( Schema ); +static int checkTypes( Schema ); +static int checkEnts( Schema ); +static void markDescs( Entity ); +static int checkItem( Type, Scope, Schema, int *, int ); +static int ENUMcanBeProcessed( Type, Schema ); +static int inSchema( Scope, Scope ); /* static void addRenameTypedefs( Schema, FILE * ); */ -static void addAggrTypedefs(Schema schema); -static void addUseRefNames(Schema, FILE *); +static void addAggrTypedefs( Schema schema ); +static void addUseRefNames( Schema, FILE * ); -void print_schemas_separate(Express express, FILES *files) +void print_schemas_separate( Express express, FILES * files ) /* * Generates the C++ files corresponding to a list of schemas. Does so in * multiple passes through the schemas. In each pass it checks for enti- @@ -69,31 +69,31 @@ void print_schemas_separate(Express express, FILES *files) Schema schema; /* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */ - initializeMarks(express); + initializeMarks( express ); /* FIXME SdaiAll.cc:12:24: warning: unused variable ‘is’ [-Wunused-variable] (also for ui & ri) */ /* fprintf( files->create, " Interface_spec_ptr is;\n Used_item_ptr ui;\n Referenced_item_ptr ri;\n Uniqueness_rule_ptr ur;\n Where_rule_ptr wr;\n Global_rule_ptr gr;\n" ); */ - while(!complete) { + while( !complete ) { complete = TRUE; - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { - if(schema->search_id == UNPROCESSED) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { + if( schema->search_id == UNPROCESSED ) { /* i.e., if the schema has more ents/types to process in it */ - unsetObjs(schema); + unsetObjs( schema ); /* Unset the ones which had search_id = CANTPROCESS. We're // going to check that again since things may have changed by // this pass. The ones with search_id = PROCESSED do not // change since we're done with them. */ schema->search_id = PROCESSED; /* We assume this is the case unless something goes wrong. */ - val1 = checkTypes(schema); - val2 = checkEnts(schema); + val1 = checkTypes( schema ); + val2 = checkEnts( schema ); /* The check functions recheck all the ents, types, USEd, and // REFs which are still NOTKNOWN to see if we can process any // more this pass. If any returns TRUE, we'll process again // this round. */ - if(val1 || val2) { - if(schema->search_id == UNPROCESSED || - *(int *)schema->clientData > 0) { + if( val1 || val2 ) { + if( schema->search_id == UNPROCESSED || + *( int * )schema->clientData > 0 ) { /* What we're trying to determine here is if we will // need to print multiple files for this schema. If // we're already beyond a first file (2nd condition) @@ -103,13 +103,13 @@ void print_schemas_separate(Express express, FILES *files) // printed in multiple files. If so, SCHEMAprint() // will create files with the suffixes "_1", "_2", etc. // If not, no file suffix will be added. */ - suffix = ++*(int *)schema->clientData; - SCHEMAprint(schema, files, suffix); + suffix = ++*( int * )schema->clientData; + SCHEMAprint( schema, files, suffix ); } else { - SCHEMAprint(schema, files, 0); + SCHEMAprint( schema, files, 0 ); } } - complete = complete && (schema->search_id == PROCESSED); + complete = complete && ( schema->search_id == PROCESSED ); /* Job's not complete so long as schema still has entities it // had to skip. */ } @@ -131,18 +131,18 @@ void print_schemas_separate(Express express, FILES *files) /* Before closing, we have three more situations to deal with (i.e., three // types of declarations etc. which could only be printed at the end). // Each is explained in the header section of its respective function. */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* (These two tasks are totally unrelated but are done in the same loop // for efficiency.) */ - addUseRefNames(schema, files->create); + addUseRefNames( schema, files->create ); } /* Third situation: (Must be dealt with after first, see header comments // of addAggrTypedefs.) */ - DICTdo_type_init(express->symbol_table, &de, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de)) != 0) { + DICTdo_type_init( express->symbol_table, &de, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de ) ) != 0 ) { /* addAggrTypedefs( schema, files->classes ); */ - addAggrTypedefs(schema); + addAggrTypedefs( schema ); } /* On our way out, print the necessary statements to add support for @@ -168,20 +168,19 @@ void print_schemas_separate(Express express, FILES *files) * an attribute/item which comes from another schema. All other types can * be processed the first time, but that will be caught in checkTypes().) */ -static void initializeMarks(Express express) -{ +static void initializeMarks( Express express ) { DictionaryEntry de_sch, de_ent, de_type; Schema schema; - DICTdo_type_init(express->symbol_table, &de_sch, OBJ_SCHEMA); - while((schema = (Scope)DICTdo(&de_sch)) != 0) { + DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); + while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { schema->search_id = UNPROCESSED; - schema->clientData = (int *)malloc(sizeof(int)); - *(int *)schema->clientData = 0; - SCOPEdo_entities(schema, ent, de_ent) + schema->clientData = ( int * )malloc( sizeof( int ) ); + *( int * )schema->clientData = 0; + SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; SCOPEod - SCOPEdo_types(schema, t, de_type) + SCOPEdo_types( schema, t, de_type ) t->search_id = NOTKNOWN; SCOPEod } @@ -196,17 +195,16 @@ static void initializeMarks(Express express) * types which have already been marked PROCESSED will not have to be * revisited, and are not changed. */ -static void unsetObjs(Schema schema) -{ +static void unsetObjs( Schema schema ) { DictionaryEntry de; - SCOPEdo_types(schema, t, de) - if(t->search_id == CANTPROCESS) { + SCOPEdo_types( schema, t, de ) + if( t->search_id == CANTPROCESS ) { t->search_id = NOTKNOWN; } SCOPEod - SCOPEdo_entities(schema, ent, de) - if(ent->search_id == CANTPROCESS) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id == CANTPROCESS ) { ent->search_id = NOTKNOWN; } SCOPEod @@ -224,8 +222,7 @@ static void unsetObjs(Schema schema) * CANTPROCESS. If some types in schema *can* be processed now, we return * TRUE. (See relevant header comments of checkEnts() below.) */ -static int checkTypes(Schema schema) -{ +static int checkTypes( Schema schema ) { DictionaryEntry de; int retval = FALSE, unknowncnt; Type i; @@ -234,8 +231,8 @@ static int checkTypes(Schema schema) do { unknowncnt = 0; - SCOPEdo_types(schema, type, de) - if(type->search_id != NOTKNOWN) { + SCOPEdo_types( schema, type, de ) + if( type->search_id != NOTKNOWN ) { continue; } /* We're only interested in the ones which haven't been processed @@ -244,9 +241,9 @@ static int checkTypes(Schema schema) type->search_id = CANPROCESS; /* Assume this until disproven. */ - if(TYPEis_enumeration(type) && TYPEget_head(type)) { - i = TYPEget_ancestor(type); - if(!sameSchema(i, type) && i->search_id != PROCESSED) { + if( TYPEis_enumeration( type ) && TYPEget_head( type ) ) { + i = TYPEget_ancestor( type ); + if( !sameSchema( i, type ) && i->search_id != PROCESSED ) { /* Note - if, however, i is in same schema, we're safe: We // know it'll be processed this pass because enum's are // always processed on the first pass. (We do have to take @@ -255,10 +252,10 @@ static int checkTypes(Schema schema) type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } - } else if(TYPEis_select(type)) { - LISTdo(SEL_TYPEget_items(type), ii, Type) { - if(!TYPEis_entity(ii)) { - if(checkItem(ii, type, schema, &unknowncnt, 0)) { + } else if( TYPEis_select( type ) ) { + LISTdo( SEL_TYPEget_items( type ), ii, Type ) { + if( !TYPEis_entity( ii ) ) { + if( checkItem( ii, type, schema, &unknowncnt, 0 ) ) { break; } /* checkItem does most of the work of determining if @@ -272,8 +269,8 @@ static int checkTypes(Schema schema) } else { /* Check if our select has an entity item which itself // has unprocessed selects or enums. */ - ent = ENT_TYPEget_entity(ii); - if(ent->search_id == PROCESSED) { + ent = ENT_TYPEget_entity( ii ); + if( ent->search_id == PROCESSED ) { continue; } /* If entity has been processed already, things must be @@ -283,33 +280,31 @@ static int checkTypes(Schema schema) // item (and we can create a pointer to a not-yet-pro- // cessed object), while it will contain actual objects // for the enum and select attributes of ent.) */ - attribs = ENTITYget_all_attributes(ent); - LISTdo_n(attribs, attr, Variable, b) { - if(checkItem(attr->type, type, schema, - &unknowncnt, 1)) { + attribs = ENTITYget_all_attributes( ent ); + LISTdo_n( attribs, attr, Variable, b ) { + if( checkItem( attr->type, type, schema, + &unknowncnt, 1 ) ) { break; } - } - LISTod - LISTfree(attribs); + } LISTod + LISTfree( attribs ); } - } - LISTod + } LISTod /* One more condition - if we're a select which is a rename of // another select - we must also make sure the original select // is in this schema or has been processed. Since a rename- // select is defined with typedef's to the original, we can't // do that if the original hasn't been defined. */ - if((type->search_id == CANPROCESS) - && ((i = TYPEget_ancestor(type)) != NULL) - && (!sameSchema(i, type)) - && (i->search_id != PROCESSED)) { + if( ( type->search_id == CANPROCESS ) + && ( ( i = TYPEget_ancestor( type ) ) != NULL ) + && ( !sameSchema( i, type ) ) + && ( i->search_id != PROCESSED ) ) { type->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; } } - if(type->search_id == CANPROCESS) { + if( type->search_id == CANPROCESS ) { /* NOTE - This condition will be met if type isn't a select or // enum at all and above if was never entered (and it's our // first pass so type hasn't been processed). So for non-enums @@ -318,7 +313,7 @@ static int checkTypes(Schema schema) retval = TRUE; } SCOPEod - } while(unknowncnt > 0); + } while( unknowncnt > 0 ); /* We loop to deal with the following situation: Say sel A contains enum B // as an item, but A appears earlier in the EXPRESS file than B. In such a // case, we really can process A now since it doesn't depend on anything @@ -336,7 +331,7 @@ static int checkTypes(Schema schema) return retval; } -static int checkEnts(Schema schema) +static int checkEnts( Schema schema ) /* * Goes through the entities contained in this schema checking for ones * which can't be processed. It checks for two situations: (1) If we find @@ -358,8 +353,8 @@ static int checkEnts(Schema schema) int retval = FALSE, ignore = 0; /* Loop through schema's entities: */ - SCOPEdo_entities(schema, ent, de) - if(ent->search_id != NOTKNOWN) { + SCOPEdo_entities( schema, ent, de ) + if( ent->search_id != NOTKNOWN ) { continue; } /* ent->search_id may = CANTPROCESS signifying we've already determined @@ -371,10 +366,10 @@ static int checkEnts(Schema schema) /* First traverse ent's supertypes. If any is from a different schema // and is not yet defined, ent will have to wait. */ - LISTdo(ENTITYget_supertypes(ent), super, Entity) - if((!sameSchema(ent, super)) - && (super->search_id != PROCESSED)) { - markDescs(ent); + LISTdo( ENTITYget_supertypes( ent ), super, Entity ) + if( ( !sameSchema( ent, super ) ) + && ( super->search_id != PROCESSED ) ) { + markDescs( ent ); schema->search_id = UNPROCESSED; break; /* Exit the LISTdo loop. Since we found an unprocessed @@ -384,17 +379,17 @@ static int checkEnts(Schema schema) /* Next traverse ent's attributes, looking for attributes which are // not yet defined (more explanation in checkItem()). */ - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* Only do next test if ent hasn't already failed the 1st. */ - LISTdo(ENTITYget_attributes(ent), attr, Variable) - if(checkItem(attr->type, ent, schema, &ignore, 0)) { - markDescs(ent); + LISTdo( ENTITYget_attributes( ent ), attr, Variable ) + if( checkItem( attr->type, ent, schema, &ignore, 0 ) ) { + markDescs( ent ); break; } LISTod } - if(ent->search_id == CANPROCESS) { + if( ent->search_id == CANPROCESS ) { /* If ent's mark still = CANPROCESS and not CANTPROCESS, it // must still be processable. Set retval to TRUE signifying // that there are ent's we'll be able to process. */ @@ -410,7 +405,7 @@ static int checkEnts(Schema schema) return retval; } -static void markDescs(Entity ent) +static void markDescs( Entity ent ) /* * Sets the mark value of ent and all its subtypes to CANTPROCESS. This * function is called if we've determined that ent is a subtype of an @@ -418,13 +413,13 @@ static void markDescs(Entity ent) */ { ent->search_id = CANTPROCESS; - LISTdo(ENTITYget_subtypes(ent), sub, Entity) - markDescs(sub); + LISTdo( ENTITYget_subtypes( ent ), sub, Entity ) + markDescs( sub ); LISTod } -static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, - int noSel) +static int checkItem( Type t, Scope parent, Schema schema, int * unknowncnt, + int noSel ) /* * Function with a lot of side effects: Checks if type t, a member of * `parent' makes parent unprocessable. parent may be an entity and t is @@ -450,8 +445,8 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, { Type i = t; - if(isAggregateType(t)) { - i = TYPEget_base_type(t); + if( isAggregateType( t ) ) { + i = TYPEget_base_type( t ); /* NOTE - If t is a 2D aggregate or higher, we do not go down to its // lowest base type. An item which is a higher dimension aggregates // does not make its parent unprocessable. All an e.g. entity needs @@ -460,26 +455,26 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, // Sdaiclasses.h. */ } - if(TYPEis_enumeration(i) && !ENUMcanBeProcessed(i, schema)) { + if( TYPEis_enumeration( i ) && !ENUMcanBeProcessed( i, schema ) ) { /* Enum's are usually processed on the first try. ENUMcanBeProcessed() // checks for cases of renamed enum's, which must wait for the enum i // is a rename of. */ - if(parent->search_id == NOTKNOWN) { + if( parent->search_id == NOTKNOWN ) { /* We had thought parent's val was going to be NOTKNOWN - i.e., // dependent on other selects in this schema which haven't been // processed. When we set it to NOTKNOWN we also incremented // unknowncnt. Now we see it's not going to be unknown so we // decrement the count: */ - (*unknowncnt)--; + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if(TYPEis_select(i) && !noSel) { - if(!sameSchema(i, parent)) { - if(i->search_id != PROCESSED) { - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + } else if( TYPEis_select( i ) && !noSel ) { + if( !sameSchema( i, parent ) ) { + if( i->search_id != PROCESSED ) { + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; @@ -489,24 +484,24 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, /* We have another sel in the same schema. This gets complicated - // it may be processable but we just haven't gotten to it yet. So // we may have to wait on parent. */ - if(i->search_id == CANTPROCESS) { + if( i->search_id == CANTPROCESS ) { /* We *have* checked i already and it can't be processed. */ - if(parent->search_id == NOTKNOWN) { - (*unknowncnt)--; + if( parent->search_id == NOTKNOWN ) { + ( *unknowncnt )--; } parent->search_id = CANTPROCESS; schema->search_id = UNPROCESSED; return TRUE; - } else if(i->search_id == NOTKNOWN) { + } else if( i->search_id == NOTKNOWN ) { /* We haven't processed i this pass. */ - if(parent->search_id != NOTKNOWN) { + if( parent->search_id != NOTKNOWN ) { parent->search_id = NOTKNOWN; /* We lower parent's value. But don't return TRUE. That // would tell checkTypes() that there's nothing more to // check. But checkTypes should keep looping through the re- // maining items of parent - maybe one of them will tell us // that parent definitely can't be processed this pass. */ - (*unknowncnt)++; + ( *unknowncnt )++; } } } @@ -514,7 +509,7 @@ static int checkItem(Type t, Scope parent, Schema schema, int *unknowncnt, return FALSE; } -static int ENUMcanBeProcessed(Type e, Schema s) +static int ENUMcanBeProcessed( Type e, Schema s ) /* * Tells us if an enumeration type has been processed already, or if not * will be processed this pass through schema s. As always, I take great @@ -526,31 +521,31 @@ static int ENUMcanBeProcessed(Type e, Schema s) { Type a; - if(!inSchema(e, s)) { + if( !inSchema( e, s ) ) { /* If e is not in s - the schema we're processing now - things are // fairly simple. Nothing is going to change by the time we finish // with this schema. Base the return val on whether or not e *was* // processed already. */ - return (e->search_id == PROCESSED); + return ( e->search_id == PROCESSED ); } - if(e->search_id != NOTKNOWN) { + if( e->search_id != NOTKNOWN ) { /* Next case: e is in our schema, but either it's been processed // already, or we've determined that it can or can't be processed. // This case is also relatively simple - we have nothing more to // figure out here. */ - return (e->search_id >= CANPROCESS); + return ( e->search_id >= CANPROCESS ); /* PROC/CANPROC - TRUE; UNPROC'ED/CANTPROC - FALSE */ } /* Remaining case: e is in our schema and still = NOTKNOWN. I.e., we // haven't gotten to e this pass and don't yet know whether it'll be // processable. Figure that out now: */ - if((a = TYPEget_ancestor(e)) == NULL) { + if( ( a = TYPEget_ancestor( e ) ) == NULL ) { /* If e is not a rename of anything, it should be processed now. */ return TRUE; } - if(inSchema(a, s) || a->search_id == PROCESSED) { + if( inSchema( a, s ) || a->search_id == PROCESSED ) { /* If e's ancestor (the one it's a rename of) is in our schema it will // be processed now. If not, it must have been processed already. */ return TRUE; @@ -558,26 +553,26 @@ static int ENUMcanBeProcessed(Type e, Schema s) return FALSE; } -int sameSchema(Scope sc1, Scope sc2) +int sameSchema( Scope sc1, Scope sc2 ) /* * Checks if sc1 and sc2 are in the same superscope. Normally called for * two types to see if they're in the same schema. */ { - return (!strcmp(SCOPEget_name(sc1->superscope), - SCOPEget_name(sc2->superscope))); + return ( !strcmp( SCOPEget_name( sc1->superscope ), + SCOPEget_name( sc2->superscope ) ) ); } -static int inSchema(Scope scope, Scope super) +static int inSchema( Scope scope, Scope super ) /* * Checks if scope is contained in super's scope. */ { - return (!strcmp(SCOPEget_name(scope->superscope), - SCOPEget_name(super))); + return ( !strcmp( SCOPEget_name( scope->superscope ), + SCOPEget_name( super ) ) ); } -static void addAggrTypedefs(Schema schema) +static void addAggrTypedefs( Schema schema ) /* * Print typedefs at the end of Sdiaclasses.h for aggregates of enum's and * selects. Since the underlying enum/sel may appear in any schema, this @@ -589,15 +584,15 @@ static void addAggrTypedefs(Schema schema) DictionaryEntry de; Type i; - SCOPEdo_types(schema, t, de) - if(TYPEis_aggregate(t)) { - i = TYPEget_base_type(t); - if(TYPEis_enumeration(i) || TYPEis_select(i)) { + SCOPEdo_types( schema, t, de ) + if( TYPEis_aggregate( t ) ) { + i = TYPEget_base_type( t ); + if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) { /* This if will pass if t was a 1D aggregate only. They are // the only types which had to wait for their underlying type. // 2D aggr's and higher only need type GenericAggr defined // which is built-in. */ - printf("in addAggrTypedefs. %s is enum or select.\n", TYPEget_name(t)); + printf( "in addAggrTypedefs. %s is enum or select.\n", TYPEget_name( t ) ); /* strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ ); //printf("%s;%s",nm,TYPEget_ctype( t )); //if( firsttime ) { @@ -615,7 +610,7 @@ static void addAggrTypedefs(Schema schema) SCOPEod } -static void addUseRefNames(Schema schema, FILE *create) +static void addUseRefNames( Schema schema, FILE * create ) /* * Checks the USE and REFERENCE dicts contained in schema. If either dict * contains items (types or entities) which are renamed in this schema, @@ -627,60 +622,60 @@ static void addUseRefNames(Schema schema, FILE *create) { Dictionary useRefDict; DictionaryEntry de; - Rename *rnm; - char *oldnm, schNm[BUFSIZ]; + Rename * rnm; + char * oldnm, schNm[BUFSIZ]; static int firsttime = TRUE; - if((useRefDict = schema->u.schema->usedict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { + if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { /* strcmp != 0, so old and new names different. // Note: can't just check if nnew != old. That wouldn't // catch following: schema C USEs obj Y from schema B // (not renamed). B USEd it from schema A and renamed it // from X. nnew would = old, but name would not be same // as rnm->object's name. */ - if(firsttime) { - fprintf(create, "\t// Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( firsttime ) { + fprintf( create, "\t// Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = FALSE; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); } else { /* must be an entity */ - fprintf(create, "\t%s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, "\t%s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } - if((useRefDict = schema->u.schema->refdict) != NULL) { - DICTdo_init(useRefDict, &de); - while((rnm = (Rename *)DICTdo(&de)) != 0) { - oldnm = ((Scope)rnm->object)->symbol.name; - if((strcmp(oldnm, rnm->nnew->name))) { - if(firsttime) { - fprintf(create, "\t// Alternate names for types and "); - fprintf(create, "entities when used in other schemas:\n"); + if( ( useRefDict = schema->u.schema->refdict ) != NULL ) { + DICTdo_init( useRefDict, &de ); + while( ( rnm = ( Rename * )DICTdo( &de ) ) != 0 ) { + oldnm = ( ( Scope )rnm->object )->symbol.name; + if( ( strcmp( oldnm, rnm->nnew->name ) ) ) { + if( firsttime ) { + fprintf( create, "\t// Alternate names for types and " ); + fprintf( create, "entities when used in other schemas:\n" ); firsttime = FALSE; } - if(rnm->type == OBJ_TYPE) { - fprintf(create, "\t%s", TYPEtd_name((Type)rnm->object)); + if( rnm->type == OBJ_TYPE ) { + fprintf( create, "\t%s", TYPEtd_name( ( Type )rnm->object ) ); } else { - fprintf(create, "\t%s%s%s", - SCOPEget_name(((Entity)rnm->object)->superscope), - ENT_PREFIX, ENTITYget_name((Entity)rnm->object)); + fprintf( create, "\t%s%s%s", + SCOPEget_name( ( ( Entity )rnm->object )->superscope ), + ENT_PREFIX, ENTITYget_name( ( Entity )rnm->object ) ); } - strcpy(schNm, PrettyTmpName(SCHEMAget_name(schema))); - fprintf(create, "->addAltName( \"%s\", \"%s\" );\n", - schNm, PrettyTmpName(rnm->nnew->name)); + strcpy( schNm, PrettyTmpName( SCHEMAget_name( schema ) ) ); + fprintf( create, "->addAltName( \"%s\", \"%s\" );\n", + schNm, PrettyTmpName( rnm->nnew->name ) ); } } } diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index 3a202d900..b44abab95 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -25,13 +25,13 @@ extern int multiple_inheritance; #include "classes.h" #include -bool is_python_keyword(char *word); -int isAggregateType(const Type t); -char *generate_attribute_name(Variable a, char *out); -void ATTRsign_access_methods(Variable a, FILE *file); -char *generate_attribute_func_name(Variable a, char *out); -void ATTRprint_access_methods_get_head(const char *classnm, Variable a, FILE *file); -void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file); +bool is_python_keyword( char * word ); +int isAggregateType( const Type t ); +char * generate_attribute_name( Variable a, char * out ); +void ATTRsign_access_methods( Variable a, FILE * file ); +char * generate_attribute_func_name( Variable a, char * out ); +void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file ); +void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ); #define BASE_SELECT "SCLP23(Select)" @@ -62,17 +62,15 @@ void ATTRprint_access_methods_put_head(const char *entnm, Variable a, FILE *file #define FALSE 0 const char * -SEL_ITEMget_enumtype(Type t) -{ - return StrToUpper(TYPEget_name(t)); +SEL_ITEMget_enumtype( Type t ) { + return StrToUpper( TYPEget_name( t ) ); } /** FIXME implement for python or remove ** \returns type used to represent the underlying type in a select class */ -const char *TYPEget_utype(Type t) -{ +const char * TYPEget_utype( Type t ) { (void) t; /* unused */ return NULL; } @@ -84,14 +82,13 @@ determines if the given entity is a member of the list. RETURNS the member if it is a member; otherwise 0 is returned. *******************/ void * -LISTmember(const Linked_List list, void *e) -{ +LISTmember( const Linked_List list, void *e ) { Link node; - for(node = list->mark->next; node != list->mark; node = node->next) - if(e == node -> data) { + for( node = list->mark->next; node != list->mark; node = node->next ) + if( e == node -> data ) { return e; } - return (0); + return ( 0 ); } /******************* @@ -106,19 +103,18 @@ LISTmember(const Linked_List list, void *e) dered equivalent. One such case is the generation of duplicate lists. *******************/ static int -compareOrigTypes(Type a, Type b) -{ +compareOrigTypes( Type a, Type b ) { Type t, u; - if((TYPEis_select(a) && TYPEis_select(b)) - || (TYPEis_enumeration(a) && TYPEis_enumeration(b))) { + if( ( TYPEis_select( a ) && TYPEis_select( b ) ) + || ( TYPEis_enumeration( a ) && TYPEis_enumeration( b ) ) ) { t = a; u = b; - } else if(TYPEis_aggregate(a) && TYPEis_aggregate(b)) { - t = TYPEget_base_type(a); - u = TYPEget_base_type(b); - if(!((TYPEis_select(t) && TYPEis_select(u)) - || (TYPEis_enumeration(t) && TYPEis_enumeration(u)))) { + } else if( TYPEis_aggregate( a ) && TYPEis_aggregate( b ) ) { + t = TYPEget_base_type( a ); + u = TYPEget_base_type( b ); + if( !( ( TYPEis_select( t ) && TYPEis_select( u ) ) + || ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) { return FALSE; /* Only go further with 1D aggregates of sels or enums. Note that // for 2D aggrs and higher we do not continue. These are all recog- @@ -129,13 +125,13 @@ compareOrigTypes(Type a, Type b) return FALSE; } - if(TYPEget_head(t)) { - t = TYPEget_ancestor(t); + if( TYPEget_head( t ) ) { + t = TYPEget_ancestor( t ); } - if(TYPEget_head(u)) { - u = TYPEget_ancestor(u); + if( TYPEget_head( u ) ) { + u = TYPEget_ancestor( u ); } - return (!strcmp(TYPEget_name(t), TYPEget_name(u))); + return ( !strcmp( TYPEget_name( t ), TYPEget_name( u ) ) ); } /******************* @@ -149,16 +145,15 @@ compareOrigTypes(Type a, Type b) compareOrigTypes() above). *******************/ const char * -utype_member(const Linked_List list, const Type check, int rename) -{ +utype_member( const Linked_List list, const Type check, int rename ) { static char r [BUFSIZ]; - LISTdo(list, t, Type) - strncpy(r, TYPEget_utype(t), BUFSIZ); - if(strcmp(r, TYPEget_utype(check)) == 0) { + LISTdo( list, t, Type ) + strncpy( r, TYPEget_utype( t ), BUFSIZ ); + if( strcmp( r, TYPEget_utype( check ) ) == 0 ) { return r; } - if(rename && compareOrigTypes(check, t)) { + if( rename && compareOrigTypes( check, t ) ) { return r; } LISTod; @@ -176,16 +171,15 @@ utype_member(const Linked_List list, const Type check, int rename) Linked_List -SELgetnew_dmlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SELgetnew_dmlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); - LISTdo(complete, t, Type) + LISTdo( complete, t, Type ) /* if t\'s underlying type is not already in newlist, */ - if(! utype_member(newlist, t, 0)) { - LISTadd_last(newlist, t); + if( ! utype_member( newlist, t, 0 ) ) { + LISTadd_last( newlist, t ); } LISTod; @@ -195,10 +189,9 @@ SELgetnew_dmlist(const Type type) } const char * -SEL_ITEMget_dmtype(Type t, const Linked_List l) -{ - const char *r = utype_member(l, t, 0); - return StrToLower(r ? r : TYPEget_utype(t)); +SEL_ITEMget_dmtype( Type t, const Linked_List l ) { + const char * r = utype_member( l, t, 0 ); + return StrToLower( r ? r : TYPEget_utype( t ) ); } @@ -211,15 +204,14 @@ of the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_in_express_list(const Linked_List list, const Type check) -{ - if(TYPEis_entity(check)) { +duplicate_in_express_list( const Linked_List list, const Type check ) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; /* don\'t compare check to itself */ } else { return TRUE; /* other things in the list conflict */ @@ -236,10 +228,9 @@ underlying Express type. RETURNS 1 if true, else 0. *******************/ int -unique_types(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_in_express_list(list, t)) { +unique_types( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_in_express_list( list, t ) ) { return FALSE; } LISTod; @@ -254,30 +245,29 @@ determines if the given "link's" C++ representation is used again in the list. RETURNS 1 if true, else 0. *******************/ int -duplicate_utype_member(const Linked_List list, const Type check) -{ +duplicate_utype_member( const Linked_List list, const Type check ) { char b [BUFSIZ]; - if(TYPEis_entity(check)) { + if( TYPEis_entity( check ) ) { return FALSE; } /* entities are never the same */ - LISTdo(list, t, Type) - if(t == check) { + LISTdo( list, t, Type ) + if( t == check ) { ; } /* don\'t compare check to itself */ else { /* continue looking */ - strncpy(b, TYPEget_utype(t), BUFSIZ); - if((!strcmp(b, TYPEget_utype(check))) - || (compareOrigTypes(t, check))) + strncpy( b, TYPEget_utype( t ), BUFSIZ ); + if( ( !strcmp( b, TYPEget_utype( check ) ) ) + || ( compareOrigTypes( t, check ) ) ) /* if the underlying types are the same */ { return TRUE; } - if(! strcmp(b, "SCLP23(Integer)") && - (! strcmp(TYPEget_utype(check), "SCLP23(Real)"))) + if( ! strcmp( b, "SCLP23(Integer)" ) && + ( ! strcmp( TYPEget_utype( check ), "SCLP23(Real)" ) ) ) /* integer\'s and real\'s are not unique */ { return TRUE; @@ -295,10 +285,9 @@ C++ representation for the underlying Express type. RETURNS 1 if true, else 0. *******************/ int -any_duplicates_in_select(const Linked_List list) -{ - LISTdo(list, t, Type) - if(duplicate_utype_member(list, t)) { +any_duplicates_in_select( const Linked_List list ) { + LISTdo( list, t, Type ) + if( duplicate_utype_member( list, t ) ) { return TRUE; } LISTod; @@ -314,25 +303,24 @@ returns TRUE, else FALSE. list should be unbound before calling, and freed afterwards. *******************/ int -find_duplicate_list(const Type type, Linked_List *duplicate_list) -{ +find_duplicate_list( const Type type, Linked_List * duplicate_list ) { Linked_List temp; /** temporary list for comparison **/ *duplicate_list = LISTcreate(); - if(any_duplicates_in_select(SEL_TYPEget_items(type))) { + if( any_duplicates_in_select( SEL_TYPEget_items( type ) ) ) { /** if there is a dup somewhere **/ temp = LISTcreate(); - LISTdo(SEL_TYPEget_items(type), u, Type) - if(!utype_member(*duplicate_list, u, 1)) { + LISTdo( SEL_TYPEget_items( type ), u, Type ) + if( !utype_member( *duplicate_list, u, 1 ) ) { /** if not already a duplicate **/ - if(utype_member(temp, u, 1)) { - LISTadd_first(*duplicate_list, u); + if( utype_member( temp, u, 1 ) ) { + LISTadd_first( *duplicate_list, u ); } else { - LISTadd_first(temp, u); + LISTadd_first( temp, u ); } } LISTod; - LISTfree(temp); + LISTfree( temp ); return TRUE; } return FALSE; @@ -367,10 +355,9 @@ enum __types { the leaf nodes. */ void -non_unique_types_vector(const Type type, int *tvec) -{ - LISTdo(SEL_TYPEget_items(type), t, Type) - switch(TYPEget_body(t)->type) { +non_unique_types_vector( const Type type, int * tvec ) { + LISTdo( SEL_TYPEget_items( type ), t, Type ) + switch( TYPEget_body( t )->type ) { case integer_: tvec[tint]++; break; @@ -390,7 +377,7 @@ non_unique_types_vector(const Type type, int *tvec) break; case select_: /* SELECT, ergo recurse! */ - non_unique_types_vector(t, tvec); + non_unique_types_vector( t, tvec ); break; case entity_: tvec[tentity]++; @@ -406,7 +393,7 @@ non_unique_types_vector(const Type type, int *tvec) tvec[tnumber]++; break; default: - fprintf(stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body(t)->type); + fprintf( stderr, "Error at %s:%d - type %d not handled by switch statement.", __FILE__, __LINE__, TYPEget_body( t )->type ); abort(); } LISTod; @@ -418,60 +405,59 @@ non_unique_types_vector(const Type type, int *tvec) types. If all types are unique, the string (0) is generated. */ char * -non_unique_types_string(const Type type) -{ +non_unique_types_string( const Type type ) { int tvec[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - char *typestr; + char * typestr; int first = 1; int i; - non_unique_types_vector(type, tvec); + non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = (char *)malloc(BUFSIZ); + typestr = ( char * )malloc( BUFSIZ ); typestr[0] = '\0'; - strcat(typestr, (char *)"("); - for(i = 0; i <= tnumber; i++) { - if(tvec[i] < 2) { + strcat( typestr, ( char * )"(" ); + for( i = 0; i <= tnumber; i++ ) { + if( tvec[i] < 2 ) { continue; /* skip, this one is unique */ } - if(!first) { - strcat(typestr, (char *)" | "); + if( !first ) { + strcat( typestr, ( char * )" | " ); } else { first = 0; } - switch(i) { + switch( i ) { case tint : - strcat(typestr, (char *)"sdaiINTEGER"); + strcat( typestr, ( char * )"sdaiINTEGER" ); break; case treal : - strcat(typestr, (char *)"sdaiREAL"); + strcat( typestr, ( char * )"sdaiREAL" ); break; case tstring: - strcat(typestr, (char *)"sdaiSTRING"); + strcat( typestr, ( char * )"sdaiSTRING" ); break; case tbinary: - strcat(typestr, (char *)"sdaiBINARY"); + strcat( typestr, ( char * )"sdaiBINARY" ); break; case tenum : - strcat(typestr, (char *)"sdaiENUMERATION"); + strcat( typestr, ( char * )"sdaiENUMERATION" ); break; case tentity: - strcat(typestr, (char *)"sdaiINSTANCE"); + strcat( typestr, ( char * )"sdaiINSTANCE" ); break; case taggr : - strcat(typestr, (char *)"sdaiAGGR"); + strcat( typestr, ( char * )"sdaiAGGR" ); break; case tnumber: - strcat(typestr, (char *)"sdaiNUMBER"); + strcat( typestr, ( char * )"sdaiNUMBER" ); break; } } - if(first) { - strcat(typestr, (char *)"0"); + if( first ) { + strcat( typestr, ( char * )"0" ); } - strcat(typestr, (char *)")"); + strcat( typestr, ( char * )")" ); return typestr; } @@ -488,19 +474,18 @@ non_unique_types_string(const Type type) ******************************************************************/ Variable -ATTR_LISTmember(Linked_List l, Variable check) -{ +ATTR_LISTmember( Linked_List l, Variable check ) { char nm [BUFSIZ]; char cur [BUFSIZ]; - generate_attribute_name(check, nm); - LISTdo(l, a, Variable) - generate_attribute_name(a, cur); - if(! strcmp(nm, cur)) { + generate_attribute_name( check, nm ); + LISTdo( l, a, Variable ) + generate_attribute_name( a, cur ); + if( ! strcmp( nm, cur ) ) { return check; } LISTod; - return (0); + return ( 0 ); } @@ -516,20 +501,19 @@ ATTR_LISTmember(Linked_List l, Variable check) ******************************************************************/ Linked_List -SEL_TYPEgetnew_attribute_list(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SEL_TYPEgetnew_attribute_list( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Linked_List attrs; Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - attrs = ENTITYget_all_attributes(cur); - LISTdo_n(attrs, a, Variable, b) - if(! ATTR_LISTmember(newlist, a)) { - LISTadd_first(newlist, a); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + attrs = ENTITYget_all_attributes( cur ); + LISTdo_n( attrs, a, Variable, b ) + if( ! ATTR_LISTmember( newlist, a ) ) { + LISTadd_first( newlist, a ); } LISTod; } @@ -539,46 +523,44 @@ SEL_TYPEgetnew_attribute_list(const Type type) Linked_List -ENTITYget_expanded_entities(Entity e, Linked_List l) -{ +ENTITYget_expanded_entities( Entity e, Linked_List l ) { Linked_List supers; Entity super; - if(! LISTmember(l, e)) { - LISTadd_first(l, e); + if( ! LISTmember( l, e ) ) { + LISTadd_first( l, e ); } - if(multiple_inheritance) { + if( multiple_inheritance ) { int super_cnt = 0; - supers = ENTITYget_supertypes(e); - LISTdo(supers, s, Entity) + supers = ENTITYget_supertypes( e ); + LISTdo( supers, s, Entity ) /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - if(super_cnt == 0) { - ENTITYget_expanded_entities(s, l); + if( super_cnt == 0 ) { + ENTITYget_expanded_entities( s, l ); } ++ super_cnt; LISTod; } else { /* ignore the more than one supertype since multiple inheritance isn\'t implemented */ - super = ENTITYget_superclass(e); - ENTITYget_expanded_entities(super, l); + super = ENTITYget_superclass( e ); + ENTITYget_expanded_entities( super, l ); } return l; } Linked_List -SELget_entity_itemlist(const Type type) -{ - Linked_List complete = SEL_TYPEget_items(type); +SELget_entity_itemlist( const Type type ) { + Linked_List complete = SEL_TYPEget_items( type ); Linked_List newlist = LISTcreate(); Entity cur; - LISTdo(complete, t, Type) - if(TYPEis_entity(t)) { - cur = ENT_TYPEget_entity(t); - ENTITYget_expanded_entities(cur, newlist); + LISTdo( complete, t, Type ) + if( TYPEis_entity( t ) ) { + cur = ENT_TYPEget_entity( t ); + ENTITYget_expanded_entities( cur, newlist ); } LISTod; return newlist; @@ -591,39 +573,38 @@ TYPEselect_lib_print prints the member functions (definitions) of a select class. *******************/ void -TYPEselect_lib_print(const Type type, FILE *f) -{ +TYPEselect_lib_print( const Type type, FILE * f ) { int nbr_select = 0; int num = 0; - fprintf(f, "# SELECT TYPE %s\n", TYPEget_name(type)); + fprintf( f, "# SELECT TYPE %s\n", TYPEget_name( type ) ); /* create the SELECT */ - if(is_python_keyword(TYPEget_name(type))) { - fprintf(f, "%s_ = SELECT(", TYPEget_name(type)); + if( is_python_keyword( TYPEget_name( type ) ) ) { + fprintf( f, "%s_ = SELECT(", TYPEget_name( type ) ); } else { - fprintf(f, "%s = SELECT(", TYPEget_name(type)); + fprintf( f, "%s = SELECT(", TYPEget_name( type ) ); } /* first compute the number of types (necessary to insert commas) */ nbr_select = 0; - LISTdo(SEL_TYPEget_items(type), t, Type) + LISTdo( SEL_TYPEget_items( type ), t, Type ) (void) t; /* unused */ nbr_select++; LISTod; /* then write types */ num = 0; - LISTdo(SEL_TYPEget_items(type), t, Type) - if(is_python_keyword(TYPEget_name(t))) { - fprintf(f, "\n\t'%s_'", TYPEget_name(t)); + LISTdo( SEL_TYPEget_items( type ), t, Type ) + if( is_python_keyword( TYPEget_name( t ) ) ) { + fprintf( f, "\n\t'%s_'", TYPEget_name( t ) ); } else { - fprintf(f, "\n\t'%s'", TYPEget_name(t)); + fprintf( f, "\n\t'%s'", TYPEget_name( t ) ); } - if(num < nbr_select - 1) { - fprintf(f, ","); + if( num < nbr_select - 1 ) { + fprintf( f, "," ); } num++; LISTod; - fprintf(f, ",\n\tscope = schema_scope)\n"); + fprintf( f, ",\n\tscope = schema_scope)\n" ); } #undef BASE_SELECT diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 0d1fb9649..5d6b7a6f3 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories( ${SC_SOURCE_DIR}/src/express ) -if(BUILD_SHARED_LIBS) +if($CACHE{SC_BUILD_SHARED_LIBS}) SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) set_target_properties(libexppp PROPERTIES PREFIX "") if(WIN32) @@ -38,7 +38,7 @@ if(BUILD_SHARED_LIBS) endif() endif() -if(BUILD_STATIC_LIBS) +if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) set_target_properties(libexppp-static PROPERTIES PREFIX "") endif() diff --git a/src/exppp/exppp-main.c b/src/exppp/exppp-main.c index 7ca23c034..670dd7a88 100644 --- a/src/exppp/exppp-main.c +++ b/src/exppp/exppp-main.c @@ -3,66 +3,63 @@ #include "../express/express.h" #include "exppp.h" -static void exppp_usage(void) -{ +static void exppp_usage( void ) { char *warnings_help_msg = ERRORget_warnings_help("\t", "\n"); - fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name); - fprintf(stderr, "\t-v produces a version description\n"); - fprintf(stderr, "\t-l specifies line length hint for output\n"); - fprintf(stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n"); - fprintf(stderr, "\t-c for constants, print one item per line (YMMV!)\n"); - fprintf(stderr, "\t-o specifies the name of the output file (-- for stdout)\n"); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", warnings_help_msg); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); - exit(2); + fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "\t-v produces a version description\n" ); + fprintf( stderr, "\t-l specifies line length hint for output\n" ); + fprintf( stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n" ); + fprintf( stderr, "\t-c for constants, print one item per line (YMMV!)\n" ); + fprintf( stderr, "\t-o specifies the name of the output file (-- for stdout)\n" ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, "%s", warnings_help_msg); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); + exit( 2 ); } -int Handle_Exppp_Args(int i, char *arg) -{ - if(tolower((char)i) == 'o') { - if(!strcmp("--", arg)) { +int Handle_Exppp_Args( int i, char * arg ) { + if( tolower( ( char )i ) == 'o' ) { + if( !strcmp( "--", arg ) ) { exppp_print_to_stdout = true; return 0; } exppp_output_filename_reset = false; exppp_output_filename = arg; return 0; - } else if(tolower((char)i) == 'l') { - if((strlen(arg) > 5) || (strlen(arg) < 2)) { - fprintf(stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg); + } else if( tolower( ( char )i ) == 'l' ) { + if( ( strlen( arg ) > 5 ) || ( strlen( arg ) < 2 ) ) { + fprintf( stderr, "Unreasonable number of chars in arg for -l: %s\nTry 2-5 digits.", arg ); return 1; } - exppp_linelength = atoi(arg); + exppp_linelength = atoi( arg ); return 0; - } else if(tolower((char)i) == 'c') { + } else if( tolower( ( char )i ) == 'c' ) { exppp_aggressively_wrap_consts = true; return 0; - } else if(tolower((char)i) == 't') { + } else if( tolower( ( char )i ) == 't' ) { exppp_tail_comment = true; return 0; } return 1; } -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { exppp_alphabetize = true; EXPRESSbackend = EXPRESSout; ERRORusage_function = exppp_usage; - strcat(EXPRESSgetopt_options, "o:l:ct"); + strcat( EXPRESSgetopt_options, "o:l:ct" ); EXPRESSgetopt = Handle_Exppp_Args; } diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index 0aba5bbfc..e40ffaee9 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -30,26 +30,26 @@ # error "PP_SMALL_BUF_SZ already defined" #endif -void ALGscope_out(Scope s, int level); -void ENTITYattrs_out(Linked_List attributes, int derived, int level); -void ENTITY_out(Entity e, int level); -void ENTITYinverse_out(Linked_List attrs, int level); -void ENTITYunique_out(Linked_List u, int level); -void FUNC_out(Function fn, int level); -void PROC_out(Procedure p, int level); -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); -void RULE_out(Rule r, int level); -void SCOPEalgs_out(Scope s, int level); -void SCOPEconsts_out(Scope s, int level); -void SCOPEentities_out(Scope s, int level); -void SCOPElocals_out(Scope s, int level); -void SCOPEtypes_out(Scope s, int level); -void STMT_out(Statement s, int level); -void STMTlist_out(Linked_List stmts, int level); -void TYPE_out(Type t, int level); -void TYPE_head_out(Type t, int level); -void TYPE_body_out(Type t, int level); -void WHERE_out(Linked_List wheres, int level); +void ALGscope_out( Scope s, int level ); +void ENTITYattrs_out( Linked_List attributes, int derived, int level ); +void ENTITY_out( Entity e, int level ); +void ENTITYinverse_out( Linked_List attrs, int level ); +void ENTITYunique_out( Linked_List u, int level ); +void FUNC_out( Function fn, int level ); +void PROC_out( Procedure p, int level ); +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); +void RULE_out( Rule r, int level ); +void SCOPEalgs_out( Scope s, int level ); +void SCOPEconsts_out( Scope s, int level ); +void SCOPEentities_out( Scope s, int level ); +void SCOPElocals_out( Scope s, int level ); +void SCOPEtypes_out( Scope s, int level ); +void STMT_out( Statement s, int level ); +void STMTlist_out( Linked_List stmts, int level ); +void TYPE_out( Type t, int level ); +void TYPE_head_out( Type t, int level ); +void TYPE_body_out( Type t, int level ); +void WHERE_out( Linked_List wheres, int level ); Error ERROR_select_empty; @@ -73,11 +73,11 @@ bool exppp_terse = false; bool exppp_reference_info = false; /* if true, add commentary about where things came from */ bool exppp_tail_comment = false; -FILE *exppp_fp = NULL; /* output file */ -char *exppp_buf = 0; /* output buffer */ +FILE * exppp_fp = NULL; /* output file */ +char * exppp_buf = 0; /* output buffer */ int exppp_maxbuflen = 0; /* size of expppbuf */ unsigned int exppp_buflen = 0; /* remaining space in expppbuf */ -char *exppp_bufp = 0; /* pointer to write position in expppbuf, +char * exppp_bufp = 0; /* pointer to write position in expppbuf, * should usually be pointing to a "\0" */ /** used to print a comment containing the name of a structure at the @@ -85,20 +85,18 @@ char *exppp_bufp = 0; /* pointer to write position in expppbuf, * * prints a newline regardless */ -void tail_comment(const char *name) -{ - if(exppp_tail_comment) { - raw(" -- %s", name); +void tail_comment( const char * name ) { + if( exppp_tail_comment ) { + raw( " -- %s", name ); } - raw("\n"); + raw( "\n" ); } /** count newlines in a string */ -int count_newlines(char *s) -{ +int count_newlines( char * s ) { int count = 0; - for(; *s; s++) { - if(*s == '\n') { + for( ; *s; s++ ) { + if( *s == '\n' ) { count++; } } @@ -108,48 +106,46 @@ int count_newlines(char *s) /** true if last char through exp_output was a space */ static bool printedSpaceLast = false; -void exp_output(char *buf, unsigned int len) -{ - FILE *fp = (exppp_fp ? exppp_fp : stdout); +void exp_output( char * buf, unsigned int len ) { + FILE * fp = ( exppp_fp ? exppp_fp : stdout ); - error_sym.line += count_newlines(buf); - printedSpaceLast = (*(buf + len - 1) == ' '); - if(exppp_buf) { + error_sym.line += count_newlines( buf ); + printedSpaceLast = ( *( buf + len - 1) == ' ' ); + if( exppp_buf ) { /* output to string */ - if(len > exppp_buflen) { + if( len > exppp_buflen ) { /* should provide flag to enable complaint */ /* for now, just ignore */ return; } - memcpy(exppp_bufp, buf, len + 1); + memcpy( exppp_bufp, buf, len + 1 ); exppp_bufp += len; exppp_buflen -= len; } else { /* output to file */ - size_t out = fwrite(buf, 1, len, fp); - if(out != len) { - const char *err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; - fprintf(stderr, err, __FILE__, __LINE__, len, out); + size_t out = fwrite( buf, 1, len, fp ); + if( out != len ) { + const char * err = "%s:%u - ERROR: write operation on output file failed. Wanted %u bytes, wrote %u."; + fprintf( stderr, err, __FILE__, __LINE__, len, out ); abort(); } } } -void wrap(const char *fmt, ...) -{ +void wrap( const char * fmt, ... ) { char buf[10000]; - char *p, * start = buf; + char * p, * start = buf; int len; va_list args; - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); + va_start( args, fmt ); + vsprintf( buf, fmt, args ); + va_end( args ); - len = strlen(buf); + len = strlen( buf ); /* eliminate leading whitespace */ - while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { + while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ start++; len--; } @@ -161,26 +157,26 @@ void wrap(const char *fmt, ...) * 3rd condition: if exppp_linelength == indent2 and curpos > indent2, always newline * to use #3: temporarily change exppp_linelength; it doesn't make sense to change indent2 */ - if((((curpos + len) > exppp_linelength) && ((indent2 + len) < exppp_linelength)) - || ((exppp_linelength == indent2) && (curpos > indent2))) { + if( ( ( ( curpos + len ) > exppp_linelength ) && ( ( indent2 + len ) < exppp_linelength ) ) + || ( ( exppp_linelength == indent2 ) && ( curpos > indent2 ) ) ) { /* move to new continuation line */ char line[1000]; - sprintf(line, "\n%*s", indent2, ""); - exp_output(line, 1 + indent2); + sprintf( line, "\n%*s", indent2, "" ); + exp_output( line, 1 + indent2 ); curpos = indent2; /* reset current position */ } /* eliminate leading whitespace - again */ - while((*start == ' ') && ((printedSpaceLast) || (*(start + 1) == ' '))) { + while( ( *start == ' ' ) && ( ( printedSpaceLast ) || ( *( start + 1 ) == ' ' ) ) ){ start++; len--; } - exp_output(start, len); + exp_output( start, len ); - if(len) { + if( len ) { /* reset cur position based on last newline seen */ - if(0 == (p = strrchr(start, '\n'))) { + if( 0 == ( p = strrchr( start, '\n' ) ) ) { curpos += len; } else { curpos = len + start - p; @@ -188,24 +184,23 @@ void wrap(const char *fmt, ...) } } -void raw(const char *fmt, ...) -{ - char *p; +void raw( const char * fmt, ... ) { + char * p; char buf[10000]; int len; va_list args; - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); + va_start( args, fmt ); + vsprintf( buf, fmt, args ); + va_end( args ); - len = strlen(buf); + len = strlen( buf ); - exp_output(buf, len); + exp_output( buf, len ); - if(len) { + if( len ) { /* reset cur position based on last newline seen */ - if(0 == (p = strrchr(buf, '\n'))) { + if( 0 == ( p = strrchr( buf, '\n' ) ) ) { curpos += len; } else { curpos = len + buf - p; @@ -213,21 +208,19 @@ void raw(const char *fmt, ...) } } -void exppp_init() -{ +void exppp_init() { static bool first_time = true; - if(!first_time) { + if( !first_time ) { return; } first_time = false; } -void exppp_ref_info(Symbol *s) -{ - if(exppp_reference_info) { - raw("--info %s %s %d\n", s->name, s->filename, s->line); +void exppp_ref_info( Symbol * s ) { + if( exppp_reference_info ) { + raw( "--info %s %s %d\n", s->name, s->filename, s->line ); } } @@ -237,21 +230,19 @@ void exppp_ref_info(Symbol *s) */ bool first_line = true; /* if first line */ -void first_newline() -{ - if(first_line) { +void first_newline() { + if( first_line ) { first_line = false; } else { - raw("\n"); + raw( "\n" ); } } -int minimum(int a, int b, int c) -{ - if(a < b) { - return ((a < c) ? a : c); +int minimum( int a, int b, int c ) { + if( a < b ) { + return ( ( a < c ) ? a : c ); } else { - return ((b < c) ? b : c); + return ( ( b < c ) ? b : c ); } } @@ -261,11 +252,10 @@ int minimum(int a, int b, int c) * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char *real2exp(double r) -{ -#define PP_SMALL_BUF_SZ 80 +const char * real2exp( double r ) { + #define PP_SMALL_BUF_SZ 80 static char result[PP_SMALL_BUF_SZ] = { 0 }; - char *pos = result, * lcNumeric = setlocale(LC_NUMERIC, NULL); + char * pos = result, * lcNumeric = setlocale( LC_NUMERIC, NULL ); /* the following ensures that PP_SMALL_BUF_SZ is at least * as big as the largest possible string: @@ -280,92 +270,89 @@ const char *real2exp(double r) * non-exotic platforms. */ unsigned int exponentDigits = 2, expMax = DBL_MAX_10_EXP; - while(expMax >= 10) { + while( expMax >= 10 ) { exponentDigits++; expMax /= 10; } - if(!((DBL_DIG + exponentDigits + 3) < PP_SMALL_BUF_SZ)) { - fprintf(stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__); + if( !( ( DBL_DIG + exponentDigits + 3 ) < PP_SMALL_BUF_SZ ) ) { + fprintf( stderr, "ERROR: buffer undersized at %s:%d\n", __FILE__, __LINE__ ); abort(); } - if(strcmp("C", lcNumeric)) { - fprintf(stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, - "(are you calling exppp from Qt?). Incorrect formatting is possible.\n"); - setlocale(LC_NUMERIC, "C"); + if( strcmp( "C", lcNumeric ) ) { + fprintf( stderr, "WARNING: locale has been set to \"%s\", not \"C\" %s", lcNumeric, + "(are you calling exppp from Qt?). Incorrect formatting is possible.\n" ); + setlocale( LC_NUMERIC, "C" ); } - snprintf(result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r); + snprintf( result, PP_SMALL_BUF_SZ, "%#.*g", DBL_DIG, r ); /* eliminate trailing zeros in the mantissa */ - assert(strlen(result) < PP_SMALL_BUF_SZ - 1); - while((*pos != '.') && (*pos != '\0')) { + assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); + while( ( *pos != '.' ) && ( *pos != '\0' ) ) { /* search for '.' */ pos++; } - if(*pos != '\0') { - char *firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ + if( *pos != '\0' ) { + char * firstUnnecessaryDigit = NULL; /* this will be the first zero of the trailing zeros in the mantissa */ pos++; - while(isdigit(*pos)) { - if((*pos == '0') && (firstUnnecessaryDigit == NULL)) { + while( isdigit( *pos ) ) { + if( ( *pos == '0' ) && ( firstUnnecessaryDigit == NULL ) ) { firstUnnecessaryDigit = pos; - } else if(*pos != '0') { + } else if( *pos != '0' ) { firstUnnecessaryDigit = NULL; } pos++; } - if((firstUnnecessaryDigit != NULL) && (firstUnnecessaryDigit < pos)) { - if((*(firstUnnecessaryDigit - 1) == '.') && (*pos == '\0')) { + if( ( firstUnnecessaryDigit != NULL ) && ( firstUnnecessaryDigit < pos ) ) { + if( ( *( firstUnnecessaryDigit - 1 ) == '.' ) && ( *pos == '\0' ) ) { /* no exponent, nothing after decimal point - remove decimal point */ - *(firstUnnecessaryDigit - 1) = '\0'; + *( firstUnnecessaryDigit - 1 ) = '\0'; } else { /* copy exponent (or \0) immediately after the decimal point */ - memmove(firstUnnecessaryDigit, pos, strlen(pos) + 1); + memmove( firstUnnecessaryDigit, pos, strlen( pos ) + 1 ); } } } - assert(strlen(result) < PP_SMALL_BUF_SZ - 1); + assert( strlen( result ) < PP_SMALL_BUF_SZ - 1 ); return result; -#undef PP_SMALL_BUF_SZ + #undef PP_SMALL_BUF_SZ } /** Find next '.' in null-terminated string, return number of chars * If no '.' found, returns length of string */ -int nextBreakpoint(const char *pos, const char *end) -{ +int nextBreakpoint( const char * pos, const char * end ) { int i = 0; - while((*pos != '.') && (*pos != '\0') && (pos < end)) { + while( ( *pos != '.' ) && ( *pos != '\0' ) && ( pos < end ) ) { i++; pos++; } - if(*pos == '.') { + if( *pos == '.' ) { i++; } return i; } /** true if it makes sense to break before printing next part of the string */ -bool shouldBreak(int len) -{ - if((curpos > indent2) && - ((curpos + len) > exppp_linelength)) { +bool shouldBreak( int len ) { + if( ( curpos > indent2 ) && + ( ( curpos + len ) > exppp_linelength ) ) { return true; } return false; } /** Insert newline if it makes sense. */ -void maybeBreak(int len, bool first) -{ - if(shouldBreak(len)) { - if(first) { - raw("\n%*s'", indent2, ""); +void maybeBreak( int len, bool first ) { + if( shouldBreak( len ) ) { + if( first ) { + raw( "\n%*s'", indent2, "" ); } else { - raw("'\n%*s+ '", indent2, ""); + raw( "'\n%*s+ '", indent2, "" ); } - } else if(first) { + } else if( first ) { /* staying on same line */ - raw("%s", (printedSpaceLast ? "'" : " '")); + raw( "%s", ( printedSpaceLast ? "'": " '" ) ); } } @@ -376,29 +363,28 @@ void maybeBreak(int len, bool first) * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr(const char *in) -{ - const char *iptr = in, * end; - unsigned int inlen = strlen(in); +void breakLongStr( const char * in ) { + const char * iptr = in, * end; + unsigned int inlen = strlen( in ); bool first = true; /* used to ensure that we don't overrun the input buffer */ end = in + inlen; - if((inlen == 0) || (((int) inlen + curpos) < exppp_linelength)) { + if( ( inlen == 0 ) || ( ( ( int ) inlen + curpos ) < exppp_linelength ) ) { /* short enough to fit on current line */ - raw("%s'%s'", (printedSpaceLast ? "" : " "), in); + raw( "%s'%s'", ( printedSpaceLast ? "": " " ), in ); return; } /* insert newlines at dots as necessary */ - while((iptr < end) && (*iptr)) { - int i = nextBreakpoint(iptr, end); - maybeBreak(i, first); + while( ( iptr < end ) && ( *iptr ) ) { + int i = nextBreakpoint( iptr, end ); + maybeBreak( i, first ); first = false; - raw("%.*s", i, iptr); + raw( "%.*s", i, iptr ); iptr += i; } - raw("' "); + raw( "' "); } /* Interfacing Definitions */ @@ -410,11 +396,10 @@ static bool string_func_in_use = false; static bool file_func_in_use = false; /** return 0 if successful */ -int prep_buffer(char *buf, int len) -{ +int prep_buffer( char * buf, int len ) { /* this should never happen */ - if(string_func_in_use) { - fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); + if( string_func_in_use ) { + fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); return 1; } string_func_in_use = true; @@ -433,8 +418,7 @@ int prep_buffer(char *buf, int len) } /** \return length of string */ -int finish_buffer() -{ +int finish_buffer() { exppp_buf = 0; curpos = old_curpos; error_sym.line = old_lineno; @@ -443,18 +427,17 @@ int finish_buffer() } /** \return 0 if successful */ -int prep_string() -{ +int prep_string() { /* this should never happen */ - if(string_func_in_use) { - fprintf(stderr, "cannot generate EXPRESS string representations recursively!\n"); + if( string_func_in_use ) { + fprintf( stderr, "cannot generate EXPRESS string representations recursively!\n" ); return 1; } string_func_in_use = true; - exppp_buf = exppp_bufp = (char *)sc_malloc(BIGBUFSIZ); - if(!exppp_buf) { - fprintf(stderr, "failed to allocate exppp buffer\n"); + exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ ); + if( !exppp_buf ) { + fprintf( stderr, "failed to allocate exppp buffer\n" ); return 1; } exppp_buflen = exppp_maxbuflen = BIGBUFSIZ; @@ -469,12 +452,11 @@ int prep_string() return 0; } -char *finish_string() -{ - char *b = (char *)sc_realloc(exppp_buf, 1 + exppp_maxbuflen - exppp_buflen); +char * finish_string() { + char * b = ( char * )sc_realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); - if(b == 0) { - fprintf(stderr, "failed to reallocate exppp buffer\n"); + if( b == 0 ) { + fprintf( stderr, "failed to reallocate exppp buffer\n" ); return 0; } exppp_buf = 0; @@ -485,14 +467,13 @@ char *finish_string() return b; } -static FILE *oldfp; +static FILE * oldfp; -void prep_file() -{ +void prep_file() { /* this can only happen if user calls output func while suspended */ /* inside another output func both called from debugger */ - if(file_func_in_use) { - fprintf(stderr, "cannot print EXPRESS representations recursively!\n"); + if( file_func_in_use ) { + fprintf( stderr, "cannot print EXPRESS representations recursively!\n" ); } file_func_in_use = true; @@ -503,13 +484,12 @@ void prep_file() curpos = 1; } -void finish_file() -{ +void finish_file() { exppp_fp = oldfp; /* reset back to original file */ file_func_in_use = false; } -char *placeholder = "placeholder"; +char * placeholder = "placeholder"; diff --git a/src/exppp/pp.h b/src/exppp/pp.h index e2bfad19b..89825de6a 100644 --- a/src/exppp/pp.h +++ b/src/exppp/pp.h @@ -13,19 +13,19 @@ extern const int NOLEVEL; /**< unused-level indicator */ extern Symbol error_sym; /**< only used when printing errors */ extern Error ERROR_select_empty; -extern FILE *exppp_fp; +extern FILE * exppp_fp; extern bool first_line; /** output a string, exactly as provided * \sa wrap() */ -void raw(const char *fmt, ...); +void raw( const char * fmt, ... ); /** output a string, insert newlines to keep line length down * TODO list globals this func uses * \sa raw() */ -void wrap(const char *fmt, ...); +void wrap( const char * fmt, ... ); /** convert a real into our preferred form compatible with 10303-11 * (i.e. decimal point is required; no trailing zeros) @@ -33,7 +33,7 @@ void wrap(const char *fmt, ...); * \param r the real to convert * \returns const char pointer to static buffer containing ascii representation of real */ -const char *real2exp(double r); +const char * real2exp( double r ); /** Break a long un-encoded string up, enclose in '', output via raw() * if short, don't insert line breaks @@ -42,21 +42,21 @@ const char *real2exp(double r); * side effects: output via raw() * reads globals indent2 and curpos */ -void breakLongStr(const char *in); +void breakLongStr( const char * in ); int finish_buffer(); -int minimum(int a, int b, int c); -int prep_buffer(char *buf, int len); +int minimum( int a, int b, int c ); +int prep_buffer( char * buf, int len ); int prep_string(); void finish_file(); void first_newline(); void prep_file(); -char *finish_string(); -const char *real2exp(double r); -void exp_output(char *buf, unsigned int len); +char * finish_string(); +const char * real2exp( double r ); +void exp_output( char * buf, unsigned int len ); void exppp_init(); -void exppp_ref_info(Symbol *s); -extern char *placeholder; +void exppp_ref_info( Symbol * s ); +extern char * placeholder; #endif /* PP_H */ diff --git a/src/exppp/pretty_alg.c b/src/exppp/pretty_alg.c index 3899b8492..ba8a07aa5 100644 --- a/src/exppp/pretty_alg.c +++ b/src/exppp/pretty_alg.c @@ -13,19 +13,17 @@ #include "pretty_scope.h" #include "pretty_alg.h" -void ALGscope_out(Scope s, int level) -{ - SCOPEtypes_out(s, level); - SCOPEentities_out(s, level); - SCOPEalgs_out(s, level); - - SCOPEconsts_out(s, level); - SCOPElocals_out(s, level); +void ALGscope_out( Scope s, int level ) { + SCOPEtypes_out( s, level ); + SCOPEentities_out( s, level ); + SCOPEalgs_out( s, level ); + + SCOPEconsts_out( s, level ); + SCOPElocals_out( s, level ); } /** last arg is not terminated with ; or \n */ -void ALGargs_out(Linked_List args, int level) -{ +void ALGargs_out( Linked_List args, int level ) { Type previoustype = 0; bool previousVAR = false; indent2 = level + exppp_continuation_indent; @@ -37,27 +35,26 @@ void ALGargs_out(Linked_List args, int level) * flags.var is set in the formal_parameter production */ - LISTdo(args, v, Variable) { - if((previoustype != v->type) || (previousVAR != v->flags.var)) { - if(previoustype) { - wrap(" : "); - TYPE_head_out(previoustype, NOLEVEL); - raw(";\n"); + LISTdo( args, v, Variable ) { + if( ( previoustype != v->type ) || ( previousVAR != v->flags.var ) ) { + if( previoustype ) { + wrap( " : " ); + TYPE_head_out( previoustype, NOLEVEL ); + raw( ";\n" ); } - raw("%*s", level, ""); - if(v->flags.var) { - raw("VAR "); + raw( "%*s", level, "" ); + if( v->flags.var ) { + raw( "VAR " ); } - EXPR_out(VARget_name(v), 0); + EXPR_out( VARget_name( v ), 0 ); } else { - raw(", "); - EXPR_out(VARget_name(v), 0); + raw( ", " ); + EXPR_out( VARget_name( v ), 0 ); } previoustype = v->type; previousVAR = v->flags.var; - } - LISTod + } LISTod - wrap(" : "); - TYPE_head_out(previoustype, NOLEVEL); + wrap( " : " ); + TYPE_head_out( previoustype, NOLEVEL ); } diff --git a/src/exppp/pretty_alg.h b/src/exppp/pretty_alg.h index ab0c5f566..a365da9fc 100644 --- a/src/exppp/pretty_alg.h +++ b/src/exppp/pretty_alg.h @@ -4,7 +4,7 @@ #include #include -void ALGargs_out(Linked_List args, int level); -void ALGscope_out(Scope s, int level); +void ALGargs_out( Linked_List args, int level ); +void ALGscope_out( Scope s, int level ); #endif /* PRETTY_ALG_H */ diff --git a/src/exppp/pretty_case.c b/src/exppp/pretty_case.c index 086ab53a9..82a9f2772 100644 --- a/src/exppp/pretty_case.c +++ b/src/exppp/pretty_case.c @@ -10,66 +10,61 @@ #include "pretty_stmt.h" #include "pretty_case.h" -void CASEout(struct Case_Statement_ * c, int level) -{ +void CASEout( struct Case_Statement_ * c, int level ) { int len = 0, max_indent = 0, old_curpos = 0; - raw("%*sCASE ", level, ""); - EXPR_out(c->selector, 0); - wrap(" OF\n"); + raw( "%*sCASE ", level, "" ); + EXPR_out( c->selector, 0 ); + wrap( " OF\n" ); /* EXPRlength messes up curpos */ old_curpos = curpos; /* pass 1: calculate length of longest label */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { - len = EXPRlength(label); - } - LISTod + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { + len = EXPRlength( label ); + } LISTod } else { - len = strlen("OTHERWISE"); + len = strlen( "OTHERWISE" ); } - if(len > max_indent) { + if( len > max_indent ) { max_indent = len; } - } - LISTod + } LISTod curpos = old_curpos; level += exppp_nesting_indent; - if(max_indent + level > exppp_linelength / 2) { - max_indent = (exppp_linelength / 3) - level; + if( max_indent + level > exppp_linelength / 2 ) { + max_indent = ( exppp_linelength / 3 ) - level; } /* pass 2: print them */ - LISTdo(c->cases, ci, Case_Item) { - if(ci->labels) { - LISTdo_n(ci->labels, label, Expression, b) { + LISTdo( c->cases, ci, Case_Item ) { + if( ci->labels ) { + LISTdo_n( ci->labels, label, Expression, b ) { int spaces; /* print label(s) */ indent2 = level + exppp_continuation_indent; - raw("%*s", level, ""); - EXPR_out(label, 0); + raw( "%*s", level, "" ); + EXPR_out( label, 0 ); spaces = level + max_indent - curpos; - raw("%*s : ", ((spaces > 0) ? spaces : 0), ""); + raw( "%*s : ", ( ( spaces > 0 ) ? spaces : 0 ), "" ); /* print action */ - STMT_out(ci->action, level + exppp_nesting_indent); - } - LISTod + STMT_out( ci->action, level + exppp_nesting_indent ); + } LISTod } else { /* print OTHERWISE */ indent2 = level + exppp_continuation_indent; - raw("%*s", level, ""); - raw("OTHERWISE"); - raw("%*s : ", level + max_indent - curpos, ""); + raw( "%*s", level, "" ); + raw( "OTHERWISE" ); + raw( "%*s : ", level + max_indent - curpos, "" ); /* print action */ - STMT_out(ci->action, level + exppp_nesting_indent); + STMT_out( ci->action, level + exppp_nesting_indent ); } - } - LISTod + } LISTod - raw("%*sEND_CASE;\n", level, ""); + raw( "%*sEND_CASE;\n", level, "" ); } diff --git a/src/exppp/pretty_case.h b/src/exppp/pretty_case.h index 1028e0bf5..de46f417f 100644 --- a/src/exppp/pretty_case.h +++ b/src/exppp/pretty_case.h @@ -3,6 +3,6 @@ #include -void CASEout(struct Case_Statement_ * c, int level); +void CASEout( struct Case_Statement_ * c, int level ); #endif /* PRETTY_CASE_H */ diff --git a/src/exppp/pretty_entity.c b/src/exppp/pretty_entity.c index 248294bab..73d167bba 100644 --- a/src/exppp/pretty_entity.c +++ b/src/exppp/pretty_entity.c @@ -14,258 +14,244 @@ #include "pretty_type.h" #include "pretty_entity.h" -void ENTITY_out(Entity e, int level) -{ +void ENTITY_out( Entity e, int level ) { const unsigned int EXPLICIT = 0, DERIVED = 1; int linelen = exppp_linelength; bool first_time = true; first_newline(); - exppp_ref_info(&e->symbol); + exppp_ref_info( &e->symbol ); - raw("%*sENTITY %s", level, "", e->symbol.name); + raw( "%*sENTITY %s", level, "", e->symbol.name ); level += exppp_nesting_indent; indent2 = level + exppp_continuation_indent; exppp_linelength = indent2; /* force newlines */ - if(ENTITYget_abstract(e)) { - if(e->u.entity->subtype_expression) { - raw("\n%*sABSTRACT SUPERTYPE OF ", level, ""); - SUBTYPEout(e->u.entity->subtype_expression); + if( ENTITYget_abstract( e ) ) { + if( e->u.entity->subtype_expression ) { + raw( "\n%*sABSTRACT SUPERTYPE OF ", level, "" ); + SUBTYPEout( e->u.entity->subtype_expression ); } else { - raw("\n%*sABSTRACT SUPERTYPE", level, ""); + raw( "\n%*sABSTRACT SUPERTYPE", level, "" ); } } else { - if(e->u.entity->subtype_expression) { - raw("\n%*sSUPERTYPE OF ", level, ""); - SUBTYPEout(e->u.entity->subtype_expression); + if( e->u.entity->subtype_expression ) { + raw( "\n%*sSUPERTYPE OF ", level, "" ); + SUBTYPEout( e->u.entity->subtype_expression ); } } exppp_linelength = linelen; - if(e->u.entity->supertype_symbols) { - raw("\n%*sSUBTYPE OF ( ", level, ""); + if( e->u.entity->supertype_symbols ) { + raw( "\n%*sSUBTYPE OF ( ", level, "" ); - LISTdo(e->u.entity->supertype_symbols, s, Symbol *) - if(first_time) { + LISTdo( e->u.entity->supertype_symbols, s, Symbol * ) + if( first_time ) { first_time = false; } else { - raw(", "); + raw( ", " ); } - wrap(s->name); + wrap( s->name ); LISTod - raw(" )"); + raw( " )" ); } - raw(";\n"); + raw( ";\n" ); #if 0 /* add a little more space before entities if sub or super appears */ - if(e->u.entity->supertype_symbols || e->u.entity->subtype_expression) { - raw("\n"); + if( e->u.entity->supertype_symbols || e->u.entity->subtype_expression ) { + raw( "\n" ); } #endif - ENTITYattrs_out(e->u.entity->attributes, EXPLICIT, level); - ENTITYattrs_out(e->u.entity->attributes, DERIVED, level); - ENTITYinverse_out(e->u.entity->attributes, level); - ENTITYunique_out(e->u.entity->unique, level); - WHERE_out(TYPEget_where(e), level); + ENTITYattrs_out( e->u.entity->attributes, EXPLICIT, level ); + ENTITYattrs_out( e->u.entity->attributes, DERIVED, level ); + ENTITYinverse_out( e->u.entity->attributes, level ); + ENTITYunique_out( e->u.entity->unique, level ); + WHERE_out( TYPEget_where( e ), level ); level -= exppp_nesting_indent; - raw("%*sEND_ENTITY;", level, ""); - tail_comment(e->symbol.name); + raw( "%*sEND_ENTITY;", level, "" ); + tail_comment( e->symbol.name ); } -void ENTITYunique_out(Linked_List u, int level) -{ +void ENTITYunique_out( Linked_List u, int level ) { int i; int max_indent; - Symbol *sym; + Symbol * sym; - if(!u) { + if( !u ) { return; } - raw("%*sUNIQUE\n", level, ""); + raw( "%*sUNIQUE\n", level, "" ); /* pass 1 */ max_indent = 0; - LISTdo(u, list, Linked_List) { - if(0 != (sym = (Symbol *)LISTget_first(list))) { + LISTdo( u, list, Linked_List ) { + if( 0 != ( sym = ( Symbol * )LISTget_first( list ) ) ) { int length; - length = strlen(sym->name); - if(length > max_indent) { + length = strlen( sym->name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod level += exppp_nesting_indent; - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; - LISTdo(u, list, Linked_List) { + LISTdo( u, list, Linked_List ) { i = 0; - LISTdo_n(list, e, Expression, b) { + LISTdo_n( list, e, Expression, b ) { i++; - if(i == 1) { + if( i == 1 ) { /* print label if present */ - if(e) { - raw("%*s%-*s : ", level, "", max_indent, ((Symbol *)e)->name); + if( e ) { + raw( "%*s%-*s : ", level, "", max_indent, ( ( Symbol * )e )->name ); } else { - raw("%*s%-*s ", level, "", max_indent, ""); + raw( "%*s%-*s ", level, "", max_indent, "" ); } } else { - if(i > 2) { - raw(", "); + if( i > 2 ) { + raw( ", " ); } - EXPR_out(e, 0); + EXPR_out( e, 0 ); } - } - LISTod - raw(";\n"); - } - LISTod + } LISTod + raw( ";\n" ); + } LISTod } -void ENTITYinverse_out(Linked_List attrs, int level) -{ +void ENTITYinverse_out( Linked_List attrs, int level ) { int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { int length; - length = strlen(v->name->symbol.name); - if(length > max_indent) { + length = strlen( v->name->symbol.name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod - if(max_indent == 0) { + if( max_indent == 0 ) { return; } - raw("%*sINVERSE\n", level, ""); + raw( "%*sINVERSE\n", level, "" ); level += exppp_nesting_indent; - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: print them */ - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { /* print attribute name */ - raw("%*s", level, ""); - EXPR_out(v->name, 0); - raw("%-*s :", (((max_indent - curpos) > 0) ? max_indent - curpos : 0), ""); + raw( "%*s", level, "" ); + EXPR_out( v->name, 0 ); + raw( "%-*s :", ( ( ( max_indent - curpos ) > 0 ) ? max_indent - curpos : 0 ), "" ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); - raw(" FOR "); + raw( " FOR " ); - wrap(v->inverse_attribute->name->symbol.name); + wrap( v->inverse_attribute->name->symbol.name ); - raw(";\n"); + raw( ";\n" ); } - } - LISTod + } LISTod } -void ENTITYattrs_out(Linked_List attrs, int derived, int level) -{ +void ENTITYattrs_out( Linked_List attrs, int derived, int level ) { int max_indent; /* pass 1: calculate length of longest attr name */ max_indent = 0; - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { continue; } - if((derived && v->initializer) || - (!derived && !v->initializer)) { + if( ( derived && v->initializer ) || + ( !derived && !v->initializer ) ) { int length; - length = EXPRlength(v->name); - if(length > max_indent) { + length = EXPRlength( v->name ); + if( length > max_indent ) { max_indent = length; } } - } - LISTod + } LISTod - if(max_indent == 0) { + if( max_indent == 0 ) { return; } - if(derived) { - raw("%*sDERIVE\n", level, ""); + if( derived ) { + raw( "%*sDERIVE\n", level, "" ); } level += exppp_nesting_indent; - if(level + max_indent > exppp_linelength / 3) { - max_indent = (exppp_linelength / 3) - level; + if( level + max_indent > exppp_linelength / 3 ) { + max_indent = ( exppp_linelength / 3 ) - level; } - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: print them */ - LISTdo(attrs, v, Variable) { - if(v->inverse_symbol) { + LISTdo( attrs, v, Variable ) { + if( v->inverse_symbol ) { continue; } - if((derived && v->initializer) || (!derived && !v->initializer)) { + if( ( derived && v->initializer ) || ( !derived && !v->initializer ) ) { int spaces; /* print attribute name */ - raw("%*s", level, ""); - EXPR_out(v->name, 0); + raw( "%*s", level, "" ); + EXPR_out( v->name, 0 ); spaces = level + max_indent + 2 - curpos; - if(spaces < 0) { + if( spaces < 0 ) { spaces = 0; } - raw("%*s :", spaces, ""); + raw( "%*s :", spaces, "" ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); - if(derived && v->initializer) { - wrap(" := "); - EXPR_out(v->initializer, 0); + if( derived && v->initializer ) { + wrap( " := " ); + EXPR_out( v->initializer, 0 ); } - raw(";\n"); + raw( ";\n" ); } - } - LISTod + } LISTod } -char *ENTITYto_string(Entity e) -{ - if(prep_string()) { +char * ENTITYto_string( Entity e ) { + if( prep_string() ) { return placeholder; } - ENTITY_out(e, 0); - return (finish_string()); + ENTITY_out( e, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int ENTITYto_buffer(Entity e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int ENTITYto_buffer( Entity e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - ENTITY_out(e, 0); - return(finish_buffer()); + ENTITY_out( e, 0 ); + return( finish_buffer() ); } -void ENTITYout(Entity e) -{ +void ENTITYout( Entity e ) { prep_file(); - ENTITY_out(e, 0); + ENTITY_out( e, 0 ); finish_file(); } diff --git a/src/exppp/pretty_entity.h b/src/exppp/pretty_entity.h index 9b21e27c3..7c54ae446 100644 --- a/src/exppp/pretty_entity.h +++ b/src/exppp/pretty_entity.h @@ -7,13 +7,13 @@ #include "pp.h" -char *ENTITYto_string(Entity e); -void ENTITY_out(Entity e, int level); -void ENTITYattrs_out(Linked_List attrs, int derived, int level); -void ENTITYinverse_out(Linked_List attrs, int level); -void ENTITYout(Entity e); -int ENTITYto_buffer(Entity e, char *buffer, int length); -void ENTITYunique_out(Linked_List u, int level); +char * ENTITYto_string( Entity e ); +void ENTITY_out( Entity e, int level ); +void ENTITYattrs_out( Linked_List attrs, int derived, int level ); +void ENTITYinverse_out( Linked_List attrs, int level ); +void ENTITYout( Entity e ); +int ENTITYto_buffer( Entity e, char * buffer, int length ); +void ENTITYunique_out( Linked_List u, int level ); #endif /* PRETTY_ENTITY_H */ diff --git a/src/exppp/pretty_expr.c b/src/exppp/pretty_expr.c index 2fb2f023a..60a1c2ded 100644 --- a/src/exppp/pretty_expr.c +++ b/src/exppp/pretty_expr.c @@ -14,17 +14,16 @@ /** print array bounds */ -void EXPRbounds_out(TypeBody tb) -{ - if(!tb->upper) { +void EXPRbounds_out( TypeBody tb ) { + if( !tb->upper ) { return; } - wrap(" ["); - EXPR_out(tb->lower, 0); - wrap(" : "); - EXPR_out(tb->upper, 0); - raw("]"); + wrap( " [" ); + EXPR_out( tb->lower, 0 ); + wrap( " : " ); + EXPR_out( tb->upper, 0 ); + raw( "]" ); } /** @@ -33,138 +32,135 @@ void EXPRbounds_out(TypeBody tb) * precedence/associativity is not a problem) parens may be omitted. * if paren == 0, then parens may be omitted without consequence */ -void EXPR__out(Expression e, int paren, unsigned int previous_op) -{ +void EXPR__out( Expression e, int paren, unsigned int previous_op ) { int i; /* trusty temporary */ - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - wrap("?"); + if( e == LITERAL_INFINITY ) { + wrap( "?" ); } else { - wrap("%d", e->u.integer); + wrap( "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - wrap("PI"); - } else if(e == LITERAL_E) { - wrap("E"); + if( e == LITERAL_PI ) { + wrap( "PI" ); + } else if( e == LITERAL_E ) { + wrap( "E" ); } else { - wrap(real2exp(e->u.real)); + wrap( real2exp( e->u.real ) ); } break; case binary_: - wrap("%%%s", e->u.binary); /* put "%" back */ + wrap( "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - wrap("TRUE"); + wrap( "TRUE" ); break; case Lfalse: - wrap("FALSE"); + wrap( "FALSE" ); break; default: - wrap("UNKNOWN"); + wrap( "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - wrap("\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + wrap( "\"%s\"", e->symbol.name ); } else { - breakLongStr(e->symbol.name); + breakLongStr( e->symbol.name ); } break; case entity_: case identifier_: case attribute_: case enumeration_: - wrap("%s", e->symbol.name); + wrap( "%s", e->symbol.name ); break; case query_: - wrap("QUERY ( %s <* ", e->u.query->local->name->symbol.name); - EXPR_out(e->u.query->aggregate, 1); - wrap(" | "); - EXPR_out(e->u.query->expression, 1); - raw(" )"); + wrap( "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); + EXPR_out( e->u.query->aggregate, 1 ); + wrap( " | " ); + EXPR_out( e->u.query->expression, 1 ); + raw( " )" ); break; case self_: - wrap("SELF"); + wrap( "SELF" ); break; case funcall_: - wrap("%s( ", e->symbol.name); + wrap( "%s( ", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - EXPR_out(arg, 0); + EXPR_out( arg, 0 ); LISTod - raw(" )"); + raw( " )" ); break; case op_: - EXPRop__out(&e->e, paren, previous_op); + EXPRop__out( &e->e, paren, previous_op ); break; case aggregate_: - wrap("["); + wrap( "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if(i != 1) { - if(repeat) { - raw(" : "); + if( i != 1 ) { + if( repeat ) { + raw( " : " ); } else { - raw(", "); + raw( ", " ); } } - EXPR_out(arg, 0); - } - LISTod - raw("]"); + EXPR_out( arg, 0 ); + } LISTod + raw( "]" ); break; case oneof_: { int old_indent = indent2; - wrap("ONEOF ( "); + wrap( "ONEOF ( " ); - if(exppp_linelength == indent2) { + if( exppp_linelength == indent2 ) { exppp_linelength += exppp_continuation_indent; } indent2 += exppp_continuation_indent; i = 0; - LISTdo(e->u.list, arg, Expression) + LISTdo( e->u.list, arg, Expression ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - EXPR_out(arg, 1); + EXPR_out( arg, 1 ); LISTod - if(exppp_linelength == indent2) { + if( exppp_linelength == indent2 ) { exppp_linelength = old_indent; } indent2 = old_indent; - raw(" )"); + raw( " )" ); break; } default: - fprintf(stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis(e->type)); + fprintf( stderr, "%s:%d: ERROR - unknown expression, type %d", e->symbol.filename, e->symbol.line, TYPEis( e->type ) ); abort(); } } /** print expression that has op and operands */ -void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op) -{ +void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ) { const unsigned int PAD = 1, NOPAD = 0; - switch(oe->op_code) { + switch( oe->op_code ) { case OP_AND: case OP_ANDOR: case OP_OR: @@ -173,7 +169,7 @@ void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_o case OP_PLUS: case OP_TIMES: case OP_XOR: - EXPRop2__out(oe, (char *)0, paren, PAD, previous_op); + EXPRop2__out( oe, ( char * )0, paren, PAD, previous_op ); break; case OP_EXP: case OP_GREATER_EQUAL: @@ -186,91 +182,88 @@ void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_o case OP_LIKE: case OP_MOD: case OP_NOT_EQUAL: - EXPRop2_out(oe, (char *)0, paren, PAD); + EXPRop2_out( oe, ( char * )0, paren, PAD ); break; case OP_NOT: - EXPRop1_out(oe, "NOT ", paren); + EXPRop1_out( oe, "NOT ", paren ); break; case OP_REAL_DIV: - EXPRop2_out(oe, "/", paren, PAD); + EXPRop2_out( oe, "/", paren, PAD ); break; case OP_DIV: - EXPRop2_out(oe, "DIV", paren, PAD); + EXPRop2_out( oe, "DIV", paren, PAD ); break; case OP_MINUS: - EXPRop2_out(oe, "-", paren, PAD); + EXPRop2_out( oe, "-", paren, PAD ); break; case OP_DOT: - EXPRop2_out(oe, ".", paren, NOPAD); + EXPRop2_out( oe, ".", paren, NOPAD ); break; case OP_GROUP: - EXPRop2_out(oe, "\\", paren, NOPAD); + EXPRop2_out( oe, "\\", paren, NOPAD ); break; case OP_NEGATE: - EXPRop1_out(oe, "-", paren); + EXPRop1_out( oe, "-", paren ); break; case OP_ARRAY_ELEMENT: - EXPR_out(oe->op1, 1); - wrap("["); - EXPR_out(oe->op2, 0); - raw("]"); + EXPR_out( oe->op1, 1 ); + wrap( "[" ); + EXPR_out( oe->op2, 0 ); + raw( "]" ); break; case OP_SUBCOMPONENT: - EXPR_out(oe->op1, 1); - wrap("["); - EXPR_out(oe->op2, 0); - wrap(" : "); - EXPR_out(oe->op3, 0); - raw("]"); + EXPR_out( oe->op1, 1 ); + wrap( "[" ); + EXPR_out( oe->op2, 0 ); + wrap( " : " ); + EXPR_out( oe->op3, 0 ); + raw( "]" ); break; default: - wrap("(* unknown op-expression *)"); + wrap( "(* unknown op-expression *)" ); } } -void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op) -{ - if(pad && paren && (eo->op_code != previous_op)) { - wrap("( "); +void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ) { + if( pad && paren && ( eo->op_code != previous_op ) ) { + wrap( "( " ); } - EXPR__out(eo->op1, 1, eo->op_code); - if(pad) { - raw(" "); + EXPR__out( eo->op1, 1, eo->op_code ); + if( pad ) { + raw( " " ); } - wrap("%s", (opcode ? opcode : EXPop_table[eo->op_code].token)); - if(pad) { - wrap(" "); + wrap( "%s", ( opcode ? opcode : EXPop_table[eo->op_code].token ) ); + if( pad ) { + wrap( " " ); } - EXPR__out(eo->op2, 1, eo->op_code); - if(pad && paren && (eo->op_code != previous_op)) { - raw(" )"); + EXPR__out( eo->op2, 1, eo->op_code ); + if( pad && paren && ( eo->op_code != previous_op ) ) { + raw( " )" ); } } /** Print out a one-operand operation. If there were more than two of these * I'd generalize it to do padding, but it's not worth it. */ -void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren) -{ - if(paren) { - wrap("( "); +void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ) { + if( paren ) { + wrap( "( " ); } - wrap("%s", opcode); - EXPR_out(eo->op1, 1); - if(paren) { - raw(" )"); + wrap( "%s", opcode ); + EXPR_out( eo->op1, 1 ); + if( paren ) { + raw( " )" ); } } -int EXPRop_length(struct Op_Subexpression *oe) -{ - switch(oe->op_code) { +int EXPRop_length( struct Op_Subexpression * oe ) { + switch( oe->op_code ) { case OP_DOT: case OP_GROUP: - return(1 + EXPRlength(oe->op1) - + EXPRlength(oe->op2)); + return( 1 + EXPRlength( oe->op1 ) + + EXPRlength( oe->op2 ) ); default: - fprintf(stdout, "EXPRop_length: unknown op-expression"); + fprintf( stdout, "EXPRop_length: unknown op-expression" ); } return 0; } @@ -280,173 +273,165 @@ int EXPRop_length(struct Op_Subexpression *oe) * any kind of expression * contains fragment of string, adds to it */ -void EXPRstring(char *buffer, Expression e) -{ +void EXPRstring( char * buffer, Expression e ) { int i; - switch(TYPEis(e->type)) { + switch( TYPEis( e->type ) ) { case integer_: - if(e == LITERAL_INFINITY) { - strcpy(buffer, "?"); + if( e == LITERAL_INFINITY ) { + strcpy( buffer, "?" ); } else { - sprintf(buffer, "%d", e->u.integer); + sprintf( buffer, "%d", e->u.integer ); } break; case real_: - if(e == LITERAL_PI) { - strcpy(buffer, "PI"); - } else if(e == LITERAL_E) { - strcpy(buffer, "E"); + if( e == LITERAL_PI ) { + strcpy( buffer, "PI" ); + } else if( e == LITERAL_E ) { + strcpy( buffer, "E" ); } else { - sprintf(buffer, "%s", real2exp(e->u.real)); + sprintf( buffer, "%s", real2exp( e->u.real ) ); } break; case binary_: - sprintf(buffer, "%%%s", e->u.binary); /* put "%" back */ + sprintf( buffer, "%%%s", e->u.binary ); /* put "%" back */ break; case logical_: case boolean_: - switch(e->u.logical) { + switch( e->u.logical ) { case Ltrue: - strcpy(buffer, "TRUE"); + strcpy( buffer, "TRUE" ); break; case Lfalse: - strcpy(buffer, "FALSE"); + strcpy( buffer, "FALSE" ); break; default: - strcpy(buffer, "UNKNOWN"); + strcpy( buffer, "UNKNOWN" ); break; } break; case string_: - if(TYPEis_encoded(e->type)) { - sprintf(buffer, "\"%s\"", e->symbol.name); + if( TYPEis_encoded( e->type ) ) { + sprintf( buffer, "\"%s\"", e->symbol.name ); } else { - sprintf(buffer, "%s", e->symbol.name); + sprintf( buffer, "%s", e->symbol.name ); } break; case entity_: case identifier_: case attribute_: case enumeration_: - strcpy(buffer, e->symbol.name); + strcpy( buffer, e->symbol.name ); break; case query_: - sprintf(buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name); - EXPRstring(buffer + strlen(buffer), e->u.query->aggregate); - strcat(buffer, " | "); - EXPRstring(buffer + strlen(buffer), e->u.query->expression); - strcat(buffer, " )"); + sprintf( buffer, "QUERY ( %s <* ", e->u.query->local->name->symbol.name ); + EXPRstring( buffer + strlen( buffer ), e->u.query->aggregate ); + strcat( buffer, " | " ); + EXPRstring( buffer + strlen( buffer ), e->u.query->expression ); + strcat( buffer, " )" ); break; case self_: - strcpy(buffer, "SELF"); + strcpy( buffer, "SELF" ); break; case funcall_: - sprintf(buffer, "%s( ", e->symbol.name); + sprintf( buffer, "%s( ", e->symbol.name ); i = 0; - LISTdo(e->u.funcall.list, arg, Expression) + LISTdo( e->u.funcall.list, arg, Expression ) i++; - if(i != 1) { - strcat(buffer, ", "); + if( i != 1 ) { + strcat( buffer, ", " ); } - EXPRstring(buffer + strlen(buffer), arg); + EXPRstring( buffer + strlen( buffer ), arg ); LISTod - strcat(buffer, " )"); + strcat( buffer, " )" ); break; case op_: - EXPRop_string(buffer, &e->e); + EXPRop_string( buffer, &e->e ); break; case aggregate_: - strcpy(buffer, "["); + strcpy( buffer, "[" ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { bool repeat = arg->type->u.type->body->flags.repeat; /* if repeat is true, the previous Expression repeats and this one is the count */ i++; - if(i != 1) { - if(repeat) { - strcat(buffer, " : "); + if( i != 1 ) { + if( repeat ) { + strcat( buffer, " : " ); } else { - strcat(buffer, ", "); + strcat( buffer, ", " ); } } - EXPRstring(buffer + strlen(buffer), arg); - } - LISTod - strcat(buffer, "]"); + EXPRstring( buffer + strlen( buffer ), arg ); + } LISTod + strcat( buffer, "]" ); break; case oneof_: - strcpy(buffer, "ONEOF ( "); + strcpy( buffer, "ONEOF ( " ); i = 0; - LISTdo(e->u.list, arg, Expression) { + LISTdo( e->u.list, arg, Expression ) { i++; - if(i != 1) { - strcat(buffer, ", "); + if( i != 1 ) { + strcat( buffer, ", " ); } - EXPRstring(buffer + strlen(buffer), arg); - } - LISTod + EXPRstring( buffer + strlen( buffer ), arg ); + } LISTod - strcat(buffer, " )"); + strcat( buffer, " )" ); break; default: - sprintf(buffer, "EXPRstring: unknown expression, type %d", TYPEis(e->type)); - fprintf(stderr, "%s", buffer); + sprintf( buffer, "EXPRstring: unknown expression, type %d", TYPEis( e->type ) ); + fprintf( stderr, "%s", buffer ); } } -void EXPRop_string(char *buffer, struct Op_Subexpression *oe) -{ - EXPRstring(buffer, oe->op1); - switch(oe->op_code) { +void EXPRop_string( char * buffer, struct Op_Subexpression * oe ) { + EXPRstring( buffer, oe->op1 ); + switch( oe->op_code ) { case OP_DOT: - strcat(buffer, "."); + strcat( buffer, "." ); break; case OP_GROUP: - strcat(buffer, "\\"); + strcat( buffer, "\\" ); break; default: - strcat(buffer, "(* unknown op-expression *)"); + strcat( buffer, "(* unknown op-expression *)" ); } - EXPRstring(buffer + strlen(buffer), oe->op2); + EXPRstring( buffer + strlen( buffer ), oe->op2 ); } /** returns length of printable representation of expression w.o. printing it * doesn't understand as many expressions as the printing functions (!) * WARNING this *does* change the global 'curpos'! */ -int EXPRlength(Expression e) -{ +int EXPRlength( Expression e ) { char buffer[10000]; *buffer = '\0'; - EXPRstring(buffer, e); - return(strlen(buffer)); + EXPRstring( buffer, e ); + return( strlen( buffer ) ); } -char *EXPRto_string(Expression e) -{ - if(prep_string()) { +char * EXPRto_string( Expression e ) { + if( prep_string() ) { return placeholder; } - EXPR_out(e, 0); - return (finish_string()); + EXPR_out( e, 0 ); + return ( finish_string() ); } /** \return length of buffer used */ -int EXPRto_buffer(Expression e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int EXPRto_buffer( Expression e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - EXPR_out(e, 0); - return(finish_buffer()); + EXPR_out( e, 0 ); + return( finish_buffer() ); } -void EXPRout(Expression e) -{ +void EXPRout( Expression e ) { prep_file(); - EXPR_out(e, 0); + EXPR_out( e, 0 ); finish_file(); } diff --git a/src/exppp/pretty_expr.h b/src/exppp/pretty_expr.h index 39f9ce989..633bdf3f1 100644 --- a/src/exppp/pretty_expr.h +++ b/src/exppp/pretty_expr.h @@ -10,13 +10,13 @@ EXPRop2__out(oe,string,paren,pad,OP_UNKNOWN) #define EXPRop_out(oe,paren) EXPRop__out(oe,paren,OP_UNKNOWN) -void EXPRop__out(struct Op_Subexpression *oe, int paren, unsigned int previous_op); -void EXPRop_string(char *buffer, struct Op_Subexpression *oe); -void EXPRop1_out(struct Op_Subexpression *eo, char *opcode, int paren); -void EXPRop2__out(struct Op_Subexpression *eo, char *opcode, int paren, int pad, unsigned int previous_op); -void EXPR__out(Expression e, int paren, unsigned int previous_op); -void EXPRbounds_out(TypeBody tb); -int EXPRlength(Expression e); +void EXPRop__out( struct Op_Subexpression * oe, int paren, unsigned int previous_op ); +void EXPRop_string( char * buffer, struct Op_Subexpression * oe ); +void EXPRop1_out( struct Op_Subexpression * eo, char * opcode, int paren ); +void EXPRop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int pad, unsigned int previous_op ); +void EXPR__out( Expression e, int paren, unsigned int previous_op ); +void EXPRbounds_out( TypeBody tb ); +int EXPRlength( Expression e ); #endif /* PRETTY_EXPR_H */ diff --git a/src/exppp/pretty_express.c b/src/exppp/pretty_express.c index 911567126..610d5e938 100644 --- a/src/exppp/pretty_express.c +++ b/src/exppp/pretty_express.c @@ -9,15 +9,14 @@ #include "pretty_schema.h" #include "pretty_express.h" -void EXPRESSout(Express e) -{ +void EXPRESSout( Express e ) { Schema s; DictionaryEntry de; exppp_init(); - DICTdo_init(e->symbol_table, &de); - while(0 != (s = (Schema)DICTdo(&de))) { - (void) SCHEMAout(s); + DICTdo_init( e->symbol_table, &de ); + while( 0 != ( s = ( Schema )DICTdo( &de ) ) ) { + ( void ) SCHEMAout( s ); } } diff --git a/src/exppp/pretty_express.h b/src/exppp/pretty_express.h index 7ab337f4a..18d7e1296 100644 --- a/src/exppp/pretty_express.h +++ b/src/exppp/pretty_express.h @@ -1,6 +1,6 @@ #ifndef PRETTY_EXPRESS_H #define PRETTY_EXPRESS_H -void EXPRESSout(Express e); +void EXPRESSout( Express e ); #endif /* PRETTY_EXPRESS_H */ diff --git a/src/exppp/pretty_func.c b/src/exppp/pretty_func.c index f07f5291e..4129d7855 100644 --- a/src/exppp/pretty_func.c +++ b/src/exppp/pretty_func.c @@ -9,58 +9,54 @@ #include "pretty_stmt.h" #include "pretty_func.h" -void FUNC_out(Function fn, int level) -{ - if(fn->u.func->builtin) { +void FUNC_out( Function fn, int level ) { + if( fn->u.func->builtin ) { return; } first_newline(); - exppp_ref_info(&fn->symbol); - - raw("%*sFUNCTION %s", level, "", fn->symbol.name); - if(fn->u.func->parameters) { - unsigned int param_indent = level + strlen("FUNCTION "); - raw("(\n"); - ALGargs_out(fn->u.func->parameters, param_indent); - raw("\n%*s)", param_indent - exppp_continuation_indent, ""); + exppp_ref_info( &fn->symbol ); + + raw( "%*sFUNCTION %s", level, "", fn->symbol.name ); + if( fn->u.func->parameters ) { + unsigned int param_indent = level + strlen( "FUNCTION " ); + raw( "(\n" ); + ALGargs_out( fn->u.func->parameters, param_indent ); + raw( "\n%*s)", param_indent - exppp_continuation_indent, "" ); } - raw(" :"); + raw( " :" ); indent2 = curpos + exppp_continuation_indent; - TYPE_head_out(fn->u.func->return_type, NOLEVEL); - raw(";\n"); + TYPE_head_out( fn->u.func->return_type, NOLEVEL ); + raw( ";\n" ); - ALGscope_out(fn, level + exppp_nesting_indent); - STMTlist_out(fn->u.proc->body, level + exppp_nesting_indent); + ALGscope_out( fn, level + exppp_nesting_indent ); + STMTlist_out( fn->u.proc->body, level + exppp_nesting_indent ); - raw("\n%*sEND_FUNCTION;", level, ""); - tail_comment(fn->symbol.name); + raw( "\n%*sEND_FUNCTION;", level, "" ); + tail_comment( fn->symbol.name ); } -char *FUNCto_string(Function f) -{ - if(prep_string()) { +char * FUNCto_string( Function f ) { + if( prep_string() ) { return placeholder; } - FUNC_out(f, 0); - return (finish_string()); + FUNC_out( f, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int FUNCto_buffer(Function e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int FUNCto_buffer( Function e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - FUNC_out(e, 0); - return(finish_buffer()); + FUNC_out( e, 0 ); + return( finish_buffer() ); } -void FUNCout(Function f) -{ +void FUNCout( Function f ) { prep_file(); - FUNC_out(f, 0); + FUNC_out( f, 0 ); finish_file(); } diff --git a/src/exppp/pretty_func.h b/src/exppp/pretty_func.h index 71d857c6a..70d4b850d 100644 --- a/src/exppp/pretty_func.h +++ b/src/exppp/pretty_func.h @@ -3,10 +3,10 @@ #include -char *FUNCto_string(Function f); -void FUNC_out(Function fn, int level); -void FUNCout(Function f); -int FUNCto_buffer(Function e, char *buffer, int length); +char * FUNCto_string( Function f ); +void FUNC_out( Function fn, int level ); +void FUNCout( Function f ); +int FUNCto_buffer( Function e, char * buffer, int length ); #endif /* PRETTY_FUNC_H */ diff --git a/src/exppp/pretty_loop.c b/src/exppp/pretty_loop.c index da29fd58e..95a059f44 100644 --- a/src/exppp/pretty_loop.c +++ b/src/exppp/pretty_loop.c @@ -11,42 +11,41 @@ #include "pretty_stmt.h" #include "pretty_loop.h" -void LOOPout(struct Loop_ *loop, int level) -{ +void LOOPout( struct Loop_ *loop, int level ) { Variable v; - raw("%*sREPEAT", level, ""); + raw( "%*sREPEAT", level, "" ); /* increment */ /* if (loop->scope->u.incr) {*/ - if(loop->scope) { + if( loop->scope ) { DictionaryEntry de; - DICTdo_init(loop->scope->symbol_table, &de); - v = (Variable)DICTdo(&de); - wrap(" %s := ", v->name->symbol.name); - EXPR_out(loop->scope->u.incr->init, 0); - wrap(" TO "); - EXPR_out(loop->scope->u.incr->end, 0); - wrap(" BY "); /* parser always forces a "by" expr */ - EXPR_out(loop->scope->u.incr->increment, 0); + DICTdo_init( loop->scope->symbol_table, &de ); + v = ( Variable )DICTdo( &de ); + wrap( " %s := ", v->name->symbol.name ); + EXPR_out( loop->scope->u.incr->init, 0 ); + wrap( " TO " ); + EXPR_out( loop->scope->u.incr->end, 0 ); + wrap( " BY " ); /* parser always forces a "by" expr */ + EXPR_out( loop->scope->u.incr->increment, 0 ); } /* while */ - if(loop->while_expr) { - wrap(" WHILE "); - EXPR_out(loop->while_expr, 0); + if( loop->while_expr ) { + wrap( " WHILE " ); + EXPR_out( loop->while_expr, 0 ); } /* until */ - if(loop->until_expr) { - wrap(" UNTIL "); - EXPR_out(loop->until_expr, 0); + if( loop->until_expr ) { + wrap( " UNTIL " ); + EXPR_out( loop->until_expr, 0 ); } - raw(";\n"); + raw( ";\n" ); - STMTlist_out(loop->statements, level + exppp_nesting_indent); + STMTlist_out( loop->statements, level + exppp_nesting_indent ); - raw("%*sEND_REPEAT;\n", level, ""); + raw( "%*sEND_REPEAT;\n", level, "" ); } diff --git a/src/exppp/pretty_loop.h b/src/exppp/pretty_loop.h index 804f4b450..7a048211d 100644 --- a/src/exppp/pretty_loop.h +++ b/src/exppp/pretty_loop.h @@ -3,6 +3,6 @@ #include -void LOOPout(struct Loop_ *loop, int level); +void LOOPout( struct Loop_ *loop, int level ); #endif /* PRETTY_LOOP_H */ diff --git a/src/exppp/pretty_proc.c b/src/exppp/pretty_proc.c index cb297fbab..ee16d6853 100644 --- a/src/exppp/pretty_proc.c +++ b/src/exppp/pretty_proc.c @@ -8,51 +8,47 @@ #include "pretty_stmt.h" #include "pretty_proc.h" -char *PROCto_string(Procedure p) -{ - if(prep_string()) { +char * PROCto_string( Procedure p ) { + if( prep_string() ) { return placeholder; } - PROC_out(p, 0); - return (finish_string()); + PROC_out( p, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int PROCto_buffer(Procedure e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int PROCto_buffer( Procedure e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - PROC_out(e, 0); - return(finish_buffer()); + PROC_out( e, 0 ); + return( finish_buffer() ); } -void PROCout(Procedure p) -{ +void PROCout( Procedure p ) { prep_file(); - PROC_out(p, 0); + PROC_out( p, 0 ); finish_file(); } -void PROC_out(Procedure p, int level) -{ - if(p->u.proc->builtin) { +void PROC_out( Procedure p, int level ) { + if( p->u.proc->builtin ) { return; } first_newline(); - exppp_ref_info(&p->symbol); + exppp_ref_info( &p->symbol ); - raw("%*sPROCEDURE %s(\n", level, "", p->symbol.name); + raw( "%*sPROCEDURE %s(\n", level, "", p->symbol.name ); - ALGargs_out(p->u.proc->parameters, level + strlen("PROCEDURE ")); + ALGargs_out( p->u.proc->parameters, level + strlen( "PROCEDURE " ) ); - raw("%*s);\n", level + exppp_nesting_indent, ""); + raw( "%*s);\n", level + exppp_nesting_indent, "" ); - ALGscope_out(p, level + exppp_nesting_indent); - STMTlist_out(p->u.proc->body, level + exppp_nesting_indent); + ALGscope_out( p, level + exppp_nesting_indent ); + STMTlist_out( p->u.proc->body, level + exppp_nesting_indent ); - raw("\n%*sEND_PROCEDURE;", level, ""); - tail_comment(p->symbol.name); + raw( "\n%*sEND_PROCEDURE;", level, "" ); + tail_comment( p->symbol.name ); } diff --git a/src/exppp/pretty_proc.h b/src/exppp/pretty_proc.h index 46df8839e..22099878e 100644 --- a/src/exppp/pretty_proc.h +++ b/src/exppp/pretty_proc.h @@ -3,9 +3,9 @@ #include -char *PROCto_string(Procedure p); -void PROC_out(Procedure p, int level); -void PROCout(Procedure p); -int PROCto_buffer(Procedure e, char *buffer, int length); +char * PROCto_string( Procedure p ); +void PROC_out( Procedure p, int level ); +void PROCout( Procedure p ); +int PROCto_buffer( Procedure e, char * buffer, int length ); #endif /* PRETTY_PROC_H */ diff --git a/src/exppp/pretty_ref.c b/src/exppp/pretty_ref.c index 72cf13d1a..3d73efd77 100644 --- a/src/exppp/pretty_ref.c +++ b/src/exppp/pretty_ref.c @@ -8,64 +8,62 @@ #include "pp.h" #include "pretty_ref.h" -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level) -{ +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ) { Dictionary dict; DictionaryEntry de; - struct Rename *ren; + struct Rename * ren; Linked_List list; - LISTdo(reflist, s, Schema) - raw("%s FROM %s;\n", type, s->symbol.name); + LISTdo( reflist, s, Schema ) + raw( "%s FROM %s;\n", type, s->symbol.name ); LISTod - if(!refdict) { + if( !refdict ) { return; } - dict = DICTcreate(10); + dict = DICTcreate( 10 ); /* sort each list by schema */ /* step 1: for each entry, store it in a schema-specific list */ - DICTdo_init(refdict, &de); - while(0 != (ren = (struct Rename *)DICTdo(&de))) { + DICTdo_init( refdict, &de ); + while( 0 != ( ren = ( struct Rename * )DICTdo( &de ) ) ) { Linked_List nameList; - nameList = (Linked_List)DICTlookup(dict, ren->schema->symbol.name); - if(!nameList) { + nameList = ( Linked_List )DICTlookup( dict, ren->schema->symbol.name ); + if( !nameList ) { nameList = LISTcreate(); - DICTdefine(dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN); + DICTdefine( dict, ren->schema->symbol.name, nameList, NULL, OBJ_UNKNOWN ); } - LISTadd_last(nameList, ren); + LISTadd_last( nameList, ren ); } /* step 2: for each list, print out the renames */ level = 6; /* no special reason, feels good */ indent2 = level + exppp_continuation_indent; - DICTdo_init(dict, &de); - while(0 != (list = (Linked_List)DICTdo(&de))) { + DICTdo_init( dict, &de ); + while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) { bool first_time = true; - LISTdo(list, r, struct Rename *) { - if(first_time) { - raw("%s FROM %s\n", type, r->schema->symbol.name); + LISTdo( list, r, struct Rename * ) { + if( first_time ) { + raw( "%s FROM %s\n", type, r->schema->symbol.name ); } else { /* finish previous line */ - raw(",\n"); + raw( ",\n" ); } - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(r->old->name); - if(r->old != r->nnew) { - wrap(" AS %s", r->nnew->name); + raw( r->old->name ); + if( r->old != r->nnew ) { + wrap( " AS %s", r->nnew->name ); } - } - LISTod - raw(" );\n"); + } LISTod + raw( " );\n" ); } - HASHdestroy(dict); + HASHdestroy( dict ); } diff --git a/src/exppp/pretty_ref.h b/src/exppp/pretty_ref.h index 7d1f22535..2b1c1cf84 100644 --- a/src/exppp/pretty_ref.h +++ b/src/exppp/pretty_ref.h @@ -4,6 +4,6 @@ #include #include -void REFout(Dictionary refdict, Linked_List reflist, char *type, int level); +void REFout( Dictionary refdict, Linked_List reflist, char * type, int level ); #endif /* PRETTY_REF_H */ diff --git a/src/exppp/pretty_rule.c b/src/exppp/pretty_rule.c index 9e18ef21e..49d4d0e15 100644 --- a/src/exppp/pretty_rule.c +++ b/src/exppp/pretty_rule.c @@ -9,54 +9,50 @@ #include "pretty_where.h" #include "pretty_rule.h" -char *RULEto_string(Rule r) -{ - if(prep_string()) { +char * RULEto_string( Rule r ) { + if( prep_string() ) { return placeholder; } - RULE_out(r, 0); - return (finish_string()); + RULE_out( r, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int RULEto_buffer(Rule e, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int RULEto_buffer( Rule e, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - RULE_out(e, 0); - return(finish_buffer()); + RULE_out( e, 0 ); + return( finish_buffer() ); } -void RULEout(Rule r) -{ +void RULEout( Rule r ) { prep_file(); - RULE_out(r, 0); + RULE_out( r, 0 ); finish_file(); } -void RULE_out(Rule r, int level) -{ +void RULE_out( Rule r, int level ) { int i = 0; first_newline(); - exppp_ref_info(&r->symbol); + exppp_ref_info( &r->symbol ); - raw("%*sRULE %s FOR ( ", level, "", r->symbol.name); + raw( "%*sRULE %s FOR ( ", level, "", r->symbol.name ); - LISTdo(r->u.rule->parameters, p, Variable) + LISTdo( r->u.rule->parameters, p, Variable ) i++; - if(i != 1) { - raw(", "); + if( i != 1 ) { + raw( ", " ); } - wrap(p->name->symbol.name); + wrap( p->name->symbol.name ); LISTod; - raw(" );\n"); + raw( " );\n" ); - ALGscope_out(r, level + exppp_nesting_indent); - STMTlist_out(r->u.rule->body, level + exppp_nesting_indent); - raw("\n"); - WHERE_out(RULEget_where(r), level); + ALGscope_out( r, level + exppp_nesting_indent ); + STMTlist_out( r->u.rule->body, level + exppp_nesting_indent ); + raw( "\n" ); + WHERE_out( RULEget_where( r ), level ); - raw("\n%*sEND_RULE;", level, ""); - tail_comment(r->symbol.name); + raw( "\n%*sEND_RULE;", level, "" ); + tail_comment( r->symbol.name ); } diff --git a/src/exppp/pretty_rule.h b/src/exppp/pretty_rule.h index f507bde20..18d29e0c8 100644 --- a/src/exppp/pretty_rule.h +++ b/src/exppp/pretty_rule.h @@ -3,9 +3,9 @@ #include "../express/alg.h" -char *RULEto_string(Rule r); -void RULE_out(Rule r, int level); -void RULEout(Rule r); -int RULEto_buffer(Rule e, char *buffer, int length); +char * RULEto_string( Rule r ); +void RULE_out( Rule r, int level ); +void RULEout( Rule r ); +int RULEto_buffer( Rule e, char * buffer, int length ); #endif /* PRETTY_RULE_H */ diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 50940c413..6b555f379 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -19,48 +20,47 @@ # include /* for unlink */ #endif -char *exppp_output_filename = (char *)0; /* if this is set, override default output filename */ +char * exppp_output_filename = ( char * )0; /* if this is set, override default output filename */ char exppp_filename_buffer[1000]; /* output file name */ /* Only the first line is compared to an existing file, so putting a * version number in here won't cause problems. The actual version must * be inserted later - this can't be initialized with non-constant. */ -char *expheader[] = { - "(* This file was generated by the EXPRESS Pretty Printer exppp,", - "part of STEPcode (formerly NIST's SCL). exppp version:", - "" /* if there are two consecutive blank lines, */, - "" /* the version string will be printed on the first */, - "WARNING: If you modify this file and want to save the changes,", - "delete this comment block or else the file will be rewritten", - "the next time exppp processes this schema. *)", +char * expheader[] = { + "(* This file was generated by the EXPRESS Pretty Printer exppp," , + "part of STEPcode (formerly NIST's SCL). exppp version:" , + "" /* if there are two consecutive blank lines, */ , + "" /* the version string will be printed on the first */ , + "WARNING: If you modify this file and want to save the changes," , + "delete this comment block or else the file will be rewritten" , + "the next time exppp processes this schema. *)" , 0 }; /** returns name of file written to in static storage */ -char *SCHEMAout(Schema s) -{ -#define PP_SMALL_BUF_SZ 80 +char * SCHEMAout( Schema s ) { + #define PP_SMALL_BUF_SZ 80 char buf[PP_SMALL_BUF_SZ]; - char *p; + char * p; int level = 0; - char **hp; + char ** hp; bool described = false; - if(exppp_print_to_stdout) { + if( exppp_print_to_stdout ) { exppp_fp = stdout; } else { - FILE *f; - if(exppp_output_filename_reset) { + FILE * f; + if( exppp_output_filename_reset ) { exppp_output_filename = 0; } - if(exppp_output_filename) { - if(!strcmp(input_filename, exppp_output_filename)) { - fprintf(stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename); - exit(EXIT_FAILURE); + if( exppp_output_filename ) { + if( !strcmp( input_filename, exppp_output_filename ) ) { + fprintf( stderr, "Error: input filename and output filename are the same (%s)", exppp_output_filename ); + exit( EXIT_FAILURE ); } - strcpy(exppp_filename_buffer, exppp_output_filename); + strcpy( exppp_filename_buffer, exppp_output_filename ); } else { /* when there is only a single file, allow user to find */ /* out what it is */ @@ -70,47 +70,47 @@ char *SCHEMAout(Schema s) /* since we have to generate a filename, make sure we don't */ /* overwrite a valuable file */ - sprintf(exppp_filename_buffer, "%s.exp", s->symbol.name); + sprintf( exppp_filename_buffer, "%s.exp", s->symbol.name ); - if(0 != (f = fopen(exppp_filename_buffer, "r"))) { - char *result = fgets(buf, PP_SMALL_BUF_SZ, f); - if(0 != (p = strchr(buf, '\n'))) { + if( 0 != ( f = fopen( exppp_filename_buffer, "r" ) ) ) { + char * result = fgets( buf, PP_SMALL_BUF_SZ, f ); + if( 0 != ( p = strchr( buf, '\n' ) ) ) { *p = '\0'; } - if((!result) || (!strcmp(buf, expheader[0]))) { - unlink(exppp_filename_buffer); + if( ( !result ) || ( !strcmp( buf, expheader[0] ) ) ) { + unlink( exppp_filename_buffer ); } else { - fprintf(stderr, "%s: %s already exists and appears to be hand-written\n", - EXPRESSprogram_name, exppp_filename_buffer); + fprintf( stderr, "%s: %s already exists and appears to be hand-written\n", + EXPRESSprogram_name, exppp_filename_buffer ); /* strcat(bp,".pp");*/ - strcat(exppp_filename_buffer, ".pp"); - fprintf(stderr, "%s: writing schema file %s instead\n", - EXPRESSprogram_name, exppp_filename_buffer); + strcat( exppp_filename_buffer, ".pp" ); + fprintf( stderr, "%s: writing schema file %s instead\n", + EXPRESSprogram_name, exppp_filename_buffer ); described = true; } } - if(f) { - fclose(f); + if( f ) { + fclose( f ); } } error_sym.filename = exppp_filename_buffer; - if(!described && !exppp_terse) { - fprintf(stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer); + if( !described && !exppp_terse ) { + fprintf( stdout, "%s: writing schema file %s\n", EXPRESSprogram_name, exppp_filename_buffer ); } - if(!(exppp_fp = f = fopen(exppp_filename_buffer, "w"))) { - ERRORreport(FILE_UNWRITABLE, exppp_filename_buffer, strerror(errno)); + if( !( exppp_fp = f = fopen( exppp_filename_buffer, "w" ) ) ) { + ERRORreport( FILE_UNWRITABLE, exppp_filename_buffer, strerror( errno ) ); return 0; } } error_sym.line = 1; /* print our header - generated by exppp, don't edit, etc */ - for(hp = expheader; *hp; hp++) { - if((**hp == '\0') && (**(hp + 1) == '\0')) { + for( hp = expheader; *hp; hp++ ) { + if( ( **hp == '\0' ) && ( **( hp + 1 ) == '\0' ) ) { /* if this and the next lines are blank, put version string on this line */ - raw("%s\n", SC_VERSION); + raw( "%s\n", sc_version ); } else { - raw("%s\n", *hp); + raw( "%s\n", *hp ); } } @@ -118,15 +118,15 @@ char *SCHEMAout(Schema s) /* raw("SCHEMA %s;\n",s->symbol.name);*/ first_line = false; - raw("\nSCHEMA %s;\n", s->symbol.name); + raw( "\nSCHEMA %s;\n", s->symbol.name ); - if(s->u.schema->usedict || s->u.schema->use_schemas - || s->u.schema->refdict || s->u.schema->ref_schemas) { - raw("\n"); + if( s->u.schema->usedict || s->u.schema->use_schemas + || s->u.schema->refdict || s->u.schema->ref_schemas ) { + raw( "\n" ); } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", level + exppp_nesting_indent ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", level + exppp_nesting_indent ); /* output order for DIS & IS schemas: * CONSTANT @@ -139,47 +139,44 @@ char *SCHEMAout(Schema s) * Within each of those groups, declarations must be sorted alphabetically. */ - SCOPEconsts_out(s, level + exppp_nesting_indent); - SCOPEtypes_out(s, level + exppp_nesting_indent); - SCOPEentities_out(s, level + exppp_nesting_indent); - SCOPEalgs_out(s, level + exppp_nesting_indent); + SCOPEconsts_out( s, level + exppp_nesting_indent ); + SCOPEtypes_out( s, level + exppp_nesting_indent ); + SCOPEentities_out( s, level + exppp_nesting_indent ); + SCOPEalgs_out( s, level + exppp_nesting_indent ); - raw("\nEND_SCHEMA;"); - tail_comment(s->symbol.name); + raw( "\nEND_SCHEMA;"); + tail_comment( s->symbol.name ); - fclose(exppp_fp); + fclose( exppp_fp ); return exppp_filename_buffer; -#undef PP_SMALL_BUF_SZ + #undef PP_SMALL_BUF_SZ } -char *SCHEMAref_to_string(Schema s) -{ - if(prep_string()) { +char * SCHEMAref_to_string( Schema s ) { + if( prep_string() ) { return placeholder; } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); - return (finish_string()); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int SCHEMAref_to_buffer(Schema s, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int SCHEMAref_to_buffer( Schema s, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); - return(finish_buffer()); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); + return( finish_buffer() ); } -void SCHEMAref_out(Schema s) -{ +void SCHEMAref_out( Schema s ) { prep_file(); - REFout(s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0); - REFout(s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0); + REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 ); + REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 ); finish_file(); } diff --git a/src/exppp/pretty_schema.h b/src/exppp/pretty_schema.h index 7005bc363..b9c649f99 100644 --- a/src/exppp/pretty_schema.h +++ b/src/exppp/pretty_schema.h @@ -3,9 +3,9 @@ #include -char *SCHEMAout(Schema s); -char *SCHEMAref_to_string(Schema s); -void SCHEMAref_out(Schema s); -int SCHEMAref_to_buffer(Schema s, char *buffer, int length); +char * SCHEMAout( Schema s ); +char * SCHEMAref_to_string( Schema s ); +void SCHEMAref_out( Schema s ); +int SCHEMAref_to_buffer( Schema s, char * buffer, int length ); #endif /* PRETTY_SCHEMA_H */ diff --git a/src/exppp/pretty_scope.c b/src/exppp/pretty_scope.c index b3c92fc43..85fe041d1 100644 --- a/src/exppp/pretty_scope.c +++ b/src/exppp/pretty_scope.c @@ -13,121 +13,111 @@ #include "pretty_scope.h" /** add items from s to list alphabetically */ -void SCOPEadd_inorder(Linked_List list, Scope s) -{ +void SCOPEadd_inorder( Linked_List list, Scope s ) { Link k = 0; - LISTdo_links(list, link) - if(0 > strcmp( - SCOPEget_name(s), - SCOPEget_name((Type)(link->data)))) { + LISTdo_links( list, link ) + if( 0 > strcmp( + SCOPEget_name( s ), + SCOPEget_name( ( Type )( link->data ) ) ) ) { k = link; break; - } - LISTod + } LISTod - LISTadd_before(list, k, s); + LISTadd_before( list, k, s ); } /** like SCOPEadd_inorder, but for Variables */ -void SCOPEaddvars_inorder(Linked_List list, Variable v) -{ +void SCOPEaddvars_inorder( Linked_List list, Variable v ) { Link k = 0; - LISTdo_links(list, link) - if(0 > strcmp(v->name->symbol.name, ((Variable) link->data)->name->symbol.name)) { + LISTdo_links( list, link ) + if( 0 > strcmp( v->name->symbol.name, ( ( Variable ) link->data )->name->symbol.name ) ) { k = link; break; - } - LISTod + } LISTod - LISTadd_before(list, k, v); + LISTadd_before( list, k, v ); } /** print the rules in a scope */ -void SCOPErules_out(Scope s, int level) -{ +void SCOPErules_out( Scope s, int level ) { Rule r; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - RULE_out(r, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + RULE_out( r, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_RULE); - while(0 != (r = (Rule)DICTdo(&de))) { - SCOPEadd_inorder(alpha, r); + DICTdo_type_init( s->symbol_table, &de, OBJ_RULE ); + while( 0 != ( r = ( Rule )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, r ); } - LISTdo(alpha, ru, Rule) { - RULE_out(ru, level); - } - LISTod + LISTdo( alpha, ru, Rule ) { + RULE_out( ru, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /** print the functions in a scope */ -void SCOPEfuncs_out(Scope s, int level) -{ +void SCOPEfuncs_out( Scope s, int level ) { Function f; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - FUNC_out(f, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + FUNC_out( f, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_FUNCTION); - while(0 != (f = (Function)DICTdo(&de))) { - SCOPEadd_inorder(alpha, f); + DICTdo_type_init( s->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( f = ( Function )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, f ); } - LISTdo(alpha, fun, Function) { - FUNC_out(fun, level); - } - LISTod + LISTdo( alpha, fun, Function ) { + FUNC_out( fun, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /* print the procs in a scope */ -void SCOPEprocs_out(Scope s, int level) -{ +void SCOPEprocs_out( Scope s, int level ) { Procedure p; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - PROC_out(p, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + PROC_out( p, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_PROCEDURE); - while(0 != (p = (Procedure)DICTdo(&de))) { - SCOPEadd_inorder(alpha, p); + DICTdo_type_init( s->symbol_table, &de, OBJ_PROCEDURE ); + while( 0 != ( p = ( Procedure )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, p ); } - LISTdo(alpha, pr, Procedure) { - PROC_out(pr, level); - } - LISTod + LISTdo( alpha, pr, Procedure ) { + PROC_out( pr, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } @@ -143,252 +133,240 @@ void SCOPEprocs_out(Scope s, int level) * Within each of those groups, declarations must be sorted alphabetically. */ /* print the algorithms in a scope */ -void SCOPEalgs_out(Scope s, int level) -{ +void SCOPEalgs_out( Scope s, int level ) { /* Supplementary Directivies 2.1.1 requires rules to be separated */ /* might as well separate funcs and procs, too */ - SCOPErules_out(s, level); - SCOPEfuncs_out(s, level); - SCOPEprocs_out(s, level); + SCOPErules_out( s, level ); + SCOPEfuncs_out( s, level ); + SCOPEprocs_out( s, level ); } /** output one const - used in SCOPEconsts_out, below */ -void SCOPEconst_out(Variable v, int level, size_t max_indent) -{ +void SCOPEconst_out( Variable v, int level, size_t max_indent ) { size_t old_indent2; /* print attribute name */ - raw("%*s%-*s :", level + 2, "", - max_indent, v->name->symbol.name); + raw( "%*s%-*s :", level + 2, "", + max_indent, v->name->symbol.name ); /* print attribute type */ - if(VARget_optional(v)) { - wrap(" OPTIONAL"); + if( VARget_optional( v ) ) { + wrap( " OPTIONAL" ); } /* let type definition stick out a bit to the left if it's on a new line */ old_indent2 = indent2; - if(indent2 > 4) { + if( indent2 > 4 ) { indent2 -= 4; } - TYPE_head_out(v->type, NOLEVEL); + TYPE_head_out( v->type, NOLEVEL ); indent2 = old_indent2; - if(v->initializer) { + if( v->initializer ) { int old_ll = exppp_linelength; /* so exppp_linelength can be restored */ - raw(" :="); + raw( " :=" ); /* let '[' on first line of initializer stick out so strings are aligned */ - raw("\n%*s", indent2 - 2, ""); + raw( "\n%*s", indent2 - 2, "" ); - if(exppp_aggressively_wrap_consts) { + if( exppp_aggressively_wrap_consts ) { /* causes wrap() to always begin new line */ exppp_linelength = indent2; } - EXPR_out(v->initializer, 0); + EXPR_out( v->initializer, 0 ); exppp_linelength = old_ll; } - raw(";\n"); + raw( ";\n" ); } /** output all consts in this scope */ -void SCOPEconsts_out(Scope s, int level) -{ +void SCOPEconsts_out( Scope s, int level ) { Variable v; DictionaryEntry de; size_t max_indent = 0; Dictionary d = s->symbol_table; /* checks length of constant names */ - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - if(strlen(v->name->symbol.name) > max_indent) { - max_indent = strlen(v->name->symbol.name); + if( strlen( v->name->symbol.name ) > max_indent ) { + max_indent = strlen( v->name->symbol.name ); } } - if(!max_indent) { + if( !max_indent ) { return; } first_newline(); - raw("%*sCONSTANT\n", level, ""); + raw( "%*sCONSTANT\n", level, "" ); /* if max_indent is too big, wrap() won't insert any newlines * fiddled with this until it looked ok on 242 arm */ - if((max_indent + 20) > (size_t) exppp_linelength / 2) { - max_indent = (size_t) exppp_linelength / 3; + if( ( max_indent + 20 ) > ( size_t ) exppp_linelength / 2 ) { + max_indent = ( size_t ) exppp_linelength / 3; } - indent2 = level + max_indent + strlen(": ab") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": ab" ) + exppp_continuation_indent; - if(!exppp_alphabetize) { - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + if( !exppp_alphabetize ) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - SCOPEconst_out(v, level, max_indent); + SCOPEconst_out( v, level, max_indent ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !v->flags.constant ) { continue; } - SCOPEaddvars_inorder(alpha, v); + SCOPEaddvars_inorder( alpha, v ); } - LISTdo(alpha, cnst, Variable) { - SCOPEconst_out(cnst, level, max_indent); - } - LISTod - LISTfree(alpha); + LISTdo( alpha, cnst, Variable ) { + SCOPEconst_out( cnst, level, max_indent ); + } LISTod + LISTfree( alpha ); } - raw("%*sEND_CONSTANT;\n", level, ""); + raw( "%*sEND_CONSTANT;\n", level, "" ); } /** insert variable v into list, keeping the list ordered by ascending v->offset */ -void SCOPElocals_order(Linked_List list, Variable v) -{ - LISTdo_links(list, link) { - if(v->offset < ((Variable) link->data)->offset) { - LISTadd_before(list, link, v); +void SCOPElocals_order( Linked_List list, Variable v ) { + LISTdo_links( list, link ) { + if( v->offset < ( (Variable) link->data )->offset ) { + LISTadd_before( list, link, v ); return; } - } - LISTod - LISTadd_last(list, v); + } LISTod + LISTadd_last( list, v ); } -void SCOPElocals_out(Scope s, int level) -{ +void SCOPElocals_out( Scope s, int level ) { Variable v; DictionaryEntry de; Linked_List orderedLocals = 0; /**< this list is used to order the vars the same way they were in the file */ size_t max_indent = 0; Dictionary d = s->symbol_table; - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( v->flags.constant ) { continue; } - if(v->flags.parameter) { + if( v->flags.parameter ) { continue; } - if(strlen(v->name->symbol.name) > max_indent) { - max_indent = strlen(v->name->symbol.name); + if( strlen( v->name->symbol.name ) > max_indent ) { + max_indent = strlen( v->name->symbol.name ); } } - if(!max_indent) { + if( !max_indent ) { return; } first_newline(); - raw("%*sLOCAL\n", level, ""); - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + raw( "%*sLOCAL\n", level, "" ); + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; - DICTdo_type_init(d, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(v->flags.constant) { + DICTdo_type_init( d, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( v->flags.constant ) { continue; } - if(v->flags.parameter) { + if( v->flags.parameter ) { continue; } - if(!orderedLocals) { + if( !orderedLocals ) { orderedLocals = LISTcreate(); - LISTadd_first(orderedLocals, v); + LISTadd_first( orderedLocals, v ); } else { /* sort by v->offset */ - SCOPElocals_order(orderedLocals, v); + SCOPElocals_order( orderedLocals, v ); } } - LISTdo(orderedLocals, var, Variable) { + LISTdo( orderedLocals, var, Variable ) { /* print attribute name */ - raw("%*s%-*s :", level + exppp_nesting_indent, "", - max_indent, var->name->symbol.name); + raw( "%*s%-*s :", level + exppp_nesting_indent, "", + max_indent, var->name->symbol.name ); /* print attribute type */ - if(VARget_optional(var)) { - wrap(" OPTIONAL"); + if( VARget_optional( var ) ) { + wrap( " OPTIONAL" ); } - TYPE_head_out(var->type, NOLEVEL); + TYPE_head_out( var->type, NOLEVEL ); - if(var->initializer) { - wrap(" := "); - EXPR_out(var->initializer, 0); + if( var->initializer ) { + wrap( " := " ); + EXPR_out( var->initializer, 0 ); } - raw(";\n"); - } - LISTod - LISTfree(orderedLocals); + raw( ";\n" ); + } LISTod + LISTfree( orderedLocals ); - raw("%*sEND_LOCAL;\n", level, ""); + raw( "%*sEND_LOCAL;\n", level, "" ); } /** print all entities in a scope */ -void SCOPEentities_out(Scope s, int level) -{ +void SCOPEentities_out( Scope s, int level ) { Entity e; DictionaryEntry de; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); - while(0 != (e = (Entity)DICTdo(&de))) { - ENTITY_out(e, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { + ENTITY_out( e, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_ENTITY); - while(0 != (e = (Entity)DICTdo(&de))) { - SCOPEadd_inorder(alpha, e); + DICTdo_type_init( s->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( e = ( Entity )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, e ); } - LISTdo(alpha, en, Entity) { - ENTITY_out(en, level); - } - LISTod + LISTdo( alpha, en, Entity ) { + ENTITY_out( en, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } /** print all types in a scope */ -void SCOPEtypes_out(Scope s, int level) -{ +void SCOPEtypes_out( Scope s, int level ) { DictionaryEntry de; Type t; - if(exppp_alphabetize == false) { - DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); - while(0 != (t = (Type)DICTdo(&de))) { - TYPE_out(t, level); + if( exppp_alphabetize == false ) { + DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); + while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { + TYPE_out( t, level ); } } else { Linked_List alpha = LISTcreate(); - DICTdo_type_init(s->symbol_table, &de, OBJ_TYPE); - while(0 != (t = (Type)DICTdo(&de))) { - SCOPEadd_inorder(alpha, t); + DICTdo_type_init( s->symbol_table, &de, OBJ_TYPE ); + while( 0 != ( t = ( Type )DICTdo( &de ) ) ) { + SCOPEadd_inorder( alpha, t ); } - LISTdo(alpha, ty, Type) { - TYPE_out(ty, level); - } - LISTod + LISTdo( alpha, ty, Type ) { + TYPE_out( ty, level ); + } LISTod - LISTfree(alpha); + LISTfree( alpha ); } } diff --git a/src/exppp/pretty_scope.h b/src/exppp/pretty_scope.h index 82a64221d..1e4e82e7d 100644 --- a/src/exppp/pretty_scope.h +++ b/src/exppp/pretty_scope.h @@ -6,15 +6,15 @@ #include "pp.h" -void SCOPEadd_inorder(Linked_List list, Scope s); -void SCOPEalgs_out(Scope s, int level); -void SCOPEconsts_out(Scope s, int level); -void SCOPEentities_out(Scope s, int level); -void SCOPEfuncs_out(Scope s, int level); -void SCOPElocals_out(Scope s, int level); -void SCOPEprocs_out(Scope s, int level); -void SCOPErules_out(Scope s, int level); -void SCOPEtypes_out(Scope s, int level); +void SCOPEadd_inorder( Linked_List list, Scope s ); +void SCOPEalgs_out( Scope s, int level ); +void SCOPEconsts_out( Scope s, int level ); +void SCOPEentities_out( Scope s, int level ); +void SCOPEfuncs_out( Scope s, int level ); +void SCOPElocals_out( Scope s, int level ); +void SCOPEprocs_out( Scope s, int level ); +void SCOPErules_out( Scope s, int level ); +void SCOPEtypes_out( Scope s, int level ); #endif /* PRETTY_SCOPE_H */ diff --git a/src/exppp/pretty_stmt.c b/src/exppp/pretty_stmt.c index b99aaa2e5..7694577ed 100644 --- a/src/exppp/pretty_stmt.c +++ b/src/exppp/pretty_stmt.c @@ -9,115 +9,110 @@ #include "pretty_loop.h" #include "pretty_stmt.h" -void STMT_out(Statement s, int level) -{ +void STMT_out( Statement s, int level ) { bool first_time = true; - if(!s) { /* null statement */ - raw("%*s;\n", level, ""); + if( !s ) { /* null statement */ + raw( "%*s;\n", level, "" ); return; } indent2 = level + exppp_continuation_indent; - switch(s->type) { + switch( s->type ) { case STMT_ASSIGN: - raw("%*s", level, ""); - EXPR_out(s->u.assign->lhs, 0); - wrap(" := "); - EXPR_out(s->u.assign->rhs, 0); - raw(";\n", level, ""); + raw( "%*s", level, "" ); + EXPR_out( s->u.assign->lhs, 0 ); + wrap( " := " ); + EXPR_out( s->u.assign->rhs, 0 ); + raw( ";\n", level, "" ); break; case STMT_CASE: - CASEout(s->u.Case, level); + CASEout( s->u.Case, level ); break; case STMT_COMPOUND: - raw("\n%*sBEGIN\n", level, ""); - STMTlist_out(s->u.compound->statements, level + exppp_nesting_indent); - raw("%*sEND;\n", level, ""); + raw( "\n%*sBEGIN\n", level, "" ); + STMTlist_out( s->u.compound->statements, level + exppp_nesting_indent ); + raw( "%*sEND;\n", level, "" ); break; case STMT_COND: - raw("%*sIF ", level, ""); - EXPR_out(s->u.cond->test, 0); - wrap(" THEN\n"); - STMTlist_out(s->u.cond->code, level + exppp_nesting_indent); - if(s->u.cond->otherwise) { - raw("%*sELSE\n", level, ""); - STMTlist_out(s->u.cond->otherwise, level + exppp_nesting_indent); + raw( "%*sIF ", level, "" ); + EXPR_out( s->u.cond->test, 0 ); + wrap( " THEN\n" ); + STMTlist_out( s->u.cond->code, level + exppp_nesting_indent ); + if( s->u.cond->otherwise ) { + raw( "%*sELSE\n", level, "" ); + STMTlist_out( s->u.cond->otherwise, level + exppp_nesting_indent ); } - raw("%*sEND_IF;\n", level, ""); + raw( "%*sEND_IF;\n", level, "" ); break; case STMT_LOOP: - LOOPout(s->u.loop, level); + LOOPout( s->u.loop, level ); break; case STMT_PCALL: - raw("%*s%s( ", level, "", s->symbol.name); - LISTdo(s->u.proc->parameters, p, Expression) - if(first_time) { + raw( "%*s%s( ", level, "", s->symbol.name ); + LISTdo( s->u.proc->parameters, p, Expression ) + if( first_time ) { first_time = false; } else { - raw(", "); + raw( ", " ); } - EXPR_out(p, 0); + EXPR_out( p, 0 ); LISTod - raw(" );\n"); + raw( " );\n" ); break; case STMT_RETURN: - raw("%*sRETURN", level, ""); - if(s->u.ret->value) { - wrap("( "); - EXPR_out(s->u.ret->value, 0); - raw(" )"); + raw( "%*sRETURN", level, "" ); + if( s->u.ret->value ) { + wrap( "( " ); + EXPR_out( s->u.ret->value, 0 ); + raw( " )" ); } - raw(";\n"); + raw( ";\n" ); break; case STMT_ALIAS: - raw("%*sALIAS %s for %s;\n", level, "", s->symbol.name, - /* should be generalized reference */ - s->u.alias->variable->name->symbol.name); - STMTlist_out(s->u.alias->statements, level + exppp_nesting_indent); - raw("%*sEND_ALIAS;", level, ""); - tail_comment(s->symbol.name); + raw( "%*sALIAS %s for %s;\n", level, "", s->symbol.name, + /* should be generalized reference */ + s->u.alias->variable->name->symbol.name ); + STMTlist_out( s->u.alias->statements, level + exppp_nesting_indent ); + raw( "%*sEND_ALIAS;", level, "" ); + tail_comment( s->symbol.name ); break; case STMT_SKIP: - raw("%*sSKIP;\n", level, ""); + raw( "%*sSKIP;\n", level, "" ); break; case STMT_ESCAPE: - raw("%*sESCAPE;\n", level, ""); + raw( "%*sESCAPE;\n", level, "" ); break; } } -void STMTlist_out(Linked_List stmts, int level) -{ - LISTdo(stmts, stmt, Statement) - STMT_out(stmt, level); +void STMTlist_out( Linked_List stmts, int level ) { + LISTdo( stmts, stmt, Statement ) + STMT_out( stmt, level ); LISTod } -char *STMTto_string(Statement s) -{ - if(prep_string()) { +char * STMTto_string( Statement s ) { + if( prep_string() ) { return placeholder; } - STMT_out(s, 0); - return (finish_string()); + STMT_out( s, 0 ); + return ( finish_string() ); } /* return length of buffer used */ -int STMTto_buffer(Statement s, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int STMTto_buffer( Statement s, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - STMT_out(s, 0); - return(finish_buffer()); + STMT_out( s, 0 ); + return( finish_buffer() ); } -void STMTout(Statement s) -{ +void STMTout( Statement s ) { prep_file(); - STMT_out(s, 0); + STMT_out( s, 0 ); finish_file(); } diff --git a/src/exppp/pretty_stmt.h b/src/exppp/pretty_stmt.h index f25d8bbde..fe75ff372 100644 --- a/src/exppp/pretty_stmt.h +++ b/src/exppp/pretty_stmt.h @@ -4,11 +4,11 @@ #include #include -char *STMTto_string(Statement s); -void STMT_out(Statement s, int level); -void STMTlist_out(Linked_List stmts, int level); -void STMTout(Statement s); -int STMTto_buffer(Statement s, char *buffer, int length); +char * STMTto_string( Statement s ); +void STMT_out( Statement s, int level ); +void STMTlist_out( Linked_List stmts, int level ); +void STMTout( Statement s ); +int STMTto_buffer( Statement s, char * buffer, int length ); #endif /* PRETTY_STMT_H */ diff --git a/src/exppp/pretty_subtype.c b/src/exppp/pretty_subtype.c index 1113d6ee1..d47298e49 100644 --- a/src/exppp/pretty_subtype.c +++ b/src/exppp/pretty_subtype.c @@ -10,27 +10,25 @@ #include "pretty_expr.h" #include "pretty_subtype.h" -void SUBTYPEout(Expression e) -{ +void SUBTYPEout( Expression e ) { /* language insists on having parens around entity names */ /* even if there is only one, but if the expression is */ /* complex, EXPRout will add on its own parens */ /* if (TYPEis_expression(e->type)) {*/ - raw("( "); + raw( "( " ); /* }*/ - EXPR_out(e, 0); + EXPR_out( e, 0 ); /* if (TYPEis_expression(e->type)) {*/ - raw(" )"); + raw( " )" ); /* }*/ } -char *SUBTYPEto_string(Expression e) -{ - if(prep_string()) { +char * SUBTYPEto_string( Expression e ) { + if( prep_string() ) { return placeholder; } - EXPR_out(e, 0); - return (finish_string()); + EXPR_out( e, 0 ); + return ( finish_string() ); } diff --git a/src/exppp/pretty_subtype.h b/src/exppp/pretty_subtype.h index d938093b1..4ff6ef085 100644 --- a/src/exppp/pretty_subtype.h +++ b/src/exppp/pretty_subtype.h @@ -3,8 +3,8 @@ #include -char *SUBTYPEto_string(Expression e); -void SUBTYPEout(Expression e); +char * SUBTYPEto_string( Expression e ); +void SUBTYPEout( Expression e ); #endif /* PRETTY_SUBTYPE_H */ diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index c6e7c580a..d18402ddc 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -14,293 +14,280 @@ #include "pretty_type.h" /** print a type definition. I.e., a TYPE statement */ -void TYPE_out(Type t, int level) -{ +void TYPE_out( Type t, int level ) { first_newline(); - exppp_ref_info(&t->symbol); + exppp_ref_info( &t->symbol ); - raw("%*sTYPE %s =", level, "", t->symbol.name); - if(TYPEget_head(t)) { - wrap(" %s", TYPEget_name(TYPEget_head(t))); + raw( "%*sTYPE %s =", level, "", t->symbol.name ); + if( TYPEget_head( t ) ) { + wrap( " %s", TYPEget_name( TYPEget_head( t ) ) ); } else { - TYPE_body_out(t, level + exppp_nesting_indent); + TYPE_body_out( t, level + exppp_nesting_indent ); } - raw(";\n"); + raw( ";\n" ); - WHERE_out(t->where, level); + WHERE_out( t->where, level ); - raw("%*sEND_TYPE;", level, ""); - tail_comment(t->symbol.name); + raw( "%*sEND_TYPE;", level, "" ); + tail_comment( t->symbol.name ); } /** prints type description (preceded by a space). * I.e., the type of an attribute or other object */ -void TYPE_head_out(Type t, int level) -{ - if(t->symbol.name) { +void TYPE_head_out( Type t, int level ) { + if( t->symbol.name ) { int old_indent = indent2; - if(indent2 + (int) strlen(t->symbol.name) > exppp_linelength) { - indent2 = (indent2 + level) / 2; + if( indent2 + ( int ) strlen( t->symbol.name ) > exppp_linelength ) { + indent2 = ( indent2 + level ) / 2; } - wrap(" %s", t->symbol.name); + wrap( " %s", t->symbol.name ); indent2 = old_indent; } else { - TYPE_body_out(t, level); + TYPE_body_out( t, level ); } } -void TYPEunique_or_optional_out(TypeBody tb) -{ - if(tb->flags.unique) { - wrap(" UNIQUE"); +void TYPEunique_or_optional_out( TypeBody tb ) { + if( tb->flags.unique ) { + wrap( " UNIQUE" ); } - if(tb->flags.optional) { - wrap(" OPTIONAL"); + if( tb->flags.optional ) { + wrap( " OPTIONAL" ); } } -void TYPE_body_out(Type t, int level) -{ +void TYPE_body_out( Type t, int level ) { bool first_time = true; Expression expr; DictionaryEntry de; - TypeBody tb = TYPEget_body(t); + TypeBody tb = TYPEget_body( t ); - switch(tb->type) { + switch( tb->type ) { case integer_: - wrap(" INTEGER"); + wrap( " INTEGER" ); break; case real_: - wrap(" REAL"); + wrap( " REAL" ); break; case string_: - wrap(" STRING"); + wrap( " STRING" ); break; case binary_: - wrap(" BINARY"); + wrap( " BINARY" ); break; case boolean_: - wrap(" BOOLEAN"); + wrap( " BOOLEAN" ); break; case logical_: - wrap(" LOGICAL"); + wrap( " LOGICAL" ); break; case number_: - wrap(" NUMBER"); + wrap( " NUMBER" ); break; case entity_: - wrap(" %s", tb->entity->symbol.name); + wrap( " %s", tb->entity->symbol.name ); break; case aggregate_: case array_: case bag_: case set_: case list_: - switch(tb->type) { + switch( tb->type ) { /* ignore the aggregate bounds for now */ case aggregate_: - wrap(" AGGREGATE"); - if(tb->tag) { - wrap(":%s", tb->tag->symbol.name); + wrap( " AGGREGATE" ); + if( tb->tag ) { + wrap( ":%s", tb->tag->symbol.name ); } - wrap(" OF"); + wrap( " OF" ); break; case array_: - wrap(" ARRAY"); - EXPRbounds_out(tb); - wrap(" OF"); - TYPEunique_or_optional_out(tb); + wrap( " ARRAY" ); + EXPRbounds_out( tb ); + wrap( " OF" ); + TYPEunique_or_optional_out( tb ); break; case bag_: - wrap(" BAG"); - EXPRbounds_out(tb); - wrap(" OF"); + wrap( " BAG" ); + EXPRbounds_out( tb ); + wrap( " OF" ); break; case set_: - wrap(" SET"); - EXPRbounds_out(tb); - wrap(" OF"); + wrap( " SET" ); + EXPRbounds_out( tb ); + wrap( " OF" ); break; case list_: - wrap(" LIST"); - EXPRbounds_out(tb); - wrap(" OF"); - TYPEunique_or_optional_out(tb); + wrap( " LIST" ); + EXPRbounds_out( tb ); + wrap( " OF" ); + TYPEunique_or_optional_out( tb ); break; default: - fprintf(stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__); + fprintf( stderr, "exppp: Reached default case, %s:%d", __FILE__, __LINE__ ); abort(); } - TYPE_head_out(tb->base, level); + TYPE_head_out( tb->base, level ); break; case enumeration_: { int i, count = 0; - char **names; + char ** names; /* * write names out in original order by first bucket sorting * to a temporary array. This is trivial since all buckets * will get filled with one and only one object. */ - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (expr = (Expression)DICTdo(&de))) { + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { count++; } - names = (char **)sc_malloc(count * sizeof(char *)); - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (expr = (Expression)DICTdo(&de))) { + names = ( char ** )sc_malloc( count * sizeof( char * ) ); + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { names[expr->u.integer - 1] = expr->symbol.name; } - wrap(" ENUMERATION OF\n"); + wrap( " ENUMERATION OF\n" ); - for(i = 0; i < count; i++) { + for( i = 0; i < count; i++ ) { /* finish line from previous enum item */ - if(!first_time) { - raw(",\n"); + if( !first_time ) { + raw( ",\n" ); } /* start new enum item */ - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(names[i]); + raw( names[i] ); } - raw(" )"); - sc_free((char *)names); + raw( " )" ); + sc_free( ( char * )names ); } break; case select_: - wrap(" SELECT\n"); - LISTdo(tb->list, type, Type) + wrap( " SELECT\n" ); + LISTdo( tb->list, type, Type ) /* finish line from previous entity */ - if(!first_time) { - raw(",\n"); + if( !first_time ) { + raw( ",\n" ); } /* start new entity */ - if(first_time) { - raw("%*s( ", level, ""); + if( first_time ) { + raw( "%*s( ", level, "" ); first_time = false; } else { - raw("%*s ", level, ""); + raw( "%*s ", level, "" ); } - raw(type->symbol.name); + raw( type->symbol.name ); LISTod /* if empty, force a left paren */ - if(first_time) { - ERRORreport_with_symbol(SELECT_EMPTY, &error_sym, t->symbol.name); - raw("%*s( ", level, ""); + if( first_time ) { + ERRORreport_with_symbol( SELECT_EMPTY, &error_sym, t->symbol.name ); + raw( "%*s( ", level, "" ); } - raw(" )"); + raw( " )" ); break; case generic_: - wrap(" GENERIC"); - if(tb->tag) { - wrap(":%s", tb->tag->symbol.name); + wrap( " GENERIC" ); + if( tb->tag ) { + wrap( ":%s", tb->tag->symbol.name ); } break; default: - wrap(" (* unknown type %d *)", tb->type); + wrap( " (* unknown type %d *)", tb->type ); } - if(tb->precision) { - wrap(" ( "); - EXPR_out(tb->precision, 0); - raw(" )"); + if( tb->precision ) { + wrap( " ( " ); + EXPR_out( tb->precision, 0 ); + raw( " )" ); } - if(tb->flags.fixed) { - wrap(" FIXED"); + if( tb->flags.fixed ) { + wrap( " FIXED" ); } } -char *TYPEto_string(Type t) -{ - if(prep_string()) { +char * TYPEto_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_out(t, 0); - return (finish_string()); + TYPE_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEto_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEto_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_out(t, 0); - return(finish_buffer()); + TYPE_out( t, 0 ); + return( finish_buffer() ); } -void TYPEout(Type t) -{ +void TYPEout( Type t ) { prep_file(); - TYPE_out(t, 0); + TYPE_out( t, 0 ); finish_file(); } -char *TYPEhead_to_string(Type t) -{ - if(prep_string()) { +char * TYPEhead_to_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_head_out(t, 0); - return (finish_string()); + TYPE_head_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEhead_to_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEhead_to_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_out(t, 0); - return(finish_buffer()); + TYPE_out( t, 0 ); + return( finish_buffer() ); } -void TYPEhead_out(Type t) -{ +void TYPEhead_out( Type t ) { prep_file(); - TYPE_head_out(t, 0); + TYPE_head_out( t, 0 ); finish_file(); } -char *TYPEbody_to_string(Type t) -{ - if(prep_string()) { +char * TYPEbody_to_string( Type t ) { + if( prep_string() ) { return placeholder; } - TYPE_body_out(t, 0); - return (finish_string()); + TYPE_body_out( t, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int TYPEbody_to_buffer(Type t, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int TYPEbody_to_buffer( Type t, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - TYPE_body_out(t, 0); - return(finish_buffer()); + TYPE_body_out( t, 0 ); + return( finish_buffer() ); } -void TYPEbody_out(Type t) -{ +void TYPEbody_out( Type t ) { prep_file(); - TYPE_body_out(t, 0); + TYPE_body_out( t, 0 ); finish_file(); } diff --git a/src/exppp/pretty_type.h b/src/exppp/pretty_type.h index 91f788954..29101695b 100644 --- a/src/exppp/pretty_type.h +++ b/src/exppp/pretty_type.h @@ -3,19 +3,19 @@ #include "../express/type.h" -char *TYPEbody_to_string(Type t); -char *TYPEhead_to_string(Type t); -char *TYPEto_string(Type t); -void TYPE_body_out(Type t, int level); -void TYPE_head_out(Type t, int level); -void TYPE_out(Type t, int level); -void TYPEbody_out(Type t); -int TYPEbody_to_buffer(Type t, char *buffer, int length); -void TYPEhead_out(Type t); -int TYPEhead_to_buffer(Type t, char *buffer, int length); -void TYPEout(Type t); -int TYPEto_buffer(Type t, char *buffer, int length); -void TYPEunique_or_optional_out(TypeBody tb); +char * TYPEbody_to_string( Type t ); +char * TYPEhead_to_string( Type t ); +char * TYPEto_string( Type t ); +void TYPE_body_out( Type t, int level ); +void TYPE_head_out( Type t, int level ); +void TYPE_out( Type t, int level ); +void TYPEbody_out( Type t ); +int TYPEbody_to_buffer( Type t, char * buffer, int length ); +void TYPEhead_out( Type t ); +int TYPEhead_to_buffer( Type t, char * buffer, int length ); +void TYPEout( Type t ); +int TYPEto_buffer( Type t, char * buffer, int length ); +void TYPEunique_or_optional_out( TypeBody tb ); #endif /* PRETTY_TYPE_H */ diff --git a/src/exppp/pretty_where.c b/src/exppp/pretty_where.c index 3aef4197c..b461baaa6 100644 --- a/src/exppp/pretty_where.c +++ b/src/exppp/pretty_where.c @@ -10,71 +10,65 @@ #include "pretty_expr.h" #include "pretty_where.h" -char *WHEREto_string(Linked_List w) -{ - if(prep_string()) { +char * WHEREto_string( Linked_List w ) { + if( prep_string() ) { return placeholder; } - WHERE_out(w, 0); - return (finish_string()); + WHERE_out( w, 0 ); + return ( finish_string() ); } /** return length of buffer used */ -int WHEREto_buffer(Linked_List w, char *buffer, int length) -{ - if(prep_buffer(buffer, length)) { +int WHEREto_buffer( Linked_List w, char * buffer, int length ) { + if( prep_buffer( buffer, length ) ) { return -1; } - WHERE_out(w, 0); - return(finish_buffer()); + WHERE_out( w, 0 ); + return( finish_buffer() ); } -void WHEREout(Linked_List w) -{ +void WHEREout( Linked_List w ) { prep_file(); - WHERE_out(w, 0); + WHERE_out( w, 0 ); finish_file(); } -void WHERE_out(Linked_List wheres, int level) -{ +void WHERE_out( Linked_List wheres, int level ) { size_t max_indent; - if(!wheres) { + if( !wheres ) { return; } - raw("%*s%s", level, "", "WHERE\n"); + raw( "%*s%s", level, "", "WHERE\n" ); level += exppp_nesting_indent; /* pass 1: calculate length of longest label */ max_indent = 0; - LISTdo(wheres, w, Where) { - if(w->label) { - if(strlen(w->label->name) > max_indent) { - max_indent = strlen(w->label->name); + LISTdo( wheres, w, Where ) { + if( w->label ) { + if( strlen( w->label->name ) > max_indent ) { + max_indent = strlen( w->label->name ); } } - } - LISTod + } LISTod - if(max_indent > 10) { + if( max_indent > 10 ) { /* don't bother indenting completely for * labels that are ridiculously long */ max_indent = 4; } - indent2 = level + max_indent + strlen(": ") + exppp_continuation_indent; + indent2 = level + max_indent + strlen( ": " ) + exppp_continuation_indent; /* pass 2: now print labels and exprs */ - LISTdo(wheres, w, Where) { - if(w->label) { - raw("%*s%-*s: ", level, "", max_indent, w->label->name); + LISTdo( wheres, w, Where ) { + if( w->label ) { + raw( "%*s%-*s: ", level, "", max_indent, w->label->name ); } else { /* no label */ - raw("%*s%-*s ", level, "", max_indent, ""); + raw( "%*s%-*s ", level, "", max_indent, "" ); } - EXPR_out(w->expr, max_indent); - raw(";\n"); - } - LISTod + EXPR_out( w->expr, max_indent ); + raw( ";\n" ); + } LISTod } diff --git a/src/exppp/pretty_where.h b/src/exppp/pretty_where.h index 68b5968ac..72d1a657a 100644 --- a/src/exppp/pretty_where.h +++ b/src/exppp/pretty_where.h @@ -3,10 +3,10 @@ #include -void WHERE_out(Linked_List wheres, int level); -void WHEREout(Linked_List w); -int WHEREto_buffer(Linked_List w, char *buffer, int length); -char *WHEREto_string(Linked_List w); +void WHERE_out( Linked_List wheres, int level ); +void WHEREout( Linked_List w ); +int WHEREto_buffer( Linked_List w, char * buffer, int length ); +char * WHEREto_string( Linked_List w ); #endif /* PRETTY_WHERE_H */ diff --git a/src/exppp/test/test_breakLongStr.c b/src/exppp/test/test_breakLongStr.c index 0382b3667..f93a5809d 100644 --- a/src/exppp/test/test_breakLongStr.c +++ b/src/exppp/test/test_breakLongStr.c @@ -2,9 +2,8 @@ #include "../pp.h" #include "exppp.h" -int main() -{ - char *testarr[] = { +int main() { + char * testarr[] = { "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION_RELATIONSHIP.RELATED_PRODUCT_DEFINITION", "ASSEMBLY_STRUCTURE_MIM_LF.PRODUCT_DEFINITION" }; @@ -13,29 +12,29 @@ int main() /* globals */ exppp_fp = stdout; exppp_linelength = 40; - /* - indent2 = 30; - curpos = 20; - */ - for(i = 0; i < exppp_linelength + 10; i += 15) { - for(c = 2; c < exppp_linelength + 10; c += 13) { +/* + indent2 = 30; + curpos = 20; +*/ + for( i = 0; i < exppp_linelength + 10; i += 15 ) { + for( c = 2; c < exppp_linelength + 10; c += 13 ) { curpos = c; indent2 = i; - raw("indent2: %d, curpos: %d\n%*s||", i, c, c, ""); - breakLongStr(testarr[0]); + raw( "indent2: %d, curpos: %d\n%*s||", i, c, c, "" ); + breakLongStr( testarr[0] ); curpos = c; indent2 = i; - raw("\n%*s||", c, ""); - breakLongStr(testarr[1]); - raw("\n"); + raw( "\n%*s||", c, "" ); + breakLongStr( testarr[1] ); + raw( "\n" ); } } curpos = 77; exppp_linelength = 130; indent2 = 17; - raw("\n%*s||", 77, ""); - breakLongStr(testarr[0]); - raw("\n"); + raw( "\n%*s||", 77, "" ); + breakLongStr( testarr[0] ); + raw( "\n" ); return EXIT_SUCCESS; } diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 409d974ee..5ef962c83 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -4,29 +4,58 @@ include_directories( ${SC_SOURCE_DIR}/src/base ) +# Set up the information we need to feed the generated source management +# scripts +set(BASELINE_INFORMATION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/generated/verification_info.cmake") +set(PROJECT_CMAKE_DIR "${SC_SOURCE_DIR}/cmake") +set(MD5_FILELIST + "${CMAKE_CURRENT_SOURCE_DIR}/expscan.l" + "${CMAKE_CURRENT_SOURCE_DIR}/expparse.y" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c" + "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h" + ) +configure_file(${SC_SOURCE_DIR}/cmake/md5_gen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake @ONLY) +configure_file(${SC_SOURCE_DIR}/cmake/md5_verify.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake @ONLY) + +# Convenience target to generate an updated verification_info.cmake file +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel + ) +add_custom_target(express_md5gen DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel) + +# Target for actually checking cached MD5 sums against files +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel + DEPENDS ${MD5_FILELIST} + ) +add_custom_target(express_verify DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel) + + # Depending on whether we're using pre-generated sources or building them on # the fly, set up targets and source lists. if(SC_GENERATE_LP_SOURCES) LEMON_TARGET(ExpParser expparse.y) PERPLEX_TARGET(ExpScanner expscan.l) ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner ExpParser) - include_directories( - ${LEMON_ExpParser_INCLUDE_DIR} - ${PERPLEX_ExpScanner_INCLUDE_DIR} - ) + + add_library(objlib_expscan_c OBJECT ${PERPLEX_ExpScanner_SRC}) + set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + + add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_SRC}) + set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + else(SC_GENERATE_LP_SOURCES) - set(LEMON_ExpParser_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c) - set(LEMON_ExpParser_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h) - set(PERPLEX_ExpScanner_SRC ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c) - set(PERPLEX_ExpScanner_HDR ${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/generated) + add_subdirectory(generated) + include_directories(generated) endif(SC_GENERATE_LP_SOURCES) set(EXPRESS_SOURCES - ${LEMON_ExpParser_HDR} - ${LEMON_ExpParser_SRC} - ${PERPLEX_ExpScanner_HDR} - ${PERPLEX_ExpScanner_SRC} symbol.c type.c variable.c @@ -51,42 +80,30 @@ set(EXPRESS_SOURCES ordered_attrs.cc info.c factory.c - ) + ) + +set(EXPRESS_OBJS) +foreach(_src ${EXPRESS_SOURCES}) + string(REPLACE "." "_" _suffix ${_src}) + set(_objlib "objlib_${_suffix}") + add_library(${_objlib} OBJECT ${_src}) + # TODO: probably PIC should be used everywhere... + set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) + list(APPEND EXPRESS_OBJS $) +endforeach() -add_library(express-obj OBJECT ${EXPRESS_SOURCES}) -add_dependencies(express-obj base) -if(MSVC) - set_property(TARGET express-obj APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") -endif(MSVC) - - -add_library(express SHARED ${EXPRESS_SOURCES}) -target_link_libraries(express base) -if(OPENBSD) - set_target_properties(express PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) -else(OPENBSD) - set_target_properties(express PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) -endif(OPENBSD) -if(APPLE) - set_property(TARGET express APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress") -endif(APPLE) -install(TARGETS express - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) - -if(MSVC) - set_property(TARGET express APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") - set_property(TARGET express APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") -endif(MSVC) - -if (BUILD_STATIC_LIBS) - add_library(express-static STATIC ${EXPRESS_SOURCES}) - install(TARGETS express-static - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) -endif (BUILD_STATIC_LIBS) +list(APPEND EXPRESS_OBJS $) +list(APPEND EXPRESS_OBJS $) + + +if(SC_GENERATE_LP_SOURCES) + set_property(TARGET objlib_expparse_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") + set_property(TARGET objlib_expscan_c objlib_express_c objlib_lexact_c + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + # OBJECT libraries are not targets, and so an explicit dependency is required + set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") +endif() # TODO # Currently, fedex.c provides the main() for multiple programs. These programs @@ -101,13 +118,51 @@ set(CHECK_EXPRESS_SOURCES fedex.c inithook.c ) -add_executable(check-express ${CHECK_EXPRESS_SOURCES}) -target_link_libraries(check-express express base) -install(TARGETS check-express - RUNTIME DESTINATION ${BIN_DIR} - LIBRARY DESTINATION ${LIB_DIR} - ARCHIVE DESTINATION ${LIB_DIR}) +SET(EXPRESS_PRIVATE_HDRS + exptoks.h + stack.h + ) + +variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) +variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) + +if($CACHE{SC_BUILD_SHARED_LIBS}) + SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) + if(WIN32) + target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) + endif() + + if(SC_GENERATE_LP_SOURCES) + add_custom_command(TARGET express POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + ) + else() + add_dependencies(express express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express version_string) + endif() +endif() + +if($CACHE{SC_BUILD_STATIC_LIBS}) + SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) + + if(SC_GENERATE_LP_SOURCES) + add_custom_command(TARGET express-static POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake + ) + else() + add_dependencies(express-static express_verify) + endif() + + if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) + add_dependencies(express-static version_string) + endif() +endif() + +SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/express/alg.c b/src/express/alg.c index f4966691e..2211eff1a 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -48,11 +48,10 @@ struct freelist_head RULE_fl; struct freelist_head PROC_fl; struct freelist_head WHERE_fl; -Scope ALGcreate(char type) -{ - Scope s = SCOPEcreate(type); +Scope ALGcreate( char type ) { + Scope s = SCOPEcreate( type ); - switch(type) { + switch( type ) { case OBJ_PROCEDURE: s->u.proc = PROC_new(); break; @@ -74,13 +73,11 @@ Scope ALGcreate(char type) */ /** Initialize the Algorithm module. */ -void ALGinitialize(void) -{ +void ALGinitialize( void ) { } -void ALGput_full_text(Scope s, int start, int end) -{ - switch(s->type) { +void ALGput_full_text( Scope s, int start, int end ) { + switch( s->type ) { case OBJ_FUNCTION: s->u.func->text.filename = s->symbol.filename; s->u.func->text.start = start; diff --git a/src/express/alloc.c b/src/express/alloc.c index 4fae5d50e..e20cfa943 100644 --- a/src/express/alloc.c +++ b/src/express/alloc.c @@ -49,11 +49,10 @@ Now you can say things like: * \param flh freelist head * \param bytes new memory size */ -Freelist *create_freelist(struct freelist_head *flh, int bytes) -{ - Freelist *current = (Freelist *)malloc(bytes); - if(current == 0) { - return(0); +Freelist * create_freelist( struct freelist_head * flh, int bytes ) { + Freelist * current = ( Freelist * )malloc( bytes ); + if( current == 0 ) { + return( 0 ); } flh->freelist = current; @@ -62,25 +61,24 @@ Freelist *create_freelist(struct freelist_head *flh, int bytes) flh->create++; /* set max to point to end of freelist */ - if((char *)flh->freelist + bytes > (char *)flh->max) { - flh->max = (char *)flh->freelist + bytes; + if( ( char * )flh->freelist + bytes > ( char * )flh->max ) { + flh->max = ( char * )flh->freelist + bytes; } #endif - while((char *)current + flh->size < - ((char *)flh->freelist + bytes)) { - current->next = (Freelist *)(¤t->memory + flh->size); + while( ( char * )current + flh->size < + ( ( char * )flh->freelist + bytes ) ) { + current->next = ( Freelist * )( ¤t->memory + flh->size ); current = current->next; } current->next = NULL; - return(current); + return( current ); } void -_ALLOCinitialize() -{ +_ALLOCinitialize() { #ifdef DEBUG_MALLOC - malloc_debug(2); + malloc_debug( 2 ); #endif } @@ -90,8 +88,7 @@ _ALLOCinitialize() * \param alloc1 number to allocate initially * \param alloc2 number to allocate if we run out */ -void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, int alloc2) -{ +void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 ) { flh->size_elt = size; /* kludge for calloc-like behavior */ #ifndef NOSTAT flh->alloc = flh->dealloc = flh->create = 0; @@ -99,7 +96,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i #endif /* make block large enough to hold the linked list pointer */ - flh->size = (size > sizeof(Freelist *) ? size : sizeof(Freelist *)); + flh->size = ( size > sizeof( Freelist * ) ? size : sizeof( Freelist * ) ); /* set up for future allocations */ flh->bytes = flh->size * alloc2; @@ -107,7 +104,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i return; /*NOTREACHED*/ #else - if(0 == create_freelist(flh, flh->size * alloc1)) { + if( 0 == create_freelist( flh, flh->size * alloc1 ) ) { ERRORnospace(); } @@ -118,8 +115,7 @@ void ALLOCinitialize(struct freelist_head *flh, unsigned int size, int alloc1, i #endif } -void *ALLOC_new(struct freelist_head *flh) -{ +void * ALLOC_new( struct freelist_head * flh ) { void *obj; #ifndef NOSTAT @@ -127,10 +123,10 @@ void *ALLOC_new(struct freelist_head *flh) #endif #ifdef REAL_MALLOC - return(calloc(1, flh->size_elt)); + return( calloc( 1, flh->size_elt ) ); /*NOTREACHED*/ #else - if(flh->freelist == NULL && 0 == create_freelist(flh, flh->bytes)) { + if( flh->freelist == NULL && 0 == create_freelist( flh, flh->bytes ) ) { ERRORnospace(); } @@ -138,7 +134,7 @@ void *ALLOC_new(struct freelist_head *flh) flh->freelist = flh->freelist->next; #ifndef NOSTAT - if(obj > flh->max) { + if( obj > flh->max ) { abort(); } #endif @@ -148,20 +144,19 @@ void *ALLOC_new(struct freelist_head *flh) #endif /*SPACE_PROFILE*/ /* calloc-like */ - memset(obj, 0, flh->size_elt); + memset( obj, 0, flh->size_elt ); - return(obj); + return( obj ); #endif } -void ALLOC_destroy(struct freelist_head *flh, Freelist *link) -{ +void ALLOC_destroy( struct freelist_head * flh, Freelist * link ) { #ifndef NOSTAT flh->dealloc++; #endif #ifdef REAL_MALLOC - free(link); + free( link ); return; /*NOTREACHED*/ #else @@ -186,35 +181,34 @@ struct oct { char a[16]; }; -main() -{ - struct oct *o1, *o2, *o3, *o4, *o5, *o6; +main() { + struct oct * o1, *o2, *o3, *o4, *o5, *o6; - memory_init(&oct_freelist, sizeof(struct oct), 5, 2); + memory_init( &oct_freelist, sizeof( struct oct ), 5, 2 ); o1 = new_oct(); - fprintf(stderr, "o1 = %x\n", o1); + fprintf( stderr, "o1 = %x\n", o1 ); o2 = new_oct(); - fprintf(stderr, "o2 = %x\n", o2); + fprintf( stderr, "o2 = %x\n", o2 ); o3 = new_oct(); - fprintf(stderr, "o3 = %x\n", o3); + fprintf( stderr, "o3 = %x\n", o3 ); o4 = new_oct(); - fprintf(stderr, "o4 = %x\n", o4); + fprintf( stderr, "o4 = %x\n", o4 ); o5 = new_oct(); - fprintf(stderr, "o5 = %x\n", o5); + fprintf( stderr, "o5 = %x\n", o5 ); o6 = new_oct(); - fprintf(stderr, "o6 = %x\n", o6); - destroy_oct(o1); - destroy_oct(o2); + fprintf( stderr, "o6 = %x\n", o6 ); + destroy_oct( o1 ); + destroy_oct( o2 ); o1 = new_oct(); - fprintf(stderr, "o1 = %x\n", o1); + fprintf( stderr, "o1 = %x\n", o1 ); o2 = new_oct(); - fprintf(stderr, "o2 = %x\n", o2); + fprintf( stderr, "o2 = %x\n", o2 ); o3 = new_oct(); - fprintf(stderr, "o3 = %x\n", o3); + fprintf( stderr, "o3 = %x\n", o3 ); o4 = new_oct(); - fprintf(stderr, "o4 = %x\n", o4); + fprintf( stderr, "o4 = %x\n", o4 ); o5 = new_oct(); - fprintf(stderr, "o5 = %x\n", o5); + fprintf( stderr, "o5 = %x\n", o5 ); } #endif /*ALLOC_MAIN*/ diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 67a06d4e8..fe8aa460f 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -34,8 +34,7 @@ /** Initialize the Case Item module. */ void -CASE_ITinitialize(void) -{ +CASE_ITinitialize( void ) { } /** @@ -48,11 +47,10 @@ CASE_ITinitialize(void) ** \note If the 'labels' parameter is LIST_NULL, a case item ** matching in the default case is created. */ -Case_Item CASE_ITcreate(Linked_List labels, Statement statement) -{ +Case_Item CASE_ITcreate( Linked_List labels, Statement statement ) { struct Case_Item_ *s = CASE_IT_new(); s->labels = labels; s->action = statement; - return(s); + return( s ); } diff --git a/src/express/dict.c b/src/express/dict.c index 506daf473..69d8d1dd8 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -39,28 +39,25 @@ char DICT_type; /**< set to type of object found, as a side-effect of DICT lookup routines */ -void DICTprint(Dictionary dict) -{ +void DICTprint( Dictionary dict ) { Element e; DictionaryEntry de; - HASHlistinit(dict, &de); + HASHlistinit( dict, &de ); - while(0 != (e = (HASHlist(&de)))) { - fprintf(stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", + while( 0 != ( e = ( HASHlist( &de ) ) ) ) { + fprintf( stderr, "key <%s> data <%s> line <%d> <\"%c\" %s> <%s>\n", e->key, e->data, e->symbol->line, e->type, - OBJget_type(e->type), e->symbol->filename); + OBJget_type( e->type ), e->symbol->filename ); } } /** Initialize the Dictionary module */ -void DICTinitialize(void) -{ +void DICTinitialize( void ) { } /** Clean up the Dictionary module */ -void DICTcleanup(void) -{ +void DICTcleanup( void ) { } /** @@ -68,8 +65,7 @@ void DICTcleanup(void) * error directly if there is a duplicate value. * \return 0 on success, 1 on failure */ -int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) -{ +int DICTdefine( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ new, *old; new.key = name; @@ -77,8 +73,8 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) new.symbol = sym; new.type = type; - if(0 == (old = HASHsearch(dict, &new, HASH_INSERT))) { - return(0); + if( 0 == ( old = HASHsearch( dict, &new, HASH_INSERT ) ) ) { + return( 0 ); } /* allow multiple definitions of an enumeration id in its @@ -91,20 +87,20 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) * to have the same name. To fix this, I replaced the * || with && in the else-if below. */ - if((type == OBJ_ENUM) && (old->type == OBJ_ENUM)) { + if( ( type == OBJ_ENUM ) && ( old->type == OBJ_ENUM ) ) { /* if we're adding an enum, but we've already seen one */ /* (and only one enum), mark it ambiguous */ - DICTchange_type(old, OBJ_AMBIG_ENUM); - } else if((type != OBJ_ENUM) && (!IS_ENUM(old->type))) { + DICTchange_type( old, OBJ_AMBIG_ENUM ); + } else if( ( type != OBJ_ENUM ) && ( !IS_ENUM( old->type ) ) ) { /* if we're adding a non-enum, and we've * * already added a non-enum, complain */ - if(sym->filename == old->symbol->filename) { - ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, old->symbol->line); + if( sym->filename == old->symbol->filename ) { + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, old->symbol->line ); } else { - ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, old->symbol->line, old->symbol->filename ); } ERRORreport(SUBORDINATE_FAILED); - return(1); + return( 1 ); } return 0; } @@ -117,8 +113,7 @@ int DICTdefine(Dictionary dict, char *name, void *obj, Symbol *sym, char type) * their unusual behavior with respect to scoping and visibility rules * \sa DICTdefine() */ -int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) -{ +int DICT_define( Dictionary dict, char * name, void *obj, Symbol * sym, char type ) { struct Element_ e, *e2; e.key = name; @@ -126,17 +121,17 @@ int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) e.symbol = sym; e.type = type; - if(0 == (e2 = HASHsearch(dict, &e, HASH_INSERT))) { - return(0); + if( 0 == ( e2 = HASHsearch( dict, &e, HASH_INSERT ) ) ) { + return( 0 ); } - if(sym->filename == e2->symbol->filename) { - ERRORreport_with_symbol(DUPLICATE_DECL, sym, name, e2->symbol->line); + if( sym->filename == e2->symbol->filename ) { + ERRORreport_with_symbol( DUPLICATE_DECL, sym, name, e2->symbol->line ); } else { - ERRORreport_with_symbol(DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename); + ERRORreport_with_symbol( DUPLICATE_DECL_DIFF_FILE, sym, name, e2->symbol->line, e2->symbol->filename ); } ERRORreport(SUBORDINATE_FAILED); - return(1); + return( 1 ); } /** @@ -146,12 +141,11 @@ int DICT_define(Dictionary dict, char *name, void *obj, Symbol *sym, char type) Changed to return void, since the hash code frees the element, there is no way to return (without godawful casting) the generic itself. */ -void DICTundefine(Dictionary dict, char *name) -{ +void DICTundefine( Dictionary dict, char * name ) { struct Element_ e; e.key = name; - HASHsearch(dict, &e, HASH_DELETE); + HASHsearch( dict, &e, HASH_DELETE ); } /** @@ -159,47 +153,44 @@ void DICTundefine(Dictionary dict, char *name) ** \param name name to look up ** \return the value found, NULL if not found */ -void *DICTlookup(Dictionary dictionary, char *name) -{ +void *DICTlookup( Dictionary dictionary, char * name ) { struct Element_ e, *ep; - if(!dictionary) { + if( !dictionary ) { return 0; } e.key = name; - ep = HASHsearch(dictionary, &e, HASH_FIND); - if(ep) { + ep = HASHsearch( dictionary, &e, HASH_FIND ); + if( ep ) { DICT_type = ep->type; - return(ep->data); + return( ep->data ); } - return(NULL); + return( NULL ); } /** like DICTlookup but returns symbol, too * \sa DICTlookup() */ -void *DICTlookup_symbol(Dictionary dictionary, char *name, Symbol **sym) -{ +void *DICTlookup_symbol( Dictionary dictionary, char * name, Symbol ** sym ) { struct Element_ e, *ep; - if(!dictionary) { + if( !dictionary ) { return 0; } e.key = name; - ep = HASHsearch(dictionary, &e, HASH_FIND); - if(ep) { + ep = HASHsearch( dictionary, &e, HASH_FIND ); + if( ep ) { DICT_type = ep->type; *sym = ep->symbol; - return(ep->data); + return( ep->data ); } - return(NULL); + return( NULL ); } -void *DICTdo(DictionaryEntry *dict_entry) -{ - if(0 == HASHlist(dict_entry)) { +void *DICTdo( DictionaryEntry * dict_entry ) { + if( 0 == HASHlist( dict_entry ) ) { return 0; } diff --git a/src/express/entity.c b/src/express/entity.c index 506f0450a..507b2c23f 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -120,10 +120,9 @@ int ENTITY_MARK = 0; /** returns true if variable is declared (or redeclared) directly by entity */ -int ENTITYdeclares_variable(Entity e, Variable v) -{ - LISTdo(e->u.entity->attributes, attr, Variable) - if(attr == v) { +int ENTITYdeclares_variable( Entity e, Variable v ) { + LISTdo( e->u.entity->attributes, attr, Variable ) + if( attr == v ) { return true; } LISTod; @@ -131,8 +130,7 @@ int ENTITYdeclares_variable(Entity e, Variable v) return false; } -static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) -{ +static Entity ENTITY_find_inherited_entity( Entity entity, char * name, int down ) { Entity result; /* avoid searching scopes that we've already searched */ @@ -140,34 +138,34 @@ static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if(entity->search_id == __SCOPE_search_id) { + if( entity->search_id == __SCOPE_search_id ) { return NULL; } entity->search_id = __SCOPE_search_id; - LISTdo(entity->u.entity->supertypes, super, Entity) - if(!strcmp(super->symbol.name, name)) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + if( !strcmp( super->symbol.name, name ) ) { return super; } LISTod - LISTdo(entity->u.entity->supertypes, super, Entity) - result = ENTITY_find_inherited_entity(super, name, down); - if(result) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + result = ENTITY_find_inherited_entity( super, name, down ); + if( result ) { return result; } LISTod; - if(down) { - LISTdo(entity->u.entity->subtypes, sub, Entity) - if(!strcmp(sub->symbol.name, name)) { + if( down ) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + if( !strcmp( sub->symbol.name, name ) ) { return sub; } LISTod; - LISTdo(entity->u.entity->subtypes, sub, Entity) - result = ENTITY_find_inherited_entity(sub, name, down); - if(result) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + result = ENTITY_find_inherited_entity( sub, name, down ); + if( result ) { return result; } LISTod; @@ -176,19 +174,17 @@ static Entity ENTITY_find_inherited_entity(Entity entity, char *name, int down) return 0; } -struct Scope_ *ENTITYfind_inherited_entity(struct Scope_ *entity, char *name, int down) -{ - if(!strcmp(name, entity->symbol.name)) { - return(entity); +struct Scope_ * ENTITYfind_inherited_entity( struct Scope_ *entity, char * name, int down ) { + if( !strcmp( name, entity->symbol.name ) ) { + return( entity ); } __SCOPE_search_id++; - return ENTITY_find_inherited_entity(entity, name, down); + return ENTITY_find_inherited_entity( entity, name, down ); } /** find a (possibly inherited) attribute */ -Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, struct Symbol_ **where) -{ +Variable ENTITY_find_inherited_attribute( Entity entity, char * name, int * down, struct Symbol_ ** where ) { Variable result; /* avoid searching scopes that we've already searched */ @@ -196,34 +192,34 @@ Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, s /* if A ref's B which ref's C, and A ref's C. Then C */ /* can be searched twice by A. Similar problem with */ /* sub/super inheritance. */ - if(entity->search_id == __SCOPE_search_id) { + if( entity->search_id == __SCOPE_search_id ) { return NULL; } entity->search_id = __SCOPE_search_id; /* first look locally */ - result = (Variable)DICTlookup(entity->symbol_table, name); - if(result) { - if(down && *down && where) { + result = ( Variable )DICTlookup( entity->symbol_table, name ); + if( result ) { + if( down && *down && where ) { *where = &entity->symbol; } return result; } /* check supertypes */ - LISTdo(entity->u.entity->supertypes, super, Entity) - result = ENTITY_find_inherited_attribute(super, name, down, where); - if(result) { + LISTdo( entity->u.entity->supertypes, super, Entity ) + result = ENTITY_find_inherited_attribute( super, name, down, where ); + if( result ) { return result; } LISTod; /* check subtypes, if requested */ - if(down) { + if( down ) { ++*down; - LISTdo(entity->u.entity->subtypes, sub, Entity) - result = ENTITY_find_inherited_attribute(sub, name, down, where); - if(result) { + LISTdo( entity->u.entity->subtypes, sub, Entity ) + result = ENTITY_find_inherited_attribute( sub, name, down, where ); + if( result ) { return result; } LISTod; @@ -233,54 +229,52 @@ Variable ENTITY_find_inherited_attribute(Entity entity, char *name, int *down, s return 0; } -Variable ENTITYfind_inherited_attribute(struct Scope_ *entity, char *name, - struct Symbol_ **down_sym) -{ +Variable ENTITYfind_inherited_attribute( struct Scope_ *entity, char * name, + struct Symbol_ ** down_sym ) { extern int __SCOPE_search_id; int down_flag = 0; __SCOPE_search_id++; - if(down_sym) { - return ENTITY_find_inherited_attribute(entity, name, &down_flag, down_sym); + if( down_sym ) { + return ENTITY_find_inherited_attribute( entity, name, &down_flag, down_sym ); } else { - return ENTITY_find_inherited_attribute(entity, name, 0, 0); + return ENTITY_find_inherited_attribute( entity, name, 0, 0 ); } } /** resolve a (possibly group-qualified) attribute ref. * report errors as appropriate */ -Variable ENTITYresolve_attr_ref(Entity e, Symbol *grp_ref, Symbol *attr_ref) -{ +Variable ENTITYresolve_attr_ref( Entity e, Symbol * grp_ref, Symbol * attr_ref ) { Entity ref_entity; Variable attr; struct Symbol_ *where; - if(grp_ref) { + if( grp_ref ) { /* use entity provided in group reference */ - ref_entity = ENTITYfind_inherited_entity(e, grp_ref->name, 0); - if(!ref_entity) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name); + ref_entity = ENTITYfind_inherited_entity( e, grp_ref->name, 0 ); + if( !ref_entity ) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, grp_ref, grp_ref->name, e->symbol.name ); return 0; } - attr = (Variable)DICTlookup(ref_entity->symbol_table, - attr_ref->name); - if(!attr) { + attr = ( Variable )DICTlookup( ref_entity->symbol_table, + attr_ref->name ); + if( !attr ) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, attr_ref, attr_ref->name, - ref_entity->symbol.name); + ref_entity->symbol.name ); /* resolve_failed(e);*/ } } else { /* no entity provided, look through supertype chain */ where = NULL; - attr = ENTITYfind_inherited_attribute(e, attr_ref->name, &where); - if(!attr /* was ref_entity? */) { + attr = ENTITYfind_inherited_attribute( e, attr_ref->name, &where ); + if( !attr /* was ref_entity? */ ) { ERRORreport_with_symbol(UNKNOWN_ATTR_IN_ENTITY, - attr_ref, attr_ref->name, - e->symbol.name); - } else if(where != NULL) { + attr_ref, attr_ref->name, + e->symbol.name ); + } else if( where != NULL ) { ERRORreport_with_symbol(IMPLICIT_DOWNCAST, attr_ref, - where->name); + where->name ); } } return attr; @@ -290,8 +284,7 @@ Variable ENTITYresolve_attr_ref(Entity e, Symbol *grp_ref, Symbol *attr_ref) * currently, this is only used by USEresolve * low-level function for type Entity */ -Entity ENTITYcopy(Entity e) -{ +Entity ENTITYcopy( Entity e ) { /* for now, do a totally shallow copy */ Entity e2 = SCOPE_new(); *e2 = *e; @@ -299,8 +292,7 @@ Entity ENTITYcopy(Entity e) } /** Initialize the Entity module. */ -void ENTITYinitialize() -{ +void ENTITYinitialize() { } /** @@ -308,22 +300,21 @@ void ENTITYinitialize() ** \param attr attribute to add ** Add an attribute to an entity. */ -void ENTITYadd_attribute(Entity entity, Variable attr) -{ +void ENTITYadd_attribute( Entity entity, Variable attr ) { int rc; - if(attr->name->type->u.type->body->type != op_) { + if( attr->name->type->u.type->body->type != op_ ) { /* simple id */ - rc = DICTdefine(entity->symbol_table, attr->name->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE); + rc = DICTdefine( entity->symbol_table, attr->name->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE ); } else { /* SELF\ENTITY.SIMPLE_ID */ - rc = DICTdefine(entity->symbol_table, attr->name->e.op2->symbol.name, - attr, &attr->name->symbol, OBJ_VARIABLE); + rc = DICTdefine( entity->symbol_table, attr->name->e.op2->symbol.name, + attr, &attr->name->symbol, OBJ_VARIABLE ); } - if(rc == 0) { - LISTadd_last(entity->u.entity->attributes, attr); - VARput_offset(attr, entity->u.entity->attribute_count); + if( rc == 0 ) { + LISTadd_last( entity->u.entity->attributes, attr ); + VARput_offset( attr, entity->u.entity->attribute_count ); entity->u.entity->attribute_count++; } } @@ -333,12 +324,11 @@ void ENTITYadd_attribute(Entity entity, Variable attr) ** \param instance new instance ** Add an item to the instance list of an entity. */ -void ENTITYadd_instance(Entity entity, void *instance) -{ - if(entity->u.entity->instances == LIST_NULL) { +void ENTITYadd_instance( Entity entity, void *instance ) { + if( entity->u.entity->instances == LIST_NULL ) { entity->u.entity->instances = LISTcreate(); } - LISTadd_last(entity->u.entity->instances, instance); + LISTadd_last( entity->u.entity->instances, instance ); } /** @@ -347,13 +337,12 @@ void ENTITYadd_instance(Entity entity, void *instance) ** \return does child's superclass chain include parent? ** Look for a certain entity in the supertype graph of an entity. */ -bool ENTITYhas_supertype(Entity child, Entity parent) -{ - LISTdo(child->u.entity->supertypes, entity, Entity) - if(entity == parent) { +bool ENTITYhas_supertype( Entity child, Entity parent ) { + LISTdo( child->u.entity->supertypes, entity, Entity ) + if( entity == parent ) { return true; } - if(ENTITYhas_supertype(entity, parent)) { + if( ENTITYhas_supertype( entity, parent ) ) { return true; } LISTod; @@ -366,10 +355,9 @@ bool ENTITYhas_supertype(Entity child, Entity parent) ** \return is parent a direct supertype of child? ** Check whether an entity has a specific immediate superclass. */ -bool ENTITYhas_immediate_supertype(Entity child, Entity parent) -{ - LISTdo(child->u.entity->supertypes, entity, Entity) - if(entity == parent) { +bool ENTITYhas_immediate_supertype( Entity child, Entity parent ) { + LISTdo( child->u.entity->supertypes, entity, Entity ) + if( entity == parent ) { return true; } LISTod; @@ -377,15 +365,14 @@ bool ENTITYhas_immediate_supertype(Entity child, Entity parent) } /** called by ENTITYget_all_attributes(). \sa ENTITYget_all_attributes */ -static void ENTITY_get_all_attributes(Entity entity, Linked_List result) -{ - LISTdo(entity->u.entity->supertypes, super, Entity) +static void ENTITY_get_all_attributes( Entity entity, Linked_List result ) { + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity))*/ - ENTITY_get_all_attributes(super, result); + ENTITY_get_all_attributes( super, result ); LISTod; /* Gee, aren't they resolved by this time? */ - LISTdo(entity->u.entity->attributes, attr, void *) - LISTadd_last(result, attr); + LISTdo( entity->u.entity->attributes, attr, void * ) + LISTadd_last( result, attr ); LISTod; } @@ -400,11 +387,10 @@ static void ENTITY_get_all_attributes(Entity entity, Linked_List result) ** attributes, this call returns an empty list. Note ** that this is distinct from the constant LIST_NULL. */ -Linked_List ENTITYget_all_attributes(Entity entity) -{ +Linked_List ENTITYget_all_attributes( Entity entity ) { Linked_List result = LISTcreate(); - ENTITY_get_all_attributes(entity, result); + ENTITY_get_all_attributes( entity, result ); return result; } @@ -417,19 +403,18 @@ Linked_List ENTITYget_all_attributes(Entity entity) ** \note If the entity has no attribute with the given name, ** VARIABLE_NULL is returned. */ -Variable ENTITYget_named_attribute(Entity entity, char *name) -{ +Variable ENTITYget_named_attribute( Entity entity, char * name ) { Variable attribute; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(!strcmp(VARget_simple_name(attr), name)) { + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( !strcmp( VARget_simple_name( attr ), name ) ) { return attr; } LISTod; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity) && */ - if(0 != (attribute = ENTITYget_named_attribute(super, name))) { + if( 0 != ( attribute = ENTITYget_named_attribute( super, name ) ) ) { return attribute; } LISTod; @@ -445,23 +430,22 @@ Variable ENTITYget_named_attribute(Entity entity, char *name) ** \note If the entity does not include the attribute, -1 ** is returned. */ -int ENTITYget_attribute_offset(Entity entity, Variable attribute) -{ +int ENTITYget_attribute_offset( Entity entity, Variable attribute ) { int offset; int value; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(attr == attribute) { - return entity->u.entity->inheritance + VARget_offset(attribute); + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( attr == attribute ) { + return entity->u.entity->inheritance + VARget_offset( attribute ); } LISTod; offset = 0; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if((value = ENTITYget_attribute_offset(super, attribute)) != -1) { + if( ( value = ENTITYget_attribute_offset( super, attribute ) ) != -1 ) { return value + offset; } - offset += ENTITYget_initial_offset(super); + offset += ENTITYget_initial_offset( super ); /* }*/ LISTod; return -1; @@ -476,23 +460,22 @@ int ENTITYget_attribute_offset(Entity entity, Variable attribute) ** \note If the entity has no attribute with the given name, ** -1 is returned. */ -int ENTITYget_named_attribute_offset(Entity entity, char *name) -{ +int ENTITYget_named_attribute_offset( Entity entity, char * name ) { int offset; int value; - LISTdo(entity->u.entity->attributes, attr, Variable) - if(!strcmp(VARget_simple_name(attr), name)) + LISTdo( entity->u.entity->attributes, attr, Variable ) + if( !strcmp( VARget_simple_name( attr ), name ) ) return entity->u.entity->inheritance + - VARget_offset(ENTITY_find_inherited_attribute(entity, name, 0, 0)); + VARget_offset( ENTITY_find_inherited_attribute( entity, name, 0, 0 ) ); LISTod; offset = 0; - LISTdo(entity->u.entity->supertypes, super, Entity) + LISTdo( entity->u.entity->supertypes, super, Entity ) /* if (OBJis_kind_of(super, Class_Entity)) {*/ - if((value = ENTITYget_named_attribute_offset(super, name)) != -1) { + if( ( value = ENTITYget_named_attribute_offset( super, name ) ) != -1 ) { return value + offset; } - offset += ENTITYget_initial_offset(super); + offset += ENTITYget_initial_offset( super ); /* }*/ LISTod; return -1; @@ -503,7 +486,6 @@ int ENTITYget_named_attribute_offset(Entity entity, char *name) ** \return number of inherited attributes ** Retrieve the initial offset to an entity's local frame. */ -int ENTITYget_initial_offset(Entity entity) -{ +int ENTITYget_initial_offset( Entity entity ) { return entity->u.entity->inheritance; } diff --git a/src/express/error.c b/src/express/error.c index 5d47a8e57..04bcc4154 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -98,10 +98,8 @@ static struct Error_ LibErrors[] = { [FILE_UNREADABLE] = {SEVERITY_ERROR, "Could not read file %s: %s", NULL, false}, [FILE_UNWRITABLE] = {SEVERITY_ERROR, "Could not write file %s: %s", NULL, false}, [WARN_UNSUPPORTED_LANG_FEAT] = {SEVERITY_WARNING, "Unsupported language feature (%s) at %s:%d", "unsupported", false}, - [WARN_SMALL_REAL] = { - SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " - "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false - }, + [WARN_SMALL_REAL] = {SEVERITY_WARNING, "REALs with extremely small magnitude may be interpreted as zero by other EXPRESS parsers " + "(IEEE 754 float denormals are sometimes rounded to zero) - fabs(%f) <= FLT_MIN.", "limits", false}, /* lexact.c */ [INCLUDE_FILE] = {SEVERITY_ERROR, "Could not open include file `%s'.", NULL, false}, [UNMATCHED_CLOSE_COMMENT] = {SEVERITY_ERROR, "unmatched close comment", NULL, false}, @@ -159,7 +157,7 @@ static struct Error_ LibErrors[] = { bool __ERROR_buffer_errors = false; -const char *current_filename = "stdin"; +const char * current_filename = "stdin"; /* flag to remember whether non-warning errors have occurred */ bool ERRORoccurred = false; @@ -176,7 +174,7 @@ int malloc_debug_resolve = 0; /* for debugging yacc/lex */ int debug = 0; -void (*ERRORusage_function)(void); +void ( *ERRORusage_function )( void ); #define ERROR_MAX_ERRORS 100 /**< max line-numbered errors */ #define ERROR_MAX_SPACE 4000 /**< max space for line-numbered errors */ @@ -187,16 +185,16 @@ void (*ERRORusage_function)(void); static struct heap_element { int line; - char *msg; + char * msg; } heap[ERROR_MAX_ERRORS + 1]; /**< NOTE! element 0 is purposely ignored, and * an additional element is at the end. This * allows the later heap calculations to be * much simpler */ static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */ -static char *ERROR_string; -static char *ERROR_string_base; -static char *ERROR_string_end; +static char * ERROR_string; +static char * ERROR_string_base; +static char * ERROR_string_end; static bool ERROR_unsafe = false; static jmp_buf ERROR_safe_env; @@ -204,9 +202,8 @@ static jmp_buf ERROR_safe_env; #define error_file stderr /**< message buffer file */ -static int ERROR_vprintf(const char *format, va_list ap) -{ - int result = vsnprintf(ERROR_string, ERROR_string_end - ERROR_string, format, ap); +static int ERROR_vprintf( const char *format, va_list ap ) { + int result = vsnprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap ); if(result < 0) { ERROR_string = ERROR_string_end; @@ -218,109 +215,102 @@ static int ERROR_vprintf(const char *format, va_list ap) return result; } -static int ERROR_printf(const char *format, ...) -{ +static int ERROR_printf( const char *format, ... ) { int result; va_list ap; - va_start(ap, format); - result = ERROR_vprintf(format, ap); - va_end(ap); + va_start( ap, format ); + result = ERROR_vprintf( format, ap ); + va_end( ap ); return result; } -static void ERROR_nexterror() -{ - if(ERROR_string == ERROR_string_end) { +static void ERROR_nexterror() { + if( ERROR_string == ERROR_string_end ) { return; } ERROR_string++; } /** Initialize the Error module */ -void ERRORinitialize(void) -{ - ERROR_string_base = (char *)sc_malloc(ERROR_MAX_SPACE); +void ERRORinitialize( void ) { + ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); #ifdef SIGQUIT - signal(SIGQUIT, ERRORabort); + signal( SIGQUIT, ERRORabort ); #endif #ifdef SIGBUS - signal(SIGBUS, ERRORabort); + signal( SIGBUS, ERRORabort ); #endif #ifdef SIGSEGV - signal(SIGSEGV, ERRORabort); + signal( SIGSEGV, ERRORabort ); #endif #ifdef SIGABRT - signal(SIGABRT, ERRORabort); + signal( SIGABRT, ERRORabort ); #endif } /** Clean up the Error module */ -void ERRORcleanup(void) -{ - sc_free(ERROR_string_base); +void ERRORcleanup( void ) { + sc_free( ERROR_string_base ); } -void ERRORset_warning(char *name, bool warn_only) -{ +void ERRORset_warning(char * name, bool warn_only) { Error err; bool found = false; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { + if (err->severity <= SEVERITY_WARNING && !strcmp(err->name, name)) { found = true; err->override = warn_only; } - } - - if(!found) { - fprintf(stderr, "unknown warning: %s\n", name); - if(ERRORusage_function) { - (*ERRORusage_function)(); + } + + if (!found) { + fprintf( stderr, "unknown warning: %s\n", name ); + if( ERRORusage_function ) { + ( *ERRORusage_function )(); } else { EXPRESSusage(1); } } } -void ERRORset_all_warnings(bool warn_only) -{ +void ERRORset_all_warnings( bool warn_only ) { Error err; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->severity <= SEVERITY_WARNING) { + if (err->severity <= SEVERITY_WARNING) { err->override = warn_only; - } - } + } + } } -char *ERRORget_warnings_help(const char *prefix, const char *eol) -{ +char * ERRORget_warnings_help(const char* prefix, const char *eol) { unsigned int sz = 2048, len, clen; char *buf, *nbuf; Error err; - + clen = strlen(prefix) + strlen(eol) + 1; - + buf = sc_malloc(sz); - if(!buf) { + if (!buf) { fprintf(error_file, "failed to allocate memory for warnings help!\n"); } buf[0] = '\0'; - - for(unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { + + for (unsigned int errnum = 0; errnum < (sizeof LibErrors / sizeof LibErrors[0]); errnum++) { err = &LibErrors[errnum]; - if(err->name) { + if (err->name) { len = strlen(buf) + strlen(err->name) + clen; - if(len > sz) { + if (len > sz) { sz *= 2; nbuf = sc_realloc(buf, sz); - if(!nbuf) { - fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); + if (!nbuf) { + fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); } buf = nbuf; } @@ -329,13 +319,12 @@ char *ERRORget_warnings_help(const char *prefix, const char *eol) strcat(buf, eol); } } - + return buf; } bool -ERRORis_enabled(enum ErrorCode errnum) -{ +ERRORis_enabled(enum ErrorCode errnum) { Error err = &LibErrors[errnum]; return !err->override; } @@ -349,34 +338,33 @@ ERRORis_enabled(enum ErrorCode errnum) ** format fields of the message generated by 'what.' */ void -ERRORreport(enum ErrorCode errnum, ...) -{ +ERRORreport( enum ErrorCode errnum, ... ) { va_list args; - va_start(args, errnum); + va_start( args, errnum ); Error what = &LibErrors[errnum]; - if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { - if(what->severity >= SEVERITY_ERROR) { - fprintf(error_file, "ERROR PE%03d: ", errnum); - vfprintf(error_file, what->message, args); - fputc('\n', error_file); + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum) ) { + if( what->severity >= SEVERITY_ERROR ) { + fprintf( error_file, "ERROR PE%03d: ", errnum ); + vfprintf( error_file, what->message, args ); + fputc( '\n', error_file ); ERRORoccurred = true; } else { - fprintf(error_file, "WARNING PW%03d: %d", errnum, what->severity); - vfprintf(error_file, what->message, args); - fputc('\n', error_file); + fprintf( error_file, "WARNING PW%03d: %d", errnum, what->severity ); + vfprintf( error_file, what->message, args ); + fputc( '\n', error_file ); } - if(what->severity >= SEVERITY_EXIT) { + if( what->severity >= SEVERITY_EXIT ) { ERROR_flush_message_buffer(); - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } - va_end(args); + va_end( args ); } /** @@ -389,11 +377,10 @@ ERRORreport(enum ErrorCode errnum, ...) ** format fields of the message generated by 'what.' */ void -ERRORreport_with_line(enum ErrorCode errnum, int line, ...) -{ +ERRORreport_with_line( enum ErrorCode errnum, int line, ... ) { Symbol sym; va_list args; - va_start(args, line); + va_start( args, line ); sym.filename = current_filename; sym.line = line; @@ -401,14 +388,13 @@ ERRORreport_with_line(enum ErrorCode errnum, int line, ...) } void -ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) -{ +ERRORreport_with_symbol( enum ErrorCode errnum, Symbol * sym, ... ) { va_list args; - va_start(args, sym); + va_start( args, sym ); Error what = &LibErrors[errnum]; - if(errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { - if(__ERROR_buffer_errors) { + if (errnum != SUBORDINATE_FAILED && ERRORis_enabled(errnum)) { + if( __ERROR_buffer_errors ) { int child, parent; /* @@ -420,8 +406,8 @@ ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) child = ++ERROR_with_lines; parent = child / 2; - while(parent) { - if(sym->line < heap[parent].line) { + while( parent ) { + if( sym->line < heap[parent].line ) { heap[child] = heap[parent]; } else { break; @@ -432,53 +418,52 @@ ERRORreport_with_symbol(enum ErrorCode errnum, Symbol *sym, ...) heap[child].line = sym->line; heap[child].msg = ERROR_string; - if(what->severity >= SEVERITY_ERROR) { - ERROR_printf("%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); - ERROR_vprintf(what->message, args); + if( what->severity >= SEVERITY_ERROR ) { + ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); + ERROR_vprintf( what->message, args ); ERROR_nexterror(); ERRORoccurred = true; } else { - ERROR_printf("%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); - ERROR_vprintf(what->message, args); + ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); + ERROR_vprintf( what->message, args ); ERROR_nexterror(); } - if(what->severity >= SEVERITY_EXIT || + if( what->severity >= SEVERITY_EXIT || ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE || - ERROR_with_lines == ERROR_MAX_ERRORS) { + ERROR_with_lines == ERROR_MAX_ERRORS ) { ERROR_flush_message_buffer(); - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } else { - if(what->severity >= SEVERITY_ERROR) { - fprintf(error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum); - vfprintf(error_file, what->message, args); - fprintf(error_file, "\n"); + if( what->severity >= SEVERITY_ERROR ) { + fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, errnum ); + vfprintf( error_file, what->message, args ); + fprintf( error_file, "\n" ); ERRORoccurred = true; } else { - fprintf(error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum); - vfprintf(error_file, what->message, args); - fprintf(error_file, "\n"); + fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, errnum ); + vfprintf( error_file, what->message, args ); + fprintf( error_file, "\n" ); } - if(what->severity >= SEVERITY_EXIT) { - if(what->severity >= SEVERITY_DUMP) { + if( what->severity >= SEVERITY_EXIT ) { + if( what->severity >= SEVERITY_DUMP ) { abort(); } else { - exit(EXPRESS_fail((Express)0)); + exit( EXPRESS_fail( ( Express )0 ) ); } } } } - va_end(args); + va_end( args ); } -void ERRORnospace() -{ - fprintf(stderr, "%s: out of space\n", EXPRESSprogram_name); - ERRORabort(0); +void ERRORnospace() { + fprintf( stderr, "%s: out of space\n", EXPRESSprogram_name ); + ERRORabort( 0 ); } /** \fn ERRORbuffer_messages @@ -494,40 +479,38 @@ void ERRORnospace() ** \note The error messages are sorted by line number (which appears in the third column). */ -void ERROR_start_message_buffer(void) -{ +void ERROR_start_message_buffer( void ) { ERROR_string = ERROR_string_base; ERROR_with_lines = 0; } -void ERROR_flush_message_buffer(void) -{ +void ERROR_flush_message_buffer( void ) { if(!__ERROR_buffer_errors) { return; } - while(ERROR_with_lines) { - struct heap_element *replace; + while( ERROR_with_lines ) { + struct heap_element * replace; int parent, child; /* pop off the top of the heap */ - fprintf(stderr, "%s", heap[1].msg); + fprintf( stderr, "%s", heap[1].msg ); replace = &heap[ERROR_with_lines--]; child = 1; - while(1) { + while( 1 ) { parent = child; child = 2 * parent; - if(child > ERROR_with_lines) { + if( child > ERROR_with_lines ) { break; } - if(child + 1 <= ERROR_with_lines) { - if(heap[child].line > heap[child + 1].line) { + if( child + 1 <= ERROR_with_lines ) { + if( heap[child].line > heap[child + 1].line ) { child++; } } - if(replace->line <= heap[child].line) { + if( replace->line <= heap[child].line ) { break; } heap[parent] = heap[child]; @@ -536,32 +519,29 @@ void ERROR_flush_message_buffer(void) } } -void ERRORabort(int sig) -{ +void ERRORabort( int sig ) { (void) sig; /* quell unused param warning */ /* TODO: rework - fprintf is not atomic * so ERRORflush_messages() is unsafe if __ERROR_buffer_errors is set */ - + /* NOTE: signals can be caught in gdb, * no need for special treatment of debugging scenario */ - if(ERROR_unsafe) { - longjmp(ERROR_safe_env, 1); + if( ERROR_unsafe ) { + longjmp( ERROR_safe_env, 1 ); } #ifdef SIGABRT - signal(SIGABRT, SIG_DFL); + signal( SIGABRT, SIG_DFL ); #endif /* TODO: library shouldn't abort an application? */ abort(); } -void ERRORsafe(jmp_buf env) -{ - memcpy(ERROR_safe_env, env, sizeof(jmp_buf)); +void ERRORsafe( jmp_buf env ) { + memcpy( ERROR_safe_env, env, sizeof( jmp_buf ) ); } -void ERRORunsafe() -{ +void ERRORunsafe() { ERROR_unsafe = true; } diff --git a/src/express/exp_kw.c b/src/express/exp_kw.c index e765fa510..837e49393 100644 --- a/src/express/exp_kw.c +++ b/src/express/exp_kw.c @@ -1,122 +1,122 @@ #include "express/exp_kw.h" -char *KW_ABS = "ABS"; -char *KW_ABSTRACT = "ABSTRACT"; -char *KW_ACOS = "ACOS"; -char *KW_AGGREGATE = "AGGREGATE"; -char *KW_ALIAS = "ALIAS"; -char *KW_AND = "AND"; -char *KW_ANDOR = "ANDOR"; -char *KW_ARRAY = "ARRAY"; -char *KW_AS = "AS"; -char *KW_ASIN = "ASIN"; -char *KW_ATAN = "ATAN"; -char *KW_BAG = "BAG"; -char *KW_BEGIN = "BEGIN"; -char *KW_BINARY = "BINARY"; -char *KW_BLENGTH = "BLENGTH"; -char *KW_BOOLEAN = "BOOLEAN"; -char *KW_BY = "BY"; -char *KW_CASE = "CASE"; -char *KW_CONST_E = "CONST_E"; -char *KW_CONSTANT = "CONSTANT"; -char *KW_CONTEXT = "CONTEXT"; -char *KW_COS = "COS"; -char *KW_DERIVE = "DERIVE"; -char *KW_DIV = "DIV"; -char *KW_ELSE = "ELSE"; -char *KW_END = "END"; -char *KW_END_ALIAS = "END_ALIAS"; -char *KW_END_CASE = "END_CASE"; -char *KW_END_CONSTANT = "END_CONSTANT"; -char *KW_END_CONTEXT = "END_CONTEXT"; -char *KW_END_ENTITY = "END_ENTITY"; -char *KW_END_FUNCTION = "END_FUNCTION"; -char *KW_END_IF = "END_IF"; -char *KW_END_LOCAL = "END_LOCAL"; -char *KW_END_MODEL = "END_MODEL"; -char *KW_END_PROCEDURE = "END_PROCEDURE"; -char *KW_END_REPEAT = "END_REPEAT"; -char *KW_END_RULE = "END_RULE"; -char *KW_END_SCHEMA = "END_SCHEMA"; -char *KW_END_TYPE = "END_TYPE"; -char *KW_ENTITY = "ENTITY"; -char *KW_ENUMERATION = "ENUMERATION"; -char *KW_ESCAPE = "ESCAPE"; -char *KW_EXISTS = "EXISTS"; -char *KW_EXP = "EXP"; -char *KW_FALSE = "FALSE"; -char *KW_FIXED = "FIXED"; -char *KW_FOR = "FOR"; -char *KW_FORMAT = "FORMAT"; -char *KW_FROM = "FROM"; -char *KW_FUNCTION = "FUNCTION"; -char *KW_GENERIC = "GENERIC"; -char *KW_HIBOUND = "HIBOUND"; -char *KW_HIINDEX = "HIINDEX"; -char *KW_IF = "IF"; -char *KW_IN = "IN"; -char *KW_INCLUDE = "INCLUDE"; -char *KW_INSERT = "INSERT"; -char *KW_INTEGER = "INTEGER"; -char *KW_INVERSE = "INVERSE"; -char *KW_LENGTH = "LENGTH"; -char *KW_LIKE = "LIKE"; -char *KW_LIST = "LIST"; -char *KW_LOBOUND = "LOBOUND"; -char *KW_LOCAL = "LOCAL"; -char *KW_LOG = "LOG"; -char *KW_LOG10 = "LOG10"; -char *KW_LOG2 = "LOG2"; -char *KW_LOGICAL = "LOGICAL"; -char *KW_LOINDEX = "LOINDEX"; -char *KW_MOD = "MOD"; -char *KW_MODEL = "MODEL"; -char *KW_NOT = "NOT"; -char *KW_NUMBER = "NUMBER"; -char *KW_NVL = "NVL"; -char *KW_ODD = "ODD"; -char *KW_OF = "OF"; -char *KW_ONEOF = "ONEOF"; -char *KW_OPTIONAL = "OPTIONAL"; -char *KW_OR = "OR"; -char *KW_OTHERWISE = "OTHERWISE"; -char *KW_PI = "PI"; -char *KW_PROCEDURE = "PROCEDURE"; -char *KW_QUERY = "QUERY"; -char *KW_REAL = "REAL"; -char *KW_REFERENCE = "REFERENCE"; -char *KW_REMOVE = "REMOVE"; -char *KW_REPEAT = "REPEAT"; -char *KW_RETURN = "RETURN"; -char *KW_ROLESOF = "ROLESOF"; -char *KW_RULE = "RULE"; -char *KW_SCHEMA = "SCHEMA"; -char *KW_SELECT = "SELECT"; -char *KW_SELF = "SELF"; -char *KW_SET = "SET"; -char *KW_SIN = "SIN"; -char *KW_SIZEOF = "SIZEOF"; -char *KW_SKIP = "SKIP"; -char *KW_SQRT = "SQRT"; -char *KW_STRING = "STRING"; -char *KW_SUBTYPE = "SUBTYPE"; -char *KW_SUPERTYPE = "SUPERTYPE"; -char *KW_TAN = "TAN"; -char *KW_THEN = "THEN"; -char *KW_TO = "TO"; -char *KW_TRUE = "TRUE"; -char *KW_TYPE = "TYPE"; -char *KW_TYPEOF = "TYPEOF"; -char *KW_UNIQUE = "UNIQUE"; -char *KW_UNKNOWN = "UNKNOWN"; -char *KW_UNTIL = "UNTIL"; -char *KW_USE = "USE"; -char *KW_USEDIN = "USEDIN"; -char *KW_VALUE = "VALUE"; -char *KW_VALUE_IN = "VALUE_IN"; -char *KW_VALUE_UNIQUE = "VALUE_UNIQUE"; -char *KW_VAR = "VAR"; -char *KW_WHERE = "WHERE"; -char *KW_WHILE = "WHILE"; -char *KW_XOR = "XOR"; +char * KW_ABS = "ABS"; +char * KW_ABSTRACT = "ABSTRACT"; +char * KW_ACOS = "ACOS"; +char * KW_AGGREGATE = "AGGREGATE"; +char * KW_ALIAS = "ALIAS"; +char * KW_AND = "AND"; +char * KW_ANDOR = "ANDOR"; +char * KW_ARRAY = "ARRAY"; +char * KW_AS = "AS"; +char * KW_ASIN = "ASIN"; +char * KW_ATAN = "ATAN"; +char * KW_BAG = "BAG"; +char * KW_BEGIN = "BEGIN"; +char * KW_BINARY = "BINARY"; +char * KW_BLENGTH = "BLENGTH"; +char * KW_BOOLEAN = "BOOLEAN"; +char * KW_BY = "BY"; +char * KW_CASE = "CASE"; +char * KW_CONST_E = "CONST_E"; +char * KW_CONSTANT = "CONSTANT"; +char * KW_CONTEXT = "CONTEXT"; +char * KW_COS = "COS"; +char * KW_DERIVE = "DERIVE"; +char * KW_DIV = "DIV"; +char * KW_ELSE = "ELSE"; +char * KW_END = "END"; +char * KW_END_ALIAS = "END_ALIAS"; +char * KW_END_CASE = "END_CASE"; +char * KW_END_CONSTANT = "END_CONSTANT"; +char * KW_END_CONTEXT = "END_CONTEXT"; +char * KW_END_ENTITY = "END_ENTITY"; +char * KW_END_FUNCTION = "END_FUNCTION"; +char * KW_END_IF = "END_IF"; +char * KW_END_LOCAL = "END_LOCAL"; +char * KW_END_MODEL = "END_MODEL"; +char * KW_END_PROCEDURE = "END_PROCEDURE"; +char * KW_END_REPEAT = "END_REPEAT"; +char * KW_END_RULE = "END_RULE"; +char * KW_END_SCHEMA = "END_SCHEMA"; +char * KW_END_TYPE = "END_TYPE"; +char * KW_ENTITY = "ENTITY"; +char * KW_ENUMERATION = "ENUMERATION"; +char * KW_ESCAPE = "ESCAPE"; +char * KW_EXISTS = "EXISTS"; +char * KW_EXP = "EXP"; +char * KW_FALSE = "FALSE"; +char * KW_FIXED = "FIXED"; +char * KW_FOR = "FOR"; +char * KW_FORMAT = "FORMAT"; +char * KW_FROM = "FROM"; +char * KW_FUNCTION = "FUNCTION"; +char * KW_GENERIC = "GENERIC"; +char * KW_HIBOUND = "HIBOUND"; +char * KW_HIINDEX = "HIINDEX"; +char * KW_IF = "IF"; +char * KW_IN = "IN"; +char * KW_INCLUDE = "INCLUDE"; +char * KW_INSERT = "INSERT"; +char * KW_INTEGER = "INTEGER"; +char * KW_INVERSE = "INVERSE"; +char * KW_LENGTH = "LENGTH"; +char * KW_LIKE = "LIKE"; +char * KW_LIST = "LIST"; +char * KW_LOBOUND = "LOBOUND"; +char * KW_LOCAL = "LOCAL"; +char * KW_LOG = "LOG"; +char * KW_LOG10 = "LOG10"; +char * KW_LOG2 = "LOG2"; +char * KW_LOGICAL = "LOGICAL"; +char * KW_LOINDEX = "LOINDEX"; +char * KW_MOD = "MOD"; +char * KW_MODEL = "MODEL"; +char * KW_NOT = "NOT"; +char * KW_NUMBER = "NUMBER"; +char * KW_NVL = "NVL"; +char * KW_ODD = "ODD"; +char * KW_OF = "OF"; +char * KW_ONEOF = "ONEOF"; +char * KW_OPTIONAL = "OPTIONAL"; +char * KW_OR = "OR"; +char * KW_OTHERWISE = "OTHERWISE"; +char * KW_PI = "PI"; +char * KW_PROCEDURE = "PROCEDURE"; +char * KW_QUERY = "QUERY"; +char * KW_REAL = "REAL"; +char * KW_REFERENCE = "REFERENCE"; +char * KW_REMOVE = "REMOVE"; +char * KW_REPEAT = "REPEAT"; +char * KW_RETURN = "RETURN"; +char * KW_ROLESOF = "ROLESOF"; +char * KW_RULE = "RULE"; +char * KW_SCHEMA = "SCHEMA"; +char * KW_SELECT = "SELECT"; +char * KW_SELF = "SELF"; +char * KW_SET = "SET"; +char * KW_SIN = "SIN"; +char * KW_SIZEOF = "SIZEOF"; +char * KW_SKIP = "SKIP"; +char * KW_SQRT = "SQRT"; +char * KW_STRING = "STRING"; +char * KW_SUBTYPE = "SUBTYPE"; +char * KW_SUPERTYPE = "SUPERTYPE"; +char * KW_TAN = "TAN"; +char * KW_THEN = "THEN"; +char * KW_TO = "TO"; +char * KW_TRUE = "TRUE"; +char * KW_TYPE = "TYPE"; +char * KW_TYPEOF = "TYPEOF"; +char * KW_UNIQUE = "UNIQUE"; +char * KW_UNKNOWN = "UNKNOWN"; +char * KW_UNTIL = "UNTIL"; +char * KW_USE = "USE"; +char * KW_USEDIN = "USEDIN"; +char * KW_VALUE = "VALUE"; +char * KW_VALUE_IN = "VALUE_IN"; +char * KW_VALUE_UNIQUE = "VALUE_UNIQUE"; +char * KW_VAR = "VAR"; +char * KW_WHERE = "WHERE"; +char * KW_WHILE = "WHILE"; +char * KW_XOR = "XOR"; diff --git a/src/express/expr.c b/src/express/expr.c index a4870dd08..7f814cf89 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -87,11 +87,10 @@ Expression LITERAL_ONE; void EXPop_init(); -static inline int OPget_number_of_operands(Op_Code op) -{ - if((op == OP_NEGATE) || (op == OP_NOT)) { +static inline int OPget_number_of_operands( Op_Code op ) { + if( ( op == OP_NEGATE ) || ( op == OP_NOT ) ) { return 1; - } else if(op == OP_SUBCOMPONENT) { + } else if( op == OP_SUBCOMPONENT ) { return 3; } else { return 2; @@ -99,47 +98,45 @@ static inline int OPget_number_of_operands(Op_Code op) } /** Description: Initialize the Expression module. */ -void EXPinitialize(void) -{ +void EXPinitialize( void ) { #ifdef does_not_appear_to_be_necessary_or_even_make_sense - LITERAL_EMPTY_SET = EXPcreate_simple(Type_Set); + LITERAL_EMPTY_SET = EXPcreate_simple( Type_Set ); LITERAL_EMPTY_SET->u.list = LISTcreate(); - resolved_all(LITERAL_EMPTY_SET); + resolved_all( LITERAL_EMPTY_SET ); #endif /* E and PI might come out of math.h */ - LITERAL_E = EXPcreate_simple(Type_Real); + LITERAL_E = EXPcreate_simple( Type_Real ); #ifndef M_E #define M_E 2.7182818284590452354 #endif LITERAL_E->u.real = M_E; - resolved_all(LITERAL_E); + resolved_all( LITERAL_E ); - LITERAL_PI = EXPcreate_simple(Type_Real); + LITERAL_PI = EXPcreate_simple( Type_Real ); #ifndef M_PI #define M_PI 3.14159265358979323846 #endif LITERAL_PI->u.real = M_PI; - resolved_all(LITERAL_PI); + resolved_all( LITERAL_PI ); - LITERAL_INFINITY = EXPcreate_simple(Type_Integer); + LITERAL_INFINITY = EXPcreate_simple( Type_Integer ); LITERAL_INFINITY->u.integer = INT_MAX; - resolved_all(LITERAL_INFINITY); + resolved_all( LITERAL_INFINITY ); - LITERAL_ZERO = EXPcreate_simple(Type_Integer); + LITERAL_ZERO = EXPcreate_simple( Type_Integer ); LITERAL_ZERO->u.integer = 0; - resolved_all(LITERAL_ZERO); + resolved_all( LITERAL_ZERO ); - LITERAL_ONE = EXPcreate_simple(Type_Integer); + LITERAL_ONE = EXPcreate_simple( Type_Integer ); LITERAL_ONE->u.integer = 1; - resolved_all(LITERAL_ONE); + resolved_all( LITERAL_ONE ); EXPop_init(); } -void EXPcleanup(void) -{ +void EXPcleanup( void ) { } /** @@ -153,24 +150,23 @@ void EXPcleanup(void) * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, - Variable *v, char *dt, struct Symbol_ **where, int s_id) -{ +static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e, + Variable * v, char * dt, struct Symbol_ ** where, int s_id ) { Expression item; Variable tmp; int options = 0; struct Symbol_ *w = NULL; - if(selection->search_id == s_id) { + if( selection->search_id == s_id ) { return 0; } - switch(selection->u.type->body->type) { + switch( selection->u.type->body->type ) { case entity_: /* goes through supertypes and their subtypes (!!) */ - tmp = ENTITYfind_inherited_attribute(selection->u.type->body->entity, sref.name, &w); - if(tmp) { - if(w != NULL) { + tmp = ENTITYfind_inherited_attribute( selection->u.type->body->entity, sref.name, &w ); + if( tmp ) { + if( w != NULL ) { *where = w; } *v = tmp; @@ -184,70 +180,64 @@ static int EXP_resolve_op_dot_fuzzy(Type selection, Symbol sref, Expression *e, Linked_List subt = LISTcreate(); Linked_List uniqSubs = LISTcreate(); selection->search_id = s_id; - LISTdo(selection->u.type->body->list, t, Type) { - int nr = EXP_resolve_op_dot_fuzzy(t, sref, e, v, dt, &w, s_id); - if(nr) { - if(w != NULL) { + LISTdo( selection->u.type->body->list, t, Type ) { + int nr = EXP_resolve_op_dot_fuzzy( t, sref, e, v, dt, &w, s_id ); + if( nr ) { + if( w != NULL ) { /* only ever set due to ENTITYfind_inherited_attribute in case entity_. * it is set to a subtype of one of the current type's supertypes. not * sure of the circumstances in which this is beneficial. */ *where = w; - LISTadd_last(subt, w); + LISTadd_last( subt, w ); } else { - LISTadd_last(supert, t); + LISTadd_last( supert, t ); } options += nr; } - } - LISTod + } LISTod /* go through supertypes and subtypes, comparing. for any subtypes in supertypes, remove item from subtypes * would be possible to delete items from subt while going through the list... worth the effort? */ - LISTdo(subt, s, Symbol *) { + LISTdo( subt, s, Symbol* ) { bool found = false; - LISTdo_n(supert, t, Type, b) { - if(0 == strcmp(s->name, t->symbol.name)) { + LISTdo_n( supert, t, Type, b ) { + if( 0 == strcmp( s->name, t->symbol.name ) ) { found = true; break; } + } LISTod + if( !found ) { + LISTadd_last( uniqSubs, s ); } - LISTod - if(!found) { - LISTadd_last(uniqSubs, s); - } - } - LISTod - if((LISTget_length(uniqSubs) == 0) && (LISTget_length(supert) == 1) && (options > 1)) { + } LISTod + if( ( LISTget_length( uniqSubs ) == 0 ) && ( LISTget_length( supert ) == 1 ) && ( options > 1 ) ) { options = 1; /* this ensures that v is set correctly and wasn't overwritten */ - EXP_resolve_op_dot_fuzzy((Type) LISTget_first(supert), sref, e, v, dt, &w, s_id); + EXP_resolve_op_dot_fuzzy( (Type) LISTget_first( supert ), sref, e, v, dt, &w, s_id ); } - if(options > 1) { + if( options > 1 ) { /* found more than one, so ambiguous */ *v = VARIABLE_NULL; } - LISTfree(supert); - LISTfree(subt); - LISTfree(uniqSubs); + LISTfree( supert ); + LISTfree( subt ); + LISTfree( uniqSubs ); return options; } case enumeration_: - item = (Expression)DICTlookup(TYPEget_enum_tags(selection), sref.name); - if(item) { + item = ( Expression )DICTlookup( TYPEget_enum_tags( selection ), sref.name ); + if( item ) { *e = item; *dt = DICT_type; return 1; - } else { - return 0; } default: return 0; } } -Type EXPresolve_op_dot(Expression expr, Scope scope) -{ +Type EXPresolve_op_dot( Expression expr, Scope scope ) { Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Variable v = 0; @@ -263,151 +253,151 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) /* op1 is entity expression, op2 is attribute */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve(op1, scope, Type_Dont_Care); - if(is_resolve_failed(op1)) { - resolve_failed(expr); - return(Type_Bad); + EXPresolve( op1, scope, Type_Dont_Care ); + if( is_resolve_failed( op1 ) ) { + resolve_failed( expr ); + return( Type_Bad ); } op1type = op1->return_type; - switch(op1type->u.type->body->type) { + switch( op1type->u.type->body->type ) { case generic_: case runtime_: /* defer */ - return(Type_Runtime); + return( Type_Runtime ); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo(op1type->u.type->body->list, t, Type) { + LISTdo( op1type->u.type->body->list, t, Type ) { /* this used to increment options by 1 if EXP_resolve_op_dot_fuzzy found 1 or more possibilities. * thus the code for handling ambiguities was only used if the ambig was in the immediate type * and not a supertype. don't think that's right... */ - options += EXP_resolve_op_dot_fuzzy(t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id); + options += EXP_resolve_op_dot_fuzzy( t, op2->symbol, &item, &v, &dt, &where, __SCOPE_search_id ); } LISTod; - switch(options) { + switch( options ) { case 0: - LISTdo(op1type->u.type->body->list, t, Type) { - if(t->u.type->body->type != enumeration_) { + LISTdo( op1type->u.type->body->list, t, Type ) { + if( t->u.type->body->type != enumeration_ ) { all_enums = false; } } LISTod; - if(all_enums) { - ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name); + if( all_enums ) { + ERRORreport_with_symbol(CASE_SKIP_LABEL, &op2->symbol, op2->symbol.name ); } else { /* no possible resolutions */ - ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name); + ERRORreport_with_symbol(UNDEFINED_ATTR, &op2->symbol, op2->symbol.name ); } - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); case 1: /* only one possible resolution */ - if(dt == OBJ_VARIABLE) { - if(where) { - ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name); + if( dt == OBJ_VARIABLE ) { + if( where ) { + ERRORreport_with_symbol(IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } - if(v == VARIABLE_NULL) { - fprintf(stderr, "EXPresolve_op_dot: nonsense value for Variable\n"); - ERRORabort(0); + if( v == VARIABLE_NULL ) { + fprintf( stderr, "EXPresolve_op_dot: nonsense value for Variable\n" ); + ERRORabort( 0 ); } op2->u.variable = v; op2->return_type = v->type; - resolved_all(expr); - return(v->type); - } else if(dt == OBJ_ENUM) { + resolved_all( expr ); + return( v->type ); + } else if( dt == OBJ_ENUM ) { op2->u.expression = item; op2->return_type = item->type; - resolved_all(expr); - return(item->type); + resolved_all( expr ); + return( item->type ); } else { - fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); - ERRORabort(0); - return(Type_Bad); + fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); + ERRORabort( 0 ); } + default: /* compile-time ambiguous */ - if(where) { + if( where ) { /* this is actually a warning, not an error */ - ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name); + ERRORreport_with_symbol(AMBIG_IMPLICIT_DOWNCAST, &op2->symbol, where->name ); } - return(Type_Runtime); + return( Type_Runtime ); } case attribute_: - v = ENTITYresolve_attr_ref(op1->u.variable->type->u.type->body->entity, (struct Symbol_ *)0, &op2->symbol); + v = ENTITYresolve_attr_ref( op1->u.variable->type->u.type->body->entity, ( struct Symbol_ * )0, &op2->symbol ); - if(!v) { + if( !v ) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); } - if(DICT_type != OBJ_VARIABLE) { - fprintf(stderr, "EXPresolved_op_dot: attribute not an attribute?\n"); - ERRORabort(0); + if( DICT_type != OBJ_VARIABLE ) { + fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); + ERRORabort( 0 ); } op2->u.variable = v; op2->return_type = v->type; - resolved_all(expr); - return(v->type); + resolved_all( expr ); + return( v->type ); case entity_: case op_: /* (op1).op2 */ - v = ENTITYresolve_attr_ref(op1type->u.type->body->entity, - (struct Symbol_ *)0, &op2->symbol); - if(!v) { + v = ENTITYresolve_attr_ref( op1type->u.type->body->entity, + ( struct Symbol_ * )0, &op2->symbol ); + if( !v ) { /* reported by ENTITYresolve_attr_ref */ /* ERRORreport_with_symbol(ERROR_undefined_attribute,*/ /* &expr->symbol,op2->symbol.name);*/ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); } - if(DICT_type != OBJ_VARIABLE) { - fprintf(stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n"); + if( DICT_type != OBJ_VARIABLE ) { + fprintf( stderr, "ERROR: EXPresolved_op_dot: attribute not an attribute?\n" ); } op2->u.variable = v; /* changed to set return_type */ op2->return_type = op2->u.variable->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); case enumeration_: /* enumerations within a select will be handled by `case select_` above, * which calls EXP_resolve_op_dot_fuzzy(). */ - item = (Expression)DICTlookup(TYPEget_enum_tags(op1type), op2->symbol.name); - if(!item) { + item = ( Expression )DICTlookup( TYPEget_enum_tags( op1type ), op2->symbol.name ); + if( !item ) { ERRORreport_with_symbol(ENUM_NO_SUCH_ITEM, &op2->symbol, - op1type->symbol.name, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + op1type->symbol.name, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } op2->u.expression = item; op2->return_type = item->type; - resolved_all(expr); - return(item->type); + resolved_all( expr ); + return( item->type ); case aggregate_: case array_: case bag_: case list_: case set_: ERRORreport_with_symbol(ATTRIBUTE_REF_ON_AGGREGATE, - &op2->symbol, op2->symbol.name); - /*FALLTHRU*/ + &op2->symbol, op2->symbol.name ); + /*FALLTHRU*/ case unknown_: /* unable to resolved operand */ /* presumably error has already been reported */ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); default: ERRORreport_with_symbol(ATTRIBUTE_REF_FROM_NON_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } } @@ -416,21 +406,20 @@ Type EXPresolve_op_dot(Expression expr, Scope scope) * there will be no ambiguities, since we're looking at (and marking) * only types, and it's marking only entities */ -static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, - int s_id) -{ +static int EXP_resolve_op_group_fuzzy( Type selection, Symbol sref, Entity * e, + int s_id ) { Entity tmp; int options = 0; - if(selection->search_id == s_id) { + if( selection->search_id == s_id ) { return 0; } - switch(selection->u.type->body->type) { + switch( selection->u.type->body->type ) { case entity_: - tmp = (Entity)ENTITYfind_inherited_entity( - selection->u.type->body->entity, sref.name, 1); - if(tmp) { + tmp = ( Entity )ENTITYfind_inherited_entity( + selection->u.type->body->entity, sref.name, 1 ); + if( tmp ) { *e = tmp; return 1; } @@ -439,16 +428,16 @@ static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, case select_: tmp = *e; selection->search_id = s_id; - LISTdo(selection->u.type->body->list, t, Type) - if(EXP_resolve_op_group_fuzzy(t, sref, e, s_id)) { - if(*e != tmp) { + LISTdo( selection->u.type->body->list, t, Type ) + if( EXP_resolve_op_group_fuzzy( t, sref, e, s_id ) ) { + if( *e != tmp ) { tmp = *e; ++options; } } LISTod; - switch(options) { + switch( options ) { case 0: return 0; case 1: @@ -463,8 +452,7 @@ static int EXP_resolve_op_group_fuzzy(Type selection, Symbol sref, Entity *e, } } -Type EXPresolve_op_group(Expression expr, Scope scope) -{ +Type EXPresolve_op_group( Expression expr, Scope scope ) { Expression op1 = expr->e.op1; Expression op2 = expr->e.op2; Entity ent_ref = ENTITY_NULL; @@ -477,84 +465,84 @@ Type EXPresolve_op_group(Expression expr, Scope scope) /* op1 is entity expression, op2 is entity */ /* could be very impossible to determine except */ /* at run-time, .... */ - EXPresolve(op1, scope, Type_Dont_Care); - if(is_resolve_failed(op1)) { - resolve_failed(expr); - return(Type_Bad); + EXPresolve( op1, scope, Type_Dont_Care ); + if( is_resolve_failed( op1 ) ) { + resolve_failed( expr ); + return( Type_Bad ); } op1type = op1->return_type; - switch(op1type->u.type->body->type) { + switch( op1type->u.type->body->type ) { case generic_: case runtime_: case op_: /* All these cases are very painful to do right */ /* "Generic" and sometimes others require runtime evaluation */ op2->return_type = Type_Runtime; - return(Type_Runtime); + return( Type_Runtime ); case self_: case entity_: /* Get entity denoted by "X\" */ - tmp = ((op1type->u.type->body->type == self_) - ? scope - : op1type->u.type->body->entity); + tmp = ( ( op1type->u.type->body->type == self_ ) + ? scope + : op1type->u.type->body->entity ); /* Now get entity denoted by "X\Y" */ ent_ref = - (Entity)ENTITYfind_inherited_entity(tmp, op2->symbol.name, 1); - if(!ent_ref) { + ( Entity )ENTITYfind_inherited_entity( tmp, op2->symbol.name, 1 ); + if( !ent_ref ) { ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); } op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); case select_: __SCOPE_search_id++; /* don't think this actually actually catches anything on the */ /* first go-round, but let's be consistent */ op1type->search_id = __SCOPE_search_id; - LISTdo(op1type->u.type->body->list, t, Type) - if(EXP_resolve_op_group_fuzzy(t, op2->symbol, &ent_ref, - __SCOPE_search_id)) { - if(ent_ref != tmp) { + LISTdo( op1type->u.type->body->list, t, Type ) + if( EXP_resolve_op_group_fuzzy( t, op2->symbol, &ent_ref, + __SCOPE_search_id ) ) { + if( ent_ref != tmp ) { tmp = ent_ref; ++options; } } LISTod; - switch(options) { + switch( options ) { case 0: /* no possible resolutions */ ERRORreport_with_symbol(GROUP_REF_NO_SUCH_ENTITY, - &op2->symbol, op2->symbol.name); - resolve_failed(expr); - return(Type_Bad); + &op2->symbol, op2->symbol.name ); + resolve_failed( expr ); + return( Type_Bad ); case 1: /* only one possible resolution */ op2->u.entity = ent_ref; op2->return_type = ent_ref->u.entity->type; - resolved_all(expr); - return(op2->return_type); + resolved_all( expr ); + return( op2->return_type ); default: /* compile-time ambiguous */ /* ERRORreport_with_symbol(ERROR_ambiguous_group,*/ /* &op2->symbol, op2->symbol.name);*/ - return(Type_Runtime); + return( Type_Runtime ); } case array_: - if(op1->type->u.type->body->type == self_) { - return(Type_Runtime); /* not sure if there are other cases where Type_Runtime should be returned, or not */ + if( op1->type->u.type->body->type == self_ ) { + return( Type_Runtime ); /* not sure if there are other cases where Type_Runtime should be returned, or not */ } /* else fallthrough */ case unknown_: /* unable to resolve operand */ /* presumably error has already been reported */ - resolve_failed(expr); - return(Type_Bad); + resolve_failed( expr ); + return( Type_Bad ); case aggregate_: case bag_: @@ -562,117 +550,112 @@ Type EXPresolve_op_group(Expression expr, Scope scope) case set_: default: ERRORreport_with_symbol(GROUP_REF_UNEXPECTED_TYPE, - &op1->symbol); - return(Type_Bad); + &op1->symbol ); + return( Type_Bad ); } } -Type EXPresolve_op_relational(Expression e, Scope s) -{ +Type EXPresolve_op_relational( Expression e, Scope s ) { Type t = 0; int failed = 0; Type op1type; /* Prevent op1 from complaining if it fails */ - EXPresolve(e->e.op1, s, Type_Unknown); - failed = is_resolve_failed(e->e.op1); + EXPresolve( e->e.op1, s, Type_Unknown ); + failed = is_resolve_failed( e->e.op1 ); op1type = e->e.op1->return_type; /* now, either op1 was resolved in which case, we use its return type */ /* for typechecking, OR, it wasn't resolved in which case we resolve */ /* op2 in such a way that it complains if it fails to resolved */ - if(op1type == Type_Unknown) { + if( op1type == Type_Unknown ) { t = Type_Dont_Care; } else { t = op1type; } - EXPresolve(e->e.op2, s, t); - if(is_resolve_failed(e->e.op2)) { + EXPresolve( e->e.op2, s, t ); + if( is_resolve_failed( e->e.op2 ) ) { failed = 1; } /* If op1 wasn't successfully resolved, retry it now with new information */ - if((failed == 0) && !is_resolved(e->e.op1)) { - EXPresolve(e->e.op1, s, e->e.op2->return_type); - if(is_resolve_failed(e->e.op1)) { + if( ( failed == 0 ) && !is_resolved( e->e.op1 ) ) { + EXPresolve( e->e.op1, s, e->e.op2->return_type ); + if( is_resolve_failed( e->e.op1 ) ) { failed = 1; } } - if(failed) { - resolve_failed(e); + if( failed ) { + resolve_failed( e ); } else { - resolved_all(e); + resolved_all( e ); } - return(Type_Logical); + return( Type_Logical ); } -void EXPresolve_op_default(Expression e, Scope s) -{ +void EXPresolve_op_default( Expression e, Scope s ) { int failed = 0; - if(OPget_number_of_operands(e->e.op_code) == 3) { - EXPresolve(e->e.op3, s, Type_Dont_Care); - failed = is_resolve_failed(e->e.op3); - } - if(OPget_number_of_operands(e->e.op_code) == 2) { - EXPresolve(e->e.op2, s, Type_Dont_Care); - failed |= is_resolve_failed(e->e.op2); + switch( OPget_number_of_operands( e->e.op_code ) ) { + case 3: + EXPresolve( e->e.op3, s, Type_Dont_Care ); + failed = is_resolve_failed( e->e.op3 ); + case 2: + EXPresolve( e->e.op2, s, Type_Dont_Care ); + failed |= is_resolve_failed( e->e.op2 ); } - EXPresolve(e->e.op1, s, Type_Dont_Care); - if(failed || is_resolve_failed(e->e.op1)) { - resolve_failed(e); + EXPresolve( e->e.op1, s, Type_Dont_Care ); + if( failed || is_resolve_failed( e->e.op1 ) ) { + resolve_failed( e ); } else { - resolved_all(e); + resolved_all( e ); } } /* prototype for this func cannot change - it is passed as a fn pointer */ -Type EXPresolve_op_unknown(Expression e, Scope s) -{ +Type EXPresolve_op_unknown( Expression e, Scope s ) { (void) e; /* quell unused param warning */ (void) s; - ERRORreport(INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE); + ERRORreport( INTERNAL_UNRECOGNISED_OP_IN_EXPRESOLVE ); return Type_Bad; } -typedef Type(Resolve_expr_func)(Expression, Scope); +typedef Type (Resolve_expr_func) ( Expression , Scope ); -Type EXPresolve_op_logical(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); - return(Type_Logical); +Type EXPresolve_op_logical( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); + return( Type_Logical ); } -Type EXPresolve_op_array_like(Expression e, Scope s) -{ +Type EXPresolve_op_array_like( Expression e, Scope s ) { Type op1type; - EXPresolve_op_default(e, s); + EXPresolve_op_default( e, s ); op1type = e->e.op1->return_type; - if(TYPEis_aggregate(op1type)) { - return(op1type->u.type->body->base); - } else if(TYPEis_string(op1type)) { - return(op1type); - } else if(op1type == Type_Runtime) { - return(Type_Runtime); - } else if(op1type->u.type->body->type == binary_) { - ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__); - return(Type_Binary); - } else if(op1type->u.type->body->type == generic_) { - return(Type_Generic); - } else if(TYPEis_select(op1type)) { + if( TYPEis_aggregate( op1type ) ) { + return( op1type->u.type->body->base ); + } else if( TYPEis_string( op1type ) ) { + return( op1type ); + } else if( op1type == Type_Runtime ) { + return( Type_Runtime ); + } else if( op1type->u.type->body->type == binary_ ) { + ERRORreport_with_symbol(WARN_UNSUPPORTED_LANG_FEAT, &e->symbol, "indexing on a BINARY", __FILE__, __LINE__ ); + return( Type_Binary ); + } else if( op1type->u.type->body->type == generic_ ) { + return( Type_Generic ); + } else if( TYPEis_select( op1type ) ) { int numAggr = 0, numNonAggr = 0; bool sameAggrType = true; Type lasttype = 0; /* FIXME Is it possible that the base type hasn't yet been resolved? * If it is possible, we should signal that we need to come back later... but how? */ - assert(op1type->symbol.resolved == 1); + assert( op1type->symbol.resolved == 1 ); /* FIXME We should check for a not...or excluding non-aggregate types in the select, such as * WR1: NOT('INDEX_ATTRIBUTE.COMMON_DATUM_LIST' IN TYPEOF(base)) OR (SELF\shape_aspect.of_shape = base[1]\shape_aspect.of_shape); @@ -680,13 +663,13 @@ Type EXPresolve_op_array_like(Expression e, Scope s) */ /* count aggregates and non-aggregates, check aggregate types */ - LISTdo(op1type->u.type->body->list, item, Type) { - if(TYPEis_aggregate(item)) { + LISTdo( op1type->u.type->body->list, item, Type ) { + if( TYPEis_aggregate( item ) ) { numAggr++; - if(lasttype == TYPE_NULL) { + if( lasttype == TYPE_NULL ) { lasttype = item; } else { - if(lasttype->u.type->body->type != item->u.type->body->type) { + if( lasttype->u.type->body->type != item->u.type->body->type ) { sameAggrType = false; } } @@ -698,43 +681,40 @@ Type EXPresolve_op_array_like(Expression e, Scope s) /* NOTE the following code returns the same data for every case that isn't an error. * It needs to be simplified or extended, depending on whether it works or not. */ - if(sameAggrType && (numAggr != 0) && (numNonAggr == 0)) { + if( sameAggrType && ( numAggr != 0 ) && ( numNonAggr == 0 ) ) { /* All are the same aggregation type */ - return(lasttype->u.type->body->base); - } else if(numNonAggr == 0) { + return( lasttype->u.type->body->base ); + } else if( numNonAggr == 0 ) { /* All aggregates, but different types */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); - return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ - } else if(numAggr != 0) { + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); + return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ + } else if( numAggr != 0 ) { /* One or more aggregates, one or more nonaggregates */ - ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name); - return(lasttype->u.type->body->base); /* WARNING I'm assuming that any of the types is acceptable!!! */ + ERRORreport_with_symbol(WARN_INDEXING_MIXED, &e->symbol, op1type->symbol.name ); + return( lasttype->u.type->body->base ); /* WARNING I'm assuming that any of the types is acceptable!!! */ } /* Else, all are nonaggregates. This is an error. */ } - ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol); - return(Type_Unknown); + ERRORreport_with_symbol(INDEXING_ILLEGAL, &e->symbol ); + return( Type_Unknown ); } -Type EXPresolve_op_entity_constructor(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_entity_constructor( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); /* perhaps should return Type_Runtime? */ return Type_Entity; } -Type EXPresolve_op_int_div_like(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_int_div_like( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); return Type_Integer; } -Type EXPresolve_op_plus_like(Expression e, Scope s) -{ +Type EXPresolve_op_plus_like( Expression e, Scope s ) { /* i.e., Integer or Real */ - EXPresolve_op_default(e, s); - if(is_resolve_failed(e)) { - resolve_failed(e); - return(Type_Unknown); + EXPresolve_op_default( e, s ); + if( is_resolve_failed( e ) ) { + resolve_failed( e ); + return( Type_Unknown ); } /* could produce better results with a lot of pain but the EXPRESS */ @@ -745,22 +725,21 @@ Type EXPresolve_op_plus_like(Expression e, Scope s) /* and list+set=? */ /* crude but sufficient */ - if((TYPEis_aggregate(e->e.op1->return_type)) || - (TYPEis_aggregate(e->e.op2->return_type))) { + if( ( TYPEis_aggregate( e->e.op1->return_type ) ) || + ( TYPEis_aggregate( e->e.op2->return_type ) ) ) { return Type_Aggregate; } /* crude but sufficient */ - if((e->e.op1->return_type->u.type->body->type == real_) || - (e->e.op2->return_type->u.type->body->type == real_)) { - return(Type_Real); + if( ( e->e.op1->return_type->u.type->body->type == real_ ) || + ( e->e.op2->return_type->u.type->body->type == real_ ) ) { + return( Type_Real ); } return Type_Integer; } -Type EXPresolve_op_unary_minus(Expression e, Scope s) -{ - EXPresolve_op_default(e, s); +Type EXPresolve_op_unary_minus( Expression e, Scope s ) { + EXPresolve_op_default( e, s ); return e->e.op1->return_type; } @@ -773,43 +752,41 @@ Type EXPresolve_op_unary_minus(Expression e, Scope s) * \param string human-readable description * \param resolve_func resolves an expression of this type */ -void EXPop_create(int token_number, char *string, Resolve_expr_func *resolve_func) -{ +void EXPop_create( int token_number, char * string, Resolve_expr_func * resolve_func ) { EXPop_table[token_number].token = string; EXPop_table[token_number].resolve = resolve_func; } -void EXPop_init() -{ - EXPop_create(OP_AND, "AND", EXPresolve_op_logical); - EXPop_create(OP_ANDOR, "ANDOR", EXPresolve_op_logical); - EXPop_create(OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like); - EXPop_create(OP_CONCAT, "||", EXPresolve_op_entity_constructor); - EXPop_create(OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like); - EXPop_create(OP_DOT, ".", EXPresolve_op_dot); - EXPop_create(OP_EQUAL, "=", EXPresolve_op_relational); - EXPop_create(OP_EXP, "**", EXPresolve_op_plus_like); - EXPop_create(OP_GREATER_EQUAL, ">=", EXPresolve_op_relational); - EXPop_create(OP_GREATER_THAN, ">", EXPresolve_op_relational); - EXPop_create(OP_GROUP, "\\", EXPresolve_op_group); - EXPop_create(OP_IN, "IN", EXPresolve_op_relational); - EXPop_create(OP_INST_EQUAL, ":=:", EXPresolve_op_relational); - EXPop_create(OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational); - EXPop_create(OP_LESS_EQUAL, "<=", EXPresolve_op_relational); - EXPop_create(OP_LESS_THAN, "<", EXPresolve_op_relational); - EXPop_create(OP_LIKE, "LIKE", EXPresolve_op_relational); - EXPop_create(OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like); - EXPop_create(OP_MOD, "MOD", EXPresolve_op_int_div_like); - EXPop_create(OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus); - EXPop_create(OP_NOT, "NOT", EXPresolve_op_logical); - EXPop_create(OP_NOT_EQUAL, "<>", EXPresolve_op_relational); - EXPop_create(OP_OR, "OR", EXPresolve_op_logical); - EXPop_create(OP_PLUS, "+", EXPresolve_op_plus_like); - EXPop_create(OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like); - EXPop_create(OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like); - EXPop_create(OP_TIMES, "*", EXPresolve_op_plus_like); - EXPop_create(OP_XOR, "XOR", EXPresolve_op_logical); - EXPop_create(OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown); +void EXPop_init() { + EXPop_create( OP_AND, "AND", EXPresolve_op_logical ); + EXPop_create( OP_ANDOR, "ANDOR", EXPresolve_op_logical ); + EXPop_create( OP_ARRAY_ELEMENT, "[array element]", EXPresolve_op_array_like ); + EXPop_create( OP_CONCAT, "||", EXPresolve_op_entity_constructor ); + EXPop_create( OP_DIV, "/ (INTEGER)", EXPresolve_op_int_div_like ); + EXPop_create( OP_DOT, ".", EXPresolve_op_dot ); + EXPop_create( OP_EQUAL, "=", EXPresolve_op_relational ); + EXPop_create( OP_EXP, "**", EXPresolve_op_plus_like ); + EXPop_create( OP_GREATER_EQUAL, ">=", EXPresolve_op_relational ); + EXPop_create( OP_GREATER_THAN, ">", EXPresolve_op_relational ); + EXPop_create( OP_GROUP, "\\", EXPresolve_op_group ); + EXPop_create( OP_IN, "IN", EXPresolve_op_relational ); + EXPop_create( OP_INST_EQUAL, ":=:", EXPresolve_op_relational ); + EXPop_create( OP_INST_NOT_EQUAL, ":<>:", EXPresolve_op_relational ); + EXPop_create( OP_LESS_EQUAL, "<=", EXPresolve_op_relational ); + EXPop_create( OP_LESS_THAN, "<", EXPresolve_op_relational ); + EXPop_create( OP_LIKE, "LIKE", EXPresolve_op_relational ); + EXPop_create( OP_MINUS, "- (MINUS)", EXPresolve_op_plus_like ); + EXPop_create( OP_MOD, "MOD", EXPresolve_op_int_div_like ); + EXPop_create( OP_NEGATE, "- (NEGATE)", EXPresolve_op_unary_minus ); + EXPop_create( OP_NOT, "NOT", EXPresolve_op_logical ); + EXPop_create( OP_NOT_EQUAL, "<>", EXPresolve_op_relational ); + EXPop_create( OP_OR, "OR", EXPresolve_op_logical ); + EXPop_create( OP_PLUS, "+", EXPresolve_op_plus_like ); + EXPop_create( OP_REAL_DIV, "/ (REAL)", EXPresolve_op_plus_like ); + EXPop_create( OP_SUBCOMPONENT, "[:]", EXPresolve_op_array_like ); + EXPop_create( OP_TIMES, "*", EXPresolve_op_plus_like ); + EXPop_create( OP_XOR, "XOR", EXPresolve_op_logical ); + EXPop_create( OP_UNKNOWN, "UNKNOWN OP", EXPresolve_op_unknown ); } /** @@ -818,82 +795,80 @@ void EXPop_init() ** \returns value of expression ** Compute the value of an integer expression. */ -int EXPget_integer_value(Expression expression) -{ +int EXPget_integer_value( Expression expression ) { /* TODO: why is this treated differently than a type error below? */ - if(expression == EXPRESSION_NULL) { + if( expression == EXPRESSION_NULL ) { return 0; } - if(expression->return_type->u.type->body->type == integer_) { - return INT_LITget_value(expression); + if( expression->return_type->u.type->body->type == integer_ ) { + return INT_LITget_value( expression ); } else { ERRORreport(INTEGER_EXPRESSION_EXPECTED); return 0; } } -char *opcode_print(Op_Code o) -{ - switch(o) { +char * opcode_print( Op_Code o ) { + switch( o ) { case OP_AND: - return("OP_AND"); + return( "OP_AND" ); case OP_ANDOR: - return("OP_ANDOR"); + return( "OP_ANDOR" ); case OP_ARRAY_ELEMENT: - return("OP_ARRAY_ELEMENT"); + return( "OP_ARRAY_ELEMENT" ); case OP_CONCAT: - return("OP_CONCAT"); + return( "OP_CONCAT" ); case OP_DIV: - return("OP_DIV"); + return( "OP_DIV" ); case OP_DOT: - return("OP_DOT"); + return( "OP_DOT" ); case OP_EQUAL: - return("OP_EQUAL"); + return( "OP_EQUAL" ); case OP_EXP: - return("OP_EXP"); + return( "OP_EXP" ); case OP_GREATER_EQUAL: - return("OP_GREATER_EQUAL"); + return( "OP_GREATER_EQUAL" ); case OP_GREATER_THAN: - return("OP_GREATER_THAN"); + return( "OP_GREATER_THAN" ); case OP_GROUP: - return("OP_GROUP"); + return( "OP_GROUP" ); case OP_IN: - return("OP_IN"); + return( "OP_IN" ); case OP_INST_EQUAL: - return("OP_INST_EQUAL"); + return( "OP_INST_EQUAL" ); case OP_INST_NOT_EQUAL: - return("OP_INST_NOT_EQUAL"); + return( "OP_INST_NOT_EQUAL" ); case OP_LESS_EQUAL: - return("OP_LESS_EQUAL"); + return( "OP_LESS_EQUAL" ); case OP_LESS_THAN: - return("OP_LESS_THAN"); + return( "OP_LESS_THAN" ); case OP_LIKE: - return("OP_LIKE"); + return( "OP_LIKE" ); case OP_MINUS: - return("OP_MINUS"); + return( "OP_MINUS" ); case OP_MOD: - return("OP_MOD"); + return( "OP_MOD" ); case OP_NEGATE: - return("OP_NEGATE"); + return( "OP_NEGATE" ); case OP_NOT: - return("OP_NOT"); + return( "OP_NOT" ); case OP_NOT_EQUAL: - return("OP_NOT_EQUAL"); + return( "OP_NOT_EQUAL" ); case OP_OR: - return("OP_OR"); + return( "OP_OR" ); case OP_PLUS: - return("OP_PLUS"); + return( "OP_PLUS" ); case OP_REAL_DIV: - return("OP_REAL_DIV"); + return( "OP_REAL_DIV" ); case OP_SUBCOMPONENT: - return("OP_SUBCOMPONENT"); + return( "OP_SUBCOMPONENT" ); case OP_TIMES: - return("OP_TIMES"); + return( "OP_TIMES" ); case OP_XOR: - return("OP_XOR"); + return( "OP_XOR" ); case OP_UNKNOWN: - return("OP_UNKNOWN"); + return( "OP_UNKNOWN" ); default: - return("no such op"); + return( "no such op" ); } } diff --git a/src/express/express.c b/src/express/express.c index 783b142e3..82e7b7889 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -87,22 +87,22 @@ #include "parse_data.h" #include "express/lexact.h" -void *ParseAlloc(void *(*mallocProc)(size_t)); -void ParseFree(void *parser, void (*freeProc)(void *)); -void Parse(void *parser, int tokenID, YYSTYPE data, parse_data_t parseData); +void * ParseAlloc( void * ( *mallocProc )( size_t ) ); +void ParseFree( void * parser, void ( *freeProc )( void * ) ); +void Parse( void * parser, int tokenID, YYSTYPE data, parse_data_t parseData ); void ParseTrace(FILE *TraceFILE, char *zTracePrompt); Linked_List EXPRESS_path; int EXPRESSpass; -void (*EXPRESSinit_args)(int, char **) = NULL; -void (*EXPRESSinit_parse)(void) = NULL; -int (*EXPRESSfail)(Express) = NULL; -int (*EXPRESSsucceed)(Express) = NULL; -void (*EXPRESSbackend)(Express) = NULL; -char *EXPRESSprogram_name; +void ( *EXPRESSinit_args )( int, char ** ) = NULL; +void ( *EXPRESSinit_parse )( void ) = NULL; +int ( *EXPRESSfail )( Express ) = NULL; +int ( *EXPRESSsucceed )( Express ) = NULL; +void ( *EXPRESSbackend )( Express ) = NULL; +char * EXPRESSprogram_name; extern char EXPRESSgetopt_options[]; /* initialized elsewhere */ -int (*EXPRESSgetopt)(int, char *) = NULL; +int ( *EXPRESSgetopt )( int, char * ) = NULL; bool EXPRESSignore_duplicate_schemas = false; Function funcdef(char *name, int pcount, Type ret_typ); @@ -111,154 +111,146 @@ void BUILTINSinitialize(); Dictionary EXPRESSbuiltins; /* procedures/functions */ -struct Scope_ *FUNC_NVL; -struct Scope_ *FUNC_USEDIN; +struct Scope_ * FUNC_NVL; +struct Scope_ * FUNC_USEDIN; extern Express yyexpresult; extern Linked_List PARSEnew_schemas; -void SCOPEinitialize(void); +void SCOPEinitialize( void ); -static Express PARSERrun(char *, FILE *); +static Express PARSERrun( char *, FILE * ); /** name specified on command line */ -char *input_filename = 0; +char * input_filename = 0; -int EXPRESS_fail(Express model) -{ +int EXPRESS_fail( Express model ) { ERRORflush_messages(); - if(EXPRESSfail) { - return((*EXPRESSfail)(model)); + if( EXPRESSfail ) { + return( ( *EXPRESSfail )( model ) ); } - fprintf(stderr, "Errors in input\n"); + fprintf( stderr, "Errors in input\n" ); return 1; } -int EXPRESS_succeed(Express model) -{ - if(EXPRESSsucceed) { - return((*EXPRESSsucceed)(model)); +int EXPRESS_succeed( Express model ) { + if( EXPRESSsucceed ) { + return( ( *EXPRESSsucceed )( model ) ); } - fprintf(stderr, "No errors in input\n"); + fprintf( stderr, "No errors in input\n" ); return 0; } -Express EXPRESScreate() -{ - Express model = SCOPEcreate(OBJ_EXPRESS); - model->u.express = (struct Express_ *)sc_calloc(1, sizeof(struct Express_)); +Express EXPRESScreate() { + Express model = SCOPEcreate( OBJ_EXPRESS ); + model->u.express = ( struct Express_ * )sc_calloc( 1, sizeof( struct Express_ ) ); return model; } -void EXPRESSdestroy(Express model) -{ - if(model->u.express->basename) { - sc_free(model->u.express->basename); +void EXPRESSdestroy( Express model ) { + if( model->u.express->basename ) { + sc_free( model->u.express->basename ); } - if(model->u.express->filename) { - sc_free(model->u.express->filename); + if( model->u.express->filename ) { + sc_free( model->u.express->filename ); } - sc_free(model->u.express); - SCOPEdestroy(model); + sc_free( model->u.express ); + SCOPEdestroy( model ); } #define MAX_SCHEMA_FILENAME_SIZE 256 typedef struct Dir { char full[MAX_SCHEMA_FILENAME_SIZE]; - char *leaf; + char * leaf; } Dir; -static void EXPRESS_PATHinit() -{ - char *p; - Dir *dir; +static void EXPRESS_PATHinit() { + char * p; + Dir * dir; EXPRESS_path = LISTcreate(); - p = getenv("EXPRESS_PATH"); - if(!p) { + p = getenv( "EXPRESS_PATH" ); + if( !p ) { /* if no EXPRESS_PATH, search current directory anyway */ - dir = (Dir *)sc_malloc(sizeof(Dir)); + dir = ( Dir * )sc_malloc( sizeof( Dir ) ); dir->leaf = dir->full; - LISTadd_last(EXPRESS_path, dir); + LISTadd_last( EXPRESS_path, dir ); } else { int done = 0; - while(!done) { - char *start; /* start of current dir */ + while( !done ) { + char * start; /* start of current dir */ int length; /* length of dir */ - char *slash; /* last slash in dir */ + char * slash; /* last slash in dir */ char save; /* place to character from where we */ /* temporarily null terminate */ /* get next directory */ - while(isspace(*p)) { + while( isspace( *p ) ) { p++; } - if(*p == '\0') { + if( *p == '\0' ) { break; } start = p; /* find the end of the directory */ - while(*p != '\0' && !isspace(*p)) { + while( *p != '\0' && !isspace( *p ) ) { p++; } save = *p; - if(*p == 0) { + if( *p == 0 ) { done = 1; } else { *p = '\0'; } p++; /* leave p after terminating null */ - dir = (Dir *)sc_malloc(sizeof(Dir)); + dir = ( Dir * )sc_malloc( sizeof( Dir ) ); /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ - if(!strcmp(".", start)) { + if( !strcmp( ".", start ) ) { dir->leaf = dir->full; - LISTadd_last(EXPRESS_path, dir); - *(p - 1) = save; /* put char back where */ + LISTadd_last( EXPRESS_path, dir ); + *( p - 1 ) = save; /* put char back where */ /* temp null was */ continue; } - length = (p - 1) - start; + length = ( p - 1 ) - start; /* if slash present at end, don't add another */ - slash = strrchr(start, '/'); - if(slash && (slash[1] == '\0')) { - strcpy(dir->full, start); + slash = strrchr( start, '/' ); + if( slash && ( slash[1] == '\0' ) ) { + strcpy( dir->full, start ); dir->leaf = dir->full + length; } else { - sprintf(dir->full, "%s/", start); + sprintf( dir->full, "%s/", start ); dir->leaf = dir->full + length + 1; } - LISTadd_last(EXPRESS_path, dir); + LISTadd_last( EXPRESS_path, dir ); - *(p - 1) = save; /* put char back where temp null was */ + *( p - 1 ) = save; /* put char back where temp null was */ } } } -static void EXPRESS_PATHfree(void) -{ - LISTdo(EXPRESS_path, dir, Dir *) - sc_free(dir); +static void EXPRESS_PATHfree( void ) { + LISTdo( EXPRESS_path, dir, Dir * ) + sc_free( dir ); LISTod - LISTfree(EXPRESS_path); + LISTfree( EXPRESS_path ); } /** inform object system about bit representation for handling pass diagnostics */ -void PASSinitialize() -{ +void PASSinitialize() { } /** Initialize the Express package. */ -void EXPRESSinitialize(void) -{ +void EXPRESSinitialize( void ) { MEMORYinitialize(); ERRORinitialize(); @@ -287,15 +279,14 @@ void EXPRESSinitialize(void) STMTinitialize(); SCANinitialize(); - + BUILTINSinitialize(); EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */ } /** Clean up the EXPRESS package. */ -void EXPRESScleanup(void) -{ +void EXPRESScleanup( void ) { EXPRESS_PATHfree(); DICTcleanup(); @@ -312,103 +303,101 @@ void EXPRESScleanup(void) ** \return resulting Working Form model ** Parse an Express source file into the Working Form. */ -void EXPRESSparse(Express model, FILE *fp, char *filename) -{ +void EXPRESSparse( Express model, FILE * fp, char * filename ) { yyexpresult = model; - if(!fp) { - fp = fopen(filename, "r"); + if( !fp ) { + fp = fopen( filename, "r" ); } - if(!fp) { + if( !fp ) { /* go down path looking for file */ - LISTdo(EXPRESS_path, dir, Dir *) - sprintf(dir->leaf, "%s", filename); - if(0 != (fp = fopen(dir->full, "r"))) { + LISTdo( EXPRESS_path, dir, Dir * ) + sprintf( dir->leaf, "%s", filename ); + if( 0 != ( fp = fopen( dir->full, "r" ) ) ) { filename = dir->full; break; } LISTod } - if(!fp) { - ERRORreport(FILE_UNREADABLE, filename, strerror(errno)); + if( !fp ) { + ERRORreport( FILE_UNREADABLE, filename, strerror( errno ) ); return; } - if(filename) { - char *dot = strrchr(filename, '.'); - char *slash = strrchr(filename, '/'); + if( filename ) { + char * dot = strrchr( filename, '.' ); + char * slash = strrchr( filename, '/' ); /* get beginning of basename */ - char *start = slash ? (slash + 1) : filename; + char * start = slash ? ( slash + 1 ) : filename; - int length = strlen(start); + int length = strlen( start ); /* drop .exp suffix if present */ - if(dot && !strcmp(dot, ".exp")) { + if( dot && !strcmp( dot, ".exp" ) ) { length -= 4; } - model->u.express->basename = (char *)sc_malloc(length + 1); - memcpy(model->u.express->basename, filename, length); + model->u.express->basename = ( char * )sc_malloc( length + 1 ); + memcpy( model->u.express->basename, filename, length ); model->u.express->basename[length] = '\0'; /* get new copy of filename to avoid being smashed */ /* by subsequent lookups on EXPRESS_path */ - model->u.express->filename = SCANstrdup(filename); + model->u.express->filename = SCANstrdup( filename ); filename = model->u.express->filename; } PARSEnew_schemas = LISTcreate(); - PARSERrun(filename, model->u.express->file = fp); + PARSERrun( filename, model->u.express->file = fp ); } /* TODO LEMON ought to put this in expparse.h */ void parserInitState(); /** start parsing a new schema file */ -static Express PARSERrun(char *filename, FILE *fp) -{ - extern void SCAN_lex_init(char *, FILE *); +static Express PARSERrun( char * filename, FILE * fp ) { + extern void SCAN_lex_init( char *, FILE * ); extern YYSTYPE yylval; extern int yyerrstatus; int tokenID; parse_data_t parseData; - void *parser = ParseAlloc(malloc); - perplex_t scanner = perplexFileScanner(fp); + void * parser = ParseAlloc( malloc ); + perplex_t scanner = perplexFileScanner( fp ); parseData.scanner = scanner; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "parse (pass %d)\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "parse (pass %d)\n", EXPRESSpass ); } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: %s (schema file)\n", filename); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "parse: %s (schema file)\n", filename ); } - SCAN_lex_init(filename, fp); + SCAN_lex_init( filename, fp ); parserInitState(); yyerrstatus = 0; /* NOTE uncomment the next line to enable parser tracing */ /* ParseTrace( stderr, "- expparse - " ); */ - while((tokenID = yylex(scanner)) > 0) { - Parse(parser, tokenID, yylval, parseData); + while( ( tokenID = yylex( scanner ) ) > 0 ) { + Parse( parser, tokenID, yylval, parseData ); } - Parse(parser, 0, yylval, parseData); + Parse( parser, 0, yylval, parseData ); /* want 0 on success, 1 on invalid input, 2 on memory exhaustion */ - if(yyerrstatus != 0) { - fprintf(stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus); - ERRORreport(BAIL_OUT); + if( yyerrstatus != 0 ) { + fprintf( stderr, ">> Bailing! (yyerrstatus = %d)\n", yyerrstatus ); + ERRORreport( BAIL_OUT ); /* free model and model->u.express */ return 0; } EXPRESSpass = 1; - perplexFree(scanner); - ParseFree(parser, free); + perplexFree( scanner ); + ParseFree( parser, free ); return yyexpresult; } @@ -420,42 +409,40 @@ static Express PARSERrun(char *filename, FILE *fp) * * Sept 2013 - remove unused param enum rename_type type (TODO should this be used)? */ -static void *SCOPEfind_for_rename(Scope schema, char *name) -{ +static void * SCOPEfind_for_rename( Scope schema, char * name ) { void *result; - Rename *rename; + Rename * rename; /* object can only appear in top level symbol table */ /* OR in another rename clause */ - result = DICTlookup(schema->symbol_table, name); - if(result) { + result = DICTlookup( schema->symbol_table, name ); + if( result ) { return result; } /* Occurs in a fully USE'd schema? */ - LISTdo(schema->u.schema->use_schemas, use_schema, Schema) { + LISTdo( schema->u.schema->use_schemas, use_schema, Schema ) { /* follow chain'd USEs */ - result = SCOPEfind_for_rename(use_schema, name); - if(result) { - return(result); + result = SCOPEfind_for_rename( use_schema, name ); + if( result ) { + return( result ); } - } - LISTod; + } LISTod; /* Occurs in a partially USE'd schema? */ - rename = (Rename *)DICTlookup(schema->u.schema->usedict, name); - if(rename) { - RENAMEresolve(rename, schema); + rename = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); + if( rename ) { + RENAMEresolve( rename, schema ); DICT_type = rename->type; - return(rename->object); + return( rename->object ); } - LISTdo(schema->u.schema->uselist, r, Rename *) - if(!strcmp((r->nnew ? r->nnew : r->old)->name, name)) { - RENAMEresolve(r, schema); + LISTdo( schema->u.schema->uselist, r, Rename * ) + if( !strcmp( ( r->nnew ? r->nnew : r->old )->name, name ) ) { + RENAMEresolve( r, schema ); DICT_type = r->type; - return(r->object); + return( r->object ); } LISTod; @@ -466,114 +453,111 @@ static void *SCOPEfind_for_rename(Scope schema, char *name) return 0; } -void RENAMEresolve(Rename *r, Schema s) -{ +void RENAMEresolve( Rename * r, Schema s ) { void *remote; /* if (is_resolved_rename_raw(r->old)) return;*/ - if(r->object) { + if( r->object ) { return; } - if(is_resolve_failed_raw(r->old)) { + if( is_resolve_failed_raw( r->old ) ) { return; } - if(is_resolve_in_progress_raw(r->old)) { - ERRORreport_with_symbol(CIRCULAR_REFERENCE, - r->old, r->old->name); - resolve_failed_raw(r->old); + if( is_resolve_in_progress_raw( r->old ) ) { + ERRORreport_with_symbol( CIRCULAR_REFERENCE, + r->old, r->old->name ); + resolve_failed_raw( r->old ); return; } - resolve_in_progress_raw(r->old); + resolve_in_progress_raw( r->old ); - remote = SCOPEfind_for_rename(r->schema, r->old->name); - if(remote == 0) { - ERRORreport_with_symbol(REF_NONEXISTENT, r->old, - r->old->name, r->schema->symbol.name); - resolve_failed_raw(r->old); + remote = SCOPEfind_for_rename( r->schema, r->old->name ); + if( remote == 0 ) { + ERRORreport_with_symbol( REF_NONEXISTENT, r->old, + r->old->name, r->schema->symbol.name ); + resolve_failed_raw( r->old ); } else { r->object = remote; r->type = DICT_type; - switch(r->rename_type) { + switch( r->rename_type ) { case use: - SCHEMAdefine_use(s, r); + SCHEMAdefine_use( s, r ); break; case ref: - SCHEMAdefine_reference(s, r); + SCHEMAdefine_reference( s, r ); break; } /* resolve_rename_raw(r->old);*/ } - resolve_not_in_progress_raw(r->old); + resolve_not_in_progress_raw( r->old ); } #ifdef using_enum_items_is_a_pain -static void RENAMEresolve_enum(Type t, Schema s) -{ +static void RENAMEresolve_enum( Type t, Schema s ) { DictionaryEntry de; Expression x; - DICTdo_type_init(t->symbol_table, &de, OBJ_EXPRESSION); - while(0 != (x = (Expression)DICTdo(&de))) { + DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); + while( 0 != ( x = ( Expression )DICTdo( &de ) ) ) { /* SCHEMAadd_use(s, v*/ /* raw(x->symbol.name);*/ } } #endif -Schema EXPRESSfind_schema(Dictionary modeldict, char *name) -{ +Schema EXPRESSfind_schema( Dictionary modeldict, char * name ) { Schema s; - FILE *fp; - char *src, *dest; + FILE * fp; + char * src, *dest; char lower[MAX_SCHEMA_FILENAME_SIZE]; /* avoid lowerizing original */ - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema reference)\n", - EXPRESSpass, name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema reference)\n", + EXPRESSpass, name ); } - s = (Schema)DICTlookup(modeldict, name); - if(s) { + s = ( Schema )DICTlookup( modeldict, name ); + if( s ) { return s; } dest = lower; - for(src = name; *src; src++) { - *dest++ = tolower(*src); + for( src = name; *src; src++ ) { + *dest++ = tolower( *src ); } *dest = '\0'; /* go down path looking for file */ - LISTdo(EXPRESS_path, dir, Dir *) - sprintf(dir->leaf, "%s.exp", lower); - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file?)\n", - EXPRESSpass, dir->full); - } - fp = fopen(dir->full, "r"); - if(fp) { + LISTdo( EXPRESS_path, dir, Dir * ) + sprintf( dir->leaf, "%s.exp", lower ); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file?)\n", + EXPRESSpass, dir->full ); + } + fp = fopen( dir->full, "r" ); + if( fp ) { Express express; - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file found)\n", - EXPRESSpass, dir->full); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file found)\n", + EXPRESSpass, dir->full ); } - express = PARSERrun(SCANstrdup(dir->full), fp); - if(express) { - s = (Schema)DICTlookup(modeldict, name); + express = PARSERrun( SCANstrdup( dir->full ), fp ); + if( express ) { + s = ( Schema )DICTlookup( modeldict, name ); } - if(s) { + if( s ) { return s; } - ERRORreport(SCHEMA_NOT_IN_OWN_SCHEMA_FILE, - name, dir->full); + ERRORreport( SCHEMA_NOT_IN_OWN_SCHEMA_FILE, + name, dir->full ); return 0; } else { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema file not found), errno = %d\n", EXPRESSpass, dir->full, errno ); } } LISTod @@ -587,20 +571,19 @@ Schema EXPRESSfind_schema(Dictionary modeldict, char *name) * because of partial schema references * \sa connect_schema_lists() */ -static void connect_lists(Dictionary modeldict, Schema schema, Linked_List list) -{ - Rename *r; +static void connect_lists( Dictionary modeldict, Schema schema, Linked_List list ) { + Rename * r; /* translate symbols to schemas */ - LISTdo_links(list, l) - r = (Rename *)l->data; - r->schema = EXPRESSfind_schema(modeldict, r->schema_sym->name); - if(!r->schema) { + LISTdo_links( list, l ) + r = ( Rename * )l->data; + r->schema = EXPRESSfind_schema( modeldict, r->schema_sym->name ); + if( !r->schema ) { ERRORreport_with_symbol(UNDEFINED_SCHEMA, - r->schema_sym, - r->schema_sym->name); - resolve_failed_raw(r->old); - resolve_failed(schema); + r->schema_sym, + r->schema_sym->name ); + resolve_failed_raw( r->old ); + resolve_failed( schema ); } LISTod } @@ -609,18 +592,17 @@ static void connect_lists(Dictionary modeldict, Schema schema, Linked_List list) * same as `connect_lists` except for full schemas * \sa connect_lists() */ -static void connect_schema_lists(Dictionary modeldict, Schema schema, Linked_List schema_list) -{ - Symbol *sym; +static void connect_schema_lists( Dictionary modeldict, Schema schema, Linked_List schema_list ) { + Symbol * sym; Schema ref_schema; /* translate symbols to schemas */ - LISTdo_links(schema_list, list) - sym = (Symbol *)list->data; - ref_schema = EXPRESSfind_schema(modeldict, sym->name); - if(!ref_schema) { - ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name); - resolve_failed(schema); + LISTdo_links( schema_list, list ) + sym = ( Symbol * )list->data; + ref_schema = EXPRESSfind_schema( modeldict, sym->name ); + if( !ref_schema ) { + ERRORreport_with_symbol(UNDEFINED_SCHEMA, sym, sym->name ); + resolve_failed( schema ); list->data = NULL; } else { list->data = ref_schema; @@ -632,8 +614,7 @@ static void connect_schema_lists(Dictionary modeldict, Schema schema, Linked_Lis ** \param model - Working Form model to resolve ** Perform symbol resolution on a loosely-coupled WF. */ -void EXPRESSresolve(Express model) -{ +void EXPRESSresolve( Express model ) { /* resolve multiple schemas. Schemas will be resolved here or when */ /* they are first encountered by a use/reference clause, whichever */ /* comes first - DEL */ @@ -642,14 +623,14 @@ void EXPRESSresolve(Express model) DictionaryEntry de; jmp_buf env; - if(setjmp(env)) { + if( setjmp( env ) ) { return; } - ERRORsafe(env); + ERRORsafe( env ); EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving schema references\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving schema references\n", EXPRESSpass ); } /* connect the real schemas to all the rename clauses */ @@ -659,59 +640,58 @@ void EXPRESSresolve(Express model) /* add news schemas to end, drop old ones off the front as we */ /* process them. */ - LISTdo(PARSEnew_schemas, print_schema, Schema) { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, print_schema->symbol.name); + LISTdo( PARSEnew_schemas, print_schema, Schema ) { + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, print_schema->symbol.name ); } - if(print_schema->u.schema->uselist) - connect_lists(model->symbol_table, - print_schema, print_schema->u.schema->uselist); - if(print_schema->u.schema->reflist) - connect_lists(model->symbol_table, - print_schema, print_schema->u.schema->reflist); + if( print_schema->u.schema->uselist ) + connect_lists( model->symbol_table, + print_schema, print_schema->u.schema->uselist ); + if( print_schema->u.schema->reflist ) + connect_lists( model->symbol_table, + print_schema, print_schema->u.schema->reflist ); - connect_schema_lists(model->symbol_table, - print_schema, print_schema->u.schema->use_schemas); - connect_schema_lists(model->symbol_table, - print_schema, print_schema->u.schema->ref_schemas); - } - LISTod; + connect_schema_lists( model->symbol_table, + print_schema, print_schema->u.schema->use_schemas ); + connect_schema_lists( model->symbol_table, + print_schema, print_schema->u.schema->ref_schemas ); + } LISTod; - LISTfree(PARSEnew_schemas); + LISTfree( PARSEnew_schemas ); PARSEnew_schemas = 0; /* just in case */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving objects references to other schemas\n", EXPRESSpass ); } /* connect the object in each rename clause to the real object */ - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name ); } /* do USE's first because they take precedence */ - if(schema->u.schema->uselist) { - LISTdo(schema->u.schema->uselist, r, Rename *) - RENAMEresolve(r, schema); + if( schema->u.schema->uselist ) { + LISTdo( schema->u.schema->uselist, r, Rename * ) + RENAMEresolve( r, schema ); LISTod; - LISTfree(schema->u.schema->uselist); + LISTfree( schema->u.schema->uselist ); schema->u.schema->uselist = 0; } - if(schema->u.schema->reflist) { - LISTdo(schema->u.schema->reflist, r, Rename *) - RENAMEresolve(r, schema); + if( schema->u.schema->reflist ) { + LISTdo( schema->u.schema->reflist, r, Rename * ) + RENAMEresolve( r, schema ); LISTod; - LISTfree(schema->u.schema->reflist); + LISTfree( schema->u.schema->reflist ); schema->u.schema->reflist = 0; } } @@ -719,29 +699,29 @@ void EXPRESSresolve(Express model) /* resolve sub- and supertype references. also resolve all */ /* defined types */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving sub and supertypes\n", EXPRESSpass ); } - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - SCOPEresolve_subsupers(schema); + SCOPEresolve_subsupers( schema ); } - if(ERRORoccurred) { + if( ERRORoccurred ) { ERRORunsafe(); } /* resolve types */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving types\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving types\n", EXPRESSpass ); } - SCOPEresolve_types(model); - if(ERRORoccurred) { + SCOPEresolve_types( model ); + if( ERRORoccurred ) { ERRORunsafe(); } @@ -750,57 +730,56 @@ void EXPRESSresolve(Express model) /* doesn't really deserve its own pass, but needs to come after */ /* type resolution */ EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving implied USE's\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving implied USE's\n", EXPRESSpass ); } - DICTdo_type_init(model->symbol_table, &de, OBJ_SCHEMA); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_not_resolvable(schema)) { + DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_not_resolvable( schema ) ) { continue; } - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "pass %d: %s (schema)\n", - EXPRESSpass, schema->symbol.name); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "pass %d: %s (schema)\n", + EXPRESSpass, schema->symbol.name ); } - if(schema->u.schema->usedict) { - DICTdo_init(schema->u.schema->usedict, &fg) - while(0 != (r = (Rename)DICTdo(&fg))) { - if((r->type = OBJ_TYPE) && ((Type)r->object)->body && - TYPEis_enumeration((Type)r->object)) { - RENAMEresolve_enum((Type)r->object, schema); + if( schema->u.schema->usedict ) { + DICTdo_init( schema->u.schema->usedict, &fg ) + while( 0 != ( r = ( Rename )DICTdo( &fg ) ) ) { + if( ( r->type = OBJ_TYPE ) && ( ( Type )r->object )->body && + TYPEis_enumeration( ( Type )r->object ) ) { + RENAMEresolve_enum( ( Type )r->object, schema ); } } } } - if(ERRORoccurred) { + if( ERRORoccurred ) { ERRORunsafe(); } #endif EXPRESSpass++; - if(print_objects_while_running & OBJ_PASS_BITS) { - fprintf(stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass); + if( print_objects_while_running & OBJ_PASS_BITS ) { + fprintf( stderr, "pass %d: resolving expressions and statements\n", EXPRESSpass ); } - SCOPEresolve_expressions_statements(model); - if(ERRORoccurred) { + SCOPEresolve_expressions_statements( model ); + if( ERRORoccurred ) { ERRORunsafe(); } /* mark everything resolved if possible */ - DICTdo_init(model->symbol_table, &de); - while(0 != (schema = (Schema)DICTdo(&de))) { - if(is_resolvable(schema)) { - resolved_all(schema); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) { + if( is_resolvable( schema ) ) { + resolved_all( schema ); } } } -Function funcdef(char *name, int pcount, Type ret_typ) -{ +Function funcdef(char *name, int pcount, Type ret_typ) { Function f = ALGcreate(OBJ_FUNCTION); f->symbol.name = name; f->u.func->pcount = pcount; @@ -811,8 +790,7 @@ Function funcdef(char *name, int pcount, Type ret_typ) return f; } -void procdef(char *name, int pcount) -{ +void procdef(char *name, int pcount) { Procedure p = ALGcreate(OBJ_PROCEDURE); p->symbol.name = name; p->u.proc->pcount = pcount; @@ -821,40 +799,39 @@ void procdef(char *name, int pcount) DICTdefine(EXPRESSbuiltins, name, p, 0, OBJ_PROCEDURE); } -void BUILTINSinitialize() -{ - EXPRESSbuiltins = DICTcreate(35); - procdef("INSERT", 3); - procdef("REMOVE", 2); - - funcdef("ABS", 1, Type_Number); - funcdef("ACOS", 1, Type_Real); - funcdef("ASIN", 1, Type_Real); - funcdef("ATAN", 2, Type_Real); - funcdef("BLENGTH", 1, Type_Integer); - funcdef("COS", 1, Type_Real); - funcdef("EXISTS", 1, Type_Boolean); - funcdef("EXP", 1, Type_Real); - funcdef("FORMAT", 2, Type_String); - funcdef("HIBOUND", 1, Type_Integer); - funcdef("HIINDEX", 1, Type_Integer); - funcdef("LENGTH", 1, Type_Integer); - funcdef("LOBOUND", 1, Type_Integer); - funcdef("LOG", 1, Type_Real); - funcdef("LOG10", 1, Type_Real); - funcdef("LOG2", 1, Type_Real); - funcdef("LOINDEX", 1, Type_Integer); - funcdef("ODD", 1, Type_Logical); - funcdef("ROLESOF", 1, Type_Set_Of_String); - funcdef("SIN", 1, Type_Real); - funcdef("SIZEOF", 1, Type_Integer); - funcdef("SQRT", 1, Type_Real); - funcdef("TAN", 1, Type_Real); - funcdef("TYPEOF", 1, Type_Set_Of_String); - funcdef("VALUE", 1, Type_Number); - funcdef("VALUE_IN", 2, Type_Logical); - funcdef("VALUE_UNIQUE", 1, Type_Logical); - - FUNC_NVL = funcdef("NVL", 2, Type_Generic); - FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic); +void BUILTINSinitialize() { + EXPRESSbuiltins = DICTcreate( 35 ); + procdef("INSERT", 3 ); + procdef("REMOVE", 2 ); + + funcdef("ABS", 1, Type_Number ); + funcdef("ACOS", 1, Type_Real ); + funcdef("ASIN", 1, Type_Real ); + funcdef("ATAN", 2, Type_Real ); + funcdef("BLENGTH", 1, Type_Integer ); + funcdef("COS", 1, Type_Real ); + funcdef("EXISTS", 1, Type_Boolean ); + funcdef("EXP", 1, Type_Real ); + funcdef("FORMAT", 2, Type_String ); + funcdef("HIBOUND", 1, Type_Integer ); + funcdef("HIINDEX", 1, Type_Integer ); + funcdef("LENGTH", 1, Type_Integer ); + funcdef("LOBOUND", 1, Type_Integer ); + funcdef("LOG", 1, Type_Real ); + funcdef("LOG10", 1, Type_Real ); + funcdef("LOG2", 1, Type_Real ); + funcdef("LOINDEX", 1, Type_Integer ); + funcdef("ODD", 1, Type_Logical ); + funcdef("ROLESOF", 1, Type_Set_Of_String ); + funcdef("SIN", 1, Type_Real ); + funcdef("SIZEOF", 1, Type_Integer ); + funcdef("SQRT", 1, Type_Real ); + funcdef("TAN", 1, Type_Real ); + funcdef("TYPEOF", 1, Type_Set_Of_String ); + funcdef("VALUE", 1, Type_Number ); + funcdef("VALUE_IN", 2, Type_Logical ); + funcdef("VALUE_UNIQUE", 1, Type_Logical ); + + FUNC_NVL = funcdef("NVL", 2, Type_Generic ); + FUNC_USEDIN = funcdef("USEDIN", 2, Type_Bag_Of_Generic ); } diff --git a/src/express/expscan.l b/src/express/expscan.l index cde644887..cbd56c535 100644 --- a/src/express/expscan.l +++ b/src/express/expscan.l @@ -118,11 +118,6 @@ static int nesting_level = 0; #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; -/* isascii isn't part of newer C standards */ -#ifndef isascii -# define isascii(c) ((unsigned)((c) + 1) < 129) -#endif - static_inline int SCANnextchar(char* buffer) diff --git a/src/express/factory.c b/src/express/factory.c index 0e739518c..daf6ee7d3 100644 --- a/src/express/factory.c +++ b/src/express/factory.c @@ -34,144 +34,138 @@ Type Type_Set_Of_String; Type Type_Set_Of_Generic; Type Type_Bag_Of_Generic; -void FACTORYinitialize() -{ +void FACTORYinitialize() { /* Very commonly-used read-only types */ - Type_Unknown = TYPEcreate(unknown_); - Type_Dont_Care = TYPEcreate(special_); - Type_Bad = TYPEcreate(special_); - Type_Runtime = TYPEcreate(runtime_); + Type_Unknown = TYPEcreate( unknown_ ); + Type_Dont_Care = TYPEcreate( special_ ); + Type_Bad = TYPEcreate( special_ ); + Type_Runtime = TYPEcreate( runtime_ ); - Type_Enumeration = TYPEcreate(enumeration_); + Type_Enumeration = TYPEcreate( enumeration_ ); Type_Enumeration->u.type->body->flags.shared = 1; - resolved_all(Type_Enumeration); + resolved_all( Type_Enumeration ); - Type_Expression = TYPEcreate(op_); + Type_Expression = TYPEcreate( op_ ); Type_Expression->u.type->body->flags.shared = 1; - Type_Aggregate = TYPEcreate(aggregate_); + Type_Aggregate = TYPEcreate( aggregate_ ); Type_Aggregate->u.type->body->flags.shared = 1; Type_Aggregate->u.type->body->base = Type_Runtime; - Type_Integer = TYPEcreate(integer_); + Type_Integer = TYPEcreate( integer_ ); Type_Integer->u.type->body->flags.shared = 1; - resolved_all(Type_Integer); + resolved_all( Type_Integer ); - Type_Real = TYPEcreate(real_); + Type_Real = TYPEcreate( real_ ); Type_Real->u.type->body->flags.shared = 1; - resolved_all(Type_Real); + resolved_all( Type_Real ); - Type_Number = TYPEcreate(number_); + Type_Number = TYPEcreate( number_ ); Type_Number->u.type->body->flags.shared = 1; - resolved_all(Type_Number); + resolved_all( Type_Number ); - Type_String = TYPEcreate(string_); + Type_String = TYPEcreate( string_ ); Type_String->u.type->body->flags.shared = 1; - resolved_all(Type_String); + resolved_all( Type_String ); - Type_String_Encoded = TYPEcreate(string_); + Type_String_Encoded = TYPEcreate( string_ ); Type_String_Encoded->u.type->body->flags.shared = 1; Type_String_Encoded->u.type->body->flags.encoded = 1; - resolved_all(Type_String); + resolved_all( Type_String ); - Type_Logical = TYPEcreate(logical_); + Type_Logical = TYPEcreate( logical_ ); Type_Logical->u.type->body->flags.shared = 1; - resolved_all(Type_Logical); + resolved_all( Type_Logical ); - Type_Binary = TYPEcreate(binary_); + Type_Binary = TYPEcreate( binary_ ); Type_Binary->u.type->body->flags.shared = 1; - resolved_all(Type_Binary); + resolved_all( Type_Binary ); - Type_Number = TYPEcreate(number_); + Type_Number = TYPEcreate( number_ ); Type_Number->u.type->body->flags.shared = 1; - resolved_all(Type_Number); + resolved_all( Type_Number ); - Type_Boolean = TYPEcreate(boolean_); + Type_Boolean = TYPEcreate( boolean_ ); Type_Boolean->u.type->body->flags.shared = 1; - resolved_all(Type_Boolean); + resolved_all( Type_Boolean ); - Type_Generic = TYPEcreate(generic_); + Type_Generic = TYPEcreate( generic_ ); Type_Generic->u.type->body->flags.shared = 1; - resolved_all(Type_Generic); + resolved_all( Type_Generic ); - Type_Set_Of_String = TYPEcreate(set_); + Type_Set_Of_String = TYPEcreate( set_ ); Type_Set_Of_String->u.type->body->flags.shared = 1; Type_Set_Of_String->u.type->body->base = Type_String; - Type_Set_Of_Generic = TYPEcreate(set_); + Type_Set_Of_Generic = TYPEcreate( set_ ); Type_Set_Of_Generic->u.type->body->flags.shared = 1; Type_Set_Of_Generic->u.type->body->base = Type_Generic; - Type_Bag_Of_Generic = TYPEcreate(bag_); + Type_Bag_Of_Generic = TYPEcreate( bag_ ); Type_Bag_Of_Generic->u.type->body->flags.shared = 1; Type_Bag_Of_Generic->u.type->body->base = Type_Generic; - Type_Attribute = TYPEcreate(attribute_); + Type_Attribute = TYPEcreate( attribute_ ); Type_Attribute->u.type->body->flags.shared = 1; - Type_Entity = TYPEcreate(entity_); + Type_Entity = TYPEcreate( entity_ ); Type_Entity->u.type->body->flags.shared = 1; - Type_Funcall = TYPEcreate(funcall_); + Type_Funcall = TYPEcreate( funcall_ ); Type_Funcall->u.type->body->flags.shared = 1; - Type_Generic = TYPEcreate(generic_); + Type_Generic = TYPEcreate( generic_ ); Type_Generic->u.type->body->flags.shared = 1; - Type_Identifier = TYPEcreate(identifier_); + Type_Identifier = TYPEcreate( identifier_ ); Type_Identifier->u.type->body->flags.shared = 1; - Type_Repeat = TYPEcreate(integer_); + Type_Repeat = TYPEcreate( integer_ ); Type_Repeat->u.type->body->flags.shared = 1; Type_Repeat->u.type->body->flags.repeat = 1; - Type_Oneof = TYPEcreate(oneof_); + Type_Oneof = TYPEcreate( oneof_ ); Type_Oneof->u.type->body->flags.shared = 1; - Type_Query = TYPEcreate(query_); + Type_Query = TYPEcreate( query_ ); Type_Query->u.type->body->flags.shared = 1; - Type_Self = TYPEcreate(self_); + Type_Self = TYPEcreate( self_ ); Type_Self->u.type->body->flags.shared = 1; } /** Create and return an empty scope inside a parent scope. */ -Scope SCOPEcreate(char type) -{ +Scope SCOPEcreate( char type ) { Scope d = SCOPE_new(); - d->symbol_table = DICTcreate(50); + d->symbol_table = DICTcreate( 50 ); d->type = type; return d; } -Scope SCOPEcreate_tiny(char type) -{ +Scope SCOPEcreate_tiny( char type ) { Scope d = SCOPE_new(); - d->symbol_table = DICTcreate(1); + d->symbol_table = DICTcreate( 1 ); d->type = type; return d; } -void SCOPEdestroy(Scope scope) -{ - SCOPE_destroy(scope); +void SCOPEdestroy( Scope scope ) { + SCOPE_destroy( scope ); } /** * create a scope without a symbol table * used for simple types */ -Scope SCOPEcreate_nostab(char type) -{ +Scope SCOPEcreate_nostab( char type ) { Scope d = SCOPE_new(); d->type = type; return d; } /** Create and return a schema. */ -Schema SCHEMAcreate(void) -{ - Scope s = SCOPEcreate(OBJ_SCHEMA); +Schema SCHEMAcreate( void ) { + Scope s = SCOPEcreate( OBJ_SCHEMA ); s->enum_table = DICTcreate(50); s->u.schema = SCHEMA_new(); return s; @@ -180,14 +174,13 @@ Schema SCHEMAcreate(void) /** * create a type with no symbol table */ -Type TYPEcreate_nostab(struct Symbol_ *symbol, Scope scope, char objtype) -{ - Type t = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_nostab( struct Symbol_ *symbol, Scope scope, char objtype ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->symbol = *symbol; - DICTdefine(scope->symbol_table, symbol->name, t, &t->symbol, objtype); + DICTdefine( scope->symbol_table, symbol->name, t, &t->symbol, objtype ); return t; } @@ -197,9 +190,8 @@ Type TYPEcreate_nostab(struct Symbol_ *symbol, Scope scope, char objtype) * such as enumerations (which have a symbol table added later) * or to be used as a type reference */ -Type TYPEcreate_name(Symbol *symbol) -{ - Scope s = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_name( Symbol * symbol ) { + Scope s = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead t = TYPEHEAD_new(); s->u.type = t; @@ -207,35 +199,31 @@ Type TYPEcreate_name(Symbol *symbol) return s; } -Type TYPEcreate(enum type_enum type) -{ - TypeBody tb = TYPEBODYcreate(type); - Type t = TYPEcreate_from_body_anonymously(tb); - return(t); +Type TYPEcreate( enum type_enum type ) { + TypeBody tb = TYPEBODYcreate( type ); + Type t = TYPEcreate_from_body_anonymously( tb ); + return( t ); } -Type TYPEcreate_from_body_anonymously(TypeBody tb) -{ - Type t = SCOPEcreate_nostab(OBJ_TYPE); +Type TYPEcreate_from_body_anonymously( TypeBody tb ) { + Type t = SCOPEcreate_nostab( OBJ_TYPE ); TypeHead th = TYPEHEAD_new(); t->u.type = th; t->u.type->body = tb; t->symbol.name = 0; - SYMBOLset(t); + SYMBOLset( t ); return t; } -TypeBody TYPEBODYcreate(enum type_enum type) -{ +TypeBody TYPEBODYcreate( enum type_enum type ) { TypeBody tb = TYPEBODY_new(); tb->type = type; return tb; } -Symbol *SYMBOLcreate(char *name, int line, const char *filename) -{ - Symbol *sym = SYMBOL_new(); +Symbol * SYMBOLcreate( char * name, int line, const char * filename ) { + Symbol * sym = SYMBOL_new(); sym->name = name; sym->line = line; sym->filename = filename; /* NOTE this used the global 'current_filename', @@ -254,19 +242,18 @@ Symbol *SYMBOLcreate(char *name, int line, const char *filename) ** empty list; all other aspects of the entity are initially ** undefined (i.e., have appropriate NULL values). */ -Entity ENTITYcreate(Symbol *sym) -{ - Scope s = SCOPEcreate(OBJ_ENTITY); +Entity ENTITYcreate( Symbol * sym ) { + Scope s = SCOPEcreate( OBJ_ENTITY ); s->u.entity = ENTITY_new(); s->u.entity->attributes = LISTcreate(); s->u.entity->inheritance = ENTITY_INHERITANCE_UNINITIALIZED; /* it's so useful to have a type hanging around for each entity */ - s->u.entity->type = TYPEcreate_name(sym); - s->u.entity->type->u.type->body = TYPEBODYcreate(entity_); + s->u.entity->type = TYPEcreate_name( sym ); + s->u.entity->type->u.type->body = TYPEBODYcreate( entity_ ); s->u.entity->type->u.type->body->entity = s; - return(s); + return( s ); } /** VARcreate @@ -279,39 +266,35 @@ Entity ENTITYcreate(Symbol *sym) ** dynamic. Special flags associated with the variable ** (e.g., optional) are initially false. */ -Variable VARcreate(Expression name, Type type) -{ +Variable VARcreate( Expression name, Type type ) { Variable v = VAR_new(); v->name = name; v->type = type; return v; } -Expression EXPcreate(Type type) -{ +Expression EXPcreate( Type type ) { Expression e; e = EXP_new(); - SYMBOLset(e); + SYMBOLset( e ); e->type = type; e->return_type = Type_Unknown; - return(e); + return( e ); } /** * use this when the return_type is the same as the type * For example, for constant integers */ -Expression EXPcreate_simple(Type type) -{ +Expression EXPcreate_simple( Type type ) { Expression e; e = EXP_new(); - SYMBOLset(e); + SYMBOLset( e ); e->type = e->return_type = type; - return(e); + return( e ); } -Expression EXPcreate_from_symbol(Type type, Symbol *symbol) -{ +Expression EXPcreate_from_symbol( Type type, Symbol * symbol ) { Expression e; e = EXP_new(); e->type = type; @@ -328,9 +311,8 @@ Expression EXPcreate_from_symbol(Type type, Symbol *symbol) ** \returns Ternary_Expression - the expression created ** Create a ternary operation Expression. */ -Expression TERN_EXPcreate(Op_Code op, Expression operand1, Expression operand2, Expression operand3) -{ - Expression e = EXPcreate(Type_Expression); +Expression TERN_EXPcreate( Op_Code op, Expression operand1, Expression operand2, Expression operand3 ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand1; @@ -347,9 +329,8 @@ Expression TERN_EXPcreate(Op_Code op, Expression operand1, Expression operand2, ** \returns Binary_Expression - the expression created ** Create a binary operation Expression. */ -Expression BIN_EXPcreate(Op_Code op, Expression operand1, Expression operand2) -{ - Expression e = EXPcreate(Type_Expression); +Expression BIN_EXPcreate( Op_Code op, Expression operand1, Expression operand2 ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand1; @@ -363,9 +344,8 @@ Expression BIN_EXPcreate(Op_Code op, Expression operand1, Expression operand2) ** \returns the expression created ** Create a unary operation Expression. */ -Expression UN_EXPcreate(Op_Code op, Expression operand) -{ - Expression e = EXPcreate(Type_Expression); +Expression UN_EXPcreate( Op_Code op, Expression operand ) { + Expression e = EXPcreate( Type_Expression ); e->e.op_code = op; e->e.op1 = operand; @@ -379,15 +359,14 @@ Expression UN_EXPcreate(Op_Code op, Expression operand) ** Create a query Expression. ** NOTE Dec 2011 - MP - function description did not match actual params. Had to guess. */ -Expression QUERYcreate(Symbol *local, Expression aggregate) -{ - Expression e = EXPcreate_from_symbol(Type_Query, local); - Scope s = SCOPEcreate_tiny(OBJ_QUERY); - Expression e2 = EXPcreate_from_symbol(Type_Attribute, local); +Expression QUERYcreate( Symbol * local, Expression aggregate ) { + Expression e = EXPcreate_from_symbol( Type_Query, local ); + Scope s = SCOPEcreate_tiny( OBJ_QUERY ); + Expression e2 = EXPcreate_from_symbol( Type_Attribute, local ); - Variable v = VARcreate(e2, Type_Attribute); + Variable v = VARcreate( e2, Type_Attribute ); - DICTdefine(s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE); + DICTdefine( s->symbol_table, local->name, v, &e2->symbol, OBJ_VARIABLE ); e->u.query = QUERY_new(); e->u.query->scope = s; e->u.query->local = v; diff --git a/src/express/fedex.c b/src/express/fedex.c index 9c03bcf99..805f8aeed 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -77,6 +77,7 @@ #include "sc_cf.h" #include "sc_memmgr.h" #include "sc_export.h" +#include "sc_version_string.h" #include "sc_getopt.h" #include "express/error.h" #include "express/express.h" @@ -90,17 +91,15 @@ extern int exp_yydebug; char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string because exp2cxx, exppp, etc may append their own options */ static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */ -void print_fedex_version(void) -{ - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, SC_VERSION); +void print_fedex_version( void ) { + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version ); no_need_to_work = 1; } -int main(int argc, char **argv) -{ +int main( int argc, char ** argv ) { int c; int rc; - char *cp; + char * cp; int no_warnings = 1; int resolve = 1; int result; @@ -115,27 +114,27 @@ int main(int argc, char **argv) EXPRESSinitialize(); - if(EXPRESSinit_args) { - (*EXPRESSinit_args)(argc, argv); + if( EXPRESSinit_args ) { + ( *EXPRESSinit_args )( argc, argv ); } sc_optind = 1; - while((c = sc_getopt(argc, argv, EXPRESSgetopt_options)) != -1) { - switch(c) { + while( ( c = sc_getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 ) { + switch( c ) { case 'd': ERRORdebugging = 1; - switch(atoi(sc_optarg)) { + switch( atoi( sc_optarg ) ) { case 0: - fprintf(stderr, "\ndebug codes:\n"); - fprintf(stderr, " 0 - this help\n"); - fprintf(stderr, " 1 - basic debugging\n"); + fprintf( stderr, "\ndebug codes:\n" ); + fprintf( stderr, " 0 - this help\n" ); + fprintf( stderr, " 1 - basic debugging\n" ); #ifdef debugging - fprintf(stderr, " 4 - light malloc debugging\n"); - fprintf(stderr, " 5 - heavy malloc debugging\n"); - fprintf(stderr, " 6 - heavy malloc debugging while resolving\n"); + fprintf( stderr, " 4 - light malloc debugging\n" ); + fprintf( stderr, " 5 - heavy malloc debugging\n" ); + fprintf( stderr, " 6 - heavy malloc debugging while resolving\n" ); #endif /* debugging*/ #ifdef YYDEBUG - fprintf(stderr, " 8 - set YYDEBUG\n"); + fprintf( stderr, " 8 - set YYDEBUG\n" ); #endif /*YYDEBUG*/ break; case 1: @@ -143,10 +142,10 @@ int main(int argc, char **argv) break; #ifdef debugging case 4: - malloc_debug(1); + malloc_debug( 1 ); break; case 5: - malloc_debug(2); + malloc_debug( 2 ); break; case 6: malloc_debug_resolve = 1; @@ -174,16 +173,16 @@ int main(int argc, char **argv) case 'i': case 'w': no_warnings = 0; - ERRORset_warning(sc_optarg, c == 'w'); + ERRORset_warning( sc_optarg, c == 'w' ); break; case 'p': - for(cp = sc_optarg; *cp; cp++) { - if(*cp == '#') { + for( cp = sc_optarg; *cp; cp++ ) { + if( *cp == '#' ) { print_objects_while_running |= OBJ_PASS_BITS; - } else if(*cp == 'E') { + } else if( *cp == 'E' ) { print_objects_while_running = OBJ_ANYTHING_BITS; } else { - print_objects_while_running |= OBJget_bits(*cp); + print_objects_while_running |= OBJget_bits( *cp ); } } break; @@ -193,12 +192,12 @@ int main(int argc, char **argv) break; default: rc = 1; - if(EXPRESSgetopt) { - rc = (*EXPRESSgetopt)(c, sc_optarg); + if( EXPRESSgetopt ) { + rc = ( *EXPRESSgetopt )( c, sc_optarg ); } - if(rc == 1) { - if(ERRORusage_function) { - (*ERRORusage_function)(); + if( rc == 1 ) { + if( ERRORusage_function ) { + ( *ERRORusage_function )(); } else { EXPRESSusage(1); } @@ -206,66 +205,66 @@ int main(int argc, char **argv) break; } } - if(!input_filename) { + if( !input_filename ) { input_filename = argv[sc_optind]; - if(!input_filename) { + if( !input_filename ) { EXPRESScleanup(); - if(no_need_to_work) { - return(0); + if( no_need_to_work ) { + return( 0 ); } else { - (*ERRORusage_function)(); + ( *ERRORusage_function )(); } } } - if(no_warnings) { - ERRORset_all_warnings(1); + if( no_warnings ) { + ERRORset_all_warnings( 1 ); } - ERRORbuffer_messages(buffer_messages); + ERRORbuffer_messages( buffer_messages ); - if(EXPRESSinit_parse) { - (*EXPRESSinit_parse)(); + if( EXPRESSinit_parse ) { + ( *EXPRESSinit_parse )(); } model = EXPRESScreate(); - EXPRESSparse(model, (FILE *)0, input_filename); - if(ERRORoccurred) { - result = EXPRESS_fail(model); + EXPRESSparse( model, ( FILE * )0, input_filename ); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } #ifdef debugging - if(malloc_debug_resolve) { + if( malloc_debug_resolve ) { malloc_verify(); - malloc_debug(2); + malloc_debug( 2 ); } #endif /*debugging*/ - if(resolve) { - EXPRESSresolve(model); - if(ERRORoccurred) { - result = EXPRESS_fail(model); + if( resolve ) { + EXPRESSresolve( model ); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } } - if(EXPRESSbackend) { - (*EXPRESSbackend)(model); + if( EXPRESSbackend ) { + ( *EXPRESSbackend )( model ); } - if(ERRORoccurred) { - result = EXPRESS_fail(model); + if( ERRORoccurred ) { + result = EXPRESS_fail( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } - result = EXPRESS_succeed(model); + result = EXPRESS_succeed( model ); EXPRESScleanup(); - EXPRESSdestroy(model); + EXPRESSdestroy( model ); return result; } diff --git a/src/express/generated/CMakeLists.txt b/src/express/generated/CMakeLists.txt new file mode 100644 index 000000000..53e9293be --- /dev/null +++ b/src/express/generated/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(.) + +add_library(objlib_expscan_c OBJECT expscan.c) +set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) + +add_library(objlib_expparse_c OBJECT expparse.c) +set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + diff --git a/src/express/generated/README b/src/express/generated/README index ccee594dd..7ca0ac13a 100644 --- a/src/express/generated/README +++ b/src/express/generated/README @@ -5,7 +5,8 @@ lexing and parsing logic. DO NOT EDIT THESE FILES. They are machine generated and should not be modified directly - bugs in these files need to be fixed in either the -Perplex/RE2C/Lemon input files or the tools themselves. +Perplex/RE2C/Lemon input files or the tools themselves. Directly changing +these files will result in a build failure. If changes need to be made, the correct approach is: @@ -13,4 +14,12 @@ If changes need to be made, the correct approach is: 2. make any necessary fixes to the input files and/or the generator tools. 3. run the build, and copy the new generated expscan and expparse c and h files to this directory. +4. run the build target "express_md5gen" to generate a new verification_info.cmake + file, and copy that file into this directory as well. +The verification_info.cmake file in this directory is used by CMake to protect +the integrity of the generated files. + +If iterative debugging is necessary, set the cmake configure variable +DEBUGGING_GENERATED_SOURCES to avoid having to update generated sources and md5 +sums each time an input file is changed. diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index bc97a5036..217c349d6 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -15,18 +15,18 @@ int yyerrstatus = 0; YYSTYPE yylval; -/* - * YACC grammar for Express parser. - * - * This software was developed by U.S. Government employees as part of - * their official duties and is not subject to copyright. - * - * $Log: expparse.y,v $ - * Revision 1.23 1997/11/14 17:09:04 libes - * allow multiple group references - * - * ** 22 older revision log records removed 3 January 2014 ** - */ + /* + * YACC grammar for Express parser. + * + * This software was developed by U.S. Government employees as part of + * their official duties and is not subject to copyright. + * + * $Log: expparse.y,v $ + * Revision 1.23 1997/11/14 17:09:04 libes + * allow multiple group references + * + * ** 22 older revision log records removed 3 January 2014 ** + */ #include "express/symbol.h" #include "express/linklist.h" @@ -38,9 +38,9 @@ YYSTYPE yylval; #include "expscan.h" #include -extern int print_objects_while_running; + extern int print_objects_while_running; -int tag_count; /**< use this to count tagged GENERIC types in the formal + int tag_count; /**< use this to count tagged GENERIC types in the formal * argument lists. Gross, but much easier to do it this * way then with the 'help' of yacc. Set it to -1 to * indicate that tags cannot be defined, only used @@ -50,46 +50,46 @@ int tag_count; /**< use this to count tagged GENERIC types in the formal * - snc */ -int local_var_count; /**< used to keep LOCAL variables in order + int local_var_count; /**< used to keep LOCAL variables in order * used in combination with Variable.offset */ -Express yyexpresult; /* hook to everything built by parser */ + Express yyexpresult; /* hook to everything built by parser */ -Symbol *interface_schema; /* schema of interest in use/ref clauses */ -void (*interface_func)(); /* func to attach rename clauses */ + Symbol *interface_schema; /* schema of interest in use/ref clauses */ + void (*interface_func)(); /* func to attach rename clauses */ -/* record schemas found in a single parse here, allowing them to be */ -/* differentiated from other schemas parsed earlier */ -Linked_List PARSEnew_schemas; + /* record schemas found in a single parse here, allowing them to be */ + /* differentiated from other schemas parsed earlier */ + Linked_List PARSEnew_schemas; -void SCANskip_to_end_schema(perplex_t scanner); + void SCANskip_to_end_schema(perplex_t scanner); -int yylineno; + int yylineno; -bool yyeof = false; + bool yyeof = false; #define MAX_SCOPE_DEPTH 20 /* max number of scopes that can be nested */ -static struct scope { - struct Scope_ *this_; - char type; /* one of OBJ_XXX */ - struct scope *pscope; /* pointer back to most recent scope */ - /* that has a printable name - for better */ - /* error messages */ -} scopes[MAX_SCOPE_DEPTH], *scope; + static struct scope { + struct Scope_ *this_; + char type; /* one of OBJ_XXX */ + struct scope *pscope; /* pointer back to most recent scope */ + /* that has a printable name - for better */ + /* error messages */ + } scopes[MAX_SCOPE_DEPTH], *scope; #define CURRENT_SCOPE (scope->this_) #define PREVIOUS_SCOPE ((scope-1)->this_) #define CURRENT_SCHEMA (scope->this_->u.schema) #define CURRENT_SCOPE_NAME (OBJget_symbol(scope->pscope->this_,scope->pscope->type)->name) #define CURRENT_SCOPE_TYPE_PRINTABLE (OBJget_type(scope->pscope->type)) -/* ths = new scope to enter */ -/* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ -/* are not named, in which case sym should be 0 */ -/* This is useful for when a diagnostic is printed, an earlier named */ -/* scoped can be used */ -/* typ = type of scope */ + /* ths = new scope to enter */ + /* sym = name of scope to enter into parent. Some scopes (i.e., increment) */ + /* are not named, in which case sym should be 0 */ + /* This is useful for when a diagnostic is printed, an earlier named */ + /* scoped can be used */ + /* typ = type of scope */ #define PUSH_SCOPE(ths,sym,typ) \ if (sym) DICTdefine(scope->this_->symbol_table,(sym)->name,(Generic)ths,sym,typ);\ ths->superscope = scope->this_; \ @@ -102,12 +102,12 @@ static struct scope { } #define POP_SCOPE() scope-- -/* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ -/* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ + /* PUSH_SCOPE_DUMMY just pushes the scope stack with nothing actually on it */ + /* Necessary for situations when a POP_SCOPE is unnecessary but inevitable */ #define PUSH_SCOPE_DUMMY() scope++ -/* normally the superscope is added by PUSH_SCOPE, but some things (types) */ -/* bother to get pushed so fix them this way */ + /* normally the superscope is added by PUSH_SCOPE, but some things (types) */ + /* bother to get pushed so fix them this way */ #define SCOPEadd_super(ths) ths->superscope = scope->this_; #define ERROR(code) ERRORreport(code, yylineno) @@ -127,10 +127,10 @@ void parserInitState() /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ -/* +/* ** These constants (all generated automatically by the parser generator) ** specify the various kinds of tokens (terminals) that the parser -** understands. +** understands. ** ** Each symbol here is a terminal symbol in the grammar. */ @@ -147,7 +147,7 @@ void parserInitState() ** and nonterminals. "int" is used otherwise. ** YYNOCODE is a number of type YYCODETYPE which corresponds ** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash +** number is used to fill in empty slots of the hash ** table. ** YYFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the @@ -156,7 +156,7 @@ void parserInitState() ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. -** ParseTOKENTYPE is the data type used for minor tokens given +** ParseTOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** YYMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of @@ -176,36 +176,36 @@ void parserInitState() #define YYCODETYPE unsigned short int #define YYNOCODE 280 #define YYACTIONTYPE unsigned short int -#define ParseTOKENTYPE YYSTYPE +#define ParseTOKENTYPE YYSTYPE typedef union { - int yyinit; - ParseTOKENTYPE yy0; - struct qualifier yy46; - Variable yy91; - Op_Code yy126; - struct entity_body yy176; - Where yy234; - struct subsuper_decl yy242; - struct type_flags yy252; - struct upper_lower yy253; - Symbol *yy275; - Type yy297; - Case_Item yy321; - Statement yy332; - Linked_List yy371; - struct type_either yy378; - struct subtypes yy385; - Expression yy401; - TypeBody yy477; - Integer yy507; + int yyinit; + ParseTOKENTYPE yy0; + struct qualifier yy46; + Variable yy91; + Op_Code yy126; + struct entity_body yy176; + Where yy234; + struct subsuper_decl yy242; + struct type_flags yy252; + struct upper_lower yy253; + Symbol* yy275; + Type yy297; + Case_Item yy321; + Statement yy332; + Linked_List yy371; + struct type_either yy378; + struct subtypes yy385; + Expression yy401; + TypeBody yy477; + Integer yy507; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 0 #endif #define ParseARG_SDECL parse_data_t parseData ; -#define ParseARG_PDECL , parse_data_t parseData -#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData -#define ParseARG_STORE yypParser->parseData = parseData +#define ParseARG_PDECL , parse_data_t parseData +#define ParseARG_FETCH parse_data_t parseData = yypParser->parseData +#define ParseARG_STORE yypParser->parseData = parseData #define YYNSTATE 645 #define YYNRULE 332 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) @@ -232,7 +232,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; /* Next are the tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an -** action integer. +** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows @@ -257,7 +257,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; ** If the index value yy_shift_ofst[S]+X is out of range or if the value ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. +** and that yy_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after @@ -278,691 +278,691 @@ static const YYMINORTYPE yyzerominor = { 0 }; */ #define YY_ACTTAB_COUNT (2659) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, - /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, - /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, - /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, - /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, - /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, - /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, - /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, - /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, - /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, - /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, - /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, - /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, - /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, - /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, - /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, - /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, - /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, - /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, - /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, - /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, - /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, - /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, - /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, - /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, - /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, - /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, - /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, - /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, - /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, - /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, - /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, - /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, - /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, - /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, - /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, - /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, - /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, - /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, - /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, - /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, - /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, - /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, - /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, - /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, - /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, - /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, - /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, - /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, - /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, - /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, - /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, - /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, - /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, - /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, - /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, - /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, - /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, - /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, - /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, - /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, - /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, - /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, - /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, - /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, - /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, - /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, - /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, - /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, - /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, - /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, - /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, - /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, - /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, - /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, - /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, - /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, - /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, - /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, - /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, - /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, - /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, - /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, - /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, - /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, - /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, - /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, - /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, - /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, - /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, - /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, - /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, - /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, - /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, - /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, - /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, - /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, - /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, - /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, - /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, - /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, - /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, - /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, - /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, - /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, - /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, - /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, - /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, - /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, - /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, - /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, - /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, - /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, - /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, - /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, - /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, - /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, - /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, - /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, - /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, - /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, - /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, - /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, - /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, - /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, - /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, - /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, - /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, - /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, - /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, - /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, - /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, - /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, - /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, - /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, - /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, - /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, - /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, - /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, - /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, - /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, - /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, - /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, - /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, - /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, - /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, - /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, - /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, - /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, - /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, - /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, - /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, - /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, - /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, - /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, - /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, - /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, - /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, - /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, - /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, - /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, - /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, - /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, - /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, - /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, - /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, - /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, - /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, - /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, - /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, - /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, - /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, - /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, - /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, - /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, - /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, - /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, - /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, - /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, - /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, - /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, - /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, - /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, - /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, - /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, - /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, - /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, - /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, - /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, - /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, - /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, - /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, - /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, - /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, - /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, - /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, - /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, - /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, - /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, - /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, - /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, - /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, - /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, - /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, - /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, - /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, - /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, - /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, - /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, - /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, - /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, - /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, - /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, - /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, - /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, - /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, - /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, - /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, - /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, - /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, - /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, - /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, - /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, - /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, - /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, - /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, - /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, - /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, - /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, - /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, - /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, - /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, - /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, - /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, - /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, - /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, - /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, - /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, - /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, - /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, + /* 0 */ 77, 78, 614, 67, 68, 45, 380, 71, 69, 70, + /* 10 */ 72, 248, 79, 74, 73, 16, 42, 583, 396, 395, + /* 20 */ 75, 483, 482, 388, 368, 599, 57, 56, 450, 602, + /* 30 */ 268, 597, 60, 35, 596, 379, 594, 598, 66, 89, + /* 40 */ 593, 44, 153, 158, 559, 619, 618, 113, 112, 569, + /* 50 */ 77, 78, 203, 550, 612, 168, 523, 249, 110, 613, + /* 60 */ 306, 15, 79, 611, 108, 16, 42, 175, 621, 606, + /* 70 */ 449, 525, 159, 388, 301, 378, 608, 607, 605, 604, + /* 80 */ 603, 405, 408, 183, 409, 179, 407, 169, 66, 387, + /* 90 */ 87, 978, 118, 403, 203, 619, 618, 113, 112, 401, + /* 100 */ 77, 78, 612, 544, 612, 60, 518, 244, 535, 613, + /* 110 */ 170, 611, 79, 611, 144, 16, 42, 549, 39, 606, + /* 120 */ 396, 395, 75, 388, 301, 82, 608, 607, 605, 604, + /* 130 */ 603, 524, 467, 454, 466, 469, 864, 465, 66, 387, + /* 140 */ 350, 468, 526, 234, 633, 619, 618, 396, 348, 75, + /* 150 */ 77, 78, 73, 132, 612, 467, 470, 466, 469, 613, + /* 160 */ 465, 311, 79, 611, 468, 16, 42, 346, 616, 606, + /* 170 */ 447, 122, 333, 388, 247, 224, 608, 607, 605, 604, + /* 180 */ 603, 467, 464, 466, 469, 550, 465, 550, 66, 387, + /* 190 */ 468, 227, 167, 113, 112, 619, 618, 113, 112, 557, + /* 200 */ 77, 78, 516, 346, 612, 467, 463, 466, 469, 613, + /* 210 */ 465, 39, 79, 611, 468, 16, 42, 359, 237, 606, + /* 220 */ 864, 122, 442, 312, 445, 615, 608, 607, 605, 604, + /* 230 */ 603, 367, 365, 361, 402, 731, 111, 545, 66, 387, + /* 240 */ 405, 209, 171, 373, 170, 619, 618, 337, 154, 549, + /* 250 */ 102, 549, 644, 251, 612, 777, 510, 334, 36, 613, + /* 260 */ 67, 68, 250, 611, 71, 69, 70, 72, 479, 606, + /* 270 */ 74, 73, 137, 144, 114, 344, 608, 607, 605, 604, + /* 280 */ 603, 589, 587, 590, 131, 585, 584, 588, 591, 387, + /* 290 */ 586, 67, 68, 514, 130, 71, 69, 70, 72, 609, + /* 300 */ 125, 74, 73, 777, 115, 154, 222, 620, 510, 23, + /* 310 */ 114, 473, 386, 510, 402, 496, 495, 494, 493, 492, + /* 320 */ 491, 490, 489, 488, 487, 2, 302, 512, 569, 322, + /* 330 */ 129, 318, 165, 373, 163, 623, 245, 243, 576, 575, + /* 340 */ 242, 240, 543, 527, 315, 451, 223, 29, 154, 215, + /* 350 */ 356, 236, 625, 19, 26, 626, 510, 3, 627, 632, + /* 360 */ 631, 521, 630, 629, 642, 162, 161, 343, 218, 5, + /* 370 */ 385, 286, 496, 495, 494, 493, 492, 491, 490, 489, + /* 380 */ 488, 487, 2, 71, 69, 70, 72, 129, 43, 74, + /* 390 */ 73, 431, 154, 355, 432, 430, 525, 433, 632, 631, + /* 400 */ 510, 630, 629, 41, 428, 39, 14, 204, 12, 134, + /* 410 */ 517, 13, 84, 107, 3, 496, 495, 494, 493, 492, + /* 420 */ 491, 490, 489, 488, 487, 2, 550, 612, 642, 429, + /* 430 */ 129, 642, 542, 520, 67, 68, 611, 304, 71, 69, + /* 440 */ 70, 72, 154, 298, 74, 73, 103, 335, 521, 40, + /* 450 */ 510, 39, 581, 63, 190, 521, 216, 3, 232, 496, + /* 460 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 470 */ 435, 67, 68, 335, 129, 71, 69, 70, 72, 91, + /* 480 */ 335, 74, 73, 434, 90, 154, 223, 354, 421, 580, + /* 490 */ 548, 640, 316, 510, 563, 559, 362, 641, 639, 638, + /* 500 */ 39, 3, 637, 636, 635, 634, 117, 229, 238, 496, + /* 510 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 520 */ 522, 121, 85, 521, 129, 185, 378, 519, 186, 154, + /* 530 */ 352, 401, 39, 309, 569, 331, 503, 510, 246, 164, + /* 540 */ 174, 623, 245, 243, 576, 575, 242, 240, 10, 349, + /* 550 */ 562, 3, 496, 495, 494, 493, 492, 491, 490, 489, + /* 560 */ 488, 487, 2, 330, 308, 551, 556, 129, 39, 628, + /* 570 */ 625, 173, 172, 626, 486, 100, 627, 632, 631, 154, + /* 580 */ 630, 629, 413, 362, 39, 182, 39, 510, 551, 425, + /* 590 */ 362, 202, 310, 98, 3, 520, 496, 495, 494, 493, + /* 600 */ 492, 491, 490, 489, 488, 487, 2, 135, 76, 377, + /* 610 */ 329, 129, 467, 462, 466, 469, 299, 465, 415, 297, + /* 620 */ 199, 468, 154, 376, 485, 375, 21, 558, 624, 625, + /* 630 */ 510, 560, 626, 529, 374, 627, 632, 631, 3, 630, + /* 640 */ 629, 120, 24, 126, 369, 140, 496, 495, 494, 493, + /* 650 */ 492, 491, 490, 489, 488, 487, 2, 529, 362, 14, + /* 660 */ 204, 129, 228, 353, 13, 378, 327, 351, 231, 53, + /* 670 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 14, + /* 680 */ 204, 57, 56, 230, 13, 402, 332, 60, 3, 496, + /* 690 */ 495, 494, 493, 492, 491, 490, 489, 488, 487, 2, + /* 700 */ 467, 461, 466, 469, 129, 465, 14, 204, 225, 468, + /* 710 */ 642, 13, 366, 188, 642, 315, 363, 444, 617, 364, + /* 720 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 730 */ 109, 3, 57, 56, 104, 360, 541, 106, 60, 515, + /* 740 */ 357, 221, 9, 20, 478, 477, 476, 601, 370, 27, + /* 750 */ 116, 220, 217, 212, 32, 637, 636, 635, 634, 117, + /* 760 */ 207, 18, 9, 20, 478, 477, 476, 347, 866, 206, + /* 770 */ 80, 25, 205, 342, 97, 637, 636, 635, 634, 117, + /* 780 */ 460, 201, 95, 160, 92, 336, 93, 198, 331, 9, + /* 790 */ 20, 478, 477, 476, 453, 197, 193, 192, 136, 426, + /* 800 */ 324, 187, 637, 636, 635, 634, 117, 189, 331, 323, + /* 810 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 820 */ 418, 321, 57, 56, 467, 459, 466, 469, 60, 465, + /* 830 */ 184, 416, 177, 468, 319, 331, 180, 176, 123, 58, + /* 840 */ 317, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 850 */ 50, 441, 8, 57, 56, 196, 11, 643, 642, 60, + /* 860 */ 143, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 870 */ 50, 325, 400, 57, 56, 39, 67, 68, 61, 60, + /* 880 */ 71, 69, 70, 72, 582, 622, 74, 73, 595, 21, + /* 890 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 900 */ 577, 574, 57, 56, 467, 458, 466, 469, 60, 465, + /* 910 */ 241, 573, 572, 468, 59, 239, 566, 578, 235, 53, + /* 920 */ 51, 54, 47, 49, 48, 52, 55, 46, 50, 37, + /* 930 */ 86, 57, 56, 119, 83, 569, 561, 60, 467, 457, + /* 940 */ 466, 469, 600, 465, 233, 141, 540, 468, 38, 105, + /* 950 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 960 */ 81, 533, 57, 56, 530, 115, 536, 539, 60, 359, + /* 970 */ 467, 456, 466, 469, 538, 465, 445, 537, 571, 468, + /* 980 */ 53, 51, 54, 47, 49, 48, 52, 55, 46, 50, + /* 990 */ 384, 599, 57, 56, 532, 602, 278, 597, 60, 253, + /* 1000 */ 596, 367, 594, 598, 531, 251, 593, 44, 153, 158, + /* 1010 */ 28, 528, 142, 254, 53, 51, 54, 47, 49, 48, + /* 1020 */ 52, 55, 46, 50, 137, 513, 57, 56, 508, 507, + /* 1030 */ 214, 506, 60, 27, 53, 51, 54, 47, 49, 48, + /* 1040 */ 52, 55, 46, 50, 505, 504, 57, 56, 4, 213, + /* 1050 */ 500, 498, 60, 497, 53, 51, 54, 47, 49, 48, + /* 1060 */ 52, 55, 46, 50, 208, 1, 57, 56, 484, 14, + /* 1070 */ 204, 480, 60, 244, 13, 467, 455, 466, 469, 472, + /* 1080 */ 465, 211, 446, 139, 468, 303, 452, 448, 99, 6, + /* 1090 */ 96, 53, 51, 54, 47, 49, 48, 52, 55, 46, + /* 1100 */ 50, 438, 195, 57, 56, 443, 252, 440, 194, 60, + /* 1110 */ 124, 439, 437, 436, 31, 191, 53, 51, 54, 47, + /* 1120 */ 49, 48, 52, 55, 46, 50, 599, 300, 57, 56, + /* 1130 */ 602, 427, 597, 326, 60, 596, 424, 594, 598, 17, + /* 1140 */ 423, 593, 44, 154, 157, 422, 420, 419, 417, 133, + /* 1150 */ 181, 510, 475, 20, 478, 477, 476, 414, 320, 412, + /* 1160 */ 411, 410, 406, 30, 154, 637, 636, 635, 634, 117, + /* 1170 */ 599, 178, 510, 521, 602, 151, 597, 88, 399, 596, + /* 1180 */ 404, 594, 598, 285, 547, 593, 44, 153, 158, 382, + /* 1190 */ 381, 546, 372, 371, 467, 200, 466, 469, 331, 465, + /* 1200 */ 534, 642, 338, 468, 499, 101, 22, 339, 244, 94, + /* 1210 */ 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, + /* 1220 */ 509, 467, 127, 466, 469, 129, 465, 340, 341, 138, + /* 1230 */ 468, 496, 495, 494, 493, 492, 491, 490, 489, 488, + /* 1240 */ 487, 481, 62, 383, 599, 520, 129, 610, 602, 278, + /* 1250 */ 597, 592, 244, 596, 512, 594, 598, 501, 471, 593, + /* 1260 */ 44, 153, 158, 555, 53, 51, 54, 47, 49, 48, + /* 1270 */ 52, 55, 46, 50, 553, 314, 57, 56, 554, 599, + /* 1280 */ 65, 511, 60, 602, 151, 597, 474, 64, 596, 328, + /* 1290 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 305, + /* 1300 */ 358, 521, 602, 276, 597, 979, 979, 596, 362, 594, + /* 1310 */ 598, 307, 979, 593, 44, 153, 158, 34, 979, 7, + /* 1320 */ 979, 979, 979, 979, 979, 979, 244, 979, 979, 219, + /* 1330 */ 612, 979, 979, 979, 570, 625, 979, 313, 626, 611, + /* 1340 */ 33, 627, 632, 631, 569, 630, 629, 979, 246, 979, + /* 1350 */ 174, 623, 245, 243, 576, 575, 242, 240, 979, 979, + /* 1360 */ 979, 244, 979, 979, 502, 979, 979, 979, 128, 979, + /* 1370 */ 166, 979, 979, 520, 979, 979, 642, 210, 979, 979, + /* 1380 */ 244, 173, 172, 552, 599, 979, 979, 979, 602, 261, + /* 1390 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1400 */ 44, 153, 158, 599, 979, 979, 521, 602, 579, 597, + /* 1410 */ 979, 979, 596, 979, 594, 598, 284, 979, 593, 44, + /* 1420 */ 153, 158, 599, 979, 979, 979, 602, 266, 597, 979, + /* 1430 */ 979, 596, 979, 594, 598, 979, 362, 593, 44, 153, + /* 1440 */ 158, 599, 979, 979, 979, 602, 265, 597, 979, 979, + /* 1450 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 1460 */ 979, 979, 979, 979, 979, 599, 244, 979, 979, 602, + /* 1470 */ 398, 597, 979, 979, 596, 979, 594, 598, 520, 979, + /* 1480 */ 593, 44, 153, 158, 599, 244, 979, 979, 602, 397, + /* 1490 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1500 */ 44, 153, 158, 979, 244, 979, 979, 979, 979, 599, + /* 1510 */ 979, 979, 979, 602, 296, 597, 979, 979, 596, 979, + /* 1520 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 1530 */ 979, 979, 602, 295, 597, 979, 979, 596, 979, 594, + /* 1540 */ 598, 362, 979, 593, 44, 153, 158, 244, 979, 979, + /* 1550 */ 979, 979, 979, 979, 979, 979, 599, 979, 979, 979, + /* 1560 */ 602, 294, 597, 979, 979, 596, 244, 594, 598, 979, + /* 1570 */ 979, 593, 44, 153, 158, 979, 979, 979, 599, 979, + /* 1580 */ 979, 979, 602, 293, 597, 979, 979, 596, 979, 594, + /* 1590 */ 598, 244, 979, 593, 44, 153, 158, 599, 979, 979, + /* 1600 */ 979, 602, 292, 597, 979, 979, 596, 979, 594, 598, + /* 1610 */ 244, 979, 593, 44, 153, 158, 599, 979, 979, 979, + /* 1620 */ 602, 291, 597, 979, 979, 596, 979, 594, 598, 979, + /* 1630 */ 979, 593, 44, 153, 158, 979, 979, 599, 244, 979, + /* 1640 */ 979, 602, 290, 597, 979, 979, 596, 979, 594, 598, + /* 1650 */ 979, 979, 593, 44, 153, 158, 979, 979, 979, 979, + /* 1660 */ 244, 979, 979, 979, 979, 599, 979, 979, 979, 602, + /* 1670 */ 289, 597, 979, 979, 596, 979, 594, 598, 979, 244, + /* 1680 */ 593, 44, 153, 158, 599, 979, 979, 979, 602, 288, + /* 1690 */ 597, 979, 979, 596, 979, 594, 598, 979, 244, 593, + /* 1700 */ 44, 153, 158, 979, 979, 979, 599, 979, 979, 979, + /* 1710 */ 602, 287, 597, 979, 979, 596, 979, 594, 598, 244, + /* 1720 */ 979, 593, 44, 153, 158, 599, 979, 979, 979, 602, + /* 1730 */ 277, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1740 */ 593, 44, 153, 158, 599, 979, 979, 244, 602, 264, + /* 1750 */ 597, 979, 979, 596, 979, 594, 598, 979, 979, 593, + /* 1760 */ 44, 153, 158, 979, 979, 599, 244, 979, 979, 602, + /* 1770 */ 263, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 1780 */ 593, 44, 153, 158, 979, 979, 979, 979, 244, 979, + /* 1790 */ 979, 979, 979, 599, 979, 979, 979, 602, 262, 597, + /* 1800 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 1810 */ 153, 158, 599, 979, 979, 979, 602, 275, 597, 979, + /* 1820 */ 979, 596, 979, 594, 598, 979, 244, 593, 44, 153, + /* 1830 */ 158, 979, 979, 979, 599, 979, 979, 979, 602, 274, + /* 1840 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 1850 */ 44, 153, 158, 599, 979, 979, 979, 602, 260, 597, + /* 1860 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1870 */ 153, 158, 599, 979, 979, 244, 602, 259, 597, 979, + /* 1880 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 153, + /* 1890 */ 158, 979, 979, 599, 244, 979, 979, 602, 273, 597, + /* 1900 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 1910 */ 153, 158, 979, 979, 979, 979, 244, 979, 979, 979, + /* 1920 */ 979, 599, 979, 979, 979, 602, 150, 597, 979, 979, + /* 1930 */ 596, 979, 594, 598, 979, 244, 593, 44, 153, 158, + /* 1940 */ 599, 979, 979, 979, 602, 149, 597, 979, 979, 596, + /* 1950 */ 979, 594, 598, 979, 244, 593, 44, 153, 158, 979, + /* 1960 */ 979, 979, 599, 979, 979, 979, 602, 258, 597, 979, + /* 1970 */ 979, 596, 979, 594, 598, 244, 979, 593, 44, 153, + /* 1980 */ 158, 599, 979, 979, 979, 602, 257, 597, 979, 979, + /* 1990 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2000 */ 599, 979, 979, 244, 602, 256, 597, 979, 979, 596, + /* 2010 */ 979, 594, 598, 979, 979, 593, 44, 153, 158, 979, + /* 2020 */ 979, 599, 244, 979, 979, 602, 148, 597, 979, 979, + /* 2030 */ 596, 979, 594, 598, 979, 979, 593, 44, 153, 158, + /* 2040 */ 979, 979, 979, 979, 244, 979, 979, 979, 979, 599, + /* 2050 */ 979, 979, 979, 602, 272, 597, 979, 979, 596, 979, + /* 2060 */ 594, 598, 979, 244, 593, 44, 153, 158, 599, 979, + /* 2070 */ 979, 979, 602, 255, 597, 979, 979, 596, 979, 594, + /* 2080 */ 598, 979, 244, 593, 44, 153, 158, 979, 979, 979, + /* 2090 */ 599, 979, 979, 979, 602, 271, 597, 979, 979, 596, + /* 2100 */ 979, 594, 598, 244, 979, 593, 44, 153, 158, 599, + /* 2110 */ 979, 979, 979, 602, 270, 597, 979, 979, 596, 979, + /* 2120 */ 594, 598, 979, 979, 593, 44, 153, 158, 599, 979, + /* 2130 */ 979, 244, 602, 269, 597, 979, 979, 596, 979, 594, + /* 2140 */ 598, 979, 979, 593, 44, 153, 158, 979, 979, 599, + /* 2150 */ 244, 979, 979, 602, 147, 597, 979, 979, 596, 979, + /* 2160 */ 594, 598, 979, 979, 593, 44, 153, 158, 979, 979, + /* 2170 */ 979, 979, 244, 979, 979, 979, 979, 599, 305, 358, + /* 2180 */ 979, 602, 267, 597, 979, 979, 596, 979, 594, 598, + /* 2190 */ 979, 244, 593, 44, 153, 158, 34, 979, 7, 979, + /* 2200 */ 979, 979, 979, 979, 979, 979, 979, 979, 219, 612, + /* 2210 */ 244, 599, 979, 979, 979, 602, 979, 597, 611, 33, + /* 2220 */ 596, 979, 594, 598, 979, 979, 593, 44, 279, 158, + /* 2230 */ 979, 244, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2240 */ 979, 979, 979, 502, 979, 979, 599, 128, 979, 166, + /* 2250 */ 602, 979, 597, 979, 979, 596, 210, 594, 598, 244, + /* 2260 */ 979, 593, 44, 394, 158, 599, 979, 979, 979, 602, + /* 2270 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2280 */ 593, 44, 393, 158, 979, 979, 599, 979, 979, 979, + /* 2290 */ 602, 979, 597, 244, 979, 596, 979, 594, 598, 979, + /* 2300 */ 979, 593, 44, 392, 158, 599, 979, 979, 979, 602, + /* 2310 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2320 */ 593, 44, 391, 158, 979, 979, 599, 979, 244, 979, + /* 2330 */ 602, 979, 597, 979, 979, 596, 979, 594, 598, 979, + /* 2340 */ 979, 593, 44, 390, 158, 599, 979, 244, 979, 602, + /* 2350 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2360 */ 593, 44, 389, 158, 979, 979, 979, 979, 244, 979, + /* 2370 */ 979, 979, 979, 979, 599, 979, 979, 979, 602, 979, + /* 2380 */ 597, 979, 979, 596, 979, 594, 598, 244, 979, 593, + /* 2390 */ 44, 283, 158, 979, 979, 568, 625, 979, 979, 626, + /* 2400 */ 979, 979, 627, 632, 631, 599, 630, 629, 244, 602, + /* 2410 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2420 */ 593, 44, 282, 158, 979, 599, 979, 244, 979, 602, + /* 2430 */ 979, 597, 979, 979, 596, 979, 594, 598, 979, 979, + /* 2440 */ 593, 44, 146, 158, 979, 979, 979, 979, 599, 979, + /* 2450 */ 979, 979, 602, 979, 597, 979, 244, 596, 979, 594, + /* 2460 */ 598, 979, 979, 593, 44, 145, 158, 979, 979, 979, + /* 2470 */ 979, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2480 */ 979, 979, 596, 979, 594, 598, 979, 244, 593, 44, + /* 2490 */ 152, 158, 567, 625, 979, 979, 626, 979, 979, 627, + /* 2500 */ 632, 631, 599, 630, 629, 979, 602, 244, 597, 979, + /* 2510 */ 979, 596, 979, 594, 598, 979, 979, 593, 44, 280, + /* 2520 */ 158, 979, 979, 979, 979, 979, 979, 979, 979, 979, + /* 2530 */ 244, 979, 979, 599, 979, 979, 979, 602, 979, 597, + /* 2540 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2550 */ 281, 158, 979, 599, 979, 244, 979, 602, 979, 597, + /* 2560 */ 979, 979, 596, 979, 594, 598, 979, 979, 593, 44, + /* 2570 */ 599, 156, 979, 979, 602, 979, 597, 979, 979, 596, + /* 2580 */ 979, 594, 598, 979, 244, 593, 44, 979, 155, 979, + /* 2590 */ 565, 625, 979, 979, 626, 979, 979, 627, 632, 631, + /* 2600 */ 979, 630, 629, 979, 979, 979, 979, 979, 979, 979, + /* 2610 */ 979, 979, 979, 979, 979, 244, 564, 625, 979, 979, + /* 2620 */ 626, 979, 979, 627, 632, 631, 979, 630, 629, 226, + /* 2630 */ 625, 979, 979, 626, 979, 244, 627, 632, 631, 979, + /* 2640 */ 630, 629, 979, 979, 979, 979, 345, 625, 979, 979, + /* 2650 */ 626, 979, 244, 627, 632, 631, 979, 630, 629, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, - /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, - /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, - /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, - /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, - /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, - /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, - /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, - /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, - /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, - /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, - /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, - /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, - /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, - /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, - /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, - /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, - /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, - /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, - /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, - /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, - /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, - /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, - /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, - /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, - /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, - /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, - /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, - /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, - /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, - /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, - /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, - /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, - /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, - /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, - /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, - /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, - /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, - /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, - /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, - /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, - /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, - /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, - /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, - /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, - /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, - /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, - /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, - /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, - /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, - /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, - /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, - /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, - /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, - /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, - /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, - /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, - /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, - /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, - /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, - /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, - /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, - /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, - /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, - /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, - /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, - /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, - /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, - /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, - /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, - /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, - /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, - /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, - /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, - /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, - /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, - /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, - /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, - /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, - /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, - /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, - /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, - /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, - /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, - /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, - /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, - /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, - /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, - /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, - /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, - /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, - /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, - /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, - /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, - /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, - /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, - /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, - /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, - /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, - /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, - /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, - /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, - /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, - /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, - /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, - /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, - /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, - /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, - /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, - /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, - /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, - /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, - /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, - /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, - /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, - /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, - /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, - /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, - /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, - /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, - /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, - /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, - /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, - /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, - /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, - /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, - /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, - /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, - /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, - /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, - /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, - /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, - /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, - /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, - /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, - /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, - /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, - /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, - /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, - /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, - /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, - /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, - /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, - /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, - /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, - /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, - /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, - /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, - /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, - /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, - /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, - /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, - /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, - /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, - /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, - /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, - /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, - /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, - /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, - /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, - /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, - /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, - /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, - /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, - /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, - /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, - /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, - /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, - /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, - /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, - /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, - /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, - /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, - /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, - /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, - /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, - /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, - /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, - /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, - /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, - /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, - /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, - /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, - /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, - /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, - /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, - /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, - /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, - /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, - /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, - /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, - /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, - /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, - /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, - /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, - /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, - /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, - /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, - /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, - /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, - /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, - /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, - /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, - /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, - /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, - /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, - /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, - /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, - /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, - /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, - /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, - /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, - /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, - /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, - /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, - /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, - /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, - /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, - /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, + /* 0 */ 11, 12, 28, 11, 12, 31, 66, 15, 16, 17, + /* 10 */ 18, 80, 23, 21, 22, 26, 27, 28, 24, 25, + /* 20 */ 26, 123, 124, 34, 125, 127, 13, 14, 167, 131, + /* 30 */ 132, 133, 19, 39, 136, 95, 138, 139, 49, 30, + /* 40 */ 142, 143, 144, 145, 34, 56, 57, 19, 20, 34, + /* 50 */ 11, 12, 191, 129, 65, 40, 28, 235, 159, 70, + /* 60 */ 162, 239, 23, 74, 27, 26, 27, 33, 29, 80, + /* 70 */ 167, 34, 169, 34, 170, 65, 87, 88, 89, 90, + /* 80 */ 91, 241, 260, 261, 262, 263, 264, 72, 49, 100, + /* 90 */ 33, 251, 252, 253, 191, 56, 57, 19, 20, 129, + /* 100 */ 11, 12, 65, 179, 65, 19, 28, 209, 129, 70, + /* 110 */ 186, 74, 23, 74, 274, 26, 27, 193, 26, 80, + /* 120 */ 24, 25, 26, 34, 170, 33, 87, 88, 89, 90, + /* 130 */ 91, 94, 212, 213, 214, 215, 27, 217, 49, 100, + /* 140 */ 51, 221, 174, 164, 165, 56, 57, 24, 25, 26, + /* 150 */ 11, 12, 22, 183, 65, 212, 213, 214, 215, 70, + /* 160 */ 217, 182, 23, 74, 221, 26, 27, 136, 34, 80, + /* 170 */ 168, 267, 268, 34, 206, 207, 87, 88, 89, 90, + /* 180 */ 91, 212, 213, 214, 215, 129, 217, 129, 49, 100, + /* 190 */ 221, 30, 31, 19, 20, 56, 57, 19, 20, 229, + /* 200 */ 11, 12, 28, 136, 65, 212, 213, 214, 215, 70, + /* 210 */ 217, 26, 23, 74, 221, 26, 27, 62, 33, 80, + /* 220 */ 111, 267, 268, 34, 69, 34, 87, 88, 89, 90, + /* 230 */ 91, 113, 114, 115, 79, 0, 178, 179, 49, 100, + /* 240 */ 241, 148, 186, 129, 186, 56, 57, 30, 128, 193, + /* 250 */ 33, 193, 253, 98, 65, 27, 136, 255, 30, 70, + /* 260 */ 11, 12, 107, 74, 15, 16, 17, 18, 135, 80, + /* 270 */ 21, 22, 117, 274, 243, 244, 87, 88, 89, 90, + /* 280 */ 91, 1, 2, 3, 31, 5, 6, 7, 8, 100, + /* 290 */ 10, 11, 12, 173, 180, 15, 16, 17, 18, 50, + /* 300 */ 128, 21, 22, 27, 58, 128, 134, 29, 136, 31, + /* 310 */ 243, 244, 27, 136, 79, 195, 196, 197, 198, 199, + /* 320 */ 200, 201, 202, 203, 204, 205, 32, 194, 34, 83, + /* 330 */ 210, 85, 38, 129, 40, 41, 42, 43, 44, 45, + /* 340 */ 46, 47, 228, 28, 109, 28, 31, 27, 128, 256, + /* 350 */ 173, 211, 212, 30, 31, 215, 136, 237, 218, 219, + /* 360 */ 220, 136, 222, 223, 111, 71, 72, 73, 77, 78, + /* 370 */ 34, 146, 195, 196, 197, 198, 199, 200, 201, 202, + /* 380 */ 203, 204, 205, 15, 16, 17, 18, 210, 101, 21, + /* 390 */ 22, 212, 128, 173, 215, 216, 34, 218, 219, 220, + /* 400 */ 136, 222, 223, 30, 225, 26, 149, 150, 151, 152, + /* 410 */ 28, 154, 33, 31, 237, 195, 196, 197, 198, 199, + /* 420 */ 200, 201, 202, 203, 204, 205, 129, 65, 111, 250, + /* 430 */ 210, 111, 228, 208, 11, 12, 74, 173, 15, 16, + /* 440 */ 17, 18, 128, 185, 21, 22, 30, 31, 136, 30, + /* 450 */ 136, 26, 29, 30, 275, 136, 157, 237, 33, 195, + /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 470 */ 28, 11, 12, 31, 210, 15, 16, 17, 18, 30, + /* 480 */ 31, 21, 22, 28, 265, 128, 31, 173, 230, 29, + /* 490 */ 193, 234, 273, 136, 95, 34, 271, 240, 241, 242, + /* 500 */ 26, 237, 245, 246, 247, 248, 249, 33, 33, 195, + /* 510 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 520 */ 208, 60, 33, 136, 210, 28, 65, 208, 31, 128, + /* 530 */ 173, 129, 26, 146, 34, 278, 237, 136, 38, 33, + /* 540 */ 40, 41, 42, 43, 44, 45, 46, 47, 160, 161, + /* 550 */ 66, 237, 195, 196, 197, 198, 199, 200, 201, 202, + /* 560 */ 203, 204, 205, 63, 177, 175, 176, 210, 26, 211, + /* 570 */ 212, 71, 72, 215, 173, 33, 218, 219, 220, 128, + /* 580 */ 222, 223, 28, 271, 26, 31, 26, 136, 175, 176, + /* 590 */ 271, 33, 171, 33, 237, 208, 195, 196, 197, 198, + /* 600 */ 199, 200, 201, 202, 203, 204, 205, 276, 277, 25, + /* 610 */ 110, 210, 212, 213, 214, 215, 171, 217, 257, 258, + /* 620 */ 140, 221, 128, 34, 173, 24, 27, 34, 211, 212, + /* 630 */ 136, 229, 215, 212, 34, 218, 219, 220, 237, 222, + /* 640 */ 223, 30, 39, 30, 36, 27, 195, 196, 197, 198, + /* 650 */ 199, 200, 201, 202, 203, 204, 205, 212, 271, 149, + /* 660 */ 150, 210, 34, 34, 154, 65, 156, 173, 33, 1, + /* 670 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 149, + /* 680 */ 150, 13, 14, 33, 154, 79, 156, 19, 237, 195, + /* 690 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 700 */ 212, 213, 214, 215, 210, 217, 149, 150, 61, 221, + /* 710 */ 111, 154, 33, 156, 111, 109, 33, 237, 50, 115, + /* 720 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 730 */ 27, 237, 13, 14, 27, 33, 212, 27, 19, 34, + /* 740 */ 34, 37, 232, 233, 234, 235, 236, 28, 224, 120, + /* 750 */ 36, 55, 77, 104, 39, 245, 246, 247, 248, 249, + /* 760 */ 104, 30, 232, 233, 234, 235, 236, 34, 111, 53, + /* 770 */ 30, 39, 59, 30, 33, 245, 246, 247, 248, 249, + /* 780 */ 34, 33, 33, 33, 30, 34, 33, 93, 278, 232, + /* 790 */ 233, 234, 235, 236, 34, 97, 116, 33, 27, 1, + /* 800 */ 34, 106, 245, 246, 247, 248, 249, 68, 278, 36, + /* 810 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 820 */ 27, 84, 13, 14, 212, 213, 214, 215, 19, 217, + /* 830 */ 34, 34, 108, 221, 82, 278, 34, 34, 269, 30, + /* 840 */ 84, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 850 */ 10, 270, 238, 13, 14, 155, 239, 237, 111, 19, + /* 860 */ 237, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 870 */ 10, 153, 227, 13, 14, 26, 11, 12, 27, 19, + /* 880 */ 15, 16, 17, 18, 157, 141, 21, 22, 28, 27, + /* 890 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 900 */ 141, 189, 13, 14, 212, 213, 214, 215, 19, 217, + /* 910 */ 141, 96, 189, 221, 49, 141, 95, 28, 137, 1, + /* 920 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 39, + /* 930 */ 192, 13, 14, 86, 192, 34, 237, 19, 212, 213, + /* 940 */ 214, 215, 102, 217, 181, 184, 212, 221, 30, 95, + /* 950 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 960 */ 190, 66, 13, 14, 174, 58, 237, 212, 19, 62, + /* 970 */ 212, 213, 214, 215, 212, 217, 69, 212, 29, 221, + /* 980 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 990 */ 126, 127, 13, 14, 237, 131, 132, 133, 19, 92, + /* 1000 */ 136, 113, 138, 139, 237, 98, 142, 143, 144, 145, + /* 1010 */ 118, 212, 33, 237, 1, 2, 3, 4, 5, 6, + /* 1020 */ 7, 8, 9, 10, 117, 237, 13, 14, 237, 237, + /* 1030 */ 148, 237, 19, 120, 1, 2, 3, 4, 5, 6, + /* 1040 */ 7, 8, 9, 10, 237, 237, 13, 14, 237, 147, + /* 1050 */ 237, 237, 19, 237, 1, 2, 3, 4, 5, 6, + /* 1060 */ 7, 8, 9, 10, 147, 237, 13, 14, 237, 149, + /* 1070 */ 150, 237, 19, 209, 154, 212, 213, 214, 215, 237, + /* 1080 */ 217, 28, 34, 254, 221, 170, 34, 237, 192, 76, + /* 1090 */ 192, 1, 2, 3, 4, 5, 6, 7, 8, 9, + /* 1100 */ 10, 34, 272, 13, 14, 237, 237, 237, 168, 19, + /* 1110 */ 27, 237, 237, 172, 81, 27, 1, 2, 3, 4, + /* 1120 */ 5, 6, 7, 8, 9, 10, 127, 170, 13, 14, + /* 1130 */ 131, 237, 133, 175, 19, 136, 237, 138, 139, 119, + /* 1140 */ 237, 142, 143, 128, 145, 34, 230, 237, 237, 27, + /* 1150 */ 259, 136, 232, 233, 234, 235, 236, 257, 34, 237, + /* 1160 */ 237, 237, 237, 48, 128, 245, 246, 247, 248, 249, + /* 1170 */ 127, 259, 136, 136, 131, 132, 133, 188, 227, 136, + /* 1180 */ 237, 138, 139, 146, 237, 142, 143, 144, 145, 227, + /* 1190 */ 227, 237, 227, 227, 212, 213, 214, 215, 278, 217, + /* 1200 */ 129, 111, 227, 221, 237, 188, 163, 227, 209, 188, + /* 1210 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 1220 */ 205, 212, 213, 214, 215, 210, 217, 227, 227, 237, + /* 1230 */ 221, 195, 196, 197, 198, 199, 200, 201, 202, 203, + /* 1240 */ 204, 205, 226, 126, 127, 208, 210, 266, 131, 132, + /* 1250 */ 133, 194, 209, 136, 194, 138, 139, 130, 67, 142, + /* 1260 */ 143, 144, 145, 237, 1, 2, 3, 4, 5, 6, + /* 1270 */ 7, 8, 9, 10, 231, 158, 13, 14, 237, 127, + /* 1280 */ 187, 237, 19, 131, 132, 133, 237, 187, 136, 34, + /* 1290 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 34, + /* 1300 */ 35, 136, 131, 132, 133, 279, 279, 136, 271, 138, + /* 1310 */ 139, 146, 279, 142, 143, 144, 145, 52, 279, 54, + /* 1320 */ 279, 279, 279, 279, 279, 279, 209, 279, 279, 64, + /* 1330 */ 65, 279, 279, 279, 211, 212, 279, 166, 215, 74, + /* 1340 */ 75, 218, 219, 220, 34, 222, 223, 279, 38, 279, + /* 1350 */ 40, 41, 42, 43, 44, 45, 46, 47, 279, 279, + /* 1360 */ 279, 209, 279, 279, 99, 279, 279, 279, 103, 279, + /* 1370 */ 105, 279, 279, 208, 279, 279, 111, 112, 279, 279, + /* 1380 */ 209, 71, 72, 231, 127, 279, 279, 279, 131, 132, + /* 1390 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1400 */ 143, 144, 145, 127, 279, 279, 136, 131, 132, 133, + /* 1410 */ 279, 279, 136, 279, 138, 139, 146, 279, 142, 143, + /* 1420 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1430 */ 279, 136, 279, 138, 139, 279, 271, 142, 143, 144, + /* 1440 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1450 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 1460 */ 279, 279, 279, 279, 279, 127, 209, 279, 279, 131, + /* 1470 */ 132, 133, 279, 279, 136, 279, 138, 139, 208, 279, + /* 1480 */ 142, 143, 144, 145, 127, 209, 279, 279, 131, 132, + /* 1490 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1500 */ 143, 144, 145, 279, 209, 279, 279, 279, 279, 127, + /* 1510 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 1520 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 1530 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1540 */ 139, 271, 279, 142, 143, 144, 145, 209, 279, 279, + /* 1550 */ 279, 279, 279, 279, 279, 279, 127, 279, 279, 279, + /* 1560 */ 131, 132, 133, 279, 279, 136, 209, 138, 139, 279, + /* 1570 */ 279, 142, 143, 144, 145, 279, 279, 279, 127, 279, + /* 1580 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 1590 */ 139, 209, 279, 142, 143, 144, 145, 127, 279, 279, + /* 1600 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1610 */ 209, 279, 142, 143, 144, 145, 127, 279, 279, 279, + /* 1620 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 279, + /* 1630 */ 279, 142, 143, 144, 145, 279, 279, 127, 209, 279, + /* 1640 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 1650 */ 279, 279, 142, 143, 144, 145, 279, 279, 279, 279, + /* 1660 */ 209, 279, 279, 279, 279, 127, 279, 279, 279, 131, + /* 1670 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 209, + /* 1680 */ 142, 143, 144, 145, 127, 279, 279, 279, 131, 132, + /* 1690 */ 133, 279, 279, 136, 279, 138, 139, 279, 209, 142, + /* 1700 */ 143, 144, 145, 279, 279, 279, 127, 279, 279, 279, + /* 1710 */ 131, 132, 133, 279, 279, 136, 279, 138, 139, 209, + /* 1720 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 1730 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1740 */ 142, 143, 144, 145, 127, 279, 279, 209, 131, 132, + /* 1750 */ 133, 279, 279, 136, 279, 138, 139, 279, 279, 142, + /* 1760 */ 143, 144, 145, 279, 279, 127, 209, 279, 279, 131, + /* 1770 */ 132, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 1780 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 1790 */ 279, 279, 279, 127, 279, 279, 279, 131, 132, 133, + /* 1800 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 1810 */ 144, 145, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1820 */ 279, 136, 279, 138, 139, 279, 209, 142, 143, 144, + /* 1830 */ 145, 279, 279, 279, 127, 279, 279, 279, 131, 132, + /* 1840 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 1850 */ 143, 144, 145, 127, 279, 279, 279, 131, 132, 133, + /* 1860 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1870 */ 144, 145, 127, 279, 279, 209, 131, 132, 133, 279, + /* 1880 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 1890 */ 145, 279, 279, 127, 209, 279, 279, 131, 132, 133, + /* 1900 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 1910 */ 144, 145, 279, 279, 279, 279, 209, 279, 279, 279, + /* 1920 */ 279, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1930 */ 136, 279, 138, 139, 279, 209, 142, 143, 144, 145, + /* 1940 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 1950 */ 279, 138, 139, 279, 209, 142, 143, 144, 145, 279, + /* 1960 */ 279, 279, 127, 279, 279, 279, 131, 132, 133, 279, + /* 1970 */ 279, 136, 279, 138, 139, 209, 279, 142, 143, 144, + /* 1980 */ 145, 127, 279, 279, 279, 131, 132, 133, 279, 279, + /* 1990 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2000 */ 127, 279, 279, 209, 131, 132, 133, 279, 279, 136, + /* 2010 */ 279, 138, 139, 279, 279, 142, 143, 144, 145, 279, + /* 2020 */ 279, 127, 209, 279, 279, 131, 132, 133, 279, 279, + /* 2030 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2040 */ 279, 279, 279, 279, 209, 279, 279, 279, 279, 127, + /* 2050 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2060 */ 138, 139, 279, 209, 142, 143, 144, 145, 127, 279, + /* 2070 */ 279, 279, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2080 */ 139, 279, 209, 142, 143, 144, 145, 279, 279, 279, + /* 2090 */ 127, 279, 279, 279, 131, 132, 133, 279, 279, 136, + /* 2100 */ 279, 138, 139, 209, 279, 142, 143, 144, 145, 127, + /* 2110 */ 279, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2120 */ 138, 139, 279, 279, 142, 143, 144, 145, 127, 279, + /* 2130 */ 279, 209, 131, 132, 133, 279, 279, 136, 279, 138, + /* 2140 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 127, + /* 2150 */ 209, 279, 279, 131, 132, 133, 279, 279, 136, 279, + /* 2160 */ 138, 139, 279, 279, 142, 143, 144, 145, 279, 279, + /* 2170 */ 279, 279, 209, 279, 279, 279, 279, 127, 34, 35, + /* 2180 */ 279, 131, 132, 133, 279, 279, 136, 279, 138, 139, + /* 2190 */ 279, 209, 142, 143, 144, 145, 52, 279, 54, 279, + /* 2200 */ 279, 279, 279, 279, 279, 279, 279, 279, 64, 65, + /* 2210 */ 209, 127, 279, 279, 279, 131, 279, 133, 74, 75, + /* 2220 */ 136, 279, 138, 139, 279, 279, 142, 143, 144, 145, + /* 2230 */ 279, 209, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2240 */ 279, 279, 279, 99, 279, 279, 127, 103, 279, 105, + /* 2250 */ 131, 279, 133, 279, 279, 136, 112, 138, 139, 209, + /* 2260 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2270 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2280 */ 142, 143, 144, 145, 279, 279, 127, 279, 279, 279, + /* 2290 */ 131, 279, 133, 209, 279, 136, 279, 138, 139, 279, + /* 2300 */ 279, 142, 143, 144, 145, 127, 279, 279, 279, 131, + /* 2310 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2320 */ 142, 143, 144, 145, 279, 279, 127, 279, 209, 279, + /* 2330 */ 131, 279, 133, 279, 279, 136, 279, 138, 139, 279, + /* 2340 */ 279, 142, 143, 144, 145, 127, 279, 209, 279, 131, + /* 2350 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2360 */ 142, 143, 144, 145, 279, 279, 279, 279, 209, 279, + /* 2370 */ 279, 279, 279, 279, 127, 279, 279, 279, 131, 279, + /* 2380 */ 133, 279, 279, 136, 279, 138, 139, 209, 279, 142, + /* 2390 */ 143, 144, 145, 279, 279, 211, 212, 279, 279, 215, + /* 2400 */ 279, 279, 218, 219, 220, 127, 222, 223, 209, 131, + /* 2410 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2420 */ 142, 143, 144, 145, 279, 127, 279, 209, 279, 131, + /* 2430 */ 279, 133, 279, 279, 136, 279, 138, 139, 279, 279, + /* 2440 */ 142, 143, 144, 145, 279, 279, 279, 279, 127, 279, + /* 2450 */ 279, 279, 131, 279, 133, 279, 209, 136, 279, 138, + /* 2460 */ 139, 279, 279, 142, 143, 144, 145, 279, 279, 279, + /* 2470 */ 279, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2480 */ 279, 279, 136, 279, 138, 139, 279, 209, 142, 143, + /* 2490 */ 144, 145, 211, 212, 279, 279, 215, 279, 279, 218, + /* 2500 */ 219, 220, 127, 222, 223, 279, 131, 209, 133, 279, + /* 2510 */ 279, 136, 279, 138, 139, 279, 279, 142, 143, 144, + /* 2520 */ 145, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 2530 */ 209, 279, 279, 127, 279, 279, 279, 131, 279, 133, + /* 2540 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2550 */ 144, 145, 279, 127, 279, 209, 279, 131, 279, 133, + /* 2560 */ 279, 279, 136, 279, 138, 139, 279, 279, 142, 143, + /* 2570 */ 127, 145, 279, 279, 131, 279, 133, 279, 279, 136, + /* 2580 */ 279, 138, 139, 279, 209, 142, 143, 279, 145, 279, + /* 2590 */ 211, 212, 279, 279, 215, 279, 279, 218, 219, 220, + /* 2600 */ 279, 222, 223, 279, 279, 279, 279, 279, 279, 279, + /* 2610 */ 279, 279, 279, 279, 279, 209, 211, 212, 279, 279, + /* 2620 */ 215, 279, 279, 218, 219, 220, 279, 222, 223, 211, + /* 2630 */ 212, 279, 279, 215, 279, 209, 218, 219, 220, 279, + /* 2640 */ 222, 223, 279, 279, 279, 279, 211, 212, 279, 279, + /* 2650 */ 215, 279, 209, 218, 219, 220, 279, 222, 223, }; #define YY_SHIFT_USE_DFLT (-70) #define YY_SHIFT_COUNT (402) #define YY_SHIFT_MIN (-69) #define YY_SHIFT_MAX (2144) static const short yy_shift_ofst[] = { - /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, - /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, - /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, - /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, - /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, - /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, - /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, - /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, - /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, - /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, - /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, - /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, - /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, - /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, - /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, - /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, - /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, - /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, - /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, - /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, - /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, - /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, - /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, - /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, - /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, - /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, - /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, - /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, - /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, - /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, - /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, - /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, - /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, - /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, - /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, - /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, - /* 400 */ 34, 9, -69, + /* 0 */ 606, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, 1265, + /* 10 */ 89, 155, 907, 907, 907, 155, 39, 189, 2144, 2144, + /* 20 */ 907, -11, 189, 139, 139, 139, 139, 139, 139, 139, + /* 30 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 40 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 50 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 60 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + /* 70 */ 139, 139, 139, 139, 139, 139, 500, 139, 139, 139, + /* 80 */ 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, 1310, + /* 90 */ 246, 294, 294, 294, 294, 294, 294, 294, 294, 294, + /* 100 */ 294, 294, 294, 294, 37, 600, 37, 37, 37, 37, + /* 110 */ 461, 600, 37, 37, 362, 362, 362, 118, 235, 10, + /* 120 */ 10, 10, 1052, 1052, 1191, 123, 15, 603, 629, 599, + /* 130 */ 10, 10, 10, 1124, 1111, 1020, 901, 1255, 1191, 1083, + /* 140 */ 901, 1020, -70, -70, -70, 280, 280, 1090, 1115, 1090, + /* 150 */ 1090, 1090, 249, 865, -6, 96, 96, 96, 96, 317, + /* 160 */ -60, 560, 558, 542, -60, 506, 320, 10, 474, 425, + /* 170 */ 253, 253, 379, 185, 92, -60, 747, 747, 747, 1122, + /* 180 */ 747, 747, 1124, 1122, 747, 747, 1111, 747, 1020, 747, + /* 190 */ 747, 1052, 1088, 747, 747, 1083, 1067, 747, 747, 747, + /* 200 */ 747, 821, 821, 1052, 1048, 747, 747, 747, 747, 892, + /* 210 */ 747, 747, 747, 747, 892, 913, 747, 747, 747, 747, + /* 220 */ 747, 747, 747, 901, 888, 747, 747, 895, 747, 901, + /* 230 */ 901, 901, 901, 854, 847, 747, 890, 821, 821, 815, + /* 240 */ 851, 815, 851, 851, 862, 851, 849, 747, 747, -70, + /* 250 */ -70, -70, -70, -70, -70, 1053, 1033, 1013, 979, 949, + /* 260 */ 918, 889, 860, 840, 719, 668, 809, 1263, 1263, 1263, + /* 270 */ 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 423, + /* 280 */ 460, -8, 368, 368, 174, 78, 28, 13, 13, 13, + /* 290 */ 13, 13, 13, 13, 13, 13, 13, 554, 497, 455, + /* 300 */ 442, 449, 217, 416, 291, 109, 323, 178, 382, 178, + /* 310 */ 315, 161, 228, -26, 278, 803, 724, 802, 756, 797, + /* 320 */ 752, 796, 737, 793, 773, 766, 695, 739, 798, 771, + /* 330 */ 764, 680, 698, 694, 754, 760, 753, 751, 750, 749, + /* 340 */ 748, 741, 746, 743, 713, 732, 740, 657, 733, 716, + /* 350 */ 731, 656, 649, 715, 675, 696, 704, 714, 706, 705, + /* 360 */ 710, 702, 707, 703, 683, 604, 618, 679, 647, 628, + /* 370 */ 608, 650, 635, 613, 611, 593, 601, 589, 584, 484, + /* 380 */ 399, 489, 475, 419, 373, 287, 336, 285, 276, 130, + /* 390 */ 130, 130, 130, 130, 130, 191, 134, 86, 86, 57, + /* 400 */ 34, 9, -69, }; #define YY_REDUCE_USE_DFLT (-179) #define YY_REDUCE_COUNT (254) #define YY_REDUCE_MIN (-178) #define YY_REDUCE_MAX (2443) static const short yy_reduce_ofst[] = { - /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, - /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, - /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, - /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, - /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, - /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, - /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, - /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, - /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, - /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, - /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, - /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, - /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, - /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, - /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, - /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, - /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, - /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, - /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, - /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, - /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, - /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, - /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, - /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, - /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, - /* 250 */ 718, 700, 581, 569, 614, + /* 0 */ -160, 494, 451, 401, 357, 314, 264, 220, 177, 120, + /* 10 */ -102, 257, 557, 530, 510, 257, 1117, 1043, 1036, 1015, + /* 20 */ 920, 1171, 1152, 864, 2050, 2022, 2001, 1982, 1963, 1941, + /* 30 */ 1922, 1894, 1873, 1854, 1835, 1813, 1794, 1766, 1745, 1726, + /* 40 */ 1707, 1685, 1666, 1638, 1617, 1598, 1579, 1557, 1538, 1510, + /* 50 */ 1489, 1470, 1451, 1429, 1401, 1382, 1357, 1338, 1314, 1295, + /* 60 */ 1276, 1257, 2406, 2375, 2346, 2321, 2298, 2278, 2247, 2218, + /* 70 */ 2199, 2178, 2159, 2138, 2119, 2084, 179, 2443, 2426, 999, + /* 80 */ 2435, 2418, 2405, 2379, 2281, 2184, 1123, 417, 358, 140, + /* 90 */ -178, 1009, 982, 863, 758, 726, 692, 612, 488, 400, + /* 100 */ -7, -31, -57, -80, 387, 58, 1270, 1165, 1037, 225, + /* 110 */ -21, -76, 319, 312, 67, 31, 172, -32, -1, 114, + /* 120 */ 56, -30, -46, -96, -97, 133, 524, 480, 93, 299, + /* 130 */ 204, 297, 402, 361, 258, 413, 445, 331, -139, 2, + /* 140 */ 421, 390, 388, -101, 219, 1100, 1093, 1049, 1127, 1044, + /* 150 */ 1041, 1026, 981, 1016, 1060, 1057, 1057, 1057, 1057, 992, + /* 160 */ 1021, 1001, 1000, 980, 1017, 975, 967, 1071, 966, 965, + /* 170 */ 954, 947, 963, 962, 951, 989, 943, 925, 924, 912, + /* 180 */ 923, 922, 900, 891, 911, 910, 916, 903, 958, 899, + /* 190 */ 894, 957, 941, 875, 874, 940, 830, 870, 869, 868, + /* 200 */ 850, 898, 896, 915, 829, 842, 834, 831, 828, 917, + /* 210 */ 816, 814, 813, 811, 902, 882, 808, 807, 794, 792, + /* 220 */ 791, 788, 776, 799, 790, 767, 757, 770, 729, 765, + /* 230 */ 762, 755, 734, 761, 763, 699, 781, 742, 738, 723, + /* 240 */ 774, 712, 769, 759, 727, 744, 645, 623, 620, 617, + /* 250 */ 718, 700, 581, 569, 614, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, - /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, - /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, - /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, - /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, - /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, - /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, - /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, - /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, - /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, - /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, - /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, - /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, - /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, - /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, - /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, - /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, - /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, - /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, - /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, - /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, - /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, - /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, - /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, - /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, - /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, - /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, - /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, - /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, - /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, - /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, - /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, - /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, - /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, - /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, - /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, - /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, - /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, - /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, - /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, - /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, - /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, - /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, - /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, - /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, - /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, - /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, - /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, - /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, - /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, - /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, - /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, - /* 640 */ 688, 687, 899, 797, 733, + /* 0 */ 977, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 10 */ 700, 894, 649, 649, 649, 893, 977, 977, 977, 977, + /* 20 */ 649, 977, 972, 977, 977, 977, 977, 977, 977, 977, + /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 50 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 60 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 70 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 80 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 90 */ 686, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 100 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 110 */ 714, 965, 977, 977, 707, 707, 977, 916, 977, 977, + /* 120 */ 977, 977, 839, 839, 760, 943, 977, 977, 975, 977, + /* 130 */ 825, 977, 715, 977, 977, 973, 977, 977, 760, 763, + /* 140 */ 977, 973, 695, 675, 813, 977, 977, 977, 691, 977, + /* 150 */ 977, 977, 977, 734, 977, 954, 953, 952, 749, 977, + /* 160 */ 849, 977, 977, 977, 849, 977, 977, 977, 977, 977, + /* 170 */ 977, 977, 977, 977, 977, 849, 977, 977, 977, 977, + /* 180 */ 810, 977, 977, 977, 807, 977, 977, 977, 977, 977, + /* 190 */ 977, 977, 977, 977, 977, 763, 977, 977, 977, 977, + /* 200 */ 977, 955, 955, 977, 977, 977, 977, 977, 977, 966, + /* 210 */ 977, 977, 977, 977, 966, 975, 977, 977, 977, 977, + /* 220 */ 977, 977, 977, 977, 917, 977, 977, 728, 977, 977, + /* 230 */ 977, 977, 977, 964, 824, 977, 977, 955, 955, 854, + /* 240 */ 856, 854, 856, 856, 977, 856, 977, 977, 977, 686, + /* 250 */ 892, 863, 843, 842, 667, 977, 977, 977, 977, 977, + /* 260 */ 977, 977, 977, 977, 977, 977, 977, 836, 698, 699, + /* 270 */ 976, 967, 692, 799, 657, 659, 758, 759, 655, 977, + /* 280 */ 977, 748, 757, 756, 977, 977, 977, 747, 746, 745, + /* 290 */ 744, 743, 742, 741, 740, 739, 738, 977, 977, 977, + /* 300 */ 977, 977, 977, 977, 977, 794, 977, 928, 977, 927, + /* 310 */ 977, 977, 794, 977, 977, 977, 977, 977, 977, 977, + /* 320 */ 800, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 330 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 340 */ 977, 977, 977, 788, 977, 977, 977, 868, 977, 977, + /* 350 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 360 */ 977, 977, 977, 977, 921, 977, 977, 977, 977, 977, + /* 370 */ 977, 977, 977, 977, 724, 977, 977, 977, 977, 851, + /* 380 */ 850, 977, 977, 656, 658, 977, 977, 977, 794, 755, + /* 390 */ 754, 753, 752, 751, 750, 977, 977, 737, 736, 977, + /* 400 */ 977, 977, 977, 732, 897, 896, 895, 814, 812, 811, + /* 410 */ 809, 808, 806, 804, 803, 802, 801, 805, 891, 890, + /* 420 */ 889, 888, 887, 886, 772, 941, 939, 938, 937, 936, + /* 430 */ 935, 934, 933, 932, 898, 847, 722, 940, 862, 861, + /* 440 */ 860, 841, 840, 838, 837, 774, 775, 776, 773, 765, + /* 450 */ 766, 764, 790, 791, 762, 661, 781, 783, 785, 787, + /* 460 */ 789, 786, 784, 782, 780, 779, 770, 769, 768, 767, + /* 470 */ 660, 761, 709, 708, 706, 650, 648, 647, 646, 942, + /* 480 */ 702, 701, 697, 696, 882, 915, 914, 912, 911, 910, + /* 490 */ 909, 908, 907, 906, 905, 904, 903, 902, 884, 883, + /* 500 */ 881, 798, 865, 859, 858, 796, 795, 723, 703, 694, + /* 510 */ 670, 671, 669, 666, 645, 721, 922, 930, 931, 926, + /* 520 */ 924, 929, 925, 923, 848, 794, 918, 920, 846, 845, + /* 530 */ 919, 720, 730, 729, 727, 726, 823, 820, 819, 818, + /* 540 */ 817, 816, 822, 821, 963, 962, 960, 961, 959, 958, + /* 550 */ 957, 974, 971, 970, 969, 968, 719, 717, 725, 724, + /* 560 */ 718, 716, 853, 852, 678, 828, 956, 901, 900, 844, + /* 570 */ 827, 826, 685, 855, 684, 683, 682, 681, 857, 735, + /* 580 */ 870, 869, 771, 652, 880, 879, 878, 877, 876, 875, + /* 590 */ 874, 873, 945, 951, 950, 949, 948, 947, 946, 944, + /* 600 */ 872, 871, 835, 834, 833, 832, 831, 830, 829, 885, + /* 610 */ 815, 793, 792, 778, 651, 868, 867, 693, 705, 704, + /* 620 */ 654, 653, 680, 679, 677, 674, 673, 672, 668, 665, + /* 630 */ 664, 663, 662, 676, 713, 712, 711, 710, 690, 689, + /* 640 */ 688, 687, 899, 797, 733, }; /* The next table maps tokens into fallback tokens. If a construct ** like the following: -** +** ** %fallback ID X Y Z. ** ** appears in the grammar, then ID becomes a fallback token for X, Y, @@ -988,10 +988,10 @@ static const YYCODETYPE yyFallback[] = { ** It is sometimes called the "minor" token. */ struct yyStackEntry { - YYACTIONTYPE stateno; /* The state-number */ - YYCODETYPE major; /* The major token value. This is the code + YYACTIONTYPE stateno; /* The state-number */ + YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This + YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; @@ -999,17 +999,17 @@ typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { - int yyidx; /* Index of top element in stack */ + int yyidx; /* Index of top element in stack */ #ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ + int yyidxMax; /* Maximum value of yyidx */ #endif - int yyerrcnt; /* Shifts left before out of the error */ - ParseARG_SDECL /* A place to hold %extra_argument */ + int yyerrcnt; /* Shifts left before out of the error */ + ParseARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ + int yystksz; /* Current side of the stack */ + yyStackEntry *yystack; /* The parser's stack */ #else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ + yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ #endif }; typedef struct yyParser yyParser; @@ -1021,10 +1021,10 @@ static char *yyTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG -/* +/* ** Turn parser tracing on by giving a stream to which to write the trace ** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL +** by making either argument NULL ** ** Inputs: **
            @@ -1038,92 +1038,88 @@ static char *yyTracePrompt = 0; ** Outputs: ** None. */ -void ParseTrace(FILE *TraceFILE, char *zTracePrompt) -{ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if(yyTraceFILE == 0) { - yyTracePrompt = 0; - } else if(yyTracePrompt == 0) { - yyTraceFILE = 0; - } +void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if( yyTraceFILE==0 ) yyTracePrompt = 0; + else if( yyTracePrompt==0 ) yyTraceFILE = 0; } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", - "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", - "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", - "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", - "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", - "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", - "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", - "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", - "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", - "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", - "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", - "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", - "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", - "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", - "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", - "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", - "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", - "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", - "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", - "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", - "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", - "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", - "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", - "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", - "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", - "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", - "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", - "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", - "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", - "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", - "TOK_WHILE", "error", "statement_list", "case_action", - "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", - "assignable", "attribute_decl", "by_expression", "constant", - "expression", "function_call", "general_ref", "group_ref", - "identifier", "initializer", "interval", "literal", - "local_initializer", "precision_spec", "query_expression", "query_start", - "simple_expression", "unary_expression", "supertype_expression", "until_control", - "while_control", "function_header", "fh_lineno", "rule_header", - "rh_start", "rh_get_line", "procedure_header", "ph_get_line", - "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", - "case_action_list", "case_block", "case_labels", "where_clause_list", - "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", - "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", - "nested_id_list", "statement_rep", "subtype_decl", "where_rule", - "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", - "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", - "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", - "optional_or_unique", "optional_fixed", "optional", "var", - "unique", "qualified_attr", "qualifier", "alias_statement", - "assignment_statement", "case_statement", "compound_statement", "escape_statement", - "if_statement", "proc_call_statement", "repeat_statement", "return_statement", - "skip_statement", "statement", "subsuper_decl", "supertype_decl", - "supertype_factor", "function_id", "procedure_id", "attribute_type", - "defined_type", "parameter_type", "generic_type", "basic_type", - "select_type", "aggregate_type", "aggregation_type", "array_type", - "bag_type", "conformant_aggregation", "list_type", "set_type", - "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", - "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", - "action_body_item_rep", "action_body_item", "declaration", "constant_decl", - "local_decl", "semicolon", "alias_push_scope", "block_list", - "block_member", "include_directive", "rule_decl", "constant_body", - "constant_body_list", "entity_decl", "function_decl", "procedure_decl", - "type_decl", "entity_header", "enumeration_type", "express_file", - "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", - "increment_control", "rename", "rename_list", "parened_rename_list", - "reference_clause", "reference_head", "use_clause", "use_head", - "interface_specification", "interface_specification_list", "right_curl", "local_variable", - "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", - "ph_push_scope", "schema_body", "schema_header", "type_item_body", - "type_item", "ti_start", "td_start", +static const char *const yyTokenName[] = { + "$", "TOK_EQUAL", "TOK_GREATER_EQUAL", "TOK_GREATER_THAN", + "TOK_IN", "TOK_INST_EQUAL", "TOK_INST_NOT_EQUAL", "TOK_LESS_EQUAL", + "TOK_LESS_THAN", "TOK_LIKE", "TOK_NOT_EQUAL", "TOK_MINUS", + "TOK_PLUS", "TOK_OR", "TOK_XOR", "TOK_DIV", + "TOK_MOD", "TOK_REAL_DIV", "TOK_TIMES", "TOK_AND", + "TOK_ANDOR", "TOK_CONCAT_OP", "TOK_EXP", "TOK_NOT", + "TOK_DOT", "TOK_BACKSLASH", "TOK_LEFT_BRACKET", "TOK_LEFT_PAREN", + "TOK_RIGHT_PAREN", "TOK_RIGHT_BRACKET", "TOK_COLON", "TOK_COMMA", + "TOK_AGGREGATE", "TOK_OF", "TOK_IDENTIFIER", "TOK_ALIAS", + "TOK_FOR", "TOK_END_ALIAS", "TOK_ARRAY", "TOK_ASSIGNMENT", + "TOK_BAG", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_REAL", + "TOK_NUMBER", "TOK_LOGICAL", "TOK_BINARY", "TOK_STRING", + "TOK_BY", "TOK_LEFT_CURL", "TOK_RIGHT_CURL", "TOK_OTHERWISE", + "TOK_CASE", "TOK_END_CASE", "TOK_BEGIN", "TOK_END", + "TOK_PI", "TOK_E", "TOK_CONSTANT", "TOK_END_CONSTANT", + "TOK_DERIVE", "TOK_END_ENTITY", "TOK_ENTITY", "TOK_ENUMERATION", + "TOK_ESCAPE", "TOK_SELF", "TOK_OPTIONAL", "TOK_VAR", + "TOK_END_FUNCTION", "TOK_FUNCTION", "TOK_BUILTIN_FUNCTION", "TOK_LIST", + "TOK_SET", "TOK_GENERIC", "TOK_QUESTION_MARK", "TOK_IF", + "TOK_THEN", "TOK_END_IF", "TOK_ELSE", "TOK_INCLUDE", + "TOK_STRING_LITERAL", "TOK_TO", "TOK_AS", "TOK_REFERENCE", + "TOK_FROM", "TOK_USE", "TOK_INVERSE", "TOK_INTEGER_LITERAL", + "TOK_REAL_LITERAL", "TOK_STRING_LITERAL_ENCODED", "TOK_LOGICAL_LITERAL", "TOK_BINARY_LITERAL", + "TOK_LOCAL", "TOK_END_LOCAL", "TOK_ONEOF", "TOK_UNIQUE", + "TOK_FIXED", "TOK_END_PROCEDURE", "TOK_PROCEDURE", "TOK_BUILTIN_PROCEDURE", + "TOK_QUERY", "TOK_ALL_IN", "TOK_SUCH_THAT", "TOK_REPEAT", + "TOK_END_REPEAT", "TOK_RETURN", "TOK_END_RULE", "TOK_RULE", + "TOK_END_SCHEMA", "TOK_SCHEMA", "TOK_SELECT", "TOK_SEMICOLON", + "TOK_SKIP", "TOK_SUBTYPE", "TOK_ABSTRACT", "TOK_SUPERTYPE", + "TOK_END_TYPE", "TOK_TYPE", "TOK_UNTIL", "TOK_WHERE", + "TOK_WHILE", "error", "statement_list", "case_action", + "case_otherwise", "entity_body", "aggregate_init_element", "aggregate_initializer", + "assignable", "attribute_decl", "by_expression", "constant", + "expression", "function_call", "general_ref", "group_ref", + "identifier", "initializer", "interval", "literal", + "local_initializer", "precision_spec", "query_expression", "query_start", + "simple_expression", "unary_expression", "supertype_expression", "until_control", + "while_control", "function_header", "fh_lineno", "rule_header", + "rh_start", "rh_get_line", "procedure_header", "ph_get_line", + "action_body", "actual_parameters", "aggregate_init_body", "explicit_attr_list", + "case_action_list", "case_block", "case_labels", "where_clause_list", + "derive_decl", "explicit_attribute", "expression_list", "formal_parameter", + "formal_parameter_list", "formal_parameter_rep", "id_list", "defined_type_list", + "nested_id_list", "statement_rep", "subtype_decl", "where_rule", + "where_rule_OPT", "supertype_expression_list", "labelled_attrib_list_list", "labelled_attrib_list", + "inverse_attr_list", "inverse_clause", "attribute_decl_list", "derived_attribute_rep", + "unique_clause", "rule_formal_parameter_list", "qualified_attr_list", "rel_op", + "optional_or_unique", "optional_fixed", "optional", "var", + "unique", "qualified_attr", "qualifier", "alias_statement", + "assignment_statement", "case_statement", "compound_statement", "escape_statement", + "if_statement", "proc_call_statement", "repeat_statement", "return_statement", + "skip_statement", "statement", "subsuper_decl", "supertype_decl", + "supertype_factor", "function_id", "procedure_id", "attribute_type", + "defined_type", "parameter_type", "generic_type", "basic_type", + "select_type", "aggregate_type", "aggregation_type", "array_type", + "bag_type", "conformant_aggregation", "list_type", "set_type", + "set_or_bag_of_entity", "type", "cardinality_op", "bound_spec", + "inverse_attr", "derived_attribute", "rule_formal_parameter", "where_clause", + "action_body_item_rep", "action_body_item", "declaration", "constant_decl", + "local_decl", "semicolon", "alias_push_scope", "block_list", + "block_member", "include_directive", "rule_decl", "constant_body", + "constant_body_list", "entity_decl", "function_decl", "procedure_decl", + "type_decl", "entity_header", "enumeration_type", "express_file", + "schema_decl_list", "schema_decl", "fh_push_scope", "fh_plist", + "increment_control", "rename", "rename_list", "parened_rename_list", + "reference_clause", "reference_head", "use_clause", "use_head", + "interface_specification", "interface_specification_list", "right_curl", "local_variable", + "local_body", "local_decl_rules_on", "local_decl_rules_off", "oneof_op", + "ph_push_scope", "schema_body", "schema_header", "type_item_body", + "type_item", "ti_start", "td_start", }; #endif /* NDEBUG */ @@ -1131,338 +1127,338 @@ static const char *const yyTokenName[] = { /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { - /* 0 */ "action_body ::= action_body_item_rep statement_rep", - /* 1 */ "action_body_item ::= declaration", - /* 2 */ "action_body_item ::= constant_decl", - /* 3 */ "action_body_item ::= local_decl", - /* 4 */ "action_body_item_rep ::=", - /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", - /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", - /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", - /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", - /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", - /* 10 */ "aggregate_init_element ::= expression", - /* 11 */ "aggregate_init_body ::= aggregate_init_element", - /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", - /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", - /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", - /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", - /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", - /* 17 */ "aggregation_type ::= array_type", - /* 18 */ "aggregation_type ::= bag_type", - /* 19 */ "aggregation_type ::= list_type", - /* 20 */ "aggregation_type ::= set_type", - /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", - /* 22 */ "alias_push_scope ::=", - /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", - /* 24 */ "assignable ::= assignable qualifier", - /* 25 */ "assignable ::= identifier", - /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", - /* 27 */ "attribute_type ::= aggregation_type", - /* 28 */ "attribute_type ::= basic_type", - /* 29 */ "attribute_type ::= defined_type", - /* 30 */ "explicit_attr_list ::=", - /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", - /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", - /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", - /* 34 */ "basic_type ::= TOK_BOOLEAN", - /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", - /* 36 */ "basic_type ::= TOK_REAL precision_spec", - /* 37 */ "basic_type ::= TOK_NUMBER", - /* 38 */ "basic_type ::= TOK_LOGICAL", - /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", - /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", - /* 41 */ "block_list ::=", - /* 42 */ "block_list ::= block_list block_member", - /* 43 */ "block_member ::= declaration", - /* 44 */ "block_member ::= include_directive", - /* 45 */ "block_member ::= rule_decl", - /* 46 */ "by_expression ::=", - /* 47 */ "by_expression ::= TOK_BY expression", - /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", - /* 49 */ "case_action ::= case_labels TOK_COLON statement", - /* 50 */ "case_action_list ::=", - /* 51 */ "case_action_list ::= case_action_list case_action", - /* 52 */ "case_block ::= case_action_list case_otherwise", - /* 53 */ "case_labels ::= expression", - /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", - /* 55 */ "case_otherwise ::=", - /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", - /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", - /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", - /* 59 */ "constant ::= TOK_PI", - /* 60 */ "constant ::= TOK_E", - /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", - /* 62 */ "constant_body_list ::=", - /* 63 */ "constant_body_list ::= constant_body constant_body_list", - /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", - /* 65 */ "declaration ::= entity_decl", - /* 66 */ "declaration ::= function_decl", - /* 67 */ "declaration ::= procedure_decl", - /* 68 */ "declaration ::= type_decl", - /* 69 */ "derive_decl ::=", - /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", - /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", - /* 72 */ "derived_attribute_rep ::= derived_attribute", - /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", - /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", - /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", - /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", - /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", - /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", - /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", - /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", - /* 81 */ "attribute_decl_list ::= attribute_decl", - /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", - /* 83 */ "optional ::=", - /* 84 */ "optional ::= TOK_OPTIONAL", - /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", - /* 86 */ "express_file ::= schema_decl_list", - /* 87 */ "schema_decl_list ::= schema_decl", - /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", - /* 89 */ "expression ::= simple_expression", - /* 90 */ "expression ::= expression TOK_AND expression", - /* 91 */ "expression ::= expression TOK_OR expression", - /* 92 */ "expression ::= expression TOK_XOR expression", - /* 93 */ "expression ::= expression TOK_LESS_THAN expression", - /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", - /* 95 */ "expression ::= expression TOK_EQUAL expression", - /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", - /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", - /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", - /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", - /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", - /* 101 */ "expression ::= expression TOK_IN expression", - /* 102 */ "expression ::= expression TOK_LIKE expression", - /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", - /* 104 */ "simple_expression ::= unary_expression", - /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", - /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", - /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", - /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", - /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", - /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", - /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", - /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", - /* 113 */ "expression_list ::= expression", - /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", - /* 115 */ "var ::=", - /* 116 */ "var ::= TOK_VAR", - /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", - /* 118 */ "formal_parameter_list ::=", - /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", - /* 120 */ "formal_parameter_rep ::= formal_parameter", - /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", - /* 122 */ "parameter_type ::= basic_type", - /* 123 */ "parameter_type ::= conformant_aggregation", - /* 124 */ "parameter_type ::= defined_type", - /* 125 */ "parameter_type ::= generic_type", - /* 126 */ "function_call ::= function_id actual_parameters", - /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", - /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", - /* 129 */ "fh_lineno ::= TOK_FUNCTION", - /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", - /* 131 */ "fh_plist ::= formal_parameter_list", - /* 132 */ "function_id ::= TOK_IDENTIFIER", - /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", - /* 134 */ "conformant_aggregation ::= aggregate_type", - /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", - /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", - /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", - /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", - /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", - /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", - /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", - /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", - /* 143 */ "generic_type ::= TOK_GENERIC", - /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", - /* 145 */ "id_list ::= TOK_IDENTIFIER", - /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", - /* 147 */ "identifier ::= TOK_SELF", - /* 148 */ "identifier ::= TOK_QUESTION_MARK", - /* 149 */ "identifier ::= TOK_IDENTIFIER", - /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", - /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", - /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", - /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", - /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", - /* 155 */ "rename ::= TOK_IDENTIFIER", - /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", - /* 157 */ "rename_list ::= rename", - /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", - /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", - /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", - /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", - /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", - /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", - /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", - /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", - /* 166 */ "interface_specification ::= use_clause", - /* 167 */ "interface_specification ::= reference_clause", - /* 168 */ "interface_specification_list ::=", - /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", - /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", - /* 171 */ "set_or_bag_of_entity ::= defined_type", - /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", - /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", - /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", - /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", - /* 176 */ "inverse_attr_list ::= inverse_attr", - /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", - /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", - /* 179 */ "inverse_clause ::=", - /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", - /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", - /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", - /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", - /* 184 */ "literal ::= TOK_INTEGER_LITERAL", - /* 185 */ "literal ::= TOK_REAL_LITERAL", - /* 186 */ "literal ::= TOK_STRING_LITERAL", - /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", - /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", - /* 189 */ "literal ::= TOK_BINARY_LITERAL", - /* 190 */ "literal ::= constant", - /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", - /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", - /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", - /* 194 */ "local_body ::=", - /* 195 */ "local_body ::= local_variable local_body", - /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", - /* 197 */ "local_decl_rules_on ::=", - /* 198 */ "local_decl_rules_off ::=", - /* 199 */ "defined_type ::= TOK_IDENTIFIER", - /* 200 */ "defined_type_list ::= defined_type", - /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", - /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", - /* 203 */ "oneof_op ::= TOK_ONEOF", - /* 204 */ "optional_or_unique ::=", - /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", - /* 206 */ "optional_or_unique ::= TOK_UNIQUE", - /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", - /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", - /* 209 */ "optional_fixed ::=", - /* 210 */ "optional_fixed ::= TOK_FIXED", - /* 211 */ "precision_spec ::=", - /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", - /* 214 */ "proc_call_statement ::= procedure_id semicolon", - /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", - /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", - /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", - /* 218 */ "ph_get_line ::=", - /* 219 */ "procedure_id ::= TOK_IDENTIFIER", - /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", - /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", - /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", - /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", - /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", - /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", - /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", - /* 228 */ "rel_op ::= TOK_LESS_THAN", - /* 229 */ "rel_op ::= TOK_GREATER_THAN", - /* 230 */ "rel_op ::= TOK_EQUAL", - /* 231 */ "rel_op ::= TOK_LESS_EQUAL", - /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", - /* 233 */ "rel_op ::= TOK_NOT_EQUAL", - /* 234 */ "rel_op ::= TOK_INST_EQUAL", - /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", - /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", - /* 238 */ "return_statement ::= TOK_RETURN semicolon", - /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", - /* 240 */ "right_curl ::= TOK_RIGHT_CURL", - /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", - /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", - /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", - /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", - /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", - /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", - /* 247 */ "rh_get_line ::=", - /* 248 */ "schema_body ::= interface_specification_list block_list", - /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", - /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", - /* 251 */ "schema_decl ::= include_directive", - /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", - /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 254 */ "semicolon ::= TOK_SEMICOLON", - /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", - /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", - /* 257 */ "skip_statement ::= TOK_SKIP semicolon", - /* 258 */ "statement ::= alias_statement", - /* 259 */ "statement ::= assignment_statement", - /* 260 */ "statement ::= case_statement", - /* 261 */ "statement ::= compound_statement", - /* 262 */ "statement ::= escape_statement", - /* 263 */ "statement ::= if_statement", - /* 264 */ "statement ::= proc_call_statement", - /* 265 */ "statement ::= repeat_statement", - /* 266 */ "statement ::= return_statement", - /* 267 */ "statement ::= skip_statement", - /* 268 */ "statement_rep ::=", - /* 269 */ "statement_rep ::= semicolon statement_rep", - /* 270 */ "statement_rep ::= statement statement_rep", - /* 271 */ "subsuper_decl ::=", - /* 272 */ "subsuper_decl ::= supertype_decl", - /* 273 */ "subsuper_decl ::= subtype_decl", - /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", - /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", - /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", - /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 279 */ "supertype_expression ::= supertype_factor", - /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", - /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", - /* 282 */ "supertype_expression_list ::= supertype_expression", - /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", - /* 284 */ "supertype_factor ::= identifier", - /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", - /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", - /* 287 */ "type ::= aggregation_type", - /* 288 */ "type ::= basic_type", - /* 289 */ "type ::= defined_type", - /* 290 */ "type ::= select_type", - /* 291 */ "type_item_body ::= enumeration_type", - /* 292 */ "type_item_body ::= type", - /* 293 */ "type_item ::= ti_start type_item_body semicolon", - /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", - /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", - /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", - /* 297 */ "general_ref ::= assignable group_ref", - /* 298 */ "general_ref ::= assignable", - /* 299 */ "unary_expression ::= aggregate_initializer", - /* 300 */ "unary_expression ::= unary_expression qualifier", - /* 301 */ "unary_expression ::= literal", - /* 302 */ "unary_expression ::= function_call", - /* 303 */ "unary_expression ::= identifier", - /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", - /* 305 */ "unary_expression ::= interval", - /* 306 */ "unary_expression ::= query_expression", - /* 307 */ "unary_expression ::= TOK_NOT unary_expression", - /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", - /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", - /* 310 */ "unique ::=", - /* 311 */ "unique ::= TOK_UNIQUE", - /* 312 */ "qualified_attr ::= attribute_decl", - /* 313 */ "qualified_attr_list ::= qualified_attr", - /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", - /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", - /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", - /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", - /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", - /* 319 */ "unique_clause ::=", - /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", - /* 321 */ "until_control ::=", - /* 322 */ "until_control ::= TOK_UNTIL expression", - /* 323 */ "where_clause ::= expression semicolon", - /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", - /* 325 */ "where_clause_list ::= where_clause", - /* 326 */ "where_clause_list ::= where_clause_list where_clause", - /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", - /* 328 */ "where_rule_OPT ::=", - /* 329 */ "where_rule_OPT ::= where_rule", - /* 330 */ "while_control ::=", - /* 331 */ "while_control ::= TOK_WHILE expression", + /* 0 */ "action_body ::= action_body_item_rep statement_rep", + /* 1 */ "action_body_item ::= declaration", + /* 2 */ "action_body_item ::= constant_decl", + /* 3 */ "action_body_item ::= local_decl", + /* 4 */ "action_body_item_rep ::=", + /* 5 */ "action_body_item_rep ::= action_body_item action_body_item_rep", + /* 6 */ "actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN", + /* 7 */ "actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN", + /* 8 */ "aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET", + /* 9 */ "aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET", + /* 10 */ "aggregate_init_element ::= expression", + /* 11 */ "aggregate_init_body ::= aggregate_init_element", + /* 12 */ "aggregate_init_body ::= aggregate_init_element TOK_COLON expression", + /* 13 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element", + /* 14 */ "aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression", + /* 15 */ "aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type", + /* 16 */ "aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type", + /* 17 */ "aggregation_type ::= array_type", + /* 18 */ "aggregation_type ::= bag_type", + /* 19 */ "aggregation_type ::= list_type", + /* 20 */ "aggregation_type ::= set_type", + /* 21 */ "alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon", + /* 22 */ "alias_push_scope ::=", + /* 23 */ "array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type", + /* 24 */ "assignable ::= assignable qualifier", + /* 25 */ "assignable ::= identifier", + /* 26 */ "assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon", + /* 27 */ "attribute_type ::= aggregation_type", + /* 28 */ "attribute_type ::= basic_type", + /* 29 */ "attribute_type ::= defined_type", + /* 30 */ "explicit_attr_list ::=", + /* 31 */ "explicit_attr_list ::= explicit_attr_list explicit_attribute", + /* 32 */ "bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type", + /* 33 */ "bag_type ::= TOK_BAG TOK_OF attribute_type", + /* 34 */ "basic_type ::= TOK_BOOLEAN", + /* 35 */ "basic_type ::= TOK_INTEGER precision_spec", + /* 36 */ "basic_type ::= TOK_REAL precision_spec", + /* 37 */ "basic_type ::= TOK_NUMBER", + /* 38 */ "basic_type ::= TOK_LOGICAL", + /* 39 */ "basic_type ::= TOK_BINARY precision_spec optional_fixed", + /* 40 */ "basic_type ::= TOK_STRING precision_spec optional_fixed", + /* 41 */ "block_list ::=", + /* 42 */ "block_list ::= block_list block_member", + /* 43 */ "block_member ::= declaration", + /* 44 */ "block_member ::= include_directive", + /* 45 */ "block_member ::= rule_decl", + /* 46 */ "by_expression ::=", + /* 47 */ "by_expression ::= TOK_BY expression", + /* 48 */ "cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL", + /* 49 */ "case_action ::= case_labels TOK_COLON statement", + /* 50 */ "case_action_list ::=", + /* 51 */ "case_action_list ::= case_action_list case_action", + /* 52 */ "case_block ::= case_action_list case_otherwise", + /* 53 */ "case_labels ::= expression", + /* 54 */ "case_labels ::= case_labels TOK_COMMA expression", + /* 55 */ "case_otherwise ::=", + /* 56 */ "case_otherwise ::= TOK_OTHERWISE TOK_COLON statement", + /* 57 */ "case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon", + /* 58 */ "compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon", + /* 59 */ "constant ::= TOK_PI", + /* 60 */ "constant ::= TOK_E", + /* 61 */ "constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon", + /* 62 */ "constant_body_list ::=", + /* 63 */ "constant_body_list ::= constant_body constant_body_list", + /* 64 */ "constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon", + /* 65 */ "declaration ::= entity_decl", + /* 66 */ "declaration ::= function_decl", + /* 67 */ "declaration ::= procedure_decl", + /* 68 */ "declaration ::= type_decl", + /* 69 */ "derive_decl ::=", + /* 70 */ "derive_decl ::= TOK_DERIVE derived_attribute_rep", + /* 71 */ "derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon", + /* 72 */ "derived_attribute_rep ::= derived_attribute", + /* 73 */ "derived_attribute_rep ::= derived_attribute_rep derived_attribute", + /* 74 */ "entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT", + /* 75 */ "entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon", + /* 76 */ "entity_header ::= TOK_ENTITY TOK_IDENTIFIER", + /* 77 */ "enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list", + /* 78 */ "escape_statement ::= TOK_ESCAPE semicolon", + /* 79 */ "attribute_decl ::= TOK_IDENTIFIER", + /* 80 */ "attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER", + /* 81 */ "attribute_decl_list ::= attribute_decl", + /* 82 */ "attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl", + /* 83 */ "optional ::=", + /* 84 */ "optional ::= TOK_OPTIONAL", + /* 85 */ "explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon", + /* 86 */ "express_file ::= schema_decl_list", + /* 87 */ "schema_decl_list ::= schema_decl", + /* 88 */ "schema_decl_list ::= schema_decl_list schema_decl", + /* 89 */ "expression ::= simple_expression", + /* 90 */ "expression ::= expression TOK_AND expression", + /* 91 */ "expression ::= expression TOK_OR expression", + /* 92 */ "expression ::= expression TOK_XOR expression", + /* 93 */ "expression ::= expression TOK_LESS_THAN expression", + /* 94 */ "expression ::= expression TOK_GREATER_THAN expression", + /* 95 */ "expression ::= expression TOK_EQUAL expression", + /* 96 */ "expression ::= expression TOK_LESS_EQUAL expression", + /* 97 */ "expression ::= expression TOK_GREATER_EQUAL expression", + /* 98 */ "expression ::= expression TOK_NOT_EQUAL expression", + /* 99 */ "expression ::= expression TOK_INST_EQUAL expression", + /* 100 */ "expression ::= expression TOK_INST_NOT_EQUAL expression", + /* 101 */ "expression ::= expression TOK_IN expression", + /* 102 */ "expression ::= expression TOK_LIKE expression", + /* 103 */ "expression ::= simple_expression cardinality_op simple_expression", + /* 104 */ "simple_expression ::= unary_expression", + /* 105 */ "simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression", + /* 106 */ "simple_expression ::= simple_expression TOK_EXP simple_expression", + /* 107 */ "simple_expression ::= simple_expression TOK_TIMES simple_expression", + /* 108 */ "simple_expression ::= simple_expression TOK_DIV simple_expression", + /* 109 */ "simple_expression ::= simple_expression TOK_REAL_DIV simple_expression", + /* 110 */ "simple_expression ::= simple_expression TOK_MOD simple_expression", + /* 111 */ "simple_expression ::= simple_expression TOK_PLUS simple_expression", + /* 112 */ "simple_expression ::= simple_expression TOK_MINUS simple_expression", + /* 113 */ "expression_list ::= expression", + /* 114 */ "expression_list ::= expression_list TOK_COMMA expression", + /* 115 */ "var ::=", + /* 116 */ "var ::= TOK_VAR", + /* 117 */ "formal_parameter ::= var id_list TOK_COLON parameter_type", + /* 118 */ "formal_parameter_list ::=", + /* 119 */ "formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN", + /* 120 */ "formal_parameter_rep ::= formal_parameter", + /* 121 */ "formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter", + /* 122 */ "parameter_type ::= basic_type", + /* 123 */ "parameter_type ::= conformant_aggregation", + /* 124 */ "parameter_type ::= defined_type", + /* 125 */ "parameter_type ::= generic_type", + /* 126 */ "function_call ::= function_id actual_parameters", + /* 127 */ "function_decl ::= function_header action_body TOK_END_FUNCTION semicolon", + /* 128 */ "function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon", + /* 129 */ "fh_lineno ::= TOK_FUNCTION", + /* 130 */ "fh_push_scope ::= TOK_IDENTIFIER", + /* 131 */ "fh_plist ::= formal_parameter_list", + /* 132 */ "function_id ::= TOK_IDENTIFIER", + /* 133 */ "function_id ::= TOK_BUILTIN_FUNCTION", + /* 134 */ "conformant_aggregation ::= aggregate_type", + /* 135 */ "conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type", + /* 136 */ "conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type", + /* 137 */ "conformant_aggregation ::= TOK_BAG TOK_OF parameter_type", + /* 138 */ "conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type", + /* 139 */ "conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type", + /* 140 */ "conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type", + /* 141 */ "conformant_aggregation ::= TOK_SET TOK_OF parameter_type", + /* 142 */ "conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type", + /* 143 */ "generic_type ::= TOK_GENERIC", + /* 144 */ "generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER", + /* 145 */ "id_list ::= TOK_IDENTIFIER", + /* 146 */ "id_list ::= id_list TOK_COMMA TOK_IDENTIFIER", + /* 147 */ "identifier ::= TOK_SELF", + /* 148 */ "identifier ::= TOK_QUESTION_MARK", + /* 149 */ "identifier ::= TOK_IDENTIFIER", + /* 150 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon", + /* 151 */ "if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon", + /* 152 */ "include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon", + /* 153 */ "increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression", + /* 154 */ "initializer ::= TOK_ASSIGNMENT expression", + /* 155 */ "rename ::= TOK_IDENTIFIER", + /* 156 */ "rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER", + /* 157 */ "rename_list ::= rename", + /* 158 */ "rename_list ::= rename_list TOK_COMMA rename", + /* 159 */ "parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN", + /* 160 */ "reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon", + /* 161 */ "reference_clause ::= reference_head parened_rename_list semicolon", + /* 162 */ "reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER", + /* 163 */ "use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon", + /* 164 */ "use_clause ::= use_head parened_rename_list semicolon", + /* 165 */ "use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER", + /* 166 */ "interface_specification ::= use_clause", + /* 167 */ "interface_specification ::= reference_clause", + /* 168 */ "interface_specification_list ::=", + /* 169 */ "interface_specification_list ::= interface_specification_list interface_specification", + /* 170 */ "interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl", + /* 171 */ "set_or_bag_of_entity ::= defined_type", + /* 172 */ "set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type", + /* 173 */ "set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type", + /* 174 */ "set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type", + /* 175 */ "set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type", + /* 176 */ "inverse_attr_list ::= inverse_attr", + /* 177 */ "inverse_attr_list ::= inverse_attr_list inverse_attr", + /* 178 */ "inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon", + /* 179 */ "inverse_clause ::=", + /* 180 */ "inverse_clause ::= TOK_INVERSE inverse_attr_list", + /* 181 */ "bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET", + /* 182 */ "list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type", + /* 183 */ "list_type ::= TOK_LIST TOK_OF unique attribute_type", + /* 184 */ "literal ::= TOK_INTEGER_LITERAL", + /* 185 */ "literal ::= TOK_REAL_LITERAL", + /* 186 */ "literal ::= TOK_STRING_LITERAL", + /* 187 */ "literal ::= TOK_STRING_LITERAL_ENCODED", + /* 188 */ "literal ::= TOK_LOGICAL_LITERAL", + /* 189 */ "literal ::= TOK_BINARY_LITERAL", + /* 190 */ "literal ::= constant", + /* 191 */ "local_initializer ::= TOK_ASSIGNMENT expression", + /* 192 */ "local_variable ::= id_list TOK_COLON parameter_type semicolon", + /* 193 */ "local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon", + /* 194 */ "local_body ::=", + /* 195 */ "local_body ::= local_variable local_body", + /* 196 */ "local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off", + /* 197 */ "local_decl_rules_on ::=", + /* 198 */ "local_decl_rules_off ::=", + /* 199 */ "defined_type ::= TOK_IDENTIFIER", + /* 200 */ "defined_type_list ::= defined_type", + /* 201 */ "defined_type_list ::= defined_type_list TOK_COMMA defined_type", + /* 202 */ "nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN", + /* 203 */ "oneof_op ::= TOK_ONEOF", + /* 204 */ "optional_or_unique ::=", + /* 205 */ "optional_or_unique ::= TOK_OPTIONAL", + /* 206 */ "optional_or_unique ::= TOK_UNIQUE", + /* 207 */ "optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE", + /* 208 */ "optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL", + /* 209 */ "optional_fixed ::=", + /* 210 */ "optional_fixed ::= TOK_FIXED", + /* 211 */ "precision_spec ::=", + /* 212 */ "precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 213 */ "proc_call_statement ::= procedure_id actual_parameters semicolon", + /* 214 */ "proc_call_statement ::= procedure_id semicolon", + /* 215 */ "procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon", + /* 216 */ "procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon", + /* 217 */ "ph_push_scope ::= TOK_IDENTIFIER", + /* 218 */ "ph_get_line ::=", + /* 219 */ "procedure_id ::= TOK_IDENTIFIER", + /* 220 */ "procedure_id ::= TOK_BUILTIN_PROCEDURE", + /* 221 */ "group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 222 */ "qualifier ::= TOK_DOT TOK_IDENTIFIER", + /* 223 */ "qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER", + /* 224 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET", + /* 225 */ "qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET", + /* 226 */ "query_expression ::= query_start expression TOK_RIGHT_PAREN", + /* 227 */ "query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT", + /* 228 */ "rel_op ::= TOK_LESS_THAN", + /* 229 */ "rel_op ::= TOK_GREATER_THAN", + /* 230 */ "rel_op ::= TOK_EQUAL", + /* 231 */ "rel_op ::= TOK_LESS_EQUAL", + /* 232 */ "rel_op ::= TOK_GREATER_EQUAL", + /* 233 */ "rel_op ::= TOK_NOT_EQUAL", + /* 234 */ "rel_op ::= TOK_INST_EQUAL", + /* 235 */ "rel_op ::= TOK_INST_NOT_EQUAL", + /* 236 */ "repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 237 */ "repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon", + /* 238 */ "return_statement ::= TOK_RETURN semicolon", + /* 239 */ "return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon", + /* 240 */ "right_curl ::= TOK_RIGHT_CURL", + /* 241 */ "rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon", + /* 242 */ "rule_formal_parameter ::= TOK_IDENTIFIER", + /* 243 */ "rule_formal_parameter_list ::= rule_formal_parameter", + /* 244 */ "rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter", + /* 245 */ "rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon", + /* 246 */ "rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN", + /* 247 */ "rh_get_line ::=", + /* 248 */ "schema_body ::= interface_specification_list block_list", + /* 249 */ "schema_body ::= interface_specification_list constant_decl block_list", + /* 250 */ "schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon", + /* 251 */ "schema_decl ::= include_directive", + /* 252 */ "schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon", + /* 253 */ "select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 254 */ "semicolon ::= TOK_SEMICOLON", + /* 255 */ "set_type ::= TOK_SET bound_spec TOK_OF attribute_type", + /* 256 */ "set_type ::= TOK_SET TOK_OF attribute_type", + /* 257 */ "skip_statement ::= TOK_SKIP semicolon", + /* 258 */ "statement ::= alias_statement", + /* 259 */ "statement ::= assignment_statement", + /* 260 */ "statement ::= case_statement", + /* 261 */ "statement ::= compound_statement", + /* 262 */ "statement ::= escape_statement", + /* 263 */ "statement ::= if_statement", + /* 264 */ "statement ::= proc_call_statement", + /* 265 */ "statement ::= repeat_statement", + /* 266 */ "statement ::= return_statement", + /* 267 */ "statement ::= skip_statement", + /* 268 */ "statement_rep ::=", + /* 269 */ "statement_rep ::= semicolon statement_rep", + /* 270 */ "statement_rep ::= statement statement_rep", + /* 271 */ "subsuper_decl ::=", + /* 272 */ "subsuper_decl ::= supertype_decl", + /* 273 */ "subsuper_decl ::= subtype_decl", + /* 274 */ "subsuper_decl ::= supertype_decl subtype_decl", + /* 275 */ "subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN", + /* 276 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE", + /* 277 */ "supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 278 */ "supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 279 */ "supertype_expression ::= supertype_factor", + /* 280 */ "supertype_expression ::= supertype_expression TOK_AND supertype_factor", + /* 281 */ "supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor", + /* 282 */ "supertype_expression_list ::= supertype_expression", + /* 283 */ "supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression", + /* 284 */ "supertype_factor ::= identifier", + /* 285 */ "supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN", + /* 286 */ "supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN", + /* 287 */ "type ::= aggregation_type", + /* 288 */ "type ::= basic_type", + /* 289 */ "type ::= defined_type", + /* 290 */ "type ::= select_type", + /* 291 */ "type_item_body ::= enumeration_type", + /* 292 */ "type_item_body ::= type", + /* 293 */ "type_item ::= ti_start type_item_body semicolon", + /* 294 */ "ti_start ::= TOK_IDENTIFIER TOK_EQUAL", + /* 295 */ "type_decl ::= td_start TOK_END_TYPE semicolon", + /* 296 */ "td_start ::= TOK_TYPE type_item where_rule_OPT", + /* 297 */ "general_ref ::= assignable group_ref", + /* 298 */ "general_ref ::= assignable", + /* 299 */ "unary_expression ::= aggregate_initializer", + /* 300 */ "unary_expression ::= unary_expression qualifier", + /* 301 */ "unary_expression ::= literal", + /* 302 */ "unary_expression ::= function_call", + /* 303 */ "unary_expression ::= identifier", + /* 304 */ "unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN", + /* 305 */ "unary_expression ::= interval", + /* 306 */ "unary_expression ::= query_expression", + /* 307 */ "unary_expression ::= TOK_NOT unary_expression", + /* 308 */ "unary_expression ::= TOK_PLUS unary_expression", + /* 309 */ "unary_expression ::= TOK_MINUS unary_expression", + /* 310 */ "unique ::=", + /* 311 */ "unique ::= TOK_UNIQUE", + /* 312 */ "qualified_attr ::= attribute_decl", + /* 313 */ "qualified_attr_list ::= qualified_attr", + /* 314 */ "qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr", + /* 315 */ "labelled_attrib_list ::= qualified_attr_list semicolon", + /* 316 */ "labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon", + /* 317 */ "labelled_attrib_list_list ::= labelled_attrib_list", + /* 318 */ "labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list", + /* 319 */ "unique_clause ::=", + /* 320 */ "unique_clause ::= TOK_UNIQUE labelled_attrib_list_list", + /* 321 */ "until_control ::=", + /* 322 */ "until_control ::= TOK_UNTIL expression", + /* 323 */ "where_clause ::= expression semicolon", + /* 324 */ "where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon", + /* 325 */ "where_clause_list ::= where_clause", + /* 326 */ "where_clause_list ::= where_clause_list where_clause", + /* 327 */ "where_rule ::= TOK_WHERE where_clause_list", + /* 328 */ "where_rule_OPT ::=", + /* 329 */ "where_rule_OPT ::= where_rule", + /* 330 */ "while_control ::=", + /* 331 */ "while_control ::= TOK_WHILE expression", }; #endif /* NDEBUG */ @@ -1471,27 +1467,26 @@ static const char *const yyRuleName[] = { /* ** Try to increase the size of the parser stack. */ -static void yyGrowStack(yyParser *p) -{ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz * 2 + 256; - pNew = realloc(p->yystack, newSize * sizeof(pNew[0])); - if(pNew) { - p->yystack = pNew; - p->yystksz = newSize; +static void yyGrowStack(yyParser *p){ + int newSize; + yyStackEntry *pNew; + + newSize = p->yystksz*2 + 256; + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + if( pNew ){ + p->yystack = pNew; + p->yystksz = newSize; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } -#endif + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", + yyTracePrompt, p->yystksz); } +#endif + } } #endif -/* +/* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. @@ -1503,22 +1498,21 @@ static void yyGrowStack(yyParser *p) ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(size_t)) -{ - yyParser *pParser; - pParser = (yyParser *)(*mallocProc)((size_t)sizeof(yyParser)); - if(pParser) { - pParser->yyidx = -1; +void *ParseAlloc(void *(*mallocProc)(size_t)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); + if( pParser ){ + pParser->yyidx = -1; #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; + pParser->yyidxMax = 0; #endif #if YYSTACKDEPTH<=0 - pParser->yystack = NULL; - pParser->yystksz = 0; - yyGrowStack(pParser); + pParser->yystack = NULL; + pParser->yystksz = 0; + yyGrowStack(pParser); #endif - } - return pParser; + } + return pParser; } /* The following function deletes the value associated with a @@ -1527,36 +1521,35 @@ void *ParseAlloc(void *(*mallocProc)(size_t)) ** the value. */ static void yy_destructor( - yyParser *yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE *yypminor /* The object to be destroyed */ -) -{ - ParseARG_FETCH; - switch(yymajor) { - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 122: { /* statement_list */ + yyParser *yypParser, /* The parser */ + YYCODETYPE yymajor, /* Type code for object to destroy */ + YYMINORTYPE *yypminor /* The object to be destroyed */ +){ + ParseARG_FETCH; + switch( yymajor ){ + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 122: /* statement_list */ +{ #line 124 "expparse.y" - if(parseData.scanner == NULL) { - (yypminor->yy0).string = (char *)NULL; - } + if (parseData.scanner == NULL) { + (yypminor->yy0).string = (char*)NULL; + } #line 1549 "expparse.c" - } - break; - default: - break; /* If no destructor action specified: do nothing */ - } +} + break; + default: break; /* If no destructor action specified: do nothing */ + } } /* @@ -1567,31 +1560,28 @@ static void yy_destructor( ** ** Return the major token number for the symbol popped. */ -static int yy_pop_parser_stack(yyParser *pParser) -{ - YYCODETYPE yymajor; - yyStackEntry *yytos; +static int yy_pop_parser_stack(yyParser *pParser){ + YYCODETYPE yymajor; + yyStackEntry *yytos; - if(pParser->yyidx < 0) { - return 0; - } + if( pParser->yyidx<0 ) return 0; - yytos = &pParser->yystack[pParser->yyidx]; + yytos = &pParser->yystack[pParser->yyidx]; #ifndef NDEBUG - if(yyTraceFILE && pParser->yyidx >= 0) { - fprintf(yyTraceFILE, "%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } + if( yyTraceFILE && pParser->yyidx>=0 ){ + fprintf(yyTraceFILE,"%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos->major]); + } #endif - yymajor = yytos->major; - yy_destructor(pParser, yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; + yymajor = yytos->major; + yy_destructor(pParser, yymajor, &yytos->minor); + pParser->yyidx--; + return yymajor; } -/* +/* ** Deallocate and destroy a parser. Destructors are all called for ** all stack elements before shutting the parser down. ** @@ -1604,31 +1594,25 @@ static int yy_pop_parser_stack(yyParser *pParser) **
          */ void ParseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void *) /* Function used to reclaim memory */ -) -{ - yyParser *pParser = (yyParser *)p; - if(pParser == 0) { - return; - } - while(pParser->yyidx >= 0) { - yy_pop_parser_stack(pParser); - } + void *p, /* The parser to be deleted */ + void (*freeProc)(void*) /* Function used to reclaim memory */ +){ + yyParser *pParser = (yyParser*)p; + if( pParser==0 ) return; + while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 - free(pParser->yystack); + free(pParser->yystack); #endif - (*freeProc)((void *)pParser); + (*freeProc)((void*)pParser); } /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH -int ParseStackPeak(void *p) -{ - yyParser *pParser = (yyParser *)p; - return pParser->yyidxMax; +int ParseStackPeak(void *p){ + yyParser *pParser = (yyParser*)p; + return pParser->yyidxMax; } #endif @@ -1641,61 +1625,60 @@ int ParseStackPeak(void *p) ** return YY_NO_ACTION. */ static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -) -{ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if(stateno > YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno]) == YY_SHIFT_USE_DFLT) { - return yy_default[stateno]; - } - assert(iLookAhead != YYNOCODE); - i += iLookAhead; - if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { - if(iLookAhead > 0) { + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->yystack[pParser->yyidx].stateno; + + if( stateno>YY_SHIFT_COUNT + || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ + return yy_default[stateno]; + } + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; + if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ + if( iLookAhead>0 ){ #ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if(iLookAhead < sizeof(yyFallback) / sizeof(yyFallback[0]) - && (iFallback = yyFallback[iLookAhead]) != 0) { + YYCODETYPE iFallback; /* Fallback token */ + if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + } #endif - return yy_find_shift_action(pParser, iFallback); - } + return yy_find_shift_action(pParser, iFallback); + } #endif #ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( + { + int j = i - iLookAhead + YYWILDCARD; + if( #if YY_SHIFT_MIN+YYWILDCARD<0 - j >= 0 && + j>=0 && #endif #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j < YY_ACTTAB_COUNT && + j %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } #endif /* NDEBUG */ - return yy_action[j]; - } - } -#endif /* YYWILDCARD */ + return yy_action[j]; } - return yy_default[stateno]; - } else { - return yy_action[i]; + } +#endif /* YYWILDCARD */ } + return yy_default[stateno]; + }else{ + return yy_action[i]; + } } /* @@ -1707,103 +1690,97 @@ static int yy_find_shift_action( ** return YY_NO_ACTION. */ static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -) -{ - int i; + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; #ifdef YYERRORSYMBOL - if(stateno > YY_REDUCE_COUNT) { - return yy_default[stateno]; - } + if( stateno>YY_REDUCE_COUNT ){ + return yy_default[stateno]; + } #else - assert(stateno <= YY_REDUCE_COUNT); + assert( stateno<=YY_REDUCE_COUNT ); #endif - i = yy_reduce_ofst[stateno]; - assert(i != YY_REDUCE_USE_DFLT); - assert(iLookAhead != YYNOCODE); - i += iLookAhead; + i = yy_reduce_ofst[stateno]; + assert( i!=YY_REDUCE_USE_DFLT ); + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; #ifdef YYERRORSYMBOL - if(i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { - return yy_default[stateno]; - } + if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ + return yy_default[stateno]; + } #else - assert(i >= 0 && i < YY_ACTTAB_COUNT); - assert(yy_lookahead[i] == iLookAhead); + assert( i>=0 && iyyidx--; +static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ + ParseARG_FETCH; + yypParser->yyidx--; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will execute if the parser - ** stack every overflows */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ #line 2440 "expparse.y" fprintf(stderr, "Express parser experienced stack overflow.\n"); fprintf(stderr, "Last token had value %x\n", yypMinor->yy0.val); #line 1738 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ } /* ** Perform a shift action. */ static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ -) -{ - yyStackEntry *yytos; - yypParser->yyidx++; + yyParser *yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ +){ + yyStackEntry *yytos; + yypParser->yyidx++; #ifdef YYTRACKMAXSTACKDEPTH - if(yypParser->yyidx > yypParser->yyidxMax) { - yypParser->yyidxMax = yypParser->yyidx; - } + if( yypParser->yyidx>yypParser->yyidxMax ){ + yypParser->yyidxMax = yypParser->yyidx; + } #endif -#if YYSTACKDEPTH>0 - if(yypParser->yyidx >= YYSTACKDEPTH) { - yyStackOverflow(yypParser, yypMinor); - return; - } +#if YYSTACKDEPTH>0 + if( yypParser->yyidx>=YYSTACKDEPTH ){ + yyStackOverflow(yypParser, yypMinor); + return; + } #else - if(yypParser->yyidx >= yypParser->yystksz) { - yyGrowStack(yypParser); - if(yypParser->yyidx >= yypParser->yystksz) { - yyStackOverflow(yypParser, yypMinor); - return; - } + if( yypParser->yyidx>=yypParser->yystksz ){ + yyGrowStack(yypParser); + if( yypParser->yyidx>=yypParser->yystksz ){ + yyStackOverflow(yypParser, yypMinor); + return; } + } #endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; - yytos->minor = *yypMinor; + yytos = &yypParser->yystack[yypParser->yyidx]; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; + yytos->minor = *yypMinor; #ifndef NDEBUG - if(yyTraceFILE && yypParser->yyidx > 0) { - int i; - fprintf(yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState); - fprintf(yyTraceFILE, "%sStack:", yyTracePrompt); - for(i = 1; i <= yypParser->yyidx; i++) { - fprintf(yyTraceFILE, " %s", yyTokenName[yypParser->yystack[i].major]); - } - fprintf(yyTraceFILE, "\n"); - } + if( yyTraceFILE && yypParser->yyidx>0 ){ + int i; + fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); + fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); + for(i=1; i<=yypParser->yyidx; i++) + fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); + fprintf(yyTraceFILE,"\n"); + } #endif } @@ -1811,2744 +1788,2639 @@ static void yy_shift( ** is used during the reduce. */ static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } yyRuleInfo[] = { - { 156, 2 }, - { 233, 1 }, - { 233, 1 }, - { 233, 1 }, - { 232, 0 }, - { 232, 2 }, - { 157, 3 }, - { 157, 2 }, - { 127, 2 }, - { 127, 3 }, - { 126, 1 }, - { 158, 1 }, - { 158, 3 }, - { 158, 3 }, - { 158, 5 }, - { 217, 3 }, - { 217, 5 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 218, 1 }, - { 195, 9 }, - { 238, 0 }, - { 219, 5 }, - { 128, 2 }, - { 128, 1 }, - { 196, 4 }, - { 211, 1 }, - { 211, 1 }, - { 211, 1 }, - { 159, 0 }, - { 159, 2 }, - { 220, 4 }, - { 220, 3 }, - { 215, 1 }, - { 215, 2 }, - { 215, 2 }, - { 215, 1 }, - { 215, 1 }, - { 215, 3 }, - { 215, 3 }, - { 239, 0 }, - { 239, 2 }, - { 240, 1 }, - { 240, 1 }, - { 240, 1 }, - { 130, 0 }, - { 130, 2 }, - { 226, 5 }, - { 123, 3 }, - { 160, 0 }, - { 160, 2 }, - { 161, 2 }, - { 162, 1 }, - { 162, 3 }, - { 124, 0 }, - { 124, 3 }, - { 197, 6 }, - { 198, 4 }, - { 131, 1 }, - { 131, 1 }, - { 243, 6 }, - { 244, 0 }, - { 244, 2 }, - { 235, 4 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 234, 1 }, - { 164, 0 }, - { 164, 2 }, - { 229, 5 }, - { 183, 1 }, - { 183, 2 }, - { 125, 5 }, - { 245, 6 }, - { 249, 2 }, - { 250, 3 }, - { 199, 2 }, - { 129, 1 }, - { 129, 5 }, - { 182, 1 }, - { 182, 3 }, - { 190, 0 }, - { 190, 1 }, - { 165, 5 }, - { 251, 1 }, - { 252, 1 }, - { 252, 2 }, - { 132, 1 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 132, 3 }, - { 144, 1 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 144, 3 }, - { 166, 1 }, - { 166, 3 }, - { 191, 0 }, - { 191, 1 }, - { 167, 4 }, - { 168, 0 }, - { 168, 3 }, - { 169, 1 }, - { 169, 3 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 213, 1 }, - { 133, 2 }, - { 246, 4 }, - { 149, 6 }, - { 150, 1 }, - { 254, 1 }, - { 255, 1 }, - { 209, 1 }, - { 209, 1 }, - { 221, 1 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 221, 4 }, - { 221, 5 }, - { 221, 3 }, - { 221, 4 }, - { 214, 1 }, - { 214, 3 }, - { 170, 1 }, - { 170, 3 }, - { 136, 1 }, - { 136, 1 }, - { 136, 1 }, - { 200, 6 }, - { 200, 8 }, - { 241, 3 }, - { 256, 6 }, - { 137, 2 }, - { 257, 1 }, - { 257, 3 }, - { 258, 1 }, - { 258, 3 }, - { 259, 3 }, - { 260, 4 }, - { 260, 3 }, - { 261, 3 }, - { 262, 4 }, - { 262, 3 }, - { 263, 3 }, - { 264, 1 }, - { 264, 1 }, - { 265, 0 }, - { 265, 2 }, - { 138, 7 }, - { 224, 1 }, - { 224, 3 }, - { 224, 4 }, - { 224, 4 }, - { 224, 3 }, - { 180, 1 }, - { 180, 2 }, - { 228, 6 }, - { 181, 0 }, - { 181, 2 }, - { 227, 5 }, - { 222, 5 }, - { 222, 4 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 139, 1 }, - { 140, 2 }, - { 267, 4 }, - { 267, 5 }, - { 268, 0 }, - { 268, 2 }, - { 236, 6 }, - { 269, 0 }, - { 270, 0 }, - { 212, 1 }, - { 171, 1 }, - { 171, 3 }, - { 172, 3 }, - { 271, 1 }, - { 188, 0 }, - { 188, 1 }, - { 188, 1 }, - { 188, 2 }, - { 188, 2 }, - { 189, 0 }, - { 189, 1 }, - { 141, 0 }, - { 141, 3 }, - { 201, 3 }, - { 201, 2 }, - { 247, 4 }, - { 154, 5 }, - { 272, 1 }, - { 155, 0 }, - { 210, 1 }, - { 210, 1 }, - { 135, 2 }, - { 194, 2 }, - { 194, 2 }, - { 194, 3 }, - { 194, 5 }, - { 142, 3 }, - { 143, 6 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 187, 1 }, - { 202, 8 }, - { 202, 7 }, - { 203, 2 }, - { 203, 5 }, - { 266, 1 }, - { 242, 5 }, - { 230, 1 }, - { 185, 1 }, - { 185, 3 }, - { 151, 4 }, - { 152, 5 }, - { 153, 0 }, - { 273, 2 }, - { 273, 3 }, - { 253, 4 }, - { 253, 1 }, - { 274, 3 }, - { 216, 4 }, - { 237, 1 }, - { 223, 4 }, - { 223, 3 }, - { 204, 2 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 205, 1 }, - { 173, 0 }, - { 173, 2 }, - { 173, 2 }, - { 206, 0 }, - { 206, 1 }, - { 206, 1 }, - { 206, 2 }, - { 174, 5 }, - { 207, 2 }, - { 207, 5 }, - { 207, 6 }, - { 146, 1 }, - { 146, 3 }, - { 146, 3 }, - { 177, 1 }, - { 177, 3 }, - { 208, 1 }, - { 208, 4 }, - { 208, 3 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 225, 1 }, - { 275, 1 }, - { 275, 1 }, - { 276, 3 }, - { 277, 2 }, - { 248, 3 }, - { 278, 3 }, - { 134, 2 }, - { 134, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 3 }, - { 145, 1 }, - { 145, 1 }, - { 145, 2 }, - { 145, 2 }, - { 145, 2 }, - { 192, 0 }, - { 192, 1 }, - { 193, 1 }, - { 186, 1 }, - { 186, 3 }, - { 179, 2 }, - { 179, 4 }, - { 178, 1 }, - { 178, 2 }, - { 184, 0 }, - { 184, 2 }, - { 147, 0 }, - { 147, 2 }, - { 231, 2 }, - { 231, 4 }, - { 163, 1 }, - { 163, 2 }, - { 175, 2 }, - { 176, 0 }, - { 176, 1 }, - { 148, 0 }, - { 148, 2 }, + { 156, 2 }, + { 233, 1 }, + { 233, 1 }, + { 233, 1 }, + { 232, 0 }, + { 232, 2 }, + { 157, 3 }, + { 157, 2 }, + { 127, 2 }, + { 127, 3 }, + { 126, 1 }, + { 158, 1 }, + { 158, 3 }, + { 158, 3 }, + { 158, 5 }, + { 217, 3 }, + { 217, 5 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 218, 1 }, + { 195, 9 }, + { 238, 0 }, + { 219, 5 }, + { 128, 2 }, + { 128, 1 }, + { 196, 4 }, + { 211, 1 }, + { 211, 1 }, + { 211, 1 }, + { 159, 0 }, + { 159, 2 }, + { 220, 4 }, + { 220, 3 }, + { 215, 1 }, + { 215, 2 }, + { 215, 2 }, + { 215, 1 }, + { 215, 1 }, + { 215, 3 }, + { 215, 3 }, + { 239, 0 }, + { 239, 2 }, + { 240, 1 }, + { 240, 1 }, + { 240, 1 }, + { 130, 0 }, + { 130, 2 }, + { 226, 5 }, + { 123, 3 }, + { 160, 0 }, + { 160, 2 }, + { 161, 2 }, + { 162, 1 }, + { 162, 3 }, + { 124, 0 }, + { 124, 3 }, + { 197, 6 }, + { 198, 4 }, + { 131, 1 }, + { 131, 1 }, + { 243, 6 }, + { 244, 0 }, + { 244, 2 }, + { 235, 4 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 234, 1 }, + { 164, 0 }, + { 164, 2 }, + { 229, 5 }, + { 183, 1 }, + { 183, 2 }, + { 125, 5 }, + { 245, 6 }, + { 249, 2 }, + { 250, 3 }, + { 199, 2 }, + { 129, 1 }, + { 129, 5 }, + { 182, 1 }, + { 182, 3 }, + { 190, 0 }, + { 190, 1 }, + { 165, 5 }, + { 251, 1 }, + { 252, 1 }, + { 252, 2 }, + { 132, 1 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 132, 3 }, + { 144, 1 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 144, 3 }, + { 166, 1 }, + { 166, 3 }, + { 191, 0 }, + { 191, 1 }, + { 167, 4 }, + { 168, 0 }, + { 168, 3 }, + { 169, 1 }, + { 169, 3 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 213, 1 }, + { 133, 2 }, + { 246, 4 }, + { 149, 6 }, + { 150, 1 }, + { 254, 1 }, + { 255, 1 }, + { 209, 1 }, + { 209, 1 }, + { 221, 1 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 221, 4 }, + { 221, 5 }, + { 221, 3 }, + { 221, 4 }, + { 214, 1 }, + { 214, 3 }, + { 170, 1 }, + { 170, 3 }, + { 136, 1 }, + { 136, 1 }, + { 136, 1 }, + { 200, 6 }, + { 200, 8 }, + { 241, 3 }, + { 256, 6 }, + { 137, 2 }, + { 257, 1 }, + { 257, 3 }, + { 258, 1 }, + { 258, 3 }, + { 259, 3 }, + { 260, 4 }, + { 260, 3 }, + { 261, 3 }, + { 262, 4 }, + { 262, 3 }, + { 263, 3 }, + { 264, 1 }, + { 264, 1 }, + { 265, 0 }, + { 265, 2 }, + { 138, 7 }, + { 224, 1 }, + { 224, 3 }, + { 224, 4 }, + { 224, 4 }, + { 224, 3 }, + { 180, 1 }, + { 180, 2 }, + { 228, 6 }, + { 181, 0 }, + { 181, 2 }, + { 227, 5 }, + { 222, 5 }, + { 222, 4 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 139, 1 }, + { 140, 2 }, + { 267, 4 }, + { 267, 5 }, + { 268, 0 }, + { 268, 2 }, + { 236, 6 }, + { 269, 0 }, + { 270, 0 }, + { 212, 1 }, + { 171, 1 }, + { 171, 3 }, + { 172, 3 }, + { 271, 1 }, + { 188, 0 }, + { 188, 1 }, + { 188, 1 }, + { 188, 2 }, + { 188, 2 }, + { 189, 0 }, + { 189, 1 }, + { 141, 0 }, + { 141, 3 }, + { 201, 3 }, + { 201, 2 }, + { 247, 4 }, + { 154, 5 }, + { 272, 1 }, + { 155, 0 }, + { 210, 1 }, + { 210, 1 }, + { 135, 2 }, + { 194, 2 }, + { 194, 2 }, + { 194, 3 }, + { 194, 5 }, + { 142, 3 }, + { 143, 6 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 187, 1 }, + { 202, 8 }, + { 202, 7 }, + { 203, 2 }, + { 203, 5 }, + { 266, 1 }, + { 242, 5 }, + { 230, 1 }, + { 185, 1 }, + { 185, 3 }, + { 151, 4 }, + { 152, 5 }, + { 153, 0 }, + { 273, 2 }, + { 273, 3 }, + { 253, 4 }, + { 253, 1 }, + { 274, 3 }, + { 216, 4 }, + { 237, 1 }, + { 223, 4 }, + { 223, 3 }, + { 204, 2 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 205, 1 }, + { 173, 0 }, + { 173, 2 }, + { 173, 2 }, + { 206, 0 }, + { 206, 1 }, + { 206, 1 }, + { 206, 2 }, + { 174, 5 }, + { 207, 2 }, + { 207, 5 }, + { 207, 6 }, + { 146, 1 }, + { 146, 3 }, + { 146, 3 }, + { 177, 1 }, + { 177, 3 }, + { 208, 1 }, + { 208, 4 }, + { 208, 3 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 225, 1 }, + { 275, 1 }, + { 275, 1 }, + { 276, 3 }, + { 277, 2 }, + { 248, 3 }, + { 278, 3 }, + { 134, 2 }, + { 134, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 1 }, + { 145, 1 }, + { 145, 1 }, + { 145, 3 }, + { 145, 1 }, + { 145, 1 }, + { 145, 2 }, + { 145, 2 }, + { 145, 2 }, + { 192, 0 }, + { 192, 1 }, + { 193, 1 }, + { 186, 1 }, + { 186, 3 }, + { 179, 2 }, + { 179, 4 }, + { 178, 1 }, + { 178, 2 }, + { 184, 0 }, + { 184, 2 }, + { 147, 0 }, + { 147, 2 }, + { 231, 2 }, + { 231, 4 }, + { 163, 1 }, + { 163, 2 }, + { 175, 2 }, + { 176, 0 }, + { 176, 1 }, + { 148, 0 }, + { 148, 2 }, }; -static void yy_accept(yyParser *); /* Forward Declaration */ +static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -) -{ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - ParseARG_FETCH; - - yymsp = &yypParser->yystack[yypParser->yyidx]; - - if(yyruleno >= 0) { + yyParser *yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ +){ + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yyStackEntry *yymsp; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + ParseARG_FETCH; + + yymsp = &yypParser->yystack[yypParser->yyidx]; + + if( yyruleno>=0 ) { #ifndef NDEBUG - if(yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0]))) { - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } - } -#endif /* NDEBUG */ - } else { - /* invalid rule number range */ - return; + if ( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0]))) { + if (yyTraceFILE) { + fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno]); } - - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - /*memset(&yygotominor, 0, sizeof(yygotominor));*/ - yygotominor = yyzerominor; - - - switch(yyruleno) { - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line - ** { ... } // User supplied code - ** #line - ** break; - */ - case 0: /* action_body ::= action_body_item_rep statement_rep */ - case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ - yytestcase(yyruleno == 70); - case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ - yytestcase(yyruleno == 180); - case 269: /* statement_rep ::= semicolon statement_rep */ - yytestcase(yyruleno == 269); - case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ - yytestcase(yyruleno == 320); - case 327: /* where_rule ::= TOK_WHERE where_clause_list */ - yytestcase(yyruleno == 327); - case 329: /* where_rule_OPT ::= where_rule */ - yytestcase(yyruleno == 329); + } +#endif /* NDEBUG */ + } else { + /* invalid rule number range */ + return; + } + + + /* Silence complaints from purify about yygotominor being uninitialized + ** in some cases when it is copied into the stack after the following + ** switch. yygotominor is uninitialized when a rule reduces that does + ** not set the value of its left-hand side nonterminal. Leaving the + ** value of the nonterminal uninitialized is utterly harmless as long + ** as the value is never used. So really the only thing this code + ** accomplishes is to quieten purify. + ** + ** 2007-01-16: The wireshark project (www.wireshark.org) reports that + ** without this code, their parser segfaults. I'm not sure what there + ** parser is doing to make this happen. This is the second bug report + ** from wireshark this week. Clearly they are stressing Lemon in ways + ** that it has not been previously stressed... (SQLite ticket #2172) + */ + /*memset(&yygotominor, 0, sizeof(yygotominor));*/ + yygotominor = yyzerominor; + + + switch( yyruleno ){ + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** #line + ** { ... } // User supplied code + ** #line + ** break; + */ + case 0: /* action_body ::= action_body_item_rep statement_rep */ + case 70: /* derive_decl ::= TOK_DERIVE derived_attribute_rep */ yytestcase(yyruleno==70); + case 180: /* inverse_clause ::= TOK_INVERSE inverse_attr_list */ yytestcase(yyruleno==180); + case 269: /* statement_rep ::= semicolon statement_rep */ yytestcase(yyruleno==269); + case 320: /* unique_clause ::= TOK_UNIQUE labelled_attrib_list_list */ yytestcase(yyruleno==320); + case 327: /* where_rule ::= TOK_WHERE where_clause_list */ yytestcase(yyruleno==327); + case 329: /* where_rule_OPT ::= where_rule */ yytestcase(yyruleno==329); #line 297 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; - } +{ + yygotominor.yy371 = yymsp[0].minor.yy371; +} #line 2201 "expparse.c" - break; - case 1: /* action_body_item ::= declaration */ - case 2: /* action_body_item ::= constant_decl */ - yytestcase(yyruleno == 2); - case 3: /* action_body_item ::= local_decl */ - yytestcase(yyruleno == 3); - case 43: /* block_member ::= declaration */ - yytestcase(yyruleno == 43); - case 44: /* block_member ::= include_directive */ - yytestcase(yyruleno == 44); - case 45: /* block_member ::= rule_decl */ - yytestcase(yyruleno == 45); - case 65: /* declaration ::= entity_decl */ - yytestcase(yyruleno == 65); - case 66: /* declaration ::= function_decl */ - yytestcase(yyruleno == 66); - case 67: /* declaration ::= procedure_decl */ - yytestcase(yyruleno == 67); - case 68: /* declaration ::= type_decl */ - yytestcase(yyruleno == 68); - case 87: /* schema_decl_list ::= schema_decl */ - yytestcase(yyruleno == 87); - case 157: /* rename_list ::= rename */ - yytestcase(yyruleno == 157); - case 166: /* interface_specification ::= use_clause */ - yytestcase(yyruleno == 166); - case 167: /* interface_specification ::= reference_clause */ - yytestcase(yyruleno == 167); - case 203: /* oneof_op ::= TOK_ONEOF */ - yytestcase(yyruleno == 203); - case 251: /* schema_decl ::= include_directive */ - yytestcase(yyruleno == 251); - case 291: /* type_item_body ::= enumeration_type */ - yytestcase(yyruleno == 291); + break; + case 1: /* action_body_item ::= declaration */ + case 2: /* action_body_item ::= constant_decl */ yytestcase(yyruleno==2); + case 3: /* action_body_item ::= local_decl */ yytestcase(yyruleno==3); + case 43: /* block_member ::= declaration */ yytestcase(yyruleno==43); + case 44: /* block_member ::= include_directive */ yytestcase(yyruleno==44); + case 45: /* block_member ::= rule_decl */ yytestcase(yyruleno==45); + case 65: /* declaration ::= entity_decl */ yytestcase(yyruleno==65); + case 66: /* declaration ::= function_decl */ yytestcase(yyruleno==66); + case 67: /* declaration ::= procedure_decl */ yytestcase(yyruleno==67); + case 68: /* declaration ::= type_decl */ yytestcase(yyruleno==68); + case 87: /* schema_decl_list ::= schema_decl */ yytestcase(yyruleno==87); + case 157: /* rename_list ::= rename */ yytestcase(yyruleno==157); + case 166: /* interface_specification ::= use_clause */ yytestcase(yyruleno==166); + case 167: /* interface_specification ::= reference_clause */ yytestcase(yyruleno==167); + case 203: /* oneof_op ::= TOK_ONEOF */ yytestcase(yyruleno==203); + case 251: /* schema_decl ::= include_directive */ yytestcase(yyruleno==251); + case 291: /* type_item_body ::= enumeration_type */ yytestcase(yyruleno==291); #line 303 "expparse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[0].minor.yy0; +} #line 2224 "expparse.c" - break; - case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ - case 42: /* block_list ::= block_list block_member */ - yytestcase(yyruleno == 42); - case 63: /* constant_body_list ::= constant_body constant_body_list */ - yytestcase(yyruleno == 63); - case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ - yytestcase(yyruleno == 88); - case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ - yytestcase(yyruleno == 169); - case 195: /* local_body ::= local_variable local_body */ - yytestcase(yyruleno == 195); - case 248: /* schema_body ::= interface_specification_list block_list */ - yytestcase(yyruleno == 248); + break; + case 5: /* action_body_item_rep ::= action_body_item action_body_item_rep */ + case 42: /* block_list ::= block_list block_member */ yytestcase(yyruleno==42); + case 63: /* constant_body_list ::= constant_body constant_body_list */ yytestcase(yyruleno==63); + case 88: /* schema_decl_list ::= schema_decl_list schema_decl */ yytestcase(yyruleno==88); + case 169: /* interface_specification_list ::= interface_specification_list interface_specification */ yytestcase(yyruleno==169); + case 195: /* local_body ::= local_variable local_body */ yytestcase(yyruleno==195); + case 248: /* schema_body ::= interface_specification_list block_list */ yytestcase(yyruleno==248); #line 320 "expparse.y" - { - yygotominor.yy0 = yymsp[-1].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-1].minor.yy0; +} #line 2237 "expparse.c" - break; - case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ - case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 202); - case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 275); + break; + case 6: /* actual_parameters ::= TOK_LEFT_PAREN expression_list TOK_RIGHT_PAREN */ + case 202: /* nested_id_list ::= TOK_LEFT_PAREN id_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==202); + case 275: /* subtype_decl ::= TOK_SUBTYPE TOK_OF TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==275); #line 337 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 2246 "expparse.c" - break; - case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ - case 319: /* unique_clause ::= */ - yytestcase(yyruleno == 319); + break; + case 7: /* actual_parameters ::= TOK_LEFT_PAREN TOK_RIGHT_PAREN */ + case 319: /* unique_clause ::= */ yytestcase(yyruleno==319); #line 341 "expparse.y" - { - yygotominor.yy371 = 0; - } +{ + yygotominor.yy371 = 0; +} #line 2254 "expparse.c" - break; - case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ + break; + case 8: /* aggregate_initializer ::= TOK_LEFT_BRACKET TOK_RIGHT_BRACKET */ #line 347 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = LISTcreate(); - } +{ + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = LISTcreate(); +} #line 2262 "expparse.c" - break; - case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ + break; + case 9: /* aggregate_initializer ::= TOK_LEFT_BRACKET aggregate_init_body TOK_RIGHT_BRACKET */ #line 353 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Aggregate); - yygotominor.yy401->u.list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy401 = EXPcreate(Type_Aggregate); + yygotominor.yy401->u.list = yymsp[-1].minor.yy371; +} #line 2270 "expparse.c" - break; - case 10: /* aggregate_init_element ::= expression */ - case 25: /* assignable ::= identifier */ - yytestcase(yyruleno == 25); - case 47: /* by_expression ::= TOK_BY expression */ - yytestcase(yyruleno == 47); - case 89: /* expression ::= simple_expression */ - yytestcase(yyruleno == 89); - case 104: /* simple_expression ::= unary_expression */ - yytestcase(yyruleno == 104); - case 154: /* initializer ::= TOK_ASSIGNMENT expression */ - yytestcase(yyruleno == 154); - case 190: /* literal ::= constant */ - yytestcase(yyruleno == 190); - case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ - yytestcase(yyruleno == 191); - case 298: /* general_ref ::= assignable */ - yytestcase(yyruleno == 298); - case 299: /* unary_expression ::= aggregate_initializer */ - yytestcase(yyruleno == 299); - case 301: /* unary_expression ::= literal */ - yytestcase(yyruleno == 301); - case 302: /* unary_expression ::= function_call */ - yytestcase(yyruleno == 302); - case 303: /* unary_expression ::= identifier */ - yytestcase(yyruleno == 303); - case 305: /* unary_expression ::= interval */ - yytestcase(yyruleno == 305); - case 306: /* unary_expression ::= query_expression */ - yytestcase(yyruleno == 306); - case 308: /* unary_expression ::= TOK_PLUS unary_expression */ - yytestcase(yyruleno == 308); - case 312: /* qualified_attr ::= attribute_decl */ - yytestcase(yyruleno == 312); - case 322: /* until_control ::= TOK_UNTIL expression */ - yytestcase(yyruleno == 322); - case 331: /* while_control ::= TOK_WHILE expression */ - yytestcase(yyruleno == 331); + break; + case 10: /* aggregate_init_element ::= expression */ + case 25: /* assignable ::= identifier */ yytestcase(yyruleno==25); + case 47: /* by_expression ::= TOK_BY expression */ yytestcase(yyruleno==47); + case 89: /* expression ::= simple_expression */ yytestcase(yyruleno==89); + case 104: /* simple_expression ::= unary_expression */ yytestcase(yyruleno==104); + case 154: /* initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==154); + case 190: /* literal ::= constant */ yytestcase(yyruleno==190); + case 191: /* local_initializer ::= TOK_ASSIGNMENT expression */ yytestcase(yyruleno==191); + case 298: /* general_ref ::= assignable */ yytestcase(yyruleno==298); + case 299: /* unary_expression ::= aggregate_initializer */ yytestcase(yyruleno==299); + case 301: /* unary_expression ::= literal */ yytestcase(yyruleno==301); + case 302: /* unary_expression ::= function_call */ yytestcase(yyruleno==302); + case 303: /* unary_expression ::= identifier */ yytestcase(yyruleno==303); + case 305: /* unary_expression ::= interval */ yytestcase(yyruleno==305); + case 306: /* unary_expression ::= query_expression */ yytestcase(yyruleno==306); + case 308: /* unary_expression ::= TOK_PLUS unary_expression */ yytestcase(yyruleno==308); + case 312: /* qualified_attr ::= attribute_decl */ yytestcase(yyruleno==312); + case 322: /* until_control ::= TOK_UNTIL expression */ yytestcase(yyruleno==322); + case 331: /* while_control ::= TOK_WHILE expression */ yytestcase(yyruleno==331); #line 359 "expparse.y" - { - yygotominor.yy401 = yymsp[0].minor.yy401; - } +{ + yygotominor.yy401 = yymsp[0].minor.yy401; +} #line 2295 "expparse.c" - break; - case 11: /* aggregate_init_body ::= aggregate_init_element */ - case 113: /* expression_list ::= expression */ - yytestcase(yyruleno == 113); - case 282: /* supertype_expression_list ::= supertype_expression */ - yytestcase(yyruleno == 282); - case 313: /* qualified_attr_list ::= qualified_attr */ - yytestcase(yyruleno == 313); + break; + case 11: /* aggregate_init_body ::= aggregate_init_element */ + case 113: /* expression_list ::= expression */ yytestcase(yyruleno==113); + case 282: /* supertype_expression_list ::= supertype_expression */ yytestcase(yyruleno==282); + case 313: /* qualified_attr_list ::= qualified_attr */ yytestcase(yyruleno==313); #line 364 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2306 "expparse.c" - break; - case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ + break; + case 12: /* aggregate_init_body ::= aggregate_init_element TOK_COLON expression */ #line 369 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; - } + yymsp[0].minor.yy401->type = Type_Repeat; +} #line 2318 "expparse.c" - break; - case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ + break; + case 13: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element */ #line 379 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +} #line 2328 "expparse.c" - break; - case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ + break; + case 14: /* aggregate_init_body ::= aggregate_init_body TOK_COMMA aggregate_init_element TOK_COLON expression */ #line 387 "expparse.y" - { - yygotominor.yy371 = yymsp[-4].minor.yy371; +{ + yygotominor.yy371 = yymsp[-4].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[-2].minor.yy401); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - yymsp[0].minor.yy401->type = Type_Repeat; - } + yymsp[0].minor.yy401->type = Type_Repeat; +} #line 2340 "expparse.c" - break; - case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ + break; + case 15: /* aggregate_type ::= TOK_AGGREGATE TOK_OF parameter_type */ #line 397 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - - if(tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } - } +{ + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + + if (tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } +} #line 2356 "expparse.c" - break; - case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ + break; + case 16: /* aggregate_type ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER TOK_OF parameter_type */ #line 411 "expparse.y" - { - Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); - - if(t) { - SCOPEadd_super(t); - yygotominor.yy477 = TYPEBODYcreate(aggregate_); - yygotominor.yy477->tag = t; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } - } +{ + Type t = TYPEcreate_user_defined_tag(yymsp[0].minor.yy297, CURRENT_SCOPE, yymsp[-2].minor.yy0.symbol); + + if (t) { + SCOPEadd_super(t); + yygotominor.yy477 = TYPEBODYcreate(aggregate_); + yygotominor.yy477->tag = t; + yygotominor.yy477->base = yymsp[0].minor.yy297; + } +} #line 2370 "expparse.c" - break; - case 17: /* aggregation_type ::= array_type */ - case 18: /* aggregation_type ::= bag_type */ - yytestcase(yyruleno == 18); - case 19: /* aggregation_type ::= list_type */ - yytestcase(yyruleno == 19); - case 20: /* aggregation_type ::= set_type */ - yytestcase(yyruleno == 20); + break; + case 17: /* aggregation_type ::= array_type */ + case 18: /* aggregation_type ::= bag_type */ yytestcase(yyruleno==18); + case 19: /* aggregation_type ::= list_type */ yytestcase(yyruleno==19); + case 20: /* aggregation_type ::= set_type */ yytestcase(yyruleno==20); #line 423 "expparse.y" - { - yygotominor.yy477 = yymsp[0].minor.yy477; - } +{ + yygotominor.yy477 = yymsp[0].minor.yy477; +} #line 2380 "expparse.c" - break; - case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ + break; + case 21: /* alias_statement ::= TOK_ALIAS TOK_IDENTIFIER TOK_FOR general_ref semicolon alias_push_scope statement_rep TOK_END_ALIAS semicolon */ #line 442 "expparse.y" - { - Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); - Variable v = VARcreate(e, Type_Unknown); +{ + Expression e = EXPcreate_from_symbol(Type_Attribute, yymsp[-7].minor.yy0.symbol); + Variable v = VARcreate(e, Type_Unknown); - v->initializer = yymsp[-5].minor.yy401; + v->initializer = yymsp[-5].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, - yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); - yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-7].minor.yy0.symbol->name, (Generic)v, + yymsp[-7].minor.yy0.symbol, OBJ_VARIABLE); + yygotominor.yy332 = ALIAScreate(CURRENT_SCOPE, v, yymsp[-2].minor.yy371); - POP_SCOPE(); - } + POP_SCOPE(); +} #line 2396 "expparse.c" - break; - case 22: /* alias_push_scope ::= */ + break; + case 22: /* alias_push_scope ::= */ #line 456 "expparse.y" - { - struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); - PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); - } +{ + struct Scope_ *s = SCOPEcreate_tiny(OBJ_ALIAS); + PUSH_SCOPE(s, (Symbol *)0, OBJ_ALIAS); +} #line 2404 "expparse.c" - break; - case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ + break; + case 23: /* array_type ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique attribute_type */ #line 463 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 2417 "expparse.c" - break; - case 24: /* assignable ::= assignable qualifier */ - case 300: /* unary_expression ::= unary_expression qualifier */ - yytestcase(yyruleno == 300); + break; + case 24: /* assignable ::= assignable qualifier */ + case 300: /* unary_expression ::= unary_expression qualifier */ yytestcase(yyruleno==300); #line 475 "expparse.y" - { - yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy46.expr; - } +{ + yymsp[0].minor.yy46.first->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy46.expr; +} #line 2426 "expparse.c" - break; - case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ + break; + case 26: /* assignment_statement ::= assignable TOK_ASSIGNMENT expression semicolon */ #line 486 "expparse.y" - { - yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); - } +{ + yygotominor.yy332 = ASSIGNcreate(yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); +} #line 2433 "expparse.c" - break; - case 27: /* attribute_type ::= aggregation_type */ - case 28: /* attribute_type ::= basic_type */ - yytestcase(yyruleno == 28); - case 122: /* parameter_type ::= basic_type */ - yytestcase(yyruleno == 122); - case 123: /* parameter_type ::= conformant_aggregation */ - yytestcase(yyruleno == 123); + break; + case 27: /* attribute_type ::= aggregation_type */ + case 28: /* attribute_type ::= basic_type */ yytestcase(yyruleno==28); + case 122: /* parameter_type ::= basic_type */ yytestcase(yyruleno==122); + case 123: /* parameter_type ::= conformant_aggregation */ yytestcase(yyruleno==123); #line 491 "expparse.y" - { - yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); - SCOPEadd_super(yygotominor.yy297); - } +{ + yygotominor.yy297 = TYPEcreate_from_body_anonymously(yymsp[0].minor.yy477); + SCOPEadd_super(yygotominor.yy297); +} #line 2444 "expparse.c" - break; - case 29: /* attribute_type ::= defined_type */ - case 124: /* parameter_type ::= defined_type */ - yytestcase(yyruleno == 124); - case 125: /* parameter_type ::= generic_type */ - yytestcase(yyruleno == 125); + break; + case 29: /* attribute_type ::= defined_type */ + case 124: /* parameter_type ::= defined_type */ yytestcase(yyruleno==124); + case 125: /* parameter_type ::= generic_type */ yytestcase(yyruleno==125); #line 501 "expparse.y" - { - yygotominor.yy297 = yymsp[0].minor.yy297; - } +{ + yygotominor.yy297 = yymsp[0].minor.yy297; +} #line 2453 "expparse.c" - break; - case 30: /* explicit_attr_list ::= */ - case 50: /* case_action_list ::= */ - yytestcase(yyruleno == 50); - case 69: /* derive_decl ::= */ - yytestcase(yyruleno == 69); - case 268: /* statement_rep ::= */ - yytestcase(yyruleno == 268); + break; + case 30: /* explicit_attr_list ::= */ + case 50: /* case_action_list ::= */ yytestcase(yyruleno==50); + case 69: /* derive_decl ::= */ yytestcase(yyruleno==69); + case 268: /* statement_rep ::= */ yytestcase(yyruleno==268); #line 506 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - } +{ + yygotominor.yy371 = LISTcreate(); +} #line 2463 "expparse.c" - break; - case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ + break; + case 31: /* explicit_attr_list ::= explicit_attr_list explicit_attribute */ #line 510 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); +} #line 2471 "expparse.c" - break; - case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ - case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ - yytestcase(yyruleno == 138); + break; + case 32: /* bag_type ::= TOK_BAG bound_spec TOK_OF attribute_type */ + case 138: /* conformant_aggregation ::= TOK_BAG bound_spec TOK_OF parameter_type */ yytestcase(yyruleno==138); #line 516 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 2482 "expparse.c" - break; - case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ + break; + case 33: /* bag_type ::= TOK_BAG TOK_OF attribute_type */ #line 523 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 2490 "expparse.c" - break; - case 34: /* basic_type ::= TOK_BOOLEAN */ + break; + case 34: /* basic_type ::= TOK_BOOLEAN */ #line 529 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(boolean_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(boolean_); +} #line 2497 "expparse.c" - break; - case 35: /* basic_type ::= TOK_INTEGER precision_spec */ + break; + case 35: /* basic_type ::= TOK_INTEGER precision_spec */ #line 533 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(integer_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; - } +{ + yygotominor.yy477 = TYPEBODYcreate(integer_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; +} #line 2505 "expparse.c" - break; - case 36: /* basic_type ::= TOK_REAL precision_spec */ + break; + case 36: /* basic_type ::= TOK_REAL precision_spec */ #line 538 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(real_); - yygotominor.yy477->precision = yymsp[0].minor.yy401; - } +{ + yygotominor.yy477 = TYPEBODYcreate(real_); + yygotominor.yy477->precision = yymsp[0].minor.yy401; +} #line 2513 "expparse.c" - break; - case 37: /* basic_type ::= TOK_NUMBER */ + break; + case 37: /* basic_type ::= TOK_NUMBER */ #line 543 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(number_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(number_); +} #line 2520 "expparse.c" - break; - case 38: /* basic_type ::= TOK_LOGICAL */ + break; + case 38: /* basic_type ::= TOK_LOGICAL */ #line 547 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(logical_); - } +{ + yygotominor.yy477 = TYPEBODYcreate(logical_); +} #line 2527 "expparse.c" - break; - case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ + break; + case 39: /* basic_type ::= TOK_BINARY precision_spec optional_fixed */ #line 551 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(binary_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; - } +{ + yygotominor.yy477 = TYPEBODYcreate(binary_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; +} #line 2536 "expparse.c" - break; - case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ + break; + case 40: /* basic_type ::= TOK_STRING precision_spec optional_fixed */ #line 557 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(string_); - yygotominor.yy477->precision = yymsp[-1].minor.yy401; - yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; - } +{ + yygotominor.yy477 = TYPEBODYcreate(string_); + yygotominor.yy477->precision = yymsp[-1].minor.yy401; + yygotominor.yy477->flags.fixed = yymsp[0].minor.yy252.fixed; +} #line 2545 "expparse.c" - break; - case 46: /* by_expression ::= */ + break; + case 46: /* by_expression ::= */ #line 583 "expparse.y" - { - yygotominor.yy401 = LITERAL_ONE; - } +{ + yygotominor.yy401 = LITERAL_ONE; +} #line 2552 "expparse.c" - break; - case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ - case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ - yytestcase(yyruleno == 181); + break; + case 48: /* cardinality_op ::= TOK_LEFT_CURL expression TOK_COLON expression TOK_RIGHT_CURL */ + case 181: /* bound_spec ::= TOK_LEFT_BRACKET expression TOK_COLON expression TOK_RIGHT_BRACKET */ yytestcase(yyruleno==181); #line 593 "expparse.y" - { - yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; - yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy253.lower_limit = yymsp[-3].minor.yy401; + yygotominor.yy253.upper_limit = yymsp[-1].minor.yy401; +} #line 2561 "expparse.c" - break; - case 49: /* case_action ::= case_labels TOK_COLON statement */ + break; + case 49: /* case_action ::= case_labels TOK_COLON statement */ #line 599 "expparse.y" - { - yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); - } +{ + yygotominor.yy321 = CASE_ITcreate(yymsp[-2].minor.yy371, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); +} #line 2569 "expparse.c" - break; - case 51: /* case_action_list ::= case_action_list case_action */ + break; + case 51: /* case_action_list ::= case_action_list case_action */ #line 609 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-1].minor.yy371; + yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); - } + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy321); +} #line 2580 "expparse.c" - break; - case 52: /* case_block ::= case_action_list case_otherwise */ + break; + case 52: /* case_block ::= case_action_list case_otherwise */ #line 618 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - - if(yymsp[0].minor.yy321) { - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy321); - } - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + + if (yymsp[0].minor.yy321) { + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy321); + } +} #line 2592 "expparse.c" - break; - case 53: /* case_labels ::= expression */ + break; + case 53: /* case_labels ::= expression */ #line 628 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); +{ + yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2601 "expparse.c" - break; - case 54: /* case_labels ::= case_labels TOK_COMMA expression */ + break; + case 54: /* case_labels ::= case_labels TOK_COMMA expression */ #line 634 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2611 "expparse.c" - break; - case 55: /* case_otherwise ::= */ + break; + case 55: /* case_otherwise ::= */ #line 642 "expparse.y" - { - yygotominor.yy321 = (Case_Item)0; - } +{ + yygotominor.yy321 = (Case_Item)0; +} #line 2618 "expparse.c" - break; - case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ + break; + case 56: /* case_otherwise ::= TOK_OTHERWISE TOK_COLON statement */ #line 646 "expparse.y" - { - yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); - SYMBOLset(yygotominor.yy321); - } +{ + yygotominor.yy321 = CASE_ITcreate(LIST_NULL, yymsp[0].minor.yy332); + SYMBOLset(yygotominor.yy321); +} #line 2626 "expparse.c" - break; - case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ + break; + case 57: /* case_statement ::= TOK_CASE expression TOK_OF case_block TOK_END_CASE semicolon */ #line 653 "expparse.y" - { - yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = CASEcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +} #line 2633 "expparse.c" - break; - case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ + break; + case 58: /* compound_statement ::= TOK_BEGIN statement_rep TOK_END semicolon */ #line 658 "expparse.y" - { - yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = COMP_STMTcreate(yymsp[-2].minor.yy371); +} #line 2640 "expparse.c" - break; - case 59: /* constant ::= TOK_PI */ + break; + case 59: /* constant ::= TOK_PI */ #line 663 "expparse.y" - { - yygotominor.yy401 = LITERAL_PI; - } +{ + yygotominor.yy401 = LITERAL_PI; +} #line 2647 "expparse.c" - break; - case 60: /* constant ::= TOK_E */ + break; + case 60: /* constant ::= TOK_E */ #line 668 "expparse.y" - { - yygotominor.yy401 = LITERAL_E; - } +{ + yygotominor.yy401 = LITERAL_E; +} #line 2654 "expparse.c" - break; - case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ + break; + case 61: /* constant_body ::= identifier TOK_COLON attribute_type TOK_ASSIGNMENT expression semicolon */ #line 675 "expparse.y" - { - Variable v; - - yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; - v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); - v->initializer = yymsp[-1].minor.yy401; - v->flags.constant = 1; - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, - &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); - } +{ + Variable v; + + yymsp[-5].minor.yy401->type = yymsp[-3].minor.yy297; + v = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy297); + v->initializer = yymsp[-1].minor.yy401; + v->flags.constant = 1; + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-5].minor.yy401->symbol.name, (Generic)v, + &yymsp[-5].minor.yy401->symbol, OBJ_VARIABLE); +} #line 2668 "expparse.c" - break; - case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ + break; + case 64: /* constant_decl ::= TOK_CONSTANT constant_body_list TOK_END_CONSTANT semicolon */ #line 694 "expparse.y" - { - yygotominor.yy0 = yymsp[-3].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-3].minor.yy0; +} #line 2675 "expparse.c" - break; - case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ + break; + case 71: /* derived_attribute ::= attribute_decl TOK_COLON attribute_type initializer semicolon */ #line 726 "expparse.y" - { - yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); - yygotominor.yy91->initializer = yymsp[-1].minor.yy401; - yygotominor.yy91->flags.attribute = true; - } +{ + yygotominor.yy91 = VARcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy297); + yygotominor.yy91->initializer = yymsp[-1].minor.yy401; + yygotominor.yy91->flags.attribute = true; +} #line 2684 "expparse.c" - break; - case 72: /* derived_attribute_rep ::= derived_attribute */ - case 176: /* inverse_attr_list ::= inverse_attr */ - yytestcase(yyruleno == 176); + break; + case 72: /* derived_attribute_rep ::= derived_attribute */ + case 176: /* inverse_attr_list ::= inverse_attr */ yytestcase(yyruleno==176); #line 733 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 2693 "expparse.c" - break; - case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ - case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ - yytestcase(yyruleno == 177); + break; + case 73: /* derived_attribute_rep ::= derived_attribute_rep derived_attribute */ + case 177: /* inverse_attr_list ::= inverse_attr_list inverse_attr */ yytestcase(yyruleno==177); #line 738 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 2702 "expparse.c" - break; - case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ + break; + case 74: /* entity_body ::= explicit_attr_list derive_decl inverse_clause unique_clause where_rule_OPT */ #line 745 "expparse.y" - { - yygotominor.yy176.attributes = yymsp[-4].minor.yy371; - /* this is flattened out in entity_decl - DEL */ - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); - - if(yymsp[-2].minor.yy371 != LIST_NULL) { - LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); - } - - yygotominor.yy176.unique = yymsp[-1].minor.yy371; - yygotominor.yy176.where = yymsp[0].minor.yy371; - } +{ + yygotominor.yy176.attributes = yymsp[-4].minor.yy371; + /* this is flattened out in entity_decl - DEL */ + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-3].minor.yy371); + + if (yymsp[-2].minor.yy371 != LIST_NULL) { + LISTadd_last(yygotominor.yy176.attributes, (Generic)yymsp[-2].minor.yy371); + } + + yygotominor.yy176.unique = yymsp[-1].minor.yy371; + yygotominor.yy176.where = yymsp[0].minor.yy371; +} #line 2718 "expparse.c" - break; - case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ + break; + case 75: /* entity_decl ::= entity_header subsuper_decl semicolon entity_body TOK_END_ENTITY semicolon */ #line 760 "expparse.y" - { - CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; - CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; - LISTdo(yymsp[-2].minor.yy176.attributes, l, Linked_List) { - LISTdo_n(l, a, Variable, b) { - ENTITYadd_attribute(CURRENT_SCOPE, a); - } - LISTod; - } - LISTod; - CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; - CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; - CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; - POP_SCOPE(); - } +{ + CURRENT_SCOPE->u.entity->subtype_expression = yymsp[-4].minor.yy242.subtypes; + CURRENT_SCOPE->u.entity->supertype_symbols = yymsp[-4].minor.yy242.supertypes; + LISTdo( yymsp[-2].minor.yy176.attributes, l, Linked_List ) { + LISTdo_n( l, a, Variable, b ) { + ENTITYadd_attribute(CURRENT_SCOPE, a); + } LISTod; + } LISTod; + CURRENT_SCOPE->u.entity->abstract = yymsp[-4].minor.yy242.abstract; + CURRENT_SCOPE->u.entity->unique = yymsp[-2].minor.yy176.unique; + CURRENT_SCOPE->where = yymsp[-2].minor.yy176.where; + POP_SCOPE(); +} #line 2735 "expparse.c" - break; - case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ + break; + case 76: /* entity_header ::= TOK_ENTITY TOK_IDENTIFIER */ #line 775 "expparse.y" - { - Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); +{ + Entity e = ENTITYcreate(yymsp[0].minor.yy0.symbol); - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_ENTITY_BITS) { + fprintf( stderr, "parse: %s (entity)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); - } + PUSH_SCOPE(e, yymsp[0].minor.yy0.symbol, OBJ_ENTITY); +} #line 2748 "expparse.c" - break; - case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ + break; + case 77: /* enumeration_type ::= TOK_ENUMERATION TOK_OF nested_id_list */ #line 786 "expparse.y" - { - int value = 0; - Expression x; - Symbol *tmp; - TypeBody tb; - tb = TYPEBODYcreate(enumeration_); - CURRENT_SCOPE->u.type->head = 0; - CURRENT_SCOPE->u.type->body = tb; - tb->list = yymsp[0].minor.yy371; - - if(!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - if(!PREVIOUS_SCOPE->enum_table) { - PREVIOUS_SCOPE->enum_table = DICTcreate(25); - } - LISTdo_links(yymsp[0].minor.yy371, id) { - tmp = (Symbol *)id->data; - id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); - x->symbol = *(tmp); - x->u.integer = ++value; - - /* define both in enum scope and scope of */ - /* 1st visibility */ - DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, - (Generic)x, &x->symbol, OBJ_EXPRESSION); - SYMBOL_destroy(tmp); - } - LISTod; - } +{ + int value = 0; + Expression x; + Symbol *tmp; + TypeBody tb; + tb = TYPEBODYcreate(enumeration_); + CURRENT_SCOPE->u.type->head = 0; + CURRENT_SCOPE->u.type->body = tb; + tb->list = yymsp[0].minor.yy371; + + if (!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + if (!PREVIOUS_SCOPE->enum_table) { + PREVIOUS_SCOPE->enum_table = DICTcreate(25); + } + LISTdo_links(yymsp[0].minor.yy371, id) { + tmp = (Symbol *)id->data; + id->data = (Generic)(x = EXPcreate(CURRENT_SCOPE)); + x->symbol = *(tmp); + x->u.integer = ++value; + + /* define both in enum scope and scope of */ + /* 1st visibility */ + DICT_define(CURRENT_SCOPE->symbol_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + DICTdefine(PREVIOUS_SCOPE->enum_table, x->symbol.name, + (Generic)x, &x->symbol, OBJ_EXPRESSION); + SYMBOL_destroy(tmp); + } LISTod; +} #line 2783 "expparse.c" - break; - case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ + break; + case 78: /* escape_statement ::= TOK_ESCAPE semicolon */ #line 819 "expparse.y" - { - yygotominor.yy332 = STATEMENT_ESCAPE; - } +{ + yygotominor.yy332 = STATEMENT_ESCAPE; +} #line 2790 "expparse.c" - break; - case 79: /* attribute_decl ::= TOK_IDENTIFIER */ + break; + case 79: /* attribute_decl ::= TOK_IDENTIFIER */ #line 834 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Attribute); - yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Attribute); + yygotominor.yy401->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 2799 "expparse.c" - break; - case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ + break; + case 80: /* attribute_decl ::= TOK_SELF TOK_BACKSLASH TOK_IDENTIFIER TOK_DOT TOK_IDENTIFIER */ #line 841 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); - yygotominor.yy401->e.op1->e.op_code = OP_GROUP; - yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); - yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); - SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); - - yygotominor.yy401->e.op_code = OP_DOT; - yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1 = EXPcreate(Type_Expression); + yygotominor.yy401->e.op1->e.op_code = OP_GROUP; + yygotominor.yy401->e.op1->e.op1 = EXPcreate(Type_Self); + yygotominor.yy401->e.op1->e.op2 = EXPcreate_from_symbol(Type_Entity, yymsp[-2].minor.yy0.symbol); + SYMBOL_destroy(yymsp[-2].minor.yy0.symbol); + + yygotominor.yy401->e.op_code = OP_DOT; + yygotominor.yy401->e.op2 = EXPcreate_from_symbol(Type_Attribute, yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 2815 "expparse.c" - break; - case 81: /* attribute_decl_list ::= attribute_decl */ + break; + case 81: /* attribute_decl_list ::= attribute_decl */ #line 855 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +} #line 2824 "expparse.c" - break; - case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ - case 114: /* expression_list ::= expression_list TOK_COMMA expression */ - yytestcase(yyruleno == 114); - case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ - yytestcase(yyruleno == 314); + break; + case 82: /* attribute_decl_list ::= attribute_decl_list TOK_COMMA attribute_decl */ + case 114: /* expression_list ::= expression_list TOK_COMMA expression */ yytestcase(yyruleno==114); + case 314: /* qualified_attr_list ::= qualified_attr_list TOK_COMMA qualified_attr */ yytestcase(yyruleno==314); #line 862 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy401); +} #line 2834 "expparse.c" - break; - case 83: /* optional ::= */ + break; + case 83: /* optional ::= */ #line 868 "expparse.y" - { - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.optional = 0; +} #line 2841 "expparse.c" - break; - case 84: /* optional ::= TOK_OPTIONAL */ + break; + case 84: /* optional ::= TOK_OPTIONAL */ #line 872 "expparse.y" - { - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.optional = 1; +} #line 2848 "expparse.c" - break; - case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ + break; + case 85: /* explicit_attribute ::= attribute_decl_list TOK_COLON optional attribute_type semicolon */ #line 878 "expparse.y" - { - Variable v; - - LISTdo_links(yymsp[-4].minor.yy371, attr) - v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); - v->flags.optional = yymsp[-2].minor.yy252.optional; - v->flags.attribute = true; - attr->data = (Generic)v; - LISTod; - - yygotominor.yy371 = yymsp[-4].minor.yy371; - } +{ + Variable v; + + LISTdo_links (yymsp[-4].minor.yy371, attr) + v = VARcreate((Expression)attr->data, yymsp[-1].minor.yy297); + v->flags.optional = yymsp[-2].minor.yy252.optional; + v->flags.attribute = true; + attr->data = (Generic)v; + LISTod; + + yygotominor.yy371 = yymsp[-4].minor.yy371; +} #line 2864 "expparse.c" - break; - case 90: /* expression ::= expression TOK_AND expression */ + break; + case 90: /* expression ::= expression TOK_AND expression */ #line 907 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2873 "expparse.c" - break; - case 91: /* expression ::= expression TOK_OR expression */ + break; + case 91: /* expression ::= expression TOK_OR expression */ #line 913 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_OR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2882 "expparse.c" - break; - case 92: /* expression ::= expression TOK_XOR expression */ + break; + case 92: /* expression ::= expression TOK_XOR expression */ #line 919 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_XOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2891 "expparse.c" - break; - case 93: /* expression ::= expression TOK_LESS_THAN expression */ + break; + case 93: /* expression ::= expression TOK_LESS_THAN expression */ #line 925 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2900 "expparse.c" - break; - case 94: /* expression ::= expression TOK_GREATER_THAN expression */ + break; + case 94: /* expression ::= expression TOK_GREATER_THAN expression */ #line 931 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_THAN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2909 "expparse.c" - break; - case 95: /* expression ::= expression TOK_EQUAL expression */ + break; + case 95: /* expression ::= expression TOK_EQUAL expression */ #line 937 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2918 "expparse.c" - break; - case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ + break; + case 96: /* expression ::= expression TOK_LESS_EQUAL expression */ #line 943 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LESS_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2927 "expparse.c" - break; - case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ + break; + case 97: /* expression ::= expression TOK_GREATER_EQUAL expression */ #line 949 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_GREATER_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2936 "expparse.c" - break; - case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ + break; + case 98: /* expression ::= expression TOK_NOT_EQUAL expression */ #line 955 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2945 "expparse.c" - break; - case 99: /* expression ::= expression TOK_INST_EQUAL expression */ + break; + case 99: /* expression ::= expression TOK_INST_EQUAL expression */ #line 961 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_INST_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2954 "expparse.c" - break; - case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ + break; + case 100: /* expression ::= expression TOK_INST_NOT_EQUAL expression */ #line 967 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_INST_NOT_EQUAL, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2963 "expparse.c" - break; - case 101: /* expression ::= expression TOK_IN expression */ + break; + case 101: /* expression ::= expression TOK_IN expression */ #line 973 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_IN, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2972 "expparse.c" - break; - case 102: /* expression ::= expression TOK_LIKE expression */ + break; + case 102: /* expression ::= expression TOK_LIKE expression */ #line 979 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_LIKE, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2981 "expparse.c" - break; - case 103: /* expression ::= simple_expression cardinality_op simple_expression */ - case 240: /* right_curl ::= TOK_RIGHT_CURL */ - yytestcase(yyruleno == 240); - case 254: /* semicolon ::= TOK_SEMICOLON */ - yytestcase(yyruleno == 254); + break; + case 103: /* expression ::= simple_expression cardinality_op simple_expression */ + case 240: /* right_curl ::= TOK_RIGHT_CURL */ yytestcase(yyruleno==240); + case 254: /* semicolon ::= TOK_SEMICOLON */ yytestcase(yyruleno==254); #line 985 "expparse.y" - { - yyerrok; - } +{ + yyerrok; +} #line 2990 "expparse.c" - break; - case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ + break; + case 105: /* simple_expression ::= simple_expression TOK_CONCAT_OP simple_expression */ #line 995 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_CONCAT, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 2999 "expparse.c" - break; - case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ + break; + case 106: /* simple_expression ::= simple_expression TOK_EXP simple_expression */ #line 1001 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_EXP, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3008 "expparse.c" - break; - case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ + break; + case 107: /* simple_expression ::= simple_expression TOK_TIMES simple_expression */ #line 1007 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_TIMES, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3017 "expparse.c" - break; - case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ + break; + case 108: /* simple_expression ::= simple_expression TOK_DIV simple_expression */ #line 1013 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3026 "expparse.c" - break; - case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ + break; + case 109: /* simple_expression ::= simple_expression TOK_REAL_DIV simple_expression */ #line 1019 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_REAL_DIV, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3035 "expparse.c" - break; - case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ + break; + case 110: /* simple_expression ::= simple_expression TOK_MOD simple_expression */ #line 1025 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_MOD, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3044 "expparse.c" - break; - case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ + break; + case 111: /* simple_expression ::= simple_expression TOK_PLUS simple_expression */ #line 1031 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_PLUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3053 "expparse.c" - break; - case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ + break; + case 112: /* simple_expression ::= simple_expression TOK_MINUS simple_expression */ #line 1037 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); - } + yygotominor.yy401 = BIN_EXPcreate(OP_MINUS, yymsp[-2].minor.yy401, yymsp[0].minor.yy401); +} #line 3062 "expparse.c" - break; - case 115: /* var ::= */ + break; + case 115: /* var ::= */ #line 1055 "expparse.y" - { - yygotominor.yy252.var = 0; - } +{ + yygotominor.yy252.var = 0; +} #line 3069 "expparse.c" - break; - case 116: /* var ::= TOK_VAR */ + break; + case 116: /* var ::= TOK_VAR */ #line 1059 "expparse.y" - { - yygotominor.yy252.var = 1; - } +{ + yygotominor.yy252.var = 1; +} #line 3076 "expparse.c" - break; - case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ + break; + case 117: /* formal_parameter ::= var id_list TOK_COLON parameter_type */ #line 1064 "expparse.y" - { - Symbol *tmp; - Expression e; - Variable v; - - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTdo_links(yygotominor.yy371, param) - tmp = (Symbol *)param->data; - - e = EXPcreate_from_symbol(Type_Attribute, tmp); - v = VARcreate(e, yymsp[0].minor.yy297); - v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ - v->flags.parameter = true; - param->data = (Generic)v; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, - tmp->name, (Generic)v, tmp, OBJ_VARIABLE); - - LISTod; - } +{ + Symbol *tmp; + Expression e; + Variable v; + + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTdo_links(yygotominor.yy371, param) + tmp = (Symbol*)param->data; + + e = EXPcreate_from_symbol(Type_Attribute, tmp); + v = VARcreate(e, yymsp[0].minor.yy297); + v->flags.var = yymsp[-3].minor.yy252.var; /* NOTE this was flags.optional... ?! */ + v->flags.parameter = true; + param->data = (Generic)v; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, + tmp->name, (Generic)v, tmp, OBJ_VARIABLE); + + LISTod; +} #line 3101 "expparse.c" - break; - case 118: /* formal_parameter_list ::= */ - case 179: /* inverse_clause ::= */ - yytestcase(yyruleno == 179); - case 328: /* where_rule_OPT ::= */ - yytestcase(yyruleno == 328); + break; + case 118: /* formal_parameter_list ::= */ + case 179: /* inverse_clause ::= */ yytestcase(yyruleno==179); + case 328: /* where_rule_OPT ::= */ yytestcase(yyruleno==328); #line 1087 "expparse.y" - { - yygotominor.yy371 = LIST_NULL; - } +{ + yygotominor.yy371 = LIST_NULL; +} #line 3110 "expparse.c" - break; - case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ + break; + case 119: /* formal_parameter_list ::= TOK_LEFT_PAREN formal_parameter_rep TOK_RIGHT_PAREN */ #line 1092 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; - } +} #line 3118 "expparse.c" - break; - case 120: /* formal_parameter_rep ::= formal_parameter */ + break; + case 120: /* formal_parameter_rep ::= formal_parameter */ #line 1098 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; +{ + yygotominor.yy371 = yymsp[0].minor.yy371; - } +} #line 3126 "expparse.c" - break; - case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ + break; + case 121: /* formal_parameter_rep ::= formal_parameter_rep semicolon formal_parameter */ #line 1104 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_all(yygotominor.yy371, yymsp[0].minor.yy371); +} #line 3134 "expparse.c" - break; - case 126: /* function_call ::= function_id actual_parameters */ + break; + case 126: /* function_call ::= function_id actual_parameters */ #line 1129 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Funcall); - yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; - SYMBOL_destroy(yymsp[-1].minor.yy275); - yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; - } +{ + yygotominor.yy401 = EXPcreate(Type_Funcall); + yygotominor.yy401->symbol = *yymsp[-1].minor.yy275; + SYMBOL_destroy(yymsp[-1].minor.yy275); + yygotominor.yy401->u.funcall.list = yymsp[0].minor.yy371; +} #line 3144 "expparse.c" - break; - case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ + break; + case 127: /* function_decl ::= function_header action_body TOK_END_FUNCTION semicolon */ #line 1138 "expparse.y" - { - FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + FUNCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3153 "expparse.c" - break; - case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ + break; + case 128: /* function_header ::= fh_lineno fh_push_scope fh_plist TOK_COLON parameter_type semicolon */ #line 1146 "expparse.y" - { - Function f = CURRENT_SCOPE; +{ + Function f = CURRENT_SCOPE; - f->u.func->return_type = yymsp[-1].minor.yy297; - yygotominor.yy507 = yymsp[-5].minor.yy507; - } + f->u.func->return_type = yymsp[-1].minor.yy297; + yygotominor.yy507 = yymsp[-5].minor.yy507; +} #line 3163 "expparse.c" - break; - case 129: /* fh_lineno ::= TOK_FUNCTION */ - case 218: /* ph_get_line ::= */ - yytestcase(yyruleno == 218); - case 247: /* rh_get_line ::= */ - yytestcase(yyruleno == 247); + break; + case 129: /* fh_lineno ::= TOK_FUNCTION */ + case 218: /* ph_get_line ::= */ yytestcase(yyruleno==218); + case 247: /* rh_get_line ::= */ yytestcase(yyruleno==247); #line 1154 "expparse.y" - { - yygotominor.yy507 = SCANtell(); - } +{ + yygotominor.yy507 = SCANtell(); +} #line 3172 "expparse.c" - break; - case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ + break; + case 130: /* fh_push_scope ::= TOK_IDENTIFIER */ #line 1159 "expparse.y" - { - Function f = ALGcreate(OBJ_FUNCTION); - tag_count = 0; - if(print_objects_while_running & OBJ_FUNCTION_BITS) { - fprintf(stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); - } - PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); - } +{ + Function f = ALGcreate(OBJ_FUNCTION); + tag_count = 0; + if (print_objects_while_running & OBJ_FUNCTION_BITS) { + fprintf( stderr, "parse: %s (function)\n", yymsp[0].minor.yy0.symbol->name); + } + PUSH_SCOPE(f, yymsp[0].minor.yy0.symbol, OBJ_FUNCTION); +} #line 3184 "expparse.c" - break; - case 131: /* fh_plist ::= formal_parameter_list */ + break; + case 131: /* fh_plist ::= formal_parameter_list */ #line 1169 "expparse.y" - { - Function f = CURRENT_SCOPE; - f->u.func->parameters = yymsp[0].minor.yy371; - f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); - f->u.func->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ - } +{ + Function f = CURRENT_SCOPE; + f->u.func->parameters = yymsp[0].minor.yy371; + f->u.func->pcount = LISTget_length(yymsp[0].minor.yy371); + f->u.func->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ +} #line 3195 "expparse.c" - break; - case 132: /* function_id ::= TOK_IDENTIFIER */ - case 219: /* procedure_id ::= TOK_IDENTIFIER */ - yytestcase(yyruleno == 219); - case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ - yytestcase(yyruleno == 220); + break; + case 132: /* function_id ::= TOK_IDENTIFIER */ + case 219: /* procedure_id ::= TOK_IDENTIFIER */ yytestcase(yyruleno==219); + case 220: /* procedure_id ::= TOK_BUILTIN_PROCEDURE */ yytestcase(yyruleno==220); #line 1178 "expparse.y" - { - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; - } +{ + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; +} #line 3204 "expparse.c" - break; - case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ + break; + case 133: /* function_id ::= TOK_BUILTIN_FUNCTION */ #line 1182 "expparse.y" - { - yygotominor.yy275 = yymsp[0].minor.yy0.symbol; +{ + yygotominor.yy275 = yymsp[0].minor.yy0.symbol; - } +} #line 3212 "expparse.c" - break; - case 134: /* conformant_aggregation ::= aggregate_type */ + break; + case 134: /* conformant_aggregation ::= aggregate_type */ #line 1188 "expparse.y" - { - yygotominor.yy477 = yymsp[0].minor.yy477; +{ + yygotominor.yy477 = yymsp[0].minor.yy477; - } +} #line 3220 "expparse.c" - break; - case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ + break; + case 135: /* conformant_aggregation ::= TOK_ARRAY TOK_OF optional_or_unique parameter_type */ #line 1194 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 3230 "expparse.c" - break; - case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ + break; + case 136: /* conformant_aggregation ::= TOK_ARRAY bound_spec TOK_OF optional_or_unique parameter_type */ #line 1202 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(array_); - yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(array_); + yygotominor.yy477->flags.optional = yymsp[-1].minor.yy252.optional; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; +} #line 3242 "expparse.c" - break; - case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ + break; + case 137: /* conformant_aggregation ::= TOK_BAG TOK_OF parameter_type */ #line 1211 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(bag_); - yygotominor.yy477->base = yymsp[0].minor.yy297; +{ + yygotominor.yy477 = TYPEBODYcreate(bag_); + yygotominor.yy477->base = yymsp[0].minor.yy297; - } +} #line 3251 "expparse.c" - break; - case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ + break; + case 139: /* conformant_aggregation ::= TOK_LIST TOK_OF unique parameter_type */ #line 1224 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->base = yymsp[0].minor.yy297; +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->base = yymsp[0].minor.yy297; - } +} #line 3261 "expparse.c" - break; - case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ + break; + case 140: /* conformant_aggregation ::= TOK_LIST bound_spec TOK_OF unique parameter_type */ #line 1232 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; +} #line 3272 "expparse.c" - break; - case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ - case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ - yytestcase(yyruleno == 256); + break; + case 141: /* conformant_aggregation ::= TOK_SET TOK_OF parameter_type */ + case 256: /* set_type ::= TOK_SET TOK_OF attribute_type */ yytestcase(yyruleno==256); #line 1240 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; +} #line 3281 "expparse.c" - break; - case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ + break; + case 142: /* conformant_aggregation ::= TOK_SET bound_spec TOK_OF parameter_type */ #line 1245 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3291 "expparse.c" - break; - case 143: /* generic_type ::= TOK_GENERIC */ + break; + case 143: /* generic_type ::= TOK_GENERIC */ #line 1253 "expparse.y" - { - yygotominor.yy297 = Type_Generic; - - if(tag_count < 0) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); - } - } +{ + yygotominor.yy297 = Type_Generic; + + if (tag_count < 0) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, + CURRENT_SCOPE_NAME); + } +} #line 3306 "expparse.c" - break; - case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ + break; + case 144: /* generic_type ::= TOK_GENERIC TOK_COLON TOK_IDENTIFIER */ #line 1265 "expparse.y" - { - TypeBody g = TYPEBODYcreate(generic_); - yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); +{ + TypeBody g = TYPEBODYcreate(generic_); + yygotominor.yy297 = TYPEcreate_from_body_anonymously(g); - SCOPEadd_super(yygotominor.yy297); + SCOPEadd_super(yygotominor.yy297); - g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); - if(g->tag) { - SCOPEadd_super(g->tag); - } - } + g->tag = TYPEcreate_user_defined_tag(yygotominor.yy297, CURRENT_SCOPE, yymsp[0].minor.yy0.symbol); + if (g->tag) { + SCOPEadd_super(g->tag); + } +} #line 3321 "expparse.c" - break; - case 145: /* id_list ::= TOK_IDENTIFIER */ + break; + case 145: /* id_list ::= TOK_IDENTIFIER */ #line 1278 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); - } +} #line 3330 "expparse.c" - break; - case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ + break; + case 146: /* id_list ::= id_list TOK_COMMA TOK_IDENTIFIER */ #line 1284 "expparse.y" - { - yyerrok; +{ + yyerrok; - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); - } + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy0.symbol); +} #line 3340 "expparse.c" - break; - case 147: /* identifier ::= TOK_SELF */ + break; + case 147: /* identifier ::= TOK_SELF */ #line 1292 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Self); - } +{ + yygotominor.yy401 = EXPcreate(Type_Self); +} #line 3347 "expparse.c" - break; - case 148: /* identifier ::= TOK_QUESTION_MARK */ + break; + case 148: /* identifier ::= TOK_QUESTION_MARK */ #line 1296 "expparse.y" - { - yygotominor.yy401 = LITERAL_INFINITY; - } +{ + yygotominor.yy401 = LITERAL_INFINITY; +} #line 3354 "expparse.c" - break; - case 149: /* identifier ::= TOK_IDENTIFIER */ + break; + case 149: /* identifier ::= TOK_IDENTIFIER */ #line 1300 "expparse.y" - { - yygotominor.yy401 = EXPcreate(Type_Identifier); - yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = EXPcreate(Type_Identifier); + yygotominor.yy401->symbol = *(yymsp[0].minor.yy0.symbol); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3363 "expparse.c" - break; - case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ + break; + case 150: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_END_IF semicolon */ #line 1308 "expparse.y" - { - yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); - } +{ + yygotominor.yy332 = CONDcreate(yymsp[-4].minor.yy401, yymsp[-2].minor.yy371, STATEMENT_LIST_NULL); +} #line 3370 "expparse.c" - break; - case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ + break; + case 151: /* if_statement ::= TOK_IF expression TOK_THEN statement_rep TOK_ELSE statement_rep TOK_END_IF semicolon */ #line 1313 "expparse.y" - { - yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = CONDcreate(yymsp[-6].minor.yy401, yymsp[-4].minor.yy371, yymsp[-2].minor.yy371); +} #line 3377 "expparse.c" - break; - case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ + break; + case 152: /* include_directive ::= TOK_INCLUDE TOK_STRING_LITERAL semicolon */ #line 1318 "expparse.y" - { - SCANinclude_file(yymsp[-1].minor.yy0.string); - } +{ + SCANinclude_file(yymsp[-1].minor.yy0.string); +} #line 3384 "expparse.c" - break; - case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ + break; + case 153: /* increment_control ::= TOK_IDENTIFIER TOK_ASSIGNMENT expression TOK_TO expression by_expression */ #line 1324 "expparse.y" - { - Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); +{ + Increment i = INCR_CTLcreate(yymsp[-5].minor.yy0.symbol, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401, yymsp[0].minor.yy401); - /* scope doesn't really have/need a name, I suppose */ - /* naming it by the iterator variable is fine */ + /* scope doesn't really have/need a name, I suppose */ + /* naming it by the iterator variable is fine */ - PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); - } + PUSH_SCOPE(i, (Symbol *)0, OBJ_INCREMENT); +} #line 3396 "expparse.c" - break; - case 155: /* rename ::= TOK_IDENTIFIER */ + break; + case 155: /* rename ::= TOK_IDENTIFIER */ #line 1342 "expparse.y" - { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); - } +{ + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[0].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); +} #line 3403 "expparse.c" - break; - case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ + break; + case 156: /* rename ::= TOK_IDENTIFIER TOK_AS TOK_IDENTIFIER */ #line 1346 "expparse.y" - { - (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); - } +{ + (*interface_func)(CURRENT_SCOPE, interface_schema, yymsp[-2].minor.yy0.symbol, yymsp[0].minor.yy0.symbol); +} #line 3410 "expparse.c" - break; - case 158: /* rename_list ::= rename_list TOK_COMMA rename */ - case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ - yytestcase(yyruleno == 161); - case 164: /* use_clause ::= use_head parened_rename_list semicolon */ - yytestcase(yyruleno == 164); - case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ - yytestcase(yyruleno == 249); - case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ - yytestcase(yyruleno == 295); + break; + case 158: /* rename_list ::= rename_list TOK_COMMA rename */ + case 161: /* reference_clause ::= reference_head parened_rename_list semicolon */ yytestcase(yyruleno==161); + case 164: /* use_clause ::= use_head parened_rename_list semicolon */ yytestcase(yyruleno==164); + case 249: /* schema_body ::= interface_specification_list constant_decl block_list */ yytestcase(yyruleno==249); + case 295: /* type_decl ::= td_start TOK_END_TYPE semicolon */ yytestcase(yyruleno==295); #line 1355 "expparse.y" - { - yygotominor.yy0 = yymsp[-2].minor.yy0; - } +{ + yygotominor.yy0 = yymsp[-2].minor.yy0; +} #line 3421 "expparse.c" - break; - case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 160: /* reference_clause ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1365 "expparse.y" - { - if(!CURRENT_SCHEMA->ref_schemas) { - CURRENT_SCHEMA->ref_schemas = LISTcreate(); - } +{ + if (!CURRENT_SCHEMA->ref_schemas) { + CURRENT_SCHEMA->ref_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); - } + LISTadd_last(CURRENT_SCHEMA->ref_schemas, (Generic)yymsp[-1].minor.yy0.symbol); +} #line 3432 "expparse.c" - break; - case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ + break; + case 162: /* reference_head ::= TOK_REFERENCE TOK_FROM TOK_IDENTIFIER */ #line 1378 "expparse.y" - { - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_reference; - } +{ + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_reference; +} #line 3440 "expparse.c" - break; - case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ + break; + case 163: /* use_clause ::= TOK_USE TOK_FROM TOK_IDENTIFIER semicolon */ #line 1384 "expparse.y" - { - if(!CURRENT_SCHEMA->use_schemas) { - CURRENT_SCHEMA->use_schemas = LISTcreate(); - } +{ + if (!CURRENT_SCHEMA->use_schemas) { + CURRENT_SCHEMA->use_schemas = LISTcreate(); + } - LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); - } + LISTadd_last(CURRENT_SCHEMA->use_schemas, (Generic)yymsp[-1].minor.yy0.symbol); +} #line 3451 "expparse.c" - break; - case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ + break; + case 165: /* use_head ::= TOK_USE TOK_FROM TOK_IDENTIFIER */ #line 1397 "expparse.y" - { - interface_schema = yymsp[0].minor.yy0.symbol; - interface_func = SCHEMAadd_use; - } +{ + interface_schema = yymsp[0].minor.yy0.symbol; + interface_func = SCHEMAadd_use; +} #line 3459 "expparse.c" - break; - case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ + break; + case 170: /* interval ::= TOK_LEFT_CURL simple_expression rel_op simple_expression rel_op simple_expression right_curl */ #line 1420 "expparse.y" - { - Expression tmp1, tmp2; - - yygotominor.yy401 = (Expression)0; - tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); - tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); - yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); - } +{ + Expression tmp1, tmp2; + + yygotominor.yy401 = (Expression)0; + tmp1 = BIN_EXPcreate(yymsp[-4].minor.yy126, yymsp[-5].minor.yy401, yymsp[-3].minor.yy401); + tmp2 = BIN_EXPcreate(yymsp[-2].minor.yy126, yymsp[-3].minor.yy401, yymsp[-1].minor.yy401); + yygotominor.yy401 = BIN_EXPcreate(OP_AND, tmp1, tmp2); +} #line 3471 "expparse.c" - break; - case 171: /* set_or_bag_of_entity ::= defined_type */ - case 289: /* type ::= defined_type */ - yytestcase(yyruleno == 289); + break; + case 171: /* set_or_bag_of_entity ::= defined_type */ + case 289: /* type ::= defined_type */ yytestcase(yyruleno==289); #line 1432 "expparse.y" - { - yygotominor.yy378.type = yymsp[0].minor.yy297; - yygotominor.yy378.body = 0; - } +{ + yygotominor.yy378.type = yymsp[0].minor.yy297; + yygotominor.yy378.body = 0; +} #line 3480 "expparse.c" - break; - case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ + break; + case 172: /* set_or_bag_of_entity ::= TOK_SET TOK_OF defined_type */ #line 1437 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; - } +} #line 3490 "expparse.c" - break; - case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ + break; + case 173: /* set_or_bag_of_entity ::= TOK_SET bound_spec TOK_OF defined_type */ #line 1444 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(set_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(set_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3501 "expparse.c" - break; - case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ + break; + case 174: /* set_or_bag_of_entity ::= TOK_BAG bound_spec TOK_OF defined_type */ #line 1452 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; - yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; + yygotominor.yy378.body->upper = yymsp[-2].minor.yy253.upper_limit; + yygotominor.yy378.body->lower = yymsp[-2].minor.yy253.lower_limit; +} #line 3512 "expparse.c" - break; - case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ + break; + case 175: /* set_or_bag_of_entity ::= TOK_BAG TOK_OF defined_type */ #line 1460 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = TYPEBODYcreate(bag_); - yygotominor.yy378.body->base = yymsp[0].minor.yy297; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = TYPEBODYcreate(bag_); + yygotominor.yy378.body->base = yymsp[0].minor.yy297; +} #line 3521 "expparse.c" - break; - case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ + break; + case 178: /* inverse_attr ::= attribute_decl TOK_COLON set_or_bag_of_entity TOK_FOR TOK_IDENTIFIER semicolon */ #line 1487 "expparse.y" - { - if(yymsp[-3].minor.yy378.type) { - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); - } else { - Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); - SCOPEadd_super(t); - yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); - } - - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; - } +{ + if (yymsp[-3].minor.yy378.type) { + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, yymsp[-3].minor.yy378.type); + } else { + Type t = TYPEcreate_from_body_anonymously(yymsp[-3].minor.yy378.body); + SCOPEadd_super(t); + yygotominor.yy91 = VARcreate(yymsp[-5].minor.yy401, t); + } + + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->inverse_symbol = yymsp[-1].minor.yy0.symbol; +} #line 3537 "expparse.c" - break; - case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ + break; + case 182: /* list_type ::= TOK_LIST bound_spec TOK_OF unique attribute_type */ #line 1521 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; + yygotominor.yy477->lower = yymsp[-3].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-3].minor.yy253.upper_limit; +} #line 3548 "expparse.c" - break; - case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ + break; + case 183: /* list_type ::= TOK_LIST TOK_OF unique attribute_type */ #line 1529 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(list_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; - } +{ + yygotominor.yy477 = TYPEBODYcreate(list_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->flags.unique = yymsp[-1].minor.yy252.unique; +} #line 3557 "expparse.c" - break; - case 184: /* literal ::= TOK_INTEGER_LITERAL */ + break; + case 184: /* literal ::= TOK_INTEGER_LITERAL */ #line 1536 "expparse.y" - { - if(yymsp[0].minor.yy0.iVal == 0) { - yygotominor.yy401 = LITERAL_ZERO; - } else if(yymsp[0].minor.yy0.iVal == 1) { - yygotominor.yy401 = LITERAL_ONE; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Integer); - yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; - resolved_all(yygotominor.yy401); - } - } +{ + if (yymsp[0].minor.yy0.iVal == 0) { + yygotominor.yy401 = LITERAL_ZERO; + } else if (yymsp[0].minor.yy0.iVal == 1) { + yygotominor.yy401 = LITERAL_ONE; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Integer); + yygotominor.yy401->u.integer = (int)yymsp[0].minor.yy0.iVal; + resolved_all(yygotominor.yy401); + } +} #line 3572 "expparse.c" - break; - case 185: /* literal ::= TOK_REAL_LITERAL */ + break; + case 185: /* literal ::= TOK_REAL_LITERAL */ #line 1548 "expparse.y" - { - /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ - if((fabs(yymsp[0].minor.yy0.rVal) <= FLT_MIN) && (fabs(yymsp[0].minor.yy0.rVal) > 0)) { - Symbol sym; - sym.line = yylineno; - sym.filename = current_filename; - ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal); - } - if(fabs(yymsp[0].minor.yy0.rVal) < DBL_MIN) { - yygotominor.yy401 = LITERAL_ZERO; - } else { - yygotominor.yy401 = EXPcreate_simple(Type_Real); - yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; - resolved_all(yygotominor.yy401); - } - } +{ + /* if rVal (a double) is nonzero and has magnitude <= the smallest non-denormal float, print a warning */ + if( ( fabs( yymsp[0].minor.yy0.rVal ) <= FLT_MIN ) && ( fabs( yymsp[0].minor.yy0.rVal ) > 0 ) ) { + Symbol sym; + sym.line = yylineno; + sym.filename = current_filename; + ERRORreport_with_symbol(WARN_SMALL_REAL, &sym, yymsp[0].minor.yy0.rVal ); + } + if( fabs( yymsp[0].minor.yy0.rVal ) < DBL_MIN ) { + yygotominor.yy401 = LITERAL_ZERO; + } else { + yygotominor.yy401 = EXPcreate_simple(Type_Real); + yygotominor.yy401->u.real = yymsp[0].minor.yy0.rVal; + resolved_all(yygotominor.yy401); + } +} #line 3592 "expparse.c" - break; - case 186: /* literal ::= TOK_STRING_LITERAL */ + break; + case 186: /* literal ::= TOK_STRING_LITERAL */ #line 1565 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_String); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_String); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); +} #line 3601 "expparse.c" - break; - case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ + break; + case 187: /* literal ::= TOK_STRING_LITERAL_ENCODED */ #line 1571 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_String_Encoded); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.string; + resolved_all(yygotominor.yy401); +} #line 3610 "expparse.c" - break; - case 188: /* literal ::= TOK_LOGICAL_LITERAL */ + break; + case 188: /* literal ::= TOK_LOGICAL_LITERAL */ #line 1577 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_Logical); - yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_Logical); + yygotominor.yy401->u.logical = yymsp[0].minor.yy0.logical; + resolved_all(yygotominor.yy401); +} #line 3619 "expparse.c" - break; - case 189: /* literal ::= TOK_BINARY_LITERAL */ + break; + case 189: /* literal ::= TOK_BINARY_LITERAL */ #line 1583 "expparse.y" - { - yygotominor.yy401 = EXPcreate_simple(Type_Binary); - yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; - resolved_all(yygotominor.yy401); - } +{ + yygotominor.yy401 = EXPcreate_simple(Type_Binary); + yygotominor.yy401->symbol.name = yymsp[0].minor.yy0.binary; + resolved_all(yygotominor.yy401); +} #line 3628 "expparse.c" - break; - case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ + break; + case 192: /* local_variable ::= id_list TOK_COLON parameter_type semicolon */ #line 1599 "expparse.y" - { - Expression e; - Variable v; - LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) - - /* convert symbol to name-expression */ - - e = EXPcreate(Type_Attribute); - e->symbol = *sym; - SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-1].minor.yy297); - v->offset = local_var_count++; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-3].minor.yy371); - } +{ + Expression e; + Variable v; + LISTdo(yymsp[-3].minor.yy371, sym, Symbol *) + + /* convert symbol to name-expression */ + + e = EXPcreate(Type_Attribute); + e->symbol = *sym; SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-1].minor.yy297); + v->offset = local_var_count++; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-3].minor.yy371); +} #line 3647 "expparse.c" - break; - case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ + break; + case 193: /* local_variable ::= id_list TOK_COLON parameter_type local_initializer semicolon */ #line 1616 "expparse.y" - { - Expression e; - Variable v; - LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) - e = EXPcreate(Type_Attribute); - e->symbol = *sym; - SYMBOL_destroy(sym); - v = VARcreate(e, yymsp[-2].minor.yy297); - v->offset = local_var_count++; - v->initializer = yymsp[-1].minor.yy401; - DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, - &e->symbol, OBJ_VARIABLE); - LISTod; - LISTfree(yymsp[-4].minor.yy371); - } +{ + Expression e; + Variable v; + LISTdo(yymsp[-4].minor.yy371, sym, Symbol *) + e = EXPcreate(Type_Attribute); + e->symbol = *sym; SYMBOL_destroy(sym); + v = VARcreate(e, yymsp[-2].minor.yy297); + v->offset = local_var_count++; + v->initializer = yymsp[-1].minor.yy401; + DICTdefine(CURRENT_SCOPE->symbol_table, e->symbol.name, (Generic)v, + &e->symbol, OBJ_VARIABLE); + LISTod; + LISTfree(yymsp[-4].minor.yy371); +} #line 3665 "expparse.c" - break; - case 197: /* local_decl_rules_on ::= */ + break; + case 197: /* local_decl_rules_on ::= */ #line 1640 "expparse.y" - { - tag_count = 0; /* don't signal an error if we find a generic_type */ - local_var_count = 0; /* used to keep local var decl's in the same order */ - } +{ + tag_count = 0; /* don't signal an error if we find a generic_type */ + local_var_count = 0; /* used to keep local var decl's in the same order */ +} #line 3673 "expparse.c" - break; - case 198: /* local_decl_rules_off ::= */ + break; + case 198: /* local_decl_rules_off ::= */ #line 1646 "expparse.y" - { - tag_count = -1; /* signal an error if we find a generic_type */ - } +{ + tag_count = -1; /* signal an error if we find a generic_type */ +} #line 3680 "expparse.c" - break; - case 199: /* defined_type ::= TOK_IDENTIFIER */ + break; + case 199: /* defined_type ::= TOK_IDENTIFIER */ #line 1651 "expparse.y" - { - yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(yygotominor.yy297); - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy297 = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(yygotominor.yy297); + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3689 "expparse.c" - break; - case 200: /* defined_type_list ::= defined_type */ + break; + case 200: /* defined_type_list ::= defined_type */ #line 1658 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy297); - } +} #line 3698 "expparse.c" - break; - case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ + break; + case 201: /* defined_type_list ::= defined_type_list TOK_COMMA defined_type */ #line 1664 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, - (Generic)yymsp[0].minor.yy297); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, + (Generic)yymsp[0].minor.yy297); +} #line 3707 "expparse.c" - break; - case 204: /* optional_or_unique ::= */ + break; + case 204: /* optional_or_unique ::= */ #line 1681 "expparse.y" - { - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 0; +} #line 3715 "expparse.c" - break; - case 205: /* optional_or_unique ::= TOK_OPTIONAL */ + break; + case 205: /* optional_or_unique ::= TOK_OPTIONAL */ #line 1686 "expparse.y" - { - yygotominor.yy252.unique = 0; - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.unique = 0; + yygotominor.yy252.optional = 1; +} #line 3723 "expparse.c" - break; - case 206: /* optional_or_unique ::= TOK_UNIQUE */ + break; + case 206: /* optional_or_unique ::= TOK_UNIQUE */ #line 1691 "expparse.y" - { - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 0; - } +{ + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 0; +} #line 3731 "expparse.c" - break; - case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ - case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ - yytestcase(yyruleno == 208); + break; + case 207: /* optional_or_unique ::= TOK_OPTIONAL TOK_UNIQUE */ + case 208: /* optional_or_unique ::= TOK_UNIQUE TOK_OPTIONAL */ yytestcase(yyruleno==208); #line 1696 "expparse.y" - { - yygotominor.yy252.unique = 1; - yygotominor.yy252.optional = 1; - } +{ + yygotominor.yy252.unique = 1; + yygotominor.yy252.optional = 1; +} #line 3740 "expparse.c" - break; - case 209: /* optional_fixed ::= */ + break; + case 209: /* optional_fixed ::= */ #line 1707 "expparse.y" - { - yygotominor.yy252.fixed = 0; - } +{ + yygotominor.yy252.fixed = 0; +} #line 3747 "expparse.c" - break; - case 210: /* optional_fixed ::= TOK_FIXED */ + break; + case 210: /* optional_fixed ::= TOK_FIXED */ #line 1711 "expparse.y" - { - yygotominor.yy252.fixed = 1; - } +{ + yygotominor.yy252.fixed = 1; +} #line 3754 "expparse.c" - break; - case 211: /* precision_spec ::= */ + break; + case 211: /* precision_spec ::= */ #line 1716 "expparse.y" - { - yygotominor.yy401 = (Expression)0; - } +{ + yygotominor.yy401 = (Expression)0; +} #line 3761 "expparse.c" - break; - case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ - case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ - yytestcase(yyruleno == 304); + break; + case 212: /* precision_spec ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ + case 304: /* unary_expression ::= TOK_LEFT_PAREN expression TOK_RIGHT_PAREN */ yytestcase(yyruleno==304); #line 1720 "expparse.y" - { - yygotominor.yy401 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy401 = yymsp[-1].minor.yy401; +} #line 3769 "expparse.c" - break; - case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ + break; + case 213: /* proc_call_statement ::= procedure_id actual_parameters semicolon */ #line 1730 "expparse.y" - { - yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); - yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); - } +{ + yygotominor.yy332 = PCALLcreate(yymsp[-1].minor.yy371); + yygotominor.yy332->symbol = *(yymsp[-2].minor.yy275); +} #line 3777 "expparse.c" - break; - case 214: /* proc_call_statement ::= procedure_id semicolon */ + break; + case 214: /* proc_call_statement ::= procedure_id semicolon */ #line 1735 "expparse.y" - { - yygotominor.yy332 = PCALLcreate((Linked_List)0); - yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); - } +{ + yygotominor.yy332 = PCALLcreate((Linked_List)0); + yygotominor.yy332->symbol = *(yymsp[-1].minor.yy275); +} #line 3785 "expparse.c" - break; - case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ + break; + case 215: /* procedure_decl ::= procedure_header action_body TOK_END_PROCEDURE semicolon */ #line 1742 "expparse.y" - { - PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + PROCput_body(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-3].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3794 "expparse.c" - break; - case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ + break; + case 216: /* procedure_header ::= TOK_PROCEDURE ph_get_line ph_push_scope formal_parameter_list semicolon */ #line 1750 "expparse.y" - { - Procedure p = CURRENT_SCOPE; - p->u.proc->parameters = yymsp[-1].minor.yy371; - p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); - p->u.proc->tag_count = tag_count; - tag_count = -1; /* done with parameters, no new tags can be defined */ - yygotominor.yy507 = yymsp[-3].minor.yy507; - } +{ + Procedure p = CURRENT_SCOPE; + p->u.proc->parameters = yymsp[-1].minor.yy371; + p->u.proc->pcount = LISTget_length(yymsp[-1].minor.yy371); + p->u.proc->tag_count = tag_count; + tag_count = -1; /* done with parameters, no new tags can be defined */ + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 3806 "expparse.c" - break; - case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ + break; + case 217: /* ph_push_scope ::= TOK_IDENTIFIER */ #line 1760 "expparse.y" - { - Procedure p = ALGcreate(OBJ_PROCEDURE); - tag_count = 0; +{ + Procedure p = ALGcreate(OBJ_PROCEDURE); + tag_count = 0; - if(print_objects_while_running & OBJ_PROCEDURE_BITS) { - fprintf(stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_PROCEDURE_BITS) { + fprintf( stderr, "parse: %s (procedure)\n", yymsp[0].minor.yy0.symbol->name); + } - PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); - } + PUSH_SCOPE(p, yymsp[0].minor.yy0.symbol, OBJ_PROCEDURE); +} #line 3820 "expparse.c" - break; - case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 221: /* group_ref ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1786 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy401->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy401->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3830 "expparse.c" - break; - case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ + break; + case 222: /* qualifier ::= TOK_DOT TOK_IDENTIFIER */ #line 1794 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_DOT, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3840 "expparse.c" - break; - case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ + break; + case 223: /* qualifier ::= TOK_BACKSLASH TOK_IDENTIFIER */ #line 1801 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); - yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; - SYMBOL_destroy(yymsp[0].minor.yy0.symbol); - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_GROUP, (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = EXPcreate(Type_Identifier); + yygotominor.yy46.expr->e.op2->symbol = *yymsp[0].minor.yy0.symbol; + SYMBOL_destroy(yymsp[0].minor.yy0.symbol); +} #line 3850 "expparse.c" - break; - case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ + break; + case 224: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_RIGHT_BRACKET */ #line 1810 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, - (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = BIN_EXPcreate(OP_ARRAY_ELEMENT, (Expression)0, + (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-1].minor.yy401; +} #line 3859 "expparse.c" - break; - case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ + break; + case 225: /* qualifier ::= TOK_LEFT_BRACKET simple_expression TOK_COLON simple_expression TOK_RIGHT_BRACKET */ #line 1819 "expparse.y" - { - yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, - (Expression)0, (Expression)0); - yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; - yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy46.expr = yygotominor.yy46.first = TERN_EXPcreate(OP_SUBCOMPONENT, (Expression)0, + (Expression)0, (Expression)0); + yygotominor.yy46.expr->e.op2 = yymsp[-3].minor.yy401; + yygotominor.yy46.expr->e.op3 = yymsp[-1].minor.yy401; +} #line 3869 "expparse.c" - break; - case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ + break; + case 226: /* query_expression ::= query_start expression TOK_RIGHT_PAREN */ #line 1827 "expparse.y" - { - yygotominor.yy401 = yymsp[-2].minor.yy401; - yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; - POP_SCOPE(); - } +{ + yygotominor.yy401 = yymsp[-2].minor.yy401; + yygotominor.yy401->u.query->expression = yymsp[-1].minor.yy401; + POP_SCOPE(); +} #line 3878 "expparse.c" - break; - case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ + break; + case 227: /* query_start ::= TOK_QUERY TOK_LEFT_PAREN TOK_IDENTIFIER TOK_ALL_IN expression TOK_SUCH_THAT */ #line 1835 "expparse.y" - { - yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); - SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); - PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); - } +{ + yygotominor.yy401 = QUERYcreate(yymsp[-3].minor.yy0.symbol, yymsp[-1].minor.yy401); + SYMBOL_destroy(yymsp[-3].minor.yy0.symbol); + PUSH_SCOPE(yygotominor.yy401->u.query->scope, (Symbol *)0, OBJ_QUERY); +} #line 3887 "expparse.c" - break; - case 228: /* rel_op ::= TOK_LESS_THAN */ + break; + case 228: /* rel_op ::= TOK_LESS_THAN */ #line 1842 "expparse.y" - { - yygotominor.yy126 = OP_LESS_THAN; - } +{ + yygotominor.yy126 = OP_LESS_THAN; +} #line 3894 "expparse.c" - break; - case 229: /* rel_op ::= TOK_GREATER_THAN */ + break; + case 229: /* rel_op ::= TOK_GREATER_THAN */ #line 1846 "expparse.y" - { - yygotominor.yy126 = OP_GREATER_THAN; - } +{ + yygotominor.yy126 = OP_GREATER_THAN; +} #line 3901 "expparse.c" - break; - case 230: /* rel_op ::= TOK_EQUAL */ + break; + case 230: /* rel_op ::= TOK_EQUAL */ #line 1850 "expparse.y" - { - yygotominor.yy126 = OP_EQUAL; - } +{ + yygotominor.yy126 = OP_EQUAL; +} #line 3908 "expparse.c" - break; - case 231: /* rel_op ::= TOK_LESS_EQUAL */ + break; + case 231: /* rel_op ::= TOK_LESS_EQUAL */ #line 1854 "expparse.y" - { - yygotominor.yy126 = OP_LESS_EQUAL; - } +{ + yygotominor.yy126 = OP_LESS_EQUAL; +} #line 3915 "expparse.c" - break; - case 232: /* rel_op ::= TOK_GREATER_EQUAL */ + break; + case 232: /* rel_op ::= TOK_GREATER_EQUAL */ #line 1858 "expparse.y" - { - yygotominor.yy126 = OP_GREATER_EQUAL; - } +{ + yygotominor.yy126 = OP_GREATER_EQUAL; +} #line 3922 "expparse.c" - break; - case 233: /* rel_op ::= TOK_NOT_EQUAL */ + break; + case 233: /* rel_op ::= TOK_NOT_EQUAL */ #line 1862 "expparse.y" - { - yygotominor.yy126 = OP_NOT_EQUAL; - } +{ + yygotominor.yy126 = OP_NOT_EQUAL; +} #line 3929 "expparse.c" - break; - case 234: /* rel_op ::= TOK_INST_EQUAL */ + break; + case 234: /* rel_op ::= TOK_INST_EQUAL */ #line 1866 "expparse.y" - { - yygotominor.yy126 = OP_INST_EQUAL; - } +{ + yygotominor.yy126 = OP_INST_EQUAL; +} #line 3936 "expparse.c" - break; - case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ + break; + case 235: /* rel_op ::= TOK_INST_NOT_EQUAL */ #line 1870 "expparse.y" - { - yygotominor.yy126 = OP_INST_NOT_EQUAL; - } +{ + yygotominor.yy126 = OP_INST_NOT_EQUAL; +} #line 3943 "expparse.c" - break; - case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 236: /* repeat_statement ::= TOK_REPEAT increment_control while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1878 "expparse.y" - { - yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +{ + yygotominor.yy332 = LOOPcreate(CURRENT_SCOPE, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - /* matching PUSH_SCOPE is in increment_control */ - POP_SCOPE(); - } + /* matching PUSH_SCOPE is in increment_control */ + POP_SCOPE(); +} #line 3953 "expparse.c" - break; - case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ + break; + case 237: /* repeat_statement ::= TOK_REPEAT while_control until_control semicolon statement_rep TOK_END_REPEAT semicolon */ #line 1886 "expparse.y" - { - yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); - } +{ + yygotominor.yy332 = LOOPcreate((struct Scope_ *)0, yymsp[-5].minor.yy401, yymsp[-4].minor.yy401, yymsp[-2].minor.yy371); +} #line 3960 "expparse.c" - break; - case 238: /* return_statement ::= TOK_RETURN semicolon */ + break; + case 238: /* return_statement ::= TOK_RETURN semicolon */ #line 1891 "expparse.y" - { - yygotominor.yy332 = RETcreate((Expression)0); - } +{ + yygotominor.yy332 = RETcreate((Expression)0); +} #line 3967 "expparse.c" - break; - case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ + break; + case 239: /* return_statement ::= TOK_RETURN TOK_LEFT_PAREN expression TOK_RIGHT_PAREN semicolon */ #line 1896 "expparse.y" - { - yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); - } +{ + yygotominor.yy332 = RETcreate(yymsp[-2].minor.yy401); +} #line 3974 "expparse.c" - break; - case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ + break; + case 241: /* rule_decl ::= rule_header action_body where_rule TOK_END_RULE semicolon */ #line 1907 "expparse.y" - { - RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); - RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); - ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); - POP_SCOPE(); - } +{ + RULEput_body(CURRENT_SCOPE, yymsp[-3].minor.yy371); + RULEput_where(CURRENT_SCOPE, yymsp[-2].minor.yy371); + ALGput_full_text(CURRENT_SCOPE, yymsp[-4].minor.yy507, SCANtell()); + POP_SCOPE(); +} #line 3984 "expparse.c" - break; - case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ + break; + case 242: /* rule_formal_parameter ::= TOK_IDENTIFIER */ #line 1915 "expparse.y" - { - Expression e; - Type t; - - /* it's true that we know it will be an entity_ type later */ - TypeBody tb = TYPEBODYcreate(set_); - tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); - SCOPEadd_super(tb->base); - t = TYPEcreate_from_body_anonymously(tb); - SCOPEadd_super(t); - e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); - yygotominor.yy91 = VARcreate(e, t); - yygotominor.yy91->flags.attribute = true; - yygotominor.yy91->flags.parameter = true; - - /* link it in to the current scope's dict */ - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, - yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); - } +{ + Expression e; + Type t; + + /* it's true that we know it will be an entity_ type later */ + TypeBody tb = TYPEBODYcreate(set_); + tb->base = TYPEcreate_name(yymsp[0].minor.yy0.symbol); + SCOPEadd_super(tb->base); + t = TYPEcreate_from_body_anonymously(tb); + SCOPEadd_super(t); + e = EXPcreate_from_symbol(t, yymsp[0].minor.yy0.symbol); + yygotominor.yy91 = VARcreate(e, t); + yygotominor.yy91->flags.attribute = true; + yygotominor.yy91->flags.parameter = true; + + /* link it in to the current scope's dict */ + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[0].minor.yy0.symbol->name, (Generic)yygotominor.yy91, + yymsp[0].minor.yy0.symbol, OBJ_VARIABLE); +} #line 4007 "expparse.c" - break; - case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ + break; + case 243: /* rule_formal_parameter_list ::= rule_formal_parameter */ #line 1936 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 4015 "expparse.c" - break; - case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ + break; + case 244: /* rule_formal_parameter_list ::= rule_formal_parameter_list TOK_COMMA rule_formal_parameter */ #line 1942 "expparse.y" - { - yygotominor.yy371 = yymsp[-2].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); - } +{ + yygotominor.yy371 = yymsp[-2].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy91); +} #line 4023 "expparse.c" - break; - case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ + break; + case 245: /* rule_header ::= rh_start rule_formal_parameter_list TOK_RIGHT_PAREN semicolon */ #line 1949 "expparse.y" - { - CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; +{ + CURRENT_SCOPE->u.rule->parameters = yymsp[-2].minor.yy371; - yygotominor.yy507 = yymsp[-3].minor.yy507; - } + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 4032 "expparse.c" - break; - case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ + break; + case 246: /* rh_start ::= TOK_RULE rh_get_line TOK_IDENTIFIER TOK_FOR TOK_LEFT_PAREN */ #line 1957 "expparse.y" - { - Rule r = ALGcreate(OBJ_RULE); +{ + Rule r = ALGcreate(OBJ_RULE); - if(print_objects_while_running & OBJ_RULE_BITS) { - fprintf(stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); - } + if (print_objects_while_running & OBJ_RULE_BITS) { + fprintf( stderr, "parse: %s (rule)\n", yymsp[-2].minor.yy0.symbol->name); + } - PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); + PUSH_SCOPE(r, yymsp[-2].minor.yy0.symbol, OBJ_RULE); - yygotominor.yy507 = yymsp[-3].minor.yy507; - } + yygotominor.yy507 = yymsp[-3].minor.yy507; +} #line 4047 "expparse.c" - break; - case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ + break; + case 250: /* schema_decl ::= schema_header schema_body TOK_END_SCHEMA semicolon */ #line 1984 "expparse.y" - { - POP_SCOPE(); - } +{ + POP_SCOPE(); +} #line 4054 "expparse.c" - break; - case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ + break; + case 252: /* schema_header ::= TOK_SCHEMA TOK_IDENTIFIER semicolon */ #line 1993 "expparse.y" - { - Schema schema = (Schema) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); - - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); - } - - if(EXPRESSignore_duplicate_schemas && schema) { - SCANskip_to_end_schema(parseData.scanner); - PUSH_SCOPE_DUMMY(); - } else { - schema = SCHEMAcreate(); - LISTadd_last(PARSEnew_schemas, (Generic)schema); - PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); - } - } +{ + Schema schema = ( Schema ) DICTlookup(CURRENT_SCOPE->symbol_table, yymsp[-1].minor.yy0.symbol->name); + + if (print_objects_while_running & OBJ_SCHEMA_BITS) { + fprintf( stderr, "parse: %s (schema)\n", yymsp[-1].minor.yy0.symbol->name); + } + + if (EXPRESSignore_duplicate_schemas && schema) { + SCANskip_to_end_schema(parseData.scanner); + PUSH_SCOPE_DUMMY(); + } else { + schema = SCHEMAcreate(); + LISTadd_last(PARSEnew_schemas, (Generic)schema); + PUSH_SCOPE(schema, yymsp[-1].minor.yy0.symbol, OBJ_SCHEMA); + } +} #line 4074 "expparse.c" - break; - case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ + break; + case 253: /* select_type ::= TOK_SELECT TOK_LEFT_PAREN defined_type_list TOK_RIGHT_PAREN */ #line 2012 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(select_); - yygotominor.yy477->list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy477 = TYPEBODYcreate(select_); + yygotominor.yy477->list = yymsp[-1].minor.yy371; +} #line 4082 "expparse.c" - break; - case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ + break; + case 255: /* set_type ::= TOK_SET bound_spec TOK_OF attribute_type */ #line 2023 "expparse.y" - { - yygotominor.yy477 = TYPEBODYcreate(set_); - yygotominor.yy477->base = yymsp[0].minor.yy297; - yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; - yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; - } +{ + yygotominor.yy477 = TYPEBODYcreate(set_); + yygotominor.yy477->base = yymsp[0].minor.yy297; + yygotominor.yy477->lower = yymsp[-2].minor.yy253.lower_limit; + yygotominor.yy477->upper = yymsp[-2].minor.yy253.upper_limit; +} #line 4092 "expparse.c" - break; - case 257: /* skip_statement ::= TOK_SKIP semicolon */ + break; + case 257: /* skip_statement ::= TOK_SKIP semicolon */ #line 2036 "expparse.y" - { - yygotominor.yy332 = STATEMENT_SKIP; - } +{ + yygotominor.yy332 = STATEMENT_SKIP; +} #line 4099 "expparse.c" - break; - case 258: /* statement ::= alias_statement */ - case 259: /* statement ::= assignment_statement */ - yytestcase(yyruleno == 259); - case 260: /* statement ::= case_statement */ - yytestcase(yyruleno == 260); - case 261: /* statement ::= compound_statement */ - yytestcase(yyruleno == 261); - case 262: /* statement ::= escape_statement */ - yytestcase(yyruleno == 262); - case 263: /* statement ::= if_statement */ - yytestcase(yyruleno == 263); - case 264: /* statement ::= proc_call_statement */ - yytestcase(yyruleno == 264); - case 265: /* statement ::= repeat_statement */ - yytestcase(yyruleno == 265); - case 266: /* statement ::= return_statement */ - yytestcase(yyruleno == 266); - case 267: /* statement ::= skip_statement */ - yytestcase(yyruleno == 267); + break; + case 258: /* statement ::= alias_statement */ + case 259: /* statement ::= assignment_statement */ yytestcase(yyruleno==259); + case 260: /* statement ::= case_statement */ yytestcase(yyruleno==260); + case 261: /* statement ::= compound_statement */ yytestcase(yyruleno==261); + case 262: /* statement ::= escape_statement */ yytestcase(yyruleno==262); + case 263: /* statement ::= if_statement */ yytestcase(yyruleno==263); + case 264: /* statement ::= proc_call_statement */ yytestcase(yyruleno==264); + case 265: /* statement ::= repeat_statement */ yytestcase(yyruleno==265); + case 266: /* statement ::= return_statement */ yytestcase(yyruleno==266); + case 267: /* statement ::= skip_statement */ yytestcase(yyruleno==267); #line 2041 "expparse.y" - { - yygotominor.yy332 = yymsp[0].minor.yy332; - } +{ + yygotominor.yy332 = yymsp[0].minor.yy332; +} #line 4115 "expparse.c" - break; - case 270: /* statement_rep ::= statement statement_rep */ + break; + case 270: /* statement_rep ::= statement statement_rep */ #line 2090 "expparse.y" - { - yygotominor.yy371 = yymsp[0].minor.yy371; - LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); - } +{ + yygotominor.yy371 = yymsp[0].minor.yy371; + LISTadd_first(yygotominor.yy371, (Generic)yymsp[-1].minor.yy332); +} #line 4123 "expparse.c" - break; - case 271: /* subsuper_decl ::= */ + break; + case 271: /* subsuper_decl ::= */ #line 2100 "expparse.y" - { - yygotominor.yy242.subtypes = EXPRESSION_NULL; - yygotominor.yy242.abstract = false; - yygotominor.yy242.supertypes = LIST_NULL; - } +{ + yygotominor.yy242.subtypes = EXPRESSION_NULL; + yygotominor.yy242.abstract = false; + yygotominor.yy242.supertypes = LIST_NULL; +} #line 4132 "expparse.c" - break; - case 272: /* subsuper_decl ::= supertype_decl */ + break; + case 272: /* subsuper_decl ::= supertype_decl */ #line 2106 "expparse.y" - { - yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; - yygotominor.yy242.supertypes = LIST_NULL; - } +{ + yygotominor.yy242.subtypes = yymsp[0].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[0].minor.yy385.abstract; + yygotominor.yy242.supertypes = LIST_NULL; +} #line 4141 "expparse.c" - break; - case 273: /* subsuper_decl ::= subtype_decl */ + break; + case 273: /* subsuper_decl ::= subtype_decl */ #line 2112 "expparse.y" - { - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; - yygotominor.yy242.abstract = false; - yygotominor.yy242.subtypes = EXPRESSION_NULL; - } +{ + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; + yygotominor.yy242.abstract = false; + yygotominor.yy242.subtypes = EXPRESSION_NULL; +} #line 4150 "expparse.c" - break; - case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ + break; + case 274: /* subsuper_decl ::= supertype_decl subtype_decl */ #line 2118 "expparse.y" - { - yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; - yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; - yygotominor.yy242.supertypes = yymsp[0].minor.yy371; - } +{ + yygotominor.yy242.subtypes = yymsp[-1].minor.yy385.subtypes; + yygotominor.yy242.abstract = yymsp[-1].minor.yy385.abstract; + yygotominor.yy242.supertypes = yymsp[0].minor.yy371; +} #line 4159 "expparse.c" - break; - case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ + break; + case 276: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE */ #line 2131 "expparse.y" - { - yygotominor.yy385.subtypes = (Expression)0; - yygotominor.yy385.abstract = true; - } +{ + yygotominor.yy385.subtypes = (Expression)0; + yygotominor.yy385.abstract = true; +} #line 4167 "expparse.c" - break; - case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 277: /* supertype_decl ::= TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2137 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = false; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = false; +} #line 4175 "expparse.c" - break; - case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 278: /* supertype_decl ::= TOK_ABSTRACT TOK_SUPERTYPE TOK_OF TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2143 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - yygotominor.yy385.abstract = true; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; + yygotominor.yy385.abstract = true; +} #line 4183 "expparse.c" - break; - case 279: /* supertype_expression ::= supertype_factor */ + break; + case 279: /* supertype_expression ::= supertype_factor */ #line 2149 "expparse.y" - { - yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; - } +{ + yygotominor.yy401 = yymsp[0].minor.yy385.subtypes; +} #line 4190 "expparse.c" - break; - case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ + break; + case 280: /* supertype_expression ::= supertype_expression TOK_AND supertype_factor */ #line 2153 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_AND, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); +} #line 4197 "expparse.c" - break; - case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ + break; + case 281: /* supertype_expression ::= supertype_expression TOK_ANDOR supertype_factor */ #line 2158 "expparse.y" - { - yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); - } +{ + yygotominor.yy401 = BIN_EXPcreate(OP_ANDOR, yymsp[-2].minor.yy401, yymsp[0].minor.yy385.subtypes); +} #line 4204 "expparse.c" - break; - case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ + break; + case 283: /* supertype_expression_list ::= supertype_expression_list TOK_COMMA supertype_expression */ #line 2169 "expparse.y" - { - LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); - yygotominor.yy371 = yymsp[-2].minor.yy371; - } +{ + LISTadd_last(yymsp[-2].minor.yy371, (Generic)yymsp[0].minor.yy401); + yygotominor.yy371 = yymsp[-2].minor.yy371; +} #line 4212 "expparse.c" - break; - case 284: /* supertype_factor ::= identifier */ + break; + case 284: /* supertype_factor ::= identifier */ #line 2175 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[0].minor.yy401; - } +{ + yygotominor.yy385.subtypes = yymsp[0].minor.yy401; +} #line 4219 "expparse.c" - break; - case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ + break; + case 285: /* supertype_factor ::= oneof_op TOK_LEFT_PAREN supertype_expression_list TOK_RIGHT_PAREN */ #line 2180 "expparse.y" - { - yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); - yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; - } +{ + yygotominor.yy385.subtypes = EXPcreate(Type_Oneof); + yygotominor.yy385.subtypes->u.list = yymsp[-1].minor.yy371; +} #line 4227 "expparse.c" - break; - case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ + break; + case 286: /* supertype_factor ::= TOK_LEFT_PAREN supertype_expression TOK_RIGHT_PAREN */ #line 2185 "expparse.y" - { - yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy385.subtypes = yymsp[-1].minor.yy401; +} #line 4234 "expparse.c" - break; - case 287: /* type ::= aggregation_type */ - case 288: /* type ::= basic_type */ - yytestcase(yyruleno == 288); - case 290: /* type ::= select_type */ - yytestcase(yyruleno == 290); + break; + case 287: /* type ::= aggregation_type */ + case 288: /* type ::= basic_type */ yytestcase(yyruleno==288); + case 290: /* type ::= select_type */ yytestcase(yyruleno==290); #line 2190 "expparse.y" - { - yygotominor.yy378.type = 0; - yygotominor.yy378.body = yymsp[0].minor.yy477; - } +{ + yygotominor.yy378.type = 0; + yygotominor.yy378.body = yymsp[0].minor.yy477; +} #line 4244 "expparse.c" - break; - case 292: /* type_item_body ::= type */ + break; + case 292: /* type_item_body ::= type */ #line 2215 "expparse.y" - { - CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; - CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; - } +{ + CURRENT_SCOPE->u.type->head = yymsp[0].minor.yy378.type; + CURRENT_SCOPE->u.type->body = yymsp[0].minor.yy378.body; +} #line 4252 "expparse.c" - break; - case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ + break; + case 294: /* ti_start ::= TOK_IDENTIFIER TOK_EQUAL */ #line 2223 "expparse.y" - { - Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); - PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); - } +{ + Type t = TYPEcreate_name(yymsp[-1].minor.yy0.symbol); + PUSH_SCOPE(t, yymsp[-1].minor.yy0.symbol, OBJ_TYPE); +} #line 4260 "expparse.c" - break; - case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ + break; + case 296: /* td_start ::= TOK_TYPE type_item where_rule_OPT */ #line 2234 "expparse.y" - { - CURRENT_SCOPE->where = yymsp[0].minor.yy371; - POP_SCOPE(); - yygotominor.yy0 = yymsp[-2].minor.yy0; - } +{ + CURRENT_SCOPE->where = yymsp[0].minor.yy371; + POP_SCOPE(); + yygotominor.yy0 = yymsp[-2].minor.yy0; +} #line 4269 "expparse.c" - break; - case 297: /* general_ref ::= assignable group_ref */ + break; + case 297: /* general_ref ::= assignable group_ref */ #line 2241 "expparse.y" - { - yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; - yygotominor.yy401 = yymsp[0].minor.yy401; - } +{ + yymsp[0].minor.yy401->e.op1 = yymsp[-1].minor.yy401; + yygotominor.yy401 = yymsp[0].minor.yy401; +} #line 4277 "expparse.c" - break; - case 307: /* unary_expression ::= TOK_NOT unary_expression */ + break; + case 307: /* unary_expression ::= TOK_NOT unary_expression */ #line 2284 "expparse.y" - { - yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); - } +{ + yygotominor.yy401 = UN_EXPcreate(OP_NOT, yymsp[0].minor.yy401); +} #line 4284 "expparse.c" - break; - case 309: /* unary_expression ::= TOK_MINUS unary_expression */ + break; + case 309: /* unary_expression ::= TOK_MINUS unary_expression */ #line 2292 "expparse.y" - { - yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); - } +{ + yygotominor.yy401 = UN_EXPcreate(OP_NEGATE, yymsp[0].minor.yy401); +} #line 4291 "expparse.c" - break; - case 310: /* unique ::= */ + break; + case 310: /* unique ::= */ #line 2297 "expparse.y" - { - yygotominor.yy252.unique = 0; - } +{ + yygotominor.yy252.unique = 0; +} #line 4298 "expparse.c" - break; - case 311: /* unique ::= TOK_UNIQUE */ + break; + case 311: /* unique ::= TOK_UNIQUE */ #line 2301 "expparse.y" - { - yygotominor.yy252.unique = 1; - } +{ + yygotominor.yy252.unique = 1; +} #line 4305 "expparse.c" - break; - case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ + break; + case 315: /* labelled_attrib_list ::= qualified_attr_list semicolon */ #line 2328 "expparse.y" - { - LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_first(yymsp[-1].minor.yy371, (Generic)EXPRESSION_NULL); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4313 "expparse.c" - break; - case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ + break; + case 316: /* labelled_attrib_list ::= TOK_IDENTIFIER TOK_COLON qualified_attr_list semicolon */ #line 2334 "expparse.y" - { - LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_first(yymsp[-1].minor.yy371, (Generic)yymsp[-3].minor.yy0.symbol); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4321 "expparse.c" - break; - case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ + break; + case 317: /* labelled_attrib_list_list ::= labelled_attrib_list */ #line 2341 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy371); +} #line 4329 "expparse.c" - break; - case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ + break; + case 318: /* labelled_attrib_list_list ::= labelled_attrib_list_list labelled_attrib_list */ #line 2347 "expparse.y" - { - LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); - yygotominor.yy371 = yymsp[-1].minor.yy371; - } +{ + LISTadd_last(yymsp[-1].minor.yy371, (Generic)yymsp[0].minor.yy371); + yygotominor.yy371 = yymsp[-1].minor.yy371; +} #line 4337 "expparse.c" - break; - case 321: /* until_control ::= */ - case 330: /* while_control ::= */ - yytestcase(yyruleno == 330); + break; + case 321: /* until_control ::= */ + case 330: /* while_control ::= */ yytestcase(yyruleno==330); #line 2362 "expparse.y" - { - yygotominor.yy401 = 0; - } +{ + yygotominor.yy401 = 0; +} #line 4345 "expparse.c" - break; - case 323: /* where_clause ::= expression semicolon */ + break; + case 323: /* where_clause ::= expression semicolon */ #line 2371 "expparse.y" - { - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); - yygotominor.yy234->expr = yymsp[-1].minor.yy401; - } +{ + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = SYMBOLcreate("", yylineno, current_filename); + yygotominor.yy234->expr = yymsp[-1].minor.yy401; +} #line 4354 "expparse.c" - break; - case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ + break; + case 324: /* where_clause ::= TOK_IDENTIFIER TOK_COLON expression semicolon */ #line 2377 "expparse.y" - { - yygotominor.yy234 = WHERE_new(); - yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; - yygotominor.yy234->expr = yymsp[-1].minor.yy401; - - if(!CURRENT_SCOPE->symbol_table) { - CURRENT_SCOPE->symbol_table = DICTcreate(25); - } - - DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, - yymsp[-3].minor.yy0.symbol, OBJ_WHERE); - } +{ + yygotominor.yy234 = WHERE_new(); + yygotominor.yy234->label = yymsp[-3].minor.yy0.symbol; + yygotominor.yy234->expr = yymsp[-1].minor.yy401; + + if (!CURRENT_SCOPE->symbol_table) { + CURRENT_SCOPE->symbol_table = DICTcreate(25); + } + + DICTdefine(CURRENT_SCOPE->symbol_table, yymsp[-3].minor.yy0.symbol->name, (Generic)yygotominor.yy234, + yymsp[-3].minor.yy0.symbol, OBJ_WHERE); +} #line 4370 "expparse.c" - break; - case 325: /* where_clause_list ::= where_clause */ + break; + case 325: /* where_clause_list ::= where_clause */ #line 2391 "expparse.y" - { - yygotominor.yy371 = LISTcreate(); - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); - } +{ + yygotominor.yy371 = LISTcreate(); + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); +} #line 4378 "expparse.c" - break; - case 326: /* where_clause_list ::= where_clause_list where_clause */ + break; + case 326: /* where_clause_list ::= where_clause_list where_clause */ #line 2396 "expparse.y" - { - yygotominor.yy371 = yymsp[-1].minor.yy371; - LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); - } +{ + yygotominor.yy371 = yymsp[-1].minor.yy371; + LISTadd_last(yygotominor.yy371, (Generic)yymsp[0].minor.yy234); +} #line 4386 "expparse.c" - break; - default: - /* (4) action_body_item_rep ::= */ - yytestcase(yyruleno == 4); - /* (41) block_list ::= */ yytestcase(yyruleno == 41); - /* (62) constant_body_list ::= */ yytestcase(yyruleno == 62); - /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno == 86); - /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno == 159); - /* (168) interface_specification_list ::= */ yytestcase(yyruleno == 168); - /* (194) local_body ::= */ yytestcase(yyruleno == 194); - /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno == 196); - /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno == 293); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto); - if(yyact < YYNSTATE) { + break; + default: + /* (4) action_body_item_rep ::= */ yytestcase(yyruleno==4); + /* (41) block_list ::= */ yytestcase(yyruleno==41); + /* (62) constant_body_list ::= */ yytestcase(yyruleno==62); + /* (86) express_file ::= schema_decl_list */ yytestcase(yyruleno==86); + /* (159) parened_rename_list ::= TOK_LEFT_PAREN rename_list TOK_RIGHT_PAREN */ yytestcase(yyruleno==159); + /* (168) interface_specification_list ::= */ yytestcase(yyruleno==168); + /* (194) local_body ::= */ yytestcase(yyruleno==194); + /* (196) local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off */ yytestcase(yyruleno==196); + /* (293) type_item ::= ti_start type_item_body semicolon */ yytestcase(yyruleno==293); + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser->yyidx -= yysize; + yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); + if( yyact < YYNSTATE ){ #ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if(yysize) { - yypParser->yyidx++; - yymsp -= yysize - 1; - yymsp->stateno = (YYACTIONTYPE)yyact; - yymsp->major = (YYCODETYPE)yygoto; - yymsp->minor = yygotominor; - } else + /* If we are not debugging and the reduce action popped at least + ** one element off the stack, then we can push the new element back + ** onto the stack here, and skip the stack overflow test in yy_shift(). + ** That gives a significant speed improvement. */ + if( yysize ){ + yypParser->yyidx++; + yymsp -= yysize-1; + yymsp->stateno = (YYACTIONTYPE)yyact; + yymsp->major = (YYCODETYPE)yygoto; + yymsp->minor = yygotominor; + }else #endif - { - yy_shift(yypParser, yyact, yygoto, &yygotominor); - } - } else { - assert(yyact == YYNSTATE + YYNRULE + 1); - yy_accept(yypParser); + { + yy_shift(yypParser,yyact,yygoto,&yygotominor); } + }else{ + assert( yyact == YYNSTATE + YYNRULE + 1 ); + yy_accept(yypParser); + } } /* @@ -4556,21 +4428,18 @@ static void yy_reduce( */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( - yyParser *yypParser /* The parser */ -) -{ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +){ + ParseARG_FETCH; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will be executed whenever the - ** parser fails */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -4578,12 +4447,11 @@ static void yy_parse_failed( ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -) -{ - ParseARG_FETCH; + yyParser *yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ +){ + ParseARG_FETCH; #define TOKEN (yyminor.yy0) #line 2424 "expparse.y" @@ -4597,30 +4465,27 @@ static void yy_syntax_error( sym.filename = current_filename; ERRORreport_with_symbol(SYNTAX, &sym, "Syntax error", - CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); + CURRENT_SCOPE_TYPE_PRINTABLE, CURRENT_SCOPE_NAME); #line 4470 "expparse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( - yyParser *yypParser /* The parser */ -) -{ - ParseARG_FETCH; + yyParser *yypParser /* The parser */ +){ + ParseARG_FETCH; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); + } #endif - while(yypParser->yyidx >= 0) { - yy_pop_parser_stack(yypParser); - } - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -4643,153 +4508,152 @@ static void yy_accept( ** None. */ void Parse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - ParseTOKENTYPE yyminor /* The value for the token */ - ParseARG_PDECL /* Optional %extra_argument parameter */ -) -{ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ + void *yyp, /* The parser */ + int yymajor, /* The major token code number */ + ParseTOKENTYPE yyminor /* The value for the token */ + ParseARG_PDECL /* Optional %extra_argument parameter */ +){ + YYMINORTYPE yyminorunion; + int yyact; /* The parser action. */ + int yyendofinput; /* True if we are at the end of input */ #ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ + int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser; /* The parser */ + yyParser *yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser *)yyp; - if(yypParser->yyidx < 0) { + /* (re)initialize the parser, if necessary */ + yypParser = (yyParser*)yyp; + if( yypParser->yyidx<0 ){ #if YYSTACKDEPTH<=0 - if(yypParser->yystksz <= 0) { - /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ - yyminorunion = yyzerominor; - yyStackOverflow(yypParser, &yyminorunion); - return; - } -#endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + if( yypParser->yystksz <=0 ){ + /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ + yyminorunion = yyzerominor; + yyStackOverflow(yypParser, &yyminorunion); + return; } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor == 0); - ParseARG_STORE; +#endif + yypParser->yyidx = 0; + yypParser->yyerrcnt = -1; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor; + yyendofinput = (yymajor==0); + ParseARG_STORE; #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); + } #endif - do { - yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor); - if(yyact < YYNSTATE) { - assert(!yyendofinput); /* Impossible to shift the $ token */ - yy_shift(yypParser, yyact, yymajor, &yyminorunion); - yypParser->yyerrcnt--; - yymajor = YYNOCODE; - } else if(yyact < YYNSTATE + YYNRULE) { - yy_reduce(yypParser, yyact - YYNSTATE); - } else { - assert(yyact == YY_ERROR_ACTION); + do{ + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); + if( yyactyyerrcnt--; + yymajor = YYNOCODE; + }else if( yyact < YYNSTATE + YYNRULE ){ + yy_reduce(yypParser,yyact-YYNSTATE); + }else{ + assert( yyact == YY_ERROR_ACTION ); #ifdef YYERRORSYMBOL - int yymx; + int yymx; #endif #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); + } #endif #ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if(yypParser->yyerrcnt < 0) { - yy_syntax_error(yypParser, yymajor, yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if(yymx == YYERRORSYMBOL || yyerrorhit) { + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( yypParser->yyerrcnt<0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yymx = yypParser->yystack[yypParser->yyidx].major; + if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG - if(yyTraceFILE) { - fprintf(yyTraceFILE, "%sDiscard input token %s\n", - yyTracePrompt, yyTokenName[yymajor]); - } + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sDiscard input token %s\n", + yyTracePrompt,yyTokenName[yymajor]); + } #endif - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yymajor = YYNOCODE; - } else { - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ) { - yy_pop_parser_stack(yypParser); - } - if(yypParser->yyidx < 0 || yymajor == 0) { - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - } else if(yymx != YYERRORSYMBOL) { - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser, yyact, YYERRORSYMBOL, &u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; + yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); + yymajor = YYNOCODE; + }else{ + while( + yypParser->yyidx >= 0 && + yymx != YYERRORSYMBOL && + (yyact = yy_find_reduce_action( + yypParser->yystack[yypParser->yyidx].stateno, + YYERRORSYMBOL)) >= YYNSTATE + ){ + yy_pop_parser_stack(yypParser); + } + if( yypParser->yyidx < 0 || yymajor==0 ){ + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + yy_parse_failed(yypParser); + yymajor = YYNOCODE; + }else if( yymx!=YYERRORSYMBOL ){ + YYMINORTYPE u2; + u2.YYERRSYMDT = 0; + yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); + } + } + yypParser->yyerrcnt = 3; + yyerrorhit = 1; #elif defined(YYNOERRORRECOVERY) - /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to - ** do any kind of error recovery. Instead, simply invoke the syntax - ** error routine and continue going as if nothing had happened. - ** - ** Applications can set this macro (for example inside %include) if - ** they intend to abandon the parse upon the first syntax error seen. - */ - yy_syntax_error(yypParser, yymajor, yyminorunion); - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - yymajor = YYNOCODE; - + /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + yy_syntax_error(yypParser,yymajor,yyminorunion); + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if(yypParser->yyerrcnt <= 0) { - yy_syntax_error(yypParser, yymajor, yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); - if(yyendofinput) { - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( yypParser->yyerrcnt<=0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yypParser->yyerrcnt = 3; + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + if( yyendofinput ){ + yy_parse_failed(yypParser); + } + yymajor = YYNOCODE; #endif - } - } while(yymajor != YYNOCODE && yypParser->yyidx >= 0); - return; + } + }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); + return; } diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index 1c5727001..b78b863a5 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -106,47 +106,42 @@ #include "expparse.h" #include "expscan.h" enum { INITIAL, code, comment, return_end_schema }; -extern int yylineno; -extern bool yyeof; -static int nesting_level = 0; +extern int yylineno; +extern bool yyeof; +static int nesting_level = 0; /* can't imagine this will ever be more than 2 or 3 - DEL */ #define MAX_NESTED_COMMENTS 20 static struct Symbol_ open_comment[MAX_NESTED_COMMENTS]; -/* isascii isn't part of newer C standards */ -#ifndef isascii -# define isascii(c) ((unsigned)((c) + 1) < 129) -#endif static_inline int -SCANnextchar(char *buffer) +SCANnextchar(char* buffer) { - extern bool SCANread(void); +extern bool SCANread(void); #ifdef keep_nul - static int escaped = 0; +static int escaped = 0; #endif - if(SCANtext_ready || SCANread()) { +if (SCANtext_ready || SCANread()) { #ifdef keep_nul - if(!*SCANcurrent) { - buffer[0] = SCAN_ESCAPE; - *SCANcurrent = '0'; - return 1; - } else if((*SCANcurrent == SCAN_ESCAPE) && !escaped) { - escaped = 1; - buffer[0] = SCAN_ESCAPE; - return 1; - } - SCANbuffer.numRead--; +if (!*SCANcurrent) { +buffer[0] = SCAN_ESCAPE; +*SCANcurrent = '0'; +return 1; +} else if ((*SCANcurrent == SCAN_ESCAPE) && !escaped) { +escaped = 1; +buffer[0] = SCAN_ESCAPE; +return 1; +} +SCANbuffer.numRead--; #endif - buffer[0] = *(SCANcurrent++); - if(!isascii(buffer[0])) { - ERRORreport_with_line(NONASCII_CHAR, yylineno, - 0xff & buffer[0]); - buffer[0] = ' '; /* substitute space */ - } - return 1; - } else { - return 0; - } +buffer[0] = *(SCANcurrent++); +if (!isascii(buffer[0])) { +ERRORreport_with_line(NONASCII_CHAR,yylineno, +0xff & buffer[0]); +buffer[0] = ' '; /* substitute space */ +} +return 1; +} else +return 0; } #define NEWLINE (yylineno++) /* when lex looks ahead over a newline, error messages get thrown off */ @@ -154,15 +149,14 @@ SCANnextchar(char *buffer) #define LINENO_FUDGE (yylineno - 1) /* added for re-initializing parser -snc 22-Apr-1992 */ void -SCAN_lex_init(char *filename, FILE *fp) -{ - /* return to initial scan buffer */ - SCAN_current_buffer = 0; - *(SCANcurrent = SCANbuffer.text) = '\0'; - SCANbuffer.readEof = false; - SCANbuffer.file = fp; - SCANbuffer.filename = (filename ? filename : ""); - current_filename = SCANbuffer.filename; +SCAN_lex_init(char *filename, FILE *fp) { +/* return to initial scan buffer */ +SCAN_current_buffer = 0; +*(SCANcurrent = SCANbuffer.text) = '\0'; +SCANbuffer.readEof = false; +SCANbuffer.file = fp; +SCANbuffer.filename = (filename ? filename : ""); +current_filename = SCANbuffer.filename; } #define PERPLEX_USING_CONDITIONS @@ -218,27 +212,27 @@ SCAN_lex_init(char *filename, FILE *fp) #include /* --- from flex's flexdef.h --- */ -void buf_init(struct Buf *buf, size_t elem_size); -void buf_destroy(struct Buf *buf); -struct Buf *buf_append(struct Buf *buf, const void *ptr, int n_elem); -struct Buf *buf_concat(struct Buf *dest, const struct Buf *src); +void buf_init(struct Buf * buf, size_t elem_size); +void buf_destroy(struct Buf * buf); +struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem); +struct Buf *buf_concat(struct Buf* dest, const struct Buf* src); struct Buf *buf_strappend(struct Buf *, const char *str); struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); -struct Buf *buf_strdefine(struct Buf *buf, const char *str, const char *def); -struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char *s); -struct Buf *buf_m4_define(struct Buf *buf, const char *def, const char *val); -struct Buf *buf_m4_undefine(struct Buf *buf, const char *def); -struct Buf *buf_print_strings(struct Buf *buf, FILE *out); -struct Buf *buf_linedir(struct Buf *buf, const char *filename, int lineno); +struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def); +struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); +struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val); +struct Buf *buf_m4_undefine(struct Buf *buf, const char* def); +struct Buf *buf_print_strings(struct Buf * buf, FILE* out); +struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno); /* --- from flex's misc.c --- */ -static void * +static void* allocate_array(int size, size_t element_size) { return malloc(element_size * size); } -static void * +static void* reallocate_array(void *array, int size, size_t element_size) { return realloc(array, element_size * size); @@ -248,17 +242,17 @@ reallocate_array(void *array, int size, size_t element_size) /* Take note: The buffer object is sometimes used as a String buffer (one * continuous string), and sometimes used as a list of strings, usually line by * line. - * + * * The type is specified in buf_init by the elt_size. If the elt_size is * sizeof(char), then the buffer should be treated as string buffer. If the * elt_size is sizeof(char*), then the buffer should be treated as a list of * strings. * - * Certain functions are only appropriate for one type or the other. + * Certain functions are only appropriate for one type or the other. */ -struct Buf * -buf_print_strings(struct Buf *buf, FILE *out) +struct Buf* +buf_print_strings(struct Buf * buf, FILE* out) { int i; @@ -266,22 +260,22 @@ buf_print_strings(struct Buf *buf, FILE *out) return buf; } - for(i = 0; i < buf->nelts; i++) { - const char *s = ((char **)buf->elts)[i]; + for (i = 0; i < buf->nelts; i++) { + const char *s = ((char**)buf->elts)[i]; if(s) { fprintf(out, "%s", s); - } + } } return buf; } /* Append a "%s" formatted string to a string buffer */ -struct Buf * +struct Buf* buf_prints(struct Buf *buf, const char *fmt, const char *s) { char *t; - t = (char *)malloc(strlen(fmt) + strlen(s) + 1); + t = (char*)malloc(strlen(fmt) + strlen(s) + 1); sprintf(t, fmt, s); buf = buf_strappend(buf, t); free(t); @@ -295,12 +289,12 @@ int numDigits(int n) /* take absolute value of n */ n = n >= 0 ? n : -n; - if(n == 0) { - return 1; + if (n == 0) { + return 1; } - for(digits = 0; n > 0; digits++) { - n /= 10; + for (digits = 0; n > 0; digits++) { + n /= 10; } return digits; @@ -312,13 +306,13 @@ int numDigits(int n) * @param lineno line number * @return buf */ -struct Buf * -buf_linedir(struct Buf *buf, const char *filename, int lineno) +struct Buf* +buf_linedir(struct Buf *buf, const char* filename, int lineno) { char *t; const char fmt[] = "#line %d \"%s\"\n"; - - t = (char *)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); + + t = (char*)malloc(strlen(fmt) + strlen(filename) + numDigits(lineno) + 1); sprintf(t, fmt, lineno, filename); buf = buf_strappend(buf, t); free(t); @@ -331,8 +325,8 @@ buf_linedir(struct Buf *buf, const char *filename, int lineno) * @param @a dest the source buffer * @return @a dest */ -struct Buf * -buf_concat(struct Buf *dest, const struct Buf *src) +struct Buf* +buf_concat(struct Buf* dest, const struct Buf* src) { buf_append(dest, src->elts, src->nelts); return dest; @@ -340,7 +334,7 @@ buf_concat(struct Buf *dest, const struct Buf *src) /* Appends n characters in str to buf. */ -struct Buf * +struct Buf* buf_strnappend(struct Buf *buf, const char *str, int n) { buf_append(buf, str, n + 1); @@ -352,14 +346,14 @@ buf_strnappend(struct Buf *buf, const char *str, int n) } /* Appends characters in str to buf. */ -struct Buf * +struct Buf* buf_strappend(struct Buf *buf, const char *str) { return buf_strnappend(buf, str, strlen(str)); } /* appends "#define str def\n" */ -struct Buf * +struct Buf* buf_strdefine(struct Buf *buf, const char *str, const char *def) { buf_strappend(buf, "#define "); @@ -377,14 +371,14 @@ buf_strdefine(struct Buf *buf, const char *str, const char *def) * @param val The definition; may be NULL. * @return buf */ -struct Buf * -buf_m4_define(struct Buf *buf, const char *def, const char *val) +struct Buf* +buf_m4_define(struct Buf *buf, const char* def, const char* val) { const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n"; char *str; val = val ? val : ""; - str = (char *)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); + str = (char*)malloc(strlen(fmt) + strlen(def) + strlen(val) + 2); sprintf(str, fmt, def, val); buf_append(buf, &str, 1); @@ -396,13 +390,13 @@ buf_m4_define(struct Buf *buf, const char *def, const char *val) * @param def The m4 symbol to undefine. * @return buf */ -struct Buf * -buf_m4_undefine(struct Buf *buf, const char *def) +struct Buf* +buf_m4_undefine(struct Buf *buf, const char* def) { const char *fmt = "m4_undefine( [[%s]])m4_dnl\n"; char *str; - str = (char *)malloc(strlen(fmt) + strlen(def) + 2); + str = (char*)malloc(strlen(fmt) + strlen(def) + 2); sprintf(str, fmt, def); buf_append(buf, &str, 1); @@ -413,7 +407,7 @@ buf_m4_undefine(struct Buf *buf, const char *def) void buf_init(struct Buf *buf, size_t elem_size) { - buf->elts = (void *)0; + buf->elts = (void*)0; buf->nelts = 0; buf->elt_size = elem_size; buf->nmax = 0; @@ -423,12 +417,11 @@ buf_init(struct Buf *buf, size_t elem_size) void buf_destroy(struct Buf *buf) { - if(buf && buf->elts) { - free(buf->elts); - } - if(buf) { - buf->elts = (void *)0; + if (buf && buf->elts) { + free(buf->elts); } + if (buf) + buf->elts = (void*)0; } /* appends ptr[] to buf, grow if necessary. @@ -436,33 +429,33 @@ buf_destroy(struct Buf *buf) * returns buf. * We grow by mod(512) boundaries. */ -struct Buf * +struct Buf* buf_append(struct Buf *buf, const void *ptr, int n_elem) { int n_alloc = 0; - if(!ptr || n_elem == 0) { - return buf; + if (!ptr || n_elem == 0) { + return buf; } /* May need to alloc more. */ - if(n_elem + buf->nelts > buf->nmax) { - /* exact amount needed... */ - n_alloc = (n_elem + buf->nelts) * buf->elt_size; - - /* ...plus some extra */ - if(((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { - n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; - } - if(!buf->elts) { - buf->elts = allocate_array(n_alloc, buf->elt_size); - } else { - buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); - } - buf->nmax = n_alloc; + if (n_elem + buf->nelts > buf->nmax) { + /* exact amount needed... */ + n_alloc = (n_elem + buf->nelts) * buf->elt_size; + + /* ...plus some extra */ + if (((n_alloc * buf->elt_size) % 512) != 0 && buf->elt_size < 512) { + n_alloc += (512 - ((n_alloc * buf->elt_size) % 512)) / buf->elt_size; + } + if (!buf->elts) { + buf->elts = allocate_array(n_alloc, buf->elt_size); + } else { + buf->elts = reallocate_array(buf->elts, n_alloc, buf->elt_size); + } + buf->nmax = n_alloc; } - memcpy((char *)buf->elts + buf->nelts * buf->elt_size, ptr, - n_elem * buf->elt_size); + memcpy((char*)buf->elts + buf->nelts * buf->elt_size, ptr, + n_elem * buf->elt_size); buf->nelts += n_elem; @@ -475,18 +468,18 @@ buf_append(struct Buf *buf, const void *ptr, int n_elem) */ /* get pointer to the start of the first element */ -static char * +static char* bufferFirstElt(struct Buf *buf) { - return (char *)buf->elts; + return (char*)buf->elts; } /* get pointer to the start of the last element */ -static char * +static char* bufferLastElt(struct Buf *buf) { - if(buf->nelts < 1) { - return NULL; + if (buf->nelts < 1) { + return NULL; } return bufferFirstElt(buf) + buf->nelts - 1; } @@ -515,7 +508,7 @@ bufferAppend(perplex_t scanner, size_t n) in = scanner->inFile; /* save marker offsets */ - bufStart = (char *)buf->elts; + bufStart = (char*)buf->elts; cursorOffset = (size_t)(scanner->cursor - bufStart); markerOffset = (size_t)(scanner->marker - bufStart); tokenStartOffset = (size_t)(scanner->tokenStart - bufStart); @@ -523,12 +516,12 @@ bufferAppend(perplex_t scanner, size_t n) /* remove last (null) element */ buf->nelts--; - for(i = 0; i < n; i++) { - if((c = fgetc(in)) == EOF) { - scanner->atEOI = 1; - break; - } - bufferAppendChar(buf, c); + for (i = 0; i < n; i++) { + if ((c = fgetc(in)) == EOF) { + scanner->atEOI = 1; + break; + } + bufferAppendChar(buf, c); } /* (scanner->null - eltSize) should be the last input element, @@ -538,7 +531,7 @@ bufferAppend(perplex_t scanner, size_t n) scanner->null = bufferLastElt(buf); /* update markers in case append caused buffer to be reallocated */ - bufStart = (char *)buf->elts; + bufStart = (char*)buf->elts; scanner->cursor = bufStart + cursorOffset; scanner->marker = bufStart + markerOffset; scanner->tokenStart = bufStart + tokenStartOffset; @@ -551,9 +544,9 @@ bufferFill(perplex_t scanner, size_t n) struct Buf *buf; size_t totalElts, usedElts, freeElts; - if(scanner->atEOI) { - /* nothing to add to buffer */ - return; + if (scanner->atEOI) { + /* nothing to add to buffer */ + return; } buf = scanner->buffer; @@ -563,53 +556,53 @@ bufferFill(perplex_t scanner, size_t n) freeElts = totalElts - usedElts; /* not enough room for append, shift buffer contents to avoid realloc */ - if(n > freeElts) { - void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; - size_t bytesInUse, shiftSize; + if (n > freeElts) { + void *bufFirst, *scannerFirst, *tokenStart, *marker, *null; + size_t bytesInUse, shiftSize; - tokenStart = (void *)scanner->tokenStart; - marker = (void *)scanner->marker; - null = (void *)scanner->null; + tokenStart = (void*)scanner->tokenStart; + marker = (void*)scanner->marker; + null = (void*)scanner->null; - bufFirst = bufferFirstElt(buf); + bufFirst = bufferFirstElt(buf); - /* Find first buffer element still in use by scanner. Will be - * tokenStart unless backtracking marker is in use. - */ - scannerFirst = tokenStart; - if(marker >= bufFirst && marker < tokenStart) { - scannerFirst = marker; - } + /* Find first buffer element still in use by scanner. Will be + * tokenStart unless backtracking marker is in use. + */ + scannerFirst = tokenStart; + if (marker >= bufFirst && marker < tokenStart) { + scannerFirst = marker; + } - /* bytes of input being used by scanner */ - bytesInUse = (size_t)null - (size_t)scannerFirst + 1; + /* bytes of input being used by scanner */ + bytesInUse = (size_t)null - (size_t)scannerFirst + 1; - /* copy in-use elements to start of buffer */ - memmove(bufFirst, scannerFirst, bytesInUse); + /* copy in-use elements to start of buffer */ + memmove(bufFirst, scannerFirst, bytesInUse); - /* update number of elements */ + /* update number of elements */ buf->nelts = bytesInUse / buf->elt_size; - /* update markers */ - shiftSize = (size_t)scannerFirst - (size_t)bufFirst; - scanner->marker -= shiftSize; - scanner->cursor -= shiftSize; - scanner->null -= shiftSize; - scanner->tokenStart -= shiftSize; + /* update markers */ + shiftSize = (size_t)scannerFirst - (size_t)bufFirst; + scanner->marker -= shiftSize; + scanner->cursor -= shiftSize; + scanner->null -= shiftSize; + scanner->tokenStart -= shiftSize; } bufferAppend(scanner, n); } -static char * +static char* getTokenText(perplex_t scanner) { int tokenChars = scanner->cursor - scanner->tokenStart; - if(scanner->tokenText != NULL) { - free(scanner->tokenText); + if (scanner->tokenText != NULL) { + free(scanner->tokenText); } - scanner->tokenText = (char *)malloc(sizeof(char) * (tokenChars + 1)); + scanner->tokenText = (char*)malloc(sizeof(char) * (tokenChars + 1)); memcpy(scanner->tokenText, scanner->tokenStart, tokenChars); scanner->tokenText[tokenChars] = '\0'; @@ -635,7 +628,7 @@ newScanner() static void initBuffer(perplex_t scanner) { - scanner->buffer = (struct Buf *)malloc(sizeof(struct Buf)); + scanner->buffer = (struct Buf*)malloc(sizeof(struct Buf)); buf_init(scanner->buffer, sizeof(char)); } @@ -654,8 +647,8 @@ perplexStringScanner(char *firstChar, size_t numChars) buf = scanner->buffer; /* copy string to buffer */ - for(i = 0; i < numChars; i++) { - bufferAppendChar(buf, firstChar[i]); + for (i = 0; i < numChars; i++) { + bufferAppendChar(buf, firstChar[i]); } bufferAppendChar(buf, '\0'); @@ -686,9 +679,9 @@ perplexFileScanner(FILE *input) void perplexFree(perplex_t scanner) { - if(scanner->buffer != NULL) { - buf_destroy(scanner->buffer); - free(scanner->buffer); + if (scanner->buffer != NULL) { + buf_destroy(scanner->buffer); + free(scanner->buffer); } free(scanner); @@ -700,7 +693,7 @@ perplexSetExtra(perplex_t scanner, void *extra) scanner->extra = extra; } -void * +void* perplexGetExtra(perplex_t scanner) { return scanner->extra; @@ -738,8 +731,8 @@ perplexUnput(perplex_t scanner, char c) /* input from cursor to null is shifted to the right */ cursor = scanner->cursor; - for(curr = scanner->null; curr != cursor; curr--) { - curr[0] = curr[-1]; + for (curr = scanner->null; curr != cursor; curr--) { + curr[0] = curr[-1]; } /* insert c */ @@ -781,10 +774,9 @@ PERPLEX_PUBLIC_LEXER { ret = PERPLEX_LEXER_private(scanner); - if(scanner->tokenText != NULL) - { - free(scanner->tokenText); - scanner->tokenText = NULL; + if (scanner->tokenText != NULL) { + free(scanner->tokenText); + scanner->tokenText = NULL; } return ret; @@ -796,1109 +788,921 @@ PERPLEX_PRIVATE_LEXER { PERPLEX_ON_ENTER; - while(1) - { - if(scanner->atEOI && scanner->cursor >= scanner->null) { - return YYEOF; - } - - { - unsigned int yyaccept = 0; - switch(YYGETCONDITION) { - case 0: - goto yyc_0; - case code: - goto yyc_code; - case comment: - goto yyc_comment; - case return_end_schema: - goto yyc_return_end_schema; - } - /* *********************************** */ + while (1) { + if (scanner->atEOI && scanner->cursor >= scanner->null) { + return YYEOF; + } + + { + unsigned int yyaccept = 0; + switch (YYGETCONDITION) { + case 0: goto yyc_0; + case code: goto yyc_code; + case comment: goto yyc_comment; + case return_end_schema: goto yyc_return_end_schema; + } +/* *********************************** */ yyc_0: - YYSETCONDITION(code); - { - } - /* *********************************** */ + YYSETCONDITION(code); + { +} +/* *********************************** */ yyc_code: - if((scanner->null - scanner->cursor) < 4) { - YYFILL(4); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy8; - case '\n': - goto yy9; - case '"': - goto yy11; - case '$': - case '&': - case '@': - case '^': - case '~': - goto yy12; - case '%': - goto yy14; - case '\'': - goto yy15; - case '(': - goto yy16; - case ')': - goto yy18; - case '*': - goto yy20; - case '+': - goto yy22; - case ',': - goto yy24; - case '-': - goto yy26; - case '.': - goto yy28; - case '/': - goto yy30; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy32; - case ':': - goto yy34; - case ';': - goto yy36; - case '<': - goto yy38; - case '=': - goto yy40; - case '>': - goto yy42; - case '?': - goto yy44; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy46; - case '[': - goto yy48; - case '\\': - goto yy50; - case ']': - goto yy52; - case '_': - goto yy54; - case '{': - goto yy56; - case '|': - goto yy58; - case '}': - goto yy60; - default: - goto yy6; - } -yy5: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 4) YYFILL(4); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy8; + case '\n': goto yy9; + case '"': goto yy11; + case '$': + case '&': + case '@': + case '^': + case '~': goto yy12; + case '%': goto yy14; + case '\'': goto yy15; + case '(': goto yy16; + case ')': goto yy18; + case '*': goto yy20; + case '+': goto yy22; + case ',': goto yy24; + case '-': goto yy26; + case '.': goto yy28; + case '/': goto yy30; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy32; + case ':': goto yy34; + case ';': goto yy36; + case '<': goto yy38; + case '=': goto yy40; + case '>': goto yy42; + case '?': goto yy44; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy46; + case '[': goto yy48; + case '\\': goto yy50; + case ']': goto yy52; + case '_': goto yy54; + case '{': goto yy56; + case '|': goto yy58; + case '}': goto yy60; + default: goto yy6; + } +yy5: + { +IGNORE_TOKEN; } yy6: - ++scanner->cursor; -yy7: { - IGNORE_TOKEN; - } + ++scanner->cursor; +yy7: + { +IGNORE_TOKEN; } yy8: - yych = *++scanner->cursor; - goto yy127; + yych = *++scanner->cursor; + goto yy127; yy9: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy11: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy121; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy121; yy12: - ++scanner->cursor; -yy13: { - ERRORreport_with_line(UNEXPECTED_CHARACTER, yylineno, yytext[0]); - IGNORE_TOKEN; - } + ++scanner->cursor; +yy13: + { +ERRORreport_with_line(UNEXPECTED_CHARACTER,yylineno,yytext[0]); +IGNORE_TOKEN; +} yy14: - yych = *++scanner->cursor; - switch(yych) { - case '0': - case '1': - goto yy117; - default: - goto yy13; - } + yych = *++scanner->cursor; + switch (yych) { + case '0': + case '1': goto yy117; + default: goto yy13; + } yy15: - yyaccept = 0; - yych = *(scanner->marker = ++scanner->cursor); - goto yy112; + yyaccept = 0; + yych = *(scanner->marker = ++scanner->cursor); + goto yy112; yy16: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy109; - default: - goto yy17; - } -yy17: { - return TOK_LEFT_PAREN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy109; + default: goto yy17; + } +yy17: + { +return TOK_LEFT_PAREN; } yy18: - ++scanner->cursor; - { - return TOK_RIGHT_PAREN; - } + ++scanner->cursor; + { +return TOK_RIGHT_PAREN; } yy20: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case ')': - goto yy105; - case '*': - goto yy107; - default: - goto yy21; - } -yy21: { - return TOK_TIMES; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case ')': goto yy105; + case '*': goto yy107; + default: goto yy21; + } +yy21: + { +return TOK_TIMES; } yy22: - ++scanner->cursor; - { - return TOK_PLUS; - } + ++scanner->cursor; + { +return TOK_PLUS; } yy24: - ++scanner->cursor; - { - return TOK_COMMA; - } + ++scanner->cursor; + { +return TOK_COMMA; } yy26: - yyaccept = 1; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '-': - goto yy101; - default: - goto yy27; - } -yy27: { - return TOK_MINUS; - } + yyaccept = 1; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '-': goto yy101; + default: goto yy27; + } +yy27: + { +return TOK_MINUS; } yy28: - ++scanner->cursor; - { - return TOK_DOT; - } + ++scanner->cursor; + { +return TOK_DOT; } yy30: - ++scanner->cursor; - { - return TOK_REAL_DIV; - } + ++scanner->cursor; + { +return TOK_REAL_DIV; } yy32: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '.': - goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy92; - default: - goto yy33; - } -yy33: { - return SCANprocess_integer_literal(yytext); - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '.': goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy92; + default: goto yy33; + } +yy33: + { +return SCANprocess_integer_literal(yytext); +} yy34: - yyaccept = 2; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '<': - goto yy84; - case '=': - goto yy85; - default: - goto yy35; - } -yy35: { - return TOK_COLON; - } + yyaccept = 2; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '<': goto yy84; + case '=': goto yy85; + default: goto yy35; + } +yy35: + { +return TOK_COLON; } yy36: - yyaccept = 3; - yych = *(scanner->marker = ++scanner->cursor); - switch(yych) { - case '\t': - case ' ': - goto yy76; - case '-': - goto yy79; - default: - goto yy37; - } -yy37: { - return SCANprocess_semicolon(yytext, 0); - } + yyaccept = 3; + yych = *(scanner->marker = ++scanner->cursor); + switch (yych) { + case '\t': + case ' ': goto yy76; + case '-': goto yy79; + default: goto yy37; + } +yy37: + { +return SCANprocess_semicolon(yytext, 0); } yy38: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy74; - case '=': - goto yy72; - case '>': - goto yy70; - default: - goto yy39; - } -yy39: { - return TOK_LESS_THAN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy74; + case '=': goto yy72; + case '>': goto yy70; + default: goto yy39; + } +yy39: + { +return TOK_LESS_THAN; } yy40: - ++scanner->cursor; - { - return TOK_EQUAL; - } + ++scanner->cursor; + { +return TOK_EQUAL; } yy42: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '=': - goto yy68; - default: - goto yy43; - } -yy43: { - return TOK_GREATER_THAN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '=': goto yy68; + default: goto yy43; + } +yy43: + { +return TOK_GREATER_THAN; } yy44: - ++scanner->cursor; - { - return TOK_QUESTION_MARK; - } + ++scanner->cursor; + { +return TOK_QUESTION_MARK; } yy46: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy67; -yy47: { - return SCANprocess_identifier_or_keyword(yytext); - } + ++scanner->cursor; + yych = *scanner->cursor; + goto yy67; +yy47: + { +return SCANprocess_identifier_or_keyword(yytext); +} yy48: - ++scanner->cursor; - { - return TOK_LEFT_BRACKET; - } + ++scanner->cursor; + { +return TOK_LEFT_BRACKET; } yy50: - ++scanner->cursor; - { - return TOK_BACKSLASH; - } + ++scanner->cursor; + { +return TOK_BACKSLASH; } yy52: - ++scanner->cursor; - { - return TOK_RIGHT_BRACKET; - } + ++scanner->cursor; + { +return TOK_RIGHT_BRACKET; } yy54: - ++scanner->cursor; - yych = *scanner->cursor; - goto yy65; -yy55: { - ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); - return SCANprocess_identifier_or_keyword(yytext); - } + ++scanner->cursor; + yych = *scanner->cursor; + goto yy65; +yy55: + { +ERRORreport_with_line(BAD_IDENTIFIER, yylineno, yytext); +return SCANprocess_identifier_or_keyword(yytext); +} yy56: - ++scanner->cursor; - { - return TOK_LEFT_CURL; - } + ++scanner->cursor; + { +return TOK_LEFT_CURL; } yy58: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '|': - goto yy62; - default: - goto yy59; - } -yy59: { - return TOK_SUCH_THAT; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '|': goto yy62; + default: goto yy59; + } +yy59: + { +return TOK_SUCH_THAT; } yy60: - ++scanner->cursor; - { - return TOK_RIGHT_CURL; - } + ++scanner->cursor; + { +return TOK_RIGHT_CURL; } yy62: - ++scanner->cursor; - { - return TOK_CONCAT_OP; - } + ++scanner->cursor; + { +return TOK_CONCAT_OP; } yy64: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy65: - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy64; - default: - goto yy55; - } + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy64; + default: goto yy55; + } yy66: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy67: - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - goto yy66; - default: - goto yy47; - } + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy66; + default: goto yy47; + } yy68: - ++scanner->cursor; - { - return TOK_GREATER_EQUAL; - } + ++scanner->cursor; + { +return TOK_GREATER_EQUAL; } yy70: - ++scanner->cursor; - { - return TOK_NOT_EQUAL; - } + ++scanner->cursor; + { +return TOK_NOT_EQUAL; } yy72: - ++scanner->cursor; - { - return TOK_LESS_EQUAL; - } + ++scanner->cursor; + { +return TOK_LESS_EQUAL; } yy74: - ++scanner->cursor; - { - return TOK_ALL_IN; - } + ++scanner->cursor; + { +return TOK_ALL_IN; } yy76: - ++scanner->cursor; - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy76; - case '-': - goto yy79; - default: - goto yy78; - } + ++scanner->cursor; + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy76; + case '-': goto yy79; + default: goto yy78; + } yy78: - scanner->cursor = scanner->marker; - switch(yyaccept) { - case 0: - goto yy7; - case 1: - goto yy27; - case 2: - goto yy35; - case 3: - goto yy37; - case 4: - goto yy96; - case 5: - goto yy114; - } + scanner->cursor = scanner->marker; + switch (yyaccept) { + case 0: goto yy7; + case 1: goto yy27; + case 2: goto yy35; + case 3: goto yy37; + case 4: goto yy96; + case 5: goto yy114; + } yy79: - yych = *++scanner->cursor; - switch(yych) { - case '-': - goto yy80; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '-': goto yy80; + default: goto yy78; + } yy80: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\n': - goto yy82; - default: - goto yy80; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\n': goto yy82; + default: goto yy80; + } yy82: - ++scanner->cursor; - { - NEWLINE; - return SCANprocess_semicolon(yytext, 1); - } + ++scanner->cursor; + { +NEWLINE; +return SCANprocess_semicolon(yytext, 1); +} yy84: - yych = *++scanner->cursor; - switch(yych) { - case '>': - goto yy89; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '>': goto yy89; + default: goto yy78; + } yy85: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case ':': - goto yy87; - default: - goto yy86; - } -yy86: { - return TOK_ASSIGNMENT; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case ':': goto yy87; + default: goto yy86; + } +yy86: + { +return TOK_ASSIGNMENT; } yy87: - ++scanner->cursor; - { - return TOK_INST_EQUAL; - } + ++scanner->cursor; + { +return TOK_INST_EQUAL; } yy89: - yych = *++scanner->cursor; - switch(yych) { - case ':': - goto yy90; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case ':': goto yy90; + default: goto yy78; + } yy90: - ++scanner->cursor; - { - return TOK_INST_NOT_EQUAL; - } + ++scanner->cursor; + { +return TOK_INST_NOT_EQUAL; } yy92: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '.': - goto yy94; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy92; - default: - goto yy33; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '.': goto yy94; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy92; + default: goto yy33; + } yy94: - yyaccept = 4; - scanner->marker = ++scanner->cursor; - if((scanner->null - scanner->cursor) < 3) { - YYFILL(3); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy94; - case 'E': - case 'e': - goto yy97; - default: - goto yy96; - } -yy96: { - return SCANprocess_real_literal(yytext); - } + yyaccept = 4; + scanner->marker = ++scanner->cursor; + if ((scanner->null - scanner->cursor) < 3) YYFILL(3); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy94; + case 'E': + case 'e': goto yy97; + default: goto yy96; + } +yy96: + { +return SCANprocess_real_literal(yytext); +} yy97: - yych = *++scanner->cursor; - switch(yych) { - case '+': - case '-': - goto yy98; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '+': + case '-': goto yy98; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy78; + } yy98: - yych = *++scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy78; - } + yych = *++scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy78; + } yy99: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - goto yy99; - default: - goto yy96; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy99; + default: goto yy96; + } yy101: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\n': - goto yy103; - default: - goto yy101; - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\n': goto yy103; + default: goto yy101; + } yy103: - ++scanner->cursor; - { - NEWLINE; - SCANsave_comment(yytext); - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +SCANsave_comment(yytext); +IGNORE_TOKEN; +} yy105: - ++scanner->cursor; - { - ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); - IGNORE_TOKEN; - } + ++scanner->cursor; + { +ERRORreport_with_line(UNMATCHED_CLOSE_COMMENT, yylineno); +IGNORE_TOKEN; +} yy107: - ++scanner->cursor; - { - return TOK_EXP; - } + ++scanner->cursor; + { +return TOK_EXP; } yy109: - ++scanner->cursor; - YYSETCONDITION(comment); - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + YYSETCONDITION(comment); + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy112: - switch(yych) { - case '\n': - goto yy115; - case '\'': - goto yy113; - default: - goto yy111; - } + switch (yych) { + case '\n': goto yy115; + case '\'': goto yy113; + default: goto yy111; + } yy113: - yyaccept = 5; - scanner->marker = ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\'': - goto yy111; - default: - goto yy114; - } -yy114: { - return SCANprocess_string(yytext); - } + yyaccept = 5; + scanner->marker = ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\'': goto yy111; + default: goto yy114; + } +yy114: + { +return SCANprocess_string(yytext); +} yy115: - ++scanner->cursor; - { - ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); - NEWLINE; - return SCANprocess_string(yytext); - } + ++scanner->cursor; + { +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); +NEWLINE; +return SCANprocess_string(yytext); +} yy117: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '0': - case '1': - goto yy117; - default: - goto yy119; - } -yy119: { - return SCANprocess_binary_literal(yytext); - } + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '0': + case '1': goto yy117; + default: goto yy119; + } +yy119: + { +return SCANprocess_binary_literal(yytext); +} yy120: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy121: - switch(yych) { - case '\n': - goto yy122; - case '"': - goto yy124; - default: - goto yy120; - } + switch (yych) { + case '\n': goto yy122; + case '"': goto yy124; + default: goto yy120; + } yy122: - ++scanner->cursor; - { - ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); - NEWLINE; - return SCANprocess_encoded_string(yytext); - } + ++scanner->cursor; + { +ERRORreport_with_line(UNTERMINATED_STRING, LINENO_FUDGE); +NEWLINE; +return SCANprocess_encoded_string(yytext); +} yy124: - ++scanner->cursor; - { - return SCANprocess_encoded_string(yytext); - } + ++scanner->cursor; + { +return SCANprocess_encoded_string(yytext); +} yy126: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy127: - switch(yych) { - case '\t': - case ' ': - goto yy126; - default: - goto yy5; - } - /* *********************************** */ + switch (yych) { + case '\t': + case ' ': goto yy126; + default: goto yy5; + } +/* *********************************** */ yyc_comment: - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy132; - case '\n': - goto yy133; - case '(': - goto yy135; - case ')': - goto yy137; - case '*': - goto yy138; - default: - goto yy131; - } -yy130: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy132; + case '\n': goto yy133; + case '(': goto yy135; + case ')': goto yy137; + case '*': goto yy138; + default: goto yy131; + } +yy130: + { +IGNORE_TOKEN; } yy131: - yych = *++scanner->cursor; - goto yy144; + yych = *++scanner->cursor; + goto yy144; yy132: - yych = *++scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy145; - default: - goto yy144; - } + yych = *++scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy145; + default: goto yy144; + } yy133: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy135: - ++scanner->cursor; - switch((yych = *scanner->cursor)) { - case '*': - goto yy141; - default: - goto yy136; - } -yy136: { - IGNORE_TOKEN; - } + ++scanner->cursor; + switch ((yych = *scanner->cursor)) { + case '*': goto yy141; + default: goto yy136; + } +yy136: + { +IGNORE_TOKEN; } yy137: - yych = *++scanner->cursor; - goto yy136; + yych = *++scanner->cursor; + goto yy136; yy138: - yych = *++scanner->cursor; - switch(yych) { - case ')': - goto yy139; - default: - goto yy136; - } + yych = *++scanner->cursor; + switch (yych) { + case ')': goto yy139; + default: goto yy136; + } yy139: - ++scanner->cursor; - { - if(0 == --nesting_level) { - YYSETCONDITION(code); - } - IGNORE_TOKEN; - } + ++scanner->cursor; + { +if (0 == --nesting_level) { +YYSETCONDITION(code); +} +IGNORE_TOKEN; +} yy141: - ++scanner->cursor; - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy144: - switch(yych) { - case '\n': - case '(': - case ')': - case '*': - goto yy130; - default: - goto yy143; - } + switch (yych) { + case '\n': + case '(': + case ')': + case '*': goto yy130; + default: goto yy143; + } yy145: - ++scanner->cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy145; - case '\n': - case '(': - case ')': - case '*': - goto yy130; - default: - goto yy143; - } - /* *********************************** */ + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy145; + case '\n': + case '(': + case ')': + case '*': goto yy130; + default: goto yy143; + } +/* *********************************** */ yyc_return_end_schema: - if((scanner->null - scanner->cursor) < 2) { - YYFILL(2); - } - yych = *scanner->cursor; - switch(yych) { - case '\t': - case ' ': - goto yy152; - case '\n': - goto yy153; - case '(': - goto yy155; - case 'X': - case 'x': - goto yy156; - default: - goto yy150; - } -yy149: { - IGNORE_TOKEN; - } + if ((scanner->null - scanner->cursor) < 2) YYFILL(2); + yych = *scanner->cursor; + switch (yych) { + case '\t': + case ' ': goto yy152; + case '\n': goto yy153; + case '(': goto yy155; + case 'X': + case 'x': goto yy156; + default: goto yy150; + } +yy149: + { +IGNORE_TOKEN; } yy150: - ++scanner->cursor; -yy151: { - IGNORE_TOKEN; - } + ++scanner->cursor; +yy151: + { +IGNORE_TOKEN; } yy152: - yych = *++scanner->cursor; - goto yy161; + yych = *++scanner->cursor; + goto yy161; yy153: - ++scanner->cursor; - { - NEWLINE; - IGNORE_TOKEN; - } + ++scanner->cursor; + { +NEWLINE; +IGNORE_TOKEN; +} yy155: - yych = *++scanner->cursor; - switch(yych) { - case '*': - goto yy158; - default: - goto yy151; - } + yych = *++scanner->cursor; + switch (yych) { + case '*': goto yy158; + default: goto yy151; + } yy156: - ++scanner->cursor; - YYSETCONDITION(code); - { - return TOK_END_SCHEMA; - } + ++scanner->cursor; + YYSETCONDITION(code); + { +return TOK_END_SCHEMA; +} yy158: - ++scanner->cursor; - YYSETCONDITION(comment); - { - if(nesting_level < MAX_NESTED_COMMENTS) { - open_comment[nesting_level].line = yylineno; - open_comment[nesting_level].filename = current_filename; - } - nesting_level++; - IGNORE_TOKEN; - } + ++scanner->cursor; + YYSETCONDITION(comment); + { +if (nesting_level cursor; - if(scanner->null <= scanner->cursor) { - YYFILL(1); - } - yych = *scanner->cursor; + ++scanner->cursor; + if (scanner->null <= scanner->cursor) YYFILL(1); + yych = *scanner->cursor; yy161: - switch(yych) { - case '\t': - case ' ': - goto yy160; - default: - goto yy149; - } - } + switch (yych) { + case '\t': + case ' ': goto yy160; + default: goto yy149; + } + } } } @@ -1907,7 +1711,7 @@ yy151: { void SCANskip_to_end_schema(perplex_t scanner) { - while(yylex(scanner) != TOK_END_SCHEMA); - perplexUnput(scanner, 'X'); /* any old character */ - YYSETCONDITION(return_end_schema); +while (yylex(scanner) != TOK_END_SCHEMA); +perplexUnput(scanner, 'X'); /* any old character */ +YYSETCONDITION(return_end_schema); } diff --git a/src/express/generated/expscan.h b/src/express/generated/expscan.h index 7b0ccb3a6..a9e6705cf 100644 --- a/src/express/generated/expscan.h +++ b/src/express/generated/expscan.h @@ -56,10 +56,10 @@ #define YYEOF -1 struct Buf { - void *elts; /* elements. */ - int nelts; /* number of elements. */ - size_t elt_size; /* in bytes. */ - int nmax; /* max capacity of elements. */ + void *elts; /* elements. */ + int nelts; /* number of elements. */ + size_t elt_size; /* in bytes. */ + int nmax; /* max capacity of elements. */ }; /* scanner data */ @@ -82,7 +82,7 @@ void perplexFree(perplex_t scanner); void perplexUnput(perplex_t scanner, char c); void perplexSetExtra(perplex_t scanner, void *extra); -void *perplexGetExtra(perplex_t scanner); +void* perplexGetExtra(perplex_t scanner); #ifndef PERPLEX_LEXER #define PERPLEX_LEXER yylex diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake new file mode 100644 index 000000000..b3d7b3608 --- /dev/null +++ b/src/express/generated/verification_info.cmake @@ -0,0 +1,7 @@ +# Autogenerated verification information +set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) +set(baseline_expparse_y_md5 3722242f16c679c40323317833757a6d) +set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) +set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) +set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) +set(baseline_expparse_h_md5 e4a5599839b2a9f7a6915a0dcc7747b0) diff --git a/src/express/hash.c b/src/express/hash.c index eeb073a8a..5556ade92 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -116,8 +116,8 @@ ** Internal routines */ -static inline Address HASHhash(char *, Hash_Table); -static void HASHexpand_table(Hash_Table); +static inline Address HASHhash( char *, Hash_Table ); +static void HASHexpand_table( Hash_Table ); /* ** Local data @@ -132,13 +132,11 @@ static long HashAccesses, HashCollisions; */ void -HASHinitialize() -{ +HASHinitialize() { } Hash_Table -HASHcreate(unsigned count) -{ +HASHcreate( unsigned count ) { unsigned i; Hash_Table table; @@ -147,10 +145,10 @@ HASHcreate(unsigned count) ** minimum SEGMENT_SIZE, then convert into segments. */ i = SEGMENT_SIZE; - while(i < count) { + while( i < count ) { i <<= 1; } - count = DIV(i, SEGMENT_SIZE_SHIFT); + count = DIV( i, SEGMENT_SIZE_SHIFT ); table = HASH_Table_new(); #if 0 @@ -160,33 +158,32 @@ HASHcreate(unsigned count) /* ** Allocate initial 'i' segments of buckets */ - for(i = 0; i < count; i++) - CALLOC(table->Directory[i], SEGMENT_SIZE, Element) + for( i = 0; i < count; i++ ) + CALLOC( table->Directory[i], SEGMENT_SIZE, Element ) /*, "segment in HASHcreate");*/ table->SegmentCount = count; - table->maxp = MUL(count, SEGMENT_SIZE_SHIFT); + table->maxp = MUL( count, SEGMENT_SIZE_SHIFT ); table->MinLoadFactor = 1; table->MaxLoadFactor = MAX_LOAD_FACTOR; # ifdef HASH_DEBUG - fprintf(stderr, - "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", - table, - count, - table->maxp, - table->SegmentCount); + fprintf( stderr, + "[HASHcreate] table %x count %d maxp %d SegmentCount %d\n", + table, + count, + table->maxp, + table->SegmentCount ); # endif # ifdef HASH_STATISTICS HashAccesses = HashCollisions = 0; # endif - return(table); + return( table ); } /* initialize pointer to beginning of hash table so we can step through it */ /* on repeated calls to HASHlist - DEL */ void -HASHlistinit(Hash_Table table, HashEntry *he) -{ +HASHlistinit( Hash_Table table, HashEntry * he ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -197,8 +194,7 @@ HASHlistinit(Hash_Table table, HashEntry *he) } void -HASHlistinit_by_type(Hash_Table table, HashEntry *he, char type) -{ +HASHlistinit_by_type( Hash_Table table, HashEntry * he, char type ) { he->i = he->j = 0; he->p = 0; he->table = table; @@ -211,27 +207,25 @@ HASHlistinit_by_type(Hash_Table table, HashEntry *he, char type) #if 0 /* if you don't step to the end, you can clear the flag this way */ void -HASHlistend(HashEntry *he) -{ +HASHlistend( HashEntry * he ) { he->table->in_use = 0; } #endif /* provide a way to step through the hash */ Element -HASHlist(HashEntry *he) -{ +HASHlist( HashEntry * he ) { int i2 = he->i; int j2 = he->j; Segment s; he->e = 0; - for(he->i = i2; he->i < he->table->SegmentCount; he->i++) { + for( he->i = i2; he->i < he->table->SegmentCount; he->i++ ) { /* test probably unnecessary */ - if((s = he->table->Directory[he->i]) != NULL) { - for(he->j = j2; he->j < SEGMENT_SIZE; he->j++) { - if(!he->p) { + if( ( s = he->table->Directory[he->i] ) != NULL ) { + for( he->j = j2; he->j < SEGMENT_SIZE; he->j++ ) { + if( !he->p ) { he->p = s[he->j]; } @@ -240,22 +234,22 @@ HASHlist(HashEntry *he) for he->p */ retry: - if(he->p) { - if((he->type != '*') && - (he->type != he->p->type)) { + if( he->p ) { + if( ( he->type != '*' ) && + ( he->type != he->p->type ) ) { he->p = he->p->next; goto retry; } - if(he->e) { - return(he->e); + if( he->e ) { + return( he->e ); } he->e = he->p; he->p = he->p->next; } /* avoid incrementing he->j by returning here */ - if(he->p) { - return(he->e); + if( he->p ) { + return( he->e ); } } j2 = 0; @@ -265,58 +259,55 @@ HASHlist(HashEntry *he) #if 0 he->table->in_use = 0; #endif - return(he->e); + return( he->e ); } #if 0 /* this verifies no one else is walking through the table that we might screw up */ /* it should be called before adding, deleting or destroying a table */ -HASH_in_use(Hash_Table table, char *action) -{ - fprintf(stderr, "HASH: attempted to %s but hash table in use\n", action); +HASH_in_use( Hash_Table table, char * action ) { + fprintf( stderr, "HASH: attempted to %s but hash table in use\n", action ); } #endif void -HASHdestroy(Hash_Table table) -{ +HASHdestroy( Hash_Table table ) { Segment s; Element p, q; - if(table != HASH_NULL) { + if( table != HASH_NULL ) { unsigned int i, j; #if 0 - if(table->in_use) { - HASH_in_use(table, "destroy hash table"); + if( table->in_use ) { + HASH_in_use( table, "destroy hash table" ); } #endif - for(i = 0; i < table->SegmentCount; i++) { + for( i = 0; i < table->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = table->Directory[i]) != NULL) { - for(j = 0; j < SEGMENT_SIZE; j++) { + if( ( s = table->Directory[i] ) != NULL ) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { p = s[j]; - while(p != NULL) { + while( p != NULL ) { q = p->next; - HASH_Element_destroy(p); + HASH_Element_destroy( p ); p = q; } } - sc_free(table->Directory[i]); + sc_free( table->Directory[i] ); } } - HASH_Table_destroy(table); + HASH_Table_destroy( table ); # if defined(HASH_STATISTICS) && defined(HASH_DEBUG) - fprintf(stderr, - "[hdestroy] Accesses %ld Collisions %ld\n", - HashAccesses, - HashCollisions); + fprintf( stderr, + "[hdestroy] Accesses %ld Collisions %ld\n", + HashAccesses, + HashCollisions ); # endif } } Element -HASHsearch(Hash_Table table, Element item, Action action) -{ +HASHsearch( Hash_Table table, Element item, Action action ) { Address h; Segment CurrentSegment; int SegmentIndex; @@ -325,18 +316,18 @@ HASHsearch(Hash_Table table, Element item, Action action) Element q; Element deleteme; - assert(table != HASH_NULL); /* Kinder really than return(NULL); */ + assert( table != HASH_NULL ); /* Kinder really than return(NULL); */ # ifdef HASH_STATISTICS HashAccesses++; # endif - h = HASHhash(item->key, table); - SegmentDir = DIV(h, SEGMENT_SIZE_SHIFT); - SegmentIndex = MOD(h, SEGMENT_SIZE); + h = HASHhash( item->key, table ); + SegmentDir = DIV( h, SEGMENT_SIZE_SHIFT ); + SegmentIndex = MOD( h, SEGMENT_SIZE ); /* ** valid segment ensured by HASHhash() */ CurrentSegment = table->Directory[SegmentDir]; - assert(CurrentSegment != NULL); /* bad failure if tripped */ + assert( CurrentSegment != NULL ); /* bad failure if tripped */ p = CurrentSegment + SegmentIndex; q = *p; /* @@ -345,7 +336,7 @@ HASHsearch(Hash_Table table, Element item, Action action) ** p = &element, and ** q = element */ - while(q != NULL && strcmp(q->key, item->key)) { + while( q != NULL && strcmp( q->key, item->key ) ) { p = &q->next; q = *p; # ifdef HASH_STATISTICS @@ -353,34 +344,34 @@ HASHsearch(Hash_Table table, Element item, Action action) # endif } /* at this point, we have either found the element or it doesn't exist */ - switch(action) { + switch( action ) { case HASH_FIND: - return((Element)q); + return( ( Element )q ); case HASH_DELETE: - if(!q) { - return(0); + if( !q ) { + return( 0 ); } /* at this point, element exists and action == DELETE */ #if 0 - if(table->in_use) { - HASH_in_use(table, "insert element"); + if( table->in_use ) { + HASH_in_use( table, "insert element" ); } #endif deleteme = q; *p = q->next; /*STRINGfree(deleteme->key);*/ - HASH_Element_destroy(deleteme); + HASH_Element_destroy( deleteme ); --table->KeyCount; - return(deleteme); /* of course, user shouldn't deref this! */ + return( deleteme ); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ - if(q != NULL) { - return(q); /* was return(0);!!!!!?!?! */ + if( q != NULL ) { + return( q ); /* was return(0);!!!!!?!?! */ } #if 0 - if(table->in_use) { - HASH_in_use(table, "delete element"); + if( table->in_use ) { + HASH_in_use( table, "delete element" ); } #endif /* at this point, element does not exist and action == INSERT */ @@ -399,63 +390,61 @@ HASHsearch(Hash_Table table, Element item, Action action) /* ** table over-full? */ - if(++table->KeyCount / MUL(table->SegmentCount, SEGMENT_SIZE_SHIFT) > table->MaxLoadFactor) { - HASHexpand_table(table); /* doesn't affect q */ + if( ++table->KeyCount / MUL( table->SegmentCount, SEGMENT_SIZE_SHIFT ) > table->MaxLoadFactor ) { + HASHexpand_table( table ); /* doesn't affect q */ } } - return((Element)0); /* was return (Element)q */ + return( ( Element )0 ); /* was return (Element)q */ } /* ** Internal routines */ -static inline Address HASHhash(char *Key, Hash_Table table) -{ +static inline Address HASHhash( char * Key, Hash_Table table ) { Address h, address; - register unsigned char *k = (unsigned char *)Key; + register unsigned char * k = ( unsigned char * )Key; h = 0; /* ** Convert string to integer */ /*SUPPRESS 112*/ - assert(Key); - while(*k) + assert( Key ); + while( *k ) /*SUPPRESS 8*/ { /*SUPPRESS 112*/ - h = h * PRIME1 ^ (*k++ - ' '); + h = h * PRIME1 ^ ( *k++ - ' ' ); } h %= PRIME2; - address = MOD(h, table->maxp); - if(address < table->p) { - address = MOD(h, (table->maxp << 1)); /* h % (2*table->maxp) */ + address = MOD( h, table->maxp ); + if( address < table->p ) { + address = MOD( h, ( table->maxp << 1 ) ); /* h % (2*table->maxp) */ } - return(address); + return( address ); } -static void HASHexpand_table(Hash_Table table) -{ +static void HASHexpand_table( Hash_Table table ) { Segment OldSegment, NewSegment; Element Current, *Previous, *LastOfNew; - if(table->maxp + table->p < MUL(DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT)) { + if( table->maxp + table->p < MUL( DIRECTORY_SIZE, SEGMENT_SIZE_SHIFT ) ) { Address NewAddress; int OldSegmentIndex, NewSegmentIndex; int OldSegmentDir, NewSegmentDir; /* ** Locate the bucket to be split */ - OldSegmentDir = DIV(table->p, SEGMENT_SIZE_SHIFT); + OldSegmentDir = DIV( table->p, SEGMENT_SIZE_SHIFT ); OldSegment = table->Directory[OldSegmentDir]; - OldSegmentIndex = MOD(table->p, SEGMENT_SIZE); + OldSegmentIndex = MOD( table->p, SEGMENT_SIZE ); /* ** Expand address space; if necessary create a new segment */ NewAddress = table->maxp + table->p; - NewSegmentDir = DIV(NewAddress, SEGMENT_SIZE_SHIFT); - NewSegmentIndex = MOD(NewAddress, SEGMENT_SIZE); - if(NewSegmentIndex == 0) { - CALLOC(table->Directory[NewSegmentDir], SEGMENT_SIZE, Element); + NewSegmentDir = DIV( NewAddress, SEGMENT_SIZE_SHIFT ); + NewSegmentIndex = MOD( NewAddress, SEGMENT_SIZE ); + if( NewSegmentIndex == 0 ) { + CALLOC( table->Directory[NewSegmentDir], SEGMENT_SIZE, Element ); } /* "segment in HASHexpand_table");*/ NewSegment = table->Directory[NewSegmentDir]; @@ -463,7 +452,7 @@ static void HASHexpand_table(Hash_Table table) ** Adjust state variables */ table->p++; - if(table->p == table->maxp) { + if( table->p == table->maxp ) { table->maxp <<= 1; /* table->maxp *= 2 */ table->p = 0; } @@ -475,8 +464,8 @@ static void HASHexpand_table(Hash_Table table) Current = *Previous; LastOfNew = &NewSegment[NewSegmentIndex]; *LastOfNew = NULL; - while(Current != NULL) { - if(HASHhash(Current->key, table) == NewAddress) { + while( Current != NULL ) { + if( HASHhash( Current->key, table ) == NewAddress ) { /* ** Attach it to the end of the new chain */ @@ -504,17 +493,16 @@ static void HASHexpand_table(Hash_Table table) /* But then, it isn't called when objects are inserted/deleted so this seems */ /* reasonable - DEL */ Hash_Table -HASHcopy(Hash_Table oldtable) -{ +HASHcopy( Hash_Table oldtable ) { Hash_Table newtable; Segment s, s2; - Element *pp; /* old element */ - Element *qq; /* new element */ + Element * pp; /* old element */ + Element * qq; /* new element */ unsigned int i, j; newtable = HASH_Table_new(); - for(i = 0; i < oldtable->SegmentCount; i++) { - CALLOC(newtable->Directory[i], SEGMENT_SIZE, Element); + for( i = 0; i < oldtable->SegmentCount; i++ ) { + CALLOC( newtable->Directory[i], SEGMENT_SIZE, Element ); /* "segment in HASHcopy");*/ } @@ -525,55 +513,54 @@ HASHcopy(Hash_Table oldtable) newtable->MaxLoadFactor = oldtable->MaxLoadFactor; newtable->KeyCount = oldtable->KeyCount; - for(i = 0; i < oldtable->SegmentCount; i++) { + for( i = 0; i < oldtable->SegmentCount; i++ ) { /* test probably unnecessary */ - if((s = oldtable->Directory[i]) != NULL) { + if( ( s = oldtable->Directory[i] ) != NULL ) { s2 = newtable->Directory[i]; - for(j = 0; j < SEGMENT_SIZE; j++) { + for( j = 0; j < SEGMENT_SIZE; j++ ) { qq = &s2[j]; - for(pp = &s[j]; *pp; pp = &(*pp)->next) { + for( pp = &s[j]; *pp; pp = &( *pp )->next ) { *qq = HASH_Element_new(); /* (*qq)->key = STRINGcopy((*pp)->key);*/ /* I really doubt it is necessary to copy the key!!! */ - (*qq)->key = (*pp)->key; - (*qq)->data = (*pp)->data; - (*qq)->symbol = (*pp)->symbol; - (*qq)->type = (*pp)->type; - (*qq)->next = NULL; - qq = &((*qq)->next); + ( *qq )->key = ( *pp )->key; + ( *qq )->data = ( *pp )->data; + ( *qq )->symbol = ( *pp )->symbol; + ( *qq )->type = ( *pp )->type; + ( *qq )->next = NULL; + qq = &( ( *qq )->next ); } } } } - return(newtable); + return( newtable ); } /* following code is for testing hash package */ #ifdef HASHTEST struct Element e1, e2, e3, *e; -struct Hash_Table *t; +struct Hash_Table * t; HashEntry he; -main() -{ +main() { e1.key = "foo"; - e1.data = (char *)1; + e1.data = ( char * )1; e2.key = "bar"; - e2.data = (char *)2; + e2.data = ( char * )2; e3.key = "herschel"; - e3.data = (char *)3; - - t = HASHcreate(100); - e = HASHsearch(t, &e1, HASH_INSERT); - e = HASHsearch(t, &e2, HASH_INSERT); - e = HASHsearch(t, &e3, HASH_INSERT); - HASHlistinit(t, &he); - for(;;) { - e = HASHlist(&he); - if(!e) { - exit(0); + e3.data = ( char * )3; + + t = HASHcreate( 100 ); + e = HASHsearch( t, &e1, HASH_INSERT ); + e = HASHsearch( t, &e2, HASH_INSERT ); + e = HASHsearch( t, &e3, HASH_INSERT ); + HASHlistinit( t, &he ); + for( ;; ) { + e = HASHlist( &he ); + if( !e ) { + exit( 0 ); } - fprintf(stderr, "found key %s, data %d\n", e->key, (int)e->data); + fprintf( stderr, "found key %s, data %d\n", e->key, ( int )e->data ); } } #endif diff --git a/src/express/info.c b/src/express/info.c index 2839d5c15..50af7ab11 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -4,34 +4,40 @@ #include "express/info.h" #include "express/express.h" -char *EXPRESSversion(void) -{ - return("Express Language, IS (N65), October 24, 1994"); +#ifndef SCHEMA_SCANNER +# include "sc_version_string.h" +#else + /* dummy string to make the compiler happy when building the schema scanner, + * should never be seen by users */ + const char * sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; +#endif + +char * EXPRESSversion( void ) { + return( "Express Language, IS (N65), October 24, 1994" ); } -void EXPRESSusage(int _exit) -{ - fprintf(stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name); - fprintf(stderr, "where\t-v produces the following version description:\n"); - fprintf(stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, SC_VERSION); - fprintf(stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n"); - fprintf(stderr, "\t-p turns on printing when processing certain objects (see below)\n"); - fprintf(stderr, "\t-w warning enable\n"); - fprintf(stderr, "\t-i warning ignore\n"); - fprintf(stderr, "and is one of:\n"); - fprintf(stderr, "\tnone\n\tall\n"); - fprintf(stderr, "%s", ERRORget_warnings_help("\t", "\n")); - fprintf(stderr, "and is one or more of:\n"); - fprintf(stderr, " e entity\n"); - fprintf(stderr, " p procedure\n"); - fprintf(stderr, " r rule\n"); - fprintf(stderr, " f function\n"); - fprintf(stderr, " t type\n"); - fprintf(stderr, " s schema or file\n"); - fprintf(stderr, " # pass #\n"); - fprintf(stderr, " E everything (all of the above)\n"); - if(_exit) { - exit(2); +void EXPRESSusage( int _exit ) { + fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); + fprintf( stderr, "where\t-v produces the following version description:\n" ); + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version ); + fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); + fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); + fprintf( stderr, "\t-w warning enable\n" ); + fprintf( stderr, "\t-i warning ignore\n" ); + fprintf( stderr, "and is one of:\n" ); + fprintf( stderr, "\tnone\n\tall\n" ); + fprintf( stderr, ERRORget_warnings_help("\t", "\n") ); + fprintf( stderr, "and is one or more of:\n" ); + fprintf( stderr, " e entity\n" ); + fprintf( stderr, " p procedure\n" ); + fprintf( stderr, " r rule\n" ); + fprintf( stderr, " f function\n" ); + fprintf( stderr, " t type\n" ); + fprintf( stderr, " s schema or file\n" ); + fprintf( stderr, " # pass #\n" ); + fprintf( stderr, " E everything (all of the above)\n" ); + if( _exit ) { + exit( 2 ); } } diff --git a/src/express/inithook.c b/src/express/inithook.c index edf3fbcec..a3d3eac5d 100644 --- a/src/express/inithook.c +++ b/src/express/inithook.c @@ -2,7 +2,6 @@ /* dummy function, user can supply one allowing them to setup a backend */ /* or customize other parts of fedex application */ -void EXPRESSinit_init(void) -{ +void EXPRESSinit_init( void ) { } diff --git a/src/express/lexact.c b/src/express/lexact.c index 27db69163..abcde3176 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -71,20 +71,20 @@ extern YYSTYPE yylval; Scan_Buffer SCAN_buffers[SCAN_NESTING_DEPTH]; int SCAN_current_buffer = 0; -char *SCANcurrent; +char * SCANcurrent; extern int yylineno; #define SCAN_COMMENT_LENGTH 256 static char last_comment_[256] = ""; -static char *last_comment = 0; +static char * last_comment = 0; /* keyword lookup table */ static Hash_Table keyword_dictionary; static struct keyword_entry { - char *key; + char * key; int token; } keywords[] = { { "ABS", TOK_BUILTIN_FUNCTION }, @@ -206,8 +206,7 @@ static struct keyword_entry { { 0, 0} }; -static void SCANpush_buffer(char *filename, FILE *fp) -{ +static void SCANpush_buffer( char * filename, FILE * fp ) { SCANbuffer.savedPos = SCANcurrent; SCANbuffer.lineno = yylineno; yylineno = 1; @@ -215,17 +214,16 @@ static void SCANpush_buffer(char *filename, FILE *fp) #ifdef keep_nul SCANbuffer.numRead = 0; #else - *(SCANcurrent = SCANbuffer.text) = '\0'; + *( SCANcurrent = SCANbuffer.text ) = '\0'; #endif SCANbuffer.readEof = false; SCANbuffer.file = fp; SCANbuffer.filename = current_filename = filename; } -static void SCANpop_buffer() -{ - if(SCANbuffer.file != NULL) { - fclose(SCANbuffer.file); +static void SCANpop_buffer() { + if( SCANbuffer.file != NULL ) { + fclose( SCANbuffer.file ); } --SCAN_current_buffer; SCANcurrent = SCANbuffer.savedPos; @@ -233,43 +231,37 @@ static void SCANpop_buffer() current_filename = SCANbuffer.filename; } -void SCANinitialize(void) -{ - struct keyword_entry *k; +void SCANinitialize( void ) { + struct keyword_entry * k; - keyword_dictionary = HASHcreate(100); /* not exact */ - for(k = keywords; k->key; k++) { - DICTdefine(keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN); + keyword_dictionary = HASHcreate( 100 ); /* not exact */ + for( k = keywords; k->key; k++ ) { + DICTdefine( keyword_dictionary, k->key, k, NULL, OBJ_UNKNOWN ); /* not "unknown", but certainly won't be looked up by type! */ } } /** Clean up the Scan module */ -void SCANcleanup(void) -{ +void SCANcleanup( void ) { } -int SCANprocess_real_literal(const char *yytext) -{ - sscanf(yytext, "%lf", &(yylval.rVal)); +int SCANprocess_real_literal( const char * yytext ) { + sscanf( yytext, "%lf", &( yylval.rVal ) ); return TOK_REAL_LITERAL; } -int SCANprocess_integer_literal(const char *yytext) -{ - sscanf(yytext, "%d", &(yylval.iVal)); +int SCANprocess_integer_literal( const char * yytext ) { + sscanf( yytext, "%d", &( yylval.iVal ) ); return TOK_INTEGER_LITERAL; } -int SCANprocess_binary_literal(const char *yytext) -{ - yylval.binary = SCANstrdup(yytext + 1); /* drop '%' prefix */ +int SCANprocess_binary_literal( const char * yytext ) { + yylval.binary = SCANstrdup( yytext + 1 ); /* drop '%' prefix */ return TOK_BINARY_LITERAL; } -int SCANprocess_logical_literal(char *string) -{ - switch(string[0]) { +int SCANprocess_logical_literal( char * string ) { + switch( string[0] ) { case 'T': yylval.logical = Ltrue; break; @@ -281,67 +273,65 @@ int SCANprocess_logical_literal(char *string) break; /* default will actually be triggered by 'UNKNOWN' keyword */ } - sc_free(string); + sc_free( string ); return TOK_LOGICAL_LITERAL; } -int SCANprocess_identifier_or_keyword(const char *yytext) -{ - char *test_string, * dest; - const char *src; - struct keyword_entry *k; +int SCANprocess_identifier_or_keyword( const char * yytext ) { + char * test_string, * dest; + const char * src; + struct keyword_entry * k; int len; /* make uppercase copy */ - len = strlen(yytext); - dest = test_string = (char *)sc_malloc(len + 1); - for(src = yytext; *src; src++, dest++) { - *dest = (islower(*src) ? toupper(*src) : *src); + len = strlen( yytext ); + dest = test_string = ( char * )sc_malloc( len + 1 ); + for( src = yytext; *src; src++, dest++ ) { + *dest = ( islower( *src ) ? toupper( *src ) : *src ); } *dest = '\0'; /* check for language keywords */ - k = (struct keyword_entry *)DICTlookup(keyword_dictionary, test_string); - if(k) { - switch(k->token) { + k = ( struct keyword_entry * )DICTlookup( keyword_dictionary, test_string ); + if( k ) { + switch( k->token ) { case TOK_BUILTIN_FUNCTION: case TOK_BUILTIN_PROCEDURE: break; case TOK_LOGICAL_LITERAL: - return SCANprocess_logical_literal(test_string); + return SCANprocess_logical_literal( test_string ); default: - sc_free(test_string); + sc_free( test_string ); return k->token; } } /* now we have an identifier token */ - yylval.symbol = SYMBOLcreate(test_string, yylineno, current_filename); - if(k) { + yylval.symbol = SYMBOLcreate( test_string, yylineno, current_filename ); + if( k ) { /* built-in function/procedure */ - return(k->token); + return( k->token ); } else { /* plain identifier */ /* translate back to lower-case */ - SCANlowerize(test_string); + SCANlowerize( test_string ); return TOK_IDENTIFIER; } } -int SCANprocess_string(const char *yytext) -{ - char *s, *d; /* source, destination */ +int SCANprocess_string( const char * yytext ) { + char * s, *d; /* source, destination */ /* strip off quotes */ - yylval.string = SCANstrdup(yytext + 1); /* remove 1st single quote */ + yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st single quote */ /* change pairs of quotes to single quotes */ - for(s = d = yylval.string; *s;) { - if(*s != '\'') { + for( s = d = yylval.string; *s; ) { + if( *s != '\'' ) { *d++ = *s++; - } else if(0 == strncmp(s, "''", 2)) { + } else if( 0 == strncmp( s, "''", 2 ) ) { *d++ = '\''; s += 2; - } else if(*s == '\'') { + } else if( *s == '\'' ) { /* trailing quote */ *s = '\0'; /* if string was unterminated, there will be no */ @@ -354,68 +344,64 @@ int SCANprocess_string(const char *yytext) return TOK_STRING_LITERAL; } -int SCANprocess_encoded_string(const char *yytext) -{ - char *s; /* source */ +int SCANprocess_encoded_string( const char * yytext ) { + char * s; /* source */ int count; /* strip off quotes */ - yylval.string = SCANstrdup(yytext + 1); /* remove 1st double quote */ + yylval.string = SCANstrdup( yytext + 1 ); /* remove 1st double quote */ - s = strrchr(yylval.string, '"'); - if(s) { + s = strrchr( yylval.string, '"' ); + if( s ) { *s = '\0'; /* remove last double quote */ } /* if string was unterminated, there will be no quote to remove */ /* in which case the scanner has already complained about it */ count = 0; - for(s = yylval.string; *s; s++, count++) { - if(!isxdigit(*s)) { - ERRORreport_with_line(ENCODED_STRING_BAD_DIGIT, yylineno, *s); + for( s = yylval.string; *s; s++, count++ ) { + if( !isxdigit( *s ) ) { + ERRORreport_with_line( ENCODED_STRING_BAD_DIGIT, yylineno, *s ); } } - if(0 != (count % 8)) { - ERRORreport_with_line(ENCODED_STRING_BAD_COUNT, yylineno, count); + if( 0 != ( count % 8 ) ) { + ERRORreport_with_line( ENCODED_STRING_BAD_COUNT, yylineno, count ); } return TOK_STRING_LITERAL_ENCODED; } -int SCANprocess_semicolon(const char *yytext, int commentp) -{ +int SCANprocess_semicolon( const char * yytext, int commentp ) { - if(commentp) { - strcpy(last_comment_, strchr(yytext, '-')); + if( commentp ) { + strcpy( last_comment_, strchr( yytext, '-' ) ); yylval.string = last_comment_; } else { yylval.string = last_comment; } - if(last_comment) { + if( last_comment ) { last_comment = 0; } return TOK_SEMICOLON; } -void SCANsave_comment(const char *yytext) -{ - strncpy(last_comment_, yytext, SCAN_COMMENT_LENGTH - 1); +void SCANsave_comment( const char * yytext ) { + strncpy( last_comment_ , yytext, SCAN_COMMENT_LENGTH - 1 ); last_comment = last_comment_; } -bool SCANread(void) -{ +bool SCANread( void ) { int numRead; bool done; do { /* this loop is guaranteed to terminate, since buffer[0] is on yyin */ - while(SCANbuffer.file == NULL) { + while( SCANbuffer.file == NULL ) { SCANpop_buffer(); - if(SCANtext_ready) { + if( SCANtext_ready ) { return true; } } @@ -423,15 +409,15 @@ bool SCANread(void) /* now we have a file buffer */ /* check for more stuff already buffered */ - if(SCANtext_ready) { + if( SCANtext_ready ) { return true; } /* check whether we've seen eof on this file */ - if(!SCANbuffer.readEof) { - numRead = fread(SCANbuffer.text, sizeof(char), - SCAN_BUFFER_SIZE, SCANbuffer.file); - if(numRead < SCAN_BUFFER_SIZE) { + if( !SCANbuffer.readEof ) { + numRead = fread( SCANbuffer.text, sizeof( char ), + SCAN_BUFFER_SIZE, SCANbuffer.file ); + if( numRead < SCAN_BUFFER_SIZE ) { SCANbuffer.readEof = true; } #ifdef keep_nul @@ -442,66 +428,61 @@ bool SCANread(void) SCANcurrent = SCANbuffer.text; } - if(!(done = SCANtext_ready)) { - if(SCAN_current_buffer == 0) { + if( !( done = SCANtext_ready ) ) { + if( SCAN_current_buffer == 0 ) { done = true; - fclose(SCANbuffer.file); /* close yyin */ + fclose( SCANbuffer.file ); /* close yyin */ SCANbuffer.file = NULL; } else { SCANpop_buffer(); } } - } while(!done); + } while( !done ); return SCANtext_ready; } -void SCANinclude_file(char *filename) -{ +void SCANinclude_file( char * filename ) { extern int print_objects_while_running; - FILE *fp; + FILE * fp; - if((fp = fopen(filename, "r")) == NULL) { - ERRORreport_with_line(INCLUDE_FILE, yylineno); + if( ( fp = fopen( filename, "r" ) ) == NULL ) { + ERRORreport_with_line( INCLUDE_FILE, yylineno ); } else { - if(print_objects_while_running & OBJ_SCHEMA_BITS) { - fprintf(stderr, "parse: including %s at line %d of %s\n", - filename, yylineno, SCANbuffer.filename); + if( print_objects_while_running & OBJ_SCHEMA_BITS ) { + fprintf( stderr, "parse: including %s at line %d of %s\n", + filename, yylineno, SCANbuffer.filename ); } - SCANpush_buffer(filename, fp); + SCANpush_buffer( filename, fp ); } } -void SCANlowerize(char *s) -{ - for(; *s; s++) { - if(isupper(*s)) { - *s = tolower(*s); +void SCANlowerize( char * s ) { + for( ; *s; s++ ) { + if( isupper( *s ) ) { + *s = tolower( *s ); } } } -void SCANupperize(char *s) -{ - for(; *s; s++) { - if(islower(*s)) { - *s = toupper(*s); +void SCANupperize( char * s ) { + for( ; *s; s++ ) { + if( islower( *s ) ) { + *s = toupper( *s ); } } } -char *SCANstrdup(const char *s) -{ - char *s2 = (char *)sc_malloc(strlen(s) + 1); - if(!s2) { +char * SCANstrdup( const char * s ) { + char * s2 = ( char * )sc_malloc( strlen( s ) + 1 ); + if( !s2 ) { return 0; } - strcpy(s2, s); + strcpy( s2, s ); return s2; } -long SCANtell() -{ +long SCANtell() { return yylineno; } diff --git a/src/express/linklist.c b/src/express/linklist.c index 9a32e7bbe..7089dd81d 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -23,76 +23,66 @@ #include "express/linklist.h" -void LISTinitialize(void) -{ +void LISTinitialize( void ) { } -void LISTcleanup(void) -{ +void LISTcleanup( void ) { } -Linked_List LISTcreate() -{ +Linked_List LISTcreate() { Linked_List list = LIST_new(); list->mark = LINK_new(); list->mark->next = list->mark->prev = list->mark; - return(list); + return( list ); } -Linked_List LISTcopy(Linked_List src) -{ +Linked_List LISTcopy( Linked_List src ) { Linked_List dst = LISTcreate(); - LISTdo(src, x, void *) - LISTadd_last(dst, x); + LISTdo( src, x, void * ) + LISTadd_last( dst, x ); LISTod return dst; } -void LISTfree(Linked_List list) -{ +void LISTfree( Linked_List list ) { Link p, q = list->mark->next; - for(p = q->next; p != list->mark; q = p, p = p->next) { - LINK_destroy(q); + for( p = q->next; p != list->mark; q = p, p = p->next ) { + LINK_destroy( q ); } - if(q != list->mark) { - LINK_destroy(q); + if( q != list->mark ) { + LINK_destroy( q ); } - LINK_destroy(list->mark); - LIST_destroy(list); + LINK_destroy( list->mark ); + LIST_destroy( list ); } -void LISTsort(Linked_List list, int (*comp)(void *, void *)) -{ +void LISTsort( Linked_List list, int (*comp)(void*, void*)) { unsigned int moved; Link node, prev; - if(LISTempty(list)) { + if (LISTempty(list)) return; - } - while(true) { - for(node = list->mark->next, moved = 0; node != list->mark; node = node->next) { + while (true) { + for ( node = list->mark->next, moved = 0; node != list->mark; node = node->next ) { prev = node->prev; - if(prev != list->mark && comp(prev->data, node->data) < 0) { + if (prev != list->mark && comp(prev->data, node->data) < 0) { LISTswap(prev, node); moved++; } } - if(moved == 0) { + if (moved == 0) break; - } } } -void LISTswap(Link p, Link q) -{ +void LISTswap( Link p, Link q ) { void *tmp; - if(p == LINK_NULL || q == LINK_NULL || p == q) { + if( p == LINK_NULL || q == LINK_NULL || p == q ) return; - } tmp = p->data; p->data = q->data; @@ -100,49 +90,45 @@ void LISTswap(Link p, Link q) } -void *LISTadd_first(Linked_List list, void *item) -{ +void *LISTadd_first( Linked_List list, void *item ) { Link node; node = LINK_new(); node->data = item; - (node->next = list->mark->next)->prev = node; - (list->mark->next = node)->prev = list->mark; + ( node->next = list->mark->next )->prev = node; + ( list->mark->next = node )->prev = list->mark; return item; } -void *LISTadd_last(Linked_List list, void *item) -{ +void *LISTadd_last( Linked_List list, void *item ) { Link node; node = LINK_new(); node->data = item; - (node->prev = list->mark->prev)->next = node; - (list->mark->prev = node)->next = list->mark; + ( node->prev = list->mark->prev )->next = node; + ( list->mark->prev = node )->next = list->mark; return item; } -void *LISTadd_after(Linked_List list, Link link, void *item) -{ +void *LISTadd_after( Linked_List list, Link link, void *item ) { Link node; - if(link == LINK_NULL) { - LISTadd_first(list, item); + if( link == LINK_NULL ) { + LISTadd_first( list, item ); } else { node = LINK_new(); node->data = item; - (node->next = link->next)->prev = node; - (link->next = node)->prev = link; + ( node->next = link->next )->prev = node; + ( link->next = node )->prev = link; } return item; } -void *LISTadd_before(Linked_List list, Link link, void *item) -{ +void *LISTadd_before( Linked_List list, Link link, void *item ) { Link node; - if(link == LINK_NULL) { - LISTadd_last(list, item); + if( link == LINK_NULL ) { + LISTadd_last( list, item ); } else { node = LINK_new(); node->data = item; @@ -156,46 +142,43 @@ void *LISTadd_before(Linked_List list, Link link, void *item) } -void *LISTremove_first(Linked_List list) -{ +void *LISTremove_first( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { - ERRORreport(EMPTY_LIST, "LISTremove_first"); + if( node == list->mark ) { + ERRORreport( EMPTY_LIST, "LISTremove_first" ); return NULL; } item = node->data; - (list->mark->next = node->next)->prev = list->mark; - LINK_destroy(node); + ( list->mark->next = node->next )->prev = list->mark; + LINK_destroy( node ); return item; } -void *LISTget_first(Linked_List list) -{ +void *LISTget_first( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } item = node->data; return item; } -void *LISTget_second(Linked_List list) -{ +void *LISTget_second( Linked_List list ) { Link node; void *item; node = list->mark->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } node = node->next; - if(node == list->mark) { + if( node == list->mark ) { return NULL; } item = node->data; @@ -203,40 +186,37 @@ void *LISTget_second(Linked_List list) } /** first is 1, not 0 */ -void *LISTget_nth(Linked_List list, int n) -{ +void *LISTget_nth( Linked_List list, int n ) { int count = 1; Link node; - for(node = list->mark->next; node != list->mark; node = node->next) { - if(n == count++) { - return(node->data); + for( node = list->mark->next; node != list->mark; node = node->next ) { + if( n == count++ ) { + return( node->data ); } } - return(0); + return( 0 ); } -int LISTget_length(Linked_List list) -{ +int LISTget_length( Linked_List list ) { Link node; int count = 0; - if(!list) { + if( !list ) { return 0; } - for(node = list->mark->next; node != list->mark; node = node->next) { + for( node = list->mark->next; node != list->mark; node = node->next ) { count++; } return count; } -bool LISTempty(Linked_List list) -{ - if(!list) { +bool LISTempty( Linked_List list ) { + if( !list ) { return true; } - if(list->mark->next == list->mark) { + if( list->mark->next == list->mark ) { return true; } return false; diff --git a/src/express/memory.c b/src/express/memory.c index a257582fb..f8b536e45 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -51,53 +51,52 @@ struct freelist_head PCALL_fl; struct freelist_head RET_fl; struct freelist_head INCR_fl; -void MEMORYinitialize() -{ +void MEMORYinitialize() { _ALLOCinitialize(); - - ALLOCinitialize(&HASH_Table_fl, sizeof(struct Hash_Table_), 50, 50); - ALLOCinitialize(&HASH_Element_fl, sizeof(struct Element_), 500, 100); - - ALLOCinitialize(&LINK_fl, sizeof(struct Link_), 500, 100); - ALLOCinitialize(&LIST_fl, sizeof(struct Linked_List_), 100, 50); - - ALLOCinitialize(&SYMBOL_fl, sizeof(struct Symbol_), 100, 100); - - ALLOCinitialize(&SCOPE_fl, sizeof(struct Scope_), 100, 50); - - ALLOCinitialize(&TYPEHEAD_fl, sizeof(struct TypeHead_), 500, 100); - ALLOCinitialize(&TYPEBODY_fl, sizeof(struct TypeBody_), 200, 100); - - ALLOCinitialize(&VAR_fl, sizeof(struct Variable_), 100, 50); - - ALLOCinitialize(&FUNC_fl, sizeof(struct Function_), 100, 50); - ALLOCinitialize(&RULE_fl, sizeof(struct Rule_), 100, 50); - ALLOCinitialize(&PROC_fl, sizeof(struct Procedure_), 100, 50); - ALLOCinitialize(&WHERE_fl, sizeof(struct Where_), 100, 50); - - ALLOCinitialize(&ENTITY_fl, sizeof(struct Entity_), 500, 100); - - ALLOCinitialize(&SCHEMA_fl, sizeof(struct Schema_), 40, 20); - ALLOCinitialize(&REN_fl, sizeof(struct Rename), 30, 30); - - ALLOCinitialize(&CASE_IT_fl, sizeof(struct Case_Item_), 500, 100); - - ALLOCinitialize(&EXP_fl, sizeof(struct Expression_), 500, 200); - ALLOCinitialize(&OP_fl, sizeof(struct Op_Subexpression), 500, 100); - ALLOCinitialize(&QUERY_fl, sizeof(struct Query_), 50, 10); - ALLOCinitialize(&QUAL_ATTR_fl, sizeof(struct Query_), 20, 10); - - ALLOCinitialize(&STMT_fl, sizeof(struct Statement_), 500, 100); - - ALLOCinitialize(&ALIAS_fl, sizeof(struct Alias_), 10, 10); - ALLOCinitialize(&ASSIGN_fl, sizeof(struct Assignment_), 100, 30); - ALLOCinitialize(&CASE_fl, sizeof(struct Case_Statement_), 100, 30); - ALLOCinitialize(&COMP_STMT_fl, sizeof(struct Compound_Statement_), 100, 30); - ALLOCinitialize(&COND_fl, sizeof(struct Conditional_), 100, 30); - ALLOCinitialize(&LOOP_fl, sizeof(struct Loop_), 100, 30); - ALLOCinitialize(&PCALL_fl, sizeof(struct Procedure_Call_), 100, 30); - ALLOCinitialize(&RET_fl, sizeof(struct Return_Statement_), 100, 30); - ALLOCinitialize(&INCR_fl, sizeof(struct Increment_), 100, 30); + + ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 ); + ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 ); + + ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 ); + ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 ); + + ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 ); + + ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 ); + + ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 ); + ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 ); + + ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 ); + + ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 ); + ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 ); + ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 ); + ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 ); + + ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 ); + + ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 ); + ALLOCinitialize( &REN_fl, sizeof( struct Rename ), 30, 30 ); + + ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 ); + + ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 ); + ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 ); + ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 ); + ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 ); + + ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 ); + + ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 ); + ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 ); + ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 ); + ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 ); + ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 ); + ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 ); + ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 ); + ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 ); + ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 ); } diff --git a/src/express/object.c b/src/express/object.c index 3aa76f2ec..f75e64274 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -30,84 +30,76 @@ #include "express/type.h" #include "express/expr.h" -Symbol *SCOPE_get_symbol(void *s); -Symbol *EXPRESS_get_symbol(void *e); -Symbol *RENAME_get_symbol(void *r); -Symbol *TYPE_get_symbol(void *t); -Symbol *EXP_get_symbol(void *e); -Symbol *WHERE_get_symbol(void *w); -Symbol *VAR_get_symbol(void *v); -Symbol *UNK_get_symbol(void *x); +Symbol * SCOPE_get_symbol( void *s ); +Symbol * EXPRESS_get_symbol( void *e ); +Symbol * RENAME_get_symbol( void *r ); +Symbol * TYPE_get_symbol( void *t ); +Symbol * EXP_get_symbol( void *e ); +Symbol * WHERE_get_symbol( void *w ); +Symbol * VAR_get_symbol( void *v ); +Symbol * UNK_get_symbol( void *x ); /* global Object type array */ struct Object OBJ[] = { [0] = {UNK_get_symbol, "of unknown type", 0}, - + [OBJ_VARIABLE] = {VAR_get_symbol, "variable", OBJ_VARIABLE_BITS}, [OBJ_ENTITY] = {SCOPE_get_symbol, "entity", OBJ_ENTITY_BITS}, - + [OBJ_EXPRESSION] = {EXP_get_symbol, "expression", OBJ_EXPRESSION_BITS}, [OBJ_AMBIG_ENUM] = {EXP_get_symbol, "ambiguous enumeration", OBJ_UNUSED_BITS}, - + [OBJ_RULE] = {SCOPE_get_symbol, "rule", OBJ_UNUSED_BITS}, [OBJ_PROCEDURE] = {SCOPE_get_symbol, "procedure", OBJ_PROCEDURE_BITS}, [OBJ_FUNCTION] = {SCOPE_get_symbol, "function", OBJ_FUNCTION_BITS}, [OBJ_WHERE] = {WHERE_get_symbol, "where", OBJ_WHERE_BITS}, - + [OBJ_SCHEMA] = {SCOPE_get_symbol, "schema", OBJ_SCHEMA_BITS}, /* TODO: PASS should also have a symbol */ [OBJ_PASS] = {UNK_get_symbol, "pass", OBJ_PASS_BITS}, [OBJ_EXPRESS] = {EXPRESS_get_symbol, "express file", OBJ_UNUSED_BITS}, [OBJ_RENAME] = {RENAME_get_symbol, "rename clause", OBJ_UNUSED_BITS}, - + [OBJ_TYPE] = {TYPE_get_symbol, "type", OBJ_TYPE_BITS}, [OBJ_TAG] = {TYPE_get_symbol, "tag", OBJ_TYPE_BITS}, - + [OBJ_ALIAS] = {SCOPE_get_symbol, "alias scope", OBJ_UNUSED_BITS }, [OBJ_INCREMENT] = {SCOPE_get_symbol, "increment scope", OBJ_UNUSED_BITS }, {0} }; -Symbol *UNK_get_symbol(void *x) -{ +Symbol * UNK_get_symbol( void *x ) { (void) x; /* quell unused param warning; it appears that the prototype must match other functions */ - fprintf(stderr, "OBJget_symbol called on object of unknown type\n"); - ERRORabort(0); + fprintf( stderr, "OBJget_symbol called on object of unknown type\n" ); + ERRORabort( 0 ); return 0; } -Symbol *VAR_get_symbol(void *v) -{ - return &((Variable)v)->name->symbol; +Symbol * VAR_get_symbol( void *v ) { + return &( ( Variable )v )->name->symbol; } -Symbol *SCOPE_get_symbol(void *s) -{ - return &((Scope)s)->symbol; +Symbol * SCOPE_get_symbol( void *s ) { + return &( ( Scope )s )->symbol; } -Symbol *EXP_get_symbol(void *e) -{ - return &((Expression)e)->symbol; +Symbol * EXP_get_symbol( void *e ) { + return &( ( Expression )e )->symbol; } -Symbol *WHERE_get_symbol(void *w) -{ - return ((Where)w)->label; +Symbol * WHERE_get_symbol( void *w ) { + return ( ( Where )w )->label; } -Symbol *EXPRESS_get_symbol(void *e) -{ - return &((Express)e)->symbol; +Symbol * EXPRESS_get_symbol( void *e ) { + return &( ( Express )e )->symbol; } -Symbol *RENAME_get_symbol(void *r) -{ - return ((Rename *)r)->old; +Symbol * RENAME_get_symbol( void *r ) { + return ( ( Rename * )r )->old; } -Symbol *TYPE_get_symbol(void *t) -{ - return &((Type)t)->symbol; +Symbol * TYPE_get_symbol( void *t ) { + return &( ( Type )t )->symbol; } diff --git a/src/express/ordered_attrs.cc b/src/express/ordered_attrs.cc index ce3e2b08f..8081c16e3 100644 --- a/src/express/ordered_attrs.cc +++ b/src/express/ordered_attrs.cc @@ -15,20 +15,18 @@ oaList attrs; unsigned int attrIndex = 0; /// uses depth-first recursion to add attrs in order; looks for derived attrs -void populateAttrList(oaList &list, Entity ent) -{ +void populateAttrList( oaList & list, Entity ent ) { unsigned int attrCount = list.size(); //use to figure out how many attrs on end of list need to be checked for duplicates //recurse through supertypes - LISTdo(ent->u.entity->supertypes, super, Entity) { - populateAttrList(list, super); - } - LISTod + LISTdo( ent->u.entity->supertypes, super, Entity ) { + populateAttrList( list, super ); + } LISTod //then look at ent's own attrs, checking against attrs with index >= attrCount //derivation check only - leave deduplication for later - LISTdo(ent->u.entity->attributes, attr, Variable) { + LISTdo( ent->u.entity->attributes, attr, Variable ) { bool unique = true; - for(unsigned int i = attrCount; i < list.size(); i++) { - if(0 == strcasecmp(attr->name->symbol.name, list[i]->attr->name->symbol.name)) { + for( unsigned int i = attrCount; i < list.size(); i++ ) { + if( 0 == strcasecmp( attr->name->symbol.name, list[i]->attr->name->symbol.name ) ) { // an attr by this name exists in a supertype // originally printed a warning here, but that was misleading - they have more uses than I thought unique = false; @@ -36,68 +34,63 @@ void populateAttrList(oaList &list, Entity ent) break; } } - if(unique) { - orderedAttr *oa = new orderedAttr; - oa->attr = attr; - oa->creator = ent; - if(attr->initializer) { + if( unique ) { + orderedAttr * oa = new orderedAttr; + oa->attr=attr; + oa->creator=ent; + if( attr->initializer ) { // attrs derived by their owner are omitted from part 21 - section 10.2.3 oa->deriver = ent; } else { oa->deriver = 0; } oa->redefiner = 0; - list.push_back(oa); + list.push_back( oa ); } - } - LISTod + } LISTod } ///compare attr name and creator, remove all but first occurrence ///this is necessary for diamond inheritance -void dedupList(oaList &list) -{ +void dedupList( oaList & list ) { oaList::iterator it, jt; - for(it = list.begin(); it != list.end(); it++) { - for(jt = it + 1; jt != list.end(); jt++) { - if((0 == strcasecmp((* it)->attr->name->symbol.name, (* jt)->attr->name->symbol.name)) && - (0 == strcasecmp((* it)->creator->symbol.name, (* jt)->creator->symbol.name))) { + for( it = list.begin(); it != list.end(); it++ ) { + for( jt = it + 1; jt != list.end(); jt++ ) { + if( ( 0 == strcasecmp( ( * it )->attr->name->symbol.name, ( * jt )->attr->name->symbol.name ) ) && + ( 0 == strcasecmp( ( * it )->creator->symbol.name, ( * jt )->creator->symbol.name ) ) ) { //fprintf( stderr, "erasing %s created by %s\n", ( * jt )->attr->name->symbol.name, ( * jt )->creator->symbol.name ); jt--; - list.erase(jt + 1); + list.erase( jt + 1 ); } } } } /// set up ordered attrs for new entity -void orderedAttrsInit(Entity e) -{ +void orderedAttrsInit( Entity e ) { orderedAttrsCleanup(); attrIndex = 0; currentEntity = e; - if(currentEntity) { - populateAttrList(attrs, currentEntity); - if(attrs.size() > 1) { - dedupList(attrs); + if( currentEntity ) { + populateAttrList( attrs, currentEntity ); + if( attrs.size() > 1 ) { + dedupList( attrs ); } } } -void orderedAttrsCleanup() -{ - for(unsigned int i = 0; i < attrs.size(); i++) { +void orderedAttrsCleanup() { + for( unsigned int i = 0; i < attrs.size(); i++ ) { delete attrs[i]; } attrs.clear(); } -const orderedAttr *nextAttr() -{ - if(attrIndex < attrs.size()) { +const orderedAttr * nextAttr() { + if( attrIndex < attrs.size() ) { unsigned int i = attrIndex; attrIndex++; - return attrs.at(i); + return attrs.at( i ); } else { return 0; } diff --git a/src/express/resolve.c b/src/express/resolve.c index f4f1a233f..fa5797917 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -72,16 +72,14 @@ static bool found_self; /**< remember whether we've seen a SELF in a WHERE clau /* function prototypes */ /***********************/ -extern void VAR_resolve_types(Variable v); +extern void VAR_resolve_types( Variable v ); /** Initialize the Fed-X second pass. */ -void RESOLVEinitialize(void) -{ +void RESOLVEinitialize( void ) { } /** Clean up the Fed-X second pass */ -void RESOLVEcleanup(void) -{ +void RESOLVEcleanup( void ) { } /** @@ -90,18 +88,17 @@ void RESOLVEcleanup(void) ** \param t_agg the current aggregate type ** \return the aggregate type */ -Type TYPE_retrieve_aggregate(Type t_select, Type t_agg) -{ - if(TYPEis_select(t_select)) { +Type TYPE_retrieve_aggregate( Type t_select, Type t_agg ) { + if( TYPEis_select( t_select ) ) { /* parse the underlying types */ - LISTdo_links(t_select->u.type->body->list, link) + LISTdo_links( t_select->u.type->body->list, link ) /* the current underlying type */ - Type t = (Type) link->data; - if(TYPEis_select(t)) { - t_agg = TYPE_retrieve_aggregate(t, t_agg); - } else if(TYPEis_aggregate(t)) { - if(t_agg) { - if(t_agg != t->u.type->body->base) { + Type t = ( Type ) link->data; + if( TYPEis_select( t ) ) { + t_agg = TYPE_retrieve_aggregate( t, t_agg ); + } else if( TYPEis_aggregate( t ) ) { + if( t_agg ) { + if( t_agg != t->u.type->body->base ) { /* 2 underlying types do not have to the same base */ return 0; } @@ -127,10 +124,9 @@ Type TYPE_retrieve_aggregate(Type t_select, Type t_agg) ** Resolve all references in an expression. ** \note the macro 'EXPresolve' calls this function after checking if expr is already resolved */ -void EXP_resolve(Expression expr, Scope scope, Type typecheck) -{ +void EXP_resolve( Expression expr, Scope scope, Type typecheck ) { Function f = 0; - Symbol *sym; + Symbol * sym; void *x; Entity e; Type t; @@ -139,73 +135,73 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) /* if (expr == EXPRESSION_NULL) return; */ - switch(expr->type->u.type->body->type) { + switch( expr->type->u.type->body->type ) { case funcall_: /* functions with no arguments get handled elsewhere */ /* because the parser sees them just like attributes */ - x = SCOPEfind(scope, expr->symbol.name, - SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY); - if(!x) { - ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name); - resolve_failed(expr); + x = SCOPEfind( scope, expr->symbol.name, + SCOPE_FIND_FUNCTION | SCOPE_FIND_ENTITY ); + if( !x ) { + ERRORreport_with_symbol(UNDEFINED_FUNC, &expr->symbol, expr->symbol.name ); + resolve_failed( expr ); break; } - if((DICT_type != OBJ_FUNCTION) && (DICT_type != OBJ_ENTITY)) { - sym = OBJget_symbol(x, DICT_type); - ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name); - resolve_failed(expr); + if( ( DICT_type != OBJ_FUNCTION ) && ( DICT_type != OBJ_ENTITY ) ) { + sym = OBJget_symbol( x, DICT_type ); + ERRORreport_with_symbol(FUNCALL_NOT_A_FUNCTION, &expr->symbol, sym->name ); + resolve_failed( expr ); break; } /* original code accepted rules, too? */ /* entities are treated like implicit constructor functions */ - if(DICT_type == OBJ_ENTITY) { + if( DICT_type == OBJ_ENTITY ) { Type self_old = self; /* save previous in the unlikely but possible case that * SELF is in a derived initialization of an entity */ - e = (Entity)x; + e = ( Entity )x; self = e->u.entity->type; /* skip parameter resolution for now */ /* ARGresolve();*/ expr->return_type = e->u.entity->type; self = self_old; /* restore old SELF */ } else { - f = (Function)x; + f = ( Function )x; expr->return_type = f->u.func->return_type; /* do argument typechecking here if requested */ /* currently, we just check arg count; necessary */ /* to NVL code later which assumes args are present */ - if(LISTget_length(expr->u.funcall.list) != - f->u.func->pcount) { + if( LISTget_length( expr->u.funcall.list ) != + f->u.func->pcount ) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, - LISTget_length(expr->u.funcall.list), - f->u.func->pcount); + LISTget_length( expr->u.funcall.list ), + f->u.func->pcount ); } #ifdef future_work - if(EXPRESS_lint) { + if( EXPRESS_lint ) { /* verify parameters match function call */ } #endif /* should make this data-driven! */ - if(f == FUNC_NVL) { - EXPresolve((Expression)LISTget_first(expr->u.funcall.list), scope, typecheck); - EXPresolve((Expression)LISTget_second(expr->u.funcall.list), scope, typecheck); + if( f == FUNC_NVL ) { + EXPresolve( ( Expression )LISTget_first( expr->u.funcall.list ), scope, typecheck ); + EXPresolve( ( Expression )LISTget_second( expr->u.funcall.list ), scope, typecheck ); func_args_checked = true; } /* why is this here? (snc) */ - if(f == FUNC_USEDIN) { + if( f == FUNC_USEDIN ) { expr->return_type = Type_Bag_Of_Generic; } } - if(!func_args_checked) { - LISTdo(expr->u.funcall.list, param, Expression) - EXPresolve(param, scope, Type_Dont_Care); - if(is_resolve_failed(param)) { - resolve_failed(expr); + if( !func_args_checked ) { + LISTdo( expr->u.funcall.list, param, Expression ) + EXPresolve( param, scope, Type_Dont_Care ); + if( is_resolve_failed( param ) ) { + resolve_failed( expr ); break; } LISTod; @@ -213,48 +209,48 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) #if 0 /* add function or entity as first element of list */ - LISTadd_first(expr->u.list, x); + LISTadd_first( expr->u.list, x ); #endif - expr->u.funcall.function = (struct Scope_ *) x; + expr->u.funcall.function = ( struct Scope_ * ) x; - resolved_all(expr); + resolved_all( expr ); break; case aggregate_: - LISTdo(expr->u.list, elt, Expression) - EXPresolve(elt, scope, Type_Dont_Care); - if(is_resolve_failed(elt)) { - resolve_failed(expr); + LISTdo( expr->u.list, elt, Expression ) + EXPresolve( elt, scope, Type_Dont_Care ); + if( is_resolve_failed( elt ) ) { + resolve_failed( expr ); break; } LISTod; /* may have to do more work here! */ expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; case identifier_: x = 0; /* assume it's a variable/attribute */ - if(!x) { - x = VARfind(scope, expr->symbol.name, 0); + if( !x ) { + x = VARfind( scope, expr->symbol.name, 0 ); } /* if not found as a variable, try as function, etc ... */ - if(!x) { - x = SCOPEfind(scope, expr->symbol.name, - SCOPE_FIND_ANYTHING); + if( !x ) { + x = SCOPEfind( scope, expr->symbol.name, + SCOPE_FIND_ANYTHING ); } /* Not all enums have `typecheck->u.type->body->type` == `enumeration_` - ?! */ - if(!x) { + if( !x ) { Scope enumscope = scope; - while(1) { + while( 1 ) { /* look up locally, then go through the superscopes */ - x = DICTlookup(enumscope->enum_table, expr->symbol.name); - if(x) { + x = DICTlookup( enumscope->enum_table, expr->symbol.name ); + if( x ) { break; } - if(enumscope->type == OBJ_SCHEMA) { + if( enumscope->type == OBJ_SCHEMA ) { /* if we get here, this means that we've looked through all scopes */ x = 0; break; @@ -263,121 +259,121 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) } } - if(!x) { - if(typecheck == Type_Unknown) { + if( !x ) { + if( typecheck == Type_Unknown ) { return; } else { - ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name); - resolve_failed(expr); + ERRORreport_with_symbol(UNDEFINED, &expr->symbol, expr->symbol.name ); + resolve_failed( expr ); break; } } - switch(DICT_type) { + switch( DICT_type ) { case OBJ_VARIABLE: - expr->u.variable = (Variable)x; + expr->u.variable = ( Variable )x; #if 0 /* gee, I don't see what variables have to go through this right here */ - VARresolve_expressions(expr->u.variable, scope); - if(is_resolve_failed(expr->u.variable->name)) { - resolve_failed(expr); + VARresolve_expressions( expr->u.variable, scope ); + if( is_resolve_failed( expr->u.variable->name ) ) { + resolve_failed( expr ); break; } #endif /* Geez, don't wipe out original type! */ expr->return_type = expr->u.variable->type; - if(expr->u.variable->flags.attribute) { + if( expr->u.variable->flags.attribute ) { found_self = true; } - resolved_all(expr); + resolved_all( expr ); break; case OBJ_ENTITY: - expr->return_type = expr->type = ((Entity)x)->u.entity->type; + expr->return_type = expr->type = ( ( Entity )x )->u.entity->type; /* entity may not actually be resolved by now */ /* but I don't think that's a problem */ - resolved_all(expr); + resolved_all( expr ); break; case OBJ_EXPRESSION: /* so far only enumerations get returned this way */ - expr->u.expression = (Expression)x; - expr->type = expr->return_type = ((Expression)x)->type; - resolved_all(expr); + expr->u.expression = ( Expression )x; + expr->type = expr->return_type = ( ( Expression )x )->type; + resolved_all( expr ); break; case OBJ_FUNCTION: /* functions with no args end up here because the */ /* parser doesn't know any better */ expr->u.list = LISTcreate(); - LISTadd_last(expr->u.list, x); + LISTadd_last( expr->u.list, x ); expr->type = Type_Funcall; - expr->return_type = ((Function)x)->u.func->return_type; + expr->return_type = ( ( Function )x )->u.func->return_type; /* function may not actually be resolved by now */ /* but I don't think that's a problem */ - if(((Function)x)->u.func->pcount != 0) { + if( ( ( Function )x )->u.func->pcount != 0 ) { ERRORreport_with_symbol(WRONG_ARG_COUNT, &expr->symbol, expr->symbol.name, 0, - f->u.func->pcount); - resolve_failed(expr); + f->u.func->pcount ); + resolve_failed( expr ); } else { - resolved_all(expr); + resolved_all( expr ); } break; case OBJ_TYPE: /* enumerations can appear here, I don't know about others */ - expr->type = (Type)x; - expr->return_type = (Type)x; + expr->type = ( Type )x; + expr->return_type = ( Type )x; expr->symbol.resolved = expr->type->symbol.resolved; break; default: - fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); + fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); break; } break; case op_: - expr->return_type = (*EXPop_table[expr->e.op_code].resolve)(expr, scope); + expr->return_type = ( *EXPop_table[expr->e.op_code].resolve )( expr, scope ); break; case entity_: /* only 'self' is seen this way */ case self_: - if(self) { + if( self ) { expr->return_type = self; /* we can't really call ourselves resolved, but we */ /* will be by the time we return, and besides, */ /* there's no way this will be accessed if the true */ /* entity fails resolution */ found_self = true; - resolved_all(expr); + resolved_all( expr ); } else { - ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol); - resolve_failed(expr); + ERRORreport_with_symbol(SELF_IS_UNKNOWN, &scope->symbol ); + resolve_failed( expr ); } break; case query_: - EXPresolve(expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care); + EXPresolve( expr->u.query->aggregate, expr->u.query->scope, Type_Dont_Care ); expr->return_type = expr->u.query->aggregate->return_type; /* verify that it's an aggregate */ - if(is_resolve_failed(expr->u.query->aggregate)) { - resolve_failed(expr); + if( is_resolve_failed( expr->u.query->aggregate ) ) { + resolve_failed( expr ); break; } - if(TYPEis_aggregate(expr->return_type)) { + if( TYPEis_aggregate( expr->return_type ) ) { t = expr->u.query->aggregate->return_type->u.type->body->base; - } else if(TYPEis_select(expr->return_type)) { + } else if( TYPEis_select( expr->return_type ) ) { /* retrieve the common aggregate type */ - t = TYPE_retrieve_aggregate(expr->return_type, 0); - if(!t) { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); - resolve_failed(expr); + t = TYPE_retrieve_aggregate( expr->return_type, 0 ); + if( !t ) { + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); + resolve_failed( expr ); break; } - } else if(TYPEis_runtime(expr->return_type)) { + } else if( TYPEis_runtime( expr->return_type ) ) { t = Type_Runtime; } else { - ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol); - resolve_failed(expr); + ERRORreport_with_symbol(QUERY_REQUIRES_AGGREGATE, &expr->u.query->aggregate->symbol ); + resolve_failed( expr ); break; } expr->u.query->local->type = t; expr->u.query->local->name->return_type = t; - EXPresolve(expr->u.query->expression, expr->u.query->scope, Type_Dont_Care); + EXPresolve( expr->u.query->expression, expr->u.query->scope, Type_Dont_Care ); expr->symbol.resolved = expr->u.query->expression->symbol.resolved; break; case integer_: @@ -388,62 +384,61 @@ void EXP_resolve(Expression expr, Scope scope, Type typecheck) case logical_: case number_: expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; case attribute_: expr->return_type = expr->type; - resolved_all(expr); + resolved_all( expr ); break; default: - fprintf(stderr, "ERROR: unexpected type in EXPresolve.\n"); + fprintf( stderr, "ERROR: unexpected type in EXPresolve.\n" ); } } -int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, Linked_List *flat) -{ +int ENTITYresolve_subtype_expression( Expression expr, Entity ent/*was scope*/, Linked_List * flat ) { Entity ent_ref; int i = UNRESOLVED; - if(!expr) { - return (RESOLVED); - } else if(TYPEis_expression(expr->type)) { - i = ENTITYresolve_subtype_expression(expr->e.op1, ent, flat); - i |= ENTITYresolve_subtype_expression(expr->e.op2, ent, flat); - } else if(TYPEis_oneof(expr->type)) { - LISTdo(expr->u.list, sel, Expression) - i |= ENTITYresolve_subtype_expression(sel, ent, flat); + if( !expr ) { + return ( RESOLVED ); + } else if( TYPEis_expression( expr->type ) ) { + i = ENTITYresolve_subtype_expression( expr->e.op1, ent, flat ); + i |= ENTITYresolve_subtype_expression( expr->e.op2, ent, flat ); + } else if( TYPEis_oneof( expr->type ) ) { + LISTdo( expr->u.list, sel, Expression ) + i |= ENTITYresolve_subtype_expression( sel, ent, flat ); LISTod; } else { /* must be a simple entity reference */ - ent_ref = (Entity)SCOPEfind(ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY); - if(!ent_ref) { + ent_ref = ( Entity )SCOPEfind( ent->superscope, expr->symbol.name, SCOPE_FIND_ENTITY ); + if( !ent_ref ) { ERRORreport_with_symbol(UNKNOWN_SUBTYPE, &ent->symbol, - expr->symbol.name, ent->symbol.name); + expr->symbol.name, ent->symbol.name ); i = RESOLVE_FAILED; - } else if(DICT_type != OBJ_ENTITY) { - Symbol *sym = OBJget_symbol(ent_ref, DICT_type); + } else if( DICT_type != OBJ_ENTITY ) { + Symbol * sym = OBJget_symbol( ent_ref, DICT_type ); /* line number should really be on supertype name, */ /* but all we have easily is the entity line number */ ERRORreport_with_symbol(SUBTYPE_RESOLVE, &ent->symbol, - expr->symbol.name, sym->line); + expr->symbol.name, sym->line ); i = RESOLVE_FAILED; } else { bool found = false; /* link in to flat list */ - if(!*flat) { + if( !*flat ) { *flat = LISTcreate(); } - LISTdo(*flat, sub, Entity) - if(sub == ent_ref) { + LISTdo( *flat, sub, Entity ) + if( sub == ent_ref ) { found = true; break; } LISTod - if(!found) { - LISTadd_last(*flat, ent_ref); + if( !found ) { + LISTadd_last( *flat, ent_ref ); } /* link in to expression */ @@ -454,22 +449,22 @@ int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, L /* If the user said there was a subtype relationship but */ /* did not mention the reverse supertype relationship, */ /* complain (IS p. 44) */ - LISTdo(ent_ref->u.entity->supertypes, sup, Entity) - if(sup == ent) { + LISTdo( ent_ref->u.entity->supertypes, sup, Entity ) + if( sup == ent ) { found = true; break; } LISTod - if(!found) { - if(!ent_ref->u.entity->supertypes) { + if( !found ) { + if( !ent_ref->u.entity->supertypes ) { ent_ref->u.entity->supertypes = LISTcreate(); } - LISTadd_last(ent_ref->u.entity->supertypes, ent); + LISTadd_last( ent_ref->u.entity->supertypes, ent ); } #endif } } - return(i); + return( i ); } /** @@ -478,43 +473,42 @@ int ENTITYresolve_subtype_expression(Expression expr, Entity ent/*was scope*/, L ** ** Resolve all references in a type. */ -void TYPE_resolve(Type *typeaddr /*, Scope scope*/) -{ +void TYPE_resolve( Type * typeaddr /*, Scope scope*/ ) { Type type = *typeaddr; Type ref_type; TypeBody body = type->u.type->body; Scope scope = type->superscope; - if(body) { + if( body ) { /* complex type definition such as aggregates, enums, ... */ - resolve_in_progress(type); + resolve_in_progress( type ); - if(TYPEis_aggregate(type)) { - TYPEresolve(&body->base); + if( TYPEis_aggregate( type ) ) { + TYPEresolve( &body->base ); /* only really critical failure point for future use */ /* of this type is the base type, ignore others (above) */ type->symbol.resolved = body->base->symbol.resolved; - } else if(TYPEis_select(type)) { - LISTdo_links(body->list, link) - TYPEresolve((Type *)&link->data); - if(is_resolve_failed((Type)link->data)) { - resolve_failed(type); + } else if( TYPEis_select( type ) ) { + LISTdo_links( body->list, link ) + TYPEresolve( ( Type * )&link->data ); + if( is_resolve_failed( ( Type )link->data ) ) { + resolve_failed( type ); break; } LISTod; } - } else if(type->u.type->head) { + } else if( type->u.type->head ) { /* simple type definition such as "TYPE T = U" */ - resolve_in_progress(type); + resolve_in_progress( type ); - TYPEresolve(&type->u.type->head); + TYPEresolve( &type->u.type->head ); - if(!is_resolve_failed(type->u.type->head)) { - if(ERRORis_enabled(TYPE_IS_ENTITY)) { - if(TYPEis_entity(type->u.type->head)) { - ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name); - resolve_failed(type); + if( !is_resolve_failed( type->u.type->head ) ) { + if( ERRORis_enabled( TYPE_IS_ENTITY ) ) { + if( TYPEis_entity( type->u.type->head ) ) { + ERRORreport_with_symbol(TYPE_IS_ENTITY, &type->symbol, type->u.type->head->u.type->body->entity->symbol.name ); + resolve_failed( type ); } } /* allow type ref's to be bypassed by caching true type */ @@ -527,14 +521,14 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) /* an attribute or formal parameter whose name is the same */ /* as its type, i.e. "foo : foo". unfortunately, babys like */ /* local variables get thrown out with the bathwater. -snc */ - ref_type = (Type)SCOPEfind(scope, type->symbol.name, - SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE); + ref_type = ( Type )SCOPEfind( scope, type->symbol.name, + SCOPE_FIND_ANYTHING ^ SCOPE_FIND_VARIABLE ); /* SCOPE_FIND_TYPE | SCOPE_FIND_ENTITY);*/ - if(!ref_type) { - ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name); + if( !ref_type ) { + ERRORreport_with_symbol(UNDEFINED_TYPE, &type->symbol, type->symbol.name ); *typeaddr = Type_Bad; /* just in case */ - resolve_failed(type); - } else if(DICT_type == OBJ_TYPE) { + resolve_failed( type ); + } else if( DICT_type == OBJ_TYPE ) { /* due to declarations of multiple attributes off of a */ /* single type ref, we have to use reference counts */ /* to safely deallocate the TypeHead. It's trivial to do */ @@ -542,21 +536,21 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) /* if (type->refcount--) TYPE_destroy(type); */ type = *typeaddr = ref_type; - TYPEresolve(typeaddr); /* addr doesn't matter here */ + TYPEresolve( typeaddr ); /* addr doesn't matter here */ /* it will not be written through */ - } else if(DICT_type == OBJ_ENTITY) { + } else if( DICT_type == OBJ_ENTITY ) { /* if (type->refcount--) TYPE_destroy(type); see above */ - type = *typeaddr = ((Entity)ref_type)->u.entity->type; + type = *typeaddr = ( ( Entity )ref_type )->u.entity->type; } else { ERRORreport_with_symbol(NOT_A_TYPE, &type->symbol, type->symbol.name, - OBJget_type(DICT_type)); - resolve_failed(type); + OBJget_type( DICT_type ) ); + resolve_failed( type ); } } - if(!is_resolve_failed(type)) { - resolved_all(type); + if( !is_resolve_failed( type ) ) { + resolved_all( type ); } return; } @@ -567,15 +561,14 @@ void TYPE_resolve(Type *typeaddr /*, Scope scope*/) ** ** Resolve all references in a variable definition. */ -void VAR_resolve_expressions(Variable v, Entity entity /* was scope */) -{ - EXPresolve(v->name, entity, Type_Dont_Care); /* new!! */ +void VAR_resolve_expressions( Variable v, Entity entity /* was scope */ ) { + EXPresolve( v->name, entity, Type_Dont_Care ); /* new!! */ - if(v->initializer) { - EXPresolve(v->initializer, entity, v->type); + if( v->initializer ) { + EXPresolve( v->initializer, entity, v->type ); - if(is_resolve_failed(v->initializer)) { - resolve_failed(v->name); + if( is_resolve_failed( v->initializer ) ) { + resolve_failed( v->name ); } } } @@ -585,49 +578,48 @@ void VAR_resolve_expressions(Variable v, Entity entity /* was scope */) ** ** Resolve all references in a variable definition. */ -void VAR_resolve_types(Variable v) -{ +void VAR_resolve_types( Variable v ) { int failed = 0; - TYPEresolve(&v->type); - failed = is_resolve_failed(v->type); + TYPEresolve( &v->type ); + failed = is_resolve_failed( v->type ); - if(v->inverse_symbol && (!v->inverse_attribute)) { + if( v->inverse_symbol && ( !v->inverse_attribute ) ) { /* resolve inverse */ Variable attr; Type type = v->type; - if(TYPEis_aggregate(type)) { + if( TYPEis_aggregate( type ) ) { /* pull entity out of aggregate type defn for ... */ /* inverse var: set (or bag) of entity for ...; */ type = type->u.type->body->base; } - if(type->u.type->body->type != entity_) { + if( type->u.type->body->type != entity_ ) { ERRORreport_with_symbol(INVERSE_BAD_ENTITY, - &v->name->symbol, v->inverse_symbol->name); + &v->name->symbol, v->inverse_symbol->name ); } else { - attr = VARfind(type->u.type->body->entity, v->inverse_symbol->name, 1); - if(attr) { + attr = VARfind( type->u.type->body->entity, v->inverse_symbol->name, 1 ); + if( attr ) { v->inverse_attribute = attr; - failed |= is_resolve_failed(attr->name); + failed |= is_resolve_failed( attr->name ); } else { ERRORreport_with_symbol(INVERSE_BAD_ATTR, - v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name); + v->inverse_symbol, v->inverse_symbol->name, type->u.type->body->entity->symbol.name ); } } /* symbol is no longer used here and could be gc'd */ /* but keep around anyway for ease in later reconstruction */ } - if(failed) { - resolve_failed(v->name); + if( failed ) { + resolve_failed( v->name ); } /* note: cannot set resolved bit since it has to be resolved again */ /* by VAR_resolve_expressions later on */ #if 0 else { - resolved_all(v->name); + resolved_all( v->name ); } #endif } @@ -639,10 +631,9 @@ void VAR_resolve_types(Variable v) ** Resolve all references in a statement. */ -void STMTlist_resolve(Linked_List list, Scope scope) -{ - LISTdo(list, s, Statement) - STMTresolve(s, scope); +void STMTlist_resolve( Linked_List list, Scope scope ) { + LISTdo( list, s, Statement ) + STMTresolve( s, scope ); LISTod; } @@ -653,100 +644,98 @@ void STMTlist_resolve(Linked_List list, Scope scope) * * Resolve all references in a case item */ -void CASE_ITresolve(Case_Item item, Scope scope, Statement statement) -{ +void CASE_ITresolve( Case_Item item, Scope scope, Statement statement ) { int validLabels = 0; - LISTdo(item->labels, e, Expression) { - EXPresolve(e, scope, statement->u.Case->selector->return_type); - if(e->return_type != Type_Bad) { + LISTdo( item->labels, e, Expression ) { + EXPresolve( e, scope, statement->u.Case->selector->return_type ); + if( e->return_type != Type_Bad ) { validLabels++; } } LISTod; - if(validLabels) { - STMTresolve(item->action, scope); + if( validLabels ) { + STMTresolve( item->action, scope ); } } -void STMTresolve(Statement statement, Scope scope) -{ +void STMTresolve( Statement statement, Scope scope ) { /* scope is always the function/procedure/rule from SCOPEresolve_expressions_statements(); */ Scope proc; - if(!statement) { + if( !statement ) { return; /* could be null statement */ } - switch(statement->type) { + switch( statement->type ) { case STMT_ALIAS: - EXPresolve(statement->u.alias->variable->initializer, scope, Type_Dont_Care); + EXPresolve( statement->u.alias->variable->initializer, scope, Type_Dont_Care ); statement->u.alias->variable->type = statement->u.alias->variable->initializer->type; - if(!is_resolve_failed(statement->u.alias->variable->initializer)) { - STMTlist_resolve(statement->u.alias->statements, statement->u.alias->scope); + if( !is_resolve_failed( statement->u.alias->variable->initializer ) ) { + STMTlist_resolve( statement->u.alias->statements, statement->u.alias->scope ); } break; case STMT_ASSIGN: - EXPresolve(statement->u.assign->lhs, scope, Type_Dont_Care); - EXPresolve(statement->u.assign->rhs, scope, statement->u.assign->lhs->type); + EXPresolve( statement->u.assign->lhs, scope, Type_Dont_Care ); + EXPresolve( statement->u.assign->rhs, scope, statement->u.assign->lhs->type ); break; case STMT_CASE: - EXPresolve(statement->u.Case->selector, scope, Type_Dont_Care); - LISTdo(statement->u.Case->cases, c, Case_Item) { - CASE_ITresolve(c, scope, statement); + EXPresolve( statement->u.Case->selector, scope, Type_Dont_Care ); + LISTdo( statement->u.Case->cases, c, Case_Item ) { + CASE_ITresolve( c, scope, statement ); } LISTod; break; case STMT_COMPOUND: - STMTlist_resolve(statement->u.compound->statements, scope); + STMTlist_resolve( statement->u.compound->statements, scope ); break; case STMT_COND: - EXPresolve(statement->u.cond->test, scope, Type_Dont_Care); - STMTlist_resolve(statement->u.cond->code, scope); - if(statement->u.cond->otherwise) { - STMTlist_resolve(statement->u.cond->otherwise, scope); + EXPresolve( statement->u.cond->test, scope, Type_Dont_Care ); + STMTlist_resolve( statement->u.cond->code, scope ); + if( statement->u.cond->otherwise ) { + STMTlist_resolve( statement->u.cond->otherwise, scope ); } break; case STMT_PCALL: #define proc_name statement->symbol.name - proc = (Scope)SCOPEfind(scope, proc_name, - SCOPE_FIND_PROCEDURE); - if(proc) { - if(DICT_type != OBJ_PROCEDURE) { - Symbol *newsym = OBJget_symbol(proc, DICT_type); - ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line); + proc = ( Scope )SCOPEfind( scope, proc_name, + SCOPE_FIND_PROCEDURE ); + if( proc ) { + if( DICT_type != OBJ_PROCEDURE ) { + Symbol * newsym = OBJget_symbol( proc, DICT_type ); + ERRORreport_with_symbol(EXPECTED_PROC, &statement->symbol, proc_name, newsym->line ); } else { statement->u.proc->procedure = proc; } } else { - ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name); + ERRORreport_with_symbol(NO_SUCH_PROCEDURE, &statement->symbol, proc_name ); } - LISTdo(statement->u.proc->parameters, e, Expression) - EXPresolve(e, scope, Type_Dont_Care); + LISTdo( statement->u.proc->parameters, e, Expression ) + EXPresolve( e, scope, Type_Dont_Care ); LISTod; break; case STMT_LOOP: - if(statement->u.loop->scope) { + if( statement->u.loop->scope ) { /* resolve increment with old scope */ - EXPresolve(statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care); - EXPresolve(statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care); - EXPresolve(statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care); + EXPresolve( statement->u.loop->scope->u.incr->init, scope, Type_Dont_Care ); + EXPresolve( statement->u.loop->scope->u.incr->end, scope, Type_Dont_Care ); + EXPresolve( statement->u.loop->scope->u.incr->increment, scope, Type_Dont_Care ); /* resolve others with new scope! */ scope = statement->u.loop->scope; } - if(statement->u.loop->while_expr) { - EXPresolve(statement->u.loop->while_expr, scope, Type_Dont_Care); + if( statement->u.loop->while_expr ) { + EXPresolve( statement->u.loop->while_expr, scope, Type_Dont_Care ); } - if(statement->u.loop->until_expr) { - EXPresolve(statement->u.loop->until_expr, scope, Type_Dont_Care); + if( statement->u.loop->until_expr ) { + EXPresolve( statement->u.loop->until_expr, scope, Type_Dont_Care ); } - STMTlist_resolve(statement->u.loop->statements, scope); + STMTlist_resolve( statement->u.loop->statements, scope ); break; case STMT_RETURN: - if(statement->u.ret->value) { - EXPresolve(statement->u.ret->value, scope, Type_Dont_Care); + if( statement->u.ret->value ) { + EXPresolve( statement->u.ret->value, scope, Type_Dont_Care ); } break; case STMT_SKIP: @@ -756,87 +745,83 @@ void STMTresolve(Statement statement, Scope scope) } } -static Variable ENTITY_get_local_attribute(Entity e, char *name) -{ - LISTdo(e->u.entity->attributes, a, Variable) - if(!strcmp(VARget_simple_name(a), name)) { +static Variable ENTITY_get_local_attribute( Entity e, char * name ) { + LISTdo( e->u.entity->attributes, a, Variable ) + if( !strcmp( VARget_simple_name( a ), name ) ) { return a; } LISTod; return 0; } -void ENTITYresolve_expressions(Entity e) -{ +void ENTITYresolve_expressions( Entity e ) { Variable v; int status = 0; DictionaryEntry de; - char *sname; + char * sname; Entity sup; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } self = e->u.entity->type; - LISTdo(e->u.entity->attributes, attr, Variable) { - if(attr->name->type->u.type->body->type == op_) { + LISTdo( e->u.entity->attributes, attr, Variable ) { + if( attr->name->type->u.type->body->type == op_ ) { /* attribute redeclaration */ sname = attr->name->e.op1->e.op2->symbol.name; - if(!strcmp(sname, e->symbol.name) || - !(sup = ENTITYfind_inherited_entity(e, sname, 0))) { + if( !strcmp( sname, e->symbol.name ) || + !( sup = ENTITYfind_inherited_entity( e, sname, 0 ) ) ) { ERRORreport_with_symbol(REDECL_NO_SUCH_SUPERTYPE, &attr->name->e.op1->e.op2->symbol, attr->name->e.op1->e.op2->symbol.name, - VARget_simple_name(attr)); - resolve_failed(attr->name); + VARget_simple_name( attr ) ); + resolve_failed( attr->name ); } else { - sname = VARget_simple_name(attr); - if(!ENTITY_get_local_attribute(sup, sname)) { + sname = VARget_simple_name( attr ); + if( !ENTITY_get_local_attribute( sup, sname ) ) { ERRORreport_with_symbol(REDECL_NO_SUCH_ATTR, &attr->name->e.op2->symbol, sname, - sup->symbol.name); - resolve_failed(attr->name); + sup->symbol.name ); + resolve_failed( attr->name ); } /* should be ok to share this ptr */ attr->name->symbol.name = sname; } } else { /* new attribute declaration */ - LISTdo_n(e->u.entity->supertypes, supr, Entity, b) { - if(ENTITYget_named_attribute(supr, - attr->name->symbol.name)) { - ERRORreport_with_symbol(OVERLOADED_ATTR, - &attr->name->symbol, - attr->name->symbol.name, - supr->symbol.name); - resolve_failed(attr->name); - } - } - LISTod; + LISTdo_n( e->u.entity->supertypes, supr, Entity, b ) { + if( ENTITYget_named_attribute( supr, + attr->name->symbol.name ) ) { + ERRORreport_with_symbol(OVERLOADED_ATTR, + &attr->name->symbol, + attr->name->symbol.name, + supr->symbol.name ); + resolve_failed( attr->name ); + } + } LISTod; } - VARresolve_expressions(attr, e); - status |= is_resolve_failed(attr->name); - } - LISTod; - - DICTdo_type_init(e->symbol_table, &de, OBJ_VARIABLE); - while(0 != (v = (Variable)DICTdo(&de))) { - if(!is_resolve_failed(v->name)) { - TYPEresolve_expressions(v->type, e); - if(v->initializer) { - EXPresolve(v->initializer, e, v->type); - status |= is_resolve_failed(v->initializer); + VARresolve_expressions( attr, e ); + status |= is_resolve_failed( attr->name ); + } LISTod; + + DICTdo_type_init( e->symbol_table, &de, OBJ_VARIABLE ); + while( 0 != ( v = ( Variable )DICTdo( &de ) ) ) { + if( !is_resolve_failed( v->name ) ) { + TYPEresolve_expressions( v->type, e ); + if( v->initializer ) { + EXPresolve( v->initializer, e, v->type ); + status |= is_resolve_failed( v->initializer ); } } else { status = RESOLVE_FAILED; } } - if(!WHEREresolve(e->where, e, 1)) { + if( !WHEREresolve( e->where, e, 1 ) ) { status = RESOLVE_FAILED; } @@ -847,87 +832,80 @@ void ENTITYresolve_expressions(Entity e) -void ENTITYcheck_missing_supertypes(Entity ent) -{ +void ENTITYcheck_missing_supertypes( Entity ent ) { int found; /* Make sure each of my subtypes lists me as a supertype */ - LISTdo(ent->u.entity->subtypes, sub, Entity) { + LISTdo( ent->u.entity->subtypes, sub, Entity ) { found = false; - LISTdo_n(sub->u.entity->supertypes, sup, Entity, b) { - if(sup == ent) { + LISTdo_n( sub->u.entity->supertypes, sup, Entity, b ) { + if( sup == ent ) { found = true; break; } + } LISTod; + if( !found ) { + ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name ); + resolve_failed( sub ); } - LISTod; - if(!found) { - ERRORreport_with_symbol(MISSING_SUPERTYPE, &sub->symbol, ent->symbol.name, sub->symbol.name); - resolve_failed(sub); - } - } - LISTod; + } LISTod; } /** calculate number of attributes inheritance, following up superclass chain */ -void ENTITYcalculate_inheritance(Entity e) -{ +void ENTITYcalculate_inheritance( Entity e ) { e->u.entity->inheritance = 0; - LISTdo(e->u.entity->supertypes, super, Entity) { - if(super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED) { - ENTITYcalculate_inheritance(super); + LISTdo( e->u.entity->supertypes, super, Entity ) { + if( super->u.entity->inheritance == ENTITY_INHERITANCE_UNINITIALIZED ) { + ENTITYcalculate_inheritance( super ); } - e->u.entity->inheritance += ENTITYget_size(super); + e->u.entity->inheritance += ENTITYget_size( super ); } LISTod } /** returns 1 if entity is involved in circularity, else 0 */ -int ENTITY_check_subsuper_cyclicity(Entity e, Entity enew) -{ +int ENTITY_check_subsuper_cyclicity( Entity e, Entity enew ) { /* just check subtypes - this implicitly checks supertypes */ /* as well */ - LISTdo(enew->u.entity->subtypes, sub, Entity) - if(e == sub) { - ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name); + LISTdo( enew->u.entity->subtypes, sub, Entity ) + if( e == sub ) { + ERRORreport_with_symbol(SUBSUPER_LOOP, &sub->symbol, e->symbol.name ); return 1; } - if(sub->search_id == __SCOPE_search_id) { + if( sub->search_id == __SCOPE_search_id ) { return 0; } sub->search_id = __SCOPE_search_id; - if(ENTITY_check_subsuper_cyclicity(e, sub)) { - ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name); + if( ENTITY_check_subsuper_cyclicity( e, sub ) ) { + ERRORreport_with_symbol(SUBSUPER_CONTINUATION, &sub->symbol, sub->symbol.name ); return 1; } LISTod; return 0; } -void ENTITYcheck_subsuper_cyclicity(Entity e) -{ +void ENTITYcheck_subsuper_cyclicity( Entity e ) { __SCOPE_search_id++; - (void) ENTITY_check_subsuper_cyclicity(e, e); + ( void ) ENTITY_check_subsuper_cyclicity( e, e ); } /** returns 1 if select type is involved in circularity, else 0 */ -int TYPE_check_select_cyclicity(TypeBody tb, Type tnew) -{ - LISTdo(tnew->u.type->body->list, item, Type) - if(item->u.type->body->type == select_) { - if(tb == item->u.type->body) { +int TYPE_check_select_cyclicity( TypeBody tb, Type tnew ) { + LISTdo( tnew->u.type->body->list, item, Type ) + if( item->u.type->body->type == select_ ) { + if( tb == item->u.type->body ) { ERRORreport_with_symbol(SELECT_LOOP, - &item->symbol, item->symbol.name); + &item->symbol, item->symbol.name ); return 1; } - if(item->search_id == __SCOPE_search_id) { + if( item->search_id == __SCOPE_search_id ) { return 0; } item->search_id = __SCOPE_search_id; - if(TYPE_check_select_cyclicity(tb, item)) { + if( TYPE_check_select_cyclicity( tb, item ) ) { ERRORreport_with_symbol(SELECT_CONTINUATION, - &item->symbol, item->symbol.name); + &item->symbol, item->symbol.name ); return 1; } } @@ -935,115 +913,112 @@ int TYPE_check_select_cyclicity(TypeBody tb, Type tnew) return 0; } -void TYPEcheck_select_cyclicity(Type t) -{ - if(t->u.type->body->type == select_) { +void TYPEcheck_select_cyclicity( Type t ) { + if( t->u.type->body->type == select_ ) { __SCOPE_search_id++; - (void) TYPE_check_select_cyclicity(t->u.type->body, t); + ( void ) TYPE_check_select_cyclicity( t->u.type->body, t ); } } -void ENTITYresolve_types(Entity e); +void ENTITYresolve_types( Entity e ); /** also resolves inheritance counts and sub/super consistency */ -void SCOPEresolve_types(Scope s) -{ +void SCOPEresolve_types( Scope s ) { Variable var; DictionaryEntry de; void *x; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - DICTdo_init(s->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(DICT_type) { + DICTdo_init( s->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( DICT_type ) { case OBJ_TYPE: - if(ERRORis_enabled(SELECT_LOOP)) { - TYPEcheck_select_cyclicity((Type)x); + if( ERRORis_enabled( SELECT_LOOP ) ) { + TYPEcheck_select_cyclicity( ( Type )x ); } break; case OBJ_VARIABLE: /* really constants */ - var = (Variable)x; + var = ( Variable )x; /* before OBJ_BITS hack, we looked in s->superscope */ - TYPEresolve(&var->type); - if(is_resolve_failed(var->type)) { - resolve_failed(var->name); - resolve_failed(s); + TYPEresolve( &var->type ); + if( is_resolve_failed( var->type ) ) { + resolve_failed( var->name ); + resolve_failed( s ); } break; case OBJ_ENTITY: - ENTITYcheck_missing_supertypes((Entity)x); - ENTITYresolve_types((Entity)x); - ENTITYcalculate_inheritance((Entity)x); - if(ERRORis_enabled(SUBSUPER_LOOP)) { - ENTITYcheck_subsuper_cyclicity((Entity)x); + ENTITYcheck_missing_supertypes( ( Entity )x ); + ENTITYresolve_types( ( Entity )x ); + ENTITYcalculate_inheritance( ( Entity )x ); + if( ERRORis_enabled( SUBSUPER_LOOP ) ) { + ENTITYcheck_subsuper_cyclicity( ( Entity )x ); } - if(is_resolve_failed((Entity)x)) { - resolve_failed(s); + if( is_resolve_failed( ( Entity )x ) ) { + resolve_failed( s ); } break; case OBJ_SCHEMA: - if(is_not_resolvable((Schema)x)) { + if( is_not_resolvable( ( Schema )x ) ) { break; } - /*FALLTHRU*/ + /*FALLTHRU*/ case OBJ_PROCEDURE: case OBJ_RULE: case OBJ_FUNCTION: - SCOPEresolve_types((Scope)x); - if(is_resolve_failed((Scope)x)) { - resolve_failed(s); + SCOPEresolve_types( ( Scope )x ); + if( is_resolve_failed( ( Scope )x ) ) { + resolve_failed( s ); } break; default: break; } } - if(s->type == OBJ_FUNCTION) { - TYPEresolve(&s->u.func->return_type); + if( s->type == OBJ_FUNCTION ) { + TYPEresolve( &s->u.func->return_type ); } } /** for each supertype, find the entity it refs to */ -void ENTITYresolve_supertypes(Entity e) -{ +void ENTITYresolve_supertypes( Entity e ) { Entity ref_entity; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - if(e->u.entity->supertype_symbols) { + if( e->u.entity->supertype_symbols ) { e->u.entity->supertypes = LISTcreate(); } #if 0 - if(e->u.entity->supertype_symbols && !e->u.entity->supertypes) { + if( e->u.entity->supertype_symbols && !e->u.entity->supertypes ) { e->u.entity->supertypes = LISTcreate(); } #endif - LISTdo(e->u.entity->supertype_symbols, sym, Symbol *) { - ref_entity = (Entity)SCOPEfind(e->superscope, sym->name, SCOPE_FIND_ENTITY); - if(!ref_entity) { - ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name); + LISTdo( e->u.entity->supertype_symbols, sym, Symbol * ) { + ref_entity = ( Entity )SCOPEfind( e->superscope, sym->name, SCOPE_FIND_ENTITY ); + if( !ref_entity ) { + ERRORreport_with_symbol(UNKNOWN_SUPERTYPE, sym, sym->name, e->symbol.name ); /* ENTITY_resolve_failed = 1;*/ - resolve_failed(e); - } else if(DICT_type != OBJ_ENTITY) { - Symbol *newsym = OBJget_symbol(ref_entity, DICT_type); - ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line); + resolve_failed( e ); + } else if( DICT_type != OBJ_ENTITY ) { + Symbol * newsym = OBJget_symbol( ref_entity, DICT_type ); + ERRORreport_with_symbol(SUPERTYPE_RESOLVE, sym, sym->name, newsym->line ); /* ENTITY_resolve_failed = 1;*/ - resolve_failed(e); + resolve_failed( e ); } else { bool found = false; - LISTadd_last(e->u.entity->supertypes, ref_entity); - if(is_resolve_failed(ref_entity)) { - resolve_failed(e); + LISTadd_last( e->u.entity->supertypes, ref_entity ); + if( is_resolve_failed( ref_entity ) ) { + resolve_failed( e ); } /* If the user said there was a supertype relationship but */ @@ -1051,36 +1026,33 @@ void ENTITYresolve_supertypes(Entity e) /* force it to be explicitly known by listing this entity */ /* in the ref'd entity's subtype list */ - LISTdo_n(ref_entity->u.entity->subtypes, sub, Entity, b) { - if(sub == e) { + LISTdo_n( ref_entity->u.entity->subtypes, sub, Entity, b ) { + if( sub == e ) { found = true; break; } - } - LISTod - if(!found) { - if(!ref_entity->u.entity->subtypes) { + } LISTod + if( !found ) { + if( !ref_entity->u.entity->subtypes ) { ref_entity->u.entity->subtypes = LISTcreate(); } - LISTadd_last(ref_entity->u.entity->subtypes, e); + LISTadd_last( ref_entity->u.entity->subtypes, e ); } } - } - LISTod; + } LISTod; } -void ENTITYresolve_subtypes(Entity e) -{ +void ENTITYresolve_subtypes( Entity e ) { int i; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - i = ENTITYresolve_subtype_expression(e->u.entity->subtype_expression, e, &e->u.entity->subtypes); - if(i & RESOLVE_FAILED) { - resolve_failed(e); + i = ENTITYresolve_subtype_expression( e->u.entity->subtype_expression, e, &e->u.entity->subtypes ); + if( i & RESOLVE_FAILED ) { + resolve_failed( e ); } } @@ -1090,86 +1062,80 @@ void ENTITYresolve_subtypes(Entity e) * where ref'd_attrs are either simple ids or SELF\entity.attr * where "entity" represents a supertype (only, I believe) */ -void ENTITYresolve_uniques(Entity e) -{ +void ENTITYresolve_uniques( Entity e ) { Variable attr, attr2 = 0; int failed = 0; - LISTdo(e->u.entity->unique, unique, Linked_List) { + LISTdo( e->u.entity->unique, unique, Linked_List ) { int i = 0; - LISTdo_links(unique, reflink) { + LISTdo_links( unique, reflink ) { Type old_self = self; Expression expr; /* skip first which is always the label (or NULL if no label) */ i++; - if(i == 1) { + if( i == 1 ) { continue; } - expr = (Expression) reflink->data; - assert(expr); + expr = ( Expression ) reflink->data; + assert( expr ); self = e->u.entity->type; - EXPresolve(expr, e, Type_Dont_Care); + EXPresolve( expr, e, Type_Dont_Care ); self = old_self; /* SELF\entity.attr, or just an attr name? */ - if((expr->e.op_code == OP_DOT) && - (expr->e.op1->e.op_code == OP_GROUP) && - (expr->e.op1->e.op1->type == Type_Self)) { - attr = ENTITYresolve_attr_ref(e, &(expr->e.op1->e.op2->symbol), &(expr->e.op2->symbol)); - attr2 = ENTITYresolve_attr_ref(e, 0, &(expr->e.op2->symbol)); + if( ( expr->e.op_code == OP_DOT ) && + ( expr->e.op1->e.op_code == OP_GROUP ) && + ( expr->e.op1->e.op1->type == Type_Self ) ) { + attr = ENTITYresolve_attr_ref( e, &( expr->e.op1->e.op2->symbol ), &( expr->e.op2->symbol ) ); + attr2 = ENTITYresolve_attr_ref( e, 0, &( expr->e.op2->symbol ) ); } else { - attr = ENTITYresolve_attr_ref(e, 0, &(expr->symbol)); + attr = ENTITYresolve_attr_ref( e, 0, &( expr->symbol ) ); } - if((attr2) && (attr != attr2) && (ENTITYdeclares_variable(e, attr2))) { + if( ( attr2 ) && ( attr != attr2 ) && ( ENTITYdeclares_variable( e, attr2 ) ) ) { /* attr exists in type + supertype - it's a redeclaration. * in this case, qualifiers are unnecessary; print a warning */ - ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &(expr->e.op2->symbol), expr->e.op2->symbol.name, e->symbol.name); + ERRORreport_with_symbol(UNIQUE_QUAL_REDECL, &( expr->e.op2->symbol ), expr->e.op2->symbol.name, e->symbol.name ); } - if(!attr) { + if( !attr ) { /* ERRORreport_with_symbol(ERROR_unknown_attr_in_entity,*/ /* aref->attribute, aref->attribute->name,*/ /* e->symbol.name);*/ failed = RESOLVE_FAILED; continue; } - if(ENTITYdeclares_variable(e, attr)) { + if( ENTITYdeclares_variable( e, attr ) ) { attr->flags.unique = 1; } - } - LISTod; - } - LISTod; + } LISTod; + } LISTod; e->symbol.resolved |= failed; } -void ENTITYresolve_types(Entity e) -{ +void ENTITYresolve_types( Entity e ) { int failed = 0; - if(print_objects_while_running & OBJ_ENTITY_BITS) { - fprintf(stderr, "pass %d: %s (entity)\n", EXPRESSpass, - e->symbol.name); + if( print_objects_while_running & OBJ_ENTITY_BITS ) { + fprintf( stderr, "pass %d: %s (entity)\n", EXPRESSpass, + e->symbol.name ); } - LISTdo(e->u.entity->attributes, att, Variable) { + LISTdo( e->u.entity->attributes, att, Variable ) { /* resolve in context of superscope to allow "X : X;" */ - VARresolve_types(att); - failed |= is_resolve_failed(att->name); - } - LISTod; + VARresolve_types( att ); + failed |= is_resolve_failed( att->name ); + } LISTod; /* * resolve the 'unique' list */ - ENTITYresolve_uniques(e); + ENTITYresolve_uniques( e ); /* don't wipe out any previous failure stat */ e->symbol.resolved |= failed; } /** resolve all expressions in type definitions */ -void TYPEresolve_expressions(Type t, Scope s) -{ +void TYPEresolve_expressions( Type t, Scope s ) { TypeBody body; /* meaning of self in a type declaration refers to the type itself, so */ @@ -1178,69 +1144,67 @@ void TYPEresolve_expressions(Type t, Scope s) self = t; /* recurse through base types */ - for(;; t = body->base) { - if(t->where) { - (void)WHEREresolve(t->where, s, 1); + for( ;; t = body->base ) { + if( t->where ) { + ( void )WHEREresolve( t->where, s, 1 ); } /* reached an indirect type definition, resolved elsewhere */ - if(t->u.type->head) { + if( t->u.type->head ) { break; } - if(!TYPEis_aggregate(t)) { + if( !TYPEis_aggregate( t ) ) { break; } body = t->u.type->body; - if(body->upper) { - EXPresolve(body->upper, s, Type_Dont_Care); + if( body->upper ) { + EXPresolve( body->upper, s, Type_Dont_Care ); } - if(body->lower) { - EXPresolve(body->lower, s, Type_Dont_Care); + if( body->lower ) { + EXPresolve( body->lower, s, Type_Dont_Care ); } - if(body->precision) { - EXPresolve(body->precision, s, Type_Dont_Care); + if( body->precision ) { + EXPresolve( body->precision, s, Type_Dont_Care ); } } self = self_old; } -int WHEREresolve(Linked_List list, Scope scope, int need_self) -{ +int WHEREresolve( Linked_List list, Scope scope, int need_self ) { int status = 0; - LISTdo(list, w, Where) + LISTdo( list, w, Where ) /* check if we've been here before */ /* i'm not sure why, but it happens */ status |= w->label->resolved; - if(w->label->resolved & (RESOLVED | RESOLVE_FAILED)) { + if( w->label->resolved & ( RESOLVED | RESOLVE_FAILED ) ) { break; } found_self = false; - EXPresolve(w->expr, scope, Type_Dont_Care); - if(need_self && ! found_self) { + EXPresolve( w->expr, scope, Type_Dont_Care ); + if( need_self && ! found_self ) { ERRORreport_with_symbol(MISSING_SELF, - w->label, - w->label->name); + w->label, + w->label->name ); w->label->resolved = RESOLVE_FAILED; } else { w->label->resolved = RESOLVED; } status |= w->label->resolved; LISTod - if(status == RESOLVE_FAILED) { + if( status == RESOLVE_FAILED ) { return 0; } else { return 1; } } -struct tag *TAGcreate_tags() -{ +struct tag * TAGcreate_tags() { extern int tag_count; - return((struct tag *)calloc(tag_count, sizeof(struct tag))); + return( ( struct tag * )calloc( tag_count, sizeof( struct tag ) ) ); } diff --git a/src/express/resolve2.c b/src/express/resolve2.c index e00e50e3c..bd5518595 100644 --- a/src/express/resolve2.c +++ b/src/express/resolve2.c @@ -7,91 +7,89 @@ #include "express/schema.h" #include "express/resolve.h" -void SCOPEresolve_subsupers(Scope scope) -{ +void SCOPEresolve_subsupers( Scope scope ) { DictionaryEntry de; void *x; char type; - Symbol *sym; + Symbol * sym; Type t; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(scope->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - scope->symbol.name, OBJget_type(scope->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( scope->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + scope->symbol.name, OBJget_type( scope->type ) ); } - DICTdo_init(scope->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(type = DICT_type) { + DICTdo_init( scope->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( type = DICT_type ) { case OBJ_ENTITY: - ENTITYresolve_supertypes((Entity)x); - ENTITYresolve_subtypes((Entity)x); + ENTITYresolve_supertypes( ( Entity )x ); + ENTITYresolve_subtypes( ( Entity )x ); break; case OBJ_FUNCTION: case OBJ_PROCEDURE: case OBJ_RULE: - SCOPEresolve_subsupers((Scope)x); + SCOPEresolve_subsupers( ( Scope )x ); break; case OBJ_TYPE: - t = (Type)x; - TYPEresolve(&t); + t = ( Type )x; + TYPEresolve( &t ); break; default: /* ignored everything else */ break; } - sym = OBJget_symbol(x, type); - if(is_resolve_failed_raw(sym)) { - resolve_failed(scope); + sym = OBJget_symbol( x, type ); + if( is_resolve_failed_raw( sym ) ) { + resolve_failed( scope ); } } } -void SCOPEresolve_expressions_statements(Scope s) -{ +void SCOPEresolve_expressions_statements( Scope s ) { DictionaryEntry de; void *x; Variable v; - if(print_objects_while_running & OBJ_SCOPE_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_SCOPE_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - DICTdo_init(s->symbol_table, &de); - while(0 != (x = DICTdo(&de))) { - switch(DICT_type) { + DICTdo_init( s->symbol_table, &de ); + while( 0 != ( x = DICTdo( &de ) ) ) { + switch( DICT_type ) { case OBJ_SCHEMA: - if(is_not_resolvable((Schema)x)) { + if( is_not_resolvable( ( Schema )x ) ) { break; } - SCOPEresolve_expressions_statements((Scope)x); + SCOPEresolve_expressions_statements( ( Scope )x ); break; case OBJ_ENTITY: - ENTITYresolve_expressions((Entity)x); + ENTITYresolve_expressions( ( Entity )x ); break; case OBJ_FUNCTION: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.func->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.func->body ); break; case OBJ_PROCEDURE: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.proc->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.proc->body ); break; case OBJ_RULE: - ALGresolve_expressions_statements((Scope)x, ((Scope)x)->u.rule->body); + ALGresolve_expressions_statements( ( Scope )x, ( ( Scope )x )->u.rule->body ); - WHEREresolve(RULEget_where((Scope)x), (Scope)x, 0); + WHEREresolve( RULEget_where( ( Scope )x ), ( Scope )x, 0 ); break; case OBJ_VARIABLE: - v = (Variable)x; - TYPEresolve_expressions(v->type, s); - if(v->initializer) { - EXPresolve(v->initializer, s, v->type); + v = ( Variable )x; + TYPEresolve_expressions( v->type, s ); + if( v->initializer ) { + EXPresolve( v->initializer, s, v->type ); } break; case OBJ_TYPE: - TYPEresolve_expressions((Type)x, s); + TYPEresolve_expressions( ( Type )x, s ); break; default: /* ignored everything else */ @@ -100,18 +98,17 @@ void SCOPEresolve_expressions_statements(Scope s) } } -void ALGresolve_expressions_statements(Scope s, Linked_List statements) -{ +void ALGresolve_expressions_statements( Scope s, Linked_List statements ) { int status = 0; - if(print_objects_while_running & OBJ_ALGORITHM_BITS & - OBJget_bits(s->type)) { - fprintf(stderr, "pass %d: %s (%s)\n", EXPRESSpass, - s->symbol.name, OBJget_type(s->type)); + if( print_objects_while_running & OBJ_ALGORITHM_BITS & + OBJget_bits( s->type ) ) { + fprintf( stderr, "pass %d: %s (%s)\n", EXPRESSpass, + s->symbol.name, OBJget_type( s->type ) ); } - SCOPEresolve_expressions_statements(s); - STMTlist_resolve(statements, s); + SCOPEresolve_expressions_statements( s ); + STMTlist_resolve( statements, s ); s->symbol.resolved = status; } diff --git a/src/express/schema.c b/src/express/schema.c index 7fc3d6899..5dd77873a 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -53,8 +53,7 @@ int __SCOPE_search_id = 0; /** Initialize the Schema module. */ -void SCHEMAinitialize(void) -{ +void SCHEMAinitialize( void ) { } @@ -74,125 +73,116 @@ void SCHEMAinitialize(void) */ void -SCHEMAdump(Schema schema, FILE *file) -{ - fprintf(file, "SCHEMA %s:\n", SCHEMAget_name(schema)); - SCOPEdump(schema, file); - fprintf(file, "END SCHEMA %s\n\n", SCHEMAget_name(schema)); +SCHEMAdump( Schema schema, FILE * file ) { + fprintf( file, "SCHEMA %s:\n", SCHEMAget_name( schema ) ); + SCOPEdump( schema, file ); + fprintf( file, "END SCHEMA %s\n\n", SCHEMAget_name( schema ) ); } #endif #if 0 -SYMBOLprint(Symbol *s) -{ - fprintf(stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename); +SYMBOLprint( Symbol * s ) { + fprintf( stderr, "%s (r:%d #:%d f:%s)\n", s->name, s->resolved, s->line, s->filename ); } #endif -void SCHEMAadd_reference(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) -{ - Rename *r = REN_new(); +void SCHEMAadd_reference( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { + Rename * r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = ref; - if(!cur_schema->u.schema->reflist) { + if( !cur_schema->u.schema->reflist ) { cur_schema->u.schema->reflist = LISTcreate(); } - LISTadd_last(cur_schema->u.schema->reflist, r); + LISTadd_last( cur_schema->u.schema->reflist, r ); } -void SCHEMAadd_use(Schema cur_schema, Symbol *ref_schema, Symbol *old, Symbol *snnew) -{ - Rename *r = REN_new(); +void SCHEMAadd_use( Schema cur_schema, Symbol * ref_schema, Symbol * old, Symbol * snnew ) { + Rename * r = REN_new(); r->schema_sym = ref_schema; r->old = old; r->nnew = snnew; r->rename_type = use; - if(!cur_schema->u.schema->uselist) { + if( !cur_schema->u.schema->uselist ) { cur_schema->u.schema->uselist = LISTcreate(); } - LISTadd_last(cur_schema->u.schema->uselist, r); + LISTadd_last( cur_schema->u.schema->uselist, r ); } -void SCHEMAdefine_reference(Schema schema, Rename *r) -{ - Rename *old = 0; - char *name = (r->nnew ? r->nnew : r->old)->name; +void SCHEMAdefine_reference( Schema schema, Rename * r ) { + Rename * old = 0; + char * name = ( r->nnew ? r->nnew : r->old )->name; - if(!schema->u.schema->refdict) { - schema->u.schema->refdict = DICTcreate(20); + if( !schema->u.schema->refdict ) { + schema->u.schema->refdict = DICTcreate( 20 ); } else { - old = (Rename *)DICTlookup(schema->u.schema->refdict, name); + old = ( Rename * )DICTlookup( schema->u.schema->refdict, name ); } - if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { - DICTdefine(schema->u.schema->refdict, name, - r, r->old, OBJ_RENAME); + if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { + DICTdefine( schema->u.schema->refdict, name, + r, r->old, OBJ_RENAME ); } } -void SCHEMAdefine_use(Schema schema, Rename *r) -{ - Rename *old = 0; - char *name = (r->nnew ? r->nnew : r->old)->name; +void SCHEMAdefine_use( Schema schema, Rename * r ) { + Rename * old = 0; + char * name = ( r->nnew ? r->nnew : r->old )->name; - if(!schema->u.schema->usedict) { - schema->u.schema->usedict = DICTcreate(20); + if( !schema->u.schema->usedict ) { + schema->u.schema->usedict = DICTcreate( 20 ); } else { - old = (Rename *)DICTlookup(schema->u.schema->usedict, name); + old = ( Rename * )DICTlookup( schema->u.schema->usedict, name ); } - if(!old || (DICT_type != OBJ_RENAME) || (old->object != r->object)) { - DICTdefine(schema->u.schema->usedict, name, - r, r->old, OBJ_RENAME); + if( !old || ( DICT_type != OBJ_RENAME ) || ( old->object != r->object ) ) { + DICTdefine( schema->u.schema->usedict, name, + r, r->old, OBJ_RENAME ); } } -static void SCHEMA_get_entities_use(Scope scope, Linked_List result) -{ +static void SCHEMA_get_entities_use( Scope scope, Linked_List result ) { DictionaryEntry de; - Rename *rename; + Rename * rename; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return; } scope->search_id = __SCOPE_search_id; /* fully USE'd schema */ - LISTdo(scope->u.schema->use_schemas, schema, Schema) - SCOPE_get_entities(schema, result); - SCHEMA_get_entities_use(schema, result); + LISTdo( scope->u.schema->use_schemas, schema, Schema ) + SCOPE_get_entities( schema, result ); + SCHEMA_get_entities_use( schema, result ); LISTod /* partially USE'd schema */ - if(scope->u.schema->usedict) { - DICTdo_init(scope->u.schema->usedict, &de); - while(0 != (rename = (Rename *)DICTdo(&de))) { - LISTadd_last(result, rename->object); + if( scope->u.schema->usedict ) { + DICTdo_init( scope->u.schema->usedict, &de ); + while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { + LISTadd_last( result, rename->object ); } } } /** return use'd entities */ -Linked_List SCHEMAget_entities_use(Scope scope) -{ +Linked_List SCHEMAget_entities_use( Scope scope ) { Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_use(scope, result); - return(result); + SCHEMA_get_entities_use( scope, result ); + return( result ); } /** return ref'd entities */ -void SCHEMA_get_entities_ref(Scope scope, Linked_List result) -{ - Rename *rename; +void SCHEMA_get_entities_ref( Scope scope, Linked_List result ) { + Rename * rename; DictionaryEntry de; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return; } scope->search_id = __SCOPE_search_id; @@ -200,47 +190,45 @@ void SCHEMA_get_entities_ref(Scope scope, Linked_List result) ENTITY_MARK++; /* fully REF'd schema */ - LISTdo(scope->u.schema->ref_schemas, schema, Schema) - SCOPE_get_entities(schema, result); + LISTdo( scope->u.schema->ref_schemas, schema, Schema ) + SCOPE_get_entities( schema, result ); /* don't go down remote schema's ref_schemas */ LISTod /* partially REF'd schema */ - DICTdo_init(scope->u.schema->refdict, &de); - while(0 != (rename = (Rename *)DICTdo(&de))) { - if(DICT_type == OBJ_ENTITY) { - LISTadd_last(result, rename->object); + DICTdo_init( scope->u.schema->refdict, &de ); + while( 0 != ( rename = ( Rename * )DICTdo( &de ) ) ) { + if( DICT_type == OBJ_ENTITY ) { + LISTadd_last( result, rename->object ); } } } /** return ref'd entities */ -Linked_List SCHEMAget_entities_ref(Scope scope) -{ +Linked_List SCHEMAget_entities_ref( Scope scope ) { Linked_List result = LISTcreate(); __SCOPE_search_id++; ENTITY_MARK++; - SCHEMA_get_entities_ref(scope, result); - return(result); + SCHEMA_get_entities_ref( scope, result ); + return( result ); } /** * look up an attribute reference * if strict false, anything can be returned, not just attributes */ -Variable VARfind(Scope scope, char *name, int strict) -{ +Variable VARfind( Scope scope, char * name, int strict ) { Variable result; /* first look up locally */ - switch(scope->type) { + switch( scope->type ) { case OBJ_ENTITY: - result = ENTITYfind_inherited_attribute(scope, name, 0); - if(result) { - if(strict && (DICT_type != OBJ_VARIABLE)) { - fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); + result = ENTITYfind_inherited_attribute( scope, name, 0 ); + if( result ) { + if( strict && ( DICT_type != OBJ_VARIABLE ) ) { + fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); } return result; } @@ -248,14 +236,14 @@ Variable VARfind(Scope scope, char *name, int strict) case OBJ_INCREMENT: case OBJ_QUERY: case OBJ_ALIAS: - result = (Variable)DICTlookup(scope->symbol_table, name); - if(result) { - if(strict && (DICT_type != OBJ_VARIABLE)) { - fprintf(stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n"); + result = ( Variable )DICTlookup( scope->symbol_table, name ); + if( result ) { + if( strict && ( DICT_type != OBJ_VARIABLE ) ) { + fprintf( stderr, "ERROR: strict && ( DICT_type != OBJ_VARIABLE )\n" ); } return result; } - return(VARfind(scope->superscope, name, strict)); + return( VARfind( scope->superscope, name, strict ) ); } return 0; } diff --git a/src/express/scope.c b/src/express/scope.c index f9193e6c5..3d93509d7 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -43,68 +43,62 @@ #include "express/scope.h" #include "express/resolve.h" -void SCOPEinitialize(void) -{ +void SCOPEinitialize( void ) { } /** * \sa SCOPEget_entities() */ -void SCOPE_get_entities(Scope scope, Linked_List result) -{ +void SCOPE_get_entities( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_ENTITY); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_ENTITY ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPEget_functions() */ -void SCOPE_get_functions(Scope scope, Linked_List result) -{ +void SCOPE_get_functions( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_FUNCTION); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_FUNCTION ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPE_get_functions() */ -Linked_List SCOPEget_functions(Scope scope) -{ +Linked_List SCOPEget_functions( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_functions(scope, result); - return(result); + SCOPE_get_functions( scope, result ); + return( result ); } /** * \sa SCOPEget_rules() */ -void SCOPE_get_rules(Scope scope, Linked_List result) -{ +void SCOPE_get_rules( Scope scope, Linked_List result ) { DictionaryEntry de; void *x; - DICTdo_type_init(scope->symbol_table, &de, OBJ_RULE); - while(0 != (x = DICTdo(&de))) { - LISTadd_last(result, x); + DICTdo_type_init( scope->symbol_table, &de, OBJ_RULE ); + while( 0 != ( x = DICTdo( &de ) ) ) { + LISTadd_last( result, x ); } } /** * \sa SCOPE_get_rules() */ -Linked_List SCOPEget_rules(Scope scope) -{ +Linked_List SCOPEget_rules( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_rules(scope, result); - return(result); + SCOPE_get_rules( scope, result ); + return( result ); } @@ -118,30 +112,28 @@ Linked_List SCOPEget_rules(Scope scope) ** SCOPEget_entities_superclass_order(), and should be used whenever ** the order of the entities on the list is not important. */ -Linked_List SCOPEget_entities(Scope scope) -{ +Linked_List SCOPEget_entities( Scope scope ) { Linked_List result = LISTcreate(); - SCOPE_get_entities(scope, result); - return(result); + SCOPE_get_entities( scope, result ); + return( result ); } /** * \sa SCOPEget_entities_superclass_order() */ -void SCOPE_dfs(Dictionary symbols, Entity root, Linked_List result) -{ +void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { Entity ent; - if((ENTITYget_mark(root) != ENTITY_MARK)) { - ENTITYput_mark(root, ENTITY_MARK); - LISTdo(ENTITYget_supertypes(root), super, Entity) + if( ( ENTITYget_mark( root ) != ENTITY_MARK ) ) { + ENTITYput_mark( root, ENTITY_MARK ); + LISTdo( ENTITYget_supertypes( root ), super, Entity ) /* if super explicitly defined in scope, recurse. */ /* this chops out USEd and REFd entities */ - if((ent = (Entity)DICTlookup(symbols, ENTITYget_name(super))) != ENTITY_NULL) { - SCOPE_dfs(symbols, ent, result); + if( ( ent = ( Entity )DICTlookup( symbols, ENTITYget_name( super ) ) ) != ENTITY_NULL ) { + SCOPE_dfs( symbols, ent, result ); } LISTod - LISTadd_last(result, root); + LISTadd_last( result, root ); } } @@ -154,15 +146,14 @@ void SCOPE_dfs(Dictionary symbols, Entity root, Linked_List result) ** \note The list returned is ordered such that an entity appears before all of its subtypes. ** \sa SCOPEget_entities() */ -Linked_List SCOPEget_entities_superclass_order(Scope scope) -{ +Linked_List SCOPEget_entities_superclass_order( Scope scope ) { Linked_List result; DictionaryEntry de; result = LISTcreate(); ++ENTITY_MARK; - SCOPEdo_entities(scope, e, de) - SCOPE_dfs(scope->symbol_table, e, result); + SCOPEdo_entities( scope, e, de ) + SCOPE_dfs( scope->symbol_table, e, result ); SCOPEod; return result; } @@ -172,20 +163,19 @@ Linked_List SCOPEget_entities_superclass_order(Scope scope) * note that object found is not actually checked, only because * caller is in a better position to describe the error with context */ -void *SCOPEfind(Scope scope, char *name, int type) -{ +void *SCOPEfind( Scope scope, char * name, int type ) { extern Dictionary EXPRESSbuiltins; /* procedures/functions */ void *x; __SCOPE_search_id++; - x = SCOPE_find(scope, name, type); - if(x) { + x = SCOPE_find( scope, name, type ); + if( x ) { return x; } - if(type & (SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE)) { - x = DICTlookup(EXPRESSbuiltins, name); + if( type & ( SCOPE_FIND_FUNCTION | SCOPE_FIND_PROCEDURE ) ) { + x = DICTlookup( EXPRESSbuiltins, name ); } return x; } @@ -196,58 +186,57 @@ void *SCOPEfind(Scope scope, char *name, int type) * the supertype/subtype hierarchy * EH??? -> lookup an object when the current scope is not a schema */ -void *SCOPE_find(Scope scope, char *name, int type) -{ +void *SCOPE_find( Scope scope, char * name, int type ) { void *result; - Rename *rename; + Rename * rename; - if(scope->search_id == __SCOPE_search_id) { + if( scope->search_id == __SCOPE_search_id ) { return 0; } scope->search_id = __SCOPE_search_id; /* go up the superscopes, looking for object */ - while(1) { + while( 1 ) { /* first look up locally */ - result = DICTlookup(scope->symbol_table, name); - if(result && OBJtype_is_oneof(DICT_type, type)) { + result = DICTlookup( scope->symbol_table, name ); + if( result && OBJtype_is_oneof( DICT_type, type ) ) { return result; } - if(scope->type == OBJ_SCHEMA) { + if( scope->type == OBJ_SCHEMA ) { break; } scope = scope->superscope; } - if(type & (SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE)) { + if( type & ( SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE ) ) { /* Occurs in a fully USE'd schema? */ - LISTdo(scope->u.schema->use_schemas, schema, Schema) + LISTdo( scope->u.schema->use_schemas, schema, Schema ) /* follow chain'd USEs */ - if(schema == 0) { + if( schema == 0 ) { continue; } - result = SCOPE_find(schema, name, type); - if(result) { - return(result); + result = SCOPE_find( schema, name, type ); + if( result ) { + return( result ); } LISTod; /* Occurs in a partially USE'd schema? */ - rename = (Rename *)DICTlookup(scope->u.schema->usedict, name); - if(rename) { + rename = ( Rename * )DICTlookup( scope->u.schema->usedict, name ); + if( rename ) { DICT_type = rename->type; - return(rename->object); + return( rename->object ); } } /* Occurs in a fully REF'd schema? */ - LISTdo(scope->u.schema->ref_schemas, schema, Schema) - if(schema == 0) { + LISTdo( scope->u.schema->ref_schemas, schema, Schema ) + if( schema == 0 ) { continue; } - result = DICTlookup(schema->symbol_table, name); - if(result) { + result = DICTlookup( schema->symbol_table, name ); + if( result ) { return result; } else { continue; /* try another schema */ @@ -255,10 +244,10 @@ void *SCOPE_find(Scope scope, char *name, int type) LISTod; /* Occurs in a partially REF'd schema? */ - rename = (Rename *)DICTlookup(scope->u.schema->refdict, name); - if(rename) { + rename = ( Rename * )DICTlookup( scope->u.schema->refdict, name ); + if( rename ) { DICT_type = rename->type; - return(rename->object); + return( rename->object ); } return 0; diff --git a/src/express/stack.h b/src/express/stack.h index cb80180c9..d0d99e14f 100644 --- a/src/express/stack.h +++ b/src/express/stack.h @@ -75,4 +75,12 @@ typedef Linked_List Stack; /* function prototypes */ /***********************/ +/*******************************/ +/* inline function definitions */ +/*******************************/ + +#if supports_inline_functions || defined(STACK_C) + +#endif /* supports_inline_functions || defined(STACK_C) */ + #endif /* STACK_H */ diff --git a/src/express/stmt.c b/src/express/stmt.c index e5fd8ff5a..7f1579f25 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -45,20 +45,18 @@ Statement STATEMENT_ESCAPE = STATEMENT_NULL; Statement STATEMENT_SKIP = STATEMENT_NULL; -Statement STMTcreate(int type) -{ +Statement STMTcreate( int type ) { Statement s; s = STMT_new(); - SYMBOLset(s); + SYMBOLset( s ); s->type = type; return s; } /** Initialize the Statement module. */ -void STMTinitialize(void) -{ - STATEMENT_SKIP = STMTcreate(STMT_SKIP); - STATEMENT_ESCAPE = STMTcreate(STMT_ESCAPE); +void STMTinitialize( void ) { + STATEMENT_SKIP = STMTcreate( STMT_SKIP ); + STATEMENT_ESCAPE = STMTcreate( STMT_ESCAPE ); } /** @@ -68,10 +66,9 @@ void STMTinitialize(void) ** ** Create and return an assignment statement. */ -Statement ASSIGNcreate(Expression lhs, Expression rhs) -{ +Statement ASSIGNcreate( Expression lhs, Expression rhs ) { Statement s; - s = STMTcreate(STMT_ASSIGN); + s = STMTcreate( STMT_ASSIGN ); s->u.assign = ASSIGN_new(); s->u.assign->lhs = lhs; s->u.assign->rhs = rhs; @@ -85,15 +82,14 @@ Statement ASSIGNcreate(Expression lhs, Expression rhs) ** ** Create and return a case statement. */ -Statement CASEcreate(Expression selector, Linked_List cases) -{ +Statement CASEcreate( Expression selector, Linked_List cases ) { Statement s; - s = STMTcreate(STMT_CASE); + s = STMTcreate( STMT_CASE ); s->u.Case = CASE_new(); s->u.Case->selector = selector; s->u.Case->cases = cases; - return(s); + return( s ); } /** @@ -102,10 +98,9 @@ Statement CASEcreate(Expression selector, Linked_List cases) ** ** Create and return a compound statement. */ -Statement COMP_STMTcreate(Linked_List statements) -{ +Statement COMP_STMTcreate( Linked_List statements ) { Statement s; - s = STMTcreate(STMT_COMPOUND); + s = STMTcreate( STMT_COMPOUND ); s->u.compound = COMP_STMT_new(); s->u.compound->statements = statements; return s; @@ -119,15 +114,14 @@ Statement COMP_STMTcreate(Linked_List statements) ** ** Create and return an if statement. */ -Statement CONDcreate(Expression test, Linked_List then, Linked_List otherwise) -{ +Statement CONDcreate( Expression test, Linked_List then, Linked_List otherwise ) { Statement s; - s = STMTcreate(STMT_COND); + s = STMTcreate( STMT_COND ); s->u.cond = COND_new(); s->u.cond->test = test; s->u.cond->code = then; s->u.cond->otherwise = otherwise; - return(s); + return( s ); } /** @@ -136,10 +130,9 @@ Statement CONDcreate(Expression test, Linked_List then, Linked_List otherwise) ** ** Create and return a procedure call statement. */ -Statement PCALLcreate(Linked_List parameters) -{ +Statement PCALLcreate( Linked_List parameters ) { Statement s; - s = STMTcreate(STMT_PCALL); + s = STMTcreate( STMT_PCALL ); s->u.proc = PCALL_new(); s->u.proc->parameters = parameters; return s; @@ -150,25 +143,23 @@ Statement PCALLcreate(Linked_List parameters) ** ** Create and return a loop statement. */ -Statement LOOPcreate(Scope scope, Expression while_expr, Expression until_expr, Linked_List statements) -{ - Statement s = STMTcreate(STMT_LOOP); +Statement LOOPcreate( Scope scope, Expression while_expr, Expression until_expr, Linked_List statements ) { + Statement s = STMTcreate( STMT_LOOP ); s->u.loop = LOOP_new(); s->u.loop->scope = scope; s->u.loop->while_expr = while_expr; s->u.loop->until_expr = until_expr; s->u.loop->statements = statements; - return(s); + return( s ); } -Statement ALIAScreate(Scope scope, Variable variable, Linked_List statements) -{ - Statement s = STMTcreate(STMT_ALIAS); +Statement ALIAScreate( Scope scope, Variable variable, Linked_List statements ) { + Statement s = STMTcreate( STMT_ALIAS ); s->u.alias = ALIAS_new(); s->u.alias->scope = scope; s->u.alias->variable = variable; s->u.alias->statements = statements; - return(s); + return( s ); } /** @@ -180,14 +171,13 @@ Statement ALIAScreate(Scope scope, Variable variable, Linked_List statements) ** ** Create and return an increment control as specified. */ -Scope INCR_CTLcreate(Symbol *control, Expression start, - Expression end, Expression increment) -{ - Scope s = SCOPEcreate_tiny(OBJ_INCREMENT); - Expression e = EXPcreate_from_symbol(Type_Attribute, control); - Variable v = VARcreate(e, Type_Number); - DICTdefine(s->symbol_table, control->name, - v, control, OBJ_VARIABLE); +Scope INCR_CTLcreate( Symbol * control, Expression start, + Expression end, Expression increment ) { + Scope s = SCOPEcreate_tiny( OBJ_INCREMENT ); + Expression e = EXPcreate_from_symbol( Type_Attribute, control ); + Variable v = VARcreate( e, Type_Number ); + DICTdefine( s->symbol_table, control->name, + v, control, OBJ_VARIABLE ); s->u.incr = INCR_new(); s->u.incr->init = start; s->u.incr->end = end; @@ -200,9 +190,8 @@ Scope INCR_CTLcreate(Symbol *control, Expression start, ** \return the return statement created Create and return a return statement. */ -Statement RETcreate(Expression expression) -{ - Statement s = STMTcreate(STMT_RETURN); +Statement RETcreate( Expression expression ) { + Statement s = STMTcreate( STMT_RETURN ); s->u.ret = RET_new(); s->u.ret->value = expression; return s; diff --git a/src/express/symbol.c b/src/express/symbol.c index 2985cdcbe..ed71fb836 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -35,6 +35,5 @@ #include "express/symbol.h" /** Initialize the Symbol module */ -void SYMBOLinitialize(void) -{ +void SYMBOLinitialize( void ) { } diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 1c4fd7e90..6d2615a9b 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -4,17 +4,35 @@ if(SC_GENERATE_LP_SOURCES) include_directories("${PERPLEX_ExpScanner_INCLUDE_DIR}" "${LEMON_ExpParser_INCLUDE_DIR}") endif(SC_GENERATE_LP_SOURCES) -add_executable(test_expr driver.c test_expr.c) -target_link_libraries(test_expr express) +set(EXPRESS_CORE_OBJ + # base + $ + $ + $ + $ + + # global tables + $ + $ + + # AST creation + $ + $ + $ + + # deprecated + $ + $ +) + +add_executable(test_expr driver.c test_expr.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME exp_resolve_select_enum_member COMMAND test_expr resolve_select_enum_member) add_test(NAME exp_resolve_entity_attribute COMMAND test_expr resolve_entity_attribute) -add_executable(test_express driver.c test_express.c) -target_link_libraries(test_express express) +add_executable(test_express driver.c test_express.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME express_rename_resolve COMMAND test_express express_rename_resolve) -add_executable(test_resolve driver.c test_resolve.c) -target_link_libraries(test_resolve express) +add_executable(test_resolve driver.c test_resolve.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME exp_resolve_bad_func_call COMMAND test_resolve exp_resolve_bad_func_call) add_test(NAME exp_resolve_func_call COMMAND test_resolve exp_resolve_func_call) @@ -25,24 +43,20 @@ add_test(NAME stmt_resolve_pcall_proc COMMAND test_resolve stmt_resolve_pcall_pr add_test(NAME scope_resolve_named_types COMMAND test_resolve scope_resolve_named_types) add_test(NAME entity_resolve_supertypes_entity COMMAND test_resolve entity_resolve_supertypes_entity) -add_executable(test_resolve2 driver.c test_resolve2.c) -target_link_libraries(test_resolve2 express) +add_executable(test_resolve2 driver.c test_resolve2.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME scope_resolve_expr_stmt COMMAND test_resolve2 scope_resolve_expr_stmt) add_test(NAME scope_resolve_subsupers COMMAND test_resolve2 scope_resolve_subsupers) -add_executable(test_schema driver.c test_schema.c) -target_link_libraries(test_schema express) +add_executable(test_schema driver.c test_schema.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME schema_define_ref COMMAND test_schema schema_define_ref) add_test(NAME schema_define_use COMMAND test_schema schema_define_use) add_test(NAME schema_get_entities_ref COMMAND test_schema schema_get_entities_ref) add_test(NAME var_find COMMAND test_schema var_find) -add_executable(test_scope driver.c test_scope.c) -target_link_libraries(test_scope express) +add_executable(test_scope driver.c test_scope.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME scope_find COMMAND test_scope scope_find) -add_executable(test_type driver.c test_type.c) -target_link_libraries(test_type express) +add_executable(test_type driver.c test_type.c $ ${EXPRESS_CORE_OBJ}) add_test(NAME type_create_user_defined_tag COMMAND test_type type_create_user_defined_tag) add_test(NAME build_check_express diff --git a/src/express/test/driver.c b/src/express/test/driver.c index f53dbaf5c..d3e5f4dc5 100644 --- a/src/express/test/driver.c +++ b/src/express/test/driver.c @@ -8,40 +8,38 @@ extern struct test_def tests[]; -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { int status; - + /* enable libexpress allocator */ MEMORYinitialize(); FACTORYinitialize(); - + argc--; status = 0; - if(argc) { + if (argc) { int test_counter = argc; - + /* selected tests */ - for(int i = 1; i <= argc; i++) { - for(unsigned int j = 0; tests[j].name != NULL; j++) { + for (int i=1; i <= argc; i++) { + for (unsigned int j=0; tests[j].name != NULL; j++) { const char *test_name = tests[j].name; - int (*test_ptr)(void) = tests[j].testfunc; - - if(!strcmp(argv[i], test_name)) { + int (*test_ptr) (void) = tests[j].testfunc; + + if (!strcmp(argv[i], test_name)) { test_counter--; setup(); status |= test_ptr(); } } } - - if(test_counter) { + + if (test_counter) fprintf(stderr, "WARNING: some tests not found...\n"); - } } else { /* all tests */ - for(unsigned int j = 0; tests[j].name != NULL; j++) { - int (*test_ptr)(void) = tests[j].testfunc; + for (unsigned int j=0; tests[j].name != NULL; j++) { + int (*test_ptr) (void) = tests[j].testfunc; setup(); status |= test_ptr(); } diff --git a/src/express/test/driver.h b/src/express/test/driver.h index ba9acde42..0df5707cd 100644 --- a/src/express/test/driver.h +++ b/src/express/test/driver.h @@ -3,7 +3,7 @@ struct test_def { const char *name; - int (*testfunc)(void); + int (*testfunc) (void); }; void setup(); diff --git a/src/express/test/fff.h b/src/express/test/fff.h index 4f7135976..ecd19da4f 100644 --- a/src/express/test/fff.h +++ b/src/express/test/fff.h @@ -34,10 +34,10 @@ SOFTWARE. #define FFF_MAX_ARGS (20u) #ifndef FFF_ARG_HISTORY_LEN -#define FFF_ARG_HISTORY_LEN (50u) + #define FFF_ARG_HISTORY_LEN (50u) #endif #ifndef FFF_CALL_HISTORY_LEN -#define FFF_CALL_HISTORY_LEN (50u) + #define FFF_CALL_HISTORY_LEN (50u) #endif /* -- INTERNAL HELPER MACROS -- */ #define SET_RETURN_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ @@ -107,11 +107,11 @@ SOFTWARE. return FUNCNAME##_fake.return_val; \ #ifdef __cplusplus -#define FFF_EXTERN_C extern "C"{ -#define FFF_END_EXTERN_C } + #define FFF_EXTERN_C extern "C"{ + #define FFF_END_EXTERN_C } #else /* ansi c */ -#define FFF_EXTERN_C -#define FFF_END_EXTERN_C + #define FFF_EXTERN_C + #define FFF_END_EXTERN_C #endif /* cpp/ansi c */ #define DEFINE_RESET_FUNCTION(FUNCNAME) \ @@ -122,7 +122,7 @@ SOFTWARE. /* -- END INTERNAL HELPER MACROS -- */ typedef void (*fff_function_t)(void); -typedef struct { +typedef struct { fff_function_t call_history[FFF_CALL_HISTORY_LEN]; unsigned int call_history_idx; } fff_globals_t; @@ -182,7 +182,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC0(FUNCNAME) \ DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ DEFINE_FAKE_VOID_FUNC0(FUNCNAME) \ - + #define DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -227,7 +227,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -275,7 +275,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -326,7 +326,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -380,7 +380,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -437,7 +437,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -497,7 +497,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -560,7 +560,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -626,7 +626,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -695,7 +695,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -767,7 +767,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VOID_FUNC10(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -842,7 +842,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VOID_FUNC11(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -920,7 +920,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VOID_FUNC12(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -1001,7 +1001,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VOID_FUNC13(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -1085,7 +1085,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VOID_FUNC14(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -1172,7 +1172,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VOID_FUNC15(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -1262,7 +1262,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VOID_FUNC16(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -1355,7 +1355,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VOID_FUNC17(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -1451,7 +1451,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VOID_FUNC18(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -1550,7 +1550,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VOID_FUNC19(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -1652,7 +1652,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VOID_FUNC20(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ FFF_EXTERN_C \ @@ -1702,7 +1702,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DECLARE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ DEFINE_FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ - + #define DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ FFF_EXTERN_C \ @@ -1755,7 +1755,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DECLARE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ FFF_EXTERN_C \ @@ -1811,7 +1811,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DECLARE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ DEFINE_FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ FFF_EXTERN_C \ @@ -1870,7 +1870,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DECLARE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ DEFINE_FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ FFF_EXTERN_C \ @@ -1932,7 +1932,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DECLARE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ DEFINE_FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ FFF_EXTERN_C \ @@ -1997,7 +1997,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DECLARE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ DEFINE_FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ FFF_EXTERN_C \ @@ -2065,7 +2065,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DECLARE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ DEFINE_FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ FFF_EXTERN_C \ @@ -2136,7 +2136,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DECLARE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ DEFINE_FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ FFF_EXTERN_C \ @@ -2210,7 +2210,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DECLARE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ DEFINE_FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ FFF_EXTERN_C \ @@ -2287,7 +2287,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DECLARE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ DEFINE_FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ FFF_EXTERN_C \ @@ -2367,7 +2367,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DECLARE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ DEFINE_FAKE_VALUE_FUNC10(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ FFF_EXTERN_C \ @@ -2450,7 +2450,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DECLARE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ DEFINE_FAKE_VALUE_FUNC11(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ FFF_EXTERN_C \ @@ -2536,7 +2536,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DECLARE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ DEFINE_FAKE_VALUE_FUNC12(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ FFF_EXTERN_C \ @@ -2625,7 +2625,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DECLARE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ DEFINE_FAKE_VALUE_FUNC13(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ FFF_EXTERN_C \ @@ -2717,7 +2717,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DECLARE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ DEFINE_FAKE_VALUE_FUNC14(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ FFF_EXTERN_C \ @@ -2812,7 +2812,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DECLARE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ DEFINE_FAKE_VALUE_FUNC15(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ FFF_EXTERN_C \ @@ -2910,7 +2910,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DECLARE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ DEFINE_FAKE_VALUE_FUNC16(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ FFF_EXTERN_C \ @@ -3011,7 +3011,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DECLARE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ DEFINE_FAKE_VALUE_FUNC17(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ FFF_EXTERN_C \ @@ -3115,7 +3115,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DECLARE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ DEFINE_FAKE_VALUE_FUNC18(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ FFF_EXTERN_C \ @@ -3222,7 +3222,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DECLARE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ DEFINE_FAKE_VALUE_FUNC19(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE) \ - + #define DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ FFF_EXTERN_C \ @@ -3332,7 +3332,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DECLARE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ DEFINE_FAKE_VALUE_FUNC20(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ARG19_TYPE) \ - + #define DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -3374,7 +3374,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC2_VARARG(FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -3419,7 +3419,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -3467,7 +3467,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC4_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -3518,7 +3518,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC5_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -3572,7 +3572,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC6_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -3629,7 +3629,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC7_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -3689,7 +3689,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC8_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -3752,7 +3752,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC9_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -3818,7 +3818,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC10_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -3887,7 +3887,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC11_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -3959,7 +3959,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC12_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -4034,7 +4034,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC13_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -4112,7 +4112,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC14_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -4193,7 +4193,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC15_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -4277,7 +4277,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC16_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -4364,7 +4364,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC17_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -4454,7 +4454,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC18_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -4547,7 +4547,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC19_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -4643,7 +4643,7 @@ FFF_END_EXTERN_C \ #define FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VOID_FUNC20_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ FFF_EXTERN_C \ @@ -4691,7 +4691,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC2_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ FFF_EXTERN_C \ @@ -4742,7 +4742,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC3_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ FFF_EXTERN_C \ @@ -4796,7 +4796,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC4_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ FFF_EXTERN_C \ @@ -4853,7 +4853,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC5_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ FFF_EXTERN_C \ @@ -4913,7 +4913,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC6_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ FFF_EXTERN_C \ @@ -4976,7 +4976,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC7_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ FFF_EXTERN_C \ @@ -5042,7 +5042,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC8_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ FFF_EXTERN_C \ @@ -5111,7 +5111,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC9_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ FFF_EXTERN_C \ @@ -5183,7 +5183,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC10_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ FFF_EXTERN_C \ @@ -5258,7 +5258,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC11_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ FFF_EXTERN_C \ @@ -5336,7 +5336,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC12_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ FFF_EXTERN_C \ @@ -5417,7 +5417,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC13_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ FFF_EXTERN_C \ @@ -5501,7 +5501,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC14_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ FFF_EXTERN_C \ @@ -5588,7 +5588,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC15_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ FFF_EXTERN_C \ @@ -5678,7 +5678,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC16_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ FFF_EXTERN_C \ @@ -5771,7 +5771,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC17_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ FFF_EXTERN_C \ @@ -5867,7 +5867,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC18_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ FFF_EXTERN_C \ @@ -5966,7 +5966,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC19_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ...) \ - + #define DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ FFF_EXTERN_C \ @@ -6068,7 +6068,7 @@ FFF_END_EXTERN_C \ #define FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DECLARE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ DEFINE_FAKE_VALUE_FUNC20_VARARG(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE, ARG9_TYPE, ARG10_TYPE, ARG11_TYPE, ARG12_TYPE, ARG13_TYPE, ARG14_TYPE, ARG15_TYPE, ARG16_TYPE, ARG17_TYPE, ARG18_TYPE, ...) \ - + /* MSVC expand macro fix */ #define EXPAND(x) x diff --git a/src/express/test/print_attrs.c b/src/express/test/print_attrs.c index 99384de8e..881ada059 100644 --- a/src/express/test/print_attrs.c +++ b/src/express/test/print_attrs.c @@ -23,31 +23,29 @@ #include "ordered_attrs.h" #include -char *entityName, _buf[512] = { 0 }; +char * entityName, _buf[512] = { 0 }; /** prints usage info specific to print_attrs */ -void my_usage(void) -{ - EXPRESSusage(0); - printf(" ----\n\t-a : print attrs for \n"); - exit(2); +void my_usage(void) { + EXPRESSusage( 0 ); + printf( " ----\n\t-a : print attrs for \n" ); + exit( 2 ); } /** prints info about one attr */ -void describeAttr(const orderedAttr *oa) -{ - const char *visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; - const char *visibility, * descrip1 = "", * descrip2 = "", * descrip3 = 0; - if(oa->deriver) { - assert(0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute"); +void describeAttr( const orderedAttr * oa ) { + const char * visible_p21 = " Y ", * hidden_p21 = " N ", * explicit_derived = " * "; + const char * visibility, * descrip1="", * descrip2="", * descrip3=0; + if( oa->deriver ) { + assert( 0 == oa->attr->inverse_attribute && "Can't be derived *and* an inverse attribute" ); descrip1 = "derived in "; descrip2 = oa->deriver->symbol.name; - if(oa->deriver == oa->creator) { + if( oa->deriver == oa->creator ) { visibility = hidden_p21; } else { visibility = explicit_derived; } - } else if(oa->attr->inverse_attribute) { + } else if( oa->attr->inverse_attribute ) { visibility = hidden_p21; descrip1 = "inverse of "; descrip2 = oa->attr->inverse_attribute->name->symbol.name; @@ -56,56 +54,53 @@ void describeAttr(const orderedAttr *oa) visibility = visible_p21; } printf("%s|%22s |%22s | %s%s%s%s\n", visibility, oa->attr->name->symbol.name, - oa->creator->symbol.name, descrip1, descrip2, ((descrip3) ? " in " : ""), ((descrip3) ? descrip3 : "")); + oa->creator->symbol.name, descrip1, descrip2, ( ( descrip3 ) ? " in " : "" ), ( ( descrip3 ) ? descrip3 : "" ) ); } -void print_attrs(Entity ent) -{ - const orderedAttr *oa; - const char *dashes = "--------------------------------------------------------------------------"; - printf("Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, - " In P21? | attr name | creator | detail", dashes); - orderedAttrsInit(ent); - while(0 != (oa = nextAttr())) { - describeAttr(oa); +void print_attrs( Entity ent ) { + const orderedAttr * oa; + const char * dashes="--------------------------------------------------------------------------"; + printf( "Entity %s\n%s\n%s\n%s\n", ent->symbol.name, dashes, + " In P21? | attr name | creator | detail", dashes ); + orderedAttrsInit( ent ); + while( 0 != ( oa = nextAttr() ) ) { + describeAttr( oa ); } orderedAttrsCleanup(); } -void find_and_print(Express model) -{ +void find_and_print( Express model ) { DictionaryEntry de; Schema s; Entity e; - DICTdo_init(model->symbol_table, &de); - while(0 != (s = (Schema) DICTdo(&de))) { - printf("Schema %s\n", s->symbol.name); - e = (Entity) DICTlookup(s->symbol_table, entityName); - if(e) { - print_attrs(e); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { + printf( "Schema %s\n", s->symbol.name ); + e = (Entity) DICTlookup( s->symbol_table, entityName ); + if( e ) { + print_attrs( e ); } } } /** reads arg setting entity name */ -int attr_arg(int i, char *arg) -{ - const char *src = arg; +int attr_arg( int i, char * arg ) { + const char * src = arg; int count = 0; - if((char)i == 'a') { + if( ( char )i == 'a' ) { entityName = _buf; - while(*src) { - _buf[count] = tolower(*src); + while( *src ) { + _buf[count] = tolower( *src ); src++; count++; - if(count == 511) { + if( count == 511 ) { break; } } - if(count == 0) { + if( count == 0 ) { entityName = 0; } - } else if(!entityName) { + } else if( !entityName ) { /* if libexpress comes across an unrecognized arg that isn't '-a', * and if the entityName isn't set, print usage and exit */ @@ -115,11 +110,10 @@ int attr_arg(int i, char *arg) } /** set the functions to be called by main() in libexpress */ -void EXPRESSinit_init() -{ +void EXPRESSinit_init() { entityName = 0; EXPRESSbackend = find_and_print; ERRORusage_function = my_usage; - strcat(EXPRESSgetopt_options, "a:"); + strcat( EXPRESSgetopt_options, "a:" ); EXPRESSgetopt = attr_arg; } diff --git a/src/express/test/print_schemas.c b/src/express/test/print_schemas.c index 3d3db9c1b..40bb0a1e0 100644 --- a/src/express/test/print_schemas.c +++ b/src/express/test/print_schemas.c @@ -15,23 +15,21 @@ #include "express/express.h" void -print_schemas(Express model) -{ +print_schemas( Express model ) { DictionaryEntry de; Schema s; - printf("File: %s\n ", model->u.express->filename); + printf( "File: %s\n ", model->u.express->filename ); - DICTdo_init(model->symbol_table, &de); - while(0 != (s = (Schema) DICTdo(&de))) { - printf("%s", s->symbol.name); + DICTdo_init( model->symbol_table, &de ); + while( 0 != ( s = (Schema) DICTdo( &de ) ) ) { + printf( "%s", s->symbol.name ); } - printf("\n"); - exit(0); + printf( "\n" ); + exit( 0 ); } -void EXPRESSinit_init() -{ +void EXPRESSinit_init() { EXPRESSbackend = print_schemas; } diff --git a/src/express/test/test_expr.c b/src/express/test/test_expr.c index 8de1be0ab..72c4d3e14 100644 --- a/src/express/test/test_expr.c +++ b/src/express/test/test_expr.c @@ -17,7 +17,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -37,10 +37,9 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(struct Scope_ *, ENTITYfind_inherited_entity, struct Scope_ *, char *, int) FAKE_VOID_FUNC(EXP_resolve, Expression, Scope, Type) -void setup() -{ +void setup() { EXPinitialize(); - + RESET_FAKE(EXPRESS_fail); RESET_FAKE(ENTITYfind_inherited_attribute); RESET_FAKE(ENTITYresolve_attr_ref); @@ -49,17 +48,15 @@ void setup() } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) -{ +void EXP_resolve_type_handler(Expression exp, Scope cxt, Type typ) { (void) typ; - Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); + Type res_typ = DICTlookup(cxt->symbol_table, exp->symbol.name); exp->type = res_typ; exp->return_type = res_typ; exp->symbol.resolved = RESOLVED; } -int test_resolve_select_enum_member() -{ +int test_resolve_select_enum_member() { Schema scope; Symbol *e_type_id, *enum_id, *s_type_id; Type enum_typ, select_typ, chk_typ; @@ -74,56 +71,55 @@ int test_resolve_select_enum_member() s_type_id = SYMBOLcreate("sel1", 1, "test1"); e_type_id = SYMBOLcreate("enum1", 1, "test1"); enum_id = SYMBOLcreate("val1", 1, "test1"); - + enum_typ = TYPEcreate_name(e_type_id); enum_typ->symbol_table = DICTcreate(50); - + exp_enum_id = EXPcreate(enum_typ); exp_enum_id->symbol = *enum_id; exp_enum_id->u.integer = 1; - + tb = TYPEBODYcreate(enumeration_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_id); enum_typ->u.type->body = tb; - + DICT_define(scope->symbol_table, e_type_id->name, enum_typ, &enum_typ->symbol, OBJ_TYPE); - + /* TODO: OBJ_ENUM / OBJ_EXPRESSION are used interchangeably, this is confusing. */ DICT_define(scope->enum_table, exp_enum_id->symbol.name, exp_enum_id, &exp_enum_id->symbol, OBJ_EXPRESSION); DICT_define(enum_typ->symbol_table, enum_id->name, exp_enum_id, enum_id, OBJ_EXPRESSION); - + select_typ = TYPEcreate_name(s_type_id); tb = TYPEBODYcreate(select_); tb->list = LISTcreate(); LISTadd_last(tb->list, enum_typ); select_typ->u.type->body = tb; DICT_define(scope->symbol_table, s_type_id->name, select_typ, &select_typ->symbol, OBJ_TYPE); - + op1 = EXPcreate_from_symbol(Type_Identifier, s_type_id); op2 = EXPcreate_from_symbol(Type_Identifier, enum_id); - expr = BIN_EXPcreate(OP_DOT, op1, op2); + expr = BIN_EXPcreate(OP_DOT, op1, op2); /* * test: sel_ref '.' enum_id * expectation: enum_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_type_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == select_typ); assert(chk_typ == enum_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } /* TODO: remove DICTlookup after eliminating DICT_type */ -void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) -{ +void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) { (void) unused; Entity ent = DICTlookup(cxt->symbol_table, exp->symbol.name); Type typ = ent->u.entity->type; @@ -132,15 +128,13 @@ void EXP_resolve_entity_handler(Expression exp, Scope cxt, Type unused) exp->symbol.resolved = RESOLVED; } -Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) -{ +Variable ENTITY_resolve_attr_handler(Entity ent, Symbol *grp_ref, Symbol *attr_ref) { (void) grp_ref; Variable v = DICTlookup(ent->symbol_table, attr_ref->name); - return v; + return v; } -int test_resolve_entity_attribute() -{ +int test_resolve_entity_attribute() { Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -160,7 +154,7 @@ int test_resolve_entity_attribute() DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -168,29 +162,29 @@ int test_resolve_entity_attribute() var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); op1 = EXPcreate_from_symbol(Type_Identifier, e_type_id); op2 = EXPcreate_from_symbol(Type_Attribute, attr_id); expr = BIN_EXPcreate(OP_DOT, op1, op2); - + /* * test: entity_ref '.' attribute_id * expectation: attr_typ */ EXP_resolve_fake.custom_fake = EXP_resolve_entity_handler; ENTITYresolve_attr_ref_fake.custom_fake = ENTITY_resolve_attr_handler; - + chk_typ = EXPresolve_op_dot(expr, scope); assert(EXP_resolve_fake.call_count == 1); assert(expr->e.op1->type == ent->u.entity->type); assert(chk_typ == attr_typ); - + /* in case of error SIGABRT will be raised (and non-zero returned) */ - + return 0; } diff --git a/src/express/test/test_express.c b/src/express/test/test_express.c index ff51ec334..8ce3eb5e1 100644 --- a/src/express/test/test_express.c +++ b/src/express/test/test_express.c @@ -34,8 +34,8 @@ int yyerrstatus; /* * mock functions */ -typedef void *(*malloc_func_t)(size_t); -typedef void (*free_func_t)(void *); +typedef void * (*malloc_func_t) (size_t); +typedef void (*free_func_t) (void *); DEFINE_FFF_GLOBALS @@ -71,8 +71,7 @@ FAKE_VALUE_FUNC(char *, SCANstrdup, const char *) FAKE_VALUE_FUNC(perplex_t, perplexFileScanner, FILE *) FAKE_VALUE_FUNC(int, yylex, perplex_t) -void setup() -{ +void setup() { RESET_FAKE(RESOLVEinitialize); RESET_FAKE(SYMBOLinitialize); RESET_FAKE(SCOPEinitialize); @@ -105,8 +104,7 @@ void setup() RESET_FAKE(yylex); } -int test_express_rename_resolve() -{ +int test_express_rename_resolve() { Schema cur_schema, ref_schema; Rename *use_ref; Entity ent; @@ -116,17 +114,17 @@ int test_express_rename_resolve() ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->uselist = LISTcreate(); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + /* TODO: create RENcreate(...), refactor SCHEMAadd_use() */ use_ref = REN_new(); use_ref->schema_sym = ref_schema_id; @@ -135,9 +133,9 @@ int test_express_rename_resolve() use_ref->rename_type = use; LISTadd_last(cur_schema->u.schema->uselist, use_ref); use_ref->schema = ref_schema; - + RENAMEresolve(use_ref, cur_schema); - + assert(use_ref->type == OBJ_ENTITY); return 0; } diff --git a/src/express/test/test_resolve.c b/src/express/test/test_resolve.c index 9c974029c..2fc30ac68 100644 --- a/src/express/test/test_resolve.c +++ b/src/express/test/test_resolve.c @@ -19,12 +19,12 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; int EXPRESSpass; -struct Scope_ *FUNC_NVL; -struct Scope_ *FUNC_USEDIN; +struct Scope_ * FUNC_NVL; +struct Scope_ * FUNC_USEDIN; struct EXPop_entry EXPop_table[OP_LAST]; @@ -45,10 +45,9 @@ FAKE_VALUE_FUNC(Variable, ENTITYresolve_attr_ref, Entity, Symbol *, Symbol *) FAKE_VALUE_FUNC(int, ENTITYdeclares_variable, Entity, Variable) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESOLVEinitialize(); - + RESET_FAKE(SCOPEfind); RESET_FAKE(VARfind); RESET_FAKE(VARget_simple_name); @@ -59,74 +58,69 @@ void setup() RESET_FAKE(EXPRESS_fail); } -void *SCOPEfind_handler(Scope scope, char *name, int type) -{ +void * SCOPEfind_handler(Scope scope, char * name, int type) { (void) type; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_bad_func_call() -{ +int test_exp_resolve_bad_func_call() { Schema scope; Symbol *func_id; Expression func_call; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - - SCOPEfind_fake.custom_fake = SCOPEfind_handler; + + SCOPEfind_fake.custom_fake = SCOPEfind_handler; EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved != RESOLVED); - + return 0; } -int test_exp_resolve_func_call() -{ +int test_exp_resolve_func_call() { Schema scope; Symbol *func_id; Expression func_call; Function func_def; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test1"); func_call = EXPcreate_from_symbol(Type_Funcall, func_id); - + func_def = TYPEcreate_nostab(func_id, scope, OBJ_FUNCTION); - SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; + EXP_resolve(func_call, scope, Type_Dont_Care); - + assert(func_call->symbol.resolved == RESOLVED); assert(func_call->u.funcall.function == func_def); - + return 0; } -Variable VARfind_handler(Scope scope, char *name, int strict) -{ +Variable VARfind_handler(Scope scope, char *name, int strict) { (void) strict; return DICTlookup(scope->symbol_table, name); } -int test_exp_resolve_local_identifier() -{ +int test_exp_resolve_local_identifier() { Schema scope; Entity ent; Expression ent_attr, ent_attr_ref; Symbol *attr_id, *attr_ref, *ent_id; Variable v_attr; Type attr_typ; - + scope = SCHEMAcreate(); - + ent_id = SYMBOLcreate("entity1", 1, "test_2"); - ent = ENTITYcreate(ent_id); + ent = ENTITYcreate(ent_id); DICT_define(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test_2"); @@ -135,35 +129,34 @@ int test_exp_resolve_local_identifier() v_attr = VARcreate(ent_attr, attr_typ); v_attr->flags.attribute = true; DICT_define(ent->symbol_table, attr_id->name, v_attr, attr_id, OBJ_VARIABLE); - + attr_ref = SYMBOLcreate("attr1", 1, "test_2"); ent_attr_ref = EXPcreate_from_symbol(Type_Identifier, attr_ref); - + VARfind_fake.custom_fake = VARfind_handler; - + EXP_resolve(ent_attr_ref, ent, Type_Dont_Care); - + assert(ent_attr_ref->u.variable == v_attr); assert(ent_attr_ref->symbol.resolved == RESOLVED); - + return 0; } -int test_entity_resolve_subtype_expr_entity() -{ +int test_entity_resolve_subtype_expr_entity() { Schema scope; Entity ent1, ent2; Expression subtype_exp; Symbol *ent1_id, *ent2_id, *ent2_ref; int chk; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); ent2_ref = SYMBOLcreate("ent2", 1, "test_3"); ent1 = ENTITYcreate(ent1_id); ent2 = ENTITYcreate(ent2_id); - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); @@ -171,26 +164,25 @@ int test_entity_resolve_subtype_expr_entity() ent1->superscope = scope; ent1->u.entity->subtypes = LISTcreate(); ent1->u.entity->subtype_expression = subtype_exp; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; chk = ENTITYresolve_subtype_expression(subtype_exp, ent1, &ent1->u.entity->subtypes); - + assert(chk == RESOLVED); - + return 0; } -int test_type_resolve_entity() -{ +int test_type_resolve_entity() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -200,62 +192,60 @@ int test_type_resolve_entity() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; TYPE_resolve(&sel); - + assert(sel->symbol.resolved == RESOLVED); - + return 0; } -int test_stmt_resolve_pcall_proc() -{ +int test_stmt_resolve_pcall_proc() { Schema scope; Function f; Procedure p; Statement s; Symbol *func_id, *proc_id, *proc_ref; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); proc_id = SYMBOLcreate("proc1", 1, "test_5"); proc_ref = SYMBOLcreate("proc1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + p = ALGcreate(OBJ_PROCEDURE); DICTdefine(f->symbol_table, proc_id->name, p, proc_id, OBJ_PROCEDURE); - + s = PCALLcreate(NULL); s->symbol = *proc_ref; - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + STMTresolve(s, f); - + assert(s->u.proc->procedure == p); - + return 0; } -int test_scope_resolve_named_types() -{ +int test_scope_resolve_named_types() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); ent_id = SYMBOLcreate("ent", 1, "test_4"); - + ent_base = TYPEcreate(entity_); ent_base->symbol = *ent_id; ent_base->superscope = scope; @@ -266,27 +256,26 @@ int test_scope_resolve_named_types() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + SCOPEresolve_types(scope); - + assert(!(ent->symbol.resolved & RESOLVE_FAILED)); assert(!(sel->symbol.resolved & RESOLVE_FAILED)); assert(!(scope->symbol.resolved & RESOLVE_FAILED)); - + return 0; } -int test_entity_resolve_supertypes() -{ +int test_entity_resolve_supertypes() { Schema scope; Entity ent1, ent2; Symbol *ent1_id, *ent2_id, *ent1_ref; - + scope = SCHEMAcreate(); ent1_id = SYMBOLcreate("ent1", 1, "test_3"); ent2_id = SYMBOLcreate("ent2", 1, "test_3"); @@ -295,19 +284,19 @@ int test_entity_resolve_supertypes() ent2 = ENTITYcreate(ent2_id); ent1->superscope = scope; ent2->superscope = scope; - + DICTdefine(scope->symbol_table, ent1_id->name, ent1, ent1_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, ent2_id->name, ent2, ent2_id, OBJ_ENTITY); - + ent2->u.entity->supertype_symbols = LISTcreate(); LISTadd_last(ent2->u.entity->supertype_symbols, ent1_ref); - + SCOPEfind_fake.custom_fake = SCOPEfind_handler; - + ENTITYresolve_supertypes(ent2); assert(!(ent2->symbol.resolved & RESOLVE_FAILED)); - + return 0; } diff --git a/src/express/test/test_resolve2.c b/src/express/test/test_resolve2.c index 6fe469217..a293dce69 100644 --- a/src/express/test/test_resolve2.c +++ b/src/express/test/test_resolve2.c @@ -17,7 +17,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int EXPRESSpass; int yylineno; int print_objects_while_running; @@ -39,8 +39,7 @@ FAKE_VOID_FUNC(ENTITYresolve_expressions, Entity) FAKE_VALUE_FUNC(int, WHEREresolve, Linked_List, Scope, int) FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(ENTITYresolve_supertypes); RESET_FAKE(ENTITYresolve_subtypes); RESET_FAKE(TYPE_resolve); @@ -52,17 +51,16 @@ void setup() RESET_FAKE(EXPRESS_fail); } -int test_scope_resolve_expr_stmt() -{ +int test_scope_resolve_expr_stmt() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -72,29 +70,28 @@ int test_scope_resolve_expr_stmt() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_expressions_statements(scope); - + assert(ENTITYresolve_expressions_fake.call_count == 1); assert(TYPEresolve_expressions_fake.call_count == 1); - + return 0; } -int test_scope_resolve_subsupers() -{ +int test_scope_resolve_subsupers() { Schema scope; Type sel, ent_base; Entity ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -104,16 +101,16 @@ int test_scope_resolve_subsupers() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); SCOPEresolve_subsupers(scope); - + assert(TYPE_resolve_fake.call_count == 1); assert(ENTITYresolve_supertypes_fake.call_count == 1); assert(ENTITYresolve_subtypes_fake.call_count == 1); - + return 0; } diff --git a/src/express/test/test_schema.c b/src/express/test/test_schema.c index 106e9cca5..80fe0eadc 100644 --- a/src/express/test/test_schema.c +++ b/src/express/test/test_schema.c @@ -17,7 +17,7 @@ /* * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int ENTITY_MARK; @@ -33,15 +33,13 @@ FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) FAKE_VOID_FUNC(SCOPE_get_entities, Scope, Linked_List) FAKE_VALUE_FUNC(Variable, ENTITYfind_inherited_attribute, struct Scope_ *, char *, struct Symbol_ **) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail) RESET_FAKE(SCOPE_get_entities) RESET_FAKE(ENTITYfind_inherited_attribute) } -int test_schema_define_ref() -{ +int test_schema_define_ref() { Schema cur_schema, ref_schema; Rename *ref_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -49,31 +47,30 @@ int test_schema_define_ref() cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; ref_rename->nnew = ent_ref; ref_rename->rename_type = ref; ref_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_reference(cur_schema, ref_rename); - + assert(cur_schema->u.schema->refdict->KeyCount == 1); - + return 0; } -int test_schema_define_use() -{ +int test_schema_define_use() { Schema cur_schema, ref_schema; Rename *use_rename; Symbol *cur_schema_id, *ent_ref, *ref_schema_id; @@ -81,35 +78,34 @@ int test_schema_define_use() cur_schema_id = SYMBOLcreate("cur_schema", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->usedict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; - + use_rename = REN_new(); use_rename->schema_sym = ref_schema_id; use_rename->old = ent_ref; use_rename->nnew = ent_ref; use_rename->rename_type = use; use_rename->schema = ref_schema; - DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); - + DICTdefine(cur_schema->u.schema->usedict, ent_ref->name, use_rename, ent_ref, OBJ_RENAME); + SCHEMAdefine_use(cur_schema, use_rename); - + assert(cur_schema->u.schema->usedict->KeyCount == 1); - + return 0; } -/* TODO: +/* TODO: * currently this function expects OBJ_RENAME stored as OBJ_ENTITY * (to indicate partial reference) */ -int test_schema_get_entities_ref() -{ +int test_schema_get_entities_ref() { Schema cur_schema, ref_schema; Rename *ref_rename; Entity ent; @@ -120,17 +116,17 @@ int test_schema_get_entities_ref() ent_id = SYMBOLcreate("line", 1, "cur.exp"); ent_ref = SYMBOLcreate("line", 1, "ref.exp"); ref_schema_id = SYMBOLcreate("ref_schema", 1, "ref.exp"); - + cur_schema = SCHEMAcreate(); cur_schema->symbol = *cur_schema_id; cur_schema->u.schema->refdict = DICTcreate(20); - + ref_schema = SCHEMAcreate(); ref_schema->symbol = *ref_schema_id; ent = ENTITYcreate(ent_id); DICTdefine(ref_schema->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); - + ref_rename = REN_new(); ref_rename->schema_sym = ref_schema_id; ref_rename->old = ent_ref; @@ -138,19 +134,19 @@ int test_schema_get_entities_ref() ref_rename->rename_type = ref; ref_rename->schema = ref_schema; ref_rename->object = ent; - DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); - + DICTdefine(cur_schema->u.schema->refdict, ent_ref->name, ref_rename, ent_ref, OBJ_ENTITY); + r = LISTcreate(); cur_schema->search_id = -1; SCHEMA_get_entities_ref(cur_schema, r); - + assert(LISTget_length(r) == 1); - + return 0; } -Variable -ENTITY_find_attr_handler(struct Scope_ *entity, char *name, struct Symbol_ **down_sym) +Variable +ENTITY_find_attr_handler(struct Scope_ *entity, char * name, struct Symbol_** down_sym) { Variable r; (void) down_sym; @@ -158,8 +154,7 @@ ENTITY_find_attr_handler(struct Scope_ *entity, char *name, struct Symbol_ **dow return r; } -int test_var_find() -{ +int test_var_find() { Schema scope; Symbol *e_type_id, *attr_id; Entity ent; @@ -176,7 +171,7 @@ int test_var_find() DICT_define(scope->symbol_table, e_type_id->name, ent, &ent->symbol, OBJ_ENTITY); attr_id = SYMBOLcreate("attr1", 1, "test2"); - exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); + exp_attr = EXPcreate_from_symbol(Type_Attribute, attr_id); tb = TYPEBODYcreate(number_); attr_typ = TYPEcreate_from_body_anonymously(tb); attr_typ->superscope = ent; @@ -184,16 +179,16 @@ int test_var_find() var_attr->flags.attribute = 1; explicit_attr_list = LISTcreate(); LISTadd_last(explicit_attr_list, var_attr); - + LISTadd_last(ent->u.entity->attributes, explicit_attr_list); - DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); - + DICTdefine(ent->symbol_table, attr_id->name, var_attr, &var_attr->name->symbol, OBJ_VARIABLE); + ENTITYfind_inherited_attribute_fake.custom_fake = ENTITY_find_attr_handler; - + var_ref = VARfind(ent, "attr1", 1); - + assert(var_ref != NULL); - + return 0; } diff --git a/src/express/test/test_scope.c b/src/express/test/test_scope.c index 17ac6bc81..b59ef4acc 100644 --- a/src/express/test/test_scope.c +++ b/src/express/test/test_scope.c @@ -15,7 +15,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int __SCOPE_search_id; @@ -33,22 +33,20 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail); } -int test_scope_find() -{ +int test_scope_find() { Schema scope; Type sel, ent_base, chk_sel; Entity ent, chk_ent; Symbol *ent_id, *sel_id; - + scope = SCHEMAcreate(); ent_id = SYMBOLcreate("ent", 1, "test_4"); sel_id = SYMBOLcreate("sel_typ", 1, "test_4"); - + ent_base = TYPEcreate_name(ent_id); ent_base->superscope = scope; ent = ENTITYcreate(ent_id); @@ -58,19 +56,19 @@ int test_scope_find() sel->u.type->body->list = LISTcreate(); sel->superscope = scope; LISTadd_last(sel->u.type->body->list, ent_base); - + DICTdefine(scope->symbol_table, ent_id->name, ent, ent_id, OBJ_ENTITY); DICTdefine(scope->symbol_table, sel_id->name, sel, sel_id, OBJ_TYPE); - + scope->search_id = -1; chk_sel = SCOPE_find(scope, "sel_typ", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + scope->search_id = -1; chk_ent = SCOPE_find(scope, "ent", SCOPE_FIND_ENTITY | SCOPE_FIND_TYPE); - + assert(chk_sel == sel); assert(chk_ent == ent); - + return 0; } diff --git a/src/express/test/test_type.c b/src/express/test/test_type.c index 419d03a7e..94b1f8b5a 100644 --- a/src/express/test/test_type.c +++ b/src/express/test/test_type.c @@ -15,7 +15,7 @@ * mock globals */ -char *EXPRESSprogram_name; +char * EXPRESSprogram_name; int yylineno; int tag_count; @@ -29,35 +29,33 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, EXPRESS_fail, Express) -void setup() -{ +void setup() { RESET_FAKE(EXPRESS_fail) TYPEinitialize(); } -int test_type_create_user_defined_tag() -{ +int test_type_create_user_defined_tag() { Schema scope; Function f; Type t, g, chk; Symbol *func_id, *tag_id; - + scope = SCHEMAcreate(); - + func_id = SYMBOLcreate("func1", 1, "test_5"); tag_id = SYMBOLcreate("item1", 1, "test_5"); f = ALGcreate(OBJ_FUNCTION); f->symbol = *func_id; DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION); - + g = TYPEcreate(generic_); t = TYPEcreate_nostab(tag_id, f, OBJ_TAG); - + chk = TYPEcreate_user_defined_tag(g, f, tag_id); - + assert(chk == t); - + return 0; } diff --git a/src/express/token_type.h b/src/express/token_type.h index 6c2bf2240..03cd99ab5 100644 --- a/src/express/token_type.h +++ b/src/express/token_type.h @@ -60,11 +60,11 @@ typedef union YYSTYPE { Linked_List list; Logical logical; Op_Code op_code; - Qualified_Attr *qualified_attr; + Qualified_Attr * qualified_attr; Real rVal; Statement statement; - Symbol *symbol; - char *string; + Symbol * symbol; + char * string; Type type; TypeBody typebody; Variable variable; diff --git a/src/express/type.c b/src/express/type.c index 838ce6a29..ffcba5915 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -126,21 +126,20 @@ This module implements the type abstraction. It is #include "express/type.h" -Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) -{ +Type TYPEcreate_user_defined_tag( Type base, Scope scope, struct Symbol_ *symbol ) { Type t; extern int tag_count; - t = (Type)DICTlookup(scope->symbol_table, symbol->name); - if(t) { - if(DICT_type == OBJ_TAG) { - return(t); + t = ( Type )DICTlookup( scope->symbol_table, symbol->name ); + if( t ) { + if( DICT_type == OBJ_TAG ) { + return( t ); } else { /* easiest to just generate the error this way! * following call WILL fail intentionally */ - DICTdefine(scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG); - return(0); + DICTdefine( scope->symbol_table, symbol->name, 0, symbol, OBJ_TAG ); + return( 0 ); } } @@ -148,22 +147,22 @@ Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) * if we are outside a formal parameter list (hack, hack) * then we can only refer to existing tags, so produce an error */ - if(tag_count < 0) { - ERRORreport_with_symbol(UNDEFINED_TAG, symbol, - symbol->name); - return(0); + if( tag_count < 0 ) { + ERRORreport_with_symbol( UNDEFINED_TAG, symbol, + symbol->name ); + return( 0 ); } /* otherwise, we're in a formal parameter list, * so it's ok to define it */ - t = TYPEcreate_nostab(symbol, scope, OBJ_TAG); + t = TYPEcreate_nostab( symbol, scope, OBJ_TAG ); t->u.type->head = base; /* count unique type tags inside PROC and FUNC headers */ tag_count++; - return(t); + return( t ); } /** @@ -172,63 +171,60 @@ Type TYPEcreate_user_defined_tag(Type base, Scope scope, struct Symbol_ *symbol) */ #define TYPE_inherits_from(t,e) ((t) && TYPEinherits_from((t),(e))) -bool TYPEinherits_from(Type t, enum type_enum e) -{ +bool TYPEinherits_from( Type t, enum type_enum e ) { TypeBody tb = t->u.type->body; - assert((t->type == OBJ_TYPE) && (tb) && "Not a Type!"); - switch(e) { + assert( ( t->type == OBJ_TYPE ) && ( tb ) && "Not a Type!" ); + switch( e ) { case aggregate_: - if(tb->type == aggregate_ || + if( tb->type == aggregate_ || tb->type == array_ || tb->type == bag_ || tb->type == set_ || - tb->type == list_) { + tb->type == list_ ) { return true; } else { - return(TYPE_inherits_from(tb->base, e)); + return( TYPE_inherits_from( tb->base, e ) ); } case array_: - return((tb->type == array_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == array_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case bag_: - return((tb->type == bag_ || - tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == bag_ || + tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case set_: - return((tb->type == set_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == set_ ) ? true : TYPE_inherits_from( tb->base, e ) ); case list_: - return((tb->type == list_) ? true : TYPE_inherits_from(tb->base, e)); + return( ( tb->type == list_ ) ? true : TYPE_inherits_from( tb->base, e ) ); default: break; } - return (tb->type == e); + return ( tb->type == e ); } #if 0 case binary_: -return((t->type == binary_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == binary_ ) ? true : TYPEinherits_from( t->base, e ) ); case integer_: -return((t->type == integer_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == integer_ ) ? true : TYPEinherits_from( t->base, e ) ); case real_: -return((t->type == real_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == real_ ) ? true : TYPEinherits_from( t->base, e ) ); case string_: -return((t->type == string_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == string_ ) ? true : TYPEinherits_from( t->base, e ) ); case logical_: -return((t->type == logical_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == logical_ ) ? true : TYPEinherits_from( t->base, e ) ); case boolean_: -return((t->type == boolean_) ? true : TYPEinherits_from(t->base, e)); +return( ( t->type == boolean_ ) ? true : TYPEinherits_from( t->base, e ) ); default: -return(false); +return( false ); } } #endif /** Initialize the Type module */ -void TYPEinitialize() -{ +void TYPEinitialize() { } /** Clean up the Type module */ -void TYPEcleanup(void) -{ +void TYPEcleanup( void ) { } /** @@ -236,9 +232,8 @@ void TYPEcleanup(void) * \return the base type of the aggregate type * Retrieve the base type of an aggregate. */ -Type TYPEget_nonaggregate_base_type(Type t) -{ - while(TYPEis_aggregate(t)) { +Type TYPEget_nonaggregate_base_type( Type t ) { + while( TYPEis_aggregate( t ) ) { t = t->u.type->body->base; } return t; diff --git a/src/express/variable.c b/src/express/variable.c index e99ca0b6f..b3ec9f88a 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -87,31 +87,29 @@ #include "express/variable.h" #include "express/object.h" -char *opcode_print(Op_Code o); +char * opcode_print( Op_Code o ); /** Initialize the Variable module. */ -void VARinitialize() -{ +void VARinitialize() { } /** VARget_simple_name * returns simple name of variable * for example, if var is named SELF\xxx.yyy, return yyy */ -extern char *VARget_simple_name(Variable v) -{ - Expression e = VARget_name(v); +extern char * VARget_simple_name( Variable v ) { + Expression e = VARget_name( v ); - while(TYPEis_expression(EXPget_type(e))) { - switch(e->e.op_code) { + while( TYPEis_expression( EXPget_type( e ) ) ) { + switch( e->e.op_code ) { case OP_DOT: case OP_GROUP: e = e->e.op2; break; default: - fprintf(stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print(e->e.op_code)); + fprintf( stderr, "unexpected op_code (%s) encountered in variable name expression\n", opcode_print( e->e.op_code ) ); abort(); } } - return EXPget_name(e); + return EXPget_name( e ); } diff --git a/src/test/SEarritr.h b/src/test/SEarritr.h index bf1214c20..f84b6fbb8 100644 --- a/src/test/SEarritr.h +++ b/src/test/SEarritr.h @@ -17,42 +17,36 @@ // Best used in the form: for (SEitr=0; !SEitr; ++SEitr) { ... } // (this for loop walks the whole array) -class SEarrIterator -{ +class SEarrIterator { private: - const STEPentity **SEarr; // Array of pointers to STEPentity's + const STEPentity ** SEarr; // Array of pointers to STEPentity's int index; // current index int size; // size of array public: // Construct the iterator with a given array and its size - SEarrIterator(const STEPentity **entarr, int sz) - { + SEarrIterator( const STEPentity ** entarr, int sz ) { SEarr = entarr; index = 0; size = sz; } // set the value of the index: SEitr = 3 - void operator= (int newindex) - { + void operator= ( int newindex ) { index = newindex; } // check if we're out of range: if (!SEitr)... - int operator!() - { - return (index < size); + int operator!() { + return ( index < size ); } // return current element: SEptr = SEitr() - STEPentity *operator()() - { - return (STEPentity *)SEarr[index]; + STEPentity * operator()() { + return ( STEPentity * )SEarr[index]; } // PREFIX increment operator: ++SEitr - int operator++ () - { + int operator++ () { index++; return operator!(); } diff --git a/src/test/generate_express/generate_express.cc b/src/test/generate_express/generate_express.cc index 404929f4f..a6cb1ef29 100644 --- a/src/test/generate_express/generate_express.cc +++ b/src/test/generate_express/generate_express.cc @@ -12,44 +12,43 @@ /******************** main() ****************************/ -main() -{ +main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // "Reset" has tables for browsing registry->ResetSchemas(); - const SchemaDescriptor *schema = 0; + const SchemaDescriptor * schema = 0; - SchemaDescriptor *schema2 = 0; - schema = (SchemaDescriptor *)registry->FindSchema("Example_Schema"); - EntityDescriptor *ed = (EntityDescriptor *)registry->FindEntity("Circle"); + SchemaDescriptor * schema2 = 0; + schema = ( SchemaDescriptor * )registry->FindSchema( "Example_Schema" ); + EntityDescriptor * ed = ( EntityDescriptor * )registry->FindEntity( "Circle" ); Uniqueness_rule_ptr ur = new Uniqueness_rule; - ur->comment_("(* Hi Dave *)\n"); - if(ed->_uniqueness_rules) { - ed->_uniqueness_rules->Append(ur); + ur->comment_( "(* Hi Dave *)\n" ); + if( ed->_uniqueness_rules ) { + ed->_uniqueness_rules->Append( ur ); } else { - ed->uniqueness_rules_(new Uniqueness_rule__set); - ed->_uniqueness_rules->Append(ur); + ed->uniqueness_rules_( new Uniqueness_rule__set ); + ed->_uniqueness_rules->Append( ur ); } registry->ResetSchemas(); schema = registry->NextSchema(); - ofstream *efile; + ofstream * efile; std::string str, tmp; - while(schema != 0) { + while( schema != 0 ) { str = ""; - str.Append(StrToLower(schema->Name(), tmp)); - str.Append(".exp"); - efile = new ofstream(str.c_str()); + str.Append( StrToLower( schema->Name(), tmp ) ); + str.Append( ".exp" ); + efile = new ofstream( str.c_str() ); cout << "Generating: " << str << endl; - schema->GenerateExpress(*efile); + schema->GenerateExpress( *efile ); efile->close(); delete efile; diff --git a/src/test/needFunc.cc b/src/test/needFunc.cc index a8f507b04..d71c8f28c 100644 --- a/src/test/needFunc.cc +++ b/src/test/needFunc.cc @@ -14,7 +14,6 @@ // To see an example of this function used with the Data Probe look in // ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor(). /////////////////////////////////////////////////////////////////////////////// -void DeleteSEE(StepEntityEditor *se) -{ +void DeleteSEE( StepEntityEditor * se ) { delete se; } diff --git a/src/test/needFunc.h b/src/test/needFunc.h index 471c41a62..a473c332c 100644 --- a/src/test/needFunc.h +++ b/src/test/needFunc.h @@ -1,11 +1,10 @@ // define this to be the name of the display window object for // STEP entity instance editing or define your own. -class StepEntityEditor -{ +class StepEntityEditor { public: StepEntityEditor() {}; ~StepEntityEditor() {}; }; -extern void DeleteSEE(StepEntityEditor *se); +extern void DeleteSEE( StepEntityEditor * se ); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index 04211ee98..f3fc1a3c6 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -12,7 +12,8 @@ ** provided the file written out is called file.out */ -extern void SchemaInit(class Registry &); +extern void SchemaInit( class Registry & ); +#include "sc_version_string.h" #include #include #include @@ -34,23 +35,22 @@ extern void SchemaInit(class Registry &); * before comparison. If they are not identical, attempt to strip any * ASN.1 identifiers and compare again. Returns true for a match. */ -bool compareOneSchName(std::string lib, std::string file) -{ +bool compareOneSchName( std::string lib, std::string file ) { size_t b, e, ls, fs; - b = lib.find_first_of('\'') + 1; - e = lib.find_last_of('\''); - lib = lib.substr(b, e - b); - std::transform(lib.begin(), lib.end(), lib.begin(), ::toupper); - std::transform(file.begin(), file.end(), file.begin(), ::toupper); - if(lib == file) { + b = lib.find_first_of( '\'' ) + 1; + e = lib.find_last_of( '\'' ); + lib = lib.substr( b, e - b ); + std::transform( lib.begin(), lib.end(), lib.begin(), ::toupper ); + std::transform( file.begin(), file.end(), file.begin(), ::toupper ); + if( lib == file ) { return true; } //There are no spaces, unless there is an ASN.1 identifier. If //the strings don't already match, try to remove this identifier. - ls = lib.find_first_of(' '); - fs = file.find_first_of(' '); - if(lib.substr(0, ls) == file.substr(0, fs)) { + ls = lib.find_first_of( ' ' ); + fs = file.find_first_of( ' ' ); + if( lib.substr( 0, ls ) == file.substr( 0, fs ) ) { return true; } std::cerr << "This pair of schema names do not match - " << lib << " and " << file << std::endl; @@ -61,43 +61,40 @@ bool compareOneSchName(std::string lib, std::string file) * Loop through all available schemas and attributes, looking * for a match. If match not found, print error and exit(1) */ -void checkSchemaName(Registry ®, STEPfile &sf, bool ignoreErr) -{ +void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) { bool match = false; std::string sname; - STEPattribute *attr; - const Schema *sc; + STEPattribute * attr; + const Schema * sc; reg.ResetSchemas(); //file id 3 is always the schema name - SDAI_Application_instance *ai = - sf.HeaderInstances()->FindFileId(3)->GetApplication_instance(); - while((attr = ai->NextAttribute())) { + SDAI_Application_instance * ai = + sf.HeaderInstances()->FindFileId( 3 )->GetApplication_instance(); + while( ( attr = ai->NextAttribute() ) ) { sname = attr->asStr(); - while((sc = reg.NextSchema())) { - if(compareOneSchName(sname, sc->Name())) { + while( ( sc = reg.NextSchema() ) ) { + if( compareOneSchName( sname, sc->Name() ) ) { match = true; break; } } - if(match) { + if( match ) { break; } } - if(!match) { + if( !match ) { std::cerr << "ERROR - schema name mismatch. Tried all available combinations." << std::endl; - if(!ignoreErr) { - exit(1); + if( !ignoreErr ) { + exit( 1 ); } } } -void printVersion(const char *exe) -{ - std::cout << exe << " build info: " << SC_VERSION << std::endl; +void printVersion( const char * exe ) { + std::cout << exe << " build info: " << sc_version << std::endl; } -void printUse(const char *exe) -{ +void printUse( const char * exe ) { std::cout << "p21read - read a STEP Part 21 exchange file using SCL, and write the data to another file." << std::endl; std::cout << "Syntax: " << exe << " [-i] [-s] infile [outfile]" << std::endl; std::cout << "Use '-i' to ignore a schema name mismatch." << std::endl; @@ -105,24 +102,23 @@ void printUse(const char *exe) std::cout << "Use '-s' for strict interpretation (attributes that are \"missing and required\" will cause errors)." << std::endl; std::cout << "Use '-v' to print the version info below and exit." << std::endl; std::cout << "Use '--' as the last argument if a file name starts with a dash." << std::endl; - printVersion(exe); - exit(1); + printVersion( exe ); + exit( 1 ); } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { bool ignoreErr = false; bool strict = false; bool trackStats = true; char c; - if(argc > 4 || argc < 2) { - printUse(argv[0]); + if( argc > 4 || argc < 2 ) { + printUse( argv[0] ); } char opts[] = "itsv"; - while((c = sc_getopt(argc, argv, opts)) != -1) { - switch(c) { + while( ( c = sc_getopt( argc, argv, opts ) ) != -1 ) { + switch( c ) { case 'i': ignoreErr = true; break; @@ -133,11 +129,11 @@ int main(int argc, char *argv[]) strict = true; break; case 'v': - printVersion(argv[0]); - exit(0); + printVersion( argv[0] ); + exit( 0 ); case '?': default: - printUse(argv[0]); + printUse( argv[0] ); } } @@ -149,51 +145,50 @@ int main(int argc, char *argv[]) // // The registry is always going to be in memory. /////////////////////////////////////////////////////////////////////////////// - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", strict); - char *flnm; + STEPfile sfile( registry, instance_list, "", strict ); + char * flnm; - // p21 ReadExchangeFile() - benchmark stats; + benchmark stats( "p21 ReadExchangeFile()" ); cout << argv[0] << ": load file ..." << endl; - if(argc >= (sc_optind + 1)) { + if( argc >= ( sc_optind + 1 ) ) { flnm = argv[sc_optind]; } else { - flnm = (char *)"testfile.step"; + flnm = ( char * )"testfile.step"; } - sfile.ReadExchangeFile(flnm); - if(sfile.Error().severity() < SEVERITY_USERMSG) { - sfile.Error().PrintContents(cout); + sfile.ReadExchangeFile( flnm ); + if( sfile.Error().severity() < SEVERITY_USERMSG ) { + sfile.Error().PrintContents( cout ); } - if(trackStats) { + if( trackStats ) { stats.stop(); - stats.out(); + stats.out( ); } - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - exit(1); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + exit( 1 ); } - checkSchemaName(registry, sfile, ignoreErr); + checkSchemaName( registry, sfile, ignoreErr ); Severity readSev = sfile.Error().severity(); //otherwise, errors from reading will be wiped out by sfile.WriteExchangeFile() cout << argv[0] << ": write file ..." << endl; - if(argc == sc_optind + 2) { + if( argc == sc_optind + 2 ) { flnm = argv[sc_optind + 1]; } else { - flnm = (char *)"file.out"; + flnm = ( char * )"file.out"; } - sfile.WriteExchangeFile(flnm); - if(sfile.Error().severity() < SEVERITY_USERMSG) { - sfile.Error().PrintContents(cout); + sfile.WriteExchangeFile( flnm ); + if( sfile.Error().severity() < SEVERITY_USERMSG ) { + sfile.Error().PrintContents( cout ); } cout << argv[0] << ": " << flnm << " written" << endl; - if((sfile.Error().severity() <= SEVERITY_INCOMPLETE) || (readSev <= SEVERITY_INCOMPLETE)) { //lower is worse - exit(1); + if( ( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) || ( readSev <= SEVERITY_INCOMPLETE ) ) { //lower is worse + exit( 1 ); } } diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index 6de41407b..f597b36e4 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -46,8 +46,7 @@ // you what kind of _aggragation_ (no pun intended) you have, as in giving // you a code or "Bag" or something by itself. It probably doesn't work // aesthetically for compound aggregates (i.e., a list of lists). -void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) -{ +void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtml ) { std::string buf; // The type. See src/clstepcore/baseType.h for info @@ -56,45 +55,45 @@ void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) // the type descriptor for the "referent type," if any. // This is NULL if the attribute is a fundamental type. // All we use it for now is checking for NULL. - const TypeDescriptor *reference = typeDesc->ReferentType(); + const TypeDescriptor * reference = typeDesc->ReferentType(); // Do we need an anchor? int anchor = 0; // First, figure out if we need an anchor... - if(reference) { // if this has a referent type (i.e., is a non-base type) - if(base != sdaiAGGR) { // anchor all non-bases except for aggregates + if( reference ) { // if this has a referent type (i.e., is a non-base type) + if( base != sdaiAGGR ) { // anchor all non-bases except for aggregates anchor = 1; // which we'll take care of recursively } } else { // entities and enumerations show up as base, but we want to // anchor them anyway - if(base == sdaiENUMERATION || base == sdaiINSTANCE) { + if( base == sdaiENUMERATION || base == sdaiINSTANCE ) { anchor = 1; } } // Now, print type, with anchor if necessary - if(anchor && base != sdaiINSTANCE) { + if( anchor && base != sdaiINSTANCE ) { // for regular TYPEs, anchor to the index at that definition outhtml << "Name() << "\">"; - } else if(anchor && base == sdaiINSTANCE) { + } else if( anchor && base == sdaiINSTANCE ) { // for entities, anchor to that entity's page outhtml << "Name(); outhtml << ".html\">"; } - typeDesc->AttrTypeName(buf); + typeDesc->AttrTypeName( buf ); outhtml << buf; - if(base == sdaiAGGR) { + if( base == sdaiAGGR ) { outhtml << " (contains elements of type "; - PrintAttrTypeWithAnchor(typeDesc->AggrElemTypeDescriptor(), outhtml); + PrintAttrTypeWithAnchor( typeDesc->AggrElemTypeDescriptor(), outhtml ); outhtml << ")" << endl; } - if(anchor) { + if( anchor ) { outhtml << ""; } } @@ -103,8 +102,7 @@ void PrintAttrTypeWithAnchor(const TypeDescriptor *typeDesc, ofstream &outhtml) // Given an entity, print out to the HTML file an unordered list of // the entity's attributes and their types. It returns the number of // explicit attributes that the entity has. -int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) -{ +int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) { int attrCount = 0; // To traverse the attributes of the entity, we're going to use @@ -112,19 +110,19 @@ int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) // been done using GetHead() and NextNode() of the entity's attribute // list (nearly identical to how the entity lists are traversed), see // PrintParentAttrsHTML() and also main() below. - AttrDescItr aditr(ent->ExplicitAttr()); - const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); - if(attrDesc != 0) { + AttrDescItr aditr( ent->ExplicitAttr() ); + const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); + if( attrDesc != 0 ) { outhtml << "\nName() << " >\n\n"; outhtml << "
            " << endl; - while(attrDesc != 0) { + while( attrDesc != 0 ) { attrCount++; outhtml << "
          • " << attrDesc->Name() << " : "; - if((attrDesc->Optional()) == SDAI_LOGICAL(LTrue)) { + if( ( attrDesc->Optional() ) == SDAI_LOGICAL( LTrue ) ) { outhtml << "optional "; } - PrintAttrTypeWithAnchor(attrDesc->ReferentType(), outhtml); + PrintAttrTypeWithAnchor( attrDesc->ReferentType(), outhtml ); outhtml << endl; attrDesc = aditr.NextAttrDesc(); } @@ -139,9 +137,8 @@ int PrintAttrsHTML(const EntityDescriptor *ent, ofstream &outhtml) // the inheritance tree of the entity, printing to the HTML file a // description-list structure showing all ancestors. For each ancestor, // the attributes are printed using the PrintAttrsHTML() function above. -void PrintParentAttrsHTML(const EntityDescriptor *ent, - const EntityDescriptor *parent, ofstream &outhtml) -{ +void PrintParentAttrsHTML( const EntityDescriptor * ent, + const EntityDescriptor * parent, ofstream & outhtml ) { // Passing this function the pointer to ent is really cosmetic, so // we can easily print out this 'header' information. outhtml << "\nName() << ">\n\n"; @@ -152,17 +149,17 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, // Here we're going to traverse the list of supertypes of the parent // using the EntityDescriptorList - const EntityDescriptorList *grandpaList = &(parent->Supertypes()); - EntityDescLinkNode *grandpaNode = - (EntityDescLinkNode *)grandpaList->GetHead(); - while(grandpaNode) { + const EntityDescriptorList * grandpaList = &( parent->Supertypes() ); + EntityDescLinkNode * grandpaNode = + ( EntityDescLinkNode * )grandpaList->GetHead(); + while( grandpaNode ) { // for each "grandparent" of ent, inside a descriptor body (
            ) // recursively call this function... the 'while' takes care of // multiple inheritance: for each grandparent, trace back. outhtml << "
            " << endl; - const EntityDescriptor *grandpa = grandpaNode->EntityDesc(); - PrintParentAttrsHTML(parent, grandpa, outhtml); - grandpaNode = (EntityDescLinkNode *)grandpaNode->NextNode(); + const EntityDescriptor * grandpa = grandpaNode->EntityDesc(); + PrintParentAttrsHTML( parent, grandpa, outhtml ); + grandpaNode = ( EntityDescLinkNode * )grandpaNode->NextNode(); } // Now print the parent's attributes. This calls PrintAttrsHTML() to @@ -170,13 +167,13 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, // any, we'll check to see if the head of the attribute descriptor list // exists. Conversely, once grabbing the head we could print out // the attributes by following the list (attrNode->NextNode()). - const AttrDescriptorList *attrList = &(parent->ExplicitAttr()); - AttrDescLinkNode *attrNode = (AttrDescLinkNode *)attrList->GetHead(); - if(attrNode) { + const AttrDescriptorList * attrList = &( parent->ExplicitAttr() ); + AttrDescLinkNode * attrNode = ( AttrDescLinkNode * )attrList->GetHead(); + if( attrNode ) { outhtml << "
            " << parent->Name(); outhtml << " has the following attributes" << endl; outhtml << "
            " << endl; - if(PrintAttrsHTML(parent, outhtml) == 0) { + if( PrintAttrsHTML( parent, outhtml ) == 0 ) { outhtml << "none" << endl; } } @@ -187,14 +184,13 @@ void PrintParentAttrsHTML(const EntityDescriptor *ent, /******************** main() ****************************/ -main() -{ +main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // Rather than using the standard Registry class here, as in the treg // example, we are using MyRegistry, which is derived from the original. @@ -207,7 +203,7 @@ main() registry->ResetSchemas(); registry->ResetTypes(); - const SchemaDescriptor *schema = registry->NextSchema(); + const SchemaDescriptor * schema = registry->NextSchema(); int num_ents = registry->GetEntityCnt(); cout << "Processing schema " << schema->Name(); cout << " with " << num_ents << " entities." << endl; @@ -217,7 +213,7 @@ main() // the schema. cout << "Creating 'index.html'" << endl; - ofstream root("index.html"); + ofstream root( "index.html" ); root << "" << schema->Name() << "" << endl; root << "

            Schema: " << schema->Name() << "

            " << endl; @@ -227,11 +223,11 @@ main() root << "

            Types

            " << endl; root << "
              " << endl; - const TypeDescriptor *type; + const TypeDescriptor * type; type = registry->NextType(); root << "\n"; root << "\n"; - while(type != 0) { + while( type != 0 ) { cout << "."; root << "
            • Name() << "\">"; root << type->Name() << ": "; @@ -254,12 +250,12 @@ main() // for ancestors, but we'll use subs to list subclasses and make links // to them. - const EntityDescriptor *ent; - const EntityDescriptorList *supers; - const EntityDescriptorList *subs; - EntityDescLinkNode *entNode; + const EntityDescriptor * ent; + const EntityDescriptorList * supers; + const EntityDescriptorList * subs; + EntityDescLinkNode * entNode; - for(int i = 0; i < num_ents; i++) { + for( int i = 0; i < num_ents; i++ ) { ent = registry->NextEntity(); cout << "Processing " << ent->Name() << endl; @@ -268,8 +264,8 @@ main() root << ent->Name() << "" << endl; // construct page for entity - char *tmpstr = new char[strlen(ent->Name()) + 6]; - ofstream entout(strcat(strcpy(tmpstr, ent->Name()), ".html")); + char * tmpstr = new char[strlen( ent->Name() ) + 6]; + ofstream entout( strcat( strcpy( tmpstr, ent->Name() ), ".html" ) ); delete [] tmpstr; entout << "Entity " << ent->Name() << "" << endl; entout << "

              " << ent->Name() << "

              " << endl; @@ -278,22 +274,22 @@ main() entout << "
              \n

              Inherited Attributes

              " << endl; entout << "Name() << ">\n"; - supers = &(ent->Supertypes()); - entNode = (EntityDescLinkNode *)supers->GetHead(); - if(!entNode) { + supers = &( ent->Supertypes() ); + entNode = ( EntityDescLinkNode * )supers->GetHead(); + if( !entNode ) { entout << "none" << endl; } - while(entNode) { + while( entNode ) { // call PrintParentAttrsHTML to explore the parents // of the entity, for each parent. - const EntityDescriptor *parent = entNode->EntityDesc(); - PrintParentAttrsHTML(ent, parent, entout); - entNode = (EntityDescLinkNode *)entNode->NextNode(); + const EntityDescriptor * parent = entNode->EntityDesc(); + PrintParentAttrsHTML( ent, parent, entout ); + entNode = ( EntityDescLinkNode * )entNode->NextNode(); } // local attributes entout << "
              \n

              Local Attributes

              " << endl; - if(PrintAttrsHTML(ent, entout) == 0) { + if( PrintAttrsHTML( ent, entout ) == 0 ) { entout << "none" << endl; } @@ -302,16 +298,16 @@ main() // of the entity, a little more simply than in PrintParentAttrsHTML() entout << "
              \n

              Subtypes

              " << endl; entout << "\n"; - subs = &(ent->Subtypes()); - entNode = (EntityDescLinkNode *)subs->GetHead(); - if(entNode) { + subs = &( ent->Subtypes() ); + entNode = ( EntityDescLinkNode * )subs->GetHead(); + if( entNode ) { entout << "
                " << endl; - EntityDescriptor *child; - while(entNode) { + EntityDescriptor * child; + while( entNode ) { child = entNode->EntityDesc(); entout << "
              • Name() << ".html\">"; entout << child->Name() << "" << endl; - entNode = (EntityDescLinkNode *)entNode->NextNode(); + entNode = ( EntityDescLinkNode * )entNode->NextNode(); } entout << "
              " << endl; } else { diff --git a/src/test/tests.h b/src/test/tests.h index 148fca03f..52fcb3a59 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -31,4 +31,4 @@ #include -extern void SchemaInit(Registry &); +extern void SchemaInit( Registry & ); diff --git a/src/test/tio/tio.cc b/src/test/tio/tio.cc index 9936965bd..a73aab4b2 100644 --- a/src/test/tio/tio.cc +++ b/src/test/tio/tio.cc @@ -18,14 +18,13 @@ #define DONT_NEED_HEADER #include "tests.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int using_outfile = 0; - if(argc > 3 || argc < 2) { + if( argc > 3 || argc < 2 ) { cout << "Syntax: tio infile [outfile]" << endl; - exit(1); - } else if(argc > 2) { + exit( 1 ); + } else if( argc > 2 ) { using_outfile = 1; // output filename is in argv[2] } @@ -37,7 +36,7 @@ int main(int argc, char *argv[]) // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -47,7 +46,7 @@ int main(int argc, char *argv[]) // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile *sfile = new STEPfile(*registry, instance_list); + STEPfile * sfile = new STEPfile( *registry, instance_list ); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -60,28 +59,28 @@ int main(int argc, char *argv[]) // The instances get pointers into the InstMgr, and each type // and entity gets a pointer into the registry. cout << "\n### Reading exchange file from " << argv[1] << endl; - sfile->ReadExchangeFile(argv[1]); + sfile->ReadExchangeFile( argv[1] ); // Just checking... ;-) cout << "\n### The InstMgr says there are "; cout << instance_list.InstanceCount() << " instantiated objects" << endl; cout << "\n### Here is the exchange file:" << endl << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); // If you append in another exchange file, it creates new instances // starting at a 1000-block of numbers. Just 'Read'ing again // would clobber the instances already there. cout << "\n### Now appending in another copy" << endl; - sfile->AppendExchangeFile(argv[1]); + sfile->AppendExchangeFile( argv[1] ); // Browsing the registry... cout << "\n### Here is a list of entities now in the registry:" << endl; registry->ResetEntities(); - const EntityDescriptor *ent = registry->NextEntity(); + const EntityDescriptor * ent = registry->NextEntity(); std::string tmpstr; - while(ent) { - cout << ent->Name() << ": " << ent->TypeString(tmpstr) << endl; + while( ent ) { + cout << ent->Name() << ": " << ent->TypeString( tmpstr ) << endl; ent = registry->NextEntity(); } @@ -91,22 +90,22 @@ int main(int argc, char *argv[]) int numInstances = instance_list.InstanceCount(); cout << "### The InstMgr says we have " << numInstances; cout << " things instantiated.\n"; - for(int i = 0; i < numInstances; i++) { - cout << i << ": " << instance_list.GetSTEPentity(i)->EntityName(); + for( int i = 0; i < numInstances; i++ ) { + cout << i << ": " << instance_list.GetSTEPentity( i )->EntityName(); cout << " (" << - instance_list.GetSTEPentity(i)->eDesc->Description(); + instance_list.GetSTEPentity( i )->eDesc->Description(); cout << ")" << endl; } // Dump everything to STEPfiles... cout << "\n### Here it is in STEPfile format:" << endl << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); - if(using_outfile) { - ofstream stepout(argv[2]); + if( using_outfile ) { + ofstream stepout( argv[2] ); cout << "\n### Writing that to outfile " << argv[2] << endl; - sfile->WriteExchangeFile(stepout); + sfile->WriteExchangeFile( stepout ); } - exit(0); + exit( 0 ); } diff --git a/src/test/treg/treg.cc b/src/test/treg/treg.cc index c35f2b33f..aea466013 100644 --- a/src/test/treg/treg.cc +++ b/src/test/treg/treg.cc @@ -27,17 +27,16 @@ // put data values in its attributes. PopulateEntity doesn't care what // attributes your entity has. It goes through them, one at a time, checks // their type, and puts an appropriate random value in. -void PopulateEntity(STEPentity *ent) -{ +void PopulateEntity( STEPentity * ent ) { int attrCount = ent->AttributeCount(); cout << "Populating " << ent->EntityName() << " which has "; cout << attrCount << " attributes." << endl; ent->ResetAttributes(); // start us walking at the top of the list - STEPattribute *attr = ent->NextAttribute(); - while(attr != 0) { - const AttrDescriptor *attrDesc = attr->aDesc; + STEPattribute * attr = ent->NextAttribute(); + while( attr != 0 ) { + const AttrDescriptor * attrDesc = attr->aDesc; cout << " attribute " << attrDesc->Name(); cout << " [" << attrDesc->TypeName() << "] = "; int needOutput = 1; // true if we need to output the value @@ -48,7 +47,7 @@ void PopulateEntity(STEPentity *ent) // a string value as the value of the attribute. Then, depending on // the type of the attribute, put something nearly appropriate in. ostringstream valstr; - switch(attrDesc->NonRefType()) { + switch( attrDesc->NonRefType() ) { case INTEGER_TYPE: // for these types, just put in a random number case REAL_TYPE: // from 0-99. case NUMBER_TYPE: @@ -63,8 +62,8 @@ void PopulateEntity(STEPentity *ent) case BOOLEAN_TYPE: // the trick here is that the value needs to be case LOGICAL_TYPE: { // the word, not the int value, because of StrToVal cout << "(enum/bool/logi) "; - STEPenumeration *se = attr->ptr.e; // grab the enumeration... - valstr << se->element_at(rand() % se->no_elements()); + STEPenumeration * se = attr->ptr.e; // grab the enumeration... + valstr << se->element_at( rand() % se->no_elements() ); } break; default: // for other stuff like aggregates and selects, just leave @@ -74,25 +73,24 @@ void PopulateEntity(STEPentity *ent) } valstr << ends; // flush and null-terminate the stream /*** char *val = valstr.str(); ***/ // fix stream into char* string - char *val = &(valstr.str()[0]); - if(needOutput) { + char * val = &( valstr.str()[0] ); + if( needOutput ) { cout << val << endl; } - attr->StrToVal(val); // and assign + attr->StrToVal( val ); // and assign attr = ent->NextAttribute(); } } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int using_outfile = 0; - if(argc > 2) { + if( argc > 2 ) { cout << "Syntax: treg [filename]" << endl; - exit(1); - } else if(argc > 1) { + exit( 1 ); + } else if( argc > 1 ) { using_outfile = 1; // output filename is in argc[1] } @@ -101,7 +99,7 @@ int main(int argc, char *argv[]) // The SchemaInit() function is generated by exp2cxx... see // extern statement above. - Registry *registry = new Registry(SchemaInit); + Registry * registry = new Registry( SchemaInit ); // The nifty thing about the Registry is that it basically keeps a list // of everything in your schema. What this means is that we can go @@ -111,7 +109,7 @@ int main(int argc, char *argv[]) // other schema, rather than the example, and run happily. InstMgr instance_list; - STEPfile *sfile = new STEPfile(*registry, instance_list); + STEPfile * sfile = new STEPfile( *registry, instance_list ); // The STEPfile is actually an object that manages the relationship // between what's instantiated in the instance manager, and how that @@ -127,7 +125,7 @@ int main(int argc, char *argv[]) // to store a pointer to one of each. int num_ents = registry->GetEntityCnt(); - STEPentity **SEarray = new STEPentity*[num_ents]; + STEPentity ** SEarray = new STEPentity*[num_ents]; // "Reset" the Schema and Entity hash tables... this sets things up // so we can walk through the table using registry->NextEntity() @@ -137,46 +135,46 @@ int main(int argc, char *argv[]) // Print out what schema we're running through. - const SchemaDescriptor *schema = registry->NextSchema(); + const SchemaDescriptor * schema = registry->NextSchema(); cout << "Building entities in schema " << schema->Name() << endl; // "Loop" through the schema, building one of each entity type. - const EntityDescriptor *ent; // needs to be declared const... - for(int i = 0; i < num_ents; i++) { + const EntityDescriptor * ent; // needs to be declared const... + for( int i = 0; i < num_ents; i++ ) { ent = registry->NextEntity(); cout << " Building entity " << ent->Name() << endl; // Build object, using its name, through the registry - SEarray[i] = registry->ObjCreate(ent->Name()); + SEarray[i] = registry->ObjCreate( ent->Name() ); // Add each realized entity to the instance list - instance_list.Append(SEarray[i], completeSE); + instance_list.Append( SEarray[i], completeSE ); // Put some data into each instance - PopulateEntity(SEarray[i]); + PopulateEntity( SEarray[i] ); } // Print out all entities - SEarrIterator SEitr((const STEPentity **) SEarray, num_ents); + SEarrIterator SEitr( ( const STEPentity ** ) SEarray, num_ents ); // the above cast is needed because the SEarrIterator // constructor takes a const entity array pointer argument cout << endl << "Here are the entities instantiated, via the SEarray:"; cout << endl; - for(SEitr = 0; !SEitr; ++SEitr) { - SEitr()->STEPwrite(cout); + for( SEitr = 0; !SEitr; ++SEitr ) { + SEitr()->STEPwrite( cout ); } cout << endl << "Here are all the entities via the STEPfile:" << endl; - sfile->WriteExchangeFile(cout); + sfile->WriteExchangeFile( cout ); - if(using_outfile) { + if( using_outfile ) { cout << "\nWriting STEPfile to output file " << argv[1] << endl; - ofstream step_out(argv[1]); - sfile->WriteExchangeFile(step_out); + ofstream step_out( argv[1] ); + sfile->WriteExchangeFile( step_out ); } - exit(0); + exit( 0 ); } diff --git a/src/test/tstatic/tstatic.cc b/src/test/tstatic/tstatic.cc index 56f0c4e7d..eb6d6f2c5 100644 --- a/src/test/tstatic/tstatic.cc +++ b/src/test/tstatic/tstatic.cc @@ -17,8 +17,7 @@ /* STEPentity* Iterator class definition */ #include "../SEarritr.h" -int main() -{ +int main() { // This has to be done before anything else. This initializes // all of the registry information for the schema you are using. // The SchemaInit() function is generated by exp2cxx... see @@ -31,15 +30,15 @@ int main() // For specifics on the structure of the entity classes, see // the SdaiEXAMPLE_SCHEMA.h header file. - const STEPentity *entArr[4]; // our array of entity pointers + const STEPentity * entArr[4]; // our array of entity pointers cout << "Creating an SdaiRectangle..." << endl; SdaiRectangle rect; - rect.item_name_("MyRect"); - rect.item_color_(Color__orange); - rect.number_of_sides_(4); - rect.height_(5); - rect.width_(10); + rect.item_name_( "MyRect" ); + rect.item_color_( Color__orange ); + rect.number_of_sides_( 4 ); + rect.height_( 5 ); + rect.width_( 10 ); cout << "Rectangle: (" << rect.opcode() << ") " << endl; cout << " Name: " << rect.item_name_().c_str() << endl; cout << " Color: " << rect.item_color_() << endl; @@ -51,11 +50,11 @@ int main() cout << "Creating an SdaiSquare..." << endl; SdaiSquare square; - square.item_name_("MySquare"); - square.item_color_(Color__green); - square.number_of_sides_(4); - square.height_(3); - square.width_(3); + square.item_name_( "MySquare" ); + square.item_color_( Color__green ); + square.number_of_sides_( 4 ); + square.height_( 3 ); + square.width_( 3 ); cout << "Square: (" << square.opcode() << ") " << endl; cout << " Name: " << square.item_name_().c_str() << endl; cout << " Color: " << square.item_color_() << endl; @@ -67,12 +66,12 @@ int main() cout << "Creating an SdaiTriangle..." << endl; SdaiTriangle tri; - tri.item_name_("MyTri"); - tri.item_color_(Color__blue); - tri.number_of_sides_(3); - tri.side1_length_(3); - tri.side2_length_(4); - tri.side3_length_(5); + tri.item_name_( "MyTri" ); + tri.item_color_( Color__blue ); + tri.number_of_sides_( 3 ); + tri.side1_length_( 3 ); + tri.side2_length_( 4 ); + tri.side3_length_( 5 ); cout << "Triangle: (" << tri.opcode() << ") " << endl; cout << " Name: " << tri.item_name_().c_str() << endl; cout << " Color: " << tri.item_color_() << endl; @@ -85,10 +84,10 @@ int main() cout << "Creating an SdaiCircle..." << endl; SdaiCircle circ; - circ.item_name_("MyCirc"); - circ.item_color_(Color__red); - circ.number_of_sides_(1); - circ.radius_(15); + circ.item_name_( "MyCirc" ); + circ.item_color_( Color__red ); + circ.number_of_sides_( 1 ); + circ.radius_( 15 ); cout << "Circle: (" << circ.opcode() << ") " << endl; cout << " Name: " << circ.item_name_().c_str() << endl; cout << " Color: " << circ.item_color_() << endl; @@ -98,9 +97,9 @@ int main() entArr[3] = ˆ cout << "And now, all entities in STEP Exchange Format!" << endl << endl; - SEarrIterator SEitr(entArr, 4); - for(SEitr = 0; !SEitr; ++SEitr) { - SEitr()->STEPwrite(cout); + SEarrIterator SEitr( entArr, 4 ); + for( SEitr = 0; !SEitr; ++SEitr ) { + SEitr()->STEPwrite( cout ); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05530cb5b..48d826458 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,8 +13,10 @@ foreach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) endif( UNITARY_SCHEMA MATCHES "fail_.*" ) endforeach(UNITARY_SCHEMA ${UNITARY_SCHEMAS}) -add_subdirectory(p21) -add_subdirectory(cpp) +if(NOT ${SC_BUILD_EXPRESS_ONLY}) + add_subdirectory(p21) + add_subdirectory(cpp) +endif() # Local Variables: # tab-width: 8 diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index 7af916d2c..cccf68811 100644 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #c++ tests diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index c96ea08f3..39ce6541a 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -9,10 +9,6 @@ include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${ # added as a workaround for changed behavior in newer cmake # versions (changes somewhere between 2.8 and 3.1) function(get_sdai_incl_dir out_path_var sdai_lib) - if (NOT TARGET sdai_${sdai_lib}) - message("sdai_${sdai_lib} is not a target") - return() - endif (NOT TARGET sdai_${sdai_lib}) if(NOT "${sdai_${sdai_lib}_SOURCE_DIR}" STREQUAL "") set(${out_path_var} "${sdai_${sdai_lib}_SOURCE_DIR}" PARENT_SCOPE) return() diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index d7394417f..fe103ab8e 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -13,112 +13,111 @@ #include "SdaiTEST_ARRAY_BOUNDS_EXPR.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit(1); + exit( 1 ); } - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); Severity readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } // Keeps track of the last processed ent id int search_index = 0; //find structured_mesh, find the array attribute, and check its bounds as much as possible. need an instance to check 100%. - const EntityDescriptor *ed = registry.FindEntity("Structured_mesh"); - AttrDescItr aditr(ed->ExplicitAttr()); - const AttrDescriptor *attrDesc = aditr.NextAttrDesc(); + const EntityDescriptor * ed = registry.FindEntity( "Structured_mesh" ); + AttrDescItr aditr( ed->ExplicitAttr() ); + const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); int descAggrCount = 0; - while(attrDesc != 0) { - if((attrDesc->NonRefType() == ARRAY_TYPE) && (attrDesc->AggrElemType() == sdaiINTEGER)) { + while( attrDesc != 0 ) { + if( ( attrDesc->NonRefType() == ARRAY_TYPE ) && ( attrDesc->AggrElemType() == sdaiINTEGER ) ) { cout << "Array attribute: " << attrDesc->Name(); - const AggrTypeDescriptor *atd = (const AggrTypeDescriptor *) attrDesc->DomainType(); - if(!(atd->Bound1Type() == bound_constant) || !(atd->Bound2Type() == bound_runtime)) { + const AggrTypeDescriptor * atd = ( const AggrTypeDescriptor * ) attrDesc->DomainType(); + if( !( atd->Bound1Type() == bound_constant ) || !( atd->Bound2Type() == bound_runtime ) ) { cerr << "Invalid bounds. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << " -- bound 1 is a constant (" << atd->Bound1() << "). bound 2 depends upon the instance." << endl; descAggrCount++; } attrDesc = aditr.NextAttrDesc(); } - if(descAggrCount != 1) { + if( descAggrCount != 1 ) { cerr << "Expected 1 aggregate attribute descriptor, found " << descAggrCount << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } // Loop over the instances in the file, check the bound for each - SdaiStructured_mesh *ent; - while(ENTITY_NULL != (ent = (SdaiStructured_mesh *) - instance_list.GetApplication_instance("Structured_mesh", search_index))) { + SdaiStructured_mesh * ent; + while( ENTITY_NULL != ( ent = ( SdaiStructured_mesh * ) + instance_list.GetApplication_instance( "Structured_mesh", search_index ) ) ) { SDAI_Integer b2; int instAggrCnt = 0; - IntAggregate *vertex_counts = ent->vertex_counts_(); + IntAggregate * vertex_counts = ent->vertex_counts_(); int cnt = ent->AttributeCount(); - STEPattributeList &sal = ent->attributes; + STEPattributeList & sal = ent->attributes; int id = ent->StepFileId(); cout << "Ent #" << id << " - "; - if(cnt != 3) { + if( cnt != 3 ) { cerr << "Expected 3 attributes, found " << cnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - if(id > 2) { + if( id > 2 ) { cerr << "Expected 2 instances, found " << cnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } //loop over the attributes - for(int i = 0; i < cnt; i++) { - const AttrDescriptor *ad = sal[i].getADesc(); - if((ad->NonRefType() == ARRAY_TYPE) && (ad->AggrElemType() == sdaiINTEGER)) { - b2 = ((AggrTypeDescriptor *) ad->DomainType())->Bound2Runtime(ent); + for( int i = 0; i < cnt; i++ ) { + const AttrDescriptor * ad = sal[i].getADesc(); + if( ( ad->NonRefType() == ARRAY_TYPE ) && ( ad->AggrElemType() == sdaiINTEGER ) ) { + b2 = ( ( AggrTypeDescriptor * ) ad->DomainType() )->Bound2Runtime( ent ); cout << "bound 2: " << b2 << " values: "; instAggrCnt++; - if(((id == 1) && (b2 != 3)) || ((id == 2) && (b2 != 5))) { + if( ( ( id == 1 ) && ( b2 != 3 ) ) || ( ( id == 2 ) && ( b2 != 5 ) ) ) { cerr << "Instance " << id << ": value " << b2 << " is invalid for bound 2."; cerr << " Expecting 3 for instance #1 or 5 for #2." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } } } int node = 0; int aggrValues[2][5] = {{1, 2, 3, -1, -1}, {9, 34, 0, 3, 999999}}; - IntNode *aggrNode = (IntNode *) vertex_counts->GetHead(); - while(aggrNode != 0) { - if(node >= b2) { + IntNode * aggrNode = ( IntNode * ) vertex_counts->GetHead(); + while( aggrNode != 0 ) { + if( node >= b2 ) { cerr << "Instance " << id << ": Number of values exceeds upper bound. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << aggrNode->value << " "; - if(aggrValues[id - 1][node] != aggrNode->value) { + if( aggrValues[id - 1][node] != aggrNode->value ) { cerr << "Instance " << id << ": aggregate value " << aggrNode->value << " at index " << node << " is incorrect. Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - aggrNode = (IntNode *) aggrNode->NextNode(); + aggrNode = ( IntNode * ) aggrNode->NextNode(); node++; } cout << endl; - if(instAggrCnt != 1) { + if( instAggrCnt != 1 ) { cerr << "Expected 1 aggregate attribute in this instance, found " << instAggrCnt << ". Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - MgrNode *mnode = instance_list.FindFileId(id); - search_index = instance_list.GetIndex(mnode) + 1; + MgrNode * mnode = instance_list.FindFileId( id ); + search_index = instance_list.GetIndex( mnode ) + 1; } } diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index 578e14911..bc624143a 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,6 +3,7 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include +#include "sc_version_string.h" #include #include #include @@ -18,43 +19,42 @@ #include "schema.h" -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool foundMatch = false; - const char *attrname = "description"; - if(argc != 2) { - exit(EXIT_FAILURE); + const char * attrname = "description"; + if( argc != 2 ) { + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - const SdaiWindow *wind = dynamic_cast< SdaiWindow * >(instance_list.GetApplication_instance("window")); + const SdaiWindow * wind = dynamic_cast< SdaiWindow * >( instance_list.GetApplication_instance( "window" ) ); int i = 0; - if(wind) { + if( wind ) { STEPattributeList attrlist = wind->attributes; - for(; i < attrlist.list_length(); i++) { + for( ; i < attrlist.list_length(); i++ ) { cout << "attr " << i << ": " << attrlist[i].Name() << endl; - if(0 == strcmp(attrname, attrlist[i].Name())) { + if( 0 == strcmp( attrname, attrlist[i].Name() ) ) { foundMatch = true; cout << "attribute " << '"' << attrname << '"' << " found at " << i << endl; } } } - if(!i) { + if( !i ) { cout << "no attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - if(!foundMatch) { + if( !foundMatch ) { cout << "attribute " << '"' << attrname << '"' << " not found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } } diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 717baec3a..3fd51454c 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,6 +4,7 @@ ** */ #include +#include "sc_version_string.h" #include "SubSuperIterators.h" #include #include @@ -20,78 +21,76 @@ #include "schema.h" ///first way of finding inverse attrs -bool findInverseAttrs1(InverseAItr iai, InstMgr &instList) -{ - const Inverse_attribute *ia; +bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { + const Inverse_attribute * ia; int j = 0; - while(0 != (ia = iai.NextInverse_attribute())) { + while( 0 != ( ia = iai.NextInverse_attribute() ) ) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - SdaiReldefinesbytype *rdbt; + SdaiReldefinesbytype * rdbt; int ent_id = 0; - while(0 != (rdbt = (SdaiReldefinesbytype *) instList.GetApplication_instance("reldefinesbytype", ent_id))) { + while( 0 != ( rdbt = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( "reldefinesbytype", ent_id ) ) ) { int i = rdbt->StepFileId(); - if(i < ent_id) { + if( i < ent_id ) { break; } - EntityAggregate *relObj = rdbt->relatedobjects_(); - if(!(relObj && (relObj->is_null() == 0))) { + EntityAggregate * relObj = rdbt->relatedobjects_(); + if( !( relObj && ( relObj->is_null() == 0 ) ) ) { return false; } else { - EntityNode *en = (EntityNode *) relObj->GetHead(); - SdaiObject *obj = (SdaiObject *) en->node; + EntityNode * en = ( EntityNode * ) relObj->GetHead(); + SdaiObject * obj = ( SdaiObject * ) en->node; cout << "file id " << obj->StepFileId() << "; name " - << instList.GetApplication_instance(obj->StepFileId() - 1)->eDesc->Name() << endl; + << instList.GetApplication_instance( obj->StepFileId() - 1 )->getEDesc()->Name() << endl; } ent_id = i; } j++; } - return(j != 0); + return( j != 0 ); } -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool inverseAttrsFound = false; - if(argc != 2) { + if( argc != 2 ) { cout << "wrong args" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor *ed = registry.FindEntity("window"); - InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes - if(findInverseAttrs1(iaIter, instance_list)) { + const EntityDescriptor * ed = registry.FindEntity( "window" ); + InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes + if( findInverseAttrs1( iaIter, instance_list ) ) { inverseAttrsFound = true; } //now, find inherited inverse attrs - supertypesIterator iter(ed); - const EntityDescriptor *super; - for(; !iter.empty(); iter++) { + supertypesIterator iter( ed ); + const EntityDescriptor * super; + for( ; !iter.empty(); iter++ ) { super = iter.current(); cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter(&(super->InverseAttr())); - if(findInverseAttrs1(superIaIter, instance_list)) { + InverseAItr superIaIter( &( super->InverseAttr() ) ); + if( findInverseAttrs1( superIaIter, instance_list ) ) { inverseAttrsFound = true; } } - if(!inverseAttrsFound) { + if( !inverseAttrsFound ) { cout << "no inverse attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 0feef4b5b..d30eabe7b 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,6 +4,7 @@ ** */ #include +#include "sc_version_string.h" #include #include #include @@ -19,21 +20,20 @@ #include "schema.h" ///second way of finding inverse attrs -bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) -{ - const Inverse_attribute *ia; +bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { + const Inverse_attribute * ia; int j = 0; - while(0 != (ia = iai.NextInverse_attribute())) { + while( 0 != ( ia = iai.NextInverse_attribute() ) ) { cout << "inverse attr #" << j << ", name: " << ia->Name() << ", inverted attr id: " << ia->inverted_attr_id_() << ", from entity: " << ia->inverted_entity_id_() << endl; //now find the entity containing the attribute in question - const EntityDescriptor *inv_ed = reg.FindEntity(ia->inverted_entity_id_()); - AttrDescItr attr_desc_itr(inv_ed->ExplicitAttr()); - const AttrDescriptor *attrDesc; + const EntityDescriptor * inv_ed = reg.FindEntity( ia->inverted_entity_id_() ); + AttrDescItr attr_desc_itr( inv_ed->ExplicitAttr() ); + const AttrDescriptor * attrDesc; int k = 0; - while(0 != (attrDesc = attr_desc_itr.NextAttrDesc())) { - if(!strcmp(ia->inverted_attr_id_(), attrDesc->Name())) { + while( 0 != ( attrDesc = attr_desc_itr.NextAttrDesc() ) ) { + if( !strcmp( ia->inverted_attr_id_(), attrDesc->Name() ) ) { cout << "attribute '" << attrDesc->Name() << "' is attribute #" << k << " of '" << inv_ed->Name() << "'." << endl; @@ -41,20 +41,20 @@ bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) // entity type 'inv_ed', looking for references to 'ed' in the // attribute described by 'attrDesc' int l = 0; - SdaiReldefinesbytype *inst; - while(0 != (inst = (SdaiReldefinesbytype *) instList.GetApplication_instance(inv_ed->Name(), l))) { + SdaiReldefinesbytype * inst; + while( 0 != ( inst = ( SdaiReldefinesbytype * ) instList.GetApplication_instance( inv_ed->Name(), l ) ) ) { int i = inst->StepFileId(); - if(i < l) { + if( i < l ) { break; } STEPattributeList attrlist = inst->attributes; - if(attrlist.list_length() < k + 1) { + if( attrlist.list_length() < k + 1 ) { return false; } STEPattribute sa = attrlist[k]; - if(sa.getADesc()->DomainType()->Type() == SET_TYPE) { - STEPaggregate *aggr = sa.Aggregate(); - if(!aggr || aggr->is_null() != 0) { + if( sa.getADesc()->DomainType()->Type() == SET_TYPE ) { + STEPaggregate * aggr = sa.Aggregate(); + if( !aggr || aggr->is_null() != 0 ) { cout << "findInverseAttrs2 FAILED" << endl; return false; } @@ -69,46 +69,45 @@ bool findInverseAttrs2(InverseAItr iai, InstMgr &instList, Registry ®) } j++; } - return(j != 0); + return( j != 0 ); } -int main(int argc, char *argv[]) -{ - Registry registry(SchemaInit); +int main( int argc, char * argv[] ) { + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); bool inverseAttrsFound = false; - if(argc != 2) { - exit(EXIT_FAILURE); + if( argc != 2 ) { + exit( EXIT_FAILURE ); } - sfile.ReadExchangeFile(argv[1]); + sfile.ReadExchangeFile( argv[1] ); - if(sfile.Error().severity() <= SEVERITY_INCOMPLETE) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } //find inverse attribute descriptors //first, find inverse attrs unique to this entity (i.e. not inherited) - const EntityDescriptor *ed = registry.FindEntity("window"); - InverseAItr iaIter(&(ed->InverseAttr())); //iterator for inverse attributes - if(findInverseAttrs2(iaIter, instance_list, registry)) { + const EntityDescriptor * ed = registry.FindEntity( "window" ); + InverseAItr iaIter( &( ed->InverseAttr() ) ); //iterator for inverse attributes + if( findInverseAttrs2( iaIter, instance_list, registry ) ) { inverseAttrsFound = true; } //now, find inherited inverse attrs - EntityDescItr edi(ed->GetSupertypes()); - const EntityDescriptor *super; - while(0 != (super = edi.NextEntityDesc())) { + EntityDescItr edi( ed->GetSupertypes() ); + const EntityDescriptor * super; + while( 0 != ( super = edi.NextEntityDesc() ) ) { cout << "supertype " << super->Name() << endl; - InverseAItr superIaIter(&(super->InverseAttr())); - if(findInverseAttrs2(superIaIter, instance_list, registry)) { + InverseAItr superIaIter( &( super->InverseAttr() ) ); + if( findInverseAttrs2( superIaIter, instance_list, registry ) ) { inverseAttrsFound = true; } } - if(!inverseAttrsFound) { + if( !inverseAttrsFound ) { cout << "no inverse attrs found" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index f1e5d842b..866801dbf 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -22,51 +22,50 @@ #include #include "schema.h" -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { int exitStatus = EXIT_SUCCESS; - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args!" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } lazyInstMgr lim; - lim.initRegistry(SchemaInit); + lim.initRegistry( SchemaInit ); - lim.openFile(argv[1]); + lim.openFile( argv[1] ); //find attributes - instanceTypes_t::cvector *insts = lim.getInstances("window"); - if(!insts || insts->empty()) { + instanceTypes_t::cvector * insts = lim.getInstances( "window" ); + if( !insts || insts->empty() ) { cout << "No window instances found!" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - SdaiWindow *instance = dynamic_cast< SdaiWindow * >(lim.loadInstance(insts->at(0))); - if(!instance) { + SdaiWindow * instance = dynamic_cast< SdaiWindow * >( lim.loadInstance( insts->at( 0 ) ) ); + if( !instance ) { cout << "Problem loading instance" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } cout << "instance #" << instance->StepFileId() << endl; SDAI_Application_instance::iAMap_t::value_type v = instance->getInvAttr("isdefinedby"); iAstruct attr = v.second; //instance->getInvAttr(ia); - if(attr.a && attr.a->EntryCount()) { - cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; - } else { - cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void *) v.first << endl; - exitStatus = EXIT_FAILURE; - } + if( attr.a && attr.a->EntryCount() ) { + cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl; + } else { + cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void*) v.first << endl; + exitStatus = EXIT_FAILURE; + } - EntityAggregate *aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... - if(attr.a != aggr) { + EntityAggregate * aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile... + if( attr.a != aggr ) { cout << "Error! got different EntityAggregate's when using map vs method" << endl; exitStatus = EXIT_FAILURE; } - if(aggr && aggr->EntryCount()) { + if( aggr && aggr->EntryCount() ) { cout << "Found " << aggr->EntryCount() << " inverse references." << endl; } else { cout << "inverse attr is not defined" << endl; exitStatus = EXIT_FAILURE; } - exit(exitStatus); + exit( exitStatus ); } diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index ae6071ad0..3b9e17d04 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -41,75 +41,72 @@ // NOTE this test requires std::thread, part of C++11. It will fail to compile otherwise. -void readProgressParallel(STEPfile &f, float &maxProgress) -{ - while(1) { +void readProgressParallel( STEPfile & f, float & maxProgress ) { + while( 1 ) { float p = f.GetReadProgress(); - if(p > maxProgress) { + if( p > maxProgress ) { maxProgress = p; } - DELAY(5); + DELAY( 5 ); } } -void writeProgressParallel(STEPfile &f, float &maxProgress) -{ - while(1) { +void writeProgressParallel( STEPfile & f, float & maxProgress ) { + while( 1 ) { float p = f.GetWriteProgress(); - if(p > maxProgress) { + if( p > maxProgress ) { maxProgress = p; } - DELAY(5); + DELAY( 5 ); } } -int main(int argc, char *argv[]) -{ +int main( int argc, char * argv[] ) { float progress = 0.0; - if(argc != 2) { + if( argc != 2 ) { cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } - Registry registry(SchemaInit); + Registry registry( SchemaInit ); InstMgr instance_list; - STEPfile sfile(registry, instance_list, "", false); + STEPfile sfile( registry, instance_list, "", false ); // read the file - std::thread r(readProgressParallel, std::ref(sfile), std::ref(progress)); - sfile.ReadExchangeFile(argv[1]); + std::thread r( readProgressParallel, std::ref( sfile ), std::ref( progress ) ); + sfile.ReadExchangeFile( argv[1] ); r.detach(); Severity readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - if(progress < 55) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. + if( progress < 55 ) { //55 is arbitrary. should be >50 due to how GetReadProgress() works. cerr << "Error: Read progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { cout << "Read progress reached " << progress << "% - success." << endl; } progress = 0; // write the file - std::thread w(writeProgressParallel, std::ref(sfile), std::ref(progress)); - sfile.WriteExchangeFile("out.stp"); + std::thread w( writeProgressParallel, std::ref( sfile ), std::ref( progress ) ); + sfile.WriteExchangeFile( "out.stp" ); w.detach(); readSev = sfile.Error().severity(); - if(readSev != SEVERITY_NULL) { - sfile.Error().PrintContents(cout); - exit(EXIT_FAILURE); + if( readSev != SEVERITY_NULL ) { + sfile.Error().PrintContents( cout ); + exit( EXIT_FAILURE ); } - if(progress < 55) { + if( progress < 55 ) { cerr << "Error: Write progress (" << progress << ") never exceeded the threshold (55). Exiting." << endl; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE ); } else { cout << "Write progress reached " << progress << "% - success." << endl; } - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS ); } diff --git a/test/p21/CMakeLists.txt b/test/p21/CMakeLists.txt index 7d533f9ca..b16bdd7b3 100644 --- a/test/p21/CMakeLists.txt +++ b/test/p21/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #test part 21 files #necessary macros won't already be defined if SC_BUILD_SCHEMAS is set to "" From 97de8f90699b2c824a602c774f32b41d0a4cdf6e Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 8 Aug 2021 10:38:43 +0100 Subject: [PATCH 115/244] replace nullptr by NULL --- CMakeLists.txt | 3 --- include/sc_cf_cmake.h.in | 1 - src/base/CMakeLists.txt | 1 - src/base/sc_nullptr.h | 13 ------------- src/clstepcore/mgrnode.h | 4 +--- src/clstepcore/sdaiApplication_instance.cc | 4 +--- 6 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 src/base/sc_nullptr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d897264c0..7d6de746c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,9 +113,6 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) else() add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) - if(HAVE_NULLPTR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif(HAVE_NULLPTR) endif() include_directories( diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf_cmake.h.in index 6caec92aa..873be14bf 100644 --- a/include/sc_cf_cmake.h.in +++ b/include/sc_cf_cmake.h.in @@ -26,6 +26,5 @@ #cmakedefine HAVE_STD_THREAD 1 #cmakedefine HAVE_STD_CHRONO 1 -#cmakedefine HAVE_NULLPTR 1 #endif /* SCL_CF_H */ diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index cd41f97b6..04d5487d2 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -15,7 +15,6 @@ set(SC_BASE_HDRS sc_getopt.h sc_trace_fprintf.h sc_mkdir.h - sc_nullptr.h path2str.h judy/src/judy.h judy/src/judyLArray.h diff --git a/src/base/sc_nullptr.h b/src/base/sc_nullptr.h deleted file mode 100644 index 342397001..000000000 --- a/src/base/sc_nullptr.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef NULLPTR_H -#define NULLPTR_H - -#include - -#ifdef HAVE_NULLPTR -#include -#else -# define nullptr_t void* -# define nullptr NULL -#endif //HAVE_NULLPTR - -#endif //NULLPTR_H diff --git a/src/clstepcore/mgrnode.h b/src/clstepcore/mgrnode.h index 435b6aa70..eca3e19e7 100644 --- a/src/clstepcore/mgrnode.h +++ b/src/clstepcore/mgrnode.h @@ -25,15 +25,13 @@ class DisplayNode; #include -#include - class InstMgr; class SC_CORE_EXPORT MgrNodeBase : public GenericNode { public: virtual inline SDAI_Application_instance * GetSTEPentity() { abort(); - return nullptr; + return NULL; }; virtual ~MgrNodeBase() {}; }; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 2bbf6b31c..7d74361f2 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -20,8 +20,6 @@ #include "sdaiApplication_instance.h" #include "superInvAttrIter.h" -#include - SDAI_Application_instance NilSTEPentity; bool isNilSTEPentity( const SDAI_Application_instance * ai ) { @@ -956,7 +954,7 @@ const SDAI_Application_instance::iAMap_t::value_type SDAI_Application_instance:: } iAstruct z; memset( &z, 0, sizeof z ); - iAMap_t::value_type nil( (Inverse_attribute *) nullptr, z ); + iAMap_t::value_type nil( ( Inverse_attribute * ) NULL, z ); return nil; } From e617808be185307466190c5a7cd57e88d64f8c96 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 8 Aug 2021 12:28:17 +0100 Subject: [PATCH 116/244] simplify SC_VERSION and library versioning --- CMakeLists.txt | 24 ++++-- cmake/SC_Build_opts.cmake | 11 --- cmake/SC_CXX_schema_macros.cmake | 3 - cmake/SC_Config_Headers.cmake | 28 +------ cmake/SC_Targets.cmake | 6 +- cmake/sc_version_string.cmake | 84 ------------------- example/ap203min/CMakeLists.txt | 8 +- include/CMakeLists.txt | 5 +- src/exp2cxx/CMakeLists.txt | 4 - src/exp2cxx/classes_misc.c | 3 +- src/exp2python/CMakeLists.txt | 3 - src/exppp/pretty_schema.c | 3 +- src/express/CMakeLists.txt | 6 -- src/express/fedex.c | 3 +- src/express/info.c | 10 +-- src/test/p21read/p21read.cc | 3 +- test/cpp/schema_specific/attribute.cc | 1 - test/cpp/schema_specific/inverse_attr1.cc | 1 - test/cpp/schema_specific/inverse_attr2.cc | 1 - .../schema_specific/stepfile_rw_progress.cc | 1 - 20 files changed, 34 insertions(+), 174 deletions(-) delete mode 100644 cmake/sc_version_string.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d6de746c..8a585a95f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,13 +42,10 @@ project(SC) # SC version set(SC_VERSION_MAJOR 0) -set(SC_VERSION_MINOR 8-dev) -set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) +set(SC_VERSION_MINOR 9) +set(SC_VERSION_PATCH 1) +set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) -# 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) # Minimum required version of CMake cmake_minimum_required(VERSION 3.6.3) @@ -99,8 +96,8 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -# create config headers sc_cf.h and sc_version_string.h include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) +# create config headers sc_cf.h ################ @@ -144,6 +141,19 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) else() add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) endif() +if(NOT SC_IS_SUBBUILD) + #----------------------------------------------------------------------------- + # 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 ") + include(CPack) +endif(NOT SC_IS_SUBBUILD) + # 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. diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index 8ca942615..f725e0b87 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -144,17 +144,6 @@ if(NOT SC_IS_SUBBUILD) 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 ") - include(CPack) - #----------------------------------------------------------------------------- # Uninstall target # From http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 388d820a5..da47ab78c 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -28,10 +28,8 @@ endmacro(P21_TESTS sfile) macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) - #add_dependencies(p21read_${PROJECT_NAME} version_string) if(NOT WIN32) SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) - #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) #add user-defined executables @@ -39,7 +37,6 @@ macro(SCHEMA_EXES) get_filename_component(name ${src} NAME_WE) get_filename_component(path ${src} ABSOLUTE) SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${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) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 17d0c2774..712ebd5bb 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,4 +1,3 @@ -# 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 @@ -18,6 +17,7 @@ if(NOT COMMAND CONFIG_H_APPEND) 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}") +# create sc_cf.h include(CheckLibraryExists) include(CheckIncludeFile) @@ -101,32 +101,6 @@ 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. -if(SC_GIT_VERSION) - 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 - 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 -else(SC_GIT_VERSION) - set(VER_HDR " - #ifndef SC_VERSION_STRING - #define SC_VERSION_STRING - static char sc_version[512] = {\"${SC_VERSION}\"}; - #endif" - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}") -endif(SC_GIT_VERSION) -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 diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index 09204146c..cb2d11dd6 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -46,7 +46,11 @@ macro(SC_ADDLIB _addlib_target) if(${_arg_prefix}_SHARED) add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES}) - set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION}) + if(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) + else(OPENBSD) + set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) + endif(OPENBSD) if(APPLE) set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") endif(APPLE) diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake deleted file mode 100644 index ed53ac27e..000000000 --- a/cmake/sc_version_string.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# creates sc_version_string.h, which defines sc_version() -# sc_version() returns a pretty commit description and a build timestamp. - -# only update the file if the git commit has changed, because whenever the file is updated files including the header must rebuild -# parallel rebuilds can result in race conditions and failures, particularly when running ctest in parallel - -# http://stackoverflow.com/questions/3780667 -# http://www.cmake.org/pipermail/cmake/2009-February/027014.html - -set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") -set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@") - -set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h") - -#---------- find commit id ------------------ -#use git for a pretty commit id -#uses 'git describe --tags', so tags are required in the repo -#create a tag with 'git tag ' 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) - if(NOT SC_IS_SUBBUILD) - message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.") - endif(NOT SC_IS_SUBBUILD) - 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) -endif() -string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) - -#-------------- date and time --------------- - -if(SC_ENABLE_TESTING) - set (date_time_string "NA - disabled for testing") -else() - string(TIMESTAMP date_time_string UTC) -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" - ) - -#don't update the file unless something changed -string(RANDOM tmpsuffix) -file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string}) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER}) -execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix}) - -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 diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index 624ca44a4..f1fccb2ea 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -14,14 +14,14 @@ if(NOT DEFINED STEPCODE_ROOT_DIR) 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") +if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") 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") + if(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c") 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") + endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c") +endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c") # Use STEPcode as library, but build from this build process. diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 566c3780d..c0bb55054 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -35,9 +35,8 @@ install(FILES ordered_attrs.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) +install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h + DESTINATION ${INCLUDE_DIR}/stepcode) # Local Variables: # tab-width: 8 diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index fe438ad28..93cf8c911 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -39,10 +39,6 @@ include_directories( SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) -if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(exp2cxx version_string) -endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - if(SC_ENABLE_TESTING) add_subdirectory(test) endif(SC_ENABLE_TESTING) diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 4e24a8d24..4b5226912 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -4,7 +4,6 @@ #include "classes.h" #include -#include "sc_version_string.h" #include "class_strings.h" /** \file classes_misc.c @@ -44,7 +43,7 @@ FILE * FILEcreate( const char * filename ) { fprintf( file, "#ifndef %s\n", fn ); fprintf( file, "#define %s\n\n", fn ); - fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version ); + fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", SC_VERSION ); fprintf( file, "// You probably don't want to edit it since your modifications\n" ); fprintf( file, "// will be lost if exp2cxx is used to regenerate it.\n\n" ); return ( file ); diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index 0cbf338aa..a9feb39d2 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -31,9 +31,6 @@ if(SC_PYTHON_GENERATOR) ) SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(exp2python version_string) - endif(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) endif(SC_PYTHON_GENERATOR) # Local Variables: diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 6b555f379..c17ebe5be 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -108,7 +107,7 @@ char * SCHEMAout( Schema s ) { for( hp = expheader; *hp; hp++ ) { if( ( **hp == '\0' ) && ( **( hp + 1 ) == '\0' ) ) { /* if this and the next lines are blank, put version string on this line */ - raw( "%s\n", sc_version ); + raw( "%s\n", SC_VERSION ); } else { raw( "%s\n", *hp ); } diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 5ef962c83..ebf104e2d 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -141,9 +141,6 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) add_dependencies(express express_verify) endif() - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(express version_string) - endif() endif() if($CACHE{SC_BUILD_STATIC_LIBS}) @@ -157,9 +154,6 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) add_dependencies(express-static express_verify) endif() - if(NOT SC_IS_SUBBUILD AND SC_GIT_VERSION) - add_dependencies(express-static version_string) - endif() endif() SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) diff --git a/src/express/fedex.c b/src/express/fedex.c index 805f8aeed..c32989616 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -77,7 +77,6 @@ #include "sc_cf.h" #include "sc_memmgr.h" #include "sc_export.h" -#include "sc_version_string.h" #include "sc_getopt.h" #include "express/error.h" #include "express/express.h" @@ -92,7 +91,7 @@ char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string b static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */ void print_fedex_version( void ) { - fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, sc_version ); + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode and scl-dev on google groups\n", EXPRESSprogram_name, SC_VERSION ); no_need_to_work = 1; } diff --git a/src/express/info.c b/src/express/info.c index 50af7ab11..85553d667 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -4,14 +4,6 @@ #include "express/info.h" #include "express/express.h" -#ifndef SCHEMA_SCANNER -# include "sc_version_string.h" -#else - /* dummy string to make the compiler happy when building the schema scanner, - * should never be seen by users */ - const char * sc_version = "ERROR: version unknown / SCHEMA_SCANNER defined in libexpress!"; -#endif - char * EXPRESSversion( void ) { return( "Express Language, IS (N65), October 24, 1994" ); } @@ -19,7 +11,7 @@ char * EXPRESSversion( void ) { void EXPRESSusage( int _exit ) { fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } express_file\n", EXPRESSprogram_name ); fprintf( stderr, "where\t-v produces the following version description:\n" ); - fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version ); + fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, SC_VERSION ); fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" ); fprintf( stderr, "\t-w warning enable\n" ); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index f3fc1a3c6..cbdbcaa02 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -13,7 +13,6 @@ */ extern void SchemaInit( class Registry & ); -#include "sc_version_string.h" #include #include #include @@ -91,7 +90,7 @@ void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) { } void printVersion( const char * exe ) { - std::cout << exe << " build info: " << sc_version << std::endl; + std::cout << exe << " build info: " << SC_VERSION << std::endl; } void printUse( const char * exe ) { diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index bc624143a..a74cee078 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,7 +3,6 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include -#include "sc_version_string.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 3fd51454c..eafcc5404 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,7 +4,6 @@ ** */ #include -#include "sc_version_string.h" #include "SubSuperIterators.h" #include #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index d30eabe7b..2f3fdf233 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,7 +4,6 @@ ** */ #include -#include "sc_version_string.h" #include #include #include diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 3b9e17d04..e007c7f37 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -1,5 +1,4 @@ -#include "sc_version_string.h" #include #include #include From faadf26cdf7290e2cd3f675b3ef82c83e9cffa6a Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 8 Aug 2021 12:38:05 +0100 Subject: [PATCH 117/244] add missing feature define for stat S_IFDIR --- src/base/sc_mkdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c index 1a908155c..d0866f6e3 100644 --- a/src/base/sc_mkdir.c +++ b/src/base/sc_mkdir.c @@ -1,4 +1,4 @@ - +#define _XOPEN_SOURCE /* for S_IFDIR */ #include "sc_mkdir.h" #include From 6cf5d1e8607fffe145211640f6fe830a8cad17ee Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 8 Aug 2021 22:05:15 +0100 Subject: [PATCH 118/244] CMake update - variable usage, RPATHs, config header generation - remove the CMake core target --- CMakeLists.txt | 121 ++++++++++--- cmake/Path_Setup.cmake | 164 ++++++++++++++++++ cmake/SC_CXX_schema_macros.cmake | 8 +- cmake/SC_Config_Headers.cmake | 25 +-- cmake/schema_scanner/schemaScanner.cmake | 4 +- data/CMakeLists.txt | 2 +- .../cmake/External_STEPCode.cmake | 5 - include/CMakeLists.txt | 6 +- include/sc_cf.h.in | 32 ++++ src/base/CMakeLists.txt | 6 +- src/cldai/CMakeLists.txt | 6 +- src/cleditor/CMakeLists.txt | 6 +- src/cllazyfile/CMakeLists.txt | 9 +- src/clstepcore/CMakeLists.txt | 6 +- src/clutils/CMakeLists.txt | 6 +- src/exppp/CMakeLists.txt | 4 +- src/express/CMakeLists.txt | 4 +- test/cpp/schema_specific/CMakeLists.txt | 4 + 18 files changed, 336 insertions(+), 82 deletions(-) create mode 100644 cmake/Path_Setup.cmake create mode 100644 include/sc_cf.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a585a95f..2e355a3ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,13 @@ set(SC_VERSION_MINOR 9) set(SC_VERSION_PATCH 1) set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}) +# Set language standards +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # Minimum required version of CMake cmake_minimum_required(VERSION 3.6.3) @@ -56,26 +63,101 @@ cmake_policy(SET CMP0057 NEW) # 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") -if(NOT SC_IS_SUBBUILD) - set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}") -else(NOT SC_IS_SUBBUILD) - set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}") -endif(NOT SC_IS_SUBBUILD) +list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}") + +# OpenBSD has its own naming conventions. Set a platform variable based on +# the OS name so we can test for it succinctly. +if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") + set(OPENBSD ON) +endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*") + +#--------------------------------------------------------------------- +# Set up various relative path variables and build output directories +include(Path_Setup) + +#--------------------------------------------------------------------- +# 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 +if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH) + set(CMAKE_SKIP_BUILD_RPATH FALSE) +endif() + +# when building, don't use the install RPATH already +# (but later on when installing) +if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +endif() + +# the RPATH/INSTALL_NAME_DIR to be used when installing +if (NOT APPLE) + if(NOT DEFINED CMAKE_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib") + endif() +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 +if(NOT DEFINED CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +endif() + +# add the automatically determined parts of the RPATH which point to +# directories outside the build tree to the install RPATH +if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + + +#--------------------------------------------------------------------- +# Build options +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +option(BUILD_STATIC_LIBS "Build static libraries" OFF) -# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc -include(${SC_CMAKE_DIR}/SC_Build_opts.cmake) +option(SC_PYTHON_GENERATOR "Compile exp2python" ON) +option(SC_CPP_GENERATOR "Compile exp2cxx" ON) + +option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) +option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) + +option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) +if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) + set(CMAKE_CXX_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) +endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + +option(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) +endif(SC_ENABLE_TESTING) + +# TODO - BRL-CAD is the only known user of this option, and it will be +# transitioning to a new setup that won't need it - once that's done, +# we should just remove this option. +option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) +mark_as_advanced(SC_SKIP_EXEC_INSTALL) # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc -include(${SC_CMAKE_DIR}/SC_Targets.cmake) +include(SC_Targets) # Macros related to paths -include(${SC_CMAKE_DIR}/SC_Paths.cmake) +include(SC_Paths) # locale stuff -include(${SC_CMAKE_DIR}/SC_Locale.cmake) +include(SC_Locale) # logic related to regenerating the lexer and parser source code -include(${SC_CMAKE_DIR}/SC_Regenerate.cmake) +include(SC_Regenerate) + +# create config header sc_cf.h +include(SC_Config_Headers) 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") @@ -86,7 +168,7 @@ if(NOT DEFINED SC_BUILD_SCHEMAS) "** 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") + 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(NOT SC_IS_SUBBUILD) @@ -96,19 +178,17 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake) # create config headers sc_cf.h +include(SC_Config_Headers) ################ -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 11) - if(MSVC) # 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) -else() +endif() +if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) endif() @@ -134,13 +214,6 @@ if(SC_ENABLE_TESTING) endif(SC_ENABLE_TESTING) add_subdirectory(doc) -# 'make core' builds everything that isn't generated. for devs. -add_custom_target(core) -if($CACHE{SC_BUILD_SHARED_LIBS}) - add_dependencies(core stepdai stepeditor exp2cxx check-express) -else() - add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express) -endif() if(NOT SC_IS_SUBBUILD) #----------------------------------------------------------------------------- # SC Packaging diff --git a/cmake/Path_Setup.cmake b/cmake/Path_Setup.cmake new file mode 100644 index 000000000..f5db3b411 --- /dev/null +++ b/cmake/Path_Setup.cmake @@ -0,0 +1,164 @@ +# Copyright (c) 2010-2020 United States Government as represented by +# the U.S. Army Research Laboratory. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#--------------------------------------------------------------------- +# Define relative install locations. Don't set these if they have already +# been set by some other means (like a higher level CMakeLists.txt file +# including this one). + +# The location in which to install BRL-CAD executables. +if(NOT BIN_DIR) + set(BIN_DIR bin) +endif(NOT BIN_DIR) + +# Define a relative path that will "reset" a path back to +# the point before BIN_DIR was appended. This is primarily +# useful when working with generator expressions +unset(RBIN_DIR CACHE) +set(LBIN_DIR "${BIN_DIR}") +while (NOT "${LBIN_DIR}" STREQUAL "") + get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY) + set(LBIN_DIR "${LBDIR}") + if ("${RBIN_DIR}" STREQUAL "") + set(RBIN_DIR "..") + else ("${RBIN_DIR}" STREQUAL "") + set(RBIN_DIR "../${RBIN_DIR}") + endif ("${RBIN_DIR}" STREQUAL "") +endwhile (NOT "${LBIN_DIR}" STREQUAL "") + +# The location in which to install BRL-CAD libraries. +if(NOT LIB_DIR) + set(LIB_DIR lib) +endif(NOT LIB_DIR) +if(NOT LIBEXEC_DIR) + set(LIBEXEC_DIR libexec) +endif(NOT LIBEXEC_DIR) + +# The location in which to install BRL-CAD header files. +if(NOT INCLUDE_DIR) + set(INCLUDE_DIR include) +endif(NOT INCLUDE_DIR) + +# The location in which to install BRL-CAD data files +if(NOT DATA_DIR) + set(DATA_DIR share) +endif(NOT DATA_DIR) + +# The location in which to install BRL-CAD documentation files +if(NOT DOC_DIR) + set(DOC_DIR ${DATA_DIR}/doc) +endif(NOT DOC_DIR) + +# The location in which to install BRL-CAD Manual pages +if(NOT MAN_DIR) + set(MAN_DIR ${DATA_DIR}/man) +endif(NOT MAN_DIR) + +# Make sure no absolute paths have been supplied to these variables +set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC) +foreach(instdir ${INSTALL_DIRS}) + get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE) + if("${${instdir}_DIR}" STREQUAL "${instdir_full}") + message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"") + set(HAVE_INSTALL_DIR_FULL_PATH 1) + endif("${${instdir}_DIR}" STREQUAL "${instdir_full}") +endforeach(instdir ${INSTALL_DIRS}) + +#--------------------------------------------------------------------- +# Output directories - this is where built library and executable +# files will be placed after building but prior to install. The +# necessary variables change between single and multi configuration +# build systems, so it is necessary to handle both cases on a +# conditional basis. + +if(NOT CMAKE_CONFIGURATION_TYPES) + # If we're not doing multi-configuration, just set the three main + # variables to the correct values. + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} 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 ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) +else(NOT CMAKE_CONFIGURATION_TYPES) + # Multi-configuration is more difficult. Not only do we need to + # properly set the output directories, but we also need to + # identify the "toplevel" directory for each configuration so + # we can place files, documentation, etc. in the correct + # relative positions. Because files may be placed by CMake + # without a build target to put them in their proper relative build + # directory position using these paths, we must fully qualify them + # without using CMAKE_CFG_INTDIR. + # + # We define directories that may not be quite "standard" + # for a particular build tool - for example, native VS2010 projects use + # another directory to denote CPU type being compiled for - but CMake only + # supports multi-configuration setups having multiple configurations, + # not multiple compilers. + # + # One additional wrinkle we must watch for here is the case where + # a multi-configuration setup uses "." for its internal directory - + # if that's the case, we need to just set the various config output + # directories to the same value. + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}) + foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE}) + endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") + endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") + endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) + if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) + set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) + if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) + set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) + endforeach() +endif(NOT CMAKE_CONFIGURATION_TYPES) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index da47ab78c..016450c2c 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -93,7 +93,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ${SC_SOURCE_DIR}/src/base/judy/src ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation - if($CACHE{SC_BUILD_SHARED_LIBS}) + if(BUILD_SHARED_LIBS) SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) if(WIN32) @@ -102,6 +102,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj") endif() endif() + # TODO - ideally we would avoid generating code that triggers this warning, but figuring out + # how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings + # we get due to this issue so it doesn't mask other problems. + if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers") + endif() endif() if($CACHE{SC_BUILD_STATIC_LIBS}) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 712ebd5bb..f9a8cc86b 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,22 +1,3 @@ - -# 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}") # create sc_cf.h include(CheckLibraryExists) @@ -97,10 +78,8 @@ int main() {return !(f() == f());} endif(SC_ENABLE_CXX11) # 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) - +configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) # Local Variables: # tab-width: 8 diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index 0c345d931..affe5c5cc 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -71,9 +71,9 @@ message( STATUS "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}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_DIR}) else(WIN32) - install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR}) + install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR}) endif(WIN32) # macro SCHEMA_CMLIST diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 819403e6f..e6ef03d19 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,7 +10,7 @@ # .exp file inside, which it uses. otherwise, ${path} is assumed to # be an express file. -if(NOT ${SC_BUILD_EXPRESS_ONLY} AND NOT "${SC_BUILD_SCHEMAS}" STREQUAL "") +if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND 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) diff --git a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake index 62df14322..96fca295b 100644 --- a/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake +++ b/example/ap203min/ExternalProjectBuild/cmake/External_STEPCode.cmake @@ -22,8 +22,3 @@ ENDIF() SET( STEPCODE_BINARY_DIR ${BINARY_DIR} ) -# SC CMake does not honor -DCMAKE_INSTALL_PREFIX:PATH= -# Consequently, force Debug so it installs in ../sc-install directory -# instead of /usr/local/lib. -# -# SC's own programs fail to build with -DSC_BUILD_SHARED_LIBS=OFF \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index c0bb55054..da3ae5eb5 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,18 +22,18 @@ set(express_HDRS express/variable.h ) install(FILES ${express_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express) + DESTINATION ${INCLUDE_DIR}/stepcode/express) set(exppp_HDRS exppp/exppp.h ) install(FILES ${exppp_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp) + DESTINATION ${INCLUDE_DIR}/stepcode/exppp) install(FILES ordered_attrs.h sc_export.h sc_stdbool.h - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode) + DESTINATION ${INCLUDE_DIR}/stepcode) install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h DESTINATION ${INCLUDE_DIR}/stepcode) diff --git a/include/sc_cf.h.in b/include/sc_cf.h.in new file mode 100644 index 000000000..67d88c433 --- /dev/null +++ b/include/sc_cf.h.in @@ -0,0 +1,32 @@ +#ifndef SCL_CF_H +#define SCL_CF_H + +/**** Define statements for CMake ****/ +#cmakedefine SC_VERSION "@SC_VERSION@" +#cmakedefine HAVE_NDIR_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_PARAM_H 1 +#cmakedefine HAVE_SYSENT_H 1 +#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine HAVE_DIRENT_H 1 +#cmakedefine HAVE_STDBOOL_H 1 +#cmakedefine HAVE_PROCESS_H 1 +#cmakedefine HAVE_IO_H 1 + +#cmakedefine SC_TRACE_FPRINTF 1 +#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 + +#cmakedefine HAVE_ABS 1 +#cmakedefine HAVE_MEMCPY 1 +#cmakedefine HAVE_MEMMOVE 1 +#cmakedefine HAVE_GETOPT 1 +#cmakedefine HAVE_VSNPRINTF 1 + +#cmakedefine HAVE_SSIZE_T 1 + +#cmakedefine HAVE_STD_THREAD 1 +#cmakedefine HAVE_STD_CHRONO 1 +#cmakedefine HAVE_NULLPTR 1 + +#endif /* SCL_CF_H */ diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 04d5487d2..5aad0a929 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -32,7 +32,7 @@ if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) endif() -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base psapi) @@ -40,7 +40,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) if(WIN32) target_link_libraries(base-static psapi) @@ -61,7 +61,7 @@ if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src") install(FILES ${SC_BASE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base) + DESTINATION ${INCLUDE_DIR}/stepcode/base) # Local Variables: # tab-width: 8 diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 2978f8c7a..023ce1ab6 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -36,19 +36,19 @@ include_directories( set(_libdeps steputils base) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLDAI_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai) + DESTINATION ${INCLUDE_DIR}/stepcode/cldai) # Local Variables: # tab-width: 8 diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 4c40f73fc..6370bcacb 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -27,19 +27,19 @@ include_directories( ${SC_SOURCE_DIR}/src/clutils ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) endif() install(FILES ${SC_CLEDITOR_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor) + DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) # Local Variables: # tab-width: 8 diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index d737a9c89..b5e763628 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -32,22 +32,23 @@ include_directories( set(_libdeps stepcore stepdai steputils base stepeditor) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES $-static) +if(BUILD_STATIC_LIBS) + set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) endif() SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile) + DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) # Local Variables: # tab-width: 8 diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 937985fff..910235973 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -133,19 +133,19 @@ include_directories( set(_libdeps steputils stepdai base) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) endif() install(FILES ${SC_CLSTEPCORE_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore) + DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 2553f4fa5..514980ad9 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) @@ -33,7 +33,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) if(WIN32) target_link_libraries(steputils-static shlwapi) @@ -41,7 +41,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) endif() install(FILES ${SC_CLUTILS_HDRS} - DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils) + DESTINATION ${INCLUDE_DIR}/stepcode/clutils) # Local Variables: # tab-width: 8 diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 5d6b7a6f3..0d1fb9649 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories( ${SC_SOURCE_DIR}/src/express ) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if(BUILD_SHARED_LIBS) SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) set_target_properties(libexppp PROPERTIES PREFIX "") if(WIN32) @@ -38,7 +38,7 @@ if($CACHE{SC_BUILD_SHARED_LIBS}) endif() endif() -if($CACHE{SC_BUILD_STATIC_LIBS}) +if(BUILD_STATIC_LIBS) SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) set_target_properties(libexppp-static PROPERTIES PREFIX "") endif() diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index ebf104e2d..51ea8dbc0 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -127,7 +127,7 @@ SET(EXPRESS_PRIVATE_HDRS variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) -if($CACHE{SC_BUILD_SHARED_LIBS}) +if("$CACHE{SC_BUILD_SHARED_LIBS}" OR NOT "$CACHE{SC_BUILD_STATIC_LIBS}") SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) if(WIN32) target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) @@ -153,7 +153,7 @@ if($CACHE{SC_BUILD_STATIC_LIBS}) else() add_dependencies(express-static express_verify) endif() - + endif() SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index 39ce6541a..c96ea08f3 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -9,6 +9,10 @@ include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${ # added as a workaround for changed behavior in newer cmake # versions (changes somewhere between 2.8 and 3.1) function(get_sdai_incl_dir out_path_var sdai_lib) + if (NOT TARGET sdai_${sdai_lib}) + message("sdai_${sdai_lib} is not a target") + return() + endif (NOT TARGET sdai_${sdai_lib}) if(NOT "${sdai_${sdai_lib}_SOURCE_DIR}" STREQUAL "") set(${out_path_var} "${sdai_${sdai_lib}_SOURCE_DIR}" PARENT_SCOPE) return() From 736d637d639996fa9b66726e068b4108714d58f8 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 12 Aug 2021 19:28:11 -0400 Subject: [PATCH 119/244] Remove MD5 verification logic. --- src/express/CMakeLists.txt | 53 +------------------ src/express/generated/README | 19 +------ src/express/generated/verification_info.cmake | 7 --- 3 files changed, 3 insertions(+), 76 deletions(-) delete mode 100644 src/express/generated/verification_info.cmake diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 51ea8dbc0..a074a0f82 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -4,39 +4,6 @@ include_directories( ${SC_SOURCE_DIR}/src/base ) -# Set up the information we need to feed the generated source management -# scripts -set(BASELINE_INFORMATION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/generated/verification_info.cmake") -set(PROJECT_CMAKE_DIR "${SC_SOURCE_DIR}/cmake") -set(MD5_FILELIST - "${CMAKE_CURRENT_SOURCE_DIR}/expscan.l" - "${CMAKE_CURRENT_SOURCE_DIR}/expparse.y" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.c" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expscan.h" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.c" - "${CMAKE_CURRENT_SOURCE_DIR}/generated/expparse.h" - ) -configure_file(${SC_SOURCE_DIR}/cmake/md5_gen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake @ONLY) -configure_file(${SC_SOURCE_DIR}/cmake/md5_verify.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake @ONLY) - -# Convenience target to generate an updated verification_info.cmake file -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel - ) -add_custom_target(express_md5gen DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_md5gen.sentinel) - -# Target for actually checking cached MD5 sums against files -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel - DEPENDS ${MD5_FILELIST} - ) -add_custom_target(express_verify DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/express_verify.sentinel) - - # Depending on whether we're using pre-generated sources or building them on # the fly, set up targets and source lists. if(SC_GENERATE_LP_SOURCES) @@ -87,6 +54,8 @@ foreach(_src ${EXPRESS_SOURCES}) string(REPLACE "." "_" _suffix ${_src}) set(_objlib "objlib_${_suffix}") add_library(${_objlib} OBJECT ${_src}) + add_dependencies(${_objlib} objlib_expscan_c) + add_dependencies(${_objlib} objlib_expparse_c) # TODO: probably PIC should be used everywhere... set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) list(APPEND EXPRESS_OBJS $) @@ -132,28 +101,10 @@ if("$CACHE{SC_BUILD_SHARED_LIBS}" OR NOT "$CACHE{SC_BUILD_STATIC_LIBS}") if(WIN32) target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) endif() - - if(SC_GENERATE_LP_SOURCES) - add_custom_command(TARGET express POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - ) - else() - add_dependencies(express express_verify) - endif() - endif() if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) - - if(SC_GENERATE_LP_SOURCES) - add_custom_command(TARGET express-static POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake - ) - else() - add_dependencies(express-static express_verify) - endif() - endif() SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) diff --git a/src/express/generated/README b/src/express/generated/README index 7ca0ac13a..fef02da84 100644 --- a/src/express/generated/README +++ b/src/express/generated/README @@ -5,21 +5,4 @@ lexing and parsing logic. DO NOT EDIT THESE FILES. They are machine generated and should not be modified directly - bugs in these files need to be fixed in either the -Perplex/RE2C/Lemon input files or the tools themselves. Directly changing -these files will result in a build failure. - -If changes need to be made, the correct approach is: - -1. install Perplex, RE2C, and Lemon -2. make any necessary fixes to the input files and/or the generator tools. -3. run the build, and copy the new generated expscan and expparse c and h - files to this directory. -4. run the build target "express_md5gen" to generate a new verification_info.cmake - file, and copy that file into this directory as well. - -The verification_info.cmake file in this directory is used by CMake to protect -the integrity of the generated files. - -If iterative debugging is necessary, set the cmake configure variable -DEBUGGING_GENERATED_SOURCES to avoid having to update generated sources and md5 -sums each time an input file is changed. +Perplex/RE2C/Lemon input files or the tools themselves. diff --git a/src/express/generated/verification_info.cmake b/src/express/generated/verification_info.cmake deleted file mode 100644 index b3d7b3608..000000000 --- a/src/express/generated/verification_info.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Autogenerated verification information -set(baseline_expscan_l_md5 c86358d3e57ce6916c28a63262fad6e6) -set(baseline_expparse_y_md5 3722242f16c679c40323317833757a6d) -set(baseline_expscan_c_md5 b6b239869e4c7d169107fe45f760ffa0) -set(baseline_expscan_h_md5 3052c058a37045b43f96e4c04039bce3) -set(baseline_expparse_c_md5 c170b5e39b5fe56e2c39288fbe2b48a1) -set(baseline_expparse_h_md5 e4a5599839b2a9f7a6915a0dcc7747b0) From f7e929fe6a4465b3a2c3fbd2740a39b7d30049b8 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 14 Aug 2021 11:18:22 +0100 Subject: [PATCH 120/244] Add DLL defines for obj libs --- src/express/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index a074a0f82..e28b7489a 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -22,6 +22,13 @@ else(SC_GENERATE_LP_SOURCES) include_directories(generated) endif(SC_GENERATE_LP_SOURCES) +if(MSVC) + set_property(TARGET objlib_expscan_c APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") + set_property(TARGET objlib_expscan_c APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") + set_property(TARGET objlib_expparse_c APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") + set_property(TARGET objlib_expparse_c APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") +endif(MSVC) + set(EXPRESS_SOURCES symbol.c type.c @@ -56,6 +63,10 @@ foreach(_src ${EXPRESS_SOURCES}) add_library(${_objlib} OBJECT ${_src}) add_dependencies(${_objlib} objlib_expscan_c) add_dependencies(${_objlib} objlib_expparse_c) + if(MSVC) + set_property(TARGET ${_objlib} APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") + set_property(TARGET ${_objlib} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") + endif(MSVC) # TODO: probably PIC should be used everywhere... set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) list(APPEND EXPRESS_OBJS $) From 14c5476537988308e216c1918a5fe3abb4b46bdc Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 12 Aug 2021 19:50:07 -0400 Subject: [PATCH 121/244] Use straight-up CMake commands in lieu of wrapping The basic CMake commands are more straightforward to work with for someone not familiar with stepcode, and we don't really have enough targets w/ apply-this-to-everything add-ons to need the more elaborate logic the way BRL-CAD does (which is what originally inspired them.) --- src/express/CMakeLists.txt | 58 +++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index e28b7489a..b06d24210 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -85,6 +85,36 @@ if(SC_GENERATE_LP_SOURCES) set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") endif() +if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) + add_library(express SHARED ${EXPRESS_OBJS}) + target_link_libraries(express base) + if(OPENBSD) + set_target_properties(express PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) + else(OPENBSD) + set_target_properties(express PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR}) + endif(OPENBSD) + if(APPLE) + set_property(TARGET express APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress") + endif(APPLE) + install(TARGETS express + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) + + if(MSVC) + set_property(TARGET express APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") + set_property(TARGET express APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") + endif(MSVC) +endif() + +if(BUILD_STATIC_LIBS) + add_library(express-static STATIC ${EXPRESS_OBJS}) + install(TARGETS express-static + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) +endif() + # TODO # Currently, fedex.c provides the main() for multiple programs. These programs # provide custom behavior by defining EXPRESSinit_init (called by fedex.c's @@ -99,26 +129,16 @@ set(CHECK_EXPRESS_SOURCES inithook.c ) -SET(EXPRESS_PRIVATE_HDRS - exptoks.h - stack.h - ) - -variable_watch(SC_ADDLIB_EXPRESS_ARG_LINK_LIBRARIES) -variable_watch(SC_ADDLIB_EXPRESS-STATIC_ARG_LINK_LIBRARIES) - -if("$CACHE{SC_BUILD_SHARED_LIBS}" OR NOT "$CACHE{SC_BUILD_STATIC_LIBS}") - SC_ADDLIB(express SHARED SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base) - if(WIN32) - target_compile_definitions(express PRIVATE SC_EXPRESS_DLL_EXPORTS) - endif() +add_executable(check-express ${CHECK_EXPRESS_SOURCES}) +if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) + target_link_libraries(check-express express base) +else() + target_link_libraries(check-express express-static base-static) endif() - -if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(express-static STATIC SOURCES "dummy.c" ${EXPRESS_OBJS} LINK_LIBRARIES base-static) -endif() - -SC_ADDEXEC(check-express SOURCES ${CHECK_EXPRESS_SOURCES} LINK_LIBRARIES express base ${SC_EXEC_NOINSTALL}) +install(TARGETS check-express + RUNTIME DESTINATION ${BIN_DIR} + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR}) if(SC_ENABLE_TESTING) add_subdirectory(test) From 5ea56aac02f2333b2473d28f831d4bf2f002abdd Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 9 Aug 2021 16:29:43 -0400 Subject: [PATCH 122/244] update build system (cherry picked from commit b1844be9cc097d86eac1e70beb0c247c35d01f0c) --- cmake/SC_Regenerate.cmake | 48 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/cmake/SC_Regenerate.cmake b/cmake/SC_Regenerate.cmake index 513b4787a..8c4264681 100644 --- a/cmake/SC_Regenerate.cmake +++ b/cmake/SC_Regenerate.cmake @@ -1,4 +1,4 @@ -# The Express parser uses the tools Perplex, RE2C and Lemon to generate code +# The Express parser uses the tools 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. @@ -10,45 +10,37 @@ # 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") + +set(_valid_gen_states AUTO ON OFF) +set(_verbosity "QUIET") + +set(SC_GENERATE_LEXER_PARSER "AUTO" CACHE + STRING "Use Perplex, RE2C and Lemon to generate C source code.") +set_property(CACHE SC_GENERATE_LEXER_PARSER PROPERTY STRINGS ${_valid_gen_states}) +string(TOUPPER "${SC_GENERATE_LEXER_PARSER}" SC_GENERATE_LEXER_PARSER) + +if(NOT "${SC_GENERATE_LEXER_PARSER}" IN_LIST _valid_gen_states) 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") +endif() # If the generators have not been turned off, we need to check for them if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF") + # NOTE: lemon doesn't have a stable versioning system (it's always 1) 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}") - + find_package(RE2C 1.0.3 ${_verbosity}) + + if(LEMON_FOUND AND RE2C_FOUND) 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) + message(".. Found re2c, and lemon - can regenerate lexer/parser if necessary") + else() 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") + message(FATAL_ERROR "\nSC_GENERATE_LEXER_PARSER set to ON, but couldn't find lemon/re2c") 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) + endif() else(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF") set(SC_GENERATE_LP_SOURCES 0) endif(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF") From 22c437d45eceaaeaa98956abb4b54244aa2c3b15 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 28 May 2018 15:18:23 +0100 Subject: [PATCH 123/244] Simplify the Lemon and RE2C modules Original work adapted from commits: b1844be9cc097d86eac1e70beb0c247c35d01f0c 92cb70de2b60c9dd9e9300009897a5f025acb94d --- cmake/FindLEMON.cmake | 252 +++++++++++++++++---------------------- cmake/FindRE2C.cmake | 271 +++++++++++++++++++++++------------------- 2 files changed, 260 insertions(+), 263 deletions(-) diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index 19aa0d500..004ac5ecb 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -47,158 +47,126 @@ find_program(LEMON_EXECUTABLE lemon DOC "path to the lemon executable") mark_as_advanced(LEMON_EXECUTABLE) -if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - # look for the template in share - if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") - set (LEMON_TEMPLATE "${DATA_DIR}/lemon/lempar.c") - elseif (EXISTS "share/lemon/lempar.c") - set (LEMON_TEMPLATE "share/lemon/lempar.c") - elseif (EXISTS "/usr/share/lemon/lempar.c") - set (LEMON_TEMPLATE "/usr/share/lemon/lempar.c") - endif (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") -endif (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - -if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - # look for the template in bin dir - get_filename_component(lemon_path ${LEMON_EXECUTABLE} PATH) - if (lemon_path) - if (EXISTS ${lemon_path}/lempar.c) - set (LEMON_TEMPLATE "${lemon_path}/lempar.c") - endif (EXISTS ${lemon_path}/lempar.c) - if (EXISTS /usr/share/lemon/lempar.c) - set (LEMON_TEMPLATE "/usr/share/lemon/lempar.c") - endif (EXISTS /usr/share/lemon/lempar.c) - endif (lemon_path) -endif(LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - -if (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - # fallback - set (LEMON_TEMPLATE "lempar.c") - if (NOT EXISTS ${LEMON_TEMPLATE}) - message(WARNING "Lemon's lempar.c template file could not be found automatically, set LEMON_TEMPLATE") - endif (NOT EXISTS ${LEMON_TEMPLATE}) -endif (LEMON_EXECUTABLE AND NOT LEMON_TEMPLATE) - -mark_as_advanced(LEMON_TEMPLATE) +if (LEMON_EXECUTABLE) + if(NOT LEMON_TEMPLATE) + # look for the template, if we've not already been told where it is + if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c") + find_file(LEMON_TEMPLATE lempar.c + PATHS "${DATA_DIR}/lemon/lempar.c" + NO_DEFAULT_PATH) + endif () + + # If the above did not succeed, check standard locations + get_filename_component(lemon_dir ${LEMON_EXECUTABLE} DIRECTORY) + find_file(LEMON_TEMPLATE lempar.c + PATHS "${lemon_dir}" "/usr/share/lemon" + NO_DEFAULT_PATH) + mark_as_advanced(LEMON_TEMPLATE) + endif() + + # We need a template to be able to use lemon correctly + if(NOT LEMON_TEMPLATE) + message(FATAL_ERROR "Failed to find lemon template file (lempar.c) - need to set LEMON_TEMPLATE") + endif() + + # Define the function + # LEMON_TARGET( + # []) + # which will create a custom rule to generate a parser. is + # the path to a lemon file. is the desired name for the + # generated source file. is the desired name for the + # generated header which contains the token list. Anything in the optional + # parameter is appended to the lemon command line. + # + # ==================================================================== + # Example: + # + # find_package(LEMON) + # LEMON_TARGET(MyParser parser.y parser.c parser.h) + # add_executable(Foo main.cpp ${LEMON_MyParser_OUTPUTS}) + # ==================================================================== + + include(CMakeParseArguments) + + if(NOT COMMAND LEMON_TARGET) + function(LEMON_TARGET Name LemonInput LemonOutput) + set(LT_ARGS DEFINES_FILE COMPILE_FLAGS) + cmake_parse_arguments(LEMON_TARGET_ARG "" "${LT_ARGS}" "" ${ARGN}) + + if(NOT "${LEMON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") + set(LEMON_EXECUTABLE_opts "${LEMON_TARGET_ARG_COMPILE_FLAGS}") + separate_arguments(LEMON_EXECUTABLE_opts) + else() + set(LEMON_EXECUTABLE_opts "") + endif() + + # check for LemonOutput + get_filename_component(_basename ${LemonOutput} NAME_WE) + get_filename_component(_out_src_file ${LemonOutput} NAME) + get_filename_component(_out_dir ${LemonOutput} PATH) + if(NOT "${_out_dir}" STREQUAL "") + message(WARNING "Full path specified for LemonOutput - should be filename only") + endif() + + # set report file + set(_out_rpt_file "${_basename}.out") + + # check for DEFINES_FILE + if ("${LEMON_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + set(_out_hdr_file "${_basename}.h") + else() + get_filename_component(_out_dir ${LEMON_TARGET_ARG_DEFINES_FILE} PATH) + get_filename_component(_out_hdr_file ${LEMON_TARGET_ARG_DEFINES_FILE} NAME) + if(NOT "${_out_dir}" STREQUAL "") + message(WARNING "Full path specified for DEFINES_FILE - should be filename only") + endif() + endif() + + # input file + get_filename_component(_in_y_path ${LemonInput} ABSOLUTE) + get_filename_component(_in_y_file ${LemonInput} NAME) + + # TODO: is this really necessary? + add_custom_command( + OUTPUT ${_in_y_file} + COMMAND ${CMAKE_COMMAND} -E copy ${_in_y_path} ${CMAKE_CURRENT_BINARY_DIR} + ) -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LEMON DEFAULT_MSG LEMON_EXECUTABLE LEMON_TEMPLATE) - -# Define the macro -# LEMON_TARGET( -# []) -# which will create a custom rule to generate a parser. is -# the path to a lemon file. is the desired name for the -# generated source file. is the desired name for the -# generated header which contains the token list. Anything in the optional -# parameter is appended to the lemon command line. -# -# ==================================================================== -# Example: -# -# find_package(LEMON) -# LEMON_TARGET(MyParser parser.y parser.c parser.h) -# add_executable(Foo main.cpp ${LEMON_MyParser_OUTPUTS}) -# ==================================================================== - -include(CMakeParseArguments) - -if(NOT COMMAND LEMON_TARGET) - macro(LEMON_TARGET Name Input) - - get_filename_component(IN_FILE_WE ${Input} NAME_WE) - set(LVAR_PREFIX ${Name}_${IN_FILE_WE}) - - if(${ARGC} GREATER 3) - CMAKE_PARSE_ARGUMENTS(${LVAR_PREFIX} "" "OUT_SRC_FILE;OUT_HDR_FILE;WORKING_DIR;EXTRA_ARGS" "" ${ARGN}) - endif(${ARGC} GREATER 3) - - # Need a working directory - if("${${LVAR_PREFIX}_WORKING_DIR}" STREQUAL "") - set(${LVAR_PREFIX}_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LVAR_PREFIX}") - endif("${${LVAR_PREFIX}_WORKING_DIR}" STREQUAL "") - file(MAKE_DIRECTORY ${${LVAR_PREFIX}_WORKING_DIR}) - - # Output source file - if ("${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "") - set(${LVAR_PREFIX}_OUT_SRC_FILE ${${LVAR_PREFIX}_WORKING_DIR}/${IN_FILE_WE}.c) - else ("${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "") - get_filename_component(specified_out_dir ${${LVAR_PREFIX}_OUT_SRC_FILE} PATH) - if(NOT "${specified_out_dir}" STREQUAL "") - message(FATAL_ERROR "\nFull path specified for OUT_SRC_FILE - should be filename only.\n") - endif(NOT "${specified_out_dir}" STREQUAL "") - set(${LVAR_PREFIX}_OUT_SRC_FILE ${${LVAR_PREFIX}_WORKING_DIR}/${${LVAR_PREFIX}_OUT_SRC_FILE}) - endif ("${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "") - - # Output header file - if ("${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "") - set(${LVAR_PREFIX}_OUT_HDR_FILE ${${LVAR_PREFIX}_WORKING_DIR}/${IN_FILE_WE}.h) - else ("${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "") - get_filename_component(specified_out_dir ${${LVAR_PREFIX}_OUT_HDR_FILE} PATH) - if(NOT "${specified_out_dir}" STREQUAL "") - message(FATAL_ERROR "\nFull path specified for OUT_HDR_FILE - should be filename only.\n") - endif(NOT "${specified_out_dir}" STREQUAL "") - set(${LVAR_PREFIX}_OUT_HDR_FILE ${${LVAR_PREFIX}_WORKING_DIR}/${${LVAR_PREFIX}_OUT_HDR_FILE}) - endif ("${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "") - - # input file - get_filename_component(in_full ${Input} ABSOLUTE) - if("${in_full}" STREQUAL "${Input}") - set(lemon_in_file ${Input}) - else("${in_full}" STREQUAL "${Input}") - set(lemon_in_file "${CMAKE_CURRENT_SOURCE_DIR}/${Input}") - endif("${in_full}" STREQUAL "${Input}") - - - # names of lemon output files will be based on the name of the input file - set(LEMON_GEN_SOURCE ${${LVAR_PREFIX}_WORKING_DIR}/${IN_FILE_WE}.c) - set(LEMON_GEN_HEADER ${${LVAR_PREFIX}_WORKING_DIR}/${IN_FILE_WE}.h) - set(LEMON_GEN_OUT ${${LVAR_PREFIX}_WORKING_DIR}/${IN_FILE_WE}.out) - - # copy input to bin directory and run lemon - get_filename_component(INPUT_NAME ${Input} NAME) - add_custom_command( - OUTPUT ${LEMON_GEN_OUT} ${LEMON_GEN_SOURCE} ${LEMON_GEN_HEADER} - COMMAND ${CMAKE_COMMAND} -E copy ${lemon_in_file} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} - COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME} ${${LVAR_PREFIX}__EXTRA_ARGS} - DEPENDS ${Input} ${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_TARGET} - WORKING_DIRECTORY ${${LVAR_PREFIX}_WORKING_DIR} - COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" - ) - - # rename generated outputs - if(NOT "${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "${LEMON_GEN_SOURCE}") + # execute lemon add_custom_command( - OUTPUT ${${LVAR_PREFIX}_OUT_SRC_FILE} - COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${${LVAR_PREFIX}_OUT_SRC_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} + OUTPUT ${_out_src_file} + COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file} + DEPENDS ${_in_y_file} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" ) - set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_SRC_FILE} ${LEMON_${Name}_OUTPUTS}) - endif(NOT "${${LVAR_PREFIX}_OUT_SRC_FILE}" STREQUAL "${LEMON_GEN_SOURCE}") - if(NOT "${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "${LEMON_GEN_HEADER}") + + # rename the header add_custom_command( - OUTPUT ${${LVAR_PREFIX}_OUT_HDR_FILE} - COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${${LVAR_PREFIX}_OUT_HDR_FILE} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} + OUTPUT ${_out_hdr_file} + COMMAND ${CMAKE_COMMAND} ARGS -E rename ${_basename}.h ${_out_hdr_file} + DEPENDS ${_out_src_file} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - set(LEMON_${Name}_OUTPUTS ${${LVAR_PREFIX}_OUT_HDR_FILE} ${LEMON_${Name}_OUTPUTS}) - endif(NOT "${${LVAR_PREFIX}_OUT_HDR_FILE}" STREQUAL "${LEMON_GEN_HEADER}") - set(LEMON_${Name}_OUTPUTS ${LEMON_${Name}_OUTPUTS} ${LEMON_GEN_OUT}) + # set the return values + # TODO: for generated sources even headers should be target dependencies + set(LEMON_${Name}_DEFINED TRUE PARENT_SCOPE) + set(LEMON_${Name}_OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${_out_hdr_file}" PARENT_SCOPE) + set(LEMON_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) + set(LEMON_${Name}_OUTPUTS "${_out_src_file}" PARENT_SCOPE) - # make sure we clean up generated output and copied input - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}") - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${${LVAR_PREFIX}_WORKING_DIR}/${INPUT_NAME}") + # make sure we clean up generated output and copied input + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}") - # macro ran successfully - set(LEMON_${Name}_DEFINED TRUE) + endfunction(LEMON_TARGET) + endif(NOT COMMAND LEMON_TARGET) - set(LEMON_${Name}_SRC ${${LVAR_PREFIX}_OUT_SRC_FILE}) - set(LEMON_${Name}_HDR ${${LVAR_PREFIX}_OUT_HDR_FILE}) - set(LEMON_${Name}_INCLUDE_DIR ${${LVAR_PREFIX}_WORKING_DIR}) +endif(LEMON_EXECUTABLE) - endmacro(LEMON_TARGET) -endif(NOT COMMAND LEMON_TARGET) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LEMON REQUIRED_VARS LEMON_EXECUTABLE LEMON_TEMPLATE) #============================================================ # FindLEMON.cmake ends here diff --git a/cmake/FindRE2C.cmake b/cmake/FindRE2C.cmake index 5450c34a9..cab426eef 100644 --- a/cmake/FindRE2C.cmake +++ b/cmake/FindRE2C.cmake @@ -6,134 +6,163 @@ find_program(RE2C_EXECUTABLE re2c DOC "path to the re2c executable") mark_as_advanced(RE2C_EXECUTABLE) -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(RE2C DEFAULT_MSG RE2C_EXECUTABLE) +if(RE2C_EXECUTABLE) -# Provide a macro to generate custom build rules: + execute_process(COMMAND ${RE2C_EXECUTABLE} -v + OUTPUT_VARIABLE RE2C_version_output + ERROR_VARIABLE RE2C_version_error + RESULT_VARIABLE RE2C_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE) -# RE2C_TARGET(Name RE2CInput RE2COutput [COMPILE_FLAGS ]) -# which creates a custom command to generate the file from -# the file. If COMPILE_FLAGS option is specified, the next -# parameter is added to the re2c command line. Name is an alias used to -# get details of this custom command. + if(NOT ${RE2C_version_result} EQUAL 0) + message(SEND_ERROR + "Command \"${RE2C_EXECUTABLE} -v\" failed with output:\n${RE2C_version_output}\n${RE2C_version_error}") + else() + string(REGEX REPLACE "^re2c ([0-9]+[^ ]*)( .*)?$" "\\1" RE2C_VERSION "${RE2C_version_output}") + endif() -# This module also defines a macro: -# ADD_RE2C_LEMON_DEPENDENCY(RE2CTarget LemonTarget) -# which adds the required dependency between a scanner and a parser -# where and are the first parameters of -# respectively RE2C_TARGET and LEMON_TARGET macros. -# -# ==================================================================== -# Example: -# -# find_package(LEMON) -# find_package(RE2C) -# -# LEMON_TARGET(MyParser parser.y "${CMAKE_CURRENT_BINARY_DIR}/parser.cpp") -# RE2C_TARGET(MyScanner scanner.re "${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp") -# ADD_RE2C_LEMON_DEPENDENCY(MyScanner MyParser) -# -# include_directories("${CMAKE_CURRENT_BINARY_DIR}") -# add_executable(Foo -# Foo.cc -# ${LEMON_MyParser_OUTPUTS} -# ${RE2C_MyScanner_OUTPUTS} -# ) -# ==================================================================== -# -#============================================================================= -# Copyright (c) 2010-2016 United States Government as represented by -# the U.S. Army Research Laboratory. -# 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. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= + # Provide a macro to generate custom build rules: -#============================================================ -# RE2C_TARGET (public macro) -#============================================================ -# -# TODO - rework this macro to make use of CMakeParseArguments, see -# http://www.cmake.org/pipermail/cmake/2012-July/051309.html -if(NOT COMMAND RE2C_TARGET) - macro(RE2C_TARGET Name Input Output) - set(RE2C_TARGET_usage "RE2C_TARGET( [COMPILE_FLAGS ]") - if(${ARGC} GREATER 3) - if(${ARGC} EQUAL 5) - if("${ARGV3}" STREQUAL "COMPILE_FLAGS") - set(RE2C_EXECUTABLE_opts "${ARGV4}") - SEPARATE_ARGUMENTS(RE2C_EXECUTABLE_opts) + # RE2C_TARGET(Name RE2CInput RE2COutput [COMPILE_FLAGS ]) + # which creates a custom command to generate the file from + # the file. If COMPILE_FLAGS option is specified, the next + # parameter is added to the re2c command line. Name is an alias used to + # get details of this custom command. + + # This module also defines a macro: + # ADD_RE2C_LEMON_DEPENDENCY(RE2CTarget LemonTarget) + # which adds the required dependency between a scanner and a parser + # where and are the first parameters of + # respectively RE2C_TARGET and LEMON_TARGET macros. + # + # ==================================================================== + # Example: + # + # find_package(LEMON) + # find_package(RE2C) + # + # LEMON_TARGET(MyParser parser.y "${CMAKE_CURRENT_BINARY_DIR}/parser.cpp") + # RE2C_TARGET(MyScanner scanner.re "${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp") + # ADD_RE2C_LEMON_DEPENDENCY(MyScanner MyParser) + # + # include_directories("${CMAKE_CURRENT_BINARY_DIR}") + # add_executable(Foo + # Foo.cc + # ${LEMON_MyParser_OUTPUTS} + # ${RE2C_MyScanner_OUTPUTS} + # ) + # ==================================================================== + # + #============================================================================= + # Copyright (c) 2010-2016 United States Government as represented by + # the U.S. Army Research Laboratory. + # 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. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #============================================================================= + + #============================================================ + # RE2C_TARGET (public macro) + #============================================================ + # + if(NOT COMMAND RE2C_TARGET) + function(RE2C_TARGET Name RE2CInput RE2COutput) + set(_re2c_args COMPILE_FLAGS DEFINES_FILE) + cmake_parse_arguments(RE2C_TARGET_ARG "" "${_re2c_args}" "" ${ARGN}) + + if(NOT "${RE2C_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "") + message(SEND_ERROR "RE2C_TARGET( + [COMPILE_FLAGS ] + [DEFINES_FILE ])") + else() + if(NOT "${RE2C_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") + set(RE2C_EXECUTABLE_opts "${RE2C_TARGET_ARG_COMPILE_FLAGS}") + separate_arguments(RE2C_EXECUTABLE_opts) else() - message(SEND_ERROR ${RE2C_TARGET_usage}) + set(RE2C_EXECUTABLE_opts "") endif() - else() - message(SEND_ERROR ${RE2C_TARGET_usage}) + + if(NOT "${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + list(APPEND RE2C_EXECUTABLE_opts -t ${RE2C_TARGET_ARG_DEFINES_FILE}) + endif() + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RE2COutput} + COMMAND ${RE2C_EXECUTABLE} + ARGS ${RE2C_EXECUTABLE_opts} -o ${RE2COutput} ${CMAKE_CURRENT_SOURCE_DIR}/${RE2CInput} + DEPENDS ${RE2CInput} + COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + + # TODO: check, for generated sources headers should be included in outputs + set(RE2C_${Name}_DEFINED TRUE PARENT_SCOPE) + set(RE2C_${Name}_OUTPUTS ${RE2COutput} PARENT_SCOPE) + if("${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + set(RE2C_${Name}_OUTPUT_HEADER "" PARENT_SCOPE) + else() + set(RE2C_${Name}_OUTPUT_HEADER "${RE2C_TARGET_ARG_DEFINES_FILE}" PARENT_SCOPE) + endif() + set(RE2C_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) endif() - endif() - - add_custom_command(OUTPUT ${Output} - COMMAND ${RE2C_EXECUTABLE} - ARGS ${RE2C_EXECUTABLE_opts} -o${Output} ${Input} - DEPENDS ${Input} ${RE2C_EXECUTABLE_TARGET} - COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") - - set(RE2C_${Name}_DEFINED TRUE) - set(RE2C_${Name}_OUTPUTS ${Output}) - set(RE2C_${Name}_INPUT ${Input}) - set(RE2C_${Name}_COMPILE_FLAGS ${RE2C_EXECUTABLE_opts}) - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${Output}") - endmacro(RE2C_TARGET) -endif(NOT COMMAND RE2C_TARGET) -#============================================================ - -#============================================================ -# ADD_RE2C_LEMON_DEPENDENCY (public macro) -#============================================================ -# -if(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY) - macro(ADD_RE2C_LEMON_DEPENDENCY RE2CTarget LemonTarget) - - if(NOT RE2C_${RE2CTarget}_OUTPUTS) - message(SEND_ERROR "RE2C target `${RE2CTarget}' does not exists.") - endif() - - if(NOT LEMON_${LemonTarget}_HDR) - message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.") - endif() - - set_source_files_properties(${RE2C_${RE2CTarget}_OUTPUTS} - PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_HDR}) - endmacro(ADD_RE2C_LEMON_DEPENDENCY) -endif(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY) -#============================================================ + + endfunction(RE2C_TARGET) + endif(NOT COMMAND RE2C_TARGET) + #============================================================ + + #============================================================ + # ADD_RE2C_LEMON_DEPENDENCY (public macro) + #============================================================ + # + if(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY) + function(ADD_RE2C_LEMON_DEPENDENCY RE2CTarget LemonTarget) + + if(NOT RE2C_${RE2CTarget}_OUTPUTS) + message(SEND_ERROR "RE2C target `${RE2CTarget}' does not exists.") + endif() + + if(NOT LEMON_${LemonTarget}_OUTPUT_HEADER) + message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.") + endif() + + set_source_files_properties(${RE2C_${RE2CTarget}_OUTPUTS} + PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER}) + endfunction(ADD_RE2C_LEMON_DEPENDENCY) + endif(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY) + #============================================================ + +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(RE2C REQUIRED_VARS RE2C_EXECUTABLE + VERSION_VAR RE2C_VERSION) # RE2C_Util.cmake ends here From 8c9b3471fbeaced0118efa5dad90e581fd52334b Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 12 Aug 2021 18:19:09 -0400 Subject: [PATCH 124/244] Build again w/ the generator tools. --- cmake/FindLEMON.cmake | 5 ++++- cmake/FindPERPLEX.cmake | 4 ++-- cmake/SC_Regenerate.cmake | 1 + src/express/CMakeLists.txt | 7 +++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index 004ac5ecb..887e351a7 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -156,8 +156,11 @@ if (LEMON_EXECUTABLE) set(LEMON_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) set(LEMON_${Name}_OUTPUTS "${_out_src_file}" PARENT_SCOPE) + # TODO - remove once perplex goes away... + add_custom_target(${Name} DEPENDS ${_out_hdr_file}) + # make sure we clean up generated output and copied input - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_out_src_file}") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}") endfunction(LEMON_TARGET) diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index 22d632032..34982516a 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -240,12 +240,12 @@ if(NOT COMMAND ADD_PERPLEX_LEMON_DEPENDENCY) message(SEND_ERROR "PERPLEX target `${PERPLEXTarget}' does not exists.") endif() - if(NOT LEMON_${LemonTarget}_HDR) + if(NOT TARGET ${LemonTarget}) message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.") endif() set_source_files_properties(${PERPLEX_${PERPLEXTarget}_SRC} - PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_HDR}) + PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER}) endmacro(ADD_PERPLEX_LEMON_DEPENDENCY) endif(NOT COMMAND ADD_PERPLEX_LEMON_DEPENDENCY) diff --git a/cmake/SC_Regenerate.cmake b/cmake/SC_Regenerate.cmake index 8c4264681..2666b51b9 100644 --- a/cmake/SC_Regenerate.cmake +++ b/cmake/SC_Regenerate.cmake @@ -30,6 +30,7 @@ if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF") # NOTE: lemon doesn't have a stable versioning system (it's always 1) find_package(LEMON ${_verbosity}) find_package(RE2C 1.0.3 ${_verbosity}) + find_package(PERPLEX ${_verbosity}) if(LEMON_FOUND AND RE2C_FOUND) set(SC_GENERATE_LP_SOURCES 1) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index b06d24210..79cda961c 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -7,14 +7,17 @@ include_directories( # Depending on whether we're using pre-generated sources or building them on # the fly, set up targets and source lists. if(SC_GENERATE_LP_SOURCES) - LEMON_TARGET(ExpParser expparse.y) + LEMON_TARGET(ExpParser expparse.y expparse.c + COMPILE_FLAGS "-p -c" + DEFINES_FILE "expparse.h" + ) PERPLEX_TARGET(ExpScanner expscan.l) ADD_PERPLEX_LEMON_DEPENDENCY(ExpScanner ExpParser) add_library(objlib_expscan_c OBJECT ${PERPLEX_ExpScanner_SRC}) set_property(TARGET objlib_expscan_c PROPERTY POSITION_INDEPENDENT_CODE ON) - add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_SRC}) + add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_OUTPUTS}) set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) else(SC_GENERATE_LP_SOURCES) From ae18190f696fa16647ccfda012ce753f61e7d586 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Thu, 12 Aug 2021 19:25:44 -0400 Subject: [PATCH 125/244] Make copy more robust for parallel builds This is a classic problem - the file copy will begin, the file will be "present" in some sense on the file system, and build steps that need it will begin - but they won't find what they actually need because the copy isn't fully executed. The standard approach for this is to add a second file which is only created after the first is done, and then make the target depend on the second file rather than the first. --- cmake/FindLEMON.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index 887e351a7..7ad58984e 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -126,17 +126,24 @@ if (LEMON_EXECUTABLE) get_filename_component(_in_y_path ${LemonInput} ABSOLUTE) get_filename_component(_in_y_file ${LemonInput} NAME) - # TODO: is this really necessary? + # Stage the source file in the binary directory for lemon. We need to make + # sure it's fully copied, so use a sentinel guard add_custom_command( OUTPUT ${_in_y_file} COMMAND ${CMAKE_COMMAND} -E copy ${_in_y_path} ${CMAKE_CURRENT_BINARY_DIR} ) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel + DEPENDS ${_in_y_file} + ) + add_custom_target(${Name}_input_cpy DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel) # execute lemon add_custom_command( OUTPUT ${_out_src_file} COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file} - DEPENDS ${_in_y_file} + DEPENDS ${Name}_input_cpy WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}" ) From fceb57390c42c6e44ee5715bc140b76688379d5f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:58:43 -0400 Subject: [PATCH 126/244] Until we need the newer re2c, don't insist on it. BRL-CAD's supporting system for building this will need some updates once we require a newer re2c - to make testing easier in the meantime, don't require the newer version. --- cmake/SC_Regenerate.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/SC_Regenerate.cmake b/cmake/SC_Regenerate.cmake index 2666b51b9..cab3b049c 100644 --- a/cmake/SC_Regenerate.cmake +++ b/cmake/SC_Regenerate.cmake @@ -29,9 +29,9 @@ endif() if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF") # NOTE: lemon doesn't have a stable versioning system (it's always 1) find_package(LEMON ${_verbosity}) - find_package(RE2C 1.0.3 ${_verbosity}) + find_package(RE2C ${_verbosity}) find_package(PERPLEX ${_verbosity}) - + if(LEMON_FOUND AND RE2C_FOUND) set(SC_GENERATE_LP_SOURCES 1) message(".. Found re2c, and lemon - can regenerate lexer/parser if necessary") From 8adb5e638d0a537aab8ca584e9adc8ae82f7ad32 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 13 Aug 2021 13:57:02 -0400 Subject: [PATCH 127/244] Remove no-longer-used CMake files. --- CMakeLists.txt | 6 -- cmake/Generated_Source_Utils.cmake | 67 ------------ cmake/SC_Build_opts.cmake | 165 ----------------------------- cmake/md5_gen.cmake.in | 35 ------ cmake/md5_verify.cmake.in | 30 ------ cmake/sync_generated.cmake.in | 83 --------------- 6 files changed, 386 deletions(-) delete mode 100644 cmake/Generated_Source_Utils.cmake delete mode 100644 cmake/SC_Build_opts.cmake delete mode 100644 cmake/md5_gen.cmake.in delete mode 100644 cmake/md5_verify.cmake.in delete mode 100644 cmake/sync_generated.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e355a3ac..cd6eed7c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,12 +138,6 @@ if(SC_ENABLE_TESTING) include(CTest) endif(SC_ENABLE_TESTING) -# TODO - BRL-CAD is the only known user of this option, and it will be -# transitioning to a new setup that won't need it - once that's done, -# we should just remove this option. -option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) -mark_as_advanced(SC_SKIP_EXEC_INSTALL) - # SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc include(SC_Targets) diff --git a/cmake/Generated_Source_Utils.cmake b/cmake/Generated_Source_Utils.cmake deleted file mode 100644 index 601f92364..000000000 --- a/cmake/Generated_Source_Utils.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# Utility routines for managing generated files with CMake - -macro(MD5 filename md5sum) - file(READ "${filename}" RAW_MD5_FILE) - string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}") - string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}") -endmacro(MD5) - -macro(FILEVAR filename var) - string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${var} ${filename}) -endmacro(FILEVAR) - -macro(VERIFY_FILES filelist warn resultvar) - set(${resultvar} 1) - foreach(fileitem ${filelist}) - # Deal with absolute and relative paths a bit differently - get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) - if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${fileitem}") - else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") - endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - get_filename_component(filename "${fileitem}" NAME) - # Got filename components sorted - proceed - if(NOT EXISTS ${filefullname}) - message(FATAL_ERROR "Attempted to verify non-existant file ${filefullname}") - endif(NOT EXISTS ${filefullname}) - FILEVAR(${filename} filevar) - if(NOT baseline_${filevar}_md5) - message(FATAL_ERROR "No baseline MD5 available for ${filename} - baseline_${filevar}_md5 is not defined") - endif(NOT baseline_${filevar}_md5) - MD5(${filefullname} ${filevar}_md5) - if(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") - if("${warn}" STREQUAL "1") - message("\n${filename} differs from baseline: baseline md5 hash is ${baseline_${filevar}_md5} and current hash is ${${filevar}_md5}\n") - endif("${warn}" STREQUAL "1") - set(${resultvar} 0) - endif(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}") - endforeach(fileitem ${filelist}) -endmacro(VERIFY_FILES filelist resultvar) - -macro(WRITE_MD5_SUMS filelist outfile) - foreach(fileitem ${filelist}) - # Deal with absolute and relative paths a bit differently - get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE) - if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${fileitem}") - else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}") - endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}") - get_filename_component(filename "${fileitem}" NAME) - # Got filename components sorted - proceed - if(NOT EXISTS ${filefullname}) - message(FATAL_ERROR "Attempted to get MD5 sum of non-existant file ${filefullname}") - endif(NOT EXISTS ${filefullname}) - FILEVAR(${filename} filevar) - MD5(${filefullname} ${filevar}_md5) - file(APPEND ${outfile} "set(baseline_${filevar}_md5 ${${filevar}_md5})\n") - endforeach(fileitem ${filelist}) -endmacro(WRITE_MD5_SUMS) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake deleted file mode 100644 index f725e0b87..000000000 --- a/cmake/SC_Build_opts.cmake +++ /dev/null @@ -1,165 +0,0 @@ -# BIN and LIB directories -if(NOT DEFINED BIN_DIR) - set(BIN_DIR bin) -endif(NOT DEFINED BIN_DIR) - -if(NOT DEFINED LIB_DIR) - set(LIB_DIR lib) -endif(NOT DEFINED LIB_DIR) - -# 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) - -# Should we use C++11? -OPTION_WITH_DEFAULT(SC_ENABLE_CXX11 "Build with C++ 11 features" ON) - -# Get version from git -OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON) - -option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) -mark_as_advanced(SC_BUILD_EXPRESS_ONLY) - -option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF) -mark_as_advanced(DEBUGGING_GENERATED_SOURCES) - -#--------------------------------------------------------------------- -# 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 ${SC_BUILD_EXPRESS_ONLY} AND NOT DEFINED SC_BUILD_SCHEMAS) - set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified - endif() - include(CTest) -endif(SC_ENABLE_TESTING) - -#--------------------------------------------------------------------- -# Executable install option -OPTION_WITH_DEFAULT(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF) -if(SC_SKIP_EXEC_INSTALL) - set(SC_EXEC_NOINSTALL "NO_INSTALL") -endif(SC_SKIP_EXEC_INSTALL) - -#--------------------------------------------------------------------- -# 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) - - #----------------------------------------------------------------------------- - # 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 - diff --git a/cmake/md5_gen.cmake.in b/cmake/md5_gen.cmake.in deleted file mode 100644 index 9d664baa0..000000000 --- a/cmake/md5_gen.cmake.in +++ /dev/null @@ -1,35 +0,0 @@ -# Inherit the parent CMake setting -set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) -set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) - -# Define a variety of convenience routines -include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake) - -# The following steps are executed to sync generated sources: -# -# 1. Create a new verification_info.cmake file and populate -# it with the MD5 sums for current files. -# -# 2. Overwrite the original cached verification_info.cmake -# and generated files with the new ones. If LOCKED_SOURCE_DIR -# is ON, this step will not be carried out - instead, an -# informational message with manual updating instructions -# will be printed. - -set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake") - - -file(WRITE ${new_info_file} "# Autogenerated verification information\n") - -# Handle input files -set(input_files "@MD5_FILELIST@") -WRITE_MD5_SUMS("${input_files}" "${new_info_file}") - -message("New verification file created: ${new_info_file}") - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/md5_verify.cmake.in b/cmake/md5_verify.cmake.in deleted file mode 100644 index 5eb105337..000000000 --- a/cmake/md5_verify.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# Inherit the parent CMake setting -set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@) -set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") - -# Include the file the provides the baseline against which -# current files will be compared - - include("@BASELINE_INFORMATION_FILE@") - - # Define a variety of convenience routines - include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake") - - # Individually verify all of the files in question. - set(filelist "@MD5_FILELIST@") - VERIFY_FILES("${filelist}" 1 srcs_pass) - if(NOT srcs_pass) - if(NOT DEBUGGING_GENERATED_SOURCES) - message(FATAL_ERROR "Sources have been modified and md5 sums have not been updated. This generally indicates either\n a) an input file has been modified but generated files have not been updated, or\n b) genenerated files have been edited directly.\nTo clear the error:\n a) Copy the new generated sources from the build directory to the generated/ sources directory, use the _md5gen build target to create a new verifictation_info.cmake file, and copy verfication_info.cmake to generated/ as well.\n b) install Perplex/Re2C/LEMON and make the changes to the input file rather than the generated file.\nNote:\n If this is a debugging situation where multiple sequential tests must be conducted, temporarily set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure to disable this check.\nThis measure is necessary to ensure that compilations using either Perplex/Re2C/LEMON generation or the cached outputs of those tools produce consistent results.") - else(NOT DEBUGGING_GENERATED_SOURCES) - message(WARNING "Note: Sources have been modified and md5 sums have not been updated - build failure condition temporarily overridden by DEBUGGING_GENERATED_SOURCES setting.") - endif(NOT DEBUGGING_GENERATED_SOURCES) - endif(NOT srcs_pass) - - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/cmake/sync_generated.cmake.in b/cmake/sync_generated.cmake.in deleted file mode 100644 index aa51ab516..000000000 --- a/cmake/sync_generated.cmake.in +++ /dev/null @@ -1,83 +0,0 @@ -# Inherit the parent CMake setting -set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) -set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) -set(CACHED_FILES_DIR @CACHED_FILES_DIR@) -set(LEMON_EXECUTABLE @LEMON_EXECUTABLE@) -set(RE2C_EXECUTABLE @RE2C_EXECUTABLE@) -set(PERPLEX_EXECUTABLE @PERPLEX_EXECUTABLE@) -set(LOCKED_SOURCE_DIR @LOCKED_SOURCE_DIR@) -set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@) - -if(NOT DEBUGGING_GENERATED_SOURCES) - # Define a variety of convenience routines - include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake) - - # The following steps are executed to sync generated sources: - # - # 1. Create a new verification_info.cmake file and populate - # it with the current versions of perplex, re2c and lemon. - # Also add the MD5 sums for current template files. - # - # 2. For all files that need to be updated in the cache, - # calculate new MD5 sums and add them to the new - # verification_info.cmake - this is usually the input - # files and the generated outputs. - # - # 3. Overwrite the original cached verification_info.cmake - # and generated files with the new ones. If LOCKED_SOURCE_DIR - # is ON, this step will not be carried out - instead, an - # informational message with manual updating instructions - # will be printed. - - set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake.new") - - - file(WRITE ${new_info_file} "# Autogenerated verification information\n") - - # Handle generator version numbers - GET_GENERATOR_EXEC_VERSIONS() - file(APPEND ${new_info_file} "set(baseline_lemon_version \"${lemon_version}\")\n") - file(APPEND ${new_info_file} "set(baseline_re2c_version \"${re2c_version}\")\n") - file(APPEND ${new_info_file} "set(baseline_perplex_version \"${perplex_version}\")\n") - - # Handle template files - set(template_files "@TEMPLATE_FILELIST@") - WRITE_MD5_SUMS("${template_files}" "${new_info_file}") - - # Handle input files - set(input_files "@INPUT_FILELIST@") - WRITE_MD5_SUMS("${input_files}" "${new_info_file}") - - # Handle generated files - set(output_files "@BUILD_OUTPUT_FILELIST@") - WRITE_MD5_SUMS("${output_files}" "${new_info_file}") - - # Copy files into their final locations - if(NOT LOCKED_SOURCE_DIR) - configure_file(${new_info_file} "${CACHED_FILES_DIR}/verification_info.cmake" COPYONLY) - foreach(outf ${output_files}) - get_filename_component(filecorename ${outf} NAME) - message("copying ${outf} to ${CACHED_FILES_DIR}/${filecorename}") - configure_file(${outf} "${CACHED_FILES_DIR}/${filecorename}" COPYONLY) - endforeach(outf ${output_files}) - else(NOT LOCKED_SOURCE_DIR) - message("Source directory writing is locked - LOCKED_SOURCE_DIR is set.") - message("To update the generated files, manually copy the following to ${CACHED_FILES_DIR}:") - message(" ${new_info_file} (rename to verification_info.cmake)") - foreach(outf ${output_files}) - message(" ${outf}") - endforeach(outf ${output_files}) - endif(NOT LOCKED_SOURCE_DIR) - -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) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 From c2fddd8a7af6d21ab46617bc331ee76892551012 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 13 Aug 2021 13:45:43 -0400 Subject: [PATCH 128/244] Restore SC_BUILD_EXPRESS_ONLY option --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd6eed7c3..476375230 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,9 +130,12 @@ if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE) endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") +option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) +mark_as_advanced(SC_BUILD_EXPRESS_ONLY) + option(SC_ENABLE_TESTING "Enable unittesting framework" OFF) if(SC_ENABLE_TESTING) - if(NOT DEFINED SC_BUILD_SCHEMAS) + if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND NOT DEFINED SC_BUILD_SCHEMAS) set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified endif() include(CTest) @@ -157,13 +160,13 @@ 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) +if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND 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) +endif() if(NOT SC_IS_SUBBUILD) list(APPEND CONFIG_END_MESSAGES From 62be4c90c62f64e878fa5e1456865933f3861c12 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 13 Aug 2021 14:11:21 -0400 Subject: [PATCH 129/244] Use CMake 3.12 everywhere. --- CMakeLists.txt | 12 ++++++------ cmake/schema_scanner/CMakeLists.txt | 2 +- example/ap203min/CMakeLists.txt | 2 +- example/ap203min/ExternalProjectBuild/CMakeLists.txt | 2 +- src/base/judy/CMakeLists.txt | 2 +- src/clstepcore/test/CMakeLists.txt | 2 +- src/exp2cxx/test/inverse_qualifiers.cmake | 2 +- src/exp2cxx/test/unique_qualifiers.cmake | 2 +- src/exppp/test/CMakeLists.txt | 2 +- src/exppp/test/exppp_div_slash.cmake | 2 +- src/exppp/test/exppp_lost_var.cmake | 2 +- src/exppp/test/inverse_qualifiers.cmake | 2 +- src/exppp/test/unique_qualifiers.cmake | 2 +- test/cpp/CMakeLists.txt | 2 +- test/cpp/schema_specific/CMakeLists.txt | 2 +- test/p21/CMakeLists.txt | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 476375230..64adfac2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,12 @@ project(SC) +# Minimum required version of CMake +cmake_minimum_required(VERSION 3.12) +if (POLICY CMP0077) + cmake_policy(SET CMP0077 OLD) +endif (POLICY CMP0077) + # SC version set(SC_VERSION_MAJOR 0) set(SC_VERSION_MINOR 9) @@ -54,12 +60,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Minimum required version of CMake -cmake_minimum_required(VERSION 3.6.3) -cmake_policy(SET CMP0003 NEW) -cmake_policy(SET CMP0026 NEW) -cmake_policy(SET CMP0057 NEW) - # 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") diff --git a/cmake/schema_scanner/CMakeLists.txt b/cmake/schema_scanner/CMakeLists.txt index 34520e67c..16219eb9a 100644 --- a/cmake/schema_scanner/CMakeLists.txt +++ b/cmake/schema_scanner/CMakeLists.txt @@ -1,5 +1,5 @@ project(SC_SUBPROJECT_SCHEMA_SCANNER) -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR)) message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}") diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index f1fccb2ea..52bbe7028 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -6,7 +6,7 @@ # for the use of this file. # project(AP203Minimum) -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) # Set STEPCODE_ROOT_DIR to point to the root of the STEPcode source tree. if(NOT DEFINED STEPCODE_ROOT_DIR) diff --git a/example/ap203min/ExternalProjectBuild/CMakeLists.txt b/example/ap203min/ExternalProjectBuild/CMakeLists.txt index 7e964684c..3a5409088 100644 --- a/example/ap203min/ExternalProjectBuild/CMakeLists.txt +++ b/example/ap203min/ExternalProjectBuild/CMakeLists.txt @@ -6,7 +6,7 @@ # for the use of this file. # project(AP203Minimum) -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) INCLUDE( ExternalProject ) diff --git a/src/base/judy/CMakeLists.txt b/src/base/judy/CMakeLists.txt index 807fcd0af..3c26e4df2 100644 --- a/src/base/judy/CMakeLists.txt +++ b/src/base/judy/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) project( JudyTemplates ) if( NOT DEFINED CMAKE_BUILD_TYPE ) diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index 1de017638..f9f353e26 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #c++ tests for clstepcore include_directories( diff --git a/src/exp2cxx/test/inverse_qualifiers.cmake b/src/exp2cxx/test/inverse_qualifiers.cmake index e222c0b57..ed26e0b75 100644 --- a/src/exp2cxx/test/inverse_qualifiers.cmake +++ b/src/exp2cxx/test/inverse_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXE}, input file is ${INFILE} diff --git a/src/exp2cxx/test/unique_qualifiers.cmake b/src/exp2cxx/test/unique_qualifiers.cmake index 3b3b1d7b5..13225bd6a 100644 --- a/src/exp2cxx/test/unique_qualifiers.cmake +++ b/src/exp2cxx/test/unique_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXE}, input file is ${INFILE} diff --git a/src/exppp/test/CMakeLists.txt b/src/exppp/test/CMakeLists.txt index 3b620a4b8..0d911e590 100644 --- a/src/exppp/test/CMakeLists.txt +++ b/src/exppp/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) project(test_exppp) set(breakLongStr_SRCS diff --git a/src/exppp/test/exppp_div_slash.cmake b/src/exppp/test/exppp_div_slash.cmake index b72b8582d..5e11a92a0 100644 --- a/src/exppp/test/exppp_div_slash.cmake +++ b/src/exppp/test/exppp_div_slash.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/exppp_lost_var.cmake b/src/exppp/test/exppp_lost_var.cmake index 02809d6fd..1989cc465 100644 --- a/src/exppp/test/exppp_lost_var.cmake +++ b/src/exppp/test/exppp_lost_var.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/inverse_qualifiers.cmake b/src/exppp/test/inverse_qualifiers.cmake index 233cb5399..48f1fc5ea 100644 --- a/src/exppp/test/inverse_qualifiers.cmake +++ b/src/exppp/test/inverse_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/src/exppp/test/unique_qualifiers.cmake b/src/exppp/test/unique_qualifiers.cmake index 5c26f8b11..812793d94 100644 --- a/src/exppp/test/unique_qualifiers.cmake +++ b/src/exppp/test/unique_qualifiers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.6.3 ) +cmake_minimum_required( VERSION 3.12 ) # executable is ${EXPPP}, input file is ${INFILE} diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index cccf68811..7af916d2c 100644 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #c++ tests diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index c96ea08f3..44fa4e5bc 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.12) #c++ tests that depend on a particular schema include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/clutils diff --git a/test/p21/CMakeLists.txt b/test/p21/CMakeLists.txt index b16bdd7b3..7d533f9ca 100644 --- a/test/p21/CMakeLists.txt +++ b/test/p21/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) #test part 21 files #necessary macros won't already be defined if SC_BUILD_SCHEMAS is set to "" From 55d36377c30e657596b9766c543f28347099c166 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 14 Aug 2021 11:21:31 +0100 Subject: [PATCH 130/244] Adjust whitespace --- CMakeLists.txt | 2 +- src/express/CMakeLists.txt | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64adfac2a..0251f05d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,7 @@ if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND 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 +# 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() diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 79cda961c..7448a9a36 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -57,22 +57,22 @@ set(EXPRESS_SOURCES ordered_attrs.cc info.c factory.c - ) + ) set(EXPRESS_OBJS) foreach(_src ${EXPRESS_SOURCES}) - string(REPLACE "." "_" _suffix ${_src}) - set(_objlib "objlib_${_suffix}") - add_library(${_objlib} OBJECT ${_src}) - add_dependencies(${_objlib} objlib_expscan_c) - add_dependencies(${_objlib} objlib_expparse_c) + string(REPLACE "." "_" _suffix ${_src}) + set(_objlib "objlib_${_suffix}") + add_library(${_objlib} OBJECT ${_src}) + add_dependencies(${_objlib} objlib_expscan_c) + add_dependencies(${_objlib} objlib_expparse_c) if(MSVC) set_property(TARGET ${_objlib} APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") set_property(TARGET ${_objlib} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") endif(MSVC) - # TODO: probably PIC should be used everywhere... - set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) - list(APPEND EXPRESS_OBJS $) + # TODO: probably PIC should be used everywhere... + set_property(TARGET ${_objlib} PROPERTY POSITION_INDEPENDENT_CODE ON) + list(APPEND EXPRESS_OBJS $) endforeach() list(APPEND EXPRESS_OBJS $) @@ -81,9 +81,9 @@ list(APPEND EXPRESS_OBJS $) if(SC_GENERATE_LP_SOURCES) set_property(TARGET objlib_expparse_c objlib_express_c objlib_lexact_c - APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") + APPEND PROPERTY INCLUDE_DIRECTORIES "${PERPLEX_ExpScanner_INCLUDE_DIR}") set_property(TARGET objlib_expscan_c objlib_express_c objlib_lexact_c - APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") + APPEND PROPERTY INCLUDE_DIRECTORIES "${LEMON_ExpParser_INCLUDE_DIR}") # OBJECT libraries are not targets, and so an explicit dependency is required set_source_files_properties(express.c lexact.c PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR};${LEMON_ExpParser_HDR}") endif() @@ -130,7 +130,7 @@ endif() set(CHECK_EXPRESS_SOURCES fedex.c inithook.c - ) + ) add_executable(check-express ${CHECK_EXPRESS_SOURCES}) if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) From 1bf945d60b9bebeb14266d444077470aad693f07 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 13:37:39 -0400 Subject: [PATCH 131/244] Define a default copy constructor. Werror=deprecated-copy with GCC was triggered by code generated from this exp2cxx output. Go ahead and define the copy constructor to avoid the deprecated behavior. --- src/exp2cxx/classes_type.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 62d737aba..3059dd70a 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -182,12 +182,12 @@ void TYPEenum_inc_print( const Type type, FILE * inc ) { /* constructors */ strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); - tdnm[BUFSIZ-1] = '\0'; - fprintf( inc, " public:\n %s (const char * n =0, Enum" - "TypeDescriptor *et =%s);\n", n, tdnm ); + tdnm[BUFSIZ - 1] = '\0'; + fprintf( inc, " public:\n %s (const char * n =0, EnumTypeDescriptor *et =%s);\n", n, tdnm ); fprintf( inc, " %s (%s e, EnumTypeDescriptor *et =%s)\n" " : type(et) { set_value (e); }\n", n, EnumName( TYPEget_name( type ) ), tdnm ); + fprintf( inc, " %s (const %s &e) { set_value(e); }\n", n, TYPEget_ctype( type ) ); /* destructor */ fprintf( inc, " ~%s () { }\n", n ); From dcb156f1eb16e0a85aa991d1b22eb59d7efec085 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 13:42:07 -0400 Subject: [PATCH 132/244] Export ERRORget_warnings_help for MSVC --- include/express/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/express/error.h b/include/express/error.h index 7eef340c4..9a9334f88 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -225,7 +225,7 @@ extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool ); extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); -extern char * ERRORget_warnings_help(const char* prefix, const char *eol); +extern SC_EXPRESS_EXPORT char * ERRORget_warnings_help(const char* prefix, const char *eol); extern bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ From 5e1ad8f1c8aa164fd4f4f11a9bab2fece11144cb Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:09:10 -0400 Subject: [PATCH 133/244] Remove Raw() and getEDesc(), restore C asStr() This commit removes the Raw and getEDesc methods in favor of the simplicity of just making ptr and eDesc public. Add back in previous version of asStr() that returns a C string. aDesc is also made public. These changes are motivated by BRL-CAD's use of stepcode. --- src/cllazyfile/lazyRefs.h | 10 +-- src/cllazyfile/lazy_test.cc | 4 +- src/cllazyfile/sectionReader.cc | 2 +- src/clstepcore/Registry.cc | 2 +- src/clstepcore/STEPattribute.cc | 94 ++++++++++++++++++++++ src/clstepcore/STEPattribute.h | 38 ++++----- src/clstepcore/sdaiApplication_instance.cc | 8 +- src/clstepcore/sdaiApplication_instance.h | 6 +- src/exp2cxx/selects.c | 4 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- 10 files changed, 129 insertions(+), 41 deletions(-) diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 6d2e093e4..723dd0998 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -115,9 +115,9 @@ class SC_LAZYFILE_EXPORT lazyRefs { if( !ai ) { ias.i = rinst; _inst->setInvAttr( ia, ias ); - } else if( ai->GetFileId() != (int)inst ) { - std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->getEDesc()->Name(); - std::cerr << " and " << ai << ", #" << ai->GetFileId() <<"=" << ai->getEDesc()->Name() << ") refer to inst "; + } else if( ai->GetFileId() != ( int )inst ) { + std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->eDesc->Name(); + std::cerr << " and " << ai << ", #" << ai->GetFileId() << "=" << ai->eDesc->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 ); } @@ -184,7 +184,7 @@ class SC_LAZYFILE_EXPORT lazyRefs { } ++iai; } - std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->getEDesc()->Name() << std::endl; + std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->eDesc->Name() << std::endl; abort(); iAstruct nil = {nullptr}; return nil; @@ -279,7 +279,7 @@ class SC_LAZYFILE_EXPORT lazyRefs { // 1. find inverse attrs with recursion - getInverseAttrs( ai->getEDesc(), _iaList ); + getInverseAttrs( ai->eDesc, _iaList ); //2. find reverse refs, map id to type (stop if there are no inverse attrs or no refs) if( _iaList.size() == 0 || !mapRefsToTypes() ) { diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 87838e467..71786bb59 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -111,14 +111,14 @@ void dumpComplexInst( STEPcomplex * c ) { 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 component " << complex->eDesc->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; + std::cout << "non-complex component at depth " << depth << ", " << ai->eDesc->Name() << std::endl; } else { std::cout << "unknown component at depth " << depth << ": " << complex << std::endl; } diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 7a6053a46..0384efd4c 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -306,7 +306,7 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg if( !comment.empty() ) { inst->AddP21Comment( comment ); } - assert( inst->getEDesc() ); + assert( inst->eDesc ); _file.seekg( begin ); findNormalString( "(" ); _file.seekg( _file.tellg() - std::streampos(1) ); diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 6bbd3eaff..2e5eb490f 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -260,7 +260,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->setEDesc( entd ); + se->eDesc = entd; return se; } else { return ENTITY_NULL; diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 251beb445..866248fe4 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -382,6 +382,100 @@ Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int add } } +/*****************************************************************//** + ** \fn asStr + ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). + ** \returns the value of the attribute + ** Status: complete 3/91 + *********************************************************************/ +const char * STEPattribute::asStr( std::string & str, const char * currSch ) const { + ostringstream ss; + + str.clear(); + + // The attribute has been derived by a subtype's attribute + if( IsDerived() ) { + str = "*"; + return const_cast( str.c_str() ); + } + + // The attribute has been redefined by the attribute pointed + // to by _redefAttr so write the redefined value. + if( _redefAttr ) { + return _redefAttr->asStr( str, currSch ); + } + + if( is_null() ) { + str = ""; + return const_cast( str.c_str() ); + } + + switch( NonRefType() ) { + case INTEGER_TYPE: + ss << *( ptr.i ); + str += ss.str(); + break; + + case NUMBER_TYPE: + case REAL_TYPE: + + ss.precision( ( int ) Real_Num_Precision ); + ss << *( ptr.r ); + str += ss.str(); + break; + + case ENTITY_TYPE: + // print instance id only if not empty pointer + // and has value assigned + if( ( *( ptr.c ) == S_ENTITY_NULL ) || ( *( ptr.c ) == 0 ) ) { + break; + } else { + ( *( ptr.c ) )->STEPwrite_reference( str ); + } + break; + + case BINARY_TYPE: + if( !( ( ptr.b )->empty() ) ) { + ( ptr.b ) -> STEPwrite( str ); + } + break; + + case STRING_TYPE: + if( !( ( ptr.S )->empty() ) ) { + return ( ptr.S ) -> asStr( str ); + } + break; + + case AGGREGATE_TYPE: + case ARRAY_TYPE: // DAS + case BAG_TYPE: // DAS + case SET_TYPE: // DAS + case LIST_TYPE: // DAS + return ptr.a->asStr( str ) ; + + case ENUM_TYPE: + case BOOLEAN_TYPE: + case LOGICAL_TYPE: + return ptr.e -> asStr( str ); + + case SELECT_TYPE: + ptr.sh -> STEPwrite( str, currSch ); + return const_cast( str.c_str() ); + + case REFERENCE_TYPE: + case GENERIC_TYPE: + cerr << "Internal error: " << __FILE__ << __LINE__ + << "\n" << _POC_ "\n"; + return 0; + + case UNKNOWN_TYPE: + default: + return ( ptr.u -> asStr( str ) ); + } + return const_cast( str.c_str() ); +} + + /*****************************************************************//** ** \fn asStr ** \param currSch - used for select type writes. See commenting in SDAI_Select::STEPwrite(). diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index e3b43e0b4..08d8a62e5 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -75,21 +75,15 @@ extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, Erro class SC_CORE_EXPORT STEPattribute { friend ostream & operator<< ( ostream &, STEPattribute & ); friend class SDAI_Application_instance; - protected: - bool _derive; - bool _mustDeletePtr; ///if a member uses new to create an object in ptr - ErrorDescriptor _error; - STEPattribute * _redefAttr; - const AttrDescriptor * aDesc; - int refCount; + public: /** \union ptr - ** You know which of these to use based on the return value of - ** NonRefType() - see below. BASE_TYPE is defined in baseType.h - ** This variable points to an appropriate member variable in the entity - ** class in the generated schema class library (the entity class is - ** inherited from SDAI_Application_instance) - */ + ** You know which of these to use based on the return value of + ** NonRefType() - see below. BASE_TYPE is defined in baseType.h + ** This variable points to an appropriate member variable in the entity + ** class in the generated schema class library (the entity class is + ** inherited from SDAI_Application_instance) + */ union attrUnion { SDAI_String * S; // STRING_TYPE SDAI_Integer * i; // INTEGER_TYPE (Integer is a long int) @@ -103,6 +97,18 @@ class SC_CORE_EXPORT STEPattribute { void * p; } ptr; + + protected: + bool _derive; + bool _mustDeletePtr; ///if a member uses new to create an object in ptr + ErrorDescriptor _error; + STEPattribute * _redefAttr; + public: + const AttrDescriptor * aDesc; + + protected: + int refCount; + char SkipBadAttr( istream & in, char * StopChars ); void AddErrorInfo(); void STEPwriteError( ostream& out, unsigned int line, const char* desc ); @@ -137,6 +143,7 @@ class SC_CORE_EXPORT STEPattribute { /// return the attr value as a string string asStr( const char * currSch = 0 ) const; + const char * asStr( std::string &, const char * = 0 ) const; /// put the attr value in ostream void STEPwrite( ostream & out = cout, const char * currSch = 0 ); @@ -167,11 +174,6 @@ class SC_CORE_EXPORT STEPattribute { SCLundefined * Undefined(); ///@} - /// allows direct access to the union containing attr data (dangerous!) - attrUnion * Raw() { - return & ptr; - } - /** * These functions allow setting the attribute value. * Attr type is verified using an assertion. diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 7d74361f2..31fadb812 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -170,10 +170,6 @@ void SDAI_Application_instance::AppendMultInstance( SDAI_Application_instance * } } -const EntityDescriptor* SDAI_Application_instance::getEDesc() const { - return eDesc; -} - // BUG implement this -- FIXME function is never used SDAI_Application_instance * SDAI_Application_instance::GetMiEntity( char * entName ) { std::string s1, s2; @@ -788,9 +784,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->getEDesc() ) { + else if( se->eDesc ) { // is se a descendant of ed? - if( se->getEDesc()->IsA( ed ) ) { + if( se->eDesc->IsA( ed ) ) { return SEVERITY_NULL; } else { if( se->IsComplex() ) { diff --git a/src/clstepcore/sdaiApplication_instance.h b/src/clstepcore/sdaiApplication_instance.h index 70b7b3308..405964c24 100644 --- a/src/clstepcore/sdaiApplication_instance.h +++ b/src/clstepcore/sdaiApplication_instance.h @@ -36,8 +36,8 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { public: typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t; - protected: const EntityDescriptor * eDesc; + protected: #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable: 4251 ) @@ -89,10 +89,6 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI { /// initialize inverse attribute list void InitIAttrs(); - void setEDesc( const EntityDescriptor * const ed ) { - eDesc = ed; - } - const EntityDescriptor * getEDesc() const; void StepFileId( int fid ) { STEPfile_id = fid; } diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index b4fd3e60d..3a188e378 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -1493,7 +1493,7 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { " _%s = ReadEntityRef(in, &_error, \",)\", instances, addFileId);\n", dm ); fprintf( f, " if( _%s && ( _%s != S_ENTITY_NULL) &&\n " - " ( CurrentUnderlyingType()->CanBe( _%s->getEDesc() ) ) ) {\n" + " ( CurrentUnderlyingType()->CanBe( _%s->eDesc ) ) ) {\n" " return severity();\n", dm, dm, dm ); fprintf( f, " } else {\n " @@ -1680,7 +1680,7 @@ void SELlib_print_protected( const Type type, FILE * f ) { if( TYPEis_select( t ) ) { fprintf( f, " // %s\n" /* item name */ - " if( %s->CanBe( se->getEDesc() ) ) {\n" + " if( %s->CanBe( se->eDesc ) ) {\n" " _%s.AssignEntity (se);\n" /* underlying data member */ " return SetUnderlyingType (%s);\n" /* td */ " }\n", diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index eafcc5404..c06177b1c 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -43,7 +43,7 @@ bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { EntityNode * en = ( EntityNode * ) relObj->GetHead(); SdaiObject * obj = ( SdaiObject * ) en->node; cout << "file id " << obj->StepFileId() << "; name " - << instList.GetApplication_instance( obj->StepFileId() - 1 )->getEDesc()->Name() << endl; + << instList.GetApplication_instance( obj->StepFileId() - 1 )->eDesc->Name() << endl; } ent_id = i; } From f05ce582ac240b9193559d8788d8efc7cce36c80 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:15:34 -0400 Subject: [PATCH 134/244] Export MEMORYinitialize and FACTORYinitialize for Windows. --- include/express/factory.h | 4 +++- include/express/memory.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/express/factory.h b/include/express/factory.h index 77075720d..4942256fe 100644 --- a/include/express/factory.h +++ b/include/express/factory.h @@ -1,6 +1,8 @@ #ifndef __FACTORY_H_ #define __FACTORY_H_ -void FACTORYinitialize(); +#include "sc_export.h" + +SC_EXPRESS_EXPORT void FACTORYinitialize(); #endif /* __FACTORY_H_ */ diff --git a/include/express/memory.h b/include/express/memory.h index 77357cf7e..3d1e58c74 100644 --- a/include/express/memory.h +++ b/include/express/memory.h @@ -1,6 +1,8 @@ #ifndef __MEMORY_H #define __MEMORY_H -void MEMORYinitialize(); +#include "sc_export.h" + +SC_EXPRESS_EXPORT void MEMORYinitialize(); #endif // __MEMORY_H From 345bcd8174bb106506f88f668f3537d9a0c15c92 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:20:57 -0400 Subject: [PATCH 135/244] Check before deferencing, and initialize to NULL. Crash was observed in Release build for BRL-CAD's step-g on Ubuntu Linux without this check. --- src/clstepcore/complexSupport.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index 46b673b46..cd2d9611f 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -173,26 +173,27 @@ class SC_CORE_EXPORT EntList { // but all we need. EntList * firstNot( JoinType ); EntList * nextNot( JoinType j ) { - return next->firstNot( j ); + return ( next ) ? next->firstNot( j ) : NULL; } EntList * firstWanted( MatchType ); EntList * nextWanted( MatchType mat ) { - return next->firstWanted( mat ); + return ( next ) ? next->firstWanted( mat ) : NULL; } EntList * lastNot( JoinType ); EntList * prevNot( JoinType j ) { - return prev->lastNot( j ); + return ( prev ) ? prev->lastNot( j ) : NULL; } EntList * lastWanted( MatchType ); EntList * prevWanted( MatchType mat ) { - return prev->lastWanted( mat ); + return ( prev ) ? prev->lastWanted( mat ) : NULL; } JoinType join; int multiple() { return ( join != SIMPLE ); } - EntList * next, *prev; + EntList * next = NULL; + EntList * prev = NULL; protected: MatchType viable; From 9f35265f75bcc0c9cbddf579062985c0147b4eb3 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:26:09 -0400 Subject: [PATCH 136/244] Clear deprecated-copy warning from C++ class. Getting a -Wdeprecated-copy trigger from ap210e3's use of SDAI_BOOLEAN - make an explicit assignment operator. --- src/cldai/sdaiEnum.cc | 5 +++++ src/cldai/sdaiEnum.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index a8e37d407..b0336ac2d 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -313,6 +313,11 @@ SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_LOGICAL & t ) { return *this; } +SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_BOOLEAN & t ) { + v = t; + return *this; +} + SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const Boolean t ) { v = t; return *this; diff --git a/src/cldai/sdaiEnum.h b/src/cldai/sdaiEnum.h index c883f2be6..aff524b88 100644 --- a/src/cldai/sdaiEnum.h +++ b/src/cldai/sdaiEnum.h @@ -138,6 +138,7 @@ class SC_DAI_EXPORT SDAI_BOOLEAN : operator ::Boolean() const; SDAI_BOOLEAN & operator=( const SDAI_LOGICAL & t ); + SDAI_BOOLEAN & operator=( const SDAI_BOOLEAN & t ); SDAI_BOOLEAN & operator=( const ::Boolean t ); SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const; From 1f1965beaeee2588dd16426f0b8bda147ffc7a5f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:24:58 -0400 Subject: [PATCH 137/244] Clear some C++ compilation warnings from the main stepcode libs --- src/base/judy/src/judy.c | 3 +- src/cldai/sdaiEntity_extent.cc | 2 +- src/cldai/sdaiEntity_extent.h | 2 +- src/cldai/sdaiModel_contents.cc | 6 ++-- src/cldai/sdaiModel_contents.h | 2 +- src/cldai/sdaiString.cc | 5 +++ src/cldai/sdaiString.h | 2 ++ src/clstepcore/STEPattribute.cc | 1 + src/clstepcore/globalRule.h | 2 +- src/clstepcore/interfaceSpec.h | 24 ++++++++------ src/clstepcore/sdaiApplication_instance.cc | 10 ++++-- src/clutils/sc_hash.cc | 2 +- src/exp2cxx/classes_type.c | 4 +-- src/exp2cxx/classes_wrapper.cc | 34 ++++++++++++++++---- src/exp2python/src/classes_python.c | 4 +-- src/exp2python/src/classes_wrapper_python.cc | 11 +++++-- src/express/expr.c | 17 ++++++---- src/express/info.c | 2 +- src/express/stack.h | 8 ----- 19 files changed, 91 insertions(+), 50 deletions(-) diff --git a/src/base/judy/src/judy.c b/src/base/judy/src/judy.c index 45e0cba44..91380cead 100644 --- a/src/base/judy/src/judy.c +++ b/src/base/judy/src/judy.c @@ -1080,7 +1080,7 @@ JudySlot * judy_prv( Judy * judy ) { // returning previous entry. JudySlot * judy_del( Judy * judy ) { - int slot, off, size, type, high; + int slot, off, size, type; JudySlot * table, *inner; JudySlot next, *node; int keysize, cnt; @@ -1133,7 +1133,6 @@ JudySlot * judy_del( Judy * judy ) { table = ( JudySlot * )( next & JUDY_mask ); inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask ); inner[slot & 0x0F] = 0; - high = slot & 0xF0; for( cnt = 16; cnt--; ) if( inner[cnt] ) { diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index f98d5d279..22db4e61b 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -56,7 +56,7 @@ void SDAI_Entity_extent::owned_by_( SDAI_Model_contents__list_var& mclv ) { } SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const { - return ( const SDAI_Model_contents__list_var ) &_owned_by; + return ( SDAI_Model_contents__list_var ) &_owned_by; } /* diff --git a/src/cldai/sdaiEntity_extent.h b/src/cldai/sdaiEntity_extent.h index 0dcca471f..68c90c2b5 100644 --- a/src/cldai/sdaiEntity_extent.h +++ b/src/cldai/sdaiEntity_extent.h @@ -56,7 +56,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance { return &_instances; } SDAI_DAObject__set_var instances_() const { - return ( const SDAI_DAObject__set_var )&_instances; + return ( SDAI_DAObject__set_var )&_instances; } // need to implement Model_contents__list diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index 67140916a..abe0386b2 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -27,7 +27,7 @@ SDAI_Model_contents::instances_() { SDAI_Model_contents_instances_ptr SDAI_Model_contents::instances_() const { - return ( const SDAI_Model_contents_instances_ptr ) &_instances; + return ( SDAI_Model_contents_instances_ptr ) &_instances; } SDAI_Entity_extent__set_var @@ -37,7 +37,7 @@ SDAI_Model_contents::folders_() { SDAI_Entity_extent__set_var SDAI_Model_contents::folders_() const { - return ( const SDAI_Entity_extent__set_var )&_folders; + return ( SDAI_Entity_extent__set_var )&_folders; } SDAI_Entity_extent__set_var @@ -47,7 +47,7 @@ SDAI_Model_contents::populated_folders_() { SDAI_Entity_extent__set_var SDAI_Model_contents::populated_folders_() const { - return ( const SDAI_Entity_extent__set_var )&_populated_folders; + return ( SDAI_Entity_extent__set_var )&_populated_folders; } SDAI_PID_DA_ptr SDAI_Model_contents::get_object_pid( const SDAI_DAObject_ptr & d ) const { diff --git a/src/cldai/sdaiModel_contents.h b/src/cldai/sdaiModel_contents.h index 5795232dc..984742728 100644 --- a/src/cldai/sdaiModel_contents.h +++ b/src/cldai/sdaiModel_contents.h @@ -40,7 +40,7 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject { return &_instances; } SDAI_DAObject__set_var contents_() const { - return ( const SDAI_DAObject__set_var ) &_instances; + return ( SDAI_DAObject__set_var ) &_instances; } }; diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 664a39358..87f29eebd 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -41,6 +41,11 @@ SDAI_String & SDAI_String::operator= ( const char * s ) { return *this; } +SDAI_String & SDAI_String::operator= ( const SDAI_String & s ) { + content = s.content; + return *this; +} + bool SDAI_String::operator== ( const char * s ) const { return ( content == s ); } diff --git a/src/cldai/sdaiString.h b/src/cldai/sdaiString.h index 083da80ea..7fd40e1cf 100644 --- a/src/cldai/sdaiString.h +++ b/src/cldai/sdaiString.h @@ -12,6 +12,7 @@ */ #include +#include #include @@ -36,6 +37,7 @@ class SC_DAI_EXPORT SDAI_String { // operators SDAI_String & operator= ( const char * s ); + SDAI_String & operator= ( const SDAI_String & s ); bool operator== ( const char * s ) const; void clear( void ); diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 251beb445..839622bba 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -1353,6 +1353,7 @@ STEPattribute::~STEPattribute() { delete ( SDAI_BOOLEAN * ) ptr.e; ptr.e = 0; } + break; case LOGICAL_TYPE: if( ptr.e ) { delete ( SDAI_LOGICAL * ) ptr.e; diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index c5614fdbf..ffd1200fd 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -14,7 +14,6 @@ class SC_CORE_EXPORT Global_rule : public Dictionary_instance { #pragma warning( disable: 4251 ) #endif Express_id _name; - std::string _rule_text; // non-SDAI #ifdef _MSC_VER #pragma warning( pop ) #endif @@ -22,6 +21,7 @@ class SC_CORE_EXPORT Global_rule : public Dictionary_instance { Entity__set_var _entities; // not implemented Where_rule__list_var _where_rules; Schema_ptr _parent_schema; + std::string _rule_text; // non-SDAI Global_rule(); Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt ); diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index 8469a555d..0b61b4b04 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -13,19 +13,25 @@ class SC_CORE_EXPORT Interface_spec : public Dictionary_instance { #pragma warning( push ) #pragma warning( disable: 4251 ) #endif - Express_id _current_schema_id; // schema containing the USE/REF stmt - - // non-SDAI, not useful for SDAI use of Interface_spec (it would need to - // be a list). - // schema that defined the USE/REFd objects - Express_id _foreign_schema_id; + Express_id _current_schema_id; // schema containing the USE/REF stmt #ifdef _MSC_VER #pragma warning( pop ) #endif + // set of objects from USE/REFERENCE stmt(s) + Explicit_item_id__set_var _explicit_items; + Implicit_item_id__set_var _implicit_items; //not yet initialized for schema - // set of objects from USE/REFERENCE stmt(s) - Explicit_item_id__set_var _explicit_items; - Implicit_item_id__set_var _implicit_items; //not yet initialized for schema +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + // non-SDAI, not useful for SDAI use of Interface_spec (it would need to + // be a list). + // schema that defined the USE/REFd objects + Express_id _foreign_schema_id; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif // non-SDAI, not useful for SDAI use of Interface_spec (it would need to // be a list of ints). diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 7d74361f2..e77b351dd 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -677,6 +677,7 @@ SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, err->AppendToDetailMsg( "Use of @ instead of # to identify entity.\n" ); err->GreaterSeverity( SEVERITY_WARNING ); // no break statement here on purpose + [[gnu::fallthrough]]; case '#': { int id = -1; in >> id; @@ -881,9 +882,12 @@ Severity EntityValidLevel( const char * attrValue, // string contain entity ref if( ( found1 > 0 ) || ( found2 > 0 ) ) { if( ( found1 == 2 ) || ( found2 == 2 ) ) { - sprintf( messageBuf, - " Attribute's Entity Reference %s is %s data \'%s\'.\n", - attrValue, "followed by invalid", tmp ); + int ocnt = snprintf( messageBuf, BUFSIZ, + " Attribute's Entity Reference %s is %s data \'%s\'.\n", + attrValue, "followed by invalid", tmp ); + if( ocnt < BUFSIZ ) { + fprintf( stderr, "Warning - truncation of Attribute's Entry Reference msg\n" ); + } err->AppendToUserMsg( messageBuf ); err->AppendToDetailMsg( messageBuf ); err->GreaterSeverity( SEVERITY_WARNING ); diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index 706780411..ddbe06a0b 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -63,7 +63,7 @@ void SC_HASHinsert( Hash_TableP t, char * s, void * data ) { e.symbol = 0; e2 = SC_HASHsearch( t, &e, HASH_INSERT ); if( e2 ) { - fprintf( stderr, "%s: Redeclaration of %s\n", __FUNCTION__, s ); + fprintf( stderr, "%s: Redeclaration of %s\n", __func__, s ); } } diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 62d737aba..a90aad329 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -120,7 +120,7 @@ char * CheckEnumSymbol( char * s ) { } else { strcpy( b, s ); strcat( b, "_" ); - fprintf( stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __FUNCTION__, s, b ); + fprintf( stderr, "Warning in %s: the enumerated value %s is already being used and has been changed to %s\n", __func__, s, b ); return ( b ); } } @@ -1285,7 +1285,7 @@ char * TYPEget_express_type( const Type t ) { /* default returns undefined */ - fprintf( stderr, "Warning in %s: type %s is undefined\n", __FUNCTION__, TYPEget_name( t ) ); + fprintf( stderr, "Warning in %s: type %s is undefined\n", __func__, TYPEget_name( t ) ); return ( "SCLundefined" ); } diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 517fa8a89..7a847885e 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -385,6 +385,7 @@ void INITFileFinish( FILE * initfile, Schema schema ) { ** Status: ******************************************************************/ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) { + int ocnt = 0; char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ FILE * libfile, @@ -402,11 +403,20 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) /* 1. header file */ sprintf( schnm, "%s%s", SCHEMA_FILE_PREFIX, StrToUpper( SCHEMAget_name( schema ) ) ); //TODO change file names to CamelCase? if( suffix == 0 ) { - sprintf( sufnm, "%s", schnm ); + ocnt = snprintf( sufnm, MAX_LEN, "%s", schnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; + } } else { - sprintf( sufnm, "%s_%d", schnm, suffix ); + ocnt = snprintf( sufnm, MAX_LEN, "%s_%d", schnm, suffix ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; + } + } + ocnt = snprintf( fnm, MAX_LEN, "%s.h", sufnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; } - sprintf( fnm, "%s.h", sufnm ); if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { return; @@ -447,7 +457,11 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) fprintf( libfile, "\n#include \"%s.h\"\n", schnm ); // 3. header for namespace to contain all formerly-global variables - sprintf( fnm, "%sNames.h", schnm ); + ocnt = snprintf( fnm, MAX_LEN, "%sNames.h", schnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; + } + if( !( files->names = FILEcreate( fnm ) ) ) { return; } @@ -462,7 +476,11 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) if( suffix <= 1 ) { /* I.e., if this is our first pass with schema */ - sprintf( fnm, "%s.init.cc", schnm ); + ocnt = snprintf( fnm, MAX_LEN, "%s.init.cc", schnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; + } + /* Note - We use schnm (without the "_x" suffix sufnm has) since we ** only generate a single init.cc file. */ if( !( initfile = ( files -> init ) = FILEcreate( fnm ) ) ) { @@ -525,7 +543,11 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) fprintf( files->classes, "\n#include \"%sNames.h\"\n", schnm ); } else { /* Just reopen the .init.cc (in append mode): */ - sprintf( fnm, "%s.init.cc", schnm ); + ocnt = snprintf( fnm, MAX_LEN, "%s.init.cc", schnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; + } + initfile = files->init = fopen( fnm, "a" ); } diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 8c672868a..7a6eb6df6 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -370,7 +370,7 @@ char* EXPRto_python( Expression e ) { buf = ( char * )sc_malloc( bufsize ); if( !buf ) { - fprintf(stderr, "%s failed to allocate buffer: %s\n", __FUNCTION__, strerror(errno) ); + fprintf( stderr, "%s failed to allocate buffer: %s\n", __func__, strerror( errno ) ); abort(); } @@ -467,7 +467,7 @@ char* EXPRto_python( Expression e ) { temp = ( char * )sc_realloc( buf, 1 + strlen(buf) ); if( temp == 0 ) { - fprintf(stderr, "%s failed to realloc buffer: %s\n", __FUNCTION__, strerror(errno) ); + fprintf( stderr, "%s failed to realloc buffer: %s\n", __func__, strerror( errno ) ); abort(); } diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index 21c16d1c4..ef039f828 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -151,6 +151,7 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { ******************************************************************/ void SCHEMAprint( Schema schema, FILES * files, int suffix ) { + int ocnt = 0; char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; /* sufnm = schema name + suffix */ FILE * libfile; @@ -161,9 +162,15 @@ void SCHEMAprint( Schema schema, FILES * files, int suffix ) { if( suffix == 0 ) { sprintf( sufnm, "%s", schnm ); } else { - sprintf( sufnm, "%s_%d", schnm, suffix ); + ocnt = snprintf( sufnm, MAX_LEN, "%s_%d", schnm, suffix ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper_python.cc - sufnm not large enough to hold string\n"; + } + } + ocnt = snprintf( fnm, MAX_LEN, "%s.h", sufnm ); + if( ocnt > MAX_LEN ) { + std::cerr << "Warning - classes_wrapper_python.cc - fnm not large enough to hold string\n"; } - sprintf( fnm, "%s.h", sufnm ); np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ diff --git a/src/express/expr.c b/src/express/expr.c index 7f814cf89..19ab0af91 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -231,6 +231,8 @@ static int EXP_resolve_op_dot_fuzzy( Type selection, Symbol sref, Expression * e *e = item; *dt = DICT_type; return 1; + } else { + return 0; } default: return 0; @@ -317,6 +319,7 @@ Type EXPresolve_op_dot( Expression expr, Scope scope ) { } else { fprintf( stderr, "EXPresolved_op_dot: attribute not an attribute?\n" ); ERRORabort( 0 ); + return( Type_Bad ); } default: @@ -601,13 +604,13 @@ Type EXPresolve_op_relational( Expression e, Scope s ) { void EXPresolve_op_default( Expression e, Scope s ) { int failed = 0; - switch( OPget_number_of_operands( e->e.op_code ) ) { - case 3: - EXPresolve( e->e.op3, s, Type_Dont_Care ); - failed = is_resolve_failed( e->e.op3 ); - case 2: - EXPresolve( e->e.op2, s, Type_Dont_Care ); - failed |= is_resolve_failed( e->e.op2 ); + if( OPget_number_of_operands( e->e.op_code ) == 3 ) { + EXPresolve( e->e.op3, s, Type_Dont_Care ); + failed = is_resolve_failed( e->e.op3 ); + } + if( OPget_number_of_operands( e->e.op_code ) == 2 ) { + EXPresolve( e->e.op2, s, Type_Dont_Care ); + failed |= is_resolve_failed( e->e.op2 ); } EXPresolve( e->e.op1, s, Type_Dont_Care ); if( failed || is_resolve_failed( e->e.op1 ) ) { diff --git a/src/express/info.c b/src/express/info.c index 85553d667..bacc2f564 100644 --- a/src/express/info.c +++ b/src/express/info.c @@ -18,7 +18,7 @@ void EXPRESSusage( int _exit ) { fprintf( stderr, "\t-i warning ignore\n" ); fprintf( stderr, "and is one of:\n" ); fprintf( stderr, "\tnone\n\tall\n" ); - fprintf( stderr, ERRORget_warnings_help("\t", "\n") ); + fprintf( stderr, "%s", ERRORget_warnings_help( "\t", "\n" ) ); fprintf( stderr, "and is one or more of:\n" ); fprintf( stderr, " e entity\n" ); fprintf( stderr, " p procedure\n" ); diff --git a/src/express/stack.h b/src/express/stack.h index d0d99e14f..cb80180c9 100644 --- a/src/express/stack.h +++ b/src/express/stack.h @@ -75,12 +75,4 @@ typedef Linked_List Stack; /* function prototypes */ /***********************/ -/*******************************/ -/* inline function definitions */ -/*******************************/ - -#if supports_inline_functions || defined(STACK_C) - -#endif /* supports_inline_functions || defined(STACK_C) */ - #endif /* STACK_H */ From b158a79f6c2fa743d30c8eb71a49c78c7c05ea2d Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:47:16 -0400 Subject: [PATCH 138/244] Remove unneeded indentation in generated output. Newer GCC doesn't like the indenting of this line, since in some situations it looks as if the logic is being guarded by an if clause when it is not. --- src/exp2cxx/selects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index b4fd3e60d..d72163667 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -34,7 +34,7 @@ extern int multiple_inheritance; ((t)->u.type->body->type == integer_) || \ ((t)->u.type->body->type == number_) ) #define PRINT_BUG_REPORT \ - fprintf( f, " std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ + fprintf( f, "std::cerr << __FILE__ << \":\" << __LINE__ << \": ERROR" \ " in schema library: \\n\" \n << _POC_ << \"\\n\\n\";\n"); #define PRINT_SELECTBUG_WARNING(f) \ From 211bc660da45ebbaec48bac5c5b5653f000ecad0 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:50:37 -0400 Subject: [PATCH 139/244] Per suggestion from Sean, don't hardcode file or line numbers. --- src/exp2cxx/classes_wrapper.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 7a847885e..874491ee7 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -405,17 +405,17 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) if( suffix == 0 ) { ocnt = snprintf( sufnm, MAX_LEN, "%s", schnm ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 425 - sufnm not large enough to hold schnm\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - sufnm not large enough to hold schnm\n"; } } else { ocnt = snprintf( sufnm, MAX_LEN, "%s_%d", schnm, suffix ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 430 - sufnm not large enough to hold string\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - sufnm not large enough to hold string\n"; } } ocnt = snprintf( fnm, MAX_LEN, "%s.h", sufnm ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 436 - sufnm not large enough to hold string\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - sufnm not large enough to hold string\n"; } if( !( incfile = ( files -> inc ) = FILEcreate( fnm ) ) ) { @@ -459,7 +459,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) // 3. header for namespace to contain all formerly-global variables ocnt = snprintf( fnm, MAX_LEN, "%sNames.h", schnm ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 480 - fnm not large enough to hold schnm\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - fnm not large enough to hold schnm\n"; } if( !( files->names = FILEcreate( fnm ) ) ) { @@ -478,7 +478,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) /* I.e., if this is our first pass with schema */ ocnt = snprintf( fnm, MAX_LEN, "%s.init.cc", schnm ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 499 - fnm not large enough to hold string\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - fnm not large enough to hold string\n"; } /* Note - We use schnm (without the "_x" suffix sufnm has) since we @@ -545,7 +545,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) /* Just reopen the .init.cc (in append mode): */ ocnt = snprintf( fnm, MAX_LEN, "%s.init.cc", schnm ); if( ocnt > MAX_LEN ) { - std::cerr << "Warning - classes_wrapper.cc line 558 - sufnm not large enough to hold string\n"; + std::cerr << "Warning - " << __FILE__ << " line " << __LINE__ << " - sufnm not large enough to hold string\n"; } initfile = files->init = fopen( fnm, "a" ); From 093e59e5a7a7607cfaed23111db5718d9579b639 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 16 Aug 2021 19:41:23 -0400 Subject: [PATCH 140/244] Per suggestion from Sean, go ahead and export all symbols. --- include/express/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/express/error.h b/include/express/error.h index 9a9334f88..4d9c1dde8 100644 --- a/include/express/error.h +++ b/include/express/error.h @@ -226,6 +226,6 @@ extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env ); extern SC_EXPRESS_EXPORT void ERRORunsafe( void ); extern SC_EXPRESS_EXPORT char * ERRORget_warnings_help(const char* prefix, const char *eol); -extern bool ERRORis_enabled(enum ErrorCode errnum); +extern SC_EXPRESS_EXPORT bool ERRORis_enabled(enum ErrorCode errnum); #endif /* ERROR_H */ From 8dc5dceb59df34a22c25e664e69bf152a97b6204 Mon Sep 17 00:00:00 2001 From: "Wolfgang E. Sanyer" Date: Tue, 3 Aug 2021 14:10:46 -0400 Subject: [PATCH 141/244] Fix compile error related to ODR violation. These structs were already declared in alg.h, leading to build issues. fixes #404 Signed-off-by: Wolfgang E. Sanyer (cherry picked from commit fa87ef1e6d2e670730c3b7b19e8acaa4186eaac5) --- src/express/memory.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/express/memory.c b/src/express/memory.c index f8b536e45..da4db3751 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -1,6 +1,7 @@ #include "express/memory.h" #include "express/alloc.h" +#include "express/alg.h" #include "express/hash.h" #include "express/symbol.h" @@ -26,11 +27,6 @@ struct freelist_head TYPEBODY_fl; struct freelist_head VAR_fl; -struct freelist_head FUNC_fl; -struct freelist_head RULE_fl; -struct freelist_head PROC_fl; -struct freelist_head WHERE_fl; - struct freelist_head ENTITY_fl; struct freelist_head CASE_IT_fl; From e4277656ef2164f5aa60cd3a707bc7055f931a8e Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:00:15 -0400 Subject: [PATCH 142/244] Add a sentinel target for perplex generated output Getting an intermittent failure on Windows where the expscan.h header apparently isn't present on the file system soon enough for the build to succeed (a subsequent reinvocation of the build command does succeed.) Try the standard technique of making another file write depend on the outputs of the header and src file, then define a target depending on that sentinel file and make the obj libraries depend on that target. --- cmake/FindPERPLEX.cmake | 8 ++++++++ src/express/CMakeLists.txt | 3 +++ 2 files changed, 11 insertions(+) diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index 34982516a..022a07666 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -227,6 +227,14 @@ if(NOT COMMAND PERPLEX_TARGET) set(PERPLEX_${Name}_SRC ${${PVAR_PREFIX}_OUT_SRC_FILE}) set(PERPLEX_${Name}_HDR ${${PVAR_PREFIX}_OUT_HDR_FILE}) set(PERPLEX_${Name}_INCLUDE_DIR ${${PVAR_PREFIX}_WORKING_DIR}) + + add_custom_command( + OUTPUT ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel + COMMAND ${CMAKE_COMMAND} -E touch ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel + DEPENDS ${${PVAR_PREFIX}_OUT_SRC_FILE} ${${PVAR_PREFIX}_OUT_HDR_FILE} + ) + add_custom_target(${Name} DEPENDS ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel) + endmacro(PERPLEX_TARGET) endif(NOT COMMAND PERPLEX_TARGET) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 7448a9a36..2a3aa4299 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -66,6 +66,9 @@ foreach(_src ${EXPRESS_SOURCES}) add_library(${_objlib} OBJECT ${_src}) add_dependencies(${_objlib} objlib_expscan_c) add_dependencies(${_objlib} objlib_expparse_c) + if(TARGET ExpScanner) + add_dependencies(${_objlib} ExpScanner) + endif(TARGET ExpScanner) if(MSVC) set_property(TARGET ${_objlib} APPEND PROPERTY COMPILE_DEFINITIONS "SC_EXPRESS_DLL_EXPORTS") set_property(TARGET ${_objlib} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SC_EXPRESS_DLL_IMPORTS") From 0f1196ef94ee7ab3fc49458f08ceed45b98159ac Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:20:22 -0400 Subject: [PATCH 143/244] Remove references to stepcode.org --- CMakeLists.txt | 3 +-- NEWS | 5 ++++- README.md | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0251f05d9..d27a53e05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,8 +162,7 @@ endif(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS) if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND 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") + "** Note: CMake variable SC_BUILD_SCHEMAS was not set - defaults to building ALL 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() diff --git a/NEWS b/NEWS index 35bcba3e6..564f1e155 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ -STEPcode -- http://github.com/stepcode/stepcode -- http://stepcode.org ************************************************************************ + STEPcode + http://github.com/stepcode/stepcode +************************************************************************ + Release 0.8 (December, 2014) New since v0.7: diff --git a/README.md b/README.md index 4df78fd0d..2df902f5e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Linux, OSX (LLVM) | Windows (MSVC) [![Build Status](https://travis-ci.org/stepcode/stepcode.svg?branch=master)](https://travis-ci.org/stepcode/stepcode) | [![Build status](https://ci.appveyor.com/api/projects/status/3fbr9t9gfa812oqu?svg=true)](https://ci.appveyor.com/project/mpictor/stepcode) *********************************************************************** -STEPcode v0.8 -- stepcode.org, github.com/stepcode/stepcode +STEPcode v0.8 -- 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 From 75af3df51c73839d35464b402fc1508d158a335e Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:24:20 -0400 Subject: [PATCH 144/244] Shouldn't need the SC_VERSION.txt file --- SC_VERSION.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 SC_VERSION.txt diff --git a/SC_VERSION.txt b/SC_VERSION.txt deleted file mode 100644 index aec258df7..000000000 --- a/SC_VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -0.8 From ccb6728efa9314820bf7283cd9db6f122ca349c2 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:29:06 -0400 Subject: [PATCH 145/244] Add some more patterns to the gitignore file. --- .gitignore | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 008fe8f32..462bd78c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,20 @@ +# Common build directories used in the source tree /build +/.build + +# Temporary files +*~ +\#*\# +.\#* +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] + +# OS specific files +.DS_Store +.DS_Store? + +# Tool specific patterns *.kdev4 .kdev_include_paths From 125820c84c1fd572e1be1c4ffc8bbbb0dc56bd1d Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:18:11 -0400 Subject: [PATCH 146/244] Start of a Github Actions CI setup. --- .githhub/workflows/build.yml | 155 +++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 .githhub/workflows/build.yml diff --git a/.githhub/workflows/build.yml b/.githhub/workflows/build.yml new file mode 100644 index 000000000..6d406643a --- /dev/null +++ b/.githhub/workflows/build.yml @@ -0,0 +1,155 @@ +name: STEPCODE + +on: [push] + +jobs: + windows: + name: Windows Latest MSVC + runs-on: windows-latest + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Checkout + uses: actions/checkout@v2 + + - name: Add github workspace to path + # https://github.community/t/deprecated-add-path/136621 + run: echo "$ENV{GITHUB_WORKSPACE}" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Add cl.exe to PATH + uses: ilammy/msvc-dev-cmd@v1 + + - name: Configure + run: | + cmake -S . -B build -G Ninja -D CMAKE_C_COMPILER="cl.exe" -D CMAKE_CXX_COMPILER="cl.exe" -DDEBUGGING_GENERATED_SOURCES=ON + # We do the following in order to help ensure files are "flushed" + # to disk before compilation is attempted + # https://superuser.com/a/1553374/1286142 + powershell Write-VolumeCache C + powershell Write-VolumeCache D + + - name: Build + run: cd build && ninja -j1 -v + + linux: + name: Ubuntu Latest GCC + runs-on: ubuntu-20.04 + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + # TODO - we will want this when the new parser work comes in, + # as we won't need perplex and the system tools should suffice + # to exercise the generator logic: + # + # - name: Setup - System + # env: + # DEBIAN_FRONTEND: noninteractive + # run: | + # sudo apt-get update + # # Install dev tools + # sudo apt-get install re2c lemon + # sudo apt-get clean + + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DDEBUGGING_GENERATED_SOURCES=ON + + - name: Build + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cmake --build build --config Release + + osx: + name: macOS Latest Clang + runs-on: macos-latest + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + export CC=clang + export CXX=clang++ + cmake -S . -G Ninja -B build -D CMAKE_BUILD_TYPE=Release -DDEBUGGING_GENERATED_SOURCES=ON + + - name: Build + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cd build && ninja -j1 + +# brlcad: +# name: BRL-CAD step-g Test +# runs-on: ubuntu-20.04 +# strategy: +# fail-fast: true +# steps: +# - name: Setup - CMake +# uses: lukka/get-cmake@latest +# +# - name: Setup - Ninja +# uses: seanmiddleditch/gha-setup-ninja@master +# +# - name: Setup - System +# env: +# DEBIAN_FRONTEND: noninteractive +# run: | +# sudo apt-get update +# # Install dev tools +# sudo apt-get install re2c lemon +# sudo apt-get clean +# +# - name: Checkout +# run: | +# git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main +# cd brlcad/src/other/ext && rm -rf stepcode +# git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop +# # Ordinarily BRL-CAD keeps track of what files are supposed to be +# # present in the repository. In this case we're not interested in +# # updating the list to the working stepcode filelist, so use an empty +# # list instead +# echo "set(stepcode_ignore_files)" > stepcode.dist +# cd ../../../../ +# +# +# - name: Configure +# run: | +# export PATH=$ENV{GITHUB_WORKSPACE}:$PATH +# cd brlcad +# cmake -S . -G Ninja -B build -DENABLE_ALL=ON -DCMAKE_BUILD_TYPE=Release -DEXT_BUILD_VERBOSE=ON +# cd .. +# +# - name: Build +# run: | +# export PATH=$ENV{GITHUB_WORKSPACE}:$PATH +# cd brlcad +# cmake --build build --config Release --target step-g +# cd .. +# From 20c6d4c80000c7fa6232420c41f8cc51b52e7cb4 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 10:19:21 -0400 Subject: [PATCH 147/244] Enable all tests, set up BRL-CAD step-g WIN32 test With all the recent patches to develop applied, the following tests all succeeded as Github Actions in a test repository. --- .githhub/workflows/build.yml | 179 +++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 51 deletions(-) diff --git a/.githhub/workflows/build.yml b/.githhub/workflows/build.yml index 6d406643a..2572fb230 100644 --- a/.githhub/workflows/build.yml +++ b/.githhub/workflows/build.yml @@ -30,7 +30,7 @@ jobs: - name: Configure run: | - cmake -S . -B build -G Ninja -D CMAKE_C_COMPILER="cl.exe" -D CMAKE_CXX_COMPILER="cl.exe" -DDEBUGGING_GENERATED_SOURCES=ON + cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DSC_ENABLE_TESTING=ON # We do the following in order to help ensure files are "flushed" # to disk before compilation is attempted # https://superuser.com/a/1553374/1286142 @@ -40,6 +40,10 @@ jobs: - name: Build run: cd build && ninja -j1 -v + - name: Test + run: | + cd build && ctest -j1 . + linux: name: Ubuntu Latest GCC runs-on: ubuntu-20.04 @@ -71,13 +75,17 @@ jobs: - name: Configure run: | export PATH=$ENV{GITHUB_WORKSPACE}:$PATH - cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DDEBUGGING_GENERATED_SOURCES=ON + cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON - name: Build run: | export PATH=$ENV{GITHUB_WORKSPACE}:$PATH cmake --build build --config Release + - name: Test + run: | + cd build && ctest -j1 . -C Release + osx: name: macOS Latest Clang runs-on: macos-latest @@ -98,58 +106,127 @@ jobs: export PATH=$ENV{GITHUB_WORKSPACE}:$PATH export CC=clang export CXX=clang++ - cmake -S . -G Ninja -B build -D CMAKE_BUILD_TYPE=Release -DDEBUGGING_GENERATED_SOURCES=ON + cmake -S . -G Ninja -B build -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON - name: Build run: | export PATH=$ENV{GITHUB_WORKSPACE}:$PATH cd build && ninja -j1 -# brlcad: -# name: BRL-CAD step-g Test -# runs-on: ubuntu-20.04 -# strategy: -# fail-fast: true -# steps: -# - name: Setup - CMake -# uses: lukka/get-cmake@latest -# -# - name: Setup - Ninja -# uses: seanmiddleditch/gha-setup-ninja@master -# -# - name: Setup - System -# env: -# DEBIAN_FRONTEND: noninteractive -# run: | -# sudo apt-get update -# # Install dev tools -# sudo apt-get install re2c lemon -# sudo apt-get clean -# -# - name: Checkout -# run: | -# git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main -# cd brlcad/src/other/ext && rm -rf stepcode -# git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop -# # Ordinarily BRL-CAD keeps track of what files are supposed to be -# # present in the repository. In this case we're not interested in -# # updating the list to the working stepcode filelist, so use an empty -# # list instead -# echo "set(stepcode_ignore_files)" > stepcode.dist -# cd ../../../../ -# -# -# - name: Configure -# run: | -# export PATH=$ENV{GITHUB_WORKSPACE}:$PATH -# cd brlcad -# cmake -S . -G Ninja -B build -DENABLE_ALL=ON -DCMAKE_BUILD_TYPE=Release -DEXT_BUILD_VERBOSE=ON -# cd .. -# -# - name: Build -# run: | -# export PATH=$ENV{GITHUB_WORKSPACE}:$PATH -# cd brlcad -# cmake --build build --config Release --target step-g -# cd .. -# + - name: Test + run: | + cd build && ctest -j1 . -C Release + + brlcad_linux: + name: BRL-CAD Linux step-g Test + runs-on: ubuntu-20.04 + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Setup - System + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo apt-get update + # Install dev tools + sudo apt-get install re2c lemon + sudo apt-get clean + + - name: Checkout + run: | + git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main + cd brlcad/src/other/ext && rm -rf stepcode + git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop + # Ordinarily BRL-CAD keeps track of what files are supposed to be + # present in the repository. In this case we're not interested in + # updating the list to the working stepcode filelist, so use an empty + # list instead + echo "set(stepcode_ignore_files)" > stepcode.dist + cd ../../../../ + + + - name: Configure + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cd brlcad + cmake -S . -G Ninja -B build -DENABLE_ALL=ON -DCMAKE_BUILD_TYPE=Release -DEXT_BUILD_VERBOSE=ON + cd .. + + - name: Build + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cd brlcad + cmake --build build --config Release --target step-g + cd .. + + - name: Test + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + cd brlcad/build + ./bin/step-g ../db/nist/NIST_MBE_PMI_3.stp -o nist3.g + cd ../.. + + + brlcad_windows: + name: BRL-CAD Windows step-g Test + runs-on: windows-latest + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Add github workspace to path + # https://github.community/t/deprecated-add-path/136621 + run: echo "$ENV{GITHUB_WORKSPACE}" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Add cl.exe to PATH + uses: ilammy/msvc-dev-cmd@v1 + + - name: Checkout + run: | + git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main + cd brlcad/src/other/ext + cmake -E rm -r stepcode + git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop + # Ordinarily BRL-CAD keeps track of what files are supposed to be + # present in the repository. In this case we're not interested in + # updating the list to the working stepcode filelist, so use an empty + # list instead + echo "set(stepcode_ignore_files)" > stepcode.dist + cd ../../../../ + + - name: Configure + run: | + cd brlcad && cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DSC_ENABLE_TESTING=ON + cd .. + # We do the following in order to help ensure files are "flushed" + # to disk before compilation is attempted + # https://superuser.com/a/1553374/1286142 + powershell Write-VolumeCache C + powershell Write-VolumeCache D + + - name: Build + run: | + cd brlcad/build + ninja -j1 -v step-g + cd ../.. + + - name: Test + run: | + cd brlcad/build + ./bin/step-g.exe ../db/nist/NIST_MBE_PMI_3.stp -o nist3.g + cd ../.. + From 5fddadb1e4aec91d923496d9e0875a9674353d75 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:52:17 -0400 Subject: [PATCH 148/244] Test with the Ubuntu clang compiler as well. --- .githhub/workflows/build.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.githhub/workflows/build.yml b/.githhub/workflows/build.yml index 2572fb230..90294c127 100644 --- a/.githhub/workflows/build.yml +++ b/.githhub/workflows/build.yml @@ -86,6 +86,49 @@ jobs: run: | cd build && ctest -j1 . -C Release + linux_clang: + name: Ubuntu Latest Clang + runs-on: ubuntu-20.04 + strategy: + fail-fast: true + steps: + - name: Setup - CMake + uses: lukka/get-cmake@latest + + - name: Setup - Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + # TODO - we will want this when the new parser work comes in, + # as we won't need perplex and the system tools should suffice + # to exercise the generator logic: + # + # - name: Setup - System + # env: + # DEBIAN_FRONTEND: noninteractive + # run: | + # sudo apt-get update + # # Install dev tools + # sudo apt-get install re2c lemon + # sudo apt-get clean + + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + CC=clang CXX=clang++ cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON + + - name: Build + run: | + export PATH=$ENV{GITHUB_WORKSPACE}:$PATH + CC=clang CXX=clang++ cmake --build build --config Release + + - name: Test + run: | + cd build && ctest -j1 . -C Release + + osx: name: macOS Latest Clang runs-on: macos-latest From 30534dbf0e6ed81472983c654b68c7811b7e62a0 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:44:04 -0400 Subject: [PATCH 149/244] Remove the old CI files --- .appveyor.yml | 65 --------------------------------------------------- .travis.yml | 16 ------------- README.md | 5 +--- 3 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index b7f2d5c36..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,65 +0,0 @@ -version: '{build}' - -# for Appveyor CI (windows) - -branches: - only: - - master - -os: Windows Server 2012 R2 - -clone_folder: c:\projects\STEPcode - -#grab zip instead of git clone -shallow_clone: true -platform: x64 -configuration: Debug - -# errors or couldn't be found by cmake -# - GENERATOR: "Visual Studio 9 2008" -# ARCH: 32 -# - GENERATOR: "Visual Studio 10" -# ARCH: 32 - -#no point in these without artifact support... -# - GENERATOR: "Visual Studio 11" - #ARCH: 32 - #- GENERATOR: "Visual Studio 12" - #ARCH: 32 - -environment: - matrix: - - GENERATOR: "Visual Studio 12 Win64" - ARCH: 64 - -# build: -# parallel: true -# project: ALL_BUILD.vcxproj - -#appveyor limits compile/test to 30 minutes -# to reduce time, only test schemas with files: ifc2x3, ap214e3, ap209 - -build_script: -- ps: | - cd c:\projects\STEPcode - mkdir build - cd build - cmake -version - grep --version - cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209" - echo "filtering build output with grep" - cmake --build . --config Debug | grep -ve "CMake does not need to re-run because" -e "ZERO_CHECK.ZERO_CHECK" -e "^ Creating directory" - -#msbuld seems to provide no benefits, and I can't filter its output... -#msbuild SC.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Debug /p:Platform=x64 -# /toolsversion:14.0 /p:PlatformToolset=v140 - -test_script: - - cmd: echo Running CTest... - - cmd: cd c:\projects\STEPcode\build - - cmd: echo excluding test_inverse_attr3, which hangs - - cmd: ctest -j1 . -C Debug --output-on-failure - -# - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log - -# we could upload a compiled zip somewhere (see Appveyor artifact documentation) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 269a382ad..000000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: cpp -compiler: - - clang -script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2 --output-on-failure -branches: - only: - - master -notifications: - irc: "chat.freenode.net#stepcode" - email: scl-dev@groups.google.com - on_success: change - on_failure: always -os: - - linux - - osx diff --git a/README.md b/README.md index 2df902f5e..502388cf7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ - Travis-CI | AppVeyor CI -:-------------:|:---------------: -Linux, OSX (LLVM) | Windows (MSVC) -[![Build Status](https://travis-ci.org/stepcode/stepcode.svg?branch=master)](https://travis-ci.org/stepcode/stepcode) | [![Build status](https://ci.appveyor.com/api/projects/status/3fbr9t9gfa812oqu?svg=true)](https://ci.appveyor.com/project/mpictor/stepcode) +![Build Status](https://github.com/stepcode/stepcode/actions/workflows/build.yml/badge.svg?branch=develop) *********************************************************************** STEPcode v0.8 -- github.com/stepcode/stepcode From de375f8ceadc27e07c9d0bcbb28604f629adfb50 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 4 Sep 2021 17:30:03 +0100 Subject: [PATCH 150/244] fix github actions / ci directory name --- {.githhub => .github}/workflows/build.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.githhub => .github}/workflows/build.yml (100%) diff --git a/.githhub/workflows/build.yml b/.github/workflows/build.yml similarity index 100% rename from .githhub/workflows/build.yml rename to .github/workflows/build.yml From bf14461daeb788cee053f0839db5a0c2b910403d Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:22:05 -0400 Subject: [PATCH 151/244] Point to the main stepcode repository --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90294c127..5d4e04bd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,7 +185,7 @@ jobs: run: | git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main cd brlcad/src/other/ext && rm -rf stepcode - git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop + git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop # Ordinarily BRL-CAD keeps track of what files are supposed to be # present in the repository. In this case we're not interested in # updating the list to the working stepcode filelist, so use an empty @@ -243,7 +243,7 @@ jobs: git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main cd brlcad/src/other/ext cmake -E rm -r stepcode - git clone --depth 1 git://github.com/starseeker/stepcode.git -b develop + git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop # Ordinarily BRL-CAD keeps track of what files are supposed to be # present in the repository. In this case we're not interested in # updating the list to the working stepcode filelist, so use an empty From 2a50010e6f6b8bd4843561e48fdb0fd4e8b87f39 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 6 Sep 2021 19:53:23 -0400 Subject: [PATCH 152/244] No longer using appveyor --- misc/summarize-appveyor-log.go | 330 --------------------------------- 1 file changed, 330 deletions(-) delete mode 100644 misc/summarize-appveyor-log.go diff --git a/misc/summarize-appveyor-log.go b/misc/summarize-appveyor-log.go deleted file mode 100644 index f14d888ce..000000000 --- a/misc/summarize-appveyor-log.go +++ /dev/null @@ -1,330 +0,0 @@ -//summarize MSVC errors from an appveyor log -// compile with 'go build summarize-appveyor-log.go' -// takes 0 or 1 args; with 0, gets log from latest -// build. with 1, uses that file as raw json-like log -package main - -import ( - "bufio" - "encoding/json" - "fmt" - "io" - "net/http" - "os" - "regexp" - "sort" - "strings" -) - -const ( - headerKey = "Authorization" - headerVal = "Bearer %s" - projUrl = "https://ci.appveyor.com/api/projects/mpictor/stepcode" - //"https://ci.appveyor.com/api/buildjobs/2rjxdv1rnb8jcg8y/log" - logUrl = "https://ci.appveyor.com/api/buildjobs/%s/log" - consoleUrl = "https://ci.appveyor.com/api/buildjobs/%s/console" -) - -func main() { - var rawlog io.ReadCloser - var build string - var err error - if len(os.Args) == 2 { - rawlog, build, err = processArgv() - } else { - rawlog, build, err = getLog() - } - if err != nil { - fmt.Fprintf(os.Stderr, "ERROR: %s\n", err) - return - } - defer rawlog.Close() - log := decodeConsole(rawlog) - warns, errs := countMessages(log) - fi, err := os.Create(fmt.Sprintf("appveyor-%s.smy", build)) - if err != nil { - fmt.Fprintf(os.Stderr, "ERROR: %s\n", err) - return - } - printMessages("error", errs, fi) - printMessages("warning", warns, fi) - - fmt.Printf("done\n") - -} - -/* categorizes warnings and errors based upon the MSVC message number (i.e. C4244) - * the regex will match lines like -c:\projects\stepcode\src\base\sc_benchmark.h(45): warning C4251: 'benchmark::descr' : class 'std::basic_string,std::allocator>' needs to have dll-interface to be used by clients of class 'benchmark' [C:\projects\STEPcode\build\src\base\base.vcxproj] -[00:03:48] C:\projects\STEPcode\src\base\sc_benchmark.cc(61): warning C4244: '=' : conversion from 'SIZE_T' to 'long', possible loss of data [C:\projects\STEPcode\build\src\base\base.vcxproj]* -*/ -func countMessages(log []string) (warns, errs map[string][]string) { - warns = make(map[string][]string) - errs = make(map[string][]string) - fname := " *(.*)" // $1 - fline := `(?:\((\d+)\)| ): ` // $2 - either line number in parenthesis or a space, followed by a colon - msgNr := `([A-Z]+\d+): ` // $3 - C4251, LNK2005, etc - msgTxt := `([^\[]*) ` // $4 - tail := `\[[^\[\]]*\]` - warnRe := regexp.MustCompile(fname + fline + `warning ` + msgNr + msgTxt + tail) - errRe := regexp.MustCompile(fname + fline + `(?:fatal )?error ` + msgNr + msgTxt + tail) - for _, line := range log { - if warnRe.MatchString(line) { - key := warnRe.ReplaceAllString(line, "$3") - path := strings.ToLower(warnRe.ReplaceAllString(line, "$1:$2")) - arr := warns[key] - if arr == nil { - arr = make([]string, 5) - //detailed text as first string in array - text := warnRe.ReplaceAllString(line, "$4") - arr[0] = fmt.Sprintf("%s", text) - } - //eliminate duplicates - match := false - for _, l := range arr { - if l == path { - match = true - } - } - if !match { - warns[key] = append(arr, path) - } - } else if errRe.MatchString(line) { - key := errRe.ReplaceAllString(line, "$3") - path := strings.ToLower(errRe.ReplaceAllString(line, "$1:$2")) - arr := errs[key] - if arr == nil { - arr = make([]string, 5) - //detailed text as first string in array - text := errRe.ReplaceAllString(line, "$4") - arr[0] = fmt.Sprintf("%s", text) - } - //eliminate duplicates - match := false - for _, l := range arr { - if l == path { - match = true - } - } - if !match { - errs[key] = append(arr, path) - } - } - } - return -} - -func printMessages(typ string, m map[string][]string, w io.Writer) { - //sort keys - keys := make([]string, 0, len(m)) - for key := range m { - keys = append(keys, key) - } - sort.Strings(keys) - for _, k := range keys { - for i, l := range m[k] { - //first string is an example, not a location - if i == 0 { - fmt.Fprintf(w, "%s %s (i.e. \"%s\")\n", typ, k, l) - } else if len(l) > 1 { //not sure where blank lines are coming from... - fmt.Fprintf(w, " >> %s\n", l) - } - } - } -} - -//structs from http://json2struct.mervine.net/ - -//{"values":[{"i":0,"t":"Specify a project or solution file. The directory does not contain a project or solution file.\r\n","dt":"00:00:04","bg":12,"fg":15}]} -type AppVeyorConsoleLines struct { - Values []struct { - I int `json:"i"` - Text string `json:"t"` - DateTime string `json:"dt"` - BgColor int `json:"bg"` - FgColor int `json:"fg"` - } -} -type AppVeyorBuild struct { - Build struct { - /*BuildNumber int `json:"buildNumber"`*/ - Version string `json:"version"` - Jobs []struct { - JobID string `json:"jobId"` - } `json:"jobs"` - } `json:"build"` -} - -func splitAppend(log *[]string, blob string) { - //blob = strings.Replace(blob,"\r\n", "\n",-1) - blob = strings.Replace(blob, "\\", "/", -1) - r := strings.NewReader(blob) - unwrapScanner := bufio.NewScanner(r) - for unwrapScanner.Scan() { - txt := unwrapScanner.Text() - //fmt.Printf("%s\n", txt) - *log = append(*log, txt) - } -} - -//calculate length of string without escape chars -// func escapeLen(s string)(l int) { -// //s = strings.Replace(s,"\\\\", "/",-1) -// s = strings.Replace(s,"\\\"", "",-1) -// s = strings.Replace(s,"\r\n", "RN",-1) -// return len(s) -// } - - -//decode the almost-JSON console data from appveyor -func decodeConsole(r io.Reader) (log []string) { - wrapper := Wrap(r) - dec := json.NewDecoder(wrapper) - var consoleLines AppVeyorConsoleLines - var err error - var txtBlob string - err = dec.Decode(&consoleLines) - if err == io.EOF { - err = nil - } - if err == nil { - for _, l := range consoleLines.Values { - txtBlob += l.Text - //el := escapeLen(l.Text) - //something inserts newlines at 229 chars (+\n\r == 231) (found in CMake output) - lenTwoThreeOne := len(l.Text) == 231 - if lenTwoThreeOne { - txtBlob = strings.TrimSuffix(txtBlob, "\r\n") - } - //something else starts new log lines at 1024 chars without inserting newlines (found in CTest error output) - if len(l.Text) != 1024 && !lenTwoThreeOne { - //fmt.Printf("sa for l %d, el %d\n", len(l.Text),el) - splitAppend(&log, txtBlob) - txtBlob = "" - } - } - } else { - fmt.Printf("decode err %s\n", err) - } - if len(txtBlob) > 0 { - splitAppend(&log, txtBlob) - } - return -} - -func processArgv() (log io.ReadCloser, build string, err error) { - fname := os.Args[1] - if len(fname) < 14 { - err = fmt.Errorf("Name arg '%s' too short. Run as '%s appveyor-NNN.log'", fname, os.Args[0]) - return - } - buildRe := regexp.MustCompile(`appveyor-(.+).log`) - build = buildRe.ReplaceAllString(fname, "$1") - if len(build) == 0 { - err = fmt.Errorf("No build id in %s", fname) - return - } - log, err = os.Open(fname) - return -} - -func getLog() (log io.ReadCloser, build string, err error) { - client := &http.Client{} - req, err := http.NewRequest("GET", projUrl, nil) - if err != nil { - return - } - apikey := os.Getenv("APPVEYOR_API_KEY") - //api key isn't necessary for read-only queries on public projects - if len(apikey) > 0 { - req.Header.Add(headerKey, fmt.Sprintf(headerVal, apikey)) - } //else { - // fmt.Printf("Env var APPVEYOR_API_KEY is not set.") - //} - resp, err := client.Do(req) - if err != nil { - return - } - - build, job := decodeProjInfo(resp.Body) - fmt.Printf("build #%s, jobId %s\n", build, job) - resp, err = http.Get(fmt.Sprintf(consoleUrl, job)) - if err != nil { - return - } - logName := fmt.Sprintf("appveyor-%s.log", build) - fi, err := os.Create(logName) - if err != nil { - return - } - _, err = io.Copy(fi, resp.Body) - if err != nil { - return - } - log, err = os.Open(logName) - if err != nil { - log = nil - } - return -} - -func decodeProjInfo(r io.Reader) (vers string, job string) { - dec := json.NewDecoder(r) - var av AppVeyorBuild - err := dec.Decode(&av) - if err != io.EOF && err != nil { - fmt.Printf("err %s\n", err) - return - } - if len(av.Build.Jobs) != 1 { - return - } - vers = av.Build.Version - job = av.Build.Jobs[0].JobID - return -} - -//wrap a reader, modifying content to make the json decoder happy -//only tested with data from appveyor console -type jsonWrapper struct { - source io.Reader - begin bool - end bool -} - -func Wrap(r io.Reader) *jsonWrapper { - return &jsonWrapper{ - source: r, - begin: true, - } -} - -// func nonNeg(n int) (int) { -// if n < 0 { -// return 0 -// } -// return n -// } - -func (w *jsonWrapper) Read(p []byte) (n int, err error) { - if w.end { - return 0, io.EOF - } - if w.begin { - w.begin = false - n = copy(p, []byte(`{"values":[`)) - } - m, err := w.source.Read(p[n:]) - n += m - if err == io.EOF { - w.end = true - if n < len(p) { - n = copy(p, []byte(`{"dummy":"data"}]}`)) - } else { - err = fmt.Errorf("No room to terminate JSON struct with '}'\n") - } - } - return -} - -// kate: indent-width 8; space-indent off; replace-tabs off; replace-tabs-save off; replace-trailing-space-save on; remove-trailing-space on; tab-intent on; tab-width 8; show-tabs off; From 7456652b67fe8589616a7ca763fa8d2e20acec9e Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 6 Sep 2021 19:56:51 -0400 Subject: [PATCH 153/244] Still getting appveyor in checks list (??) --- .appveyor.yml | 65 --------------------------------------------------- .travis.yml | 16 ------------- 2 files changed, 81 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index b7f2d5c36..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,65 +0,0 @@ -version: '{build}' - -# for Appveyor CI (windows) - -branches: - only: - - master - -os: Windows Server 2012 R2 - -clone_folder: c:\projects\STEPcode - -#grab zip instead of git clone -shallow_clone: true -platform: x64 -configuration: Debug - -# errors or couldn't be found by cmake -# - GENERATOR: "Visual Studio 9 2008" -# ARCH: 32 -# - GENERATOR: "Visual Studio 10" -# ARCH: 32 - -#no point in these without artifact support... -# - GENERATOR: "Visual Studio 11" - #ARCH: 32 - #- GENERATOR: "Visual Studio 12" - #ARCH: 32 - -environment: - matrix: - - GENERATOR: "Visual Studio 12 Win64" - ARCH: 64 - -# build: -# parallel: true -# project: ALL_BUILD.vcxproj - -#appveyor limits compile/test to 30 minutes -# to reduce time, only test schemas with files: ifc2x3, ap214e3, ap209 - -build_script: -- ps: | - cd c:\projects\STEPcode - mkdir build - cd build - cmake -version - grep --version - cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209" - echo "filtering build output with grep" - cmake --build . --config Debug | grep -ve "CMake does not need to re-run because" -e "ZERO_CHECK.ZERO_CHECK" -e "^ Creating directory" - -#msbuld seems to provide no benefits, and I can't filter its output... -#msbuild SC.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Debug /p:Platform=x64 -# /toolsversion:14.0 /p:PlatformToolset=v140 - -test_script: - - cmd: echo Running CTest... - - cmd: cd c:\projects\STEPcode\build - - cmd: echo excluding test_inverse_attr3, which hangs - - cmd: ctest -j1 . -C Debug --output-on-failure - -# - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log - -# we could upload a compiled zip somewhere (see Appveyor artifact documentation) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 269a382ad..000000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: cpp -compiler: - - clang -script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2 --output-on-failure -branches: - only: - - master -notifications: - irc: "chat.freenode.net#stepcode" - email: scl-dev@groups.google.com - on_success: change - on_failure: always -os: - - linux - - osx From f19cfecebed518f2f5a483173105dac82febe2c4 Mon Sep 17 00:00:00 2001 From: Brian Alger Date: Tue, 22 Mar 2022 07:45:44 -0600 Subject: [PATCH 154/244] Fix FileExists() logic --- src/clutils/dirobj.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clutils/dirobj.h b/src/clutils/dirobj.h index a89e28dad..7f3806d99 100644 --- a/src/clutils/dirobj.h +++ b/src/clutils/dirobj.h @@ -61,10 +61,10 @@ class SC_UTILS_EXPORT DirObj { const char * File( int index ); // check for file in the currently loaded directory bool FileExists( const char * file ) { - return Index( file ) ? 1 : 0; + return Index( file ) != -1; } bool FileExists( const std::string & file ) { - return Index( file.c_str() ) ? true : false; + return Index( file.c_str() ) != -1; } int Count(); From 90f3c5ce260744188a9722ca20649353fcf84516 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Thu, 9 Jun 2022 23:10:37 +0100 Subject: [PATCH 155/244] fix workflow actions for pull requests, and add manual trigger for updated branches --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d4e04bd6..5bcbc40c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,8 @@ name: STEPCODE -on: [push] +on: + workflow_dispatch: + pull_request: jobs: windows: From 50e2cdb5273b3c59b544277fe4bcf162a470e866 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:31:30 -0400 Subject: [PATCH 156/244] Fix git clone lines to use https Github has disabled git:// protocol support, so we need to switch: https://github.blog/2021-09-01-improving-git-protocol-security-github/ --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bcbc40c7..626c5887b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,9 +185,9 @@ jobs: - name: Checkout run: | - git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main + git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main cd brlcad/src/other/ext && rm -rf stepcode - git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop + git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop # Ordinarily BRL-CAD keeps track of what files are supposed to be # present in the repository. In this case we're not interested in # updating the list to the working stepcode filelist, so use an empty @@ -242,10 +242,10 @@ jobs: - name: Checkout run: | - git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main + git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main cd brlcad/src/other/ext cmake -E rm -r stepcode - git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop + git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop # Ordinarily BRL-CAD keeps track of what files are supposed to be # present in the repository. In this case we're not interested in # updating the list to the working stepcode filelist, so use an empty From aa6cbe2d724a7c86a5174eed2076adc57600c36c Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 9 Jan 2021 21:17:44 -0500 Subject: [PATCH 157/244] Fix example build (Issue #404) by adding the sc_cf.h.in file (making a copy rather than a symlink for the sake of Windows.) --- example/ap203min/include/sc_cf.h.in | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 example/ap203min/include/sc_cf.h.in diff --git a/example/ap203min/include/sc_cf.h.in b/example/ap203min/include/sc_cf.h.in new file mode 100644 index 000000000..67d88c433 --- /dev/null +++ b/example/ap203min/include/sc_cf.h.in @@ -0,0 +1,32 @@ +#ifndef SCL_CF_H +#define SCL_CF_H + +/**** Define statements for CMake ****/ +#cmakedefine SC_VERSION "@SC_VERSION@" +#cmakedefine HAVE_NDIR_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_PARAM_H 1 +#cmakedefine HAVE_SYSENT_H 1 +#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine HAVE_DIRENT_H 1 +#cmakedefine HAVE_STDBOOL_H 1 +#cmakedefine HAVE_PROCESS_H 1 +#cmakedefine HAVE_IO_H 1 + +#cmakedefine SC_TRACE_FPRINTF 1 +#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 + +#cmakedefine HAVE_ABS 1 +#cmakedefine HAVE_MEMCPY 1 +#cmakedefine HAVE_MEMMOVE 1 +#cmakedefine HAVE_GETOPT 1 +#cmakedefine HAVE_VSNPRINTF 1 + +#cmakedefine HAVE_SSIZE_T 1 + +#cmakedefine HAVE_STD_THREAD 1 +#cmakedefine HAVE_STD_CHRONO 1 +#cmakedefine HAVE_NULLPTR 1 + +#endif /* SCL_CF_H */ From f11d3256411951c07c89c9c57a0b7b43997ff033 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 13:48:23 +0000 Subject: [PATCH 158/244] remove Python 2.6 compatibility code --- AUTHORS | 1 + src/exp2python/python/SCL/BaseType.py | 1 - src/exp2python/python/SCL/Model.py | 1 - src/exp2python/python/SCL/Part21.py | 13 ------------- src/exp2python/python/SCL/SimpleDataTypes.py | 1 - src/exp2python/python/SCL/TypeChecker.py | 1 - src/exp2python/python/SCL/Utils.py | 1 - src/exp2python/python/SCL/essa_par.py | 1 - 8 files changed, 1 insertion(+), 19 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0e6c2518a..998c16349 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,6 +19,7 @@ Paviot, Thomas (tpaviot) Pictor, Mark (mpictor) Reed, Nick (nickreed) Shah, Kesha (kesha, keshashah) +Sparks, Devon (devonsparks) Thomas, Dawn (homovulgaris, madant) Wouters, Dave (davyw) Yapp, Clifford (starseeker) diff --git a/src/exp2python/python/SCL/BaseType.py b/src/exp2python/python/SCL/BaseType.py index a92fc39fa..070b5aa1e 100644 --- a/src/exp2python/python/SCL/BaseType.py +++ b/src/exp2python/python/SCL/BaseType.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. diff --git a/src/exp2python/python/SCL/Model.py b/src/exp2python/python/SCL/Model.py index c697dfa66..6e2279c5d 100644 --- a/src/exp2python/python/SCL/Model.py +++ b/src/exp2python/python/SCL/Model.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. diff --git a/src/exp2python/python/SCL/Part21.py b/src/exp2python/python/SCL/Part21.py index 3490b55bf..f6607841c 100644 --- a/src/exp2python/python/SCL/Part21.py +++ b/src/exp2python/python/SCL/Part21.py @@ -41,19 +41,6 @@ from ply.lex import LexError logger = logging.getLogger(__name__) - -# ensure Python 2.6 compatibility -if not hasattr(logging, 'NullHandler'): - class NullHandler(logging.Handler): - def handle(self, record): - pass - def emit(self, record): - pass - def createLock(self): - self.lock = None - - setattr(logging, 'NullHandler', NullHandler) - logger.addHandler(logging.NullHandler()) #################################################################################################### diff --git a/src/exp2python/python/SCL/SimpleDataTypes.py b/src/exp2python/python/SCL/SimpleDataTypes.py index d1a99f259..3cd28cbc2 100644 --- a/src/exp2python/python/SCL/SimpleDataTypes.py +++ b/src/exp2python/python/SCL/SimpleDataTypes.py @@ -32,7 +32,6 @@ """ Docstrings are courtesy of ISO 10303-11:1994(E) """ -from __future__ import print_function class NUMBER: """ diff --git a/src/exp2python/python/SCL/TypeChecker.py b/src/exp2python/python/SCL/TypeChecker.py index d46b00aad..e11b50f53 100644 --- a/src/exp2python/python/SCL/TypeChecker.py +++ b/src/exp2python/python/SCL/TypeChecker.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. diff --git a/src/exp2python/python/SCL/Utils.py b/src/exp2python/python/SCL/Utils.py index 4ba119349..fc50f83b8 100644 --- a/src/exp2python/python/SCL/Utils.py +++ b/src/exp2python/python/SCL/Utils.py @@ -30,7 +30,6 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''' This module provide string utils''' -from __future__ import print_function def process_nested_parent_str(attr_str,idx=0): ''' diff --git a/src/exp2python/python/SCL/essa_par.py b/src/exp2python/python/SCL/essa_par.py index 9c21ee4bd..314a91d4e 100644 --- a/src/exp2python/python/SCL/essa_par.py +++ b/src/exp2python/python/SCL/essa_par.py @@ -1,4 +1,3 @@ -from __future__ import print_function def process_nested_parent_str(attr_str): ''' The first letter should be a parenthesis From 53a2bcdd8bcdce059e3186d065bf5a9471e866d8 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 14:02:10 +0000 Subject: [PATCH 159/244] PEP-517 compliance, e.g. pip install . --- src/exp2python/python/{setup.py => LICENSE} | 20 +++++--------------- src/exp2python/python/pyproject.toml | 6 ++++++ src/exp2python/python/setup.cfg | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 15 deletions(-) rename src/exp2python/python/{setup.py => LICENSE} (81%) create mode 100644 src/exp2python/python/pyproject.toml create mode 100644 src/exp2python/python/setup.cfg diff --git a/src/exp2python/python/setup.py b/src/exp2python/python/LICENSE similarity index 81% rename from src/exp2python/python/setup.py rename to src/exp2python/python/LICENSE index bda974879..80934a9d5 100644 --- a/src/exp2python/python/setup.py +++ b/src/exp2python/python/LICENSE @@ -1,9 +1,10 @@ -#!/usr/bin/env python - # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) +# Copyright (c) 2014, Christopher HORLER (cshorler@googlemail.com) +# Copyright (c) 2021, Devon Sparks (devonsparks.com) + # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the StepClassLibrary (SCL). # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -29,15 +30,4 @@ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -from distutils.core import setup - -setup(name='SCL', - version='0.5', - description='Python STEP Class Library', - author='Thomas Paviot', - author_email='tpaviot@gmail.com', - url='https://github.com/mpictor/StepClassLibrary', - packages=['SCL'], - ) \ No newline at end of file +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/src/exp2python/python/pyproject.toml b/src/exp2python/python/pyproject.toml new file mode 100644 index 000000000..b5a3c468d --- /dev/null +++ b/src/exp2python/python/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/src/exp2python/python/setup.cfg b/src/exp2python/python/setup.cfg new file mode 100644 index 000000000..9e5dada61 --- /dev/null +++ b/src/exp2python/python/setup.cfg @@ -0,0 +1,18 @@ +[metadata] +name = SCL +version = 0.6.1 +author = Thomas Paviot , Christopher HORLER (cshorler@googlemail.com), Devon Sparks (devonsparks.com) +description = SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +url = https://github.com/stepcode/stepcode +project_urls = + Bug Tracker = https://github.com/stepcode/stepcode/issues +classifiers = + Programming Language :: Python :: 3 + +[options] +package_dir = + =. +packages=find: +python_requires = >=3.6 +install_requires = + ply From f8b786ac40b6682929ace04335f8ca54f4e807d7 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 18:18:26 +0000 Subject: [PATCH 160/244] fixup some exp2py tests --- src/exp2python/python/SCL/Utils.py | 10 ++++++---- src/exp2python/python/SCL/__init__.py | 2 +- src/exp2python/test/test_base.py | 7 +++---- src/exp2python/test/test_unitary_schemas.py | 1 - 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/exp2python/python/SCL/Utils.py b/src/exp2python/python/SCL/Utils.py index fc50f83b8..73b789cc9 100644 --- a/src/exp2python/python/SCL/Utils.py +++ b/src/exp2python/python/SCL/Utils.py @@ -1,4 +1,6 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) +# Copyright (c) 2021, Devon Sparks (devonsparks.com) + # All rights reserved. # This file is part of the StepClassLibrary (SCL). @@ -61,10 +63,10 @@ def process_nested_parent_str(attr_str,idx=0): return params,k if __name__=="__main__": - print(process_nested_parent_str2("'A'")[0]) - print(process_nested_parent_str2("30.0,0.0,5.0")[0]) - print(process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0]) - print(process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0]) + print(process_nested_parent_str("'A'")[0]) + print(process_nested_parent_str("30.0,0.0,5.0")[0]) + print(process_nested_parent_str("1,2,(3,4,5),6,7,8")[0]) + print(process_nested_parent_str("(#9149,#9166),#9142,.T.")[0]) diff --git a/src/exp2python/python/SCL/__init__.py b/src/exp2python/python/SCL/__init__.py index ebced4874..0bb38afaa 100644 --- a/src/exp2python/python/SCL/__init__.py +++ b/src/exp2python/python/SCL/__init__.py @@ -1 +1 @@ -__all__ = ['SCLBase','SimpleDataTypes','AggregationDataTypes','TypeChecker','ConstructedDataTypes','Expr','Part21'] +__all__ = ['SCLBase','SimpleDataTypes','AggregationDataTypes','TypeChecker','ConstructedDataTypes','Part21'] diff --git a/src/exp2python/test/test_base.py b/src/exp2python/test/test_base.py index 413d6fdf6..9781b5a45 100644 --- a/src/exp2python/test/test_base.py +++ b/src/exp2python/test/test_base.py @@ -403,10 +403,9 @@ def test_fill_bounded_set(self): # class TestENUMERATION(unittest.TestCase): def test_simple_enum(self): - scp = sys.modules[__name__] - ahead_or_behind = ENUMERATION('ahead','behind',scope=scp) - check_type(ahead,ahead_or_behind) - check_type(behind,ahead_or_behind) + ahead_or_behind = ENUMERATION('ahead_or_behind', 'ahead behind', module=__name__) + check_type(ahead_or_behind.ahead,ahead_or_behind) + check_type(ahead_or_behind.behind,ahead_or_behind) try: check_type("some string",ahead_or_behind) except TypeError: diff --git a/src/exp2python/test/test_unitary_schemas.py b/src/exp2python/test/test_unitary_schemas.py index 6d5f7f23f..c23bed882 100644 --- a/src/exp2python/test/test_unitary_schemas.py +++ b/src/exp2python/test/test_unitary_schemas.py @@ -38,7 +38,6 @@ from SCL.ConstructedDataTypes import * from SCL.AggregationDataTypes import * from SCL.TypeChecker import check_type -from SCL.Expr import * class TestSelectDataType(unittest.TestCase): ''' From ae6f9d9310806deda701f2eaf46f4adf8b17efb8 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 19:28:46 +0000 Subject: [PATCH 161/244] move tests to python folder --- src/exp2python/{test => python/tests}/test_SCL.py | 0 src/exp2python/{test => python/tests}/test_base.py | 0 src/exp2python/{test => python/tests}/test_builtin.py | 0 src/exp2python/{test => python/tests}/test_unitary_schemas.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/exp2python/{test => python/tests}/test_SCL.py (100%) rename src/exp2python/{test => python/tests}/test_base.py (100%) rename src/exp2python/{test => python/tests}/test_builtin.py (100%) rename src/exp2python/{test => python/tests}/test_unitary_schemas.py (100%) diff --git a/src/exp2python/test/test_SCL.py b/src/exp2python/python/tests/test_SCL.py similarity index 100% rename from src/exp2python/test/test_SCL.py rename to src/exp2python/python/tests/test_SCL.py diff --git a/src/exp2python/test/test_base.py b/src/exp2python/python/tests/test_base.py similarity index 100% rename from src/exp2python/test/test_base.py rename to src/exp2python/python/tests/test_base.py diff --git a/src/exp2python/test/test_builtin.py b/src/exp2python/python/tests/test_builtin.py similarity index 100% rename from src/exp2python/test/test_builtin.py rename to src/exp2python/python/tests/test_builtin.py diff --git a/src/exp2python/test/test_unitary_schemas.py b/src/exp2python/python/tests/test_unitary_schemas.py similarity index 100% rename from src/exp2python/test/test_unitary_schemas.py rename to src/exp2python/python/tests/test_unitary_schemas.py From bfe5219dc2022a62c72030d15b47b03402771ca0 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 19:47:48 +0000 Subject: [PATCH 162/244] Added new sanity test for Part 21 parser. --- .../python/SCL/ConstructedDataTypes.py | 1 - src/exp2python/python/tests/test_parser.py | 111 ++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/exp2python/python/tests/test_parser.py diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/SCL/ConstructedDataTypes.py index f272994ef..cc62eb72a 100644 --- a/src/exp2python/python/SCL/ConstructedDataTypes.py +++ b/src/exp2python/python/SCL/ConstructedDataTypes.py @@ -29,7 +29,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import sys from enum import Enum import BaseType diff --git a/src/exp2python/python/tests/test_parser.py b/src/exp2python/python/tests/test_parser.py new file mode 100644 index 000000000..20344d787 --- /dev/null +++ b/src/exp2python/python/tests/test_parser.py @@ -0,0 +1,111 @@ +# Copyright (c) 2021, Devon Sparks (devonsparks.com) +# All rights reserved. + +# This file is part StepClassLibrary (SCL). +# +# 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. +# +# Neither the name of the nor the names of its contributors may +# be used to endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import unittest +from SCL.Part21 import Parser + +ShapesSample =""" +ISO-10303-21; +HEADER; +FILE_DESCRIPTION(('simple example file'),'1'); +FILE_NAME('testfile.step','1997-10-06T16:15:42',('long forgotten'),('nist'),'0','1','2'); +FILE_SCHEMA(('example_schema')); +ENDSEC; +DATA; +#0=SQUARE('Square9',.BROWN.,13,15.,51.); +#1=CIRCLE('Circle8',.ORANGE.,19,12.); +#2=TRIANGLE('Triangle7',.BLACK.,67,84.,60.,25.); +#3=LINE(#6,#7); +#4=SHAPE('Shape4',.WHITE.,83); +#5=RECTANGLE('Rectangle8',.BROWN.,66,78.,95.); +#6=CARTESIAN_POINT(11.,67.,54.); +#7=CARTESIAN_POINT(1.,2.,3.); +ENDSEC; +END-ISO-10303-21; +""" + +class TestSample(unittest.TestCase): + def setUp(self): + self.parser = Parser() + def tearDown(self): + self.parser = None + + +class TestShapesParse(TestSample): + """ + Tests whether we're able to parse the shapes sample at all + """ + def test_parse(self): + model = self.parser.parse(ShapesSample) + self.assertIsNotNone(model) + + +class TestShapesHeader(TestSample): + """ + Test basic structure and payload of Header section + """ + def test_header_name(self): + model = self.parser.parse(ShapesSample) + self.assertEqual(model.header.file_name.params[0][0], "testfile.step") + + def test_header_schema(self): + model = self.parser.parse(ShapesSample) + self.assertEqual(model.header.file_schema.params[0][0][0], "example_schema") + + +class TestShapesData(TestSample): + """ + Test basic structure and shape of data section + """ + def test_data_section_form(self): + model = self.parser.parse(ShapesSample) + self.assertEqual(len(model.sections), 1) + self.assertEqual(len(model.sections[0].entities), 8) + + +class TestEntity(TestSample): + """ + Test structure and contents of several entities within the DATA section + """ + def test_line(self): + model = self.parser.parse(ShapesSample) + line = model.sections[0].entities[3] + self.assertEqual(line.type_name, "LINE") + self.assertEqual(line.ref, "#3") + self.assertEqual(line.params[0], ["#6", "#7"]) + + def test_rectangle8(self): + model = self.parser.parse(ShapesSample) + rect8 = model.sections[0].entities[5] + self.assertEqual(rect8.type_name, "RECTANGLE") + self.assertEqual(rect8.ref, "#5") + self.assertEqual(rect8.params[0], ['Rectangle8', '.BROWN.', 66, 78.0, 95.0]) + From 68cca0e22268e80531692cb51b4cdfecb18ae786 Mon Sep 17 00:00:00 2001 From: Devon Sparks Date: Mon, 17 May 2021 15:02:37 -0700 Subject: [PATCH 163/244] Added initial README --- src/exp2python/python/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/exp2python/python/README.md diff --git a/src/exp2python/python/README.md b/src/exp2python/python/README.md new file mode 100644 index 000000000..19f27ef3c --- /dev/null +++ b/src/exp2python/python/README.md @@ -0,0 +1,18 @@ +# SCL - A Python3 STEP Class Library + +SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. + +# Use + +To parse a ISO 10303 Part 21 file, use the `Parser` class of `SCL.Part21`. On a successful parse, the result will be a Part 21 parse tree and associated STEP instances. + +See [test_parser](tests/test_parser.py) for use of the `SCL.Part21` parser with a sample STEP file. + + +# Building + +The SCL Python package can be built directly using [PyPA's build module](https://github.com/pypa/build) + +# License + +See [LICENSE](LICENSE) \ No newline at end of file From fc3bcf057815ad03bedc72525ad7963217de10e4 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 19:57:06 +0000 Subject: [PATCH 164/244] Minor updates to README. --- src/exp2python/python/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/exp2python/python/README.md b/src/exp2python/python/README.md index 19f27ef3c..309feb243 100644 --- a/src/exp2python/python/README.md +++ b/src/exp2python/python/README.md @@ -11,8 +11,7 @@ See [test_parser](tests/test_parser.py) for use of the `SCL.Part21` parser with # Building -The SCL Python package can be built directly using [PyPA's build module](https://github.com/pypa/build) - +The SCL Python package can be built directly using [PyPA's build module](https://github.com/pypa/build). Run `python3 -m build` from this directory. # License See [LICENSE](LICENSE) \ No newline at end of file From ead7c6c8c32e79e62c06588282d331f75b87dfdf Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 19:59:08 +0000 Subject: [PATCH 165/244] Added README to setup.cfg --- src/exp2python/python/setup.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/exp2python/python/setup.cfg b/src/exp2python/python/setup.cfg index 9e5dada61..725d44532 100644 --- a/src/exp2python/python/setup.cfg +++ b/src/exp2python/python/setup.cfg @@ -2,7 +2,10 @@ name = SCL version = 0.6.1 author = Thomas Paviot , Christopher HORLER (cshorler@googlemail.com), Devon Sparks (devonsparks.com) -description = SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +description = SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +long_description = file: README.md +long_description_content_type = text/markdown + url = https://github.com/stepcode/stepcode project_urls = Bug Tracker = https://github.com/stepcode/stepcode/issues From 3e8b836b3ea20d3a9f12d5c5380468c869b994a9 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 20:11:46 +0000 Subject: [PATCH 166/244] fixup path for unitary schema tests --- src/exp2python/python/tests/test_unitary_schemas.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/exp2python/python/tests/test_unitary_schemas.py b/src/exp2python/python/tests/test_unitary_schemas.py index c23bed882..66b2a7d25 100644 --- a/src/exp2python/python/tests/test_unitary_schemas.py +++ b/src/exp2python/python/tests/test_unitary_schemas.py @@ -31,7 +31,10 @@ import unittest import sys -sys.path.append('../examples/unitary_schemas') +import os + +here = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.join(here, "..", "..", "examples", "unitary_schemas")) from SCL.SCLBase import * from SCL.SimpleDataTypes import * From 43329f557f2a9e60fc6a19e128eddd50b4e66e63 Mon Sep 17 00:00:00 2001 From: Devon Sparks Date: Mon, 17 May 2021 16:40:38 -0700 Subject: [PATCH 167/244] Add notes about test suite to README --- src/exp2python/python/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/exp2python/python/README.md b/src/exp2python/python/README.md index 309feb243..470e626a3 100644 --- a/src/exp2python/python/README.md +++ b/src/exp2python/python/README.md @@ -12,6 +12,11 @@ See [test_parser](tests/test_parser.py) for use of the `SCL.Part21` parser with # Building The SCL Python package can be built directly using [PyPA's build module](https://github.com/pypa/build). Run `python3 -m build` from this directory. + +# Testing + +SCL comes with a small test suite (additions welcome!) From this directory, `python3 -m unittest discover`. + # License See [LICENSE](LICENSE) \ No newline at end of file From dace0f70ef83e8024dad6f168e060fcb37a13168 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 20 Nov 2021 20:26:31 +0000 Subject: [PATCH 168/244] Simplified setup.cfg package search to use explicit package listing. --- src/exp2python/python/pyproject.toml | 2 +- src/exp2python/python/setup.cfg | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/exp2python/python/pyproject.toml b/src/exp2python/python/pyproject.toml index b5a3c468d..8d4a680fe 100644 --- a/src/exp2python/python/pyproject.toml +++ b/src/exp2python/python/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools>=40", "wheel" ] build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/src/exp2python/python/setup.cfg b/src/exp2python/python/setup.cfg index 725d44532..ef47b03e0 100644 --- a/src/exp2python/python/setup.cfg +++ b/src/exp2python/python/setup.cfg @@ -15,7 +15,8 @@ classifiers = [options] package_dir = =. -packages=find: +packages = SCL python_requires = >=3.6 install_requires = ply + From b42a909e6515014f4e1626f071313c18d6f70625 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 21 Nov 2021 12:01:08 +0000 Subject: [PATCH 169/244] python SCL standardise all class declarations (remove object base) --- src/exp2python/python/SCL/AggregationDataTypes.py | 2 +- src/exp2python/python/SCL/BaseType.py | 2 +- src/exp2python/python/SCL/ConstructedDataTypes.py | 2 +- src/exp2python/python/SCL/Model.py | 2 +- src/exp2python/python/SCL/Part21.py | 4 ++-- src/exp2python/python/SCL/Rules.py | 2 +- src/exp2python/python/SCL/SCLBase.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/exp2python/python/SCL/AggregationDataTypes.py b/src/exp2python/python/SCL/AggregationDataTypes.py index 09c4892b1..9345dc0af 100644 --- a/src/exp2python/python/SCL/AggregationDataTypes.py +++ b/src/exp2python/python/SCL/AggregationDataTypes.py @@ -33,7 +33,7 @@ from TypeChecker import check_type import BaseType -class BaseAggregate(object): +class BaseAggregate: """ A class that define common properties to ARRAY, LIST, SET and BAG. """ def __init__( self , bound1 , bound2 , base_type ): diff --git a/src/exp2python/python/SCL/BaseType.py b/src/exp2python/python/SCL/BaseType.py index 070b5aa1e..93b931de2 100644 --- a/src/exp2python/python/SCL/BaseType.py +++ b/src/exp2python/python/SCL/BaseType.py @@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -class Type(object): +class Type: ''' A type can be defined from its name and scope Looking into the scope dict returns the python type class. diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/SCL/ConstructedDataTypes.py index cc62eb72a..b84f50927 100644 --- a/src/exp2python/python/SCL/ConstructedDataTypes.py +++ b/src/exp2python/python/SCL/ConstructedDataTypes.py @@ -58,7 +58,7 @@ class ENUMERATION(Enum): """ pass -class SELECT(object): +class SELECT: """ A select data type has as its domain the union of the domains of the named data types in its select list. The select data type is a generalization of each of the named data types in its select list. diff --git a/src/exp2python/python/SCL/Model.py b/src/exp2python/python/SCL/Model.py index 6e2279c5d..036a435da 100644 --- a/src/exp2python/python/SCL/Model.py +++ b/src/exp2python/python/SCL/Model.py @@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -class Model(object): +class Model: """ The container for entity instances """ def __init_(self): diff --git a/src/exp2python/python/SCL/Part21.py b/src/exp2python/python/SCL/Part21.py index f6607841c..d993305fa 100644 --- a/src/exp2python/python/SCL/Part21.py +++ b/src/exp2python/python/SCL/Part21.py @@ -53,7 +53,7 @@ #################################################################################################### # Lexer #################################################################################################### -class Lexer(object): +class Lexer: tokens = list(base_tokens) states = (('slurp', 'exclusive'),) @@ -239,7 +239,7 @@ def __init__(self, type_name, *params): #################################################################################################### # Parser #################################################################################################### -class Parser(object): +class Parser: tokens = list(base_tokens) start = 'exchange_file' diff --git a/src/exp2python/python/SCL/Rules.py b/src/exp2python/python/SCL/Rules.py index 1267a99d6..1b94f6e0b 100644 --- a/src/exp2python/python/SCL/Rules.py +++ b/src/exp2python/python/SCL/Rules.py @@ -31,7 +31,7 @@ __doc__ = "This module defines EXPRESS rules" -class Rule(object): +class Rule: ''' This class describes a RULE @TODO: to be implemented diff --git a/src/exp2python/python/SCL/SCLBase.py b/src/exp2python/python/SCL/SCLBase.py index 617c816ad..d71600bf5 100644 --- a/src/exp2python/python/SCL/SCLBase.py +++ b/src/exp2python/python/SCL/SCLBase.py @@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -class BaseEntityClass(object): +class BaseEntityClass: """ A class that allows advanced __repr__ features for entity instances """ def __repr__(self): From 0cefcae1535b018ae75274d257d74f8b5feb47cd Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 21 Nov 2021 12:03:13 +0000 Subject: [PATCH 170/244] fixup: python SCL standardise all class declarations (remove object base) --- src/exp2python/python/tests/test_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2python/python/tests/test_base.py b/src/exp2python/python/tests/test_base.py index 9781b5a45..fb3ea6e2d 100644 --- a/src/exp2python/python/tests/test_base.py +++ b/src/exp2python/python/tests/test_base.py @@ -415,9 +415,9 @@ def test_simple_enum(self): else: self.fail('ExpectedException not thrown') -class ob1(object): +class ob1: pass -class ob2(object): +class ob2: pass class TestSELECT(unittest.TestCase): def test_select(self): From af637a28d89e8fb3e4a308ed8c400de7ecde5f45 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 8 Jun 2022 20:19:39 +0100 Subject: [PATCH 171/244] remove unitary_schemas, these should be dynamically generated --- .../unitary_schemas/gcc_incomplete_type.py | 28 - .../generate_schemas_modules.py | 13 - .../unitary_schemas/index_attribute.py | 140 ----- .../examples/unitary_schemas/multiple_rep.py | 353 ----------- .../examples/unitary_schemas/test_array.py | 43 -- .../test_array_of_array_of_simple_types.py | 43 -- .../test_array_of_simple_types.py | 79 --- .../unitary_schemas/test_derived_attribute.py | 123 ---- .../unitary_schemas/test_entity_where_rule.py | 322 ---------- .../unitary_schemas/test_enum_entity_name.py | 32 - .../unitary_schemas/test_enums_same_name.py | 29 - .../examples/unitary_schemas/test_function.py | 80 --- .../test_multiple_inheritance.py | 582 ------------------ .../unitary_schemas/test_named_type.py | 94 --- .../unitary_schemas/test_select_data_type.py | 252 -------- .../test_single_inheritance.py | 121 ---- .../test_single_inheritance_multi_level.py | 130 ---- .../unitary_schemas/test_where_rule.py | 51 -- 18 files changed, 2515 deletions(-) delete mode 100644 src/exp2python/examples/unitary_schemas/gcc_incomplete_type.py delete mode 100644 src/exp2python/examples/unitary_schemas/generate_schemas_modules.py delete mode 100644 src/exp2python/examples/unitary_schemas/index_attribute.py delete mode 100644 src/exp2python/examples/unitary_schemas/multiple_rep.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_array.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_derived_attribute.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_entity_where_rule.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_enum_entity_name.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_enums_same_name.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_function.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_named_type.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_select_data_type.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_single_inheritance.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py delete mode 100644 src/exp2python/examples/unitary_schemas/test_where_rule.py diff --git a/src/exp2python/examples/unitary_schemas/gcc_incomplete_type.py b/src/exp2python/examples/unitary_schemas/gcc_incomplete_type.py deleted file mode 100644 index 75448145b..000000000 --- a/src/exp2python/examples/unitary_schemas/gcc_incomplete_type.py +++ /dev/null @@ -1,28 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'gcc_incomplete_type' - -schema_scope = sys.modules[__name__] - -# Defined datatype maths_number -class maths_number(NUMBER): - def __init__(self,*kargs): - pass - -# SELECT TYPE atom_based_value -atom_based_value = SELECT( - 'maths_number', - 'atom_based_tuple', - scope = schema_scope) -atom_based_tuple = LIST(0,None,'atom_based_value', scope = schema_scope) diff --git a/src/exp2python/examples/unitary_schemas/generate_schemas_modules.py b/src/exp2python/examples/unitary_schemas/generate_schemas_modules.py deleted file mode 100644 index bc61a1a01..000000000 --- a/src/exp2python/examples/unitary_schemas/generate_schemas_modules.py +++ /dev/null @@ -1,13 +0,0 @@ -__doc__= ''' This script runs exp2python over each EXPRESS schema in the test/unitary_schemas folder''' - -unitary_schemas_path = '../../../../test/unitary_schemas' -exp2python_path = '../../../../cmake-build/bin/exp2python' - -import subprocess -import glob -import os - -unitary_schemas = glob.glob(os.path.join(unitary_schemas_path,'*.exp')) - -for unitary_schema in unitary_schemas: - subprocess.call([exp2python_path,unitary_schema]) \ No newline at end of file diff --git a/src/exp2python/examples/unitary_schemas/index_attribute.py b/src/exp2python/examples/unitary_schemas/index_attribute.py deleted file mode 100644 index 32fffaeab..000000000 --- a/src/exp2python/examples/unitary_schemas/index_attribute.py +++ /dev/null @@ -1,140 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'index_attribute' - -schema_scope = sys.modules[__name__] - -common_datum_list = LIST(1,None,'datum_reference_element', scope = schema_scope) -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - -# SELECT TYPE datum_or_common_datum -datum_or_common_datum = SELECT( - 'common_datum_list', - 'datum', - scope = schema_scope) - -#################### - # ENTITY shape_aspect # -#################### -class shape_aspect(BaseEntityClass): - '''Entity shape_aspect definition. - - :param name - :type name:label - - :param of_shape - :type of_shape:product_definition_shape - ''' - def __init__( self , name,of_shape, ): - self.name = name - self.of_shape = of_shape - - @apply - def name(): - def fget( self ): - return self._name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument name is mandatory and can not be set to None') - if not check_type(value,label): - self._name = label(value) - else: - self._name = value - return property(**locals()) - - @apply - def of_shape(): - def fget( self ): - return self._of_shape - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument of_shape is mandatory and can not be set to None') - if not check_type(value,product_definition_shape): - self._of_shape = product_definition_shape(value) - else: - self._of_shape = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (SIZEOF(USEDIN(self,'INDEX_ATTRIBUTE.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - -#################### - # ENTITY general_datum_reference # -#################### -class general_datum_reference(shape_aspect): - '''Entity general_datum_reference definition. - - :param base - :type base:datum_or_common_datum - ''' - def __init__( self , inherited0__name , inherited1__of_shape , base, ): - shape_aspect.__init__(self , inherited0__name , inherited1__of_shape , ) - self.base = base - - @apply - def base(): - def fget( self ): - return self._base - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument base is mandatory and can not be set to None') - if not check_type(value,datum_or_common_datum): - self._base = datum_or_common_datum(value) - else: - self._base = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (( not ('INDEX_ATTRIBUTE.COMMON_DATUM_LIST' == TYPEOF(self.base))) or (self.self.shape_aspect.self.of_shape == self.base[1].self.shape_aspect.self.of_shape)) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - -#################### - # ENTITY product_definition_shape # -#################### -class product_definition_shape(BaseEntityClass): - '''Entity product_definition_shape definition. - ''' - # This class does not define any attribute. - pass - -#################### - # ENTITY datum_reference_element # -#################### -class datum_reference_element(general_datum_reference): - '''Entity datum_reference_element definition. - ''' - def __init__( self , inherited0__name , inherited1__of_shape , inherited2__base , ): - general_datum_reference.__init__(self , inherited0__name , inherited1__of_shape , inherited2__base , ) - -#################### - # ENTITY datum # -#################### -class datum(shape_aspect): - '''Entity datum definition. - ''' - def __init__( self , inherited0__name , inherited1__of_shape , ): - shape_aspect.__init__(self , inherited0__name , inherited1__of_shape , ) diff --git a/src/exp2python/examples/unitary_schemas/multiple_rep.py b/src/exp2python/examples/unitary_schemas/multiple_rep.py deleted file mode 100644 index 3805349fc..000000000 --- a/src/exp2python/examples/unitary_schemas/multiple_rep.py +++ /dev/null @@ -1,353 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'multiple_rep' - -schema_scope = sys.modules[__name__] - -# Defined datatype text -class text(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype representation_context -class representation_context(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype identifier -class identifier(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype shape_definition -class shape_definition(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype transformation -class transformation(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype representation_item -class representation_item(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype characterized_product_definition -class characterized_product_definition(STRING): - def __init__(self,*kargs): - pass - -# SELECT TYPE characterized_definition -characterized_definition = SELECT( - 'characterized_object', - 'characterized_product_definition', - 'shape_definition', - scope = schema_scope) -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype characterized_object -class characterized_object(STRING): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY representation_relationship # -#################### -class representation_relationship(BaseEntityClass): - '''Entity representation_relationship definition. - - :param name - :type name:label - - :param rep_1 - :type rep_1:representation - - :param rep_2 - :type rep_2:representation - ''' - def __init__( self , name,rep_1,rep_2, ): - self.name = name - self.rep_1 = rep_1 - self.rep_2 = rep_2 - - @apply - def name(): - def fget( self ): - return self._name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument name is mandatory and can not be set to None') - if not check_type(value,label): - self._name = label(value) - else: - self._name = value - return property(**locals()) - - @apply - def rep_1(): - def fget( self ): - return self._rep_1 - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument rep_1 is mandatory and can not be set to None') - if not check_type(value,representation): - self._rep_1 = representation(value) - else: - self._rep_1 = value - return property(**locals()) - - @apply - def rep_2(): - def fget( self ): - return self._rep_2 - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument rep_2 is mandatory and can not be set to None') - if not check_type(value,representation): - self._rep_2 = representation(value) - else: - self._rep_2 = value - return property(**locals()) - -#################### - # ENTITY shape_representation_relationship # -#################### -class shape_representation_relationship(representation_relationship): - '''Entity shape_representation_relationship definition. - ''' - def __init__( self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ): - representation_relationship.__init__(self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ) - def wr1(self): - eval_wr1_wr = ('MULTIPLE_REP.SHAPE_REPRESENTATION' == (TYPEOF(self.self.representation_relationship.self.rep_1) + TYPEOF(self.self.representation_relationship.self.rep_2))) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - -#################### - # ENTITY representation # -#################### -class representation(BaseEntityClass): - '''Entity representation definition. - - :param name - :type name:label - - :param items - :type items:SET(1,None,'STRING', scope = schema_scope) - - :param context_of_items - :type context_of_items:representation_context - ''' - def __init__( self , name,items,context_of_items, ): - self.name = name - self.items = items - self.context_of_items = context_of_items - - @apply - def name(): - def fget( self ): - return self._name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument name is mandatory and can not be set to None') - if not check_type(value,label): - self._name = label(value) - else: - self._name = value - return property(**locals()) - - @apply - def items(): - def fget( self ): - return self._items - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument items is mandatory and can not be set to None') - if not check_type(value,SET(1,None,'STRING', scope = schema_scope)): - self._items = SET(value) - else: - self._items = value - return property(**locals()) - - @apply - def context_of_items(): - def fget( self ): - return self._context_of_items - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument context_of_items is mandatory and can not be set to None') - if not check_type(value,representation_context): - self._context_of_items = representation_context(value) - else: - self._context_of_items = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - def wr2(self): - eval_wr2_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1) - if not eval_wr2_wr: - raise AssertionError('Rule wr2 violated') - else: - return eval_wr2_wr - - -#################### - # ENTITY property_definition # -#################### -class property_definition(BaseEntityClass): - '''Entity property_definition definition. - - :param name - :type name:label - - :param definition - :type definition:characterized_definition - ''' - def __init__( self , name,definition, ): - self.name = name - self.definition = definition - - @apply - def name(): - def fget( self ): - return self._name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument name is mandatory and can not be set to None') - if not check_type(value,label): - self._name = label(value) - else: - self._name = value - return property(**locals()) - - @apply - def definition(): - def fget( self ): - return self._definition - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument definition is mandatory and can not be set to None') - if not check_type(value,characterized_definition): - self._definition = characterized_definition(value) - else: - self._definition = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - -#################### - # ENTITY context_dependent_shape_representation # -#################### -class context_dependent_shape_representation(BaseEntityClass): - '''Entity context_dependent_shape_representation definition. - - :param representation_relation - :type representation_relation:shape_representation_relationship - ''' - def __init__( self , representation_relation, ): - self.representation_relation = representation_relation - - @apply - def representation_relation(): - def fget( self ): - return self._representation_relation - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument representation_relation is mandatory and can not be set to None') - if not check_type(value,shape_representation_relationship): - self._representation_relation = shape_representation_relationship(value) - else: - self._representation_relation = value - return property(**locals()) - def wr2(self): - eval_wr2_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1) - if not eval_wr2_wr: - raise AssertionError('Rule wr2 violated') - else: - return eval_wr2_wr - - def wr3(self): - eval_wr3_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'NAME_ATTRIBUTE.NAMED_ITEM')) <= 1) - if not eval_wr3_wr: - raise AssertionError('Rule wr3 violated') - else: - return eval_wr3_wr - - -#################### - # ENTITY definitional_representation_relationship # -#################### -class definitional_representation_relationship(representation_relationship): - '''Entity definitional_representation_relationship definition. - ''' - def __init__( self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ): - representation_relationship.__init__(self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ) - -#################### - # ENTITY component_2d_location # -#################### -class component_2d_location(context_dependent_shape_representation,shape_representation_relationship,definitional_representation_relationship): - '''Entity component_2d_location definition. - - :param context_dependent_shape_representation_representation_relation - :type context_dependent_shape_representation_representation_relation:component_2d_location - ''' - def __init__( self , inherited0__representation_relation , inherited1__name , inherited2__rep_1 , inherited3__rep_2 , inherited4__name , inherited5__rep_1 , inherited6__rep_2 , ): - context_dependent_shape_representation.__init__(self , inherited0__representation_relation , ) - shape_representation_relationship.__init__(self , inherited1__name , inherited2__rep_1 , inherited3__rep_2 , ) - definitional_representation_relationship.__init__(self , inherited4__name , inherited5__rep_1 , inherited6__rep_2 , ) - - @apply - def context_dependent_shape_representation_representation_relation(): - def fget( self ): - attribute_eval = self - return attribute_eval - def fset( self, value ): - # DERIVED argument - raise AssertionError('Argument context_dependent_shape_representation_representation_relation is DERIVED. It is computed and can not be set to any value') - return property(**locals()) - def wr1(self): - eval_wr1_wr = (self.self.representation_relationship.self.name == 'component 2d location') - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - diff --git a/src/exp2python/examples/unitary_schemas/test_array.py b/src/exp2python/examples/unitary_schemas/test_array.py deleted file mode 100644 index 7f4fb6259..000000000 --- a/src/exp2python/examples/unitary_schemas/test_array.py +++ /dev/null @@ -1,43 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_array' - -schema_scope = sys.modules[__name__] - - -#################### - # ENTITY point # -#################### -class point(BaseEntityClass): - '''Entity point definition. - - :param coords - :type coords:ARRAY(1,3,'REAL', scope = schema_scope) - ''' - def __init__( self , coords, ): - self.coords = coords - - @apply - def coords(): - def fget( self ): - return self._coords - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument coords is mandatory and can not be set to None') - if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)): - self._coords = ARRAY(value) - else: - self._coords = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py b/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py deleted file mode 100644 index 3ea8a8c15..000000000 --- a/src/exp2python/examples/unitary_schemas/test_array_of_array_of_simple_types.py +++ /dev/null @@ -1,43 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_array_of_array_of_simple_types' - -schema_scope = sys.modules[__name__] - - -#################### - # ENTITY transformation # -#################### -class transformation(BaseEntityClass): - '''Entity transformation definition. - - :param rotation - :type rotation:ARRAY(1,3,ARRAY(1,3,'REAL', scope = schema_scope)) - ''' - def __init__( self , rotation, ): - self.rotation = rotation - - @apply - def rotation(): - def fget( self ): - return self._rotation - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument rotation is mandatory and can not be set to None') - if not check_type(value,ARRAY(1,3,ARRAY(1,3,'REAL', scope = schema_scope))): - self._rotation = ARRAY(value) - else: - self._rotation = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py b/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py deleted file mode 100644 index 4c3d6f5df..000000000 --- a/src/exp2python/examples/unitary_schemas/test_array_of_simple_types.py +++ /dev/null @@ -1,79 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_array_of_simple_types' - -schema_scope = sys.modules[__name__] - - -#################### - # ENTITY point # -#################### -class point(BaseEntityClass): - '''Entity point definition. - - :param arr_real - :type arr_real:ARRAY(1,3,'REAL', scope = schema_scope) - - :param arr_string - :type arr_string:ARRAY(1,3,'STRING', scope = schema_scope) - - :param arr_integer - :type arr_integer:ARRAY(1,None,'INTEGER', scope = schema_scope) - ''' - def __init__( self , arr_real,arr_string,arr_integer, ): - self.arr_real = arr_real - self.arr_string = arr_string - self.arr_integer = arr_integer - - @apply - def arr_real(): - def fget( self ): - return self._arr_real - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument arr_real is mandatory and can not be set to None') - if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)): - self._arr_real = ARRAY(value) - else: - self._arr_real = value - return property(**locals()) - - @apply - def arr_string(): - def fget( self ): - return self._arr_string - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument arr_string is mandatory and can not be set to None') - if not check_type(value,ARRAY(1,3,'STRING', scope = schema_scope)): - self._arr_string = ARRAY(value) - else: - self._arr_string = value - return property(**locals()) - - @apply - def arr_integer(): - def fget( self ): - return self._arr_integer - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument arr_integer is mandatory and can not be set to None') - if not check_type(value,ARRAY(1,None,'INTEGER', scope = schema_scope)): - self._arr_integer = ARRAY(value) - else: - self._arr_integer = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_derived_attribute.py b/src/exp2python/examples/unitary_schemas/test_derived_attribute.py deleted file mode 100644 index bdd4b82ee..000000000 --- a/src/exp2python/examples/unitary_schemas/test_derived_attribute.py +++ /dev/null @@ -1,123 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_derived_attribute' - -schema_scope = sys.modules[__name__] - - -#################### - # ENTITY vector # -#################### -class vector(BaseEntityClass): - '''Entity vector definition. - ''' - # This class does not define any attribute. - pass - -#################### - # ENTITY circle # -#################### -class circle(BaseEntityClass): - '''Entity circle definition. - - :param centre - :type centre:point - - :param radius - :type radius:REAL - - :param axis - :type axis:vector - - :param area - :type area:REAL - - :param perimeter - :type perimeter:REAL - ''' - def __init__( self , centre,radius,axis, ): - self.centre = centre - self.radius = radius - self.axis = axis - - @apply - def centre(): - def fget( self ): - return self._centre - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument centre is mandatory and can not be set to None') - if not check_type(value,point): - self._centre = point(value) - else: - self._centre = value - return property(**locals()) - - @apply - def radius(): - def fget( self ): - return self._radius - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument radius is mandatory and can not be set to None') - if not check_type(value,REAL): - self._radius = REAL(value) - else: - self._radius = value - return property(**locals()) - - @apply - def axis(): - def fget( self ): - return self._axis - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument axis is mandatory and can not be set to None') - if not check_type(value,vector): - self._axis = vector(value) - else: - self._axis = value - return property(**locals()) - - @apply - def area(): - def fget( self ): - attribute_eval = ( PI * (self.radius ** 2)) - return attribute_eval - def fset( self, value ): - # DERIVED argument - raise AssertionError('Argument area is DERIVED. It is computed and can not be set to any value') - return property(**locals()) - - @apply - def perimeter(): - def fget( self ): - attribute_eval = ((2 * PI ) * self.radius) - return attribute_eval - def fset( self, value ): - # DERIVED argument - raise AssertionError('Argument perimeter is DERIVED. It is computed and can not be set to any value') - return property(**locals()) - -#################### - # ENTITY point # -#################### -class point(BaseEntityClass): - '''Entity point definition. - ''' - # This class does not define any attribute. - pass diff --git a/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py b/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py deleted file mode 100644 index 84c56c78b..000000000 --- a/src/exp2python/examples/unitary_schemas/test_entity_where_rule.py +++ /dev/null @@ -1,322 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_entity_where_rule' - -schema_scope = sys.modules[__name__] - -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY unit_vector # -#################### -class unit_vector(BaseEntityClass): - '''Entity unit_vector definition. - - :param a - :type a:REAL - - :param b - :type b:REAL - - :param c - :type c:REAL - ''' - def __init__( self , a,b,c, ): - self.a = a - self.b = b - self.c = c - - @apply - def a(): - def fget( self ): - return self._a - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument a is mandatory and can not be set to None') - if not check_type(value,REAL): - self._a = REAL(value) - else: - self._a = value - return property(**locals()) - - @apply - def b(): - def fget( self ): - return self._b - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument b is mandatory and can not be set to None') - if not check_type(value,REAL): - self._b = REAL(value) - else: - self._b = value - return property(**locals()) - - @apply - def c(): - def fget( self ): - return self._c - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument c is mandatory and can not be set to None') - if not check_type(value,REAL): - self._c = REAL(value) - else: - self._c = value - return property(**locals()) - def length_1(self): - eval_length_1_wr = ((((self.a ** 2) + (self.b ** 2)) + (self.c ** 2)) == 1) - if not eval_length_1_wr: - raise AssertionError('Rule length_1 violated') - else: - return eval_length_1_wr - - -#################### - # ENTITY address # -#################### -class address(BaseEntityClass): - '''Entity address definition. - - :param internal_location - :type internal_location:label - - :param street_number - :type street_number:label - - :param street - :type street:label - - :param postal_box - :type postal_box:label - - :param town - :type town:label - - :param region - :type region:label - - :param postal_code - :type postal_code:label - - :param country - :type country:label - - :param facsimile_number - :type facsimile_number:label - - :param telephone_number - :type telephone_number:label - - :param electronic_mail_address - :type electronic_mail_address:label - - :param telex_number - :type telex_number:label - ''' - def __init__( self , internal_location,street_number,street,postal_box,town,region,postal_code,country,facsimile_number,telephone_number,electronic_mail_address,telex_number, ): - self.internal_location = internal_location - self.street_number = street_number - self.street = street - self.postal_box = postal_box - self.town = town - self.region = region - self.postal_code = postal_code - self.country = country - self.facsimile_number = facsimile_number - self.telephone_number = telephone_number - self.electronic_mail_address = electronic_mail_address - self.telex_number = telex_number - - @apply - def internal_location(): - def fget( self ): - return self._internal_location - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._internal_location = label(value) - else: - self._internal_location = value - else: - self._internal_location = value - return property(**locals()) - - @apply - def street_number(): - def fget( self ): - return self._street_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._street_number = label(value) - else: - self._street_number = value - else: - self._street_number = value - return property(**locals()) - - @apply - def street(): - def fget( self ): - return self._street - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._street = label(value) - else: - self._street = value - else: - self._street = value - return property(**locals()) - - @apply - def postal_box(): - def fget( self ): - return self._postal_box - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._postal_box = label(value) - else: - self._postal_box = value - else: - self._postal_box = value - return property(**locals()) - - @apply - def town(): - def fget( self ): - return self._town - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._town = label(value) - else: - self._town = value - else: - self._town = value - return property(**locals()) - - @apply - def region(): - def fget( self ): - return self._region - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._region = label(value) - else: - self._region = value - else: - self._region = value - return property(**locals()) - - @apply - def postal_code(): - def fget( self ): - return self._postal_code - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._postal_code = label(value) - else: - self._postal_code = value - else: - self._postal_code = value - return property(**locals()) - - @apply - def country(): - def fget( self ): - return self._country - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._country = label(value) - else: - self._country = value - else: - self._country = value - return property(**locals()) - - @apply - def facsimile_number(): - def fget( self ): - return self._facsimile_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._facsimile_number = label(value) - else: - self._facsimile_number = value - else: - self._facsimile_number = value - return property(**locals()) - - @apply - def telephone_number(): - def fget( self ): - return self._telephone_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._telephone_number = label(value) - else: - self._telephone_number = value - else: - self._telephone_number = value - return property(**locals()) - - @apply - def electronic_mail_address(): - def fget( self ): - return self._electronic_mail_address - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._electronic_mail_address = label(value) - else: - self._electronic_mail_address = value - else: - self._electronic_mail_address = value - return property(**locals()) - - @apply - def telex_number(): - def fget( self ): - return self._telex_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._telex_number = label(value) - else: - self._telex_number = value - else: - self._telex_number = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (((((((((((EXISTS(self.internal_location) or EXISTS(self.street_number)) or EXISTS(self.street)) or EXISTS(self.postal_box)) or EXISTS(self.town)) or EXISTS(self.region)) or EXISTS(self.postal_code)) or EXISTS(self.country)) or EXISTS(self.facsimile_number)) or EXISTS(self.telephone_number)) or EXISTS(self.electronic_mail_address)) or EXISTS(self.telex_number)) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - diff --git a/src/exp2python/examples/unitary_schemas/test_enum_entity_name.py b/src/exp2python/examples/unitary_schemas/test_enum_entity_name.py deleted file mode 100644 index 5285ef88b..000000000 --- a/src/exp2python/examples/unitary_schemas/test_enum_entity_name.py +++ /dev/null @@ -1,32 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_enum_entity_name' - -schema_scope = sys.modules[__name__] - - -# ENUMERATION TYPE simple_datum_reference_modifier -simple_datum_reference_modifier = ENUMERATION( - 'line', - 'translation', - scope = schema_scope) - -#################### - # ENTITY line # -#################### -class line(BaseEntityClass): - '''Entity line definition. - ''' - # This class does not define any attribute. - pass diff --git a/src/exp2python/examples/unitary_schemas/test_enums_same_name.py b/src/exp2python/examples/unitary_schemas/test_enums_same_name.py deleted file mode 100644 index 4a446be99..000000000 --- a/src/exp2python/examples/unitary_schemas/test_enums_same_name.py +++ /dev/null @@ -1,29 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_enums_same_name' - -schema_scope = sys.modules[__name__] - - -# ENUMERATION TYPE hair_color -hair_color = ENUMERATION( - 'bald', - 'red', - scope = schema_scope) - -# ENUMERATION TYPE favorite_color -favorite_color = ENUMERATION( - 'clear', - 'red', - scope = schema_scope) diff --git a/src/exp2python/examples/unitary_schemas/test_function.py b/src/exp2python/examples/unitary_schemas/test_function.py deleted file mode 100644 index 72a90c1e4..000000000 --- a/src/exp2python/examples/unitary_schemas/test_function.py +++ /dev/null @@ -1,80 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_function' - -schema_scope = sys.modules[__name__] - - -#################### - # ENTITY dummy # -#################### -class dummy(BaseEntityClass): - '''Entity dummy definition. - ''' - # This class does not define any attribute. - pass - -#################### - # FUNCTION add # -#################### -def add(r1,r2,): - ''' - :param r1 - :type r1:REAL - :param r2 - :type r2:REAL - ''' - result = r1 + r2 - return result - -#################### - # FUNCTION pow_n # -#################### -def pow_n(r1,n,): - ''' - :param r1 - :type r1:REAL - :param n - :type n:INTEGER - ''' - if (n == 0): - return 1 - else: - result = r1 - for i in range(1,n,1): - result = result * r1 - return result - -#################### - # FUNCTION case_1 # -#################### -def case_1(a,): - ''' - :param a - :type a:INTEGER - ''' - case_selector = a - if case_selector == 1: - x = SIN(a) - elif case_selector == 2: - x = EXP(a) - elif case_selector == 3: - x = SQRT(a) - elif case_selector == 4: - x = LOG(a) - elif case_selector == 5: - x = LOG(a) - else: - x = 0 - return x diff --git a/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py b/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py deleted file mode 100644 index ce4e42d52..000000000 --- a/src/exp2python/examples/unitary_schemas/test_multiple_inheritance.py +++ /dev/null @@ -1,582 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_multiple_inheritance' - -schema_scope = sys.modules[__name__] - -# SELECT TYPE classification_item -classification_item = SELECT( - 'person_and_organization_address', - 'address', - scope = schema_scope) -# Defined datatype text -class text(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype identifier -class identifier(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY address # -#################### -class address(BaseEntityClass): - '''Entity address definition. - - :param internal_location - :type internal_location:label - - :param street_number - :type street_number:label - - :param street - :type street:label - - :param postal_box - :type postal_box:label - - :param town - :type town:label - - :param region - :type region:label - - :param postal_code - :type postal_code:label - - :param country - :type country:label - - :param facsimile_number - :type facsimile_number:label - - :param telephone_number - :type telephone_number:label - - :param electronic_mail_address - :type electronic_mail_address:label - - :param telex_number - :type telex_number:label - ''' - def __init__( self , internal_location,street_number,street,postal_box,town,region,postal_code,country,facsimile_number,telephone_number,electronic_mail_address,telex_number, ): - self.internal_location = internal_location - self.street_number = street_number - self.street = street - self.postal_box = postal_box - self.town = town - self.region = region - self.postal_code = postal_code - self.country = country - self.facsimile_number = facsimile_number - self.telephone_number = telephone_number - self.electronic_mail_address = electronic_mail_address - self.telex_number = telex_number - - @apply - def internal_location(): - def fget( self ): - return self._internal_location - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._internal_location = label(value) - else: - self._internal_location = value - else: - self._internal_location = value - return property(**locals()) - - @apply - def street_number(): - def fget( self ): - return self._street_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._street_number = label(value) - else: - self._street_number = value - else: - self._street_number = value - return property(**locals()) - - @apply - def street(): - def fget( self ): - return self._street - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._street = label(value) - else: - self._street = value - else: - self._street = value - return property(**locals()) - - @apply - def postal_box(): - def fget( self ): - return self._postal_box - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._postal_box = label(value) - else: - self._postal_box = value - else: - self._postal_box = value - return property(**locals()) - - @apply - def town(): - def fget( self ): - return self._town - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._town = label(value) - else: - self._town = value - else: - self._town = value - return property(**locals()) - - @apply - def region(): - def fget( self ): - return self._region - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._region = label(value) - else: - self._region = value - else: - self._region = value - return property(**locals()) - - @apply - def postal_code(): - def fget( self ): - return self._postal_code - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._postal_code = label(value) - else: - self._postal_code = value - else: - self._postal_code = value - return property(**locals()) - - @apply - def country(): - def fget( self ): - return self._country - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._country = label(value) - else: - self._country = value - else: - self._country = value - return property(**locals()) - - @apply - def facsimile_number(): - def fget( self ): - return self._facsimile_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._facsimile_number = label(value) - else: - self._facsimile_number = value - else: - self._facsimile_number = value - return property(**locals()) - - @apply - def telephone_number(): - def fget( self ): - return self._telephone_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._telephone_number = label(value) - else: - self._telephone_number = value - else: - self._telephone_number = value - return property(**locals()) - - @apply - def electronic_mail_address(): - def fget( self ): - return self._electronic_mail_address - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._electronic_mail_address = label(value) - else: - self._electronic_mail_address = value - else: - self._electronic_mail_address = value - return property(**locals()) - - @apply - def telex_number(): - def fget( self ): - return self._telex_number - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._telex_number = label(value) - else: - self._telex_number = value - else: - self._telex_number = value - return property(**locals()) - -#################### - # ENTITY personal_address # -#################### -class personal_address(address): - '''Entity personal_address definition. - - :param people - :type people:SET(1,None,'person', scope = schema_scope) - - :param description - :type description:text - ''' - def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , people,description, ): - address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , ) - self.people = people - self.description = description - - @apply - def people(): - def fget( self ): - return self._people - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument people is mandatory and can not be set to None') - if not check_type(value,SET(1,None,'person', scope = schema_scope)): - self._people = SET(value) - else: - self._people = value - return property(**locals()) - - @apply - def description(): - def fget( self ): - return self._description - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,text): - self._description = text(value) - else: - self._description = value - else: - self._description = value - return property(**locals()) - -#################### - # ENTITY organizational_address # -#################### -class organizational_address(address): - '''Entity organizational_address definition. - - :param organizations - :type organizations:SET(1,None,'organization', scope = schema_scope) - - :param description - :type description:text - ''' - def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , organizations,description, ): - address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , ) - self.organizations = organizations - self.description = description - - @apply - def organizations(): - def fget( self ): - return self._organizations - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument organizations is mandatory and can not be set to None') - if not check_type(value,SET(1,None,'organization', scope = schema_scope)): - self._organizations = SET(value) - else: - self._organizations = value - return property(**locals()) - - @apply - def description(): - def fget( self ): - return self._description - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,text): - self._description = text(value) - else: - self._description = value - else: - self._description = value - return property(**locals()) - -#################### - # ENTITY person # -#################### -class person(BaseEntityClass): - '''Entity person definition. - - :param id - :type id:identifier - - :param last_name - :type last_name:label - - :param first_name - :type first_name:label - - :param middle_names - :type middle_names:LIST(1,None,'STRING', scope = schema_scope) - - :param prefix_titles - :type prefix_titles:LIST(1,None,'STRING', scope = schema_scope) - - :param suffix_titles - :type suffix_titles:LIST(1,None,'STRING', scope = schema_scope) - ''' - def __init__( self , id,last_name,first_name,middle_names,prefix_titles,suffix_titles, ): - self.id = id - self.last_name = last_name - self.first_name = first_name - self.middle_names = middle_names - self.prefix_titles = prefix_titles - self.suffix_titles = suffix_titles - - @apply - def id(): - def fget( self ): - return self._id - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument id is mandatory and can not be set to None') - if not check_type(value,identifier): - self._id = identifier(value) - else: - self._id = value - return property(**locals()) - - @apply - def last_name(): - def fget( self ): - return self._last_name - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._last_name = label(value) - else: - self._last_name = value - else: - self._last_name = value - return property(**locals()) - - @apply - def first_name(): - def fget( self ): - return self._first_name - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,label): - self._first_name = label(value) - else: - self._first_name = value - else: - self._first_name = value - return property(**locals()) - - @apply - def middle_names(): - def fget( self ): - return self._middle_names - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)): - self._middle_names = LIST(value) - else: - self._middle_names = value - else: - self._middle_names = value - return property(**locals()) - - @apply - def prefix_titles(): - def fget( self ): - return self._prefix_titles - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)): - self._prefix_titles = LIST(value) - else: - self._prefix_titles = value - else: - self._prefix_titles = value - return property(**locals()) - - @apply - def suffix_titles(): - def fget( self ): - return self._suffix_titles - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)): - self._suffix_titles = LIST(value) - else: - self._suffix_titles = value - else: - self._suffix_titles = value - return property(**locals()) - def wr1(self): - eval_wr1_wr = (EXISTS(self.last_name) or EXISTS(self.first_name)) - if not eval_wr1_wr: - raise AssertionError('Rule wr1 violated') - else: - return eval_wr1_wr - - -#################### - # ENTITY organization # -#################### -class organization(BaseEntityClass): - '''Entity organization definition. - - :param id - :type id:identifier - - :param name - :type name:label - - :param description - :type description:text - ''' - def __init__( self , id,name,description, ): - self.id = id - self.name = name - self.description = description - - @apply - def id(): - def fget( self ): - return self._id - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,identifier): - self._id = identifier(value) - else: - self._id = value - else: - self._id = value - return property(**locals()) - - @apply - def name(): - def fget( self ): - return self._name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument name is mandatory and can not be set to None') - if not check_type(value,label): - self._name = label(value) - else: - self._name = value - return property(**locals()) - - @apply - def description(): - def fget( self ): - return self._description - def fset( self, value ): - if value != None: # OPTIONAL attribute - if not check_type(value,text): - self._description = text(value) - else: - self._description = value - else: - self._description = value - return property(**locals()) - -#################### - # ENTITY person_and_organization_address # -#################### -class person_and_organization_address(organizational_address,personal_address): - '''Entity person_and_organization_address definition. - - :param organizational_address_organizations - :type organizational_address_organizations:SET(1,1,'organization', scope = schema_scope) - - :param personal_address_people - :type personal_address_people:SET(1,1,'person', scope = schema_scope) - ''' - def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , inherited12__organizations , inherited13__description , inherited14__internal_location , inherited15__street_number , inherited16__street , inherited17__postal_box , inherited18__town , inherited19__region , inherited20__postal_code , inherited21__country , inherited22__facsimile_number , inherited23__telephone_number , inherited24__electronic_mail_address , inherited25__telex_number , inherited26__people , inherited27__description , organizational_address_organizations,personal_address_people, ): - organizational_address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , inherited12__organizations , inherited13__description , ) - personal_address.__init__(self , inherited14__internal_location , inherited15__street_number , inherited16__street , inherited17__postal_box , inherited18__town , inherited19__region , inherited20__postal_code , inherited21__country , inherited22__facsimile_number , inherited23__telephone_number , inherited24__electronic_mail_address , inherited25__telex_number , inherited26__people , inherited27__description , ) - self.organizational_address_organizations = organizational_address_organizations - self.personal_address_people = personal_address_people - - @apply - def organizational_address_organizations(): - def fget( self ): - return self._organizational_address_organizations - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument organizational_address_organizations is mandatory and can not be set to None') - if not check_type(value,SET(1,1,'organization', scope = schema_scope)): - self._organizational_address_organizations = SET(value) - else: - self._organizational_address_organizations = value - return property(**locals()) - - @apply - def personal_address_people(): - def fget( self ): - return self._personal_address_people - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument personal_address_people is mandatory and can not be set to None') - if not check_type(value,SET(1,1,'person', scope = schema_scope)): - self._personal_address_people = SET(value) - else: - self._personal_address_people = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_named_type.py b/src/exp2python/examples/unitary_schemas/test_named_type.py deleted file mode 100644 index 8ba93647f..000000000 --- a/src/exp2python/examples/unitary_schemas/test_named_type.py +++ /dev/null @@ -1,94 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_named_type' - -schema_scope = sys.modules[__name__] - -# Defined datatype measure -class measure(REAL): - def __init__(self,*kargs): - pass - -# Defined datatype type2 -class type2(INTEGER): - def __init__(self,*kargs): - pass - -# Defined datatype type3 -class type3(type2): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY line # -#################### -class line(BaseEntityClass): - '''Entity line definition. - - :param line_length - :type line_length:measure - - :param other_param - :type other_param:type3 - - :param and_another - :type and_another:REAL - ''' - def __init__( self , line_length,other_param,and_another, ): - self.line_length = line_length - self.other_param = other_param - self.and_another = and_another - - @apply - def line_length(): - def fget( self ): - return self._line_length - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument line_length is mandatory and can not be set to None') - if not check_type(value,measure): - self._line_length = measure(value) - else: - self._line_length = value - return property(**locals()) - - @apply - def other_param(): - def fget( self ): - return self._other_param - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument other_param is mandatory and can not be set to None') - if not check_type(value,type3): - self._other_param = type3(value) - else: - self._other_param = value - return property(**locals()) - - @apply - def and_another(): - def fget( self ): - return self._and_another - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument and_another is mandatory and can not be set to None') - if not check_type(value,REAL): - self._and_another = REAL(value) - else: - self._and_another = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_select_data_type.py b/src/exp2python/examples/unitary_schemas/test_select_data_type.py deleted file mode 100644 index d4c3b53c3..000000000 --- a/src/exp2python/examples/unitary_schemas/test_select_data_type.py +++ /dev/null @@ -1,252 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_select_data_type' - -schema_scope = sys.modules[__name__] - -# SELECT TYPE permanent_attachment -permanent_attachment = SELECT( - 'glue', - 'weld', - scope = schema_scope) -# SELECT TYPE temporary_attachment -temporary_attachment = SELECT( - 'nail', - 'screw', - scope = schema_scope) -# SELECT TYPE attachment_method -attachment_method = SELECT( - 'permanent_attachment', - 'temporary_attachment', - scope = schema_scope) - -#################### - # ENTITY weld # -#################### -class weld(BaseEntityClass): - '''Entity weld definition. - - :param composition - :type composition:STRING - ''' - def __init__( self , composition, ): - self.composition = composition - - @apply - def composition(): - def fget( self ): - return self._composition - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument composition is mandatory and can not be set to None') - if not check_type(value,STRING): - self._composition = STRING(value) - else: - self._composition = value - return property(**locals()) - -#################### - # ENTITY glue # -#################### -class glue(BaseEntityClass): - '''Entity glue definition. - - :param composition - :type composition:STRING - - :param solvent - :type solvent:STRING - ''' - def __init__( self , composition,solvent, ): - self.composition = composition - self.solvent = solvent - - @apply - def composition(): - def fget( self ): - return self._composition - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument composition is mandatory and can not be set to None') - if not check_type(value,STRING): - self._composition = STRING(value) - else: - self._composition = value - return property(**locals()) - - @apply - def solvent(): - def fget( self ): - return self._solvent - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument solvent is mandatory and can not be set to None') - if not check_type(value,STRING): - self._solvent = STRING(value) - else: - self._solvent = value - return property(**locals()) - -#################### - # ENTITY wall_mounting # -#################### -class wall_mounting(BaseEntityClass): - '''Entity wall_mounting definition. - - :param mounting - :type mounting:STRING - - :param on - :type on:STRING - - :param using - :type using:attachment_method - ''' - def __init__( self , mounting,on,using, ): - self.mounting = mounting - self.on = on - self.using = using - - @apply - def mounting(): - def fget( self ): - return self._mounting - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument mounting is mandatory and can not be set to None') - if not check_type(value,STRING): - self._mounting = STRING(value) - else: - self._mounting = value - return property(**locals()) - - @apply - def on(): - def fget( self ): - return self._on - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument on is mandatory and can not be set to None') - if not check_type(value,STRING): - self._on = STRING(value) - else: - self._on = value - return property(**locals()) - - @apply - def using(): - def fget( self ): - return self._using - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument using is mandatory and can not be set to None') - if not check_type(value,attachment_method): - self._using = attachment_method(value) - else: - self._using = value - return property(**locals()) - -#################### - # ENTITY screw # -#################### -class screw(BaseEntityClass): - '''Entity screw definition. - - :param body_length - :type body_length:REAL - - :param pitch - :type pitch:REAL - ''' - def __init__( self , body_length,pitch, ): - self.body_length = body_length - self.pitch = pitch - - @apply - def body_length(): - def fget( self ): - return self._body_length - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument body_length is mandatory and can not be set to None') - if not check_type(value,REAL): - self._body_length = REAL(value) - else: - self._body_length = value - return property(**locals()) - - @apply - def pitch(): - def fget( self ): - return self._pitch - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument pitch is mandatory and can not be set to None') - if not check_type(value,REAL): - self._pitch = REAL(value) - else: - self._pitch = value - return property(**locals()) - -#################### - # ENTITY nail # -#################### -class nail(BaseEntityClass): - '''Entity nail definition. - - :param body_length - :type body_length:REAL - - :param head_area - :type head_area:REAL - ''' - def __init__( self , body_length,head_area, ): - self.body_length = body_length - self.head_area = head_area - - @apply - def body_length(): - def fget( self ): - return self._body_length - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument body_length is mandatory and can not be set to None') - if not check_type(value,REAL): - self._body_length = REAL(value) - else: - self._body_length = value - return property(**locals()) - - @apply - def head_area(): - def fget( self ): - return self._head_area - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument head_area is mandatory and can not be set to None') - if not check_type(value,REAL): - self._head_area = REAL(value) - else: - self._head_area = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_single_inheritance.py b/src/exp2python/examples/unitary_schemas/test_single_inheritance.py deleted file mode 100644 index bd67d1a8b..000000000 --- a/src/exp2python/examples/unitary_schemas/test_single_inheritance.py +++ /dev/null @@ -1,121 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_single_inheritance' - -schema_scope = sys.modules[__name__] - -# Defined datatype length_measure -class length_measure(REAL): - def __init__(self,*kargs): - pass - -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype point -class point(REAL): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY shape # -#################### -class shape(BaseEntityClass): - '''Entity shape definition. - - :param item_name - :type item_name:label - - :param number_of_sides - :type number_of_sides:INTEGER - ''' - def __init__( self , item_name,number_of_sides, ): - self.item_name = item_name - self.number_of_sides = number_of_sides - - @apply - def item_name(): - def fget( self ): - return self._item_name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument item_name is mandatory and can not be set to None') - if not check_type(value,label): - self._item_name = label(value) - else: - self._item_name = value - return property(**locals()) - - @apply - def number_of_sides(): - def fget( self ): - return self._number_of_sides - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument number_of_sides is mandatory and can not be set to None') - if not check_type(value,INTEGER): - self._number_of_sides = INTEGER(value) - else: - self._number_of_sides = value - return property(**locals()) - -#################### - # ENTITY rectangle # -#################### -class rectangle(shape): - '''Entity rectangle definition. - - :param height - :type height:length_measure - - :param width - :type width:length_measure - ''' - def __init__( self , inherited0__item_name , inherited1__number_of_sides , height,width, ): - shape.__init__(self , inherited0__item_name , inherited1__number_of_sides , ) - self.height = height - self.width = width - - @apply - def height(): - def fget( self ): - return self._height - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument height is mandatory and can not be set to None') - if not check_type(value,length_measure): - self._height = length_measure(value) - else: - self._height = value - return property(**locals()) - - @apply - def width(): - def fget( self ): - return self._width - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument width is mandatory and can not be set to None') - if not check_type(value,length_measure): - self._width = length_measure(value) - else: - self._width = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py b/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py deleted file mode 100644 index b15846391..000000000 --- a/src/exp2python/examples/unitary_schemas/test_single_inheritance_multi_level.py +++ /dev/null @@ -1,130 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_single_inheritance_multi_level' - -schema_scope = sys.modules[__name__] - -# Defined datatype length_measure -class length_measure(REAL): - def __init__(self,*kargs): - pass - -# Defined datatype label -class label(STRING): - def __init__(self,*kargs): - pass - -# Defined datatype point -class point(REAL): - def __init__(self,*kargs): - pass - - -#################### - # ENTITY shape # -#################### -class shape(BaseEntityClass): - '''Entity shape definition. - - :param item_name - :type item_name:label - - :param number_of_sides - :type number_of_sides:INTEGER - ''' - def __init__( self , item_name,number_of_sides, ): - self.item_name = item_name - self.number_of_sides = number_of_sides - - @apply - def item_name(): - def fget( self ): - return self._item_name - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument item_name is mandatory and can not be set to None') - if not check_type(value,label): - self._item_name = label(value) - else: - self._item_name = value - return property(**locals()) - - @apply - def number_of_sides(): - def fget( self ): - return self._number_of_sides - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument number_of_sides is mandatory and can not be set to None') - if not check_type(value,INTEGER): - self._number_of_sides = INTEGER(value) - else: - self._number_of_sides = value - return property(**locals()) - -#################### - # ENTITY subshape # -#################### -class subshape(shape): - '''Entity subshape definition. - ''' - def __init__( self , inherited0__item_name , inherited1__number_of_sides , ): - shape.__init__(self , inherited0__item_name , inherited1__number_of_sides , ) - -#################### - # ENTITY rectangle # -#################### -class rectangle(subshape): - '''Entity rectangle definition. - - :param height - :type height:length_measure - - :param width - :type width:length_measure - ''' - def __init__( self , inherited0__item_name , inherited1__number_of_sides , height,width, ): - subshape.__init__(self , inherited0__item_name , inherited1__number_of_sides , ) - self.height = height - self.width = width - - @apply - def height(): - def fget( self ): - return self._height - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument height is mandatory and can not be set to None') - if not check_type(value,length_measure): - self._height = length_measure(value) - else: - self._height = value - return property(**locals()) - - @apply - def width(): - def fget( self ): - return self._width - def fset( self, value ): - # Mandatory argument - if value==None: - raise AssertionError('Argument width is mandatory and can not be set to None') - if not check_type(value,length_measure): - self._width = length_measure(value) - else: - self._width = value - return property(**locals()) diff --git a/src/exp2python/examples/unitary_schemas/test_where_rule.py b/src/exp2python/examples/unitary_schemas/test_where_rule.py deleted file mode 100644 index 99bb2f146..000000000 --- a/src/exp2python/examples/unitary_schemas/test_where_rule.py +++ /dev/null @@ -1,51 +0,0 @@ -# This file was generated by exp2python. You probably don't want to edit -# it since your modifications will be lost if exp2python is used to -# regenerate it. -import sys - -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type -from SCL.Builtin import * -from SCL.Rules import * - -schema_name = 'test_where_rule' - -schema_scope = sys.modules[__name__] - -# Defined datatype month -class month(INTEGER): - def __init__(self,*kargs): - pass - self.unnamed_wr_0() - self.unnamed_wr_1() - - def unnamed_wr_0(self): - eval_unnamed_wr_0 = (self <= 12) - if not eval_unnamed_wr_0: - raise AssertionError('Rule unnamed_wr_0 violated') - else: - return eval_unnamed_wr_0 - - def unnamed_wr_1(self): - eval_unnamed_wr_1 = (self >= 1) - if not eval_unnamed_wr_1: - raise AssertionError('Rule unnamed_wr_1 violated') - else: - return eval_unnamed_wr_1 - -# Defined datatype positive -class positive(INTEGER): - def __init__(self,*kargs): - pass - self.notnegative() - - def notnegative(self): - eval_notnegative_wr = (self > 0) - if not eval_notnegative_wr: - raise AssertionError('Rule notnegative violated') - else: - return eval_notnegative_wr - From cd8efa604fa5240368ae9e25a4c1ca8ccdf2dbdb Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 1 Apr 2020 00:27:25 +0100 Subject: [PATCH 172/244] exploration of sqlite3 plugin (based on json1.c) for allowing high performance predicates, intended as a layer between ORM and direct database manipulation --- src/exp2python/python/SCL/p21sql.c | 3512 ++++++++++++++++++++++++++++ src/exp2python/python/SCL/p21sql.l | 2641 +++++++++++++++++++++ 2 files changed, 6153 insertions(+) create mode 100644 src/exp2python/python/SCL/p21sql.c create mode 100644 src/exp2python/python/SCL/p21sql.l diff --git a/src/exp2python/python/SCL/p21sql.c b/src/exp2python/python/SCL/p21sql.c new file mode 100644 index 000000000..d13fdf7eb --- /dev/null +++ b/src/exp2python/python/SCL/p21sql.c @@ -0,0 +1,3512 @@ +/* Generated by re2c 1.0.3 on Mon Apr 6 21:17:12 2020 */ +#line 1 "p21sql.l" +/* +** 2015-08-12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This SQLite extension implements P21 functions. The interface is +** modeled after MySQL JSON functions: +** +** https://dev.mysql.com/doc/refman/5.7/en/json.html +** +** For the time being, all P21 params are stored as pure text. +*/ +#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_P21SQL) +#if !defined(SQLITEINT_H) +#include "sqlite3ext.h" +#endif +SQLITE_EXTENSION_INIT1 +#include +#include +#include +#include + +/* Mark a function parameter as unused, to suppress nuisance compiler +** warnings. */ +#ifndef UNUSED_PARAM +# define UNUSED_PARAM(X) (void)(X) +#endif + +#ifndef LARGEST_INT64 +# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#endif + +/* +** Versions of isspace(), isalnum() and isdigit() to which it is safe +** to pass signed char values. +*/ +#ifdef sqlite3Isdigit + /* Use the SQLite core versions if this routine is part of the + ** SQLite amalgamation */ +# define safe_isdigit(x) sqlite3Isdigit(x) +# define safe_isalnum(x) sqlite3Isalnum(x) +# define safe_isxdigit(x) sqlite3Isxdigit(x) +#else + /* Use the standard library for separate compilation */ +#include /* amalgamator: keep */ +# define safe_isdigit(x) isdigit((unsigned char)(x)) +# define safe_isalnum(x) isalnum((unsigned char)(x)) +# define safe_isxdigit(x) isxdigit((unsigned char)(x)) +#endif + +/* +** Growing our own isspace() routine this way is twice as fast as +** the library isspace() function, resulting in a 7% overall performance +** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). +*/ +static const char p21IsSpace[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#define safe_isspace(x) (p21IsSpace[(unsigned char)x]) + +#ifndef SQLITE_AMALGAMATION + /* Unsigned integer types. These are already defined in the sqliteInt.h, + ** but the definitions need to be repeated for separate compilation. */ + typedef sqlite3_uint64 u64; + typedef unsigned int u32; + typedef unsigned short int u16; + typedef unsigned char u8; +#endif + +/* some C implementations don't have these? (inttypes.h / stdint.h) */ +#ifndef UINT16_WIDTH +# define UINT16_WIDTH 16 +#endif +#ifndef UINT16_MAX +# define UINT16_MAX 65535 +#endif + +/* Objects */ +typedef struct P21String P21String; +typedef struct P21Node P21Node; +typedef struct P21Parse P21Parse; + +/* An instance of this object represents a P21 parameter string +** under construction. Really, this is a generic string accumulator +** that can be and is used to create strings other than JSON (here P21!). +*/ +struct P21String { + sqlite3_context *pCtx; /* Function context - put error messages here */ + char *zBuf; /* Append P21 content here */ + u64 nAlloc; /* Bytes of storage available in zBuf[] */ + u64 nUsed; /* Bytes of zBuf[] currently used */ + u8 bStatic; /* True if zBuf is static space */ + u8 bErr; /* True if an error has been encountered */ + char zSpace[100]; /* Initial static space */ +}; + +#define P21_EMPTY 0x1 /* optional attribute not provided : '$' */ +#define P21_DERIVED 0x2 /* derived attribute not provided : '*' */ +#define P21_ENUMERATION 0x3 /* (also) includes boolean and logical values */ +#define P21_INTEGER 0x4 +#define P21_REAL 0x5 +#define P21_STRING 0x6 +#define P21_BINARY 0x7 +#define P21_EID 0x8 /* entity_instance_name */ +#define P21_LIST 0x9 +#define P21_RECORD 0xA /* simple_record */ + +#define P21_SUBTYPE 80 /* Ascii for "P" */ + + +/* +** Names of the various P21 types: +*/ +static const char * const p21Type[] = { + "", + "empty", "derived", "enumeration", "integer", "real", + "string", "binary", "eid", "list", "record" +}; + +/* Bit values for the P21Node.jnFlag field +*/ +#define PNODE_RAW 0x01 /* Content is raw, not P21 encoded */ +#define PNODE_ESCAPE 0x02 /* Content is text with \ escapes */ +#define PNODE_REMOVE 0x04 /* Do not output */ +#define PNODE_REPLACE 0x08 /* Replace with P21Node.u.iReplace */ +#define PNODE_PATCH 0x10 /* Patch with P21Node.u.pPatch */ +#define PNODE_APPEND 0x20 /* More ARRAY/OBJECT entries at u.iAppend */ +#define PNODE_LABEL 0x40 /* Is a label of an object */ + + +/* A single node of parsed P21 params +*/ +struct P21Node { + u8 eType; /* One of the P21_ type values */ + u8 jnFlags; /* P21Node flags */ + u16 n_kw; /* store the KEYWORD length */ + u32 n; /* Bytes of content, or number of sub-nodes */ + union { + const char *zJContent; /* Content for INT, REAL, and STRING */ + u32 iAppend; /* More terms for ARRAY and OBJECT */ + u32 iKey; /* Key for ARRAY objects in p21_tree() */ + u32 iReplace; /* Replacement content for PNODE_REPLACE */ + P21Node *pPatch; /* Node chain of patch for PNODE_PATCH */ + } u; +}; + +/* A completely parsed P21 string +*/ +struct P21Parse { + u32 nNode; /* Number of slots of aNode[] used */ + u32 nAlloc; /* Number of slots of aNode[] allocated */ + P21Node *aNode; /* Array of nodes containing the parse */ + const char *zP21; /* Original P21 string */ + u32 *aUp; /* Index of parent of each node */ + u8 oom; /* Set to true if out of memory */ + u8 nErr; /* Number of errors seen */ + u16 iDepth; /* Nesting depth */ + int nP21; /* Length of the zP21 string in bytes */ + u32 iHold; /* Replace cache line with the lowest iHold value */ +}; + +/* +** Maximum nesting depth of P21 for this implementation. +*/ +#define P21_MAX_DEPTH 20 + +/************************************************************************** +** Utility routines for dealing with P21String objects +**************************************************************************/ + +/* Set the P21String object to an empty string +*/ +static void p21Zero(P21String *p){ + p->zBuf = p->zSpace; + p->nAlloc = sizeof(p->zSpace); + p->nUsed = 0; + p->bStatic = 1; +} + +/* Initialize the P21String object +*/ +static void p21Init(P21String *p, sqlite3_context *pCtx){ + p->pCtx = pCtx; + p->bErr = 0; + p21Zero(p); +} + + +/* Free all allocated memory and reset the P21String object back to its +** initial state. +*/ +static void p21Reset(P21String *p){ + if( !p->bStatic ) sqlite3_free(p->zBuf); + p21Zero(p); +} + + +/* Report an out-of-memory (OOM) condition +*/ +static void p21Oom(P21String *p){ + p->bErr = 1; + sqlite3_result_error_nomem(p->pCtx); + p21Reset(p); +} + +/* Enlarge p->zBuf so that it can hold at least N more bytes. +** Return zero on success. Return non-zero on an OOM error +*/ +static int p21Grow(P21String *p, u32 N){ + u64 nTotal = NnAlloc ? p->nAlloc*2 : p->nAlloc+N+10; + char *zNew; + if( p->bStatic ){ + if( p->bErr ) return 1; + zNew = sqlite3_malloc64(nTotal); + if( zNew==0 ){ + p21Oom(p); + return SQLITE_NOMEM; + } + memcpy(zNew, p->zBuf, (size_t)p->nUsed); + p->zBuf = zNew; + p->bStatic = 0; + }else{ + zNew = sqlite3_realloc64(p->zBuf, nTotal); + if( zNew==0 ){ + p21Oom(p); + return SQLITE_NOMEM; + } + p->zBuf = zNew; + } + p->nAlloc = nTotal; + return SQLITE_OK; +} + +/* Append N bytes from zIn onto the end of the P21String string. +*/ +static void p21AppendRaw(P21String *p, const char *zIn, u32 N){ + if( (N+p->nUsed >= p->nAlloc) && p21Grow(p,N)!=0 ) return; + memcpy(p->zBuf+p->nUsed, zIn, N); + p->nUsed += N; +} + +/* Append formatted text (not to exceed N bytes) to the P21String. +*/ +static void p21Printf(int N, P21String *p, const char *zFormat, ...){ + va_list ap; + if( (p->nUsed + N >= p->nAlloc) && p21Grow(p, N) ) return; + va_start(ap, zFormat); + sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap); + va_end(ap); + p->nUsed += (int)strlen(p->zBuf+p->nUsed); +} + +/* Append a single character +*/ +static void p21AppendChar(P21String *p, char c){ + if( p->nUsed>=p->nAlloc && p21Grow(p,1)!=0 ) return; + p->zBuf[p->nUsed++] = c; +} + +/* Append a comma separator to the output buffer, if the previous +** character is not '[' or '{'. +*/ +static void p21AppendSeparator(P21String *p){ + char c; + if( p->nUsed==0 ) return; + c = p->zBuf[p->nUsed-1]; + if( c!='(' ) p21AppendChar(p, ','); +} + +/* Append the N-byte string in zIn to the end of the P21String string +** under construction. Enclose the string in '...' and escape +** any double-quotes or backslash characters contained within the +** string. +*/ +static void p21AppendString(P21String *p, const char *zIn, u32 N){ + u32 i; + if( (N+p->nUsed+2 >= p->nAlloc) && p21Grow(p,N+2)!=0 ) return; + p->zBuf[p->nUsed++] = '\''; + for(i=0; inUsed+N+3-i > p->nAlloc) && p21Grow(p,N+3-i)!=0 ) return; + p->zBuf[p->nUsed++] = '\\'; + }else if( c<=0x1f ){ + static const char aSpecial[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + assert( sizeof(aSpecial)==32 ); + assert( aSpecial['\b']=='b' ); + assert( aSpecial['\f']=='f' ); + assert( aSpecial['\n']=='n' ); + assert( aSpecial['\r']=='r' ); + assert( aSpecial['\t']=='t' ); + if( aSpecial[c] ){ + c = aSpecial[c]; + goto p21_simple_escape; + } + if( (p->nUsed+N+7+i > p->nAlloc) && p21Grow(p,N+7-i)!=0 ) return; + p->zBuf[p->nUsed++] = '\\'; + p->zBuf[p->nUsed++] = 'u'; + p->zBuf[p->nUsed++] = '0'; + p->zBuf[p->nUsed++] = '0'; + p->zBuf[p->nUsed++] = '0' + (c>>4); + c = "0123456789abcdef"[c&0xf]; + } + p->zBuf[p->nUsed++] = c; + } + p->zBuf[p->nUsed++] = '\''; + assert( p->nUsednAlloc ); +} + +/* +** Append a function parameter value to the P21 string under +** construction. +*/ +static void p21AppendValue( + P21String *p, /* Append to this P21 string */ + sqlite3_value *pValue /* Value to append */ +){ + switch( sqlite3_value_type(pValue) ){ + case SQLITE_NULL: { + p21AppendRaw(p, "$", 1); + break; + } + case SQLITE_INTEGER: + case SQLITE_FLOAT: { + const char *z = (const char*)sqlite3_value_text(pValue); + /* TODO: confirm format is valid */ + u32 n = (u32)sqlite3_value_bytes(pValue); + p21AppendRaw(p, z, n); + break; + } + case SQLITE_TEXT: { + const char *z = (const char*)sqlite3_value_text(pValue); + u32 n = (u32)sqlite3_value_bytes(pValue); + if( sqlite3_value_subtype(pValue)==P21_SUBTYPE ){ + p21AppendRaw(p, z, n); + }else{ + p21AppendString(p, z, n); + } + break; + } + default: { + if( p->bErr==0 ){ + sqlite3_result_error(p->pCtx, "P21 cannot hold BLOB values", -1); + p->bErr = 2; + p21Reset(p); + } + break; + } + } +} + + +/* Make the P21 in p the result of the SQL function. +*/ +static void p21Result(P21String *p){ + if( p->bErr==0 ){ + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, + SQLITE_UTF8); + p21Zero(p); + } + assert( p->bStatic ); +} + +/************************************************************************** +** Utility routines for dealing with P21Node and P21Parse objects +**************************************************************************/ + +/* +** Return the number of consecutive P21Node slots need to represent +** the parsed P21 at pNode. The minimum answer is 1. For ARRAY and +** OBJECT types, the number might be larger. +** +** Appended elements are not counted. The value returned is the number +** by which the P21Node counter should increment in order to go to the +** next peer value. +*/ +static u32 p21NodeSize(P21Node *pNode){ + return pNode->eType < P21_LIST ? 1 : pNode->n + 1; +} + +/* +** Reclaim all memory allocated by a P21Parse object. But do not +** delete the P21Parse object itself. +*/ +static void p21ParseReset(P21Parse *pParse){ + sqlite3_free(pParse->aNode); + pParse->aNode = 0; + pParse->nNode = 0; + pParse->nAlloc = 0; + sqlite3_free(pParse->aUp); + pParse->aUp = 0; +} + +/* +** Free a P21Parse object that was obtained from sqlite3_malloc(). +*/ +static void p21ParseFree(P21Parse *pParse){ + p21ParseReset(pParse); + sqlite3_free(pParse); +} + +/* +** Convert the P21Node pNode into a pure P21 string and +** append to pOut. Subsubstructure is also included. Return +** the number of P21Node objects that are encoded. +*/ +static void p21RenderNode( + P21Node *pNode, /* The node to render */ + P21String *pOut, /* Write P21 here */ + sqlite3_value **aReplace /* Replacement values */ +){ + if( pNode->jnFlags & (PNODE_REPLACE|PNODE_PATCH) ){ + if( pNode->jnFlags & PNODE_REPLACE ){ + p21AppendValue(pOut, aReplace[pNode->u.iReplace]); + return; + } + pNode = pNode->u.pPatch; + } + switch( pNode->eType ){ + default: { + assert( pNode->eType==P21_EMPTY ); + p21AppendChar(pOut, '$'); + break; + } + case P21_ENUMERATION: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_DERIVED: { + p21AppendChar(pOut, '*'); + break; + } + case P21_BINARY: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_EID: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_STRING: { + if( pNode->jnFlags & PNODE_RAW ){ + p21AppendString(pOut, pNode->u.zJContent, pNode->n); + break; + } + /* Fall through into the next case */ + } + case P21_REAL: + case P21_INTEGER: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_LIST: { + u32 j = 1; + p21AppendChar(pOut, '('); + for(;;){ + while( j<=pNode->n ){ + if( (pNode[j].jnFlags & PNODE_REMOVE)==0 ){ + p21AppendSeparator(pOut); + p21RenderNode(&pNode[j], pOut, aReplace); + } + j += p21NodeSize(&pNode[j]); + } + if( (pNode->jnFlags & PNODE_APPEND)==0 ) break; + pNode = &pNode[pNode->u.iAppend]; + j = 1; + } + p21AppendChar(pOut, ')'); + break; + } + case P21_RECORD: { + u32 j = 1; + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n_kw); + p21AppendChar(pOut, '('); + for(;;){ + while( j<= pNode->n ){ + if( (pNode[j].jnFlags & PNODE_REMOVE)==0 ){ + p21AppendSeparator(pOut); + p21RenderNode(&pNode[j], pOut, aReplace); + } + j += p21NodeSize(&pNode[j]); + } + if( (pNode->jnFlags & PNODE_APPEND)==0 ) break; + pNode = &pNode[pNode->u.iAppend]; + j = 1; + } + p21AppendChar(pOut, ')'); + break; + } + } +} + +/* +** Return a P21Node and all its descendents as a P21 string. +*/ +static void p21ReturnP21( + P21Node *pNode, /* Node to return */ + sqlite3_context *pCtx, /* Return value for this function */ + sqlite3_value **aReplace /* Array of replacement values */ +){ + P21String s; + p21Init(&s, pCtx); + p21RenderNode(pNode, &s, aReplace); + p21Result(&s); + sqlite3_result_subtype(pCtx, P21_SUBTYPE); +} + +/* +** Translate a single byte of Hex into an integer. +** This routine only works if h really is a valid hexadecimal +** character: 0..9a..fA..F +*/ +static u8 p21HexToInt(int h){ + assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') ); +#ifdef SQLITE_EBCDIC + h += 9*(1&~(h>>4)); +#else + h += 9*(1&(h>>6)); +#endif + return (u8)(h & 0xf); +} + +/* +** Convert a 4-byte hex string into an integer +*/ +static u32 p21HexToInt4(const char *z){ + u32 v; + assert( safe_isxdigit(z[0]) ); + assert( safe_isxdigit(z[1]) ); + assert( safe_isxdigit(z[2]) ); + assert( safe_isxdigit(z[3]) ); + v = (p21HexToInt(z[0])<<12) + + (p21HexToInt(z[1])<<8) + + (p21HexToInt(z[2])<<4) + + p21HexToInt(z[3]); + return v; +} +/* +** Make the P21Node the return value of the function. +*/ +static void p21Return( + P21Node *pNode, /* Node to return */ + sqlite3_context *pCtx, /* Return value for this function */ + sqlite3_value **aReplace /* Array of replacement values */ +){ + switch( pNode->eType ){ + default: { + assert( pNode->eType==P21_EMPTY ); + sqlite3_result_null(pCtx); + break; + } + case P21_DERIVED: { + assert(0); + } + case P21_ENUMERATION: { + assert(0); + } + case P21_BINARY: { + assert(0); + } + case P21_EID: { + sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, SQLITE_TRANSIENT); + break; + } + case P21_INTEGER: { + sqlite3_int64 i = 0; + const char *z = pNode->u.zJContent; + if( z[0]=='-' ){ z++; } + while( z[0]>='0' && z[0]<='9' ){ + unsigned v = *(z++) - '0'; + if( i>=LARGEST_INT64/10 ){ + if( i>LARGEST_INT64/10 ) goto int_as_real; + if( z[0]>='0' && z[0]<='9' ) goto int_as_real; + if( v==9 ) goto int_as_real; + if( v==8 ){ + if( pNode->u.zJContent[0]=='-' ){ + sqlite3_result_int64(pCtx, SMALLEST_INT64); + goto int_done; + }else{ + goto int_as_real; + } + } + } + i = i*10 + v; + } + if( pNode->u.zJContent[0]=='-' ){ i = -i; } + sqlite3_result_int64(pCtx, i); + int_done: + break; + int_as_real: /* fall through to real */; + } + case P21_REAL: { + double r; +#ifdef SQLITE_AMALGAMATION + const char *z = pNode->u.zJContent; + sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); +#else + r = strtod(pNode->u.zJContent, 0); +#endif + sqlite3_result_double(pCtx, r); + break; + } + case P21_STRING: { +#if 0 /* Never happens because PNODE_RAW is only set by p21_set(), + ** p21_insert() and p21_replace() and those routines do not + ** call p21Return() */ + if( pNode->jnFlags & PNODE_RAW ){ + sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, + SQLITE_TRANSIENT); + }else +#endif + assert( (pNode->jnFlags & PNODE_RAW)==0 ); + if( (pNode->jnFlags & PNODE_ESCAPE)==0 ){ + /* P21 formatted without any backslash-escapes */ + sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, + SQLITE_TRANSIENT); + }else{ + /* Translate P21 formatted string into raw text */ + u32 i; + u32 n = pNode->n; + const char *z = pNode->u.zJContent; + char *zOut; + u32 j; + /* TODO: */ + assert(0); + zOut = sqlite3_malloc( n+1 ); + if( zOut==0 ){ + sqlite3_result_error_nomem(pCtx); + break; + } + for(i=1, j=0; i>6)); + zOut[j++] = 0x80 | (v&0x3f); + }else{ + u32 vlo; + if( (v&0xfc00)==0xd800 + && i>18); + zOut[j++] = 0x80 | ((v>>12)&0x3f); + zOut[j++] = 0x80 | ((v>>6)&0x3f); + zOut[j++] = 0x80 | (v&0x3f); + }else{ + zOut[j++] = 0xe0 | (v>>12); + zOut[j++] = 0x80 | ((v>>6)&0x3f); + zOut[j++] = 0x80 | (v&0x3f); + } + } + }else{ + if( c=='b' ){ + c = '\b'; + }else if( c=='f' ){ + c = '\f'; + }else if( c=='n' ){ + c = '\n'; + }else if( c=='r' ){ + c = '\r'; + }else if( c=='t' ){ + c = '\t'; + } + zOut[j++] = c; + } + } + } + zOut[j] = 0; + sqlite3_result_text(pCtx, zOut, j, sqlite3_free); + } + break; + } + case P21_LIST: + case P21_RECORD: { + p21ReturnP21(pNode, pCtx, aReplace); + break; + } + } +} + +/* Forward reference */ +static int p21ParseAddNode(P21Parse*,u32,u32,const char*); + +/* +** A macro to hint to the compiler that a function should not be +** inlined. +*/ +#if defined(__GNUC__) +# define P21_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) && _MSC_VER>=1310 +# define P21_NOINLINE __declspec(noinline) +#else +# define P21_NOINLINE +#endif + + +static P21_NOINLINE int p21ParseAddNodeExpand( + P21Parse *pParse, /* Append the node to this object */ + u32 eType, /* Node type */ + u32 n, /* Content size or sub-node count */ + const char *zContent /* Content */ +){ + u32 nNew; + P21Node *pNew; + assert( pParse->nNode>=pParse->nAlloc ); + if( pParse->oom ) return -1; + nNew = pParse->nAlloc*2 + 10; + pNew = sqlite3_realloc64(pParse->aNode, sizeof(P21Node)*nNew); + if( pNew==0 ){ + pParse->oom = 1; + return -1; + } + pParse->nAlloc = nNew; + pParse->aNode = pNew; + assert( pParse->nNodenAlloc ); + return p21ParseAddNode(pParse, eType, n, zContent); +} + +/* +** Create a new P21Node instance based on the arguments and append that +** instance to the P21Parse. Return the index in pParse->aNode[] of the +** new node, or -1 if a memory allocation fails. +*/ +static int p21ParseAddNode( + P21Parse *pParse, /* Append the node to this object */ + u32 eType, /* Node type */ + u32 n, /* Content size or sub-node count */ + const char *zContent /* Content */ +){ + P21Node *p; + if( pParse->nNode>=pParse->nAlloc ){ + return p21ParseAddNodeExpand(pParse, eType, n, zContent); + } + p = &pParse->aNode[pParse->nNode]; + p->eType = (u8)eType; + p->jnFlags = 0; + p->n = n; + p->u.zJContent = zContent; + return pParse->nNode++; +} + +/* +** Return true if z[] begins with 4 (or more) hexadecimal digits +*/ +static int p21Is4Hex(const char *z){ + int i; + for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0; + return 1; +} + +/* +** Parse P21 value which begins at pParse->zP21[i]. Return the +** index of the first character past the end of the value parsed. +** +** Return negative for a syntax error. +*/ +static int p21ParseValue(P21Parse *pParse, u32 i) { + static int cxtStack[P21_MAX_DEPTH]; + const unsigned char *sp, *cur, *mrk, *tok, *end; + const unsigned char *yyt1; + int *piThis, x; + u32 n; + P21Node *pNode; + + sp = cur = tok = &pParse->zP21[i]; + piThis = cxtStack + pParse->iDepth; + +#line 832 "p21sql.l" + + +start: + + tok = cur; + +#line 822 "p21sql.c" +{ + unsigned char yych; + yych = *cur; + if (yych <= '\r') { + if (yych <= 0x0008) goto yy2; + if (yych <= '\n') goto yy3; + if (yych >= '\r') goto yy3; + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yy3; + } else { + if (yych == '(') goto yy6; + } + } +yy2: +#line 850 "p21sql.l" + { + /* (simple_entity_instance) parameter_list */ + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } +#line 848 "p21sql.c" +yy3: + yych = *++cur; + if (yych <= '\f') { + if (yych <= 0x0008) goto yy5; + if (yych <= '\n') goto yy3; + } else { + if (yych <= '\r') goto yy3; + if (yych == ' ') goto yy3; + } +yy5: +#line 838 "p21sql.l" + { + goto start; + } +#line 863 "p21sql.c" +yy6: + ++cur; +#line 841 "p21sql.l" + { + /* (complex_entity_instance) parameter_list */ + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto keywords; + } +#line 876 "p21sql.c" +} +#line 859 "p21sql.l" + + +keywords: + tok = cur; + + +#line 885 "p21sql.c" +{ + unsigned char yych; + yych = *(mrk = cur); + if (yych <= '(') { + if (yych <= '\r') { + if (yych <= 0x0008) goto yy10; + if (yych <= '\n') goto yy11; + if (yych >= '\r') goto yy11; + } else { + if (yych <= 0x001F) goto yy10; + if (yych <= ' ') goto yy11; + if (yych <= '!') goto yy14; + } + } else { + if (yych <= '^') { + if (yych <= ')') goto yy16; + if (yych <= '@') goto yy10; + if (yych <= 'Z') goto yy18; + } else { + if (yych == '`') goto yy10; + if (yych <= 'z') goto yy18; + } + } +yy10: +#line 885 "p21sql.l" + { + /* fix-up and revert to P21_RECORD */ + pNode = pParse->aNode + *(piThis - 1); + pNode->eType = P21_RECORD; + assert(pParse->iDepth == 1); + goto params1; + } +#line 918 "p21sql.c" +yy11: + yych = *++cur; + if (yych <= '\f') { + if (yych <= 0x0008) goto yy13; + if (yych <= '\n') goto yy11; + } else { + if (yych <= '\r') goto yy11; + if (yych == ' ') goto yy11; + } +yy13: +#line 865 "p21sql.l" + { + goto keywords; + } +#line 933 "p21sql.c" +yy14: + yych = *++cur; + if (yych <= '^') { + if (yych <= '@') goto yy15; + if (yych <= 'Z') goto yy18; + } else { + if (yych == '`') goto yy15; + if (yych <= 'z') goto yy18; + } +yy15: + cur = mrk; + goto yy10; +yy16: + ++cur; +#line 877 "p21sql.l" + { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + assert(pNode->eType == P21_LIST); + + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto eol; + } +#line 957 "p21sql.c" +yy18: + yych = *++cur; + if (yych <= '(') { + if (yych <= '\r') { + if (yych <= 0x0008) goto yy15; + if (yych <= '\n') { + yyt1 = cur; + goto yy20; + } + if (yych <= '\f') goto yy15; + yyt1 = cur; + } else { + if (yych == ' ') { + yyt1 = cur; + goto yy20; + } + if (yych <= '\'') goto yy15; + yyt1 = cur; + goto yy22; + } + } else { + if (yych <= 'Z') { + if (yych <= '/') goto yy15; + if (yych <= '9') goto yy18; + if (yych <= '@') goto yy15; + goto yy18; + } else { + if (yych <= '_') { + if (yych <= '^') goto yy15; + goto yy18; + } else { + if (yych <= '`') goto yy15; + if (yych <= 'z') goto yy18; + goto yy15; + } + } + } +yy20: + yych = *++cur; + if (yych <= '\r') { + if (yych <= 0x0008) goto yy15; + if (yych <= '\n') goto yy20; + if (yych <= '\f') goto yy15; + goto yy20; + } else { + if (yych <= ' ') { + if (yych <= 0x001F) goto yy15; + goto yy20; + } else { + if (yych != '(') goto yy15; + } + } +yy22: + ++cur; + end = yyt1; +#line 868 "p21sql.l" + { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } +#line 1023 "p21sql.c" +} +#line 892 "p21sql.l" + + +params1: + tok = cur; + + +#line 1032 "p21sql.c" +{ + unsigned char yych; + unsigned int yyaccept = 0; + yych = *(mrk = cur); + if (yych <= ')') { + if (yych <= '!') { + if (yych <= '\f') { + if (yych <= 0x0008) goto yy26; + if (yych <= '\n') goto yy27; + } else { + if (yych <= '\r') goto yy27; + if (yych <= 0x001F) goto yy26; + if (yych <= ' ') goto yy27; + goto yy30; + } + } else { + if (yych <= '$') { + if (yych <= '"') goto yy32; + if (yych <= '#') goto yy33; + goto yy34; + } else { + if (yych <= '&') goto yy26; + if (yych <= '\'') goto yy36; + if (yych <= '(') goto yy38; + goto yy40; + } + } + } else { + if (yych <= '9') { + if (yych <= ',') { + if (yych <= '*') goto yy42; + if (yych <= '+') goto yy44; + goto yy46; + } else { + if (yych <= '-') goto yy44; + if (yych <= '.') goto yy48; + if (yych >= '0') goto yy49; + } + } else { + if (yych <= '^') { + if (yych <= '@') goto yy26; + if (yych <= 'Z') goto yy52; + } else { + if (yych == '`') goto yy26; + if (yych <= 'z') goto yy52; + } + } + } +yy26: +#line 959 "p21sql.l" + { + if (pParse->iDepth) --pParse->iDepth; + piThis = cxtStack + pParse->iDepth; + pNode = pParse->aNode + *piThis; + assert(pNode->eType == P21_RECORD); + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto eol; + } +#line 1091 "p21sql.c" +yy27: + yych = *++cur; + if (yych <= '\f') { + if (yych <= 0x0008) goto yy29; + if (yych <= '\n') goto yy27; + } else { + if (yych <= '\r') goto yy27; + if (yych == ' ') goto yy27; + } +yy29: +#line 898 "p21sql.l" + { + goto params1; + } +#line 1106 "p21sql.c" +yy30: + yych = *++cur; + if (yych <= '^') { + if (yych <= '@') goto yy31; + if (yych <= 'Z') goto yy52; + } else { + if (yych == '`') goto yy31; + if (yych <= 'z') goto yy52; + } +yy31: + cur = mrk; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy26; + } else { + goto yy60; + } + } else { + goto yy67; + } +yy32: + yych = *++cur; + if (yych <= '/') goto yy31; + if (yych <= '3') goto yy54; + goto yy31; +yy33: + yych = *++cur; + if (yych <= '/') goto yy31; + if (yych <= '9') goto yy56; + goto yy31; +yy34: + ++cur; +#line 945 "p21sql.l" + { + p21ParseAddNode(pParse, P21_EMPTY, cur - tok, tok); + goto params1; + } +#line 1144 "p21sql.c" +yy36: + yych = *++cur; + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy31; + if (yych == '\'') goto yy59; + goto yy36; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy31; + goto yy61; + } else { + if (yych <= ']') goto yy31; + if (yych <= '~') goto yy36; + goto yy31; + } + } +yy38: + ++cur; +#line 910 "p21sql.l" + { + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } +#line 1172 "p21sql.c" +yy40: + ++cur; +#line 953 "p21sql.l" + { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto params1; + } +#line 1182 "p21sql.c" +yy42: + ++cur; +#line 949 "p21sql.l" + { + p21ParseAddNode(pParse, P21_DERIVED, cur - tok, tok); + goto params1; + } +#line 1190 "p21sql.c" +yy44: + yych = *++cur; + if (yych <= ',') { + if (yych == '+') goto yy44; + goto yy31; + } else { + if (yych <= '-') goto yy44; + if (yych <= '/') goto yy31; + if (yych <= '9') goto yy49; + goto yy31; + } +yy46: + ++cur; +#line 918 "p21sql.l" + { + goto params1; + } +#line 1208 "p21sql.c" +yy48: + yych = *++cur; + if (yych <= '@') goto yy31; + if (yych <= 'Z') goto yy63; + if (yych == '_') goto yy63; + goto yy31; +yy49: + yych = *++cur; + if (yych == '.') goto yy65; + if (yych <= '/') goto yy51; + if (yych <= '9') goto yy49; +yy51: +#line 925 "p21sql.l" + { + p21ParseAddNode(pParse, P21_INTEGER, cur - tok, tok); + goto params1; + } +#line 1226 "p21sql.c" +yy52: + yych = *++cur; + if (yych <= '(') { + if (yych <= '\r') { + if (yych <= 0x0008) goto yy31; + if (yych <= '\n') { + yyt1 = cur; + goto yy68; + } + if (yych <= '\f') goto yy31; + yyt1 = cur; + goto yy68; + } else { + if (yych == ' ') { + yyt1 = cur; + goto yy68; + } + if (yych <= '\'') goto yy31; + yyt1 = cur; + goto yy70; + } + } else { + if (yych <= 'Z') { + if (yych <= '/') goto yy31; + if (yych <= '9') goto yy52; + if (yych <= '@') goto yy31; + goto yy52; + } else { + if (yych <= '_') { + if (yych <= '^') goto yy31; + goto yy52; + } else { + if (yych <= '`') goto yy31; + if (yych <= 'z') goto yy52; + goto yy31; + } + } + } +yy54: + yych = *++cur; + if (yych <= '/') { + if (yych == '"') goto yy72; + goto yy31; + } else { + if (yych <= '9') goto yy54; + if (yych <= '@') goto yy31; + if (yych <= 'F') goto yy54; + goto yy31; + } +yy56: + yych = *++cur; + if (yych <= '/') goto yy58; + if (yych <= '9') goto yy56; +yy58: +#line 941 "p21sql.l" + { + p21ParseAddNode(pParse, P21_EID, cur - tok, tok); + goto params1; + } +#line 1286 "p21sql.c" +yy59: + yyaccept = 1; + yych = *(mrk = ++cur); + if (yych == '\'') goto yy36; +yy60: +#line 929 "p21sql.l" + { + p21ParseAddNode(pParse, P21_STRING, cur - tok, tok); + goto params1; + } +#line 1297 "p21sql.c" +yy61: + yych = *++cur; + if (yych <= 'S') { + if (yych <= '&') { + if (yych <= 0x001F) goto yy31; + goto yy36; + } else { + if (yych <= '\'') goto yy59; + if (yych <= 'R') goto yy36; + goto yy74; + } + } else { + if (yych <= '\\') { + if (yych <= 'Z') goto yy36; + if (yych <= '[') goto yy31; + goto yy61; + } else { + if (yych <= ']') goto yy31; + if (yych <= '~') goto yy36; + goto yy31; + } + } +yy63: + yych = *++cur; + if (yych <= '9') { + if (yych == '.') goto yy75; + if (yych <= '/') goto yy31; + goto yy63; + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yy31; + goto yy63; + } else { + if (yych == '_') goto yy63; + goto yy31; + } + } +yy65: + yyaccept = 2; + yych = *(mrk = ++cur); + if (yych <= '/') goto yy67; + if (yych <= '9') goto yy65; + if (yych == 'E') goto yy77; +yy67: +#line 921 "p21sql.l" + { + p21ParseAddNode(pParse, P21_REAL, cur - tok, tok); + goto params1; + } +#line 1347 "p21sql.c" +yy68: + yych = *++cur; + if (yych <= '\r') { + if (yych <= 0x0008) goto yy31; + if (yych <= '\n') goto yy68; + if (yych <= '\f') goto yy31; + goto yy68; + } else { + if (yych <= ' ') { + if (yych <= 0x001F) goto yy31; + goto yy68; + } else { + if (yych != '(') goto yy31; + } + } +yy70: + ++cur; + end = yyt1; +#line 901 "p21sql.l" + { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } +#line 1376 "p21sql.c" +yy72: + ++cur; +#line 933 "p21sql.l" + { + p21ParseAddNode(pParse, P21_BINARY, cur - tok, tok); + goto params1; + } +#line 1384 "p21sql.c" +yy74: + yych = *++cur; + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy31; + if (yych == '\'') goto yy59; + goto yy36; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy31; + goto yy79; + } else { + if (yych <= ']') goto yy31; + if (yych <= '~') goto yy36; + goto yy31; + } + } +yy75: + ++cur; +#line 937 "p21sql.l" + { + p21ParseAddNode(pParse, P21_ENUMERATION, cur - tok, tok); + goto params1; + } +#line 1408 "p21sql.c" +yy77: + yych = *++cur; + if (yych <= ',') { + if (yych == '+') goto yy77; + goto yy31; + } else { + if (yych <= '-') goto yy77; + if (yych <= '/') goto yy31; + if (yych <= '9') goto yy80; + goto yy31; + } +yy79: + yych = *++cur; + if (yych <= 'S') { + if (yych <= '&') { + if (yych <= 0x001F) goto yy31; + goto yy36; + } else { + if (yych <= '\'') goto yy82; + if (yych <= 'R') goto yy36; + goto yy74; + } + } else { + if (yych <= '\\') { + if (yych <= 'Z') goto yy36; + if (yych <= '[') goto yy31; + goto yy61; + } else { + if (yych <= ']') goto yy31; + if (yych <= '~') goto yy36; + goto yy31; + } + } +yy80: + yych = *++cur; + if (yych <= '/') goto yy67; + if (yych <= '9') goto yy80; + goto yy67; +yy82: + yyaccept = 1; + yych = *(mrk = ++cur); + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy60; + if (yych == '\'') goto yy82; + goto yy36; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy60; + goto yy61; + } else { + if (yych <= ']') goto yy60; + if (yych <= '~') goto yy36; + goto yy60; + } + } +} +#line 967 "p21sql.l" + + +params2: + tok = cur; + + +#line 1472 "p21sql.c" +{ + unsigned char yych; + unsigned int yyaccept = 0; + yych = *cur; + if (yych <= ')') { + if (yych <= '!') { + if (yych <= '\f') { + if (yych <= 0x0008) goto yy86; + if (yych <= '\n') goto yy87; + } else { + if (yych <= '\r') goto yy87; + if (yych <= 0x001F) goto yy86; + if (yych <= ' ') goto yy87; + goto yy90; + } + } else { + if (yych <= '$') { + if (yych <= '"') goto yy91; + if (yych <= '#') goto yy92; + goto yy93; + } else { + if (yych <= '&') goto yy86; + if (yych <= '\'') goto yy95; + if (yych <= '(') goto yy97; + goto yy99; + } + } + } else { + if (yych <= '9') { + if (yych <= ',') { + if (yych <= '*') goto yy101; + if (yych <= '+') goto yy103; + goto yy105; + } else { + if (yych <= '-') goto yy103; + if (yych <= '.') goto yy107; + if (yych >= '0') goto yy108; + } + } else { + if (yych <= '^') { + if (yych <= '@') goto yy86; + if (yych <= 'Z') goto yy111; + } else { + if (yych == '`') goto yy86; + if (yych <= 'z') goto yy111; + } + } + } +yy86: + cur = mrk; + if (yyaccept == 0) { + goto yy119; + } else { + goto yy126; + } +yy87: + yych = *++cur; + if (yych <= '\f') { + if (yych <= 0x0008) goto yy89; + if (yych <= '\n') goto yy87; + } else { + if (yych <= '\r') goto yy87; + if (yych == ' ') goto yy87; + } +yy89: +#line 973 "p21sql.l" + { + goto params2; + } +#line 1542 "p21sql.c" +yy90: + yych = *++cur; + if (yych <= '^') { + if (yych <= '@') goto yy86; + if (yych <= 'Z') goto yy111; + goto yy86; + } else { + if (yych == '`') goto yy86; + if (yych <= 'z') goto yy111; + goto yy86; + } +yy91: + yych = *++cur; + if (yych <= '/') goto yy86; + if (yych <= '3') goto yy113; + goto yy86; +yy92: + yych = *++cur; + if (yych <= '/') goto yy86; + if (yych <= '9') goto yy115; + goto yy86; +yy93: + ++cur; +#line 1020 "p21sql.l" + { + p21ParseAddNode(pParse, P21_EMPTY, cur - tok, tok); + goto params2; + } +#line 1571 "p21sql.c" +yy95: + yych = *++cur; + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy86; + if (yych == '\'') goto yy118; + goto yy95; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy86; + goto yy120; + } else { + if (yych <= ']') goto yy86; + if (yych <= '~') goto yy95; + goto yy86; + } + } +yy97: + ++cur; +#line 985 "p21sql.l" + { + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } +#line 1599 "p21sql.c" +yy99: + ++cur; +#line 1028 "p21sql.l" + { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + pNode->n = pParse->nNode - (u32)*piThis - 1; + if (pParse->iDepth > 1) { + goto params2; + } else { + goto keywords; + } + } +#line 1613 "p21sql.c" +yy101: + ++cur; +#line 1024 "p21sql.l" + { + p21ParseAddNode(pParse, P21_DERIVED, cur - tok, tok); + goto params2; + } +#line 1621 "p21sql.c" +yy103: + yych = *++cur; + if (yych <= ',') { + if (yych == '+') goto yy103; + goto yy86; + } else { + if (yych <= '-') goto yy103; + if (yych <= '/') goto yy86; + if (yych <= '9') goto yy108; + goto yy86; + } +yy105: + ++cur; +#line 993 "p21sql.l" + { + goto params2; + } +#line 1639 "p21sql.c" +yy107: + yych = *++cur; + if (yych <= '@') goto yy86; + if (yych <= 'Z') goto yy122; + if (yych == '_') goto yy122; + goto yy86; +yy108: + yych = *++cur; + if (yych == '.') goto yy124; + if (yych <= '/') goto yy110; + if (yych <= '9') goto yy108; +yy110: +#line 1000 "p21sql.l" + { + p21ParseAddNode(pParse, P21_INTEGER, cur - tok, tok); + goto params2; + } +#line 1657 "p21sql.c" +yy111: + yych = *++cur; + if (yych <= '(') { + if (yych <= '\r') { + if (yych <= 0x0008) goto yy86; + if (yych <= '\n') { + yyt1 = cur; + goto yy127; + } + if (yych <= '\f') goto yy86; + yyt1 = cur; + goto yy127; + } else { + if (yych == ' ') { + yyt1 = cur; + goto yy127; + } + if (yych <= '\'') goto yy86; + yyt1 = cur; + goto yy129; + } + } else { + if (yych <= 'Z') { + if (yych <= '/') goto yy86; + if (yych <= '9') goto yy111; + if (yych <= '@') goto yy86; + goto yy111; + } else { + if (yych <= '_') { + if (yych <= '^') goto yy86; + goto yy111; + } else { + if (yych <= '`') goto yy86; + if (yych <= 'z') goto yy111; + goto yy86; + } + } + } +yy113: + yych = *++cur; + if (yych <= '/') { + if (yych == '"') goto yy131; + goto yy86; + } else { + if (yych <= '9') goto yy113; + if (yych <= '@') goto yy86; + if (yych <= 'F') goto yy113; + goto yy86; + } +yy115: + yych = *++cur; + if (yych <= '/') goto yy117; + if (yych <= '9') goto yy115; +yy117: +#line 1016 "p21sql.l" + { + p21ParseAddNode(pParse, P21_EID, cur - tok, tok); + goto params2; + } +#line 1717 "p21sql.c" +yy118: + yyaccept = 0; + yych = *(mrk = ++cur); + if (yych == '\'') goto yy95; +yy119: +#line 1004 "p21sql.l" + { + p21ParseAddNode(pParse, P21_STRING, cur - tok, tok); + goto params2; + } +#line 1728 "p21sql.c" +yy120: + yych = *++cur; + if (yych <= 'S') { + if (yych <= '&') { + if (yych <= 0x001F) goto yy86; + goto yy95; + } else { + if (yych <= '\'') goto yy118; + if (yych <= 'R') goto yy95; + goto yy133; + } + } else { + if (yych <= '\\') { + if (yych <= 'Z') goto yy95; + if (yych <= '[') goto yy86; + goto yy120; + } else { + if (yych <= ']') goto yy86; + if (yych <= '~') goto yy95; + goto yy86; + } + } +yy122: + yych = *++cur; + if (yych <= '9') { + if (yych == '.') goto yy134; + if (yych <= '/') goto yy86; + goto yy122; + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yy86; + goto yy122; + } else { + if (yych == '_') goto yy122; + goto yy86; + } + } +yy124: + yyaccept = 1; + yych = *(mrk = ++cur); + if (yych <= '/') goto yy126; + if (yych <= '9') goto yy124; + if (yych == 'E') goto yy136; +yy126: +#line 996 "p21sql.l" + { + p21ParseAddNode(pParse, P21_REAL, cur - tok, tok); + goto params2; + } +#line 1778 "p21sql.c" +yy127: + yych = *++cur; + if (yych <= '\r') { + if (yych <= 0x0008) goto yy86; + if (yych <= '\n') goto yy127; + if (yych <= '\f') goto yy86; + goto yy127; + } else { + if (yych <= ' ') { + if (yych <= 0x001F) goto yy86; + goto yy127; + } else { + if (yych != '(') goto yy86; + } + } +yy129: + ++cur; + end = yyt1; +#line 976 "p21sql.l" + { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } +#line 1807 "p21sql.c" +yy131: + ++cur; +#line 1008 "p21sql.l" + { + p21ParseAddNode(pParse, P21_BINARY, cur - tok, tok); + goto params2; + } +#line 1815 "p21sql.c" +yy133: + yych = *++cur; + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy86; + if (yych == '\'') goto yy118; + goto yy95; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy86; + goto yy138; + } else { + if (yych <= ']') goto yy86; + if (yych <= '~') goto yy95; + goto yy86; + } + } +yy134: + ++cur; +#line 1012 "p21sql.l" + { + p21ParseAddNode(pParse, P21_ENUMERATION, cur - tok, tok); + goto params2; + } +#line 1839 "p21sql.c" +yy136: + yych = *++cur; + if (yych <= ',') { + if (yych == '+') goto yy136; + goto yy86; + } else { + if (yych <= '-') goto yy136; + if (yych <= '/') goto yy86; + if (yych <= '9') goto yy139; + goto yy86; + } +yy138: + yych = *++cur; + if (yych <= 'S') { + if (yych <= '&') { + if (yych <= 0x001F) goto yy86; + goto yy95; + } else { + if (yych <= '\'') goto yy141; + if (yych <= 'R') goto yy95; + goto yy133; + } + } else { + if (yych <= '\\') { + if (yych <= 'Z') goto yy95; + if (yych <= '[') goto yy86; + goto yy120; + } else { + if (yych <= ']') goto yy86; + if (yych <= '~') goto yy95; + goto yy86; + } + } +yy139: + yych = *++cur; + if (yych <= '/') goto yy126; + if (yych <= '9') goto yy139; + goto yy126; +yy141: + yyaccept = 0; + yych = *(mrk = ++cur); + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy119; + if (yych == '\'') goto yy141; + goto yy95; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy119; + goto yy120; + } else { + if (yych <= ']') goto yy119; + if (yych <= '~') goto yy95; + goto yy119; + } + } +} +#line 1039 "p21sql.l" + + +eol: + tok = cur; + + +#line 1903 "p21sql.c" +{ + unsigned char yych; + yych = *cur; + if (yych >= 0x0001) goto yy147; + ++cur; +#line 1045 "p21sql.l" + { + return cur - sp; + } +#line 1913 "p21sql.c" +yy147: + ++cur; +#line 1048 "p21sql.l" + { + return -1; + } +#line 1920 "p21sql.c" +} +#line 1051 "p21sql.l" + + +} + + +/* +** Parse a complete P21 string. Return 0 on success or non-zero if there +** are any errors. If an error occurs, free all memory associated with +** pParse. +** +** pParse is uninitialized when this routine is called. +*/ +static int p21Parse( + P21Parse *pParse, /* Initialize and fill this P21Parse object */ + sqlite3_context *pCtx, /* Report errors here */ + const char *zP21 /* Input P21 text to be parsed */ +){ + int i; + memset(pParse, 0, sizeof(*pParse)); + if( zP21==0 ) return 1; + pParse->zP21 = zP21; + i = p21ParseValue(pParse, 0); + if( pParse->oom ) i = -1; + if( i>0 ){ + assert( pParse->iDepth==0 ); + } + if( i<=0 ){ + if( pCtx!=0 ){ + if( pParse->oom ){ + sqlite3_result_error_nomem(pCtx); + }else{ + sqlite3_result_error(pCtx, "malformed P21", -1); + } + } + p21ParseReset(pParse); + return 1; + } + return 0; +} + +/* Mark node i of pParse as being a child of iParent. Call recursively +** to fill in all the descendants of node i. +*/ +static void p21ParseFillInParentage(P21Parse *pParse, u32 i, u32 iParent){ + P21Node *pNode = &pParse->aNode[i]; + u32 j; + pParse->aUp[i] = iParent; + switch( pNode->eType ){ + case P21_RECORD: + case P21_LIST: { + for(j=1; j<=pNode->n; j += p21NodeSize(pNode+j)){ + p21ParseFillInParentage(pParse, i+j, i); + } + break; + } + default: { + break; + } + } +} + +/* +** Compute the parentage of all nodes in a completed parse. +*/ +static int p21ParseFindParents(P21Parse *pParse){ + u32 *aUp; + assert( pParse->aUp==0 ); + aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode ); + if( aUp==0 ){ + pParse->oom = 1; + return SQLITE_NOMEM; + } + p21ParseFillInParentage(pParse, 0, 0); + return SQLITE_OK; +} + +/* +** Magic number used for the P21 parse cache in sqlite3_get_auxdata() +*/ +#define P21_CACHE_ID (-429938) /* First cache entry */ +#define P21_CACHE_SZ 4 /* Max number of cache entries */ + +/* +** Obtain a complete parse of the P21 found in the first argument +** of the argv array. Use the sqlite3_get_auxdata() cache for this +** parse if it is available. If the cache is not available or if it +** is no longer valid, parse the P21 again and return the new parse, +** and also register the new parse so that it will be available for +** future sqlite3_get_auxdata() calls. +*/ +static P21Parse *p21ParseCached( + sqlite3_context *pCtx, + sqlite3_value **argv, + sqlite3_context *pErrCtx +){ + const char *zP21 = (const char*)sqlite3_value_text(argv[0]); + int nP21 = sqlite3_value_bytes(argv[0]); + P21Parse *p; + P21Parse *pMatch = 0; + int iKey; + int iMinKey = 0; + u32 iMinHold = 0xffffffff; + u32 iMaxHold = 0; + if( zP21==0 ) return 0; + for(iKey=0; iKeynP21==nP21 + && memcmp(p->zP21,zP21,nP21)==0 + ){ + p->nErr = 0; + pMatch = p; + }else if( p->iHoldiHold; + iMinKey = iKey; + } + if( p->iHold>iMaxHold ){ + iMaxHold = p->iHold; + } + } + if( pMatch ){ + pMatch->nErr = 0; + pMatch->iHold = iMaxHold+1; + return pMatch; + } + p = sqlite3_malloc64( sizeof(*p) + nP21 + 1 ); + if( p==0 ){ + sqlite3_result_error_nomem(pCtx); + return 0; + } + memset(p, 0, sizeof(*p)); + p->zP21 = (char*)&p[1]; + memcpy((char*)p->zP21, zP21, nP21+1); + if( p21Parse(p, pErrCtx, p->zP21) ){ + sqlite3_free(p); + return 0; + } + p->nP21 = nP21; + p->iHold = iMaxHold+1; + sqlite3_set_auxdata(pCtx, P21_CACHE_ID+iMinKey, p, + (void(*)(void*))p21ParseFree); + return (P21Parse*)sqlite3_get_auxdata(pCtx, P21_CACHE_ID+iMinKey); +} + +/* +** Compare the OBJECT label at pNode against zKey,nKey. Return true on +** a match. +*/ +static int p21LabelCompare(P21Node *pNode, const char *zKey, u32 nKey){ + if( pNode->jnFlags & PNODE_RAW ){ + if( pNode->n!=nKey ) return 0; + return strncmp(pNode->u.zJContent, zKey, nKey)==0; + }else{ + if( pNode->n!=nKey+2 ) return 0; + return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; + } +} + +/* forward declaration */ +static P21Node *p21LookupAppend(P21Parse*,const char*,int*,const char**); + +/* +** Search along zPath to find the node specified. Return a pointer +** to that node, or NULL if zPath is malformed or if there is no such +** node. +** +** If pApnd!=0, then try to append new nodes to complete zPath if it is +** possible to do so and if no existing node corresponds to zPath. If +** new nodes are appended *pApnd is set to 1. +*/ +static P21Node *p21LookupStep( + P21Parse *pParse, /* The P21 to search */ + u32 iRoot, /* Begin the search at this node */ + const char *zPath, /* The path to search */ + int *pApnd, /* Append nodes to complete path if not NULL */ + const char **pzErr /* Make *pzErr point to any syntax error in zPath */ +){ + u32 i, j, nKey; + const char *zKey; + P21Node *pRoot = &pParse->aNode[iRoot]; + if( zPath[0]==0 ) return pRoot; + if( pRoot->jnFlags & PNODE_REPLACE ) return 0; + if( zPath[0]=='.' ){ + if( pRoot->eType!=P21_RECORD ) return 0; + zPath++; + if( zPath[0]=='"' ){ + zKey = zPath + 1; + for(i=1; zPath[i] && zPath[i]!='"'; i++){} + nKey = i-1; + if( zPath[i] ){ + i++; + }else{ + *pzErr = zPath; + return 0; + } + }else{ + zKey = zPath; + for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} + nKey = i; + } + if( nKey==0 ){ + *pzErr = zPath; + return 0; + } + j = 1; + for(;;){ + while( j<=pRoot->n ){ + if( p21LabelCompare(pRoot+j, zKey, nKey) ){ + return p21LookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); + } + j++; + j += p21NodeSize(&pRoot[j]); + } + if( (pRoot->jnFlags & PNODE_APPEND)==0 ) break; + iRoot += pRoot->u.iAppend; + pRoot = &pParse->aNode[iRoot]; + j = 1; + } + if( pApnd ){ + u32 iStart, iLabel; + P21Node *pNode; + iStart = p21ParseAddNode(pParse, P21_RECORD, 2, 0); + iLabel = p21ParseAddNode(pParse, P21_STRING, nKey, zKey); + zPath += i; + pNode = p21LookupAppend(pParse, zPath, pApnd, pzErr); + if( pParse->oom ) return 0; + if( pNode ){ + pRoot = &pParse->aNode[iRoot]; + pRoot->u.iAppend = iStart - iRoot; + pRoot->jnFlags |= PNODE_APPEND; + pParse->aNode[iLabel].jnFlags |= PNODE_RAW; + } + return pNode; + } + }else if( zPath[0]=='[' ){ + i = 0; + j = 1; + while( safe_isdigit(zPath[j]) ){ + i = i*10 + zPath[j] - '0'; + j++; + } + if( j<2 || zPath[j]!=']' ){ + if( zPath[1]=='#' ){ + P21Node *pBase = pRoot; + int iBase = iRoot; + if( pRoot->eType!=P21_LIST && pRoot->eType!=P21_RECORD) return 0; + for(;;){ + while( j<=pBase->n ){ + if( (pBase[j].jnFlags & PNODE_REMOVE)==0 ) i++; + j += p21NodeSize(&pBase[j]); + } + if( (pBase->jnFlags & PNODE_APPEND)==0 ) break; + iBase += pBase->u.iAppend; + pBase = &pParse->aNode[iBase]; + j = 1; + } + j = 2; + if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){ + unsigned int x = 0; + j = 3; + do{ + x = x*10 + zPath[j] - '0'; + j++; + }while( safe_isdigit(zPath[j]) ); + if( x>i ) return 0; + i -= x; + } + if( zPath[j]!=']' ){ + *pzErr = zPath; + return 0; + } + }else{ + *pzErr = zPath; + return 0; + } + } + if( pRoot->eType!=P21_LIST && pRoot->eType!=P21_RECORD ) return 0; + zPath += j + 1; + j = 1; + for(;;){ + while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & PNODE_REMOVE)!=0) ){ + if( (pRoot[j].jnFlags & PNODE_REMOVE)==0 ) i--; + j += p21NodeSize(&pRoot[j]); + } + if( (pRoot->jnFlags & PNODE_APPEND)==0 ) break; + iRoot += pRoot->u.iAppend; + pRoot = &pParse->aNode[iRoot]; + j = 1; + } + if( j<=pRoot->n ){ + return p21LookupStep(pParse, iRoot+j, zPath, pApnd, pzErr); + } + if( i==0 && pApnd ){ + u32 iStart; + P21Node *pNode; + iStart = p21ParseAddNode(pParse, P21_LIST, 1, 0); + pNode = p21LookupAppend(pParse, zPath, pApnd, pzErr); + if( pParse->oom ) return 0; + if( pNode ){ + pRoot = &pParse->aNode[iRoot]; + pRoot->u.iAppend = iStart - iRoot; + pRoot->jnFlags |= PNODE_APPEND; + } + return pNode; + } + }else{ + *pzErr = zPath; + } + return 0; +} + +/* +** Append content to pParse that will complete zPath. Return a pointer +** to the inserted node, or return NULL if the append fails. +*/ +static P21Node *p21LookupAppend( + P21Parse *pParse, /* Append content to the P21 parse */ + const char *zPath, /* Description of content to append */ + int *pApnd, /* Set this flag to 1 */ + const char **pzErr /* Make this point to any syntax error */ +){ + *pApnd = 1; + if( zPath[0]==0 ){ + p21ParseAddNode(pParse, P21_EMPTY, 0, 0); + return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1]; + } + if( zPath[0]=='.' ){ + p21ParseAddNode(pParse, P21_RECORD, 0, 0); + }else if( strncmp(zPath,"[0]",3)==0 ){ + p21ParseAddNode(pParse, P21_LIST, 0, 0); + }else{ + return 0; + } + if( pParse->oom ) return 0; + return p21LookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr); +} + +/* +** Return the text of a syntax error message on a P21 path. Space is +** obtained from sqlite3_malloc(). +*/ +static char *p21PathSyntaxError(const char *zErr){ + return sqlite3_mprintf("P21 path error near '%q'", zErr); +} + +/* +** Do a node lookup using zPath. Return a pointer to the node on success. +** Return NULL if not found or if there is an error. +** +** On an error, write an error message into pCtx and increment the +** pParse->nErr counter. +** +** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if +** nodes are appended. +*/ +static P21Node *p21Lookup( + P21Parse *pParse, /* The P21 to search */ + const char *zPath, /* The path to search */ + int *pApnd, /* Append nodes to complete path if not NULL */ + sqlite3_context *pCtx /* Report errors here, if not NULL */ +){ + const char *zErr = 0; + P21Node *pNode = 0; + char *zMsg; + + if( zPath==0 ) return 0; + if( zPath[0]!='$' ){ + zErr = zPath; + goto lookup_err; + } + zPath++; + pNode = p21LookupStep(pParse, 0, zPath, pApnd, &zErr); + if( zErr==0 ) return pNode; + +lookup_err: + pParse->nErr++; + assert( zErr!=0 && pCtx!=0 ); + zMsg = p21PathSyntaxError(zErr); + if( zMsg ){ + sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_free(zMsg); + }else{ + sqlite3_result_error_nomem(pCtx); + } + return 0; +} + + +/* +** Report the wrong number of arguments for p21_insert(), p21_replace() +** or p21_set(). +*/ +static void p21WrongNumArgs( + sqlite3_context *pCtx, + const char *zFuncName +){ + char *zMsg = sqlite3_mprintf("p21_%s() needs an odd number of arguments", + zFuncName); + sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_free(zMsg); +} + +/* +** Mark all NULL entries in the Object passed in as PNODE_REMOVE. +*/ +static void p21RemoveAllNulls(P21Node *pNode){ + int i, n; + assert( pNode->eType==P21_RECORD ); + n = pNode->n; + for(i=2; i<=n; i += p21NodeSize(&pNode[i])+1){ + switch( pNode[i].eType ){ + case P21_EMPTY: + pNode[i].jnFlags |= PNODE_REMOVE; + break; + case P21_RECORD: + p21RemoveAllNulls(&pNode[i]); + break; + } + } +} + + +/**************************************************************************** +** SQL functions used for testing and debugging +****************************************************************************/ + +#ifdef SQLITE_DEBUG +/* +** The p21_parse(P21) function returns a string which describes +** a parse of the P21 provided. Or it returns NULL if P21 is not +** well-formed. +*/ +static void p21ParseFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String s; /* Output string - not real P21 */ + P21Parse x; /* The parse */ + u32 i; + + assert( argc==1 ); + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + p21ParseFindParents(&x); + p21Init(&s, ctx); + for(i=0; inNode ); + if( argc==2 ){ + const char *zPath = (const char*)sqlite3_value_text(argv[1]); + pNode = p21Lookup(p, zPath, 0, ctx); + }else{ + pNode = p->aNode; + } + if( pNode==0 ){ + return; + } + if( pNode->eType==P21_LIST ){ + assert( (pNode->jnFlags & PNODE_APPEND)==0 ); + for(i=1; i<=pNode->n; n++){ + i += p21NodeSize(&pNode[i]); + } + } + sqlite3_result_int64(ctx, n); +} + +/* +** p21_extract(P21, PATH, ...) +** +** Return the element described by PATH. Return NULL if there is no +** PATH element. If there are multiple PATHs, then return a P21 array +** with the result from each path. Throw an error if the P21 or any PATH +** is malformed. +*/ +static void p21ExtractFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + P21Node *pNode; + const char *zPath; + P21String jx; + int i; + + if( argc<2 ) return; + p = p21ParseCached(ctx, argv, ctx); + if( p==0 ) return; + p21Init(&jx, ctx); + p21AppendChar(&jx, '['); + for(i=1; inErr ) break; + if( argc>2 ){ + p21AppendSeparator(&jx); + if( pNode ){ + p21RenderNode(pNode, &jx, 0); + }else{ + p21AppendRaw(&jx, "null", 4); + } + }else if( pNode ){ + p21Return(pNode, ctx, 0); + } + } + if( argc>2 && i==argc ){ + p21AppendChar(&jx, ']'); + p21Result(&jx); + sqlite3_result_subtype(ctx, P21_SUBTYPE); + } + p21Reset(&jx); +} + +#if 0 +/* TODO: a MergeRecord function could be useful + */ +static P21Node *p21MergePatch( + P21Parse *pParse, /* The P21 parser that contains the TARGET */ + u32 iTarget, /* Node of the TARGET in pParse */ + P21Node *pPatch /* The PATCH */ +){ + u32 i, j; + u32 iRoot; + P21Node *pTarget; + if( pPatch->eType!=P21_RECORD ){ + return pPatch; + } + assert( iTargetnNode ); + pTarget = &pParse->aNode[iTarget]; + assert( (pPatch->jnFlags & PNODE_APPEND)==0 ); + if( pTarget->eType!=P21_RECORD ){ + p21RemoveAllNulls(pPatch); + return pPatch; + } + iRoot = iTarget; + for(i=1; in; i += p21NodeSize(&pPatch[i+1])+1){ + u32 nKey; + const char *zKey; + assert( pPatch[i].eType==P21_STRING ); + assert( pPatch[i].jnFlags & PNODE_LABEL ); + nKey = pPatch[i].n; + zKey = pPatch[i].u.zJContent; + assert( (pPatch[i].jnFlags & PNODE_RAW)==0 ); + for(j=1; jn; j += p21NodeSize(&pTarget[j+1])+1 ){ + assert( pTarget[j].eType==P21_STRING ); + assert( pTarget[j].jnFlags & PNODE_LABEL ); + assert( (pPatch[i].jnFlags & PNODE_RAW)==0 ); + if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){ + if( pTarget[j+1].jnFlags & (PNODE_REMOVE|PNODE_PATCH) ) break; + if( pPatch[i+1].eType==P21_EMPTY ){ + pTarget[j+1].jnFlags |= PNODE_REMOVE; + }else{ + P21Node *pNew = p21MergePatch(pParse, iTarget+j+1, &pPatch[i+1]); + if( pNew==0 ) return 0; + pTarget = &pParse->aNode[iTarget]; + if( pNew!=&pTarget[j+1] ){ + pTarget[j+1].u.pPatch = pNew; + pTarget[j+1].jnFlags |= PNODE_PATCH; + } + } + break; + } + } + if( j>=pTarget->n && pPatch[i+1].eType!=P21_EMPTY ){ + int iStart, iPatch; + iStart = p21ParseAddNode(pParse, P21_RECORD, 2, 0); + p21ParseAddNode(pParse, P21_STRING, nKey, zKey); + iPatch = p21ParseAddNode(pParse, P21_TRUE, 0, 0); + if( pParse->oom ) return 0; + p21RemoveAllNulls(pPatch); + pTarget = &pParse->aNode[iTarget]; + pParse->aNode[iRoot].jnFlags |= PNODE_APPEND; + pParse->aNode[iRoot].u.iAppend = iStart - iRoot; + iRoot = iStart; + pParse->aNode[iPatch].jnFlags |= PNODE_PATCH; + pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; + } + } + return pTarget; +} + + +/* +** Implementation of the json_mergepatch(JSON1,JSON2) function. Return a P21 +** object that is the result of running the RFC 7396 MergePatch() algorithm +** on the two arguments. +*/ +static void p21PatchFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The P21 that is being patched */ + P21Parse y; /* The patch */ + P21Node *pResult; /* The result of the merge */ + + UNUSED_PARAM(argc); + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + if( p21Parse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){ + p21ParseReset(&x); + return; + } + pResult = p21MergePatch(&x, 0, y.aNode); + assert( pResult!=0 || x.oom ); + if( pResult ){ + p21ReturnP21(pResult, ctx, 0); + }else{ + sqlite3_result_error_nomem(ctx); + } + p21ParseReset(&x); + p21ParseReset(&y); +} +#endif + +/* +** Implementation of the p21_object(NAME,VALUE,...) function. Return a P21 +** object that contains all name/value given in arguments. Or if any name +** is not a string or if any value is a BLOB, throw an error. +*/ +static void p21ObjectFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + int i; + P21String jx; + const char *z; + u32 n; + + if( argc&1 ){ + sqlite3_result_error(ctx, "p21_object() requires an even number " + "of arguments", -1); + return; + } + p21Init(&jx, ctx); + p21AppendChar(&jx, '{'); + for(i=0; ijnFlags |= PNODE_REMOVE; + } + if( (x.aNode[0].jnFlags & PNODE_REMOVE)==0 ){ + p21ReturnP21(x.aNode, ctx, 0); + } +remove_done: + p21ParseReset(&x); +} + +/* +** p21_replace(P21, PATH, VALUE, ...) +** +** Replace the value at PATH with VALUE. If PATH does not already exist, +** this routine is a no-op. If P21 or PATH is malformed, throw an error. +*/ +static void p21ReplaceFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The parse */ + P21Node *pNode; + const char *zPath; + u32 i; + + if( argc<1 ) return; + if( (argc&1)==0 ) { + p21WrongNumArgs(ctx, "replace"); + return; + } + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + assert( x.nNode ); + for(i=1; i<(u32)argc; i+=2){ + zPath = (const char*)sqlite3_value_text(argv[i]); + pNode = p21Lookup(&x, zPath, 0, ctx); + if( x.nErr ) goto replace_err; + if( pNode ){ + pNode->jnFlags |= (u8)PNODE_REPLACE; + pNode->u.iReplace = i + 1; + } + } + if( x.aNode[0].jnFlags & PNODE_REPLACE ){ + sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); + }else{ + p21ReturnP21(x.aNode, ctx, argv); + } +replace_err: + p21ParseReset(&x); +} + +/* +** p21_set(P21, PATH, VALUE, ...) +** +** Set the value at PATH to VALUE. Create the PATH if it does not already +** exist. Overwrite existing values that do exist. +** If P21 or PATH is malformed, throw an error. +** +** p21_insert(P21, PATH, VALUE, ...) +** +** Create PATH and initialize it to VALUE. If PATH already exists, this +** routine is a no-op. If P21 or PATH is malformed, throw an error. +*/ +static void p21SetFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The parse */ + P21Node *pNode; + const char *zPath; + u32 i; + int bApnd; + int bIsSet = *(int*)sqlite3_user_data(ctx); + + if( argc<1 ) return; + if( (argc&1)==0 ) { + p21WrongNumArgs(ctx, bIsSet ? "set" : "insert"); + return; + } + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + assert( x.nNode ); + for(i=1; i<(u32)argc; i+=2){ + zPath = (const char*)sqlite3_value_text(argv[i]); + bApnd = 0; + pNode = p21Lookup(&x, zPath, &bApnd, ctx); + if( x.oom ){ + sqlite3_result_error_nomem(ctx); + goto p21SetDone; + }else if( x.nErr ){ + goto p21SetDone; + }else if( pNode && (bApnd || bIsSet) ){ + pNode->jnFlags |= (u8)PNODE_REPLACE; + pNode->u.iReplace = i + 1; + } + } + if( x.aNode[0].jnFlags & PNODE_REPLACE ){ + sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); + }else{ + p21ReturnP21(x.aNode, ctx, argv); + } +p21SetDone: + p21ParseReset(&x); +} + +/* +** p21_type(P21) +** p21_type(P21, PATH) +** +** Return the top-level "type" of a P21 string. Throw an error if +** either the P21 or PATH inputs are not well-formed. +*/ +static void p21TypeFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + const char *zPath; + P21Node *pNode; + + p = p21ParseCached(ctx, argv, ctx); + if( p==0 ) return; + if( argc==2 ){ + zPath = (const char*)sqlite3_value_text(argv[1]); + pNode = p21Lookup(p, zPath, 0, ctx); + }else{ + pNode = p->aNode; + } + if( pNode ){ + sqlite3_result_text(ctx, p21Type[pNode->eType], -1, SQLITE_STATIC); + } +} + +/* +** p21_valid(P21) +** +** Return 1 if P21 is a well-formed P21 string according to RFC-7159. +** Return 0 otherwise. +*/ +static void p21ValidFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + UNUSED_PARAM(argc); + p = p21ParseCached(ctx, argv, 0); + sqlite3_result_int(ctx, p!=0); +} + + +/**************************************************************************** +** Aggregate SQL function implementations +****************************************************************************/ +/* +** p21_group_array(VALUE) +** +** Return a P21 array composed of all values in the aggregate. +*/ +static void p21ArrayStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String *pStr; + UNUSED_PARAM(argc); + pStr = (P21String*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + p21Init(pStr, ctx); + p21AppendChar(pStr, '['); + }else if( pStr->nUsed>1 ){ + p21AppendChar(pStr, ','); + pStr->pCtx = ctx; + } + p21AppendValue(pStr, argv[0]); + } +} +static void p21ArrayCompute(sqlite3_context *ctx, int isFinal){ + P21String *pStr; + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + pStr->pCtx = ctx; + p21AppendChar(pStr, ']'); + if( pStr->bErr ){ + if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); + assert( pStr->bStatic ); + }else if( isFinal ){ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + }else{ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); + pStr->nUsed--; + } + }else{ + sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, P21_SUBTYPE); +} +static void p21ArrayValue(sqlite3_context *ctx){ + p21ArrayCompute(ctx, 0); +} +static void p21ArrayFinal(sqlite3_context *ctx){ + p21ArrayCompute(ctx, 1); +} + +#ifndef SQLITE_OMIT_WINDOWFUNC +/* +** This method works for both p21_group_array() and p21_group_object(). +** It works by removing the first element of the group by searching forward +** to the first comma (",") that is not within a string and deleting all +** text through that comma. +*/ +static void p21GroupInverse( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + unsigned int i; + int inStr = 0; + int nNest = 0; + char *z; + char c; + P21String *pStr; + UNUSED_PARAM(argc); + UNUSED_PARAM(argv); + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); +#ifdef NEVER + /* pStr is always non-NULL since p21ArrayStep() or p21ObjectStep() will + ** always have been called to initalize it */ + if( NEVER(!pStr) ) return; +#endif + z = pStr->zBuf; + for(i=1; (c = z[i])!=',' || inStr || nNest; i++){ + if( i>=pStr->nUsed ){ + pStr->nUsed = 1; + return; + } + if( c=='"' ){ + inStr = !inStr; + }else if( c=='\\' ){ + i++; + }else if( !inStr ){ + if( c=='{' || c=='[' ) nNest++; + if( c=='}' || c==']' ) nNest--; + } + } + pStr->nUsed -= i; + memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); +} +#else +# define p21GroupInverse 0 +#endif + + +/* +** p21_group_obj(NAME,VALUE) +** +** Return a P21 object composed of all names and values in the aggregate. +*/ +static void p21ObjectStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String *pStr; + const char *z; + u32 n; + UNUSED_PARAM(argc); + pStr = (P21String*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + p21Init(pStr, ctx); + p21AppendChar(pStr, '{'); + }else if( pStr->nUsed>1 ){ + p21AppendChar(pStr, ','); + pStr->pCtx = ctx; + } + z = (const char*)sqlite3_value_text(argv[0]); + n = (u32)sqlite3_value_bytes(argv[0]); + p21AppendString(pStr, z, n); + p21AppendChar(pStr, ':'); + p21AppendValue(pStr, argv[1]); + } +} +static void p21ObjectCompute(sqlite3_context *ctx, int isFinal){ + P21String *pStr; + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + p21AppendChar(pStr, '}'); + if( pStr->bErr ){ + if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); + assert( pStr->bStatic ); + }else if( isFinal ){ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + }else{ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); + pStr->nUsed--; + } + }else{ + sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, P21_SUBTYPE); +} +static void p21ObjectValue(sqlite3_context *ctx){ + p21ObjectCompute(ctx, 0); +} +static void p21ObjectFinal(sqlite3_context *ctx){ + p21ObjectCompute(ctx, 1); +} + + + +#ifndef SQLITE_OMIT_VIRTUALTABLE +/**************************************************************************** +** The p21_each virtual table +****************************************************************************/ +typedef struct P21EachCursor P21EachCursor; +struct P21EachCursor { + sqlite3_vtab_cursor base; /* Base class - must be first */ + u32 iRowid; /* The rowid */ + u32 iBegin; /* The first node of the scan */ + u32 i; /* Index in sParse.aNode[] of current row */ + u32 iEnd; /* EOF when i equals or exceeds this value */ + u8 eType; /* Type of top-level element */ + char *zP21; /* Input P21 */ + char *zRoot; /* Path by which to filter zP21 */ + P21Parse sParse; /* Parse of the input P21 */ +}; + +/* Constructor for the p21_each virtual table */ +static int p21EachConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + sqlite3_vtab *pNew; + int rc; + +/* Column numbers */ +#define PEACH_KEY 0 +#define PEACH_VALUE 1 +#define PEACH_TYPE 2 +#define PEACH_ATOM 3 +#define PEACH_ID 4 +#define PEACH_PARENT 5 +#define PEACH_FULLKEY 6 +#define PEACH_PATH 7 +/* The xBestIndex method assumes that the P21 and ROOT columns are +** the last two columns in the table. Should this ever changes, be +** sure to update the xBestIndex method. */ +#define PEACH_P21 8 +#define PEACH_ROOT 9 + + UNUSED_PARAM(pzErr); + UNUSED_PARAM(argv); + UNUSED_PARAM(argc); + UNUSED_PARAM(pAux); + rc = sqlite3_declare_vtab(db, + "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path," + "p21 HIDDEN,root HIDDEN)"); + if( rc==SQLITE_OK ){ + pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); + } + return rc; +} + +/* destructor for p21_each virtual table */ +static int p21EachDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* constructor for a P21EachCursor object for p21_each(). */ +static int p21EachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + P21EachCursor *pCur; + + UNUSED_PARAM(p); + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* Reset a P21EachCursor back to its original state. Free any memory +** held. */ +static void p21EachCursorReset(P21EachCursor *p){ + sqlite3_free(p->zP21); + sqlite3_free(p->zRoot); + p21ParseReset(&p->sParse); + p->iRowid = 0; + p->i = 0; + p->iEnd = 0; + p->eType = 0; + p->zP21 = 0; + p->zRoot = 0; +} + +/* Destructor for a p21EachCursor object */ +static int p21EachClose(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + p21EachCursorReset(p); + sqlite3_free(cur); + return SQLITE_OK; +} + +/* Return TRUE if the p21EachCursor object has been advanced off the end +** of the P21 object */ +static int p21EachEof(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + return p->i >= p->iEnd; +} + +/* Advance the cursor to the next element for p21_tree() */ +static int p21EachNext(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + switch( p->eType ){ + case P21_RECORD: + case P21_LIST: { + p->i += p21NodeSize(&p->sParse.aNode[p->i]); + p->iRowid++; + break; + } + default: { + p->i = p->iEnd; + break; + } + } + return SQLITE_OK; +} + +/* Append the name of the path for element i to pStr +*/ +static void p21EachComputePath( + P21EachCursor *p, /* The cursor */ + P21String *pStr, /* Write the path here */ + u32 i /* Path to this element */ +){ + P21Node *pNode, *pUp; + u32 iUp; + if( i==0 ){ + p21AppendChar(pStr, '$'); + return; + } + iUp = p->sParse.aUp[i]; + p21EachComputePath(p, pStr, iUp); + pNode = &p->sParse.aNode[i]; + pUp = &p->sParse.aNode[iUp]; + if( pUp->eType==P21_LIST ){ + p21Printf(30, pStr, "[%d]", pUp->u.iKey); + }else{ + assert( pUp->eType==P21_RECORD ); + if( (pNode->jnFlags & PNODE_LABEL)==0 ) pNode--; + assert( pNode->eType==P21_STRING ); + assert( pNode->jnFlags & PNODE_LABEL ); + p21Printf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); + } +} + +/* Return the value of a column */ +static int p21EachColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + P21EachCursor *p = (P21EachCursor*)cur; + P21Node *pThis = &p->sParse.aNode[p->i]; + switch( i ){ + case PEACH_KEY: { + if( p->i==0 ) break; + if( p->eType==P21_RECORD ){ + p21Return(pThis, ctx, 0); + }else if( p->eType==P21_LIST ){ + u32 iKey; + iKey = p->iRowid; + sqlite3_result_int64(ctx, (sqlite3_int64)iKey); + } + break; + } + case PEACH_VALUE: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + p21Return(pThis, ctx, 0); + break; + } + case PEACH_TYPE: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + sqlite3_result_text(ctx, p21Type[pThis->eType], -1, SQLITE_STATIC); + break; + } + case PEACH_ATOM: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + if( pThis->eType>=P21_LIST ) break; + p21Return(pThis, ctx, 0); + break; + } + case PEACH_ID: { + sqlite3_result_int64(ctx, + (sqlite3_int64)p->i + ((pThis->jnFlags & PNODE_LABEL)!=0)); + break; + } + case PEACH_FULLKEY: { + P21String x; + p21Init(&x, ctx); + if( p->zRoot ){ + p21AppendRaw(&x, p->zRoot, (int)strlen(p->zRoot)); + }else{ + p21AppendChar(&x, '$'); + } + if( p->eType==P21_LIST ){ + p21Printf(30, &x, "[%d]", p->iRowid); + }else if( p->eType==P21_RECORD ){ + p21Printf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); + } + p21Result(&x); + break; + } + case PEACH_PATH: + default: { + const char *zRoot = p->zRoot; + if( zRoot==0 ) zRoot = "$"; + sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC); + break; + } + case PEACH_P21: { + assert( i==PEACH_P21 ); + sqlite3_result_text(ctx, p->sParse.zP21, -1, SQLITE_STATIC); + break; + } + } + return SQLITE_OK; +} + +/* Return the current rowid value */ +static int p21EachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + P21EachCursor *p = (P21EachCursor*)cur; + *pRowid = p->iRowid; + return SQLITE_OK; +} + +/* The query strategy is to look for an equality constraint on the p21 +** column. Without such a constraint, the table cannot operate. idxNum is +** 1 if the constraint is found, 3 if the constraint and zRoot are found, +** and 0 otherwise. +*/ +static int p21EachBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; /* Loop counter or computed array index */ + int aIdx[2]; /* Index of constraints for P21 and ROOT */ + int unusableMask = 0; /* Mask of unusable P21 and ROOT constraints */ + int idxMask = 0; /* Mask of usable == constraints P21 and ROOT */ + const struct sqlite3_index_constraint *pConstraint; + + /* This implementation assumes that P21 and ROOT are the last two + ** columns in the table */ + assert( PEACH_ROOT == PEACH_P21+1 ); + UNUSED_PARAM(tab); + aIdx[0] = aIdx[1] = -1; + pConstraint = pIdxInfo->aConstraint; + for(i=0; inConstraint; i++, pConstraint++){ + int iCol; + int iMask; + if( pConstraint->iColumn < PEACH_P21 ) continue; + iCol = pConstraint->iColumn - PEACH_P21; + assert( iCol==0 || iCol==1 ); + iMask = 1 << iCol; + if( pConstraint->usable==0 ){ + unusableMask |= iMask; + }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + aIdx[iCol] = i; + idxMask |= iMask; + } + } + if( (unusableMask & ~idxMask)!=0 ){ + /* If there are any unusable constraints on P21 or ROOT, then reject + ** this entire plan */ + return SQLITE_CONSTRAINT; + } + if( aIdx[0]<0 ){ + /* No P21 input. Leave estimatedCost at the huge value that it was + ** initialized to to discourage the query planner from selecting this + ** plan. */ + pIdxInfo->idxNum = 0; + }else{ + pIdxInfo->estimatedCost = 1.0; + i = aIdx[0]; + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + pIdxInfo->aConstraintUsage[i].omit = 1; + if( aIdx[1]<0 ){ + pIdxInfo->idxNum = 1; /* Only P21 supplied. Plan 1 */ + }else{ + i = aIdx[1]; + pIdxInfo->aConstraintUsage[i].argvIndex = 2; + pIdxInfo->aConstraintUsage[i].omit = 1; + pIdxInfo->idxNum = 3; /* Both P21 and ROOT are supplied. Plan 3 */ + } + } + return SQLITE_OK; +} + +/* Start a search on a new P21 string */ +static int p21EachFilter( + sqlite3_vtab_cursor *cur, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + P21EachCursor *p = (P21EachCursor*)cur; + const char *z; + const char *zRoot = 0; + sqlite3_int64 n; + + UNUSED_PARAM(idxStr); + UNUSED_PARAM(argc); + p21EachCursorReset(p); + if( idxNum==0 ) return SQLITE_OK; + z = (const char*)sqlite3_value_text(argv[0]); + if( z==0 ) return SQLITE_OK; + n = sqlite3_value_bytes(argv[0]); + p->zP21 = sqlite3_malloc64( n+1 ); + if( p->zP21==0 ) return SQLITE_NOMEM; + memcpy(p->zP21, z, (size_t)n+1); + if( p21Parse(&p->sParse, 0, p->zP21) ){ + int rc = SQLITE_NOMEM; + if( p->sParse.oom==0 ){ + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = sqlite3_mprintf("malformed P21"); + if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR; + } + p21EachCursorReset(p); + return rc; + }else{ + P21Node *pNode = 0; + if( idxNum==3 ){ + const char *zErr = 0; + zRoot = (const char*)sqlite3_value_text(argv[1]); + if( zRoot==0 ) return SQLITE_OK; + n = sqlite3_value_bytes(argv[1]); + p->zRoot = sqlite3_malloc64( n+1 ); + if( p->zRoot==0 ) return SQLITE_NOMEM; + memcpy(p->zRoot, zRoot, (size_t)n+1); + if( zRoot[0]!='$' ){ + zErr = zRoot; + }else{ + pNode = p21LookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr); + } + if( zErr ){ + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = p21PathSyntaxError(zErr); + p21EachCursorReset(p); + return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; + }else if( pNode==0 ){ + return SQLITE_OK; + } + }else{ + pNode = p->sParse.aNode; + } + p->iBegin = p->i = (int)(pNode - p->sParse.aNode); + p->eType = pNode->eType; + if( p->eType>=P21_LIST ){ + pNode->u.iKey = 0; + p->iEnd = p->i + pNode->n + 1; + p->i++; + }else{ + p->iEnd = p->i+1; + } + } + return SQLITE_OK; +} + +/* The methods of the p21_each virtual table */ +static sqlite3_module p21EachModule = { + 0, /* iVersion */ + 0, /* xCreate */ + p21EachConnect, /* xConnect */ + p21EachBestIndex, /* xBestIndex */ + p21EachDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + p21EachOpenEach, /* xOpen - open a cursor */ + p21EachClose, /* xClose - close a cursor */ + p21EachFilter, /* xFilter - configure scan constraints */ + p21EachNext, /* xNext - advance a cursor */ + p21EachEof, /* xEof - check for end of scan */ + p21EachColumn, /* xColumn - read data */ + p21EachRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ +}; + +#endif /* SQLITE_OMIT_VIRTUALTABLE */ + +/**************************************************************************** +** The following routines are the only publically visible identifiers in this +** file. Call the following routines in order to register the various SQL +** functions and the virtual table implemented by this file. +****************************************************************************/ + +int sqlite3P21sqlInit(sqlite3 *db){ + int rc = SQLITE_OK; + unsigned int i; + static const struct { + const char *zName; + int nArg; + int flag; + void (*xFunc)(sqlite3_context*,int,sqlite3_value**); + } aFunc[] = { + { "p21", 1, 0, p21RemoveFunc }, + { "p21_array", -1, 0, p21ArrayFunc }, + { "p21_array_length", 1, 0, p21ArrayLengthFunc }, + { "p21_array_length", 2, 0, p21ArrayLengthFunc }, + { "p21_extract", -1, 0, p21ExtractFunc }, + { "p21_insert", -1, 0, p21SetFunc }, + { "p21_object", -1, 0, p21ObjectFunc }, +#if 0 + { "p21_patch", 2, 0, p21PatchFunc }, +#endif + { "p21_quote", 1, 0, p21QuoteFunc }, + { "p21_remove", -1, 0, p21RemoveFunc }, + { "p21_replace", -1, 0, p21ReplaceFunc }, + { "p21_set", -1, 1, p21SetFunc }, + { "p21_type", 1, 0, p21TypeFunc }, + { "p21_type", 2, 0, p21TypeFunc }, + { "p21_valid", 1, 0, p21ValidFunc }, + +#if SQLITE_DEBUG + /* DEBUG and TESTING functions */ + { "p21_parse", 1, 0, p21ParseFunc }, + { "p21_test1", 1, 0, p21Test1Func }, +#endif + }; + static const struct { + const char *zName; + int nArg; + void (*xStep)(sqlite3_context*,int,sqlite3_value**); + void (*xFinal)(sqlite3_context*); + void (*xValue)(sqlite3_context*); + } aAgg[] = { + { "p21_group_array", 1, + p21ArrayStep, p21ArrayFinal, p21ArrayValue }, + { "p21_group_object", 2, + p21ObjectStep, p21ObjectFinal, p21ObjectValue }, + }; +#ifndef SQLITE_OMIT_VIRTUALTABLE + static const struct { + const char *zName; + sqlite3_module *pModule; + } aMod[] = { + { "p21_each", &p21EachModule }, + }; +#endif + static const int enc = + SQLITE_UTF8 | + SQLITE_DETERMINISTIC | + SQLITE_INNOCUOUS; + for(i=0; i +#include +#include +#include + +/* Mark a function parameter as unused, to suppress nuisance compiler +** warnings. */ +#ifndef UNUSED_PARAM +# define UNUSED_PARAM(X) (void)(X) +#endif + +#ifndef LARGEST_INT64 +# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#endif + +/* +** Versions of isspace(), isalnum() and isdigit() to which it is safe +** to pass signed char values. +*/ +#ifdef sqlite3Isdigit + /* Use the SQLite core versions if this routine is part of the + ** SQLite amalgamation */ +# define safe_isdigit(x) sqlite3Isdigit(x) +# define safe_isalnum(x) sqlite3Isalnum(x) +# define safe_isxdigit(x) sqlite3Isxdigit(x) +#else + /* Use the standard library for separate compilation */ +#include /* amalgamator: keep */ +# define safe_isdigit(x) isdigit((unsigned char)(x)) +# define safe_isalnum(x) isalnum((unsigned char)(x)) +# define safe_isxdigit(x) isxdigit((unsigned char)(x)) +#endif + +/* +** Growing our own isspace() routine this way is twice as fast as +** the library isspace() function, resulting in a 7% overall performance +** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). +*/ +static const char p21IsSpace[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#define safe_isspace(x) (p21IsSpace[(unsigned char)x]) + +#ifndef SQLITE_AMALGAMATION + /* Unsigned integer types. These are already defined in the sqliteInt.h, + ** but the definitions need to be repeated for separate compilation. */ + typedef sqlite3_uint64 u64; + typedef unsigned int u32; + typedef unsigned short int u16; + typedef unsigned char u8; +#endif + +/* some C implementations don't have these? (inttypes.h / stdint.h) */ +#ifndef UINT16_WIDTH +# define UINT16_WIDTH 16 +#endif +#ifndef UINT16_MAX +# define UINT16_MAX 65535 +#endif + +/* Objects */ +typedef struct P21String P21String; +typedef struct P21Node P21Node; +typedef struct P21Parse P21Parse; + +/* An instance of this object represents a P21 parameter string +** under construction. Really, this is a generic string accumulator +** that can be and is used to create strings other than JSON (here P21!). +*/ +struct P21String { + sqlite3_context *pCtx; /* Function context - put error messages here */ + char *zBuf; /* Append P21 content here */ + u64 nAlloc; /* Bytes of storage available in zBuf[] */ + u64 nUsed; /* Bytes of zBuf[] currently used */ + u8 bStatic; /* True if zBuf is static space */ + u8 bErr; /* True if an error has been encountered */ + char zSpace[100]; /* Initial static space */ +}; + +#define P21_EMPTY 0x1 /* optional attribute not provided : '$' */ +#define P21_DERIVED 0x2 /* derived attribute not provided : '*' */ +#define P21_ENUMERATION 0x3 /* (also) includes boolean and logical values */ +#define P21_INTEGER 0x4 +#define P21_REAL 0x5 +#define P21_STRING 0x6 +#define P21_BINARY 0x7 +#define P21_EID 0x8 /* entity_instance_name */ +#define P21_LIST 0x9 +#define P21_RECORD 0xA /* simple_record */ + +#define P21_SUBTYPE 80 /* Ascii for "P" */ + + +/* +** Names of the various P21 types: +*/ +static const char * const p21Type[] = { + "", + "empty", "derived", "enumeration", "integer", "real", + "string", "binary", "eid", "list", "record" +}; + +/* Bit values for the P21Node.jnFlag field +*/ +#define PNODE_RAW 0x01 /* Content is raw, not P21 encoded */ +#define PNODE_ESCAPE 0x02 /* Content is text with \ escapes */ +#define PNODE_REMOVE 0x04 /* Do not output */ +#define PNODE_REPLACE 0x08 /* Replace with P21Node.u.iReplace */ +#define PNODE_PATCH 0x10 /* Patch with P21Node.u.pPatch */ +#define PNODE_APPEND 0x20 /* More ARRAY/OBJECT entries at u.iAppend */ +#define PNODE_LABEL 0x40 /* Is a label of an object */ + + +/* A single node of parsed P21 params +*/ +struct P21Node { + u8 eType; /* One of the P21_ type values */ + u8 jnFlags; /* P21Node flags */ + u16 n_kw; /* store the KEYWORD length */ + u32 n; /* Bytes of content, or number of sub-nodes */ + union { + const char *zJContent; /* Content for INT, REAL, and STRING */ + u32 iAppend; /* More terms for ARRAY and OBJECT */ + u32 iKey; /* Key for ARRAY objects in p21_tree() */ + u32 iReplace; /* Replacement content for PNODE_REPLACE */ + P21Node *pPatch; /* Node chain of patch for PNODE_PATCH */ + } u; +}; + +/* A completely parsed P21 string +*/ +struct P21Parse { + u32 nNode; /* Number of slots of aNode[] used */ + u32 nAlloc; /* Number of slots of aNode[] allocated */ + P21Node *aNode; /* Array of nodes containing the parse */ + const char *zP21; /* Original P21 string */ + u32 *aUp; /* Index of parent of each node */ + u8 oom; /* Set to true if out of memory */ + u8 nErr; /* Number of errors seen */ + u16 iDepth; /* Nesting depth */ + int nP21; /* Length of the zP21 string in bytes */ + u32 iHold; /* Replace cache line with the lowest iHold value */ +}; + +/* +** Maximum nesting depth of P21 for this implementation. +*/ +#define P21_MAX_DEPTH 20 + +/************************************************************************** +** Utility routines for dealing with P21String objects +**************************************************************************/ + +/* Set the P21String object to an empty string +*/ +static void p21Zero(P21String *p){ + p->zBuf = p->zSpace; + p->nAlloc = sizeof(p->zSpace); + p->nUsed = 0; + p->bStatic = 1; +} + +/* Initialize the P21String object +*/ +static void p21Init(P21String *p, sqlite3_context *pCtx){ + p->pCtx = pCtx; + p->bErr = 0; + p21Zero(p); +} + + +/* Free all allocated memory and reset the P21String object back to its +** initial state. +*/ +static void p21Reset(P21String *p){ + if( !p->bStatic ) sqlite3_free(p->zBuf); + p21Zero(p); +} + + +/* Report an out-of-memory (OOM) condition +*/ +static void p21Oom(P21String *p){ + p->bErr = 1; + sqlite3_result_error_nomem(p->pCtx); + p21Reset(p); +} + +/* Enlarge p->zBuf so that it can hold at least N more bytes. +** Return zero on success. Return non-zero on an OOM error +*/ +static int p21Grow(P21String *p, u32 N){ + u64 nTotal = NnAlloc ? p->nAlloc*2 : p->nAlloc+N+10; + char *zNew; + if( p->bStatic ){ + if( p->bErr ) return 1; + zNew = sqlite3_malloc64(nTotal); + if( zNew==0 ){ + p21Oom(p); + return SQLITE_NOMEM; + } + memcpy(zNew, p->zBuf, (size_t)p->nUsed); + p->zBuf = zNew; + p->bStatic = 0; + }else{ + zNew = sqlite3_realloc64(p->zBuf, nTotal); + if( zNew==0 ){ + p21Oom(p); + return SQLITE_NOMEM; + } + p->zBuf = zNew; + } + p->nAlloc = nTotal; + return SQLITE_OK; +} + +/* Append N bytes from zIn onto the end of the P21String string. +*/ +static void p21AppendRaw(P21String *p, const char *zIn, u32 N){ + if( (N+p->nUsed >= p->nAlloc) && p21Grow(p,N)!=0 ) return; + memcpy(p->zBuf+p->nUsed, zIn, N); + p->nUsed += N; +} + +/* Append formatted text (not to exceed N bytes) to the P21String. +*/ +static void p21Printf(int N, P21String *p, const char *zFormat, ...){ + va_list ap; + if( (p->nUsed + N >= p->nAlloc) && p21Grow(p, N) ) return; + va_start(ap, zFormat); + sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap); + va_end(ap); + p->nUsed += (int)strlen(p->zBuf+p->nUsed); +} + +/* Append a single character +*/ +static void p21AppendChar(P21String *p, char c){ + if( p->nUsed>=p->nAlloc && p21Grow(p,1)!=0 ) return; + p->zBuf[p->nUsed++] = c; +} + +/* Append a comma separator to the output buffer, if the previous +** character is not '[' or '{'. +*/ +static void p21AppendSeparator(P21String *p){ + char c; + if( p->nUsed==0 ) return; + c = p->zBuf[p->nUsed-1]; + if( c!='(' ) p21AppendChar(p, ','); +} + +/* Append the N-byte string in zIn to the end of the P21String string +** under construction. Enclose the string in '...' and escape +** any double-quotes or backslash characters contained within the +** string. +*/ +static void p21AppendString(P21String *p, const char *zIn, u32 N){ + u32 i; + if( (N+p->nUsed+2 >= p->nAlloc) && p21Grow(p,N+2)!=0 ) return; + p->zBuf[p->nUsed++] = '\''; + for(i=0; inUsed+N+3-i > p->nAlloc) && p21Grow(p,N+3-i)!=0 ) return; + p->zBuf[p->nUsed++] = '\\'; + }else if( c<=0x1f ){ + static const char aSpecial[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + assert( sizeof(aSpecial)==32 ); + assert( aSpecial['\b']=='b' ); + assert( aSpecial['\f']=='f' ); + assert( aSpecial['\n']=='n' ); + assert( aSpecial['\r']=='r' ); + assert( aSpecial['\t']=='t' ); + if( aSpecial[c] ){ + c = aSpecial[c]; + goto p21_simple_escape; + } + if( (p->nUsed+N+7+i > p->nAlloc) && p21Grow(p,N+7-i)!=0 ) return; + p->zBuf[p->nUsed++] = '\\'; + p->zBuf[p->nUsed++] = 'u'; + p->zBuf[p->nUsed++] = '0'; + p->zBuf[p->nUsed++] = '0'; + p->zBuf[p->nUsed++] = '0' + (c>>4); + c = "0123456789abcdef"[c&0xf]; + } + p->zBuf[p->nUsed++] = c; + } + p->zBuf[p->nUsed++] = '\''; + assert( p->nUsednAlloc ); +} + +/* +** Append a function parameter value to the P21 string under +** construction. +*/ +static void p21AppendValue( + P21String *p, /* Append to this P21 string */ + sqlite3_value *pValue /* Value to append */ +){ + switch( sqlite3_value_type(pValue) ){ + case SQLITE_NULL: { + p21AppendRaw(p, "$", 1); + break; + } + case SQLITE_INTEGER: + case SQLITE_FLOAT: { + const char *z = (const char*)sqlite3_value_text(pValue); + /* TODO: confirm format is valid */ + u32 n = (u32)sqlite3_value_bytes(pValue); + p21AppendRaw(p, z, n); + break; + } + case SQLITE_TEXT: { + const char *z = (const char*)sqlite3_value_text(pValue); + u32 n = (u32)sqlite3_value_bytes(pValue); + if( sqlite3_value_subtype(pValue)==P21_SUBTYPE ){ + p21AppendRaw(p, z, n); + }else{ + p21AppendString(p, z, n); + } + break; + } + default: { + if( p->bErr==0 ){ + sqlite3_result_error(p->pCtx, "P21 cannot hold BLOB values", -1); + p->bErr = 2; + p21Reset(p); + } + break; + } + } +} + + +/* Make the P21 in p the result of the SQL function. +*/ +static void p21Result(P21String *p){ + if( p->bErr==0 ){ + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, + SQLITE_UTF8); + p21Zero(p); + } + assert( p->bStatic ); +} + +/************************************************************************** +** Utility routines for dealing with P21Node and P21Parse objects +**************************************************************************/ + +/* +** Return the number of consecutive P21Node slots need to represent +** the parsed P21 at pNode. The minimum answer is 1. For ARRAY and +** OBJECT types, the number might be larger. +** +** Appended elements are not counted. The value returned is the number +** by which the P21Node counter should increment in order to go to the +** next peer value. +*/ +static u32 p21NodeSize(P21Node *pNode){ + return pNode->eType < P21_LIST ? 1 : pNode->n + 1; +} + +/* +** Reclaim all memory allocated by a P21Parse object. But do not +** delete the P21Parse object itself. +*/ +static void p21ParseReset(P21Parse *pParse){ + sqlite3_free(pParse->aNode); + pParse->aNode = 0; + pParse->nNode = 0; + pParse->nAlloc = 0; + sqlite3_free(pParse->aUp); + pParse->aUp = 0; +} + +/* +** Free a P21Parse object that was obtained from sqlite3_malloc(). +*/ +static void p21ParseFree(P21Parse *pParse){ + p21ParseReset(pParse); + sqlite3_free(pParse); +} + +/* +** Convert the P21Node pNode into a pure P21 string and +** append to pOut. Subsubstructure is also included. Return +** the number of P21Node objects that are encoded. +*/ +static void p21RenderNode( + P21Node *pNode, /* The node to render */ + P21String *pOut, /* Write P21 here */ + sqlite3_value **aReplace /* Replacement values */ +){ + if( pNode->jnFlags & (PNODE_REPLACE|PNODE_PATCH) ){ + if( pNode->jnFlags & PNODE_REPLACE ){ + p21AppendValue(pOut, aReplace[pNode->u.iReplace]); + return; + } + pNode = pNode->u.pPatch; + } + switch( pNode->eType ){ + default: { + assert( pNode->eType==P21_EMPTY ); + p21AppendChar(pOut, '$'); + break; + } + case P21_ENUMERATION: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_DERIVED: { + p21AppendChar(pOut, '*'); + break; + } + case P21_BINARY: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_EID: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_STRING: { + if( pNode->jnFlags & PNODE_RAW ){ + p21AppendString(pOut, pNode->u.zJContent, pNode->n); + break; + } + /* Fall through into the next case */ + } + case P21_REAL: + case P21_INTEGER: { + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n); + break; + } + case P21_LIST: { + u32 j = 1; + p21AppendChar(pOut, '('); + for(;;){ + while( j<=pNode->n ){ + if( (pNode[j].jnFlags & PNODE_REMOVE)==0 ){ + p21AppendSeparator(pOut); + p21RenderNode(&pNode[j], pOut, aReplace); + } + j += p21NodeSize(&pNode[j]); + } + if( (pNode->jnFlags & PNODE_APPEND)==0 ) break; + pNode = &pNode[pNode->u.iAppend]; + j = 1; + } + p21AppendChar(pOut, ')'); + break; + } + case P21_RECORD: { + u32 j = 1; + p21AppendRaw(pOut, pNode->u.zJContent, pNode->n_kw); + p21AppendChar(pOut, '('); + for(;;){ + while( j<= pNode->n ){ + if( (pNode[j].jnFlags & PNODE_REMOVE)==0 ){ + p21AppendSeparator(pOut); + p21RenderNode(&pNode[j], pOut, aReplace); + } + j += p21NodeSize(&pNode[j]); + } + if( (pNode->jnFlags & PNODE_APPEND)==0 ) break; + pNode = &pNode[pNode->u.iAppend]; + j = 1; + } + p21AppendChar(pOut, ')'); + break; + } + } +} + +/* +** Return a P21Node and all its descendents as a P21 string. +*/ +static void p21ReturnP21( + P21Node *pNode, /* Node to return */ + sqlite3_context *pCtx, /* Return value for this function */ + sqlite3_value **aReplace /* Array of replacement values */ +){ + P21String s; + p21Init(&s, pCtx); + p21RenderNode(pNode, &s, aReplace); + p21Result(&s); + sqlite3_result_subtype(pCtx, P21_SUBTYPE); +} + +/* +** Translate a single byte of Hex into an integer. +** This routine only works if h really is a valid hexadecimal +** character: 0..9a..fA..F +*/ +static u8 p21HexToInt(int h){ + assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') ); +#ifdef SQLITE_EBCDIC + h += 9*(1&~(h>>4)); +#else + h += 9*(1&(h>>6)); +#endif + return (u8)(h & 0xf); +} + +/* +** Convert a 4-byte hex string into an integer +*/ +static u32 p21HexToInt4(const char *z){ + u32 v; + assert( safe_isxdigit(z[0]) ); + assert( safe_isxdigit(z[1]) ); + assert( safe_isxdigit(z[2]) ); + assert( safe_isxdigit(z[3]) ); + v = (p21HexToInt(z[0])<<12) + + (p21HexToInt(z[1])<<8) + + (p21HexToInt(z[2])<<4) + + p21HexToInt(z[3]); + return v; +} +/* +** Make the P21Node the return value of the function. +*/ +static void p21Return( + P21Node *pNode, /* Node to return */ + sqlite3_context *pCtx, /* Return value for this function */ + sqlite3_value **aReplace /* Array of replacement values */ +){ + switch( pNode->eType ){ + default: { + assert( pNode->eType==P21_EMPTY ); + sqlite3_result_null(pCtx); + break; + } + case P21_DERIVED: { + assert(0); + } + case P21_ENUMERATION: { + assert(0); + } + case P21_BINARY: { + assert(0); + } + case P21_EID: { + sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, SQLITE_TRANSIENT); + break; + } + case P21_INTEGER: { + sqlite3_int64 i = 0; + const char *z = pNode->u.zJContent; + if( z[0]=='-' ){ z++; } + while( z[0]>='0' && z[0]<='9' ){ + unsigned v = *(z++) - '0'; + if( i>=LARGEST_INT64/10 ){ + if( i>LARGEST_INT64/10 ) goto int_as_real; + if( z[0]>='0' && z[0]<='9' ) goto int_as_real; + if( v==9 ) goto int_as_real; + if( v==8 ){ + if( pNode->u.zJContent[0]=='-' ){ + sqlite3_result_int64(pCtx, SMALLEST_INT64); + goto int_done; + }else{ + goto int_as_real; + } + } + } + i = i*10 + v; + } + if( pNode->u.zJContent[0]=='-' ){ i = -i; } + sqlite3_result_int64(pCtx, i); + int_done: + break; + int_as_real: /* fall through to real */; + } + case P21_REAL: { + double r; +#ifdef SQLITE_AMALGAMATION + const char *z = pNode->u.zJContent; + sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); +#else + r = strtod(pNode->u.zJContent, 0); +#endif + sqlite3_result_double(pCtx, r); + break; + } + case P21_STRING: { +#if 0 /* Never happens because PNODE_RAW is only set by p21_set(), + ** p21_insert() and p21_replace() and those routines do not + ** call p21Return() */ + if( pNode->jnFlags & PNODE_RAW ){ + sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, + SQLITE_TRANSIENT); + }else +#endif + assert( (pNode->jnFlags & PNODE_RAW)==0 ); + if( (pNode->jnFlags & PNODE_ESCAPE)==0 ){ + /* P21 formatted without any backslash-escapes */ + sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, + SQLITE_TRANSIENT); + }else{ + /* Translate P21 formatted string into raw text */ + u32 i; + u32 n = pNode->n; + const char *z = pNode->u.zJContent; + char *zOut; + u32 j; + /* TODO: */ + assert(0); + zOut = sqlite3_malloc( n+1 ); + if( zOut==0 ){ + sqlite3_result_error_nomem(pCtx); + break; + } + for(i=1, j=0; i>6)); + zOut[j++] = 0x80 | (v&0x3f); + }else{ + u32 vlo; + if( (v&0xfc00)==0xd800 + && i>18); + zOut[j++] = 0x80 | ((v>>12)&0x3f); + zOut[j++] = 0x80 | ((v>>6)&0x3f); + zOut[j++] = 0x80 | (v&0x3f); + }else{ + zOut[j++] = 0xe0 | (v>>12); + zOut[j++] = 0x80 | ((v>>6)&0x3f); + zOut[j++] = 0x80 | (v&0x3f); + } + } + }else{ + if( c=='b' ){ + c = '\b'; + }else if( c=='f' ){ + c = '\f'; + }else if( c=='n' ){ + c = '\n'; + }else if( c=='r' ){ + c = '\r'; + }else if( c=='t' ){ + c = '\t'; + } + zOut[j++] = c; + } + } + } + zOut[j] = 0; + sqlite3_result_text(pCtx, zOut, j, sqlite3_free); + } + break; + } + case P21_LIST: + case P21_RECORD: { + p21ReturnP21(pNode, pCtx, aReplace); + break; + } + } +} + +/* Forward reference */ +static int p21ParseAddNode(P21Parse*,u32,u32,const char*); + +/* +** A macro to hint to the compiler that a function should not be +** inlined. +*/ +#if defined(__GNUC__) +# define P21_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) && _MSC_VER>=1310 +# define P21_NOINLINE __declspec(noinline) +#else +# define P21_NOINLINE +#endif + + +static P21_NOINLINE int p21ParseAddNodeExpand( + P21Parse *pParse, /* Append the node to this object */ + u32 eType, /* Node type */ + u32 n, /* Content size or sub-node count */ + const char *zContent /* Content */ +){ + u32 nNew; + P21Node *pNew; + assert( pParse->nNode>=pParse->nAlloc ); + if( pParse->oom ) return -1; + nNew = pParse->nAlloc*2 + 10; + pNew = sqlite3_realloc64(pParse->aNode, sizeof(P21Node)*nNew); + if( pNew==0 ){ + pParse->oom = 1; + return -1; + } + pParse->nAlloc = nNew; + pParse->aNode = pNew; + assert( pParse->nNodenAlloc ); + return p21ParseAddNode(pParse, eType, n, zContent); +} + +/* +** Create a new P21Node instance based on the arguments and append that +** instance to the P21Parse. Return the index in pParse->aNode[] of the +** new node, or -1 if a memory allocation fails. +*/ +static int p21ParseAddNode( + P21Parse *pParse, /* Append the node to this object */ + u32 eType, /* Node type */ + u32 n, /* Content size or sub-node count */ + const char *zContent /* Content */ +){ + P21Node *p; + if( pParse->nNode>=pParse->nAlloc ){ + return p21ParseAddNodeExpand(pParse, eType, n, zContent); + } + p = &pParse->aNode[pParse->nNode]; + p->eType = (u8)eType; + p->jnFlags = 0; + p->n = n; + p->u.zJContent = zContent; + return pParse->nNode++; +} + +/* +** Return true if z[] begins with 4 (or more) hexadecimal digits +*/ +static int p21Is4Hex(const char *z){ + int i; + for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0; + return 1; +} + +/* +** Parse P21 value which begins at pParse->zP21[i]. Return the +** index of the first character past the end of the value parsed. +** +** Return negative for a syntax error. +*/ +static int p21ParseValue(P21Parse *pParse, u32 i) { + static int cxtStack[P21_MAX_DEPTH]; + const unsigned char *sp, *cur, *mrk, *tok, *end; + /*!stags:re2c format = 'const unsigned char *@@;'; */ + int *piThis, x; + u32 n; + P21Node *pNode; + + sp = cur = tok = &pParse->zP21[i]; + piThis = cxtStack + pParse->iDepth; + +/*!re2c + re2c:yyfill:enable = 0; + re2c:flags:tags = 1; + re2c:define:YYCTYPE = 'unsigned char'; + re2c:define:YYCURSOR = 'cur'; + re2c:define:YYMARKER = 'mrk'; + + ascii_encoding = [][!"*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_ ] | "''" | "\\" ; + page_encoding = "\\" [A-I] "\\" | "\\S\\" [][!"'*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_\\ ] ; + hex_encoding = "\\X2\\" ([0-9A-F]{4})+ "\\X0\\" | "\\X4\\" ([0-9A-F]{8})+ "\\X0\\" ; + byte_encoding = "\\X\\" [0-9A-F]{2} ; + + WS = [ \t\r\n] ; + KEYWORD = "!"? [A-Za-z_] [0-9A-Za-z_]* ; + REAL = [+-]* [0-9] [0-9]* "." [0-9]* ("E" [+-]* [0-9] [0-9]*)? ; + INTEGER = [+-]* [0-9] [0-9]* ; + STRING = "'" (ascii_encoding | page_encoding | hex_encoding | byte_encoding )* "'" ; + BINARY = '"' [0-3] [0-9A-F]* '"' ; + ENUMERATION = "." [A-Z_] [A-Z0-9_]* "." ; + EID = "#" [0-9]+ ; + */ + +start: + + tok = cur; +/*!re2c + WS+ { + goto start; + } + "(" { + /* (complex_entity_instance) parameter_list */ + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto keywords; + } + "" { + /* (simple_entity_instance) parameter_list */ + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } + */ + +keywords: + tok = cur; + +/*!re2c + WS+ { + goto keywords; + } + KEYWORD @end WS* "(" { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } + ")" { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + assert(pNode->eType == P21_LIST); + + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto eol; + } + "" { + /* fix-up and revert to P21_RECORD */ + pNode = pParse->aNode + *(piThis - 1); + pNode->eType = P21_RECORD; + assert(pParse->iDepth == 1); + goto params1; + } + */ + +params1: + tok = cur; + +/*!re2c + WS+ { + goto params1; + } + KEYWORD @end WS* "(" { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } + "(" { + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params1; + } + "," { + goto params1; + } + REAL { + p21ParseAddNode(pParse, P21_REAL, cur - tok, tok); + goto params1; + } + INTEGER { + p21ParseAddNode(pParse, P21_INTEGER, cur - tok, tok); + goto params1; + } + STRING { + p21ParseAddNode(pParse, P21_STRING, cur - tok, tok); + goto params1; + } + BINARY { + p21ParseAddNode(pParse, P21_BINARY, cur - tok, tok); + goto params1; + } + ENUMERATION { + p21ParseAddNode(pParse, P21_ENUMERATION, cur - tok, tok); + goto params1; + } + EID { + p21ParseAddNode(pParse, P21_EID, cur - tok, tok); + goto params1; + } + "$" { + p21ParseAddNode(pParse, P21_EMPTY, cur - tok, tok); + goto params1; + } + "*" { + p21ParseAddNode(pParse, P21_DERIVED, cur - tok, tok); + goto params1; + } + ")" { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto params1; + } + "" { + if (pParse->iDepth) --pParse->iDepth; + piThis = cxtStack + pParse->iDepth; + pNode = pParse->aNode + *piThis; + assert(pNode->eType == P21_RECORD); + pNode->n = pParse->nNode - (u32)*piThis - 1; + goto eol; + } + */ + +params2: + tok = cur; + +/*!re2c + WS+ { + goto params2; + } + KEYWORD @end WS* "(" { + *piThis = p21ParseAddNode(pParse, P21_RECORD, 0, tok); + if (*piThis < 0) return -1; + pParse->aNode[*piThis].n_kw = (u16)(end - tok); + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } + "(" { + *piThis = p21ParseAddNode(pParse, P21_LIST, 0, 0); + if (*piThis < 0) return -1; + + if( ++pParse->iDepth > P21_MAX_DEPTH ) return -1; + piThis = cxtStack + pParse->iDepth; + goto params2; + } + "," { + goto params2; + } + REAL { + p21ParseAddNode(pParse, P21_REAL, cur - tok, tok); + goto params2; + } + INTEGER { + p21ParseAddNode(pParse, P21_INTEGER, cur - tok, tok); + goto params2; + } + STRING { + p21ParseAddNode(pParse, P21_STRING, cur - tok, tok); + goto params2; + } + BINARY { + p21ParseAddNode(pParse, P21_BINARY, cur - tok, tok); + goto params2; + } + ENUMERATION { + p21ParseAddNode(pParse, P21_ENUMERATION, cur - tok, tok); + goto params2; + } + EID { + p21ParseAddNode(pParse, P21_EID, cur - tok, tok); + goto params2; + } + "$" { + p21ParseAddNode(pParse, P21_EMPTY, cur - tok, tok); + goto params2; + } + "*" { + p21ParseAddNode(pParse, P21_DERIVED, cur - tok, tok); + goto params2; + } + ")" { + piThis = cxtStack + --pParse->iDepth; + pNode = pParse->aNode + *piThis; + pNode->n = pParse->nNode - (u32)*piThis - 1; + if (pParse->iDepth > 1) { + goto params2; + } else { + goto keywords; + } + } + /* continue to next block for error handling */ + */ + +eol: + tok = cur; + +/*!re2c + [\x00] { + return cur - sp; + } + * { + return -1; + } + */ + +} + + +/* +** Parse a complete P21 string. Return 0 on success or non-zero if there +** are any errors. If an error occurs, free all memory associated with +** pParse. +** +** pParse is uninitialized when this routine is called. +*/ +static int p21Parse( + P21Parse *pParse, /* Initialize and fill this P21Parse object */ + sqlite3_context *pCtx, /* Report errors here */ + const char *zP21 /* Input P21 text to be parsed */ +){ + int i; + memset(pParse, 0, sizeof(*pParse)); + if( zP21==0 ) return 1; + pParse->zP21 = zP21; + i = p21ParseValue(pParse, 0); + if( pParse->oom ) i = -1; + if( i>0 ){ + assert( pParse->iDepth==0 ); + } + if( i<=0 ){ + if( pCtx!=0 ){ + if( pParse->oom ){ + sqlite3_result_error_nomem(pCtx); + }else{ + sqlite3_result_error(pCtx, "malformed P21", -1); + } + } + p21ParseReset(pParse); + return 1; + } + return 0; +} + +/* Mark node i of pParse as being a child of iParent. Call recursively +** to fill in all the descendants of node i. +*/ +static void p21ParseFillInParentage(P21Parse *pParse, u32 i, u32 iParent){ + P21Node *pNode = &pParse->aNode[i]; + u32 j; + pParse->aUp[i] = iParent; + switch( pNode->eType ){ + case P21_RECORD: + case P21_LIST: { + for(j=1; j<=pNode->n; j += p21NodeSize(pNode+j)){ + p21ParseFillInParentage(pParse, i+j, i); + } + break; + } + default: { + break; + } + } +} + +/* +** Compute the parentage of all nodes in a completed parse. +*/ +static int p21ParseFindParents(P21Parse *pParse){ + u32 *aUp; + assert( pParse->aUp==0 ); + aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode ); + if( aUp==0 ){ + pParse->oom = 1; + return SQLITE_NOMEM; + } + p21ParseFillInParentage(pParse, 0, 0); + return SQLITE_OK; +} + +/* +** Magic number used for the P21 parse cache in sqlite3_get_auxdata() +*/ +#define P21_CACHE_ID (-429938) /* First cache entry */ +#define P21_CACHE_SZ 4 /* Max number of cache entries */ + +/* +** Obtain a complete parse of the P21 found in the first argument +** of the argv array. Use the sqlite3_get_auxdata() cache for this +** parse if it is available. If the cache is not available or if it +** is no longer valid, parse the P21 again and return the new parse, +** and also register the new parse so that it will be available for +** future sqlite3_get_auxdata() calls. +*/ +static P21Parse *p21ParseCached( + sqlite3_context *pCtx, + sqlite3_value **argv, + sqlite3_context *pErrCtx +){ + const char *zP21 = (const char*)sqlite3_value_text(argv[0]); + int nP21 = sqlite3_value_bytes(argv[0]); + P21Parse *p; + P21Parse *pMatch = 0; + int iKey; + int iMinKey = 0; + u32 iMinHold = 0xffffffff; + u32 iMaxHold = 0; + if( zP21==0 ) return 0; + for(iKey=0; iKeynP21==nP21 + && memcmp(p->zP21,zP21,nP21)==0 + ){ + p->nErr = 0; + pMatch = p; + }else if( p->iHoldiHold; + iMinKey = iKey; + } + if( p->iHold>iMaxHold ){ + iMaxHold = p->iHold; + } + } + if( pMatch ){ + pMatch->nErr = 0; + pMatch->iHold = iMaxHold+1; + return pMatch; + } + p = sqlite3_malloc64( sizeof(*p) + nP21 + 1 ); + if( p==0 ){ + sqlite3_result_error_nomem(pCtx); + return 0; + } + memset(p, 0, sizeof(*p)); + p->zP21 = (char*)&p[1]; + memcpy((char*)p->zP21, zP21, nP21+1); + if( p21Parse(p, pErrCtx, p->zP21) ){ + sqlite3_free(p); + return 0; + } + p->nP21 = nP21; + p->iHold = iMaxHold+1; + sqlite3_set_auxdata(pCtx, P21_CACHE_ID+iMinKey, p, + (void(*)(void*))p21ParseFree); + return (P21Parse*)sqlite3_get_auxdata(pCtx, P21_CACHE_ID+iMinKey); +} + +/* +** Compare the OBJECT label at pNode against zKey,nKey. Return true on +** a match. +*/ +static int p21LabelCompare(P21Node *pNode, const char *zKey, u32 nKey){ + if( pNode->jnFlags & PNODE_RAW ){ + if( pNode->n!=nKey ) return 0; + return strncmp(pNode->u.zJContent, zKey, nKey)==0; + }else{ + if( pNode->n!=nKey+2 ) return 0; + return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; + } +} + +/* forward declaration */ +static P21Node *p21LookupAppend(P21Parse*,const char*,int*,const char**); + +/* +** Search along zPath to find the node specified. Return a pointer +** to that node, or NULL if zPath is malformed or if there is no such +** node. +** +** If pApnd!=0, then try to append new nodes to complete zPath if it is +** possible to do so and if no existing node corresponds to zPath. If +** new nodes are appended *pApnd is set to 1. +*/ +static P21Node *p21LookupStep( + P21Parse *pParse, /* The P21 to search */ + u32 iRoot, /* Begin the search at this node */ + const char *zPath, /* The path to search */ + int *pApnd, /* Append nodes to complete path if not NULL */ + const char **pzErr /* Make *pzErr point to any syntax error in zPath */ +){ + u32 i, j, nKey; + const char *zKey; + P21Node *pRoot = &pParse->aNode[iRoot]; + if( zPath[0]==0 ) return pRoot; + if( pRoot->jnFlags & PNODE_REPLACE ) return 0; + if( zPath[0]=='.' ){ + if( pRoot->eType!=P21_RECORD ) return 0; + zPath++; + if( zPath[0]=='"' ){ + zKey = zPath + 1; + for(i=1; zPath[i] && zPath[i]!='"'; i++){} + nKey = i-1; + if( zPath[i] ){ + i++; + }else{ + *pzErr = zPath; + return 0; + } + }else{ + zKey = zPath; + for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} + nKey = i; + } + if( nKey==0 ){ + *pzErr = zPath; + return 0; + } + j = 1; + for(;;){ + while( j<=pRoot->n ){ + if( p21LabelCompare(pRoot+j, zKey, nKey) ){ + return p21LookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); + } + j++; + j += p21NodeSize(&pRoot[j]); + } + if( (pRoot->jnFlags & PNODE_APPEND)==0 ) break; + iRoot += pRoot->u.iAppend; + pRoot = &pParse->aNode[iRoot]; + j = 1; + } + if( pApnd ){ + u32 iStart, iLabel; + P21Node *pNode; + iStart = p21ParseAddNode(pParse, P21_RECORD, 2, 0); + iLabel = p21ParseAddNode(pParse, P21_STRING, nKey, zKey); + zPath += i; + pNode = p21LookupAppend(pParse, zPath, pApnd, pzErr); + if( pParse->oom ) return 0; + if( pNode ){ + pRoot = &pParse->aNode[iRoot]; + pRoot->u.iAppend = iStart - iRoot; + pRoot->jnFlags |= PNODE_APPEND; + pParse->aNode[iLabel].jnFlags |= PNODE_RAW; + } + return pNode; + } + }else if( zPath[0]=='[' ){ + i = 0; + j = 1; + while( safe_isdigit(zPath[j]) ){ + i = i*10 + zPath[j] - '0'; + j++; + } + if( j<2 || zPath[j]!=']' ){ + if( zPath[1]=='#' ){ + P21Node *pBase = pRoot; + int iBase = iRoot; + if( pRoot->eType!=P21_LIST && pRoot->eType!=P21_RECORD) return 0; + for(;;){ + while( j<=pBase->n ){ + if( (pBase[j].jnFlags & PNODE_REMOVE)==0 ) i++; + j += p21NodeSize(&pBase[j]); + } + if( (pBase->jnFlags & PNODE_APPEND)==0 ) break; + iBase += pBase->u.iAppend; + pBase = &pParse->aNode[iBase]; + j = 1; + } + j = 2; + if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){ + unsigned int x = 0; + j = 3; + do{ + x = x*10 + zPath[j] - '0'; + j++; + }while( safe_isdigit(zPath[j]) ); + if( x>i ) return 0; + i -= x; + } + if( zPath[j]!=']' ){ + *pzErr = zPath; + return 0; + } + }else{ + *pzErr = zPath; + return 0; + } + } + if( pRoot->eType!=P21_LIST && pRoot->eType!=P21_RECORD ) return 0; + zPath += j + 1; + j = 1; + for(;;){ + while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & PNODE_REMOVE)!=0) ){ + if( (pRoot[j].jnFlags & PNODE_REMOVE)==0 ) i--; + j += p21NodeSize(&pRoot[j]); + } + if( (pRoot->jnFlags & PNODE_APPEND)==0 ) break; + iRoot += pRoot->u.iAppend; + pRoot = &pParse->aNode[iRoot]; + j = 1; + } + if( j<=pRoot->n ){ + return p21LookupStep(pParse, iRoot+j, zPath, pApnd, pzErr); + } + if( i==0 && pApnd ){ + u32 iStart; + P21Node *pNode; + iStart = p21ParseAddNode(pParse, P21_LIST, 1, 0); + pNode = p21LookupAppend(pParse, zPath, pApnd, pzErr); + if( pParse->oom ) return 0; + if( pNode ){ + pRoot = &pParse->aNode[iRoot]; + pRoot->u.iAppend = iStart - iRoot; + pRoot->jnFlags |= PNODE_APPEND; + } + return pNode; + } + }else{ + *pzErr = zPath; + } + return 0; +} + +/* +** Append content to pParse that will complete zPath. Return a pointer +** to the inserted node, or return NULL if the append fails. +*/ +static P21Node *p21LookupAppend( + P21Parse *pParse, /* Append content to the P21 parse */ + const char *zPath, /* Description of content to append */ + int *pApnd, /* Set this flag to 1 */ + const char **pzErr /* Make this point to any syntax error */ +){ + *pApnd = 1; + if( zPath[0]==0 ){ + p21ParseAddNode(pParse, P21_EMPTY, 0, 0); + return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1]; + } + if( zPath[0]=='.' ){ + p21ParseAddNode(pParse, P21_RECORD, 0, 0); + }else if( strncmp(zPath,"[0]",3)==0 ){ + p21ParseAddNode(pParse, P21_LIST, 0, 0); + }else{ + return 0; + } + if( pParse->oom ) return 0; + return p21LookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr); +} + +/* +** Return the text of a syntax error message on a P21 path. Space is +** obtained from sqlite3_malloc(). +*/ +static char *p21PathSyntaxError(const char *zErr){ + return sqlite3_mprintf("P21 path error near '%q'", zErr); +} + +/* +** Do a node lookup using zPath. Return a pointer to the node on success. +** Return NULL if not found or if there is an error. +** +** On an error, write an error message into pCtx and increment the +** pParse->nErr counter. +** +** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if +** nodes are appended. +*/ +static P21Node *p21Lookup( + P21Parse *pParse, /* The P21 to search */ + const char *zPath, /* The path to search */ + int *pApnd, /* Append nodes to complete path if not NULL */ + sqlite3_context *pCtx /* Report errors here, if not NULL */ +){ + const char *zErr = 0; + P21Node *pNode = 0; + char *zMsg; + + if( zPath==0 ) return 0; + if( zPath[0]!='$' ){ + zErr = zPath; + goto lookup_err; + } + zPath++; + pNode = p21LookupStep(pParse, 0, zPath, pApnd, &zErr); + if( zErr==0 ) return pNode; + +lookup_err: + pParse->nErr++; + assert( zErr!=0 && pCtx!=0 ); + zMsg = p21PathSyntaxError(zErr); + if( zMsg ){ + sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_free(zMsg); + }else{ + sqlite3_result_error_nomem(pCtx); + } + return 0; +} + + +/* +** Report the wrong number of arguments for p21_insert(), p21_replace() +** or p21_set(). +*/ +static void p21WrongNumArgs( + sqlite3_context *pCtx, + const char *zFuncName +){ + char *zMsg = sqlite3_mprintf("p21_%s() needs an odd number of arguments", + zFuncName); + sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_free(zMsg); +} + +/* +** Mark all NULL entries in the Object passed in as PNODE_REMOVE. +*/ +static void p21RemoveAllNulls(P21Node *pNode){ + int i, n; + assert( pNode->eType==P21_RECORD ); + n = pNode->n; + for(i=2; i<=n; i += p21NodeSize(&pNode[i])+1){ + switch( pNode[i].eType ){ + case P21_EMPTY: + pNode[i].jnFlags |= PNODE_REMOVE; + break; + case P21_RECORD: + p21RemoveAllNulls(&pNode[i]); + break; + } + } +} + + +/**************************************************************************** +** SQL functions used for testing and debugging +****************************************************************************/ + +#ifdef SQLITE_DEBUG +/* +** The p21_parse(P21) function returns a string which describes +** a parse of the P21 provided. Or it returns NULL if P21 is not +** well-formed. +*/ +static void p21ParseFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String s; /* Output string - not real P21 */ + P21Parse x; /* The parse */ + u32 i; + + assert( argc==1 ); + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + p21ParseFindParents(&x); + p21Init(&s, ctx); + for(i=0; inNode ); + if( argc==2 ){ + const char *zPath = (const char*)sqlite3_value_text(argv[1]); + pNode = p21Lookup(p, zPath, 0, ctx); + }else{ + pNode = p->aNode; + } + if( pNode==0 ){ + return; + } + if( pNode->eType==P21_LIST ){ + assert( (pNode->jnFlags & PNODE_APPEND)==0 ); + for(i=1; i<=pNode->n; n++){ + i += p21NodeSize(&pNode[i]); + } + } + sqlite3_result_int64(ctx, n); +} + +/* +** p21_extract(P21, PATH, ...) +** +** Return the element described by PATH. Return NULL if there is no +** PATH element. If there are multiple PATHs, then return a P21 array +** with the result from each path. Throw an error if the P21 or any PATH +** is malformed. +*/ +static void p21ExtractFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + P21Node *pNode; + const char *zPath; + P21String jx; + int i; + + if( argc<2 ) return; + p = p21ParseCached(ctx, argv, ctx); + if( p==0 ) return; + p21Init(&jx, ctx); + p21AppendChar(&jx, '['); + for(i=1; inErr ) break; + if( argc>2 ){ + p21AppendSeparator(&jx); + if( pNode ){ + p21RenderNode(pNode, &jx, 0); + }else{ + p21AppendRaw(&jx, "null", 4); + } + }else if( pNode ){ + p21Return(pNode, ctx, 0); + } + } + if( argc>2 && i==argc ){ + p21AppendChar(&jx, ']'); + p21Result(&jx); + sqlite3_result_subtype(ctx, P21_SUBTYPE); + } + p21Reset(&jx); +} + +#if 0 +/* TODO: a MergeRecord function could be useful + */ +static P21Node *p21MergePatch( + P21Parse *pParse, /* The P21 parser that contains the TARGET */ + u32 iTarget, /* Node of the TARGET in pParse */ + P21Node *pPatch /* The PATCH */ +){ + u32 i, j; + u32 iRoot; + P21Node *pTarget; + if( pPatch->eType!=P21_RECORD ){ + return pPatch; + } + assert( iTargetnNode ); + pTarget = &pParse->aNode[iTarget]; + assert( (pPatch->jnFlags & PNODE_APPEND)==0 ); + if( pTarget->eType!=P21_RECORD ){ + p21RemoveAllNulls(pPatch); + return pPatch; + } + iRoot = iTarget; + for(i=1; in; i += p21NodeSize(&pPatch[i+1])+1){ + u32 nKey; + const char *zKey; + assert( pPatch[i].eType==P21_STRING ); + assert( pPatch[i].jnFlags & PNODE_LABEL ); + nKey = pPatch[i].n; + zKey = pPatch[i].u.zJContent; + assert( (pPatch[i].jnFlags & PNODE_RAW)==0 ); + for(j=1; jn; j += p21NodeSize(&pTarget[j+1])+1 ){ + assert( pTarget[j].eType==P21_STRING ); + assert( pTarget[j].jnFlags & PNODE_LABEL ); + assert( (pPatch[i].jnFlags & PNODE_RAW)==0 ); + if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){ + if( pTarget[j+1].jnFlags & (PNODE_REMOVE|PNODE_PATCH) ) break; + if( pPatch[i+1].eType==P21_EMPTY ){ + pTarget[j+1].jnFlags |= PNODE_REMOVE; + }else{ + P21Node *pNew = p21MergePatch(pParse, iTarget+j+1, &pPatch[i+1]); + if( pNew==0 ) return 0; + pTarget = &pParse->aNode[iTarget]; + if( pNew!=&pTarget[j+1] ){ + pTarget[j+1].u.pPatch = pNew; + pTarget[j+1].jnFlags |= PNODE_PATCH; + } + } + break; + } + } + if( j>=pTarget->n && pPatch[i+1].eType!=P21_EMPTY ){ + int iStart, iPatch; + iStart = p21ParseAddNode(pParse, P21_RECORD, 2, 0); + p21ParseAddNode(pParse, P21_STRING, nKey, zKey); + iPatch = p21ParseAddNode(pParse, P21_TRUE, 0, 0); + if( pParse->oom ) return 0; + p21RemoveAllNulls(pPatch); + pTarget = &pParse->aNode[iTarget]; + pParse->aNode[iRoot].jnFlags |= PNODE_APPEND; + pParse->aNode[iRoot].u.iAppend = iStart - iRoot; + iRoot = iStart; + pParse->aNode[iPatch].jnFlags |= PNODE_PATCH; + pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; + } + } + return pTarget; +} + + +/* +** Implementation of the json_mergepatch(JSON1,JSON2) function. Return a P21 +** object that is the result of running the RFC 7396 MergePatch() algorithm +** on the two arguments. +*/ +static void p21PatchFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The P21 that is being patched */ + P21Parse y; /* The patch */ + P21Node *pResult; /* The result of the merge */ + + UNUSED_PARAM(argc); + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + if( p21Parse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){ + p21ParseReset(&x); + return; + } + pResult = p21MergePatch(&x, 0, y.aNode); + assert( pResult!=0 || x.oom ); + if( pResult ){ + p21ReturnP21(pResult, ctx, 0); + }else{ + sqlite3_result_error_nomem(ctx); + } + p21ParseReset(&x); + p21ParseReset(&y); +} +#endif + +/* +** Implementation of the p21_object(NAME,VALUE,...) function. Return a P21 +** object that contains all name/value given in arguments. Or if any name +** is not a string or if any value is a BLOB, throw an error. +*/ +static void p21ObjectFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + int i; + P21String jx; + const char *z; + u32 n; + + if( argc&1 ){ + sqlite3_result_error(ctx, "p21_object() requires an even number " + "of arguments", -1); + return; + } + p21Init(&jx, ctx); + p21AppendChar(&jx, '{'); + for(i=0; ijnFlags |= PNODE_REMOVE; + } + if( (x.aNode[0].jnFlags & PNODE_REMOVE)==0 ){ + p21ReturnP21(x.aNode, ctx, 0); + } +remove_done: + p21ParseReset(&x); +} + +/* +** p21_replace(P21, PATH, VALUE, ...) +** +** Replace the value at PATH with VALUE. If PATH does not already exist, +** this routine is a no-op. If P21 or PATH is malformed, throw an error. +*/ +static void p21ReplaceFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The parse */ + P21Node *pNode; + const char *zPath; + u32 i; + + if( argc<1 ) return; + if( (argc&1)==0 ) { + p21WrongNumArgs(ctx, "replace"); + return; + } + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + assert( x.nNode ); + for(i=1; i<(u32)argc; i+=2){ + zPath = (const char*)sqlite3_value_text(argv[i]); + pNode = p21Lookup(&x, zPath, 0, ctx); + if( x.nErr ) goto replace_err; + if( pNode ){ + pNode->jnFlags |= (u8)PNODE_REPLACE; + pNode->u.iReplace = i + 1; + } + } + if( x.aNode[0].jnFlags & PNODE_REPLACE ){ + sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); + }else{ + p21ReturnP21(x.aNode, ctx, argv); + } +replace_err: + p21ParseReset(&x); +} + +/* +** p21_set(P21, PATH, VALUE, ...) +** +** Set the value at PATH to VALUE. Create the PATH if it does not already +** exist. Overwrite existing values that do exist. +** If P21 or PATH is malformed, throw an error. +** +** p21_insert(P21, PATH, VALUE, ...) +** +** Create PATH and initialize it to VALUE. If PATH already exists, this +** routine is a no-op. If P21 or PATH is malformed, throw an error. +*/ +static void p21SetFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse x; /* The parse */ + P21Node *pNode; + const char *zPath; + u32 i; + int bApnd; + int bIsSet = *(int*)sqlite3_user_data(ctx); + + if( argc<1 ) return; + if( (argc&1)==0 ) { + p21WrongNumArgs(ctx, bIsSet ? "set" : "insert"); + return; + } + if( p21Parse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + assert( x.nNode ); + for(i=1; i<(u32)argc; i+=2){ + zPath = (const char*)sqlite3_value_text(argv[i]); + bApnd = 0; + pNode = p21Lookup(&x, zPath, &bApnd, ctx); + if( x.oom ){ + sqlite3_result_error_nomem(ctx); + goto p21SetDone; + }else if( x.nErr ){ + goto p21SetDone; + }else if( pNode && (bApnd || bIsSet) ){ + pNode->jnFlags |= (u8)PNODE_REPLACE; + pNode->u.iReplace = i + 1; + } + } + if( x.aNode[0].jnFlags & PNODE_REPLACE ){ + sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); + }else{ + p21ReturnP21(x.aNode, ctx, argv); + } +p21SetDone: + p21ParseReset(&x); +} + +/* +** p21_type(P21) +** p21_type(P21, PATH) +** +** Return the top-level "type" of a P21 string. Throw an error if +** either the P21 or PATH inputs are not well-formed. +*/ +static void p21TypeFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + const char *zPath; + P21Node *pNode; + + p = p21ParseCached(ctx, argv, ctx); + if( p==0 ) return; + if( argc==2 ){ + zPath = (const char*)sqlite3_value_text(argv[1]); + pNode = p21Lookup(p, zPath, 0, ctx); + }else{ + pNode = p->aNode; + } + if( pNode ){ + sqlite3_result_text(ctx, p21Type[pNode->eType], -1, SQLITE_STATIC); + } +} + +/* +** p21_valid(P21) +** +** Return 1 if P21 is a well-formed P21 string according to RFC-7159. +** Return 0 otherwise. +*/ +static void p21ValidFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21Parse *p; /* The parse */ + UNUSED_PARAM(argc); + p = p21ParseCached(ctx, argv, 0); + sqlite3_result_int(ctx, p!=0); +} + + +/**************************************************************************** +** Aggregate SQL function implementations +****************************************************************************/ +/* +** p21_group_array(VALUE) +** +** Return a P21 array composed of all values in the aggregate. +*/ +static void p21ArrayStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String *pStr; + UNUSED_PARAM(argc); + pStr = (P21String*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + p21Init(pStr, ctx); + p21AppendChar(pStr, '['); + }else if( pStr->nUsed>1 ){ + p21AppendChar(pStr, ','); + pStr->pCtx = ctx; + } + p21AppendValue(pStr, argv[0]); + } +} +static void p21ArrayCompute(sqlite3_context *ctx, int isFinal){ + P21String *pStr; + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + pStr->pCtx = ctx; + p21AppendChar(pStr, ']'); + if( pStr->bErr ){ + if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); + assert( pStr->bStatic ); + }else if( isFinal ){ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + }else{ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); + pStr->nUsed--; + } + }else{ + sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, P21_SUBTYPE); +} +static void p21ArrayValue(sqlite3_context *ctx){ + p21ArrayCompute(ctx, 0); +} +static void p21ArrayFinal(sqlite3_context *ctx){ + p21ArrayCompute(ctx, 1); +} + +#ifndef SQLITE_OMIT_WINDOWFUNC +/* +** This method works for both p21_group_array() and p21_group_object(). +** It works by removing the first element of the group by searching forward +** to the first comma (",") that is not within a string and deleting all +** text through that comma. +*/ +static void p21GroupInverse( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + unsigned int i; + int inStr = 0; + int nNest = 0; + char *z; + char c; + P21String *pStr; + UNUSED_PARAM(argc); + UNUSED_PARAM(argv); + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); +#ifdef NEVER + /* pStr is always non-NULL since p21ArrayStep() or p21ObjectStep() will + ** always have been called to initalize it */ + if( NEVER(!pStr) ) return; +#endif + z = pStr->zBuf; + for(i=1; (c = z[i])!=',' || inStr || nNest; i++){ + if( i>=pStr->nUsed ){ + pStr->nUsed = 1; + return; + } + if( c=='"' ){ + inStr = !inStr; + }else if( c=='\\' ){ + i++; + }else if( !inStr ){ + if( c=='{' || c=='[' ) nNest++; + if( c=='}' || c==']' ) nNest--; + } + } + pStr->nUsed -= i; + memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); +} +#else +# define p21GroupInverse 0 +#endif + + +/* +** p21_group_obj(NAME,VALUE) +** +** Return a P21 object composed of all names and values in the aggregate. +*/ +static void p21ObjectStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + P21String *pStr; + const char *z; + u32 n; + UNUSED_PARAM(argc); + pStr = (P21String*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + p21Init(pStr, ctx); + p21AppendChar(pStr, '{'); + }else if( pStr->nUsed>1 ){ + p21AppendChar(pStr, ','); + pStr->pCtx = ctx; + } + z = (const char*)sqlite3_value_text(argv[0]); + n = (u32)sqlite3_value_bytes(argv[0]); + p21AppendString(pStr, z, n); + p21AppendChar(pStr, ':'); + p21AppendValue(pStr, argv[1]); + } +} +static void p21ObjectCompute(sqlite3_context *ctx, int isFinal){ + P21String *pStr; + pStr = (P21String*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + p21AppendChar(pStr, '}'); + if( pStr->bErr ){ + if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); + assert( pStr->bStatic ); + }else if( isFinal ){ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + }else{ + sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); + pStr->nUsed--; + } + }else{ + sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, P21_SUBTYPE); +} +static void p21ObjectValue(sqlite3_context *ctx){ + p21ObjectCompute(ctx, 0); +} +static void p21ObjectFinal(sqlite3_context *ctx){ + p21ObjectCompute(ctx, 1); +} + + + +#ifndef SQLITE_OMIT_VIRTUALTABLE +/**************************************************************************** +** The p21_each virtual table +****************************************************************************/ +typedef struct P21EachCursor P21EachCursor; +struct P21EachCursor { + sqlite3_vtab_cursor base; /* Base class - must be first */ + u32 iRowid; /* The rowid */ + u32 iBegin; /* The first node of the scan */ + u32 i; /* Index in sParse.aNode[] of current row */ + u32 iEnd; /* EOF when i equals or exceeds this value */ + u8 eType; /* Type of top-level element */ + char *zP21; /* Input P21 */ + char *zRoot; /* Path by which to filter zP21 */ + P21Parse sParse; /* Parse of the input P21 */ +}; + +/* Constructor for the p21_each virtual table */ +static int p21EachConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + sqlite3_vtab *pNew; + int rc; + +/* Column numbers */ +#define PEACH_KEY 0 +#define PEACH_VALUE 1 +#define PEACH_TYPE 2 +#define PEACH_ATOM 3 +#define PEACH_ID 4 +#define PEACH_PARENT 5 +#define PEACH_FULLKEY 6 +#define PEACH_PATH 7 +/* The xBestIndex method assumes that the P21 and ROOT columns are +** the last two columns in the table. Should this ever changes, be +** sure to update the xBestIndex method. */ +#define PEACH_P21 8 +#define PEACH_ROOT 9 + + UNUSED_PARAM(pzErr); + UNUSED_PARAM(argv); + UNUSED_PARAM(argc); + UNUSED_PARAM(pAux); + rc = sqlite3_declare_vtab(db, + "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path," + "p21 HIDDEN,root HIDDEN)"); + if( rc==SQLITE_OK ){ + pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); + } + return rc; +} + +/* destructor for p21_each virtual table */ +static int p21EachDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* constructor for a P21EachCursor object for p21_each(). */ +static int p21EachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + P21EachCursor *pCur; + + UNUSED_PARAM(p); + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* Reset a P21EachCursor back to its original state. Free any memory +** held. */ +static void p21EachCursorReset(P21EachCursor *p){ + sqlite3_free(p->zP21); + sqlite3_free(p->zRoot); + p21ParseReset(&p->sParse); + p->iRowid = 0; + p->i = 0; + p->iEnd = 0; + p->eType = 0; + p->zP21 = 0; + p->zRoot = 0; +} + +/* Destructor for a p21EachCursor object */ +static int p21EachClose(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + p21EachCursorReset(p); + sqlite3_free(cur); + return SQLITE_OK; +} + +/* Return TRUE if the p21EachCursor object has been advanced off the end +** of the P21 object */ +static int p21EachEof(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + return p->i >= p->iEnd; +} + +/* Advance the cursor to the next element for p21_tree() */ +static int p21EachNext(sqlite3_vtab_cursor *cur){ + P21EachCursor *p = (P21EachCursor*)cur; + switch( p->eType ){ + case P21_RECORD: + case P21_LIST: { + p->i += p21NodeSize(&p->sParse.aNode[p->i]); + p->iRowid++; + break; + } + default: { + p->i = p->iEnd; + break; + } + } + return SQLITE_OK; +} + +/* Append the name of the path for element i to pStr +*/ +static void p21EachComputePath( + P21EachCursor *p, /* The cursor */ + P21String *pStr, /* Write the path here */ + u32 i /* Path to this element */ +){ + P21Node *pNode, *pUp; + u32 iUp; + if( i==0 ){ + p21AppendChar(pStr, '$'); + return; + } + iUp = p->sParse.aUp[i]; + p21EachComputePath(p, pStr, iUp); + pNode = &p->sParse.aNode[i]; + pUp = &p->sParse.aNode[iUp]; + if( pUp->eType==P21_LIST ){ + p21Printf(30, pStr, "[%d]", pUp->u.iKey); + }else{ + assert( pUp->eType==P21_RECORD ); + if( (pNode->jnFlags & PNODE_LABEL)==0 ) pNode--; + assert( pNode->eType==P21_STRING ); + assert( pNode->jnFlags & PNODE_LABEL ); + p21Printf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); + } +} + +/* Return the value of a column */ +static int p21EachColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + P21EachCursor *p = (P21EachCursor*)cur; + P21Node *pThis = &p->sParse.aNode[p->i]; + switch( i ){ + case PEACH_KEY: { + if( p->i==0 ) break; + if( p->eType==P21_RECORD ){ + p21Return(pThis, ctx, 0); + }else if( p->eType==P21_LIST ){ + u32 iKey; + iKey = p->iRowid; + sqlite3_result_int64(ctx, (sqlite3_int64)iKey); + } + break; + } + case PEACH_VALUE: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + p21Return(pThis, ctx, 0); + break; + } + case PEACH_TYPE: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + sqlite3_result_text(ctx, p21Type[pThis->eType], -1, SQLITE_STATIC); + break; + } + case PEACH_ATOM: { + if( pThis->jnFlags & PNODE_LABEL ) pThis++; + if( pThis->eType>=P21_LIST ) break; + p21Return(pThis, ctx, 0); + break; + } + case PEACH_ID: { + sqlite3_result_int64(ctx, + (sqlite3_int64)p->i + ((pThis->jnFlags & PNODE_LABEL)!=0)); + break; + } + case PEACH_FULLKEY: { + P21String x; + p21Init(&x, ctx); + if( p->zRoot ){ + p21AppendRaw(&x, p->zRoot, (int)strlen(p->zRoot)); + }else{ + p21AppendChar(&x, '$'); + } + if( p->eType==P21_LIST ){ + p21Printf(30, &x, "[%d]", p->iRowid); + }else if( p->eType==P21_RECORD ){ + p21Printf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); + } + p21Result(&x); + break; + } + case PEACH_PATH: + default: { + const char *zRoot = p->zRoot; + if( zRoot==0 ) zRoot = "$"; + sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC); + break; + } + case PEACH_P21: { + assert( i==PEACH_P21 ); + sqlite3_result_text(ctx, p->sParse.zP21, -1, SQLITE_STATIC); + break; + } + } + return SQLITE_OK; +} + +/* Return the current rowid value */ +static int p21EachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + P21EachCursor *p = (P21EachCursor*)cur; + *pRowid = p->iRowid; + return SQLITE_OK; +} + +/* The query strategy is to look for an equality constraint on the p21 +** column. Without such a constraint, the table cannot operate. idxNum is +** 1 if the constraint is found, 3 if the constraint and zRoot are found, +** and 0 otherwise. +*/ +static int p21EachBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; /* Loop counter or computed array index */ + int aIdx[2]; /* Index of constraints for P21 and ROOT */ + int unusableMask = 0; /* Mask of unusable P21 and ROOT constraints */ + int idxMask = 0; /* Mask of usable == constraints P21 and ROOT */ + const struct sqlite3_index_constraint *pConstraint; + + /* This implementation assumes that P21 and ROOT are the last two + ** columns in the table */ + assert( PEACH_ROOT == PEACH_P21+1 ); + UNUSED_PARAM(tab); + aIdx[0] = aIdx[1] = -1; + pConstraint = pIdxInfo->aConstraint; + for(i=0; inConstraint; i++, pConstraint++){ + int iCol; + int iMask; + if( pConstraint->iColumn < PEACH_P21 ) continue; + iCol = pConstraint->iColumn - PEACH_P21; + assert( iCol==0 || iCol==1 ); + iMask = 1 << iCol; + if( pConstraint->usable==0 ){ + unusableMask |= iMask; + }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + aIdx[iCol] = i; + idxMask |= iMask; + } + } + if( (unusableMask & ~idxMask)!=0 ){ + /* If there are any unusable constraints on P21 or ROOT, then reject + ** this entire plan */ + return SQLITE_CONSTRAINT; + } + if( aIdx[0]<0 ){ + /* No P21 input. Leave estimatedCost at the huge value that it was + ** initialized to to discourage the query planner from selecting this + ** plan. */ + pIdxInfo->idxNum = 0; + }else{ + pIdxInfo->estimatedCost = 1.0; + i = aIdx[0]; + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + pIdxInfo->aConstraintUsage[i].omit = 1; + if( aIdx[1]<0 ){ + pIdxInfo->idxNum = 1; /* Only P21 supplied. Plan 1 */ + }else{ + i = aIdx[1]; + pIdxInfo->aConstraintUsage[i].argvIndex = 2; + pIdxInfo->aConstraintUsage[i].omit = 1; + pIdxInfo->idxNum = 3; /* Both P21 and ROOT are supplied. Plan 3 */ + } + } + return SQLITE_OK; +} + +/* Start a search on a new P21 string */ +static int p21EachFilter( + sqlite3_vtab_cursor *cur, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + P21EachCursor *p = (P21EachCursor*)cur; + const char *z; + const char *zRoot = 0; + sqlite3_int64 n; + + UNUSED_PARAM(idxStr); + UNUSED_PARAM(argc); + p21EachCursorReset(p); + if( idxNum==0 ) return SQLITE_OK; + z = (const char*)sqlite3_value_text(argv[0]); + if( z==0 ) return SQLITE_OK; + n = sqlite3_value_bytes(argv[0]); + p->zP21 = sqlite3_malloc64( n+1 ); + if( p->zP21==0 ) return SQLITE_NOMEM; + memcpy(p->zP21, z, (size_t)n+1); + if( p21Parse(&p->sParse, 0, p->zP21) ){ + int rc = SQLITE_NOMEM; + if( p->sParse.oom==0 ){ + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = sqlite3_mprintf("malformed P21"); + if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR; + } + p21EachCursorReset(p); + return rc; + }else{ + P21Node *pNode = 0; + if( idxNum==3 ){ + const char *zErr = 0; + zRoot = (const char*)sqlite3_value_text(argv[1]); + if( zRoot==0 ) return SQLITE_OK; + n = sqlite3_value_bytes(argv[1]); + p->zRoot = sqlite3_malloc64( n+1 ); + if( p->zRoot==0 ) return SQLITE_NOMEM; + memcpy(p->zRoot, zRoot, (size_t)n+1); + if( zRoot[0]!='$' ){ + zErr = zRoot; + }else{ + pNode = p21LookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr); + } + if( zErr ){ + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = p21PathSyntaxError(zErr); + p21EachCursorReset(p); + return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; + }else if( pNode==0 ){ + return SQLITE_OK; + } + }else{ + pNode = p->sParse.aNode; + } + p->iBegin = p->i = (int)(pNode - p->sParse.aNode); + p->eType = pNode->eType; + if( p->eType>=P21_LIST ){ + pNode->u.iKey = 0; + p->iEnd = p->i + pNode->n + 1; + p->i++; + }else{ + p->iEnd = p->i+1; + } + } + return SQLITE_OK; +} + +/* The methods of the p21_each virtual table */ +static sqlite3_module p21EachModule = { + 0, /* iVersion */ + 0, /* xCreate */ + p21EachConnect, /* xConnect */ + p21EachBestIndex, /* xBestIndex */ + p21EachDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + p21EachOpenEach, /* xOpen - open a cursor */ + p21EachClose, /* xClose - close a cursor */ + p21EachFilter, /* xFilter - configure scan constraints */ + p21EachNext, /* xNext - advance a cursor */ + p21EachEof, /* xEof - check for end of scan */ + p21EachColumn, /* xColumn - read data */ + p21EachRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ +}; + +#endif /* SQLITE_OMIT_VIRTUALTABLE */ + +/**************************************************************************** +** The following routines are the only publically visible identifiers in this +** file. Call the following routines in order to register the various SQL +** functions and the virtual table implemented by this file. +****************************************************************************/ + +int sqlite3P21sqlInit(sqlite3 *db){ + int rc = SQLITE_OK; + unsigned int i; + static const struct { + const char *zName; + int nArg; + int flag; + void (*xFunc)(sqlite3_context*,int,sqlite3_value**); + } aFunc[] = { + { "p21", 1, 0, p21RemoveFunc }, + { "p21_array", -1, 0, p21ArrayFunc }, + { "p21_array_length", 1, 0, p21ArrayLengthFunc }, + { "p21_array_length", 2, 0, p21ArrayLengthFunc }, + { "p21_extract", -1, 0, p21ExtractFunc }, + { "p21_insert", -1, 0, p21SetFunc }, + { "p21_object", -1, 0, p21ObjectFunc }, +#if 0 + { "p21_patch", 2, 0, p21PatchFunc }, +#endif + { "p21_quote", 1, 0, p21QuoteFunc }, + { "p21_remove", -1, 0, p21RemoveFunc }, + { "p21_replace", -1, 0, p21ReplaceFunc }, + { "p21_set", -1, 1, p21SetFunc }, + { "p21_type", 1, 0, p21TypeFunc }, + { "p21_type", 2, 0, p21TypeFunc }, + { "p21_valid", 1, 0, p21ValidFunc }, + +#if SQLITE_DEBUG + /* DEBUG and TESTING functions */ + { "p21_parse", 1, 0, p21ParseFunc }, + { "p21_test1", 1, 0, p21Test1Func }, +#endif + }; + static const struct { + const char *zName; + int nArg; + void (*xStep)(sqlite3_context*,int,sqlite3_value**); + void (*xFinal)(sqlite3_context*); + void (*xValue)(sqlite3_context*); + } aAgg[] = { + { "p21_group_array", 1, + p21ArrayStep, p21ArrayFinal, p21ArrayValue }, + { "p21_group_object", 2, + p21ObjectStep, p21ObjectFinal, p21ObjectValue }, + }; +#ifndef SQLITE_OMIT_VIRTUALTABLE + static const struct { + const char *zName; + sqlite3_module *pModule; + } aMod[] = { + { "p21_each", &p21EachModule }, + }; +#endif + static const int enc = + SQLITE_UTF8 | + SQLITE_DETERMINISTIC | + SQLITE_INNOCUOUS; + for(i=0; i Date: Fri, 24 Apr 2020 17:51:47 +0100 Subject: [PATCH 173/244] prototype re2c based LL(3) Part21 parser --- src/exp2python/python/SCL/_cPart21.c | 4694 ++++++++++++++++++++++++++ src/exp2python/python/SCL/_cPart21.l | 1602 +++++++++ 2 files changed, 6296 insertions(+) create mode 100644 src/exp2python/python/SCL/_cPart21.c create mode 100644 src/exp2python/python/SCL/_cPart21.l diff --git a/src/exp2python/python/SCL/_cPart21.c b/src/exp2python/python/SCL/_cPart21.c new file mode 100644 index 000000000..1bdcfa24a --- /dev/null +++ b/src/exp2python/python/SCL/_cPart21.c @@ -0,0 +1,4694 @@ +/* Generated by re2c 1.2.1 on Mon May 18 17:14:55 2020 */ +/* + * STEP Part 21 Parser + * + * Copyright (c) 2020, Christopher HORLER (cshorler@googlemail.com) + * + * All rights reserved. + * + * This file is part of the StepClassLibrary (SCL). + * + * 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. + * + * Neither the name of the nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define YYCTYPE unsigned char +#define YYCURSOR in->cur +#define YYLIMIT in->lim +#define YYMARKER in->mrk +#define YYCTXMARKER in->ctxmrk +#define YYFILL(n) do { \ + if (fill(in, n) != 0) { \ + fprintf(stderr, "lexer fill(...) failed, exiting\n"); \ + exit(1); \ + } \ + } while (0) + +#define YYMAXFILL 17 + +#define INIT_BUF_SZ 4096 +#define INIT_STACK_SZ 64 + +/* reserved literals '(' ')' ';' '=' */ +#define T_P21_START 'S' +#define T_P21_END 'X' +#define T_HEADER 'H' +#define T_DATA 'D' +#define T_ENDSEC 'E' +#define T_EID 'I' +#define T_KEYWORD 'K' +#define T_VARIANT 'V' +#define T_EOF '\x00' +#define T_ERROR '\x01' + +#define V_REAL 'r' +#define V_INTEGER 'i' +#define V_STRING 's' +#define V_BINARY 'b' +#define V_ENUMERATION 'e' +#define V_EID T_EID +#define V_DERIVED '*' +#define V_EMPTY '$' + +#define P_FILE 'f' +#define P_HEADERSECTION 'h' +#define P_DATASECTION 'd' +#define P_HEADERENTITY 'x' +#define P_SIMPLEENTITY 's' +#define P_COMPLEXENTITY 'c' +#define P_SIMPLERECORD 'u' +#define P_LIST 'l' +#define P_PARAMETER 'p' + +int debug = 1; +#define dprintf(fmt, ...) \ + do { if (debug) fprintf(stderr, "%s:%3d " fmt, __FILE__, __LINE__, ##__VA_ARGS__); } while (0) + +/* ppfu https://stackoverflow.com/a/11763277/1162349 */ +#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME +#define _EXPAND(x) x + +/* for lookahead */ +#define PUSH_SYMBOL(...) _EXPAND(GET_MACRO(__VA_ARGS__, _4, _3, _PUSH_SYMBOL2, _PUSH_SYMBOL1)(__VA_ARGS__)) +#define _PUSH_SYMBOL1(token) in->sym[in->nsym++] = (Symbol){(token), 0, n, in->lineno, in->sp - in->basemrk} +#define _PUSH_SYMBOL2(token, vtype) in->sym[in->nsym++] = (Symbol){(token), (vtype), n, in->lineno, in->sp - in->basemrk} + +/* for parse stack */ +#define PUSH_TERMINAL(stack, sym) do { \ + Symbol it = (sym); \ + push((stack), it); \ + if (it.token == T_ERROR) goto err; \ + } while (0) + +#define PUSH_TERMINAL_EXT(cxt, stack, sym) do { \ + Symbol it = (sym); \ + push((stack), it); \ + if (it.token == T_ERROR) goto err; \ + else if (it.token == '(') (cxt) = (stack)->idx_top - 1; \ + else if (it.token == ')') (stack)->items[(cxt)].n = (stack)->idx_top - (cxt) - 1; \ + } while (0) + +/* test for one in a set of 1 to 4 e.g. {t0, t1, t2, t3} */ +#define LOOKAHEAD(x, ...) _EXPAND(GET_MACRO(__VA_ARGS__, _LOOKAHEAD4, _LOOKAHEAD3, _LOOKAHEAD2, _LOOKAHEAD1)(x, __VA_ARGS__)) +#define _LOOKAHEAD1(x, t0) ((t0) == (x).token) +#define _LOOKAHEAD2(x, t0, t1) ((t0) == (x).token || (t1) == (x).token) +#define _LOOKAHEAD3(x, t0, t1, t2) (_LOOKAHEAD2(x, t0, t1) || (t2) == (x).token) +#define _LOOKAHEAD4(x, t0, t1, t2, t3) (_LOOKAHEAD2(x, t0, t1) || _LOOKAHEAD2(x, t2, t3)) + + + + + +/* lexeme */ +typedef struct { + uint8_t token; + union { + uint8_t vtype; + uint8_t errtoken; + }; + uint16_t n; + uint32_t lineno; + union { + ptrdiff_t offset; /* from basemrk */ + void *data; /* production allocation if applicable */ + }; +} Symbol; + +typedef struct SimpleRecord_ { + Symbol *kw; /* 'KEYWORD' */ + Symbol *args;/* '(' */ +} SimpleRecord; + +typedef struct SimpleRecord_ HeaderEntity; + +typedef struct { + Symbol *eid; /* '#' */ + Symbol *eq; /* '=' */ + Symbol *kw; /* 'KEYWORD' */ + Symbol *args;/* '(' */ +} SimpleEntity; + +typedef struct { + Symbol *eid; /* '#' */ + Symbol *eq; /* '=' */ + Symbol *subsupers;/* '(' */ +} ComplexEntity; + + +typedef struct { + FILE *file; + size_t bufsz; + unsigned char *cur, *mrk, *ctxmrk, *lim; + unsigned char *sp, *basemrk; + int eof; + uint32_t lineno; + int nsym; + Symbol sym[3]; + unsigned char *buf; +} Input; + +typedef struct { + int idx_top; + int idx_lim; + Symbol *items; +} Stack; + +/* LL(3) parser */ +typedef struct { + bool error; + bool hold; + Input *in; + Stack *stack; +} P21Parser; + +typedef void (p21_action_cb_t) (P21Parser *, int, void *); +typedef void (p21_error_cb_t) (P21Parser *, int, uint8_t); +typedef void (p21_ud_cb_t) (void *); + +typedef struct { + void *userdata; + p21_error_cb_t *error_cb; + p21_ud_cb_t *ud_init_cb; + p21_ud_cb_t *ud_exit_cb; + p21_action_cb_t *exchange_file_cb; + p21_action_cb_t *header_start_cb; + p21_action_cb_t *header_entity_list_cb; + p21_action_cb_t *data_section_list_cb; + p21_action_cb_t *data_start_cb; + p21_action_cb_t *header_entity_cb; + p21_action_cb_t *simple_entity_instance_cb; + p21_action_cb_t *complex_entity_instance_cb; + p21_action_cb_t *parameter_list_cb; + p21_action_cb_t *parameter_cb; + p21_action_cb_t *entity_instance_list_cb; + p21_action_cb_t *entity_instance_cb; + p21_action_cb_t *simple_record_list_cb; + p21_action_cb_t *simple_record_cb; +} P21ParserActions; + + +void report_error(P21Parser *, const char *); +void _recover(Input *, uint8_t, uint8_t, uint8_t); +Symbol lpop(Input *, uint8_t); + +void p21_parse(P21Parser *, P21ParserActions *); +void p21_exchange_file(P21Parser *, P21ParserActions *); +void p21_header_section(P21Parser *, P21ParserActions *); +void p21_header_entity_list(P21Parser *, P21ParserActions *); +void p21_header_entity(P21Parser *, P21ParserActions *); +void p21_data_section_list(P21Parser *, P21ParserActions *); +void p21_data_section(P21Parser *, P21ParserActions *); +void p21_entity_instance(P21Parser *, P21ParserActions *); +void p21_simple_entity_instance(P21Parser *, P21ParserActions *); +void p21_complex_entity_instance(P21Parser *, P21ParserActions *); +void p21_entity_instance_list(P21Parser *, P21ParserActions *); +void p21_parameter(P21Parser *, P21ParserActions *); +void p21_parameter_list(P21Parser *, P21ParserActions *); +void p21_simple_record(P21Parser *, P21ParserActions *); +void p21_simple_record_list(P21Parser *, P21ParserActions *); + + +void push(Stack *stack, Symbol it) { + if (stack->idx_top == stack->idx_lim) { + Symbol *nitems = realloc(stack->items, 2 * stack->idx_lim * sizeof stack->items[0]); + if (!nitems) { + fprintf(stderr, "failed to grow parser stack, memory exhausted\n"); + exit(1); + } + stack->items = nitems; + stack->idx_lim *= 2; + } + + stack->items[stack->idx_top++] = it; +} + +/* mock implementations */ +void drop(Stack *stack, uint32_t n) { + assert(stack->idx_top >= n); + stack->idx_top -= n; +} + +void unwind(Stack *stack, int bsp) { + stack->idx_top = bsp; +} + +Symbol *pop(Stack *stack) { + assert(stack->idx_top >= 1); + stack->idx_top--; + return stack->items + stack->idx_top; +} + +Symbol *peek(Stack *stack) { + assert(stack->idx_top >= 1); + return stack->items + stack->idx_top - 1; +} + +Symbol lpop(Input *in, uint8_t token) { + Symbol *stack = in->sym; + Symbol sym = stack[0]; + + /* missing input or unexpected lookahead token */ + if (in->nsym == 0) + return (Symbol){T_ERROR, token, 0, in->lineno}; + else if (sym.token != token) + return (Symbol){T_ERROR, token, 0, sym.lineno}; + + if (!--in->nsym) { + memset(&in->sym[0], 0, sizeof in->sym[0]); + } else { + memmove(&in->sym[0], &in->sym[1], in->nsym * sizeof in->sym[0]); + memset(&in->sym[in->nsym], 0, sizeof in->sym[0]); + } + + return sym; +} + +static int fill(Input *in, size_t need) +{ + size_t free; + unsigned char *newbuf; + + if (in->eof) { + return 1; + } + free = in->basemrk - in->buf; + if (free < need) { + newbuf = realloc(in->buf, 2 * in->bufsz + YYMAXFILL); + if (!newbuf) { + fprintf(stderr, "fatal - buffer memory exhausted, exiting\n"); + return 2; + } + in->bufsz *= 2; + in->lim = newbuf + (in->lim - in->buf); + in->cur = newbuf + (in->cur - in->buf); + in->mrk = newbuf + (in->mrk - in->buf); + in->ctxmrk = newbuf + (in->ctxmrk - in->buf); + in->basemrk = newbuf + (in->basemrk - in->buf); + in->sp = newbuf + (in->sp - in->buf); + in->buf = newbuf; + + /* don't memmove() here! */ + free = (in->buf + in->bufsz) - in->lim; + } else { + memmove(in->buf, in->basemrk, in->lim - in->basemrk); + in->lim -= free; + in->cur -= free; + in->mrk -= free; + in->ctxmrk -= free; + in->basemrk -= free; + in->sp -= free; + } + + in->lim += fread(in->lim, 1, free, in->file); + if (in->lim < in->buf + in->bufsz) { + in->eof = 1; + memset(in->lim, 0, YYMAXFILL); + in->lim += YYMAXFILL; + } + return 0; +} + +static void p21_init(P21Parser *p, FILE *file) +{ + Stack *stack; + Input *in; + + in = malloc(sizeof *in); + if (!in) + goto err; + memset(in, 0, sizeof *in); + in->bufsz = INIT_BUF_SZ; + in->buf = malloc(INIT_BUF_SZ + YYMAXFILL); + if (!in->buf) + goto err; + in->file = file; + in->cur = in->basemrk = in->sp = in->lim = in->buf + INIT_BUF_SZ; + in->lineno = 1; + fill(in, 1); + + stack = malloc(sizeof *stack); + if (!stack) + goto err; + memset(stack, 0, sizeof *stack); + stack->idx_lim = 16; + stack->idx_top = 0; + stack->items = malloc(stack->idx_lim * sizeof stack->items[0]); + if (!stack->items) + goto err; + + p->in = in; + p->stack = stack; + p->error = false; + + return; + +err: + fprintf(stderr, "failed to initialise parser\n"); + exit(1); +} + +/* noop error handler */ +void default_error_handler(P21Parser *p, int bsp, uint8_t t) { + Symbol *sym = peek(p->stack); + if (sym->token == T_ERROR) + pop(p->stack); + push(p->stack, (Symbol){t}); +} + +/* TODO: this needs to be reworked */ +void report_error(P21Parser *p, const char *cxt) { + Input *in = p->in; + Symbol *it = peek(p->stack); + int lineno; + unsigned char *cur; + + fprintf(stderr, cxt); + + if (it->token == T_ERROR) { + fprintf(stderr, " syntax error - line: %d\n", it->lineno); + fprintf(stderr, " expected '%c' (token type) ", it->errtoken); + } else { + cur = in->cur; + lineno = in->lineno; + while (1) { + if (*(cur - 2) == '\r' && *(cur - 1) == '\n') { cur -= 2; --lineno; } + else if (*(cur - 1) == '\n') { --cur; --lineno; } + else { break; } + } + fprintf(stderr, " syntax error - line: %d\n", lineno); + } + + if (!in->nsym) { + cur = in->cur; + lineno = in->lineno; + while (1) { + if (*cur == '\r' && *(cur + 1) == '\n') { cur -= 2; --lineno; } + else if (*cur == '\n') { --cur; --lineno; } + else { break; } + } + fprintf(stderr, " unexpected character '%c' (line: %d)\n", *cur, lineno); + } else { + fprintf(stderr, " got '%c' (token type)\n", in->sym[0].token); + } +} + + +void lex_comment(Input *in) { + size_t n; + int comment_lvl = 1; + + while (1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '*') { + if (yych <= '\r') { + if (yych == '\n') goto yy4; + if (yych >= '\r') goto yy6; + } else { + if (yych <= 0x001F) goto yy2; + if (yych <= ' ') goto yy7; + if (yych <= ')') goto yy10; + goto yy13; + } + } else { + if (yych <= '[') { + if (yych == '/') goto yy16; + if (yych <= 'Z') goto yy10; + } else { + if (yych == ']') goto yy2; + if (yych <= '~') goto yy10; + } + } +yy2: + ++YYCURSOR; +yy3: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy4: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy6: + yych = *++YYCURSOR; + if (yych == '\n') goto yy4; + goto yy3; +yy7: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych <= ')') { + if (yych <= 0x001F) goto yy9; + if (yych <= ' ') goto yy7; + goto yy10; + } else { + if (yych <= '*') goto yy9; + if (yych <= '.') goto yy10; + } + } else { + if (yych <= '\\') { + if (yych != '[') goto yy10; + } else { + if (yych <= ']') goto yy9; + if (yych <= '~') goto yy10; + } + } +yy9: + { n = in->cur - in->sp; } + { continue; } +yy10: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych <= ')') { + if (yych >= ' ') goto yy10; + } else { + if (yych <= '*') goto yy12; + if (yych <= '.') goto yy10; + } + } else { + if (yych <= '\\') { + if (yych != '[') goto yy10; + } else { + if (yych <= ']') goto yy12; + if (yych <= '~') goto yy10; + } + } +yy12: + { n = in->cur - in->sp; } + { continue; } +yy13: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '*') goto yy13; + if (yych == '/') goto yy18; + { n = in->cur - in->sp; } + { continue; } +yy16: + yych = *++YYCURSOR; + if (yych == '*') goto yy20; + { n = in->cur - in->sp; } + { continue; } +yy18: + ++YYCURSOR; + { n = in->cur - in->sp; } + { + if (!--comment_lvl) { break; } + else { continue; } + } +yy20: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + + return; + +err: + fprintf(stderr, "invalid character in comment, exiting\n"); + exit(1); +} + +#define recover(in, ...) GET_MACRO(__VA_ARGS__, _4, _RECOVER3, _RECOVER2, _RECOVER1)(in, __VA_ARGS__) +#define _RECOVER1(in, u0) _recover((in), (u0), 0U, 0U) +#define _RECOVER2(in, u0, u1) _recover((in), (u0), (u1), 0U) +#define _RECOVER3(in, u0, u1, u2) _recover((in), (u0), (u1), (u2)) + +void _recover(Input *in, uint8_t u0, uint8_t u1, uint8_t u2) { + size_t n; + Symbol sym; + + while (in->nsym) { + if (LOOKAHEAD(in->sym[0], u0, u1, u2, T_EOF)) + break; + --in->nsym; + memmove(&in->sym[0], &in->sym[1], in->nsym * sizeof in->sym[0]); + memset(&in->sym[in->nsym], 0, sizeof in->sym[0]); + } + + if (in->nsym) + return; + + while (1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + if ((YYLIMIT - YYCURSOR) < 17) YYFILL(17); + yych = *YYCURSOR; + if (yych <= '-') { + if (yych <= '"') { + if (yych <= '\r') { + if (yych == '\n') goto yy26; + if (yych >= '\r') goto yy28; + } else { + if (yych <= 0x001F) goto yy24; + if (yych <= ' ') goto yy29; + if (yych <= '!') goto yy32; + goto yy33; + } + } else { + if (yych <= '\'') { + if (yych <= '#') goto yy34; + if (yych <= '$') goto yy35; + if (yych >= '\'') goto yy37; + } else { + if (yych <= '*') { + if (yych <= ')') goto yy38; + goto yy40; + } else { + if (yych != ',') goto yy42; + } + } + } + } else { + if (yych <= 'E') { + if (yych <= ':') { + if (yych <= '.') goto yy43; + if (yych <= '/') goto yy44; + if (yych <= '9') goto yy45; + } else { + if (yych <= '@') { + if (yych <= ';') goto yy38; + } else { + if (yych <= 'C') goto yy48; + if (yych <= 'D') goto yy51; + goto yy52; + } + } + } else { + if (yych <= 'Z') { + if (yych <= 'G') goto yy48; + if (yych <= 'H') goto yy53; + if (yych <= 'I') goto yy54; + goto yy48; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy48; + } else { + if (yych <= '`') goto yy24; + if (yych <= 'z') goto yy48; + } + } + } + } +yy24: + ++YYCURSOR; +yy25: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy26: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy28: + yych = *++YYCURSOR; + if (yych == '\n') goto yy26; + goto yy25; +yy29: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy29; + { n = in->cur - in->sp; } + { continue; } +yy32: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy25; + if (yych <= 'Z') goto yy48; + goto yy25; + } else { + if (yych == '`') goto yy25; + if (yych <= 'z') goto yy48; + goto yy25; + } +yy33: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '/') goto yy25; + if (yych <= '3') goto yy55; + goto yy25; +yy34: + yych = *++YYCURSOR; + if (yych <= '/') goto yy25; + if (yych <= '9') goto yy58; + goto yy25; +yy35: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_EMPTY}; goto check; } +yy37: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '[') { + if (yych <= 0x001F) goto yy25; + if (yych <= 'Z') goto yy62; + goto yy25; + } else { + if (yych == ']') goto yy25; + if (yych <= '~') goto yy62; + goto yy25; + } +yy38: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){*in->sp}; goto check; } +yy40: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_DERIVED}; goto check; } +yy42: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= ',') { + if (yych == '+') goto yy66; + goto yy25; + } else { + if (yych <= '-') goto yy66; + if (yych <= '/') goto yy25; + if (yych <= '9') goto yy45; + goto yy25; + } +yy43: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') goto yy25; + if (yych <= 'Z') goto yy68; + if (yych == '_') goto yy68; + goto yy25; +yy44: + yych = *++YYCURSOR; + if (yych == '*') goto yy70; + goto yy25; +yy45: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '.') goto yy72; + if (yych <= '/') goto yy47; + if (yych <= '9') goto yy45; +yy47: + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_INTEGER}; goto check; } +yy48: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy49: + if (yych <= 'Z') { + if (yych <= '/') goto yy50; + if (yych <= '9') goto yy48; + if (yych >= 'A') goto yy48; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy48; + } else { + if (yych <= '`') goto yy50; + if (yych <= 'z') goto yy48; + } + } +yy50: + { n = in->cur - in->sp; } + { sym = (Symbol){T_KEYWORD}; goto check; } +yy51: + yych = *++YYCURSOR; + if (yych == 'A') goto yy75; + goto yy49; +yy52: + yych = *++YYCURSOR; + if (yych == 'N') goto yy76; + goto yy49; +yy53: + yych = *++YYCURSOR; + if (yych == 'E') goto yy77; + goto yy49; +yy54: + yych = *++YYCURSOR; + if (yych == 'S') goto yy78; + goto yy49; +yy55: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych == '"') goto yy79; + } else { + if (yych <= '9') goto yy55; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy55; + } +yy57: + YYCURSOR = YYMARKER; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy25; + } else { + goto yy64; + } + } else { + if (yyaccept == 2) { + goto yy74; + } else { + goto yy50; + } + } +yy58: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy60; + if (yych <= '9') goto yy58; +yy60: + { n = in->cur - in->sp; } + { sym = (Symbol){T_EID}; goto check; } +yy61: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy62: + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy57; + if (yych != '\'') goto yy61; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy57; + goto yy65; + } else { + if (yych <= ']') goto yy57; + if (yych <= '~') goto yy61; + goto yy57; + } + } + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\'') goto yy61; +yy64: + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_STRING}; goto check; } +yy65: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'S') { + if (yych <= '@') goto yy57; + if (yych <= 'I') goto yy81; + if (yych <= 'R') goto yy57; + goto yy82; + } else { + if (yych <= 'X') { + if (yych <= 'W') goto yy57; + goto yy83; + } else { + if (yych == '\\') goto yy61; + goto yy57; + } + } +yy66: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yy66; + goto yy57; + } else { + if (yych <= '-') goto yy66; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy45; + goto yy57; + } +yy68: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych == '.') goto yy84; + if (yych <= '/') goto yy57; + goto yy68; + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yy57; + goto yy68; + } else { + if (yych == '_') goto yy68; + goto yy57; + } + } +yy70: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy72: + yyaccept = 2; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy74; + if (yych <= '9') goto yy72; + if (yych == 'E') goto yy86; +yy74: + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_REAL}; goto check; } +yy75: + yych = *++YYCURSOR; + if (yych == 'T') goto yy88; + goto yy49; +yy76: + yych = *++YYCURSOR; + if (yych == 'D') goto yy89; + goto yy49; +yy77: + yych = *++YYCURSOR; + if (yych == 'A') goto yy90; + goto yy49; +yy78: + yych = *++YYCURSOR; + if (yych == 'O') goto yy91; + goto yy49; +yy79: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_BINARY}; goto check; } +yy81: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy61; + goto yy57; +yy82: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy92; + goto yy57; +yy83: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '3') { + if (yych == '2') goto yy93; + goto yy57; + } else { + if (yych <= '4') goto yy94; + if (yych == '\\') goto yy95; + goto yy57; + } +yy84: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_VARIANT, V_ENUMERATION}; goto check; } +yy86: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yy86; + goto yy57; + } else { + if (yych <= '-') goto yy86; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy96; + goto yy57; + } +yy88: + yych = *++YYCURSOR; + if (yych == 'A') goto yy98; + goto yy49; +yy89: + yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '-') goto yy99; + if (yych == 'S') goto yy100; + goto yy49; +yy90: + yych = *++YYCURSOR; + if (yych == 'D') goto yy101; + goto yy49; +yy91: + yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '-') goto yy102; + goto yy49; +yy92: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '[') { + if (yych <= 0x001F) goto yy57; + if (yych <= 'Z') goto yy61; + goto yy57; + } else { + if (yych == ']') goto yy57; + if (yych <= '~') goto yy61; + goto yy57; + } +yy93: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy103; + goto yy57; +yy94: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy104; + goto yy57; +yy95: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy105; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy105; + goto yy57; +yy96: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy74; + if (yych <= '9') goto yy96; + goto yy74; +yy98: + yych = *++YYCURSOR; + if (yych <= ')') { + if (yych == ' ') goto yy106; + if (yych <= '\'') goto yy49; + goto yy106; + } else { + if (yych <= '/') { + if (yych <= '.') goto yy49; + goto yy106; + } else { + if (yych == ';') goto yy106; + goto yy49; + } + } +yy99: + yych = *++YYCURSOR; + if (yych == 'I') goto yy108; + goto yy57; +yy100: + yych = *++YYCURSOR; + if (yych == 'E') goto yy109; + goto yy49; +yy101: + yych = *++YYCURSOR; + if (yych == 'E') goto yy110; + goto yy49; +yy102: + yych = *++YYCURSOR; + if (yych == '1') goto yy111; + goto yy57; +yy103: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy112; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy112; + goto yy57; +yy104: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy113; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy113; + goto yy57; +yy105: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy61; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy61; + goto yy57; +yy106: + ++YYCURSOR; + YYCURSOR -= 1; + { n = in->cur - in->sp; } + { sym = (Symbol){T_DATA}; goto check; } +yy108: + yych = *++YYCURSOR; + if (yych == 'S') goto yy114; + goto yy57; +yy109: + yych = *++YYCURSOR; + if (yych == 'C') goto yy115; + goto yy49; +yy110: + yych = *++YYCURSOR; + if (yych == 'R') goto yy116; + goto yy49; +yy111: + yych = *++YYCURSOR; + if (yych == '0') goto yy117; + goto yy57; +yy112: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy118; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy118; + goto yy57; +yy113: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy119; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy119; + goto yy57; +yy114: + yych = *++YYCURSOR; + if (yych == 'O') goto yy120; + goto yy57; +yy115: + yych = *++YYCURSOR; + if (yych == ';') goto yy121; + goto yy49; +yy116: + yych = *++YYCURSOR; + if (yych == ';') goto yy123; + goto yy49; +yy117: + yych = *++YYCURSOR; + if (yych == '3') goto yy125; + goto yy57; +yy118: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy126; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy126; + goto yy57; +yy119: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy127; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy127; + goto yy57; +yy120: + yych = *++YYCURSOR; + if (yych == '-') goto yy128; + goto yy57; +yy121: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_ENDSEC}; goto check; } +yy123: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_HEADER}; goto check; } +yy125: + yych = *++YYCURSOR; + if (yych == '0') goto yy129; + goto yy57; +yy126: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy130; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy130; + goto yy57; +yy127: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy131; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy131; + goto yy57; +yy128: + yych = *++YYCURSOR; + if (yych == '1') goto yy132; + goto yy57; +yy129: + yych = *++YYCURSOR; + if (yych == '3') goto yy133; + goto yy57; +yy130: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy112; + goto yy57; + } else { + if (yych <= 'F') goto yy112; + if (yych == '\\') goto yy134; + goto yy57; + } +yy131: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy135; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy135; + goto yy57; +yy132: + yych = *++YYCURSOR; + if (yych == '0') goto yy136; + goto yy57; +yy133: + yych = *++YYCURSOR; + if (yych == '-') goto yy137; + goto yy57; +yy134: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == 'X') goto yy138; + goto yy57; +yy135: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy139; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy139; + goto yy57; +yy136: + yych = *++YYCURSOR; + if (yych == '3') goto yy140; + goto yy57; +yy137: + yych = *++YYCURSOR; + if (yych == '2') goto yy141; + goto yy57; +yy138: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '0') goto yy81; + goto yy57; +yy139: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy142; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy142; + goto yy57; +yy140: + yych = *++YYCURSOR; + if (yych == '0') goto yy143; + goto yy57; +yy141: + yych = *++YYCURSOR; + if (yych == '1') goto yy144; + goto yy57; +yy142: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy145; + if (yych <= '@') goto yy57; + if (yych <= 'F') goto yy145; + goto yy57; +yy143: + yych = *++YYCURSOR; + if (yych == '3') goto yy146; + goto yy57; +yy144: + yych = *++YYCURSOR; + if (yych == ';') goto yy147; + goto yy57; +yy145: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy57; + if (yych <= '9') goto yy113; + goto yy57; + } else { + if (yych <= 'F') goto yy113; + if (yych == '\\') goto yy134; + goto yy57; + } +yy146: + yych = *++YYCURSOR; + if (yych == '-') goto yy149; + goto yy57; +yy147: + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_P21_START}; goto check; } +yy149: + yych = *++YYCURSOR; + if (yych != '2') goto yy57; + yych = *++YYCURSOR; + if (yych != '1') goto yy57; + yych = *++YYCURSOR; + if (yych != ';') goto yy57; + ++YYCURSOR; + { n = in->cur - in->sp; } + { sym = (Symbol){T_P21_END}; goto check; } +} + +check: + if (LOOKAHEAD(sym, u0, u1, u2, T_EOF)) { + PUSH_SYMBOL(sym.token, sym.vtype); + break; + } + } + + return; + +err: + fprintf(stderr, "fatal, failed to resolve follow set (%c, %c, %c)\n", u0, u1, u2); + exit(1); +} + + +/* + * P21Parser + */ +void p21_parse(P21Parser *p, P21ParserActions *act) { + if (act->ud_init_cb) + act->ud_init_cb(act->userdata); + + p21_exchange_file(p, act); + + if (act->ud_exit_cb) + act->ud_exit_cb(act->userdata); + + assert(p->stack->idx_top == 1); + return; + +err: + report_error(p, "exchange_file' << 0 >>\n"); +} + +void p21_exchange_file(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 13) YYFILL(13); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yy158; + } else { + if (yych == '\r') goto yy160; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yy161; + if (yych >= '/') goto yy164; + } else { + if (yych == 'I') goto yy165; + } + } + ++YYCURSOR; +yy157: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy158: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy160: + yych = *++YYCURSOR; + if (yych == '\n') goto yy158; + goto yy157; +yy161: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy161; + { n = in->cur - in->sp; } + { continue; } +yy164: + yych = *++YYCURSOR; + if (yych == '*') goto yy166; + goto yy157; +yy165: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'S') goto yy168; + goto yy157; +yy166: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy168: + yych = *++YYCURSOR; + if (yych == 'O') goto yy170; +yy169: + YYCURSOR = YYMARKER; + goto yy157; +yy170: + yych = *++YYCURSOR; + if (yych != '-') goto yy169; + yych = *++YYCURSOR; + if (yych != '1') goto yy169; + yych = *++YYCURSOR; + if (yych != '0') goto yy169; + yych = *++YYCURSOR; + if (yych != '3') goto yy169; + yych = *++YYCURSOR; + if (yych != '0') goto yy169; + yych = *++YYCURSOR; + if (yych != '3') goto yy169; + yych = *++YYCURSOR; + if (yych != '-') goto yy169; + yych = *++YYCURSOR; + if (yych != '2') goto yy169; + yych = *++YYCURSOR; + if (yych != '1') goto yy169; + yych = *++YYCURSOR; + if (yych != ';') goto yy169; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_P21_START); continue;} +} + + } + PUSH_TERMINAL(p->stack, lpop(in, T_P21_START)); + + p21_header_section(p, act); + p21_data_section_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_P21_END)); + + if (p->error) + goto err; + + /* user action */ + if (act->exchange_file_cb) + act->exchange_file_cb(p, bsp, act->userdata); + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_FILE}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "exchange_file << 1 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_FILE); + else default_error_handler(p, bsp, P_FILE); + recover(in, T_EOF); +} + +void p21_header_section(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yya186; + } else { + if (yych == '\r') goto yya188; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yya189; + if (yych >= '/') goto yya192; + } else { + if (yych == 'H') goto yya193; + } + } + ++YYCURSOR; +yya185: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yya186: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yya188: + yych = *++YYCURSOR; + if (yych == '\n') goto yya186; + goto yya185; +yya189: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yya189; + { n = in->cur - in->sp; } + { continue; } +yya192: + yych = *++YYCURSOR; + if (yych == '*') goto yya194; + goto yya185; +yya193: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yya196; + goto yya185; +yya194: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yya196: + yych = *++YYCURSOR; + if (yych == 'A') goto yya198; +yya197: + YYCURSOR = YYMARKER; + goto yya185; +yya198: + yych = *++YYCURSOR; + if (yych != 'D') goto yya197; + yych = *++YYCURSOR; + if (yych != 'E') goto yya197; + yych = *++YYCURSOR; + if (yych != 'R') goto yya197; + yych = *++YYCURSOR; + if (yych != ';') goto yya197; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_HEADER); continue; } +} + + } + PUSH_TERMINAL(p->stack, lpop(in, T_HEADER)); + + /* section callback */ + if (act->header_start_cb) + act->header_start_cb(p, bsp, act->userdata); + + /* mandatory headers */ + p21_header_entity(p, act); + p21_header_entity(p, act); + p21_header_entity(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych <= '\r') { + if (yych == '\n') goto yyb208; + if (yych >= '\r') goto yyb210; + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yyb211; + } else { + if (yych <= '!') goto yyb214; + if (yych >= '/') goto yyb215; + } + } + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yyb206; + if (yych == 'E') goto yyb219; + goto yyb216; + } else { + if (yych <= '_') { + if (yych >= '_') goto yyb216; + } else { + if (yych <= '`') goto yyb206; + if (yych <= 'z') goto yyb216; + } + } + } +yyb206: + ++YYCURSOR; +yyb207: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yyb208: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yyb210: + yych = *++YYCURSOR; + if (yych == '\n') goto yyb208; + goto yyb207; +yyb211: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yyb211; + { n = in->cur - in->sp; } + { continue; } +yyb214: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yyb207; + if (yych <= 'Z') goto yyb216; + goto yyb207; + } else { + if (yych == '`') goto yyb207; + if (yych <= 'z') goto yyb216; + goto yyb207; + } +yyb215: + yych = *++YYCURSOR; + if (yych == '*') goto yyb220; + goto yyb207; +yyb216: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yyb217: + if (yych <= 'Z') { + if (yych <= '/') goto yyb218; + if (yych <= '9') goto yyb216; + if (yych >= 'A') goto yyb216; + } else { + if (yych <= '_') { + if (yych >= '_') goto yyb216; + } else { + if (yych <= '`') goto yyb218; + if (yych <= 'z') goto yyb216; + } + } +yyb218: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yyb219: + yych = *++YYCURSOR; + if (yych == 'N') goto yyb222; + goto yyb217; +yyb220: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yyb222: + yych = *++YYCURSOR; + if (yych != 'D') goto yyb217; + yych = *++YYCURSOR; + if (yych != 'S') goto yyb217; + yych = *++YYCURSOR; + if (yych != 'E') goto yyb217; + yych = *++YYCURSOR; + if (yych != 'C') goto yyb217; + yych = *++YYCURSOR; + if (yych != ';') goto yyb217; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_ENDSEC); continue; } +} + + } + + /* optional headers */ + if (LOOKAHEAD(in->sym[0], T_KEYWORD)) + p21_header_entity_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_ENDSEC)); + + if (p->error) + goto err; + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_HEADERSECTION}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "header_section << 2 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_HEADERSECTION); + else default_error_handler(p, bsp, P_HEADERSECTION); + recover(in, T_DATA); +} + +void p21_data_section_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + uint32_t len = 0; + Input *in = p->in; + + do { + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 17) YYFILL(17); + yych = *YYCURSOR; + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yy233; + } else { + if (yych <= '\r') goto yy235; + if (yych >= ' ') goto yy236; + } + } else { + if (yych <= 'C') { + if (yych == '/') goto yy239; + } else { + if (yych <= 'D') goto yy240; + if (yych <= 'E') goto yy241; + } + } + ++YYCURSOR; +yy232: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy233: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy235: + yych = *++YYCURSOR; + if (yych == '\n') goto yy233; + goto yy232; +yy236: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy236; + { n = in->cur - in->sp; } + { continue; } +yy239: + yych = *++YYCURSOR; + if (yych == '*') goto yy242; + goto yy232; +yy240: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'A') goto yy244; + goto yy232; +yy241: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'N') goto yy246; + goto yy232; +yy242: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy244: + yych = *++YYCURSOR; + if (yych == 'T') goto yy247; +yy245: + YYCURSOR = YYMARKER; + goto yy232; +yy246: + yych = *++YYCURSOR; + if (yych == 'D') goto yy248; + goto yy245; +yy247: + yych = *++YYCURSOR; + if (yych == 'A') goto yy249; + goto yy245; +yy248: + yych = *++YYCURSOR; + if (yych == '-') goto yy250; + goto yy245; +yy249: + yych = *++YYCURSOR; + if (yych <= ')') { + if (yych == ' ') goto yy251; + if (yych <= '\'') goto yy245; + goto yy251; + } else { + if (yych <= '/') { + if (yych <= '.') goto yy245; + goto yy251; + } else { + if (yych == ';') goto yy251; + goto yy245; + } + } +yy250: + yych = *++YYCURSOR; + if (yych == 'I') goto yy253; + goto yy245; +yy251: + ++YYCURSOR; + YYCURSOR -= 1; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_DATA); continue; } +yy253: + yych = *++YYCURSOR; + if (yych != 'S') goto yy245; + yych = *++YYCURSOR; + if (yych != 'O') goto yy245; + yych = *++YYCURSOR; + if (yych != '-') goto yy245; + yych = *++YYCURSOR; + if (yych != '1') goto yy245; + yych = *++YYCURSOR; + if (yych != '0') goto yy245; + yych = *++YYCURSOR; + if (yych != '3') goto yy245; + yych = *++YYCURSOR; + if (yych != '0') goto yy245; + yych = *++YYCURSOR; + if (yych != '3') goto yy245; + yych = *++YYCURSOR; + if (yych != '-') goto yy245; + yych = *++YYCURSOR; + if (yych != '2') goto yy245; + yych = *++YYCURSOR; + if (yych != '1') goto yy245; + yych = *++YYCURSOR; + if (yych != ';') goto yy245; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_P21_END); continue; } +} + + } + if (!LOOKAHEAD(in->sym[0], T_DATA)) + break; + p21_data_section(p, act); + } while (++len); + + /* one or more */ + if (!len) { + push(p->stack, (Symbol){T_ERROR, T_DATA, 0, in->sym[0].lineno}); + p->error = true; + } + + if(p->error) + goto err; + + /* user action */ + if (act->data_section_list_cb) + act->data_section_list_cb(p, bsp, act->userdata); + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "data_section_list << 3 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_P21_END); +} + +void p21_data_section(P21Parser *p, P21ParserActions *act) { + size_t n, cxt; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 2) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yya271; + } else { + if (yych <= '\r') goto yya273; + if (yych >= ' ') goto yya274; + } + } else { + if (yych <= '.') { + if (yych == '(') goto yya277; + } else { + if (yych <= '/') goto yya279; + if (yych == ';') goto yya277; + } + } + ++YYCURSOR; +yya270: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yya271: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yya273: + yych = *++YYCURSOR; + if (yych == '\n') goto yya271; + goto yya270; +yya274: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yya274; + { n = in->cur - in->sp; } + { continue; } +yya277: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(*in->sp); continue; } +yya279: + yych = *++YYCURSOR; + if (yych != '*') goto yya270; + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + PUSH_TERMINAL(p->stack, lpop(in, T_DATA)); + + if (LOOKAHEAD(in->sym[0], '(')) { + PUSH_TERMINAL(p->stack, lpop(in, '(')); + + p21_parameter_list(p, act); + while (in->nsym < 2) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yyb286; + } else { + if (yych == '\r') goto yyb288; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yyb289; + if (yych >= '/') goto yyb292; + } else { + if (yych == ';') goto yyb293; + } + } + ++YYCURSOR; +yyb285: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yyb286: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yyb288: + yych = *++YYCURSOR; + if (yych == '\n') goto yyb286; + goto yyb285; +yyb289: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yyb289; + { n = in->cur - in->sp; } + { continue; } +yyb292: + yych = *++YYCURSOR; + if (yych == '*') goto yyb295; + goto yyb285; +yyb293: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(';'); continue; } +yyb295: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + + PUSH_TERMINAL(p->stack, lpop(in, ')')); + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (act->data_start_cb) + act->data_start_cb(p, bsp, act->userdata); + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yyc301; + } else { + if (yych <= '\r') goto yyc303; + if (yych >= ' ') goto yyc304; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yyc307; + } else { + if (yych <= '/') goto yyc308; + if (yych == 'E') goto yyc309; + } + } + ++YYCURSOR; +yyc300: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yyc301: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yyc303: + yych = *++YYCURSOR; + if (yych == '\n') goto yyc301; + goto yyc300; +yyc304: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yyc304; + { n = in->cur - in->sp; } + { continue; } +yyc307: + yych = *++YYCURSOR; + if (yych <= '/') goto yyc300; + if (yych <= '9') goto yyc310; + goto yyc300; +yyc308: + yych = *++YYCURSOR; + if (yych == '*') goto yyc313; + goto yyc300; +yyc309: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'N') goto yyc315; + goto yyc300; +yyc310: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yyc312; + if (yych <= '9') goto yyc310; +yyc312: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_EID); continue; } +yyc313: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yyc315: + yych = *++YYCURSOR; + if (yych == 'D') goto yyc317; +yyc316: + YYCURSOR = YYMARKER; + goto yyc300; +yyc317: + yych = *++YYCURSOR; + if (yych != 'S') goto yyc316; + yych = *++YYCURSOR; + if (yych != 'E') goto yyc316; + yych = *++YYCURSOR; + if (yych != 'C') goto yyc316; + yych = *++YYCURSOR; + if (yych != ';') goto yyc316; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_ENDSEC); continue; } +} + + } + if (LOOKAHEAD(in->sym[0], T_EID)) + p21_entity_instance_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_ENDSEC)); + + if (p->error) + goto err; + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_DATASECTION}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "data_section << 4 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_DATASECTION); + else default_error_handler(p, bsp, P_DATASECTION); + recover(in, T_P21_END, T_DATA); +} + +void p21_header_entity(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + /* set KEYWORD as basemrk to prevent fill() recycling the buffer before user action */ + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '.') { + if (yych <= '\r') { + if (yych == '\n') goto yy327; + if (yych >= '\r') goto yy329; + } else { + if (yych <= 0x001F) goto yy325; + if (yych <= ' ') goto yy330; + if (yych <= '!') goto yy333; + } + } else { + if (yych <= '^') { + if (yych <= '/') goto yy334; + if (yych <= '@') goto yy325; + if (yych <= 'Z') goto yy335; + } else { + if (yych == '`') goto yy325; + if (yych <= 'z') goto yy335; + } + } +yy325: + ++YYCURSOR; +yy326: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy327: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy329: + yych = *++YYCURSOR; + if (yych == '\n') goto yy327; + goto yy326; +yy330: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy330; + { n = in->cur - in->sp; } + { continue; } +yy333: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy326; + if (yych <= 'Z') goto yy335; + goto yy326; + } else { + if (yych == '`') goto yy326; + if (yych <= 'z') goto yy335; + goto yy326; + } +yy334: + yych = *++YYCURSOR; + if (yych == '*') goto yy338; + goto yy326; +yy335: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yy337; + if (yych <= '9') goto yy335; + if (yych >= 'A') goto yy335; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy335; + } else { + if (yych <= '`') goto yy337; + if (yych <= 'z') goto yy335; + } + } +yy337: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yy338: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + + /* set KEYWORD as basemrk to prevent fill() recycling the buffer before user action */ + assert(in->nsym == 1); + in->basemrk += in->sym[0].offset; + in->sym[0].offset = 0; + + p21_simple_record(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yy344; + } else { + if (yych == '\r') goto yy346; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yy347; + if (yych >= '/') goto yy350; + } else { + if (yych == ';') goto yy351; + } + } + ++YYCURSOR; +yy343: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy344: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy346: + yych = *++YYCURSOR; + if (yych == '\n') goto yy344; + goto yy343; +yy347: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy347; + { n = in->cur - in->sp; } + { continue; } +yy350: + yych = *++YYCURSOR; + if (yych == '*') goto yy353; + goto yy343; +yy351: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(';'); continue; } +yy353: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->header_entity_cb) + act->header_entity_cb(p, bsp, act->userdata); + + /* reduction */ + assert(!p->hold); + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_HEADERENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "header_entity << 5 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_HEADERENTITY); + else default_error_handler(p, bsp, P_HEADERENTITY); + recover(in, T_ENDSEC, T_KEYWORD); +} + +void p21_header_entity_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_header_entity(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych <= '\r') { + if (yych == '\n') goto yy359; + if (yych >= '\r') goto yy361; + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yy362; + } else { + if (yych <= '!') goto yy365; + if (yych >= '/') goto yy366; + } + } + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yy357; + if (yych == 'E') goto yy370; + goto yy367; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy367; + } else { + if (yych <= '`') goto yy357; + if (yych <= 'z') goto yy367; + } + } + } +yy357: + ++YYCURSOR; +yy358: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy359: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy361: + yych = *++YYCURSOR; + if (yych == '\n') goto yy359; + goto yy358; +yy362: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy362; + { n = in->cur - in->sp; } + { continue; } +yy365: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy358; + if (yych <= 'Z') goto yy367; + goto yy358; + } else { + if (yych == '`') goto yy358; + if (yych <= 'z') goto yy367; + goto yy358; + } +yy366: + yych = *++YYCURSOR; + if (yych == '*') goto yy371; + goto yy358; +yy367: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy368: + if (yych <= 'Z') { + if (yych <= '/') goto yy369; + if (yych <= '9') goto yy367; + if (yych >= 'A') goto yy367; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy367; + } else { + if (yych <= '`') goto yy369; + if (yych <= 'z') goto yy367; + } + } +yy369: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yy370: + yych = *++YYCURSOR; + if (yych == 'N') goto yy373; + goto yy368; +yy371: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy373: + yych = *++YYCURSOR; + if (yych != 'D') goto yy368; + yych = *++YYCURSOR; + if (yych != 'S') goto yy368; + yych = *++YYCURSOR; + if (yych != 'E') goto yy368; + yych = *++YYCURSOR; + if (yych != 'C') goto yy368; + yych = *++YYCURSOR; + if (yych != ';') goto yy368; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_ENDSEC); continue; } +} + + } + if (!LOOKAHEAD(in->sym[0], T_KEYWORD)) + break; + p21_header_entity(p, act); + } while (1); + + if (p->error) + goto err; + + + /* user action */ + if (act->header_entity_list_cb) + act->header_entity_list_cb(p, bsp, act->userdata); + + /* reduction */ + assert(!p->hold); + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "header_entity_list << 6 >>"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC); +} + +void p21_entity_instance_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_entity_instance(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yy384; + } else { + if (yych <= '\r') goto yy386; + if (yych >= ' ') goto yy387; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yy390; + } else { + if (yych <= '/') goto yy391; + if (yych == 'E') goto yy392; + } + } + ++YYCURSOR; +yy383: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy384: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy386: + yych = *++YYCURSOR; + if (yych == '\n') goto yy384; + goto yy383; +yy387: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy387; + { n = in->cur - in->sp; } + { continue; } +yy390: + yych = *++YYCURSOR; + if (yych <= '/') goto yy383; + if (yych <= '9') goto yy393; + goto yy383; +yy391: + yych = *++YYCURSOR; + if (yych == '*') goto yy396; + goto yy383; +yy392: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'N') goto yy398; + goto yy383; +yy393: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy395; + if (yych <= '9') goto yy393; +yy395: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_EID); continue; } +yy396: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy398: + yych = *++YYCURSOR; + if (yych == 'D') goto yy400; +yy399: + YYCURSOR = YYMARKER; + goto yy383; +yy400: + yych = *++YYCURSOR; + if (yych != 'S') goto yy399; + yych = *++YYCURSOR; + if (yych != 'E') goto yy399; + yych = *++YYCURSOR; + if (yych != 'C') goto yy399; + yych = *++YYCURSOR; + if (yych != ';') goto yy399; + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_ENDSEC); continue; } +} + + } + if (!LOOKAHEAD(in->sym[0], T_EID)) + break; + p21_entity_instance(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->entity_instance_list_cb) + act->entity_instance_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "entity_instance_list << 7 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC); +} + +void p21_parameter_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_parameter(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yy410; + } else { + if (yych <= '\r') goto yy412; + if (yych >= ' ') goto yy413; + } + } else { + if (yych <= '+') { + if (yych == ')') goto yy416; + } else { + if (yych <= ',') goto yy416; + if (yych == '/') goto yy418; + } + } + ++YYCURSOR; +yy409: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy410: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy412: + yych = *++YYCURSOR; + if (yych == '\n') goto yy410; + goto yy409; +yy413: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy413; + { n = in->cur - in->sp; } + { continue; } +yy416: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(*in->sp); continue; } +yy418: + yych = *++YYCURSOR; + if (yych != '*') goto yy409; + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + if (LOOKAHEAD(in->sym[0], ')')) + break; + + PUSH_TERMINAL(p->stack, lpop(in, ',')); + p21_parameter(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->parameter_list_cb) + act->parameter_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "parameter_list << 8 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, ')', ';'); +} + +void p21_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + /* set EID as basemrk to prevent fill() recycling the buffer before user action */ + assert(in->nsym == 1); + in->basemrk += in->sym[0].offset; + in->sym[0].offset = 0; + + while (in->nsym < 3) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '.') { + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yy425; + } else { + if (yych == '\r') goto yy427; + } + } else { + if (yych <= '!') { + if (yych <= ' ') goto yy428; + goto yy431; + } else { + if (yych == '(') goto yy432; + } + } + } else { + if (yych <= 'Z') { + if (yych <= '<') { + if (yych <= '/') goto yy434; + } else { + if (yych <= '=') goto yy432; + if (yych >= 'A') goto yy435; + } + } else { + if (yych <= '_') { + if (yych >= '_') goto yy435; + } else { + if (yych <= '`') goto yy423; + if (yych <= 'z') goto yy435; + } + } + } +yy423: + ++YYCURSOR; +yy424: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy425: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy427: + yych = *++YYCURSOR; + if (yych == '\n') goto yy425; + goto yy424; +yy428: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy428; + { n = in->cur - in->sp; } + { continue; } +yy431: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy424; + if (yych <= 'Z') goto yy435; + goto yy424; + } else { + if (yych == '`') goto yy424; + if (yych <= 'z') goto yy435; + goto yy424; + } +yy432: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(*in->sp); continue; } +yy434: + yych = *++YYCURSOR; + if (yych == '*') goto yy438; + goto yy424; +yy435: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yy437; + if (yych <= '9') goto yy435; + if (yych >= 'A') goto yy435; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy435; + } else { + if (yych <= '`') goto yy437; + if (yych <= 'z') goto yy435; + } + } +yy437: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yy438: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + if (!LOOKAHEAD(in->sym[0], T_EID) || !LOOKAHEAD(in->sym[1], '=')) + goto err; + + if (LOOKAHEAD(in->sym[2], T_KEYWORD)) { + p21_simple_entity_instance(p, act); + } else if (LOOKAHEAD(in->sym[2], '(')) { + p21_complex_entity_instance(p, act); + } + + if (p->error) + goto err; + + /* user action */ + if (act->entity_instance_cb) + act->entity_instance_cb(p, bsp, act->userdata); + + /* no default reduction */ + + return; + +err: + report_error(p, "entity_instance << 9 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC, T_EID); +} + +void p21_simple_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + PUSH_TERMINAL(p->stack, lpop(in, T_EID)); + PUSH_TERMINAL(p->stack, lpop(in, '=')); + + p21_simple_record(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yy444; + } else { + if (yych == '\r') goto yy446; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yy447; + if (yych >= '/') goto yy450; + } else { + if (yych == ';') goto yy451; + } + } + ++YYCURSOR; +yy443: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy444: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy446: + yych = *++YYCURSOR; + if (yych == '\n') goto yy444; + goto yy443; +yy447: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy447; + { n = in->cur - in->sp; } + { continue; } +yy450: + yych = *++YYCURSOR; + if (yych == '*') goto yy453; + goto yy443; +yy451: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(';'); continue; } +yy453: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_entity_instance_cb) + act->simple_entity_instance_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_SIMPLEENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_entity_instance << 10 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_SIMPLEENTITY); + else default_error_handler(p, bsp, P_SIMPLEENTITY); + recover(in, T_ENDSEC, T_EID); +} + + +void p21_complex_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n, c; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + PUSH_TERMINAL(p->stack, lpop(in, T_EID)); + PUSH_TERMINAL(p->stack, lpop(in, '=')); + PUSH_TERMINAL_EXT(c, p->stack, lpop(in, '(')); + + p21_simple_record_list(p, act); + + while (in->nsym < 2) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yy459; + } else { + if (yych == '\r') goto yy461; + } + } else { + if (yych <= '/') { + if (yych <= ' ') goto yy462; + if (yych >= '/') goto yy465; + } else { + if (yych == ';') goto yy466; + } + } + ++YYCURSOR; +yy458: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy459: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy461: + yych = *++YYCURSOR; + if (yych == '\n') goto yy459; + goto yy458; +yy462: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy462; + { n = in->cur - in->sp; } + { continue; } +yy465: + yych = *++YYCURSOR; + if (yych == '*') goto yy468; + goto yy458; +yy466: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(';'); continue; } +yy468: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + + PUSH_TERMINAL_EXT(c, p->stack, lpop(in, ')')); + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->complex_entity_instance_cb) + act->complex_entity_instance_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_COMPLEXENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "complex_entity_instance << 11 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_COMPLEXENTITY); + else default_error_handler(p, bsp, P_COMPLEXENTITY); + recover(in, T_ENDSEC, T_EID); +} + +void p21_simple_record(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 3) { + in->sp = in->cur; + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ')') { + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yy474; + } else { + if (yych <= '\r') goto yy476; + if (yych >= ' ') goto yy477; + } + } else { + if (yych <= '#') { + if (yych <= '!') goto yy480; + if (yych <= '"') goto yy481; + goto yy482; + } else { + if (yych <= '$') goto yy483; + if (yych <= '&') goto yy472; + if (yych <= '\'') goto yy485; + goto yy486; + } + } + } else { + if (yych <= '9') { + if (yych <= ',') { + if (yych <= '*') goto yy488; + if (yych <= '+') goto yy490; + } else { + if (yych <= '-') goto yy490; + if (yych <= '.') goto yy491; + if (yych <= '/') goto yy492; + goto yy493; + } + } else { + if (yych <= '^') { + if (yych <= '@') goto yy472; + if (yych <= 'Z') goto yy496; + } else { + if (yych == '`') goto yy472; + if (yych <= 'z') goto yy496; + } + } + } +yy472: + ++YYCURSOR; +yy473: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy474: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy476: + yych = *++YYCURSOR; + if (yych == '\n') goto yy474; + goto yy473; +yy477: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy477; + { n = in->cur - in->sp; } + { continue; } +yy480: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy473; + if (yych <= 'Z') goto yy496; + goto yy473; + } else { + if (yych == '`') goto yy473; + if (yych <= 'z') goto yy496; + goto yy473; + } +yy481: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '/') goto yy473; + if (yych <= '3') goto yy499; + goto yy473; +yy482: + yych = *++YYCURSOR; + if (yych <= '/') goto yy473; + if (yych <= '9') goto yy502; + goto yy473; +yy483: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_EMPTY); continue; } +yy485: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '[') { + if (yych <= 0x001F) goto yy473; + if (yych <= 'Z') goto yy506; + goto yy473; + } else { + if (yych == ']') goto yy473; + if (yych <= '~') goto yy506; + goto yy473; + } +yy486: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(*in->sp); continue; } +yy488: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_DERIVED); continue; } +yy490: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= ',') { + if (yych == '+') goto yy510; + goto yy473; + } else { + if (yych <= '-') goto yy510; + if (yych <= '/') goto yy473; + if (yych <= '9') goto yy493; + goto yy473; + } +yy491: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') goto yy473; + if (yych <= 'Z') goto yy512; + if (yych == '_') goto yy512; + goto yy473; +yy492: + yych = *++YYCURSOR; + if (yych == '*') goto yy514; + goto yy473; +yy493: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '.') goto yy516; + if (yych <= '/') goto yy495; + if (yych <= '9') goto yy493; +yy495: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_INTEGER); continue; } +yy496: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yy498; + if (yych <= '9') goto yy496; + if (yych >= 'A') goto yy496; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy496; + } else { + if (yych <= '`') goto yy498; + if (yych <= 'z') goto yy496; + } + } +yy498: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yy499: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych == '"') goto yy519; + } else { + if (yych <= '9') goto yy499; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy499; + } +yy501: + YYCURSOR = YYMARKER; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy473; + } else { + goto yy508; + } + } else { + goto yy518; + } +yy502: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy504; + if (yych <= '9') goto yy502; +yy504: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_EID); continue; } +yy505: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy506: + if (yych <= 'Z') { + if (yych <= 0x001F) goto yy501; + if (yych != '\'') goto yy505; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy501; + goto yy509; + } else { + if (yych <= ']') goto yy501; + if (yych <= '~') goto yy505; + goto yy501; + } + } + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\'') goto yy505; +yy508: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_STRING); continue; } +yy509: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'S') { + if (yych <= '@') goto yy501; + if (yych <= 'I') goto yy521; + if (yych <= 'R') goto yy501; + goto yy522; + } else { + if (yych <= 'X') { + if (yych <= 'W') goto yy501; + goto yy523; + } else { + if (yych == '\\') goto yy505; + goto yy501; + } + } +yy510: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yy510; + goto yy501; + } else { + if (yych <= '-') goto yy510; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy493; + goto yy501; + } +yy512: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych == '.') goto yy524; + if (yych <= '/') goto yy501; + goto yy512; + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yy501; + goto yy512; + } else { + if (yych == '_') goto yy512; + goto yy501; + } + } +yy514: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yy516: + yyaccept = 2; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy518; + if (yych <= '9') goto yy516; + if (yych == 'E') goto yy526; +yy518: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_REAL); continue; } +yy519: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_BINARY); continue; } +yy521: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy505; + goto yy501; +yy522: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy528; + goto yy501; +yy523: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '3') { + if (yych == '2') goto yy529; + goto yy501; + } else { + if (yych <= '4') goto yy530; + if (yych == '\\') goto yy531; + goto yy501; + } +yy524: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_ENUMERATION); continue; } +yy526: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yy526; + goto yy501; + } else { + if (yych <= '-') goto yy526; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy532; + goto yy501; + } +yy528: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '[') { + if (yych <= 0x001F) goto yy501; + if (yych <= 'Z') goto yy505; + goto yy501; + } else { + if (yych == ']') goto yy501; + if (yych <= '~') goto yy505; + goto yy501; + } +yy529: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy534; + goto yy501; +yy530: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy535; + goto yy501; +yy531: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy536; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy536; + goto yy501; +yy532: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy518; + if (yych <= '9') goto yy532; + goto yy518; +yy534: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy537; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy537; + goto yy501; +yy535: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy538; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy538; + goto yy501; +yy536: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy505; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy505; + goto yy501; +yy537: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy539; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy539; + goto yy501; +yy538: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy540; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy540; + goto yy501; +yy539: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy541; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy541; + goto yy501; +yy540: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy542; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy542; + goto yy501; +yy541: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy543; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy543; + goto yy501; +yy542: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy544; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy544; + goto yy501; +yy543: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy537; + goto yy501; + } else { + if (yych <= 'F') goto yy537; + if (yych == '\\') goto yy545; + goto yy501; + } +yy544: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy546; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy546; + goto yy501; +yy545: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == 'X') goto yy547; + goto yy501; +yy546: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy548; + if (yych <= '@') goto yy501; + if (yych <= 'F') goto yy548; + goto yy501; +yy547: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '0') goto yy521; + goto yy501; +yy548: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy549; + if (yych <= '@') goto yy501; + if (yych >= 'G') goto yy501; +yy549: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy550; + if (yych <= '@') goto yy501; + if (yych >= 'G') goto yy501; +yy550: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy501; + if (yych <= '9') goto yy538; + goto yy501; + } else { + if (yych <= 'F') goto yy538; + if (yych == '\\') goto yy545; + goto yy501; + } +} + + } + + PUSH_TERMINAL(p->stack, lpop(in, T_KEYWORD)); + PUSH_TERMINAL_EXT(n, p->stack, lpop(in, '(')); + + if (LOOKAHEAD(in->sym[0], '(', T_KEYWORD, T_VARIANT)) + p21_parameter_list(p, act); + + PUSH_TERMINAL_EXT(n, p->stack, lpop(in, ')')); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_record_cb) + act->simple_record_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_SIMPLERECORD}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_record << 12 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_SIMPLERECORD); + else default_error_handler(p, bsp, P_SIMPLERECORD); + recover(in, ';', ')', T_KEYWORD); +} + +void p21_simple_record_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_simple_record(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ')') { + if (yych <= '\r') { + if (yych == '\n') goto yy555; + if (yych >= '\r') goto yy557; + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yy558; + } else { + if (yych <= '!') goto yy561; + if (yych >= ')') goto yy562; + } + } + } else { + if (yych <= 'Z') { + if (yych == '/') goto yy564; + if (yych >= 'A') goto yy565; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy565; + } else { + if (yych <= '`') goto yy553; + if (yych <= 'z') goto yy565; + } + } + } +yy553: + ++YYCURSOR; +yy554: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yy555: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yy557: + yych = *++YYCURSOR; + if (yych == '\n') goto yy555; + goto yy554; +yy558: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yy558; + { n = in->cur - in->sp; } + { continue; } +yy561: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy554; + if (yych <= 'Z') goto yy565; + goto yy554; + } else { + if (yych == '`') goto yy554; + if (yych <= 'z') goto yy565; + goto yy554; + } +yy562: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(')'); continue; } +yy564: + yych = *++YYCURSOR; + if (yych == '*') goto yy568; + goto yy554; +yy565: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yy567; + if (yych <= '9') goto yy565; + if (yych >= 'A') goto yy565; + } else { + if (yych <= '_') { + if (yych >= '_') goto yy565; + } else { + if (yych <= '`') goto yy567; + if (yych <= 'z') goto yy565; + } + } +yy567: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yy568: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + if (!LOOKAHEAD(in->sym[0], T_KEYWORD)) + break; + p21_simple_record(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_record_list_cb) + act->simple_record_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_record_list << 13 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, ')', ';'); +} + +void p21_parameter(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 2) { + in->sp = in->cur; + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ')') { + if (yych <= ' ') { + if (yych <= '\f') { + if (yych == '\n') goto yya574; + } else { + if (yych <= '\r') goto yya576; + if (yych >= ' ') goto yya577; + } + } else { + if (yych <= '#') { + if (yych <= '!') goto yya580; + if (yych <= '"') goto yya581; + goto yya582; + } else { + if (yych <= '$') goto yya583; + if (yych <= '&') goto yya572; + if (yych <= '\'') goto yya585; + goto yya586; + } + } + } else { + if (yych <= '9') { + if (yych <= ',') { + if (yych <= '*') goto yya588; + if (yych <= '+') goto yya590; + goto yya586; + } else { + if (yych <= '-') goto yya590; + if (yych <= '.') goto yya591; + if (yych <= '/') goto yya592; + goto yya593; + } + } else { + if (yych <= '^') { + if (yych <= '@') goto yya572; + if (yych <= 'Z') goto yya596; + } else { + if (yych == '`') goto yya572; + if (yych <= 'z') goto yya596; + } + } + } +yya572: + ++YYCURSOR; +yya573: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yya574: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yya576: + yych = *++YYCURSOR; + if (yych == '\n') goto yya574; + goto yya573; +yya577: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yya577; + { n = in->cur - in->sp; } + { continue; } +yya580: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yya573; + if (yych <= 'Z') goto yya596; + goto yya573; + } else { + if (yych == '`') goto yya573; + if (yych <= 'z') goto yya596; + goto yya573; + } +yya581: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '/') goto yya573; + if (yych <= '3') goto yya599; + goto yya573; +yya582: + yych = *++YYCURSOR; + if (yych <= '/') goto yya573; + if (yych <= '9') goto yya602; + goto yya573; +yya583: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_EMPTY); continue; } +yya585: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '[') { + if (yych <= 0x001F) goto yya573; + if (yych <= 'Z') goto yya606; + goto yya573; + } else { + if (yych == ']') goto yya573; + if (yych <= '~') goto yya606; + goto yya573; + } +yya586: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(*in->sp); continue; } +yya588: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_DERIVED); continue; } +yya590: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= ',') { + if (yych == '+') goto yya610; + goto yya573; + } else { + if (yych <= '-') goto yya610; + if (yych <= '/') goto yya573; + if (yych <= '9') goto yya593; + goto yya573; + } +yya591: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') goto yya573; + if (yych <= 'Z') goto yya612; + if (yych == '_') goto yya612; + goto yya573; +yya592: + yych = *++YYCURSOR; + if (yych == '*') goto yya614; + goto yya573; +yya593: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '.') goto yya616; + if (yych <= '/') goto yya595; + if (yych <= '9') goto yya593; +yya595: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_INTEGER); continue; } +yya596: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yya598; + if (yych <= '9') goto yya596; + if (yych >= 'A') goto yya596; + } else { + if (yych <= '_') { + if (yych >= '_') goto yya596; + } else { + if (yych <= '`') goto yya598; + if (yych <= 'z') goto yya596; + } + } +yya598: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_KEYWORD); continue; } +yya599: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych == '"') goto yya619; + } else { + if (yych <= '9') goto yya599; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya599; + } +yya601: + YYCURSOR = YYMARKER; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yya573; + } else { + goto yya608; + } + } else { + goto yya618; + } +yya602: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya604; + if (yych <= '9') goto yya602; +yya604: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_EID); continue; } +yya605: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yya606: + if (yych <= 'Z') { + if (yych <= 0x001F) goto yya601; + if (yych != '\'') goto yya605; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yya601; + goto yya609; + } else { + if (yych <= ']') goto yya601; + if (yych <= '~') goto yya605; + goto yya601; + } + } + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\'') goto yya605; +yya608: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_STRING); continue; } +yya609: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'S') { + if (yych <= '@') goto yya601; + if (yych <= 'I') goto yya621; + if (yych <= 'R') goto yya601; + goto yya622; + } else { + if (yych <= 'X') { + if (yych <= 'W') goto yya601; + goto yya623; + } else { + if (yych == '\\') goto yya605; + goto yya601; + } + } +yya610: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yya610; + goto yya601; + } else { + if (yych <= '-') goto yya610; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya593; + goto yya601; + } +yya612: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych == '.') goto yya624; + if (yych <= '/') goto yya601; + goto yya612; + } else { + if (yych <= 'Z') { + if (yych <= '@') goto yya601; + goto yya612; + } else { + if (yych == '_') goto yya612; + goto yya601; + } + } +yya614: + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +yya616: + yyaccept = 2; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya618; + if (yych <= '9') goto yya616; + if (yych == 'E') goto yya626; +yya618: + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_REAL); continue; } +yya619: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_BINARY); continue; } +yya621: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yya605; + goto yya601; +yya622: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yya628; + goto yya601; +yya623: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '3') { + if (yych == '2') goto yya629; + goto yya601; + } else { + if (yych <= '4') goto yya630; + if (yych == '\\') goto yya631; + goto yya601; + } +yya624: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(T_VARIANT, V_ENUMERATION); continue; } +yya626: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yya626; + goto yya601; + } else { + if (yych <= '-') goto yya626; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya632; + goto yya601; + } +yya628: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '[') { + if (yych <= 0x001F) goto yya601; + if (yych <= 'Z') goto yya605; + goto yya601; + } else { + if (yych == ']') goto yya601; + if (yych <= '~') goto yya605; + goto yya601; + } +yya629: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yya634; + goto yya601; +yya630: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yya635; + goto yya601; +yya631: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya636; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya636; + goto yya601; +yya632: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya618; + if (yych <= '9') goto yya632; + goto yya618; +yya634: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya637; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya637; + goto yya601; +yya635: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya638; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya638; + goto yya601; +yya636: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya605; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya605; + goto yya601; +yya637: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya639; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya639; + goto yya601; +yya638: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya640; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya640; + goto yya601; +yya639: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya641; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya641; + goto yya601; +yya640: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya642; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya642; + goto yya601; +yya641: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya643; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya643; + goto yya601; +yya642: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya644; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya644; + goto yya601; +yya643: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya637; + goto yya601; + } else { + if (yych <= 'F') goto yya637; + if (yych == '\\') goto yya645; + goto yya601; + } +yya644: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya646; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya646; + goto yya601; +yya645: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == 'X') goto yya647; + goto yya601; +yya646: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya648; + if (yych <= '@') goto yya601; + if (yych <= 'F') goto yya648; + goto yya601; +yya647: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '0') goto yya621; + goto yya601; +yya648: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya649; + if (yych <= '@') goto yya601; + if (yych >= 'G') goto yya601; +yya649: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya650; + if (yych <= '@') goto yya601; + if (yych >= 'G') goto yya601; +yya650: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yya601; + if (yych <= '9') goto yya638; + goto yya601; + } else { + if (yych <= 'F') goto yya638; + if (yych == '\\') goto yya645; + goto yya601; + } +} + + } + + if (LOOKAHEAD(in->sym[0], T_VARIANT)) { + PUSH_TERMINAL(p->stack, lpop(in, T_VARIANT)); + } else { + if (LOOKAHEAD(in->sym[0], T_KEYWORD)) { + PUSH_TERMINAL(p->stack, lpop(in, T_KEYWORD)); + PUSH_TERMINAL(p->stack, lpop(in, '(')); + p21_parameter(p, act); + } else { + PUSH_TERMINAL(p->stack, lpop(in, '(')); + if (LOOKAHEAD(in->sym[0], '(', T_KEYWORD, T_VARIANT)) { + p21_parameter_list(p, act); + } + } + while (in->nsym < 1) { + in->sp = in->cur; + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x001F) { + if (yych <= '\n') { + if (yych >= '\n') goto yyb655; + } else { + if (yych == '\r') goto yyb657; + } + } else { + if (yych <= ')') { + if (yych <= ' ') goto yyb658; + if (yych >= ')') goto yyb661; + } else { + if (yych == '/') goto yyb663; + } + } + ++YYCURSOR; +yyb654: + { n = in->cur - in->sp; } + { YYCURSOR--; break; } +yyb655: + ++YYCURSOR; + { n = in->cur - in->sp; } + { in->lineno++; continue; } +yyb657: + yych = *++YYCURSOR; + if (yych == '\n') goto yyb655; + goto yyb654; +yyb658: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == ' ') goto yyb658; + { n = in->cur - in->sp; } + { continue; } +yyb661: + ++YYCURSOR; + { n = in->cur - in->sp; } + { PUSH_SYMBOL(')'); continue; } +yyb663: + yych = *++YYCURSOR; + if (yych != '*') goto yyb654; + ++YYCURSOR; + { n = in->cur - in->sp; } + { lex_comment(in); continue; } +} + + } + PUSH_TERMINAL(p->stack, lpop(in, ')')); + } + + if (p->error) + goto err; + + /* user action */ + if (act->parameter_cb) + act->parameter_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_PARAMETER}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "parameter << 14 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_PARAMETER); + else default_error_handler(p, bsp, P_PARAMETER); + recover(in, ')', ',', ';'); +} + +void mock_error(P21Parser *, int, uint8_t); +void mock_ud_init(void *); +void mock_ud_exit(void *); +void mock_exchange_file(P21Parser *, int, void *); +void mock_header_start(P21Parser *, int, void *); +void mock_header_entity_list(P21Parser *, int, void *); +void mock_data_section_list(P21Parser *, int, void *); +void mock_data_start(P21Parser *, int, void *); +void mock_header_entity(P21Parser *, int, void *); +void mock_simple_entity_instance(P21Parser *, int, void *); +void mock_complex_entity_instance(P21Parser *, int, void *); +void mock_parameter_list(P21Parser *, int, void *); +void mock_parameter(P21Parser *, int, void *); +void mock_entity_instance_list(P21Parser *, int, void *); +void mock_entity_instance(P21Parser *, int, void *); +void mock_simple_record_list(P21Parser *, int, void *); +void mock_simple_record(P21Parser *, int, void *); +void mock_noop(P21Parser *, int, void *); + +typedef struct { + sqlite3 *db; + sqlite3_stmt *sec_stmt; + sqlite3_stmt *sei_stmt; + sqlite3_stmt *cei_stmt; + sqlite3_stmt *hei_stmt; + int section_idx; +} P21UserData; + +P21UserData mockdata = {0}; + +P21ParserActions mockact = { + .userdata = &mockdata, + .error_cb = mock_error, + .ud_init_cb = mock_ud_init, + .ud_exit_cb = mock_ud_exit, + .header_start_cb = mock_header_start, + .data_start_cb = mock_data_start, + .exchange_file_cb = NULL, + .header_entity_list_cb = NULL, + .data_section_list_cb = NULL, + .header_entity_cb = mock_header_entity, + .simple_entity_instance_cb = mock_simple_entity_instance, + .complex_entity_instance_cb = mock_complex_entity_instance, + .parameter_list_cb = mock_noop, + .parameter_cb = mock_noop, + .entity_instance_list_cb = NULL, + .entity_instance_cb = NULL, + .simple_record_list_cb = mock_noop, + .simple_record_cb = mock_noop +}; + +void mock_error(P21Parser *p, int bsp, uint8_t cxt) { + switch (cxt) { + case P_SIMPLEENTITY: + case P_COMPLEXENTITY: + case P_HEADERENTITY: + dprintf("caught error: '%c'\n", cxt); + p->error = false; + drop(p->stack, p->stack->idx_top - bsp - 1); + break; + default: + p->error = true; + break; + } +} + + +void mock_ud_init(void *d) { + P21UserData *ud = d; + char ddl_sql[] = + "PRAGMA foreign_keys = ON;\n" + "CREATE TABLE entity_enum (type TEXT(1) PRIMARY KEY);\n" + "INSERT INTO entity_enum (type) VALUES ('S'), ('C');\n" + "CREATE TABLE section_enum (type TEXT(1) PRIMARY KEY);\n" + "INSERT INTO section_enum (type) VALUES ('D'), ('H');\n" + + "CREATE TABLE section_table (\n" + " id INTEGER PRIMARY KEY,\n" + " lineno INTEGER NOT NULL,\n" + " section_type TEXT(1) NOT NULL REFERENCES section_enum(type)\n" + ");\n" + + "CREATE TABLE section_headers (\n" + " id INTEGER PRIMARY KEY,\n" + " type_name TEXT COLLATE NOCASE,\n" + " raw_data TEXT NOT NULL,\n" + " lineno INTEGER NOT NULL,\n" + " fk_section INTEGER NOT NULL REFERENCES section_table(id)\n" + ");\n" + + "CREATE TABLE data_table (\n" + " id TEXT PRIMARY KEY,\n" + " type_name TEXT COLLATE NOCASE,\n" + " raw_data TEXT NOT NULL,\n" + " lineno INTEGER NOT NULL,\n" + " entity_type TEXT(1) NOT NULL REFERENCES entity_enum(type),\n" + " fk_section INTEGER NOT NULL REFERENCES section_table(id)\n" + ") WITHOUT ROWID;\n" + + "BEGIN DEFERRED TRANSACTION;"; + + char sei_sql[] = "INSERT INTO data_table VALUES (?,?,?,?,'S',?)"; + char cei_sql[] = "INSERT INTO data_table VALUES (?,NULL,?,?,'C',?)"; + char hei_sql[] = "INSERT INTO section_headers(type_name, raw_data, lineno, fk_section) VALUES (?, ?, ?, ?)"; + int rc; + + rc = sqlite3_open_v2(":memory:", &ud->db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); + + /* TODO: read ddl sql from external file */ + rc = sqlite3_exec(ud->db, ddl_sql, NULL, NULL, NULL); + + rc |= sqlite3_prepare_v3(ud->db, sei_sql, sizeof sei_sql, SQLITE_PREPARE_PERSISTENT, &ud->sei_stmt, NULL); + rc |= sqlite3_prepare_v3(ud->db, cei_sql, sizeof cei_sql, SQLITE_PREPARE_PERSISTENT, &ud->cei_stmt, NULL); + rc |= sqlite3_prepare_v3(ud->db, hei_sql, sizeof hei_sql, SQLITE_PREPARE_PERSISTENT, &ud->hei_stmt, NULL); + + if (rc != SQLITE_OK) + exit(1); + + ud->section_idx = 0; +} + +void mock_ud_exit(void *d) { + P21UserData *ud = d; + int rc; + char ddl_sql[] = + "CREATE INDEX ix_type_name ON data_table(type_name);\n" + "CREATE INDEX ix_entity_type ON data_table(entity_type);\n" + "CREATE INDEX ix_fk_section ON data_table(fk_section);"; + + rc = sqlite3_finalize(ud->sei_stmt); + rc |= sqlite3_finalize(ud->cei_stmt); + rc |= sqlite3_finalize(ud->hei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_exec(ud->db, "COMMIT TRANSACTION", NULL, NULL, NULL); + if (rc != SQLITE_OK) goto err; + + /* TODO: benchmark index creation here vs on db init */ + rc = sqlite3_exec(ud->db, ddl_sql, NULL, NULL, NULL); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_close(ud->db); + if (rc != SQLITE_OK) goto err; + + return; +err: + dprintf("db error\n"); + exit(1); +} + +void mock_exchange_file(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_header_start(P21Parser *p, int bsp, void *d) { + char sec_sql[] = "INSERT INTO section_table VALUES(?,?,'H')"; + Stack *s = p->stack; + P21UserData *ud = d; + Symbol *t = s->items + bsp; + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(ud->db, sec_sql, sizeof sec_sql, &stmt, NULL); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_bind_int(stmt, 1, ++ud->section_idx); + rc |= sqlite3_bind_int(stmt, 2, t->lineno); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_step(stmt); + if (rc != SQLITE_DONE) goto err; + + sqlite3_finalize(stmt); + + /* + s->items[bsp] = (Symbol){P_HEADERSECTION}; + drop(s, s->idx_top - bsp - 1); + */ + + return; + +err: + dprintf("db error\n"); + exit(1); +} +void mock_header_entity_list(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_data_section_list(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_data_start(P21Parser *p, int bsp, void *d) { + char sec_sql[] = "INSERT INTO section_table VALUES(?,?,'D')"; + Stack *s = p->stack; + P21UserData *ud = d; + Symbol *t = s->items + bsp; + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(ud->db, sec_sql, sizeof sec_sql, &stmt, NULL); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_bind_int(stmt, 1, ++ud->section_idx); + rc |= sqlite3_bind_int(stmt, 2, t->lineno); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_step(stmt); + if (rc!= SQLITE_DONE) goto err; + + sqlite3_finalize(stmt); + + return; + +err: + dprintf("db error\n"); + exit(1); +} + +void mock_header_entity(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + HeaderEntity e = {s->items + bsp, s->items + bsp + 1}; + size_t i, nargs = e.args->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) args member before bind */ + e.args->offset = (e.args + 1)->offset; + e.args->n = (e.args + 1)->n; + for (i = 2, ep = e.args->offset + 1; i < nargs; i++) { + Symbol *t = e.args + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.args->n = ep - e.args->offset; + + rc = sqlite3_reset(ud->hei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->hei_stmt, 1, basemrk + e.kw->offset, e.kw->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->hei_stmt, 2, basemrk + e.args->offset, e.args->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->hei_stmt, 3, e.kw->lineno); + rc |= sqlite3_bind_int(ud->hei_stmt, 4, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->hei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + return; + +err: + mock_error(p, bsp, P_HEADERENTITY); + dprintf("db error\n"); +} + +void mock_simple_entity_instance(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + SimpleEntity e = {s->items + bsp, s->items + bsp + 1, s->items + bsp + 2, s->items + bsp + 3}; + size_t i, nargs = e.args->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) args before bind */ + e.args->offset = (e.args + 1)->offset; + e.args->n = (e.args + 1)->n; + for (i = 2, ep = e.args->offset + e.args->n; i < nargs; i++) { + Symbol *t = e.args + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.args->n = ep - e.args->offset; + + /* */ + rc = sqlite3_reset(ud->sei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->sei_stmt, 1, basemrk + e.eid->offset, e.eid->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->sei_stmt, 2, basemrk + e.kw->offset, e.kw->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->sei_stmt, 3, basemrk + e.args->offset, e.args->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->sei_stmt, 4, e.eid->lineno); + rc |= sqlite3_bind_int(ud->sei_stmt, 5, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->sei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + + return; + +err: + mock_error(p, bsp, P_SIMPLEENTITY); + dprintf("db error\n"); +} + + +void mock_complex_entity_instance(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + ComplexEntity e = {s->items + bsp, s->items + bsp + 1, s->items + bsp + 2}; + size_t i, nsubsupers = e.subsupers->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) list before bind */ + for (i = 1, ep = e.subsupers->offset + 1; i < nsubsupers; i++) { + Symbol *t = e.subsupers + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.subsupers->n = ep - e.subsupers->offset; + + rc = sqlite3_reset(ud->cei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->cei_stmt, 1, basemrk + e.eid->offset, e.eid->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->cei_stmt, 2, basemrk + e.subsupers->offset, e.subsupers->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->cei_stmt, 3, e.eid->lineno); + rc |= sqlite3_bind_int(ud->cei_stmt, 4, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->cei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + return; + +err: + mock_error(p, bsp, P_COMPLEXENTITY); + dprintf("db error \n"); +} + +void mock_parameter_list(P21Parser *p, int bsp, void *d) { } +void mock_parameter(P21Parser *p, int bsp, void *d) { } +void mock_entity_instance_list(P21Parser *p, int bsp, void *d) { } +void mock_entity_instance(P21Parser *p, int bsp, void *d) { } +void mock_simple_record_list(P21Parser *p, int bsp, void *d) { } +void mock_simple_record(P21Parser *p, int bsp, void *d) {} + +void mock_noop(P21Parser *p, int bsp, void *d) { + p->hold = true; +} + +int main(char *argv[], int argc) { + const char *paths[] = { + "/home/chorler/projects/src/stepcode/test/p21/test_array_bounds_FAIL1.p21", + "/home/chorler/projects/src/stepcode/test/p21/comments.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_inverse_attr.p21", + "/home/chorler/projects/src/stepcode/test/p21/missing_and_required.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_array_bounds.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_inherit_inverse.p21", + "/home/chorler/projects/src/stepcode/data/ap214e3/as1-oc-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/dm1-id-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD_BACK.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD_FRONT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY_FRONT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT_BACK_000.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT_FRONT_000.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY_BACK.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL_TURBINE.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL_MIDDLE_PART.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/sg1-c5-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/io1-cm-214.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1-out.stp" + }; + + P21Parser myp; + P21UserData mydata; + FILE *fp; + memset(&mydata, 0, sizeof mydata); + + for (unsigned int i = 0; i < (sizeof paths / sizeof paths[0]); i++) { + fp = fopen(paths[i], "rb"); + if (!fp) { fprintf(stderr, "failed to read input: %s\n", paths[i]); continue; } + else { fprintf(stderr, "processing: %s\n", paths[i]); } + p21_init(&myp, fp); + p21_parse(&myp, &mockact); + } +} diff --git a/src/exp2python/python/SCL/_cPart21.l b/src/exp2python/python/SCL/_cPart21.l new file mode 100644 index 000000000..25cced1ba --- /dev/null +++ b/src/exp2python/python/SCL/_cPart21.l @@ -0,0 +1,1602 @@ +/* + * STEP Part 21 Parser + * + * Copyright (c) 2020, Christopher HORLER (cshorler@googlemail.com) + * + * All rights reserved. + * + * This file is part of the StepClassLibrary (SCL). + * + * 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. + * + * Neither the name of the nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define YYCTYPE unsigned char +#define YYCURSOR in->cur +#define YYLIMIT in->lim +#define YYMARKER in->mrk +#define YYCTXMARKER in->ctxmrk +#define YYFILL(n) do { \ + if (fill(in, n) != 0) { \ + fprintf(stderr, "lexer fill(...) failed, exiting\n"); \ + exit(1); \ + } \ + } while (0) + +/*!max:re2c*/ +#define INIT_BUF_SZ 4096 +#define INIT_STACK_SZ 64 + +/* reserved literals '(' ')' ';' '=' */ +#define T_P21_START 'S' +#define T_P21_END 'X' +#define T_HEADER 'H' +#define T_DATA 'D' +#define T_ENDSEC 'E' +#define T_EID 'I' +#define T_KEYWORD 'K' +#define T_VARIANT 'V' +#define T_EOF '\x00' +#define T_ERROR '\x01' + +#define V_REAL 'r' +#define V_INTEGER 'i' +#define V_STRING 's' +#define V_BINARY 'b' +#define V_ENUMERATION 'e' +#define V_EID T_EID +#define V_DERIVED '*' +#define V_EMPTY '$' + +#define P_FILE 'f' +#define P_HEADERSECTION 'h' +#define P_DATASECTION 'd' +#define P_HEADERENTITY 'x' +#define P_SIMPLEENTITY 's' +#define P_COMPLEXENTITY 'c' +#define P_SIMPLERECORD 'u' +#define P_LIST 'l' +#define P_PARAMETER 'p' + +int debug = 1; +#define dprintf(fmt, ...) \ + do { if (debug) fprintf(stderr, "%s:%3d " fmt, __FILE__, __LINE__, ##__VA_ARGS__); } while (0) + +/* ppfu https://stackoverflow.com/a/11763277/1162349 */ +#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME +#define _EXPAND(x) x + +/* for lookahead */ +#define PUSH_SYMBOL(...) _EXPAND(GET_MACRO(__VA_ARGS__, _4, _3, _PUSH_SYMBOL2, _PUSH_SYMBOL1)(__VA_ARGS__)) +#define _PUSH_SYMBOL1(token) in->sym[in->nsym++] = (Symbol){(token), 0, n, in->lineno, in->sp - in->basemrk} +#define _PUSH_SYMBOL2(token, vtype) in->sym[in->nsym++] = (Symbol){(token), (vtype), n, in->lineno, in->sp - in->basemrk} + +/* for parse stack */ +#define PUSH_TERMINAL(stack, sym) do { \ + Symbol it = (sym); \ + push((stack), it); \ + if (it.token == T_ERROR) goto err; \ + } while (0) + +#define PUSH_TERMINAL_EXT(cxt, stack, sym) do { \ + Symbol it = (sym); \ + push((stack), it); \ + if (it.token == T_ERROR) goto err; \ + else if (it.token == '(') (cxt) = (stack)->idx_top - 1; \ + else if (it.token == ')') (stack)->items[(cxt)].n = (stack)->idx_top - (cxt) - 1; \ + } while (0) + +/* test for one in a set of 1 to 4 e.g. {t0, t1, t2, t3} */ +#define LOOKAHEAD(x, ...) _EXPAND(GET_MACRO(__VA_ARGS__, _LOOKAHEAD4, _LOOKAHEAD3, _LOOKAHEAD2, _LOOKAHEAD1)(x, __VA_ARGS__)) +#define _LOOKAHEAD1(x, t0) ((t0) == (x).token) +#define _LOOKAHEAD2(x, t0, t1) ((t0) == (x).token || (t1) == (x).token) +#define _LOOKAHEAD3(x, t0, t1, t2) (_LOOKAHEAD2(x, t0, t1) || (t2) == (x).token) +#define _LOOKAHEAD4(x, t0, t1, t2, t3) (_LOOKAHEAD2(x, t0, t1) || _LOOKAHEAD2(x, t2, t3)) + + +/*!rules:re2c + ascii_encoding = [][!"*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_ ] | "''" | "\\\\" ; + page_encoding = "\\" [A-I] "\\" | "\\S\\" [][!"'*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_\\ ] ; + hex_encoding = "\\X2\\" ([0-9A-F]{4})+ "\\X0\\" | "\\X4\\" ([0-9A-F]{8})+ "\\X0\\" ; + byte_encoding = "\\X\\" [0-9A-F]{2} ; + + NL = ("\n" | "\r\n") ; + PUNCTUATION = [ ;()/] ; + + P21_START = "ISO-10303-21;" ; + P21_END = "END-ISO-10303-21;" ; + DATA = "DATA" ; + HEADER = "HEADER;" ; + ENDSEC = "ENDSEC;" ; + + WS = " " ; + KEYWORD = "!"? [A-Za-z_] [0-9A-Za-z_]* ; + REAL = [+-]* [0-9] [0-9]* "." [0-9]* ("E" [+-]* [0-9] [0-9]*)? ; + INTEGER = [+-]* [0-9] [0-9]* ; + STRING = "'" (ascii_encoding | page_encoding | hex_encoding | byte_encoding )* "'" ; + BINARY = '"' [0-3] [0-9A-F]* '"' ; + ENUMERATION = "." [A-Z_] [A-Z0-9_]* "." ; + EID = "#" [0-9]+ ; + + { n = in->cur - in->sp; } + WS+ { continue; } + NL { in->lineno++; continue; } + "/*" { lex_comment(in); continue; } + * { YYCURSOR--; break; } + + */ + + +/* lexeme */ +typedef struct { + uint8_t token; + union { + uint8_t vtype; + uint8_t errtoken; + }; + uint16_t n; + uint32_t lineno; + union { + ptrdiff_t offset; /* from basemrk */ + void *data; /* production allocation if applicable */ + }; +} Symbol; + +typedef struct SimpleRecord_ { + Symbol *kw; /* 'KEYWORD' */ + Symbol *args;/* '(' */ +} SimpleRecord; + +typedef struct SimpleRecord_ HeaderEntity; + +typedef struct { + Symbol *eid; /* '#' */ + Symbol *eq; /* '=' */ + Symbol *kw; /* 'KEYWORD' */ + Symbol *args;/* '(' */ +} SimpleEntity; + +typedef struct { + Symbol *eid; /* '#' */ + Symbol *eq; /* '=' */ + Symbol *subsupers;/* '(' */ +} ComplexEntity; + + +typedef struct { + FILE *file; + size_t bufsz; + unsigned char *cur, *mrk, *ctxmrk, *lim; + unsigned char *sp, *basemrk; + int eof; + uint32_t lineno; + int nsym; + Symbol sym[3]; + unsigned char *buf; +} Input; + +typedef struct { + int idx_top; + int idx_lim; + Symbol *items; +} Stack; + +/* LL(3) parser */ +typedef struct { + bool error; + bool hold; + Input *in; + Stack *stack; +} P21Parser; + +typedef void (p21_action_cb_t) (P21Parser *, int, void *); +typedef void (p21_error_cb_t) (P21Parser *, int, uint8_t); +typedef void (p21_ud_cb_t) (void *); + +typedef struct { + void *userdata; + p21_error_cb_t *error_cb; + p21_ud_cb_t *ud_init_cb; + p21_ud_cb_t *ud_exit_cb; + p21_action_cb_t *exchange_file_cb; + p21_action_cb_t *header_start_cb; + p21_action_cb_t *header_entity_list_cb; + p21_action_cb_t *data_section_list_cb; + p21_action_cb_t *data_start_cb; + p21_action_cb_t *header_entity_cb; + p21_action_cb_t *simple_entity_instance_cb; + p21_action_cb_t *complex_entity_instance_cb; + p21_action_cb_t *parameter_list_cb; + p21_action_cb_t *parameter_cb; + p21_action_cb_t *entity_instance_list_cb; + p21_action_cb_t *entity_instance_cb; + p21_action_cb_t *simple_record_list_cb; + p21_action_cb_t *simple_record_cb; +} P21ParserActions; + + +void report_error(P21Parser *, const char *); +void _recover(Input *, uint8_t, uint8_t, uint8_t); +Symbol lpop(Input *, uint8_t); + +void p21_parse(P21Parser *, P21ParserActions *); +void p21_exchange_file(P21Parser *, P21ParserActions *); +void p21_header_section(P21Parser *, P21ParserActions *); +void p21_header_entity_list(P21Parser *, P21ParserActions *); +void p21_header_entity(P21Parser *, P21ParserActions *); +void p21_data_section_list(P21Parser *, P21ParserActions *); +void p21_data_section(P21Parser *, P21ParserActions *); +void p21_entity_instance(P21Parser *, P21ParserActions *); +void p21_simple_entity_instance(P21Parser *, P21ParserActions *); +void p21_complex_entity_instance(P21Parser *, P21ParserActions *); +void p21_entity_instance_list(P21Parser *, P21ParserActions *); +void p21_parameter(P21Parser *, P21ParserActions *); +void p21_parameter_list(P21Parser *, P21ParserActions *); +void p21_simple_record(P21Parser *, P21ParserActions *); +void p21_simple_record_list(P21Parser *, P21ParserActions *); + + +void push(Stack *stack, Symbol it) { + if (stack->idx_top == stack->idx_lim) { + Symbol *nitems = realloc(stack->items, 2 * stack->idx_lim * sizeof stack->items[0]); + if (!nitems) { + fprintf(stderr, "failed to grow parser stack, memory exhausted\n"); + exit(1); + } + stack->items = nitems; + stack->idx_lim *= 2; + } + + stack->items[stack->idx_top++] = it; +} + +/* mock implementations */ +void drop(Stack *stack, uint32_t n) { + assert(stack->idx_top >= n); + stack->idx_top -= n; +} + +void unwind(Stack *stack, int bsp) { + stack->idx_top = bsp; +} + +Symbol *pop(Stack *stack) { + assert(stack->idx_top >= 1); + stack->idx_top--; + return stack->items + stack->idx_top; +} + +Symbol *peek(Stack *stack) { + assert(stack->idx_top >= 1); + return stack->items + stack->idx_top - 1; +} + +Symbol lpop(Input *in, uint8_t token) { + Symbol *stack = in->sym; + Symbol sym = stack[0]; + + /* missing input or unexpected lookahead token */ + if (in->nsym == 0) + return (Symbol){T_ERROR, token, 0, in->lineno}; + else if (sym.token != token) + return (Symbol){T_ERROR, token, 0, sym.lineno}; + + if (!--in->nsym) { + memset(&in->sym[0], 0, sizeof in->sym[0]); + } else { + memmove(&in->sym[0], &in->sym[1], in->nsym * sizeof in->sym[0]); + memset(&in->sym[in->nsym], 0, sizeof in->sym[0]); + } + + return sym; +} + +static int fill(Input *in, size_t need) +{ + size_t free; + unsigned char *newbuf; + + if (in->eof) { + return 1; + } + free = in->basemrk - in->buf; + if (free < need) { + newbuf = realloc(in->buf, 2 * in->bufsz + YYMAXFILL); + if (!newbuf) { + fprintf(stderr, "fatal - buffer memory exhausted, exiting\n"); + return 2; + } + in->bufsz *= 2; + in->lim = newbuf + (in->lim - in->buf); + in->cur = newbuf + (in->cur - in->buf); + in->mrk = newbuf + (in->mrk - in->buf); + in->ctxmrk = newbuf + (in->ctxmrk - in->buf); + in->basemrk = newbuf + (in->basemrk - in->buf); + in->sp = newbuf + (in->sp - in->buf); + in->buf = newbuf; + + /* don't memmove() here! */ + free = (in->buf + in->bufsz) - in->lim; + } else { + memmove(in->buf, in->basemrk, in->lim - in->basemrk); + in->lim -= free; + in->cur -= free; + in->mrk -= free; + in->ctxmrk -= free; + in->basemrk -= free; + in->sp -= free; + } + + in->lim += fread(in->lim, 1, free, in->file); + if (in->lim < in->buf + in->bufsz) { + in->eof = 1; + memset(in->lim, 0, YYMAXFILL); + in->lim += YYMAXFILL; + } + return 0; +} + +static void p21_init(P21Parser *p, FILE *file) +{ + Stack *stack; + Input *in; + + in = malloc(sizeof *in); + if (!in) + goto err; + memset(in, 0, sizeof *in); + in->bufsz = INIT_BUF_SZ; + in->buf = malloc(INIT_BUF_SZ + YYMAXFILL); + if (!in->buf) + goto err; + in->file = file; + in->cur = in->basemrk = in->sp = in->lim = in->buf + INIT_BUF_SZ; + in->lineno = 1; + fill(in, 1); + + stack = malloc(sizeof *stack); + if (!stack) + goto err; + memset(stack, 0, sizeof *stack); + stack->idx_lim = 16; + stack->idx_top = 0; + stack->items = malloc(stack->idx_lim * sizeof stack->items[0]); + if (!stack->items) + goto err; + + p->in = in; + p->stack = stack; + p->error = false; + + return; + +err: + fprintf(stderr, "failed to initialise parser\n"); + exit(1); +} + +/* noop error handler */ +void default_error_handler(P21Parser *p, int bsp, uint8_t t) { + Symbol *sym = peek(p->stack); + if (sym->token == T_ERROR) + pop(p->stack); + push(p->stack, (Symbol){t}); +} + +/* TODO: this needs to be reworked */ +void report_error(P21Parser *p, const char *cxt) { + Input *in = p->in; + Symbol *it = peek(p->stack); + int lineno; + unsigned char *cur; + + fprintf(stderr, cxt); + + if (it->token == T_ERROR) { + fprintf(stderr, " syntax error - line: %d\n", it->lineno); + fprintf(stderr, " expected '%c' (token type) ", it->errtoken); + } else { + cur = in->cur; + lineno = in->lineno; + while (1) { + if (*(cur - 2) == '\r' && *(cur - 1) == '\n') { cur -= 2; --lineno; } + else if (*(cur - 1) == '\n') { --cur; --lineno; } + else { break; } + } + fprintf(stderr, " syntax error - line: %d\n", lineno); + } + + if (!in->nsym) { + cur = in->cur; + lineno = in->lineno; + while (1) { + if (*cur == '\r' && *(cur + 1) == '\n') { cur -= 2; --lineno; } + else if (*cur == '\n') { --cur; --lineno; } + else { break; } + } + fprintf(stderr, " unexpected character '%c' (line: %d)\n", *cur, lineno); + } else { + fprintf(stderr, " got '%c' (token type)\n", in->sym[0].token); + } +} + + +void lex_comment(Input *in) { + size_t n; + int comment_lvl = 1; + + while (1) { + in->sp = in->cur; + /*!use:re2c + NOT_SLASH_STAR = [][!"#$%&'()+,\-.:;<=>?@\\^`{|}~0-9A-Z_a-z ] ; + + "*"+ "/" { + if (!--comment_lvl) { break; } + else { continue; } + } + "*"+ { continue; } + NOT_SLASH_STAR+ { continue; } + "/" { continue; } + "/*" { ++comment_lvl; continue; } */ + } + + return; + +err: + fprintf(stderr, "invalid character in comment, exiting\n"); + exit(1); +} + +#define recover(in, ...) GET_MACRO(__VA_ARGS__, _4, _RECOVER3, _RECOVER2, _RECOVER1)(in, __VA_ARGS__) +#define _RECOVER1(in, u0) _recover((in), (u0), 0U, 0U) +#define _RECOVER2(in, u0, u1) _recover((in), (u0), (u1), 0U) +#define _RECOVER3(in, u0, u1, u2) _recover((in), (u0), (u1), (u2)) + +void _recover(Input *in, uint8_t u0, uint8_t u1, uint8_t u2) { + size_t n; + Symbol sym; + + while (in->nsym) { + if (LOOKAHEAD(in->sym[0], u0, u1, u2, T_EOF)) + break; + --in->nsym; + memmove(&in->sym[0], &in->sym[1], in->nsym * sizeof in->sym[0]); + memset(&in->sym[in->nsym], 0, sizeof in->sym[0]); + } + + if (in->nsym) + return; + + while (1) { + in->sp = in->cur; + /*!use:re2c + P21_START { sym = (Symbol){T_P21_START}; goto check; } + P21_END { sym = (Symbol){T_P21_END}; goto check; } + HEADER { sym = (Symbol){T_HEADER}; goto check; } + DATA / PUNCTUATION { sym = (Symbol){T_DATA}; goto check; } + ENDSEC { sym = (Symbol){T_ENDSEC}; goto check; } + EID { sym = (Symbol){T_EID}; goto check; } + KEYWORD { sym = (Symbol){T_KEYWORD}; goto check; } + REAL { sym = (Symbol){T_VARIANT, V_REAL}; goto check; } + INTEGER { sym = (Symbol){T_VARIANT, V_INTEGER}; goto check; } + STRING { sym = (Symbol){T_VARIANT, V_STRING}; goto check; } + BINARY { sym = (Symbol){T_VARIANT, V_BINARY}; goto check; } + ENUMERATION { sym = (Symbol){T_VARIANT, V_ENUMERATION}; goto check; } + "*" { sym = (Symbol){T_VARIANT, V_DERIVED}; goto check; } + "$" { sym = (Symbol){T_VARIANT, V_EMPTY}; goto check; } + [();] { sym = (Symbol){*in->sp}; goto check; } + */ +check: + if (LOOKAHEAD(sym, u0, u1, u2, T_EOF)) { + PUSH_SYMBOL(sym.token, sym.vtype); + break; + } + } + + return; + +err: + fprintf(stderr, "fatal, failed to resolve follow set (%c, %c, %c)\n", u0, u1, u2); + exit(1); +} + + +/* + * P21Parser + */ +void p21_parse(P21Parser *p, P21ParserActions *act) { + if (act->ud_init_cb) + act->ud_init_cb(act->userdata); + + p21_exchange_file(p, act); + + if (act->ud_exit_cb) + act->ud_exit_cb(act->userdata); + + assert(p->stack->idx_top == 1); + return; + +err: + report_error(p, "exchange_file' << 0 >>\n"); +} + +void p21_exchange_file(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + P21_START { PUSH_SYMBOL(T_P21_START); continue;} */ + } + PUSH_TERMINAL(p->stack, lpop(in, T_P21_START)); + + p21_header_section(p, act); + p21_data_section_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_P21_END)); + + if (p->error) + goto err; + + /* user action */ + if (act->exchange_file_cb) + act->exchange_file_cb(p, bsp, act->userdata); + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_FILE}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "exchange_file << 1 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_FILE); + else default_error_handler(p, bsp, P_FILE); + recover(in, T_EOF); +} + +void p21_header_section(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix = 'yya'; + HEADER { PUSH_SYMBOL(T_HEADER); continue; } */ + } + PUSH_TERMINAL(p->stack, lpop(in, T_HEADER)); + + /* section callback */ + if (act->header_start_cb) + act->header_start_cb(p, bsp, act->userdata); + + /* mandatory headers */ + p21_header_entity(p, act); + p21_header_entity(p, act); + p21_header_entity(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix = 'yyb'; + ENDSEC { PUSH_SYMBOL(T_ENDSEC); continue; } + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } */ + } + + /* optional headers */ + if (LOOKAHEAD(in->sym[0], T_KEYWORD)) + p21_header_entity_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_ENDSEC)); + + if (p->error) + goto err; + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_HEADERSECTION}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "header_section << 2 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_HEADERSECTION); + else default_error_handler(p, bsp, P_HEADERSECTION); + recover(in, T_DATA); +} + +void p21_data_section_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + uint32_t len = 0; + Input *in = p->in; + + do { + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + DATA / PUNCTUATION { PUSH_SYMBOL(T_DATA); continue; } + P21_END { PUSH_SYMBOL(T_P21_END); continue; } */ + } + if (!LOOKAHEAD(in->sym[0], T_DATA)) + break; + p21_data_section(p, act); + } while (++len); + + /* one or more */ + if (!len) { + push(p->stack, (Symbol){T_ERROR, T_DATA, 0, in->sym[0].lineno}); + p->error = true; + } + + if(p->error) + goto err; + + /* user action */ + if (act->data_section_list_cb) + act->data_section_list_cb(p, bsp, act->userdata); + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "data_section_list << 3 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_P21_END); +} + +void p21_data_section(P21Parser *p, P21ParserActions *act) { + size_t n, cxt; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 2) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix = 'yya'; + [(;] { PUSH_SYMBOL(*in->sp); continue; } */ + } + PUSH_TERMINAL(p->stack, lpop(in, T_DATA)); + + if (LOOKAHEAD(in->sym[0], '(')) { + PUSH_TERMINAL(p->stack, lpop(in, '(')); + + p21_parameter_list(p, act); + while (in->nsym < 2) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix = 'yyb'; + ";" { PUSH_SYMBOL(';'); continue; } */ + } + + PUSH_TERMINAL(p->stack, lpop(in, ')')); + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (act->data_start_cb) + act->data_start_cb(p, bsp, act->userdata); + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix = 'yyc'; + ENDSEC { PUSH_SYMBOL(T_ENDSEC); continue; } + EID { PUSH_SYMBOL(T_EID); continue; } */ + } + if (LOOKAHEAD(in->sym[0], T_EID)) + p21_entity_instance_list(p, act); + + PUSH_TERMINAL(p->stack, lpop(in, T_ENDSEC)); + + if (p->error) + goto err; + + /* default reduction */ + p->stack->items[bsp] = (Symbol){P_DATASECTION}; + drop(p->stack, p->stack->idx_top - bsp - 1); + + return; + +err: + report_error(p, "data_section << 4 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_DATASECTION); + else default_error_handler(p, bsp, P_DATASECTION); + recover(in, T_P21_END, T_DATA); +} + +void p21_header_entity(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + /* set KEYWORD as basemrk to prevent fill() recycling the buffer before user action */ + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } */ + } + + /* set KEYWORD as basemrk to prevent fill() recycling the buffer before user action */ + assert(in->nsym == 1); + in->basemrk += in->sym[0].offset; + in->sym[0].offset = 0; + + p21_simple_record(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + ";" { PUSH_SYMBOL(';'); continue; } */ + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->header_entity_cb) + act->header_entity_cb(p, bsp, act->userdata); + + /* reduction */ + assert(!p->hold); + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_HEADERENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "header_entity << 5 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_HEADERENTITY); + else default_error_handler(p, bsp, P_HEADERENTITY); + recover(in, T_ENDSEC, T_KEYWORD); +} + +void p21_header_entity_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_header_entity(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } + ENDSEC { PUSH_SYMBOL(T_ENDSEC); continue; } */ + } + if (!LOOKAHEAD(in->sym[0], T_KEYWORD)) + break; + p21_header_entity(p, act); + } while (1); + + if (p->error) + goto err; + + + /* user action */ + if (act->header_entity_list_cb) + act->header_entity_list_cb(p, bsp, act->userdata); + + /* reduction */ + assert(!p->hold); + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "header_entity_list << 6 >>"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC); +} + +void p21_entity_instance_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_entity_instance(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + EID { PUSH_SYMBOL(T_EID); continue; } + ENDSEC { PUSH_SYMBOL(T_ENDSEC); continue; } */ + } + if (!LOOKAHEAD(in->sym[0], T_EID)) + break; + p21_entity_instance(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->entity_instance_list_cb) + act->entity_instance_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "entity_instance_list << 7 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC); +} + +void p21_parameter_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_parameter(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + [,)] { PUSH_SYMBOL(*in->sp); continue; } */ + } + if (LOOKAHEAD(in->sym[0], ')')) + break; + + PUSH_TERMINAL(p->stack, lpop(in, ',')); + p21_parameter(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->parameter_list_cb) + act->parameter_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "parameter_list << 8 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, ')', ';'); +} + +void p21_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + /* set EID as basemrk to prevent fill() recycling the buffer before user action */ + assert(in->nsym == 1); + in->basemrk += in->sym[0].offset; + in->sym[0].offset = 0; + + while (in->nsym < 3) { + in->sp = in->cur; + /*!use:re2c + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } + [(=] { PUSH_SYMBOL(*in->sp); continue; } */ + } + if (!LOOKAHEAD(in->sym[0], T_EID) || !LOOKAHEAD(in->sym[1], '=')) + goto err; + + if (LOOKAHEAD(in->sym[2], T_KEYWORD)) { + p21_simple_entity_instance(p, act); + } else if (LOOKAHEAD(in->sym[2], '(')) { + p21_complex_entity_instance(p, act); + } + + if (p->error) + goto err; + + /* user action */ + if (act->entity_instance_cb) + act->entity_instance_cb(p, bsp, act->userdata); + + /* no default reduction */ + + return; + +err: + report_error(p, "entity_instance << 9 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, T_ENDSEC, T_EID); +} + +void p21_simple_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + PUSH_TERMINAL(p->stack, lpop(in, T_EID)); + PUSH_TERMINAL(p->stack, lpop(in, '=')); + + p21_simple_record(p, act); + + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + ";" { PUSH_SYMBOL(';'); continue; } */ + } + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_entity_instance_cb) + act->simple_entity_instance_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_SIMPLEENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_entity_instance << 10 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_SIMPLEENTITY); + else default_error_handler(p, bsp, P_SIMPLEENTITY); + recover(in, T_ENDSEC, T_EID); +} + + +void p21_complex_entity_instance(P21Parser *p, P21ParserActions *act) { + size_t n, c; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + PUSH_TERMINAL(p->stack, lpop(in, T_EID)); + PUSH_TERMINAL(p->stack, lpop(in, '=')); + PUSH_TERMINAL_EXT(c, p->stack, lpop(in, '(')); + + p21_simple_record_list(p, act); + + while (in->nsym < 2) { + in->sp = in->cur; + /*!use:re2c + ";" { PUSH_SYMBOL(';'); continue; } */ + } + + PUSH_TERMINAL_EXT(c, p->stack, lpop(in, ')')); + PUSH_TERMINAL(p->stack, lpop(in, ';')); + + if (p->error) + goto err; + + /* user action */ + if (act->complex_entity_instance_cb) + act->complex_entity_instance_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_COMPLEXENTITY}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "complex_entity_instance << 11 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_COMPLEXENTITY); + else default_error_handler(p, bsp, P_COMPLEXENTITY); + recover(in, T_ENDSEC, T_EID); +} + +void p21_simple_record(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 3) { + in->sp = in->cur; + /*!use:re2c + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } + REAL { PUSH_SYMBOL(T_VARIANT, V_REAL); continue; } + INTEGER { PUSH_SYMBOL(T_VARIANT, V_INTEGER); continue; } + STRING { PUSH_SYMBOL(T_VARIANT, V_STRING); continue; } + BINARY { PUSH_SYMBOL(T_VARIANT, V_BINARY); continue; } + ENUMERATION { PUSH_SYMBOL(T_VARIANT, V_ENUMERATION); continue; } + EID { PUSH_SYMBOL(T_VARIANT, V_EID); continue; } + "*" { PUSH_SYMBOL(T_VARIANT, V_DERIVED); continue; } + "$" { PUSH_SYMBOL(T_VARIANT, V_EMPTY); continue; } + [()] { PUSH_SYMBOL(*in->sp); continue; } */ + } + + PUSH_TERMINAL(p->stack, lpop(in, T_KEYWORD)); + PUSH_TERMINAL_EXT(n, p->stack, lpop(in, '(')); + + if (LOOKAHEAD(in->sym[0], '(', T_KEYWORD, T_VARIANT)) + p21_parameter_list(p, act); + + PUSH_TERMINAL_EXT(n, p->stack, lpop(in, ')')); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_record_cb) + act->simple_record_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_SIMPLERECORD}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_record << 12 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_SIMPLERECORD); + else default_error_handler(p, bsp, P_SIMPLERECORD); + recover(in, ';', ')', T_KEYWORD); +} + +void p21_simple_record_list(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + p21_simple_record(p, act); + + do { + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } + ")" { PUSH_SYMBOL(')'); continue; } */ + } + if (!LOOKAHEAD(in->sym[0], T_KEYWORD)) + break; + p21_simple_record(p, act); + } while (1); + + if (p->error) + goto err; + + /* user action */ + if (act->simple_record_list_cb) + act->simple_record_list_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_LIST}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "simple_record_list << 13 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_LIST); + else default_error_handler(p, bsp, P_LIST); + recover(in, ')', ';'); +} + +void p21_parameter(P21Parser *p, P21ParserActions *act) { + size_t n; + uint32_t bsp = p->stack->idx_top; + Input *in = p->in; + + while (in->nsym < 2) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix='yya'; + KEYWORD { PUSH_SYMBOL(T_KEYWORD); continue; } + REAL { PUSH_SYMBOL(T_VARIANT, V_REAL); continue; } + INTEGER { PUSH_SYMBOL(T_VARIANT, V_INTEGER); continue; } + STRING { PUSH_SYMBOL(T_VARIANT, V_STRING); continue; } + BINARY { PUSH_SYMBOL(T_VARIANT, V_BINARY); continue; } + ENUMERATION { PUSH_SYMBOL(T_VARIANT, V_ENUMERATION); continue; } + EID { PUSH_SYMBOL(T_VARIANT, V_EID); continue; } + "*" { PUSH_SYMBOL(T_VARIANT, V_DERIVED); continue; } + "$" { PUSH_SYMBOL(T_VARIANT, V_EMPTY); continue; } + [(),] { PUSH_SYMBOL(*in->sp); continue; } */ + } + + if (LOOKAHEAD(in->sym[0], T_VARIANT)) { + PUSH_TERMINAL(p->stack, lpop(in, T_VARIANT)); + } else { + if (LOOKAHEAD(in->sym[0], T_KEYWORD)) { + PUSH_TERMINAL(p->stack, lpop(in, T_KEYWORD)); + PUSH_TERMINAL(p->stack, lpop(in, '(')); + p21_parameter(p, act); + } else { + PUSH_TERMINAL(p->stack, lpop(in, '(')); + if (LOOKAHEAD(in->sym[0], '(', T_KEYWORD, T_VARIANT)) { + p21_parameter_list(p, act); + } + } + while (in->nsym < 1) { + in->sp = in->cur; + /*!use:re2c re2c:labelprefix='yyb'; + ")" { PUSH_SYMBOL(')'); continue; } */ + } + PUSH_TERMINAL(p->stack, lpop(in, ')')); + } + + if (p->error) + goto err; + + /* user action */ + if (act->parameter_cb) + act->parameter_cb(p, bsp, act->userdata); + + /* reduction */ + if (!p->hold) { + p->stack->items[bsp] = (Symbol){P_PARAMETER}; + drop(p->stack, p->stack->idx_top - bsp - 1); + } + + return; + +err: + report_error(p, "parameter << 14 >>\n"); + if (act->error_cb) act->error_cb(p, bsp, P_PARAMETER); + else default_error_handler(p, bsp, P_PARAMETER); + recover(in, ')', ',', ';'); +} + +void mock_error(P21Parser *, int, uint8_t); +void mock_ud_init(void *); +void mock_ud_exit(void *); +void mock_exchange_file(P21Parser *, int, void *); +void mock_header_start(P21Parser *, int, void *); +void mock_header_entity_list(P21Parser *, int, void *); +void mock_data_section_list(P21Parser *, int, void *); +void mock_data_start(P21Parser *, int, void *); +void mock_header_entity(P21Parser *, int, void *); +void mock_simple_entity_instance(P21Parser *, int, void *); +void mock_complex_entity_instance(P21Parser *, int, void *); +void mock_parameter_list(P21Parser *, int, void *); +void mock_parameter(P21Parser *, int, void *); +void mock_entity_instance_list(P21Parser *, int, void *); +void mock_entity_instance(P21Parser *, int, void *); +void mock_simple_record_list(P21Parser *, int, void *); +void mock_simple_record(P21Parser *, int, void *); +void mock_noop(P21Parser *, int, void *); + +typedef struct { + sqlite3 *db; + sqlite3_stmt *sec_stmt; + sqlite3_stmt *sei_stmt; + sqlite3_stmt *cei_stmt; + sqlite3_stmt *hei_stmt; + int section_idx; +} P21UserData; + +P21UserData mockdata = {0}; + +P21ParserActions mockact = { + .userdata = &mockdata, + .error_cb = mock_error, + .ud_init_cb = mock_ud_init, + .ud_exit_cb = mock_ud_exit, + .header_start_cb = mock_header_start, + .data_start_cb = mock_data_start, + .exchange_file_cb = NULL, + .header_entity_list_cb = NULL, + .data_section_list_cb = NULL, + .header_entity_cb = mock_header_entity, + .simple_entity_instance_cb = mock_simple_entity_instance, + .complex_entity_instance_cb = mock_complex_entity_instance, + .parameter_list_cb = mock_noop, + .parameter_cb = mock_noop, + .entity_instance_list_cb = NULL, + .entity_instance_cb = NULL, + .simple_record_list_cb = mock_noop, + .simple_record_cb = mock_noop +}; + +void mock_error(P21Parser *p, int bsp, uint8_t cxt) { + switch (cxt) { + case P_SIMPLEENTITY: + case P_COMPLEXENTITY: + case P_HEADERENTITY: + dprintf("caught error: '%c'\n", cxt); + p->error = false; + drop(p->stack, p->stack->idx_top - bsp - 1); + break; + default: + p->error = true; + break; + } +} + + +void mock_ud_init(void *d) { + P21UserData *ud = d; + char ddl_sql[] = + "PRAGMA foreign_keys = ON;\n" + "CREATE TABLE entity_enum (type TEXT(1) PRIMARY KEY);\n" + "INSERT INTO entity_enum (type) VALUES ('S'), ('C');\n" + "CREATE TABLE section_enum (type TEXT(1) PRIMARY KEY);\n" + "INSERT INTO section_enum (type) VALUES ('D'), ('H');\n" + + "CREATE TABLE section_table (\n" + " id INTEGER PRIMARY KEY,\n" + " lineno INTEGER NOT NULL,\n" + " section_type TEXT(1) NOT NULL REFERENCES section_enum(type)\n" + ");\n" + + "CREATE TABLE section_headers (\n" + " id INTEGER PRIMARY KEY,\n" + " type_name TEXT COLLATE NOCASE,\n" + " raw_data TEXT NOT NULL,\n" + " lineno INTEGER NOT NULL,\n" + " fk_section INTEGER NOT NULL REFERENCES section_table(id)\n" + ");\n" + + "CREATE TABLE data_table (\n" + " id TEXT PRIMARY KEY,\n" + " type_name TEXT COLLATE NOCASE,\n" + " raw_data TEXT NOT NULL,\n" + " lineno INTEGER NOT NULL,\n" + " entity_type TEXT(1) NOT NULL REFERENCES entity_enum(type),\n" + " fk_section INTEGER NOT NULL REFERENCES section_table(id)\n" + ") WITHOUT ROWID;\n" + + "BEGIN DEFERRED TRANSACTION;"; + + char sei_sql[] = "INSERT INTO data_table VALUES (?,?,?,?,'S',?)"; + char cei_sql[] = "INSERT INTO data_table VALUES (?,NULL,?,?,'C',?)"; + char hei_sql[] = "INSERT INTO section_headers(type_name, raw_data, lineno, fk_section) VALUES (?, ?, ?, ?)"; + int rc; + + rc = sqlite3_open_v2(":memory:", &ud->db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); + + /* TODO: read ddl sql from external file */ + rc = sqlite3_exec(ud->db, ddl_sql, NULL, NULL, NULL); + + rc |= sqlite3_prepare_v3(ud->db, sei_sql, sizeof sei_sql, SQLITE_PREPARE_PERSISTENT, &ud->sei_stmt, NULL); + rc |= sqlite3_prepare_v3(ud->db, cei_sql, sizeof cei_sql, SQLITE_PREPARE_PERSISTENT, &ud->cei_stmt, NULL); + rc |= sqlite3_prepare_v3(ud->db, hei_sql, sizeof hei_sql, SQLITE_PREPARE_PERSISTENT, &ud->hei_stmt, NULL); + + if (rc != SQLITE_OK) + exit(1); + + ud->section_idx = 0; +} + +void mock_ud_exit(void *d) { + P21UserData *ud = d; + int rc; + char ddl_sql[] = + "CREATE INDEX ix_type_name ON data_table(type_name);\n" + "CREATE INDEX ix_entity_type ON data_table(entity_type);\n" + "CREATE INDEX ix_fk_section ON data_table(fk_section);"; + + rc = sqlite3_finalize(ud->sei_stmt); + rc |= sqlite3_finalize(ud->cei_stmt); + rc |= sqlite3_finalize(ud->hei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_exec(ud->db, "COMMIT TRANSACTION", NULL, NULL, NULL); + if (rc != SQLITE_OK) goto err; + + /* TODO: benchmark index creation here vs on db init */ + rc = sqlite3_exec(ud->db, ddl_sql, NULL, NULL, NULL); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_close(ud->db); + if (rc != SQLITE_OK) goto err; + + return; +err: + dprintf("db error\n"); + exit(1); +} + +void mock_exchange_file(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_header_start(P21Parser *p, int bsp, void *d) { + char sec_sql[] = "INSERT INTO section_table VALUES(?,?,'H')"; + Stack *s = p->stack; + P21UserData *ud = d; + Symbol *t = s->items + bsp; + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(ud->db, sec_sql, sizeof sec_sql, &stmt, NULL); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_bind_int(stmt, 1, ++ud->section_idx); + rc |= sqlite3_bind_int(stmt, 2, t->lineno); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_step(stmt); + if (rc != SQLITE_DONE) goto err; + + sqlite3_finalize(stmt); + + /* + s->items[bsp] = (Symbol){P_HEADERSECTION}; + drop(s, s->idx_top - bsp - 1); + */ + + return; + +err: + dprintf("db error\n"); + exit(1); +} +void mock_header_entity_list(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_data_section_list(P21Parser *p, int bsp, void *d) { Stack *s = p->stack; } +void mock_data_start(P21Parser *p, int bsp, void *d) { + char sec_sql[] = "INSERT INTO section_table VALUES(?,?,'D')"; + Stack *s = p->stack; + P21UserData *ud = d; + Symbol *t = s->items + bsp; + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(ud->db, sec_sql, sizeof sec_sql, &stmt, NULL); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_bind_int(stmt, 1, ++ud->section_idx); + rc |= sqlite3_bind_int(stmt, 2, t->lineno); + if (rc != SQLITE_OK) goto err; + + rc |= sqlite3_step(stmt); + if (rc!= SQLITE_DONE) goto err; + + sqlite3_finalize(stmt); + + return; + +err: + dprintf("db error\n"); + exit(1); +} + +void mock_header_entity(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + HeaderEntity e = {s->items + bsp, s->items + bsp + 1}; + size_t i, nargs = e.args->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) args member before bind */ + e.args->offset = (e.args + 1)->offset; + e.args->n = (e.args + 1)->n; + for (i = 2, ep = e.args->offset + 1; i < nargs; i++) { + Symbol *t = e.args + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.args->n = ep - e.args->offset; + + rc = sqlite3_reset(ud->hei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->hei_stmt, 1, basemrk + e.kw->offset, e.kw->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->hei_stmt, 2, basemrk + e.args->offset, e.args->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->hei_stmt, 3, e.kw->lineno); + rc |= sqlite3_bind_int(ud->hei_stmt, 4, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->hei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + return; + +err: + mock_error(p, bsp, P_HEADERENTITY); + dprintf("db error\n"); +} + +void mock_simple_entity_instance(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + SimpleEntity e = {s->items + bsp, s->items + bsp + 1, s->items + bsp + 2, s->items + bsp + 3}; + size_t i, nargs = e.args->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) args before bind */ + e.args->offset = (e.args + 1)->offset; + e.args->n = (e.args + 1)->n; + for (i = 2, ep = e.args->offset + e.args->n; i < nargs; i++) { + Symbol *t = e.args + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.args->n = ep - e.args->offset; + + /* */ + rc = sqlite3_reset(ud->sei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->sei_stmt, 1, basemrk + e.eid->offset, e.eid->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->sei_stmt, 2, basemrk + e.kw->offset, e.kw->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->sei_stmt, 3, basemrk + e.args->offset, e.args->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->sei_stmt, 4, e.eid->lineno); + rc |= sqlite3_bind_int(ud->sei_stmt, 5, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->sei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + + return; + +err: + mock_error(p, bsp, P_SIMPLEENTITY); + dprintf("db error\n"); +} + + +void mock_complex_entity_instance(P21Parser *p, int bsp, void *d) { + Stack *s = p->stack; + P21UserData *ud = d; + ComplexEntity e = {s->items + bsp, s->items + bsp + 1, s->items + bsp + 2}; + size_t i, nsubsupers = e.subsupers->n; + unsigned char *basemrk = p->in->basemrk; + ptrdiff_t ep; + int rc; + + /* rewrite (normalise) list before bind */ + for (i = 1, ep = e.subsupers->offset + 1; i < nsubsupers; i++) { + Symbol *t = e.subsupers + i; + if (t->token == '(') t->n = 1; + if (ep != t->offset) memmove(basemrk + ep, basemrk + t->offset, t->n); + ep += t->n; + } + e.subsupers->n = ep - e.subsupers->offset; + + rc = sqlite3_reset(ud->cei_stmt); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_bind_text(ud->cei_stmt, 1, basemrk + e.eid->offset, e.eid->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_text(ud->cei_stmt, 2, basemrk + e.subsupers->offset, e.subsupers->n, SQLITE_TRANSIENT); + rc |= sqlite3_bind_int(ud->cei_stmt, 3, e.eid->lineno); + rc |= sqlite3_bind_int(ud->cei_stmt, 4, ud->section_idx); + if (rc != SQLITE_OK) goto err; + + rc = sqlite3_step(ud->cei_stmt); + if (rc != SQLITE_DONE) goto err; + + p->hold = false; + return; + +err: + mock_error(p, bsp, P_COMPLEXENTITY); + dprintf("db error \n"); +} + +void mock_parameter_list(P21Parser *p, int bsp, void *d) { } +void mock_parameter(P21Parser *p, int bsp, void *d) { } +void mock_entity_instance_list(P21Parser *p, int bsp, void *d) { } +void mock_entity_instance(P21Parser *p, int bsp, void *d) { } +void mock_simple_record_list(P21Parser *p, int bsp, void *d) { } +void mock_simple_record(P21Parser *p, int bsp, void *d) {} + +void mock_noop(P21Parser *p, int bsp, void *d) { + p->hold = true; +} + +int main(char *argv[], int argc) { + const char *paths[] = { + "/home/chorler/projects/src/stepcode/test/p21/test_array_bounds_FAIL1.p21", + "/home/chorler/projects/src/stepcode/test/p21/comments.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_inverse_attr.p21", + "/home/chorler/projects/src/stepcode/test/p21/missing_and_required.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_array_bounds.p21", + "/home/chorler/projects/src/stepcode/test/p21/test_inherit_inverse.p21", + "/home/chorler/projects/src/stepcode/data/ap214e3/as1-oc-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/dm1-id-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD_BACK.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD_FRONT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY_FRONT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT_BACK_000.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT_FRONT_000.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/MAINBODY_BACK.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/HEAD.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL_TURBINE.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/TAIL_MIDDLE_PART.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/s1-c5-214/FOOT.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/sg1-c5-214.stp", + "/home/chorler/projects/src/stepcode/data/ap214e3/io1-cm-214.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS3Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS4-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS7Mod0-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS2Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS8Mod0-outresult.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS10-out.stp", + "/home/chorler/projects/src/stepcode/data/ap209/ATS1-out.stp" + }; + + P21Parser myp; + P21UserData mydata; + FILE *fp; + memset(&mydata, 0, sizeof mydata); + + for (unsigned int i = 0; i < (sizeof paths / sizeof paths[0]); i++) { + fp = fopen(paths[i], "rb"); + if (!fp) { fprintf(stderr, "failed to read input: %s\n", paths[i]); continue; } + else { fprintf(stderr, "processing: %s\n", paths[i]); } + p21_init(&myp, fp); + p21_parse(&myp, &mockact); + } +} From 0f303d5c062a93f78c0755d6cfe5accdd05e5897 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 23 Mar 2020 12:57:23 +0000 Subject: [PATCH 174/244] Part21 alternative Lexer / Parser specification populates an sqlite database --- src/exp2python/python/SCL/cPart21.py | 586 +++++++++++++++++++++++++++ 1 file changed, 586 insertions(+) create mode 100644 src/exp2python/python/SCL/cPart21.py diff --git a/src/exp2python/python/SCL/cPart21.py b/src/exp2python/python/SCL/cPart21.py new file mode 100644 index 000000000..94eeedc61 --- /dev/null +++ b/src/exp2python/python/SCL/cPart21.py @@ -0,0 +1,586 @@ +# +# STEP Part 21 Parser +# +# Copyright (c) 2020, Christopher HORLER (cshorler@googlemail.com) +# +# All rights reserved. +# +# This file is part of the StepClassLibrary (SCL). +# +# 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. +# +# Neither the name of the nor the names of its contributors may +# be used to endorse or promote products derived from this software without +# specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import logging +import os.path, sqlite3, datetime, tempfile + +import re +import ply.lex as lex +import ply.yacc as yacc +from ply.lex import LexError, TOKEN + +logger = logging.getLogger(__name__) +#logger.addHandler(logging.NullHandler()) + +# assemble catchall regexp +p21_real = r'(?:[+-]*[0-9][0-9]*\.[0-9]*(?:E[+-]*[0-9][0-9]*)?)' +p21_integer = r'(?:[+-]*[0-9][0-9]*)' +p21_string = r"""(?x)(?:' + (?: + # basic string + [][!"*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_ ]|''|\\\\| + # \P\A, \P\B, ... --> iso8859-1, iso8859-2,... applicable to following \S\c directives + \\P[A-I]\\| + # page control directive \S\c + \\S\\[][!"'*$%&.#+,\-()?/:;<=>@{}|^`~0-9a-zA-Z_\\ ]| + # hex string encodings + \\X2\\(?:[0-9A-F]{4})+\\X0\\|\\X4\\(?:[0-9A-F]{8})+\\X0\\| + # hex byte encoding + \\X\\[0-9A-F]{2} + )* +')""" +p21_binary = r'(?:"[0-3][0-9A-F]*")' +p21_enumeration = r'(?:\.[A-Z_][A-Z0-9_]*\.)' +p21_keyword = r'(?:!|)[A-Za-z_][0-9A-Za-z_]*' +p21_eid = r'\#[0-9]+' + +_catchall_types = [p21_real, p21_integer, p21_string, p21_binary, p21_enumeration, + p21_keyword, p21_eid] + +groups_re = re.compile(r"(?P\()|(?P\#[0-9]+)|(?P\))|(?P')") +p21_string_re = re.compile(p21_string) + +def _mkgroups(s): + """used to populate the xref database table""" + stack_idx = 0 + stack_depth = 2 + stack = [set(), set()] + + cp = 0 + while True: + m = groups_re.search(s, cp) + if not m: break + + if m.group('eid'): + stack[stack_idx].add(m.group()) + elif m.group('lparens'): + stack_idx += 1 + if stack_idx == len(stack): + stack_depth += 2 + stack.extend((set(), set())) + elif m.group('rparens'): + stack_idx -= 1 + else: + m = p21_string_re.match(s, m.start()) + + cp = m.end() + + groups = [] + if any(stack): + _stack = filter(bool, stack) + # expand the first level + stack = tuple((x,) for x in next(_stack)) + tuple(_stack) + groups = list(enumerate(stack, 1)) + + return groups + + +base_tokens = ['PART21_START', 'PART21_END', 'HEADER', 'DATA', 'ENDSEC', + 'INTEGER', 'REAL', 'KEYWORD', 'STRING', 'BINARY', 'ENUMERATION', + 'EID', 'RAW'] + +#################################################################################################### +# Lexer +#################################################################################################### +class Lexer(object): + tokens = list(base_tokens) + literals = '()=;,*$' + + states = (('slurp', 'exclusive'), + ('header', 'exclusive'), + ('data', 'exclusive'), + ('raw', 'exclusive'), + ('params', 'exclusive')) + + def __init__(self, debug=False, optimize=False, header_limit=4096): + self.base_tokens = list(base_tokens) + self.schema_dict = {} + self.active_schema = {} + self.header_limit = header_limit + self.lexer = lex.lex(module=self, debug=debug, optimize=optimize, lextab='cl21tab', + debuglog=logger, errorlog=logger) + self.reset() + + def __getattr__(self, name): + if name == 'lineno': + return self.lexer.lineno + elif name == 'lexpos': + return self.lexer.lexpos + else: + raise AttributeError + + def input(self, s): + self.lexer.input(s) + + def reset(self): + self.lexer.lineno = 1 + self.lexer.lvl = 0 + self.lexer.begin('slurp') + + def token(self): + return self.lexer.token() + + def activate_schema(self, schema_name): + if schema_name in self.schema_dict: + self.active_schema = self.schema_dict[schema_name] + else: + raise ValueError('schema not registered') + + def register_schema(self, schema_name, entities): + if schema_name in self.schema_dict: + raise ValueError('schema already registered') + + for k in entities: + if k in self.base_tokens: raise ValueError('schema cannot override base_tokens') + + if isinstance(entities, list): + entities = dict((k, k) for k in entities) + + self.schema_dict[schema_name] = entities + + def t_slurp_error(self, t): + m = re.search(r'(?P/\*)|(ISO-10303-21;)', t.value[:self.header_limit]) + if m: + if m.group('comment'): + t.lexer.skip(m.start()) + else: + t.type = 'PART21_START' + t.value = m.group() + t.lexpos += m.start() + t.lineno += t.value[:m.start()].count('\n') + t.lexer.lexpos += m.end() + t.lexer.begin('INITIAL') + return t + elif len(t.value) < self.header_limit: + t.lexer.skip(len(t.value)) + else: + raise LexError("Scanning error. try increasing lexer header_limit parameter", + "{0}...".format(t.value[0:20])) + + def t_error(self, t): + raise LexError("Scanning error, invalid input", "{0}...".format(t.value[0:20])) + + def t_ANY_COMMENT(self, t): + r'/\*(?:.|\n)*?\*/' + t.lexer.lineno += t.value.count('\n') + + + def t_PART21_END(self, t): + r'END-ISO-10303-21;' + self.lexer.lvl = 0 + self.lexer.begin('slurp') + return t + def t_HEADER(self, t): + r'HEADER;' + t.lexer.push_state('header') + return t + def t_header_data_ENDSEC(self, t): + r'ENDSEC;' + t.lexer.pop_state() + return t + def t_DATA(self, t): + r'DATA\b' + t.lexer.in_header = True + t.lexer.push_state('data') + return t + + + @TOKEN(p21_keyword) + def t_header_KEYWORD(self, t): + return t + def t_header_lparens(self, t): + r'\(' + t.lexer.lexpos -= 1 + t.lexer.push_state('params') + def t_header_rparens(self, t): + r'\)' + t.type = ')' + t.lexer.pop_state() + return t + + + def t_data_lparens(self, t): + r'\(' + if t.lexer.in_header: + t.type = '(' + t.lexer.push_state('header') + else: + t.type = 'RAW' + t.lexer.push_state('raw') + return t + def t_data_header_end(self, t): + r';' + t.type = ';' + t.lexer.in_header = False + return t + @TOKEN(p21_eid) + def t_data_EID(self, t): + return t + @TOKEN(p21_keyword) + def t_data_KEYWORD(self, t): + t.lexer.push_state('raw') + return t + + + def t_params_lparens(self, t): + r'\(' + t.type = 'RAW' + t.lexer.lvl += 1 + return t + def t_params_rparens(self, t): + r'\)' + t.type = 'RAW' + t.lexer.lvl -= 1 + if t.lexer.lvl == 0: + t.lexer.pop_state() + return t + @TOKEN('(?:' + '|'.join(_catchall_types) + r'|(?:[,*$]))+') + def t_params_RAW(self, t): + return t + + + def t_raw_end(self, t): + r';' + t.lexer.pop_state() + t.type = ';' + return t + @TOKEN('(?:' + '|'.join(_catchall_types) + r'|(?:[(),*$]))+') + def t_raw_RAW(self, t): + return t + + + def t_ANY_newline(self, t): + r'\n+' + t.lexer.lineno += len(t.value) + t_ANY_ignore = ' \t\r' + + +#################################################################################################### +# Parser +#################################################################################################### +class Parser(object): + tokens = list(base_tokens) + + def __init__(self, lexer=None, debug=False, tabmodule=None, start=None, optimize=False, + tempdb=False): + # defaults + start_tabs = {'exchange_file': 'cp21tab', 'extract_header': 'cp21hdrtab'} + if start and tabmodule: start_tabs[start] = tabmodule + if not start: start = 'exchange_file' + if start not in start_tabs: raise ValueError('please pass (dedicated) tabmodule') + + self.tempdb = tempdb + self.lexer = lexer if lexer else Lexer() + self.parser = yacc.yacc(debug=debug, module=self, tabmodule=start_tabs[start], start=start, + optimize=optimize, debuglog=logger, errorlog=logger) + + def parse(self, p21_data, db_path=None, **kwargs): + #TODO: will probably need to change this function if the lexer is ever to support t_eof + self.reset(self.tempdb, db_path) + self.lexer.input(p21_data) + + if 'debug' in kwargs: + result = self.parser.parse(lexer=self.lexer, debug=logger, + ** dict((k, v) for k, v in kwargs.items() if k != 'debug')) + else: + result = self.parser.parse(lexer=self.lexer, **kwargs) + return result + + def reset(self, tempdb=None, db_path=None): + self.lexer.reset() + self.initdb(tempdb, db_path) + + def closedb(self): + try: + self.db_cxn.commit() + self.db_cxn.close() + except AttributeError: + pass + + def initdb(self, tempdb, db_path=None): + if tempdb and not db_path: + tm = datetime.datetime.utcnow().isoformat(timespec='seconds').replace(':','-') + db_path = os.path.join(tempfile.mkdtemp(), tm + '_test.db') + elif not db_path: + db_path = ":memory:" + logger.info('db_path: %s', db_path) + self.db_cxn = sqlite3.connect(db_path) + self.db_writer = self.db_cxn.cursor() + self.db_writer.executescript(""" + PRAGMA foreign_keys = ON; + CREATE TABLE entity_enum (type TEXT(1) PRIMARY KEY); + INSERT INTO entity_enum (type) VALUES ('S'), ('C'); + CREATE TABLE section_enum (type TEXT(1) PRIMARY KEY); + INSERT INTO section_enum (type) VALUES ('D'), ('H'); + + CREATE TABLE section_table ( + id INTEGER PRIMARY KEY, + lineno INTEGER NOT NULL, + section_type TEXT(1) NOT NULL REFERENCES section_enum(type) + ); + + CREATE TABLE section_headers ( + id INTEGER PRIMARY KEY, + type_name TEXT COLLATE NOCASE, + raw_data TEXT NOT NULL, + lineno INTEGER NOT NULL, + fk_section INTEGER NOT NULL REFERENCES section_table(id) + ); + + CREATE TABLE data_table ( + id TEXT PRIMARY KEY, + type_name TEXT COLLATE NOCASE, + raw_data TEXT NOT NULL, + lineno INTEGER NOT NULL, + entity_type TEXT(1) NOT NULL REFERENCES entity_enum(type), + fk_section INTEGER NOT NULL REFERENCES section_table(id) + ) WITHOUT ROWID; + + CREATE TABLE data_xref ( + id_from TEXT NOT NULL REFERENCES data_table(id) DEFERRABLE INITIALLY DEFERRED, + id_to TEXT NOT NULL REFERENCES data_table(id), + id_group INTEGER NOT NULL, + PRIMARY KEY (id_from, id_to, id_group) + ) WITHOUT ROWID; + + CREATE INDEX ix_type_name ON data_table(type_name); + CREATE INDEX ix_entity_type ON data_table(entity_type); + CREATE INDEX ix_fk_section ON data_table(fk_section); + CREATE INDEX ix_id_from ON data_xref(id_from); + """) + self.db_cxn.commit() + + def p_exchange_file(self, p): + """exchange_file : PART21_START header_section data_section_list PART21_END""" + self.closedb() + + def p_header_section(self, p): + """header_section : header_start header_entity header_entity header_entity ENDSEC""" + + def p_header_section_with_entity_list(self, p): + """header_section : header_start header_entity header_entity header_entity header_entity_list ENDSEC""" + + def p_header_section_start(self, p): + """header_start : HEADER""" + tmpl = "INSERT INTO section_table(lineno, section_type) VALUES (?,?)" + self.db_writer.execute(tmpl, (p.lineno(1), 'H')) + self.db_writer.execute('SELECT last_insert_rowid();') + (self.sid,) = self.db_writer.fetchone() + + def p_header_entity(self, p): + """header_entity : KEYWORD raw_data ';'""" + tmpl = "INSERT INTO section_headers(type_name, raw_data, lineno, fk_section) VALUES (?, ?, ?, ?)" + self.db_writer.execute(tmpl, (p[1], p[2], p.lineno(1), self.sid)) + + def p_header_entity_list_init(self, p): + """header_entity_list : header_entity""" + + def p_header_entity_list(self, p): + """header_entity_list : header_entity_list header_entity""" + + def p_data_section(self, p): + """data_section : data_start entity_instance_list ENDSEC""" + + def p_data_start(self, p): + """data_start : DATA '(' parameter_list ')' ';'""" + tmpl = "INSERT INTO section_table(lineno, section_type) VALUES (?,?)" + lineno = p.lineno(1) + self.db_writer.execute(tmpl, (lineno, 'D')) + self.db_writer.execute('SELECT last_insert_rowid();') + (self.sid,) = self.db_writer.fetchone() + tmpl = "INSERT INTO section_headers(type_name, raw_data, lineno, fk_section) VALUES (?, ?, ?, ?)" + self.db_writer.executemany(tmpl, [(t, x, lineno, self.sid) for t, x in p[3]]) + + def p_data_start_empty(self, p): + """data_start : DATA '(' ')' ';' + | DATA ';'""" + tmpl = "INSERT INTO section_table(lineno, section_type) VALUES (?,?)" + self.db_writer.execute(tmpl, (p.lineno(1), 'D')) + self.db_writer.execute('SELECT last_insert_rowid();') + (self.sid,) = self.db_writer.fetchone() + + def p_data_section_list_init(self, p): + """data_section_list : data_section""" + + def p_data_section_list(self, p): + """data_section_list : data_section_list data_section""" + + def p_entity_instance_list_init(self, p): + """entity_instance_list : entity_instance""" + + def p_entity_instance_list(self, p): + """entity_instance_list : entity_instance_list entity_instance""" + + def p_entity_instance(self, p): + """entity_instance : simple_entity_instance + | complex_entity_instance""" + + def p_entity_instance_error(self, p): + """entity_instance : EID '=' error ';'""" + logger.error('resyncing parser, check input between lineno %d and %d', p.lineno(2), p.lineno(4)) + + def p_simple_entity_instance(self, p): + """simple_entity_instance : EID '=' KEYWORD raw_data ';'""" + eid = p[1] + tmpl = "INSERT INTO data_table VALUES (?,?,?,?,?,?)" + self.db_writer.execute(tmpl, (p[1], p[3], p[4][1:-1], p.lineno(1), 'S', self.sid)) + tmpl = "INSERT INTO data_xref(id_from, id_to, id_group) VALUES (?, ?, ?)" + xrefs = [(rid, eid, n) for n, x in _mkgroups(p[4]) for rid in x] + self.db_writer.executemany(tmpl, xrefs) + + def p_complex_entity_instance(self, p): + """complex_entity_instance : EID '=' raw_data ';'""" + eid = p[1] + tmpl = "INSERT INTO data_table VALUES (?,NULL,?,?,?,?)" + self.db_writer.execute(tmpl, (p[1], p[3], p.lineno(1), 'C', self.sid)) + tmpl = "INSERT INTO data_xref(id_from, id_to, id_group) VALUES (?, ?, ?)" + xrefs = [(rid, eid, n) for n, x in _mkgroups(p[3]) for rid in x] + self.db_writer.executemany(tmpl, xrefs) + + def p_parameter_list_init(self, p): + """parameter_list : parameter""" + p[0] = [p[1],] + + def p_parameter_list(self, p): + """parameter_list : parameter_list ',' parameter""" + p[0] = p[1] + p[0].append(p[3]) + + def p_typed_parameter(self, p): + """parameter : KEYWORD raw_data""" + p[0] = (p[1], p[2]) + + def p_other_parameter(self, p): + """parameter : raw_data""" + p[0] = (None, p[1]) + + def p_raw_concat(self, p): + """raw_data : raw_data RAW + | RAW""" + try: p[0] = p[1] + p[2] + except IndexError: p[0] = p[1] + + +def debug_lexer(): + import codecs + from os.path import normpath, expanduser + + logging.basicConfig() + logger.setLevel(logging.DEBUG) + + lexer = Lexer(debug=True) + + p = normpath(expanduser('~/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp')) + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + lexer.input(s) + while True: + tok = lexer.token() + if not tok: break + logger.debug(tok) + +def debug_parser(): + import codecs + from os.path import normpath, expanduser + + logging.basicConfig() + logger.setLevel(logging.DEBUG) + + parser = Parser(debug=True, tempdb=True) + + logger.info("***** parser debug *****") + p = normpath(expanduser('~/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp')) + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + parser.parse(s, debug=1) + + # test reverse lookup + logger.info('***** testing xrefs *****') + tm = datetime.datetime.utcnow().isoformat(timespec='seconds').replace(':', '-') + db_path = os.path.join(tempfile.mkdtemp(), tm + '_xref_test.db') + + parser = Parser() + + p = normpath(expanduser('~/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp')) + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + parser.parse(s, db_path=db_path) + + # contrived use case: we're looking for the objects referencing each of these [set] of items + items = [('#53','#93','#133','#173','#191'), ('#174','#192'), ('#193','#196','#195'), ('#1',)] + tmpl = "SELECT id_to FROM data_xref WHERE id_from IN (%s) GROUP BY id_group, id_to HAVING count(id_to) = ?" + with sqlite3.connect(db_path) as db_cxn: + for grp in items: + db_cursor = db_cxn.execute(tmpl % ','.join('?'*len(grp)), grp + (len(grp),)) + for eid in db_cursor: + logger.info('grp: %s, ref: %r', grp, eid) + + logger.info("***** finished *****") + +def test(): + import os, codecs + from os.path import normpath, expanduser + + logging.basicConfig() + logger.setLevel(logging.INFO) + + lexer = Lexer(optimize=True) + parser = Parser(lexer=lexer, optimize=True) + + def parse_check(p): + logger.info("processing {0}".format(p)) + parser.reset() + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + parser.parse(s) + + logger.info("***** standard test *****") + stepcode_dir = normpath(os.path.expanduser('~/projects/src/stepcode')) + for d, _, files in os.walk(stepcode_dir): + for f in filter(lambda x: x.endswith('.stp'), files): + p = os.path.join(d, f) + try: + parse_check(p) + except LexError: + logger.exception('Lexer failure: {0}'.format(os.path.basename(p))) + + logger.info("***** finished *****") + + +if __name__ == '__main__': + #debug_lexer() + #debug_parser() + test() + From 3c21bf00ac95c5df480ed68d38427d681a2589f6 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Mon, 23 Mar 2020 07:36:59 +0000 Subject: [PATCH 175/244] Part21 Legacy Parser * optimisations - remove list copy and try clauses - stop using token iterator - tab modules (for ply optimised mode) - add missing t_error function (for ply optimised mode) * useability - add option to only parse the header then exit * fixes - fix ComplexEntity creation, and simpify / correct AST creation --- src/exp2python/python/SCL/Part21.py | 212 +++++++++++++++++++--------- 1 file changed, 149 insertions(+), 63 deletions(-) diff --git a/src/exp2python/python/SCL/Part21.py b/src/exp2python/python/SCL/Part21.py index d993305fa..f2e70a3ba 100644 --- a/src/exp2python/python/SCL/Part21.py +++ b/src/exp2python/python/SCL/Part21.py @@ -57,15 +57,15 @@ class Lexer: tokens = list(base_tokens) states = (('slurp', 'exclusive'),) - def __init__(self, debug=0, optimize=0, compatibility_mode=False, header_limit=4096): + def __init__(self, debug=False, optimize=False, compatibility_mode=False, header_limit=4096): self.base_tokens = list(base_tokens) self.schema_dict = {} self.active_schema = {} self.input_length = 0 self.compatibility_mode = compatibility_mode self.header_limit = header_limit - self.lexer = lex.lex(module=self, debug=debug, debuglog=logger, optimize=optimize, - errorlog=logger) + self.lexer = lex.lex(module=self, debug=debug, optimize=optimize, lextab='l21tab', + debuglog=logger, errorlog=logger) self.reset() def __getattr__(self, name): @@ -85,10 +85,7 @@ def reset(self): self.lexer.begin('slurp') def token(self): - try: - return next(self.lexer) - except StopIteration: - return None + return self.lexer.token() def activate_schema(self, schema_name): if schema_name in self.schema_dict: @@ -125,6 +122,9 @@ def t_slurp_error(self, t): t.lexer.lineno += t.value[0:offset].count('\n') t.lexer.skip(offset) + def t_error(self, t): + raise LexError("Scanning error, invalid input", "{0}...".format(t.value[0:20])) + # Comment (ignored) def t_COMMENT(self, t): r'/\*(.|\n)*?\*/' @@ -193,8 +193,8 @@ def t_BINARY(self, t): # Punctuation literals = '()=;,*$' - t_ANY_ignore = ' \t' - + t_ANY_ignore = ' \t\r' + #################################################################################################### # Simple Model @@ -212,24 +212,24 @@ def __init__(self, file_description, file_name, file_schema): self.extra_headers = [] class HeaderEntity: - def __init__(self, type_name, *params): + def __init__(self, type_name, params): self.type_name = type_name - self.params = list(params) if params else [] + self.params = params class Section: def __init__(self, entities): self.entities = entities class SimpleEntity: - def __init__(self, ref, type_name, *params): + def __init__(self, ref, type_name, params): self.ref = ref self.type_name = type_name - self.params = list(params) if params else [] + self.params = params class ComplexEntity: - def __init__(self, ref, *params): + def __init__(self, ref, params): self.ref = ref - self.params = list(params) if params else [] + self.params = params class TypedParameter: def __init__(self, type_name, *params): @@ -241,15 +241,21 @@ def __init__(self, type_name, *params): #################################################################################################### class Parser: tokens = list(base_tokens) - start = 'exchange_file' - def __init__(self, lexer=None, debug=0): - self.lexer = lexer if lexer else Lexer() - + def __init__(self, lexer=None, debug=False, tabmodule=None, start=None, optimize=False): + # defaults + start_tabs = {'exchange_file': 'p21tab', 'extract_header': 'p21hdrtab'} + if start and tabmodule: start_tabs[start] = tabmodule + if not start: start = 'exchange_file' + if start not in start_tabs: raise ValueError('please pass (dedicated) tabmodule') + + # lexer may provide a more specialised set of tokens for use in (subclassed) parser try: self.tokens = lexer.tokens except AttributeError: pass - self.parser = yacc.yacc(module=self, debug=debug, debuglog=logger, errorlog=logger) + self.lexer = lexer if lexer else Lexer() + self.parser = yacc.yacc(debug=debug, module=self, tabmodule=start_tabs[start], start=start, + optimize=optimize, debuglog=logger, errorlog=logger) self.reset() def parse(self, p21_data, **kwargs): @@ -259,7 +265,7 @@ def parse(self, p21_data, **kwargs): if 'debug' in kwargs: result = self.parser.parse(lexer=self.lexer, debug=logger, - ** dict((k, v) for k, v in kwargs.iteritems() if k != 'debug')) + ** dict((k, v) for k, v in kwargs.items() if k != 'debug')) else: result = self.parser.parse(lexer=self.lexer, **kwargs) return result @@ -271,6 +277,12 @@ def reset(self): def p_exchange_file(self, p): """exchange_file : check_p21_start_token header_section data_section_list check_p21_end_token""" p[0] = P21File(p[2], p[3]) + + def p_extract_header(self, p): + """extract_header : check_p21_start_token header_section DATA""" + p[0] = P21File(p[2], []) + # clear input to avoid trailing context errors + p.lexer.input('') def p_check_start_token(self, p): """check_p21_start_token : PART21_START""" @@ -310,9 +322,8 @@ def p_simple_entity_instance(self, p): p[0] = SimpleEntity(p[1], *p[3]) def p_entity_instance_error(self, p): - """simple_entity_instance : error '=' simple_record ';' - complex_entity_instance : error '=' subsuper_record ';'""" - pass + """entity_instance : check_entity_instance_name '=' error ';'""" + logger.error('resyncing parser, check input between lineno %d and %d', p.lineno(2), p.lineno(4)) def p_complex_entity_instance(self, p): """complex_entity_instance : check_entity_instance_name '=' subsuper_record ';'""" @@ -320,25 +331,34 @@ def p_complex_entity_instance(self, p): def p_subsuper_record(self, p): """subsuper_record : '(' simple_record_list ')'""" - p[0] = [TypedParameter(*x) for x in p[2]] + p[0] = [SimpleEntity(None, *x) for x in p[2]] + def p_data_section_list_init(self, p): + """data_section_list : data_section""" + p[0] = [p[1],] + def p_data_section_list(self, p): - """data_section_list : data_section_list data_section - | data_section""" - try: p[0] = p[1] + [p[2],] - except IndexError: p[0] = [p[1],] + """data_section_list : data_section_list data_section""" + p[0] = p[1] + p[0].append(p[2]) + def p_header_entity_list_init(self, p): + """header_entity_list : header_entity""" + p[0] = [p[1],] + def p_header_entity_list(self, p): - """header_entity_list : header_entity_list header_entity - | header_entity""" - try: p[0] = p[1] + [p[2],] - except IndexError: p[0] = [p[1],] + """header_entity_list : header_entity_list header_entity""" + p[0] = p[1] + p[0].append(p[2]) + def p_parameter_list_init(self, p): + """parameter_list : parameter""" + p[0] = [p[1],] + def p_parameter_list(self, p): - """parameter_list : parameter_list ',' parameter - | parameter""" - try: p[0] = p[1] + [p[3],] - except IndexError: p[0] = [p[1],] + """parameter_list : parameter_list ',' parameter""" + p[0] = p[1] + p[0].append(p[3]) def p_keyword(self, p): """keyword : USER_DEFINED_KEYWORD @@ -372,7 +392,7 @@ def p_parameter_empty_list(self, p): def p_data_start(self, p): """data_start : DATA '(' parameter_list ')' ';'""" - pass + pass # TODO: do something with the parameters def p_data_start_empty(self, p): """data_start : DATA '(' ')' ';' @@ -383,11 +403,14 @@ def p_data_section(self, p): """data_section : data_start entity_instance_list ENDSEC""" p[0] = Section(p[2]) + def p_entity_instance_list_init(self, p): + """entity_instance_list : entity_instance""" + p[0] = [p[1],] + def p_entity_instance_list(self, p): - """entity_instance_list : entity_instance_list entity_instance - | entity_instance""" - try: p[0] = p[1] + [p[2],] - except IndexError: p[0] = [p[1],] + """entity_instance_list : entity_instance_list entity_instance""" + p[0] = p[1] + p[0].append(p[2]) def p_entity_instance_list_empty(self, p): """entity_instance_list : empty""" @@ -407,18 +430,41 @@ def p_simple_record_with_params(self, p): """simple_record : keyword '(' parameter_list ')'""" p[0] = (p[1], p[3]) + def p_simple_record_list_init(self, p): + """simple_record_list : simple_record""" + p[0] = [p[1],] + def p_simple_record_list(self, p): - """simple_record_list : simple_record_list simple_record - | simple_record""" - try: p[0] = p[1] + [p[2],] - except IndexError: p[0] = [p[1],] + """simple_record_list : simple_record_list simple_record""" + p[0] = p[1] + p[0].append(p[2]) def p_empty(self, p): """empty :""" pass -def test_debug(): - import os.path + +def debug_lexer(): + import codecs + from os.path import normpath, expanduser + + logging.basicConfig() + logger.setLevel(logging.DEBUG) + + lexer = Lexer(debug=True) + + p = normpath(expanduser('~/projects/src/stepcode/data/ap209/ATS7-out.stp')) + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + lexer.input(s) + while True: + tok = lexer.token() + if not tok: break + print(tok) + +def debug_parser(): + import codecs + from os.path import normpath, expanduser logging.basicConfig() logger.setLevel(logging.DEBUG) @@ -427,36 +473,73 @@ def test_debug(): parser.reset() logger.info("***** parser debug *****") - p = os.path.expanduser('~/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp') - with open(p, 'rU') as f: + p = normpath(expanduser('~/projects/src/stepcode/data/ap214e3/s1-c5-214/s1-c5-214.stp')) + with codecs.open(p, 'r', encoding='iso-8859-1') as f: s = f.read() - try: - parser.parse(s, debug=1) - except SystemExit: - pass + parser.parse(s, debug=1) logger.info("***** finished *****") def test(): - import os, os.path, itertools, codecs + import os, codecs + from os.path import normpath, expanduser logging.basicConfig() logger.setLevel(logging.INFO) + + lexer = Lexer(optimize=True) + parser = Parser(lexer=lexer, optimize=True) + compat_list = [] - parser = Parser() + def parse_check(p): + logger.info("processing {0}".format(p)) + parser.reset() + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() + parser.parse(s) + + logger.info("***** standard test *****") + stepcode_dir = normpath(os.path.expanduser('~/projects/src/stepcode')) + for d, _, files in os.walk(stepcode_dir): + for f in filter(lambda x: x.endswith('.stp'), files): + p = os.path.join(d, f) + try: + parse_check(p) + except LexError: + logger.exception('Lexer issue, adding {0} to compatibility test list'.format(os.path.basename(p))) + compat_list.append(p) + + lexer = Lexer(optimize=True, compatibility_mode=True) + parser = Parser(lexer=lexer, optimize=True) + + logger.info("***** compatibility test *****") + for p in compat_list: + parse_check(p) + + logger.info("***** finished *****") + +def test_header_only(): + import os, codecs + from os.path import normpath, expanduser + + logging.basicConfig() + logger.setLevel(logging.INFO) + + lexer = Lexer(optimize=True) + parser = Parser(start='extract_header', optimize=True) compat_list = [] def parse_check(p): logger.info("processing {0}".format(p)) parser.reset() - with open(p, 'rU') as f: - iso_wrapper = codecs.EncodedFile(f, 'iso-8859-1') - s = iso_wrapper.read() + with codecs.open(p, 'r', encoding='iso-8859-1') as f: + s = f.read() parser.parse(s) logger.info("***** standard test *****") - for d, _, files in os.walk(os.path.expanduser('~/projects/src/stepcode')): - for f in itertools.ifilter(lambda x: x.endswith('.stp'), files): + stepcode_dir = normpath(os.path.expanduser('~/projects/src/stepcode')) + for d, _, files in os.walk(stepcode_dir): + for f in filter(lambda x: x.endswith('.stp'), files): p = os.path.join(d, f) try: parse_check(p) @@ -464,8 +547,8 @@ def parse_check(p): logger.exception('Lexer issue, adding {0} to compatibility test list'.format(os.path.basename(p))) compat_list.append(p) - lexer = Lexer(compatibility_mode=True) - parser = Parser(lexer=lexer) + lexer = Lexer(optimize=True, compatibility_mode=True) + parser = Parser(lexer=lexer, start='extract_header', optimize=True) logger.info("***** compatibility test *****") for p in compat_list: @@ -474,4 +557,7 @@ def parse_check(p): logger.info("***** finished *****") if __name__ == '__main__': + #debug_lexer() + #debug_parser() test() + #test_header_only() From 7aa43098489a34e987b4b0494735f03a431b0363 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 13:19:35 +0000 Subject: [PATCH 176/244] exp2py: use relative imports for SCL library --- src/exp2python/python/SCL/AggregationDataTypes.py | 6 +++--- src/exp2python/python/SCL/Builtin.py | 8 ++++---- src/exp2python/python/SCL/ConstructedDataTypes.py | 2 +- src/exp2python/python/SCL/TypeChecker.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/exp2python/python/SCL/AggregationDataTypes.py b/src/exp2python/python/SCL/AggregationDataTypes.py index 9345dc0af..5ed1409ab 100644 --- a/src/exp2python/python/SCL/AggregationDataTypes.py +++ b/src/exp2python/python/SCL/AggregationDataTypes.py @@ -29,9 +29,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from SimpleDataTypes import * -from TypeChecker import check_type -import BaseType +from .SimpleDataTypes import * +from .TypeChecker import check_type +from . import BaseType class BaseAggregate: """ A class that define common properties to ARRAY, LIST, SET and BAG. diff --git a/src/exp2python/python/SCL/Builtin.py b/src/exp2python/python/SCL/Builtin.py index 54b7eb167..fb2910a2f 100644 --- a/src/exp2python/python/SCL/Builtin.py +++ b/src/exp2python/python/SCL/Builtin.py @@ -32,9 +32,9 @@ __doc__ = "This module defines EXPRESS built in constants and functions" import math -from SimpleDataTypes import * -from BaseType import Aggregate -from AggregationDataTypes import * +from .SimpleDataTypes import * +from .BaseType import Aggregate +from .AggregationDataTypes import * SCL_float_epsilon = 1e-7 # Builtin constants @@ -713,4 +713,4 @@ def VALUE_UNIQUE(V): raise TypeError("VALUE_UNIQUE method takes an aggregate as first parameter") return V.get_value_unique() - \ No newline at end of file + diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/SCL/ConstructedDataTypes.py index b84f50927..0e9393333 100644 --- a/src/exp2python/python/SCL/ConstructedDataTypes.py +++ b/src/exp2python/python/SCL/ConstructedDataTypes.py @@ -30,7 +30,7 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from enum import Enum -import BaseType +from . import BaseType class ENUMERATION(Enum): """ diff --git a/src/exp2python/python/SCL/TypeChecker.py b/src/exp2python/python/SCL/TypeChecker.py index e11b50f53..0a77716fb 100644 --- a/src/exp2python/python/SCL/TypeChecker.py +++ b/src/exp2python/python/SCL/TypeChecker.py @@ -29,8 +29,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from ConstructedDataTypes import ENUMERATION, SELECT -import BaseType +from .ConstructedDataTypes import ENUMERATION, SELECT +from . import BaseType RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH = True DEBUG = False From 0ef7755151105dd3293299e6e491a505c3fc53e9 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 13:23:38 +0000 Subject: [PATCH 177/244] exp2py: first steps to fix output order and dependency logic --- src/exp2python/src/classes_wrapper_python.cc | 58 ++++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index ef039f828..ef8f5ead1 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -29,30 +29,31 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { DictionaryEntry de; Type i; int redefs = 0;// index = 0; + int skipped; - /* Defined Types based on SIMPLE types */ - SCOPEdo_types( scope, t, de ) - if ( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) - && ( TYPEget_ancestor( t ) == NULL) ) { - TYPEprint_descriptions( t, files, schema ); - t->search_id = PROCESSED; - } - SCOPEod + while( 1 ) { + skipped = 0; - /* Defined Types with defined ancestor head - * TODO: recursive approach - */ - SCOPEdo_types( scope, t, de ) - if ( ( t->search_id == CANPROCESS ) - && !( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) - && ( ( i = TYPEget_head( t ) ) != NULL ) ) { - if (i->search_id == PROCESSED) { + SCOPEdo_types( scope, t, de ) + if( TYPEis_enumeration( t ) || TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + continue; + } + + i = TYPEget_head( t ); + if( ( !i || i->search_id == PROCESSED ) + && t->search_id == CANPROCESS ) { TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; + } else if( t->search_id == CANPROCESS ) { + skipped++; + } + + SCOPEod + + if( !skipped ) { + break; } } - SCOPEod /* fill in the values for the type descriptors */ /* and print the enumerations */ @@ -74,14 +75,15 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { SCOPEod SCOPEdo_types( scope, t, de ) + if( TYPEis_select( t ) || TYPEis_aggregate( t ) ) { + continue; + } + // Do the non-redefined enumerations: if( ( t->search_id == CANPROCESS ) && !( TYPEis_enumeration( t ) && TYPEget_head( t ) ) ) { TYPEprint_descriptions( t, files, schema ); - if( !TYPEis_select( t ) ) { - // Selects have a lot more processing and are done below. - t->search_id = PROCESSED; - } + t->search_id = PROCESSED; } SCOPEod; @@ -101,11 +103,13 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { // we don't have to worry about printing B before A. This is checked in // TYPEselect_print(). SCOPEdo_types( scope, t, de ) - if( t->search_id == CANPROCESS ) { + if( t->search_id == CANPROCESS && TYPEis_select( t ) ) { // Only selects haven't been processed yet and may still be set to // CANPROCESS. //FIXME this function is not implemented! // TYPEselect_print( t, files, schema ); + // TODO: due to conditional error we were previously executing this above without realising + TYPEprint_descriptions( t, files, schema ); t->search_id = PROCESSED; } SCOPEod; @@ -131,6 +135,14 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { LISTod; LISTfree( rule_list ); + // TODO: check dependencies + SCOPEdo_types( scope, t, de ) + if( t->search_id == CANPROCESS && TYPEis_aggregate( t ) ) { + TYPEprint_descriptions( t, files, schema ); + t->search_id = PROCESSED; + } + SCOPEod + } From 35da61660b5d33ff922dec842970ba163eaad055 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 13:27:35 +0000 Subject: [PATCH 178/244] exp2py: update repo gitignore to ignore all __pycache__ folders --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 462bd78c4..c39a631c2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ [._]*.sw[a-p] [._]s[a-v][a-z] [._]sw[a-p] +**/__pycache__/ # OS specific files .DS_Store From fed696dc63b2af5c15c66bc0b22fac8375a677b0 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 20:11:59 +0000 Subject: [PATCH 179/244] exp2py: raise NotImplementedError when appropriate --- src/exp2python/python/SCL/SCLBase.py | 6 ++++++ src/exp2python/src/classes_python.c | 8 ++++---- src/exp2python/src/classes_wrapper_python.cc | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/exp2python/python/SCL/SCLBase.py b/src/exp2python/python/SCL/SCLBase.py index d71600bf5..ff8413e8b 100644 --- a/src/exp2python/python/SCL/SCLBase.py +++ b/src/exp2python/python/SCL/SCLBase.py @@ -1,4 +1,5 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) +# Copyright (c) 2022, Chris Horler (cshorler@googlemail.com) # All rights reserved. # This file is part of the StepClassLibrary (SCL). @@ -29,6 +30,11 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +__all__ = ['BaseEntityClass'] + +def raise_(exc): + raise exc + class BaseEntityClass: """ A class that allows advanced __repr__ features for entity instances """ diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 7a6eb6df6..fcae8bbec 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -429,7 +429,7 @@ char* EXPRto_python( Expression e ) { snprintf( buf, bufsize, "%s.%s", TYPEget_name(e->type), e->symbol.name ); break; case query_: - strcpy( buf, "# query_ NOT_IMPLEMENTED!" ); + strcpy( buf, "SCLBase.raise_(NotImplementedError('query_'))" ); break; case self_: strcpy( buf, "self" ); @@ -451,13 +451,13 @@ char* EXPRto_python( Expression e ) { break; } case op_: - strcpy( buf, "# op_ NOT_IMPLEMENTED!" ); + strcpy( buf, "SCLBase.raise_(NotImplementedError('op_'))" ); break; case aggregate_: - strcpy( buf, "# aggregate_ NOT_IMPLEMENTED!" ); + strcpy( buf, "SCLBase.raise_(NotImplementedError('aggregate_'))" ); break; case oneof_: { - strcpy( buf, "# oneof_ NOT_IMPLEMENTED!" ); + strcpy( buf, "SCLBase.raise_(NotImplementedError('oneof_'))" ); break; } default: diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index ef8f5ead1..9f2d02b62 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -193,6 +193,7 @@ void SCHEMAprint( Schema schema, FILES * files, int suffix ) { } fprintf( libfile, "import sys\n" ); fprintf( libfile, "\n" ); + fprintf( libfile, "from SCL import SCLBase\n" ); fprintf( libfile, "from SCL.SCLBase import *\n" ); fprintf( libfile, "from SCL.SimpleDataTypes import *\n" ); fprintf( libfile, "from SCL.ConstructedDataTypes import *\n" ); From 472bd4cb120d5de04be3892ad557e31d62c19b3d Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 20:19:08 +0000 Subject: [PATCH 180/244] exp2py: fix some indentation errors found in for and while loops --- src/exp2python/src/classes_python.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index fcae8bbec..0fc1909c9 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -1104,6 +1104,7 @@ LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { fprintf( file, "):\n" ); if( loop->while_expr ) { + python_indent( file, level + 1 ); fprintf( file, "if " ); EXPRESSION_out( loop->while_expr, 0 , file ); fprintf( file, ":\n"); @@ -1113,9 +1114,12 @@ LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { } if( loop->until_expr ) { + python_indent( file, level + 1 ); fprintf( file, "if " ); EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + fprintf( file, ":\n" ); + python_indent( file, level + 2 ); + fprintf( file, "break\n" ); } } else if( loop->while_expr ) { fprintf( file, "while " ); @@ -1124,17 +1128,23 @@ LOOPpyout( struct Loop_ *loop, int level, FILE * file ) { STATEMENTlist_out( loop->statements, level + 1 , file ); if( loop->until_expr ) { + python_indent( file, level + 1 ); fprintf( file, "if " ); EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + fprintf( file, ":\n" ); + python_indent( file, level + 2 ); + fprintf( file, "break\n" ); } } else { fprintf( file, "while True:\n" ); STATEMENTlist_out( loop->statements, level + 1 , file ); + python_indent( file, level + 1 ); fprintf( file, "if " ); EXPRESSION_out( loop->until_expr, 0 , file ); - fprintf( file, ":\n\tbreak\n"); + fprintf( file, ":\n" ); + python_indent( file, level + 2 ); + fprintf( file, "break\n" ); } } From 06ee050fb2c32c7faed54cc784ac481e9f8cb300 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sat, 26 Feb 2022 22:46:13 +0000 Subject: [PATCH 181/244] exp2py: add "property" to reserved words --- src/exp2python/src/classes_python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 0fc1909c9..3b237ca01 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -175,7 +175,7 @@ int Handle_FedPlus_Args( int i, char * arg ) { bool is_python_keyword( char * word ) { int i; - const char* keyword_list[] = {"class", "pass", NULL}; + const char* keyword_list[] = {"class", "pass", "property", NULL}; bool python_keyword = false; for( i = 0; keyword_list[i] != NULL; i++ ) { From 70b5d0d0af3720cadcaa7329ed7b7a2757eb5c87 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Tue, 15 Mar 2022 22:48:08 +0000 Subject: [PATCH 182/244] exp2py: expressions are held in a 2-tree, processed recursively * set OP_UNKNOWN on LHS * test for OP_DOT and OP_GROUP when processing identifier_ --- src/exp2python/src/classes_python.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 3b237ca01..e719fc928 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -1209,7 +1209,11 @@ ATTRIBUTE_INITIALIZER__out( Expression e, int paren, int previous_op , FILE * fi break; case entity_: case identifier_: - fprintf( file, "self.%s", e->symbol.name ); + if( previous_op == OP_DOT || previous_op == OP_GROUP ) { + fprintf( file, "%s", e->symbol.name ); + } else { + fprintf( file, "self.%s", e->symbol.name ); + } break; case attribute_: fprintf( file, "%s", e->symbol.name ); @@ -1429,8 +1433,8 @@ ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression* oe, int paren, Op_Code pr ATTRIBUTE_INITIALIZERop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + ATTRIBUTE_INITIALIZERop2_out( oe, " in ", paren, PAD, file ); + break; case OP_INST_EQUAL: ATTRIBUTE_INITIALIZERop2_out( oe, " == ", paren, PAD, file ); break; @@ -1511,7 +1515,7 @@ EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, EXPRESSIONop2_out( oe, " * ", paren, PAD, file ); break; case OP_XOR: - EXPRESSIONop2__out( oe, " != ", paren, PAD, previous_op, file ); + EXPRESSIONop2_out( oe, " != ", paren, PAD, file ); break; case OP_EXP: EXPRESSIONop2_out( oe, " ** ", paren, PAD, file ); @@ -1523,8 +1527,8 @@ EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, EXPRESSIONop2_out( oe, " > ", paren, PAD, file ); break; case OP_IN: - /* EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); */ - /* break; */ + EXPRESSIONop2_out( oe, " in ", paren, PAD, file ); + break; case OP_INST_EQUAL: EXPRESSIONop2_out( oe, " == ", paren, PAD, file ); break; @@ -1542,8 +1546,7 @@ EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, EXPRESSIONop2_out( oe, " % ", paren, PAD, file ); break; case OP_NOT_EQUAL: - /*EXPRESSIONop2_out( oe, ( char * )0, paren, PAD ,file); */ - EXPRESSIONop2_out( oe, " != ", paren, PAD , file ); + EXPRESSIONop2_out( oe, " != ", paren, PAD, file ); break; case OP_NOT: EXPRESSIONop1_out( oe, " not ", paren, file ); @@ -1588,7 +1591,7 @@ EXPRESSIONop2__out( struct Op_Subexpression * eo, char * opcode, int paren, int if( pad && paren && ( eo->op_code != previous_op ) ) { fprintf( file, "(" ); } - EXPRESSION__out( eo->op1, 1, eo->op_code , file ); + EXPRESSION__out( eo->op1, 1, OP_UNKNOWN, file ); if( pad ) { fprintf( file, " " ); } @@ -1607,7 +1610,7 @@ ATTRIBUTE_INITIALIZERop2__out( struct Op_Subexpression * eo, char * opcode, int if( pad && paren && ( eo->op_code != previous_op ) ) { fprintf( file, "(" ); } - ATTRIBUTE_INITIALIZER__out( eo->op1, 1, eo->op_code , file ); + ATTRIBUTE_INITIALIZER__out( eo->op1, 1, OP_UNKNOWN, file ); if( pad ) { fprintf( file, " " ); } @@ -1668,8 +1671,8 @@ WHEREPrint( Linked_List wheres, int level , FILE * file ) { fprintf( file, "\tdef unnamed_wr_%i(self):\n", where_rule_number ); fprintf( file, "\t\teval_unnamed_wr_%i = ", where_rule_number ); } - /*EXPRESSION_out( w->expr, level+1 , file ); */ - ATTRIBUTE_INITIALIZER_out( w->expr, level + 1 , file ); + + ATTRIBUTE_INITIALIZER_out( w->expr, level + 1, file ); /* raise exception if rule violated */ if( strcmp( w->label->name, "" ) ) { fprintf( file, "\n\t\tif not eval_%s_wr:\n", w->label->name ); From 8a8ea3e23af63ccd9a7a740fcd66cd371a4a62c6 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Tue, 22 Mar 2022 22:08:04 +0000 Subject: [PATCH 183/244] exp2py: fix comparisons with None --- src/exp2python/src/classes_python.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index e719fc928..8afb44c3a 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -762,7 +762,7 @@ LIBdescribe_entity( Entity entity, FILE * file ) { /* if the argument is not optional */ if( !VARget_optional( v ) ) { fprintf( file, "\t\t# Mandatory argument\n" ); - fprintf( file, "\t\tassert value != None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); + fprintf( file, "\t\tassert value is not None, 'Argument \"value\" is mandatory and cannot be set to None'\n" ); fprintf( file, "\t\tif not check_type(value," ); if( TYPEis_aggregate( t ) ) { process_aggregate( file, t ); @@ -773,7 +773,7 @@ LIBdescribe_entity( Entity entity, FILE * file ) { fprintf( file, "%s):\n", attr_type ); } } else { - fprintf( file, "\t\tif value != None: # OPTIONAL attribute\n\t" ); + fprintf( file, "\t\tif value is not None: # OPTIONAL attribute\n\t" ); fprintf( file, "\t\tif not check_type(value," ); if( TYPEis_aggregate( t ) ) { process_aggregate( file, t ); From 0be8f439ef66f7b975f7a95b94b50385bca32907 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Tue, 22 Mar 2022 22:11:04 +0000 Subject: [PATCH 184/244] exp2py: add initial OP_GROUP support --- src/exp2python/src/classes_python.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 8afb44c3a..fe0d51e70 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -1469,7 +1469,10 @@ ATTRIBUTE_INITIALIZERop__out( struct Op_Subexpression* oe, int paren, Op_Code pr ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - ATTRIBUTE_INITIALIZERop2_out( oe, ".", paren, NOPAD, file ); + ATTRIBUTE_INITIALIZER_out(oe->op1, 1, file); + fprintf(file, "._scl_group("); + EXPRESSION_out(oe->op2, 0, file); + fprintf(file, ")"); break; case OP_NEGATE: ATTRIBUTE_INITIALIZERop1_out( oe, "-", paren, file ); @@ -1562,7 +1565,10 @@ EXPRESSIONop__out( struct Op_Subexpression* oe, int paren, Op_Code previous_op, EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); break; case OP_GROUP: - EXPRESSIONop2_out( oe, ".", paren, NOPAD, file ); + EXPRESSION_out(oe->op1, 1, file); + fprintf(file, "._scl_group("); + EXPRESSION_out(oe->op2, 0, file); + fprintf(file, ")"); break; case OP_NEGATE: EXPRESSIONop1_out( oe, "-", paren, file ); From fd8b7e3a6bd0ff885f58e02b0824f2a3c1801336 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Tue, 22 Mar 2022 22:16:44 +0000 Subject: [PATCH 185/244] exp2py: reduce TYPE output to class level pass statement for simple types --- src/exp2python/src/classes_python.c | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index fe0d51e70..136ff8025 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -2012,22 +2012,26 @@ TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { } else { fprintf( files->lib, "%s):\n", output ); } - fprintf( files->lib, "\tdef __init__(self,*kargs):\n" ); - fprintf( files->lib, "\t\tpass\n" ); - /* call the where / rules */ - LISTdo( type->where, w, Where ) - if( strcmp( w->label->name, "" ) ) { - /* define a function with the name 'label' */ - fprintf( files->lib, "\t\tself.%s()\n", w->label->name ); - } else { - /* no label */ - fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number ); - where_rule_number ++; + + if (LISTempty(type->where)) { + fprintf( files->lib, "\tpass\n" ); + } else { + fprintf( files->lib, "\tdef __init__(self, *args):\n" ); + /* call the where / rules */ + LISTdo( type->where, w, Where ) + if( strcmp( w->label->name, "" ) ) { + /* define a function with the name 'label' */ + fprintf( files->lib, "\t\tself.%s()\n", w->label->name ); + } else { + /* no label */ + fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number ); + where_rule_number ++; + } + LISTod + fprintf( files->lib, "\n" ); + /* then we process the where rules */ + WHEREPrint( type->where, 0, files->lib ); } - LISTod - fprintf( files->lib, "\n" ); - /* then we process the where rules */ - WHEREPrint( type->where, 0, files->lib ); } } else { /* TODO: cleanup, currently this is deadcode */ switch( TYPEget_body( type )->type ) { From 0fd354cb397e0d9e994a8ab613f2283b5bac35ba Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 14:25:49 -0500 Subject: [PATCH 186/244] Make sure BUFSIZ buffers have room for NULL In case we do end up with buffers with contents at the BUFSIZ limit, make sure we leave room to set a null termination char. Not always clear where these buffers might get used or re-used, so just bump their size across the board. --- cmake/schema_scanner/schemaScanner.cc | 2 +- src/cleditor/STEPfile.cc | 12 +++---- src/cleditor/STEPfile.inline.cc | 6 ++-- src/clstepcore/Registry.cc | 2 +- src/clstepcore/STEPaggrEntity.cc | 2 +- src/clstepcore/STEPaggrInt.cc | 2 +- src/clstepcore/STEPaggrSelect.cc | 2 +- src/clstepcore/STEPaggregate.cc | 2 +- src/clstepcore/STEPattribute.cc | 4 +-- src/clstepcore/STEPcomplex.cc | 8 ++--- src/clstepcore/complexSupport.h | 4 +-- src/clstepcore/enumTypeDescriptor.cc | 2 +- src/clstepcore/instmgr.cc | 2 +- src/clstepcore/read_func.cc | 4 +-- src/clstepcore/schRename.h | 4 +-- src/clstepcore/sdaiApplication_instance.cc | 20 +++++------ src/clstepcore/typeDescriptor.cc | 2 +- src/clstepcore/typeDescriptor.h | 2 +- src/clutils/Str.cc | 8 ++--- src/exp2cxx/class_strings.c | 6 ++-- src/exp2cxx/classes.c | 4 +-- src/exp2cxx/classes_attribute.c | 28 +++++++-------- src/exp2cxx/classes_entity.c | 20 +++++------ src/exp2cxx/classes_misc.c | 6 ++-- src/exp2cxx/classes_type.c | 36 +++++++++---------- src/exp2cxx/complexSupport.h | 4 +-- src/exp2cxx/genCxxFilenames.c | 4 +-- src/exp2cxx/multpass.c | 6 ++-- src/exp2cxx/selects.c | 42 +++++++++++----------- src/exp2python/src/classes_misc_python.c | 6 ++-- src/exp2python/src/classes_python.c | 8 ++--- src/exp2python/src/complexSupport.h | 4 +-- src/exp2python/src/multpass_python.c | 2 +- src/exp2python/src/selects_python.c | 10 +++--- src/exppp/exppp.c | 2 +- 35 files changed, 139 insertions(+), 139 deletions(-) diff --git a/cmake/schema_scanner/schemaScanner.cc b/cmake/schema_scanner/schemaScanner.cc index 88bd110ae..7f1d167c0 100644 --- a/cmake/schema_scanner/schemaScanner.cc +++ b/cmake/schema_scanner/schemaScanner.cc @@ -220,7 +220,7 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei, cmLists.close(); - char pwd[BUFSIZ] = {0}; + char pwd[BUFSIZ+1] = {0}; if( getcwd( pwd, BUFSIZ ) ) { cout << pwd << "/" << shortName << endl; } else { diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index cb1fe5bca..2d0da93bf 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -117,7 +117,7 @@ Severity STEPfile::ReadHeader( istream & in ) { int fileid; std::string keywd; char c = '\0'; - char buf [BUFSIZ]; + char buf [BUFSIZ+1]; std::string strbuf; @@ -442,7 +442,7 @@ int STEPfile::ReadData1( istream & in ) { char c; int instance_count = 0; - char buf[BUFSIZ]; + char buf[BUFSIZ+1]; buf[0] = '\0'; std::string tmpbuf; @@ -565,7 +565,7 @@ int STEPfile::ReadData2( istream & in, bool useTechCor ) { _warningCount = 0; // reset error count char c; - char buf[BUFSIZ]; + char buf[BUFSIZ+1]; buf[0] = '\0'; std::string tmpbuf; @@ -730,7 +730,7 @@ int STEPfile::FindDataSection( istream & in ) { } int STEPfile::FindHeaderSection( istream & in ) { - char buf[BUFSIZ]; + char buf[BUFSIZ+1]; char * b = buf; *b = '\0'; @@ -1150,7 +1150,7 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out, Severity sev = SEVERITY_NULL; std::string tmpbuf; - char errbuf[BUFSIZ]; + char errbuf[BUFSIZ+1]; errbuf[0] = '\0'; std::string currSch; std::string objnm; @@ -1603,7 +1603,7 @@ void STEPfile::WriteValuePairsData( ostream & out, int writeComments, int mixedC Severity STEPfile::AppendFile( istream * in, bool useTechCor ) { Severity rval = SEVERITY_NULL; - char errbuf[BUFSIZ]; + char errbuf[BUFSIZ+1]; SetFileIdIncrement(); int total_insts = 0, valid_insts = 0; diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 0c5b937e0..f67bc3978 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -179,7 +179,7 @@ istream * STEPfile::OpenInputFile( const std::string filename ) { return( 0 ); } else { if( SetFileName( filename ).empty() && ( filename.compare( "-" ) != 0 ) ) { - char msg[BUFSIZ]; + char msg[BUFSIZ+1]; sprintf( msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str() ); _error.AppendToUserMsg( msg ); _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); @@ -196,7 +196,7 @@ istream * STEPfile::OpenInputFile( const std::string filename ) { } if( !in || !( in -> good() ) ) { - char msg[BUFSIZ]; + char msg[BUFSIZ+1]; sprintf( msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str() ); _error.AppendToUserMsg( msg ); _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); @@ -231,7 +231,7 @@ ofstream * STEPfile::OpenOutputFile( std::string filename ) { } } else { if( SetFileName( filename ).empty() ) { - char msg[BUFSIZ]; + char msg[BUFSIZ+1]; sprintf( msg, "can't find file: %s\nFile not written.\n", filename.c_str() ); _error.AppendToUserMsg( msg ); _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 2e5eb490f..a97c37e82 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -79,7 +79,7 @@ void Registry::DeleteContents() { const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const { const EntityDescriptor * entd; const SchRename * altlist; - char schformat[BUFSIZ], altName[BUFSIZ]; + char schformat[BUFSIZ+1], altName[BUFSIZ+1]; if( check_case ) { entd = ( EntityDescriptor * )SC_HASHfind( primordialSwamp, ( char * )e ); diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index bda8f6db5..057c491fd 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -21,7 +21,7 @@ Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, int addFileId, int assignVal, int exchangeFileFormat, const char * ) { ErrorDescriptor errdesc; - char errmsg[BUFSIZ]; + char errmsg[BUFSIZ+1]; int value_cnt = 0; std::string buf; diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index 2e61a1504..3989e82f9 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -94,7 +94,7 @@ const char * IntNode::asStr( std::string & s ) { } const char * IntNode::STEPwrite( std::string & s, const char * ) { - char tmp[BUFSIZ]; + char tmp[BUFSIZ+1]; if( value != S_INT_NULL ) { sprintf( tmp, "%ld", value ); s = tmp; diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index 02970479c..2e02113d7 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -19,7 +19,7 @@ Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err, int addFileId, int assignVal, int exchangeFileFormat, const char * currSch ) { ErrorDescriptor errdesc; - char errmsg[BUFSIZ]; + char errmsg[BUFSIZ+1]; int value_cnt = 0; std::string buf; diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index db3bbf819..960a7866c 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -106,7 +106,7 @@ Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err, (void) addFileId; //not used in ReadValue() for this class ErrorDescriptor errdesc; - char errmsg[BUFSIZ]; + char errmsg[BUFSIZ+1]; int value_cnt = 0; std::string buf; diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index e25409dec..a378ae2b7 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -1263,7 +1263,7 @@ ostream & operator<< ( ostream & out, STEPattribute & a ) { * value. ******************************************************************/ void STEPattribute::AddErrorInfo() { - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; if( SEVERITY_INPUT_ERROR < _error.severity() && _error.severity() < SEVERITY_NULL ) { @@ -1293,7 +1293,7 @@ char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { // read bad data until end of this attribute or entity. char * foundCh = 0; char c = '\0'; - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; _error.GreaterSeverity( SEVERITY_WARNING ); diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 5daf31ab7..1178a7ca3 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -20,7 +20,7 @@ STEPcomplex::STEPcomplex( Registry * registry, int fileid ) STEPcomplex::STEPcomplex( Registry * registry, const std::string ** names, int fileid, const char * schnm ) : SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) { - char * nms[BUFSIZ]; + char * nms[BUFSIZ+1]; int j, k; head = this; @@ -61,7 +61,7 @@ void STEPcomplex::Initialize( const char ** names, const char * schnm ) { EntNode * ents = new EntNode( names ), *eptr = ents, *prev = NULL, *enext; const EntityDescriptor * enDesc; - char nm[BUFSIZ]; + char nm[BUFSIZ+1]; bool invalid = false, outOfOrder = false; // Splice out the invalid names from our list: @@ -659,7 +659,7 @@ const char * STEPcomplex::WriteExtMapEntities( std::string & buf, const char * c void STEPcomplex::CopyAs( SDAI_Application_instance * se ) { if( !se->IsComplex() ) { - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; cerr << "STEPcomplex::CopyAs() called with non-complex entity: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; sprintf( errStr, @@ -700,7 +700,7 @@ SDAI_Application_instance * STEPcomplex::Replicate() { } nameList[i] = ( std::string * )0; if( i == 63 ) { - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; cerr << "STEPcomplex::Replicate() name buffer too small: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; sprintf( errStr, diff --git a/src/clstepcore/complexSupport.h b/src/clstepcore/complexSupport.h index cd2d9611f..f7d3db734 100644 --- a/src/clstepcore/complexSupport.h +++ b/src/clstepcore/complexSupport.h @@ -132,7 +132,7 @@ class SC_CORE_EXPORT EntNode { private: MarkType mark; - char name[BUFSIZ]; + char name[BUFSIZ+1]; bool multSupers; ///< do I correspond to an entity with >1 supertype? EntNode * lastSmaller( EntNode * ); ///< used by ::sort() }; @@ -238,7 +238,7 @@ class SC_CORE_EXPORT SimpleList : public EntList { } private: - char name[BUFSIZ]; ///< Name of entity we correspond to. + char name[BUFSIZ+1]; ///< Name of entity we correspond to. MarkType I_marked; ///< Did I mark, and with what type of mark. }; diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 9200b196f..9598702f0 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -25,7 +25,7 @@ SDAI_Enum * EnumTypeDescriptor::CreateEnum() { } const char * EnumTypeDescriptor::GenerateExpress( std::string & buf ) const { - char tmp[BUFSIZ]; + char tmp[BUFSIZ+1]; buf = "TYPE "; buf.append( StrToLower( Name(), tmp ) ); buf.append( " = ENUMERATION OF \n (" ); diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 702ea0869..0f74b27c0 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -94,7 +94,7 @@ void InstMgr::DeleteInstances() { enum Severity InstMgr::VerifyInstances( ErrorDescriptor & err ) { int errorCount = 0; - char errbuf[BUFSIZ]; + char errbuf[BUFSIZ+1]; int n = InstanceCount(); MgrNode * mn; diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index 395e52cfd..a0c47dc2a 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -467,7 +467,7 @@ void PushPastString( istream & in, std::string & s, ErrorDescriptor * err ) { * This is used to read aggregates that are part of multidimensional aggregates. */ void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { - char messageBuf[BUFSIZ]; + char messageBuf[BUFSIZ+1]; messageBuf[0] = '\0'; char c; @@ -506,7 +506,7 @@ void PushPastImbedAggr( istream & in, std::string & s, ErrorDescriptor * err ) { * to contain an aggregate as an element. */ void PushPastAggr1Dim( istream & in, std::string & s, ErrorDescriptor * err ) { - char messageBuf[BUFSIZ]; + char messageBuf[BUFSIZ+1]; messageBuf[0] = '\0'; char c; diff --git a/src/clstepcore/schRename.h b/src/clstepcore/schRename.h index a0403a5d8..154cce0a3 100644 --- a/src/clstepcore/schRename.h +++ b/src/clstepcore/schRename.h @@ -41,8 +41,8 @@ class SC_CORE_EXPORT SchRename { SchRename * next; private: - char schName[BUFSIZ]; - char newName[BUFSIZ]; + char schName[BUFSIZ+1]; + char newName[BUFSIZ+1]; }; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index c6635fd61..3d34f8efa 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -102,7 +102,7 @@ void SDAI_Application_instance::InitIAttrs() { } SDAI_Application_instance * SDAI_Application_instance::Replicate() { - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; if( IsComplex() ) { cerr << "STEPcomplex::Replicate() should be called: " << __FILE__ << __LINE__ << "\n" << _POC_ "\n"; @@ -416,7 +416,7 @@ void SDAI_Application_instance::WriteValuePairs( ostream & out, const char * SDAI_Application_instance::STEPwrite( std::string & buf, const char * currSch ) { buf.clear(); - char instanceInfo[BUFSIZ]; + char instanceInfo[BUFSIZ+1]; std::string tmp; sprintf( instanceInfo, "#%d=%s(", STEPfile_id, StrToUpper( EntityName( currSch ), tmp ) ); @@ -438,7 +438,7 @@ const char * SDAI_Application_instance::STEPwrite( std::string & buf, const char } void SDAI_Application_instance::PrependEntityErrMsg() { - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; if( _error.severity() == SEVERITY_NULL ) { @@ -459,7 +459,7 @@ void SDAI_Application_instance::PrependEntityErrMsg() { ******************************************************************/ void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, const char * schnm ) { (void) in; - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; if( _error.severity() == SEVERITY_NULL ) { @@ -511,7 +511,7 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, const char * currSch, bool useTechCor, bool strict ) { STEPfile_id = id; char c = '\0'; - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; Severity severe; int i = 0; @@ -663,7 +663,7 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList, InstMgrBase * instances, int addFileId ) { char c; - char errStr[BUFSIZ]; + char errStr[BUFSIZ+1]; errStr[0] = '\0'; in >> ws; @@ -756,7 +756,7 @@ Severity EntityValidLevel( SDAI_Application_instance * se, // to match. (this must be an // EntityDescriptor) ErrorDescriptor * err ) { - char messageBuf [BUFSIZ]; + char messageBuf [BUFSIZ+1]; messageBuf[0] = '\0'; if( !ed || ( ed->NonRefType() != ENTITY_TYPE ) ) { @@ -825,7 +825,7 @@ Severity EntityValidLevel( SDAI_Application_instance * se, * DAVE: Is this needed will sscanf return 1 if assignment suppression is used? */ int SetErrOnNull( const char * attrValue, ErrorDescriptor * error ) { - char scanBuf[BUFSIZ]; + char scanBuf[BUFSIZ+1]; scanBuf[0] = '\0'; std::stringstream fmtstr; @@ -853,9 +853,9 @@ Severity EntityValidLevel( const char * attrValue, // string contain entity ref // to match. (this must be an // EntityDescriptor) ErrorDescriptor * err, InstMgrBase * im, int clearError ) { - char tmp [BUFSIZ]; + char tmp [BUFSIZ+1]; tmp[0] = '\0'; - char messageBuf [BUFSIZ]; + char messageBuf [BUFSIZ+1]; messageBuf[0] = '\0'; std::stringstream fmtstr1, fmtstr2; diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index e37d931bb..31ead1662 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -132,7 +132,7 @@ void TypeDescriptor::AttrTypeName( std::string & buf, const char * schnm ) const } const char * TypeDescriptor::GenerateExpress( std::string & buf ) const { - char tmp[BUFSIZ]; + char tmp[BUFSIZ+1]; buf = "TYPE "; buf.append( StrToLower( Name(), tmp ) ); buf.append( " = " ); diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 915c1831d..7fb53a53c 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -111,7 +111,7 @@ class SC_CORE_EXPORT TypeDescriptor { /// schema which USEs/ REFERENCEs this. (A complete list of /// alternate names is stored in altNames below. _altname pro- /// vides storage space for the currently used one.) - char _altname[BUFSIZ]; + char _altname[BUFSIZ+1]; /// contains list of renamings of type - used by other schemas /// which USE/ REFERENCE this diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index a14f0dc08..4ae8ef69c 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -53,7 +53,7 @@ char * StrToLower( const char * strOld, char * strNew ) { } const char * StrToLower( const char * word, std::string & s ) { - char newword [BUFSIZ]; + char newword [BUFSIZ+1]; int i = 0; while( word [i] != '\0' ) { @@ -66,7 +66,7 @@ const char * StrToLower( const char * word, std::string & s ) { } const char * StrToUpper( const char * word, std::string & s ) { - char newword [BUFSIZ]; + char newword [BUFSIZ+1]; int i = 0; while( word [i] != '\0' ) { @@ -79,7 +79,7 @@ const char * StrToUpper( const char * word, std::string & s ) { } const char * StrToConstant( const char * word, std::string & s ) { - char newword [BUFSIZ]; + char newword [BUFSIZ+1]; int i = 0; while( word [i] != '\0' ) { @@ -179,7 +179,7 @@ std::string GetLiteralStr( istream & in, ErrorDescriptor * err ) { ******************************************************************/ const char * PrettyTmpName( const char * oldname ) { int i = 0; - static char newname [BUFSIZ]; + static char newname [BUFSIZ+1]; newname [0] = '\0'; while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { newname [i] = ToLower( oldname [i] ); diff --git a/src/exp2cxx/class_strings.c b/src/exp2cxx/class_strings.c index d1736a644..8bae77746 100644 --- a/src/exp2cxx/class_strings.c +++ b/src/exp2cxx/class_strings.c @@ -6,7 +6,7 @@ const char * ClassName( const char * oldname ) { int i = 0, j = 0; - static char newname [BUFSIZ]; + static char newname [BUFSIZ+1]; if( !oldname ) { return ( "" ); } @@ -152,12 +152,12 @@ const char * TYPE_get_ctype( const Type t, char * retval, size_t buf_siz ) { } const char * TYPEget_ctype( const Type t ) { - static char retval [BUFSIZ] = {0}; + static char retval [BUFSIZ+1] = {0}; return TYPE_get_ctype( t, retval, BUFSIZ ); } const char * TypeName( Type t ) { - static char name [BUFSIZ]; + static char name [BUFSIZ+1]; strcpy( name, TYPE_PREFIX ); if( TYPEget_name( t ) ) { strncat( name, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - strlen( TYPE_PREFIX ) - 1 ); diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 0f1494ded..26e39a909 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -104,8 +104,8 @@ void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * t DictionaryEntry de; struct Rename * r; Linked_List list; - char td_name[BUFSIZ]; - char sch_name[BUFSIZ]; + char td_name[BUFSIZ+1]; + char sch_name[BUFSIZ+1]; strncpy( sch_name, PrettyTmpName( SCHEMAget_name( schema ) ), BUFSIZ ); diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index f304ba176..b97e2f95d 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -102,7 +102,7 @@ bool attrIsObj( Type t ) { * \p attr_count_tmp is a _copy_ of attr_count */ void ATTRnames_print( Entity entity, FILE* file ) { - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; LISTdo( ENTITYget_attributes( entity ), v, Variable ) { generate_attribute_name( v, attrnm ); @@ -121,7 +121,7 @@ void ATTRnames_print( Entity entity, FILE* file ) { * \param file file being written to */ void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; const char * ctype, * etype; if( !VARget_inverse( a ) && ( VARget_initializer( a ) == EXPRESSION_NULL ) ) { ctype = TYPEget_ctype( VARget_type( a ) ); @@ -165,8 +165,8 @@ void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { void ATTRsign_access_methods( Variable a, FILE * file ) { Type t = VARget_type( a ); - char ctype [BUFSIZ]; - char attrnm [BUFSIZ]; + char ctype [BUFSIZ+1]; + char attrnm [BUFSIZ+1]; generate_attribute_func_name( a, attrnm ); @@ -208,8 +208,8 @@ void ATTRsign_access_methods( Variable a, FILE * file ) { ******************************************************************/ void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * file, bool returnsConst ) { Type t = VARget_type( a ); - char ctype [BUFSIZ]; /* return type of the get function */ - char funcnm [BUFSIZ]; /* name of member function */ + char ctype [BUFSIZ+1]; /* return type of the get function */ + char funcnm [BUFSIZ+1]; /* name of member function */ generate_attribute_func_name( a, funcnm ); strncpy( ctype, AccessType( t ), BUFSIZ ); ctype[BUFSIZ-1] = '\0'; @@ -240,8 +240,8 @@ void ATTRprint_access_methods_get_head( const char * classnm, Variable a, FILE * void ATTRprint_access_methods_put_head( const char * entnm, Variable a, FILE * file ) { Type t = VARget_type( a ); - char ctype [BUFSIZ]; - char funcnm [BUFSIZ]; + char ctype [BUFSIZ+1]; + char funcnm [BUFSIZ+1]; generate_attribute_func_name( a, funcnm ); @@ -442,7 +442,7 @@ void ATTRprint_access_methods_log_bool( const char * entnm, const char * attrnm, /** print access methods for inverse attrs, using iAMap */ void INVprint_access_methods( const char * entnm, const char * attrnm, const char * funcnm, const char * nm, const char * ctype, Variable a, FILE * file, Schema schema ) { - char iaName[BUFSIZ] = {0}; + char iaName[BUFSIZ+1] = {0}; snprintf( iaName, BUFSIZ - 1, "%s::%s%d%s%s", SCHEMAget_name( schema ), ATTR_PREFIX, a->idx, /* can it ever be anything but "I"? */ ( VARis_derived( a ) ? "D" : ( VARis_type_shifter( a ) ? "R" : ( VARget_inverse( a ) ? "I" : "" ) ) ), attrnm ); @@ -490,12 +490,12 @@ void INVprint_access_methods( const char * entnm, const char * attrnm, const cha void ATTRprint_access_methods( const char * entnm, Variable a, FILE * file, Schema schema ) { Type t = VARget_type( a ); Class_Of_Type classType; - char ctype [BUFSIZ]; /* type of data member */ - char attrnm [BUFSIZ]; - char membernm[BUFSIZ]; - char funcnm [BUFSIZ]; /* name of member function */ + char ctype [BUFSIZ+1]; /* type of data member */ + char attrnm [BUFSIZ+1]; + char membernm[BUFSIZ+1]; + char funcnm [BUFSIZ+1]; /* name of member function */ - char nm [BUFSIZ]; + char nm [BUFSIZ+1]; /* I believe nm has the name of the underlying type without Sdai in front of it */ if( TYPEget_name( t ) ) { strncpy( nm, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - 1 ); diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 10a6af92c..00035380f 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -59,7 +59,7 @@ void ENTITYnames_print( Entity entity, FILE * file ) { * \param schema schema being processed */ void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; fprintf( file, "EntityDescriptor * %s::%s%s = 0;\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); LISTdo( ENTITYget_attributes( entity ), v, Variable ) { @@ -81,7 +81,7 @@ void LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { void LIBmemberFunctionPrint( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; - char entnm [BUFSIZ]; + char entnm [BUFSIZ+1]; strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ @@ -149,7 +149,7 @@ int get_attribute_number( Entity entity ) { * \p file file being written to */ void ENTITYhead_print( Entity entity, FILE * file ) { - char entnm [BUFSIZ]; + char entnm [BUFSIZ+1]; Linked_List list; Entity super = 0; @@ -180,7 +180,7 @@ void ENTITYhead_print( Entity entity, FILE * file ) { * skip inverse attrs */ void DataMemberInit( bool * first, Variable a, FILE * lib ) { - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; if( VARis_derived( a ) || VARget_inverse( a ) ) { return; } @@ -244,7 +244,7 @@ void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) { Linked_List attr_list; static int entcode = 0; - char entnm [BUFSIZ]; + char entnm [BUFSIZ+1]; strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */ entnm[BUFSIZ-1] = '\0'; @@ -328,7 +328,7 @@ void initializeAttrs( Entity e, FILE* file ) { void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; Linked_List list; Entity principalSuper = 0; @@ -489,13 +489,13 @@ void LIBstructor_print( Entity entity, Linked_List neededAttr, FILE * file, Sche void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * file, Schema schema ) { Linked_List attr_list; Type t; - char attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; Linked_List list; int super_cnt = 0; /* added for calling parents constructor if there is one */ - char parentnm [BUFSIZ]; + char parentnm [BUFSIZ+1]; char * parent = 0; const char * entnm; @@ -690,8 +690,8 @@ char * generate_dict_attr_name( Variable a, char * out ) { void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schema ) { #define entity_name ENTITYget_name(entity) #define schema_name SCHEMAget_name(schema) - char attrnm [BUFSIZ]; - char dict_attrnm [BUFSIZ]; + char attrnm [BUFSIZ+1]; + char dict_attrnm [BUFSIZ+1]; const char * super_schema; char * tmp, *tmp2; bool hasInverse = false; diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 4b5226912..8fde1a808 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -70,7 +70,7 @@ int isAggregateType( const Type t ) { /** \returns a pointer to a static buffer, containing a string which is the type used by the c++ data member access functions */ const char * AccessType( Type t ) { Class_Of_Type class; - static char nm [BUFSIZ]; + static char nm [BUFSIZ+1]; strncpy( nm, TypeName( t ), BUFSIZ - 4 ); if( TYPEis_entity( t ) ) { strcat( nm, "_ptr" ); @@ -102,7 +102,7 @@ const char * AccessType( Type t ) { */ const char * PrettyTmpName( const char * oldname ) { int i = 0; - static char newname [BUFSIZ]; + static char newname [BUFSIZ+1]; newname [0] = '\0'; while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { newname [i] = ToLower( oldname [i] ); @@ -203,7 +203,7 @@ const char * FundamentalType( const Type t, int report_reftypes ) { * TypeDescriptor or subtype of TypeDescriptor to represent Type t in the dictionary. */ const char * TypeDescriptorName( Type t ) { - static char b [BUFSIZ]; + static char b [BUFSIZ+1]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 95c76dbb0..e6a6967e0 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -101,7 +101,7 @@ void strcat_bounds( TypeBody b, char * buf ) { ** Change Date: 5/22/91 CD ******************************************************************/ const char * EnumCElementName( Type type, Expression expr ) { - static char buf [BUFSIZ]; + static char buf [BUFSIZ+1]; sprintf( buf, "%s__", EnumName( TYPEget_name( type ) ) ); strcat( buf, StrToLower( EXPget_name( expr ) ) ); @@ -110,7 +110,7 @@ const char * EnumCElementName( Type type, Expression expr ) { } char * CheckEnumSymbol( char * s ) { - static char b [BUFSIZ]; + static char b [BUFSIZ+1]; if( strcmp( s, "sdaiTRUE" ) && strcmp( s, "sdaiFALSE" ) && strcmp( s, "sdaiUNKNOWN" ) ) { @@ -153,8 +153,8 @@ char * TypeDescription( const Type t ) { void TYPEenum_inc_print( const Type type, FILE * inc ) { Expression expr; - char tdnm[BUFSIZ], - enumAggrNm[BUFSIZ]; + char tdnm[BUFSIZ+1], + enumAggrNm[BUFSIZ+1]; const char * n; /* pointer to class name */ int cnt = 0; @@ -250,7 +250,7 @@ void TYPEenum_lib_print( const Type type, FILE * f ) { DictionaryEntry de; Expression expr; const char * n; /* pointer to class name */ - char c_enum_ele [BUFSIZ]; + char c_enum_ele [BUFSIZ+1]; n = TYPEget_ctype( type ); @@ -380,7 +380,7 @@ static void printEnumCreateHdr( FILE * inc, const Type type ) { /** See header comment above by printEnumCreateHdr. */ static void printEnumCreateBody( FILE * lib, const Type type ) { const char * nm = TYPEget_ctype( type ); - char tdnm[BUFSIZ]; + char tdnm[BUFSIZ+1]; tdnm[BUFSIZ-1] = '\0'; strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); @@ -399,7 +399,7 @@ static void printEnumAggrCrHdr( FILE * inc, const Type type ) { static void printEnumAggrCrBody( FILE * lib, const Type type ) { const char * n = TYPEget_ctype( type ); - char tdnm[BUFSIZ]; + char tdnm[BUFSIZ+1]; strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); tdnm[BUFSIZ-1] = '\0'; @@ -424,7 +424,7 @@ static void printEnumAggrCrBody( FILE * lib, const Type type ) { ** Dec 2011 - MAP - remove goto **************************************************************************/ void TYPEprint_typedefs( Type t, FILE * classes ) { - char nm [BUFSIZ]; + char nm [BUFSIZ+1]; Type i; bool aggrNot1d = true; /* added so I can get rid of a goto */ @@ -506,10 +506,10 @@ void TYPEprint_typedefs( Type t, FILE * classes ) { TYPEprint_init() (below) which is done in exp2cxx's 1st pass only.) *****/ void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { - char tdnm [BUFSIZ], - typename_buf [MAX_LEN], - base [BUFSIZ], - nm [BUFSIZ]; + char tdnm [BUFSIZ+1], + typename_buf [MAX_LEN+1], + base [BUFSIZ+1], + nm [BUFSIZ+1]; Type i; strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); @@ -563,8 +563,8 @@ void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { } void TYPEprint_init( const Type type, FILE * header, FILE * impl, Schema schema ) { - char tdnm [BUFSIZ]; - char typename_buf[MAX_LEN]; + char tdnm [BUFSIZ+1]; + char typename_buf[MAX_LEN+1]; strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); @@ -1026,7 +1026,7 @@ void TypeBody_Description( TypeBody body, char * buf ) { } const char * IdlEntityTypeName( Type t ) { - static char name [BUFSIZ]; + static char name [BUFSIZ+1]; strcpy( name, TYPE_PREFIX ); if( TYPEget_name( t ) ) { strcpy( name, FirstToUpper( TYPEget_name( t ) ) ); @@ -1039,7 +1039,7 @@ const char * IdlEntityTypeName( Type t ) { const char * GetAggrElemType( const Type type ) { Class_Of_Type class; Type bt; - static char retval [BUFSIZ]; + static char retval [BUFSIZ+1]; if( isAggregateType( type ) ) { bt = TYPEget_nonaggregate_base_type( type ); @@ -1097,7 +1097,7 @@ const char * GetAggrElemType( const Type type ) { const char * TYPEget_idl_type( const Type t ) { Class_Of_Type class; - static char retval [BUFSIZ]; + static char retval [BUFSIZ+1]; /* aggregates are based on their base type case TYPE_ARRAY: @@ -1202,7 +1202,7 @@ const char * TYPEget_idl_type( const Type t ) { char * TYPEget_express_type( const Type t ) { Class_Of_Type class; Type bt; - char retval [BUFSIZ]; + char retval [BUFSIZ+1]; char * n, * permval, * aggr_type; diff --git a/src/exp2cxx/complexSupport.h b/src/exp2cxx/complexSupport.h index 8277a03fa..baf02dbbe 100644 --- a/src/exp2cxx/complexSupport.h +++ b/src/exp2cxx/complexSupport.h @@ -116,7 +116,7 @@ class EntNode { private: MarkType mark; - char name[BUFSIZ]; + char name[BUFSIZ+1]; int multSupers; // do I correspond to an entity with >1 supertype? }; @@ -225,7 +225,7 @@ class SimpleList : public EntList { void write( ostream & ); private: - char name[BUFSIZ]; // Name of entity we correspond to. + char name[BUFSIZ+1]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index 47004e43d..3b90d1cf2 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -17,8 +17,8 @@ */ /* these buffers are shared amongst (and potentially overwritten by) all functions in this file */ -char impl[ BUFSIZ ] = {0}; -char header[ BUFSIZ ] = {0}; +char impl[ BUFSIZ+1 ] = {0}; +char header[ BUFSIZ+1 ] = {0}; /* struct containing pointers to above buffers. pointers are 'const char *' */ filenames_t fnames = { impl, header }; diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 51a210ecb..5028c8246 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -608,7 +608,7 @@ static int inSchema( Scope scope, Scope super ) static void addRenameTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; - char nm[BUFSIZ], basenm[BUFSIZ]; + char nm[BUFSIZ+1], basenm[BUFSIZ+1]; static bool firsttime = true; SCOPEdo_types( schema, t, de ) { @@ -654,7 +654,7 @@ static void addAggrTypedefs( Schema schema, FILE * classes ) { DictionaryEntry de; Type i; static bool firsttime = true; - char nm[BUFSIZ]; + char nm[BUFSIZ+1]; SCOPEdo_types( schema, t, de ) { if( TYPEis_aggregate( t ) ) { @@ -691,7 +691,7 @@ static void addUseRefNames( Schema schema, FILE * create ) { Dictionary useRefDict; DictionaryEntry de; Rename * rnm; - char * oldnm, schNm[BUFSIZ]; + char * oldnm, schNm[BUFSIZ+1]; static bool firsttime = true; if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index afd490832..1c82796a6 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -123,7 +123,7 @@ static int compareOrigTypes( Type a, Type b ) { compareOrigTypes() above). */ const char * utype_member( const Linked_List list, const Type check, int rename ) { - static char r [BUFSIZ]; + static char r [BUFSIZ+1]; bool checkIsEntity = TYPEis_entity( check ); LISTdo( list, t, Type ) { @@ -244,7 +244,7 @@ int unique_types( const Linked_List list ) { RETURNS 1 if true, else 0. */ int duplicate_utype_member( const Linked_List list, const Type check ) { - char b [BUFSIZ]; + char b [BUFSIZ+1]; if( TYPEis_entity( check ) ) { return FALSE; @@ -397,7 +397,7 @@ char * non_unique_types_string( const Type type ) { non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = ( char * )sc_malloc( BUFSIZ ); + typestr = ( char * )sc_malloc( BUFSIZ + 1 ); typestr[0] = '\0'; strcat( typestr, ( char * )"(" ); for( i = 0; i <= tnumber; i++ ) { @@ -450,8 +450,8 @@ char * non_unique_types_string( const Type type ) { * \returns the attribute 'check' if an attribute with the same name is on the list, 0 otherwise */ Variable ATTR_LISTmember( Linked_List l, Variable check ) { - char nm [BUFSIZ]; - char cur [BUFSIZ]; + char nm [BUFSIZ+1]; + char cur [BUFSIZ+1]; generate_attribute_name( check, nm ); LISTdo( l, a, Variable ) { @@ -494,9 +494,9 @@ Linked_List SEL_TYPEgetnew_attribute_list( const Type type ) { void TYPEselect_inc_print_vars( const Type type, FILE * f, Linked_List dups ) { int size, j; Linked_List data_members = SELgetnew_dmlist( type ); - char dmname [BUFSIZ], - classnm [BUFSIZ], - tdnm [BUFSIZ]; + char dmname [BUFSIZ+1], + classnm [BUFSIZ+1], + tdnm [BUFSIZ+1]; strncpy( classnm, SelectName( TYPEget_name( type ) ), BUFSIZ ); classnm[BUFSIZ-1] = '\0'; @@ -583,8 +583,8 @@ void TYPEselect_inc_print_vars( const Type type, FILE * f, Linked_List dups ) { * class. */ void TYPEselect_inc_print( const Type type, FILE * f ) { - char n[BUFSIZ]; /* class name */ - char tdnm [BUFSIZ]; /* TypeDescriptor name */ + char n[BUFSIZ+1]; /* class name */ + char tdnm [BUFSIZ+1]; /* TypeDescriptor name */ Linked_List dups; int dup_result; Linked_List attrs; @@ -708,8 +708,8 @@ void TYPEselect_inc_print( const Type type, FILE * f ) { void TYPEselect_lib_print_part_one( const Type type, FILE * f, Linked_List dups, char * n ) { #define schema_name SCHEMAget_name(schema) - char tdnm[BUFSIZ], - nm[BUFSIZ]; + char tdnm[BUFSIZ+1], + nm[BUFSIZ+1]; int size = strlen( n ) * 2 + 4, j; /* size - for formatting output */ strncpy( tdnm, TYPEtd_name( type ), BUFSIZ ); @@ -1049,10 +1049,10 @@ void TYPEselect_lib_part_three_getter( const Type type, const char * classnm, co void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm ) { #define ENTITYget_type(e) ((e)->u.entity->type) - char uent[BUFSIZ], /* name of underlying entity type */ - utype[BUFSIZ], /* underlying type name */ - attrnm [BUFSIZ], /* attribute name -> data member = _attrnm */ - funcnm[BUFSIZ]; /* access function name = Attrnm */ + char uent[BUFSIZ+1], /* name of underlying entity type */ + utype[BUFSIZ+1], /* underlying type name */ + attrnm [BUFSIZ+1], /* attribute name -> data member = _attrnm */ + funcnm[BUFSIZ+1]; /* access function name = Attrnm */ Linked_List items = SEL_TYPEget_items( type ); /* all the items in the select type */ Linked_List attrs = SEL_TYPEgetnew_attribute_list( type ); @@ -1151,7 +1151,7 @@ void TYPEselect_lib_print_part_three( const Type type, FILE * f, char * classnm * TYPEselect_lib_print_part_four prints part 4 of the SDAI document of a select class. */ void TYPEselect_lib_print_part_four( const Type type, FILE * f, Linked_List dups, char * n ) { - char x[BUFSIZ]; + char x[BUFSIZ+1]; fprintf( f, "\n // part 4\n" ); @@ -1280,7 +1280,7 @@ void TYPEselect_init_print( const Type type, FILE * f ) { } void TYPEselect_lib_part21( const Type type, FILE * f ) { - char n[BUFSIZ]; /* pointers to class name(s) */ + char n[BUFSIZ+1]; /* pointers to class name(s) */ const char * dm; /* data member name */ Linked_List data_members = SELgetnew_dmlist( type ); @@ -1554,7 +1554,7 @@ void TYPEselect_lib_part21( const Type type, FILE * f ) { void TYPEselect_lib_StrToVal( const Type type, FILE * f ) { - char n[BUFSIZ]; /* pointers to class name */ + char n[BUFSIZ+1]; /* pointers to class name */ Linked_List data_members = SELgetnew_dmlist( type ); int enum_cnt = 0; @@ -1713,7 +1713,7 @@ void SELlib_print_protected( const Type type, FILE * f ) { * TYPEselect_lib_print prints the member functions (definitions) of a select class. */ void TYPEselect_lib_print( const Type type, FILE * f ) { - char n[BUFSIZ], m[BUFSIZ]; + char n[BUFSIZ+1], m[BUFSIZ+1]; const char * z; /* pointers to class name(s) */ Linked_List dups; int dup_result; @@ -1850,7 +1850,7 @@ void TYPEselect_lib_print( const Type type, FILE * f ) { void TYPEselect_print( Type t, FILES * files, Schema schema ) { SelectTag tag, tmp; Type i, bt; /* type of elements in an aggregate */ - char nm[BUFSIZ], tdnm[BUFSIZ]; + char nm[BUFSIZ+1], tdnm[BUFSIZ+1]; FILE * inc = files->inc; /* if type is already marked, return */ diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index a425f0d88..7596f8348 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -194,7 +194,7 @@ int isAggregateType( const Type t ) { */ const char * ClassName( const char * oldname ) { int i = 0, j = 0; - static char newname [BUFSIZ]; + static char newname [BUFSIZ+1]; if( !oldname ) { return ( "" ); } @@ -221,7 +221,7 @@ const char * ENTITYget_classname( Entity ent ) { /** returns a new capitalized name, in internal static buffer */ const char * PrettyTmpName( const char * oldname ) { int i = 0; - static char newname [BUFSIZ]; + static char newname [BUFSIZ+1]; newname [0] = '\0'; while( ( oldname [i] != '\0' ) && ( i < BUFSIZ ) ) { newname [i] = ToLower( oldname [i] ); @@ -332,7 +332,7 @@ const char * FundamentalType( const Type t, int report_reftypes ) { * the dictionary. */ const char * TypeDescriptorName( Type t ) { - static char b [BUFSIZ]; + static char b [BUFSIZ+1]; Schema parent = t->superscope; /* NOTE - I corrected a prev bug here in which the *current* schema was ** passed to this function. Now we take "parent" - the schema in which diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 136ff8025..091ba79c0 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -556,7 +556,7 @@ int cmp_python_mro( void * e1, void * e2 ) { void LIBdescribe_entity( Entity entity, FILE * file ) { int attr_count_tmp = attr_count; - char attrnm [BUFSIZ], parent_attrnm[BUFSIZ]; + char attrnm [BUFSIZ+1], parent_attrnm[BUFSIZ+1]; char * attr_type; bool generate_constructor = true; /*by default, generates a python constructor */ bool single_inheritance = false; @@ -1970,10 +1970,10 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { - char tdnm [BUFSIZ], + char tdnm [BUFSIZ+1], typename_buf [MAX_LEN], - base [BUFSIZ], - nm [BUFSIZ]; + base [BUFSIZ+1], + nm [BUFSIZ+1]; Type i; int where_rule_number = 0; diff --git a/src/exp2python/src/complexSupport.h b/src/exp2python/src/complexSupport.h index 7cd781a37..7a478bbb8 100644 --- a/src/exp2python/src/complexSupport.h +++ b/src/exp2python/src/complexSupport.h @@ -116,7 +116,7 @@ class EntNode { private: MarkType mark; - char name[BUFSIZ]; + char name[BUFSIZ+1]; int multSupers; // do I correspond to an entity with >1 supertype? }; @@ -225,7 +225,7 @@ class SimpleList : public EntList { void write( ostream & ); private: - char name[BUFSIZ]; // Name of entity we correspond to. + char name[BUFSIZ+1]; // Name of entity we correspond to. MarkType I_marked; // Did I mark, and with what type of mark. }; diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index ece7e6617..bbc8a6611 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -623,7 +623,7 @@ static void addUseRefNames( Schema schema, FILE * create ) Dictionary useRefDict; DictionaryEntry de; Rename * rnm; - char * oldnm, schNm[BUFSIZ]; + char * oldnm, schNm[BUFSIZ+1]; static int firsttime = TRUE; if( ( useRefDict = schema->u.schema->usedict ) != NULL ) { diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index b44abab95..c3cfea97a 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -146,7 +146,7 @@ compareOrigTypes( Type a, Type b ) { *******************/ const char * utype_member( const Linked_List list, const Type check, int rename ) { - static char r [BUFSIZ]; + static char r [BUFSIZ+1]; LISTdo( list, t, Type ) strncpy( r, TYPEget_utype( t ), BUFSIZ ); @@ -246,7 +246,7 @@ determines if the given "link's" C++ representation is used again in the list. *******************/ int duplicate_utype_member( const Linked_List list, const Type check ) { - char b [BUFSIZ]; + char b [BUFSIZ+1]; if( TYPEis_entity( check ) ) { return FALSE; @@ -414,7 +414,7 @@ non_unique_types_string( const Type type ) { non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = ( char * )malloc( BUFSIZ ); + typestr = ( char * )malloc( BUFSIZ+1 ); typestr[0] = '\0'; strcat( typestr, ( char * )"(" ); for( i = 0; i <= tnumber; i++ ) { @@ -475,8 +475,8 @@ non_unique_types_string( const Type type ) { Variable ATTR_LISTmember( Linked_List l, Variable check ) { - char nm [BUFSIZ]; - char cur [BUFSIZ]; + char nm [BUFSIZ+1]; + char cur [BUFSIZ+1]; generate_attribute_name( check, nm ); LISTdo( l, a, Variable ) diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index e40ffaee9..70ba63d7f 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -435,7 +435,7 @@ int prep_string() { } string_func_in_use = true; - exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ ); + exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ + 1 ); if( !exppp_buf ) { fprintf( stderr, "failed to allocate exppp buffer\n" ); return 1; From 6c9a2582c647c9ce77ca029318822468d3a06f66 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:05:02 -0500 Subject: [PATCH 187/244] Use calloc to initialize the names array. --- src/exppp/pretty_type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index d18402ddc..b5fda9301 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -151,7 +151,7 @@ void TYPE_body_out( Type t, int level ) { while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { count++; } - names = ( char ** )sc_malloc( count * sizeof( char * ) ); + names = ( char ** )sc_calloc( count, sizeof( char * ) ); DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { names[expr->u.integer - 1] = expr->symbol.name; From 61d34a352cc86569c83472d85dbb8dc449579a94 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:11:26 -0500 Subject: [PATCH 188/244] Add some default initializers in the generated C++ code. --- src/exp2cxx/classes_attribute.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index b97e2f95d..95dd8e861 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -130,11 +130,24 @@ void DataMemberPrintAttr( Entity entity, Variable a, FILE * file ) { fprintf( stderr, "Warning: in entity %s, the type for attribute %s is not fully implemented\n", ENTITYget_name( entity ), attrnm ); } if( TYPEis_entity( VARget_type( a ) ) ) { - fprintf( file, " SDAI_Application_instance_ptr _%s;", attrnm ); + fprintf( file, " SDAI_Application_instance_ptr _%s = NULL;", attrnm ); } else if( TYPEis_aggregate( VARget_type( a ) ) ) { - fprintf( file, " %s_ptr _%s;", ctype, attrnm ); + fprintf( file, " %s_ptr _%s = NULL;", ctype, attrnm ); } else { - fprintf( file, " %s _%s;", ctype, attrnm ); + Class_Of_Type class = TYPEget_type(VARget_type(a)); + switch (class) { + case boolean_: + fprintf(file, " %s _%s = false;", ctype, attrnm); + break; + case integer_: + fprintf(file, " %s _%s = 0;", ctype, attrnm); + break; + case real_: + fprintf(file, " %s _%s = 0.0;", ctype, attrnm); + break; + default: + fprintf(file, " %s _%s;", ctype, attrnm); + } } if( VARget_optional( a ) ) { fprintf( file, " // OPTIONAL" ); From 8ed3d2fe33d59e05d9df9292ab94a459ed73dda9 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:14:50 -0500 Subject: [PATCH 189/244] Fix output for SC_TRACE_FPRINTF option (used for debugging - reports where generated code in exp2cxx output comes from.) --- src/exp2cxx/classes_entity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 00035380f..82e8b797a 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -599,8 +599,8 @@ void LIBstructor_print_w_args( Entity entity, Linked_List neededAttr, FILE * fil fprintf( file, " /* Put attribute on this class' attributes list so the access functions still work. */\n" ); fprintf( file, " attributes.push( a );\n" ); - fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. **\n" ); - fprintf( file, " ** The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); + fprintf( file, " /* Put attribute on the attributes list for the main inheritance hierarchy. */\n" ); + fprintf( file, " /* The push method rejects duplicates found by comparing attrDescriptor's. */\n" ); fprintf( file, " if( addAttrs ) {\n" ); fprintf( file, " se->attributes.push( a );\n }\n" ); From d36c0dde5b85ff4b4bee886880e25a63f514d03e Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:17:37 -0500 Subject: [PATCH 190/244] Add initializers for TYPEis entities --- src/exp2cxx/selects.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 1c82796a6..6377c8e80 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -741,7 +741,11 @@ void TYPEselect_lib_print_part_one( const Type type, FILE * f, if( ( TYPEis_entity( t ) ) || ( !utype_member( dups, t, 1 ) ) ) { if( isAggregateType( t ) && ( t->u.type->body->base ) ) { fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) ); - } + } else if (TYPEis_entity(t)) { + // Per TYPEget_utype, any TYPEis_entity is an + // SDAI_Application_instance_ptr - initialize it here. + fprintf(f, " _%s = NULL;\n", SEL_ITEMget_dmname(t)); + } } } LISTod fprintf( f, " nullify();\n" ); From 65e0f704fd2dd36141e33697fc0153bfc35ad489 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:14:11 -0400 Subject: [PATCH 191/244] Using newer standards, remove sc_stdbool.h --- include/CMakeLists.txt | 1 - include/exppp/exppp.h | 2 +- include/express/basic.h | 2 +- include/sc_stdbool.h | 43 ----------------------------- src/exp2cxx/classes_entity.c | 2 +- src/exp2python/src/selects_python.c | 2 +- src/exppp/pp.h | 2 +- src/exppp/pretty_expr.c | 2 +- 8 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 include/sc_stdbool.h diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index da3ae5eb5..8e7e71026 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -32,7 +32,6 @@ install(FILES ${exppp_HDRS} install(FILES ordered_attrs.h sc_export.h - sc_stdbool.h DESTINATION ${INCLUDE_DIR}/stepcode) install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h diff --git a/include/exppp/exppp.h b/include/exppp/exppp.h index f6159cbf5..e519aa70b 100644 --- a/include/exppp/exppp.h +++ b/include/exppp/exppp.h @@ -1,7 +1,7 @@ #ifndef EXPPP_H #define EXPPP_H -#include +#include #include diff --git a/include/express/basic.h b/include/express/basic.h index 2dffecf3c..21a525d07 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -82,7 +82,7 @@ #ifdef HAVE_STDBOOL_H # include #else -# include +# include #endif #if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__cplusplus) diff --git a/include/sc_stdbool.h b/include/sc_stdbool.h deleted file mode 100644 index 0591fa536..000000000 --- a/include/sc_stdbool.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef STDBOOL_H_ -#define STDBOOL_H_ - -/** - * stdbool.h - ISO C99 Boolean type - * Author - Bill Chatfield - * E-mail - bill underscore chatfield at yahoo dot com - * Copyright - You are free to use for any purpose except illegal acts - * Warrenty - None: don't blame me if it breaks something - * - * In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but - * some compilers don't offer these yet. This header file is an - * implementation of the standard ISO C99 stdbool.h header file. It checks - * for various compiler versions and defines things that are missing in - * those versions. - * - * See http://predef.sourceforge.net/precomp.html for compile macros. - */ - -#ifndef __cplusplus - -/** - * Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005, - * and version 15.00.30729.01, which comes with Visual C++ 2008, do not - * define _Bool. - */ -#if defined(_MSC_VER) && _MSC_VER<1800 -typedef int _Bool; -#endif - -/** - * Define the Boolean macros only if they are not already defined. - */ -#ifndef __bool_true_false_are_defined -#define bool _Bool -#define false 0 -#define true 1 -#define __bool_true_false_are_defined 1 -#endif - -#endif /* __cplusplus */ - -#endif /*STDBOOL_H_*/ diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 82e8b797a..6c63c44be 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -16,7 +16,7 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #include #include -#include +#include #include #include #include "classes.h" diff --git a/src/exp2python/src/selects_python.c b/src/exp2python/src/selects_python.c index c3cfea97a..2bc45d151 100644 --- a/src/exp2python/src/selects_python.c +++ b/src/exp2python/src/selects_python.c @@ -23,7 +23,7 @@ extern int multiple_inheritance; **************************************************************************/ #include #include "classes.h" -#include +#include bool is_python_keyword( char * word ); int isAggregateType( const Type t ); diff --git a/src/exppp/pp.h b/src/exppp/pp.h index 89825de6a..a441fece9 100644 --- a/src/exppp/pp.h +++ b/src/exppp/pp.h @@ -4,7 +4,7 @@ #ifndef PP_H #define PP_H -#include +#include #include extern int indent2; /**< where continuation lines start */ diff --git a/src/exppp/pretty_expr.c b/src/exppp/pretty_expr.c index 60a1c2ded..1b9aeda7b 100644 --- a/src/exppp/pretty_expr.c +++ b/src/exppp/pretty_expr.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include "exppp.h" From 97c3d193a1421d6ee561c06f83323704cf4000cf Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:27:47 -0400 Subject: [PATCH 192/244] sc_cf.h -> config.h Remove unused sc_cf_cmake.h.in, rename sc_cf.h to the more standard name "config.h", don't call the generator twice --- CMakeLists.txt | 6 +---- cmake/SC_Config_Headers.cmake | 8 +++--- include/CMakeLists.txt | 2 +- include/{sc_cf.h.in => config.h.in} | 0 include/express/basic.h | 2 +- include/sc_cf_cmake.h.in | 30 ----------------------- src/base/sc_memmgr.cc | 2 +- src/cllazyfile/lazyTypes.h | 2 +- src/cllazyfile/lazy_test.cc | 2 +- src/clstepcore/sdai.h | 2 +- src/clutils/dirobj.cc | 2 +- src/clutils/dirobj.h | 2 +- src/clutils/gennodearray.cc | 2 +- src/express/error.c | 2 +- src/express/fedex.c | 2 +- src/express/test/print_attrs.c | 2 +- src/express/test/print_schemas.c | 2 +- test/cpp/schema_specific/attribute.cc | 2 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- test/cpp/schema_specific/inverse_attr2.cc | 2 +- test/cpp/schema_specific/inverse_attr3.cc | 2 +- 21 files changed, 22 insertions(+), 56 deletions(-) rename include/{sc_cf.h.in => config.h.in} (100%) delete mode 100644 include/sc_cf_cmake.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d27a53e05..5d3f0b180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ include(SC_Locale) # logic related to regenerating the lexer and parser source code include(SC_Regenerate) -# create config header sc_cf.h +# create config.h header include(SC_Config_Headers) if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS) @@ -174,10 +174,6 @@ if(NOT SC_IS_SUBBUILD) ".. Generating step can take a while if you are building several schemas.") endif(NOT SC_IS_SUBBUILD) -# create config headers sc_cf.h -include(SC_Config_Headers) - - ################ if(MSVC) diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index f9a8cc86b..68f1c37ad 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -1,4 +1,4 @@ -# create sc_cf.h +# create config.h include(CheckLibraryExists) include(CheckIncludeFile) @@ -77,9 +77,9 @@ int main() {return !(f() == f());} cmake_pop_check_state() endif(SC_ENABLE_CXX11) -# Now that all the tests are done, configure the sc_cf.h file: -configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h) +# Now that all the tests are done, configure the config.h file: +configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h.gen) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h) # Local Variables: # tab-width: 8 diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 8e7e71026..9ad25faeb 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -34,7 +34,7 @@ install(FILES ordered_attrs.h sc_export.h DESTINATION ${INCLUDE_DIR}/stepcode) -install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h +install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h DESTINATION ${INCLUDE_DIR}/stepcode) # Local Variables: diff --git a/include/sc_cf.h.in b/include/config.h.in similarity index 100% rename from include/sc_cf.h.in rename to include/config.h.in diff --git a/include/express/basic.h b/include/express/basic.h index 21a525d07..3318ffc19 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -71,7 +71,7 @@ * */ -#include +#include "config.h" #include #include diff --git a/include/sc_cf_cmake.h.in b/include/sc_cf_cmake.h.in deleted file mode 100644 index 873be14bf..000000000 --- a/include/sc_cf_cmake.h.in +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef SCL_CF_H -#define SCL_CF_H - -/**** Define statements for CMake ****/ -#cmakedefine HAVE_NDIR_H 1 -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_SYS_STAT_H 1 -#cmakedefine HAVE_SYS_PARAM_H 1 -#cmakedefine HAVE_SYSENT_H 1 -#cmakedefine HAVE_UNISTD_H 1 -#cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_STDBOOL_H 1 -#cmakedefine HAVE_PROCESS_H 1 -#cmakedefine HAVE_IO_H 1 - -#cmakedefine SC_TRACE_FPRINTF 1 -#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 - -#cmakedefine HAVE_ABS 1 -#cmakedefine HAVE_MEMCPY 1 -#cmakedefine HAVE_MEMMOVE 1 -#cmakedefine HAVE_GETOPT 1 -#cmakedefine HAVE_VSNPRINTF 1 - -#cmakedefine HAVE_SSIZE_T 1 - -#cmakedefine HAVE_STD_THREAD 1 -#cmakedefine HAVE_STD_CHRONO 1 - -#endif /* SCL_CF_H */ diff --git a/src/base/sc_memmgr.cc b/src/base/sc_memmgr.cc index 262d26e28..61d89a5ed 100644 --- a/src/base/sc_memmgr.cc +++ b/src/base/sc_memmgr.cc @@ -1,7 +1,7 @@ #define SC_MEMMGR_CC -#include +#include "config.h" #include "sc_memmgr.h" #include diff --git a/src/cllazyfile/lazyTypes.h b/src/cllazyfile/lazyTypes.h index 0ba2aa671..f1fdbd782 100644 --- a/src/cllazyfile/lazyTypes.h +++ b/src/cllazyfile/lazyTypes.h @@ -1,7 +1,7 @@ #ifndef LAZYTYPES_H #define LAZYTYPES_H -#include "sc_cf.h" +#include "config.h" #include #include diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 71786bb59..c41003e9b 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -2,7 +2,7 @@ #include #include "SdaiSchemaInit.h" #include "sc_memmgr.h" -#include +#include "config.h" #ifndef NO_REGISTRY # include "schema.h" diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index 5751996a0..46ae3996b 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -18,7 +18,7 @@ * values for the EXPRESS base types. */ -#include "sc_cf.h" +#include "config.h" #include extern const char * SCLversion; diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 337774342..76e3b2a26 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -39,7 +39,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "config.h" #include #ifdef HAVE_DIRENT_H # include diff --git a/src/clutils/dirobj.h b/src/clutils/dirobj.h index 7f3806d99..fe847a1e5 100644 --- a/src/clutils/dirobj.h +++ b/src/clutils/dirobj.h @@ -33,7 +33,7 @@ // /////////////////////////////////////////////////////////////////////////////// -#include +#include "config.h" #include #include diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index f78acbd14..0111794fb 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -11,7 +11,7 @@ */ -#include +#include "config.h" #include #include diff --git a/src/express/error.c b/src/express/error.c index 04bcc4154..c151a2d87 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -24,7 +24,7 @@ * Revision 1.11 1997/10/22 16:10:26 sauderd * This would #include stdarg.h if __STDC__ was defined otherwise it would * #include vararg.h. I changed it to check the configure generated config file - * named sc_cf.h (if HAVE_CONFIG_H is defined - it's also defined by + * named config.h (if HAVE_CONFIG_H is defined - it's also defined by * configure) to see if HAVE_STDARG_H is defined. If it is it #includes stdarg.h * otherwise it #includes vararg.h. If HAVE_CONFIG_H isn't defined then it works * like it used to. diff --git a/src/express/fedex.c b/src/express/fedex.c index c32989616..7ccae40d4 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -74,7 +74,7 @@ #include #include -#include "sc_cf.h" +#include "config.h" #include "sc_memmgr.h" #include "sc_export.h" #include "sc_getopt.h" diff --git a/src/express/test/print_attrs.c b/src/express/test/print_attrs.c index 881ada059..6729a70ce 100644 --- a/src/express/test/print_attrs.c +++ b/src/express/test/print_attrs.c @@ -6,7 +6,7 @@ * print_attrs -a */ -#include "sc_cf.h" +#include "config.h" #include #ifdef HAVE_SYS_PARAM_H # include diff --git a/src/express/test/print_schemas.c b/src/express/test/print_schemas.c index 40bb0a1e0..b0cba2f71 100644 --- a/src/express/test/print_schemas.c +++ b/src/express/test/print_schemas.c @@ -2,7 +2,7 @@ /* prints names of schemas used in an EXPRESS file */ /* symlink.c author: Don Libes, NIST, 20-Mar-1993 */ -#include "sc_cf.h" +#include "config.h" #include #ifdef HAVE_SYS_PARAM_H # include diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index a74cee078..dc819f029 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -2,7 +2,7 @@ * 1-Jul-2012 * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ -#include +#include "config.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index c06177b1c..27a383ab6 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -3,7 +3,7 @@ ** Test inverse attributes; uses a tiny schema similar to a subset of IFC2x3 ** */ -#include +#include "config.h" #include "SubSuperIterators.h" #include #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 2f3fdf233..00cd7da0c 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -3,7 +3,7 @@ ** Test inverse attributes; uses a tiny schema similar to a subset of IFC2x3 ** */ -#include +#include "config.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 866801dbf..2a55efc66 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -4,7 +4,7 @@ * * This test originally used STEPfile, which didn't work. Fixing STEPfile would have been very difficult, it uses lazyInstMgr now. */ -#include +#include "config.h" #include #include #include From 4446d020635e82b294fd0b80115061c4c75bf525 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:56:21 -0400 Subject: [PATCH 193/244] Adjust name of example header as well --- example/ap203min/include/{sc_cf.h.in => config.h.in} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename example/ap203min/include/{sc_cf.h.in => config.h.in} (100%) diff --git a/example/ap203min/include/sc_cf.h.in b/example/ap203min/include/config.h.in similarity index 100% rename from example/ap203min/include/sc_cf.h.in rename to example/ap203min/include/config.h.in From c7bd9fa9956e1c70bfe785f29fcab18938ba57c2 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:15:15 -0500 Subject: [PATCH 194/244] Use array deletes, clean up temporary objects. --- src/cldai/sdaiEntity_extent_set.cc | 4 ++-- src/cleditor/STEPfile.cc | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index af3658222..e472de06f 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -51,7 +51,7 @@ SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) { } SDAI_Entity_extent__set::~SDAI_Entity_extent__set() { - delete _buf; + delete[] _buf; } void SDAI_Entity_extent__set::Check( int index ) { @@ -62,7 +62,7 @@ void SDAI_Entity_extent__set::Check( int index ) { _bufsize = ( index + 1 ) * 2; newbuf = new SDAI_Entity_extent_ptr[_bufsize]; memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) ); - delete _buf; + delete[] _buf; _buf = newbuf; } } diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 2d0da93bf..b8936d761 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -851,6 +851,8 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou << " User Defined Entity in DATA section ignored.\n" << "\tData lost: \'!" << objnm << "\': " << tmpbuf << endl; + if (scopelist) + delete[] scopelist; return ENTITY_NULL; } else { schnm = schemaName(); @@ -879,6 +881,8 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou out << "ERROR: instance #" << fileid << " \'" << objnm << "\': " << result.UserMsg() << ".\n\tData lost: " << tmpbuf << "\n\n"; + if (scopelist) + delete[] scopelist; return ENTITY_NULL; } obj -> STEPfile_id = fileid; @@ -887,6 +891,10 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou SkipInstance( in, tmpbuf ); ReadTokenSeparator( in ); + + if (scopelist) + delete[] scopelist; + return obj; } @@ -1531,9 +1539,11 @@ void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & o void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { // Get the FileName instance from _headerInstances SDAI_Application_instance * se = 0; + bool del_se = false; se = _headerInstances->GetApplication_instance( "File_Name" ); if( se == ENTITY_NULL ) { se = ( SDAI_Application_instance * )HeaderDefaultFileName(); + del_se = true; } //set some of the attribute values at time of output @@ -1553,6 +1563,9 @@ void STEPfile::WriteHeaderInstanceFileName( ostream & out ) { //output the values to the file WriteHeaderInstance( se, out ); + + if (del_se) + delete se; } void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) { @@ -1563,8 +1576,11 @@ void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance se = ( SDAI_Application_instance * )HeaderDefaultFileDescription(); + WriteHeaderInstance(se, out); + delete se; + } else { + WriteHeaderInstance( se, out ); } - WriteHeaderInstance( se, out ); } void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) { @@ -1575,8 +1591,11 @@ void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) { // ERROR: no File_Name instance in _headerInstances // create a File_Name instance se = ( SDAI_Application_instance * ) HeaderDefaultFileSchema(); + WriteHeaderInstance( se, out ); + delete se; + } else { + WriteHeaderInstance( se, out ); } - WriteHeaderInstance( se, out ); } void STEPfile::WriteData( ostream & out, int writeComments ) { From 874dca8499e23531af319bb63fd80e2c8e5f6aac Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:17:12 -0500 Subject: [PATCH 195/244] Add destructor for CmdMgr --- src/cleditor/cmdmgr.cc | 10 ++++++++++ src/cleditor/cmdmgr.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index 7c015ce47..3044790de 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -72,6 +72,16 @@ CmdMgr::CmdMgr() { replicateList = new ReplicateList(); } +CmdMgr::~CmdMgr() { + delete completeList; + delete incompleteList; + delete deleteList; + delete mappedWriteList; + delete mappedViewList; + delete closeList; + delete replicateList; +} + void CmdMgr::ReplicateCmdList( MgrNode * mn ) { if( !( replicateList->IsOnList( mn ) ) ) { replicateList->AddNode( mn ); diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 7ef2f00b5..c9c45b404 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -145,6 +145,7 @@ class SC_EDITOR_EXPORT CmdMgr { public: CmdMgr(); + ~CmdMgr(); // STATE LIST OPERATIONS MgrNode * GetHead( stateEnum listType ); From 3e9fe17fcd00fe23035ea281eb55fc910a48df88 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:18:10 -0500 Subject: [PATCH 196/244] Delete _headerInstances in destructor --- src/cllazyfile/headerSectionReader.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cllazyfile/headerSectionReader.h b/src/cllazyfile/headerSectionReader.h index 8a51f5721..1e42d0440 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/src/cllazyfile/headerSectionReader.h @@ -31,6 +31,7 @@ class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader { //FIXME delete each instance?! maybe add to clear, since it iterates over everything already //enum clearHow { rawData, deletePointers } _headerInstances->clear(); + delete _headerInstances; } }; From 93c79df2dfee2d6b3be3e6a405a227078040a17f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:22:24 -0500 Subject: [PATCH 197/244] Initialize, fix variable types. --- src/cllazyfile/lazyP21DataSectionReader.cc | 1 + src/cllazyfile/p21HeaderSectionReader.cc | 1 + src/cllazyfile/sectionReader.cc | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index 9e9df2070..baecb260e 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -49,6 +49,7 @@ const namedLazyInstance lazyP21DataSectionReader::nextInstance() { namedLazyInstance i; i.refs = 0; + i.loc.section = 0; i.loc.begin = _file.tellg(); i.loc.instance = readInstanceNumber(); if( ( _file.good() ) && ( i.loc.instance > 0 ) ) { diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index bcb78ac83..a01e47c3d 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -33,6 +33,7 @@ const namedLazyInstance p21HeaderSectionReader::nextInstance() { namedLazyInstance i; static instanceID nextFreeInstance = 4; // 1-3 are reserved per 10303-21 + i.refs = 0; i.loc.begin = _file.tellg(); i.loc.section = _sectionID; skipWS(); diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 0384efd4c..9e2c45f3d 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -30,7 +30,7 @@ sectionReader::sectionReader( lazyFileReader * parent, std::ifstream & file, std std::streampos sectionReader::findNormalString( const std::string & str, bool semicolon ) { std::streampos found = -1, startPos = _file.tellg(), nextTry = startPos; int i = 0, l = str.length(); - char c; + int c; //i is reset every time a character doesn't match; if i == l, this means that we've found the entire string while( i < l || semicolon ) { @@ -84,7 +84,7 @@ std::streampos sectionReader::findNormalString( const std::string & str, bool se // returns pointer to the contents of a static std::string const char * sectionReader::getDelimitedKeyword( const char * delimiters ) { static std::string str; - char c; + int c; str.clear(); str.reserve( 100 ); skipWS(); @@ -114,7 +114,7 @@ const char * sectionReader::getDelimitedKeyword( const char * delimiters ) { /// be the opening parenthesis; otherwise, it is likely to fail. ///NOTE *must* check return value! std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) { - char c; + int c; int parenDepth = 0; while( c = _file.get(), _file.good() ) { switch( c ) { @@ -176,7 +176,7 @@ void sectionReader::locateAllInstances() { } instanceID sectionReader::readInstanceNumber() { - char c; + int c; size_t digits = 0; instanceID id = 0; @@ -251,7 +251,7 @@ instanceID sectionReader::readInstanceNumber() { */ 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; + int c; const char * tName = 0, * sName = 0; //these are necessary since typeName and schName are const std::string comment; Severity sev = SEVERITY_NULL; From ae933edba5a8105df6ed173b6d7da3422c18470d Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:24:28 -0500 Subject: [PATCH 198/244] Add destructor, use array delete --- src/cllazyfile/sectionReader.cc | 5 ++++- src/cllazyfile/sectionReader.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 9e2c45f3d..fe3bd4b2a 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -26,6 +26,9 @@ sectionReader::sectionReader( lazyFileReader * parent, std::ifstream & file, std _error = new ErrorDescriptor(); } +sectionReader::~sectionReader() { + delete _error; +} std::streampos sectionReader::findNormalString( const std::string & str, bool semicolon ) { std::streampos found = -1, startPos = _file.tellg(), nextTry = startPos; @@ -221,7 +224,7 @@ instanceID sectionReader::readInstanceNumber() { _error->UserMsg( "A very large instance ID encountered" ); _error->DetailMsg( errorMsg.str() ); - delete buffer; + delete[] buffer; return 0; } diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index c6a64b55a..88c5e1ceb 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -38,6 +38,7 @@ class SC_LAZYFILE_EXPORT sectionReader { // protected member functions sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ); + ~sectionReader(); /** Find a string, ignoring occurrences in comments or Part 21 strings (i.e. 'string with \S\' control directive' ) * \param str string to find From a6bea3572ec909c70800032f98bd8ac49b99dbc8 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:25:52 -0500 Subject: [PATCH 199/244] Delete temporary element after use --- src/clstepcore/Registry.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index a97c37e82..b9b9f6103 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -235,13 +235,13 @@ void Registry::RemoveType( const char * n ) { */ void Registry::RemoveClones( const EntityDescriptor & e ) { const SchRename * alts = e.AltNameList(); - struct Element * tmp; while( alts ) { - tmp = new Element; + struct Element * tmp = new Element; tmp->key = ( char * ) alts->objName(); SC_HASHsearch( primordialSwamp, tmp, HASH_DELETE ); alts = alts->next; + delete tmp; } } From ca1d62719a407f6e6e37f54cbf0418e32ebaaf21 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:28:37 -0500 Subject: [PATCH 200/244] If we need to allocate an EntityNode, clean it up. --- src/clstepcore/STEPaggrEntity.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index 057c491fd..c0fddfbbb 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -24,6 +24,7 @@ Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, char errmsg[BUFSIZ+1]; int value_cnt = 0; std::string buf; + bool free_item = false; if( assignVal ) { Empty(); // read new values and discard existing ones @@ -67,6 +68,7 @@ Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, // It is used to read the values else if( !assignVal ) { item = new EntityNode(); + free_item = true; } while( in.good() && ( c != ')' ) ) { @@ -114,8 +116,12 @@ Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err, } else { // expectation for end paren delim has not been met err->GreaterSeverity( SEVERITY_INPUT_ERROR ); err->AppendToUserMsg( "Missing close paren for aggregate value" ); + if (free_item) + delete item; return SEVERITY_INPUT_ERROR; } + if (free_item) + delete item; return err->severity(); } From 1d46986e80d3bbaa401cbe5d44141131a502c988 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:34:12 -0500 Subject: [PATCH 201/244] Passing back the internal pointer to a std::string is evidently a Bad Idea - just send back a std::string. --- src/clstepcore/STEPattribute.cc | 14 +++++++------- src/clstepcore/STEPattribute.h | 2 +- src/clstepcore/sdaiApplication_instance.cc | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index a378ae2b7..dcfeb2486 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -1268,15 +1268,15 @@ void STEPattribute::AddErrorInfo() { if( SEVERITY_INPUT_ERROR < _error.severity() && _error.severity() < SEVERITY_NULL ) { sprintf( errStr, " Warning: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); + Name(), TypeName().c_str(), Type() ); _error.PrependToDetailMsg( errStr ); } else if( _error.severity() == SEVERITY_INPUT_ERROR ) { sprintf( errStr, " Error: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); + Name(), TypeName().c_str(), Type() ); _error.PrependToDetailMsg( errStr ); } else if( _error.severity() <= SEVERITY_BUG ) { sprintf( errStr, " BUG: ATTRIBUTE '%s : %s : %d' - ", - Name(), TypeName(), Type() ); + Name(), TypeName().c_str(), Type() ); _error.PrependToDetailMsg( errStr ); } } @@ -1304,12 +1304,12 @@ char STEPattribute::SkipBadAttr( istream & in, char * StopChars ) { if( in.eof() ) { _error.GreaterSeverity( SEVERITY_INPUT_ERROR ); sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), + Name(), TypeName().c_str(), Type(), "Unexpected EOF when skipping bad attr value" ); _error.AppendToDetailMsg( errStr ); } else { sprintf( errStr, " Error: attribute '%s : %s : %d' - %s.\n", - Name(), TypeName(), Type(), "Invalid value" ); + Name(), TypeName().c_str(), Type(), "Invalid value" ); _error.AppendToDetailMsg( errStr ); } in.putback( c ); @@ -1465,11 +1465,11 @@ const char * STEPattribute::Name() const { return aDesc->Name(); } -const char * STEPattribute::TypeName() const { +std::string STEPattribute::TypeName() const { if( _redefAttr ) { return _redefAttr->TypeName(); } - return aDesc->TypeName().c_str(); + return aDesc->TypeName(); } BASE_TYPE STEPattribute::Type() const { diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 08d8a62e5..47b99e025 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -208,7 +208,7 @@ class SC_CORE_EXPORT STEPattribute { } const char * Name() const; - const char * TypeName() const; + std::string TypeName() const; BASE_TYPE Type() const; BASE_TYPE NonRefType() const; BASE_TYPE BaseType() const; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 3d34f8efa..de5d19b76 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -472,7 +472,7 @@ void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, con if( ( i >= 0 ) && ( i < attributes.list_length() ) ) { // i is an attribute Error().GreaterSeverity( SEVERITY_WARNING ); sprintf( errStr, " invalid data before type \'%s\'\n", - attributes[i].TypeName() ); + attributes[i].TypeName().c_str() ); _error.AppendToDetailMsg( errStr ); } else { Error().GreaterSeverity( SEVERITY_INPUT_ERROR ); From 3c17e71b6367db57c114d62d58056004cd30e91b Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:35:35 -0500 Subject: [PATCH 202/244] Make sure we have item, and don't continue after we delete it. --- src/clstepcore/SingleLinkList.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index b13e2061d..890e423b8 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -95,7 +95,7 @@ void SingleLinkList::AppendNode( SingleLinkNode * item ) { } void SingleLinkList::DeleteNode( SingleLinkNode * item ) { - if( head ) { + if( head && item ) { SingleLinkNode * trailer = 0; SingleLinkNode * leader = head; while( leader ) { @@ -111,6 +111,7 @@ void SingleLinkList::DeleteNode( SingleLinkNode * item ) { tail = trailer; } delete item; + return; } else { if( trailer ) { trailer = trailer->NextNode(); From 830e29fb803da502681e607416b9e4f2b1b787d4 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:36:37 -0500 Subject: [PATCH 203/244] Add more initializers --- src/clstepcore/aggrTypeDescriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clstepcore/aggrTypeDescriptor.h b/src/clstepcore/aggrTypeDescriptor.h index 850a6b2e7..44282bb6c 100644 --- a/src/clstepcore/aggrTypeDescriptor.h +++ b/src/clstepcore/aggrTypeDescriptor.h @@ -57,7 +57,7 @@ class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor { AggrTypeDescriptor( const char * nm, PrimitiveType ft, Schema * origSchema, const char * d, AggregateCreator f = 0 ) - : TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ) { } + : TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ), _bound1_type( bound_unset ), _bound2_type( bound_unset ), _bound1_callback( NULL ), _bound2_callback( NULL ) { } virtual ~AggrTypeDescriptor(); From 09deafbe23125bd029a15d2f72eabbd1451ffb39 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:38:44 -0500 Subject: [PATCH 204/244] Use strncpy to initialize schName and newName --- src/clstepcore/schRename.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clstepcore/schRename.h b/src/clstepcore/schRename.h index 154cce0a3..b5ffdbaa1 100644 --- a/src/clstepcore/schRename.h +++ b/src/clstepcore/schRename.h @@ -22,8 +22,10 @@ class SC_CORE_EXPORT SchRename { public: SchRename( const char * sch = "\0", const char * newnm = "\0" ) : next( 0 ) { - strcpy( schName, sch ); - strcpy( newName, newnm ); + strncpy( schName, sch, BUFSIZ ); + schName[BUFSIZ] = '\0'; + strncpy( newName, newnm, BUFSIZ ); + newName[BUFSIZ] = '\0'; } ~SchRename() { delete next; From 88e512c92c0acb59cd19cdd28bd05f336d87c964 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:42:49 -0500 Subject: [PATCH 205/244] Use strncpy to copy path to buf --- src/clutils/dirobj.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 76e3b2a26..397d5f477 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -257,10 +257,11 @@ std::string DirObj::Normalize( const std::string & path ) { const char * DirObj::ValidDirectories( const char * path ) { #ifdef _WIN32 static char buf[MAX_PATH + 1]; + strncpy(buf, path, MAX_PATH); #else static char buf[MAXPATHLEN + 1]; + strncpy(buf, path, MAXPATHLEN); #endif - strcpy( buf, path ); int i = strlen( path ); while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) { From 7209a3e75d25c0603005b8366d4e740b3a5eb268 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:44:07 -0500 Subject: [PATCH 206/244] Use free on fileList[index] --- src/clutils/dirobj.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 397d5f477..657a9ab5c 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -327,8 +327,8 @@ void DirObj::InsertFile( const char * f, int index ) { void DirObj::RemoveFile( int index ) { if( index < --fileCount ) { + free(fileList[index]); const char ** spot = ( const char ** )&fileList[index]; - delete spot; memmove( spot, spot + 1, ( fileCount - index )*sizeof( char * ) ); } } From 43231cdbc942daa39d9fd28a019955cb3c9a521f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:45:48 -0500 Subject: [PATCH 207/244] Set default types, note a bad problem with how sc_hash is set up. --- src/clutils/sc_hash.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index ddbe06a0b..1839b6707 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -50,6 +50,7 @@ void * SC_HASHfind( Hash_TableP t, char * s ) { e.key = s; e.symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ + e.type = '*'; ep = SC_HASHsearch( t, &e, HASH_FIND ); return( ep ? ep->data : 0 ); } @@ -61,6 +62,7 @@ void SC_HASHinsert( Hash_TableP t, char * s, void * data ) { e.key = s; e.data = data; e.symbol = 0; + e.type = '*'; e2 = SC_HASHsearch( t, &e, HASH_INSERT ); if( e2 ) { fprintf( stderr, "%s: Redeclaration of %s\n", __func__, s ); @@ -258,6 +260,9 @@ struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item, /*STRINGfree(deleteme->key);*/ SC_HASH_Element_destroy( deleteme ); --table->KeyCount; + // TODO - we shouldn't be returning this pointer - it invites a + // USE_AFTER_FREE error. Could we just replace SC_HASH completely + // with one of the C++ containers? return( deleteme ); /* of course, user shouldn't deref this! */ case HASH_INSERT: /* if trying to insert it (twice), let them know */ From 28c5d2642930c9781abe6b024364c10c04912426 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:50:03 -0500 Subject: [PATCH 208/244] As with BUFSIZ, make sure MAX_LEN buffers have room to null terminate. --- src/exp2cxx/class_strings.c | 8 ++++---- src/exp2cxx/classes_entity.c | 2 +- src/exp2cxx/classes_misc.c | 4 ++-- src/exp2cxx/classes_type.c | 4 ++-- src/exp2cxx/classes_wrapper.cc | 4 ++-- src/exp2python/src/classes_misc_python.c | 12 ++++++------ src/exp2python/src/classes_python.c | 2 +- src/exp2python/src/classes_wrapper_python.cc | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/exp2cxx/class_strings.c b/src/exp2cxx/class_strings.c index 8bae77746..7058e4719 100644 --- a/src/exp2cxx/class_strings.c +++ b/src/exp2cxx/class_strings.c @@ -185,7 +185,7 @@ char ToUpper( char c ) { } const char * StrToLower( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; int i = 0; if( !word ) { return 0; @@ -200,7 +200,7 @@ const char * StrToLower( const char * word ) { } const char * StrToUpper( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; int i = 0; while( word [i] != '\0' ) { @@ -212,7 +212,7 @@ const char * StrToUpper( const char * word ) { } const char * StrToConstant( const char * word ) { - static char newword[MAX_LEN]; + static char newword[MAX_LEN+1]; int i = 0; while( word [i] != '\0' ) { @@ -229,7 +229,7 @@ const char * StrToConstant( const char * word ) { } const char * FirstToUpper( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; strncpy( newword, word, MAX_LEN ); newword[0] = ToUpper( newword[0] ); diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 6c63c44be..0bd8feaf4 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -827,7 +827,7 @@ void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schem ); } else { /* manufacture new one(s) on the spot */ - char typename_buf[MAX_LEN]; + char typename_buf[MAX_LEN+1]; print_typechain( header, impl, v->type, typename_buf, schema, v->name->symbol.name ); fprintf( impl, " %s::%s%d%s%s =\n new %s" "(\"%s\",%s,%s,%s%s,\n *%s::%s%s);\n", diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 8fde1a808..8399826c5 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -123,7 +123,7 @@ const char * PrettyTmpName( const char * oldname ) { /* This function is out of date DAS */ const char * EnumName( const char * oldname ) { int j = 0; - static char newname [MAX_LEN]; + static char newname [MAX_LEN+1]; if( !oldname ) { return ( "" ); } @@ -139,7 +139,7 @@ const char * EnumName( const char * oldname ) { const char * SelectName( const char * oldname ) { int j = 0; - static char newname [MAX_LEN]; + static char newname [MAX_LEN+1]; if( !oldname ) { return ( "" ); } diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index e6a6967e0..7c01c49f7 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -832,7 +832,7 @@ void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Sche const char * ctype = TYPEget_ctype( t ); int count = type_count++; - char name_buf[MAX_LEN]; + char name_buf[MAX_LEN+1]; int s; switch( TYPEget_body( t )->type ) { @@ -878,7 +878,7 @@ void print_typechain( FILE * header, FILE * impl, const Type t, char * buf, Sche } else { Type base = 0; /* no name, recurse */ - char callee_buffer[MAX_LEN]; + char callee_buffer[MAX_LEN+1]; if( TYPEget_body( t ) ) { base = TYPEget_body( t )->base; } diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 874491ee7..180067b1e 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -386,7 +386,7 @@ void INITFileFinish( FILE * initfile, Schema schema ) { ******************************************************************/ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) { int ocnt = 0; - char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; + char schnm[MAX_LEN+1], sufnm[MAX_LEN+1], fnm[MAX_LEN+1], *np; /* sufnm = schema name + suffix */ FILE * libfile, * incfile, @@ -628,7 +628,7 @@ void getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { ** Status: 24-Feb-1992 new -kcm ******************************************************************/ void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { - char fnm [MAX_LEN], *np; + char fnm [MAX_LEN+1], *np; const char * schnm; /* schnm is really "express name" */ FILE * libfile; FILE * incfile; diff --git a/src/exp2python/src/classes_misc_python.c b/src/exp2python/src/classes_misc_python.c index 7596f8348..5a34c5fa7 100644 --- a/src/exp2python/src/classes_misc_python.c +++ b/src/exp2python/src/classes_misc_python.c @@ -111,7 +111,7 @@ ToUpper( char c ) { const char * StrToLower( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; int i = 0; if( !word ) { return 0; @@ -126,7 +126,7 @@ StrToLower( const char * word ) { } const char * StrToUpper( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; int i = 0; char ToUpper( char c ); @@ -140,7 +140,7 @@ const char * StrToUpper( const char * word ) { } const char * StrToConstant( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; int i = 0; while( word [i] != '\0' ) { @@ -242,7 +242,7 @@ const char * PrettyTmpName( const char * oldname ) { /** This function is out of date DAS */ const char * EnumName( const char * oldname ) { int j = 0; - static char newname [MAX_LEN]; + static char newname [MAX_LEN+1]; if( !oldname ) { return ( "" ); } @@ -258,7 +258,7 @@ const char * EnumName( const char * oldname ) { const char * SelectName( const char * oldname ) { int j = 0; - static char newname [MAX_LEN]; + static char newname [MAX_LEN+1]; if( !oldname ) { return ( "" ); } @@ -274,7 +274,7 @@ const char * SelectName( const char * oldname ) { } const char * FirstToUpper( const char * word ) { - static char newword [MAX_LEN]; + static char newword [MAX_LEN+1]; strncpy( newword, word, MAX_LEN ); newword[0] = ToUpper( newword[0] ); diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index 091ba79c0..b844985e3 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -1971,7 +1971,7 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) { void TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) { char tdnm [BUFSIZ+1], - typename_buf [MAX_LEN], + typename_buf [MAX_LEN+1], base [BUFSIZ+1], nm [BUFSIZ+1]; Type i; diff --git a/src/exp2python/src/classes_wrapper_python.cc b/src/exp2python/src/classes_wrapper_python.cc index 9f2d02b62..c6842ba44 100644 --- a/src/exp2python/src/classes_wrapper_python.cc +++ b/src/exp2python/src/classes_wrapper_python.cc @@ -164,7 +164,7 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema ) { void SCHEMAprint( Schema schema, FILES * files, int suffix ) { int ocnt = 0; - char schnm[MAX_LEN], sufnm[MAX_LEN], fnm[MAX_LEN], *np; + char schnm[MAX_LEN+1], sufnm[MAX_LEN+1], fnm[MAX_LEN+1], *np; /* sufnm = schema name + suffix */ FILE * libfile; /********** create files based on name of schema ***********/ @@ -285,7 +285,7 @@ getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) { ******************************************************************/ void EXPRESSPrint( Express express, FILES * files ) { - char fnm [MAX_LEN]; + char fnm [MAX_LEN+1]; const char * schnm; /* schnm is really "express name" */ FILE * libfile; /* new */ From 64873b4dd7d3f193db3b7a33b8a5b26b4304e40f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:53:16 -0500 Subject: [PATCH 209/244] Use strncat to copy name to buf --- src/exp2cxx/classes_type.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 7c01c49f7..d3c3eb95a 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -104,8 +104,7 @@ const char * EnumCElementName( Type type, Expression expr ) { static char buf [BUFSIZ+1]; sprintf( buf, "%s__", EnumName( TYPEget_name( type ) ) ); - strcat( buf, StrToLower( EXPget_name( expr ) ) ); - + strncat( buf, StrToLower( EXPget_name( expr ) ), BUFSIZ ); return buf; } From 9b15e1c6971024e1229c2b86e71b87f8f8edbac7 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:01:52 -0500 Subject: [PATCH 210/244] Make a variety of adjustments to string printing, free temporary copy of EXPRto_String output. --- src/exp2cxx/classes_type.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index d3c3eb95a..5ac968207 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -1026,9 +1026,9 @@ void TypeBody_Description( TypeBody body, char * buf ) { const char * IdlEntityTypeName( Type t ) { static char name [BUFSIZ+1]; - strcpy( name, TYPE_PREFIX ); + strncpy( name, TYPE_PREFIX, BUFSIZ ); if( TYPEget_name( t ) ) { - strcpy( name, FirstToUpper( TYPEget_name( t ) ) ); + strncpy( name, FirstToUpper( TYPEget_name( t ) ), BUFSIZ ); } else { return TYPEget_ctype( t ); } @@ -1061,14 +1061,14 @@ const char * GetAggrElemType( const Type type ) { /* case TYPE_ENTITY: */ if( class == entity_ ) { - strcpy( retval, IdlEntityTypeName( bt ) ); + strncpy( retval, IdlEntityTypeName( bt ), BUFSIZ ); } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ if( ( class == enumeration_ ) || ( class == select_ ) ) { - strcpy( retval, TYPEget_ctype( bt ) ); + strncpy( retval, TYPEget_ctype( bt ), BUFSIZ ); } /* case TYPE_LOGICAL: */ @@ -1165,18 +1165,14 @@ const char * TYPEget_idl_type( const Type t ) { /* case TYPE_ENTITY: */ if( class == entity_ ) { /* better do this because the return type might go away */ - strcpy( retval, IdlEntityTypeName( t ) ); + strncpy( retval, IdlEntityTypeName( t ), BUFSIZ - 4 ); strcat( retval, "_ptr" ); return retval; } /* case TYPE_ENUM: */ /* case TYPE_SELECT: */ if( class == enumeration_ ) { - strncpy( retval, EnumName( TYPEget_name( t ) ), BUFSIZ - 2 ); - - strcat( retval, " /*" ); - strcat( retval, IdlEntityTypeName( t ) ); - strcat( retval, "*/ " ); + snprintf( retval, BUFSIZ, "%s /*%s*/ ", EnumName(TYPEget_name(t)), IdlEntityTypeName(t) ); return retval; } if( class == select_ ) { @@ -1201,9 +1197,8 @@ const char * TYPEget_idl_type( const Type t ) { char * TYPEget_express_type( const Type t ) { Class_Of_Type class; Type bt; - char retval [BUFSIZ+1]; - char * n, * permval, * aggr_type; - + char retval [BUFSIZ+1] = {'\0'}; + char * n = NULL, * permval = NULL, * aggr_type = NULL; /* 1. "DEFINED" types */ /* case TYPE_ENUM: */ @@ -1293,7 +1288,9 @@ char * TYPEget_express_type( const Type t ) { void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const char * aggr_name, const char * cname, Expression bound, int boundNr ) { if( bound->symbol.resolved ) { if( bound->type == Type_Funcall ) { - fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, EXPRto_string( bound ) ); + char *bound_str = EXPRto_string(bound); + fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, bound_str ); + sc_free(bound_str); } else { fprintf( impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer ); } From efd353858e9fb7ec2aaca96fff4af55c0e67d433 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:02:54 -0500 Subject: [PATCH 211/244] Use strncpy to transfer nm to name --- src/exp2cxx/complexSupport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2cxx/complexSupport.h b/src/exp2cxx/complexSupport.h index baf02dbbe..f285c506d 100644 --- a/src/exp2cxx/complexSupport.h +++ b/src/exp2cxx/complexSupport.h @@ -73,7 +73,7 @@ class EntNode { public: EntNode( const char * nm = "" ) : next( 0 ), mark( NOMARK ), multSupers( 0 ) { - strcpy( name, nm ); + strncpy( name, nm, BUFSIZ ); } EntNode( char *[] ); // given a list, create a linked list of EntNodes ~EntNode() { From 4bab26918d32d4bf51fa7fcf920f09da94a0bd7b Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 26 Feb 2022 16:04:03 -0500 Subject: [PATCH 212/244] strcpy -> strncpy --- src/exp2cxx/expressbuild.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exp2cxx/expressbuild.cc b/src/exp2cxx/expressbuild.cc index a1c665656..42458c31a 100644 --- a/src/exp2cxx/expressbuild.cc +++ b/src/exp2cxx/expressbuild.cc @@ -286,7 +286,7 @@ void ComplexList::addImplicitSubs( Linked_List subs, ComplexCollect * col ) AndOrList * ao = 0; LISTdo( subs, subEnt, Entity ) - strcpy( node.name, ENTITYget_name( subEnt ) ); + strncpy( node.name, ENTITYget_name( subEnt ), BUFSIZ ); if( !contains( &node ) ) { // We've found an implicit subtype. #ifdef COMPLEX_INFO From 520e7a37898c36c1fbf4ee07111aaa629af325e6 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Sun, 25 Sep 2022 16:24:30 +0100 Subject: [PATCH 213/244] update contributing guidelines to allow more flexibility when accepting PRs --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8d1f443e..62e9503db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,9 +11,12 @@ We love contributions! * Encouraged but not enforced: each commit should stand alone, in the sense that the code should compile and run at that point. * One major topic per pull request. Commits that fix small things (typos, formatting) are perfectly acceptable in a PR fixing a bug or adding a feature. * Tests are good. Tests are required unless you're fixing something simple or that was obviously broken. + * Do not change EXPRESS schema definition without reference to an upstream change. * Make your changes and push them to your GitHub repo * Once your branch is pushed, submit a pull request. -* We'll look at the PR and either merge or add feedback. If there isn't any activity within several days, send a message to the mailing list - `scl-dev` AT `groups.google.com`. + - enable github option on each PR 'Allow edits from maintainers', refer to github help if necessary +* We'll look at the PR and either merge (possibly after rebase) or add feedback. + - If there isn't any activity within several days send a message to the mailing list - `scl-dev` AT `groups.google.com`. ## Coding Standards From 8e9a68968c1a55a10db3fb6659981d901617ffc5 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 1 Sep 2022 18:00:27 -0700 Subject: [PATCH 214/244] Changed Python SCL setup.cfg name to "stepcode-scl" so the package can be deployed to pypi. The current package name, SCL, is too similar to existing pypi package names that the repository will not allow it to be committed. This change does not affect internal package name, which remains "SCL", just the name used to fetch the package from the pypi repository. After this change is committed and posted to pypi, users will be able to fetch the package with `pip install stepcode-scl`. --- src/exp2python/python/setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exp2python/python/setup.cfg b/src/exp2python/python/setup.cfg index ef47b03e0..276a8bd30 100644 --- a/src/exp2python/python/setup.cfg +++ b/src/exp2python/python/setup.cfg @@ -1,8 +1,8 @@ [metadata] -name = SCL +name = stepcode-scl version = 0.6.1 author = Thomas Paviot , Christopher HORLER (cshorler@googlemail.com), Devon Sparks (devonsparks.com) -description = SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +description = stepcode-scl is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. long_description = file: README.md long_description_content_type = text/markdown From 7dbda20be04845f02b9ae4441a7c9a746618915e Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 11 Jun 2022 22:46:58 -0400 Subject: [PATCH 215/244] Remove base library from stepcode Move specific pieces of logic still in use next to the individual parts of the code that use them, and eliminate base from the code. --- CMakeLists.txt | 2 - cmake/SC_CXX_schema_macros.cmake | 14 +- cmake/schema_scanner/CMakeLists.txt | 2 - cmake/schema_scanner/schemaScanner.cc | 57 ++- example/ap203min/CMakeLists.txt | 3 +- .../ExternalProjectBuild/CMakeLists.txt | 3 - example/ap203min/include/config.h.in | 1 - include/config.h.in | 1 - include/express/basic.h | 3 + src/base/CMakeLists.txt | 72 ---- src/base/path2str.c | 29 -- src/base/path2str.h | 20 - src/base/sc_getopt.cc | 214 --------- src/base/sc_getopt.h | 32 -- src/base/sc_memmgr.cc | 405 ------------------ src/base/sc_memmgr.h | 79 ---- src/base/sc_mkdir.c | 32 -- src/base/sc_mkdir.h | 15 - src/base/sc_stdio.h | 39 -- src/base/sc_strtoull.h | 11 - src/cldai/CMakeLists.txt | 3 +- src/cldai/sdaiApplication_instance_set.cc | 1 - src/cldai/sdaiBinary.cc | 1 - src/cldai/sdaiDaObject.cc | 1 - src/cldai/sdaiEntity_extent.cc | 1 - src/cldai/sdaiEntity_extent_set.cc | 1 - src/cldai/sdaiEnum.cc | 1 - src/cldai/sdaiModel_contents.cc | 1 - src/cldai/sdaiModel_contents_list.cc | 1 - src/cldai/sdaiObject.cc | 1 - src/cldai/sdaiSession_instance.cc | 1 - src/cldai/sdaiString.cc | 1 - src/cleditor/CMakeLists.txt | 5 +- src/cleditor/STEPfile.cc | 2 - src/cleditor/STEPfile.inline.cc | 1 - src/cleditor/SdaiHeaderSchema.cc | 1 - src/cleditor/SdaiHeaderSchemaAll.cc | 1 - src/cleditor/SdaiHeaderSchemaInit.cc | 1 - src/cleditor/SdaiSchemaInit.cc | 1 - src/cleditor/cmdmgr.cc | 1 - src/cllazyfile/CMakeLists.txt | 16 +- src/cllazyfile/headerSectionReader.h | 1 - src/{base => cllazyfile}/judy/CMakeLists.txt | 0 src/{base => cllazyfile}/judy/README.md | 0 src/{base => cllazyfile}/judy/misc/astyle.cfg | 0 src/{base => cllazyfile}/judy/misc/hextest.sh | 0 src/{base => cllazyfile}/judy/misc/judy64n.c | 0 src/{base => cllazyfile}/judy/src/judy.c | 0 src/{base => cllazyfile}/judy/src/judy.h | 0 .../judy/src/judyL2Array.h | 0 .../judy/src/judyLArray.h | 0 .../judy/src/judyS2Array.h | 0 .../judy/src/judySArray.h | 0 src/{base => cllazyfile}/judy/test/hexSort.c | 0 .../judy/test/judyL2test.cc | 0 .../judy/test/judyLtest.cc | 0 .../judy/test/judyS2test.cc | 0 .../judy/test/judyStest.cc | 0 .../judy/test/pennySort.c | 0 src/{base => cllazyfile}/judy/test/sort.c | 0 src/{base => cllazyfile}/judy/test/sort.h | 0 src/cllazyfile/lazyDataSectionReader.h | 1 - src/cllazyfile/lazyFileReader.h | 2 - src/cllazyfile/lazyInstMgr.h | 1 - src/cllazyfile/lazyP21DataSectionReader.h | 1 - src/cllazyfile/lazy_test.cc | 3 +- src/cllazyfile/p21HeaderSectionReader.h | 1 - src/{base => cllazyfile}/sc_benchmark.cc | 3 +- src/{base => cllazyfile}/sc_benchmark.h | 7 +- src/cllazyfile/sectionReader.cc | 7 +- src/cllazyfile/sectionReader.h | 1 - src/clstepcore/CMakeLists.txt | 3 +- src/clstepcore/Registry.cc | 1 - src/clstepcore/STEPaggregate.cc | 1 - src/clstepcore/STEPattribute.cc | 1 - src/clstepcore/STEPattributeList.cc | 1 - src/clstepcore/STEPcomplex.cc | 1 - src/clstepcore/STEPinvAttrList.cc | 1 - src/clstepcore/STEPundefined.cc | 1 - src/clstepcore/SingleLinkList.cc | 1 - src/clstepcore/collect.cc | 1 - src/clstepcore/complexlist.cc | 1 - src/clstepcore/dispnode.cc | 1 - src/clstepcore/dispnodelist.cc | 1 - src/clstepcore/entlist.cc | 1 - src/clstepcore/entnode.cc | 1 - src/clstepcore/instmgr.cc | 1 - src/clstepcore/match-ors.cc | 1 - src/clstepcore/mgrnode.cc | 1 - src/clstepcore/mgrnodearray.cc | 1 - src/clstepcore/mgrnodelist.cc | 1 - src/clstepcore/multlist.cc | 1 - src/clstepcore/needFunc.cc | 1 - src/clstepcore/non-ors.cc | 1 - src/clstepcore/orlist.cc | 1 - src/clstepcore/print.cc | 1 - src/clstepcore/read_func.cc | 1 - src/clstepcore/sdai.cc | 1 - src/clstepcore/test/CMakeLists.txt | 9 +- src/clstepcore/trynext.cc | 1 - src/clutils/CMakeLists.txt | 5 +- src/clutils/dirobj.cc | 2 - src/clutils/errordesc.cc | 1 - src/clutils/gennode.cc | 1 - src/clutils/gennodearray.cc | 1 - src/clutils/gennodelist.cc | 1 - src/clutils/sc_hash.cc | 1 - src/exp2cxx/CMakeLists.txt | 5 +- src/exp2cxx/classes.c | 6 +- src/exp2cxx/classes_attribute.c | 11 +- src/exp2cxx/classes_entity.c | 43 +- src/exp2cxx/classes_misc.c | 8 +- src/exp2cxx/classes_type.c | 74 +++- src/exp2cxx/classes_wrapper.cc | 8 +- src/exp2cxx/collect.cc | 1 - src/exp2cxx/complexlist.cc | 1 - src/exp2cxx/entlist.cc | 1 - src/exp2cxx/entnode.cc | 1 - src/exp2cxx/expressbuild.cc | 1 - src/exp2cxx/fedex_main.c | 3 +- src/exp2cxx/genCxxFilenames.c | 5 - src/exp2cxx/match-ors.cc | 1 - src/exp2cxx/multlist.cc | 1 - src/exp2cxx/multpass.c | 7 +- src/exp2cxx/non-ors.cc | 1 - src/exp2cxx/orlist.cc | 1 - src/exp2cxx/print.cc | 1 - src/exp2cxx/selects.c | 9 +- .../trace_fprintf.c} | 3 +- .../trace_fprintf.h} | 4 +- src/exp2cxx/trynext.cc | 1 - src/exp2cxx/write.cc | 5 +- src/exp2python/CMakeLists.txt | 3 +- src/exp2python/src/classes_python.c | 10 +- src/exppp/CMakeLists.txt | 7 +- src/exppp/exppp.c | 11 +- src/exppp/pretty_subtype.c | 2 - src/exppp/pretty_type.c | 5 +- src/exppp/test/CMakeLists.txt | 2 +- src/express/CMakeLists.txt | 6 +- src/express/error.c | 14 +- src/express/express.c | 17 +- src/express/fedex.c | 64 ++- src/express/hash.c | 3 +- src/express/lexact.c | 9 +- src/express/test/CMakeLists.txt | 4 +- src/test/p21read/p21read.cc | 61 ++- src/test/p21read/sc_benchmark.cc | 149 +++++++ src/test/p21read/sc_benchmark.h | 74 ++++ test/cpp/schema_specific/CMakeLists.txt | 4 +- test/cpp/schema_specific/attribute.cc | 60 ++- test/cpp/schema_specific/inverse_attr1.cc | 62 ++- test/cpp/schema_specific/inverse_attr2.cc | 61 ++- test/cpp/schema_specific/inverse_attr3.cc | 63 ++- 154 files changed, 831 insertions(+), 1218 deletions(-) delete mode 100644 src/base/CMakeLists.txt delete mode 100644 src/base/path2str.c delete mode 100644 src/base/path2str.h delete mode 100644 src/base/sc_getopt.cc delete mode 100644 src/base/sc_getopt.h delete mode 100644 src/base/sc_memmgr.cc delete mode 100644 src/base/sc_memmgr.h delete mode 100644 src/base/sc_mkdir.c delete mode 100644 src/base/sc_mkdir.h delete mode 100644 src/base/sc_stdio.h delete mode 100644 src/base/sc_strtoull.h rename src/{base => cllazyfile}/judy/CMakeLists.txt (100%) rename src/{base => cllazyfile}/judy/README.md (100%) rename src/{base => cllazyfile}/judy/misc/astyle.cfg (100%) rename src/{base => cllazyfile}/judy/misc/hextest.sh (100%) rename src/{base => cllazyfile}/judy/misc/judy64n.c (100%) rename src/{base => cllazyfile}/judy/src/judy.c (100%) rename src/{base => cllazyfile}/judy/src/judy.h (100%) rename src/{base => cllazyfile}/judy/src/judyL2Array.h (100%) rename src/{base => cllazyfile}/judy/src/judyLArray.h (100%) rename src/{base => cllazyfile}/judy/src/judyS2Array.h (100%) rename src/{base => cllazyfile}/judy/src/judySArray.h (100%) rename src/{base => cllazyfile}/judy/test/hexSort.c (100%) rename src/{base => cllazyfile}/judy/test/judyL2test.cc (100%) rename src/{base => cllazyfile}/judy/test/judyLtest.cc (100%) rename src/{base => cllazyfile}/judy/test/judyS2test.cc (100%) rename src/{base => cllazyfile}/judy/test/judyStest.cc (100%) rename src/{base => cllazyfile}/judy/test/pennySort.c (100%) rename src/{base => cllazyfile}/judy/test/sort.c (100%) rename src/{base => cllazyfile}/judy/test/sort.h (100%) rename src/{base => cllazyfile}/sc_benchmark.cc (99%) rename src/{base => cllazyfile}/sc_benchmark.h (93%) rename src/{base/sc_trace_fprintf.c => exp2cxx/trace_fprintf.c} (92%) rename src/{base/sc_trace_fprintf.h => exp2cxx/trace_fprintf.h} (85%) create mode 100644 src/test/p21read/sc_benchmark.cc create mode 100644 src/test/p21read/sc_benchmark.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d3f0b180..bced0837b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,6 @@ option(BUILD_STATIC_LIBS "Build static libraries" OFF) option(SC_PYTHON_GENERATOR "Compile exp2python" ON) option(SC_CPP_GENERATOR "Compile exp2cxx" ON) -option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) @@ -189,7 +188,6 @@ include_directories( ${SC_BINARY_DIR}/include ) -add_subdirectory(src/base) add_subdirectory(src/express) add_subdirectory(src/exppp) add_subdirectory(src/exp2cxx) diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 016450c2c..c94d63e48 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -27,16 +27,16 @@ 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} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) + SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) if(NOT WIN32) - SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE) + SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc;${RELATIVE_PATH_COMPONENT}/src/cllazyfile/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils TESTABLE) 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} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE) + SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE) #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) @@ -89,12 +89,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) ) 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 + ${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/cllazyfile + ${SC_SOURCE_DIR}/src/cllazyfile/judy/src ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation if(BUILD_SHARED_LIBS) - SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE) + SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils TESTABLE) add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) if(WIN32) target_compile_definitions("${PROJECT_NAME}" PRIVATE SC_SCHEMA_DLL_EXPORTS) @@ -111,7 +111,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) endif() if($CACHE{SC_BUILD_STATIC_LIBS}) - SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static base-static TESTABLE) + SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static TESTABLE) add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME}) target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC) if(MSVC) diff --git a/cmake/schema_scanner/CMakeLists.txt b/cmake/schema_scanner/CMakeLists.txt index 16219eb9a..20968ddb0 100644 --- a/cmake/schema_scanner/CMakeLists.txt +++ b/cmake/schema_scanner/CMakeLists.txt @@ -16,7 +16,6 @@ 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 @@ -52,7 +51,6 @@ 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 ) diff --git a/cmake/schema_scanner/schemaScanner.cc b/cmake/schema_scanner/schemaScanner.cc index 7f1d167c0..e37238415 100644 --- a/cmake/schema_scanner/schemaScanner.cc +++ b/cmake/schema_scanner/schemaScanner.cc @@ -14,20 +14,25 @@ */ extern "C" { -# include "expparse.h" -# include "expscan.h" -# include "express/scope.h" -# include "genCxxFilenames.h" -# include "sc_mkdir.h" - -# include - -# ifdef _WIN32 -# include -# define getcwd _getcwd -# else -# include -# endif +#define _XOPEN_SOURCE /* for S_IFDIR */ + +#include +#include +#include + +#include "expparse.h" +#include "expscan.h" +#include "express/scope.h" +#include "genCxxFilenames.h" + +#include + +#ifdef _WIN32 +# include +# define getcwd _getcwd +#else +# include +#endif } #include @@ -125,6 +130,30 @@ string makeShortName( const char * longName ) { return filename; } +/* 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 */ +static 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; +} + + /** 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 ) { diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index 52bbe7028..6537d3e80 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -51,14 +51,13 @@ endif(NOT EXISTS ${SCHEMA_FILE}) 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}) +set(STEPCODE_LIBRARIES 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) # 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 diff --git a/example/ap203min/ExternalProjectBuild/CMakeLists.txt b/example/ap203min/ExternalProjectBuild/CMakeLists.txt index 3a5409088..45cce97e9 100644 --- a/example/ap203min/ExternalProjectBuild/CMakeLists.txt +++ b/example/ap203min/ExternalProjectBuild/CMakeLists.txt @@ -19,7 +19,6 @@ INCLUDE( External_STEPCode ) IF(NOT WIN32) set( STEPCODE_LIBRARIES - ${STEPCODE_INSTALL_DIR}/lib/libbase.a ${STEPCODE_INSTALL_DIR}/lib/libstepcore.a ${STEPCODE_INSTALL_DIR}/lib/libstepeditor.a ${STEPCODE_INSTALL_DIR}/lib/libstepdai.a @@ -28,7 +27,6 @@ IF(NOT WIN32) ) ELSE() set( STEPCODE_LIBRARIES - ${STEPCODE_INSTALL_DIR}/lib/libbase.lib ${STEPCODE_INSTALL_DIR}/lib/libstepcore.lib ${STEPCODE_INSTALL_DIR}/lib/libstepeditor.lib ${STEPCODE_INSTALL_DIR}/lib/libstepdai.lib @@ -44,7 +42,6 @@ MESSAGE( STATUS "STEPCODE_INSTALL_DIR: " ${STEPCODE_INSTALL_DIR} ) set( STEPCODE_INCLUDE_DIR ${STEPCODE_INSTALL_DIR}/include/stepcode -${STEPCODE_INSTALL_DIR}/include/stepcode/base ${STEPCODE_INSTALL_DIR}/include/stepcode/clstepcore ${STEPCODE_INSTALL_DIR}/include/stepcode/cldai ${STEPCODE_INSTALL_DIR}/include/stepcode/clutils diff --git a/example/ap203min/include/config.h.in b/example/ap203min/include/config.h.in index 67d88c433..63ccc4ed1 100644 --- a/example/ap203min/include/config.h.in +++ b/example/ap203min/include/config.h.in @@ -15,7 +15,6 @@ #cmakedefine HAVE_IO_H 1 #cmakedefine SC_TRACE_FPRINTF 1 -#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 #cmakedefine HAVE_ABS 1 #cmakedefine HAVE_MEMCPY 1 diff --git a/include/config.h.in b/include/config.h.in index 67d88c433..63ccc4ed1 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -15,7 +15,6 @@ #cmakedefine HAVE_IO_H 1 #cmakedefine SC_TRACE_FPRINTF 1 -#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1 #cmakedefine HAVE_ABS 1 #cmakedefine HAVE_MEMCPY 1 diff --git a/include/express/basic.h b/include/express/basic.h index 3318ffc19..f7c6b90f0 100644 --- a/include/express/basic.h +++ b/include/express/basic.h @@ -96,5 +96,8 @@ typedef void ( *voidFuncptr )(); typedef int ( *intFuncptr )(); +/* Option index - can we get rid of this? */ +extern SC_EXPRESS_EXPORT int sc_optind; + #endif /* BASIC_H */ diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt deleted file mode 100644 index 5aad0a929..000000000 --- a/src/base/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ - -set(SC_BASE_SOURCES - sc_memmgr.cc - sc_trace_fprintf.c - sc_getopt.cc - sc_benchmark.cc - sc_mkdir.c - path2str.c - judy/src/judy.c - ) - -set(SC_BASE_HDRS - sc_benchmark.h - sc_memmgr.h - sc_getopt.h - sc_trace_fprintf.h - sc_mkdir.h - path2str.h - judy/src/judy.h - judy/src/judyLArray.h - judy/src/judyL2Array.h - judy/src/judySArray.h - judy/src/judyS2Array.h - ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/judy/src - ) - -if($CACHE{SC_MEMMGR_ENABLE_CHECKS}) - add_definitions(-DSC_MEMMGR_ENABLE_CHECKS) -endif() - -if(BUILD_SHARED_LIBS) - SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES}) - if(WIN32) - target_link_libraries(base psapi) - target_compile_definitions(base PRIVATE SC_BASE_DLL_EXPORTS) - endif() -endif() - -if(BUILD_STATIC_LIBS) - SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES}) - if(WIN32) - target_link_libraries(base-static psapi) - endif() -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") - -install(FILES ${SC_BASE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/base) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 - diff --git a/src/base/path2str.c b/src/base/path2str.c deleted file mode 100644 index 6f5aedd7c..000000000 --- a/src/base/path2str.c +++ /dev/null @@ -1,29 +0,0 @@ - -#include "path2str.h" -#include "sc_memmgr.h" -#include - -/* for windows, rewrite backslashes in paths - * that will be written to generated code - */ -const char * path2str_fn( const char * fileMacro ) { - static char * result = 0; - static size_t rlen = 0; - char * p; - if( rlen < strlen( fileMacro ) ) { - if( result ) { - sc_free( result ); - } - rlen = strlen( fileMacro ); - result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 ); - } - strcpy( result, fileMacro ); - p = result; - while( *p ) { - if( *p == '\\' ) { - *p = '/'; - } - p++; - } - return result; -} diff --git a/src/base/path2str.h b/src/base/path2str.h deleted file mode 100644 index 84155cd9f..000000000 --- a/src/base/path2str.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PATH2STR_H -#define PATH2STR_H - -#include - -/** windows only: rewrite backslashes in paths as forward slashes - * call as path2str(__FILE__) to take advantage of macro - * - * silence "unknown escape sequence" warning when contents of __FILE__ - * are fprintf'd into string in generated code - */ -SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro ); - -#ifdef _WIN32 -# define path2str(path) path2str_fn(path) -#else -# define path2str(path) path -#endif - -#endif /* PATH2STR_H */ diff --git a/src/base/sc_getopt.cc b/src/base/sc_getopt.cc deleted file mode 100644 index 01e925b56..000000000 --- a/src/base/sc_getopt.cc +++ /dev/null @@ -1,214 +0,0 @@ -/****** RENAMED from xgetopt.cc to sc_getopt.cc ***********/ - -// XGetopt.cpp Version 1.2 -// -// Author: Hans Dietrich -// hdietrich2@hotmail.com -// -// Description: -// XGetopt.cpp implements sc_getopt(), a function to parse command lines. -// -// History -// Version 1.2 - 2003 May 17 -// - Added Unicode support -// -// Version 1.1 - 2002 March 10 -// - Added example to XGetopt.cpp module header -// -// This software is released into the public domain. -// You are free to use it in any way you like. -// -// This software is provided "as is" with no expressed -// or implied warranty. I accept no liability for any -// damage or loss of business that this software may cause. -// -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// if you are using precompiled headers then include this line: -//#include "stdafx.h" -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// if you are not using precompiled headers then include these lines: -//#include -#include -#include -/////////////////////////////////////////////////////////////////////////////// - -#include "sc_getopt.h" - -/////////////////////////////////////////////////////////////////////////////// -// -// X G e t o p t . c p p -// -// -// NAME -// sc_getopt -- parse command line options -// -// SYNOPSIS -// int sc_getopt(int argc, char *argv[], char *optstring) -// -// extern char *sc_optarg; -// extern int sc_optind; -// -// DESCRIPTION -// The sc_getopt() function parses the command line arguments. Its -// arguments argc and argv are the argument count and array as -// passed into the application on program invocation. In the case -// of Visual C++ programs, argc and argv are available via the -// variables __argc and __argv (double underscores), respectively. -// sc_getopt returns the next option letter in argv that matches a -// letter in optstring. (Note: Unicode programs should use -// __targv instead of __argv. Also, all character and string -// literals should be enclosed in _T( ) ). -// -// optstring is a string of recognized option letters; if a letter -// is followed by a colon, the option is expected to have an argument -// that may or may not be separated from it by white space. sc_optarg -// is set to point to the start of the option argument on return from -// sc_getopt. -// -// Option letters may be combined, e.g., "-ab" is equivalent to -// "-a -b". Option letters are case sensitive. -// -// sc_getopt places in the external variable sc_optind the argv index -// of the next argument to be processed. sc_optind is initialized -// to 0 before the first call to sc_getopt. -// -// When all options have been processed (i.e., up to the first -// non-option argument), sc_getopt returns EOF, sc_optarg will point -// to the argument, and sc_optind will be set to the argv index of -// the argument. If there are no non-option arguments, sc_optarg -// will be set to NULL. -// -// The special option "--" may be used to delimit the end of the -// options; EOF will be returned, and "--" (and everything after it) -// will be skipped. -// -// RETURN VALUE -// For option letters contained in the string optstring, sc_getopt -// will return the option letter. sc_getopt returns a question mark (?) -// when it encounters an option letter not included in optstring. -// EOF is returned when processing is finished. -// -// BUGS -// 1) Long options are not supported. -// 2) The GNU double-colon extension is not supported. -// 3) The environment variable POSIXLY_CORRECT is not supported. -// 4) The + syntax is not supported. -// 5) The automatic permutation of arguments is not supported. -// 6) This implementation of sc_getopt() returns EOF if an error is -// encountered, instead of -1 as the latest standard requires. -// -// EXAMPLE -// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[]) -// { -// int c; -// -// while ((c = sc_getopt(argc, argv, _T("aBn:"))) != EOF) -// { -// switch (c) -// { -// case _T('a'): -// TRACE(_T("option a\n")); -// // -// // set some flag here -// // -// break; -// -// case _T('B'): -// TRACE( _T("option B\n")); -// // -// // set some other flag here -// // -// break; -// -// case _T('n'): -// TRACE(_T("option n: value=%d\n"), atoi(sc_optarg)); -// // -// // do something with value here -// // -// break; -// -// case _T('?'): -// TRACE(_T("ERROR: illegal option %s\n"), argv[sc_optind-1]); -// return FALSE; -// break; -// -// default: -// TRACE(_T("WARNING: no handler for option %c\n"), c); -// return FALSE; -// break; -// } -// } -// // -// // check for non-option args here -// // -// return TRUE; -// } -// -/////////////////////////////////////////////////////////////////////////////// - -char * sc_optarg; // global argument pointer -int sc_optind = 0; // global argv index - -int sc_getopt( int argc, char * argv[], char * optstring ) { - static char * next = NULL; - if( sc_optind == 0 ) { - next = NULL; - } - - sc_optarg = NULL; - - if( next == NULL || *next == '\0' ) { - if( sc_optind == 0 ) { - sc_optind++; - } - - if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { - sc_optarg = NULL; - if( sc_optind < argc ) { - sc_optarg = argv[sc_optind]; - } - return EOF; - } - - if( strcmp( argv[sc_optind], "--" ) == 0 ) { - sc_optind++; - sc_optarg = NULL; - if( sc_optind < argc ) { - sc_optarg = argv[sc_optind]; - } - return EOF; - } - - next = argv[sc_optind]; - next++; // skip past - - sc_optind++; - } - - char c = *next++; - char * cp = strchr( optstring, c ); - - if( cp == NULL || c == ':' ) { - return '?'; - } - - cp++; - if( *cp == ':' ) { - if( *next != '\0' ) { - sc_optarg = next; - next = NULL; - } else if( sc_optind < argc ) { - sc_optarg = argv[sc_optind]; - sc_optind++; - } else { - return '?'; - } - } - - return c; -} diff --git a/src/base/sc_getopt.h b/src/base/sc_getopt.h deleted file mode 100644 index e1421a7bf..000000000 --- a/src/base/sc_getopt.h +++ /dev/null @@ -1,32 +0,0 @@ -/** \file sc_getopt.h - * this was xgetopt.h - * XGetopt.h Version 1.2 - * - * Author: Hans Dietrich - * hdietrich2@hotmail.com - * - * This software is released into the public domain. - * You are free to use it in any way you like. - * - * This software is provided "as is" with no expressed - * or implied warranty. I accept no liability for any - * damage or loss of business that this software may cause. - */ -#ifndef XGETOPT_H -#define XGETOPT_H -#include "sc_export.h" - -#ifdef __cplusplus -extern "C" { -#endif - - extern SC_BASE_EXPORT int sc_optind, sc_opterr; - extern SC_BASE_EXPORT char * sc_optarg; - - int SC_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring ); - -#ifdef __cplusplus -} -#endif - -#endif /* XGETOPT_H */ diff --git a/src/base/sc_memmgr.cc b/src/base/sc_memmgr.cc deleted file mode 100644 index 61d89a5ed..000000000 --- a/src/base/sc_memmgr.cc +++ /dev/null @@ -1,405 +0,0 @@ - -#define SC_MEMMGR_CC - -#include "config.h" -#include "sc_memmgr.h" - -#include -#include - -#include -#include - -#ifdef SC_MEMMGR_ENABLE_CHECKS - -/** - sc_memmgr_error definition -*/ -class sc_memmgr_error { - private: - std::string _srcfile; - unsigned int _srcline; - unsigned int _occurences; - public: - sc_memmgr_error( const std::string & file, const unsigned int line ); - sc_memmgr_error( const sc_memmgr_error & rhs ); - ~sc_memmgr_error( void ); - - bool operator<( const sc_memmgr_error & rhs ) const; - - std::string getsrcfile( void ) const; - unsigned int getsrcline( void ) const; - unsigned int getoccurences( void ) const; -}; - -typedef std::set sc_memmgr_errors; -typedef std::set::iterator sc_memmgr_error_iterator; - -/** - sc_memmgr_record definition -*/ -class sc_memmgr_record { - private: - void * _addr; - size_t _size; - std::string _srcfile; - unsigned int _srcline; - public: - sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ); - sc_memmgr_record( void * addr ); - sc_memmgr_record( const sc_memmgr_record & rhs ); - ~sc_memmgr_record( void ); - - bool operator<( const sc_memmgr_record & rhs ) const; - - void * getaddr( void ) const; - size_t getsize( void ) const; - std::string getsrcfile( void ) const; - unsigned int getsrcline( void ) const; -}; - -typedef std::set sc_memmgr_records; -typedef std::set::iterator sc_memmgr_record_iterator; - -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - -/** - sc_memmgr definition -*/ -class sc_memmgr { - private: -#ifdef SC_MEMMGR_ENABLE_CHECKS - bool _record_insert_busy, _record_erase_busy; - // memory allocation/reallocation records, inserted at allocation, erased at deallocation. - sc_memmgr_records _records; - // memory stats - unsigned int _allocated; // amount of memory allocated simultaniously - unsigned int _maximum_allocated; // maximum amount of memory allocated simultaniously - unsigned int _allocated_total; // total amount of memory allocated in bytes - unsigned int _reallocated_total; // total amount of memory reallocated in bytes - unsigned int _deallocated_total; // total amount of memory deallocated in bytes -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - protected: - public: - sc_memmgr( void ); - ~sc_memmgr( void ); - - void * allocate( size_t size, const char * file, const int line ); - void * reallocate( void * addr, size_t size, const char * file, const int line ); - void deallocate( void * addr, const char * file, const int line ); -}; - -/** - sc_memmgr instance. - There should be one static instance of memmgr. - This instance is automatically destroyed when application exits, so this allows us to add - memory leak detection in it's destructor. -*/ -sc_memmgr memmgr; - -/** - c memory functions implementation -*/ -extern "C" { - - void * sc_malloc_fn( unsigned int size, const char * file, const int line ) { - return memmgr.allocate( size, file, line ); - } - - void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) { - return memmgr.allocate( count * size, file, line ); - } - - void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) { - return memmgr.reallocate( addr, size, file, line ); - } - - void sc_free_fn( void * addr ) { - memmgr.deallocate( addr, "", 0 ); - } - -} - -/** - c++ memory operators implementation -*/ -void * sc_operator_new( size_t size, const char * file, const int line ) { - return memmgr.allocate( size, file, line ); -} - -void sc_operator_delete( void * addr, const char * file, const int line ) { - memmgr.deallocate( addr, file, line ); -} - -void sc_operator_delete( void * addr ) { - memmgr.deallocate( addr, "", 0 ); -} - -/** - sc_memmgr implementation -*/ -sc_memmgr::sc_memmgr( void ) { -#ifdef SC_MEMMGR_ENABLE_CHECKS - _record_insert_busy = false; - _record_erase_busy = false; - - _allocated = 0; - _maximum_allocated = 0; - _allocated_total = 0; - _reallocated_total = 0; - _deallocated_total = 0; -#endif /* SC_MEMMGR_ENABLE_CHECKS */ -} - -/** - Destructor: - sc_memmgr::~sc_memmgr(void) - Description: - The sc_memmgr destructor is used to check for memory leaks when enabled. - All records still present when sc_memmgr instance is destroyed can be considered as - memory leaks. -*/ -sc_memmgr::~sc_memmgr( void ) { -#ifdef SC_MEMMGR_ENABLE_CHECKS - sc_memmgr_record_iterator irecord; - sc_memmgr_errors errors; - sc_memmgr_error_iterator ierror; - - // Check if total allocated equals total deallocated - if( _allocated_total != _deallocated_total ) { - // todo: generate warning for possible memory leaks, enable full memory leak checking - fprintf( stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total ); - } - - // Compact leaks into an error list to prevent same leak being reported multiple times. - _record_insert_busy = true; - _record_erase_busy = true; - for( irecord = _records.begin(); - irecord != _records.end(); - irecord ++ ) { - sc_memmgr_error error( irecord->getsrcfile(), irecord->getsrcline() ); - ierror = errors.find( error ); - if( ierror == errors.end() ) { - errors.insert( error ); - } - //else - // ierror->occurences ++; - } - _record_insert_busy = false; - _record_erase_busy = false; - - // Loop through memory leaks to generate/buffer errors - for( ierror = errors.begin(); - ierror != errors.end(); - ierror ++ ) { - // todo: generate error for memory leak - fprintf( stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline() ); - } - - // Clear remaining records - _record_erase_busy = true; - _records.clear(); - errors.clear(); - _record_erase_busy = false; -#endif /* SC_MEMMGR_ENABLE_CHECKS */ -} - -void * sc_memmgr::allocate( size_t size, const char * file, const int line ) { - void * addr; - - // Allocate - addr = malloc( size ); - if( addr == NULL ) { - // todo: error allocation failed - fprintf( stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line ); - } - - // Some stl implementations (for example debian gcc) use the new operator to construct - // new elements when inserting sc_memmgr_record. When this our new operator gets used - // for this operation, this would result in an infinite loop. This is fixed by the - // _record_insert_busy flag. -#ifdef SC_MEMMGR_ENABLE_CHECKS - if( !_record_insert_busy ) { - // Store record for this allocation - _record_insert_busy = true; - _records.insert( sc_memmgr_record( addr, size, file, line ) ); - _record_insert_busy = false; - - // Update stats - _allocated += size; - if( _allocated > _maximum_allocated ) { - _maximum_allocated = _allocated; - } - _allocated_total += size; - } -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - - return addr; -} - -void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const int line ) { -#ifdef SC_MEMMGR_ENABLE_CHECKS - sc_memmgr_record_iterator record; - - if( !_record_insert_busy ) { - // Find record of previous allocation/reallocation - record = _records.find( sc_memmgr_record( addr ) ); - if( record == _records.end() ) { - // todo: error reallocating memory not allocated? - fprintf( stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line ); - } else { - // Update stats - _allocated -= record->getsize(); - _deallocated_total += record->getsize(); - - // Erase previous allocation/reallocation - _record_erase_busy = true; - _records.erase( record ); - _record_erase_busy = false; - } - } -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - - // Reallocate - addr = realloc( addr, size ); - if( addr == NULL ) { - // todo: error reallocation failed - fprintf( stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line ); - } - -#ifdef SC_MEMMGR_ENABLE_CHECKS - if( !_record_insert_busy ) { - // Store record for this reallocation - _record_insert_busy = true; - _records.insert( sc_memmgr_record( addr, size, file, line ) ); - _record_insert_busy = false; - - // Update stats - _allocated += size; - if( _allocated > _maximum_allocated ) { - _maximum_allocated = _allocated; - } - _allocated_total += size; - _reallocated_total += size; - } -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - - return addr; -} - -void sc_memmgr::deallocate( void * addr, const char * file, const int line ) { -#ifdef SC_MEMMGR_ENABLE_CHECKS - sc_memmgr_record_iterator record; - - if( !_record_erase_busy ) { - // Find record of previous allocation/reallocation - record = _records.find( sc_memmgr_record( addr ) ); - if( record == _records.end() ) { - // todo: error free called for not allocated memory? - fprintf( stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line ); - } else { - // Update stats - _allocated -= record->getsize(); - _deallocated_total += record->getsize(); - - // Erase record - _record_erase_busy = true; - _records.erase( record ); - _record_erase_busy = false; - } - } -#else - (void) file; // quell unused param warnings - (void) line; -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - - // Deallocate - free( addr ); -} - -#ifdef SC_MEMMGR_ENABLE_CHECKS -/** - sc_memmgr_error implementation -*/ -sc_memmgr_error::sc_memmgr_error( const std::string & file, const unsigned int line ) { - _srcfile = file; - _srcline = line; - _occurences = 1; -} - -sc_memmgr_error::sc_memmgr_error( const sc_memmgr_error & rhs ) { - _srcfile = rhs._srcfile; - _srcline = rhs._srcline; - _occurences = rhs._occurences; -} - -sc_memmgr_error::~sc_memmgr_error( void ) { -} - -bool sc_memmgr_error::operator<( const sc_memmgr_error & rhs ) const { - if( _srcfile == rhs._srcfile ) { - return _srcline < rhs._srcline; - } - return _srcfile < rhs._srcfile; -} - -std::string sc_memmgr_error::getsrcfile( void ) const { - return _srcfile; -} - -unsigned int sc_memmgr_error::getsrcline( void ) const { - return _srcline; -} - -unsigned int sc_memmgr_error::getoccurences( void ) const { - return _occurences; -} - -/** - sc_memmgr_record implementation -*/ -sc_memmgr_record::sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ) { - _addr = addr; - _size = size; - _srcfile = file; - _srcline = line; -} - -sc_memmgr_record::sc_memmgr_record( void * addr ) { - _addr = addr; - _size = 0; - _srcfile = ""; - _srcline = -1; -} - -sc_memmgr_record::sc_memmgr_record( const sc_memmgr_record & rhs ) { - _addr = rhs._addr; - _size = rhs._size; - _srcfile = rhs._srcfile; - _srcline = rhs._srcline; -} - -sc_memmgr_record::~sc_memmgr_record( void ) { -} - -bool sc_memmgr_record::operator<( const sc_memmgr_record & rhs ) const { - return _addr < rhs._addr; -} - -void * sc_memmgr_record::getaddr( void ) const { - return _addr; -} - -size_t sc_memmgr_record::getsize( void ) const { - return _size; -} - -std::string sc_memmgr_record::getsrcfile( void ) const { - return _srcfile; -} - -unsigned int sc_memmgr_record::getsrcline( void ) const { - return _srcline; -} - -#endif /* SC_MEMMGR_ENABLE_CHECKS */ diff --git a/src/base/sc_memmgr.h b/src/base/sc_memmgr.h deleted file mode 100644 index 9517a20bc..000000000 --- a/src/base/sc_memmgr.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef SC_MEMMGR_H -#define SC_MEMMGR_H - -#include -#include - -#if defined(SC_MEMMGR_ENABLE_CHECKS) - -#ifdef __cplusplus -#include -extern "C" { -#endif /* __cplusplus */ - - SC_BASE_EXPORT void * sc_malloc_fn( unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ); - SC_BASE_EXPORT void sc_free_fn( void * addr ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#ifdef __cplusplus - -SC_BASE_EXPORT void * sc_operator_new( size_t size, const char * file, const int line ); -SC_BASE_EXPORT void sc_operator_delete( void * addr, const char * file, const int line ); -SC_BASE_EXPORT void sc_operator_delete( void * addr ); - -#endif /* __cplusplus */ - -#ifndef SC_MEMMGR_CC - -#define sc_malloc(size) sc_malloc_fn(size, __FILE__, __LINE__) -#define sc_calloc(count, size) sc_calloc_fn(count, size, __FILE__, __LINE__) -#define sc_realloc(addr, size) sc_realloc_fn(addr, size, __FILE__, __LINE__) -#define sc_free(addr) sc_free_fn(addr) - -#ifdef __cplusplus - -#include - -inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) { - return sc_operator_new( size, file, line ); -} - -inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) { - return sc_operator_new( size, file, line ); -} - -inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) { - sc_operator_delete( addr, file, line ); -} - -inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) { - sc_operator_delete( addr, file, line ); -} - -inline void operator delete( void * addr ) throw () { - sc_operator_delete( addr ); -} - -inline void operator delete[]( void * addr ) throw () { - sc_operator_delete( addr ); -} - -#define new new(__FILE__, __LINE__) - -#endif /* __cplusplus */ - -#endif /* SC_MEMMGR_CC */ - -#else -#define sc_malloc(size) malloc(size) -#define sc_calloc(count, size) calloc(count, size) -#define sc_realloc(addr, size) realloc(addr, size) -#define sc_free(addr) free(addr) -#endif /* SC_MEMMGR_ENABLE_CHECKS */ - -#endif /* SC_MEMMGR_H */ diff --git a/src/base/sc_mkdir.c b/src/base/sc_mkdir.c deleted file mode 100644 index d0866f6e3..000000000 --- a/src/base/sc_mkdir.c +++ /dev/null @@ -1,32 +0,0 @@ -#define _XOPEN_SOURCE /* for S_IFDIR */ -#include "sc_mkdir.h" - -#include -#include -#include -#ifdef _WIN32 -# include -#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; -} diff --git a/src/base/sc_mkdir.h b/src/base/sc_mkdir.h deleted file mode 100644 index 21c8d9c5c..000000000 --- a/src/base/sc_mkdir.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SC_MKDIR -#define SC_MKDIR - -#include - -/** 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 */ diff --git a/src/base/sc_stdio.h b/src/base/sc_stdio.h deleted file mode 100644 index 78fefc53b..000000000 --- a/src/base/sc_stdio.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __SC_STDIO_H -#define __SC_STDIO_H - -/* - * https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 - * (NOTE: MSVC defines va_list as a char*, so this should be safe) - */ -#if defined(_MSC_VER) && _MSC_VER < 1900 - -#include - -static __inline int -c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) { - int count = -1; - - if (sz != 0) - count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap); - if (count == -1) - count = _vscprintf(format, ap); - - return count; -} - -static __inline int -c99_snprintf(char *buffer, size_t sz, const char *format, ...) { - int count; - va_list ap; - - va_start(ap, format); - count = c99_vsnprintf(buffer, sz, format, ap); - va_end(ap); - - return count; -} - -#endif - -#endif /* __SC_STDIO_H */ - diff --git a/src/base/sc_strtoull.h b/src/base/sc_strtoull.h deleted file mode 100644 index b68b76707..000000000 --- a/src/base/sc_strtoull.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SC_STRTOULL_H -#define SC_STRTOULL_H - -#include - -#ifdef _WIN32 -# define strtoull _strtoui64 -# define ULLONG_MAX _UI64_MAX -#endif - -#endif /* SC_STRTOULL_H */ diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 023ce1ab6..b34b5f161 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -29,12 +29,11 @@ SET(SC_CLDAI_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${SC_SOURCE_DIR}/src/base ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/clutils ) -set(_libdeps steputils base) +set(_libdeps steputils) if(BUILD_SHARED_LIBS) SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index 30a9103f4..ec0511500 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -29,7 +29,6 @@ #include #include -#include "sc_memmgr.h" #include "sdaiApplication_instance.h" diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index 678add01c..4d1a9b4c9 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -11,7 +11,6 @@ #include #include -#include "sc_memmgr.h" SDAI_Binary::SDAI_Binary( const char * str, int max ) { content = std::string( str, max ); diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index 2f43ab284..edae7f5b9 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -3,7 +3,6 @@ #include #include -#include "sc_memmgr.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index 22db4e61b..90d37089c 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -3,7 +3,6 @@ //#include #include -#include "sc_memmgr.h" SDAI_Entity_extent::SDAI_Entity_extent( ) : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index e472de06f..1cda8be03 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -27,7 +27,6 @@ #include #include -#include "sc_memmgr.h" /* #include diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index b0336ac2d..e89ddd8dc 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -1,6 +1,5 @@ #include -#include "sc_memmgr.h" /* * NIST STEP Core Class Library diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index abe0386b2..c061d20a7 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -1,6 +1,5 @@ #include -#include "sc_memmgr.h" ///////// SDAI_Model_contents_instances diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index 8f6440e8e..882f4287c 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -24,7 +24,6 @@ * UArray implementation. */ #include -#include "sc_memmgr.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index 14cf6c26a..2ab8352ad 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,5 +1,4 @@ #include -#include "sc_memmgr.h" SDAI_sdaiObject::SDAI_sdaiObject() { } diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 6f48be442..578154428 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,5 +1,4 @@ #include -#include "sc_memmgr.h" SDAI_Session_instance::SDAI_Session_instance() { } diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index 87f29eebd..f640633ee 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -11,7 +11,6 @@ #include #include -#include "sc_memmgr.h" SDAI_String::SDAI_String( const char * str, size_t max ) { if( !str ) { diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 6370bcacb..2e2ec980d 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -21,21 +21,20 @@ SET(SC_CLEDITOR_HDRS 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 ) if(BUILD_SHARED_LIBS) - SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base) + SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static) + SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static) endif() install(FILES ${SC_CLEDITOR_HDRS} diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index b8936d761..b7f536a39 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -34,8 +34,6 @@ // void PushPastString (istream& in, std::string &s, ErrorDescriptor *err) #include -#include "sc_memmgr.h" - /** * \returns The new file name for the class. * \param newName The file name to be set. diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index f67bc3978..b02d84d97 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -17,7 +17,6 @@ #include #include -#include "sc_memmgr.h" extern void HeaderSchemaInit( Registry & reg ); diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index cea95b42f..af08cb2e3 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -13,7 +13,6 @@ extern ofstream * logStream; #include #include #include -#include "sc_memmgr.h" Schema * s_header_section_schema = 0; diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index 3a469c7d3..83996e685 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -5,7 +5,6 @@ // regenerate it. #include -#include "sc_memmgr.h" void HeaderInitSchemasAndEnts( Registry & reg ) { Uniqueness_rule_ptr ur; diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 35099d805..1c9f691ab 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -8,7 +8,6 @@ #include #include #include -#include "sc_memmgr.h" void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index 05790a09c..9515f85ea 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -5,7 +5,6 @@ // regenerate it. #include -#include "sc_memmgr.h" void HeaderSchemaInit( Registry & reg ) { HeaderInitSchemasAndEnts( reg ); diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index 3044790de..0196cede8 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -11,7 +11,6 @@ */ #include -#include "sc_memmgr.h" ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index b5e763628..d9646b74d 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -6,6 +6,7 @@ set( clLazyFile_SRCS p21HeaderSectionReader.cc sectionReader.cc lazyP21DataSectionReader.cc + judy/src/judy.c ) set( SC_CLLAZYFILE_HDRS @@ -17,7 +18,13 @@ set( SC_CLLAZYFILE_HDRS lazyInstMgr.h lazyTypes.h sectionReader.h + sectionReader.h instMgrHelper.h + judy/src/judy.h + judy/src/judyLArray.h + judy/src/judyL2Array.h + judy/src/judySArray.h + judy/src/judyS2Array.h ) include_directories( @@ -26,11 +33,10 @@ include_directories( ${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}/judy/src ) -set(_libdeps stepcore stepdai steputils base stepeditor) +set(_libdeps stepcore stepdai steputils stepeditor) if(BUILD_SHARED_LIBS) SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) @@ -40,11 +46,11 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static) + set(_libdeps stepcore-static stepdai-static steputils-static stepeditor-static) SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) endif() -SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) +SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) install(FILES ${SC_CLLAZYFILE_HDRS} diff --git a/src/cllazyfile/headerSectionReader.h b/src/cllazyfile/headerSectionReader.h index 1e42d0440..bea5582aa 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/src/cllazyfile/headerSectionReader.h @@ -8,7 +8,6 @@ #include "lazyFileReader.h" #include "sectionReader.h" #include "lazyTypes.h" -#include "sc_memmgr.h" #include "sc_export.h" diff --git a/src/base/judy/CMakeLists.txt b/src/cllazyfile/judy/CMakeLists.txt similarity index 100% rename from src/base/judy/CMakeLists.txt rename to src/cllazyfile/judy/CMakeLists.txt diff --git a/src/base/judy/README.md b/src/cllazyfile/judy/README.md similarity index 100% rename from src/base/judy/README.md rename to src/cllazyfile/judy/README.md diff --git a/src/base/judy/misc/astyle.cfg b/src/cllazyfile/judy/misc/astyle.cfg similarity index 100% rename from src/base/judy/misc/astyle.cfg rename to src/cllazyfile/judy/misc/astyle.cfg diff --git a/src/base/judy/misc/hextest.sh b/src/cllazyfile/judy/misc/hextest.sh similarity index 100% rename from src/base/judy/misc/hextest.sh rename to src/cllazyfile/judy/misc/hextest.sh diff --git a/src/base/judy/misc/judy64n.c b/src/cllazyfile/judy/misc/judy64n.c similarity index 100% rename from src/base/judy/misc/judy64n.c rename to src/cllazyfile/judy/misc/judy64n.c diff --git a/src/base/judy/src/judy.c b/src/cllazyfile/judy/src/judy.c similarity index 100% rename from src/base/judy/src/judy.c rename to src/cllazyfile/judy/src/judy.c diff --git a/src/base/judy/src/judy.h b/src/cllazyfile/judy/src/judy.h similarity index 100% rename from src/base/judy/src/judy.h rename to src/cllazyfile/judy/src/judy.h diff --git a/src/base/judy/src/judyL2Array.h b/src/cllazyfile/judy/src/judyL2Array.h similarity index 100% rename from src/base/judy/src/judyL2Array.h rename to src/cllazyfile/judy/src/judyL2Array.h diff --git a/src/base/judy/src/judyLArray.h b/src/cllazyfile/judy/src/judyLArray.h similarity index 100% rename from src/base/judy/src/judyLArray.h rename to src/cllazyfile/judy/src/judyLArray.h diff --git a/src/base/judy/src/judyS2Array.h b/src/cllazyfile/judy/src/judyS2Array.h similarity index 100% rename from src/base/judy/src/judyS2Array.h rename to src/cllazyfile/judy/src/judyS2Array.h diff --git a/src/base/judy/src/judySArray.h b/src/cllazyfile/judy/src/judySArray.h similarity index 100% rename from src/base/judy/src/judySArray.h rename to src/cllazyfile/judy/src/judySArray.h diff --git a/src/base/judy/test/hexSort.c b/src/cllazyfile/judy/test/hexSort.c similarity index 100% rename from src/base/judy/test/hexSort.c rename to src/cllazyfile/judy/test/hexSort.c diff --git a/src/base/judy/test/judyL2test.cc b/src/cllazyfile/judy/test/judyL2test.cc similarity index 100% rename from src/base/judy/test/judyL2test.cc rename to src/cllazyfile/judy/test/judyL2test.cc diff --git a/src/base/judy/test/judyLtest.cc b/src/cllazyfile/judy/test/judyLtest.cc similarity index 100% rename from src/base/judy/test/judyLtest.cc rename to src/cllazyfile/judy/test/judyLtest.cc diff --git a/src/base/judy/test/judyS2test.cc b/src/cllazyfile/judy/test/judyS2test.cc similarity index 100% rename from src/base/judy/test/judyS2test.cc rename to src/cllazyfile/judy/test/judyS2test.cc diff --git a/src/base/judy/test/judyStest.cc b/src/cllazyfile/judy/test/judyStest.cc similarity index 100% rename from src/base/judy/test/judyStest.cc rename to src/cllazyfile/judy/test/judyStest.cc diff --git a/src/base/judy/test/pennySort.c b/src/cllazyfile/judy/test/pennySort.c similarity index 100% rename from src/base/judy/test/pennySort.c rename to src/cllazyfile/judy/test/pennySort.c diff --git a/src/base/judy/test/sort.c b/src/cllazyfile/judy/test/sort.c similarity index 100% rename from src/base/judy/test/sort.c rename to src/cllazyfile/judy/test/sort.c diff --git a/src/base/judy/test/sort.h b/src/cllazyfile/judy/test/sort.h similarity index 100% rename from src/base/judy/test/sort.h rename to src/cllazyfile/judy/test/sort.h diff --git a/src/cllazyfile/lazyDataSectionReader.h b/src/cllazyfile/lazyDataSectionReader.h index f2dc9dee4..41ad62a5c 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/src/cllazyfile/lazyDataSectionReader.h @@ -5,7 +5,6 @@ #include #include "sectionReader.h" #include "lazyTypes.h" -#include "sc_memmgr.h" #include "sc_export.h" diff --git a/src/cllazyfile/lazyFileReader.h b/src/cllazyfile/lazyFileReader.h index 49eea5b50..20c35f73a 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/src/cllazyfile/lazyFileReader.h @@ -16,8 +16,6 @@ * #include "lazyP28DataSectionReader.h" * #include "p28HeaderSectionReader.h" */ -#include "sc_memmgr.h" - class lazyInstMgr; class Registry; class headerSectionReader; diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 78444a756..881031620 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -10,7 +10,6 @@ #include "lazyTypes.h" #include "Registry.h" -#include "sc_memmgr.h" #include "sc_export.h" #include "judyLArray.h" diff --git a/src/cllazyfile/lazyP21DataSectionReader.h b/src/cllazyfile/lazyP21DataSectionReader.h index 423679142..0602b421a 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.h +++ b/src/cllazyfile/lazyP21DataSectionReader.h @@ -3,7 +3,6 @@ #include "lazyDataSectionReader.h" #include "lazyFileReader.h" -#include "sc_memmgr.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index c41003e9b..10aebaa1e 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,7 +1,6 @@ #include "lazyInstMgr.h" -#include +#include "./sc_benchmark.h" #include "SdaiSchemaInit.h" -#include "sc_memmgr.h" #include "config.h" #ifndef NO_REGISTRY diff --git a/src/cllazyfile/p21HeaderSectionReader.h b/src/cllazyfile/p21HeaderSectionReader.h index b5ce04948..01452ea06 100644 --- a/src/cllazyfile/p21HeaderSectionReader.h +++ b/src/cllazyfile/p21HeaderSectionReader.h @@ -2,7 +2,6 @@ #define P21HEADERSECTIONREADER_H #include "headerSectionReader.h" -#include "sc_memmgr.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { diff --git a/src/base/sc_benchmark.cc b/src/cllazyfile/sc_benchmark.cc similarity index 99% rename from src/base/sc_benchmark.cc rename to src/cllazyfile/sc_benchmark.cc index 44f085f2f..2f00cd5a4 100644 --- a/src/base/sc_benchmark.cc +++ b/src/cllazyfile/sc_benchmark.cc @@ -1,7 +1,6 @@ /// \file sc_benchmark.cc memory info, timers, etc for benchmarking -#include "sc_benchmark.h" -#include "sc_memmgr.h" +#include "./sc_benchmark.h" #ifdef _WIN32 #include diff --git a/src/base/sc_benchmark.h b/src/cllazyfile/sc_benchmark.h similarity index 93% rename from src/base/sc_benchmark.h rename to src/cllazyfile/sc_benchmark.h index 8512bd892..5b77317c4 100644 --- a/src/base/sc_benchmark.h +++ b/src/cllazyfile/sc_benchmark.h @@ -2,14 +2,11 @@ #define SC_BENCHMARK_H /// \file sc_benchmark.h memory info, timers, etc for benchmarking -#include "sc_export.h" - #ifdef __cplusplus #include #include #include -#include "sc_memmgr.h" extern "C" { #endif @@ -23,7 +20,7 @@ extern "C" { * * not yet implemented for OSX or Windows. */ - SC_BASE_EXPORT benchVals getMemAndTime( ); + benchVals getMemAndTime( ); #ifdef __cplusplus } @@ -39,7 +36,7 @@ extern "C" { * depends on getMemAndTime() above - may not work on all platforms. */ -class SC_BASE_EXPORT benchmark { +class benchmark { protected: benchVals initialVals, laterVals; #ifdef _MSC_VER diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index fe3bd4b2a..445ef6502 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -5,9 +5,14 @@ #include #include #include +#include + +#ifdef _WIN32 +# define strtoull _strtoui64 +# define ULLONG_MAX _UI64_MAX +#endif #include "Registry.h" -#include "sc_strtoull.h" #include "sdaiApplication_instance.h" #include "read_func.h" #include "SdaiSchemaInit.h" diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index 88c5e1ceb..b2b7f726a 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -4,7 +4,6 @@ #include #include #include "lazyTypes.h" -#include "sc_memmgr.h" #include "sc_export.h" #include "errordesc.h" #include "STEPcomplex.h" diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 910235973..67132ee45 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -125,13 +125,12 @@ set(SC_CLSTEPCORE_HDRS 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 ) -set(_libdeps steputils stepdai base) +set(_libdeps steputils stepdai) if(BUILD_SHARED_LIBS) SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index b9b9f6103..851e9e3bf 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -11,7 +11,6 @@ #include #include -#include "sc_memmgr.h" /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 960a7866c..2226d1713 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -17,7 +17,6 @@ #include #include #include -#include "sc_memmgr.h" /** diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index dcfeb2486..83d21fe3b 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -19,7 +19,6 @@ #include #include #include -#include "sc_memmgr.h" // REAL_NUM_PRECISION is defined in STEPattribute.h, and is also used // in aggregate real handling (STEPaggregate.cc) -- IMS 6 Jun 95 diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 7774321b2..721175e90 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -12,7 +12,6 @@ #include #include -#include "sc_memmgr.h" AttrListNode::AttrListNode( STEPattribute * a ) { attr = a; diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 1178a7ca3..13d67267e 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -6,7 +6,6 @@ #include #include #include -#include "sc_memmgr.h" extern const char * ReadStdKeyword( istream & in, std::string & buf, int skipInitWS ); diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index 52bdf1ee5..991a7d98c 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -5,7 +5,6 @@ #include #include -#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 ) {} diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index 6ca378099..e2dd94f00 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -13,7 +13,6 @@ #include // to get the BUFSIZ #define #include #include -#include "sc_memmgr.h" /** \class SCLundefined ** helper functions for reading unknown types diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index 890e423b8..d46cc062e 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -11,7 +11,6 @@ */ #include -#include "sc_memmgr.h" #include diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index b6abef73c..6f5ae75dc 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Inserts a new ComplexList to our list. The ComplexLists are ordered by diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index 2fc289381..92dfecb1f 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Destructor for ComplexList. diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 2590e034c..3756143bc 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -18,7 +18,6 @@ #include #include -#include "sc_memmgr.h" // define this to be the name of the display object class StepEntityEditor; diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index f4d00a6aa..66761e3a3 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -19,7 +19,6 @@ #include #include #include -#include "sc_memmgr.h" void DisplayNodeList::Remove( GenericNode * node ) { GenNodeList::Remove( node ); diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index 0dd35803a..8b4cf98f0 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -14,7 +14,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Returns the number of EntLists in this's list (EntList->next, next->next diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 792489e4b..81c05a6eb 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Given a list of entity names, creates a sorted linked list of EntNodes diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 0f74b27c0..691167f6d 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -18,7 +18,6 @@ #include #include -#include "sc_memmgr.h" /////////////////////////////////////////////////////////////////////////////// // debug_level >= 2 => tells when a command is chosen diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index 5f17f7d93..915c95620 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -14,7 +14,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Loops through descendants of this, invoking their matchOR functions. diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 8e44443ee..00caf283e 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -22,7 +22,6 @@ #include #include -#include "sc_memmgr.h" void * MgrNode::SEE() { return ( di ? di->SEE() : 0 ); diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 23069f02b..304738b88 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -37,7 +37,6 @@ static int PrintFunctionTrace = 2; #include #include // to get bcopy() - ANSI -#include "sc_memmgr.h" ////////////////////////////////////////////////////////////////////////////// // class MgrNodeArray member functions diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index 9bff8e254..a52870f56 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -16,7 +16,6 @@ #include #include #include -#include "sc_memmgr.h" MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { // if(debug_level >= PrintFunctionTrace) diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index 959720ed0..f82dba642 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -14,7 +14,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Deletes the childList of this, before this is deleted. diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index eea46ddb5..d71c8f28c 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -1,5 +1,4 @@ #include -#include "sc_memmgr.h" /////////////////////////////////////////////////////////////////////////////// // Function defined as a stub (necessary to use the scl) diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index 14607f606..addc49522 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Checks if we match the nodes of ents. If only one unmarked is left diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index b820bea53..c829e4ae6 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" /** * Check if we matched nm. We have two possibilities here: If we have a diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index 2139d1f61..bd7ad8b7b 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -8,7 +8,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" // Local function prototypes: static char * joinText( JoinType, char * ); diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index a0c47dc2a..a1715d736 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -5,7 +5,6 @@ #include #include #include "Str.h" -#include "sc_memmgr.h" const int RealNumPrecision = REAL_NUM_PRECISION; diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index 731a381f5..ee1631e74 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -2,7 +2,6 @@ #include #include -#include "sc_memmgr.h" const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; diff --git a/src/clstepcore/test/CMakeLists.txt b/src/clstepcore/test/CMakeLists.txt index f9f353e26..ea37cb0cd 100644 --- a/src/clstepcore/test/CMakeLists.txt +++ b/src/clstepcore/test/CMakeLists.txt @@ -3,7 +3,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12) 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 ) @@ -21,10 +20,10 @@ function(add_stepcore_test name libs) 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("operators_SDAI_Select" "stepcore;steputils;stepeditor;stepdai;base") -add_stepcore_test("null_attr" "stepcore;steputils;stepeditor;stepdai;base") +add_stepcore_test("SupertypesIterator" "stepcore;steputils;stepeditor;stepdai") #all these libs are necessary? +add_stepcore_test("operators_STEPattribute" "stepcore;steputils;stepeditor;stepdai") +add_stepcore_test("operators_SDAI_Select" "stepcore;steputils;stepeditor;stepdai") +add_stepcore_test("null_attr" "stepcore;steputils;stepeditor;stepdai") # Local Variables: # tab-width: 8 diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 145af7699..3554cd378 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include "sc_memmgr.h" // Local function prototypes: static EntList * firstCandidate( EntList * ); diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 514980ad9..427ecb43d 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -20,13 +20,12 @@ set(SC_CLUTILS_HDRS ) include_directories( - ${SC_SOURCE_DIR}/src/base ${SC_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} ) if(BUILD_SHARED_LIBS) - SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base) + SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS}) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) target_link_libraries(steputils shlwapi) @@ -34,7 +33,7 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS} LINK_LIBRARIES base-static) + SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS}) if(WIN32) target_link_libraries(steputils-static shlwapi) endif() diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 657a9ab5c..37110948f 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -58,8 +58,6 @@ #include #endif -#include - /////////////////////////////////////////////////////////////////////////////// // // Create a new DirObj object. diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index c5a998c8c..46d6c820d 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -12,7 +12,6 @@ #include #include -#include DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; ostream * ErrorDescriptor::_out = 0; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index 3036ab19d..44a2b0aa6 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -14,7 +14,6 @@ #include #include -#include ////////////////////////////////////////////////////////////////////////////// // class GenericNode inline functions that depend on other classes diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index 0111794fb..801742293 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -16,7 +16,6 @@ #include #include #include -#include #ifndef HAVE_MEMMOVE extern "C" { diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index 9560a72b1..f333d6585 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -16,7 +16,6 @@ #include //#include #include -#include // inserts after existNode void GenNodeList::InsertAfter( GenericNode * newNode, diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index 1839b6707..5b754c769 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -9,7 +9,6 @@ #include #include #include -#include /* constants */ #define HASH_NULL (Hash_TableP)NULL diff --git a/src/exp2cxx/CMakeLists.txt b/src/exp2cxx/CMakeLists.txt index 93cf8c911..6ccebb17a 100644 --- a/src/exp2cxx/CMakeLists.txt +++ b/src/exp2cxx/CMakeLists.txt @@ -5,6 +5,7 @@ set(FEDEX_COMMON_SRCS set(exp2cxx_SOURCES ${FEDEX_COMMON_SRCS} + trace_fprintf.c fedex_main.c classes_wrapper.cc classes.c @@ -31,13 +32,13 @@ set(exp2cxx_SOURCES ) include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} ${SC_SOURCE_DIR}/include ${SC_SOURCE_DIR}/include/exppp ${SC_SOURCE_DIR}/include/express - ${SC_SOURCE_DIR}/src/base ) -SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express base) +SC_ADDEXEC(exp2cxx SOURCES ${exp2cxx_SOURCES} LINK_LIBRARIES libexppp express) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/exp2cxx/classes.c b/src/exp2cxx/classes.c index 26e39a909..40dcf46c2 100644 --- a/src/exp2cxx/classes.c +++ b/src/exp2cxx/classes.c @@ -25,14 +25,12 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ -#include #include #include -#include #include "classes.h" #include -#include +#include "./trace_fprintf.h" int multiple_inheritance = 1; int print_logging = 0; @@ -96,7 +94,7 @@ void format_for_std_stringout( FILE * f, char * orig_buf ) { optr++; } fprintf( f, "%s", s_end ); - sc_free( orig_buf ); + free( orig_buf ); } void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ) { diff --git a/src/exp2cxx/classes_attribute.c b/src/exp2cxx/classes_attribute.c index 95dd8e861..cf2de189d 100644 --- a/src/exp2cxx/classes_attribute.c +++ b/src/exp2cxx/classes_attribute.c @@ -10,22 +10,15 @@ The conventions used in this binding follow the proposed specification for the STEP Standard Data Access Interface as defined in document N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. *******************************************************************/ -#include #include #include #include -#include #include #include #include "classes.h" #include "classes_attribute.h" -#include - -#if defined(_MSC_VER) && _MSC_VER < 1900 -# include "sc_stdio.h" -# define snprintf c99_snprintf -#endif +#include "./trace_fprintf.h" extern int old_accessors; extern int print_logging; @@ -64,7 +57,7 @@ char * generate_attribute_name( Variable a, char * out ) { } } *q = '\0'; - sc_free( temp ); + free( temp ); return out; } diff --git a/src/exp2cxx/classes_entity.c b/src/exp2cxx/classes_entity.c index 0bd8feaf4..39e69c8a1 100644 --- a/src/exp2cxx/classes_entity.c +++ b/src/exp2cxx/classes_entity.c @@ -14,11 +14,16 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ -#include +#define _XOPEN_SOURCE /* for S_IFDIR */ +#include +#include +#include +#ifdef _WIN32 +# include +#endif /* _WIN32 */ #include #include #include -#include #include "classes.h" #include "classes_entity.h" #include "class_strings.h" @@ -26,11 +31,34 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #include #include "rules.h" -#include +#include "./trace_fprintf.h" extern int multiple_inheritance; extern int old_accessors; +/* cross-platform mkdir */ +static 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 */ +static 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; +} + /* attribute numbering used to use a global variable attr_count. * it could be tricky keep the numbering consistent when making * changes, so this has been replaced with an added member in the @@ -676,7 +704,7 @@ char * generate_dict_attr_name( Variable a, char * out ) { } *q = '\0'; - sc_free( temp ); + free( temp ); return out; } @@ -864,15 +892,15 @@ void ENTITYincode_print( Entity entity, FILE * header, FILE * impl, Schema schem if( VARis_derived( v ) && v->initializer ) { tmp = EXPRto_string( v->initializer ); - tmp2 = ( char * )sc_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); + tmp2 = ( char * )malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); fprintf( impl, " %s::%s%d%s%s->initializer_(\"%s\");\n", schema_name, ATTR_PREFIX, v->idx, ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, format_for_stringout( tmp, tmp2 ) ); - sc_free( tmp ); - sc_free( tmp2 ); + free( tmp ); + free( tmp2 ); } if( VARget_inverse( v ) ) { fprintf( impl, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", @@ -957,7 +985,6 @@ void ENTITYPrint_cc( const Entity entity, FILE * createall, FILE * header, FILE DEBUG( "Entering ENTITYPrint_cc for %s\n", name ); fprintf( impl, "#include \"schema.h\"\n" ); - fprintf( impl, "#include \"sc_memmgr.h\"\n" ); fprintf( impl, "#include \"entity/%s.h\"\n\n", name ); LIBdescribe_entity( entity, impl, schema ); diff --git a/src/exp2cxx/classes_misc.c b/src/exp2cxx/classes_misc.c index 8399826c5..9db5e7eb7 100644 --- a/src/exp2cxx/classes_misc.c +++ b/src/exp2cxx/classes_misc.c @@ -1,9 +1,7 @@ #define CLASSES_MISC_C -#include #include #include "classes.h" -#include #include "class_strings.h" /** \file classes_misc.c @@ -322,7 +320,7 @@ Entity ENTITYput_superclass( Entity entity ) { LISTod; } - tag = ( EntityTag ) sc_malloc( sizeof( struct EntityTag_ ) ); + tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); return super; @@ -386,10 +384,10 @@ Variable VARis_type_shifter( Variable a ) { temp = EXPRto_string( VARget_name( a ) ); if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - sc_free( temp ); + free( temp ); return a; } - sc_free( temp ); + free( temp ); return 0; } diff --git a/src/exp2cxx/classes_type.c b/src/exp2cxx/classes_type.c index 5ac968207..bce1d34fb 100644 --- a/src/exp2cxx/classes_type.c +++ b/src/exp2cxx/classes_type.c @@ -14,18 +14,24 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ -#include -#include +#define _XOPEN_SOURCE /* for S_IFDIR */ +#include +#include +#include +#ifdef _WIN32 +# include +#endif /* _WIN32 */ + #include +#include #include -#include #include "classes.h" #include "class_strings.h" #include "genCxxFilenames.h" #include #include "rules.h" -#include +#include "./trace_fprintf.h" static int type_count; /**< number each temporary type for same reason as \sa attr_count */ @@ -43,6 +49,59 @@ int isMultiDimAggregateType( const Type t ); void Type_Description( const Type, char * ); void TypeBody_Description( TypeBody body, char * buf ); +/* cross-platform mkdir */ +static 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 */ +static 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; +} + +#ifdef _WIN32 +/* for windows, rewrite backslashes in paths + * that will be written to generated code + */ +static const char * path2str_fn( const char * fileMacro ) { + static char * result = 0; + static size_t rlen = 0; + char * p; + if( rlen < strlen( fileMacro ) ) { + if( result ) { + free( result ); + } + rlen = strlen( fileMacro ); + result = ( char * )malloc( rlen * sizeof( char ) + 1 ); + } + strcpy( result, fileMacro ); + p = result; + while( *p ) { + if( *p == '\\' ) { + *p = '/'; + } + p++; + } + return result; +} +# define path2str(path) path2str_fn(path) +#else +# define path2str(path) path +#endif + /** write representation of expression to end of buf * * TODO: add buflen arg and check for overflow @@ -317,7 +376,6 @@ void TYPEPrint_cc( const Type type, const filenames_t * names, FILE * hdr, FILE DEBUG( "Entering TYPEPrint_cc for %s\n", names->impl ); fprintf( impl, "#include \"schema.h\"\n" ); - fprintf( impl, "#include \"sc_memmgr.h\"\n" ); fprintf( impl, "#include \"%s\"\n\n", names->header ); if ( TYPEis_enumeration( type ) ) { @@ -634,7 +692,7 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema, bool needWR ) char * temp; temp = non_unique_types_string( type ); fprintf( create, " %s = new SelectTypeDescriptor (\n ~%s, //unique elements,\n", TYPEtd_name( type ), temp ); - sc_free( temp ); + free( temp ); TYPEprint_nm_ft_desc( schema, type, create, "," ); fprintf( create, " (SelectCreator) create_%s); // Creator function\n", SelectName( TYPEget_name( type ) ) ); } else { @@ -1271,7 +1329,7 @@ char * TYPEget_express_type( const Type t ) { /* this will declare extra memory when aggregate is > 1D */ - permval = ( char * )sc_malloc( strlen( retval ) * sizeof( char ) + 1 ); + permval = ( char * )malloc( strlen( retval ) * sizeof( char ) + 1 ); strcpy( permval, retval ); return permval; @@ -1290,7 +1348,7 @@ void AGGRprint_bound( FILE * header, FILE * impl, const char * var_name, const c if( bound->type == Type_Funcall ) { char *bound_str = EXPRto_string(bound); fprintf( impl, " %s->SetBound%dFromExpressFuncall( \"%s\" );\n", var_name, boundNr, bound_str ); - sc_free(bound_str); + free(bound_str); } else { fprintf( impl, " %s->SetBound%d( %d );\n", var_name, boundNr, bound->u.integer ); } diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 180067b1e..3d9151178 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -4,9 +4,8 @@ #include "complexSupport.h" #include "class_strings.h" -#include -#include +#include "./trace_fprintf.h" /******************************************************************* ** FedEx parser output module for generating C++ class definitions @@ -91,7 +90,6 @@ void print_file_header( FILES * files ) { files -> initall = FILEcreate( "schema.cc" ); fprintf( files->initall, "\n// in the exp2cxx source code, this file is generally referred to as files->initall or schemainit\n" ); fprintf( files->initall, "#include \"schema.h\"\n" ); - fprintf( files->initall, "#include \"sc_memmgr.h\"\n" ); fprintf( files->initall, "class Registry;\n" ); fprintf( files->initall, "\nvoid SchemaInit (Registry & reg) {\n" ); @@ -105,7 +103,6 @@ void print_file_header( FILES * files ) { files -> create = FILEcreate( "SdaiAll.cc" ); fprintf( files->create, "\n// in the exp2cxx source code, this file is generally referred to as files->create or createall\n" ); fprintf( files->create, "#include \"schema.h\"\n" ); - fprintf( files->create, "#include \"sc_memmgr.h\"\n" ); fprintf( files->create, "\nvoid InitSchemasAndEnts (Registry & reg) {\n" ); // This file declares all entity classes as incomplete types. This will @@ -424,7 +421,6 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); fprintf( incfile, "#include \"schema.h\"\n" ); - fprintf( incfile, "#include \"sc_memmgr.h\"\n" ); np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ @@ -445,7 +441,6 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) #else fprintf( libfile, "#include \"schema.h\"\n" ); #endif - fprintf( libfile, "#include \"sc_memmgr.h\"\n" ); fprintf( libfile, "\n#ifdef SC_LOGGING \n" @@ -500,7 +495,6 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) "#endif\n" ); #endif fprintf( initfile, "#include \n#include \n" ); - fprintf( initfile, "#include \n" ); fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); diff --git a/src/exp2cxx/collect.cc b/src/exp2cxx/collect.cc index d12db7346..a50b808be 100644 --- a/src/exp2cxx/collect.cc +++ b/src/exp2cxx/collect.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include void ComplexCollect::insert( ComplexList * c ) /* diff --git a/src/exp2cxx/complexlist.cc b/src/exp2cxx/complexlist.cc index 2a42c6d96..485f0609d 100644 --- a/src/exp2cxx/complexlist.cc +++ b/src/exp2cxx/complexlist.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include ComplexList::~ComplexList() /* diff --git a/src/exp2cxx/entlist.cc b/src/exp2cxx/entlist.cc index e27114294..bd45be671 100644 --- a/src/exp2cxx/entlist.cc +++ b/src/exp2cxx/entlist.cc @@ -14,7 +14,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include int EntList::siblings() /* diff --git a/src/exp2cxx/entnode.cc b/src/exp2cxx/entnode.cc index 50f3a8659..569dcde87 100644 --- a/src/exp2cxx/entnode.cc +++ b/src/exp2cxx/entnode.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include EntNode::EntNode( char * namelist[] ) /* diff --git a/src/exp2cxx/expressbuild.cc b/src/exp2cxx/expressbuild.cc index 42458c31a..d55465eef 100644 --- a/src/exp2cxx/expressbuild.cc +++ b/src/exp2cxx/expressbuild.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include // Local function prototypes: static void initEnts( Express ); diff --git a/src/exp2cxx/fedex_main.c b/src/exp2cxx/fedex_main.c index 81c6f1515..b83976daf 100644 --- a/src/exp2cxx/fedex_main.c +++ b/src/exp2cxx/fedex_main.c @@ -72,13 +72,12 @@ * Added * to typedefs. Replaced warning kludges with ERRORoption. */ -#include #include #include #include "../express/express.h" #include "../express/resolve.h" -#include +#include "./trace_fprintf.h" extern void print_fedex_version( void ); diff --git a/src/exp2cxx/genCxxFilenames.c b/src/exp2cxx/genCxxFilenames.c index 3b90d1cf2..14bee4295 100644 --- a/src/exp2cxx/genCxxFilenames.c +++ b/src/exp2cxx/genCxxFilenames.c @@ -1,11 +1,6 @@ #include "genCxxFilenames.h" #include "class_strings.h" -#if defined(_MSC_VER) && _MSC_VER < 1900 -# include "sc_stdio.h" -# define snprintf c99_snprintf -#endif - /** \file genCxxFilenames.c * functions shared by exp2cxx and the schema scanner. * The latter creates, at configuration time, a list diff --git a/src/exp2cxx/match-ors.cc b/src/exp2cxx/match-ors.cc index 1b86622e4..41d5af88c 100644 --- a/src/exp2cxx/match-ors.cc +++ b/src/exp2cxx/match-ors.cc @@ -14,7 +14,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include MatchType AndOrList::matchORs( EntNode * ents ) /* diff --git a/src/exp2cxx/multlist.cc b/src/exp2cxx/multlist.cc index fb74cf5d1..5d2cade84 100644 --- a/src/exp2cxx/multlist.cc +++ b/src/exp2cxx/multlist.cc @@ -13,7 +13,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include MultList::~MultList() /* diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 5028c8246..fbba2b271 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -31,11 +31,10 @@ * Date: 04/09/97 * *****************************************************************************/ -#include #include #include "classes.h" -#include +#include "./trace_fprintf.h" int isAggregateType( const Type t ); @@ -189,7 +188,7 @@ static void initializeMarks( Express express ) DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { schema->search_id = UNPROCESSED; - schema->clientData = ( int * )sc_malloc( sizeof( int ) ); + schema->clientData = ( int * )malloc( sizeof( int ) ); *( int * )schema->clientData = 0; SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; @@ -207,7 +206,7 @@ static void cleanupMarks( Express express ) { DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA ); while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) { if( schema->clientData ) { - sc_free( schema->clientData ); + free( schema->clientData ); schema->clientData = NULL; } } diff --git a/src/exp2cxx/non-ors.cc b/src/exp2cxx/non-ors.cc index 2ef5dd803..6b05bb378 100644 --- a/src/exp2cxx/non-ors.cc +++ b/src/exp2cxx/non-ors.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include MatchType SimpleList::matchNonORs( EntNode * ents ) /* diff --git a/src/exp2cxx/orlist.cc b/src/exp2cxx/orlist.cc index dd0c9db88..809804320 100644 --- a/src/exp2cxx/orlist.cc +++ b/src/exp2cxx/orlist.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include int OrList::hit( const char * nm ) /* diff --git a/src/exp2cxx/print.cc b/src/exp2cxx/print.cc index 0b1398a6d..b338c5954 100644 --- a/src/exp2cxx/print.cc +++ b/src/exp2cxx/print.cc @@ -8,7 +8,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include // Local function prototypes: static char * joinText( JoinType, char * ); diff --git a/src/exp2cxx/selects.c b/src/exp2cxx/selects.c index 6377c8e80..5d975cdde 100644 --- a/src/exp2cxx/selects.c +++ b/src/exp2cxx/selects.c @@ -16,13 +16,12 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. extern int multiple_inheritance; -#include #include #include "classes.h" #include "classes_type.h" #include "classes_attribute.h" -#include +#include "./trace_fprintf.h" #define BASE_SELECT "SDAI_Select" @@ -397,7 +396,7 @@ char * non_unique_types_string( const Type type ) { non_unique_types_vector( type, tvec ); /* build type string from vector */ - typestr = ( char * )sc_malloc( BUFSIZ + 1 ); + typestr = ( char * )malloc( BUFSIZ + 1 ); typestr[0] = '\0'; strcat( typestr, ( char * )"(" ); for( i = 0; i <= tnumber; i++ ) { @@ -1866,7 +1865,7 @@ void TYPEselect_print( Type t, FILES * files, Schema schema ) { } /* mark the type as being processed */ - tag = ( SelectTag ) sc_malloc( sizeof( struct SelectTag_ ) ); + tag = ( SelectTag ) malloc( sizeof( struct SelectTag_ ) ); tag -> started = 1; tag -> complete = 0; TYPEput_clientData( t, ( ClientData ) tag ); @@ -1938,7 +1937,7 @@ void TYPEselect_print( Type t, FILES * files, Schema schema ) { DAR - moved to TYPEprint_init() - to keep init info together. */ tag -> complete = 1; - sc_free( tag ); + free( tag ); } #undef BASE_SELECT diff --git a/src/base/sc_trace_fprintf.c b/src/exp2cxx/trace_fprintf.c similarity index 92% rename from src/base/sc_trace_fprintf.c rename to src/exp2cxx/trace_fprintf.c index 95ca6b9c6..3a3838d67 100644 --- a/src/base/sc_trace_fprintf.c +++ b/src/exp2cxx/trace_fprintf.c @@ -1,8 +1,7 @@ - #include #include -#include "sc_trace_fprintf.h" +#include "trace_fprintf.h" void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) { va_list args; diff --git a/src/base/sc_trace_fprintf.h b/src/exp2cxx/trace_fprintf.h similarity index 85% rename from src/base/sc_trace_fprintf.h rename to src/exp2cxx/trace_fprintf.h index b7aa05fa2..9e5c2f073 100644 --- a/src/base/sc_trace_fprintf.h +++ b/src/exp2cxx/trace_fprintf.h @@ -1,7 +1,7 @@ #ifndef SC_TRACE_FPRINTF_H #define SC_TRACE_FPRINTF_H -/** \file sc_trace_fprintf.h +/** \file trace_fprintf.h * Used to track the source file and line where generated code is printed from * When enabled, comments are printed into the generated files for every 'fprintf': * / * source: scl/src/exp2cxx/selects.c:1375 * / @@ -20,7 +20,7 @@ extern "C" { /** Used to find where generated c++ originates from in exp2cxx. * To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON' */ - SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ); + void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ); #ifdef __cplusplus } #endif diff --git a/src/exp2cxx/trynext.cc b/src/exp2cxx/trynext.cc index 97cacc8a3..e2c0a0edf 100644 --- a/src/exp2cxx/trynext.cc +++ b/src/exp2cxx/trynext.cc @@ -12,7 +12,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include // Local function prototypes: static EntList * firstCandidate( EntList * ); diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 964aca652..d864b3476 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -11,7 +11,6 @@ *****************************************************************************/ #include "complexSupport.h" -#include // Local function prototypes: static void writeheader( ostream &, int ); @@ -117,7 +116,7 @@ static void writeheader( ostream & os, int noLists ) << " * file, however, there are no complex entities, so this\n" << " * function is a stub.\n" << " */" << endl << endl; - os << "#include \"complexSupport.h\"\n#include \"sc_memmgr.h\"\n\n"; + os << "#include \"complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << "{" << endl; return; @@ -129,7 +128,7 @@ static void writeheader( ostream & os, int noLists ) << " * support structures. The structures will be used in the SCL to\n" << " * validate user requests to instantiate complex entities.\n" << " */" << endl << endl; - os << "#include \"complexSupport.h\"\n#include \"sc_memmgr.h\"\n\n"; + os << "#include \"complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << " /*" << endl << " * This function contains instantiation statements for all the\n" diff --git a/src/exp2python/CMakeLists.txt b/src/exp2python/CMakeLists.txt index a9feb39d2..60ced2d77 100644 --- a/src/exp2python/CMakeLists.txt +++ b/src/exp2python/CMakeLists.txt @@ -3,7 +3,6 @@ if(SC_PYTHON_GENERATOR) include_directories( ${SC_SOURCE_DIR}/include ${SC_SOURCE_DIR}/include/express - ${SC_SOURCE_DIR}/src/base ) add_definitions(-DHAVE_CONFIG_H) @@ -29,7 +28,7 @@ if(SC_PYTHON_GENERATOR) ../exp2cxx/write.cc ../exp2cxx/print.cc ) - SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express base) + SC_ADDEXEC(exp2python SOURCES ${exp2python_SOURCES} LINK_LIBRARIES express) endif(SC_PYTHON_GENERATOR) diff --git a/src/exp2python/src/classes_python.c b/src/exp2python/src/classes_python.c index b844985e3..109efecda 100644 --- a/src/exp2python/src/classes_python.c +++ b/src/exp2python/src/classes_python.c @@ -27,7 +27,6 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #include #include -#include "sc_memmgr.h" #include "classes.h" #include "expr.h" @@ -44,11 +43,6 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. #define PAD 1 #define NOPAD 0 -#if defined(_MSC_VER) && _MSC_VER < 1900 -# include "sc_stdio.h" -# define snprintf c99_snprintf -#endif - int isAggregateType( const Type t ); int isAggregate( Variable a ); Variable VARis_type_shifter( Variable a ); @@ -368,7 +362,7 @@ char* EXPRto_python( Expression e ) { char * temp; unsigned int bufsize = BIGBUFSIZ; - buf = ( char * )sc_malloc( bufsize ); + buf = ( char * )malloc( bufsize ); if( !buf ) { fprintf( stderr, "%s failed to allocate buffer: %s\n", __func__, strerror( errno ) ); abort(); @@ -465,7 +459,7 @@ char* EXPRto_python( Expression e ) { abort(); } - temp = ( char * )sc_realloc( buf, 1 + strlen(buf) ); + temp = ( char * )realloc( buf, 1 + strlen(buf) ); if( temp == 0 ) { fprintf( stderr, "%s failed to realloc buffer: %s\n", __func__, strerror( errno ) ); abort(); diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 0d1fb9649..0eada170b 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -26,12 +26,11 @@ SET(EXPPP_SOURCES include_directories( ${SC_SOURCE_DIR}/include ${SC_SOURCE_DIR}/include/exppp - ${SC_SOURCE_DIR}/src/base ${SC_SOURCE_DIR}/src/express ) if(BUILD_SHARED_LIBS) - SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express base) + SC_ADDLIB(libexppp SHARED SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express) set_target_properties(libexppp PROPERTIES PREFIX "") if(WIN32) target_compile_definitions(libexppp PRIVATE SC_EXPPP_DLL_EXPORTS) @@ -39,11 +38,11 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static base-static) + SC_ADDLIB(libexppp-static STATIC SOURCES ${LIBEXPPP_SOURCES} LINK_LIBRARIES express-static) set_target_properties(libexppp-static PROPERTIES PREFIX "") endif() -SC_ADDEXEC(exppp SOURCES ${EXPPP_SOURCES} LINK_LIBRARIES libexppp express base) +SC_ADDEXEC(exppp SOURCES ${EXPPP_SOURCES} LINK_LIBRARIES libexppp express) if(SC_ENABLE_TESTING) add_subdirectory(test) diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index 70ba63d7f..ff929e57d 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -13,12 +12,6 @@ #include "pp.h" #include "exppp.h" - -#if defined(_MSC_VER) && _MSC_VER < 1900 -# include "sc_stdio.h" -# define snprintf c99_snprintf -#endif - /* PP_SMALL_BUF_SZ is a macro used in a few places where const int causes * "warning: ISO C90 forbids variable length array 'buf' [-Wvla]" * @@ -435,7 +428,7 @@ int prep_string() { } string_func_in_use = true; - exppp_buf = exppp_bufp = ( char * )sc_malloc( BIGBUFSIZ + 1 ); + exppp_buf = exppp_bufp = ( char * )malloc( BIGBUFSIZ + 1 ); if( !exppp_buf ) { fprintf( stderr, "failed to allocate exppp buffer\n" ); return 1; @@ -453,7 +446,7 @@ int prep_string() { } char * finish_string() { - char * b = ( char * )sc_realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); + char * b = ( char * )realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); if( b == 0 ) { fprintf( stderr, "failed to reallocate exppp buffer\n" ); diff --git a/src/exppp/pretty_subtype.c b/src/exppp/pretty_subtype.c index d47298e49..f21d6c620 100644 --- a/src/exppp/pretty_subtype.c +++ b/src/exppp/pretty_subtype.c @@ -2,8 +2,6 @@ * split out of exppp.c 9/21/13 */ -#include - #include "exppp.h" #include "pp.h" diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index b5fda9301..678d2b87a 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -5,7 +5,6 @@ #include #include -#include #include "exppp.h" #include "pp.h" @@ -151,7 +150,7 @@ void TYPE_body_out( Type t, int level ) { while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { count++; } - names = ( char ** )sc_calloc( count, sizeof( char * ) ); + names = ( char ** )calloc( count, sizeof( char * ) ); DICTdo_type_init( t->symbol_table, &de, OBJ_EXPRESSION ); while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { names[expr->u.integer - 1] = expr->symbol.name; @@ -175,7 +174,7 @@ void TYPE_body_out( Type t, int level ) { raw( names[i] ); } raw( " )" ); - sc_free( ( char * )names ); + free( ( char * )names ); } break; case select_: diff --git a/src/exppp/test/CMakeLists.txt b/src/exppp/test/CMakeLists.txt index 0d911e590..e13a480e0 100644 --- a/src/exppp/test/CMakeLists.txt +++ b/src/exppp/test/CMakeLists.txt @@ -14,7 +14,7 @@ add_test(NAME build_exppp ) # this executable doesn't really check the results, just ensures no segfaults. ought to improve it... -SC_ADDEXEC(tst_breakLongStr SOURCES ${breakLongStr_SRCS} LINK_LIBRARIES express base TESTABLE) +SC_ADDEXEC(tst_breakLongStr SOURCES ${breakLongStr_SRCS} LINK_LIBRARIES express TESTABLE) add_test(NAME build_tst_breakLongStr WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 2a3aa4299..ae4e97bd0 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -1,7 +1,6 @@ include_directories( ${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} - ${SC_SOURCE_DIR}/src/base ) # Depending on whether we're using pre-generated sources or building them on @@ -93,7 +92,6 @@ endif() if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) add_library(express SHARED ${EXPRESS_OBJS}) - target_link_libraries(express base) if(OPENBSD) set_target_properties(express PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}) else(OPENBSD) @@ -137,9 +135,9 @@ set(CHECK_EXPRESS_SOURCES add_executable(check-express ${CHECK_EXPRESS_SOURCES}) if(BUILD_SHARED_LIBS OR NOT BUILD_STATIC_LIBS) - target_link_libraries(check-express express base) + target_link_libraries(check-express express) else() - target_link_libraries(check-express express-static base-static) + target_link_libraries(check-express express-static) endif() install(TARGETS check-express RUNTIME DESTINATION ${BIN_DIR} diff --git a/src/express/error.c b/src/express/error.c index c151a2d87..9b63825c2 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -58,17 +58,11 @@ #include #include -#include "sc_memmgr.h" #include "express/express.h" #include "express/error.h" #include "express/info.h" #include "express/linklist.h" -#if defined(_MSC_VER) && _MSC_VER < 1900 -# include "sc_stdio.h" -# define vsnprintf c99_vsnprintf -#endif - static struct Error_ LibErrors[] = { /* dict.c */ [DUPLICATE_DECL] = {SEVERITY_ERROR, "Redeclaration of %s. Previous declaration was on line %d.", NULL, false}, @@ -233,7 +227,7 @@ static void ERROR_nexterror() { /** Initialize the Error module */ void ERRORinitialize( void ) { - ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE ); + ERROR_string_base = ( char * )malloc( ERROR_MAX_SPACE ); ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE; ERROR_start_message_buffer(); @@ -253,7 +247,7 @@ void ERRORinitialize( void ) { /** Clean up the Error module */ void ERRORcleanup( void ) { - sc_free( ERROR_string_base ); + free( ERROR_string_base ); } void ERRORset_warning(char * name, bool warn_only) { @@ -296,7 +290,7 @@ char * ERRORget_warnings_help(const char* prefix, const char *eol) { clen = strlen(prefix) + strlen(eol) + 1; - buf = sc_malloc(sz); + buf = malloc(sz); if (!buf) { fprintf(error_file, "failed to allocate memory for warnings help!\n"); } @@ -308,7 +302,7 @@ char * ERRORget_warnings_help(const char* prefix, const char *eol) { len = strlen(buf) + strlen(err->name) + clen; if (len > sz) { sz *= 2; - nbuf = sc_realloc(buf, sz); + nbuf = realloc(buf, sz); if (!nbuf) { fprintf(error_file, "failed to reallocate / grow memory for warnings help!\n"); } diff --git a/src/express/express.c b/src/express/express.c index 82e7b7889..f6a027ad2 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -73,7 +73,6 @@ #include #include -#include "sc_memmgr.h" #include "express/memory.h" #include "express/basic.h" #include "express/express.h" @@ -146,18 +145,18 @@ int EXPRESS_succeed( Express model ) { Express EXPRESScreate() { Express model = SCOPEcreate( OBJ_EXPRESS ); - model->u.express = ( struct Express_ * )sc_calloc( 1, sizeof( struct Express_ ) ); + model->u.express = ( struct Express_ * )calloc( 1, sizeof( struct Express_ ) ); return model; } void EXPRESSdestroy( Express model ) { if( model->u.express->basename ) { - sc_free( model->u.express->basename ); + free( model->u.express->basename ); } if( model->u.express->filename ) { - sc_free( model->u.express->filename ); + free( model->u.express->filename ); } - sc_free( model->u.express ); + free( model->u.express ); SCOPEdestroy( model ); } @@ -175,7 +174,7 @@ static void EXPRESS_PATHinit() { p = getenv( "EXPRESS_PATH" ); if( !p ) { /* if no EXPRESS_PATH, search current directory anyway */ - dir = ( Dir * )sc_malloc( sizeof( Dir ) ); + dir = ( Dir * )malloc( sizeof( Dir ) ); dir->leaf = dir->full; LISTadd_last( EXPRESS_path, dir ); } else { @@ -208,7 +207,7 @@ static void EXPRESS_PATHinit() { } p++; /* leave p after terminating null */ - dir = ( Dir * )sc_malloc( sizeof( Dir ) ); + dir = ( Dir * )malloc( sizeof( Dir ) ); /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ @@ -240,7 +239,7 @@ static void EXPRESS_PATHinit() { static void EXPRESS_PATHfree( void ) { LISTdo( EXPRESS_path, dir, Dir * ) - sc_free( dir ); + free( dir ); LISTod LISTfree( EXPRESS_path ); } @@ -339,7 +338,7 @@ void EXPRESSparse( Express model, FILE * fp, char * filename ) { length -= 4; } - model->u.express->basename = ( char * )sc_malloc( length + 1 ); + model->u.express->basename = ( char * )malloc( length + 1 ); memcpy( model->u.express->basename, filename, length ); model->u.express->basename[length] = '\0'; diff --git a/src/express/fedex.c b/src/express/fedex.c index 7ccae40d4..efca9ddd1 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -75,9 +75,7 @@ #include #include "config.h" -#include "sc_memmgr.h" #include "sc_export.h" -#include "sc_getopt.h" #include "express/error.h" #include "express/express.h" #include "express/resolve.h" @@ -87,6 +85,68 @@ extern int exp_yydebug; #endif /*YYDEBUG*/ +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index + +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} + + char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string because exp2cxx, exppp, etc may append their own options */ static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */ diff --git a/src/express/hash.c b/src/express/hash.c index 5556ade92..f6de3b9f3 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -109,7 +109,6 @@ #include #include -#include "sc_memmgr.h" #include "express/hash.h" /* @@ -293,7 +292,7 @@ HASHdestroy( Hash_Table table ) { p = q; } } - sc_free( table->Directory[i] ); + free( table->Directory[i] ); } } HASH_Table_destroy( table ); diff --git a/src/express/lexact.c b/src/express/lexact.c index abcde3176..d0ae80a28 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -55,7 +55,6 @@ #include #include -#include "sc_memmgr.h" #include "express/lexact.h" #include "express/linklist.h" #include "stack.h" @@ -273,7 +272,7 @@ int SCANprocess_logical_literal( char * string ) { break; /* default will actually be triggered by 'UNKNOWN' keyword */ } - sc_free( string ); + free( string ); return TOK_LOGICAL_LITERAL; } @@ -285,7 +284,7 @@ int SCANprocess_identifier_or_keyword( const char * yytext ) { /* make uppercase copy */ len = strlen( yytext ); - dest = test_string = ( char * )sc_malloc( len + 1 ); + dest = test_string = ( char * )malloc( len + 1 ); for( src = yytext; *src; src++, dest++ ) { *dest = ( islower( *src ) ? toupper( *src ) : *src ); } @@ -301,7 +300,7 @@ int SCANprocess_identifier_or_keyword( const char * yytext ) { case TOK_LOGICAL_LITERAL: return SCANprocess_logical_literal( test_string ); default: - sc_free( test_string ); + free( test_string ); return k->token; } } @@ -474,7 +473,7 @@ void SCANupperize( char * s ) { } char * SCANstrdup( const char * s ) { - char * s2 = ( char * )sc_malloc( strlen( s ) + 1 ); + char * s2 = ( char * )malloc( strlen( s ) + 1 ); if( !s2 ) { return 0; } diff --git a/src/express/test/CMakeLists.txt b/src/express/test/CMakeLists.txt index 6d2615a9b..413761fd3 100644 --- a/src/express/test/CMakeLists.txt +++ b/src/express/test/CMakeLists.txt @@ -74,8 +74,8 @@ add_test(NAME test_plib_parse_err set_tests_properties( test_plib_parse_err PROPERTIES DEPENDS "build_check_express;$" ) set_tests_properties( test_plib_parse_err build_check_express PROPERTIES LABELS parser ) -sc_addexec(print_schemas SOURCES ../fedex.c print_schemas.c LINK_LIBRARIES express base) -sc_addexec(print_attrs SOURCES ../fedex.c print_attrs.c LINK_LIBRARIES express base) +sc_addexec(print_schemas SOURCES ../fedex.c print_schemas.c LINK_LIBRARIES express) +sc_addexec(print_attrs SOURCES ../fedex.c print_attrs.c LINK_LIBRARIES express) # Local Variables: # tab-width: 8 diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index cbdbcaa02..c8faddd52 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -26,7 +26,66 @@ extern void SchemaInit( class Registry & ); # include #endif -#include +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index + +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} /** * Compare the schema names from the lib (generated by exp2cxx) and diff --git a/src/test/p21read/sc_benchmark.cc b/src/test/p21read/sc_benchmark.cc new file mode 100644 index 000000000..2f00cd5a4 --- /dev/null +++ b/src/test/p21read/sc_benchmark.cc @@ -0,0 +1,149 @@ +/// \file sc_benchmark.cc memory info, timers, etc for benchmarking + +#include "./sc_benchmark.h" + +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +/// mem values in kb, times in ms (granularity may be higher than 1ms) +benchVals getMemAndTime( ) { + benchVals vals; +#ifdef __linux__ + // adapted from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c + std::ifstream stat_stream( "/proc/self/stat", std::ios_base::in ); + + // dummy vars for leading entries in stat that we don't care about + std::string pid, comm, state, ppid, pgrp, session, tty_nr; + std::string tpgid, flags, minflt, cminflt, majflt, cmajflt; + std::string /*utime, stime,*/ cutime, cstime, priority, nice; + std::string O, itrealvalue, starttime; + + // the fields we want + unsigned long utime, stime, vsize; + long rss; + + stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr + >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt + >> utime >> stime >> cutime >> cstime >> priority >> nice + >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest + + long page_size_kb = sysconf( _SC_PAGE_SIZE ) / 1024; // in case x86-64 is configured to use 2MB pages + vals.physMemKB = rss * page_size_kb; + vals.virtMemKB = ( vsize / 1024 ) - vals.physMemKB; + vals.userMilliseconds = ( utime * 1000 ) / sysconf( _SC_CLK_TCK ); + vals.sysMilliseconds = ( stime * 1000 ) / sysconf( _SC_CLK_TCK ); +#elif defined(__APPLE__) + // http://stackoverflow.com/a/1911863/382458 +#elif defined(_WIN32) + // http://stackoverflow.com/a/282220/382458 and http://stackoverflow.com/a/64166/382458 + PROCESS_MEMORY_COUNTERS MemoryCntrs; + FILETIME CreationTime, ExitTime, KernelTime, UserTime; + long page_size_kb = 1024; + ULARGE_INTEGER kTime, uTime; + + if( GetProcessMemoryInfo( GetCurrentProcess(), &MemoryCntrs, sizeof( MemoryCntrs ) ) ) { + vals.physMemKB = MemoryCntrs.PeakWorkingSetSize / page_size_kb; + vals.virtMemKB = MemoryCntrs.PeakPagefileUsage / page_size_kb; + } else { + vals.physMemKB = 0; + vals.virtMemKB = 0; + } + + if( GetProcessTimes( GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime ) ) { + assert( sizeof( FILETIME ) == sizeof( ULARGE_INTEGER ) ); + memcpy( &kTime, &KernelTime, sizeof( FILETIME ) ); + memcpy( &uTime, &UserTime, sizeof( FILETIME ) ); + vals.userMilliseconds = ( long )( uTime.QuadPart / 100000L ); + vals.sysMilliseconds = ( long )( kTime.QuadPart / 100000L ); + } else { + vals.userMilliseconds = 0; + vals.sysMilliseconds = 0; + } +#else +#warning Unknown platform! +#endif // __linux__ + return vals; +} + +// --------------------- benchmark class --------------------- + +benchmark::benchmark( std::string description, bool debugMessages, std::ostream & o_stream ): ostr( o_stream ), + descr( description ), debug( debugMessages ), stopped( false ) { + initialVals = getMemAndTime( ); +} + +benchmark::~benchmark() { + if( !stopped ) { + stop( ); + if( debug ) { + ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl; + } + out( ); + } +} + +void benchmark::stop( ) { + if( stopped ) { + std::cerr << "benchmark::stop(): tried to stop a benchmark that was already stopped!" << std::endl; + } else { + laterVals = getMemAndTime( ); + stopped = true; + } +} + +benchVals benchmark::get( ) { + if( !stopped ) { + laterVals = getMemAndTime( ); + } + benchVals delta; + delta.physMemKB = laterVals.physMemKB - initialVals.physMemKB; + delta.virtMemKB = laterVals.virtMemKB - initialVals.virtMemKB; + delta.sysMilliseconds = laterVals.sysMilliseconds - initialVals.sysMilliseconds; + delta.userMilliseconds = laterVals.userMilliseconds - initialVals.userMilliseconds; + + //If vm is negative, the memory had been requested before initialVals was set. Don't count it + if( delta.virtMemKB < 0 ) { + delta.physMemKB -= delta.virtMemKB; + delta.virtMemKB = 0; + } + return delta; +} + +void benchmark::reset( std::string description ) { + descr = description; + reset(); +} +void benchmark::reset( ) { + stopped = false; + initialVals = getMemAndTime(); +} + +std::string benchmark::str( ) { + return str( get( ) ); +} + +void benchmark::out() { + ostr << str( ) << std::endl; +} + +std::string benchmark::str( const benchVals & bv ) { + std::stringstream ss; + ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB; + ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms"; + return ss.str(); +} + diff --git a/src/test/p21read/sc_benchmark.h b/src/test/p21read/sc_benchmark.h new file mode 100644 index 000000000..5b77317c4 --- /dev/null +++ b/src/test/p21read/sc_benchmark.h @@ -0,0 +1,74 @@ +#ifndef SC_BENCHMARK_H +#define SC_BENCHMARK_H +/// \file sc_benchmark.h memory info, timers, etc for benchmarking + +#ifdef __cplusplus +#include +#include +#include + +extern "C" { +#endif + + typedef struct { + long virtMemKB, physMemKB, userMilliseconds, sysMilliseconds; + } benchVals; + + /** return a benchVals struct with four current statistics for this process: + * virtual and physical memory use in kb, + * user and system cpu time in ms + * + * not yet implemented for OSX or Windows. + */ + benchVals getMemAndTime( ); + +#ifdef __cplusplus +} + + +/** reports the difference in memory and cpu use between when the + * constructor is called and when stop() or the destructor is called. + * + * if the destructor is called and stop() had not previously been + * called, the results are printed to the ostream given in the + * constructor, prefixed by the description. + * + * depends on getMemAndTime() above - may not work on all platforms. + */ + +class benchmark { + protected: + benchVals initialVals, laterVals; +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) +#endif + std::ostream & ostr; + std::string descr; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + bool debug, stopped; + public: + benchmark( std::string description = "", bool debugMessages = true, std::ostream & o_stream = std::cout ); + + /// if 'stopped' is false, uses str(true) to print to ostream + ~benchmark( ); + void reset( ); + void reset( std::string description ); + benchVals get( ); + void stop( ); + + /// converts data member 'laterVals' into a string and returns it + std::string str( ); + + /// outputs result of str() on ostream 'ostr' + void out( ); + + /// converts 'bv' into a string, prefixed by data member 'descr' + std::string str( const benchVals & bv ); +}; + + +#endif //__cplusplus +#endif //SC_BENCHMARK_H diff --git a/test/cpp/schema_specific/CMakeLists.txt b/test/cpp/schema_specific/CMakeLists.txt index 44fa4e5bc..e1bd06e10 100644 --- a/test/cpp/schema_specific/CMakeLists.txt +++ b/test/cpp/schema_specific/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) #c++ tests that depend on a particular schema 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 ) + ${SC_SOURCE_DIR}/src/clstepcore ) # helper function for add_schema_dependent_test # given an sdai target, set out_path_var to the include dir @@ -92,7 +92,7 @@ set_tests_properties( test_aggregate_bound_runtime_FAIL1 PROPERTIES add_schema_dependent_test( "inverse_attr1" "inverse_attr" "${SC_SOURCE_DIR}/test/p21/test_inverse_attr.p21" ) add_schema_dependent_test( "inverse_attr2" "inverse_attr" "${SC_SOURCE_DIR}/test/p21/test_inverse_attr.p21" ) add_schema_dependent_test( "inverse_attr3" "inverse_attr" "${SC_SOURCE_DIR}/test/p21/test_inverse_attr.p21" - "${SC_SOURCE_DIR}/src/cllazyfile;${SC_SOURCE_DIR}/src/base/judy/src" "" "steplazyfile" ) + "${SC_SOURCE_DIR}/src/cllazyfile;${SC_SOURCE_DIR}/src/cllazyfile/judy/src" "" "steplazyfile" ) add_schema_dependent_test( "attribute" "inverse_attr" "${SC_SOURCE_DIR}/test/p21/test_inverse_attr.p21" ) if(HAVE_STD_THREAD) diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index dc819f029..79d462fda 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -14,10 +14,68 @@ #ifdef HAVE_UNISTD_H # include #endif -#include #include "schema.h" +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} int main( int argc, char * argv[] ) { Registry registry( SchemaInit ); InstMgr instance_list; diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 27a383ab6..079ababbf 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -16,9 +16,69 @@ #ifdef HAVE_UNISTD_H # include #endif -#include #include "schema.h" +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index + +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} + ///first way of finding inverse attrs bool findInverseAttrs1( InverseAItr iai, InstMgr & instList ) { const Inverse_attribute * ia; diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 00cd7da0c..6423786f6 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -15,9 +15,68 @@ #ifdef HAVE_UNISTD_H # include #endif -#include #include "schema.h" +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index + +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} ///second way of finding inverse attrs bool findInverseAttrs2( InverseAItr iai, InstMgr & instList, Registry & reg ) { const Inverse_attribute * ia; diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 2a55efc66..782ebb1df 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -19,9 +19,70 @@ #ifdef HAVE_UNISTD_H # include #endif -#include #include "schema.h" +char * sc_optarg; // global argument pointer +int sc_optind = 0; // global argv index + +int sc_getopt( int argc, char * argv[], char * optstring ) { + static char * next = NULL; + if( sc_optind == 0 ) { + next = NULL; + } + + sc_optarg = NULL; + + if( next == NULL || *next == '\0' ) { + if( sc_optind == 0 ) { + sc_optind++; + } + + if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) { + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + if( strcmp( argv[sc_optind], "--" ) == 0 ) { + sc_optind++; + sc_optarg = NULL; + if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + } + return EOF; + } + + next = argv[sc_optind]; + next++; // skip past - + sc_optind++; + } + + char c = *next++; + char * cp = strchr( optstring, c ); + + if( cp == NULL || c == ':' ) { + return '?'; + } + + cp++; + if( *cp == ':' ) { + if( *next != '\0' ) { + sc_optarg = next; + next = NULL; + } else if( sc_optind < argc ) { + sc_optarg = argv[sc_optind]; + sc_optind++; + } else { + return '?'; + } + } + + return c; +} + + int main( int argc, char * argv[] ) { int exitStatus = EXIT_SUCCESS; if( argc != 2 ) { From 28783de62b858e19c5169ce0a934bd7502867caf Mon Sep 17 00:00:00 2001 From: bitbybit3d Date: Tue, 11 Jan 2022 08:52:37 +0800 Subject: [PATCH 216/244] fix target_compile_definitions misspelling --- cmake/SC_CXX_schema_macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index c94d63e48..eab9174a7 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -113,7 +113,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles) if($CACHE{SC_BUILD_STATIC_LIBS}) SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static TESTABLE) add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME}) - target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC) + target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC) if(MSVC) target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj") endif() From 0978cfcd00c492eb967ac8090b731893f38dbf10 Mon Sep 17 00:00:00 2001 From: luz paz Date: Mon, 26 Sep 2022 20:46:05 -0400 Subject: [PATCH 217/244] Fix typos in src/clstepcore subdir --- src/clstepcore/STEPaggrEnum.h | 4 ++-- src/clstepcore/STEPaggrSelect.h | 4 ++-- src/clstepcore/typeDescriptor.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/clstepcore/STEPaggrEnum.h b/src/clstepcore/STEPaggrEnum.h index 161706a48..14cf1d6de 100644 --- a/src/clstepcore/STEPaggrEnum.h +++ b/src/clstepcore/STEPaggrEnum.h @@ -9,7 +9,7 @@ /** * \class EnumAggregate - * This is a minimal representions for a collection of SDAI_Enum + * This is a minimal representation for a collection of SDAI_Enum */ class SC_CORE_EXPORT EnumAggregate : public STEPaggregate { public: @@ -55,7 +55,7 @@ SC_CORE_EXPORT BOOLEANS * create_BOOLEANS(); /** * * \class EnumNode - ** This is a minimal representions for node in lists of SDAI_Enum + ** This is a minimal representation for node in lists of SDAI_Enum */ class SC_CORE_EXPORT EnumNode : public STEPnode { public: diff --git a/src/clstepcore/STEPaggrSelect.h b/src/clstepcore/STEPaggrSelect.h index b62a9c3fe..1b97d6e43 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/src/clstepcore/STEPaggrSelect.h @@ -11,7 +11,7 @@ /** * * \class SelectAggregate - ** This is a minimal represention for a collection of SDAI_Select + ** This is a minimal representation for a collection of SDAI_Select */ class SC_CORE_EXPORT SelectAggregate : public STEPaggregate { public: @@ -35,7 +35,7 @@ typedef SelectAggregate_ptr SelectAggregate_var; /** * * \class SelectNode - ** This is a minimal representions for node in lists of SDAI_Select + ** This is a minimal representation for node in lists of SDAI_Select */ class SC_CORE_EXPORT SelectNode : public STEPnode { public: diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index 31ead1662..651a508f5 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -75,7 +75,7 @@ bool TypeDescriptor::CurrName( const char * other, const char * schNm ) const { // other better = the alt name. return ( !StrCmpIns( _altname, other ) ); } else { - // If we have no desginated alternate name when the current schema = + // If we have no designated alternate name when the current schema = // schNm, other must = our _name. return ( OurName( other ) ); } From f83e0abc74f6aa9ae0cb90f4fed9d19272cb8417 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 28 Sep 2022 21:16:51 +0100 Subject: [PATCH 218/244] exp2py: change SCL package to stepcode package --- src/exp2python/python/{SCL => stepcode}/AggregationDataTypes.py | 0 src/exp2python/python/{SCL => stepcode}/BaseType.py | 0 src/exp2python/python/{SCL => stepcode}/Builtin.py | 0 src/exp2python/python/{SCL => stepcode}/ConstructedDataTypes.py | 0 src/exp2python/python/{SCL => stepcode}/Model.py | 0 src/exp2python/python/{SCL => stepcode}/Part21.py | 0 src/exp2python/python/{SCL => stepcode}/Rules.py | 0 src/exp2python/python/{SCL => stepcode}/SCLBase.py | 0 src/exp2python/python/{SCL => stepcode}/SimpleDataTypes.py | 0 src/exp2python/python/{SCL => stepcode}/TypeChecker.py | 0 src/exp2python/python/{SCL => stepcode}/Utils.py | 0 src/exp2python/python/{SCL => stepcode}/__init__.py | 0 src/exp2python/python/{SCL => stepcode}/_cPart21.c | 0 src/exp2python/python/{SCL => stepcode}/_cPart21.l | 0 src/exp2python/python/{SCL => stepcode}/cPart21.py | 0 src/exp2python/python/{SCL => stepcode}/essa_par.py | 0 src/exp2python/python/{SCL => stepcode}/p21sql.c | 0 src/exp2python/python/{SCL => stepcode}/p21sql.l | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename src/exp2python/python/{SCL => stepcode}/AggregationDataTypes.py (100%) rename src/exp2python/python/{SCL => stepcode}/BaseType.py (100%) rename src/exp2python/python/{SCL => stepcode}/Builtin.py (100%) rename src/exp2python/python/{SCL => stepcode}/ConstructedDataTypes.py (100%) rename src/exp2python/python/{SCL => stepcode}/Model.py (100%) rename src/exp2python/python/{SCL => stepcode}/Part21.py (100%) rename src/exp2python/python/{SCL => stepcode}/Rules.py (100%) rename src/exp2python/python/{SCL => stepcode}/SCLBase.py (100%) rename src/exp2python/python/{SCL => stepcode}/SimpleDataTypes.py (100%) rename src/exp2python/python/{SCL => stepcode}/TypeChecker.py (100%) rename src/exp2python/python/{SCL => stepcode}/Utils.py (100%) rename src/exp2python/python/{SCL => stepcode}/__init__.py (100%) rename src/exp2python/python/{SCL => stepcode}/_cPart21.c (100%) rename src/exp2python/python/{SCL => stepcode}/_cPart21.l (100%) rename src/exp2python/python/{SCL => stepcode}/cPart21.py (100%) rename src/exp2python/python/{SCL => stepcode}/essa_par.py (100%) rename src/exp2python/python/{SCL => stepcode}/p21sql.c (100%) rename src/exp2python/python/{SCL => stepcode}/p21sql.l (100%) diff --git a/src/exp2python/python/SCL/AggregationDataTypes.py b/src/exp2python/python/stepcode/AggregationDataTypes.py similarity index 100% rename from src/exp2python/python/SCL/AggregationDataTypes.py rename to src/exp2python/python/stepcode/AggregationDataTypes.py diff --git a/src/exp2python/python/SCL/BaseType.py b/src/exp2python/python/stepcode/BaseType.py similarity index 100% rename from src/exp2python/python/SCL/BaseType.py rename to src/exp2python/python/stepcode/BaseType.py diff --git a/src/exp2python/python/SCL/Builtin.py b/src/exp2python/python/stepcode/Builtin.py similarity index 100% rename from src/exp2python/python/SCL/Builtin.py rename to src/exp2python/python/stepcode/Builtin.py diff --git a/src/exp2python/python/SCL/ConstructedDataTypes.py b/src/exp2python/python/stepcode/ConstructedDataTypes.py similarity index 100% rename from src/exp2python/python/SCL/ConstructedDataTypes.py rename to src/exp2python/python/stepcode/ConstructedDataTypes.py diff --git a/src/exp2python/python/SCL/Model.py b/src/exp2python/python/stepcode/Model.py similarity index 100% rename from src/exp2python/python/SCL/Model.py rename to src/exp2python/python/stepcode/Model.py diff --git a/src/exp2python/python/SCL/Part21.py b/src/exp2python/python/stepcode/Part21.py similarity index 100% rename from src/exp2python/python/SCL/Part21.py rename to src/exp2python/python/stepcode/Part21.py diff --git a/src/exp2python/python/SCL/Rules.py b/src/exp2python/python/stepcode/Rules.py similarity index 100% rename from src/exp2python/python/SCL/Rules.py rename to src/exp2python/python/stepcode/Rules.py diff --git a/src/exp2python/python/SCL/SCLBase.py b/src/exp2python/python/stepcode/SCLBase.py similarity index 100% rename from src/exp2python/python/SCL/SCLBase.py rename to src/exp2python/python/stepcode/SCLBase.py diff --git a/src/exp2python/python/SCL/SimpleDataTypes.py b/src/exp2python/python/stepcode/SimpleDataTypes.py similarity index 100% rename from src/exp2python/python/SCL/SimpleDataTypes.py rename to src/exp2python/python/stepcode/SimpleDataTypes.py diff --git a/src/exp2python/python/SCL/TypeChecker.py b/src/exp2python/python/stepcode/TypeChecker.py similarity index 100% rename from src/exp2python/python/SCL/TypeChecker.py rename to src/exp2python/python/stepcode/TypeChecker.py diff --git a/src/exp2python/python/SCL/Utils.py b/src/exp2python/python/stepcode/Utils.py similarity index 100% rename from src/exp2python/python/SCL/Utils.py rename to src/exp2python/python/stepcode/Utils.py diff --git a/src/exp2python/python/SCL/__init__.py b/src/exp2python/python/stepcode/__init__.py similarity index 100% rename from src/exp2python/python/SCL/__init__.py rename to src/exp2python/python/stepcode/__init__.py diff --git a/src/exp2python/python/SCL/_cPart21.c b/src/exp2python/python/stepcode/_cPart21.c similarity index 100% rename from src/exp2python/python/SCL/_cPart21.c rename to src/exp2python/python/stepcode/_cPart21.c diff --git a/src/exp2python/python/SCL/_cPart21.l b/src/exp2python/python/stepcode/_cPart21.l similarity index 100% rename from src/exp2python/python/SCL/_cPart21.l rename to src/exp2python/python/stepcode/_cPart21.l diff --git a/src/exp2python/python/SCL/cPart21.py b/src/exp2python/python/stepcode/cPart21.py similarity index 100% rename from src/exp2python/python/SCL/cPart21.py rename to src/exp2python/python/stepcode/cPart21.py diff --git a/src/exp2python/python/SCL/essa_par.py b/src/exp2python/python/stepcode/essa_par.py similarity index 100% rename from src/exp2python/python/SCL/essa_par.py rename to src/exp2python/python/stepcode/essa_par.py diff --git a/src/exp2python/python/SCL/p21sql.c b/src/exp2python/python/stepcode/p21sql.c similarity index 100% rename from src/exp2python/python/SCL/p21sql.c rename to src/exp2python/python/stepcode/p21sql.c diff --git a/src/exp2python/python/SCL/p21sql.l b/src/exp2python/python/stepcode/p21sql.l similarity index 100% rename from src/exp2python/python/SCL/p21sql.l rename to src/exp2python/python/stepcode/p21sql.l From e05bfc7bd405e7f614759b67ef5a33615bae9378 Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 28 Sep 2022 21:34:56 +0100 Subject: [PATCH 219/244] exp2py: change file header StepClassLibrary (SCL) to STEPCODE project --- src/exp2python/python/LICENSE | 2 +- src/exp2python/python/stepcode/AggregationDataTypes.py | 2 +- src/exp2python/python/stepcode/BaseType.py | 2 +- src/exp2python/python/stepcode/Builtin.py | 2 +- src/exp2python/python/stepcode/ConstructedDataTypes.py | 2 +- src/exp2python/python/stepcode/Model.py | 2 +- src/exp2python/python/stepcode/Part21.py | 2 +- src/exp2python/python/stepcode/Rules.py | 2 +- src/exp2python/python/stepcode/SCLBase.py | 2 +- src/exp2python/python/stepcode/SimpleDataTypes.py | 2 +- src/exp2python/python/stepcode/TypeChecker.py | 2 +- src/exp2python/python/stepcode/Utils.py | 2 +- src/exp2python/python/stepcode/_cPart21.c | 2 +- src/exp2python/python/stepcode/_cPart21.l | 2 +- src/exp2python/python/stepcode/cPart21.py | 2 +- src/exp2python/python/tests/test_SCL.py | 2 +- src/exp2python/python/tests/test_base.py | 2 +- src/exp2python/python/tests/test_builtin.py | 2 +- src/exp2python/python/tests/test_parser.py | 2 +- src/exp2python/python/tests/test_unitary_schemas.py | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/exp2python/python/LICENSE b/src/exp2python/python/LICENSE index 80934a9d5..6e4fe3b3b 100644 --- a/src/exp2python/python/LICENSE +++ b/src/exp2python/python/LICENSE @@ -4,7 +4,7 @@ # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/AggregationDataTypes.py b/src/exp2python/python/stepcode/AggregationDataTypes.py index 5ed1409ab..9dfd1b1a0 100644 --- a/src/exp2python/python/stepcode/AggregationDataTypes.py +++ b/src/exp2python/python/stepcode/AggregationDataTypes.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/BaseType.py b/src/exp2python/python/stepcode/BaseType.py index 93b931de2..64bf779f2 100644 --- a/src/exp2python/python/stepcode/BaseType.py +++ b/src/exp2python/python/stepcode/BaseType.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/Builtin.py b/src/exp2python/python/stepcode/Builtin.py index fb2910a2f..0d71466a1 100644 --- a/src/exp2python/python/stepcode/Builtin.py +++ b/src/exp2python/python/stepcode/Builtin.py @@ -1,7 +1,7 @@ # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/ConstructedDataTypes.py b/src/exp2python/python/stepcode/ConstructedDataTypes.py index 0e9393333..9b9d8bc5e 100644 --- a/src/exp2python/python/stepcode/ConstructedDataTypes.py +++ b/src/exp2python/python/stepcode/ConstructedDataTypes.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/Model.py b/src/exp2python/python/stepcode/Model.py index 036a435da..0a2d20aca 100644 --- a/src/exp2python/python/stepcode/Model.py +++ b/src/exp2python/python/stepcode/Model.py @@ -1,7 +1,7 @@ # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/Part21.py b/src/exp2python/python/stepcode/Part21.py index f2e70a3ba..8c8be8fef 100644 --- a/src/exp2python/python/stepcode/Part21.py +++ b/src/exp2python/python/stepcode/Part21.py @@ -6,7 +6,7 @@ # # All rights reserved. # -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/Rules.py b/src/exp2python/python/stepcode/Rules.py index 1b94f6e0b..4c01e15a0 100644 --- a/src/exp2python/python/stepcode/Rules.py +++ b/src/exp2python/python/stepcode/Rules.py @@ -1,7 +1,7 @@ # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/SCLBase.py b/src/exp2python/python/stepcode/SCLBase.py index ff8413e8b..aebc880f3 100644 --- a/src/exp2python/python/stepcode/SCLBase.py +++ b/src/exp2python/python/stepcode/SCLBase.py @@ -2,7 +2,7 @@ # Copyright (c) 2022, Chris Horler (cshorler@googlemail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/SimpleDataTypes.py b/src/exp2python/python/stepcode/SimpleDataTypes.py index 3cd28cbc2..4e1d0a508 100644 --- a/src/exp2python/python/stepcode/SimpleDataTypes.py +++ b/src/exp2python/python/stepcode/SimpleDataTypes.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/TypeChecker.py b/src/exp2python/python/stepcode/TypeChecker.py index 0a77716fb..c97d7c11f 100644 --- a/src/exp2python/python/stepcode/TypeChecker.py +++ b/src/exp2python/python/stepcode/TypeChecker.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/Utils.py b/src/exp2python/python/stepcode/Utils.py index 73b789cc9..76e352fc3 100644 --- a/src/exp2python/python/stepcode/Utils.py +++ b/src/exp2python/python/stepcode/Utils.py @@ -3,7 +3,7 @@ # All rights reserved. -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/_cPart21.c b/src/exp2python/python/stepcode/_cPart21.c index 1bdcfa24a..2b93ac7ca 100644 --- a/src/exp2python/python/stepcode/_cPart21.c +++ b/src/exp2python/python/stepcode/_cPart21.c @@ -6,7 +6,7 @@ * * All rights reserved. * - * This file is part of the StepClassLibrary (SCL). + * This file is part of the STEPCODE project. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/_cPart21.l b/src/exp2python/python/stepcode/_cPart21.l index 25cced1ba..2a8ded85a 100644 --- a/src/exp2python/python/stepcode/_cPart21.l +++ b/src/exp2python/python/stepcode/_cPart21.l @@ -5,7 +5,7 @@ * * All rights reserved. * - * This file is part of the StepClassLibrary (SCL). + * This file is part of the STEPCODE project. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/stepcode/cPart21.py b/src/exp2python/python/stepcode/cPart21.py index 94eeedc61..6e4b9a697 100644 --- a/src/exp2python/python/stepcode/cPart21.py +++ b/src/exp2python/python/stepcode/cPart21.py @@ -5,7 +5,7 @@ # # All rights reserved. # -# This file is part of the StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/tests/test_SCL.py b/src/exp2python/python/tests/test_SCL.py index 0c3e8703f..9759980c0 100644 --- a/src/exp2python/python/tests/test_SCL.py +++ b/src/exp2python/python/tests/test_SCL.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/tests/test_base.py b/src/exp2python/python/tests/test_base.py index fb3ea6e2d..92f56e876 100644 --- a/src/exp2python/python/tests/test_base.py +++ b/src/exp2python/python/tests/test_base.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/tests/test_builtin.py b/src/exp2python/python/tests/test_builtin.py index 983c01610..5f3f7544d 100644 --- a/src/exp2python/python/tests/test_builtin.py +++ b/src/exp2python/python/tests/test_builtin.py @@ -1,7 +1,7 @@ # Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/tests/test_parser.py b/src/exp2python/python/tests/test_parser.py index 20344d787..4522383e4 100644 --- a/src/exp2python/python/tests/test_parser.py +++ b/src/exp2python/python/tests/test_parser.py @@ -1,7 +1,7 @@ # Copyright (c) 2021, Devon Sparks (devonsparks.com) # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/src/exp2python/python/tests/test_unitary_schemas.py b/src/exp2python/python/tests/test_unitary_schemas.py index 66b2a7d25..7566b6dbd 100644 --- a/src/exp2python/python/tests/test_unitary_schemas.py +++ b/src/exp2python/python/tests/test_unitary_schemas.py @@ -1,7 +1,7 @@ # Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com) # All rights reserved. -# This file is part StepClassLibrary (SCL). +# This file is part of the STEPCODE project. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: From 80b4588f6a38d2f3de95a84cb92627a73090e6ff Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 28 Sep 2022 21:58:44 +0100 Subject: [PATCH 220/244] exp2py: tests SCL -> stepcode --- src/exp2python/python/tests/test_base.py | 8 ++++---- src/exp2python/python/tests/test_builtin.py | 10 +++++----- src/exp2python/python/tests/test_parser.py | 2 +- src/exp2python/python/tests/test_unitary_schemas.py | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/exp2python/python/tests/test_base.py b/src/exp2python/python/tests/test_base.py index 92f56e876..deb9c7301 100644 --- a/src/exp2python/python/tests/test_base.py +++ b/src/exp2python/python/tests/test_base.py @@ -32,10 +32,10 @@ import sys import unittest -from SCL.SimpleDataTypes import * -from SCL.TypeChecker import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * +from stepcode.SimpleDataTypes import * +from stepcode.TypeChecker import * +from stepcode.ConstructedDataTypes import * +from stepcode.AggregationDataTypes import * # # Simple data types diff --git a/src/exp2python/python/tests/test_builtin.py b/src/exp2python/python/tests/test_builtin.py index 5f3f7544d..1a6fa5c73 100644 --- a/src/exp2python/python/tests/test_builtin.py +++ b/src/exp2python/python/tests/test_builtin.py @@ -32,11 +32,11 @@ import sys import unittest -from SCL.SimpleDataTypes import * -from SCL.TypeChecker import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.Builtin import * +from stepcode.SimpleDataTypes import * +from stepcode.TypeChecker import * +from stepcode.ConstructedDataTypes import * +from stepcode.AggregationDataTypes import * +from stepcode.Builtin import * float_epsilon = 1e-8 # diff --git a/src/exp2python/python/tests/test_parser.py b/src/exp2python/python/tests/test_parser.py index 4522383e4..b17470b47 100644 --- a/src/exp2python/python/tests/test_parser.py +++ b/src/exp2python/python/tests/test_parser.py @@ -30,7 +30,7 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import unittest -from SCL.Part21 import Parser +from stepcode.Part21 import Parser ShapesSample =""" ISO-10303-21; diff --git a/src/exp2python/python/tests/test_unitary_schemas.py b/src/exp2python/python/tests/test_unitary_schemas.py index 7566b6dbd..077644253 100644 --- a/src/exp2python/python/tests/test_unitary_schemas.py +++ b/src/exp2python/python/tests/test_unitary_schemas.py @@ -36,11 +36,11 @@ here = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.join(here, "..", "..", "examples", "unitary_schemas")) -from SCL.SCLBase import * -from SCL.SimpleDataTypes import * -from SCL.ConstructedDataTypes import * -from SCL.AggregationDataTypes import * -from SCL.TypeChecker import check_type +from stepcode.SCLBase import * +from stepcode.SimpleDataTypes import * +from stepcode.ConstructedDataTypes import * +from stepcode.AggregationDataTypes import * +from stepcode.TypeChecker import check_type class TestSelectDataType(unittest.TestCase): ''' From c2842f884aa7978c91f75b79c1aebcf87ed121af Mon Sep 17 00:00:00 2001 From: Chris HORLER Date: Wed, 28 Sep 2022 21:59:58 +0100 Subject: [PATCH 221/244] exp2py: bump package version number and replace SCL references in README and setup.cfg --- src/exp2python/python/README.md | 12 ++++++------ src/exp2python/python/setup.cfg | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/exp2python/python/README.md b/src/exp2python/python/README.md index 470e626a3..20278a512 100644 --- a/src/exp2python/python/README.md +++ b/src/exp2python/python/README.md @@ -1,21 +1,21 @@ -# SCL - A Python3 STEP Class Library +# stepcode - A Python3 STEP Library -SCL is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +STEPCODE Python is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. # Use -To parse a ISO 10303 Part 21 file, use the `Parser` class of `SCL.Part21`. On a successful parse, the result will be a Part 21 parse tree and associated STEP instances. +To parse a ISO 10303 Part 21 file, use the `Parser` class of `stepcode.Part21`. On a successful parse, the result will be a Part 21 parse tree and associated STEP instances. -See [test_parser](tests/test_parser.py) for use of the `SCL.Part21` parser with a sample STEP file. +See [test_parser](tests/test_parser.py) for use of the `stepcode.Part21` parser with a sample STEP file. # Building -The SCL Python package can be built directly using [PyPA's build module](https://github.com/pypa/build). Run `python3 -m build` from this directory. +The stepcode Python package can be built directly using [PyPA's build module](https://github.com/pypa/build). Run `python3 -m build` from this directory. # Testing -SCL comes with a small test suite (additions welcome!) From this directory, `python3 -m unittest discover`. +STEPCODE Python comes with a small test suite (additions welcome!) From this directory, `python3 -m unittest discover`. # License diff --git a/src/exp2python/python/setup.cfg b/src/exp2python/python/setup.cfg index 276a8bd30..3a05fbf27 100644 --- a/src/exp2python/python/setup.cfg +++ b/src/exp2python/python/setup.cfg @@ -1,8 +1,8 @@ [metadata] -name = stepcode-scl -version = 0.6.1 +name = stepcode +version = 0.7.0 author = Thomas Paviot , Christopher HORLER (cshorler@googlemail.com), Devon Sparks (devonsparks.com) -description = stepcode-scl is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. +description = stepcode is a Python3-based library for parsing and manipulating ISO 10303 Part 21 ("STEP") files. long_description = file: README.md long_description_content_type = text/markdown @@ -15,7 +15,7 @@ classifiers = [options] package_dir = =. -packages = SCL +packages = stepcode python_requires = >=3.6 install_requires = ply From 33102ee9e346d9b137290cbc75da8fc1d606d04a Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 08:39:18 -0400 Subject: [PATCH 222/244] First steps of resituating stepcode headers Goal is for client codes to be able to simply include the stepcode direcotry and have everything work, rather than having to worry about individual step libraries. Will also make it clear with the dir prefixes when libraries are using .h files from other libraries, rather than their own. --- include/core/CMakeLists.txt | 71 +++++++++++++++++++ .../core}/aggrTypeDescriptor.h | 0 .../core}/attrDescriptor.h | 0 .../core}/attrDescriptorList.h | 0 src/cldai/CMakeLists.txt | 1 + src/cleditor/CMakeLists.txt | 1 + src/cllazyfile/CMakeLists.txt | 1 + src/clstepcore/CMakeLists.txt | 4 +- src/clstepcore/ExpDict.h | 6 +- src/clstepcore/aggrTypeDescriptor.cc | 2 +- src/clstepcore/attrDescriptor.cc | 2 +- src/clstepcore/attrDescriptorList.cc | 4 +- src/clstepcore/derivedAttribute.h | 2 +- src/clstepcore/entityDescriptor.cc | 2 +- src/clstepcore/entityDescriptor.h | 4 +- src/clstepcore/inverseAttribute.h | 2 +- src/clutils/CMakeLists.txt | 1 + 17 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 include/core/CMakeLists.txt rename {src/clstepcore => include/core}/aggrTypeDescriptor.h (100%) rename {src/clstepcore => include/core}/attrDescriptor.h (100%) rename {src/clstepcore => include/core}/attrDescriptorList.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt new file mode 100644 index 000000000..4129130a0 --- /dev/null +++ b/include/core/CMakeLists.txt @@ -0,0 +1,71 @@ +set(CORE_HDRS + aggrTypeDescriptor.h + attrDescriptor.h + attrDescriptorList.h +# baseType.h +# complexSupport.h +# create_Aggr.h +# derivedAttribute.h +# dictSchema.h +# dictdefs.h +# dictionaryInstance.h +# dispnode.h +# dispnodelist.h +# entityDescriptor.h +# entityDescriptorList.h +# enumTypeDescriptor.h +# ExpDict.h +# explicitItemId.h +# globalRule.h +# implicitItemId.h +# instmgr.h +# interfaceSpec.h +# interfacedItem.h +# inverseAttribute.h +# inverseAttributeList.h +# mgrnode.h +# mgrnodearray.h +# mgrnodelist.h +# needFunc.h +# read_func.h +# realTypeDescriptor.h +# Registry.h +# schRename.h +# sdai.h +# sdaiApplication_instance.h +# sdaiSelect.h +# selectTypeDescriptor.h +# SingleLinkList.h +# STEPaggregate.h +# STEPaggrBinary.h +# STEPaggrEntity.h +# STEPaggrEnum.h +# STEPaggrGeneric.h +# STEPaggrInt.h +# STEPaggrReal.h +# STEPaggrSelect.h +# STEPaggrString.h +# STEPattribute.h +# STEPattributeList.h +# STEPcomplex.h +# STEPinvAttrList.h +# STEPundefined.h +# stringTypeDescriptor.h +# SubSuperIterators.h +# typeDescriptor.h +# typeDescriptorList.h +# typeOrRuleVar.h +# uniquenessRule.h +# whereRule.h +) + +install(FILES ${CORE_HDRS} + DESTINATION ${INCLUDE_DIR}/stepcode/core) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/src/clstepcore/aggrTypeDescriptor.h b/include/core/aggrTypeDescriptor.h similarity index 100% rename from src/clstepcore/aggrTypeDescriptor.h rename to include/core/aggrTypeDescriptor.h diff --git a/src/clstepcore/attrDescriptor.h b/include/core/attrDescriptor.h similarity index 100% rename from src/clstepcore/attrDescriptor.h rename to include/core/attrDescriptor.h diff --git a/src/clstepcore/attrDescriptorList.h b/include/core/attrDescriptorList.h similarity index 100% rename from src/clstepcore/attrDescriptorList.h rename to include/core/attrDescriptorList.h diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index b34b5f161..9d8616f1c 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -29,6 +29,7 @@ SET(SC_CLDAI_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include/stepcode ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/clutils ) diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 2e2ec980d..75340aa3c 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -21,6 +21,7 @@ SET(SC_CLEDITOR_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include/stepcode ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/clutils diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index d9646b74d..392f56fdc 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -29,6 +29,7 @@ set( SC_CLLAZYFILE_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include/stepcode ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/clstepcore diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 67132ee45..845c37677 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,9 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - aggrTypeDescriptor.h - attrDescriptor.h - attrDescriptorList.h baseType.h complexSupport.h create_Aggr.h @@ -125,6 +122,7 @@ set(SC_CLSTEPCORE_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include/stepcode ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/clutils diff --git a/src/clstepcore/ExpDict.h b/src/clstepcore/ExpDict.h index e73b8dd01..f59ca5fe4 100644 --- a/src/clstepcore/ExpDict.h +++ b/src/clstepcore/ExpDict.h @@ -28,7 +28,7 @@ #include // each of these contains linked list, list node, iterator -#include "attrDescriptorList.h" +#include "core/attrDescriptorList.h" #include "inverseAttributeList.h" #include "typeDescriptorList.h" #include "entityDescriptorList.h" @@ -37,7 +37,7 @@ #include "typeDescriptor.h" #include "entityDescriptor.h" #include "enumTypeDescriptor.h" -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" #include "derivedAttribute.h" #include "inverseAttribute.h" @@ -56,7 +56,7 @@ #include "dictSchema.h" #include "schRename.h" -#include "aggrTypeDescriptor.h" +#include "core/aggrTypeDescriptor.h" #include "selectTypeDescriptor.h" #include "stringTypeDescriptor.h" #include "realTypeDescriptor.h" diff --git a/src/clstepcore/aggrTypeDescriptor.cc b/src/clstepcore/aggrTypeDescriptor.cc index 91bed40be..e1e87a78c 100644 --- a/src/clstepcore/aggrTypeDescriptor.cc +++ b/src/clstepcore/aggrTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "aggrTypeDescriptor.h" +#include "core/aggrTypeDescriptor.h" STEPaggregate * AggrTypeDescriptor::CreateAggregate() { if( CreateNewAggr ) { diff --git a/src/clstepcore/attrDescriptor.cc b/src/clstepcore/attrDescriptor.cc index 329d90393..2ce5e74e1 100644 --- a/src/clstepcore/attrDescriptor.cc +++ b/src/clstepcore/attrDescriptor.cc @@ -1,4 +1,4 @@ -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType, Logical optional, Logical unique, AttrType_Enum at, diff --git a/src/clstepcore/attrDescriptorList.cc b/src/clstepcore/attrDescriptorList.cc index c197ac5e2..987f34243 100644 --- a/src/clstepcore/attrDescriptorList.cc +++ b/src/clstepcore/attrDescriptorList.cc @@ -1,6 +1,6 @@ -#include "attrDescriptorList.h" +#include "core/attrDescriptorList.h" -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" AttrDescriptorList::AttrDescriptorList() { } diff --git a/src/clstepcore/derivedAttribute.h b/src/clstepcore/derivedAttribute.h index 234521a07..a882b0448 100644 --- a/src/clstepcore/derivedAttribute.h +++ b/src/clstepcore/derivedAttribute.h @@ -1,7 +1,7 @@ #ifndef DERIVEDATTRIBUTE_H #define DERIVEDATTRIBUTE_H -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" #include "sc_export.h" diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 0e58c4db6..f8fb6a2d0 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -2,7 +2,7 @@ #include "entityDescriptor.h" #include "Registry.h" -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" #include "inverseAttribute.h" #include "SubSuperIterators.h" diff --git a/src/clstepcore/entityDescriptor.h b/src/clstepcore/entityDescriptor.h index e0bd25ec8..2e85e7a66 100644 --- a/src/clstepcore/entityDescriptor.h +++ b/src/clstepcore/entityDescriptor.h @@ -2,9 +2,9 @@ #define ENTITYDESCRIPTOR_H #include "typeDescriptor.h" -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" #include "uniquenessRule.h" -#include "attrDescriptorList.h" +#include "core/attrDescriptorList.h" #include "inverseAttributeList.h" #include "sc_export.h" diff --git a/src/clstepcore/inverseAttribute.h b/src/clstepcore/inverseAttribute.h index 0d02b793d..368eaa67f 100644 --- a/src/clstepcore/inverseAttribute.h +++ b/src/clstepcore/inverseAttribute.h @@ -1,7 +1,7 @@ #ifndef INVERSEATTRIBUTE_H #define INVERSEATTRIBUTE_H -#include "attrDescriptor.h" +#include "core/attrDescriptor.h" class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor { diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 427ecb43d..69f2f935d 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -22,6 +22,7 @@ set(SC_CLUTILS_HDRS include_directories( ${SC_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include/stepcode ) if(BUILD_SHARED_LIBS) From 840d57c2f18f45c3b601363c4d48f70c0a183af3 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 09:03:31 -0400 Subject: [PATCH 223/244] Move a few more headers --- include/core/CMakeLists.txt | 6 +++--- include/core/aggrTypeDescriptor.h | 2 +- {src/clstepcore => include/core}/baseType.h | 0 {src/clstepcore => include/core}/complexSupport.h | 0 {src/clstepcore => include/core}/create_Aggr.h | 0 src/cleditor/SdaiSchemaInit.h | 2 +- src/clstepcore/CMakeLists.txt | 3 --- src/clstepcore/ExpDict.h | 4 ++-- src/clstepcore/Registry.h | 2 +- src/clstepcore/STEPaggregate.h | 2 +- src/clstepcore/STEPattribute.h | 2 +- src/clstepcore/STEPcomplex.cc | 2 +- src/clstepcore/STEPcomplex.h | 2 +- src/clstepcore/collect.cc | 2 +- src/clstepcore/complexlist.cc | 2 +- src/clstepcore/create_Aggr.cc | 2 +- src/clstepcore/entlist.cc | 2 +- src/clstepcore/entnode.cc | 2 +- src/clstepcore/match-ors.cc | 2 +- src/clstepcore/multlist.cc | 2 +- src/clstepcore/non-ors.cc | 2 +- src/clstepcore/orlist.cc | 2 +- src/clstepcore/print.cc | 2 +- src/clstepcore/sdai.h | 2 +- src/clstepcore/test/test_operators_SDAI_Select.cc | 2 +- src/clstepcore/trynext.cc | 2 +- src/exp2cxx/multpass.c | 2 +- src/exp2cxx/write.cc | 4 ++-- src/exp2python/src/multpass_python.c | 2 +- src/test/scl2html/scl2html.cc | 2 +- 30 files changed, 30 insertions(+), 33 deletions(-) rename {src/clstepcore => include/core}/baseType.h (100%) rename {src/clstepcore => include/core}/complexSupport.h (100%) rename {src/clstepcore => include/core}/create_Aggr.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index 4129130a0..ade73c57e 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -2,9 +2,9 @@ set(CORE_HDRS aggrTypeDescriptor.h attrDescriptor.h attrDescriptorList.h -# baseType.h -# complexSupport.h -# create_Aggr.h + baseType.h + complexSupport.h + create_Aggr.h # derivedAttribute.h # dictSchema.h # dictdefs.h diff --git a/include/core/aggrTypeDescriptor.h b/include/core/aggrTypeDescriptor.h index 44282bb6c..3a08d56eb 100644 --- a/include/core/aggrTypeDescriptor.h +++ b/include/core/aggrTypeDescriptor.h @@ -2,7 +2,7 @@ #define AGGRTYPEDESCRIPTOR_H #include "typeDescriptor.h" -#include "create_Aggr.h" +#include "core/create_Aggr.h" #include "assert.h" diff --git a/src/clstepcore/baseType.h b/include/core/baseType.h similarity index 100% rename from src/clstepcore/baseType.h rename to include/core/baseType.h diff --git a/src/clstepcore/complexSupport.h b/include/core/complexSupport.h similarity index 100% rename from src/clstepcore/complexSupport.h rename to include/core/complexSupport.h diff --git a/src/clstepcore/create_Aggr.h b/include/core/create_Aggr.h similarity index 100% rename from src/clstepcore/create_Aggr.h rename to include/core/create_Aggr.h diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index a0868fbc6..256ef7356 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include "core/complexSupport.h" #include #include diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 845c37677..bb1fb7850 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,9 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - baseType.h - complexSupport.h - create_Aggr.h derivedAttribute.h dictSchema.h dictdefs.h diff --git a/src/clstepcore/ExpDict.h b/src/clstepcore/ExpDict.h index f59ca5fe4..b187ad762 100644 --- a/src/clstepcore/ExpDict.h +++ b/src/clstepcore/ExpDict.h @@ -23,7 +23,7 @@ #include -#include +#include "core/baseType.h" #include #include @@ -41,7 +41,7 @@ #include "derivedAttribute.h" #include "inverseAttribute.h" -#include "create_Aggr.h" +#include "core/create_Aggr.h" #include "dictionaryInstance.h" #include "uniquenessRule.h" diff --git a/src/clstepcore/Registry.h b/src/clstepcore/Registry.h index d4d4d4db0..d340bdd01 100644 --- a/src/clstepcore/Registry.h +++ b/src/clstepcore/Registry.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include "core/complexSupport.h" // defined and created in Registry.cc diff --git a/src/clstepcore/STEPaggregate.h b/src/clstepcore/STEPaggregate.h index df2178ee9..1b9f52193 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/src/clstepcore/STEPaggregate.h @@ -19,7 +19,7 @@ class TypeDescriptor; #include #include #include -#include +#include "core/baseType.h" #include #include #include diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 47b99e025..61fbeaf71 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include "core/baseType.h" #include diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index 13d67267e..f4576a20b 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -2,7 +2,7 @@ #include #include -#include +#include "core/complexSupport.h" #include #include #include diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index caf7ea255..f190ea7d7 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include "core/baseType.h" #include #include diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index 6f5ae75dc..255036c6a 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -11,7 +11,7 @@ * Date: 11/14/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Inserts a new ComplexList to our list. The ComplexLists are ordered by diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index 92dfecb1f..6d2df417b 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -10,7 +10,7 @@ * Date: 01/07/97 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Destructor for ComplexList. diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 72f6adb53..7bb13257d 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,4 +1,4 @@ -#include "create_Aggr.h" +#include "core/create_Aggr.h" #include EnumAggregate * create_EnumAggregate() { diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index 8b4cf98f0..086f3bd76 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -13,7 +13,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Returns the number of EntLists in this's list (EntList->next, next->next diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 81c05a6eb..0d594c993 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -11,7 +11,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Given a list of entity names, creates a sorted linked list of EntNodes diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index 915c95620..2a97254ab 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -13,7 +13,7 @@ * Date: 10/17/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Loops through descendants of this, invoking their matchOR functions. diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index f82dba642..9e30e5ab1 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -13,7 +13,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Deletes the childList of this, before this is deleted. diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index addc49522..78c3c5fe6 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -10,7 +10,7 @@ * Date: 10/17/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Checks if we match the nodes of ents. If only one unmarked is left diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index c829e4ae6..6e58242eb 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -10,7 +10,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" /** * Check if we matched nm. We have two possibilities here: If we have a diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index bd7ad8b7b..b30643b06 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -7,7 +7,7 @@ * Date: 10/31/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" // Local function prototypes: static char * joinText( JoinType, char * ); diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index 46ae3996b..065cf42c3 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -29,7 +29,7 @@ extern const char * SCLversion; #include "dictdefs.h" -#include "baseType.h" +#include "core/baseType.h" #include "Str.h" #include "errordesc.h" diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index fcb6cde4d..2d89a0a75 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -7,7 +7,7 @@ #include #include "ExpDict.h" -#include "baseType.h" +#include "core/baseType.h" #include "sdaiSelect.h" using namespace std; diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 3554cd378..4b9571a20 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -11,7 +11,7 @@ * Date: 10/24/96 * *****************************************************************************/ -#include "complexSupport.h" +#include "core/complexSupport.h" // Local function prototypes: static EntList * firstCandidate( EntList * ); diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index fbba2b271..50adf2eb1 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -159,7 +159,7 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files ) // which hasn't been closed yet. (That's done on 2nd line below.)) */ fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); fprintf( files->initall, "}\n\n" ); - fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \"core\/complexSupport.h\"\n" ); fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); /* Function GetModelContents() is printed at the end of the schema.xx diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index d864b3476..1d73dc46a 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -116,7 +116,7 @@ static void writeheader( ostream & os, int noLists ) << " * file, however, there are no complex entities, so this\n" << " * function is a stub.\n" << " */" << endl << endl; - os << "#include \"complexSupport.h\"\n\n"; + os << "#include \"core/complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << "{" << endl; return; @@ -128,7 +128,7 @@ static void writeheader( ostream & os, int noLists ) << " * support structures. The structures will be used in the SCL to\n" << " * validate user requests to instantiate complex entities.\n" << " */" << endl << endl; - os << "#include \"complexSupport.h\"\n\n"; + os << "#include \"core/complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << " /*" << endl << " * This function contains instantiation statements for all the\n" diff --git a/src/exp2python/src/multpass_python.c b/src/exp2python/src/multpass_python.c index bbc8a6611..a4204c1c8 100644 --- a/src/exp2python/src/multpass_python.c +++ b/src/exp2python/src/multpass_python.c @@ -150,7 +150,7 @@ void print_schemas_separate( Express express, FILES * files ) // which hasn't been closed yet. (That's done on 2nd line below.)) * / //fprintf( files->initall, "\t reg.SetCompCollect( gencomplex() );\n" ); //fprintf( files->initall, "}\n\n" ); - //fprintf( files->incall, "\n#include \n" ); + //fprintf( files->incall, "\n#include \"core/complexSupport.h\"\n" ); //fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); */ /* Function GetModelContents() is printed at the end of the schema.xx diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index f597b36e4..72160c7df 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -49,7 +49,7 @@ void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtml ) { std::string buf; - // The type. See src/clstepcore/baseType.h for info + // The type. See core/baseType.h for info PrimitiveType base = typeDesc->Type(); // the type descriptor for the "referent type," if any. From 8a7e0af3b5a0cbcedbc58f928b025294549a931c Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 09:13:51 -0400 Subject: [PATCH 224/244] See if we can script some of the move process --- include/core/CMakeLists.txt | 2 +- {src/clstepcore => include/core}/derivedAttribute.h | 0 misc/header_mv.sh | 4 ++++ src/clstepcore/ExpDict.h | 2 +- src/clstepcore/derivedAttribute.cc | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) rename {src/clstepcore => include/core}/derivedAttribute.h (100%) create mode 100755 misc/header_mv.sh diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index ade73c57e..7089bfd88 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -5,7 +5,7 @@ set(CORE_HDRS baseType.h complexSupport.h create_Aggr.h -# derivedAttribute.h + derivedAttribute.h # dictSchema.h # dictdefs.h # dictionaryInstance.h diff --git a/src/clstepcore/derivedAttribute.h b/include/core/derivedAttribute.h similarity index 100% rename from src/clstepcore/derivedAttribute.h rename to include/core/derivedAttribute.h diff --git a/misc/header_mv.sh b/misc/header_mv.sh new file mode 100755 index 000000000..3a7690876 --- /dev/null +++ b/misc/header_mv.sh @@ -0,0 +1,4 @@ +#!/bin/bash +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; + diff --git a/src/clstepcore/ExpDict.h b/src/clstepcore/ExpDict.h index b187ad762..7835ff341 100644 --- a/src/clstepcore/ExpDict.h +++ b/src/clstepcore/ExpDict.h @@ -38,7 +38,7 @@ #include "entityDescriptor.h" #include "enumTypeDescriptor.h" #include "core/attrDescriptor.h" -#include "derivedAttribute.h" +#include "core/derivedAttribute.h" #include "inverseAttribute.h" #include "core/create_Aggr.h" diff --git a/src/clstepcore/derivedAttribute.cc b/src/clstepcore/derivedAttribute.cc index 7fca3b16f..d361ca1be 100644 --- a/src/clstepcore/derivedAttribute.cc +++ b/src/clstepcore/derivedAttribute.cc @@ -1,4 +1,4 @@ -#include "derivedAttribute.h" +#include "core/derivedAttribute.h" Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType, Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner ) From 94c978359de09cb9b2a926e71b82ccc73997b136 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 09:20:21 -0400 Subject: [PATCH 225/244] Move d* headers in clstepcore --- include/core/CMakeLists.txt | 10 +++++----- {src/clstepcore => include/core}/dictSchema.h | 0 {src/clstepcore => include/core}/dictdefs.h | 0 {src/clstepcore => include/core}/dictionaryInstance.h | 0 {src/clstepcore => include/core}/dispnode.h | 0 {src/clstepcore => include/core}/dispnodelist.h | 2 +- src/cleditor/cmdmgr.h | 4 ++-- src/clstepcore/CMakeLists.txt | 6 ------ src/clstepcore/ExpDict.h | 6 +++--- src/clstepcore/dictSchema.cc | 2 +- src/clstepcore/dispnode.cc | 4 ++-- src/clstepcore/dispnodelist.cc | 4 ++-- src/clstepcore/globalRule.h | 2 +- src/clstepcore/instmgr.h | 4 ++-- src/clstepcore/interfaceSpec.h | 2 +- src/clstepcore/interfacedItem.h | 2 +- src/clstepcore/mgrnode.cc | 4 ++-- src/clstepcore/mgrnodelist.cc | 4 ++-- src/clstepcore/sdai.h | 2 +- src/clstepcore/typeDescriptor.h | 2 +- src/clstepcore/typeOrRuleVar.h | 2 +- src/clstepcore/uniquenessRule.h | 2 +- src/clstepcore/whereRule.h | 2 +- 23 files changed, 30 insertions(+), 36 deletions(-) rename {src/clstepcore => include/core}/dictSchema.h (100%) rename {src/clstepcore => include/core}/dictdefs.h (100%) rename {src/clstepcore => include/core}/dictionaryInstance.h (100%) rename {src/clstepcore => include/core}/dispnode.h (100%) rename {src/clstepcore => include/core}/dispnodelist.h (98%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index 7089bfd88..b41ebd4a4 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -6,11 +6,11 @@ set(CORE_HDRS complexSupport.h create_Aggr.h derivedAttribute.h -# dictSchema.h -# dictdefs.h -# dictionaryInstance.h -# dispnode.h -# dispnodelist.h + dictSchema.h + dictdefs.h + dictionaryInstance.h + dispnode.h + dispnodelist.h # entityDescriptor.h # entityDescriptorList.h # enumTypeDescriptor.h diff --git a/src/clstepcore/dictSchema.h b/include/core/dictSchema.h similarity index 100% rename from src/clstepcore/dictSchema.h rename to include/core/dictSchema.h diff --git a/src/clstepcore/dictdefs.h b/include/core/dictdefs.h similarity index 100% rename from src/clstepcore/dictdefs.h rename to include/core/dictdefs.h diff --git a/src/clstepcore/dictionaryInstance.h b/include/core/dictionaryInstance.h similarity index 100% rename from src/clstepcore/dictionaryInstance.h rename to include/core/dictionaryInstance.h diff --git a/src/clstepcore/dispnode.h b/include/core/dispnode.h similarity index 100% rename from src/clstepcore/dispnode.h rename to include/core/dispnode.h diff --git a/src/clstepcore/dispnodelist.h b/include/core/dispnodelist.h similarity index 98% rename from src/clstepcore/dispnodelist.h rename to include/core/dispnodelist.h index c4fe4dde3..c67dcfd11 100644 --- a/src/clstepcore/dispnodelist.h +++ b/include/core/dispnodelist.h @@ -21,7 +21,7 @@ //#include #include #include -#include +#include "core/dispnode.h" #include /////////////////////////////////////////////////////////////////////////////// diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index c9c45b404..41c37f2e6 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" #include //#define NUM_CMDMGR_CMDS 9 diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index bb1fb7850..e97911dd5 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,12 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - derivedAttribute.h - dictSchema.h - dictdefs.h - dictionaryInstance.h - dispnode.h - dispnodelist.h entityDescriptor.h entityDescriptorList.h enumTypeDescriptor.h diff --git a/src/clstepcore/ExpDict.h b/src/clstepcore/ExpDict.h index 7835ff341..7974b93fb 100644 --- a/src/clstepcore/ExpDict.h +++ b/src/clstepcore/ExpDict.h @@ -24,7 +24,7 @@ #include #include "core/baseType.h" -#include +#include "core/dictdefs.h" #include // each of these contains linked list, list node, iterator @@ -42,7 +42,7 @@ #include "inverseAttribute.h" #include "core/create_Aggr.h" -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "uniquenessRule.h" #include "whereRule.h" @@ -53,7 +53,7 @@ #include "interfaceSpec.h" #include "typeOrRuleVar.h" #include "globalRule.h" -#include "dictSchema.h" +#include "core/dictSchema.h" #include "schRename.h" #include "core/aggrTypeDescriptor.h" diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 11170d4df..3b3b7e494 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -1,4 +1,4 @@ -#include "dictSchema.h" +#include "core/dictSchema.h" #include "typeDescriptor.h" #include "entityDescriptor.h" diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 3756143bc..6950a0e6e 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -16,8 +16,8 @@ #include //#include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" // define this to be the name of the display object class StepEntityEditor; diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index 66761e3a3..7f947f9d5 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -17,8 +17,8 @@ #include #include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" void DisplayNodeList::Remove( GenericNode * node ) { GenNodeList::Remove( node ); diff --git a/src/clstepcore/globalRule.h b/src/clstepcore/globalRule.h index ffd1200fd..2fe3ee14f 100644 --- a/src/clstepcore/globalRule.h +++ b/src/clstepcore/globalRule.h @@ -1,7 +1,7 @@ #ifndef GLOBALRULE_H #define GLOBALRULE_H -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "whereRule.h" #include "entityDescriptorList.h" diff --git a/src/clstepcore/instmgr.h b/src/clstepcore/instmgr.h index 3f185b3fb..d45900ead 100644 --- a/src/clstepcore/instmgr.h +++ b/src/clstepcore/instmgr.h @@ -34,8 +34,8 @@ #include #include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" #include diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index 0b61b4b04..6ab0a4563 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -1,7 +1,7 @@ #ifndef INTERFACESPEC_H #define INTERFACESPEC_H -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "explicitItemId.h" #include "implicitItemId.h" diff --git a/src/clstepcore/interfacedItem.h b/src/clstepcore/interfacedItem.h index 00401b68b..5084cab60 100644 --- a/src/clstepcore/interfacedItem.h +++ b/src/clstepcore/interfacedItem.h @@ -1,7 +1,7 @@ #ifndef INTERFACEDITEM_H #define INTERFACEDITEM_H -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "sdai.h" diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 00caf283e..11c122ad2 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -14,8 +14,8 @@ #include #include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" #include //#include diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index a52870f56..d8b835ded 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -14,8 +14,8 @@ #include #include -#include -#include +#include "core/dispnode.h" +#include "core/dispnodelist.h" MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { // if(debug_level >= PrintFunctionTrace) diff --git a/src/clstepcore/sdai.h b/src/clstepcore/sdai.h index 065cf42c3..11a1c7588 100644 --- a/src/clstepcore/sdai.h +++ b/src/clstepcore/sdai.h @@ -27,7 +27,7 @@ extern const char * SCLversion; #include -#include "dictdefs.h" +#include "core/dictdefs.h" #include "core/baseType.h" #include "Str.h" diff --git a/src/clstepcore/typeDescriptor.h b/src/clstepcore/typeDescriptor.h index 7fb53a53c..a3e64a33b 100644 --- a/src/clstepcore/typeDescriptor.h +++ b/src/clstepcore/typeDescriptor.h @@ -3,7 +3,7 @@ #include "schRename.h" #include "whereRule.h" -#include "dictSchema.h" +#include "core/dictSchema.h" #include "sc_export.h" diff --git a/src/clstepcore/typeOrRuleVar.h b/src/clstepcore/typeOrRuleVar.h index 09f78da59..9fa58be34 100644 --- a/src/clstepcore/typeOrRuleVar.h +++ b/src/clstepcore/typeOrRuleVar.h @@ -1,7 +1,7 @@ #ifndef TYPEORRULEVAR_H #define TYPEORRULEVAR_H -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "sc_export.h" diff --git a/src/clstepcore/uniquenessRule.h b/src/clstepcore/uniquenessRule.h index 4751ce97b..2ce576b66 100644 --- a/src/clstepcore/uniquenessRule.h +++ b/src/clstepcore/uniquenessRule.h @@ -1,7 +1,7 @@ #ifndef UNIQUENESSRULE_H #define UNIQUENESSRULE_H -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "sdai.h" diff --git a/src/clstepcore/whereRule.h b/src/clstepcore/whereRule.h index ef9043a4b..7c36ec1ee 100644 --- a/src/clstepcore/whereRule.h +++ b/src/clstepcore/whereRule.h @@ -3,7 +3,7 @@ #include #include "sdai.h" -#include "dictionaryInstance.h" +#include "core/dictionaryInstance.h" #include "typeOrRuleVar.h" #include "sc_export.h" From 9d1583be630658c6b4c27c41cd7bf321e6ff1f16 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:20:10 -0400 Subject: [PATCH 226/244] Move the e* clstepcore headers --- include/core/CMakeLists.txt | 12 ++++++------ {src/clstepcore => include/core}/ExpDict.h | 0 {src/clstepcore => include/core}/entityDescriptor.h | 0 .../core}/entityDescriptorList.h | 0 .../clstepcore => include/core}/enumTypeDescriptor.h | 0 {src/clstepcore => include/core}/explicitItemId.h | 0 {src/clstepcore => include/core}/globalRule.h | 0 misc/header_mv.sh | 4 ++-- src/cleditor/SdaiHeaderSchema.cc | 2 +- src/cleditor/SdaiHeaderSchemaInit.cc | 2 +- src/cleditor/SdaiSchemaInit.h | 2 +- src/cllazyfile/lazyRefs.h | 2 +- src/clstepcore/CMakeLists.txt | 6 ------ src/clstepcore/Registry.cc | 2 +- src/clstepcore/STEPaggregate.cc | 2 +- src/clstepcore/STEPattribute.cc | 2 +- src/clstepcore/STEPcomplex.h | 2 +- src/clstepcore/STEPinvAttrList.cc | 2 +- src/clstepcore/SubSuperIterators.h | 4 ++-- src/clstepcore/dictSchema.cc | 2 +- src/clstepcore/entityDescriptor.cc | 2 +- src/clstepcore/entityDescriptorList.cc | 2 +- src/clstepcore/enumTypeDescriptor.cc | 2 +- src/clstepcore/explicitItemId.cc | 2 +- src/clstepcore/globalRule.cc | 2 +- src/clstepcore/interfaceSpec.h | 2 +- src/clstepcore/sdaiSelect.cc | 2 +- src/clstepcore/superInvAttrIter.h | 2 +- src/clstepcore/test/test_SupertypesIterator.cc | 2 +- src/clstepcore/test/test_null_attr.cc | 2 +- src/clstepcore/test/test_operators_SDAI_Select.cc | 2 +- src/clstepcore/test/test_operators_STEPattribute.cc | 2 +- src/exp2cxx/classes_wrapper.cc | 2 +- src/test/p21read/p21read.cc | 2 +- src/test/tests.h | 2 +- 35 files changed, 35 insertions(+), 41 deletions(-) rename {src/clstepcore => include/core}/ExpDict.h (100%) rename {src/clstepcore => include/core}/entityDescriptor.h (100%) rename {src/clstepcore => include/core}/entityDescriptorList.h (100%) rename {src/clstepcore => include/core}/enumTypeDescriptor.h (100%) rename {src/clstepcore => include/core}/explicitItemId.h (100%) rename {src/clstepcore => include/core}/globalRule.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index b41ebd4a4..14f279243 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -11,12 +11,12 @@ set(CORE_HDRS dictionaryInstance.h dispnode.h dispnodelist.h -# entityDescriptor.h -# entityDescriptorList.h -# enumTypeDescriptor.h -# ExpDict.h -# explicitItemId.h -# globalRule.h + entityDescriptor.h + entityDescriptorList.h + enumTypeDescriptor.h + ExpDict.h + explicitItemId.h + globalRule.h # implicitItemId.h # instmgr.h # interfaceSpec.h diff --git a/src/clstepcore/ExpDict.h b/include/core/ExpDict.h similarity index 100% rename from src/clstepcore/ExpDict.h rename to include/core/ExpDict.h diff --git a/src/clstepcore/entityDescriptor.h b/include/core/entityDescriptor.h similarity index 100% rename from src/clstepcore/entityDescriptor.h rename to include/core/entityDescriptor.h diff --git a/src/clstepcore/entityDescriptorList.h b/include/core/entityDescriptorList.h similarity index 100% rename from src/clstepcore/entityDescriptorList.h rename to include/core/entityDescriptorList.h diff --git a/src/clstepcore/enumTypeDescriptor.h b/include/core/enumTypeDescriptor.h similarity index 100% rename from src/clstepcore/enumTypeDescriptor.h rename to include/core/enumTypeDescriptor.h diff --git a/src/clstepcore/explicitItemId.h b/include/core/explicitItemId.h similarity index 100% rename from src/clstepcore/explicitItemId.h rename to include/core/explicitItemId.h diff --git a/src/clstepcore/globalRule.h b/include/core/globalRule.h similarity index 100% rename from src/clstepcore/globalRule.h rename to include/core/globalRule.h diff --git a/misc/header_mv.sh b/misc/header_mv.sh index 3a7690876..6e3170786 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -1,4 +1,4 @@ #!/bin/bash -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index af08cb2e3..f013606b9 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -10,7 +10,7 @@ extern ofstream * logStream; #define SCLLOGFILE "scl.log" #endif -#include +#include "core/ExpDict.h" #include #include diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 1c9f691ab..e0bbb9247 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -5,7 +5,7 @@ // regenerate it. #include -#include +#include "core/ExpDict.h" #include #include diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index 256ef7356..fe5bc387a 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include "core/ExpDict.h" #include #include "core/complexSupport.h" diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 723dd0998..bcfa3fa9b 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -9,7 +9,7 @@ #include "sc_export.h" #include "lazyTypes.h" #include "lazyInstMgr.h" -#include "ExpDict.h" +#include "core/ExpDict.h" #include "SubSuperIterators.h" #include #include diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index e97911dd5..fea36750b 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,12 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - entityDescriptor.h - entityDescriptorList.h - enumTypeDescriptor.h - ExpDict.h - explicitItemId.h - globalRule.h implicitItemId.h instmgr.h interfaceSpec.h diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 851e9e3bf..4cf6a7f0c 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -9,7 +9,7 @@ * and is not subject to copyright. */ -#include +#include "core/ExpDict.h" #include /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 2226d1713..036501ea3 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include "core/ExpDict.h" /** diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 83d21fe3b..8f1a9625e 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include "core/ExpDict.h" #include // REAL_NUM_PRECISION is defined in STEPattribute.h, and is also used diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index f190ea7d7..8225ec8c2 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -5,7 +5,7 @@ #include #include #include "core/baseType.h" -#include +#include "core/ExpDict.h" #include #include diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index 991a7d98c..b8f4a824b 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -4,7 +4,7 @@ */ #include -#include +#include "core/ExpDict.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 ) {} diff --git a/src/clstepcore/SubSuperIterators.h b/src/clstepcore/SubSuperIterators.h index 9ca78765b..b70c4bde7 100644 --- a/src/clstepcore/SubSuperIterators.h +++ b/src/clstepcore/SubSuperIterators.h @@ -1,8 +1,8 @@ #ifndef SUB_SUPER_ITERATORS #define SUB_SUPER_ITERATORS -#include "ExpDict.h" -#include "ExpDict.h" +#include "core/ExpDict.h" +#include "core/ExpDict.h" #include #include diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 3b3b7e494..5e739287c 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -1,7 +1,7 @@ #include "core/dictSchema.h" #include "typeDescriptor.h" -#include "entityDescriptor.h" +#include "core/entityDescriptor.h" Schema::Schema( const char * schemaName ) : _use_interface_list( new Interface_spec__set ), diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index f8fb6a2d0..6816fc492 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -1,6 +1,6 @@ #include -#include "entityDescriptor.h" +#include "core/entityDescriptor.h" #include "Registry.h" #include "core/attrDescriptor.h" #include "inverseAttribute.h" diff --git a/src/clstepcore/entityDescriptorList.cc b/src/clstepcore/entityDescriptorList.cc index 86d937c76..bef52120a 100644 --- a/src/clstepcore/entityDescriptorList.cc +++ b/src/clstepcore/entityDescriptorList.cc @@ -1,4 +1,4 @@ -#include "entityDescriptorList.h" +#include "core/entityDescriptorList.h" EntityDescLinkNode::EntityDescLinkNode() { _entityDesc = 0; diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 9598702f0..653a1cc0d 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "enumTypeDescriptor.h" +#include "core/enumTypeDescriptor.h" /* * why have EnumTypeDescriptor + EnumerationTypeDescriptor ??? diff --git a/src/clstepcore/explicitItemId.cc b/src/clstepcore/explicitItemId.cc index c229f6369..8436befd5 100644 --- a/src/clstepcore/explicitItemId.cc +++ b/src/clstepcore/explicitItemId.cc @@ -1,4 +1,4 @@ -#include "explicitItemId.h" +#include "core/explicitItemId.h" Explicit_item_id::Explicit_item_id() { _local_definition = 0; diff --git a/src/clstepcore/globalRule.cc b/src/clstepcore/globalRule.cc index b6fdeb19a..06629f2c1 100644 --- a/src/clstepcore/globalRule.cc +++ b/src/clstepcore/globalRule.cc @@ -1,4 +1,4 @@ -#include "globalRule.h" +#include "core/globalRule.h" Global_rule::Global_rule() : _entities( 0 ), _where_rules( 0 ), _parent_schema( 0 ) { diff --git a/src/clstepcore/interfaceSpec.h b/src/clstepcore/interfaceSpec.h index 6ab0a4563..f0b4bde19 100644 --- a/src/clstepcore/interfaceSpec.h +++ b/src/clstepcore/interfaceSpec.h @@ -2,7 +2,7 @@ #define INTERFACESPEC_H #include "core/dictionaryInstance.h" -#include "explicitItemId.h" +#include "core/explicitItemId.h" #include "implicitItemId.h" #include "sc_export.h" diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 08e789a6d..060a7b149 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -11,7 +11,7 @@ */ #include // to get the BUFSIZ #define -#include +#include "core/ExpDict.h" #include #include #include diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index bfe73dc17..4b7a02a1d 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -2,7 +2,7 @@ #define SUPERINVATTRITER_H #include "SubSuperIterators.h" -#include "ExpDict.h" +#include "core/ExpDict.h" /** * this class implements an iterator for inverse attributes in an EntityDescriptor's supertypes diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index f557d7c72..9fe2a54b7 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -5,7 +5,7 @@ //subtypesiterator shouldn't need tested separately from supertypesiterator since there is very little difference #include "SubSuperIterators.h" -#include "ExpDict.h" +#include "core/ExpDict.h" #include int main( int /*argc*/, char ** /*argv*/ ) { diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index 0c96c5798..cb7064ebb 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -1,4 +1,4 @@ -#include +#include "core/ExpDict.h" #include #include diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index 2d89a0a75..83e0f6469 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -6,7 +6,7 @@ #include -#include "ExpDict.h" +#include "core/ExpDict.h" #include "core/baseType.h" #include "sdaiSelect.h" diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index abd396816..cc14cb102 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -1,7 +1,7 @@ ///test constructors, destructor, shallow copy, assignment operators for STEPattribute #include -#include +#include "core/ExpDict.h" #include diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 3d9151178..69487ef32 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -79,7 +79,7 @@ void print_file_header( FILES * files ) { fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \"core/ExpDict.h\"\n" ); fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \n" ); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index c8faddd52..b9b0a9b0e 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -16,7 +16,7 @@ extern void SchemaInit( class Registry & ); #include #include #include -#include +#include "core/ExpDict.h" #include #include #include diff --git a/src/test/tests.h b/src/test/tests.h index 52fcb3a59..85b3b010c 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -16,7 +16,7 @@ #include /* General SCL stuff */ -#include +#include "core/ExpDict.h" #include #include #include From 6e53c8f83365b411ad12dbded9b1f79fb6c58355 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:24:21 -0400 Subject: [PATCH 227/244] Relocate i* stepcore headers --- {src/clstepcore => include/core}/implicitItemId.h | 0 {src/clstepcore => include/core}/instmgr.h | 0 {src/clstepcore => include/core}/interfaceSpec.h | 0 {src/clstepcore => include/core}/interfacedItem.h | 0 {src/clstepcore => include/core}/inverseAttribute.h | 0 {src/clstepcore => include/core}/inverseAttributeList.h | 0 src/cleditor/STEPfile.h | 2 +- src/cllazyfile/instMgrHelper.h | 2 +- src/clstepcore/STEPaggregate.cc | 2 +- src/clstepcore/STEPattribute.cc | 2 +- src/clstepcore/entityDescriptor.cc | 2 +- src/clstepcore/implicitItemId.cc | 2 +- src/clstepcore/instmgr.cc | 2 +- src/clstepcore/interfaceSpec.cc | 2 +- src/clstepcore/interfacedItem.cc | 2 +- src/clstepcore/inverseAttribute.cc | 2 +- src/clstepcore/inverseAttributeList.cc | 4 ++-- src/clstepcore/mgrnode.cc | 2 +- src/clstepcore/sdaiApplication_instance.cc | 2 +- 19 files changed, 14 insertions(+), 14 deletions(-) rename {src/clstepcore => include/core}/implicitItemId.h (100%) rename {src/clstepcore => include/core}/instmgr.h (100%) rename {src/clstepcore => include/core}/interfaceSpec.h (100%) rename {src/clstepcore => include/core}/interfacedItem.h (100%) rename {src/clstepcore => include/core}/inverseAttribute.h (100%) rename {src/clstepcore => include/core}/inverseAttributeList.h (100%) diff --git a/src/clstepcore/implicitItemId.h b/include/core/implicitItemId.h similarity index 100% rename from src/clstepcore/implicitItemId.h rename to include/core/implicitItemId.h diff --git a/src/clstepcore/instmgr.h b/include/core/instmgr.h similarity index 100% rename from src/clstepcore/instmgr.h rename to include/core/instmgr.h diff --git a/src/clstepcore/interfaceSpec.h b/include/core/interfaceSpec.h similarity index 100% rename from src/clstepcore/interfaceSpec.h rename to include/core/interfaceSpec.h diff --git a/src/clstepcore/interfacedItem.h b/include/core/interfacedItem.h similarity index 100% rename from src/clstepcore/interfacedItem.h rename to include/core/interfacedItem.h diff --git a/src/clstepcore/inverseAttribute.h b/include/core/inverseAttribute.h similarity index 100% rename from src/clstepcore/inverseAttribute.h rename to include/core/inverseAttribute.h diff --git a/src/clstepcore/inverseAttributeList.h b/include/core/inverseAttributeList.h similarity index 100% rename from src/clstepcore/inverseAttributeList.h rename to include/core/inverseAttributeList.h diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index 37c7d20bc..402473ef0 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -15,7 +15,7 @@ #include #include -#include +#include "core/instmgr.h" #include #include #include diff --git a/src/cllazyfile/instMgrHelper.h b/src/cllazyfile/instMgrHelper.h index 659f1ec8e..16588cf1e 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/src/cllazyfile/instMgrHelper.h @@ -5,7 +5,7 @@ #include #include -#include +#include "core/instmgr.h" /** * \file instMgrHelper.h helper classes for the lazyInstMgr. Allows use of SDAI_Application_instance class diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 036501ea3..0f9620f57 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include "core/instmgr.h" #include "core/ExpDict.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 8f1a9625e..fa67b3e40 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -14,7 +14,7 @@ #include #include -#include +#include "core/instmgr.h" #include #include #include "core/ExpDict.h" diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 6816fc492..6b816d67d 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -3,7 +3,7 @@ #include "core/entityDescriptor.h" #include "Registry.h" #include "core/attrDescriptor.h" -#include "inverseAttribute.h" +#include "core/inverseAttribute.h" #include "SubSuperIterators.h" EntityDescriptor::EntityDescriptor( ) diff --git a/src/clstepcore/implicitItemId.cc b/src/clstepcore/implicitItemId.cc index 1961727af..dd43fc1f1 100644 --- a/src/clstepcore/implicitItemId.cc +++ b/src/clstepcore/implicitItemId.cc @@ -1,4 +1,4 @@ -#include "implicitItemId.h" +#include "core/implicitItemId.h" Implicit_item_id::Implicit_item_id() { _local_definition = 0; diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 691167f6d..2da10f762 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -17,7 +17,7 @@ ////////////////////////////////////////////////////////////////////////////// #include -#include +#include "core/instmgr.h" /////////////////////////////////////////////////////////////////////////////// // debug_level >= 2 => tells when a command is chosen diff --git a/src/clstepcore/interfaceSpec.cc b/src/clstepcore/interfaceSpec.cc index eb0fecf3a..c8698789e 100644 --- a/src/clstepcore/interfaceSpec.cc +++ b/src/clstepcore/interfaceSpec.cc @@ -1,4 +1,4 @@ -#include "interfaceSpec.h" +#include "core/interfaceSpec.h" Interface_spec__set::Interface_spec__set( int defaultSize ) { _bufsize = defaultSize; diff --git a/src/clstepcore/interfacedItem.cc b/src/clstepcore/interfacedItem.cc index 749a5922e..aadfce68d 100644 --- a/src/clstepcore/interfacedItem.cc +++ b/src/clstepcore/interfacedItem.cc @@ -1,4 +1,4 @@ -#include "interfacedItem.h" +#include "core/interfacedItem.h" Interfaced_item::Interfaced_item() { } diff --git a/src/clstepcore/inverseAttribute.cc b/src/clstepcore/inverseAttribute.cc index eeccec90a..be7f7cfa3 100644 --- a/src/clstepcore/inverseAttribute.cc +++ b/src/clstepcore/inverseAttribute.cc @@ -1,4 +1,4 @@ -#include "inverseAttribute.h" +#include "core/inverseAttribute.h" #include const char * Inverse_attribute::AttrExprDefStr( std::string & s ) const { diff --git a/src/clstepcore/inverseAttributeList.cc b/src/clstepcore/inverseAttributeList.cc index 22591d41c..e1767e3b3 100644 --- a/src/clstepcore/inverseAttributeList.cc +++ b/src/clstepcore/inverseAttributeList.cc @@ -1,5 +1,5 @@ -#include "inverseAttributeList.h" -#include "inverseAttribute.h" +#include "core/inverseAttributeList.h" +#include "core/inverseAttribute.h" Inverse_attributeLinkNode::Inverse_attributeLinkNode() { _invAttr = 0; diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 11c122ad2..f2d4a389d 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -17,7 +17,7 @@ #include "core/dispnode.h" #include "core/dispnodelist.h" -#include +#include "core/instmgr.h" //#include #include diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index de5d19b76..c1c9b129d 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -12,7 +12,7 @@ #include #include -#include +#include "core/instmgr.h" #include #include #include //for ReadTokenSeparator, used when comments are inside entities From fc4edb9b069e5f2535cb38f881e8953054e9fcf7 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:32:25 -0400 Subject: [PATCH 228/244] Move stepcore headers through r* --- include/core/CMakeLists.txt | 26 +++++++++---------- {src/clstepcore => include/core}/Registry.h | 0 include/core/dispnodelist.h | 2 +- include/core/instmgr.h | 6 ++--- {src/clstepcore => include/core}/mgrnode.h | 0 .../core}/mgrnodearray.h | 4 +-- .../clstepcore => include/core}/mgrnodelist.h | 0 {src/clstepcore => include/core}/needFunc.h | 0 {src/clstepcore => include/core}/read_func.h | 0 .../core}/realTypeDescriptor.h | 0 src/cleditor/STEPfile.h | 4 +-- src/cleditor/SdaiHeaderSchema.h | 2 +- src/cleditor/SdaiHeaderSchemaInit.cc | 2 +- src/cleditor/SdaiSchemaInit.h | 2 +- src/cleditor/cmdmgr.h | 4 +-- src/cllazyfile/instMgrHelper.h | 2 +- src/cllazyfile/lazyInstMgr.cc | 2 +- src/cllazyfile/lazyInstMgr.h | 2 +- src/cllazyfile/sectionReader.cc | 4 +-- src/clstepcore/CMakeLists.txt | 13 ---------- src/clstepcore/Registry.cc | 2 +- src/clstepcore/STEPaggregate.cc | 2 +- src/clstepcore/STEPattribute.cc | 2 +- src/clstepcore/STEPcomplex.h | 2 +- src/clstepcore/STEPundefined.h | 2 +- src/clstepcore/dispnodelist.cc | 4 +-- src/clstepcore/entityDescriptor.cc | 2 +- src/clstepcore/mgrnode.cc | 4 +-- src/clstepcore/mgrnodearray.cc | 2 +- src/clstepcore/mgrnodelist.cc | 4 +-- src/clstepcore/needFunc.cc | 2 +- src/clstepcore/read_func.cc | 2 +- src/clstepcore/sdaiApplication_instance.cc | 2 +- src/exp2cxx/classes_wrapper.cc | 4 +-- src/test/p21read/p21read.cc | 2 +- 35 files changed, 50 insertions(+), 63 deletions(-) rename {src/clstepcore => include/core}/Registry.h (100%) rename {src/clstepcore => include/core}/mgrnode.h (100%) rename {src/clstepcore => include/core}/mgrnodearray.h (98%) rename {src/clstepcore => include/core}/mgrnodelist.h (100%) rename {src/clstepcore => include/core}/needFunc.h (100%) rename {src/clstepcore => include/core}/read_func.h (100%) rename {src/clstepcore => include/core}/realTypeDescriptor.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index 14f279243..de22dfee7 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -17,19 +17,19 @@ set(CORE_HDRS ExpDict.h explicitItemId.h globalRule.h -# implicitItemId.h -# instmgr.h -# interfaceSpec.h -# interfacedItem.h -# inverseAttribute.h -# inverseAttributeList.h -# mgrnode.h -# mgrnodearray.h -# mgrnodelist.h -# needFunc.h -# read_func.h -# realTypeDescriptor.h -# Registry.h + implicitItemId.h + instmgr.h + interfaceSpec.h + interfacedItem.h + inverseAttribute.h + inverseAttributeList.h + mgrnode.h + mgrnodearray.h + mgrnodelist.h + needFunc.h + read_func.h + realTypeDescriptor.h + Registry.h # schRename.h # sdai.h # sdaiApplication_instance.h diff --git a/src/clstepcore/Registry.h b/include/core/Registry.h similarity index 100% rename from src/clstepcore/Registry.h rename to include/core/Registry.h diff --git a/include/core/dispnodelist.h b/include/core/dispnodelist.h index c67dcfd11..88da55f76 100644 --- a/include/core/dispnodelist.h +++ b/include/core/dispnodelist.h @@ -20,7 +20,7 @@ #include //#include #include -#include +#include "core/mgrnode.h" #include "core/dispnode.h" #include diff --git a/include/core/instmgr.h b/include/core/instmgr.h index d45900ead..94f334982 100644 --- a/include/core/instmgr.h +++ b/include/core/instmgr.h @@ -31,13 +31,13 @@ #include #include -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" -#include +#include "core/mgrnodearray.h" class SC_CORE_EXPORT InstMgrBase { public: diff --git a/src/clstepcore/mgrnode.h b/include/core/mgrnode.h similarity index 100% rename from src/clstepcore/mgrnode.h rename to include/core/mgrnode.h diff --git a/src/clstepcore/mgrnodearray.h b/include/core/mgrnodearray.h similarity index 98% rename from src/clstepcore/mgrnodearray.h rename to include/core/mgrnodearray.h index 22019d071..05a11dff9 100644 --- a/src/clstepcore/mgrnodearray.h +++ b/include/core/mgrnodearray.h @@ -23,8 +23,8 @@ #include //#include -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include diff --git a/src/clstepcore/mgrnodelist.h b/include/core/mgrnodelist.h similarity index 100% rename from src/clstepcore/mgrnodelist.h rename to include/core/mgrnodelist.h diff --git a/src/clstepcore/needFunc.h b/include/core/needFunc.h similarity index 100% rename from src/clstepcore/needFunc.h rename to include/core/needFunc.h diff --git a/src/clstepcore/read_func.h b/include/core/read_func.h similarity index 100% rename from src/clstepcore/read_func.h rename to include/core/read_func.h diff --git a/src/clstepcore/realTypeDescriptor.h b/include/core/realTypeDescriptor.h similarity index 100% rename from src/clstepcore/realTypeDescriptor.h rename to include/core/realTypeDescriptor.h diff --git a/src/cleditor/STEPfile.h b/src/cleditor/STEPfile.h index 402473ef0..316fe2b34 100644 --- a/src/cleditor/STEPfile.h +++ b/src/cleditor/STEPfile.h @@ -16,13 +16,13 @@ #include #include #include "core/instmgr.h" -#include +#include "core/Registry.h" #include #include #include #include -#include +#include "core/read_func.h" //error reporting level #define READ_COMPLETE 10 diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index 7cd45d848..c57dc582d 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -6,7 +6,7 @@ #include #include -#include +#include "core/Registry.h" #include #include #include diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index e0bbb9247..2f906e30c 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -4,7 +4,7 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include +#include "core/Registry.h" #include "core/ExpDict.h" #include #include diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index fe5bc387a..a4dc6f740 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -10,7 +10,7 @@ #include #include -#include +#include "core/Registry.h" #include #include #include "core/ExpDict.h" diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 41c37f2e6..2d2651db3 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -18,8 +18,8 @@ #include #include -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" #include diff --git a/src/cllazyfile/instMgrHelper.h b/src/cllazyfile/instMgrHelper.h index 16588cf1e..b6cf550b7 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/src/cllazyfile/instMgrHelper.h @@ -3,7 +3,7 @@ #include -#include +#include "core/mgrnode.h" #include #include "core/instmgr.h" diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 7ce253ee9..f2a4f3867 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -1,6 +1,6 @@ #include "lazyTypes.h" #include "lazyInstMgr.h" -#include "Registry.h" +#include "core/Registry.h" #include #include "SdaiSchemaInit.h" #include "instMgrHelper.h" diff --git a/src/cllazyfile/lazyInstMgr.h b/src/cllazyfile/lazyInstMgr.h index 881031620..689f611a5 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/src/cllazyfile/lazyInstMgr.h @@ -9,7 +9,7 @@ #include "lazyFileReader.h" #include "lazyTypes.h" -#include "Registry.h" +#include "core/Registry.h" #include "sc_export.h" #include "judyLArray.h" diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 445ef6502..7125fda46 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -12,9 +12,9 @@ # define ULLONG_MAX _UI64_MAX #endif -#include "Registry.h" +#include "core/Registry.h" #include "sdaiApplication_instance.h" -#include "read_func.h" +#include "core/read_func.h" #include "SdaiSchemaInit.h" #include "STEPcomplex.h" diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index fea36750b..27b1d2ffc 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,19 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - implicitItemId.h - instmgr.h - interfaceSpec.h - interfacedItem.h - inverseAttribute.h - inverseAttributeList.h - mgrnode.h - mgrnodearray.h - mgrnodelist.h - needFunc.h - read_func.h - realTypeDescriptor.h - Registry.h schRename.h sdai.h sdaiApplication_instance.h diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 4cf6a7f0c..5d9f5d917 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -10,7 +10,7 @@ */ #include "core/ExpDict.h" -#include +#include "core/Registry.h" /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 0f9620f57..3a2ee0914 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -12,7 +12,7 @@ #include -#include +#include "core/read_func.h" #include #include #include "core/instmgr.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index fa67b3e40..2175a2670 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -12,7 +12,7 @@ #include #include -#include +#include "core/read_func.h" #include #include "core/instmgr.h" #include diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index 8225ec8c2..d437e6dc2 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -6,7 +6,7 @@ #include #include "core/baseType.h" #include "core/ExpDict.h" -#include +#include "core/Registry.h" #include diff --git a/src/clstepcore/STEPundefined.h b/src/clstepcore/STEPundefined.h index 306eb0ef2..da9883215 100644 --- a/src/clstepcore/STEPundefined.h +++ b/src/clstepcore/STEPundefined.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include "core/read_func.h" class SC_CORE_EXPORT SCLundefined { protected: diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index 7f947f9d5..b58d12db2 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -15,8 +15,8 @@ #include #include -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 6b816d67d..ef16eca82 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -1,7 +1,7 @@ #include #include "core/entityDescriptor.h" -#include "Registry.h" +#include "core/Registry.h" #include "core/attrDescriptor.h" #include "core/inverseAttribute.h" #include "SubSuperIterators.h" diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index f2d4a389d..33007e7fc 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -12,8 +12,8 @@ /* $Id: mgrnode.cc,v 3.0.1.3 1997/11/05 22:11:37 sauderd DP3.1 $ */ -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 304738b88..aae8efc43 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -32,7 +32,7 @@ static int PrintFunctionTrace = 2; // values within functions get printed out //static int PrintValues = 3; -#include +#include "core/mgrnodearray.h" //#include #include diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index d8b835ded..e477e366c 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -12,8 +12,8 @@ /* $Id: mgrnodelist.cc,v 3.0.1.2 1997/11/05 22:11:39 sauderd DP3.1 $ */ -#include -#include +#include "core/mgrnode.h" +#include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index d71c8f28c..731230d60 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -1,4 +1,4 @@ -#include +#include "core/needFunc.h" /////////////////////////////////////////////////////////////////////////////// // Function defined as a stub (necessary to use the scl) diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index a1715d736..e251ed603 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -2,7 +2,7 @@ #include #include #include -#include +#include "core/read_func.h" #include #include "Str.h" diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index c1c9b129d..7bd94355d 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -15,7 +15,7 @@ #include "core/instmgr.h" #include #include -#include //for ReadTokenSeparator, used when comments are inside entities +#include "core/read_func.h" //for ReadTokenSeparator, used when comments are inside entities #include "sdaiApplication_instance.h" #include "superInvAttrIter.h" diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 69487ef32..3a3a3e322 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -76,7 +76,7 @@ void print_file_header( FILES * files ) { fprintf( files->incall, "#endif\n" ); fprintf( files->incall, "#include \n\n" ); - fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \"core/Registry.h\"\n" ); fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \"core/ExpDict.h\"\n" ); @@ -494,7 +494,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) "#include \"schema.h\"\n" "#endif\n" ); #endif - fprintf( initfile, "#include \n#include \n" ); + fprintf( initfile, "#include \"core/Registry.h\"\n#include \n" ); fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index b9b0a9b0e..c9fa7875a 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -17,7 +17,7 @@ extern void SchemaInit( class Registry & ); #include #include #include "core/ExpDict.h" -#include +#include "core/Registry.h" #include #include #include From 77a43bc3f2eabc3738ff6b7958a299c6cac26795 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:43:22 -0400 Subject: [PATCH 229/244] Move all non STEP* headers in stepcore --- include/core/CMakeLists.txt | 26 +++++++++---------- include/core/ExpDict.h | 4 +-- include/core/Registry.h | 2 +- .../core}/SingleLinkList.h | 0 .../core}/SubSuperIterators.h | 0 include/core/dispnode.h | 2 +- include/core/mgrnode.h | 2 +- include/core/read_func.h | 2 +- {src/clstepcore => include/core}/schRename.h | 0 {src/clstepcore => include/core}/sdai.h | 4 +-- .../core}/sdaiApplication_instance.h | 0 {src/clstepcore => include/core}/sdaiSelect.h | 0 .../core}/selectTypeDescriptor.h | 0 .../core}/stringTypeDescriptor.h | 0 .../core}/typeDescriptor.h | 0 .../core}/typeDescriptorList.h | 0 .../core}/typeOrRuleVar.h | 0 .../core}/uniquenessRule.h | 0 {src/clstepcore => include/core}/whereRule.h | 0 src/cldai/sdaiApplication_instance_set.cc | 4 +-- src/cldai/sdaiBinary.cc | 2 +- src/cldai/sdaiDaObject.cc | 2 +- src/cldai/sdaiEntity_extent.cc | 2 +- src/cldai/sdaiEntity_extent_set.cc | 2 +- src/cldai/sdaiEnum.cc | 2 +- src/cldai/sdaiModel_contents.cc | 2 +- src/cldai/sdaiModel_contents_list.cc | 2 +- src/cldai/sdaiObject.cc | 2 +- src/cldai/sdaiSession_instance.cc | 2 +- src/cldai/sdaiSession_instance.h | 2 +- src/cldai/sdaiString.cc | 2 +- src/cleditor/STEPfile.cc | 2 +- src/cleditor/SdaiHeaderSchema.h | 2 +- src/cleditor/SdaiSchemaInit.h | 2 +- src/cleditor/cmdmgr.h | 2 +- src/cleditor/seeinfodefault.h | 2 +- src/cllazyfile/lazyInstMgr.cc | 4 +-- src/cllazyfile/lazyRefs.h | 2 +- src/cllazyfile/sectionReader.cc | 2 +- src/clstepcore/CMakeLists.txt | 13 ---------- src/clstepcore/STEPaggrEntity.cc | 2 +- src/clstepcore/STEPaggrSelect.cc | 2 +- src/clstepcore/STEPaggregate.h | 4 +-- src/clstepcore/STEPattribute.cc | 2 +- src/clstepcore/STEPattribute.h | 2 +- src/clstepcore/STEPattributeList.h | 2 +- src/clstepcore/STEPcomplex.h | 2 +- src/clstepcore/STEPinvAttrList.h | 2 +- src/clstepcore/SingleLinkList.cc | 2 +- src/clstepcore/dictSchema.cc | 2 +- src/clstepcore/entityDescriptor.cc | 2 +- src/clstepcore/instmgr.cc | 2 +- src/clstepcore/mgrnode.cc | 2 +- src/clstepcore/mgrnodearray.cc | 2 +- src/clstepcore/read_func.cc | 2 +- src/clstepcore/schRename.cc | 2 +- src/clstepcore/sdai.cc | 2 +- src/clstepcore/sdaiApplication_instance.cc | 4 +-- src/clstepcore/sdaiSelect.cc | 2 +- src/clstepcore/selectTypeDescriptor.cc | 2 +- src/clstepcore/superInvAttrIter.h | 2 +- .../test/test_SupertypesIterator.cc | 2 +- .../test/test_operators_SDAI_Select.cc | 2 +- src/clstepcore/typeDescriptor.cc | 2 +- src/clstepcore/typeDescriptorList.cc | 2 +- src/clstepcore/typeOrRuleVar.cc | 2 +- src/clstepcore/uniquenessRule.cc | 2 +- src/clstepcore/whereRule.cc | 2 +- src/exp2cxx/classes_wrapper.cc | 4 +-- 69 files changed, 75 insertions(+), 88 deletions(-) rename {src/clstepcore => include/core}/SingleLinkList.h (100%) rename {src/clstepcore => include/core}/SubSuperIterators.h (100%) rename {src/clstepcore => include/core}/schRename.h (100%) rename {src/clstepcore => include/core}/sdai.h (99%) rename {src/clstepcore => include/core}/sdaiApplication_instance.h (100%) rename {src/clstepcore => include/core}/sdaiSelect.h (100%) rename {src/clstepcore => include/core}/selectTypeDescriptor.h (100%) rename {src/clstepcore => include/core}/stringTypeDescriptor.h (100%) rename {src/clstepcore => include/core}/typeDescriptor.h (100%) rename {src/clstepcore => include/core}/typeDescriptorList.h (100%) rename {src/clstepcore => include/core}/typeOrRuleVar.h (100%) rename {src/clstepcore => include/core}/uniquenessRule.h (100%) rename {src/clstepcore => include/core}/whereRule.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index de22dfee7..209bffb51 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -30,12 +30,12 @@ set(CORE_HDRS read_func.h realTypeDescriptor.h Registry.h -# schRename.h -# sdai.h -# sdaiApplication_instance.h -# sdaiSelect.h -# selectTypeDescriptor.h -# SingleLinkList.h + schRename.h + sdai.h + sdaiApplication_instance.h + sdaiSelect.h + selectTypeDescriptor.h + SingleLinkList.h # STEPaggregate.h # STEPaggrBinary.h # STEPaggrEntity.h @@ -50,13 +50,13 @@ set(CORE_HDRS # STEPcomplex.h # STEPinvAttrList.h # STEPundefined.h -# stringTypeDescriptor.h -# SubSuperIterators.h -# typeDescriptor.h -# typeDescriptorList.h -# typeOrRuleVar.h -# uniquenessRule.h -# whereRule.h + stringTypeDescriptor.h + SubSuperIterators.h + typeDescriptor.h + typeDescriptorList.h + typeOrRuleVar.h + uniquenessRule.h + whereRule.h ) install(FILES ${CORE_HDRS} diff --git a/include/core/ExpDict.h b/include/core/ExpDict.h index 7974b93fb..8aa82df55 100644 --- a/include/core/ExpDict.h +++ b/include/core/ExpDict.h @@ -15,13 +15,13 @@ */ #include -#include +#include "core/sdai.h" #include #include #include -#include +#include "core/SingleLinkList.h" #include "core/baseType.h" #include "core/dictdefs.h" diff --git a/include/core/Registry.h b/include/core/Registry.h index d340bdd01..eda955b39 100644 --- a/include/core/Registry.h +++ b/include/core/Registry.h @@ -13,7 +13,7 @@ */ #include -#include +#include "core/sdai.h" #include #include #include diff --git a/src/clstepcore/SingleLinkList.h b/include/core/SingleLinkList.h similarity index 100% rename from src/clstepcore/SingleLinkList.h rename to include/core/SingleLinkList.h diff --git a/src/clstepcore/SubSuperIterators.h b/include/core/SubSuperIterators.h similarity index 100% rename from src/clstepcore/SubSuperIterators.h rename to include/core/SubSuperIterators.h diff --git a/include/core/dispnode.h b/include/core/dispnode.h index 1209b9c3e..c22b62644 100644 --- a/include/core/dispnode.h +++ b/include/core/dispnode.h @@ -19,7 +19,7 @@ /*#include */ /*#include */ -#include +#include "core/sdai.h" #include #include diff --git a/include/core/mgrnode.h b/include/core/mgrnode.h index eca3e19e7..f2ffd5caf 100644 --- a/include/core/mgrnode.h +++ b/include/core/mgrnode.h @@ -18,7 +18,7 @@ class GenericNode; class DisplayNode; -#include +#include "core/sdai.h" #include #include diff --git a/include/core/read_func.h b/include/core/read_func.h index 92cff5705..66289efbe 100644 --- a/include/core/read_func.h +++ b/include/core/read_func.h @@ -2,7 +2,7 @@ #define READ_FUNC_H #include -#include +#include "core/sdai.h" /// This was 512. According to 10303-21:2002 section 5.6: comment length is unlimited. FIXME need to check the code for potential problems before eliminating this limit completely. #define MAX_COMMENT_LENGTH 8192 diff --git a/src/clstepcore/schRename.h b/include/core/schRename.h similarity index 100% rename from src/clstepcore/schRename.h rename to include/core/schRename.h diff --git a/src/clstepcore/sdai.h b/include/core/sdai.h similarity index 99% rename from src/clstepcore/sdai.h rename to include/core/sdai.h index 11a1c7588..b5f316708 100644 --- a/src/clstepcore/sdai.h +++ b/include/core/sdai.h @@ -188,7 +188,7 @@ BOOLEAN and LOGICAL #include -#include +#include "core/sdaiApplication_instance.h" #include /****************************************************************************** @@ -198,7 +198,7 @@ SELECT sdaiSelect.h ******************************************************************************/ -#include +#include "core/sdaiSelect.h" class SDAI_Model_contents; typedef SDAI_Model_contents * SDAI_Model_contents_ptr; diff --git a/src/clstepcore/sdaiApplication_instance.h b/include/core/sdaiApplication_instance.h similarity index 100% rename from src/clstepcore/sdaiApplication_instance.h rename to include/core/sdaiApplication_instance.h diff --git a/src/clstepcore/sdaiSelect.h b/include/core/sdaiSelect.h similarity index 100% rename from src/clstepcore/sdaiSelect.h rename to include/core/sdaiSelect.h diff --git a/src/clstepcore/selectTypeDescriptor.h b/include/core/selectTypeDescriptor.h similarity index 100% rename from src/clstepcore/selectTypeDescriptor.h rename to include/core/selectTypeDescriptor.h diff --git a/src/clstepcore/stringTypeDescriptor.h b/include/core/stringTypeDescriptor.h similarity index 100% rename from src/clstepcore/stringTypeDescriptor.h rename to include/core/stringTypeDescriptor.h diff --git a/src/clstepcore/typeDescriptor.h b/include/core/typeDescriptor.h similarity index 100% rename from src/clstepcore/typeDescriptor.h rename to include/core/typeDescriptor.h diff --git a/src/clstepcore/typeDescriptorList.h b/include/core/typeDescriptorList.h similarity index 100% rename from src/clstepcore/typeDescriptorList.h rename to include/core/typeDescriptorList.h diff --git a/src/clstepcore/typeOrRuleVar.h b/include/core/typeOrRuleVar.h similarity index 100% rename from src/clstepcore/typeOrRuleVar.h rename to include/core/typeOrRuleVar.h diff --git a/src/clstepcore/uniquenessRule.h b/include/core/uniquenessRule.h similarity index 100% rename from src/clstepcore/uniquenessRule.h rename to include/core/uniquenessRule.h diff --git a/src/clstepcore/whereRule.h b/include/core/whereRule.h similarity index 100% rename from src/clstepcore/whereRule.h rename to include/core/whereRule.h diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index ec0511500..ff4033e74 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -25,12 +25,12 @@ */ //#include -#include +#include "core/sdai.h" #include #include -#include "sdaiApplication_instance.h" +#include "core/sdaiApplication_instance.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index 4d1a9b4c9..7ccf00689 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -10,7 +10,7 @@ */ #include -#include +#include "core/sdai.h" SDAI_Binary::SDAI_Binary( const char * str, int max ) { content = std::string( str, max ); diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index edae7f5b9..801b21b8f 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -2,7 +2,7 @@ #include #include -#include +#include "core/sdai.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index 90d37089c..d28fca2bb 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -2,7 +2,7 @@ //#include -#include +#include "core/sdai.h" SDAI_Entity_extent::SDAI_Entity_extent( ) : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index 1cda8be03..ca464eb2b 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -26,7 +26,7 @@ #include #include -#include +#include "core/sdai.h" /* #include diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index e89ddd8dc..65ce8828f 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -1,5 +1,5 @@ -#include +#include "core/sdai.h" /* * NIST STEP Core Class Library diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index c061d20a7..b7043a454 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -1,5 +1,5 @@ -#include +#include "core/sdai.h" ///////// SDAI_Model_contents_instances diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index 882f4287c..a74aadb41 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -23,7 +23,7 @@ /* * UArray implementation. */ -#include +#include "core/sdai.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index 2ab8352ad..f0a1ac592 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,4 +1,4 @@ -#include +#include "core/sdai.h" SDAI_sdaiObject::SDAI_sdaiObject() { } diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 578154428..5c8a901d2 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,4 +1,4 @@ -#include +#include "core/sdai.h" SDAI_Session_instance::SDAI_Session_instance() { } diff --git a/src/cldai/sdaiSession_instance.h b/src/cldai/sdaiSession_instance.h index fcc8fad15..4423037cf 100644 --- a/src/cldai/sdaiSession_instance.h +++ b/src/cldai/sdaiSession_instance.h @@ -3,7 +3,7 @@ #define SESSION_INSTANCE_H 1 #include -//#include +//#include "core/sdai.h" class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index f640633ee..e5818d190 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -9,7 +9,7 @@ * and is not subject to copyright. */ -#include +#include "core/sdai.h" #include SDAI_String::SDAI_String( const char * str, size_t max ) { diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index b7f536a39..a162f8a69 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -25,7 +25,7 @@ #include #include -#include +#include "core/sdai.h" #include #include #include diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index c57dc582d..3fc7a851a 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -5,7 +5,7 @@ // regenerate it. #include -#include +#include "core/sdai.h" #include "core/Registry.h" #include #include diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index a4dc6f740..642f0bd97 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -9,7 +9,7 @@ #endif #include -#include +#include "core/sdai.h" #include "core/Registry.h" #include #include diff --git a/src/cleditor/cmdmgr.h b/src/cleditor/cmdmgr.h index 2d2651db3..dda9810e9 100644 --- a/src/cleditor/cmdmgr.h +++ b/src/cleditor/cmdmgr.h @@ -22,7 +22,7 @@ #include "core/mgrnodelist.h" #include "core/dispnode.h" #include "core/dispnodelist.h" -#include +#include "core/SingleLinkList.h" //#define NUM_CMDMGR_CMDS 9 // this is the number of columns that contain cmds (as opposed diff --git a/src/cleditor/seeinfodefault.h b/src/cleditor/seeinfodefault.h index 51198eac8..66ba1ce89 100644 --- a/src/cleditor/seeinfodefault.h +++ b/src/cleditor/seeinfodefault.h @@ -20,7 +20,7 @@ class MgrNode; class DisplayNode; class DisplayNodelist; -#include +#include "core/sdai.h" //class SDAI_Application_instance; #include diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index f2a4f3867..107bdfb5d 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -1,12 +1,12 @@ #include "lazyTypes.h" #include "lazyInstMgr.h" #include "core/Registry.h" -#include +#include "core/SubSuperIterators.h" #include "SdaiSchemaInit.h" #include "instMgrHelper.h" #include "lazyRefs.h" -#include "sdaiApplication_instance.h" +#include "core/sdaiApplication_instance.h" lazyInstMgr::lazyInstMgr() { _headerRegistry = new Registry( HeaderSchemaInit ); diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index bcfa3fa9b..62fbd0dc4 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -10,7 +10,7 @@ #include "lazyTypes.h" #include "lazyInstMgr.h" #include "core/ExpDict.h" -#include "SubSuperIterators.h" +#include "core/SubSuperIterators.h" #include #include diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 7125fda46..70385a0f6 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -13,7 +13,7 @@ #endif #include "core/Registry.h" -#include "sdaiApplication_instance.h" +#include "core/sdaiApplication_instance.h" #include "core/read_func.h" #include "SdaiSchemaInit.h" #include "STEPcomplex.h" diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 27b1d2ffc..3280aefc3 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -63,12 +63,6 @@ set(LIBSTEPCORE_SRCS ) set(SC_CLSTEPCORE_HDRS - schRename.h - sdai.h - sdaiApplication_instance.h - sdaiSelect.h - selectTypeDescriptor.h - SingleLinkList.h STEPaggregate.h STEPaggrBinary.h STEPaggrEntity.h @@ -83,13 +77,6 @@ set(SC_CLSTEPCORE_HDRS STEPcomplex.h STEPinvAttrList.h STEPundefined.h - stringTypeDescriptor.h - SubSuperIterators.h - typeDescriptor.h - typeDescriptorList.h - typeOrRuleVar.h - uniquenessRule.h - whereRule.h ) include_directories( diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index c0fddfbbb..6b4fc1512 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -1,6 +1,6 @@ #include "STEPaggrEntity.h" #include "STEPattribute.h" -#include "typeDescriptor.h" +#include "core/typeDescriptor.h" #include /** \file STEPaggrEntity.cc diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index 2e02113d7..b14a1a4f7 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -1,5 +1,5 @@ #include "STEPaggrSelect.h" -#include "typeDescriptor.h" +#include "core/typeDescriptor.h" #include /** \file STEPaggrSelect.cc diff --git a/src/clstepcore/STEPaggregate.h b/src/clstepcore/STEPaggregate.h index 1b9f52193..2d62f227a 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/src/clstepcore/STEPaggregate.h @@ -18,9 +18,9 @@ class TypeDescriptor; #include #include -#include +#include "core/SingleLinkList.h" #include "core/baseType.h" -#include +#include "core/sdai.h" #include #include diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 2175a2670..cf8ea382e 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -18,7 +18,7 @@ #include #include #include "core/ExpDict.h" -#include +#include "core/sdai.h" // REAL_NUM_PRECISION is defined in STEPattribute.h, and is also used // in aggregate real handling (STEPaggregate.cc) -- IMS 6 Jun 95 diff --git a/src/clstepcore/STEPattribute.h b/src/clstepcore/STEPattribute.h index 61fbeaf71..754cec9d1 100644 --- a/src/clstepcore/STEPattribute.h +++ b/src/clstepcore/STEPattribute.h @@ -18,7 +18,7 @@ #include #include "core/baseType.h" -#include +#include "core/sdai.h" /** \def REAL_NUM_PRECISION * this is used to set a const int Real_Num_Precision diff --git a/src/clstepcore/STEPattributeList.h b/src/clstepcore/STEPattributeList.h index 9159f4664..929ef84a2 100644 --- a/src/clstepcore/STEPattributeList.h +++ b/src/clstepcore/STEPattributeList.h @@ -16,7 +16,7 @@ class STEPattribute; #include -#include +#include "core/SingleLinkList.h" class STEPattributeList; diff --git a/src/clstepcore/STEPcomplex.h b/src/clstepcore/STEPcomplex.h index d437e6dc2..6e64f3e20 100644 --- a/src/clstepcore/STEPcomplex.h +++ b/src/clstepcore/STEPcomplex.h @@ -3,7 +3,7 @@ #include #include -#include +#include "core/sdai.h" #include "core/baseType.h" #include "core/ExpDict.h" #include "core/Registry.h" diff --git a/src/clstepcore/STEPinvAttrList.h b/src/clstepcore/STEPinvAttrList.h index 342720065..7df262a34 100644 --- a/src/clstepcore/STEPinvAttrList.h +++ b/src/clstepcore/STEPinvAttrList.h @@ -15,7 +15,7 @@ class Inverse_attribute; #include -#include +#include "core/SingleLinkList.h" class STEPinvAttrList; class EntityAggregate; diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index d46cc062e..9a4f750dc 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -10,7 +10,7 @@ * and is not subject to copyright. */ -#include +#include "core/SingleLinkList.h" #include diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 5e739287c..301d2c42d 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -1,6 +1,6 @@ #include "core/dictSchema.h" -#include "typeDescriptor.h" +#include "core/typeDescriptor.h" #include "core/entityDescriptor.h" Schema::Schema( const char * schemaName ) diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index ef16eca82..4b4ceaf98 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -4,7 +4,7 @@ #include "core/Registry.h" #include "core/attrDescriptor.h" #include "core/inverseAttribute.h" -#include "SubSuperIterators.h" +#include "core/SubSuperIterators.h" EntityDescriptor::EntityDescriptor( ) : _abstractEntity( LUnknown ), _extMapping( LUnknown ), diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index 2da10f762..f0ef13892 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -16,7 +16,7 @@ // ////////////////////////////////////////////////////////////////////////////// -#include +#include "core/sdai.h" #include "core/instmgr.h" /////////////////////////////////////////////////////////////////////////////// diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index 33007e7fc..f6ceafcaf 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -19,7 +19,7 @@ #include "core/instmgr.h" //#include -#include +#include "core/sdai.h" #include diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index aae8efc43..0467f73a1 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -34,7 +34,7 @@ static int PrintFunctionTrace = 2; #include "core/mgrnodearray.h" //#include -#include +#include "core/sdai.h" #include // to get bcopy() - ANSI diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index e251ed603..3a0d3bcc7 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -1,7 +1,7 @@ #include #include -#include +#include "core/sdai.h" #include "core/read_func.h" #include #include "Str.h" diff --git a/src/clstepcore/schRename.cc b/src/clstepcore/schRename.cc index b7159a6e0..b0f96c4c0 100644 --- a/src/clstepcore/schRename.cc +++ b/src/clstepcore/schRename.cc @@ -1,4 +1,4 @@ -#include "schRename.h" +#include "core/schRename.h" /** diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index ee1631e74..00ea0f932 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -1,7 +1,7 @@ #include #include -#include +#include "core/sdai.h" const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 7bd94355d..26824bfb9 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -11,13 +11,13 @@ */ #include -#include +#include "core/sdai.h" #include "core/instmgr.h" #include #include #include "core/read_func.h" //for ReadTokenSeparator, used when comments are inside entities -#include "sdaiApplication_instance.h" +#include "core/sdaiApplication_instance.h" #include "superInvAttrIter.h" SDAI_Application_instance NilSTEPentity; diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 060a7b149..69595178c 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -14,7 +14,7 @@ #include "core/ExpDict.h" #include #include -#include +#include "core/sdai.h" #include #ifdef SC_LOGGING diff --git a/src/clstepcore/selectTypeDescriptor.cc b/src/clstepcore/selectTypeDescriptor.cc index a7c0ad032..c3737b85b 100644 --- a/src/clstepcore/selectTypeDescriptor.cc +++ b/src/clstepcore/selectTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "selectTypeDescriptor.h" +#include "core/selectTypeDescriptor.h" /////////////////////////////////////////////////////////////////////////////// // SelectTypeDescriptor functions diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index 4b7a02a1d..0f7853bc1 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -1,7 +1,7 @@ #ifndef SUPERINVATTRITER_H #define SUPERINVATTRITER_H -#include "SubSuperIterators.h" +#include "core/SubSuperIterators.h" #include "core/ExpDict.h" /** diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index 9fe2a54b7..52f6ca795 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -4,7 +4,7 @@ //subtypesiterator shouldn't need tested separately from supertypesiterator since there is very little difference -#include "SubSuperIterators.h" +#include "core/SubSuperIterators.h" #include "core/ExpDict.h" #include diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index 83e0f6469..a0e920c38 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -8,7 +8,7 @@ #include "core/ExpDict.h" #include "core/baseType.h" -#include "sdaiSelect.h" +#include "core/sdaiSelect.h" using namespace std; diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index 651a508f5..c1394c8f6 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -1,4 +1,4 @@ -#include "typeDescriptor.h" +#include "core/typeDescriptor.h" TypeDescriptor::TypeDescriptor( ) : _name( 0 ), altNames( 0 ), _fundamentalType( UNKNOWN_TYPE ), diff --git a/src/clstepcore/typeDescriptorList.cc b/src/clstepcore/typeDescriptorList.cc index f47e8f502..2a5444378 100644 --- a/src/clstepcore/typeDescriptorList.cc +++ b/src/clstepcore/typeDescriptorList.cc @@ -1,4 +1,4 @@ -#include "typeDescriptorList.h" +#include "core/typeDescriptorList.h" TypeDescLinkNode::TypeDescLinkNode() { _typeDesc = 0; diff --git a/src/clstepcore/typeOrRuleVar.cc b/src/clstepcore/typeOrRuleVar.cc index 0b06f1949..dec362a28 100644 --- a/src/clstepcore/typeOrRuleVar.cc +++ b/src/clstepcore/typeOrRuleVar.cc @@ -1,4 +1,4 @@ -#include "typeOrRuleVar.h" +#include "core/typeOrRuleVar.h" #include diff --git a/src/clstepcore/uniquenessRule.cc b/src/clstepcore/uniquenessRule.cc index 038f1a68f..fd8ba05ca 100644 --- a/src/clstepcore/uniquenessRule.cc +++ b/src/clstepcore/uniquenessRule.cc @@ -1,4 +1,4 @@ -#include "uniquenessRule.h" +#include "core/uniquenessRule.h" #include diff --git a/src/clstepcore/whereRule.cc b/src/clstepcore/whereRule.cc index e60c64940..44f23dc14 100644 --- a/src/clstepcore/whereRule.cc +++ b/src/clstepcore/whereRule.cc @@ -1,4 +1,4 @@ -#include "whereRule.h" +#include "core/whereRule.h" Where_rule::Where_rule() { _type_or_rule = 0; diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 3a3a3e322..0efdae642 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -75,7 +75,7 @@ void print_file_header( FILES * files ) { fprintf( files->incall, "#include \n" ); fprintf( files->incall, "#endif\n" ); - fprintf( files->incall, "#include \n\n" ); + fprintf( files->incall, "#include \"core/sdai.h\"\n\n" ); fprintf( files->incall, "\n#include \"core/Registry.h\"\n" ); fprintf( files->incall, "\n#include \n" ); fprintf( files->incall, "\n#include \n" ); @@ -643,7 +643,7 @@ void EXPRESSPrint( Express express, ComplexCollect & col, FILES * files ) { } fprintf( files->inc, "\n// in the exp2cxx source code, this file is generally referred to as files->inc or incfile\n" ); - fprintf( incfile, "#include \n" ); + fprintf( incfile, "#include \"core/sdai.h\" \n" ); np = fnm + strlen( fnm ) - 1; /* point to end of constant part of string */ /* 1.9 init unity files (large translation units, faster compilation) */ From b36b78ffce6239dccecad2e5441d9b1a7d5d9a32 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:50:05 -0400 Subject: [PATCH 230/244] Need to process a few more directories --- include/core/create_Aggr.h | 2 +- include/core/interfacedItem.h | 2 +- include/core/uniquenessRule.h | 2 +- include/core/whereRule.h | 2 +- misc/header_mv.sh | 6 ++++++ src/test/p21read/p21read.cc | 2 +- src/test/tests.h | 2 +- test/cpp/schema_specific/aggregate_bound_runtime.cc | 6 +++--- test/cpp/schema_specific/attribute.cc | 6 +++--- test/cpp/schema_specific/inverse_attr1.cc | 6 +++--- test/cpp/schema_specific/inverse_attr2.cc | 6 +++--- test/cpp/schema_specific/inverse_attr3.cc | 6 +++--- test/cpp/schema_specific/stepfile_rw_progress.cc | 6 +++--- 13 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/core/create_Aggr.h b/include/core/create_Aggr.h index a0483fa66..e6b6b39cb 100644 --- a/include/core/create_Aggr.h +++ b/include/core/create_Aggr.h @@ -3,7 +3,7 @@ //typedef's for aggregate creators -#include "sdai.h" +#include "core/sdai.h" #include "sc_export.h" diff --git a/include/core/interfacedItem.h b/include/core/interfacedItem.h index 5084cab60..909aa3881 100644 --- a/include/core/interfacedItem.h +++ b/include/core/interfacedItem.h @@ -3,7 +3,7 @@ #include "core/dictionaryInstance.h" -#include "sdai.h" +#include "core/sdai.h" #include "sc_export.h" diff --git a/include/core/uniquenessRule.h b/include/core/uniquenessRule.h index 2ce576b66..93c13a75d 100644 --- a/include/core/uniquenessRule.h +++ b/include/core/uniquenessRule.h @@ -3,7 +3,7 @@ #include "core/dictionaryInstance.h" -#include "sdai.h" +#include "core/sdai.h" #include "sc_export.h" diff --git a/include/core/whereRule.h b/include/core/whereRule.h index 7c36ec1ee..3a88f71c9 100644 --- a/include/core/whereRule.h +++ b/include/core/whereRule.h @@ -2,7 +2,7 @@ #define WHERERULE_H #include -#include "sdai.h" +#include "core/sdai.h" #include "core/dictionaryInstance.h" #include "typeOrRuleVar.h" diff --git a/misc/header_mv.sh b/misc/header_mv.sh index 6e3170786..8735a4421 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -2,3 +2,9 @@ find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; + +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; + diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index c9fa7875a..1bf8d6c12 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -14,7 +14,7 @@ extern void SchemaInit( class Registry & ); #include -#include +#include "core/sdai.h" #include #include "core/ExpDict.h" #include "core/Registry.h" diff --git a/src/test/tests.h b/src/test/tests.h index 85b3b010c..df4e3af01 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -19,7 +19,7 @@ #include "core/ExpDict.h" #include #include -#include +#include "core/sdai.h" /* Stuff more or less specifically for the Example schema */ /* The only program that needs this is tstatic. Since the other programs */ diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index fe103ab8e..e4d8ea64c 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -1,9 +1,9 @@ #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index 79d462fda..c7b951d5a 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -4,10 +4,10 @@ */ #include "config.h" #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 079ababbf..46b066839 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -6,10 +6,10 @@ #include "config.h" #include "SubSuperIterators.h" #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 6423786f6..44d5e18cb 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -5,10 +5,10 @@ */ #include "config.h" #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 782ebb1df..70d884092 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -7,10 +7,10 @@ #include "config.h" #include #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index e007c7f37..a740d9b0c 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -1,9 +1,9 @@ #include -#include +#include "core/sdai.h" #include -#include -#include +#include "core/ExpDict.h" +#include "core/Registry.h" #include #include #include From ac19698fde1f893fb46f92629a7979ba68c372d8 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:59:16 -0400 Subject: [PATCH 231/244] Move remaining stepcore headers --- include/core/CMakeLists.txt | 28 +++++++++---------- .../core}/STEPaggrBinary.h | 2 +- .../core}/STEPaggrEntity.h | 2 +- .../core}/STEPaggrEnum.h | 2 +- .../core}/STEPaggrGeneric.h | 2 +- .../clstepcore => include/core}/STEPaggrInt.h | 2 +- .../core}/STEPaggrReal.h | 2 +- .../core}/STEPaggrSelect.h | 2 +- .../core}/STEPaggrString.h | 2 +- .../core}/STEPaggregate.h | 18 ++++++------ .../core}/STEPattribute.h | 0 .../core}/STEPattributeList.h | 0 .../clstepcore => include/core}/STEPcomplex.h | 0 .../core}/STEPinvAttrList.h | 0 .../core}/STEPundefined.h | 0 include/core/dispnode.h | 2 +- include/core/sdai.h | 4 +-- src/cleditor/STEPfile.cc | 6 ++-- src/cleditor/STEPfile.inline.cc | 2 +- src/cleditor/SdaiHeaderSchema.cc | 2 +- src/cleditor/SdaiHeaderSchema.h | 2 +- src/cleditor/SdaiHeaderSchemaInit.cc | 2 +- src/cleditor/SdaiSchemaInit.h | 6 ++-- src/cllazyfile/lazyRefs.h | 4 +-- src/cllazyfile/sectionReader.cc | 2 +- src/cllazyfile/sectionReader.h | 2 +- src/clstepcore/CMakeLists.txt | 20 ------------- src/clstepcore/STEPaggrBinary.cc | 2 +- src/clstepcore/STEPaggrEntity.cc | 4 +-- src/clstepcore/STEPaggrEnum.cc | 2 +- src/clstepcore/STEPaggrGeneric.cc | 2 +- src/clstepcore/STEPaggrInt.cc | 2 +- src/clstepcore/STEPaggrReal.cc | 2 +- src/clstepcore/STEPaggrSelect.cc | 2 +- src/clstepcore/STEPaggrString.cc | 2 +- src/clstepcore/STEPaggregate.cc | 4 +-- src/clstepcore/STEPattribute.cc | 6 ++-- src/clstepcore/STEPattributeList.cc | 4 +-- src/clstepcore/STEPcomplex.cc | 6 ++-- src/clstepcore/STEPinvAttrList.cc | 2 +- src/clstepcore/STEPundefined.cc | 4 +-- src/clstepcore/create_Aggr.cc | 2 +- src/clstepcore/read_func.cc | 2 +- src/clstepcore/sdaiApplication_instance.cc | 4 +-- src/clstepcore/sdaiSelect.cc | 2 +- src/clstepcore/test/test_null_attr.cc | 2 +- .../test/test_operators_STEPattribute.cc | 2 +- src/exp2cxx/classes_wrapper.cc | 6 ++-- src/exp2cxx/multpass.c | 2 +- src/test/p21read/p21read.cc | 2 +- src/test/tests.h | 2 +- .../aggregate_bound_runtime.cc | 2 +- test/cpp/schema_specific/attribute.cc | 2 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- test/cpp/schema_specific/inverse_attr2.cc | 2 +- test/cpp/schema_specific/inverse_attr3.cc | 2 +- .../schema_specific/stepfile_rw_progress.cc | 2 +- 57 files changed, 89 insertions(+), 109 deletions(-) rename {src/clstepcore => include/core}/STEPaggrBinary.h (97%) rename {src/clstepcore => include/core}/STEPaggrEntity.h (98%) rename {src/clstepcore => include/core}/STEPaggrEnum.h (98%) rename {src/clstepcore => include/core}/STEPaggrGeneric.h (98%) rename {src/clstepcore => include/core}/STEPaggrInt.h (97%) rename {src/clstepcore => include/core}/STEPaggrReal.h (97%) rename {src/clstepcore => include/core}/STEPaggrSelect.h (99%) rename {src/clstepcore => include/core}/STEPaggrString.h (97%) rename {src/clstepcore => include/core}/STEPaggregate.h (93%) rename {src/clstepcore => include/core}/STEPattribute.h (100%) rename {src/clstepcore => include/core}/STEPattributeList.h (100%) rename {src/clstepcore => include/core}/STEPcomplex.h (100%) rename {src/clstepcore => include/core}/STEPinvAttrList.h (100%) rename {src/clstepcore => include/core}/STEPundefined.h (100%) diff --git a/include/core/CMakeLists.txt b/include/core/CMakeLists.txt index 209bffb51..f43f93519 100644 --- a/include/core/CMakeLists.txt +++ b/include/core/CMakeLists.txt @@ -36,20 +36,20 @@ set(CORE_HDRS sdaiSelect.h selectTypeDescriptor.h SingleLinkList.h -# STEPaggregate.h -# STEPaggrBinary.h -# STEPaggrEntity.h -# STEPaggrEnum.h -# STEPaggrGeneric.h -# STEPaggrInt.h -# STEPaggrReal.h -# STEPaggrSelect.h -# STEPaggrString.h -# STEPattribute.h -# STEPattributeList.h -# STEPcomplex.h -# STEPinvAttrList.h -# STEPundefined.h + STEPaggregate.h + STEPaggrBinary.h + STEPaggrEntity.h + STEPaggrEnum.h + STEPaggrGeneric.h + STEPaggrInt.h + STEPaggrReal.h + STEPaggrSelect.h + STEPaggrString.h + STEPattribute.h + STEPattributeList.h + STEPcomplex.h + STEPinvAttrList.h + STEPundefined.h stringTypeDescriptor.h SubSuperIterators.h typeDescriptor.h diff --git a/src/clstepcore/STEPaggrBinary.h b/include/core/STEPaggrBinary.h similarity index 97% rename from src/clstepcore/STEPaggrBinary.h rename to include/core/STEPaggrBinary.h index cd4991bbb..0afe1612f 100644 --- a/src/clstepcore/STEPaggrBinary.h +++ b/include/core/STEPaggrBinary.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRBINARY_H #define STEPAGGRBINARY_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include /** \file STEPaggrBinary.h diff --git a/src/clstepcore/STEPaggrEntity.h b/include/core/STEPaggrEntity.h similarity index 98% rename from src/clstepcore/STEPaggrEntity.h rename to include/core/STEPaggrEntity.h index f18bc3d0f..2f80985bf 100644 --- a/src/clstepcore/STEPaggrEntity.h +++ b/include/core/STEPaggrEntity.h @@ -5,7 +5,7 @@ * classes EntityAggregate, EntityNode */ -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include class SC_CORE_EXPORT EntityAggregate : public STEPaggregate { diff --git a/src/clstepcore/STEPaggrEnum.h b/include/core/STEPaggrEnum.h similarity index 98% rename from src/clstepcore/STEPaggrEnum.h rename to include/core/STEPaggrEnum.h index 14cf1d6de..fb181ee8e 100644 --- a/src/clstepcore/STEPaggrEnum.h +++ b/include/core/STEPaggrEnum.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRENUM_H #define STEPAGGRENUM_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include "sc_export.h" /** \file StepaggrEnum.h * classes EnumAggregate, LOGICALS, BOOLEANS, EnumNode diff --git a/src/clstepcore/STEPaggrGeneric.h b/include/core/STEPaggrGeneric.h similarity index 98% rename from src/clstepcore/STEPaggrGeneric.h rename to include/core/STEPaggrGeneric.h index 76190406e..c122d2be9 100644 --- a/src/clstepcore/STEPaggrGeneric.h +++ b/include/core/STEPaggrGeneric.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRGENERIC_H #define STEPAGGRGENERIC_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include /** \file STEPaggrGeneric.h diff --git a/src/clstepcore/STEPaggrInt.h b/include/core/STEPaggrInt.h similarity index 97% rename from src/clstepcore/STEPaggrInt.h rename to include/core/STEPaggrInt.h index 726d07c0e..95d392f64 100644 --- a/src/clstepcore/STEPaggrInt.h +++ b/include/core/STEPaggrInt.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRINT_H #define STEPAGGRINT_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include class SC_CORE_EXPORT IntAggregate : public STEPaggregate { diff --git a/src/clstepcore/STEPaggrReal.h b/include/core/STEPaggrReal.h similarity index 97% rename from src/clstepcore/STEPaggrReal.h rename to include/core/STEPaggrReal.h index 48cd90e51..fb3dad7c4 100644 --- a/src/clstepcore/STEPaggrReal.h +++ b/include/core/STEPaggrReal.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRREAL_H #define STEPAGGRREAL_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include class SC_CORE_EXPORT RealAggregate : public STEPaggregate { diff --git a/src/clstepcore/STEPaggrSelect.h b/include/core/STEPaggrSelect.h similarity index 99% rename from src/clstepcore/STEPaggrSelect.h rename to include/core/STEPaggrSelect.h index 1b97d6e43..82e39dbf6 100644 --- a/src/clstepcore/STEPaggrSelect.h +++ b/include/core/STEPaggrSelect.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRSELECT_H #define STEPAGGRSELECT_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include /** \file STEPaggrSelect.h diff --git a/src/clstepcore/STEPaggrString.h b/include/core/STEPaggrString.h similarity index 97% rename from src/clstepcore/STEPaggrString.h rename to include/core/STEPaggrString.h index 6f5cc8331..91c148891 100644 --- a/src/clstepcore/STEPaggrString.h +++ b/include/core/STEPaggrString.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRSTRING_H #define STEPAGGRSTRING_H -#include "STEPaggregate.h" +#include "core/STEPaggregate.h" #include /** \file STEPaggrString.h diff --git a/src/clstepcore/STEPaggregate.h b/include/core/STEPaggregate.h similarity index 93% rename from src/clstepcore/STEPaggregate.h rename to include/core/STEPaggregate.h index 2d62f227a..efb3477a6 100644 --- a/src/clstepcore/STEPaggregate.h +++ b/include/core/STEPaggregate.h @@ -21,7 +21,7 @@ class TypeDescriptor; #include "core/SingleLinkList.h" #include "core/baseType.h" #include "core/sdai.h" -#include +#include "core/STEPundefined.h" #include #define AGGR_NULL &NilSTEPaggregate @@ -110,14 +110,14 @@ class SC_CORE_EXPORT STEPnode : public SingleLinkNode { }; typedef STEPnode * STEPnodeH; -#include "STEPaggrGeneric.h" -#include "STEPaggrEntity.h" -#include "STEPaggrSelect.h" -#include "STEPaggrString.h" -#include "STEPaggrBinary.h" -#include "STEPaggrEnum.h" -#include "STEPaggrReal.h" -#include "STEPaggrInt.h" +#include "core/STEPaggrGeneric.h" +#include "core/STEPaggrEntity.h" +#include "core/STEPaggrSelect.h" +#include "core/STEPaggrString.h" +#include "core/STEPaggrBinary.h" +#include "core/STEPaggrEnum.h" +#include "core/STEPaggrReal.h" +#include "core/STEPaggrInt.h" /****************************************************************** ** FIXME The following classes are currently stubs diff --git a/src/clstepcore/STEPattribute.h b/include/core/STEPattribute.h similarity index 100% rename from src/clstepcore/STEPattribute.h rename to include/core/STEPattribute.h diff --git a/src/clstepcore/STEPattributeList.h b/include/core/STEPattributeList.h similarity index 100% rename from src/clstepcore/STEPattributeList.h rename to include/core/STEPattributeList.h diff --git a/src/clstepcore/STEPcomplex.h b/include/core/STEPcomplex.h similarity index 100% rename from src/clstepcore/STEPcomplex.h rename to include/core/STEPcomplex.h diff --git a/src/clstepcore/STEPinvAttrList.h b/include/core/STEPinvAttrList.h similarity index 100% rename from src/clstepcore/STEPinvAttrList.h rename to include/core/STEPinvAttrList.h diff --git a/src/clstepcore/STEPundefined.h b/include/core/STEPundefined.h similarity index 100% rename from src/clstepcore/STEPundefined.h rename to include/core/STEPundefined.h diff --git a/include/core/dispnode.h b/include/core/dispnode.h index c22b62644..44b0cc233 100644 --- a/include/core/dispnode.h +++ b/include/core/dispnode.h @@ -17,7 +17,7 @@ #include -/*#include */ +/*#include "core/STEPattribute.h"*/ /*#include */ #include "core/sdai.h" diff --git a/include/core/sdai.h b/include/core/sdai.h index b5f316708..9e080f019 100644 --- a/include/core/sdai.h +++ b/include/core/sdai.h @@ -40,8 +40,8 @@ class EntityDescriptor; class SelectTypeDescriptor; class InstMgrBase; -#include "STEPattributeList.h" -#include "STEPinvAttrList.h" +#include "core/STEPattributeList.h" +#include "core/STEPinvAttrList.h" class STEPattributeList; class STEPattribute; diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index a162f8a69..0d7f90450 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -26,13 +26,13 @@ #include #include "core/sdai.h" -#include -#include +#include "core/STEPcomplex.h" +#include "core/STEPattribute.h" #include // STEPundefined contains // void PushPastString (istream& in, std::string &s, ErrorDescriptor *err) -#include +#include "core/STEPundefined.h" /** * \returns The new file name for the class. diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index b02d84d97..e525a5206 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -13,7 +13,7 @@ #include #include -#include +#include "core/STEPaggregate.h" #include #include diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index f013606b9..efca80295 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -11,7 +11,7 @@ extern ofstream * logStream; #endif #include "core/ExpDict.h" -#include +#include "core/STEPattribute.h" #include Schema * s_header_section_schema = 0; diff --git a/src/cleditor/SdaiHeaderSchema.h b/src/cleditor/SdaiHeaderSchema.h index 3fc7a851a..78e2089b8 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/src/cleditor/SdaiHeaderSchema.h @@ -7,7 +7,7 @@ #include #include "core/sdai.h" #include "core/Registry.h" -#include +#include "core/STEPaggregate.h" #include #include diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 2f906e30c..b5e1a7125 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -6,7 +6,7 @@ #include "core/Registry.h" #include "core/ExpDict.h" -#include +#include "core/STEPattribute.h" #include void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { diff --git a/src/cleditor/SdaiSchemaInit.h b/src/cleditor/SdaiSchemaInit.h index 642f0bd97..f5d1a4464 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/src/cleditor/SdaiSchemaInit.h @@ -11,10 +11,10 @@ #include #include "core/sdai.h" #include "core/Registry.h" -#include -#include +#include "core/STEPaggregate.h" +#include "core/STEPundefined.h" #include "core/ExpDict.h" -#include +#include "core/STEPattribute.h" #include "core/complexSupport.h" #include diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 62fbd0dc4..801cc642d 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -11,8 +11,8 @@ #include "lazyInstMgr.h" #include "core/ExpDict.h" #include "core/SubSuperIterators.h" -#include -#include +#include "core/STEPattribute.h" +#include "core/STEPaggregate.h" #ifdef _WIN32 #define strcasecmp _strcmpi diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 70385a0f6..144d386b3 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -16,7 +16,7 @@ #include "core/sdaiApplication_instance.h" #include "core/read_func.h" #include "SdaiSchemaInit.h" -#include "STEPcomplex.h" +#include "core/STEPcomplex.h" #include "sectionReader.h" #include "lazyFileReader.h" diff --git a/src/cllazyfile/sectionReader.h b/src/cllazyfile/sectionReader.h index b2b7f726a..1e3379cc1 100644 --- a/src/cllazyfile/sectionReader.h +++ b/src/cllazyfile/sectionReader.h @@ -6,7 +6,7 @@ #include "lazyTypes.h" #include "sc_export.h" #include "errordesc.h" -#include "STEPcomplex.h" +#include "core/STEPcomplex.h" class SDAI_Application_instance; class lazyFileReader; diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index 3280aefc3..d7f6cd539 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -62,23 +62,6 @@ set(LIBSTEPCORE_SRCS whereRule.cc ) -set(SC_CLSTEPCORE_HDRS - STEPaggregate.h - STEPaggrBinary.h - STEPaggrEntity.h - STEPaggrEnum.h - STEPaggrGeneric.h - STEPaggrInt.h - STEPaggrReal.h - STEPaggrSelect.h - STEPaggrString.h - STEPattribute.h - STEPattributeList.h - STEPcomplex.h - STEPinvAttrList.h - STEPundefined.h -) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode @@ -100,9 +83,6 @@ if(BUILD_STATIC_LIBS) SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) endif() -install(FILES ${SC_CLSTEPCORE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) - if(SC_ENABLE_TESTING) add_subdirectory(test) endif(SC_ENABLE_TESTING) diff --git a/src/clstepcore/STEPaggrBinary.cc b/src/clstepcore/STEPaggrBinary.cc index fd7302748..90172139f 100644 --- a/src/clstepcore/STEPaggrBinary.cc +++ b/src/clstepcore/STEPaggrBinary.cc @@ -1,4 +1,4 @@ -#include "STEPaggrBinary.h" +#include "core/STEPaggrBinary.h" #include /** \file STEPaggrBinary.cc diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index 6b4fc1512..5f677ee1e 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -1,5 +1,5 @@ -#include "STEPaggrEntity.h" -#include "STEPattribute.h" +#include "core/STEPaggrEntity.h" +#include "core/STEPattribute.h" #include "core/typeDescriptor.h" #include diff --git a/src/clstepcore/STEPaggrEnum.cc b/src/clstepcore/STEPaggrEnum.cc index 41b77aa21..d0b1e944b 100644 --- a/src/clstepcore/STEPaggrEnum.cc +++ b/src/clstepcore/STEPaggrEnum.cc @@ -1,4 +1,4 @@ -#include "STEPaggrEnum.h" +#include "core/STEPaggrEnum.h" #include /** \file StepaggrEnum.cc diff --git a/src/clstepcore/STEPaggrGeneric.cc b/src/clstepcore/STEPaggrGeneric.cc index 899d6c656..8ddcf413f 100644 --- a/src/clstepcore/STEPaggrGeneric.cc +++ b/src/clstepcore/STEPaggrGeneric.cc @@ -1,4 +1,4 @@ -#include "STEPaggrGeneric.h" +#include "core/STEPaggrGeneric.h" #include /** \file STEPaggrGeneric.cc diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index 3989e82f9..4d6740623 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -1,4 +1,4 @@ -#include "STEPaggrInt.h" +#include "core/STEPaggrInt.h" IntAggregate::IntAggregate() { diff --git a/src/clstepcore/STEPaggrReal.cc b/src/clstepcore/STEPaggrReal.cc index 7d05c1333..92920e202 100644 --- a/src/clstepcore/STEPaggrReal.cc +++ b/src/clstepcore/STEPaggrReal.cc @@ -1,4 +1,4 @@ -#include "STEPaggrReal.h" +#include "core/STEPaggrReal.h" /** \file STEPaggrReal.cc * implementation of classes RealAggregate and RealNode diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index b14a1a4f7..c70f91c70 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -1,4 +1,4 @@ -#include "STEPaggrSelect.h" +#include "core/STEPaggrSelect.h" #include "core/typeDescriptor.h" #include diff --git a/src/clstepcore/STEPaggrString.cc b/src/clstepcore/STEPaggrString.cc index fd9285ad3..7f2a99579 100644 --- a/src/clstepcore/STEPaggrString.cc +++ b/src/clstepcore/STEPaggrString.cc @@ -1,4 +1,4 @@ -#include "STEPaggrString.h" +#include "core/STEPaggrString.h" #include /** \file STEPaggrString.cc diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index 3a2ee0914..e71723251 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -13,8 +13,8 @@ #include #include "core/read_func.h" -#include -#include +#include "core/STEPaggregate.h" +#include "core/STEPattribute.h" #include "core/instmgr.h" #include "core/ExpDict.h" diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index cf8ea382e..93a7dcd26 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -13,10 +13,10 @@ #include #include "core/read_func.h" -#include +#include "core/STEPattribute.h" #include "core/instmgr.h" -#include -#include +#include "core/STEPundefined.h" +#include "core/STEPaggregate.h" #include "core/ExpDict.h" #include "core/sdai.h" diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 721175e90..10a0b80b6 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -10,8 +10,8 @@ * and is not subject to copyright. */ -#include -#include +#include "core/STEPattributeList.h" +#include "core/STEPattribute.h" AttrListNode::AttrListNode( STEPattribute * a ) { attr = a; diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index f4576a20b..f49b1ea4e 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -1,10 +1,10 @@ #include -#include +#include "core/STEPcomplex.h" #include "core/complexSupport.h" -#include -#include +#include "core/STEPattribute.h" +#include "core/STEPaggregate.h" #include extern const char * diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index b8f4a824b..502af4567 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -3,7 +3,7 @@ * derived from STEPattributeList.cc */ -#include +#include "core/STEPinvAttrList.h" #include "core/ExpDict.h" invAttrListNodeI::invAttrListNodeI(Inverse_attribute* a, setterI_t s, getterI_t g): invAttrListNode(a), set( s ), get( g ) {} diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index e2dd94f00..c74fc7a8c 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -11,8 +11,8 @@ */ #include // to get the BUFSIZ #define -#include -#include +#include "core/STEPattribute.h" +#include "core/STEPundefined.h" /** \class SCLundefined ** helper functions for reading unknown types diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 7bb13257d..0fe195bb7 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,5 +1,5 @@ #include "core/create_Aggr.h" -#include +#include "core/STEPaggregate.h" EnumAggregate * create_EnumAggregate() { return new EnumAggregate; diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index 3a0d3bcc7..65a635dbe 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -3,7 +3,7 @@ #include #include "core/sdai.h" #include "core/read_func.h" -#include +#include "core/STEPattribute.h" #include "Str.h" const int RealNumPrecision = REAL_NUM_PRECISION; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 26824bfb9..1b39b12c4 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -13,8 +13,8 @@ #include #include "core/sdai.h" #include "core/instmgr.h" -#include -#include +#include "core/STEPcomplex.h" +#include "core/STEPattribute.h" #include "core/read_func.h" //for ReadTokenSeparator, used when comments are inside entities #include "core/sdaiApplication_instance.h" diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 69595178c..5c3168281 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -15,7 +15,7 @@ #include #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #ifdef SC_LOGGING #include diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index cb7064ebb..b82cb49ba 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -1,5 +1,5 @@ #include "core/ExpDict.h" -#include +#include "core/STEPattribute.h" #include AttrDescriptor *ad = 0; diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index cc14cb102..b5266cde3 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -1,6 +1,6 @@ ///test constructors, destructor, shallow copy, assignment operators for STEPattribute -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index 0efdae642..b668361b9 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -77,10 +77,10 @@ void print_file_header( FILES * files ) { fprintf( files->incall, "#include \"core/sdai.h\"\n\n" ); fprintf( files->incall, "\n#include \"core/Registry.h\"\n" ); - fprintf( files->incall, "\n#include \n" ); - fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \"core/STEPaggregate.h\"\n" ); + fprintf( files->incall, "\n#include \"core/STEPundefined.h\"\n" ); fprintf( files->incall, "\n#include \"core/ExpDict.h\"\n" ); - fprintf( files->incall, "\n#include \n" ); + fprintf( files->incall, "\n#include \"core/STEPattribute.h\"\n" ); fprintf( files->incall, "\n#include \n" ); diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 50adf2eb1..2db9f744e 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -159,7 +159,7 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files ) // which hasn't been closed yet. (That's done on 2nd line below.)) */ fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); fprintf( files->initall, "}\n\n" ); - fprintf( files->incall, "\n#include \"core\/complexSupport.h\"\n" ); + fprintf( files->incall, "\n#include \"core/complexSupport.h\"\n" ); fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); /* Function GetModelContents() is printed at the end of the schema.xx diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index 1bf8d6c12..fe60301c5 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -15,7 +15,7 @@ extern void SchemaInit( class Registry & ); #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/src/test/tests.h b/src/test/tests.h index df4e3af01..d4dd60d4a 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -18,7 +18,7 @@ /* General SCL stuff */ #include "core/ExpDict.h" #include -#include +#include "core/STEPattribute.h" #include "core/sdai.h" /* Stuff more or less specifically for the Example schema */ diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index e4d8ea64c..9dab65f65 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -1,7 +1,7 @@ #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index c7b951d5a..d06a93a34 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -5,7 +5,7 @@ #include "config.h" #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 46b066839..ee8a46f01 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -7,7 +7,7 @@ #include "SubSuperIterators.h" #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 44d5e18cb..2edfb88e0 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -6,7 +6,7 @@ #include "config.h" #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 70d884092..cea95a2fb 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -8,7 +8,7 @@ #include #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index a740d9b0c..6ace78348 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -1,7 +1,7 @@ #include #include "core/sdai.h" -#include +#include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" #include From c85720fbb4a8354204f2f5eb8c0a891e88c0ab03 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:15:07 -0400 Subject: [PATCH 232/244] Stub in CMake logic for other header dirs --- include/CMakeLists.txt | 6 ++++++ include/dai/CMakeLists.txt | 14 ++++++++++++++ include/editor/CMakeLists.txt | 14 ++++++++++++++ include/lazy/CMakeLists.txt | 14 ++++++++++++++ include/utils/CMakeLists.txt | 14 ++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 include/dai/CMakeLists.txt create mode 100644 include/editor/CMakeLists.txt create mode 100644 include/lazy/CMakeLists.txt create mode 100644 include/utils/CMakeLists.txt diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 9ad25faeb..c6e9ec18f 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -37,6 +37,12 @@ install(FILES ordered_attrs.h install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h DESTINATION ${INCLUDE_DIR}/stepcode) +add_subdirectory(core) +add_subdirectory(dai) +add_subdirectory(editor) +add_subdirectory(lazy) +add_subdirectory(utils) + # Local Variables: # tab-width: 8 # mode: cmake diff --git a/include/dai/CMakeLists.txt b/include/dai/CMakeLists.txt new file mode 100644 index 000000000..a37d635e7 --- /dev/null +++ b/include/dai/CMakeLists.txt @@ -0,0 +1,14 @@ +set(DAI_HDRS + + ) + +install(FILES ${DAI_HDRS} + DESTINATION ${INCLUDE_DIR}/stepcode/dai) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/include/editor/CMakeLists.txt b/include/editor/CMakeLists.txt new file mode 100644 index 000000000..3558d4805 --- /dev/null +++ b/include/editor/CMakeLists.txt @@ -0,0 +1,14 @@ +set(EDITOR_HDRS + + ) + +install(FILES ${EDITOR_HDRS} + DESTINATION ${INCLUDE_DIR}/stepcode/editor) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/include/lazy/CMakeLists.txt b/include/lazy/CMakeLists.txt new file mode 100644 index 000000000..70d657254 --- /dev/null +++ b/include/lazy/CMakeLists.txt @@ -0,0 +1,14 @@ +set(LAZY_HDRS + + ) + +install(FILES ${LAZY_HDRS} + DESTINATION ${INCLUDE_DIR}/stepcode/lazy) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/include/utils/CMakeLists.txt b/include/utils/CMakeLists.txt new file mode 100644 index 000000000..9fb164919 --- /dev/null +++ b/include/utils/CMakeLists.txt @@ -0,0 +1,14 @@ +set(UTILS_HDRS + + ) + +install(FILES ${UTILS_HDRS} + DESTINATION ${INCLUDE_DIR}/stepcode/utils) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + From 04a5404e60dd985544892b8f1a0bcdf4ef9b368f Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:22:16 -0400 Subject: [PATCH 233/244] Move cldai headers --- include/core/attrDescriptor.h | 2 +- include/core/sdai.h | 20 +++++++++---------- include/core/sdaiApplication_instance.h | 2 +- include/dai/CMakeLists.txt | 12 ++++++++++- .../dai}/sdaiApplication_instance_set.h | 0 {src/cldai => include/dai}/sdaiBinary.h | 0 {src/cldai => include/dai}/sdaiDaObject.h | 4 ++-- .../cldai => include/dai}/sdaiEntity_extent.h | 0 .../dai}/sdaiEntity_extent_set.h | 0 {src/cldai => include/dai}/sdaiEnum.h | 0 .../dai}/sdaiModel_contents.h | 0 .../dai}/sdaiModel_contents_list.h | 0 {src/cldai => include/dai}/sdaiObject.h | 0 .../dai}/sdaiSession_instance.h | 0 misc/header_mv.sh | 12 +++++------ src/cldai/sdaiApplication_instance_set.cc | 2 +- 16 files changed, 32 insertions(+), 22 deletions(-) rename {src/cldai => include/dai}/sdaiApplication_instance_set.h (100%) rename {src/cldai => include/dai}/sdaiBinary.h (100%) rename {src/cldai => include/dai}/sdaiDaObject.h (99%) rename {src/cldai => include/dai}/sdaiEntity_extent.h (100%) rename {src/cldai => include/dai}/sdaiEntity_extent_set.h (100%) rename {src/cldai => include/dai}/sdaiEnum.h (100%) rename {src/cldai => include/dai}/sdaiModel_contents.h (100%) rename {src/cldai => include/dai}/sdaiModel_contents_list.h (100%) rename {src/cldai => include/dai}/sdaiObject.h (100%) rename {src/cldai => include/dai}/sdaiSession_instance.h (100%) diff --git a/include/core/attrDescriptor.h b/include/core/attrDescriptor.h index cee4d13bc..ca146d8b8 100644 --- a/include/core/attrDescriptor.h +++ b/include/core/attrDescriptor.h @@ -3,7 +3,7 @@ #include "typeDescriptor.h" -#include "sdaiEnum.h" +#include "dai/sdaiEnum.h" #include "sc_export.h" diff --git a/include/core/sdai.h b/include/core/sdai.h index 9e080f019..26888a377 100644 --- a/include/core/sdai.h +++ b/include/core/sdai.h @@ -157,10 +157,10 @@ typedef char * SDAI_Schema_name; #include -#include +#include "dai/sdaiBinary.h" // define Object which I am calling sdaiObject for now - DAS -#include +#include "dai/sdaiObject.h" /****************************************************************************** ENUMERATION @@ -172,7 +172,7 @@ ENUMERATION * the value ENUM_NULL is used to represent NULL for all enumerated types *****************************************************************************/ -#include +#include "dai/sdaiEnum.h" /****************************************************************************** BOOLEAN and LOGICAL @@ -185,11 +185,11 @@ BOOLEAN and LOGICAL // ***note*** this file needs classes from sdaiEnum.h // define DAObjectID and classes PID, PID_DA, PID_SDAI, DAObject, DAObject_SDAI -#include +#include "dai/sdaiDaObject.h" #include "core/sdaiApplication_instance.h" -#include +#include "dai/sdaiApplication_instance_set.h" /****************************************************************************** SELECT @@ -204,12 +204,12 @@ class SDAI_Model_contents; typedef SDAI_Model_contents * SDAI_Model_contents_ptr; typedef SDAI_Model_contents_ptr SDAI_Model_contents_var; -#include +#include "dai/sdaiModel_contents_list.h" -#include -#include -#include -#include +#include "dai/sdaiSession_instance.h" +#include "dai/sdaiEntity_extent.h" +#include "dai/sdaiEntity_extent_set.h" +#include "dai/sdaiModel_contents.h" // ENTITY extern SC_CORE_EXPORT SDAI_Application_instance NilSTEPentity; diff --git a/include/core/sdaiApplication_instance.h b/include/core/sdaiApplication_instance.h index 405964c24..9fbca1e72 100644 --- a/include/core/sdaiApplication_instance.h +++ b/include/core/sdaiApplication_instance.h @@ -16,7 +16,7 @@ #include #include -#include +#include "dai/sdaiDaObject.h" class EntityAggregate; class Inverse_attribute; diff --git a/include/dai/CMakeLists.txt b/include/dai/CMakeLists.txt index a37d635e7..1a394d32f 100644 --- a/include/dai/CMakeLists.txt +++ b/include/dai/CMakeLists.txt @@ -1,5 +1,15 @@ set(DAI_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 ) install(FILES ${DAI_HDRS} diff --git a/src/cldai/sdaiApplication_instance_set.h b/include/dai/sdaiApplication_instance_set.h similarity index 100% rename from src/cldai/sdaiApplication_instance_set.h rename to include/dai/sdaiApplication_instance_set.h diff --git a/src/cldai/sdaiBinary.h b/include/dai/sdaiBinary.h similarity index 100% rename from src/cldai/sdaiBinary.h rename to include/dai/sdaiBinary.h diff --git a/src/cldai/sdaiDaObject.h b/include/dai/sdaiDaObject.h similarity index 99% rename from src/cldai/sdaiDaObject.h rename to include/dai/sdaiDaObject.h index 168c7bfbc..b27bb2421 100644 --- a/src/cldai/sdaiDaObject.h +++ b/include/dai/sdaiDaObject.h @@ -1,9 +1,9 @@ #ifndef SDAIDAOBJECT_H #define SDAIDAOBJECT_H 1 -#include +#include "dai/sdaiObject.h" #include -#include +#include "dai/sdaiEnum.h" #include diff --git a/src/cldai/sdaiEntity_extent.h b/include/dai/sdaiEntity_extent.h similarity index 100% rename from src/cldai/sdaiEntity_extent.h rename to include/dai/sdaiEntity_extent.h diff --git a/src/cldai/sdaiEntity_extent_set.h b/include/dai/sdaiEntity_extent_set.h similarity index 100% rename from src/cldai/sdaiEntity_extent_set.h rename to include/dai/sdaiEntity_extent_set.h diff --git a/src/cldai/sdaiEnum.h b/include/dai/sdaiEnum.h similarity index 100% rename from src/cldai/sdaiEnum.h rename to include/dai/sdaiEnum.h diff --git a/src/cldai/sdaiModel_contents.h b/include/dai/sdaiModel_contents.h similarity index 100% rename from src/cldai/sdaiModel_contents.h rename to include/dai/sdaiModel_contents.h diff --git a/src/cldai/sdaiModel_contents_list.h b/include/dai/sdaiModel_contents_list.h similarity index 100% rename from src/cldai/sdaiModel_contents_list.h rename to include/dai/sdaiModel_contents_list.h diff --git a/src/cldai/sdaiObject.h b/include/dai/sdaiObject.h similarity index 100% rename from src/cldai/sdaiObject.h rename to include/dai/sdaiObject.h diff --git a/src/cldai/sdaiSession_instance.h b/include/dai/sdaiSession_instance.h similarity index 100% rename from src/cldai/sdaiSession_instance.h rename to include/dai/sdaiSession_instance.h diff --git a/misc/header_mv.sh b/misc/header_mv.sh index 8735a4421..72890820a 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -1,10 +1,10 @@ #!/bin/bash -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"core\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"core\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index ff4033e74..d1961fce3 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -24,7 +24,7 @@ * UArray implementation. */ -//#include +//#include "dai/sdaiApplication_instance_set.h" #include "core/sdai.h" #include From 84d939baa79e7945d108c7244ceab644cde89b2c Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:24:25 -0400 Subject: [PATCH 234/244] Missed sdaiString.h --- include/core/sdai.h | 2 +- include/dai/sdaiDaObject.h | 2 +- {src/cldai => include/dai}/sdaiString.h | 0 src/cldai/CMakeLists.txt | 17 ----------------- src/clstepcore/test/test_null_attr.cc | 2 +- 5 files changed, 3 insertions(+), 20 deletions(-) rename {src/cldai => include/dai}/sdaiString.h (100%) diff --git a/include/core/sdai.h b/include/core/sdai.h index 26888a377..d47cbca3b 100644 --- a/include/core/sdai.h +++ b/include/core/sdai.h @@ -155,7 +155,7 @@ typedef char * SDAI_Time_stamp; typedef char * SDAI_Entity_name; typedef char * SDAI_Schema_name; -#include +#include "dai/sdaiString.h" #include "dai/sdaiBinary.h" diff --git a/include/dai/sdaiDaObject.h b/include/dai/sdaiDaObject.h index b27bb2421..e615e4244 100644 --- a/include/dai/sdaiDaObject.h +++ b/include/dai/sdaiDaObject.h @@ -2,7 +2,7 @@ #define SDAIDAOBJECT_H 1 #include "dai/sdaiObject.h" -#include +#include "dai/sdaiString.h" #include "dai/sdaiEnum.h" #include diff --git a/src/cldai/sdaiString.h b/include/dai/sdaiString.h similarity index 100% rename from src/cldai/sdaiString.h rename to include/dai/sdaiString.h diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 9d8616f1c..1905704b5 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -13,20 +13,6 @@ set(LIBSTEPDAI_SRCS 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 - ) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode @@ -47,9 +33,6 @@ if(BUILD_STATIC_LIBS) SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) endif() -install(FILES ${SC_CLDAI_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cldai) - # Local Variables: # tab-width: 8 # mode: cmake diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index b82cb49ba..c25025614 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -1,6 +1,6 @@ #include "core/ExpDict.h" #include "core/STEPattribute.h" -#include +#include "dai/sdaiString.h" AttrDescriptor *ad = 0; EntityDescriptor *ed = 0; From f9f5c71204728b2d805f6ea58648538ed5574187 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:29:38 -0400 Subject: [PATCH 235/244] Move editor headers --- include/core/dispnode.h | 2 +- include/core/dispnodelist.h | 2 +- include/core/mgrnode.h | 2 +- include/core/mgrnodelist.h | 2 +- include/editor/CMakeLists.txt | 8 +++++++- {src/cleditor => include/editor}/STEPfile.h | 0 {src/cleditor => include/editor}/SdaiHeaderSchema.h | 4 ++-- .../editor}/SdaiHeaderSchemaClasses.h | 0 {src/cleditor => include/editor}/SdaiSchemaInit.h | 4 ++-- {src/cleditor => include/editor}/cmdmgr.h | 2 +- {src/cleditor => include/editor}/editordefines.h | 0 {src/cleditor => include/editor}/seeinfodefault.h | 2 +- misc/header_mv.sh | 12 ++++++------ src/cleditor/CMakeLists.txt | 13 ------------- src/cleditor/STEPfile.cc | 4 ++-- src/cleditor/STEPfile.inline.cc | 4 ++-- src/cleditor/SdaiHeaderSchema.cc | 2 +- src/cleditor/SdaiHeaderSchemaAll.cc | 2 +- src/cleditor/SdaiHeaderSchemaInit.cc | 2 +- src/cleditor/SdaiSchemaInit.cc | 2 +- src/cleditor/cmdmgr.cc | 2 +- src/cllazyfile/lazyInstMgr.cc | 2 +- src/cllazyfile/lazy_test.cc | 2 +- src/cllazyfile/sectionReader.cc | 2 +- src/test/p21read/p21read.cc | 2 +- src/test/tests.h | 2 +- test/cpp/schema_specific/aggregate_bound_runtime.cc | 2 +- test/cpp/schema_specific/attribute.cc | 2 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- test/cpp/schema_specific/inverse_attr2.cc | 2 +- test/cpp/schema_specific/stepfile_rw_progress.cc | 2 +- 31 files changed, 42 insertions(+), 49 deletions(-) rename {src/cleditor => include/editor}/STEPfile.h (100%) rename {src/cleditor => include/editor}/SdaiHeaderSchema.h (99%) rename {src/cleditor => include/editor}/SdaiHeaderSchemaClasses.h (100%) rename {src/cleditor => include/editor}/SdaiSchemaInit.h (89%) rename {src/cleditor => include/editor}/cmdmgr.h (99%) rename {src/cleditor => include/editor}/editordefines.h (100%) rename {src/cleditor => include/editor}/seeinfodefault.h (96%) diff --git a/include/core/dispnode.h b/include/core/dispnode.h index 44b0cc233..ad519f87f 100644 --- a/include/core/dispnode.h +++ b/include/core/dispnode.h @@ -24,7 +24,7 @@ #include #include //#include -#include +#include "editor/editordefines.h" //#include class MgrNode; diff --git a/include/core/dispnodelist.h b/include/core/dispnodelist.h index 88da55f76..af64fabc5 100644 --- a/include/core/dispnodelist.h +++ b/include/core/dispnodelist.h @@ -19,7 +19,7 @@ #include //#include -#include +#include "editor/editordefines.h" #include "core/mgrnode.h" #include "core/dispnode.h" #include diff --git a/include/core/mgrnode.h b/include/core/mgrnode.h index f2ffd5caf..ef871b071 100644 --- a/include/core/mgrnode.h +++ b/include/core/mgrnode.h @@ -23,7 +23,7 @@ class DisplayNode; #include #include -#include +#include "editor/editordefines.h" class InstMgr; diff --git a/include/core/mgrnodelist.h b/include/core/mgrnodelist.h index be822c798..92edcfe39 100644 --- a/include/core/mgrnodelist.h +++ b/include/core/mgrnodelist.h @@ -20,7 +20,7 @@ #include //#include #include -#include +#include "editor/editordefines.h" ////////////////////////////////////////////////////////////////////////////// // class MgrNodeList diff --git a/include/editor/CMakeLists.txt b/include/editor/CMakeLists.txt index 3558d4805..bd3421699 100644 --- a/include/editor/CMakeLists.txt +++ b/include/editor/CMakeLists.txt @@ -1,5 +1,11 @@ set(EDITOR_HDRS - + STEPfile.h + cmdmgr.h + editordefines.h + SdaiHeaderSchema.h + SdaiHeaderSchemaClasses.h + SdaiSchemaInit.h + seeinfodefault.h ) install(FILES ${EDITOR_HDRS} diff --git a/src/cleditor/STEPfile.h b/include/editor/STEPfile.h similarity index 100% rename from src/cleditor/STEPfile.h rename to include/editor/STEPfile.h diff --git a/src/cleditor/SdaiHeaderSchema.h b/include/editor/SdaiHeaderSchema.h similarity index 99% rename from src/cleditor/SdaiHeaderSchema.h rename to include/editor/SdaiHeaderSchema.h index 78e2089b8..592e32a8e 100644 --- a/src/cleditor/SdaiHeaderSchema.h +++ b/include/editor/SdaiHeaderSchema.h @@ -8,8 +8,8 @@ #include "core/sdai.h" #include "core/Registry.h" #include "core/STEPaggregate.h" -#include -#include +#include "editor/SdaiHeaderSchemaClasses.h" +#include "editor/SdaiSchemaInit.h" ///////// ENTITY section_language diff --git a/src/cleditor/SdaiHeaderSchemaClasses.h b/include/editor/SdaiHeaderSchemaClasses.h similarity index 100% rename from src/cleditor/SdaiHeaderSchemaClasses.h rename to include/editor/SdaiHeaderSchemaClasses.h diff --git a/src/cleditor/SdaiSchemaInit.h b/include/editor/SdaiSchemaInit.h similarity index 89% rename from src/cleditor/SdaiSchemaInit.h rename to include/editor/SdaiSchemaInit.h index f5d1a4464..de267adb9 100644 --- a/src/cleditor/SdaiSchemaInit.h +++ b/include/editor/SdaiSchemaInit.h @@ -17,8 +17,8 @@ #include "core/STEPattribute.h" #include "core/complexSupport.h" -#include -#include +#include "editor/SdaiHeaderSchemaClasses.h" +#include "editor/SdaiHeaderSchema.h" SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & ); SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & ); diff --git a/src/cleditor/cmdmgr.h b/include/editor/cmdmgr.h similarity index 99% rename from src/cleditor/cmdmgr.h rename to include/editor/cmdmgr.h index dda9810e9..3b8607640 100644 --- a/src/cleditor/cmdmgr.h +++ b/include/editor/cmdmgr.h @@ -17,7 +17,7 @@ #include #include -#include +#include "editor/editordefines.h" #include "core/mgrnode.h" #include "core/mgrnodelist.h" #include "core/dispnode.h" diff --git a/src/cleditor/editordefines.h b/include/editor/editordefines.h similarity index 100% rename from src/cleditor/editordefines.h rename to include/editor/editordefines.h diff --git a/src/cleditor/seeinfodefault.h b/include/editor/seeinfodefault.h similarity index 96% rename from src/cleditor/seeinfodefault.h rename to include/editor/seeinfodefault.h index 66ba1ce89..bf2e765ad 100644 --- a/src/cleditor/seeinfodefault.h +++ b/include/editor/seeinfodefault.h @@ -23,7 +23,7 @@ class DisplayNodelist; #include "core/sdai.h" //class SDAI_Application_instance; -#include +#include "editor/editordefines.h" class SC_EDITOR_EXPORT seeInfo : public DisplayNode { public: diff --git a/misc/header_mv.sh b/misc/header_mv.sh index 72890820a..d43a1cd0f 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -1,10 +1,10 @@ #!/bin/bash -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"dai\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"dai\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 75340aa3c..3e21261ae 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -9,16 +9,6 @@ set(LIBSTEPEDITOR_SRCS SdaiSchemaInit.cc ) -SET(SC_CLEDITOR_HDRS - STEPfile.h - cmdmgr.h - editordefines.h - SdaiHeaderSchema.h - SdaiHeaderSchemaClasses.h - SdaiSchemaInit.h - seeinfodefault.h - ) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode @@ -38,9 +28,6 @@ if(BUILD_STATIC_LIBS) SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static) endif() -install(FILES ${SC_CLEDITOR_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) - # Local Variables: # tab-width: 8 # mode: cmake diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 0d7f90450..2d4999bcc 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -24,11 +24,11 @@ #include #include -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPcomplex.h" #include "core/STEPattribute.h" -#include +#include "editor/SdaiHeaderSchema.h" // STEPundefined contains // void PushPastString (istream& in, std::string &s, ErrorDescriptor *err) diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index e525a5206..404c6780b 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -11,8 +11,8 @@ * and is not subject to copyright. */ -#include -#include +#include "editor/STEPfile.h" +#include "editor/SdaiHeaderSchema.h" #include "core/STEPaggregate.h" #include diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index efca80295..bf23f340e 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -12,7 +12,7 @@ extern ofstream * logStream; #include "core/ExpDict.h" #include "core/STEPattribute.h" -#include +#include "editor/SdaiHeaderSchema.h" Schema * s_header_section_schema = 0; diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index 83996e685..76fc8d996 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -4,7 +4,7 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include +#include "editor/SdaiHeaderSchema.h" void HeaderInitSchemasAndEnts( Registry & reg ) { Uniqueness_rule_ptr ur; diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index b5e1a7125..94e0d50eb 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -7,7 +7,7 @@ #include "core/Registry.h" #include "core/ExpDict.h" #include "core/STEPattribute.h" -#include +#include "editor/SdaiHeaderSchema.h" void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index 9515f85ea..d7a54bdd0 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -4,7 +4,7 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include +#include "editor/SdaiSchemaInit.h" void HeaderSchemaInit( Registry & reg ) { HeaderInitSchemasAndEnts( reg ); diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index 0196cede8..6646ee0a8 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -10,7 +10,7 @@ * and is not subject to copyright. */ -#include +#include "editor/cmdmgr.h" ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 107bdfb5d..6f4a3ffb0 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -2,7 +2,7 @@ #include "lazyInstMgr.h" #include "core/Registry.h" #include "core/SubSuperIterators.h" -#include "SdaiSchemaInit.h" +#include "editor/SdaiSchemaInit.h" #include "instMgrHelper.h" #include "lazyRefs.h" diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 10aebaa1e..b0216daa4 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,6 +1,6 @@ #include "lazyInstMgr.h" #include "./sc_benchmark.h" -#include "SdaiSchemaInit.h" +#include "editor/SdaiSchemaInit.h" #include "config.h" #ifndef NO_REGISTRY diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 144d386b3..9a49d05b7 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -15,7 +15,7 @@ #include "core/Registry.h" #include "core/sdaiApplication_instance.h" #include "core/read_func.h" -#include "SdaiSchemaInit.h" +#include "editor/SdaiSchemaInit.h" #include "core/STEPcomplex.h" #include "sectionReader.h" diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index fe60301c5..d896faa48 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -13,7 +13,7 @@ */ extern void SchemaInit( class Registry & ); -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" diff --git a/src/test/tests.h b/src/test/tests.h index d4dd60d4a..504a6f5a3 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -17,7 +17,7 @@ /* General SCL stuff */ #include "core/ExpDict.h" -#include +#include "editor/STEPfile.h" #include "core/STEPattribute.h" #include "core/sdai.h" diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index 9dab65f65..e8ebb598a 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -1,5 +1,5 @@ -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index d06a93a34..8dff9d8fd 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,7 +3,7 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include "config.h" -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index ee8a46f01..201aeff8e 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -5,7 +5,7 @@ */ #include "config.h" #include "SubSuperIterators.h" -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 2edfb88e0..fea50f309 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,7 +4,7 @@ ** */ #include "config.h" -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 6ace78348..c2c3c1522 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -1,5 +1,5 @@ -#include +#include "editor/STEPfile.h" #include "core/sdai.h" #include "core/STEPattribute.h" #include "core/ExpDict.h" From 820ca861592b391c74500d7a5de4f70f26f37cd5 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:43:53 -0400 Subject: [PATCH 236/244] Move the cllazyfile headers, trim down judy arrays I'm not sure if this logic was ever brought to a production level - needs investigateion... maybe we should just arcive it if there isn't any active development? Regardless, there appears to be no upstream activity on the judy code, so just make it a part of cllazy directly. --- include/lazy/CMakeLists.txt | 15 +- .../lazy}/headerSectionReader.h | 6 +- .../lazy}/instMgrHelper.h | 2 +- .../judy/src => include/lazy}/judy.h | 0 .../judy/src => include/lazy}/judyL2Array.h | 0 .../judy/src => include/lazy}/judyLArray.h | 0 .../judy/src => include/lazy}/judyS2Array.h | 0 .../judy/src => include/lazy}/judySArray.h | 0 .../lazy}/lazyDataSectionReader.h | 4 +- .../lazy}/lazyFileReader.h | 6 +- .../cllazyfile => include/lazy}/lazyInstMgr.h | 6 +- .../lazy}/lazyP21DataSectionReader.h | 4 +- {src/cllazyfile => include/lazy}/lazyTypes.h | 0 .../lazy}/p21HeaderSectionReader.h | 2 +- .../lazy}/sectionReader.h | 2 +- misc/header_mv.sh | 12 +- src/cllazyfile/CMakeLists.txt | 24 +- src/cllazyfile/{judy/src => }/judy.c | 2 +- src/cllazyfile/judy/CMakeLists.txt | 78 - src/cllazyfile/judy/README.md | 43 - src/cllazyfile/judy/misc/astyle.cfg | 29 - src/cllazyfile/judy/misc/hextest.sh | 8 - src/cllazyfile/judy/misc/judy64n.c | 2084 ----------------- src/cllazyfile/judy/test/hexSort.c | 124 - src/cllazyfile/judy/test/judyL2test.cc | 72 - src/cllazyfile/judy/test/judyLtest.cc | 33 - src/cllazyfile/judy/test/judyS2test.cc | 75 - src/cllazyfile/judy/test/judyStest.cc | 43 - src/cllazyfile/judy/test/pennySort.c | 236 -- src/cllazyfile/judy/test/sort.c | 233 -- src/cllazyfile/judy/test/sort.h | 58 - src/cllazyfile/lazyDataSectionReader.cc | 6 +- src/cllazyfile/lazyFileReader.cc | 8 +- src/cllazyfile/lazyInstMgr.cc | 6 +- src/cllazyfile/lazyP21DataSectionReader.cc | 4 +- src/cllazyfile/lazyRefs.h | 4 +- src/cllazyfile/lazy_test.cc | 2 +- src/cllazyfile/p21HeaderSectionReader.cc | 10 +- src/cllazyfile/sectionReader.cc | 8 +- test/cpp/schema_specific/inverse_attr3.cc | 2 +- 40 files changed, 63 insertions(+), 3188 deletions(-) rename {src/cllazyfile => include/lazy}/headerSectionReader.h (91%) rename {src/cllazyfile => include/lazy}/instMgrHelper.h (98%) rename {src/cllazyfile/judy/src => include/lazy}/judy.h (100%) rename {src/cllazyfile/judy/src => include/lazy}/judyL2Array.h (100%) rename {src/cllazyfile/judy/src => include/lazy}/judyLArray.h (100%) rename {src/cllazyfile/judy/src => include/lazy}/judyS2Array.h (100%) rename {src/cllazyfile/judy/src => include/lazy}/judySArray.h (100%) rename {src/cllazyfile => include/lazy}/lazyDataSectionReader.h (93%) rename {src/cllazyfile => include/lazy}/lazyFileReader.h (92%) rename {src/cllazyfile => include/lazy}/lazyInstMgr.h (98%) rename {src/cllazyfile => include/lazy}/lazyP21DataSectionReader.h (90%) rename {src/cllazyfile => include/lazy}/lazyTypes.h (100%) rename {src/cllazyfile => include/lazy}/p21HeaderSectionReader.h (94%) rename {src/cllazyfile => include/lazy}/sectionReader.h (99%) rename src/cllazyfile/{judy/src => }/judy.c (99%) delete mode 100644 src/cllazyfile/judy/CMakeLists.txt delete mode 100644 src/cllazyfile/judy/README.md delete mode 100644 src/cllazyfile/judy/misc/astyle.cfg delete mode 100755 src/cllazyfile/judy/misc/hextest.sh delete mode 100644 src/cllazyfile/judy/misc/judy64n.c delete mode 100644 src/cllazyfile/judy/test/hexSort.c delete mode 100644 src/cllazyfile/judy/test/judyL2test.cc delete mode 100644 src/cllazyfile/judy/test/judyLtest.cc delete mode 100644 src/cllazyfile/judy/test/judyS2test.cc delete mode 100644 src/cllazyfile/judy/test/judyStest.cc delete mode 100644 src/cllazyfile/judy/test/pennySort.c delete mode 100644 src/cllazyfile/judy/test/sort.c delete mode 100644 src/cllazyfile/judy/test/sort.h diff --git a/include/lazy/CMakeLists.txt b/include/lazy/CMakeLists.txt index 70d657254..c7ed6ad9e 100644 --- a/include/lazy/CMakeLists.txt +++ b/include/lazy/CMakeLists.txt @@ -1,5 +1,18 @@ set(LAZY_HDRS - + headerSectionReader.h + lazyFileReader.h + lazyP21DataSectionReader.h + p21HeaderSectionReader.h + lazyDataSectionReader.h + lazyInstMgr.h + lazyTypes.h + sectionReader.h + instMgrHelper.h + judy.h + judyL2Array.h + judyLArray.h + judyS2Array.h + judySArray.h ) install(FILES ${LAZY_HDRS} diff --git a/src/cllazyfile/headerSectionReader.h b/include/lazy/headerSectionReader.h similarity index 91% rename from src/cllazyfile/headerSectionReader.h rename to include/lazy/headerSectionReader.h index bea5582aa..b4eb807f9 100644 --- a/src/cllazyfile/headerSectionReader.h +++ b/include/lazy/headerSectionReader.h @@ -5,9 +5,9 @@ #include #include "judyL2Array.h" -#include "lazyFileReader.h" -#include "sectionReader.h" -#include "lazyTypes.h" +#include "lazy/lazyFileReader.h" +#include "lazy/sectionReader.h" +#include "lazy/lazyTypes.h" #include "sc_export.h" diff --git a/src/cllazyfile/instMgrHelper.h b/include/lazy/instMgrHelper.h similarity index 98% rename from src/cllazyfile/instMgrHelper.h rename to include/lazy/instMgrHelper.h index b6cf550b7..fc36863ea 100644 --- a/src/cllazyfile/instMgrHelper.h +++ b/include/lazy/instMgrHelper.h @@ -4,7 +4,7 @@ #include #include "core/mgrnode.h" -#include +#include "lazy/lazyInstMgr.h" #include "core/instmgr.h" /** diff --git a/src/cllazyfile/judy/src/judy.h b/include/lazy/judy.h similarity index 100% rename from src/cllazyfile/judy/src/judy.h rename to include/lazy/judy.h diff --git a/src/cllazyfile/judy/src/judyL2Array.h b/include/lazy/judyL2Array.h similarity index 100% rename from src/cllazyfile/judy/src/judyL2Array.h rename to include/lazy/judyL2Array.h diff --git a/src/cllazyfile/judy/src/judyLArray.h b/include/lazy/judyLArray.h similarity index 100% rename from src/cllazyfile/judy/src/judyLArray.h rename to include/lazy/judyLArray.h diff --git a/src/cllazyfile/judy/src/judyS2Array.h b/include/lazy/judyS2Array.h similarity index 100% rename from src/cllazyfile/judy/src/judyS2Array.h rename to include/lazy/judyS2Array.h diff --git a/src/cllazyfile/judy/src/judySArray.h b/include/lazy/judySArray.h similarity index 100% rename from src/cllazyfile/judy/src/judySArray.h rename to include/lazy/judySArray.h diff --git a/src/cllazyfile/lazyDataSectionReader.h b/include/lazy/lazyDataSectionReader.h similarity index 93% rename from src/cllazyfile/lazyDataSectionReader.h rename to include/lazy/lazyDataSectionReader.h index 41ad62a5c..449345007 100644 --- a/src/cllazyfile/lazyDataSectionReader.h +++ b/include/lazy/lazyDataSectionReader.h @@ -3,8 +3,8 @@ #include #include -#include "sectionReader.h" -#include "lazyTypes.h" +#include "lazy/sectionReader.h" +#include "lazy/lazyTypes.h" #include "sc_export.h" diff --git a/src/cllazyfile/lazyFileReader.h b/include/lazy/lazyFileReader.h similarity index 92% rename from src/cllazyfile/lazyFileReader.h rename to include/lazy/lazyFileReader.h index 20c35f73a..40c4d9c95 100644 --- a/src/cllazyfile/lazyFileReader.h +++ b/include/lazy/lazyFileReader.h @@ -8,9 +8,9 @@ #include "sc_export.h" // PART 21 -#include "lazyP21DataSectionReader.h" -#include "p21HeaderSectionReader.h" -#include "headerSectionReader.h" +#include "lazy/lazyP21DataSectionReader.h" +#include "lazy/p21HeaderSectionReader.h" +#include "lazy/headerSectionReader.h" /* // PART 28 * #include "lazyP28DataSectionReader.h" diff --git a/src/cllazyfile/lazyInstMgr.h b/include/lazy/lazyInstMgr.h similarity index 98% rename from src/cllazyfile/lazyInstMgr.h rename to include/lazy/lazyInstMgr.h index 689f611a5..ff9afc5cb 100644 --- a/src/cllazyfile/lazyInstMgr.h +++ b/include/lazy/lazyInstMgr.h @@ -5,9 +5,9 @@ #include #include -#include "lazyDataSectionReader.h" -#include "lazyFileReader.h" -#include "lazyTypes.h" +#include "lazy/lazyDataSectionReader.h" +#include "lazy/lazyFileReader.h" +#include "lazy/lazyTypes.h" #include "core/Registry.h" #include "sc_export.h" diff --git a/src/cllazyfile/lazyP21DataSectionReader.h b/include/lazy/lazyP21DataSectionReader.h similarity index 90% rename from src/cllazyfile/lazyP21DataSectionReader.h rename to include/lazy/lazyP21DataSectionReader.h index 0602b421a..81e5f6bde 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.h +++ b/include/lazy/lazyP21DataSectionReader.h @@ -1,8 +1,8 @@ #ifndef LAZYP21DATASECTIONREADER_H #define LAZYP21DATASECTIONREADER_H -#include "lazyDataSectionReader.h" -#include "lazyFileReader.h" +#include "lazy/lazyDataSectionReader.h" +#include "lazy/lazyFileReader.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { diff --git a/src/cllazyfile/lazyTypes.h b/include/lazy/lazyTypes.h similarity index 100% rename from src/cllazyfile/lazyTypes.h rename to include/lazy/lazyTypes.h diff --git a/src/cllazyfile/p21HeaderSectionReader.h b/include/lazy/p21HeaderSectionReader.h similarity index 94% rename from src/cllazyfile/p21HeaderSectionReader.h rename to include/lazy/p21HeaderSectionReader.h index 01452ea06..e89c50288 100644 --- a/src/cllazyfile/p21HeaderSectionReader.h +++ b/include/lazy/p21HeaderSectionReader.h @@ -1,7 +1,7 @@ #ifndef P21HEADERSECTIONREADER_H #define P21HEADERSECTIONREADER_H -#include "headerSectionReader.h" +#include "lazy/headerSectionReader.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { diff --git a/src/cllazyfile/sectionReader.h b/include/lazy/sectionReader.h similarity index 99% rename from src/cllazyfile/sectionReader.h rename to include/lazy/sectionReader.h index 1e3379cc1..7b62a910c 100644 --- a/src/cllazyfile/sectionReader.h +++ b/include/lazy/sectionReader.h @@ -3,7 +3,7 @@ #include #include -#include "lazyTypes.h" +#include "lazy/lazyTypes.h" #include "sc_export.h" #include "errordesc.h" #include "core/STEPcomplex.h" diff --git a/misc/header_mv.sh b/misc/header_mv.sh index d43a1cd0f..8d5a67d39 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -1,10 +1,10 @@ #!/bin/bash -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"editor\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"editor\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index 392f56fdc..ea6d37a77 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -6,25 +6,7 @@ set( clLazyFile_SRCS p21HeaderSectionReader.cc sectionReader.cc lazyP21DataSectionReader.cc - judy/src/judy.c - ) - -set( SC_CLLAZYFILE_HDRS - headerSectionReader.h - lazyFileReader.h - lazyP21DataSectionReader.h - p21HeaderSectionReader.h - lazyDataSectionReader.h - lazyInstMgr.h - lazyTypes.h - sectionReader.h - sectionReader.h - instMgrHelper.h - judy/src/judy.h - judy/src/judyLArray.h - judy/src/judyL2Array.h - judy/src/judySArray.h - judy/src/judyS2Array.h + judy.c ) include_directories( @@ -34,7 +16,6 @@ include_directories( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/clutils - ${CMAKE_CURRENT_SOURCE_DIR}/judy/src ) set(_libdeps stepcore stepdai steputils stepeditor) @@ -54,9 +35,6 @@ endif() SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) target_compile_definitions(lazy_test PRIVATE NO_REGISTRY) -install(FILES ${SC_CLLAZYFILE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) - # Local Variables: # tab-width: 8 # mode: cmake diff --git a/src/cllazyfile/judy/src/judy.c b/src/cllazyfile/judy.c similarity index 99% rename from src/cllazyfile/judy/src/judy.c rename to src/cllazyfile/judy.c index 91380cead..2bdba01ea 100644 --- a/src/cllazyfile/judy/src/judy.c +++ b/src/cllazyfile/judy.c @@ -60,7 +60,7 @@ # endif #endif -#include "judy.h" +#include "lazy/judy.h" #include #include diff --git a/src/cllazyfile/judy/CMakeLists.txt b/src/cllazyfile/judy/CMakeLists.txt deleted file mode 100644 index 3c26e4df2..000000000 --- a/src/cllazyfile/judy/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ - -cmake_minimum_required(VERSION 3.12) -project( JudyTemplates ) - -if( NOT DEFINED CMAKE_BUILD_TYPE ) - # 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 ) -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" ) - - #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 ) -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 ) -endif( CMAKE_COMPILER_IS_GNUCC ) - -add_library( judy_lib STATIC ${JUDYS_SOURCES} ) - -include_directories( src ) - -if( 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( 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( 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 ) - -endif( ENABLE_TESTING ) - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 - diff --git a/src/cllazyfile/judy/README.md b/src/cllazyfile/judy/README.md deleted file mode 100644 index 5fc134587..000000000 --- a/src/cllazyfile/judy/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Judy Array Templates -The Judy Array is a sparse dynamic array. It is a particular kind of trie that is highly efficient in space and time, and does not require tuning. - -This uses [Karl Malbrain's implementation](http://code.google.com/p/judyarray/) of the Judy Array. Additional information can be found with Doug Baskins' [original implementation](http://judy.sourceforge.net/) on sourceforge, or on [Wikipedia](http://en.wikipedia.org/wiki/Judy_array). -## The templates -* `judyLArray` - a C++ template wrapper for an int-int Judy Array. JudyKey and JudyValue must be integer types and the same size as a pointer (i.e. 32- or 64-bit) -* `judySArray` - Same as judyLArray, but with string-int mapping. The above restrictions on JudyValue apply here as well. -* **TODO** - single-key, multi-value versions of the above -* **TODO** - single-key, n-value versions of the above *(?)* - -## Comparison between this and the versions Karl and Doug wrote -* Doug Baskins' code is licenced under the LGPL. While more permissive than the GPL, it's still not always acceptable. His code is very fast but weighs in at ~20k lines. -* Karl Malbrain's code is ~1250 lines, in a single file containing the judy array and the test code; use requires creating a header. -* Both of the above are written in C, so they don't fit neatly into object-oriented C++. -* Unlike Doug's code, this is ~1250 lines. Unlike Karl's, this is split into several files. - -## Files -* `CMakeLists.txt` - CMake build logic. If you don't have CMake, it should be quite easy to write a file for the build system of your choice. -* **src/** - * `judy.c`, `judy.h` - implementation of the Judy Array - * `judyLArray.h` - the judyLArray template - * `judySArray.h` - the judySArray template -* **test/** - * `hexSort.c` - Sorts a file where each line contains 32 hex chars. Compiles to `hexsort`, which is the same executable as compiling Karl's code with `-DHEXSORT -DSTANDALONE` - * `pennySort.c` - Sorts strings; compiles to `pennysort`. Same as compiling Karl's code with `-DSTANDALONE`. - * `sort.c`, `sort.h` - Karl's sorting functions. Only used by `hexsort` and `pennysort`. - * `judyLtest.cc` - an incomplete test of the judyLArray template. - * `judyStest.cc` - an incomplete test of the judySArray template. - - -## Compiling -* requires C and C++ compilers, CMake. -* from the command line: - * `mkdir build; cd build` - * `cmake .. -DENABLE_TESTING=TRUE` - * `make` - -## License - -Karl Malbrain's judy array code is public domain; what I've added is public domain as well. - -## Contact -mpictor -a-t- gmail diff --git a/src/cllazyfile/judy/misc/astyle.cfg b/src/cllazyfile/judy/misc/astyle.cfg deleted file mode 100644 index eec1dd399..000000000 --- a/src/cllazyfile/judy/misc/astyle.cfg +++ /dev/null @@ -1,29 +0,0 @@ -#astyle config file - -#run astyle on one or a few files: use -# astyle --options=misc/astyle.cfg path/to/file - -#run astyle on all files: from the root dir, use -# astyle --options=misc/astyle.cfg --recursive "src/*.c" "src/*.h" "test/*.c" "test/*.h" -# in the above line, the double quotes *are* necessary - - -suffix=none #don't create backup files - -style=java #compact bracket style - -indent=spaces=4 - -indent-preprocessor -indent-classes -indent-switches -indent-namespaces -pad-oper #pad (space) around operators -pad-paren-in #pad inside parenthesis -unpad-paren #remove parenthesis padding other than requested above - -add-brackets #add brackets on one-line conditionals -convert-tabs #convert all tabs to spaces -align-pointer=middle #char * foo - -lineend=linux #lines end with LF (linux), not CRLF (windows) diff --git a/src/cllazyfile/judy/misc/hextest.sh b/src/cllazyfile/judy/misc/hextest.sh deleted file mode 100755 index ee8606d48..000000000 --- a/src/cllazyfile/judy/misc/hextest.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -#generates a file of hex keys and runs hexsort on it. No verification is done. -#hex data comes from /dev/urandom, so it isn't all that random. - -hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >ukeys -#a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs] -time bin/hexsort ukeys skeys \ No newline at end of file diff --git a/src/cllazyfile/judy/misc/judy64n.c b/src/cllazyfile/judy/misc/judy64n.c deleted file mode 100644 index 8dc8f909a..000000000 --- a/src/cllazyfile/judy/misc/judy64n.c +++ /dev/null @@ -1,2084 +0,0 @@ -// Judy arrays 23 NOV 2012 - -// Author Karl Malbrain, malbrain@yahoo.com -// with assistance from Jan Weiss. - -// Simplified judy arrays for strings and integers -// Adapted from the ideas of Douglas Baskins of HP. - -// The -D ASKITIS benchmarking option was implemented with -// assistance from Dr. Nikolas Askitis (www.naskitis.com). - -// Map a set of keys to corresponding memory cells (unsigned ints). -// Each cell must be set to a non-zero value by the caller. - -// STANDALONE is defined to compile into a string sorter. - -// String mappings are denoted by calling judy_open with zero as -// the second argument. Integer mappings are denoted by calling -// judy_open with the Integer depth of the Judy Trie as the second -// argument. - -//#define STANDALONE - -// functions: -// judy_open: open a new judy array returning a judy object. -// judy_close: close an open judy array, freeing all memory. -// judy_clone: clone an open judy array, duplicating the stack. -// judy_data: allocate data memory within judy array for external use. -// judy_cell: insert a string into the judy array, return cell pointer. -// judy_strt: retrieve the cell pointer greater than or equal to given key -// judy_slot: retrieve the cell pointer, or return NULL for a given key. -// judy_key: retrieve the string value for the most recent judy query. -// judy_end: retrieve the cell pointer for the last string in the array. -// judy_nxt: retrieve the cell pointer for the next string in the array. -// judy_prv: retrieve the cell pointer for the prev string in the array. -// judy_del: delete the key and cell for the current stack entry. - -#include -#include -#include - -#ifdef linux - #define _FILE_OFFSET_BITS 64 - #define _LARGEFILE_SOURCE - #define __USE_FILE_OFFSET64 - - #include -#else - #ifdef __BIG_ENDIAN__ - #ifndef BYTE_ORDER - #define BYTE_ORDER 4321 - #endif - #else - #ifndef BYTE_ORDER - #define BYTE_ORDER 1234 - #endif - #endif - #ifndef BIG_ENDIAN - #define BIG_ENDIAN 4321 - #endif -#endif - - - -#define PRIuint "u" - -#if defined(__LP64__) || \ - defined(__x86_64__) || \ - defined(__amd64__) || \ - defined(_WIN64) || \ - defined(__sparc64__) || \ - defined(__arch64__) || \ - defined(__powerpc64__) || \ - defined (__s390x__) - // defines for 64 bit - - typedef unsigned long long judyvalue; - typedef unsigned long long JudySlot; - #define JUDY_key_mask (0x07) - #define JUDY_key_size 8 - #define JUDY_slot_size 8 - #define JUDY_span_bytes (3 * JUDY_key_size) - #define JUDY_span_equiv JUDY_2 - #define JUDY_radix_equiv JUDY_8 - - #define PRIjudyvalue "llu" - -#else - // defines for 32 bit - - typedef unsigned int judyvalue; - typedef unsigned int JudySlot; - #define JUDY_key_mask (0x03) - #define JUDY_key_size 4 - #define JUDY_slot_size 4 - #define JUDY_span_bytes (7 * JUDY_key_size) - #define JUDY_span_equiv JUDY_4 - #define JUDY_radix_equiv JUDY_8 - - #define PRIjudyvalue "u" - -#endif - -#define JUDY_mask (~(JudySlot)0x07) - -// define the alignment factor for judy nodes and allocations -// to enable this feature, set to 64 - -#define JUDY_cache_line 8 // minimum size is 8 bytes - -#if defined(STANDALONE) || defined(ASKITIS) -#include -#include - -unsigned int MaxMem = 0; - -// void judy_abort (char *msg) __attribute__ ((noreturn)); // Tell static analyser that this function will not return -void judy_abort (char *msg) -{ - fprintf(stderr, "%s\n", msg); - exit(1); -} -#endif - -#define JUDY_seg 65536 - -enum JUDY_types { - JUDY_radix = 0, // inner and outer radix fan-out - JUDY_1 = 1, // linear list nodes of designated count - JUDY_2 = 2, - JUDY_4 = 3, - JUDY_8 = 4, - JUDY_16 = 5, - JUDY_32 = 6, -#ifdef ASKITIS - JUDY_64 = 7 -#else - JUDY_span = 7 // up to 28 tail bytes of key contiguously stored -#endif -}; - -int JudySize[] = { - (JUDY_slot_size * 16), // JUDY_radix node size - (JUDY_slot_size + JUDY_key_size), // JUDY_1 node size - (2 * JUDY_slot_size + 2 * JUDY_key_size), - (4 * JUDY_slot_size + 4 * JUDY_key_size), - (8 * JUDY_slot_size + 8 * JUDY_key_size), - (16 * JUDY_slot_size + 16 * JUDY_key_size), - (32 * JUDY_slot_size + 32 * JUDY_key_size), -#ifndef ASKITIS - (JUDY_span_bytes + JUDY_slot_size) -#else - (64 * JUDY_slot_size + 64 * JUDY_key_size) -#endif -}; - -judyvalue JudyMask[9] = { -0, 0xff, 0xffff, 0xffffff, 0xffffffff, -#if JUDY_key_size > 4 -0xffffffffffULL, 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL -#endif -}; - -typedef struct { - void *seg; // next used allocator - unsigned int next; // next available offset -} JudySeg; - -typedef struct { - JudySlot next; // judy object - unsigned int off; // offset within key - int slot; // slot within object -} JudyStack; - -typedef struct { - JudySlot root[1]; // root of judy array - void **reuse[8]; // reuse judy blocks - JudySeg *seg; // current judy allocator - unsigned int level; // current height of stack - unsigned int max; // max height of stack - unsigned int depth; // number of Integers in a key, or zero for string keys - JudyStack stack[1]; // current cursor -} Judy; - -#ifdef ASKITIS -int Words = 0; -int Inserts = 0; -int Found = 0; - -#if JUDY_key_size < 8 -#define JUDY_max JUDY_16 -#else -#define JUDY_max JUDY_64 -#endif -#else -#define JUDY_max JUDY_32 -#endif - -// open judy object -// call with max key size -// and Integer tree depth. - -void *judy_open (unsigned int max, unsigned int depth) -{ -JudySeg *seg; -Judy *judy; -unsigned int amt; - - max++; // allow for zero terminator on keys - - if( (seg = malloc(JUDY_seg)) ) { - seg->seg = NULL; - seg->next = JUDY_seg; - } else { -#if defined(STANDALONE) || defined(ASKITIS) - judy_abort ("No virtual memory"); -#else - return NULL; -#endif - } - - amt = sizeof(Judy) + max * sizeof(JudyStack); - - if( amt & (JUDY_cache_line - 1) ) - amt |= JUDY_cache_line - 1, amt++; - -#if defined(STANDALONE) || defined(ASKITIS) - MaxMem += JUDY_seg; -#endif - - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); - seg->next -= amt; - - judy = (Judy *)((unsigned char *)seg + seg->next); - memset(judy, 0, amt); - judy->depth = depth; - judy->seg = seg; - judy->max = max; - return judy; -} - -void judy_close (Judy *judy) -{ -JudySeg *seg, *nxt = judy->seg; - - while( (seg = nxt) ) - nxt = seg->seg, free (seg); -} - -// allocate judy node - -void *judy_alloc (Judy *judy, unsigned int type) -{ -unsigned int amt, idx, min; -JudySeg *seg; -void **block; -void **rtn; - - if( !judy->seg ) -#if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); -#else - return NULL; -#endif - - if( type == JUDY_radix ) - type = JUDY_radix_equiv; - -#ifndef ASKITIS - if( type == JUDY_span ) - type = JUDY_span_equiv; -#endif - - amt = JudySize[type]; - - if( amt & 0x07 ) - amt |= 0x07, amt += 1; - - // see if free block is already available - - if( (block = judy->reuse[type]) ) { - judy->reuse[type] = *block; - memset (block, 0, amt); - return (void *)block; - } - - // break down available larger block - // for reuse into smaller blocks - - if( type >= JUDY_1 ) - for( idx = type; idx++ < JUDY_max; ) - if( block = judy->reuse[idx] ) { - judy->reuse[idx] = *block; - while( idx-- > type) { - judy->reuse[idx] = block + JudySize[idx] / sizeof(void *); - block[JudySize[idx] / sizeof(void *)] = 0; - } - memset (block, 0, amt); - return (void *)block; - } - - min = amt < JUDY_cache_line ? JUDY_cache_line : amt; - - if( judy->seg->next < min + sizeof(*seg) ) { - if( (seg = malloc (JUDY_seg)) ) { - seg->next = JUDY_seg; - seg->seg = judy->seg; - judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); - } else { -#if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); -#else - return NULL; -#endif - } - -#if defined(STANDALONE) || defined(ASKITIS) - MaxMem += JUDY_seg; -#endif - } - - // generate additional free blocks - // to fill up to cache line size - - rtn = (void **)((unsigned char *)judy->seg + judy->seg->next - amt); - - for( idx = type; amt & (JUDY_cache_line - 1); amt <<= 1 ) { - block = (void **)((unsigned char *)judy->seg + judy->seg->next - 2 * amt); - judy->reuse[idx++] = block; - *block = 0; - } - - judy->seg->next -= amt; - memset (rtn, 0, JudySize[type]); - return (void *)rtn; -} - -void *judy_data (Judy *judy, unsigned int amt) - -{ -JudySeg *seg; -void *block; - - if( !judy->seg ) -#if defined(STANDALONE) || defined(ASKITIS) - judy_abort("illegal allocation from judy clone"); -#else - return NULL; -#endif - - if( amt & (JUDY_cache_line - 1)) - amt |= (JUDY_cache_line - 1), amt += 1; - - if( judy->seg->next < amt + sizeof(*seg) ) { - if( (seg = malloc (JUDY_seg)) ) { - seg->next = JUDY_seg; - seg->seg = judy->seg; - judy->seg = seg; - seg->next -= (JudySlot)seg & (JUDY_cache_line - 1); - } else { -#if defined(STANDALONE) || defined(ASKITIS) - judy_abort("Out of virtual memory"); -#else - return NULL; -#endif - } - -#if defined(STANDALONE) || defined(ASKITIS) - MaxMem += JUDY_seg; -#endif - } - - judy->seg->next -= amt; - - block = (void *)((unsigned char *)judy->seg + judy->seg->next); - memset (block, 0, amt); - return block; -} - -void *judy_clone (Judy *judy) -{ -Judy *clone; -unsigned int amt; - - amt = sizeof(Judy) + judy->max * sizeof(JudyStack); - clone = judy_data (judy, amt); - memcpy (clone, judy, amt); - clone->seg = NULL; // stop allocations from cloned array - return clone; -} - -void judy_free (Judy *judy, void *block, int type) -{ - if( type == JUDY_radix ) - type = JUDY_radix_equiv; - -#ifndef ASKITIS - if( type == JUDY_span ) - type = JUDY_span_equiv; -#endif - - *((void **)(block)) = judy->reuse[type]; - judy->reuse[type] = (void **)block; - return; -} - -// assemble key from current path - -unsigned int judy_key (Judy *judy, unsigned char *buff, unsigned int max) -{ -judyvalue *dest = (judyvalue *)buff; -unsigned int len = 0, idx = 0, depth; -int slot, off, type; -judyvalue value; -unsigned char *base; -int keysize; - - if( judy->depth ) - max = judy->depth * JUDY_key_size; - else - max--; // leave room for zero terminator - - while( len < max && ++idx <= judy->level ) { - type = judy->stack[idx].next & 0x07; - slot = judy->stack[idx].slot; - depth = len / JUDY_key_size; - - if( judy->depth ) - if( !(len & JUDY_key_mask) ) - dest[depth] = 0; - - switch( type ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - keysize = JUDY_key_size - (judy->stack[idx].off & JUDY_key_mask); - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - - if( judy->depth ) { - value = *(judyvalue *)(base + slot * keysize); - value &= JudyMask[keysize]; - dest[depth++] |= value; - len += keysize; - - if( depth < judy->depth ) - continue; - - return len; - } - -#if BYTE_ORDER != BIG_ENDIAN - off = keysize; - - while( off-- && len < max ) - if( buff[len] = base[slot * keysize + off] ) - len++; - else - break; -#else - for( off = 0; off < keysize && len < max; off++ ) - if( buff[len] = base[slot * keysize + off] ) - len++; - else - break; -#endif - continue; - - case JUDY_radix: - if( judy->depth ) { - dest[depth] |= (judyvalue)slot << (JUDY_key_size - (++len & JUDY_key_mask)) * 8; - if( !(len & JUDY_key_mask) ) - depth++; - if( depth < judy->depth ) - continue; - - return len; - } - - if( !slot ) - break; - buff[len++] = (unsigned char)slot; - continue; - -#ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(judy->stack[idx].next & JUDY_mask); - - for( slot = 0; slot < JUDY_span_bytes && base[slot]; slot++ ) - if( len < max ) - buff[len++] = base[slot]; - continue; -#endif - } - } - buff[len] = 0; - return len; -} - -// find slot & setup cursor - -JudySlot *judy_slot (Judy *judy, unsigned char *buff, unsigned int max) -{ -judyvalue *src = (judyvalue *)buff; -int slot, size, keysize, tst, cnt; -JudySlot next = *judy->root; -judyvalue value, test = 0; -JudySlot *table; -JudySlot *node; -unsigned int depth = 0; -unsigned int off = 0; -unsigned char *base; - -#ifndef ASKITIS - judy->level = 0; -#endif - - while( next ) { -#ifndef ASKITIS - if( judy->level < judy->max ) - judy->level++; - - judy->stack[judy->level].next = next; - judy->stack[judy->level].off = off; -#endif - size = JudySize[next & 0x07]; - - switch( next & 0x07 ) { - - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - slot = cnt; - value = 0; - - if( judy->depth ) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if( off < max ) - value |= buff[off]; - } while( ++off & JUDY_key_mask ); - - // find slot > key - - while( slot-- ) { - test = *(judyvalue *)(base + slot * keysize); -#if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); -#else - test &= JudyMask[keysize]; -#endif - if( test <= value ) - break; - } -#ifndef ASKITIS - judy->stack[judy->level].slot = slot; -#endif - if( test == value ) { - - // is this a leaf? - - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) - return &node[-slot-1]; - - next = node[-slot-1]; - continue; - } - - return NULL; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); // outer radix - - if( judy->depth ) - slot = (src[depth] >> ((JUDY_key_size - off++ & JUDY_key_mask) * 8)) & 0xff; - else if( off < max ) - slot = buff[off++]; - else - slot = 0; -#ifndef ASKITIS - // put radix slot on judy stack - - judy->stack[judy->level].slot = slot; -#endif - if( (next = table[slot >> 4]) ) - table = (JudySlot *)(next & JUDY_mask); // inner radix - else - return NULL; - - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) // leaf? - if( table[slot & 0x0F] ) // occupied? - return &table[slot & 0x0F]; - else - return NULL; - - next = table[slot & 0x0F]; - continue; - -#ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = tst = JUDY_span_bytes; - if( tst > (int)(max - off) ) - tst = max - off; - value = strncmp((const char *)base, (const char *)(buff + off), tst); - if( !value && tst < cnt && !base[tst] ) // leaf? - return &node[-1]; - - if( !value && tst == cnt ) { - next = node[-1]; - off += cnt; - continue; - } - return NULL; -#endif - } - } - - return NULL; -} - -// promote full nodes to next larger size - -JudySlot *judy_promote (Judy *judy, JudySlot *next, int idx, judyvalue value, int keysize) -{ -unsigned char *base = (unsigned char *)(*next & JUDY_mask); -int oldcnt, newcnt, slot; -#if BYTE_ORDER == BIG_ENDIAN - int i; -#endif -JudySlot *newnode, *node; -JudySlot *result; -unsigned char *newbase; -unsigned int type; - - type = (*next & 0x07) + 1; - node = (JudySlot *)((*next & JUDY_mask) + JudySize[type-1]); - oldcnt = JudySize[type-1] / (sizeof(JudySlot) + keysize); - newcnt = JudySize[type] / (sizeof(JudySlot) + keysize); - - // promote node to next larger size - - newbase = judy_alloc (judy, type); - newnode = (JudySlot *)(newbase + JudySize[type]); - *next = (JudySlot)newbase | type; - - // open up slot at idx - - memcpy(newbase + (newcnt - oldcnt - 1) * keysize, base, idx * keysize); // copy keys - - for( slot = 0; slot < idx; slot++ ) - newnode[-(slot + newcnt - oldcnt)] = node[-(slot + 1)]; // copy ptr - - // fill in new node - -#if BYTE_ORDER != BIG_ENDIAN - memcpy(newbase + (idx + newcnt - oldcnt - 1) * keysize, &value, keysize); // copy key -#else - i = keysize; - - while( i-- ) - newbase[(idx + newcnt - oldcnt - 1) * keysize + i] = value, value >>= 8; -#endif - result = &newnode[-(idx + newcnt - oldcnt)]; - - // copy rest of old node - - memcpy(newbase + (idx + newcnt - oldcnt) * keysize, base + (idx * keysize), (oldcnt - slot) * keysize); // copy keys - - for( ; slot < oldcnt; slot++ ) - newnode[-(slot + newcnt - oldcnt + 1)] = node[-(slot + 1)]; // copy ptr - -#ifndef ASKITIS - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = idx + newcnt - oldcnt - 1; -#endif - judy_free (judy, (void **)base, type - 1); - return result; -} - -// construct new node for JUDY_radix entry -// make node with slot - start entries -// moving key over one offset - -void judy_radix (Judy *judy, JudySlot *radix, unsigned char *old, int start, int slot, int keysize, unsigned char key, unsigned int depth) -{ -int size, idx, cnt = slot - start, newcnt; -JudySlot *node, *oldnode; -unsigned int type = JUDY_1 - 1; -JudySlot *table; -unsigned char *base; - - // if necessary, setup inner radix node - - if( !(table = (JudySlot *)(radix[key >> 4] & JUDY_mask)) ) { - table = judy_alloc (judy, JUDY_radix); - radix[key >> 4] = (JudySlot)table | JUDY_radix; - } - - oldnode = (JudySlot *)(old + JudySize[JUDY_max]); - - // is this slot a leaf? - - if( !judy->depth && (!key || !keysize) || judy->depth && !keysize && depth == judy->depth) { - table[key & 0x0F] = oldnode[-start-1]; - return; - } - - // calculate new node big enough to contain slots - - do { - type++; - size = JudySize[type]; - newcnt = size / (sizeof(JudySlot) + keysize); - } while( cnt > newcnt && type < JUDY_max ); - - // store new node pointer in inner table - - base = judy_alloc (judy, type); - node = (JudySlot *)(base + size); - table[key & 0x0F] = (JudySlot)base | type; - - // allocate node and copy old contents - // shorten keys by 1 byte during copy - - for( idx = 0; idx < cnt; idx++ ) { -#if BYTE_ORDER != BIG_ENDIAN - memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1), keysize); -#else - memcpy (base + (newcnt - idx - 1) * keysize, old + (start + cnt - idx - 1) * (keysize + 1) + 1, keysize); -#endif - node[-(newcnt - idx)] = oldnode[-(start + cnt - idx)]; - } -} - -// decompose full node to radix nodes - -void judy_splitnode (Judy *judy, JudySlot *next, unsigned int size, unsigned int keysize, unsigned int depth) -{ -int cnt, slot, start = 0; -unsigned int key = 0x0100, nxt; -JudySlot *newradix; -unsigned char *base; - - base = (unsigned char *)(*next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); - - // allocate outer judy_radix node - - newradix = judy_alloc (judy, JUDY_radix); - *next = (JudySlot)newradix | JUDY_radix; - - for( slot = 0; slot < cnt; slot++ ) { -#if BYTE_ORDER != BIG_ENDIAN - nxt = base[slot * keysize + keysize - 1]; -#else - nxt = base[slot * keysize]; -#endif - - if( key > 0xFF ) - key = nxt; - if( nxt == key ) - continue; - - // decompose portion of old node into radix nodes - - judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - start = slot; - key = nxt; - } - - judy_radix (judy, newradix, base, start, slot, keysize - 1, (unsigned char)key, depth); - judy_free (judy, (void **)base, JUDY_max); -} - -// return first leaf - -JudySlot *judy_first (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ -JudySlot *table, *inner; -unsigned int keysize, size; -JudySlot *node; -int slot, cnt; -unsigned char *base; - - while( next ) { - if( judy->level < judy->max ) - judy->level++; - - judy->stack[judy->level].off = off; - judy->stack[judy->level].next = next; - size = JudySize[next & 0x07]; - - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - cnt = size / (sizeof(JudySlot) + keysize); - - for( slot = 0; slot < cnt; slot++ ) - if( node[-slot-1] ) - break; - - judy->stack[judy->level].slot = slot; -#if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) - return &node[-slot-1]; -#else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) - return &node[-slot-1]; -#endif - next = node[-slot - 1]; - off = (off | JUDY_key_mask) + 1; - continue; - case JUDY_radix: - off++; - - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - table = (JudySlot *)(next & JUDY_mask); - for( slot = 0; slot < 256; slot++ ) - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( (next = inner[slot & 0x0F]) ) { - judy->stack[judy->level].slot = slot; - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[slot & 0x0F]; - else - break; - } - } else - slot |= 0x0F; - continue; -#ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) // leaf node? - return &node[-1]; - next = node[-1]; - off += cnt; - continue; -#endif - } - } - return NULL; -} - -// return last leaf cell pointer - -JudySlot *judy_last (Judy *judy, JudySlot next, unsigned int off, unsigned int depth) -{ -JudySlot *table, *inner; -unsigned int keysize, size; -JudySlot *node; -int slot, cnt; -unsigned char *base; - - while( next ) { - if( judy->level < judy->max ) - judy->level++; - - judy->stack[judy->level].next = next; - judy->stack[judy->level].off = off; - size = JudySize[next & 0x07]; - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - slot = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(next & JUDY_mask); - node = (JudySlot *)((next & JUDY_mask) + size); - judy->stack[judy->level].slot = --slot; - -#if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) -#else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) -#endif - return &node[-slot-1]; - - next = node[-slot-1]; - off += keysize; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - off++; - - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - for( slot = 256; slot--; ) { - judy->stack[judy->level].slot = slot; - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( (next = inner[slot & 0x0F]) ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[0]; - else - break; - } else - slot &= 0xF0; - } - continue; - -#ifndef ASKITIS - case JUDY_span: - node = (JudySlot *)((next & JUDY_mask) + JudySize[JUDY_span]); - base = (unsigned char *)(next & JUDY_mask); - cnt = JUDY_span_bytes; - if( !base[cnt - 1] ) // leaf node? - return &node[-1]; - next = node[-1]; - off += cnt; - continue; -#endif - } - } - return NULL; -} - -// judy_end: return last entry - -JudySlot *judy_end (Judy *judy) -{ - judy->level = 0; - return judy_last (judy, *judy->root, 0, 0); -} // judy_nxt: return next entry - -JudySlot *judy_nxt (Judy *judy) -{ -JudySlot *table, *inner; -int slot, size, cnt; -JudySlot *node; -JudySlot next; -unsigned int keysize; -unsigned char *base; -unsigned int depth; -unsigned int off; - - if( !judy->level ) - return judy_first (judy, *judy->root, 0, 0); - - while( judy->level ) { - next = judy->stack[judy->level].next; - slot = judy->stack[judy->level].slot; - off = judy->stack[judy->level].off; - keysize = JUDY_key_size - (off & JUDY_key_mask); - size = JudySize[next & 0x07]; - depth = off / JUDY_key_size; - - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - if( ++slot < cnt ) -#if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[slot * keysize] || judy->depth && ++depth == judy->depth ) -#else - if( !judy->depth && !base[slot * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) -#endif - { - judy->stack[judy->level].slot = slot; - return &node[-slot - 1]; - } else { - judy->stack[judy->level].slot = slot; - return judy_first (judy, node[-slot-1], (off | JUDY_key_mask) + 1, depth); - } - judy->level--; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if( judy->depth ) - if( !((off+1) & JUDY_key_mask) ) - depth++; - - while( ++slot < 256 ) - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) { - if( inner[slot & 0x0F] ) { - judy->stack[judy->level].slot = slot; - if( !judy->depth || depth < judy->depth ) - return judy_first(judy, inner[slot & 0x0F], off + 1, depth); - return &inner[slot & 0x0F]; - } - } else - slot |= 0x0F; - - judy->level--; - continue; -#ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; -#endif - } - } - return NULL; -} - -// judy_prv: return ptr to previous entry - -JudySlot *judy_prv (Judy *judy) -{ -int slot, size, keysize; -JudySlot *table, *inner; -JudySlot *node, next; -unsigned char *base; -unsigned int depth; -unsigned int off; - - if( !judy->level ) - return judy_last (judy, *judy->root, 0, 0); - - while( judy->level ) { - next = judy->stack[judy->level].next; - slot = judy->stack[judy->level].slot; - off = judy->stack[judy->level].off; - size = JudySize[next & 0x07]; - depth = off / JUDY_key_size; - - switch( next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - node = (JudySlot *)((next & JUDY_mask) + size); - if( !slot || !node[-slot] ) { - judy->level--; - continue; - } - - base = (unsigned char *)(next & JUDY_mask); - judy->stack[judy->level].slot--; - keysize = JUDY_key_size - (off & JUDY_key_mask); - -#if BYTE_ORDER != BIG_ENDIAN - if( !judy->depth && !base[(slot - 1) * keysize] || judy->depth && ++depth == judy->depth ) -#else - if( !judy->depth && !base[(slot - 1) * keysize + keysize - 1] || judy->depth && ++depth == judy->depth ) -#endif - return &node[-slot]; - return judy_last (judy, node[-slot], (off | JUDY_key_mask) + 1, depth); - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - - if( judy->depth ) - if( !((off + 1) & JUDY_key_mask) ) - depth++; - - while( slot-- ) { - judy->stack[judy->level].slot--; - if( (inner = (JudySlot *)(table[slot >> 4] & JUDY_mask)) ) - if( inner[slot & 0x0F] ) - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) - return &inner[0]; - else - return judy_last(judy, inner[slot & 0x0F], off + 1, depth); - } - - judy->level--; - continue; - -#ifndef ASKITIS - case JUDY_span: - judy->level--; - continue; -#endif - } - } - return NULL; -} - -// judy_del: delete string from judy array -// returning previous entry. - -JudySlot *judy_del (Judy *judy) -{ -int slot, off, size, type, high; -JudySlot *table, *inner; -JudySlot next, *node; -int keysize, cnt; -unsigned char *base; - - while( judy->level ) { - next = judy->stack[judy->level].next; - slot = judy->stack[judy->level].slot; - off = judy->stack[judy->level].off; - size = JudySize[next & 0x07]; - - switch( type = next & 0x07 ) { - case JUDY_1: - case JUDY_2: - case JUDY_4: - case JUDY_8: - case JUDY_16: - case JUDY_32: -#ifdef ASKITIS - case JUDY_64: -#endif - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - node = (JudySlot *)((next & JUDY_mask) + size); - base = (unsigned char *)(next & JUDY_mask); - - // move deleted slot to first slot - - while( slot ) { - node[-slot-1] = node[-slot]; - memcpy (base + slot * keysize, base + (slot - 1) * keysize, keysize); - slot--; - } - - // zero out first slot - - node[-1] = 0; - memset (base, 0, keysize); - - if( node[-cnt] ) { // does node have any slots left? - judy->stack[judy->level].slot++; - return judy_prv (judy); - } - - judy_free (judy, base, type); - judy->level--; - continue; - - case JUDY_radix: - table = (JudySlot *)(next & JUDY_mask); - inner = (JudySlot *)(table[slot >> 4] & JUDY_mask); - inner[slot & 0x0F] = 0; - high = slot & 0xF0; - - for( cnt = 16; cnt--; ) - if( inner[cnt] ) - return judy_prv (judy); - - judy_free (judy, inner, JUDY_radix); - table[slot >> 4] = 0; - - for( cnt = 16; cnt--; ) - if( table[cnt] ) - return judy_prv (judy); - - judy_free (judy, table, JUDY_radix); - judy->level--; - continue; - -#ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(next & JUDY_mask); - judy_free (judy, base, type); - judy->level--; - continue; -#endif - } - } - - // tree is now empty - - *judy->root = 0; - return NULL; -} - -// return cell for first key greater than or equal to given key - -JudySlot *judy_strt (Judy *judy, unsigned char *buff, unsigned int max) -{ -JudySlot *cell; - - judy->level = 0; - - if( !max ) - return judy_first (judy, *judy->root, 0, 0); - - if( (cell = judy_slot (judy, buff, max)) ) - return cell; - - return judy_nxt (judy); -} - -// split open span node - -#ifndef ASKITIS -void judy_splitspan (Judy *judy, JudySlot *next, unsigned char *base) -{ -JudySlot *node = (JudySlot *)(base + JudySize[JUDY_span]); -unsigned int cnt = JUDY_span_bytes; -unsigned char *newbase; -unsigned int off = 0; -#if BYTE_ORDER != BIG_ENDIAN -int i; -#endif - - do { - newbase = judy_alloc (judy, JUDY_1); - *next = (JudySlot)newbase | JUDY_1; - -#if BYTE_ORDER != BIG_ENDIAN - i = JUDY_key_size; - while( i-- ) - *newbase++ = base[off + i]; -#else - memcpy (newbase, base + off, JUDY_key_size); - newbase += JUDY_key_size; -#endif - next = (JudySlot *)newbase; - - off += JUDY_key_size; - cnt -= JUDY_key_size; - } while( cnt && base[off - 1] ); - - *next = node[-1]; - judy_free (judy, base, JUDY_span); -} -#endif - -// judy_cell: add string to judy array - -JudySlot *judy_cell (Judy *judy, unsigned char *buff, unsigned int max) -{ -judyvalue *src = (judyvalue *)buff; -int size, idx, slot, cnt, tst; -JudySlot *next = judy->root; -judyvalue test, value; -unsigned int off = 0, start; -JudySlot *table; -JudySlot *node; -unsigned int depth = 0; -unsigned int keysize; -unsigned char *base; - - judy->level = 0; -#ifdef ASKITIS - Words++; -#endif - - while( *next ) { -#ifndef ASKITIS - if( judy->level < judy->max ) - judy->level++; - - judy->stack[judy->level].next = *next; - judy->stack[judy->level].off = off; -#endif - switch( *next & 0x07 ) { - default: - size = JudySize[*next & 0x07]; - keysize = JUDY_key_size - (off & JUDY_key_mask); - cnt = size / (sizeof(JudySlot) + keysize); - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + size); - start = off; - slot = cnt; - value = 0; - - if( judy->depth ) { - value = src[depth++]; - off |= JUDY_key_mask; - off++; - value &= JudyMask[keysize]; - } else - do { - value <<= 8; - if( off < max ) - value |= buff[off]; - } while( ++off & JUDY_key_mask ); - - // find slot > key - - while( slot-- ) { - test = *(judyvalue *)(base + slot * keysize); -#if BYTE_ORDER == BIG_ENDIAN - test >>= 8 * (JUDY_key_size - keysize); -#else - test &= JudyMask[keysize]; -#endif - if( test <= value ) - break; - } -#ifndef ASKITIS - judy->stack[judy->level].slot = slot; -#endif - if( test == value ) { // new key is equal to slot key - next = &node[-slot-1]; - - // is this a leaf? - - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { -#ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; -#endif - return next; - } - - continue; - } - - // if this node is not full - // open up cell after slot - - if( !node[-1] ) { - memmove(base, base + keysize, slot * keysize); // move keys less than new key down one slot -#if BYTE_ORDER != BIG_ENDIAN - memcpy(base + slot * keysize, &value, keysize); // copy new key into slot -#else - test = value; - idx = keysize; - - while( idx-- ) - base[slot * keysize + idx] = test, test >>= 8; -#endif - for( idx = 0; idx < slot; idx++ ) - node[-idx-1] = node[-idx-2];// copy tree ptrs/cells down one slot - - node[-slot-1] = 0; // set new tree ptr/cell - next = &node[-slot-1]; - - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { -#ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; -#endif - return next; - } - - continue; - } - - if( size < JudySize[JUDY_max] ) { - next = judy_promote (judy, next, slot+1, value, keysize); - - if( !judy->depth && !(value & 0xFF) || judy->depth && depth == judy->depth ) { -#ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; -#endif - return next; - } - - continue; - } - - // split full maximal node into JUDY_radix nodes - // loop to reprocess new insert - - judy_splitnode (judy, next, size, keysize, depth); -#ifndef ASKITIS - judy->level--; -#endif - off = start; - if( judy->depth ) - depth--; - continue; - - case JUDY_radix: - table = (JudySlot *)(*next & JUDY_mask); // outer radix - - if( judy->depth ) - slot = (src[depth] >> ((JUDY_key_size - ++off & JUDY_key_mask) * 8)) & 0xff; - else if( off < max ) - slot = buff[off++]; - else - slot = 0, off++; - - if( judy->depth ) - if( !(off & JUDY_key_mask) ) - depth++; - - // allocate inner radix if empty - - if( !table[slot >> 4] ) - table[slot >> 4] = (JudySlot)judy_alloc (judy, JUDY_radix) | JUDY_radix; - - table = (JudySlot *)(table[slot >> 4] & JUDY_mask); -#ifndef ASKITIS - judy->stack[judy->level].slot = slot; -#endif - next = &table[slot & 0x0F]; - - if( !judy->depth && !slot || judy->depth && depth == judy->depth ) { // leaf? -#ifdef ASKITIS - if( *next ) - Found++; - else - Inserts++; -#endif - return next; - } - - continue; - -#ifndef ASKITIS - case JUDY_span: - base = (unsigned char *)(*next & JUDY_mask); - node = (JudySlot *)((*next & JUDY_mask) + JudySize[JUDY_span]); - cnt = JUDY_span_bytes; - tst = cnt; - - if( tst > (int)(max - off) ) - tst = max - off; - - value = strncmp((const char *)base, (const char *)(buff + off), tst); - - if( !value && tst < cnt && !base[tst] ) // leaf? - return &node[-1]; - - if( !value && tst == cnt ) { - next = &node[-1]; - off += cnt; - continue; - } - - // bust up JUDY_span node and produce JUDY_1 nodes - // then loop to reprocess insert - - judy_splitspan (judy, next, base); - judy->level--; - continue; -#endif - } - } - - // place JUDY_1 node under JUDY_radix node(s) - -#ifndef ASKITIS - if( off & JUDY_key_mask ) - if( judy->depth || off <= max ) { -#else - while( off <= max ) { -#endif - base = judy_alloc (judy, JUDY_1); - keysize = JUDY_key_size - (off & JUDY_key_mask); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; - - // fill in slot 0 with bytes of key - - if( judy->depth ) { - value = src[depth]; -#if BYTE_ORDER != BIG_ENDIAN - memcpy(base, &value, keysize); // copy new key into slot -#else - while( keysize-- ) - base[keysize] = value, value >>= 8; -#endif - } else { -#if BYTE_ORDER != BIG_ENDIAN - while( keysize ) - if( off + keysize <= max ) - *base++ = buff[off + --keysize]; - else - base++, --keysize; -#else - tst = keysize; - - if( tst > (int)(max - off) ) - tst = max - off; - - memcpy (base, buff + off, tst); -#endif - } -#ifndef ASKITIS - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; -#endif - next = &node[-1]; - - off |= JUDY_key_mask; - depth++; - off++; - } - - // produce span nodes to consume rest of key - // or judy_1 nodes if not string tree - -#ifndef ASKITIS - if( !judy->depth ) - while( off <= max ) { - base = judy_alloc (judy, JUDY_span); - *next = (JudySlot)base | JUDY_span; - node = (JudySlot *)(base + JudySize[JUDY_span]); - cnt = tst = JUDY_span_bytes; - if( tst > (int)(max - off) ) - tst = max - off; - memcpy (base, buff + off, tst); - - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off += tst; - depth++; - - if( !base[cnt-1] ) // done on leaf - break; - } - else - while( depth < judy->depth ) { - base = judy_alloc (judy, JUDY_1); - node = (JudySlot *)(base + JudySize[JUDY_1]); - *next = (JudySlot)base | JUDY_1; - - // fill in slot 0 with bytes of key - - *(judyvalue *)base = src[depth]; - - if( judy->level < judy->max ) - judy->level++; - judy->stack[judy->level].next = *next; - judy->stack[judy->level].slot = 0; - judy->stack[judy->level].off = off; - next = &node[-1]; - off |= JUDY_key_mask; - depth++; - off++; - } -#endif - -#ifdef ASKITIS - Inserts++; -#endif - return next; -} - -#if defined(STANDALONE) || defined(ASKITIS) - -#if defined(__APPLE__) || defined(linux) -#include -#include -#include -#include -#include -#else -#include -#include -#endif - -#include - -// memory map input file and sort - -// define pennysort parameters - -unsigned int PennyRecs = (4096 * 400); // records to sort to temp files -unsigned int PennyLine = 100; // length of input record -unsigned int PennyKey = 10; // length of input key -unsigned int PennyOff = 0; // key offset in input record - -unsigned long long PennyMerge; // PennyRecs * PennyLine = file map length -unsigned int PennyPasses; // number of intermediate files created -unsigned int PennySortTime; // cpu time to run sort -unsigned int PennyMergeTime; // cpu time to run merge - -typedef struct { - void *buff; // record pointer in input file map - void *next; // duplicate chain -} PennySort; - -void sort (FILE *infile, char *outname) -{ -unsigned long long size, off, offset, part; -int ifd = fileno (infile); -char filename[512]; -PennySort *line; -JudySlot *cell; -unsigned char *inbuff; -void *judy; -FILE *out; -#if defined(_WIN32) -HANDLE hndl, fm; -DWORD hiword; -FILETIME dummy[1]; -FILETIME user[1]; -#else -struct tms buff[1]; -#endif -time_t start = time(NULL); - - if( PennyOff + PennyKey > PennyLine ) - fprintf (stderr, "Key Offset + Key Length > Record Length\n"), exit(1); - - offset = 0; - PennyPasses = 0; - -#if defined(_WIN32) - hndl = (HANDLE)_get_osfhandle(ifd); - size = GetFileSize (hndl, &hiword); - fm = CreateFileMapping(hndl, NULL, PAGE_READONLY, hiword, (DWORD)size, NULL); - if( !fm ) - fprintf (stderr, "CreateFileMapping error %d\n", GetLastError()), exit(1); - size |= (unsigned long long)hiword << 32; -#else - size = lseek (ifd, 0L, 2); -#endif - - while( offset < size ) { -#if defined(_WIN32) - part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part); - if( !inbuff ) - fprintf (stderr, "MapViewOfFile error %d\n", GetLastError()), exit(1); -#else - inbuff = mmap (NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset); - - if( inbuff == MAP_FAILED ) - fprintf (stderr, "mmap error %d\n", errno), exit(1); - - if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL) < 0 ) - fprintf (stderr, "madvise error %d\n", errno); -#endif - judy = judy_open (PennyKey, 0); - - off = 0; - - // build judy array from mapped input chunk - - while( offset + off < size && off < PennyMerge ) { - line = judy_data (judy, sizeof(PennySort)); - cell = judy_cell (judy, inbuff + off + PennyOff, PennyKey); - line->next = *(void **)cell; - line->buff = inbuff + off; - - *(PennySort **)cell = line; - off += PennyLine; - } - - sprintf (filename, "%s.%d", outname, PennyPasses); - out = fopen (filename, "wb"); - setvbuf (out, NULL, _IOFBF, 4096 * 1024); - -#ifndef _WIN32 - if( madvise (inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM) < 0 ) - fprintf (stderr, "madvise error %d\n", errno); -#endif - - // write judy array in sorted order to temporary file - - cell = judy_strt (judy, NULL, 0); - - if( cell ) do { - line = *(PennySort **)cell; - do fwrite (line->buff, PennyLine, 1, out); - while( line = line->next ); - } while( cell = judy_nxt (judy) ); - -#if defined(_WIN32) - UnmapViewOfFile (inbuff); -#else - munmap (inbuff, PennyMerge); -#endif - judy_close (judy); - offset += off; - fflush (out); - fclose (out); - PennyPasses++; - } - fprintf (stderr, "End Sort %d secs", time(NULL) - start); -#if defined(_WIN32) - CloseHandle (fm); - GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); - PennySortTime = *(unsigned long long*)user / 10000000; -#else - times (buff); - PennySortTime = buff->tms_utime/100; -#endif - fprintf (stderr, " Cpu %d\n", PennySortTime); -} - -int merge (FILE *out, char *outname) -{ -time_t start = time(NULL); -char filename[512]; -JudySlot *cell; -unsigned int nxt, idx; -unsigned char **line; -unsigned int *next; -void *judy; -FILE **in; - - next = calloc (PennyPasses + 1, sizeof(unsigned int)); - line = calloc (PennyPasses, sizeof(void *)); - in = calloc (PennyPasses, sizeof(void *)); - - judy = judy_open (PennyKey, 0); - - // initialize merge with one record from each temp file - - for( idx = 0; idx < PennyPasses; idx++ ) { - sprintf (filename, "%s.%d", outname, idx); - in[idx] = fopen (filename, "rb"); - line[idx] = malloc (PennyLine); - setvbuf (in[idx], NULL, _IOFBF, 4096 * 1024); - fread (line[idx], PennyLine, 1, in[idx]); - cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; - *cell = idx + 1; - } - - // output records, replacing smallest each time - - while( cell = judy_strt (judy, NULL, 0) ) { - nxt = *(unsigned int *)cell; - judy_del (judy); - - // process duplicates - - while( idx = nxt ) { - nxt = next[idx--]; - fwrite (line[idx], PennyLine, 1, out); - - if( fread (line[idx], PennyLine, 1, in[idx]) ) { - cell = judy_cell (judy, line[idx] + PennyOff, PennyKey); - next[idx + 1] = *(unsigned int *)cell; - *cell = idx + 1; - } else - next[idx + 1] = 0; - } - } - - for( idx = 0; idx < PennyPasses; idx++ ) { - fclose (in[idx]); - free (line[idx]); - } - - free (line); - free (next); - free (in); - - fprintf (stderr, "End Merge %d secs", time(NULL) - start); -#ifdef _WIN32 - { - FILETIME dummy[1]; - FILETIME user[1]; - GetProcessTimes (GetCurrentProcess(), dummy, dummy, dummy, user); - PennyMergeTime = *(unsigned long long*)user / 10000000; - } -#else - { - struct tms buff[1]; - times (buff); - PennyMergeTime = buff->tms_utime/100; - } -#endif - fprintf (stderr, " Cpu %d\n", PennyMergeTime - PennySortTime); - judy_close (judy); - fflush (out); - fclose (out); - return 0; -} - -// compilation: -// cc -O3 judy64j.c - -// usage: -// a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs] -// where keysize is 10 to indicate pennysort files - -#if !defined(_WIN32) -typedef struct timeval timer; -#endif - -// ASKITIS compilation: -// cc -O3 judy64n.c - -// usage: -// a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs] -// where keysize is 10 to indicate pennysort files - -// naskitis.com. -// g++ -O3 -fpermissive -fomit-frame-pointer -w -D STANDALONE -D ASKITIS -o judy64n judy64n.c -// ./judy64n [input-file-to-build-judy] e.g. distinct_1 or skew1_1 - -// note: the judy array is an in-memory data structure. As such, make sure you -// have enough memory to hold the entire input file + data structure, otherwise -// you'll have to break the input file into smaller pieces and load them in -// on-by-one. - -// Also, the file to search judy is hardcoded to skew1_1. - -int main (int argc, char **argv) -{ -unsigned char buff[1024]; -JudySlot max = 0; -JudySlot *cell; -FILE *in, *out; -void *judy; -unsigned int len; -unsigned int idx; -#ifdef ASKITIS -char *askitis; -int prev, off; -float insert_real_time=0.0; -float search_real_time=0.0; -int size; -#if !defined(_WIN32) -timer start, stop; -#else -time_t start[1], stop[1]; -#endif -#endif - - if( argc > 1 ) - in = fopen (argv[1], "rb"); - else - in = stdin; - - if( argc > 2 ) - out = fopen (argv[2], "wb"); - else - out = stdout; - - setvbuf (out, NULL, _IOFBF, 4096 * 1024); - - if( !in ) - fprintf (stderr, "unable to open input file\n"); - - if( !out ) - fprintf (stderr, "unable to open output file\n"); - - if( argc > 6 ) - PennyRecs = atoi(argv[6]); - - if( argc > 5 ) - PennyOff = atoi(argv[5]); - - if( argc > 4 ) - PennyLine = atoi(argv[4]); - - PennyMerge = (unsigned long long)PennyLine * PennyRecs; - - if( argc > 3 ) { - PennyKey = atoi(argv[3]); - sort (in, argv[2]); - return merge (out, argv[2]); - } - -#ifdef ASKITIS - judy = judy_open (1024, 0); - -// build judy array - size = lseek (fileno(in), 0L, 2); - askitis = malloc(size); - lseek (fileno(in), 0L, 0); - read (fileno(in), askitis,size); - prev = 0; -// naskitis.com: -// Start the timer. - -#if !defined(_WIN32) - gettimeofday(&start, NULL); -#else - time(start); -#endif - - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *(judy_cell (judy, askitis+prev, off - prev)) += 1; // count instances of string - prev = off + 1; - } -// naskitis.com: -// Stop the timer and do some math to compute the time required to insert the strings into the judy array. - -#if !defined(_WIN32) - gettimeofday(&stop, NULL); - - insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * (stop.tv_usec - start.tv_usec ); - insert_real_time = insert_real_time/1000.0; -#else - time (stop); - insert_real_time = *stop - *start; -#endif - -// naskitis.com: -// Free the input buffer used to store the first file. We must do this before we get the process size below. - free (askitis); - fprintf(stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem/1000000., "Time to insert:", insert_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); - - Words = 0; - Inserts = 0; - Found = 0; - -// search judy array - if( in = freopen ("skew1_1", "rb", in) ) - size = lseek (fileno(in), 0L, 2); - else - exit(0); - askitis = malloc(size); - lseek (fileno(in), 0L, 0); - read (fileno(in), askitis,size); - prev = 0; - -#if !defined(_WIN32) - gettimeofday(&start, NULL); -#else - time(start); -#endif - - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *judy_cell (judy, askitis+prev, off - prev) += 1; - prev = off + 1; - } -// naskitis.com: -// Stop the timer and do some math to compute the time required to search the judy array. - -#if !defined(_WIN32) - gettimeofday(&stop, NULL); - search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 - * (stop.tv_usec - start.tv_usec ); - search_real_time = search_real_time/1000.0; -#else - time(stop); - search_real_time = *stop - *start; -#endif - -// naskitis.com: -// To do: report a count on the number of strings found. - - fprintf(stderr,"\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem/1000000., "Time to search:", search_real_time); - fprintf(stderr, "%-20s %d\n", "Words:", Words); - fprintf(stderr, "%-20s %d\n", "Inserts:", Inserts); - fprintf(stderr, "%-20s %d\n", "Found:", Found); - exit(0); -#endif -#ifdef HEXKEYS - judy = judy_open (1024, 16/JUDY_key_size); - - while( fgets((char *)buff, sizeof(buff), in) ) { - judyvalue key[16/JUDY_key_size]; - if( len = strlen((const char *)buff) ) - buff[--len] = 0; // remove LF -#if JUDY_key_size == 4 - key[3] = strtoul (buff + 24, NULL, 16); - buff[24] = 0; - key[2] = strtoul (buff + 16, NULL, 16); - buff[16] = 0; - key[1] = strtoul (buff + 8, NULL, 16); - buff[8] = 0; - key[0] = strtoul (buff, NULL, 16); -#else - key[1] = strtoull (buff + 16, NULL, 16); - buff[16] = 0; - key[0] = strtoull (buff, NULL, 16); -#endif - *(judy_cell (judy, (void *)key, 0)) += 1; // count instances of string - max++; - } - - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - - cell = judy_strt (judy, NULL, 0); - - if( cell ) do { - judyvalue key[16/JUDY_key_size]; - len = judy_key(judy, (void *)key, 0); - for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates -#if JUDY_key_size == 4 - fprintf (out, "%.8X", key[0]); - fprintf (out, "%.8X", key[1]); - fprintf (out, "%.8X", key[2]); - fprintf (out, "%.8X", key[3]); -#else - fprintf (out, "%.16llX", key[0]); - fprintf (out, "%.16llX", key[1]); -#endif - fputc('\n', out); - } - } while( cell = judy_nxt (judy) ); - -#else - judy = judy_open (1024, 0); - - while( fgets((char *)buff, sizeof(buff), in) ) { - if( len = strlen((const char *)buff) ) - buff[--len] = 0; // remove LF - *(judy_cell (judy, buff, len)) += 1; // count instances of string - max++; - } - - fprintf(stderr, "%" PRIuint " memory used\n", MaxMem); - - cell = judy_strt (judy, NULL, 0); - - if( cell ) do { - len = judy_key(judy, buff, sizeof(buff)); - for( idx = 0; idx < *cell; idx++ ){ // spit out duplicates - fwrite(buff, len, 1, out); - fputc('\n', out); - } - } while( cell = judy_nxt (judy) ); -#endif -#if 0 - // test deletion all the way to an empty tree - - if( cell = judy_prv (judy) ) - do max -= *cell; - while( cell = judy_del (judy) ); - - assert (max == 0); -#endif - judy_close(judy); - return 0; -} -#endif - diff --git a/src/cllazyfile/judy/test/hexSort.c b/src/cllazyfile/judy/test/hexSort.c deleted file mode 100644 index 0d770d752..000000000 --- a/src/cllazyfile/judy/test/hexSort.c +++ /dev/null @@ -1,124 +0,0 @@ -// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ ) -// This code is public domain. - -// Author Karl Malbrain, malbrain AT yahoo.com -// with assistance from Jan Weiss. -// modifications (and any bugs) by Mark Pictor, mpictor at gmail - -// Simplified judy arrays for strings and integers -// Adapted from the ideas of Douglas Baskins of HP. - -// Map a set of keys to corresponding memory cells (uints). -// Each cell must be set to a non-zero value by the caller. - - -// Integer mappings are denoted by calling judy_open with the -// Integer depth of the Judy Trie as the second argument. - -#ifndef STANDALONE -# error must define STANDALONE while compiling this file and judy64.c -#endif - -#include "judy.h" -#include "sort.h" - -unsigned int MaxMem = 0; -/** - usage: - a.out [in-file] [out-file] - where all lines of in-file are 32 chars, hexadecimal - On linux, a 1M-line file can be created with the following: - hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >in-file -*/ -int main( int argc, char ** argv ) { - unsigned char buff[1024]; - JudySlot max = 0; - JudySlot * cell; - FILE * in, *out; - void * judy; - unsigned int len; - unsigned int idx; - - if( argc > 1 ) { - in = fopen( argv[1], "rb" ); - } else { - in = stdin; - } - - if( argc > 2 ) { - out = fopen( argv[2], "wb" ); - } else { - out = stdout; - } - - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - - if( !in ) { - fprintf( stderr, "unable to open input file\n" ); - } - - if( !out ) { - fprintf( stderr, "unable to open output file\n" ); - } - - PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - - judy = judy_open( 1024, 16 / JUDY_key_size ); - - while( fgets( ( char * )buff, sizeof( buff ), in ) ) { - judyvalue key[16 / JUDY_key_size]; - if( len = strlen( ( const char * )buff ) ) { - buff[--len] = 0; // remove LF - } -#if JUDY_key_size == 4 - key[3] = strtoul( buff + 24, NULL, 16 ); - buff[24] = 0; - key[2] = strtoul( buff + 16, NULL, 16 ); - buff[16] = 0; - key[1] = strtoul( buff + 8, NULL, 16 ); - buff[8] = 0; - key[0] = strtoul( buff, NULL, 16 ); -#else - key[1] = strtoull( buff + 16, NULL, 16 ); - buff[16] = 0; - key[0] = strtoull( buff, NULL, 16 ); -#endif - *( judy_cell( judy, ( void * )key, 0 ) ) += 1; // count instances of string - max++; - } - - fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - - cell = judy_strt( judy, NULL, 0 ); - - if( cell ) do { - judyvalue key[16 / JUDY_key_size]; - len = judy_key( judy, ( void * )key, 0 ); - for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates -#if JUDY_key_size == 4 - fprintf( out, "%.8X", key[0] ); - fprintf( out, "%.8X", key[1] ); - fprintf( out, "%.8X", key[2] ); - fprintf( out, "%.8X", key[3] ); -#else - fprintf( out, "%.16llX", key[0] ); - fprintf( out, "%.16llX", key[1] ); -#endif - fputc( '\n', out ); - } - } while( cell = judy_nxt( judy ) ); - -#if 0 - // test deletion all the way to an empty tree - - if( cell = judy_prv( judy ) ) - do { - max -= *cell; - } while( cell = judy_del( judy ) ); - - assert( max == 0 ); -#endif - judy_close( judy ); - return 0; -} - diff --git a/src/cllazyfile/judy/test/judyL2test.cc b/src/cllazyfile/judy/test/judyL2test.cc deleted file mode 100644 index 20ef559a9..000000000 --- a/src/cllazyfile/judy/test/judyL2test.cc +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include - -#include "judyL2Array.h" -typedef judyL2Array< uint64_t, uint64_t > jl2a; - -bool testFind( jl2a & j, uint64_t key, unsigned int count ) { - jl2a::cvector * v = j.find( key ); - std::cout << "find: key " << key << " ..." << std::endl; - if( count > 0 ) { - if( !v || !j.success() || ( v->size() != count ) ) { - std::cout << " false negative - v: " << v << " success: " << j.success(); - if( v ) { - std::cout << " expected count: " << count << " actual: " << v->size(); - } - std::cout << std::endl; - return false; - } else { - // note - this doesn't verify that the right keys are returned, just the right number! - jl2a::vector::const_iterator it = v->begin(); - std::cout << " correct number of values -"; - for( ; it != v->end(); it++ ) { - std::cout << " " << *it; - } - std::cout << std::endl; - } - } else { - if( v || j.success() ) { - std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; - return false; - } else { - std::cout << " not found, as expected." << std::endl; - } - } - return true; -} - -int main() { - bool pass = true; - jl2a jl; - std::cout.setf( std::ios::boolalpha ); -// std::cout << "size of judyL2Array: " << sizeof( jl ) << std::endl; - jl.insert( 5, 12 ); - jl.insert( 6, 2 ); - jl.insert( 7, 312 ); - jl.insert( 11, 412 ); - jl.insert( 7, 313 ); - jl2a::cpair kv = jl.atOrAfter( 4 ); - std::cout << "atOrAfter test ..." << std::endl; - if( kv.value != 0 && jl.success() ) { - std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; - } else { - std::cout << " failed" << std::endl; - pass = false; - } - - pass &= testFind( jl, 8, 0 ); - pass &= testFind( jl, 11, 1 ); - pass &= testFind( jl, 7, 2 ); - - jl.clear(); - - //TODO test all of judyL2Array - if( pass ) { - std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); - } else { - std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); - } -} \ No newline at end of file diff --git a/src/cllazyfile/judy/test/judyLtest.cc b/src/cllazyfile/judy/test/judyLtest.cc deleted file mode 100644 index 01ae3d5d7..000000000 --- a/src/cllazyfile/judy/test/judyLtest.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -#include "judyLArray.h" - -int main() { - std::cout.setf( std::ios::boolalpha ); - judyLArray< uint64_t, uint64_t > jl; - std::cout << "size of judyLArray: " << sizeof( jl ) << std::endl; - jl.insert( 5, 12 ); - jl.insert( 6, 2 ); - jl.insert( 7, 312 ); - jl.insert( 8, 412 ); - judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter( 4 ); - std::cout << "k " << kv.key << " v " << kv.value << std::endl; - - long v = jl.find( 11 ); - if( v != 0 || jl.success() ) { - std::cout << "find: false positive - v: " << v << " success: " << jl.success() << std::endl; - exit( EXIT_FAILURE ); - } - v = jl.find( 7 ); - if( v != 312 || !jl.success() ) { - std::cout << "find: false negative - v: " << v << " success: " << jl.success() << std::endl; - exit( EXIT_FAILURE ); - } - - jl.clear(); - - //TODO test all of judyLArray - exit( EXIT_SUCCESS ); -} \ No newline at end of file diff --git a/src/cllazyfile/judy/test/judyS2test.cc b/src/cllazyfile/judy/test/judyS2test.cc deleted file mode 100644 index ec25f960b..000000000 --- a/src/cllazyfile/judy/test/judyS2test.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include - -#include "judyS2Array.h" - -typedef judyS2Array< uint64_t > js2a; - -bool testFind( js2a & j, const char * key, unsigned int count ) { - js2a::cvector * v = j.find( key ); - std::cout << "find: key " << key << " ..." << std::endl; - if( count > 0 ) { - if( !v || !j.success() || ( v->size() != count ) ) { - std::cout << " false negative - v: " << v << " success: " << j.success(); - if( v ) { - std::cout << " expected count: " << count << " actual: " << v->size(); - } - std::cout << std::endl; - return false; - } else { - // note - this doesn't verify that the right keys are returned, just the right number! - js2a::vector::const_iterator it = v->begin(); - std::cout << " correct number of values -"; - for( ; it != v->end(); it++ ) { - std::cout << " " << *it; - } - std::cout << std::endl; - } - } else { - if( v || j.success() ) { - std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl; - return false; - } else { - std::cout << " not found, as expected." << std::endl; - } - } - return true; -} - -int main() { - bool pass = true; - std::cout.setf( std::ios::boolalpha ); - - js2a js( 255 ); - js.insert( "blah", 1234 ); - js.insert( "bah", 124 ); - js.insert( "blh", 123 ); - js.insert( "blh", 4123 ); - js.insert( "bla", 134 ); - js.insert( "bh", 234 ); - - js2a::cpair kv = js.atOrAfter( "ab" ); - std::cout << "atOrAfter test ..." << std::endl; - if( kv.value != 0 && js.success() ) { - std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl; - } else { - std::cout << " failed" << std::endl; - pass = false; - } - - pass &= testFind( js, "sdafsd", 0 ); - pass &= testFind( js, "bah", 1 ); - pass &= testFind( js, "blh", 2 ); - - js.clear(); - - //TODO test all of judyS2Array - if( pass ) { - std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); - } else { - std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); - } -} \ No newline at end of file diff --git a/src/cllazyfile/judy/test/judyStest.cc b/src/cllazyfile/judy/test/judyStest.cc deleted file mode 100644 index 3d620b015..000000000 --- a/src/cllazyfile/judy/test/judyStest.cc +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "judySArray.h" - -int main() { - bool pass = true; - std::cout.setf( std::ios::boolalpha ); - - judySArray< uint64_t > js( 255 ); - js.insert( "blah", 1234 ); - js.insert( "bah", 124 ); - js.insert( "blh", 123 ); - js.insert( "bla", 134 ); - js.insert( "bh", 234 ); - - - judySArray< uint64_t >::pair kv = js.atOrAfter( "ab" ); - //TODO if()... - std::cout << "k " << kv.key << " v " << kv.value << std::endl; - - long v = js.find( "sdafsd" ); - if( v != 0 || js.success() ) { - std::cout << "find: false positive - v: " << v << " success: " << js.success() << std::endl; - pass = false; - } - v = js.find( "bah" ); - if( v != 124 || !js.success() ) { - std::cout << "find: false negative - v: " << v << " success: " << js.success() << std::endl; - pass = false; - } - - - //TODO test all of judySArray - if( pass ) { - std::cout << "All tests passed." << std::endl; - exit( EXIT_SUCCESS ); - } else { - std::cout << "At least one test failed." << std::endl; - exit( EXIT_FAILURE ); - } -} \ No newline at end of file diff --git a/src/cllazyfile/judy/test/pennySort.c b/src/cllazyfile/judy/test/pennySort.c deleted file mode 100644 index a279b1a70..000000000 --- a/src/cllazyfile/judy/test/pennySort.c +++ /dev/null @@ -1,236 +0,0 @@ -// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ ) -// This code is public domain. - -// Author Karl Malbrain, malbrain AT yahoo.com -// with assistance from Jan Weiss. -// modifications (and any bugs) by Mark Pictor, mpictor at gmail - -// Simplified judy arrays for strings and integers -// Adapted from the ideas of Douglas Baskins of HP. - -// Map a set of keys to corresponding memory cells (uints). -// Each cell must be set to a non-zero value by the caller. - -// STANDALONE is defined to compile into a string sorter. - -// String mappings are denoted by calling judy_open with zero as -// the second argument. - -#ifndef STANDALONE -# error must define STANDALONE while compiling this file and judy64.c -#endif - -#include "judy.h" -#include "sort.h" - -unsigned int MaxMem = 0; - -// usage: -// a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs] -// where keysize is 10 to indicate pennysort files - -// ASKITIS compilation: -// g++ -O3 -fpermissive -fomit-frame-pointer -w -D STANDALONE -D ASKITIS -o judy64n judy64n.c -// ./judy64n [input-file-to-build-judy] e.g. distinct_1 or skew1_1 - -// note: the judy array is an in-memory data structure. As such, make sure you -// have enough memory to hold the entire input file + data structure, otherwise -// you'll have to break the input file into smaller pieces and load them in -// on-by-one. - -// Also, the file to search judy is hardcoded to skew1_1. - -int main( int argc, char ** argv ) { - unsigned char buff[1024]; - JudySlot max = 0; - JudySlot * cell; - FILE * in, *out; - void * judy; - unsigned int len; - unsigned int idx; -#ifdef ASKITIS - char * askitis; - int prev, off; - float insert_real_time = 0.0; - float search_real_time = 0.0; - int size; -#if !defined(_WIN32) - timer start, stop; -#else - time_t start[1], stop[1]; -#endif -#endif - - if( argc > 1 ) { - in = fopen( argv[1], "rb" ); - } else { - in = stdin; - } - - if( argc > 2 ) { - out = fopen( argv[2], "wb" ); - } else { - out = stdout; - } - - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - - if( !in ) { - fprintf( stderr, "unable to open input file\n" ); - } - - if( !out ) { - fprintf( stderr, "unable to open output file\n" ); - } - - if( argc > 6 ) { - PennyRecs = atoi( argv[6] ); - } - - if( argc > 5 ) { - PennyOff = atoi( argv[5] ); - } - - if( argc > 4 ) { - PennyLine = atoi( argv[4] ); - } - - PennyMerge = ( unsigned long long )PennyLine * PennyRecs; - - if( argc > 3 ) { - PennyKey = atoi( argv[3] ); - sort( in, argv[2] ); - return merge( out, argv[2] ); - } - -#ifdef ASKITIS - judy = judy_open( 1024, 0 ); - -// build judy array - size = lseek( fileno( in ), 0L, 2 ); - askitis = malloc( size ); - lseek( fileno( in ), 0L, 0 ); - read( fileno( in ), askitis, size ); - prev = 0; -// naskitis.com: -// Start the timer. - -#if !defined(_WIN32) - gettimeofday( &start, NULL ); -#else - time( start ); -#endif - - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *( judy_cell( judy, askitis + prev, off - prev ) ) += 1; // count instances of string - prev = off + 1; - } -// naskitis.com: -// Stop the timer and do some math to compute the time required to insert the strings into the judy array. - -#if !defined(_WIN32) - gettimeofday( &stop, NULL ); - - insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * ( stop.tv_usec - start.tv_usec ); - insert_real_time = insert_real_time / 1000.0; -#else - time( stop ); - insert_real_time = *stop - *start; -#endif - -// naskitis.com: -// Free the input buffer used to store the first file. We must do this before we get the process size below. - free( askitis ); - fprintf( stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time ); - fprintf( stderr, "%-20s %d\n", "Words:", Words ); - fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); - fprintf( stderr, "%-20s %d\n", "Found:", Found ); - - Words = 0; - Inserts = 0; - Found = 0; - -// search judy array - if( in = freopen( "skew1_1", "rb", in ) ) { - size = lseek( fileno( in ), 0L, 2 ); - } else { - exit( 0 ); - } - askitis = malloc( size ); - lseek( fileno( in ), 0L, 0 ); - read( fileno( in ), askitis, size ); - prev = 0; - -#if !defined(_WIN32) - gettimeofday( &start, NULL ); -#else - time( start ); -#endif - - for( off = 0; off < size; off++ ) - if( askitis[off] == '\n' ) { - *judy_cell( judy, askitis + prev, off - prev ) += 1; - prev = off + 1; - } -// naskitis.com: -// Stop the timer and do some math to compute the time required to search the judy array. - -#if !defined(_WIN32) - gettimeofday( &stop, NULL ); - search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 - * ( stop.tv_usec - start.tv_usec ); - search_real_time = search_real_time / 1000.0; -#else - time( stop ); - search_real_time = *stop - *start; -#endif - -// naskitis.com: -// To do: report a count on the number of strings found. - - fprintf( stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n", - "Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time ); - fprintf( stderr, "%-20s %d\n", "Words:", Words ); - fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts ); - fprintf( stderr, "%-20s %d\n", "Found:", Found ); - exit( 0 ); -#endif - - judy = judy_open( 1024, 0 ); - - while( fgets( ( char * )buff, sizeof( buff ), in ) ) { - if( len = strlen( ( const char * )buff ) ) { - buff[--len] = 0; // remove LF - } - *( judy_cell( judy, buff, len ) ) += 1; // count instances of string - max++; - } - - fprintf( stderr, "%" PRIuint " memory used\n", MaxMem ); - - cell = judy_strt( judy, NULL, 0 ); - - if( cell ) do { - len = judy_key( judy, buff, sizeof( buff ) ); - for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates - fwrite( buff, len, 1, out ); - fputc( '\n', out ); - } - } while( cell = judy_nxt( judy ) ); - -#if 0 - // test deletion all the way to an empty tree - - if( cell = judy_prv( judy ) ) - do { - max -= *cell; - } while( cell = judy_del( judy ) ); - - assert( max == 0 ); -#endif - judy_close( judy ); - return 0; -} - diff --git a/src/cllazyfile/judy/test/sort.c b/src/cllazyfile/judy/test/sort.c deleted file mode 100644 index e483b92e0..000000000 --- a/src/cllazyfile/judy/test/sort.c +++ /dev/null @@ -1,233 +0,0 @@ -// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ ) -// This code is public domain. - -// Author Karl Malbrain, malbrain AT yahoo.com -// with assistance from Jan Weiss. -// modifications (and any bugs) by Mark Pictor, mpictor at gmail - -// Simplified judy arrays for strings and integers -// Adapted from the ideas of Douglas Baskins of HP. - -// Map a set of keys to corresponding memory cells (uints). -// Each cell must be set to a non-zero value by the caller. - -// STANDALONE is defined to compile into a string sorter. - -// String mappings are denoted by calling judy_open with zero as -// the second argument. Integer mappings are denoted by calling -// judy_open with the Integer depth of the Judy Trie as the second -// argument. - -#include "judy.h" -#include "sort.h" - -// memory map input file and sort - -// define pennysort parameters -unsigned int PennyRecs = ( 4096 * 400 ); // records to sort to temp files -unsigned int PennyLine = 100; // length of input record -unsigned int PennyKey = 10; // length of input key -unsigned int PennyOff = 0; // key offset in input record - -unsigned long long PennyMerge; // PennyRecs * PennyLine = file map length -unsigned int PennyPasses; // number of intermediate files created -unsigned int PennySortTime; // cpu time to run sort -unsigned int PennyMergeTime; // cpu time to run merge - -void sort( FILE * infile, char * outname ) { - unsigned long long size, off, offset, part; - int ifd = fileno( infile ); - char filename[512]; - PennySort * line; - JudySlot * cell; - unsigned char * inbuff; - void * judy; - FILE * out; -#if defined(_WIN32) - HANDLE hndl, fm; - DWORD hiword; - FILETIME dummy[1]; - FILETIME user[1]; -#else - struct tms buff[1]; -#endif - time_t start = time( NULL ); - - if( PennyOff + PennyKey > PennyLine ) { - fprintf( stderr, "Key Offset + Key Length > Record Length\n" ), exit( 1 ); - } - - offset = 0; - PennyPasses = 0; - -#if defined(_WIN32) - hndl = ( HANDLE )_get_osfhandle( ifd ); - size = GetFileSize( hndl, &hiword ); - fm = CreateFileMapping( hndl, NULL, PAGE_READONLY, hiword, ( DWORD )size, NULL ); - if( !fm ) { - fprintf( stderr, "CreateFileMapping error %d\n", GetLastError() ), exit( 1 ); - } - size |= ( unsigned long long )hiword << 32; -#else - size = lseek( ifd, 0L, 2 ); -#endif - - while( offset < size ) { -#if defined(_WIN32) - part = offset + PennyMerge > size ? size - offset : PennyMerge; - inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part ); - if( !inbuff ) { - fprintf( stderr, "MapViewOfFile error %d\n", GetLastError() ), exit( 1 ); - } -#else - inbuff = mmap( NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset ); - - if( inbuff == MAP_FAILED ) { - fprintf( stderr, "mmap error %d\n", errno ), exit( 1 ); - } - - if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL ) < 0 ) { - fprintf( stderr, "madvise error %d\n", errno ); - } -#endif - judy = judy_open( PennyKey, 0 ); - - off = 0; - - // build judy array from mapped input chunk - - while( offset + off < size && off < PennyMerge ) { - line = judy_data( judy, sizeof( PennySort ) ); - cell = judy_cell( judy, inbuff + off + PennyOff, PennyKey ); - line->next = *( void ** )cell; - line->buff = inbuff + off; - - *( PennySort ** )cell = line; - off += PennyLine; - } - - sprintf( filename, "%s.%d", outname, PennyPasses ); - out = fopen( filename, "wb" ); - setvbuf( out, NULL, _IOFBF, 4096 * 1024 ); - -#ifndef _WIN32 - if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM ) < 0 ) { - fprintf( stderr, "madvise error %d\n", errno ); - } -#endif - - // write judy array in sorted order to temporary file - - cell = judy_strt( judy, NULL, 0 ); - - if( cell ) do { - line = *( PennySort ** )cell; - do { - fwrite( line->buff, PennyLine, 1, out ); - } while( line = line->next ); - } while( cell = judy_nxt( judy ) ); - -#if defined(_WIN32) - UnmapViewOfFile( inbuff ); -#else - munmap( inbuff, PennyMerge ); -#endif - judy_close( judy ); - offset += off; - fflush( out ); - fclose( out ); - PennyPasses++; - } - fprintf( stderr, "End Sort %llu secs", ( unsigned long long ) time( NULL ) - start ); -#if defined(_WIN32) - CloseHandle( fm ); - GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); - PennySortTime = *( unsigned long long * )user / 10000000; -#else - times( buff ); - PennySortTime = buff->tms_utime / 100; -#endif - fprintf( stderr, " Cpu %d\n", PennySortTime ); -} - -int merge( FILE * out, char * outname ) { - time_t start = time( NULL ); - char filename[512]; - JudySlot * cell; - unsigned int nxt, idx; - unsigned char ** line; - unsigned int * next; - void * judy; - FILE ** in; - - next = calloc( PennyPasses + 1, sizeof( unsigned int ) ); - line = calloc( PennyPasses, sizeof( void * ) ); - in = calloc( PennyPasses, sizeof( void * ) ); - - judy = judy_open( PennyKey, 0 ); - - // initialize merge with one record from each temp file - - for( idx = 0; idx < PennyPasses; idx++ ) { - sprintf( filename, "%s.%d", outname, idx ); - in[idx] = fopen( filename, "rb" ); - line[idx] = malloc( PennyLine ); - setvbuf( in[idx], NULL, _IOFBF, 4096 * 1024 ); - fread( line[idx], PennyLine, 1, in[idx] ); - cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); - next[idx + 1] = *( unsigned int * )cell; - *cell = idx + 1; - } - - // output records, replacing smallest each time - - while( cell = judy_strt( judy, NULL, 0 ) ) { - nxt = *( unsigned int * )cell; - judy_del( judy ); - - // process duplicates - - while( idx = nxt ) { - nxt = next[idx--]; - fwrite( line[idx], PennyLine, 1, out ); - - if( fread( line[idx], PennyLine, 1, in[idx] ) ) { - cell = judy_cell( judy, line[idx] + PennyOff, PennyKey ); - next[idx + 1] = *( unsigned int * )cell; - *cell = idx + 1; - } else { - next[idx + 1] = 0; - } - } - } - - for( idx = 0; idx < PennyPasses; idx++ ) { - fclose( in[idx] ); - free( line[idx] ); - } - - free( line ); - free( next ); - free( in ); - - fprintf( stderr, "End Merge %llu secs", ( unsigned long long ) time( NULL ) - start ); -#ifdef _WIN32 - { - FILETIME dummy[1]; - FILETIME user[1]; - GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user ); - PennyMergeTime = *( unsigned long long * )user / 10000000; - } -#else - { - struct tms buff[1]; - times( buff ); - PennyMergeTime = buff->tms_utime / 100; - } -#endif - fprintf( stderr, " Cpu %d\n", PennyMergeTime - PennySortTime ); - judy_close( judy ); - fflush( out ); - fclose( out ); - return 0; -} diff --git a/src/cllazyfile/judy/test/sort.h b/src/cllazyfile/judy/test/sort.h deleted file mode 100644 index 785e58d69..000000000 --- a/src/cllazyfile/judy/test/sort.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef SORT_H -#define SORT_H - -// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ ) -// This code is public domain. - -// Author Karl Malbrain, malbrain AT yahoo.com -// with assistance from Jan Weiss. -// modifications (and any bugs) by Mark Pictor, mpictor at gmail - -// Simplified judy arrays for strings and integers -// Adapted from the ideas of Douglas Baskins of HP. - -// Map a set of keys to corresponding memory cells (uints). -// Each cell must be set to a non-zero value by the caller. - -// STANDALONE is defined to compile into a string sorter. - -// String mappings are denoted by calling judy_open with zero as -// the second argument. Integer mappings are denoted by calling -// judy_open with the Integer depth of the Judy Trie as the second -// argument. - -#include -#include -#include -#include -#include "judy.h" - -#ifdef linux -# include -# include -# include -# include -# include -#else -# include -# include -#endif - -#include - -#define PRIuint "u" - - -//these are initialized in penny.c -extern unsigned int PennyRecs; -extern unsigned int PennyLine; -extern unsigned int PennyKey; -extern unsigned int PennyOff; -extern unsigned long long PennyMerge; - -typedef struct { - void * buff; // record pointer in input file map - void * next; // duplicate chain -} PennySort; - -#endif //SORT_H \ No newline at end of file diff --git a/src/cllazyfile/lazyDataSectionReader.cc b/src/cllazyfile/lazyDataSectionReader.cc index 4b1bc1785..cede12733 100644 --- a/src/cllazyfile/lazyDataSectionReader.cc +++ b/src/cllazyfile/lazyDataSectionReader.cc @@ -1,6 +1,6 @@ -#include "lazyDataSectionReader.h" -#include "lazyFileReader.h" -#include "lazyInstMgr.h" +#include "lazy/lazyDataSectionReader.h" +#include "lazy/lazyFileReader.h" +#include "lazy/lazyInstMgr.h" #include lazyDataSectionReader::lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index 9cc294df0..090e3337f 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -1,10 +1,10 @@ #include -#include "lazyFileReader.h" -#include "lazyDataSectionReader.h" -#include "headerSectionReader.h" -#include "lazyInstMgr.h" +#include "lazy/lazyFileReader.h" +#include "lazy/lazyDataSectionReader.h" +#include "lazy/headerSectionReader.h" +#include "lazy/lazyInstMgr.h" void lazyFileReader::initP21() { _header = new p21HeaderSectionReader( this, _file, 0, -1 ); diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index 6f4a3ffb0..f7aec713f 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -1,9 +1,9 @@ -#include "lazyTypes.h" -#include "lazyInstMgr.h" +#include "lazy/lazyTypes.h" +#include "lazy/lazyInstMgr.h" #include "core/Registry.h" #include "core/SubSuperIterators.h" #include "editor/SdaiSchemaInit.h" -#include "instMgrHelper.h" +#include "lazy/instMgrHelper.h" #include "lazyRefs.h" #include "core/sdaiApplication_instance.h" diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index baecb260e..0a726cde8 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -1,7 +1,7 @@ #include #include -#include "lazyP21DataSectionReader.h" -#include "lazyInstMgr.h" +#include "lazy/lazyP21DataSectionReader.h" +#include "lazy/lazyInstMgr.h" lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index 801cc642d..b13a4b4e2 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -7,8 +7,8 @@ #include #include "sc_export.h" -#include "lazyTypes.h" -#include "lazyInstMgr.h" +#include "lazy/lazyTypes.h" +#include "lazy/lazyInstMgr.h" #include "core/ExpDict.h" #include "core/SubSuperIterators.h" #include "core/STEPattribute.h" diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index b0216daa4..47af530da 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,4 +1,4 @@ -#include "lazyInstMgr.h" +#include "lazy/lazyInstMgr.h" #include "./sc_benchmark.h" #include "editor/SdaiSchemaInit.h" #include "config.h" diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index a01e47c3d..126d2295f 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -1,11 +1,11 @@ #include #include -#include "p21HeaderSectionReader.h" -#include "headerSectionReader.h" -#include "sectionReader.h" -#include "lazyInstMgr.h" -#include "judyL2Array.h" +#include "lazy/p21HeaderSectionReader.h" +#include "lazy/headerSectionReader.h" +#include "lazy/sectionReader.h" +#include "lazy/lazyInstMgr.h" +#include "lazy/judyL2Array.h" void p21HeaderSectionReader::findSectionStart() { diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 9a49d05b7..1d1a81253 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -18,10 +18,10 @@ #include "editor/SdaiSchemaInit.h" #include "core/STEPcomplex.h" -#include "sectionReader.h" -#include "lazyFileReader.h" -#include "lazyInstMgr.h" -#include "lazyTypes.h" +#include "lazy/sectionReader.h" +#include "lazy/lazyFileReader.h" +#include "lazy/lazyInstMgr.h" +#include "lazy/lazyTypes.h" #include "current_function.hpp" diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index cea95a2fb..61f5b6577 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -5,7 +5,7 @@ * This test originally used STEPfile, which didn't work. Fixing STEPfile would have been very difficult, it uses lazyInstMgr now. */ #include "config.h" -#include +#include "lazy/lazyInstMgr.h" #include #include "core/sdai.h" #include "core/STEPattribute.h" From bc96f29d6bc8a41a6e2d52ebeaab7eaabd03d0ae Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 11:52:27 -0400 Subject: [PATCH 237/244] Move utils headers --- include/core/ExpDict.h | 2 +- include/core/Registry.h | 6 +++--- include/core/STEPaggregate.h | 2 +- include/core/STEPattribute.h | 2 +- include/core/STEPcomplex.h | 2 +- include/core/STEPundefined.h | 2 +- include/core/complexSupport.h | 2 +- include/core/dispnode.h | 4 ++-- include/core/dispnodelist.h | 4 ++-- include/core/instmgr.h | 6 +++--- include/core/mgrnode.h | 4 ++-- include/core/mgrnodearray.h | 6 +++--- include/core/mgrnodelist.h | 4 ++-- include/core/schRename.h | 2 +- include/core/sdai.h | 4 ++-- include/editor/STEPfile.h | 4 ++-- include/editor/cmdmgr.h | 6 +++--- include/lazy/sectionReader.h | 2 +- include/utils/CMakeLists.txt | 8 +++++++- {src/clutils => include/utils}/Str.h | 2 +- {src/clutils => include/utils}/dirobj.h | 0 {src/clutils => include/utils}/errordesc.h | 0 {src/clutils => include/utils}/gennode.h | 0 {src/clutils => include/utils}/gennodearray.h | 2 +- {src/clutils => include/utils}/gennodelist.h | 0 {src/clutils => include/utils}/sc_hash.h | 0 misc/header_mv.sh | 12 ++++++------ src/clstepcore/dispnode.cc | 4 ++-- src/clstepcore/dispnodelist.cc | 4 ++-- src/clstepcore/read_func.cc | 4 ++-- src/clutils/CMakeLists.txt | 14 -------------- src/clutils/Str.cc | 2 +- src/clutils/dirobj.cc | 2 +- src/clutils/errordesc.cc | 4 ++-- src/clutils/gennode.cc | 4 ++-- src/clutils/gennodearray.cc | 6 +++--- src/clutils/gennodelist.cc | 6 +++--- src/clutils/sc_hash.cc | 2 +- src/test/p21read/p21read.cc | 2 +- .../cpp/schema_specific/aggregate_bound_runtime.cc | 2 +- test/cpp/schema_specific/attribute.cc | 2 +- test/cpp/schema_specific/inverse_attr1.cc | 2 +- test/cpp/schema_specific/inverse_attr2.cc | 2 +- test/cpp/schema_specific/inverse_attr3.cc | 2 +- test/cpp/schema_specific/stepfile_rw_progress.cc | 2 +- 45 files changed, 73 insertions(+), 81 deletions(-) rename {src/clutils => include/utils}/Str.h (98%) rename {src/clutils => include/utils}/dirobj.h (100%) rename {src/clutils => include/utils}/errordesc.h (100%) rename {src/clutils => include/utils}/gennode.h (100%) rename {src/clutils => include/utils}/gennodearray.h (98%) rename {src/clutils => include/utils}/gennodelist.h (100%) rename {src/clutils => include/utils}/sc_hash.h (100%) diff --git a/include/core/ExpDict.h b/include/core/ExpDict.h index 8aa82df55..4e7087cfb 100644 --- a/include/core/ExpDict.h +++ b/include/core/ExpDict.h @@ -25,7 +25,7 @@ #include "core/baseType.h" #include "core/dictdefs.h" -#include +#include "utils/Str.h" // each of these contains linked list, list node, iterator #include "core/attrDescriptorList.h" diff --git a/include/core/Registry.h b/include/core/Registry.h index eda955b39..2f97f9d7a 100644 --- a/include/core/Registry.h +++ b/include/core/Registry.h @@ -14,9 +14,9 @@ #include #include "core/sdai.h" -#include -#include -#include +#include "utils/errordesc.h" +#include "utils/sc_hash.h" +#include "utils/Str.h" #include "core/complexSupport.h" diff --git a/include/core/STEPaggregate.h b/include/core/STEPaggregate.h index efb3477a6..69a78b420 100644 --- a/include/core/STEPaggregate.h +++ b/include/core/STEPaggregate.h @@ -17,7 +17,7 @@ class STEPaggregate; class TypeDescriptor; #include -#include +#include "utils/errordesc.h" #include "core/SingleLinkList.h" #include "core/baseType.h" #include "core/sdai.h" diff --git a/include/core/STEPattribute.h b/include/core/STEPattribute.h index 754cec9d1..fd361c817 100644 --- a/include/core/STEPattribute.h +++ b/include/core/STEPattribute.h @@ -15,7 +15,7 @@ #include #include -#include +#include "utils/errordesc.h" #include "core/baseType.h" #include "core/sdai.h" diff --git a/include/core/STEPcomplex.h b/include/core/STEPcomplex.h index 6e64f3e20..2b8c24d8e 100644 --- a/include/core/STEPcomplex.h +++ b/include/core/STEPcomplex.h @@ -2,7 +2,7 @@ #define STEPCOMPLEX_H #include -#include +#include "utils/errordesc.h" #include "core/sdai.h" #include "core/baseType.h" #include "core/ExpDict.h" diff --git a/include/core/STEPundefined.h b/include/core/STEPundefined.h index da9883215..25e3f99b2 100644 --- a/include/core/STEPundefined.h +++ b/include/core/STEPundefined.h @@ -13,7 +13,7 @@ */ #include -#include +#include "utils/errordesc.h" #include #include "core/read_func.h" diff --git a/include/core/complexSupport.h b/include/core/complexSupport.h index f7d3db734..83dbf2006 100644 --- a/include/core/complexSupport.h +++ b/include/core/complexSupport.h @@ -18,7 +18,7 @@ #include #include using namespace std; -#include "Str.h" +#include "utils/Str.h" #define LISTEND 999 /** \def LISTEND diff --git a/include/core/dispnode.h b/include/core/dispnode.h index ad519f87f..b25ff46ca 100644 --- a/include/core/dispnode.h +++ b/include/core/dispnode.h @@ -21,8 +21,8 @@ /*#include */ #include "core/sdai.h" -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" //#include #include "editor/editordefines.h" //#include diff --git a/include/core/dispnodelist.h b/include/core/dispnodelist.h index af64fabc5..385dbbf5e 100644 --- a/include/core/dispnodelist.h +++ b/include/core/dispnodelist.h @@ -17,12 +17,12 @@ #include -#include +#include "utils/gennode.h" //#include #include "editor/editordefines.h" #include "core/mgrnode.h" #include "core/dispnode.h" -#include +#include "utils/gennodelist.h" /////////////////////////////////////////////////////////////////////////////// // class DisplayNodeList diff --git a/include/core/instmgr.h b/include/core/instmgr.h index 94f334982..b763b87b7 100644 --- a/include/core/instmgr.h +++ b/include/core/instmgr.h @@ -27,9 +27,9 @@ // IT IS VERY IMPORTANT THAT THE ORDER OF THE FOLLOWING INCLUDE FILES // BE PRESERVED -#include -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" +#include "utils/gennodearray.h" #include "core/mgrnode.h" #include "core/mgrnodelist.h" diff --git a/include/core/mgrnode.h b/include/core/mgrnode.h index ef871b071..3befa9393 100644 --- a/include/core/mgrnode.h +++ b/include/core/mgrnode.h @@ -20,8 +20,8 @@ class GenericNode; class DisplayNode; #include "core/sdai.h" -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" #include "editor/editordefines.h" diff --git a/include/core/mgrnodearray.h b/include/core/mgrnodearray.h index 05a11dff9..02d2191fa 100644 --- a/include/core/mgrnodearray.h +++ b/include/core/mgrnodearray.h @@ -19,14 +19,14 @@ #include -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" //#include #include "core/mgrnode.h" #include "core/mgrnodelist.h" -#include +#include "utils/gennodearray.h" #define ARRAY_DEFAULT_SIZE (1024) diff --git a/include/core/mgrnodelist.h b/include/core/mgrnodelist.h index 92edcfe39..471e40216 100644 --- a/include/core/mgrnodelist.h +++ b/include/core/mgrnodelist.h @@ -17,9 +17,9 @@ #include -#include +#include "utils/gennode.h" //#include -#include +#include "utils/gennodelist.h" #include "editor/editordefines.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/include/core/schRename.h b/include/core/schRename.h index b5ffdbaa1..042b7fda2 100644 --- a/include/core/schRename.h +++ b/include/core/schRename.h @@ -4,7 +4,7 @@ #include #include -#include "Str.h" +#include "utils/Str.h" #include "sc_export.h" diff --git a/include/core/sdai.h b/include/core/sdai.h index d47cbca3b..674571bde 100644 --- a/include/core/sdai.h +++ b/include/core/sdai.h @@ -30,8 +30,8 @@ extern const char * SCLversion; #include "core/dictdefs.h" #include "core/baseType.h" -#include "Str.h" -#include "errordesc.h" +#include "utils/Str.h" +#include "utils/errordesc.h" typedef std::string Express_id; diff --git a/include/editor/STEPfile.h b/include/editor/STEPfile.h index 316fe2b34..b85ea4d22 100644 --- a/include/editor/STEPfile.h +++ b/include/editor/STEPfile.h @@ -18,8 +18,8 @@ #include "core/instmgr.h" #include "core/Registry.h" #include -#include -#include +#include "utils/dirobj.h" +#include "utils/errordesc.h" #include #include "core/read_func.h" diff --git a/include/editor/cmdmgr.h b/include/editor/cmdmgr.h index 3b8607640..cac165b78 100644 --- a/include/editor/cmdmgr.h +++ b/include/editor/cmdmgr.h @@ -13,9 +13,9 @@ */ #include -#include -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" +#include "utils/gennodearray.h" #include "editor/editordefines.h" #include "core/mgrnode.h" diff --git a/include/lazy/sectionReader.h b/include/lazy/sectionReader.h index 7b62a910c..2afbf500e 100644 --- a/include/lazy/sectionReader.h +++ b/include/lazy/sectionReader.h @@ -5,7 +5,7 @@ #include #include "lazy/lazyTypes.h" #include "sc_export.h" -#include "errordesc.h" +#include "utils/errordesc.h" #include "core/STEPcomplex.h" class SDAI_Application_instance; diff --git a/include/utils/CMakeLists.txt b/include/utils/CMakeLists.txt index 9fb164919..127b971e2 100644 --- a/include/utils/CMakeLists.txt +++ b/include/utils/CMakeLists.txt @@ -1,5 +1,11 @@ set(UTILS_HDRS - + dirobj.h + errordesc.h + gennodearray.h + gennode.h + gennodelist.h + sc_hash.h + Str.h ) install(FILES ${UTILS_HDRS} diff --git a/src/clutils/Str.h b/include/utils/Str.h similarity index 98% rename from src/clutils/Str.h rename to include/utils/Str.h index f605bfdda..80ea6ab1d 100644 --- a/src/clutils/Str.h +++ b/include/utils/Str.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include "utils/errordesc.h" #ifndef STRING_DELIM #define STRING_DELIM '\'' diff --git a/src/clutils/dirobj.h b/include/utils/dirobj.h similarity index 100% rename from src/clutils/dirobj.h rename to include/utils/dirobj.h diff --git a/src/clutils/errordesc.h b/include/utils/errordesc.h similarity index 100% rename from src/clutils/errordesc.h rename to include/utils/errordesc.h diff --git a/src/clutils/gennode.h b/include/utils/gennode.h similarity index 100% rename from src/clutils/gennode.h rename to include/utils/gennode.h diff --git a/src/clutils/gennodearray.h b/include/utils/gennodearray.h similarity index 98% rename from src/clutils/gennodearray.h rename to include/utils/gennodearray.h index 4c0ee075a..f19dc21be 100644 --- a/src/clutils/gennodearray.h +++ b/include/utils/gennodearray.h @@ -26,7 +26,7 @@ #include #include // to get bcopy for CenterLine -#include +#include "utils/gennode.h" // the initial size of the array #define ARRAY_DEFAULT_SIZE (1024) diff --git a/src/clutils/gennodelist.h b/include/utils/gennodelist.h similarity index 100% rename from src/clutils/gennodelist.h rename to include/utils/gennodelist.h diff --git a/src/clutils/sc_hash.h b/include/utils/sc_hash.h similarity index 100% rename from src/clutils/sc_hash.h rename to include/utils/sc_hash.h diff --git a/misc/header_mv.sh b/misc/header_mv.sh index 8d5a67d39..0d2be0f0f 100755 --- a/misc/header_mv.sh +++ b/misc/header_mv.sh @@ -1,10 +1,10 @@ #!/bin/bash -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; -find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \; +find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; -find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \; +find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"lazy\/$1\"/g" {} \; -find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"lazy\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \; +find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \; diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 6950a0e6e..8b01541ad 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -12,8 +12,8 @@ /* $Id: dispnode.cc,v 3.0.1.2 1997/11/05 22:11:39 sauderd DP3.1 $ */ -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" //#include #include "core/dispnode.h" diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index b58d12db2..f00ca79df 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -12,8 +12,8 @@ /* $Id: dispnodelist.cc,v 3.0.1.2 1997/11/05 22:11:40 sauderd DP3.1 $ */ -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" #include "core/mgrnode.h" #include "core/mgrnodelist.h" diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index 65a635dbe..85fb28a29 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -1,10 +1,10 @@ -#include +#include "utils/errordesc.h" #include #include "core/sdai.h" #include "core/read_func.h" #include "core/STEPattribute.h" -#include "Str.h" +#include "utils/Str.h" const int RealNumPrecision = REAL_NUM_PRECISION; diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 69f2f935d..2032efc02 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -1,4 +1,3 @@ - set(LIBSTEPUTILS_SRCS Str.cc dirobj.cc @@ -9,16 +8,6 @@ set(LIBSTEPUTILS_SRCS errordesc.cc ) -set(SC_CLUTILS_HDRS - dirobj.h - errordesc.h - gennodearray.h - gennode.h - gennodelist.h - sc_hash.h - Str.h - ) - include_directories( ${SC_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} @@ -40,9 +29,6 @@ if(BUILD_STATIC_LIBS) endif() endif() -install(FILES ${SC_CLUTILS_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/clutils) - # Local Variables: # tab-width: 8 # mode: cmake diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index 4ae8ef69c..ec8f5b3da 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -9,7 +9,7 @@ * and is not subject to copyright. */ -#include "Str.h" +#include "utils/Str.h" #include #include diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 37110948f..97dc4fda6 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -40,7 +40,7 @@ */ #include "config.h" -#include +#include "utils/dirobj.h" #ifdef HAVE_DIRENT_H # include #endif diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index 46d6c820d..4cfb1f2c1 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -10,8 +10,8 @@ * and is not subject to copyright. */ -#include -#include +#include "utils/errordesc.h" +#include "utils/Str.h" DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; ostream * ErrorDescriptor::_out = 0; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index 44a2b0aa6..e1f7d83b9 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -12,8 +12,8 @@ /* $Id: gennode.cc,v 3.0.1.4 1997/11/05 22:33:47 sauderd DP3.1 $ */ -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" ////////////////////////////////////////////////////////////////////////////// // class GenericNode inline functions that depend on other classes diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index 801742293..1645589d5 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -13,9 +13,9 @@ #include "config.h" -#include -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" +#include "utils/gennodearray.h" #ifndef HAVE_MEMMOVE extern "C" { diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index f333d6585..7650781cf 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -12,10 +12,10 @@ /* $Id: gennodelist.cc,v 3.0.1.2 1997/11/05 22:33:49 sauderd DP3.1 $ */ -#include -#include +#include "utils/gennode.h" +#include "utils/gennodelist.h" //#include -#include +#include "utils/gennodearray.h" // inserts after existNode void GenNodeList::InsertAfter( GenericNode * newNode, diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index 5b754c769..db6eda0ec 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -5,7 +5,7 @@ * also, hcreate/hdestroy routines added to simulate hsearch(3). */ -#include +#include "utils/sc_hash.h" #include #include #include diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index d896faa48..cd7bd9748 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -18,7 +18,7 @@ extern void SchemaInit( class Registry & ); #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #include "sc_benchmark.h" diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index e8ebb598a..72b507634 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -4,7 +4,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index 8dff9d8fd..4c8674da2 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -8,7 +8,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 201aeff8e..0ec52d47d 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -10,7 +10,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index fea50f309..5948660e0 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -9,7 +9,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index 61f5b6577..a20a822c1 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -11,7 +11,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include #include diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index c2c3c1522..4ee676627 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -4,7 +4,7 @@ #include "core/STEPattribute.h" #include "core/ExpDict.h" #include "core/Registry.h" -#include +#include "utils/errordesc.h" #include #include From 1bd7ad942bd8b28b7101b56570b3baffb883e6d9 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 12:17:48 -0400 Subject: [PATCH 238/244] Remove includes of other lib src directories --- src/cldai/CMakeLists.txt | 9 +++------ src/cleditor/CMakeLists.txt | 10 +++------- src/cllazyfile/CMakeLists.txt | 11 +++-------- src/clstepcore/CMakeLists.txt | 10 +++------- src/clutils/CMakeLists.txt | 7 +++---- 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/cldai/CMakeLists.txt b/src/cldai/CMakeLists.txt index 1905704b5..e37ac06d2 100644 --- a/src/cldai/CMakeLists.txt +++ b/src/cldai/CMakeLists.txt @@ -1,5 +1,4 @@ - -set(LIBSTEPDAI_SRCS +set(DAI_SRCS sdaiApplication_instance_set.cc sdaiBinary.cc sdaiDaObject.cc @@ -16,21 +15,19 @@ set(LIBSTEPDAI_SRCS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode - ${SC_SOURCE_DIR}/src/clstepcore - ${SC_SOURCE_DIR}/src/clutils ) set(_libdeps steputils) if(BUILD_SHARED_LIBS) - SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps}) + SC_ADDLIB(stepdai SHARED SOURCES ${DAI_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS) endif() endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $-static) + SC_ADDLIB(stepdai-static STATIC SOURCES ${DAI_SRCS} LINK_LIBRARIES $-static) endif() # Local Variables: diff --git a/src/cleditor/CMakeLists.txt b/src/cleditor/CMakeLists.txt index 3e21261ae..2b306068e 100644 --- a/src/cleditor/CMakeLists.txt +++ b/src/cleditor/CMakeLists.txt @@ -1,5 +1,4 @@ - -set(LIBSTEPEDITOR_SRCS +set(EDITOR_SRCS STEPfile.cc STEPfile.inline.cc cmdmgr.cc @@ -12,20 +11,17 @@ set(LIBSTEPEDITOR_SRCS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode - ${SC_SOURCE_DIR}/src/cldai - ${SC_SOURCE_DIR}/src/clstepcore - ${SC_SOURCE_DIR}/src/clutils ) if(BUILD_SHARED_LIBS) - SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils) + SC_ADDLIB(stepeditor SHARED SOURCES ${EDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils) if(WIN32) target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS) endif() endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static) + SC_ADDLIB(stepeditor-static STATIC SOURCES ${EDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static) endif() # Local Variables: diff --git a/src/cllazyfile/CMakeLists.txt b/src/cllazyfile/CMakeLists.txt index ea6d37a77..c56e8dbbc 100644 --- a/src/cllazyfile/CMakeLists.txt +++ b/src/cllazyfile/CMakeLists.txt @@ -1,5 +1,4 @@ - -set( clLazyFile_SRCS +set(LAZY_SRCS lazyDataSectionReader.cc lazyFileReader.cc lazyInstMgr.cc @@ -12,16 +11,12 @@ set( clLazyFile_SRCS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode - ${SC_SOURCE_DIR}/src/cleditor - ${SC_SOURCE_DIR}/src/cldai - ${SC_SOURCE_DIR}/src/clstepcore - ${SC_SOURCE_DIR}/src/clutils ) set(_libdeps stepcore stepdai steputils stepeditor) if(BUILD_SHARED_LIBS) - SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) + SC_ADDLIB(steplazyfile SHARED SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS) endif() @@ -29,7 +24,7 @@ endif() if(BUILD_STATIC_LIBS) set(_libdeps stepcore-static stepdai-static steputils-static stepeditor-static) - SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps}) + SC_ADDLIB(steplazyfile-static STATIC SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps}) endif() SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL) diff --git a/src/clstepcore/CMakeLists.txt b/src/clstepcore/CMakeLists.txt index d7f6cd539..e31f8ad8e 100644 --- a/src/clstepcore/CMakeLists.txt +++ b/src/clstepcore/CMakeLists.txt @@ -1,5 +1,4 @@ - -set(LIBSTEPCORE_SRCS +set(CORE_SRCS aggrTypeDescriptor.cc attrDescriptor.cc attrDescriptorList.cc @@ -65,22 +64,19 @@ set(LIBSTEPCORE_SRCS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/stepcode - ${SC_SOURCE_DIR}/src/cldai - ${SC_SOURCE_DIR}/src/cleditor - ${SC_SOURCE_DIR}/src/clutils ) set(_libdeps steputils stepdai) if(BUILD_SHARED_LIBS) - SC_ADDLIB(stepcore SHARED SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES ${_libdeps}) + SC_ADDLIB(stepcore SHARED SOURCES ${CORE_SRCS} LINK_LIBRARIES ${_libdeps}) if(WIN32) target_compile_definitions(stepcore PRIVATE SC_CORE_DLL_EXPORTS) endif() endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(stepcore-static STATIC SOURCES ${LIBSTEPCORE_SRCS} LINK_LIBRARIES $-static) + SC_ADDLIB(stepcore-static STATIC SOURCES ${CORE_SRCS} LINK_LIBRARIES $-static) endif() if(SC_ENABLE_TESTING) diff --git a/src/clutils/CMakeLists.txt b/src/clutils/CMakeLists.txt index 2032efc02..27cb08745 100644 --- a/src/clutils/CMakeLists.txt +++ b/src/clutils/CMakeLists.txt @@ -1,4 +1,4 @@ -set(LIBSTEPUTILS_SRCS +set(UTILS_SRCS Str.cc dirobj.cc gennode.cc @@ -11,11 +11,10 @@ set(LIBSTEPUTILS_SRCS include_directories( ${SC_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/include/stepcode ) if(BUILD_SHARED_LIBS) - SC_ADDLIB(steputils SHARED SOURCES ${LIBSTEPUTILS_SRCS}) + SC_ADDLIB(steputils SHARED SOURCES ${UTILS_SRCS}) if(WIN32) target_compile_definitions(steputils PRIVATE SC_UTILS_DLL_EXPORTS) target_link_libraries(steputils shlwapi) @@ -23,7 +22,7 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - SC_ADDLIB(steputils-static STATIC SOURCES ${LIBSTEPUTILS_SRCS}) + SC_ADDLIB(steputils-static STATIC SOURCES ${UTILS_SRCS}) if(WIN32) target_link_libraries(steputils-static shlwapi) endif() From d824fc0c4ee5f3921f7137f2e65847a017727878 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sun, 2 Oct 2022 16:48:51 -0400 Subject: [PATCH 239/244] Keep longer directory names We want to be consistent with the previous layout, to avoid needlessly breaking existing codes. The header update means client codes are not required to include all of the stepcode library includes explicitly - i.e., stepcode itself does not force this requirement with its own internal includes. However, if client codes do not want to add the library prefixes to their own includes as we have for stepcode, they should still be able to add the various includes and work as before. Adjust the include directory names accordingly. --- include/CMakeLists.txt | 10 ++--- include/{dai => cldai}/CMakeLists.txt | 2 +- .../sdaiApplication_instance_set.h | 0 include/{dai => cldai}/sdaiBinary.h | 0 include/{dai => cldai}/sdaiDaObject.h | 6 +-- include/{dai => cldai}/sdaiEntity_extent.h | 0 .../{dai => cldai}/sdaiEntity_extent_set.h | 0 include/{dai => cldai}/sdaiEnum.h | 0 include/{dai => cldai}/sdaiModel_contents.h | 0 .../{dai => cldai}/sdaiModel_contents_list.h | 0 include/{dai => cldai}/sdaiObject.h | 0 include/{dai => cldai}/sdaiSession_instance.h | 2 +- include/{dai => cldai}/sdaiString.h | 0 include/{editor => cleditor}/CMakeLists.txt | 2 +- include/{editor => cleditor}/STEPfile.h | 10 ++--- .../{editor => cleditor}/SdaiHeaderSchema.h | 10 ++--- .../SdaiHeaderSchemaClasses.h | 0 include/{editor => cleditor}/SdaiSchemaInit.h | 18 ++++----- include/{editor => cleditor}/cmdmgr.h | 20 +++++----- include/{editor => cleditor}/editordefines.h | 0 include/{editor => cleditor}/seeinfodefault.h | 4 +- include/{lazy => cllazyfile}/CMakeLists.txt | 2 +- .../headerSectionReader.h | 6 +-- include/{lazy => cllazyfile}/instMgrHelper.h | 6 +-- include/{lazy => cllazyfile}/judy.h | 0 include/{lazy => cllazyfile}/judyL2Array.h | 0 include/{lazy => cllazyfile}/judyLArray.h | 0 include/{lazy => cllazyfile}/judyS2Array.h | 0 include/{lazy => cllazyfile}/judySArray.h | 0 .../lazyDataSectionReader.h | 4 +- include/{lazy => cllazyfile}/lazyFileReader.h | 6 +-- include/{lazy => cllazyfile}/lazyInstMgr.h | 8 ++-- .../lazyP21DataSectionReader.h | 4 +- include/{lazy => cllazyfile}/lazyTypes.h | 0 .../p21HeaderSectionReader.h | 2 +- include/{lazy => cllazyfile}/sectionReader.h | 6 +-- include/{core => clstepcore}/CMakeLists.txt | 2 +- include/{core => clstepcore}/ExpDict.h | 24 ++++++------ include/{core => clstepcore}/Registry.h | 10 ++--- include/{core => clstepcore}/STEPaggrBinary.h | 2 +- include/{core => clstepcore}/STEPaggrEntity.h | 2 +- include/{core => clstepcore}/STEPaggrEnum.h | 2 +- .../{core => clstepcore}/STEPaggrGeneric.h | 2 +- include/{core => clstepcore}/STEPaggrInt.h | 2 +- include/{core => clstepcore}/STEPaggrReal.h | 2 +- include/{core => clstepcore}/STEPaggrSelect.h | 2 +- include/{core => clstepcore}/STEPaggrString.h | 2 +- include/{core => clstepcore}/STEPaggregate.h | 26 ++++++------- include/{core => clstepcore}/STEPattribute.h | 6 +-- .../{core => clstepcore}/STEPattributeList.h | 2 +- include/{core => clstepcore}/STEPcomplex.h | 10 ++--- .../{core => clstepcore}/STEPinvAttrList.h | 2 +- include/{core => clstepcore}/STEPundefined.h | 4 +- include/{core => clstepcore}/SingleLinkList.h | 0 .../{core => clstepcore}/SubSuperIterators.h | 4 +- .../{core => clstepcore}/aggrTypeDescriptor.h | 2 +- include/{core => clstepcore}/attrDescriptor.h | 2 +- .../{core => clstepcore}/attrDescriptorList.h | 0 include/{core => clstepcore}/baseType.h | 0 include/{core => clstepcore}/complexSupport.h | 2 +- include/{core => clstepcore}/create_Aggr.h | 2 +- .../{core => clstepcore}/derivedAttribute.h | 2 +- include/{core => clstepcore}/dictSchema.h | 0 include/{core => clstepcore}/dictdefs.h | 0 .../{core => clstepcore}/dictionaryInstance.h | 0 include/{core => clstepcore}/dispnode.h | 10 ++--- include/{core => clstepcore}/dispnodelist.h | 10 ++--- .../{core => clstepcore}/entityDescriptor.h | 4 +- .../entityDescriptorList.h | 0 .../{core => clstepcore}/enumTypeDescriptor.h | 0 include/{core => clstepcore}/explicitItemId.h | 0 include/{core => clstepcore}/globalRule.h | 2 +- include/{core => clstepcore}/implicitItemId.h | 0 include/{core => clstepcore}/instmgr.h | 16 ++++---- include/{core => clstepcore}/interfaceSpec.h | 4 +- include/{core => clstepcore}/interfacedItem.h | 4 +- .../{core => clstepcore}/inverseAttribute.h | 2 +- .../inverseAttributeList.h | 0 include/{core => clstepcore}/mgrnode.h | 8 ++-- include/{core => clstepcore}/mgrnodearray.h | 10 ++--- include/{core => clstepcore}/mgrnodelist.h | 6 +-- include/{core => clstepcore}/needFunc.h | 0 include/{core => clstepcore}/read_func.h | 2 +- .../{core => clstepcore}/realTypeDescriptor.h | 0 include/{core => clstepcore}/schRename.h | 2 +- include/{core => clstepcore}/sdai.h | 38 +++++++++---------- .../sdaiApplication_instance.h | 2 +- include/{core => clstepcore}/sdaiSelect.h | 0 .../selectTypeDescriptor.h | 0 .../stringTypeDescriptor.h | 0 include/{core => clstepcore}/typeDescriptor.h | 2 +- .../{core => clstepcore}/typeDescriptorList.h | 0 include/{core => clstepcore}/typeOrRuleVar.h | 2 +- include/{core => clstepcore}/uniquenessRule.h | 4 +- include/{core => clstepcore}/whereRule.h | 4 +- include/{utils => clutils}/CMakeLists.txt | 2 +- include/{utils => clutils}/Str.h | 2 +- include/{utils => clutils}/dirobj.h | 0 include/{utils => clutils}/errordesc.h | 0 include/{utils => clutils}/gennode.h | 0 include/{utils => clutils}/gennodearray.h | 2 +- include/{utils => clutils}/gennodelist.h | 0 include/{utils => clutils}/sc_hash.h | 0 src/cldai/sdaiApplication_instance_set.cc | 6 +-- src/cldai/sdaiBinary.cc | 2 +- src/cldai/sdaiDaObject.cc | 2 +- src/cldai/sdaiEntity_extent.cc | 2 +- src/cldai/sdaiEntity_extent_set.cc | 2 +- src/cldai/sdaiEnum.cc | 2 +- src/cldai/sdaiModel_contents.cc | 2 +- src/cldai/sdaiModel_contents_list.cc | 2 +- src/cldai/sdaiObject.cc | 2 +- src/cldai/sdaiSession_instance.cc | 2 +- src/cldai/sdaiString.cc | 2 +- src/cleditor/STEPfile.cc | 12 +++--- src/cleditor/STEPfile.inline.cc | 6 +-- src/cleditor/SdaiHeaderSchema.cc | 6 +-- src/cleditor/SdaiHeaderSchemaAll.cc | 2 +- src/cleditor/SdaiHeaderSchemaInit.cc | 8 ++-- src/cleditor/SdaiSchemaInit.cc | 2 +- src/cleditor/cmdmgr.cc | 2 +- src/cllazyfile/judy.c | 2 +- src/cllazyfile/lazyDataSectionReader.cc | 6 +-- src/cllazyfile/lazyFileReader.cc | 8 ++-- src/cllazyfile/lazyInstMgr.cc | 14 +++---- src/cllazyfile/lazyP21DataSectionReader.cc | 4 +- src/cllazyfile/lazyRefs.h | 12 +++--- src/cllazyfile/lazy_test.cc | 4 +- src/cllazyfile/p21HeaderSectionReader.cc | 10 ++--- src/cllazyfile/sectionReader.cc | 18 ++++----- src/clstepcore/Registry.cc | 4 +- src/clstepcore/STEPaggrBinary.cc | 2 +- src/clstepcore/STEPaggrEntity.cc | 6 +-- src/clstepcore/STEPaggrEnum.cc | 2 +- src/clstepcore/STEPaggrGeneric.cc | 2 +- src/clstepcore/STEPaggrInt.cc | 2 +- src/clstepcore/STEPaggrReal.cc | 2 +- src/clstepcore/STEPaggrSelect.cc | 4 +- src/clstepcore/STEPaggrString.cc | 2 +- src/clstepcore/STEPaggregate.cc | 10 ++--- src/clstepcore/STEPattribute.cc | 14 +++---- src/clstepcore/STEPattributeList.cc | 4 +- src/clstepcore/STEPcomplex.cc | 8 ++-- src/clstepcore/STEPinvAttrList.cc | 4 +- src/clstepcore/STEPundefined.cc | 4 +- src/clstepcore/SingleLinkList.cc | 2 +- src/clstepcore/aggrTypeDescriptor.cc | 2 +- src/clstepcore/attrDescriptor.cc | 2 +- src/clstepcore/attrDescriptorList.cc | 4 +- src/clstepcore/collect.cc | 2 +- src/clstepcore/complexlist.cc | 2 +- src/clstepcore/create_Aggr.cc | 4 +- src/clstepcore/derivedAttribute.cc | 2 +- src/clstepcore/dictSchema.cc | 6 +-- src/clstepcore/dispnode.cc | 8 ++-- src/clstepcore/dispnodelist.cc | 12 +++--- src/clstepcore/entityDescriptor.cc | 10 ++--- src/clstepcore/entityDescriptorList.cc | 2 +- src/clstepcore/entlist.cc | 2 +- src/clstepcore/entnode.cc | 2 +- src/clstepcore/enumTypeDescriptor.cc | 2 +- src/clstepcore/explicitItemId.cc | 2 +- src/clstepcore/globalRule.cc | 2 +- src/clstepcore/implicitItemId.cc | 2 +- src/clstepcore/instmgr.cc | 4 +- src/clstepcore/interfaceSpec.cc | 2 +- src/clstepcore/interfacedItem.cc | 2 +- src/clstepcore/inverseAttribute.cc | 2 +- src/clstepcore/inverseAttributeList.cc | 4 +- src/clstepcore/match-ors.cc | 2 +- src/clstepcore/mgrnode.cc | 12 +++--- src/clstepcore/mgrnodearray.cc | 4 +- src/clstepcore/mgrnodelist.cc | 8 ++-- src/clstepcore/multlist.cc | 2 +- src/clstepcore/needFunc.cc | 2 +- src/clstepcore/non-ors.cc | 2 +- src/clstepcore/orlist.cc | 2 +- src/clstepcore/print.cc | 2 +- src/clstepcore/read_func.cc | 10 ++--- src/clstepcore/schRename.cc | 2 +- src/clstepcore/sdai.cc | 2 +- src/clstepcore/sdaiApplication_instance.cc | 12 +++--- src/clstepcore/sdaiSelect.cc | 6 +-- src/clstepcore/selectTypeDescriptor.cc | 2 +- src/clstepcore/superInvAttrIter.h | 4 +- .../test/test_SupertypesIterator.cc | 4 +- src/clstepcore/test/test_null_attr.cc | 6 +-- .../test/test_operators_SDAI_Select.cc | 6 +-- .../test/test_operators_STEPattribute.cc | 4 +- src/clstepcore/trynext.cc | 2 +- src/clstepcore/typeDescriptor.cc | 2 +- src/clstepcore/typeDescriptorList.cc | 2 +- src/clstepcore/typeOrRuleVar.cc | 2 +- src/clstepcore/uniquenessRule.cc | 2 +- src/clstepcore/whereRule.cc | 2 +- src/clutils/Str.cc | 2 +- src/clutils/dirobj.cc | 2 +- src/clutils/errordesc.cc | 4 +- src/clutils/gennode.cc | 4 +- src/clutils/gennodearray.cc | 6 +-- src/clutils/gennodelist.cc | 6 +-- src/clutils/sc_hash.cc | 2 +- src/exp2cxx/classes_wrapper.cc | 14 +++---- src/exp2cxx/multpass.c | 2 +- src/exp2cxx/write.cc | 4 +- src/test/p21read/p21read.cc | 12 +++--- src/test/scl2html/scl2html.cc | 2 +- src/test/tests.h | 8 ++-- .../aggregate_bound_runtime.cc | 12 +++--- test/cpp/schema_specific/attribute.cc | 12 +++--- test/cpp/schema_specific/inverse_attr1.cc | 12 +++--- test/cpp/schema_specific/inverse_attr2.cc | 12 +++--- test/cpp/schema_specific/inverse_attr3.cc | 12 +++--- .../schema_specific/stepfile_rw_progress.cc | 12 +++--- 214 files changed, 462 insertions(+), 462 deletions(-) rename include/{dai => cldai}/CMakeLists.txt (89%) rename include/{dai => cldai}/sdaiApplication_instance_set.h (100%) rename include/{dai => cldai}/sdaiBinary.h (100%) rename include/{dai => cldai}/sdaiDaObject.h (99%) rename include/{dai => cldai}/sdaiEntity_extent.h (100%) rename include/{dai => cldai}/sdaiEntity_extent_set.h (100%) rename include/{dai => cldai}/sdaiEnum.h (100%) rename include/{dai => cldai}/sdaiModel_contents.h (100%) rename include/{dai => cldai}/sdaiModel_contents_list.h (100%) rename include/{dai => cldai}/sdaiObject.h (100%) rename include/{dai => cldai}/sdaiSession_instance.h (94%) rename include/{dai => cldai}/sdaiString.h (100%) rename include/{editor => cleditor}/CMakeLists.txt (85%) rename include/{editor => cleditor}/STEPfile.h (98%) rename include/{editor => cleditor}/SdaiHeaderSchema.h (97%) rename include/{editor => cleditor}/SdaiHeaderSchemaClasses.h (100%) rename include/{editor => cleditor}/SdaiSchemaInit.h (60%) rename include/{editor => cleditor}/cmdmgr.h (94%) rename include/{editor => cleditor}/editordefines.h (100%) rename include/{editor => cleditor}/seeinfodefault.h (94%) rename include/{lazy => cllazyfile}/CMakeLists.txt (89%) rename include/{lazy => cllazyfile}/headerSectionReader.h (90%) rename include/{lazy => cllazyfile}/instMgrHelper.h (94%) rename include/{lazy => cllazyfile}/judy.h (100%) rename include/{lazy => cllazyfile}/judyL2Array.h (100%) rename include/{lazy => cllazyfile}/judyLArray.h (100%) rename include/{lazy => cllazyfile}/judyS2Array.h (100%) rename include/{lazy => cllazyfile}/judySArray.h (100%) rename include/{lazy => cllazyfile}/lazyDataSectionReader.h (92%) rename include/{lazy => cllazyfile}/lazyFileReader.h (90%) rename include/{lazy => cllazyfile}/lazyInstMgr.h (98%) rename include/{lazy => cllazyfile}/lazyP21DataSectionReader.h (89%) rename include/{lazy => cllazyfile}/lazyTypes.h (100%) rename include/{lazy => cllazyfile}/p21HeaderSectionReader.h (93%) rename include/{lazy => cllazyfile}/sectionReader.h (97%) rename include/{core => clstepcore}/CMakeLists.txt (96%) rename include/{core => clstepcore}/ExpDict.h (70%) rename include/{core => clstepcore}/Registry.h (95%) rename include/{core => clstepcore}/STEPaggrBinary.h (97%) rename include/{core => clstepcore}/STEPaggrEntity.h (98%) rename include/{core => clstepcore}/STEPaggrEnum.h (98%) rename include/{core => clstepcore}/STEPaggrGeneric.h (97%) rename include/{core => clstepcore}/STEPaggrInt.h (97%) rename include/{core => clstepcore}/STEPaggrReal.h (97%) rename include/{core => clstepcore}/STEPaggrSelect.h (98%) rename include/{core => clstepcore}/STEPaggrString.h (97%) rename include/{core => clstepcore}/STEPaggregate.h (89%) rename include/{core => clstepcore}/STEPattribute.h (99%) rename include/{core => clstepcore}/STEPattributeList.h (97%) rename include/{core => clstepcore}/STEPcomplex.h (95%) rename include/{core => clstepcore}/STEPinvAttrList.h (98%) rename include/{core => clstepcore}/STEPundefined.h (95%) rename include/{core => clstepcore}/SingleLinkList.h (100%) rename include/{core => clstepcore}/SubSuperIterators.h (99%) rename include/{core => clstepcore}/aggrTypeDescriptor.h (99%) rename include/{core => clstepcore}/attrDescriptor.h (99%) rename include/{core => clstepcore}/attrDescriptorList.h (100%) rename include/{core => clstepcore}/baseType.h (100%) rename include/{core => clstepcore}/complexSupport.h (99%) rename include/{core => clstepcore}/create_Aggr.h (97%) rename include/{core => clstepcore}/derivedAttribute.h (95%) rename include/{core => clstepcore}/dictSchema.h (100%) rename include/{core => clstepcore}/dictdefs.h (100%) rename include/{core => clstepcore}/dictionaryInstance.h (100%) rename include/{core => clstepcore}/dispnode.h (92%) rename include/{core => clstepcore}/dispnodelist.h (92%) rename include/{core => clstepcore}/entityDescriptor.h (98%) rename include/{core => clstepcore}/entityDescriptorList.h (100%) rename include/{core => clstepcore}/enumTypeDescriptor.h (100%) rename include/{core => clstepcore}/explicitItemId.h (100%) rename include/{core => clstepcore}/globalRule.h (97%) rename include/{core => clstepcore}/implicitItemId.h (100%) rename include/{core => clstepcore}/instmgr.h (93%) rename include/{core => clstepcore}/interfaceSpec.h (97%) rename include/{core => clstepcore}/interfacedItem.h (89%) rename include/{core => clstepcore}/inverseAttribute.h (98%) rename include/{core => clstepcore}/inverseAttributeList.h (100%) rename include/{core => clstepcore}/mgrnode.h (97%) rename include/{core => clstepcore}/mgrnodearray.h (95%) rename include/{core => clstepcore}/mgrnodelist.h (94%) rename include/{core => clstepcore}/needFunc.h (100%) rename include/{core => clstepcore}/read_func.h (99%) rename include/{core => clstepcore}/realTypeDescriptor.h (100%) rename include/{core => clstepcore}/schRename.h (98%) rename include/{core => clstepcore}/sdai.h (92%) rename include/{core => clstepcore}/sdaiApplication_instance.h (99%) rename include/{core => clstepcore}/sdaiSelect.h (100%) rename include/{core => clstepcore}/selectTypeDescriptor.h (100%) rename include/{core => clstepcore}/stringTypeDescriptor.h (100%) rename include/{core => clstepcore}/typeDescriptor.h (99%) rename include/{core => clstepcore}/typeDescriptorList.h (100%) rename include/{core => clstepcore}/typeOrRuleVar.h (89%) rename include/{core => clstepcore}/uniquenessRule.h (96%) rename include/{core => clstepcore}/whereRule.h (96%) rename include/{utils => clutils}/CMakeLists.txt (83%) rename include/{utils => clutils}/Str.h (98%) rename include/{utils => clutils}/dirobj.h (100%) rename include/{utils => clutils}/errordesc.h (100%) rename include/{utils => clutils}/gennode.h (100%) rename include/{utils => clutils}/gennodearray.h (98%) rename include/{utils => clutils}/gennodelist.h (100%) rename include/{utils => clutils}/sc_hash.h (100%) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index c6e9ec18f..5f39f0ba9 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -37,11 +37,11 @@ install(FILES ordered_attrs.h install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h DESTINATION ${INCLUDE_DIR}/stepcode) -add_subdirectory(core) -add_subdirectory(dai) -add_subdirectory(editor) -add_subdirectory(lazy) -add_subdirectory(utils) +add_subdirectory(cldai) +add_subdirectory(cleditor) +add_subdirectory(cllazyfile) +add_subdirectory(clstepcore) +add_subdirectory(clutils) # Local Variables: # tab-width: 8 diff --git a/include/dai/CMakeLists.txt b/include/cldai/CMakeLists.txt similarity index 89% rename from include/dai/CMakeLists.txt rename to include/cldai/CMakeLists.txt index 1a394d32f..471671fbd 100644 --- a/include/dai/CMakeLists.txt +++ b/include/cldai/CMakeLists.txt @@ -13,7 +13,7 @@ set(DAI_HDRS ) install(FILES ${DAI_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/dai) + DESTINATION ${INCLUDE_DIR}/stepcode/cldai) # Local Variables: # tab-width: 8 diff --git a/include/dai/sdaiApplication_instance_set.h b/include/cldai/sdaiApplication_instance_set.h similarity index 100% rename from include/dai/sdaiApplication_instance_set.h rename to include/cldai/sdaiApplication_instance_set.h diff --git a/include/dai/sdaiBinary.h b/include/cldai/sdaiBinary.h similarity index 100% rename from include/dai/sdaiBinary.h rename to include/cldai/sdaiBinary.h diff --git a/include/dai/sdaiDaObject.h b/include/cldai/sdaiDaObject.h similarity index 99% rename from include/dai/sdaiDaObject.h rename to include/cldai/sdaiDaObject.h index e615e4244..3bb0c20f4 100644 --- a/include/dai/sdaiDaObject.h +++ b/include/cldai/sdaiDaObject.h @@ -1,9 +1,9 @@ #ifndef SDAIDAOBJECT_H #define SDAIDAOBJECT_H 1 -#include "dai/sdaiObject.h" -#include "dai/sdaiString.h" -#include "dai/sdaiEnum.h" +#include "cldai/sdaiObject.h" +#include "cldai/sdaiString.h" +#include "cldai/sdaiEnum.h" #include diff --git a/include/dai/sdaiEntity_extent.h b/include/cldai/sdaiEntity_extent.h similarity index 100% rename from include/dai/sdaiEntity_extent.h rename to include/cldai/sdaiEntity_extent.h diff --git a/include/dai/sdaiEntity_extent_set.h b/include/cldai/sdaiEntity_extent_set.h similarity index 100% rename from include/dai/sdaiEntity_extent_set.h rename to include/cldai/sdaiEntity_extent_set.h diff --git a/include/dai/sdaiEnum.h b/include/cldai/sdaiEnum.h similarity index 100% rename from include/dai/sdaiEnum.h rename to include/cldai/sdaiEnum.h diff --git a/include/dai/sdaiModel_contents.h b/include/cldai/sdaiModel_contents.h similarity index 100% rename from include/dai/sdaiModel_contents.h rename to include/cldai/sdaiModel_contents.h diff --git a/include/dai/sdaiModel_contents_list.h b/include/cldai/sdaiModel_contents_list.h similarity index 100% rename from include/dai/sdaiModel_contents_list.h rename to include/cldai/sdaiModel_contents_list.h diff --git a/include/dai/sdaiObject.h b/include/cldai/sdaiObject.h similarity index 100% rename from include/dai/sdaiObject.h rename to include/cldai/sdaiObject.h diff --git a/include/dai/sdaiSession_instance.h b/include/cldai/sdaiSession_instance.h similarity index 94% rename from include/dai/sdaiSession_instance.h rename to include/cldai/sdaiSession_instance.h index 4423037cf..7aa9a1502 100644 --- a/include/dai/sdaiSession_instance.h +++ b/include/cldai/sdaiSession_instance.h @@ -3,7 +3,7 @@ #define SESSION_INSTANCE_H 1 #include -//#include "core/sdai.h" +//#include "clstepcore/sdai.h" class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject { diff --git a/include/dai/sdaiString.h b/include/cldai/sdaiString.h similarity index 100% rename from include/dai/sdaiString.h rename to include/cldai/sdaiString.h diff --git a/include/editor/CMakeLists.txt b/include/cleditor/CMakeLists.txt similarity index 85% rename from include/editor/CMakeLists.txt rename to include/cleditor/CMakeLists.txt index bd3421699..1d128c8fa 100644 --- a/include/editor/CMakeLists.txt +++ b/include/cleditor/CMakeLists.txt @@ -9,7 +9,7 @@ set(EDITOR_HDRS ) install(FILES ${EDITOR_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/editor) + DESTINATION ${INCLUDE_DIR}/stepcode/cleditor) # Local Variables: # tab-width: 8 diff --git a/include/editor/STEPfile.h b/include/cleditor/STEPfile.h similarity index 98% rename from include/editor/STEPfile.h rename to include/cleditor/STEPfile.h index b85ea4d22..1ecfb67c2 100644 --- a/include/editor/STEPfile.h +++ b/include/cleditor/STEPfile.h @@ -15,14 +15,14 @@ #include #include -#include "core/instmgr.h" -#include "core/Registry.h" +#include "clstepcore/instmgr.h" +#include "clstepcore/Registry.h" #include -#include "utils/dirobj.h" -#include "utils/errordesc.h" +#include "clutils/dirobj.h" +#include "clutils/errordesc.h" #include -#include "core/read_func.h" +#include "clstepcore/read_func.h" //error reporting level #define READ_COMPLETE 10 diff --git a/include/editor/SdaiHeaderSchema.h b/include/cleditor/SdaiHeaderSchema.h similarity index 97% rename from include/editor/SdaiHeaderSchema.h rename to include/cleditor/SdaiHeaderSchema.h index 592e32a8e..5979202f0 100644 --- a/include/editor/SdaiHeaderSchema.h +++ b/include/cleditor/SdaiHeaderSchema.h @@ -5,11 +5,11 @@ // regenerate it. #include -#include "core/sdai.h" -#include "core/Registry.h" -#include "core/STEPaggregate.h" -#include "editor/SdaiHeaderSchemaClasses.h" -#include "editor/SdaiSchemaInit.h" +#include "clstepcore/sdai.h" +#include "clstepcore/Registry.h" +#include "clstepcore/STEPaggregate.h" +#include "cleditor/SdaiHeaderSchemaClasses.h" +#include "cleditor/SdaiSchemaInit.h" ///////// ENTITY section_language diff --git a/include/editor/SdaiHeaderSchemaClasses.h b/include/cleditor/SdaiHeaderSchemaClasses.h similarity index 100% rename from include/editor/SdaiHeaderSchemaClasses.h rename to include/cleditor/SdaiHeaderSchemaClasses.h diff --git a/include/editor/SdaiSchemaInit.h b/include/cleditor/SdaiSchemaInit.h similarity index 60% rename from include/editor/SdaiSchemaInit.h rename to include/cleditor/SdaiSchemaInit.h index de267adb9..862f297bd 100644 --- a/include/editor/SdaiSchemaInit.h +++ b/include/cleditor/SdaiSchemaInit.h @@ -9,16 +9,16 @@ #endif #include -#include "core/sdai.h" -#include "core/Registry.h" -#include "core/STEPaggregate.h" -#include "core/STEPundefined.h" -#include "core/ExpDict.h" -#include "core/STEPattribute.h" -#include "core/complexSupport.h" +#include "clstepcore/sdai.h" +#include "clstepcore/Registry.h" +#include "clstepcore/STEPaggregate.h" +#include "clstepcore/STEPundefined.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/complexSupport.h" -#include "editor/SdaiHeaderSchemaClasses.h" -#include "editor/SdaiHeaderSchema.h" +#include "cleditor/SdaiHeaderSchemaClasses.h" +#include "cleditor/SdaiHeaderSchema.h" SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & ); SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & ); diff --git a/include/editor/cmdmgr.h b/include/cleditor/cmdmgr.h similarity index 94% rename from include/editor/cmdmgr.h rename to include/cleditor/cmdmgr.h index cac165b78..4f420467b 100644 --- a/include/editor/cmdmgr.h +++ b/include/cleditor/cmdmgr.h @@ -13,16 +13,16 @@ */ #include -#include "utils/gennode.h" -#include "utils/gennodelist.h" -#include "utils/gennodearray.h" - -#include "editor/editordefines.h" -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" -#include "core/dispnode.h" -#include "core/dispnodelist.h" -#include "core/SingleLinkList.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" +#include "clutils/gennodearray.h" + +#include "cleditor/editordefines.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" +#include "clstepcore/SingleLinkList.h" //#define NUM_CMDMGR_CMDS 9 // this is the number of columns that contain cmds (as opposed diff --git a/include/editor/editordefines.h b/include/cleditor/editordefines.h similarity index 100% rename from include/editor/editordefines.h rename to include/cleditor/editordefines.h diff --git a/include/editor/seeinfodefault.h b/include/cleditor/seeinfodefault.h similarity index 94% rename from include/editor/seeinfodefault.h rename to include/cleditor/seeinfodefault.h index bf2e765ad..202c5eb1a 100644 --- a/include/editor/seeinfodefault.h +++ b/include/cleditor/seeinfodefault.h @@ -20,10 +20,10 @@ class MgrNode; class DisplayNode; class DisplayNodelist; -#include "core/sdai.h" +#include "clstepcore/sdai.h" //class SDAI_Application_instance; -#include "editor/editordefines.h" +#include "cleditor/editordefines.h" class SC_EDITOR_EXPORT seeInfo : public DisplayNode { public: diff --git a/include/lazy/CMakeLists.txt b/include/cllazyfile/CMakeLists.txt similarity index 89% rename from include/lazy/CMakeLists.txt rename to include/cllazyfile/CMakeLists.txt index c7ed6ad9e..853aa98b9 100644 --- a/include/lazy/CMakeLists.txt +++ b/include/cllazyfile/CMakeLists.txt @@ -16,7 +16,7 @@ set(LAZY_HDRS ) install(FILES ${LAZY_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/lazy) + DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile) # Local Variables: # tab-width: 8 diff --git a/include/lazy/headerSectionReader.h b/include/cllazyfile/headerSectionReader.h similarity index 90% rename from include/lazy/headerSectionReader.h rename to include/cllazyfile/headerSectionReader.h index b4eb807f9..e3a9f5725 100644 --- a/include/lazy/headerSectionReader.h +++ b/include/cllazyfile/headerSectionReader.h @@ -5,9 +5,9 @@ #include #include "judyL2Array.h" -#include "lazy/lazyFileReader.h" -#include "lazy/sectionReader.h" -#include "lazy/lazyTypes.h" +#include "cllazyfile/lazyFileReader.h" +#include "cllazyfile/sectionReader.h" +#include "cllazyfile/lazyTypes.h" #include "sc_export.h" diff --git a/include/lazy/instMgrHelper.h b/include/cllazyfile/instMgrHelper.h similarity index 94% rename from include/lazy/instMgrHelper.h rename to include/cllazyfile/instMgrHelper.h index fc36863ea..1af698160 100644 --- a/include/lazy/instMgrHelper.h +++ b/include/cllazyfile/instMgrHelper.h @@ -3,9 +3,9 @@ #include -#include "core/mgrnode.h" -#include "lazy/lazyInstMgr.h" -#include "core/instmgr.h" +#include "clstepcore/mgrnode.h" +#include "cllazyfile/lazyInstMgr.h" +#include "clstepcore/instmgr.h" /** * \file instMgrHelper.h helper classes for the lazyInstMgr. Allows use of SDAI_Application_instance class diff --git a/include/lazy/judy.h b/include/cllazyfile/judy.h similarity index 100% rename from include/lazy/judy.h rename to include/cllazyfile/judy.h diff --git a/include/lazy/judyL2Array.h b/include/cllazyfile/judyL2Array.h similarity index 100% rename from include/lazy/judyL2Array.h rename to include/cllazyfile/judyL2Array.h diff --git a/include/lazy/judyLArray.h b/include/cllazyfile/judyLArray.h similarity index 100% rename from include/lazy/judyLArray.h rename to include/cllazyfile/judyLArray.h diff --git a/include/lazy/judyS2Array.h b/include/cllazyfile/judyS2Array.h similarity index 100% rename from include/lazy/judyS2Array.h rename to include/cllazyfile/judyS2Array.h diff --git a/include/lazy/judySArray.h b/include/cllazyfile/judySArray.h similarity index 100% rename from include/lazy/judySArray.h rename to include/cllazyfile/judySArray.h diff --git a/include/lazy/lazyDataSectionReader.h b/include/cllazyfile/lazyDataSectionReader.h similarity index 92% rename from include/lazy/lazyDataSectionReader.h rename to include/cllazyfile/lazyDataSectionReader.h index 449345007..6fad4e0b8 100644 --- a/include/lazy/lazyDataSectionReader.h +++ b/include/cllazyfile/lazyDataSectionReader.h @@ -3,8 +3,8 @@ #include #include -#include "lazy/sectionReader.h" -#include "lazy/lazyTypes.h" +#include "cllazyfile/sectionReader.h" +#include "cllazyfile/lazyTypes.h" #include "sc_export.h" diff --git a/include/lazy/lazyFileReader.h b/include/cllazyfile/lazyFileReader.h similarity index 90% rename from include/lazy/lazyFileReader.h rename to include/cllazyfile/lazyFileReader.h index 40c4d9c95..9a5fccb5e 100644 --- a/include/lazy/lazyFileReader.h +++ b/include/cllazyfile/lazyFileReader.h @@ -8,9 +8,9 @@ #include "sc_export.h" // PART 21 -#include "lazy/lazyP21DataSectionReader.h" -#include "lazy/p21HeaderSectionReader.h" -#include "lazy/headerSectionReader.h" +#include "cllazyfile/lazyP21DataSectionReader.h" +#include "cllazyfile/p21HeaderSectionReader.h" +#include "cllazyfile/headerSectionReader.h" /* // PART 28 * #include "lazyP28DataSectionReader.h" diff --git a/include/lazy/lazyInstMgr.h b/include/cllazyfile/lazyInstMgr.h similarity index 98% rename from include/lazy/lazyInstMgr.h rename to include/cllazyfile/lazyInstMgr.h index ff9afc5cb..e3445660a 100644 --- a/include/lazy/lazyInstMgr.h +++ b/include/cllazyfile/lazyInstMgr.h @@ -5,11 +5,11 @@ #include #include -#include "lazy/lazyDataSectionReader.h" -#include "lazy/lazyFileReader.h" -#include "lazy/lazyTypes.h" +#include "cllazyfile/lazyDataSectionReader.h" +#include "cllazyfile/lazyFileReader.h" +#include "cllazyfile/lazyTypes.h" -#include "core/Registry.h" +#include "clstepcore/Registry.h" #include "sc_export.h" #include "judyLArray.h" diff --git a/include/lazy/lazyP21DataSectionReader.h b/include/cllazyfile/lazyP21DataSectionReader.h similarity index 89% rename from include/lazy/lazyP21DataSectionReader.h rename to include/cllazyfile/lazyP21DataSectionReader.h index 81e5f6bde..c14376fc0 100644 --- a/include/lazy/lazyP21DataSectionReader.h +++ b/include/cllazyfile/lazyP21DataSectionReader.h @@ -1,8 +1,8 @@ #ifndef LAZYP21DATASECTIONREADER_H #define LAZYP21DATASECTIONREADER_H -#include "lazy/lazyDataSectionReader.h" -#include "lazy/lazyFileReader.h" +#include "cllazyfile/lazyDataSectionReader.h" +#include "cllazyfile/lazyFileReader.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader { diff --git a/include/lazy/lazyTypes.h b/include/cllazyfile/lazyTypes.h similarity index 100% rename from include/lazy/lazyTypes.h rename to include/cllazyfile/lazyTypes.h diff --git a/include/lazy/p21HeaderSectionReader.h b/include/cllazyfile/p21HeaderSectionReader.h similarity index 93% rename from include/lazy/p21HeaderSectionReader.h rename to include/cllazyfile/p21HeaderSectionReader.h index e89c50288..ab91fb2bd 100644 --- a/include/lazy/p21HeaderSectionReader.h +++ b/include/cllazyfile/p21HeaderSectionReader.h @@ -1,7 +1,7 @@ #ifndef P21HEADERSECTIONREADER_H #define P21HEADERSECTIONREADER_H -#include "lazy/headerSectionReader.h" +#include "cllazyfile/headerSectionReader.h" #include "sc_export.h" class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader { diff --git a/include/lazy/sectionReader.h b/include/cllazyfile/sectionReader.h similarity index 97% rename from include/lazy/sectionReader.h rename to include/cllazyfile/sectionReader.h index 2afbf500e..74f1fa5bf 100644 --- a/include/lazy/sectionReader.h +++ b/include/cllazyfile/sectionReader.h @@ -3,10 +3,10 @@ #include #include -#include "lazy/lazyTypes.h" +#include "cllazyfile/lazyTypes.h" #include "sc_export.h" -#include "utils/errordesc.h" -#include "core/STEPcomplex.h" +#include "clutils/errordesc.h" +#include "clstepcore/STEPcomplex.h" class SDAI_Application_instance; class lazyFileReader; diff --git a/include/core/CMakeLists.txt b/include/clstepcore/CMakeLists.txt similarity index 96% rename from include/core/CMakeLists.txt rename to include/clstepcore/CMakeLists.txt index f43f93519..a8447cea3 100644 --- a/include/core/CMakeLists.txt +++ b/include/clstepcore/CMakeLists.txt @@ -60,7 +60,7 @@ set(CORE_HDRS ) install(FILES ${CORE_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/core) + DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore) # Local Variables: # tab-width: 8 diff --git a/include/core/ExpDict.h b/include/clstepcore/ExpDict.h similarity index 70% rename from include/core/ExpDict.h rename to include/clstepcore/ExpDict.h index 4e7087cfb..c8c71258b 100644 --- a/include/core/ExpDict.h +++ b/include/clstepcore/ExpDict.h @@ -15,20 +15,20 @@ */ #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include #include #include -#include "core/SingleLinkList.h" +#include "clstepcore/SingleLinkList.h" -#include "core/baseType.h" -#include "core/dictdefs.h" -#include "utils/Str.h" +#include "clstepcore/baseType.h" +#include "clstepcore/dictdefs.h" +#include "clutils/Str.h" // each of these contains linked list, list node, iterator -#include "core/attrDescriptorList.h" +#include "clstepcore/attrDescriptorList.h" #include "inverseAttributeList.h" #include "typeDescriptorList.h" #include "entityDescriptorList.h" @@ -37,12 +37,12 @@ #include "typeDescriptor.h" #include "entityDescriptor.h" #include "enumTypeDescriptor.h" -#include "core/attrDescriptor.h" -#include "core/derivedAttribute.h" +#include "clstepcore/attrDescriptor.h" +#include "clstepcore/derivedAttribute.h" #include "inverseAttribute.h" -#include "core/create_Aggr.h" -#include "core/dictionaryInstance.h" +#include "clstepcore/create_Aggr.h" +#include "clstepcore/dictionaryInstance.h" #include "uniquenessRule.h" #include "whereRule.h" @@ -53,10 +53,10 @@ #include "interfaceSpec.h" #include "typeOrRuleVar.h" #include "globalRule.h" -#include "core/dictSchema.h" +#include "clstepcore/dictSchema.h" #include "schRename.h" -#include "core/aggrTypeDescriptor.h" +#include "clstepcore/aggrTypeDescriptor.h" #include "selectTypeDescriptor.h" #include "stringTypeDescriptor.h" #include "realTypeDescriptor.h" diff --git a/include/core/Registry.h b/include/clstepcore/Registry.h similarity index 95% rename from include/core/Registry.h rename to include/clstepcore/Registry.h index 2f97f9d7a..099015686 100644 --- a/include/core/Registry.h +++ b/include/clstepcore/Registry.h @@ -13,11 +13,11 @@ */ #include -#include "core/sdai.h" -#include "utils/errordesc.h" -#include "utils/sc_hash.h" -#include "utils/Str.h" -#include "core/complexSupport.h" +#include "clstepcore/sdai.h" +#include "clutils/errordesc.h" +#include "clutils/sc_hash.h" +#include "clutils/Str.h" +#include "clstepcore/complexSupport.h" // defined and created in Registry.cc diff --git a/include/core/STEPaggrBinary.h b/include/clstepcore/STEPaggrBinary.h similarity index 97% rename from include/core/STEPaggrBinary.h rename to include/clstepcore/STEPaggrBinary.h index 0afe1612f..59ea61ab5 100644 --- a/include/core/STEPaggrBinary.h +++ b/include/clstepcore/STEPaggrBinary.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRBINARY_H #define STEPAGGRBINARY_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include /** \file STEPaggrBinary.h diff --git a/include/core/STEPaggrEntity.h b/include/clstepcore/STEPaggrEntity.h similarity index 98% rename from include/core/STEPaggrEntity.h rename to include/clstepcore/STEPaggrEntity.h index 2f80985bf..8338fc8f8 100644 --- a/include/core/STEPaggrEntity.h +++ b/include/clstepcore/STEPaggrEntity.h @@ -5,7 +5,7 @@ * classes EntityAggregate, EntityNode */ -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include class SC_CORE_EXPORT EntityAggregate : public STEPaggregate { diff --git a/include/core/STEPaggrEnum.h b/include/clstepcore/STEPaggrEnum.h similarity index 98% rename from include/core/STEPaggrEnum.h rename to include/clstepcore/STEPaggrEnum.h index fb181ee8e..cf16fb0e6 100644 --- a/include/core/STEPaggrEnum.h +++ b/include/clstepcore/STEPaggrEnum.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRENUM_H #define STEPAGGRENUM_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include "sc_export.h" /** \file StepaggrEnum.h * classes EnumAggregate, LOGICALS, BOOLEANS, EnumNode diff --git a/include/core/STEPaggrGeneric.h b/include/clstepcore/STEPaggrGeneric.h similarity index 97% rename from include/core/STEPaggrGeneric.h rename to include/clstepcore/STEPaggrGeneric.h index c122d2be9..ecb286d00 100644 --- a/include/core/STEPaggrGeneric.h +++ b/include/clstepcore/STEPaggrGeneric.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRGENERIC_H #define STEPAGGRGENERIC_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include /** \file STEPaggrGeneric.h diff --git a/include/core/STEPaggrInt.h b/include/clstepcore/STEPaggrInt.h similarity index 97% rename from include/core/STEPaggrInt.h rename to include/clstepcore/STEPaggrInt.h index 95d392f64..11bf57464 100644 --- a/include/core/STEPaggrInt.h +++ b/include/clstepcore/STEPaggrInt.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRINT_H #define STEPAGGRINT_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include class SC_CORE_EXPORT IntAggregate : public STEPaggregate { diff --git a/include/core/STEPaggrReal.h b/include/clstepcore/STEPaggrReal.h similarity index 97% rename from include/core/STEPaggrReal.h rename to include/clstepcore/STEPaggrReal.h index fb3dad7c4..920c98907 100644 --- a/include/core/STEPaggrReal.h +++ b/include/clstepcore/STEPaggrReal.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRREAL_H #define STEPAGGRREAL_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include class SC_CORE_EXPORT RealAggregate : public STEPaggregate { diff --git a/include/core/STEPaggrSelect.h b/include/clstepcore/STEPaggrSelect.h similarity index 98% rename from include/core/STEPaggrSelect.h rename to include/clstepcore/STEPaggrSelect.h index 82e39dbf6..dd6621caa 100644 --- a/include/core/STEPaggrSelect.h +++ b/include/clstepcore/STEPaggrSelect.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRSELECT_H #define STEPAGGRSELECT_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include /** \file STEPaggrSelect.h diff --git a/include/core/STEPaggrString.h b/include/clstepcore/STEPaggrString.h similarity index 97% rename from include/core/STEPaggrString.h rename to include/clstepcore/STEPaggrString.h index 91c148891..93aa1636e 100644 --- a/include/core/STEPaggrString.h +++ b/include/clstepcore/STEPaggrString.h @@ -1,7 +1,7 @@ #ifndef STEPAGGRSTRING_H #define STEPAGGRSTRING_H -#include "core/STEPaggregate.h" +#include "clstepcore/STEPaggregate.h" #include /** \file STEPaggrString.h diff --git a/include/core/STEPaggregate.h b/include/clstepcore/STEPaggregate.h similarity index 89% rename from include/core/STEPaggregate.h rename to include/clstepcore/STEPaggregate.h index 69a78b420..0acb638d6 100644 --- a/include/core/STEPaggregate.h +++ b/include/clstepcore/STEPaggregate.h @@ -17,11 +17,11 @@ class STEPaggregate; class TypeDescriptor; #include -#include "utils/errordesc.h" -#include "core/SingleLinkList.h" -#include "core/baseType.h" -#include "core/sdai.h" -#include "core/STEPundefined.h" +#include "clutils/errordesc.h" +#include "clstepcore/SingleLinkList.h" +#include "clstepcore/baseType.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPundefined.h" #include #define AGGR_NULL &NilSTEPaggregate @@ -110,14 +110,14 @@ class SC_CORE_EXPORT STEPnode : public SingleLinkNode { }; typedef STEPnode * STEPnodeH; -#include "core/STEPaggrGeneric.h" -#include "core/STEPaggrEntity.h" -#include "core/STEPaggrSelect.h" -#include "core/STEPaggrString.h" -#include "core/STEPaggrBinary.h" -#include "core/STEPaggrEnum.h" -#include "core/STEPaggrReal.h" -#include "core/STEPaggrInt.h" +#include "clstepcore/STEPaggrGeneric.h" +#include "clstepcore/STEPaggrEntity.h" +#include "clstepcore/STEPaggrSelect.h" +#include "clstepcore/STEPaggrString.h" +#include "clstepcore/STEPaggrBinary.h" +#include "clstepcore/STEPaggrEnum.h" +#include "clstepcore/STEPaggrReal.h" +#include "clstepcore/STEPaggrInt.h" /****************************************************************** ** FIXME The following classes are currently stubs diff --git a/include/core/STEPattribute.h b/include/clstepcore/STEPattribute.h similarity index 99% rename from include/core/STEPattribute.h rename to include/clstepcore/STEPattribute.h index fd361c817..f496fa46c 100644 --- a/include/core/STEPattribute.h +++ b/include/clstepcore/STEPattribute.h @@ -15,10 +15,10 @@ #include #include -#include "utils/errordesc.h" -#include "core/baseType.h" +#include "clutils/errordesc.h" +#include "clstepcore/baseType.h" -#include "core/sdai.h" +#include "clstepcore/sdai.h" /** \def REAL_NUM_PRECISION * this is used to set a const int Real_Num_Precision diff --git a/include/core/STEPattributeList.h b/include/clstepcore/STEPattributeList.h similarity index 97% rename from include/core/STEPattributeList.h rename to include/clstepcore/STEPattributeList.h index 929ef84a2..54aca69b4 100644 --- a/include/core/STEPattributeList.h +++ b/include/clstepcore/STEPattributeList.h @@ -16,7 +16,7 @@ class STEPattribute; #include -#include "core/SingleLinkList.h" +#include "clstepcore/SingleLinkList.h" class STEPattributeList; diff --git a/include/core/STEPcomplex.h b/include/clstepcore/STEPcomplex.h similarity index 95% rename from include/core/STEPcomplex.h rename to include/clstepcore/STEPcomplex.h index 2b8c24d8e..3c8a75fc3 100644 --- a/include/core/STEPcomplex.h +++ b/include/clstepcore/STEPcomplex.h @@ -2,11 +2,11 @@ #define STEPCOMPLEX_H #include -#include "utils/errordesc.h" -#include "core/sdai.h" -#include "core/baseType.h" -#include "core/ExpDict.h" -#include "core/Registry.h" +#include "clutils/errordesc.h" +#include "clstepcore/sdai.h" +#include "clstepcore/baseType.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" #include diff --git a/include/core/STEPinvAttrList.h b/include/clstepcore/STEPinvAttrList.h similarity index 98% rename from include/core/STEPinvAttrList.h rename to include/clstepcore/STEPinvAttrList.h index 7df262a34..ccbb733b0 100644 --- a/include/core/STEPinvAttrList.h +++ b/include/clstepcore/STEPinvAttrList.h @@ -15,7 +15,7 @@ class Inverse_attribute; #include -#include "core/SingleLinkList.h" +#include "clstepcore/SingleLinkList.h" class STEPinvAttrList; class EntityAggregate; diff --git a/include/core/STEPundefined.h b/include/clstepcore/STEPundefined.h similarity index 95% rename from include/core/STEPundefined.h rename to include/clstepcore/STEPundefined.h index 25e3f99b2..9cbb87ee7 100644 --- a/include/core/STEPundefined.h +++ b/include/clstepcore/STEPundefined.h @@ -13,9 +13,9 @@ */ #include -#include "utils/errordesc.h" +#include "clutils/errordesc.h" #include -#include "core/read_func.h" +#include "clstepcore/read_func.h" class SC_CORE_EXPORT SCLundefined { protected: diff --git a/include/core/SingleLinkList.h b/include/clstepcore/SingleLinkList.h similarity index 100% rename from include/core/SingleLinkList.h rename to include/clstepcore/SingleLinkList.h diff --git a/include/core/SubSuperIterators.h b/include/clstepcore/SubSuperIterators.h similarity index 99% rename from include/core/SubSuperIterators.h rename to include/clstepcore/SubSuperIterators.h index b70c4bde7..ccc059d28 100644 --- a/include/core/SubSuperIterators.h +++ b/include/clstepcore/SubSuperIterators.h @@ -1,8 +1,8 @@ #ifndef SUB_SUPER_ITERATORS #define SUB_SUPER_ITERATORS -#include "core/ExpDict.h" -#include "core/ExpDict.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/ExpDict.h" #include #include diff --git a/include/core/aggrTypeDescriptor.h b/include/clstepcore/aggrTypeDescriptor.h similarity index 99% rename from include/core/aggrTypeDescriptor.h rename to include/clstepcore/aggrTypeDescriptor.h index 3a08d56eb..0031adf2d 100644 --- a/include/core/aggrTypeDescriptor.h +++ b/include/clstepcore/aggrTypeDescriptor.h @@ -2,7 +2,7 @@ #define AGGRTYPEDESCRIPTOR_H #include "typeDescriptor.h" -#include "core/create_Aggr.h" +#include "clstepcore/create_Aggr.h" #include "assert.h" diff --git a/include/core/attrDescriptor.h b/include/clstepcore/attrDescriptor.h similarity index 99% rename from include/core/attrDescriptor.h rename to include/clstepcore/attrDescriptor.h index ca146d8b8..c3d6493dd 100644 --- a/include/core/attrDescriptor.h +++ b/include/clstepcore/attrDescriptor.h @@ -3,7 +3,7 @@ #include "typeDescriptor.h" -#include "dai/sdaiEnum.h" +#include "cldai/sdaiEnum.h" #include "sc_export.h" diff --git a/include/core/attrDescriptorList.h b/include/clstepcore/attrDescriptorList.h similarity index 100% rename from include/core/attrDescriptorList.h rename to include/clstepcore/attrDescriptorList.h diff --git a/include/core/baseType.h b/include/clstepcore/baseType.h similarity index 100% rename from include/core/baseType.h rename to include/clstepcore/baseType.h diff --git a/include/core/complexSupport.h b/include/clstepcore/complexSupport.h similarity index 99% rename from include/core/complexSupport.h rename to include/clstepcore/complexSupport.h index 83dbf2006..34e78814e 100644 --- a/include/core/complexSupport.h +++ b/include/clstepcore/complexSupport.h @@ -18,7 +18,7 @@ #include #include using namespace std; -#include "utils/Str.h" +#include "clutils/Str.h" #define LISTEND 999 /** \def LISTEND diff --git a/include/core/create_Aggr.h b/include/clstepcore/create_Aggr.h similarity index 97% rename from include/core/create_Aggr.h rename to include/clstepcore/create_Aggr.h index e6b6b39cb..7e5fdb0b3 100644 --- a/include/core/create_Aggr.h +++ b/include/clstepcore/create_Aggr.h @@ -3,7 +3,7 @@ //typedef's for aggregate creators -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include "sc_export.h" diff --git a/include/core/derivedAttribute.h b/include/clstepcore/derivedAttribute.h similarity index 95% rename from include/core/derivedAttribute.h rename to include/clstepcore/derivedAttribute.h index a882b0448..69e0a37cf 100644 --- a/include/core/derivedAttribute.h +++ b/include/clstepcore/derivedAttribute.h @@ -1,7 +1,7 @@ #ifndef DERIVEDATTRIBUTE_H #define DERIVEDATTRIBUTE_H -#include "core/attrDescriptor.h" +#include "clstepcore/attrDescriptor.h" #include "sc_export.h" diff --git a/include/core/dictSchema.h b/include/clstepcore/dictSchema.h similarity index 100% rename from include/core/dictSchema.h rename to include/clstepcore/dictSchema.h diff --git a/include/core/dictdefs.h b/include/clstepcore/dictdefs.h similarity index 100% rename from include/core/dictdefs.h rename to include/clstepcore/dictdefs.h diff --git a/include/core/dictionaryInstance.h b/include/clstepcore/dictionaryInstance.h similarity index 100% rename from include/core/dictionaryInstance.h rename to include/clstepcore/dictionaryInstance.h diff --git a/include/core/dispnode.h b/include/clstepcore/dispnode.h similarity index 92% rename from include/core/dispnode.h rename to include/clstepcore/dispnode.h index b25ff46ca..fccde675c 100644 --- a/include/core/dispnode.h +++ b/include/clstepcore/dispnode.h @@ -17,14 +17,14 @@ #include -/*#include "core/STEPattribute.h"*/ +/*#include "clstepcore/STEPattribute.h"*/ /*#include */ -#include "core/sdai.h" +#include "clstepcore/sdai.h" -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" //#include -#include "editor/editordefines.h" +#include "cleditor/editordefines.h" //#include class MgrNode; diff --git a/include/core/dispnodelist.h b/include/clstepcore/dispnodelist.h similarity index 92% rename from include/core/dispnodelist.h rename to include/clstepcore/dispnodelist.h index 385dbbf5e..6dfc697bd 100644 --- a/include/core/dispnodelist.h +++ b/include/clstepcore/dispnodelist.h @@ -17,12 +17,12 @@ #include -#include "utils/gennode.h" +#include "clutils/gennode.h" //#include -#include "editor/editordefines.h" -#include "core/mgrnode.h" -#include "core/dispnode.h" -#include "utils/gennodelist.h" +#include "cleditor/editordefines.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/dispnode.h" +#include "clutils/gennodelist.h" /////////////////////////////////////////////////////////////////////////////// // class DisplayNodeList diff --git a/include/core/entityDescriptor.h b/include/clstepcore/entityDescriptor.h similarity index 98% rename from include/core/entityDescriptor.h rename to include/clstepcore/entityDescriptor.h index 2e85e7a66..a51810c3f 100644 --- a/include/core/entityDescriptor.h +++ b/include/clstepcore/entityDescriptor.h @@ -2,9 +2,9 @@ #define ENTITYDESCRIPTOR_H #include "typeDescriptor.h" -#include "core/attrDescriptor.h" +#include "clstepcore/attrDescriptor.h" #include "uniquenessRule.h" -#include "core/attrDescriptorList.h" +#include "clstepcore/attrDescriptorList.h" #include "inverseAttributeList.h" #include "sc_export.h" diff --git a/include/core/entityDescriptorList.h b/include/clstepcore/entityDescriptorList.h similarity index 100% rename from include/core/entityDescriptorList.h rename to include/clstepcore/entityDescriptorList.h diff --git a/include/core/enumTypeDescriptor.h b/include/clstepcore/enumTypeDescriptor.h similarity index 100% rename from include/core/enumTypeDescriptor.h rename to include/clstepcore/enumTypeDescriptor.h diff --git a/include/core/explicitItemId.h b/include/clstepcore/explicitItemId.h similarity index 100% rename from include/core/explicitItemId.h rename to include/clstepcore/explicitItemId.h diff --git a/include/core/globalRule.h b/include/clstepcore/globalRule.h similarity index 97% rename from include/core/globalRule.h rename to include/clstepcore/globalRule.h index 2fe3ee14f..0987fbfbd 100644 --- a/include/core/globalRule.h +++ b/include/clstepcore/globalRule.h @@ -1,7 +1,7 @@ #ifndef GLOBALRULE_H #define GLOBALRULE_H -#include "core/dictionaryInstance.h" +#include "clstepcore/dictionaryInstance.h" #include "whereRule.h" #include "entityDescriptorList.h" diff --git a/include/core/implicitItemId.h b/include/clstepcore/implicitItemId.h similarity index 100% rename from include/core/implicitItemId.h rename to include/clstepcore/implicitItemId.h diff --git a/include/core/instmgr.h b/include/clstepcore/instmgr.h similarity index 93% rename from include/core/instmgr.h rename to include/clstepcore/instmgr.h index b763b87b7..86ed28603 100644 --- a/include/core/instmgr.h +++ b/include/clstepcore/instmgr.h @@ -27,17 +27,17 @@ // IT IS VERY IMPORTANT THAT THE ORDER OF THE FOLLOWING INCLUDE FILES // BE PRESERVED -#include "utils/gennode.h" -#include "utils/gennodelist.h" -#include "utils/gennodearray.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" +#include "clutils/gennodearray.h" -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" -#include "core/dispnode.h" -#include "core/dispnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" -#include "core/mgrnodearray.h" +#include "clstepcore/mgrnodearray.h" class SC_CORE_EXPORT InstMgrBase { public: diff --git a/include/core/interfaceSpec.h b/include/clstepcore/interfaceSpec.h similarity index 97% rename from include/core/interfaceSpec.h rename to include/clstepcore/interfaceSpec.h index f0b4bde19..9eeea3f85 100644 --- a/include/core/interfaceSpec.h +++ b/include/clstepcore/interfaceSpec.h @@ -1,8 +1,8 @@ #ifndef INTERFACESPEC_H #define INTERFACESPEC_H -#include "core/dictionaryInstance.h" -#include "core/explicitItemId.h" +#include "clstepcore/dictionaryInstance.h" +#include "clstepcore/explicitItemId.h" #include "implicitItemId.h" #include "sc_export.h" diff --git a/include/core/interfacedItem.h b/include/clstepcore/interfacedItem.h similarity index 89% rename from include/core/interfacedItem.h rename to include/clstepcore/interfacedItem.h index 909aa3881..238969836 100644 --- a/include/core/interfacedItem.h +++ b/include/clstepcore/interfacedItem.h @@ -1,9 +1,9 @@ #ifndef INTERFACEDITEM_H #define INTERFACEDITEM_H -#include "core/dictionaryInstance.h" +#include "clstepcore/dictionaryInstance.h" -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include "sc_export.h" diff --git a/include/core/inverseAttribute.h b/include/clstepcore/inverseAttribute.h similarity index 98% rename from include/core/inverseAttribute.h rename to include/clstepcore/inverseAttribute.h index 368eaa67f..4008cdaf8 100644 --- a/include/core/inverseAttribute.h +++ b/include/clstepcore/inverseAttribute.h @@ -1,7 +1,7 @@ #ifndef INVERSEATTRIBUTE_H #define INVERSEATTRIBUTE_H -#include "core/attrDescriptor.h" +#include "clstepcore/attrDescriptor.h" class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor { diff --git a/include/core/inverseAttributeList.h b/include/clstepcore/inverseAttributeList.h similarity index 100% rename from include/core/inverseAttributeList.h rename to include/clstepcore/inverseAttributeList.h diff --git a/include/core/mgrnode.h b/include/clstepcore/mgrnode.h similarity index 97% rename from include/core/mgrnode.h rename to include/clstepcore/mgrnode.h index 3befa9393..9bc96ef1d 100644 --- a/include/core/mgrnode.h +++ b/include/clstepcore/mgrnode.h @@ -18,12 +18,12 @@ class GenericNode; class DisplayNode; -#include "core/sdai.h" +#include "clstepcore/sdai.h" -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" -#include "editor/editordefines.h" +#include "cleditor/editordefines.h" class InstMgr; diff --git a/include/core/mgrnodearray.h b/include/clstepcore/mgrnodearray.h similarity index 95% rename from include/core/mgrnodearray.h rename to include/clstepcore/mgrnodearray.h index 02d2191fa..c09f6995f 100644 --- a/include/core/mgrnodearray.h +++ b/include/clstepcore/mgrnodearray.h @@ -19,14 +19,14 @@ #include -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" //#include -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" -#include "utils/gennodearray.h" +#include "clutils/gennodearray.h" #define ARRAY_DEFAULT_SIZE (1024) diff --git a/include/core/mgrnodelist.h b/include/clstepcore/mgrnodelist.h similarity index 94% rename from include/core/mgrnodelist.h rename to include/clstepcore/mgrnodelist.h index 471e40216..e085b66c5 100644 --- a/include/core/mgrnodelist.h +++ b/include/clstepcore/mgrnodelist.h @@ -17,10 +17,10 @@ #include -#include "utils/gennode.h" +#include "clutils/gennode.h" //#include -#include "utils/gennodelist.h" -#include "editor/editordefines.h" +#include "clutils/gennodelist.h" +#include "cleditor/editordefines.h" ////////////////////////////////////////////////////////////////////////////// // class MgrNodeList diff --git a/include/core/needFunc.h b/include/clstepcore/needFunc.h similarity index 100% rename from include/core/needFunc.h rename to include/clstepcore/needFunc.h diff --git a/include/core/read_func.h b/include/clstepcore/read_func.h similarity index 99% rename from include/core/read_func.h rename to include/clstepcore/read_func.h index 66289efbe..448297164 100644 --- a/include/core/read_func.h +++ b/include/clstepcore/read_func.h @@ -2,7 +2,7 @@ #define READ_FUNC_H #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" /// This was 512. According to 10303-21:2002 section 5.6: comment length is unlimited. FIXME need to check the code for potential problems before eliminating this limit completely. #define MAX_COMMENT_LENGTH 8192 diff --git a/include/core/realTypeDescriptor.h b/include/clstepcore/realTypeDescriptor.h similarity index 100% rename from include/core/realTypeDescriptor.h rename to include/clstepcore/realTypeDescriptor.h diff --git a/include/core/schRename.h b/include/clstepcore/schRename.h similarity index 98% rename from include/core/schRename.h rename to include/clstepcore/schRename.h index 042b7fda2..b3f7fdefd 100644 --- a/include/core/schRename.h +++ b/include/clstepcore/schRename.h @@ -4,7 +4,7 @@ #include #include -#include "utils/Str.h" +#include "clutils/Str.h" #include "sc_export.h" diff --git a/include/core/sdai.h b/include/clstepcore/sdai.h similarity index 92% rename from include/core/sdai.h rename to include/clstepcore/sdai.h index 674571bde..f063653ce 100644 --- a/include/core/sdai.h +++ b/include/clstepcore/sdai.h @@ -27,11 +27,11 @@ extern const char * SCLversion; #include -#include "core/dictdefs.h" +#include "clstepcore/dictdefs.h" -#include "core/baseType.h" -#include "utils/Str.h" -#include "utils/errordesc.h" +#include "clstepcore/baseType.h" +#include "clutils/Str.h" +#include "clutils/errordesc.h" typedef std::string Express_id; @@ -40,8 +40,8 @@ class EntityDescriptor; class SelectTypeDescriptor; class InstMgrBase; -#include "core/STEPattributeList.h" -#include "core/STEPinvAttrList.h" +#include "clstepcore/STEPattributeList.h" +#include "clstepcore/STEPinvAttrList.h" class STEPattributeList; class STEPattribute; @@ -155,12 +155,12 @@ typedef char * SDAI_Time_stamp; typedef char * SDAI_Entity_name; typedef char * SDAI_Schema_name; -#include "dai/sdaiString.h" +#include "cldai/sdaiString.h" -#include "dai/sdaiBinary.h" +#include "cldai/sdaiBinary.h" // define Object which I am calling sdaiObject for now - DAS -#include "dai/sdaiObject.h" +#include "cldai/sdaiObject.h" /****************************************************************************** ENUMERATION @@ -172,7 +172,7 @@ ENUMERATION * the value ENUM_NULL is used to represent NULL for all enumerated types *****************************************************************************/ -#include "dai/sdaiEnum.h" +#include "cldai/sdaiEnum.h" /****************************************************************************** BOOLEAN and LOGICAL @@ -185,11 +185,11 @@ BOOLEAN and LOGICAL // ***note*** this file needs classes from sdaiEnum.h // define DAObjectID and classes PID, PID_DA, PID_SDAI, DAObject, DAObject_SDAI -#include "dai/sdaiDaObject.h" +#include "cldai/sdaiDaObject.h" -#include "core/sdaiApplication_instance.h" -#include "dai/sdaiApplication_instance_set.h" +#include "clstepcore/sdaiApplication_instance.h" +#include "cldai/sdaiApplication_instance_set.h" /****************************************************************************** SELECT @@ -198,18 +198,18 @@ SELECT sdaiSelect.h ******************************************************************************/ -#include "core/sdaiSelect.h" +#include "clstepcore/sdaiSelect.h" class SDAI_Model_contents; typedef SDAI_Model_contents * SDAI_Model_contents_ptr; typedef SDAI_Model_contents_ptr SDAI_Model_contents_var; -#include "dai/sdaiModel_contents_list.h" +#include "cldai/sdaiModel_contents_list.h" -#include "dai/sdaiSession_instance.h" -#include "dai/sdaiEntity_extent.h" -#include "dai/sdaiEntity_extent_set.h" -#include "dai/sdaiModel_contents.h" +#include "cldai/sdaiSession_instance.h" +#include "cldai/sdaiEntity_extent.h" +#include "cldai/sdaiEntity_extent_set.h" +#include "cldai/sdaiModel_contents.h" // ENTITY extern SC_CORE_EXPORT SDAI_Application_instance NilSTEPentity; diff --git a/include/core/sdaiApplication_instance.h b/include/clstepcore/sdaiApplication_instance.h similarity index 99% rename from include/core/sdaiApplication_instance.h rename to include/clstepcore/sdaiApplication_instance.h index 9fbca1e72..4e764f593 100644 --- a/include/core/sdaiApplication_instance.h +++ b/include/clstepcore/sdaiApplication_instance.h @@ -16,7 +16,7 @@ #include #include -#include "dai/sdaiDaObject.h" +#include "cldai/sdaiDaObject.h" class EntityAggregate; class Inverse_attribute; diff --git a/include/core/sdaiSelect.h b/include/clstepcore/sdaiSelect.h similarity index 100% rename from include/core/sdaiSelect.h rename to include/clstepcore/sdaiSelect.h diff --git a/include/core/selectTypeDescriptor.h b/include/clstepcore/selectTypeDescriptor.h similarity index 100% rename from include/core/selectTypeDescriptor.h rename to include/clstepcore/selectTypeDescriptor.h diff --git a/include/core/stringTypeDescriptor.h b/include/clstepcore/stringTypeDescriptor.h similarity index 100% rename from include/core/stringTypeDescriptor.h rename to include/clstepcore/stringTypeDescriptor.h diff --git a/include/core/typeDescriptor.h b/include/clstepcore/typeDescriptor.h similarity index 99% rename from include/core/typeDescriptor.h rename to include/clstepcore/typeDescriptor.h index a3e64a33b..51a815593 100644 --- a/include/core/typeDescriptor.h +++ b/include/clstepcore/typeDescriptor.h @@ -3,7 +3,7 @@ #include "schRename.h" #include "whereRule.h" -#include "core/dictSchema.h" +#include "clstepcore/dictSchema.h" #include "sc_export.h" diff --git a/include/core/typeDescriptorList.h b/include/clstepcore/typeDescriptorList.h similarity index 100% rename from include/core/typeDescriptorList.h rename to include/clstepcore/typeDescriptorList.h diff --git a/include/core/typeOrRuleVar.h b/include/clstepcore/typeOrRuleVar.h similarity index 89% rename from include/core/typeOrRuleVar.h rename to include/clstepcore/typeOrRuleVar.h index 9fa58be34..c698c5bd5 100644 --- a/include/core/typeOrRuleVar.h +++ b/include/clstepcore/typeOrRuleVar.h @@ -1,7 +1,7 @@ #ifndef TYPEORRULEVAR_H #define TYPEORRULEVAR_H -#include "core/dictionaryInstance.h" +#include "clstepcore/dictionaryInstance.h" #include "sc_export.h" diff --git a/include/core/uniquenessRule.h b/include/clstepcore/uniquenessRule.h similarity index 96% rename from include/core/uniquenessRule.h rename to include/clstepcore/uniquenessRule.h index 93c13a75d..b42a7414d 100644 --- a/include/core/uniquenessRule.h +++ b/include/clstepcore/uniquenessRule.h @@ -1,9 +1,9 @@ #ifndef UNIQUENESSRULE_H #define UNIQUENESSRULE_H -#include "core/dictionaryInstance.h" +#include "clstepcore/dictionaryInstance.h" -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include "sc_export.h" diff --git a/include/core/whereRule.h b/include/clstepcore/whereRule.h similarity index 96% rename from include/core/whereRule.h rename to include/clstepcore/whereRule.h index 3a88f71c9..98952d049 100644 --- a/include/core/whereRule.h +++ b/include/clstepcore/whereRule.h @@ -2,8 +2,8 @@ #define WHERERULE_H #include -#include "core/sdai.h" -#include "core/dictionaryInstance.h" +#include "clstepcore/sdai.h" +#include "clstepcore/dictionaryInstance.h" #include "typeOrRuleVar.h" #include "sc_export.h" diff --git a/include/utils/CMakeLists.txt b/include/clutils/CMakeLists.txt similarity index 83% rename from include/utils/CMakeLists.txt rename to include/clutils/CMakeLists.txt index 127b971e2..9992890bc 100644 --- a/include/utils/CMakeLists.txt +++ b/include/clutils/CMakeLists.txt @@ -9,7 +9,7 @@ set(UTILS_HDRS ) install(FILES ${UTILS_HDRS} - DESTINATION ${INCLUDE_DIR}/stepcode/utils) + DESTINATION ${INCLUDE_DIR}/stepcode/clutils) # Local Variables: # tab-width: 8 diff --git a/include/utils/Str.h b/include/clutils/Str.h similarity index 98% rename from include/utils/Str.h rename to include/clutils/Str.h index 80ea6ab1d..487a2c9e2 100644 --- a/include/utils/Str.h +++ b/include/clutils/Str.h @@ -19,7 +19,7 @@ #include #include #include -#include "utils/errordesc.h" +#include "clutils/errordesc.h" #ifndef STRING_DELIM #define STRING_DELIM '\'' diff --git a/include/utils/dirobj.h b/include/clutils/dirobj.h similarity index 100% rename from include/utils/dirobj.h rename to include/clutils/dirobj.h diff --git a/include/utils/errordesc.h b/include/clutils/errordesc.h similarity index 100% rename from include/utils/errordesc.h rename to include/clutils/errordesc.h diff --git a/include/utils/gennode.h b/include/clutils/gennode.h similarity index 100% rename from include/utils/gennode.h rename to include/clutils/gennode.h diff --git a/include/utils/gennodearray.h b/include/clutils/gennodearray.h similarity index 98% rename from include/utils/gennodearray.h rename to include/clutils/gennodearray.h index f19dc21be..1643f05e6 100644 --- a/include/utils/gennodearray.h +++ b/include/clutils/gennodearray.h @@ -26,7 +26,7 @@ #include #include // to get bcopy for CenterLine -#include "utils/gennode.h" +#include "clutils/gennode.h" // the initial size of the array #define ARRAY_DEFAULT_SIZE (1024) diff --git a/include/utils/gennodelist.h b/include/clutils/gennodelist.h similarity index 100% rename from include/utils/gennodelist.h rename to include/clutils/gennodelist.h diff --git a/include/utils/sc_hash.h b/include/clutils/sc_hash.h similarity index 100% rename from include/utils/sc_hash.h rename to include/clutils/sc_hash.h diff --git a/src/cldai/sdaiApplication_instance_set.cc b/src/cldai/sdaiApplication_instance_set.cc index d1961fce3..f1733d40d 100644 --- a/src/cldai/sdaiApplication_instance_set.cc +++ b/src/cldai/sdaiApplication_instance_set.cc @@ -24,13 +24,13 @@ * UArray implementation. */ -//#include "dai/sdaiApplication_instance_set.h" -#include "core/sdai.h" +//#include "cldai/sdaiApplication_instance_set.h" +#include "clstepcore/sdai.h" #include #include -#include "core/sdaiApplication_instance.h" +#include "clstepcore/sdaiApplication_instance.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiBinary.cc b/src/cldai/sdaiBinary.cc index 7ccf00689..e9c384f74 100644 --- a/src/cldai/sdaiBinary.cc +++ b/src/cldai/sdaiBinary.cc @@ -10,7 +10,7 @@ */ #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" SDAI_Binary::SDAI_Binary( const char * str, int max ) { content = std::string( str, max ); diff --git a/src/cldai/sdaiDaObject.cc b/src/cldai/sdaiDaObject.cc index 801b21b8f..52f06fc16 100644 --- a/src/cldai/sdaiDaObject.cc +++ b/src/cldai/sdaiDaObject.cc @@ -2,7 +2,7 @@ #include #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiEntity_extent.cc b/src/cldai/sdaiEntity_extent.cc index d28fca2bb..7c27ea6e4 100644 --- a/src/cldai/sdaiEntity_extent.cc +++ b/src/cldai/sdaiEntity_extent.cc @@ -2,7 +2,7 @@ //#include -#include "core/sdai.h" +#include "clstepcore/sdai.h" SDAI_Entity_extent::SDAI_Entity_extent( ) : _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) { diff --git a/src/cldai/sdaiEntity_extent_set.cc b/src/cldai/sdaiEntity_extent_set.cc index ca464eb2b..4080e336b 100644 --- a/src/cldai/sdaiEntity_extent_set.cc +++ b/src/cldai/sdaiEntity_extent_set.cc @@ -26,7 +26,7 @@ #include #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" /* #include diff --git a/src/cldai/sdaiEnum.cc b/src/cldai/sdaiEnum.cc index 65ce8828f..8228855b5 100644 --- a/src/cldai/sdaiEnum.cc +++ b/src/cldai/sdaiEnum.cc @@ -1,5 +1,5 @@ -#include "core/sdai.h" +#include "clstepcore/sdai.h" /* * NIST STEP Core Class Library diff --git a/src/cldai/sdaiModel_contents.cc b/src/cldai/sdaiModel_contents.cc index b7043a454..3cb0828a0 100644 --- a/src/cldai/sdaiModel_contents.cc +++ b/src/cldai/sdaiModel_contents.cc @@ -1,5 +1,5 @@ -#include "core/sdai.h" +#include "clstepcore/sdai.h" ///////// SDAI_Model_contents_instances diff --git a/src/cldai/sdaiModel_contents_list.cc b/src/cldai/sdaiModel_contents_list.cc index a74aadb41..62197b190 100644 --- a/src/cldai/sdaiModel_contents_list.cc +++ b/src/cldai/sdaiModel_contents_list.cc @@ -23,7 +23,7 @@ /* * UArray implementation. */ -#include "core/sdai.h" +#include "clstepcore/sdai.h" // to help ObjectCenter #ifndef HAVE_MEMMOVE diff --git a/src/cldai/sdaiObject.cc b/src/cldai/sdaiObject.cc index f0a1ac592..fd930881c 100644 --- a/src/cldai/sdaiObject.cc +++ b/src/cldai/sdaiObject.cc @@ -1,4 +1,4 @@ -#include "core/sdai.h" +#include "clstepcore/sdai.h" SDAI_sdaiObject::SDAI_sdaiObject() { } diff --git a/src/cldai/sdaiSession_instance.cc b/src/cldai/sdaiSession_instance.cc index 5c8a901d2..291c0c21b 100644 --- a/src/cldai/sdaiSession_instance.cc +++ b/src/cldai/sdaiSession_instance.cc @@ -1,4 +1,4 @@ -#include "core/sdai.h" +#include "clstepcore/sdai.h" SDAI_Session_instance::SDAI_Session_instance() { } diff --git a/src/cldai/sdaiString.cc b/src/cldai/sdaiString.cc index e5818d190..06f94d9e6 100644 --- a/src/cldai/sdaiString.cc +++ b/src/cldai/sdaiString.cc @@ -9,7 +9,7 @@ * and is not subject to copyright. */ -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include SDAI_String::SDAI_String( const char * str, size_t max ) { diff --git a/src/cleditor/STEPfile.cc b/src/cleditor/STEPfile.cc index 2d4999bcc..a05ef9a7f 100644 --- a/src/cleditor/STEPfile.cc +++ b/src/cleditor/STEPfile.cc @@ -24,15 +24,15 @@ #include #include -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPcomplex.h" -#include "core/STEPattribute.h" -#include "editor/SdaiHeaderSchema.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPcomplex.h" +#include "clstepcore/STEPattribute.h" +#include "cleditor/SdaiHeaderSchema.h" // STEPundefined contains // void PushPastString (istream& in, std::string &s, ErrorDescriptor *err) -#include "core/STEPundefined.h" +#include "clstepcore/STEPundefined.h" /** * \returns The new file name for the class. diff --git a/src/cleditor/STEPfile.inline.cc b/src/cleditor/STEPfile.inline.cc index 404c6780b..86af07564 100644 --- a/src/cleditor/STEPfile.inline.cc +++ b/src/cleditor/STEPfile.inline.cc @@ -11,9 +11,9 @@ * and is not subject to copyright. */ -#include "editor/STEPfile.h" -#include "editor/SdaiHeaderSchema.h" -#include "core/STEPaggregate.h" +#include "cleditor/STEPfile.h" +#include "cleditor/SdaiHeaderSchema.h" +#include "clstepcore/STEPaggregate.h" #include #include diff --git a/src/cleditor/SdaiHeaderSchema.cc b/src/cleditor/SdaiHeaderSchema.cc index bf23f340e..73212bc48 100644 --- a/src/cleditor/SdaiHeaderSchema.cc +++ b/src/cleditor/SdaiHeaderSchema.cc @@ -10,9 +10,9 @@ extern ofstream * logStream; #define SCLLOGFILE "scl.log" #endif -#include "core/ExpDict.h" -#include "core/STEPattribute.h" -#include "editor/SdaiHeaderSchema.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/STEPattribute.h" +#include "cleditor/SdaiHeaderSchema.h" Schema * s_header_section_schema = 0; diff --git a/src/cleditor/SdaiHeaderSchemaAll.cc b/src/cleditor/SdaiHeaderSchemaAll.cc index 76fc8d996..cf88eb3aa 100644 --- a/src/cleditor/SdaiHeaderSchemaAll.cc +++ b/src/cleditor/SdaiHeaderSchemaAll.cc @@ -4,7 +4,7 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include "editor/SdaiHeaderSchema.h" +#include "cleditor/SdaiHeaderSchema.h" void HeaderInitSchemasAndEnts( Registry & reg ) { Uniqueness_rule_ptr ur; diff --git a/src/cleditor/SdaiHeaderSchemaInit.cc b/src/cleditor/SdaiHeaderSchemaInit.cc index 94e0d50eb..32b1655d1 100644 --- a/src/cleditor/SdaiHeaderSchemaInit.cc +++ b/src/cleditor/SdaiHeaderSchemaInit.cc @@ -4,10 +4,10 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include "core/Registry.h" -#include "core/ExpDict.h" -#include "core/STEPattribute.h" -#include "editor/SdaiHeaderSchema.h" +#include "clstepcore/Registry.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/STEPattribute.h" +#include "cleditor/SdaiHeaderSchema.h" void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) { header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING ); diff --git a/src/cleditor/SdaiSchemaInit.cc b/src/cleditor/SdaiSchemaInit.cc index d7a54bdd0..82323987a 100644 --- a/src/cleditor/SdaiSchemaInit.cc +++ b/src/cleditor/SdaiSchemaInit.cc @@ -4,7 +4,7 @@ // it since your modifications will be lost if exp2cxx is used to // regenerate it. -#include "editor/SdaiSchemaInit.h" +#include "cleditor/SdaiSchemaInit.h" void HeaderSchemaInit( Registry & reg ) { HeaderInitSchemasAndEnts( reg ); diff --git a/src/cleditor/cmdmgr.cc b/src/cleditor/cmdmgr.cc index 6646ee0a8..4b78d4f90 100644 --- a/src/cleditor/cmdmgr.cc +++ b/src/cleditor/cmdmgr.cc @@ -10,7 +10,7 @@ * and is not subject to copyright. */ -#include "editor/cmdmgr.h" +#include "cleditor/cmdmgr.h" ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) { ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead(); diff --git a/src/cllazyfile/judy.c b/src/cllazyfile/judy.c index 2bdba01ea..f3bba2b7e 100644 --- a/src/cllazyfile/judy.c +++ b/src/cllazyfile/judy.c @@ -60,7 +60,7 @@ # endif #endif -#include "lazy/judy.h" +#include "cllazyfile/judy.h" #include #include diff --git a/src/cllazyfile/lazyDataSectionReader.cc b/src/cllazyfile/lazyDataSectionReader.cc index cede12733..6de006fe4 100644 --- a/src/cllazyfile/lazyDataSectionReader.cc +++ b/src/cllazyfile/lazyDataSectionReader.cc @@ -1,6 +1,6 @@ -#include "lazy/lazyDataSectionReader.h" -#include "lazy/lazyFileReader.h" -#include "lazy/lazyInstMgr.h" +#include "cllazyfile/lazyDataSectionReader.h" +#include "cllazyfile/lazyFileReader.h" +#include "cllazyfile/lazyInstMgr.h" #include lazyDataSectionReader::lazyDataSectionReader( lazyFileReader * parent, std::ifstream & file, diff --git a/src/cllazyfile/lazyFileReader.cc b/src/cllazyfile/lazyFileReader.cc index 090e3337f..fed35c6f5 100644 --- a/src/cllazyfile/lazyFileReader.cc +++ b/src/cllazyfile/lazyFileReader.cc @@ -1,10 +1,10 @@ #include -#include "lazy/lazyFileReader.h" -#include "lazy/lazyDataSectionReader.h" -#include "lazy/headerSectionReader.h" -#include "lazy/lazyInstMgr.h" +#include "cllazyfile/lazyFileReader.h" +#include "cllazyfile/lazyDataSectionReader.h" +#include "cllazyfile/headerSectionReader.h" +#include "cllazyfile/lazyInstMgr.h" void lazyFileReader::initP21() { _header = new p21HeaderSectionReader( this, _file, 0, -1 ); diff --git a/src/cllazyfile/lazyInstMgr.cc b/src/cllazyfile/lazyInstMgr.cc index f7aec713f..65f3e7558 100644 --- a/src/cllazyfile/lazyInstMgr.cc +++ b/src/cllazyfile/lazyInstMgr.cc @@ -1,12 +1,12 @@ -#include "lazy/lazyTypes.h" -#include "lazy/lazyInstMgr.h" -#include "core/Registry.h" -#include "core/SubSuperIterators.h" -#include "editor/SdaiSchemaInit.h" -#include "lazy/instMgrHelper.h" +#include "cllazyfile/lazyTypes.h" +#include "cllazyfile/lazyInstMgr.h" +#include "clstepcore/Registry.h" +#include "clstepcore/SubSuperIterators.h" +#include "cleditor/SdaiSchemaInit.h" +#include "cllazyfile/instMgrHelper.h" #include "lazyRefs.h" -#include "core/sdaiApplication_instance.h" +#include "clstepcore/sdaiApplication_instance.h" lazyInstMgr::lazyInstMgr() { _headerRegistry = new Registry( HeaderSchemaInit ); diff --git a/src/cllazyfile/lazyP21DataSectionReader.cc b/src/cllazyfile/lazyP21DataSectionReader.cc index 0a726cde8..0716f5c5f 100644 --- a/src/cllazyfile/lazyP21DataSectionReader.cc +++ b/src/cllazyfile/lazyP21DataSectionReader.cc @@ -1,7 +1,7 @@ #include #include -#include "lazy/lazyP21DataSectionReader.h" -#include "lazy/lazyInstMgr.h" +#include "cllazyfile/lazyP21DataSectionReader.h" +#include "cllazyfile/lazyInstMgr.h" lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ): diff --git a/src/cllazyfile/lazyRefs.h b/src/cllazyfile/lazyRefs.h index b13a4b4e2..b8daff295 100644 --- a/src/cllazyfile/lazyRefs.h +++ b/src/cllazyfile/lazyRefs.h @@ -7,12 +7,12 @@ #include #include "sc_export.h" -#include "lazy/lazyTypes.h" -#include "lazy/lazyInstMgr.h" -#include "core/ExpDict.h" -#include "core/SubSuperIterators.h" -#include "core/STEPattribute.h" -#include "core/STEPaggregate.h" +#include "cllazyfile/lazyTypes.h" +#include "cllazyfile/lazyInstMgr.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/SubSuperIterators.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/STEPaggregate.h" #ifdef _WIN32 #define strcasecmp _strcmpi diff --git a/src/cllazyfile/lazy_test.cc b/src/cllazyfile/lazy_test.cc index 47af530da..d5ce6081a 100644 --- a/src/cllazyfile/lazy_test.cc +++ b/src/cllazyfile/lazy_test.cc @@ -1,6 +1,6 @@ -#include "lazy/lazyInstMgr.h" +#include "cllazyfile/lazyInstMgr.h" #include "./sc_benchmark.h" -#include "editor/SdaiSchemaInit.h" +#include "cleditor/SdaiSchemaInit.h" #include "config.h" #ifndef NO_REGISTRY diff --git a/src/cllazyfile/p21HeaderSectionReader.cc b/src/cllazyfile/p21HeaderSectionReader.cc index 126d2295f..037604fc4 100644 --- a/src/cllazyfile/p21HeaderSectionReader.cc +++ b/src/cllazyfile/p21HeaderSectionReader.cc @@ -1,11 +1,11 @@ #include #include -#include "lazy/p21HeaderSectionReader.h" -#include "lazy/headerSectionReader.h" -#include "lazy/sectionReader.h" -#include "lazy/lazyInstMgr.h" -#include "lazy/judyL2Array.h" +#include "cllazyfile/p21HeaderSectionReader.h" +#include "cllazyfile/headerSectionReader.h" +#include "cllazyfile/sectionReader.h" +#include "cllazyfile/lazyInstMgr.h" +#include "cllazyfile/judyL2Array.h" void p21HeaderSectionReader::findSectionStart() { diff --git a/src/cllazyfile/sectionReader.cc b/src/cllazyfile/sectionReader.cc index 1d1a81253..bfa8a2a12 100644 --- a/src/cllazyfile/sectionReader.cc +++ b/src/cllazyfile/sectionReader.cc @@ -12,16 +12,16 @@ # define ULLONG_MAX _UI64_MAX #endif -#include "core/Registry.h" -#include "core/sdaiApplication_instance.h" -#include "core/read_func.h" -#include "editor/SdaiSchemaInit.h" -#include "core/STEPcomplex.h" +#include "clstepcore/Registry.h" +#include "clstepcore/sdaiApplication_instance.h" +#include "clstepcore/read_func.h" +#include "cleditor/SdaiSchemaInit.h" +#include "clstepcore/STEPcomplex.h" -#include "lazy/sectionReader.h" -#include "lazy/lazyFileReader.h" -#include "lazy/lazyInstMgr.h" -#include "lazy/lazyTypes.h" +#include "cllazyfile/sectionReader.h" +#include "cllazyfile/lazyFileReader.h" +#include "cllazyfile/lazyInstMgr.h" +#include "cllazyfile/lazyTypes.h" #include "current_function.hpp" diff --git a/src/clstepcore/Registry.cc b/src/clstepcore/Registry.cc index 5d9f5d917..9eeb975e0 100644 --- a/src/clstepcore/Registry.cc +++ b/src/clstepcore/Registry.cc @@ -9,8 +9,8 @@ * and is not subject to copyright. */ -#include "core/ExpDict.h" -#include "core/Registry.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" /* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor * Name, FundamentalType, Originating Schema, Description */ diff --git a/src/clstepcore/STEPaggrBinary.cc b/src/clstepcore/STEPaggrBinary.cc index 90172139f..f1170926c 100644 --- a/src/clstepcore/STEPaggrBinary.cc +++ b/src/clstepcore/STEPaggrBinary.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrBinary.h" +#include "clstepcore/STEPaggrBinary.h" #include /** \file STEPaggrBinary.cc diff --git a/src/clstepcore/STEPaggrEntity.cc b/src/clstepcore/STEPaggrEntity.cc index 5f677ee1e..02bfa3fb2 100644 --- a/src/clstepcore/STEPaggrEntity.cc +++ b/src/clstepcore/STEPaggrEntity.cc @@ -1,6 +1,6 @@ -#include "core/STEPaggrEntity.h" -#include "core/STEPattribute.h" -#include "core/typeDescriptor.h" +#include "clstepcore/STEPaggrEntity.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/typeDescriptor.h" #include /** \file STEPaggrEntity.cc diff --git a/src/clstepcore/STEPaggrEnum.cc b/src/clstepcore/STEPaggrEnum.cc index d0b1e944b..01ac21e4a 100644 --- a/src/clstepcore/STEPaggrEnum.cc +++ b/src/clstepcore/STEPaggrEnum.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrEnum.h" +#include "clstepcore/STEPaggrEnum.h" #include /** \file StepaggrEnum.cc diff --git a/src/clstepcore/STEPaggrGeneric.cc b/src/clstepcore/STEPaggrGeneric.cc index 8ddcf413f..5db812b27 100644 --- a/src/clstepcore/STEPaggrGeneric.cc +++ b/src/clstepcore/STEPaggrGeneric.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrGeneric.h" +#include "clstepcore/STEPaggrGeneric.h" #include /** \file STEPaggrGeneric.cc diff --git a/src/clstepcore/STEPaggrInt.cc b/src/clstepcore/STEPaggrInt.cc index 4d6740623..936ab36d8 100644 --- a/src/clstepcore/STEPaggrInt.cc +++ b/src/clstepcore/STEPaggrInt.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrInt.h" +#include "clstepcore/STEPaggrInt.h" IntAggregate::IntAggregate() { diff --git a/src/clstepcore/STEPaggrReal.cc b/src/clstepcore/STEPaggrReal.cc index 92920e202..96ae53406 100644 --- a/src/clstepcore/STEPaggrReal.cc +++ b/src/clstepcore/STEPaggrReal.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrReal.h" +#include "clstepcore/STEPaggrReal.h" /** \file STEPaggrReal.cc * implementation of classes RealAggregate and RealNode diff --git a/src/clstepcore/STEPaggrSelect.cc b/src/clstepcore/STEPaggrSelect.cc index c70f91c70..73fe97176 100644 --- a/src/clstepcore/STEPaggrSelect.cc +++ b/src/clstepcore/STEPaggrSelect.cc @@ -1,5 +1,5 @@ -#include "core/STEPaggrSelect.h" -#include "core/typeDescriptor.h" +#include "clstepcore/STEPaggrSelect.h" +#include "clstepcore/typeDescriptor.h" #include /** \file STEPaggrSelect.cc diff --git a/src/clstepcore/STEPaggrString.cc b/src/clstepcore/STEPaggrString.cc index 7f2a99579..1aaf752e1 100644 --- a/src/clstepcore/STEPaggrString.cc +++ b/src/clstepcore/STEPaggrString.cc @@ -1,4 +1,4 @@ -#include "core/STEPaggrString.h" +#include "clstepcore/STEPaggrString.h" #include /** \file STEPaggrString.cc diff --git a/src/clstepcore/STEPaggregate.cc b/src/clstepcore/STEPaggregate.cc index e71723251..4336aa6f6 100644 --- a/src/clstepcore/STEPaggregate.cc +++ b/src/clstepcore/STEPaggregate.cc @@ -12,11 +12,11 @@ #include -#include "core/read_func.h" -#include "core/STEPaggregate.h" -#include "core/STEPattribute.h" -#include "core/instmgr.h" -#include "core/ExpDict.h" +#include "clstepcore/read_func.h" +#include "clstepcore/STEPaggregate.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/instmgr.h" +#include "clstepcore/ExpDict.h" /** diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 93a7dcd26..ff07d55b7 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -12,13 +12,13 @@ #include #include -#include "core/read_func.h" -#include "core/STEPattribute.h" -#include "core/instmgr.h" -#include "core/STEPundefined.h" -#include "core/STEPaggregate.h" -#include "core/ExpDict.h" -#include "core/sdai.h" +#include "clstepcore/read_func.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/instmgr.h" +#include "clstepcore/STEPundefined.h" +#include "clstepcore/STEPaggregate.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/sdai.h" // REAL_NUM_PRECISION is defined in STEPattribute.h, and is also used // in aggregate real handling (STEPaggregate.cc) -- IMS 6 Jun 95 diff --git a/src/clstepcore/STEPattributeList.cc b/src/clstepcore/STEPattributeList.cc index 10a0b80b6..2993dd275 100644 --- a/src/clstepcore/STEPattributeList.cc +++ b/src/clstepcore/STEPattributeList.cc @@ -10,8 +10,8 @@ * and is not subject to copyright. */ -#include "core/STEPattributeList.h" -#include "core/STEPattribute.h" +#include "clstepcore/STEPattributeList.h" +#include "clstepcore/STEPattribute.h" AttrListNode::AttrListNode( STEPattribute * a ) { attr = a; diff --git a/src/clstepcore/STEPcomplex.cc b/src/clstepcore/STEPcomplex.cc index f49b1ea4e..9451d6df6 100644 --- a/src/clstepcore/STEPcomplex.cc +++ b/src/clstepcore/STEPcomplex.cc @@ -1,10 +1,10 @@ #include -#include "core/STEPcomplex.h" -#include "core/complexSupport.h" -#include "core/STEPattribute.h" -#include "core/STEPaggregate.h" +#include "clstepcore/STEPcomplex.h" +#include "clstepcore/complexSupport.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/STEPaggregate.h" #include extern const char * diff --git a/src/clstepcore/STEPinvAttrList.cc b/src/clstepcore/STEPinvAttrList.cc index 502af4567..3eaa9d352 100644 --- a/src/clstepcore/STEPinvAttrList.cc +++ b/src/clstepcore/STEPinvAttrList.cc @@ -3,8 +3,8 @@ * derived from STEPattributeList.cc */ -#include "core/STEPinvAttrList.h" -#include "core/ExpDict.h" +#include "clstepcore/STEPinvAttrList.h" +#include "clstepcore/ExpDict.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 ) {} diff --git a/src/clstepcore/STEPundefined.cc b/src/clstepcore/STEPundefined.cc index c74fc7a8c..19c63f37d 100644 --- a/src/clstepcore/STEPundefined.cc +++ b/src/clstepcore/STEPundefined.cc @@ -11,8 +11,8 @@ */ #include // to get the BUFSIZ #define -#include "core/STEPattribute.h" -#include "core/STEPundefined.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/STEPundefined.h" /** \class SCLundefined ** helper functions for reading unknown types diff --git a/src/clstepcore/SingleLinkList.cc b/src/clstepcore/SingleLinkList.cc index 9a4f750dc..19a1f82e7 100644 --- a/src/clstepcore/SingleLinkList.cc +++ b/src/clstepcore/SingleLinkList.cc @@ -10,7 +10,7 @@ * and is not subject to copyright. */ -#include "core/SingleLinkList.h" +#include "clstepcore/SingleLinkList.h" #include diff --git a/src/clstepcore/aggrTypeDescriptor.cc b/src/clstepcore/aggrTypeDescriptor.cc index e1e87a78c..b61b08f72 100644 --- a/src/clstepcore/aggrTypeDescriptor.cc +++ b/src/clstepcore/aggrTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "core/aggrTypeDescriptor.h" +#include "clstepcore/aggrTypeDescriptor.h" STEPaggregate * AggrTypeDescriptor::CreateAggregate() { if( CreateNewAggr ) { diff --git a/src/clstepcore/attrDescriptor.cc b/src/clstepcore/attrDescriptor.cc index 2ce5e74e1..a6a71b65a 100644 --- a/src/clstepcore/attrDescriptor.cc +++ b/src/clstepcore/attrDescriptor.cc @@ -1,4 +1,4 @@ -#include "core/attrDescriptor.h" +#include "clstepcore/attrDescriptor.h" AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType, Logical optional, Logical unique, AttrType_Enum at, diff --git a/src/clstepcore/attrDescriptorList.cc b/src/clstepcore/attrDescriptorList.cc index 987f34243..903180c5b 100644 --- a/src/clstepcore/attrDescriptorList.cc +++ b/src/clstepcore/attrDescriptorList.cc @@ -1,6 +1,6 @@ -#include "core/attrDescriptorList.h" +#include "clstepcore/attrDescriptorList.h" -#include "core/attrDescriptor.h" +#include "clstepcore/attrDescriptor.h" AttrDescriptorList::AttrDescriptorList() { } diff --git a/src/clstepcore/collect.cc b/src/clstepcore/collect.cc index 255036c6a..7a952f556 100644 --- a/src/clstepcore/collect.cc +++ b/src/clstepcore/collect.cc @@ -11,7 +11,7 @@ * Date: 11/14/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Inserts a new ComplexList to our list. The ComplexLists are ordered by diff --git a/src/clstepcore/complexlist.cc b/src/clstepcore/complexlist.cc index 6d2df417b..3dcdff482 100644 --- a/src/clstepcore/complexlist.cc +++ b/src/clstepcore/complexlist.cc @@ -10,7 +10,7 @@ * Date: 01/07/97 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Destructor for ComplexList. diff --git a/src/clstepcore/create_Aggr.cc b/src/clstepcore/create_Aggr.cc index 0fe195bb7..e71cfbc86 100644 --- a/src/clstepcore/create_Aggr.cc +++ b/src/clstepcore/create_Aggr.cc @@ -1,5 +1,5 @@ -#include "core/create_Aggr.h" -#include "core/STEPaggregate.h" +#include "clstepcore/create_Aggr.h" +#include "clstepcore/STEPaggregate.h" EnumAggregate * create_EnumAggregate() { return new EnumAggregate; diff --git a/src/clstepcore/derivedAttribute.cc b/src/clstepcore/derivedAttribute.cc index d361ca1be..8d21b0884 100644 --- a/src/clstepcore/derivedAttribute.cc +++ b/src/clstepcore/derivedAttribute.cc @@ -1,4 +1,4 @@ -#include "core/derivedAttribute.h" +#include "clstepcore/derivedAttribute.h" Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType, Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner ) diff --git a/src/clstepcore/dictSchema.cc b/src/clstepcore/dictSchema.cc index 301d2c42d..aa87b4586 100644 --- a/src/clstepcore/dictSchema.cc +++ b/src/clstepcore/dictSchema.cc @@ -1,7 +1,7 @@ -#include "core/dictSchema.h" +#include "clstepcore/dictSchema.h" -#include "core/typeDescriptor.h" -#include "core/entityDescriptor.h" +#include "clstepcore/typeDescriptor.h" +#include "clstepcore/entityDescriptor.h" Schema::Schema( const char * schemaName ) : _use_interface_list( new Interface_spec__set ), diff --git a/src/clstepcore/dispnode.cc b/src/clstepcore/dispnode.cc index 8b01541ad..15f249d37 100644 --- a/src/clstepcore/dispnode.cc +++ b/src/clstepcore/dispnode.cc @@ -12,12 +12,12 @@ /* $Id: dispnode.cc,v 3.0.1.2 1997/11/05 22:11:39 sauderd DP3.1 $ */ -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" //#include -#include "core/dispnode.h" -#include "core/dispnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" // define this to be the name of the display object class StepEntityEditor; diff --git a/src/clstepcore/dispnodelist.cc b/src/clstepcore/dispnodelist.cc index f00ca79df..7fbd788c3 100644 --- a/src/clstepcore/dispnodelist.cc +++ b/src/clstepcore/dispnodelist.cc @@ -12,13 +12,13 @@ /* $Id: dispnodelist.cc,v 3.0.1.2 1997/11/05 22:11:40 sauderd DP3.1 $ */ -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" -#include "core/dispnode.h" -#include "core/dispnodelist.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" void DisplayNodeList::Remove( GenericNode * node ) { GenNodeList::Remove( node ); diff --git a/src/clstepcore/entityDescriptor.cc b/src/clstepcore/entityDescriptor.cc index 4b4ceaf98..764d77066 100644 --- a/src/clstepcore/entityDescriptor.cc +++ b/src/clstepcore/entityDescriptor.cc @@ -1,10 +1,10 @@ #include -#include "core/entityDescriptor.h" -#include "core/Registry.h" -#include "core/attrDescriptor.h" -#include "core/inverseAttribute.h" -#include "core/SubSuperIterators.h" +#include "clstepcore/entityDescriptor.h" +#include "clstepcore/Registry.h" +#include "clstepcore/attrDescriptor.h" +#include "clstepcore/inverseAttribute.h" +#include "clstepcore/SubSuperIterators.h" EntityDescriptor::EntityDescriptor( ) : _abstractEntity( LUnknown ), _extMapping( LUnknown ), diff --git a/src/clstepcore/entityDescriptorList.cc b/src/clstepcore/entityDescriptorList.cc index bef52120a..e23baeabb 100644 --- a/src/clstepcore/entityDescriptorList.cc +++ b/src/clstepcore/entityDescriptorList.cc @@ -1,4 +1,4 @@ -#include "core/entityDescriptorList.h" +#include "clstepcore/entityDescriptorList.h" EntityDescLinkNode::EntityDescLinkNode() { _entityDesc = 0; diff --git a/src/clstepcore/entlist.cc b/src/clstepcore/entlist.cc index 086f3bd76..e7c0d7c89 100644 --- a/src/clstepcore/entlist.cc +++ b/src/clstepcore/entlist.cc @@ -13,7 +13,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Returns the number of EntLists in this's list (EntList->next, next->next diff --git a/src/clstepcore/entnode.cc b/src/clstepcore/entnode.cc index 0d594c993..bc2141360 100644 --- a/src/clstepcore/entnode.cc +++ b/src/clstepcore/entnode.cc @@ -11,7 +11,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Given a list of entity names, creates a sorted linked list of EntNodes diff --git a/src/clstepcore/enumTypeDescriptor.cc b/src/clstepcore/enumTypeDescriptor.cc index 653a1cc0d..61c4eef0f 100644 --- a/src/clstepcore/enumTypeDescriptor.cc +++ b/src/clstepcore/enumTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "core/enumTypeDescriptor.h" +#include "clstepcore/enumTypeDescriptor.h" /* * why have EnumTypeDescriptor + EnumerationTypeDescriptor ??? diff --git a/src/clstepcore/explicitItemId.cc b/src/clstepcore/explicitItemId.cc index 8436befd5..b7177c189 100644 --- a/src/clstepcore/explicitItemId.cc +++ b/src/clstepcore/explicitItemId.cc @@ -1,4 +1,4 @@ -#include "core/explicitItemId.h" +#include "clstepcore/explicitItemId.h" Explicit_item_id::Explicit_item_id() { _local_definition = 0; diff --git a/src/clstepcore/globalRule.cc b/src/clstepcore/globalRule.cc index 06629f2c1..227562faa 100644 --- a/src/clstepcore/globalRule.cc +++ b/src/clstepcore/globalRule.cc @@ -1,4 +1,4 @@ -#include "core/globalRule.h" +#include "clstepcore/globalRule.h" Global_rule::Global_rule() : _entities( 0 ), _where_rules( 0 ), _parent_schema( 0 ) { diff --git a/src/clstepcore/implicitItemId.cc b/src/clstepcore/implicitItemId.cc index dd43fc1f1..963844314 100644 --- a/src/clstepcore/implicitItemId.cc +++ b/src/clstepcore/implicitItemId.cc @@ -1,4 +1,4 @@ -#include "core/implicitItemId.h" +#include "clstepcore/implicitItemId.h" Implicit_item_id::Implicit_item_id() { _local_definition = 0; diff --git a/src/clstepcore/instmgr.cc b/src/clstepcore/instmgr.cc index f0ef13892..6b6cc6a7e 100644 --- a/src/clstepcore/instmgr.cc +++ b/src/clstepcore/instmgr.cc @@ -16,8 +16,8 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "core/sdai.h" -#include "core/instmgr.h" +#include "clstepcore/sdai.h" +#include "clstepcore/instmgr.h" /////////////////////////////////////////////////////////////////////////////// // debug_level >= 2 => tells when a command is chosen diff --git a/src/clstepcore/interfaceSpec.cc b/src/clstepcore/interfaceSpec.cc index c8698789e..b0ed39bc5 100644 --- a/src/clstepcore/interfaceSpec.cc +++ b/src/clstepcore/interfaceSpec.cc @@ -1,4 +1,4 @@ -#include "core/interfaceSpec.h" +#include "clstepcore/interfaceSpec.h" Interface_spec__set::Interface_spec__set( int defaultSize ) { _bufsize = defaultSize; diff --git a/src/clstepcore/interfacedItem.cc b/src/clstepcore/interfacedItem.cc index aadfce68d..9ddb5b5a5 100644 --- a/src/clstepcore/interfacedItem.cc +++ b/src/clstepcore/interfacedItem.cc @@ -1,4 +1,4 @@ -#include "core/interfacedItem.h" +#include "clstepcore/interfacedItem.h" Interfaced_item::Interfaced_item() { } diff --git a/src/clstepcore/inverseAttribute.cc b/src/clstepcore/inverseAttribute.cc index be7f7cfa3..512c71c34 100644 --- a/src/clstepcore/inverseAttribute.cc +++ b/src/clstepcore/inverseAttribute.cc @@ -1,4 +1,4 @@ -#include "core/inverseAttribute.h" +#include "clstepcore/inverseAttribute.h" #include const char * Inverse_attribute::AttrExprDefStr( std::string & s ) const { diff --git a/src/clstepcore/inverseAttributeList.cc b/src/clstepcore/inverseAttributeList.cc index e1767e3b3..2dd7d46b0 100644 --- a/src/clstepcore/inverseAttributeList.cc +++ b/src/clstepcore/inverseAttributeList.cc @@ -1,5 +1,5 @@ -#include "core/inverseAttributeList.h" -#include "core/inverseAttribute.h" +#include "clstepcore/inverseAttributeList.h" +#include "clstepcore/inverseAttribute.h" Inverse_attributeLinkNode::Inverse_attributeLinkNode() { _invAttr = 0; diff --git a/src/clstepcore/match-ors.cc b/src/clstepcore/match-ors.cc index 2a97254ab..72427ca6b 100644 --- a/src/clstepcore/match-ors.cc +++ b/src/clstepcore/match-ors.cc @@ -13,7 +13,7 @@ * Date: 10/17/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Loops through descendants of this, invoking their matchOR functions. diff --git a/src/clstepcore/mgrnode.cc b/src/clstepcore/mgrnode.cc index f6ceafcaf..a7d13b538 100644 --- a/src/clstepcore/mgrnode.cc +++ b/src/clstepcore/mgrnode.cc @@ -12,14 +12,14 @@ /* $Id: mgrnode.cc,v 3.0.1.3 1997/11/05 22:11:37 sauderd DP3.1 $ */ -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" -#include "core/dispnode.h" -#include "core/dispnodelist.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" -#include "core/instmgr.h" +#include "clstepcore/instmgr.h" //#include -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include diff --git a/src/clstepcore/mgrnodearray.cc b/src/clstepcore/mgrnodearray.cc index 0467f73a1..d777b596f 100644 --- a/src/clstepcore/mgrnodearray.cc +++ b/src/clstepcore/mgrnodearray.cc @@ -32,9 +32,9 @@ static int PrintFunctionTrace = 2; // values within functions get printed out //static int PrintValues = 3; -#include "core/mgrnodearray.h" +#include "clstepcore/mgrnodearray.h" //#include -#include "core/sdai.h" +#include "clstepcore/sdai.h" #include // to get bcopy() - ANSI diff --git a/src/clstepcore/mgrnodelist.cc b/src/clstepcore/mgrnodelist.cc index e477e366c..77ee20100 100644 --- a/src/clstepcore/mgrnodelist.cc +++ b/src/clstepcore/mgrnodelist.cc @@ -12,10 +12,10 @@ /* $Id: mgrnodelist.cc,v 3.0.1.2 1997/11/05 22:11:39 sauderd DP3.1 $ */ -#include "core/mgrnode.h" -#include "core/mgrnodelist.h" -#include "core/dispnode.h" -#include "core/dispnodelist.h" +#include "clstepcore/mgrnode.h" +#include "clstepcore/mgrnodelist.h" +#include "clstepcore/dispnode.h" +#include "clstepcore/dispnodelist.h" MgrNodeList::MgrNodeList( stateEnum type ) : GenNodeList( new MgrNode() ) { // if(debug_level >= PrintFunctionTrace) diff --git a/src/clstepcore/multlist.cc b/src/clstepcore/multlist.cc index 9e30e5ab1..b36488377 100644 --- a/src/clstepcore/multlist.cc +++ b/src/clstepcore/multlist.cc @@ -13,7 +13,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Deletes the childList of this, before this is deleted. diff --git a/src/clstepcore/needFunc.cc b/src/clstepcore/needFunc.cc index 731230d60..e72215fed 100644 --- a/src/clstepcore/needFunc.cc +++ b/src/clstepcore/needFunc.cc @@ -1,4 +1,4 @@ -#include "core/needFunc.h" +#include "clstepcore/needFunc.h" /////////////////////////////////////////////////////////////////////////////// // Function defined as a stub (necessary to use the scl) diff --git a/src/clstepcore/non-ors.cc b/src/clstepcore/non-ors.cc index 78c3c5fe6..14b6a4f6c 100644 --- a/src/clstepcore/non-ors.cc +++ b/src/clstepcore/non-ors.cc @@ -10,7 +10,7 @@ * Date: 10/17/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Checks if we match the nodes of ents. If only one unmarked is left diff --git a/src/clstepcore/orlist.cc b/src/clstepcore/orlist.cc index 6e58242eb..f5fa185b0 100644 --- a/src/clstepcore/orlist.cc +++ b/src/clstepcore/orlist.cc @@ -10,7 +10,7 @@ * Date: 9/18/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" /** * Check if we matched nm. We have two possibilities here: If we have a diff --git a/src/clstepcore/print.cc b/src/clstepcore/print.cc index b30643b06..63759b9fc 100644 --- a/src/clstepcore/print.cc +++ b/src/clstepcore/print.cc @@ -7,7 +7,7 @@ * Date: 10/31/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" // Local function prototypes: static char * joinText( JoinType, char * ); diff --git a/src/clstepcore/read_func.cc b/src/clstepcore/read_func.cc index 85fb28a29..9f31db401 100644 --- a/src/clstepcore/read_func.cc +++ b/src/clstepcore/read_func.cc @@ -1,10 +1,10 @@ -#include "utils/errordesc.h" +#include "clutils/errordesc.h" #include -#include "core/sdai.h" -#include "core/read_func.h" -#include "core/STEPattribute.h" -#include "utils/Str.h" +#include "clstepcore/sdai.h" +#include "clstepcore/read_func.h" +#include "clstepcore/STEPattribute.h" +#include "clutils/Str.h" const int RealNumPrecision = REAL_NUM_PRECISION; diff --git a/src/clstepcore/schRename.cc b/src/clstepcore/schRename.cc index b0f96c4c0..6e5e12686 100644 --- a/src/clstepcore/schRename.cc +++ b/src/clstepcore/schRename.cc @@ -1,4 +1,4 @@ -#include "core/schRename.h" +#include "clstepcore/schRename.h" /** diff --git a/src/clstepcore/sdai.cc b/src/clstepcore/sdai.cc index 00ea0f932..ec96a63b3 100644 --- a/src/clstepcore/sdai.cc +++ b/src/clstepcore/sdai.cc @@ -1,7 +1,7 @@ #include #include -#include "core/sdai.h" +#include "clstepcore/sdai.h" const char * SCLversion = "STEPcode, github.com/stepcode/stepcode"; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index 1b39b12c4..c44a2c5ea 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -11,13 +11,13 @@ */ #include -#include "core/sdai.h" -#include "core/instmgr.h" -#include "core/STEPcomplex.h" -#include "core/STEPattribute.h" -#include "core/read_func.h" //for ReadTokenSeparator, used when comments are inside entities +#include "clstepcore/sdai.h" +#include "clstepcore/instmgr.h" +#include "clstepcore/STEPcomplex.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/read_func.h" //for ReadTokenSeparator, used when comments are inside entities -#include "core/sdaiApplication_instance.h" +#include "clstepcore/sdaiApplication_instance.h" #include "superInvAttrIter.h" SDAI_Application_instance NilSTEPentity; diff --git a/src/clstepcore/sdaiSelect.cc b/src/clstepcore/sdaiSelect.cc index 5c3168281..95e6d83bc 100644 --- a/src/clstepcore/sdaiSelect.cc +++ b/src/clstepcore/sdaiSelect.cc @@ -11,11 +11,11 @@ */ #include // to get the BUFSIZ #define -#include "core/ExpDict.h" +#include "clstepcore/ExpDict.h" #include #include -#include "core/sdai.h" -#include "core/STEPattribute.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" #ifdef SC_LOGGING #include diff --git a/src/clstepcore/selectTypeDescriptor.cc b/src/clstepcore/selectTypeDescriptor.cc index c3737b85b..e143a3a30 100644 --- a/src/clstepcore/selectTypeDescriptor.cc +++ b/src/clstepcore/selectTypeDescriptor.cc @@ -1,4 +1,4 @@ -#include "core/selectTypeDescriptor.h" +#include "clstepcore/selectTypeDescriptor.h" /////////////////////////////////////////////////////////////////////////////// // SelectTypeDescriptor functions diff --git a/src/clstepcore/superInvAttrIter.h b/src/clstepcore/superInvAttrIter.h index 0f7853bc1..6228b67be 100644 --- a/src/clstepcore/superInvAttrIter.h +++ b/src/clstepcore/superInvAttrIter.h @@ -1,8 +1,8 @@ #ifndef SUPERINVATTRITER_H #define SUPERINVATTRITER_H -#include "core/SubSuperIterators.h" -#include "core/ExpDict.h" +#include "clstepcore/SubSuperIterators.h" +#include "clstepcore/ExpDict.h" /** * this class implements an iterator for inverse attributes in an EntityDescriptor's supertypes diff --git a/src/clstepcore/test/test_SupertypesIterator.cc b/src/clstepcore/test/test_SupertypesIterator.cc index 52f6ca795..084189bf0 100644 --- a/src/clstepcore/test/test_SupertypesIterator.cc +++ b/src/clstepcore/test/test_SupertypesIterator.cc @@ -4,8 +4,8 @@ //subtypesiterator shouldn't need tested separately from supertypesiterator since there is very little difference -#include "core/SubSuperIterators.h" -#include "core/ExpDict.h" +#include "clstepcore/SubSuperIterators.h" +#include "clstepcore/ExpDict.h" #include int main( int /*argc*/, char ** /*argv*/ ) { diff --git a/src/clstepcore/test/test_null_attr.cc b/src/clstepcore/test/test_null_attr.cc index c25025614..95c7dcd02 100644 --- a/src/clstepcore/test/test_null_attr.cc +++ b/src/clstepcore/test/test_null_attr.cc @@ -1,6 +1,6 @@ -#include "core/ExpDict.h" -#include "core/STEPattribute.h" -#include "dai/sdaiString.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/STEPattribute.h" +#include "cldai/sdaiString.h" AttrDescriptor *ad = 0; EntityDescriptor *ed = 0; diff --git a/src/clstepcore/test/test_operators_SDAI_Select.cc b/src/clstepcore/test/test_operators_SDAI_Select.cc index a0e920c38..b82d20ddc 100644 --- a/src/clstepcore/test/test_operators_SDAI_Select.cc +++ b/src/clstepcore/test/test_operators_SDAI_Select.cc @@ -6,9 +6,9 @@ #include -#include "core/ExpDict.h" -#include "core/baseType.h" -#include "core/sdaiSelect.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/baseType.h" +#include "clstepcore/sdaiSelect.h" using namespace std; diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index b5266cde3..a64d274de 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -1,7 +1,7 @@ ///test constructors, destructor, shallow copy, assignment operators for STEPattribute -#include "core/STEPattribute.h" -#include "core/ExpDict.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" #include diff --git a/src/clstepcore/trynext.cc b/src/clstepcore/trynext.cc index 4b9571a20..dd2941edd 100644 --- a/src/clstepcore/trynext.cc +++ b/src/clstepcore/trynext.cc @@ -11,7 +11,7 @@ * Date: 10/24/96 * *****************************************************************************/ -#include "core/complexSupport.h" +#include "clstepcore/complexSupport.h" // Local function prototypes: static EntList * firstCandidate( EntList * ); diff --git a/src/clstepcore/typeDescriptor.cc b/src/clstepcore/typeDescriptor.cc index c1394c8f6..1d654f609 100644 --- a/src/clstepcore/typeDescriptor.cc +++ b/src/clstepcore/typeDescriptor.cc @@ -1,4 +1,4 @@ -#include "core/typeDescriptor.h" +#include "clstepcore/typeDescriptor.h" TypeDescriptor::TypeDescriptor( ) : _name( 0 ), altNames( 0 ), _fundamentalType( UNKNOWN_TYPE ), diff --git a/src/clstepcore/typeDescriptorList.cc b/src/clstepcore/typeDescriptorList.cc index 2a5444378..bbc91de9e 100644 --- a/src/clstepcore/typeDescriptorList.cc +++ b/src/clstepcore/typeDescriptorList.cc @@ -1,4 +1,4 @@ -#include "core/typeDescriptorList.h" +#include "clstepcore/typeDescriptorList.h" TypeDescLinkNode::TypeDescLinkNode() { _typeDesc = 0; diff --git a/src/clstepcore/typeOrRuleVar.cc b/src/clstepcore/typeOrRuleVar.cc index dec362a28..c9b823cbf 100644 --- a/src/clstepcore/typeOrRuleVar.cc +++ b/src/clstepcore/typeOrRuleVar.cc @@ -1,4 +1,4 @@ -#include "core/typeOrRuleVar.h" +#include "clstepcore/typeOrRuleVar.h" #include diff --git a/src/clstepcore/uniquenessRule.cc b/src/clstepcore/uniquenessRule.cc index fd8ba05ca..d22bf2c2c 100644 --- a/src/clstepcore/uniquenessRule.cc +++ b/src/clstepcore/uniquenessRule.cc @@ -1,4 +1,4 @@ -#include "core/uniquenessRule.h" +#include "clstepcore/uniquenessRule.h" #include diff --git a/src/clstepcore/whereRule.cc b/src/clstepcore/whereRule.cc index 44f23dc14..191b1ec36 100644 --- a/src/clstepcore/whereRule.cc +++ b/src/clstepcore/whereRule.cc @@ -1,4 +1,4 @@ -#include "core/whereRule.h" +#include "clstepcore/whereRule.h" Where_rule::Where_rule() { _type_or_rule = 0; diff --git a/src/clutils/Str.cc b/src/clutils/Str.cc index ec8f5b3da..1f6a3dce3 100644 --- a/src/clutils/Str.cc +++ b/src/clutils/Str.cc @@ -9,7 +9,7 @@ * and is not subject to copyright. */ -#include "utils/Str.h" +#include "clutils/Str.h" #include #include diff --git a/src/clutils/dirobj.cc b/src/clutils/dirobj.cc index 97dc4fda6..e0e3f970a 100644 --- a/src/clutils/dirobj.cc +++ b/src/clutils/dirobj.cc @@ -40,7 +40,7 @@ */ #include "config.h" -#include "utils/dirobj.h" +#include "clutils/dirobj.h" #ifdef HAVE_DIRENT_H # include #endif diff --git a/src/clutils/errordesc.cc b/src/clutils/errordesc.cc index 4cfb1f2c1..17a2de465 100644 --- a/src/clutils/errordesc.cc +++ b/src/clutils/errordesc.cc @@ -10,8 +10,8 @@ * and is not subject to copyright. */ -#include "utils/errordesc.h" -#include "utils/Str.h" +#include "clutils/errordesc.h" +#include "clutils/Str.h" DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF; ostream * ErrorDescriptor::_out = 0; diff --git a/src/clutils/gennode.cc b/src/clutils/gennode.cc index e1f7d83b9..c8a993632 100644 --- a/src/clutils/gennode.cc +++ b/src/clutils/gennode.cc @@ -12,8 +12,8 @@ /* $Id: gennode.cc,v 3.0.1.4 1997/11/05 22:33:47 sauderd DP3.1 $ */ -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" ////////////////////////////////////////////////////////////////////////////// // class GenericNode inline functions that depend on other classes diff --git a/src/clutils/gennodearray.cc b/src/clutils/gennodearray.cc index 1645589d5..22a9a73d3 100644 --- a/src/clutils/gennodearray.cc +++ b/src/clutils/gennodearray.cc @@ -13,9 +13,9 @@ #include "config.h" -#include "utils/gennode.h" -#include "utils/gennodelist.h" -#include "utils/gennodearray.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" +#include "clutils/gennodearray.h" #ifndef HAVE_MEMMOVE extern "C" { diff --git a/src/clutils/gennodelist.cc b/src/clutils/gennodelist.cc index 7650781cf..c75d7a712 100644 --- a/src/clutils/gennodelist.cc +++ b/src/clutils/gennodelist.cc @@ -12,10 +12,10 @@ /* $Id: gennodelist.cc,v 3.0.1.2 1997/11/05 22:33:49 sauderd DP3.1 $ */ -#include "utils/gennode.h" -#include "utils/gennodelist.h" +#include "clutils/gennode.h" +#include "clutils/gennodelist.h" //#include -#include "utils/gennodearray.h" +#include "clutils/gennodearray.h" // inserts after existNode void GenNodeList::InsertAfter( GenericNode * newNode, diff --git a/src/clutils/sc_hash.cc b/src/clutils/sc_hash.cc index db6eda0ec..8ed4c54ab 100644 --- a/src/clutils/sc_hash.cc +++ b/src/clutils/sc_hash.cc @@ -5,7 +5,7 @@ * also, hcreate/hdestroy routines added to simulate hsearch(3). */ -#include "utils/sc_hash.h" +#include "clutils/sc_hash.h" #include #include #include diff --git a/src/exp2cxx/classes_wrapper.cc b/src/exp2cxx/classes_wrapper.cc index b668361b9..ef874a790 100644 --- a/src/exp2cxx/classes_wrapper.cc +++ b/src/exp2cxx/classes_wrapper.cc @@ -75,12 +75,12 @@ void print_file_header( FILES * files ) { fprintf( files->incall, "#include \n" ); fprintf( files->incall, "#endif\n" ); - fprintf( files->incall, "#include \"core/sdai.h\"\n\n" ); - fprintf( files->incall, "\n#include \"core/Registry.h\"\n" ); - fprintf( files->incall, "\n#include \"core/STEPaggregate.h\"\n" ); - fprintf( files->incall, "\n#include \"core/STEPundefined.h\"\n" ); - fprintf( files->incall, "\n#include \"core/ExpDict.h\"\n" ); - fprintf( files->incall, "\n#include \"core/STEPattribute.h\"\n" ); + fprintf( files->incall, "#include \"clstepcore/sdai.h\"\n\n" ); + fprintf( files->incall, "\n#include \"clstepcore/Registry.h\"\n" ); + fprintf( files->incall, "\n#include \"clstepcore/STEPaggregate.h\"\n" ); + fprintf( files->incall, "\n#include \"clstepcore/STEPundefined.h\"\n" ); + fprintf( files->incall, "\n#include \"clstepcore/ExpDict.h\"\n" ); + fprintf( files->incall, "\n#include \"clstepcore/STEPattribute.h\"\n" ); fprintf( files->incall, "\n#include \n" ); @@ -494,7 +494,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol, int suffix ) "#include \"schema.h\"\n" "#endif\n" ); #endif - fprintf( initfile, "#include \"core/Registry.h\"\n#include \n" ); + fprintf( initfile, "#include \"clstepcore/Registry.h\"\n#include \n" ); fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm ); diff --git a/src/exp2cxx/multpass.c b/src/exp2cxx/multpass.c index 2db9f744e..03e1eb885 100644 --- a/src/exp2cxx/multpass.c +++ b/src/exp2cxx/multpass.c @@ -159,7 +159,7 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files ) // which hasn't been closed yet. (That's done on 2nd line below.)) */ fprintf( files->initall, " reg.SetCompCollect( gencomplex() );\n" ); fprintf( files->initall, "}\n\n" ); - fprintf( files->incall, "\n#include \"core/complexSupport.h\"\n" ); + fprintf( files->incall, "\n#include \"clstepcore/complexSupport.h\"\n" ); fprintf( files->incall, "ComplexCollect *gencomplex();\n" ); /* Function GetModelContents() is printed at the end of the schema.xx diff --git a/src/exp2cxx/write.cc b/src/exp2cxx/write.cc index 1d73dc46a..da1ecb747 100644 --- a/src/exp2cxx/write.cc +++ b/src/exp2cxx/write.cc @@ -116,7 +116,7 @@ static void writeheader( ostream & os, int noLists ) << " * file, however, there are no complex entities, so this\n" << " * function is a stub.\n" << " */" << endl << endl; - os << "#include \"core/complexSupport.h\"\n\n"; + os << "#include \"clstepcore/complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << "{" << endl; return; @@ -128,7 +128,7 @@ static void writeheader( ostream & os, int noLists ) << " * support structures. The structures will be used in the SCL to\n" << " * validate user requests to instantiate complex entities.\n" << " */" << endl << endl; - os << "#include \"core/complexSupport.h\"\n\n"; + os << "#include \"clstepcore/complexSupport.h\"\n\n"; os << "ComplexCollect *gencomplex()" << endl; os << " /*" << endl << " * This function contains instantiation statements for all the\n" diff --git a/src/test/p21read/p21read.cc b/src/test/p21read/p21read.cc index cd7bd9748..cf96b86dd 100644 --- a/src/test/p21read/p21read.cc +++ b/src/test/p21read/p21read.cc @@ -13,12 +13,12 @@ */ extern void SchemaInit( class Registry & ); -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #include "sc_benchmark.h" diff --git a/src/test/scl2html/scl2html.cc b/src/test/scl2html/scl2html.cc index 72160c7df..afe65b11f 100644 --- a/src/test/scl2html/scl2html.cc +++ b/src/test/scl2html/scl2html.cc @@ -49,7 +49,7 @@ void PrintAttrTypeWithAnchor( const TypeDescriptor * typeDesc, ofstream & outhtml ) { std::string buf; - // The type. See core/baseType.h for info + // The type. See clstepcore/baseType.h for info PrimitiveType base = typeDesc->Type(); // the type descriptor for the "referent type," if any. diff --git a/src/test/tests.h b/src/test/tests.h index 504a6f5a3..0494b55d2 100644 --- a/src/test/tests.h +++ b/src/test/tests.h @@ -16,10 +16,10 @@ #include /* General SCL stuff */ -#include "core/ExpDict.h" -#include "editor/STEPfile.h" -#include "core/STEPattribute.h" -#include "core/sdai.h" +#include "clstepcore/ExpDict.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/sdai.h" /* Stuff more or less specifically for the Example schema */ /* The only program that needs this is tstatic. Since the other programs */ diff --git a/test/cpp/schema_specific/aggregate_bound_runtime.cc b/test/cpp/schema_specific/aggregate_bound_runtime.cc index 72b507634..f459697e6 100644 --- a/test/cpp/schema_specific/aggregate_bound_runtime.cc +++ b/test/cpp/schema_specific/aggregate_bound_runtime.cc @@ -1,10 +1,10 @@ -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/attribute.cc b/test/cpp/schema_specific/attribute.cc index 4c8674da2..4fab32933 100644 --- a/test/cpp/schema_specific/attribute.cc +++ b/test/cpp/schema_specific/attribute.cc @@ -3,12 +3,12 @@ * Test attribute access; uses a tiny schema similar to a subset of IFC2x3 */ #include "config.h" -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 0ec52d47d..52cc3628b 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -5,12 +5,12 @@ */ #include "config.h" #include "SubSuperIterators.h" -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr2.cc b/test/cpp/schema_specific/inverse_attr2.cc index 5948660e0..cdf8dbbd0 100644 --- a/test/cpp/schema_specific/inverse_attr2.cc +++ b/test/cpp/schema_specific/inverse_attr2.cc @@ -4,12 +4,12 @@ ** */ #include "config.h" -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #ifdef HAVE_UNISTD_H diff --git a/test/cpp/schema_specific/inverse_attr3.cc b/test/cpp/schema_specific/inverse_attr3.cc index a20a822c1..bb4ce0929 100644 --- a/test/cpp/schema_specific/inverse_attr3.cc +++ b/test/cpp/schema_specific/inverse_attr3.cc @@ -5,13 +5,13 @@ * This test originally used STEPfile, which didn't work. Fixing STEPfile would have been very difficult, it uses lazyInstMgr now. */ #include "config.h" -#include "lazy/lazyInstMgr.h" +#include "cllazyfile/lazyInstMgr.h" #include -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include #include diff --git a/test/cpp/schema_specific/stepfile_rw_progress.cc b/test/cpp/schema_specific/stepfile_rw_progress.cc index 4ee676627..1fe5cb0dc 100644 --- a/test/cpp/schema_specific/stepfile_rw_progress.cc +++ b/test/cpp/schema_specific/stepfile_rw_progress.cc @@ -1,10 +1,10 @@ -#include "editor/STEPfile.h" -#include "core/sdai.h" -#include "core/STEPattribute.h" -#include "core/ExpDict.h" -#include "core/Registry.h" -#include "utils/errordesc.h" +#include "cleditor/STEPfile.h" +#include "clstepcore/sdai.h" +#include "clstepcore/STEPattribute.h" +#include "clstepcore/ExpDict.h" +#include "clstepcore/Registry.h" +#include "clutils/errordesc.h" #include #include From f35d25d93dd5d039627a4b38a89253fd7a137074 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:41:17 -0400 Subject: [PATCH 240/244] Missed a header conversion --- test/cpp/schema_specific/inverse_attr1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/schema_specific/inverse_attr1.cc b/test/cpp/schema_specific/inverse_attr1.cc index 52cc3628b..9f776a37a 100644 --- a/test/cpp/schema_specific/inverse_attr1.cc +++ b/test/cpp/schema_specific/inverse_attr1.cc @@ -4,7 +4,7 @@ ** */ #include "config.h" -#include "SubSuperIterators.h" +#include "clstepcore/SubSuperIterators.h" #include "cleditor/STEPfile.h" #include "clstepcore/sdai.h" #include "clstepcore/STEPattribute.h" From 6fd22a1e0af4c42c428f60764bf6df3e896e5aec Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Mon, 17 Oct 2022 10:02:16 -0400 Subject: [PATCH 241/244] Make expparse explicitly depend on scanner header Without this dependency, we get intermittent failures where parallel builds attempt the expparse.c compile before the necessary header is in place. --- src/express/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index ae4e97bd0..e5c0dfe04 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -18,6 +18,7 @@ if(SC_GENERATE_LP_SOURCES) add_library(objlib_expparse_c OBJECT ${LEMON_ExpParser_OUTPUTS}) set_property(TARGET objlib_expparse_c PROPERTY POSITION_INDEPENDENT_CODE ON) + set_source_files_properties(${LEMON_ExpParser_OUTPUTS} PROPERTIES OBJECT_DEPENDS "${PERPLEX_ExpScanner_HDR}") else(SC_GENERATE_LP_SOURCES) add_subdirectory(generated) From 592823b64b9e2a108f6de495b5580c083fb1a000 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:54:33 -0400 Subject: [PATCH 242/244] List the generated .h file explicitly as an output Occasional compile problems with libexpress appear to be an attempt to compile with an incompletely generated header. Make the dependency explicit to assist CMake in generating proper build ordering rules. --- cmake/FindLEMON.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index 7ad58984e..83c63c487 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -141,7 +141,7 @@ if (LEMON_EXECUTABLE) # execute lemon add_custom_command( - OUTPUT ${_out_src_file} + OUTPUT ${_out_src_file} ${_basename}.h COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file} DEPENDS ${Name}_input_cpy WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -152,7 +152,7 @@ if (LEMON_EXECUTABLE) add_custom_command( OUTPUT ${_out_hdr_file} COMMAND ${CMAKE_COMMAND} ARGS -E rename ${_basename}.h ${_out_hdr_file} - DEPENDS ${_out_src_file} + DEPENDS ${_out_src_file} ${_basename}.h WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) From db2c3d8e5ba75684373830704fbe0efdb018ce48 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:57:10 -0400 Subject: [PATCH 243/244] Minor updates for newer compilers The Wstrict-prototypes flag didn't like some of the stepcode function definitions. Also add a couple includes and defines for isascii. --- include/express/object.h | 2 +- src/express/expparse.y | 7 +++---- src/express/expscan.l | 7 +++++-- src/express/generated/expparse.c | 7 +++---- src/express/generated/expscan.c | 6 +++++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/express/object.h b/include/express/object.h index e5736f45b..15e4a435f 100644 --- a/include/express/object.h +++ b/include/express/object.h @@ -68,7 +68,7 @@ /***************************/ struct Object { - struct Symbol_ * ( *get_symbol )(); + struct Symbol_ * ( *get_symbol )( void * ); char * type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */ int bits; /**< a bitwise selector of a type, i.e. OBJ_XX_BITS */ }; diff --git a/src/express/expparse.y b/src/express/expparse.y index f6bc296c2..92a9bfcca 100644 --- a/src/express/expparse.y +++ b/src/express/expparse.y @@ -51,7 +51,7 @@ YYSTYPE yylval; Express yyexpresult; /* hook to everything built by parser */ Symbol *interface_schema; /* schema of interest in use/ref clauses */ - void (*interface_func)(); /* func to attach rename clauses */ + void (*interface_func)(struct Scope_ *, Symbol *, Symbol *, Symbol *); /* func to attach rename clauses */ /* record schemas found in a single parse here, allowing them to be */ /* differentiated from other schemas parsed earlier */ @@ -106,7 +106,7 @@ YYSTYPE yylval; #define ERROR(code) ERRORreport(code, yylineno) -void parserInitState() +void parserInitState( void ) { scope = scopes; /* no need to define scope->this */ @@ -402,8 +402,7 @@ aggregate_type(A) ::= TOK_AGGREGATE TOK_OF parameter_type(B). Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } aggregate_type(A) ::= TOK_AGGREGATE TOK_COLON TOK_IDENTIFIER(B) TOK_OF diff --git a/src/express/expscan.l b/src/express/expscan.l index cbd56c535..755e21fc1 100644 --- a/src/express/expscan.l +++ b/src/express/expscan.l @@ -98,9 +98,12 @@ * * Revision 4.1 90/09/13 16:29:00 clark * BPR 2.1 alpha - * + * */ - +#include +#if !defined(isascii) && defined(__isascii) +# define isascii __isascii +#endif #include "express/basic.h" #include "express/error.h" #include "express/lexact.h" diff --git a/src/express/generated/expparse.c b/src/express/generated/expparse.c index 217c349d6..393d5c303 100644 --- a/src/express/generated/expparse.c +++ b/src/express/generated/expparse.c @@ -57,7 +57,7 @@ YYSTYPE yylval; Express yyexpresult; /* hook to everything built by parser */ Symbol *interface_schema; /* schema of interest in use/ref clauses */ - void (*interface_func)(); /* func to attach rename clauses */ + void (*interface_func)(struct Scope_ *, Symbol *, Symbol *, Symbol *); /* func to attach rename clauses */ /* record schemas found in a single parse here, allowing them to be */ /* differentiated from other schemas parsed earlier */ @@ -112,7 +112,7 @@ YYSTYPE yylval; #define ERROR(code) ERRORreport(code, yylineno) -void parserInitState() +void parserInitState( void ) { scope = scopes; /* no need to define scope->this */ @@ -2348,8 +2348,7 @@ static void yy_reduce( Symbol sym; sym.line = yylineno; sym.filename = current_filename; - ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, - CURRENT_SCOPE_NAME); + ERRORreport_with_symbol(UNLABELLED_PARAM_TYPE, &sym, CURRENT_SCOPE_NAME); } } #line 2356 "expparse.c" diff --git a/src/express/generated/expscan.c b/src/express/generated/expscan.c index b78b863a5..0b60210cb 100644 --- a/src/express/generated/expscan.c +++ b/src/express/generated/expscan.c @@ -99,6 +99,10 @@ * Revision 4.1 90/09/13 16:29:00 clark * BPR 2.1 alpha * */ +#include +#if !defined(isascii) && defined(__isascii) +# define isascii __isascii +#endif #include "express/basic.h" #include "express/error.h" #include "express/lexact.h" @@ -617,7 +621,7 @@ getTokenText(perplex_t scanner) #define yyextra scanner->extra static perplex_t -newScanner() +newScanner(void) { perplex_t scanner; scanner = (perplex_t)calloc(1, sizeof(struct perplex)); From 56da4ab614cb60f45ab093f31ac263223cb39ad9 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:26:58 -0400 Subject: [PATCH 244/244] Update ap203min example for new header setup. --- example/ap203min/CMakeLists.txt | 4 ---- example/ap203min/ap203min.cpp | 18 +++++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/example/ap203min/CMakeLists.txt b/example/ap203min/CMakeLists.txt index 6537d3e80..5aea13a4b 100644 --- a/example/ap203min/CMakeLists.txt +++ b/example/ap203min/CMakeLists.txt @@ -58,10 +58,6 @@ add_subdirectory(${STEPCODE_ROOT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/sc" EXCLUDE_F # Set up STEPcode include directories. set(STEPCODE_INCLUDE_DIR - ${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} diff --git a/example/ap203min/ap203min.cpp b/example/ap203min/ap203min.cpp index 5e05b7b59..1a6039f83 100644 --- a/example/ap203min/ap203min.cpp +++ b/example/ap203min/ap203min.cpp @@ -49,15 +49,15 @@ // $./AP203Minimum // AP203Minimum outfile.stp -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include #include "schema.h"